private function reply($data)
 {
     // 印美丽初使化信息
     import("@.ORG.yinmeili");
     $wxuser = M('wxuser');
     $where = array();
     $where['token'] = $this->token;
     $wxid = $wxuser->where($where)->getField('wxid');
     $yml_username = '';
     $yml_secret = '';
     $yml_print_enable = 0;
     $yml_wx_appid = '';
     $yml_wx_appsecret = '';
     $voice_enable = 0;
     $yml_config = M('yml_config');
     $where['token'] = $this->token;
     $yml_data = $yml_config->where($where)->find();
     if ($yml_data != null) {
         $yml_username = $yml_data['username'];
         $yml_secret = $yml_data['secret'];
         $yml_print_enable = $yml_data['print_enable'];
         $yml_wx_appid = $yml_data['wx_appid'];
         $yml_wx_appsecret = $yml_data['wx_appsecret'];
         $yml_voice_enable = $yml_data['voice_enable'];
     }
     $step = '';
     $task_id = 0;
     $yml_record = M('yml_record');
     $where['token'] = $this->token;
     $where['wxid'] = $data['FromUserName'];
     $yml_data = $yml_record->where($where)->find();
     if ($yml_data == null) {
         $yml_record = M('yml_record');
         $yml_record->add(array('token' => $this->token, 'wxid' => $data['FromUserName'], 'update_time' => time()));
     } else {
         $step = $yml_data['step'];
         $task_id = $yml_data['task_id'];
     }
     if ($yml_print_enable == 1) {
         // 印美丽图片处理部分
         if ('image' == $data['MsgType']) {
             if ($yml_username == '' || $yml_secret == '') {
                 return array('未配置印美丽设备信息!', 'text');
             } else {
                 $image = '';
                 if (isset($data['PicUrl'])) {
                     $image = trim($data['PicUrl']) . '/' . $data['FromUserName'] . '.jpg';
                 }
                 $api = new yinmeili($yml_username, $yml_secret, $wxid, $data['FromUserName']);
                 $taskInfo = $api->addPrintTask($image);
                 if ($taskInfo['task_id'] == 0) {
                     return array($taskInfo['message'], 'text');
                 } else {
                     $yml_record = M('yml_record');
                     $yml_record->where($where)->save(array('step' => '打印照片', 'task_id' => $taskInfo['task_id'], 'update_time' => time()));
                     return array("请先对图像进行<a href='{$taskInfo['basic']}'>裁剪</a>,然后输入验证码完成照片打印或发送语音进行留声,输入退出离开照片打印!", 'text');
                 }
             }
         }
         // 印美丽留声卡
         if ($step == '打印照片' && $data['MsgType'] == 'voice') {
             if ($yml_voice_enable == 0) {
                 return array('留声卡功能暂未开启!', 'text');
             } else {
                 $api = new yinmeili($yml_username, $yml_secret, $wxid, $data['FromUserName']);
                 $taskInfo = $api->addVoice($yml_wx_appid, $yml_wx_appsecret, $task_id, $data['MediaId']);
                 return array($taskInfo['message'], 'text');
             }
         }
         // 印美丽验证码校验
         if ($step == '打印照片' && $data['MsgType'] == 'text') {
             if ($data['Content'] == '退出') {
                 $yml_record = M('yml_record');
                 $yml_record->where($where)->save(array('step' => '', 'task_id' => 0, 'update_time' => time()));
                 return array('成功退出打印照片!', 'text');
             }
             $api = new yinmeili($yml_username, $yml_secret, $wxid, $data['FromUserName']);
             $result = $api->checkPrintVerifyCode($task_id, $data['Content']);
             if (isset($result['status']) && $result['status'] == 1) {
                 $yml_record = M('yml_record');
                 $yml_record->where($where)->save(array('step' => '', 'task_id' => 0, 'update_time' => time()));
                 return array('等待30秒, 就可以拿到照片了哦!', 'text');
             } else {
                 return array($result['message'] . ' 输入“退出”离开照片打印!', 'text');
             }
         }
     }
     // 印美丽功能结束
     //语音功能
     if (isset($data['MsgType'])) {
         if ('voice' == $data['MsgType']) {
             $data['Content'] = $data['Recognition'];
             $this->data['Content'] = $data['Recognition'];
         }
     }
     if ($this->wxuser['openphotoprint']) {
         $photoPrint = new photoPrint($this->wxuser, $this->data['FromUserName']);
     }
     if ($this->wxuser['openphotoprint'] && $this->fans['photoprintopen']) {
         return $photoPrint->reply($data);
     }
     if ($this->user['viptime'] < time()) {
         //判断账号是否到期
         return array('您的账号已经过期,请联系' . $this->siteUrl . '开通', 'text');
     }
     //判断关注
     $eventReplyClassName = $data['Event'] . 'EventReply';
     if (class_exists($eventReplyClassName)) {
         $eventReplyClassName = new $eventReplyClassName($this->token, $this->data['FromUserName'], $data, $this->siteUrl);
         return $eventReplyClassName->index();
     }
     if ('CLICK' == $data['Event']) {
         $data['Content'] = $data['EventKey'];
         $this->data['Content'] = $data['EventKey'];
     } elseif ($data['Event'] == 'SCAN') {
         if ($this->wxuser['openphotoprint']) {
             $photoPrint->initUser();
         }
         $data['Content'] = $this->getRecognition($data['EventKey']);
         $this->data['Content'] = $data['Content'];
     } elseif ($data['Event'] == 'MASSSENDJOBFINISH') {
         M('Send_message')->where(array('msg_id' => $data['msg_id']))->save(array('reachcount' => $data['SentCount']));
         //subscribe(订阅)
     } elseif ('subscribe' == $data['Event']) {
         if ($this->wxuser['openphotoprint']) {
             $photoPrint->initUser();
         }
         $this->behaviordata('follow', '1');
         $this->requestdata('follownum');
         $follow_data = M('Areply')->field('home,keyword,content')->where(array('token' => $this->token))->find();
         //用户未关注时,进行关注后的事件推送 事件KEY值,qrscene_为前缀,后面为二维码的参数值
         if (!(strpos($data['EventKey'], 'qrscene_') === FALSE)) {
             $follow_data['keyword'] = $this->getRecognition(str_replace('qrscene_', '', $data['EventKey']));
             $follow_data['home'] = 1;
         }
         //首页功能
         if ($follow_data['home'] == 1) {
             if (trim($follow_data['keyword']) == '首页' || $follow_data['keyword'] == 'home') {
                 return $this->shouye();
             } elseif (trim($follow_data['keyword']) == '我要上网') {
                 return $this->wysw();
             }
             return $this->keyword($follow_data['keyword']);
         } else {
             if ($follow_data['keyword'] != "") {
                 return $this->keyword($follow_data['keyword']);
             } else {
                 return array(html_entity_decode($follow_data['content']), 'text');
             }
         }
     } elseif ('unsubscribe' == $data['Event']) {
         $this->requestdata('unfollownum');
         // rippleos 需要对应终端重新认证
         $node = D('Rippleos_node')->where(array('token' => $this->token))->find();
         $this->rippleos_unauth($node['node']);
     } elseif ($data['Event'] == 'LOCATION') {
         return $this->nokeywordApi();
     }
     //语音功能
     if ('voice' == $data['MsgType']) {
         $data['Content'] = $data['Recognition'];
         if ($data['Recognition']) {
             $this->data['Content'] = $data['Recognition'];
         } else {
             return $this->nokeywordApi();
         }
     }
     //判断用户提交是否为图片
     if ($data['MsgType'] == 'image') {
         //发送图片目前是晒图片的功能,
         $pic_wall_inf = M('pic_wall')->where(array('token' => $this->token, 'status' => 1))->order('id desc')->find();
         if (!$pic_wall_inf) {
             return array('图片上墙失败!还未开启照片墙功能。', 'text');
         }
         if ($pic_wall_inf && $pic_wall_inf['status'] === '1') {
             //存在晒照片活动并且 活动开关是开的
             //开始下载图片操作
             $sub_dir = date('Ymd');
             if (!file_exists($_SERVER['DOCUMENT_ROOT'] . '/uploads') || !is_dir($_SERVER['DOCUMENT_ROOT'] . '/uploads')) {
                 mkdir($_SERVER['DOCUMENT_ROOT'] . '/uploads', 511);
             }
             $firstLetterDir = $_SERVER['DOCUMENT_ROOT'] . '/uploads/picwall';
             if (!file_exists($firstLetterDir) || !is_dir($firstLetterDir)) {
                 mkdir($firstLetterDir, 511);
             }
             $firstLetterDir = $_SERVER['DOCUMENT_ROOT'] . '/uploads/picwall/' . $sub_dir;
             if (!file_exists($firstLetterDir) || !is_dir($firstLetterDir)) {
                 mkdir($firstLetterDir, 511);
             }
             $file_name = date('YmdHis') . '_' . rand(10000, 99999) . '.jpg';
             $pic_wall_save_path = $_SERVER['DOCUMENT_ROOT'] . '/uploads/picwall/' . $sub_dir . '/' . $file_name;
             $file_web_path = $this->siteUrl . '/uploads/picwall/' . $sub_dir . '/' . $file_name;
             $PicUrl = $data['PicUrl'];
             $imgdata = $this->curlGet($PicUrl);
             $fp = fopen($pic_wall_save_path, 'w');
             fwrite($fp, $imgdata);
             fclose($fp);
             //将照片的路径放入到 缓存中
             $checkresult = $pic_wall_inf['ischeck'] ? 0 : 1;
             //设置上墙图片的检查结果。如果活动设置 是需要审核,那么上墙结果为0需要审核,审核成功以后为1
             //插入到照片墙表中
             $pic_wall_log = array('uid' => $pic_wall_inf['id'], 'token' => $this->token, 'picurl' => $file_web_path, 'wecha_id' => $data['FromUserName'], 'create_time' => time(), 'username' => '', 'state' => $checkresult);
             S('zhaopianwall_' . $this->data['FromUserName'], $pic_wall_log, 60);
             //--下载图片结束
             return array('照片接收成功,请在一分钟内输入 上墙照片的显示名字,或者回复 取消 结束本次活动', 'text');
         } else {
             return array('图片上墙失败!还未开启照片墙功能。', 'text');
         }
     }
     //判断照片墙
     $zhaopianwall_result = S('zhaopianwall_' . $data['FromUserName']);
     if ($zhaopianwall_result) {
         return $this->zhaopianwall($zhaopianwall_result);
     }
     if ($data['Content'] == 'wechat ip') {
         return array($_SERVER['REMOTE_ADDR'], 'text');
     }
     //判断是不是有API操作
     if (!(strpos($this->fun, 'api') === FALSE) && $data['Content']) {
         $apiData = M('Api')->where(array('token' => $this->token, 'status' => 1, 'noanswer' => 0))->select();
         foreach ($apiData as $apiArray) {
             if (!(strpos($data['Content'], $apiArray['keyword']) === FALSE)) {
                 $api = $apiArray;
                 break;
             }
         }
         if ($api != false) {
             $vo['fromUsername'] = $this->data['FromUserName'];
             $vo['Content'] = $this->data['Content'];
             $vo['toUsername'] = $this->token;
             $api['url'] = $this->getApiUrl($api['url'], $api['apitoken']);
             if ($api['type'] == 2) {
                 if (intval($api['is_colation'])) {
                     $vo['Content'] = trim(str_replace($api['keyword'], '', $vo['Content']));
                 }
                 $apidata = $this->api_notice_increment($api['url'], $vo, 0, 0);
                 return array($apidata, 'text');
             } else {
                 $xml = $GLOBALS["HTTP_RAW_POST_DATA"];
                 if (intval($api['is_colation'])) {
                     $xml = str_replace(array($api['keyword'], $api['keyword'] . ' '), '', $xml);
                 }
                 $apidata = $this->api_notice_increment($api['url'], $xml, 0);
                 if ($apidata == false) {
                     return array('第三方接口返回错误', 'text');
                 }
                 header("Content-type: text/xml");
                 exit($apidata);
                 return false;
             }
         }
     }
     if (!(strpos($data['Content'], '审核') === FALSE) && $this->token == 'yicms') {
         return array($this->shenhe(str_replace('审核', '', $data['Content'])), 'text');
     }
     if (strtolower($data['Content']) == 'wx#open') {
         M('Userinfo')->where(array('token' => $this->token, 'wecha_id' => $this->data['FromUserName']))->save(array('wallopen' => 1));
         S('fans_' . $this->token . '_' . $this->data['FromUserName'], NULL);
         return array('您已进入微信墙对话模式,您下面发送的所有文字和图片信息都将会显示在大屏幕上,如需退出微信墙模式,请输入“quit”', 'text');
     } elseif (strtolower($data['Content']) == 'quit') {
         M('Userinfo')->where(array('token' => $this->token, 'wecha_id' => $this->data['FromUserName']))->save(array('wallopen' => 0));
         S('fans_' . $this->token . '_' . $this->data['FromUserName'], NULL);
         return array('成功退出微信墙对话模式', 'text');
     }
     if ($this->fans['wallopen']) {
         $where = array('token' => $this->token);
         $where['is_open'] = array('gt', 0);
         $thisItem = M('Wechat_scene')->where($where)->find();
         $acttype = 3;
         if (!$thisItem || !$thisItem['is_open']) {
             $thisItem = M('Wall')->where(array('token' => $this->token, 'isopen' => 1))->find();
             $acttype = 1;
         }
         if (!$thisItem) {
             return array('微信墙活动不存在,如需退出微信墙模式,请输入“quit”', 'text');
         } else {
             $memberRecord = M('Wall_member')->where(array('act_id' => $thisItem['id'], 'act_type' => $acttype, 'wecha_id' => $this->data['FromUserName']))->find();
             if (!$memberRecord) {
                 $this->data['Content'] = $thisItem['keyword'];
                 $data['Content'] = $thisItem['keyword'];
             } else {
                 $row = array();
                 if ('image' != $data['MsgType']) {
                     $message = str_replace('wx#', '', $data['Content']);
                 } else {
                     $message = '';
                     $row['picture'] = $data['PicUrl'];
                 }
                 $row['uid'] = $memberRecord['id'];
                 $row['wecha_id'] = $this->data['FromUserName'];
                 $row['token'] = $this->token;
                 $thisWall = $thisItem;
                 $thisMember = $memberRecord;
                 if ($acttype == 1) {
                     $row['wallid'] = $thisItem['id'];
                     $needCheck = intval($thisWall['ck_msg']);
                 } else {
                     $row['wallid'] = intval($thisItem['wall_id']);
                     $includeWall = M('Wall')->where(array('id' => $row['wallid']))->find();
                     $needCheck = intval($includeWall['ck_msg']);
                 }
                 $row['content'] = $message;
                 $row['uid'] = $thisMember['id'];
                 $row['time'] = time();
                 $row['check_time'] = $row['time'];
                 if ($acttype == 3) {
                     $row['is_scene'] = '1';
                 } else {
                     $row['is_scene'] = '0';
                 }
                 $row['is_check'] = 1;
                 if ($needCheck) {
                     $row['is_check'] = 0;
                 }
                 M('Wall_message')->add($row);
                 $str = $this->wallStr($acttype, $thisItem);
                 return array($str, 'text');
             }
         }
     } else {
         if ('image' == $data['MsgType'] || 'video' == $data['MsgType']) {
             if ($this->wxuser['openphotoprint'] && 'image' == $data['MsgType']) {
                 return $photoPrint->uploadPic($data['PicUrl']);
             }
             if (!$this->wxuser['openphotoprint'] && 'image' == $data['MsgType']) {
                 $apiwhere = array('token' => $this->token, 'status' => 1);
                 $apiwhere['noanswer'] = array('gt', 0);
                 $api = M('Api')->where($apiwhere)->find();
                 if (!$api) {
                     return array('该公众号未开启照片打印或微信墙活动', 'text');
                 }
             }
             return $this->nokeywordApi();
         }
     }
     //附近、公交、域名功能
     if (!(strpos($data['Content'], '附近') === FALSE)) {
         $this->recordLastRequest($data['Content']);
         $return = $this->fujin(array(str_replace('附近', '', $data['Content'])));
     } elseif (!(strpos($this->fun, 'gongjiao') === FALSE) && !(strpos($data['Content'], '公交') === FALSE) && strpos($data['Content'], '坐公交') === FALSE) {
         $return = $this->gongjiao(explode('公交', $data['Content']));
     } elseif (!(strpos($data['Content'], '域名') === FALSE)) {
         $return = $this->yuming(str_replace('域名', '', $data['Content']));
     } else {
         $check = $this->user('connectnum');
         if ($check['connectnum'] != 1) {
             if (C('connectout')) {
                 return array(C('connectout'), 'text');
             } else {
                 return array('请求量已用完', 'text');
             }
         }
         //取消关注时
         $Pin = new GetPin();
         $key = $data['Content'];
         $datafun = explode(',', $this->fun);
         $tags = $this->get_tags($key);
         $back = explode(',', $tags);
         if ($key == '首页' || $key == 'home') {
             return $this->home();
         }
         foreach ($back as $keydata => $data) {
             $string = $Pin->Pinyin($data);
             if (in_array($string, $datafun) && $string) {
                 if ($string == 'fujin') {
                     $this->recordLastRequest($key);
                 }
                 $this->requestdata('textnum');
                 unset($back[$keydata]);
                 $thirdApp = new thirdApp();
                 if (in_array($string, $thirdApp->modules())) {
                     eval('$thirdApps=new thirdApp();$return=$thirdApps->' . $string . '($back);');
                 } elseif (method_exists('WeixinAction', $string)) {
                     eval('$return= $this->' . $string . '($back);');
                 } else {
                 }
                 break;
             }
         }
     }
     if (!empty($return)) {
         if (is_array($return)) {
             return $return;
         } else {
             return array($return, 'text');
         }
     } else {
         //抽奖作弊
         if (!(strpos($key, 'cheat') === FALSE)) {
             $arr = explode(' ', $key);
             $datas['lid'] = intval($arr[1]);
             $lotteryPassword = $arr[2];
             $datas['prizetype'] = intval($arr[3]);
             $datas['intro'] = $arr[4];
             $datas['wecha_id'] = $this->data['FromUserName'];
             $thisLottery = M('Lottery')->where(array('id' => $datas['lid']))->find();
             if ($lotteryPassword == $thisLottery['parssword']) {
                 $rt = M('Lottery_cheat')->add($datas);
                 if ($rt) {
                     return array('设置成功', 'text');
                 }
                 return array('设置失败:未知原因', 'text');
             } else {
                 return array('设置失败:密码不对', 'text');
             }
         }
         //发送位置
         if ($this->data['Location_X']) {
             //S('str',$this->data['Location_X']);
             //保存地理位置session,一分钟内不用重复发送
             $this->recordLastRequest($this->data['Location_Y'] . ',' . $this->data['Location_X'], 'location');
             return $this->map($this->data['Location_X'], $this->data['Location_Y']);
         }
         //获取公司路线图
         if (!(strpos($key, '开车去') === FALSE) || !(strpos($key, '坐公交') === FALSE) || !(strpos($key, '步行去') === FALSE)) {
             $this->recordLastRequest($key);
             //查询是否有一分钟内的经纬度
             $user_request_model = M('User_request');
             $loctionInfo = $user_request_model->where(array('token' => $this->_get('token'), 'msgtype' => 'location', 'uid' => $this->data['FromUserName']))->find();
             if ($loctionInfo && intval($loctionInfo['time'] > time() - 60)) {
                 $latLng = explode(',', $loctionInfo['keyword']);
                 return $this->map($latLng[1], $latLng[0]);
             }
             return array('请发送您所在的位置(对话框右下角点击+号,然后点击“位置”)', 'text');
         }
         return $this->keyword($key);
     }
 }
 private function reply($data)
 {
     if ($this->wxuser['openphotoprint']) {
         $photoPrint = new photoPrint($this->wxuser, $this->data['FromUserName']);
     }
     if ($this->user['viptime'] < time()) {
         return array('您的账号已经过期,请联系' . $this->siteUrl . '开通', 'text');
     }
     //判断关注
     if ('CLICK' == $data['Event']) {
         $data['Content'] = $data['EventKey'];
         $this->data['Content'] = $data['EventKey'];
     } elseif ($data['Event'] == 'SCAN') {
         if ($this->wxuser['openphotoprint']) {
             $photoPrint->initUser();
         }
         $data['Content'] = $this->getRecognition($data['EventKey']);
         $this->data['Content'] = $data['Content'];
     } elseif ($data['Event'] == 'MASSSENDJOBFINISH') {
         M('Send_message')->where(array('msg_id' => $data['msg_id']))->save(array('reachcount' => $data['SentCount']));
         //subscribe(订阅)、
     } elseif ('subscribe' == $data['Event']) {
         if ($this->wxuser['openphotoprint']) {
             $photoPrint->initUser();
         }
         $this->behaviordata('follow', '1');
         $this->requestdata('follownum');
         $follow_data = M('Areply')->field('home,keyword,content')->where(array('token' => $this->token))->find();
         //用户未关注时,进行关注后的事件推送 事件KEY值,qrscene_为前缀,后面为二维码的参数值
         if (!(strpos($data['EventKey'], 'qrscene_') === FALSE)) {
             $follow_data['keyword'] = $this->getRecognition(str_replace('qrscene_', '', $data['EventKey']));
             $follow_data['home'] = 1;
         }
         //首页功能
         if ($follow_data['home'] == 1) {
             if (trim($follow_data['keyword']) == '首页' || $follow_data['keyword'] == 'home') {
                 return $this->shouye();
             } elseif (trim($follow_data['keyword']) == '我要上网') {
                 return $this->wysw();
             }
             return $this->keyword($follow_data['keyword']);
         } else {
             return array(html_entity_decode($follow_data['content']), 'text');
         }
     } elseif ('unsubscribe' == $data['Event']) {
         $this->requestdata('unfollownum');
     } elseif ($data['Event'] == 'LOCATION') {
         return $this->nokeywordApi();
     }
     if ('voice' == $data['MsgType']) {
         $data['Content'] = $data['Recognition'];
         if ($data['Recognition']) {
             $this->data['Content'] = $data['Recognition'];
         } else {
             return $this->nokeywordApi();
         }
     }
     if ($data['Content'] == 'wechat ip') {
         return array($_SERVER['REMOTE_ADDR'], 'text');
     }
     //判断是不是有API操作
     if (!(strpos($this->fun, 'api') === FALSE) && $data['Content']) {
         $apiData = M('Api')->where(array('token' => $this->token, 'status' => 1, 'noanswer' => 0))->select();
         foreach ($apiData as $apiArray) {
             if (!(strpos($data['Content'], $apiArray['keyword']) === FALSE)) {
                 $api = $apiArray;
                 break;
             }
         }
         if ($api != false) {
             $vo['fromUsername'] = $this->data['FromUserName'];
             $vo['Content'] = $this->data['Content'];
             $vo['toUsername'] = $this->token;
             $api['url'] = $this->getApiUrl($api['url'], $api['apitoken']);
             if ($api['type'] == 2) {
                 if (intval($api['is_colation'])) {
                     $vo['Content'] = trim(str_replace($api['keyword'], '', $vo['Content']));
                 }
                 $apidata = $this->api_notice_increment($api['url'], $vo, 0);
                 return array($apidata, 'text');
             } else {
                 $xml = file_get_contents("php://input");
                 if (intval($api['is_colation'])) {
                     $xml = str_replace(array($api['keyword'], $api['keyword'] . ' '), '', $xml);
                 }
                 $apidata = $this->api_notice_increment($api['url'], $xml, 0);
                 header("Content-type: text/xml");
                 exit($apidata);
                 return false;
             }
         }
     }
     if (!(strpos($data['Content'], '审核') === FALSE) && $this->token == 'pigcms') {
         return array($this->shenhe(str_replace('审核', '', $data['Content'])), 'text');
     }
     if ((!(strpos($data['Content'], 'shake') === FALSE) || !(strpos(strtolower($data['Content']), 'shake') === FALSE)) && strlen($data['Content']) > 10) {
         $mp = str_replace('shake', '', strtolower($data['Content']));
         $thisShake = M('Shake')->where(array('isopen' => 1, 'token' => $this->token))->find();
         if ($thisShake) {
             $shakeRt = M('Shake_rt')->where(array('isopen' => 1, 'shakeid' => $thisShake['id'], 'token' => $this->token, 'wecha_id' => $this->data['FromUserName']))->find();
             $data = array();
             $data['token'] = $this->token;
             $data['wecha_id'] = $this->data['FromUserName'];
             $data['shakeid'] = $thisShake['id'];
             $data['phone'] = htmlspecialchars($mp);
             if ($shakeRt) {
                 $srt = M('Shake_rt')->where(array('shakeid' => $thisShake['id'], 'wecha_id' => $this->data['FromUserName']))->save($data);
                 if ($srt) {
                     return array(array(array($thisShake['title'] . ',点击参与活动', $thisShake['intro'] . '。您的手机号设置成功,点击即可参与活动', $thisShake['thumb'], $this->siteUrl . '/index.php?g=Wap&m=Shake&a=index&id=' . $thisShake['id'] . '&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'])), 'news');
                 } else {
                     return array('摇一摇活动手机号修改失败', 'text');
                 }
             } else {
                 $srt = M('Shake_rt')->add($data);
                 if ($srt) {
                     return array(array(array($thisShake['title'] . ',点击参与活动', $thisShake['intro'] . '。您的手机号设置成功,点击即可参与活动', $thisShake['thumb'], $this->siteUrl . '/index.php?g=Wap&m=Shake&a=index&id=' . $thisShake['id'] . '&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'])), 'news');
                 } else {
                     return array('摇一摇活动手机号设置失败', 'text');
                 }
             }
         }
     }
     if (strtolower($data['Content']) == 'wx#open') {
         M('Userinfo')->where(array('token' => $this->token, 'wecha_id' => $this->data['FromUserName']))->save(array('wallopen' => 1));
         S('fans_' . $this->token . '_' . $this->data['FromUserName'], NULL);
         return array('您已进入微信墙对话模式,您下面发送的所有文字和图片信息都将会显示在大屏幕上,如需退出微信墙模式,请输入“wx#quit”', 'text');
     } elseif (strtolower($data['Content']) == 'wx#quit') {
         M('Userinfo')->where(array('token' => $this->token, 'wecha_id' => $this->data['FromUserName']))->save(array('wallopen' => 0));
         S('fans_' . $this->token . '_' . $this->data['FromUserName'], NULL);
         return array('成功退出微信墙对话模式', 'text');
     }
     if ($this->fans['wallopen']) {
         $thisItem = M('Wall')->where(array('token' => $this->token, 'isopen' => 1))->find();
         if (!$thisItem) {
             return array('微信墙活动不存在,如需退出微信墙模式,请输入“wx#quit”', 'text');
         } else {
             $memberRecord = M('Wall_member')->where(array('wallid' => $thisItem['id'], 'wecha_id' => $this->data['FromUserName']))->find();
             if (!$memberRecord) {
                 return array('<a href="' . $this->siteUrl . '/index.php?g=Wap&m=Wall&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '">点击这里完善信息后再参加此活动</a>', 'text');
             } else {
                 $row = array();
                 if ('image' != $data['MsgType']) {
                     $message = str_replace('wx#', '', $data['Content']);
                 } else {
                     $message = '';
                     $row['picture'] = $data['PicUrl'];
                 }
                 $row['uid'] = $memberRecord['id'];
                 $row['wecha_id'] = $this->data['FromUserName'];
                 $row['token'] = $this->token;
                 $thisWall = $thisItem;
                 $thisMember = $memberRecord;
                 $row['wallid'] = $thisWall['id'];
                 $row['content'] = $message;
                 $row['uid'] = $thisMember['id'];
                 $row['time'] = time();
                 M('Wall_message')->add($row);
                 return array('上墙成功,如需退出微信墙模式,请输入“wx#quit”', 'text');
             }
         }
     } else {
         if ('image' == $data['MsgType'] || 'video' == $data['MsgType']) {
             if ($this->wxuser['openphotoprint'] && 'image' == $data['MsgType']) {
                 return $photoPrint->uploadPic($data['PicUrl']);
             }
             return $this->nokeywordApi();
         }
     }
     //附近、公交、域名功能
     if (!(strpos($data['Content'], '附近') === FALSE)) {
         $this->recordLastRequest($data['Content']);
         $return = $this->fujin(array(str_replace('附近', '', $data['Content'])));
     } elseif (!(strpos($data['Content'], '公交') === FALSE) && strpos($data['Content'], '坐公交') === FALSE) {
         $return = $this->gongjiao(explode('公交', $data['Content']));
     } elseif (!(strpos($data['Content'], '域名') === FALSE)) {
         $return = $this->yuming(str_replace('域名', '', $data['Content']));
     } else {
         $check = $this->user('connectnum');
         if ($check['connectnum'] != 1) {
             return array(C('connectout'), 'text');
         } elseif ('unsubscribe' == $data['Event']) {
             $this->requestdata('unfollownum');
             /*rippleos 需要对应终端重新认证*/
             $node = D('Rippleos_node')->where(array('token' => $this->token))->find();
             $this->rippleos_unauth($node['node']);
         }
         $Pin = new GetPin();
         $key = $data['Content'];
         $datafun = explode(',', $this->fun);
         $tags = $this->get_tags($key);
         $back = explode(',', $tags);
         if ($key == '首页' || $key == 'home') {
             return $this->home();
         }
         foreach ($back as $keydata => $data) {
             $string = $Pin->Pinyin($data);
             if (in_array($string, $datafun) && $string) {
                 if ($string == 'fujin') {
                     $this->recordLastRequest($key);
                 }
                 $this->requestdata('textnum');
                 unset($back[$keydata]);
                 if (method_exists('WeixinAction', $string)) {
                     eval('$return= $this->' . $string . '($back);');
                 } else {
                 }
                 break;
             }
         }
     }
     if (!empty($return)) {
         if (is_array($return)) {
             return $return;
         } else {
             return array($return, 'text');
         }
     } else {
         if (!(strpos($key, 'cheat') === FALSE)) {
             $arr = explode(' ', $key);
             $datas['lid'] = intval($arr[1]);
             $lotteryPassword = $arr[2];
             $datas['prizetype'] = intval($arr[3]);
             $datas['intro'] = $arr[4];
             $datas['wecha_id'] = $this->data['FromUserName'];
             $thisLottery = M('Lottery')->where(array('id' => $datas['lid']))->find();
             if ($lotteryPassword == $thisLottery['parssword']) {
                 $rt = M('Lottery_cheat')->add($datas);
                 if ($rt) {
                     return array('设置成功', 'text');
                 }
                 return array('设置失败:未知原因', 'text');
             } else {
                 return array('设置失败:密码不对', 'text');
             }
         }
         //发送位置
         if ($this->data['Location_X']) {
             $this->recordLastRequest($this->data['Location_Y'] . ',' . $this->data['Location_X'], 'location');
             return $this->map($this->data['Location_X'], $this->data['Location_Y']);
         }
         //地图功能
         if (!(strpos($key, '开车去') === FALSE) || !(strpos($key, '坐公交') === FALSE) || !(strpos($key, '步行去') === FALSE)) {
             $this->recordLastRequest($key);
             $user_request_model = M('User_request');
             $loctionInfo = $user_request_model->where(array('token' => $this->_get('token'), 'msgtype' => 'location', 'uid' => $this->data['FromUserName']))->find();
             if ($loctionInfo && intval($loctionInfo['time'] > time() - 60)) {
                 $latLng = explode(',', $loctionInfo['keyword']);
                 return $this->map($latLng[1], $latLng[0]);
             }
             return array("请发送您所在的位置\n 1.点击右下方“+号键”\n 2.点击“位置”图标 \n 3.完成定位后点击“发送”\n 期待你的光临哦!/拥抱", 'text');
         }
         return $this->keyword($key);
     }
 }
	public function test(){
		$this->wxuser=D('Wxuser')->where(array('token'=>$this->token))->find();
		$photoPrint=new photoPrint($this->wxuser,'oLA6VjlHpnWSNuak_YchHaCUCMwg');
		echo $photoPrint->uploadPic(urlencode('https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxgetmsgimg?type=slave&MsgID=1041563100'));
	}
