Beispiel #1
0
 public function post($f3)
 {
     // 权限检查
     $this->requirePrivilege('manage_plugin_plugin_configure');
     global $smarty;
     // 参数验证
     $validator = new Validator($f3->get('POST'));
     $yiqifacps_rate_web = $validator->required()->validate('yiqifacps_rate_web');
     $yiqifacps_rate_mobile = $validator->required()->validate('yiqifacps_rate_mobile');
     $qqcaibei_key1 = $validator->required()->validate('qqcaibei_key1');
     $qqcaibei_key2 = $validator->required()->validate('qqcaibei_key2');
     $yiqifacps_duration = $validator->required()->digits()->min(1)->validate('yiqifacps_duration');
     if (!$this->validate($validator)) {
         goto out_display;
     }
     // 保存设置
     YiqifaCpsPlugin::saveOptionValue('yiqifacps_rate_web', $yiqifacps_rate_web);
     YiqifaCpsPlugin::saveOptionValue('yiqifacps_rate_mobile', $yiqifacps_rate_mobile);
     YiqifaCpsPlugin::saveOptionValue('yiqifacps_duration', $yiqifacps_duration);
     YiqifaCpsPlugin::saveOptionValue('qqcaibei_key1', $qqcaibei_key1);
     YiqifaCpsPlugin::saveOptionValue('qqcaibei_key2', $qqcaibei_key2);
     $this->addFlashMessage('保存设置成功');
     out_display:
     $smarty->display('yiqifacps_configure.tpl', 'post');
 }
Beispiel #2
0
 public function get($f3)
 {
     // 设置 order_refer 记录,记录在客户端
     $orderRefer = array();
     // 检查彩贝的记录
     $caibeiRefer = $f3->get('SESSION[yiqifa_caibei_order_refer]');
     if (!empty($caibeiRefer)) {
         $orderRefer = $caibeiRefer;
         unset($orderRefer['refer_host']);
         // 去掉彩贝的 refer_host
     }
     // 清除彩贝记录
     $f3->set('SESSION[yiqifa_caibei_order_refer]', null);
     $orderRefer['utm_source'] = 'YIQIFACPS';
     // 保存额外的 亿起发 参数
     $validator = new Validator($_REQUEST);
     $referParamArray = array();
     $referParamArray['src'] = $validator->validate('src');
     $referParamArray['cid'] = $validator->validate('cid');
     $referParamArray['wi'] = $validator->validate('wi');
     $referParamArray['channel'] = $validator->validate('channel');
     $orderRefer['refer_param'] = json_encode($referParamArray);
     //设置 cookie
     ReferHelper::setOrderReferSpecific($f3, $orderRefer, YiqifaCpsPlugin::getOptionValue('yiqifacps_duration'));
     // 页面跳转到商品
     $url = $validator->validate('url');
     $redirectUrl = empty($url) ? '/' : $url;
     RouteHelper::reRoute($this, $redirectUrl);
     return;
 }
Beispiel #3
0
 public function post($f3)
 {
     //首先验证参数签名
     $map = $_POST;
     unset($map['Vkey']);
     //读取除了vkey外的所有参数,并且放入数组map中
     ksort($map);
     //进行按参数的升序排序
     //进行签名,注意考虑到md5加密输出的大小写问题,所有约定md5的输出均为小写
     $vkey = implode('', array_values($map));
     $md5_1 = strtolower(md5($vkey . YiqifaCpsPlugin::getOptionValue('qqcaibei_key1')));
     $vkey = strtolower(md5($md5_1 . YiqifaCpsPlugin::getOptionValue('qqcaibei_key2')));
     if ($vkey != $_POST['Vkey']) {
         // 参数签名错误
         goto out;
     }
     // 保存额外的 亿起发 参数
     $orderRefer = array();
     $orderRefer['utm_medium'] = 'QQCAIBEI';
     //设置 cookie
     ReferHelper::setOrderReferSpecific($f3, $orderRefer, YiqifaCpsPlugin::getOptionValue('yiqifacps_duration'));
     $f3->set('SESSION[yiqifa_caibei_order_refer]', ReferHelper::parseOrderRefer($f3));
     // 取得QQ彩贝传递过来的参数
     //$acct     = @$_POST['Acct'];
     $url = @$_POST['Url'];
     $openId = @$_POST['OpenId'];
     //$clubInfo = @intval($_POST['ClubInfo']); // 会员等级信息,目前没用
     $viewInfo = @$_POST['ViewInfo'];
     if (get_magic_quotes_gpc()) {
         $viewInfo = stripslashes($viewInfo);
     }
     $viewInfoArray = array();
     parse_str($viewInfo, $viewInfoArray);
     //解析 viewInfoArray 数组
     //$f3->set('SESSION[qqcaibei_viewinfoarray]', json_encode($viewInfoArray)); //放入到 session 里面
     // 设置 ClientData
     ClientData::saveClientData('qqcaibei_viewinfoarray', json_encode($viewInfoArray));
     if (empty($openId)) {
         // 没有  openId 没法登陆,直接退出
         goto out;
     }
     // 这里做 QQ彩贝 联合登陆
     $sns_login = "******";
     // 用户登陆操作
     $userBasicService = new UserBasicService();
     $authUser = $userBasicService->doAuthSnsUser($sns_login, null, null, false);
     if ($authUser) {
         goto out_login_user;
     }
     // 之前没有登陆过,自动注册用户
     $authUser = $userBasicService->doAuthSnsUser($sns_login, $openId . '@qq.com', $openId . '@qq.com', true);
     printLog('注册QQ用户:' . print_r($viewInfoArray, true), 'QQLOGIN', \Core\Log\Base::INFO);
     out_login_user:
     AuthHelper::saveAuthUser($authUser->toArray(), 'qqcaibei');
     // 设置用户名在网页显示
     ClientData::saveClientData(\Controller\User\Login::$clientDataIsUserLoginKey, true);
     ClientData::saveClientData(\Controller\User\Login::$clientDataUserNameDisplayKey, 'QQ彩贝用户:' . $viewInfoArray['NickName']);
     out:
     // 页面跳转到商品
     $redirectUrl = empty($url) ? '/' : $url;
     RouteHelper::reRoute($this, $redirectUrl);
     return;
 }
Beispiel #4
0
 public function doUpdate($currentVersion)
 {
     // 简单的把版本设置为 1.0.0 就算完成升级了
     YiqifaCpsPlugin::saveOptionValue('version', $this->targetVersion);
     return true;
 }
Beispiel #5
0
 public function getCpsParam($orderRefer, $orderInfo, $orderGoods)
 {
     if (empty($orderRefer->utm_source) || 'YIQIFACPS' != $orderRefer->utm_source) {
         return false;
     }
     // 返回 yiqifacps 的费率
     return array('cps_rate' => YiqifaCpsPlugin::getOptionValue(YiqifaCpsRefer::$cpsRateKey));
 }