Example #1
0
// Validation
if (isset($_POST['valid']) && $_POST['valid'] == '1' || $from_admin) {
    $adh = null;
    $login_adh = null;
    if (($login->isAdmin() || $login->isStaff()) && isset($_GET['id_adh'])) {
        $adh = new Adherent((int) $_GET['id_adh']);
        $login_adh = $adh->login;
    } else {
        $login_adh = $_POST['login'];
        $adh = new Adherent($login_adh);
    }
    if ($adh->id != '') {
        //account has been found, proceed
        if (Core\GaletteMail::isValidEmail($adh->email)) {
            $password = new Core\Password();
            $res = $password->generateNewPassword($adh->id);
            if ($res == true) {
                $link_validity = new DateTime();
                $link_validity->add(new DateInterval('PT24H'));
                $df = _T("Y-m-d H:i:s");
                $proto = 'http';
                if (isset($_SERVER['HTTPS'])) {
                    $proto = 'https';
                }
                $texts = new Texts($texts_fields, $preferences, array('change_pass_uri' => $proto . '://' . $_SERVER['SERVER_NAME'] . dirname($_SERVER['REQUEST_URI']) . '/change_passwd.php?hash=' . urlencode($password->getHash()), 'link_validity' => $link_validity->format(_T("Y-m-d H:i:s")), 'login_adh' => custom_html_entity_decode($adh->login, ENT_QUOTES)));
                $mtxt = $texts->getTexts('pwd', $adh->language);
                $mail = new Core\GaletteMail();
                $mail->setSubject($texts->getSubject());
                $mail->setRecipients(array($adh->email => $adh->sname));
                $mail->setMessage($texts->getBody());
                $sent = $mail->send();