important security checks and there is NO workaround. Please contact your host for more information."); } //obsolete $installer_folder_name = 'e107_install'; include_once("./{$HANDLERS_DIRECTORY}core_functions.php"); include_once("./{$HANDLERS_DIRECTORY}e107_class.php"); function check_class($whatever='') { return true; } $override = array(); if(isset($_POST['previous_steps'])) { $tmp = unserialize(base64_decode($_POST['previous_steps'])); $override = (isset($tmp['paths']['hash'])) ? array('site_path'=>$tmp['paths']['hash']) : array(); unset($tmp); } //$e107_paths = compact('ADMIN_DIRECTORY', 'FILES_DIRECTORY', 'IMAGES_DIRECTORY', 'THEMES_DIRECTORY', 'PLUGINS_DIRECTORY', 'HANDLERS_DIRECTORY', 'LANGUAGES_DIRECTORY', 'HELP_DIRECTORY', 'CACHE_DIRECTORY', 'DOWNLOADS_DIRECTORY', 'UPLOADS_DIRECTORY', 'MEDIA_DIRECTORY', 'LOGS_DIRECTORY', 'SYSTEM_DIRECTORY', 'CORE_DIRECTORY'); $e107_paths = array(); $e107 = e107::getInstance(); $ebase = realpath(dirname(__FILE__)); if($e107->initInstall($e107_paths, $ebase, $override)===false) { die_fatal_error("Error creating the following empty file: ".$ebase.DIRECTORY_SEPARATOR."e107_config.php
Please create it manually and then run the installation again."); } unset($e107_paths,$override,$ebase); ### NEW Register Autoload - do it asap if(!function_exists('spl_autoload_register')) { // PHP >= 5.1.2 required die_fatal_error('Fatal exception - spl_autoload_* required.'); } // register core autoload e107::autoload_register(array('e107', 'autoload')); // NEW - session handler require_once(e_HANDLER.'session_handler.php'); define('e_SECURITY_LEVEL', e_session::SECURITY_LEVEL_NONE); define('e_COOKIE', 'e107install'); e107::getSession(); // starts session, creates default namespace // session_start(); function include_lan($path, $force = false) { return include($path); } //obsolete $e107->e107_dirs['INSTALLER'] = "{$installer_folder_name}/"; if(isset($_GET['create_tables'])) { create_tables_unattended(); exit; } $e_install = new e_install(); $e_forms = new e_forms(); $e_install->template->SetTag("installer_css_http", $_SERVER['PHP_SELF']."?object=stylesheet"); //obsolete $e_install->template->SetTag("installer_folder_http", e_HTTP.$installer_folder_name."/"); $e_install->template->SetTag("files_dir_http", e_FILE_ABS); $e_install->renderPage(); /** * Set Cookie * @param string $name * @param string $value * @param integer $expire seconds * @param string $path * @param string $domain * @param boolean $secure * @return void */ function cookie($name, $value, $expire=0, $path = e_HTTP, $domain = '', $secure = 0) { setcookie($name, $value, $expire, $path, $domain, $secure); } class e_install { var $paths; var $template; var $debug_info; var $debug_db_info; var $e107; var $previous_steps; var $stage; var $post_data; var $required = ""; //TODO - use for highlighting required fields with css/js. var $logFile; // Name of log file, empty string if logging disabled var $dbLink = NULL; // DB link - needed for PHP5.3 bug var $session = null; protected $pdo = false; protected $debug = false; // public function __construct() function __construct() { // notice removal, required from various core routines define('USERID', 1); define('USER', true); define('ADMIN', true); define('e_UC_MAINADMIN', 250); define('E107_DEBUG_LEVEL',0); if($_SERVER['QUERY_STRING'] == "debug") { $this->debug = true; } if(defined('PDO::ATTR_DRIVER_NAME')) // TODO Uncomment when ready. { $this->pdo = true; define('e_PDO', true); } if(!empty($this->previous_steps['mysql']['prefix'])) { define('MPREFIX', $this->previous_steps['mysql']['prefix']); } $tp = e107::getParser(); // session instance $this->session = e107::getSession(); $this->logFile = ''; if (MAKE_INSTALL_LOG) { if(is_writable(dirname(__FILE__))) { $this->logFile = dirname(__FILE__).'/e107InstallLog.log'; } } // $this->logLine('Query string: '); $this->template = new SimpleTemplate(); while (@ob_end_clean()); global $e107; $this->e107 = $e107; if(isset($_POST['previous_steps'])) { $this->previous_steps = unserialize(base64_decode($_POST['previous_steps'])); $this->previous_steps = $tp->filter($this->previous_steps); unset($_POST['previous_steps']); } else { $this->previous_steps = array(); } $this->get_lan_file(); $this->post_data = $tp->filter($_POST); $this->template->SetTag('required', ''); if(isset($this->previous_steps['language'])) { define("e_LANGUAGE", $this->previous_steps['language']); include_lan(e_LANGUAGEDIR.e_LANGUAGE."/".e_LANGUAGE.".php"); include_lan(e_LANGUAGEDIR.e_LANGUAGE."/admin/lan_admin.php"); } } /** * Write a line of text to the log file (if enabled) - prepend time/date, append \n * Can always call this routine - it will return if logging disabled * * @param string $logLine - text to log * @return none */ protected function logLine($logLine) { if (!MAKE_INSTALL_LOG || ($this->logFile == '')) return; $logfp = fopen($this->logFile, 'a+'); fwrite($logfp, ($now = time()).', '.gmstrftime('%y-%m-%d %H:%M:%S',$now).' '.$logLine."\n"); fclose($logfp); } function add_button($id, $title='', $align = "right", $type = "submit") { global $e_forms; $e_forms->form .= "
"; if($id != 'start') { // $this->form .= "« ".LAN_BACK." "; $prevStage = ($this->stage - 1); $e_forms->form .= " "; } if($id != 'back') { $e_forms->form .= ""; } $e_forms->form .= "
\n"; } function renderPage() { if(!isset($_POST['stage'])) { $_POST['stage'] = 1; } $_POST['stage'] = intval($_POST['stage']); if(!empty($_POST['back'])) { $_POST['stage'] = intval($_POST['back']); } switch ($_POST['stage']) { case 1: $this->stage_1(); break; case 2: $this->stage_2(); break; case 3: $this->stage_3(); break; case 4: $this->stage_4(); break; case 5: $this->stage_5(); break; case 6: $this->stage_6(); break; case 7: $this->stage_7(); break; case 8: $this->stage_8(); break; default: $this->raise_error("Install stage information from client makes no sense to me."); } if($_SERVER['QUERY_STRING'] == "debug") { $this->template->SetTag("debug_info", print_a($this->previous_steps,TRUE)); } else { $this->template->SetTag("debug_info", (count($this->debug_info) ? print_a($this->debug_info,TRUE)."Backtrace:
".print_a($this,TRUE) : "")); } echo $this->template->ParseTemplate(template_data(), TEMPLATE_TYPE_DATA); } function raise_error($details) { $this->debug_info[] = array ( 'info' => array ( 'details' => $details, 'backtrace' => debug_backtrace() ) ); } function display_required() { if(!$this->required) { return; } $this->required = array_filter($this->required); if(vartrue($this->required)) { $this->template->SetTag("required","
". implode("
",$this->required)."
"); $this->required = array(); } } private function stage_1() { global $e_forms; $this->stage = 1; $this->logLine('Stage 1 started'); $this->template->SetTag("installation_heading", LANINS_001); $this->template->SetTag("stage_pre", LANINS_002); $this->template->SetTag("stage_num", LANINS_003); $this->template->SetTag("stage_title", LANINS_004); $this->template->SetTag("percent", 10); $this->template->SetTag("bartype", 'warning'); $e_forms->start_form("language_select", $_SERVER['PHP_SELF'].($_SERVER['QUERY_STRING'] == "debug" ? "?debug" : "")); $e_forms->add_select_item("language", $this->get_languages(), "English"); $this->finish_form(); $this->add_button("start", LAN_CONTINUE); $output = "
\n
\n
".$e_forms->return_form()."

