function DeleteInstall() { global $txt, $HTTP_SESSION_VARS, $incontext; global $current_smf_version, $sourcedir, $forum_version, $modSettings, $user_info, $db_type; $incontext['page_title'] = $txt['congratulations']; $incontext['sub_template'] = 'delete_install'; $incontext['continue'] = 0; require dirname(__FILE__) . '/Settings.php'; load_database(); chdir(dirname(__FILE__)); require_once $sourcedir . '/Errors.php'; require_once $sourcedir . '/lib/Subs.php'; require_once $sourcedir . '/CommonAPI.php'; require_once $sourcedir . '/Load.php'; require_once $sourcedir . '/Security.php'; require_once $sourcedir . '/lib/Subs-Auth.php'; // Bring a warning over. if (!empty($incontext['account_existed'])) { $incontext['warning'] = $incontext['account_existed']; } smf_db_query(' SET NAMES utf8', array()); // As track stats is by default enabled let's add some activity. smf_db_insert('ignore', '{db_prefix}log_activity', array('date' => 'date', 'topics' => 'int', 'posts' => 'int', 'registers' => 'int'), array(strftime('%Y-%m-%d', time()), 1, 1, !empty($incontext['member_id']) ? 1 : 0), array('date')); // Automatically log them in ;) if (isset($incontext['member_id']) && isset($incontext['member_salt'])) { setLoginCookie(3153600 * 60, $incontext['member_id'], sha1(sha1(strtolower($_POST['username']) . $_POST['password1']) . $incontext['member_salt'])); } $result = smf_db_query(' SELECT value FROM {db_prefix}settings WHERE variable = {string:db_sessions}', array('db_sessions' => 'databaseSession_enable', 'db_error_skip' => true)); if (mysql_num_rows($result) != 0) { list($db_sessions) = mysql_fetch_row($result); } mysql_free_result($result); if (empty($db_sessions)) { if (@version_compare(PHP_VERSION, '4.2.0') == -1) { $HTTP_SESSION_VARS['php_412_bugfix'] = true; } $_SESSION['admin_time'] = time(); } else { $_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211); smf_db_insert('replace', '{db_prefix}sessions', array('session_id' => 'string', 'last_update' => 'int', 'data' => 'string'), array(session_id(), time(), 'USER_AGENT|s:' . strlen($_SERVER['HTTP_USER_AGENT']) . ':"' . $_SERVER['HTTP_USER_AGENT'] . '";admin_time|i:' . time() . ';'), array('session_id')); } // We're going to want our lovely $modSettings now. $request = smf_db_query(' SELECT variable, value FROM {db_prefix}settings', array('db_error_skip' => true)); // Only proceed if we can load the data. if ($request) { while ($row = mysql_fetch_row($request)) { $modSettings[$row[0]] = $row[1]; } mysql_free_result($request); } updateStats('member'); updateStats('message'); updateStats('topic'); $request = smf_db_query(' SELECT id_msg FROM {db_prefix}messages WHERE id_msg = 1 AND modified_time = 0 LIMIT 1', array('db_error_skip' => true)); if (mysql_num_rows($request) > 0) { updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject'])); } mysql_free_result($request); // Now is the perfect time to fetch the SM files. require_once $sourcedir . '/ScheduledTasks.php'; // Sanity check that they loaded earlier! if (isset($modSettings['recycle_board'])) { $forum_version = $current_smf_version; // The variable is usually defined in index.php so lets just use our variable to do it for us. scheduled_fetchSMfiles(); // Now go get those files! // We've just installed! $user_info['ip'] = $_SERVER['REMOTE_ADDR']; $user_info['id'] = isset($incontext['member_id']) ? $incontext['member_id'] : 0; logAction('install', array('version' => $forum_version), 'admin'); } // Check if we need some stupid MySQL fix. $server_version = smf_db_get_version(); if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { updateSettings(array('db_mysql_group_by_fix' => '1')); } // Some final context for the template. $incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\'; $incontext['probably_delete_install'] = isset($_SESSION['installer_temp_ftp']) || is_writable(dirname(__FILE__)) || is_writable(__FILE__); return false; }
function DeleteUpgrade() { global $command_line, $language, $upcontext, $boarddir, $sourcedir, $forum_version, $user_info, $maintenance, $smcFunc, $db_type; // Now it's nice to have some of the basic SMF source files. if (!isset($_GET['ssi']) && !$command_line) { redirectLocation('&ssi=1'); } $upcontext['sub_template'] = 'upgrade_complete'; $upcontext['page_title'] = 'Upgrade Complete'; $endl = $command_line ? "\n" : '<br />' . "\n"; $changes = array('language' => '\'' . (substr($language, -4) == '.lng' ? substr($language, 0, -4) : $language) . '\'', 'db_error_send' => '1', 'upgradeData' => '#remove#'); // Are we in maintenance mode? if (isset($upcontext['user']['main'])) { if ($command_line) { echo ' * '; } $upcontext['removed_maintenance'] = true; $changes['maintenance'] = $upcontext['user']['main']; } elseif (!empty($maintenance) && $maintenance == 2) { $changes['maintenance'] = 1; } // Wipe this out... $upcontext['user'] = array(); // Make a backup of Settings.php first as otherwise earlier changes are lost. copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php'); changeSettings($changes); // Clean any old cache files away. clean_cache(); // Can we delete the file? $upcontext['can_delete_script'] = is_writable(dirname(__FILE__)) || is_writable(__FILE__); // Now is the perfect time to fetch the SM files. if ($command_line) { cli_scheduled_fetchSMfiles(); } else { require_once $sourcedir . '/ScheduledTasks.php'; $forum_version = SMF_VERSION; // The variable is usually defined in index.php so lets just use the constant to do it for us. scheduled_fetchSMfiles(); // Now go get those files! } // Log what we've done. if (empty($user_info['id'])) { $user_info['id'] = !empty($upcontext['user']['id']) ? $upcontext['user']['id'] : 0; } // Log the action manually, so CLI still works. $smcFunc['db_insert']('', '{db_prefix}log_actions', array('log_time' => 'int', 'id_log' => 'int', 'id_member' => 'int', 'ip' => 'string-16', 'action' => 'string', 'id_board' => 'int', 'id_topic' => 'int', 'id_msg' => 'int', 'extra' => 'string-65534'), array(time(), 3, $user_info['id'], $command_line ? '127.0.0.1' : $user_info['ip'], 'upgrade', 0, 0, 0, serialize(array('version' => $forum_version, 'member' => $user_info['id']))), array('id_action')); $user_info['id'] = 0; // Save the current database version. $server_version = $smcFunc['db_server_info'](); if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) { updateSettings(array('db_mysql_group_by_fix' => '1')); } if ($command_line) { echo $endl; echo 'Upgrade Complete!', $endl; echo 'Please delete this file as soon as possible for security reasons.', $endl; exit; } // Make sure it says we're done. $upcontext['overall_percent'] = 100; if (isset($upcontext['step_progress'])) { unset($upcontext['step_progress']); } $_GET['substep'] = 0; return false; }