index c93410bd41a0651d899cfe96871f868affaa2c54..459512228ef18b6574e2257483c79b57d07ca091 100644 (file)
<?php
/*
- This code is part of GOsa (https://gosa.gonicus.de)
- Copyright (C) 2003-2007 Cajus Pollmeier
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * This code is part of GOsa (http://www.gosa-project.org)
+ * Copyright (C) 2003-2008 GONICUS GmbH
+ *
+ * ID: $$Id$$
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
function displayPWchanger()
header("Content-type: text/html; charset=UTF-8");
-session_start();
+session::start();
/* Destroy old session if exists.
Else you will get your old session back, if you not logged out correctly. */
-if(is_array($_SESSION) && count($_SESSION)){
- session_destroy();
- session_start();
+if(is_array(session::get_all()) && count(session::get_all())){
+ session::destroy();
+ session::start();
}
/* Reset errors */
-$_SESSION['js'] = true;
-$_SESSION['errors'] = "";
-$_SESSION['errorsAlreadyPosted']= array();
-$_SESSION['LastError'] = "";
+session::global_set('js',true);
+session::set('errors',"");
+session::set('errorsAlreadyPosted',array());
+session::set('LastError',"");
/* Check if CONFIG_FILE is accessible */
if (!is_readable(CONFIG_DIR."/".CONFIG_FILE)){
- echo sprintf(_("GOsa configuration %s/%s is not readable. Aborted."), CONFIG_DIR,CONFIG_FILE);
- exit();
+ msg_dialog::display(_("Fatal error"), sprintf(_("GOsa configuration %s/%s is not readable. Aborted."),CONFIG_DIR,CONFIG_FILE), FATAL_ERROR_DIALOG);
+ exit;
}
/* Parse configuration file */
$config= new config(CONFIG_DIR."/".CONFIG_FILE, $BASE_DIR);
-$_SESSION['DEBUGLEVEL']= $config->data['MAIN']['DEBUGLEVEL'];
+session::global_set('DEBUGLEVEL', $config->get_cfg_value("debuglevel"));
if ($_SERVER["REQUEST_METHOD"] != "POST"){
@DEBUG (DEBUG_CONFIG, __LINE__, __FUNCTION__, __FILE__, $config->data, "config");
}
/* Set template compile directory */
-if (isset ($config->data['MAIN']['COMPILE'])){
- $smarty->compile_dir= $config->data['MAIN']['COMPILE'];
-} else {
- $smarty->compile_dir= '/var/spool/gosa';
-}
+$smarty->compile_dir= $config->get_cfg_value("templateCompileDirectory", '/var/spool/gosa');
/* Check for compile directory */
if (!(is_dir($smarty->compile_dir) && is_writable($smarty->compile_dir))){
- echo sprintf(_("Directory '%s' specified as compile directory is not accessible!"),
- $smarty->compile_dir);
- exit();
+ msg_dialog::display(_("Configuration error"), sprintf(_("Directory '%s' specified as compile directory is not accessible!"),
+ $smarty->compile_dir), FATAL_ERROR_DIALOG);
+ exit;
}
/* Check for old files in compile directory */
clean_smarty_compile_dir($smarty->compile_dir);
/* Language setup */
-if ($config->data['MAIN']['LANG'] == ""){
+if ($config->get_cfg_value("language") == ""){
$lang= get_browser_language();
} else {
- $lang= $config->data['MAIN']['LANG'];
+ $lang= $config->get_cfg_value("language");
}
$lang.=".UTF-8";
putenv("LANGUAGE=");
/* Set the text domain as 'messages' */
$domain = 'messages';
-bindtextdomain($domain, "$BASE_DIR/locale");
+bindtextdomain($domain, LOCALE_DIR);
textdomain($domain);
/* Generate server list */
/* Set config to selected one */
$config->set_current($directory);
-$_SESSION['config']= $config;
+session::global_set('config',$config);
if ($_SERVER["REQUEST_METHOD"] != "POST"){
@DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $lang, "Setting language to");
}
/* If SSL is forced, just forward to the SSL enabled site */
-if ($config->data['MAIN']['FORCESSL'] == 'true' && $ssl != ''){
+if ($config->get_cfg_value("forcessl") == 'true' && $ssl != ''){
header ("Location: $ssl");
exit;
}
/* Check for selected password method */
-$method= $config->current['HASH'];
+$method= $config->get_cfg_value("hash", "crypt/md5");
if (isset($_GET['method'])){
$method= validate($_GET['method']);
$tmp = new passwordMethod($config);
$available = $tmp->get_available_methods();
if (!isset($available[$method])){
- echo _("Error: Password method not available!");
+ msg_dialog::display(_("Password method"),_("Error: Password method not available!"),FATAL_ERROR_DIALOG);
exit;
}
}
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['apply'])){
/* Destroy old sessions, they cause a successfull login to relog again ...*/
- if(isset($_SESSION['_LAST_PAGE_REQUEST'])){
- $_SESSION['_LAST_PAGE_REQUEST'] = time();
+ if(session::global_is_set('_LAST_PAGE_REQUEST')){
+ session::global_set('_LAST_PAGE_REQUEST',time());
}
$message= array();
$message[]= _("The passwords you've entered as 'New password' and 'Repeated new password' do not match.");
} else {
if ($_POST['new_password'] == ""){
- $message[]= _("The password you've entered as 'New password' is empty.");
+ $message[]= msgPool::required(_("New password"));
}
}
/* Password policy fulfilled? */
- if (isset($config->data['MAIN']['PWDIFFER'])){
- $l= $config->data['MAIN']['PWDIFFER'];
+ if ($config->get_cfg_value("passwordMinDiffer") != ""){
+ $l= $config->get_cfg_value("passwordMinDiffer");
if (substr($_POST['current_password'], 0, $l) == substr($_POST['new_password'], 0, $l)){
$message[]= _("The password used as new and current are too similar.");
}
}
- if (isset($config->data['MAIN']['PWMINLEN'])){
- if (strlen($_POST['new_password']) < $config->data['MAIN']['PWMINLEN']){
+ if ($config->get_cfg_value("passwordMinLength") != ""){
+ if (strlen($_POST['new_password']) < $config->get_cfg_value("passwordMinLength")){
$message[]= _("The password used as new is to short.");
}
}
/* Validate */
- if (!ereg("^[A-Za-z0-9_.-]+$", $uid)){
- $message[]= _("Please specify a valid username!");
+ if (!tests::is_uid($uid)){
+ $message[]= msgPool::invalid(_("Login"));
} elseif (mb_strlen($_POST["current_password"], 'UTF-8') == 0){
- $message[]= _("Please specify your password!");
+ $message[]= msgPool::required(_("Current password"));
} else {
/* Do we have the selected user somewhere? */
/* Do we need to show error messages? */
if (count ($message) != 0){
/* Show error message and continue editing */
- show_errors($message);
+ msg_dialog::displayChecks($message);
} else {
/* Passed quality check, just try to change the password now */
$output= "";
- if (isset($config->data['MAIN']['EXTERNALPWDHOOK'])){
- exec($config->data['MAIN']['EXTERNALPWDHOOK']." ".$ui->username." ".
+ if ($config->get_cfg_value("passwordHook") != ""){
+ exec($config->get_cfg_value("passwordHook")." ".$ui->username." ".
$_POST['current_password']." ".$_POST['new_password'], $resarr);
if(count($resarr) > 0) {
$output= join('\n', $resarr);
}
if ($output != ""){
$message[]= _("External password changer reported a problem: ".$output);
- show_errors($message);
+ msg_dialog::displayChecks($message);
} else {
if ($method != ""){
change_password ($ui->dn, $_POST['new_password'], 0, $method);
$smarty->assign ('password_img', get_template_path('images/password.png'));
/* Displasy SSL mode warning? */
-if ($ssl != "" && $config->data['MAIN']['WARNSSL'] == 'true'){
+if ($ssl != "" && $config->get_cfg_value("warnssl") == 'true'){
$smarty->assign ("ssl", "<b>"._("Warning").":</b> "._("Session will not be encrypted.")." <a style=\"color:red;\" href=\"".htmlentities($ssl)."\"><b>"._("Enter SSL session")."</b></a>!");
} else {
$smarty->assign ("ssl", "");
}
/* show login screen */
+$smarty->assign("JS",session::global_get('js'));
$smarty->assign ("PHPSESSID", session_id());
-if (isset($_SESSION['errors'])){
- $smarty->assign("errors", $_SESSION['errors']);
+if (session::is_set('errors')){
+ $smarty->assign("errors", session::get('errors'));;
}
if ($error_collector != ""){
$smarty->assign("php_errors", $error_collector."</div>");
$smarty->assign("php_errors", "");
}
+$smarty->assign("msg_dialogs", msg_dialog::get_dialogs());
displayPWchanger();
?>