diff --git a/SQL/regex_statserver_json.php b/SQL/regex_statserver_json.php index b7665db..a90f75e 100644 --- a/SQL/regex_statserver_json.php +++ b/SQL/regex_statserver_json.php @@ -1,183 +1,114 @@ 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 "
";
 print_r($Info);
+echo "
"; -echo "

RESULTS

"; - -$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 . "
"; -echo "Players: " .$Players . "
"; +// test REGEX +echo "

RESULAT parser JSON

"; +echo "Hostname: " .$HostName . "
"; +echo "Players: " .$PLayers . "
"; echo "MaxPlayers: " .$MaxPlayers . "
"; echo "Secure: " .$Secure . "
"; echo "Map: " .$Map . "
"; echo "Os: " .$Os . "
"; echo "Version: " .$Version . "
"; -echo "Port: " .$GamePort . "

"; +echo "Port: " .$GamePort . "


"; echo "

Payes ta regex

"; $result = explode(",", $InfoGT); print_r($result); -echo "
".$InfoGT."
"; +echo "
".$InfoGT."
"; //echo ""; echo "
"; ?> -

example

-
-
-$regtimeacc  = "/etm([0-9]{1,2}[.][0-9]{1})/";
-$result = preg_grep($regtimeacc, explode(",", $InfoGT));
-foreach ($result as $key => $val) {
- echo $val;
-}
-
+

example code

+

+$regtimeacc  = "/etm([0-9]{1,2}[.][0-9]{1})/";
+$result =  preg_grep($regtimeacc, explode(",", $InfoGT));
+foreach ($result as $key => $val) {
+   echo $val;
+}
+
"; -echo "
  '/(battleye)/' 
"; -$regtimsev = "/(battleye)/"; -$result = preg_grep($regtimsev, explode(",", $InfoGT)); -//print_r($result); -//echo $result[0]; -foreach ($result as $key => $val) { - echo $val; -} + +$regbattle = "/(battleye)/"; +echo "
$regbattle 
"; +$result = preg_grep($regbattle, explode(",", $InfoGT)); +foreach ($result as $key => $val) { echo $val; } echo "

"; -echo "
 '/[^,]...(Hive)/'
"; -$re = '/[^,]...(Hive)/'; -$result = preg_grep($re,explode(",", $InfoGT)); -foreach ($result as $key => $val) { - echo $val; -} +$rehive = '/[^,]...(Hive)/'; +echo "
$rehive 
"; +$result = preg_grep($rehive,explode(",", $InfoGT)); +foreach ($result as $key => $val) { echo $val; } echo "

"; -echo "
  '/[0-9]{1,2}[:][0-9]{1,2}/' 
"; $regtimsev = "/[0-9]{1,2}[:][0-9]{1,2}/"; +echo "
$regtimsev 
"; $result = preg_grep($regtimsev, explode(",", $InfoGT)); -foreach ($result as $key => $val) { - echo $val; -} +foreach ($result as $key => $val) { echo $val; } echo "

"; -echo "
  '/(mod)/' 
"; $regmod = "/(mod)/"; +echo "
$regmod 
"; $result = preg_grep($regmod, explode(",", $InfoGT)); -foreach ($result as $key => $val) { - echo $val; -} +foreach ($result as $key => $val) { echo $val; } echo "

"; -echo "
 '/etm([0-9]{1,2}[.][0-9]{1})/' 
"; -$regtimeacc = "/etm([0-9]{1,2}[.][0-9]{1})/"; +$regtimeacc = "/etm[0-9]{1,2}[.][0-9]{1}/"; +echo "
$regtimeacc 
"; $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 "

"; -//echo "
 '/entm[0-9]{1,2}[.][0-9]{1}/' 
"; -$regtimeacn = "/entm[0-9][.][0-9]{1}/"; -echo "
 .$regtimeacn.
"; + +$regtimeacn = "/entm[0-9]{1,2}[.][0-9]{1}/"; +echo "
 $regtimeacn
"; $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 "

"; -echo "

Payes ton explode

"; -$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 "
"; +echo "

Payes ton explode

"; +$retest = explode(",", $InfoGT); +echo '
';
+echo $retest[0] . "|".$retest[2]. "|". $retest[3]. "|". $retest[4]. "|". $retest[8]. "|". $retest[5]. "|". $retest[6]; 
+echo "

"; +echo "

Payes tes tests

"; $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 '
'; print_r($matches); echo '
'; - +echo '
'; print_r($matches); echo '
'; echo "
"; $encode = json_encode($matches); @@ -191,3 +122,16 @@ echo $output; ?> + + diff --git a/config.php b/config.php index 9e032a0..c614e6d 100644 --- a/config.php +++ b/config.php @@ -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 "

"; - - echo "InfoGT: " .$InfoGT . "
"; - echo "ModDesc: " .$Info['ModDesc'] . "
"; - echo "Hostname: " .$Info['HostName'] . "
"; - echo "Players: " .$Info['Players'] . "
"; - echo "MaxPlayers: " .$Info['MaxPlayers'] . "
"; - echo "Secure: " .$Info['Secure'] . "
"; - echo "Map: " .$Info['Map'] . "
"; - echo "Os: " .$Info['Os'] . "
"; - echo "Version: " .$Info['Version'] . "
"; - echo "Port: " .$Info['GamePort'] . "
"; - echo "GameID: " .$Info['GameID'] . "
"; - echo "
test SQL"; */ // Variables