Advisor: mark that 'Rate of reading fixed position' may be wrong, requires further...
[phpmyadmin/thilanka.git] / libraries / import / upload / apc.php
blob5fe34bb2206d82f9352c3cc283f405b71d16aaf3
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @package phpMyAdmin
6 */
8 if (! defined('PHPMYADMIN')) {
9 exit;
12 $ID_KEY = 'APC_UPLOAD_PROGRESS';
14 /**
15 * Returns upload status.
17 * This is implementation for APC extension.
19 * @param string $id
20 * @return array|null
22 function PMA_getUploadStatus($id)
24 global $SESSION_KEY;
25 global $ID_KEY;
27 if (trim($id) == "") {
28 return null;
30 if (! array_key_exists($id, $_SESSION[$SESSION_KEY])) {
31 $_SESSION[$SESSION_KEY][$id] = array(
32 'id' => $id,
33 'finished' => false,
34 'percent' => 0,
35 'total' => 0,
36 'complete' => 0,
37 'plugin' => $ID_KEY
40 $ret = $_SESSION[$SESSION_KEY][$id];
42 if (! PMA_import_apcCheck() || $ret['finished']) {
43 return $ret;
45 $status = apc_fetch('upload_' . $id);
47 if ($status) {
48 $ret['finished'] = (bool)$status['done'];
49 $ret['total'] = $status['total'];
50 $ret['complete'] = $status['current'];
52 if ($ret['total'] > 0) {
53 $ret['percent'] = $ret['complete'] / $ret['total'] * 100;
56 if ($ret['percent'] == 100) {
57 $ret['finished'] = (bool)true;
60 $_SESSION[$SESSION_KEY][$id] = $ret;
63 return $ret;