示例#1
0
文件: ajax.class.php 项目: ATS001/MRN
 /**
  * Last Activité exec
  * update users_sys with last activité usuful for auto logout
  * return log && Error
  * 
  */
 private function last_active()
 {
     global $db;
     //Get last activity time and compare with now
     //if is elapsed logout
     $sql = "SELECT TIMESTAMPDIFF(MINUTE, lastactive, CURRENT_TIMESTAMP) as expir\n\t\t\t\tFROM users_sys \n\t\t        where id = " . MySQL::SQLValue(session::get('userid'));
     $time = $db->QuerySingleValue0($sql);
     if ($time > 20) {
         $this->error = false;
         $this->log .= ' </br>vous avez été deconnecté du serveur pour une inactivité de ' . $time . ' Minutes //AUTO_LOGOUT';
         $new_logout = new MLogin();
         $new_logout->token = session::get('username');
         $new_logout->logout();
     } else {
         //Update lastactive into users_sys
         $val_time['lastactive'] = 'CURRENT_TIMESTAMP';
         $whr_user['id'] = MySQL::SQLValue(session::get('userid'));
         if (!$db->UpdateRows('users_sys', $val_time, $whr_user)) {
             $this->log .= $db->Error();
             $this->error = false;
             $this->log .= '</br>Problème MAJ dérnière activité';
         }
     }
 }
示例#2
0
文件: forgot_c.php 项目: ATS001/MRN
    //Check if array have empty element return list
    //for acceptable empty field do not put here
    $checker = null;
    $empty_list = "Les champs suivants sont obligatoires:\n<ul>";
    if ($posted_data['email'] == NULL) {
        $empty_list .= "<li>L'adresse email ou Pseudo</li>";
        $checker = 1;
    }
    if ($posted_data['captcha'] == NULL) {
        $empty_list .= "<li>Le code Anti-robots</li>";
        $checker = 1;
    }
    if ($posted_data['captcha'] != $_SESSION['Captcha']) {
        $empty_list .= "<li>Le code Anti-robots Incorrect</li>";
        $checker = 1;
    }
    $empty_list .= "</ul>";
    if ($checker == 1) {
        exit("0#{$empty_list}");
    }
    //End check empty element
    $new_forgot = new MLogin($posted_data);
    //execute Login returne false if error
    if ($new_forgot->do_forgot()) {
        echo "1#" . $new_forgot->log;
    } else {
        echo "0#" . $new_forgot->log;
    }
} else {
    view::load('login', 'login');
}
示例#3
0
文件: login_c.php 项目: ATS001/MRN
<?php

if (MInit::form_verif(false)) {
    $posted_data = array('user' => Mreq::tp('user'), 'pass' => Mreq::tp('pass'));
    //Check if array have empty element return list
    //for acceptable empty field do not put here
    $checker = null;
    $empty_list = "Les champs suivants sont obligatoires:\n<ul>";
    if ($posted_data['user'] == NULL) {
        $empty_list .= "<li>Nom d'utilisateur</li>";
        $checker = 1;
    }
    if ($posted_data['pass'] == NULL) {
        $empty_list .= "<li>Mot de passe</li>";
        $checker = 1;
    }
    $empty_list .= "</ul>";
    if ($checker == 1) {
        exit("0#{$empty_list}");
    }
    //End check empty element
    $new_login = new MLogin($posted_data);
    //execute Login returne false if error
    if ($new_login->do_login()) {
        echo "1#" . $new_login->log;
    } else {
        echo "0#" . $new_login->log;
    }
} else {
    view::load('login', 'login');
}
示例#4
0
文件: logout_c.php 项目: ATS001/MRN
<?php

$new_logout = new MLogin();
$new_logout->token = session::get('username');
if ($new_logout->logout()) {
    header('location:./');
} else {
    MInit::msg_cor($new_logout->log, $err = "", $return = "");
    //exit('error');
}
示例#5
0
 public function authenticate($user, $pass, $log = true)
 {
     $base = $this->manager->getConf('login.ldap.base');
     $custom = $this->manager->getConf('login.ldap.custom');
     $schema = $this->manager->getConf('login.ldap.schema');
     $attr = $this->manager->getConf('login.ldap.userName');
     $l = $this->manager->getConf('login.ldap.login');
     $idPerson = $this->manager->getConf('login.ldap.idperson');
     $vars = array('%domain%' => $_SERVER['HOST_NAME'], '%login%' => $user, '%password%' => md5($pass), 'AND(' => '&(', 'OR(' => '|(');
     switch ($schema) {
         case 'manager':
             $search = '(&(login='******')(password='******'))';
             $login = false;
             break;
         case 'system':
             $search = 'uid=' . $user;
             $login = true;
             break;
         default:
             if ($custom) {
                 $search = strtr($custom, $vars);
             } else {
                 $search = strtr('(&(|(uid=%login%)(login=%login%))(objectClass=managerUser))', $vars);
             }
             $login = null;
     }
     $sr = ldap_search($this->conn, $base, $search, array('dn', $attr, 'password', 'managerGroup', $l, $idPerson));
     $info = ldap_get_entries($this->conn, $sr);
     for ($i = 0; $i < $info['count']; $i++) {
         $bind = $exists = false;
         if ($info[$i]['dn']) {
             if (!$login) {
                 $exists = $info[$i]['password'][0] == md5($pass);
             }
             if (!$exists && ($login || is_null($login))) {
                 $bind = ldap_bind($this->conn, $info[$i]['dn'], $pass);
             }
             if ($bind || $exists) {
                 $r = true;
                 break;
             }
         }
     }
     if ($l) {
         $user = $info[$i][$l][0];
     }
     $groups = array();
     if ($info[$i]['managergroup']['count'] > 0) {
         unset($info[$i]['managergroup']['count']);
         $groups = $info[$i]['managergroup'];
     }
     if ($log && $r) {
         $login = new MLogin($user, $pass, $info[$i][$attr][0], 0);
         $login->setIdPerson($info[$i][$idPerson][0]);
         $login->setGroups($groups);
         $this->setLogin($login);
     }
     return $r;
 }