Пример #1
0
function cache_pun_coloured_usergroups()
{
    global $forum_db;
    $query = array('SELECT' => 'g.g_id, g.link_color, g.hover_color', 'FROM' => 'groups AS g');
    $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
    $output = array();
    while ($all_groups = $forum_db->fetch_assoc($result)) {
        if (isset($all_groups['link_color'])) {
            $link_color = ' color: ' . $all_groups['link_color'] . ';';
            $output[] = '.group_color_' . $all_groups['g_id'] . ' a:link, .group_color_' . $all_groups['g_id'] . ' { color: ' . $all_groups['link_color'] . ' !important; }' . "\n";
            $output[] = '.group_color_' . $all_groups['g_id'] . ' a:visited { color: ' . $all_groups['link_color'] . '; }' . "\n";
        } else {
            $link_color = '';
        }
        if (isset($all_groups['hover_color'])) {
            $output[] = '.group_color_' . $all_groups['g_id'] . ' a:hover { color: ' . $all_groups['hover_color'] . '; }' . "\n";
            $output[] = '.group_color_' . $all_groups['g_id'] . ' { color: ' . $all_groups['hover_color'] . '; }' . "\n\n";
        }
    }
    // WRITE CACHE
    if (!empty($output)) {
        if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) {
            require FORUM_ROOT . 'include/cache.php';
        }
        if (!write_cache_file(FORUM_CACHE_DIR . 'cache_pun_coloured_usergroups.php', '<?php' . "\n\n" . '$pun_colored_usergroups_cache = \'' . implode(" ", $output) . "';\n" . '?>')) {
            error('Unable to write configuration cache file to cache directory. Please make sure PHP has write access to the directory \'cache\'.', __FILE__, __LINE__);
        }
    }
}
Пример #2
0
 public function cache()
 {
     if (FALSE === ($groups = $this->move_users->get_groups())) {
         message(App::$lang_common['Bad request']);
     }
     if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) {
         require FORUM_ROOT . 'include/cache.php';
     }
     // Output ranks list as PHP code
     if (!write_cache_file(FORUM_CACHE_DIR . 'cache_move_users.php', '<?php' . "\n\n" . 'define(\'FORUM_MOVE_USERS_LOADED\', 1);' . "\n\n" . '$forum_move_users = ' . var_export($groups, true) . ';' . "\n\n" . '?>')) {
         error('Unable to write ranks cache file to cache directory.<br />Please make sure PHP has write access to the directory \'cache\'.', __FILE__, __LINE__);
     }
 }
