cvs: phpweb /include site.inc
| From: | Hannes Magnusson | Date: | Fri, 06 Jun 2008 21:05:13 +0000 |
| Subject: | cvs: phpweb /include site.inc | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-1880@lists.php.net to get a copy of this message | ||
bjori Fri Jun 6 21:05:13 2008 UTC
Modified files:
/phpweb/include site.inc
Log:
Send out user-agent headers
http://cvs.php.net/viewvc.cgi/phpweb/include/site.inc?r1=1.256&r2=1.257&diff_format=u
Index: phpweb/include/site.inc
diff -u phpweb/include/site.inc:1.256 phpweb/include/site.inc:1.257
--- phpweb/include/site.inc:1.256 Mon Apr 21 11:00:33 2008
+++ phpweb/include/site.inc Fri Jun 6 21:05:12 2008
@@ -1,6 +1,6 @@
<?php // -*- C++ -*-
-// $Id: site.inc,v 1.256 2008/04/21 11:00:33 bjori Exp $
+// $Id: site.inc,v 1.257 2008/06/06 21:05:12 bjori Exp $
// Define $MIRRORS array, and some constants
include $_SERVER['DOCUMENT_ROOT'] . '/include/mirrors.inc';
@@ -177,6 +177,9 @@
// Compatibility function to fetch data from external source
function fetch_contents($url, $headers = false) {
if(function_exists('file_get_contents') &&
ini_get('allow_url_fopen')) {
+ $opts = array('user_agent' => 'php.net',);
+
+ stream_context_get_default(array("http" => $opts));
$data = @file_get_contents($url);
if ($headers) {
return $http_response_header;
@@ -191,6 +194,7 @@
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);
@@ -220,6 +224,7 @@
}
fputs($fd,"GET {$path} HTTP/1.0\r\n");
fputs($fd,"Host: {$array["host"]}\r\n");
+ fputs($fd,"User-Agent: php.net\r\n");
fputs($fd,"Connection: close\r\n\r\n");
while($line = fgets($fd)) {