"; $this->template->SetTag("stage_content", $output); $this->logLine('Stage 1 completed'); } private function stage_2() { global $e_forms; $this->stage = 2; $this->logLine('Stage 2 started'); if(!empty($_POST['language'])) { $this->previous_steps['language'] = $_POST['language']; } $this->template->SetTag("installation_heading", LANINS_001); $this->template->SetTag("stage_pre", LANINS_002); $this->template->SetTag("stage_num", LANINS_021); $this->template->SetTag("stage_title", LANINS_022); $this->template->SetTag("percent", 25); $this->template->SetTag("bartype", 'warning'); if(!isset($this->previous_steps['mysql']['createdb'])) { $this->previous_steps['mysql']['createdb'] = 1; // default to yes. } // $this->template->SetTag("onload", "document.getElementById('name').focus()"); // $page_info = nl2br(LANINS_023); $page_info = "
".LANINS_141."
"; $e_forms->start_form("versions", $_SERVER['PHP_SELF'].($_SERVER['QUERY_STRING'] == "debug" ? "?debug" : "")); $isrequired = (($_SERVER['SERVER_ADDR'] == "127.0.0.1") || ($_SERVER['SERVER_ADDR'] == "localhost") || ($_SERVER['SERVER_ADDR'] == "::1") || preg_match('^192\.168\.\d{1,3}\.\d{1,3}$',$_SERVER['SERVER_ADDR'])) ? "" : "required='required'"; // Deals with IP V6, and 192.168.x.x address ranges, could be improved to validate x.x to a valid IP but for this use, I dont think its required to be that picky. $output = "
".LANINS_030."
".LANINS_031."
".LANINS_032."
".LANINS_033."
".LANINS_034."


\n"; $e_forms->add_plain_html($output); $this->finish_form(); $this->add_button("submit", LAN_CONTINUE); $this->template->SetTag("stage_content", $page_info.$e_forms->return_form()); $this->logLine('Stage 2 completed'); } /** * Replace hash paths and create folders if needed. * * @param none * @return none */ private function updatePaths() { $hash = $this->e107->makeSiteHash($this->previous_steps['mysql']['db'],$this->previous_steps['mysql']['prefix']); $this->e107->site_path = $hash; $this->previous_steps['paths']['hash'] = $hash; $omit = array('FILES_DIRECTORY','WEB_IMAGES_DIRECTORY'); foreach($this->e107->e107_dirs as $dir => $p) { if(in_array($dir, $omit)) { continue; } $this->e107->e107_dirs[$dir] = str_replace("[hash]", $hash, $this->e107->e107_dirs[$dir]); if(!is_dir($this->e107->e107_dirs[$dir])) { @mkdir($this->e107->e107_dirs[$dir]); } } } private function stage_3() { global $e_forms; $success = TRUE; $this->stage = 3; $this->logLine('Stage 3 started'); $this->template->SetTag("installation_heading", LANINS_001); $this->template->SetTag("stage_pre", LANINS_002); $this->template->SetTag("stage_num", LANINS_036); $this->template->SetTag("onload", "document.getElementById('name').focus()"); $this->template->SetTag("percent", 40); $this->template->SetTag("bartype", 'warning'); $tp = e107::getParser(); if(!empty($_POST['server'])) { $this->previous_steps['mysql']['server'] = trim($tp->filter($_POST['server'])); $this->previous_steps['mysql']['user'] = trim($tp->filter($_POST['name'])); $this->previous_steps['mysql']['password'] = trim($tp->filter($_POST['password'])); $this->previous_steps['mysql']['db'] = trim($tp->filter($_POST['db'])); $this->previous_steps['mysql']['createdb'] = (isset($_POST['createdb']) && $_POST['createdb'] == true ? true : false); $this->previous_steps['mysql']['prefix'] = trim($tp->filter($_POST['prefix'])); } if(!empty($_POST['overwritedb'])) { $this->previous_steps['mysql']['overwritedb'] = 1; } $success = $this->check_name($this->previous_steps['mysql']['db'], FALSE) && $this->check_name($this->previous_steps['mysql']['prefix'], TRUE); if ($success) { $success = $this->checkDbFields($this->previous_steps['mysql']); // Check for invalid characters } if(!$success || $this->previous_steps['mysql']['server'] == "" || $this->previous_steps['mysql']['user'] == "") { $this->stage = 3; $this->template->SetTag("stage_num", LANINS_021); $e_forms->start_form("versions", $_SERVER['PHP_SELF'].($_SERVER['QUERY_STRING'] == "debug" ? "?debug" : "")); $head = LANINS_039."

\n"; $output = "
"; if (!$success) { $output .= ""; } $output .= "
".LANINS_030."
".LANINS_031."
".LANINS_032."

".LANINS_033."
".LANINS_034."
".LANINS_105."


