-
Notifications
You must be signed in to change notification settings - Fork 3
/
cron.php
45 lines (39 loc) · 878 Bytes
/
cron.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
/**
* Created by PhpStorm.
* User: Azathoth
* Date: 11. 5. 2016
* Time: 19:11
*/
$interval = 60; //in seconds
while (true) {
sleep($interval);
$string = file_get_contents('www/cron.txt');
if ($string == '') {
continue;
}
$locked = file_get_contents('www/running.txt');
if ($locked != '') {
continue;
}
if ( ! isConnectedToInternet()) {
echo 'connection to internet lost' . PHP_EOL;
continue;
}
$datetime = new DateTime($string);
$difference = (new DateTime())->getTimestamp() - $datetime->getTimestamp(); //in seconds
echo $difference . PHP_EOL;
if ($difference < 0) {
continue;
}
$output = shell_exec('php www/index.php bot:queue --debug-mode');
echo $output . PHP_EOL;
}
function isConnectedToInternet() {
$connected = @fsockopen('www.google.com', 80);
if ($connected) {
fclose($connected);
return true;
}
return false;
}