From 4c7c3a31a5ee3f04d731817136852a3a1d3d90d8 Mon Sep 17 00:00:00 2001 From: "J.M" Date: Sun, 24 Jun 2012 21:01:36 +0200 Subject: [PATCH 1/2] Another try to fix PHP 5.4-based upload progress --- import_status.php | 63 ++++++++++++++--------------------------------- 1 file changed, 18 insertions(+), 45 deletions(-) diff --git a/import_status.php b/import_status.php index b544748b9d..d056c3e1d4 100644 --- a/import_status.php +++ b/import_status.php @@ -24,60 +24,33 @@ if (version_compare(PHP_VERSION, '5.4.0', '>=') && ini_get('session.upload_progress.enabled') ) { - if (!isset($_POST['session_upload_progress'])) { - $sessionupload = array(); - $prefix = ini_get('session.upload_progress.prefix'); + $sessionupload = array(); + $prefix = ini_get('session.upload_progress.prefix'); - session_start(); - foreach ($_SESSION as $key => $value) { - // only copy session-prefixed data - if (substr($key, 0, strlen($prefix)) == $prefix) { - $sessionupload[$key] = $value; - } + session_start(); + foreach ($_SESSION as $key => $value) { + // only copy session-prefixed data + if (substr($key, 0, strlen($prefix)) == $prefix) { + $sessionupload[$key] = $value; } - - // perform internal self-request - $url = 'http' . - ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 's' : '') . - '://' . $_SERVER['HTTP_HOST'] . - $_SERVER['REQUEST_URI']; - - if (!function_exists('curl_exec') || !function_exists('getallheaders')) { - die(); - } - $headers = @getallheaders(); - if (!isset($headers['Cookie'])) { - die(); - } - $ch = curl_init($url); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt( - $ch, CURLOPT_POSTFIELDS, - 'session_upload_progress=' . rawurlencode(serialize($sessionupload)) - ); - curl_setopt($ch, CURLOPT_COOKIE, $headers['Cookie']); - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3); - curl_setopt($ch, CURLOPT_TIMEOUT, 3); - - // to avoid problems with self-signed certs - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); - - // show the result of the internal request - echo @curl_exec($ch); - die(); } + // PMA will kill all variables, so let's use a constant + define('SESSIONUPLOAD', serialize($sessionupload)); + session_write_close(); + + session_name('phpMyAdmin'); + session_id($_COOKIE['phpMyAdmin']); } +define('PMA_MINIMUM_COMMON', 1); + require_once 'libraries/common.inc.php'; require_once 'libraries/display_import_ajax.lib.php'; -if (isset($_POST['session_upload_progress'])) { - // this is the internal request response - // restore sessionupload from the POSTed data (see above), - // then write sessionupload back into the loaded session +if (defined('SESSIONUPLOAD')) { + // write sessionupload back into the loaded PMA session - $sessionupload = unserialize($_POST['session_upload_progress']); + $sessionupload = unserialize(SESSIONUPLOAD); foreach ($sessionupload as $key => $value) { $_SESSION[$key] = $value; } From ed8e998307e87c811787654aba0f7f4ba041d457 Mon Sep 17 00:00:00 2001 From: "J.M" Date: Sun, 24 Jun 2012 21:08:54 +0200 Subject: [PATCH 2/2] Remove check for cURL support in PHP 5.4 upload progress handler, we dont need it anymore --- libraries/display_import_ajax.lib.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/libraries/display_import_ajax.lib.php b/libraries/display_import_ajax.lib.php index e0180a2b2e..d17e7b133c 100644 --- a/libraries/display_import_ajax.lib.php +++ b/libraries/display_import_ajax.lib.php @@ -83,8 +83,6 @@ function PMA_import_uploadprogressCheck() /** * Checks if PHP 5.4 session upload-progress feature is available. - * Due to a bug in PHP 5.4's session upload feature (see /import_status.php), - * we need to check for cURL support. * * @return boolean true if PHP 5.4 session upload-progress is available, * false if it is not @@ -93,7 +91,6 @@ function PMA_import_sessionCheck() { if (PMA_PHP_INT_VERSION < 50400 || ! ini_get('session.upload_progress.enabled') - || ! function_exists('curl_exec') ) { return false; }