当前位置: 首页>>代码示例>>PHP>>正文


PHP Util::strtolower方法代码示例

本文整理汇总了PHP中Util::strtolower方法的典型用法代码示例。如果您正苦于以下问题:PHP Util::strtolower方法的具体用法?PHP Util::strtolower怎么用?PHP Util::strtolower使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Util的用法示例。


在下文中一共展示了Util::strtolower方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: member

 /**
  * Search for a member - by real_name or member_name by default.
  *
  * @return string
  */
 public function member()
 {
     global $user_info, $context;
     $search = trim(Util::strtolower($_REQUEST['search'])) . '*';
     $search = strtr($search, array('%' => '\\%', '_' => '\\_', '*' => '%', '?' => '_', '&' => '&'));
     require_once SUBSDIR . '/Members.subs.php';
     // Find the member.
     $xml_data = getMember($search, !empty($context['search_param']['buddies']) ? $user_info['buddies'] : array());
     return $xml_data;
 }
开发者ID:KeiroD,项目名称:Elkarte,代码行数:15,代码来源:Suggest.class.php

示例2: template_package_list

/**
 * Shows all of the addon packs available on the package server
 */
function template_package_list()
{
    global $context, $settings, $txt;
    echo '
	<div id="admincenter">
		<h2 class="category_header">' . $context['page_title'] . '</h2>
			<div class="content">';
    // No packages, as yet.
    if (empty($context['package_list'])) {
        echo '
				<ul>
					<li>', $txt['no_packages'], '</li>
				</ul>';
    } else {
        echo '
				<ul id="package_list">';
        foreach ($context['package_list'] as $i => $packageSection) {
            echo '
					<li>
						<span class="package_toggle">&nbsp;
							<span id="ps_img_', $i, '" class="collapse" style="display: none;" title="', $txt['hide'], '"></span>
						</span>
						<a href="#" id="upshrink_link_', $i, '" class="highlight">', $packageSection['title'], '</a>';
            if (!empty($packageSection['text'])) {
                echo '
						<div class="content">', $packageSection['text'], '</div>';
            }
            // List of addons available in this section
            echo '
						<ol id="package_section_', $i, '" class="packages">';
            $alt = false;
            foreach ($packageSection['items'] as $id => $package) {
                echo '
							<li>';
                // 1. Some addon [ Download ].
                echo '
							<strong>
								<img id="ps_img_', $i, '_pkg_', $id, '" src="', $settings['images_url'], '/selected_open.png" alt="*" style="display: none;" /> ', $package['can_install'] ? '<strong>' . $package['name'] . '</strong> <a class="linkbutton" href="' . $package['download']['href'] . '">' . $txt['download'] . '</a>' : $package['name'];
                // Mark as installed and current?
                if ($package['is_installed'] && !$package['is_newer']) {
                    echo '<img src="', $settings['images_url'], '/icons/package_', $package['is_current'] ? 'installed' : 'old', '.png" class="centericon package_img" alt="', $package['is_current'] ? $txt['package_installed_current'] : $txt['package_installed_old'], '" />';
                }
                echo '
							</strong>
							<ul id="package_section_', $i, '_pkg_', $id, '" class="package_section">';
                // Show the addon type?
                if ($package['type'] != '') {
                    echo '
								<li class="package_section">', $txt['package_type'], ':&nbsp; ', Util::ucwords(Util::strtolower($package['type'])), '</li>';
                }
                // Show the version number?
                if ($package['version'] != '') {
                    echo '
								<li class="package_section">', $txt['mod_version'], ':&nbsp; ', $package['version'], '</li>';
                }
                // Show the last date?
                if ($package['date'] != '') {
                    echo '
								<li class="package_section">', $txt['mod_date'], ':&nbsp; ', $package['date'], '</li>';
                }
                // How 'bout the author?
                if (!empty($package['author'])) {
                    echo '
								<li class="package_section">', $txt['mod_author'], ':&nbsp; ', $package['author'], '</li>';
                }
                // Nothing but hooks ?
                if ($package['hooks'] != '' && in_array($package['hooks'], array('yes', 'true'))) {
                    echo '
								<li class="package_section">', $txt['mod_hooks'], ' <i class="fa fa-check-circle-o"></i></li>';
                }
                // Location of file: http://someplace/.
                echo '
								<ul style="margin-left: 5em">
									<li class="package_section"><i class="fa fa-cloud-download"></i> ', $txt['file_location'], ':&nbsp; <a href="', $package['server']['download'], '">', $package['server']['download'], '</a></li>';
                // Location of issues?
                if (!empty($package['server']['bugs'])) {
                    echo '
									<li class="package_section"><i class="fa fa-bug"></i> ', $txt['bug_location'], ':&nbsp; <a href="', $package['server']['bugs'], '">', $package['server']['bugs'], '</a></li>';
                }
                // Location of support?
                if (!empty($package['server']['support'])) {
                    echo '
									<li class="package_section"><i class="fa fa-support"></i> ', $txt['support_location'], ':&nbsp; <a href="', $package['server']['support'], '">', $package['server']['support'], '</a></li>';
                }
                // Description: bleh bleh!
                echo '
								</ul>
								<li class="package_section"><div class="infobox">', $txt['package_description'], ':&nbsp; ', $package['description'], '</div></li>
							</ul>';
                $alt = !$alt;
                echo '
						</li>';
            }
            echo '
					</ol>
						</li>';
        }
//.........这里部分代码省略.........
开发者ID:KeiroD,项目名称:Elkarte,代码行数:101,代码来源:PackageServers.template.php

示例3: sendpm

/**
 * Sends a personal message from the specified person to the specified people
 * ($from defaults to the user)
 *
 * @package PersonalMessage
 * @param mixed[] $recipients - an array containing the arrays 'to' and 'bcc', both containing id_member's.
 * @param string $subject - should have no slashes and no html entities
 * @param string $message - should have no slashes and no html entities
 * @param bool $store_outbox
 * @param mixed[]|null $from - an array with the id, name, and username of the member.
 * @param int $pm_head - the ID of the chain being replied to - if any.
 * @return mixed[] an array with log entries telling how many recipients were successful and which recipients it failed to send to.
 */
function sendpm($recipients, $subject, $message, $store_outbox = true, $from = null, $pm_head = 0)
{
    global $scripturl, $txt, $user_info, $language, $modSettings, $webmaster_email;
    $db = database();
    // Make sure the PM language file is loaded, we might need something out of it.
    loadLanguage('PersonalMessage');
    // Needed for our email and post functions
    require_once SUBSDIR . '/Mail.subs.php';
    require_once SUBSDIR . '/Post.subs.php';
    // Initialize log array.
    $log = array('failed' => array(), 'sent' => array());
    if ($from === null) {
        $from = array('id' => $user_info['id'], 'name' => $user_info['name'], 'username' => $user_info['username']);
    } else {
        $user_info['name'] = $from['name'];
    }
    // This is the one that will go in their inbox.
    $htmlmessage = Util::htmlspecialchars($message, ENT_QUOTES, 'UTF-8', true);
    preparsecode($htmlmessage);
    $htmlsubject = strtr(Util::htmlspecialchars($subject), array("\r" => '', "\n" => '', "\t" => ''));
    if (Util::strlen($htmlsubject) > 100) {
        $htmlsubject = Util::substr($htmlsubject, 0, 100);
    }
    // Make sure is an array
    if (!is_array($recipients)) {
        $recipients = array($recipients);
    }
    // Integrated PMs
    call_integration_hook('integrate_personal_message', array(&$recipients, &$from, &$subject, &$message));
    // Get a list of usernames and convert them to IDs.
    $usernames = array();
    foreach ($recipients as $rec_type => $rec) {
        foreach ($rec as $id => $member) {
            if (!is_numeric($recipients[$rec_type][$id])) {
                $recipients[$rec_type][$id] = Util::strtolower(trim(preg_replace('/[<>&"\'=\\\\]/', '', $recipients[$rec_type][$id])));
                $usernames[$recipients[$rec_type][$id]] = 0;
            }
        }
    }
    if (!empty($usernames)) {
        $request = $db->query('pm_find_username', '
			SELECT
				id_member, member_name
			FROM {db_prefix}members
			WHERE ' . (defined('DB_CASE_SENSITIVE') ? 'LOWER(member_name)' : 'member_name') . ' IN ({array_string:usernames})', array('usernames' => array_keys($usernames)));
        while ($row = $db->fetch_assoc($request)) {
            if (isset($usernames[Util::strtolower($row['member_name'])])) {
                $usernames[Util::strtolower($row['member_name'])] = $row['id_member'];
            }
        }
        $db->free_result($request);
        // Replace the usernames with IDs. Drop usernames that couldn't be found.
        foreach ($recipients as $rec_type => $rec) {
            foreach ($rec as $id => $member) {
                if (is_numeric($recipients[$rec_type][$id])) {
                    continue;
                }
                if (!empty($usernames[$member])) {
                    $recipients[$rec_type][$id] = $usernames[$member];
                } else {
                    $log['failed'][$id] = sprintf($txt['pm_error_user_not_found'], $recipients[$rec_type][$id]);
                    unset($recipients[$rec_type][$id]);
                }
            }
        }
    }
    // Make sure there are no duplicate 'to' members.
    $recipients['to'] = array_unique($recipients['to']);
    // Only 'bcc' members that aren't already in 'to'.
    $recipients['bcc'] = array_diff(array_unique($recipients['bcc']), $recipients['to']);
    // Combine 'to' and 'bcc' recipients.
    $all_to = array_merge($recipients['to'], $recipients['bcc']);
    // Check no-one will want it deleted right away!
    $request = $db->query('', '
		SELECT
			id_member, criteria, is_or
		FROM {db_prefix}pm_rules
		WHERE id_member IN ({array_int:to_members})
			AND delete_pm = {int:delete_pm}', array('to_members' => $all_to, 'delete_pm' => 1));
    $deletes = array();
    // Check whether we have to apply anything...
    while ($row = $db->fetch_assoc($request)) {
        $criteria = unserialize($row['criteria']);
        // Note we don't check the buddy status, cause deletion from buddy = madness!
        $delete = false;
        foreach ($criteria as $criterium) {
            if ($criterium['t'] == 'mid' && $criterium['v'] == $from['id'] || $criterium['t'] == 'gid' && in_array($criterium['v'], $user_info['groups']) || $criterium['t'] == 'sub' && strpos($subject, $criterium['v']) !== false || $criterium['t'] == 'msg' && strpos($message, $criterium['v']) !== false) {
//.........这里部分代码省略.........
开发者ID:joshuaadickerson,项目名称:Elkarte,代码行数:101,代码来源:PersonalMessage.subs.php

示例4: sportal_get_shouts

/**
 * Loads all the shouts for a given shoutbox
 *
 * @param int $shoutbox id of the shoutbox to get data from
 * @param mixed[] $parameters
 *
 * @return type
 */
function sportal_get_shouts($shoutbox, $parameters)
{
    global $scripturl, $context, $user_info, $modSettings, $txt;
    $db = database();
    // Set defaults or used what was passed
    $shoutbox = !empty($shoutbox) ? (int) $shoutbox : 0;
    $start = !empty($parameters['start']) ? (int) $parameters['start'] : 0;
    $limit = !empty($parameters['limit']) ? (int) $parameters['limit'] : 20;
    $bbc = !empty($parameters['bbc']) ? $parameters['bbc'] : array();
    $reverse = !empty($parameters['reverse']);
    $cache = !empty($parameters['cache']);
    $can_delete = !empty($parameters['can_moderate']);
    // Cached, use it first
    if (!empty($start) || !$cache || ($shouts = cache_get_data('shoutbox_shouts-' . $shoutbox, 240)) === null) {
        $request = $db->query('', '
			SELECT
				sh.id_shout, sh.body, IFNULL(mem.id_member, 0) AS id_member,
				IFNULL(mem.real_name, sh.member_name) AS member_name, sh.log_time,
				mg.online_color AS member_group_color, pg.online_color AS post_group_color
			FROM {db_prefix}sp_shouts AS sh
				LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = sh.id_member)
				LEFT JOIN {db_prefix}membergroups AS pg ON (pg.id_group = mem.id_post_group)
				LEFT JOIN {db_prefix}membergroups AS mg ON (mg.id_group = mem.id_group)
			WHERE sh.id_shoutbox = {int:id_shoutbox}
			ORDER BY sh.id_shout DESC
			LIMIT {int:start}, {int:limit}', array('id_shoutbox' => $shoutbox, 'start' => $start, 'limit' => $limit));
        $shouts = array();
        while ($row = $db->fetch_assoc($request)) {
            // Disable the aeva mod for the shoutbox.
            $context['aeva_disable'] = true;
            $online_color = !empty($row['member_group_color']) ? $row['member_group_color'] : $row['post_group_color'];
            $shouts[$row['id_shout']] = array('id' => $row['id_shout'], 'author' => array('id' => $row['id_member'], 'name' => $row['member_name'], 'link' => $row['id_member'] ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" title="' . $txt['on'] . ' ' . strip_tags(standardTime($row['log_time'])) . '"' . (!empty($online_color) ? ' style="color: ' . $online_color . ';"' : '') . '>' . $row['member_name'] . '</a>' : $row['member_name'], 'color' => $online_color), 'time' => $row['log_time'], 'text' => parse_bbc($row['body'], true, '', $bbc));
        }
        $db->free_result($request);
        if (empty($start) && $cache) {
            cache_put_data('shoutbox_shouts-' . $shoutbox, $shouts, 240);
        }
    }
    foreach ($shouts as $shout) {
        // Private shouts @username: only get shown to the shouter and shoutee, and the admin
        if (preg_match('~^@(.+?): ~u', $shout['text'], $target) && Util::strtolower($target[1]) !== Util::strtolower($user_info['name']) && $shout['author']['id'] != $user_info['id'] && !$user_info['is_admin']) {
            unset($shouts[$shout['id']]);
            continue;
        }
        $shouts[$shout['id']] += array('is_me' => preg_match('~^<div\\sclass="meaction">\\* ' . preg_quote($shout['author']['name'], '~') . '.+</div>$~', $shout['text']) != 0, 'delete_link' => $can_delete ? '<a class="dot dotdelete" href="' . $scripturl . '?action=shoutbox;shoutbox_id=' . $shoutbox . ';delete=' . $shout['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '"></a> ' : '', 'delete_link_js' => $can_delete ? '<a class="dot dotdelete" href="' . $scripturl . '?action=shoutbox;shoutbox_id=' . $shoutbox . ';delete=' . $shout['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" onclick="sp_delete_shout(' . $shoutbox . ', ' . $shout['id'] . ', \'' . $context['session_var'] . '\', \'' . $context['session_id'] . '\'); return false;"></a> ' : '');
        // Prepare for display in the box
        $shouts[$shout['id']]['time'] = standardTime($shouts[$shout['id']]['time']);
        $shouts[$shout['id']]['text'] = preg_replace('~(</?)div([^<]*>)~', '$1span$2', $shouts[$shout['id']]['text']);
        $shouts[$shout['id']]['text'] = preg_replace('~<a([^>]+>)([^<]+)</a>~', '<a$1' . $txt['sp_link'] . '</a>', $shouts[$shout['id']]['text']);
        $shouts[$shout['id']]['text'] = censorText($shouts[$shout['id']]['text']);
        // Ignored user, hide the shout with option to show it
        if (!empty($modSettings['enable_buddylist']) && in_array($shout['author']['id'], $context['user']['ignoreusers'])) {
            $shouts[$shout['id']]['text'] = '<a href="#toggle" id="ignored_shout_link_' . $shout['id'] . '" onclick="sp_show_ignored_shout(' . $shout['id'] . '); return false;">[' . $txt['sp_shoutbox_show_ignored'] . ']</a><span id="ignored_shout_' . $shout['id'] . '" style="display: none;">' . $shouts[$shout['id']]['text'] . '</span>';
        }
    }
    if ($reverse) {
        $shouts = array_reverse($shouts);
    }
    return $shouts;
}
开发者ID:emanuele45,项目名称:SimplePortal_ElkArte,代码行数:68,代码来源:PortalShoutbox.subs.php

示例5: profileReloadUser

/**
 * Reload a users settings.
 */
function profileReloadUser()
{
    global $modSettings, $context, $cur_profile;
    // Log them back in - using the verify password as they must have matched and this one doesn't get changed by anyone!
    if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') {
        require_once SUBSDIR . '/Auth.subs.php';
        setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash('sha256', Util::strtolower($cur_profile['member_name']) . un_htmlspecialchars($_POST['passwrd2']) . $cur_profile['password_salt']));
    }
    loadUserSettings();
    writeLog();
}
开发者ID:scripple,项目名称:Elkarte,代码行数:14,代码来源:Profile.subs.php

示例6: template_package_list

/**
 * Shows all of the addon packs available on the package server
 */
function template_package_list()
{
    global $context, $settings, $txt;
    echo '
	<div id="admincenter">
		<h2 class="category_header">' . $context['page_title'] . '</h2>
		<div class="windowbg">
			<div class="content">';
    // No packages, as yet.
    if (empty($context['package_list'])) {
        echo '
				<ul>
					<li>', $txt['no_packages'], '</li>
				</ul>';
    } else {
        echo '
				<ul id="package_list">';
        foreach ($context['package_list'] as $i => $packageSection) {
            echo '
					<li>
						<img id="ps_img_', $i, '" src="', $settings['images_url'], '/collapse.png" class="floatright" alt="*" style="display: none;" /><strong>', $packageSection['title'], '</strong>';
            if (!empty($packageSection['text'])) {
                echo '
						<div class="information">', $packageSection['text'], '</div>';
            }
            echo '
						<', $context['list_type'], ' id="package_section_', $i, '" class="packages">';
            $alt = false;
            foreach ($packageSection['items'] as $id => $package) {
                echo '
							<li>';
                // Textual message. Could be empty just for a blank line...
                if ($package['is_text']) {
                    echo '
								', empty($package['name']) ? '&nbsp;' : $package['name'];
                } elseif ($package['is_line']) {
                    echo '
							<hr />';
                } elseif ($package['is_remote']) {
                    echo '
							<strong>', $package['link'], '</strong>';
                } elseif ($package['is_heading'] || $package['is_title']) {
                    echo '
							<strong>', $package['name'], '</strong>';
                } else {
                    // 1. Some addon [ Download ].
                    echo '
							<strong><img id="ps_img_', $i, '_pkg_', $id, '" src="', $settings['images_url'], '/selected_open.png" alt="*" style="display: none;" /> ', $package['can_install'] ? '<strong>' . $package['name'] . '</strong> <a href="' . $package['download']['href'] . '">[ ' . $txt['download'] . ' ]</a>' : $package['name'];
                    // Mark as installed and current?
                    if ($package['is_installed'] && !$package['is_newer']) {
                        echo '<img src="', $settings['images_url'], '/icons/package_', $package['is_current'] ? 'installed' : 'old', '.png" class="centericon" style="width: 12px; height: 11px; margin-left: 2ex;" alt="', $package['is_current'] ? $txt['package_installed_current'] : $txt['package_installed_old'], '" />';
                    }
                    echo '
							</strong>
							<ul id="package_section_', $i, '_pkg_', $id, '" class="package_section">';
                    // Show the addon type?
                    if ($package['type'] != '') {
                        echo '
								<li class="package_section">', $txt['package_type'], ':&nbsp; ', Util::ucwords(Util::strtolower($package['type'])), '</li>';
                    }
                    // Show the version number?
                    if ($package['version'] != '') {
                        echo '
								<li class="package_section">', $txt['mod_version'], ':&nbsp; ', $package['version'], '</li>';
                    }
                    // How 'bout the author?
                    if (!empty($package['author']) && $package['author']['name'] != '' && isset($package['author']['link'])) {
                        echo '
								<li class="package_section">', $txt['mod_author'], ':&nbsp; ', $package['author']['link'], '</li>';
                    }
                    // The homepage....
                    if ($package['author']['website']['link'] != '') {
                        echo '
								<li class="package_section">', $txt['author_website'], ':&nbsp; ', $package['author']['website']['link'], '</li>';
                    }
                    // Description: bleh bleh!
                    // Location of file: http://someplace/.
                    echo '
								<li class="package_section">', $txt['file_location'], ':&nbsp; <a href="', $package['href'], '">', $package['href'], '</a></li>
								<li class="package_section"><div class="information">', $txt['package_description'], ':&nbsp; ', $package['description'], '</div></li>
							</ul>';
                }
                $alt = !$alt;
                echo '
						</li>';
            }
            echo '
					</', $context['list_type'], '>
						</li>';
        }
        echo '
				</ul>';
    }
    echo '
			</div>
		</div>
		<div>
//.........这里部分代码省略.........
开发者ID:scripple,项目名称:Elkarte,代码行数:101,代码来源:PackageServers.template.php

示例7: action_mailingcompose

 /**
  * Shows a form to edit a forum mailing and its recipients.
  *
  * What it does:
  * - Called by ?action=admin;area=news;sa=mailingcompose.
  * - Requires the send_mail permission.
  * - Form is submitted to ?action=admin;area=news;sa=mailingsend.
  *
  * @uses ManageNews template, email_members_compose sub-template.
  */
 public function action_mailingcompose()
 {
     global $txt, $context;
     // Setup the template!
     $context['page_title'] = $txt['admin_newsletters'];
     $context['sub_template'] = 'email_members_compose';
     $context['subject'] = !empty($_POST['subject']) ? $_POST['subject'] : $context['forum_name'] . ': ' . htmlspecialchars($txt['subject'], ENT_COMPAT, 'UTF-8');
     $context['message'] = !empty($_POST['message']) ? $_POST['message'] : htmlspecialchars($txt['message'] . "\n\n" . replaceBasicActionUrl($txt['regards_team']) . "\n\n" . '{$board_url}', ENT_COMPAT, 'UTF-8');
     // Needed for the WYSIWYG editor.
     require_once SUBSDIR . '/Editor.subs.php';
     // Now create the editor.
     $editorOptions = array('id' => 'message', 'value' => $context['message'], 'height' => '250px', 'width' => '100%', 'labels' => array('post_button' => $txt['sendtopic_send']), 'preview_type' => 2);
     create_control_richedit($editorOptions);
     if (isset($context['preview'])) {
         require_once SUBSDIR . '/Mail.subs.php';
         $context['recipients']['members'] = !empty($_POST['members']) ? explode(',', $_POST['members']) : array();
         $context['recipients']['exclude_members'] = !empty($_POST['exclude_members']) ? explode(',', $_POST['exclude_members']) : array();
         $context['recipients']['groups'] = !empty($_POST['groups']) ? explode(',', $_POST['groups']) : array();
         $context['recipients']['exclude_groups'] = !empty($_POST['exclude_groups']) ? explode(',', $_POST['exclude_groups']) : array();
         $context['recipients']['emails'] = !empty($_POST['emails']) ? explode(';', $_POST['emails']) : array();
         $context['email_force'] = !empty($_POST['email_force']) ? 1 : 0;
         $context['total_emails'] = !empty($_POST['total_emails']) ? (int) $_POST['total_emails'] : 0;
         $context['max_id_member'] = !empty($_POST['max_id_member']) ? (int) $_POST['max_id_member'] : 0;
         $context['send_pm'] = !empty($_POST['send_pm']) ? 1 : 0;
         $context['send_html'] = !empty($_POST['send_html']) ? '1' : '0';
         return prepareMailingForPreview();
     }
     // Start by finding any members!
     $toClean = array();
     if (!empty($_POST['members'])) {
         $toClean[] = 'members';
     }
     if (!empty($_POST['exclude_members'])) {
         $toClean[] = 'exclude_members';
     }
     if (!empty($toClean)) {
         require_once SUBSDIR . '/Auth.subs.php';
         foreach ($toClean as $type) {
             // Remove the quotes.
             $_POST[$type] = strtr((string) $_POST[$type], array('\\"' => '"'));
             preg_match_all('~"([^"]+)"~', $_POST[$type], $matches);
             $_POST[$type] = array_unique(array_merge($matches[1], explode(',', preg_replace('~"[^"]+"~', '', $_POST[$type]))));
             foreach ($_POST[$type] as $index => $member) {
                 if (strlen(trim($member)) > 0) {
                     $_POST[$type][$index] = Util::htmlspecialchars(Util::strtolower(trim($member)));
                 } else {
                     unset($_POST[$type][$index]);
                 }
             }
             // Find the members
             $_POST[$type] = implode(',', array_keys(findMembers($_POST[$type])));
         }
     }
     if (isset($_POST['member_list']) && is_array($_POST['member_list'])) {
         $members = array();
         foreach ($_POST['member_list'] as $member_id) {
             $members[] = (int) $member_id;
         }
         $_POST['members'] = implode(',', $members);
     }
     if (isset($_POST['exclude_member_list']) && is_array($_POST['exclude_member_list'])) {
         $members = array();
         foreach ($_POST['exclude_member_list'] as $member_id) {
             $members[] = (int) $member_id;
         }
         $_POST['exclude_members'] = implode(',', $members);
     }
     // Clean the other vars.
     $this->action_mailingsend(true);
     // We need a couple strings from the email template file
     loadLanguage('EmailTemplates');
     require_once SUBSDIR . '/News.subs.php';
     // Get a list of all full banned users.  Use their Username and email to find them.
     // Only get the ones that can't login to turn off notification.
     $context['recipients']['exclude_members'] = excludeBannedMembers();
     // Did they select moderators - if so add them as specific members...
     if (!empty($context['recipients']['groups']) && in_array(3, $context['recipients']['groups']) || !empty($context['recipients']['exclude_groups']) && in_array(3, $context['recipients']['exclude_groups'])) {
         $mods = getModerators();
         foreach ($mods as $row) {
             if (in_array(3, $context['recipients'])) {
                 $context['recipients']['exclude_members'][] = $row;
             } else {
                 $context['recipients']['members'][] = $row;
             }
         }
     }
     require_once SUBSDIR . '/Members.subs.php';
     // For progress bar!
     $context['total_emails'] = count($context['recipients']['emails']);
     $context['max_id_member'] = maxMemberID();
//.........这里部分代码省略.........
开发者ID:Ralkage,项目名称:Elkarte,代码行数:101,代码来源:ManageNews.controller.php

示例8: write_theme_info

/**
 * Builds a theme-info.xml file for use when a new theme is installed by copying
 * an existing theme
 *
 * @param string $name
 * @param string $version
 * @param string $theme_dir
 * @param mixed[] $theme_values
 */
function write_theme_info($name, $version, $theme_dir, $theme_values)
{
    $xml_info = '<' . '?xml version="1.0"?' . '>
	<theme-info xmlns="http://www.elkarte.net/xml/theme-info" xmlns:elk="http://www.elkarte.net/">
		<!-- For the id, always use something unique - put your name, a colon, and then the package name. -->
		<id>elk:' . Util::strtolower(str_replace(array(' '), '_', $name)) . '</id>
		<version>' . $version . '</version>
		<!-- Theme name, used purely for aesthetics. -->
		<name>' . $name . '</name>
		<!-- Author: your email address or contact information. The name attribute is optional. -->
		<author name="Your Name">info@youremailaddress.tld</author>
		<!-- Website... where to get updates and more information. -->
		<website>http://www.yourdomain.tld/</website>
		<!-- Template layers to use, defaults to "html,body". -->
		<layers>' . (empty($theme_values['theme_layers']) ? 'html,body' : $theme_values['theme_layers']) . '</layers>
		<!-- Templates to load on startup. Default is "index". -->
		<templates>' . (empty($theme_values['theme_templates']) ? 'index' : $theme_values['theme_templates']) . '</templates>
		<!-- Base this theme off another? Default is blank, or no. It could be "default". -->
		<based-on></based-on>
	</theme-info>';
    // Now write it.
    file_put_contents($theme_dir . '/theme_info.xml', $xml_info);
}
开发者ID:KeiroD,项目名称:Elkarte,代码行数:32,代码来源:Themes.subs.php

示例9: validateLoginPassword

/**
 * Checks whether an entered password is correct for the user
 *
 * What it does:
 * - called when logging in or whenever a password needs to be validated for a user
 * - used to generate a new hash for the db, used during registration or any password changes
 * - if a non SHA256 password is sent, will generate one with SHA256(user + password) and return it in password
 *
 * @package Authorization
 * @param string $password user password if not already 64 characters long will be SHA256 with the user name
 * @param string $hash hash as generated from a SHA256 password
 * @param string $user user name only required if creating a SHA-256 password
 * @param boolean $returnhash flag to determine if we are returning a hash suitable for the database
 */
function validateLoginPassword(&$password, $hash, $user = '', $returnhash = false)
{
    // Our hashing controller
    require_once EXTDIR . '/PasswordHash.php';
    // Base-2 logarithm of the iteration count used for password stretching, the
    // higher the number the more secure and CPU time consuming
    $hash_cost_log2 = 10;
    // Do we require the hashes to be portable to older systems (less secure)?
    $hash_portable = false;
    // Get an instance of the hasher
    $hasher = new PasswordHash($hash_cost_log2, $hash_portable);
    // Guilty until we know otherwise
    $passhash = false;
    // If the password is not 64 characters, lets make it a (SHA-256)
    if (strlen($password) !== 64) {
        $password = hash('sha256', Util::strtolower($user) . un_htmlspecialchars($password));
    }
    // They need a password hash, something to save in the db?
    if ($returnhash) {
        $passhash = $hasher->HashPassword($password);
        // Something is not right, we can not generate a valid hash thats <20 characters
        if (strlen($passhash) < 20) {
            $passhash = false;
        }
    } else {
        $passhash = (bool) $hasher->CheckPassword($password, $hash);
    }
    unset($hasher);
    return $passhash;
}
开发者ID:KeiroD,项目名称:Elkarte,代码行数:44,代码来源:Auth.subs.php

示例10: getMember

/**
 * Finds a member from the database using supplied string as real_name
 *
 * - Optionaly will only search/find the member in a buddy list
 *
 * @package Members
 * @param string $search string to search real_name for like finds
 * @param int[]|null $buddies
 */
function getMember($search, $buddies = array())
{
    $db = database();
    // Find the member.
    $request = $db->query('', '
		SELECT id_member, real_name
		FROM {db_prefix}members
		WHERE {raw:real_name} LIKE {string:search}' . (!empty($buddies) ? '
			AND id_member IN ({array_int:buddy_list})' : '') . '
			AND is_activated IN ({array_int:activation_status})
		LIMIT {int:limit}', array('real_name' => defined('DB_CASE_SENSITIVE') ? 'LOWER(real_name)' : 'real_name', 'buddy_list' => $buddies, 'search' => Util::strtolower($search), 'activation_status' => array(1, 12), 'limit' => Util::strlen($search) <= 2 ? 100 : 800));
    $xml_data = array('items' => array('identifier' => 'item', 'children' => array()));
    while ($row = $db->fetch_assoc($request)) {
        $row['real_name'] = strtr($row['real_name'], array('&amp;' => '&#038;', '&lt;' => '&#060;', '&gt;' => '&#062;', '&quot;' => '&#034;'));
        $xml_data['items']['children'][] = array('attributes' => array('id' => $row['id_member']), 'value' => $row['real_name']);
    }
    $db->free_result($request);
    return $xml_data;
}
开发者ID:Ralkage,项目名称:Elkarte,代码行数:28,代码来源:Members.subs.php

示例11: action_spellcheck

    /**
     * Spell checks the post for typos ;).
     * It uses the pspell library, which MUST be installed.
     * It has problems with internationalization.
     * It is accessed via ?action=spellcheck.
     */
    public function action_spellcheck()
    {
        global $txt, $context;
        // A list of "words" we know about but pspell doesn't.
        $known_words = array('elkarte', 'php', 'mysql', 'www', 'gif', 'jpeg', 'png', 'http');
        loadLanguage('Post');
        loadTemplate('Post');
        // Okay, this looks funny, but it actually fixes a weird bug.
        ob_start();
        $old = error_reporting(0);
        // See, first, some windows machines don't load pspell properly on the first try.  Dumb, but this is a workaround.
        pspell_new('en');
        // Next, the dictionary in question may not exist. So, we try it... but...
        $pspell_link = pspell_new($txt['lang_dictionary'], $txt['lang_spelling'], '', 'utf-8', PSPELL_FAST | PSPELL_RUN_TOGETHER);
        // Most people don't have anything but English installed... So we use English as a last resort.
        if (!$pspell_link) {
            $pspell_link = pspell_new('en', '', '', '', PSPELL_FAST | PSPELL_RUN_TOGETHER);
        }
        error_reporting($old);
        @ob_end_clean();
        if (!isset($_POST['spellstring']) || !$pspell_link) {
            die;
        }
        // Construct a bit of Javascript code.
        $context['spell_js'] = '
			var txt = {"done": "' . $txt['spellcheck_done'] . '"},
				mispstr = ' . ($_POST['fulleditor'] === 'true' ? 'window.opener.spellCheckGetText(spell_fieldname)' : 'window.opener.document.forms[spell_formname][spell_fieldname].value') . ',
				misps = Array(';
        // Get all the words (Javascript already separated them).
        $alphas = explode("\n", strtr($_POST['spellstring'], array("\r" => '')));
        $found_words = false;
        for ($i = 0, $n = count($alphas); $i < $n; $i++) {
            // Words are sent like 'word|offset_begin|offset_end'.
            $check_word = explode('|', $alphas[$i]);
            // If the word is a known word, or spelled right...
            if (in_array(Util::strtolower($check_word[0]), $known_words) || pspell_check($pspell_link, $check_word[0]) || !isset($check_word[2])) {
                continue;
            }
            // Find the word, and move up the "last occurance" to here.
            $found_words = true;
            // Add on the javascript for this misspelling.
            $context['spell_js'] .= '
				new misp("' . strtr($check_word[0], array('\\' => '\\\\', '"' => '\\"', '<' => '', '&gt;' => '')) . '", ' . (int) $check_word[1] . ', ' . (int) $check_word[2] . ', [';
            // If there are suggestions, add them in...
            $suggestions = pspell_suggest($pspell_link, $check_word[0]);
            if (!empty($suggestions)) {
                // But first check they aren't going to be censored - no naughty words!
                foreach ($suggestions as $k => $word) {
                    if ($suggestions[$k] != censorText($word)) {
                        unset($suggestions[$k]);
                    }
                }
                if (!empty($suggestions)) {
                    $context['spell_js'] .= '"' . implode('", "', $suggestions) . '"';
                }
            }
            $context['spell_js'] .= ']),';
        }
        // If words were found, take off the last comma.
        if ($found_words) {
            $context['spell_js'] = substr($context['spell_js'], 0, -1);
        }
        $context['spell_js'] .= '
			);';
        // And instruct the template system to just show the spellcheck sub template.
        Template_Layers::getInstance()->removeAll();
        $context['sub_template'] = 'spellcheck';
    }
开发者ID:Ralkage,项目名称:Elkarte,代码行数:74,代码来源:Post.controller.php

示例12: action_search2

    /**
     * Actually do the search of personal messages and show the results
     *
     * What it does:
     * - accessed with ?action=pm;sa=search2
     * - checks user input and searches the pm table for messages matching the query.
     * - uses the search_results sub template of the PersonalMessage template.
     * - show the results of the search query.
     */
    public function action_search2()
    {
        global $scripturl, $modSettings, $context, $txt, $memberContext;
        $db = database();
        // Make sure the server is able to do this right now
        if (!empty($modSettings['loadavg_search']) && $modSettings['current_load'] >= $modSettings['loadavg_search']) {
            fatal_lang_error('loadavg_search_disabled', false);
        }
        // Some useful general permissions.
        $context['can_send_pm'] = allowedTo('pm_send');
        // Some hardcoded variables that can be tweaked if required.
        $maxMembersToSearch = 500;
        // Extract all the search parameters.
        $search_params = array();
        if (isset($_REQUEST['params'])) {
            $temp_params = explode('|"|', base64_decode(strtr($_REQUEST['params'], array(' ' => '+'))));
            foreach ($temp_params as $i => $data) {
                @(list($k, $v) = explode('|\'|', $data));
                $search_params[$k] = $v;
            }
        }
        $context['start'] = isset($_GET['start']) ? (int) $_GET['start'] : 0;
        // Store whether simple search was used (needed if the user wants to do another query).
        if (!isset($search_params['advanced'])) {
            $search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1;
        }
        // 1 => 'allwords' (default, don't set as param) / 2 => 'anywords'.
        if (!empty($search_params['searchtype']) || !empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2) {
            $search_params['searchtype'] = 2;
        }
        // Minimum age of messages. Default to zero (don't set param in that case).
        if (!empty($search_params['minage']) || !empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0) {
            $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage'];
        }
        // Maximum age of messages. Default to infinite (9999 days: param not set).
        if (!empty($search_params['maxage']) || !empty($_REQUEST['maxage']) && $_REQUEST['maxage'] < 9999) {
            $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage'];
        }
        // Search modifiers
        $search_params['subject_only'] = !empty($search_params['subject_only']) || !empty($_REQUEST['subject_only']);
        $search_params['show_complete'] = !empty($search_params['show_complete']) || !empty($_REQUEST['show_complete']);
        $search_params['sent_only'] = !empty($search_params['sent_only']) || !empty($_REQUEST['sent_only']);
        $context['folder'] = empty($search_params['sent_only']) ? 'inbox' : 'sent';
        // Default the user name to a wildcard matching every user (*).
        if (!empty($search_params['userspec']) || !empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*') {
            $search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec'];
        }
        // This will be full of all kinds of parameters!
        $searchq_parameters = array();
        // If there's no specific user, then don't mention it in the main query.
        if (empty($search_params['userspec'])) {
            $userQuery = '';
        } else {
            // Set up so we can seach by user name, wildcards, like, etc
            $userString = strtr(Util::htmlspecialchars($search_params['userspec'], ENT_QUOTES), array('&quot;' => '"'));
            $userString = strtr($userString, array('%' => '\\%', '_' => '\\_', '*' => '%', '?' => '_'));
            preg_match_all('~"([^"]+)"~', $userString, $matches);
            $possible_users = array_merge($matches[1], explode(',', preg_replace('~"[^"]+"~', '', $userString)));
            require_once SUBSDIR . '/Members.subs.php';
            // Who matches those criteria?
            $members = membersBy('member_names', array('member_names' => $possible_users));
            foreach ($possible_users as $key => $possible_user) {
                $searchq_parameters['guest_user_name_implode_' . $key] = defined('DB_CASE_SENSITIVE') ? strtolower($possible_user) : $possible_user;
            }
            // Simply do nothing if there are too many members matching the criteria.
            if (count($members) > $maxMembersToSearch) {
                $userQuery = '';
            } elseif (count($members) == 0) {
                if ($context['folder'] === 'inbox') {
                    $uq = array();
                    $name = defined('DB_CASE_SENSITIVE') ? 'LOWER(pm.from_name)' : 'pm.from_name';
                    foreach (array_keys($possible_users) as $key) {
                        $uq[] = 'AND pm.id_member_from = 0 AND (' . $name . ' LIKE {string:guest_user_name_implode_' . $key . '})';
                    }
                    $userQuery = implode(' ', $uq);
                    $searchq_parameters['pm_from_name'] = defined('DB_CASE_SENSITIVE') ? 'LOWER(pm.from_name)' : 'pm.from_name';
                } else {
                    $userQuery = '';
                }
            } else {
                $memberlist = array();
                foreach ($members as $id) {
                    $memberlist[] = $id;
                }
                // Use the name as as sent from or sent to
                if ($context['folder'] === 'inbox') {
                    $uq = array();
                    $name = defined('DB_CASE_SENSITIVE') ? 'LOWER(pm.from_name)' : 'pm.from_name';
                    foreach (array_keys($possible_users) as $key) {
                        $uq[] = 'AND (pm.id_member_from IN ({array_int:member_list}) OR (pm.id_member_from = 0 AND (' . $name . ' LIKE {string:guest_user_name_implode_' . $key . '})))';
                    }
//.........这里部分代码省略.........
开发者ID:KeiroD,项目名称:Elkarte,代码行数:101,代码来源:PersonalMessage.controller.php

示例13: action_register2

 public function action_register2()
 {
     global $txt, $modSettings, $context, $user_info;
     // Start collecting together any errors.
     $reg_errors = Error_Context::context('register', 0);
     // Check they are who they should be
     checkSession();
     if (!validateToken('register', 'post', true, false)) {
         $reg_errors->addError('token_verification');
     }
     // You can't register if it's disabled.
     if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 3) {
         fatal_lang_error('registration_disabled', false);
     }
     // Well, if you don't agree, you can't register.
     if (!empty($modSettings['requireAgreement']) && !isset($_POST['checkbox_agreement'])) {
         $reg_errors->addError('agreement_unchecked');
     }
     // Make sure they came from *somewhere*, have a session.
     if (!isset($_SESSION['old_url'])) {
         redirectexit('action=register');
     }
     // Check their provider deatils match up correctly in case they're pulling something funny
     if ($_POST['provider'] != $_SESSION['extauth_info']['provider']) {
         redirectexit('action=register');
     }
     // Clean up
     foreach ($_POST as $key => $value) {
         if (!is_array($_POST[$key])) {
             $_POST[$key] = htmltrim__recursive(str_replace(array("\n", "\r"), '', $_POST[$key]));
         }
     }
     // Needed for isReservedName() and registerMember()
     require_once SUBSDIR . '/Members.subs.php';
     // Needed for generateValidationCode()
     require_once SUBSDIR . '/Auth.subs.php';
     // Set the options needed for registration.
     $regOptions = array('interface' => 'guest', 'username' => !empty($_POST['user']) ? $_POST['user'] : '', 'email' => !empty($_POST['email']) ? $_POST['email'] : '', 'check_reserved_name' => true, 'check_password_strength' => true, 'check_email_ban' => true, 'send_welcome_email' => !empty($modSettings['send_welcomeEmail']), 'require' => empty($modSettings['registration_method']) ? 'nothing' : ($modSettings['registration_method'] == 1 ? 'activation' : 'approval'));
     // Lets check for other errors before trying to register the member.
     if ($reg_errors->hasErrors()) {
         return $this->action_register();
     }
     mt_srand(time() + 1277);
     $regOptions['password'] = generateValidationCode();
     $regOptions['password_check'] = $regOptions['password'];
     // Registration needs to know your IP
     $req = request();
     $regOptions['ip'] = $user_info['ip'];
     $regOptions['ip2'] = $req->ban_ip();
     $memberID = registerMember($regOptions, 'register');
     // If there are "important" errors and you are not an admin: log the first error
     // Otherwise grab all of them and don't log anything
     if ($reg_errors->hasErrors(1) && !$user_info['is_admin']) {
         foreach ($reg_errors->prepareErrors(1) as $error) {
             fatal_error($error, 'general');
         }
     }
     // One last error check
     if ($reg_errors->hasErrors()) {
         return $this->action_register();
     }
     // Do our spam protection now.
     spamProtection('register');
     // Since all is well, we'll go ahead and associate the member's external account
     addAuth($memberID, $_SESSION['extauth_info']['provider'], $_SESSION['extauth_info']['uid'], $_SESSION['extauth_info']['name']);
     // Basic template variable setup.
     if (!empty($modSettings['registration_method'])) {
         loadTemplate('Register');
         $context += array('page_title' => $txt['register'], 'title' => $txt['registration_successful'], 'sub_template' => 'after', 'description' => $modSettings['registration_method'] == 2 ? $txt['approval_after_registration'] : $txt['activate_after_registration']);
     } else {
         call_integration_hook('integrate_activate', array($regOptions['username']));
         setLoginCookie(60 * $modSettings['cookieTime'], $memberID, hash('sha256', Util::strtolower($regOptions['username']) . $regOptions['password'] . $regOptions['register_vars']['password_salt']));
         redirectexit('action=auth;sa=check;member=' . $memberID, $context['server']['needs_login_fix']);
     }
 }
开发者ID:eurich,项目名称:elkarte-external-authentication,代码行数:75,代码来源:Extauth.controller.php

示例14: text2words

/**
 * Chops a string into words and prepares them to be inserted into (or searched from) the database.
 *
 * @param string $text
 * @param int|null $max_chars = 20
 *     - if encrypt = true this is the maximum number of bytes to use in integer hashes (for searching)
 *     - if encrypt = false this is the maximum number of letters in each word
 * @param bool $encrypt = false Used for custom search indexes to return an array of ints representing the words
 */
function text2words($text, $max_chars = 20, $encrypt = false)
{
    // Step 1: Remove entities/things we don't consider words:
    $words = preg_replace('~(?:[\\x0B\\0\\x{A0}\\t\\r\\s\\n(){}\\[\\]<>!@$%^*.,:+=`\\~\\?/\\\\]+|&(?:amp|lt|gt|quot);)+~u', ' ', strtr($text, array('<br />' => ' ')));
    // Step 2: Entities we left to letters, where applicable, lowercase.
    $words = un_htmlspecialchars(Util::strtolower($words));
    // Step 3: Ready to split apart and index!
    $words = explode(' ', $words);
    if ($encrypt) {
        // Range of characters that crypt will produce (0-9, a-z, A-Z .)
        $possible_chars = array_flip(array_merge(range(46, 57), range(65, 90), range(97, 122)));
        $returned_ints = array();
        foreach ($words as $word) {
            if (($word = trim($word, '-_\'')) !== '') {
                // Get a crypt representation of this work
                $encrypted = substr(crypt($word, 'uk'), 2, $max_chars);
                $total = 0;
                // Create an integer reprsentation
                for ($i = 0; $i < $max_chars; $i++) {
                    $total += $possible_chars[ord($encrypted[$i])] * pow(63, $i);
                }
                // Return the value
                $returned_ints[] = $max_chars == 4 ? min($total, 16777215) : $total;
            }
        }
        return array_unique($returned_ints);
    } else {
        // Trim characters before and after and add slashes for database insertion.
        $returned_words = array();
        foreach ($words as $word) {
            if (($word = trim($word, '-_\'')) !== '') {
                $returned_words[] = $max_chars === null ? $word : substr($word, 0, $max_chars);
            }
        }
        // Filter out all words that occur more than once.
        return array_unique($returned_words);
    }
}
开发者ID:joshuaadickerson,项目名称:Elkarte,代码行数:47,代码来源:Subs.php

示例15: action_members

 /**
  * Display members of a group, and allow adding of members to a group.
  *
  * What it does:
  * - It can be called from ManageMembergroups if it needs templating within the admin environment.
  * - It shows a list of members that are part of a given membergroup.
  * - It is called by ?action=moderate;area=viewgroups;sa=members;group=x
  * - It requires the manage_membergroups permission.
  * - It allows to add and remove members from the selected membergroup.
  * - It allows sorting on several columns.
  * - It redirects to itself.
  * @uses ManageMembergroups template, group_members sub template.
  */
 public function action_members()
 {
     global $txt, $scripturl, $context, $modSettings, $user_info, $settings;
     $current_group = isset($_REQUEST['group']) ? (int) $_REQUEST['group'] : 0;
     // These will be needed
     require_once SUBSDIR . '/Membergroups.subs.php';
     require_once SUBSDIR . '/Members.subs.php';
     // Load up the group details.
     $context['group'] = membergroupById($current_group, true, true);
     // No browsing of guests, membergroup 0 or moderators or non-existing groups.
     if ($context['group'] === false || in_array($current_group, array(-1, 0, 3))) {
         fatal_lang_error('membergroup_does_not_exist', false);
     }
     $context['group']['id'] = $context['group']['id_group'];
     $context['group']['name'] = $context['group']['group_name'];
     // Fix the membergroup icons.
     $context['group']['icons'] = explode('#', $context['group']['icons']);
     $context['group']['icons'] = !empty($context['group']['icons'][0]) && !empty($context['group']['icons'][1]) ? str_repeat('<img src="' . $settings['images_url'] . '/group_icons/' . $context['group']['icons'][1] . '" alt="*" />', $context['group']['icons'][0]) : '';
     $context['group']['can_moderate'] = allowedTo('manage_membergroups') && (allowedTo('admin_forum') || $context['group']['group_type'] != 1);
     // The template is very needy
     $context['linktree'][] = array('url' => $scripturl . '?action=groups;sa=members;group=' . $context['group']['id'], 'name' => $context['group']['name']);
     $context['can_send_email'] = allowedTo('send_email_to_members');
     $context['sort_direction'] = isset($_REQUEST['desc']) ? 'down' : 'up';
     $context['start'] = $_REQUEST['start'];
     $context['can_moderate_forum'] = allowedTo('moderate_forum');
     // @todo: use createList
     // Load all the group moderators, for fun.
     $context['group']['moderators'] = array();
     $moderators = getGroupModerators($current_group);
     foreach ($moderators as $id_member => $name) {
         $context['group']['moderators'][] = array('id' => $id_member, 'name' => $name);
         if ($user_info['id'] == $id_member && $context['group']['group_type'] != 1) {
             $context['group']['can_moderate'] = true;
         }
     }
     // If this group is hidden then it can only "exist" if the user can moderate it!
     if ($context['group']['hidden'] && !$context['group']['can_moderate']) {
         fatal_lang_error('membergroup_does_not_exist', false);
     }
     // You can only assign membership if you are the moderator and/or can manage groups!
     if (!$context['group']['can_moderate']) {
         $context['group']['assignable'] = 0;
     } elseif ($context['group']['id'] == 1 && !allowedTo('admin_forum')) {
         $context['group']['assignable'] = 0;
     }
     // Removing member from group?
     if (isset($_POST['remove']) && !empty($_REQUEST['rem']) && is_array($_REQUEST['rem']) && $context['group']['assignable']) {
         // Security first
         checkSession();
         validateToken('mod-mgm');
         // Make sure we're dealing with integers only.
         foreach ($_REQUEST['rem'] as $key => $group) {
             $_REQUEST['rem'][$key] = (int) $group;
         }
         removeMembersFromGroups($_REQUEST['rem'], $current_group, true);
     } elseif (isset($_REQUEST['add']) && (!empty($_REQUEST['toAdd']) || !empty($_REQUEST['member_add'])) && $context['group']['assignable']) {
         // Make sure you can do this
         checkSession();
         validateToken('mod-mgm');
         $member_query = array(array('and' => 'not_in_group'));
         $member_parameters = array('not_in_group' => $current_group);
         // Get all the members to be added... taking into account names can be quoted ;)
         $_REQUEST['toAdd'] = strtr(Util::htmlspecialchars($_REQUEST['toAdd'], ENT_QUOTES), array('&quot;' => '"'));
         preg_match_all('~"([^"]+)"~', $_REQUEST['toAdd'], $matches);
         $member_names = array_unique(array_merge($matches[1], explode(',', preg_replace('~"[^"]+"~', '', $_REQUEST['toAdd']))));
         foreach ($member_names as $index => $member_name) {
             $member_names[$index] = trim(Util::strtolower($member_names[$index]));
             if (strlen($member_names[$index]) == 0) {
                 unset($member_names[$index]);
             }
         }
         // Any members passed by ID?
         $member_ids = array();
         if (!empty($_REQUEST['member_add'])) {
             foreach ($_REQUEST['member_add'] as $id) {
                 if ($id > 0) {
                     $member_ids[] = (int) $id;
                 }
             }
         }
         // Construct the query pelements, first for adds by name
         if (!empty($member_ids)) {
             $member_query[] = array('or' => 'member_ids');
             $member_parameters['member_ids'] = $member_ids;
         }
         // And then adds by ID
         if (!empty($member_names)) {
//.........这里部分代码省略.........
开发者ID:KeiroD,项目名称:Elkarte,代码行数:101,代码来源:Groups.controller.php


注:本文中的Util::strtolower方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。