debugging
This commit is contained in:
@@ -20,13 +20,13 @@ function askWebServer($read)
|
||||
|
||||
if ( stream_select( $read, $array, $array, 0 ))
|
||||
{
|
||||
logger(DEBUG,_("socket ready to read"));
|
||||
logger(DEBUG, _("socket ready to read"), __FILE__ . ":" . __LINE__);
|
||||
$spawn = stream_socket_accept($read[0]);
|
||||
if ($spawn !== false)
|
||||
{
|
||||
logger(DEBUG,_("socket accepted"));
|
||||
logger(DEBUG, _("socket accepted"), __FILE__ . ":" . __LINE__);
|
||||
$input = fgets($spawn, 4096);
|
||||
logger(DEBUG, $input);
|
||||
logger(DEBUG, $input, __FILE__ . ":" . __LINE__);
|
||||
if (!empty($input))
|
||||
{
|
||||
$input = substr($input,5);
|
||||
@@ -34,17 +34,18 @@ function askWebServer($read)
|
||||
$argTmp = explode("&", $input[0]);
|
||||
foreach($argTmp as $tmp)
|
||||
{
|
||||
logger(DEBUG, $tmp);
|
||||
logger(DEBUG, $tmp, __FILE__ . ":" . __LINE__);
|
||||
$array = explode("=", $tmp);
|
||||
print_r($array);
|
||||
//print_r($array);
|
||||
if (isset($array[1])) $argList[$array[0]] = $array[1];
|
||||
}
|
||||
if(array_key_exists("cmd", $argList))
|
||||
{
|
||||
switch(strtolower($argList["cmd"]))
|
||||
$command = strtolower($argList["cmd"]);
|
||||
switch($command)
|
||||
{
|
||||
case "get":
|
||||
logger(DEBUG, "get reached");
|
||||
logger(DEBUG, _("GET reached"), __FILE__ . ":" . __LINE__);
|
||||
if(empty($argList["device"]))
|
||||
{
|
||||
$response = "<html><header><body>get passed</body></header><html>";
|
||||
@@ -52,12 +53,13 @@ function askWebServer($read)
|
||||
fwrite($spawn, $response);
|
||||
break;
|
||||
case "set":
|
||||
logger(DEBUG, "set reached");
|
||||
logger(DEBUG, _("SET reached"), __FILE__ . ":" . __LINE__);
|
||||
$response = "<html><header><body>set passed</body></header><html>";
|
||||
fwrite($spawn, $response);
|
||||
break;
|
||||
case "dump":
|
||||
case "print":
|
||||
logger(DEBUG, "print reached");
|
||||
logger(DEBUG, $command . _(" reached"), __FILE__ . ":" . __LINE__);
|
||||
$var = $GLOBALS[$argList["object"]];
|
||||
if (isset($argList["topic"]))
|
||||
{
|
||||
@@ -78,7 +80,12 @@ function askWebServer($read)
|
||||
}
|
||||
}else
|
||||
{
|
||||
logger(ERROR, _("topic is not defining: add &topic=zigbee2mqtt to the resquest"));
|
||||
$str = _("topic is not defining: add &topic=\nThese topics are availables: ");
|
||||
foreach($topics as $key => $value)
|
||||
{
|
||||
$str .= $key . EOL;
|
||||
}
|
||||
logger(ERROR, $str, __FILE__ . ":" . __LINE__);
|
||||
}
|
||||
}
|
||||
$error = error_get_last();
|
||||
@@ -86,12 +93,19 @@ function askWebServer($read)
|
||||
{
|
||||
$response = "<html><header><body>" . $error["message"] . " file: " . $error["file"] . " line: " . $error["line"] . "</body></header><html>";
|
||||
}
|
||||
$response = "<html><header><body>" . print_r($var, true) . "</body></header><html>";
|
||||
if ($command === "print")
|
||||
{
|
||||
$response = print_r($var, true);
|
||||
}elseif($command === "dump")
|
||||
{
|
||||
$response = "Dump" . EOL;
|
||||
$response .= var_export($var, true);
|
||||
}
|
||||
fwrite($spawn, $response);
|
||||
break;
|
||||
default:
|
||||
logger(DEBUG, "not understanding command");
|
||||
fwrite($spawn, "not understanding command");
|
||||
logger(DEBUG, _("unknown command"), __FILE__ . ":" . __LINE__);
|
||||
fwrite($spawn, _("unknown command"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user