-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathedit_person.php
96 lines (81 loc) · 3.26 KB
/
edit_person.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
$directaccess = true;
error_reporting(E_ALL ^ (E_NOTICE | E_WARNING));
require("config.php");
$r_id = (string)$_POST['id'];
$r_action= (string)$_POST['action'];
$r_name = (string)$_POST['name'];
$r_pingto = (string)$_POST['ip'];
$r_theme = (string)$_POST['theme'];
$r_theme_bg = (string)$_POST['theme_bg'];
$r_ShowSettingsMenue = (string)$_POST['ShowSettingsMenue'];
$r_ShowFBdect200EnergyData = (string)$_POST['ShowFBdect200EnergyData'];
$r_AutoRefreshDeviceData = (string)$_POST['AutoRefreshDeviceData'];
$r_IndoorTempSource = (string)$_POST['IndoorTempSource'];
$r_favoritgroups = $_POST['favoritgroups'];
$r_favoritactions = $_POST['favoritactions'];
$r_favoritdevices = $_POST['favoritdevices'];
switch ($r_action) {
case "add":
$newid=1;
foreach($xml->persons->person as $person) {
$oldid=(integer)$person->id;
if($oldid >= $newid) {
$newid = $oldid + 1;
}
}
$r_favoritdevices = implode(",", $r_favoritdevices);
$r_favoritgroups = implode(",", $r_favoritgroups);
$r_favoritactions = implode(",", $r_favoritactions);
$newdevice = $xml->persons->addChild('person');
$newdevice->addChild('id', $newid);
$newdevice->addChild('name', $r_name);
$newdevice->addChild('pingto', $r_pingto);
$newdevice->addChild('theme', $r_theme);
$newdevice->addChild('theme_bg', $r_theme_bg);
$newdevice->addChild('ShowSettingsMenue', $r_ShowSettingsMenue);
$newdevice->addChild('ShowFBdect200EnergyData', $r_ShowFBdect200EnergyData);
$newdevice->addChild('AutoRefreshDeviceData', $r_AutoRefreshDeviceData);
$newdevice->addChild('IndoorTempSource', $r_IndoorTempSource);
$newdevice->addChild('favoritgroups', $r_favoritgroups);
$newdevice->addChild('favoritactions', $r_favoritactions);
$newdevice->addChild('favoritdevices', $r_favoritdevices);
echo "ok";
config_save();
break;
case "edit":
$xpath='//person/id[.="'.$r_id.'"]/parent::*';
$res = $xml->xpath($xpath);
$parent = $res[0];
$r_favoritdevices = implode(",", $r_favoritdevices);
$r_favoritgroups = implode(",", $r_favoritgroups);
$r_favoritactions = implode(",", $r_favoritactions);
$parent[0]->id = $r_id;
$parent[0]->name = $r_name;
$parent[0]->pingto = $r_pingto;
if ($r_pingto == "") $parent[0]->status = "";
$parent[0]->theme = $r_theme;
$parent[0]->theme_bg = $r_theme_bg;
$parent[0]->ShowSettingsMenue = $r_ShowSettingsMenue;
$parent[0]->ShowFBdect200EnergyData = $r_ShowFBdect200EnergyData;
$parent[0]->AutoRefreshDeviceData = $r_AutoRefreshDeviceData;
$parent[0]->IndoorTempSource = $r_IndoorTempSource;
$parent[0]->favoritgroups = $r_favoritgroups;
$parent[0]->favoritactions = $r_favoritactions;
$parent[0]->favoritdevices = $r_favoritdevices;
echo "ok";
config_save();
break;
case "delete":
$xpath='//person/id[.="'.$r_id.'"]/parent::*';
$res = $xml->xpath($xpath);
$parent = $res[0];
unset($parent[0]);
echo "ok";
config_save();
break;
default:
echo "unsupported";
break;
}
?>