Merge pull request #838 from sachith500/master

(Feature Request 1466 : Refactoring)
This commit is contained in:
Marc Delisle 2014-01-08 06:24:17 -08:00
commit 77b2467193
2 changed files with 26 additions and 28 deletions

View File

@ -4184,6 +4184,29 @@ class PMA_Util
}
return $context;
}
/**
* Updates an existing curl as necessary
*
* @param resource $curl_handle A curl_handle resource
* created by curl_init which should
* have several options set
*
* @return resource curl_handle with updated options
*/
public static function configureCurl(resource $curl_handle)
{
if (strlen($GLOBALS['cfg']['ProxyUrl'])) {
curl_setopt($curl_handle, CURLOPT_PROXY, $GLOBALS['cfg']['ProxyUrl']);
if (strlen($GLOBALS['cfg']['ProxyUser'])) {
curl_setopt(
$curl_handle,
CURLOPT_PROXYUSERPWD,
$GLOBALS['cfg']['ProxyUser'] . ':' . $GLOBALS['cfg']['ProxyPass']
);
}
}
return $curl_handle;
}
/**
* Returns information with latest version from phpmyadmin.net
*
@ -4191,8 +4214,6 @@ class PMA_Util
*/
public static function getLatestVersion()
{
global $cfg;
// wait 3s at most for server response, it's enough to get information
// from a working server
$connection_timeout = 3;
@ -4223,21 +4244,7 @@ class PMA_Util
);
} else if (function_exists('curl_init')) {
$curl_handle = curl_init($file);
if (strlen($cfg['ProxyUrl'])) {
curl_setopt(
$curl_handle,
CURLOPT_PROXY,
$cfg['ProxyUrl']
);
if (strlen($cfg['ProxyUser'])) {
curl_setopt(
$curl_handle,
CURLOPT_PROXYUSERPWD,
$cfg['ProxyUser']
. ':' . $cfg['ProxyPass']
);
}
}
$curl_handle = PMA_Util::configureCurl($curl_handle);
curl_setopt(
$curl_handle,
CURLOPT_HEADER,

View File

@ -7,7 +7,7 @@
*/
/*
* Include for handleContext (in sendErrorReport.
* Include for handleContext() and configureCurl in PMA_sendErrorReport()
*/
require_once 'libraries/Util.class.php';
@ -151,16 +151,7 @@ function PMA_sendErrorReport($report)
}
$curl_handle = curl_init(SUBMISSION_URL);
if (strlen($GLOBALS['cfg']['ProxyUrl'])) {
curl_setopt($curl_handle, CURLOPT_PROXY, $GLOBALS['cfg']['ProxyUrl']);
if (strlen($GLOBALS['cfg']['ProxyUser'])) {
curl_setopt(
$curl_handle,
CURLOPT_PROXYUSERPWD,
$GLOBALS['cfg']['ProxyUser'] . ':' . $GLOBALS['cfg']['ProxyPass']
);
}
}
$curl_handle = PMA_Util::configureCurl($curl_handle);
curl_setopt($curl_handle, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl_handle, CURLOPT_HTTPHEADER, array('Expect:'));
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $data_string);