2 /* vim: set expandtab sw=4 ts=4 sts=4: */
8 /* PHP 5.4 stores upload progress data only in the default session.
9 * After calling session_name(), we won't find the progress data anymore.
11 * The bug should be somewhere in
12 * https://github.com/php/php-src/blob/master/ext/session/session.c#L2342
14 * Until this is fixed, we need to load the default session to load the data.
15 * As we cannot load the phpMyAdmin-session after that, we will try to do
16 * an internal POST request to call ourselves in a new instance.
17 * That POST request grabs the transmitted upload data and stores them.
19 * TODO: The internal HTTP request may fail if the DNS name cannot be resolved
20 * or if a firewall blocks outgoing requests on the used port.
23 if (version_compare(PHP_VERSION
, '5.4.0', '>=')
24 && ini_get('session.upload_progress.enabled')
27 if (!isset($_POST['session_upload_progress'])) {
28 $sessionupload = array();
29 $prefix = ini_get('session.upload_progress.prefix');
32 foreach ($_SESSION as $key => $value) {
33 // only copy session-prefixed data
34 if (substr($key, 0, strlen($prefix)) == $prefix) {
35 $sessionupload[$key] = $value;
39 // perform internal self-request
41 ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ?
's' : '') .
42 '://' . $_SERVER['HTTP_HOST'] .
43 $_SERVER['REQUEST_URI'];
45 if (!function_exists('curl_exec') ||
!function_exists('getallheaders')) {
48 $headers = @getallheaders
();
49 if (!isset($headers['Cookie'])) {
52 $ch = curl_init($url);
53 curl_setopt($ch, CURLOPT_RETURNTRANSFER
, 1);
55 $ch, CURLOPT_POSTFIELDS
,
56 'session_upload_progress=' . rawurlencode(serialize($sessionupload))
58 curl_setopt($ch, CURLOPT_COOKIE
, $headers['Cookie']);
59 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT
, 3);
60 curl_setopt($ch, CURLOPT_TIMEOUT
, 3);
62 // to avoid problems with self-signed certs
63 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER
, 0);
64 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST
, 0);
66 // show the result of the internal request
72 require_once 'libraries/common.inc.php';
73 require_once 'libraries/display_import_ajax.lib.php';
75 if (isset($_POST['session_upload_progress'])) {
76 // this is the internal request response
77 // restore sessionupload from the POSTed data (see above),
78 // then write sessionupload back into the loaded session
80 $sessionupload = unserialize($_POST['session_upload_progress']);
81 foreach ($sessionupload as $key => $value) {
82 $_SESSION[$key] = $value;
87 * Sets globals from $_GET
93 foreach ($get_params as $one_get_param) {
94 if (isset($_GET[$one_get_param])) {
95 $GLOBALS[$one_get_param] = $_GET[$one_get_param];
99 // AJAX requests can't be cached!
100 PMA_no_cache_header();
102 // $GLOBALS["message"] is used for asking for an import message
103 if (isset($GLOBALS["message"]) && $GLOBALS["message"]) {
105 header('Content-type: text/html');
107 // wait 0.3 sec before we check for $_SESSION variable, which is set inside import.php
110 // wait until message is available
111 while ($_SESSION['Import_message']['message'] == null) {
112 usleep(250000); // 0.25 sec
115 echo $_SESSION['Import_message']['message'];
116 echo '<fieldset class="tblFooters">' . "\n";
117 echo ' [ <a href="' . $_SESSION['Import_message']['go_back_url'] . '">' . __('Back') . '</a> ]' . "\n";
118 echo '</fieldset>'."\n";
121 PMA_importAjaxStatus($GLOBALS["id"]);