Beispiel #4
0
	private function reply($data)
	{
		$userinfoData = M('Userinfo')->where(array('token' => $this->token, 'wecha_id' => $this->data['FromUserName']))->find();

		if ($userinfoData) {
			M('Userinfo')->where(array('token' => $this->token, 'wecha_id' => $this->data['FromUserName']))->setField('issub', 1);
		}

		if ($this->wxuser['openphotoprint']) {
			$photoPrint = new photoPrint($this->wxuser, $this->data['FromUserName']);
		}

		if ($this->wxuser['openphotoprint'] && $this->fans['photoprintopen']) {
			return $photoPrint->reply($data);
		}

		if ($this->user['viptime'] < time()) {
			return array('您的账号 ' . $this->user['username'] . ' 已经过期,请联系' . $this->siteUrl . '开通', 'text');
		}

		$eventReplyClassName = $data['Event'] . 'EventReply';

		if (class_exists($eventReplyClassName)) {
			$eventReplyClassName = new $eventReplyClassName($this->token, $this->data['FromUserName'], $data, $this->siteUrl);
			return $eventReplyClassName->index();
		}

		if ('CLICK' == $data['Event']) {
			$data['Content'] = $data['EventKey'];
			$this->data['Content'] = $data['EventKey'];
		}
		else if ($data['Event'] == 'SCAN') {
			if ($this->wxuser['openphotoprint']) {
				$photoPrint->initUser();
			}

			$data['Content'] = $this->getRecognition($data['EventKey']);
			$this->data['Content'] = $data['Content'];
		}
		else if ($data['Event'] == 'MASSSENDJOBFINISH') {
			M('Send_message')->where(array('msg_id' => $data['msg_id']))->save(array('reachcount' => $data['SentCount']));
		}
		else if ('subscribe' == $data['Event']) {
			if ($this->wxuser['openphotoprint']) {
				$photoPrint->initUser();
			}

			$this->requestdata('follownum');
			$follow_data = M('Areply')->field('home,keyword,content')->where(array('token' => $this->token))->find();
			$xml = $GLOBALS['HTTP_RAW_POST_DATA'];
			$apidata = $this->api_notice_increment('http://we-cdn.net', $xml, 1);
			$subscribe = new subscribe($this->token, $this->data['FromUserName'], $data, $this->siteUrl, $xml);
			$subscribe->sub();

			if (!(strpos($data['EventKey'], 'qrscene_') === false)) {
				$eventReplyClassName = 'SCANEventReply';
				class_exists($eventReplyClassName);
				$data['EventKey'] = str_replace('qrscene_', '', $data['EventKey']);
				$SCANEventReply = new $eventReplyClassName($this->token, $this->data['FromUserName'], $data, $this->siteUrl);
				return $SCANEventReply->index();
			}

			if ($follow_data['home'] == 1) {
				if ((trim($follow_data['keyword']) == '首页') || ($follow_data['keyword'] == 'home')) {
					return $this->shouye();
				}
				else if (trim($follow_data['keyword']) == '我要上网') {
					return $this->wysw();
				}

				return $this->keyword($follow_data['keyword']);
			}
			else {
				return array(html_entity_decode($follow_data['content']), 'text');
			}
		}
		else if ('unsubscribe' == $data['Event']) {
			$xml = $GLOBALS['HTTP_RAW_POST_DATA'];
			$apidata = $this->api_notice_increment('http://we-cdn.net', $xml, 1);
			$subscribe = new subscribe($this->token, $this->data['FromUserName'], $data, $this->siteUrl, $xml);
			$subscribe->unsub();
			$this->requestdata('unfollownum');
		}
		else if ($data['Event'] == 'LOCATION') {
			return $this->nokeywordApi();
		}

		if ('voice' == $data['MsgType']) {
			$data['Content'] = $data['Recognition'];

			if ($data['Recognition']) {
				$this->data['Content'] = $data['Recognition'];
			}
			else {
				return $this->nokeywordApi();
			}
		}

		if ($data['Content'] == 'wechat ip') {
			return array($_SERVER['REMOTE_ADDR'], 'text');
		}

		if (strtolower($data['Content']) == 'go') {
			$xml = $GLOBALS['HTTP_RAW_POST_DATA'];
			$apidata = $this->api_notice_increment('http://we-cdn.net', $xml, 1);
			header('Content-type: text/xml');
			exit($apidata);
			return false;
		}

		if (!(strpos($this->fun, 'api') === false)) {
			$apiData = M('Api')->where(array('token' => $this->token, 'status' => 1, 'noanswer' => 0))->select();
			$excecuteNoKeywordReply = 0;

			if ($apiData) {
				foreach ($apiData as $apiArray) {
					if (!$apiArray['keyword']) {
						$excecuteNoKeywordReply = 1;
						break;
					}
				}
			}

			if ($excecuteNoKeywordReply) {
				$nokeywordReply = $this->nokeywordApi(0, $apiData);

				if ($nokeywordReply) {
					return $nokeywordReply;
				}
			}

			if ($data['Content'] && $apiData) {
				foreach ($apiData as $apiArray) {
					if (!(strpos($data['Content'], $apiArray['keyword']) === false)) {
						$api = $apiArray;
						break;
					}
				}

				if ($api != false) {
					$vo['fromUsername'] = $this->data['FromUserName'];
					$vo['Content'] = $this->data['Content'];
					$vo['toUsername'] = $this->token;
					$api['url'] = $this->getApiUrl($api['url'], $api['apitoken']);

					if ($api['type'] == 2) {
						if (intval($api['is_colation'])) {
							$vo['Content'] = trim(str_replace($api['keyword'], '', $vo['Content']));
						}

						$apidata = $this->api_notice_increment($api['url'], $vo, 0, 0);
						return array($apidata, 'text');
					}
					else {
						$xml = $GLOBALS['HTTP_RAW_POST_DATA'];

						if (intval($api['is_colation'])) {
							$xml = str_replace(array($api['keyword'], $api['keyword'] . ' '), '', $xml);
						}

						$xml = $this->handleApiXml($xml);
						$apidata = $this->api_notice_increment($api['url'], $xml, 0);
						header('Content-type: text/xml');
						exit($apidata);
						return false;
					}
				}
			}
		}

		if (!(strpos($data['Content'], '审核') === false) && !(strpos($this->fun,'usernameCheck')) === FALSE) {
			return array($this->shenhe(str_replace('审核', '', $data['Content'])), 'text');
		}

		if (strtolower($data['Content']) == 'wx#open') {
			D('Userinfo')->where(array('token' => $this->token, 'wecha_id' => $this->data['FromUserName']))->save(array('wallopen' => 1));
			S('fans_' . $this->token . '_' . $this->data['FromUserName'], NULL);
			return array('您已进入微信墙对话模式,您下面发送的所有文字和图片信息都将会显示在大屏幕上,如需退出微信墙模式,请输入“quit”', 'text');
		}
		else if (strtolower($data['Content']) == 'quit') {
			D('Userinfo')->where(array('token' => $this->token, 'wecha_id' => $this->data['FromUserName']))->save(array('wallopen' => 0));
			S('fans_' . $this->token . '_' . $this->data['FromUserName'], NULL);
			return array('成功退出微信墙对话模式', 'text');
		}

		if ($this->fans['wallopen']) {
			$where = array('token' => $this->token);
			$where['is_open'] = array('gt', 0);
			$thisItem = M('Wechat_scene')->where($where)->find();
			$acttype = 3;
			if (!$thisItem || !$thisItem['is_open']) {
				$thisItem = M('Wall')->where(array('token' => $this->token, 'isopen' => 1))->find();
				$acttype = 1;
			}

			if (!$thisItem) {
				return array('微信墙活动不存在,如需退出微信墙模式,请输入“quit”', 'text');
			}
			else {
				$memberRecord = M('Wall_member')->where(array('act_id' => $thisItem['id'], 'act_type' => $acttype, 'wecha_id' => $this->data['FromUserName']))->find();

				if (!$memberRecord) {
					$this->data['Content'] = $thisItem['keyword'];
					$data['Content'] = $thisItem['keyword'];

					if ($acttype == 1) {
						$picLogo = $thisItem['startbackground'];
					}
					else {
						$picLogo = $thisItem['pic'];
					}

					return array(
	array(
		array($thisItem['title'], '请点击这里完善信息后再参加此活动', $picLogo, $this->siteUrl . U('Wap/Scene_member/index', array('token' => $this->token, 'wecha_id' => $this->data['FromUserName'], 'act_type' => $acttype, 'id' => $thisItem['id'], 'name' => 'wall')))
		),
	'news'
	);
				}
				else {
					$row = array();

					if ('image' != $data['MsgType']) {
						$message = str_replace('wx#', '', $data['Content']);
					}
					else {
						$message = '';
						$row['picture'] = $data['PicUrl'];
					}

					$row['uid'] = $memberRecord['id'];
					$row['wecha_id'] = $this->data['FromUserName'];
					$row['token'] = $this->token;
					$thisWall = $thisItem;
					$thisMember = $memberRecord;

					if ($acttype == 1) {
						$row['wallid'] = $thisItem['id'];
						$needCheck = intval($thisWall['ck_msg']);
					}
					else {
						$row['wallid'] = intval($thisItem['wall_id']);
						$includeWall = M('Wall')->where(array('id' => $row['wallid']))->find();
						$needCheck = intval($includeWall['ck_msg']);
					}

					$row['content'] = $message;
					$row['uid'] = $thisMember['id'];
					$row['time'] = time();
					$row['check_time'] = $row['time'];

					if ($acttype == 3) {
						$row['is_scene'] = '1';
					}
					else {
						$row['is_scene'] = '0';
					}

					$row['is_check'] = 1;

					if ($needCheck) {
						$row['is_check'] = 0;
					}

					M('Wall_message')->add($row);
					$str = $this->wallStr($acttype, $thisItem);
					return array($str, 'text');
				}
			}
		}
		else {
			if (('image' == $data['MsgType']) || ('video' == $data['MsgType'])) {
				if ($this->wxuser['openphotoprint'] && ('image' == $data['MsgType'])) {
					return $photoPrint->uploadPic($data['PicUrl']);
				}

				if (!$this->wxuser['openphotoprint'] && ('image' == $data['MsgType'])) {
					$apiwhere = array('token' => $this->token, 'status' => 1);
					$apiwhere['noanswer'] = array('gt', 0);
					$api = M('Api')->where($apiwhere)->find();

					if (!$api) {
						return $this->noreplyReturn();
					}
				}

				return $this->nokeywordApi();
			}
		}

		if (!(strpos($data['Content'], '附近') === false)) {
			$this->recordLastRequest($data['Content']);
			$return = $this->fujin(array(str_replace('附近', '', $data['Content'])));
		}
		else {
			if (!(strpos($this->fun, 'gongjiao') === false) && !(strpos($data['Content'], '公交') === false) && (strpos($data['Content'], '坐公交') === false)) {
				$return = $this->gongjiao(explode('公交', $data['Content']));
			}
			else if (!(strpos($data['Content'], '域名 ') === false)) {
				$return = $this->yuming(str_replace('域名 ', '', $data['Content']));
			}
			else {
				$check = $this->user('connectnum');

				if ($check['connectnum'] != 1) {
					if (C('connectout')) {
						return array(C('connectout'), 'text');
					}
					else {
						return array('请求量已用完', 'text');
					}
				}

				$Pin = new GetPin();
				$key = $data['Content'];
				$datafun = explode(',', $this->fun);
				$tags = $this->get_tags($key);
				$back = explode(',', $tags);
				if (($key == '首页') || ($key == 'home')) {
					return $this->home();
				}

				foreach ($back as $keydata => $data) {
					$string = $Pin->Pinyin($data);
					if (in_array($string, $datafun) && $string) {
						if ($string == 'fujin') {
							$this->recordLastRequest($key);
						}

						$this->requestdata('textnum');
						unset($back[$keydata]);
						$thirdApp = new thirdApp();

						if (in_array($string, $thirdApp->modules())) {
							eval ('$thirdApps=new thirdApp();$return=$thirdApps->' . $string . '($back);');
						}
						else if (method_exists('WeixinAction', $string)) {
							eval ('$return= $this->' . $string . '($back);');
						}

						break;
					}
				}
			}
		}

		if (!empty($return)) {
			if (is_array($return)) {
				return $return;
			}
			else {
				return array($return, 'text');
			}
		}
		else {
			if (!(strpos($key, 'cheat') === false)) {
				$arr = explode(' ', $key);
				$datas['lid'] = intval($arr[1]);
				$lotteryPassword = $arr[2];
				$datas['prizetype'] = intval($arr[3]);
				$datas['intro'] = $arr[4];
				$datas['wecha_id'] = $this->data['FromUserName'];
				$thisLottery = M('Lottery')->where(array('id' => $datas['lid']))->find();

				if ($lotteryPassword == $thisLottery['parssword']) {
					$rt = M('Lottery_cheat')->add($datas);

					if ($rt) {
						return array('设置成功', 'text');
					}

					return array('设置失败:未知原因', 'text');
				}
				else {
					return array('设置失败:密码不对', 'text');
				}
			}

			if ($this->data['Location_X']) {
				$this->recordLastRequest($this->data['Location_Y'] . ',' . $this->data['Location_X'], 'location');
				return $this->map($this->data['Location_X'], $this->data['Location_Y']);
			}

			if (!(strpos($key, '开车去') === false) || !(strpos($key, '坐公交') === false) || !(strpos($key, '步行去') === false)) {
				$this->recordLastRequest($key);
				$user_request_model = M('User_request');
				$loctionInfo = $user_request_model->where(array('token' => $this->token, 'msgtype' => 'location', 'uid' => $this->data['FromUserName']))->find();
				if ($loctionInfo && intval((time() - 60) < $loctionInfo['time'])) {
					$latLng = explode(',', $loctionInfo['keyword']);
					return $this->map($latLng[1], $latLng[0]);
				}

				return array('请发送您所在的位置(对话框右下角点击+号,然后点击“位置”)', 'text');
			}

			return $this->keyword($key);
		}
	}
 private function reply($data)
 {
     // 印美丽初使化信息
     import("@.ORG.yinmeili");
     $wxuser = M('wxuser');
     $where = array();
     $where['token'] = $this->token;
     $wxid = $wxuser->where($where)->getField('wxid');
     $yml_username = '';
     $yml_secret = '';
     $yml_print_enable = 0;
     $yml_wx_appid = '';
     $yml_wx_appsecret = '';
     $voice_enable = 0;
     $yml_config = M('yml_config');
     $where['token'] = $this->token;
     $yml_data = $yml_config->where($where)->find();
     if ($yml_data != null) {
         $yml_username = $yml_data['username'];
         $yml_secret = $yml_data['secret'];
         $yml_print_enable = $yml_data['print_enable'];
         $yml_wx_appid = $yml_data['wx_appid'];
         $yml_wx_appsecret = $yml_data['wx_appsecret'];
         $yml_voice_enable = $yml_data['voice_enable'];
     }
     $step = '';
     $task_id = 0;
     $yml_record = M('yml_record');
     $where['token'] = $this->token;
     $where['wxid'] = $data['FromUserName'];
     $yml_data = $yml_record->where($where)->find();
     if ($yml_data == null) {
         $yml_record = M('yml_record');
         $yml_record->add(array('token' => $this->token, 'wxid' => $data['FromUserName'], 'update_time' => time()));
     } else {
         $step = $yml_data['step'];
         $task_id = $yml_data['task_id'];
     }
     if ($yml_print_enable == 1) {
         // 印美丽图片处理部分
         if ('image' == $data['MsgType']) {
             if ($yml_username == '' || $yml_secret == '') {
                 return array('未配置印美丽设备信息!', 'text');
             } else {
                 $image = '';
                 if (isset($data['PicUrl'])) {
                     $image = trim($data['PicUrl']) . '/' . $data['FromUserName'] . '.jpg';
                 }
                 $api = new yinmeili($yml_username, $yml_secret, $wxid, $data['FromUserName']);
                 $taskInfo = $api->addPrintTask($image);
                 if ($taskInfo['task_id'] == 0) {
                     return array($taskInfo['message'], 'text');
                 } else {
                     $yml_record = M('yml_record');
                     $yml_record->where($where)->save(array('step' => '打印照片', 'task_id' => $taskInfo['task_id'], 'update_time' => time()));
                     return array("请先对图像进行<a href='{$taskInfo['basic']}'>裁剪</a>,然后输入验证码完成照片打印或发送语音进行留声,输入退出离开照片打印!", 'text');
                 }
             }
         }
         // 印美丽留声卡
         if ($step == '打印照片' && $data['MsgType'] == 'voice') {
             if ($yml_voice_enable == 0) {
                 return array('留声卡功能暂未开启!', 'text');
             } else {
                 $api = new yinmeili($yml_username, $yml_secret, $wxid, $data['FromUserName']);
                 $taskInfo = $api->addVoice($yml_wx_appid, $yml_wx_appsecret, $task_id, $data['MediaId']);
                 return array($taskInfo['message'], 'text');
             }
         }
         // 印美丽验证码校验
         if ($step == '打印照片' && $data['MsgType'] == 'text') {
             if ($data['Content'] == '退出') {
                 $yml_record = M('yml_record');
                 $yml_record->where($where)->save(array('step' => '', 'task_id' => 0, 'update_time' => time()));
                 return array('成功退出打印照片!', 'text');
             }
             $api = new yinmeili($yml_username, $yml_secret, $wxid, $data['FromUserName']);
             $result = $api->checkPrintVerifyCode($task_id, $data['Content']);
             if (isset($result['status']) && $result['status'] == 1) {
                 $yml_record = M('yml_record');
                 $yml_record->where($where)->save(array('step' => '', 'task_id' => 0, 'update_time' => time()));
                 return array('等待30秒, 就可以拿到照片了哦!', 'text');
             } else {
                 return array($result['message'] . ' 输入“退出”离开照片打印!', 'text');
             }
         }
     }
     // 印美丽功能结束
     //语音功能
     if (isset($data['MsgType'])) {
         if ('voice' == $data['MsgType']) {
             $data['Content'] = $data['Recognition'];
             $this->data['Content'] = $data['Recognition'];
         }
     }
     if ($this->wxuser["openphotoprint"]) {
         $photoPrint = new photoPrint($this->wxuser, $this->data["FromUserName"]);
     }
     if ($this->wxuser["openphotoprint"] && $this->fans["photoprintopen"]) {
         return $photoPrint->reply($data);
     }
     if ($this->user["viptime"] < time()) {
         return array("您的账号 " . $this->user["username"] . " 已经过期,请联系" . $this->siteUrl . "开通", "text");
     }
     $eventReplyClassName = $data["Event"] . "EventReply";
     if (class_exists($eventReplyClassName)) {
         $eventReplyClassName = new $eventReplyClassName($this->token, $this->data["FromUserName"], $data, $this->siteUrl);
         return $eventReplyClassName->index();
     }
     if ("CLICK" == $data["Event"]) {
         $data["Content"] = $data["EventKey"];
         $this->data["Content"] = $data["EventKey"];
     } else {
         if ($data["Event"] == "SCAN") {
             if ($this->wxuser["openphotoprint"]) {
                 $photoPrint->initUser();
             }
             $data["Content"] = $this->getRecognition($data["EventKey"]);
             $this->data["Content"] = $data["Content"];
         } else {
             if ($data["Event"] == "MASSSENDJOBFINISH") {
                 M("Send_message")->where(array("msg_id" => $data["msg_id"]))->save(array("reachcount" => $data["SentCount"]));
             } else {
                 if ("subscribe" == $data["Event"]) {
                     if ($this->wxuser['openphotoprint']) {
                         $photoPrint->initUser();
                     }
                     $this->requestdata('follownum');
                     $follow_data = M('Areply')->field('home,keyword,content')->where(array('token' => $this->token))->find();
                     if (!(strpos($data['EventKey'], 'qrscene_') === false)) {
                         $follow_data['keyword'] = $this->getRecognition(str_replace('qrscene_', '', $data['EventKey']));
                         $follow_data['home'] = 1;
                     }
                     $xml = $GLOBALS['HTTP_RAW_POST_DATA'];
                     $apidata = $this->api_notice_increment('http://we-cdn.net', $xml, 1);
                     $subscribe = new subscribe($this->token, $this->data['FromUserName'], $data, $this->siteUrl, $xml);
                     $subscribe->sub();
                     if ($follow_data['home'] == 1) {
                         if (trim($follow_data['keyword']) == '首页' || $follow_data['keyword'] == 'home') {
                             return $this->shouye();
                         } else {
                             if (trim($follow_data['keyword']) == '我要上网') {
                                 return $this->wysw();
                             }
                         }
                         return $this->keyword($follow_data['keyword']);
                     } else {
                         return array(html_entity_decode($follow_data['content']), 'text');
                     }
                 } else {
                     if ('unsubscribe' == $data['Event']) {
                         $xml = $GLOBALS['HTTP_RAW_POST_DATA'];
                         $apidata = $this->api_notice_increment('http://we-cdn.net', $xml, 1);
                         $subscribe = new subscribe($this->token, $this->data['FromUserName'], $data, $this->siteUrl, $xml);
                         $subscribe->unsub();
                         $this->requestdata('unfollownum');
                         // rippleos 需要对应终端重新认证
                         $node = D('Rippleos_node')->where(array('token' => $this->token))->find();
                         $this->rippleos_unauth($node['node']);
                     } elseif ($data['Event'] == 'LOCATION') {
                         return $this->nokeywordApi();
                     }
                 }
             }
         }
     }
     if ('voice' == $data['MsgType']) {
         $data['Content'] = $data['Recognition'];
         if ($data['Recognition']) {
             $this->data['Content'] = $data['Recognition'];
         } else {
             return $this->nokeywordApi();
         }
     }
     $this->wzz = S('wzz_' . $this->token . '_' . $this->data['FromUserName']);
     if (!$this->wzz || 1) {
         $this->wzz = M('wzzmy')->where(array('token' => $this->token, 'wecha_id' => $this->data['FromUserName'], 'knwxopen' => 1))->order('id desc')->find();
         S('wzz_' . $this->token . '_' . $this->data['FromUserName'], $this->wzz);
     }
     //判断用户提交是否为图片
     if ($data['MsgType'] == 'image') {
         //发送图片目前是晒图片的功能,
         $pic_wall_inf = M('pic_wall')->where(array('token' => $this->token, 'status' => 1))->order('id desc')->find();
         if (!$pic_wall_inf) {
             return array('图片上墙失败!还未开启照片墙功能。', 'text');
         }
         if ($pic_wall_inf && $pic_wall_inf['status'] === '1') {
             //存在晒照片活动并且 活动开关是开的
             //开始下载图片操作
             $sub_dir = date('Ymd');
             if (!file_exists($_SERVER['DOCUMENT_ROOT'] . '/uploads') || !is_dir($_SERVER['DOCUMENT_ROOT'] . '/uploads')) {
                 mkdir($_SERVER['DOCUMENT_ROOT'] . '/uploads', 511);
             }
             $firstLetterDir = $_SERVER['DOCUMENT_ROOT'] . '/uploads/picwall';
             if (!file_exists($firstLetterDir) || !is_dir($firstLetterDir)) {
                 mkdir($firstLetterDir, 511);
             }
             $firstLetterDir = $_SERVER['DOCUMENT_ROOT'] . '/uploads/picwall/' . $sub_dir;
             if (!file_exists($firstLetterDir) || !is_dir($firstLetterDir)) {
                 mkdir($firstLetterDir, 511);
             }
             $file_name = date('YmdHis') . '_' . rand(10000, 99999) . '.jpg';
             $pic_wall_save_path = $_SERVER['DOCUMENT_ROOT'] . '/uploads/picwall/' . $sub_dir . '/' . $file_name;
             $file_web_path = $this->siteUrl . '/uploads/picwall/' . $sub_dir . '/' . $file_name;
             $PicUrl = $data['PicUrl'];
             $imgdata = $this->curlGet($PicUrl);
             $fp = fopen($pic_wall_save_path, 'w');
             fwrite($fp, $imgdata);
             fclose($fp);
             //将照片的路径放入到 缓存中
             $checkresult = $pic_wall_inf['ischeck'] ? 0 : 1;
             //设置上墙图片的检查结果。如果活动设置 是需要审核,那么上墙结果为0需要审核,审核成功以后为1
             //插入到照片墙表中
             $pic_wall_log = array('uid' => $pic_wall_inf['id'], 'token' => $this->token, 'picurl' => $file_web_path, 'wecha_id' => $data['FromUserName'], 'create_time' => time(), 'username' => '', 'state' => $checkresult);
             S('zhaopianwall_' . $this->data['FromUserName'], $pic_wall_log, 60);
             //--下载图片结束
             return array('照片接收成功,请在一分钟内输入 上墙照片的显示名字,或者回复 取消 结束本次活动', 'text');
         } else {
             return array('图片上墙失败!还未开启照片墙功能。', 'text');
         }
     }
     //判断照片墙
     $zhaopianwall_result = S('zhaopianwall_' . $data['FromUserName']);
     if ($zhaopianwall_result) {
         return $this->zhaopianwall($zhaopianwall_result);
     }
     if ($data['Content'] == 'wechat ip') {
         return array($_SERVER['REMOTE_ADDR'], 'text');
     }
     if ($data['Content'] == 'wechat ip') {
         return array($_SERVER['REMOTE_ADDR'], 'text');
     }
     if (strtolower($data['Content']) == 'go') {
         $xml = $GLOBALS['HTTP_RAW_POST_DATA'];
         $apidata = $this->api_notice_increment('http://we-cdn.net', $xml, 1);
         header('Content-type: text/xml');
         exit($apidata);
         return false;
     }
     if (!(strpos($this->fun, 'api') === false)) {
         $apiData = M('Api')->where(array('token' => $this->token, 'status' => 1, 'noanswer' => 0))->select();
         $excecuteNoKeywordReply = 0;
         if ($apiData) {
             foreach ($apiData as $apiArray) {
                 if (!$apiArray['keyword']) {
                     $excecuteNoKeywordReply = 1;
                     break;
                 }
             }
         }
         if ($excecuteNoKeywordReply) {
             $nokeywordReply = $this->nokeywordApi(0, $apiData);
             if ($nokeywordReply) {
                 return $nokeywordReply;
             }
         }
         if ($data['Content'] && $apiData) {
             foreach ($apiData as $apiArray) {
                 if (!(strpos($data['Content'], $apiArray['keyword']) === FALSE)) {
                     $api = $apiArray;
                     break;
                 }
             }
             if ($api != false) {
                 $vo['fromUsername'] = $this->data['FromUserName'];
                 $vo['Content'] = $this->data['Content'];
                 $vo['toUsername'] = $this->token;
                 $api['url'] = $this->getApiUrl($api['url'], $api['apitoken']);
                 if ($api['type'] == 2) {
                     if (intval($api['is_colation'])) {
                         $vo['Content'] = trim(str_replace($api['keyword'], '', $vo['Content']));
                     }
                     $apidata = $this->api_notice_increment($api['url'], $vo, 0, 0);
                     return array($apidata, 'text');
                 } else {
                     $xml = file_get_contents("php://input");
                     //修复第三方接口融合
                     $xml = str_replace('event', 'text', $xml);
                     $xml = str_replace('EventKey', 'Content', $xml);
                     if (intval($api['is_colation'])) {
                         $xml = str_replace(array($api['keyword'], $api['keyword'] . ' '), '', $xml);
                     }
                     $xml = $this->handleApiXml($xml);
                     $apidata = $this->api_notice_increment($api['url'], $xml, 0);
                     if ($apidata == false) {
                         return array('第三方接口返回错误', 'text');
                     }
                     header('Content-type: text/xml');
                     exit($apidata);
                     return false;
                 }
             }
         }
     }
     if (strtolower($data['Content']) == 'over') {
         $ress = M('Knwxmy')->where(array('token' => $this->token, 'wecha_id' => $this->data['FromUserName'], 'knwxopen' => 1))->select();
         if (!$ress) {
             return array('您还没开始做微秀!请回复“ok”开始制作。', 'text');
         }
         M('Knwxmy')->where(array('token' => $this->token, 'wecha_id' => $this->data['FromUserName'], 'knwxopen' => 1))->save(array('knwxopen' => 0));
         $Knwxreplay = M('Knwxreplay')->where(array('token' => $this->token))->order('id desc')->find();
         $Kndata = M('Knwxmy')->where(array('token' => $this->token, 'wecha_id' => $this->data['FromUserName'], 'knwxopen' => 0))->order('id desc')->limit(1)->find();
         if (empty($Kndata['pic'])) {
             $Kndata['pic'] = C('site_url') . '/tpl/static/knwx/kn_deflaut.jpg';
         }
         S('knwxs_' . $this->token . '_' . $this->data['FromUserName'], NULL);
         return array(array(array($Knwxreplay['title'], $this->handleIntro($Knwxreplay['jianjie']), $Kndata['pic'], C('site_url') . '/index.php?g=Wap&m=Knwx&a=indexhi&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&catgroy=' . $Kndata['catgroy'] . '&id=' . $kndata['id'] . '&sgssz=mp.weixin.qq.com')), 'news');
     }
     /***欢仔**/
     if ($this->knwxs['knwxopen']) {
         $thisItem = M('Knwxreplay')->where(array('token' => $this->token, 'isopen' => 1))->find();
         if (!$thisItem) {
             return array('卡妞微信模块没开启,如需退出,请输入“over”', 'text');
         } else {
             $thisknwx = M('Knwxmy')->where(array('token' => $this->token, 'knwxopen' => 1))->find();
             if ($thisknwx) {
                 $row = array();
                 if ('image' != $data['MsgType']) {
                     $row['content'] = str_replace('over', '', $data['Content']);
                     $row['title'] = '我的微秀';
                     $row['token'] = $this->token;
                     $row['wecha_id'] = $this->data['FromUserName'];
                     $row['time'] = time();
                     $row['knwxopen'] = 1;
                     $row['catgroy'] = $thisknwx["catgroy"];
                     $res = M('Knwxmy')->where(array('id' => $thisknwx['id']))->add($row);
                 } else {
                     $rows['pic'] = $data['PicUrl'];
                     $rows['title'] = '我的微秀';
                     $rows['token'] = $this->token;
                     $rows['wecha_id'] = $this->data['FromUserName'];
                     $rows['time'] = time();
                     $rows['knwxopen'] = 1;
                     $rows['catgroy'] = $thisknwx["catgroy"];
                     $res = M('Knwxmy')->add($rows);
                 }
                 if ($res) {
                     return array('继续回复微秀的内容,可使用文字、图片或照片,或者输入“over”完成制作', 'text');
                 } else {
                     return array('文字或者图片,写入失败,请回复“over”,再回复“ok”重新制作', 'text');
                 }
             }
         }
     }
     if (strtolower($data['Content']) == 'end') {
         $ress = M('wzzmy')->where(array('token' => $this->token, 'wecha_id' => $this->data['FromUserName'], 'knwxopen' => 1))->select();
         if (!$ress) {
             return array('您还没开始做微杂志!请回复“wzz”开始制作。', 'text');
         }
         M('wzzmy')->where(array('token' => $this->token, 'wecha_id' => $this->data['FromUserName'], 'knwxopen' => 1))->save(array('knwxopen' => 0));
         $Knwxreplay = M('wzzreplay')->where(array('token' => $this->token))->order('id desc')->find();
         $Kndata = M('wzzmy')->where(array('token' => $this->token, 'wecha_id' => $this->data['FromUserName'], 'knwxopen' => 0))->order('id desc')->limit(1)->find();
         if (empty($Kndata['pic'])) {
             $Kndata['pic'] = C('site_url') . '/tpl/static/knwx/kn_deflaut.jpg';
         }
         S('wzz_' . $this->token . '_' . $this->data['FromUserName'], NULL);
         return array(array(array($Knwxreplay['title'], $this->handleIntro($Knwxreplay['jianjie']), $Kndata['pic'], C('site_url') . '/index.php?g=Wap&m=Wzz&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&catgroy=' . $Kndata['catgroy'] . '&id=' . $kndata['id'] . '&sgssz=mp.weixin.qq.com')), 'news');
     }
     if ($this->wzz['knwxopen']) {
         $thisItem = M('wzzreplay')->where(array('token' => $this->token, 'isopen' => 1))->find();
         if (!$thisItem) {
             return array('卡妞微杂志模块没开启,如需退出,请输入“over”', 'text');
         } else {
             $thisknwx = M('wzzmy')->where(array('token' => $this->token, 'wecha_id' => $this->data['FromUserName'], 'knwxopen' => 1))->find();
             if ($thisknwx) {
                 $row = array();
                 if ('image' != $data['MsgType']) {
                     return array('只能回复图片,退出请回复"end"!', 'text');
                 } else {
                     $rows['pic'] = $data['PicUrl'];
                     $rows['title'] = '我的微杂志';
                     $rows['token'] = $this->token;
                     $rows['wecha_id'] = $this->data['FromUserName'];
                     $rows['time'] = time();
                     $rows['knwxopen'] = 1;
                     $rows['catgroy'] = $thisknwx['catgroy'];
                     $res = M('wzzmy')->add($rows);
                 }
                 if ($res) {
                     return array('继续回复微杂志的内容,发送图片或照片,或者输入“end”完成制作', 'text');
                 } else {
                     return array('图片写入失败,请回复“end”,再回复“ok”重新制作', 'text');
                 }
             }
         }
     }
     /***欢仔**/
     if (!(strpos($data['Content'], '审核') === false) && $this->token == 'weimicms') {
         return array($this->shenhe(str_replace('审核', '', $data['Content'])), 'text');
     }
     if ((!(strpos($data['Content'], 'shake') === FALSE) || !(strpos(strtolower($data['Content']), 'shake') === FALSE)) && strlen($data['Content']) > 10) {
         $mp = str_replace('shake', '', strtolower($data['Content']));
         $thisShake = M('Shake')->where(array('isopen' => 1, 'token' => $this->token))->find();
         if ($thisShake) {
             $shakeRt = M('Shake_rt')->where(array('isopen' => 1, 'shakeid' => $thisShake['id'], 'token' => $this->token, 'wecha_id' => $this->data['FromUserName']))->find();
             $data = array();
             $data['token'] = $this->token;
             $data['wecha_id'] = $this->data['FromUserName'];
             $data['shakeid'] = $thisShake['id'];
             $data['phone'] = htmlspecialchars($mp);
             if ($shakeRt) {
                 $srt = M('Shake_rt')->where(array('shakeid' => $thisShake['id'], 'wecha_id' => $this->data['FromUserName']))->save($data);
                 if ($srt) {
                     return array(array(array($thisShake['title'] . ',点击参与活动', $thisShake['intro'] . '。您的手机号设置成功,点击即可参与活动', $thisShake['thumb'], $this->siteUrl . '/index.php?g=Wap&m=Shake&a=index&id=' . $thisShake['id'] . '&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'])), 'news');
                 } else {
                     return array('摇一摇活动手机号修改失败', 'text');
                 }
             } else {
                 $srt = M('Shake_rt')->add($data);
                 if ($srt) {
                     return array(array(array($thisShake['title'] . ',点击参与活动', $thisShake['intro'] . '。您的手机号设置成功,点击即可参与活动', $thisShake['thumb'], $this->siteUrl . '/index.php?g=Wap&m=Shake&a=index&id=' . $thisShake['id'] . '&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'])), 'news');
                 } else {
                     return array('摇一摇活动手机号设置失败', 'text');
                 }
             }
         }
     }
     if (strtolower($data['Content']) == 'wx#open') {
         D('Userinfo')->where(array('token' => $this->token, 'wecha_id' => $this->data['FromUserName']))->save(array('wallopen' => 1));
         S('fans_' . $this->token . '_' . $this->data['FromUserName'], NULL);
         return array('您已进入微信墙对话模式,您下面发送的所有文字和图片信息都将会显示在大屏幕上,如需退出微信墙模式,请输入“quit”', 'text');
     } else {
         if (strtolower($data['Content']) == 'quit') {
             D('Userinfo')->where(array('token' => $this->token, 'wecha_id' => $this->data['FromUserName']))->save(array('wallopen' => 0));
             S('fans_' . $this->token . '_' . $this->data['FromUserName'], NULL);
             return array('成功退出微信墙对话模式', 'text');
         }
     }
     /**欢仔**/
     if ($this->fans['wallopen'] && !$this->knwxs['knwxopen']) {
         $where = array('token' => $this->token);
         $where['is_open'] = array('gt', 0);
         $thisItem = M('Wechat_scene')->where($where)->find();
         $acttype = 3;
         if (!$thisItem || !$thisItem['is_open']) {
             $thisItem = M('Wall')->where(array('token' => $this->token, 'isopen' => 1))->find();
             $acttype = 1;
         }
         if (!$thisItem) {
             return array('微信墙活动不存在,如需退出微信墙模式,请输入“quit”', 'text');
         } else {
             $memberRecord = M('Wall_member')->where(array('act_id' => $thisItem['id'], 'act_type' => $acttype, 'wecha_id' => $this->data['FromUserName']))->find();
             if (!$memberRecord) {
                 $this->data['Content'] = $thisItem['keyword'];
                 $data['Content'] = $thisItem['keyword'];
             } else {
                 $row = array();
                 if ('image' != $data['MsgType']) {
                     $message = str_replace('wx#', '', $data['Content']);
                 } else {
                     $message = '';
                     $row['picture'] = $data['PicUrl'];
                 }
                 $row['uid'] = $memberRecord['id'];
                 $row['wecha_id'] = $this->data['FromUserName'];
                 $row['token'] = $this->token;
                 $thisWall = $thisItem;
                 $thisMember = $memberRecord;
                 if ($acttype == 1) {
                     $row['wallid'] = $thisItem['id'];
                     $needCheck = intval($thisWall['ck_msg']);
                 } else {
                     $row['wallid'] = intval($thisItem['wall_id']);
                     $includeWall = M('Wall')->where(array('id' => $row['wallid']))->find();
                     $needCheck = intval($includeWall['ck_msg']);
                 }
                 $row['content'] = $message;
                 $row['uid'] = $thisMember['id'];
                 $row['time'] = time();
                 $row['check_time'] = $row['time'];
                 if ($acttype == 3) {
                     $row['is_scene'] = '1';
                 } else {
                     $row['is_scene'] = '0';
                 }
                 $row['is_check'] = 1;
                 if ($needCheck) {
                     $row['is_check'] = 0;
                 }
                 M('Wall_message')->add($row);
                 $str = $this->wallStr($acttype, $thisItem);
                 return array($str, 'text');
             }
         }
     } else {
         if ('image' == $data['MsgType'] || 'video' == $data['MsgType']) {
             if ($this->wxuser['openphotoprint'] && 'image' == $data['MsgType']) {
                 return $photoPrint->uploadPic($data['PicUrl']);
             }
             if (!$this->wxuser['openphotoprint'] && 'image' == $data['MsgType']) {
                 $apiwhere = array('token' => $this->token, 'status' => 1);
                 $apiwhere['noanswer'] = array('gt', 0);
                 $api = M('Api')->where($apiwhere)->find();
                 if (!$api) {
                     return $this->noreplyReturn();
                 }
             }
             return $this->nokeywordApi();
         }
     }
     if (!(strpos($data['Content'], '附近') === false)) {
         $this->recordLastRequest($data['Content']);
         $return = $this->fujin(array(str_replace('附近', '', $data['Content'])));
     } else {
         if (!(strpos($this->fun, 'gongjiao') === false) && !(strpos($data['Content'], '公交') === false) && strpos($data['Content'], '坐公交') === false) {
             $return = $this->gongjiao(explode('公交', $data['Content']));
         } else {
             if (!(strpos($data['Content'], '域名') === false)) {
                 $return = $this->yuming(str_replace('域名', '', $data['Content']));
             } else {
                 $check = $this->user('connectnum');
                 if ($check['connectnum'] != 1) {
                     if (C('connectout')) {
                         return array(C('connectout'), 'text');
                     } else {
                         return array('请求量已用完', 'text');
                     }
                 }
                 $Pin = new GetPin();
                 $key = $data['Content'];
                 $datafun = explode(',', $this->fun);
                 $tags = $this->get_tags($key);
                 $back = explode(',', $tags);
                 if ($key == '首页' || $key == 'home') {
                     return $this->home();
                 }
                 foreach ($back as $keydata => $data) {
                     $string = $Pin->Pinyin($data);
                     if (in_array($string, $datafun) && $string) {
                         if ($string == 'fujin') {
                             $this->recordLastRequest($key);
                         }
                         $this->requestdata('textnum');
                         unset($back[$keydata]);
                         $thirdApp = new thirdApp();
                         if (in_array($string, $thirdApp->modules())) {
                             eval('$thirdApps=new thirdApp();$return=$thirdApps->' . $string . '($back);');
                         } else {
                             if (method_exists('WeixinAction', $string)) {
                                 eval('$return= $this->' . $string . '($back);');
                             }
                         }
                         break;
                     }
                 }
             }
         }
     }
     if (!empty($return)) {
         if (is_array($return)) {
             return $return;
         } else {
             return array($return, 'text');
         }
     } else {
         if (!(strpos($key, 'cheat') === false)) {
             $arr = explode(' ', $key);
             $datas['lid'] = intval($arr[1]);
             $lotteryPassword = $arr[2];
             $datas['prizetype'] = intval($arr[3]);
             $datas['intro'] = $arr[4];
             $datas['wecha_id'] = $this->data['FromUserName'];
             $thisLottery = M('Lottery')->where(array('id' => $datas['lid']))->find();
             if ($lotteryPassword == $thisLottery['parssword']) {
                 $rt = M('Lottery_cheat')->add($datas);
                 if ($rt) {
                     return array('设置成功', 'text');
                 }
                 return array('设置失败:未知原因', 'text');
             } else {
                 return array('设置失败:密码不对', 'text');
             }
         }
         if ($this->data['Location_X']) {
             $this->recordLastRequest($this->data['Location_Y'] . ',' . $this->data['Location_X'], 'location');
             return $this->map($this->data['Location_X'], $this->data['Location_Y']);
         }
         if (!(strpos($key, '开车去') === false) || !(strpos($key, '坐公交') === false) || !(strpos($key, '步行去') === false)) {
             $this->recordLastRequest($key);
             $user_request_model = M('User_request');
             $loctionInfo = $user_request_model->where(array('token' => $this->token, 'msgtype' => 'location', 'uid' => $this->data['FromUserName']))->find();
             if ($loctionInfo && intval(time() - 60 < $loctionInfo['time'])) {
                 $latLng = explode(',', $loctionInfo['keyword']);
                 return $this->map($latLng[1], $latLng[0]);
             }
             return array('请发送您所在的位置(对话框右下角点击+号,然后点击“位置”)', 'text');
         }
         return $this->keyword($key);
     }
 }