Beispiel #1
0
 /**
  * special helper method:
  * showCaptcha() returns an image, so we can use it in img tags in the views, like
  * <img src="......./login/showCaptcha" />
  */
 function showCaptcha()
 {
     $captcha = new Captcha();
     // generate new string with captcha characters and write them into $_SESSION['captcha']
     $captcha->generateCaptcha();
     // render a img showing the characters (=the captcha)
     $captcha->showCaptcha();
 }
Beispiel #2
0
            //设置cookie 记住用户id即可,把信息存放到浏览器
            setcookie('user_id', $user['a_id'], time() + 7 * 24 * 3600);
        }
        //没有勾选不操作
        //更新用户信息
        $admin->updateLoginInfo($user['a_id']);
        //sueecess,go to homepage 验证成功 进入首页
        admin_redirect('index.php', '登录成功', 1);
    } else {
        //false 验证失败
        admin_redirect('privilege.php', '帐号或密码错误');
    }
} elseif ($act == 'logout') {
    //logout用户退出
    //destroy or empty session
    session_destroy();
    //清除cookie
    if (isset($_COOKIE['user_id'])) {
        //设置cookie有效期1,表示70年过期,0表示关闭浏览器过期
        setcookie('user_id', '', 1);
    }
    //go to login.php
    admin_redirect('privilege.php?act=login', '退出成功');
} elseif ($act == 'captcha') {
    //用户想要获取验证码图片
    $captcha = new Captcha();
    //告知浏览器作为图片处理
    header('Content-type:image/png');
    //生成验证码图片
    $captcha->generateCaptcha();
}