summaryrefslogtreecommitdiff
path: root/hugo/libraries/plugins/import/upload
diff options
context:
space:
mode:
Diffstat (limited to 'hugo/libraries/plugins/import/upload')
-rw-r--r--hugo/libraries/plugins/import/upload/UploadApc.class.php84
-rw-r--r--hugo/libraries/plugins/import/upload/UploadNoplugin.class.php64
-rw-r--r--hugo/libraries/plugins/import/upload/UploadProgress.class.php94
-rw-r--r--hugo/libraries/plugins/import/upload/UploadSession.class.php96
4 files changed, 338 insertions, 0 deletions
diff --git a/hugo/libraries/plugins/import/upload/UploadApc.class.php b/hugo/libraries/plugins/import/upload/UploadApc.class.php
new file mode 100644
index 0000000..881832f
--- /dev/null
+++ b/hugo/libraries/plugins/import/upload/UploadApc.class.php
@@ -0,0 +1,84 @@
+<?php
+/* vim: set expandtab sw=4 ts=4 sts=4: */
+/**
+ * Provides upload functionalities for the import plugins
+ *
+ * @package PhpMyAdmin
+ */
+if (! defined('PHPMYADMIN')) {
+ exit;
+}
+
+/* Get the transformations interface */
+require_once 'libraries/plugins/UploadInterface.int.php';
+
+/**
+ * Implementation for the APC extension
+ *
+ * @package PhpMyAdmin
+ */
+class UploadApc implements UploadInterface
+{
+ /**
+ * Gets the specific upload ID Key
+ *
+ * @return string ID Key
+ */
+ public static function getIdKey()
+ {
+ return 'APC_UPLOAD_PROGRESS';
+ }
+
+ /**
+ * Returns upload status.
+ *
+ * This is implementation for APC extension.
+ *
+ * @param string $id upload id
+ *
+ * @return array|null
+ */
+ public static function getUploadStatus($id)
+ {
+ global $SESSION_KEY;
+
+ if (trim($id) == "") {
+ return null;
+ }
+ if (! array_key_exists($id, $_SESSION[$SESSION_KEY])) {
+ $_SESSION[$SESSION_KEY][$id] = array(
+ 'id' => $id,
+ 'finished' => false,
+ 'percent' => 0,
+ 'total' => 0,
+ 'complete' => 0,
+ 'plugin' => UploadApc::getIdKey()
+ );
+ }
+ $ret = $_SESSION[$SESSION_KEY][$id];
+
+ if (! PMA_import_apcCheck() || $ret['finished']) {
+ return $ret;
+ }
+ $status = apc_fetch('upload_' . $id);
+
+ if ($status) {
+ $ret['finished'] = (bool)$status['done'];
+ $ret['total'] = $status['total'];
+ $ret['complete'] = $status['current'];
+
+ if ($ret['total'] > 0) {
+ $ret['percent'] = $ret['complete'] / $ret['total'] * 100;
+ }
+
+ if ($ret['percent'] == 100) {
+ $ret['finished'] = (bool)true;
+ }
+
+ $_SESSION[$SESSION_KEY][$id] = $ret;
+ }
+
+ return $ret;
+ }
+}
+?> \ No newline at end of file
diff --git a/hugo/libraries/plugins/import/upload/UploadNoplugin.class.php b/hugo/libraries/plugins/import/upload/UploadNoplugin.class.php
new file mode 100644
index 0000000..90148de
--- /dev/null
+++ b/hugo/libraries/plugins/import/upload/UploadNoplugin.class.php
@@ -0,0 +1,64 @@
+<?php
+/* vim: set expandtab sw=4 ts=4 sts=4: */
+/**
+ * Provides upload functionalities for the import plugins
+ *
+ * @package PhpMyAdmin
+ */
+if (! defined('PHPMYADMIN')) {
+ exit;
+}
+
+/* Get the transformations interface */
+require_once 'libraries/plugins/UploadInterface.int.php';
+
+/**
+ * Implementation for no plugin
+ *
+ * @package PhpMyAdmin
+ */
+class UploadNoplugin implements UploadInterface
+{
+ /**
+ * Gets the specific upload ID Key
+ *
+ * @return string ID Key
+ */
+ public static function getIdKey()
+ {
+ return 'noplugin';
+ }
+
+ /**
+ * Returns upload status.
+ *
+ * This is implementation when no webserver support exists,
+ * so it returns just zeroes.
+ *
+ * @param string $id upload id
+ *
+ * @return array|null
+ */
+ public static function getUploadStatus($id)
+ {
+ global $SESSION_KEY;
+
+ if (trim($id) == "") {
+ return null;
+ }
+ if (! array_key_exists($id, $_SESSION[$SESSION_KEY])) {
+ $_SESSION[$SESSION_KEY][$id] = array(
+ 'id' => $id,
+ 'finished' => false,
+ 'percent' => 0,
+ 'total' => 0,
+ 'complete' => 0,
+ 'plugin' => UploadNoplugin::getIdKey()
+ );
+ }
+ $ret = $_SESSION[$SESSION_KEY][$id];
+
+ return $ret;
+ }
+}
+?> \ No newline at end of file
diff --git a/hugo/libraries/plugins/import/upload/UploadProgress.class.php b/hugo/libraries/plugins/import/upload/UploadProgress.class.php
new file mode 100644
index 0000000..1a50776
--- /dev/null
+++ b/hugo/libraries/plugins/import/upload/UploadProgress.class.php
@@ -0,0 +1,94 @@
+<?php
+/* vim: set expandtab sw=4 ts=4 sts=4: */
+/**
+ * Provides upload functionalities for the import plugins
+ *
+ * @package PhpMyAdmin
+ */
+if (! defined('PHPMYADMIN')) {
+ exit;
+}
+
+/* Get the transformations interface */
+require_once 'libraries/plugins/UploadInterface.int.php';
+
+/**
+ * Implementation for upload progress
+ *
+ * @package PhpMyAdmin
+ */
+class UploadProgress implements UploadInterface
+{
+ /**
+ * Gets the specific upload ID Key
+ *
+ * @return string ID Key
+ */
+ public static function getIdKey()
+ {
+ return 'UPLOAD_IDENTIFIER';
+ }
+
+ /**
+ * Returns upload status.
+ *
+ * This is implementation for upload progress
+ *
+ * @param string $id upload id
+ *
+ * @return array|null
+ */
+ public static function getUploadStatus($id)
+ {
+ global $SESSION_KEY;
+
+ if (trim($id) == "") {
+ return null;
+ }
+
+ if (! array_key_exists($id, $_SESSION[$SESSION_KEY])) {
+ $_SESSION[$SESSION_KEY][$id] = array(
+ 'id' => $id,
+ 'finished' => false,
+ 'percent' => 0,
+ 'total' => 0,
+ 'complete' => 0,
+ 'plugin' => UploadProgress::getIdKey()
+ );
+ }
+ $ret = $_SESSION[$SESSION_KEY][$id];
+
+ if (! PMA_import_progressCheck() || $ret['finished']) {
+ return $ret;
+ }
+
+ $status = uploadprogress_get_info($id);
+
+ if ($status) {
+ if ($status['bytes_uploaded'] == $status['bytes_total']) {
+ $ret['finished'] = true;
+ } else {
+ $ret['finished'] = false;
+ }
+ $ret['total'] = $status['bytes_total'];
+ $ret['complete'] = $status['bytes_uploaded'];
+
+ if ($ret['total'] > 0) {
+ $ret['percent'] = $ret['complete'] / $ret['total'] * 100;
+ }
+ } else {
+ $ret = array(
+ 'id' => $id,
+ 'finished' => true,
+ 'percent' => 100,
+ 'total' => $ret['total'],
+ 'complete' => $ret['total'],
+ 'plugin' => UploadProgress::getIdKey()
+ );
+ }
+
+ $_SESSION[$SESSION_KEY][$id] = $ret;
+ return $ret;
+ }
+}
+?> \ No newline at end of file
diff --git a/hugo/libraries/plugins/import/upload/UploadSession.class.php b/hugo/libraries/plugins/import/upload/UploadSession.class.php
new file mode 100644
index 0000000..3640413
--- /dev/null
+++ b/hugo/libraries/plugins/import/upload/UploadSession.class.php
@@ -0,0 +1,96 @@
+<?php
+/* vim: set expandtab sw=4 ts=4 sts=4: */
+/**
+ * Provides upload functionalities for the import plugins
+ *
+ * @package PhpMyAdmin
+ */
+if (! defined('PHPMYADMIN')) {
+ exit;
+}
+
+/* Get the transformations interface */
+require_once 'libraries/plugins/UploadInterface.int.php';
+
+/**
+ * Implementation for session
+ *
+ * @package PhpMyAdmin
+ */
+class UploadSession implements UploadInterface
+{
+ /**
+ * Gets the specific upload ID Key
+ *
+ * @return string ID Key
+ */
+ public static function getIdKey()
+ {
+ return ini_get('session.upload_progress.name');
+ }
+
+ /**
+ * Returns upload status.
+ *
+ * This is implementation for session.upload_progress in PHP 5.4+.
+ *
+ * @param string $id upload id
+ *
+ * @return array|null
+ */
+ public static function getUploadStatus($id)
+ {
+ global $SESSION_KEY;
+
+ if (trim($id) == '') {
+ return null;
+ }
+
+ if (! array_key_exists($id, $_SESSION[$SESSION_KEY])) {
+ $_SESSION[$SESSION_KEY][$id] = array(
+ 'id' => $id,
+ 'finished' => false,
+ 'percent' => 0,
+ 'total' => 0,
+ 'complete' => 0,
+ 'plugin' => UploadSession::getIdKey()
+ );
+ }
+ $ret = $_SESSION[$SESSION_KEY][$id];
+
+ if (! PMA_import_sessionCheck() || $ret['finished']) {
+ return $ret;
+ }
+
+ $status = false;
+ $sessionkey = ini_get('session.upload_progress.prefix') . $id;
+
+ if (isset($_SESSION[$sessionkey])) {
+ $status = $_SESSION[$sessionkey];
+ }
+
+ if ($status) {
+ $ret['finished'] = $status['done'];
+ $ret['total'] = $status['content_length'];
+ $ret['complete'] = $status['bytes_processed'];
+
+ if ($ret['total'] > 0) {
+ $ret['percent'] = $ret['complete'] / $ret['total'] * 100;
+ }
+ } else {
+ $ret = array(
+ 'id' => $id,
+ 'finished' => true,
+ 'percent' => 100,
+ 'total' => $ret['total'],
+ 'complete' => $ret['total'],
+ 'plugin' => UploadSession::getIdKey()
+ );
+ }
+
+ $_SESSION[$SESSION_KEY][$id] = $ret;
+
+ return $ret;
+ }
+}
+?> \ No newline at end of file