예제 #1
7
 public static function getInfo()
 {
     /*
       Using SourceQuery class by xPaw
       to get the server info.
       
       https://github.com/xPaw/PHP-Source-Query-Class/
     */
     require './class/SourceQuery/SourceQuery.class.php';
     require './settings.php';
     $query = new SourceQuery();
     try {
         $query->Connect($server['ip'], $server['port'], 1, SourceQuery::SOURCE);
         $info = $query->GetInfo();
     } catch (Exception $e) {
         return array('error' => 'Server connection failed');
     }
     $result = array();
     $result['ip'] = $server['ip'] . ':' . $server['port'];
     $result['players'] = $info['Players'];
     $result['maxplayers'] = $info['MaxPlayers'];
     $result['map'] = $info['Map'];
     if ($server['name']) {
         $result['name'] = $server['name'];
     } else {
         $result['name'] = $info['HostName'];
     }
     return $result;
 }
예제 #2
1
	  ga('create', 'UA-25646959-3', 'auto');
	  ga('send', 'pageview');

	</script>
	</head>
<body>
<?php 
error_reporting(-1);
require __DIR__ . '/SourceQuery/SourceQuery.class.php';
define('SQ_SERVER_ADDR', '37.187.170.178');
//zero one
define('SQ_SERVER_PORT', 2303);
define('SQ_TIMEOUT', 1);
define('SQ_ENGINE', SourceQuery::SOURCE);
$Query = new SourceQuery();
try {
    $Query->Connect(SQ_SERVER_ADDR, SQ_SERVER_PORT, SQ_TIMEOUT, SQ_ENGINE);
    $players_online = $Query->GetInfo()['Players'];
    $arma_online = true;
    $playerlist = $Query->GetPlayers();
    /*
    echo '<pre>';
    //print_r( $Query->GetInfo( ) );
    echo print_r($playerlist['0']['Name']);
    echo '</pre>';
    echo $playerlist;
    */
} catch (Exception $e) {
    echo $e->getMessage();
}
예제 #3
1
function getServerInfo($ip, $port, $translation)
{
    $SQ_SERVER_ADDR = $ip;
    $SQ_SERVER_PORT = $port;
    $SQ_TIMEOUT = 5;
    $SQ_ENGINE = SourceQuery::SOURCE;
    $Query = new SourceQuery();
    $connect = $translation['table_headers']['connect'];
    $nick = $translation['table_headers']['nick'];
    $score = $translation['table_headers']['score'];
    $time = $translation['table_headers']['time'];
    try {
        $Query->Connect($SQ_SERVER_ADDR, $SQ_SERVER_PORT, $SQ_TIMEOUT, $SQ_ENGINE);
        $ip = $SQ_SERVER_ADDR . ':' . $SQ_SERVER_PORT;
        $server_info = $Query->GetInfo();
        if ($server_info !== false) {
            $server_name = $server_info['HostName'];
            $server_map = $server_info['Map'];
            $server_port = $server_info['GamePort'];
            $server_max = $server_info['MaxPlayers'];
            $server_players = $server_info['Players'];
            $players = $Query->GetPlayers();
            $result = '<tr  class="server"  data-key="' . $server_info['ServerID'] . '" data-game-folder="csgo">
    <td class="icon"><img src="./..//images/games/csgo.png" alt="Counter-Strike: Global Offensive" title="Counter-Strike: Global Offensive"></td>
    <td class="ServerQuery_VAC icon"><img src="./../images/secure.png" alt="Valve Anti-Cheat"></td>
    <td class="ServerQuery_hostname">';
            $result .= '<a href="steam://connect/' . $ip . '" title="';
            $result .= $connect;
            $result .= '">';
            $result .= $server_name;
            $result .= '</a>';
            $result .= '</td>
    <td class="ServerQuery_players">';
            $result .= $server_players . '/' . $server_max;
            $result .= '</td>
    <td class="ServerQuery_map">';
            $result .= $server_map;
            $result .= '</td>
</tr>';
            $result .= '<tr class="section" id="server-section-' . $server_info['ServerID'] . '">
    <td colspan="6">
        <div>
            <table class="table table-condensed table-hover pull-left" style="max-width: 430px">
                <thead>
                <tr>
                    <th>';
            $result .= $nick;
            $result .= '</th>
                    <th class="nowrap text-right">';
            $result .= $score;
            $result .= '</th>
                    <th class="nowrap">';
            $result .= $time;
            $result .= '</th>
                </tr>
                </thead>
                <tbody>';
            foreach ($players as $player) {
                if ($player['Name'] !== '') {
                    $result .= '<tr class="player" >
                    <td>';
                    $result .= $player['Name'];
                    $result .= '</td>
                    <td class="text-right">';
                    $result .= $player['Frags'];
                    $result .= '</td>
                    <td class="nowrap text-right">';
                    $result .= $player['TimeF'];
                    $result .= '</td></tr>';
                }
            }
            $result .= '</tbody>
            </table>
            <div class="pull-right">';
            if (@getimagesize('http://ezpz.cz/images/maps/csgo/' . $server_map . '.jpg') === false) {
                $result .= '<img alt="' . $server_map . '" class="map-image img-rounded" width="340px" height="255px"
                           src="./../images/maps/unknown.jpg">';
            } else {
                $result .= '<img alt="' . $server_map . '" class="map-image img-rounded" width="340px" height="255px"
                           src="./../images/maps/csgo/' . $server_map . '.jpg">';
            }
            $result .= '<div class="well text-center"><p>' . $ip . '</p>
                    <a class="btn btn-success" href="steam://connect/' . $ip . '">';
            $result .= $connect;
            $result .= '</a>

                </div>
            </div>
        </div>
    </td>
</tr>';
        }
    } catch (Exception $e) {
        $result .= $e;
    }
    return $result;
}
 public function post(Request $request, Application $app)
 {
     $sourceQuery = new \SourceQuery();
     try {
         $ip = $request->get('serverIp');
         $port = $request->get('port');
         $appId = $request->get('appid');
         $sourceQuery->Connect($ip, $port, 1, $appId);
         $result = array('success' => true, 'data' => array('info' => $sourceQuery->GetInfo(), 'players' => $sourceQuery->GetPlayers()));
         $result['success'] = is_array($result['data']['info']) && is_array($result['data']['players']);
         return new JsonResponse($result);
     } catch (\Exception $e) {
         return new JsonResponse(array('success' => FALSE, 'message' => $e->getMessage()));
     }
     $sourceQuery->Disconnect();
 }
