本文整理汇总了PHP中setNcCookie函数的典型用法代码示例。如果您正苦于以下问题:PHP setNcCookie函数的具体用法?PHP setNcCookie怎么用?PHP setNcCookie使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setNcCookie函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: logoutOp
public function logoutOp() {
$this->recordSellerLog('注销成功');
// 清除店铺消息数量缓存
setNcCookie('storemsgnewnum'.$_SESSION['seller_id'],0,-3600);
session_destroy();
redirect('index.php?act=seller_login');
}
示例2: loginoutOp
public function loginoutOp()
{
session_unset();
session_destroy();
setNcCookie('goodsnum', '', -3600);
showDialog(L('login_logout_success'), '', 'succ', '', 2);
}
示例3: logoutOp
/**
* 退出
*/
public function logoutOp()
{
session_unset();
session_destroy();
setNcCookie('sys_key', '', -1, '', null);
@header("Location: index.php");
exit;
}
示例4: select_cityOp
public function select_cityOp()
{
$city_id = intval($_GET['city_id']);
if ($city_id != 0 && (!isset($this->groupbuy_vr_cities['name'][$city_id]) || !isset($this->groupbuy_vr_cities['parent'][$city_id]) || $this->groupbuy_vr_cities['parent'][$city_id] != 0)) {
showMessage('该城市不存在,请选择其他城市');
}
setNcCookie('city_id', $city_id);
redirect(urlShop('show_groupbuy', $_GET['back_op']));
}
示例5: makeSeccode
/**
* 产生验证码
*
* @param string $nchash 哈希数
* @return string
*/
function makeSeccode($nchash)
{
$seccode = random(6, 1);
$seccodeunits = '';
$s = sprintf('%04s', base_convert($seccode, 10, 23));
$seccodeunits = 'ABCEFGHJKMPRTVXY2346789';
if ($seccodeunits) {
$seccode = '';
for ($i = 0; $i < 4; $i++) {
$unit = ord($s[$i]);
$seccode .= $unit >= 0x30 && $unit <= 0x39 ? $seccodeunits[$unit - 0x30] : $seccodeunits[$unit - 0x57];
}
}
setNcCookie('seccode' . $nchash, encrypt(strtoupper($seccode) . "\t" . time() . "\t" . $nchash, MD5_KEY), 31536000);
return $seccode;
}
示例6: checkStoreMsg
/**
* 商家消息数量
*/
private function checkStoreMsg()
{
//判断cookie是否存在
$cookie_name = 'storemsgnewnum' . $_SESSION['seller_id'];
if (cookie($cookie_name) != null && intval(cookie($cookie_name)) >= 0) {
$countnum = intval(cookie($cookie_name));
} else {
$where = array();
$where['store_id'] = $_SESSION['store_id'];
$where['sm_readids'] = array('notlike', '%,' . $_SESSION['seller_id'] . ',%');
if ($_SESSION['seller_smt_limits'] !== false) {
$where['smt_code'] = array('in', $_SESSION['seller_smt_limits']);
}
$countnum = Model('store_msg')->getStoreMsgCount($where);
setNcCookie($cookie_name, intval($countnum), 2 * 3600);
//保存2小时
}
Tpl::output('store_msg_num', $countnum);
}
示例7: addforwardOp
/**
* 添加转发
*/
public function addforwardOp(){
$obj_validate = new Validate();
$originalid = intval($_POST["originalid"]);
$validate_arr[] = array("input"=>$originalid, "require"=>"true",'validator'=>'Compare',"operator"=>' > ','to'=>0,"message"=>Language::get('sns_forward_fail'));
$validate_arr[] = array("input"=>$_POST["forwardcontent"], "validator"=>'Length',"min"=>0,"max"=>140,"message"=>Language::get('sns_content_beyond'));
//发帖数超过最大次数出现验证码
if(intval(cookie('forwardnum'))>=self::MAX_RECORDNUM){
$validate_arr[] = array("input"=>$_POST["captcha"], "require"=>"true","message"=>Language::get('wrong_null'));
}
$obj_validate -> validateparam = $validate_arr;
$error = $obj_validate->validate();
if ($error != ''){
showDialog($error,'','error');
}
//发帖数超过最大次数出现验证码
if(intval(cookie('forwardnum'))>=self::MAX_RECORDNUM){
if (!checkSeccode($_POST['nchash'],$_POST['captcha'])){
showDialog(Language::get('wrong_checkcode'),'','error');
}
}
//查询会员信息
$member_model = Model('member');
$member_info = $member_model->getMemberInfo(array('member_id'=>$_SESSION['member_id'],'member_state'=>1));
if (empty($member_info)){
showDialog(Language::get('sns_member_error'),'','error');
}
//查询原帖信息
$tracelog_model = Model('sns_tracelog');
$tracelog_info = $tracelog_model->getTracelogRow(array('trace_id'=>"{$originalid}",'trace_state'=>"0"));
if (empty($tracelog_info)){
showDialog(Language::get('sns_forward_fail'),'','error');
}
$insert_arr = array();
$insert_arr['trace_originalid'] = $tracelog_info['trace_originalid']>0?$tracelog_info['trace_originalid']:$originalid;//如果被转发的帖子为原帖的话,那么为原帖ID;如果被转发的帖子为转帖的话,那么为该转帖的原帖ID(即最初始帖子ID)
$insert_arr['trace_originalmemberid'] = $tracelog_info['trace_originalid']>0?$tracelog_info['trace_originalmemberid']:$tracelog_info['trace_memberid'];
$insert_arr['trace_memberid'] = $_SESSION['member_id'];
$insert_arr['trace_membername'] = $_SESSION['member_name'];
$insert_arr['trace_memberavatar'] = $member_info['member_avatar'];
$insert_arr['trace_title'] = $_POST['forwardcontent']?$_POST['forwardcontent']:Language::get('sns_forward');
if ($tracelog_info['trace_originalid'] > 0 || $tracelog_info['trace_from'] != 1){
$insert_arr['trace_content'] = addslashes($tracelog_info['trace_content']);
}else {
$content_str ="<div class=\"title\"><a href=\"%siteurl%index.php?act=member_snshome&mid={$tracelog_info['trace_memberid']}\" target=\"_blank\" class=\"uname\">{$tracelog_info['trace_membername']}</a>";
$content_str .= Language::get('nc_colon')."{$tracelog_info['trace_title']}</div>";
$content_str .=addslashes($tracelog_info['trace_content']);
$insert_arr['trace_content'] = $content_str;
}
$insert_arr['trace_addtime'] = time();
$insert_arr['trace_state'] = '0';
if ($tracelog_info['trace_privacy'] >0){
$insert_arr['trace_privacy'] = 2;//因为动态可见权限跟转帖功能,本身就是矛盾的,为了防止可见度无法控制,所以如果原帖不为所有人可见,那么转帖的动态权限就为仅自己可见,否则为所有人可见
}else {
$insert_arr['trace_privacy'] = 0;
}
$insert_arr['trace_commentcount'] = 0;
$insert_arr['trace_copycount'] = 0;
$insert_arr['trace_orgcommentcount'] = $tracelog_info['trace_orgcommentcount'];
$insert_arr['trace_orgcopycount'] = $tracelog_info['trace_orgcopycount'];
$result = $tracelog_model->tracelogAdd($insert_arr);
if ($result){
//更新动态转发次数
$tracelog_model = Model('sns_tracelog');
$update_arr = array();
$update_arr['trace_copycount'] = array('sign'=>'increase','value'=>'1');
$update_arr['trace_orgcopycount'] = array('sign'=>'increase','value'=>'1');
$condition = array();
//原始贴和被转帖都增加转帖次数
if ($tracelog_info['trace_originalid'] > 0){
$condition['traceid_in'] = "{$tracelog_info['trace_originalid']}','{$originalid}";
}else {
$condition['trace_id'] = "$originalid";
}
$tracelog_model->tracelogEdit($update_arr,$condition);
unset($condition);
//更新所有转帖的原帖转发次数
$condition = array();
//原始贴和被转帖都增加转帖次数
if ($tracelog_info['trace_originalid'] > 0){
$condition['trace_originalid'] = "{$tracelog_info['trace_originalid']}";
}else {
$condition['trace_originalid'] = "$originalid";
}
$tracelog_model->tracelogEdit(array('trace_orgcopycount'=>$tracelog_info['trace_orgcopycount']+1),$condition);
if ($_GET['irefresh']){
//建立cookie
if (cookie('forwardnum') != null && intval(cookie('forwardnum')) >0){
setNcCookie('forwardnum',intval(cookie('forwardnum'))+1,2*3600);//保存2小时
}else{
setNcCookie('forwardnum',1,2*3600);//保存2小时
}
if ($_GET['type']=='home'){
$js = "$('#friendtrace').lazyshow({url:\"index.php?act=member_snshome&op=tracelist&mid={$tracelog_info['trace_memberid']}&curpage=1\",'iIntervalId':true});";
}else if ($_GET['type']=='snshome'){
$js = "$('#forward_".$originalid."').hide();$('#friendtrace').lazyshow({url:\"index.php?act=member_snshome&op=tracelist&mid={$tracelog_info['trace_memberid']}&curpage=1\",'iIntervalId':true});";
}else {
$js = "$('#friendtrace').lazyshow({url:\"index.php?act=member_snsindex&op=tracelist&curpage=1\",'iIntervalId':true});";
}
//.........这里部分代码省略.........
示例8: delcompareOp
/**
* 清除对比栏
*/
public function delcompareOp()
{
if (trim($_GET['gid']) == 'all') {
$gid_arr = array();
} else {
$gids = cookie('comparegoods');
$gid_arr = $gids ? explode(',', $gids) : array();
$gid = intval($_GET['gid']);
if ($gid > 0 && $gid_arr) {
unset($gid_arr[array_search($gid, $gid_arr)]);
}
}
$gid_str = $gid_arr ? implode(',', $gid_arr) : '';
//更新cookie数据
if ($gid_str) {
setNcCookie('comparegoods', $gid_str);
} else {
setNcCookie('comparegoods', '', -3600);
}
exit(json_encode(array('done' => true, 'gid_str' => $gid_str)));
}
示例9: save_replyOp
/**
* 话题回复保存
*/
public function save_replyOp()
{
// Reply function does close,throw error.
if (!intval(C('circle_istalk'))) {
showDialog(L('circle_has_been_closed_reply'));
}
// checked cookie of SEC
if (cookie(circle_intervaltime)) {
showDialog(L('circle_operation_too_frequent'));
}
// 会员信息
$this->memberInfo();
// 不是圈子成员不能发帖
if (!in_array($this->identity, array(1, 2, 3))) {
showDialog(L('circle_no_join_ban_reply'));
}
// 话题信息
$this->themeInfo();
if (chksubmit()) {
/**
* 验证
*/
$obj_validate = new Validate();
$obj_validate->validateparam = array(array("input" => $_POST["replycontent"], "require" => "true", "message" => L('circle_reply_not_null')));
$error = $obj_validate->validate();
if ($error != '') {
showDialog($error);
} else {
$model = Model();
$insert = array();
$insert['theme_id'] = $this->t_id;
$insert['circle_id'] = $this->c_id;
$insert['member_id'] = $_SESSION['member_id'];
$insert['member_name'] = $_SESSION['member_name'];
$insert['reply_content'] = circleCenterCensor($_POST['replycontent']);
$insert['reply_addtime'] = time();
$insert['is_closed'] = 0;
// 回复楼层验证
if ($_POST['answer_id'] != '') {
$reply_info = Model()->table('circle_threply')->where(array('theme_id' => $this->t_id, 'reply_id' => intval($_POST['answer_id'])))->find();
if (!empty($reply_info)) {
$insert['reply_replyid'] = $reply_info['reply_id'];
$insert['reply_replyname'] = $reply_info['member_name'];
}
}
$reply_id = $model->table('circle_threply')->insert($insert);
if ($reply_id) {
if ($_GET['type'] == 'adv') {
// 插入话题商品
if (!empty($_POST['goods'])) {
$goods_insert = array();
foreach ($_POST['goods'] as $key => $val) {
$p = array();
$p['theme_id'] = $this->t_id;
$p['reply_id'] = $reply_id;
$p['circle_id'] = $this->c_id;
$p['goods_id'] = $val['id'];
$p['goods_name'] = $val['name'];
$p['goods_price'] = $val['price'];
$p['goods_image'] = $val['image'];
$p['store_id'] = $val['storeid'];
$p['thg_type'] = $val['type'];
$p['thg_url'] = $val['type'] == 1 ? $val['uri'] : '';
$goods_insert[] = $p;
}
$rs = $model->table('circle_thg')->insertAll($goods_insert);
}
// 更新话题附件
$model->table('circle_affix')->where(array('affix_type' => 2, 'member_id' => $_SESSION['member_id'], 'reply_id' => 0))->update(array('theme_id' => $this->t_id, 'reply_id' => $reply_id, 'circle_id' => $this->c_id));
}
// 话题被回复数增加 最后发言人发言时间
$update = array();
$update['theme_id'] = $this->t_id;
$update['theme_commentcount'] = array('exp', 'theme_commentcount+1');
$update['lastspeak_id'] = $_SESSION['member_id'];
$update['lastspeak_name'] = $_SESSION['member_name'];
$update['lastspeak_time'] = time();
$model->table('circle_theme')->update($update);
// 成员回复数增加 最后回复时间
$model->table('circle_member')->where(array('member_id' => $_SESSION['member_id'], 'circle_id' => $this->c_id))->update(array('cm_comcount' => array('exp', 'cm_comcount+1'), 'cm_lastspeaktime' => time()));
// set cookie of SEC
if (intval(C('circle_intervaltime')) > 0) {
setNcCookie('circle_intervaltime', true, intval(C('circle_intervaltime')));
}
if ($this->theme_info['member_id'] != $_SESSION['member_id']) {
// Experience for replyer
$param = array();
$param['member_id'] = $_SESSION['member_id'];
$param['member_name'] = $_SESSION['member_name'];
$param['circle_id'] = $this->c_id;
$param['theme_id'] = $this->t_id;
$param['type'] = 'reply';
$param['itemid'] = $this->t_id . ',' . $reply_id;
Model('circle_exp')->saveExp($param);
// Experience for releaser
$param = array();
$param['member_id'] = $this->theme_info['member_id'];
//.........这里部分代码省略.........
示例10: authOp
/**
* 统一身份验证入口
*/
public function authOp()
{
$model_member = Model('member');
if (chksubmit(false, true)) {
if (!in_array($_POST['type'], array('modify_pwd', 'modify_mobile', 'modify_email', 'modify_paypwd', 'pd_cash'))) {
redirect('index.php?act=member_security&op=index');
}
$member_common_info = $model_member->getMemberCommonInfo(array('member_id' => $_SESSION['member_id']));
if (empty($member_common_info) || !is_array($member_common_info)) {
showMessage('验证失败', '', 'html', 'error');
}
if ($member_common_info['auth_code'] != $_POST['auth_code'] || TIMESTAMP - $member_common_info['send_acode_time'] > 1800) {
showMessage('验证码已被使用或超时,请重新获取验证码', '', 'html', 'error');
}
$data = array();
$data['auth_code'] = '';
$data['send_acode_time'] = 0;
$update = $model_member->editMemberCommon($data, array('member_id' => $_SESSION['member_id']));
if (!$update) {
showMessage('系统发生错误,如有疑问请与管理员联系', SHOP_SITE_URL, 'html', 'error');
}
setNcCookie('seccode' . $_POST['nchash'], '', -3600);
$_SESSION['auth_' . $_POST['type']] = TIMESTAMP;
self::profile_menu($_POST['type'], $_POST['type']);
if ($_POST['type'] == 'pd_cash') {
Tpl::showpage('member_pd_cash.add');
} else {
Tpl::showpage('member_security.' . $_POST['type']);
}
} else {
if (!in_array($_GET['type'], array('modify_pwd', 'modify_mobile', 'modify_email', 'modify_paypwd', 'pd_cash'))) {
redirect('index.php?act=member_security&op=index');
}
//继承父类的member_info
$member_info = $this->member_info;
if (!$member_info) {
$member_info = $model_member->getMemberInfo(array('member_id' => $_SESSION['member_id']), 'member_email,member_email_bind,member_mobile,member_mobile_bind');
}
self::profile_menu($_GET['type'], $_GET['type']);
//第一次绑定邮箱,不用发验证码,直接进下一步
//第一次绑定手机,不用发验证码,直接进下一步
if ($_GET['type'] == 'modify_email' && $member_info['member_email_bind'] == '0' || $_GET['type'] == 'modify_mobile' && $member_info['member_mobile_bind'] == '0') {
$_SESSION['auth_' . $_GET['type']] = TIMESTAMP;
Tpl::showpage('member_security.' . $_GET['type']);
exit;
}
//修改密码、设置支付密码时,必须绑定邮箱或手机
if (in_array($_GET['type'], array('modify_pwd', 'modify_paypwd')) && $member_info['member_email_bind'] == '0' && $member_info['member_mobile_bind'] == '0') {
showMessage('请先绑定邮箱或手机', 'index.php?act=member_security&op=index', 'html', 'error');
}
Tpl::output('member_info', $member_info);
Tpl::showpage('member_security.auth');
}
}
示例11: delOp
/**
* 购物车删除单个商品,未登录前使用cart_id即为goods_id
*/
public function delOp()
{
$cart_id = intval($_GET['cart_id']);
if ($cart_id < 0) {
return;
}
$model_cart = Model('cart');
$data = array();
if ($_SESSION['member_id']) {
//登录状态下删除数据库内容
$delete = $model_cart->delCart('db', array('cart_id' => $cart_id, 'buyer_id' => $_SESSION['member_id']));
if ($delete) {
$data['state'] = 'true';
$data['quantity'] = $model_cart->cart_goods_num;
$data['amount'] = $model_cart->cart_all_price;
} else {
$data['msg'] = Language::get('cart_drop_del_fail', 'UTF-8');
}
} else {
//未登录时删除cookie的购物车信息
$delete = $model_cart->delCart('cookie', array('goods_id' => $cart_id));
if ($delete) {
$data['state'] = 'true';
$data['quantity'] = $model_cart->cart_goods_num;
$data['amount'] = $model_cart->cart_all_price;
}
}
setNcCookie('cart_goods_num', $model_cart->cart_goods_num, 2 * 3600);
$json_data = json_encode($data);
if (isset($_GET['callback'])) {
$json_data = $_GET['callback'] == '?' ? '(' . $json_data . ')' : $_GET['callback'] . "({$json_data});";
}
exit($json_data);
}
示例12: del_msgOp
/**
* AJAX删除消息
*/
public function del_msgOp()
{
// 验证参数
$smids = $_GET['smids'];
if (!preg_match('/^[\\d,]+$/i', $smids)) {
showDialog(L('para_error'), '', 'error');
}
$smid_array = explode(',', $smids);
// 验证是否为管理员
if (!$this->checkIsAdmin()) {
showDialog(L('para_error'), '', 'error');
}
$where = array();
$where['store_id'] = $_SESSION['store_id'];
$where['sm_id'] = array('in', $smid_array);
// 删除消息记录
Model('store_msg')->delStoreMsg($where);
// 删除阅读记录
unset($where['store_id']);
Model('store_msg_read')->delStoreMsgRead($where);
// 清除店铺消息数量缓存
setNcCookie('storemsgnewnum' . $_SESSION['seller_id'], 0, -3600);
showDialog(L('nc_common_op_succ'), 'reload', 'succ');
}
示例13: getCartNum
/**
* 计算购物车总商品数和总金额
* @param string $type 购物车信息保存类型 db,cookie,cache
* @param array $condition 只有登录后操作购物车表时才会用到该参数
*/
public function getCartNum($type, $condition = array())
{
if ($type == 'db') {
$cart_all_price = 0;
$cart_goods = $this->listCart('db', $condition);
$this->cart_goods_num = count($cart_goods);
if (!empty($cart_goods) && is_array($cart_goods)) {
foreach ($cart_goods as $val) {
$cart_all_price += $val['goods_price'] * $val['goods_num'];
}
}
$this->cart_all_price = ncPriceFormat($cart_all_price);
} elseif ($type == 'cache') {
$obj_cache = Cache::getInstance(C('cache.type'));
$cart_array = $obj_cache->get($_COOKIE['PHPSESSID'], 'cart_');
$cart_array = @unserialize($cart_array);
$cart_array = !is_array($cart_array) ? array() : $cart_array;
$this->cart_goods_num = count($cart_array);
$cart_all_price = 0;
if (!empty($cart_array)) {
foreach ($cart_array as $v) {
$cart_all_price += floatval($v['goods_price']) * intval($v['goods_num']);
}
}
$this->cart_all_price = $cart_all_price;
} elseif ($type == 'cookie') {
$cart_str = get_magic_quotes_gpc() ? stripslashes(cookie('cart')) : cookie('cart');
$cart_str = base64_decode(decrypt($cart_str));
$cart_array = @unserialize($cart_str);
$cart_array = !is_array($cart_array) ? array() : $cart_array;
$this->cart_goods_num = count($cart_array);
$cart_all_price = 0;
foreach ($cart_array as $v) {
$cart_all_price += floatval($v['goods_price']) * intval($v['goods_num']);
}
$this->cart_all_price = $cart_all_price;
}
setNcCookie('cart_goods_num', $this->cart_goods_num, 2 * 3600);
return $this->cart_goods_num;
}
示例14: indexOp
/**
* 首页 话题列表
*/
public function indexOp(){
// 圈子信息
$this->circleInfo();
// 圈主和管理信息
$this->manageList();
// 会员信息
$this->memberInfo();
// sidebar相关
$this->sidebar();
$model = Model();
// 话题列表
$where = array();
$where['circle_id'] = $this->c_id;
$thc_id = intval($_GET['thc_id']);
if($thc_id > 0){
$where['thclass_id']= $thc_id;
Tpl::output('thc_id', $thc_id);
}
if(intval($_GET['cream']) == 1){
$where['is_digest'] = 1;
}
$theme_list = $model->table('circle_theme')->where($where)->order('is_stick desc,lastspeak_time desc')->page(20)->select();
$theme_list = array_under_reset($theme_list, 'theme_id');
Tpl::output('show_page', $model->showpage('2'));
Tpl::output('theme_list', $theme_list);
// 附件列表
if(!empty($theme_list)){
$themeid_array = array_keys($theme_list);
$affix_list = $model->table('circle_affix')->where(array('affix_type'=>1,'theme_id'=>array('in', $themeid_array)))->select();
$affix_list = array_under_reset($affix_list, 'theme_id', 2);
Tpl::output('affix_list', $affix_list);
}
// 今日话题数
// 当天时间戳
$year = date("Y");$month = date("m");$day = date("d");
$dayBegin = mktime(0,0,0,$month,$day,$year);
$todaythcount = $model->table('circle_theme')->where(array('theme_addtime'=>array('egt',$dayBegin), 'circle_id'=>$this->c_id))->count();
Tpl::output('todaythcount', $todaythcount);
//展示形式,默认以图文展示 list/preview
if($_GET['type'] != ''){
$display_mode = ($_GET['type'] == 'list')?'list':'preview';
setNcCookie('circleDisplayMode', $display_mode, 30*24*60*60);
}else{
$display_mode = cookie('circleDisplayMode') ? cookie('circleDisplayMode') : 'preview';
}
Tpl::output('display_mode',$display_mode);
// 话题分类
$where = array();
$where['circle_id'] = $this->c_id;
$where['thclass_status']= 1;
$thclass_list = $model->table('circle_thclass')->where($where)->order('thclass_sort asc')->select();
$thclass_list = array_under_reset($thclass_list, 'thclass_id');
Tpl::output('thclass_list', $thclass_list);
// Read Permission
$readperm = $this->readPermissions($this->cm_info);
Tpl::output('readperm', $readperm);
Tpl::output('m_readperm', $this->m_readperm);
$this->circleSEO($this->circle_info['circle_name']);
// breadcrumb navigation
$this->breadcrumd();
Tpl::showpage('group');
}
示例15: select_cityOp
public function select_cityOp()
{
$city_id = intval($_GET['city_id']);
$model_live_area = Model('live_area');
$city = $model_live_area->live_areaInfo(array('live_area_id' => $city_id));
if (empty($city) && $city_id != 0) {
showMessage('该城市不存在,请选择其他城市');
}
setNcCookie('city_id', $city_id);
redirect("index.php?act=show_live_groupbuy");
}