Translated using Weblate (Slovenian)
[phpmyadmin.git] / import_status.php
blobab7063e3d28fee55dc4af79533f965940e9c320a
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Import progress bar backend
6 * @package PhpMyAdmin
7 */
8 declare(strict_types=1);
10 use PhpMyAdmin\Core;
11 use PhpMyAdmin\Display\ImportAjax;
13 if (! defined('ROOT_PATH')) {
14 define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
17 /* PHP 5.4 stores upload progress data only in the default session.
18 * After calling session_name(), we won't find the progress data anymore.
20 * https://bugs.php.net/bug.php?id=64075
22 * The bug should be somewhere in
23 * https://github.com/php/php-src/blob/master/ext/session/session.c#L2342
25 * Until this is fixed, we need to load the default session to load the data,
26 * export the upload progress information from there,
27 * and re-import after switching to our session.
29 * However, since https://github.com/phpmyadmin/phpmyadmin/commit/063a2d99
30 * we have deactivated this feature, so the corresponding code is now
31 * commented out.
35 if (ini_get('session.upload_progress.enabled')) {
37 $sessionupload = array();
38 define('UPLOAD_PREFIX', ini_get('session.upload_progress.prefix'));
40 session_start();
41 foreach ($_SESSION as $key => $value) {
42 // only copy session-prefixed data
43 if (substr($key, 0, strlen(UPLOAD_PREFIX))
44 == UPLOAD_PREFIX) {
45 $sessionupload[$key] = $value;
48 // PMA will kill all variables, so let's use a constant
49 define('SESSIONUPLOAD', serialize($sessionupload));
50 session_write_close();
52 // The cookie name is not good anymore since PR #15273
53 session_name('phpMyAdmin');
54 session_id($_COOKIE['phpMyAdmin']);
58 define('PMA_MINIMUM_COMMON', 1);
60 require_once ROOT_PATH . 'libraries/common.inc.php';
61 list(
62 $SESSION_KEY,
63 $upload_id,
64 $plugins
65 ) = ImportAjax::uploadProgressSetup();
68 if (defined('SESSIONUPLOAD')) {
69 // write sessionupload back into the loaded PMA session
71 $sessionupload = unserialize(SESSIONUPLOAD);
72 foreach ($sessionupload as $key => $value) {
73 $_SESSION[$key] = $value;
76 // remove session upload data that are not set anymore
77 foreach ($_SESSION as $key => $value) {
78 if (substr($key, 0, strlen(UPLOAD_PREFIX))
79 == UPLOAD_PREFIX
80 && ! isset($sessionupload[$key])
81 ) {
82 unset($_SESSION[$key]);
88 // $_GET["message"] is used for asking for an import message
89 if (isset($_GET["message"]) && $_GET["message"]) {
90 // AJAX requests can't be cached!
91 Core::noCacheHeader();
93 header('Content-type: text/html');
95 // wait 0.3 sec before we check for $_SESSION variable,
96 // which is set inside import.php
97 usleep(300000);
99 $maximumTime = ini_get('max_execution_time');
100 $timestamp = time();
101 // wait until message is available
102 while ($_SESSION['Import_message']['message'] == null) {
103 // close session before sleeping
104 session_write_close();
105 // sleep
106 usleep(250000); // 0.25 sec
107 // reopen session
108 session_start();
110 if ((time() - $timestamp) > $maximumTime) {
111 $_SESSION['Import_message']['message'] = PhpMyAdmin\Message::error(
112 __('Could not load the progress of the import.')
113 )->getDisplay();
114 break;
118 if (isset($_SESSION['Import_message']['message'])) {
119 echo $_SESSION['Import_message']['message'];
121 if (isset($_SESSION['Import_message']['go_back_url'])) {
122 echo '<fieldset class="tblFooters">' , "\n";
123 echo ' [ <a href="' , $_SESSION['Import_message']['go_back_url']
124 . '">' , __('Back') , '</a> ]' , "\n";
125 echo '</fieldset>' , "\n";
127 } else {
128 ImportAjax::status($_GET["id"]);