示例#1
0
 public function __construct()
 {
     global $db, $template, $user;
     global $quickinstall_path, $phpbb_root_path, $phpEx, $config, $qi_config;
     // list of boards
     $boards_arr = scandir($quickinstall_path . $qi_config['boards_dir']);
     $s_has_forums = false;
     foreach ($boards_arr as $board) {
         if (in_array($board, array('.', '..', '.svn', '.htaccess', '.git'), true) || is_file($quickinstall_path . 'boards/' . $board)) {
             continue;
         }
         $s_has_forums = true;
         $template->assign_block_vars('row', array('BOARD_NAME' => htmlspecialchars($board), 'BOARD_URL' => $quickinstall_path . $qi_config['boards_dir'] . urlencode($board)));
     }
     // list of alternate enviroments
     $alt_env = '<option value="">' . $user->lang['DEFAULT_ENV'] . '</option>';
     $d = dir($quickinstall_path . 'sources/phpBB3_alt');
     while (false !== ($file = $d->read())) {
         if (in_array($file, array('.', '..', '.svn', '.htaccess'), true) || is_file($quickinstall_path . 'sources/phpBB3_alt/' . $file)) {
             continue;
         }
         $alt_env .= '<option>' . htmlspecialchars($file) . '</option>';
     }
     $d->close();
     // Assign index specific vars
     $template->assign_vars(array('U_CREATE' => qi::url('create'), 'S_IN_INSTALL' => false, 'S_IN_SETTINGS' => false, 'S_HAS_FORUMS' => $s_has_forums, 'TABLE_PREFIX' => htmlspecialchars($qi_config['table_prefix']), 'SITE_NAME' => $qi_config['site_name'], 'SITE_DESC' => $qi_config['site_desc'], 'S_AUTOMOD' => empty($qi_config['automod']) ? false : true, 'S_MAKE_WRITABLE' => empty($qi_config['make_writable']) ? false : true, 'S_POPULATE' => empty($qi_config['populate']) ? false : true, 'S_REDIRECT' => empty($qi_config['redirect']) ? false : true, 'S_SUBSILVER' => empty($qi_config['subsilver']) ? false : $qi_config['subsilver'], 'ALT_ENV' => $alt_env, 'PAGE_MAIN' => true, 'NUM_USERS' => !empty($qi_config['num_users']) ? $qi_config['num_users'] : 0, 'NUM_NEW_GROUP' => !empty($qi_config['num_new_group']) ? $qi_config['num_new_group'] : 0, 'CREATE_MOD' => !empty($qi_config['create_mod']) ? 1 : 0, 'CREATE_ADMIN' => !empty($qi_config['create_admin']) ? 1 : 0, 'NUM_CATS' => !empty($qi_config['num_cats']) ? $qi_config['num_cats'] : 0, 'NUM_FORUMS' => !empty($qi_config['num_forums']) ? $qi_config['num_forums'] : 0, 'NUM_TOPICS_MIN' => !empty($qi_config['num_topics_min']) ? $qi_config['num_topics_min'] : 0, 'NUM_TOPICS_MAX' => !empty($qi_config['num_topics_max']) ? $qi_config['num_topics_max'] : 0, 'NUM_REPLIES_MIN' => !empty($qi_config['num_replies_min']) ? $qi_config['num_replies_min'] : 0, 'NUM_REPLIES_MAX' => !empty($qi_config['num_replies_max']) ? $qi_config['num_replies_max'] : 0, 'EMAIL_DOMAIN' => !empty($qi_config['email_domain']) ? $qi_config['email_domain'] : ''));
     // Output page
     qi::page_header($user->lang['QI_MAIN'], $user->lang['QI_MAIN_ABOUT']);
     $template->set_filenames(array('body' => 'main_body.html'));
     qi::page_footer();
 }
示例#2
0
 public function __construct()
 {
     global $db, $template, $user;
     global $quickinstall_path, $phpbb_root_path, $phpEx, $config, $qi_config;
     if ($qi_config['version_check']) {
         // we use this for get_remote_file()
         include $phpbb_root_path . 'includes/functions_admin.' . $phpEx;
         // Get current and latest version
         $errstr = '';
         $errno = 0;
         $info = get_remote_file('phpbbmodders.net', '/files/updatecheck', 'quickinstall.txt', $errstr, $errno);
         if ($info !== false) {
             list($latest_version, $announcement_url) = explode("\n", $info);
             $up_to_date = version_compare(str_replace('rc', 'RC', strtolower($qi_config['qi_version'])), str_replace('rc', 'RC', strtolower($latest_version)), '<') ? false : true;
             $template->assign_vars(array('UP_TO_DATE' => $up_to_date, 'L_UPDATE' => sprintf($user->lang['UPDATE_TO'], $announcement_url, $latest_version)));
         }
     }
     $changelog_file = $quickinstall_path . 'changelog.xml';
     if ($use_changelog = file_exists($changelog_file)) {
         // let's get the changelog :)
         $automod_path = '';
         if (file_exists($quickinstall_path . 'sources/automod/includes')) {
             // Let's assume they copied the contents.
             $automod_path = $quickinstall_path . 'sources/automod/';
         } else {
             if (file_exists($quickinstall_path . 'sources/automod/root/includes')) {
                 // They copied to complete root to automod instead of its contents.
                 $automod_path = $quickinstall_path . 'sources/automod/root/';
             } else {
                 if (file_exists($quickinstall_path . 'sources/automod/upload/includes')) {
                     // They copied to complete upload directory to automod instead of its contents.
                     $automod_path = $quickinstall_path . 'sources/automod/upload/';
                 } else {
                     trigger_error($user->lang['NO_AUTOMOD']);
                 }
             }
         }
         include $automod_path . 'includes/mod_parser.' . $phpEx;
         $xml_parser = new xml_array();
         $data = $xml_parser->parse($changelog_file, file_get_contents($changelog_file));
         foreach ($data[0]['children']['ENTRY'] as &$entry) {
             list($year, $month, $day) = explode('-', $entry['children']['DATE'][0]['data']);
             $template->assign_block_vars('history', array('DATE' => qi::format_date(mktime(null, null, null, intval($month), intval($day), intval($year)), 'Y-m-d'), 'VERSION' => $entry['children']['VERSION'][0]['data']));
             foreach ($entry['children']['CHANGELOG'][0]['children']['CHANGE'] as &$change) {
                 $template->assign_block_vars('history.changelog', array('CHANGE' => htmlspecialchars($change['data'])));
             }
         }
     }
     $template->assign_vars(array('S_IN_INSTALL' => false, 'S_IN_SETTINGS' => false, 'S_ALLOW_VERSION_CHECK' => $qi_config['version_check'], 'S_ALLOW_CHANGELOG' => $use_changelog, 'PAGE_MAIN' => false));
     // Output page
     qi::page_header($user->lang['QI_ABOUT'], $user->lang['QI_ABOUT_ABOUT']);
     $template->set_filenames(array('body' => 'about_body.html'));
     qi::page_footer();
 }
示例#3
0
 public function __construct()
 {
     global $db, $template, $user, $settings;
     global $quickinstall_path, $phpbb_root_path, $phpEx, $config;
     get_installed_boards();
     $profiles = $settings->get_profiles();
     // Some error?
     if ($settings->get_config('error', 0)) {
         $error_msg = $settings->get_config('error_msg', '', true);
         $error_msg = htmlspecialchars_decode($error_msg);
         $template->assign_var('ERROR_MSG', $error_msg);
     }
     // Assign index specific vars
     $template->assign_vars(array('U_CREATE' => qi::url('create'), 'U_CHOOSE_PROFILE' => qi::url('main', array('mode' => 'change_profile')), 'TABLE_PREFIX' => $settings->get_config('table_prefix', ''), 'DB_PERFIX' => htmlspecialchars($settings->get_config('db_prefix', '')), 'SITE_NAME' => $settings->get_config('site_name', ''), 'SITE_DESC' => $settings->get_config('site_desc', ''), 'PROFILE_COUNT' => $profiles['count'], 'PROFILE_OPTIONS' => $profiles['options'], 'DBNAME' => $settings->get_config('dbname', ''), 'INSTALL_STYLES' => $settings->get_config('install_styles', 0), 'DEFAULT_STYLE' => $settings->get_config('default_style', ''), 'S_ERROR' => $settings->get_config('error', 0), 'ERROR_TITLE' => $settings->get_config('error_title', ''), 'S_AUTOMOD' => $settings->get_config('automod', 0), 'S_DELETE_FILES' => $settings->get_config('delete_files', 0), 'S_DROP_DB' => $settings->get_config('drop_db', 0), 'S_MAKE_WRITABLE' => $settings->get_config('make_writable', 0), 'S_POPULATE' => $settings->get_config('populate', 0), 'S_REDIRECT' => $settings->get_config('redirect', 0), 'S_ADMIN_NAME' => $settings->get_config('admin_name', false), 'S_ADMIN_PASS' => $settings->get_config('admin_pass', false), 'S_DBPASSWD' => $settings->get_config('dbpasswd', false), 'S_NODBPASSWD' => $settings->get_config('no_dbpasswd', false), 'S_DBUSER' => $settings->get_config('dbuser', false), 'S_MAIN' => true, 'ALT_ENV' => get_alternative_env($settings->get_config('alt_env')), 'CHUNK_POST' => $settings->get_config('chunk_post', 0), 'CHUNK_TOPIC' => $settings->get_config('chunk_topic', 0), 'CHUNK_USER' => $settings->get_config('chunk_user', 0), 'NUM_USERS' => $settings->get_config('num_users', 0), 'NUM_NEW_GROUP' => $settings->get_config('num_new_group', 0), 'CREATE_MOD' => $settings->get_config('create_mod', 0), 'CREATE_ADMIN' => $settings->get_config('create_admin', 0), 'NUM_CATS' => $settings->get_config('num_cats', 0), 'NUM_FORUMS' => $settings->get_config('num_forums', 0), 'NUM_TOPICS_MIN' => $settings->get_config('num_topics_min', 0), 'NUM_TOPICS_MAX' => $settings->get_config('num_topics_max', 0), 'NUM_REPLIES_MIN' => $settings->get_config('num_replies_min', 0), 'NUM_REPLIES_MAX' => $settings->get_config('num_replies_max', 0), 'EMAIL_DOMAIN' => $settings->get_config('email_domain', ''), 'GRANT_PERMISSIONS' => $settings->get_config('grant_permissions', ''), 'OTHER_CONFIG' => $settings->get_other_config()));
     // Output page
     qi::page_header($user->lang['QI_MANAGE'], $user->lang['QI_MANAGE_ABOUT']);
     $template->set_filenames(array('body' => 'main_body.html'));
     qi::page_footer();
 }