예제 #5
0
/**
 *	@author João Reis
 *	@return array
 */
function _getStatus()
{
    global $_ip, $_portaQuery, $_objQuery;
    // Objeto para Query's
    $_objQuery = new SourceQuery();
    try {
        // Conectar-se ao servidor
        $_objQuery->Connect($_ip, $_portaQuery, 1, SourceQuery::GOLDSOURCE);
        #print_r($_objQuery);
        $Info = array();
        $Jogadores = array();
        $Regras = array();
        // Retornar Plugins neste caso sao Regras
        $_Regras = $_objQuery->GetRules();
        // Retornar lista de Jogadores
        $Jogadores = $_objQuery->GetPlayers();
        // Retornar Informação do servidor.
        $Info = $_objQuery->GetInfo();
        $_MapaAtual = $Info['Map'];
        $_SlotsUsados = $Info['Players'];
        $_MaxSlots = $Info['MaxPlayers'];
        $_Versao = $Info['Version'];
        // Passar lista de jogadores recebida em algo Global para que o painel perceba.
        $JogadoresJ = array();
        if (count($Jogadores) > 0 && $Info != null) {
            foreach ($Jogadores as $Jogador) {
                $JogadoresJ[] = utf8_encode($Jogador["Name"]);
            }
        }
        $_Jogadores = $JogadoresJ;
        $_Plugins = $Regras;
    } catch (Exception $e) {
        $_MapaAtual = ".....";
        $_SlotsUsados = ".....";
        $_MaxSlots = ".....";
        $_Versao = "1.0.0";
    }
    return array("Map" => $_MapaAtual, "Players" => $_SlotsUsados, "MaxPlayers" => $_MaxSlots, "Playerlist" => $_Jogadores, "Plugins" => $_Regras, "Versao" => $_Versao);
}
예제 #6
0
                <th><?php 
echo $S_Players;
?>
</th>
              </tr>
            </thead>
            <tbody>
            	<?php 
