Now setting default language

This commit is contained in:
duergner 2003-05-12 20:46:58 +00:00
parent 164df704d7
commit b404e9b9e2
1 changed files with 22 additions and 4 deletions

View File

@ -30,6 +30,7 @@ session_save_path("../sess"); // Set session save path
function display_LoginPage($config_object) function display_LoginPage($config_object)
{ {
global $error_message;
// generate 256 bit key and initialization vector for user/passwd-encryption // generate 256 bit key and initialization vector for user/passwd-encryption
$key = mcrypt_create_iv(32, MCRYPT_DEV_RANDOM); $key = mcrypt_create_iv(32, MCRYPT_DEV_RANDOM);
$iv = mcrypt_create_iv(32, MCRYPT_DEV_RANDOM); $iv = mcrypt_create_iv(32, MCRYPT_DEV_RANDOM);
@ -38,6 +39,9 @@ function display_LoginPage($config_object)
setcookie("Key", base64_encode($key), 0, "/"); setcookie("Key", base64_encode($key), 0, "/");
setcookie("IV", base64_encode($iv), 0, "/"); setcookie("IV", base64_encode($iv), 0, "/");
session_register("language");
$_SESSION["language"] = $config_object->get_defaultLanguage();
// loading available languages from language.conf file // loading available languages from language.conf file
$languagefile = "../config/language.conf"; $languagefile = "../config/language.conf";
@ -48,10 +52,18 @@ function display_LoginPage($config_object)
while(!feof($file)) while(!feof($file))
{ {
$line = fgets($file, 1024); $line = fgets($file, 1024);
if($line == "\n" || $line[0] == "#") continue; // ignore comment and empty lines if($line == "" || $line == "\n" || $line[0] == "#") continue; // ignore comment and empty lines
$value = explode(":", $line); $value = explode(":", $line);
$languages[$i]["link"] = $value[0] . ":" . $value[1]; $languages[$i]["link"] = $value[0] . ":" . $value[1];
$languages[$i]["descr"] = $value[2]; $languages[$i]["descr"] = $value[2];
if(rtrim($line) == $_SESSION["language"])
{
$languages[$i]["default"] = "YES";
}
else
{
$languages[$i]["default"] = "NO";
}
$i++; $i++;
} }
fclose($file); fclose($file);
@ -151,7 +163,14 @@ function display_LoginPage($config_object)
<select name=\"language\" size=\"1\">"; <select name=\"language\" size=\"1\">";
for($i = 0; $i < count($languages); $i++) for($i = 0; $i < count($languages); $i++)
{ {
echo "<option value=\"" . $languages[$i]["link"] . "\">" . $languages[$i]["descr"] . "</option>"; if($languages[$i]["default"] == "YES")
{
echo "<option selected value=\"" . $languages[$i]["link"] . ":" . $languages[$i]["descr"] . "\">" . $languages[$i]["descr"] . "</option>";
}
else
{
echo "<option value=\"" . $languages[$i]["link"] . ":" . $languages[$i]["descr"] . "\">" . $languages[$i]["descr"] . "</option>";
}
} }
echo " </select> echo " </select>
</td>"; </td>";
@ -199,9 +218,8 @@ if($_POST['action'] == "checklogin")
$result = $ldap->connect($_POST['username'],$_POST['passwd']); // Connect to LDAP server for verifing username/password $result = $ldap->connect($_POST['username'],$_POST['passwd']); // Connect to LDAP server for verifing username/password
if($result == True) // Username/password correct. Do some configuration and load main frame. if($result == True) // Username/password correct. Do some configuration and load main frame.
{ {
session_register('language'); // store selected language in session $_SESSION["language"] = $_POST["language"]; // Write selected language in session
session_register("ldap"); // Register $ldap object in session session_register("ldap"); // Register $ldap object in session
session_register("language"); // Register $language in session
include("./main.php"); // Load main frame include("./main.php"); // Load main frame
} }