示例#4
0
 public function __construct()
 {
     global $db, $template, $user;
     global $quickinstall_path, $phpbb_root_path, $phpEx, $config, $qi_config, $msg_title;
     $action = request_var('action', '');
     $delete = request_var('delete', false);
     if ($delete) {
         $action = 'delete';
     }
     switch ($action) {
         case 'delete':
             $select = request_var('select', array(0 => ''), true);
             foreach ($select as $item) {
                 $current_item = $quickinstall_path . 'boards/' . $item;
                 // Make sure we have a valid db-name and prefix
                 $qi_config['db_prefix'] = validate_dbname($qi_config['db_prefix'], true);
                 $item = validate_dbname($item);
                 $db->sql_query('DROP DATABASE IF EXISTS ' . $qi_config['db_prefix'] . $item);
                 if (!file_exists($current_item) || !is_dir($current_item)) {
                     continue;
                 }
                 file_functions::delete_dir($current_item);
             }
             // Just return to main page after succesfull deletion.
             qi::redirect('index.' . $phpEx);
             break;
         default:
             // list of boards
             $boards_arr = scandir($quickinstall_path . $qi_config['boards_dir']);
             foreach ($boards_arr as $board) {
                 if (in_array($board, array('.', '..', '.svn', '.htaccess', '.git'), true) || is_file($quickinstall_path . 'boards/' . $board)) {
                     continue;
                 }
                 $template->assign_block_vars('row', array('BOARD_NAME' => htmlspecialchars($board), 'BOARD_URL' => $quickinstall_path . $qi_config['boards_dir'] . urlencode($board)));
             }
             $template->assign_vars(array('S_IN_INSTALL' => false, 'S_IN_SETTINGS' => false, 'PAGE_MAIN' => false));
             // Output page
             qi::page_header($user->lang['QI_MANAGE'], $user->lang['QI_MANAGE_ABOUT']);
             $template->set_filenames(array('body' => 'manage_body.html'));
             qi::page_footer();
             break;
     }
 }
示例#5
0
 public function __construct()
 {
     global $db, $template, $user, $settings;
     global $quickinstall_path, $phpbb_root_path, $phpEx, $config;
     ob_start();
     phpinfo(INFO_GENERAL | INFO_CONFIGURATION | INFO_MODULES | INFO_VARIABLES);
     $phpinfo = ob_get_clean();
     $phpinfo = trim($phpinfo);
     preg_match_all('#<body[^>]*>(.*)</body>#si', $phpinfo, $output);
     if (empty($phpinfo) || empty($output)) {
         trigger_error('NO_PHPINFO_AVAILABLE', E_USER_WARNING);
     }
     $output = $output[1][0];
     // expose_php can make the image not exist
     if (preg_match('#<a[^>]*><img[^>]*></a>#', $output)) {
         $output = preg_replace('#<tr class="v"><td>(.*?<a[^>]*><img[^>]*></a>)(.*?)</td></tr>#s', '<tr class="row1"><td><table class="type2"><tr><td>\\2</td><td>\\1</td></tr></table></td></tr>', $output);
     } else {
         $output = preg_replace('#<tr class="v"><td>(.*?)</td></tr>#s', '<tr class="row1"><td><table class="type2"><tr><td>\\1</td></tr></table></td></tr>', $output);
     }
     $output = preg_replace('#<table[^>]+>#i', '<table>', $output);
     $output = preg_replace('#<img border="0"#i', '<img', $output);
     $output = str_replace(array('class="e"', 'class="v"', 'class="h"', '<hr />', '<font', '</font>'), array('class="row1"', 'class="row2"', '', '', '<span', '</span>'), $output);
     // Fix invalid anchor names (eg "module_Zend Optimizer")
     $output = preg_replace_callback('#<a name="([^"]+)">#', array($this, 'remove_spaces'), $output);
     if (empty($output)) {
         trigger_error('NO_PHPINFO_AVAILABLE', E_USER_WARNING);
     }
     $orig_output = $output;
     preg_match_all('#<div class="center">(.*)</div>#siU', $output, $output);
     $output = !empty($output[1][0]) ? $output[1][0] : $orig_output;
     $template->assign_vars(array('S_PHPINFO' => true, 'PHPINFO' => $output));
     // Output page
     qi::page_header($user->lang['PHPINFO'], $user->lang['PHPINFO_EXPLAIN']);
     $template->set_filenames(array('body' => 'phpinfo_body.html'));
     qi::page_footer();
 }
 /**
  * Error and message handler, call with trigger_error if reqd
  */
 public static function msg_handler($errno, $msg_text, $errfile, $errline)
 {
     global $phpEx, $phpbb_root_path, $msg_title, $msg_long_text, $quickinstall_path;
     global $user;
     // Message handler is stripping text. In case we need it, we are possible to define long text...
     if (isset($msg_long_text) && $msg_long_text && !$msg_text) {
         $msg_text = $msg_long_text;
     }
     switch ($errno) {
         case E_NOTICE:
         case E_WARNING:
             // Check the error reporting level and return if the error level does not match
             // Additionally do not display notices if we suppress them via @
             // If DEBUG is defined the default level is E_ALL
             if (($errno & (defined('DEBUG') && error_reporting() ? E_ALL : error_reporting())) == 0) {
                 return;
             }
             // remove complete path to installation, with the risk of changing backslashes meant to be there
             $errfile = str_replace(array(phpbb_realpath($phpbb_root_path), '\\'), array('', '/'), $errfile);
             $msg_text = str_replace(array(phpbb_realpath($phpbb_root_path), '\\'), array('', '/'), $msg_text);
             echo '<b>[phpBB Debug] PHP Notice</b>: in file <b>' . $errfile . '</b> on line <b>' . $errline . '</b>: <b>' . $msg_text . '</b><br />' . "\n";
             return;
             break;
         case E_USER_ERROR:
         case E_USER_WARNING:
         case E_USER_NOTICE:
             // uncomment for debug
             //echo "$errfile:$errline";
             $msg_title = isset($msg_title) ? isset($user->lang[$msg_title]) ? $user->lang[$msg_title] : $msg_title : (isset($user->lang['GENERAL_ERROR']) ? $user->lang['GENERAL_ERROR'] : 'General Error');
             $msg_text = isset($user->lang[$msg_text]) ? $user->lang[$msg_text] : $msg_text;
             $l_return_index = '<a href="' . qi::url('settings') . '">Go to settings</a> &bull; ';
             $l_return_index .= '<a href="' . qi::url('main') . '">Go to QuickInstall main page</a>';
             echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
             echo '<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">';
             echo '<head>';
             echo '<meta http-equiv="content-type" content="text/html; charset=utf-8" />';
             echo '<title>' . $msg_title . '</title>';
             echo '<link href="' . $quickinstall_path . 'style/style.css" rel="stylesheet" type="text/css" media="screen" />';
             echo '</head>';
             echo '<body id="errorpage">';
             echo '<div id="wrap">';
             echo '	<div id="page-header">';
             echo '		' . $l_return_index;
             echo '	</div>';
             echo '	<div id="page-body">';
             echo '		<div id="acp">';
             echo '		<div class="panel">';
             echo '			<span class="corners-top"><span></span></span>';
             echo '			<div id="content">';
             echo '			<h1>' . $msg_title . '</h1>';
             echo '			<div>' . $msg_text . '</div>';
             echo '			</div>';
             echo '			<div style="padding-left: 10px;">';
             echo '		' . $l_return_index;
             echo '			</div>';
             echo '			<span class="corners-bottom"><span></span></span>';
             echo '		</div>';
             echo '		</div>';
             echo '	</div>';
             echo '	<div id="page-footer">';
             echo '		Powered by phpBB &copy; 2000, 2002, 2005, 2007 <a href="http://www.phpbb.com/">phpBB Group</a>';
             echo '	</div>';
             echo '</div>';
             echo '</body>';
             echo '</html>';
             exit;
             break;
     }
     // If we notice an error not handled here we pass this back to PHP by returning false
     // This may not work for all php versions
     return false;
 }
