-
Notifications
You must be signed in to change notification settings - Fork 0
/
FritzLuaLog.php
68 lines (57 loc) · 1.58 KB
/
FritzLuaLog.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?
include("FritzLuaSession.php");
include("FritzLog.php");
class FritzLuaLog extends FritzLuaSession
{
public function parselogs(object $json, string $ignore) : FritzLog
{
global $logVersion;
$result = new FritzLog(date_default_timezone_get());
if($this->debug)print_r('JSON result =' . var_dump($json));
foreach($json->data->log as $row)
{
$fieldDate = ($logVersion==0) ? ($row[0]) : ($row->date);
$fieldTime = ($logVersion==0) ? ($row[1]) : ($row->time);
$fieldMessage = ($logVersion==0) ? ($row[2]) : ($row->msg);
$fieldId = ($logVersion==0) ? ($row[3]) : ($row->id);
$fieldCategory = ($logVersion==0) ? ($row[4]) : ($row->group);
$datetime= str_replace('.','-',substr($fieldDate,0,6).'20'.substr($fieldDate,-2)) . ' ' . $fieldTime . '.000'; // this will be bad in 2099, idc tbh
$dt = new DateTime($datetime, new DateTimeZone(date_default_timezone_get()));
if (strlen($ignore)>0)
{
if(str_starts_with($fieldMessage, $ignore) || str_starts_with($datetime, '2070-'))
{
;
}
else
{
$result->add($dt, $fieldCategory, (int)$fieldId, $fieldMessage);
}
}
else
{
$result->add($dt, $fieldCategory, (int)$fieldId, $fieldMessage);
}
}
return $result;
}
public function getlogs(string $ignore="")
{
$postvars = ["xhr1" => "1",
"sid" => $this->sid,
"lang" => "en",
"page" => "log",
"xhrId" => "all",
];
$json = $this->postDataRequest($postvars);
if ($json!==FALSE)
{
return $this->parselogs($json, $ignore);
}
else
{
return $json;
}
}
}
?>