Example #1
0
     }
     if ($new_build) {
         sqlConfigSet('latest-game-build', $new_build);
     }
     if ($new_version_l) {
         sqlConfigSet('launcher-version', $new_version_l);
     }
     if ($link_win or $link_osx or $link_lin or $game_news or $new_build or $new_version_l) {
         if (MainConfig::SaveOptions()) {
             $info .= lng('OPTIONS_COMPLETE');
         } else {
             $info .= lng('WRITE_FAIL') . ' ( ' . MCR_ROOT . 'config.php )';
         }
     }
     $game_lver = sqlConfigGet('launcher-version');
     $game_build = sqlConfigGet('latest-game-build');
     $cat_list = '<option value="-1">' . lng('NEWS_LAST') . '</option>';
     $cat_list .= CategoryManager::GetList($config['game_news']);
     include View::Get('game.html', $st_subdir);
     break;
 case 'category':
     $name = Filter::input('name');
     $priority = Filter::input('lvl', 'post', 'int');
     $desc = Filter::input('desc');
     if (!$id and $name) {
         $new_category = new Category();
         if ($new_category->Create($name, $priority, $desc)) {
             $info .= lng('CAT_COMPLITE');
         } else {
             $info .= lng('CAT_EXIST');
         }
Example #2
0
}
/* Try load connect options */
$game_server = Filter::input('IP');
if (empty($game_server)) {
    $game_server = sqlConfigGet('rcon-serv');
}
if ($game_server == 0) {
    exit('<script>' . $token . 'parent.showResult("rcon unconfigured");</script>');
}
$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>");
Example #3
0
function RefreshBans()
{
    global $bd_names;
    /* Default ban until time */
    getDB()->ask("DELETE FROM {$bd_names['ip_banning']} " . "WHERE (ban_until='0000-00-00 00:00:00') " . "AND (time_start<NOW()-INTERVAL " . (int) sqlConfigGet('next-reg-time') . " HOUR)");
    getDB()->ask("DELETE FROM {$bd_names['ip_banning']} " . "WHERE (ban_until<>'0000-00-00 00:00:00') " . "AND (ban_until<NOW())");
}
Example #4
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));
     }
 }
