first commit

This commit is contained in:
Erreur32 2021-02-05 10:46:47 +01:00
parent bbc5ccaaf6
commit 350f0757c5
2 changed files with 79 additions and 41 deletions

View file

@ -3,6 +3,13 @@
include_once('./config.php'); include_once('./config.php');
include_once('./consql.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 // DEBUG
/* /*
@ -23,29 +30,77 @@ echo "GameID: " .$Info['GameID'] . "<br>";
echo "<hr>test SQL"; echo "<hr>test SQL";
*/ */
// Variables // Variables
$HostName = $Info['HostName'] ; $HostName = $Info['HostName'] ;
$Game = $Info['ModDesc'] ; $Game = $Info['ModDesc'] ;
$Version = $Info['Version'] ; $Version = $Info['Version'] ;
$Players = $Info['Players']; $Players = $Info['Players'];
$MaxPlayers = $Info['MaxPlayers'] ; $MaxPlayers = $Info['MaxPlayers'] ;
$Secure = $Info['Secure'] ; $Secure = $Info['Secure'] ;
$Map = $Info['Map']; $Map = $Info['Map'];
$Os = $Info['Os'] ; $Os = $Info['Os'] ;
$GamePort = $Info['GamePort'] ; $GamePort = $Info['GamePort'] ;
$GameID = $Info['GameID'] ; $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 . "<br>" . 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. // 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 // Check if errors with SQL query
if (mysqli_query($con, $insql)) { if (mysqli_query($con, $insql)) {
@ -54,22 +109,6 @@ if (mysqli_query($con, $insql)) {
echo "Error: " . $insql . "<br>" . mysqli_error($con); echo "Error: " . $insql . "<br>" . 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 . "<br>" . mysqli_error($con);
}
}
mysqli_close($con); mysqli_close($con);

View file

@ -10,24 +10,23 @@ error_reporting(E_ALL); // Display all types of error
//$myJSON = json_decode(utf8_encode($readjson), true); //$myJSON = json_decode(utf8_encode($readjson), true);
include_once('config.php'); include_once('../config.php');
//include_once('consql.php'); //include_once('consql.php');
//var_dump(json_decode($readjson)); //var_dump(json_decode($readjson));
$urlserv = $ipserv.":".$servport ; $urlserv = $ipserv.":".$servport ;
// librarie SQ - info serv game // librarie SQ - info serv game
require 'SQ_/bootstrap.php'; require '../SQ_/bootstrap.php';
use xPaw\SourceQuery\SourceQuery; use xPaw\SourceQuery\SourceQuery;
define( 'SQ_SERVER_ADDR', "${ipserv}" ); // IP server define( '../SQ_SERVER_ADDR', "${ipserv}" ); // IP server
define( 'SQ_SERVER_PORT', "${queryport}" ); // YOUR QUERY PORT define( '../SQ_SERVER_PORT', "${queryport}" ); // YOUR QUERY PORT
define( 'SQ_TIMEOUT', 3 ); define( '../SQ_TIMEOUT', 3 );
define( 'SQ_ENGINE', SourceQuery::SOURCE ); define( '../SQ_ENGINE', SourceQuery::SOURCE );
$Timer = MicroTime( true ); $Timer = MicroTime( true );
$Query = new SourceQuery( ); $Query = new SourceQuery( );
$Info = Array( ); $Info = Array( );
$Players = Array( ); $Players = Array( );
@ -76,10 +75,10 @@ echo "<pre>".$InfoGT."</pre>";
echo "<br>"; echo "<br>";
$result = explode(",", $InfoGT); $result = explode(",", $InfoGT);
$re = '/[^,]...(Hive)/';
print_r($result); print_r($result);
echo "<br>"; echo "<br> 2222222";
$re = '/[^,]...(Hive)/';
$rt = preg_grep($re, array($InfoGT)); $rt = preg_grep($re, array($InfoGT));
print_r($rt); print_r($rt);
echo "<br><hr>"; echo "<br><hr>";