- Joined
- Apr 11, 2009
- Messages
- 920
- Reaction score
- 463
Hello to all members of DarksTeam.net. I didn't post from a long time and I am sorry about that, that's why today I will post Language function that can be used on every kind of web that you have just include it make the connection with mysql and you are ready ;]
Hope you will enjoy it, stay tune for more ;]
Code:
//Language function
function wimpy_lang(){
//Scanning "./langs/" folder for all languages
$lang = scandir("./langs/");
foreach($lang as $sub_lang){
$sub_lang = str_replace(".", "", $sub_lang);
if(empty($sub_lang)){}
else{
//Scanning sub-folders for *.php file
$sub_lang = scandir("./langs/$sub_lang");
$today = date("d/m/Y - H:i:sa");
//Loop for taking care scanned languages
foreach($sub_lang as $value){
$path = str_replace(".php","", $value);
if(preg_match("/.php/is", $value)){
$lang_name = str_replace(".php", "", $value);
$desc_link = file_get_contents("./langs/$path/$value");
$desc = explode("/*", $desc_link);
$desc = explode("*/", $desc[1]);
$proverka = mysql_query("SELECT * FROM `Languages` WHERE lang_name='$lang_name'");
$row = mysql_fetch_row($proverka);
if($row[1] == $lang_name){}
else{
$insert_db = mysql_query("INSERT INTO `Languages` (lang_name,lang_dir,lang_desc,lang_date) VALUES ('$lang_name','./langs/$path/$value','$desc[0]','$today')") or die("Have some problem in 'Languages' query!");
}
}
else{}
}
}
}
//Select default language
if(!$_SESSION[language]){
include "./langs/English/English.php";
$_SESSION[language] = "English";
}
else{
include "./langs/$_SESSION[language]/$_SESSION[language].php";
}
}
Hope you will enjoy it, stay tune for more ;]
Last edited: