2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Handles plugins that show the upload progress
8 if (! defined('PHPMYADMIN')) {
13 * constant for differenciating array in $_SESSION variable
15 $SESSION_KEY = '__upload_status';
18 * sets default plugin for handling the import process
20 $_SESSION[$SESSION_KEY]["handler"] = "";
23 * unique ID for each upload
25 $upload_id = uniqid("");
28 * list of available plugins
30 * Each plugin has own checkfunction in display_import_ajax.lib.php
31 * and own file with functions in upload_#KEY#.php
34 // PHP 5.4 session-based upload progress is problematic, see bug 3964
41 // select available plugin
42 foreach ($plugins as $plugin) {
43 $check = "PMA_Import_" . $plugin . "Check";
46 $upload_class = "Upload" . ucwords($plugin);
47 $_SESSION[$SESSION_KEY]["handler"] = $upload_class;
48 include_once "plugins/import/upload/" . $upload_class . ".class.php";
54 * Checks if APC bar extension is available and configured correctly.
56 * @return boolean true if APC extension is available and if rfc1867 is enabled,
59 function PMA_Import_apcCheck()
61 if (! extension_loaded('apc')
62 ||
! function_exists('apc_fetch')
63 ||
! function_exists('getallheaders')
67 return (ini_get('apc.enabled') && ini_get('apc.rfc1867'));
71 * Checks if UploadProgress bar extension is available.
73 * @return boolean true if UploadProgress extension is available,
76 function PMA_Import_progressCheck()
78 if (! function_exists("uploadprogress_get_info")
79 ||
! function_exists('getallheaders')
87 * Checks if PHP 5.4 session upload-progress feature is available.
89 * @return boolean true if PHP 5.4 session upload-progress is available,
92 function PMA_Import_sessionCheck()
94 if (PMA_PHP_INT_VERSION
< 50400
95 ||
! ini_get('session.upload_progress.enabled')
103 * Default plugin for handling import.
104 * If no other plugin is available, noplugin is used.
106 * @return boolean true
108 function PMA_Import_nopluginCheck()
114 * The function outputs json encoded status of uploaded.
115 * It uses PMA_getUploadStatus, which is defined in plugin's file.
117 * @param string $id ID of transfer, usually $upload_id
118 * from display_import_ajax.lib.php
122 function PMA_importAjaxStatus($id)
124 header('Content-type: application/json');
126 $_SESSION[$GLOBALS['SESSION_KEY']]['handler']::getUploadStatus($id)