From 07055b55de4ff1b6b662635f66d723edaf7e5d28 Mon Sep 17 00:00:00 2001 From: Erreur32 Date: Fri, 5 Feb 2021 22:26:36 +0100 Subject: [PATCH] first commit --- SQL/dayz2json_parser_sql.php | 46 ++++++++++++++++++++---------------- consql.php | 12 +++++++--- 2 files changed, 35 insertions(+), 23 deletions(-) diff --git a/SQL/dayz2json_parser_sql.php b/SQL/dayz2json_parser_sql.php index 00da94c..494938f 100644 --- a/SQL/dayz2json_parser_sql.php +++ b/SQL/dayz2json_parser_sql.php @@ -4,10 +4,10 @@ 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 + // 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'); + $date = date('Y-m-d H:i:s'); // if server down update sql if (empty($Info['HostName'])) { @@ -33,45 +33,51 @@ $insql = "INSERT INTO $table (date,name,players,maxplayers,map,game,version,time } mysqli_close($con); -//exit ; } else { -// REGEX TIME +// REGEX TIME let's go :) + +// time server $regtimsev = "/[0-9]{1,2}[:][0-9]{1,2}/"; $result = preg_grep($regtimsev, explode(",", $InfoGT)); -$timeserver = $result[8]; + foreach ($result as $key => $val) { + $timeserver = $val; +} -$regtimeacd = "/([0-9][.][0-9]{1})/"; -$result = preg_grep($regtimeacd, explode(",", $InfoGT)); -$timespeed = $result[5]; +// speedtime dayz +$regtimeacc = "/etm[0-9]{1,2}[.][0-9]{1}/"; +$result = preg_grep($regtimeacc, explode(",", $InfoGT)); + foreach ($result as $key => $val) { $timespeed = trim($val,"entm.0"); } -$regtimeacn = "/([0-9][.][0-9]{1})/"; +// speedtime night +$regtimeacn = "/entm[0-9]{1,2}[.][0-9]{1}/"; $result = preg_grep($regtimeacn, explode(",", $InfoGT)); -$timespeedn = $result[6]; + foreach ($result as $key => $val) { $timespeedn = trim($val,"entm.0"); } // HIVE $reghive = '/[^,]...(Hive)/'; $result = preg_grep($reghive, explode(",", $InfoGT)); -$hive = $result[2]; + foreach ($result as $key => $val) { $hive = $val; } -// battleye check +// battleye $regbattle = "/(battleye)/"; $result = preg_grep($regbattle, explode(",", $InfoGT)); -$battleye = $result[0]; + foreach ($result as $key => $val) { $battleye = $val; } + +// mod +$regmod = "/(mod)/"; +$result = preg_grep($regmod, explode(",", $InfoGT)); + foreach ($result as $key => $val) { $mods = $val; } -// DEBUG -$timespeed="2"; -$timespeedn="4"; // SQL insert Query. $insql = "INSERT INTO $table (date,name,players,maxplayers,map,game,version,timeserver,timespeed,timespeedn,mods,battleye,hive,connect,secure,ping) VALUES ('$date','$HostName','$PLayers','$MaxPlayers','$Map','$Game','$Version','$timeserver','$timespeed','$timespeedn','$mods','$battleye','$hive','$urlserv','$Secure','$ping')"; // Check if errors with SQL query if (mysqli_query($con, $insql)) { - // echo "New record created successfully"; -} else { - echo "Error: " . $insql . "
" . mysqli_error($con); -} +// DEBUG +// echo "New record created successfully"; echo $insql; + } else { echo "Error: " . $insql . "
" . mysqli_error($con); } mysqli_close($con); } diff --git a/consql.php b/consql.php index 9f9e12b..f1bfa45 100644 --- a/consql.php +++ b/consql.php @@ -4,13 +4,19 @@ // Create Database first ;) + $servdb = "localhost"; + $userdb = "dayz"; + $pdb = "dayz32"; + $dbname = "dayzstat"; + $table = "StatServer_5"; + +/* $servdb = "localhost"; $userdb = "user"; $pdb = "pass"; $dbname = "database"; - $table = "StatServer_5"; - - + $table = "StatServer_1"; +*/ $StatServer = $table; $con = new mysqli($servdb, $userdb, $pdb, $dbname);