Пример #1
0
 public function servers($reload = false)
 {
     if ($reload or !$this->servers_cache) {
         $gametype = mysql_real_escape_string($this->gametype);
         $this->servers_cache = GameServer::find_all("gameservers.gametype = '{$gametype}'");
     }
     return $this->servers_cache;
 }
 protected static function load_gameserver($id = null)
 {
     if (!$id) {
         $id = $_GET['id'];
     }
     $server = GameServer::find_by_id($id);
     if ($server) {
         return $server;
     } else {
         Error404();
     }
 }
 protected function load_gameserver($id = null)
 {
     if (!$id) {
         $id = $_GET['id'];
     }
     $id = mysql_real_escape_string($id);
     $server = GameServer::find_by_id($id);
     if ($server && $server->online) {
         return $server;
     }
     Error404();
 }
 /**
  * @param InetAddress $serverIP
  * @param int $portNumber The listening port of the server, defaults to 27015
  */
 public function __construct(InetAddress $ipAddress, $portNumber = 27015, $isHLTV = false)
 {
     parent::__construct($portNumber);
     $this->socket = new GoldSrcSocket($ipAddress, $portNumber, $isHLTV);
 }
Пример #5
0
 /**
  * @param InetAddress $serverIP
  * @param int $portNumber The listening port of the server, defaults to 27015
  */
 public function __construct(InetAddress $ipAddress, $portNumber = 27015)
 {
     parent::__construct($portNumber);
     $this->rconSocket = new RCONSocket($ipAddress, $portNumber);
     $this->socket = new SourceSocket($ipAddress, $portNumber);
 }
Пример #6
0
 public static function load_from_row($row, $recurse_limit = 1, $current_level = 0)
 {
     // When PHP 5.3.0 is in, we can shift this over too and just redefine it
     // if needed (eg. loading child objects)
     $class = __CLASS__;
     $object = new $class();
     $fields = self::fields_array();
     $fields[] = array("created_at", "datetime");
     $fields[] = array("updated_at", "datetime");
     $fields[] = array("deleted", "bool");
     foreach ($fields as $field) {
         $property = $field[0];
         if (isset($field[2])) {
             $property = $field[2];
         }
         if (isset($row[self::table . ".{$field[0]}"])) {
             if ($field[1] == "datetime") {
                 $object->{$property} = strtotime($row[self::table . ".{$field[0]}"]);
             } else {
                 $object->{$property} = $row[self::table . ".{$field[0]}"];
             }
         } else {
             $object->{$property} = null;
         }
     }
     $object->is_new = false;
     // Load child objects here
     if ($current_level < $recurse_limit) {
         $current_level++;
         $object->server = GameServer::load_from_row($row, $recurse_limit, $current_level);
     }
     return $object;
 }
 public function handleResponseForRequest($request, $repeatOnFailure = true)
 {
     parent::handleResponseForRequest($request, $repeatOnFailure);
 }
 public function sendRequest(Packets\SteamPacket $packet)
 {
     parent::sendRequest($packet);
 }
Пример #9
0
<?php

require "init.php";
$script = Script::find_by_code('gameservers');
$script->start();
ob_start();
$time = date("H:i:s");
echo "[{$time}] Updating Game Servers\r\n\r\n";
$servers = GameServer::find_all();
foreach ($servers as $server) {
    echo " * Updating [{$server}]\r\n";
    $server->update_stats();
}
$script = Script::find_by_code('gameservers');
$output = ob_get_clean();
$script->finish($output);
 /**
  * Creates a new instance of a GoldSrc server object
  *
  * @param string $address Either an IP address, a DNS name or one of them
  *        combined with the port number. If a port number is given, e.g.
  *        'server.example.com:27016' it will override the second argument.
  * @param int $port The port the server is listening on
  * @param bool $isHLTV HLTV servers need special treatment, so this is used
  *        to determine if the server is a HLTV server
  * @throws SteamCondenserException if an host name cannot be resolved
  */
 public function __construct($address, $port = 27015, $isHLTV = false)
 {
     parent::__construct($address, $port);
     $this->isHLTV = $isHLTV;
 }
Пример #11
0
#!/php -q
<?php 
// Signal management
declare (ticks=1);
pcntl_signal(SIGTERM, "signal_handler");
pcntl_signal(SIGINT, "signal_handler");
function signal_handler($signal)
{
    switch ($signal) {
        case SIGTERM:
            print "Caught SIGTERM\n";
            exit;
        case SIGINT:
            print "Caught SIGINT\n";
            exit;
        default:
            print "Caught signal {$signal}\n ";
            exit;
    }
}
// WS Lib
require_once 'vendor/autoload.php';
use Devristo\Phpws\Server\WebSocketServer;
// Custom server
require_once 'includes/classes/ws_gameserver.php';
$gameserver = new GameServer($wsport);
$gameserver->import();
// Will need global object $gameserver
$gameserver->start();