示例#7
0
            $profile = '';
        }
    } else {
        $s_settings_failure = true;
    }
    $qi_install = false;
}
$s_settings_writable = true;
if ($settings->install) {
    // Don't show errors when installing QI
    $error = '';
} else {
    if (!is_writable($quickinstall_path . 'settings') || !is_dir($quickinstall_path . 'settings')) {
        $error .= $user->lang['SETTINGS_NOT_WRITABLE'] . '<br />';
        $s_settings_writable = false;
    }
}
if ($alt_env_missing && !$attempted && !$saved) {
    $err_string = sprintf($user->lang['NO_ALT_ENV_FOUND'], $alt_env);
    $error .= $err_string . '<br />';
}
$profiles = $settings->get_profiles();
$template->assign_vars(array('S_BOARDS_WRITABLE' => is_writable($settings->get_boards_dir()), 'S_CACHE_WRITABLE' => is_writable($settings->get_cache_dir()), 'S_CONFIG_WRITABLE' => is_writable($quickinstall_path . 'settings'), 'S_IN_INSTALL' => $settings->install, 'S_IS_CONVERTED' => $settings->is_converted, 'S_SETTINGS_WRITABLE' => $s_settings_writable, 'S_SETTINGS_SUCCESS' => $attempted && $saved ? true : false, 'S_SETTINGS_FAILURE' => $attempted && !$saved ? true : false, 'S_SETTINGS' => true, 'ERROR' => $error, 'U_UPDATE_SETTINGS' => qi::url('settings', array('mode' => 'update_settings')), 'U_CHOOSE_PROFILE' => qi::url('settings', array('mode' => 'change_profile')), 'SAVE_PROFILE' => $profile, 'TABLE_PREFIX' => htmlspecialchars($settings->get_config('table_prefix')), 'SITE_NAME' => $settings->get_config('site_name'), 'SITE_DESC' => $settings->get_config('site_desc'), 'ALT_ENV' => !empty($alt_env) ? $alt_env : false, 'PROFILE_COUNT' => $profiles['count'], 'PROFILE_OPTIONS' => $profiles['options'], 'QI_LANG' => $settings->get_lang_select("{$quickinstall_path}language/", 'qi_lang', 'lang'), 'PHPBB_LANG' => $settings->get_lang_select("{$quickinstall_path}sources/phpBB3/language/", 'default_lang'), 'CONFIG_SAVED' => $saved, 'CONFIG_TEXT' => htmlspecialchars($config_text), 'CHUNK_POST' => $settings->get_config('chunk_post', 0), 'CHUNK_TOPIC' => $settings->get_config('chunk_topic', 0), 'CHUNK_USER' => $settings->get_config('chunk_user', 0), 'CONFIG_ADMIN_EMAIL' => $settings->get_config('admin_email'), 'CONFIG_ADMIN_NAME' => $settings->get_config('admin_name'), 'CONFIG_ADMIN_PASS' => $settings->get_config('admin_pass'), 'CONFIG_ALT_ENV' => get_alternative_env($settings->get_config('alt_env')), 'CONFIG_AUTOMOD' => $settings->get_config('automod', 0), 'CONFIG_BOARD_EMAIL' => $settings->get_config('board_email'), 'CONFIG_BOARDS_DIR' => $settings->get_boards_dir(), 'CONFIG_BOARDS_URL' => $settings->get_boards_url(), 'CONFIG_CACHE_DIR' => $settings->get_cache_dir(), 'CONFIG_COOKIE_DOMAIN' => $settings->get_config('cookie_domain'), 'CONFIG_COOKIE_SECURE' => $settings->get_config('cookie_secure', 0), 'CONFIG_DB_PREFIX' => $settings->get_config('db_prefix'), 'CONFIG_DBHOST' => $settings->get_config('dbhost'), 'CONFIG_DBMS' => gen_dbms_options($settings->get_config('dbms')), 'CONFIG_DBPASSWD' => $settings->get_config('dbpasswd'), 'CONFIG_DBPORT' => $settings->get_config('dbport'), 'CONFIG_DBUSER' => $settings->get_config('dbuser'), 'CONFIG_DEFAULT_STYLE' => $settings->get_config('default_style', ''), 'CONFIG_DELETE_FILES' => $settings->get_config('delete_files', 0), 'CONFIG_DROP_DB' => $settings->get_config('drop_db', 0), 'CONFIG_EMAIL_ENABLE' => $settings->get_config('email_enable', 0), 'CONFIG_GRANT_PERMISSIONS' => $settings->get_config('grant_permissions'), 'CONFIG_INSTALL_STYLES' => $settings->get_config('install_styles', 0), 'CONFIG_MAKE_WRITABLE' => $settings->get_config('make_writable', 0), 'CONFIG_NO_PASSWORD' => $settings->get_config('no_dbpasswd', 0), 'CONFIG_POPULATE' => $settings->get_config('populate', 0), 'CONFIG_QI_DST' => $settings->get_config('qi_dst', 0), 'CONFIG_QI_TZ' => $settings->get_config('qi_tz', ''), 'CONFIG_REDIRECT' => $settings->get_config('redirect', 0), 'CONFIG_SERVER_NAME' => $settings->get_config('server_name'), 'CONFIG_SERVER_PORT' => $settings->get_config('server_port'), 'CONFIG_SHOW_CONFIRM' => $settings->get_config('show_confirm', 0), 'CONFIG_SITE_DESC' => $settings->get_config('site_desc'), 'CONFIG_SITE_NAME' => $settings->get_config('site_name'), 'CONFIG_SMTP_AUTH' => $settings->get_config('smtp_auth'), 'CONFIG_SMTP_DELIVERY' => $settings->get_config('smtp_delivery', 0), 'CONFIG_SMTP_HOST' => $settings->get_config('smtp_host'), 'CONFIG_SMTP_PASS' => $settings->get_config('smtp_pass'), 'CONFIG_SMTP_PORT' => $settings->get_config('smtp_port', 0), 'CONFIG_SMTP_USER' => $settings->get_config('smtp_user'), 'CONFIG_TABLE_PREFIX' => $settings->get_config('table_prefix'), 'CONFIG_NUM_USERS' => $settings->get_config('num_users', 0), 'CONFIG_NUM_NEW_GROUP' => $settings->get_config('num_new_group', 0), 'CONFIG_CREATE_ADMIN' => $settings->get_config('create_admin', 0), 'CONFIG_CREATE_MOD' => $settings->get_config('create_mod', 0), 'CONFIG_NUM_CATS' => $settings->get_config('num_cats', 0), 'CONFIG_NUM_FORUMS' => $settings->get_config('num_forums', 0), 'CONFIG_NUM_TOPICS_MIN' => $settings->get_config('num_topics_min', 0), 'CONFIG_NUM_TOPICS_MAX' => $settings->get_config('num_topics_max', 0), 'CONFIG_NUM_REPLIES_MIN' => $settings->get_config('num_replies_min', 0), 'CONFIG_NUM_REPLIES_MAX' => $settings->get_config('num_replies_max', 0), 'CONFIG_EMAIL_DOMAIN' => $settings->get_config('email_domain'), 'TIMEZONE_OPTIONS' => qi_timezone_select($user, $settings->get_config('qi_tz', 'UTC')), 'OTHER_CONFIG' => $settings->get_other_config(), 'SEL_LANG' => !empty($language) ? $language : ''));
/*
	''	=> $settings->get_config('', 0),
*/
// Output page
qi::page_header($user->lang['PROFILES']);
$template->set_filenames(array('body' => 'settings_body.html'));
qi::page_footer();
 public function redirect($url)
 {
     qi::redirect($url);
 }
