コード例 #1
0
ファイル: funcs.php プロジェクト: bianle/www2
 function login_init()
 {
     global $currentuinfo;
     global $loginok;
     global $currentuser_num;
     global $currentuinfo_num;
     global $currentuser;
     global $utmpnum;
     global $setboard;
     global $fromhost;
     $currentuinfo_tmp = array();
     set_fromhost();
     $compat_telnet = 0;
     @($sessionid = $_GET["sid"]);
     //TODO: add the check of telnet compat
     if ($sessionid != '' && $_SERVER['PHP_SELF'] == '/bbscon.php') {
         $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 ($utmpkey == "") {
         $error = bbs_wwwlogin(0);
         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, "/");
             setcookie("LOGINTIME", $data["logintime"], 0, "/");
             setcookie("WWWPARAMS", WWW_DEFAULT_PARAMS, 0, "/");
             @($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 && $_SERVER["PHP_SELF"] != "/bbslogin.php") {
         error_nologin();
         return;
     }
     if ($loginok == 1 && (isset($setboard) && $setboard == 1)) {
         bbs_set_onboard(0, 0);
     }
     //add end
 }
コード例 #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;
    }
コード例 #3
0
ファイル: bbslogin.php プロジェクト: bianle/www2
        //normal
        break;
    case -1:
        prompt_multilogin();
        exit;
    case 3:
        error_alert("本帐号已停机或正在戒网");
    case 5:
        error_alert("登录过于频繁");
    case 1:
        error_alert("对不起,系统忙碌,请稍候再尝试登录");
    default:
        error_alert("登录错误,错误号:" . $error);
}
$data = array();
$num = bbs_getcurrentuinfo($data);
if ($data["userid"] != "guest") {
    $wwwparameters = bbs_getwwwparameters();
    setcookie("WWWPARAMS", $wwwparameters, 0, "/");
    $currentuser_num = bbs_getcurrentuser($currentuser);
    if (!($currentuser["userlevel"] & BBS_PERM_LOGINOK)) {
        $mainurl = "bbsnew.php";
    }
    $mbids = bbs_bm_get_manageable_bids();
    if ($mbids) {
        setcookie("MANAGEBIDS", $mbids, 0, "/");
    }
    header("Set-KBSRC: " . $data["userid"]);
}
setcookie("UTMPKEY", $data["utmpkey"], 0, "/");
setcookie("UTMPNUM", $num, 0, "/");
コード例 #4
0
ファイル: user.php プロジェクト: tilitala/nForum
 /**
  * function getInstance get a User object via userid
  *
  * @param string $id
  * @return User object
  * @static
  * @access public
  * @throws UserNullException
  */
 public static function getInstance($id = null, $cache = true)
 {
     $info = $uinfo = array();
     if (is_null($id)) {
         if (is_null(self::$_instance)) {
             //the call sequence can not be exchange
             if (bbs_getcurrentuinfo($uinfo) == 0) {
                 throw new UserNullException();
             }
             bbs_getcurrentuser($info);
             self::$_instance = new User($info, $uinfo);
         }
         return self::$_instance;
     }
     if (in_array($id, array_keys(self::$_users))) {
         return self::$_users[$id];
     }
     if (bbs_getuser($id, $info) == 0) {
         throw new UserNullException();
     }
     $u = new User($info, $uinfo);
     if ($cache) {
         self::$_users[$id] = $u;
     }
     return $u;
 }