public function testpinyin() { $Pin = new GetPin(); $string = $Pin->Pinyin('小萝莉'); var_export($string); }
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 ('CLICK' == $data['Event']) { $data['Content'] = $data['EventKey']; } if ('subscribe' == $data['Event']) { $follow_data['follow_form_id'] = $data['FromUserName']; $follow_data['follow_to_id'] = $data['ToUserName']; $follow_data['follow_time'] = $data['CreateTime']; $foloow_lists = M('Follow')->add($follow_data); $this->requestdata('follownum'); $data = M('Areply')->field('home,keyword,content')->where(array('token' => $this->token))->find(); if ($data['keyword'] == '首页' || $data['keyword'] == 'home') { return $this->shouye(); } if ($data['home'] == 1) { $like['keyword'] = array('like', '%' . $data['keyword'] . '%'); $like['token'] = $this->token; $back = M('Img')->field('id,text,pic,url,title')->limit(9)->order('id desc')->where($like)->select(); foreach ($back as $keya => $infot) { if ($infot['url'] != false) { $url = $infot['url']; } else { $url = rtrim(C('site_url'), '/') . U('Wap/Index/content', array('token' => $this->token, 'id' => $infot['id'])); } $return[] = array($infot['title'], $infot['text'], $infot['pic'], $url); } return array($return, 'news'); } else { return array($data['content'], 'text'); } } elseif ('unsubscribe' == $data['Event']) { $follow_data['follow_form_id'] = $data['FromUserName']; $follow_data['follow_to_id'] = $data['ToUserName']; $foloow_del = M('Follow')->where($follow_data)->delete(); $this->requestdata('unfollownum'); } $Pin = new GetPin(); $key = $data['Content']; $open = M('Token_open')->where(array('token' => $this->_get('token')))->find(); $this->fun = $open['queryname']; $datafun = explode(',', $open['queryname']); $tags = $this->get_tags($key); $back = explode(',', $tags); foreach ($back as $keydata => $data) { $string = $Pin->Pinyin($data); if (in_array($string, $datafun)) { $check = $this->user('connectnum'); if ($string == 'fujin') { $this->recordLastRequest($key); } $this->requestdata('textnum'); if ($check['connectnum'] != 1) { $return = C('connectout'); continue; } unset($back[$keydata]); eval('$return= $this->' . $string . '($back);'); continue; } } if (!empty($return)) { if (is_array($return)) { return $return; } else { return array($return, 'text'); } } else { 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('请发送您所在的位置', 'text'); } switch ($key) { case '摇一摇': return $this->shake(); break; case '首页': return $this->home(); break; case '商城': return $this->guanwang(); break; case '主页': return $this->home(); break; case '地图': return $this->companyMap(); case '最近的': $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'); break; case '笑话': return $this->xiaohua(); break; case '快递': return $this->kuaidi(); break; case '公交': return $this->gongjiao(); break; case '火车': return $this->huoche(); break; case 'help': return $this->help(); break; case '会员卡': return $this->member(); break; case '身份证': return $this->shenfenzheng(); break; case '会员': return $this->member(); break; case '3g相册': return $this->xiangce(); break; case '相册': return $this->xiangce(); break; case '全景': $pro = M('reply_info')->where(array('infotype' => 'Panorama', 'token' => $this->token))->find(); return array(array(array($pro['title'], strip_tags(htmlspecialchars_decode($pro['info'])), $pro['picurl'], C('site_url') . '/index.php?g=Wap&m=Panorama&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'])), 'news'); break; case '留言': $pro = M('reply_info')->where(array('infotype' => 'Liuyan', 'token' => $this->token))->find(); return array(array(array($pro['title'], strip_tags(htmlspecialchars_decode($pro['info'])), $pro['picurl'], C('site_url') . '/index.php?g=Wap&m=Liuyan&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'])), 'news'); break; case '预约': $pro = M('reply_info')->where(array('infotype' => 'Yuyue', 'token' => $this->token))->find(); return array(array(array($pro['title'], strip_tags(htmlspecialchars_decode($pro['info'])), $pro['picurl'], C('site_url') . '/index.php?g=Wap&m=Yuyue&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'])), 'news'); break; case 'aaa': return array(array(array($pro['title'], strip_tags(htmlspecialchars_decode($pro['info'])), $pro['picurl'], C('site_url') . '/cms/index.php?token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'])), 'news'); break; case '订餐': $pro = M('reply_info')->where(array('infotype' => 'Dining', 'token' => $this->token))->find(); return array(array(array($pro['title'], strip_tags(htmlspecialchars_decode($pro['info'])), $pro['picurl'], C('site_url') . '/index.php?g=Wap&m=Product&a=dining&dining=1&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'])), 'news'); break; case '团购': $pro = M('reply_info')->where(array('infotype' => 'Groupon', 'token' => $this->token))->find(); return array(array(array($pro['title'], strip_tags(htmlspecialchars_decode($pro['info'])), $pro['picurl'], C('site_url') . '/index.php?g=Wap&m=Groupon&a=grouponIndex&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'])), 'news'); break; default: $check = $this->user('diynum', $key); if ($check['diynum'] != 1) { return array(C('connectout'), 'text'); } else { return $this->keyword($key); } } } }
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) { 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); } }
private function reply($data) { //语音功能 if (isset($data['MsgType'])) { if ('voice' == $data['MsgType']) { $data['Content'] = $data['Recognition']; $this->data['Content'] = $data['Recognition']; } } //判断关注 if (isset($data['Event'])) { if ('CLICK' == $data['Event']) { $data['Content'] = $data['EventKey']; $this->data['Content'] = $data['EventKey']; } if ($data['Event'] == 'SCAN') { $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'])); } elseif ('subscribe' == $data['Event']) { //subscribe(订阅)、 $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'])); } //首页功能 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'); /*rippleos 需要对应终端重新认证*/ $node=D('Rippleos_node')->where(array('token'=>$this->token))->find(); $this->rippleos_unauth($node['node']); } elseif ($data['Event'] == 'LOCATION') { return array('LOCATION', 'text'); } } //开始一站到底 if (!isset($_SESSION['wecha_id']) || $_SESSION['wecha_id'] == '') { $_SESSION['wecha_id'] = $this->data['FromUserName']; } if (@strpos($data['Content'], '出题') !== false) { $info = $this->dati(); return $info; } if (S($_SESSION['wecha_id']) == 'start') { $info = $this->dati_start($data['Content']); return $info; } //判断是不是有API操作 if (!(strpos($this->fun, 'api') === FALSE) && isset($data['Content'])) { $apiData = M('Api')->where(array('token' => $this->token, 'status' => 1))->select(); if (is_array($apiData)) { foreach ($apiData as $apiArray) { if (!(strpos($data['Content'], $apiArray['keyword']) === FALSE)) { $api['type'] = $apiArray['type']; $api['url'] = $apiArray['url']; break; } } if ($api != false) { $vo['fromUsername'] = $this->data['FromUserName']; $vo['Content'] = $this->data['Content']; $vo['toUsername'] = $this->token; if ($api['type'] == 2) { $apidata = $this->api_notice_increment($api['url'], $vo); return array($apidata, 'text'); } else { $xml = file_get_contents('php://input'); $apidata = $this->api_notice_increment($api['url'], $xml); header('Content-type: text/xml'); die($apidata); return false; } } } } //车牌判断 if (preg_match('/(京|沪|津|渝|冀|蒙|辽|吉|黑|苏|浙|皖|闽|赣|鲁|豫|鄂|湘|粤|桂|琼|川|贵|云|藏|陕|甘|青|宁|新)[a-zA-z]{1}[a-zA-z0-9]{5}/', $data['Content'], $che)) { return array($this->weizhang(strtoupper($che[0])), 'text'); die; } if ((!(strpos($data['Content'], 'yyy') === FALSE) || !(strpos(strtolower($data['Content']), 'yyy') === FALSE)) && strlen($data['Content']) == 14) { $mp = str_replace('yyy', '', 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'], (((((C('site_url') . '/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'], (((((C('site_url') . '/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="' . C('site_url')) . '/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'); } } } //附近、公交、域名功能 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'])); } elseif (isset($data['Content'])) { $check = $this->user('connectnum'); if ($check['connectnum'] != 1) { return array(C('connectout'), 'text'); } $Pin = new GetPin(); /* if (strtolower(substr($data['Content'], 0, 3)) == "yyy") { $key = "摇一摇"; $yyyphone = substr($data['Content'], 3, 11); } elseif (substr($data['Content'], 0, 2) == "##") { $key = "微信墙"; $wallmessage = substr_replace($data['Content'], "", 0, 2); } else { $key = $data['Content']; } */ $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(strtolower($data)); if (in_array($string, $datafun) && $string) { if ($string == 'cangtou') { $return = $this->cangtou(str_replace('藏头诗', '', $key)); break; } if ($string == 'dianying') { $return = $this->dianying(str_replace('电影', '', $key)); break; } if ($string == 'caipu') { $return = $this->caipu(str_replace('菜谱', '', $key)); break; } if ($string == 'fujin') { $this->recordLastRequest($key); } $this->requestdata('textnum'); unset($back[$keydata]); if (method_exists('WeixinAction', $string)) { eval(('$return= $this->' . $string) . '($back);'); } else { return array('sorry,no method in this class', 'text'); } break; } } } if (!empty($return)) { if (is_array($return)) { return $return; } else { return array($return, 'text'); } } else { if (!(strpos(strtolower($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 (isset($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('请发送您所在的位置', 'text'); } switch ($key) { case '首页': case 'home': return $this->home(); break; case '主页': return $this->home(); break; case '地图': return $this->companyMap(); case '最近的': $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' ); break; case 'help': case '帮助': return $this->help(); break; case '会员卡': return $this->member(); break; case '会员': return $this->member(); break; case '3g相册': return $this->xiangce(); break; case '相册': return $this->xiangce(); break; case '吃粽子': $pro = M('czzreply_info')->where(array( 'token' => $this->token ))->find(); $url = C('site_url') . '/index.php?g=Wap&m=Czz&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com'; return array( array( array( $pro['title'], strip_tags(htmlspecialchars_decode($pro['info'])) , $pro['picurl'], $url ) ) , 'news' ); break; case '2048': $pro = M('gamereply_info')->where(array( 'token' => $this->token ))->find(); $url = C('site_url') . '/index.php?g=Wap&m=Game&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com'; return array( array( array( $pro['title'], strip_tags(htmlspecialchars_decode($pro['info'])) , $pro['picurl'], $url ) ) , 'news' ); break; case '2048加强版': $pro = M('gametreply_info')->where(array( 'token' => $this->token ))->find(); $url = C('site_url') . '/index.php?g=Wap&m=Gamet&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com'; return array( array( array( $pro['title'], strip_tags(htmlspecialchars_decode($pro['info'])) , $pro['picurl'], $url ) ) , 'news' ); break; case 'fly2048': $pro = M('gamettreply_info')->where(array( 'token' => $this->token ))->find(); $url = C('site_url') . '/index.php?g=Wap&m=Gamett&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com'; return array( array( array( $pro['title'], strip_tags(htmlspecialchars_decode($pro['info'])) , $pro['picurl'], $url ) ) , 'news' ); break; case '商城': $pro = M('reply_info')->where(array('infotype' => 'Shop', 'token' => $this->token))->find(); $url = ((((C('site_url') . '/index.php?g=Wap&m=Store&a=cats&token=') . $this->token) . '&wecha_id=') . $this->data['FromUserName']) . '&sgssz=mp.weixin.qq.com'; if ($pro['apiurl']) { $url = str_replace('&', '&', $pro['apiurl']); } return array(array(array($pro['title'], $this->handleIntro($pro['info']), $pro['picurl'], $url)), 'news'); break; case '微商城': $pro = M('reply_info')->where(array('infotype' => 'Shop', 'token' => $this->token))->find(); $url = ((((C('site_url') . '/index.php?g=home&m=cats&a=index&token=') . $this->token) . '&wecha_id=') . $this->data['FromUserName']) . '&sgssz=mp.weixin.qq.com'; if ($pro['apiurl']) { $url = str_replace('&', '&', $pro['apiurl']); } return array(array(array($pro['title'], $this->handleIntro($pro['info']), $pro['picurl'], $url)), 'news'); break; case '微团购': $pro = M('reply_info')->where(array('infotype' => 'Shop', 'token' => $this->token))->find(); $url = ((((C('site_url') . '/sc/index.php?g=groupon&m=Index&a=index&token=') . $this->token) . '&wecha_id=') . $this->data['FromUserName']) . '&sgssz=mp.weixin.qq.com'; if ($pro['apiurl']) { $url = str_replace('&', '&', $pro['apiurl']); } return array(array(array($pro['title'], $this->handleIntro($pro['info']), $pro['picurl'], $url)), 'news'); break; case '微秒杀': $pro = M('reply_info')->where(array('infotype' => 'Shop', 'token' => $this->token))->find(); $url = ((((C('site_url') . '/sc/index.php?g=miaosha&m=Index&a=index&token=') . $this->token) . '&wecha_id=') . $this->data['FromUserName']) . '&sgssz=mp.weixin.qq.com'; if ($pro['apiurl']) { $url = str_replace('&', '&', $pro['apiurl']); } return array(array(array($pro['title'], $this->handleIntro($pro['info']), $pro['picurl'], $url)), 'news'); break; case '订餐': $pro = M('reply_info')->where(array('infotype' => 'Dining', 'token' => $this->token))->find(); $url = ((((C('site_url') . '/index.php?g=Wap&m=Repast&a=index&token=') . $this->token) . '&wecha_id=') . $this->data['FromUserName']) . '&sgssz=mp.weixin.qq.com'; if ($pro['apiurl']) { $url = str_replace('&', '&', $pro['apiurl']); } return array(array(array($pro['title'], $this->handleIntro($pro['info']), $pro['picurl'], $url)), 'news'); break; case '留言': $pro = M('reply_info')->where(array('infotype' => 'message', 'token' => $this->token))->find(); if ($pro) { return array(array(array($pro['title'], $this->handleIntro($pro['info']), $pro['picurl'], ((((C('site_url') . '/index.php?g=Wap&m=Reply&a=index&token=') . $this->token) . '&wecha_id=') . $this->data['FromUserName']) . '&sgssz=mp.weixin.qq.com')), 'news'); } else { return array(array(array('留言板', '在线留言', rtrim(C('site_url'), '/') . '/tpl/Wap/default/common/css/style/images/ly.jpg', ((((C('site_url') . '/index.php?g=Wap&m=Reply&a=index&token=') . $this->token) . '&wecha_id=') . $this->data['FromUserName']) . '&sgssz=mp.weixin.qq.com')), 'news'); } break; case '酒店': $pro = M('reply_info')->where(array('infotype' => 'Hotels', 'token' => $this->token))->find(); if ($pro) { return array(array(array($pro['title'], $this->handleIntro($pro['info']), $pro['picurl'], (((C('site_url') . '/index.php?g=Wap&m=Hotels&a=index&token=') . $this->token) . '&wecha_id=') . $this->data['FromUserName'])), 'news'); } else { return array(array(array('酒店', '酒店在线预订', rtrim(C('site_url'), '/') . 'tpl/static/images/homelogo.png', (((C('site_url') . '/index.php?g=Wap&m=Hotels&a=index&token=') . $this->token) . '&wecha_id=') . $this->data['FromUserName'])), 'news'); } break; case '团购': $pro = M('reply_info')->where(array('infotype' => 'Groupon', 'token' => $this->token))->find(); $url = ((((C('site_url') . '/index.php?g=Wap&m=Groupon&a=grouponIndex&token=') . $this->token) . '&wecha_id=') . $this->data['FromUserName']) . '&sgssz=mp.weixin.qq.com'; if ($pro['apiurl']) { $url = str_replace('&', '&', $pro['apiurl']); } return array(array(array($pro['title'], $this->handleIntro($pro['info']), $pro['picurl'], $url)), 'news'); break; case '全景': $pro = M('reply_info')->where(array('infotype' => 'panorama', 'token' => $this->token))->find(); if ($pro) { return array(array(array($pro['title'], $this->handleIntro($pro['info']), $pro['picurl'], ((((C('site_url') . '/index.php?g=Wap&m=Panorama&a=index&token=') . $this->token) . '&wecha_id=') . $this->data['FromUserName']) . '&sgssz=mp.weixin.qq.com')), 'news'); } else { return array(array(array('360°全景看车看房', '通过该功能可以实现3D全景看车看房', rtrim(C('site_url'), '/') . '/tpl/User/default/common/images/panorama/360view.jpg', ((((C('site_url') . '/index.php?g=Wap&m=Panorama&a=index&token=') . $this->token) . '&wecha_id=') . $this->data['FromUserName']) . '&sgssz=mp.weixin.qq.com')), 'news'); } break; case '微房产': $Estate = M('Estate')->where(array('token' => $this->token))->find(); return array(array(array($Estate['title'], $this->handleIntro($Estate['estate_desc']), $Estate['cover'], ((((((C('site_url') . '/index.php?g=Wap&m=Estate&a=index&token=') . $this->token) . '&wecha_id=') . $this->data['FromUserName']) . '&hid=') . $Estate['id']) . '&sgssz=mp.weixin.qq.com')), 'news'); break; case '讨论社区': case '论坛': $fconfig = M('Forum_config')->where(array('token' => $this->token))->find(); return array(array(array($fconfig['forumname'], str_replace(' ', '', strip_tags(htmlspecialchars_decode($fconfig['intro']))), $fconfig['picurl'], (((C('site_url') . '/index.php?g=Wap&m=Forum&a=index&&token=') . $this->token) . '&wecha_id=') . $this->data['FromUserName'])), 'news'); break; case '贺卡': $heka = M('Heka')->where(array('token' => $this->token))->find(); if ($heka !== null) { $url = (rtrim(C('site_url'), '/') . '/index.php?g=Wap&m=Heka&a=hklist&token=') . $this->token; return array(array(array($heka['title'], $this->handleIntro($heka['info']), $heka['picurl'], $url)), 'news'); } else { return array('商家未设置贺卡!', 'text'); } break; default: $check = $this->user('diynum', $key); if ($check['diynum'] != 1) { return array(C('connectout'), 'text'); } else { return $this->keyword($key); } } if ($data['Content'] == 'wechat ip') { return array($_SERVER['REMOTE_ADDR'], 'text'); } //有留言内容 if (!isset($data['Content'])) { return array('没有留言内容', 'text'); } } }
private function reply($data) { if ($data['Location_X']) { return $this->map($data['Location_X'], $data['Location_Y']); } if ('CLICK' == $data['Event']) { $data['Content'] = $data['EventKey']; } if ('subscribe' == $data['Event']) { $this->requestdata('follownum'); $data = M('Areply')->field('home,keyword,content')->where(array('token' => $this->token))->find(); if ($data['keyword'] == '首页' || $data['keyword'] == 'home') { return $this->shouye(); } if ($data['keyword'] == '投票' || $data['keyword'] == 'vote') { return $this->vote(); } if ($data['keyword'] == '酒店' || $data['keyword'] == 'hotel') { return $this->hotel(); } if ($data['keyword'] == '刮刮' || $data['keyword'] == '刮刮卡') { return $this->guaguaka(); } if ($data['keyword'] == '微房产' || $data['keyword'] == '房产') { return $this->house(); } if ($data['home'] == 1) { $like['keyword'] = array('like', '%' . $data['keyword'] . '%'); $like['token'] = $this->token; $back = M('Img')->field('id,text,pic,url,title')->limit(9)->order('id desc')->where($like)->select(); foreach ($back as $keya => $infot) { if ($infot['url'] != false) { if (stristr($infot['url'], '?')) { $url = $infot['url'] . '&iVanvicms=mp.weixin.qq.com'; } else { $url = $infot['url'] . '?iVanvicms=mp.weixin.qq.com'; } } else { $url = rtrim(C('site_url'), '/') . U('Wap/Index/content', array('token' => $this->token, 'id' => $infot['id'], 'wecha_id' => $this->data['FromUserName'], 'iVanvicms' => 'mp.weixin.qq.com')); } if (stristr($infot['pic'], "http:")) { $purl = $infot['pic']; } else { $purl = rtrim(C('site_url'), '/') . $infot['pic']; } $return[] = array($infot['title'], $infot['text'], $purl, $url); } return array($return, 'news'); } else { return array(strip_tags(htmlspecialchars_decode($data['content'])), 'text'); } } elseif ('unsubscribe' == $data['Event']) { $this->requestdata('unfollownum'); } $Pin = new GetPin(); $key = $data['Content']; $open = M('Token_open')->where(array('token' => $this->_get('token')))->find(); $this->fun = $open['queryname']; $datafun = explode(',', $open['queryname']); $tags = $this->get_tags($key); $back = explode(',', $tags); foreach ($back as $keydata => $data) { $string = $Pin->Pinyin($data); if (in_array($string, $datafun)) { $check = $this->user('connectnum'); if ($string == 'fujin') { $this->recordLastRequest($key); } $this->requestdata('textnum'); if ($check['connectnum'] != 1) { $return = C('connectout'); continue; } unset($back[$keydata]); eval('$return= $this->' . $string . '($back);'); continue; } } if (!empty($return)) { if (is_array($return)) { return $return; } else { return array($return, 'text'); } } else { switch ($key) { case '首页': return $this->home(); break; case '主页': return $this->home(); break; case '微网站': return $this->home(); break; case '3G': return $this->home(); break; case '3g': return $this->home(); break; case '微官网': return $this->home(); break; case '帮助': return $this->help(); break; case 'help': return $this->help(); break; case '会员卡': return $this->member(); break; case '会员': return $this->member(); break; case '3g相册': return $this->xiangce(); break; case '相册': return $this->xiangce(); break; case '微相册': return $this->xiangce(); break; case '大转盘': return $this->choujiang(); break; case '投票': return $this->vote(); break; case '微投票': return $this->vote(); break; case '订餐': return $this->ding(); break; case '微订餐': return $this->ding(); break; case '微餐饮': return $this->ding(); break; case '商城': return $this->shop(); break; case '微商城': return $this->shop(); break; case '团购': return $this->groupon(); break; case '微团购': return $this->groupon(); break; case '酒店': return $this->hotel(); break; case '微酒店': return $this->hotel(); break; case '喜帖': return $this->xitie(); break; case '微喜帖': return $this->xitie(); break; case '刮刮': return $this->guaguaka(); break; case '刮刮卡': return $this->guaguaka(); break; case '微房产': return $this->house(); break; case '房地产': return $this->house(); break; default: $check = $this->user('diynum'); if ($check['diynum'] != 1) { return array(C('connectout'), 'text'); } return $this->keyword($key); } } }
private function reply($data) { if ('CLICK' == $data['Event']) { $data['Content'] = $data['EventKey']; } //语音功能 if (isset($data['MsgType'])) { if ('voice' == $data['MsgType']) { $data['Content'] = $data['Recognition']; $this->data['Content'] = $data['Recognition']; } } //判断关注 if (isset($data['Event'])) { if ('CLICK' == $data['Event']) { $data['Content'] = $data['EventKey']; $this->data['Content'] = $data['EventKey']; } if ($data['Event'] == 'SCAN') { $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'])); } elseif ('subscribe' == $data['Event']) { //subscribe(订阅)、 $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'])); } //首页功能 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'); /*rippleos 需要对应终端重新认证*/ $node = D('Rippleos_node')->where(array('token' => $this->token))->find(); $this->rippleos_unauth($node['node']); } } //判断用户提交是否为图片 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 = C('site_url') . '/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'); } } //有留言内容 //开始一站到底 if (!isset($_SESSION['wecha_id']) || $_SESSION['wecha_id'] == '') { $_SESSION['wecha_id'] = $this->data['FromUserName']; } if (@strpos($data['Content'], '出题') !== false) { $info = $this->dati(); return $info; } if (S($_SESSION['wecha_id']) == 'start') { $info = $this->dati_start($data['Content']); return $info; } if ($data['Content'] == 'wechat ip') { return array($_SERVER['REMOTE_ADDR'], 'text'); } //判断照片墙 $zhaopianwall_result = S('zhaopianwall_' . $data['FromUserName']); if ($zhaopianwall_result) { return $this->zhaopianwall($zhaopianwall_result); } //判断是不是有API操作 if (!(strpos($this->fun, 'api') === FALSE) && isset($data['Content'])) { $apiData = M('Api')->where(array('token' => $this->token, 'status' => 1))->select(); if (is_array($apiData)) { foreach ($apiData as $apiArray) { if (!(strpos($data['Content'], $apiArray['keyword']) === FALSE)) { $api['type'] = $apiArray['type']; $api['url'] = $apiArray['url']; break; } } if ($api != false) { $vo['fromUsername'] = $this->data['FromUserName']; $vo['Content'] = $this->data['Content']; $vo['toUsername'] = $this->token; if ($api['type'] == 2) { $apidata = $this->api_notice_increment($api['url'], $vo); return array($apidata, 'text'); } else { $xml = file_get_contents('php://input'); $apidata = $this->api_notice_increment($api['url'], $xml); header('Content-type: text/xml'); die($apidata); return false; } } } } //车牌判断 if (preg_match('/(京|沪|津|渝|冀|蒙|辽|吉|黑|苏|浙|皖|闽|赣|鲁|豫|鄂|湘|粤|桂|琼|川|贵|云|藏|陕|甘|青|宁|新)[a-zA-z]{1}[a-zA-z0-9]{5}/', $data['Content'], $che)) { return array($this->weizhang(strtoupper($che[0])), 'text'); die; } 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="' . C('site_url') . '/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'); } } } //附近、公交、域名功能 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'])); } elseif (isset($data['Content'])) { $check = $this->user('connectnum'); if ($check['connectnum'] != 1) { return array(C('connectout'), 'text'); } $Pin = new GetPin(); $key = $data['Content']; $datafun = explode(',', $this->fun); $tags = $this->get_tags($key); $back = explode(',', $tags); if (strtolower(substr($data['Content'], 0, 3)) == "yyy") { $key = "摇一摇"; $yyyphone = substr($data['Content'], 3, 11); } if ($key == '首页' || $key == 'home') { return $this->home(); } foreach ($back as $keydata => $data) { $string = $Pin->Pinyin(strtolower($data)); if (in_array($string, $datafun) && $string) { if ($string == 'cangtou') { $return = $this->cangtou(str_replace('藏头诗', '', $key)); break; } if ($string == 'dianying') { $return = $this->dianying(str_replace('电影', '', $key)); break; } if ($string == 'caipu') { $return = $this->caipu(str_replace('菜谱', '', $key)); break; } if ($string == 'fujin') { $this->recordLastRequest($key); } $this->requestdata('textnum'); unset($back[$keydata]); if (method_exists('WeixinAction', $string)) { eval('$return= $this->' . $string . '($back);'); } else { return array('您输入的关键词可能被管理员禁用;请检查系统版本 或者联系作者QQ:3043527191', 'text'); } break; } } } if (!empty($return)) { if (is_array($return)) { return $return; } else { return array($return, 'text'); } } else { if (!(strpos(strtolower($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 (isset($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('请发送您所在的位置', 'text'); } switch ($key) { case '首页': case 'home': return $this->home(); break; case '主页': return $this->home(); break; case '地图': return $this->companyMap(); case '摇一摇': $yyy = M('Shake')->where(array('isopen' => '1', 'token' => $this->token))->find(); if ($yyy == false) { return array('目前没有正在进行中的摇一摇活动', 'text'); } /*if(!preg_match("/^13[0-9]{1}[0-9]{8}$|15[0189]{1}[0-9]{8}$|189[0-9]{8}$/",$yyyphone)){ return array( '拜托遵守规则好吗,请输入yyy加您的手机号码,例如yyy13647810523', 'text' ); }*/ $url = C('site_url') . U('Wap/Toshake/index', array('token' => $this->token, 'phone' => $yyyphone, 'wecha_id' => $this->data['FromUserName'])); return array('<a href="' . $url . '">★点击进入刺激的现场摇一摇活动★</a>', 'text'); case '最近的': $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'); break; case '微名片': $pro = M('vcard')->where(array('token' => $this->token))->find(); $url = C('site_url') . '/index.php?g=Wap&m=Vcard&a=lists&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com'; return array(array(array($pro['title'], strip_tags(htmlspecialchars_decode($pro['jianjie'])), $pro['tp'], $url)), 'news'); break; case 'help': case '帮助': return $this->help(); break; case '会员卡': return $this->member(); break; case '会员': return $this->member(); break; case '3g相册': return $this->xiangce(); break; case '相册': return $this->xiangce(); break; case '答题王': $pro = M('jikedati_reply')->where(array('token' => $this->token))->find(); $url = C('site_url') . '/index.php?g=Wap&m=Jikedati&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com'; return array(array(array($pro['title'], strip_tags(htmlspecialchars_decode($pro['info'])), $pro['tp'], $url)), 'news'); break; case '考试': $pro = M('fanyan_reply')->where(array('token' => $this->token))->find(); $url = C('site_url') . '/index.php?g=Wap&m=Fanyan&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com'; return array(array(array($pro['title'], strip_tags(htmlspecialchars_decode($pro['info'])), $pro['tp'], $url)), 'news'); break; case '微商盟': $pro = M('fenlei_reply')->where(array('token' => $this->token))->find(); $url = C('site_url') . '/index.php?g=Wap&m=Fenlei&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com'; return array(array(array($pro['title'], strip_tags(htmlspecialchars_decode($pro['info'])), $pro['tp'], $url)), 'news'); break; case '找工作': $pro = M('Zhaopin_reply')->where(array('token' => $this->token))->find(); $url = C('site_url') . '/index.php?g=Wap&m=Zhaopin&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com'; $news = array(); array_push($news, array($pro['title'], strip_tags(htmlspecialchars_decode($pro['info'])), $pro['tp'], $url)); array_push($news, array('【找简历】找简历,看这里', strip_tags(htmlspecialchars_decode($pro['info'])), C('site_url') . '/tpl/Wap/default/common/zhaopin/jianli.png', C('site_url') . '/index.php?g=Wap&m=Zhaopin&a=jlindex&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com')); array_push($news, array('【企业版】我要发布招聘', strip_tags(htmlspecialchars_decode($pro['info'])), C('site_url') . '/tpl/Wap/default/common/zhaopin/qiye.png', C('site_url') . '/index.php?g=Wap&m=Zhaopin&a=qiye&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com')); array_push($news, array('【个人版】我要发布简历', strip_tags(htmlspecialchars_decode($pro['info'])), C('site_url') . '/tpl/Wap/default/common/zhaopin/geren.png', C('site_url') . '/index.php?g=Wap&m=Zhaopin&a=geren&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com')); return array($news, 'news'); break; case '找房子': $pro = M('Fangchan_reply')->where(array('token' => $this->token))->find(); $url = C('site_url') . '/index.php?g=Wap&m=Fangchan&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com'; $news = array(); array_push($news, array($pro['title'], strip_tags(htmlspecialchars_decode($pro['info'])), $pro['tp'], $url)); array_push($news, array('点此→免费发布房源信息', strip_tags(htmlspecialchars_decode($pro['info'])), C('site_url') . '/tpl/Wap/default/common/zhaopin/geren.png', C('site_url') . '/index.php?g=Wap&m=Fangchan&a=fabu&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com')); return array($news, 'news'); break; case '场景应用': $pro = M('yingyong_reply')->where(array('token' => $this->token))->find(); $url = C('site_url') . '/index.php?g=Wap&m=Yingyong&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com'; return array(array(array($pro['title'], strip_tags(htmlspecialchars_decode($pro['info'])), $pro['tp'], $url)), 'news'); break; case '主题活动': $pro = M('Baoming')->where(array('token' => $this->token))->find(); $url = C('site_url') . '/index.php?g=Wap&m=Baoming&a=lists&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com'; return array(array(array($pro['title'], strip_tags(htmlspecialchars_decode($pro['jianjie'])), $pro['tp'], $url)), 'news'); break; case '2048': $pro = M('gamereply_info')->where(array('token' => $this->token))->find(); $url = C('site_url') . '/index.php?g=Wap&m=Game&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com'; return array(array(array($pro['title'], strip_tags(htmlspecialchars_decode($pro['info'])), $pro['picurl'], $url)), 'news'); break; case '神经猫': $pro = M('sjmreply_info')->where(array('token' => $this->token))->find(); $url = C('site_url') . '/index.php?g=Wap&m=Sjm&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com'; return array(array(array($pro['title'], strip_tags(htmlspecialchars_decode($pro['info'])), $pro['picurl'], $url)), 'news'); break; case '2048加强版': $pro = M('gametreply_info')->where(array('token' => $this->token))->find(); $url = C('site_url') . '/index.php?g=Wap&m=Gamet&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com'; return array(array(array($pro['title'], strip_tags(htmlspecialchars_decode($pro['info'])), $pro['picurl'], $url)), 'news'); break; case 'fly2048': $pro = M('gamettreply_info')->where(array('token' => $this->token))->find(); $url = C('site_url') . '/index.php?g=Wap&m=Gamett&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com'; return array(array(array($pro['title'], strip_tags(htmlspecialchars_decode($pro['info'])), $pro['picurl'], $url)), 'news'); break; case '吃粽子': $pro = M('czzreply_info')->where(array('token' => $this->token))->find(); $url = C('site_url') . '/index.php?g=Wap&m=Czz&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com'; return array(array(array($pro['title'], strip_tags(htmlspecialchars_decode($pro['info'])), $pro['picurl'], $url)), 'news'); break; case '微生活': $pro = M('weilivereply_info')->where(array('token' => $this->token))->find(); return array(array(array($pro['title'], strip_tags(htmlspecialchars_decode($pro['info'])), C('site_url') . $pro['picurl'], C('site_url') . '/index.php?g=Wap&m=Weilive&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'])), 'news'); break; case '商城': $pro = M('reply_info')->where(array('infotype' => 'Shop', 'token' => $this->token))->find(); $url = C('site_url') . '/index.php?g=Wap&m=Store&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com'; if ($pro['apiurl']) { $url = str_replace('&', '&', $pro['apiurl']); } return array(array(array($pro['title'], $this->handleIntro($pro['info']), $pro['picurl'], $url)), 'news'); break; case '微商城': $pro = M('reply_info')->where(array('infotype' => 'Shop', 'token' => $this->token))->find(); $url = C('site_url') . '/sc/index.php?g=home&m=Index&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com'; if ($pro['apiurl']) { $url = str_replace('&', '&', $pro['apiurl']); } return array(array(array($pro['title'], $this->handleIntro($pro['info']), $pro['picurl'], $url)), 'news'); break; case '微团购': $pro = M('reply_info')->where(array('infotype' => 'Shop', 'token' => $this->token))->find(); $url = C('site_url') . '/sc/index.php?g=groupon&m=Index&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com'; if ($pro['apiurl']) { $url = str_replace('&', '&', $pro['apiurl']); } return array(array(array($pro['title'], $this->handleIntro($pro['info']), $pro['picurl'], $url)), 'news'); break; case '微秒杀': $pro = M('reply_info')->where(array('infotype' => 'Shop', 'token' => $this->token))->find(); $url = C('site_url') . '/sc/index.php?g=miaosha&m=Index&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com'; if ($pro['apiurl']) { $url = str_replace('&', '&', $pro['apiurl']); } return array(array(array($pro['title'], $this->handleIntro($pro['info']), $pro['picurl'], $url)), 'news'); break; case '订餐': $pro = M('reply_info')->where(array('infotype' => 'Dining', 'token' => $this->token))->find(); $url = C('site_url') . '/index.php?g=Wap&m=Repast&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com'; if ($pro['apiurl']) { $url = str_replace('&', '&', $pro['apiurl']); } return array(array(array($pro['title'], $this->handleIntro($pro['info']), $pro['picurl'], $url)), 'news'); break; case '留言': $pro = M('reply_info')->where(array('infotype' => 'message', 'token' => $this->token))->find(); if ($pro) { return array(array(array($pro['title'], $this->handleIntro($pro['info']), $pro['picurl'], C('site_url') . '/index.php?g=Wap&m=Reply&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com')), 'news'); } else { return array(array(array('留言板', '在线留言', rtrim(C('site_url'), '/') . '/tpl/Wap/default/common/css/style/images/ly.jpg', C('site_url') . '/index.php?g=Wap&m=Reply&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com')), 'news'); } break; case '酒店': $pro = M('reply_info')->where(array('infotype' => 'Hotels', 'token' => $this->token))->find(); if ($pro) { return array(array(array($pro['title'], $this->handleIntro($pro['info']), $pro['picurl'], C('site_url') . '/index.php?g=Wap&m=Hotels&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'])), 'news'); } else { return array(array(array('酒店', '酒店在线预订', rtrim(C('site_url'), '/') . 'tpl/static/images/homelogo.png', C('site_url') . '/index.php?g=Wap&m=Hotels&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'])), 'news'); } break; case '团购': $pro = M('reply_info')->where(array('infotype' => 'Groupon', 'token' => $this->token))->find(); $url = C('site_url') . '/index.php?g=Wap&m=Groupon&a=grouponIndex&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com'; if ($pro['apiurl']) { $url = str_replace('&', '&', $pro['apiurl']); } return array(array(array($pro['title'], $this->handleIntro($pro['info']), $pro['picurl'], $url)), 'news'); break; case '全景': $pro = M('reply_info')->where(array('infotype' => 'panorama', 'token' => $this->token))->find(); if ($pro) { return array(array(array($pro['title'], $this->handleIntro($pro['info']), $pro['picurl'], C('site_url') . '/index.php?g=Wap&m=Panorama&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com')), 'news'); } else { return array(array(array('360°全景看车看房', '通过该功能可以实现3D全景看车看房', rtrim(C('site_url'), '/') . '/tpl/User/default/common/images/panorama/360view.jpg', C('site_url') . '/index.php?g=Wap&m=Panorama&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com')), 'news'); } break; case '微房产': $Estate = M('Estate')->where(array('token' => $this->token))->find(); return array(array(array($Estate['title'], $this->handleIntro($Estate['estate_desc']), $Estate['cover'], C('site_url') . '/index.php?g=Wap&m=Estate&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&hid=' . $Estate['id'] . '&sgssz=mp.weixin.qq.com')), 'news'); break; case '讨论社区': case '论坛': $fconfig = M('Forum_config')->where(array('token' => $this->token))->find(); return array(array(array($fconfig['forumname'], str_replace(' ', '', strip_tags(htmlspecialchars_decode($fconfig['intro']))), $fconfig['picurl'], C('site_url') . '/index.php?g=Wap&m=Forum&a=index&&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'])), 'news'); break; case '微信签到': $thisItem = M('Sign_set')->where(array('token' => $this->token))->find(); return array(array(array($thisItem['title'], $thisItem['content'], $thisItem['reply_img'], C('site_url') . U('Wap/Fanssign/index', array('token' => $this->token, 'wecha_id' => $this->data['FromUserName'])))), 'news'); break; case '微商圈': $thisItem = M('Market')->where(array('token' => $this->token))->find(); return array(array(array($thisItem['title'], $thisItem['address'], $thisItem['logo_pic'], C('site_url') . '/index.php?g=Wap&m=Market&a=index&&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'])), 'news'); break; default: $check = $this->user('diynum', $key); if ($check['diynum'] != 1) { return array(C('connectout'), 'text'); } else { return $this->keyword($key); } } } }
private function reply($data) { if ('CLICK' == $data['Event']) { $data['Content'] = $data['EventKey']; $this->data['Content'] = $data['EventKey']; } if ('voice' == $data['MsgType']) { $data['Content'] = $data['Recognition']; $this->data['Content'] = $data['Recognition']; } if ('subscribe' == $data['Event']) { $this->requestdata('follownum'); $gzdata = M('Areply')->field('home,keyword,content')->where(array('token' => $this->token))->find(); if ($gzdata['keyword'] == '首页' || $gzdata['keyword'] == 'home') { return $this->shouye(); } if ($gzdata['home'] == 1) { $like['keyword'] = array('like', '%' . $gzdata['keyword'] . '%'); $like['token'] = $this->token; $back = M('Img')->field('id,text,pic,url,title')->limit(9)->order('sorts asc,uptatetime desc')->where($like)->select(); foreach ($back as $keya => $infot) { if ($infot['url'] != false) { $url = $this->getFuncLink($infot['url']); } else { $url = rtrim(C('site_url'), '/') . U('Wap/Index/content', array('token' => $this->token, 'id' => $infot['id'], 'wecha_id' => $this->data['FromUserName'])); } $return[] = array($infot['title'], $infot['text'], $infot['pic'], $url); } return array($return, 'news'); } else { return array($gzdata['content'], 'text'); } } elseif ('unsubscribe' == $data['Event']) { $this->requestdata('unfollownum'); } if (!(strpos($this->fun, 'api') === FALSE) && $data['Content']) { $apiData = M('Api')->where(array('token' => $this->token, 'status' => 1))->select(); foreach ($apiData as $apiArray) { if (!(strpos($data['Content'], $apiArray['keyword']) === FALSE)) { $api['type'] = $apiArray['type']; $api['url'] = $apiArray['url']; break; } } if ($api != false) { $vo['fromUsername'] = $this->data['FromUserName']; $vo['Content'] = $this->data['Content']; $vo['toUsername'] = $this->token; if ($api['type'] == 2) { $apidata = $this->api_notice_increment($api['url'], $vo); return array($apidata, 'text'); } else { $xml = file_get_contents("php://input"); $apidata = $this->api_notice_increment($api['url'], $xml); header("Content-type: text/xml"); exit($apidata); return false; } } } $Pin = new GetPin(); if (strtolower(substr($data['Content'], 0, 3)) == "yyy") { $key = "摇一摇"; $yyyphone = substr($data['Content'], 3, 11); } elseif (substr($data['Content'], 0, 2) == "##") { $key = "微信墙"; $wallmessage = substr_replace($data['Content'], "", 0, 2); } else { $key = $data['Content']; } $datafun = explode(',', $this->fun); $tags = $this->get_tags($key); $back = explode(',', $tags); foreach ($back as $keydata => $data) { $string = $Pin->Pinyin($data); if (in_array($string, $datafun) && $string) { $check = $this->user('connectnum'); if ($string == 'fujin') { $this->recordLastRequest($key); } $this->requestdata('textnum'); if ($check['connectnum'] != 1) { $return = C('connectout'); break; } unset($back[$keydata]); 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->_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'); } switch ($key) { case '首页': case '微网站': case 'home': case '主页': case '微官网': return $this->shouye(); break; case '地图': return $this->companyMap(); break; case '微信墙': return $this->wxq($wallmessage); break; case '摇一摇': return $this->yyy($yyyphone); break; case '最近的': $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'); break; case '帮助': case 'help': return $this->help(); break; case '会员卡': case '会员': return $this->member(); break; case '3g相册': case '相册': return $this->xiangce(); break; case '商城': case '微商城': return $this->Shop(); break; case '订餐': case '微订餐': return $this->Dining(); break; case '商圈': case '微商圈': return $this->market(); break; case '留言': return $this->liuyan(); break; case '团购': return $this->groupon(); break; case '租车': return $this->zuche(); break; case '全景': return $this->panorama(); break; case '微酒店': return $this->hotel(); break; case '微教育': return $this->zhenghehangye('jiaoyu'); break; case '微房产': return $this->zhenghehangye('estate'); break; case '微ktv': return $this->zhenghehangye('ktv'); break; case '微酒吧': return $this->zhenghehangye('jiuba'); break; case '微教育': return $this->zhenghehangye('jiaoyu'); break; case '微健身': return $this->zhenghehangye('jianshen'); break; case '微旅游': return $this->zhenghehangye('lvyou'); break; case '微美容': return $this->zhenghehangye('meirong'); break; case '微社区': case '微论坛': case '社区': case '论坛': return $this->bbs(); break; case '积分换礼': case '换礼': case '积分商城': return $this->gift(); break; default: $check = $this->user('diynum', $key); if ($check['diynum'] != 1) { return array(C('connectout'), 'text'); } else { return $this->keyword($key); } } } }
private function reply($data) { # Log::write(json_encode($data)); M('Wxuser_message')->add($data); //if($data['Location_X']){ //return $this->map($data['Location_X'],$data['Location_Y']); //} if ('CLICK' == $data['Event']) { $data['Content'] = $data['EventKey']; } if ('voice' == $data['MsgType']) { $data['Content'] = $data['Recognition']; $this->data['Content'] = $data['Recognition']; } if ($data['Event'] == 'SCAN') { $data['Content'] = $this->getRecognition($data['EventKey']); if (!$data['Content']) { $other = M('Other')->where(array('token' => $this->token))->find(); return array($other['info'], 'text'); } else { $this->data['Content'] = $data['Content']; } } if ('subscribe' == $data['Event']) { $data['Content'] = $this->getSubscriber($data['EventKey']); $this->requestdata('follownum'); $data = M('Areply')->field('home,keyword,content')->where(array('token' => $this->token))->find(); if ($data['keyword'] == '首页' || $data['keyword'] == 'home') { return $this->shouye(); } if ($data['keyword'] == '微活动' || $data['keyword'] == 'Wreservation') { return $this->Wreservation(); } if ($data['home'] == 1) { // $like['keyword']=array('like','%'.$data['keyword'].'%'); $like['keyword'] = array('eq', $data['keyword']); $like['token'] = $this->token; $back = M('Img')->field('id,text,pic,url,title')->limit(9)->order('id desc')->where($like)->select(); foreach ($back as $keya => $infot) { if ($infot['url'] != false) { if (stristr($infot['url'], '?')) { $url = strip_tags(htmlspecialchars_decode($infot['url'])) . '&iVanvicms=mp.weixin.qq.com'; } else { $url = $infot['url'] . '?iVanvicms=mp.weixin.qq.com'; } } else { $url = rtrim(C('site_url'), '/') . U('Wap/Index/content', array('token' => $this->token, 'id' => $infot['id'], 'wecha_id' => $this->data['FromUserName'], 'iVanvicms' => 'mp.weixin.qq.com')); } if (stristr($infot['pic'], "http:")) { $purl = $infot['pic']; } else { $purl = rtrim(C('site_url'), '/') . $infot['pic']; } $return[] = array($infot['title'], $infot['text'], $purl, $url); } return array($return, 'news'); } else { return array(strip_tags(htmlspecialchars_decode($data['content'])), 'text'); } } elseif ('unsubscribe' == $data['Event']) { $this->requestdata('unfollownum'); } $Pin = new GetPin(); if (substr($data['Content'], 0, 3) == "yyy") { $key = "摇一摇"; $yyyphone = substr($data['Content'], 3, 11); } else { $key = $data['Content']; } $open = M('Token_open')->where(array('token' => $this->_get('token')))->find(); $this->fun = $open['queryname']; $datafun = explode(',', $open['queryname']); $tags = $this->get_tags($key); $back = explode(',', $tags); foreach ($back as $keydata => $data) { $string = $Pin->Pinyin($data); if (in_array($string, $datafun)) { $check = $this->user('connectnum'); if ($string == 'fujin') { $this->recordLastRequest($key); } $this->requestdata('textnum'); if ($check['connectnum'] != 1) { $return = C('connectout'); continue; } unset($back[$keydata]); eval('$return= $this->' . $string . '($back);'); continue; } } if (!empty($return)) { if (is_array($return)) { return $return; } else { return array($return, 'text'); } } else { 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('请发送您所在的位置', 'text'); } switch ($key) { case '首页': return $this->home(); break; case '主页': return $this->home(); break; case '微网站': return $this->home(); break; case '3G': return $this->home(); break; case '3g': return $this->home(); break; case '微官网': return $this->home(); break; case '地图': return $this->companyMap(); case '最近的': $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'); break; case '帮助': return $this->help(); break; case 'help': return $this->help(); break; case '会员卡': return $this->member(); break; case '会员': return $this->member(); break; case '您好': case '你好': case '在吗': case '有人吗': case '微客服': //回复多客服消息 // return array( // $key, // 'transfer_customer_service' // ); return array(array($key), 'transfer_customer_service'); break; default: $check = $this->user('diynum'); if ($check['diynum'] != 1) { return array(C('connectout'), 'text'); } return $this->keyword($key); } } }
private function reply($data) { if ('CLICK' == $data['Event']) { $data['Content'] = $data['EventKey']; $this->data['Content'] = $data['EventKey']; } elseif ($data['Event'] == 'SCAN') { $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'])); } elseif ('subscribe' == $data['Event']) { $this->behaviordata('follow', '1'); $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'])); } 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 array('', 'text'); } if ('voice' == $data['MsgType']) { $data['Content'] = $data['Recognition']; $this->data['Content'] = $data['Recognition']; } if ($data['Content'] == 'wechat ip') { return array($_SERVER['REMOTE_ADDR'], 'text'); } if (!(strpos($this->fun, 'api') === FALSE) && $data['Content']) { $apiData = M('Api')->where(array('token' => $this->token, 'status' => 1))->select(); foreach ($apiData as $apiArray) { if (!(strpos($data['Content'], $apiArray['keyword']) === FALSE)) { $api['type'] = $apiArray['type']; $api['url'] = $apiArray['url']; break; } } if ($api != false) { $vo['fromUsername'] = $this->data['FromUserName']; $vo['Content'] = $this->data['Content']; $vo['toUsername'] = $this->token; if ($api['type'] == 2) { $apidata = $this->api_notice_increment($api['url'], $vo); return array($apidata, 'text'); } else { $xml = file_get_contents("php://input"); $apidata = $this->api_notice_increment($api['url'], $xml); header("Content-type: text/xml"); exit($apidata); return false; } } } if ((!(strpos($data['Content'], 'shake') === FALSE) || !(strpos(strtolower($data['Content']), 'shake') === FALSE)) && strlen($data['Content']) == 16) { $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'], C('site_url') . '/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'], C('site_url') . '/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="' . C('site_url') . '/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'); } } } 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'); } $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('请发送您所在的位置', 'text'); } switch ($key) { case '首页': case 'home': return $this->home(); break; case '主页': return $this->home(); break; case '地图': return $this->companyMap(); case '最近的': $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'); break; case '帮助': return $this->help(); break; case 'help': return $this->help(); break; case '会员卡': return $this->member(); break; case '会员': return $this->member(); break; case '3g相册': return $this->xiangce(); break; case '相册': return $this->xiangce(); break; case '商城': $pro = M('reply_info')->where(array('infotype' => 'Shop', 'token' => $this->token))->find(); $url = C('site_url') . '/index.php?g=Wap&m=Store&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com'; if ($pro['apiurl']) { $url = str_replace('&', '&', $pro['apiurl']); } return array(array(array($pro['title'], strip_tags(htmlspecialchars_decode($pro['info'])), $pro['picurl'], $url)), 'news'); break; case '订餐': $pro = M('reply_info')->where(array('infotype' => 'Dining', 'token' => $this->token))->find(); $url = C('site_url') . '/index.php?g=Wap&m=Repast&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com'; if ($pro['apiurl']) { $url = str_replace('&', '&', $pro['apiurl']); } return array(array(array($pro['title'], strip_tags(htmlspecialchars_decode($pro['info'])), $pro['picurl'], $url)), 'news'); break; case '留言': $pro = M('reply_info')->where(array('infotype' => 'message', 'token' => $this->token))->find(); if ($pro) { return array(array(array($pro['title'], strip_tags(htmlspecialchars_decode($pro['info'])), $pro['picurl'], C('site_url') . '/index.php?g=Wap&m=Reply&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com')), 'news'); } else { return array(array(array('留言板', '在线留言', rtrim(C('site_url'), '/') . '/tpl/Wap/default/common/css/style/images/ly.jpg', C('site_url') . '/index.php?g=Wap&m=Reply&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com')), 'news'); } break; case '酒店': $pro = M('reply_info')->where(array('infotype' => 'Hotels', 'token' => $this->token))->find(); if ($pro) { return array(array(array($pro['title'], strip_tags(htmlspecialchars_decode($pro['info'])), $pro['picurl'], C('site_url') . '/index.php?g=Wap&m=Hotels&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'])), 'news'); } else { return array(array(array('酒店', '酒店在线预订', rtrim(C('site_url'), '/') . 'tpl/static/images/homelogo.png', C('site_url') . '/index.php?g=Wap&m=Hotels&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'])), 'news'); } break; case '团购': $pro = M('reply_info')->where(array('infotype' => 'Groupon', 'token' => $this->token))->find(); $url = C('site_url') . '/index.php?g=Wap&m=Groupon&a=grouponIndex&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com'; if ($pro['apiurl']) { $url = str_replace('&', '&', $pro['apiurl']); } return array(array(array($pro['title'], strip_tags(htmlspecialchars_decode($pro['info'])), $pro['picurl'], $url)), 'news'); break; case '全景': $pro = M('reply_info')->where(array('infotype' => 'panorama', 'token' => $this->token))->find(); if ($pro) { return array(array(array($pro['title'], strip_tags(htmlspecialchars_decode($pro['info'])), $pro['picurl'], C('site_url') . '/index.php?g=Wap&m=Panorama&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com')), 'news'); } else { return array(array(array('360°全景看车看房', '通过该功能可以实现3D全景看车看房', rtrim(C('site_url'), '/') . '/tpl/User/default/common/images/panorama/360view.jpg', C('site_url') . '/index.php?g=Wap&m=Panorama&a=index&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&sgssz=mp.weixin.qq.com')), 'news'); } break; case '微房产': $Estate = M('Estate')->where(array('token' => $this->token))->find(); return array(array(array($Estate['title'], str_replace(' ', '', strip_tags(htmlspecialchars_decode($Estate['estate_desc']))), $Estate['cover'], C('site_url') . '/index.php?g=Wap&m=Estate&a=index&&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'] . '&hid=' . $Estate['id'] . '&sgssz=mp.weixin.qq.com')), 'news'); break; case '讨论社区': case '论坛': $fconfig = M('Forum_config')->where(array('token' => $this->token))->find(); return array(array(array($fconfig['forumname'], str_replace(' ', '', strip_tags(htmlspecialchars_decode($fconfig['intro']))), $fconfig['picurl'], C('site_url') . '/index.php?g=Wap&m=Forum&a=index&&token=' . $this->token . '&wecha_id=' . $this->data['FromUserName'])), 'news'); break; default: $check = $this->user('diynum', $key); if ($check['diynum'] != 1) { return array(C('connectout'), 'text'); } else { 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); } }