| punbb-1.2.6/upload/include/functions.php |
punbb-1.2.16/upload/include/functions.php |
| 27: // | 27: // |
| 28: function check_cookie(&$pun_user) | 28: function check_cookie(&$pun_user) |
| 29: { | 29: { |
| 30: global $db, $pun_config, $cookie_name, $cookie_seed; | 30: global $db, $db_type, $pun_config, $cookie_name, $cookie_seed; |
| 31: | 31: |
| 32: $now = time(); | 32: $now = time(); |
| 33: $expire = $now + 31536000; // The cookie expires after a year | 33: $expire = $now + 31536000; // The cookie expires after a year |
| 75: { | 75: { |
| 76: // Update the online list | 76: // Update the online list |
| 77: if (!$pun_user['logged']) | 77: if (!$pun_user['logged']) |
| 78: $db->query('INSERT INTO '.$db->prefix.'online (user_id, ident, logged) VALUES('.$pun_user['id'].', \''.$db->escape($pun_user['username']).'\', '.$now.')') or error('Unable to insert into online list', __FILE__, __LINE__, $db->error()); | 78: { |
| | 79: $pun_user['logged'] = $now; |
| | 80: |
| | 81: // With MySQL/MySQLi, REPLACE INTO avoids a user having two rows in the online table |
| | 82: switch ($db_type) |
| | 83: { |
| | 84: case 'mysql': |
| | 85: case 'mysqli': |
| | 86: $db->query('REPLACE INTO '.$db->prefix.'online (user_id, ident, logged) VALUES('.$pun_user['id'].', \''.$db->escape($pun_user['username']).'\', '.$pun_user['logged'].')') or error('Unable to insert into online list', __FILE__, __LINE__, $db->error()); |
| | 87: break; |
| | 88: |
| | 89: default: |
| | 90: $db->query('INSERT INTO '.$db->prefix.'online (user_id, ident, logged) VALUES('.$pun_user['id'].', \''.$db->escape($pun_user['username']).'\', '.$pun_user['logged'].')') or error('Unable to insert into online list', __FILE__, __LINE__, $db->error()); |
| | 91: break; |
| | 92: } |
| | 93: } |
| 79: else | 94: else |
| 80: { | 95: { |
| 81: // Special case: We've timed out, but no other user has browsed the forums since we timed out | 96: // Special case: We've timed out, but no other user has browsed the forums since we timed out |
| 102: // | 117: // |
| 103: function set_default_user() | 118: function set_default_user() |
| 104: { | 119: { |
| 105: global $db, $pun_user, $pun_config; | 120: global $db, $db_type, $pun_user, $pun_config; |
| 106: | 121: |
| 107: $remote_addr = get_remote_address(); | 122: $remote_addr = get_remote_address(); |
| 108: | 123: |
| 115: | 130: |
| 116: // Update online list | 131: // Update online list |
| 117: if (!$pun_user['logged']) | 132: if (!$pun_user['logged']) |
| 118: $db->query('INSERT INTO '.$db->prefix.'online (user_id, ident, logged) VALUES(1, \''.$db->escape($remote_addr).'\', '.time().')') or error('Unable to insert into online list', __FILE__, __LINE__, $db->error()); | 133: { |
| | 134: $pun_user['logged'] = time(); |
| | 135: |
| | 136: // With MySQL/MySQLi, REPLACE INTO avoids a user having two rows in the online table |
| | 137: switch ($db_type) |
| | 138: { |
| | 139: case 'mysql': |
| | 140: case 'mysqli': |
| | 141: $db->query('REPLACE INTO '.$db->prefix.'online (user_id, ident, logged) VALUES(1, \''.$db->escape($remote_addr).'\', '.$pun_user['logged'].')') or error('Unable to insert into online list', __FILE__, __LINE__, $db->error()); |
| | 142: break; |
| | 143: |
| | 144: default: |
| | 145: $db->query('INSERT INTO '.$db->prefix.'online (user_id, ident, logged) VALUES(1, \''.$db->escape($remote_addr).'\', '.$pun_user['logged'].')') or error('Unable to insert into online list', __FILE__, __LINE__, $db->error()); |
| | 146: break; |
| | 147: } |
| | 148: } |
| 119: else | 149: else |
| 120: $db->query('UPDATE '.$db->prefix.'online SET logged='.time().' WHERE ident=\''.$db->escape($remote_addr).'\'') or error('Unable to update online list', __FILE__, __LINE__, $db->error()); | 150: $db->query('UPDATE '.$db->prefix.'online SET logged='.time().' WHERE ident=\''.$db->escape($remote_addr).'\'') or error('Unable to update online list', __FILE__, __LINE__, $db->error()); |
| 121: | 151: |
| 138: // Enable sending of a P3P header by removing // from the following line (try this if login is failing in IE6) | 168: // Enable sending of a P3P header by removing // from the following line (try this if login is failing in IE6) |
| 139: // @header('P3P: CP="CUR ADM"'); | 169: // @header('P3P: CP="CUR ADM"'); |
| 140: | 170: |
| 141: setcookie($cookie_name, serialize(array($user_id, md5($cookie_seed.$password_hash))), $expire, $cookie_path, $cookie_domain, $cookie_secure); | 171: if (version_compare(PHP_VERSION, '5.2.0', '>=')) |
| | 172: setcookie($cookie_name, serialize(array($user_id, md5($cookie_seed.$password_hash))), $expire, $cookie_path, $cookie_domain, $cookie_secure, true); |
| | 173: else |
| | 174: setcookie($cookie_name, serialize(array($user_id, md5($cookie_seed.$password_hash))), $expire, $cookie_path.'; HttpOnly', $cookie_domain, $cookie_secure); |
| 142: } | 175: } |
| 143: | 176: |
| 144: | 177: |
| 168: } | 201: } |
| 169: | 202: |
| 170: if ($cur_ban['username'] != '' && !strcasecmp($pun_user['username'], $cur_ban['username'])) | 203: if ($cur_ban['username'] != '' && !strcasecmp($pun_user['username'], $cur_ban['username'])) |
| | 204: { |
| | 205: $db->query('DELETE FROM '.$db->prefix.'online WHERE ident=\''.$db->escape($pun_user['username']).'\'') or error('Unable to delete from online list', __FILE__, __LINE__, $db->error()); |
| 171: message($lang_common['Ban message'].' '.(($cur_ban['expire'] != '') ? $lang_common['Ban message 2'].' '.strtolower(format_time($cur_ban['expire'], true)).'. ' : '').(($cur_ban['message'] != '') ? $lang_common['Ban message 3'].'<br /><br /><strong>'.pun_htmlspecialchars($cur_ban['message']).'</strong><br /><br />' : '<br /><br />').$lang_common['Ban message 4'].' <a href="mailto:'.$pun_config['o_admin_email'].'">'.$pun_config['o_admin_email'].'</a>.', true); | 206: message($lang_common['Ban message'].' '.(($cur_ban['expire'] != '') ? $lang_common['Ban message 2'].' '.strtolower(format_time($cur_ban['expire'], true)).'. ' : '').(($cur_ban['message'] != '') ? $lang_common['Ban message 3'].'<br /><br /><strong>'.pun_htmlspecialchars($cur_ban['message']).'</strong><br /><br />' : '<br /><br />').$lang_common['Ban message 4'].' <a href="mailto:'.$pun_config['o_admin_email'].'">'.$pun_config['o_admin_email'].'</a>.', true); |
| | 207: } |
| 172: | 208: |
| 173: if ($cur_ban['ip'] != '') | 209: if ($cur_ban['ip'] != '') |
| 174: { | 210: { |
| 179: $cur_ban_ips[$i] = $cur_ban_ips[$i].'.'; | 215: $cur_ban_ips[$i] = $cur_ban_ips[$i].'.'; |
| 180: | 216: |
| 181: if (substr($user_ip, 0, strlen($cur_ban_ips[$i])) == $cur_ban_ips[$i]) | 217: if (substr($user_ip, 0, strlen($cur_ban_ips[$i])) == $cur_ban_ips[$i]) |
| | 218: { |
| | 219: $db->query('DELETE FROM '.$db->prefix.'online WHERE ident=\''.$db->escape($pun_user['username']).'\'') or error('Unable to delete from online list', __FILE__, __LINE__, $db->error()); |
| 182: message($lang_common['Ban message'].' '.(($cur_ban['expire'] != '') ? $lang_common['Ban message 2'].' '.strtolower(format_time($cur_ban['expire'], true)).'. ' : '').(($cur_ban['message'] != '') ? $lang_common['Ban message 3'].'<br /><br /><strong>'.pun_htmlspecialchars($cur_ban['message']).'</strong><br /><br />' : '<br /><br />').$lang_common['Ban message 4'].' <a href="mailto:'.$pun_config['o_admin_email'].'">'.$pun_config['o_admin_email'].'</a>.', true); | 220: message($lang_common['Ban message'].' '.(($cur_ban['expire'] != '') ? $lang_common['Ban message 2'].' '.strtolower(format_time($cur_ban['expire'], true)).'. ' : '').(($cur_ban['message'] != '') ? $lang_common['Ban message 3'].'<br /><br /><strong>'.pun_htmlspecialchars($cur_ban['message']).'</strong><br /><br />' : '<br /><br />').$lang_common['Ban message 4'].' <a href="mailto:'.$pun_config['o_admin_email'].'">'.$pun_config['o_admin_email'].'</a>.', true); |
| | 221: } |
| 183: } | 222: } |
| 184: } | 223: } |
| 185: } | 224: } |
| 203: $now = time(); | 242: $now = time(); |
| 204: | 243: |
| 205: // Fetch all online list entries that are older than "o_timeout_online" | 244: // Fetch all online list entries that are older than "o_timeout_online" |
| 206: $result = $db->query('SELECT * FROM '.$db->prefix.'online WHERE logged<'.($now-$pun_config['o_timeout_online'])) or error('Unable to delete from online list', __FILE__, __LINE__, $db->error()); | 245: $result = $db->query('SELECT * FROM '.$db->prefix.'online WHERE logged<'.($now-$pun_config['o_timeout_online'])) or error('Unable to fetch old entries from online list', __FILE__, __LINE__, $db->error()); |
| 207: while ($cur_user = $db->fetch_assoc($result)) | 246: while ($cur_user = $db->fetch_assoc($result)) |
| 208: { | 247: { |
| 209: // If the entry is a guest, delete it | 248: // If the entry is a guest, delete it |
| 313: | 352: |
| 314: | 353: |
| 315: // | 354: // |
| 316: // 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 |
| 317: // | 356: // |
| 318: function update_forum($forum_id) | 357: function update_forum($forum_id) |
| 319: { | 358: { |
| 320: global $db; | 359: global $db; |
| 321: | 360: |
| 322: $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()); |
| 323: list($num_topics, $num_posts) = $db->fetch_row($result); | 362: list($num_topics, $num_posts) = $db->fetch_row($result); |
| 324: | 363: |
| 325: $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) |
| 332: $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()); |
| 333: } | 372: } |
| 334: else // There are no topics | 373: else // There are no topics |
| 335: $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()); |
| 336: } | 375: } |
| 337: | 376: |
| 338: | 377: |
| 675: // | 714: // |
| 676: function get_remote_address() | 715: function get_remote_address() |
| 677: { | 716: { |
| 678: $remote_address = $_SERVER['REMOTE_ADDR']; | 717: return $_SERVER['REMOTE_ADDR']; |
| 679: | |
| 680: // If HTTP_X_FORWARDED_FOR is set, we try to grab the first non-LAN IP | |
| 681: if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) | |
| 682: { | |
| 683: if (preg_match_all('/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/', $_SERVER['HTTP_X_FORWARDED_FOR'], $address_list)) | |
| 684: { | |
| 685: $lan_ips = array('/^0\./', '/^127\.0\.0\.1/', '/^192\.168\..*/', '/^172\.((1[6-9])|(2[0-9])|(3[0-1]))\..*/', '/^10\..*/', '/^224\..*/', '/^240\..*/'); | |
| 686: $address_list = preg_replace($lan_ips, null, $address_list[0]); | |
| 687: | |
| 688: while (list(, $cur_address) = each($address_list)) | |
| 689: { | |
| 690: if ($cur_address) | |
| 691: { | |
| 692: $remote_address = $cur_address; | |
| 693: break; | |
| 694: } | |
| 695: } | |
| 696: } | |
| 697: } | |
| 698: | |
| 699: return $remote_address; | |
| 700: } | 718: } |
| 701: | 719: |
| 702: | 720: |
| 764: $tpl_maint = trim(file_get_contents(PUN_ROOT.'include/template/maintenance.tpl')); | 782: $tpl_maint = trim(file_get_contents(PUN_ROOT.'include/template/maintenance.tpl')); |
| 765: | 783: |
| 766: | 784: |
| | 785: // START SUBST - <pun_include "*"> |
| | 786: while (preg_match('#<pun_include "([^/\\\\]*?)\.(php[45]?|inc|html?|txt)">#', $tpl_maint, $cur_include)) |
| | 787: { |
| | 788: if (!file_exists(PUN_ROOT.'include/user/'.$cur_include[1].'.'.$cur_include[2])) |
| | 789: error('Unable to process user include '.htmlspecialchars($cur_include[0]).' from template maintenance.tpl. There is no such file in folder /include/user/'); |
| | 790: |
| | 791: ob_start(); |
| | 792: include PUN_ROOT.'include/user/'.$cur_include[1].'.'.$cur_include[2]; |
| | 793: $tpl_temp = ob_get_contents(); |
| | 794: $tpl_maint = str_replace($cur_include[0], $tpl_temp, $tpl_maint); |
| | 795: ob_end_clean(); |
| | 796: } |
| | 797: // END SUBST - <pun_include "*"> |
| | 798: |
| | 799: |
| 767: // START SUBST - <pun_content_direction> | 800: // START SUBST - <pun_content_direction> |
| 768: $tpl_maint = str_replace('<pun_content_direction>', $lang_common['lang_direction'], $tpl_maint); | 801: $tpl_maint = str_replace('<pun_content_direction>', $lang_common['lang_direction'], $tpl_maint); |
| 769: // END SUBST - <pun_content_direction> | 802: // END SUBST - <pun_content_direction> |
| 802: $db->end_transaction(); | 835: $db->end_transaction(); |
| 803: | 836: |
| 804: | 837: |
| 805: // START SUBST - <pun_include "*"> | |
| 806: while (preg_match('#<pun_include "([^/\\\\]*?)">#', $tpl_maint, $cur_include)) | |
| 807: { | |
| 808: if (!file_exists(PUN_ROOT.'include/user/'.$cur_include[1])) | |
| 809: error('Unable to process user include <pun_include "'.htmlspecialchars($cur_include[1]).'"> from template maintenance.tpl. There is no such file in folder /include/user/'); | |
| 810: | |
| 811: ob_start(); | |
| 812: include PUN_ROOT.'include/user/'.$cur_include[1]; | |
| 813: $tpl_temp = ob_get_contents(); | |
| 814: $tpl_maint = str_replace($cur_include[0], $tpl_temp, $tpl_maint); | |
| 815: ob_end_clean(); | |
| 816: } | |
| 817: // END SUBST - <pun_include "*"> | |
| 818: | |
| 819: | |
| 820: // Close the db connection (and free up any result data) | 838: // Close the db connection (and free up any result data) |
| 821: $db->close(); | 839: $db->close(); |
| 822: | 840: |
| 831: { | 849: { |
| 832: global $db, $pun_config, $lang_common, $pun_user; | 850: global $db, $pun_config, $lang_common, $pun_user; |
| 833: | 851: |
| 834: if ($destination_url == '') | 852: // Prefix with o_base_url (unless it's there already) |
| 835: $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); |
| 836: | 858: |
| 837: // 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 |
| 838: if ($pun_config['o_redirect_delay'] == '0') | 860: if ($pun_config['o_redirect_delay'] == '0') |
| 843: $tpl_redir = trim(file_get_contents(PUN_ROOT.'include/template/redirect.tpl')); | 865: $tpl_redir = trim(file_get_contents(PUN_ROOT.'include/template/redirect.tpl')); |
| 844: | 866: |
| 845: | 867: |
| | 868: // START SUBST - <pun_include "*"> |
| | 869: while (preg_match('#<pun_include "([^/\\\\]*?)\.(php[45]?|inc|html?|txt)">#', $tpl_redir, $cur_include)) |
| | 870: { |
| | 871: if (!file_exists(PUN_ROOT.'include/user/'.$cur_include[1].'.'.$cur_include[2])) |
| | 872: error('Unable to process user include '.htmlspecialchars($cur_include[0]).' from template redirect.tpl. There is no such file in folder /include/user/'); |
| | 873: |
| | 874: ob_start(); |
| | 875: include PUN_ROOT.'include/user/'.$cur_include[1].'.'.$cur_include[2]; |
| | 876: $tpl_temp = ob_get_contents(); |
| | 877: $tpl_redir = str_replace($cur_include[0], $tpl_temp, $tpl_redir); |
| | 878: ob_end_clean(); |
| | 879: } |
| | 880: // END SUBST - <pun_include "*"> |
| | 881: |
| | 882: |
| 846: // START SUBST - <pun_content_direction> | 883: // START SUBST - <pun_content_direction> |
| 847: $tpl_redir = str_replace('<pun_content_direction>', $lang_common['lang_direction'], $tpl_redir); | 884: $tpl_redir = str_replace('<pun_content_direction>', $lang_common['lang_direction'], $tpl_redir); |
| 848: // END SUBST - <pun_content_direction> | 885: // END SUBST - <pun_content_direction> |
| 895: // END SUBST - <pun_footer> | 932: // END SUBST - <pun_footer> |
| 896: | 933: |
| 897: | 934: |
| 898: // START SUBST - <pun_include "*"> | |
| 899: while (preg_match('#<pun_include "([^/\\\\]*?)">#', $tpl_redir, $cur_include)) | |
| 900: { | |
| 901: if (!file_exists(PUN_ROOT.'include/user/'.$cur_include[1])) | |
| 902: error('Unable to process user include <pun_include "'.htmlspecialchars($cur_include[1]).'"> from template redirect.tpl. There is no such file in folder /include/user/'); | |
| 903: | |
| 904: ob_start(); | |
| 905: include PUN_ROOT.'include/user/'.$cur_include[1]; | |
| 906: $tpl_temp = ob_get_contents(); | |
| 907: $tpl_redir = str_replace($cur_include[0], $tpl_temp, $tpl_redir); | |
| 908: ob_end_clean(); | |
| 909: } | |
| 910: // END SUBST - <pun_include "*"> | |
| 911: | |
| 912: | |
| 913: // Close the db connection (and free up any result data) | 935: // Close the db connection (and free up any result data) |
| 914: $db->close(); | 936: $db->close(); |
| 915: | 937: |
| 937: | 959: |
| 938: ?> | 960: ?> |
| 939: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | 961: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
| 940: <html dir="ltr"> | 962: <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr"> |
| 941: <head> | 963: <head> |
| 942: <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> | 964: <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> |
| 943: <title><?php echo pun_htmlspecialchars($pun_config['o_board_title']) ?> / Error</title> | 965: <title><?php echo pun_htmlspecialchars($pun_config['o_board_title']) ?> / Error</title> |
| 1044: | 1066: |
| 1045: | 1067: |
| 1046: // | 1068: // |
| | 1069: // Unset any variables instantiated as a result of register_globals being enabled |
| | 1070: // |
| | 1071: function unregister_globals() |
| | 1072: { |
| | 1073: $register_globals = @ini_get('register_globals'); |
| | 1074: if ($register_globals === "" || $register_globals === "0" || strtolower($register_globals) === "off") |
| | 1075: return; |
| | 1076: |
| | 1077: // Prevent script.php?GLOBALS[foo]=bar |
| | 1078: if (isset($_REQUEST['GLOBALS']) || isset($_FILES['GLOBALS'])) |
| | 1079: exit('I\'ll have a steak sandwich and... a steak sandwich.'); |
| | 1080: |
| | 1081: // Variables that shouldn't be unset |
| | 1082: $no_unset = array('GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES'); |
| | 1083: |
| | 1084: // Remove elements in $GLOBALS that are present in any of the superglobals |
| | 1085: $input = array_merge($_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset($_SESSION) && is_array($_SESSION) ? $_SESSION : array()); |
| | 1086: foreach ($input as $k => $v) |
| | 1087: { |
| | 1088: if (!in_array($k, $no_unset) && isset($GLOBALS[$k])) |
| | 1089: { |
| | 1090: unset($GLOBALS[$k]); |
| | 1091: unset($GLOBALS[$k]); // Double unset to circumvent the zend_hash_del_key_or_index hole in PHP <4.4.3 and <5.1.4 |
| | 1092: } |
| | 1093: } |
| | 1094: } |
| | 1095: |
| | 1096: |
| | 1097: // |
| 1047: // Dump contents of variable(s) | 1098: // Dump contents of variable(s) |
| 1048: // | 1099: // |
| 1049: function dump() | 1100: function dump() |
| punbb-1.2.6/upload/install.php |
punbb-1.2.16/upload/install.php |
| 24: | 24: |
| 25: | 25: |
| 26: // The PunBB version this script installs | 26: // The PunBB version this script installs |
| 27: $punbb_version = '1.2.6'; | 27: $punbb_version = '1.2.16'; |
| 28: | 28: |
| 29: | 29: |
| 30: define('PUN_ROOT', './'); | 30: define('PUN_ROOT', './'); |
| 528: break; | 528: break; |
| 529: } | 529: } |
| 530: | 530: |
| 531: $db->query($sql) or error('Unable to create table '.$db_prefix.'online. Please check your settings and try again.', __FILE__, __LINE__, $db->error()); | 531: $db->query($sql) or error('Unable to create table '.$db_prefix.'config. Please check your settings and try again.', __FILE__, __LINE__, $db->error()); |
| 532: | 532: |
| 533: | 533: |
| 534: | 534: |
| 757: poster_id INT(10) UNSIGNED NOT NULL DEFAULT 1, | 757: poster_id INT(10) UNSIGNED NOT NULL DEFAULT 1, |
| 758: poster_ip VARCHAR(15), | 758: poster_ip VARCHAR(15), |
| 759: poster_email VARCHAR(50), | 759: poster_email VARCHAR(50), |
| 760: message TEXT NOT NULL DEFAULT '', | 760: message TEXT, |
| 761: hide_smilies TINYINT(1) NOT NULL DEFAULT 0, | 761: hide_smilies TINYINT(1) NOT NULL DEFAULT 0, |
| 762: posted INT(10) UNSIGNED NOT NULL DEFAULT 0, | 762: posted INT(10) UNSIGNED NOT NULL DEFAULT 0, |
| 763: edited INT(10) UNSIGNED, | 763: edited INT(10) UNSIGNED, |
| 774: poster_id INT NOT NULL DEFAULT 1, | 774: poster_id INT NOT NULL DEFAULT 1, |
| 775: poster_ip VARCHAR(15), | 775: poster_ip VARCHAR(15), |
| 776: poster_email VARCHAR(50), | 776: poster_email VARCHAR(50), |
| 777: message TEXT NOT NULL DEFAULT '', | 777: message TEXT, |
| 778: hide_smilies SMALLINT NOT NULL DEFAULT 0, | 778: hide_smilies SMALLINT NOT NULL DEFAULT 0, |
| 779: posted INT NOT NULL DEFAULT 0, | 779: posted INT NOT NULL DEFAULT 0, |
| 780: edited INT, | 780: edited INT, |
| 791: poster_id INTEGER NOT NULL DEFAULT 1, | 791: poster_id INTEGER NOT NULL DEFAULT 1, |
| 792: poster_ip VARCHAR(15), | 792: poster_ip VARCHAR(15), |
| 793: poster_email VARCHAR(50), | 793: poster_email VARCHAR(50), |
| 794: message TEXT NOT NULL DEFAULT '', | 794: message TEXT, |
| 795: hide_smilies INTEGER NOT NULL DEFAULT 0, | 795: hide_smilies INTEGER NOT NULL DEFAULT 0, |
| 796: posted INTEGER NOT NULL DEFAULT 0, | 796: posted INTEGER NOT NULL DEFAULT 0, |
| 797: edited INTEGER, | 797: edited INTEGER, |
| 852: forum_id INT(10) UNSIGNED NOT NULL DEFAULT 0, | 852: forum_id INT(10) UNSIGNED NOT NULL DEFAULT 0, |
| 853: reported_by INT(10) UNSIGNED NOT NULL DEFAULT 0, | 853: reported_by INT(10) UNSIGNED NOT NULL DEFAULT 0, |
| 854: created INT(10) UNSIGNED NOT NULL DEFAULT 0, | 854: created INT(10) UNSIGNED NOT NULL DEFAULT 0, |
| 855: message TEXT NOT NULL DEFAULT '', | 855: message TEXT, |
| 856: zapped INT(10) UNSIGNED, | 856: zapped INT(10) UNSIGNED, |
| 857: zapped_by INT(10) UNSIGNED, | 857: zapped_by INT(10) UNSIGNED, |
| 858: PRIMARY KEY (id) | 858: PRIMARY KEY (id) |
| 867: forum_id INT NOT NULL DEFAULT 0, | 867: forum_id INT NOT NULL DEFAULT 0, |
| 868: reported_by INT NOT NULL DEFAULT 0, | 868: reported_by INT NOT NULL DEFAULT 0, |
| 869: created INT NOT NULL DEFAULT 0, | 869: created INT NOT NULL DEFAULT 0, |
| 870: message TEXT NOT NULL DEFAULT '', | 870: message TEXT, |
| 871: zapped INT, | 871: zapped INT, |
| 872: zapped_by INT, | 872: zapped_by INT, |
| 873: PRIMARY KEY (id) | 873: PRIMARY KEY (id) |
| 882: forum_id INTEGER NOT NULL DEFAULT 0, | 882: forum_id INTEGER NOT NULL DEFAULT 0, |
| 883: reported_by INTEGER NOT NULL DEFAULT 0, | 883: reported_by INTEGER NOT NULL DEFAULT 0, |
| 884: created INTEGER NOT NULL DEFAULT 0, | 884: created INTEGER NOT NULL DEFAULT 0, |
| 885: message TEXT NOT NULL DEFAULT '', | 885: message TEXT, |
| 886: zapped INTEGER, | 886: zapped INTEGER, |
| 887: zapped_by INTEGER, | 887: zapped_by INTEGER, |
| 888: PRIMARY KEY (id) | 888: PRIMARY KEY (id) |
| 901: $sql = 'CREATE TABLE '.$db_prefix."search_cache ( | 901: $sql = 'CREATE TABLE '.$db_prefix."search_cache ( |
| 902: id INT(10) UNSIGNED NOT NULL DEFAULT 0, | 902: id INT(10) UNSIGNED NOT NULL DEFAULT 0, |
| 903: ident VARCHAR(200) NOT NULL DEFAULT '', | 903: ident VARCHAR(200) NOT NULL DEFAULT '', |
| 904: search_data TEXT NOT NULL DEFAULT '', | 904: search_data TEXT, |
| 905: PRIMARY KEY (id) | 905: PRIMARY KEY (id) |
| 906: ) TYPE=MyISAM;"; | 906: ) TYPE=MyISAM;"; |
| 907: break; | 907: break; |
| 910: $sql = 'CREATE TABLE '.$db_prefix."search_cache ( | 910: $sql = 'CREATE TABLE '.$db_prefix."search_cache ( |
| 911: id INT NOT NULL DEFAULT 0, | 911: id INT NOT NULL DEFAULT 0, |
| 912: ident VARCHAR(200) NOT NULL DEFAULT '', | 912: ident VARCHAR(200) NOT NULL DEFAULT '', |
| 913: search_data TEXT NOT NULL DEFAULT '', | 913: search_data TEXT, |
| 914: PRIMARY KEY (id) | 914: PRIMARY KEY (id) |
| 915: )"; | 915: )"; |
| 916: break; | 916: break; |
| 919: $sql = 'CREATE TABLE '.$db_prefix."search_cache ( | 919: $sql = 'CREATE TABLE '.$db_prefix."search_cache ( |
| 920: id INTEGER NOT NULL DEFAULT 0, | 920: id INTEGER NOT NULL DEFAULT 0, |
| 921: ident VARCHAR(200) NOT NULL DEFAULT '', | 921: ident VARCHAR(200) NOT NULL DEFAULT '', |
| 922: search_data TEXT NOT NULL DEFAULT '', | 922: search_data TEXT, |
| 923: PRIMARY KEY (id) | 923: PRIMARY KEY (id) |
| 924: )"; | 924: )"; |
| 925: break; | 925: break; |
| 1234: case 'mysql': | 1234: case 'mysql': |
| 1235: case 'mysqli': | 1235: case 'mysqli': |
| 1236: // We use MySQL's ALTER TABLE ... ADD INDEX syntax instead of CREATE INDEX to avoid problems with users lacking the INDEX privilege | 1236: // We use MySQL's ALTER TABLE ... ADD INDEX syntax instead of CREATE INDEX to avoid problems with users lacking the INDEX privilege |
| | 1237: $queries[] = 'ALTER TABLE '.$db_prefix.'online ADD UNIQUE INDEX '.$db_prefix.'online_user_id_ident_idx(user_id,ident)'; |
| 1237: $queries[] = 'ALTER TABLE '.$db_prefix.'online ADD INDEX '.$db_prefix.'online_user_id_idx(user_id)'; | 1238: $queries[] = 'ALTER TABLE '.$db_prefix.'online ADD INDEX '.$db_prefix.'online_user_id_idx(user_id)'; |
| 1238: $queries[] = 'ALTER TABLE '.$db_prefix.'posts ADD INDEX '.$db_prefix.'posts_topic_id_idx(topic_id)'; | 1239: $queries[] = 'ALTER TABLE '.$db_prefix.'posts ADD INDEX '.$db_prefix.'posts_topic_id_idx(topic_id)'; |
| 1239: $queries[] = 'ALTER TABLE '.$db_prefix.'posts ADD INDEX '.$db_prefix.'posts_multi_idx(poster_id, topic_id)'; | 1240: $queries[] = 'ALTER TABLE '.$db_prefix.'posts ADD INDEX '.$db_prefix.'posts_multi_idx(poster_id, topic_id)'; |
| punbb-1.2.6/upload/moderate.php |
punbb-1.2.16/upload/moderate.php |
| 35: message($lang_common['No permission']); | 35: message($lang_common['No permission']); |
| 36: | 36: |
| 37: // Is get_host an IP address or a post ID? | 37: // Is get_host an IP address or a post ID? |
| 38: if (preg_match('/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/', $_GET['get_host'])) | 38: if (@preg_match('/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/', $_GET['get_host'])) |
| 39: $ip = $_GET['get_host']; | 39: $ip = $_GET['get_host']; |
| 40: else | 40: else |
| 41: { | 41: { |
| 98: { | 98: { |
| 99: confirm_referrer('moderate.php'); | 99: confirm_referrer('moderate.php'); |
| 100: | 100: |
| 101: if (preg_match('/[^0-9,]/', $posts)) | 101: if (@preg_match('/[^0-9,]/', $posts)) |
| | 102: message($lang_common['Bad request']); |
| | 103: |
| | 104: // Verify that the post IDs are valid |
| | 105: $result = $db->query('SELECT 1 FROM '.$db->prefix.'posts WHERE id IN('.$posts.') AND topic_id='.$tid) or error('Unable to check posts', __FILE__, __LINE__, $db->error()); |
| | 106: |
| | 107: if ($db->num_rows($result) != substr_count($posts, ',') + 1) |
| 102: message($lang_common['Bad request']); | 108: message($lang_common['Bad request']); |
| 103: | 109: |
| 104: // Delete the posts | 110: // Delete the posts |
| 281: { | 287: { |
| 282: confirm_referrer('moderate.php'); | 288: confirm_referrer('moderate.php'); |
| 283: | 289: |
| 284: if (preg_match('/[^0-9,]/', $_POST['topics'])) | 290: if (@preg_match('/[^0-9,]/', $_POST['topics'])) |
| 285: message($lang_common['Bad request']); | 291: message($lang_common['Bad request']); |
| 286: | 292: |
| 287: $topics = explode(',', $_POST['topics']); | 293: $topics = explode(',', $_POST['topics']); |
| 289: if (empty($topics) || $move_to_forum < 1) | 295: if (empty($topics) || $move_to_forum < 1) |
| 290: message($lang_common['Bad request']); | 296: message($lang_common['Bad request']); |
| 291: | 297: |
| | 298: // Verify that the topic IDs are valid |
| | 299: $result = $db->query('SELECT 1 FROM '.$db->prefix.'topics WHERE id IN('.implode(',',$topics).') AND forum_id='.$fid) or error('Unable to check topics', __FILE__, __LINE__, $db->error()); |
| | 300: |
| | 301: if ($db->num_rows($result) != count($topics)) |
| | 302: message($lang_common['Bad request']); |
| | 303: |
| 292: // Delete any redirect topics if there are any (only if we moved/copied the topic back to where it where it was once moved from) | 304: // Delete any redirect topics if there are any (only if we moved/copied the topic back to where it where it was once moved from) |
| 293: $db->query('DELETE FROM '.$db->prefix.'topics WHERE forum_id='.$move_to_forum.' AND moved_to IN('.implode(',',$topics).')') or error('Unable to delete redirect topics', __FILE__, __LINE__, $db->error()); | 305: $db->query('DELETE FROM '.$db->prefix.'topics WHERE forum_id='.$move_to_forum.' AND moved_to IN('.implode(',',$topics).')') or error('Unable to delete redirect topics', __FILE__, __LINE__, $db->error()); |
| 294: | 306: |
| 400: { | 412: { |
| 401: confirm_referrer('moderate.php'); | 413: confirm_referrer('moderate.php'); |
| 402: | 414: |
| 403: if (preg_match('/[^0-9,]/', $topics)) | 415: if (@preg_match('/[^0-9,]/', $topics)) |
| 404: message($lang_common['Bad request']); | 416: message($lang_common['Bad request']); |
| 405: | 417: |
| 406: require PUN_ROOT.'include/search_idx.php'; | 418: require PUN_ROOT.'include/search_idx.php'; |
| 407: | 419: |
| | 420: // Verify that the topic IDs are valid |
| | 421: $result = $db->query('SELECT 1 FROM '.$db->prefix.'topics WHERE id IN('.$topics.') AND forum_id='.$fid) or error('Unable to check topics', __FILE__, __LINE__, $db->error()); |
| | 422: |
| | 423: if ($db->num_rows($result) != substr_count($topics, ',') + 1) |
| | 424: message($lang_common['Bad request']); |
| | 425: |
| 408: // Delete the topics and any redirect topics | 426: // Delete the topics and any redirect topics |
| 409: $db->query('DELETE FROM '.$db->prefix.'topics WHERE id IN('.$topics.') OR moved_to IN('.$topics.')') or error('Unable to delete topic', __FILE__, __LINE__, $db->error()); | 427: $db->query('DELETE FROM '.$db->prefix.'topics WHERE id IN('.$topics.') OR moved_to IN('.$topics.')') or error('Unable to delete topic', __FILE__, __LINE__, $db->error()); |
| 410: | 428: |
| 472: if (empty($topics)) | 490: if (empty($topics)) |
| 473: message($lang_misc['No topics selected']); | 491: message($lang_misc['No topics selected']); |
| 474: | 492: |
| 475: $db->query('UPDATE '.$db->prefix.'topics SET closed='.$action.' WHERE id IN('.implode(',', $topics).')') or error('Unable to close topics', __FILE__, __LINE__, $db->error()); | 493: $db->query('UPDATE '.$db->prefix.'topics SET closed='.$action.' WHERE id IN('.implode(',', $topics).') AND forum_id='.$fid) or error('Unable to close topics', __FILE__, __LINE__, $db->error()); |
| 476: | 494: |
| 477: $redirect_msg = ($action) ? $lang_misc['Close topics redirect'] : $lang_misc['Open topics redirect']; | 495: $redirect_msg = ($action) ? $lang_misc['Close topics redirect'] : $lang_misc['Open topics redirect']; |
| 478: redirect('moderate.php?fid='.$fid, $redirect_msg); | 496: redirect('moderate.php?fid='.$fid, $redirect_msg); |
| 486: if ($topic_id < 1) | 504: if ($topic_id < 1) |
| 487: message($lang_common['Bad request']); | 505: message($lang_common['Bad request']); |
| 488: | 506: |
| 489: $db->query('UPDATE '.$db->prefix.'topics SET closed='.$action.' WHERE id='.$topic_id) or error('Unable to close topic', __FILE__, __LINE__, $db->error()); | 507: $db->query('UPDATE '.$db->prefix.'topics SET closed='.$action.' WHERE id='.$topic_id.' AND forum_id='.$fid) or error('Unable to close topic', __FILE__, __LINE__, $db->error()); |
| 490: | 508: |
| 491: $redirect_msg = ($action) ? $lang_misc['Close topic redirect'] : $lang_misc['Open topic redirect']; | 509: $redirect_msg = ($action) ? $lang_misc['Close topic redirect'] : $lang_misc['Open topic redirect']; |
| 492: redirect('viewtopic.php?id='.$topic_id, $redirect_msg); | 510: redirect('viewtopic.php?id='.$topic_id, $redirect_msg); |
| 503: if ($stick < 1) | 521: if ($stick < 1) |
| 504: message($lang_common['Bad request']); | 522: message($lang_common['Bad request']); |
| 505: | 523: |
| 506: $db->query('UPDATE '.$db->prefix.'topics SET sticky=\'1\' WHERE id='.$stick) or error('Unable to stick topic', __FILE__, __LINE__, $db->error()); | 524: $db->query('UPDATE '.$db->prefix.'topics SET sticky=\'1\' WHERE id='.$stick.' AND forum_id='.$fid) or error('Unable to stick topic', __FILE__, __LINE__, $db->error()); |
| 507: | 525: |
| 508: redirect('viewtopic.php?id='.$stick, $lang_misc['Stick topic redirect']); | 526: redirect('viewtopic.php?id='.$stick, $lang_misc['Stick topic redirect']); |
| 509: } | 527: } |
| 518: if ($unstick < 1) | 536: if ($unstick < 1) |
| 519: message($lang_common['Bad request']); | 537: message($lang_common['Bad request']); |
| 520: | 538: |
| 521: $db->query('UPDATE '.$db->prefix.'topics SET sticky=\'0\' WHERE id='.$unstick) or error('Unable to unstick topic', __FILE__, __LINE__, $db->error()); | 539: $db->query('UPDATE '.$db->prefix.'topics SET sticky=\'0\' WHERE id='.$unstick.' AND forum_id='.$fid) or error('Unable to unstick topic', __FILE__, __LINE__, $db->error()); |
| 522: | 540: |
| 523: redirect('viewtopic.php?id='.$unstick, $lang_misc['Unstick topic redirect']); | 541: redirect('viewtopic.php?id='.$unstick, $lang_misc['Unstick topic redirect']); |
| 524: } | 542: } |
| punbb-1.2.6/upload/post.php |
punbb-1.2.16/upload/post.php |
| 128: $errors[] = $lang_register['Username censor']; | 128: $errors[] = $lang_register['Username censor']; |
| 129: | 129: |
| 130: // Check that the username (or a too similar username) is not already registered | 130: // Check that the username (or a too similar username) is not already registered |
| 131: $result = $db->query('SELECT username FROM '.$db->prefix.'users WHERE username=\''.$db->escape($username).'\' OR username=\''.$db->escape(preg_replace('/[^\w]/', '', $username)).'\'') or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); | 131: $result = $db->query('SELECT username FROM '.$db->prefix.'users WHERE (username=\''.$db->escape($username).'\' OR username=\''.$db->escape(preg_replace('/[^\w]/', '', $username)).'\') AND id>1') or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); |
| 132: if ($db->num_rows($result)) | 132: if ($db->num_rows($result)) |
| 133: { | 133: { |
| 134: $busy = $db->result($result); | 134: $busy = $db->result($result); |
| 338: if ($qid < 1) | 338: if ($qid < 1) |
| 339: message($lang_common['Bad request']); | 339: message($lang_common['Bad request']); |
| 340: | 340: |
| 341: $result = $db->query('SELECT poster, message FROM '.$db->prefix.'posts WHERE id='.$qid) or error('Unable to fetch quote info', __FILE__, __LINE__, $db->error()); | 341: $result = $db->query('SELECT poster, message FROM '.$db->prefix.'posts WHERE id='.$qid.' AND topic_id='.$tid) or error('Unable to fetch quote info', __FILE__, __LINE__, $db->error()); |
| 342: if (!$db->num_rows($result)) | 342: if (!$db->num_rows($result)) |
| 343: message($lang_common['Bad request']); | 343: message($lang_common['Bad request']); |
| 344: | 344: |
| 440: else if (isset($_POST['preview'])) | 440: else if (isset($_POST['preview'])) |
| 441: { | 441: { |
| 442: require_once PUN_ROOT.'include/parser.php'; | 442: require_once PUN_ROOT.'include/parser.php'; |
| 443: $message = parse_message($message, $hide_smilies); | 443: $preview_message = parse_message($message, $hide_smilies); |
| 444: | 444: |
| 445: ?> | 445: ?> |
| 446: <div id="postpreview" class="blockpost"> | 446: <div id="postpreview" class="blockpost"> |
| 449: <div class="inbox"> | 449: <div class="inbox"> |
| 450: <div class="postright"> | 450: <div class="postright"> |
| 451: <div class="postmsg"> | 451: <div class="postmsg"> |
| 452: <?php echo $message."\n" ?> | 452: <?php echo $preview_message."\n" ?> |
| 453: </div> | 453: </div> |
| 454: </div> | 454: </div> |
| 455: </div> | 455: </div> |
| 491: if ($fid): ?> | 491: if ($fid): ?> |
| 492: <label><strong><?php echo $lang_common['Subject'] ?></strong><br /><input class="longinput" type="text" name="req_subject" value="<?php if (isset($_POST['req_subject'])) echo pun_htmlspecialchars($subject); ?>" size="80" maxlength="70" tabindex="<?php echo $cur_index++ ?>" /><br /></label> | 492: <label><strong><?php echo $lang_common['Subject'] ?></strong><br /><input class="longinput" type="text" name="req_subject" value="<?php if (isset($_POST['req_subject'])) echo pun_htmlspecialchars($subject); ?>" size="80" maxlength="70" tabindex="<?php echo $cur_index++ ?>" /><br /></label> |
| 493: <?php endif; ?> <label><strong><?php echo $lang_common['Message'] ?></strong><br /> | 493: <?php endif; ?> <label><strong><?php echo $lang_common['Message'] ?></strong><br /> |
| 494: <textarea name="req_message" rows="20" cols="95" tabindex="<?php echo $cur_index++ ?>"><?php echo isset($_POST['req_message']) ? pun_htmlspecialchars(trim($_POST['req_message'])) : (isset($quote) ? $quote : ''); ?></textarea><br /></label> | 494: <textarea name="req_message" rows="20" cols="95" tabindex="<?php echo $cur_index++ ?>"><?php echo isset($_POST['req_message']) ? pun_htmlspecialchars($message) : (isset($quote) ? $quote : ''); ?></textarea><br /></label> |
| 495: <ul class="bblinks"> | 495: <ul class="bblinks"> |
| 496: <li><a href="help.php#bbcode" onclick="window.open(this.href); return false;"><?php echo $lang_common['BBCode'] ?></a>: <?php echo ($pun_config['p_message_bbcode'] == '1') ? $lang_common['on'] : $lang_common['off']; ?></li> | 496: <li><a href="help.php#bbcode" onclick="window.open(this.href); return false;"><?php echo $lang_common['BBCode'] ?></a>: <?php echo ($pun_config['p_message_bbcode'] == '1') ? $lang_common['on'] : $lang_common['off']; ?></li> |
| 497: <li><a href="help.php#img" onclick="window.open(this.href); return false;"><?php echo $lang_common['img tag'] ?></a>: <?php echo ($pun_config['p_message_img_tag'] == '1') ? $lang_common['on'] : $lang_common['off']; ?></li> | 497: <li><a href="help.php#img" onclick="window.open(this.href); return false;"><?php echo $lang_common['img tag'] ?></a>: <?php echo ($pun_config['p_message_img_tag'] == '1') ? $lang_common['on'] : $lang_common['off']; ?></li> |
| punbb-1.2.6/upload/profile.php |
punbb-1.2.16/upload/profile.php |
| 87: | 87: |
| 88: if (isset($_POST['form_sent'])) | 88: if (isset($_POST['form_sent'])) |
| 89: { | 89: { |
| | 90: if ($pun_user['g_id'] < PUN_GUEST) |
| | 91: confirm_referrer('profile.php'); |
| | 92: |
| 90: $old_password = isset($_POST['req_old_password']) ? trim($_POST['req_old_password']) : ''; | 93: $old_password = isset($_POST['req_old_password']) ? trim($_POST['req_old_password']) : ''; |
| 91: $new_password1 = trim($_POST['req_new_password1']); | 94: $new_password1 = trim($_POST['req_new_password1']); |
| 92: $new_password2 = trim($_POST['req_new_password2']); | 95: $new_password2 = trim($_POST['req_new_password2']); |
| 190: $result = $db->query('SELECT activate_string, activate_key FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to fetch activation data', __FILE__, __LINE__, $db->error()); | 193: $result = $db->query('SELECT activate_string, activate_key FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to fetch activation data', __FILE__, __LINE__, $db->error()); |
| 191: list($new_email, $new_email_key) = $db->fetch_row($result); | 194: list($new_email, $new_email_key) = $db->fetch_row($result); |
| 192: | 195: |
| 193: if ($key != $new_email_key) | 196: if ($key == '' || $key != $new_email_key) |
| 194: message($lang_profile['E-mail key bad'].' <a href="mailto:'.$pun_config['o_admin_email'].'">'.$pun_config['o_admin_email'].'</a>.'); | 197: message($lang_profile['E-mail key bad'].' <a href="mailto:'.$pun_config['o_admin_email'].'">'.$pun_config['o_admin_email'].'</a>.'); |
| 195: else | 198: else |
| 196: { | 199: { |
| 201: } | 204: } |
| 202: else if (isset($_POST['form_sent'])) | 205: else if (isset($_POST['form_sent'])) |
| 203: { | 206: { |
| | 207: if (pun_hash($_POST['req_password']) !== $pun_user['password']) |
| | 208: message($lang_profile['Wrong pass']); |
| | 209: |
| 204: require PUN_ROOT.'include/email.php'; | 210: require PUN_ROOT.'include/email.php'; |
| 205: | 211: |
| 206: // Validate the email-address | 212: // Validate the email-address |
| 264: } | 270: } |
| 265: | 271: |
| 266: $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_common['Profile']; | 272: $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_common['Profile']; |
| 267: $required_fields = array('req_new_email' => $lang_profile['New e-mail']); | 273: $required_fields = array('req_new_email' => $lang_profile['New e-mail'], 'req_password' => $lang_common['Password']); |
| 268: $focus_element = array('change_email', 'req_new_email'); | 274: $focus_element = array('change_email', 'req_new_email'); |
| 269: require PUN_ROOT.'header.php'; | 275: require PUN_ROOT.'header.php'; |
| 270: | 276: |
| 279: <div class="infldset"> | 285: <div class="infldset"> |
| 280: <input type="hidden" name="form_sent" value="1" /> | 286: <input type="hidden" name="form_sent" value="1" /> |
| 281: <label><strong><?php echo $lang_profile['New e-mail'] ?></strong><br /><input type="text" name="req_new_email" size="50" maxlength="50" /><br /></label> | 287: <label><strong><?php echo $lang_profile['New e-mail'] ?></strong><br /><input type="text" name="req_new_email" size="50" maxlength="50" /><br /></label> |
| | 288: <label><strong><?php echo $lang_common['Password'] ?></strong><br /><input type="password" name="req_password" size="16" maxlength="16" /><br /></label> |
| 282: <p><?php echo $lang_profile['E-mail instructions'] ?></p> | 289: <p><?php echo $lang_profile['E-mail instructions'] ?></p> |
| 283: </div> | 290: </div> |
| 284: </fieldset> | 291: </fieldset> |
| 362: message($lang_profile['Move failed'].' <a href="mailto:'.$pun_config['o_admin_email'].'">'.$pun_config['o_admin_email'].'</a>.'); | 369: message($lang_profile['Move failed'].' <a href="mailto:'.$pun_config['o_admin_email'].'">'.$pun_config['o_admin_email'].'</a>.'); |
| 363: | 370: |
| 364: // Now check the width/height | 371: // Now check the width/height |
| 365: list($width, $height, ,) = getimagesize($pun_config['o_avatars_dir'].'/'.$id.'.tmp'); | 372: list($width, $height, $type,) = getimagesize($pun_config['o_avatars_dir'].'/'.$id.'.tmp'); |
| 366: if (empty($width) || empty($height) || $width > $pun_config['o_avatars_width'] || $height > $pun_config['o_avatars_height']) | 373: if (empty($width) || empty($height) || $width > $pun_config['o_avatars_width'] || $height > $pun_config['o_avatars_height']) |
| 367: { | 374: { |
| 368: @unlink($pun_config['o_avatars_dir'].'/'.$id.'.tmp'); | 375: @unlink($pun_config['o_avatars_dir'].'/'.$id.'.tmp'); |
| 369: message($lang_profile['Too wide or high'].' '.$pun_config['o_avatars_width'].'x'.$pun_config['o_avatars_height'].' '.$lang_profile['pixels'].'.'); | 376: message($lang_profile['Too wide or high'].' '.$pun_config['o_avatars_width'].'x'.$pun_config['o_avatars_height'].' '.$lang_profile['pixels'].'.'); |
| 370: } | 377: } |
| | 378: else if ($type == 1 && $uploaded_file['type'] != 'image/gif') // Prevent dodgy uploads |
| | 379: { |
| | 380: @unlink($pun_config['o_avatars_dir'].'/'.$id.'.tmp'); |
| | 381: message($lang_profile['Bad type']); |
| | 382: } |
| 371: | 383: |
| 372: // Delete any old avatars and put the new one in place | 384: // Delete any old avatars and put the new one in place |
| 373: @unlink($pun_config['o_avatars_dir'].'/'.$id.$extensions[0]); | 385: @unlink($pun_config['o_avatars_dir'].'/'.$id.$extensions[0]); |
| 710: message($lang_common['Invalid e-mail']); | 722: message($lang_common['Invalid e-mail']); |
| 711: } | 723: } |
| 712: | 724: |
| | 725: // Make sure we got a valid language string |
| | 726: if (isset($form['language'])) |
| | 727: { |
| | 728: $form['language'] = preg_replace('#[\.\\\/]#', '', $form['language']); |
| | 729: if (!file_exists(PUN_ROOT.'lang/'.$form['language'].'/common.php')) |
| | 730: message($lang_common['Bad request']); |
| | 731: } |
| | 732: |
| 713: break; | 733: break; |
| 714: } | 734: } |
| 715: | 735: |
| 735: } | 755: } |
| 736: | 756: |
| 737: // Add http:// if the URL doesn't contain it already | 757: // Add http:// if the URL doesn't contain it already |
| 738: if ($form['url'] != '' && !stristr($form['url'], 'http://')) | 758: if ($form['url'] != '' && strpos(strtolower($form['url']), 'http://') !== 0) |
| 739: $form['url'] = 'http://'.$form['url']; | 759: $form['url'] = 'http://'.$form['url']; |
| 740: | 760: |
| 741: break; | 761: break; |
| 746: $form = extract_elements(array('jabber', 'icq', 'msn', 'aim', 'yahoo')); | 766: $form = extract_elements(array('jabber', 'icq', 'msn', 'aim', 'yahoo')); |
| 747: | 767: |
| 748: // If the ICQ UIN contains anything other than digits it's invalid | 768: // If the ICQ UIN contains anything other than digits it's invalid |
| 749: if ($form['icq'] != '' && preg_match('/[^0-9]/', $form['icq'])) | 769: if ($form['icq'] != '' && @preg_match('/[^0-9]/', $form['icq'])) |
| 750: message($lang_prof_reg['Bad ICQ']); | 770: message($lang_prof_reg['Bad ICQ']); |
| 751: | 771: |
| 752: break; | 772: break; |
| punbb-1.2.6/upload/search.php |
punbb-1.2.16/upload/search.php |
| 51: $action = (isset($_GET['action'])) ? $_GET['action'] : null; | 51: $action = (isset($_GET['action'])) ? $_GET['action'] : null; |
| 52: $forum = (isset($_GET['forum'])) ? intval($_GET['forum']) : -1; | 52: $forum = (isset($_GET['forum'])) ? intval($_GET['forum']) : -1; |
| 53: $sort_dir = (isset($_GET['sort_dir'])) ? (($_GET['sort_dir'] == 'DESC') ? 'DESC' : 'ASC') : 'DESC'; | 53: $sort_dir = (isset($_GET['sort_dir'])) ? (($_GET['sort_dir'] == 'DESC') ? 'DESC' : 'ASC') : 'DESC'; |
| | 54: if (isset($search_id)) unset($search_id); |
| 54: | 55: |
| 55: // If a search_id was supplied | 56: // If a search_id was supplied |
| 56: if (isset($_GET['search_id'])) | 57: if (isset($_GET['search_id'])) |
| 121: $keyword_results = $author_results = array(); | 122: $keyword_results = $author_results = array(); |
| 122: | 123: |
| 123: // Search a specific forum? | 124: // Search a specific forum? |
| 124: $forum_sql = ($forum != -1) ? ' AND t.forum_id = '.$forum : ''; | 125: $forum_sql = ($forum != -1 || ($forum == -1 && $pun_config['o_search_all_forums'] == '0')) ? ' AND t.forum_id = '.$forum : ''; |
| 125: | 126: |
| 126: if (!empty($author) || !empty($keywords)) | 127: if (!empty($author) || !empty($keywords)) |
| 127: { | 128: { |
| 169: | 170: |
| 170: $word_count = 0; | 171: $word_count = 0; |
| 171: $match_type = 'and'; | 172: $match_type = 'and'; |
| | 173: $result_list = array(); |
| 172: @reset($keywords_array); | 174: @reset($keywords_array); |
| 173: while (list(, $cur_word) = @each($keywords_array)) | 175: while (list(, $cur_word) = @each($keywords_array)) |
| 174: { | 176: { |
| 324: if ($pun_user['is_guest']) | 326: if ($pun_user['is_guest']) |
| 325: message($lang_common['No permission']); | 327: message($lang_common['No permission']); |
| 326: | 328: |
| 327: $result = $db->query('SELECT t.id FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.last_post>'.$pun_user['last_visit']) or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error()); | 329: $result = $db->query('SELECT t.id FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.last_post>'.$pun_user['last_visit'].' AND t.moved_to IS NULL') or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error()); |
| 328: $num_hits = $db->num_rows($result); | 330: $num_hits = $db->num_rows($result); |
| 329: | 331: |
| 330: if (!$num_hits) | 332: if (!$num_hits) |
| 333: // If it's a search for todays posts | 335: // If it's a search for todays posts |
| 334: else if ($action == 'show_24h') | 336: else if ($action == 'show_24h') |
| 335: { | 337: { |
| 336: $result = $db->query('SELECT t.id FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.last_post>'.(time() - 86400)) or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error()); | 338: $result = $db->query('SELECT t.id FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.last_post>'.(time() - 86400).' AND t.moved_to IS NULL') or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error()); |
| 337: $num_hits = $db->num_rows($result); | 339: $num_hits = $db->num_rows($result); |
| 338: | 340: |
| 339: if (!$num_hits) | 341: if (!$num_hits) |
| 386: | 388: |
| 387: | 389: |
| 388: // Prune "old" search results | 390: // Prune "old" search results |
| | 391: $old_searches = array(); |
| 389: $result = $db->query('SELECT ident FROM '.$db->prefix.'online') or error('Unable to fetch online list', __FILE__, __LINE__, $db->error()); | 392: $result = $db->query('SELECT ident FROM '.$db->prefix.'online') or error('Unable to fetch online list', __FILE__, __LINE__, $db->error()); |
| 390: | 393: |
| 391: if ($db->num_rows($result)) | 394: if ($db->num_rows($result)) |
| 427: // Fetch results to display | 430: // Fetch results to display |
| 428: if ($search_results != '') | 431: if ($search_results != '') |
| 429: { | 432: { |
| 430: $group_by_sql = ''; | |
| 431: switch ($sort_by) | 433: switch ($sort_by) |
| 432: { | 434: { |
| 433: case 1: | 435: case 1: |
| 447: break; | 449: break; |
| 448: | 450: |
| 449: default: | 451: default: |
| 450: { | |
| 451: $sort_by_sql = ($show_as == 'topics') ? 't.posted' : 'p.posted'; | 452: $sort_by_sql = ($show_as == 'topics') ? 't.posted' : 'p.posted'; |
| 452: | |
| 453: if ($show_as == 'topics') | |
| 454: $group_by_sql = ', t.posted'; | |
| 455: | |
| 456: break; | 453: break; |
| 457: } | |
| 458: } | 454: } |
| 459: | 455: |
| 460: if ($show_as == 'posts') | 456: if ($show_as == 'posts') |
| 463: $sql = 'SELECT p.id AS pid, p.poster AS pposter, p.posted AS pposted, p.poster_id, '.$substr_sql.'(p.message, 1, 1000) AS message, t.id AS tid, t.poster, t.subject, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.forum_id FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id WHERE p.id IN('.$search_results.') ORDER BY '.$sort_by_sql; | 459: $sql = 'SELECT p.id AS pid, p.poster AS pposter, p.posted AS pposted, p.poster_id, '.$substr_sql.'(p.message, 1, 1000) AS message, t.id AS tid, t.poster, t.subject, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.forum_id FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id WHERE p.id IN('.$search_results.') ORDER BY '.$sort_by_sql; |
| 464: } | 460: } |
| 465: else | 461: else |
| 466: $sql = 'SELECT t.id AS tid, t.poster, t.subject, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.closed, t.forum_id FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id WHERE t.id IN('.$search_results.') GROUP BY t.id, t.poster, t.subject, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.closed, t.forum_id'.$group_by_sql.' ORDER BY '.$sort_by_sql; | 462: $sql = 'SELECT t.id AS tid, t.poster, t.subject, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.closed, t.forum_id FROM '.$db->prefix.'topics AS t WHERE t.id IN('.$search_results.') ORDER BY '.$sort_by_sql; |
| 467: | 463: |
| 468: | 464: |
| 469: // Determine the topic or post offset (based on $_GET['p']) | 465: // Determine the topic or post offset (based on $_GET['p']) |