From 350f0757c5deec6ebc5180676e25ff62c946dc13 Mon Sep 17 00:00:00 2001 From: Erreur32 Date: Fri, 5 Feb 2021 10:46:47 +0100 Subject: [PATCH] first commit --- SQL/dayz2json_parser_sql.php | 103 +++++++++++++++++++++++----------- SQL/regex_statserver_json.php | 17 +++--- 2 files changed, 79 insertions(+), 41 deletions(-) diff --git a/SQL/dayz2json_parser_sql.php b/SQL/dayz2json_parser_sql.php index d2100b2..896eeba 100644 --- a/SQL/dayz2json_parser_sql.php +++ b/SQL/dayz2json_parser_sql.php @@ -3,6 +3,13 @@ include_once('./config.php'); include_once('./consql.php'); +// set the default timezone to use. Available since PHP 5.1 +// https://www.php.net/manual/en/timezones.others.php +date_default_timezone_set('Etc/GMT-1'); +//date_default_timezone_set('Europe/Paris'); + +$date = date('Y-m-d H:i:s'); + // DEBUG /* @@ -23,29 +30,77 @@ echo "GameID: " .$Info['GameID'] . "
"; echo "
test SQL"; */ - // Variables -$HostName = $Info['HostName'] ; -$Game = $Info['ModDesc'] ; -$Version = $Info['Version'] ; -$Players = $Info['Players']; +$HostName = $Info['HostName'] ; +$Game = $Info['ModDesc'] ; +$Version = $Info['Version'] ; +$Players = $Info['Players']; $MaxPlayers = $Info['MaxPlayers'] ; -$Secure = $Info['Secure'] ; -$Map = $Info['Map']; -$Os = $Info['Os'] ; -$GamePort = $Info['GamePort'] ; -$GameID = $Info['GameID'] ; +$Secure = $Info['Secure'] ; +$Map = $Info['Map']; +$Os = $Info['Os'] ; +$GamePort = $Info['GamePort'] ; +$GameID = $Info['GameID'] ; +$ping = "666"; + +// if server down update sql +if (empty($Info['HostName'])) { + +$HostName ="OFFLINE"; +$Players ="0"; +$ping ="0"; +$timeserver="0"; +$timespeed ="0"; +$timespeedn="0"; +$hive ="0"; +$battleye ="0"; + +$insql = "INSERT INTO $table (date,name,players,maxplayers,map,game,version,timeserver,timespeed,timespeedn,battleye,hive,connect,secure,ping) VALUES ('$date','$HostName','$Players','$MaxPlayers','$Map','$Game','$Version','$timeserver','$timespeed','$timespeedn','$battleye','$hive','$urlserv','$Secure','$ping')"; + + if (mysqli_query($con, $insql)) { + // echo "New record created successfully"; + } else { + echo "Error: " . $insql . "
" . mysqli_error($con); + } + +//mysqli_close($con); +exit ; +} -// set the default timezone to use. Available since PHP 5.1 -// https://www.php.net/manual/en/timezones.others.php -date_default_timezone_set('Etc/GMT-1'); -//date_default_timezone_set('Europe/Paris'); -$date = date('Y-m-d H:i:s'); +// REGEX TIME +$regtimsev = "/[0-9]{1,2}[:][0-9]{1,2}/"; +$result = preg_grep($regtimsev, explode(",", $InfoGT)); +$timeserver = $result[8]; + +$regtimeacd = "/([0-9][.][0-9]{1})/"; +$result = preg_grep($regtimeacd, explode(",", $InfoGT)); +$timespeed = $result[5]; + +$regtimeacn = "/([0-9][.][0-9]{1})/"; +$result = preg_grep($regtimeacn, explode(",", $InfoGT)); +$timespeedn = $result[6]; + +// DEBUG +$timespeed="2"; +$timespeedn="4"; + + +// HIVE +//$result = explode(",", $InfoGT); +$reghive = '/[^,]...(Hive)/'; +$result = preg_grep($reghive, explode(",", $InfoGT)); +$hive = $result[2]; + +// battleye check +$regbattle = "/(battleye)/"; +$result = preg_grep($regbattle, explode(",", $InfoGT)); +$battleye = $result[0]; + // SQL insert Query. -$insql = "INSERT INTO $table (date,name,players,maxplayers,map,game,version,timeserver,timespeed,timespeedn,battleye,hive,connect,secure,ping) VALUES ('$date','$HostName','$Players','$MaxPlayers','$Map','$Game','$Version','2:20','2','4','battleye','hive','$urlserv','$Secure','666')"; +$insql = "INSERT INTO $table (date,name,players,maxplayers,map,game,version,timeserver,timespeed,timespeedn,battleye,hive,connect,secure,ping) VALUES ('$date','$HostName','$Players','$MaxPlayers','$Map','$Game','$Version','$timeserver','$timespeed','$timespeedn','$battleye','$hive','$urlserv','$Secure','$ping')"; // Check if errors with SQL query if (mysqli_query($con, $insql)) { @@ -54,22 +109,6 @@ if (mysqli_query($con, $insql)) { echo "Error: " . $insql . "
" . mysqli_error($con); } -// if server down update sql -if (empty($Info['HostName'])) { -$HostName="OFFLINE"; -$numplayers="0"; -$players="0"; -$ping="0"; -$insql = "INSERT INTO $table (date,name,players,maxplayers,map,game,version,timeserver,timespeed,timespeedn,battleye,hive,connect,secure,ping) VALUES ('$date','$HostName','$Players','$MaxPlayers','$Map','$Game','$Version','2:20','2','4','battleye','hive','$urlserv','$Secure','666')"; - - if (mysqli_query($con, $insql)) { - // echo "New record created successfully"; - } else { - echo "Error: " . $insql . "
" . mysqli_error($con); - } - -} - mysqli_close($con); diff --git a/SQL/regex_statserver_json.php b/SQL/regex_statserver_json.php index b63ba18..6df4b2d 100644 --- a/SQL/regex_statserver_json.php +++ b/SQL/regex_statserver_json.php @@ -10,24 +10,23 @@ error_reporting(E_ALL); // Display all types of error //$myJSON = json_decode(utf8_encode($readjson), true); -include_once('config.php'); +include_once('../config.php'); //include_once('consql.php'); //var_dump(json_decode($readjson)); $urlserv = $ipserv.":".$servport ; // librarie SQ - info serv game - require 'SQ_/bootstrap.php'; + 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 ); + 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( ); @@ -76,10 +75,10 @@ echo "
".$InfoGT."
"; echo "
"; $result = explode(",", $InfoGT); -$re = '/[^,]...(Hive)/'; print_r($result); -echo "
"; +echo "
2222222"; +$re = '/[^,]...(Hive)/'; $rt = preg_grep($re, array($InfoGT)); print_r($rt); echo "

";