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


PHP cache_put_data函数代码示例

本文整理汇总了PHP中cache_put_data函数的典型用法代码示例。如果您正苦于以下问题:PHP cache_put_data函数的具体用法?PHP cache_put_data怎么用?PHP cache_put_data使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: akismet_load_theme

function akismet_load_theme()
{
    global $context, $topic;
    // Is this a topic being displayed?
    if (empty($_REQUEST['action']) && !empty($board) && !empty($topic)) {
        // Looking through the topic table can be slow, so try using the cache first.
        if (($spam = cache_get_data('akismet-spam-topic-' . $topic, 3600)) === NULL) {
            $request = $smcFunc['db_query']('', '
				SELECT id_topic
				FROM {db_prefix}topics
				WHERE id_topic = {int:id_topic}', array('id_topic' => $topic));
            // So did it find anything?
            if ($smcFunc['db_num_rows']($request)) {
                list($spam) = $smcFunc['db_fetch_row']($request);
                $smcFunc['db_free_result']($request);
                // Save save save.
                cache_put_data('akismet-spam-topic-' . $topic, $spam, 120);
            }
        }
        if (!empty($span)) {
            // So we now know this is a spam topic. Show a warning.
            loadLanguage('Akismet');
            loadTemplate('Akismet');
            $context['template_layers'][] = 'akismet_warn_topic';
        }
    }
}
开发者ID:valek0972,项目名称:hackits,代码行数:27,代码来源:Subs-Akismet.php

示例2: cache_quick_get

/**
 * Try to retrieve a cache entry. On failure, call the appropriate function.
 * This callback is sent as $file to include, and $function to call, with
 * $params parameters.
 *
 * @param string $key cache entry key
 * @param string $file file to include
 * @param string $function function to call
 * @param mixed[] $params parameters sent to the function
 * @param int $level = 1
 * @return string
 */
function cache_quick_get($key, $file, $function, $params, $level = 1)
{
    global $modSettings;
    // @todo Why are we doing this if caching is disabled?
    if (function_exists('call_integration_hook')) {
        call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level));
    }
    /* Refresh the cache if either:
    		1. Caching is disabled.
    		2. The cache level isn't high enough.
    		3. The item has not been cached or the cached item expired.
    		4. The cached item has a custom expiration condition evaluating to true.
    		5. The expire time set in the cache item has passed (needed for Zend).
    	*/
    if (empty($modSettings['cache_enable']) || $modSettings['cache_enable'] < $level || !is_array($cache_block = cache_get_data($key, 3600)) || !empty($cache_block['refresh_eval']) && eval($cache_block['refresh_eval']) || !empty($cache_block['expires']) && $cache_block['expires'] < time()) {
        require_once SOURCEDIR . '/' . $file;
        $cache_block = call_user_func_array($function, $params);
        if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= $level) {
            cache_put_data($key, $cache_block, $cache_block['expires'] - time());
        }
    }
    // Some cached data may need a freshening up after retrieval.
    if (!empty($cache_block['post_retri_eval'])) {
        eval($cache_block['post_retri_eval']);
    }
    if (function_exists('call_integration_hook')) {
        call_integration_hook('post_cache_quick_get', array($cache_block));
    }
    return $cache_block['data'];
}
开发者ID:KeiroD,项目名称:Elkarte,代码行数:42,代码来源:Cache.subs.php

示例3: getLegacyKarmaByMemberID

/**
 * Get legacy karma value for member id
 * @param int $member_id
 * @return array|bool
 */
