Autor Zpráva
svitko
Profil *
Vedel by niekto upravit tento script, tak aby spracoval aj specialne znaky.
Ide o to ze takto ako to je mi nechce zobrazovat spravne mena hracou ktory maju v mene specialne znaky.

gsquery.php
<?php


/*
* gsQuery - Querys game servers
* Copyright (c) 2002-2004 Jeremias Reith <jr@terragate.net>
* http://www.gsquery.org
*
* This file is part of the gsQuery library.
*
* The gsQuery library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* The gsQuery library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with the gsQuery library; if not, write to the
* Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*/

/**
* @mainpage gsQuery
* @htmlinclude readme.html
*/

/**
* @example small_example.php
* This is a simple example of how to use gsQuery
*/

/**
* @example example_usage.php
* This is a detailed example of how to use gsQuery
*/

/**
* @brief Abstract gsQuery base class
* @author Jeremias Reith (jr@terragate.net)
* @version $Id: gsQuery.php,v 1.27 2004/05/24 15:22:06 jr Exp $
*
* <p>The gsQuery package has one class for each protocol or game.
* This class is abstract but due to the lack of real OO
* capabilities it cannot be declared as abstract.
* Use the static method createInstance to create a gsQuery object
* that supports the specified protocol.</p>
*
* Generic usage:
* <pre>
* // including gsQuery
* include_once("path/to/gsQuery/gsQuery.php");
*
* // create a gsQuery instance
* $gameserver = gsQuery::createInstance("gameSpy", "myserver.com", 1234)
*
* // query the server
* $status = $gameserver->query_server();
*
* // check for success
* if($status) {
* // process retrieved data
* } else {
* // create an error message
* }
* </pre>
*/
class gsQuery
{

// public members you can access

/** @brief The version of the gsQuery package */
var $version;

/** @brief The scorelimit of the game */
var $scorelimit;

/** @brief The name of team 1 */
var $team1;

/** @brief The name of team 2 */
var $team2;

/** @brief The # of players on team 1 */
var $teamcnt1;

/** @brief The # of players on team 2 */
var $teamcnt2;

/** @brief The team 1 score*/
var $teamscore1;

/** @brief The team 2 score*/
var $teamscore2;

/** @brief The # of players spectating */
var $spec;

/** @brief ip or hostname of the server */
var $address;

/** @brief port to use for the query */
var $queryport;

/**
* @brief status of the server
*
* TRUE: server online, FALSE: server offline
*/
var $online;

/** @brief the name of the game */
var $gamename;

/** @brief the port you have to connect to enter the game */
var $hostport;

/** @brief the version of the game */
var $gameversion;

/** @brief The title of the server */
var $servertitle;

/** @brief The name of the map (often corresponds with the filename of the map)*/
var $mapname;

/** @brief A more descriptive name of the map */
var $maptitle;

/** @brief The gametype */
var $gametype;

/** @brief current number of players on the server */
var $numplayers;

/** @brief maximum number of players allowed on the server */
var $maxplayers;

/**
* @brief Wheather the game server is password protected
*
* 1: server is password protected<br>
* 0: server is not password protected<br>
* -1: unknown
*/
var $password;

/** @brief next map on the server */
var $nextmap;

/**
* @brief players playing on the server
* @see playerkeys
*
* Hash with player ids as key.
* The containing value will be another hash with the infos of the player.
* To access a player name use <code>players[$playerid]["name"]</code>.
* Check playerkeys to get the keys available
*/
var $players;

/**
* @brief Hash of available player infos
*
* There is a key for each player info available (e.g. name, score, ping etc).
* The value is TRUE if the info is available
*/
var $playerkeys;

/** @brief list of the team names */
var $playerteams;

/** @brief a list of all maps in cycle */
var $maplist;

/**
* @brief Hash with all server rules
*
* key: rulename<br>
* value: rulevalue
*/
var $rules;

/** @brief Short errormessage if something goes wrong */
var $errstr;

/**
* @brief Hash with debug infos
*
* Key: What we did / send<br>
* Value: Result / Error message
*
*/
var $debug;

/**
* @brief Standard constructor
*
* @param address address of the server to query
* @param queryport the queryport of the server
*/
function gsQuery($address, $queryport)
{
$this->version = ereg_replace("[^0-9\\.]", "", "\$Revision: 1.27 $");

$this->address = $address;
$this->queryport = $queryport;

$this->online = FALSE;
$this->gamename = "";
$this->hostport = 0;
$this->gameversion = "";
$this->servertitle = "";
$this->hostport = "";
$this->mapname = "";
$this->maptitle = "";
$this->gametype = "";
$this->numplayers = 0;
$this->maxplayers = 0;
$this->password = -1;
$this->nextmap="";
$this->scorelimit =0;
$this->team1 = "Team 1";
$this->team2 = "Team 2";
$this->teamcnt1 = 0;
$this->teamcnt2 = 0;
$this->spec = 0;

$this->players = array();
$this->playerkeys = array();
$this->playerteams = array();
$this->maplist = array();
$this->rules = array();
$this->debug = array();

$this->errstr="";
}

/**
* @brief Creates a new gsQuery object that supports the given protocol
*
* This static method will create an instance of the appropriate subclass
* for you.
*
* @param protocol the protocol you need
* @param address the address of the game server
* @param port the queryport of the game server
* @return a gsQuery object that supports the specified protocol
*
*/
function createInstance($protocol, $address, $port) {
global $libpath;
// including the required class and create an instance of it
switch($protocol) {
// some aliases might be useful
case("gsqp"):
include_once($libpath."gameSpy.php");
return new gameSpy($address, $port);
case("gsqp2"):
include_once($libpath."gameSpy2.php");
return new gameSpy2($address, $port);
case "halflife":
include_once($libpath."hlife.php");
return new hlife($address, $port);
case "q3a":
include_once($libpath."q3a.php");
return new q3a($address, $port);
case "ravenshield":
include_once($libpath."rvnshld.php");
return new rvnshld($address, $port);
default:
// we should be careful when using eval with supplied arguments
// e.g.: $port="123); system(\"some nasty stuff\")";
// normally this should be assured by the caller, but we are in reality
if(ereg("^[A-Za-z0-9_-]+$", $protocol) && ereg("^[A-Za-z0-9\\.-]+$", $address) && is_numeric($port)) {
include_once($libpath.$protocol .".php");
return eval("return new $protocol(\"$address\", $port);");
} else {
return FALSE;
}
}
}

/**
* @brief Creates an instance out of an previously serialized string
*
* Use this to restore a object that has been previously serialized with
* serialize
*
* @param string serialized gsQuery object
* @return the deserialized object
*/
function unserialize($string)
{
// extracting class name
$string=ltrim($string);
$length = strlen($string);
for($i=0;$i<$length;$i++) {
if($string[$i] == ":") {
break;
}
}

$className = substr($string, 0, $i);

// we should be careful when using eval with supplied arguments
if(ereg("^[A-Za-z0-9_-]+$", $className)) {
include_once($className .".php");
return unserialize(base64_decode(substr($string, $i+1)));
} else {
return FALSE;
}
}

/**
* @brief Retrieves a serialized object via HTTP and deserializes it
*
* Useful if UDP traffic isn't allowed
*
* @param url the UR
svitko
Profil *
ulozto.sk/3181958/gsquery.rar

Vaše odpověď

Mohlo by se hodit


Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm: