/** * Write out an array of values to the config.php file. * * @param array $values The config values to write. * @return void */ public static function writeConfig($values) { // Include the config file so we can re-write the values contained within it. if (file_exists($file = PATH_CONFIG . "/config.php")) { include $file; } // Now add the $values to the $config array. if (!isset($config) or !is_array($config)) { $config = array(); } $config = array_merge($config, $values); self::$config = array_merge(self::$config, $values); // Finally, loop through and write the config array to the config file. $contents = "<?php\n"; foreach ($config as $k => $v) { $contents .= '$config["' . $k . '"] = ' . var_export($v, true) . ";\n"; } $contents .= "\n// Last updated by: " . ET::$session->user["username"] . " (" . ET::$session->ip . ") @ " . date("r") . "\n?>"; file_put_contents($file, $contents); }
/** * Show the "online members" sheet. * * @return void */ public function online() { // Check if we have permission to view the online list. if (!C("esoTalk.members.visibleToGuests") and !ET::$session->user) { $this->render404(T("message.pageNotFound")); return false; } // Set the title and make sure this page isn't indexed. $this->title = T("Online Members"); $this->addToHead("<meta name='robots' content='noindex, noarchive'/>"); // Construct a query to get only members who are online. $sql = ET::SQL()->where(time() - ET::config("esoTalk.userOnlineExpire") . "<lastActionTime")->orderBy("lastActionTime DESC"); // Pass this query to the member model and get all of these members' data. $members = ET::memberModel()->getWithSQL($sql); // Filter out members who have opted out of being displayed on the online list. $hidden = 0; foreach ($members as $k => $member) { if (!empty($member["preferences"]["hideOnline"])) { unset($members[$k]); $hidden++; } } $this->data("members", $members); $this->data("hidden", $hidden); $this->render("members/online"); }
/** * Shortcut function for ET::config(). * * @see ET::config() * * @package esoTalk */ function C($string, $default = false) { return ET::config($string, $default); }
/** * Show the "online members" sheet. * * @return void */ public function online() { // Set the title and make sure this page isn't indexed. $this->title = T("Online Members"); $this->addToHead("<meta name='robots' content='noindex, noarchive'/>"); // Construct a query to get only members who are online. $sql = ET::SQL()->where(time() - ET::config("esoTalk.userOnlineExpire") . "<lastActionTime")->orderBy("lastActionTime DESC"); // Pass this query to the member model and get all of these members' data. $members = ET::memberModel()->getWithSQL($sql); $this->data("members", $members); $this->render("members/online"); }
/** * 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")); }