punbb-1.2.15/upload/include/functions.php |
punbb-1.2.16/upload/include/functions.php |
352: | 352: |
353: | 353: |
354: // | 354: // |
355: // Update posts, topics, last_post, last_post_id and last_poster for a forum (redirect topics are not included) | 355: // Update posts, topics, last_post, last_post_id and last_poster for a forum |
356: // | 356: // |
357: function update_forum($forum_id) | 357: function update_forum($forum_id) |
358: { | 358: { |
359: global $db; | 359: global $db; |
360: | 360: |
361: $result = $db->query('SELECT COUNT(id), SUM(num_replies) FROM '.$db->prefix.'topics WHERE moved_to IS NULL AND forum_id='.$forum_id) or error('Unable to fetch forum topic count', __FILE__, __LINE__, $db->error()); | 361: $result = $db->query('SELECT COUNT(id), SUM(num_replies) FROM '.$db->prefix.'topics WHERE forum_id='.$forum_id) or error('Unable to fetch forum topic count', __FILE__, __LINE__, $db->error()); |
362: list($num_topics, $num_posts) = $db->fetch_row($result); | 362: list($num_topics, $num_posts) = $db->fetch_row($result); |
363: | 363: |
364: $num_posts = $num_posts + $num_topics; // $num_posts is only the sum of all replies (we have to add the topic posts) | 364: $num_posts = $num_posts + $num_topics; // $num_posts is only the sum of all replies (we have to add the topic posts) |
371: $db->query('UPDATE '.$db->prefix.'forums SET num_topics='.$num_topics.', num_posts='.$num_posts.', last_post='.$last_post.', last_post_id='.$last_post_id.', last_poster=\''.$db->escape($last_poster).'\' WHERE id='.$forum_id) or error('Unable to update last_post/last_post_id/last_poster', __FILE__, __LINE__, $db->error()); | 371: $db->query('UPDATE '.$db->prefix.'forums SET num_topics='.$num_topics.', num_posts='.$num_posts.', last_post='.$last_post.', last_post_id='.$last_post_id.', last_poster=\''.$db->escape($last_poster).'\' WHERE id='.$forum_id) or error('Unable to update last_post/last_post_id/last_poster', __FILE__, __LINE__, $db->error()); |
372: } | 372: } |
373: else // There are no topics | 373: else // There are no topics |
374: $db->query('UPDATE '.$db->prefix.'forums SET num_topics=0, num_posts=0, last_post=NULL, last_post_id=NULL, last_poster=NULL WHERE id='.$forum_id) or error('Unable to update last_post/last_post_id/last_poster', __FILE__, __LINE__, $db->error()); | 374: $db->query('UPDATE '.$db->prefix.'forums SET num_topics='.$num_topics.', num_posts='.$num_posts.', last_post=NULL, last_post_id=NULL, last_poster=NULL WHERE id='.$forum_id) or error('Unable to update last_post/last_post_id/last_poster', __FILE__, __LINE__, $db->error()); |
375: } | 375: } |
376: | 376: |
377: | 377: |
849: { | 849: { |
850: global $db, $pun_config, $lang_common, $pun_user; | 850: global $db, $pun_config, $lang_common, $pun_user; |
851: | 851: |
852: if ($destination_url == '') | 852: // Prefix with o_base_url (unless it's there already) |
853: $destination_url = 'index.php'; | 853: if (strpos($destination_url, $pun_config['o_base_url']) !== 0) |
| 854: $destination_url = $pun_config['o_base_url'].'/'.$destination_url; |
| 855: |
| 856: // Do a little spring cleaning |
| 857: $destination_url = preg_replace('/([\r\n])|(%0[ad])|(;[\s]*data[\s]*:)/i', '', $destination_url); |
854: | 858: |
855: // If the delay is 0 seconds, we might as well skip the redirect all together | 859: // If the delay is 0 seconds, we might as well skip the redirect all together |
856: if ($pun_config['o_redirect_delay'] == '0') | 860: if ($pun_config['o_redirect_delay'] == '0') |
1067: function unregister_globals() | 1071: function unregister_globals() |
1068: { | 1072: { |
1069: $register_globals = @ini_get('register_globals'); | 1073: $register_globals = @ini_get('register_globals'); |
1070: if ($register_globals === "" || $register_globals === "0" || strtolower($register_globals === "off")) | 1074: if ($register_globals === "" || $register_globals === "0" || strtolower($register_globals) === "off") |
1071: return; | 1075: return; |
1072: | 1076: |
1073: // Prevent script.php?GLOBALS[foo]=bar | 1077: // Prevent script.php?GLOBALS[foo]=bar |