Пример #1
0
 public function responseMsg()
 {
     $postStr = $GLOBALS["HTTP_RAW_POST_DATA"];
     if (!empty($postStr)) {
         libxml_disable_entity_loader(true);
         /**
          * 接收到的xml消息
          */
         $object = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
         $fromUsername = $object->FromUserName;
         // $toUsername = $object->ToUserName;
         /**
          * 接收到的关键字
          */
         $keyword = trim($object->Content);
         /**
          * 接收到的消息类型 (text,image,voice,video,location,link,event)
          */
         $msgType = $object->MsgType;
         /**
          * 包含消息回复工具类
          */
         require_once 'utils/Reply.class.php';
         $replyObj = new Reply();
         /**
          * 初始化缓存
          */
         $mmc = memcache_init();
         /**
          * 数据库操作类
          */
         require_once 'utils/Mysql.class.php';
         $class_mysqlObj = new Class_mysql();
         /**
          * 校花校草类
          */
         require_once 'topStudent/getTopInfo.php';
         /**
          * 图书馆相关类
          */
         require_once 'lib/libInfoAction.php';
         require_once 'lib/time.php';
         require_once 'lib/renewBook.php';
         require_once 'lib/queryBook.php';
         /**
          * 得到学生的姓名
          */
         $sql_state = "select name from tb_studentinfo where openid='{$fromUsername}'";
         $studentInfoArr = $class_mysqlObj->query_array($sql_state);
         $studentName = $studentInfoArr[0]['name'];
         /**
          * 更新最后交互时间
          */
         $lastTime = time();
         $sql_state1 = "select * from tb_studentdashan where openid='{$fromUsername}'";
         $fakeid2openid = $class_mysqlObj->query_array($sql_state1);
         if (!empty($fakeid2openid)) {
             $sql_state = "update tb_studentdashan set lastTime = '{$lastTime}' where openid='{$fromUsername}'";
             $class_mysqlObj->query($sql_state);
         }
         switch ($msgType) {
             case 'text':
                 // 是查看是否有聊天的缓存
                 $memcacheLt = memcache_get($mmc, $fromUsername . "lt");
                 // ============================================= 改动
                 if ($memcacheLt == "wlt") {
                     /* 进入聊天模块 */
                     if ($keyword == "886") {
                         $content = "拜拜[再见]\n-------\n☞已退出聊天模式,欢迎使用其它功能[跳跳]";
                         memcache_delete($mmc, $fromUsername . "lt");
                         // 删除缓存
                     } else {
                         $ltUrl = "http://api.mrtimo.com/Simsimi.ashx?parm={$keyword}";
                         $content = file_get_contents($ltUrl);
                         $content = $content . "\n\n☞聊天模式☞退出发送【886】";
                     }
                 } else {
                     if (substr($keyword, 0, strlen("绑定地点")) == "绑定地点") {
                         $keywordArr = explode(",", $keyword);
                         $userPlace = $keywordArr[1];
                         memcache_set($mmc, $fromUsername . "userPlace", $userPlace);
                         // 把用户所在地加入用户所在地缓存
                         $content = "所在地绑定成功,请再次点击【今日天气】";
                     } else {
                         if (preg_match('/课表,[1-7]/', $keyword)) {
                             /**
                              * 判断用户是否已经认证
                              */
                             // $mmc_Openid = memcache_get ( $mmc, $fromUsername . "zjh" );
                             if (empty($studentName)) {
                                 $content = "首次查询需要教务认证哦![愉快]<a href=\"http://218.196.240.171/weixinapi/index.php/Home/Jiaowu/loginview/openid/{$fromUsername}\">点我认证</a>";
                             } else {
                                 $keywordArr = explode(",", $keyword);
                                 /* 要查询的星期 */
                                 $week = $keywordArr[1];
                                 /* 当前周 */
                                 $weeklyNow = date('W') - 36;
                                 if ($week == 6) {
                                     $content = "星期六,全天没课哦 \n🚶听说学霸都会点这里\n<a href=\"http://ifreeweixin.sinaapp.com/kongJs/kongjs.php\">📚空闲教室</a>\n\n👑听说学神都会点这里\n<a href=\"http://m.wsq.qq.com/264077463\">📚来点我呀</a>";
                                 } else {
                                     if ($week == 7) {
                                         $content = "星期日,全天没课哦 \n🚶听说学霸都会点这里\n<a href=\"http://ifreeweixin.sinaapp.com/kongJs/kongjs.php\">📚空闲教室</a>\n\n👑听说学神都会点这里\n<a href=\"http://m.wsq.qq.com/264077463\">📚来点我呀</a>";
                                     } else {
                                         $content = array();
                                         $weekNumArr = array(1 => "一", 2 => "二", 3 => "三", 4 => "四", 5 => "五");
                                         $content[] = array("Title" => "星期{$weekNumArr[$week]}课表如下:👇(📅第{$weeklyNow}周)", "Description" => "", "PicUrl" => "", "Url" => "ifreeweixin.sinaapp.com/kcbView/kcbView.php?openid={$fromUsername}");
                                         // 节次数组
                                         $sectionArr = array("一", "三", "五", "七", "九");
                                         foreach ($sectionArr as $key => $section) {
                                             // 几节到几节
                                             $sectionTo1 = $key * 2 + 1;
                                             $sectionTo2 = $key * 2 + 2;
                                             $sql_state = "select course_name,teaching_building,teaching_number,course_teacher,startWeekly,endWeekly from tb_studentsyllabus where openid='{$fromUsername}' and week='{$week}' and section='{$section}' and startWeekly<={$weeklyNow} and endWeekly>={$weeklyNow}";
                                             // 查询结果
                                             $resultArr = $class_mysqlObj->query_array($sql_state);
                                             if ($resultArr == null) {
                                                 $content[] = array("Title" => "{$sectionTo1}-{$sectionTo2} 节:\n👻没有课哦\n📢点击可查看空闲教室哦", "Description" => "", "PicUrl" => "", "Url" => "http://ifreeweixin.sinaapp.com/kongJs/kongjs.php");
                                             } else {
                                                 $course_name = $resultArr[0]['course_name'];
                                                 // 课程名
                                                 $teaching_building = $resultArr[0]['teaching_building'];
                                                 // 教学楼
                                                 $teaching_number = $resultArr[0]['teaching_number'];
                                                 // 教室
                                                 $course_teacher = $resultArr[0]['course_teacher'];
                                                 // 老师
                                                 $startWeekly = $resultArr[0]['startWeekly'];
                                                 // 开始周
                                                 $endWeekly = $resultArr[0]['endWeekly'];
                                                 // 结束周
                                                 if (!empty($resultArr[1]['course_name'])) {
                                                     $course_name2 = $resultArr[1]['course_name'];
                                                     // 课程名
                                                     $teaching_building2 = $resultArr[1]['teaching_building'];
                                                     // 教学楼
                                                     $teaching_number2 = $resultArr[1]['teaching_number'];
                                                     // 教室
                                                     $course_teacher2 = $resultArr[1]['course_teacher'];
                                                     // 老师
                                                     $startWeekly2 = $resultArr[1]['startWeekly'];
                                                     // 开始周
                                                     $endWeekly2 = $resultArr[1]['endWeekly'];
                                                     // 结束周
                                                     $title2 = "\n--------\n" . $course_name2 . "\n📍" . $teaching_building2 . $teaching_number2 . "\n🕘" . $course_teacher2 . "({$startWeekly2}-{$endWeekly2} 周上)";
                                                 }
                                                 $title = "{$sectionTo1}-{$sectionTo2} 节:\n" . $course_name . "\n📍" . $teaching_building . $teaching_number . "\n🕘" . $course_teacher . "({$startWeekly}-{$endWeekly} 周上)" . $title2;
                                                 $content[] = array("Title" => "{$title}", "Description" => "", "PicUrl" => "", "Url" => "ifreeweixin.sinaapp.com/kcbView/kcbView.php?openid={$fromUsername}");
                                             }
                                             $title2 = "";
                                         }
                                         $content[] = array("Title" => "💬回复课表+数字可以查看任意星期的课表哦,如【课表,1】\n㊙点击可以查看全周课表", "Description" => "", "PicUrl" => "", "Url" => "ifreeweixin.sinaapp.com/kcbView/kcbView.php?openid={$fromUsername}");
                                         echo $replyObj->transmitNews($object, $content);
                                         return;
                                     }
                                 }
                             }
                         } else {
                             if ($keyword == "朗读") {
                                 $json_string = file_get_contents('http://apix.sinaapp.com/daily/?appkey=ifreeweixin&type=listening');
                                 // 读取文件
                                 $obj = json_decode($json_string);
                                 $title = "每日英语朗读";
                                 $description = "听不懂,点击【每日英语】查看";
                                 $musicUrl = $obj->MusicUrl;
                                 $content = array("Title" => "{$title}", "Description" => "{$description}", "MusicUrl" => "{$musicUrl}", "HQMusicUrl" => "{$musicUrl}");
                                 echo $replyObj->transmitMusic($object, $content);
                                 return;
                             } else {
                                 if (substr_count($keyword, '成绩')) {
                                     /**
                                      * 判断用户是否已经认证
                                      */
                                     // $mmc_Openid = memcache_get ( $mmc, $fromUsername . "zjh" );
                                     if (empty($studentName)) {
                                         // 成绩未认证转到认证页面
                                         $scoreUrl = "http://218.196.240.171/weixinapi/index.php/Home/Jiaowu/loginview/openid/{$fromUsername}";
                                         // 体育未认证转到认证页面
                                         $peUrl = "http://218.196.240.171/weixinapi/index.php/Home/Jiaowu/loginview/openid/{$fromUsername}";
                                     } else {
                                         // 已经认证转到成绩页面
                                         $scoreUrl = "http://ifreeweixin.sinaapp.com/scoreView/scoreResultView.php?openid={$fromUsername}";
                                         // 已经认证转到体育达标页面
                                         $peUrl = "http://ifreeweixin.sinaapp.com/peQuery/peView.php?openid={$fromUsername}";
                                     }
                                     $content = array();
                                     $content[] = array("Title" => "💯期末成绩", "Description" => "", "PicUrl" => "https://mmbiz.qlogo.cn/mmbiz/EKniaJHUPHicRgibybsdwUO172PBkQtZzlyfiajHev0mE4QXic2vbOEJgcDIc1TJthkprMzZk3hqZPjppWibgNz7Zd1w/0", "Url" => $scoreUrl);
                                     $content[] = array("Title" => "💯四六级成绩", "Description" => "", "PicUrl" => "https://mmbiz.qlogo.cn/mmbiz/EKniaJHUPHicRgibybsdwUO172PBkQtZzlyChU8rZ7t9TjgXymc2hicWkCdDW16ZtV7M9PiahpA9RYP5dxQ6QAfvwNQ/0", "Url" => "http://ifreeweixin.sinaapp.com/cet46/cet46View.php?openid={$fromUsername}");
                                     $content[] = array("Title" => "💯体育达标测试", "Description" => "", "PicUrl" => "https://mmbiz.qlogo.cn/mmbiz/EKniaJHUPHicRgibybsdwUO172PBkQtZzlyEuZqXftqDwDzWtnicTNGkYWFHwyewTVE9tJygxaE4RtDMq9lk2jH0xA/0", "Url" => $peUrl);
                                     $content[] = array("Title" => "💯普通话水平测试", "Description" => "", "PicUrl" => "https://mmbiz.qlogo.cn/mmbiz/EKniaJHUPHicRgibybsdwUO172PBkQtZzlysmt4Xicn26zEUjIpVKV32roUcDJvjvLjq7m11vTEA88QjCyLAwYan5w/0", "Url" => "");
                                     $content[] = array("Title" => "💯全国计算机等级考试", "Description" => "", "PicUrl" => "https://mmbiz.qlogo.cn/mmbiz/EKniaJHUPHicRgibybsdwUO172PBkQtZzlyz59ib3tXt3d8WfpLjNUJ8wAASaqcr9T8sMaDsctEYQVIjVYS9arhSicA/0", "Url" => "");
                                     echo $replyObj->transmitNews($object, $content);
                                     return;
                                 } else {
                                     if (preg_match("/重绑密码,[A-Za-z0-9]+/", $keyword)) {
                                         $keywordArr = explode(",", $keyword);
                                         $userPassword = $keywordArr[1];
                                         $sql_state = "update tb_studentinfo set password = '******'where openid='{$fromUsername}'";
                                         if ($class_mysqlObj->query($sql_state) && memcache_set($mmc, $fromUsername . "password", $userPassword)) {
                                             $content = "重绑密码成功[跳跳],为了你的密码安全请删除上条信息后继续你的操作";
                                         } else {
                                             $content = "重绑密码失败,请查看回复格式是否正确\n\n例子:\n重绑密码,123456";
                                         }
                                     } else {
                                         if ($keyword == "男神") {
                                             $resultArr = memcache_get($mmc, "topxiaocao");
                                             if (empty($resultArr)) {
                                                 $resultArr = getTopXiaocao();
                                             }
                                             $content = array();
                                             $content[] = array("Title" => "理工男神!点击可为他投票哦", "Description" => "", "PicUrl" => "https://mmbiz.qlogo.cn/mmbiz/EKniaJHUPHicStTQ0mMDVfW9395ElfDl2Pjk7cRwhniahMIcibSAX1hPECFiaRaUWFnLsAIrRWgmKficqaCAM6z5yGGA/0?wx_fmt=jpeg", "Url" => "http://www.facejoking.com/top/18601/1");
                                             for ($i = 0; $i < count($resultArr); $i++) {
                                                 $a = $i + 1;
                                                 $content[] = array("Title" => "Top{$a} " . $resultArr[$i]['title'], "Description" => "", "PicUrl" => $resultArr[$i]['picUrl'], "Url" => $resultArr[$i]['url']);
                                             }
                                             echo $replyObj->transmitNews($object, $content);
                                             return;
                                             //$content = '对方网站维护中……暂时无法查询';
                                         } else {
                                             if ($keyword == "女神") {
                                                 $resultArr = memcache_get($mmc, "topxiaohua");
                                                 if (empty($resultArr)) {
                                                     $resultArr = getTopXiaohua();
                                                 }
                                                 $content = array();
                                                 $content[] = array("Title" => "理工女神!点击可为她投票哦", "Description" => "", "PicUrl" => "https://mmbiz.qlogo.cn/mmbiz/EKniaJHUPHicStTQ0mMDVfW9395ElfDl2PReFXQUTd9HyB6c1FR8y700yxvJEO7dJsd0O1gZCBTicaD4hOstzt3Sg/0?wx_fmt=jpeg", "Url" => "http://www.facejoking.com/top/18601/0");
                                                 for ($i = 0; $i < count($resultArr); $i++) {
                                                     $a = $i + 1;
                                                     $content[] = array("Title" => "Top{$a} " . $resultArr[$i]['title'], "Description" => "", "PicUrl" => $resultArr[$i]['picUrl'], "Url" => $resultArr[$i]['url']);
                                                 }
                                                 echo $replyObj->transmitNews($object, $content);
                                                 return;
                                                 //$content = '对方网站维护中……暂时无法查询';
                                             } else {
                                                 if ($keyword == "当前借阅") {
                                                     /**
                                                      * 判断用户是否已经认证
                                                      */
                                                     // $studentid = memcache_get ( $mmc, $fromUsername . "zjh" );
                                                     if (empty($studentName)) {
                                                         $content = "首次查询需要教务认证哦![愉快]<a href=\"http://218.196.240.171/weixinapi/index.php/Home/Jiaowu/loginview/openid/{$fromUsername}\">点我认证</a>";
                                                     } else {
                                                         // 得到当前借阅信息
                                                         $borrowNowArr = getBorrowNow($fromUsername);
                                                         if (!empty($borrowNowArr)) {
                                                             // 获取当前借阅为几本
                                                             $bookSum = count($borrowNowArr);
                                                             // 超期图书数目
                                                             $bookOutNum = 0;
                                                             $content = array();
                                                             foreach ($borrowNowArr as $bookInfo) {
                                                                 $returnTime = $bookInfo['returnTime'];
                                                                 $days = getTime($returnTime);
                                                                 if ($days < 0) {
                                                                     $bookOutNum++;
                                                                 }
                                                             }
                                                             $content[] = array("Title" => "{$studentName}同学,你当前借阅情况如下:\n数目:{$bookSum}本\t已超期:{$bookOutNum}本\n👻可以点击书名续借哦", "Description" => "", "PicUrl" => "", "Url" => "");
                                                             foreach ($borrowNowArr as $key => $bookInfo) {
                                                                 $numStr = $key + 1;
                                                                 $title = $numStr . "." . $bookInfo['bookName'] . "\n地点:" . $bookInfo['bookPlace'] . "\n借阅日期:" . $bookInfo['borrowTime'] . "\n应还日期:" . $bookInfo['returnTime'] . "\n续借次数:" . $bookInfo['number'];
                                                                 if ($bookInfo['number'] == 0) {
                                                                     $url = "http://ifreeweixin.sinaapp.com/lib/newsRenewView.php?openid={$fromUsername}&&numStr={$numStr}";
                                                                 } else {
                                                                     $url = "http://ifreeweixin.sinaapp.com/lib/error.php";
                                                                 }
                                                                 $content[] = array("Title" => $title, "Description" => "", "PicUrl" => "", "Url" => $url);
                                                             }
                                                             echo $replyObj->transmitNews($object, $content);
                                                             return;
                                                         } else {
                                                             $content = "亲,你目前还没有借任何书哦\n\n如果查询结果不对\n👉<a href=\"http://lib.hpu.edu.cn/\">可以点这里哦</a>";
                                                         }
                                                     }
                                                 } else {
                                                     if (substr_count($keyword, '续借')) {
                                                         $bookNumStr = substr($keyword, strlen("续借"), strlen($keyword) - strlen("续借"));
                                                         if (!empty($bookNumStr)) {
                                                             $bookNumArr = explode(",", $bookNumStr);
                                                             $content = renewBook($openid, $bookNumArr);
                                                         } else {
                                                             $content = "输入格式不对\n\n例子1:续借1\n续借第一本书\n\n例子2:续借1,3\n续借第一本和第三本书";
                                                         }
                                                     } else {
                                                         if (substr_count($keyword, '检索')) {
                                                             $bookName = substr($keyword, strlen("检索"), strlen($keyword) - strlen("检索"));
                                                             $bookInfoArr = queryBook($bookName);
                                                             $content = array();
                                                             $content[] = array("Title" => "🏢理工图书馆检索结果如下", "Description" => "", "PicUrl" => "https://mmbiz.qlogo.cn/mmbiz/EKniaJHUPHicSRfX5wib5PVk5Yotnq3UIJUNdSBYG2EmMbYibgKs2Eop3A7H2PiaUFiblfZLD4lADCwQTgico4Pp27UibA/0?wx_fmt=jpeg", "Url" => "");
                                                             foreach ($bookInfoArr as $key => $bookInfo) {
                                                                 $num = $key + 1;
                                                                 $title = iconv('gbk', 'utf-8', $num . "." . $bookInfo[0]) . "\n🔍" . iconv('gbk', 'utf-8', $bookInfo[1]) . "\n📍地点:" . iconv('gbk', 'utf-8', $bookInfo[2]) . "\n🔔" . iconv('gbk', 'utf-8', $bookInfo[3]);
                                                                 $content[] = array("Title" => $title, "Description" => "", "PicUrl" => "", "Url" => "");
                                                             }
                                                             echo $replyObj->transmitNews($object, $content);
                                                             return;
                                                         } else {
                                                             if ($keyword == "饭卡余额") {
                                                                 /**
                                                                  * 判断用户是否已经认证
                                                                  */
                                                                 // $studentid = memcache_get ( $mmc, $fromUsername . "zjh" );
                                                                 if (empty($studentName)) {
                                                                     $content = "首次查询需要教务认证哦![愉快]<a href=\"http://218.196.240.171/weixinapi/index.php/Home/Jiaowu/loginview/openid/{$fromUsername}\">点我认证</a>";
                                                                 } else {
                                                                     require_once 'personInfo/getEcard.php';
                                                                     $infoArr = getEcard($fromUsername);
                                                                     // 赛课作业数量
                                                                     $saiKeNum = $infoArr[0];
                                                                     // 借书数量
                                                                     $bookNum = $infoArr[1];
                                                                     // 超期图书数量
                                                                     $outBookNum = $infoArr[2];
                                                                     // 饭卡余额
                                                                     $eCardMoney = $infoArr[3];
                                                                     $content = "{$studentName}同学,你的饭卡余额为:{$eCardMoney}元";
                                                                     $content .= "\n\n【温馨提示】\n<a href=\"http://ifreeweixin.sinaapp.com/personInfo/saikeView.php?openid={$fromUsername}\">赛课作业</a>:{$saiKeNum}项\n图书借阅:{$bookNum}本,超期{$outBookNum}本";
                                                                     $content .= "\n\n【查询更多】\n回复:最新公告\n查看学校最新公告\n\n回复:校内招聘\n查看校内招聘信息\n\n回复:校外招聘\n查看校外招聘信息\n\n回复:学术讲座\n查看近期讲座安排";
                                                                     $content .= "\n\n<a href=\"http://hao.uc.cn/bst#!/index/\">点我查询生活百事</a>\n包括快递、公交等常用查询";
                                                                 }
                                                                 break;
                                                             } else {
                                                                 if ($keyword == "最新公告") {
                                                                     // 查看缓存中是否已有最新公告的缓存
                                                                     $newInfoArr = memcache_get($mmc, 'newInfoArr');
                                                                     if (empty($newInfoArr)) {
                                                                         /**
                                                                          * 判断用户是否已经认证
                                                                          */
                                                                         // $studentid = memcache_get ( $mmc, $fromUsername . "zjh" );
                                                                         if (empty($studentName)) {
                                                                             $content = "首次查询需要教务认证哦![愉快]<a href=\"http://218.196.240.171/weixinapi/index.php/Home/Jiaowu/loginview/openid/{$fromUsername}\">点我认证</a>";
                                                                         } else {
                                                                             require_once 'personInfo/getNewInfo.php';
                                                                             $newInfoArr = getNewInfo($fromUsername);
                                                                         }
                                                                     }
                                                                     $content = array();
                                                                     $content[] = array("Title" => "🏢理工最新公告", "Description" => "", "PicUrl" => "http://mmsns.qpic.cn/mmsns/EKniaJHUPHicROc3WBNbaiac4DrrLNYGnMb665BJvdxrZsUlEpcP0hhTg/0", "Url" => "");
                                                                     foreach ($newInfoArr as $newInfo) {
                                                                         $title = $newInfo['title'] . "\n" . "发布时间:" . $newInfo['time'];
                                                                         $url = $newInfo['url'];
                                                                         $content[] = array("Title" => $title, "Description" => "", "PicUrl" => "", "Url" => $url);
                                                                     }
                                                                     echo $replyObj->transmitNews($object, $content);
                                                                     return;
                                                                 } else {
                                                                     if ($keyword == "校内招聘") {
                                                                         // 查看缓存中是否已有校内招聘的缓存
                                                                         $schoolZhaoArr = memcache_get($mmc, 'schoolZhaoArr');
                                                                         if (empty($schoolZhaoArr)) {
                                                                             /**
                                                                              * 判断用户是否已经认证
                                                                              */
                                                                             // $studentid = memcache_get ( $mmc, $fromUsername . "zjh" );
                                                                             if (empty($studentName)) {
                                                                                 $content = "首次查询需要教务认证哦![愉快]<a href=\"http://218.196.240.171/weixinapi/index.php/Home/Jiaowu/loginview/openid/{$fromUsername}\">点我认证</a>";
                                                                             } else {
                                                                                 require_once 'personInfo/getSchoolZhao.php';
                                                                                 $schoolZhaoArr = getSchoolZhao($fromUsername);
                                                                             }
                                                                         }
                                                                         $content = array();
                                                                         $content[] = array("Title" => "🏢理工校内招聘", "Description" => "", "PicUrl" => "https://mmbiz.qlogo.cn/mmbiz/EKniaJHUPHicROc3WBNbaiac4DrrLNYGnMb8LM9Dgs0EicGiawpRnOABZzU6GE3zwORgJCf5RYc6GUpF5zDvOvzFBaw/0?wx_fmt=jpeg", "Url" => "");
                                                                         foreach ($schoolZhaoArr[0] as $schoolInZhaoArr) {
                                                                             $title = $schoolInZhaoArr[0] . "\n" . "发布时间:" . $schoolInZhaoArr[2];
                                                                             $url = $schoolInZhaoArr[1];
                                                                             $content[] = array("Title" => $title, "Description" => "", "PicUrl" => "", "Url" => $url);
                                                                         }
                                                                         echo $replyObj->transmitNews($object, $content);
                                                                         return;
                                                                     } else {
                                                                         if ($keyword == "校外招聘") {
                                                                             // 查看缓存中是否已有校外招聘的缓存
                                                                             $schoolZhaoArr = memcache_get($mmc, 'schoolZhaoArr');
                                                                             if (empty($schoolZhaoArr)) {
                                                                                 /**
                                                                                  * 判断用户是否已经认证
                                                                                  */
                                                                                 // $studentid = memcache_get ( $mmc, $fromUsername . "zjh" );
                                                                                 if (empty($studentName)) {
                                                                                     $content = "首次查询需要教务认证哦![愉快]<a href=\"http://218.196.240.171/weixinapi/index.php/Home/Jiaowu/loginview/openid/{$fromUsername}\">点我认证</a>";
                                                                                 } else {
                                                                                     require_once 'personInfo/getSchoolZhao.php';
                                                                                     $schoolZhaoArr = getSchoolZhao($fromUsername);
                                                                                 }
                                                                             }
                                                                             $content = array();
                                                                             $content[] = array("Title" => "🏢理工校外招聘", "Description" => "", "PicUrl" => "https://mmbiz.qlogo.cn/mmbiz/EKniaJHUPHicROc3WBNbaiac4DrrLNYGnMb8LM9Dgs0EicGiawpRnOABZzU6GE3zwORgJCf5RYc6GUpF5zDvOvzFBaw/0?wx_fmt=jpeg", "Url" => "");
                                                                             foreach ($schoolZhaoArr[1] as $schoolOutZhaoArr) {
                                                                                 $title = $schoolOutZhaoArr[0] . "\n" . "发布时间:" . $schoolOutZhaoArr[2];
                                                                                 $url = $schoolOutZhaoArr[1];
                                                                                 $content[] = array("Title" => $title, "Description" => "", "PicUrl" => "", "Url" => $url);
                                                                             }
                                                                             echo $replyObj->transmitNews($object, $content);
                                                                             return;
                                                                         } else {
                                                                             if ($keyword == "学术讲座") {
                                                                                 // 查看缓存中是否已有学术讲座的缓存
                                                                                 $xueShuInfoArr = memcache_get($mmc, 'xueShuInfoArr');
                                                                                 if (empty($xueShuInfoArr)) {
                                                                                     /**
                                                                                      * 判断用户是否已经认证
                                                                                      */
                                                                                     // $studentid = memcache_get ( $mmc, $fromUsername . "zjh" );
                                                                                     if (empty($studentName)) {
                                                                                         $content = "首次查询需要教务认证哦![愉快]<a href=\"http://218.196.240.171/weixinapi/index.php/Home/Jiaowu/loginview/openid/{$fromUsername}\">点我认证</a>";
                                                                                     } else {
                                                                                         require_once 'personInfo/getXueshu.php';
                                                                                         $xueShuInfoArr = getXueshu($fromUsername);
                                                                                     }
                                                                                 }
                                                                                 $content = array();
                                                                                 $content[] = array("Title" => "🏢理工学术讲座", "Description" => "", "PicUrl" => "https://mmbiz.qlogo.cn/mmbiz/EKniaJHUPHicROc3WBNbaiac4DrrLNYGnMb1rKnIW6V1pAXyfmvh7icKiaHc7QMXicQEBovCPfEUibVNYDbcqQUVzbymg/0?wx_fmt=jpeg", "Url" => "");
                                                                                 foreach ($xueShuInfoArr as $xueShuInfo) {
                                                                                     $title = "【题目】" . $xueShuInfo[0] . "\n【老师】" . $xueShuInfo[2] . "\n【时间】" . $xueShuInfo[3] . "\n【地点】" . $xueShuInfo[4];
                                                                                     $url = $xueShuInfo[1];
                                                                                     $content[] = array("Title" => $title, "Description" => "", "PicUrl" => "", "Url" => $url);
                                                                                 }
                                                                                 echo $replyObj->transmitNews($object, $content);
                                                                                 return;
                                                                             } else {
                                                                                 if ($keyword == "倒计时") {
                                                                                     $content = "开学倒计时,你猜还有多少天?<a href=\"http://ifreeweixin.sinaapp.com/daojishi/index.html\">点击进入</a>";
                                                                                 } else {
                                                                                     if ($keyword == "四六级") {
                                                                                         $content = "四六级成绩查询:\n\n";
                                                                                         $content .= "入口一:\n<a href=\"http://ifreeweixin.sinaapp.com/cet46/cet46View.php?openid={$fromUsername}\">知道准考证的点这里</a>\n\n";
                                                                                         $content .= "入口二:\n<a href=\"http://cet.forchange.cn/?aid=3qVhg4POSvtza3BTRjzzSwFb6zaihaBbqzaa\">忘记准考证的点这里</a>\n\n";
                                                                                     } else {
                                                                                         if ($keyword == "搭讪" || $keyword == "搭讪汉纸" || $keyword == "搭讪妹纸" || $keyword == "搭讪汉子" || $keyword == "搭讪妹子") {
                                                                                             $sql_state11 = "select fakeid from tb_studentdashan where openid='{$fromUsername}'";
                                                                                             $fromUserFakeidArr = $class_mysqlObj->query_array($sql_state11);
                                                                                             $fromUserFakeid = $fromUserFakeidArr[0]['fakeid'];
                                                                                             $nowTime = time();
                                                                                             // 取出现在的时间
                                                                                             if ($keyword == "搭讪") {
                                                                                                 $sql_state = "select fakeid,nick_name,place,sex,lastTime from tb_studentdashan where '{$nowTime}'-lastTime<172800 and openid is not null and fakeid !='{$fromUserFakeid}' order by lastTime desc";
                                                                                             } else {
                                                                                                 if ($keyword == "搭讪汉纸" || $keyword == "搭讪汉子") {
                                                                                                     $sql_state = "select fakeid,nick_name,place,sex,lastTime from tb_studentdashan where '{$nowTime}'-lastTime<172800 and openid is not null and fakeid !='{$fromUserFakeid}' and sex='汉纸' order by lastTime desc";
                                                                                                 } else {
                                                                                                     if ($keyword == "搭讪妹纸" || $keyword == "搭讪妹子") {
                                                                                                         $sql_state = "select fakeid,nick_name,place,sex,lastTime from tb_studentdashan where '{$nowTime}'-lastTime<172800 and openid is not null and fakeid !='{$fromUserFakeid}' and sex='妹纸' order by lastTime desc";
                                                                                                     }
                                                                                                 }
                                                                                             }
                                                                                             $studentDaShanInfoArr = $class_mysqlObj->query_array($sql_state);
                                                                                             // 随机取出一位搭讪者
                                                                                             $daShanNum = rand(0, count($studentDaShanInfoArr) - 1);
                                                                                             $toFakeid = $studentDaShanInfoArr[$daShanNum]['fakeid'];
                                                                                             $nick_name = $studentDaShanInfoArr[$daShanNum]['nick_name'];
                                                                                             $place = $studentDaShanInfoArr[$daShanNum]['place'] != null ? "来自" . $studentDaShanInfoArr[$daShanNum]['place'] . "的" : "";
                                                                                             $sex = $studentDaShanInfoArr[$daShanNum]['sex'] == "汉纸" ? $studentDaShanInfoArr[$daShanNum]['sex'] . "👦" : "妹纸👧";
                                                                                             $lastTime = $studentDaShanInfoArr[$daShanNum]['lastTime'];
                                                                                             $lastTime = date("Y-m-d H:i:s", $lastTime);
                                                                                             $content = "成功匹配到" . $place . $nick_name . $sex . "\n\n";
                                                                                             $content .= "ta最后一次会话时间:\n" . $lastTime . "\n\n";
                                                                                             $content .= "<a href=\"http://ifreeweixin.sinaapp.com/daShan/index.php?toUserFakeid={$toFakeid}&fromUserFakeid={$fromUserFakeid}\">点击聊天</a>\n---------------\n";
                                                                                             $content .= "发送“@+你想说的话”迅速搭讪ta吧[色]\n---------------\n";
                                                                                             $content .= "[玫瑰]多与平台互动可以提高被搭讪的机率哦";
                                                                                             $content .= "<a href=\"loginView.php?openid={$fromUsername}&&flag=0\"> </a>";
                                                                                             // 提前发送消息
                                                                                             echo $replyObj->transmitText($object, $content);
                                                                                             // 设置搭讪对象缓存
                                                                                             memcache_set($mmc, $fromUsername . "dashan", $toFakeid);
                                                                                             // memcache_set ( $mmc, $fromUsername . "dashan", "1495366437",0,36000 );
                                                                                             // 睡1秒后执行绑定openid操作
                                                                                             sleep(2);
                                                                                             // 如果为空,绑定openid
                                                                                             if (empty($fromUserFakeidArr)) {
                                                                                                 require_once 'daShan/DaShan.class.php';
                                                                                                 $daShan = new DaShan();
                                                                                                 $fakeid2openidArr = $daShan->fakeid2openid();
                                                                                                 $fakeid = $fakeid2openidArr['fakeid'];
                                                                                                 $openid = $fakeid2openidArr['openid'];
                                                                                                 $lastTime2 = $fakeid2openidArr['lastTime'];
                                                                                                 $sql_state3 = "update tb_studentdashan set openid='{$openid}',lastTime='{$lastTime2}' where fakeid='{$fakeid}'";
                                                                                                 $class_mysqlObj->query($sql_state3);
                                                                                             }
                                                                                             return;
                                                                                         } else {
                                                                                             if (preg_match('/@((.*?))/', $keyword)) {
                                                                                                 // ============== 提高绑定效率 ====================
                                                                                                 $sql_state = "select fakeid,nick_name,place,sex from tb_studentdashan where openid='{$fromUsername}'";
                                                                                                 $fromUserInfoArr = $class_mysqlObj->query_array($sql_state);
                                                                                                 $fromUserFakeid = $fromUserInfoArr[0]['fakeid'];
                                                                                                 /*
                                                                                                  * 如果为空,绑定openid if (empty ( $fromFakeid )) { require_once 'daShan/DaShan.class.php'; $daShan = new DaShan (); $fakeid2openidArr = $daShan->fakeid2openid (); $fakeid = $fakeid2openidArr ['fakeid']; $openid = $fakeid2openidArr ['openid']; $lastTime2 = $fakeid2openidArr ['lastTime']; $sql_state3 = "update tb_studentDaShan set openid='{$openid}',lastTime='{$lastTime2}' where fakeid='{$fakeid}'"; $class_mysqlObj->query ( $sql_state3 ); }
                                                                                                  */
                                                                                                 // ================ 绑定结束 ========================
                                                                                                 // 消息发送给谁
                                                                                                 $toUserFakeid = memcache_get($mmc, $fromUsername . "dashan");
                                                                                                 if (empty($toUserFakeid)) {
                                                                                                     $content = "你还未匹配到搭讪对象,请回复【搭讪】进行匹配";
                                                                                                 } else {
                                                                                                     $keyword2 = str_replace("@", "", $keyword);
                                                                                                     if (!empty($fromUserFakeid)) {
                                                                                                         $fromNick_name = $fromUserInfoArr[0]['nick_name'];
                                                                                                         $fromPlace = $fromUserInfoArr[0]['place'] != null ? "来自" . $fromUserInfoArr[0]['place'] . "的" : "";
                                                                                                         $fromSex = $fromUserInfoArr[0]['sex'] == "汉纸" ? $fromUserInfoArr[0]['sex'] . "👦" : "妹纸👧";
                                                                                                         $daShan_content = $fromPlace . $fromNick_name . $fromSex . "向你发来消息:\n------------------\n\n" . $keyword2 . "\n\n";
                                                                                                         $daShan_content .= "<a href=\"http://ifreeweixin.sinaapp.com/daShan/index.php?toUserFakeid={$fromUserFakeid}&fromUserFakeid={$toUserFakeid}\">点此回复</a>\n------------------\n";
                                                                                                         $daShan_content .= "发送“@+你想说的话”可以快速回复ta哦[色]";
                                                                                                         require_once 'daShan/DaShan.class.php';
                                                                                                         $daShan = new DaShan();
                                                                                                         // 服务带传消息
                                                                                                         $flag = $daShan->singlesendpage($daShan_content, $toUserFakeid);
                                                                                                         // ========== 得到toOpenid 并帮他设置搭讪对象缓存 ================
                                                                                                         $sql_state2 = "select openid from tb_studentdashan where fakeid='{$toUserFakeid}'";
                                                                                                         $toOpenidArr = $class_mysqlObj->query_array($sql_state2);
                                                                                                         $toOpenid = $toOpenidArr[0]['openid'];
                                                                                                         memcache_set($mmc, $toOpenid . "dashan", $fromUserFakeid);
                                                                                                         $content = "消息发送成功,请耐心等待回复……";
                                                                                                     } else {
                                                                                                         $content = "搭讪对象被抢啦,请回复【搭讪】重新进行匹配……";
                                                                                                     }
                                                                                                 }
                                                                                             } else {
                                                                                                 if ($keyword == "绑定准考证") {
                                                                                                     $content = "妈妈再也不用担心忘记准考证号了\n\n请回复:\n绑定准考证,姓名,准考证号\n\n例子\n绑定准考证,小明,123456789\n\n中间逗号分隔哦";
                                                                                                 } else {
                                                                                                     if (substr_count($keyword, "绑定准考证")) {
                                                                                                         $a = explode(',', $keyword);
                                                                                                         if (count($a) == 3) {
                                                                                                             $name = $a[1];
                                                                                                             $cet_num = $a[2];
                                                                                                             $sql_str = "insert into tb_cet46(openid,name,cet_num) values('{$fromUsername}','{$name}','{$cet_num}')";
                                                                                                             if ($class_mysqlObj->query($sql_str)) {
                                                                                                                 $content = "已经成功备份你的准考证,如果以后忘记了,可以通过回复【准考证】进行查询";
                                                                                                             } else {
                                                                                                                 $content = "绑定失败,请重新回复……";
                                                                                                             }
                                                                                                         } else {
                                                                                                             $content = "回复文字的格式不对\n\n【例子】\n绑定准考证,肖何,413011151118329";
                                                                                                         }
                                                                                                     } else {
                                                                                                         if ($keyword == "准考证") {
                                                                                                             $sql_str = "select name,cet_num from tb_cet46 where openid='{$fromUsername}'";
                                                                                                             $cet46InfoArr = $class_mysqlObj->query_array($sql_str);
                                                                                                             $name = $cet46InfoArr[0]['name'];
                                                                                                             $cet_num = $cet46InfoArr[0]['cet_num'];
                                                                                                             if (!empty($cet_num)) {
                                                                                                                 $content = "查询结果如下:\n\n姓名:{$name}\n准考证号:{$cet_num}";
                                                                                                             } else {
                                                                                                                 $content = "查询结果为空……";
                                                                                                             }
                                                                                                         } else {
                                                                                                             if ($keyword == "报修") {
                                                                                                                 /**
                                                                                                                  * 判断用户是否已经认证
                                                                                                                  */
                                                                                                                 // $mmc_Openid = memcache_get ( $mmc, $fromUsername . "zjh" );
                                                                                                                 if (empty($studentName)) {
                                                                                                                     $content = "首次使用需要教务认证哦![愉快]<a href=\"http://218.196.240.171/weixinapi/index.php/Home/Jiaowu/loginview/openid/{$fromUsername}\">点我认证</a>";
                                                                                                                 } else {
                                                                                                                     $content = array();
                                                                                                                     $content[] = array("Title" => "后勤报修系统", "Description" => "宿舍有什么坏了,都可以在这里报修哦,后勤会即时排人来帮你解决的哦", "PicUrl" => "https://mmbiz.qlogo.cn/mmbiz/EKniaJHUPHicRjURU8pMTODXmZXrMrZA4WNib8icc44PoicCiccvs9ib6anyMW1ZcibTq8UlnY7eBw4RKGqnHODw9pKrBg/0?wx_fmt=jpeg", "Url" => "http://ifreeweixin.sinaapp.com/baoxiu/baoxiu_index.php?openid=" . $fromUsername);
                                                                                                                 }
                                                                                                                 echo $replyObj->transmitNews($object, $content);
                                                                                                                 return;
                                                                                                             } else {
                                                                                                                 if ($keyword == "搭讪小编") {
                                                                                                                     $sql_state11 = "select fakeid from tb_studentdashan where openid='{$fromUsername}'";
                                                                                                                     $fromUserFakeidArr = $class_mysqlObj->query_array($sql_state11);
                                                                                                                     $fromUserFakeid = $fromUserFakeidArr[0]['fakeid'];
                                                                                                                     $content = "客官让您久等了,小编来啦!\n\n";
                                                                                                                     $content .= "<a href=\"http://ifreeweixin.sinaapp.com/daShan/index.php?toUserFakeid=2983555719&fromUserFakeid={$fromUserFakeid}\">点此聊天</a>";
                                                                                                                     $content .= "\n------------------\n吐槽、反馈以及使用过程中,遇到什么问题都来勾搭小编吧[愉快]";
                                                                                                                 } else {
                                                                                                                     if ($keyword == "导入课表") {
                                                                                                                         $content = "<a href=\"http://218.196.240.171/weixinapi/index.php/Home/Jiaowu/loginview/openid/{$fromUsername}\">快点我啊</a>[色]\n\n";
                                                                                                                     } else {
                                                                                                                         if ($keyword == '高考考生号') {
                                                                                                                             $sql_state1 = "select high_schoolId from tb_studentinfo where openid='{$fromUsername}'";
                                                                                                                             $arr = $class_mysqlObj->query_array($sql_state1);
                                                                                                                             $high_schoolId = $arr[0]['high_schoolId'];
                                                                                                                             $content = $studentName . "同学,你的高考考生号为:" . $high_schoolId;
                                                                                                                         } else {
                                                                                                                             $ltUrl = "http://www.tuling123.com/openapi/api?key=b45c5daa693dbf5f2a3d0a125a9c465c&info={$keyword}";
                                                                                                                             $jsonInfo = json_decode(file_get_contents($ltUrl), true);
                                                                                                                             $content = $jsonInfo['text'];
                                                                                                                             $content = str_replace("<br>", "\n", $content);
                                                                                                                             $content .= "\n\n☞由机器人智能回复,如果未能解决你的问题请点击人工客服";
                                                                                                                         }
                                                                                                                     }
                                                                                                                 }
                                                                                                             }
                                                                                                         }
                                                                                                     }
                                                                                                 }
                                                                                             }
                                                                                         }
                                                                                     }
                                                                                 }
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 break;
                 /* text结束 */
             /* text结束 */
             case 'image':
                 break;
             case 'voice':
                 break;
             case 'video':
                 break;
             case 'location':
                 break;
             case 'event':
                 /**
                  * 接收事件的类型,即接收的消息类型为event时
                  * (subscribe(订阅),unsubscribe(取消订阅),LOCATION,CLICK,VIEW)
                  */
                 $eventType = $object->Event;
                 switch ($eventType) {
                     case 'subscribe':
                         // 关注事件
                         $userNum = memcache_get($mmc, "userNum");
                         /* 如果缓存里为空,则设置他为第一位关注者 */
                         if (empty($userNum)) {
                             memcache_set($mmc, "userNum", 1);
                         }
                         $userNum = memcache_get($mmc, "userNum");
                         $content = '感谢关注ifree微信,你是第' . $userNum . '位关注者';
                         $content = $content . "\n\n为了更好的为你提供服务请<a href=\"http://218.196.240.171/weixinapi/index.php/Home/Jiaowu/loginview/openid/{$fromUsername}\">👉点我认证</a>\n";
                         memcache_set($mmc, "userNum", $userNum + 1);
                         echo $replyObj->transmitText($object, $content);
                         // ======= 搭讪信息获取并插入数据库 ============
                         sleep(5);
                         // 休息6秒执行
                         require_once 'daShan/DaShan.class.php';
                         $daShan = new DaShan();
                         $daShan->getUserFakeid(1);
                         return;
                         break;
                     case 'unsubscribe':
                         // 取消关注事件
                         /* 有人取消关注后把缓存里的人数减一 */
                         $userNum = memcache_get($mmc, "userNum");
                         if ($userNum > 0) {
                             memcache_set($mmc, "userNum", $userNum - 1);
                         }
                         // =========== 删除搭讪信息 =================
                         $sql_str = "delete from tb_studentdashan where openid='{$fromUsername}'";
                         $class_mysqlObj->query($sql_str);
                         break;
                     case 'LOCATION':
                         // 地址上报事件
                         break;
                     case 'CLICK':
                         // 自定义菜单点击事件
                         $eventKey = $object->EventKey;
                         switch ($eventKey) {
                             case "46ji":
                                 $content = "四六级成绩查询:\n\n";
                                 $content .= "入口一:\n<a href=\"http://ifreeweixin.sinaapp.com/cet46/cet46View.php?openid={$fromUsername}\">知道准考证的点这里</a>\n\n";
                                 $content .= "入口二:\n<a href=\"http://cet.forchange.cn/?aid=3qVhg4POSvtza3BTRjzzSwFb6zaihaBbqzaa\">忘记准考证的点这里</a>\n\n";
                                 break;
                             case "index":
                                 // 首页
                                 $content = array();
                                 $content[] = array("Title" => "走进ifree,走进微校园", "Description" => "", "PicUrl" => "https://mmbiz.qlogo.cn/mmbiz/EKniaJHUPHicRocuIpHULp9UIb7jWcvfoMG0nV1v8V6k0xf3JNmTOruY9V7WpX2pmvUCmWRZcLJRc4rQKNvfP6Yw/0", "Url" => "http://ifreeweixin.sinaapp.com/index/index.php?openid={$fromUsername}");
                                 echo $replyObj->transmitNews($object, $content);
                                 return;
                                 break;
                             case "jrtq":
                                 // 今日天气
                                 /**
                                  * 判断用户是否已经绑定过天气地点
                                  */
                                 $userPlace = memcache_get($mmc, $fromUsername . "userPlace");
                                 if ($userPlace != null) {
                                     $geourl = "http://api.map.baidu.com/telematics/v3/weather?location={$userPlace}&output=xml&ak=F5bc9d028ff51b75ca54f1b10a5ca3be";
                                     $apiStr = file_get_contents($geourl);
                                     // 读取文件
                                     $apiObj = simplexml_load_string($apiStr);
                                     // Xml解析
                                     $addStr = $apiObj->results->currentCity;
                                     // 读取城市
                                     $todayObj = $apiObj->results->weather_data->date[0];
                                     // 读取日期
                                     $weatherObj = $apiObj->results->weather_data->weather[0];
                                     // 读取当天天气
                                     $windObj = $apiObj->results->weather_data->wind[0];
                                     // 读取当天风力
                                     $desObj = $apiObj->results->index->des[3];
                                     // 读取感冒建议
                                     $weather2Obj = $apiObj->results->weather_data->weather[0];
                                     // 读取明日天气
                                     $content = "今天{$todayObj}\n------------------\n{$addStr}今日天气:\n------------------\n{$weatherObj}\t{$windObj}\n{$desObj}\n------------------\n明天天气:{$weather2Obj}";
                                 } else {
                                     $content = "初次使用需要绑定地点,请输入:绑定地点+地点\n如发送:【绑定地点,焦作】\n\n注意:☞要先退出聊天模式";
                                 }
                                 break;
                             case "dashan":
                                 // 搭讪
                                 $content = "不搭讪,怎我们?\n\n【关键字】\n回复:搭讪\n回复:搭讪妹纸\n回复:搭讪汉纸\n回复:搭讪小编\n\n找寻我们[色]";
                                 break;
                             case "zkzh":
                                 // 绑定准考证
                                 $content = "妈妈再也不用担心忘记准考证号了\n\n请回复:\n绑定准考证,姓名,准考证号\n\n例子\n绑定准考证,小明,123456789\n\n中间逗号分隔哦";
                                 break;
                             case "ckkb":
                                 // 查看课表
                                 /**
                                  * 判断用户是否已经认证
                                  */
                                 // $mmc_Openid = memcache_get ( $mmc, $fromUsername . "zjh" );
                                 if (empty($studentName)) {
                                     $content = "首次查询需要教务认证[愉快]<a href=\"http://218.196.240.171/weixinapi/index.php/Home/Jiaowu/loginview/openid/{$fromUsername}\">点我认证</a>";
                                 } else {
                                     /* 当前周 */
                                     $weeklyNow = date('W') - 36;
                                     /* 星期 */
                                     $week = date('w');
                                     if ($week == 6) {
                                         $content = "星期六,全天没课哦 \n🚶听说学霸都会点这里\n<a href=\"http://ifreeweixin.sinaapp.com/kongJs/kongjs.php\">📚来点我呀</a>\n\n👑听说学神都会点这里\n<a href=\"http://m.wsq.qq.com/264077463\">📚来点我呀</a>";
                                     } else {
                                         if ($week == 0) {
                                             $content = "星期日,全天没课哦 \n🚶听说学霸都会点这里\n<a href=\"http://ifreeweixin.sinaapp.com/kongJs/kongjs.php\">📚空闲教室</a>\n\n👑听说学神都会点这里\n<a href=\"http://m.wsq.qq.com/264077463\">📚来点我呀</a>";
                                         } else {
                                             $content = array();
                                             $weekNumArr = array(1 => "一", 2 => "二", 3 => "三", 4 => "四", 5 => "五");
                                             $content[] = array("Title" => "星期{$weekNumArr[$week]}课表如下:👇(📅第{$weeklyNow}周)", "Description" => "", "PicUrl" => "", "Url" => "ifreeweixin.sinaapp.com/kcbView/kcbView.php?openid={$fromUsername}");
                                             // 节次数组
                                             $sectionArr = array("一", "三", "五", "七", "九");
                                             foreach ($sectionArr as $key => $section) {
                                                 // 几节到几节
                                                 $sectionTo1 = $key * 2 + 1;
                                                 $sectionTo2 = $key * 2 + 2;
                                                 $sql_state = "select course_name,teaching_building,teaching_number,course_teacher,startWeekly,endWeekly from tb_studentsyllabus where openid='{$fromUsername}' and week='{$week}' and section='{$section}' and startWeekly<={$weeklyNow} and endWeekly>={$weeklyNow}";
                                                 // 查询结果
                                                 $resultArr = $class_mysqlObj->query_array($sql_state);
                                                 if ($resultArr == null) {
                                                     $content[] = array("Title" => "{$sectionTo1}-{$sectionTo2} 节:\n👻没有课哦\n📢点击可查看空闲教室哦", "Description" => "", "PicUrl" => "", "Url" => "http://ifreeweixin.sinaapp.com/kongJs/kongjs.php");
                                                 } else {
                                                     $course_name = $resultArr[0]['course_name'];
                                                     // 课程名
                                                     $teaching_building = $resultArr[0]['teaching_building'];
                                                     // 教学楼
                                                     $teaching_number = $resultArr[0]['teaching_number'];
                                                     // 教室
                                                     $course_teacher = $resultArr[0]['course_teacher'];
                                                     // 老师
                                                     $startWeekly = $resultArr[0]['startWeekly'];
                                                     // 开始周
                                                     $endWeekly = $resultArr[0]['endWeekly'];
                                                     // 结束周
                                                     if (!empty($resultArr[1]['course_name'])) {
                                                         $course_name2 = $resultArr[1]['course_name'];
                                                         // 课程名
                                                         $teaching_building2 = $resultArr[1]['teaching_building'];
                                                         // 教学楼
                                                         $teaching_number2 = $resultArr[1]['teaching_number'];
                                                         // 教室
                                                         $course_teacher2 = $resultArr[1]['course_teacher'];
                                                         // 老师
                                                         $startWeekly2 = $resultArr[1]['startWeekly'];
                                                         // 开始周
                                                         $endWeekly2 = $resultArr[1]['endWeekly'];
                                                         // 结束周
                                                         $title2 = "\n--------\n" . $course_name2 . "\n📍" . $teaching_building2 . $teaching_number2 . "\n🕘" . $course_teacher2 . "({$startWeekly2}-{$endWeekly2} 周上)";
                                                     }
                                                     $title = "{$sectionTo1}-{$sectionTo2} 节:\n" . $course_name . "\n📍" . $teaching_building . $teaching_number . "\n🕘" . $course_teacher . "({$startWeekly}-{$endWeekly} 周上)" . $title2;
                                                     $content[] = array("Title" => "{$title}", "Description" => "", "PicUrl" => "", "Url" => "ifreeweixin.sinaapp.com/kcbView/kcbView.php?openid={$fromUsername}");
                                                 }
                                                 $title2 = "";
                                             }
                                             $content[] = array("Title" => "💬回复课表+数字可以查看任意星期的课表哦,如【课表,1】\n㊙点击可以查看全周课表", "Description" => "", "PicUrl" => "", "Url" => "ifreeweixin.sinaapp.com/kcbView/kcbView.php?openid={$fromUsername}");
                                             echo $replyObj->transmitNews($object, $content);
                                             return;
                                         }
                                     }
                                 }
                                 break;
                             case "cjcx":
                                 // 成绩查询(期末成绩、四六级成绩、体育达标测试、普通话水平测试、全国计算机等级考试)
                                 /**
                                  * 判断用户是否已经认证
                                  */
                                 // $mmc_Openid = memcache_get ( $mmc, $fromUsername . "zjh" );
                                 if (empty($studentName)) {
                                     // 成绩未认证转到认证页面
                                     $scoreUrl = "http://218.196.240.171/weixinapi/index.php/Home/Jiaowu/loginview/openid/{$fromUsername}";
                                     // 体育未认证转到认证页面
                                     $peUrl = "http://218.196.240.171/weixinapi/index.php/Home/Jiaowu/loginview/openid/{$fromUsername}";
                                 } else {
                                     // 已经认证转到成绩页面
                                     $scoreUrl = "http://ifreeweixin.sinaapp.com/scoreView/scoreResultView.php?openid={$fromUsername}";
                                     // 已经认证转到体育达标页面
                                     $peUrl = "http://ifreeweixin.sinaapp.com/peQuery/peView.php?openid={$fromUsername}";
                                 }
                                 $content = array();
                                 $content[] = array("Title" => "💯期末成绩", "Description" => "", "PicUrl" => "https://mmbiz.qlogo.cn/mmbiz/EKniaJHUPHicRgibybsdwUO172PBkQtZzlyfiajHev0mE4QXic2vbOEJgcDIc1TJthkprMzZk3hqZPjppWibgNz7Zd1w/0", "Url" => $scoreUrl);
                                 $content[] = array("Title" => "💯四六级成绩", "Description" => "", "PicUrl" => "https://mmbiz.qlogo.cn/mmbiz/EKniaJHUPHicRgibybsdwUO172PBkQtZzlyChU8rZ7t9TjgXymc2hicWkCdDW16ZtV7M9PiahpA9RYP5dxQ6QAfvwNQ/0", "Url" => "http://ifreeweixin.sinaapp.com/cet46/cet46View.php?openid={$fromUsername}");
                                 $content[] = array("Title" => "💯体育达标测试", "Description" => "", "PicUrl" => "https://mmbiz.qlogo.cn/mmbiz/EKniaJHUPHicRgibybsdwUO172PBkQtZzlyEuZqXftqDwDzWtnicTNGkYWFHwyewTVE9tJygxaE4RtDMq9lk2jH0xA/0", "Url" => $peUrl);
                                 $content[] = array("Title" => "💯普通话水平测试", "Description" => "", "PicUrl" => "https://mmbiz.qlogo.cn/mmbiz/EKniaJHUPHicRgibybsdwUO172PBkQtZzlysmt4Xicn26zEUjIpVKV32roUcDJvjvLjq7m11vTEA88QjCyLAwYan5w/0", "Url" => "");
                                 $content[] = array("Title" => "💯全国计算机等级考试", "Description" => "", "PicUrl" => "https://mmbiz.qlogo.cn/mmbiz/EKniaJHUPHicRgibybsdwUO172PBkQtZzlyz59ib3tXt3d8WfpLjNUJ8wAASaqcr9T8sMaDsctEYQVIjVYS9arhSicA/0", "Url" => "");
                                 echo $replyObj->transmitNews($object, $content);
                                 return;
                                 break;
                             case "tsjs":
                                 // 图书检索
                                 $content = "突破外网限制,解决大家找书、续借难的问题\n\n回复:检索书名\n例子:检索红楼梦\n\n回复:当前借阅\n查看当前图书馆借阅情况\n\n回复:续借数字\n例子:续借1\n表示续借第一本书\n\n使用小技巧:\n1.回复当前借阅后,点击书的名字完成续借\n2.回复:续借1,2,3\n完成第一二三本书的续借,依次类推,注意以逗号分割哦\n\n提醒:超期的图书不能完成续借\n\n查询结果与实际不符\n👉<a href=\"http://lib.hpu.edu.cn/\">点这里哦</a>";
                                 break;
                             case "mryy":
                                 // 每日英语
                                 $json_mryy = file_get_contents('http://apix.sinaapp.com/daily/?appkey=ifreeweixin&type=translation');
                                 // 读取文件
                                 $newJson_mryy = trim($json_mryy, "[]");
                                 $mrryObj = json_decode($newJson_mryy);
                                 $title = "ifree微信【每日英语】";
                                 $description = $mrryObj->Description;
                                 $newDescription = $description . "\n-------------------\n*回复【朗读】获得句子语音,点击进入双语阅读";
                                 $picUrl = $mrryObj->PicUrl;
                                 $url = "http://xue.youdao.com/zx/archives/category/practical/article";
                                 $content = array();
                                 $content[] = array("Title" => "{$title}", "Description" => "{$newDescription}", "PicUrl" => "{$picUrl}", "Url" => "{$url}");
                                 echo $replyObj->transmitNews($object, $content);
                                 return;
                                 break;
                             case "fkye":
                                 // 饭卡余额
                                 /**
                                  * 判断用户是否已经认证
                                  */
                                 // $studentid = memcache_get ( $mmc, $fromUsername . "zjh" );
                                 if (empty($studentName)) {
                                     $content = "首次查询需要教务认证哦![愉快]<a href=\"http://218.196.240.171/weixinapi/index.php/Home/Jiaowu/loginview/openid/{$fromUsername}\">点我认证</a>";
                                 } else {
                                     require_once 'personInfo/getEcard.php';
                                     $infoArr = getEcard($fromUsername);
                                     // 赛课作业数量
                                     $saiKeNum = $infoArr[0];
                                     // 借书数量
                                     $bookNum = $infoArr[1];
                                     // 超期图书数量
                                     $outBookNum = $infoArr[2];
                                     // 饭卡余额
                                     $eCardMoney = $infoArr[3];
                                     $content = "{$studentName}同学,你的饭卡余额为:{$eCardMoney}元";
                                     $content .= "\n\n【温馨提示】\n<a href=\"http://ifreeweixin.sinaapp.com/personInfo/saikeView.php?openid={$fromUsername}\">赛课作业</a>:{$saiKeNum}项\n图书借阅:{$bookNum}本,超期{$outBookNum}本";
                                     $content .= "\n\n【查询更多】\n回复:最新公告\n查看学校最新公告\n\n回复:校内招聘\n查看校内招聘信息\n\n回复:校外招聘\n查看校外招聘信息\n\n回复:学术讲座\n查看近期讲座安排";
                                     $content .= "\n\n回复:报修\n再也不用去找阿姨说宿舍哪里坏啦[玫瑰]";
                                 }
                                 break;
                             case "wyly":
                                 $content = "不要着急哦,我要留意功能程序猿正在努力开发中……";
                                 break;
                             case "ylb":
                                 // 娱乐吧
                                 $content = array();
                                 // $content [] = array (
                                 // "Title" => "【表白墙】爱就大声说出来",
                                 // "Description" => "",
                                 // "PicUrl" => "https://mmbiz.qlogo.cn/mmbiz/EKniaJHUPHicSGTe3UeGJYENpy8nmB6bEDaCtHBfqJcickbxBMUk12ctubxMEjz1gUw8uw1BiaRu3A4nyvUFXDUrVQ/0",
                                 // "Url" => "http://m.wsq.qq.com/264077463/v/25"
                                 // );
                                 // $content [] = array (
                                 // "Title" => "【许愿树】\n我想做一个安静的美男子",
                                 // "Description" => "",
                                 // "PicUrl" => "https://mmbiz.qlogo.cn/mmbiz/EKniaJHUPHicSGTe3UeGJYENpy8nmB6bEDvQuCQhontqCddW570DKGj7DYLGgBD6cYlib4vMQlObcFicO7Sowa22sQ/0",
                                 // "Url" => "http://m.wsq.qq.com/264077463/v/26"
                                 // );
                                 // $content [] = array (
                                 // "Title" => "【微语录】\n放下执著奔向新生命",
                                 // "Description" => "",
                                 // "PicUrl" => "https://mmbiz.qlogo.cn/mmbiz/EKniaJHUPHicSGTe3UeGJYENpy8nmB6bEDmIBQt101DdicALVE0KAiaqtYm1pCXRyRKHOAVQIvnctsiaF7mHW57srww/0",
                                 // "Url" => "http://m.wsq.qq.com/264077463/v/27"
                                 // );
                                 $content[] = array("Title" => "【小游戏】最强眼力", "Description" => "", "PicUrl" => "https://mmbiz.qlogo.cn/mmbiz/EKniaJHUPHicSGTe3UeGJYENpy8nmB6bEDxPgaiclGYZYEcPE384xWSxicwSPBiclUQ3QzXLHdobpa0Vyz5fiafBmUfA/0", "Url" => "http://ifreeweixin.sinaapp.com/ifreegame/zuiqiangyanli/index.html");
                                 $content[] = array("Title" => "【小游戏】围住神精猫", "Description" => "", "PicUrl" => "https://mmbiz.qlogo.cn/mmbiz/EKniaJHUPHicSGTe3UeGJYENpy8nmB6bED4ZZj0ibr9THtOIoiaXIx5TzX0sow7MelmZ3zXZoM6bzic7Z3sRWSQPibxA/0", "Url" => "http://ifreeweixin.sinaapp.com/ifreegame/shenjingmao/index.html");
                                 $content[] = array("Title" => "【小游戏】2048", "Description" => "", "PicUrl" => "https://mmbiz.qlogo.cn/mmbiz/EKniaJHUPHicSGTe3UeGJYENpy8nmB6bEDdS51wd3ktIibTWqT37fsZ3Wibko5gLCsibJe9mxI1uAYu2rw7lKeneJNA/0", "Url" => "http://ifreeweixin.sinaapp.com/ifreegame/2048/index.html");
                                 echo $replyObj->transmitNews($object, $content);
                                 return;
                                 break;
                             case "nsns":
                                 $content = "回复  <a href=\"http://www.facejoking.com/top/18601/0/\">女神</a>\n查看理工女神排行榜\n\n回复  <a href=\"http://www.facejoking.com/top/18601/1/\">男神</a>\n查看理工男神排行榜\n\n点击Ta的头像可以评论或投票哦,赶快行动吧[色]";
                                 break;
                             case "wylt":
                                 // 我要聊天
                                 // 设置机器人聊天时长为10分钟
                                 // memcache_set ( $mmc, $fromUsername . "lt", "wylt", 0, 600 );
                                 $sql_state11 = "select fakeid from tb_studentdashan where openid='{$fromUsername}'";
                                 $fromUserFakeidArr = $class_mysqlObj->query_array($sql_state11);
                                 $fromUserFakeid = $fromUserFakeidArr[0]['fakeid'];
                                 $content = array();
                                 $content[] = array("Title" => "👦小编在线,时刻为你服务", "Description" => "", "PicUrl" => "https://mmbiz.qlogo.cn/mmbiz/EKniaJHUPHicTKqsC5EZpyzuicHZhrNCNYhePOwnWaWoQPrAvucjCib85hUalbDiaAibnJH5b8XPkrxhAoUJvX1GEATA/0?wx_fmt=jpeg", "Url" => "http://ifreeweixin.sinaapp.com/daShan/index.php?toUserFakeid=2983555719&fromUserFakeid={$fromUserFakeid}");
                                 $content[] = array("Title" => "【🙎人工客服】\n使用过程中遇到的问题或者有什么想问的都可以👇点这里", "Description" => "", "PicUrl" => "https://mmbiz.qlogo.cn/mmbiz/EKniaJHUPHicSGTe3UeGJYENpy8nmB6bEDVv9sn46maficLJHibia6H0BcLssHxcXg5EVzH9pwPupgtp35v1jibUAMcQ/0", "Url" => "http://wpa.qq.com/msgrd?v=3&uin=1334506819&site=qq&menu=yes");
                                 $content[] = array("Title" => "【💞加入平台交流群】\n想知道本平台都有谁吗?男神?女神?萌妹子?👇点这里", "Description" => "", "PicUrl" => "https://mmbiz.qlogo.cn/mmbiz/EKniaJHUPHicSGTe3UeGJYENpy8nmB6bEDOVjPvP1KsrdwGYXThjMGeEXLzwKkhsvLv4DaicWLSbzI4XV2cVek8HQ/0", "Url" => "http://jq.qq.com/?_wv=1027&k=bhNTRl");
                                 echo $replyObj->transmitNews($object, $content);
                                 return;
                                 break;
                             case "gdgn":
                                 // 更多功能
                                 $content = "👉点此进入<a href=\"http://ifreeweixin.sinaapp.com/index/index.php?openid={$fromUsername}\">首页</a>\n\n";
                                 $content .= "👉点此进入<a href=\"http://jiejing.qq.com/#pano=23081037131012133740100&heading=85&pitch=0&zoom=1&isappinstalled=-1&poi=0\">校园街景</a>\n\n";
                                 $content .= "👉点此进入<a href=\"http://m.weibo.cn/d/hpu1909?jumpfrom=weibocom\">理工微博</a>\n\n";
                                 $content .= "👉点此进入<a href=\"http://ifreeweixin.sinaapp.com/daojishi/index.html\">放假倒计时</a>\n\n";
                                 $content .= "👉点此进入<a href=\"http://hao.uc.cn/bst#!/index/\">生活百事通</a>\n\n";
                                 $content .= "👉点此进入<a href=\"http://www.play68.com/\">微信小游戏</a>\n\n";
                                 // $content .= "👉点此进入<a href=\"http://m.wsq.qq.com/264077463/v/29\">一起约跑吧</a>\n\n";
                                 $content .= "👉点此进入<a href=\"http://m.wsq.qq.com/app?sId=264077463&appId=wsq52871049344258\">每日逗比对话</a>\n\n";
                                 // $content .= "👉点此进入<a href=\"http://m.wsq.qq.com/264077463/v/22\">帮室友找对象</a>\n\n";
                                 // $content .= "👉点此进入<a href=\"http://m.wsq.qq.com/264077463/v/28\">英雄联盟交流</a>\n\n";
                                 $content .= "更多精彩,尽在ifree微信平台";
                                 break;
                             case 'drkb':
                                 //导入课表
                                 $content .= "<a href=\"http://218.196.240.171/weixinapi/index.php/Home/Jiaowu/loginview/openid/{$fromUsername}\">快点我啊</a>[色]\n\n";
                                 break;
                             case "wsbx":
                                 // 报修
                                 /**
                                  * 判断用户是否已经认证
                                  */
                                 // $mmc_Openid = memcache_get ( $mmc, $fromUsername . "zjh" );
                                 if (empty($studentName)) {
                                     $content = "首次使用需要教务认证 [愉快]<a href=\"http://218.196.240.171/weixinapi/index.php/Home/Jiaowu/loginview/openid/{$fromUsername}\">点我认证</a>";
                                 } else {
                                     $content = array();
                                     $content[] = array("Title" => "后勤报修系统", "Description" => "宿舍有什么坏了,都可以在这里报修哦,后勤会即时排人来帮你解决的哦", "PicUrl" => "https://mmbiz.qlogo.cn/mmbiz/EKniaJHUPHicRjURU8pMTODXmZXrMrZA4WNib8icc44PoicCiccvs9ib6anyMW1ZcibTq8UlnY7eBw4RKGqnHODw9pKrBg/0?wx_fmt=jpeg", "Url" => "http://ifreeweixin.sinaapp.com/baoxiu/baoxiu_index.php?openid=" . $fromUsername);
                                 }
                                 echo $replyObj->transmitNews($object, $content);
                                 return;
                                 break;
                         }
                         break;
                 }
                 break;
         }
         echo $replyObj->transmitText($object, $content);
     } else {
         echo "";
         exit;
     }
 }