Inheritance: extends AWS_CONTROLLER
Ejemplo n.º 1
0
 function doSaveWeibo($uid, $data, $from = 0, $type = 0, $type_data, $sync, $from_data)
 {
     if (!$data['content']) {
         return false;
     }
     $save['uid'] = $uid;
     $save['transpond_id'] = intval($data['transpond_id']);
     $save['from'] = intval($from);
     //0网站 1手机网页版 2 android 3 iphone
     $save['content'] = preg_replace_callback('/((?:https?|mailto).*?)(\\s| |&nbsp;|<br|\'|\\"|$)/', getContentUrl, $data['content']);
     $save['from_data'] = $from_data;
     if (mb_strlen($save['content'], 'UTF8') > 140) {
         return false;
     }
     if ($type) {
         $save = array_merge($save, $this->checkWeiboType($type, $type_data));
     } else {
         if ($data['type']) {
             $save['type'] = intval($data['type']);
         }
     }
     $save['ctime'] = time();
     if ($id = $this->add($save)) {
         if ($save['transpond_id']) {
             $this->setInc('transpond', 'weibo_id=' . $save['transpond_id']);
         }
         if (in_array('sina', $sync)) {
             $opt = M('login')->where("uid=" . $uid . " AND type='sina'")->field('oauth_token,oauth_token_secret,is_sync')->find();
             //if($opt['is_sync']){
             include_once SITE_PATH . '/addons/plugins/login/sina.class.php';
             $sina = new sina();
             if ($type == 1) {
                 $sina->upload($save['content'], SITE_URL . '/data/uploads/' . $type_data, $opt);
             } elseif ($type == 0) {
                 $sina->update($save['content'], $opt);
             }
             //}
         }
         //话题处理
         D('Topic', 'weibo')->addTopic($save['content']);
         return $id;
     } else {
         return false;
     }
 }
Ejemplo n.º 2
0
 public function login_callback_on_client()
 {
     $type = $_GET['type'];
     switch ($type) {
         case 'sina':
             $this->_loadTypeLogin($type);
             $sina = new sina();
             $sina->checkUser();
             redirect(Addons::createAddonUrl('Login', 'login_display_on_client', array('type' => $type)));
             break;
         default:
     }
 }
Ejemplo n.º 3
0
 public function callback()
 {
     include_once SITE_PATH . '/addons/plugins/login/sina.class.php';
     $sina = new sina();
     $sina->checkUser();
     redirect(U('home/public/otherlogin'));
 }
