-
Notifications
You must be signed in to change notification settings - Fork 0
/
databasetest.php
45 lines (40 loc) · 1.17 KB
/
databasetest.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
<?php
/*
* Copyright (c) 2017 António 'Tó' Godinho <to@isec.pt>.
* Copyright (c) 2018 JP P
* This program is free software; Distributed under the terms of the GNU GPL v3.
*/
# see if database is populated correctly, if not then JS alert to user.
echo "var zzz = 0;";
$query = "SELECT count(id) as res_count FROM alert";
try
{ $stmt = $pdo->prepare($query);
$stmt->execute();
} catch (Exception $e)
{ echo "Alert checking database for informations \n" . $e ." !!";
return;
}
if ($stmt->rowCount() > 0)
{ $row = $stmt->fetch();
if (!$row['res_count'] > 0)
{ echo "alert(\"Connected to database ok, but no alerts found. Ensure OpenArmor is logging to your database.\");";
return;
}
}
$query = "SELECT count(id) as res_count FROM location";
try
{ $stmt = $pdo->prepare($query);
$stmt->execute();
} catch (Exception $e)
{ echo "alert(\"Error on access to location : \" . $e)";
return;
}
if ($stmt->rowCount() > 0)
{ $row = $stmt->fetch();
if (!$row['res_count'] > 0)
{ echo "alert(\"Connected to database ok, but no data found. Ensure OpenArmor is logging to your database.\");";
}
} else
{ echo "alert(\"Problems checking database for information\");";
}
?>