punbb/include/cache.php
changeset 2 a8a21e1c7afa
parent 0 f9ffdbd96607
--- a/punbb/include/cache.php	Wed Jul 11 21:28:39 2007 -0400
+++ b/punbb/include/cache.php	Thu Jul 12 01:04:01 2007 -0400
@@ -78,11 +78,11 @@
 //
 function generate_config_cache()
 {
-	global $db;
+	global $pun_db;
 
 	// Get the forum config from the DB
-	$result = $db->query('SELECT * FROM '.$db->prefix.'config', true) or error('Unable to fetch forum config', __FILE__, __LINE__, $db->error());
-	while ($cur_config_item = $db->fetch_row($result))
+	$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
@@ -101,13 +101,13 @@
 //
 function generate_bans_cache()
 {
-	global $db;
+	global $pun_db;
 
 	// Get the ban list from the DB
-	$result = $db->query('SELECT * FROM '.$db->prefix.'bans', true) or error('Unable to fetch ban list', __FILE__, __LINE__, $db->error());
+	$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 = $db->fetch_assoc($result))
+	while ($cur_ban = $pun_db->fetch_assoc($result))
 		$output[] = $cur_ban;
 
 	// Output ban list as PHP code
@@ -126,13 +126,13 @@
 //
 function generate_ranks_cache()
 {
-	global $db;
+	global $pun_db;
 
 	// Get the rank list from the DB
-	$result = $db->query('SELECT * FROM '.$db->prefix.'ranks ORDER BY min_posts', true) or error('Unable to fetch rank list', __FILE__, __LINE__, $db->error());
+	$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 = $db->fetch_assoc($result))
+	while ($cur_rank = $pun_db->fetch_assoc($result))
 		$output[] = $cur_rank;
 
 	// Output ranks list as PHP code
@@ -151,7 +151,7 @@
 //
 function generate_quickjump_cache($group_id = false)
 {
-	global $db, $lang_common, $pun_user;
+	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)
@@ -159,11 +159,11 @@
 	else
 	{
 		// A group_id was now supplied, so we generate the quickjump cache for all groups
-		$result = $db->query('SELECT g_id FROM '.$db->prefix.'groups') or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error());
-		$num_groups = $db->num_rows($result);
+		$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[] = $db->result($result, $i);
+			$groups[] = $pun_db->result($result, $i);
 	}
 
 	// Loop through the groups in $groups and output the cache for each of them
@@ -178,10 +178,10 @@
 		$output .= "\t\t\t\t".'<form id="qjump" method="get" action="viewforum.php">'."\n\t\t\t\t\t".'<div><label><?php echo $lang_common[\'Jump to\'] ?>'."\n\n\t\t\t\t\t".'<br /><select name="id" onchange="window.location=(\'viewforum.php?id=\'+this.options[this.selectedIndex].value)">'."\n";
 
 
-		$result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.redirect_url FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$group_id.') WHERE fp.read_forum IS NULL OR fp.read_forum=1 ORDER BY c.disp_position, c.id, f.disp_position', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());
+		$result = $pun_db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.redirect_url FROM '.$pun_db->prefix.'categories AS c INNER JOIN '.$pun_db->prefix.'forums AS f ON c.id=f.cat_id LEFT JOIN '.$pun_db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$group_id.') WHERE fp.read_forum IS NULL OR fp.read_forum=1 ORDER BY c.disp_position, c.id, f.disp_position', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $pun_db->error());
 
 		$cur_category = 0;
-		while ($cur_forum = $db->fetch_assoc($result))
+		while ($cur_forum = $pun_db->fetch_assoc($result))
 		{
 			if ($cur_forum['cid'] != $cur_category)	// A new category since last iteration?
 			{