Пример #3
0
function om_warnings_generate_types_cache()
{
    global $forum_db;
    // Get list of all warning types defined by administrator
    $query = array('SELECT' => 'id, warn_name, warn_desc, points, expire, restriction', 'FROM' => 'om_warnings_types');
    ($hook = get_hook('om_warnings_fn_types_cache_qr_get_types')) ? eval($hook) : null;
    $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
    $types = array();
    while ($cur_type = $forum_db->fetch_assoc($result)) {
        $types[$cur_type['id']] = $cur_type;
    }
    // Output config as PHP code
    if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) {
        require FORUM_ROOT . 'include/cache.php';
    }
    if (!write_cache_file(FORUM_CACHE_DIR . 'cache_om_warnings_types.php', '<?php' . "\n\n" . '$om_warnings_types = ' . var_export($types, true) . ';' . "\n\n" . '?>')) {
        error('Unable to write configuration cache file to cache directory.<br />Please make sure PHP has write access to the directory \'cache\'.', __FILE__, __LINE__);
    }
}
Пример #4
0
function om_move_posts_generate_cache($om_move_posts_max = null)
{
    global $forum_db;
    $return = ($hook = get_hook('om_move_posts_fn_generate_cache_start')) ? eval($hook) : null;
    if ($return != null) {
        return;
    }
    if ($om_move_posts_max == null) {
        // get max value om_move_posts of posts in system o.O
        $query = array('SELECT' => 'MAX(om_move_posts)', 'FROM' => 'posts');
        ($hook = get_hook('om_move_posts_fn_generate_cache_qr_get_max_move_posts')) ? eval($hook) : null;
        $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
        $om_move_posts_max = $forum_db->result($result);
    }
    // Output config as PHP code
    if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) {
        require FORUM_ROOT . 'include/cache.php';
    }
    if (!write_cache_file(FORUM_CACHE_DIR . 'cache_om_move_posts.php', '<?php' . "\n\n" . 'define(\'OM_MOVE_POSTS_CACHE_LOADED\', 1);' . "\n\n" . '$om_move_posts_max = ' . $om_move_posts_max . ';' . "\n\n" . '?>')) {
        error('Unable to write configuration cache file to cache directory.<br />Please make sure PHP has write access to the directory \'cache\'.', __FILE__, __LINE__);
    }
}
Пример #5
0
function pun_stop_bots_generate_cache()
{
    global $forum_db;
    // Get the forum config from the DB
    $query = array('SELECT' => 'id, question, answers', 'FROM' => 'pun_stop_bots_questions');
    $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
    $output = $questions = array();
    while ($row = $forum_db->fetch_assoc($result)) {
        $questions[] = $row;
    }
    if (!empty($questions)) {
        foreach ($questions as $cur_item) {
            $output['questions'][$cur_item['id']] = array('question' => $cur_item['question'], 'answers' => $cur_item['answers']);
        }
    }
    $output['cached'] = time();
    if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) {
        require FORUM_ROOT . 'include/cache.php';
    }
    if (!write_cache_file(FORUM_CACHE_DIR . 'cache_pun_stop_bots.php', '<?php' . "\n\n" . 'define(\'PUN_STOP_BOTS_CACHE_LOADED\', 1);' . "\n\n" . '$pun_stop_bots_questions = ' . var_export($output, true) . ';' . "\n\n" . '?>')) {
        error('Unable to write cache_pun_stop_bots cache file to cache directory.<br/>Please make sure PHP has write access to the directory \'cache\'.', __FILE__, __LINE__);
    }
}
Пример #6
0
function om_medals_generate_medals_cache()
{
    global $forum_db;
    ($hook = get_hook('om_medals_fn_generate_medals_cache_start')) ? eval($hook) : null;
    $return = ($hook = get_hook('om_medals_fn_generate_medals_cache_start')) ? eval($hook) : null;
    if ($return != null) {
        return;
    }
    // Get the forum config from the DB
    $query = array('SELECT' => 'm.id AS mid, m.medal_name, m.medal_desc, m.disp_position, m.medal_type, m.medal_width, m.medal_height', 'FROM' => 'om_medals AS m', 'ORDER BY' => 'm.disp_position');
    ($hook = get_hook('om_medals_fn_generate_medals_cache_qr_get_medals')) ? eval($hook) : null;
    $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
    $output = array();
    while ($cur_medal_item = $forum_db->fetch_assoc($result)) {
        $extension = om_medals_get_image_extension($cur_medal_item['medal_type']);
        $path = $extension != null ? '/img/' . $cur_medal_item['mid'] . $extension : null;
        $medal_info = array('id' => $cur_medal_item['mid'], 'name' => $cur_medal_item['medal_name'], 'desc' => $cur_medal_item['medal_desc'], 'path' => $path, 'width' => $cur_medal_item['medal_width'], 'height' => $cur_medal_item['medal_height'], 'position' => $cur_medal_item['disp_position']);
        ($hook = get_hook('om_medals_fn_generate_medals_cache_pre_medal_info')) ? eval($hook) : null;
        $output[$cur_medal_item['mid']] = $medal_info;
    }
    // Output config as PHP code
    if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) {
        require FORUM_ROOT . 'include/cache.php';
    }
    if (!write_cache_file(FORUM_CACHE_DIR . 'cache_om_medals.php', '<?php' . "\n\n" . 'define(\'FORUM_OM_MEDALS_LOADED\', 1);' . "\n\n" . '$forum_om_medals = ' . var_export($output, true) . ';' . "\n\n" . '?>')) {
        error('Unable to write configuration cache file to cache directory.<br />Please make sure PHP has write access to the directory \'cache\'.', __FILE__, __LINE__);
    }
}
Пример #7
0
function generate_ext_versions_cache($inst_exts, $repository_urls, $repository_url_by_extension)
{
    $forum_ext_last_versions = array();
    $forum_ext_repos = array();
    foreach (array_unique(array_merge($repository_urls, $repository_url_by_extension)) as $url) {
        // Get repository timestamp
        $remote_file = get_remote_file($url . '/timestamp', 2);
        $repository_timestamp = empty($remote_file['content']) ? '' : forum_trim($remote_file['content']);
        unset($remote_file);
        if (!is_numeric($repository_timestamp)) {
            continue;
        }
        if (!isset($forum_ext_repos[$url]['timestamp'])) {
            $forum_ext_repos[$url]['timestamp'] = $repository_timestamp;
        }
        if ($forum_ext_repos[$url]['timestamp'] <= $repository_timestamp) {
            foreach ($inst_exts as $ext) {
                if (0 === strpos($ext['id'], 'pun_') and FORUM_PUN_EXTENSION_REPOSITORY_URL != $url or (FALSE === strpos($ext['id'], 'pun_') and !isset($ext['repo_url']) or isset($ext['repo_url']) and $ext['repo_url'] != $url)) {
                    continue;
                }
                $remote_file = get_remote_file($url . '/' . $ext['id'] . '/lastversion', 2);
                $version = empty($remote_file['content']) ? '' : forum_trim($remote_file['content']);
                unset($remote_file);
                if (empty($version) || !preg_match('~^[0-9a-zA-Z\\. +-]+$~u', $version)) {
                    continue;
                }
                $forum_ext_repos[$url]['extension_versions'][$ext['id']] = $version;
                // If key with current extension exist in array, compare it with version in repository
                if (!isset($forum_ext_last_versions[$ext['id']]) || version_compare($forum_ext_last_versions[$ext['id']]['version'], $version, '<')) {
                    $forum_ext_last_versions[$ext['id']] = array('version' => $version, 'repo_url' => $url);
                    $remote_file = get_remote_file($url . '/' . $ext['id'] . '/lastchanges', 2);
                    $last_changes = empty($remote_file['content']) ? '' : forum_trim($remote_file['content']);
                    unset($remote_file);
                    if (!empty($last_changes)) {
                        $forum_ext_last_versions[$ext['id']]['changes'] = $last_changes;
                    }
                }
            }
            // Write timestamp to cache
            $forum_ext_repos[$url]['timestamp'] = $repository_timestamp;
        }
    }
    if (array_keys($forum_ext_last_versions) != array_keys($inst_exts)) {
        foreach ($inst_exts as $ext) {
            if (!in_array($ext['id'], array_keys($forum_ext_last_versions))) {
                $forum_ext_last_versions[$ext['id']] = array('version' => $ext['version'], 'repo_url' => '', 'changes' => '');
            }
        }
    }
    ($hook = get_hook('ch_generate_ext_versions_cache_check_repository')) ? eval($hook) : null;
    // Output config as PHP code
    if (!write_cache_file(FORUM_CACHE_DIR . 'cache_ext_version_notifications.php', '<?php' . "\n\n" . 'if (!defined(\'FORUM_EXT_VERSIONS_LOADED\')) define(\'FORUM_EXT_VERSIONS_LOADED\', 1);' . "\n\n" . '$forum_ext_repos = ' . var_export($forum_ext_repos, true) . ';' . "\n\n" . ' $forum_ext_last_versions = ' . var_export($forum_ext_last_versions, true) . ";\n\n" . '$forum_ext_versions_update_cache = ' . time() . ";\n\n" . '?>')) {
        error('Unable to write configuration cache file to cache directory.<br />Please make sure PHP has write access to the directory \'cache\'.', __FILE__, __LINE__);
    }
}