2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Provides upload functionalities for the import plugins
8 if (! defined('PHPMYADMIN')) {
12 /* Get the transformations interface */
13 require_once 'libraries/plugins/UploadInterface.int.php';
16 * Implementation for session
20 class UploadSession
implements UploadInterface
23 * Gets the specific upload ID Key
25 * @return string ID Key
27 public static function getIdKey()
29 return ini_get('session.upload_progress.name');
33 * Returns upload status.
35 * This is implementation for session.upload_progress in PHP 5.4+.
37 * @param string $id upload id
41 public static function getUploadStatus($id)
45 if (trim($id) == '') {
49 if (! array_key_exists($id, $_SESSION[$SESSION_KEY])) {
50 $_SESSION[$SESSION_KEY][$id] = array(
56 'plugin' => UploadSession
::getIdKey()
59 $ret = $_SESSION[$SESSION_KEY][$id];
61 if (! PMA_import_sessionCheck() ||
$ret['finished']) {
66 $sessionkey = ini_get('session.upload_progress.prefix') . $id;
68 if (isset($_SESSION[$sessionkey])) {
69 $status = $_SESSION[$sessionkey];
73 $ret['finished'] = $status['done'];
74 $ret['total'] = $status['content_length'];
75 $ret['complete'] = $status['bytes_processed'];
77 if ($ret['total'] > 0) {
78 $ret['percent'] = $ret['complete'] / $ret['total'] * 100;
85 'total' => $ret['total'],
86 'complete' => $ret['total'],
87 'plugin' => UploadSession
::getIdKey()
91 $_SESSION[$SESSION_KEY][$id] = $ret;