示例#1
0
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) {
                        $url = get_absolute_url("login_api.php?{$token}", $value);
                        $scripts .= "<script src=\"{$url}\"></script>\n";
                    }
                }
                echo <<<HTML
{$scripts}
<script>
location.replace('{$return_url}');
示例#2
0
<?php

/**
 * 登录接口,多域名同步登录使用
 * @author 潘洪学 panliu888@gmail.com
 * @create_date	2011-10
 */
include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'init.php';
Passport::WriteCookie($_GET['uid'], $_GET['id'], $_GET['type'], $_GET['sign']);
echo '//ok';