diff -r e3d7322305bf -r 5e1f1e916419 punbb/include/cache.php --- a/punbb/include/cache.php Sun Sep 02 11:00:57 2007 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,205 +0,0 @@ - $v) - { - if (is_numeric($k)) - $output .= $indent.' '.$k.' => '; - else - $output .= $indent.' \''.str_replace('\'', '\\\'', str_replace('\\', '\\\\', $k)).'\' => '; - - if (is_array($v)) - $output .= var_export($v, true, $indent.' '); - else - { - if (gettype($v) != 'string' && !empty($v)) - $output .= $v.','."\n"; - else - $output .= '\''.str_replace('\'', '\\\'', str_replace('\\', '\\\\', $v)).'\','."\n"; - } - } - - $output .= ($indent != '') ? $indent.'),'."\n" : ')'; - } - else - $output = $args[0]; - - if ($args[1] == true) - return $output; - else - echo $output; - } -} - - -// -// Generate the config cache PHP script -// -function generate_config_cache() -{ - global $pun_db; - - // Get the forum config from the DB - $result = $pun_db->query('SELECT * FROM '.$pun_db->prefix.'config', true) or error('Unable to fetch forum config', __FILE__, __LINE__, $pun_db->error()); - while ($cur_config_item = $pun_db->fetch_row($result)) - $output[$cur_config_item[0]] = $cur_config_item[1]; - - // Output config as PHP code - $fh = @fopen(PUN_ROOT.'cache/cache_config.php', 'wb'); - if (!$fh) - error('Unable to write configuration cache file to cache directory. Please make sure PHP has write access to the directory \'cache\'', __FILE__, __LINE__); - - fwrite($fh, ''); - - fclose($fh); -} - - -// -// Generate the bans cache PHP script -// -function generate_bans_cache() -{ - global $pun_db; - - // Get the ban list from the DB - $result = $pun_db->query('SELECT * FROM '.$pun_db->prefix.'bans', true) or error('Unable to fetch ban list', __FILE__, __LINE__, $pun_db->error()); - - $output = array(); - while ($cur_ban = $pun_db->fetch_assoc($result)) - $output[] = $cur_ban; - - // Output ban list as PHP code - $fh = @fopen(PUN_ROOT.'cache/cache_bans.php', 'wb'); - if (!$fh) - error('Unable to write bans cache file to cache directory. Please make sure PHP has write access to the directory \'cache\'', __FILE__, __LINE__); - - fwrite($fh, ''); - - fclose($fh); -} - - -// -// Generate the ranks cache PHP script -// -function generate_ranks_cache() -{ - global $pun_db; - - // Get the rank list from the DB - $result = $pun_db->query('SELECT * FROM '.$pun_db->prefix.'ranks ORDER BY min_posts', true) or error('Unable to fetch rank list', __FILE__, __LINE__, $pun_db->error()); - - $output = array(); - while ($cur_rank = $pun_db->fetch_assoc($result)) - $output[] = $cur_rank; - - // Output ranks list as PHP code - $fh = @fopen(PUN_ROOT.'cache/cache_ranks.php', 'wb'); - if (!$fh) - error('Unable to write ranks cache file to cache directory. Please make sure PHP has write access to the directory \'cache\'', __FILE__, __LINE__); - - fwrite($fh, ''); - - fclose($fh); -} - - -// -// Generate quickjump cache PHP scripts -// -function generate_quickjump_cache($group_id = false) -{ - global $pun_db, $lang_common, $pun_user; - - // If a group_id was supplied, we generate the quickjump cache for that group only - if ($group_id !== false) - $groups[0] = $group_id; - else - { - // A group_id was now supplied, so we generate the quickjump cache for all groups - $result = $pun_db->query('SELECT g_id FROM '.$pun_db->prefix.'groups') or error('Unable to fetch user group list', __FILE__, __LINE__, $pun_db->error()); - $num_groups = $pun_db->num_rows($result); - - for ($i = 0; $i < $num_groups; ++$i) - $groups[] = $pun_db->result($result, $i); - } - - // Loop through the groups in $groups and output the cache for each of them - while (list(, $group_id) = @each($groups)) - { - // Output quickjump as PHP code - $fh = @fopen(PUN_ROOT.'cache/cache_quickjump_'.$group_id.'.php', 'wb'); - if (!$fh) - error('Unable to write quickjump cache file to cache directory. Please make sure PHP has write access to the directory \'cache\'', __FILE__, __LINE__); - - $output = ''; - $output .= "\t\t\t\t".'
'."\n\t\t\t\t\t".'
'."\n\t\t\t\t".'
'."\n"; - - fwrite($fh, $output); - - fclose($fh); - } -}