first commit

This commit is contained in:
Erreur32 2021-02-05 21:49:12 +01:00
parent b6cc8fabb5
commit 137573be5d
2 changed files with 68 additions and 144 deletions

View file

@ -1,183 +1,114 @@
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL); // Display all types of error
//set_time_limit ( 4 ); // Max execution time is set to 4 seconds
// Read JSON file
//$readjson = file_get_contents('./server.json');
//$myJSON = json_decode(utf8_encode($readjson), true);
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';
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 );
$Timer = MicroTime( true );
$Query = new SourceQuery( );
$Info = Array( );
$Players = Array( );
try
{
$Query->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'];
// print json server
echo "<pre>";
print_r($Info);
echo "</pre>";
echo "<hr><h1> RESULTS </h1>";
$sname = $Info['HostName'] ;
$Players = $Info['Players'] ;
$MaxPlayers = $Info['MaxPlayers'] ;
$Secure = $Info['Secure'] ;
$Map = $Info['Map'] ;
$Os = $Info['Os'] ;
$Version = $Info['Version'] ;
$GamePort = $Info['GamePort'] ;
echo "Hostname: " .$sname . "<br>";
echo "Players: " .$Players . "<br>";
// test REGEX
echo "<h1>RESULAT parser JSON </h1><code>";
echo "Hostname: " .$HostName . "<br>";
echo "Players: " .$PLayers . "<br>";
echo "MaxPlayers: " .$MaxPlayers . "<br>";
echo "Secure: " .$Secure . "<br>";
echo "Map: " .$Map . "<br>";
echo "Os: " .$Os . "<br>";
echo "Version: " .$Version . "<br>";
echo "Port: " .$GamePort . "<br><hr>";
echo "Port: " .$GamePort . "</code><br><hr>";
echo "<h1>Payes ta regex</h1>";
$result = explode(",", $InfoGT);
print_r($result);
echo "<pre>".$InfoGT."</pre>";
echo "<pre><code>".$InfoGT."</code></pre>";
//echo "<table><tr>";
echo "<hr>";
?>
<h2> example</h2>
<pre>
$regtimeacc = "/etm([0-9]{1,2}[.][0-9]{1})/";<br>
$result = preg_grep($regtimeacc, explode(",", $InfoGT));<br>
foreach ($result as $key => $val) {<br>
echo $val;<br>
}<br>
</pre>
<h2> example code</h2>
<pre><code>
$regtimeacc = "/etm([0-9]{1,2}[.][0-9]{1})/";
$result = preg_grep($regtimeacc, explode(",", $InfoGT));
foreach ($result as $key => $val) {
echo $val;
}
</code></pre>
<?php
echo "<hr>";
echo "<pre> '/(battleye)/' </pre> ";
$regtimsev = "/(battleye)/";
$result = preg_grep($regtimsev, explode(",", $InfoGT));
//print_r($result);
//echo $result[0];
foreach ($result as $key => $val) {
echo $val;
}
$regbattle = "/(battleye)/";
echo "<pre><code>$regbattle </code></pre>";
$result = preg_grep($regbattle, explode(",", $InfoGT));
foreach ($result as $key => $val) { echo $val; }
echo "<br><hr>";
echo "<pre> '/[^,]...(Hive)/'</pre>";
$re = '/[^,]...(Hive)/';
$result = preg_grep($re,explode(",", $InfoGT));
foreach ($result as $key => $val) {
echo $val;
}
$rehive = '/[^,]...(Hive)/';
echo "<pre><code>$rehive </code></pre>";
$result = preg_grep($rehive,explode(",", $InfoGT));
foreach ($result as $key => $val) { echo $val; }
echo "<br><hr>";
echo "<pre> '/[0-9]{1,2}[:][0-9]{1,2}/' </pre>";
$regtimsev = "/[0-9]{1,2}[:][0-9]{1,2}/";
echo "<pre><code>$regtimsev </code></pre>";
$result = preg_grep($regtimsev, explode(",", $InfoGT));
foreach ($result as $key => $val) {
echo $val;
}
foreach ($result as $key => $val) { echo $val; }
echo "<br><hr>";
echo "<pre> '/(mod)/' </pre>";
$regmod = "/(mod)/";
echo "<pre><code>$regmod </code></pre>";
$result = preg_grep($regmod, explode(",", $InfoGT));
foreach ($result as $key => $val) {
echo $val;
}
foreach ($result as $key => $val) { echo $val; }
echo "<br><hr>";
echo "<pre> '/etm([0-9]{1,2}[.][0-9]{1})/' </pre>";
$regtimeacc = "/etm([0-9]{1,2}[.][0-9]{1})/";
$regtimeacc = "/etm[0-9]{1,2}[.][0-9]{1}/";
echo "<pre><code>$regtimeacc </code></pre>";
$result = preg_grep($regtimeacc, explode(",", $InfoGT));
//print_r($result);
//echo $result[5];
foreach ($result as $key => $val) {
echo $val;
echo trim($val,"entm.0");
// $regrep = str_replace("etm", "", $val);
// echo str_replace("00000", "", $regrep);
}
echo "<br><hr>";
//echo "<pre> '/entm[0-9]{1,2}[.][0-9]{1}/' </pre>";
$regtimeacn = "/entm[0-9][.][0-9]{1}/";
echo "<pre> .$regtimeacn.</pre>";
$regtimeacn = "/entm[0-9]{1,2}[.][0-9]{1}/";
echo "<pre><code> $regtimeacn</code></pre> ";
$result = preg_grep($regtimeacn, explode(",", $InfoGT));
//print_r($result);
//echo $result[6];
foreach ($result as $key => $val) {
echo $val;
echo trim($val,"entm.0");
// $regrepn = str_replace("entm", "", $val);
// echo str_replace("00000", "", $regrepn);
}
echo "<br><hr>";
echo "<h1>Payes ton explode</h1>";
$retest = explode(",", $InfoGT);
echo $retest[0] . "|".$retest[2]. "|". $retest[3]. "|". $retest[4]. "|". $retest[8]. "|". $retest[5]. "|". $retest[6];
/*
$regtimsev = "[0-9]{1,2}[:][0-9]{1,2}";
$reghive = "[^,]...(Hive)";
$regtimeacc = "[^,etm][0-9][.][0-9]{1}";
//$regtimeacn = "[^,entm][0-9][.][0-9]{1}";
$regtimeacn = "([0-9][.][0-9]{1})";
//echo preg_grep('/[0-9]{1,2}[:][0-9]{1,2}/', explode("\n", $InfoGT));
echo preg_grep('/$regex/', $InfoGT);
$fl_array = preg_grep("/[^,entm][0-9][.][0-9]{1}/", $InfoGT);
echo $fl_array;
$re = '/(?!etm)[0-9]{1,2}[.][0-9]{1}/';
$str = 'battleye,external,privHive,shard,lqs0,etm12.000000,entm2.000000,mod,01:43';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
var_dump($matches); // Print the entire match result
*/
echo "<hr>";
echo "<h1>Payes ton explode</h1>";
$retest = explode(",", $InfoGT);
echo '<pre><code>';
echo $retest[0] . "|".$retest[2]. "|". $retest[3]. "|". $retest[4]. "|". $retest[8]. "|". $retest[5]. "|". $retest[6];
echo "</code></pre><hr>";
echo "<h1>Payes tes tests</h1>";
$re = '/[0-9]{1,2}[:][0-9]{1,2}/m';
//$str = 'battleye,external,privHive,shard,lqs0,etm2.000000,entm5.500000,mod,23:17';
preg_match_all($re, $InfoGT, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
//var_dump($matches);
echo '<pre>'; print_r($matches); echo '</pre>';
echo '<pre><code>'; print_r($matches); echo '</code></pre>';
echo "<br>";
$encode = json_encode($matches);
@ -191,3 +122,16 @@ echo $output;
?>
<style>
pre { width:min-content; }
/*pre:hover, pre:focus { width: min-content;}*/
h1 { color: #590;}
code {
display: block;
padding: 12px;
color: #F90;
background:black;
}
</style>

View file

@ -23,18 +23,15 @@
$logoteam = "logoteam.png";
$imagemap = "chernarus.jpg";
/*
// 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_default_timezone_set('Etc/GMT-1');
//$date = date('Y-m-d H:i:s');
*/
// Don't touch below
// Don't touch below (or you know what you do)
$urlserv = $ipserv.":".$servport ;
// need to fix if mod = 0
$json = file_get_contents("http://".$ipserv.":".$modport."/"); // get info from server
if (!$json) {
//echo "The variable is not empty";
@ -69,30 +66,13 @@
}
$Query->Disconnect( );
$Timer = Number_Format( MicroTime( true ) - $Timer, 4, '.', '' );
$InfoGT = $Info['GameTags'];
// DEBUG
/*
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";
*/
// Variables