-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcron.php
More file actions
executable file
·66 lines (48 loc) · 2.09 KB
/
cron.php
File metadata and controls
executable file
·66 lines (48 loc) · 2.09 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
63
64
65
66
<?php
require 'config.php';
require 'functions.php';
if(!$aGlobalConfig['cron']['enableWebAccess'])
die("The website administrator has disabled cron triggers through the URL.");
cronPrint('WebTSS cron running..');
$webTSSRoot = realpath(dirname(__FILE__));
$mysqli = new mysqli($aGlobalConfig['database']['host'], $aGlobalConfig['database']['username'], $aGlobalConfig['database']['password'], $aGlobalConfig['database']['database']);
$tssPermissions = substr(sprintf('%o', fileperms($webTSSRoot.'/tss')), -4);
if(!is_dir($webTSSRoot.'/tss'))
die('Please create the directory "'.$webTSSRoot.'/tss'.'"..');
if(!is_writable($webTSSRoot.'/tss'))
die('Can\'t write to "'.$webTSSRoot.'/tss"..');
if(!is_readable($webTSSRoot.'/tss'))
die('Can\'t read "'.$webTSSRoot.'/tss"..');
if(!is_dir($webTSSRoot.'/bins'))
die('Please create the directory "'.$webTSSRoot.'/bins"..');
if(!is_readable($webTSSRoot.'/bins'))
die('Can\'t read "'.$webTSSRoot.'/bins"..');
if (mysqli_connect_errno())
die('Can\'t connect to the database..');
if ($stmt = $mysqli->prepare("SELECT ecid, platform FROM devices")) {
/* execute statement */
$stmt->execute();
/* bind result variables */
$stmt->bind_result($ecid, $platform);
/* fetch values */
while ($stmt->fetch()) {
cronPrint("Working on $ecid ($platform)..");
$command = $aGlobalConfig['cron']['python2.7Location'].' '.$webTSSRoot.'/bins/savethemblobs.py '.hexdec($ecid).' '.$platform.' --skip-cydia --skip-ifaith --save-dir '.$webTSSRoot.'/tss/'.hexdec($ecid);
if(!is_dir($webTSSRoot.'/tss/'.hexdec($ecid))) {
cronPrint("Creating \"".$webTSSRoot.'/tss/'.hexdec($ecid)."\"..");
mkdir($webTSSRoot.'/tss/'.hexdec($ecid));
}
if(!is_readable($webTSSRoot.'/tss/'.hexdec($ecid)) || !is_writable($webTSSRoot.'/tss/'.hexdec($ecid))) {
cronPrint('Can\'t read and/or write to "'.$webTSSRoot.'/tss/'.hexdec($ecid).'"..');
} else {
cronPrint("Running \"$command\"..");
shell_exec($command);
}
}
/* close statement */
$stmt->close();
}
/* close connection */
$mysqli->close();
cronPrint('Cron finished.');
?>