Esempio n. 1
0
function upload_info($uploadId, $callback = 'updateProgressMeter')
{
    $objResponse = new xajaxResponse();
    $uploadInfo = upload_progress_meter_get_info($uploadId);
    $objResponse->call($callback, $uploadInfo);
    return $objResponse;
}
Esempio n. 2
0
 function compose($o)
 {
     if ($this->get->id) {
         $this->expires = 'onmaxage';
         Patchwork::setPrivate();
         if (function_exists('upload_progress_meter_get_info')) {
             $o = (object) @upload_progress_meter_get_info($this->get->id);
         } else {
             if (function_exists('uploadprogress_get_info')) {
                 $o = (object) @uploadprogress_get_info($this->get->id);
             }
         }
     } else {
         $this->maxage = -1;
     }
     return $o;
 }
 /**
  * Get the status of all uploads passed in
  */
 function getStatus($ids)
 {
     $ret = array();
     foreach ($ids as $id => $upId) {
         $ret[$id] = new stdClass();
         if (!function_exists('upload_progress_meter_get_info')) {
             $ret[$id]->message = "In Progress";
             $ret[$id]->percent = "10";
             $ret[$id]->noStatus = true;
             return $ret;
         }
         $tmp = upload_progress_meter_get_info($upId);
         if (!is_array($tmp)) {
             sleep(1);
             $tmp = upload_progress_meter_get_info($upId);
             if (!is_array($tmp)) {
                 $ret[$id]->message = "Upload Complete";
                 $ret[$id]->percent = "100";
                 return $ret;
             }
         }
         if ($tmp['bytes_total'] < 1) {
             $percent = 100;
         } else {
             $percent = round($tmp['bytes_uploaded'] / $tmp['bytes_total'] * 100, 2);
         }
         if ($percent == 100) {
             $ret[$id]->message = "Complete";
         }
         $eta = sprintf("%02d:%02d", $tmp['est_sec'] / 60, $tmp['est_sec'] % 60);
         $speed = $this->_formatBytes($tmp['speed_average']);
         $current = $this->_formatBytes($tmp['bytes_uploaded']);
         $total = $this->_formatBytes($tmp['bytes_total']);
         $ret[$id]->message = "{$eta} left (at {$speed}/sec)\t{$current}/{$total}({$percent}%)";
         $ret[$id]->percent = $percent;
     }
     return $ret;
 }
function upload_info($uploadId, $i, $callback = 'updateProgressMeter')
{
    $objResponse = new xajaxResponse();
    if (function_exists("upload_progress_meter_get_info")) {
        $uploadInfo = upload_progress_meter_get_info($uploadId);
        $objResponse->call($callback, $uploadInfo, $i);
    }
    return $objResponse;
}
Esempio n. 5
0
    }
    return sprintf("%.2fMB", $bytes / 1000 / 1000);
}
$data = array('status' => 0, 'msg' => '', 'progress' => 0, 'time' => '', 'size' => '');
if (isset($_POST['upload_id'])) {
    $filter = new VFilter();
    $upload_id = $filter->get('upload_id');
    if (!$upload_id) {
        $data['msg'] = 'Upload is not a valid upload!';
    } else {
        $progress = NULL;
        if (function_exists('uploadprogress_get_info')) {
            $progress = uploadprogress_get_info($upload_id);
            $data['status'] = 1;
        } elseif (function_exists('upload_progress_meter_get_info')) {
            $progress = upload_progress_meter_get_info($upload_id);
            $data['status'] = 1;
        } else {
            $data['status'] = 3;
        }
        if ($progress) {
            $meter = sprintf("%.2f", $progress['bytes_uploaded'] / $progress['bytes_total'] * 100);
            $speed_last = $progress['speed_last'];
            $speed = $speed_last < 10000 ? sprintf("%.2f", $speed_last / 1000) : sprintf("%d", $speed_last / 1000);
            $eta = sprintf("%02d:%02d", $progress['est_sec'] / 60, $progress['est_sec'] % 60);
            $uploaded = format_size($progress['bytes_uploaded']);
            $total = format_size($progress['bytes_total']);
            $data['progress'] = $meter;
            $data['time'] = $eta . ' left (at ' . $speed . 'KB/sec)';
            $data['size'] = $uploaded . '/' . $total . '(' . $meter . '%)';
            if ($progress['bytes_total'] > 1 && $progress['bytes_uploaded'] >= $progress['bytes_total'] && $progress['est_sec'] == 0) {
Esempio n. 6
0
}
$url = 'progress.php?UPLOAD_IDENTIFIER=' . $_GET["UPLOAD_IDENTIFIER"] . '&e=1';
function nice_value($x)
{
    if ($x < 100) {
        return $x;
    }
    if ($x < 10000) {
        return sprintf("%.2fKB", $x / 1000);
    }
    if ($x < 900000) {
        return sprintf("%dKB", $x / 1000);
    }
    return sprintf("%.2fMB", $x / 1000 / 1000);
}
$X = upload_progress_meter_get_info($_GET["UPLOAD_IDENTIFIER"]);
if (!$X) {
    if (array_key_exists("e", $_GET)) {
        echo "<HTML><BODY onLoad='window.close();'>" . gettext("Invalid Meter ID") . "! {$_GET["UPLOAD_IDENTIFIER"]}";
        echo '</BODY></HTML>';
    } else {
        echo '<HTML><meta HTTP-EQUIV="Refresh" CONTENT="1; url=' . $url . '"><BODY></BODY></HTML>';
    }
    exit;
} else {
    $meter = sprintf("%.2f", $X['bytes_uploaded'] / $X['bytes_total'] * 100);
    $sp = $X['speed_last'];
    if ($sp < 10000) {
        $speed = sprintf("%.2f", $sp / 1000);
    } else {
        $speed = sprintf("%d", $sp / 1000);