Upgraded phpmyadmin to 4.0.4 (All Languages) - No modifications yet
[openemr.git] / phpmyadmin / libraries / plugins / import / upload / UploadApc.class.php
blob881832fda172641d88c5da66c6f75a2e5379c39b
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Provides upload functionalities for the import plugins
6 * @package PhpMyAdmin
7 */
8 if (! defined('PHPMYADMIN')) {
9 exit;
12 /* Get the transformations interface */
13 require_once 'libraries/plugins/UploadInterface.int.php';
15 /**
16 * Implementation for the APC extension
18 * @package PhpMyAdmin
20 class UploadApc implements UploadInterface
22 /**
23 * Gets the specific upload ID Key
25 * @return string ID Key
27 public static function getIdKey()
29 return 'APC_UPLOAD_PROGRESS';
32 /**
33 * Returns upload status.
35 * This is implementation for APC extension.
37 * @param string $id upload id
39 * @return array|null
41 public static function getUploadStatus($id)
43 global $SESSION_KEY;
45 if (trim($id) == "") {
46 return null;
48 if (! array_key_exists($id, $_SESSION[$SESSION_KEY])) {
49 $_SESSION[$SESSION_KEY][$id] = array(
50 'id' => $id,
51 'finished' => false,
52 'percent' => 0,
53 'total' => 0,
54 'complete' => 0,
55 'plugin' => UploadApc::getIdKey()
58 $ret = $_SESSION[$SESSION_KEY][$id];
60 if (! PMA_import_apcCheck() || $ret['finished']) {
61 return $ret;
63 $status = apc_fetch('upload_' . $id);
65 if ($status) {
66 $ret['finished'] = (bool)$status['done'];
67 $ret['total'] = $status['total'];
68 $ret['complete'] = $status['current'];
70 if ($ret['total'] > 0) {
71 $ret['percent'] = $ret['complete'] / $ret['total'] * 100;
74 if ($ret['percent'] == 100) {
75 $ret['finished'] = (bool)true;
78 $_SESSION[$SESSION_KEY][$id] = $ret;
81 return $ret;