Ejemplo n.º 4
0
 /**
  * 领取优惠券
  *
  */
 public function pull()
 {
     if ($this->isAjax()) {
         $this->_check_login();
         $c_id = intval($_REQUEST['c_id']);
         $c_id or die('id invalid.');
         $ccModel = D('TaoCoupon');
         $detail = $ccModel->info($c_id);
         $detail or die('id invalid.');
         if ($detail['is_active'] == 0) {
             $this->ajaxReturn('', '该优惠券已下架,请选择商家其他的优惠券', 0);
         }
         $localTimeObj = LocalTime::getInstance();
         $nowtime = $localTimeObj->gmtime();
         $today = $localTimeObj->local_strtotime(date('Y-m-d 23:59:59'));
         //是否过期
         if ($detail['expiry_type'] == 1 && $detail['expiry'] < $today) {
             $this->ajaxReturn('', '该优惠券已过期,请选择商家其他的优惠券', 0);
         }
         //剩余数量
         /*
         if($detail['fetched_amount'] >= $detail['amount']){
         	$this->ajaxReturn('', '该优惠券已发放完毕,请选择其他的优惠券', 0);
         }
         */
         //领取限制
         $ccrModel = M('TaoCouponRecords');
         //每个账户一张
         if ($detail['data']['fetch_limit'] == 101) {
             if ($ccrModel->field('id')->where("c_id='{$c_id}' AND user_id='" . $this->_user['user_id'] . "'")->find()) {
                 $this->ajaxReturn('', '您已领取过该优惠券,请选择其他的优惠券', 0);
             }
         } else {
             if ($detail['data']['fetch_limit'] == 102) {
                 $b_time = $localTimeObj->local_strtotime(date('Y-m-d 00:00:00'));
                 $e_time = $today;
                 $where = "c_id='{$c_id}' AND user_id='" . $this->_user['user_id'] . "'";
                 $where .= " AND fetch_time>='{$b_time}' AND fetch_time<='{$e_time}'";
                 if ($ccrModel->field('id')->where($where)->find()) {
                     $this->ajaxReturn('', '您今天已领取过该优惠券,请选择其他的优惠券', 0);
                 }
             }
         }
         //付费情况
         if ($detail['price_type'] != 1) {
             $userModel = D('User');
             $user = $userModel->info($this->_user['user_id'], array('money', 'credit'));
             //付费
             if ($detail['price_type'] == 2) {
                 if ($user['money'] < $detail['price']) {
                     $this->ajaxReturn('', '您的账户金额不足,请先到帐号中心充值再来购买。请点击<a href="' . reUrl('Payment/pay') . '" target="_blank">在线充值</a>', 0);
                 }
                 $spend = Consume::spend($this->_user['user_id'], $detail['price'], Consume::TYPE_MONEY);
             } else {
                 if ($detail['price_type'] == 3) {
                     if ($user['credit'] < $detail['price']) {
                         $this->ajaxReturn('', '您的账户积分不足,请选择其他的优惠券', 0);
                     }
                     $spend = Consume::spend($this->_user['user_id'], $detail['price'], Consume::TYPE_CREDIT);
                 }
             }
             if ($spend !== 1) {
                 $this->ajaxReturn('', '支付失败,请重试', 0);
             }
         }
         $data = array('c_id' => $c_id, 'user_id' => $this->_user['user_id'], 'nick' => $this->_user['nick'], 'fetch_time' => $nowtime);
         $result = $ccrModel->add($data);
         if ($result) {
             $ccmService = service('TaoShop');
             $shop = $ccmService->info($detail['s_id']);
             //更新领取数量
             $ccModel->update($c_id, array('fetched_amount' => $detail['fetched_amount'] + 1));
             //更新昨日、今日、本周、本月等领取数量
             $yestoday = $nowtime - 24 * 3600;
             $ccdModel = D('TaoCouponData');
             $r = $ccdModel->info($c_id, array('yesterdayfetched', 'dayfetched', 'weekfetched', 'monthfetched', 'updatetime'));
             $yesterdayfetched = date('Ymd', $r['updatetime']) == date('Ymd', $yestoday) ? $r['dayfetched'] : $r['yesterdayfetched'];
             $dayfetched = date('Ymd', $r['updatetime']) == date('Ymd', $nowtime) ? $r['dayfetched'] + 1 : 1;
             $weekfetched = date('YW', $r['updatetime']) == date('YW', $nowtime) ? $r['weekfetched'] + 1 : 1;
             $monthfetched = date('Ym', $r['updatetime']) == date('Ym', $nowtime) ? $r['monthfetched'] + 1 : 1;
             $data = array('yesterdayfetched' => $yesterdayfetched, 'dayfetched' => $dayfetched, 'weekfetched' => $weekfetched, 'monthfetched' => $monthfetched, 'updatetime' => $nowtime);
             $ccdModel->update($c_id, $data);
             //发表一条微博
             if ($this->_CFG['sina_wb_open'] && $_SESSION['sina']['token']['access_token'] || $this->_CFG['qq_open'] && $_SESSION['qq']["access_token"]) {
                 $title = '';
                 if ($detail['title']) {
                     $title .= $detail['title'];
                 } else {
                     $title .= $detail['s_title'];
                     if ($detail['c_type'] == 1) {
                         $title .= '满' . $detail['money_max'] . '减' . $detail['money_reduce'] . '元优惠券';
                     } else {
                         $title .= $detail['money_amount'] . '元代金券';
                     }
                 }
                 $url = 'http://' . $_SERVER['HTTP_HOST'] . reUrl('Tao/show?id=' . $c_id);
                 $pic_path = tao_shop_logo($shop['pic_path']);
                 $text = '我刚刚在#' . $this->_CFG['site_name'] . '#领取了一张【' . $title . '】,数量有限,抢完为止,一般人我不告诉!' . $url;
                 if ($this->_CFG['sina_wb_open'] && $_SESSION['sina']['token']['access_token']) {
                     include_once DOC_ROOT_PATH . 'Addons/plugins/login/sina.class.php';
                     $sina = new sina();
                     $sina->upload($text, $pic_path);
                 } else {
                     if ($this->_CFG['qq_open'] && $_SESSION['qq']["access_token"]) {
                         include_once DOC_ROOT_PATH . 'Addons/plugins/login/qq.class.php';
                         $qq = new qq();
                         //发送微博
                         $qq->add_t($text);
                         //发送空间分享
                         $title = '我刚刚在' . $this->_CFG['site_name'] . '领取了一张【' . $title . '】,数量有限,抢完为止,一般人我不告诉!';
                         $site = $_SERVER['HTTP_HOST'];
                         $qq->add_share($title, $url, $site, $pic_path);
                     }
                 }
             }
             if ($detail['data']['fetch_link']) {
                 $coupon_url = $detail['data']['fetch_link'];
             } else {
                 $coupon_url = 'http://ecrm.taobao.com/shopbonusapply/buyer_apply.htm?activity_id=' . $detail['data']['activity_id'] . '&seller_id=' . $detail['data']['seller_id'];
             }
             $data = array('shop_click_url' => $shop['shop_click_url'], 'coupon_url' => $coupon_url);
             $this->ajaxReturn($data, '领取成功', 1);
         } else {
             $this->ajaxReturn('', '领取失败', 0);
         }
     }
 }
 /**
  * @deprecated
  */
 function bind_backup()
 {
     $type = h($_POST['value']);
     if ($_POST) {
         include_once SITE_PATH . '/addons/plugins/login/sina.class.php';
         $sina = new sina();
         $weiboAuth = $sina->getJSON($_POST['username'], $_POST['password']);
         if ($weiboAuth['oauth_token']) {
             $data['type'] = 'sina';
             $data['type_uid'] = $weiboAuth['user_id'];
             $data['uid'] = $this->mid;
             if ($info = M('login')->where($data)->find()) {
                 if ($info['oauth_token']) {
                     M('login')->setField('is_sync', 1, $data);
                 } else {
                     $savedata['oauth_token'] = $weiboAuth['oauth_token'];
                     $savedata['oauth_token_secret'] = $weiboAuth['oauth_token_secret'];
                     $savedata['is_sync'] = 1;
                     M('login')->where('login_id=' . $info['login_id'])->data($savedata)->save();
                 }
             } else {
                 $data['oauth_token'] = $weiboAuth['oauth_token'];
                 $data['oauth_token_secret'] = $weiboAuth['oauth_token_secret'];
                 $data['is_sync'] = 1;
                 M('login')->add($data);
             }
             echo '1';
         } else {
             echo '0';
         }
     } else {
         $map['uid'] = $this->mid;
         $map['type'] = 'sina';
         if (M('login')->where("uid={$this->mid} AND type='sina' AND oauth_token<>''")->count()) {
             M('login')->setField('is_sync', 1, $map);
             echo '1';
         } else {
             $this->display();
         }
     }
 }
