public function log($error)
 {
     $this->lastError = $error;
     if (function_exists('vtxtlog')) {
         vtxtlog($this->lastError);
     }
 }
 public function Rebuild()
 {
     $skin_way = $this->base_dir . $this->fname;
     $preview_way = $this->base_dir . 'preview/' . $this->fname;
     if (!file_exists($skin_way)) {
         $this->Delete();
         vtxtlog('[Rebuild][skinGenerator2D] SPItem ID ' . $this->id . ' not founded - delete');
         return false;
     }
     if (file_exists($preview_way)) {
         unlink($preview_way);
     }
     $skin_ratio = skinGenerator2D::isValidSkin($skin_way);
     if (!$skin_ratio) {
         $this->Delete();
         vtxtlog('[Rebuild][skinGenerator2D] SPItem ID ' . $this->id . ' wrong skin format - delete');
         return false;
     }
     if (!skinGenerator2D::savePreview($preview_way, $skin_way, false, false, 160)) {
         $this->Delete();
         vtxtlog('[Rebuild][skinGenerator2D] Fail to create preview for SPItem ID ' . $this->id);
         return false;
     }
     if (!file_exists($preview_way)) {
         vtxtlog('[Rebuild][skinGenerator2D] Fail to save preview for SPItem ID ' . $this->id);
     }
     BD("LOCK TABLES `{$this->db_ratio}` WRITE;");
     BD("INSERT INTO `{$this->db_ratio}` (ratio) VALUES ('" . (int) $skin_ratio . "') ON DUPLICATE KEY UPDATE `num`= num + 1;");
     BD("UNLOCK TABLES;");
     if ($this->ratio != $skin_ratio) {
         BD("UPDATE `{$this->db}` SET `ratio` = '" . $skin_ratio . "' WHERE `id`='" . $this->id . "'");
         $this->ratio = $skin_ratio;
     }
 }
Example #3
0
    exit('Bad login');
}
loadTool('user.class.php');
DBinit('joinserver');
$sessionidv16 = explode(":", $sessionid);
if ($sessionidv16[0] == "token" && $sessionidv16[2] == "2") {
    $sessionid = $sessionidv16[1];
}
if (!preg_match("/^[a-zA-Z0-9_-]+\$/", $login) or !preg_match("/^[0-9]+\$/", $sessionid) or !preg_match("/^[a-z0-9_-]+\$/", $serverid)) {
    vtxtlog("[joinserver.php] error while login process [input login " . $login . " sessionid " . $sessionid . " serverid " . $serverid . "]");
    exit('Bad login');
}
$tmp_user = new User($login, $bd_users['login']);
if ($tmp_user->id() === false or $tmp_user->name() !== $login) {
    vtxtlog("[joinserver.php] Bad login register");
    exit('Bad login');
}
$sql = "SELECT COUNT(*) FROM `{$bd_names['users']}` " . "WHERE `{$bd_users['session']}`=:session " . "AND `{$bd_users['login']}`=:login " . "AND `{$bd_users['server']}`=:server";
$result = getDB()->fetchRow($sql, array('session' => $sessionid, 'login' => $tmp_user->name(), 'server' => $serverid), 'num');
if ((int) $result[0] == 1) {
    vtxtlog('[joinserver.php] join Server [Result] Relogin OK');
    exit('OK');
}
$sql = "UPDATE `{$bd_names['users']}` SET `{$bd_users['server']}`=:server " . "WHERE `{$bd_users['session']}`=:session " . "AND `{$bd_users['login']}`=:login ";
$result = getDB()->ask($sql, array('session' => $sessionid, 'login' => $tmp_user->name(), 'server' => $serverid));
if ($result->rowCount() == 1) {
    vtxtlog('[joinserver.php] join Server [Result] login OK');
    exit('OK');
}
vtxtlog("[joinserver.php] join Server [Result] Bad Login - input Session [{$sessionid}] User [{$login}] Server [{$serverid}]");
exit('Bad login');
Example #4
0
 public static function DownloadTInstaller($theme_id)
 {
     $theme_info = self::GetThemeInfo($theme_id);
     if ($theme_info === false) {
         return false;
     }
     self::SaveThemeInfo($theme_id, $theme_info);
     $tmp_base_dir = MCRAFT . self::tmp_dir;
     $tmp_fname = tmp_name($tmp_base_dir);
     $tmp_file = $tmp_base_dir . $tmp_fname;
     if (!file_put_contents($tmp_file, base64_decode('UEsFBgAAAAAAAAAAAAAAAAAAAAAAAA=='))) {
         return false;
     }
     // some windows servers fail to create by ZipArchive module
     $zip = new ZipArchive();
     $zip_error = $zip->open($tmp_file, ZipArchive::OVERWRITE);
     if ($zip_error !== true) {
         vtxtlog('Cant create zip : error code: ' . $zip_error);
         return false;
     }
     $result = self::addFolderToZip(self::GetThemeDir($theme_id), self::GetThemeDir($theme_id), $zip);
     if ($result === false) {
         return false;
     }
     $zip->close();
     $fsize = filesize($tmp_file);
     if ($fsize === false) {
         return false;
     }
     if (round($fsize / 1048576) > 50) {
         unlink($tmp_file);
         return false;
     }
     $out_name = urlencode('mcr_' . $theme_id . '.zip');
     header('Content-Type:application/zip;name=' . $out_name);
     header('Content-Transfer-Encoding:binary');
     header('Content-Length:' . $fsize);
     header('Content-Disposition:attachment;filename=' . $out_name);
     header('Expires:0');
     header('Cache-Control:no-cache, must-revalidate');
     header('Pragma:no-cache');
     readfile($tmp_file);
     unlink($tmp_file);
 }
