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