Ejemplo n.º 6
0
 private function _on_sina_logined()
 {
     include_once DOC_ROOT_PATH . 'Addons/plugins/login/sina.class.php';
     $sina = new sina();
     //检查是否已绑定帐号
     $openid = $sina->get_openid();
     $platformModel = M('user_platform');
     $user = $platformModel->field('id,user_id')->where("`type`='sina' AND openid='{$openid}'")->find();
     //已绑定
     if ($user) {
         //从UC中获取资料并同步UC应用
         $ucService = service('Uc');
         $userService = service('User');
         $_user = $ucService->get_user_info($user['user_id'], 1);
         if ($_user === null) {
             $platformModel->where("id='{$user['id']}'")->delete();
             redirect(reUrl('User/bind?type=sina'));
         }
         $sina_u_info = $sina->userInfo();
         $userService->after_logined(array('user_id' => $_user[0], 'nick' => $sina_u_info['screen_name'], 'avatar' => $sina_u_info['profile_image_url']), false);
         $_SESSION['login_type'] = '102';
         $syncHtml = $ucService->build_synlogin($_user[0]);
         if (cookie('r_url')) {
             $this->assign('jumpUrl', cookie('r_url'));
             cookie('r_url', null);
         } else {
             $this->assign('jumpUrl', reUrl('User/index'));
         }
         $this->success('登陆成功' . $syncHtml);
     } else {
         redirect(reUrl('User/bind?type=sina'));
     }
 }
