Пример #1
0
 public function __construct()
 {
     parent::__construct();
     if (false == function_exists('utyjfsldDSAqkfjlfdslkjfldsawapfjdslakfHDFfjlsaf')) {
     }
     $this->token = $this->mer_id = isset($_REQUEST["mer_id"]) ? htmlspecialchars($_REQUEST["mer_id"]) : (isset($_REQUEST["token"]) ? htmlspecialchars($_REQUEST["token"]) : 0);
     if (strpos($_SERVER["HTTP_USER_AGENT"], "MicroMessenger") !== false) {
         $this->is_wexin_browser = true;
     }
     $this->assign("is_wexin_browser", $this->is_wexin_browser);
     if ($this->is_wexin_browser && empty($_SESSION["openid"])) {
         $this->authorize_openid();
     }
     if ($this->config["wechat_follow_txt_url"] && $this->config["wechat_follow_txt_txt"] && !empty($_GET["openid"])) {
         if ($this->config["wechat_follow_show_open"]) {
             $invote_follow = true;
         } else {
             if ($this->user_session["uid"]) {
                 $now_user = D("User")->get_user($this->user_session["uid"]);
                 if ($now_user["is_follow"]) {
                     $invote_follow = true;
                 }
             } else {
                 $invote_follow = true;
             }
         }
         if ($invote_follow) {
             $invote_user = D("User")->get_user($_GET["openid"], "openid");
             if (!empty($invote_user)) {
                 $invote_nickname = !empty($invote_user["truename"]) ? $invote_user["truename"] : $invote_user["nickname"];
                 $invote_array = array("url" => $this->config["wechat_follow_txt_url"], "txt" => str_replace("{nickname}", $invote_nickname, $this->config["wechat_follow_txt_txt"]), "avatar" => $invote_user["avatar"]);
                 $this->assign("invote_array", $invote_array);
             }
         }
     }
     if (MODULE_NAME == "Meal" && ACTION_NAME == "index" || MODULE_NAME == "Group" && ACTION_NAME == "detail") {
         $otherwc = isset($_GET["otherwc"]) ? intval($_GET["otherwc"]) : 0;
         if ($otherwc) {
             $_SESSION["otherwc"] = $otherwc;
         } else {
             $_SESSION["otherwc"] = 0;
         }
     }
     $this->assign('mer_id', $this->mer_id);
     $this->assign('token', $this->token);
     $this->merchant_info = d('Merchant_info')->field(true)->where(array('token' => $this->token))->find();
     $merchant = d('Merchant')->field('name')->where(array('mer_id' => $this->token))->find();
     if (empty($this->merchant_info) && true == $this->token) {
         $info = array('wxname' => $merchant['name'], 'createtime' => time(), 'updatetime' => time(), 'tpltypeid' => 1, 'tpllistid' => 1, 'tplcontentid' => 1, 'tpltypename' => '193_index_b4bt', 'tpllistname' => 'yl_list', 'tplcontentname' => 'ktv_content');
         $info['token'] = $info['uid'] = $this->token;
         $info['id'] = d('Merchant_info')->add($info);
         $this->merchant_info = $info;
     } else {
         if ($this->merchant_info['wxname'] != $merchant['name']) {
             d('Merchant_info')->where(array('id' => $this->merchant_info['id']))->save(array('wxname' => $merchant['name']));
         }
     }
     $this->merchant_info['wxname'] = $merchant['name'];
     $this->assign('wxuser', $this->merchant_info);
     $this->static_path = $this->config['site_url'] . '/tpl/Wap/static/';
     $this->assign('static_path', $this->static_path);
     $this->common_url['group_category_all'] = u('Wap/Group/index');
     $this->assign($this->common_url);
     if ($this->is_wexin_browser) {
         $share = new WechatShare($this->config, $_SESSION["openid"]);
         $this->shareScript = $share->getSgin();
         $this->assign("shareScript", $this->shareScript);
         $this->hideScript = $share->gethideOptionMenu();
         $this->assign("hideScript", $this->hideScript);
     }
 }