예제 #1
0
파일: admin.php 프로젝트: qexyorg/webMCR-1
         }
         sqlConfigSet('email-name', $email_name);
         sqlConfigSet('email-mail', $email_mail);
         if ($config['smtp']) {
             $smtp_user = Filter::input('smtp_user');
             $smtp_pass = Filter::input('smtp_pass');
             $smtp_host = Filter::input('smtp_host');
             $smtp_port = Filter::input('smtp_port', 'post', 'int');
             $smtp_hello = Filter::input('smtp_hello');
             sqlConfigSet('smtp-user', $smtp_user);
             if ($smtp_pass != '**defined**') {
                 sqlConfigSet('smtp-pass', $smtp_pass);
             }
             sqlConfigSet('smtp-host', $smtp_host);
             sqlConfigSet('smtp-port', $smtp_port);
             sqlConfigSet('smtp-hello', $smtp_hello);
         }
         if ($email_test && !EMail::Send($email_test, 'Mail test', 'Content')) {
             $info .= '<br>' . lng('OPTIONS_MAIL_TEST_FAIL');
         }
     }
     $theme_manager = new ThemeManager(false, 'index.php?mode=control&');
     $theme_selector = $theme_manager->ShowThemeSelector();
     include View::Get('constants.html', $st_subdir);
     break;
 case 'profile':
     if (!$ban_user) {
         break;
     }
     tokenTool('set');
     $group_list = GroupManager::GetList($ban_user->group());
예제 #2
0
 public function UpdateState($extra = false)
 {
     global $config;
     if (!$extra and !$this->IsTimeToUpdate() or !$this->Exist()) {
         return;
     }
     $this->online = false;
     $users_list = NULL;
     if (empty($this->address)) {
         getDB()->ask("UPDATE `" . $this->db . "` SET `online`='0',`last_update`=NOW() WHERE `id`='" . $this->id . "'");
         return;
     }
     getDB()->ask("UPDATE `" . $this->db . "` SET `last_update`=NOW() WHERE `id`='" . $this->id . "'");
     switch ($this->method) {
         case 2:
             // RCON Connect
             loadTool('rcon.class.php');
             try {
                 $rcon = new MinecraftRcon();
                 $rcon->Connect($this->address, $this->port, $this->rcon);
                 $str = $rcon->Command('list');
             } catch (MinecraftRconException $e) {
                 if ($e->getMessage() == 'Server offline') {
                     getDB()->ask("UPDATE `" . $this->db . "` SET `online`='0' WHERE `id`='" . $this->id . "'");
                     return;
                 }
             }
             $str = str_replace(array("\r\n", "\n", "\r"), '', $str);
             $names = explode(', ', substr($str, 19));
             if (!empty($names)) {
                 for ($i = 0; $i < sizeof($names); $i++) {
                     trim($names[$i]);
                 }
             }
             if (!$names[0] == '') {
                 $users_list = $names;
             }
             break;
         case 3:
             // json-api
             loadTool('json_api.php', 'bukkit/');
             $salt = sqlConfigGet('json-verification-salt');
             if (!$salt) {
                 $salt = md5(rand(1000000000, 2147483647) . rand(1000000000, 2147483647));
                 sqlConfigSet('json-verification-salt', $salt);
             }
             if (!extension_loaded("cURL")) {
                 vtxtlog('[monitoring.class.php] cURL module is required');
                 return;
             }
             $api = new JSONAPI($this->address, $this->port, $this->s_user, $this->rcon, $salt);
             // ToDo rewrite / delete . curl is custom module
             $apiresult = $api->call(array("getPlayerLimit", "getPlayerCount"), array(NULL, NULL));
             if (!$apiresult) {
                 getDB()->ask("UPDATE `" . $this->db . "` SET `online`='0' WHERE `id`='" . $this->id . "'");
                 return;
             }
             $full_state = array('numpl' => $apiresult["success"][1]["success"], 'maxplayers' => $apiresult["success"][0]["success"]);
             break;
         default:
             // query, simple query
             loadTool('query.function.php');
             $full_state = $this->method == 1 ? mcraftQuery($this->address, $this->port) : mcraftQuery_SE($this->address, $this->port);
             if (empty($full_state) or isset($full_state['too_many'])) {
                 getDB()->ask("UPDATE `" . $this->db . "` " . "SET `online`='" . (isset($full_state['too_many']) ? '1' : '0') . "' " . "WHERE `id`='" . $this->id . "'");
                 $this->online = isset($full_state['too_many']) ? true : false;
                 return;
             } elseif (!empty($full_state['players'])) {
                 $users_list = $full_state['players'];
             }
             break;
     }
     $this->online = true;
     $system_users = '';
     $numpl = !empty($full_state['numpl']) ? $full_state['numpl'] : 0;
     if ($users_list) {
         $numpl = sizeof($users_list);
         if ($numpl == 1) {
             $system_users = $users_list[0];
         } else {
             for ($i = 0; $i < $numpl; $i++) {
                 $system_users .= $i == 0 ? $users_list[$i] : ',' . $users_list[$i];
             }
         }
     }
     $this->slots = !empty($full_state) ? $full_state['maxplayers'] : -1;
     $this->numpl = $numpl;
     if (!empty($full_state)) {
         $sql = "UPDATE `" . $this->db . "` SET `numpl`=:numpl, slots=:slots, players=:players, online='1' " . "WHERE `id`='" . $this->id . "'";
         getDB()->ask($sql, array('numpl' => $this->numpl, 'slots' => $this->slots, 'players' => $system_users));
     } else {
         $sql = "UPDATE `" . $this->db . "` SET `numpl`=:numpl, slots='-1', players=:players, online='1' " . "WHERE `id`='{$this->id}'";
         getDB()->ask($sql, array('numpl' => $this->numpl, 'players' => $system_users));
     }
 }
예제 #3
0
}
$rcon_port = Filter::input('port', 'post', 'int');
if (empty($rcon_port)) {
    $rcon_port = (int) sqlConfigGet('rcon-port');
}
$rcon_pass = Filter::input('pass');
if (empty($rcon_pass)) {
    $rcon_pass = sqlConfigGet('rcon-pass');
}
/* Sync or drop config */
if (Filter::input('save', 'post', 'bool')) {
    sqlConfigSet('rcon-serv', $game_server);
    sqlConfigSet('rcon-pass', $rcon_pass);
    sqlConfigSet('rcon-port', $rcon_port);
} else {
    sqlConfigSet('rcon-serv', 0);
}
try {
    $rcon = new MinecraftRcon();
    $rcon->Connect($game_server, $rcon_port, $rcon_pass);
    if ($userlist) {
        $page = GetUserListHTML($rcon->Command('list'));
        exit("<script>'.{$token}.'parent.GetById('users_online').innerHTML = '" . $page[0] . "'; " . $page[1] . "</script>");
    }
    $command = str_replace(array("\r\n", "\n", "\r"), '', $command);
    $command = preg_replace('| +|', ' ', $command);
    $str = trim(TextBase::HTMLDestruct($rcon->Command($command)));
    $str = str_replace(array("\r\n", "\n", "\r"), '', $str);
    if (!strncmp($command, 'say', 3) and strlen($str) > 2) {
        $str = substr($str, 2);
    }
예제 #4
0
 public function getVerificationStr()
 {
     if (!$this->id) {
         return false;
     }
     $salt = sqlConfigGet('email-verification-salt');
     if (!$salt) {
         $salt = randString();
         sqlConfigSet('email-verification-salt', $salt);
     }
     return md5($this->id() . $salt);
 }