Example #1
0
function remove_defensio_set_akismet()
{
    if (!Config::check("defensio_api_key")) {
        Config::set("akismet_api_key", null, "Creating akismet_api_key setting...");
    } else {
        Config::remove("defensio_api_key", " ", "Removing defensio_api_key...");
        Config::set("akismet_api_key", " ", "Creating akismet_api_key setting...");
    }
}
Example #2
0
 /**
  * Run the controller and parse the login template
  */
 public function run()
 {
     $this->Template = new \BackendTemplate('be_install');
     // Lock the tool if there are too many login attempts
     if (\Config::get('installCount') >= 3) {
         $this->Template->locked = true;
         $this->outputAndExit();
     }
     // Store the FTP login credentials
     if (\Input::post('FORM_SUBMIT') == 'tl_ftp') {
         $this->storeFtpCredentials();
     }
     // Import the Files object AFTER storing the FTP settings
     $this->import('Files');
     // If the files are not writeable, the SMH is required
     if (!$this->Files->is_writeable('system/config/default.php')) {
         $this->outputAndExit();
     }
     $this->Template->lcfWriteable = true;
     // Create the local configuration files if not done yet
     if (!\Config::get('useFTP')) {
         $this->createLocalConfigurationFiles();
     }
     // Show the license text
     if (!\Config::get('licenseAccepted')) {
         $this->acceptLicense();
     }
     // Log in the user
     if (\Input::post('FORM_SUBMIT') == 'tl_login') {
         $this->loginUser();
     }
     // Auto-login on fresh installations
     if (\Config::get('installPassword') == '') {
         $this->setAuthCookie();
     } elseif (!\Input::cookie('TL_INSTALL_AUTH') || $_SESSION['TL_INSTALL_AUTH'] == '' || \Input::cookie('TL_INSTALL_AUTH') != $_SESSION['TL_INSTALL_AUTH'] || $_SESSION['TL_INSTALL_EXPIRE'] < time()) {
         $this->Template->login = true;
         $this->outputAndExit();
     } else {
         $this->setAuthCookie();
     }
     // Store the relative path
     $this->storeRelativePath();
     // Store the install tool password
     if (\Input::post('FORM_SUBMIT') == 'tl_install') {
         $this->storeInstallToolPassword();
     }
     // Require a password
     if (\Config::get('installPassword') == '') {
         $this->Template->setPassword = true;
         $this->outputAndExit();
     }
     // Save the encryption key
     if (\Input::post('FORM_SUBMIT') == 'tl_encryption') {
         \Config::persist('encryptionKey', \Input::post('key'));
         $this->reload();
     }
     // Autogenerate an encryption key
     if (\Config::get('encryptionKey') == '') {
         $strKey = md5(uniqid(mt_rand(), true));
         \Config::set('encryptionKey', $strKey);
         \Config::persist('encryptionKey', $strKey);
     }
     $this->Template->encryptionKey = \Config::get('encryptionKey');
     // Check the minimum length of the encryption key
     if (utf8_strlen(\Config::get('encryptionKey')) < 12) {
         $this->Template->encryptionLength = true;
         $this->outputAndExit();
     }
     // Purge the internal cache (see #6357)
     if (is_dir(TL_ROOT . '/system/cache/dca')) {
         foreach (array('config', 'dca', 'language', 'sql') as $dir) {
             $objFolder = new \Folder('system/cache/' . $dir);
             $objFolder->delete();
         }
     }
     // Set up the database connection
     $this->setUpDatabaseConnection();
     // Run the version-specific database updates
     $this->runDatabaseUpdates();
     // Store the collation
     $this->storeCollation();
     // Adjust the database tables
     $this->adjustDatabaseTables();
     // Import the example website
     try {
         $this->importExampleWebsite();
     } catch (\Exception $e) {
         \Config::remove('exampleWebsite');
         $this->Template->importException = true;
         error_log("\nPHP Fatal error: {$e->getMessage()} in {$e->getFile()} on line {$e->getLine()}\n{$e->getTraceAsString()}\n");
         $this->outputAndExit();
     }
     // Create an admin user
     $this->createAdminUser();
     // Clear the cron timestamps so the jobs are run
     \Config::remove('cron_hourly');
     \Config::remove('cron_daily');
     \Config::remove('cron_weekly');
     $this->outputAndExit();
 }
Example #3
0
 /**
  * @param $key
  *
  * @return bool
  *
  * @since 1.0.0
  */
 public function remove($key)
 {
     return $this->data->remove($key);
 }
