Currency Converter: "URL file-access is disabled"

Currency Converter: "URL file-access is disabled"

Posted by: decentone
Posted on: 2007-01-24 23:06:00

Hello,

I have a currency converter running in a Flash based store that's not currently working. I'm not sure how to go about solving this problem but when I run the PHP file directly, here are the error messages that I'm receiving:

Warning: file() [function.file]: URL file-access is disabled in the server configuration in currency.php on line 13

Warning: file(http:///m5?a=1.00&t=&s=) [function.file]: failed to open stream: no suitable wrapper could be found in currency.php on line 13

Warning: join() [function.join]: Bad arguments. in currency.php on line 14
&success=&toAmount=&


The code from the PHP file is as follows...

In reply to:

<?php

// $from var defined in cart_init
$from = $HTTP_POST_VARS['fromCurrency'];

// $to var defined in main.as
$to = $HTTP_POST_VARS['toCurrency'];

// amount var defined in main.as
$amount="1.00";

$query_url = $HTTP_POST_VARS['query_url'];
$money[0]=file('http://'.$query_url.'/m5?a='.$amount.'&t='.$to.'&s='.$from.'');
$money[0] = join("",$money[0]);
$money[0] = ereg_replace(".*<table border=1 cellpadding=2 cellspacing=0>",'',$money[0]);
$money[0] = ereg_replace("</table>.*",'',$money[0]);
// get exchange rate
$money[0] = ereg_replace("</td>.*",'',$money[0]);
$money[0] = ereg_replace(".*<td>",'',$money[0]);
// get value conversion
$rString=('&success='.$to.'&toAmount='.$money[0]);

echo $rString."&";

?>



Thanks in advance to anyone who might be able to help out here... it would be greatly greatly appreciated.



Re: Currency Converter: "URL file-access is disabl

Posted by: rlparker
Posted on: 2007-01-25 00:25:00

That is a normal consequence of having allow_url_fopen disabled in PHP, which it *is* in the default Dreamhost configurations.

You should investigate modifying your code to use cURL, and explained in this Dreamhost Wiki article.

For further information about Dreamhost's disabling of allow_url_fopen , search the forum for that term or check this Dreamhost wiki article on allow_url_fopen.

--rlparker

Re: Currency Converter: "URL file-access is disabl

Posted by: decentone
Posted on: 2007-01-25 00:53:00

Ahhh.... I see. Thank you kindly for pointing me in the right direction. I appreciate it very much. I'll have a go with cURL and check back when I have some results.

Re: Currency Converter: "URL file-access is disabl

Posted by: rlparker
Posted on: 2007-01-25 00:57:00

No problem, I'm happy to help when I can. Good luck in your attempts at making the necessary changes. smile

--rlparker

Re: Currency Converter: "URL file-access is disabl

Posted by: scjessey
Posted on: 2007-01-25 05:16:00

While you're at it, you should change $HTTP_POST_VARS['whatever'] to $_POST['whatever'] as well. The former method was deprecated a good while ago, and will not be available at all in PHP6.

Tags: server configurationphp fileerror messages