This repository was archived by the owner on Mar 10, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstate.inc.php
More file actions
62 lines (56 loc) · 1.49 KB
/
state.inc.php
File metadata and controls
62 lines (56 loc) · 1.49 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
<?php
/**
* Include file for state operations
*
* @since 0.1
* @author MekDrop <github@mekdrop.name>
*/
require_once 'func.func.php';
switch (@$_REQUEST['action']) {
case 'start':
if (auto_access_denied())
return;
exec($config['app_command']);
header('location: ?site=state');
die();
break;
case 'stop':
if (auto_access_denied())
return;
$pid = intval(file_get_contents($objBipConfigManager->vars['pid_file']));
system('kill ' . $pid, $rez);
header('location: ?site=state');
die();
break;
case 'restart':
if (auto_access_denied())
return;
$pid = intval(file_get_contents($objBipConfigManager->vars['pid_file']));
system('kill ' . $pid, $rez);
header('location: ?site=state&action=start');
die();
break;
}
echo "<b>Current state:</b> ";
$is_running = false;
if (file_exists($objBipConfigManager->vars['pid_file'])) {
ob_start();
$pid = intval(file_get_contents($objBipConfigManager->vars['pid_file']));
$lpid = intval(trim(system('ps ' . $pid, $retval)));
$is_running = $pid == $lpid;
ob_end_clean();
}
if ($is_running) {
echo 'running';
if ($_SESSION['is_admin']) {
br(2);
action_button('stop', 'Stop');
action_button('restart', 'Restart');
}
} else {
echo 'stopped';
if ($_SESSION['is_admin']) {
br(2);
action_button('start', 'Start');
}
}