本文整理汇总了PHP中Security::checkToken方法的典型用法代码示例。如果您正苦于以下问题:PHP Security::checkToken方法的具体用法?PHP Security::checkToken怎么用?PHP Security::checkToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Security
的用法示例。
在下文中一共展示了Security::checkToken方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: RegisterOp
public function RegisterOp()
{
if (!Security::checkToken()) {
showMessage('登录错误', '', '', 'error');
}
if (!checkSeccode($_POST['nchash'], $_POST['captcha'])) {
showMessage('验证码错误', '', '', 'error');
}
$model_seller = Model('seller');
$seller_info = $model_seller->getSellerInfo(array('seller_name' => $_POST['seller_name']));
if ($seller_info) {
$model_member = Model('member');
$member_info = $model_member->infoMember(array('member_id' => $seller_info['member_id'], 'member_passwd' => md5($_POST['password'])));
if ($member_info) {
// 更新卖家登陆时间
$model_seller->editSeller(array('last_login_time' => TIMESTAMP), array('seller_id' => $seller_info['seller_id']));
$model_seller_group = Model('seller_group');
$seller_group_info = $model_seller_group->getSellerGroupInfo(array('group_id' => $seller_info['seller_group_id']));
$model_store = Model('store');
$store_info = $model_store->getStoreInfoByID($seller_info['store_id']);
$_SESSION['is_login'] = '1';
$_SESSION['member_id'] = $member_info['member_id'];
$_SESSION['member_name'] = $member_info['member_name'];
$_SESSION['member_email'] = $member_info['member_email'];
$_SESSION['is_buy'] = $member_info['is_buy'];
$_SESSION['avatar'] = $member_info['member_avatar'];
$_SESSION['grade_id'] = $store_info['grade_id'];
$_SESSION['seller_id'] = $seller_info['seller_id'];
$_SESSION['seller_name'] = $seller_info['seller_name'];
$_SESSION['seller_is_admin'] = intval($seller_info['is_admin']);
$_SESSION['store_id'] = intval($seller_info['store_id']);
$_SESSION['store_name'] = $store_info['store_name'];
$_SESSION['seller_limits'] = explode(',', $seller_group_info['limits']);
if ($seller_info['is_admin']) {
$_SESSION['seller_group_name'] = '管理员';
} else {
$_SESSION['seller_group_name'] = $seller_group_info['group_name'];
}
if (!$seller_info['last_login_time']) {
$seller_info['last_login_time'] = TIMESTAMP;
}
$_SESSION['seller_last_login_time'] = date('Y-m-d H:i', $seller_info['last_login_time']);
$seller_menu = $this->getSellerMenuList($seller_info['is_admin'], explode(',', $seller_group_info['limits']));
$_SESSION['seller_menu'] = $seller_menu['seller_menu'];
$_SESSION['seller_function_list'] = $seller_menu['seller_function_list'];
if (!empty($seller_info['seller_quicklink'])) {
$quicklink_array = explode(',', $seller_info['seller_quicklink']);
foreach ($quicklink_array as $value) {
$_SESSION['seller_quicklink'][$value] = $value;
}
}
$this->recordSellerLog('登录成功');
showMessage('登录成功', 'index.php?act=seller_center');
} else {
showMessage('用户名密码错误', '', '', 'error');
}
} else {
showMessage('用户名密码错误', '', '', 'error');
}
}
示例2: chksubmit
/**
* 检测FORM是否提交
* @param $check_token 是否验证token
* @param $check_captcha 是否验证验证码
* @param $return_type 'alert','num'
* @return boolean
*/
function chksubmit($check_token = false, $check_captcha = false, $return_type = 'alert')
{
$submit = isset($_POST['form_submit']) ? $_POST['form_submit'] : $_GET['form_submit'];
if ($submit != 'ok') {
return false;
}
if ($check_token && !Security::checkToken()) {
if ($return_type == 'alert') {
showDialog('Token error!');
} else {
return -11;
}
}
if ($check_captcha) {
if (!checkSeccode($_POST['nchash'], $_POST['captcha'])) {
setNcCookie('seccode' . $_POST['nchash'], '', -3600);
if ($return_type == 'alert') {
showDialog('验证码错误!');
} else {
return -12;
}
}
setNcCookie('seccode' . $_POST['nchash'], '', -3600);
}
return true;
}
示例3: chksubmit
/**
* 检测FORM是否提交
* @param $check_token 是否验证token
* @param $check_captcha 是否验证验证码
* @param $return_type 'alert','num'
* @return boolean
*/
function chksubmit($check_token = false, $check_captcha = false, $return_type = 'alert')
{
$submit = isset($_POST['form_submit']) ? $_POST['form_submit'] : $_GET['form_submit'];
if ($submit != 'ok') {
return false;
}
if ($check_token && !Security::checkToken()) {
if ($return_type == 'alert') {
showDialog('Token error!');
} else {
return -11;
}
}
if ($check_captcha) {
if (!function_exists('checkSeccode')) {
import('function.seccode');
}
if (!checkSeccode($_POST['nchash'], $_POST['captcha'])) {
if ($return_type == 'alert') {
showDialog('Verification code error!');
} else {
return -12;
}
}
}
return true;
}
示例4: indexOp
/**
* 登录操作
*
* @param
* @return
*/
public function indexOp()
{
Language::read("home_login_index");
$lang = Language::getLangContent();
/**
* 实例化模型
*/
$model_member = Model('member');
/**
* 检查登录状态
*/
$model_member->checkloginMember();
if (chksubmit()) {
if (cookie('tm_login') == 5) {
showDialog($lang['nc_common_op_repeat'], SiteUrl);
}
Security::checkToken();
$obj_validate = new Validate();
$obj_validate->validateparam = array(array("input" => $_POST["user_name"], "require" => "true", "message" => $lang['login_index_username_isnull']), array("input" => $_POST["password"], "require" => "true", "message" => $lang['login_index_password_isnull']), array("input" => $_POST["captcha"], "require" => C('captcha_status_login') ? "true" : "false", "message" => $lang['login_index_input_checkcode']));
$error = $obj_validate->validate();
if ($error != '') {
showValidateError($error);
} else {
if (C('captcha_status_login')) {
if (!checkSeccode($_POST['nchash'], $_POST['captcha'])) {
showDialog($lang['login_index_wrong_checkcode']);
}
}
if (C('ucenter_status')) {
$model_ucenter = Model('ucenter');
$member_id = $model_ucenter->userLogin(trim($_POST['user_name']), trim($_POST['password']));
if (intval($member_id) == 0) {
if (cookie('tm_login') >= 6) {
showDialog($lang['nc_common_op_repeat']);
}
log_times('login');
showDialog($lang['login_index_login_again']);
}
}
$array = array();
$array['member_name'] = trim($_POST['user_name']);
$array['member_passwd'] = md5(trim($_POST['password']));
$member_info = $model_member->infoMember($array);
if (is_array($member_info) and !empty($member_info)) {
setNcCookie('tm_login', '', -3600);
if (!$member_info['member_state']) {
showDialog($lang['nc_notallowed_login']);
}
/**
* 登录时间更新
*/
$update_info = array('member_login_num' => $member_info['member_login_num'] + 1, 'member_login_time' => time(), 'member_old_login_time' => $member_info['member_login_time'], 'member_login_ip' => getIp(), 'member_old_login_ip' => $member_info['member_login_ip']);
$model_member->updateMember($update_info, $member_info['member_id']);
/**
* 写入session
*/
$_SESSION['is_login'] = '1';
$_SESSION['is_seller'] = intval($member_info['store_id']) == 0 ? '' : 1;
$_SESSION['member_id'] = $member_info['member_id'];
$_SESSION['member_name'] = $member_info['member_name'];
$_SESSION['member_email'] = $member_info['member_email'];
if ($GLOBALS['setting_config']['qq_isuse'] == 1 && trim($member_info['member_qqopenid'])) {
$_SESSION['openid'] = $member_info['member_qqopenid'];
}
if ($GLOBALS['setting_config']['sina_isuse'] == 1 && trim($member_info['member_sinaopenid'])) {
$_SESSION['slast_key']['uid'] = $member_info['member_sinaopenid'];
}
//查询店铺信息
if ($member_info['store_id'] > 0) {
$store_model = Model('store');
$store_info = $store_model->shopStore(array('store_id' => $member_info['store_id']));
if (is_array($store_info) && count($store_info) > 0) {
$_SESSION['store_id'] = $store_info['store_id'];
$_SESSION['store_name'] = $store_info['store_name'];
$_SESSION['grade_id'] = $store_info['grade_id'];
}
}
// cookie中的cart存入数据库
$this->mergecart();
//添加会员积分
if (C('points_isuse')) {
//一天内只有第一次登录赠送积分
if (trim(@date('Y-m-d', $member_info['member_login_time'])) != trim(date('Y-m-d'))) {
$points_model = Model('points');
$points_model->savePointsLog('login', array('pl_memberid' => $member_info['member_id'], 'pl_membername' => $member_info['member_name']), true);
}
}
$evaluate_model = Model('evaluate');
$evaluate_model->updateMemberStat($_SESSION['member_id'], $_SESSION['store_id']);
//统计更新:会员信用,卖家信用,店铺评分
$_POST['ref_url'] = strstr($_POST['ref_url'], 'logout') === false && !empty($_POST['ref_url']) ? $_POST['ref_url'] : 'index.php?act=member_snsindex';
if (C('ucenter_status')) {
$extrajs = $model_ucenter->outputLogin($member_info['member_id'], trim($_POST['password']));
} elseif (empty($_GET['inajax'])) {
//.........这里部分代码省略.........
示例5: __construct
/**
* 不进行父类的登录验证,所以增加构造方法重写了父类的构造方法
*/
public function __construct()
{
Language::read('common,layout,login');
$lang = Language::getLangContent();
if (chksubmit()) {
/**
* 检查提交
*/
Security::checkToken();
/**
* 登录验证
*/
$obj_validate = new Validate();
$obj_validate->validateparam = array(array("input" => $_POST["user_name"], "require" => "true", "message" => $lang['login_index_username_null']), array("input" => $_POST["password"], "require" => "true", "message" => $lang['login_index_password_null']), array("input" => $_POST["captcha"], "require" => "true", "message" => $lang['login_index_checkcode_null']));
$error = $obj_validate->validate();
if ($error != '') {
showMessage($lang['error'] . $error);
} else {
if (!checkSeccode($_POST['nchash'], $_POST['captcha'])) {
showMessage($lang['login_index_checkcode_wrong'] . $error);
}
/**
* 验证登录
* 目前为 都可以登录
*/
$model_admin = Model('admin');
$array = array();
$array['admin_name'] = trim($_POST['user_name']);
$array['admin_password'] = md5(trim($_POST['password']));
$admin_info = $model_admin->infoAdmin($array);
if (is_array($admin_info) and !empty($admin_info)) {
$login_array = array();
$login_array['name'] = $admin_info['admin_name'];
$login_array['id'] = $admin_info['admin_id'];
/**
* 判断是否有登录权限
* 暂时对admin_info进行赋值用来做权限验证
*/
$this->setAdminInfo($login_array);
$this->checkPermission('login');
/**
* 加密 写入cookie
*/
$authkey = md5(C('setup_date') . MD5_KEY);
setNcCookie('sys_key', encrypt(serialize($login_array), $authkey));
/**
* 登录时间更新
*/
$update_info = array('admin_id' => $admin_info['admin_id'], 'admin_login_num' => $admin_info['admin_login_num'] + 1, 'admin_login_time' => time());
$model_admin->updateAdmin($update_info);
@header('Location: index.php');
exit;
} else {
showMessage($lang['login_index_username_password_wrong'], 'index.php?act=login&op=login');
}
}
}
Tpl::output('nchash', substr(md5(SiteUrl . $_GET['act'] . $_GET['op']), 0, 8));
Tpl::output('html_title', $lang['login_index_need_login']);
Tpl::showpage('login', 'login_layout');
}