Debug serveur stats\nDebug
This commit is contained in:
66
utils.php
66
utils.php
@ -1,6 +1,55 @@
|
||||
<?php
|
||||
////logger(DEBUG, _("Including utils.php"), __FILE__ . ":" . __LINE__);
|
||||
|
||||
/*function logger($level, $log, $pos = "")
|
||||
{
|
||||
global $logFh, $logLevel, $notificationLevel, $logLevels;
|
||||
$logString = $logLevels[$level] . " " ;
|
||||
if ($pos !== false)
|
||||
{
|
||||
$logString .= $pos;
|
||||
}
|
||||
$logString .= " - " . $log;
|
||||
if ($level & $logLevel)
|
||||
{
|
||||
fwrite($logFh, date("c") . ' ' . $logString . EOL);
|
||||
print ("MOHA-" . $logString . EOL);
|
||||
}
|
||||
}*/
|
||||
|
||||
function htmlGetFriendlyNames($ieeeAddress = '')
|
||||
{
|
||||
$url = "HTTP://localhost:1025/friendlyname";
|
||||
$ch = curl_init($url);
|
||||
if ($ieeeAddress !== '')
|
||||
{
|
||||
$url .= "&ieeeAddress=" . $ieeeAddress;
|
||||
}
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
$fn = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
if (($start = strpos($fn, "{")) === false)
|
||||
{
|
||||
if (($start = strpos($fn, "[")) === false)
|
||||
{
|
||||
print "Erreur : fn = " . $fn . __FILE__ . ":" . __LINE__ . EOLH;
|
||||
return false;
|
||||
}else
|
||||
{
|
||||
$end = strpos($fn, "]");
|
||||
}
|
||||
}else
|
||||
{
|
||||
$end = strpos($fn, "}");
|
||||
}
|
||||
|
||||
$length = $end - $start + 1;
|
||||
$fn = substr($fn, $start, $length);
|
||||
return jsonDecode($fn);
|
||||
}
|
||||
|
||||
function bool2string($var)
|
||||
{
|
||||
if ($var === false)
|
||||
@ -18,7 +67,22 @@ function bool2string($var)
|
||||
}
|
||||
}
|
||||
|
||||
function validateDate($date, $format = 'Y-m-d H:i:s')
|
||||
function jsonDecode($json)
|
||||
{
|
||||
//print "==========>" . print_r($json, true) . EOLH;
|
||||
|
||||
$jsonArray = array();
|
||||
$json = trim($json, " {[]}");
|
||||
$tmp = explode(",", $json);
|
||||
foreach($tmp as $value)
|
||||
{
|
||||
$tmp2 = explode (":" , $value);
|
||||
$jsonArray[trim($tmp2[0], '"')] = trim($tmp2[1], '"');
|
||||
}
|
||||
return $jsonArray;
|
||||
}
|
||||
|
||||
function validateDate($date, $format = 'Y-m-d')
|
||||
{
|
||||
$d = DateTime::createFromFormat($format, $date);
|
||||
return $d && $d->format($format) == $date;
|
||||
|
Reference in New Issue
Block a user