function getLegacyKarmaByMemberID($member_id = 0)
{
    global $smcFunc;
    if (!$member_id) {
        return false;
    }
    // Check cache
    $legacyKarma = cache_get_data('legacyKarma_' . $member_id);
    if (empty($legacyKarma)) {
        $request = $smcFunc['db_query']('', '
			SELECT karma_good, karma_bad
			FROM {db_prefix}members
			WHERE id_member = {int:member_id}
			LIMIT 1', array('member_id' => $member_id));
        $legacyKarma = array();
        list($legacyKarma['good'], $legacyKarma['bad']) = $smcFunc['db_fetch_row']($request);
        $smcFunc['db_free_result']($request);
        cache_put_data('legacyKarma_' . $member_id, $legacyKarma);
    }
    if (!empty($legacyKarma['good']) || !empty($legacyKarma['bad'])) {
        return (!empty($legacyKarma['good']) ? '+' . $legacyKarma['good'] : '') . (!empty($legacyKarma['good']) && !empty($legacyKarma['bad']) ? '/' : '') . (!empty($legacyKarma['bad']) ? '-' . $legacyKarma['bad'] : '');
    } else {
        return false;
    }
}
开发者ID:realdigger,项目名称:SMF-Legacy-Karma,代码行数:30,代码来源:Mod-LegacyKarma.php

示例4: load_theme

 public static function load_theme()
 {
     global $context, $modSettings, $txt, $settings, $user_info;
     if (($themes = cache_get_data('TS_themes_list', 3600)) === null) {
         loadLanguage('ManageThemes');
         require_once SUBSDIR . '/Themes.subs.php';
         $themes = availableThemes($user_info['theme'], $user_info['id']);
         cache_put_data('TS_themes_list', $themes, 3600);
     }
     foreach ($themes[0] as $theme_id => $theme) {
         $name = $theme['name'];
         $selected = !empty($user_info['theme']) && $user_info['theme'] == $theme_id;
         $context['ThemeSelector'][$theme_id] = array('name' => $name, 'selected' => $selected, 'variants' => array());
         if (isset($theme['variants'])) {
             foreach ($theme['variants'] as $key => $variant) {
                 $context['ThemeSelector'][$theme_id]['variants'][$key] = array('name' => $variant['label'], 'selected' => $context['theme_variant'] == '_' . $key);
             }
         }
     }
     if (!isset($context['theme_header_callbacks'])) {
         $context['theme_header_callbacks'] = array();
     }
     $context['theme_header_callbacks'][] = 'themeselector';
     loadTemplate('ThemeSelector');
     loadJavascriptFile('ThemeSelector.js');
     loadCSSFile('ThemeSelector.css');
 }
开发者ID:CrimeS,项目名称:ThemeSelector,代码行数:27,代码来源:ThemeSelector.integrate.php

示例5: template_init

function template_init()
{
    global $context, $settings, $options, $txt, $modSettings;
    $settings['use_default_images'] = 'never';
    $settings['doctype'] = 'html';
    $settings['theme_version'] = '2.0';
    $settings['use_tabs'] = true;
    $settings['use_buttons'] = true;
    $settings['separate_sticky_lock'] = true;
    $settings['strict_doctype'] = false;
    $settings['message_index_preview'] = true;
    $settings['require_theme_strings'] = true;
    $settings['alphathemes'] = true;
    if (($settings['tp_boardicons'] = cache_get_data('alpha_boardicons', 2)) == null) {
        $settings['tp_boardicons'] = my_readfolder($settings['theme_dir'] . '/images/boardicons', $settings['theme_url'] . '/images/boardicons', '.png');
        cache_put_data('alpha_boardicons', $settings['tp_boardicons'], 2);
    }
    $settings['extra_copyrights'] = array('<b>ShelfLife</b> theme &copy; 2015, BK');
    $settings['catch_action'] = array('layers' => array('wrapinit', 'html', 'body', 'wrap'));
    /* all modules possible
    	$settings['module_display'] = '';
    	$settings['module_boardindex'] = '';
    	$settings['module_messageindex'] = '';
    	$settings['module_profile'] = '';
    	$settings['module_pm'] = '';
    	*/
    // can be board-based.
}
开发者ID:Bloc67,项目名称:ShelfLife,代码行数:28,代码来源:index.template.php

示例6: parsesmileys

/**
 * Parse smileys in the passed message.
 *
 * What it does:
 * - The smiley parsing function which makes pretty faces appear :).
 * - If custom smiley sets are turned off by smiley_enable, the default set of smileys will be used.
 * - These are specifically not parsed in code tags [url=mailto:Dad@blah.com]
 * - Caches the smileys from the database or array in memory.
 * - Doesn't return anything, but rather modifies message directly.
 *
 * @param string $message
 */
function parsesmileys(&$message)
{
    global $modSettings, $txt, $user_info;
    static $smileyPregSearch = null, $smileyPregReplacements = array();
    // No smiley set at all?!
    if ($user_info['smiley_set'] == 'none' || trim($message) == '') {
        return;
    }
    // If smileyPregSearch hasn't been set, do it now.
    if (empty($smileyPregSearch)) {
        // Use the default smileys if it is disabled. (better for "portability" of smileys.)
        if (empty($modSettings['smiley_enable'])) {
            $smileysfrom = array('>:D', ':D', '::)', '>:(', ':))', ':)', ';)', ';D', ':(', ':o', '8)', ':P', '???', ':-[', ':-X', ':-*', ':\'(', ':-\\', '^-^', 'O0', 'C:-)', 'O:)');
            $smileysto = array('evil.gif', 'cheesy.gif', 'rolleyes.gif', 'angry.gif', 'laugh.gif', 'smiley.gif', 'wink.gif', 'grin.gif', 'sad.gif', 'shocked.gif', 'cool.gif', 'tongue.gif', 'huh.gif', 'embarrassed.gif', 'lipsrsealed.gif', 'kiss.gif', 'cry.gif', 'undecided.gif', 'azn.gif', 'afro.gif', 'police.gif', 'angel.gif');
            $smileysdescs = array('', $txt['icon_cheesy'], $txt['icon_rolleyes'], $txt['icon_angry'], $txt['icon_laugh'], $txt['icon_smiley'], $txt['icon_wink'], $txt['icon_grin'], $txt['icon_sad'], $txt['icon_shocked'], $txt['icon_cool'], $txt['icon_tongue'], $txt['icon_huh'], $txt['icon_embarrassed'], $txt['icon_lips'], $txt['icon_kiss'], $txt['icon_cry'], $txt['icon_undecided'], '', '', '', $txt['icon_angel']);
        } else {
            // Load the smileys in reverse order by length so they don't get parsed wrong.
            if (($temp = cache_get_data('parsing_smileys', 480)) == null) {
                $smileysfrom = array();
                $smileysto = array();
                $smileysdescs = array();
                // @todo there is no reason $db should be used before this
                $db = database();
                $db->fetchQueryCallback('
					SELECT code, filename, description
					FROM {db_prefix}smileys
					ORDER BY LENGTH(code) DESC', array(), function ($row) use(&$smileysfrom, &$smileysto, &$smileysdescs) {
                    $smileysfrom[] = $row['code'];
                    $smileysto[] = htmlspecialchars($row['filename']);
                    $smileysdescs[] = $row['description'];
                });
                cache_put_data('parsing_smileys', array($smileysfrom, $smileysto, $smileysdescs), 480);
            } else {
                list($smileysfrom, $smileysto, $smileysdescs) = $temp;
            }
        }
        // The non-breaking-space is a complex thing...
        $non_breaking_space = '\\x{A0}';
        // This smiley regex makes sure it doesn't parse smileys within code tags (so [url=mailto:David@bla.com] doesn't parse the :D smiley)
        $smileyPregReplacements = array();
        $searchParts = array();
        $smileys_path = htmlspecialchars($modSettings['smileys_url'] . '/' . $user_info['smiley_set'] . '/');
        for ($i = 0, $n = count($smileysfrom); $i < $n; $i++) {
            $specialChars = htmlspecialchars($smileysfrom[$i], ENT_QUOTES);
            $smileyCode = '<img src="' . $smileys_path . $smileysto[$i] . '" alt="' . strtr($specialChars, array(':' => '&#58;', '(' => '&#40;', ')' => '&#41;', '$' => '&#36;', '[' => '&#091;')) . '" title="' . strtr(htmlspecialchars($smileysdescs[$i]), array(':' => '&#58;', '(' => '&#40;', ')' => '&#41;', '$' => '&#36;', '[' => '&#091;')) . '" class="smiley" />';
            $smileyPregReplacements[$smileysfrom[$i]] = $smileyCode;
            $searchParts[] = preg_quote($smileysfrom[$i], '~');
            if ($smileysfrom[$i] != $specialChars) {
                $smileyPregReplacements[$specialChars] = $smileyCode;
                $searchParts[] = preg_quote($specialChars, '~');
            }
        }
        $smileyPregSearch = '~(?<=[>:\\?\\.\\s' . $non_breaking_space . '[\\]()*\\\\;]|^)(' . implode('|', $searchParts) . ')(?=[^[:alpha:]0-9]|$)~';
    }
    // Replace away!
    $message = preg_replace_callback($smileyPregSearch, function ($matches) use($smileyPregReplacements) {
        return $smileyPregReplacements[$matches[0]];
    }, $message);
}
开发者ID:joshuaadickerson,项目名称:BBC-Parser,代码行数:71,代码来源:BBCHelpers.php

示例7: parse_smileys

