DayZ-Stat-Server/SQL/dayz2json_parser_sql.php

118 lines
3.2 KiB
PHP
Raw Normal View History

2021-02-04 18:00:02 +01:00
<?php
include_once('./config.php');
include_once('./consql.php');
2021-02-04 20:59:35 +01:00
2021-02-05 10:46:47 +01:00
// 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');
2021-02-04 18:00:02 +01:00
2021-02-04 22:14:31 +01:00
// DEBUG
/*
2021-02-04 18:00:02 +01:00
print_r($Info);
echo "<br><hr>";
echo "InfoGT: " .$InfoGT . "<br>";
echo "ModDesc: " .$Info['ModDesc'] . "<br>";
echo "Hostname: " .$Info['HostName'] . "<br>";
echo "Players: " .$Info['Players'] . "<br>";
echo "MaxPlayers: " .$Info['MaxPlayers'] . "<br>";
echo "Secure: " .$Info['Secure'] . "<br>";
echo "Map: " .$Info['Map'] . "<br>";
echo "Os: " .$Info['Os'] . "<br>";
echo "Version: " .$Info['Version'] . "<br>";
echo "Port: " .$Info['GamePort'] . "<br>";
echo "GameID: " .$Info['GameID'] . "<br>";
echo "<hr>test SQL";
2021-02-04 22:14:31 +01:00
*/
// Variables
2021-02-05 10:46:47 +01:00
$HostName = $Info['HostName'] ;
$Game = $Info['ModDesc'] ;
$Version = $Info['Version'] ;
$Players = $Info['Players'];
2021-02-04 18:00:02 +01:00
$MaxPlayers = $Info['MaxPlayers'] ;
2021-02-05 10:46:47 +01:00
$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'])) {
2021-02-04 18:00:02 +01:00
2021-02-05 10:46:47 +01:00
$HostName ="OFFLINE";
$Players ="0";
$ping ="0";
$timeserver="0";
$timespeed ="0";
$timespeedn="0";
$hive ="0";
$battleye ="0";
2021-02-04 18:00:02 +01:00
2021-02-05 10:46:47 +01:00
$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 . "<br>" . mysqli_error($con);
}
//mysqli_close($con);
exit ;
}
// 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];
2021-02-04 18:00:02 +01:00
2021-02-04 22:14:31 +01:00
// SQL insert Query.
2021-02-05 10:46:47 +01:00
$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')";
2021-02-04 18:00:02 +01:00
2021-02-04 22:14:31 +01:00
// Check if errors with SQL query
2021-02-04 18:00:02 +01:00
if (mysqli_query($con, $insql)) {
2021-02-04 22:14:31 +01:00
// echo "New record created successfully";
2021-02-04 18:00:02 +01:00
} else {
echo "Error: " . $insql . "<br>" . mysqli_error($con);
}
mysqli_close($con);
2021-02-05 10:07:23 +01:00
// end
2021-02-04 18:00:02 +01:00
?>