Ejemplo n.º 7
0
 /**
  * 领取优惠券
  *
  */
 public function pull()
 {
     if ($this->isAjax()) {
         $this->_check_login();
         $localTimeObj = LocalTime::getInstance();
         $nowtime = $localTimeObj->gmtime();
         $today = $localTimeObj->local_strtotime(date('Y-m-d 23:59:59'));
         $cccModel = D('CouponCodeCodes');
         $ip = get_client_ip();
         //同一IP领取数量限制
         $begin_time = $localTimeObj->local_strtotime(date('Y-m-d 00:00:00'));
         if ($this->_CFG['ip_fetch_limit'] && $cccModel->where("fetch_time>='{$begin_time}' AND fetch_time<='{$today}' AND ip='{$ip}'")->count() >= intval($this->_CFG['ip_fetch_limit'])) {
             $this->ajaxReturn('', '您今天领取的优惠券数量已超过限制,请明天再来', 0);
         }
         $c_id = intval($_REQUEST['c_id']);
         $c_id or die('id invalid.');
         $ccModel = D('CouponCode');
         $detail = $ccModel->info($c_id);
         $detail or die('id invalid.');
         if ($detail['is_active'] == 0) {
             $this->ajaxReturn('', '该优惠券已下架,请选择商家其他的优惠券', 0);
         }
         //是否过期
         if ($detail['expiry_type'] == 1 && $detail['expiry'] < $today) {
             $this->ajaxReturn('', '该优惠券已过期,请选择商家其他的优惠券', 0);
         }
         //剩余数量
         if ($detail['fetched_amount'] >= $detail['amount']) {
             $this->ajaxReturn('', '该优惠券已发放完毕,请选择其他的优惠券', 0);
         }
         //领取帐号限制
         if ($detail['data']['fetch_account_limit'] != 200 && intval($_SESSION['login_type']) != $detail['data']['fetch_account_limit']) {
             $fetch_account_limit_conf = CouponCodeConf::fetch_account_limit_conf();
             $this->ajaxReturn('', $fetch_account_limit_conf[$detail['data']['fetch_account_limit']], 0);
         }
         //领取数量限制
         //每个账户一张
         if ($detail['data']['fetch_limit'] == 101) {
             if ($cccModel->getOneByUid($this->_user['user_id'], $c_id)) {
                 $this->ajaxReturn('', '您已领取过该优惠券,请选择其他的优惠券', 0);
             }
         } else {
             if ($detail['data']['fetch_limit'] == 102) {
                 $b_time = $localTimeObj->local_strtotime(date('Y-m-d 00:00:00'));
                 $e_time = $today;
                 $params = array('b_time' => $b_time, 'e_time' => $e_time);
                 if ($cccModel->getOneByUid($this->_user['user_id'], $c_id, $params)) {
                     $this->ajaxReturn('', '您今天已领取过该优惠券,请选择其他的优惠券', 0);
                 }
             }
         }
         //付费情况
         if ($detail['price_type'] != 1) {
             $userModel = D('User');
             $user = $userModel->info($this->_user['user_id'], array('money', 'credit'));
             //付费
             if ($detail['price_type'] == 2) {
                 if ($user['money'] < $detail['price']) {
                     $this->ajaxReturn('', '您的账户金额不足,请先到帐号中心充值再来购买。请点击<a href="' . reUrl('Payment/pay') . '" target="_blank">在线充值</a>', 0);
                 }
                 $spend = Consume::spend($this->_user['user_id'], $detail['price'], Consume::TYPE_MONEY);
             } else {
                 if ($detail['price_type'] == 3) {
                     if ($user['credit'] < $detail['price']) {
                         $this->ajaxReturn('', '您的账户积分不足,请选择其他的优惠券', 0);
                     }
                     $spend = Consume::spend($this->_user['user_id'], $detail['price'], Consume::TYPE_CREDIT);
                 }
             }
             if ($spend !== 1) {
                 $this->ajaxReturn('', '支付失败,请重试', 0);
             }
         }
         $code = $cccModel->pull($c_id, $this->_user['user_id'], $this->_user['nick'], $nowtime, $ip);
         if ($code) {
             //更新领取数量
             $ccModel->update($c_id, array('fetched_amount' => $detail['fetched_amount'] + 1));
             //更新昨日、今日、本周、本月等领取数量
             $yestoday = $nowtime - 24 * 3600;
             $ccdModel = D('CouponCodeData');
             $r = $ccdModel->info($c_id, array('yesterdayfetched', 'dayfetched', 'weekfetched', 'monthfetched', 'updatetime'));
             $yesterdayfetched = date('Ymd', $r['updatetime']) == date('Ymd', $yestoday) ? $r['dayfetched'] : $r['yesterdayfetched'];
             $dayfetched = date('Ymd', $r['updatetime']) == date('Ymd', $nowtime) ? $r['dayfetched'] + 1 : 1;
             $weekfetched = date('YW', $r['updatetime']) == date('YW', $nowtime) ? $r['weekfetched'] + 1 : 1;
             $monthfetched = date('Ym', $r['updatetime']) == date('Ym', $nowtime) ? $r['monthfetched'] + 1 : 1;
             $data = array('yesterdayfetched' => $yesterdayfetched, 'dayfetched' => $dayfetched, 'weekfetched' => $weekfetched, 'monthfetched' => $monthfetched, 'updatetime' => $nowtime);
             $ccdModel->update($c_id, $data);
             //发表一条微博
             if ($this->_CFG['sina_wb_open'] && $_SESSION['sina']['token']['access_token'] || $this->_CFG['qq_open'] && $_SESSION['qq']["access_token"]) {
                 $ccmService = service('CouponCodeMall');
                 $mall = $ccmService->info($detail['m_id']);
                 $title = '';
                 if ($detail['title']) {
                     $title .= $detail['title'];
                 } else {
                     $title .= $mall['name'];
                     if ($detail['c_type'] == 1) {
                         $title .= '满' . $detail['money_max'] . '减' . $detail['money_reduce'] . '元优惠券';
                     } else {
                         $title .= $detail['money_amount'] . '元代金券';
                     }
                 }
                 $url = 'http://' . $_SERVER['HTTP_HOST'] . reUrl('Code/view?id=' . $c_id);
                 $pic_path = 'http://' . $_SERVER['HTTP_HOST'] . FixedUploadedFileUrl($mall['figure_image']);
                 $text = '我刚刚在#' . $this->_CFG['site_name'] . '#领取了一张【' . $title . '】,数量有限,抢完为止,一般人我不告诉!' . $url;
                 if ($this->_CFG['sina_wb_open'] && $_SESSION['sina']['token']['access_token']) {
                     include_once DOC_ROOT_PATH . 'Addons/plugins/login/sina.class.php';
                     $sina = new sina();
                     $sina->upload($text, $pic_path);
                 } else {
                     if ($this->_CFG['qq_open'] && $_SESSION['qq']["access_token"]) {
                         include_once DOC_ROOT_PATH . 'Addons/plugins/login/qq.class.php';
                         $qq = new qq();
                         //发送微博
                         $qq->add_t($text);
                         //发送空间分享
                         $title = '我刚刚在' . $this->_CFG['site_name'] . '领取了一张【' . $title . '】,数量有限,抢完为止,一般人我不告诉!';
                         $site = $_SERVER['HTTP_HOST'];
                         $qq->add_share($title, $url, $site, $pic_path);
                     }
                 }
             }
             $this->ajaxReturn($code, '领取成功', 1);
         } else {
             $this->ajaxReturn('', '领取失败', 0);
         }
     }
 }