示例#9
0
 /**
  * Error and message handler, call with trigger_error if reqd.
  * Mostly borrowed from phpBB includes/functions.php.
  */
 public static function msg_handler($errno, $msg_text, $errfile, $errline)
 {
     global $phpEx, $phpbb_root_path, $msg_title, $msg_long_text, $quickinstall_path;
     global $user;
     // Do not display notices if we suppress them via @
     if (error_reporting() == 0 && $errno != E_USER_ERROR && $errno != E_USER_WARNING && $errno != E_USER_NOTICE) {
         return;
     }
     // Message handler is stripping text. In case we need it, we are possible to define long text...
     if (isset($msg_long_text) && $msg_long_text && !$msg_text) {
         $msg_text = $msg_long_text;
     }
     if (!defined('E_DEPRECATED')) {
         define('E_DEPRECATED', 8192);
     }
     switch ($errno) {
         case E_NOTICE:
         case E_WARNING:
             // Check the error reporting level and return if the error level does not match
             // If DEBUG is defined the default level is E_ALL
             if (($errno & (defined('DEBUG') ? E_ALL : error_reporting())) == 0) {
                 return;
             }
             // remove complete path to installation, with the risk of changing backslashes meant to be there
             $errfile = str_replace(array(phpbb_functions::phpbb_realpath($phpbb_root_path), '\\'), array('', '/'), $errfile);
             $msg_text = str_replace(array(phpbb_functions::phpbb_realpath($phpbb_root_path), '\\'), array('', '/'), $msg_text);
             $error_name = $errno === E_WARNING ? 'PHP Warning' : 'PHP Notice';
             echo '<b>[QI Debug] ' . $error_name . '</b>: in file <b>' . $errfile . '</b> on line <b>' . $errline . '</b>: <b>' . $msg_text . '</b><br />' . "\n";
             return;
             break;
         case E_USER_ERROR:
         case E_USER_WARNING:
         case E_USER_NOTICE:
             if (!empty($user) && !empty($user->lang)) {
                 $msg_text = !empty($user->lang[$msg_text]) ? $user->lang[$msg_text] : $msg_text;
                 $msg_title = !isset($msg_title) ? $user->lang['GENERAL_ERROR'] : (!empty($user->lang[$msg_title]) ? $user->lang[$msg_title] : $msg_title);
                 $l_return_index = sprintf($user->lang['GO_QI_MAIN'], '<a href="' . qi::url('main') . '">', '</a> &bull; ');
                 $l_return_index .= sprintf($user->lang['GO_QI_SETTINGS'], '<a href="' . qi::url('settings') . '">', '</a>');
             } else {
                 $msg_title = 'General Error';
                 $l_return_index = '<a href="' . qi::url('main') . '">Go to QuickInstall main page</a> &bull; ';
                 $l_return_index .= '<a href="' . qi::url('settings') . '">Go to settings</a> &bull; ';
             }
             $backtrace = phpbb_functions::get_backtrace();
             if ($backtrace) {
                 $msg_text .= '<br /><br />BACKTRACE<br />' . $backtrace;
             }
             phpbb_functions::send_status_line(503, 'Service Unavailable');
             echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
             echo '<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">';
             echo '<head>';
             echo '<meta http-equiv="content-type" content="text/html; charset=utf-8" />';
             echo '<title>' . $msg_title . '</title>';
             echo '<link href="' . $quickinstall_path . 'style/style.css" rel="stylesheet" type="text/css" media="screen" />';
             echo '</head>';
             echo '<body id="errorpage">';
             echo '<div id="wrap">';
             echo '	<div id="page-header">';
             echo '		' . $l_return_index;
             echo '	</div>';
             echo '	<div id="page-body">';
             echo '		<div id="acp">';
             echo '			<div class="panel">';
             echo '				<span class="corners-top"><span></span></span>';
             echo '				<div id="content">';
             echo '				<h1>' . $msg_title . '</h1>';
             echo '				<div>' . $msg_text . '</div>';
             echo '				</div>';
             echo '				<div style="padding-left: 10px;">';
             echo '					' . $l_return_index;
             echo '				</div>';
             echo '				<span class="corners-bottom"><span></span></span>';
             echo '			</div>';
             echo '		</div>';
             echo '	</div>';
             echo '	<div id="page-footer">';
             echo '		<a href="https://www.phpbb.com/customise/db/official_tool/phpbb3_quickinstall/">phpBB QuickInstall</a> {QI_VERSION} for phpBB 3.0, 3.1 and 3.2 &copy; <a href="https://www.phpbb.com/">phpBB Limited</a><br />';
             echo '		Powered by phpBB&reg; Forum Software &copy; <a href="https://www.phpbb.com/">phpBB Limited</a>';
             echo '	</div>';
             echo '</div>';
             echo '</body>';
             echo '</html>';
             // As a pre-caution... some setups display a blank page if the flush() is not there.
             ob_get_level() > 0 ? @ob_flush() : @flush();
             // On a fatal error (and E_USER_ERROR *is* fatal) we never want other scripts to continue and force an exit here.
             exit;
             break;
     }
     // If we notice an error not handled here we pass this back to PHP by returning false
     // This may not work for all php versions
     return false;
 }
