Exemplo n.º 1
0
$mosh = new mosh_tool();
/** decide on a course of action **/
if (isset($_POST['f_op']) and $_POST['f_op'] == OP_GET_EMAIL) {
    $ACTION = OP_SEND_TOKEN;
} elseif (isset($_POST['f_op_send'])) {
    $ACTION = OP_RESET_PASS_PROC;
} elseif (!empty($_GET[$recover_key_name])) {
    $ACTION = OP_RESET_PASS;
} else {
    $ACTION = OP_GET_EMAIL;
}
/** now take the action **/
if ($ACTION == OP_SEND_TOKEN) {
    // check email addr and send email to user
    $femail = $_POST['f_email'];
    if (!$mosh->is_proper_email($_POST['f_email'])) {
        $smarty->assign('BAD_EMAIL', htmlspecialchars($femail));
        $ACTION = OP_GET_EMAIL;
    } else {
        if (!($uid = $user->get_id_by_email($femail))) {
            $smarty->assign('EMAIL_NOT_FOUND', htmlspecialchars($femail));
            $ACTION = OP_GET_EMAIL;
        } else {
            $user->set_id($uid);
            $user->force_pword_change(false);
            $smarty->assign('EMAIL_SENT', htmlspecialchars($femail));
            $user->send_pass_notification(false);
            $auth->unauth();
            $SHOWFORM = false;
        }
    }