Example #1
0
 /**
  * Construct and process the settings form for this skin, and return the path to the view that should be 
  * rendered.
  * 
  * @param ETController $sender The page controller.
  * @return string The path to the settings view to render.
  */
 public function settings($sender)
 {
     // Set up the settings form.
     $form = ETFactory::make("form");
     $form->action = URL("admin/plugins");
     $form->setValue("server", C("plugin.SMTP.server"));
     $form->setValue("username", C("plugin.SMTP.username"));
     $form->setValue("password", C("plugin.SMTP.password"));
     $form->setValue("port", C("plugin.SMTP.port"));
     $form->setValue("auth", C("plugin.SMTP.auth"));
     // If the form was submitted...
     if ($form->validPostBack("save")) {
         // Construct an array of config options to write.
         $config = array();
         $config["plugin.SMTP.server"] = $form->getValue("server");
         $config["plugin.SMTP.username"] = $form->getValue("username");
         $config["plugin.SMTP.password"] = $form->getValue("password");
         $config["plugin.SMTP.port"] = $form->getValue("port");
         $config["plugin.SMTP.auth"] = $form->getValue("auth");
         if (!$form->errorCount()) {
             // Write the config file.
             ET::writeConfig($config);
             $sender->message(T("message.changesSaved"), "success");
             $sender->redirect(URL("admin/plugins"));
         }
     }
     $sender->data("smtpSettingsForm", $form);
     return $this->getView("settings");
 }
Example #2
0
 /**
  * Write the skin's color configuration and CSS.
  * 
  * @param string $primary The primary color.
  * @return void
  */
 protected function writeColors($primary)
 {
     ET::writeConfig(array("skin.Doragon.primaryColor" => $primary));
     $rgb = colorUnpack($primary, true);
     $hsl = rgb2hsl($rgb);
     $primary = colorPack(hsl2rgb($hsl), true);
     $hsl[1] = max(0, $hsl[1] - 0.3);
     $secondary = colorPack(hsl2rgb(array(2 => 0.6) + $hsl), true);
     $tertiary = colorPack(hsl2rgb(array(2 => 0.92) + $hsl), true);
     $css = file_get_contents($this->resource("colors.css"));
     $css = str_replace(array("{primary}", "{secondary}", "{tertiary}"), array($primary, $secondary, $tertiary), $css);
     file_put_contents(PATH_CONFIG . "/colors.css", $css);
 }
Example #3
0
 /**
  * Check for updates to the esoTalk software. If there's a new version, and this is the first time we've heard
  * of it, create a notifcation for the current user.
  *
  * @return void
  */
 public function checkForUpdates()
 {
     // Save the last update check time so we won't do it again for a while.
     ET::writeConfig(array("esoTalk.admin.lastUpdateCheckTime" => time()));
     // If the latest version is different to what it was last time we checked...
     $info = C("esoTalk.admin.lastUpdateCheckInfo", array("version" => ESOTALK_VERSION));
     if ($package = ET::checkForUpdates() and $package["version"] != $info["version"]) {
         // Create a notification.
         ET::activityModel()->create("updateAvailable", ET::$session->userId, null, $package);
         // Write the latest checked version to the config file.
         ET::writeConfig(array("esoTalk.admin.lastUpdateCheckInfo" => $package));
     }
 }
 /**
  * Perform the upgrade process.
  *
  * @return void
  */
 public function action_index()
 {
     try {
         // Run the upgrade process.
         ET::upgradeModel()->upgrade(C("esoTalk.version"));
         // Update the version and serial in the config file.
         ET::writeConfig(array("esoTalk.version" => ESOTALK_VERSION));
         // Show a success message and redirect.
         $this->message(T("message.upgradeSuccessful"), "success");
         $this->redirect(URL(""));
     } catch (Exception $e) {
         $this->fatalError($e->getMessage());
     }
 }
 /**
  * Show the administrator dashboard view.
  *
  * @return void
  */
 public function action_index()
 {
     $this->title = T("Dashboard");
     // Work out a UNIX timestamp of one week ago.
     $oneWeekAgo = time() - 60 * 60 * 24 * 7;
     // Create an array of statistics to show on the dashboard.
     $statistics = array("<a href='" . URL("members") . "'>" . T("Members") . "</a>" => number_format(ET::SQL()->select("COUNT(*)")->from("member")->exec()->result()), T("Conversations") => number_format(ET::SQL()->select("COUNT(*)")->from("conversation")->exec()->result()), T("Posts") => number_format(ET::SQL()->select("COUNT(*)")->from("post")->exec()->result()), T("New members in the past week") => number_format(ET::SQL()->select("COUNT(*)")->from("member")->where(":time<joinTime")->bind(":time", $oneWeekAgo)->exec()->result()), T("New conversations in the past week") => number_format(ET::SQL()->select("COUNT(*)")->from("conversation")->where(":time<startTime")->bind(":time", $oneWeekAgo)->exec()->result()), T("New posts in the past week") => number_format(ET::SQL()->select("COUNT(*)")->from("post")->where(":time<time")->bind(":time", $oneWeekAgo)->exec()->result()));
     // Determine if we should show the welcome sheet.
     if (!C("esoTalk.admin.welcomeShown")) {
         $this->data("showWelcomeSheet", true);
         ET::writeConfig(array("esoTalk.admin.welcomeShown" => true));
     }
     $this->data("statistics", $statistics);
     $this->render("admin/dashboard");
 }