示例#10
0
 /**
  * Applies language selected by user to quickinstall.
  */
 function apply_language($lang = '')
 {
     global $quickinstall_path, $user;
     if (empty($user)) {
         return;
     }
     $lang = empty($lang) ? $this->config['qi_lang'] : $lang;
     $lang = file_exists("{$quickinstall_path}language/{$lang}") ? $lang : 'en';
     if (!empty($user)) {
         $user->lang = file_exists("{$quickinstall_path}language/{$lang}") ? $lang : 'en';
     }
     // Need to make sure 'en' exists too.
     if (file_exists("{$quickinstall_path}language/{$lang}")) {
         qi::add_lang(array('qi', 'phpbb'), "{$quickinstall_path}language/{$lang}/");
     } else {
         trigger_error('Neither your selected language or English found. Make sure that you have at least the English language files in QI_PATH/language/', E_USER_ERROR);
     }
 }
示例#11
0
    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);
    }
示例#12
0
/**
 * update_settings
 * Saves config to file.
 *
 * @param array
 * @return string, error
 */
function update_settings(&$config)
{
    global $quickinstall_path, $phpEx, $user;
    // The config cant be empty
    if (empty($config)) {
        return $user->lang['CONFIG_EMPTY'];
    }
    $error = validate_settings($config);
    if (!empty($error)) {
        return $error;
    }
    // Let's make sure our boards dir ends with a slash.
    $config['boards_dir'] = substr($config['boards_dir'], -1) == '/' ? $config['boards_dir'] : $config['boards_dir'] . '/';
    $cfg_string = '';
    foreach ($config as $key => $value) {
        $cfg_string .= $key . '=' . $value . "\n";
    }
    if (!empty($config['qi_lang']) && $config['qi_lang'] != $user->lang['USER_LANG']) {
        if (file_exists($quickinstall_path . 'language/' . $config['qi_lang'])) {
            $user->lang = $config['qi_lang'];
            qi::add_lang(array('qi', 'phpbb'), $quickinstall_path . 'language/' . $config['qi_lang'] . '/');
        }
    }
    file_put_contents($quickinstall_path . 'qi_config.cfg', $cfg_string);
}
示例#13
0
    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);
    }
