From 21d30b24f28f498852f9e654a9dc1a26c4de0ecc Mon Sep 17 00:00:00 2001 From: Erreur32 Date: Wed, 3 Feb 2021 16:12:25 +0100 Subject: [PATCH] first commit --- dayz2json.php | 9 ++---- dayz2json_parser.php | 66 ++++++++++++++++++++++++++++++++++++++++++++ index.php | 5 +--- mod2json.php | 30 ++++++++++++++++++++ mod2json_parser.php | 22 +++++++++++++++ server.json | 1 - statserver_json.php | 53 +++++++++++++++++++++++++++++++++++ 7 files changed, 174 insertions(+), 12 deletions(-) create mode 100644 dayz2json_parser.php create mode 100644 mod2json.php create mode 100644 mod2json_parser.php create mode 100644 statserver_json.php diff --git a/dayz2json.php b/dayz2json.php index 05683d4..033a016 100755 --- a/dayz2json.php +++ b/dayz2json.php @@ -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 "
"; -//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; ?> diff --git a/dayz2json_parser.php b/dayz2json_parser.php new file mode 100644 index 0000000..a4457e4 --- /dev/null +++ b/dayz2json_parser.php @@ -0,0 +1,66 @@ +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 "
"; +echo $Info['MaxPlayers'] ;echo "
"; +echo $Info['MaxPlayers'] ;echo "
"; +echo $Info['MaxPlayers'] ;echo "
"; +echo $Info['MaxPlayers'] ;echo "
"; +echo $Info['MaxPlayers'] ;echo "
"; +echo $Info['MaxPlayers'] ;echo "
"; +echo $Info['MaxPlayers'] ;echo "
"; +echo $Info['MaxPlayers'] ;echo "
"; +echo $Info['MaxPlayers'] ;echo "
"; +echo $Info['MaxPlayers'] ;echo "
"; +echo $Info['MaxPlayers'] ;echo "
"; +echo $Info['MaxPlayers'] ;echo "
"; +echo $Info['MaxPlayers'] ;echo "
"; +echo $Info['MaxPlayers'] ;echo "
"; +echo $Info['MaxPlayers'] ;echo "
"; +echo $Info['MaxPlayers'] ;echo "
"; +echo $Info['MaxPlayers'] ; + + + + +?> + diff --git a/index.php b/index.php index 3f90277..e3bf8cf 100644 --- a/index.php +++ b/index.php @@ -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";
"; } ?> - / + /
PLAYERS diff --git a/mod2json.php b/mod2json.php new file mode 100644 index 0000000..a8fb7ea --- /dev/null +++ b/mod2json.php @@ -0,0 +1,30 @@ +
"; +var_dump($json); +echo "

"; +$myJSON = json_decode(utf8_encode($json), true); +var_dump($myJSON); + + +echo "
"; + + +?> diff --git a/mod2json_parser.php b/mod2json_parser.php new file mode 100644 index 0000000..e9eaae7 --- /dev/null +++ b/mod2json_parser.php @@ -0,0 +1,22 @@ +"; +} + + +?> diff --git a/server.json b/server.json index 59d2c38..bb3e74a 100644 --- a/server.json +++ b/server.json @@ -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"}} diff --git a/statserver_json.php b/statserver_json.php new file mode 100644 index 0000000..e02cdd6 --- /dev/null +++ b/statserver_json.php @@ -0,0 +1,53 @@ + "; +print_r($myJSON); + +echo "
"; +echo "RecursiveArrayIterator:
"; +$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 "
"; +echo "var dump:
"; var_dump($readjson); +echo "
"; + +echo "Parsing data by using PHP Object
"; + $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]; + + + + +?> + + +