\n"; $e_forms->add_plain_html($output); $this->add_button("submit", LAN_CONTINUE); $this->template->SetTag("stage_title", LANINS_040); } else { $this->template->SetTag("stage_title", LANINS_037.($this->previous_steps['mysql']['createdb'] == 1 ? LANINS_038 : "")); $sql = e107::getDb(); if (!$res = $sql->connect($this->previous_steps['mysql']['server'], $this->previous_steps['mysql']['user'], $this->previous_steps['mysql']['password'])) // if (!$res = @mysql_connect($this->previous_steps['mysql']['server'], $this->previous_steps['mysql']['user'], $this->previous_steps['mysql']['password'])) { $success = FALSE; $e_forms->start_form("versions", $_SERVER['PHP_SELF'].($_SERVER['QUERY_STRING'] == "debug" ? "?debug" : "")); $page_content = LANINS_041.nl2br("\n\n".LANINS_083."\n".$sql->getLastErrorText().""); $alertType = 'error'; } elseif(($this->previous_steps['mysql']['createdb'] == 1) && empty($this->previous_steps['mysql']['overwritedb']) && $sql->database($this->previous_steps['mysql']['db'], $this->previous_steps['mysql']['server'])) { $success = false; $e_forms->start_form("versions", $_SERVER['PHP_SELF'].($_SERVER['QUERY_STRING'] == "debug" ? "?debug" : "")); $head = str_replace('[x]', ''.$this->previous_steps['mysql']['db'].'', "
". LANINS_127."
"); $alertType = 'error'; $this->add_button('overwritedb', LANINS_128); /* $e_forms->add_plain_html(" " );*/ $this->finish_form(3); $this->template->SetTag("stage_content", "
".$head."
".$e_forms->return_form()); $this->logLine('Stage 3 completed'); return; } else { $e_forms->start_form("versions", $_SERVER['PHP_SELF'].($_SERVER['QUERY_STRING'] == "debug" ? "?debug" : "")); $page_content = " ".LANINS_042; // @TODO Check database version here? /* $mysql_note = mysql_get_server_info(); if (version_compare($mysql_note, MIN_MYSQL_VERSION, '>=')) { $success = FALSE; } */ // Do brute force for now - Should be enough if(!empty($this->previous_steps['mysql']['overwritedb'])) { if($this->dbqry('DROP DATABASE `'.$this->previous_steps['mysql']['db'].'` ')) { $page_content .= "
".LANINS_136; } else { $success = false; $page_content .= "

".LANINS_043.nl2br("\n\n".LANINS_083."\n".e107::getDb()->getLastErrorText().""); } } if($this->previous_steps['mysql']['createdb'] == 1) { $notification = "
".LANINS_044; $query = 'CREATE DATABASE `'.$this->previous_steps['mysql']['db'].'` CHARACTER SET `utf8` '; } else { $notification = "
".LANINS_137; $query = 'ALTER DATABASE `'.$this->previous_steps['mysql']['db'].'` CHARACTER SET `utf8` '; } if (!$this->dbqry($query)) { $success = false; $alertType = 'error'; $page_content .= "

"; $page_content .= (empty($this->previous_steps['mysql']['createdb'])) ? LANINS_129 : LANINS_043; $page_content .= nl2br("\n\n".LANINS_083."\n".e107::getDb()->getLastErrorText().""); } else { $this->dbqry('SET NAMES `utf8`'); $page_content .= $notification; // " } } if($success) { // $page_content .= "

".LANINS_045."

"; $this->add_button("submit", LAN_CONTINUE); $alertType = 'success'; } else { $this->add_button("back", LAN_CONTINUE); } $head = $page_content; } if ($success) $this->finish_form(); else { $this->finish_form(3); } $this->template->SetTag("stage_content", "
".$head."
".$e_forms->return_form()); $this->logLine('Stage 3 completed'); } private function stage_4() { global $e_forms; $this->stage = 4; $this->logLine('Stage 4 started'); $this->template->SetTag("installation_heading", LANINS_001); $this->template->SetTag("stage_pre", LANINS_002); $this->template->SetTag("stage_num", LANINS_007); $this->template->SetTag("stage_title", LANINS_008); $this->template->SetTag("percent", 50); $this->template->SetTag("bartype", 'warning'); $not_writable = $this->check_writable_perms('must_write'); // Some directories MUST be writable $opt_writable = $this->check_writable_perms('can_write'); // Some directories CAN optionally be writable $version_fail = false; $perms_errors = ""; $mysql_pass = false; if(count($not_writable)) { $perms_pass = false; foreach ($not_writable as $file) { $perms_errors .= (substr($file, -1) == "/" ? LANINS_010a : LANINS_010)."
{$file}
\n"; } $perms_notes = LANINS_018; } elseif (count($opt_writable)) { $perms_pass = true; foreach ($opt_writable as $file) { $perms_errors .= (substr($file, -1) == "/" ? LANINS_010a : LANINS_010)."
{$file}
\n"; } $perms_notes = LANINS_106; } elseif (filesize('e107_config.php') > 1) { // Must start from an empty e107_config.php $perms_pass = FALSE; $perms_errors = LANINS_121; $perms_notes = " ".LANINS_122; } else { $perms_pass = true; $perms_errors = " "; $perms_notes = " ".LANINS_017; } if(!function_exists("mysql_connect") && !defined('PDO::ATTR_DRIVER_NAME')) { $version_fail = true; $mysql_note = LAN_ERROR; $mysql_help = LANINS_012; } elseif (!e107::getDb()->connect($this->previous_steps['mysql']['server'], $this->previous_steps['mysql']['user'], $this->previous_steps['mysql']['password'])) // elseif (!@mysql_connect($this->previous_steps['mysql']['server'], $this->previous_steps['mysql']['user'], $this->previous_steps['mysql']['password'])) { $mysql_note = LAN_ERROR; $mysql_help = LANINS_013; } else { // $mysql_note = mysql_get_server_info(); $mysql_note = e107::getDb()->getServerInfo(); if($this->pdo == true) { $mysql_note .= " (PDO)"; } if (version_compare($mysql_note, MIN_MYSQL_VERSION, '>=')) { $mysql_help = " ".LANINS_017; $mysql_pass = true; } else { $mysql_help = " ".LANINS_105; } } $php_version = phpversion(); if(version_compare($php_version, MIN_PHP_VERSION, ">=")) { $php_help = " ".LANINS_017; } else { $php_help = " ".LANINS_019; } $e_forms->start_form("versions", $_SERVER['PHP_SELF'].($_SERVER['QUERY_STRING'] == "debug" ? "?debug" : "")); $permColor = ($perms_pass == true) ? "text-success" : "text-error"; $PHPColor = ($version_fail == false) ? "text-success" : "text-error"; $mysqlColor = ($mysql_pass == true) ? "text-success" : "text-error"; $extensionCheck = array( 'xml' => array('label'=> LANINS_050, 'status'=> function_exists('utf8_encode'), 'url'=> 'http://php.net/manual/en/ref.xml.php'), 'exif' => array('label'=> LANINS_048, 'status'=> function_exists('exif_imagetype'), 'url'=> 'http://php.net/manual/en/book.exif.php'), 'gd' => array('label'=> 'GD Library', 'status'=> function_exists('gd_info'), 'url'=> 'http://php.net/manual/en/book.image.php'), 'curl' => array('label'=>'Curl Library', 'status'=> function_exists('curl_version'), 'url'=>'http://php.net/manual/en/book.curl.php') ); $output = " "; foreach($extensionCheck as $ext) { $statusText = ($ext['status'] === true) ? LANINS_051 : LANINS_052; $statusColor = ($ext['status'] === true) ? "text-success" : "text-error"; $statusIcon = ($ext['status'] === true) ? " ".LANINS_017 : str_replace(array("[x]",'[y]'), array($ext['label'], "php.net"), LANINS_145); $output .= " "; } $output .= "
".LANINS_014." {$perms_errors} {$perms_notes}
".LANINS_015." {$php_version} {$php_help}
MySQL {$mysql_note} {$mysql_help}
".$ext['label']." ".$statusText." ".$statusIcon."
\n"; if(!$perms_pass || (($extensionCheck['xml']['status'] !== true))) { $this->add_button("retest_perms", LANINS_009); $this->stage = 3; // make the installer jump back a step } elseif ($perms_pass && !$version_fail && ($extensionCheck['xml']['status'] == true)) { $this->add_button("continue_install", LAN_CONTINUE); } $this->finish_form(); $this->template->SetTag("stage_content", $output.$e_forms->return_form()); $this->logLine('Stage 4 completed'); } /** * Install stage 5 - collect Admin Login Data. * * @return string HTML form of stage 5. */ private function stage_5() { global $e_forms; $this->updatePaths(); // update dynamic paths and create media and system directories - requires mysql info. $this->stage = 5; $this->logLine('Stage 5 started'); $this->display_required(); $this->template->SetTag("installation_heading", LANINS_001); $this->template->SetTag("stage_pre", LANINS_002); $this->template->SetTag("stage_num", LANINS_046); $this->template->SetTag("stage_title", LANINS_047); // $this->template->SetTag("onload", "document.getElementById('u_name').focus()"); $this->template->SetTag("percent", 60); $this->template->SetTag("bartype", 'warning'); $e_forms->start_form("admin_info", $_SERVER['PHP_SELF'].($_SERVER['QUERY_STRING'] == "debug" ? "?debug" : "")); $output = "
previous_steps['admin']['user'] : "")."' maxlength='60' /> ".LANINS_073."
previous_steps['admin']['display'] : "")."' maxlength='60' /> ".LANINS_123."
".LANINS_124."
".LANINS_079."
previous_steps['admin']['email'] : '')."' maxlength='100' /> ".LANINS_081."


