-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.fr.php
83 lines (73 loc) · 2.07 KB
/
index.fr.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
<?php
require('config.php');
define("UNKNOWN", 0);
define("RUNNING", 1);
define("NOTTODATE", 2);
define("STOPPED", 3);
ob_start();
$arrobj = new ArrayObject($gamegrep);
$it = $arrobj->getIterator();
while ($it->valid())
{
if($it->current() == NULL) {
// If no check defined, put unknown
$status = UNKNOWN;
$rowclass = 'warning';
$imgstatus = '<img width="40" height="40" src="imgs/unknown.png" alt="Inconnu" />';
} else if ( $it->current() != EXTERNAL ) {
// Else If search by process name
$search = shell_exec('ps -ax | grep "' . $it->current() . '"');
$linecount = substr_count($search, "\n");
$status = STOPPED;
$rowclass = 'danger';
$imgstatus = '<img width="40" height="40" src="imgs/ko.png" alt="KO" style="filter: background-color:red;" />';
if($linecount > 2) {
$status = RUNNING;
$imgstatus = '<img width="40" height="40" src="imgs/ok.png" alt="OK" />';
$rowclass = 'success';
}
} else {
// Else (external grep check)
if($gameexternalcheckcommand[$it->key()] == NULL) {
// If no check given, status is UNKNOWN
$status = UNKNOWN;
$rowclass = 'warning';
$imgstatus = '<img width="40" height="40" src="imgs/unknown.png" alt="?" />';
} else {
$search = shell_exec($gameexternalcheckcommand[$it->key()]);
$linecount = substr_count($search, "\n")+2;
$status = STOPPED;
$rowclass = 'danger';
$imgstatus = '<img width="40" height="40" src="imgs/ko.png" alt="KO" style="filter: background-color:red;" />';
if($linecount > 2) {
$status = RUNNING;
$imgstatus = '<img width="40" height="40" src="imgs/ok.png" alt="OK" />';
$rowclass = 'success';
}
}
}
?>
<tr class="<?= $rowclass ?> align-middle">
<td>
<img width="230" height="107" src="<?= $gameimg[$it->key()] ?>" alt="<?= $gamename[$it->key()] ?>" \>
</td>
<td>
<p><?= $gamename[$it->key()] ?></p>
</td>
<td>
<?= $imgstatus ?>
</td>
<td>
<?= $gameaccess[$it->key()] ?>
</t/d>
<td>
<?= $gamepasswd[$it->key()] ?>
</td>
</tr>
<?php
$it->next();
}
// Fill up the template
$content = ob_get_clean();
require('template.fr.php');
?>