コード例 #1
0
ファイル: bbslogout.php プロジェクト: bianle/www2
<?php

require "www2-funcs.php";
login_init();
bbs_wwwlogoff();
cache_header("nocache");
delete_all_cookie();
header("Location: index.html");
コード例 #2
0
ファイル: www2-funcs.php プロジェクト: bianle/www2
    function login_init($sid = FALSE, $no_auto_guest_login = FALSE)
    {
        global $currentuinfo;
        global $loginok;
        global $currentuser_num;
        global $currentuinfo_num;
        global $currentuser;
        global $utmpnum;
        global $setboard;
        global $fromhost;
        global $fullfromhost;
        $currentuinfo_tmp = array();
        $compat_telnet = 0;
        $sessionid = "";
        if ($sid) {
            if (is_string($sid)) {
                $sessionid = $sid;
            } else {
                @($sessionid = $_GET["sid"]);
                if (!$sessionid) {
                    @($sessionid = $_POST["sid"]);
                }
                if (!$sessionid) {
                    @($sessionid = $_COOKIE["sid"]);
                }
                settype($sessionid, "string");
            }
        }
        if ($sessionid && strlen($sessionid) == 9) {
            $utmpnum = decodesessionchar($sessionid[0]) + decodesessionchar($sessionid[1]) * 36 + decodesessionchar($sessionid[2]) * 36 * 36;
            $utmpkey = decodesessionchar($sessionid[3]) + decodesessionchar($sessionid[4]) * 36 + decodesessionchar($sessionid[5]) * 36 * 36 + decodesessionchar($sessionid[6]) * 36 * 36 * 36 + decodesessionchar($sessionid[7]) * 36 * 36 * 36 * 36 + decodesessionchar($sessionid[8]) * 36 * 36 * 36 * 36 * 36;
            $userid = '';
            $compat_telnet = 1;
        } else {
            @($utmpkey = $_COOKIE["UTMPKEY"]);
            @($utmpnum = $_COOKIE["UTMPNUM"]);
            @($userid = $_COOKIE["UTMPUSERID"]);
        }
        if ($utmpkey) {
            if (($ret = bbs_setonlineuser($userid, intval($utmpnum), intval($utmpkey), $currentuinfo_tmp, $compat_telnet)) == 0) {
                $loginok = 1;
                $currentuinfo_num = bbs_getcurrentuinfo();
                $currentuser_num = bbs_getcurrentuser($currentuser);
            } else {
                $utmpkey = "";
            }
        }
        // add by stiger, 如果登录失败就继续用guest登录
        if (!$sessionid && !$utmpkey && !$no_auto_guest_login) {
            set_fromhost();
            $error = bbs_wwwlogin(0, $fromhost, $fullfromhost);
            if ($error == 2 || $error == 0) {
                $data = array();
                $num = bbs_getcurrentuinfo($data);
                setcookie("UTMPKEY", $data["utmpkey"], 0, "/");
                setcookie("UTMPNUM", $num, 0, "/");
                setcookie("UTMPUSERID", $data["userid"], 0, "/");
                header("Set-KBSRC: /");
                @($utmpkey = $data["utmpkey"]);
                @($utmpnum = $num);
                @($userid = $data["userid"]);
                $compat_telnet = 1;
            }
            //guest 登录成功,设置一下
            if ($utmpkey != "") {
                if (($ret = bbs_setonlineuser($userid, intval($utmpnum), intval($utmpkey), $currentuinfo_tmp, $compat_telnet)) == 0) {
                    $loginok = 1;
                    $currentuinfo_num = bbs_getcurrentuinfo();
                    $currentuser_num = bbs_getcurrentuser($currentuser);
                }
            }
        }
        $currentuinfo = $currentuinfo_tmp;
        settype($utmpnum, "integer");
        if ($loginok != 1 && !$no_auto_guest_login) {
            delete_all_cookie();
            cache_header("nocache");
            ?>
<html>
	<head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /></head>
	<body>您还没有登录,或者你发呆时间过长被服务器清除。 请重新<a href="index.html" target="_top">登录</a>。</body>
</html>
<?php 
            exit;
        }
        if ($loginok == 1 && (isset($setboard) && $setboard == 1)) {
            bbs_set_onboard(0, 0);
        }
        return $sessionid;
    }