示例#1
0
 /**
  *
  *获取微信所有用户
  * @account			微账号
  * @password		微密码
  * @datapath		cookie保存位置
  * @debug			错误是否开启 true false
  *
  */
 public function weiUserlist()
 {
     $systems = $this->systems();
     //$weiuser=M('weiuser');
     //模似登陆微信
     $options = array('account' => $systems['sys_weiAccount'], 'password' => $systems['sys_weiPassword'], 'datapath' => './temp/Data/cookie', 'debug' => true, 'logcallback' => 'logdebug');
     import("ORG.Weixin.Wechatext");
     $wechat = new Wechatext($options);
     // 获取所有用户		需添加分页跳转处理
     if ($wechat->checkValid()) {
         $userlist = reset($wechat->getUserlist());
         print_r($wechat->getInfo('2121015543'));
         exit;
         $weiuser->query('TRUNCATE ds_weiuser');
         //清空表
         foreach ($userlist as $id => $ut) {
             $array['fakeid'] = $ut['id'];
             $array['nick_name'] = $ut['nick_name'];
             $array['remark_name'] = $ut['remark_name'];
             $array['group_id'] = $ut['group_id'];
             $weiuser->add($array);
         }
         $this->success('更新成功', '__URL__/index');
     } else {
         echo "login error";
     }
 }
