Currency Converter: "URL file-access is disabled"

apps

#1

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:

[i]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=&[/i]

The code from the PHP file is as follows…

[quote]<?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(".

",’’,$money[0]);
$money[0] = ereg_replace("
.",’’,$money[0]);
// get exchange rate
$money[0] = ereg_replace(".",’’,$money[0]);
$money[0] = ereg_replace(".

",’’,$money[0]);
// get value conversion
$rString=(’&success=’.$to.’&toAmount=’.$money[0]);

echo $rString."&";

?> [/quote]

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


#2

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


#3

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.


#4

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

–rlparker


#5

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.


Simon’s website
Save $100 on 1-year plans with promo code [color=#CC0000]SCJESSEY100[/color] (details)