/** * 用户登录后处理 * * @param object $jieqiUsers 用户对象 * @access public * @return bool */ function jieqi_loginprocess($jieqiUsers, $usecookie = 0) { global $jieqiConfigs; global $jieqiHonors; global $jieqiGroups; if (!isset($jieqiConfigs['system'])) { jieqi_getconfigs('system', 'configs'); } include_once JIEQI_ROOT_PATH . '/class/users.php'; $users_handler =& JieqiUsersHandler::getInstance('JieqiUsersHandler'); //更新在线用户表 include_once JIEQI_ROOT_PATH . '/class/online.php'; $online_handler =& JieqiOnlineHandler::getInstance('JieqiOnlineHandler'); $criteria = new CriteriaCompo(new Criteria('uid', $jieqiUsers->getVar('uid', 'n'))); $criteria->setSort('updatetime'); $criteria->setOrder('DESC'); $online_handler->queryObjects($criteria); $online = $online_handler->getObject(); //读cookie信息 $jieqi_user_info = array(); if (!empty($_COOKIE['jieqiUserInfo'])) { $jieqi_user_info = jieqi_strtosary($_COOKIE['jieqiUserInfo']); } else { $jieqi_user_info = array(); } $jieqi_visit_info = array(); if (!empty($_COOKIE['jieqiVisitInfo'])) { $jieqi_visit_info = jieqi_strtosary($_COOKIE['jieqiVisitInfo']); } else { $jieqi_visit_info = array(); } if (is_object($online)) { $ip = jieqi_userip(); if (JIEQI_SESSION_EXPRIE > 0) { $exprie_time = JIEQI_SESSION_EXPRIE; } else { $exprie_time = @ini_get('session.gc_maxlifetime'); } if (empty($exprie_time)) { $exprie_time = 1800; } if (defined('JIEQI_DENY_RELOGIN') && JIEQI_DENY_RELOGIN == 1 && JIEQI_NOW_TIME - $online->getVar('updatetime') < $exprie_time && $online->getVar('ip', 'n') != $ip && $jieqi_visit_info['jieqiUserId'] != $jieqiUsers->getVar('uid')) { return -8; } $tmpvar = strlen($jieqiUsers->getVar('name', 'q')) > 0 ? $jieqiUsers->getVar('name', 'q') : $jieqiUsers->getVar('uname', 'q'); $sql = "UPDATE " . jieqi_dbprefix('system_online') . " SET uid=" . $jieqiUsers->getVar('uid', 'q') . ", sid='" . jieqi_dbslashes(session_id()) . "', uname='" . $jieqiUsers->getVar('uname', 'q') . "', name='" . $tmpvar . "', pass='******'pass', 'q') . "',email='" . $jieqiUsers->getVar('email', 'q') . "', groupid=" . $jieqiUsers->getVar('groupid', 'q') . ", updatetime=" . JIEQI_NOW_TIME . ", ip='" . jieqi_dbslashes($ip) . "' WHERE uid=" . $jieqiUsers->getVar('uid', 'q') . " OR sid='" . jieqi_dbslashes(session_id()) . "'"; $online_handler->db->query($sql); } else { include_once JIEQI_ROOT_PATH . '/include/visitorinfo.php'; $online = $online_handler->create(); $online->setVar('uid', $jieqiUsers->getVar('uid', 'n')); $online->setVar('siteid', JIEQI_SITE_ID); $online->setVar('sid', session_id()); $online->setVar('uname', $jieqiUsers->getVar('uname', 'n')); $tmpvar = strlen($jieqiUsers->getVar('name', 'n')) > 0 ? $jieqiUsers->getVar('name', 'n') : $jieqiUsers->getVar('uname', 'n'); $online->setVar('name', $tmpvar); $online->setVar('pass', $jieqiUsers->getVar('pass', 'n')); $online->setVar('email', $jieqiUsers->getVar('email', 'n')); $online->setVar('groupid', $jieqiUsers->getVar('groupid', 'n')); $tmpvar = JIEQI_NOW_TIME; $online->setVar('logintime', $tmpvar); $online->setVar('updatetime', $tmpvar); $online->setVar('operate', ''); $tmpvar = VisitorInfo::getIp(); $online->setVar('ip', $tmpvar); $online->setVar('browser', VisitorInfo::getBrowser()); $online->setVar('os', VisitorInfo::getOS()); $location = VisitorInfo::getIpLocation($tmpvar); if (JIEQI_SYSTEM_CHARSET == 'big5') { include_once JIEQI_ROOT_PATH . '/include/changecode.php'; $location = jieqi_gb2big5($location); } $online->setVar('location', $location); $online->setVar('state', '0'); $online->setVar('flag', '0'); $online_handler->insert($online); } //删除过期的在线用户 unset($criteria); $criteria = new CriteriaCompo(new Criteria('updatetime', JIEQI_NOW_TIME - $jieqiConfigs['system']['onlinetime'], '<')); $online_handler->delete($criteria); //检查短消息 include_once JIEQI_ROOT_PATH . '/class/message.php'; $message_handler = JieqiMessageHandler::getInstance('JieqiMessageHandler'); $criteria = new CriteriaCompo(new Criteria('toid', $jieqiUsers->getVar('uid'), '=')); $criteria->add(new Criteria('isread', 0, '=')); $criteria->add(new Criteria('todel', 0, '=')); $newmsgnum = $message_handler->getCount($criteria); unset($criteria); //有短消息 //用户信息 $previewlogin = intval($jieqiUsers->getVar('lastlogin')); $jieqiUsers->setVar('lastlogin', JIEQI_NOW_TIME); $userset = unserialize($jieqiUsers->getVar('setting', 'n')); if (!isset($userset['lastip']) || $userset['lastip'] != jieqi_userip()) { $userset['lastip'] = jieqi_userip(); } if (!isset($userset['logindate']) || $userset['logindate'] != date('Y-m-d')) { $userset['logindate'] = date('Y-m-d'); //增加登陆积分 $jieqiUsers->setVar('experience', $jieqiUsers->getVar('experience') + $jieqiConfigs['system']['scorelogin']); $jieqiUsers->setVar('score', $jieqiUsers->getVar('score') + $jieqiConfigs['system']['scorelogin']); } //如果换月了,清空月积分 //if(date('Y-m', $previewlogin) != date('Y-m', JIEQI_NOW_TIME)) $jieqiUsers->setVar('monthscore', 0); $jieqiUsers->setVar('setting', serialize($userset)); $jieqiUsers->unsetNew(); $users_handler->insert($jieqiUsers); header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"'); //设置SESSION jieqi_setusersession($jieqiUsers); if ($newmsgnum > 0) { $_SESSION['jieqiNewMessage'] = $newmsgnum; } //后台登录状态 $jieqi_online_info = empty($_COOKIE['jieqiOnlineInfo']) ? array() : jieqi_strtosary($_COOKIE['jieqiOnlineInfo']); if (isset($jieqi_online_info['jieqiAdminLogin']) && $jieqi_online_info['jieqiAdminLogin'] == 1) { $_SESSION['jieqiAdminLogin'] = 1; } $jieqi_user_info['jieqiUserId'] = $_SESSION['jieqiUserId']; $jieqi_user_info['jieqiUserUname'] = $_SESSION['jieqiUserUname']; $jieqi_user_info['jieqiUserName'] = $_SESSION['jieqiUserName']; $jieqi_user_info['jieqiUserGroup'] = $_SESSION['jieqiUserGroup']; $jieqi_user_info['jieqiUserGroupName'] = $jieqiGroups[$_SESSION['jieqiUserGroup']]; $jieqi_user_info['jieqiUserVip'] = $_SESSION['jieqiUserVip']; $jieqi_user_info['jieqiUserHonorId'] = $_SESSION['jieqiUserHonorId']; $jieqi_user_info['jieqiUserHonor'] = $_SESSION['jieqiUserHonor']; if ($newmsgnum > 0) { $jieqi_user_info['jieqiNewMessage'] = $newmsgnum; } if ($usecookie) { $jieqi_user_info['jieqiUserPassword'] = $jieqiUsers->getVar('pass', 'n'); } include_once JIEQI_ROOT_PATH . '/include/changecode.php'; if (JIEQI_SYSTEM_CHARSET == 'gbk') { $jieqi_user_info['jieqiUserUname_un'] = jieqi_gb2unicode($_SESSION['jieqiUserUname']); $jieqi_user_info['jieqiUserName_un'] = jieqi_gb2unicode($_SESSION['jieqiUserName']); $jieqi_user_info['jieqiUserHonor_un'] = jieqi_gb2unicode($_SESSION['jieqiUserHonor']); $jieqi_user_info['jieqiUserGroupName_un'] = jieqi_gb2unicode($jieqiGroups[$_SESSION['jieqiUserGroup']]); } else { $jieqi_user_info['jieqiUserUname_un'] = jieqi_big52unicode($_SESSION['jieqiUserUname']); $jieqi_user_info['jieqiUserName_un'] = jieqi_big52unicode($_SESSION['jieqiUserName']); $jieqi_user_info['jieqiUserHonor_un'] = jieqi_big52unicode($_SESSION['jieqiUserHonor']); $jieqi_user_info['jieqiUserGroupName_un'] = jieqi_gb2unicode($jieqiGroups[$_SESSION['jieqiUserGroup']]); } $jieqi_user_info['jieqiUserLogin'] = JIEQI_NOW_TIME; if ($usecookie < 0) { $usecookie = 0; } elseif ($usecookie == 1) { $usecookie = 315360000; } if ($usecookie) { $cookietime = JIEQI_NOW_TIME + $usecookie; } else { $cookietime = 0; } @setcookie('jieqiUserInfo', jieqi_sarytostr($jieqi_user_info), $cookietime, '/', JIEQI_COOKIE_DOMAIN, 0); $jieqi_visit_info['jieqiUserLogin'] = $jieqi_user_info['jieqiUserLogin']; $jieqi_visit_info['jieqiUserId'] = $jieqi_user_info['jieqiUserId']; @setcookie('jieqiVisitInfo', jieqi_sarytostr($jieqi_visit_info), JIEQI_NOW_TIME + 99999999, '/', JIEQI_COOKIE_DOMAIN, 0); //更新在线用户 include_once JIEQI_ROOT_PATH . '/lib/template/template.php'; $jieqiTpl =& JieqiTpl::getInstance(); $jieqiTpl->clear_cache(JIEQI_ROOT_PATH . '/templates/online.html'); return 0; }
if (strlen($watertext) < 10) { $watertext = sprintf('%10s', $watertext); } $charsetary = array('gb2312' => 'gb', 'gbk' => 'gb', 'gb' => 'gb', 'big5' => 'big5', 'utf-8' => 'utf8', 'utf8' => 'utf8'); $fontcharset = JIEQI_SYSTEM_CHARSET; //段首空格问题 if (JIEQI_SYSTEM_CHARSET == 'gb2312' || JIEQI_SYSTEM_CHARSET == 'gbk') { $outstr = str_replace(' ', chr(161) . chr(161) . chr(161) . chr(161), $outstr); } elseif (JIEQI_SYSTEM_CHARSET == 'big5') { $outstr = str_replace(' ', chr(161) . chr(64) . chr(161) . chr(64), $outstr); } if (JIEQI_SYSTEM_CHARSET != JIEQI_CHAR_SET) { if ((JIEQI_SYSTEM_CHARSET == 'gb2312' || JIEQI_SYSTEM_CHARSET == 'gbk') && JIEQI_CHAR_SET == 'big5') { if (!empty($jieqiConfigs['obook']['obkcharconvert'])) { $outstr = jieqi_gb2big5($outstr); $watertext = jieqi_gb2big5($watertext); $fontcharset = JIEQI_CHAR_SET; } } elseif (JIEQI_SYSTEM_CHARSET == 'big5' && (JIEQI_CHAR_SET == 'gb2312' || JIEQI_CHAR_SET == 'gbk')) { if (!empty($jieqiConfigs['obook']['obkcharconvert'])) { $outstr = jieqi_big52gb($outstr); $watertext = jieqi_big52gb($watertext); $fontcharset = JIEQI_CHAR_SET; } } } $changefun = ''; if (isset($charsetary[$fontcharset])) { $changefun = 'jieqi_' . $charsetary[$fontcharset] . '2utf8'; } if (function_exists($changefun)) {
/** * 本地用户注册,正式处理 * * @param array $params 参数数组 * 必须参数: $params['username'] - 用户名,$params['password'] - 密码,$params['email'] - 邮箱 * @access public * @return int */ function jieqi_uregister_lprocess(&$params) { global $jieqiConfigs; global $jieqiLang; global $query; global $users_handler; //载入参数设置 if (!isset($jieqiConfigs['system'])) { jieqi_getconfigs('system', 'configs'); } //载入语言包 if (!isset($jieqiLang['system'])) { jieqi_loadlang('users', 'system'); } //初始化查询类 if (!is_a($query, 'JieqiQueryHandler')) { jieqi_includedb(); $query = JieqiQueryHandler::getInstance('JieqiQueryHandler'); } if (!is_a($users_handler, 'JieqiUsersHandler')) { include_once JIEQI_ROOT_PATH . '/class/users.php'; $users_handler =& JieqiUsersHandler::getInstance('JieqiUsersHandler'); } include_once JIEQI_ROOT_PATH . '/lib/text/textfunction.php'; $newUser = $users_handler->create(); $newUser->setVar('siteid', JIEQI_SITE_ID); $newUser->setVar('uname', $params['username']); $newUser->setVar('name', $params['nickname']); $newUser->setVar('pass', $users_handler->encryptPass($params['password'])); $newUser->setVar('groupid', JIEQI_GROUP_USER); $newUser->setVar('regdate', JIEQI_NOW_TIME); $newUser->setVar('initial', jieqi_getinitial($params['username'])); $newUser->setVar('sex', $params['sex']); $newUser->setVar('email', $params['email']); $newUser->setVar('url', $params['url']); $newUser->setVar('avatar', 0); $newUser->setVar('workid', 0); $newUser->setVar('qq', $params['qq']); $newUser->setVar('icq', ''); $newUser->setVar('msn', $params['msn']); $newUser->setVar('mobile', ''); $newUser->setVar('sign', ''); $newUser->setVar('intro', ''); $newUser->setVar('setting', ''); $newUser->setVar('badges', ''); $newUser->setVar('lastlogin', JIEQI_NOW_TIME); $newUser->setVar('showsign', 0); $newUser->setVar('viewemail', $params['viewemail']); $newUser->setVar('notifymode', 0); $newUser->setVar('adminemail', $params['adminemail']); $newUser->setVar('monthscore', 0); $newUser->setVar('experience', $jieqiConfigs['system']['scoreregister']); $newUser->setVar('score', $jieqiConfigs['system']['scoreregister']); $newUser->setVar('egold', 0); $newUser->setVar('esilver', 0); $newUser->setVar('credit', 0); $newUser->setVar('goodnum', 0); $newUser->setVar('badnum', 0); $newUser->setVar('isvip', 0); $newUser->setVar('overtime', 0); $newUser->setVar('state', 0); if (!$users_handler->insert($newUser)) { $params['uid'] = $newUser->getVar('uid', 'n'); $params['error'] = $jieqiLang['system']['register_failure']; if ($params['return']) { return false; } else { jieqi_printfail($params['error']); } } else { //自动登录 //记录注册时间IP if ($jieqiConfigs['system']['regtimelimit'] > 0) { $sql = "DELETE FROM " . jieqi_dbprefix('system_registerip') . " WHERE regtime<" . (JIEQI_NOW_TIME - ($jieqiConfigs['system']['regtimelimit'] > 72 ? $jieqiConfigs['system']['regtimelimit'] : 72) * 3600); $query->execute($sql); $sql = "INSERT INTO " . jieqi_dbprefix('system_registerip') . " (ip, regtime, count) VALUES ('" . jieqi_dbslashes($params['uip']) . "', '" . JIEQI_NOW_TIME . "', '0')"; $query->execute($sql); } //更新在线用户表 include_once JIEQI_ROOT_PATH . '/class/online.php'; $online_handler =& JieqiOnlineHandler::getInstance('JieqiOnlineHandler'); include_once JIEQI_ROOT_PATH . '/include/visitorinfo.php'; $online = $online_handler->create(); $online->setVar('uid', $newUser->getVar('uid', 'n')); $online->setVar('siteid', JIEQI_SITE_ID); $online->setVar('sid', session_id()); $online->setVar('uname', $newUser->getVar('uname', 'n')); $tmpvar = strlen($newUser->getVar('name', 'n')) > 0 ? $newUser->getVar('name', 'n') : $newUser->getVar('uname', 'n'); $online->setVar('name', $tmpvar); $online->setVar('pass', $newUser->getVar('pass', 'n')); $online->setVar('email', $newUser->getVar('email', 'n')); $online->setVar('groupid', $newUser->getVar('groupid', 'n')); $tmpvar = JIEQI_NOW_TIME; $online->setVar('logintime', $tmpvar); $online->setVar('updatetime', $tmpvar); $online->setVar('operate', ''); $tmpvar = VisitorInfo::getIp(); $online->setVar('ip', $tmpvar); $online->setVar('browser', VisitorInfo::getBrowser()); $online->setVar('os', VisitorInfo::getOS()); $location = VisitorInfo::getIpLocation($tmpvar); if (JIEQI_SYSTEM_CHARSET == 'big5') { include_once JIEQI_ROOT_PATH . '/include/changecode.php'; $location = jieqi_gb2big5($location); } $online->setVar('location', $location); $online->setVar('state', '0'); $online->setVar('flag', '0'); $online_handler->insert($online); //设置SESSION jieqi_setusersession($newUser); //设置COOKIE $jieqi_user_info = array(); $jieqi_user_info['jieqiUserId'] = $_SESSION['jieqiUserId']; $jieqi_user_info['jieqiUserName'] = $_SESSION['jieqiUserName']; $jieqi_user_info['jieqiUserGroup'] = $_SESSION['jieqiUserGroup']; include_once JIEQI_ROOT_PATH . '/include/changecode.php'; if (JIEQI_SYSTEM_CHARSET == 'gbk') { $jieqi_user_info['jieqiUserName_un'] = jieqi_gb2unicode($_SESSION['jieqiUserName']); } else { $jieqi_user_info['jieqiUserName_un'] = jieqi_big52unicode($_SESSION['jieqiUserName']); } $jieqi_user_info['jieqiUserLogin'] = JIEQI_NOW_TIME; $cookietime = 0; @setcookie('jieqiUserInfo', jieqi_sarytostr($jieqi_user_info), $cookietime, '/', JIEQI_COOKIE_DOMAIN, 0); $jieqi_visit_info['jieqiUserLogin'] = $jieqi_user_info['jieqiUserLogin']; $jieqi_visit_info['jieqiUserId'] = $jieqi_user_info['jieqiUserId']; @setcookie('jieqiVisitInfo', jieqi_sarytostr($jieqi_visit_info), JIEQI_NOW_TIME + 99999999, '/', JIEQI_COOKIE_DOMAIN, 0); //推广积分 if (JIEQI_PROMOTION_REGISTER > 0 && !empty($_COOKIE['jieqiPromotion'])) { $users_handler->changeCredit(intval($_COOKIE['jieqiPromotion']), intval(JIEQI_PROMOTION_REGISTER), true); setcookie('jieqiPromotion', '', 0, '/', JIEQI_COOKIE_DOMAIN, 0); } } //$params['jumpurl']=JIEQI_URL.'/'; if (empty($params['jumpurl'])) { $params['jumpurl'] = JIEQI_URL . '/'; } return true; }