Translated using Weblate (Indonesian)
[phpmyadmin.git] / libraries / display_import_ajax.lib.php
blob838f9b7805c026b2c75f00936e473c8e30ed6862
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Handles plugins that show the upload progress
6 * @package PhpMyAdmin
7 */
9 /**
10 * Sets up some variables for upload progress
12 * @return array
15 function PMA_uploadProgressSetup()
17 /**
18 * constant for differentiating array in $_SESSION variable
20 $SESSION_KEY = '__upload_status';
22 /**
23 * sets default plugin for handling the import process
25 $_SESSION[$SESSION_KEY]["handler"] = "";
27 /**
28 * unique ID for each upload
30 $upload_id = uniqid("");
32 /**
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
38 $plugins = array(
39 // PHP 5.4 session-based upload progress is problematic, see bug 3964
40 //"session",
41 "progress",
42 "apc",
43 "noplugin"
46 // select available plugin
47 foreach ($plugins as $plugin) {
48 $check = "PMA_Import_" . $plugin . "Check";
50 if ($check()) {
51 $upload_class = 'PMA\libraries\plugins\import\upload\Upload' . ucwords(
52 $plugin
54 $_SESSION[$SESSION_KEY]["handler"] = $upload_class;
55 break;
58 return array($SESSION_KEY, $upload_id, $plugins);
61 /**
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,
65 * false if it is not
67 function PMA_Import_apcCheck()
69 if (! extension_loaded('apc')
70 || ! function_exists('apc_fetch')
71 || ! function_exists('getallheaders')
72 ) {
73 return false;
75 return (ini_get('apc.enabled') && ini_get('apc.rfc1867'));
78 /**
79 * Checks if PMA\libraries\plugins\import\upload\UploadProgress bar extension is
80 * available.
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')
89 ) {
90 return false;
92 return true;
95 /**
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,
99 * false if it is not
101 function PMA_Import_sessionCheck()
103 if (! ini_get('session.upload_progress.enabled')) {
104 return false;
106 return true;
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()
117 return true;
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
127 * @return void
129 function PMA_importAjaxStatus($id)
131 PMA_headerJSON();
132 echo json_encode(
133 $_SESSION[$GLOBALS['SESSION_KEY']]['handler']::getUploadStatus($id)