diff options
author | patdenice <patdenice@piwigo.org> | 2010-12-12 10:16:12 +0000 |
---|---|---|
committer | patdenice <patdenice@piwigo.org> | 2010-12-12 10:16:12 +0000 |
commit | 4448b8db7f59b4408a3ebcad2cb1ac77f6b38b8a (patch) | |
tree | 6088347ec82837198a0e694df30e463d4b7c1ec6 | |
parent | 1b5260522e3234c122613189bf14deab445ed4c9 (diff) |
merge r8089 from branch 2.1 to trunk
feature 2057: use http_build_query instead of add_url_params for GET data.
git-svn-id: http://piwigo.org/svn/trunk@8090 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r-- | admin/include/functions.php | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/admin/include/functions.php b/admin/include/functions.php index 6f2ce02e2..81723ad9f 100644 --- a/admin/include/functions.php +++ b/admin/include/functions.php @@ -1725,7 +1725,11 @@ function fetchRemote($src, &$dest, $get_data=array(), $post_data=array(), $user_ // Initialization $method = empty($post_data) ? 'GET' : 'POST'; $request = empty($post_data) ? '' : http_build_query($post_data, '', '&'); - $src = add_url_params($src, $get_data, '&'); + if (!empty($get_data)) + { + $src .= strpos($src, '?') === false ? '?' : '&'; + $src .= http_build_query($get_data, '', '&'); + } // Initialize $dest is_resource($dest) or $dest = ''; @@ -1741,7 +1745,7 @@ function fetchRemote($src, &$dest, $get_data=array(), $post_data=array(), $user_ if ($method == 'POST') { @curl_setopt($ch, CURLOPT_POST, 1); - @curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); + @curl_setopt($ch, CURLOPT_POSTFIELDS, $request); } $content = @curl_exec($ch); $header_length = @curl_getinfo($ch, CURLINFO_HEADER_SIZE); @@ -1765,10 +1769,13 @@ function fetchRemote($src, &$dest, $get_data=array(), $post_data=array(), $user_ $opts = array( 'http' => array( 'method' => $method, - 'content' => $request, 'user_agent' => $user_agent, ) ); + if ($method == 'POST') + { + $opts['http']['content'] = $request; + } $context = @stream_context_create($opts); $content = @file_get_contents($src, false, $context); if ($content !== false) @@ -1791,8 +1798,11 @@ function fetchRemote($src, &$dest, $get_data=array(), $post_data=array(), $user_ $http_request = $method." ".$path." HTTP/1.0\r\n"; $http_request .= "Host: ".$host."\r\n"; - $http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n"; - $http_request .= "Content-Length: ".strlen($request)."\r\n"; + if ($method == 'POST') + { + $http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n"; + $http_request .= "Content-Length: ".strlen($request)."\r\n"; + } $http_request .= "User-Agent: ".$user_agent."\r\n"; $http_request .= "Accept: */*\r\n"; $http_request .= "\r\n"; |