示例#2
0
 private function reply($data)
 {
     if ('subscribe' == $data['Event']) {
         //关注微信平台收到的回复信息
         $state = M('state');
         $statedata['fromusername'] = $this->data['FromUserName'];
         $statedata['state'] = "0";
         $state->add($statedata);
         return array('你好,欢迎关注,回复"微信墙"参加上墙互动Y(^_^)Y', 'text');
     } elseif ('unsubscribe' == $data['Event']) {
         $state = M('state');
         $statedata['fromusername'] = $this->data['FromUserName'];
         $state->where($statedata)->delete();
     }
     $key = $data['Content'];
     if ($key == '返回' || $key == '后退') {
         $state = M('state');
         $statewhere['fromusername'] = $this->data['FromUserName'];
         $statedata['state'] = "0";
         $state->where($statewhere)->save($statedata);
     }
     $states = M('state');
     $statewhere['fromusername'] = $this->data['FromUserName'];
     $stateinfo = $states->where($statewhere)->find();
     $statefansnow = $stateinfo['state'];
     $publicnumstate = M('publicnum')->find();
     if ($publicnumstate['type'] == 2) {
         if ($statefansnow == 1) {
             if ($this->functionw == 1) {
                 //判断是否有高级接口
                 $fans = M('fans');
                 $where['fromusername'] = $this->data['FromUserName'];
                 $where['token'] = $this->token;
                 $fansinfo = $fans->where($where)->find();
                 if ($fansinfo) {
                     $message['img'] = $fansinfo['img'];
                     $list = M('list');
                     $message['nickname'] = $fansinfo['nickname'];
                     if ($this->data['MsgType'] == "image") {
                         $PicUrl = $this->data['PicUrl'];
                         $message['content'] = '<img src="' . $PicUrl . '"/>';
                     } elseif ($this->data['MsgType'] == "text") {
                         $message['content'] = $this->data['Content'];
                     } else {
                         $message['content'] = '';
                     }
                     $message['time'] = $this->data['CreateTime'];
                     $message['examine'] = "0";
                     $message['token'] = $this->token;
                     $message['choose'] = "0";
                     $message['fromusername'] = $this->data['FromUserName'];
                     $message['fake_id'] = $fansinfo['fake_id'];
                     $message['newsid'] = $this->data['MsgId'];
                     $message['sex'] = $fansinfo['sex'];
                     $list->add($message);
                     return array(array(array('发送成功'), array('您发送的即将在大屏幕上滚动播出'), array('回复【返回】或者【后退】返回主菜单')), 'news');
                 } else {
                     vendor('wechat.wechat2#class');
                     $options = array('token' => $this->token, 'appid' => $this->appid, 'appsecret' => $this->appsecret, 'partnerid' => '88888888', 'partnerkey' => '', 'paysignkey' => '');
                     $weObj = new wechat2($options);
                     //创建实例对象
                     //$userinfodata=$weObj->getUserInfo($this->data['FromUserName']);
                     $publicaccess = M('publicnum')->where(array('token' => $this->token))->find();
                     if ($publicaccess['accesstoken'] != "") {
                         $difference = time() - $publicaccess['time'];
                         if ($difference > 0) {
                             //_______根据appid和appsecret获取access_token
                             $userinfodata = $weObj->getUserInfo($this->data['FromUserName']);
                             $access_tokennow = $weObj->access_token;
                             $data['accesstoken'] = $access_tokennow;
                             $data['time'] = time();
                             $data['token'] = $this->token;
                             $data['Id'] = $publicaccess['Id'];
                             $publicnuminfo = M('publicnum')->save($data);
                         } else {
                             $weObj->access_token = $publicaccess['accesstoken'];
                             //$publicaccess['accesstoken']
                             $userinfodata = $weObj->getUserInfo($this->data['FromUserName']);
                         }
                     } else {
                         //_______根据appid和appsecret获取access_token
                         $userinfodata = $weObj->getUserInfo($this->data['FromUserName']);
                         $access_tokennow = $weObj->access_token;
                         $data['accesstoken'] = $access_tokennow;
                         $data['time'] = time();
                         $asdfsa = "asdf";
                         $where['token'] = $this->token;
                         $where['Id'] = $publicaccess['Id'];
                         $publicnuminfo = M('publicnum')->where($where)->save($data);
                     }
                     //_______根据openid和access_token获取用户信息
                     $fansinfo['nickname'] = $userinfodata['nickname'];
                     $fansinfo['fromusername'] = $this->data['FromUserName'];
                     $fansinfo['fake_id'] = "";
                     $fansinfo['sex'] = $userinfodata['sex'];
                     $fansinfo['country'] = $userinfodata['country'];
                     $fansinfo['province'] = $userinfodata['province'];
                     $fansinfo['city'] = $userinfodata['city'];
                     $fansinfo['token'] = $this->token;
                     //下载图片
                     if ($userinfodata['headimgurl'] != "") {
                         /* $headimgurlarr=explode('/',$userinfodata['headimgurl'],-1);
                         			$headimgurl=implode('/',$headimgurlarr)."/96";
                         			
                         			$filename="upload/".$this->data['FromUserName'].".jpg";
                         			if (is_readable($filename) == false) {
                         			$jpg = file_get_contents($headimgurl);
                         			$file = fopen($filename,"w");//打开文件准备写入
                         			fwrite($file,$jpg);//写入
                         			fclose($file);//关闭 
                         			} */
                         $fansinfo['img'] = $userinfodata['headimgurl'];
                     } else {
                         $fansinfo['img'] = "http://w.zd3.cn/Public/Images/default.jpg";
                     }
                     //下载图片
                     $fansadd = M('fans')->add($fansinfo);
                     $list = M('list');
                     $message['nickname'] = $userinfodata['nickname'];
                     if ($this->data['MsgType'] == "image") {
                         $PicUrl = $this->data['PicUrl'];
                         $message['content'] = '<img src="' . $PicUrl . '"/>';
                     } elseif ($this->data['MsgType'] == "text") {
                         $message['content'] = $this->data['Content'];
                     } else {
                         $message['content'] = '';
                     }
                     $message['time'] = $this->data['CreateTime'];
                     $message['examine'] = "0";
                     $message['choose'] = "0";
                     $message['token'] = $this->token;
                     $message['fromusername'] = $this->data['FromUserName'];
                     $message['fake_id'] = "";
                     $message['newsid'] = $this->data['MsgId'];
                     $message['sex'] = $userinfodata['sex'];
                     $message['imgurl'] = $userinfodata['headimgurl'];
                     //96
                     if ($userinfodata['headimgurl'] != "") {
                         //$message['img']="http://".$this->url."/".$filename;
                         $message['img'] = $userinfodata['headimgurl'];
                     } else {
                         //$message['img']="http://".$this->url."/Public/Images/default.jpg";
                         $message['img'] = $userinfodata['headimgurl'];
                     }
                     $list->add($message);
                     ////////////////////////////////////////////////////////////////////////////
                     return array(array(array('发送成功'), array('您发送的即将在大屏幕上滚动播出'), array('回复【返回】或者【后退】返回主菜单')), 'news');
                 }
             } else {
                 return array('微信墙功能以关闭', 'text');
             }
         } elseif ($statefansnow == 2) {
             if ($this->functionv == 1) {
                 $fanvote = M('fanvote');
                 $where['fromusername'] = $this->data['FromUserName'];
                 $state = $fanvote->where($where)->find();
                 if ($state) {
                     $project = M('project');
                     $projectinfo = $project->find($state['pid']);
                     return array(array(array('您已投票,每人一票'), array('您已把宝贵的一票投给了【' . $projectinfo['project'] . '】TA目前有【' . $projectinfo['num'] . '】票'), array('回复【返回】或者【后退】返回主菜单,回复【退出】即可退出该微信墙模式')), 'news');
                 } else {
                     $project = M('project');
                     $projectwhere['order'] = $this->data['Content'];
                     $projectinfo = $project->where($projectwhere)->find();
                     if (count($projectinfo) != "") {
                         $project->where('Id=' . $projectinfo['Id'])->setInc('num', 1);
                         $fanvote = M('fanvote');
                         $fans['time'] = $this->data['CreateTime'];
                         $fans['fromusername'] = $this->data['FromUserName'];
                         $fans['pid'] = $projectinfo['Id'];
                         $fanvote->add($fans);
                         $num = $projectinfo['num'] + 1;
                         return array(array(array('投票成功'), array('您成功的把宝贵的一票投给了【' . $projectinfo['project'] . '】TA目前有【' . $num . '】票'), array('回复【返回】或者【后退】返回主菜单,回复【退出】即可退出该微信墙模式')), 'news');
                     } else {
                         $tpxm1 = M('project')->select();
                         for ($i = 0; $i < count($tpxm1); $i++) {
                             $xmlist1[] = "\n【" . $i . "】" . $tpxm1[$i]['project'] . "                            票数" . $tpxm1[$i]['num'];
                         }
                         $xmlist2 = implode('', $xmlist1);
                         $xmlist = "请回复正确的序列号参与投票" . $xmlist2;
                         return array(array(array('系统投票每人只能投一票'), array($xmlist), array('请回复正确的序列号参与投票'), array('回复【返回】或者【后退】返回主菜单')), 'news');
                     }
                 }
             } else {
                 return array('微投票功能以关闭', 'text');
             }
         } else {
             switch ($key) {
                 //服务认证号自定义回复
                 case '1':
                     $statethree = M('state');
                     $statewhere['fromusername'] = $this->data['FromUserName'];
                     $statedata['state'] = "1";
                     $statethree->where($statewhere)->save($statedata);
                     if ($this->functionw == 1) {
                         return array(array(array('成功进入上墙模式回复消息既有机会上墙及参与抽奖'), array('回复【返回】或者【后退】返回主菜单')), 'news');
                     } else {
                         return array('微信墙功能已关闭', 'text');
                     }
                     break;
                 case '2':
                     if ($this->functionv == 1) {
                         $statethree = M('state');
                         $statewhere['fromusername'] = $this->data['FromUserName'];
                         $statedata['state'] = "2";
                         $statethree->where($statewhere)->save($statedata);
                         $tpxm1 = M('project')->select();
                         for ($i = 0; $i < count($tpxm1); $i++) {
                             $xmlist1[] = "\n【" . $i . "】" . $tpxm1[$i]['project'] . "                            票数" . $tpxm1[$i]['num'];
                         }
                         $xmlist2 = implode('', $xmlist1);
                         $xmlist = "请回复序列号参与投票" . $xmlist2;
                         return array(array(array('系统投票每人只能投一票'), array($xmlist), array('请回复序列号参与投票'), array('回复【返回】或者【后退】返回主菜单')), 'news');
                     } else {
                         return array('微投票功能已关闭', 'text');
                     }
                     break;
                 case '返回':
                 case '后退':
                     $statesecond = M('state');
                     $statewhere['fromusername'] = $this->data['FromUserName'];
                     $usernamenow = $statesecond->where($statewhere)->find();
                     if (count($usernamenow) > 0) {
                         $statedata['state'] = "0";
                         $statesecond->where($statewhere)->save($statedata);
                     } else {
                         $statedata['fromusername'] = $this->data['FromUserName'];
                         $statedata['state'] = "0";
                         $statesecond->add($statedata);
                     }
                     return array('成功退出微信墙', 'text');
                     break;
                 case '微信墙':
                 case 'wall':
                     $statesecond = M('state');
                     $statewhere['fromusername'] = $this->data['FromUserName'];
                     $usernamenow = $statesecond->where($statewhere)->find();
                     if (count($usernamenow) > 0) {
                         $statedata['state'] = "0";
                         $statesecond->where($statewhere)->save($statedata);
                     } else {
                         $statedata['fromusername'] = $this->data['FromUserName'];
                         $statedata['state'] = "0";
                         $statesecond->add($statedata);
                     }
                     return array(array(array('您好,欢迎使用微信墙功能', '', '', ''), array('回复【1】参与微信墙活动', '', '', ''), array('回复【2】参与投票', '', '', ''), array('回复【返回】或者【后退】返回主菜单', '', '', '')), 'news');
                     break;
                     /*case '法猫'://例子
                     		$statesecond=M('state');
                     		$statewhere['fromusername']=$this->data['FromUserName'];
                     		$usernamenow=$statesecond->where($statewhere)->find();
                     		if(count($usernamenow)>0){
                     			$statedata['state']="0";
                     			$statesecond->where($statewhere)->save($statedata);
                     		}else{
                     			$statedata['fromusername']=$this->data['FromUserName'];
                     			$statedata['state']="0";
                     			$statesecond->add($statedata);
                     		}
                     		
                     		return array(
                     			array(
                     				array(
                     					'男子吃凉皮误食罂粟壳粉 尿检呈阳性被拘【实时新闻】',//标题
                     					'实时新闻',//描述
                     					'http://mmbiz.qpic.cn/mmbiz/KjShzHibM8gwnRf59o8HMIxcEGPeGicDqWv7h8Mylrd2KBrmKXdkkI9gEg5humtiaH4Dz2RiaXylyk7yhvURdicj4sw/640',//图片
                     					'http://mp.weixin.qq.com/s?__biz=MzA4MTY4NzkzOQ==&mid=201082427&idx=2&sn=d084eface78eb41c037991912bdb1114#rd',//链接
                     				),
                     				array(
                     					'【“我帮您转到公安机关” 听到这个就是骗子!】【息息相关】',//this
                     					'息息相关',
                     					'http://mmbiz.qpic.cn/mmbiz/KjShzHibM8gwBkEibgjsBCTSsH9EujvF476QX3KIUVqYoxjR8ehL72YKsORGIF8lTeoIaZPAiaNyByNicGB1wcOgqQ/0',
                     					'http://mp.weixin.qq.com/s?__biz=MzA4MTY4NzkzOQ==&mid=201081199&idx=3&sn=fd8a7a396b4e0fb274394905506a56f1#rd',
                     				),
                     				array(
                     					'婚姻信息联网能防范骗婚重婚吗?【法律普及】',//标题
                     					'法律普及',//描述
                     					'http://mmbiz.qpic.cn/mmbiz/KjShzHibM8gwtSk00YfkAUk3iac3jSGicIJ8OtZoS5Eg1QMywzmtHaAGsiaKOgiaMXwrnvB9BLM5YHMHWGCLTh21BVA/0',//图片
                     					'http://mp.weixin.qq.com/s?__biz=MzA4MTY4NzkzOQ==&mid=201077549&idx=3&sn=9952d31c645e38c173bfbdcfef188712#rd',//链接
                     				),
                     				array(
                     					'秋天烦躁,多按虎口“合谷穴”【息息相关】',
                     					'息息相关',
                     					'http://mmbiz.qpic.cn/mmbiz/KjShzHibM8gz2icdPxYPFJjgWY7DPrRkpCOZ93icRzzia8weCibyCQfYYbicQvwVNrnYhVFDE7F2AAB4XGsIaAFeicDLA/0',
                     					'http://mp.weixin.qq.com/s?__biz=MzA4MTY4NzkzOQ==&mid=201066486&idx=1&sn=c5c85c3afee6d3bd3a7a1eb6355c0978#rd',
                     				),
                     				array(
                     					'【话筒有关刷牙的八个困惑】【息息相关】',
                     					'息息相关',
                     					'http://mmbiz.qpic.cn/mmbiz/KjShzHibM8gzJwRv1ICHaUg5DdDSOYTibEyuWj2XFVR5sg3oSeaskKjmL4BnPHh6m1lEaqyTwqqdiadnK1ohevsfA/640',
                     					'http://mp.weixin.qq.com/s?__biz=MzA4MTY4NzkzOQ==&mid=201071101&idx=2&sn=178d27bdde4701def008bef589c178cc#rd',
                     				),
                     			),
                     			'news'
                     		);
                     		break;*/
                 /*case '法猫'://例子
                 		$statesecond=M('state');
                 		$statewhere['fromusername']=$this->data['FromUserName'];
                 		$usernamenow=$statesecond->where($statewhere)->find();
                 		if(count($usernamenow)>0){
                 			$statedata['state']="0";
                 			$statesecond->where($statewhere)->save($statedata);
                 		}else{
                 			$statedata['fromusername']=$this->data['FromUserName'];
                 			$statedata['state']="0";
                 			$statesecond->add($statedata);
                 		}
                 		
                 		return array(
                 			array(
                 				array(
                 					'男子吃凉皮误食罂粟壳粉 尿检呈阳性被拘【实时新闻】',//标题
                 					'实时新闻',//描述
                 					'http://mmbiz.qpic.cn/mmbiz/KjShzHibM8gwnRf59o8HMIxcEGPeGicDqWv7h8Mylrd2KBrmKXdkkI9gEg5humtiaH4Dz2RiaXylyk7yhvURdicj4sw/640',//图片
                 					'http://mp.weixin.qq.com/s?__biz=MzA4MTY4NzkzOQ==&mid=201082427&idx=2&sn=d084eface78eb41c037991912bdb1114#rd',//链接
                 				),
                 				array(
                 					'【“我帮您转到公安机关” 听到这个就是骗子!】【息息相关】',//this
                 					'息息相关',
                 					'http://mmbiz.qpic.cn/mmbiz/KjShzHibM8gwBkEibgjsBCTSsH9EujvF476QX3KIUVqYoxjR8ehL72YKsORGIF8lTeoIaZPAiaNyByNicGB1wcOgqQ/0',
                 					'http://mp.weixin.qq.com/s?__biz=MzA4MTY4NzkzOQ==&mid=201081199&idx=3&sn=fd8a7a396b4e0fb274394905506a56f1#rd',
                 				),
                 				array(
                 					'婚姻信息联网能防范骗婚重婚吗?【法律普及】',//标题
                 					'法律普及',//描述
                 					'http://mmbiz.qpic.cn/mmbiz/KjShzHibM8gwtSk00YfkAUk3iac3jSGicIJ8OtZoS5Eg1QMywzmtHaAGsiaKOgiaMXwrnvB9BLM5YHMHWGCLTh21BVA/0',//图片
                 					'http://mp.weixin.qq.com/s?__biz=MzA4MTY4NzkzOQ==&mid=201077549&idx=3&sn=9952d31c645e38c173bfbdcfef188712#rd',//链接
                 				),
                 				array(
                 					'秋天烦躁,多按虎口“合谷穴”【息息相关】',
                 					'息息相关',
                 					'http://mmbiz.qpic.cn/mmbiz/KjShzHibM8gz2icdPxYPFJjgWY7DPrRkpCOZ93icRzzia8weCibyCQfYYbicQvwVNrnYhVFDE7F2AAB4XGsIaAFeicDLA/0',
                 					'http://mp.weixin.qq.com/s?__biz=MzA4MTY4NzkzOQ==&mid=201066486&idx=1&sn=c5c85c3afee6d3bd3a7a1eb6355c0978#rd',
                 				),
                 				array(
                 					'【话筒有关刷牙的八个困惑】【息息相关】',
                 					'息息相关',
                 					'http://mmbiz.qpic.cn/mmbiz/KjShzHibM8gzJwRv1ICHaUg5DdDSOYTibEyuWj2XFVR5sg3oSeaskKjmL4BnPHh6m1lEaqyTwqqdiadnK1ohevsfA/640',
                 					'http://mp.weixin.qq.com/s?__biz=MzA4MTY4NzkzOQ==&mid=201071101&idx=2&sn=178d27bdde4701def008bef589c178cc#rd',
                 				),
                 			),
                 			'news'
                 		);
                 		break;*/
                 default:
                     $tulingapi = M('tulingapi')->find();
                     $tuling_key = $tulingapi['apikey'];
                     $api_url = "http://www.tuling123.com/openapi/api?key=" . $tuling_key . "&info=" . $key;
                     $result = file_get_contents($api_url);
                     $result = json_decode($result, true);
                     if ($result['code'] == 100000) {
                         $statesecond = M('state');
                         $statewhere['fromusername'] = $this->data['FromUserName'];
                         $usernamenow = $statesecond->where($statewhere)->find();
                         if (count($usernamenow) > 0) {
                             $statedata['state'] = "0";
                             $statesecond->where($statewhere)->save($statedata);
                         } else {
                             $statedata['fromusername'] = $this->data['FromUserName'];
                             $statedata['state'] = "0";
                             $statesecond->add($statedata);
                         }
                         return array($result['text'], 'text');
                     } else {
                         if ($result['code'] == 200000) {
                             $statesecond = M('state');
                             $statewhere['fromusername'] = $this->data['FromUserName'];
                             $usernamenow = $statesecond->where($statewhere)->find();
                             if (count($usernamenow) > 0) {
                                 $statedata['state'] = "0";
                                 $statesecond->where($statewhere)->save($statedata);
                             } else {
                                 $statedata['fromusername'] = $this->data['FromUserName'];
                                 $statedata['state'] = "0";
                                 $statesecond->add($statedata);
                             }
                             $text = $result['text'] . ',<a href="' . $result['url'] . '">点击进入</a>';
                             return array($text, 'text');
                         } else {
                             if ($result['code'] == 302000) {
                                 $statesecond = M('state');
                                 $statewhere['fromusername'] = $this->data['FromUserName'];
                                 $usernamenow = $statesecond->where($statewhere)->find();
                                 if (count($usernamenow) > 0) {
                                     $statedata['state'] = "0";
                                     $statesecond->where($statewhere)->save($statedata);
                                 } else {
                                     $statedata['fromusername'] = $this->data['FromUserName'];
                                     $statedata['state'] = "0";
                                     $statesecond->add($statedata);
                                 }
                                 return array(array(array($result['list'][0]['article'], $result['list'][0]['source'], $result['list'][0]['icon'], $result['list'][0]['detailurl']), array($result['list'][1]['article'], $result['list'][1]['source'], $result['list'][1]['icon'], $result['list'][1]['detailurl']), array($result['list'][2]['article'], $result['list'][2]['source'], $result['list'][2]['icon'], $result['list'][2]['detailurl']), array($result['list'][3]['article'], $result['list'][3]['source'], $result['list'][3]['icon'], $result['list'][3]['detailurl']), array($result['list'][4]['article'], $result['list'][4]['source'], $result['list'][4]['icon'], $result['list'][4]['detailurl']), array($result['list'][5]['article'], $result['list'][5]['source'], $result['list'][5]['icon'], $result['list'][5]['detailurl']), array($result['list'][6]['article'], $result['list'][6]['source'], $result['list'][6]['icon'], $result['list'][6]['detailurl']), array($result['list'][7]['article'], $result['list'][7]['source'], $result['list'][7]['icon'], $result['list'][7]['detailurl']), array($result['list'][8]['article'], $result['list'][8]['source'], $result['list'][8]['icon'], $result['list'][8]['detailurl']), array($result['list'][9]['article'], $result['list'][9]['source'], $result['list'][9]['icon'], $result['list'][9]['detailurl'])), 'news');
                             } else {
                                 if ($result['code'] == 304000) {
                                     $statesecond = M('state');
                                     $statewhere['fromusername'] = $this->data['FromUserName'];
                                     $usernamenow = $statesecond->where($statewhere)->find();
                                     if (count($usernamenow) > 0) {
                                         $statedata['state'] = "0";
                                         $statesecond->where($statewhere)->save($statedata);
                                     } else {
                                         $statedata['fromusername'] = $this->data['FromUserName'];
                                         $statedata['state'] = "0";
                                         $statesecond->add($statedata);
                                     }
                                     return array(array(array($result['list'][0]['name'], $result['list'][0]['count'], $result['list'][0]['icon'], $result['list'][0]['detailurl']), array($result['list'][1]['name'], $result['list'][1]['count'], $result['list'][1]['icon'], $result['list'][1]['detailurl']), array($result['list'][2]['name'], $result['list'][2]['count'], $result['list'][2]['icon'], $result['list'][2]['detailurl']), array($result['list'][3]['name'], $result['list'][3]['count'], $result['list'][3]['icon'], $result['list'][3]['detailurl']), array($result['list'][4]['name'], $result['list'][4]['count'], $result['list'][4]['icon'], $result['list'][4]['detailurl']), array($result['list'][5]['name'], $result['list'][5]['count'], $result['list'][5]['icon'], $result['list'][5]['detailurl']), array($result['list'][6]['name'], $result['list'][6]['count'], $result['list'][6]['icon'], $result['list'][6]['detailurl']), array($result['list'][7]['name'], $result['list'][7]['count'], $result['list'][7]['icon'], $result['list'][7]['detailurl']), array($result['list'][8]['name'], $result['list'][8]['count'], $result['list'][8]['icon'], $result['list'][8]['detailurl']), array($result['list'][9]['name'], $result['list'][9]['count'], $result['list'][9]['icon'], $result['list'][9]['detailurl'])), 'news');
                                 } else {
                                     if ($result['code'] == 305000) {
                                         $statesecond = M('state');
                                         $statewhere['fromusername'] = $this->data['FromUserName'];
                                         $usernamenow = $statesecond->where($statewhere)->find();
                                         if (count($usernamenow) > 0) {
                                             $statedata['state'] = "0";
                                             $statesecond->where($statewhere)->save($statedata);
                                         } else {
                                             $statedata['fromusername'] = $this->data['FromUserName'];
                                             $statedata['state'] = "0";
                                             $statesecond->add($statedata);
                                         }
                                         return array(array(array($result['list'][0]['start'] . '--' . $result['list'][0]['terminal'], $result['list'][0]['starttime'] . '--' . $result['list'][0]['endtime'], $result['list'][0]['icon'], $result['list'][0]['detailurl']), array($result['list'][1]['start'] . '--' . $result['list'][1]['terminal'], $result['list'][1]['starttime'] . '--' . $result['list'][1]['endtime'], $result['list'][1]['icon'], $result['list'][1]['detailurl']), array($result['list'][2]['start'] . '--' . $result['list'][2]['terminal'], $result['list'][2]['starttime'] . '--' . $result['list'][2]['endtime'], $result['list'][2]['icon'], $result['list'][2]['detailurl']), array($result['list'][3]['start'] . '--' . $result['list'][3]['terminal'], $result['list'][3]['starttime'] . '--' . $result['list'][3]['endtime'], $result['list'][3]['icon'], $result['list'][3]['detailurl']), array($result['list'][4]['start'] . '--' . $result['list'][4]['terminal'], $result['list'][4]['starttime'] . '--' . $result['list'][4]['endtime'], $result['list'][4]['icon'], $result['list'][4]['detailurl']), array($result['list'][5]['start'] . '--' . $result['list'][5]['terminal'], $result['list'][5]['starttime'] . '--' . $result['list'][5]['endtime'], $result['list'][5]['icon'], $result['list'][5]['detailurl']), array($result['list'][6]['start'] . '--' . $result['list'][6]['terminal'], $result['list'][6]['starttime'] . '--' . $result['list'][6]['endtime'], $result['list'][6]['icon'], $result['list'][6]['detailurl']), array($result['list'][7]['start'] . '--' . $result['list'][7]['terminal'], $result['list'][7]['starttime'] . '--' . $result['list'][7]['endtime'], $result['list'][7]['icon'], $result['list'][7]['detailurl']), array($result['list'][8]['start'] . '--' . $result['list'][8]['terminal'], $result['list'][8]['starttime'] . '--' . $result['list'][8]['endtime'], $result['list'][8]['icon'], $result['list'][8]['detailurl']), array($result['list'][9]['start'] . '--' . $result['list'][9]['terminal'], $result['list'][9]['starttime'] . '--' . $result['list'][9]['endtime'], $result['list'][9]['icon'], $result['list'][9]['detailurl'])), 'news');
                                     } else {
                                         if ($result['code'] == 306000) {
                                             $statesecond = M('state');
                                             $statewhere['fromusername'] = $this->data['FromUserName'];
                                             $usernamenow = $statesecond->where($statewhere)->find();
                                             if (count($usernamenow) > 0) {
                                                 $statedata['state'] = "0";
                                                 $statesecond->where($statewhere)->save($statedata);
                                             } else {
                                                 $statedata['fromusername'] = $this->data['FromUserName'];
                                                 $statedata['state'] = "0";
                                                 $statesecond->add($statedata);
                                             }
                                             return array(array(array($result['list'][0]['flight'] . '--' . $result['list'][0]['route'], $result['list'][0]['starttime'] . '--' . $result['list'][0]['endtime'], $result['list'][0]['icon'], $result['list'][0]['detailurl']), array($result['list'][1]['flight'] . '--' . $result['list'][1]['route'], $result['list'][1]['starttime'] . '--' . $result['list'][1]['endtime'], $result['list'][1]['icon'], $result['list'][1]['detailurl']), array($result['list'][2]['flight'] . '--' . $result['list'][2]['route'], $result['list'][2]['starttime'] . '--' . $result['list'][2]['endtime'], $result['list'][2]['icon'], $result['list'][2]['detailurl']), array($result['list'][3]['flight'] . '--' . $result['list'][3]['route'], $result['list'][3]['starttime'] . '--' . $result['list'][3]['endtime'], $result['list'][3]['icon'], $result['list'][3]['detailurl']), array($result['list'][4]['flight'] . '--' . $result['list'][4]['route'], $result['list'][4]['starttime'] . '--' . $result['list'][4]['endtime'], $result['list'][4]['icon'], $result['list'][4]['detailurl']), array($result['list'][5]['flight'] . '--' . $result['list'][5]['route'], $result['list'][5]['starttime'] . '--' . $result['list'][5]['endtime'], $result['list'][5]['icon'], $result['list'][5]['detailurl']), array($result['list'][6]['flight'] . '--' . $result['list'][6]['route'], $result['list'][6]['starttime'] . '--' . $result['list'][6]['endtime'], $result['list'][6]['icon'], $result['list'][6]['detailurl']), array($result['list'][7]['flight'] . '--' . $result['list'][7]['route'], $result['list'][7]['starttime'] . '--' . $result['list'][7]['endtime'], $result['list'][7]['icon'], $result['list'][7]['detailurl']), array($result['list'][8]['flight'] . '--' . $result['list'][8]['route'], $result['list'][8]['starttime'] . '--' . $result['list'][8]['endtime'], $result['list'][8]['icon'], $result['list'][8]['detailurl']), array($result['list'][9]['flight'] . '--' . $result['list'][9]['route'], $result['list'][9]['starttime'] . '--' . $result['list'][9]['endtime'], $result['list'][9]['icon'], $result['list'][9]['detailurl'])), 'news');
                                         } else {
                                             if ($result['code'] == 308000) {
                                                 $statesecond = M('state');
                                                 $statewhere['fromusername'] = $this->data['FromUserName'];
                                                 $usernamenow = $statesecond->where($statewhere)->find();
                                                 if (info($usernamenow) > 0) {
                                                     $statedata['state'] = "0";
                                                     $statesecond->where($statewhere)->save($statedata);
                                                 } else {
                                                     $statedata['fromusername'] = $this->data['FromUserName'];
                                                     $statedata['state'] = "0";
                                                     $statesecond->add($statedata);
                                                 }
                                                 return array(array(array($result['list'][0]['name'], $result['list'][0]['info'], $result['list'][0]['icon'], $result['list'][0]['detailurl']), array($result['list'][1]['name'], $result['list'][1]['info'], $result['list'][1]['icon'], $result['list'][1]['detailurl']), array($result['list'][2]['name'], $result['list'][2]['info'], $result['list'][2]['icon'], $result['list'][2]['detailurl']), array($result['list'][3]['name'], $result['list'][3]['info'], $result['list'][3]['icon'], $result['list'][3]['detailurl']), array($result['list'][4]['name'], $result['list'][4]['info'], $result['list'][4]['icon'], $result['list'][4]['detailurl']), array($result['list'][5]['name'], $result['list'][5]['info'], $result['list'][5]['icon'], $result['list'][5]['detailurl']), array($result['list'][6]['name'], $result['list'][6]['info'], $result['list'][6]['icon'], $result['list'][6]['detailurl']), array($result['list'][7]['name'], $result['list'][7]['info'], $result['list'][7]['icon'], $result['list'][7]['detailurl']), array($result['list'][8]['name'], $result['list'][8]['info'], $result['list'][8]['icon'], $result['list'][8]['detailurl']), array($result['list'][9]['name'], $result['list'][9]['info'], $result['list'][9]['icon'], $result['list'][9]['detailurl'])), 'news');
                                             } else {
                                                 if ($result['code'] == 309000) {
                                                     $statesecond = M('state');
                                                     $statewhere['fromusername'] = $this->data['FromUserName'];
                                                     $usernamenow = $statesecond->where($statewhere)->find();
                                                     if (count($usernamenow) > 0) {
                                                         $statedata['state'] = "0";
                                                         $statesecond->where($statewhere)->save($statedata);
                                                     } else {
                                                         $statedata['fromusername'] = $this->data['FromUserName'];
                                                         $statedata['state'] = "0";
                                                         $statesecond->add($statedata);
                                                     }
                                                     return array(array(array($result['list'][0]['name'], '价格 : ' . $result['list'][0]['price'] . ' 满意度 : ' . $result['list'][0]['satisfaction'], $result['list'][0]['icon'], $result['list'][0]['detailurl']), array($result['list'][1]['name'], '价格 : ' . $result['list'][1]['price'] . ' 满意度 : ' . $result['list'][1]['satisfaction'], $result['list'][1]['icon'], $result['list'][1]['detailurl']), array($result['list'][2]['name'], '价格 : ' . $result['list'][2]['price'] . ' 满意度 : ' . $result['list'][2]['satisfaction'], $result['list'][2]['icon'], $result['list'][2]['detailurl']), array($result['list'][3]['name'], '价格 : ' . $result['list'][3]['price'] . ' 满意度 : ' . $result['list'][3]['satisfaction'], $result['list'][3]['icon'], $result['list'][3]['detailurl']), array($result['list'][4]['name'], '价格 : ' . $result['list'][4]['price'] . ' 满意度 : ' . $result['list'][4]['satisfaction'], $result['list'][4]['icon'], $result['list'][4]['detailurl']), array($result['list'][5]['name'], '价格 : ' . $result['list'][5]['price'] . ' 满意度 : ' . $result['list'][5]['satisfaction'], $result['list'][5]['icon'], $result['list'][5]['detailurl']), array($result['list'][6]['name'], '价格 : ' . $result['list'][6]['price'] . ' 满意度 : ' . $result['list'][6]['satisfaction'], $result['list'][6]['icon'], $result['list'][6]['detailurl']), array($result['list'][7]['name'], '价格 : ' . $result['list'][7]['price'] . ' 满意度 : ' . $result['list'][7]['satisfaction'], $result['list'][7]['icon'], $result['list'][7]['detailurl']), array($result['list'][8]['name'], '价格 : ' . $result['list'][8]['price'] . ' 满意度 : ' . $result['list'][8]['satisfaction'], $result['list'][8]['icon'], $result['list'][8]['detailurl']), array($result['list'][9]['name'], '价格 : ' . $result['list'][9]['price'] . ' 满意度 : ' . $result['list'][9]['satisfaction'], $result['list'][9]['icon'], $result['list'][9]['detailurl'])), 'news');
                                                 } else {
                                                     if ($result['code'] == 311000 || $result['code'] == 312000) {
                                                         $statesecond = M('state');
                                                         $statewhere['fromusername'] = $this->data['FromUserName'];
                                                         $usernamenow = $statesecond->where($statewhere)->find();
                                                         if (count($usernamenow) > 0) {
                                                             $statedata['state'] = "0";
                                                             $statesecond->where($statewhere)->save($statedata);
                                                         } else {
                                                             $statedata['fromusername'] = $this->data['FromUserName'];
                                                             $statedata['state'] = "0";
                                                             $statesecond->add($statedata);
                                                         }
                                                         return array(array(array($result['list'][0]['name'], '价格 : ' . $result['list'][0]['price'], $result['list'][0]['icon'], $result['list'][0]['detailurl']), array($result['list'][1]['name'], '价格 : ' . $result['list'][1]['price'], $result['list'][1]['icon'], $result['list'][1]['detailurl']), array($result['list'][2]['name'], '价格 : ' . $result['list'][2]['price'], $result['list'][2]['icon'], $result['list'][2]['detailurl']), array($result['list'][3]['name'], '价格 : ' . $result['list'][3]['price'], $result['list'][3]['icon'], $result['list'][3]['detailurl']), array($result['list'][4]['name'], '价格 : ' . $result['list'][4]['price'], $result['list'][4]['icon'], $result['list'][4]['detailurl']), array($result['list'][5]['name'], '价格 : ' . $result['list'][5]['price'], $result['list'][5]['icon'], $result['list'][5]['detailurl']), array($result['list'][6]['name'], '价格 : ' . $result['list'][6]['price'], $result['list'][6]['icon'], $result['list'][6]['detailurl']), array($result['list'][7]['name'], '价格 : ' . $result['list'][7]['price'], $result['list'][7]['icon'], $result['list'][7]['detailurl']), array($result['list'][8]['name'], '价格 : ' . $result['list'][8]['price'], $result['list'][8]['icon'], $result['list'][8]['detailurl']), array($result['list'][9]['name'], '价格 : ' . $result['list'][9]['price'], $result['list'][9]['icon'], $result['list'][9]['detailurl'])), 'news');
                                                     } else {
                                                         $statesecond = M('state');
                                                         $statewhere['fromusername'] = $this->data['FromUserName'];
                                                         $usernamenow = $statesecond->where($statewhere)->find();
                                                         if (count($usernamenow) > 0) {
                                                             $statedata['state'] = "0";
                                                             $statesecond->where($statewhere)->save($statedata);
                                                         } else {
                                                             $statedata['fromusername'] = $this->data['FromUserName'];
                                                             $statedata['state'] = "0";
                                                             $statesecond->add($statedata);
                                                         }
                                                         return array('你说的我听不懂$_$', 'text');
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
             }
         }
     } else {
         ////////////////////////////////////plan///////////////////////////////////////////////
         if ($statefansnow == 1) {
             if ($this->functionw == 1) {
                 $fans = M('fans');
                 $where['fromusername'] = $this->data['FromUserName'];
                 $fansinfo = $fans->where($where)->find();
                 if ($fansinfo) {
                     $message['img'] = $fansinfo['img'];
                     $list = M('list');
                     $message['nickname'] = $fansinfo['nickname'];
                     $message['content'] = $this->data['Content'];
                     $message['time'] = $this->data['CreateTime'];
                     $message['examine'] = "0";
                     $message['choose'] = "0";
                     $message['fromusername'] = $this->data['FromUserName'];
                     $message['fake_id'] = $fansinfo['fake_id'];
                     $message['newsid'] = $this->data['MsgId'];
                     $message['sex'] = $fansinfo['sex'];
                     $list->add($message);
                     return array(array(array('发送成功'), array('您发送的留言即将在大屏幕上滚动播出'), array('回复【返回】或者【后退】返回主菜单')), 'news');
                 } else {
                     ///////////////////////////////plan/////////////////////////////////////////////
                     vendor('mndl.wechatext#class');
                     function logdebug($text)
                     {
                         file_put_contents('log.txt', $text . "\n", FILE_APPEND);
                     }
                     $options = array('account' => $this->username, 'password' => $this->password, 'datapath' => 'ookie_', 'debug' => true, 'logcallback' => 'logdebug');
                     $wechat = new Wechatext($options);
                     if ($wechat->checkValid()) {
                         $userdata = $wechat->getTopMsg();
                         $date_time_hf = $userdata['date_time'];
                         $content_hf = $userdata['content'];
                         /////////////////////////////////////
                         if ($date_time_hf == $this->data['CreateTime'] && $content_hf == $this->data['Content']) {
                             $whereinfo['fromusername'] = $this->data['FromUserName'];
                             $fansinfo = M('fans')->where($whereinfo)->find();
                             if (count($fansinfo) > 0) {
                                 $data_wxq['nickname'] = $userdata['nick_name'];
                                 $data_wxq['content'] = $userdata['content'];
                                 $data_wxq['newsid'] = $userdata['id'];
                                 $data_wxq['time'] = $msglist[$i]['date_time'];
                                 $data_wxq['examine'] = "0";
                                 $data_wxq['choose'] = "0";
                                 $data_wxq['fake_id'] = $userdata['fakeid'];
                                 $data_wxq['fromusername'] = $this->data['FromUserName'];
                                 $data_wxq['img'] = $fansinfo['img'];
                                 M('list')->add($data_wxq);
                                 return array(array(array('发送成功'), array('你已经成功发送等待审核即可上墙了'), array('回复【返回】或者【后退】返回主菜单')), 'news');
                             } else {
                                 $data_wxq['nickname'] = $userdata['nick_name'];
                                 $data_wxq['fake_id'] = $userdata['fakeid'];
                                 $data_wxq['fromusername'] = $this->data['FromUserName'];
                                 $headingimg = $wechat->getInfo2($data_wxq['fake_id']);
                                 if (is_readable($filename) == false) {
                                     $dataaa = $headingimg['body'];
                                     $filename = "upload/" . $this->data['FromUserName'] . ".jpg";
                                     $jpg = $dataaa;
                                     $file = fopen($filename, "w");
                                     //打开文件准备写入
                                     fwrite($file, $jpg);
                                     //写入
                                     fclose($file);
                                     //关闭
                                 }
                                 $data_wxq['img'] = "http://" . $this->url . "/" . $filename;
                                 M('fans')->add($data_wxq);
                                 $data_wxq1['nickname'] = $userdata['nick_name'];
                                 $data_wxq1['content'] = $userdata['content'];
                                 $data_wxq1['newsid'] = $userdata['id'];
                                 $data_wxq1['time'] = $userdata['date_time'];
                                 $data_wxq1['examine'] = "0";
                                 $data_wxq1['choose'] = "0";
                                 $data_wxq1['fake_id'] = $userdata['fakeid'];
                                 $data_wxq1['fromusername'] = $this->data['FromUserName'];
                                 $data_wxq1['img'] = "http://" . $this->url . "/" . $filename;
                                 M('list')->add($data_wxq1);
                                 return array(array(array('发送成功'), array('你已经成功发送等待审核即可上墙了'), array('回复【返回】或者【后退】返回主菜单')), 'news');
                             }
                         } else {
                             /////////////////////////////////////////////////////////////////////////////
                             $wherefans['fromusername'] = $this->data['FromUserName'];
                             $wherefans['newsid'] = array('neq', '');
                             $first = M('list')->where($wherefans)->order('id DESC')->find();
                             if (!empty($first['newsid'])) {
                                 $num = $wechat->getNewMsgNum($first['newsid']);
                                 $msglist = $wechat->getMsg($userdata['id'], 0, $num, 0, 0, 0);
                                 for ($i = 0; $i < $num; $i++) {
                                     $wxq_time[$i] = $msglist[$i]['date_time'];
                                     $wxq_content[$i] = $msglist[$i]['content'];
                                     if ($wxq_time[$i] == $this->data['CreateTime'] && $wxq_content[$i] == $this->data['Content']) {
                                         $wherefansif['fromusername'] = $this->data['FromUserName'];
                                         $fansinfo = M('fans')->where($wherefansif)->find();
                                         if (count($fansinfo) > 0) {
                                             $data_wxq['nickname'] = $msglist[$i]['nick_name'];
                                             $data_wxq['content'] = $msglist[$i]['content'];
                                             $data_wxq['newsid'] = $msglist[$i]['id'];
                                             $data_wxq['time'] = $msglist[$i]['date_time'];
                                             $data_wxq['examine'] = "0";
                                             $data_wxq['choose'] = "0";
                                             $data_wxq['fake_id'] = $msglist[$i]['fakeid'];
                                             $data_wxq['fromusername'] = $this->data['FromUserName'];
                                             $data_wxq['img'] = $fansinfo['img'];
                                             M('list')->add($data_wxq);
                                         } else {
                                             $data_wxq['nickname'] = $msglist[$i]['nick_name'];
                                             $data_wxq['fake_id'] = $msglist[$i]['fakeid'];
                                             $data_wxq['fromusername'] = $this->data['FromUserName'];
                                             $filename = "upload/" . $this->data['FromUserName'] . ".jpg";
                                             if (is_readable($filename) == false) {
                                                 $headingimg = $wechat->getInfo2($data_wxq['fake_id']);
                                                 $dataaa = $headingimg['body'];
                                                 $jpg = $dataaa;
                                                 $file = fopen($filename, "w");
                                                 //打开文件准备写入
                                                 fwrite($file, $jpg);
                                                 //写入
                                                 fclose($file);
                                                 //关闭
                                             }
                                             $data_wxq['img'] = "http://" . $this->url . "/" . $filename;
                                             M('fans')->add($data_wxq);
                                             $data_wxq1['nickname'] = $msglist[$i]['nick_name'];
                                             $data_wxq1['content'] = $msglist[$i]['content'];
                                             $data_wxq1['newsid'] = $msglist[$i]['id'];
                                             $data_wxq1['time'] = $msglist[$i]['date_time'];
                                             $data_wxq1['examine'] = "0";
                                             $data_wxq1['choose'] = "0";
                                             $data_wxq1['fake_id'] = $msglist[$i]['fakeid'];
                                             $data_wxq1['fromusername'] = $this->data['FromUserName'];
                                             $data_wxq1['img'] = $fansinfo['img'];
                                             M('list')->add($data_wxq1);
                                         }
                                         return array(array(array('发送成功'), array('你已经成功发送等待审核即可上墙了'), array('回复【返回】或者【后退】返回主菜单')), 'news');
                                     }
                                 }
                             } else {
                                 $msglistzt = $wechat->getMsg(0, 0, 1, 1, 0, 0);
                                 $num = $wechat->getNewMsgNum($msglistzt[0]['date_time']);
                                 $msglist = $wechat->getMsg($userdata['id'], 0, $num, 0, 0, 0);
                                 for ($i = 0; $i < count($msglist); $i++) {
                                     $wxq_time[$i] = $msglist[$i]['date_time'];
                                     $wxq_content[$i] = $msglist[$i]['content'];
                                     if ($wxq_time[$i] == $this->data['CreateTime'] && $wxq_content[$i] == $this->data['Content']) {
                                         $wherefansif['fromusername'] = $this->data['FromUserName'];
                                         $fansinfo = M('fans')->where($wherefansif)->find();
                                         if (count($fansinfo) > 0) {
                                             $data_wxq['nickname'] = $msglist[$i]['nick_name'];
                                             $data_wxq['content'] = $msglist[$i]['content'];
                                             $data_wxq['newsid'] = $msglist[$i]['id'];
                                             $data_wxq['time'] = $msglist[$i]['date_time'];
                                             $data_wxq['examine'] = "0";
                                             $data_wxq['choose'] = "0";
                                             $data_wxq['fake_id'] = $msglist[$i]['fakeid'];
                                             $data_wxq['fromusername'] = $this->data['FromUserName'];
                                             $data_wxq['img'] = $fansinfo['img'];
                                             M('list')->add($data_wxq);
                                         } else {
                                             $data_wxq['nickname'] = $msglist[$i]['nick_name'];
                                             $data_wxq['fake_id'] = $msglist[$i]['fakeid'];
                                             $data_wxq['fromusername'] = $this->data['FromUserName'];
                                             $filename = "upload/" . $this->data['FromUserName'] . ".jpg";
                                             if (is_readable($filename) == false) {
                                                 $headingimg = $wechat->getInfo2($data_wxq['fake_id']);
                                                 $dataaa = $headingimg['body'];
                                                 $jpg = $dataaa;
                                                 $file = fopen($filename, "w");
                                                 //打开文件准备写入
                                                 fwrite($file, $jpg);
                                                 //写入
                                                 fclose($file);
                                                 //关闭
                                             }
                                             $data_wxq['img'] = "http://" . $this->url . "/" . $filename;
                                             M('fans')->add($data_wxq);
                                             $data_wxq1['nickname'] = $msglist[$i]['nick_name'];
                                             $data_wxq1['nickname'] = $msglist[$i]['nick_name'];
                                             $data_wxq1['content'] = $msglist[$i]['content'];
                                             $data_wxq1['newsid'] = $msglist[$i]['id'];
                                             $data_wxq1['time'] = $msglist[$i]['date_time'];
                                             $data_wxq1['examine'] = "0";
                                             $data_wxq1['choose'] = "0";
                                             $data_wxq1['fake_id'] = $msglist[$i]['fakeid'];
                                             $data_wxq1['fromusername'] = $this->data['FromUserName'];
                                             $data_wxq1['img'] = $fansinfo['img'];
                                             M('list')->add($data_wxq1);
                                         }
                                         return array(array(array('发送成功'), array('你已经成功发送等待审核即可上墙了804'), array('回复【返回】或者【后退】返回主菜单,回复【退出】即可退出该微信墙模式')), 'news');
                                     }
                                 }
                             }
                             // //////////////////////////////////////////////////////////////////////////////////
                         }
                         ////////////////////////////////////
                     } else {
                         return array(array(array('发送失败请重新发送'), array('回复【返回】或者【后退】返回主菜单,回复【退出】即可退出该微信墙模式')), 'news');
                     }
                     ///////////////////////////////plan/////////////////////////////////////////////
                 }
             } else {
                 return array('微信墙功能以关闭', 'text');
             }
         } elseif ($statefansnow == 2) {
             if ($this->functionv == 1) {
                 $fanvote = M('fanvote');
                 $where['fromusername'] = $this->data['FromUserName'];
                 $state = $fanvote->where($where)->find();
                 if ($state) {
                     $project = M('project');
                     $projectinfo = $project->find($state['pid']);
                     return array(array(array('您已投票,每人一票'), array('您已把宝贵的一票投给了【' . $projectinfo['project'] . '】TA目前有【' . $projectinfo['num'] . '】票'), array('回复【返回】或者【后退】返回主菜单,回复【退出】即可退出该微信墙模式')), 'news');
                 } else {
                     $project = M('project');
                     $projectwhere['order'] = $this->data['Content'];
                     $projectinfo = $project->where($projectwhere)->find();
                     if (count($projectinfo) != "") {
                         $project->where('Id=' . $projectinfo['Id'])->setInc('num', 1);
                         $fanvote = M('fanvote');
                         $fans['time'] = $this->data['CreateTime'];
                         $fans['fromusername'] = $this->data['FromUserName'];
                         $fans['pid'] = $projectinfo['Id'];
                         $fanvote->add($fans);
                         $num = $projectinfo['num'] + 1;
                         return array(array(array('投票成功'), array('您成功的把宝贵的一票投给了【' . $projectinfo['project'] . '】TA目前有【' . $num . '】票'), array('回复【返回】或者【后退】返回主菜单,回复【退出】即可退出该微信墙模式')), 'news');
                     } else {
                         $tpxm1 = M('project')->select();
                         for ($i = 0; $i < count($tpxm1); $i++) {
                             $xmlist1[] = "\n【" . $i . "】" . $tpxm1[$i]['project'] . "                            票数" . $tpxm1[$i]['num'];
                         }
                         $xmlist2 = implode('', $xmlist1);
                         $xmlist = "请回复正确的序列号参与投票" . $xmlist2;
                         return array(array(array('系统投票每人只能投一票'), array($xmlist), array('请回复正确的序列号参与投票'), array('回复【返回】或者【后退】返回主菜单')), 'news');
                     }
                 }
             } else {
                 return array('微投票功能以关闭', 'text');
             }
         } else {
             switch ($key) {
                 //订阅号自定义回复
                 case '1':
                     $state = M('state');
                     $statewhere['fromusername'] = $this->data['FromUserName'];
                     $statedata['state'] = "1";
                     $state->where($statewhere)->save($statedata);
                     if ($this->functionw == 1) {
                         return array(array(array('成功进入上墙模式回复消息既有机会上墙及参与抽奖'), array('回复【返回】或者【后退】返回主菜单')), 'news');
                     } else {
                         return array('微信墙功能已关闭', 'text');
                     }
                     break;
                 case '2':
                     if ($this->functionv == 1) {
                         $state = M('state');
                         $statewhere['fromusername'] = $this->data['FromUserName'];
                         $statedata['state'] = "2";
                         $state->where($statewhere)->save($statedata);
                         $tpxm1 = M('project')->select();
                         for ($i = 0; $i < count($tpxm1); $i++) {
                             $xmlist1[] = "\n【" . $i . "】" . $tpxm1[$i]['project'] . "                            票数" . $tpxm1[$i]['num'];
                         }
                         $xmlist2 = implode('', $xmlist1);
                         $xmlist = "请回复序列号参与投票" . $xmlist2;
                         return array(array(array('系统投票每人只能投一票'), array($xmlist), array('请回复序列号参与投票'), array('回复【返回】或者【后退】返回主菜单')), 'news');
                     } else {
                         return array('微投票功能已关闭', 'text');
                     }
                     break;
                 case '返回':
                 case '后退':
                     $statesecond = M('state');
                     $statewhere['fromusername'] = $this->data['FromUserName'];
                     $usernamenow = $statesecond->where($statewhere)->find();
                     if (count($usernamenow) > 0) {
                         $statedata['state'] = "0";
                         $statesecond->where($statewhere)->save($statedata);
                     } else {
                         $statedata['fromusername'] = $this->data['FromUserName'];
                         $statedata['state'] = "0";
                         $statesecond->add($statedata);
                     }
                     return array('成功退出微信墙', 'text');
                     break;
                 case '微信墙':
                     $statesecond = M('state');
                     $statewhere['fromusername'] = $this->data['FromUserName'];
                     $usernamenow = $statesecond->where($statewhere)->find();
                     if (count($usernamenow) > 0) {
                         $statedata['state'] = "0";
                         $statesecond->where($statewhere)->save($statedata);
                     } else {
                         $statedata['fromusername'] = $this->data['FromUserName'];
                         $statedata['state'] = "0";
                         $statesecond->add($statedata);
                     }
                     return array(array(array('您好,欢迎使用微信墙', '', '', ''), array('回复【1】参与微信墙活动', '', '', ''), array('回复【2】参与投票', '', '', '')), 'news');
                     break;
                 default:
                     $tulingapi = M('tulingapi')->find();
                     $tuling_key = $tulingapi['apikey'];
                     $api_url = "http://www.tuling123.com/openapi/api?key=" . $tuling_key . "&info=" . $key;
                     $result = file_get_contents($api_url);
                     $result = json_decode($result, true);
                     if ($result['code'] == 100000) {
                         $statesecond = M('state');
                         $statewhere['fromusername'] = $this->data['FromUserName'];
                         $usernamenow = $statesecond->where($statewhere)->find();
                         if (count($usernamenow) > 0) {
                             $statedata['state'] = "0";
                             $statesecond->where($statewhere)->save($statedata);
                         } else {
                             $statedata['fromusername'] = $this->data['FromUserName'];
                             $statedata['state'] = "0";
                             $statesecond->add($statedata);
                         }
                         return array($result['text'], 'text');
                     } else {
                         if ($result['code'] == 200000) {
                             $statesecond = M('state');
                             $statewhere['fromusername'] = $this->data['FromUserName'];
                             $usernamenow = $statesecond->where($statewhere)->find();
                             if (count($usernamenow) > 0) {
                                 $statedata['state'] = "0";
                                 $statesecond->where($statewhere)->save($statedata);
                             } else {
                                 $statedata['fromusername'] = $this->data['FromUserName'];
                                 $statedata['state'] = "0";
                                 $statesecond->add($statedata);
                             }
                             $text = $result['text'] . ',<a href="' . $result['url'] . '">点击进入</a>';
                             return array($text, 'text');
                         } else {
                             if ($result['code'] == 302000) {
                                 $statesecond = M('state');
                                 $statewhere['fromusername'] = $this->data['FromUserName'];
                                 $usernamenow = $statesecond->where($statewhere)->find();
                                 if (count($usernamenow) > 0) {
                                     $statedata['state'] = "0";
                                     $statesecond->where($statewhere)->save($statedata);
                                 } else {
                                     $statedata['fromusername'] = $this->data['FromUserName'];
                                     $statedata['state'] = "0";
                                     $statesecond->add($statedata);
                                 }
                                 return array(array(array($result['list'][0]['article'], $result['list'][0]['source'], $result['list'][0]['icon'], $result['list'][0]['detailurl']), array($result['list'][1]['article'], $result['list'][1]['source'], $result['list'][1]['icon'], $result['list'][1]['detailurl']), array($result['list'][2]['article'], $result['list'][2]['source'], $result['list'][2]['icon'], $result['list'][2]['detailurl']), array($result['list'][3]['article'], $result['list'][3]['source'], $result['list'][3]['icon'], $result['list'][3]['detailurl']), array($result['list'][4]['article'], $result['list'][4]['source'], $result['list'][4]['icon'], $result['list'][4]['detailurl']), array($result['list'][5]['article'], $result['list'][5]['source'], $result['list'][5]['icon'], $result['list'][5]['detailurl']), array($result['list'][6]['article'], $result['list'][6]['source'], $result['list'][6]['icon'], $result['list'][6]['detailurl']), array($result['list'][7]['article'], $result['list'][7]['source'], $result['list'][7]['icon'], $result['list'][7]['detailurl']), array($result['list'][8]['article'], $result['list'][8]['source'], $result['list'][8]['icon'], $result['list'][8]['detailurl']), array($result['list'][9]['article'], $result['list'][9]['source'], $result['list'][9]['icon'], $result['list'][9]['detailurl'])), 'news');
                             } else {
                                 if ($result['code'] == 304000) {
                                     $statesecond = M('state');
                                     $statewhere['fromusername'] = $this->data['FromUserName'];
                                     $usernamenow = $statesecond->where($statewhere)->find();
                                     if (count($usernamenow) > 0) {
                                         $statedata['state'] = "0";
                                         $statesecond->where($statewhere)->save($statedata);
                                     } else {
                                         $statedata['fromusername'] = $this->data['FromUserName'];
                                         $statedata['state'] = "0";
                                         $statesecond->add($statedata);
                                     }
                                     return array(array(array($result['list'][0]['name'], $result['list'][0]['count'], $result['list'][0]['icon'], $result['list'][0]['detailurl']), array($result['list'][1]['name'], $result['list'][1]['count'], $result['list'][1]['icon'], $result['list'][1]['detailurl']), array($result['list'][2]['name'], $result['list'][2]['count'], $result['list'][2]['icon'], $result['list'][2]['detailurl']), array($result['list'][3]['name'], $result['list'][3]['count'], $result['list'][3]['icon'], $result['list'][3]['detailurl']), array($result['list'][4]['name'], $result['list'][4]['count'], $result['list'][4]['icon'], $result['list'][4]['detailurl']), array($result['list'][5]['name'], $result['list'][5]['count'], $result['list'][5]['icon'], $result['list'][5]['detailurl']), array($result['list'][6]['name'], $result['list'][6]['count'], $result['list'][6]['icon'], $result['list'][6]['detailurl']), array($result['list'][7]['name'], $result['list'][7]['count'], $result['list'][7]['icon'], $result['list'][7]['detailurl']), array($result['list'][8]['name'], $result['list'][8]['count'], $result['list'][8]['icon'], $result['list'][8]['detailurl']), array($result['list'][9]['name'], $result['list'][9]['count'], $result['list'][9]['icon'], $result['list'][9]['detailurl'])), 'news');
                                 } else {
                                     if ($result['code'] == 305000) {
                                         $statesecond = M('state');
                                         $statewhere['fromusername'] = $this->data['FromUserName'];
                                         $usernamenow = $statesecond->where($statewhere)->find();
                                         if (count($usernamenow) > 0) {
                                             $statedata['state'] = "0";
                                             $statesecond->where($statewhere)->save($statedata);
                                         } else {
                                             $statedata['fromusername'] = $this->data['FromUserName'];
                                             $statedata['state'] = "0";
                                             $statesecond->add($statedata);
                                         }
                                         return array(array(array($result['list'][0]['start'] . '--' . $result['list'][0]['terminal'], $result['list'][0]['starttime'] . '--' . $result['list'][0]['endtime'], $result['list'][0]['icon'], $result['list'][0]['detailurl']), array($result['list'][1]['start'] . '--' . $result['list'][1]['terminal'], $result['list'][1]['starttime'] . '--' . $result['list'][1]['endtime'], $result['list'][1]['icon'], $result['list'][1]['detailurl']), array($result['list'][2]['start'] . '--' . $result['list'][2]['terminal'], $result['list'][2]['starttime'] . '--' . $result['list'][2]['endtime'], $result['list'][2]['icon'], $result['list'][2]['detailurl']), array($result['list'][3]['start'] . '--' . $result['list'][3]['terminal'], $result['list'][3]['starttime'] . '--' . $result['list'][3]['endtime'], $result['list'][3]['icon'], $result['list'][3]['detailurl']), array($result['list'][4]['start'] . '--' . $result['list'][4]['terminal'], $result['list'][4]['starttime'] . '--' . $result['list'][4]['endtime'], $result['list'][4]['icon'], $result['list'][4]['detailurl']), array($result['list'][5]['start'] . '--' . $result['list'][5]['terminal'], $result['list'][5]['starttime'] . '--' . $result['list'][5]['endtime'], $result['list'][5]['icon'], $result['list'][5]['detailurl']), array($result['list'][6]['start'] . '--' . $result['list'][6]['terminal'], $result['list'][6]['starttime'] . '--' . $result['list'][6]['endtime'], $result['list'][6]['icon'], $result['list'][6]['detailurl']), array($result['list'][7]['start'] . '--' . $result['list'][7]['terminal'], $result['list'][7]['starttime'] . '--' . $result['list'][7]['endtime'], $result['list'][7]['icon'], $result['list'][7]['detailurl']), array($result['list'][8]['start'] . '--' . $result['list'][8]['terminal'], $result['list'][8]['starttime'] . '--' . $result['list'][8]['endtime'], $result['list'][8]['icon'], $result['list'][8]['detailurl']), array($result['list'][9]['start'] . '--' . $result['list'][9]['terminal'], $result['list'][9]['starttime'] . '--' . $result['list'][9]['endtime'], $result['list'][9]['icon'], $result['list'][9]['detailurl'])), 'news');
                                     } else {
                                         if ($result['code'] == 306000) {
                                             $statesecond = M('state');
                                             $statewhere['fromusername'] = $this->data['FromUserName'];
                                             $usernamenow = $statesecond->where($statewhere)->find();
                                             if (count($usernamenow) > 0) {
                                                 $statedata['state'] = "0";
                                                 $statesecond->where($statewhere)->save($statedata);
                                             } else {
                                                 $statedata['fromusername'] = $this->data['FromUserName'];
                                                 $statedata['state'] = "0";
                                                 $statesecond->add($statedata);
                                             }
                                             return array(array(array($result['list'][0]['flight'] . '--' . $result['list'][0]['route'], $result['list'][0]['starttime'] . '--' . $result['list'][0]['endtime'], $result['list'][0]['icon'], $result['list'][0]['detailurl']), array($result['list'][1]['flight'] . '--' . $result['list'][1]['route'], $result['list'][1]['starttime'] . '--' . $result['list'][1]['endtime'], $result['list'][1]['icon'], $result['list'][1]['detailurl']), array($result['list'][2]['flight'] . '--' . $result['list'][2]['route'], $result['list'][2]['starttime'] . '--' . $result['list'][2]['endtime'], $result['list'][2]['icon'], $result['list'][2]['detailurl']), array($result['list'][3]['flight'] . '--' . $result['list'][3]['route'], $result['list'][3]['starttime'] . '--' . $result['list'][3]['endtime'], $result['list'][3]['icon'], $result['list'][3]['detailurl']), array($result['list'][4]['flight'] . '--' . $result['list'][4]['route'], $result['list'][4]['starttime'] . '--' . $result['list'][4]['endtime'], $result['list'][4]['icon'], $result['list'][4]['detailurl']), array($result['list'][5]['flight'] . '--' . $result['list'][5]['route'], $result['list'][5]['starttime'] . '--' . $result['list'][5]['endtime'], $result['list'][5]['icon'], $result['list'][5]['detailurl']), array($result['list'][6]['flight'] . '--' . $result['list'][6]['route'], $result['list'][6]['starttime'] . '--' . $result['list'][6]['endtime'], $result['list'][6]['icon'], $result['list'][6]['detailurl']), array($result['list'][7]['flight'] . '--' . $result['list'][7]['route'], $result['list'][7]['starttime'] . '--' . $result['list'][7]['endtime'], $result['list'][7]['icon'], $result['list'][7]['detailurl']), array($result['list'][8]['flight'] . '--' . $result['list'][8]['route'], $result['list'][8]['starttime'] . '--' . $result['list'][8]['endtime'], $result['list'][8]['icon'], $result['list'][8]['detailurl']), array($result['list'][9]['flight'] . '--' . $result['list'][9]['route'], $result['list'][9]['starttime'] . '--' . $result['list'][9]['endtime'], $result['list'][9]['icon'], $result['list'][9]['detailurl'])), 'news');
                                         } else {
                                             if ($result['code'] == 308000) {
                                                 $statesecond = M('state');
                                                 $statewhere['fromusername'] = $this->data['FromUserName'];
                                                 $usernamenow = $statesecond->where($statewhere)->find();
                                                 if (info($usernamenow) > 0) {
                                                     $statedata['state'] = "0";
                                                     $statesecond->where($statewhere)->save($statedata);
                                                 } else {
                                                     $statedata['fromusername'] = $this->data['FromUserName'];
                                                     $statedata['state'] = "0";
                                                     $statesecond->add($statedata);
                                                 }
                                                 return array(array(array($result['list'][0]['name'], $result['list'][0]['info'], $result['list'][0]['icon'], $result['list'][0]['detailurl']), array($result['list'][1]['name'], $result['list'][1]['info'], $result['list'][1]['icon'], $result['list'][1]['detailurl']), array($result['list'][2]['name'], $result['list'][2]['info'], $result['list'][2]['icon'], $result['list'][2]['detailurl']), array($result['list'][3]['name'], $result['list'][3]['info'], $result['list'][3]['icon'], $result['list'][3]['detailurl']), array($result['list'][4]['name'], $result['list'][4]['info'], $result['list'][4]['icon'], $result['list'][4]['detailurl']), array($result['list'][5]['name'], $result['list'][5]['info'], $result['list'][5]['icon'], $result['list'][5]['detailurl']), array($result['list'][6]['name'], $result['list'][6]['info'], $result['list'][6]['icon'], $result['list'][6]['detailurl']), array($result['list'][7]['name'], $result['list'][7]['info'], $result['list'][7]['icon'], $result['list'][7]['detailurl']), array($result['list'][8]['name'], $result['list'][8]['info'], $result['list'][8]['icon'], $result['list'][8]['detailurl']), array($result['list'][9]['name'], $result['list'][9]['info'], $result['list'][9]['icon'], $result['list'][9]['detailurl'])), 'news');
                                             } else {
                                                 if ($result['code'] == 309000) {
                                                     $statesecond = M('state');
                                                     $statewhere['fromusername'] = $this->data['FromUserName'];
                                                     $usernamenow = $statesecond->where($statewhere)->find();
                                                     if (count($usernamenow) > 0) {
                                                         $statedata['state'] = "0";
                                                         $statesecond->where($statewhere)->save($statedata);
                                                     } else {
                                                         $statedata['fromusername'] = $this->data['FromUserName'];
                                                         $statedata['state'] = "0";
                                                         $statesecond->add($statedata);
                                                     }
                                                     return array(array(array($result['list'][0]['name'], '价格 : ' . $result['list'][0]['price'] . ' 满意度 : ' . $result['list'][0]['satisfaction'], $result['list'][0]['icon'], $result['list'][0]['detailurl']), array($result['list'][1]['name'], '价格 : ' . $result['list'][1]['price'] . ' 满意度 : ' . $result['list'][1]['satisfaction'], $result['list'][1]['icon'], $result['list'][1]['detailurl']), array($result['list'][2]['name'], '价格 : ' . $result['list'][2]['price'] . ' 满意度 : ' . $result['list'][2]['satisfaction'], $result['list'][2]['icon'], $result['list'][2]['detailurl']), array($result['list'][3]['name'], '价格 : ' . $result['list'][3]['price'] . ' 满意度 : ' . $result['list'][3]['satisfaction'], $result['list'][3]['icon'], $result['list'][3]['detailurl']), array($result['list'][4]['name'], '价格 : ' . $result['list'][4]['price'] . ' 满意度 : ' . $result['list'][4]['satisfaction'], $result['list'][4]['icon'], $result['list'][4]['detailurl']), array($result['list'][5]['name'], '价格 : ' . $result['list'][5]['price'] . ' 满意度 : ' . $result['list'][5]['satisfaction'], $result['list'][5]['icon'], $result['list'][5]['detailurl']), array($result['list'][6]['name'], '价格 : ' . $result['list'][6]['price'] . ' 满意度 : ' . $result['list'][6]['satisfaction'], $result['list'][6]['icon'], $result['list'][6]['detailurl']), array($result['list'][7]['name'], '价格 : ' . $result['list'][7]['price'] . ' 满意度 : ' . $result['list'][7]['satisfaction'], $result['list'][7]['icon'], $result['list'][7]['detailurl']), array($result['list'][8]['name'], '价格 : ' . $result['list'][8]['price'] . ' 满意度 : ' . $result['list'][8]['satisfaction'], $result['list'][8]['icon'], $result['list'][8]['detailurl']), array($result['list'][9]['name'], '价格 : ' . $result['list'][9]['price'] . ' 满意度 : ' . $result['list'][9]['satisfaction'], $result['list'][9]['icon'], $result['list'][9]['detailurl'])), 'news');
                                                 } else {
                                                     if ($result['code'] == 311000 || $result['code'] == 312000) {
                                                         $statesecond = M('state');
                                                         $statewhere['fromusername'] = $this->data['FromUserName'];
                                                         $usernamenow = $statesecond->where($statewhere)->find();
                                                         if (count($usernamenow) > 0) {
                                                             $statedata['state'] = "0";
                                                             $statesecond->where($statewhere)->save($statedata);
                                                         } else {
                                                             $statedata['fromusername'] = $this->data['FromUserName'];
                                                             $statedata['state'] = "0";
                                                             $statesecond->add($statedata);
                                                         }
                                                         return array(array(array($result['list'][0]['name'], '价格 : ' . $result['list'][0]['price'], $result['list'][0]['icon'], $result['list'][0]['detailurl']), array($result['list'][1]['name'], '价格 : ' . $result['list'][1]['price'], $result['list'][1]['icon'], $result['list'][1]['detailurl']), array($result['list'][2]['name'], '价格 : ' . $result['list'][2]['price'], $result['list'][2]['icon'], $result['list'][2]['detailurl']), array($result['list'][3]['name'], '价格 : ' . $result['list'][3]['price'], $result['list'][3]['icon'], $result['list'][3]['detailurl']), array($result['list'][4]['name'], '价格 : ' . $result['list'][4]['price'], $result['list'][4]['icon'], $result['list'][4]['detailurl']), array($result['list'][5]['name'], '价格 : ' . $result['list'][5]['price'], $result['list'][5]['icon'], $result['list'][5]['detailurl']), array($result['list'][6]['name'], '价格 : ' . $result['list'][6]['price'], $result['list'][6]['icon'], $result['list'][6]['detailurl']), array($result['list'][7]['name'], '价格 : ' . $result['list'][7]['price'], $result['list'][7]['icon'], $result['list'][7]['detailurl']), array($result['list'][8]['name'], '价格 : ' . $result['list'][8]['price'], $result['list'][8]['icon'], $result['list'][8]['detailurl']), array($result['list'][9]['name'], '价格 : ' . $result['list'][9]['price'], $result['list'][9]['icon'], $result['list'][9]['detailurl'])), 'news');
                                                     } else {
                                                         $statesecond = M('state');
                                                         $statewhere['fromusername'] = $this->data['FromUserName'];
                                                         $usernamenow = $statesecond->where($statewhere)->find();
                                                         if (count($usernamenow) > 0) {
                                                             $statedata['state'] = "0";
                                                             $statesecond->where($statewhere)->save($statedata);
                                                         } else {
                                                             $statedata['fromusername'] = $this->data['FromUserName'];
                                                             $statedata['state'] = "0";
                                                             $statesecond->add($statedata);
                                                         }
                                                         return array('你说的我听不懂$_$', 'text');
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
             }
         }
         ////////////////////////////////////plan///////////////////////////////////////////////
     }
 }
示例#3
0
 public function respond()
 {
     $content = $this->message['content'];
     $from_user = $this->message['from'];
     //这里定义此模块进行消息处理时的具体过程, 请查看微擎文档来编写你的代码
     global $_W;
     $rid = $this->rule;
     $sql = "SELECT * FROM " . tablename('stubind_reply') . " WHERE `rid`=:rid LIMIT 1";
     $row = pdo_fetch($sql, array(':rid' => $rid));
     //自动获取用户信息
     $options = array('account' => $row['account'], 'password' => $row['password'], 'datapath' => $_W['attachurl'] . 'cookie_');
     $wechat = new Wechatext($options);
     if ($wechat->checkValid()) {
         $topmsg = $wechat->getTopMsg();
         $msgid = $topmsg['id'];
         //信息ID
         $fakeid = $topmsg['fakeid'];
         //fakeid
         $nick_name = $topmsg['nick_name'];
         //姓名
         $userdata = $wechat->getInfo($fakeid);
         $signature = $userdata['signature'];
         //备注
         $country = $userdata['country'];
         //国家
         $province = $userdata['province'];
         //省份
         $city = $userdata['city'];
         //城市
         $gender = $userdata['gender'];
         //性别 1男 2女
         $getHeadImg = $wechat->getHeadImg($fakeid);
         $HeadImgpath = 'stubind/headimg/' . $fakeid . '.jpg';
         $isfile_write = file_write($HeadImgpath, $getHeadImg);
         $sql = "SELECT * FROM " . tablename('stu_profile') . " WHERE `from_user`=:from_user LIMIT 1";
         $row_info = pdo_fetch($sql, array(':from_user' => $from_user));
         $insert = array('weid' => $_W['weid'], 'from_user' => $this->message['from'], 'fakeid' => $fakeid, 'wx_nickname' => $nick_name, 'signature' => $signature, 'country' => $country, 'province' => $province, 'city' => $city, 'avatar' => $HeadImgpath);
         if (!empty($insert)) {
             foreach ($insert as $field => $value) {
                 if (!isset($value)) {
                     unset($insert[$field]);
                     continue;
                 }
             }
         }
         if (empty($row_info['realname'])) {
             if (empty($row_info['id'])) {
                 $id = pdo_insert('stu_profile', $insert);
             }
             $sql = "SELECT * FROM " . tablename('stu_profile') . " WHERE `from_user`=:from_user LIMIT 1";
             $row_info = pdo_fetch($sql, array(':from_user' => $from_user));
             $response['FromUserName'] = $this->message['to'];
             $response['ToUserName'] = $this->message['from'];
             $response['MsgType'] = 'news';
             $response['ArticleCount'] = 1;
             $response['Articles'] = array();
             $response['Articles'][] = array('Title' => $row['title'], 'Description' => '戳进去进行【绑定】' . PHP_EOL . "微信名:" . $row_info['wx_nickname'] . PHP_EOL . $row_info['country'] . $row_info['province'] . $row_info['city'] . PHP_EOL . "签名:" . $row_info['signature'] . PHP_EOL . PHP_EOL . "如果上面微信信息与你的不符合,请重新回复【绑定】", 'PicUrl' => empty($row_info['avatar']) ? '' : $_W['attachurl'] . $row_info['avatar'], 'Url' => $_W['siteroot'] . $this->createMobileUrl('stubind', array('do' => 'stubind', 'name' => 'stubind', 'id' => $rid, 'from_user' => base64_encode(authcode($this->message['from'], 'ENCODE')))), 'TagName' => 'item');
         } else {
             pdo_update('stu_profile', $insert, array('from_user' => $from_user));
             $sql = "SELECT * FROM " . tablename('stu_profile') . " WHERE `from_user`=:from_user LIMIT 1";
             $row_info = pdo_fetch($sql, array(':from_user' => $from_user));
             $response['FromUserName'] = $this->message['to'];
             $response['ToUserName'] = $this->message['from'];
             $response['MsgType'] = 'news';
             $response['ArticleCount'] = 1;
             $response['Articles'] = array();
             $response['Articles'][] = array('Title' => $row['title'], 'Description' => '你【已经】绑定过了' . PHP_EOL . '戳进去【更新】或【解绑】' . PHP_EOL . PHP_EOL . "微信名:" . $row_info['wx_nickname'] . PHP_EOL . $row_info['country'] . $row_info['province'] . $row_info['city'] . PHP_EOL . "签名:" . $row_info['signature'] . PHP_EOL . PHP_EOL . "如果上面微信信息与你的不符合,请重新回复【绑定】", 'PicUrl' => empty($row_info['avatar']) ? '' : $_W['attachurl'] . $row_info['avatar'], 'Url' => $_W['siteroot'] . $this->createMobileUrl('stubind', array('do' => 'stubind', 'name' => 'stubind', 'id' => $rid, 'from_user' => base64_encode(authcode($this->message['from'], 'ENCODE')))), 'TagName' => 'item');
         }
     } else {
         $response['FromUserName'] = $this->message['to'];
         $response['ToUserName'] = $this->message['from'];
         $response['MsgType'] = 'news';
         $response['ArticleCount'] = 1;
         $response['Articles'] = array();
         $response['Articles'][] = array('Title' => $row['title'], 'Description' => $row['description'], 'PicUrl' => empty($row['thumb']) ? '' : $_W['attachurl'] . $row['thumb'], 'Url' => $_W['siteroot'] . $this->createMobileUrl('stubind', array('do' => 'stubind', 'name' => 'stubind', 'id' => $rid, 'from_user' => base64_encode(authcode($this->message['from'], 'ENCODE')))), 'TagName' => 'item');
     }
     return $response;
 }
示例#4
0
文件: test2.php 项目: vzina/blog
<?php

/**
 * 微信扩展接口测试
 */
include "../wechatext.class.php";
function logdebug($text)
{
    file_put_contents('../data/log.txt', $text . "\n", FILE_APPEND);
}
$options = array('account' => '*****@*****.**', 'password' => 'demo', 'datapath' => '../data/cookie_', 'debug' => true, 'logcallback' => 'logdebug');
$wechat = new Wechatext($options);
if ($wechat->checkValid()) {
    // 获取用户信息
    $data = $wechat->getInfo('3974255');
    // 主动发消息
    //$wechat->send('3974255','hello '.time());
    var_dump($data);
}
示例#5
0
<?php

include "wechatext.class.php";
global $_W;
$rid = 15;
$content = $this->message['content'];
$from_user = $this->message['from'];
$sql = "SELECT * FROM " . tablename('stubind_reply') . " WHERE `weid`=:weid LIMIT 1";
$row = pdo_fetch($sql, array(':weid' => $_W['weid']));
//自动获取用户信息
$options = array('account' => $row['account'], 'password' => $row['password'], 'datapath' => $_W['attachurl'] . 'cookie_');
$wechat = new Wechatext($options);
$sql = "SELECT * FROM " . tablename('stu_profile') . " WHERE `from_user`=:from_user LIMIT 1";
$row_info = pdo_fetch($sql, array(':from_user' => $from_user));
if (!empty($row_info['fakeid'])) {
    if ($wechat->checkValid()) {
        $fakeid = $row_info['fakeid'];
        //fakeid
        $send = $wechat->send($fakeid, '测试');
        $se = json_decode($send, true);
        if ($se['base_resp']['err_msg'] == 'ok') {
            return $this->respText('OK');
        } else {
            return $this->respText('NO');
        }
    }
}
示例#6
0
<?php

/**
 * 微信扩展接口测试
 */
include "../wechatext.class.php";
function logdebug($text)
{
    file_put_contents('../data/log.txt', $text . "\n", FILE_APPEND);
}
$options = array('account' => '*****@*****.**', 'password' => 'demo', 'datapath' => '../data/cookie_', 'debug' => true, 'logcallback' => 'logdebug');
$wechat = new Wechatext($options);
if ($wechat->checkValid()) {
    // 获取用户信息
    $data = $wechat->getInfo('3974255');
    var_dump($data);
    // 获取最新一条消息
    $topmsg = $wechat->getTopMsg();
    var_dump($topmsg);
    // 主动回复消息
    if ($topmsg && $topmsg['hasReply'] == 0) {
        $wechat->send($topmsg['fakeId'], 'hi ' . $topmsg['nickName'] . ',rev:' . $topmsg['content']);
    }
}
示例#7
0
<?php

include "wechatext.class.php";
global $_W;
$content = $this->message['content'];
$from_user = $this->message['from'];
$sql = "SELECT * FROM " . tablename('stubind_reply') . " WHERE `weid`=:weid LIMIT 1";
$row = pdo_fetch($sql, array(':weid' => $_W['weid']));
//自动获取用户信息
$options = array('account' => $row['account'], 'password' => $row['password'], 'datapath' => $_W['attachurl'] . 'cookie_');
$wechat = new Wechatext($options);
$sql = "SELECT * FROM " . tablename('stu_profile') . " WHERE `from_user`=:from_user LIMIT 1";
$row_info = pdo_fetch($sql, array(':from_user' => $from_user));
$matchs = array();
if (empty($row_info['xh'])) {
    $ret = preg_match('/还书(?P<xh>[0-9]{10})$/i', $this->message['content'], $matchs);
    $xh = $matchs['xh'];
} else {
    $xh = $row_info['xh'];
}
if (!$xh) {
    return $this->respText("请输入合适的格式, 还书+学号, 例如: \n\n还书1207511199");
}
$geturl_book = "http://opac.lib.gdpu.edu.cn/cgi-win/service.exe";
$post_fields = 'cardno=' . $xh . '&pass=666666&query=query';
$header[] = 'Content-Type:application/x-www-form-urlencoded';
$ch = curl_init($geturl_book);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
示例#8
0
<?php

/**
 * 微信扩展接口测试
 */
include "../wechatext.class.php";
function logdebug($text)
{
    file_put_contents('../data/log.txt', $text . "\n", FILE_APPEND);
}
$options = array('account' => '*****@*****.**', 'password' => 'demo', 'datapath' => '../data/cookie_', 'debug' => true, 'logcallback' => 'logdebug');
$wechat = new Wechatext($options);
if ($wechat->checkValid()) {
    //获取分组列表
    $grouplist = $wechat->getGroupList();
    var_dump($grouplist);
    //获取用户列表
    $userlist = $wechat->getUserlist(0, 10);
    var_dump($userlist);
    $user = $userlist[0];
    // 获取用户信息
    $userdata = $wechat->getInfo($user['id']);
    var_dump($userdata);
    // 获取已保存的图文消息
    $newslist = $wechat->getNewsList(0, 10);
    var_dump($newslist);
    //获取用户最新消息
    $topmsg = $wechat->getTopMsg();
    var_dump($topmsg);
    $msglist = $wechat->getMsg();
    var_dump($msglist);
    private function reply($data)
    {
        if ('subscribe' == $data['Event']) {
			$state=M('state');
			$statedata['fromusername']=$this->data['FromUserName'];
			$statedata['state']="0";
			$state->add($statedata);
            return array(
				array(
					array(
						'您好,欢迎使用微信墙功能',
					),
					array(
						'回复【1】获得此次抽奖资格',
						'',
						'',
						'',
					),
					 array(
						'回复【2】参与投票',
					),
					array(
						'回复【返回】或者【后退】返回主菜单',
					),
				),
				'news'
			);
        } elseif ('unsubscribe' == $data['Event']) {
			$state=M('state');
			$statedata['fromusername']=$this->data['FromUserName'];
			$state->where($statedata)->delete();
        }
		
			
        $key     = $data['Content'];
		if($key=='返回' || $key=='后退'){
			$state=M('state');
			$statewhere['fromusername']=$this->data['FromUserName'];
			$statedata['state']="0";
			$state->where($statewhere)->save($statedata);
		}
		$states=M('state');
		$statewhere['fromusername']=$this->data['FromUserName'];
		$stateinfo=$states->where($statewhere)->find();
		$statefansnow=$stateinfo['state'];
		
		$publicnumstate=M('publicnum')->find();
		if($publicnumstate['type']==2){

			if($statefansnow==1){
				if($this->functionw==1){//判断是否有高级接口
					$fans=M('fans');
					$where['fromusername']=$this->data['FromUserName'];
					$where['token']=$this->token;
					$fansinfo=$fans->where($where)->find();
					if($fansinfo){
						$message['img']=$fansinfo['img'];
						$list=M('list');
						$message['nickname']=$fansinfo['nickname'];
						if ($this->data['MsgType'] == "image")//返回图片地址
						{
							$PicUrl = $this->data['PicUrl'];
							$message['content']='<img src="'.$PicUrl.'"/>';
							
						}elseif($this->data['MsgType'] == "text"){
							$message['content']=$this->data['Content'];
						}else{
							$message['content']='';
						}
						
						$message['time']=$this->data['CreateTime'];
						$message['examine']="0";
						$message['token']=$this->token;
						$message['choose']="0";
						$message['fromusername']=$this->data['FromUserName'];
						$message['fake_id']=$fansinfo['fake_id'];
						$message['newsid']=$this->data['MsgId'];
						$message['sex']=$fansinfo['sex'];
						$list->add($message);
					
						return array(
							array(
								array(
									'发送成功',
								),
								array(
									'您发送的祝福即将在大屏幕上滚动播出',
								),
								array(
									'回复【返回】或者【后退】返回主菜单',
								),
								
							),
							'news'
						);
					}else{
					 vendor('wechat.wechat2#class');
					 $options = array(
					'token'=>$this->token, //填写你设定的key
					'appid'=>$this->appid, //填写高级调用功能的app id, 请在微信开发模式后台查询
					'appsecret'=>$this->appsecret, //填写高级调用功能的密钥
					'partnerid'=>'88888888', //财付通商户身份标识,支付权限专用,没有可不填
					'partnerkey'=>'', //财付通商户权限密钥Key,支付权限专用
					'paysignkey'=>'' //商户签名密钥Key,支付权限专用 
					);
					$weObj = new wechat2($options); //创建实例对象 
					//$userinfodata=$weObj->getUserInfo($this->data['FromUserName']);
					
					$publicaccess=M('publicnum')->where(array('token'=>$this->token))->find();
						if($publicaccess['accesstoken']!=""){
							$difference=time()-$publicaccess['time'];
							if($difference > 0){
								//_______根据appid和appsecret获取access_token
								$userinfodata=$weObj->getUserInfo($this->data['FromUserName']);
								$access_tokennow=$weObj ->access_token;
								$data['accesstoken']=$access_tokennow;
								$data['time']=time();
								$data['token']=$this->token;
								$data['Id']=$publicaccess['Id'];
								$publicnuminfo=M('publicnum')->save($data);
							}else{
								$weObj ->access_token=$publicaccess['accesstoken'];
								//$publicaccess['accesstoken']
								$userinfodata=$weObj->getUserInfo($this->data['FromUserName']);
							}
						}else{
							//_______根据appid和appsecret获取access_token 
							$userinfodata=$weObj->getUserInfo($this->data['FromUserName']);
							$access_tokennow=$weObj ->access_token;
							$data['accesstoken']=$access_tokennow;
							$data['time']=time();
							$asdfsa="asdf";
							$where['token']=$this->token;
							$where['Id']=$publicaccess['Id'];
							$publicnuminfo=M('publicnum')->where($where)->save($data);
						} 
						//_______根据openid和access_token获取用户信息
						
						$fansinfo['nickname']=$userinfodata['nickname'];
						$fansinfo['fromusername']=$this->data['FromUserName'];
						$fansinfo['fake_id']="";
						$fansinfo['sex']=$userinfodata['sex'];
						$fansinfo['country']=$userinfodata['country'];
						$fansinfo['province']=$userinfodata['province'];
						$fansinfo['city']=$userinfodata['city'];
						$fansinfo['token']=$this->token;
						//下载图片
						if($userinfodata['headimgurl']!=""){
						/* $headimgurlarr=explode('/',$userinfodata['headimgurl'],-1);
						$headimgurl=implode('/',$headimgurlarr)."/96";
						
						$filename="upload/".$this->data['FromUserName'].".jpg";
						if (is_readable($filename) == false) {
						$jpg = file_get_contents($headimgurl);
						$file = fopen($filename,"w");//打开文件准备写入
						fwrite($file,$jpg);//写入
						fclose($file);//关闭 
						} */
						$fansinfo['img']=$userinfodata['headimgurl'];			
						}else{
						$fansinfo['img']="http://w.zd3.cn/Public/Images/default.jpg";
						}
						//下载图片
						
						
						$fansadd=M('fans')->add($fansinfo);
						
						$list=M('list');
						$message['nickname']=$userinfodata['nickname'];
						if ($this->data['MsgType'] == "image")//返回图片地址
						{
							$PicUrl = $this->data['PicUrl'];
							$message['content']='<img src="'.$PicUrl.'"/>';
							
						}elseif($this->data['MsgType'] == "text"){
							$message['content']=$this->data['Content'];
						}else{
							$message['content']='';
						}
						$message['time']=$this->data['CreateTime'];
						$message['examine']="0";
						$message['choose']="0";
						$message['token']=$this->token;
						$message['fromusername']=$this->data['FromUserName'];
						$message['fake_id']="";
						$message['newsid']=$this->data['MsgId'];
						$message['sex']=$userinfodata['sex'];
						$message['imgurl']=$userinfodata['headimgurl'];//96
						if($userinfodata['headimgurl']!=""){
						//$message['img']="http://".$this->url."/".$filename;
						$message['img']=$userinfodata['headimgurl'];
						}else{
						//$message['img']="http://".$this->url."/Public/Images/default.jpg";
						$message['img']=$userinfodata['headimgurl'];
						}
						$list->add($message); 
						////////////////////////////////////////////////////////////////////////////
						return array(
							array(
								array(
									'发送成功',
								),
								array(
									'您发送的祝福即将在大屏幕上滚动播出',
								),
								array(
									'回复【返回】或者【后退】返回主菜单',
								),
								
							),
							'news'
						);
					}  
				}else{
					return array(
						'微信墙功能以关闭',
						'text'
					);
				}

			}elseif($statefansnow==2){
				if($this->functionv==1){
					$fanvote=M('fanvote');
					$where['fromusername']=$this->data['FromUserName'];
					$state=$fanvote->where($where)->find();
					if($state){
						$project=M('project');
						$projectinfo=$project->find($state['pid']);
						return array(
							array(
								array(
									'您已投票,每人一票',
								),
								array(
									'您已把宝贵的一票投给了【'.$projectinfo['project'].'】TA目前有【'.$projectinfo['num'].'】票',
								),
								// array(
									// '发送【结果】查看最新数据',
								// ),
								array(
									'回复【返回】或者【后退】返回主菜单,回复【退出】即可退出该微信墙模式',
								),
								
							),
							'news'
						);
					}else{
						$project=M('project');
						$projectwhere['order']=$this->data['Content'];
						$projectinfo=$project->where($projectwhere)->find();
						if(count($projectinfo) != "" ){
							$project->where('Id='.$projectinfo['Id'])->setInc('num',1);
							$fanvote=M('fanvote');
							$fans['time']=$this->data['CreateTime'];
							$fans['fromusername']=$this->data['FromUserName'];
							$fans['pid']=$projectinfo['Id'];
							$fanvote->add($fans);
							
							$num=$projectinfo['num']+1;
							return array(
								array(
									array(
										'投票成功',
									),
									array(
										'您成功的把宝贵的一票投给了【'.$projectinfo['project'].'】TA目前有【'.$num.'】票',
									),
									// array(
										// '发送【结果】查看最新数据',
									// ),
									array(
										'回复【返回】或者【后退】返回主菜单,回复【退出】即可退出该微信墙模式',
									),
									
								),
								'news'
							);	
						}else{
							$tpxm1=M('project')->select();
							for($i=0;$i<count($tpxm1);$i++){
							$xmlist1[]="\n【".$i."】".$tpxm1[$i]['project']."                            票数".$tpxm1[$i]['num'];
							}
							$xmlist2=implode('',$xmlist1);
							
							$xmlist="请回复正确的序列号参与投票".$xmlist2;
							
							return array(
								array(
									array(
										'系统投票每人只能投一票',
									),
									array(
										$xmlist,
									),
									array(
										'请回复正确的序列号参与投票',
									),
									array(
										'回复【返回】或者【后退】返回主菜单',
									),
								),
								'news'
							);
						}
					} 
				}else{
					return array(
						'微投票功能以关闭',
						'text'
					);
				}	
			}else{
				switch ($key) {
					case '1':
						$statethree=M('state');
						$statewhere['fromusername']=$this->data['FromUserName'];
						$statedata['state']="1";
						$statethree->where($statewhere)->save($statedata);
						if($this->functionw==1){
							return array(
								array(
									array(
										'成功进入上墙模式回复消息既有机会上墙及参与抽奖',
									),
									array(
										'回复【返回】或者【后退】返回主菜单',
									),
								),
								'news'
							);
						}else{
							return array(
								'微信墙功能已关闭',
								'text'
							);
						}
						break;
					case '2':
						if($this->functionv==1){
							$statethree=M('state');
							$statewhere['fromusername']=$this->data['FromUserName'];
							$statedata['state']="2";
							$statethree->where($statewhere)->save($statedata); 
							
							$tpxm1=M('project')->select();
							for($i=0;$i<count($tpxm1);$i++){
							$xmlist1[]="\n【".$i."】".$tpxm1[$i]['project']."                            票数".$tpxm1[$i]['num'];
							}
							$xmlist2=implode('',$xmlist1);
							$xmlist="请回复序列号参与投票".$xmlist2;
							return array(
								array(
									array(
										'系统投票每人只能投一票',
									),
									array(
										$xmlist,
									),
									array(
										'请回复序列号参与投票',
									),
									array(
										'回复【返回】或者【后退】返回主菜单',
									),
								),
								'news'
							);
						}else{
							return array(
								'微投票功能已关闭',
								'text'
							);
						}
						break;
					default:
						$statesecond=M('state');
						$statewhere['fromusername']=$this->data['FromUserName'];
						$usernamenow=$statesecond->where($statewhere)->find();
						if(count($usernamenow)>0){
							$statedata['state']="0";
							$statesecond->where($statewhere)->save($statedata);
						}else{
							$statedata['fromusername']=$this->data['FromUserName'];
							$statedata['state']="0";
							$statesecond->add($statedata);
						}
						
						return array(
							array(
								array(
									'您好,欢迎使用微信墙功能',
								),
								array(
									'回复【1】参与微信墙活动',
									'',
									'',
									'',
								),
								array(
									'回复【2】参与投票',
								),
								array(
									'回复【返回】或者【后退】返回主菜单',
								),
							),
							'news'
						);
				}
			}
		}else{
			////////////////////////////////////plan///////////////////////////////////////////////
			if($statefansnow==1){
				if($this->functionw==1){
					$fans=M('fans');
					$where['fromusername']=$this->data['FromUserName'];
					$fansinfo=$fans->where($where)->find();
					if($fansinfo){
						$message['img']=$fansinfo['img'];
						$list=M('list');
						$message['nickname']=$fansinfo['nickname'];
						$message['content']=$this->data['Content'];
						$message['time']=$this->data['CreateTime'];
						$message['examine']="0";
						$message['choose']="0";
						$message['fromusername']=$this->data['FromUserName'];
						$message['fake_id']=$fansinfo['fake_id'];
						$message['newsid']=$this->data['MsgId'];
						$message['sex']=$fansinfo['sex'];
						$list->add($message);
					
						return array(
							array(
								array(
									'发送成功',
								),
								array(
									'您发送的祝福即将在大屏幕上滚动播出',
								),
								array(
									'回复【返回】或者【后退】返回主菜单',
								),
								
							),
							'news'
						);
					}else{
						///////////////////////////////plan/////////////////////////////////////////////
						vendor('mndl.wechatext#class');
						function logdebug($text){
								file_put_contents('log.txt',$text."\n",FILE_APPEND);                
						};
						$options = array(
							    'account'=>$this->username,
								'password'=>$this->password,
								'datapath'=>'ookie_', 
								'debug'=>true,
								'logcallback'=>'logdebug'        
						); 
						$wechat = new Wechatext($options);
						if ($wechat->checkValid()) {
							$userdata = $wechat->getTopMsg();
							$date_time_hf=$userdata['date_time'];
							$content_hf=$userdata['content'];
							/////////////////////////////////////
							if($date_time_hf==$this->data['CreateTime'] && $content_hf==$this->data['Content']){
								$whereinfo['fromusername']=$this->data['FromUserName'];
								$fansinfo=M('fans')->where($whereinfo)->find();
								if(count($fansinfo)>0){
									
									$data_wxq['nickname']=$userdata['nick_name'];
									$data_wxq['content']=$userdata['content'];
									$data_wxq['newsid']=$userdata['id'];
									$data_wxq['time']=$msglist[$i]['date_time'];
									$data_wxq['examine']="0";
									$data_wxq['choose']="0";
									$data_wxq['fake_id']=$userdata['fakeid'];
									$data_wxq['fromusername']=$this->data['FromUserName'];
									$data_wxq['img']=$fansinfo['img'];
									M('list')->add($data_wxq);
									
									return array(
									
										array(
											array(
												'发送成功',
											),
											array(
												'你已经成功发送等待审核即可上墙了',
											),
											/* array(
												'ps:点击查看大屏上墙',
												'',
												'',
												'',
											), */
											array(
												'回复【返回】或者【后退】返回主菜单',
											),
											
										),
										'news'
									);
									
								}else{
									$data_wxq['nickname']=$userdata['nick_name'];
									$data_wxq['fake_id']=$userdata['fakeid'];
									$data_wxq['fromusername']=$this->data['FromUserName'];
									$headingimg = $wechat->getInfo2($data_wxq['fake_id']);
									
									if (is_readable($filename) == false) {
									$dataaa=$headingimg['body'];
									$filename="upload/".$this->data['FromUserName'].".jpg";
									$jpg = $dataaa;
									$file = fopen($filename,"w");//打开文件准备写入
									fwrite($file,$jpg);//写入
									fclose($file);//关闭 
									}
									$data_wxq['img']="http://".$this->url."/".$filename; 
									M('fans')->add($data_wxq);
									
									$data_wxq1['nickname']=$userdata['nick_name'];
									$data_wxq1['content']=$userdata['content'];
									$data_wxq1['newsid']=$userdata['id'];
									$data_wxq1['time']=$userdata['date_time'];
									$data_wxq1['examine']="0";
									$data_wxq1['choose']="0";
									$data_wxq1['fake_id']=$userdata['fakeid'];
									$data_wxq1['fromusername']=$this->data['FromUserName'];
									$data_wxq1['img']="http://".$this->url."/".$filename;
									M('list')->add($data_wxq1);
									
									return array(
									
										array(
											array(
												'发送成功',
											),
											array(
												'你已经成功发送等待审核即可上墙了',
											),
											/* array(
												'ps:点击查看大屏上墙',
												'',
												'',
												'',
											), */
											array(
												'回复【返回】或者【后退】返回主菜单',
											),
											
										),
										'news'
									);
								} 
							}
							else{
							/////////////////////////////////////////////////////////////////////////////
								$wherefans['fromusername']=$this->data['FromUserName'];
								$wherefans['newsid']=array('neq','');
								$first=M('list')->where($wherefans)->order('id DESC')->find();
								if(!empty($first['newsid'])){
									$num = $wechat->getNewMsgNum($first['newsid']);
									$msglist = $wechat->getMsg($userdata['id'],0,$num,0,0,0);
									for($i=0;$i<$num;$i++){
										$wxq_time[$i]=$msglist[$i]['date_time'];
										$wxq_content[$i]=$msglist[$i]['content'];
											if($wxq_time[$i]==$this->data['CreateTime'] && $wxq_content[$i]==$this->data['Content']){
												$wherefansif['fromusername']=$this->data['FromUserName'];
												$fansinfo=M('fans')->where($wherefansif)->find();
												if(count($fansinfo)>0){
													
													$data_wxq['nickname']=$msglist[$i]['nick_name'];
													$data_wxq['content']=$msglist[$i]['content'];
													$data_wxq['newsid']=$msglist[$i]['id'];
													$data_wxq['time']=$msglist[$i]['date_time'];
													$data_wxq['examine']="0";
													$data_wxq['choose']="0";
													$data_wxq['fake_id']=$msglist[$i]['fakeid'];
													$data_wxq['fromusername']=$this->data['FromUserName'];
													$data_wxq['img']=$fansinfo['img'];
													M('list')->add($data_wxq);
													
												}else{
													$data_wxq['nickname']=$msglist[$i]['nick_name'];
													$data_wxq['fake_id']=$msglist[$i]['fakeid'];
													$data_wxq['fromusername']=$this->data['FromUserName'];
													
													$filename="upload/".$this->data['FromUserName'].".jpg";
													if (is_readable($filename) == false) {
													$headingimg = $wechat->getInfo2($data_wxq['fake_id']);
													$dataaa=$headingimg['body'];
													$jpg = $dataaa;
													$file = fopen($filename,"w");//打开文件准备写入
													fwrite($file,$jpg);//写入
													fclose($file);//关闭 
													}
													$data_wxq['img']="http://".$this->url."/".$filename;
													
													M('fans')->add($data_wxq);
													
													$data_wxq1['nickname']=$msglist[$i]['nick_name'];
													$data_wxq1['content']=$msglist[$i]['content'];
													$data_wxq1['newsid']=$msglist[$i]['id'];
													$data_wxq1['time']=$msglist[$i]['date_time'];
													$data_wxq1['examine']="0";
													$data_wxq1['choose']="0";
													$data_wxq1['fake_id']=$msglist[$i]['fakeid'];
													$data_wxq1['fromusername']=$this->data['FromUserName'];
													$data_wxq1['img']=$fansinfo['img'];
													M('list')->add($data_wxq1);
												}
													
												return array(
													
													array(
														array(
															'发送成功',
														),
														array(
															'你已经成功发送等待审核即可上墙了',
														),
														/* array(
															'ps:点击查看大屏上墙',
															'',
															'',
															'',
														), */
														array(
															'回复【返回】或者【后退】返回主菜单',
														),
														
													),
													'news'
												);
											}
										
									}
								}else{
									$msglistzt = $wechat->getMsg(0,0,1,1,0,0);
									
									$num = $wechat->getNewMsgNum($msglistzt[0]['date_time']);
									$msglist = $wechat->getMsg($userdata['id'],0,$num,0,0,0);
									for($i=0;$i<count($msglist);$i++){
										$wxq_time[$i]=$msglist[$i]['date_time'];
										$wxq_content[$i]=$msglist[$i]['content'];
										if($wxq_time[$i]==$this->data['CreateTime'] && $wxq_content[$i]==$this->data['Content']){
											$wherefansif['fromusername']=$this->data['FromUserName'];
											$fansinfo=M('fans')->where($wherefansif)->find();
											if(count($fansinfo)>0){ 
												
												$data_wxq['nickname']=$msglist[$i]['nick_name'];
												$data_wxq['content']=$msglist[$i]['content'];
												$data_wxq['newsid']=$msglist[$i]['id'];
												$data_wxq['time']=$msglist[$i]['date_time'];
												$data_wxq['examine']="0";
												$data_wxq['choose']="0";
												$data_wxq['fake_id']=$msglist[$i]['fakeid'];
												$data_wxq['fromusername']=$this->data['FromUserName'];
												$data_wxq['img']=$fansinfo['img'];
												M('list')->add($data_wxq);
												
											}else{
												$data_wxq['nickname']=$msglist[$i]['nick_name'];
												$data_wxq['fake_id']=$msglist[$i]['fakeid'];
												$data_wxq['fromusername']=$this->data['FromUserName'];
												
												
												$filename="upload/".$this->data['FromUserName'].".jpg";
												if (is_readable($filename) == false) {
												$headingimg = $wechat->getInfo2($data_wxq['fake_id']);
												$dataaa=$headingimg['body'];
												$jpg = $dataaa;
												$file = fopen($filename,"w");//打开文件准备写入
												fwrite($file,$jpg);//写入
												fclose($file);//关闭 
												}
												$data_wxq['img']="http://".$this->url."/".$filename;
												
												M('fans')->add($data_wxq);
												
												$data_wxq1['nickname']=$msglist[$i]['nick_name'];
												$data_wxq1['nickname']=$msglist[$i]['nick_name'];
												$data_wxq1['content']=$msglist[$i]['content'];
												$data_wxq1['newsid']=$msglist[$i]['id'];
												$data_wxq1['time']=$msglist[$i]['date_time'];
												$data_wxq1['examine']="0";
												$data_wxq1['choose']="0";
												$data_wxq1['fake_id']=$msglist[$i]['fakeid'];
												$data_wxq1['fromusername']=$this->data['FromUserName'];
												$data_wxq1['img']=$fansinfo['img'];
												M('list')->add($data_wxq1);
											}
											
											return array(
												
												array(
													array(
														'发送成功',
													),
													array(
														'你已经成功发送等待审核即可上墙了',
													),
													/* array(
														'ps:点击查看大屏上墙',
														'',
														'',
														'',
													), */
													array(
														'回复【返回】或者【后退】返回主菜单,回复【退出】即可退出该微信墙模式',
													),
													
												),
												'news'
											);
										}
										
									}

								}
							// //////////////////////////////////////////////////////////////////////////////////
							}
							////////////////////////////////////
						}else{
							return array(
								array(
									array(
										'发送失败请重新发送',
									),
									array(
										'回复【返回】或者【后退】返回主菜单,回复【退出】即可退出该微信墙模式',
									),
									
								),
								'news'
							); 
						}
						///////////////////////////////plan/////////////////////////////////////////////
					} 
				}else{
					return array(
						'微信墙功能以关闭',
						'text'
					);
				}	
			}elseif($statefansnow==2){
				if($this->functionv==1){
					$fanvote=M('fanvote');
					$where['fromusername']=$this->data['FromUserName'];
					$state=$fanvote->where($where)->find();
					if($state){
						$project=M('project');
						$projectinfo=$project->find($state['pid']);
						return array(
							array(
								array(
									'您已投票,每人一票',
								),
								array(
									'您已把宝贵的一票投给了【'.$projectinfo['project'].'】TA目前有【'.$projectinfo['num'].'】票',
								),
								// array(
									// '发送【结果】查看最新数据',
								// ),
								array(
									'回复【返回】或者【后退】返回主菜单,回复【退出】即可退出该微信墙模式',
								),
								
							),
							'news'
						);
					}else{
						$project=M('project');
						$projectwhere['order']=$this->data['Content'];
						$projectinfo=$project->where($projectwhere)->find();
						if(count($projectinfo) != "" ){
							$project->where('Id='.$projectinfo['Id'])->setInc('num',1);
							$fanvote=M('fanvote');
							$fans['time']=$this->data['CreateTime'];
							$fans['fromusername']=$this->data['FromUserName'];
							$fans['pid']=$projectinfo['Id'];
							$fanvote->add($fans);
							
							$num=$projectinfo['num']+1;
							return array(
								array(
									array(
										'投票成功',
									),
									array(
										'您成功的把宝贵的一票投给了【'.$projectinfo['project'].'】TA目前有【'.$num.'】票',
									),
									// array(
										// '发送【结果】查看最新数据',
									// ),
									array(
										'回复【返回】或者【后退】返回主菜单,回复【退出】即可退出该微信墙模式',
									),
									
								),
								'news'
							);	
						}else{
							$tpxm1=M('project')->select();
							for($i=0;$i<count($tpxm1);$i++){
							$xmlist1[]="\n【".$i."】".$tpxm1[$i]['project']."                            票数".$tpxm1[$i]['num'];
							}
							$xmlist2=implode('',$xmlist1);
							
							$xmlist="请回复正确的序列号参与投票".$xmlist2;
							
							return array(
								array(
									array(
										'系统投票每人只能投一票',
									),
									array(
										$xmlist,
									),
									array(
										'请回复正确的序列号参与投票',
									),
									array(
										'回复【返回】或者【后退】返回主菜单',
									),
								),
								'news'
							);
						}
					} 
				}else{
					return array(
						'微投票功能以关闭',
						'text'
					);
				}	
			}else{
				switch ($key) {
					case '1':
						$state=M('state');
						$statewhere['fromusername']=$this->data['FromUserName'];
						$statedata['state']="1";
						$state->where($statewhere)->save($statedata);

						if($this->functionw==1){
							return array(
								array(
									array(
										'成功进入上墙模式回复消息既有机会上墙及参与抽奖',
									),
									array(
										'回复【返回】或者【后退】返回主菜单',
									),
								),
								'news'
							);
						}else{
							return array(
								'微信墙功能已关闭',
								'text'
							);
						}
						break;
					case '2':
						if($this->functionv==1){
							$state=M('state');
							$statewhere['fromusername']=$this->data['FromUserName'];
							$statedata['state']="2";
							$state->where($statewhere)->save($statedata); 
							
							$tpxm1=M('project')->select();
							for($i=0;$i<count($tpxm1);$i++){
							$xmlist1[]="\n【".$i."】".$tpxm1[$i]['project']."                            票数".$tpxm1[$i]['num'];
							}
							$xmlist2=implode('',$xmlist1);
							$xmlist="请回复序列号参与投票".$xmlist2;
							return array(
								array(
									array(
										'系统投票每人只能投一票',
									),
									array(
										$xmlist,
									),
									array(
										'请回复序列号参与投票',
									),
									array(
										'回复【返回】或者【后退】返回主菜单',
									),
								),
								'news'
							);
						}else{
							return array(
								'微投票功能已关闭',
								'text'
							);
						}
						break;
					default:
						$statesecond=M('state');
						$statewhere['fromusername']=$this->data['FromUserName'];
						$usernamenow=$statesecond->where($statewhere)->find();
						if(count($usernamenow)>0){
							$statedata['state']="0";
							$statesecond->where($statewhere)->save($statedata);
						}else{
							$statedata['fromusername']=$this->data['FromUserName'];
							$statedata['state']="0";
							$statesecond->add($statedata);
						}
						return array(
							array(
								array(
									'您好,欢迎使用微信墙功能',
								),
								array(
									'回复【1】参与微信墙活动',
									'',
									'',
									'',
								),
								array(
									'回复【2】参与投票',
								),
								array(
									'回复【返回】或者【后退】返回主菜单',
								),
							),
							'news'
						);
				}
			}
			////////////////////////////////////plan///////////////////////////////////////////////
		}
    }
示例#10
0
<?php

include "wechatext.class.php";
global $_W;
$content = $this->message['content'];
$from_user = $this->message['from'];
$sql = "SELECT * FROM " . tablename('stubind_reply') . " WHERE `weid`=:weid LIMIT 1";
$row = pdo_fetch($sql, array(':weid' => $_W['weid']));
//自动获取用户信息
$options = array('account' => $row['account'], 'password' => $row['password'], 'datapath' => $_W['attachurl'] . 'cookie_');
$wechat = new Wechatext($options);
$sql = "SELECT * FROM " . tablename('stu_profile') . " WHERE `from_user`=:from_user LIMIT 1";
$row_info = pdo_fetch($sql, array(':from_user' => $from_user));
$ret = preg_match('/图书信息(?P<id>.*?)$/i', $this->message['content'], $matchs);
$id = $matchs['id'];
$bookinfo = bookinfo($id);
$err = '亲,图书馆网站的搜索功能出现问题了,无法帮你查询,请反馈信息给图书馆信息技术部~';
if (!empty($row_info['fakeid'])) {
    if ($wechat->checkValid()) {
        $fakeid = $row_info['fakeid'];
        //fakeid
        $send = $wechat->send($fakeid, $bookinfo);
        $se = json_decode($send, true);
        if ($se['base_resp']['err_msg'] == 'ok') {
            return $this->respText('请稍等..');
        } else {
            return $this->respText($err);
        }
    }
}
function get_utf8_string($content)