/** * 检查本次点击时候有效的点击 * * @param int $id 点击对象ID * @param string $vname 点击标志变量名 * @param bool $save 是否记录本次点击(默认是) * @access public * @return bool */ function jieqi_visit_valid($id, $vname, $save = true) { if (!is_numeric($id) || intval($id) <= 0) { return false; } $sname = ''; if (isset($_SESSION[$vname])) { $arysession = unserialize($_SESSION[$vname]); } else { $arysession = array(); } if (!is_array($arysession)) { $arysession = array(); } $tmpary = array(); $arycookie = array(); if (isset($_COOKIE['jieqiVisitId'])) { $tmpary = jieqi_strtosary($_COOKIE['jieqiVisitId'], '=', ','); if (isset($tmpary[$vname])) { $arycookie = explode('|', $tmpary[$vname]); } } if (!is_array($arycookie)) { $arycookie = array(); } if (in_array($id, $arysession) || in_array($id, $arycookie)) { return false; } if ($save) { if (!in_array($id, $arysession) && isset($_SESSION)) { $arysession[] = $id; $_SESSION[$vname] = serialize($arysession); } if (!in_array($id, $arycookie)) { $arycookie[] = $id; $tmpary[$vname] = implode('|', $arycookie); setcookie('jieqiVisitId', jieqi_sarytostr($tmpary, '=', ','), JIEQI_NOW_TIME + 3600, '/', JIEQI_COOKIE_DOMAIN, 0); } } return true; }
} else { $jieqiTpl->assign('jieqi_vtype', ''); } include_once JIEQI_ROOT_PATH . '/class/modules.php'; $modules_handler =& JieqiModulesHandler::getInstance('JieqiModulesHandler'); $criteria = new CriteriaCompo(new Criteria('publish', 1, '=')); $criteria->setSort('weight'); $criteria->setOrder('ASC'); $modules_handler->queryObjects($criteria); unset($criteria); $jieqiModary = array(); while ($v = $modules_handler->getObject()) { $jieqiModary[$v->getVar('name', 'n')] = array('name' => $v->getVar('name', 'n'), 'caption' => $v->getVar('caption', 'n'), 'description' => $v->getVar('description', 'n'), 'version' => sprintf("%0.2f", intval($v->getVar('version', 'n')) / 100), 'vtype' => $v->getVar('vtype', 'n'), 'publish' => $v->getVar('publish', 'n')); } if (!isset($license_ary)) { $license_ary = jieqi_strtosary($jieqi_license_ary[2], '=', '|'); } $licenses = array(); $i = 0; foreach ($jieqiModary as $k => $v) { $licenses[$i]['modname'] = jieqi_htmlstr($jieqiModary[$k]['caption']); $licenses[$i]['modversion'] = jieqi_htmlstr($jieqiModary[$k]['version']); if (isset($license_ary[$k])) { $vtype = $license_ary[$k]; } else { $vtype = 'Free'; } if (defined('LANG_VERSION_' . strtoupper($vtype))) { $licenses[$i]['modvtype'] = constant('LANG_VERSION_' . strtoupper($vtype)); } else { $licenses[$i]['modvtype'] = '';
/** * 用户登录后处理 * * @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; }
} $k++; } $jieqiTpl->assign('messagerows', $messagerows); //处理页面跳转 include_once JIEQI_ROOT_PATH . '/lib/html/page.php'; $jumppage = new JieqiPage($message_handler->getCount($criteria), $jieqiConfigs['system']['messagepnum'], $_REQUEST['page']); $jieqiTpl->assign('url_jumppage', $jumppage->whole_bar()); $jieqiTpl->setCaching(0); $jieqiTset['jieqi_contents_template'] = JIEQI_ROOT_PATH . '/templates/inbox.html'; //处理短消息提示 if (isset($_SESSION['jieqiNewMessage']) && $_SESSION['jieqiNewMessage'] > 0) { $_SESSION['jieqiNewMessage'] = 0; $jieqi_user_info = array(); if (!empty($_COOKIE['jieqiUserInfo'])) { $jieqi_user_info = jieqi_strtosary($_COOKIE['jieqiUserInfo']); } else { $jieqi_user_info = array(); } if (isset($jieqi_user_info['jieqiNewMessage']) && $jieqi_user_info['jieqiNewMessage'] > 0) { $jieqi_user_info['jieqiNewMessage'] = 0; } if (!empty($jieqi_user_info['jieqiUserPassword'])) { $cookietime = JIEQI_NOW_TIME + 22118400; } else { $cookietime = 0; } @setcookie('jieqiUserInfo', jieqi_sarytostr($jieqi_user_info), $cookietime, '/', JIEQI_COOKIE_DOMAIN, 0); } default: break;
/** * 检查用户权限 * * @param array $powerset 需要的权限数组 * @param int $ustatus 用户状态 * @param int $ugroup 用户组 * @param bool $isreturn 是否返回检查结果,默认不返回,表示检查不通过直接提示 * @param bool $isadmin 是否检查后台权限,默认否 * @access public * @return bool */ function jieqi_checkpower($powerset = array(), $ustatus = '0', $ugroup = '0', $isreturn = false, $isadmin = false) { if (empty($_POST)) { $local_domain_url = empty($_SERVER['HTTP_HOST']) ? '' : 'http://' . $_SERVER['HTTP_HOST']; $jumpurl = $local_domain_url . jieqi_addurlvars(array()); } elseif (!empty($_SERVER['HTTP_REFERER'])) { $jumpurl = $_SERVER['HTTP_REFERER']; } else { $jumpurl = JIEQI_MAIN_URL; } if ((!isset($_SESSION['jieqiAdminLogin']) || $_SESSION['jieqiAdminLogin'] != 1) && !empty($_COOKIE['jieqiOnlineInfo'])) { $jieqi_online_info = jieqi_strtosary($_COOKIE['jieqiOnlineInfo']); if ($jieqi_online_info['jieqiAdminLogin'] == 1) { $_SESSION['jieqiAdminLogin'] = 1; } } if ($ustatus == JIEQI_GROUP_ADMIN) { if ($isadmin && empty($_SESSION['jieqiAdminLogin'])) { if ($isreturn) { return false; } else { header('Location: ' . JIEQI_LOCAL_URL . '/admin/login.php?jumpurl=' . urlencode($jumpurl)); exit; } } else { return true; } } else { if (is_array($powerset['groups']) && (in_array($ugroup, $powerset['groups'], false) || in_array('0', $powerset['groups'], false))) { if ($isadmin && empty($_SESSION['jieqiAdminLogin'])) { if ($isreturn) { return false; } else { header('Location: ' . JIEQI_LOCAL_URL . '/admin/login.php?jumpurl=' . urlencode($jumpurl)); exit; } } else { return true; } } else { if ($isreturn) { return false; } else { if ($ugroup == JIEQI_GROUP_GUEST) { if ($isadmin) { header('Location: ' . JIEQI_USER_URL . '/admin/login.php?jumpurl=' . urlencode($jumpurl)); } else { header('Location: ' . JIEQI_USER_URL . '/login.php?jumpurl=' . urlencode($jumpurl)); } exit; } else { jieqi_printfail(LANG_NO_PERMISSION); } } } } }
*/ define('JIEQI_MODULE_NAME', 'obook'); require_once '../../global.php'; jieqi_loadlang('search', JIEQI_MODULE_NAME); if (empty($_REQUEST['searchkey'])) { jieqi_printfail($jieqiLang['obook']['need_search_keywords']); } //包含配置参数 jieqi_getconfigs(JIEQI_MODULE_NAME, 'configs'); //关键字长度 if (!empty($jieqiConfigs['obook']['minsearchlen']) && strlen($_REQUEST['searchkey']) < intval($jieqiConfigs['obook']['minsearchlen'])) { jieqi_printfail(sprintf($jieqiLang['obook']['search_minsize_limit'], $jieqiConfigs['obook']['minsearchlen'])); } //检查时间,是否允许搜索 if (!empty($jieqiConfigs['obook']['minsearchtime']) && empty($_REQUEST['page'])) { $jieqi_visit_time = jieqi_strtosary($_COOKIE['jieqiVisitTime']); if (!empty($_SESSION['jieqiObooksearchTime'])) { $logtime = $_SESSION['jieqiObooksearchTime']; } elseif (!empty($jieqi_visit_time['jieqiObooksearchTime'])) { $logtime = $jieqi_visit_time['jieqiObooksearchTime']; } else { $logtime = 0; } if ($logtime > 0 && JIEQI_NOW_TIME - $logtime < intval($jieqiConfigs['obook']['minsearchtime'])) { jieqi_printfail(sprintf($jieqiLang['obook']['search_time_limit'], $jieqiConfigs['obook']['minsearchtime'])); } $_SESSION['jieqiObooksearchTime'] = JIEQI_NOW_TIME; $jieqi_visit_time['jieqiObooksearchTime'] = JIEQI_NOW_TIME; setcookie("jieqiVisitTime", jieqi_sarytostr($jieqi_visit_time), JIEQI_NOW_TIME + 3600, '/', JIEQI_COOKIE_DOMAIN, 0); } $obook_static_url = empty($jieqiConfigs['obook']['staticurl']) ? $jieqiModules['obook']['url'] : $jieqiConfigs['obook']['staticurl'];
/** * 检查发帖是否已过时间间隔 * * @param int $sec 间隔的秒数 * @param string $svar SESSION里面的记录变量名 * @param string $cvar COOKIE里面的记录变量名 * @access public * @return bool 超出时间间隔返回true,在限制时间内返回false */ function interval_time($sec, $svar, $cvar = 'jieqiVisitTime') { $sec = intval($sec); if (empty($sec)) { return true; } if (isset($_COOKIE[$cvar])) { $jieqi_vtime = jieqi_strtosary($_COOKIE[$cvar]); } else { $jieqi_vtime = array(); } if (!empty($_SESSION[$svar])) { $logtime = $_SESSION[$svar]; } elseif (!empty($jieqi_vtime[$svar])) { $logtime = $jieqi_vtime[$svar]; } else { $logtime = 0; } if ($logtime > 0 && JIEQI_NOW_TIME - $logtime < $sec) { $this->raiseError('interval_time', JIEQI_ERROR_RETURN); return false; } $_SESSION[$svar] = JIEQI_NOW_TIME; $jieqi_vtime[$svar] = JIEQI_NOW_TIME; setcookie($cvar, jieqi_sarytostr($jieqi_vtime), JIEQI_NOW_TIME + 3600, '/', JIEQI_COOKIE_DOMAIN, 0); return true; }
/** * 本地用户登录,正式处理 * * @param array $params 参数数组 * 必须参数: $params['username'] - 用户名,$params['password'] - 密码 * @access public * @return int */ function jieqi_ulogin_lprocess(&$params) { global $jieqiLang; //载入语言包 if (!isset($jieqiLang['system'])) { jieqi_loadlang('users', 'system'); } include_once JIEQI_ROOT_PATH . '/include/checklogin.php'; if (isset($params['usecookie']) && is_numeric($params['usecookie'])) { $params['usecookie'] = intval($params['usecookie']); } else { $params['usecookie'] = 0; } if (empty($params['checkcode'])) { $params['checkcode'] = ''; } $islogin = jieqi_logincheck($params['username'], $params['password'], $params['checkcode'], $params['usecookie']); if ($islogin == 0) { if (defined('JIEQI_ADMIN_LOGIN')) { $_SESSION['jieqiAdminLogin'] = 1; $jieqi_online_info = empty($_COOKIE['jieqiOnlineInfo']) ? array() : jieqi_strtosary($_COOKIE['jieqiOnlineInfo']); $jieqi_online_info['jieqiAdminLogin'] = 1; @setcookie('jieqiOnlineInfo', jieqi_sarytostr($jieqi_online_info), 0, '/', JIEQI_COOKIE_DOMAIN, 0); //记录登录日志 include_once JIEQI_ROOT_PATH . '/class/logs.php'; $logs_handler = JieqiLogsHandler::getInstance('JieqiLogsHandler'); $logdata = array('logtype' => 1); $logs_handler->addlog($logdata); } if (empty($params['jumpurl'])) { if (!empty($params['jumpreferer']) && !empty($_SERVER['HTTP_REFERER']) && basename($_SERVER['HTTP_REFERER']) != 'login.php') { $params['jumpurl'] = $_SERVER['HTTP_REFERER']; } else { $params['jumpurl'] = JIEQI_URL . '/'; } } } else { //返回 0 正常, -1 用户名为空 -2 密码为空 -3 用户名或者密码为空 //-4 用户名不存在 -5 密码错误 -6 用户名或密码错误 -7 校验码错误 -8 帐号已经有人登陆 switch ($islogin) { case -1: $params['error'] = $jieqiLang['system']['need_username']; break; case -2: $params['error'] = $jieqiLang['system']['need_password']; break; case -3: $params['error'] = $jieqiLang['system']['need_userpass']; break; case -4: $params['error'] = $jieqiLang['system']['no_this_user']; break; case -5: $params['error'] = $jieqiLang['system']['error_password']; break; case -6: $params['error'] = $jieqiLang['system']['error_userpass']; break; case -7: $params['error'] = $jieqiLang['system']['error_checkcode']; break; case -8: $params['error'] = $jieqiLang['system']['other_has_login']; break; case -9: $params['error'] = $jieqiLang['system']['user_has_denied']; break; default: $params['error'] = $jieqiLang['system']['login_failure']; break; } $params['errorno'] = $islogin; if ($params['return']) { return false; } else { jieqi_printfail($params['error']); } } return true; }