Merge branch 'QA_3_3'
[phpmyadmin/dkf.git] / libraries / import / upload / apc.php
blob6b50aeb2a119da1552a42a66f408c19440e4ef48
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @version $Id$
6 * @package phpMyAdmin
7 */
9 if (! defined('PHPMYADMIN')) {
10 exit;
13 $ID_KEY = 'APC_UPLOAD_PROGRESS';
15 /**
16 * Returns upload status.
18 * This is implementation for APC extension.
20 function PMA_getUploadStatus($id) {
21 global $SESSION_KEY;
22 global $ID_KEY;
24 if (trim($id) == "") {
25 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_apcCheck() || $ret['finished']) {
40 return $ret;
42 $status = apc_fetch('upload_' . $id);
44 if ($status) {
45 $ret['finished'] = (bool)$status['done'];
46 $ret['total'] = $status['total'];
47 $ret['complete'] = $status['current'];
49 if ($ret['total'] > 0) {
50 $ret['percent'] = $ret['complete'] / $ret['total'] * 100;
53 if ($ret['percent'] == 100) {
54 $ret['finished'] = (bool)true;
57 $_SESSION[$SESSION_KEY][$id] = $ret;
60 return $ret;