2021-02-04 18:00:02 +01:00
|
|
|
<?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
|
|
|
|
|
2021-02-05 10:46:47 +01:00
|
|
|
include_once('../config.php');
|
2021-02-04 18:00:02 +01:00
|
|
|
|
2021-02-05 21:49:12 +01:00
|
|
|
// print json server
|
|
|
|
echo "<pre>";
|
2021-02-04 18:00:02 +01:00
|
|
|
print_r($Info);
|
2021-02-05 21:49:12 +01:00
|
|
|
echo "</pre>";
|
2021-02-04 18:00:02 +01:00
|
|
|
|
2021-02-05 21:49:12 +01:00
|
|
|
// test REGEX
|
|
|
|
echo "<h1>RESULAT parser JSON </h1><code>";
|
|
|
|
echo "Hostname: " .$HostName . "<br>";
|
|
|
|
echo "Players: " .$PLayers . "<br>";
|
2021-02-04 18:00:02 +01:00
|
|
|
echo "MaxPlayers: " .$MaxPlayers . "<br>";
|
|
|
|
echo "Secure: " .$Secure . "<br>";
|
|
|
|
echo "Map: " .$Map . "<br>";
|
|
|
|
echo "Os: " .$Os . "<br>";
|
|
|
|
echo "Version: " .$Version . "<br>";
|
2021-02-05 21:49:12 +01:00
|
|
|
echo "Port: " .$GamePort . "</code><br><hr>";
|
2021-02-04 18:00:02 +01:00
|
|
|
|
|
|
|
echo "<h1>Payes ta regex</h1>";
|
2021-02-05 18:57:23 +01:00
|
|
|
$result = explode(",", $InfoGT);
|
|
|
|
print_r($result);
|
2021-02-05 21:49:12 +01:00
|
|
|
echo "<pre><code>".$InfoGT."</code></pre>";
|
2021-02-05 18:57:23 +01:00
|
|
|
//echo "<table><tr>";
|
|
|
|
echo "<hr>";
|
2021-02-04 18:00:02 +01:00
|
|
|
|
2021-02-05 18:57:23 +01:00
|
|
|
?>
|
2021-02-04 18:00:02 +01:00
|
|
|
|
2021-02-05 21:49:12 +01:00
|
|
|
<h2> example code</h2>
|
|
|
|
<pre><code>
|
|
|
|
$regtimeacc = "/etm([0-9]{1,2}[.][0-9]{1})/";
|
|
|
|
$result = preg_grep($regtimeacc, explode(",", $InfoGT));
|
2021-02-05 18:57:23 +01:00
|
|
|
foreach ($result as $key => $val) {
|
|
|
|
echo $val;
|
|
|
|
}
|
2021-02-05 21:49:12 +01:00
|
|
|
</code></pre>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
echo "<hr>";
|
|
|
|
|
|
|
|
$regbattle = "/(battleye)/";
|
|
|
|
echo "<pre><code>$regbattle </code></pre>";
|
|
|
|
$result = preg_grep($regbattle, explode(",", $InfoGT));
|
|
|
|
foreach ($result as $key => $val) { echo $val; }
|
2021-02-04 18:00:02 +01:00
|
|
|
echo "<br><hr>";
|
|
|
|
|
2021-02-05 21:49:12 +01:00
|
|
|
$rehive = '/[^,]...(Hive)/';
|
|
|
|
echo "<pre><code>$rehive </code></pre>";
|
|
|
|
$result = preg_grep($rehive,explode(",", $InfoGT));
|
|
|
|
foreach ($result as $key => $val) { echo $val; }
|
2021-02-04 18:00:02 +01:00
|
|
|
echo "<br><hr>";
|
|
|
|
|
|
|
|
$regtimsev = "/[0-9]{1,2}[:][0-9]{1,2}/";
|
2021-02-05 21:49:12 +01:00
|
|
|
echo "<pre><code>$regtimsev </code></pre>";
|
2021-02-04 18:00:02 +01:00
|
|
|
$result = preg_grep($regtimsev, explode(",", $InfoGT));
|
2021-02-05 21:49:12 +01:00
|
|
|
foreach ($result as $key => $val) { echo $val; }
|
2021-02-04 18:00:02 +01:00
|
|
|
echo "<br><hr>";
|
|
|
|
|
2021-02-05 18:57:23 +01:00
|
|
|
$regmod = "/(mod)/";
|
2021-02-05 21:49:12 +01:00
|
|
|
echo "<pre><code>$regmod </code></pre>";
|
2021-02-05 18:57:23 +01:00
|
|
|
$result = preg_grep($regmod, explode(",", $InfoGT));
|
2021-02-05 21:49:12 +01:00
|
|
|
foreach ($result as $key => $val) { echo $val; }
|
2021-02-05 18:57:23 +01:00
|
|
|
|
|
|
|
echo "<br><hr>";
|
|
|
|
|
2021-02-05 21:49:12 +01:00
|
|
|
$regtimeacc = "/etm[0-9]{1,2}[.][0-9]{1}/";
|
|
|
|
echo "<pre><code>$regtimeacc </code></pre>";
|
2021-02-04 18:00:02 +01:00
|
|
|
$result = preg_grep($regtimeacc, explode(",", $InfoGT));
|
2021-02-05 18:57:23 +01:00
|
|
|
foreach ($result as $key => $val) {
|
2021-02-05 21:49:12 +01:00
|
|
|
echo trim($val,"entm.0");
|
|
|
|
// $regrep = str_replace("etm", "", $val);
|
|
|
|
// echo str_replace("00000", "", $regrep);
|
2021-02-05 18:57:23 +01:00
|
|
|
}
|
2021-02-04 18:00:02 +01:00
|
|
|
echo "<br><hr>";
|
2021-02-05 21:49:12 +01:00
|
|
|
|
|
|
|
$regtimeacn = "/entm[0-9]{1,2}[.][0-9]{1}/";
|
|
|
|
echo "<pre><code> $regtimeacn</code></pre> ";
|
2021-02-04 18:00:02 +01:00
|
|
|
$result = preg_grep($regtimeacn, explode(",", $InfoGT));
|
2021-02-05 18:57:23 +01:00
|
|
|
foreach ($result as $key => $val) {
|
2021-02-05 21:49:12 +01:00
|
|
|
echo trim($val,"entm.0");
|
|
|
|
// $regrepn = str_replace("entm", "", $val);
|
|
|
|
// echo str_replace("00000", "", $regrepn);
|
2021-02-05 18:57:23 +01:00
|
|
|
}
|
2021-02-04 18:00:02 +01:00
|
|
|
|
|
|
|
echo "<br><hr>";
|
|
|
|
|
|
|
|
/*
|
2021-02-05 21:49:12 +01:00
|
|
|
$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
|
2021-02-04 18:00:02 +01:00
|
|
|
*/
|
|
|
|
|
2021-02-04 20:52:15 +01:00
|
|
|
|
2021-02-05 21:49:12 +01:00
|
|
|
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>";
|
2021-02-05 18:57:23 +01:00
|
|
|
|
2021-02-05 21:49:12 +01:00
|
|
|
echo "<h1>Payes tes tests</h1>";
|
2021-02-04 20:52:15 +01:00
|
|
|
$re = '/[0-9]{1,2}[:][0-9]{1,2}/m';
|
2021-02-05 18:57:23 +01:00
|
|
|
preg_match_all($re, $InfoGT, $matches, PREG_SET_ORDER, 0);
|
2021-02-04 20:52:15 +01:00
|
|
|
|
|
|
|
// Print the entire match result
|
|
|
|
//var_dump($matches);
|
2021-02-05 21:49:12 +01:00
|
|
|
echo '<pre><code>'; print_r($matches); echo '</code></pre>';
|
2021-02-04 20:52:15 +01:00
|
|
|
echo "<br>";
|
|
|
|
|
|
|
|
$encode = json_encode($matches);
|
|
|
|
echo $encode;
|
|
|
|
echo "<br>";
|
|
|
|
|
|
|
|
//echo $matches[0];
|
2021-02-05 18:57:23 +01:00
|
|
|
$output = implode(",", array($InfoGT));
|
2021-02-04 20:52:15 +01:00
|
|
|
echo $output;
|
|
|
|
|
|
|
|
|
2021-02-04 18:00:02 +01:00
|
|
|
?>
|
|
|
|
|
2021-02-05 21:49:12 +01:00
|
|
|
<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>
|
|
|
|
|