function DBinit($log_script = 'default') { global $link, $config; if ($link) { return; } loadTool('databaseInterface.class.php', 'database/'); loadTool('statementInterface.class.php', 'database/'); if ($config['db_driver'] != 'pdo') { loadTool('mysqlDriverBase.class.php', 'database/'); loadTool('mysqlDriverStm.class.php', 'database/'); } loadTool('module.class.php', 'database/' . $config['db_driver'] . '/'); loadTool('statement.class.php', 'database/' . $config['db_driver'] . '/'); $class = $config['db_driver'] . 'Driver'; $link = new $class(); try { if (!empty($config['db_file'])) { $link->connect(array('file' => $config['db_file'])); } else { $link->connect(array('host' => $config['db_host'], 'port' => $config['db_port'], 'login' => $config['db_login'], 'password' => $config['db_passw'], 'db' => $config['db_name'])); } } catch (Exception $e) { exit($e->getMessage()); } if ($log_script and $config['action_log']) { ActionLog($log_script); } CanAccess(2); }
function ShowSkin($mini = false, $name = false, $isFemale = false, $saveBuffer = false) { global $site_ways; loadTool('skin.class.php'); if ($isFemale !== false) { $cloak = false; $skin = MCRAFT . 'tmp/skin_buffer/default/Char' . ($isFemale ? '_female' : '') . '.png'; $buffer = MCRAFT . 'tmp/skin_buffer/default/Char' . ($mini ? '_Mini' : '') . ($isFemale ? '_female' : '') . '.png'; } elseif ($name) { $skin = MCRAFT . $site_ways['skins'] . $name . ($isFemale ? '_female' : '') . '.png'; $cloak = MCRAFT . $site_ways['cloaks'] . $name . '.png'; $buffer = MCRAFT . 'tmp/skin_buffer/' . $name . ($mini ? '_Mini' : '') . '.png'; } else { exit; } if (file_exists($buffer)) { readfile($buffer); exit; } elseif ($saveBuffer) { $image = $mini ? SkinViewer2D::saveHead($buffer, $skin) : SkinViewer2D::savePreview($buffer, $skin, $cloak); } else { $image = $mini ? SkinViewer2D::createHead($skin) : SkinViewer2D::createPreview($skin, $cloak); } if ($image) { imagepng($image); } }
public function ShowAdminForm() { global $bd_names, $config; $info = $this->answer; if (isset($_POST['sp_config_set'])) { $bd_skins = InputGet('bd_skins', 'POST', 'str'); $bd_bad_skins = InputGet('bd_bad_skins', 'POST', 'str'); $bd_skins_ratio = InputGet('bd_skins_ratio', 'POST', 'str'); $rebuild_items = InputGet('rebuild_items', 'POST', 'bool'); $find_items = InputGet('find_items', 'POST', 'bool'); $sp_offline = InputGet('sp_offline', 'POST', 'bool'); $sp_upload = InputGet('sp_upload', 'POST', 'bool'); $config['sp_online'] = $sp_offline ? false : true; $config['sp_upload'] = $sp_upload; if ($bd_skins) { if (!self::BD_CheckExist($bd_skins, 'fname')) { $this->answer .= 'Таблица не найдена ( ' . $bd_skins . ' ) <br />'; } else { $bd_names['sp_skins'] = $bd_skins; } } if ($bd_bad_skins) { if (!self::BD_CheckExist($bd_bad_skins, 'hash')) { $this->answer .= 'Таблица не найдена ( ' . $bd_bad_skins . ' ) <br />'; } else { $bd_names['sp_bad_skins'] = $bd_bad_skins; } } if ($bd_skins_ratio) { if (!self::BD_CheckExist($bd_skins_ratio, 'num')) { $this->answer .= 'Таблица не найдена ( ' . $bd_skins_ratio . ' ) <br />'; } else { $bd_names['sp_skins_ratio'] = $bd_skins_ratio; } } if ($bd_skins or $bd_bad_skins or $bd_skins_ratio) { $this->answer .= 'Настройки изменены <br />'; } loadTool('alist.class.php'); if (!MainConfig::SaveOptions()) { $this->answer .= 'Ошибка применения настроек <br />'; } if ($find_items) { $this->FindNewSkins(); } if ($rebuild_items) { $this->RebuildAll(); } $info = $this->answer; } ob_start(); include $this->GetView('admin/constants.html'); return ob_get_clean(); }
<?php require '../system.php'; $login = Filter::input('user', 'get'); $serverid = Filter::input('serverId', 'get'); $sessionid = Filter::input('sessionId', 'get'); if (empty($sessionid) or empty($serverid) or empty($login)) { vtxtlog("[joinserver.php] join process [GET parameter empty] [ " . (empty($sessionid) ? 'SESSIONID ' : '') . (empty($login) ? 'USER ' : '') . (empty($serverid) ? 'SERVERID ' : '') . "]"); 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'); }
break; } $info .= lng('T_INSTALL_FAIL') . ' - ' . $t_error . '</br>'; } else { loadTool('ajax.php'); $config['s_theme'] = $result['id']; } } */ if ($theme_id === $theme_delete) { ThemeManager::DeleteTheme($theme_delete); } if ($theme_old != $config['s_theme']) { loadTool('ajax.php'); } // headers for prompt refresh cookies $config['s_name'] = $site_name; $config['s_about'] = $site_about; $config['s_keywords'] = $keywords; $config['sbuffer'] = $sbuffer; $config['rewrite'] = $rewrite; $config['log'] = $log; $config['comm_revers'] = $comm_revers; $config['offline'] = $site_offline; $config['smtp'] = $smtp; if (MainConfig::SaveOptions()) { $info .= lng('OPTIONS_COMPLETE'); } else { $info .= lng('WRITE_FAIL') . ' ( ' . MCR_ROOT . 'config.php )';
<?php if (!defined('MCR')) { exit; } loadTool('catalog.class.php'); $category = Filter::input('cid', 'get', 'int'); if ($category) { $news_manager = new NewsManager($category, 'news/', 'index.php?cid=' . $category . '&'); } else { $news_manager = new NewsManager(-1, 'news/'); } /* Default vars */ $page = lng('PAGE_NEWS'); /* Get \ Post options */ $curlist = Filter::input('l', 'get', 'int'); if ($curlist <= 0) { $curlist = 1; } $menu->SetItemActive('main'); $content_main .= $news_manager->ShowNewsListing($curlist); $content_main .= $news_manager->ShowCategorySelect(); $news_manager->destroy(); unset($news_manager);
public function aCreate($message, $fUser, $item_id, $item_type) { global $ajax_message, $config; if ($this->id) { return 0; } $this->parent_id = (int) $item_id; $this->parent_type = (int) $item_type; if (!$this->initParent()) { aExit(2, lng('MESS_NOT_FOUND')); } loadTool('ajax.php'); if (!$fUser->id()) { aExit(1, lng('MESS_FAIL')); } if (!$fUser->canPostComment()) { aExit(1, lng('MESS_TIMEOUT')); } $rcode = $this->Create($message, $fUser->id(), $item_id, $item_type); if ($rcode == 1701) { aExit(1, lng('MESS_SHORT')); } elseif ($rcode == 1702 or $rcode == 1703) { aExit(2, lng('MESS_NOT_FOUND')); } elseif ($rcode == 1) { $ajax_message['comment_html'] = $this->Show($fUser); $ajax_message['comment_revers'] = $config['comm_revers']; $fUser->setStatistic('comments_num', 1); aExit(0, lng('MESS_COMPLITE')); } else { aExit(3, lng('MESS_FAIL')); } }
public function ShowById($id, $list = 1) { $mode_txt = 'Отдельный образ'; $gender_txt = lng('NOT_SET'); $skins = ''; $skins_count = 1; $skin = new SPItem($id, $this->st_subdir); if (!$skin->Exist()) { $html_skin_list = 'Скин удален'; } else { $skins = $skin->Show(false, $full_info = true); ob_start(); include $this->GetView('skin_container.html'); $html_skin_list = ob_get_clean(); if ($this->discus) { loadTool('comment.class.php'); $comments = new CommentList($skin, $this->base_url . '&cid=' . $id, 'news/comments/'); $html_skin_list .= $comments->Show($list); $html_skin_list .= $comments->ShowAddForm(); } } ob_start(); include $this->GetView('main.html'); return ob_get_clean(); }
$comments_item = new Comments_Item($id); if (!$user->getPermission('adm_comm') and $comments_item->GetAuthorID() != $user->id()) { aExit(1); } if ($comments_item->Delete()) { aExit(0); } else { aExit(1); } break; case 'load_info': $id = Filter::input('id', 'post', 'int'); if (!$id) { aExit(1, 'Empty POST param ID'); } loadTool('profile.class.php'); $user_profile = new Profile($id, 'other/'); $ajax_message['player_info'] = $user_profile->Show(); aExit(0); break; case 'profile': $ajax_message = array('code' => 0, 'message' => 'profile', 'name' => '', 'group' => '', 'id' => '', 'skin' => 0, 'cloak' => 0, 'skin_link' => '?none'); $rcodes = null; if (empty($user) or $user->lvl() <= 0) { aExit(1); } $mod_user = $user; $user_id = Filter::input('user_id', 'post', 'int'); if ($user_id and $user->lvl() >= 15) { tokenTool('check'); $mod_user = new User($user_id);
<?php if (!defined('MCR')) { exit; } ob_start(); if (!empty($user)) { if ($mode == 'control') { include View::Get('side.html', 'admin/'); } include View::Get('mini_profile.html'); } else { if ($mode == 'register') { $addition_events .= "BlockVisible('reg-box',true); BlockVisible('login-box',false);"; } include View::Get('login.html'); } $content_side .= ob_get_clean(); loadTool('monitoring.class.php'); $servManager = new ServerManager('serverstate/'); $content_servers = $servManager->Show('side'); unset($servManager);
public function Delete() { global $user, $bd_names; if (empty($user) or !$user->getPermission('add_news') or !$this->Exist()) { return false; } $result = getDB()->ask("SELECT `id` FROM `{$bd_names['comments']}` " . "WHERE `item_id`='" . $this->id . "' AND `item_type` = '" . $this->type() . "'"); loadTool('comment.class.php'); while ($line = $result->fetch('num')) { $comments_item = new Comments_Item($line[0], false); $comments_item->Delete(); unset($comments_item); } getDB()->ask("DELETE FROM `{$bd_names['likes']}` " . "WHERE `item_id` = '" . $this->id . "' AND `item_type` = '" . $this->type() . "'"); return parent::Delete(); }
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)); } }
public function Delete() { global $bd_users, $bd_names; if (!$this->id) { return false; } loadTool('catalog.class.php'); $this->deleteCloak(); $this->deleteSkin(); $this->deleteBuffer(); $result = getDB()->ask("SELECT `id` FROM `{$bd_names['comments']}` " . "WHERE `user_id`='{$this->id}'"); while ($line = $result->fetch('num')) { $comment_del = new Comments_Item($line[0]); $comment_del->Delete(); unset($comment_del); } getDB()->ask("DELETE FROM `{$this->db}` WHERE `{$bd_users['id']}`= '{$this->id}'"); $this->id = false; return true; }