Example #6
0
 public function settings($sender)
 {
     // Set up the settings form.
     $form = ETFactory::make("form");
     $form->action = URL("admin/plugins/settings/Signature");
     // Set the values for the sitemap options.
     $form->setValue("characters", C("plugin.Signature.characters", "150"));
     // If the form was submitted...
     if ($form->validPostBack()) {
         // Construct an array of config options to write.
         $config = array();
         $config["plugin.Signature.characters"] = $form->getValue("characters");
         // Write the config file.
         ET::writeConfig($config);
         $sender->redirect(URL("admin/plugins"));
     }
     $sender->data("SignatureSettingsForm", $form);
     return $this->view("settings");
 }
Example #7
0
 public function settings($sender)
 {
     // Set up the settings form.
     $form = ETFactory::make("form");
     $form->action = URL("admin/plugins/settings/GoogleAnalytics");
     $form->setValue("trackingId", C("GoogleAnalytics.trackingId"));
     // If the form was submitted...
     if ($form->validPostBack()) {
         // Construct an array of config options to write.
         $config = array();
         $config["GoogleAnalytics.trackingId"] = $form->getValue("trackingId");
         // Write the config file.
         ET::writeConfig($config);
         $sender->message(T("message.changesSaved"), "success autoDismiss");
         $sender->redirect(URL("admin/plugins"));
     }
     $sender->data("googleAnalyticsSettingsForm", $form);
     return $this->view("settings");
 }
