svn: /web/php/trunk/include/ site.inc

From: Date: Tue, 22 Jun 2010 22:49:32 +0000
Subject: svn: /web/php/trunk/include/ site.inc
Groups: php.webmaster 
Request: Send a blank email to php-webmaster+get-8418@lists.php.net to get a copy of this message
philip Tue, 22 Jun 2010 22:49:32 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=300680 Log: 'Temp' fix for a bug on us3.php.net where only curl works... so moving the curl option of fetch_contents() to the top Changed paths: U web/php/trunk/include/site.inc Modified: web/php/trunk/include/site.inc =================================================================== --- web/php/trunk/include/site.inc 2010-06-22 22:40:03 UTC (rev 300679) +++ web/php/trunk/include/site.inc 2010-06-22 22:49:32 UTC (rev 300680) @@ -179,6 +179,38 @@ $terrors_setting = ini_set('track_errors', true); + // A mysterious and elusive bug on us3 allows this to work, but the other methods do not + // So for now, use Curl first (curl++) + if(function_exists('curl_exec')) { + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_HEADER, (int)$headers); + curl_setopt($ch, CURLOPT_USERAGENT, "php.net"); + + $data = curl_exec($ch); + curl_close($ch); + + if ($headers) { + $array = explode("\n", $data); + foreach($array as $line) { + if (strlen($line)<=2) { + return $header; + } else { + $header[] = $line; + } + } + } + if (!$data) { + return array( + 'ERROR_NOTE' => 'Unable to find a way to retrieve data with curl', + 'ERROR_LAST' => $php_errormsg, + ); + } + + return $data; + } + if(function_exists('file_get_contents') && ini_get('allow_url_fopen')) { $context = null; $opts = array('user_agent' => 'php.net'); @@ -210,37 +242,6 @@ return $data; } - // Let's find another way - if(function_exists('curl_exec')) { - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_HEADER, (int)$headers); - curl_setopt($ch, CURLOPT_USERAGENT, "php.net"); - - $data = curl_exec($ch); - curl_close($ch); - - if ($headers) { - $array = explode("\n", $data); - foreach($array as $line) { - if (strlen($line)<=2) { - return $header; - } else { - $header[] = $line; - } - } - } - if (!$data) { - return array( - 'ERROR_NOTE' => 'Unable to find a way to retrieve data with curl', - 'ERROR_LAST' => $php_errormsg, - ); - } - - return $data; - } - $array = parse_url($url); if(function_exists('fsockopen') && $fd = @fsockopen($array["host"], 80, $errno, $errstr, 15)) { $data = "";

« previous php.webmaster (#8418) next »