function convert_board($step) { require './convert_db.php'; switch ($step) { default: $url = preg_replace('/install\\/?$/i', '', $this->server_url() . dirname($_SERVER['PHP_SELF'])); echo "<form action='{$this->self}?mode=convert&step=2' method='post'>\n\t\t\t\t<table border='0' cellpadding='4' cellspacing='0'>\n"; check_writeable_files(); include 'templates/convertfromforum.php'; include 'templates/convertfromdatabase.php'; include 'templates/converttodatabase.php'; include 'templates/convertboardsettings.php'; echo "<tr>\n <td class='subheader' colspan='2' align='center'><input type='submit' value='Continue' /></td>\n </tr>\n </table>\n </form>"; break; case 2: $oldboard = new qsfglobal(); $oldboard->db = new $this->modules['database']($this->post['old_db_host'], $this->post['old_db_user'], $this->post['old_db_pass'], $this->post['old_db_name'], $this->post['old_db_port'], $this->post['old_db_socket'], $this->post['old_prefix']); if (!$oldboard->db->connection) { echo "Couldn't connect to your old database using the specified information."; break; } $this->db = new $this->modules['database']($this->post['db_host'], $this->post['db_user'], $this->post['db_pass'], $this->post['db_name'], $this->post['db_port'], $this->post['db_socket'], $this->post['prefix']); if (!$this->db->connection) { echo "Couldn't connect to your new database using the specified information."; break; } if (!isset($this->post['old_forum']) || $this->post['old_forum'] == '') { echo "You have not selected a forum to convert from. Please go back and correct this error."; break; } $oldset['old_db_host'] = $this->post['old_db_host']; $oldset['old_db_user'] = $this->post['old_db_user']; $oldset['old_db_pass'] = $this->post['old_db_pass']; $oldset['old_db_name'] = $this->post['old_db_name']; $oldset['old_db_port'] = $this->post['old_db_port']; $oldset['old_db_socket'] = $this->post['old_db_socket']; $oldset['post_inc'] = $this->post['post_inc']; $oldset['old_prefix'] = trim(preg_replace('/[^a-zA-Z0-9_]/', '', $this->post['old_prefix'])); $oldset['converted'] = '0'; if (!$this->write_olddb_sets($oldset)) { echo 'The old database connection was ok, but convert_db.php in the install directory could not be updated.<br /><br />CHMOD convert_db.php to 666. Then press the back button and try again.'; break; } $this->sets['db_host'] = $this->post['db_host']; $this->sets['db_user'] = $this->post['db_user']; $this->sets['db_pass'] = $this->post['db_pass']; $this->sets['db_name'] = $this->post['db_name']; $this->sets['db_port'] = $this->post['db_port']; $this->sets['db_socket'] = $this->post['db_socket']; $this->sets['prefix'] = trim(preg_replace('/[^a-zA-Z0-9_]/', '', $this->post['prefix'])); if (get_magic_quotes_gpc()) { $this->unset_magic_quotes_gpc($this->get); $this->unset_magic_quotes_gpc($this->post); $this->unset_magic_quotes_gpc($this->cookie); } $this->sets['installed'] = 1; if (!$this->write_db_sets('../settings.php')) { echo 'The new database connection was ok, but settings.php could not be updated.<br /><br />CHMOD settings.php to 666.'; break; } if (!is_readable('./data_tables.php')) { echo 'New database connected, settings written, but no data could be loaded from data_tables.php'; break; } if (!is_readable(SKIN_FILE)) { echo 'New database connected, settings written, but no templates could be loaded from ' . SKIN_FILE; break; } $queries = array(); $pre = $this->sets['prefix']; $this->pre = $this->sets['prefix']; include './data_tables.php'; execute_queries($queries, $this->db); $queries = NULL; // Create template $xmlInfo = new xmlparser(); $xmlInfo->parse(SKIN_FILE); $templatesNode = $xmlInfo->GetNodeByPath('QSFMOD/TEMPLATES'); packageutil::insert_templates('default', $this->db, $templatesNode); unset($templatesNode); $xmlInfo = null; $this->pre = $this->sets['prefix']; $this->sets = $this->get_settings($this->sets); $this->sets['loc_of_board'] = $this->post['board_url']; $this->sets['forum_name'] = $this->post['board_name']; $this->write_sets(); echo "<meta http-equiv='Refresh' content='0;URL={$this->post['old_forum']}'>"; break; } }
function install_skin() { if (!isset($this->post['submit']) && !isset($this->get['newskin']) && !isset($this->get['skindetails']) && !isset($this->get['temp'])) { // Build drop down list for the OLD method $skin_box = ''; $dp = opendir('../skins'); while (($file = readdir($dp)) !== false) { $ext = strtolower(substr($file, -4)); if ($ext == '.mbs') { $skin_box .= "<option value='../skins/{$file}'>" . substr($file, 0, -4) . "</option>\n"; } } closedir($dp); // Now check for skins using the NEW method // build a list of all the xml skin files $new_skin_box = ''; $packages = packageutil::scan_packages(); foreach ($packages as $package) { if ($package['type'] != 'skin') { continue; } // skip other mods $new_skin_box .= " <li><a href=\"{$this->self}?a=templates&s=load&newskin="; if (strtolower(substr($package['file'], -7)) == '.tar.gz') { $new_skin_box .= urlencode(substr($package['file'], 0, -7)) . "\" "; } else { $new_skin_box .= urlencode(substr($package['file'], 0, -4)) . "\" "; } if ($package['desc']) { $new_skin_box .= "title=\"" . htmlspecialchars($package['desc']) . "\""; } $new_skin_box .= ">"; $new_skin_box .= "<strong>" . htmlspecialchars($package['title']) . "</strong></a>"; $new_skin_box .= " " . htmlspecialchars($package['version']); $new_skin_box .= " (" . htmlspecialchars($package['author']) . ")"; $new_skin_box .= "</li>\n"; } return $this->message($this->lang->install_skin, eval($this->template('ADMIN_INSTALL_SKIN'))); } else { if (isset($this->get['skindetails'])) { // Display some preview information on the skin } else { if (isset($this->get['newskin'])) { // Use new method of install $tarTool = new archive_tar(); // Open and parse the XML file $xmlInfo = new xmlparser(); if (file_exists('../packages/' . $this->get['newskin'] . '.xml')) { $xmlInfo->parse('../packages/' . $this->get['newskin'] . '.xml'); } else { if (file_exists('../packages/' . $this->get['newskin'] . '.tar')) { $tarTool->open_file_reader('../packages/' . $this->get['newskin'] . '.tar'); $xmlFilename = $tarTool->extract_file('package.txt'); $xmlInfo->parseTar($tarTool, $xmlFilename); } else { if (file_exists('../packages/' . $this->get['newskin'] . '.tar.gz') && $tarTool->can_gunzip()) { $tarTool->open_file_reader('../packages/' . $this->get['newskin'] . '.tar.gz'); $xmlFilename = $tarTool->extract_file('package.txt'); $xmlInfo->parseTar($tarTool, $xmlFilename); } else { return $this->message($this->lang->install_skin, $this->lang->skin_none); } } } // Get the folder name $node = $xmlInfo->GetNodeByPath('QSFMOD/TYPE'); $skin_dir = $node['attrs']['FOLDER']; // Run the uninstall queries packageutil::run_queries($this->db, $xmlInfo->GetNodeByPath('QSFMOD/UNINSTALL')); // Run the install queries packageutil::run_queries($this->db, $xmlInfo->GetNodeByPath('QSFMOD/INSTALL')); // Add the templates packageutil::insert_templates($skin_dir, $this->db, $xmlInfo->GetNodeByPath('QSFMOD/TEMPLATES')); // Extract the files if (file_exists('../packages/' . $this->get['newskin'] . '.tar')) { $tarTool->open_file_reader('../packages/' . $this->get['newskin'] . '.tar'); } else { $tarTool->open_file_reader('../packages/' . $this->get['newskin'] . '.tar.gz'); } $nodes = $xmlInfo->GetNodeByPath('QSFMOD/FILES'); foreach ($nodes['child'] as $node) { if ($node['name'] == 'FILE') { $filename = $node['content']; $data = $tarTool->extract_file($filename); if ($data !== false) { $this->_make_dir('../' . $filename); $fh = fopen('../' . $filename, 'wb'); fwrite($fh, $data); fclose($fh); } } } $tarTool->close_file(); $this->chmod('../skins/' . $skin_dir, 0777, true); return $this->message($this->lang->install_skin, $this->lang->install_done); } else { // Use old method of install if (!isset($this->get['temp']) && !isset($this->get['install'])) { if (!isset($this->post['install'])) { return $this->message($this->lang->install_skin, $this->lang->skin_none); } $dir = md5(microtime()); $zip = new qsf_zip(); $zip->extract($this->post['install'], "../skins/{$dir}"); $this->chmod("../skins/{$dir}", 0777, true); include "../skins/{$dir}/info.php"; if (is_dir("../skins/{$skin['dir']}")) { return $this->message($this->lang->install_skin, "{$this->lang->install_exists1} <b>{$skin['name']}</b> {$this->lang->install_exists2}", $this->lang->install_overwrite, "{$this->self}?a=templates&s=load&temp={$dir}"); } $this->get['temp'] = $dir; } $dir = $this->get['temp']; include "../skins/{$dir}/info.php"; if (is_dir("../skins/{$skin['dir']}")) { $this->remove_dir("../skins/{$skin['dir']}"); } rename("../skins/{$dir}", "../skins/{$skin['dir']}"); $this->chmod("../skins/{$skin['dir']}", 0777, true); $dir = $skin['dir']; $queries = array(); $pre = $this->db->prefix; include "../skins/{$dir}/templates.php"; $this->db->query("DELETE FROM %pskins WHERE skin_dir='%s'", $dir); $this->db->query("INSERT INTO %pskins (skin_name, skin_dir) VALUES ('%s', '%s')", $skin['name'], $dir); $this->db->query("DELETE FROM %ptemplates WHERE template_skin='%s'", $dir); $this->execute_queries($queries); return $this->message($this->lang->install_skin, $this->lang->install_done); } } } }
function install_board($step) { switch ($step) { default: $url = preg_replace('/install\\/?$/i', '', $this->server_url() . dirname($_SERVER['PHP_SELF'])); echo "<form action='{$this->self}?mode=new_install&step=2' method='post'>\n <table border='0' cellpadding='4' cellspacing='0'>\n"; check_writeable_files(); include 'templates/newdatabase.php'; include 'templates/newboardsettings.php'; include 'templates/newadmin.php'; include 'templates/newseeddata.php'; echo "<tr>\n <td class='subheader' colspan='2' align='center'><input type='submit' value='Continue' /></td>\n </tr>\n </table>\n </form>"; break; case 2: $db = new $this->modules['database']($this->post['db_host'], $this->post['db_user'], $this->post['db_pass'], $this->post['db_name'], $this->post['db_port'], $this->post['db_socket'], $this->post['prefix']); if (!$db->connection) { echo "Couldn't connect to a database using the specified information."; break; } $this->db =& $db; $this->sets['db_host'] = $this->post['db_host']; $this->sets['db_user'] = $this->post['db_user']; $this->sets['db_pass'] = $this->post['db_pass']; $this->sets['db_name'] = $this->post['db_name']; $this->sets['db_port'] = $this->post['db_port']; $this->sets['db_socket'] = $this->post['db_socket']; $this->sets['prefix'] = trim(preg_replace('/[^a-zA-Z0-9_]/', '', $this->post['prefix'])); if (!$this->write_db_sets('../settings.php') && !isset($this->post['downloadsettings'])) { echo "The database connection was ok, but settings.php could not be updated.<br />\n"; echo "You can CHMOD settings.php to 0666 and hit reload to try again<br/>\n"; echo "Or you can force the install to continue and download the new settings.php file "; echo "so you can later place it on the website manually<br/>\n"; echo "<form action=\"{$this->self}?mode=new_install&step=2\" method=\"post\">\n\n\t\t\t\t\t<input type=\"hidden\" name=\"downloadsettings\" value=\"yes\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"db_host\" value=\"" . htmlspecialchars($this->post['db_host']) . "\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"db_name\" value=\"" . htmlspecialchars($this->post['db_name']) . "\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"db_user\" value=\"" . htmlspecialchars($this->post['db_user']) . "\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"db_pass\" value=\"" . htmlspecialchars($this->post['db_pass']) . "\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"db_port\" value=\"" . htmlspecialchars($this->post['db_port']) . "\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"db_socket\" value=\"" . htmlspecialchars($this->post['db_socket']) . "\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"prefix\" value=\"" . htmlspecialchars($this->post['prefix']) . "\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"board_name\" value=\"" . htmlspecialchars($this->post['board_name']) . "\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"board_url\" value=\"" . htmlspecialchars($this->post['board_url']) . "\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"admin_name\" value=\"" . htmlspecialchars($this->post['admin_name']) . "\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"admin_pass\" value=\"" . htmlspecialchars($this->post['admin_pass']) . "\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"admin_pass2\" value=\"" . htmlspecialchars($this->post['admin_pass2']) . "\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"admin_email\" value=\"" . htmlspecialchars($this->post['admin_email']) . "\" />\n\n\t\t\t\t\t"; if (isset($this->post['seed_data']) && $this->post['seed_data']) { echo "<input type=\"hidden\" name=\"seed_data\" value=\"yes\" />\n"; } echo "<input type=\"submit\" value=\"Force Install\" />\n\t\t\t\t\t</form>\n\t\t\t\t\t "; break; } $filename = './' . $this->sets['dbtype'] . '_data_tables.php'; if (!is_readable($filename)) { echo 'Database connected, settings written, but no tables could be loaded from file: ' . $filename; break; } if (!is_readable(SKIN_FILE)) { echo 'Database connected, settings written, but no templates could be loaded from file: ' . SKIN_FILE; break; } if (trim($this->post['admin_name']) == '' || trim($this->post['admin_pass']) == '' || trim($this->post['admin_email']) == '') { echo 'You have not specified an admistrator account. Please go back and correct this error.'; break; } if ($this->post['admin_pass'] != $this->post['admin_pass2']) { echo 'Your administrator passwords do not match. Please go back and correct this error.'; break; } if (isset($this->post['seed_data']) && $this->post['seed_data'] && !is_readable('./seed_data.php')) { echo 'Database connected, settings written, but no seed data could be loaded from file: seed_data.php'; break; } $queries = array(); $pre = $this->sets['prefix']; $this->pre = $this->sets['prefix']; // Create tables include './' . $this->sets['dbtype'] . '_data_tables.php'; execute_queries($queries, $db); $queries = null; // Create template $xmlInfo = new xmlparser(); $xmlInfo->parse(SKIN_FILE); $templatesNode = $xmlInfo->GetNodeByPath('QSFMOD/TEMPLATES'); packageutil::insert_templates('default', $this->db, $templatesNode); unset($templatesNode); $xmlInfo = null; $this->sets = $this->get_settings($this->sets); $this->sets['loc_of_board'] = $this->post['board_url']; $this->sets['forum_name'] = $this->post['board_name']; $this->post['admin_pass'] = md5($this->post['admin_pass']); if (get_magic_quotes_gpc()) { $this->unset_magic_quotes_gpc($this->get); $this->unset_magic_quotes_gpc($this->post); $this->unset_magic_quotes_gpc($this->cookie); } $this->post['admin_name'] = str_replace(array('&#', '\''), array('&#', '''), htmlspecialchars($this->post['admin_name'])); $this->db->query("INSERT INTO %pusers (user_name, user_password, user_group, user_title, user_title_custom, user_joined, user_email, user_timezone)\n\t\t\t\tVALUES ('%s', '%s', %d, 'Administrator', 1, %d, '%s', %d)", $this->post['admin_name'], $this->post['admin_pass'], USER_ADMIN, $this->time, $this->post['admin_email'], $this->sets['servertime']); $admin_uid = $this->db->insert_id("users"); $this->sets['last_member'] = $this->post['admin_name']; $this->sets['last_member_id'] = $admin_uid; $this->sets['admin_incoming'] = $this->post['admin_email']; $this->sets['admin_outgoing'] = $this->post['admin_email']; $this->sets['members']++; $this->sets['installed'] = 1; if (isset($this->post['seed_data']) && $this->post['seed_data']) { include './seed_data.php'; // Create Category $categoryId = $this->create_forum($categoryName, $categoryDesc, 0); // Create Forum $forumId = $this->create_forum($forumName, $forumDesc, $categoryId); // Create Topic $this->db->query("INSERT INTO %ptopics (topic_title, topic_forum, topic_description, topic_starter, topic_icon, topic_posted, topic_edited, topic_last_poster, topic_modes) \n\t\t\t\t\tVALUES ('%s', %d, '%s', %d, '%s', %d, %d, %d, %d)", $topicName, $forumId, $topicDesc, $admin_uid, $topicIcon, $this->time, $this->time, $admin_uid, TOPIC_PUBLISH); $topicId = $this->db->insert_id("topics"); // Create Post $this->db->query("INSERT INTO %pposts (post_topic, post_author, post_text, post_time, post_emoticons, post_mbcode, post_ip, post_icon)\n\t\t\t\t\tVALUES (%d, %d, '%s', %d, 1, 1, INET_ATON('%s'), '%s')", $topicId, $admin_uid, $topicPost, $this->time, $this->ip, $topicIcon); $postId = $this->db->insert_id("posts"); $this->db->query("UPDATE %ptopics SET topic_last_post=%d WHERE topic_id=%d", $postId, $topicId); $this->db->query("UPDATE %pusers SET user_posts=user_posts+1, user_lastpost=%d WHERE user_id=%d", $this->time, $admin_uid); $this->db->query("UPDATE %pforums SET forum_topics=forum_topics+1, forum_lastpost=%d WHERE forum_id=%d", $postId, $forumId); $this->sets['topics']++; $this->sets['posts']++; } $writeSetsWorked = $this->write_db_sets('../settings.php'); $this->write_sets(); if (version_compare(PHP_VERSION, "5.2.0", "<")) { setcookie($this->sets['cookie_prefix'] . 'user', $admin_uid, $this->time + $this->sets['logintime'], $this->sets['cookie_path'], $this->sets['cookie_domain'] . '; HttpOnly', $this->sets['cookie_secure']); setcookie($this->sets['cookie_prefix'] . 'pass', $this->post['admin_pass'], $this->time + $this->sets['logintime'], $this->sets['cookie_path'], $this->sets['cookie_domain'] . '; HttpOnly', $this->sets['cookie_secure']); } else { setcookie($this->sets['cookie_prefix'] . 'user', $admin_uid, $this->time + $this->sets['logintime'], $this->sets['cookie_path'], $this->sets['cookie_domain'], $this->sets['cookie_secure'], true); setcookie($this->sets['cookie_prefix'] . 'pass', $this->post['admin_pass'], $this->time + $this->sets['logintime'], $this->sets['cookie_path'], $this->sets['cookie_domain'], $this->sets['cookie_secure'], true); } if (!$writeSetsWorked) { echo "Congratulations! Your board has been installed.<br />\n\t\t\t\tAn administrator account was registered.<br />"; echo "Click here to download your settings.php file. You must put this file on the webhost before the board is ready to use<br/>\n"; echo "<form action=\"{$this->self}?mode=new_install&step=3\" method=\"post\">\n\n\t\t\t\t\t<input type=\"hidden\" name=\"db_host\" value=\"" . htmlspecialchars($this->post['db_host']) . "\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"db_name\" value=\"" . htmlspecialchars($this->post['db_name']) . "\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"db_user\" value=\"" . htmlspecialchars($this->post['db_user']) . "\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"db_pass\" value=\"" . htmlspecialchars($this->post['db_pass']) . "\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"db_port\" value=\"" . htmlspecialchars($this->post['db_port']) . "\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"db_socket\" value=\"" . htmlspecialchars($this->post['db_socket']) . "\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"prefix\" value=\"" . htmlspecialchars($this->post['prefix']) . "\" />\n\n\t\t\t\t\t<input type=\"submit\" value=\"Download settings.php\" />\n\t\t\t\t\t</form>\n\t\t\t\t\t<br/>\n\n\t\t\t\t\tOnce this is done: REMEMBER TO DELETE THE INSTALL DIRECTORY!<br /><br />\n\t\t\t\t\t<a href='../index.php'>Go to your board.</a>\n\t\t\t\t\t "; } else { echo "Congratulations! Your board has been installed.<br />\n\t\t\t\tAn administrator account was registered.<br />\n\t\t\t\tREMEMBER TO DELETE THE INSTALL DIRECTORY!<br /><br />\n\t\t\t\t<a href='../index.php'>Go to your board.</a>"; } break; case 3: // Give them the settings.php file $this->sets['db_host'] = $this->post['db_host']; $this->sets['db_user'] = $this->post['db_user']; $this->sets['db_pass'] = $this->post['db_pass']; $this->sets['db_name'] = $this->post['db_name']; $this->sets['db_port'] = $this->post['db_port']; $this->sets['db_socket'] = $this->post['db_socket']; $this->sets['installed'] = 1; $this->sets['prefix'] = trim(preg_replace('/[^a-zA-Z0-9_]/', '', $this->post['prefix'])); $settingsFile = $this->create_settings_file(); ob_clean(); header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=\"settings.php\""); echo $settingsFile; exit; break; } }
/** * Restore a backup * * @author Jason Warner <*****@*****.**> * @since 1.0.2 * @return string HTML **/ function restore_backup() { if (!isset($this->get['restore'])) { $tarTool = new archive_tar(); $xmlInfo = new xmlparser(); $new_backup_box = ''; $packages = packageutil::scan_packages(); foreach ($packages as $package) { if ($package['type'] != 'backup') { continue; } // skip other mods $new_backup_box .= " <li><a href=\"{$this->self}?a=backup&s=restore&restore="; if (strtolower(substr($package['file'], -7)) == '.tar.gz') { $new_backup_box .= urlencode(substr($package['file'], 0, -7)) . "\" "; } else { $new_backup_box .= urlencode(substr($package['file'], 0, -4)) . "\" "; } if ($package['desc']) { $new_backup_box .= "title=\"" . htmlspecialchars($package['desc']) . "\""; } $new_backup_box .= ">"; $new_backup_box .= "<strong>" . htmlspecialchars($package['title']) . "</strong></a>"; $new_backup_box .= " " . htmlspecialchars($package['version']); $new_backup_box .= " (" . htmlspecialchars($package['author']) . ")"; $new_backup_box .= "</li>\n"; } if ($new_backup_box) { return $this->message($this->lang->backup_restore, "\n\t\t\t\t<div>\n\t\t\t\t\t{$this->lang->backup_found}:<br /><br />\n\t\t\t\t\t{$new_backup_box}\n\t\t\t\t\t\n\t\t\t\t\t<b>{$this->lang->backup_warning}</b>\n\t\t\t\t</div>"); } else { return $this->message($this->lang->backup_restore, $this->lang->backup_none); } } else { $tarTool = new archive_tar(); // Open and parse the XML file $xmlInfo = new xmlparser(); if (file_exists('../packages/' . $this->get['restore'] . '.xml')) { $xmlInfo->parse('../packages/' . $this->get['restore'] . '.xml'); } else { if (file_exists('../packages/' . $this->get['restore'] . '.tar')) { $tarTool->open_file_reader('../packages/' . $this->get['restore'] . '.tar'); $xmlFilename = $tarTool->extract_file('package.txt'); $xmlInfo->parseTar($tarTool, $xmlFilename); } else { if (file_exists('../packages/' . $this->get['restore'] . '.tar.gz') && $tarTool->can_gunzip()) { $tarTool->open_file_reader('../packages/' . $this->get['restore'] . '.tar.gz'); $xmlFilename = $tarTool->extract_file('package.txt'); $xmlInfo->parseTar($tarTool, $xmlFilename); } else { return $this->message($this->lang->backup_restore, $this->lang->backup_invalid); } } } // Run the uninstall queries packageutil::run_queries($this->db, $xmlInfo->GetNodeByPath('QSFMOD/UNINSTALL')); // Run the install queries packageutil::run_queries($this->db, $xmlInfo->GetNodeByPath('QSFMOD/INSTALL')); // Done! return $this->message($this->lang->backup_restore, $this->lang->backup_restore_done); } }
function upgrade_board($step) { switch ($step) { default: echo "<form action='{$this->self}' method='get'>\n\t\t\t <table border='0' cellpadding='4' cellspacing='0'>\n"; check_writeable_files(); echo "<tr><td colspan='2' align='center'><b>Upgrade from what version?</b></td></tr>"; include 'templates/upgradefromversion.php'; echo " </table>\n\t\t\t </form>\n"; break; // Step 1.5 simply updates the database info // Step 1.5 simply updates the database info case 15: $this->sets['db_host'] = $this->post['db_host']; $this->sets['db_name'] = $this->post['db_name']; $this->sets['db_user'] = $this->post['db_user']; $this->sets['db_pass'] = $this->post['db_pass']; $this->sets['db_port'] = $this->post['db_port']; $this->sets['db_socket'] = $this->post['db_socket']; $this->sets['prefix'] = trim(preg_replace('/[^a-zA-Z0-9_]/', '', $this->post['prefix'])); if (!$this->write_db_sets('../settings.php')) { echo 'settings.php could not be updated.<br /><br />CHMOD settings.php to 0666.'; break; } // Fall through to the next case // Fall through to the next case case 2: @set_time_limit(300); // Check to see if all upgrade files are intact $check = $this->get['from']; while ($check <= LATEST) { if (!is_readable("./upgrade_{$check}.php")) { echo "A file required for upgrading was not found: upgrade_{$check}.php"; break 2; } $check++; } $db = new $this->modules['database']($this->sets['db_host'], $this->sets['db_user'], $this->sets['db_pass'], $this->sets['db_name'], $this->sets['db_port'], $this->sets['db_socket'], $this->sets['prefix']); if (!$db->connection) { if ($this->get['step'] == 15) { $sets_error = '<br />Could not connect with the specified information.'; } else { $sets_error = null; } include 'templates/upgradefromdatabase.php'; break; } $queries = array(); $pre = $this->sets['prefix']; $full_template_list = false; $template_list = array(); $new_permissions = array(); $this->sets['installed'] = 1; $this->pre = $this->sets['prefix']; $this->db = $db; // We can't get settings from the database unless we're already running >= 1.1.0 if ($this->get['from'] >= 10) { $this->sets = $this->get_settings($this->sets); } $this->perms = new $this->modules['permissions']($this); while ($this->get['from'] <= LATEST) { include "./upgrade_{$this->get['from']}.php"; $this->get['from']++; // This gets really complicated so be careful if (is_bool($need_templates)) { if ($need_templates) { $full_template_list = true; } } else { $template_list = array_unique(array_merge($template_list, $need_templates)); } } /** * The order this next block executes is important. * 1. Verify we can upgrade templates * 2. Upgrade board * 3. Upgrade templates * * Because the query used to upgrade templates is for * the most recent version of the board, we must run * it after the board is fully upgraded. **/ if ($need_templates && !is_readable(SKIN_FILE)) { echo 'No templates could be loaded from ' . SKIN_FILE; break; } execute_queries($queries, $this->db); $queries = array(); // Check the default skin still exists $result = $this->db->fetch("SELECT * FROM %pskins WHERE skin_dir='default'"); if (!$result) { $this->db->query("INSERT INTO %pskins (skin_name, skin_dir) VALUES ('QSF Comet', 'default')"); $full_template_list = true; } $skinsupdated = "The following templates were upgraded:<br /><br /><span class='tiny'>"; $didsomething = false; $result = $this->db->query("SELECT * FROM %pskins"); while ($row = $this->db->nqfetch($result)) { $skin = $row['skin_dir']; // QSF or MB default skin in default location if (($row['skin_name'] == 'QSF Comet' || $row['skin_name'] == 'Candy Corn') && $skin == 'default') { if ($full_template_list || $template_list) { if ($full_template_list) { $template_list = null; $this->db->query("DELETE FROM %ptemplates WHERE template_skin='default'"); $skinsupdated .= $row['skin_name'] . ": Full Template Replacement<br />"; } else { $template_list_string = ''; foreach ($template_list as $temp_name) { $template_list_string .= "'{$temp_name}',"; $skinsupdated .= $row['skin_name'] . ": " . $temp_name . "<br />"; } $template_list_string = substr($template_list_string, 0, -1); $this->db->query("DELETE FROM %ptemplates WHERE template_name IN ({$template_list_string}) AND template_skin='default'"); } // Create template $xmlInfo = new xmlparser(); $xmlInfo->parse(SKIN_FILE); $templatesNode = $xmlInfo->GetNodeByPath('QSFMOD/TEMPLATES'); packageutil::insert_templates('default', $this->db, $templatesNode, $template_list); unset($templatesNode); $xmlInfo = null; $didsomething = true; } if ($row['skin_name'] == 'Candy Corn') { $this->db->query("UPDATE %pskins SET skin_name='QSF Comet' WHERE skin_dir='%s'", $skin); } } else { // Other skins $xmlInfo = new xmlparser(); $xmlInfo->parse(SKIN_FILE); $templatesNode = $xmlInfo->GetNodeByPath('QSFMOD/TEMPLATES'); $temp_names = packageutil::list_templates($templatesNode); $temps_to_insert = array(); foreach ($temp_names as $temp_name) { $miss = $this->db->query("SELECT template_name FROM %ptemplates WHERE template_skin='%s' AND template_name='%s'", $skin, $temp_name); if ($this->db->num_rows($miss) < 1) { $skinsupdated .= $row['skin_name'] . ": Added: " . $temp_name . "<br />"; $temps_to_insert[] = $temp_name; } } if ($temps_to_insert) { $templatesNode = $xmlInfo->GetNodeByPath('QSFMOD/TEMPLATES'); packageutil::insert_templates($skin, $this->db, $templatesNode, $temps_to_insert); $didsomething = true; } $xmlInfo = null; } /* Iterate over all our templates. This is excessive, but only needs to be done once anyway. */ $sql = "SELECT template_html, template_name FROM {$this->pre}templates WHERE template_skin='{$skin}'"; $query = $this->db->query($sql); while ($row2 = $this->db->nqfetch($query)) { if (strstr($row2['template_html'], '{$messageclass}')) { $didsomething = true; $row2['template_html'] = str_replace('{$messageclass}', '<MODLET messagelink(class)>', $row2['template_html']); $updated_temps[] = $row['template_name']; $this->db->query("UPDATE %ptemplates SET template_html='%s' WHERE template_skin='%s' AND template_name='%s'", $row2['template_html'], $skin, $row2['template_name']); } if (strstr($row2['template_html'], '{$MessageLink}')) { $didsomething = true; $row2['template_html'] = str_replace('{$MessageLink}', '<MODLET messagelink(text)>', $row2['template_html']); $skinsupdated .= $row['skin_name'] . " Modified: " . $row2['template_name'] . "<br />"; $this->db->query("UPDATE %ptemplates SET template_html='%s' WHERE template_skin='%s' AND template_name='%s'", $row2['template_html'], $skin, $row2['template_name']); } if (strstr($row2['template_html'], '$mercury')) { $didsomething = true; $row2['template_html'] = str_replace('$mercury', '$qsf', $row2['template_html']); $skinsupdated .= $row['skin_name'] . " Modified: " . $row2['template_name'] . "<br />"; $this->db->query("UPDATE %ptemplates SET template_html='%s' WHERE template_skin='%s' AND template_name='%s'", $row2['template_html'], $skin, $row2['template_name']); } if (strstr($row2['template_html'], '$qsfboard')) { $didsomething = true; $row2['template_html'] = str_replace('$qsfboard', '$quicksilverforums', $row2['template_html']); $skinsupdated .= $row['skin_name'] . " Modified: " . $row2['template_name'] . "<br />"; $this->db->query("UPDATE %ptemplates SET template_html='%s' WHERE template_skin='%s' AND template_name='%s'", $row2['template_html'], $skin, $row2['template_name']); } if (strstr($row2['template_html'], '$qsf->lang->main_powered')) { $didsomething = true; $row2['template_html'] = str_replace('$qsf->lang->main_powered', '$qsf->lang->powered', $row2['template_html']); $skinsupdated .= $row['skin_name'] . " Modified: " . $row2['template_name'] . "<br />"; $this->db->query("UPDATE %ptemplates SET template_html='%s' WHERE template_skin='%s' AND template_name='%s'", $row2['template_html'], $skin, $row2['template_name']); } if (strstr($row2['template_html'], '$qsf->lang->main_seconds')) { $didsomething = true; $row2['template_html'] = str_replace('$qsf->lang->main_seconds', '$qsf->lang->seconds', $row2['template_html']); $skinsupdated .= $row['skin_name'] . " Modified: " . $row2['template_name'] . "<br />"; $this->db->query("UPDATE %ptemplates SET template_html='%s' WHERE template_skin='%s' AND template_name='%s'", $row2['template_html'], $skin, $row2['template_name']); } if (strstr($row2['template_html'], '$this->lang->pm_inbox')) { $didsomething = true; $row2['template_html'] = str_replace('$this->lang->pm_inbox', '$foldername', $row2['template_html']); $skinsupdated .= $row['skin_name'] . " Modified: " . $row2['template_name'] . "<br />"; $this->db->query("UPDATE %ptemplates SET template_html='%s' WHERE template_skin='%s' AND template_name='%s'", $row2['template_html'], $skin, $row2['template_name']); } if (strstr($row2['template_html'], '$this->lang->board_topics_new')) { $didsomething = true; $row2['template_html'] = str_replace('$this->lang->board_topics_new', '$this->lang->main_topics_new', $row2['template_html']); $skinsupdated .= $row['skin_name'] . " Modified: " . $row2['template_name'] . "<br />"; $this->db->query("UPDATE %ptemplates SET template_html='%s' WHERE template_skin='%s' AND template_name='%s'", $row2['template_html'], $skin, $row2['template_name']); } if (strstr($row2['template_html'], '$this->lang->forum_topics_new')) { $didsomething = true; $row2['template_html'] = str_replace('$this->lang->forum_topics_new', '$this->lang->main_topics_new', $row2['template_html']); $skinsupdated .= $row['skin_name'] . " Modified: " . $row2['template_name'] . "<br />"; $this->db->query("UPDATE %ptemplates SET template_html='%s' WHERE template_skin='%s' AND template_name='%s'", $row2['template_html'], $skin, $row2['template_name']); } if (strstr($row2['template_html'], '$this->lang->recent_topics_new')) { $didsomething = true; $row2['template_html'] = str_replace('$this->lang->recent_topics_new', '$this->lang->main_topics_new', $row2['template_html']); $skinsupdated .= $row['skin_name'] . " Modified: " . $row2['template_name'] . "<br />"; $this->db->query("UPDATE %ptemplates SET template_html='%s' WHERE template_skin='%s' AND template_name='%s'", $row2['template_html'], $skin, $row2['template_name']); } if (strstr($row2['template_html'], 'post_mbcode_')) { $didsomething = true; $row2['template_html'] = str_replace('post_mbcode_', 'mbcode_', $row2['template_html']); $skinsupdated .= $row['skin_name'] . " Modified: " . $row2['template_name'] . "<br />"; $this->db->query("UPDATE %ptemplates SET template_html='%s' WHERE template_skin='%s' AND template_name='%s'", $row2['template_html'], $skin, $row2['template_name']); } if (strstr($row2['template_html'], '$qsf->tree')) { $didsomething = true; $row2['template_html'] = str_replace('$qsf->tree', '$qsf->htmlwidgets->tree', $row2['template_html']); $skinsupdated .= $row['skin_name'] . " Modified: " . $row2['template_name'] . "<br />"; $this->db->query("UPDATE %ptemplates SET template_html='%s' WHERE template_skin='%s' AND template_name='%s'", $row2['template_html'], $skin, $row2['template_name']); } if (strstr($row2['template_html'], '$admin->tree')) { $didsomething = true; $row2['template_html'] = str_replace('$admin->tree', '$admin->htmlwidgets->tree', $row2['template_html']); $skinsupdated .= $row['skin_name'] . " Modified: " . $row2['template_name'] . "<br />"; $this->db->query("UPDATE %ptemplates SET template_html='%s' WHERE template_skin='%s' AND template_name='%s'", $row2['template_html'], $skin, $row2['template_name']); } if (strstr($row2['template_html'], '$this->tree')) { $didsomething = true; $row2['template_html'] = str_replace('$this->tree', '$this->htmlwidgets->tree', $row2['template_html']); $skinsupdated .= $row['skin_name'] . " Modified: " . $row2['template_name'] . "<br />"; $this->db->query("UPDATE %ptemplates SET template_html='%s' WHERE template_skin='%s' AND template_name='%s'", $row2['template_html'], $skin, $row2['template_name']); } if (strstr($row2['template_html'], '{$active[\'TOTALCOUNT\']}')) { $didsomething = true; $row2['template_html'] = str_replace('{$active[\'TOTALCOUNT\']}', 'Skin Update Required', $row2['template_html']); $skinsupdated .= $row['skin_name'] . " Modified: " . $row2['template_name'] . "<br />"; $this->db->query("UPDATE %ptemplates SET template_html='%s' WHERE template_skin='%s' AND template_name='%s'", $row2['template_html'], $skin, $row2['template_name']); } if (strstr($row2['template_html'], '{$active[\'MEMBERCOUNT\']}')) { $didsomething = true; $row2['template_html'] = str_replace('{$active[\'MEMBERCOUNT\']}', 'Skin Update Required', $row2['template_html']); $skinsupdated .= $row['skin_name'] . " Modified: " . $row2['template_name'] . "<br />"; $this->db->query("UPDATE %ptemplates SET template_html='%s' WHERE template_skin='%s' AND template_name='%s'", $row2['template_html'], $skin, $row2['template_name']); } if (strstr($row2['template_html'], '{$active[\'GUESTCOUNT\']}')) { $didsomething = true; $row2['template_html'] = str_replace('{$active[\'GUESTCOUNT\']}', 'Skin Update Required', $row2['template_html']); $skinsupdated .= $row['skin_name'] . " Modified: " . $row2['template_name'] . "<br />"; $this->db->query("UPDATE %ptemplates SET template_html='%s' WHERE template_skin='%s' AND template_name='%s'", $row2['template_html'], $skin, $row2['template_name']); } if (strstr($row2['template_html'], '{$active[\'USERS\']}')) { $didsomething = true; $row2['template_html'] = str_replace('{$active[\'USERS\']}', 'Skin Update Required', $row2['template_html']); $skinsupdated .= $row['skin_name'] . " Modified: " . $row2['template_name'] . "<br />"; $this->db->query("UPDATE %ptemplates SET template_html='%s' WHERE template_skin='%s' AND template_name='%s'", $row2['template_html'], $skin, $row2['template_name']); } } } $this->write_sets(); // New fields in forum tables need to be fixed in case the old install was a conversion $this->updateForumTrees(); $this->RecountForums(); // Check if new permissions need to be added if (!empty($new_permissions)) { foreach ($new_permissions as $id => $default) { // Groups while ($this->perms->get_group()) { $perm_on = $default; if ($this->perms->auth('is_admin')) { $perm_on = true; } if (!$this->perms->auth('do_anything')) { $perm_on = false; } if ($this->perms->is_guest) { $perm_on = false; } $this->perms->add_perm($id, $perm_on); $this->perms->update(); } // Users while ($this->perms->get_group(true)) { $perm_on = $default; if ($this->perms->auth('is_admin')) { $perm_on = true; } if (!$this->perms->auth('do_anything')) { $perm_on = false; } if ($this->perms->is_guest) { $perm_on = false; } $this->perms->add_perm($id, $perm_on); $this->perms->update(); } } } $message = ''; if ($didsomething) { $message = $skinsupdated . "</span>"; } echo $message . "<br />Upgrade successful.<br />"; echo "<a href='../index.php'>To the board</a>"; break; } }
function install_board($step) { switch ($step) { default: $url = preg_replace('/install\\/?$/i', '', $this->server_url() . dirname($_SERVER['PHP_SELF'])); echo "<form action='{$this->self}?mode=new_install&step=2' method='post'>\n <table border='0' cellpadding='4' cellspacing='0'>\n"; check_writeable_files(); include 'templates/newdatabase.php'; include 'templates/newboardsettings.php'; include 'templates/newadmin.php'; include 'templates/newseeddata.php'; echo "<tr>\n <td class='subheader' colspan='2' align='center'><input type='submit' value='Continue' /></td>\n </tr>\n </table>\n </form>"; break; case 2: $db = new $this->modules['database']($this->post['db_host'], $this->post['db_user'], $this->post['db_pass'], $this->post['db_name'], $this->post['db_port'], $this->post['db_socket'], $this->post['prefix']); if (!$db->connection) { echo "Couldn't connect to a database using the specified information."; break; } // load the installer SQL $db->install(); $this->db =& $db; $this->sets['db_host'] = $this->post['db_host']; $this->sets['db_user'] = $this->post['db_user']; $this->sets['db_pass'] = $this->post['db_pass']; $this->sets['db_name'] = $this->post['db_name']; $this->sets['db_port'] = $this->post['db_port']; $this->sets['db_socket'] = $this->post['db_socket']; $this->sets['prefix'] = trim(preg_replace('/[^a-zA-Z0-9_]/', '', $this->post['prefix'])); if (!$this->write_db_sets('../settings.php') && !isset($this->post['downloadsettings'])) { echo "The database connection was ok, but settings.php could not be updated.<br />\n"; echo "You can CHMOD settings.php to 0666 and hit reload to try again<br/>\n"; echo "Or you can force the install to continue and download the new settings.php file "; echo "so you can later place it on the website manually<br/>\n"; echo "<form action=\"{$this->self}?mode=new_install&step=2\" method=\"post\">\n\n\t\t\t\t\t<input type=\"hidden\" name=\"downloadsettings\" value=\"yes\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"db_host\" value=\"" . htmlspecialchars($this->post['db_host']) . "\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"db_name\" value=\"" . htmlspecialchars($this->post['db_name']) . "\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"db_user\" value=\"" . htmlspecialchars($this->post['db_user']) . "\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"db_pass\" value=\"" . htmlspecialchars($this->post['db_pass']) . "\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"db_port\" value=\"" . htmlspecialchars($this->post['db_port']) . "\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"db_socket\" value=\"" . htmlspecialchars($this->post['db_socket']) . "\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"prefix\" value=\"" . htmlspecialchars($this->post['prefix']) . "\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"board_name\" value=\"" . htmlspecialchars($this->post['board_name']) . "\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"board_url\" value=\"" . htmlspecialchars($this->post['board_url']) . "\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"admin_name\" value=\"" . htmlspecialchars($this->post['admin_name']) . "\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"admin_pass\" value=\"" . htmlspecialchars($this->post['admin_pass']) . "\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"admin_pass2\" value=\"" . htmlspecialchars($this->post['admin_pass2']) . "\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"admin_email\" value=\"" . htmlspecialchars($this->post['admin_email']) . "\" />\n\n\t\t\t\t\t"; if (isset($this->post['seed_data']) && $this->post['seed_data']) { echo "<input type=\"hidden\" name=\"seed_data\" value=\"yes\" />\n"; } echo "<input type=\"submit\" value=\"Force Install\" />\n\t\t\t\t\t</form>\n\t\t\t\t\t "; break; } $filename = './' . $this->sets['dbtype'] . '_data_tables.php'; if (!is_readable($filename)) { echo 'Database connected, settings written, but no tables could be loaded from file: ' . $filename; break; } if (!is_readable(SKIN_FILE)) { echo 'Database connected, settings written, but no templates could be loaded from file: ' . SKIN_FILE; break; } if (trim($this->post['admin_name']) == '' || trim($this->post['admin_pass']) == '' || trim($this->post['admin_email']) == '') { echo 'You have not specified an admistrator account. Please go back and correct this error.'; break; } if ($this->post['admin_pass'] != $this->post['admin_pass2']) { echo 'Your administrator passwords do not match. Please go back and correct this error.'; break; } if (isset($this->post['seed_data']) && $this->post['seed_data'] && !is_readable('./seed_data.php')) { echo 'Database connected, settings written, but no seed data could be loaded from file: seed_data.php'; break; } $queries = array(); $pre = $this->sets['prefix']; $this->pre = $this->sets['prefix']; // Build settings array for the DB $this->sets['attach_types'] = array('jpg', 'gif', 'png', 'bmp', 'zip', 'tgz', 'gz', 'rar'); $this->sets['attach_upload_size'] = 25600; $this->sets['avatar_height'] = 75; $this->sets['avatar_upload_size'] = 51200; $this->sets['avatar_width'] = 75; $this->sets['banned_ips'] = array(); $this->sets['clickable_per_row'] = 5; $this->sets['closed'] = 0; $this->sets['closedtext'] = 'We are upgrading to the latest version of Quicksilver Forums. Please check back later.'; $this->sets['cookie_path'] = '/'; $this->sets['cookie_prefix'] = 'qsf_'; $this->sets['cookie_domain'] = ''; $this->sets['cookie_secure'] = 0; $this->sets['emailactivation'] = 1; $this->sets['flash_avs'] = 1; $this->sets['flood_time'] = 30; $this->sets['hot_limit'] = 20; $this->sets['loc_of_board'] = $this->post['board_url']; $this->sets['forum_name'] = $this->post['board_name']; $this->sets['last_member'] = ''; $this->sets['last_member_id'] = 0; $this->sets['link_target'] = '_blank'; $this->sets['logintime'] = 31536000; $this->sets['mailserver'] = 'localhost'; $this->sets['max_load'] = 0; $this->sets['mostonline'] = 0; $this->sets['mostonlinetime'] = 0; $this->sets['output_buffer'] = extension_loaded('zlib') ? 1 : 0; $this->sets['posts'] = 0; $this->sets['posts_per_page'] = 15; $this->sets['register_image'] = 0; $this->sets['servertime'] = 151; $this->sets['topics'] = 0; $this->sets['topics_per_page'] = 20; $this->sets['vote_after_results'] = 0; $this->sets['default_skin'] = 'default'; $this->sets['default_email_shown'] = 0; $this->sets['default_lang'] = 'en'; $this->sets['default_group'] = 2; $this->sets['default_timezone'] = 151; $this->sets['default_pm'] = 1; $this->sets['default_view_avatars'] = 1; $this->sets['default_view_sigs'] = 1; $this->sets['default_view_emots'] = 1; $this->sets['flood_time_pm'] = 30; $this->sets['flood_time_search'] = 10; $this->sets['members'] = 0; $this->sets['spider_active'] = 1; $this->sets['spider_name'] = array('googlebot' => 'Google', 'lycos' => 'Google', 'ask jeeves' => 'Google', 'scooter' => 'Altavista', 'fast-webcrawler' => 'AlltheWeb', 'slurp@inktomi' => 'Inktomi', 'turnitinbot' => 'Turnitin.com', 'gigabot' => 'Gigabot', 'yahoo' => 'Yahoo! Slurp', 'msnbot' => 'MSN Search', 'mediapartners-google' => 'AdSense', 'naverbot' => 'Naver', 'jetbot' => 'JetEye', 'alexa' => 'Alexa', 'ArchitextSpider' => 'Excite-Bot', 'pipeLiner' => 'PipeLine Spider'); $this->sets['debug_mode'] = 0; $this->sets['rss_feed_title'] = ''; $this->sets['rss_feed_desc'] = ''; $this->sets['rss_feed_posts'] = 5; $this->sets['rss_feed_time'] = 60; $this->sets['optional_modules'] = array('active', 'cp', 'email', 'help', 'members', 'mod', 'pm', 'profile', 'search', 'recent', 'rssfeed'); $settings = serialize($this->sets); // Create tables include './' . $this->sets['dbtype'] . '_data_tables.php'; execute_queries($queries, $db); $queries = null; // Create template $xmlInfo = new xmlparser(); $xmlInfo->parse(SKIN_FILE); $templatesNode = $xmlInfo->GetNodeByPath('QSFMOD/TEMPLATES'); packageutil::insert_templates('default', $this->db, $templatesNode); unset($templatesNode); $xmlInfo = null; $this->post['admin_pass'] = md5($this->post['admin_pass']); if (get_magic_quotes_gpc()) { $this->unset_magic_quotes_gpc($this->get); $this->unset_magic_quotes_gpc($this->post); $this->unset_magic_quotes_gpc($this->cookie); } $this->post['admin_name'] = str_replace(array('&#', '\''), array('&#', '''), htmlspecialchars($this->post['admin_name'])); $this->db->query($this->db->install_new_user, $this->post['admin_name'], $this->post['admin_pass'], USER_ADMIN, $this->time, $this->post['admin_email'], $this->sets['servertime']); $admin_uid = $this->db->insert_id("users"); $this->sets['last_member'] = $this->post['admin_name']; $this->sets['last_member_id'] = $admin_uid; $this->sets['admin_incoming'] = $this->post['admin_email']; $this->sets['admin_outgoing'] = $this->post['admin_email']; $this->sets['members']++; $this->sets['installed'] = 1; if (isset($this->post['seed_data']) && $this->post['seed_data']) { include './seed_data.php'; // Create Category $categoryId = $this->create_forum($categoryName, $categoryDesc, 0); // Create Forum $forumId = $this->create_forum($forumName, $forumDesc, $categoryId); // Create Topic $this->db->query($this->db->install_seed_topic_create, $topicName, $forumId, $topicDesc, $admin_uid, $topicIcon, $this->time, $this->time, $admin_uid, TOPIC_PUBLISH); $topicId = $this->db->insert_id("topics"); // Create Post $this->db->query($this->db->install_seed_post_create, $topicId, $admin_uid, $topicPost, $this->time, $this->ip, $topicIcon); $postId = $this->db->insert_id("posts"); $this->db->query($this->db->install_seed_update_topic, $postId, $topicId); $this->db->query($this->db->install_seed_update_user, $this->time, $admin_uid); $this->db->query($this->db->install_seed_update_forums, $postId, $forumId); $this->sets['topics']++; $this->sets['posts']++; } $writeSetsWorked = $this->write_db_sets('../settings.php'); $this->write_sets(); setcookie($this->sets['cookie_prefix'] . 'user', $admin_uid, $this->time + $this->sets['logintime'], $this->sets['cookie_path'], $this->sets['cookie_domain'], $this->sets['cookie_secure'], true); setcookie($this->sets['cookie_prefix'] . 'pass', $this->post['admin_pass'], $this->time + $this->sets['logintime'], $this->sets['cookie_path'], $this->sets['cookie_domain'], $this->sets['cookie_secure'], true); if (!$writeSetsWorked) { echo "Congratulations! Your board has been installed.<br />\n\t\t\t\tAn administrator account was registered.<br />"; echo "Click here to download your settings.php file. You must put this file on the webhost before the board is ready to use<br/>\n"; echo "<form action=\"{$this->self}?mode=new_install&step=3\" method=\"post\">\n\n\t\t\t\t\t<input type=\"hidden\" name=\"db_host\" value=\"" . htmlspecialchars($this->post['db_host']) . "\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"db_name\" value=\"" . htmlspecialchars($this->post['db_name']) . "\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"db_user\" value=\"" . htmlspecialchars($this->post['db_user']) . "\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"db_pass\" value=\"" . htmlspecialchars($this->post['db_pass']) . "\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"db_port\" value=\"" . htmlspecialchars($this->post['db_port']) . "\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"db_socket\" value=\"" . htmlspecialchars($this->post['db_socket']) . "\" />\n\n\t\t\t\t\t<input type=\"hidden\" name=\"prefix\" value=\"" . htmlspecialchars($this->post['prefix']) . "\" />\n\n\t\t\t\t\t<input type=\"submit\" value=\"Download settings.php\" />\n\t\t\t\t\t</form>\n\t\t\t\t\t<br/>\n\n\t\t\t\t\tOnce this is done: REMEMBER TO DELETE THE INSTALL DIRECTORY!<br /><br />\n\t\t\t\t\t<a href='../index.php'>Go to your board.</a>\n\t\t\t\t\t "; } else { echo "Congratulations! Your board has been installed.<br />\n\t\t\t\tAn administrator account was registered.<br />\n\t\t\t\tREMEMBER TO DELETE THE INSTALL DIRECTORY!<br /><br />\n\t\t\t\t<a href='../index.php'>Go to your board.</a>"; } break; case 3: // Give them the settings.php file $this->sets['db_host'] = $this->post['db_host']; $this->sets['db_user'] = $this->post['db_user']; $this->sets['db_pass'] = $this->post['db_pass']; $this->sets['db_name'] = $this->post['db_name']; $this->sets['db_port'] = $this->post['db_port']; $this->sets['db_socket'] = $this->post['db_socket']; $this->sets['installed'] = 1; $this->sets['prefix'] = trim(preg_replace('/[^a-zA-Z0-9_]/', '', $this->post['prefix'])); $settingsFile = $this->create_settings_file(); ob_clean(); header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=\"settings.php\""); echo $settingsFile; exit; break; } }