"Fossies" - the Fresh Open Source Software Archive

Member "fogproject-1.5.9/packages/web/service/progress.php" (13 Sep 2020, 2171 Bytes) of package /linux/misc/fogproject-1.5.9.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "progress.php" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 1.5.8_vs_1.5.9.

    1 <?php
    2 /**
    3  * Updates the progress information
    4  *
    5  * PHP version 5
    6  *
    7  * @category Progress
    8  * @package  FOGProject
    9  * @author   Tom Elliott <tommygunsster@gmail.com>
   10  * @license  http://opensource.org/licenses/gpl-3.0 GPLv3
   11  * @link     https://fogproject.org
   12  */
   13 /**
   14  * Updates the progress information
   15  *
   16  * @category Progress
   17  * @package  FOGProject
   18  * @author   Tom Elliott <tommygunsster@gmail.com>
   19  * @license  http://opensource.org/licenses/gpl-3.0 GPLv3
   20  * @link     https://fogproject.org
   21  */
   22 require '../commons/base.inc.php';
   23 try {
   24     FOGCore::getHostItem(false);
   25     $Task = FOGCore::$Host->get('task');
   26     $TaskType = new TaskType($Task->get('typeID'));
   27     if (!$Task->isValid()) {
   28         throw new Exception(
   29             sprintf(
   30                 '%s: %s (%s)',
   31                 _('No Active Task found for Host'),
   32                 FOGCore::$Host->get('name'),
   33                 FOGCore::$Host->get('mac')->__toString()
   34             )
   35         );
   36     }
   37     $Image = $Task->getImage();
   38     if (!$Image->isValid()) {
   39         throw new Exception(_('Invalid image'));
   40     }
   41     $str = explode('@', base64_decode($_REQUEST['status']));
   42     $imagingTasks = $TaskType->isImagingTask();
   43     if ($imagingTasks) {
   44         if ($str[0]
   45             && $str[1]
   46             && $str[2]
   47             && $str[3]
   48             && $str[4]
   49             && $str[5]
   50         ) {
   51             $Task->set('bpm', $str[0])
   52                 ->set('timeElapsed', $str[1])
   53                 ->set('timeRemaining', $str[2])
   54                 ->set('dataCopied', $str[3])
   55                 ->set('dataTotal', $str[4])
   56                 ->set('percent', trim($str[5]))
   57                 ->set('pct', trim($str[5]))
   58                 ->save();
   59         }
   60         $str[6] = trim($str[6]);
   61         if (empty($str[6]) || !$Task->isCapture()) {
   62             exit;
   63         }
   64         if (strpos($Image->get('size'), $str[6]) !== false) {
   65             return;
   66         }
   67         $Image->set(
   68             'size',
   69             sprintf(
   70                 '%s%s:',
   71                 trim($Image->get('size')),
   72                 $str[6]
   73             )
   74         )->save();
   75     }
   76 } catch (Exception $e) {
   77     echo $e->getMessage();
   78 }
   79 exit;