punbb-1.2.5/upload/admin_forums.php |
punbb-1.2.17/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']]) |
385: <?php | 385: <?php |
386: | 386: |
387: $result = $db->query('SELECT id, cat_name FROM '.$db->prefix.'categories ORDER BY disp_position') or error('Unable to fetch category list', __FILE__, __LINE__, $db->error()); | 387: $result = $db->query('SELECT id, cat_name FROM '.$db->prefix.'categories ORDER BY disp_position') or error('Unable to fetch category list', __FILE__, __LINE__, $db->error()); |
388: while ($cur_cat = $db->fetch_assoc($result)) | 388: if ($db->num_rows($result) > 0) |
389: echo "\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_cat['id'].'">'.pun_htmlspecialchars($cur_cat['cat_name']).'</option>'."\n"; | 389: { |
| 390: while ($cur_cat = $db->fetch_assoc($result)) |
| 391: echo "\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_cat['id'].'">'.pun_htmlspecialchars($cur_cat['cat_name']).'</option>'."\n"; |
| 392: } |
| 393: else |
| 394: echo "\t\t\t\t\t\t\t\t\t".'<option value="0" disabled="disabled">No categories exist</option>'."\n"; |
390: | 395: |
391: ?> | 396: ?> |
392: </select> | 397: </select> |
399: </div> | 404: </div> |
400: </form> | 405: </form> |
401: </div> | 406: </div> |
| 407: <?php |
| 408: |
| 409: // Display all the categories and forums |
| 410: $result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.disp_position FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id ORDER BY c.disp_position, c.id, f.disp_position') or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error()); |
| 411: |
| 412: if ($db->num_rows($result) > 0) |
| 413: { |
402: | 414: |
| 415: ?> |
403: <h2 class="block2"><span>Edit forums</span></h2> | 416: <h2 class="block2"><span>Edit forums</span></h2> |
404: <div class="box"> | 417: <div class="box"> |
405: <form id="edforum" method="post" action="admin_forums.php?action=edit"> | 418: <form id="edforum" method="post" action="admin_forums.php?action=edit"> |
408: | 421: |
409: $tabindex_count = 4; | 422: $tabindex_count = 4; |
410: | 423: |
411: // Display all the categories and forums | |
412: $result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.disp_position FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id ORDER BY c.disp_position, c.id, f.disp_position') or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error()); | |
413: | |
414: $cur_category = 0; | 424: $cur_category = 0; |
415: while ($cur_forum = $db->fetch_assoc($result)) | 425: while ($cur_forum = $db->fetch_assoc($result)) |
416: { | 426: { |
449: <p class="submitend"><input type="submit" name="update_positions" value="Update positions" tabindex="<?php echo $tabindex_count ?>" /></p> | 459: <p class="submitend"><input type="submit" name="update_positions" value="Update positions" tabindex="<?php echo $tabindex_count ?>" /></p> |
450: </form> | 460: </form> |
451: </div> | 461: </div> |
| 462: <?php |
| 463: |
| 464: } |
| 465: |
| 466: ?> |
452: </div> | 467: </div> |
453: <div class="clearer"></div> | 468: <div class="clearer"></div> |
454: </div> | 469: </div> |
punbb-1.2.5/upload/admin_groups.php |
punbb-1.2.17/upload/admin_groups.php |
209: | 209: |
210: $title = trim($_POST['req_title']); | 210: $title = trim($_POST['req_title']); |
211: $user_title = trim($_POST['user_title']); | 211: $user_title = trim($_POST['user_title']); |
212: $read_board = isset($_POST['read_board']) ? $_POST['read_board'] : '1'; | 212: $read_board = isset($_POST['read_board']) ? intval($_POST['read_board']) : '1'; |
213: $post_replies = isset($_POST['post_replies']) ? $_POST['post_replies'] : '1'; | 213: $post_replies = isset($_POST['post_replies']) ? intval($_POST['post_replies']) : '1'; |
214: $post_topics = isset($_POST['post_topics']) ? $_POST['post_topics'] : '1'; | 214: $post_topics = isset($_POST['post_topics']) ? intval($_POST['post_topics']) : '1'; |
215: $edit_posts = isset($_POST['edit_posts']) ? $_POST['edit_posts'] : ($is_admin_group) ? '1' : '0'; | 215: $edit_posts = isset($_POST['edit_posts']) ? intval($_POST['edit_posts']) : ($is_admin_group) ? '1' : '0'; |
216: $delete_posts = isset($_POST['delete_posts']) ? $_POST['delete_posts'] : ($is_admin_group) ? '1' : '0'; | 216: $delete_posts = isset($_POST['delete_posts']) ? intval($_POST['delete_posts']) : ($is_admin_group) ? '1' : '0'; |
217: $delete_topics = isset($_POST['delete_topics']) ? $_POST['delete_topics'] : ($is_admin_group) ? '1' : '0'; | 217: $delete_topics = isset($_POST['delete_topics']) ? intval($_POST['delete_topics']) : ($is_admin_group) ? '1' : '0'; |
218: $set_title = isset($_POST['set_title']) ? $_POST['set_title'] : ($is_admin_group) ? '1' : '0'; | 218: $set_title = isset($_POST['set_title']) ? intval($_POST['set_title']) : ($is_admin_group) ? '1' : '0'; |
219: $search = isset($_POST['search']) ? $_POST['search'] : '1'; | 219: $search = isset($_POST['search']) ? intval($_POST['search']) : '1'; |
220: $search_users = isset($_POST['search_users']) ? $_POST['search_users'] : '1'; | 220: $search_users = isset($_POST['search_users']) ? intval($_POST['search_users']) : '1'; |
221: $edit_subjects_interval = isset($_POST['edit_subjects_interval']) ? intval($_POST['edit_subjects_interval']) : '0'; | 221: $edit_subjects_interval = isset($_POST['edit_subjects_interval']) ? intval($_POST['edit_subjects_interval']) : '0'; |
222: $post_flood = isset($_POST['post_flood']) ? intval($_POST['post_flood']) : '0'; | 222: $post_flood = isset($_POST['post_flood']) ? intval($_POST['post_flood']) : '0'; |
223: $search_flood = isset($_POST['search_flood']) ? intval($_POST['search_flood']) : '0'; | 223: $search_flood = isset($_POST['search_flood']) ? intval($_POST['search_flood']) : '0'; |
243: } | 243: } |
244: else | 244: else |
245: { | 245: { |
246: $result = $db->query('SELECT 1 FROM '.$db->prefix.'groups WHERE g_title=\''.$db->escape($title).'\' AND g_id!='.$_POST['group_id']) or error('Unable to check group title collision', __FILE__, __LINE__, $db->error()); | 246: $result = $db->query('SELECT 1 FROM '.$db->prefix.'groups WHERE g_title=\''.$db->escape($title).'\' AND g_id!='.intval($_POST['group_id'])) or error('Unable to check group title collision', __FILE__, __LINE__, $db->error()); |
247: if ($db->num_rows($result)) | 247: if ($db->num_rows($result)) |
248: message('There is already a group with the title \''.pun_htmlspecialchars($title).'\'.'); | 248: message('There is already a group with the title \''.pun_htmlspecialchars($title).'\'.'); |
249: | 249: |
250: $db->query('UPDATE '.$db->prefix.'groups SET g_title=\''.$db->escape($title).'\', g_user_title='.$user_title.', g_read_board='.$read_board.', g_post_replies='.$post_replies.', g_post_topics='.$post_topics.', g_edit_posts='.$edit_posts.', g_delete_posts='.$delete_posts.', g_delete_topics='.$delete_topics.', g_set_title='.$set_title.', g_search='.$search.', g_search_users='.$search_users.', g_edit_subjects_interval='.$edit_subjects_interval.', g_post_flood='.$post_flood.', g_search_flood='.$search_flood.' WHERE g_id='.$_POST['group_id']) or error('Unable to update group', __FILE__, __LINE__, $db->error()); | 250: $db->query('UPDATE '.$db->prefix.'groups SET g_title=\''.$db->escape($title).'\', g_user_title='.$user_title.', g_read_board='.$read_board.', g_post_replies='.$post_replies.', g_post_topics='.$post_topics.', g_edit_posts='.$edit_posts.', g_delete_posts='.$delete_posts.', g_delete_topics='.$delete_topics.', g_set_title='.$set_title.', g_search='.$search.', g_search_users='.$search_users.', g_edit_subjects_interval='.$edit_subjects_interval.', g_post_flood='.$post_flood.', g_search_flood='.$search_flood.' WHERE g_id='.intval($_POST['group_id'])) or error('Unable to update group', __FILE__, __LINE__, $db->error()); |
251: } | 251: } |
252: | 252: |
253: // Regenerate the quickjump cache | 253: // Regenerate the quickjump cache |
264: confirm_referrer('admin_groups.php'); | 264: confirm_referrer('admin_groups.php'); |
265: | 265: |
266: $group_id = intval($_POST['default_group']); | 266: $group_id = intval($_POST['default_group']); |
267: if ($group_id < 1) | 267: if ($group_id < 4) |
268: message($lang_common['Bad request']); | 268: message($lang_common['Bad request']); |
269: | 269: |
270: $db->query('UPDATE '.$db->prefix.'config SET conf_value='.$group_id.' WHERE conf_name=\'o_default_user_group\'') or error('Unable to update board config', __FILE__, __LINE__, $db->error()); | 270: $db->query('UPDATE '.$db->prefix.'config SET conf_value='.$group_id.' WHERE conf_name=\'o_default_user_group\'') or error('Unable to update board config', __FILE__, __LINE__, $db->error()); |
punbb-1.2.5/upload/admin_options.php |
punbb-1.2.17/upload/admin_options.php |
37: | 37: |
38: if (isset($_POST['form_sent'])) | 38: if (isset($_POST['form_sent'])) |
39: { | 39: { |
40: // Lazy referer check (in case base_url isn't correct) | 40: // Custom referrer check (so we can output a custom error message) |
41: if (!isset($_SERVER['HTTP_REFERER']) || !preg_match('#/admin_options\.php#i', $_SERVER['HTTP_REFERER'])) | 41: if (!preg_match('#^'.preg_quote(str_replace('www.', '', $pun_config['o_base_url']).'/admin_options.php', '#').'#i', str_replace('www.', '', (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '')))) |
42: message($lang_common['Bad referrer']); | 42: message('Bad HTTP_REFERER. If you have moved these forums from one location to another or switched domains, you need to update the Base URL manually in the database (look for o_base_url in the config table) and then clear the cache by deleting all .php files in the /cache directory.'); |
43: | 43: |
44: $form = array_map('trim', $_POST['form']); | 44: $form = array_map('trim', $_POST['form']); |
45: | 45: |
46: if ($form['board_title'] == '') | 46: if ($form['board_title'] == '') |
47: message('You must enter a board title.'); | 47: message('You must enter a board title.'); |
48: | 48: |
| 49: // Clean default_lang |
| 50: $form['default_lang'] = preg_replace('#[\.\\\/]#', '', $form['default_lang']); |
| 51: |
49: require PUN_ROOT.'include/email.php'; | 52: require PUN_ROOT.'include/email.php'; |
50: | 53: |
51: $form['admin_email'] = strtolower($form['admin_email']); | 54: $form['admin_email'] = strtolower($form['admin_email']); |
63: if (substr($form['base_url'], -1) == '/') | 66: if (substr($form['base_url'], -1) == '/') |
64: $form['base_url'] = substr($form['base_url'], 0, -1); | 67: $form['base_url'] = substr($form['base_url'], 0, -1); |
65: | 68: |
| 69: // Clean avatars_dir |
| 70: $form['avatars_dir'] = str_replace("\0", '', $form['avatars_dir']); |
| 71: |
66: // Make sure avatars_dir doesn't end with a slash | 72: // Make sure avatars_dir doesn't end with a slash |
67: if (substr($form['avatars_dir'], -1) == '/') | 73: if (substr($form['avatars_dir'], -1) == '/') |
68: $form['avatars_dir'] = substr($form['avatars_dir'], 0, -1); | 74: $form['avatars_dir'] = substr($form['avatars_dir'], 0, -1); |
117: while (list($key, $input) = @each($form)) | 123: while (list($key, $input) = @each($form)) |
118: { | 124: { |
119: // Only update values that have changed | 125: // Only update values that have changed |
120: if ($pun_config['o_'.$key] != $input) | 126: if (array_key_exists('o_'.$key, $pun_config) && $pun_config['o_'.$key] != $input) |
121: { | 127: { |
122: if ($input != '' || is_int($input)) | 128: if ($input != '' || is_int($input)) |
123: $value = '\''.$db->escape($input).'\''; | 129: $value = '\''.$db->escape($input).'\''; |
124: else | 130: else |
125: $value = 'NULL'; | 131: $value = 'NULL'; |
126: | 132: |
127: $db->query('UPDATE '.$db->prefix.'config SET conf_value='.$value.' WHERE conf_name=\'o_'.$key.'\'') or error('Unable to update board config', __FILE__, __LINE__, $db->error()); | 133: $db->query('UPDATE '.$db->prefix.'config SET conf_value='.$value.' WHERE conf_name=\'o_'.$db->escape($key).'\'') or error('Unable to update board config', __FILE__, __LINE__, $db->error()); |
128: } | 134: } |
129: } | 135: } |
130: | 136: |
229: $d = dir(PUN_ROOT.'lang'); | 235: $d = dir(PUN_ROOT.'lang'); |
230: while (($entry = $d->read()) !== false) | 236: while (($entry = $d->read()) !== false) |
231: { | 237: { |
232: if ($entry != '.' && $entry != '..' && is_dir(PUN_ROOT.'lang/'.$entry)) | 238: if ($entry != '.' && $entry != '..' && is_dir(PUN_ROOT.'lang/'.$entry) && file_exists(PUN_ROOT.'lang/'.$entry.'/common.php')) |
233: $languages[] = $entry; | 239: $languages[] = $entry; |
234: } | 240: } |
235: $d->close(); | 241: $d->close(); |
236: | 242: |
| 243: @natsort($languages); |
| 244: |
237: while (list(, $temp) = @each($languages)) | 245: while (list(, $temp) = @each($languages)) |
238: { | 246: { |
239: if ($pun_config['o_default_lang'] == $temp) | 247: if ($pun_config['o_default_lang'] == $temp) |
262: } | 270: } |
263: $d->close(); | 271: $d->close(); |
264: | 272: |
| 273: @natsort($styles); |
| 274: |
265: while (list(, $temp) = @each($styles)) | 275: while (list(, $temp) = @each($styles)) |
266: { | 276: { |
267: if ($pun_config['o_default_style'] == $temp) | 277: if ($pun_config['o_default_style'] == $temp) |
punbb-1.2.5/upload/include/functions.php |
punbb-1.2.17/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 |
48: // If user authorisation failed | 48: // If user authorisation failed |
49: if (!isset($pun_user['id']) || md5($cookie_seed.$pun_user['password']) !== $cookie['password_hash']) | 49: if (!isset($pun_user['id']) || md5($cookie_seed.$pun_user['password']) !== $cookie['password_hash']) |
50: { | 50: { |
51: pun_setcookie(0, random_pass(8), $expire); | 51: pun_setcookie(1, md5(uniqid(rand(), true)), $expire); |
52: set_default_user(); | 52: set_default_user(); |
53: | 53: |
54: return; | 54: return; |
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 |
256: $links[] = '<li id="navsearch"><a href="search.php">'.$lang_common['Search'].'</a>'; | 295: $links[] = '<li id="navsearch"><a href="search.php">'.$lang_common['Search'].'</a>'; |
257: | 296: |
258: $links[] = '<li id="navprofile"><a href="profile.php?id='.$pun_user['id'].'">'.$lang_common['Profile'].'</a>'; | 297: $links[] = '<li id="navprofile"><a href="profile.php?id='.$pun_user['id'].'">'.$lang_common['Profile'].'</a>'; |
259: $links[] = '<li id="navlogout"><a href="login.php?action=out&id='.$pun_user['id'].'">'.$lang_common['Logout'].'</a>'; | 298: $links[] = '<li id="navlogout"><a href="login.php?action=out&id='.$pun_user['id'].'&csrf_token='.sha1($pun_user['id'].sha1(get_remote_address())).'">'.$lang_common['Logout'].'</a>'; |
260: } | 299: } |
261: else | 300: else |
262: { | 301: { |
263: $links[] = '<li id="navsearch"><a href="search.php">'.$lang_common['Search'].'</a>'; | 302: $links[] = '<li id="navsearch"><a href="search.php">'.$lang_common['Search'].'</a>'; |
264: $links[] = '<li id="navprofile"><a href="profile.php?id='.$pun_user['id'].'">'.$lang_common['Profile'].'</a>'; | 303: $links[] = '<li id="navprofile"><a href="profile.php?id='.$pun_user['id'].'">'.$lang_common['Profile'].'</a>'; |
265: $links[] = '<li id="navadmin"><a href="admin_index.php">'.$lang_common['Admin'].'</a>'; | 304: $links[] = '<li id="navadmin"><a href="admin_index.php">'.$lang_common['Admin'].'</a>'; |
266: $links[] = '<li id="navlogout"><a href="login.php?action=out&id='.$pun_user['id'].'">'.$lang_common['Logout'].'</a>'; | 305: $links[] = '<li id="navlogout"><a href="login.php?action=out&id='.$pun_user['id'].'&csrf_token='.sha1($pun_user['id'].sha1(get_remote_address())).'">'.$lang_common['Logout'].'</a>'; |
267: } | 306: } |
268: } | 307: } |
269: | 308: |
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: ob_start(); | |
809: include PUN_ROOT.$cur_include[1]; | |
810: $tpl_temp = ob_get_contents(); | |
811: $tpl_maint = str_replace('<'.$cur_include[0].'>', $tpl_temp, $tpl_maint); | |
812: ob_end_clean(); | |
813: } | |
814: // END SUBST - <pun_include "*"> | |
815: | |
816: | |
817: // Close the db connection (and free up any result data) | 838: // Close the db connection (and free up any result data) |
818: $db->close(); | 839: $db->close(); |
819: | 840: |
828: { | 849: { |
829: global $db, $pun_config, $lang_common, $pun_user; | 850: global $db, $pun_config, $lang_common, $pun_user; |
830: | 851: |
831: if ($destination_url == '') | 852: // Prefix with o_base_url (unless there's already a valid URI) |
832: $destination_url = 'index.php'; | 853: if (strpos($destination_url, 'http://') !== 0 && strpos($destination_url, 'https://') !== 0 && strpos($destination_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); |
833: | 858: |
834: // 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 |
835: if ($pun_config['o_redirect_delay'] == '0') | 860: if ($pun_config['o_redirect_delay'] == '0') |
840: $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')); |
841: | 866: |
842: | 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: |
843: // START SUBST - <pun_content_direction> | 883: // START SUBST - <pun_content_direction> |
844: $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); |
845: // END SUBST - <pun_content_direction> | 885: // END SUBST - <pun_content_direction> |
854: ob_start(); | 894: ob_start(); |
855: | 895: |
856: ?> | 896: ?> |
857: <meta http-equiv="refresh" content="<?php echo $pun_config['o_redirect_delay'] ?>;URL=<?php echo $destination_url ?>" /> | 897: <meta http-equiv="refresh" content="<?php echo $pun_config['o_redirect_delay'] ?>;URL=<?php echo str_replace(array('<', '>', '"'), array('<', '>', '"'), $destination_url) ?>" /> |
858: <title><?php echo pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_common['Redirecting'] ?></title> | 898: <title><?php echo pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_common['Redirecting'] ?></title> |
859: <link rel="stylesheet" type="text/css" href="style/<?php echo $pun_user['style'].'.css' ?>" /> | 899: <link rel="stylesheet" type="text/css" href="style/<?php echo $pun_user['style'].'.css' ?>" /> |
860: <?php | 900: <?php |
892: // END SUBST - <pun_footer> | 932: // END SUBST - <pun_footer> |
893: | 933: |
894: | 934: |
895: // START SUBST - <pun_include "*"> | |
896: while (preg_match('<pun_include "(.*?)">', $tpl_redir, $cur_include)) | |
897: { | |
898: ob_start(); | |
899: include PUN_ROOT.$cur_include[1]; | |
900: $tpl_temp = ob_get_contents(); | |
901: $tpl_redir = str_replace('<'.$cur_include[0].'>', $tpl_temp, $tpl_redir); | |
902: ob_end_clean(); | |
903: } | |
904: // END SUBST - <pun_include "*"> | |
905: | |
906: | |
907: // Close the db connection (and free up any result data) | 935: // Close the db connection (and free up any result data) |
908: $db->close(); | 936: $db->close(); |
909: | 937: |
931: | 959: |
932: ?> | 960: ?> |
933: <!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"> |
934: <html dir="ltr"> | 962: <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr"> |
935: <head> | 963: <head> |
936: <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" /> |
937: <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> |
1038: | 1066: |
1039: | 1067: |
1040: // | 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: // |
1041: // Dump contents of variable(s) | 1098: // Dump contents of variable(s) |
1042: // | 1099: // |
1043: function dump() | 1100: function dump() |
punbb-1.2.5/upload/include/parser.php |
punbb-1.2.17/upload/include/parser.php |
184: { | 184: { |
185: // Make sure there's a [/code] and that any new [code] doesn't occur before the end tag | 185: // Make sure there's a [/code] and that any new [code] doesn't occur before the end tag |
186: $tmp = strpos($text, '[/code]'); | 186: $tmp = strpos($text, '[/code]'); |
187: $tmp2 = strpos(substr($text, 6), '[code]'); | 187: $tmp2 = strpos(substr($text, $c_start+6), '[code]'); |
| 188: if ($tmp2 !== false) |
| 189: $tmp2 += $c_start+6; |
| 190: |
188: if ($tmp === false || ($tmp2 !== false && $tmp2 < $tmp)) | 191: if ($tmp === false || ($tmp2 !== false && $tmp2 < $tmp)) |
189: { | 192: { |
190: $error = $lang_common['BBCode error'].' '.$lang_common['BBCode error 2']; | 193: $error = $lang_common['BBCode error'].' '.$lang_common['BBCode error 2']; |
261: { | 264: { |
262: global $pun_user; | 265: global $pun_user; |
263: | 266: |
264: $full_url = str_replace(' ', '%20', $url); | 267: $full_url = str_replace(array(' ', '\'', '`', '"'), array('%20', '', '', ''), $url); |
265: if (strpos($url, 'www.') === 0) // If it starts with www, we add http:// | 268: if (strpos($url, 'www.') === 0) // If it starts with www, we add http:// |
266: $full_url = 'http://'.$full_url; | 269: $full_url = 'http://'.$full_url; |
267: else if (strpos($url, 'ftp.') === 0) // Else if it starts with ftp, we add ftp:// | 270: else if (strpos($url, 'ftp.') === 0) // Else if it starts with ftp, we add ftp:// |
301: { | 304: { |
302: global $lang_common, $pun_user; | 305: global $lang_common, $pun_user; |
303: | 306: |
| 307: if (strpos($text, 'quote') !== false) |
| 308: { |
| 309: $text = str_replace('[quote]', '</p><blockquote><div class="incqbox"><p>', $text); |
| 310: $text = preg_replace('#\[quote=("|"|\'|)(.*)\\1\]#seU', '"</p><blockquote><div class=\"incqbox\"><h4>".str_replace(array(\'[\', \'\\"\'), array(\'[\', \'"\'), \'$2\')." ".$lang_common[\'wrote\'].":</h4><p>"', $text); |
| 311: $text = preg_replace('#\[\/quote\]\s*#', '</p></div></blockquote><p>', $text); |
| 312: } |
| 313: |
304: $pattern = array('#\[b\](.*?)\[/b\]#s', | 314: $pattern = array('#\[b\](.*?)\[/b\]#s', |
305: '#\[i\](.*?)\[/i\]#s', | 315: '#\[i\](.*?)\[/i\]#s', |
306: '#\[u\](.*?)\[/u\]#s', | 316: '#\[u\](.*?)\[/u\]#s', |
307: '#\[url\](.*?)\[/url\]#e', | 317: '#\[url\]([^\[]*?)\[/url\]#e', |
308: '#\[url=(.*?)\](.*?)\[/url\]#e', | 318: '#\[url=([^\[]*?)\](.*?)\[/url\]#e', |
309: '#\[email\](.*?)\[/email\]#', | 319: '#\[email\]([^\[]*?)\[/email\]#', |
310: '#\[email=(.*?)\](.*?)\[/email\]#', | 320: '#\[email=([^\[]*?)\](.*?)\[/email\]#', |
311: '#\[color=([a-zA-Z]*|\#?[0-9a-fA-F]{6})](.*?)\[/color\]#s'); | 321: '#\[color=([a-zA-Z]*|\#?[0-9a-fA-F]{6})](.*?)\[/color\]#s'); |
312: | 322: |
313: $replace = array('<strong>$1</strong>', | 323: $replace = array('<strong>$1</strong>', |
322: // This thing takes a while! :) | 332: // This thing takes a while! :) |
323: $text = preg_replace($pattern, $replace, $text); | 333: $text = preg_replace($pattern, $replace, $text); |
324: | 334: |
325: if (strpos($text, 'quote') !== false) | |
326: { | |
327: $text = str_replace('[quote]', '</p><blockquote><div class="incqbox"><p>', $text); | |
328: $text = preg_replace('#\[quote=("|"|\'|)(.*)\\1\]#seU', '"</p><blockquote><div class=\"incqbox\"><h4>".str_replace(\'[\', \'[\', \'$2\')." ".$lang_common[\'wrote\'].":</h4><p>"', $text); | |
329: $text = preg_replace('#\[\/quote\]\s*#', '</p></div></blockquote><p>', $text); | |
330: } | |
331: | |
332: return $text; | 335: return $text; |
333: } | 336: } |
334: | 337: |
punbb-1.2.5/upload/include/search_idx.php |
punbb-1.2.17/upload/include/search_idx.php |
43: | 43: |
44: if (empty($noise_match)) | 44: if (empty($noise_match)) |
45: { | 45: { |
46: $noise_match = array('quote', 'code', 'url', 'img', 'email', 'color', 'colour', '^', '$', '&', '(', ')', '<', '>', '`', '\'', '"', '|', ',', '@', '_', '?', '%', '~', '+', '[', ']', '{', '}', ':', '\\', '/', '=', '#', ';', '!', '*'); | 46: $noise_match = array('[quote', '[code', '[url', '[img', '[email', '[color', '[colour', 'quote]', 'code]', 'url]', 'img]', 'email]', 'color]', 'colour]', '^', '$', '&', '(', ')', '<', '>', '`', '\'', '"', '|', ',', '@', '_', '?', '%', '~', '+', '[', ']', '{', '}', ':', '\\', '/', '=', '#', ';', '!', '*'); |
47: $noise_replace = array('', '', '', '', '', '', '', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '', '', ' ', ' ', ' ', ' ', '', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '' , ' ', ' ', ' ', ' ', ' ', ' '); | 47: $noise_replace = array('', '', '', '', '', '', '', '', '', '', '', '', '', '', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '', '', ' ', ' ', ' ', ' ', '', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '' , ' ', ' ', ' ', ' ', ' ', ' '); |
48: | 48: |
49: $stopwords = (array)@file(PUN_ROOT.'lang/'.$pun_user['language'].'/stopwords.txt'); | 49: $stopwords = (array)@file(PUN_ROOT.'lang/'.$pun_user['language'].'/stopwords.txt'); |
50: $stopwords = array_map('trim', $stopwords); | 50: $stopwords = array_map('trim', $stopwords); |
69: { | 69: { |
70: while (list($i, $word) = @each($words)) | 70: while (list($i, $word) = @each($words)) |
71: { | 71: { |
| 72: $words[$i] = trim($word, '.'); |
72: $num_chars = pun_strlen($word); | 73: $num_chars = pun_strlen($word); |
73: | 74: |
74: if (strrpos($word, '.') == ($num_chars-1)) | |
75: $words[$i] = substr($word, 0, -1); | |
76: | |
77: if ($num_chars < 3 || $num_chars > 20 || in_array($word, $stopwords)) | 75: if ($num_chars < 3 || $num_chars > 20 || in_array($word, $stopwords)) |
78: unset($words[$i]); | 76: unset($words[$i]); |
79: } | 77: } |
punbb-1.2.5/upload/install.php |
punbb-1.2.17/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.5'; | 27: $punbb_version = '1.2.17'; |
28: | 28: |
29: | 29: |
30: define('PUN_ROOT', './'); | 30: define('PUN_ROOT', './'); |
165: <fieldset> | 165: <fieldset> |
166: <legend>Enter then name of your database</legend> | 166: <legend>Enter then name of your database</legend> |
167: <div class="infldset"> | 167: <div class="infldset"> |
168: <p>The name of the database that PunBB will be installed into. The database must exist. For SQLite, this is the relative path to the database file. If it doesn't exists, PunBB will attempt to create it.</p> | 168: <p>The name of the database that PunBB will be installed into. The database must exist. For SQLite, this is the relative path to the database file. If the SQLite database file does not exist, PunBB will attempt to create it.</p> |
169: <label for="req_db_name"><strong>Database name</strong><br /><input id="req_db_name" type="text" name="req_db_name" size="30" maxlength="50" /><br /></label> | 169: <label for="req_db_name"><strong>Database name</strong><br /><input id="req_db_name" type="text" name="req_db_name" size="30" maxlength="50" /><br /></label> |
170: </div> | 170: </div> |
171: </fieldset> | 171: </fieldset> |
324: if (preg_match('#\[b\]|\[/b\]|\[u\]|\[/u\]|\[i\]|\[/i\]|\[color|\[/color\]|\[quote\]|\[/quote\]|\[code\]|\[/code\]|\[img\]|\[/img\]|\[url|\[/url\]|\[email|\[/email\]#i', $username)) | 324: if (preg_match('#\[b\]|\[/b\]|\[u\]|\[/u\]|\[i\]|\[/i\]|\[color|\[/color\]|\[quote\]|\[/quote\]|\[code\]|\[/code\]|\[img\]|\[/img\]|\[url|\[/url\]|\[email|\[/email\]#i', $username)) |
325: error('Usernames may not contain any of the text formatting tags (BBCode) that the forum uses. Please go back and correct.'); | 325: error('Usernames may not contain any of the text formatting tags (BBCode) that the forum uses. Please go back and correct.'); |
326: | 326: |
327: if (!preg_match('/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/', $email)) | 327: if (strlen($email) > 50 || !preg_match('/^(([^<>()[\]\\.,;:\s@"\']+(\.[^<>()[\]\\.,;:\s@"\']+)*)|("[^"\']+"))@((\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\])|(([a-zA-Z\d\-]+\.)+[a-zA-Z]{2,}))$/', $email)) |
328: error('The administrator e-mail address you entered is invalid. Please go back and correct.'); | 328: error('The administrator e-mail address you entered is invalid. Please go back and correct.'); |
329: | 329: |
330: | 330: |
346: case 'sqlite': | 346: case 'sqlite': |
347: require PUN_ROOT.'include/dblayer/sqlite.php'; | 347: require PUN_ROOT.'include/dblayer/sqlite.php'; |
348: break; | 348: break; |
| 349: |
| 350: default: |
| 351: error('\''.$db_type.'\' is not a valid database type.'); |
349: } | 352: } |
350: | 353: |
351: // Create the database object (and connect/select db) | 354: // Create the database object (and connect/select db) |
525: break; | 528: break; |
526: } | 529: } |
527: | 530: |
528: $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()); |
529: | 532: |
530: | 533: |
531: | 534: |
754: poster_id INT(10) UNSIGNED NOT NULL DEFAULT 1, | 757: poster_id INT(10) UNSIGNED NOT NULL DEFAULT 1, |
755: poster_ip VARCHAR(15), | 758: poster_ip VARCHAR(15), |
756: poster_email VARCHAR(50), | 759: poster_email VARCHAR(50), |
757: message TEXT NOT NULL DEFAULT '', | 760: message TEXT, |
758: hide_smilies TINYINT(1) NOT NULL DEFAULT 0, | 761: hide_smilies TINYINT(1) NOT NULL DEFAULT 0, |
759: posted INT(10) UNSIGNED NOT NULL DEFAULT 0, | 762: posted INT(10) UNSIGNED NOT NULL DEFAULT 0, |
760: edited INT(10) UNSIGNED, | 763: edited INT(10) UNSIGNED, |
771: poster_id INT NOT NULL DEFAULT 1, | 774: poster_id INT NOT NULL DEFAULT 1, |
772: poster_ip VARCHAR(15), | 775: poster_ip VARCHAR(15), |
773: poster_email VARCHAR(50), | 776: poster_email VARCHAR(50), |
774: message TEXT NOT NULL DEFAULT '', | 777: message TEXT, |
775: hide_smilies SMALLINT NOT NULL DEFAULT 0, | 778: hide_smilies SMALLINT NOT NULL DEFAULT 0, |
776: posted INT NOT NULL DEFAULT 0, | 779: posted INT NOT NULL DEFAULT 0, |
777: edited INT, | 780: edited INT, |
788: poster_id INTEGER NOT NULL DEFAULT 1, | 791: poster_id INTEGER NOT NULL DEFAULT 1, |
789: poster_ip VARCHAR(15), | 792: poster_ip VARCHAR(15), |
790: poster_email VARCHAR(50), | 793: poster_email VARCHAR(50), |
791: message TEXT NOT NULL DEFAULT '', | 794: message TEXT, |
792: hide_smilies INTEGER NOT NULL DEFAULT 0, | 795: hide_smilies INTEGER NOT NULL DEFAULT 0, |
793: posted INTEGER NOT NULL DEFAULT 0, | 796: posted INTEGER NOT NULL DEFAULT 0, |
794: edited INTEGER, | 797: edited INTEGER, |
849: forum_id INT(10) UNSIGNED NOT NULL DEFAULT 0, | 852: forum_id INT(10) UNSIGNED NOT NULL DEFAULT 0, |
850: reported_by INT(10) UNSIGNED NOT NULL DEFAULT 0, | 853: reported_by INT(10) UNSIGNED NOT NULL DEFAULT 0, |
851: created INT(10) UNSIGNED NOT NULL DEFAULT 0, | 854: created INT(10) UNSIGNED NOT NULL DEFAULT 0, |
852: message TEXT NOT NULL DEFAULT '', | 855: message TEXT, |
853: zapped INT(10) UNSIGNED, | 856: zapped INT(10) UNSIGNED, |
854: zapped_by INT(10) UNSIGNED, | 857: zapped_by INT(10) UNSIGNED, |
855: PRIMARY KEY (id) | 858: PRIMARY KEY (id) |
864: forum_id INT NOT NULL DEFAULT 0, | 867: forum_id INT NOT NULL DEFAULT 0, |
865: reported_by INT NOT NULL DEFAULT 0, | 868: reported_by INT NOT NULL DEFAULT 0, |
866: created INT NOT NULL DEFAULT 0, | 869: created INT NOT NULL DEFAULT 0, |
867: message TEXT NOT NULL DEFAULT '', | 870: message TEXT, |
868: zapped INT, | 871: zapped INT, |
869: zapped_by INT, | 872: zapped_by INT, |
870: PRIMARY KEY (id) | 873: PRIMARY KEY (id) |
879: forum_id INTEGER NOT NULL DEFAULT 0, | 882: forum_id INTEGER NOT NULL DEFAULT 0, |
880: reported_by INTEGER NOT NULL DEFAULT 0, | 883: reported_by INTEGER NOT NULL DEFAULT 0, |
881: created INTEGER NOT NULL DEFAULT 0, | 884: created INTEGER NOT NULL DEFAULT 0, |
882: message TEXT NOT NULL DEFAULT '', | 885: message TEXT, |
883: zapped INTEGER, | 886: zapped INTEGER, |
884: zapped_by INTEGER, | 887: zapped_by INTEGER, |
885: PRIMARY KEY (id) | 888: PRIMARY KEY (id) |
898: $sql = 'CREATE TABLE '.$db_prefix."search_cache ( | 901: $sql = 'CREATE TABLE '.$db_prefix."search_cache ( |
899: id INT(10) UNSIGNED NOT NULL DEFAULT 0, | 902: id INT(10) UNSIGNED NOT NULL DEFAULT 0, |
900: ident VARCHAR(200) NOT NULL DEFAULT '', | 903: ident VARCHAR(200) NOT NULL DEFAULT '', |
901: search_data TEXT NOT NULL DEFAULT '', | 904: search_data TEXT, |
902: PRIMARY KEY (id) | 905: PRIMARY KEY (id) |
903: ) TYPE=MyISAM;"; | 906: ) TYPE=MyISAM;"; |
904: break; | 907: break; |
907: $sql = 'CREATE TABLE '.$db_prefix."search_cache ( | 910: $sql = 'CREATE TABLE '.$db_prefix."search_cache ( |
908: id INT NOT NULL DEFAULT 0, | 911: id INT NOT NULL DEFAULT 0, |
909: ident VARCHAR(200) NOT NULL DEFAULT '', | 912: ident VARCHAR(200) NOT NULL DEFAULT '', |
910: search_data TEXT NOT NULL DEFAULT '', | 913: search_data TEXT, |
911: PRIMARY KEY (id) | 914: PRIMARY KEY (id) |
912: )"; | 915: )"; |
913: break; | 916: break; |
916: $sql = 'CREATE TABLE '.$db_prefix."search_cache ( | 919: $sql = 'CREATE TABLE '.$db_prefix."search_cache ( |
917: id INTEGER NOT NULL DEFAULT 0, | 920: id INTEGER NOT NULL DEFAULT 0, |
918: ident VARCHAR(200) NOT NULL DEFAULT '', | 921: ident VARCHAR(200) NOT NULL DEFAULT '', |
919: search_data TEXT NOT NULL DEFAULT '', | 922: search_data TEXT, |
920: PRIMARY KEY (id) | 923: PRIMARY KEY (id) |
921: )"; | 924: )"; |
922: break; | 925: break; |
1231: case 'mysql': | 1234: case 'mysql': |
1232: case 'mysqli': | 1235: case 'mysqli': |
1233: // 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)'; |
1234: $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)'; |
1235: $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)'; |
1236: $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)'; |
1397: | 1401: |
1398: | 1402: |
1399: /// Display config.php and give further instructions | 1403: /// Display config.php and give further instructions |
1400: $config = '<?php'."\n\n".'$db_type = \''.$db_type."';\n".'$db_host = \''.$db_host."';\n".'$db_name = \''.$db_name."';\n".'$db_username = \''.$db_username."';\n".'$db_password = \''.$db_password."';\n".'$db_prefix = \''.$db_prefix."';\n".'$p_connect = false;'."\n\n".'$cookie_name = '."'punbb_cookie';\n".'$cookie_domain = '."'';\n".'$cookie_path = '."'/';\n".'$cookie_secure = 0;'."\n".'$cookie_seed = \''.substr(md5(time()), -8)."';\n\ndefine('PUN', 1);"; | 1404: $config = '<?php'."\n\n".'$db_type = \''.$db_type."';\n".'$db_host = \''.$db_host."';\n".'$db_name = \''.$db_name."';\n".'$db_username = \''.$db_username."';\n".'$db_password = \''.$db_password."';\n".'$db_prefix = \''.$db_prefix."';\n".'$p_connect = false;'."\n\n".'$cookie_name = '."'punbb_cookie';\n".'$cookie_domain = '."'';\n".'$cookie_path = '."'/';\n".'$cookie_secure = 0;'."\n".'$cookie_seed = \''.substr(sha1(uniqid(rand(), true)), 0, 16)."';\n\ndefine('PUN', 1);"; |
1401: | 1405: |
1402: | 1406: |
1403: ?> | 1407: ?> |
1420: <div class="fakeform"> | 1424: <div class="fakeform"> |
1421: <div class="inform"> | 1425: <div class="inform"> |
1422: <div class="forminfo"> | 1426: <div class="forminfo"> |
1423: <p>To finalize the installation all you need to do is to <strong>copy and paste the text in the text box below into a file called config.php and then upload this file to the root directory of your PunBB installation</strong>. Make sure there are no linebreaks or spaces before <?php and after ?> in the file. You can later edit config.php if you reconfigure your setup (e.g. change the database password or ).</p> | 1427: <p>To finalize the installation all you need to do is to <strong>copy and paste the text in the text box below into a file called config.php and then upload this file to the root directory of your PunBB installation</strong>. Make sure there are no linebreaks or spaces before <?php. You can later edit config.php if you reconfigure your setup (e.g. change the database password or ).</p> |
1424: <?php if ($alerts != ''): ?> <?php echo $alerts."\n" ?> | 1428: <?php if ($alerts != ''): ?> <?php echo $alerts."\n" ?> |
1425: <?php endif; ?> </div> | 1429: <?php endif; ?> </div> |
1426: <fieldset> | 1430: <fieldset> |
punbb-1.2.5/upload/moderate.php |
punbb-1.2.17/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: |
351: <br /><select name="move_to_forum"> | 363: <br /><select name="move_to_forum"> |
352: <?php | 364: <?php |
353: | 365: |
354: $result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['group_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND f.redirect_url IS NULL ORDER BY c.disp_position, c.id, f.disp_position', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error()); | 366: $result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND f.redirect_url IS NULL ORDER BY c.disp_position, c.id, f.disp_position', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error()); |
355: | 367: |
356: $cur_category = 0; | 368: $cur_category = 0; |
357: while ($cur_forum = $db->fetch_assoc($result)) | 369: while ($cur_forum = $db->fetch_assoc($result)) |
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.5/upload/post.php |
punbb-1.2.17/upload/post.php |
33: | 33: |
34: $tid = isset($_GET['tid']) ? intval($_GET['tid']) : 0; | 34: $tid = isset($_GET['tid']) ? intval($_GET['tid']) : 0; |
35: $fid = isset($_GET['fid']) ? intval($_GET['fid']) : 0; | 35: $fid = isset($_GET['fid']) ? intval($_GET['fid']) : 0; |
36: if ($tid < 1 && $fid < 1) | 36: if ($tid < 1 && $fid < 1 || $tid > 0 && $fid > 0) |
37: message($lang_common['Bad request']); | 37: message($lang_common['Bad request']); |
38: | 38: |
39: // Fetch some info about the topic and/or the forum | 39: // Fetch some info about the topic and/or the forum |
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.5/upload/profile.php |
punbb-1.2.17/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]); |
530: $result = $db->query('SELECT group_id, username FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); | 542: $result = $db->query('SELECT group_id, username FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); |
531: list($group_id, $username) = $db->fetch_row($result); | 543: list($group_id, $username) = $db->fetch_row($result); |
532: | 544: |
| 545: if ($group_id == PUN_ADMIN) |
| 546: message('Administrators cannot be deleted. In order to delete this user, you must first move him/her to a different user group.'); |
| 547: |
533: if (isset($_POST['delete_user_comply'])) | 548: if (isset($_POST['delete_user_comply'])) |
534: { | 549: { |
535: // If the user is a moderator or an administrator, we remove him/her from the moderator list in all forums as well | 550: // If the user is a moderator or an administrator, we remove him/her from the moderator list in all forums as well |
707: message($lang_common['Invalid e-mail']); | 722: message($lang_common['Invalid e-mail']); |
708: } | 723: } |
709: | 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: |
710: break; | 733: break; |
711: } | 734: } |
712: | 735: |
732: } | 755: } |
733: | 756: |
734: // Add http:// if the URL doesn't contain it already | 757: // Add http:// if the URL doesn't contain it already |
735: if ($form['url'] != '' && !stristr($form['url'], 'http://')) | 758: if ($form['url'] != '' && strpos(strtolower($form['url']), 'http://') !== 0) |
736: $form['url'] = 'http://'.$form['url']; | 759: $form['url'] = 'http://'.$form['url']; |
737: | 760: |
738: break; | 761: break; |
743: $form = extract_elements(array('jabber', 'icq', 'msn', 'aim', 'yahoo')); | 766: $form = extract_elements(array('jabber', 'icq', 'msn', 'aim', 'yahoo')); |
744: | 767: |
745: // 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 |
746: if ($form['icq'] != '' && preg_match('/[^0-9]/', $form['icq'])) | 769: if ($form['icq'] != '' && @preg_match('/[^0-9]/', $form['icq'])) |
747: message($lang_prof_reg['Bad ICQ']); | 770: message($lang_prof_reg['Bad ICQ']); |
748: | 771: |
749: break; | 772: break; |
798: { | 821: { |
799: $form = extract_elements(array('email_setting', 'save_pass', 'notify_with_post')); | 822: $form = extract_elements(array('email_setting', 'save_pass', 'notify_with_post')); |
800: | 823: |
801: $form['email_setting'] == intval($form['email_setting']); | 824: $form['email_setting'] = intval($form['email_setting']); |
802: if ($form['email_setting'] < 0 && $form['email_setting'] > 2) $form['email_setting'] = 1; | 825: if ($form['email_setting'] < 0 && $form['email_setting'] > 2) $form['email_setting'] = 1; |
803: | 826: |
804: if (!isset($form['save_pass']) || $form['save_pass'] != '1') $form['save_pass'] = '0'; | 827: if (!isset($form['save_pass']) || $form['save_pass'] != '1') $form['save_pass'] = '0'; |
820: | 843: |
821: | 844: |
822: // Singlequotes around non-empty values and NULL for empty values | 845: // Singlequotes around non-empty values and NULL for empty values |
| 846: $temp = array(); |
823: while (list($key, $input) = @each($form)) | 847: while (list($key, $input) = @each($form)) |
824: { | 848: { |
825: $value = ($input !== '') ? '\''.$db->escape($input).'\'' : 'NULL'; | 849: $value = ($input !== '') ? '\''.$db->escape($input).'\'' : 'NULL'; |
827: $temp[] = $key.'='.$value; | 851: $temp[] = $key.'='.$value; |
828: } | 852: } |
829: | 853: |
| 854: if (empty($temp)) |
| 855: message($lang_common['Bad request']); |
| 856: |
830: | 857: |
831: $db->query('UPDATE '.$db->prefix.'users SET '.implode(',', $temp).' WHERE id='.$id) or error('Unable to update profile', __FILE__, __LINE__, $db->error()); | 858: $db->query('UPDATE '.$db->prefix.'users SET '.implode(',', $temp).' WHERE id='.$id) or error('Unable to update profile', __FILE__, __LINE__, $db->error()); |
832: | 859: |
867: } | 894: } |
868: | 895: |
869: | 896: |
870: $result = $db->query('SELECT u.username, u.email, u.title, u.realname, u.url, u.jabber, u.icq, u.msn, u.aim, u.yahoo, u.location, u.use_avatar, u.signature, u.disp_topics, u.disp_posts, u.email_setting, u.save_pass, u.notify_with_post, u.show_smilies, u.show_img, u.show_img_sig, u.show_avatars, u.show_sig, u.timezone, u.style, u.num_posts, u.last_post, u.registered, u.registration_ip, u.admin_note, g.g_id, g.g_user_title FROM '.$db->prefix.'users AS u LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); | 897: $result = $db->query('SELECT u.username, u.email, u.title, u.realname, u.url, u.jabber, u.icq, u.msn, u.aim, u.yahoo, u.location, u.use_avatar, u.signature, u.disp_topics, u.disp_posts, u.email_setting, u.save_pass, u.notify_with_post, u.show_smilies, u.show_img, u.show_img_sig, u.show_avatars, u.show_sig, u.timezone, u.language, u.style, u.num_posts, u.last_post, u.registered, u.registration_ip, u.admin_note, g.g_id, g.g_user_title FROM '.$db->prefix.'users AS u LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); |
871: if (!$db->num_rows($result)) | 898: if (!$db->num_rows($result)) |
872: message($lang_common['Bad request']); | 899: message($lang_common['Bad request']); |
873: | 900: |
1131: $d = dir(PUN_ROOT.'lang'); | 1158: $d = dir(PUN_ROOT.'lang'); |
1132: while (($entry = $d->read()) !== false) | 1159: while (($entry = $d->read()) !== false) |
1133: { | 1160: { |
1134: if ($entry != '.' && $entry != '..' && is_dir(PUN_ROOT.'lang/'.$entry)) | 1161: if ($entry != '.' && $entry != '..' && is_dir(PUN_ROOT.'lang/'.$entry) && file_exists(PUN_ROOT.'lang/'.$entry.'/common.php')) |
1135: $languages[] = $entry; | 1162: $languages[] = $entry; |
1136: } | 1163: } |
1137: $d->close(); | 1164: $d->close(); |
1139: // Only display the language selection box if there's more than one language available | 1166: // Only display the language selection box if there's more than one language available |
1140: if (count($languages) > 1) | 1167: if (count($languages) > 1) |
1141: { | 1168: { |
| 1169: natsort($languages); |
1142: | 1170: |
1143: ?> | 1171: ?> |
1144: <label><?php echo $lang_prof_reg['Language'] ?>: <?php echo $lang_prof_reg['Language info'] ?> | 1172: <label><?php echo $lang_prof_reg['Language'] ?>: <?php echo $lang_prof_reg['Language info'] ?> |
1147: | 1175: |
1148: while (list(, $temp) = @each($languages)) | 1176: while (list(, $temp) = @each($languages)) |
1149: { | 1177: { |
1150: if ($pun_user['language'] == $temp) | 1178: if ($user['language'] == $temp) |
1151: echo "\t\t\t\t\t\t\t\t".'<option value="'.$temp.'" selected="selected">'.$temp.'</option>'."\n"; | 1179: echo "\t\t\t\t\t\t\t\t".'<option value="'.$temp.'" selected="selected">'.$temp.'</option>'."\n"; |
1152: else | 1180: else |
1153: echo "\t\t\t\t\t\t\t\t".'<option value="'.$temp.'">'.$temp.'</option>'."\n"; | 1181: echo "\t\t\t\t\t\t\t\t".'<option value="'.$temp.'">'.$temp.'</option>'."\n"; |
1350: echo "\t\t\t".'<div><input type="hidden" name="form[style]" value="'.$styles[0].'" /></div>'."\n"; | 1378: echo "\t\t\t".'<div><input type="hidden" name="form[style]" value="'.$styles[0].'" /></div>'."\n"; |
1351: else if (count($styles) > 1) | 1379: else if (count($styles) > 1) |
1352: { | 1380: { |
| 1381: natsort($styles); |
1353: | 1382: |
1354: ?> | 1383: ?> |
1355: <div class="inform"> | 1384: <div class="inform"> |
1488: } | 1517: } |
1489: else | 1518: else |
1490: { | 1519: { |
| 1520: if ($pun_user['id'] != $id) |
| 1521: { |
1491: | 1522: |
1492: ?> | 1523: ?> |
1493: <legend><?php echo $lang_profile['Group membership legend'] ?></legend> | 1524: <legend><?php echo $lang_profile['Group membership legend'] ?></legend> |
1495: <select id="group_id" name="group_id"> | 1526: <select id="group_id" name="group_id"> |
1496: <?php | 1527: <?php |
1497: | 1528: |
1498: $result = $db->query('SELECT g_id, g_title FROM '.$db->prefix.'groups WHERE g_id!='.PUN_GUEST.' ORDER BY g_title') or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error()); | 1529: $result = $db->query('SELECT g_id, g_title FROM '.$db->prefix.'groups WHERE g_id!='.PUN_GUEST.' ORDER BY g_title') or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error()); |
1499: | 1530: |
1500: while ($cur_group = $db->fetch_assoc($result)) | 1531: while ($cur_group = $db->fetch_assoc($result)) |
1501: { | 1532: { |
1502: if ($cur_group['g_id'] == $user['g_id'] || ($cur_group['g_id'] == $pun_config['o_default_user_group'] && $user['g_id'] == '')) | 1533: if ($cur_group['g_id'] == $user['g_id'] || ($cur_group['g_id'] == $pun_config['o_default_user_group'] && $user['g_id'] == '')) |
1503: echo "\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'" selected="selected">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n"; | 1534: echo "\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'" selected="selected">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n"; |
1504: else | 1535: else |
1505: echo "\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n"; | 1536: echo "\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n"; |
1506: } | 1537: } |
1507: | 1538: |
1508: ?> | 1539: ?> |
1509: </select> | 1540: </select> |
1513: </div> | 1544: </div> |
1514: <div class="inform"> | 1545: <div class="inform"> |
1515: <fieldset> | 1546: <fieldset> |
| 1547: <?php |
| 1548: |
| 1549: } |
| 1550: |
| 1551: ?> |
1516: <legend><?php echo $lang_profile['Delete ban legend'] ?></legend> | 1552: <legend><?php echo $lang_profile['Delete ban legend'] ?></legend> |
1517: <div class="infldset"> | 1553: <div class="infldset"> |
1518: <input type="submit" name="delete_user" value="<?php echo $lang_profile['Delete user'] ?>" /> <input type="submit" name="ban" value="<?php echo $lang_profile['Ban user'] ?>" /> | 1554: <input type="submit" name="delete_user" value="<?php echo $lang_profile['Delete user'] ?>" /> <input type="submit" name="ban" value="<?php echo $lang_profile['Ban user'] ?>" /> |
punbb-1.2.5/upload/search.php |
punbb-1.2.17/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'])) |
65: $keywords = (isset($_GET['keywords'])) ? strtolower(trim($_GET['keywords'])) : null; | 66: $keywords = (isset($_GET['keywords'])) ? strtolower(trim($_GET['keywords'])) : null; |
66: $author = (isset($_GET['author'])) ? strtolower(trim($_GET['author'])) : null; | 67: $author = (isset($_GET['author'])) ? strtolower(trim($_GET['author'])) : null; |
67: | 68: |
| 69: if (preg_match('#^[\*%]+$#', $keywords) || strlen(str_replace(array('*', '%'), '', $keywords)) < 3) |
| 70: $keywords = ''; |
| 71: |
| 72: if (preg_match('#^[\*%]+$#', $author) || strlen(str_replace(array('*', '%'), '', $author)) < 3) |
| 73: $author = ''; |
| 74: |
68: if (!$keywords && !$author) | 75: if (!$keywords && !$author) |
69: message($lang_search['No terms']); | 76: message($lang_search['No terms']); |
70: | 77: |
115: $keyword_results = $author_results = array(); | 122: $keyword_results = $author_results = array(); |
116: | 123: |
117: // Search a specific forum? | 124: // Search a specific forum? |
118: $forum_sql = ($forum != -1) ? ' AND t.forum_id = '.$forum : ''; | 125: $forum_sql = ($forum != -1 || ($forum == -1 && $pun_config['o_search_all_forums'] == '0' && $pun_user['g_id'] >= PUN_GUEST)) ? ' AND t.forum_id = '.$forum : ''; |
119: | 126: |
120: if (!empty($author) || !empty($keywords)) | 127: if (!empty($author) || !empty($keywords)) |
121: { | 128: { |
153: { | 160: { |
154: $num_chars = pun_strlen($word); | 161: $num_chars = pun_strlen($word); |
155: | 162: |
156: if ($num_chars < 3 || $num_chars > 20 || in_array($word, $stopwords)) | 163: if ($word !== 'or' && ($num_chars < 3 || $num_chars > 20 || in_array($word, $stopwords))) |
157: unset($keywords_array[$i]); | 164: unset($keywords_array[$i]); |
158: } | 165: } |
159: | 166: |
163: | 170: |
164: $word_count = 0; | 171: $word_count = 0; |
165: $match_type = 'and'; | 172: $match_type = 'and'; |
| 173: $result_list = array(); |
166: @reset($keywords_array); | 174: @reset($keywords_array); |
167: while (list(, $cur_word) = @each($keywords_array)) | 175: while (list(, $cur_word) = @each($keywords_array)) |
168: { | 176: { |
191: } | 199: } |
192: else | 200: else |
193: { | 201: { |
194: $cur_word = str_replace('*', '%', $cur_word); | 202: $cur_word = $db->escape(str_replace('*', '%', $cur_word)); |
195: $sql = 'SELECT m.post_id FROM '.$db->prefix.'search_words AS w INNER JOIN '.$db->prefix.'search_matches AS m ON m.word_id = w.id WHERE w.word LIKE \''.$cur_word.'\''.$search_in_cond; | 203: $sql = 'SELECT m.post_id FROM '.$db->prefix.'search_words AS w INNER JOIN '.$db->prefix.'search_matches AS m ON m.word_id = w.id WHERE w.word LIKE \''.$cur_word.'\''.$search_in_cond; |
196: } | 204: } |
197: | 205: |
318: if ($pun_user['is_guest']) | 326: if ($pun_user['is_guest']) |
319: message($lang_common['No permission']); | 327: message($lang_common['No permission']); |
320: | 328: |
321: $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()); |
322: $num_hits = $db->num_rows($result); | 330: $num_hits = $db->num_rows($result); |
323: | 331: |
324: if (!$num_hits) | 332: if (!$num_hits) |
327: // If it's a search for todays posts | 335: // If it's a search for todays posts |
328: else if ($action == 'show_24h') | 336: else if ($action == 'show_24h') |
329: { | 337: { |
330: $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()); |
331: $num_hits = $db->num_rows($result); | 339: $num_hits = $db->num_rows($result); |
332: | 340: |
333: if (!$num_hits) | 341: if (!$num_hits) |
380: | 388: |
381: | 389: |
382: // Prune "old" search results | 390: // Prune "old" search results |
| 391: $old_searches = array(); |
383: $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()); |
384: | 393: |
385: if ($db->num_rows($result)) | 394: if ($db->num_rows($result)) |
421: // Fetch results to display | 430: // Fetch results to display |
422: if ($search_results != '') | 431: if ($search_results != '') |
423: { | 432: { |
424: $group_by_sql = ''; | |
425: switch ($sort_by) | 433: switch ($sort_by) |
426: { | 434: { |
427: case 1: | 435: case 1: |
441: break; | 449: break; |
442: | 450: |
443: default: | 451: default: |
444: { | |
445: $sort_by_sql = ($show_as == 'topics') ? 't.posted' : 'p.posted'; | 452: $sort_by_sql = ($show_as == 'topics') ? 't.posted' : 'p.posted'; |
446: | |
447: if ($show_as == 'topics') | |
448: $group_by_sql = ', t.posted'; | |
449: | |
450: break; | 453: break; |
451: } | |
452: } | 454: } |
453: | 455: |
454: if ($show_as == 'posts') | 456: if ($show_as == 'posts') |
457: $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; |
458: } | 460: } |
459: else | 461: else |
460: $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; |
461: | 463: |
462: | 464: |
463: // Determine the topic or post offset (based on $_GET['p']) | 465: // Determine the topic or post offset (based on $_GET['p']) |
704: if ($pun_config['o_search_all_forums'] == '1' || $pun_user['g_id'] < PUN_GUEST) | 706: if ($pun_config['o_search_all_forums'] == '1' || $pun_user['g_id'] < PUN_GUEST) |
705: echo "\t\t\t\t\t\t\t".'<option value="-1">'.$lang_search['All forums'].'</option>'."\n"; | 707: echo "\t\t\t\t\t\t\t".'<option value="-1">'.$lang_search['All forums'].'</option>'."\n"; |
706: | 708: |
707: $result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.redirect_url FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['group_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND f.redirect_url IS NULL ORDER BY c.disp_position, c.id, f.disp_position', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error()); | 709: $result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.redirect_url FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND f.redirect_url IS NULL ORDER BY c.disp_position, c.id, f.disp_position', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error()); |
708: | 710: |
709: $cur_category = 0; | 711: $cur_category = 0; |
710: while ($cur_forum = $db->fetch_assoc($result)) | 712: while ($cur_forum = $db->fetch_assoc($result)) |