Merge branch 'QA_3_3'
[phpmyadmin/dkf.git] / libraries / import / upload / uploadprogress.php
blobce4c4769dd37a55d3ead6e0231db1075841645e8
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @version $Id$
6 * @package phpMyAdmin
7 */
8 if (! defined('PHPMYADMIN')) {
9 exit;
12 $ID_KEY = "UPLOAD_IDENTIFIER";
14 /**
15 * Returns upload status.
17 * This is implementation for uploadprogress extension.
19 function PMA_getUploadStatus($id) {
20 global $SESSION_KEY;
21 global $ID_KEY;
23 if (trim($id) == "") {
24 return;
27 if (! array_key_exists($id, $_SESSION[$SESSION_KEY])) {
28 $_SESSION[$SESSION_KEY][$id] = array(
29 'id' => $id,
30 'finished' => false,
31 'percent' => 0,
32 'total' => 0,
33 'complete' => 0,
34 'plugin' => $ID_KEY
37 $ret = $_SESSION[$SESSION_KEY][$id];
39 if (! PMA_import_uploadprogressCheck() || $ret['finished']) {
40 return $ret;
43 $status = uploadprogress_get_info($id);
45 if ($status) {
46 if ($status['bytes_uploaded'] == $status['bytes_total']) {
47 $ret['finished'] = true;
48 } else {
49 $ret['finished'] = false;
51 $ret['total'] = $status['bytes_total'];
52 $ret['complete'] = $status['bytes_uploaded'];
54 if ($ret['total'] > 0) {
55 $ret['percent'] = $ret['complete'] / $ret['total'] * 100;
57 } else {
58 $ret = array(
59 'id' => $id,
60 'finished' => true,
61 'percent' => 100,
62 'total' => $ret['total'],
63 'complete' => $ret['total'],
64 'plugin' => $ID_KEY
68 $_SESSION[$SESSION_KEY][$id] = $ret;
70 return $ret;