forked from jimmykane/The-Three-Little-Pigs-Siri-Proxy
/
functions.inc.php
78 lines (68 loc) · 1.85 KB
/
functions.inc.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
<?php
function getkeys() {
extract($GLOBALS);
$query = "SELECT * FROM `keys` WHERE expired='False'";
$result = $db->MakeQuery($query);
$available_keys_count = $db->GetRecordCount($result);
if ($available_keys_count > 0) {
$keys = $db->GetResultAsArray($result);
$keys[0]['availablekeys'] = $available_keys_count;
return $keys;
}
return false;
}
function getexpiredkeys() {
extract($GLOBALS);
$query = "SELECT * FROM `keys` WHERE expired='True'";
$result = $db->MakeQuery($query);
$available_keys_count = $db->GetRecordCount($result);
if ($available_keys_count > 0) {
$keys = $db->GetResultAsArray($result);
$keys[0]['expiredkeys'] = $available_keys_count;
return $keys;
}
return false;
}
function getconfig() {
extract($GLOBALS);
$query = "SELECT * FROM `config` WHERE id=1 ";
$result = $db->MakeQuery($query);
$config = $db->GetRecord($result);
return $config;
}
function ismac() {
$cmd = "uname";
exec($cmd, $output);
if ($output = "darwin") {
return true;
}
return false;
}
function checkServer() {
$isrunningmac = ismac();
if ($isrunningmac = true) {
$cmd = "ps aux < /dev/null | grep siriproxy";
exec($cmd, $output, $result);
if (count($output) >= 3) {
return true;
}
$cmd = "ps aux < /dev/null | grep ruby";
exec($cmd, $output2, $result);
if (count($output2) >= 3) {
return true;
}
return false;
}
$cmd = "ps -C siriproxy";
exec($cmd, $output, $result);
if (count($output) >= 2) {
return true;
}
$cmd = "ps -C ruby";
exec($cmd, $output2, $result);
if (count($output2) >= 2) {
return true;
}
return false;
}
?>