changeset 2 | a8a21e1c7afa |
parent 0 | f9ffdbd96607 |
1:8f6143115bf5 | 2:a8a21e1c7afa |
---|---|
76 // |
76 // |
77 // Generate the config cache PHP script |
77 // Generate the config cache PHP script |
78 // |
78 // |
79 function generate_config_cache() |
79 function generate_config_cache() |
80 { |
80 { |
81 global $db; |
81 global $pun_db; |
82 |
82 |
83 // Get the forum config from the DB |
83 // Get the forum config from the DB |
84 $result = $db->query('SELECT * FROM '.$db->prefix.'config', true) or error('Unable to fetch forum config', __FILE__, __LINE__, $db->error()); |
84 $result = $pun_db->query('SELECT * FROM '.$pun_db->prefix.'config', true) or error('Unable to fetch forum config', __FILE__, __LINE__, $pun_db->error()); |
85 while ($cur_config_item = $db->fetch_row($result)) |
85 while ($cur_config_item = $pun_db->fetch_row($result)) |
86 $output[$cur_config_item[0]] = $cur_config_item[1]; |
86 $output[$cur_config_item[0]] = $cur_config_item[1]; |
87 |
87 |
88 // Output config as PHP code |
88 // Output config as PHP code |
89 $fh = @fopen(PUN_ROOT.'cache/cache_config.php', 'wb'); |
89 $fh = @fopen(PUN_ROOT.'cache/cache_config.php', 'wb'); |
90 if (!$fh) |
90 if (!$fh) |
99 // |
99 // |
100 // Generate the bans cache PHP script |
100 // Generate the bans cache PHP script |
101 // |
101 // |
102 function generate_bans_cache() |
102 function generate_bans_cache() |
103 { |
103 { |
104 global $db; |
104 global $pun_db; |
105 |
105 |
106 // Get the ban list from the DB |
106 // Get the ban list from the DB |
107 $result = $db->query('SELECT * FROM '.$db->prefix.'bans', true) or error('Unable to fetch ban list', __FILE__, __LINE__, $db->error()); |
107 $result = $pun_db->query('SELECT * FROM '.$pun_db->prefix.'bans', true) or error('Unable to fetch ban list', __FILE__, __LINE__, $pun_db->error()); |
108 |
108 |
109 $output = array(); |
109 $output = array(); |
110 while ($cur_ban = $db->fetch_assoc($result)) |
110 while ($cur_ban = $pun_db->fetch_assoc($result)) |
111 $output[] = $cur_ban; |
111 $output[] = $cur_ban; |
112 |
112 |
113 // Output ban list as PHP code |
113 // Output ban list as PHP code |
114 $fh = @fopen(PUN_ROOT.'cache/cache_bans.php', 'wb'); |
114 $fh = @fopen(PUN_ROOT.'cache/cache_bans.php', 'wb'); |
115 if (!$fh) |
115 if (!$fh) |
124 // |
124 // |
125 // Generate the ranks cache PHP script |
125 // Generate the ranks cache PHP script |
126 // |
126 // |
127 function generate_ranks_cache() |
127 function generate_ranks_cache() |
128 { |
128 { |
129 global $db; |
129 global $pun_db; |
130 |
130 |
131 // Get the rank list from the DB |
131 // Get the rank list from the DB |
132 $result = $db->query('SELECT * FROM '.$db->prefix.'ranks ORDER BY min_posts', true) or error('Unable to fetch rank list', __FILE__, __LINE__, $db->error()); |
132 $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()); |
133 |
133 |
134 $output = array(); |
134 $output = array(); |
135 while ($cur_rank = $db->fetch_assoc($result)) |
135 while ($cur_rank = $pun_db->fetch_assoc($result)) |
136 $output[] = $cur_rank; |
136 $output[] = $cur_rank; |
137 |
137 |
138 // Output ranks list as PHP code |
138 // Output ranks list as PHP code |
139 $fh = @fopen(PUN_ROOT.'cache/cache_ranks.php', 'wb'); |
139 $fh = @fopen(PUN_ROOT.'cache/cache_ranks.php', 'wb'); |
140 if (!$fh) |
140 if (!$fh) |
149 // |
149 // |
150 // Generate quickjump cache PHP scripts |
150 // Generate quickjump cache PHP scripts |
151 // |
151 // |
152 function generate_quickjump_cache($group_id = false) |
152 function generate_quickjump_cache($group_id = false) |
153 { |
153 { |
154 global $db, $lang_common, $pun_user; |
154 global $pun_db, $lang_common, $pun_user; |
155 |
155 |
156 // If a group_id was supplied, we generate the quickjump cache for that group only |
156 // If a group_id was supplied, we generate the quickjump cache for that group only |
157 if ($group_id !== false) |
157 if ($group_id !== false) |
158 $groups[0] = $group_id; |
158 $groups[0] = $group_id; |
159 else |
159 else |
160 { |
160 { |
161 // A group_id was now supplied, so we generate the quickjump cache for all groups |
161 // A group_id was now supplied, so we generate the quickjump cache for all groups |
162 $result = $db->query('SELECT g_id FROM '.$db->prefix.'groups') or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error()); |
162 $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()); |
163 $num_groups = $db->num_rows($result); |
163 $num_groups = $pun_db->num_rows($result); |
164 |
164 |
165 for ($i = 0; $i < $num_groups; ++$i) |
165 for ($i = 0; $i < $num_groups; ++$i) |
166 $groups[] = $db->result($result, $i); |
166 $groups[] = $pun_db->result($result, $i); |
167 } |
167 } |
168 |
168 |
169 // Loop through the groups in $groups and output the cache for each of them |
169 // Loop through the groups in $groups and output the cache for each of them |
170 while (list(, $group_id) = @each($groups)) |
170 while (list(, $group_id) = @each($groups)) |
171 { |
171 { |
176 |
176 |
177 $output = '<?php'."\n\n".'if (!defined(\'PUN\')) exit;'."\n".'define(\'PUN_QJ_LOADED\', 1);'."\n\n".'?>'; |
177 $output = '<?php'."\n\n".'if (!defined(\'PUN\')) exit;'."\n".'define(\'PUN_QJ_LOADED\', 1);'."\n\n".'?>'; |
178 $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"; |
178 $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"; |
179 |
179 |
180 |
180 |
181 $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()); |
181 $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()); |
182 |
182 |
183 $cur_category = 0; |
183 $cur_category = 0; |
184 while ($cur_forum = $db->fetch_assoc($result)) |
184 while ($cur_forum = $pun_db->fetch_assoc($result)) |
185 { |
185 { |
186 if ($cur_forum['cid'] != $cur_category) // A new category since last iteration? |
186 if ($cur_forum['cid'] != $cur_category) // A new category since last iteration? |
187 { |
187 { |
188 if ($cur_category) |
188 if ($cur_category) |
189 $output .= "\t\t\t\t\t\t".'</optgroup>'."\n"; |
189 $output .= "\t\t\t\t\t\t".'</optgroup>'."\n"; |