示例#14
0
 public function __construct()
 {
     global $template, $user, $settings;
     global $quickinstall_path, $phpbb_root_path, $phpEx, $config, $msg_title;
     $action = request_var('action', '');
     $delete = request_var('delete', false);
     if ($delete) {
         $action = 'delete';
     }
     switch ($action) {
         case 'delete':
             $select = request_var('select', array(0 => ''), true);
             $boards = sizeof($select);
             $error = array();
             foreach ($select as $item) {
                 $current_item = $settings->get_boards_dir() . $item;
                 // Need to get the dbname from the board.
                 @(include $current_item . '/config.php');
                 if (!empty($dbname) && !empty($dbhost) && !empty($dbms)) {
                     $dbms = strpos($dbms, '\\') !== false ? substr(strrchr($dbms, '\\'), 1) : $dbms;
                     if ($dbms == 'sqlite') {
                         $db_file = $dbhost . $dbname;
                         if (file_exists($db_file)) {
                             // Assuming the DB file is created by PHP, then PHP should also have permissions to delete it.
                             @unlink($db_file);
                         }
                     } else {
                         if (!empty($dbuser) && !empty($dbpasswd)) {
                             // The order here is important, don't change it.
                             $db_vars = array($dbms, $dbhost, $dbuser, $dbpasswd, $dbport);
                             $db = db_connect($db_vars);
                             $db->sql_query('DROP DATABASE IF EXISTS ' . $dbname);
                             db_close($db);
                             // Might give a error since the DB it deleted, needs to be more tested.
                         }
                     }
                 }
                 if (!file_exists($current_item) || !is_dir($current_item)) {
                     continue;
                 }
                 file_functions::delete_dir($current_item);
                 if (!empty(file_functions::$error)) {
                     if ($boards > 1) {
                         $error[] = $current_item;
                         file_functions::$error = array();
                     } else {
                         $error = file_functions::$error;
                     }
                 }
             }
             if (empty($error)) {
                 // Just return to main page after succesfull deletion.
                 qi::redirect('index.' . $phpEx);
             } else {
                 foreach ($error as $row) {
                     $template->assign_block_vars('row', array('ERROR' => htmlspecialchars($row)));
                 }
                 $template->assign_var('L_THE_ERROR', $boards > 1 ? $user->lang['ERROR_DEL_BOARDS'] : $user->lang['ERROR_DEL_FILES']);
                 qi::page_header($user->lang['QI_MANAGE'], $user->lang['QI_MANAGE_ABOUT']);
                 $template->set_filenames(array('body' => 'errors_body.html'));
                 qi::page_footer();
             }
             break;
         default:
             // list of boards
             get_installed_boards();
             // Output page
             qi::page_header($user->lang['QI_MANAGE'], $user->lang['QI_MANAGE_ABOUT']);
             $template->set_filenames(array('body' => 'manage_body.html'));
             qi::page_footer();
             break;
     }
 }
