function Plugin() { if (!empty($this->defaultConfig)) { global $config; $filename = sanitizeFileName($this->id); if (!file_exists("config/{$filename}.php")) { writeConfigFile("config/{$filename}.php", '$config["' . escapeDoubleQuotes($this->id) . '"]', $this->defaultConfig); } include "config/{$filename}.php"; } }
/** * Load a language and its definition files, depending on what plugins are enabled. * * @param string $language The name of the language. * @return void */ public static function loadLanguage($language = "") { // Clear the currently loaded definitions. self::$definitions = array(); // If the specified language doesn't exist, use the default language. self::$language = file_exists(PATH_LANGUAGES . "/" . sanitizeFileName($language) . "/definitions.php") ? $language : C("esoTalk.language"); // Load the main definitions file. $languagePath = PATH_LANGUAGES . "/" . sanitizeFileName(self::$language); self::loadDefinitions("{$languagePath}/definitions.php"); // Set the locale. if (isset(ET::$languageInfo[self::$language]["locale"])) { setlocale(LC_ALL, ET::$languageInfo[self::$language]["locale"]); } // Loop through the loaded plugins and include their definition files, if they exist. foreach (C("esoTalk.enabledPlugins") as $plugin) { if (file_exists($file = "{$languagePath}/definitions." . sanitizeFileName($plugin) . ".php")) { self::loadDefinitions($file); } } // Re-define runtime definitions. foreach (self::$runtimeDefinitions as $k => $v) { ET::define($k, $v); } }
/** * 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")); }
ETFactory::registerController("admin", "ETAdminController", PATH_CONTROLLERS . "/ETAdminController.class.php"); ETFactory::registerAdminController("dashboard", "ETDashboardAdminController", PATH_CONTROLLERS . "/admin/ETDashboardAdminController.class.php"); ETFactory::registerAdminController("settings", "ETSettingsAdminController", PATH_CONTROLLERS . "/admin/ETSettingsAdminController.class.php"); ETFactory::registerAdminController("appearance", "ETAppearanceAdminController", PATH_CONTROLLERS . "/admin/ETAppearanceAdminController.class.php"); ETFactory::registerAdminController("channels", "ETChannelsAdminController", PATH_CONTROLLERS . "/admin/ETChannelsAdminController.class.php"); ETFactory::registerAdminController("plugins", "ETPluginsAdminController", PATH_CONTROLLERS . "/admin/ETPluginsAdminController.class.php"); ETFactory::registerAdminController("groups", "ETGroupsAdminController", PATH_CONTROLLERS . "/admin/ETGroupsAdminController.class.php"); ETFactory::registerAdminController("languages", "ETLanguagesAdminController", PATH_CONTROLLERS . "/admin/ETLanguagesAdminController.class.php"); if (C("esoTalk.registration.requireConfirmation") == "approval") { ETFactory::registerAdminController("unapproved", "ETUnapprovedAdminController", PATH_CONTROLLERS . "/admin/ETUnapprovedAdminController.class.php"); } } //***** 5. SET UP PLUGINS if (C("esoTalk.installed")) { foreach (C("esoTalk.enabledPlugins") as $v) { if (file_exists($file = PATH_PLUGINS . "/" . sanitizeFileName($v) . "/plugin.php")) { include_once $file; } $className = "ETPlugin_{$v}"; 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.
/** * Load a language and its definition files, depending on what plugins are enabled. * * @param string $language The name of the language. * @return void */ public static function loadLanguage($language = "") { if (isset(ET::$languageInfo[$language])) { return; } $narr = ET::$cache->filenames; if ($narr !== false && isset($narr["language_filename"])) { self::$language_filename = $narr["language_filename"]; } //while $narr is empty create an new array if (empty($narr)) { $narr = array(); } // Clear the currently loaded definitions. self::$definitions = array(); // If the specified language doesn't exist, use the default language. self::$language = file_exists(PATH_LANGUAGES . "/" . sanitizeFileName($language) . "/definitions.php") ? $language : C("esoTalk.language"); // Load the main definitions file. $languagePath = PATH_LANGUAGES . "/" . sanitizeFileName(self::$language); self::loadDefinitions("{$languagePath}/definitions.php"); // Set the locale. if (isset(ET::$languageInfo[self::$language]["locale"])) { setlocale(LC_ALL, ET::$languageInfo[self::$language]["locale"]); } // Loop through the loaded plugins and include their definition files, if they exist. foreach (C("esoTalk.enabledPlugins") as $plugin) { if (empty(self::$language_filename) || self::$language_filename[$plugin] == false) { if (file_exists($file = "{$languagePath}/definitions." . sanitizeFileName($plugin) . ".php")) { self::loadDefinitions($file); self::$language_filename[$plugin] = $file; $narr["language_filename"] = self::$language_filename; //ET::$cache->store("language_filename" , self::$language_filename); //ET::$cache->store(ET::$cache->fname_key , $narr); ET::$cache->filenames = $narr; ET::$cache->fnamechanged = true; } } else { $file = self::$language_filename[$plugin]; self::loadDefinitions($file); } } //var_dump($narr);//exit(); unset($narr); // Re-define runtime definitions. foreach (self::$runtimeDefinitions as $k => $v) { ET::define($k, $v); } }
} // If we haven't got a working language, show an error! if (empty($language)) { $esoTalk->fatalError("esoTalk can't find a language file to use. Please make sure <code>languages/{$esoTalk->language}.php</code> exists or change the default language by adding <code>\"language\" => \"YourLanguage\",</code> to <code>config/config.php</code>."); } // Include the skin file. require "config/skin.php"; if (file_exists("skins/{$config["skin"]}/skin.php")) { include_once "skins/{$config["skin"]}/skin.php"; } if (class_exists($config["skin"])) { $esoTalk->skin = new $config["skin"](); $esoTalk->skin->esoTalk =& $esoTalk; $esoTalk->skin->init(); } // If we haven't got a working skin, show an error! if (empty($esoTalk->skin)) { $esoTalk->fatalError("esoTalk can't find a skin file to use. Please make sure <code>skins/{$config["skin"]}/skin.php</code> exists or change the default skin in <code>config/skin.php</code>."); } // Load plugins, which will hook on to controllers. require "config/plugins.php"; foreach ($config["loadedPlugins"] as $v) { $v = sanitizeFileName($v); if (file_exists("plugins/{$v}/plugin.php")) { include_once "plugins/{$v}/plugin.php"; } if (class_exists($v)) { $esoTalk->plugins[$v] = new $v(); $esoTalk->plugins[$v]->esoTalk =& $esoTalk; } }
/** * Basic php file upload function, used for unsupported browsers. * The output on success/failure is very basic, and it would be best to have these errors return the user to index.html * with the errors printed on the form, but that is beyond the scope of this project as it is very application specific. * @return string Success or failure of upload */ public function postUnsupported($files) { if (empty($files)) { $files = $_FILES['bigUploadFile']; } if (empty($files)) { return array('errorStatus' => 550, 'errorText' => 'No BigUpload file uploads were specified.'); } $name = sanitizeFileName($files['name']); $size = $files['size']; $tempName = $files['tmp_name']; $fsize = @filesize($tempName); if ($fsize === false) { return array('errorStatus' => 553, 'errorText' => 'File part access error.'); } if ($fsize > config('bigupload.MAX_SIZE')) { return array('errorStatus' => 413, 'errorText' => 'File is too large.'); } $dstPath = $this->getMainDirectory() . $name; if (@move_uploaded_file($tempName, $dstPath)) { return array('errorStatus' => 0, 'fileName' => $dstName, 'errorText' => 'File uploaded.'); } else { return array('errorStatus' => 405, 'errorText' => 'There was an error uploading the file to "' . $dstPath . '".'); } }
/** * Load a language and its definition files, depending on what plugins are enabled. * * @param string $language The name of the language. * @return void */ public static function loadLanguage($language = "") { // Clear the currently loaded definitions. self::$definitions = array(); // If the specified language doesn't exist, use the default language. self::$language = file_exists(PATH_LANGUAGES . "/" . sanitizeFileName($language) . "/definitions.php") ? $language : C("esoTalk.language"); // Load the main definitions file. $languagePath = PATH_LANGUAGES . "/" . sanitizeFileName(self::$language); self::loadDefinitions("{$languagePath}/definitions.php"); // Loop through the loaded plugins and include their definition files, if they exist. foreach (C("esoTalk.enabledPlugins") as $plugin) { if (file_exists($file = "{$languagePath}/definitions." . sanitizeFileName($plugin) . ".php")) { self::loadDefinitions($file); } } }