\n"; $e_forms->add_plain_html($output); $this->finish_form(); $this->add_button("submit", LAN_CONTINUE); $this->template->SetTag("stage_content", $e_forms->return_form()); $this->logLine('Stage 5 completed'); } /** * Collect User's Website Preferences * * @return string HTML form of stage 6. */ private function stage_6() { global $e_forms; $tp = e107::getParser(); $this->stage = 6; $this->logLine('Stage 6 started'); // -------------------- Save Step 5 Data ------------------------- if(!vartrue($this->previous_steps['admin']['user']) || varset($_POST['u_name'])) { $_POST['u_name'] = str_replace(array("'", '"'), "", $_POST['u_name']); $this->previous_steps['admin']['user'] = $tp->filter($_POST['u_name']); } if(!vartrue($this->previous_steps['admin']['display']) || varset($_POST['d_name'])) { $_POST['d_name'] = str_replace(array("'", '"'), "", $_POST['d_name']); if ($_POST['d_name'] == "") { $this->previous_steps['admin']['display'] = $tp->filter($_POST['u_name']); } else { $this->previous_steps['admin']['display'] = $tp->filter($_POST['d_name']); } } if(!vartrue($this->previous_steps['admin']['email']) || varset($_POST['email'])) { $this->previous_steps['admin']['email'] = $tp->filter($_POST['email'],'email'); } if(varset($_POST['pass1']) || !vartrue($this->previous_steps['admin']['password'])) { if($_POST['pass1'] != $_POST['pass2']) { $this->required['pass1'] = LANINS_049; // passwords don't match. } elseif(!vartrue($_POST['pass1'])) { $this->required['pass1'] = LANINS_077; } else { $this->previous_steps['admin']['password'] = $_POST['pass1']; } } // ------------- Validate Step 5 Data. -------------------------- if(!vartrue($this->previous_steps['admin']['user']) || !vartrue($this->previous_steps['admin']['password'])) { $this->required['u_name'] = LANINS_086; // } if(vartrue($this->required['u_name']) || vartrue($this->required['pass1'])) { return $this->stage_5(); } // required for various core routines if(!defined('USERNAME')) { define('USERNAME', $this->previous_steps['admin']['user']); define('USEREMAIL', $this->previous_steps['admin']['email']); } // ------------- Step 6 Form -------------------------------- $this->display_required(); $this->template->SetTag("installation_heading", LANINS_001); $this->template->SetTag("stage_pre", LANINS_002); $this->template->SetTag("stage_num", LANINS_056); $this->template->SetTag("stage_title", LANINS_117); // Website Preferences; // $this->template->SetTag("onload", "document.getElementById('sitename').focus()"); $this->template->SetTag("percent", 70); $this->template->SetTag("bartype", 'warning'); $e_forms->start_form("pref_info", $_SERVER['PHP_SELF'].($_SERVER['QUERY_STRING'] == "debug" ? "?debug" : "")); $output = "
"; $themes = $this->get_themes(); foreach($themes as $val) { if($val == 'bootstrap') { continue; } $themeInfo = $this->get_theme_xml($val); $title = vartrue($themeInfo['@attributes']['name']); $category = vartrue($themeInfo['category']); $selected = ($val == 'bootstrap3') ? " checked" : ""; $output .= " "; } $output .= "
".LANINS_115." ".LANINS_116."
{$category}
".LANINS_119."
".LANINS_112."


