if (!class_exists($className)) { continue; } ET::$plugins[$v] = new $className("addons/plugins/" . $v); ET::$plugins[$v]->boot(); } } //***** 6. INITIALIZE SESSION AND DATABASE, AND CACHE // Initialize the cache. $cacheClass = C("esoTalk.cache"); ET::$cache = ETFactory::make($cacheClass ? $cacheClass : "cache"); // Connect to the database. ET::$database = ETFactory::make("database"); ET::$database->init(C("esoTalk.database.host"), C("esoTalk.database.user"), C("esoTalk.database.password"), C("esoTalk.database.dbName"), C("esoTalk.database.prefix"), C("esoTalk.database.connectionOptions"), C("esoTalk.database.port")); // Initialize the session. ET::$session = ETFactory::make("session"); // Check if any plugins need upgrading by comparing the versions in ET::$pluginInfo with the versions in // ET::$config. foreach (ET::$plugins as $k => $v) { if (C("{$k}.version") != ET::$pluginInfo[$k]["version"]) { if ($v->setup(C("{$k}.version"))) { ET::writeConfig(array("{$k}.version" => ET::$pluginInfo[$k]["version"])); } } } //***** 7. PARSE REQUEST // If $_GET["p"] was explicitly specified, use that. if (!empty($_GET["p"])) { $request = $_GET["p"]; unset($_GET["p"]); } elseif (C("esoTalk.urls.friendly") and isset($_SERVER["REQUEST_URI"])) {
/** * Now that all necessary checks have been made and data has been gathered, perform the installation. * * @return void */ public function action_install() { // If we aren't supposed to be here, get out. if (!($info = ET::$session->get("install"))) { $this->redirect(URL("install/info")); } // Make sure the base URL has a trailing slash. if (substr($info["baseURL"], -1) != "/") { $info["baseURL"] .= "/"; } // Prepare the $config variable with the installation settings. $config = array("esoTalk.installed" => true, "esoTalk.version" => ESOTALK_VERSION, "esoTalk.forumTitle" => $info["forumTitle"], "esoTalk.baseURL" => $info["baseURL"], "esoTalk.emailFrom" => "do_not_reply@{$_SERVER["HTTP_HOST"]}", "esoTalk.cookie.name" => 'et'); //"esoTalk.cookie.name" => preg_replace(array("/\s+/", "/[^\w]/"), array("_", ""), $info["forumTitle"]), // Merge these new config settings into our current conifg variable. ET::$config = array_merge(ET::$config, $config); // Initialize the database with our MySQL details. ET::$database->init(C("esoTalk.database.host"), C("esoTalk.database.user"), C("esoTalk.database.password"), C("esoTalk.database.dbName"), C("esoTalk.database.prefix"), C("esoTalk.database.connectionOptions"), C("esoTalk.database.port")); // Run the upgrade model's install function. try { ET::upgradeModel()->install($info); } catch (Exception $e) { $this->fatalError($e->getMessage()); } // Write the $config variable to config.php. @unlink(PATH_CONFIG . "/config.php"); ET::writeConfig($config); /* // Write custom.css and index.html as empty files (if they're not already there.) if (!file_exists(PATH_CONFIG."/custom.css")) file_put_contents(PATH_CONFIG."/custom.css", ""); file_put_contents(PATH_CONFIG."/index.html", ""); file_put_contents(PATH_UPLOADS."/index.html", ""); file_put_contents(PATH_UPLOADS."/avatars/index.html", ""); // Write a .htaccess file if they are using friendly URLs (and mod_rewrite). if (C("esoTalk.urls.rewrite")) { file_put_contents(PATH_ROOT."/.htaccess", "# Generated by esoTalk <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [QSA,L] </IfModule>"); } */ /* // Write a robots.txt file. file_put_contents(PATH_ROOT."/robots.txt", "User-agent: * Crawl-delay: 10 Disallow: /conversations/*?search=* Disallow: /members/ Disallow: /user/ Disallow: /conversation/start/"); */ // Clear the session of install data. ET::$session->remove("install"); // Re-initialize the session and log the administrator in. ET::$session = ETFactory::make("session"); ET::$session->loginWithMemberId(1); // Redirect them to the administration page. $this->redirect(URL("admin")); }