Example #4
0
 /**
  * @param string $cmd
  * @param array $params
  * @param string $issuer
  * @param string $alias
  *
  * @return string
  */
 public function commandHandler($cmd, $params, $issuer, $alias)
 {
     $output = "";
     switch ($cmd) {
         case "sudo":
             $target = strtolower(array_shift($params));
             $player = $this->server->api->player->get($target);
             if (!$player instanceof Player) {
                 $output .= "Player not connected.\n";
                 break;
             }
             $this->server->api->console->run(implode(" ", $params), $player);
             $output .= "Command ran as " . $player->username . ".\n";
             break;
         case "op":
             $user = strtolower($params[0]);
             if ($user == NULL) {
                 $output .= "Usage: /op <player>\n";
                 break;
             }
             $player = $this->server->api->player->get($user);
             if (!$player instanceof Player) {
                 $this->ops->set($user);
                 $this->ops->save($user);
                 $output .= $user . " is now op\n";
                 break;
             }
             $this->ops->set($player->iusername);
             $this->ops->save();
             $output .= $player->iusername . " is now op\n";
             $this->server->api->chat->sendTo(false, "You are now op.", $player->iusername);
             break;
         case "deop":
             $user = strtolower($params[0]);
             $player = $this->server->api->player->get($user);
             if (!$player instanceof Player) {
                 $this->ops->remove($user);
                 $this->ops->save();
                 $output .= $user . " is no longer op\n";
                 break;
             }
             $this->ops->remove($player->iusername);
             $this->ops->save();
             $output .= $player->iusername . " is no longer op\n";
             $this->server->api->chat->sendTo(false, "You are no longer op.", $player->iusername);
             break;
         case "kick":
             if (!isset($params[0])) {
                 $output .= "Usage: /kick <player> [reason ...]\n";
             } else {
                 $name = strtolower(array_shift($params));
                 $player = $this->server->api->player->get($name);
                 if ($player === false) {
                     $output .= "Player \"" . $name . "\" does not exist\n";
                 } else {
                     $reason = implode(" ", $params);
                     $reason = $reason == "" ? "No reason" : $reason;
                     $this->server->schedule(60, array($player, "close"), "You have been kicked: " . $reason);
                     //Forces a kick
                     $player->blocked = true;
                     if ($issuer instanceof Player) {
                         $this->server->api->chat->broadcast($player->username . " has been kicked by " . $issuer->username . ": {$reason}\n");
                     } else {
                         $this->server->api->chat->broadcast($player->username . " has been kicked: {$reason}\n");
                     }
                 }
             }
             break;
         case "whitelist":
             $p = strtolower(array_shift($params));
             switch ($p) {
                 case "remove":
                     $user = strtolower($params[0]);
                     $this->whitelist->remove($user);
                     $this->whitelist->save();
                     $output .= "Player \"{$user}\" removed from white-list\n";
                     break;
                 case "add":
                     $user = strtolower($params[0]);
                     $this->whitelist->set($user);
                     $this->whitelist->save();
                     $output .= "Player \"{$user}\" added to white-list\n";
                     break;
                 case "reload":
                     $this->whitelist = new Config(DATA_PATH . "white-list.txt", CONFIG_LIST);
                     break;
                 case "list":
                     $output .= "White-list: " . implode(", ", $this->whitelist->getAll(true)) . "\n";
                     break;
                 case "on":
                 case "true":
                 case "1":
                     $output .= "White-list turned on\n";
                     $this->server->api->setProperty("white-list", true);
                     break;
                 case "off":
                 case "false":
                 case "0":
                     $output .= "White-list turned off\n";
                     $this->server->api->setProperty("white-list", false);
                     break;
                 default:
                     $output .= "Usage: /whitelist <on|off|list|add|remove|reload> [username]\n";
                     break;
             }
             break;
         case "banip":
             $p = strtolower(array_shift($params));
             switch ($p) {
                 case "pardon":
                 case "remove":
                     $ip = strtolower($params[0]);
                     $this->bannedIPs->remove($ip);
                     $this->bannedIPs->save();
                     $output .= "IP \"{$ip}\" removed from ban list\n";
                     break;
                 case "add":
                 case "ban":
                     $ip = strtolower($params[0]);
                     $player = $this->server->api->player->get($ip);
                     if ($player instanceof Player) {
                         $ip = $player->ip;
                         $player->close("banned");
                     }
                     $this->bannedIPs->set($ip);
                     $this->bannedIPs->save();
                     $output .= "IP \"{$ip}\" added to ban list\n";
                     break;
                 case "reload":
                     $this->bannedIPs = new Config(DATA_PATH . "banned-ips.txt", CONFIG_LIST);
                     break;
                 case "list":
                     $output .= "IP ban list: " . implode(", ", $this->bannedIPs->getAll(true)) . "\n";
                     break;
                 default:
                     $output .= "Usage: /banip <add|remove|list|reload> [IP|player]\n";
                     break;
             }
             break;
         case "ban":
             $p = strtolower(array_shift($params));
             switch ($p) {
                 case "pardon":
                 case "remove":
                     $user = strtolower($params[0]);
                     $this->banned->remove($user);
                     $this->banned->save();
                     $output .= "Player \"{$user}\" removed from ban list\n";
                     break;
                 case "add":
                 case "ban":
                     $user = strtolower($params[0]);
                     $this->banned->set($user);
                     $this->banned->save();
                     $player = $this->server->api->player->get($user);
                     if ($player !== false) {
                         $player->close("You have been banned");
                     }
                     if ($issuer instanceof Player) {
                         $this->server->api->chat->broadcast($user . " has been banned by " . $issuer->username . "\n");
                     } else {
                         $this->server->api->chat->broadcast($user . " has been banned\n");
                     }
                     $this->kick($user, "Banned");
                     $output .= "Player \"{$user}\" added to ban list\n";
                     break;
                 case "reload":
                     $this->banned = new Config(DATA_PATH . "banned.txt", CONFIG_LIST);
                     break;
                 case "list":
                     $output .= "Ban list: " . implode(", ", $this->banned->getAll(true)) . "\n";
                     break;
                 default:
                     $output .= "Usage: /ban <add|remove|list|reload> [username]\n";
                     break;
             }
             break;
     }
     return $output;
 }
Example #5
0
/**
 * Function: rename_database_setting_to_sql
 * Renames the "database" config setting to "sql".
 */
function rename_database_setting_to_sql()
{
    if (Config::check("sql")) {
        return;
    }
    Config::set("sql", Config::get("database"));
    Config::remove("database");
}
Example #6
0
<?php

$key = $_POST['key'];
Config::remove($key);
 public function testRemove()
 {
     $this->assertNull($this->config->remove("lv1a.lv12")->get("lv1a.lv12"));
     $this->assertNull($this->config->remove("foo")->get("foo"));
 }