\n"; $e_forms->add_plain_html($output); $this->finish_form(); $this->add_button("submit", LAN_CONTINUE); $this->template->SetTag("stage_content", $e_forms->return_form()); $this->logLine('Stage 6 completed'); } private function stage_7() { global $e_forms; $tp = e107::getParser(); $this->e107->e107_dirs['SYSTEM_DIRECTORY'] = str_replace("[hash]",$this->e107->site_path,$this->e107->e107_dirs['SYSTEM_DIRECTORY']); $this->e107->e107_dirs['CACHE_DIRECTORY'] = str_replace("[hash]",$this->e107->site_path,$this->e107->e107_dirs['CACHE_DIRECTORY']); $this->e107->e107_dirs['SYSTEM_DIRECTORY'] = str_replace("/".$this->e107->site_path,"",$this->e107->e107_dirs['SYSTEM_DIRECTORY']); $this->e107->e107_dirs['MEDIA_DIRECTORY'] = str_replace("/".$this->e107->site_path,"",$this->e107->e107_dirs['MEDIA_DIRECTORY']); $this->stage = 7; $this->logLine('Stage 7 started'); // required for various core routines if(!defined('USERNAME')) { define('USERNAME', $this->previous_steps['admin']['user']); define('USEREMAIL', $this->previous_steps['admin']['email']); } if(varset($_POST['sitename'])) { $this->previous_steps['prefs']['sitename'] = $tp->filter($_POST['sitename']); } if(varset($_POST['sitetheme'])) { $this->previous_steps['prefs']['sitetheme'] = $tp->filter($_POST['sitetheme']); } if(varset($_POST['generate_content'])) { $this->previous_steps['generate_content'] = $tp->filter($_POST['generate_content'],'int'); } if(varset($_POST['install_plugins'])) { $this->previous_steps['install_plugins'] = $tp->filter($_POST['install_plugins'],'int'); } // Validate if(!vartrue($this->previous_steps['prefs']['sitename'])) { $this->required['sitename'] = LANINS_113; // 'Please enter a website name.'; // should be used to highlight the required field. (using css for example) } if(!vartrue($this->previous_steps['prefs']['sitetheme'])) { $this->required['sitetheme'] = LANINS_114; // 'Please select a theme.'; } if(vartrue($this->required['sitetheme']) || vartrue($this->required['sitename'])) { return $this->stage_6(); } $config_file = "previous_steps['mysql']['server']}'; \$mySQLuser = '{$this->previous_steps['mysql']['user']}'; \$mySQLpassword = '{$this->previous_steps['mysql']['password']}'; \$mySQLdefaultdb = '{$this->previous_steps['mysql']['db']}'; \$mySQLprefix = '{$this->previous_steps['mysql']['prefix']}'; \$mySQLcharset = 'utf8'; \$ADMIN_DIRECTORY = '{$this->e107->e107_dirs['ADMIN_DIRECTORY']}'; \$FILES_DIRECTORY = '{$this->e107->e107_dirs['FILES_DIRECTORY']}'; \$IMAGES_DIRECTORY = '{$this->e107->e107_dirs['IMAGES_DIRECTORY']}'; \$THEMES_DIRECTORY = '{$this->e107->e107_dirs['THEMES_DIRECTORY']}'; \$PLUGINS_DIRECTORY = '{$this->e107->e107_dirs['PLUGINS_DIRECTORY']}'; \$HANDLERS_DIRECTORY = '{$this->e107->e107_dirs['HANDLERS_DIRECTORY']}'; \$LANGUAGES_DIRECTORY = '{$this->e107->e107_dirs['LANGUAGES_DIRECTORY']}'; \$HELP_DIRECTORY = '{$this->e107->e107_dirs['HELP_DIRECTORY']}'; \$MEDIA_DIRECTORY = '{$this->e107->e107_dirs['MEDIA_DIRECTORY']}'; \$SYSTEM_DIRECTORY = '{$this->e107->e107_dirs['SYSTEM_DIRECTORY']}'; "; /* if($this->pdo == true) { $config_file .= 'define("e_PDO", true);'; $config_file .= "\n\n"; }*/ $config_result = $this->write_config($config_file); if ($config_result) { $page = $config_result."
"; $this->logLine('Error writing config file: '.$config_result); $alertType = 'warning'; } else { $this->logLine('Config file written successfully'); } // Data is okay - Continue. // $this->previous_steps['prefs']['sitename'] = $_POST['sitename']; // $this->previous_steps['prefs']['sitetheme'] = $_POST['sitetheme']; // $this->previous_steps['generate_content'] = $_POST['generate_content']; $this->template->SetTag("installation_heading", LANINS_001); $this->template->SetTag("stage_pre", LANINS_002); $this->template->SetTag("stage_num", LANINS_058); $this->template->SetTag("stage_title", LANINS_055); $this->template->SetTag("percent", 80); $this->template->SetTag("bartype", 'warning'); $e_forms->start_form("confirmation", $_SERVER['PHP_SELF'].($_SERVER['QUERY_STRING'] == "debug" ? "?debug" : "")); $page = '
'.nl2br(LANINS_057).'
'; $this->finish_form(); $this->add_button("submit", LAN_CONTINUE); $this->template->SetTag("stage_content", $page.$e_forms->return_form()); $this->logLine('Stage 7 completed'); } /** * Stage 8 - actually create database and set up the site * * @return none */ private function stage_8() { global $e_forms; //$system_dir = str_replace("/".$this->e107->site_path,"",$this->e107->e107_dirs['SYSTEM_DIRECTORY']); //$media_dir = str_replace("/".$this->e107->site_path,"",$this->e107->e107_dirs['MEDIA_DIRECTORY']); // required for various core routines if(!defined('USERNAME')) { define('USERNAME', $this->previous_steps['admin']['user']); define('USEREMAIL', $this->previous_steps['admin']['email']); } $this->stage = 8; $this->logLine('Stage 8 started'); $this->template->SetTag("installation_heading", LANINS_001); $this->template->SetTag("stage_pre", LANINS_002); $this->template->SetTag("stage_num", LANINS_120); $this->template->SetTag("stage_title", LANINS_071); $this->template->SetTag("percent", 100); $this->template->SetTag("bartype", 'success'); $htaccessError = $this->htaccess(); $e_forms->start_form("confirmation", "index.php"); $errors = $this->create_tables(); if ($errors == true) { $this->logLine('Errors creating tables: '.$errors); $page = $errors."
"; $alertType = 'error'; } else { $alertType = 'success'; $this->logLine('Tables created successfully'); $this->import_configuration(); $page = nl2br(LANINS_125)."
"; $page .= (is_writable('e107_config.php')) ? "
".str_replace("e107_config.php","e107_config.php",LANINS_126) : ""; if($htaccessError) { $page .= "
".$htaccessError; } $this->add_button('submit', LAN_CONTINUE); } $this->finish_form(); $this->stats(); $this->template->SetTag("stage_content", "
".$page."
".$e_forms->return_form()); $this->logLine('Stage 8 completed'); e107::getMessage()->reset(false, false, true); } protected function stats() { global $e_forms; $data = array('name'=>$this->previous_steps['prefs']['sitename'], 'theme'=>$this->previous_steps['prefs']['sitetheme'], 'language'=>$this->previous_steps['language'], 'url'=>$_SERVER['HTTP_REFERER']);; $base = base64_encode(http_build_query($data, null, '&')); $url = "http://e107.org/e-install/".$base; $e_forms->add_plain_html(""); } /** * htaccess - handle the .htaccess file * * @return string $error */ protected function htaccess() { $error = ""; if(!file_exists(".htaccess")) { if(!rename("e107.htaccess",".htaccess")) { $error = LANINS_142; } elseif($_SERVER['QUERY_STRING'] == "debug") { rename(".htaccess","e107.htaccess"); $error = "DEBUG: Rename from e107.htaccess to .htaccess was successful"; } } elseif(file_exists("e107.htaccess")) { $error = e107::getParser()->toHtml(LANINS_144,true); } return $error; } /** * Import and generate preferences and default content. * * @return boolean */ //FIXME always return FALSE??? public function import_configuration() { $this->logLine('Starting configuration import'); // PRE-CONFIG start - create and register blank config instances - do not load! $config_aliases = array( 'core', 'core_backup', 'emote', 'menu', 'search', 'notify', ); foreach ($config_aliases as $alias) { e107::getConfig($alias, false)->clearPrefCache(); } // PRE-CONFIG end // Basic stuff to get the handlers/classes to work. // $udirs = "admin/|plugins/|temp"; // $e_SELF = $_SERVER['PHP_SELF']; // $e_HTTP = preg_replace("#".$udirs."#i", "", substr($e_SELF, 0, strrpos($e_SELF, "/"))."/"); // define("MAGIC_QUOTES_GPC", (ini_get('magic_quotes_gpc') ? true : false)); // define('CHARSET', 'utf-8'); // define("e_LANGUAGE", $this->previous_steps['language']); // define('e_SELF', 'http://'.$_SERVER['HTTP_HOST']) . ($_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_FILENAME']); $themeImportFile = array(); $themeImportFile[0] = $this->e107->e107_dirs['THEMES_DIRECTORY'].$this->previous_steps['prefs']['sitetheme']."/install.xml"; $themeImportFile[1] = $this->e107->e107_dirs['THEMES_DIRECTORY'].$this->previous_steps['prefs']['sitetheme']."/install/install.xml"; // $themeImportFile[3] = $this->e107->e107_dirs['CORE_DIRECTORY']. "xml/default_install.xml"; $XMLImportfile = false; if(vartrue($this->previous_steps['generate_content'])) { foreach($themeImportFile as $file) { if(is_readable($file)) { $XMLImportfile = $file; break; } } } $tp = e107::getParser(); define('PREVIEWTHEMENAME',""); // Notice Removal. // include_lan($this->e107->e107_dirs['LANGUAGES_DIRECTORY'].$this->previous_steps['language']."/lan_prefs.php"); include_lan($this->e107->e107_dirs['LANGUAGES_DIRECTORY'].$this->previous_steps['language']."/admin/lan_theme.php"); // [SecretR] should work now - fixed log errors (argument noLogs = true) change to false to enable log $coreConfig = $this->e107->e107_dirs['CORE_DIRECTORY']. "xml/default_install.xml"; $ret = e107::getXml()->e107Import($coreConfig, 'replace', true, false); // Add core pref values $this->logLine('Attempting to Write Core Prefs.'); $this->logLine(print_r($ret, true)); if($XMLImportfile) // We cannot rely on themes to include all prefs..so use 'replace'. { $ret2 = e107::getXml()->e107Import($XMLImportfile, 'replace', true, false); // Overwrite specific core pref and tables entries. $this->logLine('Attempting to write Theme Prefs/Tables (install.xml)'); $this->logLine(print_r($ret2, true)); } //Create default plugin-table entries. // e107::getConfig('core')->clearPrefCache(); e107::getPlugin()->update_plugins_table('update'); $this->logLine('Plugins table updated'); // Install Theme-required plugins if(vartrue($this->previous_steps['install_plugins'])) { if($themeInfo = $this->get_theme_xml($this->previous_steps['prefs']['sitetheme'])) { if(isset($themeInfo['plugins']['plugin'])) { foreach($themeInfo['plugins']['plugin'] as $k=>$plug) { $this->install_plugin($plug['@attributes']['name']); $this->logLine('Theme-related plugin installed: '.$plug['@attributes']['name']); } } } } e107::getSingleton('e107plugin')->save_addon_prefs('update'); // save plugin addon pref-lists. eg. e_latest_list. $this->logLine('Addon prefs saved'); $tm = e107::getSingleton('themeHandler'); $tm->noLog = true; // false to enable log $tm->setTheme($this->previous_steps['prefs']['sitetheme'], false); // Admin log fix - don't allow logs to be called inside pref handler // FIX e107::getConfig('core')->setParam('nologs', true); // change to false to enable log $pref = e107::getConfig('core')->getPref(); // Set Preferences defined during install - overwriting those that may exist in the XML. $this->previous_steps['prefs']['sitelanguage'] = $this->previous_steps['language']; $this->previous_steps['prefs']['sitelang_init'] = $this->previous_steps['language']; $this->previous_steps['prefs']['siteadmin'] = $this->previous_steps['admin']['display']; $this->previous_steps['prefs']['siteadminemail'] = $this->previous_steps['admin']['email']; $this->previous_steps['prefs']['install_date'] = time(); $this->previous_steps['prefs']['siteurl'] = e_HTTP; $this->previous_steps['prefs']['sitetag'] = "e107 Website System"; $this->previous_steps['prefs']['sitedisclaimer'] = ''; $this->previous_steps['prefs']['replyto_name'] = $this->previous_steps['admin']['display']; $this->previous_steps['prefs']['replyto_email'] = $this->previous_steps['admin']['email']; // Cookie name fix, ended up with 406 error when non-latin words used $cookiename = preg_replace('/[^a-z0-9]/i', '', trim($this->previous_steps['prefs']['sitename'])); $this->previous_steps['prefs']['cookie_name'] = ($cookiename ? substr($cookiename, 0, 4).'_' : 'e_').'cookie'; ### URL related prefs // set all prefs so that they are available, required for adminReadModules() - it checks which plugins are installed e107::getConfig('core')->setPref($this->previous_steps['prefs']); $url_modules = eRouter::adminReadModules(); $url_locations = eRouter::adminBuildLocations($url_modules); $url_config = eRouter::adminBuildConfig(array(), $url_modules); $this->previous_steps['prefs']['url_aliases'] = array(); $this->previous_steps['prefs']['url_config'] = $url_config; $this->previous_steps['prefs']['url_modules'] = $url_modules; $this->previous_steps['prefs']['url_locations'] = $url_locations; eRouter::clearCache(); $this->logLine('Core URL config set to default state'); // Set prefs, save e107::getConfig('core')->setPref($this->previous_steps['prefs']); e107::getConfig('core')->save(FALSE,TRUE, FALSE); // save preferences made during install. $this->logLine('Core prefs set to install choices'); // Create the admin user - replacing any that may be been included in the XML. $ip = $_SERVER['REMOTE_ADDR']; $userp = "1, '{$this->previous_steps['admin']['display']}', '{$this->previous_steps['admin']['user']}', '', '".md5($this->previous_steps['admin']['password'])."', '', '{$this->previous_steps['admin']['email']}', '', '', 0, ".time().", 0, 0, 0, 0, 0, '{$ip}', 0, '', 0, 1, '', '', '0', '', ".time().", ''"; $qry = "REPLACE INTO {$this->previous_steps['mysql']['prefix']}user VALUES ({$userp})"; $this->dbqry("REPLACE INTO {$this->previous_steps['mysql']['prefix']}user VALUES ({$userp})" ); $this->logLine('Admin user created'); // Add Default user-extended values; $extendedQuery = "REPLACE INTO `{$this->previous_steps['mysql']['prefix']}user_extended` (`user_extended_id` , `user_hidden_fields`) VALUES ('1', NULL );"; $this->dbqry($extendedQuery); e107::getDb()->close(); // mysql_close($this->dbLink); e107::getMessage()->reset(false, false, true); return false; } /** * Install a Theme required plugin. * * @param string $plugpath - plugin folder name * @return void */ public function install_plugin($plugpath) //FIXME - requires default plugin table entries, see above. { e107::getDb()->gen("SELECT * FROM #plugin WHERE plugin_path = '".$plugpath."' LIMIT 1"); $row = e107::getDb()->fetch(); e107::getPlugin()->install_plugin($row['plugin_id']); e107::getMessage()->reset(false, false, true); return; } /** * Check a DB name or table prefix - anything starting with a numeric followed by 'e' causes problems. * Return TRUE if acceptable, FALSE if unacceptable * Empty string returns the value of $blank_ok (caller should set TRUE for prefix, FALSE for DB name) * * @param string $str * @param boolean $blank_ok [optional] * @return boolean */ function check_name($str, $blank_ok = FALSE) { if ($str == '') return $blank_ok; if (preg_match("#^\d+[e|E]#", $str)) return FALSE; return TRUE; } /** * checkDbFields - Check an array of db-related fields for illegal characters * * @param array $fields * @return boolean TRUE for OK, FALSE for invalid character */ function checkDbFields($fields) { if (!is_array($fields)) return FALSE; foreach (array('server', 'user', 'db', 'prefix') as $key) { if (isset($fields[$key])) { if (strtr($fields[$key],"';", ' ') != $fields[$key]) { return FALSE; // Invalid character found } } } return TRUE; } function get_lan_file() { if(!empty($_POST['language'])) { $this->previous_steps['language'] = $_POST['language']; } if(!isset($this->previous_steps['language'])) { $this->previous_steps['language'] = "English"; } include_lan($this->e107->e107_dirs['LANGUAGES_DIRECTORY'].$this->previous_steps['language']."/lan_installer.php"); // $this->lan_file = "{$this->e107->e107_dirs['LANGUAGES_DIRECTORY']}{$this->previous_steps['language']}/lan_installer.php"; // if(is_readable($this->lan_file)) // { // include($this->lan_file); // } // elseif(is_readable("{$this->e107->e107_dirs['LANGUAGES_DIRECTORY']}English/lan_installer.php")) // { // include("{$this->e107->e107_dirs['LANGUAGES_DIRECTORY']}English/lan_installer.php"); // } // else // { // $this->raise_error("Fatal: Could not get valid language file for installation."); // } } /** * get_languages - check language folder for language names * * @param none * @return array $lanlist */ function get_languages() { $handle = opendir($this->e107->e107_dirs['LANGUAGES_DIRECTORY']); $lanlist = array(); while ($file = readdir($handle)) { if ($file != "." && $file != ".." && $file != "/" && $file != "CVS" && $file != 'index.html') { if(file_exists("./{$this->e107->e107_dirs['LANGUAGES_DIRECTORY']}{$file}/lan_installer.php")) { $lanlist[] = $file; } } } closedir($handle); return $lanlist; } /** * get_themes - check theme folder for theme names * * @param none * @return array $themelist */ function get_themes() { $handle = opendir($this->e107->e107_dirs['THEMES_DIRECTORY']); $themelist = array(); while ($file = readdir($handle)) { if (is_dir($this->e107->e107_dirs['THEMES_DIRECTORY'].$file) && $file !='_blank') { if(is_readable("./{$this->e107->e107_dirs['THEMES_DIRECTORY']}{$file}/theme.xml")) { $themelist[] = $file; } } } closedir($handle); return $themelist; } /** * get_theme_xml - check theme.xml file of specific theme * * @param string $theme_folder * @return array $xmlArray OR boolean FALSE if result is no array */ function get_theme_xml($theme_folder) { if(!defined("SITEURL")) { define("SITEURL",""); } $path = $this->e107->e107_dirs['THEMES_DIRECTORY'].$theme_folder."/theme.xml"; if(!is_readable($path)) { return FALSE; } require_once($this->e107->e107_dirs['HANDLERS_DIRECTORY']."theme_handler.php"); $tm = new themeHandler; $xmlArray = $tm->parse_theme_xml($theme_folder); // $xml = e107::getXml(); // $xmlArray = $xml->loadXMLfile($path,'advanced'); return (is_array($xmlArray)) ? $xmlArray : FALSE; } /** * finish_form - pass data along forms * * @param string $force_stage [optional] * @return none */ function finish_form($force_stage = false) { global $e_forms; if($this->previous_steps) { $e_forms->add_hidden_data("previous_steps", base64_encode(serialize($this->previous_steps))); } $e_forms->add_hidden_data("stage", ($force_stage ? $force_stage : ($this->stage + 1))); } /** * check_writable_perms - check writable permissions * * @param string $list [default 'must_write'] * @return array $bad_files */ function check_writable_perms($list = 'must_write') { $bad_files = array(); $system_dirs = $this->e107->e107_dirs; $system_dirs['MEDIA_DIRECTORY'] = str_replace("[hash]/","", $system_dirs['MEDIA_DIRECTORY']); $system_dirs['SYSTEM_DIRECTORY'] = str_replace("[hash]/","", $system_dirs['SYSTEM_DIRECTORY']); $data['must_write'] = 'e107_config.php|{$MEDIA_DIRECTORY}|{$SYSTEM_DIRECTORY}'; // all-sub folders are created on-the-fly $data['can_write'] = '{$PLUGINS_DIRECTORY}|{$THEMES_DIRECTORY}|{$WEB_DIRECTORY}cache|{$WEB_DIRECTORY}lib'; if (!isset($data[$list])) return $bad_files; foreach ($system_dirs as $dir_name => $value) { $find[] = "{\${$dir_name}}"; $replace[] = "./$value"; } $data[$list] = str_replace($find, $replace, $data[$list]); $files = explode("|", trim($data[$list])); foreach ($files as $file) { if(!is_writable($file)) { $bad_files[] = str_replace("./", "", $file); } } return $bad_files; } /** * Create Core MySQL tables * * @return string|FALSE error code or FALSE if no errors are detected */ public function create_tables() { // $link = mysql_connect($this->previous_steps['mysql']['server'], $this->previous_steps['mysql']['user'], $this->previous_steps['mysql']['password']); $link = e107::getDb()->connect($this->previous_steps['mysql']['server'], $this->previous_steps['mysql']['user'], $this->previous_steps['mysql']['password']); if(!$link) { return nl2br(LANINS_084."\n\n".LANINS_083."\n".e107::getDb()->getLastErrorText().""); } $this->dbLink = $link; // Needed for mysql_close() to work round bug in PHP 5.3 // $db_selected = mysql_select_db($this->previous_steps['mysql']['db'], $link); $db_selected = e107::getDb()->database($this->previous_steps['mysql']['db'],$this->previous_steps['mysql']['prefix']); if(!$db_selected) { return nl2br(LANINS_085." '{$this->previous_steps['mysql']['db']}'\n\n".LANINS_083."\n".e107::getDb()->getLastErrorText().""); } $filename = "{$this->e107->e107_dirs['CORE_DIRECTORY']}sql/core_sql.php"; $fd = fopen ($filename, "r"); $sql_data = fread($fd, filesize($filename)); $sql_data = preg_replace("#\/\*.*?\*\/#mis", '', $sql_data); // Strip comments fclose ($fd); if (!$sql_data) { return nl2br(LANINS_060)."