// Select Bans
$SelectServers = $db->query("SELECT * FROM `servers`");
// Print Output
foreach ($SelectServers as $PrintServers) {
    // Query Server
    define('SQ_TIMEOUT', 1);
    define('SQ_ENGINE', SourceQuery::SOURCE);
    $ServerQuery = new SourceQuery();
    $ServerInfo = array();
    $ServerPlayers = array();
    try {
        $ServerQuery->Connect($PrintServers['IPAddress'], $PrintServers['Port'], SQ_TIMEOUT, SQ_ENGINE);
        $ServerInfo = $ServerQuery->GetInfo();
        $ServerPlayers = $ServerQuery->GetPlayers();
    } catch (Exception $e) {
        echo "Something went wrong try again later!";
    }
    $ServerQuery->Disconnect();
    echo "\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td><b>" . $PrintServers['ServerID'] . "</b></td>\n\t\t\t\t\t\t\t\t<td><a href='steam://connect/" . $PrintServers['IPAddress'] . ":" . $PrintServers['Port'] . "'>" . $PrintServers['IPAddress'] . ":" . $PrintServers['Port'] . "</a></td>\n\t\t\t\t\t\t\t\t<td>" . $PrintServers['HostName'] . "</td>\n\t\t\t\t\t\t\t\t<td>" . htmlspecialchars($ServerInfo['ModDesc']) . "</td>\n\t\t\t\t\t\t\t\t<td>" . htmlspecialchars($ServerInfo['Map']) . "</td>\n\t\t\t\t\t\t\t\t<td>" . htmlspecialchars($ServerInfo['Players']) . " / " . htmlspecialchars($ServerInfo['MaxPlayers']) . "</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t";
}
?>
            </tbody>
        </table>
예제 #7
0
<?php

