/dev/null |
b/extras/12_to_1223_update.php |
| 1: <?php |
| 2: /*********************************************************************** |
| 3: |
| 4: Copyright (C) 2002-2005 Rickard Andersson (rickard@punbb.org) |
| 5: |
| 6: This file is part of PunBB. |
| 7: |
| 8: PunBB is free software; you can redistribute it and/or modify it |
| 9: under the terms of the GNU General Public License as published |
| 10: by the Free Software Foundation; either version 2 of the License, |
| 11: or (at your option) any later version. |
| 12: |
| 13: PunBB is distributed in the hope that it will be useful, but |
| 14: WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16: GNU General Public License for more details. |
| 17: |
| 18: You should have received a copy of the GNU General Public License |
| 19: along with this program; if not, write to the Free Software |
| 20: Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21: MA 02111-1307 USA |
| 22: |
| 23: ************************************************************************/ |
| 24: |
| 25: |
| 26: // This script updates the forum database from version 1.2.* to 1.2.22 |
| 27: // Copy this file to the forum root directory and run it. Then remove it from |
| 28: // the root directory. |
| 29: |
| 30: |
| 31: $update_from = array('1.2', '1.2.1', '1.2.2', '1.2.3', '1.2.4', '1.2.5', '1.2.6', '1.2.7', '1.2.8', '1.2.9', '1.2.10', '1.2.11', '1.2.12', '1.2.13', '1.2.14', '1.2.15', '1.2.16', '1.2.17', '1.2.18', '1.2.19', '1.2.20', '1.2.21', '1.2.22'); |
| 32: $update_to = '1.2.23'; |
| 33: |
| 34: |
| 35: define('PUN_ROOT', './'); |
| 36: @include PUN_ROOT.'config.php'; |
| 37: |
| 38: // If PUN isn't defined, config.php is missing or corrupt or we are outside the root directory |
| 39: if (!defined('PUN')) |
| 40: exit('This file must be run from the forum root directory.'); |
| 41: |
| 42: // Enable debug mode |
| 43: define('PUN_DEBUG', 1); |
| 44: |
| 45: // Disable error reporting for uninitialized variables |
| 46: error_reporting(E_ERROR | E_WARNING | E_PARSE); |
| 47: |
| 48: // Turn off magic_quotes_runtime |
| 49: set_magic_quotes_runtime(0); |
| 50: |
| 51: // Turn off PHP time limit |
| 52: @set_time_limit(0); |
| 53: |
| 54: |
| 55: // Load the functions script |
| 56: require PUN_ROOT.'include/functions.php'; |
| 57: |
| 58: |
| 59: // Load DB abstraction layer and try to connect |
| 60: require PUN_ROOT.'include/dblayer/common_db.php'; |
| 61: |
| 62: |
| 63: // Check current version |
| 64: $result1 = $db->query('SELECT cur_version FROM '.$db->prefix.'options'); |
| 65: $result2 = $db->query('SELECT conf_value FROM '.$db->prefix.'config WHERE conf_name=\'o_cur_version\''); |
| 66: $cur_version = ($result1) ? $db->result($result1) : (($result2 && $db->num_rows($result2)) ? $db->result($result2) : 'beta'); |
| 67: |
| 68: if (!in_array($cur_version, $update_from)) |
| 69: error('Version mismatch. This script updates version '.implode(', ', $update_from).' to version '.$update_to.'. The database \''.$db_name.'\' doesn\'t seem to be running a supported version.', __FILE__, __LINE__); |
| 70: |
| 71: |
| 72: // Get the forum config |
| 73: $result = $db->query('SELECT * FROM '.$db->prefix.'config'); |
| 74: while ($cur_config_item = $db->fetch_row($result)) |
| 75: $pun_config[$cur_config_item[0]] = $cur_config_item[1]; |
| 76: |
| 77: |
| 78: if (!isset($_POST['form_sent'])) |
| 79: { |
| 80: |
| 81: ?> |
| 82: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
| 83: |
| 84: <html dir="ltr"> |
| 85: <head> |
| 86: <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> |
| 87: <title>FluxBB Update</title> |
| 88: <link rel="stylesheet" type="text/css" href="style/Oxygen.css" /> |
| 89: </head> |
| 90: <body> |
| 91: |
| 92: <div id="punwrap"> |
| 93: <div id="puninstall" class="pun" style="margin: 10% 20% auto 20%"> |
| 94: |
| 95: <div class="blockform"> |
| 96: <h2><span>FluxBB Update</span></h2> |
| 97: <div class="box"> |
| 98: <form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>" onsubmit="this.start.disabled=true"> |
| 99: <div><input type="hidden" name="form_sent" value="1" /></div> |
| 100: <div class="inform"> |
| 101: <p style="font-size: 1.1em">This script will update your current PunBB/FluxBB <?php echo $cur_version ?> forum database to FluxBB <?php echo $update_to ?>. The update procedure might take anything from a second to a few minutes depending on the speed of the server and the size of the forum database. Don't forget to make a backup of the database before continuing.</p> |
| 102: <p style="font-size: 1.1em">Did you read the update instructions in the documentation? If not, start there.</p> |
| 103: </div> |
| 104: <p><input type="submit" name="start" value="Start upgrade" /></p> |
| 105: </form> |
| 106: </div> |
| 107: </div> |
| 108: |
| 109: </div> |
| 110: </div> |
| 111: |
| 112: </body> |
| 113: </html> |
| 114: <?php |
| 115: |
| 116: } |
| 117: else |
| 118: { |
| 119: // If we're upgrading from 1.2 |
| 120: if ($cur_version == '1.2') |
| 121: { |
| 122: // Insert new config option o_additional_navlinks |
| 123: $db->query('INSERT INTO '.$db->prefix.'config (conf_name, conf_value) VALUES(\'o_additional_navlinks\', NULL)') or error('Unable to alter DB structure.', __FILE__, __LINE__, $db->error()); |
| 124: } |
| 125: |
| 126: // We need to add a unique index to avoid users having multiple rows in the online table |
| 127: if ($db_type == 'mysql' || $db_type == 'mysqli') |
| 128: { |
| 129: $result = $db->query('SHOW INDEX FROM '.$db->prefix.'online') or error('Unable to check DB structure.', __FILE__, __LINE__, $db->error()); |
| 130: |
| 131: if ($db->num_rows($result) == 1) |
| 132: $db->query('ALTER TABLE '.$db->prefix.'online ADD UNIQUE INDEX '.$db->prefix.'online_user_id_ident_idx(user_id,ident)') or error('Unable to alter DB structure.', __FILE__, __LINE__, $db->error()); |
| 133: } |
| 134: |
| 135: // This feels like a good time to synchronize the forums |
| 136: $result = $db->query('SELECT id FROM '.$db->prefix.'forums') or error('Unable to fetch forum info.', __FILE__, __LINE__, $db->error()); |
| 137: |
| 138: while ($row = $db->fetch_row($result)) |
| 139: update_forum($row[0]); |
| 140: |
| 141: |
| 142: // We'll empty the search cache table as well (using DELETE FROM since SQLite does not support TRUNCATE TABLE) |
| 143: $db->query('DELETE FROM '.$db->prefix.'search_cache') or error('Unable to flush search results.', __FILE__, __LINE__, $db->error()); |
| 144: |
| 145: |
| 146: // Finally, we update the version number |
| 147: $db->query('UPDATE '.$db->prefix.'config SET conf_value=\''.$update_to.'\' WHERE conf_name=\'o_cur_version\'') or error('Unable to update version.', __FILE__, __LINE__, $db->error()); |
| 148: |
| 149: |
| 150: // Delete all .php files in the cache (someone might have visited the forums while we were updating and thus, generated incorrect cache files) |
| 151: $d = dir(PUN_ROOT.'cache'); |
| 152: while (($entry = $d->read()) !== false) |
| 153: { |
| 154: if (substr($entry, strlen($entry)-4) == '.php') |
| 155: @unlink(PUN_ROOT.'cache/'.$entry); |
| 156: } |
| 157: $d->close(); |
| 158: |
| 159: ?> |
| 160: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
| 161: |
| 162: <html dir="ltr"> |
| 163: <head> |
| 164: <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> |
| 165: <title>FluxBB Update</title> |
| 166: <link rel="stylesheet" type="text/css" href="style/Oxygen.css" /> |
| 167: </head> |
| 168: <body> |
| 169: |
| 170: <div id="punwrap"> |
| 171: <div id="puninstall" class="pun" style="margin: 10% 20% auto 20%"> |
| 172: |
| 173: <div class="block"> |
| 174: <h2><span>Update completed</span></h2> |
| 175: <div class="box"> |
| 176: <div class="inbox"> |
| 177: <p>Update successful! Your forum database has now been updated to version <?php echo $update_to ?>. You should now remove this script from the forum root directory and follow the rest of the instructions in the documentation.</p> |
| 178: </div> |
| 179: </div> |
| 180: </div> |
| 181: |
| 182: </div> |
| 183: </div> |
| 184: |
| 185: </body> |
| 186: </html> |
| 187: <?php |
| 188: |
| 189: } |
a/upload/register.php |
b/upload/register.php |
163: // Check if someone else already has registered with that e-mail address | 163: // Check if someone else already has registered with that e-mail address |
164: $dupe_list = array(); | 164: $dupe_list = array(); |
165: | 165: |
166: $result = $db->query('SELECT username FROM '.$db->prefix.'users WHERE email=\''.$email1.'\'') or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); | 166: $result = $db->query('SELECT username FROM '.$db->prefix.'users WHERE email=\''.$db->escape($email1).'\'') or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); |
167: if ($db->num_rows($result)) | 167: if ($db->num_rows($result)) |
168: { | 168: { |
169: if ($pun_config['p_allow_dupe_email'] == '0') | 169: if ($pun_config['p_allow_dupe_email'] == '0') |
196: $password_hash = pun_hash($password1); | 196: $password_hash = pun_hash($password1); |
197: | 197: |
198: // Add the user | 198: // Add the user |
199: $db->query('INSERT INTO '.$db->prefix.'users (username, group_id, password, email, email_setting, save_pass, timezone, language, style, registered, registration_ip, last_visit) VALUES(\''.$db->escape($username).'\', '.$intial_group_id.', \''.$password_hash.'\', \''.$email1.'\', '.$email_setting.', '.$save_pass.', '.$timezone.' , \''.$db->escape($language).'\', \''.$pun_config['o_default_style'].'\', '.$now.', \''.get_remote_address().'\', '.$now.')') or error('Unable to create user', __FILE__, __LINE__, $db->error()); | 199: $db->query('INSERT INTO '.$db->prefix.'users (username, group_id, password, email, email_setting, save_pass, timezone, language, style, registered, registration_ip, last_visit) VALUES(\''.$db->escape($username).'\', '.$intial_group_id.', \''.$password_hash.'\', \''.$db->escape($email1).'\', '.$email_setting.', '.$save_pass.', '.$timezone.' , \''.$db->escape($language).'\', \''.$pun_config['o_default_style'].'\', '.$now.', \''.get_remote_address().'\', '.$now.')') or error('Unable to create user', __FILE__, __LINE__, $db->error()); |
200: $new_uid = $db->insert_id(); | 200: $new_uid = $db->insert_id(); |
201: | 201: |
202: | 202: |