punbb-1.2.13/upload/admin_forums.php |
punbb-1.2.15/upload/admin_forums.php |
137: | 137: |
138: while (list($forum_id, $disp_position) = @each($_POST['position'])) | 138: while (list($forum_id, $disp_position) = @each($_POST['position'])) |
139: { | 139: { |
140: if (!preg_match('#^\d+$#', $disp_position)) | 140: if (!@preg_match('#^\d+$#', $disp_position)) |
141: message('Position must be a positive integer value.'); | 141: message('Position must be a positive integer value.'); |
142: | 142: |
143: $db->query('UPDATE '.$db->prefix.'forums SET disp_position='.$disp_position.' WHERE id='.$forum_id) or error('Unable to update forum', __FILE__, __LINE__, $db->error()); | 143: $db->query('UPDATE '.$db->prefix.'forums SET disp_position='.$disp_position.' WHERE id='.intval($forum_id)) or error('Unable to update forum', __FILE__, __LINE__, $db->error()); |
144: } | 144: } |
145: | 145: |
146: // Regenerate the quickjump cache | 146: // Regenerate the quickjump cache |
186: $result = $db->query('SELECT g_id, g_read_board, g_post_replies, g_post_topics FROM '.$db->prefix.'groups WHERE g_id!='.PUN_ADMIN) or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error()); | 186: $result = $db->query('SELECT g_id, g_read_board, g_post_replies, g_post_topics FROM '.$db->prefix.'groups WHERE g_id!='.PUN_ADMIN) or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error()); |
187: while ($cur_group = $db->fetch_assoc($result)) | 187: while ($cur_group = $db->fetch_assoc($result)) |
188: { | 188: { |
189: $read_forum_new = ($cur_group['g_read_board'] == '1') ? isset($_POST['read_forum_new'][$cur_group['g_id']]) ? $_POST['read_forum_new'][$cur_group['g_id']] : '0' : $_POST['read_forum_old'][$cur_group['g_id']]; | 189: $read_forum_new = ($cur_group['g_read_board'] == '1') ? isset($_POST['read_forum_new'][$cur_group['g_id']]) ? '1' : '0' : intval($_POST['read_forum_old'][$cur_group['g_id']]); |
190: $post_replies_new = isset($_POST['post_replies_new'][$cur_group['g_id']]) ? $_POST['post_replies_new'][$cur_group['g_id']] : '0'; | 190: $post_replies_new = isset($_POST['post_replies_new'][$cur_group['g_id']]) ? '1' : '0'; |
191: $post_topics_new = isset($_POST['post_topics_new'][$cur_group['g_id']]) ? $_POST['post_topics_new'][$cur_group['g_id']] : '0'; | 191: $post_topics_new = isset($_POST['post_topics_new'][$cur_group['g_id']]) ? '1' : '0'; |
192: | 192: |
193: // Check if the new settings differ from the old | 193: // Check if the new settings differ from the old |
194: if ($read_forum_new != $_POST['read_forum_old'][$cur_group['g_id']] || $post_replies_new != $_POST['post_replies_old'][$cur_group['g_id']] || $post_topics_new != $_POST['post_topics_old'][$cur_group['g_id']]) | 194: if ($read_forum_new != $_POST['read_forum_old'][$cur_group['g_id']] || $post_replies_new != $_POST['post_replies_old'][$cur_group['g_id']] || $post_topics_new != $_POST['post_topics_old'][$cur_group['g_id']]) |
punbb-1.2.13/upload/admin_users.php |
punbb-1.2.15/upload/admin_users.php |
111: { | 111: { |
112: $ip = $_GET['show_users']; | 112: $ip = $_GET['show_users']; |
113: | 113: |
114: if (!preg_match('/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/', $ip)) | 114: if (!@preg_match('/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/', $ip)) |
115: message('The supplied IP address is not correctly formatted.'); | 115: message('The supplied IP address is not correctly formatted.'); |
116: | 116: |
117: | 117: |
257: $like_command = ($db_type == 'pgsql') ? 'ILIKE' : 'LIKE'; | 257: $like_command = ($db_type == 'pgsql') ? 'ILIKE' : 'LIKE'; |
258: while (list($key, $input) = @each($form)) | 258: while (list($key, $input) = @each($form)) |
259: { | 259: { |
260: if ($input != '') | 260: if ($input != '' && in_array($key, array('username', 'email', 'title', 'realname', 'url', 'jabber', 'icq', 'msn', 'aim', 'yahoo', 'location', 'signature', 'admin_note'))) |
261: $conditions[] = 'u.'.$db->escape($key).' '.$like_command.' \''.$db->escape(str_replace('*', '%', $input)).'\''; | 261: $conditions[] = 'u.'.$db->escape($key).' '.$like_command.' \''.$db->escape(str_replace('*', '%', $input)).'\''; |
262: } | 262: } |
263: | 263: |
267: $conditions[] = 'u.num_posts<'.$posts_less; | 267: $conditions[] = 'u.num_posts<'.$posts_less; |
268: | 268: |
269: if ($user_group != 'all') | 269: if ($user_group != 'all') |
270: $conditions[] = 'u.group_id='.$db->escape($user_group); | 270: $conditions[] = 'u.group_id='.intval($user_group); |
271: | 271: |
272: if (empty($conditions)) | 272: if (empty($conditions)) |
273: message('You didn\'t enter any search terms.'); | 273: message('You didn\'t enter any search terms.'); |
punbb-1.2.13/upload/include/functions.php |
punbb-1.2.15/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: |
752: $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')); |
753: | 783: |
754: | 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: |
755: // START SUBST - <pun_content_direction> | 800: // START SUBST - <pun_content_direction> |
756: $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); |
757: // END SUBST - <pun_content_direction> | 802: // END SUBST - <pun_content_direction> |
790: $db->end_transaction(); | 835: $db->end_transaction(); |
791: | 836: |
792: | 837: |
793: // START SUBST - <pun_include "*"> | |
794: while (preg_match('#<pun_include "([^/\\\\]*?)">#', $tpl_maint, $cur_include)) | |
795: { | |
796: if (!file_exists(PUN_ROOT.'include/user/'.$cur_include[1])) | |
797: 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/'); | |
798: | |
799: ob_start(); | |
800: include PUN_ROOT.'include/user/'.$cur_include[1]; | |
801: $tpl_temp = ob_get_contents(); | |
802: $tpl_maint = str_replace($cur_include[0], $tpl_temp, $tpl_maint); | |
803: ob_end_clean(); | |
804: } | |
805: // END SUBST - <pun_include "*"> | |
806: | |
807: | |
808: // Close the db connection (and free up any result data) | 838: // Close the db connection (and free up any result data) |
809: $db->close(); | 839: $db->close(); |
810: | 840: |
831: $tpl_redir = trim(file_get_contents(PUN_ROOT.'include/template/redirect.tpl')); | 861: $tpl_redir = trim(file_get_contents(PUN_ROOT.'include/template/redirect.tpl')); |
832: | 862: |
833: | 863: |
| 864: // START SUBST - <pun_include "*"> |
| 865: while (preg_match('#<pun_include "([^/\\\\]*?)\.(php[45]?|inc|html?|txt)">#', $tpl_redir, $cur_include)) |
| 866: { |
| 867: if (!file_exists(PUN_ROOT.'include/user/'.$cur_include[1].'.'.$cur_include[2])) |
| 868: error('Unable to process user include '.htmlspecialchars($cur_include[0]).' from template redirect.tpl. There is no such file in folder /include/user/'); |
| 869: |
| 870: ob_start(); |
| 871: include PUN_ROOT.'include/user/'.$cur_include[1].'.'.$cur_include[2]; |
| 872: $tpl_temp = ob_get_contents(); |
| 873: $tpl_redir = str_replace($cur_include[0], $tpl_temp, $tpl_redir); |
| 874: ob_end_clean(); |
| 875: } |
| 876: // END SUBST - <pun_include "*"> |
| 877: |
| 878: |
834: // START SUBST - <pun_content_direction> | 879: // START SUBST - <pun_content_direction> |
835: $tpl_redir = str_replace('<pun_content_direction>', $lang_common['lang_direction'], $tpl_redir); | 880: $tpl_redir = str_replace('<pun_content_direction>', $lang_common['lang_direction'], $tpl_redir); |
836: // END SUBST - <pun_content_direction> | 881: // END SUBST - <pun_content_direction> |
883: // END SUBST - <pun_footer> | 928: // END SUBST - <pun_footer> |
884: | 929: |
885: | 930: |
886: // START SUBST - <pun_include "*"> | |
887: while (preg_match('#<pun_include "([^/\\\\]*?)">#', $tpl_redir, $cur_include)) | |
888: { | |
889: if (!file_exists(PUN_ROOT.'include/user/'.$cur_include[1])) | |
890: 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/'); | |
891: | |
892: ob_start(); | |
893: include PUN_ROOT.'include/user/'.$cur_include[1]; | |
894: $tpl_temp = ob_get_contents(); | |
895: $tpl_redir = str_replace($cur_include[0], $tpl_temp, $tpl_redir); | |
896: ob_end_clean(); | |
897: } | |
898: // END SUBST - <pun_include "*"> | |
899: | |
900: | |
901: // Close the db connection (and free up any result data) | 931: // Close the db connection (and free up any result data) |
902: $db->close(); | 932: $db->close(); |
903: | 933: |
925: | 955: |
926: ?> | 956: ?> |
927: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | 957: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
928: <html dir="ltr"> | 958: <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr"> |
929: <head> | 959: <head> |
930: <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> | 960: <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> |
931: <title><?php echo pun_htmlspecialchars($pun_config['o_board_title']) ?> / Error</title> | 961: <title><?php echo pun_htmlspecialchars($pun_config['o_board_title']) ?> / Error</title> |
1036: // | 1066: // |
1037: function unregister_globals() | 1067: function unregister_globals() |
1038: { | 1068: { |
| 1069: $register_globals = @ini_get('register_globals'); |
| 1070: if ($register_globals === "" || $register_globals === "0" || strtolower($register_globals === "off")) |
| 1071: return; |
| 1072: |
1039: // Prevent script.php?GLOBALS[foo]=bar | 1073: // Prevent script.php?GLOBALS[foo]=bar |
1040: if (isset($_REQUEST['GLOBALS']) || isset($_FILES['GLOBALS'])) | 1074: if (isset($_REQUEST['GLOBALS']) || isset($_FILES['GLOBALS'])) |
1041: exit('I\'ll have a steak sandwich and... a steak sandwich.'); | 1075: exit('I\'ll have a steak sandwich and... a steak sandwich.'); |
1048: foreach ($input as $k => $v) | 1082: foreach ($input as $k => $v) |
1049: { | 1083: { |
1050: if (!in_array($k, $no_unset) && isset($GLOBALS[$k])) | 1084: if (!in_array($k, $no_unset) && isset($GLOBALS[$k])) |
| 1085: { |
1051: unset($GLOBALS[$k]); | 1086: unset($GLOBALS[$k]); |
| 1087: unset($GLOBALS[$k]); // Double unset to circumvent the zend_hash_del_key_or_index hole in PHP <4.4.3 and <5.1.4 |
| 1088: } |
1052: } | 1089: } |
1053: } | 1090: } |
1054: | 1091: |
punbb-1.2.13/upload/install.php |
punbb-1.2.15/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.13'; | 27: $punbb_version = '1.2.15'; |
28: | 28: |
29: | 29: |
30: define('PUN_ROOT', './'); | 30: define('PUN_ROOT', './'); |
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.13/upload/moderate.php |
punbb-1.2.15/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.13/upload/profile.php |
punbb-1.2.15/upload/profile.php |
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()); | 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()); |
191: list($new_email, $new_email_key) = $db->fetch_row($result); | 191: list($new_email, $new_email_key) = $db->fetch_row($result); |
192: | 192: |
193: if ($key != $new_email_key) | 193: 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>.'); | 194: message($lang_profile['E-mail key bad'].' <a href="mailto:'.$pun_config['o_admin_email'].'">'.$pun_config['o_admin_email'].'</a>.'); |
195: else | 195: else |
196: { | 196: { |
752: } | 752: } |
753: | 753: |
754: // Add http:// if the URL doesn't contain it already | 754: // Add http:// if the URL doesn't contain it already |
755: if ($form['url'] != '' && !stristr($form['url'], 'http://')) | 755: if ($form['url'] != '' && strpos(strtolower($form['url']), 'http://') !== 0) |
756: $form['url'] = 'http://'.$form['url']; | 756: $form['url'] = 'http://'.$form['url']; |
757: | 757: |
758: break; | 758: break; |
763: $form = extract_elements(array('jabber', 'icq', 'msn', 'aim', 'yahoo')); | 763: $form = extract_elements(array('jabber', 'icq', 'msn', 'aim', 'yahoo')); |
764: | 764: |
765: // If the ICQ UIN contains anything other than digits it's invalid | 765: // If the ICQ UIN contains anything other than digits it's invalid |
766: if ($form['icq'] != '' && preg_match('/[^0-9]/', $form['icq'])) | 766: if ($form['icq'] != '' && @preg_match('/[^0-9]/', $form['icq'])) |
767: message($lang_prof_reg['Bad ICQ']); | 767: message($lang_prof_reg['Bad ICQ']); |
768: | 768: |
769: break; | 769: break; |
punbb-1.2.13/upload/search.php |
punbb-1.2.15/upload/search.php |
122: $keyword_results = $author_results = array(); | 122: $keyword_results = $author_results = array(); |
123: | 123: |
124: // Search a specific forum? | 124: // Search a specific forum? |
125: $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 : ''; |
126: | 126: |
127: if (!empty($author) || !empty($keywords)) | 127: if (!empty($author) || !empty($keywords)) |
128: { | 128: { |
170: | 170: |
171: $word_count = 0; | 171: $word_count = 0; |
172: $match_type = 'and'; | 172: $match_type = 'and'; |
| 173: $result_list = array(); |
173: @reset($keywords_array); | 174: @reset($keywords_array); |
174: while (list(, $cur_word) = @each($keywords_array)) | 175: while (list(, $cur_word) = @each($keywords_array)) |
175: { | 176: { |
325: if ($pun_user['is_guest']) | 326: if ($pun_user['is_guest']) |
326: message($lang_common['No permission']); | 327: message($lang_common['No permission']); |
327: | 328: |
328: $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()); |
329: $num_hits = $db->num_rows($result); | 330: $num_hits = $db->num_rows($result); |
330: | 331: |
331: if (!$num_hits) | 332: if (!$num_hits) |
334: // If it's a search for todays posts | 335: // If it's a search for todays posts |
335: else if ($action == 'show_24h') | 336: else if ($action == 'show_24h') |
336: { | 337: { |
337: $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()); |
338: $num_hits = $db->num_rows($result); | 339: $num_hits = $db->num_rows($result); |
339: | 340: |
340: if (!$num_hits) | 341: if (!$num_hits) |
429: // Fetch results to display | 430: // Fetch results to display |
430: if ($search_results != '') | 431: if ($search_results != '') |
431: { | 432: { |
432: $group_by_sql = ''; | |
433: switch ($sort_by) | 433: switch ($sort_by) |
434: { | 434: { |
435: case 1: | 435: case 1: |
449: break; | 449: break; |
450: | 450: |
451: default: | 451: default: |
452: { | |
453: $sort_by_sql = ($show_as == 'topics') ? 't.posted' : 'p.posted'; | 452: $sort_by_sql = ($show_as == 'topics') ? 't.posted' : 'p.posted'; |
454: | |
455: if ($show_as == 'topics') | |
456: $group_by_sql = ', t.posted'; | |
457: | |
458: break; | 453: break; |
459: } | |
460: } | 454: } |
461: | 455: |
462: if ($show_as == 'posts') | 456: if ($show_as == 'posts') |
465: $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; |
466: } | 460: } |
467: else | 461: else |
468: $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; |
469: | 463: |
470: | 464: |
471: // Determine the topic or post offset (based on $_GET['p']) | 465: // Determine the topic or post offset (based on $_GET['p']) |