Example #5
0
function logExit($text, $output = "Bad login")
{
    vtxtlog($text);
    exit($output);
}
Example #6
0
 public static function checkPass($data)
 {
     global $bd_names, $bd_users;
     self::start();
     $db = XenForo_Application::get('db');
     $XFauthLogic = self::getXFHashCheckLogic();
     if ($XFauthLogic == 2) {
         $auth = new XenForo_Authentication_Core12();
     } elseif ($XFauthLogic == 1) {
         $auth = new XenForo_Authentication_Core();
     } else {
         vtxtlog('[xenforo.php] xenForo auth class not founded');
         return false;
     }
     $res = $db->fetchCol("SELECT `data` FROM `{$bd_names['user_auth']}` WHERE `{$bd_users['id']}`=" . $data['user_id']);
     if (!count($res)) {
         return false;
     }
     $auth->setData($res[0]);
     if ($auth->authenticate($data['user_id'], $data['pass'])) {
         return true;
     } else {
         return false;
     }
 }
Example #7
0
function POSTSafeMove($post_name, $tmp_dir = false)
{
    if (!POSTGood($post_name, false)) {
        return false;
    }
    if (!$tmp_dir) {
        $tmp_dir = MCRAFT . 'tmp/';
    }
    if (!is_dir($tmp_dir)) {
        $back = umask(0);
        mkdir($tmp_dir, 0775, true);
        umask($back);
    }
    $tmp_file = tmp_name($tmp_dir);
    if (!move_uploaded_file($_FILES[$post_name]['tmp_name'], $tmp_dir . $tmp_file)) {
        vtxtlog('[POSTSafeMove] --> "' . $tmp_dir . '" <-- ' . lng('WRITE_FAIL'));
        return false;
    }
    return array('tmp_name' => $tmp_file, 'name' => $_FILES[$post_name]['name'], 'size_mb' => round($_FILES[$post_name]['size'] / 1024 / 1024, 2));
}
Example #8
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 #9
0
<?php

