first commit

This commit is contained in:
Erreur32 2021-02-03 16:12:25 +01:00
parent decb273635
commit 21d30b24f2
7 changed files with 174 additions and 12 deletions

View File

@ -27,13 +27,8 @@ $GameQ->setOption('timeout', 5); // seconds
$GameQ->addFilter('normalize');
$results = $GameQ->process();
$expansion_gq = json_encode($results, JSON_INVALID_UTF8_IGNORE | JSON_INVALID_UTF8_SUBSTITUTE | JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR);
echo $expansion_gq;
//$myJSON = json_decode(utf8_encode($results), true);
//echo $expansion_gq['gq_numplayers'];
//echo "<br>";
//print_r($results);
$server_gq = json_encode($results, JSON_INVALID_UTF8_IGNORE | JSON_INVALID_UTF8_SUBSTITUTE | JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR);
echo $server_gq;
?>

66
dayz2json_parser.php Normal file
View File

@ -0,0 +1,66 @@
<?php
include_once('./config.php');
// Don't touch below (or you know what you do)
$urlserv = $ipserv.":".$portserv ;
// librarie SQ - info serv game
require 'SQ_/bootstrap.php';
use xPaw\SourceQuery\SourceQuery;
define( 'SQ_SERVER_ADDR', "${ipserv}" ); // IP server
define( 'SQ_SERVER_PORT', "${queryport}" ); // YOUR QUERY PORT
define( 'SQ_TIMEOUT', 3 );
define( 'SQ_ENGINE', SourceQuery::SOURCE );
$Timer = MicroTime( true );
$Query = new SourceQuery( );
$Info = Array( );
$Players = Array( );
try
{
$Query->Connect( SQ_SERVER_ADDR, SQ_SERVER_PORT, SQ_TIMEOUT, SQ_ENGINE );
$Info = $Query->GetInfo( );
$Players = $Query->GetPlayers( );
}
catch( Exception $e )
{
$Exception = $e;
}
$Query->Disconnect( );
$Timer = Number_Format( MicroTime( true ) - $Timer, 4, '.', '' );
$InfoGT = $Info['GameTags'];
echo $Info['Players'] ;echo "<br>";
echo $Info['MaxPlayers'] ;echo "<br>";
echo $Info['MaxPlayers'] ;echo "<br>";
echo $Info['MaxPlayers'] ;echo "<br>";
echo $Info['MaxPlayers'] ;echo "<br>";
echo $Info['MaxPlayers'] ;echo "<br>";
echo $Info['MaxPlayers'] ;echo "<br>";
echo $Info['MaxPlayers'] ;echo "<br>";
echo $Info['MaxPlayers'] ;echo "<br>";
echo $Info['MaxPlayers'] ;echo "<br>";
echo $Info['MaxPlayers'] ;echo "<br>";
echo $Info['MaxPlayers'] ;echo "<br>";
echo $Info['MaxPlayers'] ;echo "<br>";
echo $Info['MaxPlayers'] ;echo "<br>";
echo $Info['MaxPlayers'] ;echo "<br>";
echo $Info['MaxPlayers'] ;echo "<br>";
echo $Info['MaxPlayers'] ;echo "<br>";
echo $Info['MaxPlayers'] ;
?>

View File

@ -19,8 +19,6 @@ $sec = "300";
$objlower = $objhigher[0]; // if the json response its multidimensional this lowers it
$objlower=json_decode($json); //converts to an array of objects
// librarie SQ - info serv game
require 'SQ_/bootstrap.php';
use xPaw\SourceQuery\SourceQuery;
@ -52,7 +50,6 @@ $sec = "300";
$Timer = Number_Format( MicroTime( true ) - $Timer, 4, '.', '' );
$InfoGT = $Info['GameTags'];
?>
@ -225,7 +222,7 @@ $sec = "300";
<h5 class="description-header">
<?php if (empty($Info['Players'])) {
echo "<span style='color:grey;'>"; } ?>
<?php echo $Info['Players'] ?> <span style='color:grey;'>/<?php echo $Info['MaxPlayers'] ; ?></span></span>
<?php echo $Info['Players']; ?> <span style='color:grey;'>/<?php echo $Info['MaxPlayers'] ; ?></span></span>
</h5>
<span class="description-text">PLAYERS</span>
</div>

