Esempio n. 1
0
 /**
  * 判断未登录,则跳转到登陆页
  */
 public static function RequireLogin()
 {
     if (!Passport::IsLogin()) {
         redirect('login.php?return_url=' . urlencode($_SERVER['REQUEST_URI']));
         exit('尚未登录,<a href="login.php?return_url=' . urlencode($_SERVER['REQUEST_URI']) . '">请登录</a>!');
     }
 }
Esempio n. 2
0
<?php

/**
 * 注册页面
 * @author 潘洪学 panliu888@gmail.com
 * @create_date	2011-10
 */
include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'init.php';
if (Passport::IsLogin()) {
    redirect('index.php');
}
if (Request::IsPost()) {
    $fields = $_POST['f'];
    if (validate($fields)) {
        $user = new User();
        $ret = $user->getByName($fields['username']);
        $TEMPLATE['error'] = array();
        if ($ret) {
            $TEMPLATE['error']['username'] = '******';
        } else {
            $tableInfo = array('username' => $fields['username'], 'password' => md5($fields['password']), 'type' => $user->totals() == 0 ? 1 : 0, 'reg_date' => time(), 'last_login' => time());
            $newid = $user->insertIgnore($tableInfo);
            if ($newid) {
                $ret = Passport::WriteCookie($newid, $tableInfo['username'], $tableInfo['type']);
                $return_url = get_returnurl('index.php');
                $wt_open = new WTOpen();
                $cbs = $wt_open->getCallbackList();
                $scripts = '';
                if (count($cbs) > 0) {
                    $token = http_build_query($ret);
                    foreach ($cbs as $value) {