require '../system.php';
$user = Filter::input('user', 'get');
$serverid = Filter::input('serverId', 'get');
if (empty($user) or empty($serverid)) {
    vtxtlog("[checkserver.php] checkserver process [GET parameter empty] [ " . (empty($user) ? 'LOGIN ' : '') . (empty($serverid) ? 'SERVERID ' : '') . "]");
    exit('NO');
}
loadTool('user.class.php');
DBinit('checkserver');
if (!preg_match("/^[a-zA-Z0-9_-]+\$/", $user) or !preg_match("/^[a-z0-9_-]+\$/", $serverid)) {
    vtxtlog("[checkserver.php] error checkserver process [info login " . $user . " serverid " . $serverid . "]");
    exit('NO');
}
$sql = "SELECT  COUNT(*) FROM {$bd_names['users']} " . "WHERE `{$bd_users['login']}`=:user AND `{$bd_users['server']}`=:serverid";
$result = getDB()->fetchRow($sql, array('user' => $user, 'serverid' => $serverid), 'num');
if ((int) $result[0]) {
    $user_login = new User($user, $bd_users['login']);
    $user_login->gameLoginConfirm();
    vtxtlog("[checkserver.php] Server Test [Success]");
    exit('YES');
}
vtxtlog("[checkserver.php] [User not found] User [{$user}] Server ID [{$serverid}]");
exit('NO');
Example #10
0
 public function changeVisual($post_name, $type = 'skin')
 {
     global $bd_users;
     if (!$this->id or !$this->getPermission($type == 'skin' ? 'change_skin' : 'change_cloak')) {
         return 1605;
     }
     if (!POSTGood($post_name)) {
         return 1604;
     }
     $tmp_dir = MCRAFT . 'tmp/';
     $new_file_info = POSTSafeMove($post_name, $tmp_dir);
     if (!$new_file_info) {
         return 1610;
     }
     $way = $tmp_dir . $new_file_info['tmp_name'];
     if ((int) $this->getPermission('max_fsize') < $new_file_info['size_mb'] * 1024) {
         unlink($way);
         return 1601;
     }
     loadTool('skin.class.php');
     $newImgInfo = $type == 'skin' ? SkinViewer2D::isValidSkin($way) : SkinViewer2D::isValidCloak($way);
     if (!$newImgInfo['scale'] or $newImgInfo['scale'] > (int) $this->getPermission('max_ratio')) {
         unlink($way);
         return 1602;
     }
     $type == 'skin' ? $this->deleteSkin() : $this->deleteCloak();
     $new_way = $type == 'skin' ? $this->getSkinFName() : $this->getCloakFName();
     if (rename($way, $new_way)) {
         chmod($new_way, 0644);
     } else {
         unlink($way);
         vtxtlog('[Ошибка модуля загрузки] Ошибка копирования [' . $way . '] в [' . $new_way . '] . Проверьте доступ на ЧТЕНИЕ \\ ЗАПИСЬ соответствующих папок.');
         return 1611;
     }
     if ($type == 'skin') {
         if (!strcmp($this->defaultSkinMD5(), md5_file($this->getSkinFName()))) {
             $this->defaultSkinTrigger(true);
         } else {
             $this->defaultSkinTrigger(false);
         }
     }
     $this->deleteBuffer();
     getDB()->ask("UPDATE `{$this->db}` SET `undress_times`=`undress_times`+1 " . "WHERE `{$bd_users['id']}`='{$this->id}'");
     return 1;
 }
Example #11
0
 private static function server_action($socket, $command = false, $correct_response = false, $error_mess = false, $line = __LINE__)
 {
     if ($command) {
         fputs($socket, $command);
     }
     if ($correct_response) {
         $server_response = '';
         while (substr($server_response, 3, 1) != ' ') {
             if ($server_response = fgets($socket, 256)) {
                 continue;
             }
             if ($error_mess) {
                 vtxtlog('[SMPT] ' . $error_mess . ' Line: ' . $line);
             }
             return false;
         }
         $code = substr($server_response, 0, 3);
         if ($code == $correct_response) {
             return true;
         }
     }
     if ($error_mess) {
         vtxtlog('[SMPT] ' . $error_mess . ' | Code: ' . $code . ' Line: ' . $line);
     }
     fclose($socket);
     if ($correct_response) {
         return false;
     }
     return true;
 }