"; } preg_match_all("/create(.*?)(?:myisam|innodb);/si", $sql_data, $result ); // Force UTF-8 again $this->dbqry('SET NAMES `utf8`'); $srch = array("CREATE TABLE","("); $repl = array("DROP TABLE IF EXISTS",""); foreach ($result[0] as $sql_table) { $sql_table = preg_replace("/create table\s/si", "CREATE TABLE {$this->previous_steps['mysql']['prefix']}", $sql_table); // Drop existing tables before creating. $tmp = explode("\n",$sql_table); $drop_table = str_replace($srch,$repl,$tmp[0]); $this->dbqry($drop_table); if (!$this->dbqry($sql_table, $link)) { if($this->debug) { echo "

filename

"; var_dump($filename); echo "

sql_table

"; var_dump($sql_table); echo "

result[0]

"; var_dump($result[0]); } return nl2br(LANINS_061."\n\n".LANINS_083."\n".e107::getDb()->getLastErrorText().""); } } return FALSE; } function write_config($data) { $e107_config = 'e107_config.php'; $fp = @fopen($e107_config, 'w'); if (!@fwrite($fp, $data)) { @fclose ($fp); return nl2br(LANINS_070); } @fclose ($fp); @chmod($e107_config,0644); // correct permissions. return false; } function dbqry($qry) { $sql = e107::getDb(); return $sql->db_Query($qry); /*if($error = $sql->getLastErrorNumber()) { $errorInfo = 'Query Error [#'.$error.']: '.$sql->getLastErrorText()."\nQuery: {$qry}"; $this->debug_db_info['db_error_log'][] = $errorInfo; return false; } return true;*/ } } class e_forms { var $form; var $opened; function start_form($id, $action, $method = "post" ) { $this->form = "\n
\n"; $this->opened = true; } function add_select_item($id, $labels, $selected) { $this->form .= " \n"; } function add_hidden_data($id, $data) { $this->form .= "\n"; } function add_plain_html($html_data) { $this->form .= $html_data; } function return_form() { if($this->opened == true) { $this->form .= "
\n"; } $this->opened = false; return $this->form; } } function create_tables_unattended() { //If username or password not specified, exit if(!isset($_GET['username']) || !isset($_GET['password'])) { return false; } if(file_exists('e107_config.php')) { @include('e107_config.php'); } else { return false; } //If mysql info not set, config file is not created properly if(!isset($mySQLuser) || !isset($mySQLpassword) || !isset($mySQLdefaultdb) || !isset($mySQLprefix)) { return false; } // If specified username and password does not match the ones in config, exit if($_GET['username'] !== $mySQLuser || $_GET['password'] !== $mySQLpassword) { return false; } $einstall = new e_install(); $einstall->previous_steps['mysql']['server'] = $mySQLserver; $einstall->previous_steps['mysql']['user'] = $mySQLuser; $einstall->previous_steps['mysql']['password'] = $mySQLpassword; $einstall->previous_steps['mysql']['db'] = $mySQLdefaultdb; $einstall->previous_steps['mysql']['prefix'] = $mySQLprefix; $einstall->previous_steps['language'] = (isset($_GET['language']) ? $_GET['language'] : 'English'); $einstall->previous_steps['admin']['display'] = (isset($_GET['admin_display']) ? $_GET['admin_display'] : 'admin'); $einstall->previous_steps['admin']['user'] = (isset($_GET['admin_user']) ? $_GET['admin_user'] : 'admin'); $einstall->previous_steps['admin']['password'] = (isset($_GET['admin_password']) ? $_GET['admin_password'] : 'admin_password'); $einstall->previous_steps['admin']['email'] = (isset($_GET['admin_email']) ? $_GET['admin_email'] : 'admin_email@xxx.com'); $einstall->previous_steps['generate_content'] = isset($_GET['gen']) ? intval($_GET['gen']) : 1; $einstall->previous_steps['install_plugins'] = isset($_GET['plugins']) ? intval($_GET['plugins']) : 1; $einstall->previous_steps['prefs']['sitename'] = isset($_GET['sitename']) ? urldecode($_GET['sitename']) : LANINS_113; $einstall->previous_steps['prefs']['sitetheme'] = isset($_GET['theme']) ? urldecode($_GET['theme']) : 'jayya'; //@include_once("./{$HANDLERS_DIRECTORY}e107_class.php"); //$e107_paths = compact('ADMIN_DIRECTORY', 'FILES_DIRECTORY', 'IMAGES_DIRECTORY', 'THEMES_DIRECTORY', 'PLUGINS_DIRECTORY', 'HANDLERS_DIRECTORY', 'LANGUAGES_DIRECTORY', 'HELP_DIRECTORY', 'CACHE_DIRECTORY', 'DOWNLOADS_DIRECTORY', 'UPLOADS_DIRECTORY'); //$e107 = e107::getInstance(); //$e107->init($e107_paths, realpath(dirname(__FILE__))); //$einstall->e107 = &$e107; //FIXME - does not appear to work for import_configuration. ie. tables are blank except for user table. $einstall->create_tables(); $einstall->import_configuration(); return true; } class SimpleTemplate { var $Tags = array(); var $open_tag = "{"; var $close_tag = "}"; function SimpleTemplate() { define("TEMPLATE_TYPE_FILE", 0); define("TEMPLATE_TYPE_DATA", 1); } function SetTag($TagName, $Data) { $this->Tags[$TagName] = array( 'Tag' => $TagName, 'Data' => $Data ); } function RemoveTag($TagName) { unset($this->Tags[$TagName]); } function ClearTags() { $this->Tags = array(); } function ParseTemplate($Template, $template_type = TEMPLATE_TYPE_FILE) { if($template_type == TEMPLATE_TYPE_DATA) { $TemplateData = $Template; } else { $TemplateData = file_get_contents($Template); } foreach ($this->Tags as $Tag) { $TemplateData = str_replace($this->open_tag.$Tag['Tag'].$this->close_tag, $Tag['Data'], $TemplateData); } return $TemplateData; } } function template_data() { $data = ' {installation_heading} :: {stage_pre}{stage_num} - {stage_title}

e107

{stage_title}

{stage_content}
{debug_info}
'; return $data; } /** * Render a Fatal error and halt installation. */ function die_fatal_error($error) { define("e_IMAGE","e107_images/"); define("e_JS","e107_web/js/"); define("e_THEME", "e107_themes/"); define("e_LANGUAGEDIR", "e107_languages/"); include(e_LANGUAGEDIR."English/English.php"); include(e_LANGUAGEDIR."English/lan_installer.php"); $var = array(); $var["installation_heading"] = LANINS_001; $var["stage_pre"] = LANINS_002; $var["stage_num"] = LANINS_003; $var["stage_title"] = LAN_ERROR; $var["percent"] = 10; $var["bartype"] = 'danger'; $var['stage_content'] = "
".$error."
"; $var['debug_info'] = ''; $template = template_data(); foreach($var as $k=>$val) { $template = str_replace("{".$k."}", $val, $template); } echo $template; exit; }