require 'steamauth/steamauth.php';
if (!isset($_SESSION['authed'])) {
    header("Location: steamauth/logout.php?noadmin");
    die;
}
if (!isset($_POST['cmd']) and !isset($_POST['token'])) {
    die("Don't mess with this, buddy.");
}
require 'SourceQuery/SourceQuery.class.php';
$squery = new SourceQuery();
require 'config.php';
$squery->connect($server_ip, $server_port, 3, SourceQuery::SOURCE);
function rcon()
{
    // NOPE
}
if ($_POST["cmd"] == "kickall") {
    rcon("kick *");
    echo "All players kicked.";
} elseif ($_POST["cmd"] == "lock") {
    rcon("lock");
    echo "Server has been locked.";
} elseif ($_POST["cmd"] == "unlock") {
    rcon("unlock");
    echo "Server has been unlocked.";
} elseif ($_POST["cmd"] == "restart") {
    rcon("restart");
    echo "Server is restarting...";
} elseif ($_POST["cmd"] == "quit") {
예제 #8
0
<?php

ob_clean();
if ($_GET['cmd'] == "logout") {
    session_destroy();
    exit("<br>" . yes("You are logged out!"));
}
try {
    $Query = new SourceQuery();
    $Query->Connect($_SESSION['s'], $_SESSION['port'], SQ_TIMEOUT, SQ_ENGINE);
    $Query->setRconPassword($_SESSION['p']);
    $r = $Query->Rcon(trim($_GET['cmd']));
    $dictionary = array('§9' => '<span class="text-primary">', '§c' => '<span class="text-danger">', '§a' => '<span class="text-success">', '§0' => '', '§o' => '<span style="font-style:italic">', "\n" => '</br>', '§r' => '</span>');
    $r = str_replace(array_keys($dictionary), $dictionary, $r);
    exit($r);
} catch (Exception $e) {
    echo fail($e->getMessage());
}
예제 #9
0
// Try connecting to the DB
try {
    $pdo = new PDO('mysql:host=' . DB_HOST . ';port=' . DB_PORT . ';dbname=' . DB_NAME . ';charset=utf8', DB_USER, DB_PASS);
} catch (PDOException $e) {
    http_response_code(500);
}
if ($pdo) {
    $stmt = $pdo->prepare('SELECT * FROM kzstats_server');
    if ($stmt->execute()) {
        $results = $stmt->fetchAll(2);
        foreach ($results as $result) {
            $ip = $result['ip'];
            $port = $result['port'];
            $tick = $result['tick'];
            $countrycode = $result['countrycode'];
            $query = new SourceQuery();
            // Try connecting to the server
            try {
                $query->Connect($ip, $port, 1, SourceQuery::SOURCE);
                $info = $query->GetInfo();
            } catch (Exception $e) {
                continue;
            }
            // Check if query actually returned something
            if (!$info['HostName']) {
                continue;
            }
            // freegeoip.net API query for countrycode
            if (!$countrycode || $countrycode == null) {
                $countrydata = json_decode(file_get_contents('https://freegeoip.net/json/' . $ip));
                if ($countrydata->country_code) {
예제 #10
0
<?php

require 'steamauth/steamauth.php';
if (!isset($_SESSION['authed'])) {
    header("Location: steamauth/logout.php?noadmin");
    die;
}
require 'SourceQuery/SourceQuery.class.php';
$squery = new SourceQuery();
require 'config.php';
$squery->connect($server_ip, $server_port + 1, 3, SourceQuery::SOURCE);
$sdata = $squery->GetInfo();
$on_players = $squery->GetPlayers();
$connection = mysqli_connect($db_ip, $db_user, $db_pass, $db_name);
$plys = mysqli_query($connection, "SELECT * FROM players");
$c_cash = 0;
$c_bank = 0;
$c_ply = 0;
$c_med = 0;
$c_cop = 0;
$c_civ = 0;
$c_vehc = 0;
$c_vehc_active = 0;
$c_gangs = 0;
$c_plys_in_gang = 0;
$c_g_mstmembrs = 0;
$c_gang_mny = 0;
$g_biggest = "None";
while ($row = mysqli_fetch_row($plys)) {
    $c_cash += $row[3];
    $c_bank += $row[4];
예제 #11
0
        $Query->Connect(SQ_SERVER_ADDR, SQ_SERVER_PORT, SQ_TIMEOUT, SQ_ENGINE);
        $Query->SetRconPassword(SQ_SERVER_PASSWORD);
        var_dump($Query->Rcon('say hello'));
    } catch (Exception $e) {
        echo $e->getMessage();
    }
    $Query->Disconnect();
}
if (isset($_GET["IP"])) {
    require __DIR__ . '/SourceQuery/SourceQuery.class.php';
    define('SQ_TIMEOUT', 1);
    define('SQ_ENGINE', SourceQuery::SOURCE);
    $serverIp = $_GET["IP"];
    $serverPort = $_GET["Port"];
    $Timer = MicroTime(true);
    $Query = new SourceQuery();
    $Info = array();
    $Rules = array();
    $Players = array();
    try {
        $Query->Connect($serverIp, $serverPort, SQ_TIMEOUT, SQ_ENGINE);
        //$Query->SetRconPassword( SQ_RCON_Pass );
        $Info = $Query->GetInfo();
        $Players = $Query->GetPlayers();
        $Rules = $Query->GetRules();
    } catch (Exception $e) {
        $Exception = $e;
    }
    $Query->Disconnect();
    $Timer = Number_Format(MicroTime(true) - $Timer, 4, '.', '');
}
예제 #12
0
    $interval = date_diff($create, $end1);
    $days = (int) $interval->format("%a");
    $end = strtotime($end);
    $sql = $dbh->query("UPDATE `amx_amxadmins` SET `expired` = '{$end}' WHERE  `steamid` = '" . $row['steamid'] . "'");
    if (!$sql) {
        die("Произошла ошибка, обновите страницу и попробуйте обратиться к администратору.");
    }
}
//Удаляем всю инфу о бане (bid прописывается в password)
if ($type == 5) {
    $sql = $dbh->query("DELETE FROM `amx_bans` WHERE `bid` = '" . $row['pasword'] . "'");
    $sql = $dbh->query("DELETE FROM `amx_bans_edit` WHERE `bid` = '" . $row['pasword'] . "'");
    $sql = $dbh->query("DELETE FROM `amx_bans_log` WHERE `bid` = '" . $row['pasword'] . "'");
}
//Посылаем amx_reloadadmins спасибо xPaw
//Пока заглушка на unban чтобы не было ошибки
if ($type != 5) {
    $sql_server = $dbh->query("SELECT `address` FROM `amx_serverinfo` WHERE `id` = '{$server_id}'");
    if ($sql_server && ($row_server = $sql_server->fetch())) {
        $row_server = $sql_server->fetch();
        $address = explode(":", $row_server['address']);
        $Query = new SourceQuery();
        $Query->Connect($address[0], $address[1], $address[1], SourceQuery::GOLDSOURCE);
        $Query->SetRconPassword($rcon);
        $Query->Rcon($cmd);
        $Query->Disconnect();
    }
}
$f = @fopen("order.txt", "a+") or die("error");
fputs($f, "order_num :{$inv_id};Summ :{$out_summ};Date :{$date}\n");
fclose($f);
예제 #13
0
<div class="container">
      <form class="form-signin" role="form" action="/rcon/index.php" method="POST">
        <h2 class="form-signin-heading">Web RCON</h2>
<?php 
if (!empty($_POST)) {
    if (empty($_POST['s']) || empty($_POST['p']) || empty($_POST['port'])) {
        echo fail("All fields are required.");
    } else {
        try {
            $Query = new SourceQuery();
            $Query->Connect($_POST['s'], $_POST['port'], SQ_TIMEOUT, SQ_ENGINE);
            $Query->setRconPassword($_POST['p']);
            $_SESSION['s'] = $_POST['s'];
            $_SESSION['p'] = $_POST['p'];
            $_SESSION['port'] = $_POST['port'];
            header("Location: http://mcpe.me/rcon/index.php");
        } catch (Exception $e) {
            echo fail($e->getMessage());
        }
    }
}
?>
        <input type="text" class="form-control" placeholder="Hostname"  autofocus="" name="s" required="">
        <input type="text" class="form-control" placeholder="Port" required="" value="19132" name="port">
        <input type="password" class="form-control" placeholder="Password" required="" name="p">
        <button class="btn btn-lg btn-primary btn-block" type="submit">Connect Now</button>
      </form>

    </div>
예제 #14
0
<?php

require __DIR__ . '/SourceQuery/SourceQuery.class.php';
// For the sake of this example
Header('Content-Type: text/plain');
Header('X-Content-Type-Options: nosniff');
// Edit this ->
define('SQ_SERVER_ADDR', 'localhost');
define('SQ_SERVER_PORT', 27015);
define('SQ_TIMEOUT', 1);
define('SQ_ENGINE', SourceQuery::SOURCE);
// Edit this <-
$Query = new SourceQuery();
try {
    $Query->Connect(SQ_SERVER_ADDR, SQ_SERVER_PORT, SQ_TIMEOUT, SQ_ENGINE);
    print_r($Query->GetInfo());
    print_r($Query->GetPlayers());
    print_r($Query->GetRules());
} catch (Exception $e) {
    echo $e->getMessage();
}
$Query->Disconnect();
예제 #15
0
<?php

require __DIR__ . '/SourceQuery/SourceQuery.class.php';
// For the sake of this example
Header('Content-Type: text/plain');
Header('X-Content-Type-Options: nosniff');
// Edit this ->
define('SQ_SERVER_ADDR', 'localhost');
define('SQ_SERVER_PORT', 27015);
define('SQ_TIMEOUT', 1);
define('SQ_ENGINE', SourceQuery::SOURCE);
// Edit this <-
$Query = new SourceQuery();
try {
    $Query->Connect(SQ_SERVER_ADDR, SQ_SERVER_PORT, SQ_TIMEOUT, SQ_ENGINE);
    $Query->SetRconPassword('my_awesome_password');
    var_dump($Query->Rcon('say hello'));
} catch (Exception $e) {
    echo $e->getMessage();
}
$Query->Disconnect();
예제 #16
0
<?php

require __DIR__ . '/SourceQuery/SourceQuery.class.php';
// Edit this ->
define('SQ_SERVER_ADDR', 'localhost');
define('SQ_SERVER_PORT', 27015);
define('SQ_TIMEOUT', 1);
define('SQ_ENGINE', SourceQuery::SOURCE);
// Edit this <-
$Timer = MicroTime(true);
$Query = new SourceQuery();
$Info = array();
$Rules = array();
$Players = array();
try {
    $Query->Connect(SQ_SERVER_ADDR, SQ_SERVER_PORT, SQ_TIMEOUT, SQ_ENGINE);
    $Info = $Query->GetInfo();
    $Players = $Query->GetPlayers();
    $Rules = $Query->GetRules();
} catch (Exception $e) {
    $Exception = $e;
}
$Query->Disconnect();
$Timer = Number_Format(MicroTime(true) - $Timer, 4, '.', '');
?>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>Source Query PHP Class</title>
	
예제 #17
0
                            <strong>Players</strong>
                        </td>
                    </tr>
                </table>
                <?php 
$query = "SELECT * FROM servers";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {
    ?>
                <?php 
    $ip = $row['IPAddress'];
    $port = $row['Port'];
    define('SQ_TIMEOUT', 1);
    define('SQ_ENGINE', SourceQuery::SOURCE);
    $Timer = MicroTime(true);
    $Query = new SourceQuery();
    $Info = array();
    $Rules = array();
    $Players = array();
    try {
        $Query->Connect($ip, $port, SQ_TIMEOUT, SQ_ENGINE);
        $Info = $Query->GetInfo();
        $Players = $Query->GetPlayers();
    } catch (Exception $e) {
        $Exception = $e;
    }
    $Query->Disconnect();
    ?>
 
                <table width="100%" class="status" border="0">
                    <tr>