Пример #1
0
 /**
  * add chat msg
  *
  * @param
  * @return array
  */
 public function addMsg($msg)
 {
     $msg['f_ip'] = uk86_getIp();
     $msg['r_state'] = '2';
     //state:1--read ,2--unread
     $msg['add_time'] = time();
     $m_id = $this->table('chat_msg')->insert($msg);
     if ($m_id > 0) {
         $msg['m_id'] = $m_id;
         unset($msg['r_state']);
         $this->table('chat_log')->insert($msg);
         $msg['m_id'] = $m_id;
         $msg['add_time'] = date('Y-m-d H:i:s', $msg['add_time']);
         $t_msg = $msg['t_msg'];
         $goods_id = 0;
         $goods_info = array();
         $pattern = '#' . SHOP_SITE_URL . '/index.php\\?act=goods&op=index&goods_id=(\\d+)$#';
         preg_match($pattern, $t_msg, $matches);
         if (intval($matches[1]) < 1) {
             //伪静态
             $pattern = '#' . SHOP_SITE_URL . '/item-(\\d+)\\.html$#';
             preg_match($pattern, $t_msg, $matches);
         }
         $goods_id = intval($matches[1]);
         if ($goods_id >= 1) {
             $goods_info = $this->getGoodsInfo($goods_id);
             $goods_id = intval($goods_info['goods_id']);
         }
         $msg['goods_id'] = $goods_id;
         $msg['goods_info'] = $goods_info;
         return $msg;
     } else {
         return 0;
     }
 }
Пример #2
0
 /**
  * 初始化,未启用内存保存时默认使用lock表存储
  *
  * @param unknown_type $type
  */
 private static function init($type)
 {
     if (C('cache.type') != 'file') {
         self::$lock = Uk86Cache::uk86_getInstance(C('cache.type'));
     } else {
         self::$lock = new lock();
     }
     if (!isset(self::$processid[$type])) {
         $ip = sprintf('%u', ip2long(uk86_getIp()));
         self::$processid[$type] = str_pad($ip, 10, '0') . self::parsekey($type);
         self::$lockid[$type] = str_pad($ip, 11, '0') . self::parsekey($type);
     }
 }
Пример #3
0
 /**
  * 初始化,未启用内存保存时默认使用lock表存储
  *
  * @param unknown_type $type
  */
 private static function uk86_init($type)
 {
     if (C('cache_open')) {
         self::$lock = Cache::getInstance('cacheredis');
     } else {
         self::$lock = new Uk86lock();
     }
     if (!isset(self::$processid[$type])) {
         $ip = sprintf('%u', ip2long(uk86_getIp()));
         self::$processid[$type] = str_pad($ip, 10, '0') . self::uk86_parsekey($type);
         self::$lockid[$type] = str_pad($ip, 11, '0') . self::uk86_parsekey($type);
     }
 }
Пример #4
0
 /**
  * 注册操作
  */
 public function register_actionOp()
 {
     $insert_array = array();
     $insert_array['member_name'] = $_POST['member_name'];
     $insert_array['member_passwd'] = md5($_POST['password']);
     $insert_array['member_email'] = $_POST['email'];
     $insert_array['member_email_bind'] = 1;
     $insert_array['member_time'] = time();
     $insert_array['member_login_time'] = $insert_array['member_time'];
     $insert_array['member_points'] = 20;
     $insert_array['member_login_ip'] = uk86_getIp();
     $result = Model('member')->insert($insert_array);
     if (!empty($result)) {
         $_SESSION['is_login'] = 1;
         $_SESSION['member_id'] = intval($result);
         $_SESSION['member_name'] = $insert_array['member_name'];
         $_SESSION['member_email'] = $insert_array['member_email'];
         $_SESSION['is_buy'] = 1;
         //添加积分记录
         $pl_array = array();
         $pl_array['pl_memberid'] = intval($result);
         $pl_array['pl_membername'] = $insert_array['member_name'];
         $pl_array['pl_points'] = 20;
         $pl_array['pl_addtime'] = $insert_array['member_time'];
         $pl_array['pl_desc'] = '会员注册';
         $pl_array['pl_stage'] = 'regist';
         Model('points_log')->insert($pl_array);
         //添加经验值
         $exp_array = array();
         $exp_array['exp_memberid'] = intval($result);
         $exp_array['exp_membername'] = $insert_array['member_name'];
         $exp_array['exp_points'] = 5;
         $exp_array['exp_addtime'] = $insert_array['member_time'];
         $exp_array['exp_desc'] = '会员登录';
         $exp_array['exp_stage'] = 'login';
         Model('exppoints_log')->insert($exp_array);
         echo 11;
     } else {
         echo 10;
     }
 }
