-
Notifications
You must be signed in to change notification settings - Fork 0
/
database.php
executable file
·91 lines (83 loc) · 2.43 KB
/
database.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
<?php
include('includes/controller.php');
$controller = new Controller();
$database = $controller->database();
$conflist=$_GET['conflist'];
$load= sys_getloadavg() ;
if ( $load[0] > 60 )
$refreshTime=120 ;
else
$refreshTime=60 ;
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="refresh" content="<?php echo $refreshTime ;?>">
<title>Database</title>
<style type="text/css">
#databasePrint {
font-size: 100%;
height:100%;
overflow-y:auto;
}
</style>
</head>
<body style="font-family: 'Arial';">
<div id="databasePrint">
<br>
<form name="refresh" id="refresh" method="post" action="./database.php?conflist=<?php if (isset($conflist)) echo
$conflist?>">
<table><tr><td><input type='button' value='Refresh' onclick='this.form.submit()'></td></tr></table>
</form>
<?php
if ( isset($conflist) && ($conflist != "") )
{
//TODO: Discover fields dynamically
$fields = [ 'id', 'name', 'macAddr', 'isconnected', 'firstreg', 'rtcid',
'waitformic', 'question', 'questime',
'questove', 'votefor', 'votefo1', 'votefo2', 'votenum', 'login',
'logout', 'hostname'];
echo "<br><table border='2px'>" ;
echo "<tr>" ;
foreach($fields as $field) {
echo "<th>$field</th>";
}
echo "</tr>" ;
foreach($database->query_assocs("SELECT * FROM ".$conflist) as $data)
{
echo "<tr>" ;
foreach($fields as $field) {
echo "<td>$data[$field]</td>";
}
echo "</tr>" ;
}
echo "</table>" ;
}
?>
<?php
if ( isset($conflist) && ($conflist != "") )
{
$imagetable=$conflist."_images" ;
//TODO: Discover fields dynamically
$fields = ['id', 'name', 'path', 'macAddr', 'date', 'mime'];
echo "<br><table border='2px'>" ;
echo "<tr>" ;
foreach($fields as $field) {
echo "<th>$field</th>";
}
echo "</tr>" ;
foreach($database->query_assocs("SELECT * FROM ".$imagetable) as $data)
{
echo "<tr>" ;
foreach($fields as $field) {
echo "<td>$data[$field]</td>";
}
echo "</tr>" ;
}
echo "</table>" ;
}
?>
</div>
</body>
</html>