-
Notifications
You must be signed in to change notification settings - Fork 223
/
progress.php
79 lines (79 loc) · 2.08 KB
/
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
<?php
/**
* Updates the progress information
*
* PHP version 5
*
* @category Progress
* @package FOGProject
* @author Tom Elliott <tommygunsster@gmail.com>
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link https://fogproject.org
*/
/**
* Updates the progress information
*
* @category Progress
* @package FOGProject
* @author Tom Elliott <tommygunsster@gmail.com>
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link https://fogproject.org
*/
require '../commons/base.inc.php';
try {
$Host = FOGCore::getHostItem(false);
$Task = $Host->get('task');
$TaskType = new TaskType($Task->get('typeID'));
if (!$Task->isValid()) {
throw new Exception(
sprintf(
'%s: %s (%s)',
_('No Active Task found for Host'),
$Host->get('name'),
$Host->get('mac')->__toString()
)
);
}
$Image = $Task->getImage();
if (!$Image->isValid()) {
throw new Exception(_('Invalid image'));
}
$str = explode('@', base64_decode($_REQUEST['status']));
$imagingTasks = $TaskType->isImagingTask();
if ($imagingTasks) {
if ($str[0]
&& $str[1]
&& $str[2]
&& $str[3]
&& $str[4]
&& $str[5]
) {
$Task->set('bpm', $str[0])
->set('timeElapsed', $str[1])
->set('timeRemaining', $str[2])
->set('dataCopied', $str[3])
->set('dataTotal', $str[4])
->set('percent', trim($str[5]))
->set('pct', trim($str[5]))
->save();
}
$str[6] = trim($str[6]);
if (empty($str[6])) {
return;
}
if (strpos($Image->get('size'), $str[6]) !== false) {
return;
}
$Image->set(
'size',
sprintf(
'%s%s:',
trim($Image->get('size')),
$str[6]
)
)->save();
}
} catch (Exception $e) {
echo $e->getMessage();
}
exit;