/** * searchMapKey() * Search map key * * @param $str str - String * @param $mode str - Gamemode * @return str */ function searchMapKey($str, $mode = 'gpm_sa') { $cmg = new GameMaps(); foreach ($cmg->combos[$mode] as $key) { if (preg_match('/' . strtolower($str) . '/', strtolower($key))) { return $key; break; } elseif (preg_match('/' . strtolower($str) . '/', strtolower($cmg->getMapName($key)))) { return $key; break; } } return false; }
*/ require_once '../core/init.php'; $user->checkLogin(true); // Check his rights if ($userInfo['rights_server'] == 'no') { header('Location: ' . HOME_URL . 'panel/accessDenied.php'); die; } $pageTitle = $lang['tool_mrot']; include CORE_DIR . '/cp_header.php'; // Connect to server use T4G\BFP4F\Rcon as rcon; $rc->connect($cn, $cs); $rc->init(); // Class with maps and gamemodes $cmg = new GameMaps(); $status = ''; // If form is posted if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['rotation']) && isset($_POST['rpm'])) { sleep(2); $errors = array(); // Some checks $maps = array(); $rotation = array(); // Check rotation if (!is_array($_POST['rotation'])) { $errors[] = $lang['tool_mrot_err1']; } else { if (count($_POST['rotation']) == 0) { $errors[] = $lang['tool_mrot_err2']; } else {
/** * voteMap() * Votemap * * @param $cmdInfo - Command info * @return array - Status */ public function voteMap($cmdInfo) { $return = array('code' => 'ERROR', 'message' => ''); if (!$this->checkPollActive()) { if (!empty($cmdInfo['vars']) || $cmdInfo['vars'] != null) { $varsSplit = explode(' ', $cmdInfo['vars'], 2); if (!empty($varsSplit[0])) { $result = searchMapKey($varsSplit[0]); $mode = isset($varsSplit[1]) ? searchGameModeKey($varsSplit[1]) : 'gpm_sa'; if ($result != false) { $mc = new GameMaps(); $mapName = $mc->getMapName($result); $modeName = $mc->getGameMode(searchGameModeKey($mode)); $this->createPoll('cmdVotemapExec', $cmdInfo['origin']['nucleusId'], $cmdInfo['origin']['cdKeyHash'], array('map' => $result, 'map_name' => $mapName, 'gamemode' => searchGameModeKey($mode), 'gamemode_name' => $modeName)); $return['code'] = 'OK'; $this->ct->send('|ccc| Votemap poll created for map ' . $mapName . ' ' . $modeName . '. ' . $this->settings['tool_igcmds_votes'] . ' more votes needed. Type !yes to approve.'); } else { $return['message'] = '|ccc| Map \'' . $varsSplit[0] . '\' was not found!'; } } else { $return['message'] = '|ccc| Please specify a map, parameters: {map} {gamemode}'; } } else { $return['message'] = '|ccc| Please specify a map'; } } else { $return['message'] = '|ccc| There\'s already a poll going on. Please wait until that poll ends...'; } return $return; }
* GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ require_once '../../core/init.php'; use T4G\BFP4F\Rcon as rcon; header('Content-type: application/json'); // Default response template $response = array('status' => 'ERROR', 'msg' => '', 'request_date' => date($settings['cp_date_format_full']), 'last_stream' => date($settings['cp_date_format_full'], $settings['server_last_stream']), 'info' => array(), 'players' => array(), 'chat' => array(), 'igaAdmins' => array()); if ($user->checkLogin()) { // Connect to server if (!$rc->connect($cn, $cs) || !$rc->init()) { $response['msg'] = $lang['msg_serverdown'] . ' ' . date($settings['cp_date_format_full'], $settings['server_last_stream']); } else { $cmg = new GameMaps(); $sv = new rcon\Server(); $pl = new rcon\Players(); $ct = new rcon\Chat(); if ($userInfo['rights_server'] == 'yes') { $response['status'] = 'OK'; $response['info'] = (array) $sv->fetch(); $response['info']['mapName'] = $cmg->getMapName($response['info']['map']); $response['info']['gameModeName'] = $cmg->getGameMode($response['info']['gameMode']); if (isset($_GET['players'])) { $response['players'] = $pl->fetch(); } if (isset($_GET['chat'])) { $response['chat'] = $ct->fetch(); } if (isset($_GET['igaAdmins'])) {