Exemple #1
0
	private function reply($data)
	{
		$userinfoData = M('Userinfo')->where(array('token' => $this->token, 'wecha_id' => $this->data['FromUserName']))->find();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

					$row['is_check'] = 1;

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

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

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

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

				return $this->nokeywordApi();
			}
		}

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

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

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

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

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

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

						break;
					}
				}
			}
		}

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

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

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

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

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

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

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

			return $this->keyword($key);
		}
	}
Exemple #2
0
            } else {
                list($user, $domain) = explode("@", $email);
                if (!checkdnsrr($domain, "MX")) {
                    throw new InvalidEmailException("Invalid e-mail address!", $email);
                } else {
                    return 1;
                }
            }
        } catch (Exception $e) {
            echo $e->getMessage();
        } catch (InvalidEmailException $e) {
            echo $e->getMessage();
        }
    }
    /* This method would presumably add the user's e-mail address to
       a database. */
    function subscribeUser()
    {
        echo $this->email . " added to the database!";
    }
}
#end subscribe class
/* Assume that the e-mail address came from a subscription form. */
$_POST['email'] = "*****@*****.**";
/* Attempt to validate and add address to database. */
if (isset($_POST['email'])) {
    $subscribe = new subscribe();
    if ($subscribe->validateEmail($_POST['email'])) {
        $subscribe->subscribeUser($_POST['email']);
    }
}
 private function scan($id, $openid = '')
 {
     //获取粉丝信息
     import('subscribe', './source/class/');
     $subscribe = new subscribe();
     $subscribe->sub($openid);
     if ($id > 400000000 && $openid) {
         //return array($id.'_'.$openid, 'text');
         D('Location_qrcode')->where(array('id' => $id))->data(array('openid' => $openid, 'status' => 1))->save();
         return array('正在获取您的地理位置,如果十秒内没有响应,请点击左下角的加号将您的“位置”发送给我们', 'text');
     } elseif ($id > 300000000 && $openid) {
         $id -= 300000000;
         if ($order = M('Order')->field('`order_no`,`status`')->where(array('order_id' => $id))->find()) {
             if ($order['status'] < 2) {
                 return array('<a href="' . $this->config['wap_site_url'] . '/pay.php?id=' . $this->config['orderid_prefix'] . $order['order_no'] . '">查看订单详情</a>', 'text');
             } else {
                 return array('<a href="' . $this->config['wap_site_url'] . '/order.php?orderno=' . $this->config['orderid_prefix'] . $order['order_no'] . '">查看订单详情</a>', 'text');
             }
         } else {
             return array('获取不到该订单信息', 'text');
         }
         //https://api.weixin.qq.com/cgi-bin/user/info?access_token=ACCESS_TOKEN&openid=OPENID
     } else {
         if ($id > 290000000 && $openid) {
             $id -= 290000000;
             //if ($user = D('User')->field('uid')->where(array('openid' => $openid))->find()){
             if (D('Service')->where(array('store_id' => $id, 'openid' => $openid))->find()) {
                 return array('您已经绑定过客服,请不要重新绑定', 'text');
             } else {
                 D('Service')->data(array('store_id' => $id, 'openid' => $openid, 'add_time' => time()))->add();
                 return array('绑定客服成功,请前往补全客服信息', 'text');
             }
             //}
         } elseif ($id > 100000000 && $openid) {
             if ($user = D('User')->field('uid')->where(array('openid' => $openid))->find()) {
                 D('Login_qrcode')->where(array('id' => $id))->save(array('uid' => $user['uid']));
                 //获取地理位置
                 return array('登陆成功', 'text');
             } else {
                 D('Login_qrcode')->where(array('id' => $id))->save(array('uid' => -1));
                 $return[] = array('点击授权登录', '' . $openid . '', $this->config['site_logo'], $this->config['wap_site_url'] . '/weixin_bind.php?qrcode_id=' . $id);
                 return array($return, 'news');
             }
         }
     }
     if ($recognition = M("Recognition")->field(true)->where(array('id' => $id))->find()) {
         switch ($recognition['third_type']) {
             case 'group':
                 $now_group = D("Group")->field(true)->where(array('group_id' => $recognition['third_id']))->find();
                 $group_image_class = new group_image();
                 $tmp_pic_arr = explode(';', $now_group['pic']);
                 $image = $group_image_class->get_image_by_path($tmp_pic_arr[0], 's');
                 $return[] = array('[团购]' . $now_group['s_name'], $now_group['name'], $image, $this->config['site_url'] . "/wap.php?g=Wap&c=Group&a=detail&group_id={$now_group['group_id']}");
                 $this->saverelation($openid, $now_group['mer_id'], 0);
                 $return = $this->other_message($return, $now_group['mer_id'], $now_group['group_id']);
                 break;
             case 'merchant':
                 $now_merchant = D("Merchant")->field(true)->where(array('mer_id' => $recognition['third_id']))->find();
                 $pic = '';
                 if ($now_merchant['pic_info']) {
                     $images = explode(";", $now_merchant['pic_info']);
                     $merchant_image_class = new merchant_image();
                     $images = explode(";", $images[0]);
                     $pic = $merchant_image_class->get_image_by_path($images[0]);
                 }
                 $return[] = array('[商家]' . $now_merchant['name'], $now_merchant['txt_info'], $pic, $this->config['site_url'] . "/wap.php?g=Wap&c=Index&a=index&token={$recognition['third_id']}");
                 $return = $this->other_message($return, $now_merchant['mer_id']);
                 $this->saverelation($openid, $now_merchant['mer_id'], 1);
                 break;
             case 'meal':
                 $now_store = D("Merchant_store")->field(true)->where(array('store_id' => $recognition['third_id']))->find();
                 if ($now_store['have_meal']) {
                     $store_image_class = new store_image();
                     $images = $store_image_class->get_allImage_by_path($now_store['pic_info']);
                     $now_store['image'] = $images ? array_shift($images) : '';
                     $return[] = array('[订餐]' . $now_store['name'], $now_store['txt_info'], $now_store['image'], $this->config['site_url'] . "/wap.php?g=Wap&c=Meal&a=menu&mer_id={$now_store['mer_id']}&store_id={$now_store['store_id']}");
                 }
                 $this->saverelation($openid, $now_store['mer_id'], 0);
                 $return = $this->other_message($return, $now_store['mer_id'], 0, $now_store['store_id']);
                 break;
             case 'lottery':
                 $lottery = D("Lottery")->field(true)->where(array('id' => $recognition['third_id']))->find();
                 switch ($lottery['type']) {
                     case 1:
                         $return[] = array('[活动]' . $lottery['title'], $lottery['info'], $this->config['site_url'] . $lottery['starpicurl'], $this->config['site_url'] . "/wap.php?c=Lottery&a=index&token={$lottery['token']}&id={$lottery['id']}");
                         break;
                     case 2:
                         $return[] = array('[活动]' . $lottery['title'], $lottery['info'], $this->config['site_url'] . $lottery['starpicurl'], $this->config['site_url'] . "/wap.php?c=Guajiang&a=index&token={$lottery['token']}&id={$lottery['id']}");
                         break;
                     case 3:
                         $return[] = array('[活动]' . $lottery['title'], $lottery['info'], $this->config['site_url'] . $lottery['starpicurl'], $this->config['site_url'] . "/wap.php?c=Coupon&a=index&token={$lottery['token']}&id={$lottery['id']}");
                         break;
                     case 4:
                         $return[] = array('[活动]' . $lottery['title'], $lottery['info'], $this->config['site_url'] . $lottery['starpicurl'], $this->config['site_url'] . "/wap.php?c=LuckyFruit&a=index&token={$lottery['token']}&id={$lottery['id']}");
                         break;
                     case 5:
                         $return[] = array('[活动]' . $lottery['title'], $lottery['info'], $this->config['site_url'] . $lottery['starpicurl'], $this->config['site_url'] . "/wap.php?c=GoldenEgg&a=index&token={$lottery['token']}&id={$lottery['id']}");
                         break;
                 }
                 break;
         }
     }
     if ($return) {
         return array($return, 'news');
     }
     return array("很抱歉,暂时获取不到该二维码的信息!", 'text');
 }