Example #8
0
 public function settings($sender)
 {
     // Expand the filters array into a string that will go in the textarea.
     $filters = C("plugin.WordFilter.filters", array());
     $filterText = "";
     foreach ($filters as $word => $replacement) {
         $filterText .= $word . ($replacement ? "|{$replacement}" : "") . "\n";
     }
     $filterText = trim($filterText);
     // Set up the settings form.
     $form = ETFactory::make("form");
     $form->action = URL("admin/plugins");
     $form->setValue("filters", $filterText);
     // If the form was submitted...
     if ($form->validPostBack("wordFilterSave")) {
         // Create an array of word filters from the contents of the textarea.
         // Each line is a new element in the array; keys and values are separated by a | character.
         $filters = array();
         $lines = explode("\n", strtr($form->getValue("filters"), array("\r\n" => "\n", "\r" => "\n")));
         foreach ($lines as $line) {
             if (!$line) {
                 continue;
             }
             $parts = explode("|", $line, 2);
             if (!$parts[0]) {
                 continue;
             }
             $filters[$parts[0]] = @$parts[1];
         }
         // Construct an array of config options to write.
         $config = array();
         $config["plugin.WordFilter.filters"] = $filters;
         if (!$form->errorCount()) {
             // Write the config file.
             ET::writeConfig($config);
             $sender->message(T("message.changesSaved"), "success");
             $sender->redirect(URL("admin/plugins"));
         }
     }
     $sender->data("wordFilterSettingsForm", $form);
     return $this->getView("settings");
 }
 /**
  * Show and process the settings form.
  *
  * @return void
  */
 public function index()
 {
     // Make an array of languages for the default forum language select.
     $languages = array();
     foreach (ET::getLanguages() as $v) {
         $languages[$v] = ET::$languageInfo[$v]["name"];
     }
     // Get a list of member groups.
     $groups = ET::groupModel()->getAll();
     // Set up the form.
     $form = ETFactory::make("form");
     $form->action = URL("admin/settings");
     // Set the default values for the forum inputs.
     $form->setValue("forumTitle", C("esoTalk.forumTitle"));
     $form->setValue("language", C("esoTalk.language"));
     $form->setValue("forumHeader", C("esoTalk.forumLogo") ? "image" : "title");
     $form->setValue("defaultRoute", C("esoTalk.defaultRoute"));
     $form->setValue("registrationOpen", C("esoTalk.registration.open"));
     $form->setValue("memberListVisibleToGuests", C("esoTalk.members.visibleToGuests"));
     $form->setValue("requireAdminApproval", C("esoTalk.registration.requireAdminApproval"));
     $form->setValue("requireEmailConfirmation", C("esoTalk.registration.requireEmailConfirmation"));
     // If the save button was clicked...
     if ($form->validPostBack("save")) {
         // Construct an array of config options to write.
         $config = array("esoTalk.forumTitle" => $form->getValue("forumTitle"), "esoTalk.language" => $form->getValue("language"), "esoTalk.forumLogo" => $form->getValue("forumHeader") == "image" ? $this->uploadHeaderImage($form) : false, "esoTalk.defaultRoute" => $form->getValue("defaultRoute"), "esoTalk.registration.open" => $form->getValue("registrationOpen"), "esoTalk.registration.requireEmailConfirmation" => $form->getValue("requireEmailConfirmation"), "esoTalk.members.visibleToGuests" => $form->getValue("memberListVisibleToGuests"));
         // Make sure a forum title is present.
         if (!strlen($config["esoTalk.forumTitle"])) {
             $form->error("forumTitle", T("message.empty"));
         }
         if (!$form->errorCount()) {
             ET::writeConfig($config);
             $this->message(T("message.changesSaved"), "success");
             $this->redirect(URL("admin/settings"));
         }
     }
     $this->data("form", $form);
     $this->data("languages", $languages);
     $this->data("groups", $groups);
     $this->title = T("Forum Settings");
     $this->render("admin/settings");
 }
Example #10
0
 public function settings($sender)
 {
     // Set up the settings form. Set some default values for the first time.
     $form = ETFactory::make("form");
     $form->action = URL("admin/plugins/settings/Reputation");
     $form->setValue("showReputationPublic", C("plugin.Reputation.showReputationPublic", "0"));
     $form->setValue("conversationStartRP", C("plugin.Reputation.conversationStartRP", "10"));
     $form->setValue("getReplyRP", C("plugin.Reputation.getReplyRP", "5"));
     $form->setValue("viewsRP", C("plugin.Reputation.viewsRP", "0"));
     $form->setValue("likesRP", C("plugin.Reputation.likesRP", "5"));
     $form->setValue("replyRP", C("plugin.Reputation.replyRP", "5"));
     $form->setValue("newReputationUpdate", C("plugin.Reputation.newReputationUpdate", "0"));
     // If the form was submitted...
     if ($form->validPostBack("reputationSave")) {
         // Construct an array of config options to write.
         $config = array();
         $config["plugin.Reputation.showReputationPublic"] = $form->getValue("showReputationPublic");
         $config["plugin.Reputation.conversationStartRP"] = $form->getValue("conversationStartRP");
         $config["plugin.Reputation.getReplyRP"] = $form->getValue("getReplyRP");
         $config["plugin.Reputation.replyRP"] = $form->getValue("replyRP");
         $config["plugin.Reputation.viewsRP"] = $form->getValue("viewsRP");
         $config["plugin.Reputation.likesRP"] = $form->getValue("likesRP");
         $config["plugin.Reputation.newReputationUpdate"] = $form->getValue("newReputationUpdate");
         // Update reputatoin ponits in databse according to new formula
         if (C("plugin.Reputation.newReputationUpdate") == 1) {
             $this->updateNewReputation(C("plugin.Reputation.replyRP"), C("plugin.Reputation.conversationStartRP"), C("plugin.Reputation.viewsRP"), C("plugin.Reputation.likesRP"), C("plugin.Reputation.getReplyRP"));
             $config["plugin.Reputation.newReputationUpdate"] = 0;
         }
         if (!$form->errorCount()) {
             // Write the config file.
             ET::writeConfig($config);
             $sender->message(T("message.changesSaved"), "success autoDismiss");
             $sender->redirect(URL("admin/plugins"));
         }
     }
     $sender->data("reputationSettingsForm", $form);
     return $this->view("settings");
 }
