Esempio n. 1
0
 function remindPassword($email)
 {
     // returns:
     // - an empty string if the reminding e-mail is sent,
     // - string with an error message if something is wrong
     global $_SESSION, $_GET, $_POST, $_COOKIE;
     if ($_SESSION['password_sent'] == $email) {
         return;
     }
     // first check the mysql db
     $row = array();
     if ($this->insideMysqlDomain()) {
         $conn = nor_db_connect();
         $res = nor_db_q("select username,full_name from accounts where " . "username = "******" OR " . "username = "******"\\@.*", "", $email) . "@{$mailDomain}"), $conn);
         $row = nor_db_fetch_array($res, NOR_DB_ASSOC);
     }
     $localAccount = posix_getpwnam(eregi_replace("\\@.*", "", $email));
     if ($localAccount && preg_match("#/home/#i", $localAccount["dir"])) {
         $login = $localAccount["name"];
         $row['full_name'] = $localAccount["gecos"];
         $username = $login . "@" . $this->mailDomain;
         $password = "******";
         $this->dbg("remindPassword: localAccount login={$login}");
     } elseif ($row) {
         $username = $row['username'];
         $login = $username;
         $password = nor_random_password(8);
         nor_db_q("update accounts set password = "******" where username = "******"remindPassword: SQL username={$username}");
     } else {
         $this->dbg("remindPassword: Unknown user '{$email}'");
         return "Unknown address '{$email}'";
     }
     $this->dbg("remindPassword: sending mail to {$username} login={$login}");
     mail($username, "[login reminder] Password Request", "Dear {$row['full_name']},\n\nWe have received the password reminder request.\nThe request came from the host '" . gethostbyaddr($_SERVER['REMOTE_ADDR']) . "'.\nHere is the requested informtion:\n\n    Login:      {$login}\n    Password:   {$password}\n", "From: noReply@" . $this->mailDomain);
     $_SESSION['password_sent'] = $login;
 }
Esempio n. 2
0
function nor_group_by_name($name)
{
    $conn = nor_db_connect();
    $res = nor_db_q("select * from groups where groupname = " . nor_sql_quote($name), $conn);
    $row = nor_db_fetch_array($res, NOR_DB_ASSOC);
    return $row;
}