<?php

set_time_limit(0);
chdir('/var/www/2009/');
if (count($argv) == 0) {
    exit;
}
require 'includes/application_top.php';
require 'includes/mailru_api.php';
require 'includes/subscribe.php';
$subscribe = new subscribe();
$mail = new Mailru_API();
$news = $subscribe->get_newsletters();
for ($i = 0; $i < count($news); $i++) {
    echo $news[$i]['title'] . "\n";
    $users = $subscribe->get_subscribers(unserialize($news[$i]['filter']));
    $subscribe->set_template_param('username', '<tmpl_var name>');
    $subscribe->update_newsletters($news[$i]['id'], 2);
    //Ставим статус рассылается
    //Устанавливаем переменные для статистики
    $subscribe->key_data['type_id'] = 0;
    //Устанавливем статус письма(0 - обычная рассылка)
    $subscribe->key_data['id'] = $news[$i]['id'];
    //Идентификатор отправляемого письма
    $subscribe->key_data['date'] = time();
    //Дата отправки
    $mail->init($news[$i]['title'], $subscribe->get_template_params($news[$i]['content']));
    while ($user = tep_db_fetch_array($users)) {
        //if($subscribe->debug) print_r($user);
        $mail->set_tmpl_var('name', $user['firstname']);
        $mail->add_recipient($user['firstname'] . ' ' . $user['lastname'], $user['email']);
Exemple #5
0
<?php

require_once '../../../admin/inc/klassen/subscribe.inc.php';
$subscribe = new subscribe();
foreach ($_POST['group'] as $key => $value) {
    $groupsArr[] = $value['value'];
}
echo $subscribe->mailChimpSubscribe(array('email' => $_POST['_email'], 'group' => $groupsArr, 'name' => $_POST['name'], 'surname' => $_POST['surname']));
<?php

set_time_limit(0);
chdir('/var/www/2009/');
if (count($argv) == 0) {
    exit;
}
require 'includes/application_top.php';
require 'includes/mailru_api.php';
require 'includes/subscribe.php';
$subscribe = new subscribe();
$mailAPI = new Mailru_API();
$mailAPI->status_loger = 0;
$mailAPI->log_path = 'logs/mail_cron.log';
//1: Тематики и разделы
$categories_query = tep_db_query("SELECT s.category_id as id, c.categories_name as name FROM subscribe s\n\tLEFT JOIN " . TABLE_CATEGORIES_DESCRIPTION . " AS c ON c.categories_id = s.category_id\n\tWHERE s.type_id = 1\n\tAND c.language_id = 2\n\tGROUP BY id;");
$subscribe->type = 1;
$subscribe->get_new_products_list($categories_query, &$mailAPI);
//2: Серии
$categories_query = tep_db_query("SELECT s.category_id as id, c.series_name as name FROM subscribe s\n\tLEFT JOIN " . TABLE_SERIES . " AS c ON c.series_id = s.category_id\n\tWHERE s.type_id = 2\n\tAND c.language_id = 2\n\tGROUP BY id;");
$subscribe->type = 2;
$subscribe->get_new_products_list($categories_query, &$mailAPI);
//3: Авторы
$categories_query = tep_db_query("SELECT s.category_id as id, c.authors_name as name FROM subscribe s\n\tLEFT JOIN " . TABLE_AUTHORS . " AS c ON c.authors_id = s.category_id\n\tWHERE s.type_id = 3\n\tAND c.language_id = 2\n\tGROUP BY id;");
$subscribe->type = 3;
$subscribe->get_new_products_list($categories_query, &$mailAPI);
//4: Издательство
$categories_query = tep_db_query("SELECT s.category_id as id, c.manufacturers_name as name FROM subscribe s\n\tLEFT JOIN " . TABLE_MANUFACTURERS_INFO . " AS c ON c.manufacturers_id = s.category_id\n\tWHERE s.type_id = 4\n\tAND c.languages_id = 2\n\tGROUP BY id;");
$subscribe->type = 4;
$subscribe->get_new_products_list($categories_query, &$mailAPI);
?>
 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);
     }
 }