forked from Plecebo/newznab-tmux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_binaries.php
59 lines (47 loc) · 1.3 KB
/
update_binaries.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
<?php
require(dirname(__FILE__)."/config.php");
require_once(WWW_DIR."/lib/groups.php");
require_once(WWW_DIR."/lib/binaries.php");
require_once(dirname(__FILE__)."/../test/ColorCLI.php");
$time = TIME();
$c = new ColorCLI();
if (isset($argv[1]))
{
$group = $argv[1];
echo $c->header("Updating group {$group}");
$g = new Groups;
$group = $g->getByName($group);
$bin = new Binaries;
$bin->updateGroup(null, $group);
}
else
{
$binaries = new Binaries;
$binaries->updateAllGroups();
}
function relativeTime($_time) {
$d[0] = array(1,"sec");
$d[1] = array(60,"min");
$d[2] = array(3600,"hr");
$d[3] = array(86400,"day");
$d[4] = array(31104000,"yr");
$w = array();
$return = "";
$now = TIME();
$diff = ($now-$_time);
$secondsLeft = $diff;
for($i=4;$i>-1;$i--)
{
$w[$i] = intval($secondsLeft/$d[$i][0]);
$secondsLeft -= ($w[$i]*$d[$i][0]);
if($w[$i]!=0)
{
//$return.= abs($w[$i]). " " . $d[$i][1] . (($w[$i]>1)?'s':'') ." ";
$return.= $w[$i]. " " . $d[$i][1] . (($w[$i]>1)?'s':'') ." ";
}
}
//$return .= ($diff>0)?"ago":"left";
return $return;
}
echo $c->header("Group update process completed in: " .relativeTime($time). "\n");
?>