30
mod2json.php Normal file
View File

@ -0,0 +1,30 @@
<?php
//$page = $_SERVER['PHP_SELF'];
//$sec = "300";
ini_set('display_errors', 'on');
//error_reporting(E_ALL); // Display all types of error
// include_once('./consql.php');
include_once('./config.php');
// Don't touch below (or you know what you do)
// need to fix if mod = 0
$json = file_get_contents("http://".$ipserv.":".$modport."/");
$objhigher=json_decode($json); //converts to an object
$objlower = $objhigher[0]; // if the json response its multidimensional this lowers it
$objlower=json_decode($json); //converts to an array of objects
print_r($objlower);
echo "<br><hr>";
var_dump($json);
echo "<br><hr>";
$myJSON = json_decode(utf8_encode($json), true);
var_dump($myJSON);
echo "<br>";
?>

22
mod2json_parser.php Normal file
View File

@ -0,0 +1,22 @@
<?php
include_once('./config.php');
// Don't touch below (or you know what you do)
// need to fix if mod = 0
$modjson = file_get_contents("http://".$ipserv.":".$modport."/");
$myJSON = json_decode(utf8_encode($json), true);
//var dump
//print_r($results);
$array = json_decode($modjson, true);
foreach($array as $values) {
echo $values['name']." ";
echo $values['steamWorkshopId']."<br>";
}
?>

View File

@ -1,2 +1 @@
{"server1":{"dedicated":"d","game_descr":"DayZ","game_dir":"dayz","game_id":221100,"gq_address":"82.64.214.194","gq_dedicated":"d","gq_gametype":"DayZ","gq_hostname":"[ TOX 1 #Expansion ] Chernarus Gloom HeroMOD | Summer | FR\/EN","gq_joinlink":"steam:\/\/connect\/82.64.214.194:3201\/","gq_mapname":"ChernarusPlusGloom","gq_maxplayers":60,"gq_mod":"dayz","gq_name":"DayZ Standalone","gq_numplayers":0,"gq_online":true,"gq_password":0,"gq_port_client":3201,"gq_port_query":27001,"gq_protocol":"source","gq_transport":"udp","gq_type":"dayz","hostname":"[ TOX 1 #Expansion ] Chernarus Gloom HeroMOD | Summer | FR\/EN","keywords":"battleye,external,privHive,shard,lqs0,etm2.000000,entm5.500000,mod,07:51","map":"ChernarusPlusGloom","max_players":60,"num_bots":0,"num_players":0,"os":"w","password":0,"players":[],"port":3201,"protocol":17,"secure":1,"steam_id":90142623158817801,"steamappid":0,"teams":[],"version":"1.10.153598"}}

53
statserver_json.php Normal file
View File

@ -0,0 +1,53 @@
<?php
ini_set('display_errors', 1);
//error_reporting(E_ALL); // Display all types of error
set_time_limit ( 4 ); // Max execution time is set to 4 seconds
// Read JSON file
$readjson = file_get_contents('./server.json');
$myJSON = json_decode(utf8_encode($readjson), true);
//echo $expansion_gq['gq_numplayers'];
echo "JSON ARRAY:<br> ";
print_r($myJSON);
echo "<hr>";
echo "RecursiveArrayIterator: <br>";
$jsonIterator = new RecursiveIteratorIterator(
new RecursiveArrayIterator(json_decode($readjson, TRUE)),
RecursiveIteratorIterator::SELF_FIRST);
foreach ($jsonIterator as $key => $val) {
if(is_array($val)) {
echo "$key:\n";
} else {
echo "$key => $val\n";
}
}
echo "<hr>";
echo "var dump: <br>"; var_dump($readjson);
echo "<hr>";
echo "Parsing data by using PHP Object <br/>";
$objhigher=json_decode($readjson); //converts to an object
$objlower = $objhigher[0]; // if the json response its multidimensional this lowers it
$objlower = json_decode($readjson); //converts to an array of objects
echo $objlower->hostname;
echo $obj->gq_address;
//echo $myJSON['hostname'];
//echo $myJSON[2];
?>