3 declare(strict_types
=1);
5 namespace PhpMyAdmin\Controllers\Import
;
8 use PhpMyAdmin\Import\Ajax
;
9 use PhpMyAdmin\Message
;
10 use PhpMyAdmin\Template
;
15 use function session_start
;
16 use function session_write_close
;
21 * Import progress bar backend
23 class StatusController
28 public function __construct(Template
$template)
30 $this->template
= $template;
33 public function __invoke(): void
36 $GLOBALS['SESSION_KEY'],
37 $GLOBALS['upload_id'],
39 ] = Ajax
::uploadProgressSetup();
41 // $_GET["message"] is used for asking for an import message
42 if (isset($_GET['message']) && $_GET['message']) {
43 // AJAX requests can't be cached!
44 Core
::noCacheHeader();
46 header('Content-type: text/html');
48 // wait 0.3 sec before we check for $_SESSION variable
51 $maximumTime = ini_get('max_execution_time');
52 $GLOBALS['timestamp'] = time();
53 // wait until message is available
54 while (($_SESSION['Import_message']['message'] ??
null) == null) {
55 // close session before sleeping
56 session_write_close();
58 usleep(250000); // 0.25 sec
62 if (time() - $GLOBALS['timestamp'] > $maximumTime) {
63 $_SESSION['Import_message']['message'] = Message
::error(
64 __('Could not load the progress of the import.')
70 echo $_SESSION['Import_message']['message'] ??
'';
72 if (isset($_SESSION['Import_message']['go_back_url'])) {
73 echo $this->template
->render('import_status', [
74 'go_back_url' => $_SESSION['Import_message']['go_back_url'],
78 Ajax
::status($_GET['id']);