3.4.0-rc1
[phpmyadmin/thilanka.git] / libraries / import / upload / apc.php
blob79d435bafb30ab95c681126af92357dc62815b8a
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 function PMA_getUploadStatus($id) {
20 global $SESSION_KEY;
21 global $ID_KEY;
23 if (trim($id) == "") {
24 return;
26 if (! array_key_exists($id, $_SESSION[$SESSION_KEY])) {
27 $_SESSION[$SESSION_KEY][$id] = array(
28 'id' => $id,
29 'finished' => false,
30 'percent' => 0,
31 'total' => 0,
32 'complete' => 0,
33 'plugin' => $ID_KEY
36 $ret = $_SESSION[$SESSION_KEY][$id];
38 if (! PMA_import_apcCheck() || $ret['finished']) {
39 return $ret;
41 $status = apc_fetch('upload_' . $id);
43 if ($status) {
44 $ret['finished'] = (bool)$status['done'];
45 $ret['total'] = $status['total'];
46 $ret['complete'] = $status['current'];
48 if ($ret['total'] > 0) {
49 $ret['percent'] = $ret['complete'] / $ret['total'] * 100;
52 if ($ret['percent'] == 100) {
53 $ret['finished'] = (bool)true;
56 $_SESSION[$SESSION_KEY][$id] = $ret;
59 return $ret;