Example #1
0
/**
* Send a notification email that the password has been reset
* @param string $memberid id of member
* @param string $password new password for user
*/
function send_pwdreset_email($memberid, $password)
{
    global $conf;
    $adminemail = $conf['app']['adminEmail'];
    $appTitle = $conf['app']['title'];
    $user = new User($memberid);
    $subject = $appTitle . ' ' . translate('Password Reset');
    $msg = $user->get_fname() . ",\r\n" . translate_email('password_reset', $appTitle, $password, $appTitle, CmnFns::getScriptURL(), $adminemail);
    $mailer = new PHPMailer();
    $mailer->AddAddress($user->get_email(), $user->get_name());
    $mailer->From = $adminemail;
    $mailer->FromName = $conf['app']['title'];
    $mailer->Subject = $subject;
    $mailer->Body = $msg;
    $mailer->Send();
}
Example #2
0
function findUser($userid)
{
    $found_user = false;
    if (!empty($userid)) {
        $user = new User($userid);
        if ($user != null) {
            $userid = $user->get_id();
            $fname = $user->get_fname();
            $lname = $user->get_lname();
            $email_address = $user->get_email();
            $found_user = true;
        } else {
            $found_user = false;
        }
    }
    return $found_user;
}
Example #3
0
 /**
  * Logs the user in
  * @param string $uname username
  * @param string $pass password
  * @param string $cookieVal y or n if we are using cookie
  * @param string $isCookie id value of user stored in the cookie
  * @param string $resume page to forward the user to after a login
  * @param string $lang language code to set
  * @return any error message that occured during login
  */
 function doLogin($uname, $pass, $cookieVal = null, $isCookie = false, $resume = '', $lang = '')
 {
     global $conf;
     $msg = '';
     if (empty($resume)) {
         $resume = 'ctrlpnl.php';
     }
     // Go to control panel by default
     $_SESSION['sessionID'] = null;
     $_SESSION['sessionName'] = null;
     $_SESSION['sessionAdmin'] = null;
     $_SESSION['hourOffset'] = null;
     $uname = stripslashes($uname);
     $pass = stripslashes($pass);
     $ok_user = $ok_pass = false;
     $use_logonname = (bool) $conf['app']['useLogonName'];
     $adminemail = strtolower($conf['app']['adminEmail']);
     if ($isCookie !== false) {
         // Cookie is set
         $cookieValue = $isCookie;
         if (($id = $this->verifyCookie($cookieValue)) !== false) {
             $ok_user = $ok_pass = true;
         } else {
             $ok_user = $ok_pass = false;
             setcookie('ID', '', time() - 3600, '/');
             // Clear out all cookies
             $msg .= translate('That cookie seems to be invalid') . '<br/>';
         }
     } else {
         if ($conf['ldap']['authentication']) {
             // Include LDAPEngine class
             include_once 'LDAPEngine.class.php';
             $ldap = new LDAPEngine($uname, $pass);
             if ($ldap->connected()) {
                 $mail = $ldap->getUserEmail();
                 if ($mail) {
                     $id = $this->db->userExists($mail);
                     if ($id) {
                         // check if LDAP and local DB are in consistancy.
                         $updates = $ldap->getUserData();
                         if ($this->db->check_updates($id, $updates)) {
                             $this->db->update_user($id, $updates);
                         }
                     } else {
                         $data = $ldap->getUserData();
                         $id = $this->do_register_user($data, false);
                     }
                     $ok_user = true;
                     $ok_pass = true;
                 } else {
                     $msg .= translate('This system requires that you have an email address.');
                 }
             } else {
                 $msg .= translate('Invalid User Name/Password.');
             }
             $ldap->disconnect();
         } else {
             // If we cant find email, set message and flag
             if (!($id = $this->db->userExists($uname, $use_logonname))) {
                 $msg .= translate('We could not find that logon in our database.') . '<br/>';
                 $ok_user = false;
             } else {
                 $ok_user = true;
             }
             // If password is incorrect, set message and flag
             if ($ok_user && !$this->db->isPassword($uname, $pass, $use_logonname)) {
                 $msg .= translate('That password did not match the one in our database.') . '<br/>';
                 $ok_pass = false;
             } else {
                 $ok_pass = true;
             }
         }
     }
     // If the login failed, notify the user and quit the app
     if (!$ok_user || !$ok_pass) {
         $msg .= translate('You can try');
         return $msg;
     } else {
         $this->is_loggedin = true;
         $user = new User($id);
         // Get user info
         // If the user wants to set a cookie, set it
         // for their ID and fname.  Expires in 30 days (2592000 seconds)
         if (!empty($cookieVal)) {
             //die ('Setting cookie');
             setcookie('ID', $this->generateCookie($user->get_id()), time() + 2592000, '/');
         }
         // If it is the admin, set session variable
         if ($user->get_email() == $adminemail || $user->get_isadmin()) {
             $_SESSION['sessionAdmin'] = $user->get_email();
         }
         // Set other session variables
         $_SESSION['sessionID'] = $user->get_id();
         $_SESSION['sessionName'] = $user->get_fname();
         $_SESSION['hourOffset'] = $user->get_timezone() - $conf['app']['timezone'];
         if ($lang != '') {
             set_language($lang);
             if ($lang != $user->get_lang()) {
                 $user->set_lang($lang);
                 // Language changed so update the DB
             }
         }
         // Send them to the control panel
         CmnFns::redirect(urldecode($resume));
     }
 }