function open_session($login, $passwd, $cryptpasswd) { /* Verifie le login et le mot de passe sur l'annuaire ldap ouvre une session et cree le home et la bdd en cas de succes Renvoie : * true en cas de succes de la creation du home et de la bdd * false dans les autres cas */ global $urlauth, $scriptsbinpath, $authlink, $DBAUTH, $key_priv, $auth_mod; if ( user_valid_passwd ( $login , $passwd ) ) { /* Le mot de passe de $login est valide On ouvre une session LCS */ // Ouverture de la session php Lcs session_name("Lcs"); @session_start(); $_SESSION['login'] = $login; $_SESSION['token'] = rand(); // Creation du cookie LCSuser pour roundcube, pma... setcookie("LCSuser", xoft_encode( urlencode($passwd) ,$key_priv), 0,"/","",0); // Creation Espace Perso Utilisateur if ( !@is_dir("/home/".$login) || (@is_dir("/home/".$login) && ( !@is_dir("/home/".$login."/public_html") || !@is_dir("/home/".$login."/Maildir") || !@is_dir("/home/".$login."/Documents") || !@is_dir("/home/".$login."/Profile"))) ) { #system ("echo \"DBG >> Creation Espace perso\" >> /tmp/log.lcs"); $group=strtolower(people_get_group ($login)); exec ("/usr/bin/sudo /usr/share/lcs/scripts/mkhdir.sh ".escapeshellarg($login)." '$group' '$cryptpasswd' > /dev/null 2>&1"); } else { // Verification acces bdd et reinitialisation le cas echeant #system ("echo \"DBG >> Verif. acces mysql $login $passwd\" >> /tmp/log.lcs"); @((is_null($___mysqli_res = mysqli_close($GLOBALS["___mysqli_ston"]))) ? false : $___mysqli_res); @($GLOBALS["___mysqli_ston"] = mysqli_connect("localhost", $login, $passwd )); if ( ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)) ) { exec ( escapeshellarg("$scriptsbinpath/mysqlPasswInit.pl")." ". escapeshellarg($login) ." ". escapeshellarg($passwd) ); #system ("echo \"DBG >> Reinit mdp mysql $login $passwd\" >> /tmp/log.lcs"); } @((is_null($___mysqli_res = mysqli_close($GLOBALS["___mysqli_ston"]))) ? false : $___mysqli_res); } return true; } return false; }
} } } ((mysqli_free_result($result) || (is_object($result) && (get_class($result) == "mysqli_result"))) ? true : false); } if ( ! isset ($urluse) ) $urluse=$url_accueil; # # Detection de l'origine de la requete # list ($ip_client_prefix) = explode (".", remote_ip()); list ($ip_serv_prefix) = explode (".",getenv("SERVER_ADDR")); if ( $ip_client_prefix == $ip_serv_prefix) $source="lan"; else $source="wan"; # # Determination du groupe principal de l'utilisateur connecte # $group=people_get_group ($login); # # TimeStamp # $date=date("YmdHis"); # # Enregistrement dans la table statusages # $use=((isset($GLOBALS["___mysqli_ston"]) && is_object($GLOBALS["___mysqli_ston"])) ? mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $use) : ((trigger_error("[MySQLConverterToo] Fix the mysql_escape_string() call! This code does not work.", E_USER_ERROR)) ? "" : "")); $query="INSERT INTO statusages VALUES ('$group', '$use', '$date', '$source','$login')"; $result=@mysqli_query( $authlink, $query); # # Redirection # header("Location:$urluse"); ?>
if (isset($_POST['string_renew_mdp'])) $string_renew_mdp=$purifier->purify($_POST['string_renew_mdp']); } //ckeck Lcs account if (isset($_POST['string_mdp']) && (isset($_POST['string_login']))&& (isset($_POST['string_lilie']))) { // Verif login / password on LCS LDAP $password = decodekey($string_mdp); if ( user_valid_passwd ( $string_login, $password ) ) { // If password account OK // Create user home folder and data base $login = $string_login; $cryptpasswd = $string_mdp; if ( !@is_dir("/home/".$login) || (@is_dir("/home/".$login) && ( !@is_dir("/home/".$login."/public_html") || !@is_dir("/home/".$login."/Maildir") || !@is_dir("/home/".$login."/Documents"))) ) { $group=strtolower(people_get_group ($login)); exec ("/usr/bin/sudo /usr/share/lcs/scripts/mkhdir.sh ".escapeshellarg($login)." '$group' '$cryptpasswd' > /dev/null 2>&1"); } //Compare with date of birth if ( ! pwdMustChange ($string_login) ) { //If password account is different than date of birth // Insert data in ent_lcs table if (!@((bool)mysqli_query( $authlink, "USE " . $DBAUTH))) die ("Sélection de base de données impossible."); // Verification si une entree login existe dans la table ent_lcs.login_lcs $login=((isset($GLOBALS["___mysqli_ston"]) && is_object($GLOBALS["___mysqli_ston"])) ? mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $login) : ((trigger_error("[MySQLConverterToo] Fix the mysql_escape_string() call! This code does not work.", E_USER_ERROR)) ? "" : "")); $string_lilie=((isset($GLOBALS["___mysqli_ston"]) && is_object($GLOBALS["___mysqli_ston"])) ? mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $tring_lilie) : ((trigger_error("[MySQLConverterToo] Fix the mysql_escape_string() call! This code does not work.", E_USER_ERROR)) ? "" : "")); $query="SELECT id FROM ent_lcs WHERE login_lcs='$login_escp'"; $result=@mysqli_query($authlink, $query); if ( mysqli_num_rows($result) == "0" ) {