Example #11
0
 /**
  * Setting form on admin panel
  */
 public function settings($sender)
 {
     $form = ETFactory::make('form');
     $form->action = URL('admin/plugins');
     $form->setValue('linksBottomMenu', $this->c['linksBottomMenu']);
     $form->setValue('linksTopMenu', $this->c['linksTopMenu']);
     $form->setValue('beforeBody', $this->c['beforeBody']);
     $form->setValue('headSection', $this->c['headSection']);
     if ($form->validPostBack("MenuLinksSave")) {
         $config = array();
         $config['plugin.MenuLinks.linksBottomMenu'] = $form->getValue('linksBottomMenu');
         $config['plugin.MenuLinks.linksTopMenu'] = $form->getValue('linksTopMenu');
         $config['plugin.MenuLinks.beforeBody'] = $form->getValue('beforeBody');
         $config['plugin.MenuLinks.headSection'] = $form->getValue('headSection');
         if (!$form->errorCount()) {
             ET::writeConfig($config);
             $sender->message(T("message.changesSaved"), "success autoDismiss");
             $sender->redirect(URL("admin/plugins"));
         }
     }
     $sender->data("MenuLinks", $form);
     return $this->getView("settings");
 }
Example #12
0
 public function settings($sender)
 {
     // Set up the settings form.
     $form = ETFactory::make("form");
     $form->action = URL("admin/plugins/settings/reCAPTCHA");
     $form->setValue("secretkey", C("plugin.reCAPTCHA.secretkey"));
     $form->setValue("sitekey", C("plugin.reCAPTCHA.sitekey"));
     $form->setValue("language", C("plugin.reCAPTCHA.language"));
     $form->setValue("language", C("plugin.reCAPTCHA.language", "en"));
     // If the form was submitted...
     if ($form->validPostBack()) {
         // Construct an array of config options to write.
         $config = array();
         $config["plugin.reCAPTCHA.secretkey"] = $form->getValue("secretkey");
         $config["plugin.reCAPTCHA.sitekey"] = $form->getValue("sitekey");
         $config["plugin.reCAPTCHA.language"] = $form->getValue("language");
         // Write the config file.
         ET::writeConfig($config);
         $sender->message(T("message.changesSaved"), "success autoDismiss");
         $sender->redirect(URL("admin/plugins"));
     }
     $sender->data("reCAPTCHASettingsForm", $form);
     return $this->view("settings");
 }
 /**
  * Uninstall a plugin by calling its uninstall function and removing its directory.
  *
  * @param string $plugin The name of the plugin.
  * @return void
  */
 public function action_uninstall($plugin = "")
 {
     if (!$this->validateToken()) {
         return;
     }
     // Get the plugin.
     $plugins = $this->getPlugins();
     if (!$plugin or !array_key_exists($plugin, $plugins)) {
         return;
     }
     $enabledPlugins = C("esoTalk.enabledPlugins");
     // If the plugin is currently enabled, take it out of the loaded plugins array.
     $k = array_search($plugin, $enabledPlugins);
     if ($k !== false) {
         unset($enabledPlugins[$k]);
         // Call the plugin's disable function.
         ET::$plugins[$plugin]->disable();
         ET::writeConfig(array("esoTalk.enabledPlugins" => $enabledPlugins));
     }
     // Set up an instance of the plugin so we can call its uninstall function.
     if (file_exists($file = PATH_PLUGINS . "/" . sanitizeFileName($plugin) . "/plugin.php")) {
         include_once $file;
     }
     $className = "ETPlugin_{$plugin}";
     if (class_exists($className)) {
         $pluginObject = new $className();
         $pluginObject->uninstall();
     }
     // Attempt to remove the directory. If we couldn't, show a "not writable" message.
     if (!is_writable($file = PATH_PLUGINS) or !is_writable($file = PATH_PLUGINS . "/{$plugin}") or !rrmdir($file)) {
         $this->message(sprintf(T("message.notWritable"), $file), "warning");
     } else {
         $this->message(T("message.pluginUninstalled"), "success");
     }
     $this->redirect(URL("admin/plugins"));
 }
