2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Handles plugins that show the upload progress
10 * Sets up some variables for upload progress
15 function PMA_uploadProgressSetup()
18 * constant for differentiating array in $_SESSION variable
20 $SESSION_KEY = '__upload_status';
23 * sets default plugin for handling the import process
25 $_SESSION[$SESSION_KEY]["handler"] = "";
28 * unique ID for each upload
30 $upload_id = uniqid("");
33 * list of available plugins
35 * Each plugin has own checkfunction in display_import_ajax.lib.php
36 * and own file with functions in upload_#KEY#.php
39 // PHP 5.4 session-based upload progress is problematic, see bug 3964
46 // select available plugin
47 foreach ($plugins as $plugin) {
48 $check = "PMA_Import_" . $plugin . "Check";
51 $upload_class = 'PMA\libraries\plugins\import\upload\Upload' . ucwords(
54 $_SESSION[$SESSION_KEY]["handler"] = $upload_class;
58 return array($SESSION_KEY, $upload_id, $plugins);
62 * Checks if APC bar extension is available and configured correctly.
64 * @return boolean true if APC extension is available and if rfc1867 is enabled,
67 function PMA_Import_apcCheck()
69 if (! extension_loaded('apc')
70 ||
! function_exists('apc_fetch')
71 ||
! function_exists('getallheaders')
75 return (ini_get('apc.enabled') && ini_get('apc.rfc1867'));
79 * Checks if PMA\libraries\plugins\import\upload\UploadProgress bar extension is
82 * @return boolean true if PMA\libraries\plugins\import\upload\UploadProgress
83 * extension is available, false if it is not
85 function PMA_Import_progressCheck()
87 if (! function_exists("uploadprogress_get_info")
88 ||
! function_exists('getallheaders')
96 * Checks if PHP 5.4 session upload-progress feature is available.
98 * @return boolean true if PHP 5.4 session upload-progress is available,
101 function PMA_Import_sessionCheck()
103 if (! ini_get('session.upload_progress.enabled')) {
110 * Default plugin for handling import.
111 * If no other plugin is available, noplugin is used.
113 * @return boolean true
115 function PMA_Import_nopluginCheck()
121 * The function outputs json encoded status of uploaded.
122 * It uses PMA_getUploadStatus, which is defined in plugin's file.
124 * @param string $id ID of transfer, usually $upload_id
125 * from display_import_ajax.lib.php
129 function PMA_importAjaxStatus($id)
133 $_SESSION[$GLOBALS['SESSION_KEY']]['handler']::getUploadStatus($id)