Page 1 of 1

Multilanguage Site and Hack Issues

Posted: Thu Dec 18, 2003 5:04 pm
by Polo
Hi everyone,

I'm new here :D Hope someone can help me (and I hope I can help some people as well) :wink:

Ok, so here is what I'm having a little problem with...

I have a couple of pages, so I created a folder on my server and named it "english" in that folder I have my couple of pages, and what I want to do is translate my site into several languages.

So what I did, is I created a folder inside my "english" folder and named it "languages" inside that folder I added the file "english.php" this file has all the varialbes of my pages.

ex.

$welcome = "welcome";
$hello = "hello";

etc.. etc...

anyways, at the top of ever folder I added the following piece of php to replace the varialbes that are all over my site....

this is the piece of php that I added:

<? require "user/polo/public_html/english/languages/english.php" ?>

And the page looks perfectly fine, since it brings all of the varialbes from the english folder....

but I was wondering if using this piece of script at the top of every single page is dangerous, I mean can someone hack it or something like that?

now I'm ready to translate the "english.php" file into "spanish.php"

so far this has worked for me, maybe i'm doing it the wrong way, I do not know, I'm a newbie with php, so any comments or suggestions are welcome,

Thanks for everything,

sincerely

Posted: Thu Dec 18, 2003 5:09 pm
by qads
hmm, what you could do is make a function with a array, i.e.

Code: Select all

<?php
function check($current_lang)
{
$valid_lang[] = "english";
$valid_lang[] = "french";
$valid_lang[] = "dutch";
$valid_lang[] = "spanish";
if(in_array($current_lang, $valid_lang)
{
include("path/to/ur/langs/folder/$current_lang.php");
}
else
{
echo "you bad bad person, i hope your mom will be proud of what you have done.";
}
}
?>
just call that function on top of everypage to makesure whatever lange the user has selected is valid.

i am guessing you ARE allowing site users to select what lang they want to see the site in?!?!?

Posted: Thu Dec 18, 2003 5:53 pm
by Polo
Wow, that was fast! I will give it a try, thanks for your help qads, I really appreciate it.