-
Notifications
You must be signed in to change notification settings - Fork 9
/
ajax_progress.php
102 lines (96 loc) · 2.47 KB
/
ajax_progress.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?
// ===================================================================
// Sim Roulette -> AJAX
// License: GPL v3 (http://www.gnu.org/licenses/gpl.html)
// Copyright (c) 2016-2022 Xzero Systems, http://sim-roulette.com
// Author: Nikita Zabelin
// ===================================================================
include("_func.php");
if ($_GET['action'])
{
if ($result = mysqli_query($db, "SELECT * FROM `actions` WHERE `id`=".(int)$_GET['action']))
{
if ($row = mysqli_fetch_assoc($result))
{
$p=round($row['progress']/($row['count']/100+0.000001),2);
$e=$row['errors'];
$s=$row['success'];
$pd=$row['progress'];
if ($p>100){$p=100;}
$access=flagGet($row['device'],'answer',1);
// $access=file_get_contents($GLOBALS['root'].'flags/answer_'.$row['device']);
if ($access+30<time()){$o='Offline';$t=': '.time_calc(time()-$access);} else {$o='Online';$t='';}
if ($row['status']=='inprogress')
{
$m='<em>Задача выполняется...</em>';
}
}
else
{
$p=100;
}
}
echo $p.';'.$m.';'.$pd.';'.$e.';'.$s.';'.$o.';'.$t;
}
else
{
$txt='';
$actions=';'.$_GET['actions'].';';
$a=explode(';',$_GET['actions']);
for ($i=0;$i<count($a);$i++){$a[$i]=(int)$a[$i];}
if ($result = mysqli_query($db, "SELECT * FROM `actions` WHERE `id` IN (".implode(',',$a).")"))
{
while ($row = mysqli_fetch_assoc($result))
{
$actions=str_replace(';'.$row['id'].';',';',$actions);
$p=round($row['progress']/($row['count']/100+0.000001),2);
if ($p>100){$p=100;}
$e=$row['errors'];
$s=$row['success'];
$pd=$row['progress'];
$access=flagGet($row['device'],'answer',1);
if ($access+30<time()){$o='Offline';$t=': '.time_calc(time()-$access);} else {$o='Online';$t='';}
$el=time_calc(time()-$row['time']);
if ($row['progress'])
{
$lt=time_calc(($row['count']-$row['progress'])*((time()-$row['time'])/$row['progress']));
}
else
{
$lt='∞';
}
$txt.=$row['id'].';'.$p.';'.$pd.';'.$e.';'.$s.';'.$o.';'.$t.';'.$el.';'.$lt.';';
if ($row['status']=='inprogress')
{
$txt.='1###';
}
elseif ($row['status']=='suspended')
{
$txt.='2###';
}
elseif ($row['status']=='suspension')
{
$txt.='3###';
}
elseif ($row['status']=='preparing')
{
$txt.='4###';
}
else
{
$txt.='0###';
}
}
}
$actions=trim($actions,';');
if ($actions)
{
$actions=explode(';',$actions);
foreach ($actions AS $key=>$data)
{
$txt.=$data.';100;;;;;;;;1###';
}
}
echo $txt;
}
?>