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


PHP clean_cache函数代码示例

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


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

示例1: setTheme

 public function setTheme($name)
 {
     if (D('Config')->where(array('name' => '_THEME_NOW_THEME'))->count()) {
         $res = D('Config')->where(array('name' => '_THEME_NOW_THEME'))->setField('value', $name);
     } else {
         $config['name'] = '_THEME_NOW_THEME';
         $config['type'] = 0;
         $config['title'] = '';
         $config['group'] = 0;
         $config['extra'] = '';
         $config['remark'] = '';
         $config['create_time'] = time();
         $config['update_time'] = time();
         $config['status'] = 1;
         $config['value'] = $name;
         $config['sort'] = 0;
         $res = D('Config')->add($config);
     }
     if ($res) {
         S('conf_THEME_NOW_THEME', $name);
         cookie('TO_LOOK_THEME', $name, array('prefix' => 'OSV2'));
         clean_cache(RUNTIME_PATH . 'Cache/');
         //清除模板缓存
         return true;
     } else {
         $this->error = L('_WRITE_DATABASE_FAILURE_WITH_PERIOD_');
         return false;
     }
 }
开发者ID:nanhuacrab,项目名称:jhysns,代码行数:29,代码来源:ThemeModel.class.php

示例2: cache_check_diskspace2

function cache_check_diskspace2()
{
    $too_old = 86400;
    while (1) {
        $f = disk_free_space("../cache");
        $u = disk_usage("../cache");
        echo "free: {$f} used: {$u}\n";
        if ($f > MIN_FREE_SPACE && $u < MAX_CACHE_USAGE) {
            break;
        }
        clean_cache($too_old, "../cache");
        $too_old /= 2;
    }
}
开发者ID:Turante,项目名称:boincweb,代码行数:14,代码来源:clean_cache.php

示例3: KB_cleanCache

function KB_cleanCache()
{
    global $cachedir;
    if (!is_dir($cachedir)) {
        return;
    }
    $files = scandir($cachedir);
    $failed = true;
    foreach ($files as $key => $value) {
        if (strpos($value, 'kb_') && $value != 'index.php' && $value != '.htaccess') {
            @unlink($cachedir . '/' . $value);
            $failed = false;
        }
    }
    if ($failed == true) {
        //fall back just incase you never know :P
        clean_cache();
    }
}
开发者ID:VBGAMER45,项目名称:SMFMods,代码行数:19,代码来源:KBSubs.php

示例4: addMenuButtonWithBoardsListAdminSettings

/**
 * @param bool $return_config
 * @return array config vars
 */
function addMenuButtonWithBoardsListAdminSettings($return_config = false)
{
    global $txt, $scripturl, $context;
    loadLanguage('MenuButtonWithBoardsList/');
    $context['page_title'] = $txt['menu_button_with_boards'];
    $context['post_url'] = $scripturl . '?action=admin;area=modsettings;save;sa=menu_button_with_boards';
    $context['settings_message'] = '';
    $config_vars = array(array('title', 'menu_button_with_boards_settings'), array('text', 'menu_button_with_boards_title'), array('text', 'menu_button_with_boards_cats', 'subtext' => $txt['menu_button_with_boards_cats_desc']));
    if ($return_config) {
        return $config_vars;
    }
    if (isset($_GET['save'])) {
        checkSession();
        saveDBSettings($config_vars);
        clean_cache();
        redirectexit('action=admin;area=modsettings;sa=menu_button_with_boards');
    }
    prepareDBSettingContext($config_vars);
}
开发者ID:realdigger,项目名称:SMF-Menu-Button-With-Boards-List,代码行数:23,代码来源:Mod-MenuButtonWithBoardsList.php

示例5: finish

 /**
  * 升级完成
  */
 public function finish()
 {
     $nextVersion = $_SESSION['nextVersion'];
     $currentVersion = $_SESSION['currentVersion'];
     $versionModel = M('Version');
     $versionModel->where(array('name' => $nextVersion['name']))->setField('update_time', time());
     $versionModel->setCurrentVersion($nextVersion['name']);
     $this->assign('currentVersion', $versionModel->getCurrentVersion());
     $new_file_path = C('UPDATE_PATH') . $_SESSION['nextVersion']['name'];
     $this->assign('path', $new_file_path);
     $this->disableCheckUpdate();
     $versionModel->cleanCheckUpdateCache();
     clean_cache();
     $this->display();
 }
开发者ID:terrydeng,项目名称:beimeibang1205,代码行数:18,代码来源:CloudController.class.php

示例6: scheduled_daily_maintenance