Example #14
0
}
//***** 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"])) {
    // Remove the base path from the request URI.
    $request = preg_replace("|^" . preg_quote(ET::$webPath) . "(/index\\.php)?|", "", $_SERVER["REQUEST_URI"]);
    // If there is a querystring, remove it.
    $selfURL = $request;
    if (($pos = strpos($request, "?")) !== false) {
        $request = substr_replace($request, "", $pos);
 /**
  * Perform an upgrade to ensure that the database is up-to-date.
  *
  * @param string $currentVersion The version we are upgrading from.
  * @return void
  */
 public function upgrade($currentVersion = "")
 {
     // 1.0.0g5:
     // - Drop the cookie table
     // - Write config to enable persistence cookies. These are disabled by
     //   default in g5 because otherwise the ETSession class will encounter
     //   a fatal error (rememberToken column doesn't exist) before reaching
     //   the upgrade script.
     if (version_compare($currentVersion, "1.0.0g5", "<")) {
         ET::$database->structure()->table("cookie")->drop();
         ET::writeConfig(array("esoTalk.enablePersistenceCookies" => true));
     }
     // 1.0.0g4:
     // - Rename the 'confirmedEmail' column on the members table to 'confirmed'
     // - Rename the 'muted' column on the member_conversation table to 'ignored'
     if (version_compare($currentVersion, "1.0.0g4", "<")) {
         ET::$database->structure()->table("member")->renameColumn("confirmedEmail", "confirmed");
         ET::$database->structure()->table("member_conversation")->renameColumn("muted", "ignored");
     }
     // Make sure the application's table structure is up-to-date.
     $this->structure(false);
     // Perform any custom upgrade procedures, from $currentVersion to ESOTALK_VERSION, here.
     // 1.0.0g3:
     /// - Re-calculate all conversation post counts due to a bug which could get them un-synced
     if (version_compare($currentVersion, "1.0.0g3", "<")) {
         ET::SQL()->update("conversation c")->set("countPosts", "(" . ET::SQL()->select("COUNT(*)")->from("post p")->where("p.conversationId=c.conversationId") . ")", false)->exec();
     }
 }
 /**
  * Show and process the settings form.
  *
  * @return void
  */
 public function action_index()
 {
     // Make an array of languages for the default forum language select.
     $languages = array();
     foreach (ET::getLanguages() as $v) {
         $languages[$v] = ET::$languageInfo[$v]["name"];
     }
     // Set up the form.
     $form = ETFactory::make("form");
     $form->action = URL("admin/settings");
     // Set the default values for the forum inputs.
     $form->setValue("forumTitle", C("esoTalk.forumTitle"));
     $form->setValue("language", C("esoTalk.language"));
     $form->setValue("forumHeader", C("esoTalk.forumLogo") ? "image" : "title");
     $form->setValue("defaultRoute", C("esoTalk.defaultRoute"));
     $form->setValue("forumVisibleToGuests", C("esoTalk.visibleToGuests"));
     $form->setValue("memberListVisibleToGuests", C("esoTalk.members.visibleToGuests"));
     $form->setValue("registrationOpen", C("esoTalk.registration.open"));
     $form->setValue("requireConfirmation", C("esoTalk.registration.requireConfirmation"));
     $c = C("esoTalk.conversation.editPostTimeLimit");
     if ($c === -1) {
         $form->setValue("editPostMode", "forever");
     } elseif ($c === "reply") {
         $form->setValue("editPostMode", "reply");
     } else {
         $form->setValue("editPostMode", "custom");
         $form->setValue("editPostTimeLimit", $c);
     }
     // If the save button was clicked...
     if ($form->validPostBack("save")) {
         $forumLogo = false;
         if ($form->getValue("forumHeader") == "image") {
             if ($form->getValue("forumHeaderOld") != "image") {
                 $forumLogo = $this->uploadHeaderImage($form);
             } else {
                 $forumLogo = !empty($_FILES["forumHeaderImage"]['tmp_name']) ? $this->uploadHeaderImage($form) : C("esoTalk.forumLogo");
             }
         }
         // Construct an array of config options to write.
         $config = array("esoTalk.forumTitle" => $form->getValue("forumTitle"), "esoTalk.language" => $form->getValue("language"), "esoTalk.forumLogo" => $forumLogo, "esoTalk.defaultRoute" => $form->getValue("defaultRoute"), "esoTalk.visibleToGuests" => $form->getValue("forumVisibleToGuests"), "esoTalk.members.visibleToGuests" => $form->getValue("forumVisibleToGuests") and $form->getValue("memberListVisibleToGuests"), "esoTalk.registration.open" => $form->getValue("registrationOpen"), "esoTalk.registration.requireConfirmation" => in_array($v = $form->getValue("requireConfirmation"), array(false, "email", "approval")) ? $v : false);
         switch ($form->getValue("editPostMode")) {
             case "forever":
                 $config["esoTalk.conversation.editPostTimeLimit"] = -1;
                 break;
             case "reply":
                 $config["esoTalk.conversation.editPostTimeLimit"] = "reply";
                 break;
             case "custom":
                 $config["esoTalk.conversation.editPostTimeLimit"] = (int) $form->getValue("editPostTimeLimit");
                 break;
         }
         // Make sure a forum title is present.
         if (!strlen($config["esoTalk.forumTitle"])) {
             $form->error("forumTitle", T("message.empty"));
         }
         if (!$form->errorCount()) {
             ET::writeConfig($config);
             $this->message(T("message.changesSaved"), "success autoDismiss");
             $this->redirect(URL("admin/settings"));
         }
     }
     $this->data("form", $form);
     $this->data("languages", $languages);
     $this->title = T("Forum Settings");
     $this->render("admin/settings");
 }
 /**
  * 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"));
 }
 /**
  * Uninstall a skin by removing its directory.
  *
  * @param string $skin The name of the skin.
  * @return void
  */
 public function action_uninstall($skin = "")
 {
     if (!$this->validateToken()) {
         return;
     }
     // Get the skins and make sure this one exists.
     $skins = $this->getSkins();
     if (!$skin or !array_key_exists($skin, $skins)) {
         return false;
     }
     unset($skins[$skin]);
     // Attempt to remove the directory. If we couldn't, show a "not writable" message.
     if (!is_writable($file = PATH_SKINS) or !is_writable($file = PATH_SKINS . "/{$skin}") or !rrmdir($file)) {
         $this->message(sprintf(T("message.notWritable"), $file), "warning");
     } else {
         $this->message(T("message.skinUninstalled"), "success");
     }
     // If one of the skin config options is set to this skin, change it.
     $config = array();
     if (C("esoTalk.skin") == $skin) {
         $config["esoTalk.skin"] = reset(array_keys($skins));
     }
     if (C("esoTalk.mobileSkin") == $skin) {
         $config["esoTalk.mobileSkin"] = reset(array_keys($skins));
     }
     if (count($config)) {
         ET::writeConfig($config);
     }
     $this->redirect(URL("admin/appearance"));
 }
Example #19
0
 public function settings($sender)
 {
     // Set up the settings form.
     $form = ETFactory::make("form");
     $form->action = URL("admin/plugins/settings/AttachmentsSAE");
     $form->setValue("allowedFileTypes", implode(" ", (array) C("plugin.AttachmentsSAE.allowedFileTypes")));
     $form->setValue("maxFileSize", C("plugin.AttachmentsSAE.maxFileSize"));
     // If the form was submitted...
     if ($form->validPostBack("attachmentsSave")) {
         // Construct an array of config options to write.
         $config = array();
         $fileTypes = $form->getValue("allowedFileTypes");
         $config["plugin.AttachmentsSAE.allowedFileTypes"] = $fileTypes ? explode(" ", $fileTypes) : "";
         $config["plugin.AttachmentsSAE.maxFileSize"] = $form->getValue("maxFileSize");
         if (!$form->errorCount()) {
             // Write the config file.
             ET::writeConfig($config);
             $sender->message(T("message.changesSaved"), "success autoDismiss");
             $sender->redirect(URL("admin/plugins"));
         }
     }
     $sender->data("attachmentsSettingsForm", $form);
     return $this->view("settings");
 }
Example #20
0
 /**
  * Construct and process the settings form for this skin, and return the path to the view that should be 
  * rendered.
  * 
  * @param ETController $sender The page controller.
  * @return string The path to the settings view to render.
  */
 public function settings($sender)
 {
     // Set up the settings form.
     $form = ETFactory::make("form");
     $form->action = URL("admin/appearance");
     $form->setValue("headerColor", C("skin.Default.headerColor"));
     $form->setValue("bodyColor", C("skin.Default.bodyColor"));
     $form->setValue("noRepeat", (bool) C("skin.Default.noRepeat"));
     $form->setValue("bodyImage", (bool) C("skin.Default.bodyImage"));
     // If the form was submitted...
     if ($form->validPostBack("save")) {
         // Construct an array of config options to write.
         $config = array();
         $config["skin.Default.headerColor"] = $form->getValue("headerColor");
         $config["skin.Default.bodyColor"] = $form->getValue("bodyColor");
         // Upload a body bg image if necessary.
         if ($form->getValue("bodyImage") and !empty($_FILES["bodyImageFile"]["tmp_name"])) {
             $config["skin.Default.bodyImage"] = $this->uploadBackgroundImage($form);
         } elseif (!$form->getValue("bodyImage")) {
             $config["skin.Default.bodyImage"] = false;
         }
         $config["skin.Default.noRepeat"] = (bool) $form->getValue("noRepeat");
         if (!$form->errorCount()) {
             // Write the config file.
             ET::writeConfig($config);
             $sender->message(T("message.changesSaved"), "success");
             $sender->redirect(URL("admin/appearance"));
         }
     }
     $sender->data("skinSettingsForm", $form);
     $sender->addCSSFile("core/js/lib/farbtastic/farbtastic.css");
     $sender->addJSFile("core/js/lib/farbtastic/farbtastic.js");
     return $this->getView("settings");
 }
Example #21
0
 public function settings($sender)
 {
     $sender->addCSSFile($this->resource("sitemap.css"));
     // Set up the settings form.
     $form = ETFactory::make("form");
     $form->action = URL("admin/plugins/settings/Sitemap");
     // Add the section for the restore element.
     $form->addSection("channels");
     // Add the field for the restore select element.
     $form->addField("channels", "channels", array($this, "renderChannelsField"), array($this, "processChannelsField"));
     $form->setValue("channels[]", C("plugin.Sitemap.channels"));
     // Set the values for the sitemap options.
     $form->setValue("cache", C("plugin.Sitemap.cache", "24"));
     $form->setValue("prio1", C("plugin.Sitemap.priority1", "0.5"));
     $form->setValue("prio2", C("plugin.Sitemap.priority2", "0.6"));
     $form->setValue("prio3", C("plugin.Sitemap.priority3", "0.7"));
     $form->setValue("freq1", C("plugin.Sitemap.frequency1", "daily"));
     $form->setValue("freq2", C("plugin.Sitemap.frequency2", "daily"));
     $form->setValue("freq3", C("plugin.Sitemap.frequency3", "hourly"));
     $form->setValue("auto1", C("plugin.Sitemap.google", true));
     $form->setValue("auto2", C("plugin.Sitemap.bing", true));
     // If the form was submitted...
     if ($form->validPostBack()) {
         // Get the value from the dynamically created "compress" field.
         $form->runFieldCallbacks($data);
         // Construct an array of config options to write.
         $config = array();
         $config["plugin.Sitemap.cache"] = $form->getValue("cache");
         $config["plugin.Sitemap.channels"] = array_combine($data["channels"], $data["channels"]);
         $config["plugin.Sitemap.priority1"] = $form->getValue("prio1");
         $config["plugin.Sitemap.priority2"] = $form->getValue("prio2");
         $config["plugin.Sitemap.priority3"] = $form->getValue("prio3");
         $config["plugin.Sitemap.frequency1"] = $form->getValue("freq1");
         $config["plugin.Sitemap.frequency2"] = $form->getValue("freq2");
         $config["plugin.Sitemap.frequency3"] = $form->getValue("freq3");
         $config["plugin.Sitemap.google"] = $form->getValue("auto1");
         $config["plugin.Sitemap.bing"] = $form->getValue("auto2");
         // Write the config file.
         ET::writeConfig($config);
         $this->action_create();
         $sender->message(T("The sitemap has been regenerated!"), "success autoDismiss");
         if (!C("plugin.Sitemap.google") && !C("plugin.Sitemap.bing")) {
             $sender->message(T("Please submit <strong><i>" . C("esoTalk.baseURL") . "sitemap-index.xml</i></strong> to <a href='https://support.google.com/sites/answer/100283?hl=en' target='_blank'>Google Webmaster Tools</a> and <a href='http://www.bing.com/webmaster/help/how-to-submit-sitemaps-82a15bd4' target='_blank'>Bing Webmaster Tools</a>."), "success");
         }
         $this->autoSubmit();
         $sender->redirect(URL("admin/plugins"));
     }
     $sender->data("SitemapSettingsForm", $form);
     return $this->view("settings");
 }