function parse_smileys(&$message)
{
    global $modSettings, $txt, $user_info, $context, $smcFunc;
    static $smileyarray = array();
    // No smiley set at all?!
    if ($user_info['smiley_set'] == 'none' || trim($message) == '') {
        return;
    }
    // If the smiley array hasn't been set, do it now.
    if (empty($smileyarray)) {
        // Small fix because entities are getting messed up
        $smileyarray = array('&quot;' => '&quot;', '&apos;' => '&apos;', '&#039;' => '&#039;', '&lt;' => '&lt;', '&gt;' => '&gt;', '&amp;' => '&amp;');
        // Use the default smileys if it is disabled. (better for "portability" of smileys.)
        if (empty($modSettings['smiley_enable'])) {
            $smileysfrom = array('>:D', ':D', '::)', '>:(', ':))', ':)', ';)', ';D', ':(', ':o', '8)', ':P', '???', ':-[', ':-X', ':-*', ':\'(', ':-\\', '^-^', 'O0', 'C:-)', '0:)');
            $smileysto = array('evil.gif', 'cheesy.gif', 'rolleyes.gif', 'angry.gif', 'laugh.gif', 'smiley.gif', 'wink.gif', 'grin.gif', 'sad.gif', 'shocked.gif', 'cool.gif', 'tongue.gif', 'huh.gif', 'embarrassed.gif', 'lipsrsealed.gif', 'kiss.gif', 'cry.gif', 'undecided.gif', 'azn.gif', 'afro.gif', 'police.gif', 'angel.gif');
            $smileysdescs = array('', $txt['icon_cheesy'], $txt['icon_rolleyes'], $txt['icon_angry'], '', $txt['icon_smiley'], $txt['icon_wink'], $txt['icon_grin'], $txt['icon_sad'], $txt['icon_shocked'], $txt['icon_cool'], $txt['icon_tongue'], $txt['icon_huh'], $txt['icon_embarrassed'], $txt['icon_lips'], $txt['icon_kiss'], $txt['icon_cry'], $txt['icon_undecided'], '', '', '', '');
        } else {
            // Load the smileys in reverse order by length so they don't get parsed wrong.
            if (($temp = cache_get_data('parsing_smileys', 480)) == null) {
                $result = $smcFunc['db_query']('', '
					SELECT code, filename, description
					FROM {db_prefix}smileys', array());
                $smileysfrom = array();
                $smileysto = array();
                $smileysdescs = array();
                while ($row = $smcFunc['db_fetch_assoc']($result)) {
                    $smileysfrom[] = $row['code'];
                    $smileysto[] = $row['filename'];
                    $smileysdescs[] = $row['description'];
                }
                $smcFunc['db_free_result']($result);
                cache_put_data('parsing_smileys', array($smileysfrom, $smileysto, $smileysdescs), 480);
            } else {
                list($smileysfrom, $smileysto, $smileysdescs) = $temp;
            }
        }
        foreach ($smileysfrom as $i => $from) {
            $smileyCode = '<img src="' . $modSettings['smileys_url'] . '/' . $user_info['smiley_set'] . '/' . $smileysto[$i] . '" alt="' . htmlentities($from) . '" title="' . htmlentities($smileysdescs[$i]) . '" class="smiley" />';
            $smileyarray[$from] = $smileyCode;
            if ($from != ($specialChars = htmlspecialchars($from, ENT_QUOTES))) {
                $smileyarray[$specialChars] = $smileyCode;
            }
        }
    }
    // Replace away!
    $message = strtr($message, $smileyarray);
}
开发者ID:joshuaadickerson,项目名称:BBC-Parser,代码行数:48,代码来源:Smileys.php

示例8: ImportSmileys

function ImportSmileys($smileyPath)
{
    global $db_prefix, $modSettings;
    if (empty($modSettings['smileys_dir']) || !is_dir($modSettings['smileys_dir'] . '/' . $smileyPath)) {
        fatal_lang_error('smiley_set_unable_to_import');
    }
    $smileys = array();
    $dir = dir($modSettings['smileys_dir'] . '/' . $smileyPath);
    while ($entry = $dir->read()) {
        if (in_array(strrchr($entry, '.'), array('.jpg', '.gif', '.jpeg', '.png'))) {
            $smileys[strtolower($entry)] = addslashes($entry);
        }
    }
    $dir->close();
    // Exclude the smileys that are already in the database.
    $request = db_query("\n\t\tSELECT filename\n\t\tFROM {$db_prefix}smileys\n\t\tWHERE filename IN ('" . implode("', '", $smileys) . "')", __FILE__, __LINE__);
    while ($row = mysql_fetch_assoc($request)) {
        if (isset($smileys[strtolower($row['filename'])])) {
            unset($smileys[strtolower($row['filename'])]);
        }
    }
    mysql_free_result($request);
    $request = db_query("\n\t\tSELECT MAX(smileyOrder)\n\t\tFROM {$db_prefix}smileys\n\t\tWHERE hidden = 0\n\t\t\tAND smileyRow = 0", __FILE__, __LINE__);
    list($smileyOrder) = mysql_fetch_row($request);
    mysql_free_result($request);
    $new_smileys = array();
    foreach ($smileys as $smiley) {
        if (strlen($smiley) <= 48) {
            $new_smileys[] = "(SUBSTRING(':" . strtok($smiley, '.') . ":', 1, 30), '{$smiley}', SUBSTRING('" . strtok($smiley, '.') . "', 1, 80), 0, " . ++$smileyOrder . ')';
        }
    }
    if (!empty($new_smileys)) {
        db_query("\n\t\t\tINSERT INTO {$db_prefix}smileys\n\t\t\t\t(code, filename, description, smileyRow, smileyOrder)\n\t\t\tVALUES" . implode(',
				', $new_smileys), __FILE__, __LINE__);
        // Make sure the smiley codes are still in the right order.
        db_query("\n\t\t\tALTER TABLE {$db_prefix}smileys\n\t\t\tORDER BY LENGTH(code) DESC", __FILE__, __LINE__);
        cache_put_data('parsing_smileys', null, 480);
        cache_put_data('posting_smileys', null, 480);
    }
}
开发者ID:bbon,项目名称:mjncms,代码行数:40,代码来源:ManageSmileys.php

示例9: ManageLabels


//.........这里部分代码省略.........
                    $_POST['label_name'][$id] = trim(strtr($smcFunc['htmlspecialchars']($_POST['label_name'][$id]), array(',' => '&#044;')));
                    if ($smcFunc['strlen']($_POST['label_name'][$id]) > 30) {
                        $_POST['label_name'][$id] = $smcFunc['substr']($_POST['label_name'][$id], 0, 30);
                    }
                    if ($_POST['label_name'][$id] != '') {
                        $the_labels[(int) $id] = $_POST['label_name'][$id];
                        $new_labels[$id] = $i++;
                    } else {
                        unset($the_labels[(int) $id]);
                        $message_changes[(int) $id] = true;
                    }
                } else {
                    $new_labels[$id] = $i++;
                }
            }
        }
        // Save the label status.
        updateMemberData($user_info['id'], array('message_labels' => implode(',', $the_labels)));
        // Update all the messages currently with any label changes in them!
        if (!empty($message_changes)) {
            $searchArray = array_keys($message_changes);
            if (!empty($new_labels)) {
                for ($i = max($searchArray) + 1, $n = max(array_keys($new_labels)); $i <= $n; $i++) {
                    $searchArray[] = $i;
                }
            }
            // Now find the messages to change.
            $request = $smcFunc['db_query']('', '
				SELECT id_pm, labels
				FROM {db_prefix}pm_recipients
				WHERE FIND_IN_SET({raw:find_label_implode}, labels) != 0
					AND id_member = {int:current_member}', array('current_member' => $user_info['id'], 'find_label_implode' => '\'' . implode('\', labels) != 0 OR FIND_IN_SET(\'', $searchArray) . '\''));
            while ($row = $smcFunc['db_fetch_assoc']($request)) {
                // Do the long task of updating them...
                $toChange = explode(',', $row['labels']);
                foreach ($toChange as $key => $value) {
                    if (in_array($value, $searchArray)) {
                        if (isset($new_labels[$value])) {
                            $toChange[$key] = $new_labels[$value];
                        } else {
                            unset($toChange[$key]);
                        }
                    }
                }
                if (empty($toChange)) {
                    $toChange[] = '-1';
                }
                // Update the message.
                $smcFunc['db_query']('', '
					UPDATE {db_prefix}pm_recipients
					SET labels = {string:new_labels}
					WHERE id_pm = {int:id_pm}
						AND id_member = {int:current_member}', array('current_member' => $user_info['id'], 'id_pm' => $row['id_pm'], 'new_labels' => implode(',', array_unique($toChange))));
            }
            $smcFunc['db_free_result']($request);
            // Now do the same the rules - check through each rule.
            foreach ($context['rules'] as $k => $rule) {
                // Each action...
                foreach ($rule['actions'] as $k2 => $action) {
                    if ($action['t'] != 'lab' || !in_array($action['v'], $searchArray)) {
                        continue;
                    }
                    $rule_changes[] = $rule['id'];
                    // If we're here we have a label which is either changed or gone...
                    if (isset($new_labels[$action['v']])) {
                        $context['rules'][$k]['actions'][$k2]['v'] = $new_labels[$action['v']];
                    } else {
                        unset($context['rules'][$k]['actions'][$k2]);
                    }
                }
            }
        }
        // If we have rules to change do so now.
        if (!empty($rule_changes)) {
            $rule_changes = array_unique($rule_changes);
            // Update/delete as appropriate.
            foreach ($rule_changes as $k => $id) {
                if (!empty($context['rules'][$id]['actions'])) {
                    $smcFunc['db_query']('', '
						UPDATE {db_prefix}pm_rules
						SET actions = {string:actions}
						WHERE id_rule = {int:id_rule}
							AND id_member = {int:current_member}', array('current_member' => $user_info['id'], 'id_rule' => $id, 'actions' => serialize($context['rules'][$id]['actions'])));
                    unset($rule_changes[$k]);
                }
            }
            // Anything left here means it's lost all actions...
            if (!empty($rule_changes)) {
                $smcFunc['db_query']('', '
					DELETE FROM {db_prefix}pm_rules
					WHERE id_rule IN ({array_int:rule_list})
							AND id_member = {int:current_member}', array('current_member' => $user_info['id'], 'rule_list' => $rule_changes));
            }
        }
        // Make sure we're not caching this!
        cache_put_data('labelCounts:' . $user_info['id'], null, 720);
        // To make the changes appear right away, redirect.
        redirectexit('action=pm;sa=manlabels');
    }
}
开发者ID:Glyph13,项目名称:SMF2.1,代码行数:101,代码来源:PersonalMessage.php

示例10: moveTopics