Пример #5
0
 /**
  * 记录系统日志
  *
  * @param $lang 日志语言包
  * @param $state 1成功0失败null不出现成功失败提示
  * @param $admin_name
  * @param $admin_id
  */
 protected final function log($lang = '', $state = 1, $admin_name = '', $admin_id = 0)
 {
     if (!C('sys_log') || !is_string($lang)) {
         return;
     }
     if ($admin_name == '') {
         $admin = unserialize(uk86_decrypt(uk86_cookie('sys_key'), MD5_KEY));
         $admin_name = $admin['name'];
         $admin_id = $admin['id'];
     }
     $data = array();
     if (is_null($state)) {
         $state = null;
     } else {
         //			$state = $state ? L('nc_succ') : L('nc_fail');
         $state = $state ? '' : L('nc_fail');
     }
     $data['content'] = $lang . $state;
     $data['admin_name'] = $admin_name;
     $data['createtime'] = TIMESTAMP;
     $data['admin_id'] = $admin_id;
     $data['ip'] = uk86_getIp();
     $data['url'] = $_REQUEST['act'] . '&' . $_REQUEST['op'];
     return Model('admin_log')->insert($data);
 }
Пример #6
0
 /**
  * 添加评论(访客登录后操作)
  */
 public function addcommentOp()
 {
     $originalid = intval($_POST["originalid"]);
     if ($originalid <= 0) {
         showDialog(Uk86Language::uk86_get('wrong_argument'), '', 'error');
     }
     $obj_validate = new Uk86Validate();
     $originaltype = intval($_POST['originaltype']) > 0 ? intval($_POST['originaltype']) : 0;
     $validate_arr[] = array("input" => $_POST["commentcontent"], "require" => "true", "message" => Uk86Language::uk86_get('sns_comment_null'));
     $validate_arr[] = array("input" => $_POST["commentcontent"], "validator" => 'Length', "min" => 0, "max" => 140, "message" => Uk86Language::uk86_get('sns_content_beyond'));
     //评论数超过最大次数出现验证码
     if (intval(uk86_cookie('commentnum')) >= self::MAX_RECORDNUM) {
         $validate_arr[] = array("input" => $_POST["captcha"], "require" => "true", "message" => Uk86Language::uk86_get('wrong_null'));
     }
     $obj_validate->validateparam = $validate_arr;
     $error = $obj_validate->uk86_validate();
     if ($error != '') {
         showDialog($error, '', 'error');
     }
     //发帖数超过最大次数出现验证码
     if (intval(uk86_cookie('commentnum')) >= self::MAX_RECORDNUM) {
         if (!uk86_checkSeccode($_POST['nchash'], $_POST['captcha'])) {
             showDialog(Uk86Language::uk86_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(Uk86Language::uk86_get('sns_member_error'), '', 'error');
     }
     $owner_id = 0;
     if ($originaltype == 1) {
         //查询分享和喜欢商品信息
         $sharegoods_model = Model('sns_sharegoods');
         $sharegoods_info = $sharegoods_model->getSharegoodsInfo(array('share_id' => "{$originalid}"));
         if (empty($sharegoods_info)) {
             showDialog(Uk86Language::uk86_get('sns_comment_fail'), '', 'error');
         }
         $owner_id = $sharegoods_info['share_memberid'];
     } else {
         //查询原帖信息
         $tracelog_model = Model('sns_tracelog');
         $tracelog_info = $tracelog_model->getTracelogRow(array('trace_id' => "{$originalid}", 'trace_state' => '0'));
         if (empty($tracelog_info)) {
             showDialog(Uk86Language::uk86_get('sns_comment_fail'), '', 'error');
         }
         $owner_id = $tracelog_info['trace_memberid'];
     }
     $comment_model = Model('sns_comment');
     $insert_arr = array();
     $insert_arr['comment_memberid'] = $_SESSION['member_id'];
     $insert_arr['comment_membername'] = $_SESSION['member_name'];
     $insert_arr['comment_memberavatar'] = $member_info['member_avatar'];
     $insert_arr['comment_originalid'] = $originalid;
     $insert_arr['comment_originaltype'] = $originaltype;
     $insert_arr['comment_content'] = $_POST['commentcontent'];
     $insert_arr['comment_addtime'] = time();
     $insert_arr['comment_ip'] = uk86_getIp();
     $insert_arr['comment_state'] = '0';
     //正常
     $result = $comment_model->commentAdd($insert_arr);
     if ($result) {
         if ($originaltype == 1) {
             //更新商品的评论数
             $update_arr = array();
             $update_arr['share_commentcount'] = array('sign' => 'increase', 'value' => '1');
             $sharegoods_model->editSharegoods($update_arr, array('share_id' => "{$originalid}"));
         } else {
             //更新动态统计信息
             $update_arr = array();
             $update_arr['trace_commentcount'] = array('sign' => 'increase', 'value' => '1');
             if (intval($tracelog_info['trace_originalid']) == 0) {
                 $update_arr['trace_orgcommentcount'] = array('sign' => 'increase', 'value' => '1');
             }
             $tracelog_model->tracelogEdit($update_arr, array('trace_id' => "{$originalid}"));
             unset($update_arr);
             //更新所有转帖的原帖评论次数
             if (intval($tracelog_info['trace_originalid']) == 0) {
                 $tracelog_model->tracelogEdit(array('trace_orgcommentcount' => $tracelog_info['trace_orgcommentcount'] + 1), array('trace_originalid' => "{$originalid}"));
             }
         }
         //建立cookie
         if (uk86_cookie('commentnum') != null && intval(uk86_cookie('commentnum')) > 0) {
             uk86_setNcCookie('commentnum', intval(uk86_cookie('commentnum')) + 1, 2 * 3600);
             //保存2小时
         } else {
             uk86_setNcCookie('commentnum', 1, 2 * 3600);
             //保存2小时
         }
         $js = "\$(\"#content_comment{$originalid}\").val('');";
         if ($_POST['showtype'] == 1) {
             $js .= "\$(\"#tracereply_{$originalid}\").load('index.php?act=member_snshome&op=commenttop&mid={$owner_id}&id={$originalid}&type={$originaltype}');";
         } else {
             $js .= "\$(\"#tracereply_{$originalid}\").load('index.php?act=member_snshome&op=commentlist&mid={$owner_id}&id={$originalid}&type={$originaltype}');";
         }
         showDialog(Uk86Language::uk86_get('sns_comment_succ'), '', 'succ', $js);
     }
 }
Пример #7
0
 function indexOp()
 {
     $model_member = Model('member');
     $wxinfo = $model_member->get_wx_config();
     if (empty($wxinfo)) {
         showDialog('您还没有配置微信基本参数appid,appsecret!');
     }
     $wechat = new Wechat($wxinfo['appid'], $wxinfo['appsecret'], 'snsapi_base');
     if (!isset($_GET['code'])) {
         $redirect_uri = SHOP_SITE_URL . '/index.php?act=wxuser';
         $url = $wechat->get_code_url($redirect_uri);
         header("Location: {$url}");
     } else {
         $code = $_GET['code'];
     }
     if (empty($code)) {
         showDialog('授权获取code失败');
     }
     $oauth = json_decode($wechat->get_oauth_token($code));
     $return_url = SHOP_SITE_URL . '/index.php?act=wap_index';
     if (isset($oauth->access_token) && isset($oauth->openid)) {
         $user = json_decode($wechat->get_user_info($oauth->openid, $oauth->access_token));
         try {
             if (!$user->openid) {
                 throw new Exception('未获取到微信用户的基本信息');
             }
             $openid = $user->openid;
             $wxusers = $model_member->get_wx_user($openid);
             if ($wxusers && $wxusers[0]) {
                 $model_member->createSession($wxusers[0]);
                 header("Location:{$return_url}");
                 exit;
             }
             $model_member->beginTransaction();
             $params['openid'] = $openid;
             $params['nickname'] = $user->nickname;
             $params['sex'] = $user->sex;
             $params['headimgurl'] = $user->headimgurl;
             $params['city'] = $user->city;
             $params['province'] = $user->province;
             $params['country'] = $user->country;
             $params['userinfo'] = json_encode($user);
             $params['create_time'] = date('Y-m-d H:i:s');
             $params['update_time'] = date('Y-m-d H:i:s');
             $wx_users_id = $model_member->addWxUser($params);
             if ($wx_users_id) {
                 $count = $model_member->get_member_count();
                 $insert_array = array();
                 $insert_array['member_name'] = 'uk_wx_' . $count;
                 $insert_array['member_passwd'] = md5('123456');
                 $insert_array['member_email'] = $insert_array['member_name'] . '@xx.xx';
                 $insert_array['member_email_bind'] = 1;
                 $insert_array['member_time'] = time();
                 $insert_array['member_login_time'] = $insert_array['member_time'];
                 $insert_array['member_points'] = 20;
                 $insert_array['member_login_ip'] = uk86_getIp();
                 $insert_array['member_sex'] = $params['sex'];
                 $insert_array['wx_users_id'] = $wx_users_id;
                 $result = Model('member')->insert($insert_array);
                 if (empty($result)) {
                     throw new Exception('注册用户失败');
                 }
                 $member_info = $model_member->getMemberInfo(array('member_name' => $insert_array['member_name'], 'member_passwd' => $insert_array['member_passwd']));
                 if (!empty($member_info) && is_array($member_info)) {
                     //会员信息写入session
                     $model_member->createSession($member_info);
                 } else {
                     throw new Exception('未获取到用户注册信息');
                 }
             } else {
                 throw new Exception('微信用户信息添加失败');
             }
             $model_member->commit();
             header("Location:{$return_url}");
         } catch (Exception $e) {
             $model_member->rollback();
             showDialog($e->getMessage());
         }
     } else {
         showDialog('获取信息失败', $return_url);
     }
 }
Пример #8
0
 /**
  * 注册商城会员
  *
  * @param	array $param 会员信息
  * @return	array 数组格式的返回结果
  */
 public function addMember($param)
 {
     if (empty($param)) {
         return false;
     }
     try {
         $this->beginTransaction();
         $member_info = array();
         $member_info['member_id'] = $param['member_id'];
         $member_info['member_name'] = $param['member_name'];
         $member_info['member_passwd'] = md5(trim($param['member_passwd']));
         $member_info['member_email'] = $param['member_email'];
         $member_info['member_time'] = TIMESTAMP;
         $member_info['member_login_time'] = TIMESTAMP;
         $member_info['member_old_login_time'] = TIMESTAMP;
         $member_info['member_login_ip'] = uk86_getIp();
         $member_info['member_old_login_ip'] = $member_info['member_login_ip'];
         $member_info['member_email_bind'] = $param['member_email_bind'];
         $member_info['member_truename'] = $param['member_truename'];
         $member_info['member_qq'] = $param['member_qq'];
         $member_info['member_sex'] = $param['member_sex'];
         $member_info['member_avatar'] = $param['member_avatar'];
         $member_info['member_qqopenid'] = $param['member_qqopenid'];
         $member_info['member_qqinfo'] = $param['member_qqinfo'];
         $member_info['member_sinaopenid'] = $param['member_sinaopenid'];
         $member_info['member_sinainfo'] = $param['member_sinainfo'];
         //添加邀请人(推荐人)会员U币 by ukshop.com
         $member_info['inviter_id'] = $param['inviter_id'];
         $insert_id = $this->table('member')->insert($member_info);
         if (!$insert_id) {
             throw new Exception();
         }
         $insert = $this->addMemberCommon(array('member_id' => $insert_id));
         if (!$insert) {
             throw new Exception();
         }
         $this->commit();
         return $insert_id;
     } catch (Exception $e) {
         $this->rollback();
         return false;
     }
 }
Пример #9
0
 /**
  * 记录卖家日志
  *
  * @param $content 日志内容
  * @param $state 1成功 0失败
  */
 protected function recordSellerLog($content = '', $state = 1)
 {
     $seller_info = array();
     $seller_info['log_content'] = $content;
     $seller_info['log_time'] = TIMESTAMP;
     $seller_info['log_seller_id'] = $_SESSION['seller_id'];
     $seller_info['log_seller_name'] = $_SESSION['seller_name'];
     $seller_info['log_store_id'] = $_SESSION['store_id'];
     $seller_info['log_seller_ip'] = uk86_getIp();
     $seller_info['log_url'] = $_GET['act'] . '&' . $_GET['op'];
     $seller_info['log_state'] = $state;
     $model_seller_log = Model('seller_log');
     $model_seller_log->addSellerLog($seller_info);
 }