PHP error w/ translation script

software development

#1

Hey, all! I’ve got a translator script that SHOULD work beautifully, but when all’s said & done, I get loads of errors… Below is the cut & paste of it all:

[/quote]

RewriteEngine On
RewriteRule ^([^/]{2})/(.*)$ /websitetranslator/index.php?lang=$1&url=$2 [L]

[/quote]

<? include("http://".$_SERVER["HTTP_HOST"]."/websitetranslator/flags.php?site_url=".$_SERVER["HTTP_HOST"]."&page=".$_SERVER["REQUEST_URI"]."");?>

[/quote]

Warning: include() [function.include]: URL file-access is disabled in the server configuration in /home/.jazzycat/xionmac/phf.charliemcelvy.com/beta/index.php on line 97

Warning: include(http://www.phf.charliemcelvy.com/websitetranslator/flags.php?site_url=www.phf.charliemcelvy.com&page=/beta/index.php) [function.include]: failed to open stream: no suitable wrapper could be found in /home/.jazzycat/xionmac/phf.charliemcelvy.com/beta/index.php on line 97

Warning: include() [function.include]: Failed opening ‘http://www.phf.charliemcelvy.com/websitetranslator/flags.php?site_url=www.phf.charliemcelvy.com&page=/beta/index.php’ for inclusion (include_path=’.:/usr/local/php5/lib/php’) in /home/.jazzycat/xionmac/phf.charliemcelvy.com/beta/index.php on line 97

The heck is wrong here?? Please LMK if you have an idea as to what’s up with this…!

Best!!
Charlie


#2

OK – I’ve gotten past MOST of my errors; they apparently were stemming from DH’s block of the allow_url_fopen function (why? my understanding is that there’s no REAL security issue with leaving this active…??)

Anyway, here’s the new error I get, having substituted the ‘HTTP_HOST’ with ‘DOCUMENT_ROOT’ in all applicable files:

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/.jazzycat/xionmac/phf.charliemcelvy.com/beta/index.php on line 97

That line (#97) reads as such:

<? include($_SERVER["DOCUMENT_ROOT"]"/websitetranslator/flags.php?site_url="$_SERVER["DOCUMENT_ROOT"]"&page="$_SERVER["REQUEST_URI"]"");?>

Help! I’m trying to get a non-profit’s site to have the ability to be viewed in most languages on the fly…!

Thanks in advance!
Charlie


#3

You need to concatenate the strings and the vars in this line:

<? include($_SERVER["DOCUMENT_ROOT"]"/websitetranslator/flags.php?site_url="$_SERVER["DOCUMENT_ROOT"]"&page="$_SERVER["REQUEST_URI"]"");?>

so it looks like this:

<? include($_SERVER["DOCUMENT_ROOT"] . "/websitetranslator/flags.php?site_url=" . $_SERVER["DOCUMENT_ROOT"] . "&page=" . $_SERVER["REQUEST_URI"]);?>

I believe that should fix it, sorry for the late reply.


#4

Hey, late replies are better than none! I’m a beggar, can’t be a chooser, too :wink:

BUT, now I get this error:

Warning: include(/home/xionmac/phf.charliemcelvy.com/websitetranslator/flags.php?site_url=/home/xionmac/phf.charliemcelvy.com&page=/) [function.include]: failed to open stream: No such file or directory in /home/.jazzycat/xionmac/phf.charliemcelvy.com/index.php on line 98

Warning: include() [function.include]: Failed opening ‘/home/xionmac/phf.charliemcelvy.com/websitetranslator/flags.php?site_url=/home/xionmac/phf.charliemcelvy.com&page=/’ for inclusion (include_path=’.:/usr/local/php5/lib/php’) in /home/.jazzycat/xionmac/phf.charliemcelvy.com/index.php on line 98

HALP! :slight_smile:

Charlie


#5

maybe try $_SERVER[‘PHP_SELF’] instead of $_SERVER[‘DOCUMENT_ROOT’]


#6

Well, the errors aren’t getting any worse :wink:

Warning: include(/index.php/websitetranslator/flags.php?site_url=/index.php&page=/) [function.include]: failed to open stream: No such file or directory in /home/.jazzycat/xionmac/phf.charliemcelvy.com/index.php on line 46

Warning: include() [function.include]: Failed opening ‘/index.php/websitetranslator/flags.php?site_url=/index.php&page=/’ for inclusion (include_path=’.:/usr/local/php5/lib/php’) in /home/.jazzycat/xionmac/phf.charliemcelvy.com/index.php on line 46

PS – thanks for your help in this!

CM