//.........这里部分代码省略.........
    }
    $smcFunc['db_query']('', '
		UPDATE {db_prefix}boards
		SET
			num_topics = num_topics + {int:total_topics},
			num_posts = num_posts + {int:total_posts},' . ($isRecycleDest ? '
			unapproved_posts = {int:no_unapproved}, unapproved_topics = {int:no_unapproved}' : '
			unapproved_posts = unapproved_posts + {int:total_unapproved_posts},
			unapproved_topics = unapproved_topics + {int:total_unapproved_topics}') . '
		WHERE id_board = {int:id_board}', array('id_board' => $toBoard, 'total_topics' => $totalTopics, 'total_posts' => $totalPosts, 'total_unapproved_topics' => $totalUnapprovedTopics, 'total_unapproved_posts' => $totalUnapprovedPosts, 'no_unapproved' => 0));
    // Move the topic.  Done.  :P
    $smcFunc['db_query']('', '
		UPDATE {db_prefix}topics
		SET id_board = {int:id_board}' . ($isRecycleDest ? ',
			unapproved_posts = {int:no_unapproved}, approved = {int:is_approved}' : '') . '
		WHERE id_topic IN ({array_int:topics})', array('id_board' => $toBoard, 'topics' => $topics, 'is_approved' => 1, 'no_unapproved' => 0));
    // If this was going to the recycle bin, check what messages are being recycled, and remove them from the queue.
    if ($isRecycleDest && ($totalUnapprovedTopics || $totalUnapprovedPosts)) {
        $request = $smcFunc['db_query']('', '
			SELECT id_msg
			FROM {db_prefix}messages
			WHERE id_topic IN ({array_int:topics})
				and approved = {int:not_approved}', array('topics' => $topics, 'not_approved' => 0));
        $approval_msgs = array();
        while ($row = $smcFunc['db_fetch_assoc']($request)) {
            $approval_msgs[] = $row['id_msg'];
        }
        $smcFunc['db_free_result']($request);
        // Empty the approval queue for these, as we're going to approve them next.
        if (!empty($approval_msgs)) {
            $smcFunc['db_query']('', '
				DELETE FROM {db_prefix}approval_queue
				WHERE id_msg IN ({array_int:message_list})
					AND id_attach = {int:id_attach}', array('message_list' => $approval_msgs, 'id_attach' => 0));
        }
        // Get all the current max and mins.
        $request = $smcFunc['db_query']('', '
			SELECT id_topic, id_first_msg, id_last_msg
			FROM {db_prefix}topics
			WHERE id_topic IN ({array_int:topics})', array('topics' => $topics));
        $topicMaxMin = array();
        while ($row = $smcFunc['db_fetch_assoc']($request)) {
            $topicMaxMin[$row['id_topic']] = array('min' => $row['id_first_msg'], 'max' => $row['id_last_msg']);
        }
        $smcFunc['db_free_result']($request);
        // Check the MAX and MIN are correct.
        $request = $smcFunc['db_query']('', '
			SELECT id_topic, MIN(id_msg) AS first_msg, MAX(id_msg) AS last_msg
			FROM {db_prefix}messages
			WHERE id_topic IN ({array_int:topics})
			GROUP BY id_topic', array('topics' => $topics));
        while ($row = $smcFunc['db_fetch_assoc']($request)) {
            // If not, update.
            if ($row['first_msg'] != $topicMaxMin[$row['id_topic']]['min'] || $row['last_msg'] != $topicMaxMin[$row['id_topic']]['max']) {
                $smcFunc['db_query']('', '
					UPDATE {db_prefix}topics
					SET id_first_msg = {int:first_msg}, id_last_msg = {int:last_msg}
					WHERE id_topic = {int:selected_topic}', array('first_msg' => $row['first_msg'], 'last_msg' => $row['last_msg'], 'selected_topic' => $row['id_topic']));
            }
        }
        $smcFunc['db_free_result']($request);
    }
    $smcFunc['db_query']('', '
		UPDATE {db_prefix}messages
		SET id_board = {int:id_board}' . ($isRecycleDest ? ',approved = {int:is_approved}' : '') . '
		WHERE id_topic IN ({array_int:topics})', array('id_board' => $toBoard, 'topics' => $topics, 'is_approved' => 1));
    $smcFunc['db_query']('', '
		UPDATE {db_prefix}log_reported
		SET id_board = {int:id_board}
		WHERE id_topic IN ({array_int:topics})', array('id_board' => $toBoard, 'topics' => $topics));
    $smcFunc['db_query']('', '
		UPDATE {db_prefix}calendar
		SET id_board = {int:id_board}
		WHERE id_topic IN ({array_int:topics})', array('id_board' => $toBoard, 'topics' => $topics));
    // Mark target board as seen, if it was already marked as seen before.
    $request = $smcFunc['db_query']('', '
		SELECT (IFNULL(lb.id_msg, 0) >= b.id_msg_updated) AS isSeen
		FROM {db_prefix}boards AS b
			LEFT JOIN {db_prefix}log_boards AS lb ON (lb.id_board = b.id_board AND lb.id_member = {int:current_member})
		WHERE b.id_board = {int:id_board}', array('current_member' => $user_info['id'], 'id_board' => $toBoard));
    list($isSeen) = $smcFunc['db_fetch_row']($request);
    $smcFunc['db_free_result']($request);
    if (!empty($isSeen) && !$user_info['is_guest']) {
        $smcFunc['db_insert']('replace', '{db_prefix}log_boards', array('id_board' => 'int', 'id_member' => 'int', 'id_msg' => 'int'), array($toBoard, $user_info['id'], $modSettings['maxMsgID']), array('id_board', 'id_member'));
    }
    // Update 'em pesky stats.
    updateStats('topic');
    updateStats('message');
    updateSettings(array('calendar_updated' => time()));
    // Update the cache?
    if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) {
        foreach ($topics as $topic_id) {
            cache_put_data('topic_board-' . $topic_id, null, 120);
        }
    }
    require_once $sourcedir . '/Subs-Post.php';
    $updates = array_keys($fromBoards);
    $updates[] = $toBoard;
    updateLastMessages(array_unique($updates));
}
开发者ID:Kheros,项目名称:MMOver,代码行数:101,代码来源:MoveTopic.php

示例11: create_control_verification

function create_control_verification(&$verificationOptions, $do_test = false)
{
    global $txt, $modSettings, $options, $smcFunc;
    global $context, $settings, $user_info, $sourcedir, $scripturl;
    // First verification means we need to set up some bits...
    if (empty($context['controls']['verification'])) {
        // The template
        loadTemplate('GenericControls');
        // Some javascript ma'am?
        if (!empty($verificationOptions['override_visual']) || !empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual'])) {
            $context['html_headers'] .= '
		<script type="text/javascript" src="' . $settings['default_theme_url'] . '/scripts/captcha.js"></script>';
        }
        $context['use_graphic_library'] = in_array('gd', get_loaded_extensions());
        // Skip I, J, L, O, Q, S and Z.
        $context['standard_captcha_range'] = array_merge(range('A', 'H'), array('K', 'M', 'N', 'P', 'R'), range('T', 'Y'));
    }
    // Always have an ID.
    assert(isset($verificationOptions['id']));
    $isNew = !isset($context['controls']['verification'][$verificationOptions['id']]);
    // Log this into our collection.
    if ($isNew) {
        $context['controls']['verification'][$verificationOptions['id']] = array('id' => $verificationOptions['id'], 'show_visual' => !empty($verificationOptions['override_visual']) || !empty($modSettings['visual_verification_type']) && !isset($verificationOptions['override_visual']), 'number_questions' => isset($verificationOptions['override_qs']) ? $verificationOptions['override_qs'] : (!empty($modSettings['qa_verification_number']) ? $modSettings['qa_verification_number'] : 0), 'max_errors' => isset($verificationOptions['max_errors']) ? $verificationOptions['max_errors'] : 3, 'image_href' => $scripturl . '?action=verificationcode;vid=' . $verificationOptions['id'] . ';rand=' . md5(mt_rand()), 'text_value' => '', 'questions' => array());
    }
    $thisVerification =& $context['controls']['verification'][$verificationOptions['id']];
    // Add javascript for the object.
    if ($context['controls']['verification'][$verificationOptions['id']]['show_visual'] && !WIRELESS) {
        $context['insert_after_template'] .= '
			<script type="text/javascript"><!-- // --><![CDATA[
				var verification' . $verificationOptions['id'] . 'Handle = new smfCaptcha("' . $thisVerification['image_href'] . '", "' . $verificationOptions['id'] . '", ' . ($context['use_graphic_library'] ? 1 : 0) . ');
			// ]]></script>';
    }
    // Is there actually going to be anything?
    if (empty($thisVerification['show_visual']) && empty($thisVerification['number_questions'])) {
        return false;
    } elseif (!$isNew && !$do_test) {
        return true;
    }
    // If we want questions do we have a cache of all the IDs?
    if (!empty($thisVerification['number_questions']) && empty($modSettings['question_id_cache'])) {
        if (($modSettings['question_id_cache'] = cache_get_data('verificationQuestionIds', 300)) == null) {
            $request = $smcFunc['db_query']('', '
				SELECT id_comment
				FROM {db_prefix}log_comments
				WHERE comment_type = {string:ver_test}', array('ver_test' => 'ver_test'));
            $modSettings['question_id_cache'] = array();
            while ($row = $smcFunc['db_fetch_assoc']($request)) {
                $modSettings['question_id_cache'][] = $row['id_comment'];
            }
            $smcFunc['db_free_result']($request);
            if (!empty($modSettings['cache_enable'])) {
                cache_put_data('verificationQuestionIds', $modSettings['question_id_cache'], 300);
            }
        }
    }
    if (!isset($_SESSION[$verificationOptions['id'] . '_vv'])) {
        $_SESSION[$verificationOptions['id'] . '_vv'] = array();
    }
    // Do we need to refresh the verification?
    if (!$do_test && (!empty($_SESSION[$verificationOptions['id'] . '_vv']['did_pass']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['count']) || $_SESSION[$verificationOptions['id'] . '_vv']['count'] > 3) && empty($verificationOptions['dont_refresh'])) {
        $force_refresh = true;
    } else {
        $force_refresh = false;
    }
    // This can also force a fresh, although unlikely.
    if ($thisVerification['show_visual'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['code']) || $thisVerification['number_questions'] && empty($_SESSION[$verificationOptions['id'] . '_vv']['q'])) {
        $force_refresh = true;
    }
    $verification_errors = array();
    // Start with any testing.
    if ($do_test) {
        // This cannot happen!
        if (!isset($_SESSION[$verificationOptions['id'] . '_vv']['count'])) {
            fatal_lang_error('no_access', false);
        }
        // ... nor this!
        if ($thisVerification['number_questions'] && (!isset($_SESSION[$verificationOptions['id'] . '_vv']['q']) || !isset($_REQUEST[$verificationOptions['id'] . '_vv']['q']))) {
            fatal_lang_error('no_access', false);
        }
        if ($thisVerification['show_visual'] && (empty($_REQUEST[$verificationOptions['id'] . '_vv']['code']) || empty($_SESSION[$verificationOptions['id'] . '_vv']['code']) || strtoupper($_REQUEST[$verificationOptions['id'] . '_vv']['code']) !== $_SESSION[$verificationOptions['id'] . '_vv']['code'])) {
            $verification_errors[] = 'wrong_verification_code';
        }
        if ($thisVerification['number_questions']) {
            // Get the answers and see if they are all right!
            $request = $smcFunc['db_query']('', '
				SELECT id_comment, recipient_name AS answer
				FROM {db_prefix}log_comments
				WHERE comment_type = {string:ver_test}
					AND id_comment IN ({array_int:comment_ids})', array('ver_test' => 'ver_test', 'comment_ids' => $_SESSION[$verificationOptions['id'] . '_vv']['q']));
            $incorrectQuestions = array();
            while ($row = $smcFunc['db_fetch_assoc']($request)) {
                if (empty($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$row['id_comment']]) || trim($smcFunc['htmlspecialchars'](strtolower($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$row['id_comment']]))) != strtolower($row['answer'])) {
                    $incorrectQuestions[] = $row['id_comment'];
                }
            }
            $smcFunc['db_free_result']($request);
            if (!empty($incorrectQuestions)) {
                $verification_errors[] = 'wrong_verification_answer';
            }
        }
//.........这里部分代码省略.........
开发者ID:AhoyLemon,项目名称:ballpit,代码行数:101,代码来源:Subs-Editor.php

示例12: searchQuery

 /**
  * This has it's own custom search.
  *
  * @param mixed[] $search_params
  * @param mixed[] $search_words
  * @param string[] $excluded_words
  * @param int[] $participants
  * @param string[] $search_results
  */
 public function searchQuery($search_params, $search_words, $excluded_words, &$participants, &$search_results)
 {
     global $user_info, $context, $modSettings;
     // Only request the results if they haven't been cached yet.
     if (($cached_results = cache_get_data('searchql_results_' . md5($user_info['query_see_board'] . '_' . $context['params']))) === null) {
         // Create an instance of the sphinx client and set a few options.
         $mySphinx = @mysql_connect(($modSettings['sphinx_searchd_server'] === 'localhost' ? '127.0.0.1' : $modSettings['sphinx_searchd_server']) . ':' . (int) $modSettings['sphinxql_searchd_port']);
         // No connection, daemon not running?  log the error
         if ($mySphinx === false) {
             fatal_lang_error('error_no_search_daemon');
         }
         // Compile different options for our query
         $query = 'SELECT *' . (empty($search_params['topic']) ? ', COUNT(*) num' : '') . ', (weight() + (relevance/1000)) rank FROM elkarte_index';
         // Construct the (binary mode & |) query.
         $where_match = $this->_constructQuery($search_params['search']);
         // Nothing to search, return zero results
         if (trim($where_match) === '') {
             return 0;
         }
         if ($search_params['subject_only']) {
             $where_match = '@subject ' . $where_match;
         }
         $query .= ' WHERE MATCH(\'' . $where_match . '\')';
         // Set the limits based on the search parameters.
         $extra_where = array();
         if (!empty($search_params['min_msg_id']) || !empty($search_params['max_msg_id'])) {
             $extra_where[] = 'id >= ' . $search_params['min_msg_id'] . ' AND id <= ' . (empty($search_params['max_msg_id']) ? (int) $modSettings['maxMsgID'] : $search_params['max_msg_id']);
         }
         if (!empty($search_params['topic'])) {
             $extra_where[] = 'id_topic = ' . (int) $search_params['topic'];
         }
         if (!empty($search_params['brd'])) {
             $extra_where[] = 'id_board IN (' . implode(',', $search_params['brd']) . ')';
         }
         if (!empty($search_params['memberlist'])) {
             $extra_where[] = 'id_member IN (' . implode(',', $search_params['memberlist']) . ')';
         }
         if (!empty($extra_where)) {
             $query .= ' AND ' . implode(' AND ', $extra_where);
         }
         // Put together a sort string; besides the main column sort (relevance, id_topic, or num_replies)
         $search_params['sort_dir'] = strtoupper($search_params['sort_dir']);
         $sphinx_sort = $search_params['sort'] === 'id_msg' ? 'id_topic' : $search_params['sort'];
         // Add secondary sorting based on relevance value (if not the main sort method) and age
         $sphinx_sort .= ' ' . $search_params['sort_dir'] . ($search_params['sort'] === 'relevance' ? '' : ', relevance DESC') . ', poster_time DESC';
         // Replace relevance with the returned rank value, rank uses sphinx weight + our own computed field weight relevance
         $sphinx_sort = str_replace('relevance ', 'rank ', $sphinx_sort);
         // Grouping by topic id makes it return only one result per topic, so don't set that for in-topic searches
         if (empty($search_params['topic'])) {
             $query .= ' GROUP BY id_topic WITHIN GROUP ORDER BY ' . $sphinx_sort;
         }
         $query .= ' ORDER BY ' . $sphinx_sort;
         $query .= ' LIMIT 0,' . (int) $modSettings['sphinx_max_results'];
         // Set any options needed, like field weights
         $query .= ' OPTION field_weights=(subject=' . (!empty($modSettings['search_weight_subject']) ? $modSettings['search_weight_subject'] * 200 : 1000) . ',body=1000)';
         // Execute the search query.
         $request = mysql_query($query, $mySphinx);
         // Can a connection to the daemon be made?
         if ($request === false) {
             // Just log the error.
             if (mysql_error($mySphinx)) {
                 log_error(mysql_error($mySphinx));
             }
             fatal_lang_error('error_no_search_daemon');
         }
         // Get the relevant information from the search results.
         $cached_results = array('num_results' => 0, 'matches' => array());
         if (mysql_num_rows($request) != 0) {
             while ($match = mysql_fetch_assoc($request)) {
                 if (empty($search_params['topic'])) {
                     $num = isset($match['num']) ? $match['num'] : (isset($match['@count']) ? $match['@count'] : 0);
                 } else {
                     $num = 0;
                 }
                 $cached_results['matches'][$match['id']] = array('id' => $match['id_topic'], 'relevance' => round($match['relevance'] / 10000, 1) . '%', 'num_matches' => $num, 'matches' => array());
             }
         }
         mysql_free_result($request);
         mysql_close($mySphinx);
         $cached_results['num_results'] = count($cached_results['matches']);
         // Store the search results in the cache.
         cache_put_data('searchql_results_' . md5($user_info['query_see_board'] . '_' . $context['params']), $cached_results, 600);
     }
     $participants = array();
     foreach (array_slice(array_keys($cached_results['matches']), $_REQUEST['start'], $modSettings['search_results_per_page']) as $msgID) {
         $context['topics'][$msgID] = $cached_results['matches'][$msgID];
         $participants[$cached_results['matches'][$msgID]['id']] = false;
     }
     // Sentences need to be broken up in words for proper highlighting.
     $search_results = array();
     foreach ($search_words as $orIndex => $words) {
//.........这里部分代码省略.........
开发者ID:scripple,项目名称:Elkarte,代码行数:101,代码来源:SearchAPI-Sphinxql.class.php

示例13: up_print_MultiBlock

function up_print_MultiBlock($position)
{
    global $context, $scripturl, $ultimateportalSettings, $user_info;
    if ($position == 'header') {
        if (!empty($ultimateportalSettings['up_reduce_site_overload'])) {
            if (cache_get_data('mbk_header', 1800) === NULL) {
                LoadBlocksHEADERPortal("and enable=1");
                cache_put_data('mbk_header', !empty($context['block-' . $position]), 1800);
                cache_put_data('exists_multi' . $position, $context['exists_multi' . $position], 1800);
            } else {
                $context['block-' . $position] = cache_get_data('mbk_header', 1800);
                $context['exists_multi' . $position] = cache_get_data('exists_multi' . $position, 1800);
            }
        } else {
            LoadBlocksHEADERPortal("and enable=1");
        }
    }
    if ($position == 'footer') {
        if (!empty($ultimateportalSettings['up_reduce_site_overload'])) {
            if (cache_get_data('mbk_footer', 1800) === NULL) {
                LoadBlocksFOOTERPortal("and enable=1");
                cache_put_data('mbk_footer', !empty($context['block-' . $position]), 1800);
                cache_put_data('exists_multi' . $position, $context['exists_multi' . $position], 1800);
            } else {
                $context['block-' . $position] = cache_get_data('mbk_footer', 1800);
                $context['exists_multi' . $position] = cache_get_data('exists_multi' . $position, 1800);
            }
        } else {
            LoadBlocksFOOTERPortal("and enable=1");
        }
    }
    if (!empty($context['exists_multi' . $position])) {
        echo '
		<table id="up_bk_table_main" style="width:100%" cellpadding="3" cellspacing="0">
		<tr>
		<td>';
        foreach ($context['block-' . $position] as $multiblock) {
            $title = $user_info['is_admin'] ? '<a href="' . $scripturl . '?action=adminportal;area=multiblock;sa=edit;id=' . $multiblock['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '">' . $multiblock['mbtitle'] . '</a>' : $multiblock['mbtitle'];
            head_block('up-multiblock', $title, '-' . $multiblock['id'], $multiblock['mbk_collapse'], $multiblock['mbk_title'], $multiblock['mbk_style']);
            switch ($multiblock['design']) {
                case '1-2':
                    $column = 1;
                    //per line
                    break;
                case '2-1':
                    $column = 2;
                    //per line
                    break;
                case '3-1':
                    $column = 2;
                    //per line
                    break;
                default:
                    $column = 1;
                    //per line
                    break;
            }
            //1 Row 2 Columns
            if ($multiblock['design'] == '1-2') {
                $c1 = !empty($multiblock['vblocks']['c1']) ? count($multiblock['vblocks']['c1']) : 0;
                $c2 = !empty($multiblock['vblocks']['c2']) ? count($multiblock['vblocks']['c2']) : 0;
                echo '
				<table id="up_bk_table_main" style="width:100%" cellpadding="5" cellspacing="2">
					<tr>';
                //Now View Column 1
                if (!empty($multiblock['vblocks']['c1'])) {
                    echo '
							<td valign="top" align="left">';
                    foreach ($multiblock['vblocks']['c1'] as $vblocks) {
                        echo '
								', up_get_MBcolumn($vblocks['id']), '';
                    }
                    echo '
							</td>';
                }
                //Now View Column 2
                if (!empty($multiblock['vblocks']['c2'])) {
                    echo '
							<td valign="top" align="left">';
                    foreach ($multiblock['vblocks']['c2'] as $vblocks) {
                        echo '
								', up_get_MBcolumn($vblocks['id']), '';
                    }
                    echo '
							</td>';
                }
                echo '
					</tr>
				</table>';
                //End View Column 1
            }
            //End Design 1-2
            //2 Rows 1 Column
            if ($multiblock['design'] == '2-1') {
                $r1 = !empty($multiblock['vblocks']['r1']) ? count($multiblock['vblocks']['r1']) : 0;
                $r2 = !empty($multiblock['vblocks']['r2']) ? count($multiblock['vblocks']['r2']) : 0;
                $context['width_1'] = $r1 >= 1 && $r1 <= 2 ? '50%' : '33%';
                $context['width_2'] = $r2 >= 1 && $r2 <= 2 ? '50%' : '33%';
                $i = 1;
                //flag
//.........这里部分代码省略.........
开发者ID:4kstore,项目名称:UltimatePortal-0.4,代码行数:101,代码来源:Subs-UltimatePortal-Init-Blocks.php

示例14: ShowXmlFeed

function ShowXmlFeed()
{
    global $db_prefix, $board, $board_info, $context, $scripturl, $txt, $modSettings, $user_info;
    global $query_this_board;
    // If it's not enabled, die.
    if (empty($modSettings['xmlnews_enable'])) {
        obExit(false);
    }
    loadLanguage('Stats');
    // Default to latest 5.  No more than 255, please.
    $_GET['limit'] = empty($_GET['limit']) || (int) $_GET['limit'] < 1 ? 5 : min((int) $_GET['limit'], 255);
    // Handle the cases where a board, boards, or category is asked for.
    if (!empty($_REQUEST['c']) && empty($board)) {
        $_REQUEST['c'] = explode(',', $_REQUEST['c']);
        foreach ($_REQUEST['c'] as $i => $c) {
            $_REQUEST['c'][$i] = (int) $c;
        }
        if (count($_REQUEST['c']) == 1) {
            $request = db_query("\n\t\t\t\tSELECT name\n\t\t\t\tFROM {$db_prefix}categories\n\t\t\t\tWHERE ID_CAT = " . (int) $_REQUEST['c'][0], __FILE__, __LINE__);
            list($feed_title) = mysql_fetch_row($request);
            mysql_free_result($request);
            $feed_title = ' - ' . strip_tags($feed_title);
        }
        $request = db_query("\n\t\t\tSELECT b.ID_BOARD, b.numPosts\n\t\t\tFROM {$db_prefix}boards AS b\n\t\t\tWHERE b.ID_CAT IN (" . implode(', ', $_REQUEST['c']) . ")\n\t\t\t\tAND {$user_info['query_see_board']}", __FILE__, __LINE__);
        $total_cat_posts = 0;
        $boards = array();
        while ($row = mysql_fetch_assoc($request)) {
            $boards[] = $row['ID_BOARD'];
            $total_cat_posts += $row['numPosts'];
        }
        mysql_free_result($request);
        if (!empty($boards)) {
            $query_this_board = 'b.ID_BOARD IN (' . implode(', ', $boards) . ')';
        }
        // Try to limit the number of messages we look through.
        if ($total_cat_posts > 100 && $total_cat_posts > $modSettings['totalMessages'] / 15) {
            $query_this_board .= '
			AND m.ID_MSG >= ' . max(0, $modSettings['maxMsgID'] - 400 - $_GET['limit'] * 5);
        }
    } elseif (!empty($_REQUEST['boards'])) {
        $_REQUEST['boards'] = explode(',', $_REQUEST['boards']);
        foreach ($_REQUEST['boards'] as $i => $b) {
            $_REQUEST['boards'][$i] = (int) $b;
        }
        $request = db_query("\n\t\t\tSELECT b.ID_BOARD, b.numPosts, b.name\n\t\t\tFROM {$db_prefix}boards AS b\n\t\t\tWHERE b.ID_BOARD IN (" . implode(', ', $_REQUEST['boards']) . ")\n\t\t\t\tAND {$user_info['query_see_board']}\n\t\t\tLIMIT " . count($_REQUEST['boards']), __FILE__, __LINE__);
        // Either the board specified doesn't exist or you have no access.
        if (mysql_num_rows($request) == 0) {
            fatal_lang_error('smf232');
        }
        $total_posts = 0;
        $boards = array();
        while ($row = mysql_fetch_assoc($request)) {
            if (count($_REQUEST['boards']) == 1) {
                $feed_title = ' - ' . strip_tags($row['name']);
            }
            $boards[] = $row['ID_BOARD'];
            $total_posts += $row['numPosts'];
        }
        mysql_free_result($request);
        if (!empty($boards)) {
            $query_this_board = 'b.ID_BOARD IN (' . implode(', ', $boards) . ')';
        }
        // The more boards, the more we're going to look through...
        if ($total_posts > 100 && $total_posts > $modSettings['totalMessages'] / 12) {
            $query_this_board .= '
			AND m.ID_MSG >= ' . max(0, $modSettings['maxMsgID'] - 500 - $_GET['limit'] * 5);
        }
    } elseif (!empty($board)) {
        $request = db_query("\n\t\t\tSELECT numPosts\n\t\t\tFROM {$db_prefix}boards\n\t\t\tWHERE ID_BOARD = {$board}\n\t\t\tLIMIT 1", __FILE__, __LINE__);
        list($total_posts) = mysql_fetch_row($request);
        mysql_free_result($request);
        $feed_title = ' - ' . strip_tags($board_info['name']);
        $query_this_board = 'b.ID_BOARD = ' . $board;
        // Try to look through just a few messages, if at all possible.
        if ($total_posts > 80 && $total_posts > $modSettings['totalMessages'] / 10) {
            $query_this_board .= '
			AND m.ID_MSG >= ' . max(0, $modSettings['maxMsgID'] - 600 - $_GET['limit'] * 5);
        }
    } else {
        $query_this_board = $user_info['query_see_board'] . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? "\n\t\t\tAND b.ID_BOARD != {$modSettings['recycle_board']}" : '') . '
			AND m.ID_MSG >= ' . max(0, $modSettings['maxMsgID'] - 100 - $_GET['limit'] * 5);
    }
    // Show in rss or proprietary format?
    $xml_format = isset($_GET['type']) && in_array($_GET['type'], array('smf', 'rss', 'rss2', 'atom', 'rdf')) ? $_GET['type'] : 'smf';
    // !!! Birthdays?
    // List all the different types of data they can pull.
    $subActions = array('recent' => array('getXmlRecent', 'recent-post'), 'news' => array('getXmlNews', 'article'), 'members' => array('getXmlMembers', 'member'), 'profile' => array('getXmlProfile', null));
    if (empty($_GET['sa']) || !isset($subActions[$_GET['sa']])) {
        $_GET['sa'] = 'recent';
    }
    // Get the associative array representing the xml.
    if ($user_info['is_guest'] && !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
        $xml = cache_get_data('xmlfeed-' . $xml_format . ':' . md5(serialize($_GET)), 240);
    }
    if (empty($xml)) {
        $xml = $subActions[$_GET['sa']][0]($xml_format);
        if ($user_info['is_guest'] && !empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
            cache_put_data('xmlfeed-' . $xml_format . ':' . md5(serialize($_GET)), $xml, 240);
        }
    }
//.........这里部分代码省略.........
开发者ID:VBGAMER45,项目名称:SMFMods,代码行数:101,代码来源:News.php

示例15: up_create_control_richedit


//.........这里部分代码省略.........
            // Some hidden information is needed in order to make the spell checking work.
            if (!isset($_REQUEST['xml'])) {
                $context['insert_after_template'] .= '
				<form name="spell_form" id="spell_form" method="post" accept-charset="' . $context['character_set'] . '" target="spellWindow" action="' . $scripturl . '?action=spellcheck">
					<input type="hidden" name="spellstring" value="" />
				</form>';
            }
            // Also make sure that spell check works with rich edit.
            $context['html_headers'] .= '
				<script type="text/javascript"><!-- // --><![CDATA[
				function spellCheckDone()
				{
					for (i = 0; i < smf_editorArray.length; i++)
						setTimeout("smf_editorArray[" + i + "].spellCheckEnd()", 150);
				}
				// ]]></script>';
        }
    }
    // Start off the editor...
    $context['controls']['richedit'][$editorOptions['id']] = array('id' => $editorOptions['id'], 'value' => $editorOptions['value'], 'rich_value' => addcslashes(bbc_to_html($editorOptions['value']), "'"), 'rich_active' => empty($modSettings['disable_wysiwyg']) && (!empty($options['wysiwyg_default']) || !empty($editorOptions['force_rich']) || !empty($_REQUEST[$editorOptions['id'] . '_mode'])), 'disable_smiley_box' => !empty($editorOptions['disable_smiley_box']), 'columns' => isset($editorOptions['columns']) ? $editorOptions['columns'] : 60, 'rows' => isset($editorOptions['rows']) ? $editorOptions['rows'] : 12, 'width' => isset($editorOptions['width']) ? $editorOptions['width'] : '100%', 'height' => isset($editorOptions['height']) ? $editorOptions['height'] : '150px', 'form' => isset($editorOptions['form']) ? $editorOptions['form'] : 'postmodify', 'bbc_level' => !empty($editorOptions['bbc_level']) ? $editorOptions['bbc_level'] : 'full', 'preview_type' => isset($editorOptions['preview_type']) ? (int) $editorOptions['preview_type'] : 1, 'labels' => !empty($editorOptions['labels']) ? $editorOptions['labels'] : array());
    // Switch between default images and back... mostly in case you don't have an PersonalMessage template, but do have a Post template.
    if (isset($settings['use_default_images']) && $settings['use_default_images'] == 'defaults' && isset($settings['default_template'])) {
        $temp1 = $settings['theme_url'];
        $settings['theme_url'] = $settings['default_theme_url'];
        $temp2 = $settings['images_url'];
        $settings['images_url'] = $settings['default_images_url'];
        $temp3 = $settings['theme_dir'];
        $settings['theme_dir'] = $settings['default_theme_dir'];
    }
    if (empty($context['bbc_tags'])) {
        // The below array makes it dead easy to add images to this control. Add it to the array and everything else is done for you!
        $context['bbc_tags'] = array();
        $context['bbc_tags'][] = array(array('image' => 'bold', 'code' => 'b', 'before' => '[b]', 'after' => '[/b]', 'description' => $txt['bold']), array('image' => 'italicize', 'code' => 'i', 'before' => '[i]', 'after' => '[/i]', 'description' => $txt['italic']), array('image' => 'underline', 'code' => 'u', 'before' => '[u]', 'after' => '[/u]', 'description' => $txt['underline']), array('image' => 'strike', 'code' => 's', 'before' => '[s]', 'after' => '[/s]', 'description' => $txt['strike']), array(), array('image' => 'pre', 'code' => 'pre', 'before' => '[pre]', 'after' => '[/pre]', 'description' => $txt['preformatted']), array('image' => 'left', 'code' => 'left', 'before' => '[left]', 'after' => '[/left]', 'description' => $txt['left_align']), array('image' => 'center', 'code' => 'center', 'before' => '[center]', 'after' => '[/center]', 'description' => $txt['center']), array('image' => 'right', 'code' => 'right', 'before' => '[right]', 'after' => '[/right]', 'description' => $txt['right_align']));
        $context['bbc_tags'][] = array(array('image' => 'flash', 'code' => 'flash', 'before' => '[flash=200,200]', 'after' => '[/flash]', 'description' => $txt['flash']), array('image' => 'img', 'code' => 'img', 'before' => '[img]', 'after' => '[/img]', 'description' => $txt['image']), array('image' => 'url', 'code' => 'url', 'before' => '[url]', 'after' => '[/url]', 'description' => $txt['hyperlink']), array('image' => 'email', 'code' => 'email', 'before' => '[email]', 'after' => '[/email]', 'description' => $txt['insert_email']), array('image' => 'ftp', 'code' => 'ftp', 'before' => '[ftp]', 'after' => '[/ftp]', 'description' => $txt['ftp']), array(), array('image' => 'glow', 'code' => 'glow', 'before' => '[glow=red,2,300]', 'after' => '[/glow]', 'description' => $txt['glow']), array('image' => 'shadow', 'code' => 'shadow', 'before' => '[shadow=red,left]', 'after' => '[/shadow]', 'description' => $txt['shadow']), array('image' => 'move', 'code' => 'move', 'before' => '[move]', 'after' => '[/move]', 'description' => $txt['marquee']), array(), array('image' => 'sup', 'code' => 'sup', 'before' => '[sup]', 'after' => '[/sup]', 'description' => $txt['superscript']), array('image' => 'sub', 'code' => 'sub', 'before' => '[sub]', 'after' => '[/sub]', 'description' => $txt['subscript']), array('image' => 'tele', 'code' => 'tt', 'before' => '[tt]', 'after' => '[/tt]', 'description' => $txt['teletype']), array(), array('image' => 'table', 'code' => 'table', 'before' => '[table]\\n[tr]\\n[td]', 'after' => '[/td]\\n[/tr]\\n[/table]', 'description' => $txt['table']), array('image' => 'code', 'code' => 'code', 'before' => '[code]', 'after' => '[/code]', 'description' => $txt['bbc_code']), array('image' => 'quote', 'code' => 'quote', 'before' => '[quote]', 'after' => '[/quote]', 'description' => $txt['bbc_quote']), array(), array('image' => 'list', 'code' => 'list', 'before' => '[list]\\n[li]', 'after' => '[/li]\\n[li][/li]\\n[/list]', 'description' => $txt['list']), array('image' => 'orderlist', 'code' => 'orderlist', 'before' => '[list type=decimal]\\n[li]', 'after' => '[/li]\\n[li][/li]\\n[/list]', 'description' => $txt['list']), array('image' => 'hr', 'code' => 'hr', 'before' => '[hr]', 'description' => $txt['horizontal_rule']));
        // Show the toggle?
        if (empty($modSettings['disable_wysiwyg'])) {
            $context['bbc_tags'][count($context['bbc_tags']) - 1][] = array();
            $context['bbc_tags'][count($context['bbc_tags']) - 1][] = array('image' => 'unformat', 'code' => 'unformat', 'before' => '', 'description' => $txt['unformat_text']);
            $context['bbc_tags'][count($context['bbc_tags']) - 1][] = array('image' => 'toggle', 'code' => 'toggle', 'before' => '', 'description' => $txt['toggle_view']);
        }
        foreach ($context['bbc_tags'] as $row => $tagRow) {
            $context['bbc_tags'][$row][count($tagRow) - 1]['isLast'] = true;
        }
    }
    // Initialize smiley array... if not loaded before.
    if (empty($context['smileys']) && empty($editorOptions['disable_smiley_box'])) {
        $context['smileys'] = array('postform' => array(), 'popup' => array());
        // Load smileys - don't bother to run a query if we're not using the database's ones anyhow.
        if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') {
            $context['smileys']['postform'][] = array('smileys' => array(array('code' => ':)', 'filename' => 'smiley.gif', 'description' => $txt['icon_smiley']), array('code' => ';)', 'filename' => 'wink.gif', 'description' => $txt['icon_wink']), array('code' => ':D', 'filename' => 'cheesy.gif', 'description' => $txt['icon_cheesy']), array('code' => ';D', 'filename' => 'grin.gif', 'description' => $txt['icon_grin']), array('code' => '>:(', 'filename' => 'angry.gif', 'description' => $txt['icon_angry']), array('code' => ':(', 'filename' => 'sad.gif', 'description' => $txt['icon_sad']), array('code' => ':o', 'filename' => 'shocked.gif', 'description' => $txt['icon_shocked']), array('code' => '8)', 'filename' => 'cool.gif', 'description' => $txt['icon_cool']), array('code' => '???', 'filename' => 'huh.gif', 'description' => $txt['icon_huh']), array('code' => '::)', 'filename' => 'rolleyes.gif', 'description' => $txt['icon_rolleyes']), array('code' => ':P', 'filename' => 'tongue.gif', 'description' => $txt['icon_tongue']), array('code' => ':-[', 'filename' => 'embarrassed.gif', 'description' => $txt['icon_embarrassed']), array('code' => ':-X', 'filename' => 'lipsrsealed.gif', 'description' => $txt['icon_lips']), array('code' => ':-\\', 'filename' => 'undecided.gif', 'description' => $txt['icon_undecided']), array('code' => ':-*', 'filename' => 'kiss.gif', 'description' => $txt['icon_kiss']), array('code' => ':\'(', 'filename' => 'cry.gif', 'description' => $txt['icon_cry'], 'isLast' => true)), 'isLast' => true);
        } elseif ($user_info['smiley_set'] != 'none') {
            if (($temp = cache_get_data('posting_smileys', 480)) == null) {
                $request = $smcFunc['db_query']('', '
					SELECT code, filename, description, smiley_row, hidden
					FROM {db_prefix}smileys
					WHERE hidden IN (0, 2)
					ORDER BY smiley_row, smiley_order', array());
                while ($row = $smcFunc['db_fetch_assoc']($request)) {
                    $row['filename'] = htmlspecialchars($row['filename']);
                    $row['description'] = htmlspecialchars($row['description']);
                    $context['smileys'][empty($row['hidden']) ? 'postform' : 'popup'][$row['smiley_row']]['smileys'][] = $row;
                }
                $smcFunc['db_free_result']($request);
                foreach ($context['smileys'] as $section => $smileyRows) {
                    foreach ($smileyRows as $rowIndex => $smileys) {
                        $context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true;
                    }
                    if (!empty($smileyRows)) {
                        $context['smileys'][$section][count($smileyRows) - 1]['isLast'] = true;
                    }
                }
                cache_put_data('posting_smileys', $context['smileys'], 480);
            } else {
                $context['smileys'] = $temp;
            }
        }
    }
    // Set a flag so the sub template knows what to do...
    $context['show_bbc'] = !empty($modSettings['enableBBC']) && !empty($settings['show_bbc']);
    // Generate a list of buttons that shouldn't be shown - this should be the fastest way to do this.
    $disabled_tags = array();
    if (!empty($modSettings['disabledBBC'])) {
        $disabled_tags = explode(',', $modSettings['disabledBBC']);
    }
    if (empty($modSettings['enableEmbeddedFlash'])) {
        $disabled_tags[] = 'flash';
    }
    foreach ($disabled_tags as $tag) {
        if ($tag == 'list') {
            $context['disabled_tags']['orderlist'] = true;
        }
        $context['disabled_tags'][trim($tag)] = true;
    }
    // Switch the URLs back... now we're back to whatever the main sub template is.  (like folder in PersonalMessage.)
    if (isset($settings['use_default_images']) && $settings['use_default_images'] == 'defaults' && isset($settings['default_template'])) {
        $settings['theme_url'] = $temp1;
        $settings['images_url'] = $temp2;
        $settings['theme_dir'] = $temp3;
    }
}
开发者ID:4kstore,项目名称:UltimatePortal-0.4,代码行数:101,代码来源:Subs-UltimatePortal.php


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