function scheduled_daily_maintenance()
{
    global $modSettings, $sourcedir, $db_type;
    // First clean out the cache.
    clean_cache();
    // If warning decrement is enabled and we have people who have not had a new warning in 24 hours, lower their warning level.
    list(, , $modSettings['warning_decrement']) = explode(',', $modSettings['warning_settings']);
    if ($modSettings['warning_decrement']) {
        // Find every member who has a warning level...
        $request = smf_db_query('
			SELECT id_member, warning
			FROM {db_prefix}members
			WHERE warning > {int:no_warning}', array('no_warning' => 0));
        $members = array();
        while ($row = mysql_fetch_assoc($request)) {
            $members[$row['id_member']] = $row['warning'];
        }
        mysql_free_result($request);
        // Have some members to check?
        if (!empty($members)) {
            // Find out when they were last warned.
            $request = smf_db_query('
				SELECT id_recipient, MAX(log_time) AS last_warning
				FROM {db_prefix}log_comments
				WHERE id_recipient IN ({array_int:member_list})
					AND comment_type = {string:warning}
				GROUP BY id_recipient', array('member_list' => array_keys($members), 'warning' => 'warning'));
            $member_changes = array();
            while ($row = mysql_fetch_assoc($request)) {
                // More than 24 hours ago?
                if ($row['last_warning'] <= time() - 86400) {
                    $member_changes[] = array('id' => $row['id_recipient'], 'warning' => $members[$row['id_recipient']] >= $modSettings['warning_decrement'] ? $members[$row['id_recipient']] - $modSettings['warning_decrement'] : 0);
                }
            }
            mysql_free_result($request);
            // Have some members to change?
            if (!empty($member_changes)) {
                foreach ($member_changes as $change) {
                    smf_db_query('
						UPDATE {db_prefix}members
						SET warning = {int:warning}
						WHERE id_member = {int:id_member}', array('warning' => $change['warning'], 'id_member' => $change['id']));
                }
            }
        }
    }
    // Do any spider stuff.
    if (!empty($modSettings['spider_mode']) && $modSettings['spider_mode'] > 1) {
        require_once $sourcedir . '/ManageSearchEngines.php';
        consolidateSpiderStats();
    }
    // Check the database version - for some buggy MySQL version.
    $server_version = mysql_get_server_info();
    if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) {
        updateSettings(array('db_mysql_group_by_fix' => '1'));
    } elseif (!empty($modSettings['db_mysql_group_by_fix'])) {
        smf_db_query('
			DELETE FROM {db_prefix}settings
			WHERE variable = {string:mysql_fix}', array('mysql_fix' => 'db_mysql_group_by_fix'));
    }
    // Regenerate the Diffie-Hellman keys if OpenID is enabled.
    if (!empty($modSettings['enableOpenID'])) {
        require_once $sourcedir . '/lib/Subs-OpenID.php';
        smf_openID_setup_DH(true);
    } elseif (!empty($modSettings['dh_keys'])) {
        smf_db_query('
			DELETE FROM {db_prefix}settings
			WHERE variable = {string:dh_keys}', array('dh_keys' => 'dh_keys'));
    }
    // clean out old cached posts
    if ($modSettings['post_cache_cutoff'] < 10) {
        $modSettings['post_cache_cutoff'] = 10;
    }
    smf_db_query('
		DELETE FROM {db_prefix}messages_cache WHERE updated < {int:cutoff}', array('cutoff' => time() - $modSettings['post_cache_cutoff'] * 86400));
    // auto-expire topicbans (expires == 0 means the ban is permanent until lifted manually, so do not expire them)
    smf_db_query('DELETE FROM {db_prefix}topicbans WHERE expires <> 0 AND expires <= UNIX_TIMESTAMP(NOW())');
    HookAPI::callHook('sys_daily_maint');
    // Log we've done it...
    return true;
}
开发者ID:norv,项目名称:EosAlpha,代码行数:81,代码来源:ScheduledTasks.php

示例7: db_debug_junk


//.........这里部分代码省略.........
    if (!isset($db_show_debug) || $db_show_debug !== true || isset($_GET['action']) && $_GET['action'] == 'viewquery' || WIRELESS) {
        return;
    }
    if (empty($_SESSION['view_queries'])) {
        $_SESSION['view_queries'] = 0;
    }
    if (empty($context['debug']['language_files'])) {
        $context['debug']['language_files'] = array();
    }
    if (empty($context['debug']['sheets'])) {
        $context['debug']['sheets'] = array();
    }
    $files = get_included_files();
    $total_size = 0;
    for ($i = 0, $n = count($files); $i < $n; $i++) {
        if (file_exists($files[$i])) {
            $total_size += filesize($files[$i]);
        }
        $files[$i] = strtr($files[$i], array($boarddir => '.'));
    }
    $warnings = 0;
    if (!empty($db_cache)) {
        foreach ($db_cache as $q => $qq) {
            if (!empty($qq['w'])) {
                $warnings += count($qq['w']);
            }
        }
        $_SESSION['debug'] =& $db_cache;
    }
    // Gotta have valid HTML ;).
    $temp = ob_get_contents();
    if (function_exists('ob_clean')) {
        ob_clean();
    } else {
        ob_end_clean();
        ob_start('ob_sessrewrite');
    }
    echo preg_replace('~</body>\\s*</html>~', '', $temp), '
<div class="smalltext" style="text-align: left; margin: 1ex;">
	', $txt['debug_templates'], count($context['debug']['templates']), ': <em>', implode('</em>, <em>', $context['debug']['templates']), '</em>.<br />
	', $txt['debug_subtemplates'], count($context['debug']['sub_templates']), ': <em>', implode('</em>, <em>', $context['debug']['sub_templates']), '</em>.<br />
	', $txt['debug_language_files'], count($context['debug']['language_files']), ': <em>', implode('</em>, <em>', $context['debug']['language_files']), '</em>.<br />
	', $txt['debug_stylesheets'], count($context['debug']['sheets']), ': <em>', implode('</em>, <em>', $context['debug']['sheets']), '</em>.<br />
	', $txt['debug_files_included'], count($files), ' - ', round($total_size / 1024), $txt['debug_kb'], ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_include_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_include_info" style="display: none;"><em>', implode('</em>, <em>', $files), '</em></span>)<br />';
    if (!empty($modSettings['cache_enable']) && !empty($cache_hits)) {
        $entries = array();
        $total_t = 0;
        $total_s = 0;
        foreach ($cache_hits as $cache_hit) {
            $entries[] = $cache_hit['d'] . ' ' . $cache_hit['k'] . ': ' . sprintf($txt['debug_cache_seconds_bytes'], comma_format($cache_hit['t'], 5), $cache_hit['s']);
            $total_t += $cache_hit['t'];
            $total_s += $cache_hit['s'];
        }
        echo '
	', $txt['debug_cache_hits'], $cache_count, ': ', sprintf($txt['debug_cache_seconds_bytes_total'], comma_format($total_t, 5), comma_format($total_s)), ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_cache_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_cache_info" style="display: none;"><em>', implode('</em>, <em>', $entries), '</em></span>)<br />';
    }
    echo '
	<a href="', $scripturl, '?action=viewquery" target="_blank" class="new_win">', $warnings == 0 ? sprintf($txt['debug_queries_used'], (int) $db_count) : sprintf($txt['debug_queries_used_and_warnings'], (int) $db_count, $warnings), '</a><br />
	<br />';
    if ($_SESSION['view_queries'] == 1 && !empty($db_cache)) {
        foreach ($db_cache as $q => $qq) {
            $is_select = substr(trim($qq['q']), 0, 6) == 'SELECT' || preg_match('~^INSERT(?: IGNORE)? INTO \\w+(?:\\s+\\([^)]+\\))?\\s+SELECT .+$~s', trim($qq['q'])) != 0;
            // Temporary tables created in earlier queries are not explainable.
            if ($is_select) {
                foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) {
                    if (strpos(trim($qq['q']), $tmp) !== false) {
                        $is_select = false;
                        break;
                    }
                }
            } elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($qq['q'])) != 0) {
                $is_select = true;
            }
            // Make the filenames look a bit better.
            if (isset($qq['f'])) {
                $qq['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $qq['f']);
            }
            echo '
	<strong>', $is_select ? '<a href="' . $scripturl . '?action=viewquery;qq=' . ($q + 1) . '#qq' . $q . '" target="_blank" class="new_win" style="text-decoration: none;">' : '', nl2br(str_replace("\t", '&nbsp;&nbsp;&nbsp;', htmlspecialchars(ltrim($qq['q'], "\n\r")))) . ($is_select ? '</a></strong>' : '</strong>') . '<br />
	&nbsp;&nbsp;&nbsp;';
            if (!empty($qq['f']) && !empty($qq['l'])) {
                echo sprintf($txt['debug_query_in_line'], $qq['f'], $qq['l']);
            }
            if (isset($qq['s'], $qq['t']) && isset($txt['debug_query_which_took_at'])) {
                echo sprintf($txt['debug_query_which_took_at'], round($qq['t'], 8), round($qq['s'], 8)) . '<br />';
            } elseif (isset($qq['t'])) {
                echo sprintf($txt['debug_query_which_took'], round($qq['t'], 8)) . '<br />';
            }
            echo '
	<br />';
        }
    }
    echo '
	<a href="' . $scripturl . '?action=viewquery;sa=hide">', $txt['debug_' . (empty($_SESSION['view_queries']) ? 'show' : 'hide') . '_queries'], '</a>
</div></body></html>';
    // Empty the language cache,
    if (isset($_REQUEST['clearcache'])) {
        clean_cache('lang');
    }
}
开发者ID:Kheros,项目名称:MMOver,代码行数:101,代码来源:Subs.php

示例8: RemoveTheme

function RemoveTheme()
{
    global $modSettings, $context, $smcFunc;
    checkSession('get');
    isAllowedTo('admin_forum');
    // The theme's ID must be an integer.
    $_GET['th'] = isset($_GET['th']) ? (int) $_GET['th'] : (int) $_GET['id'];
    // You can't delete the default theme!
    if ($_GET['th'] == 1) {
        fatal_lang_error('no_access', false);
    }
    $known = explode(',', $modSettings['knownThemes']);
    for ($i = 0, $n = count($known); $i < $n; $i++) {
        if ($known[$i] == $_GET['th']) {
            unset($known[$i]);
        }
    }
    $smcFunc['db_query']('', '
		DELETE FROM {db_prefix}themes
		WHERE id_theme = {int:current_theme}', array('current_theme' => $_GET['th']));
    $smcFunc['db_query']('', '
		UPDATE {db_prefix}members
		SET id_theme = {int:default_theme}
		WHERE id_theme = {int:current_theme}', array('default_theme' => 0, 'current_theme' => $_GET['th']));
    $smcFunc['db_query']('', '
		UPDATE {db_prefix}boards
		SET id_theme = {int:default_theme}
		WHERE id_theme = {int:current_theme}', array('default_theme' => 0, 'current_theme' => $_GET['th']));
    $known = strtr(implode(',', $known), array(',,' => ','));
    // Fix it if the theme was the overall default theme.
    if ($modSettings['theme_guests'] == $_GET['th']) {
        updateSettings(array('theme_guests' => '1', 'knownThemes' => $known));
    } else {
        updateSettings(array('knownThemes' => $known));
    }
    // Remove any cached language files to keep space minimum!
    clean_cache('lang');
    redirectexit('action=admin;area=theme;sa=list;' . $context['session_var'] . '=' . $context['session_id']);
}
开发者ID:Kheros,项目名称:MMOver,代码行数:39,代码来源:Themes.php

示例9: PackageInstall


//.........这里部分代码省略.........
                require $boarddir . '/Packages/temp/' . $context['base_path'] . $action['filename'];
            } elseif ($action['type'] == 'redirect' && !empty($action['redirect_url'])) {
                $context['redirect_url'] = $action['redirect_url'];
                $context['redirect_text'] = !empty($action['filename']) && file_exists($boarddir . '/Packages/temp/' . $context['base_path'] . $action['filename']) ? file_get_contents($boarddir . '/Packages/temp/' . $context['base_path'] . $action['filename']) : ($context['uninstalling'] ? $txt['package_uninstall_done'] : $txt['package_installed_done']);
                $context['redirect_timeout'] = $action['redirect_timeout'];
                // Parse out a couple of common urls.
                $urls = array('$boardurl' => $boardurl, '$scripturl' => $scripturl, '$session_var' => $context['session_var'], '$session_id' => $context['session_id']);
                $context['redirect_url'] = strtr($context['redirect_url'], $urls);
            }
        }
        package_flush_cache();
        // First, ensure this change doesn't get removed by putting a stake in the ground (So to speak).
        package_put_contents($boarddir . '/Packages/installed.list', time());
        // See if this is already installed, and change it's state as required.
        $request = smf_db_query('
			SELECT package_id, install_state, db_changes
			FROM {db_prefix}log_packages
			WHERE install_state != {int:not_installed}
				AND package_id = {string:current_package}
				' . ($context['install_id'] ? ' AND id_install = {int:install_id} ' : '') . '
			ORDER BY time_installed DESC
			LIMIT 1', array('not_installed' => 0, 'install_id' => $context['install_id'], 'current_package' => $packageInfo['id']));
        $is_upgrade = false;
        while ($row = mysql_fetch_assoc($request)) {
            // Uninstalling?
            if ($context['uninstalling']) {
                smf_db_query('
					UPDATE {db_prefix}log_packages
					SET install_state = {int:not_installed}, member_removed = {string:member_name}, id_member_removed = {int:current_member},
						time_removed = {int:current_time}
					WHERE package_id = {string:package_id}', array('current_member' => $user_info['id'], 'not_installed' => 0, 'current_time' => time(), 'package_id' => $row['package_id'], 'member_name' => $user_info['name']));
            } else {
                $is_upgrade = true;
                $old_db_changes = empty($row['db_changes']) ? array() : unserialize($row['db_changes']);
            }
        }
        // Assuming we're not uninstalling, add the entry.
        if (!$context['uninstalling']) {
            // Any db changes from older version?
            if (!empty($old_db_changes)) {
                $db_package_log = empty($db_package_log) ? $old_db_changes : array_merge($old_db_changes, $db_package_log);
            }
            // If there are some database changes we might want to remove then filter them out.
            if (!empty($db_package_log)) {
                // We're really just checking for entries which are create table AND add columns (etc).
                $tables = array();
                function sort_table_first($a, $b)
                {
                    if ($a[0] == $b[0]) {
                        return 0;
                    }
                    return $a[0] == 'remove_table' ? -1 : 1;
                }
                usort($db_package_log, 'sort_table_first');
                foreach ($db_package_log as $k => $log) {
                    if ($log[0] == 'remove_table') {
                        $tables[] = $log[1];
                    } elseif (in_array($log[1], $tables)) {
                        unset($db_package_log[$k]);
                    }
                }
                $db_changes = serialize($db_package_log);
            } else {
                $db_changes = '';
            }
            // What themes did we actually install?
            $themes_installed = array_unique($themes_installed);
            $themes_installed = implode(',', $themes_installed);
            // What failed steps?
            $failed_step_insert = serialize($failed_steps);
            smf_db_insert('', '{db_prefix}log_packages', array('filename' => 'string', 'name' => 'string', 'package_id' => 'string', 'version' => 'string', 'id_member_installed' => 'int', 'member_installed' => 'string', 'time_installed' => 'int', 'install_state' => 'int', 'failed_steps' => 'string', 'themes_installed' => 'string', 'member_removed' => 'int', 'db_changes' => 'string'), array($packageInfo['filename'], $packageInfo['name'], $packageInfo['id'], $packageInfo['version'], $user_info['id'], $user_info['name'], time(), $is_upgrade ? 2 : 1, $failed_step_insert, $themes_installed, 0, $db_changes), array('id_install'));
        }
        mysql_free_result($request);
        $context['install_finished'] = true;
    }
    // If there's database changes - and they want them removed - let's do it last!
    if (!empty($db_changes) && !empty($_POST['do_db_changes'])) {
        // We're gonna be needing the package db functions!
        db_extend('packages');
        foreach ($db_changes as $change) {
            if ($change[0] == 'remove_table' && isset($change[1])) {
                smf_db_drop_table($change[1]);
            } elseif ($change[0] == 'remove_column' && isset($change[2])) {
                smf_db_remove_column($change[1], $change[2]);
            } elseif ($change[0] == 'remove_index' && isset($change[2])) {
                smf_db_remove_index($change[1], $change[2]);
            }
        }
    }
    // Clean house... get rid of the evidence ;).
    if (file_exists($boarddir . '/Packages/temp')) {
        deltree($boarddir . '/Packages/temp');
    }
    // Log what we just did.
    logAction($context['uninstalling'] ? 'uninstall_package' : (!empty($is_upgrade) ? 'upgrade_package' : 'install_package'), array('package' => commonAPI::htmlspecialchars($packageInfo['name']), 'version' => commonAPI::htmlspecialchars($packageInfo['version'])), 'admin');
    // Just in case, let's clear the whole cache to avoid anything going up the swanny.
    clean_cache();
    // Restore file permissions?
    create_chmod_control(array(), array(), true);
}
开发者ID:norv,项目名称:EosAlpha,代码行数:101,代码来源:Packages.php

示例10: ShopUserGroup

function ShopUserGroup()
{
    global $smcFunc, $boarddir, $context, $txt;
    // If form wasn't submitted yet...
    if (!isset($_GET['step']) || $_GET['step'] == 1) {
        // Start with an empty list
        $context['shop_usergroups'] = array();
        // Get all non post-based membergroups
        $result = $smcFunc['db_query']('', "\n\t\t\tSELECT id_group, group_name\n\t\t\tFROM {db_prefix}membergroups\n\t\t\tWHERE min_posts = -1", array());
        // For each membergroup, add it to the list
        while ($row = $smcFunc['db_fetch_assoc']($result)) {
            $context['shop_usergroups'][] = array('id' => $row['id_group'], 'groupName' => $row['group_name']);
        }
        $smcFunc['db_free_result']($result);
    } else {
        // Adding, or subtracting?
        $action = $_POST['m_action'] == 'sub' ? '-' : '+';
        // Make sure inputs were numeric
        $_POST['usergroup'] = (int) $_POST['usergroup'];
        $_POST['value'] = (double) $_POST['value'];
        // Do it!
        $smcFunc['db_query']('', "\n\t\t\tUPDATE {db_prefix}members\n\t\t\tSET money = money {raw:action} {int:value}\n\t\t\tWHERE id_group = {int:group}", array('action' => $action, 'value' => $_POST['value'], 'group' => $_POST['usergroup']));
        clean_cache();
    }
    // We're using the "usergroup" template
    $context['sub_template'] = 'usergroup';
    $context['page_title'] = $txt['shop'] . ' - ' . $txt['shop_admin_usergroup'];
    // Load the actual template
    loadTemplate('ShopAdmin');
}
开发者ID:VBGAMER45,项目名称:SMFMods,代码行数:30,代码来源:ShopAdmin.php

示例11: daily_maintenance

    /**
     * This function does daily cleaning up:
     *
     * - decrements warning levels if it's enabled
     * - consolidate spider statistics
     * - fix MySQL version
     * - regenerate Diffie-Hellman keys for OpenID
     * - remove obsolete login history logs
     */
    public function daily_maintenance()
    {
        global $modSettings, $db_type;
        $db = database();
        // First clean out the cache.
        clean_cache('data');
        // If warning decrement is enabled and we have people who have not had a new warning in 24 hours, lower their warning level.
        list(, , $modSettings['warning_decrement']) = explode(',', $modSettings['warning_settings']);
        if ($modSettings['warning_decrement']) {
            // Find every member who has a warning level...
            $request = $db->query('', '
				SELECT id_member, warning
				FROM {db_prefix}members
				WHERE warning > {int:no_warning}', array('no_warning' => 0));
            $members = array();
            while ($row = $db->fetch_assoc($request)) {
                $members[$row['id_member']] = $row['warning'];
            }
            $db->free_result($request);
            // Have some members to check?
            if (!empty($members)) {
                // Find out when they were last warned.
                $request = $db->query('', '
					SELECT id_recipient, MAX(log_time) AS last_warning
					FROM {db_prefix}log_comments
					WHERE id_recipient IN ({array_int:member_list})
						AND comment_type = {string:warning}
					GROUP BY id_recipient', array('member_list' => array_keys($members), 'warning' => 'warning'));
                $member_changes = array();
                while ($row = $db->fetch_assoc($request)) {
                    // More than 24 hours ago?
                    if ($row['last_warning'] <= time() - 86400) {
                        $member_changes[] = array('id' => $row['id_recipient'], 'warning' => $members[$row['id_recipient']] >= $modSettings['warning_decrement'] ? $members[$row['id_recipient']] - $modSettings['warning_decrement'] : 0);
                    }
                }
                $db->free_result($request);
                // Have some members to change?
                if (!empty($member_changes)) {
                    foreach ($member_changes as $change) {
                        updateMemberData($change['id'], array('warning' => $change['warning']));
                    }
                }
            }
        }
        // Do any spider stuff.
        if (!empty($modSettings['spider_mode']) && $modSettings['spider_mode'] > 1) {
            // We'll need this.
            require_once SUBSDIR . '/SearchEngines.subs.php';
            consolidateSpiderStats();
        }
        // Check the database version - for some buggy MySQL version.
        $server_version = $db->db_server_info();
        if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) {
            updateSettings(array('db_mysql_group_by_fix' => '1'));
        } elseif (!empty($modSettings['db_mysql_group_by_fix'])) {
            $db->query('', '
				DELETE FROM {db_prefix}settings
				WHERE variable = {string:mysql_fix}', array('mysql_fix' => 'db_mysql_group_by_fix'));
        }
        // Regenerate the Diffie-Hellman keys if OpenID is enabled.
        if (!empty($modSettings['enableOpenID'])) {
            require_once SUBSDIR . '/OpenID.subs.php';
            $openID = new OpenID();
            $openID->setup_DH(true);
        } elseif (!empty($modSettings['dh_keys'])) {
            $db->query('', '
				DELETE FROM {db_prefix}settings
				WHERE variable = {string:dh_keys}', array('dh_keys' => 'dh_keys'));
        }
        // Clean up some old login history information.
        $db->query('', '
			DELETE FROM {db_prefix}member_logins
			WHERE time > {int:oldLogins}', array('oldLogins' => !empty($modSettings['loginHistoryDays']) ? 60 * 60 * $modSettings['loginHistoryDays'] : 108000));
        // Log we've done it...
        return true;
    }
开发者ID:Ralkage,项目名称:Elkarte,代码行数:85,代码来源:ScheduledTask.class.php

示例12: CheckQuotaSQL_cache

function CheckQuotaSQL_cache($MDKEY)
{
    clean_cache();
    $CacheTime = round($GLOBALS["PARAMS"]["CACHE_TIME"] / 60);
    if ($CacheTime == 0) {
        $CacheTime = 6;
        $GLOBALS["PARAMS"]["CACHE_TIME"] = $CacheTime * 60;
    }
    if (!isset($GLOBALS["SQLCACHE"][$MDKEY])) {
        return 0;
    }
    $data1 = $GLOBALS["SQLCACHE"][$MDKEY]["TIME"];
    $data2 = time();
    $difference = $data2 - $data1;
    $mins = round($difference / 60);
    if ($GLOBALS["DEBUG_LEVEL"] > 1) {
        WLOG("CheckQuotaSQL_cache() -> {$mins}Mn/{$CacheTime}Mn return {$GLOBALS["SQLCACHE"][$MDKEY]["VALUE"]}MB");
    }
    if ($mins < $CacheTime) {
        return $GLOBALS["SQLCACHE"][$MDKEY]["VALUE"];
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:22,代码来源:external_acl_quota.php

示例13: ModifyLanguage


//.........这里部分代码省略.........
        }
        // Last entry to add?
        if ($multiline_cache) {
            preg_match('~\\$(helptxt|txt)\\[\'(.+)\'\\]\\s=\\s(.+);~', strtr($multiline_cache, array("\n" => '', "\t" => '')), $matches);
            if (!empty($matches[3])) {
                $entries[$matches[2]] = array('type' => $matches[1], 'full' => $matches[0], 'entry' => $matches[3]);
            }
        }
        // These are the entries we can definitely save.
        $final_saves = array();
        $context['file_entries'] = array();
        foreach ($entries as $entryKey => $entryValue) {
            // Ignore some things we set separately.
            $ignore_files = array('lang_character_set', 'lang_locale', 'lang_dictionary', 'lang_spelling', 'lang_rtl');
            if (in_array($entryKey, $ignore_files)) {
                continue;
            }
            // These are arrays that need breaking out.
            $arrays = array('days', 'days_short', 'months', 'months_titles', 'months_short');
            if (in_array($entryKey, $arrays)) {
                // Get off the first bits.
                $entryValue['entry'] = substr($entryValue['entry'], strpos($entryValue['entry'], '(') + 1, strrpos($entryValue['entry'], ')') - strpos($entryValue['entry'], '('));
                $entryValue['entry'] = explode(',', strtr($entryValue['entry'], array(' ' => '')));
                // Now create an entry for each item.
                $cur_index = 0;
                $save_cache = array('enabled' => false, 'entries' => array());
                foreach ($entryValue['entry'] as $id => $subValue) {
                    // Is this a new index?
                    if (preg_match('~^(\\d+)~', $subValue, $matches)) {
                        $cur_index = $matches[1];
                        $subValue = substr($subValue, strpos($subValue, '\''));
                    }
                    // Clean up some bits.
                    $subValue = strtr($subValue, array('"' => '', '\'' => '', ')' => ''));
                    // Can we save?
                    if (isset($save_strings[$entryKey . '-+- ' . $cur_index])) {
                        $save_cache['entries'][$cur_index] = strtr($save_strings[$entryKey . '-+- ' . $cur_index], array('\'' => ''));
                        $save_cache['enabled'] = true;
                    } else {
                        $save_cache['entries'][$cur_index] = $subValue;
                    }
                    $context['file_entries'][] = array('key' => $entryKey . '-+- ' . $cur_index, 'value' => $subValue, 'rows' => 1);
                    $cur_index++;
                }
                // Do we need to save?
                if ($save_cache['enabled']) {
                    // Format the string, checking the indexes first.
                    $items = array();
                    $cur_index = 0;
                    foreach ($save_cache['entries'] as $k2 => $v2) {
                        // Manually show the custom index.
                        if ($k2 != $cur_index) {
                            $items[] = $k2 . ' => \'' . $v2 . '\'';
                            $cur_index = $k2;
                        } else {
                            $items[] = '\'' . $v2 . '\'';
                        }
                        $cur_index++;
                    }
                    // Now create the string!
                    $final_saves[$entryKey] = array('find' => $entryValue['full'], 'replace' => '$' . $entryValue['type'] . '[\'' . $entryKey . '\'] = array(' . implode(', ', $items) . ');');
                }
            } else {
                // Saving?
                if (isset($save_strings[$entryKey]) && $save_strings[$entryKey] != $entryValue['entry']) {
                    // !!! Fix this properly.
                    if ($save_strings[$entryKey] == '') {
                        $save_strings[$entryKey] = '\'\'';
                    }
                    // Set the new value.
                    $entryValue['entry'] = $save_strings[$entryKey];
                    // And we know what to save now!
                    $final_saves[$entryKey] = array('find' => $entryValue['full'], 'replace' => '$' . $entryValue['type'] . '[\'' . $entryKey . '\'] = ' . $save_strings[$entryKey] . ';');
                }
                $editing_string = cleanLangString($entryValue['entry'], true);
                $context['file_entries'][] = array('key' => $entryKey, 'value' => $editing_string, 'rows' => (int) (strlen($editing_string) / 38) + substr_count($editing_string, "\n") + 1);
            }
        }
        // Any saves to make?
        if (!empty($final_saves)) {
            checkSession();
            $file_contents = implode('', file($current_file));
            foreach ($final_saves as $save) {
                $file_contents = strtr($file_contents, array($save['find'] => $save['replace']));
            }
            // Save the actual changes.
            $fp = fopen($current_file, 'w+');
            fwrite($fp, $file_contents);
            fclose($fp);
            $madeSave = true;
        }
        // Another restore.
        $txt = $old_txt;
    }
    // If we saved, redirect.
    if ($madeSave) {
        clean_cache('lang');
        redirectexit('action=admin;area=languages;sa=editlang;lid=' . $context['lang_id']);
    }
}
开发者ID:Kheros,项目名称:MMOver,代码行数:101,代码来源:ManageServer.php

示例14: shd_maint_clean_cache

function shd_maint_clean_cache()
{
    global $context;
    clean_cache();
    // Normally, we'd update $context['continue_post_data'] to indicate our next port of call. But here, we don't have to.
    redirectexit('action=admin;area=helpdesk_maint;sa=findrepair;done;' . $context['session_var'] . '=' . $context['session_id']);
}
开发者ID:wintstar,项目名称:Testing,代码行数:7,代码来源:SimpleDesk-AdminMaint.php

示例15: action_hooks

    /**
     * Generates a list of integration hooks for display
     *
     * - Accessed through ?action=admin;area=maintain;sa=hooks;
     * - Allows for removal or disabing of selected hooks
     */
    public function action_hooks()
    {
        global $scripturl, $context, $txt, $modSettings, $settings;
        require_once SUBSDIR . '/AddonSettings.subs.php';
        $context['filter_url'] = '';
        $context['current_filter'] = '';
        // Get the list of the current system hooks, filter them if needed
        $currentHooks = get_integration_hooks();
        if (isset($_GET['filter']) && in_array($_GET['filter'], array_keys($currentHooks))) {
            $context['filter_url'] = ';filter=' . $_GET['filter'];
            $context['current_filter'] = $_GET['filter'];
        }
        if (!empty($modSettings['handlinghooks_enabled'])) {
            if (!empty($_REQUEST['do']) && isset($_REQUEST['hook']) && isset($_REQUEST['function'])) {
                checkSession('request');
                validateToken('admin-hook', 'request');
                if ($_REQUEST['do'] == 'remove') {
                    remove_integration_function($_REQUEST['hook'], urldecode($_REQUEST['function']));
                } else {
                    if ($_REQUEST['do'] == 'disable') {
                        // It's a hack I know...but I'm way too lazy!!!
                        $function_remove = $_REQUEST['function'];
                        $function_add = $_REQUEST['function'] . ']';
                    } else {
                        $function_remove = $_REQUEST['function'] . ']';
                        $function_add = $_REQUEST['function'];
                    }
                    $file = !empty($_REQUEST['includedfile']) ? urldecode($_REQUEST['includedfile']) : '';
                    remove_integration_function($_REQUEST['hook'], $function_remove, $file);
                    add_integration_function($_REQUEST['hook'], $function_add, $file);
                    // Clean the cache.
                    require_once SUBSDIR . '/Cache.subs.php';
                    clean_cache();
                }
                redirectexit('action=admin;area=maintain;sa=hooks' . $context['filter_url']);
            }
        }
        $list_options = array('id' => 'list_integration_hooks', 'title' => $txt['maintain_sub_hooks_list'], 'items_per_page' => 20, 'base_href' => $scripturl . '?action=admin;area=maintain;sa=hooks' . $context['filter_url'] . ';' . $context['session_var'] . '=' . $context['session_id'], 'default_sort_col' => 'hook_name', 'get_items' => array('function' => array($this, 'list_getIntegrationHooks')), 'get_count' => array('function' => array($this, 'list_getIntegrationHooksCount')), 'no_items_label' => $txt['hooks_no_hooks'], 'columns' => array('hook_name' => array('header' => array('value' => $txt['hooks_field_hook_name']), 'data' => array('db' => 'hook_name'), 'sort' => array('default' => 'hook_name', 'reverse' => 'hook_name DESC')), 'function_name' => array('header' => array('value' => $txt['hooks_field_function_name']), 'data' => array('function' => create_function('$data', '
							global $txt;

							if (!empty($data[\'included_file\']))
								return $txt[\'hooks_field_function\'] . \': \' . $data[\'real_function\'] . \'<br />\' . $txt[\'hooks_field_included_file\'] . \': \' . $data[\'included_file\'];
							else
								return $data[\'real_function\'];
						')), 'sort' => array('default' => 'function_name', 'reverse' => 'function_name DESC')), 'file_name' => array('header' => array('value' => $txt['hooks_field_file_name']), 'data' => array('db' => 'file_name'), 'sort' => array('default' => 'file_name', 'reverse' => 'file_name DESC')), 'status' => array('header' => array('value' => $txt['hooks_field_hook_exists'], 'class' => 'nowrap'), 'data' => array('function' => create_function('$data', '
							global $txt, $settings, $scripturl, $context;

							$change_status = array(\'before\' => \'\', \'after\' => \'\');
							if ($data[\'can_be_disabled\'] && $data[\'status\'] != \'deny\')
							{
								$change_status[\'before\'] = \'<a href="\' . $scripturl . \'?action=admin;area=maintain;sa=hooks;do=\' . ($data[\'enabled\'] ? \'disable\' : \'enable\') . \';hook=\' . $data[\'hook_name\'] . \';function=\' . $data[\'real_function\'] . (!empty($data[\'included_file\']) ? \';includedfile=\' . urlencode($data[\'included_file\']) : \'\') . $context[\'filter_url\'] . \';\' . $context[\'admin-hook_token_var\'] . \'=\' . $context[\'admin-hook_token\'] . \';\' . $context[\'session_var\'] . \'=\' . $context[\'session_id\'] . \'" onclick="return confirm(\' . javaScriptEscape($txt[\'quickmod_confirm\']) . \');">\';
								$change_status[\'after\'] = \'</a>\';
							}
							return $change_status[\'before\'] . \'<img src="\' . $settings[\'images_url\'] . \'/admin/post_moderation_\' . $data[\'status\'] . \'.png" alt="\' . $data[\'img_text\'] . \'" title="\' . $data[\'img_text\'] . \'" />\' . $change_status[\'after\'];
						'), 'class' => 'centertext'), 'sort' => array('default' => 'status', 'reverse' => 'status DESC'))), 'additional_rows' => array(array('position' => 'after_title', 'value' => $txt['hooks_disable_instructions'] . '<br />
						' . $txt['hooks_disable_legend'] . ':
					<ul>
						<li>
							<img src="' . $settings['images_url'] . '/admin/post_moderation_allow.png" alt="' . $txt['hooks_active'] . '" title="' . $txt['hooks_active'] . '" /> ' . $txt['hooks_disable_legend_exists'] . '
						</li>
						<li>
							<img src="' . $settings['images_url'] . '/admin/post_moderation_moderate.png" alt="' . $txt['hooks_disabled'] . '" title="' . $txt['hooks_disabled'] . '" /> ' . $txt['hooks_disable_legend_disabled'] . '
						</li>
						<li>
							<img src="' . $settings['images_url'] . '/admin/post_moderation_deny.png" alt="' . $txt['hooks_missing'] . '" title="' . $txt['hooks_missing'] . '" /> ' . $txt['hooks_disable_legend_missing'] . '
						</li>
					</ul>')));
        if (!empty($modSettings['handlinghooks_enabled'])) {
            createToken('admin-hook', 'request');
            $list_options['columns']['remove'] = array('header' => array('value' => $txt['hooks_button_remove'], 'style' => 'width:3%'), 'data' => array('function' => create_function('$data', '
						global $txt, $settings, $scripturl, $context;

						if (!$data[\'hook_exists\'])
							return \'
							<a href="\' . $scripturl . \'?action=admin;area=maintain;sa=hooks;do=remove;hook=\' . $data[\'hook_name\'] . \';function=\' . urlencode($data[\'function_name\']) . $context[\'filter_url\'] . \';\' . $context[\'admin-hook_token_var\'] . \'=\' . $context[\'admin-hook_token\'] . \';\' . $context[\'session_var\'] . \'=\' . $context[\'session_id\'] . \'" onclick="return confirm(\' . javaScriptEscape($txt[\'quickmod_confirm\']) . \');">
								<img src="\' . $settings[\'images_url\'] . \'/icons/quick_remove.png" alt="\' . $txt[\'hooks_button_remove\'] . \'" title="\' . $txt[\'hooks_button_remove\'] . \'" />
							</a>\';
					'), 'class' => 'centertext'));
            $list_options['form'] = array('href' => $scripturl . '?action=admin;area=maintain;sa=hooks' . $context['filter_url'] . ';' . $context['session_var'] . '=' . $context['session_id'], 'name' => 'list_integration_hooks');
        }
        require_once SUBSDIR . '/GenericList.class.php';
        createList($list_options);
        $context['page_title'] = $txt['maintain_sub_hooks_list'];
        $context['sub_template'] = 'show_list';
        $context['default_list'] = 'list_integration_hooks';
    }
开发者ID:KeiroD,项目名称:Elkarte,代码行数:92,代码来源:Maintenance.controller.php


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