-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patheditnode.php
More file actions
77 lines (74 loc) · 1.96 KB
/
editnode.php
File metadata and controls
77 lines (74 loc) · 1.96 KB
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
<?
include 'config.php';
$id = $_GET['id'];
$return = $_GET['return'];
$cmd = $_GET['cmd'];
$name = $_GET['name'];
$host = $_GET['host'];
$x = $_GET['x'];
$y = $_GET['y'];
$db = new SQLite3("$webroot/dbdir/db");
$message = "";
$result = true;
if ($cmd == "Save") {
if ($id) {
$result = $db->exec("update node set name='$name', host='$host', x=$x, y=$y where id=$id");
} else {
$db->exec("insert into node(name, host, x, y) values('$name', '$host', $x, $y)");
}
if ($result) {
if ($return) {
header("Location: $return");
} else {
header("Location: editnode.php?id=$id");
}
} else {
$message = "Could not save";
}
} elseif ($cmd == "Delete") {
$result1 = $db->exec("delete from node where id=$id");
$result2 = $db->exec("delete from rel where srcNode=$id or destNode=$id");
$result = $result1 && $result2;
if ($result) {
if ($return) {
header("Location: $return");
} else {
header("Location: deletemessage.php?id=$id&name=$name");
}
} else {
$message = "Could not delete";
}
} elseif ($cmd == "Cancel") {
if ($return) {
header("Location: $return");
}
}
if ($id && $result) {
$result = $db->query("select * from node where id=".$id);
if ($row = $result->fetchArray()) {
$id = $row['id'];
$name = $row['name'];
$host = $row['host'];
$x = $row['x'];
$y = $row['y'];
}
}
?>
<html>
<body>
<h3><?=$message?></h3>
<form action="#" method="get">
<? if ($id) { ?>
<input type="hidden" name="id" value="<?=$id?>"/>
<? } ?>
<input type="hidden" name="return" value="<?=$return?>"/>
<table>
<tr><td>name:</td><td><input name="name" value="<?=$name?>"/></td></tr>
<tr><td>host:</td><td><input name="host" value="<?=$host?>"/></td></tr>
<tr><td>x:</td><td><input name="x" value="<?=$x?>"/></td></tr>
<tr><td>y:</td><td><input name="y" value="<?=$y?>"/></td></tr>
<tr><td colspan="2"><input type="submit" name="cmd" value="Save">
<input type="submit" name="cmd" value="Delete">
<input type="submit" name="cmd" value="Cancel"></td></tr>
</table>
</form>