Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / ProgressBar / Upload / SessionProgress.php
blob064acba513879a0e954121c8bee4b02a196824f2
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\ProgressBar\Upload;
12 use Traversable;
13 use Zend\ProgressBar\Exception;
14 use Zend\Stdlib\ArrayUtils;
16 /**
17 * Progress Bar Upload Handler for PHP 5.4+ Session Upload Progress handling
19 class SessionProgress extends AbstractUploadHandler
21 /**
22 * @param string $id
23 * @return array|bool
24 * @throws Exception\PhpEnvironmentException
26 protected function getUploadProgress($id)
28 if (!$this->isSessionUploadProgressAvailable()) {
29 throw new Exception\PhpEnvironmentException(
30 'Session Upload Progress is not available'
34 $sessionKey = ini_get('session.upload_progress.prefix') . $id;
35 $uploadInfo = (isset($_SESSION[$sessionKey])) ? $_SESSION[$sessionKey] : null;
36 if (!is_array($uploadInfo)) {
37 return false;
40 $status = array(
41 'total' => 0,
42 'current' => 0,
43 'rate' => 0,
44 'message' => '',
45 'done' => false,
47 $status = $uploadInfo + $status;
48 $status['total'] = $status['content_length'];
49 $status['current'] = $status['bytes_processed'];
51 $time = time() - $status['start_time'];
52 $status['rate'] = ($time > 0) ? $status['bytes_processed'] / $time : 0;
54 if (!empty($status['cancel_upload'])) {
55 $status['done'] = true;
56 $status['message'] = 'The upload has been canceled';
59 return $status;
62 /**
63 * Checks if Session Upload Progress is available
65 * @return bool
67 public function isSessionUploadProgressAvailable()
69 return (bool) ini_get('session.upload_progress.enabled');