////处理SID
$sid = daddslashes(($transsidstatus || CURSCRIPT == 'wap') && (isset($_GET['sid']) || isset($_POST['sid'])) ?
(isset($_GET['sid']) ? $_GET['sid'] : $_POST['sid']) :
(isset($_DCOOKIE['sid']) ? $_DCOOKIE['sid'] : ''));
CURSCRIPT == 'attachment' && isset($_GET['sid']) && $sid = addslashes(authcode($_GET['sid'], 'DECODE', $_DCACHE['settings']['authkey']));
//加密key
$discuz_auth_key = md5($_DCACHE['settings']['authkey'].$_SERVER['HTTP_USER_AGENT']);
//解密cookie
list($discuz_pw, $discuz_secques, $discuz_uid) = empty($_DCOOKIE['auth']) ? array('', '', 0) : daddslashes(explode("\t", authcode($_DCOOKIE['auth'], 'DECODE')), 1);
//初始用户变量
$prompt = $sessionexists = $seccode = 0;
$membertablefields = 'm.uid AS discuz_uid, m.username AS discuz_user, m.password AS discuz_pw, m.secques AS discuz_secques,
m.adminid, m.groupid, m.groupexpiry, m.extgroupids, m.email, m.timeoffset, m.tpp, m.ppp, m.posts, m.digestposts,
m.oltime, m.pageviews, m.credits, m.extcredits1, m.extcredits2, m.extcredits3, m.extcredits4, m.extcredits5,
m.extcredits6, m.extcredits7, m.extcredits8, m.timeformat, m.dateformat, m.pmsound, m.sigstatus, m.invisible,
m.lastvisit, m.lastactivity, m.lastpost, m.prompt, m.accessmasks, m.editormode, m.customshow, m.customaddfeed';
if($sid) {//对用户进行权限管理,如是登陆用户进一步完善信息,如是游客,清除本地cookie
if($discuz_uid) {//如果用户存在查询SESSION表中的SESSION
$query = $db->query("SELECT s.sid, s.styleid, s.groupid='6' AS ipbanned, s.pageviews AS spageviews, s.lastolupdate, s.seccode, $membertablefields
FROM {$tablepre}sessions s, {$tablepre}members m
WHERE m.uid=s.uid AND s.sid='$sid' AND CONCAT_WS('.',s.ip1,s.ip2,s.ip3,s.ip4)='$onlineip' AND m.uid='$discuz_uid'
AND m.password='$discuz_pw' AND m.secques='$discuz_secques'");
} else {//查询当前游客存在SESSION表中的SESSION
$query = $db->query("SELECT sid, uid AS sessionuid, groupid, groupid='6' AS ipbanned, pageviews AS spageviews, styleid, lastolupdate, seccode
FROM {$tablepre}sessions WHERE sid='$sid' AND CONCAT_WS('.',ip1,ip2,ip3,ip4)='$onlineip'");
}
if($_DSESSION = $db->fetch_array($query)) {//当前用户SESSION存在
$sessionexists = 1;
if(!empty($_DSESSION['sessionuid'])) {//判断是否为游客 完善登陆用户SESSION
$_DSESSION = array_merge($_DSESSION, $db->fetch_first("SELECT $membertablefields
FROM {$tablepre}members m WHERE uid='$_DSESSION[sessionuid]'"));
}
} else {//游客
//清除游客本地的COOKIE
if($_DSESSION = $db->fetch_first("SELECT sid, groupid, groupid='6' AS ipbanned, pageviews AS spageviews, styleid, lastolupdate, seccode
FROM {$tablepre}sessions WHERE sid='$sid' AND CONCAT_WS('.',ip1,ip2,ip3,ip4)='$onlineip'")) {
clearcookies();
$sessionexists = 1;
}
}
}
//SESSION不存在
if(!$sessionexists) {
if($discuz_uid) {//登陆用户 获取信息
if(!($_DSESSION = $db->fetch_first("SELECT $membertablefields, m.styleid
FROM {$tablepre}members m WHERE m.uid='$discuz_uid' AND m.password='$discuz_pw' AND m.secques='$discuz_secques'"))) {
clearcookies();
}
}
//判断当前用户IP是否受限
if(ipbanned($onlineip)) $_DSESSION['ipbanned'] = 1;
$_DSESSION['sid'] = random(6);
$_DSESSION['seccode'] = random(6, 1);
}
//获取日期时间格式
$_DSESSION['dateformat'] = empty($_DSESSION['dateformat']) || empty($_DCACHE['settings']['userdateformat'][$_DSESSION['dateformat'] -1])? $_DCACHE['settings']['dateformat'] : $_DCACHE['settings']['userdateformat'][$_DSESSION['dateformat'] -1];
$_DSESSION['timeformat'] = empty($_DSESSION['timeformat']) ? $_DCACHE['settings']['timeformat'] : ($_DSESSION['timeformat'] == 1 ? 'h:i A' : 'H:i');
$_DSESSION['timeoffset'] = isset($_DSESSION['timeoffset']) && $_DSESSION['timeoffset'] != 9999 ? $_DSESSION['timeoffset'] : $_DCACHE['settings']['timeoffset'];
$membertablefields = '';
@extract($_DSESSION);
$newpm = $prompt & 1;
$doingtask = $prompt & 2 ? 1 : 0;
//上次访问 当前时间,格式为用户定义的格式(游客为默认设置)
$lastvisit = empty($lastvisit) ? $timestamp - 86400 : $lastvisit;
$timenow = array('time' => gmdate("$dateformat $timeformat", $timestamp + 3600 * $timeoffset),
'offset' => ($timeoffset >= 0 ? ($timeoffset == 0 ? '' : '+'.$timeoffset) : $timeoffset));
if(PHP_VERSION > '5.1') {
@date_default_timezone_set('Etc/GMT'.($timeoffset > 0 ? '-' : '+').(abs($timeoffset)));
}
$accessadd1 = $accessadd2 = $modadd1 = $modadd2 = $metadescription = '';
//判断是否为登陆用户
//游客扩展信息设为默认
if(empty($discuz_uid) || empty($discuz_user)) {//用户处理,游客
$discuz_user = $extgroupids = '';
$discuz_uid = $adminid = $posts = $digestposts = $pageviews = $oltime = $invisible
= $credits = $extcredits1 = $extcredits2 = $extcredits3 = $extcredits4
= $extcredits5 = $extcredits6 = $extcredits7 = $extcredits8 = 0;
$groupid = empty($groupid) || $groupid != 6 ? 7 : 6;
} else {//已登录处理,判断管理员
$discuz_userss = $discuz_user;
$discuz_user = addslashes($discuz_user);
if($accessmasks) {
$accessadd1 = ', a.allowview, a.allowpost, a.allowreply, a.allowgetattach, a.allowpostattach';
$accessadd2 = "LEFT JOIN {$tablepre}access a ON a.uid='$discuz_uid' AND a.fid=f.fid";
}
if($adminid == 3) {
$modadd1 = ', m.uid AS ismoderator';
$modadd2 = "LEFT JOIN {$tablepre}moderators m ON m.uid='$discuz_uid' AND m.fid=f.fid";
}
}
if($errorreport == 2 || ($errorreport == 1 && $adminid > 0)) {
error_reporting(E_ERROR | E_WARNING | E_PARSE);
}
//定义论坛哈希值
define('FORMHASH', formhash());
//包含统计页面
$statstatus && !$inajax && require_once DISCUZ_ROOT.'./include/counter.inc.php';
$extra = isset($extra) && @preg_match("/^[&=;a-z0-9]+$/i", $extra) ? $extra : '';
$rsshead = $navtitle = $navigation = '';
//判断组,载入用户组缓存
$_DSESSION['groupid'] = $groupid = empty($ipbanned) ? (empty($groupid) ? 7 : intval($groupid)) : 6;
if(!@include DISCUZ_ROOT.'./forumdata/cache/usergroup_'.$groupid.'.php') {
$grouptype = $db->result_first("SELECT type FROM {$tablepre}usergroups WHERE groupid='$groupid'");
if(!empty($grouptype)) {
$cachelost .= ' usergroup_'.$groupid;
} else {
$grouptype = 'member';
}
} |