示例#15
0
function create_board_warning($msg_title, $msg_text, $page)
{
    global $settings, $phpEx;
    $args = 'page=' . urlencode($page);
    $args .= '&error_title=' . urlencode($msg_title);
    $args .= '&error_msg=' . urlencode($msg_text);
    $args .= '&error=' . 1;
    foreach ($_POST as $key => $value) {
        if (!empty($value)) {
            $args .= "&{$key}=" . urlencode($value);
        }
    }
    $url = "index.{$phpEx}?{$args}";
    qi::redirect($url);
}
示例#16
0
$qi_config['version_check'] = false;
$qi_config['qi_version'] = QI_VERSION;
$qi_config['phpbb_version'] = PHPBB_VERSION;
$qi_config['automod_version'] = AUTOMOD_VERSION;
// 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($dbms);
if (!isset($available_dbms[$dbms]['DRIVER'])) {
    trigger_error("The {$dbms} dbms is either not supported, or the php extension for it could not be loaded.", E_USER_ERROR);
}
// Load the appropriate database class if not already loaded
include $phpbb_root_path . 'includes/db/' . $available_dbms[$dbms]['DRIVER'] . '.' . $phpEx;
// now the quickinstall dbal extension
include $quickinstall_path . 'includes/db/' . $available_dbms[$dbms]['DRIVER'] . '.' . $phpEx;
// Instantiate the database
$sql_db = 'dbal_' . $available_dbms[$dbms]['DRIVER'] . '_qi';
$db = new $sql_db();
$db->sql_connect($dbhost, $dbuser, $dbpasswd, false, $dbport, false, false);
$db->sql_return_on_error(true);
// now create a module_handler object
$auth = new auth();
$cache = new cache();
$module = new module_handler($quickinstall_path . 'modules/', 'qi_');
// Set some standard variables we want to force
$config = array('load_tplcompile' => '1');
// overwrite
$cache->cache_dir = $quickinstall_path . 'cache/';
$template->cachepath = $quickinstall_path . 'cache/tpl_qi_';
// load lang
qi::add_lang(array('qi', 'phpbb'));
// Load the main module
$module->load($mode, 'qi_main');
示例#17
0
 public function __construct()
 {
     global $db, $template, $user, $settings, $s_docs;
     global $quickinstall_path, $phpbb_root_path, $phpEx, $config;
     if (legacy_request_var('page', '') == 'docs') {
         $s_about = false;
         $s_docs = true;
     } else {
         $s_about = true;
         $s_docs = false;
     }
     if ($s_about) {
         $changelog_file = $quickinstall_path . 'CHANGELOG';
         if (file_exists($changelog_file)) {
             // let's get the changelog :)
             $data = file($changelog_file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
             // We do not want the first line.
             unset($data[0]);
             foreach ($data as $row) {
                 $row = ltrim($row);
                 if ($row[0] == '-') {
                     $key = substr($row, 2);
                     $template->assign_block_vars('history', array('CHANGES_SINCE' => $key, 'U_CHANGES' => strtolower(str_replace(' ', '-', $key))));
                 } else {
                     $change = substr($row, 2);
                     $template->assign_block_vars('history.changelog', array('CHANGE' => htmlspecialchars($change)));
                 }
             }
         }
     } else {
         $doc_file = $quickinstall_path . 'readme.txt';
         if (file_exists($doc_file)) {
             $file_ary = file($doc_file, FILE_IGNORE_NEW_LINES);
             $preg_url = '!(http|http)(s)?:\\/\\/[a-zA-Z0-9.?&_/]+!';
             $end = sizeof($file_ary);
             // We do not want the first line.
             for ($i = 1; $i < $end; $i++) {
                 if (empty($file_ary[$i]) && empty($file_ary[$i + 1])) {
                     $i = $i + 2;
                     $doc_row = "</p>\n<h3>{$file_ary[$i]}</h3>\n<p>";
                 } else {
                     if (empty($file_ary[$i]) && !empty($file_ary[$i + 1])) {
                         $doc_row = "<br /><br />\n";
                     } else {
                         if (preg_match($preg_url, $file_ary[$i], $url)) {
                             $doc_row = preg_replace($preg_url, "<a href=\"\\0\">\\0</a>", $file_ary[$i]);
                         } else {
                             $doc_row = "{$file_ary[$i]}\n";
                         }
                     }
                 }
                 $template->assign_block_vars('doc_row', array('ROW' => !empty($doc_row) ? $doc_row : ''));
             }
             $template->assign_block_vars('doc_row', array('ROW' => '</p>'));
             /*
             				foreach ($data as $row)
             				{
             					if (empty($row))
             					{
             						if ($p_start && $empty_row == 1)
             						{
             							$doc_row = "</p>\n";
             							$p_start = false;
             						}
             						else if ($p_start && $empty_row == 0)
             						{
             							$doc_row = "<br />\n";
             						}
             
             						$empty_row++;
             					}
             					else if ($empty_row == 2)
             					{
             						$doc_row = str_replace(':', '', $row);
             						$doc_row = "<h3>$doc_row</h3>\n<p>";
             						$p_start = true;
             						$empty_row = 0;
             					}
             					else
             					{
             						if(preg_match($preg_url, $row, $url))
             						{
             							$doc_row = preg_replace($preg_url, "<a href=\"\\0\">\\0</a>",$row);
             						}
             						else
             						{
             							$doc_row = "$row\n";
             						}
             
             						$empty_row = 0;
             					}
             
             					$template->assign_block_vars('doc_row', array(
             						'ROW' => (!empty($doc_row)) ? $doc_row : '',
             					));
             
             					$doc_row = '';
             				}
             */
         }
     }
     $template->assign_vars(array('S_ABOUT' => $s_about, 'S_DOCS' => $s_docs));
     // Output page
     qi::page_header($s_about ? $user->lang['QI_ABOUT'] : $user->lang['QI_ABOUT'], ' ');
     $template->set_filenames(array('body' => 'about_body.html'));
     qi::page_footer();
 }