View Single Post
  #1 (permalink)  
Old 13-06-2008, 12:30
paulmann paulmann is offline
Member
 
Join Date: Jan 2008
Location: Stoke-on-Trent
Posts: 34
Default file_gets_contents() problem

Since moving Puma to a new server I have been unable to run a little script. It passes the cost of a shopping basket to a php which then googles to find conversion rates for a few different currencies.

The error is:
Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in /home.....

Here is the script I use (cut down to convert 20 pounds to Australian dollars):
Code:
<?php
$googleQuery = '20' . ' ' . 'gbp' . ' in ' . 'aud';
$googleQuery = urlEncode( $googleQuery );
$askGoogle = file_get_contents( 'http://www.google.com/search?q=' . $googleQuery );
$askGoogle = strip_tags( $askGoogle );
if (preg_match("/Rates provided for information only - see disclaimer./i", $askGoogle))
  {
  $matches = array();
  preg_match( '/= ([0-9\s\.,]+)/', $askGoogle, $matches );
  print "£20 is about \$" . $matches[1] . " AUS";
  }
else
  {
  print "n/a";
  }
?>
Is this something I can fix myself?
Reply With Quote