Script help

Script help

am 29.03.2008 15:33:16 von Joker7

Hi,
I have been using the code below for sometime and it works fine for most of
my need apart from this.
Im using it to request a page from (see code) and it keeps returning:

"Warning: file_get_contents(http://s.afnt.co.uk/df/df.aspx?a=13548&q=w estend
show tickets&n=10&t=itpd1.xsl&r=) [function.file-get-contents]: failed to
open stream: HTTP request failed! HTTP/1.1 400 Bad Request in
/home/sites/test/call.php on line 46
Request failed"

Any help\pointers with this would be great.


error_reporting(E_ALL);
define('CACHEDIR', './');
$request = 'http://s.afnt.co.uk/df/df.aspx?a=13548&q=westend show
tickets&n=10&t=itpd1.xsl&r=';
$cache_filename = 'info.htm';
$cache_fullpath = CACHEDIR.$cache_filename;
$cache_timeout = 60;
$response = request_cache($request, $cache_fullpath, $cache_timeout);
if ($response === false) {
die('Request failed');
}
echo htmlspecialchars($response, ENT_QUOTES);
$file = "/home/sites/test/info.htm";

if (! chmod($file, 0776)) {
echo ("Unable to change file permissions");
}
function request_cache($url, $dest_file, $timeout=60) {
if(!file_exists($dest_file) || filemtime($dest_file) < (time()-$timeout)) {
$data = file_get_contents($url);
if ($data === false) return false;
$tmpf = tempnam('/tmp','YWS');
$fp = fopen($tmpf,"w");
fwrite($fp, $data);
fclose($fp);
rename($tmpf, $dest_file);
} else {
return file_get_contents($dest_file);
}
return($data);
}

?>


Superb hosting & domain name deals http://dn-22.co.uk
The Handyman http://www.looker.me.uk

--
Superb hosting & domain name deals http://dn-22.co.uk
The Handyman http://www.looker.me.uk

Re: Script help (sorted)

am 29.03.2008 16:05:37 von Joker7

To restore balance to the world Joker7 wrote in
TssHj.175295$8Z.97779@newsfet10.ams
>> Hi,
>> I have been using the code below for sometime and it works fine for
>> most of my need apart from this.
>> Im using it to request a page from (see code) and it keeps returning:
>>
>> "Warning:
>> file_get_contents(http://s.afnt.co.uk/df/df.aspx?a=13548&q=w estend
>> show tickets&n=10&t=itpd1.xsl&r=) [function.file-get-contents]:
>> failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request
>> in /home/sites/test/call.php on line 46
>> Request failed"
>>
>> Any help\pointers with this would be great.
>>
>> >>
>> error_reporting(E_ALL);
>> define('CACHEDIR', './');
>> $request = 'http://s.afnt.co.uk/df/df.aspx?a=13548&q=westend show
>> tickets&n=10&t=itpd1.xsl&r=';
>> $cache_filename = 'info.htm';
>> $cache_fullpath = CACHEDIR.$cache_filename;
>> $cache_timeout = 60;
>> $response = request_cache($request, $cache_fullpath, $cache_timeout);
>> if ($response === false) {
>> die('Request failed');
>> }
>> echo htmlspecialchars($response, ENT_QUOTES);
>> $file = "/home/sites/test/info.htm";
>>
>> if (! chmod($file, 0776)) {
>> echo ("Unable to change file permissions");
>> }
>> function request_cache($url, $dest_file, $timeout=60) {
>> if(!file_exists($dest_file) || filemtime($dest_file) <
>> (time()-$timeout)) { $data = file_get_contents($url);
>> if ($data === false) return false;
>> $tmpf = tempnam('/tmp','YWS');
>> $fp = fopen($tmpf,"w");
>> fwrite($fp, $data);
>> fclose($fp);
>> rename($tmpf, $dest_file);
>> } else {
>> return file_get_contents($dest_file);
>> }
>> return($data);
>> }
>>
>>>
>>
>>


It script did not like the gaps in the url ..

Thanks
Chris