/** * Checks which databases the server can run * * @return bool Return true if it can run MySQL; false if not */ function checkDB() { $available_dbms = array('mysql' => array('LABEL' => 'MySQL', 'SCHEMA' => 'mysql', 'MODULE' => 'mysql', 'DELIM' => ';', 'COMMENTS' => 'remove_remarks', 'DRIVER' => 'mysql', 'AVAILABLE' => true, '2.0.x' => true)); foreach ($available_dbms as $db_name => $db_ary) { if ($only_20x_options and !$db_ary['2.0.x']) { if ($return_unavailable) { $available_dbms[$db_name]['AVAILABLE'] = false; } else { unset($available_dbms[$db_name]); } continue; } $dll = $db_ary['MODULE']; if (!@extension_loaded($dll)) { if (!can_load_dll($dll)) { if ($return_unavailable) { $available_dbms[$db_name]['AVAILABLE'] = false; } else { unset($available_dbms[$db_name]); } continue; } } $any_db_support = true; } if ($any_db_support) { $check = true; } else { $check = false; } return $check; }
function is_available() { if (@extension_loaded('gd')) { return true; } if (!function_exists('can_load_dll')) { include IP_ROOT_PATH . 'includes/functions_install.' . PHP_EXT; } return can_load_dll('gd'); }
function is_available() { global $phpbb_root_path, $phpEx; if (@extension_loaded('gd')) { return true; } if (!function_exists('can_load_dll')) { include $phpbb_root_path . 'includes/functions_install.' . $phpEx; } return can_load_dll('gd'); }
/** * Returns an array of available DBMS with some data, if a DBMS is specified it will only * return data for that DBMS and will load its extension if necessary. */ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20x_options = false) { global $lang; $available_dbms = array('firebird' => array('LABEL' => 'FireBird', 'SCHEMA' => 'firebird', 'MODULE' => 'interbase', 'DELIM' => ';;', 'COMMENTS' => 'remove_remarks', 'DRIVER' => 'firebird', 'AVAILABLE' => true, '2.0.x' => false), 'mysqli' => array('LABEL' => 'MySQL with MySQLi Extension', 'SCHEMA' => 'mysql_41', 'MODULE' => 'mysqli', 'DELIM' => ';', 'COMMENTS' => 'remove_remarks', 'DRIVER' => 'mysqli', 'AVAILABLE' => true, '2.0.x' => true), 'mysql' => array('LABEL' => 'MySQL', 'SCHEMA' => 'mysql', 'MODULE' => 'mysql', 'DELIM' => ';', 'COMMENTS' => 'remove_remarks', 'DRIVER' => 'mysql', 'AVAILABLE' => true, '2.0.x' => true), 'mssql' => array('LABEL' => 'MS SQL Server 2000+', 'SCHEMA' => 'mssql', 'MODULE' => 'mssql', 'DELIM' => 'GO', 'COMMENTS' => 'remove_comments', 'DRIVER' => 'mssql', 'AVAILABLE' => true, '2.0.x' => true), 'mssql_odbc' => array('LABEL' => 'MS SQL Server [ ODBC ]', 'SCHEMA' => 'mssql', 'MODULE' => 'odbc', 'DELIM' => 'GO', 'COMMENTS' => 'remove_comments', 'DRIVER' => 'mssql_odbc', 'AVAILABLE' => true, '2.0.x' => true), 'mssqlnative' => array('LABEL' => 'MS SQL Server 2005+ [ Native ]', 'SCHEMA' => 'mssql', 'MODULE' => 'sqlsrv', 'DELIM' => 'GO', 'COMMENTS' => 'remove_comments', 'DRIVER' => 'mssqlnative', 'AVAILABLE' => true, '2.0.x' => false), 'oracle' => array('LABEL' => 'Oracle', 'SCHEMA' => 'oracle', 'MODULE' => 'oci8', 'DELIM' => '/', 'COMMENTS' => 'remove_comments', 'DRIVER' => 'oracle', 'AVAILABLE' => true, '2.0.x' => false), 'postgres' => array('LABEL' => 'PostgreSQL 7.x/8.x', 'SCHEMA' => 'postgres', 'MODULE' => 'pgsql', 'DELIM' => ';', 'COMMENTS' => 'remove_comments', 'DRIVER' => 'postgres', 'AVAILABLE' => true, '2.0.x' => true), 'sqlite' => array('LABEL' => 'SQLite', 'SCHEMA' => 'sqlite', 'MODULE' => 'sqlite', 'DELIM' => ';', 'COMMENTS' => 'remove_remarks', 'DRIVER' => 'sqlite', 'AVAILABLE' => true, '2.0.x' => false)); if ($dbms) { if (isset($available_dbms[$dbms])) { $available_dbms = array($dbms => $available_dbms[$dbms]); } else { return array(); } } // now perform some checks whether they are really available foreach ($available_dbms as $db_name => $db_ary) { if ($only_20x_options && !$db_ary['2.0.x']) { if ($return_unavailable) { $available_dbms[$db_name]['AVAILABLE'] = false; } else { unset($available_dbms[$db_name]); } continue; } $dll = $db_ary['MODULE']; if (!@extension_loaded($dll)) { if (!can_load_dll($dll)) { if ($return_unavailable) { $available_dbms[$db_name]['AVAILABLE'] = false; } else { unset($available_dbms[$db_name]); } continue; } } $any_db_support = true; } if ($return_unavailable) { $available_dbms['ANY_DB_SUPPORT'] = $any_db_support; } return $available_dbms; }
/** * Returns an array of available DBMS with some data, if a DBMS is specified it will only * return data for that DBMS and will load its extension if necessary. */ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20x_options = false) { global $lang; $available_dbms = array('mysqli' => array('LABEL' => 'MySQL with MySQLi Extension', 'SCHEMA' => 'mysql_41', 'MODULE' => 'mysqli', 'DELIM' => ';', 'COMMENTS' => 'remove_remarks', 'DRIVER' => 'mysqli', 'AVAILABLE' => true, '2.0.x' => true), 'mysql' => array('LABEL' => 'MySQL', 'SCHEMA' => 'mysql', 'MODULE' => 'mysql', 'DELIM' => ';', 'COMMENTS' => 'remove_remarks', 'DRIVER' => 'mysql', 'AVAILABLE' => true, '2.0.x' => true)); if ($dbms) { if (isset($available_dbms[$dbms])) { $available_dbms = array($dbms => $available_dbms[$dbms]); } else { return array(); } } // now perform some checks whether they are really available foreach ($available_dbms as $db_name => $db_ary) { if ($only_20x_options && !$db_ary['2.0.x']) { if ($return_unavailable) { $available_dbms[$db_name]['AVAILABLE'] = false; } else { unset($available_dbms[$db_name]); } continue; } $dll = $db_ary['MODULE']; if (!@extension_loaded($dll)) { if (!can_load_dll($dll)) { if ($return_unavailable) { $available_dbms[$db_name]['AVAILABLE'] = false; } else { unset($available_dbms[$db_name]); } continue; } } $any_db_support = true; } if ($return_unavailable) { $available_dbms['ANY_DB_SUPPORT'] = $any_db_support; } return $available_dbms; }
/** * Load the contents of the schema into the database and then alter it based on what has been input during the installation */ function load_schema($mode, $sub) { global $db, $lang, $template, $phpbb_root_path, $phpEx; $this->page_title = $lang['STAGE_CREATE_TABLE']; $s_hidden_fields = ''; // Obtain any submitted data $data = $this->get_submitted_data(); if ($data['dbms'] == '') { // Someone's been silly and tried calling this page direct // So we send them back to the start to do it again properly $this->p_master->redirect("index.$phpEx?mode=install"); } // HTTP_HOST is having the correct browser url in most cases... $server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME')); $referer = (!empty($_SERVER['HTTP_REFERER'])) ? strtolower($_SERVER['HTTP_REFERER']) : getenv('HTTP_REFERER'); // HTTP HOST can carry a port number... if (strpos($server_name, ':') !== false) { $server_name = substr($server_name, 0, strpos($server_name, ':')); } $cookie_domain = ($data['server_name'] != '') ? $data['server_name'] : $server_name; // Try to come up with the best solution for cookie domain... if (strpos($cookie_domain, 'www.') === 0) { $cookie_domain = str_replace('www.', '.', $cookie_domain); } // If we get here and the extension isn't loaded it should be safe to just go ahead and load it $available_dbms = get_available_dbms($data['dbms']); if (!isset($available_dbms[$data['dbms']])) { // Someone's been silly and tried providing a non-existant dbms $this->p_master->redirect("index.$phpEx?mode=install"); } $dbms = $available_dbms[$data['dbms']]['DRIVER']; // Load the appropriate database class if not already loaded include($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); // Instantiate the database $db = new $sql_db(); $db->sql_connect($data['dbhost'], $data['dbuser'], htmlspecialchars_decode($data['dbpasswd']), $data['dbname'], $data['dbport'], false, false); // NOTE: trigger_error does not work here. $db->sql_return_on_error(true); // If mysql is chosen, we need to adjust the schema filename slightly to reflect the correct version. ;) if ($data['dbms'] == 'mysql') { if (version_compare($db->sql_server_info(true), '4.1.3', '>=')) { $available_dbms[$data['dbms']]['SCHEMA'] .= '_41'; } else { $available_dbms[$data['dbms']]['SCHEMA'] .= '_40'; } } // Ok we have the db info go ahead and read in the relevant schema // and work on building the table $dbms_schema = 'schemas/' . $available_dbms[$data['dbms']]['SCHEMA'] . '_schema.sql'; // How should we treat this schema? $remove_remarks = $available_dbms[$data['dbms']]['COMMENTS']; $delimiter = $available_dbms[$data['dbms']]['DELIM']; $sql_query = @file_get_contents($dbms_schema); $sql_query = preg_replace('#phpbb_#i', $data['table_prefix'], $sql_query); $remove_remarks($sql_query); $sql_query = split_sql_file($sql_query, $delimiter); foreach ($sql_query as $sql) { //$sql = trim(str_replace('|', ';', $sql)); if (!$db->sql_query($sql)) { $error = $db->sql_error(); $this->p_master->db_error($error['message'], $sql, __LINE__, __FILE__); } } unset($sql_query); // Ok tables have been built, let's fill in the basic information $sql_query = file_get_contents('schemas/schema_data.sql'); // Deal with any special comments switch ($data['dbms']) { case 'mssql': case 'mssql_odbc': $sql_query = preg_replace('#\# MSSQL IDENTITY (phpbb_[a-z_]+) (ON|OFF) \##s', 'SET IDENTITY_INSERT \1 \2;', $sql_query); break; case 'postgres': $sql_query = preg_replace('#\# POSTGRES (BEGIN|COMMIT) \##s', '\1; ', $sql_query); break; } // Change prefix $sql_query = preg_replace('#phpbb_#i', $data['table_prefix'], $sql_query); // Change language strings... $sql_query = preg_replace_callback('#\{L_([A-Z0-9\-_]*)\}#s', 'adjust_language_keys_callback', $sql_query); // Since there is only one schema file we know the comment style and are able to remove it directly with remove_remarks remove_remarks($sql_query); $sql_query = split_sql_file($sql_query, ';'); foreach ($sql_query as $sql) { //$sql = trim(str_replace('|', ';', $sql)); if (!$db->sql_query($sql)) { $error = $db->sql_error(); $this->p_master->db_error($error['message'], $sql, __LINE__, __FILE__); } } unset($sql_query); $current_time = time(); $user_ip = (!empty($_SERVER['REMOTE_ADDR'])) ? htmlspecialchars($_SERVER['REMOTE_ADDR']) : ''; if ($data['script_path'] !== '/') { // Adjust destination path (no trailing slash) if (substr($data['script_path'], -1) == '/') { $data['script_path'] = substr($data['script_path'], 0, -1); } $data['script_path'] = str_replace(array('../', './'), '', $data['script_path']); if ($data['script_path'][0] != '/') { $data['script_path'] = '/' . $data['script_path']; } } // Set default config and post data, this applies to all DB's $sql_ary = array( 'INSERT INTO ' . $data['table_prefix'] . "config (config_name, config_value) VALUES ('board_startdate', '$current_time')", 'INSERT INTO ' . $data['table_prefix'] . "config (config_name, config_value) VALUES ('default_lang', '" . $db->sql_escape($data['default_lang']) . "')", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($data['img_imagick']) . "' WHERE config_name = 'img_imagick'", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($data['server_name']) . "' WHERE config_name = 'server_name'", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($data['server_port']) . "' WHERE config_name = 'server_port'", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($data['board_email1']) . "' WHERE config_name = 'board_email'", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($data['board_email1']) . "' WHERE config_name = 'board_contact'", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($cookie_domain) . "' WHERE config_name = 'cookie_domain'", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($lang['default_dateformat']) . "' WHERE config_name = 'default_dateformat'", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($data['email_enable']) . "' WHERE config_name = 'email_enable'", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($data['smtp_delivery']) . "' WHERE config_name = 'smtp_delivery'", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($data['smtp_host']) . "' WHERE config_name = 'smtp_host'", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($data['smtp_auth']) . "' WHERE config_name = 'smtp_auth_method'", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($data['smtp_user']) . "' WHERE config_name = 'smtp_username'", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($data['smtp_pass']) . "' WHERE config_name = 'smtp_password'", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($data['cookie_secure']) . "' WHERE config_name = 'cookie_secure'", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($data['force_server_vars']) . "' WHERE config_name = 'force_server_vars'", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($data['script_path']) . "' WHERE config_name = 'script_path'", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($data['server_protocol']) . "' WHERE config_name = 'server_protocol'", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($data['admin_name']) . "' WHERE config_name = 'newest_username'", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . md5(mt_rand()) . "' WHERE config_name = 'avatar_salt'", 'UPDATE ' . $data['table_prefix'] . "users SET username = '******'admin_name']) . "', user_password='******'admin_pass1'])) . "', user_ip = '" . $db->sql_escape($user_ip) . "', user_lang = '" . $db->sql_escape($data['default_lang']) . "', user_email='" . $db->sql_escape($data['board_email1']) . "', user_dateformat='" . $db->sql_escape($lang['default_dateformat']) . "', user_email_hash = " . $db->sql_escape(phpbb_email_hash($data['board_email1'])) . ", username_clean = '" . $db->sql_escape(utf8_clean_string($data['admin_name'])) . "' WHERE username = '******'", 'UPDATE ' . $data['table_prefix'] . "moderator_cache SET username = '******'admin_name']) . "' WHERE username = '******'", 'UPDATE ' . $data['table_prefix'] . "forums SET forum_last_poster_name = '" . $db->sql_escape($data['admin_name']) . "' WHERE forum_last_poster_name = 'Admin'", 'UPDATE ' . $data['table_prefix'] . "topics SET topic_first_poster_name = '" . $db->sql_escape($data['admin_name']) . "', topic_last_poster_name = '" . $db->sql_escape($data['admin_name']) . "' WHERE topic_first_poster_name = 'Admin' OR topic_last_poster_name = 'Admin'", 'UPDATE ' . $data['table_prefix'] . "users SET user_regdate = $current_time", 'UPDATE ' . $data['table_prefix'] . "posts SET post_time = $current_time, poster_ip = '" . $db->sql_escape($user_ip) . "'", 'UPDATE ' . $data['table_prefix'] . "topics SET topic_time = $current_time, topic_last_post_time = $current_time", 'UPDATE ' . $data['table_prefix'] . "forums SET forum_last_post_time = $current_time", 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($db->sql_server_info(true)) . "' WHERE config_name = 'dbms_version'", ); if (@extension_loaded('gd') || can_load_dll('gd')) { $sql_ary[] = 'UPDATE ' . $data['table_prefix'] . "config SET config_value = 'phpbb_captcha_gd' WHERE config_name = 'captcha_plugin'"; $sql_ary[] = 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '1' WHERE config_name = 'captcha_gd'"; } $ref = substr($referer, strpos($referer, '://') + 3); if (!(stripos($ref, $server_name) === 0)) { $sql_ary[] = 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '0' WHERE config_name = 'referer_validation'"; } // We set a (semi-)unique cookie name to bypass login issues related to the cookie name. $cookie_name = 'phpbb3_'; $rand_str = md5(mt_rand()); $rand_str = str_replace('0', 'z', base_convert($rand_str, 16, 35)); $rand_str = substr($rand_str, 0, 5); $cookie_name .= strtolower($rand_str); $sql_ary[] = 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '" . $db->sql_escape($cookie_name) . "' WHERE config_name = 'cookie_name'"; foreach ($sql_ary as $sql) { //$sql = trim(str_replace('|', ';', $sql)); if (!$db->sql_query($sql)) { $error = $db->sql_error(); $this->p_master->db_error($error['message'], $sql, __LINE__, __FILE__); } } $submit = $lang['NEXT_STEP']; $url = $this->p_master->module_url . "?mode=$mode&sub=final"; $template->assign_vars(array( 'BODY' => $lang['STAGE_CREATE_TABLE_EXPLAIN'], 'L_SUBMIT' => $submit, 'S_HIDDEN' => build_hidden_fields($data), 'U_ACTION' => $url, )); }
/** * Checks that the server we are installing on meets the requirements for running phpBB */ function check_server_requirements($mode, $sub) { global $user, $template, $phpbb_root_path, $phpEx, $db; $this->page_title = $user->lang['STAGE_REQUIREMENTS']; $template->assign_vars(array('TITLE' => $user->lang['REQUIREMENTS_TITLE'], 'BODY' => $user->lang['REQUIREMENTS_EXPLAIN'])); $passed = array('php' => false, 'files' => false); // Test for basic PHP settings $template->assign_block_vars('checks', array('S_LEGEND' => true, 'LEGEND' => $user->lang['PHP_SETTINGS'], 'LEGEND_EXPLAIN' => $user->lang['PHP_SETTINGS_EXP'])); // Check for GD-Library if (@extension_loaded('gd') || can_load_dll('gd')) { $passed['php'] = true; $result = '<strong style="color:green">' . $user->lang['YES'] . '</strong>'; } else { $result = '<strong style="color:red">' . $user->lang['NO'] . '</strong>'; } $template->assign_block_vars('checks', array('TITLE' => $user->lang['REQ_GD_LIBRARY'], 'RESULT' => $result, 'S_EXPLAIN' => false, 'S_LEGEND' => false)); // Test for optional PHP settings $template->assign_block_vars('checks', array('S_LEGEND' => true, 'LEGEND' => $user->lang['PHP_SETTINGS_OPTIONAL'], 'LEGEND_EXPLAIN' => $user->lang['PHP_SETTINGS_OPTIONAL_EXP'])); // Image rotate if (function_exists('imagerotate')) { $result = '<strong style="color:green">' . $user->lang['YES'] . '</strong>'; } else { $gd_info = gd_info(); $result = '<strong style="color:red">' . $user->lang['NO'] . '</strong><br />' . sprintf($user->lang['OPTIONAL_IMAGEROTATE_EXP'], $gd_info['GD Version']); } $template->assign_block_vars('checks', array('TITLE' => $user->lang['OPTIONAL_IMAGEROTATE'], 'TITLE_EXPLAIN' => $user->lang['OPTIONAL_IMAGEROTATE_EXPLAIN'], 'RESULT' => $result, 'S_EXPLAIN' => true, 'S_LEGEND' => false)); // Exif data if (function_exists('exif_read_data')) { $result = '<strong style="color:green">' . $user->lang['YES'] . '</strong>'; } else { $result = '<strong style="color:red">' . $user->lang['NO'] . '</strong><br />' . $user->lang['OPTIONAL_EXIFDATA_EXP']; } $template->assign_block_vars('checks', array('TITLE' => $user->lang['OPTIONAL_EXIFDATA'], 'TITLE_EXPLAIN' => $user->lang['OPTIONAL_EXIFDATA_EXPLAIN'], 'RESULT' => $result, 'S_EXPLAIN' => true, 'S_LEGEND' => false)); // Check permissions on files/directories we need access to $template->assign_block_vars('checks', array('S_LEGEND' => true, 'LEGEND' => $user->lang['FILES_REQUIRED'], 'LEGEND_EXPLAIN' => $user->lang['FILES_REQUIRED_EXPLAIN'])); $directories = array('import', 'upload', 'medium', 'cache'); umask(0); $passed['dirs'] = true; foreach ($directories as $dir) { $write = false; // Now really check if (phpbb_gallery_url::_file_exists('', $dir, '') && is_dir(phpbb_gallery_url::_return_file('', $dir, ''))) { if (!phpbb_gallery_url::_is_writable('', $dir, '')) { @chmod(phpbb_gallery_url::_return_file('', $dir, ''), 0777); } } // Now check if it is writable by storing a simple file $fp = @fopen(phpbb_gallery_url::_return_file('', $dir, '') . 'test_lock', 'wb'); if ($fp !== false) { $write = true; } @fclose($fp); @unlink(phpbb_gallery_url::_return_file('', $dir, '') . 'test_lock'); $passed['dirs'] = $write && $passed['dirs'] ? true : false; $write = $write ? '<strong style="color:green">' . $user->lang['WRITABLE'] . '</strong>' : '<strong style="color:red">' . $user->lang['UNWRITABLE'] . '</strong>'; $template->assign_block_vars('checks', array('TITLE' => $dir, 'RESULT' => $write, 'S_EXPLAIN' => false, 'S_LEGEND' => false)); } $url = !in_array(false, $passed) ? append_sid("{$phpbb_root_path}install/index.{$phpEx}", "mode={$mode}&sub=copy_table") : append_sid("{$phpbb_root_path}install/index.{$phpEx}", "mode={$mode}&sub=requirements"); $submit = !in_array(false, $passed) ? $user->lang['INSTALL_START'] : $user->lang['INSTALL_TEST']; $template->assign_vars(array('L_SUBMIT' => $submit, 'S_HIDDEN' => '', 'U_ACTION' => $url)); }
/** * Checks that the server we are installing on meets the requirements for running phpBB */ function check_server_requirements($mode, $sub) { global $user, $template, $phpbb_root_path, $phpEx; $this->page_title = $user->lang['STAGE_REQUIREMENTS']; $template->assign_vars(array('TITLE' => $user->lang['REQUIREMENTS_TITLE'], 'BODY' => $user->lang['REQUIREMENTS_EXPLAIN'])); $passed = array('php' => false, 'files' => false, 'dirs' => false); // Test for basic PHP settings $template->assign_block_vars('checks', array('S_LEGEND' => true, 'LEGEND' => $user->lang['PHP_SETTINGS'], 'LEGEND_EXPLAIN' => $user->lang['PHP_SETTINGS_EXP'])); // Check for GD-Library if (@extension_loaded('gd') || can_load_dll('gd')) { $passed['php'] = true; $result = '<strong style="color:green">' . $user->lang['YES'] . '</strong>'; } else { $result = '<strong style="color:red">' . $user->lang['NO'] . '</strong>'; } $template->assign_block_vars('checks', array('TITLE' => $user->lang['REQ_GD_LIBRARY'], 'RESULT' => $result, 'S_EXPLAIN' => false, 'S_LEGEND' => false)); // Test for optional PHP settings $template->assign_block_vars('checks', array('S_LEGEND' => true, 'LEGEND' => $user->lang['PHP_SETTINGS_OPTIONAL'], 'LEGEND_EXPLAIN' => $user->lang['PHP_SETTINGS_OPTIONAL_EXP'])); // Image rotate if (function_exists('imagerotate')) { $result = '<strong style="color:green">' . $user->lang['YES'] . '</strong>'; } else { $gd_info = gd_info(); $result = '<strong style="color:red">' . $user->lang['NO'] . '</strong><br />' . sprintf($user->lang['OPTIONAL_IMAGEROTATE_EXP'], $gd_info['GD Version']); } $template->assign_block_vars('checks', array('TITLE' => $user->lang['OPTIONAL_IMAGEROTATE'], 'TITLE_EXPLAIN' => $user->lang['OPTIONAL_IMAGEROTATE_EXPLAIN'], 'RESULT' => $result, 'S_EXPLAIN' => true, 'S_LEGEND' => false)); // Exif data if (function_exists('exif_read_data')) { $result = '<strong style="color:green">' . $user->lang['YES'] . '</strong>'; } else { $result = '<strong style="color:red">' . $user->lang['NO'] . '</strong><br />' . $user->lang['OPTIONAL_EXIFDATA_EXP']; } $template->assign_block_vars('checks', array('TITLE' => $user->lang['OPTIONAL_EXIFDATA'], 'TITLE_EXPLAIN' => $user->lang['OPTIONAL_EXIFDATA_EXPLAIN'], 'RESULT' => $result, 'S_EXPLAIN' => true, 'S_LEGEND' => false)); // Check permissions on files/directories we need access to $template->assign_block_vars('checks', array('S_LEGEND' => true, 'LEGEND' => $user->lang['FILES_REQUIRED'], 'LEGEND_EXPLAIN' => $user->lang['FILES_REQUIRED_EXPLAIN'])); $directories = array('import', 'upload', 'medium', 'cache'); umask(0); $passed['dirs'] = true; foreach ($directories as $dir) { $write = false; // Now really check if (phpbb_gallery_url::_file_exists('', $dir, '') && is_dir(phpbb_gallery_url::_return_file('', $dir, ''))) { if (!phpbb_gallery_url::_is_writable('', $dir, '')) { @chmod(phpbb_gallery_url::_return_file('', $dir, ''), 0777); } } // Now check if it is writable by storing a simple file $fp = @fopen(phpbb_gallery_url::_return_file('', $dir, '') . 'test_lock', 'wb'); if ($fp !== false) { $write = true; } @fclose($fp); @unlink(phpbb_gallery_url::_return_file('', $dir, '') . 'test_lock'); $passed['dirs'] = $write && $passed['dirs'] ? true : false; $write = $write ? '<strong style="color:green">' . $user->lang['WRITABLE'] . '</strong>' : '<strong style="color:red">' . $user->lang['UNWRITABLE'] . '</strong>'; $template->assign_block_vars('checks', array('TITLE' => $dir, 'RESULT' => $write, 'S_EXPLAIN' => false, 'S_LEGEND' => false)); } // Check whether all old files are deleted include $phpbb_root_path . 'install/outdated_files.' . $phpEx; umask(0); $passed['files'] = true; $delete = isset($_POST['delete']) ? true : false; foreach ($oudated_files as $file) { // Replace gallery root path with the constant. if (strpos($file, 'gallery/') == 0) { $file = substr_replace($file, phpbb_gallery_url::path('relative'), 0, 8); } $file = preg_replace('/\\.php$/i', ".{$phpEx}", $file); if ($delete) { if (@file_exists($phpbb_root_path . $file)) { // Try to set CHMOD and then delete it @chmod($phpbb_root_path . $file, 0777); @unlink($phpbb_root_path . $file); // Delete failed, tell the user to delete it manually if (@file_exists($phpbb_root_path . $file)) { if ($passed['files']) { $template->assign_block_vars('checks', array('S_LEGEND' => true, 'LEGEND' => $user->lang['FILES_OUTDATED'], 'LEGEND_EXPLAIN' => $user->lang['FILES_OUTDATED_EXPLAIN'])); } $template->assign_block_vars('checks', array('TITLE' => $file, 'RESULT' => '<strong style="color:red">' . $user->lang['FILE_DELETE_FAIL'] . '</strong>', 'S_EXPLAIN' => false, 'S_LEGEND' => false)); $passed['files'] = false; } } } elseif (@file_exists($phpbb_root_path . $file)) { if ($passed['files']) { $template->assign_block_vars('checks', array('S_LEGEND' => true, 'LEGEND' => $user->lang['FILES_OUTDATED'], 'LEGEND_EXPLAIN' => $user->lang['FILES_OUTDATED_EXPLAIN'])); } $template->assign_block_vars('checks', array('TITLE' => $file, 'RESULT' => '<strong style="color:red">' . $user->lang['FILE_STILL_EXISTS'] . '</strong>', 'S_EXPLAIN' => false, 'S_LEGEND' => false)); $passed['files'] = false; } } if (!$passed['files']) { $template->assign_block_vars('checks', array('TITLE' => '<strong>' . $user->lang['FILES_DELETE_OUTDATED'] . '</strong>', 'TITLE_EXPLAIN' => $user->lang['FILES_DELETE_OUTDATED_EXPLAIN'], 'RESULT' => '<input class="button1" type="submit" id="delete" onclick="this.className = \'button1 disabled\';" name="delete" value="' . $user->lang['FILES_DELETE_OUTDATED'] . '" />', 'S_EXPLAIN' => true, 'S_LEGEND' => false)); } $url = !in_array(false, $passed) ? append_sid("{$phpbb_root_path}install/index.{$phpEx}", "mode={$mode}&sub=update_db") : append_sid("{$phpbb_root_path}install/index.{$phpEx}", "mode={$mode}&sub=requirements"); $submit = !in_array(false, $passed) ? $user->lang['INSTALL_START'] : $user->lang['INSTALL_TEST']; $template->assign_vars(array('L_SUBMIT' => $submit, 'S_HIDDEN' => '', 'U_ACTION' => $url)); }
/** * Checks that the server we are installing on meets the requirements for running phpBB Garage */ function check_server_requirements($mode, $sub) { global $lang, $template, $phpbb_root_path, $phpEx, $language; $this->page_title = $lang['STAGE_REQUIREMENTS']; $template->assign_vars(array('TITLE' => $lang['REQUIREMENTS_TITLE'], 'BODY' => $lang['REQUIREMENTS_EXPLAIN'])); $passed = array('php' => false, 'files' => false, 'imagesize' => false); // Test for basic PHP settings $template->assign_block_vars('checks', array('S_LEGEND' => true, 'LEGEND' => $lang['PHP_SETTINGS'], 'LEGEND_EXPLAIN' => $lang['PHP_SETTINGS_EXPLAIN'])); // Test the minimum PHP version $php_version = PHP_VERSION; if (version_compare($php_version, '4.3.3') < 0) { $result = '<strong style="color:red">' . $lang['NO'] . '</strong>'; } else { $passed['php'] = true; // We also give feedback on whether we're running in safe mode $result = '<strong style="color:green">' . $lang['YES']; if (@ini_get('safe_mode') || strtolower(@ini_get('safe_mode')) == 'on') { $result .= ', ' . $lang['PHP_SAFE_MODE']; } $result .= '</strong>'; } $template->assign_block_vars('checks', array('TITLE' => $lang['PHP_VERSION_REQD'], 'RESULT' => $result, 'S_EXPLAIN' => false, 'S_LEGEND' => false)); // Check for url_fopen if (@ini_get('allow_url_fopen') == '1' || strtolower(@ini_get('allow_url_fopen')) == 'on') { $result = '<strong style="color:green">' . $lang['YES'] . '</strong>'; } else { $result = '<strong style="color:red">' . $lang['NO'] . '</strong>'; } $template->assign_block_vars('checks', array('TITLE' => $lang['PHP_URL_FOPEN_SUPPORT'], 'TITLE_EXPLAIN' => $lang['PHP_URL_FOPEN_SUPPORT_EXPLAIN'], 'RESULT' => $result, 'S_EXPLAIN' => true, 'S_LEGEND' => false)); // Check for getimagesize if (@function_exists('getimagesize')) { $passed['imagesize'] = true; $result = '<strong style="color:green">' . $lang['YES'] . '</strong>'; } else { $result = '<strong style="color:red">' . $lang['NO'] . '</strong>'; } $template->assign_block_vars('checks', array('TITLE' => $lang['PHP_GETIMAGESIZE_SUPPORT'], 'TITLE_EXPLAIN' => $lang['PHP_GETIMAGESIZE_SUPPORT_EXPLAIN'], 'RESULT' => $result, 'S_EXPLAIN' => true, 'S_LEGEND' => false)); // Test for other modules $template->assign_block_vars('checks', array('S_LEGEND' => true, 'LEGEND' => $lang['PHP_REQUIRED_MODULE'], 'LEGEND_EXPLAIN' => $lang['PHP_REQUIRED_MODULE_EXPLAIN'])); foreach ($this->php_dlls_other as $dll) { if (!@extension_loaded($dll)) { if (!can_load_dll($dll)) { $template->assign_block_vars('checks', array('TITLE' => $lang['DLL_' . strtoupper($dll)], 'RESULT' => '<strong style="color:red">' . $lang['UNAVAILABLE'] . '</strong>', 'S_EXPLAIN' => false, 'S_LEGEND' => false)); continue; } } $template->assign_block_vars('checks', array('TITLE' => $lang['DLL_' . strtoupper($dll)], 'RESULT' => '<strong style="color:green">' . $lang['AVAILABLE'] . '</strong>', 'S_EXPLAIN' => false, 'S_LEGEND' => false)); } // Check permissions on files/directories we need access to $template->assign_block_vars('checks', array('S_LEGEND' => true, 'LEGEND' => $lang['FILES_REQUIRED'], 'LEGEND_EXPLAIN' => $lang['FILES_REQUIRED_EXPLAIN'])); $directories = array('garage/upload/'); umask(0); $passed['files'] = true; foreach ($directories as $dir) { $exists = $write = false; // Try to create the directory if it does not exist if (!file_exists($phpbb_root_path . $dir)) { @mkdir($phpbb_root_path . $dir, 0777); @chmod($phpbb_root_path . $dir, 0777); } // Now really check if (file_exists($phpbb_root_path . $dir) && is_dir($phpbb_root_path . $dir)) { if (!@is_writable($phpbb_root_path . $dir)) { @chmod($phpbb_root_path . $dir, 0777); } $exists = true; } // Now check if it is writable by storing a simple file $fp = @fopen($phpbb_root_path . $dir . 'test_lock', 'wb'); if ($fp !== false) { $write = true; } @fclose($fp); @unlink($phpbb_root_path . $dir . 'test_lock'); $passed['files'] = $exists && $write && $passed['files'] ? true : false; $exists = $exists ? '<strong style="color:green">' . $lang['FOUND'] . '</strong>' : '<strong style="color:red">' . $lang['NOT_FOUND'] . '</strong>'; $write = $write ? ', <strong style="color:green">' . $lang['WRITABLE'] . '</strong>' : ($exists ? ', <strong style="color:red">' . $lang['UNWRITABLE'] . '</strong>' : ''); $template->assign_block_vars('checks', array('TITLE' => $dir, 'RESULT' => $exists . $write, 'S_EXPLAIN' => false, 'S_LEGEND' => false)); } // And finally where do we want to go next (well today is taken isn't it :P) $s_hidden_fields = ''; $url = !in_array(false, $passed) ? $this->p_master->module_url . "?mode={$mode}&sub=optional&language={$language}" : $this->p_master->module_url . "?mode={$mode}&sub=requirements&language={$language}\t"; $submit = !in_array(false, $passed) ? $lang['INSTALL_START'] : $lang['INSTALL_TEST']; $template->assign_vars(array('L_SUBMIT' => $submit, 'S_HIDDEN' => $s_hidden_fields, 'U_ACTION' => $url)); }
public function __construct() { global $db, $user, $auth, $cache, $settings, $table_prefix; global $quickinstall_path, $phpbb_root_path, $phpEx, $config; // include installation functions include $quickinstall_path . 'includes/functions_install.' . $phpEx; // postgres uses remove_comments function which is defined in functions_admin include $phpbb_root_path . 'includes/functions_admin.' . $phpEx; if (defined('PHPBB_31')) { $config->set('rand_seed', md5(mt_rand())); $config->set('rand_seed_last_update', time()); } else { $config = array_merge($config, array('rand_seed' => md5(mt_rand()), 'rand_seed_last_update' => time())); } // load installer lang // qi::add_lang('phpbb'); // phpbb's install uses $lang instead of $user->lang // need to use $GLOBALS here $GLOBALS['lang'] =& $user->lang; global $lang; // Request some variables that are used several times here. $dbms = $settings->get_config('dbms'); $dbhost = $settings->get_config('dbhost'); $db_prefix = validate_dbname($settings->get_config('db_prefix'), true); $dbname = validate_dbname($settings->get_config('dbname'), true); $dbpasswd = $settings->get_config('dbpasswd'); $dbuser = $settings->get_config('dbuser'); $site_dir = validate_dbname($settings->get_config('dbname'), true, true); $site_name = $settings->get_config('site_name', '', true); $site_desc = $settings->get_config('site_desc', '', true); $admin_name = $settings->get_config('admin_name', '', true); $admin_pass = $settings->get_config('admin_pass', '', true); $alt_env = $settings->get_config('alt_env', ''); $automod = !defined('PHPBB_31') && $settings->get_config('automod', false) ? true : false; if ($alt_env !== '' && (!file_exists("{$quickinstall_path}sources/phpBB3_alt/{$alt_env}") || is_file("{$quickinstall_path}sources/phpBB3_alt/{$alt_env}"))) { create_board_warning($user->lang['MINOR_MISHAP'], $user->lang['NO_ALT_ENV_FOUND'], 'main'); } if ($automod) { $empty = true; // There can be '.', '..' and/or '.gitkeep' in the AutoMOD directory. $dh = opendir("{$quickinstall_path}sources/automod"); while (($file = readdir($dh)) !== false) { if ($file[0] != '.') { $empty = false; break; } } if ($empty) { create_board_warning($user->lang['NO_AUTOMOD_TITLE'], $user->lang['NO_AUTOMOD'], 'main'); } } // Set up our basic founder. $user->data['user_id'] = 2; // $user->data['username'] = $admin_name; $user->data['user_colour'] = 'AA0000'; // overwrite some of them ;) $user->lang = array_merge($user->lang, array('CONFIG_SITE_DESC' => $site_desc, 'CONFIG_SITENAME' => $site_name)); // check if we have a board db (and directory) name if (!$dbname) { create_board_warning($user->lang['GENERAL_ERROR'], $user->lang['NO_DB'], 'main'); } // Set the new board as root path. $board_dir = $settings->get_boards_dir() . $site_dir . '/'; $board_url = $settings->get_boards_url() . $site_dir . '/'; $phpbb_root_path = $board_dir; if (!defined('PHPBB_ROOT_PATH')) { define('PHPBB_ROOT_PATH', $board_dir); } if (file_exists($board_dir)) { if ($settings->get_config('delete_files', false)) { file_functions::delete_dir($board_dir); } else { create_board_warning($user->lang['MINOR_MISHAP'], sprintf($user->lang['DIR_EXISTS'], $board_dir), 'main'); } } // copy all of our files file_functions::copy_dir($quickinstall_path . 'sources/' . ($alt_env === '' ? 'phpBB3/' : "phpBB3_alt/{$alt_env}/"), $board_dir); if (!defined('PHPBB_31')) { // copy qi's lang file for the log $qi_lang = $settings->get_config('qi_lang'); if (file_exists("{$quickinstall_path}language/{$qi_lang}/info_acp_qi.{$phpEx}") && file_exists("{$board_dir}language/{$qi_lang}")) { copy("{$quickinstall_path}language/{$qi_lang}/info_acp_qi.{$phpEx}", "{$board_dir}language/{$qi_lang}/mods/info_acp_qi.{$phpEx}"); } else { copy("{$quickinstall_path}language/en/info_acp_qi.{$phpEx}", "{$board_dir}language/en/mods/info_acp_qi.{$phpEx}"); } } if ($dbms == 'sqlite') { $dbhost = $dbhost . $db_prefix . $dbname; } else { if ($dbms == 'firebird') { $dbhost = $db_prefix . $dbname; // temp remove some list($db_prefix, $dbname, $temp1, $temp2) = array('', '', $db_prefix, $dbname); } } // Set the new board as language path to get language files from outside phpBB //$user->set_custom_lang_path($phpbb_root_path . 'language/'); $user->lang_path = $phpbb_root_path . 'language/'; if (substr($user->lang_path, -1) != '/') { $user->lang_path .= '/'; } // Write to config.php ;) if (defined('PHPBB_32')) { $config_version = '3.2'; } else { if (defined('PHPBB_31')) { $config_version = '3.1'; } else { $config_version = '3.0'; } } $config_data = "<?php\n"; $config_data .= "// phpBB {$config_version}.x auto-generated configuration file\n// Do not change anything in this file!\n"; $config_data_array = array('$dbhost' => $dbhost, '$dbport' => $settings->get_config('dbport'), '$dbname' => $db_prefix . $dbname, '$dbuser' => $dbuser, '$dbpasswd' => htmlspecialchars_decode($dbpasswd), '$table_prefix' => $table_prefix); if (defined('PHPBB_31')) { $config_data_array['$dbms'] = "phpbb\\\\db\\\\driver\\\\{$dbms}"; $config_data_array['$acm_type'] = 'phpbb\\\\cache\\\\driver\\\\file'; $config_data_array['$phpbb_adm_relative_path'] = 'adm/'; } else { $config_data_array['$dbms'] = $dbms; $config_data_array['$acm_type'] = 'file'; $config_data_array['$load_extensions'] = ''; } foreach ($config_data_array as $key => $value) { $config_data .= "{$key} = '{$value}';\n"; } unset($config_data_array); $config_data .= "\n@define('PHPBB_INSTALLED', true);\n"; $config_data .= "@define('DEBUG', true);\n"; if (defined('PHPBB_32')) { $config_data .= "@define('PHPBB_ENVIRONMENT', 'production');\n"; } if (defined('PHPBB_31')) { $config_data .= "//@define('DEBUG_CONTAINER', true);\n"; $config_data .= "@define('PHPBB_DISPLAY_LOAD_TIME', true);\n"; } else { $config_data .= "@define('DEBUG_EXTRA', true);\n"; $config_data .= '?' . '>'; // Done this to prevent highlighting editors getting confused! } file_put_contents($board_dir . 'config.' . $phpEx, $config_data); if ($dbms == 'firebird') { // and now restore list($db_prefix, $dbname) = array($temp1, $temp2); } $db = db_connect(); if ($settings->get_config('drop_db', 0)) { $db->sql_query('DROP DATABASE IF EXISTS ' . $db_prefix . $dbname); } else { // Check if the database exists. if ($dbms == 'sqlite') { $db_check = $db->sql_select_db($dbhost); } else { if ($dbms == 'firebird') { $db_check = $db->sql_select_db($settings->get_cache_dir() . $db_prefix . $dbname); } else { if ($dbms == 'postgres') { global $sql_db; $error_collector = new phpbb_error_collector(); $error_collector->install(); $db_check_conn = new $sql_db(); $db_check_conn->sql_connect($dbhost, $dbuser, $dbpasswd, $db_prefix . $dbname, $dbport, false, false); $error_collector->uninstall(); $db_check = count($error_collector->errors) == 0; } else { $db_check = $db->sql_select_db($db_prefix . $dbname); } } } if ($db_check) { create_board_warning($user->lang['MINOR_MISHAP'], sprintf($user->lang['DB_EXISTS'], $db_prefix . $dbname), 'main'); } } if ($dbms == 'sqlite') { $db->sql_create_db($dbhost); $db->sql_select_db($dbhost); } else { if ($dbms == 'firebird') { $db->sql_query('CREATE DATABASE ' . $settings->get_cache_dir() . $db_prefix . $dbname); $db->sql_select_db($settings->get_cache_dir() . $db_prefix . $dbname); } else { if ($dbms == 'postgres') { global $sql_db; $db->sql_query('CREATE DATABASE ' . $db_prefix . $dbname); $db = new $sql_db(); $db->sql_connect($dbhost, $dbuser, $dbpasswd, $db_prefix . $dbname, $dbport, false, false); $db->sql_return_on_error(true); } else { $db->sql_query('CREATE DATABASE ' . $db_prefix . $dbname); $db->sql_select_db($db_prefix . $dbname); } } } // include install lang from phpbb. But only if it exists $default_lang = $settings->get_config('default_lang'); $selected_lang = $phpbb_root_path . "language/{$default_lang}/"; if (file_exists($selected_lang)) { qi::add_lang('install', $selected_lang); } else { // Assume that English is always available $default_lang = 'en'; qi::add_lang('install', $phpbb_root_path . 'language/en/'); } // perform sql load_schema($phpbb_root_path . 'install/schemas/', $dbms); $current_time = time(); $user_ip = !empty($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '0.0.0.0'; $user_ip = htmlspecialchars($user_ip); $script_path = !empty($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : getenv('PHP_SELF'); if (!$script_path) { $script_path = !empty($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI'); } // Replace backslashes and doubled slashes (could happen on some proxy setups) $script_path = trim(dirname($script_path)); $script_path = str_replace(array('\\', '//'), '/', $script_path); // Make sure $script_path ends with a slash (/). $script_path = substr($script_path, -1) != '/' ? $script_path . '/' : $script_path; $script_path .= $settings->get_boards_dir() . $site_dir . '/'; $config_ary = array('board_startdate' => $current_time, 'default_lang' => $default_lang, 'server_name' => $settings->get_config('server_name'), 'server_port' => $settings->get_config('server_port', 0), 'board_email' => $settings->get_config('board_email'), 'board_contact' => $settings->get_config('board_email'), 'cookie_domain' => $settings->get_config('cookie_domain'), 'default_dateformat' => $user->lang['default_dateformat'], 'email_enable' => $settings->get_config('email_enable', 0), 'smtp_delivery' => $settings->get_config('smtp_delivery', 0), 'smtp_host' => $settings->get_config('smtp_host'), 'smtp_auth_method' => $settings->get_config('smtp_auth'), 'smtp_username' => $settings->get_config('smtp_user'), 'smtp_port' => $settings->get_config('smtp_port', 0), 'smtp_password' => $settings->get_config('smtp_pass'), 'cookie_secure' => $settings->get_config('cookie_secure', 0), 'script_path' => $script_path, 'server_protocol' => $settings->get_server_protocol(), 'newest_username' => $admin_name, 'avatar_salt' => md5(mt_rand()), 'cookie_name' => 'phpbb3_' . strtolower(gen_rand_string(5))); if (defined('PHPBB_31')) { $config_ary['board_timezone'] = $settings->get_config('qi_tz', ''); $tz_data = "user_timezone = '{$config_ary['board_timezone']}'"; } else { $tz = new DateTimeZone($settings->get_config('qi_tz', '')); $tz_ary = $tz->getTransitions(time()); $offset = (double) $tz_ary[0]['offset'] / 3600; // 3600 seconds = 1 hour. $dst = $tz_ary[0]['isdst'] ? 1 : 0; $tz_data = "user_timezone = {$offset}, user_dst = {$dst}"; $config_ary['user_timezone'] = $offset; $config_ary['user_dst'] = $dst; unset($tz_ary, $tz, $offset, $dst); } if (@extension_loaded('gd') || can_load_dll('gd')) { $config_ary['captcha_gd'] = 1; } if (defined('PHPBB_31')) { $current_config = $config; $config = new \phpbb\config\db($db, $cache, "{$table_prefix}config"); set_config(false, false, false, $config); foreach ($current_config as $key => $value) { $config->set($key, $value); } } foreach ($config_ary as $config_name => $config_value) { set_config($config_name, $config_value); } // Set default config and post data, this applies to all DB's $sql_ary = array("UPDATE {$table_prefix}users\n\t\t\t\tSET username\t\t= '" . $db->sql_escape($admin_name) . "',\n\t\t\t\t\tuser_password\t= '" . $db->sql_escape(md5($admin_pass)) . "',\n\t\t\t\t\tuser_ip\t\t\t= '" . $db->sql_escape($user_ip) . "',\n\t\t\t\t\tuser_lang\t\t= '" . $db->sql_escape($default_lang) . "',\n\t\t\t\t\tuser_email\t\t= '" . $db->sql_escape($settings->get_config('board_email')) . "',\n\t\t\t\t\tuser_dateformat\t= '" . $db->sql_escape($user->lang['default_dateformat']) . "',\n\t\t\t\t\tuser_email_hash\t= " . (crc32($settings->get_config('board_email')) . strlen($settings->get_config('board_email'))) . ",\n\t\t\t\t\tusername_clean\t= '" . $db->sql_escape(utf8_clean_string($admin_name)) . "',\n\t\t\t\t\t{$tz_data}\n\t\t\t\tWHERE username = '******'", "UPDATE {$table_prefix}moderator_cache\n\t\t\t\tSET username = '******'\n\t\t\t\tWHERE username = '******'", "UPDATE {$table_prefix}forums\n\t\t\t\tSET forum_last_poster_name = '" . $db->sql_escape($admin_name) . "'\n\t\t\t\tWHERE forum_last_poster_name = 'Admin'", "UPDATE {$table_prefix}topics\n\t\t\t\tSET topic_first_poster_name = '" . $db->sql_escape($admin_name) . "', topic_last_poster_name = '" . $db->sql_escape($admin_name) . "'\n\t\t\t\tWHERE topic_first_poster_name = 'Admin'\n\t\t\t\t\tOR topic_last_poster_name = 'Admin'", "UPDATE {$table_prefix}users\n\t\t\t\tSET user_regdate = {$current_time}", "UPDATE {$table_prefix}posts\n\t\t\t\tSET post_time = {$current_time}, poster_ip = '" . $db->sql_escape($user_ip) . "'", "UPDATE {$table_prefix}topics\n\t\t\t\tSET topic_time = {$current_time}, topic_last_post_time = {$current_time}", "UPDATE {$table_prefix}forums\n\t\t\t\tSET forum_last_post_time = {$current_time}", "UPDATE {$table_prefix}config\n\t\t\t\tSET config_value = '" . $db->sql_escape($site_name) . "'\n\t\t\t\tWHERE config_name = 'sitename'", "UPDATE {$table_prefix}config\n\t\t\t\tSET config_value = '" . $db->sql_escape($site_desc) . "'\n\t\t\t\tWHERE config_name = 'site_desc'", "UPDATE {$table_prefix}config\n\t\t\t\tSET config_value = '1'\n\t\t\t\tWHERE config_name = 'load_tplcompile'"); foreach ($sql_ary as $sql) { if (!$db->sql_query($sql)) { $error = $db->sql_error(); trigger_error($error['message']); } } // main sql is done, let's get a fresh $config array $sql = 'SELECT * FROM ' . CONFIG_TABLE; $result = $db->sql_query($sql); if (defined('PHPBB_31')) { $config = new \phpbb\config\config(array()); } else { $config = array(); } while ($row = $db->sql_fetchrow($result)) { $config[$row['config_name']] = $row['config_value']; } $db->sql_freeresult($result); // Set other optional config data. // Have it here to not having to do a query for each key // to see if it is a update or insert. if (($other_config = $settings->get_other_config(true)) != '') { foreach ($other_config as $config_row) { // First check if this is a comment. if (strpos($config_row, '#') === 0) { continue; } $row_ary = explode(';', $config_row); if (empty($row_ary[0]) || empty($row_ary[1])) { continue; } $config_name = trim($row_ary[0]); $config_value = trim($row_ary[1]); $is_dynamic = !empty($row_ary[2]) ? 1 : 0; $sql_ary = array('config_name' => $config_name, 'config_value' => $config_value, 'is_dynamic' => $is_dynamic); if (defined('PHPBB_31') && $config->offsetExists($config_name) || !defined('PHPBB_31') && array_key_exists($config_name, $config)) { $sql = "UPDATE {$table_prefix}config\n\t\t\t\t\t\tSET " . $db->sql_build_array('UPDATE', $sql_ary) . "\n\t\t\t\t\t\tWHERE config_name = '{$config_name}'"; if (!$db->sql_query($sql)) { $error = $db->sql_error(); trigger_error($error['message']); } } else { $sql = "INSERT INTO {$table_prefix}config " . $db->sql_build_array('INSERT', $sql_ary); if (!$db->sql_query($sql)) { $error = $db->sql_error(); trigger_error($error['message']); } } // Update the config array. $config[$config_name] = $config_value; } unset($other_config); } // no templates though :P $config['load_tplcompile'] = '1'; // build search index if (defined('PHPBB_31')) { $search = new \phpbb\search\fulltext_native($error = false, $phpbb_root_path, $phpEx, $auth, $config, $db, $user, null); } else { if (!class_exists('fulltext_native')) { include_once $phpbb_root_path . 'includes/search/fulltext_native.' . $phpEx; } $search = new fulltext_native($error = false); } $sql = 'SELECT post_id, post_subject, post_text, poster_id, forum_id FROM ' . POSTS_TABLE; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $search->index('post', $row['post_id'], $row['post_text'], $row['post_subject'], $row['poster_id'], $row['forum_id']); } $db->sql_freeresult($result); // extended phpbb install script if (!defined('PHPBB_32')) { include $phpbb_root_path . 'install/install_install.' . $phpEx; include $quickinstall_path . 'includes/install_install_qi.' . $phpEx; } if (defined('PHPBB_32')) { $container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx); $container = $container_builder->with_environment('installer')->without_extensions()->without_cache()->with_custom_parameters(['core.disable_super_globals' => false, 'installer.create_config_file.options' => ['debug' => true, 'environment' => 'production'], 'cache.driver.class' => 'phpbb\\cache\\driver\\file'])->without_compiled_container()->get_container(); $container->register('installer.install_finish.notify_user')->setSynthetic(true); $container->set('installer.install_finish.notify_user', null); $container->compile(); $language = $container->get('language'); $language->add_lang(array('common', 'acp/common', 'acp/board', 'install', 'posting')); $iohandler_factory = $container->get('installer.helper.iohandler_factory'); $iohandler_factory->set_environment('cli'); $iohandler = $iohandler_factory->get(); $output = new \Symfony\Component\Console\Output\NullOutput(); $style = new \Symfony\Component\Console\Style\SymfonyStyle(new \Symfony\Component\Console\Input\ArrayInput(array()), $output); $iohandler->set_style($style, $output); $installer = $container->get('installer.installer.install'); $installer->set_iohandler($iohandler); // Set data $iohandler->set_input('admin_name', $admin_name); $iohandler->set_input('admin_pass1', $admin_pass); $iohandler->set_input('admin_pass2', $admin_pass); $iohandler->set_input('board_email', $settings->get_config('board_email')); $iohandler->set_input('submit_admin', 'submit'); $iohandler->set_input('default_lang', $default_lang); $iohandler->set_input('board_name', $site_name); $iohandler->set_input('board_description', $site_desc); $iohandler->set_input('submit_board', 'submit'); $iohandler->set_input('dbms', $dbms); $iohandler->set_input('dbhost', $dbhost); $iohandler->set_input('dbport', $settings->get_config('dbport')); $iohandler->set_input('dbuser', $dbuser); $iohandler->set_input('dbpasswd', $dbpasswd); $iohandler->set_input('dbname', $dbname); $iohandler->set_input('table_prefix', $table_prefix); $iohandler->set_input('submit_database', 'submit'); $iohandler->set_input('email_enable', $settings->get_config('email_enable', 0)); $iohandler->set_input('smtp_delivery', $settings->get_config('smtp_delivery', 0)); $iohandler->set_input('smtp_host', $settings->get_config('smtp_host')); $iohandler->set_input('smtp_auth', $settings->get_config('smtp_auth')); $iohandler->set_input('smtp_user', $settings->get_config('smtp_user')); $iohandler->set_input('smtp_pass', $settings->get_config('smtp_pass')); $iohandler->set_input('submit_email', 'submit'); $iohandler->set_input('cookie_secure', $settings->get_config('cookie_secure', 0)); $iohandler->set_input('server_protocol', $settings->get_server_protocol()); $iohandler->set_input('force_server_vars', 'http://'); $iohandler->set_input('server_name', $settings->get_config('server_name')); $iohandler->set_input('server_port', $settings->get_config('server_port')); $iohandler->set_input('script_path', $script_path); $iohandler->set_input('submit_server', 'submit'); // Update the lang array with keys loaded for the installer $user->lang = array_merge($user->lang, $language->get_lang_array()); // Storing the db and user objects temporarily because they // are altered by the installer processes below...not sure why? $current_user = $user; $current_db = $db; // Suppress errors because constants.php is added again in these objects // leading to debug notices about the constants already being defined. @$container->get('installer.install_finish.populate_migrations')->run(); @$container->get('installer.install_data.add_modules')->run(); @$container->get('installer.install_data.add_languages')->run(); @$container->get('installer.install_data.add_bots')->run(); $container->reset(); // Set some services in the container that may be needed later global $phpbb_container, $phpbb_log, $phpbb_dispatcher, $request, $passwords_manager; global $symfony_request, $phpbb_filesystem; $phpbb_container = $container->get('installer.helper.container_factory'); $phpbb_dispatcher = $phpbb_container->get('dispatcher'); $phpbb_log = $phpbb_container->get('log'); $request = $phpbb_container->get('request'); $request->enable_super_globals(); $passwords_manager = $phpbb_container->get('passwords.manager'); $symfony_request = $phpbb_container->get('symfony_request'); $phpbb_filesystem = $phpbb_container->get('filesystem'); // Restore user and db objects to original state $user = $current_user; $db = $current_db; unset($current_user, $current_db); } else { if (defined('PHPBB_31')) { global $phpbb_container, $phpbb_config_php_file, $phpbb_log, $phpbb_dispatcher, $request, $passwords_manager; global $symfony_request, $phpbb_filesystem; $phpbb_config_php_file = new \phpbb\config_php_file($phpbb_root_path, $phpEx); $phpbb_container_builder = new \phpbb\di\container_builder($phpbb_config_php_file, $phpbb_root_path, $phpEx); $phpbb_container_builder->set_inject_config(false); $phpbb_container_builder->set_dump_container(false); $phpbb_container_builder->set_use_extensions(false); $phpbb_container_builder->set_compile_container(false); $phpbb_container_builder->set_custom_parameters(array('core.table_prefix' => $table_prefix, 'core.root_path' => $phpbb_root_path, 'core.php_ext' => $phpEx, 'core.adm_relative_path' => 'adm/')); $phpbb_container = $phpbb_container_builder->get_container(); $phpbb_container->register('dbal.conn')->setSynthetic(true); $phpbb_container->register('dbal.conn.driver')->setSynthetic(true); $phpbb_container->register('cache.driver')->setSynthetic(true); $phpbb_container->register('cache')->setSynthetic(true); $phpbb_container->register('auth')->setSynthetic(true); $phpbb_container->register('user')->setSynthetic(true); $phpbb_container->compile(); $phpbb_container->set('dbal.conn', $db); $phpbb_container->set('cache.driver', $cache); $phpbb_container->set('user', $user); $phpbb_container->set('auth', $auth); $cache = new \phpbb\cache\service($cache, $config, $db, $phpbb_root_path, $phpEx); $phpbb_container->set('cache', $cache); $phpbb_dispatcher = $phpbb_container->get('dispatcher'); $phpbb_log = $phpbb_container->get('log'); $request = $phpbb_container->get('request'); $request->enable_super_globals(); $passwords_manager = $phpbb_container->get('passwords.manager'); $symfony_request = $phpbb_container->get('symfony_request'); $phpbb_filesystem = $phpbb_container->get('filesystem'); // Populate migrations table. $install = new install_install($p_master = new p_master_dummy()); $install->populate_migrations($phpbb_container->get('ext.manager'), $phpbb_container->get('migrator')); unset($install); } } if (!defined('PHPBB_32')) { $install = new install_install_qi($p_master = new p_master_dummy()); $install->set_data(array('dbms' => $dbms, 'dbhost' => $dbhost, 'dbport' => $settings->get_config('dbport'), 'dbuser' => $dbuser, 'dbpasswd' => $dbpasswd, 'dbname' => $dbname, 'table_prefix' => $table_prefix, 'default_lang' => $default_lang, 'admin_name' => $admin_name, 'admin_pass1' => $admin_pass, 'admin_pass2' => $admin_pass, 'board_email1' => $settings->get_config('board_email'), 'board_email2' => $settings->get_config('board_email'), 'email_enable' => $settings->get_config('email_enable', 0), 'smtp_delivery' => $settings->get_config('smtp_delivery', 0), 'smtp_host' => $settings->get_config('smtp_host'), 'smtp_auth' => $settings->get_config('smtp_auth'), 'smtp_user' => $settings->get_config('smtp_user'), 'smtp_pass' => $settings->get_config('smtp_pass'), 'cookie_secure' => $settings->get_config('cookie_secure', 0), 'server_protocol' => $settings->get_server_protocol(), 'server_name' => $settings->get_config('server_name'), 'server_port' => $settings->get_config('server_port'), 'script_path' => $script_path)); $install->add_modules(false, false); $install->add_language(false, false); $install->add_bots(false, false); } // now automod (easymod) if ($automod && !defined('PHPBB_31')) { include $quickinstall_path . 'includes/functions_install_automod.' . $phpEx; automod_installer::install_automod($board_dir, $settings->get_config('make_writable', false)); } if ($dbms == 'firebird') { // copy the temp db over file_functions::copy_file($settings->get_cache_dir() . $db_prefix . $dbname, $board_dir . $db_prefix . $dbname); $db->sql_select_db($board_dir . $db_prefix . $dbname); } // clean up file_functions::delete_files($board_dir, array('Thumbs.db', 'DS_Store', 'CVS', '.svn', '.git')); // remove install dir, develop and umil file_functions::delete_dir($board_dir . 'install/'); file_functions::delete_dir($board_dir . 'develop/'); file_functions::delete_dir($board_dir . 'umil/'); // copy extra user added files file_functions::copy_dir($quickinstall_path . 'sources/extra/', $board_dir); // Install styles if (($install_styles = $settings->get_config('install_styles', 0)) != 0) { include $phpbb_root_path . 'includes/acp/acp_styles.' . $phpEx; if (!class_exists('bitfield')) { include $phpbb_root_path . 'includes/functions_content.' . $phpEx; } if (defined('PHPBB_31')) { include $quickinstall_path . 'includes/class_31_styles.' . $phpEx; new class_31_styles($install_styles); } else { include $quickinstall_path . 'includes/class_30_styles.' . $phpEx; new class_30_styles($install_styles); } } // Add some random users and posts. Revisit. if ($settings->get_config('populate', false)) { include $quickinstall_path . 'includes/functions_populate.' . $phpEx; new populate(); } // add log entry :D $user->ip =& $user_ip; if (defined('PHPBB_31')) { add_log('admin', sprintf($user->lang['LOG_INSTALL_INSTALLED_QI'], QI_VERSION)); } else { add_log('admin', 'LOG_INSTALL_INSTALLED_QI', QI_VERSION); } // purge cache $cache->purge(); // Make all files world writable. if ($settings->get_config('make_writable', false)) { file_functions::make_writable($board_dir); } // Grant additional permissions if (($grant_permissions = octdec($settings->get_config('grant_permissions', 0))) != 0) { file_functions::grant_permissions($board_dir, $grant_permissions); } // if he/she wants to be redirected, we'll do that. if ($settings->get_config('redirect', false)) { // Log him/her in first. $user->session_begin(); $auth->login($admin_name, $settings->get_config('admin_pass'), false, true, true); qi::redirect($board_url); } // On succces just return to main page. qi::redirect('index.' . $phpEx); }
public function __construct() { global $db, $user, $auth, $cache; global $quickinstall_path, $phpbb_root_path, $phpEx, $config, $qi_config, $msg_title; // include installation functions include $quickinstall_path . 'includes/functions_install.' . $phpEx; // include($quickinstall_path . 'includes/qi_functions.' . $phpEx); $config = array_merge($config, array('rand_seed' => md5(mt_rand()), 'rand_seed_last_update' => time())); // load installer lang qi::add_lang('phpbb'); // phpbb's install uses $lang instead of $user->lang // need to use $GLOBALS here $GLOBALS['lang'] =& $user->lang; global $lang; // request variables $dbname = htmlspecialchars_decode(request_var('dbname', '', true)); $redirect = request_var('redirect', false); $drop_db = request_var('drop_db', false); $delete_files = request_var('delete_files', false); $automod = request_var('automod', false); $make_writable = request_var('make_writable', false); $populate = request_var('populate', false); $subsilver = request_var('subsilver', 0); $alt_env = request_var('alt_env', ''); $pop_data = request_var('pop_data', array('' => '')); // Some populate checking if ($populate) { if (empty($pop_data['num_users']) && empty($pop_data['num_cats']) && empty($pop_data['num_forums']) && empty($pop_data['num_topics']) && empty($pop_data['num_replies'])) { // populate with nothing? $populate = false; } else { $pop_data['email_domain'] = trim($pop_data['email_domain']); if (!empty($pop_data['num_users']) && empty($pop_data['email_domain'])) { trigger_error($user->lang['NEED_EMAIL_DOMAIN'], E_USER_ERROR); } } } foreach (array('site_name', 'site_desc', 'table_prefix', 'admin_name', 'admin_pass') as $r) { if ($_r = request_var($r, '', true)) { $qi_config[$r] = $_r; } } if ($alt_env !== '' && !file_exists($quickinstall_path . 'sources/phpBB3_alt/' . $alt_env)) { trigger_error('NO_ALT_ENV'); } // Set up our basic founder. $user->data['user_id'] = 2; // $user->data['username'] = $qi_config['admin_name']; $user->data['user_colour'] = 'AA0000'; // overwrite some of them ;) $user->lang = array_merge($user->lang, array('CONFIG_SITE_DESC' => $qi_config['site_desc'], 'CONFIG_SITENAME' => $qi_config['site_name'])); // smaller ^^ list($dbms, $table_prefix) = array(&$qi_config['dbms'], &$qi_config['table_prefix']); // check if we have a board db (and folder) name if (!$dbname) { trigger_error('NO_DB'); } // Set the new board as root path. $board_dir = $quickinstall_path . 'boards/' . $dbname . '/'; $phpbb_root_path = $board_dir; if (!defined('PHPBB_ROOT_PATH')) { define('PHPBB_ROOT_PATH', $board_dir); } if (file_exists($board_dir)) { if ($delete_files) { file_functions::delete_dir($board_dir); } else { trigger_error(sprintf($user->lang['DIR_EXISTS'], $board_dir)); } } // copy all of our files file_functions::copy_dir($quickinstall_path . 'sources/' . ($alt_env === '' ? 'phpBB3/' : "phpBB3_alt/{$alt_env}/"), $board_dir); if ($make_writable) { chmod($board_dir, 0777); } // Now make sure we have a valid db-name and prefix $qi_config['db_prefix'] = validate_dbname($qi_config['db_prefix'], true); $dbname = validate_dbname($dbname); // copy qi's lang file for the log if (file_exists("{$quickinstall_path}language/{$qi_config['qi_lang']}/info_acp_qi.{$phpEx}") && file_exists($board_dir . 'language/' . $qi_config['qi_lang'])) { copy("{$quickinstall_path}language/{$qi_config['qi_lang']}/info_acp_qi.{$phpEx}", "{$board_dir}language/{$qi_config['qi_lang']}/mods/info_acp_qi.{$phpEx}"); } else { copy("{$quickinstall_path}language/en/info_acp_qi.{$phpEx}", "{$board_dir}language/en/mods/info_acp_qi.{$phpEx}"); } if ($dbms == 'sqlite' || $dbms == 'firebird') { $qi_config['dbhost'] = $qi_config['db_prefix'] . $dbname; // temp remove some list($qi_config['db_prefix'], $dbname, $temp1, $temp2) = array('', '', &$qi_config['db_prefix'], &$dbname); } // Set the new board as language path to get language files from outside phpBB $user->set_custom_lang_path($phpbb_root_path . 'language/'); // Write to config.php ;) $config_data = "<?php\n"; $config_data .= "// phpBB 3.0.x auto-generated configuration file\n// Do not change anything in this file!\n"; $config_data_array = array('dbms' => $dbms, 'dbhost' => $qi_config['dbhost'], 'dbport' => $qi_config['dbport'], 'dbname' => $qi_config['db_prefix'] . $dbname, 'dbuser' => $qi_config['dbuser'], 'dbpasswd' => htmlspecialchars_decode($qi_config['dbpasswd']), 'table_prefix' => $table_prefix, 'acm_type' => 'file', 'load_extensions' => ''); foreach ($config_data_array as $key => $value) { $config_data .= "\${$key} = '" . str_replace("'", "\\'", str_replace('\\', '\\\\', $value)) . "';\n"; } unset($config_data_array); $config_data .= "\n@define('PHPBB_INSTALLED', true);\n"; $config_data .= "@define('DEBUG', true);\n"; $config_data .= "@define('DEBUG_EXTRA', true);\n"; $config_data .= '?' . '>'; // Done this to prevent highlighting editors getting confused! file_put_contents($board_dir . 'config.' . $phpEx, $config_data); if ($dbms == 'sqlite' || $dbms == 'firebird') { // and now restore list($qi_config['db_prefix'], $dbname) = array(&$temp1, &$temp2); } // update phpbb_root_path $phpbb_root_path = $board_dir; if ($drop_db) { $db->sql_query('DROP DATABASE IF EXISTS ' . $qi_config['db_prefix'] . $dbname); } else { // Check if the database exists. if ($dbms == 'sqlite' || $dbms == 'firebird') { $db_check = $db->sql_select_db($quickinstall_path . 'cache/' . $qi_config['db_prefix'] . $dbname); } else { $db_check = $db->sql_select_db($qi_config['db_prefix'] . $dbname); } if ($db_check) { trigger_error(sprintf($user->lang['DB_EXISTS'], $qi_config['db_prefix'] . $dbname)); } } if ($dbms == 'sqlite' || $dbms == 'firebird') { $db->sql_query('CREATE DATABASE ' . $quickinstall_path . 'cache/' . $qi_config['db_prefix'] . $dbname); $db->sql_select_db($quickinstall_path . 'cache/' . $qi_config['db_prefix'] . $dbname); } else { $db->sql_query('CREATE DATABASE ' . $qi_config['db_prefix'] . $dbname); $db->sql_select_db($qi_config['db_prefix'] . $dbname); } // include install lang fom phpbb qi::add_lang('install', $phpbb_root_path . 'language/' . $qi_config['default_lang'] . '/'); // perform sql load_schema($phpbb_root_path . 'install/schemas/', $dbms); $current_time = time(); $user_ip = !empty($_SERVER['REMOTE_ADDR']) ? htmlspecialchars($_SERVER['REMOTE_ADDR']) : ''; $script_path = !empty($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : getenv('PHP_SELF'); if (!$script_path) { $script_path = !empty($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI'); } // Replace backslashes and doubled slashes (could happen on some proxy setups) $script_path = str_replace(array('\\', '//'), '/', $script_path); $script_path = trim(dirname($script_path)); // add the dbname to script path $script_path .= '/boards/' . $dbname; $config_ary = array('board_startdate' => $current_time, 'default_lang' => $qi_config['default_lang'], 'server_name' => $qi_config['server_name'], 'server_port' => $qi_config['server_port'], 'board_email' => $qi_config['board_email'], 'board_contact' => $qi_config['board_email'], 'cookie_domain' => $qi_config['cookie_domain'], 'default_dateformat' => $user->lang['default_dateformat'], 'email_enable' => $qi_config['email_enable'], 'smtp_delivery' => $qi_config['smtp_delivery'], 'smtp_host' => $qi_config['smtp_host'], 'smtp_auth_method' => $qi_config['smtp_auth'], 'smtp_username' => $qi_config['smtp_user'], 'smtp_password' => $qi_config['smtp_pass'], 'cookie_secure' => $qi_config['cookie_secure'], 'script_path' => $script_path, 'server_protocol' => !empty($qi_config['server_protocol']) ? $qi_config['server_protocol'] : 'http://', 'newest_username' => $qi_config['admin_name'], 'avatar_salt' => md5(mt_rand()), 'cookie_name' => 'phpbb3_' . strtolower(gen_rand_string(5))); if (@extension_loaded('gd') || can_load_dll('gd')) { $config_ary['captcha_gd'] = 1; } foreach ($config_ary as $config_name => $config_value) { set_config($config_name, $config_value); } // Set default config and post data, this applies to all DB's $sql_ary = array("UPDATE {$table_prefix}users\n\t\t\t\tSET username = '******'admin_name']) . "', user_password='******'admin_pass'])) . "', user_ip = '" . $db->sql_escape($user_ip) . "', user_lang = '" . $db->sql_escape($qi_config['default_lang']) . "', user_email='" . $db->sql_escape($qi_config['board_email']) . "', user_dateformat='" . $db->sql_escape($user->lang['default_dateformat']) . "', user_email_hash = " . (crc32($qi_config['board_email']) . strlen($qi_config['board_email'])) . ", username_clean = '" . $db->sql_escape(utf8_clean_string($qi_config['admin_name'])) . "'\n\t\t\t\tWHERE username = '******'", "UPDATE {$table_prefix}moderator_cache\n\t\t\t\tSET username = '******'admin_name']) . "'\n\t\t\t\tWHERE username = '******'", "UPDATE {$table_prefix}forums\n\t\t\t\tSET forum_last_poster_name = '" . $db->sql_escape($qi_config['admin_name']) . "'\n\t\t\t\tWHERE forum_last_poster_name = 'Admin'", "UPDATE {$table_prefix}topics\n\t\t\t\tSET topic_first_poster_name = '" . $db->sql_escape($qi_config['admin_name']) . "', topic_last_poster_name = '" . $db->sql_escape($qi_config['admin_name']) . "'\n\t\t\t\tWHERE topic_first_poster_name = 'Admin'\n\t\t\t\t\tOR topic_last_poster_name = 'Admin'", "UPDATE {$table_prefix}users\n\t\t\t\tSET user_regdate = {$current_time}", "UPDATE {$table_prefix}posts\n\t\t\t\tSET post_time = {$current_time}, poster_ip = '" . $db->sql_escape($user_ip) . "'", "UPDATE {$table_prefix}topics\n\t\t\t\tSET topic_time = {$current_time}, topic_last_post_time = {$current_time}", "UPDATE {$table_prefix}forums\n\t\t\t\tSET forum_last_post_time = {$current_time}", "UPDATE {$table_prefix}config\n\t\t\t\tSET config_value = '" . $db->sql_escape($qi_config['site_name']) . "'\n\t\t\t\tWHERE config_name = 'sitename'", "UPDATE {$table_prefix}config\n\t\t\t\tSET config_value = '" . $db->sql_escape($qi_config['site_desc']) . "'\n\t\t\t\tWHERE config_name = 'site_desc'", "UPDATE {$table_prefix}config\n\t\t\t\tSET config_value = '1'\n\t\t\t\tWHERE config_name = 'load_tplcompile'"); foreach ($sql_ary as $sql) { if (!$db->sql_query($sql)) { $error = $db->sql_error(); trigger_error($error['message']); } } // main sql is done, let's get a fresh $config array $sql = 'SELECT * FROM ' . CONFIG_TABLE; $result = $db->sql_query($sql); $config = array(); while ($row = $db->sql_fetchrow($result)) { $config[$row['config_name']] = $row['config_value']; } $db->sql_freeresult($result); // no templates though :P $config['load_tplcompile'] = '1'; // build search index include_once $phpbb_root_path . 'includes/search/fulltext_native.' . $phpEx; $search = new fulltext_native($error = false); $sql = 'SELECT post_id, post_subject, post_text, poster_id, forum_id FROM ' . POSTS_TABLE; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $search->index('post', $row['post_id'], $row['post_text'], $row['post_subject'], $row['poster_id'], $row['forum_id']); } $db->sql_freeresult($result); // extended phpbb install script include $phpbb_root_path . 'install/install_install.' . $phpEx; include $quickinstall_path . 'includes/install_install_qi.' . $phpEx; $install = new install_install_qi($p_master = new p_master_dummy()); $install->set_data(array('dbms' => $dbms, 'dbhost' => $qi_config['dbhost'], 'dbport' => $qi_config['dbport'], 'dbuser' => $qi_config['dbuser'], 'dbpasswd' => $qi_config['dbpasswd'], 'dbname' => $dbname, 'table_prefix' => $table_prefix, 'default_lang' => $qi_config['default_lang'], 'admin_name' => $qi_config['admin_name'], 'admin_pass1' => $qi_config['admin_pass'], 'admin_pass2' => $qi_config['admin_pass'], 'board_email1' => $qi_config['board_email'], 'board_email2' => $qi_config['board_email'], 'email_enable' => $qi_config['email_enable'], 'smtp_delivery' => $qi_config['smtp_delivery'], 'smtp_host' => $qi_config['smtp_host'], 'smtp_auth' => $qi_config['smtp_auth'], 'smtp_user' => $qi_config['smtp_user'], 'smtp_pass' => $qi_config['smtp_pass'], 'cookie_secure' => $qi_config['cookie_secure'], 'server_protocol' => !empty($qi_config['server_protocol']) ? $qi_config['server_protocol'] : 'http://', 'server_name' => $qi_config['server_name'], 'server_port' => $qi_config['server_port'], 'script_path' => $script_path)); $install->add_modules(false, false); $install->add_language(false, false); $install->add_bots(false, false); // login $user->session_begin(); $auth->login($qi_config['admin_name'], $qi_config['admin_pass'], false, true, true); // now automod (easymod) if ($automod) { include $quickinstall_path . 'includes/functions_install_automod.' . $phpEx; automod_installer::install_automod($board_dir, $make_writable); } if ($dbms == 'sqlite' || $dbms == 'firebird') { // copy the temp db over file_functions::copy_file($quickinstall_path . 'cache/' . $qi_config['db_prefix'] . $dbname, $board_dir . $qi_config['db_prefix'] . $dbname); $db->sql_select_db($board_dir . $qi_config['db_prefix'] . $dbname); } // clean up file_functions::delete_files($board_dir, array('Thumbs.db', 'DS_Store', 'CVS', '.svn', '.git')); // remove install dir, develop and umil file_functions::delete_dir($board_dir . 'install/'); file_functions::delete_dir($board_dir . 'develop/'); file_functions::delete_dir($board_dir . 'umil/'); // copy extra user added files file_functions::copy_dir($quickinstall_path . 'sources/extra/', $board_dir); // Install Subsilver2 if ($subsilver) { if (!class_exists('bitfield')) { include $phpbb_root_path . 'includes/functions_content.' . $phpEx; } include $phpbb_root_path . 'includes/acp/acp_styles.' . $phpEx; $acp_styles = new acp_styles(); $acp_styles->main(0, ''); // Mostly copied from includes/acp/acp_styles.php $reqd_template = $reqd_theme = $reqd_imageset = false; $error = $installcfg = $style_row = array(); $element_ary = array('template' => STYLES_TEMPLATE_TABLE, 'theme' => STYLES_THEME_TABLE, 'imageset' => STYLES_IMAGESET_TABLE); $install_path = 'subsilver2'; $root_path = $phpbb_root_path . 'styles/subsilver2/'; $cfg_file = $root_path . 'style.cfg'; $installcfg = parse_cfg_file($cfg_file); if (!sizeof($installcfg)) { continue; } $name = $installcfg['name']; $copyright = $installcfg['copyright']; $version = $installcfg['version']; $style_row = array('style_id' => 0, 'template_id' => 0, 'theme_id' => 0, 'imageset_id' => 0, 'style_name' => $installcfg['name'], 'template_name' => $installcfg['name'], 'theme_name' => $installcfg['name'], 'imageset_name' => $installcfg['name'], 'template_copyright' => $installcfg['copyright'], 'theme_copyright' => $installcfg['copyright'], 'imageset_copyright' => $installcfg['copyright'], 'style_copyright' => $installcfg['copyright'], 'store_db' => 0, 'style_active' => 1, 'style_default' => $subsilver == 2 ? 1 : 0); $acp_styles->install_style($error, 'install', $root_path, $style_row['style_id'], $style_row['style_name'], $install_path, $style_row['style_copyright'], $style_row['style_active'], $style_row['style_default'], $style_row); unset($error); } // Add some random users and posts. if ($populate) { include $quickinstall_path . 'includes/functions_populate.' . $phpEx; new populate($pop_data); } // add log entry :D $user->ip =& $user_ip; add_log('admin', 'LOG_INSTALL_INSTALLED_QI', $qi_config['qi_version']); // purge cache $cache->purge(); // Make all files world writable. if ($make_writable) { file_functions::make_writable($board_dir); } // if he wants to be redirected, redirect him if ($redirect) { qi::redirect($board_dir); } // On succces just return to main page. qi::redirect('index.' . $phpEx); }