Example #5
0
    $rcodes[] = 13;
}
if (strcmp($input['pass'], $input['repass'])) {
    $rcodes[] = 9;
}
tryExit();
$verification = (bool) sqlConfigGet('email-verification');
if ($verification) {
    $group = 4;
} else {
    $group = 1;
}
$sql = "INSERT INTO `{$bd_names['users']}` (" . "`{$bd_users['login']}`," . "`{$bd_users['password']}`," . "`{$bd_users['ip']}`," . "`{$bd_users['female']}`," . "`{$bd_users['ctime']}`," . "`{$bd_users['group']}`) VALUES(:login, :pass, :ip, '{$female}', NOW(),'{$group}')";
$result = getDB()->ask($sql, array('login' => $input['login'], 'pass' => MCRAuth::createPass($input['pass']), 'ip' => GetRealIp()));
if (!$result) {
    aExit(14);
}
$tmp_user = new User(getDB()->lastInsertId());
$tmp_user->setDefaultSkin();
$next_reg = (int) sqlConfigGet('next-reg-time');
if ($next_reg > 0) {
    getDB()->ask("INSERT INTO `{$bd_names['ip_banning']}` (`IP`,`time_start`,`ban_until`) " . "VALUES (:ip, NOW(), NOW()+INTERVAL {$next_reg} HOUR)", array('ip' => $_SERVER['REMOTE_ADDR']));
}
if ($tmp_user->changeEmail($input['email'], $verification) > 1) {
    aExit(14, lng('MAIL_FAIL'));
}
if (!$verification) {
    aExit(0, lng('REG_COMPLETE') . '. <a href="#" class="btn" onclick="Login();">' . lng('ENTER') . '</a>');
} else {
    aExit(0, lng('REG_COMPLETE') . '. ' . lng('REG_CONFIRM_INFO'));
}
Example #6
0
    exit($output);
}
$login = Filter::input('user');
$password = Filter::input('password');
$ver = Filter::input('version');
if (empty($password) or empty($ver) or empty($login)) {
    logExit("[auth.php] login process [Empty input] [ " . (empty($login) ? 'LOGIN ' : '') . (empty($password) ? 'PASSWORD ' : '') . (empty($ver) ? 'VER ' : '') . "]");
}
loadTool('user.class.php');
DBinit('auth');
if (!preg_match("/^[a-zA-Z0-9_-]+\$/", $login) or !preg_match("/^[a-zA-Z0-9_-]+\$/", $password) or !preg_match("/^[0-9]+\$/", $ver)) {
    logExit("[auth.php] login process [Bad symbols] User [{$login}] Password [{$password}] Ver [{$ver}]");
}
if ((int) sqlConfigGet('launcher-version') != (int) $ver) {
    logExit("[auth.php] login process [Old version] ver " . $ver, "Old version");
}
$auth_user = new User($login, $bd_users['login']);
if (!$auth_user->id()) {
    logExit("[auth.php] login process [Unknown user] User [{$login}] Password [{$password}]");
}
if ($auth_user->lvl() <= 1) {
    exit("Bad login");
}
if (!$auth_user->authenticate($password)) {
    logExit("[auth.php] login process [Wrong password] User [{$login}] Password [{$password}]");
}
$sessid = generateSessionId();
getDB()->ask("UPDATE `{$bd_names['users']}` SET " . "`{$bd_users['session']}`=:session " . "WHERE `{$bd_users['login']}`=:login", array('session' => $sessid, 'login' => $login));
vtxtlog("[auth.php] login process [Success] User [{$login}] Session [{$sessid}]");
exit(sqlConfigGet('latest-game-build') . ':' . md5($auth_user->name()) . ':' . $auth_user->name() . ':' . $sessid . ':');
Example #7
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);
 }
Example #8
0
 private static function smtpmail($mail_to, $subject, $message, $headers)
 {
     $smtp_user = sqlConfigGet('smtp-user');
     $smtp_pass = sqlConfigGet('smtp-pass');
     $smtp_host = sqlConfigGet('smtp-host');
     $smtp_port = (int) sqlConfigGet('smtp-port');
     $smtp_hello = sqlConfigGet('smtp-hello');
     $send = "Date: " . date("D, d M Y H:i:s") . " UT\r\n";
     $send .= "Subject: {$subject}\r\n";
     $send .= $headers . "\r\n\r\n" . $message . "\r\n";
     if (!($socket = @fsockopen($smtp_host, $smtp_port, $errno, $errstr, 10))) {
         vtxtlog('[SMPT] ' . $errno . " | " . $errstr);
         return false;
     }
     stream_set_timeout($socket, 10);
     if (!self::server_action($socket, false, "220") or !self::server_action($socket, $smtp_hello . " " . $smtp_host . "\r\n", "250", 'Приветствие сервера недоступно')) {
         return false;
     }
     if (!empty($smtp_user)) {
         if (!self::server_action($socket, "AUTH LOGIN\r\n", "334", 'Нет ответа авторизации') or !self::server_action($socket, base64_encode($smtp_user) . "\r\n", "334", 'Неверный логин авторизации') or !self::server_action($socket, base64_encode($smtp_pass) . "\r\n", "235", 'Неверный пароль авторизации')) {
             return false;
         }
     }
     if (!self::server_action($socket, "MAIL FROM: <" . $smtp_user . ">\r\n", "250", 'Ошибка MAIL FROM') or !self::server_action($socket, "RCPT TO: <" . $mail_to . ">\r\n", "250", 'Ошибка RCPT TO') or !self::server_action($socket, "DATA\r\n", "354", 'Ошибка DATA') or !self::server_action($socket, $send . "\r\n.\r\n", "250", 'Ошибка сообщения')) {
         return false;
     }
     self::server_action($socket, "QUIT\r\n");
     return true;
 }