typo
[phpmyadmin/arisferyanto.git] / libraries / import / upload / uploadprogress.php
blobb1530a90d53001eb9c86cfcb000fb1c1680a617c
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 function PMA_getUploadStatus($id) {
15 global $SESSION_KEY;
16 global $ID_KEY;
18 if (trim($id) == "") {
19 return;
22 if (! array_key_exists($id, $_SESSION[$SESSION_KEY])) {
23 $_SESSION[$SESSION_KEY][$id] = array(
24 'id' => $id,
25 'finished' => false,
26 'percent' => 0,
27 'total' => 0,
28 'complete' => 0,
29 'plugin' => $ID_KEY
32 $ret = $_SESSION[$SESSION_KEY][$id];
34 if (! PMA_import_uploadprogressCheck() || $ret['finished']) {
35 return $ret;
38 $status = uploadprogress_get_info($id);
40 if ($status) {
41 if ($status['bytes_uploaded'] == $status['bytes_total']) {
42 $ret['finished'] = true;
43 } else {
44 $ret['finished'] = false;
46 $ret['total'] = $status['bytes_total'];
47 $ret['complete'] = $status['bytes_uploaded'];
49 if ($ret['total'] > 0) {
50 $ret['percent'] = $ret['complete'] / $ret['total'] * 100;
52 } else {
53 $ret = array(
54 'id' => $id,
55 'finished' => true,
56 'percent' => 100,
57 'total' => $ret['total'],
58 'complete' => $ret['total'],
59 'plugin' => $ID_KEY
63 $_SESSION[$SESSION_KEY][$id] = $ret;
65 return $ret;