Beispiel #1
0
function reply_main($request, $w)
{
    $to = $request['ToUserName'];
    $from = $request['FromUserName'];
    // 大众接口
    if ($w->get_msg_type() == "location") {
        $lacation = "x@" . (string) $request['Location_X'] . "@" . (string) $request['Location_Y'];
        $lacation = urlencode(str_replace('\\.', '\\\\.', $lacation));
        $lacation = urldecode(xiaojo($lacation, $from, $to));
        return $lacation;
    } else {
        if ($w->get_msg_type() == "image") {
            $PicUrl = $request['PicUrl'];
            $w->set_funcflag();
            return "咦,我也有这张照片:" . $PicUrl;
        } else {
            if ($w->get_msg_type() == "voice") {
                return array("title" => "你好", "description" => "亲爱的主人", "murl" => "http://weixen-file.stor.sinaapp.com/b/xiaojo.mp3", "hqurl" => "http://weixen-file.stor.sinaapp.com/b/xiaojo.mp3");
            } else {
                if ($w->get_msg_type() == "event") {
                    // 关注
                    if ($w->get_event_type() == "subscribe") {
                        $welcome = WELCOME;
                        return $welcome;
                    } elseif ($w->get_event_type() == "unsubscribe") {
                        $unsub = urldecode(xiaojo("subscribe", $from, $to));
                        return $unsub;
                    } elseif ($w->get_event_type() == "click") {
                        $menukey = $w->get_event_key();
                        $menu = urldecode(xiaojo($menukey, $from, $to));
                        return $menu;
                    } else {
                        $menukey = $w->get_event_key();
                        return $menukey;
                    }
                }
            }
        }
    }
    /**
     *  $content:获取http的content字段
     *  $reply_content:返回处理结果
     */
    $content = trim($request['Content']);
    // 开户指南
    if (strstr($content, '开')) {
        $url = 'http://mp.weixin.qq.com/s?__biz=MjM5OTA1NzMyMg==&mid=201721356&idx=1&sn=2ab0f94f0514fc6d01b5addc76caf446&scene=4#wechat_redirect';
        $reply_content = '#title|开户@title|开户指南入口#url|' . $url . '#pic';
        // 多图文回复
        if (strstr($reply_content, 'pic')) {
            $reply_content = replypic($reply_content);
        }
        return $reply_content;
    }
    if ($content == '校历') {
        $reply_content = "#title|广药2014-2015第一学期校历@title|查看校历点此进入#url|http://mp.weixin.qq.com/s?__biz=MjM5OTA1NzMyMg==&mid=202787753&idx=1&sn=c37f9e9566bf0dcd016d685c12bc3baa#rd#pic";
        $reply_content = replypic($reply_content);
        return $reply_content;
    }
    //交通卡查询
    if (strstr($content, '交') || strstr($content, '羊') || $content == "6") {
        $arr = explode('#', $content);
        $ctype = $arr[1];
        $cno = $arr[2];
        if ($ctype == 'yct' && !empty($cno) && $cno != '') {
            return "请到羊城通官方公众号查询 谢谢!";
            $url = "http://av.jejeso.com/helper/api/transfer/get_yct.php?cardno={$cno}";
            return file_get_contents($url);
        } elseif ($ctype == 'szt' && !empty($cno) && $cno != '') {
            $url = "http://av.jejeso.com/helper/api/transfer/get_szt.php?cardno={$cno}";
            return file_get_contents($url);
        } else {
            return "小助手交通卡余额查询Beta\n\n发送:交通#yct#卡号\n即可查询羊城通余额\n\n发送:交通#szt#卡号\n即可查询深圳通余额^_^\n更多便利将陆续推出";
        }
    }
    //content处理
    if (!empty($content)) {
        $flag = "0";
        // 广药内网接口
        if ($content == "?" || $content == '?' || $content == 'help') {
            $flag = 'menu';
        } else {
            if ($content == "菜单" || $content == '帮助' || $content == "列表" || $content == '清单' || $content == '功能') {
                $flag = "text";
            } else {
                if (strstr($content, "网号") || $content == "6") {
                    $flag = "6";
                } else {
                    if ($content == "1" || $content == "2" || $content == "9" || $content == "3" || $content == "4" || strstr($content, "还书") || strstr($content, "还") || strstr($content, "图书")) {
                        $flag = "gdpuapi";
                    } else {
                        if (strstr($content, "表白") || strstr($content, "cet") || strstr($content, "Cet") || strstr($content, "CET6") || strstr($content, "CET") || strstr($content, "cet4") || strstr($content, "cet6") || strstr($content, "CET4") || strstr($content, "四级") || strstr($content, "六级") || strstr($content, "4级") || strstr($content, "6级") || strstr($content, "手机") || $content == "f" || $content == "F" || strstr($content, "解梦") || $content == "e" || $content == "E" || strstr($content, "身份") || $content == "G" || $content == "g" || strstr($content, "找找帮") || $content == "8" || strstr($content, "音乐") || strstr($content, "视频") || strstr($content, "公交") || $content == "A" || $content == "a" || $content == "B" || $content == "b" || $content == "C" || $content == "c" || strstr($content, "翻译") || $content == "D" || $content == 'd' || strstr($content, "快递") || strstr($content, "天气") || strstr($content, "t") || strstr($content, "T")) {
                            $flag = "webapi";
                        } elseif (strstr($content, "成绩") || $content == "10") {
                            $content = str_replace('#', '#', $content);
                            $ret = explode('#', $content);
                            $xh = $ret[1];
                            $pw = $ret[2];
                            if (!$xh || !$pw) {
                                $name = $from;
                                $user = new user();
                                $xh = $user->get_num($name);
                                $pw = $user->get_pw($name);
                            }
                            if ($xh && $pw) {
                                $url = 'http://av.jejeso.com/helper/api/chengji/get_chengji.php?xh=' . $xh . '&pw=' . $pw;
                                $content = '#title|成绩单@title|亲爱的学霸Orz,这是您的成绩单请笑纳~^_^(单击获取,若页面为空请确认密码学号无误)' . '#url|' . $url . '#pic';
                                $content = replypic($content);
                            } else {
                                $content = "帐号或密码错误,请输入“重绑”重新绑定帐号和密码。\n或者按格式#学号#密码  查询";
                            }
                            // $content = '由于教务处当前不允许查成绩,所以小助手暂时无法帮您查询,非常抱歉!';
                            return $content;
                        } elseif ($content == "11" || strstr($content, "选修")) {
                            $content = str_replace('#', '#', $content);
                            $ret = explode('#', $content);
                            $xh = $ret[1];
                            $pw = $ret[2];
                            if (!$xh || !$pw) {
                                $name = $from;
                                $user = new user();
                                $xh = $user->get_num($name);
                                $pw = $user->get_pw($name);
                            }
                            if ($xh && $pw) {
                                $url = 'http://branch2.gdpu.edu.cn/gd/jwc/wx.xuanxiu.api.php?xh=' . $xh . '&pw=' . $pw;
                                $reply_content = file_get_contents($url);
                            } else {
                                $reply_content = "帐号或密码错误,请输入“重绑”重新绑定帐号和密码。\n或者按格式#学号#密码  查询";
                            }
                            return $reply_content;
                        } elseif (strstr($content, "绑定")) {
                            //查询用户名
                            $name = $from;
                            $url = "http://av.jejeso.com/helper/api/check.php?name=" . $name;
                            $reply_content = file_get_contents($url);
                            if ($reply_content != '') {
                                //判断用户是否存在
                                // $reply_content = "用户已绑定";
                                return "用户已绑定";
                            } else {
                                $user = new user();
                                $content = str_replace('#', '#', $content);
                                $ret = explode('#', $content);
                                $xh = $ret[1];
                                $pw = $ret[2];
                                if ($xh && $pw) {
                                    $num = $xh;
                                    $pwd = $pw;
                                    $user->blind($name, $num, $pwd);
                                    $content = "绑定成功,以后直接输入成绩即可查成绩,无需再输入学号密码\n";
                                } else {
                                    $content = "请确认【格式】正确\n\n绑定#学号#密码\n重新绑定请回复\n重绑#学号#密码";
                                }
                                return $content;
                            }
                        } elseif (strstr($content, "重新绑定") || strstr($content, "重绑")) {
                            $name = $from;
                            $user = new user();
                            $content = str_replace('#', '#', $content);
                            $ret = explode('#', $content);
                            $xh = $ret[1];
                            $pw = $ret[2];
                            if (!$xh || !$pw) {
                                $content = "请确认【格式】正确\n\n重绑#学号#密码";
                            } else {
                                $user->reblind($name, $xh, $pw);
                                $content = "重新绑定成功";
                            }
                            return $content;
                        } else {
                            if (strstr($content, "课表") || $content == "7") {
                                $content = str_replace('#', '#', $content);
                                $ret = explode('#', $content);
                                $xh = $ret[1];
                                $pw = $ret[2];
                                $day = date("w");
                                if (!$xh || !$pw) {
                                    $name = $from;
                                    $user = new user();
                                    $xh = $user->get_num($name);
                                    $pw = $user->get_pw($name);
                                    if ($ret[1]) {
                                        $day = $ret[1];
                                    }
                                }
                                if (isset($ret[3])) {
                                    if ($ret[3] >= 1 && $ret[3] <= 5) {
                                        $day = $ret[3];
                                    }
                                }
                                //			else
                                //                    $day = 1;
                                //            }
                                if ($xh && $pw) {
                                    $url = 'http://av.jejeso.com/helper/kb/kb.php?xh=' . $xh . '&pw=' . $pw . '&day=' . $day;
                                    $reply_content = file_get_contents($url);
                                } elseif (!$xh || !$pw) {
                                    $reply_content = "【现已支持所有校区】\n按照以下格式获取课表\n\n【今天课表】\n课表#学号#密码\n\n【周X课表】\n课表#学号#密码#X\n\n(X为1-5,或者是all,否则均默认为当天,周六、日显示全部课表)\n\n【例如】\n获取今天课表:\n课表#1207511199#1207511199\n\n获取周1课表:\n课表#1207511199#1207511199#1";
                                } else {
                                    $reply_content = "【现已支持所有校区】\n按照以下格式获取课表\n\n【今天课表】\n课表#学号#密码\n\n【周X课表】\n课表#学号#密码#X\n\n(X为1-5,或者是all,否则均默认为当天,周六、日显示全部课表)\n\n【例如】\n获取今天课表:\n课表#1207511199#1207511199\n\n获取周1课表:\n课表#1207511199#1207511199#1";
                                }
                                return $reply_content;
                            } else {
                                if (strstr($content, "cet") || strstr($content, "Cet") || strstr($content, "四级") || strstr($content, "六级")) {
                                    if (strstr($content, "cet") || strstr($content, "Cet") || strstr($content, "四级") || strstr($content, "六级")) {
                                        $content = trim($content);
                                        $content = str_replace('#', '#', $content);
                                        $ret = explode('#', $content);
                                        $zkzh = trim($ret[1]);
                                        $xm = trim($ret[2]);
                                        if ($zkzh == '' || $xm == '') {
                                            $reply_content = "【CET4,6级查询】\nby Ourstudio工作室\n请检查格式是否正确\n发送\n\ncet#准考证号#姓名\n\n即可查询";
                                        }
                                        if ($zkzh && $xm) {
                                            $url = 'http://av.jejeso.com/helper/api/cet/cet_wx.php?zkzh=' . $zkzh . '&xm=' . $xm;
                                            $reply_content = file_get_contents($url);
                                            if ($reply_content == "") {
                                                $reply_content = "无法查找到你的成绩,请检查学号、姓名是否正确\n";
                                            }
                                            return $reply_content;
                                        }
                                    }
                                } else {
                                    if (strstr($content, "动漫") || $content == "5") {
                                        $url = 'http://110.75.189.200/chris/helper/media_update.php';
                                        $reply_content = file_get_contents($url);
                                        return $reply_content;
                                    } else {
                                        if (strstr($content, "外卖") || strstr($content, "KFC") || strstr($content, "快餐")) {
                                            $reply_content = "1、龙旺食府 1884214432 短号:66694\n9块钱3肉一菜";
                                            return $reply_content;
                                        } else {
                                            if (strstr($content, "建议") || strstr($content, "意见") || strstr($content, "投诉")) {
                                                $content = "#title|有奖征集意见@title|填写意见点此进入.感谢您的建议#url|http://av.jejeso.com/helper/api/add_advices/commit.html#pic";
                                                if (strstr($reply_content, 'pic')) {
                                                    $reply_content = replypic($reply_content);
                                                }
                                                return $reply_content;
                                            } else {
                                                if (strstr($content, "报障") || strstr($content, "上不了网") || strstr($content, "校园网常见错误") || strstr($content, "114.w")) {
                                                    $reply_content = "#title|校园网常见错误@title|查询校园网错误点此进入#url|http://av.jejeso.com/Ours/911/index.php#pic";
                                                    if (strstr($reply_content, 'pic')) {
                                                        $reply_content = replypic($reply_content);
                                                    }
                                                    return $reply_content;
                                                } else {
                                                    if ($content == "合作" || $content == "推送") {
                                                        $reply_content = "联系人:陈正勇\n手机号、微信:18825076954(61954)\nQQ:1249192238";
                                                        return $reply_content;
                                                    } else {
                                                        if (strstr($content, "新闻")) {
                                                            $reply_content = "#title|广药新闻@title|查看最新广药新闻点此进入#url|http://ours.123nat.com:59832/news/#pic";
                                                            if (strstr($reply_content, 'pic')) {
                                                                $reply_content = replypic($reply_content);
                                                            }
                                                            return $reply_content;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        // menu内容
        if ($flag == "menu" || strstr($content, "查询")) {
            $reply_content = MENU;
        } else {
            if ($flag == "text") {
                $reply_content = TEXT;
            } else {
                if ($flag == "gdpuapi") {
                    $g = new WebAPI();
                    //广药新闻
                    if ($content == "1" || strstr($content, "新闻")) {
                        $reply_content = "#title|广药新闻@title|查看最新广药新闻点此进入#url|http://ours.123nat.com:59832/news/#pic";
                        //$reply_content = $g->get_gdpu_news ();
                    } else {
                        if ($content == "2") {
                            $reply_content = $g->get_gdpu_jobs();
                        } else {
                            if ($content == "9") {
                                $reply_content = $g->get_gdpu_partime();
                            } else {
                                if (strstr($content, "图书") || $content == "3") {
                                    $keyword = str_replace("图书", "", $content);
                                    $reply_content = $g->get_lib_book($keyword);
                                } else {
                                    if ($content == "4" || strstr($content, "还")) {
                                        $array = explode("#", $content);
                                        $xh = $array[1];
                                        if (!$xh) {
                                            $name = $from;
                                            $user = new user();
                                            $xh = $user->get_num($name);
                                        }
                                        if ($xh == '') {
                                            $reply_content = "查询正确格式为:\n还书#学号";
                                        } else {
                                            $reply_content = $g->get_lib_borrowbook($xh);
                                        }
                                    } else {
                                        $reply_content = "未知外网接口!";
                                    }
                                }
                            }
                        }
                    }
                } else {
                    if ($flag == "webapi") {
                        $o = new WebAPI();
                        //四六级
                        if ($content == "4" || strstr($content, "cet") || strstr($content, "Cet") || strstr($content, "四级") || strstr($content, "六级")) {
                            if ($content == "4" || strstr($content, "cet") || strstr($content, "Cet") || strstr($content, "四级") || strstr($content, "六级")) {
                                $content = trim($content);
                                $content = str_replace('#', '#', $content);
                                $ret = explode('#', $content);
                                $zkzh = trim($ret[1]);
                                $xm = trim($ret[2]);
                                if ($zkzh == '' || $xm == '') {
                                    $reply_content = "【CET4,6级查询】\nby Ourstudio工作室\n请检查格式是否正确\n发送\n\ncet#准考证号#姓名\n\n即可查询";
                                }
                                if ($zkzh && $xm) {
                                    $url = 'http://av.jejeso.com/helper/api/cet/cet_wx.php?zkzh=' . $zkzh . '&xm=' . $xm;
                                    $reply_content = file_get_contents($url);
                                    if ($reply_content == "") {
                                        $reply_content = "无法查找到你的成绩,请检查学号、姓名是否正确\n";
                                    }
                                    return $reply_content;
                                }
                            }
                        } else {
                            if (strstr($content, "手机") || $content == "f" || $content == "F") {
                                $date = explode("#", $content);
                                $number = $date[1];
                                if ($number == '') {
                                    $reply_content = "查归属地格式:手机#手机号\n即可查询归属地";
                                } else {
                                    $reply_content = $o->get_mobile($number);
                                }
                            } else {
                                if (strstr($content, "解梦") || $content == "e" || $content == "E") {
                                    $date = explode("#", $content);
                                    $key = $date[1];
                                    if ($key == '') {
                                        $reply_content = "发送格式:解梦#关键词\n即可解开你的梦境";
                                    } else {
                                        $reply_content = $o->get_dream($key);
                                    }
                                } else {
                                    if ($content == "l" || $content == "L") {
                                        $reply_content = $o->get_award();
                                    } else {
                                        if (strstr($content, "身份") || $content == "g" || $content == "G") {
                                            $date = explode("#", $content);
                                            $no = $date[1];
                                            if ($no == '') {
                                                $reply_content = "查看身份:\n输入\t身份#身份证";
                                            } else {
                                                $reply_content = $o->get_idcard($no);
                                            }
                                        } else {
                                            if (strstr($content, "快递") || $content == "D" || $content == "d") {
                                                $date = explode("#", $content);
                                                $com = $date[1];
                                                $no = $date[2];
                                                if ($com == '' || $no == '') {
                                                    $reply_content = "输入格式:\n快递#快递公司#单号\n即可查询您的包裹\n最新状态";
                                                } else {
                                                    $reply_content = $o->kuaidi($com, $no);
                                                }
                                            } else {
                                                if ($content == "A" || $content == "a") {
                                                    $reply_content = $o->get_song_douban();
                                                } else {
                                                    if (strstr($content, "公交") || $content == "B" || $content == "b") {
                                                        $date = explode("#", $content);
                                                        $city = $date[1];
                                                        $no = $date[2];
                                                        if ($city == '' || $no == '') {
                                                            $reply_content = "输入:公交#城市#公交线路\n即可获得线路";
                                                        } else {
                                                            $reply_content = $o->get_bus($city, $no);
                                                        }
                                                    } else {
                                                        if (strstr($content, "翻译") || $content == "C" || $content == "c") {
                                                            $date = explode("#", $content);
                                                            $key = $date[1];
                                                            if ($key == '') {
                                                                $reply_content = "输入:翻译#英文\n或者直接告诉小助手你想知道的英文单词\n小助手即刻帮您翻译";
                                                            } else {
                                                                $reply_content = $o->enTozh($key);
                                                            }
                                                        } else {
                                                            if (strstr($content, "天气") || $content == "t" || $content == "T") {
                                                                $date = explode("#", $content);
                                                                $key = $date[1];
                                                                if ($key == '') {
                                                                    $reply_content = "发送格式:天气#城市\n即可查询天气预报";
                                                                } else {
                                                                    $reply_content = $o->get_weather($key);
                                                                }
                                                            } else {
                                                                if (strstr($content, "找找帮") || ($content = "8")) {
                                                                    $text = str_replace('找找帮', '', $content);
                                                                    $reply_content = $o->send_zzbon($text, $from);
                                                                } else {
                                                                    if (strstr($content, "音乐") || $content == "h" || $content == "H") {
                                                                        $reply_content = $o->get_song_tencent($content);
                                                                        $reply_content = mb_convert_encoding($reply_content, 'utf-8', 'gbk');
                                                                    } else {
                                                                        if (strstr($content, "视频")) {
                                                                            $reply_content = $o->get_video_youku($content);
                                                                        } else {
                                                                            if (strstr($content, "表白")) {
                                                                                $reply_content = $o->get_biaobai($content, $from);
                                                                            } else {
                                                                                $reply_content = "未知外部接口!";
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    } else {
                        // 表情处理
                        $content = $w->biaoqing($content);
                        // 如果有星标的标记则设为星标(用于留言)
                        if (strstr($content, FLAG)) {
                            $w->set_funcflag();
                        }
                        $url = 'http://www.tuling123.com/openapi/api?key=2de48f93cfa6fb3fff1c0ede2ac8b953&info=' . $content;
                        $reply_content = file_get_contents($url);
                        preg_match_all('/{"code":100000,"text":"(.+?)"}/is', $reply_content, $core);
                        $reply_content = $core[1][0];
                        if (YOURNICK) {
                            $reply_content = str_replace('小豆', YOURNICK, $reply_content);
                        }
                        if ($reply_content == "") {
                            $reply_content = "你说的话太深奥了,教我如何答你好呢?\n命令:问...答...\n";
                        }
                    }
                }
            }
        }
    } else {
        if ($welcome != '') {
            $reply_content = WELCOME;
        }
    }
    // 音乐地址
    if (strstr($reply_content, 'murl')) {
        // 音乐
        $a = array();
        foreach (explode('#', $reply_content) as $reply_content) {
            list($k, $v) = explode('|', $reply_content);
            $a[$k] = $v;
        }
        $reply_content = $a;
    } elseif (strstr($reply_content, 'pic')) {
        $reply_content = replypic($reply_content);
    }
    // 最后返回
    return $reply_content;
}
Beispiel #2
0
<?php

/**
 * 小九处理类
 *
 * by:wzwjxgz
 */
$content = $this->message['content'];
$this->beginContext(1800);
$this->refreshContext(60);
if ($content == '退出' || $content == '取消') {
    $this->endContext();
    return $this->respText("你已经退出本模式");
}
global $_W;
$content = xiaojo($this->message['content'], $this->message['from']);
if (strstr($content, '#murl|')) {
    $content = str_replace('#murl|', '#musicurl|', $content);
    $content = str_replace('#hqurl|', '#HQMusicUrl|', $content);
    $music = array();
    foreach (explode('#', $content) as $content) {
        list($k, $v) = explode('|', $content);
        $music[$k] = $v;
    }
    return $this->respMusic($music);
} elseif (strstr($content, '#pic|')) {
    $content = str_replace('#pic|', '#picurl|', $content);
    $news = array();
    if (strstr($content, '@title|')) {
        $content = str_replace('@title|', '@titletitle|', $content);
        $a = array();
Beispiel #3
0
function reply_cb($request, $w)
{
    $to = $request['ToUserName'];
    $from = $request['FromUserName'];
    $time = $w->get_creattime();
    if ($w->get_msg_type() == "location") {
        $lacation = "x@" . (string) $request['Location_X'] . "@" . (string) $request['Location_Y'];
        $lacation = urlencode(str_replace('\\.', '\\\\.', $lacation));
        $lacation = urldecode(xiaojo($lacation, $from, $to));
        return $lacation;
    } else {
        if ($w->get_msg_type() == "image") {
            $PicUrl = $request['PicUrl'];
            $pic = urldecode(xiaojo("&" . $PicUrl, $from, $to));
            //$w->set_funcflag();
            return $pic;
        } else {
            if ($w->get_msg_type() == "voice") {
                return array("title" => "你好", "description" => "亲爱的主人", "murl" => "http://weixen-file.stor.sinaapp.com/b/xiaojo.mp3", "hqurl" => "http://weixen-file.stor.sinaapp.com/b/xiaojo.mp3");
            } else {
                if ($w->get_msg_type() == "event") {
                    if ($w->get_event_type() == "subscribe") {
                        $sql_flag = "replace`weixin_flag` (`openid`,`flag`,`vote`,`nickname`) VALUES ('{$from}','-1','1','{$nicheng}')";
                        mysql_query($sql_flag);
                        return media(urldecode(MOREN));
                    } elseif ($w->get_event_type() == "unsubscribe") {
                        $sql_flag = "replace`weixin_flag` (`openid`,`flag`,`vote`,`nickname`) VALUES ('{$from}','-1','1','{$nicheng}')";
                        mysql_query($sql_flag);
                        $unsub = media(urldecode(MOREN));
                        return $unsub;
                    } elseif ($w->get_event_type() == "click") {
                        $menukey = $w->get_event_key();
                        $menu = xiaojo($menukey, $from, $to);
                        return $menu;
                    } else {
                        $menukey = $w->get_event_key();
                        return $menukey;
                    }
                }
            }
        }
    }
    $content = trim($request['Content']);
    $firsttime = $content;
    if ($content !== "") {
        //$w->set_funcflag(); //如果有必要的话,加星标,方便在web处理
        $content = $w->biaoqing($content);
        //表情处理
        if (strstr($content, FLAG)) {
            $w->set_funcflag();
        }
        /*话题判断函数开始*/
        function startsWith($haystack, $needle, $case = false)
        {
            if ($case) {
                return strcmp(substr($haystack, 0, strlen($needle)), $needle) === 0;
            }
            return strcasecmp(substr($haystack, 0, strlen($needle)), $needle) === 0;
        }
        /*话题判断函数结束*/
        include "db.php";
        if (startsWith($content, $huati)) {
            file_get_contents(Web_ROOT . "/moni/test.php");
            $sql_name = "UPDATE  `weixin_flag` SET `nickname` = '{$nicheng}'  WHERE  `openid` =  '{$from}';";
            mysql_query($sql_name);
            $reply = "title|发送成功#pic|#url|{$weixin_wxq}@title|你已经成功发送,审核通过即可上墙!PS:点击我,查看微信墙!";
        }
        /*
                
        		if($reply=="")
        		{
        			$reply = MOREN ;
        		}*/
        $reply = media(urldecode($reply));
        return $reply;
    } else {
        return MOREN;
    }
}
Beispiel #4
0
function reply_main($request, $w)
{
    $to = $request['ToUserName'];
    $from = $request['FromUserName'];
    //大众接口
    if ($w->get_msg_type() == "location") {
        $lacation = "x@" . (string) $request['Location_X'] . "@" . (string) $request['Location_Y'];
        $lacation = urlencode(str_replace('\\.', '\\\\.', $lacation));
        $lacation = urldecode(xiaojo($lacation, $from, $to));
        return $lacation;
    } else {
        if ($w->get_msg_type() == "image") {
            $PicUrl = $request['PicUrl'];
            $w->set_funcflag();
            return "咦,我也有这张照片:" . $PicUrl;
        } else {
            if ($w->get_msg_type() == "voice") {
                return array("title" => "你好", "description" => "亲爱的主人", "murl" => "http://weixen-file.stor.sinaapp.com/b/xiaojo.mp3", "hqurl" => "http://weixen-file.stor.sinaapp.com/b/xiaojo.mp3");
            } else {
                if ($w->get_msg_type() == "event") {
                    //关注
                    if ($w->get_event_type() == "subscribe") {
                        $welcome = WELCOME;
                        return $welcome;
                    } elseif ($w->get_event_type() == "unsubscribe") {
                        $unsub = urldecode(xiaojo("subscribe", $from, $to));
                        return $unsub;
                    } elseif ($w->get_event_type() == "click") {
                        $menukey = $w->get_event_key();
                        $menu = urldecode(xiaojo($menukey, $from, $to));
                        return $menu;
                    } else {
                        $menukey = $w->get_event_key();
                        return $menukey;
                    }
                }
            }
        }
    }
    //获取http的content字段
    $content = trim($request['Content']);
    if (!empty($content)) {
        $flag = "0";
        //广药内网接口
        if ($content == "?" || $content == '?') {
            $flag = 'menu';
        } else {
            if (strstr($content, "绑定")) {
                return $content = "【管理员回复】\n\n绑定以及相关功能目前还在内测,还没有接入到本平台,可以加微信号doctoryanson(Y博士)或者gdpucafe(广药淅水咖啡厅)进行测试>>>\n\n有菜单版本更加方便快捷<a href=\"weixin://contacts/profile/gh_a450baf872ec\">点击关注</a>";
            } else {
                if ($content == "菜单" || $content == '帮助' || $content == "列表" || $content == '清单' || $content == '功能') {
                    $flag = "text";
                } else {
                    if (strstr($content, "开户")) {
                        $flag = "5";
                    } else {
                        if (strstr($content, "网号")) {
                            $flag = "6";
                        } else {
                            if ($content == "1" || $content == "2" || $content == "9" || strstr($content, "还书") || strstr($content, "图书")) {
                                $flag = "gdpuapi";
                            } else {
                                if (strstr($content, "表白") || strstr($content, "绑定") || strstr($content, "cet") || strstr($content, "Cet") || strstr($content, "CET6") || strstr($content, "CET") || strstr($content, "cet4") || strstr($content, "cet6") || strstr($content, "CET4") || strstr($content, "4") || strstr($content, "四级") || strstr($content, "六级") || strstr($content, "4级") || strstr($content, "6级") || strstr($content, "归属地") || strstr($content, "解梦") || strstr($content, "身份证") || strstr($content, "找找帮") || strstr($content, "音乐") || strstr($content, "视频") || $content == "A" || $content == "a") {
                                    $flag = "webapi";
                                } else {
                                    if (strstr($content, "成绩") || strstr($content, "10")) {
                                        $content = str_replace('#', '#', $content);
                                        $ret = explode('#', $content);
                                        $xh = $ret[1];
                                        $pw = $ret[2];
                                        if ($xh && $pw) {
                                            $url = 'http://ours.123nat.com:59832/helper/api/jwcapi.php?xh=' . $xh . '&pw=' . $pw . '&flag=2';
                                            $content = file_get_contents($url);
                                            //			$content = explode("2014学年",$content);
                                            //			$content = $content[1];
                                            //			$content = str_replace('2013','-',$content);
                                            $content = substr($content, 0, 1900);
                                        } elseif (!$xh || !$pw) {
                                            $content = "请确认【格式】是否正确\n\n成绩#学号#密码";
                                        } else {
                                            $content = "请确认格式是否正确\n\n成绩#学号#密码";
                                        }
                                        return $content;
                                    } else {
                                        if (strstr($content, "课表") || strstr($content, "7")) {
                                            $content = str_replace('#', '#', $content);
                                            $ret = explode('#', $content);
                                            $xh = $ret[1];
                                            $pw = $ret[2];
                                            $day = date("w");
                                            if (isset($ret[3])) {
                                                if ($ret[3] >= 1 && $ret[3] <= 5) {
                                                    $day = $ret[3];
                                                }
                                                if (strtolower($ret[3]) == 'all') {
                                                    $day = 'all';
                                                }
                                            }
                                            if ($xh && $pw) {
                                                $url = 'http://ours.123nat.com:59832/helper/kb/kb.php?xh=' . $xh . '&pw=' . $pw . '&day=' . $day;
                                                $content = file_get_contents($url);
                                            } elseif (!$xh || !$pw) {
                                                $content = "【现已支持所有校区】\n按照以下格式获取课表\n\n【今天课表】\n课表#学号#密码\n\n【周X课表】\n课表#学号#密码#X\n\n(X为1-5,或者是all,否则均默认为当天,周六、日显示全部课表)\n\n【例如】\n获取今天课表:\n课表#1207511199#1207511199\n\n获取周1课表:\n课表#1207511199#1207511199#1\n\n获取全部课表:\n课表#1207511199#1207511199#all";
                                            } else {
                                                $content = "【现已支持所有校区】\n按照以下格式获取课表\n\n【今天课表】\n课表#学号#密码\n\n【周X课表】\n课表#学号#密码#X\n\n(X为1-5,或者是all,否则均默认为当天,周六、日显示全部课表)\n\n【例如】\n获取今天课表:\n课表#1207511199#1207511199\n\n获取周1课表:\n课表#1207511199#1207511199#1\n\n获取全部课表:\n课表#1207511199#1207511199#all";
                                            }
                                            return $content;
                                        } else {
                                            if (strstr($content, "11") || strstr($content, "选修")) {
                                                $content = str_replace('#', '#', $content);
                                                $ret = explode('#', $content);
                                                $xh = $ret[1];
                                                $pw = $ret[2];
                                                if ($xh && $pw) {
                                                    $url = 'http://ours.123nat.com:59832/helper/jwc/wx.xuanxiu.api.php?xh=' . $xh . '&pw=' . $pw;
                                                    $content = file_get_contents($url);
                                                } elseif (!$xh || !$pw) {
                                                    $content = "请确认【格式】是否正确\n\n选修#学号#密码";
                                                } else {
                                                    $content = "请确认【格式】是否正确\n\n选修#学号#密码";
                                                }
                                                return $content;
                                            } else {
                                                if (strstr($content, "4") || strstr($content, "cet") || strstr($content, "Cet") || strstr($content, "四级") || strstr($content, "六级")) {
                                                    if (strstr($content, "4") || strstr($content, "cet") || strstr($content, "Cet") || strstr($content, "四级") || strstr($content, "六级")) {
                                                        $content = trim($content);
                                                        $content = str_replace('#', '#', $content);
                                                        $ret = explode('#', $content);
                                                        $zkzh = trim($ret[1]);
                                                        $xm = trim($ret[2]);
                                                        if ($zkzh == '' || $xm == '') {
                                                            $content = "【CET4,6级查询】\nby Ourstudio工作室\n请检查格式是否正确\n发送\n\ncet#准考证号#姓名\n\n即可查询";
                                                        }
                                                        if ($zkzh && $xm) {
                                                            $url = 'http://ours.123nat.com:59832/helper/chengji/cet_wx.php?zkzh=' . $zkzh . '&xm=' . $xm;
                                                            $content = file_get_contents($url);
                                                            if ($content == "") {
                                                                $content = "无法查找到你的成绩,请检查学号、姓名是否正确\n";
                                                            }
                                                            return $content;
                                                            //  $content="请确认信息全部正确,比如名字一定要全称,不能简写。收到最新消息称要到9点各网站才开通查询4,6级成绩";
                                                        }
                                                    }
                                                } else {
                                                    if (strstr($content, "动漫")) {
                                                        $url = 'http://110.75.189.200/chris/helper/media_update.php';
                                                        $content = file_get_contents($url);
                                                        return $content;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        //menu内容
        if ($flag == "menu" || strstr($content, "查询")) {
            $content = MENU;
        } else {
            if ($flag == "text") {
                $content = TEXT;
            } else {
                if ($flag == "5" || $flag == "6") {
                    if ($flag == "5") {
                        $content = ltrim($content, "开户");
                    } else {
                        if ($flag == "6") {
                            $content = ltrim($content, "网号");
                        }
                    }
                    $url = 'http://zlgc.gdpu.edu.cn/gdpuer/api.php?flag=' . $flag . '&content=' . $content;
                    $content = file_get_contents($url);
                } else {
                    if ($flag == "gdpuapi") {
                        $g = new WebAPI();
                        if ($content == "1") {
                            $content = $g->get_gdpu_news();
                        } else {
                            if ($content == "2") {
                                $content = "开发中";
                                // $content=$g->get_gdpu_jobs();
                            } else {
                                if ($content == "9") {
                                    $content = $g->get_gdpu_partime();
                                } else {
                                    if (strstr($content, "图书")) {
                                        $keyword = str_replace("图书", "", $content);
                                        $content = $g->get_lib_book($keyword);
                                    } else {
                                        if (strstr($content, "还书")) {
                                            $keyword = str_replace("还书", "", $content);
                                            $content = $g->get_lib_boorowbook($keyword);
                                        } else {
                                            $content = "未知外网接口!";
                                        }
                                    }
                                }
                            }
                        }
                    } else {
                        if ($flag == "webapi") {
                            $o = new WebAPI();
                            if (strstr($content, "4") || strstr($content, "cet") || strstr($content, "Cet") || strstr($content, "四级") || strstr($content, "六级")) {
                                if (strstr($content, "4") || strstr($content, "cet") || strstr($content, "Cet") || strstr($content, "四级") || strstr($content, "六级")) {
                                    $content = trim($content);
                                    $content = str_replace('#', '#', $content);
                                    $ret = explode('#', $content);
                                    $zkzh = trim($ret[1]);
                                    $xm = trim($ret[2]);
                                    if ($zkzh == '' || $xm == '') {
                                        $content = "【CET4,6级查询】\nby Ourstudio工作室\n请检查格式是否正确\n发送\n\ncet#准考证号#姓名\n\n即可查询";
                                    }
                                    if ($zkzh && $xm) {
                                        $url = 'http://ours.123nat.com:59832/helper/chengji/cet_wx.php?zkzh=' . $zkzh . '&xm=' . $xm;
                                        $content = file_get_contents($url);
                                        if ($content == "") {
                                            $content = "无法查找到你的成绩,请检查学号、姓名是否正确\n";
                                        }
                                        return $content;
                                        //	$content="请确认信息全部正确,比如名字一定要全称,不能简写。收到最新消息称要到9点各网站才开通查询4,6级成绩";
                                    }
                                }
                                /*
                                  $content=ltrim($content,"cet");
                                  $regex = '/[0-9]*$/';
                                  preg_match($regex, $content, $zkzh);
                                  $xm=rtrim($content,$zkzh[0]);
                                  $content=$o->get_ours_cet($zkzh[0],$xm);
                                */
                            } else {
                                if (strstr($content, "归属地")) {
                                    $number = ltrim($content, "归属地");
                                    $content = $o->get_ours_mobile($number);
                                } else {
                                    if (strstr($content, "解梦")) {
                                        $key = str_replace('解梦', '', $content);
                                        $content = $o->get_ours_dream($key);
                                    } else {
                                        if ($content == "l" || $content == "L") {
                                            $content = $o->get_ours_award();
                                        } else {
                                            if (strstr($content, "身份证")) {
                                                $no = str_replace('身份证', '', $content);
                                                $content = $o->get_ours_idcard($no);
                                            } else {
                                                if (strstr($content, "找找帮")) {
                                                    $text = str_replace('找找帮', '', $content);
                                                    $content = $o->send_ours_zzbon($text, $from);
                                                } else {
                                                    if ($content == "A" || $content == "a") {
                                                        $content = $o->get_song_random();
                                                    } else {
                                                        if (strstr($content, "音乐")) {
                                                            $content = $o->get_song_tencent($content);
                                                            $content = mb_convert_encoding($content, 'utf-8', 'gbk');
                                                        } else {
                                                            if (strstr($content, "视频")) {
                                                                $content = $o->get_video_youku($content);
                                                            } else {
                                                                if (strstr($content, "表白")) {
                                                                    $content = $o->get_biaobai($content, $from);
                                                                } else {
                                                                    $content = "未知外部接口!";
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        } else {
                            //表情处理
                            $content = $w->biaoqing($content);
                            //如果有星标的标记则设为星标(用于留言)
                            if (strstr($content, FLAG)) {
                                $w->set_funcflag();
                            }
                            //	$url = 'http://xiao.douqq.com/api.php?msg='.$content.'&type=txt';
                            $url = 'http://www.tuling123.com/openapi/api?key=2de48f93cfa6fb3fff1c0ede2ac8b953&info=' . $content;
                            $content = file_get_contents($url);
                            preg_match_all('/{"code":100000,"text":"(.+?)"}/is', $content, $core);
                            $content = $core[1][0];
                            if (YOURNICK) {
                                $content = str_replace('小豆', YOURNICK, $content);
                            }
                            if ($content == "") {
                                $content = "你说的话太深奥了,教我如何答你好呢?\n命令:问...答...\n";
                            }
                        }
                    }
                }
            }
        }
    } else {
        if ($welcome != '') {
            $content = WELCOME;
        }
    }
    //音乐地址
    if (strstr($content, 'murl')) {
        //音乐
        $a = array();
        foreach (explode('#', $content) as $content) {
            list($k, $v) = explode('|', $content);
            $a[$k] = $v;
        }
        $content = $a;
    } elseif (strstr($content, 'pic')) {
        $a = array();
        $b = array();
        $c = array();
        $n = 0;
        $contents = $content;
        foreach (explode('@t', $content) as $b[$n]) {
            if (strstr($contents, '@t')) {
                $b[$n] = str_replace("itle", "title", $b[$n]);
                $b[$n] = str_replace("ttitle", "title", $b[$n]);
            }
            foreach (explode('#', $b[$n]) as $content) {
                list($k, $v) = explode('|', $content);
                $a[$k] = $v;
                $d .= $k;
            }
            $c[$n] = $a;
            $n++;
        }
        $content = $c;
    }
    //最后返回
    return $content;
}
Beispiel #5
0
function reply_main($request, $w)
{
    $to = $request['ToUserName'];
    $from = $request['FromUserName'];
    //大众接口
    if ($w->get_msg_type() == "location") {
        $lacation = "x@" . (string) $request['Location_X'] . "@" . (string) $request['Location_Y'];
        $lacation = urlencode(str_replace('\\.', '\\\\.', $lacation));
        $lacation = urldecode(xiaojo($lacation, $from, $to));
        return $lacation;
    } else {
        if ($w->get_msg_type() == "image") {
            $PicUrl = $request['PicUrl'];
            $w->set_funcflag();
            return "咦,我也有这张照片:" . $PicUrl;
        } else {
            if ($w->get_msg_type() == "voice") {
                return array("title" => "你好", "description" => "亲爱的主人", "murl" => "http://weixen-file.stor.sinaapp.com/b/xiaojo.mp3", "hqurl" => "http://weixen-file.stor.sinaapp.com/b/xiaojo.mp3");
            } else {
                if ($w->get_msg_type() == "event") {
                    //关注
                    if ($w->get_event_type() == "subscribe") {
                        $welcome = WELCOME;
                        return $welcome;
                    } elseif ($w->get_event_type() == "unsubscribe") {
                        $unsub = urldecode(xiaojo("subscribe", $from, $to));
                        return $unsub;
                    } elseif ($w->get_event_type() == "click") {
                        $menukey = $w->get_event_key();
                        $menu = urldecode(xiaojo($menukey, $from, $to));
                        return $menu;
                    } else {
                        $menukey = $w->get_event_key();
                        return $menukey;
                    }
                }
            }
        }
    }
    //获取http的content字段
    $content = trim($request['Content']);
    //开户指南
    if (strstr($content, '开')) {
        $url = 'http://mp.weixin.qq.com/s?__biz=MjM5OTA1NzMyMg==&mid=201721356&idx=1&sn=2ab0f94f0514fc6d01b5addc76caf446&scene=4#wechat_redirect';
        $content = '#title|开户@title|开户指南入口' . '#url|' . $url . '#pic';
        if (strstr($content, 'pic')) {
            $a = array();
            $b = array();
            $c = array();
            $n = 0;
            $contents = $content;
            foreach (explode('@t', $content) as $b[$n]) {
                if (strstr($contents, '@t')) {
                    $b[$n] = str_replace("itle", "title", $b[$n]);
                    $b[$n] = str_replace("ttitle", "title", $b[$n]);
                }
                foreach (explode('#', $b[$n]) as $content) {
                    list($k, $v) = explode('|', $content);
                    $a[$k] = $v;
                    $d .= $k;
                }
                $c[$n] = $a;
                $n++;
            }
            $content = $c;
        }
        return $content;
    }
    //开户指南结束
    if (!empty($content)) {
        $flag = "0";
        //广药内网接口
        if ($content == "?" || $content == '?' || $content == 'help') {
            $flag = 'menu';
        } else {
            if (strstr($content, "绑定")) {
                return $content = "【管理员回复】\n\n绑定以及相关功能目前还在内测,还没有接入到本平台,可以加微信号doctoryanson(Y博士)或者gdpucafe(广药淅水咖啡厅)进行测试>>>\n\n有菜单版本更加方便快捷<a href=\"weixin://contacts/profile/gh_a450baf872ec\">点击关注</a>";
            } else {
                if ($content == "菜单" || $content == '帮助' || $content == "列表" || $content == '清单' || $content == '功能') {
                    $flag = "text";
                } else {
                    if (strstr($content, "网号") || $content == "6") {
                        $flag = "6";
                    } else {
                        if ($content == "1" || $content == "2" || $content == "9" || $content == "3" || $content == "4" || strstr($content, "还书") || strstr($content, "还") || strstr($content, "图书")) {
                            $flag = "gdpuapi";
                        } else {
                            if (strstr($content, "表白") || strstr($content, "绑定") || strstr($content, "cet") || strstr($content, "Cet") || strstr($content, "CET6") || strstr($content, "CET") || strstr($content, "cet4") || strstr($content, "cet6") || strstr($content, "CET4") || strstr($content, "四级") || strstr($content, "六级") || strstr($content, "4级") || strstr($content, "6级") || strstr($content, "手机") || $content == "i" || $content == "I" || strstr($content, "解梦") || $content == "g" || $content == "G" || strstr($content, "身份") || $content == "j" || $content == "J" || strstr($content, "找找帮") || $content == "8" || strstr($content, "音乐") || strstr($content, "视频") || strstr($content, "公交") || $content == "A" || $content == "a" || $content == "B" || $content == "b" || $content == "E" || $content == "e" || strstr($content, "翻译") || $content == "F" || $content == 'f' || strstr($content, "快递")) {
                                $flag = "webapi";
                            } else {
                                if (strstr($content, "成绩") || $content == "10") {
                                    $content = str_replace('#', '#', $content);
                                    $ret = explode('#', $content);
                                    $xh = $ret[1];
                                    $pw = $ret[2];
                                    if ($xh && $pw) {
                                        // $url = 'http://phpdo9.nat123.net:52182/helper/api/jwcapi.php?xh='.$xh.'&pw='.$pw.'&flag=2';
                                        $url = 'http://av.jejeso.com/helper/api/get_chengji.php?xh=' . $xh . '&pw=' . $pw;
                                        //2014 09 15 $content = file_get_contents($url);
                                        //			$content = explode("2014学年",$content);
                                        //			$content = $content[1];
                                        //			$content = str_replace('2013','-',$content);
                                        //2014 09 15 $content = substr($content,0,1900);
                                        //2014 09 15 add start
                                        //$g = file_get_contents($url);
                                        $content = '#title|成绩单@title|亲爱的学霸Orz,这是您的成绩单请笑纳~^_^(单击获取,若页面为空请确认密码学号无误)' . '#url|' . $url . '#pic';
                                        if (strstr($content, 'pic')) {
                                            $a = array();
                                            $b = array();
                                            $c = array();
                                            $n = 0;
                                            $contents = $content;
                                            foreach (explode('@t', $content) as $b[$n]) {
                                                if (strstr($contents, '@t')) {
                                                    $b[$n] = str_replace("itle", "title", $b[$n]);
                                                    $b[$n] = str_replace("ttitle", "title", $b[$n]);
                                                }
                                                foreach (explode('#', $b[$n]) as $content) {
                                                    list($k, $v) = explode('|', $content);
                                                    $a[$k] = $v;
                                                    $d .= $k;
                                                }
                                                $c[$n] = $a;
                                                $n++;
                                            }
                                            $content = $c;
                                        }
                                        return $content;
                                        //2014 09 15 add end
                                    } elseif (!$xh || !$pw) {
                                        $content = "请确认【格式】是否正确\n\n成绩#学号#密码";
                                    } else {
                                        $content = "请确认格式是否正确\n\n成绩#学号#密码";
                                    }
                                    return $content;
                                } else {
                                    if (strstr($content, "课表") || $content == "7") {
                                        $content = str_replace('#', '#', $content);
                                        $ret = explode('#', $content);
                                        $xh = $ret[1];
                                        $pw = $ret[2];
                                        $day = date("w");
                                        if (isset($ret[3])) {
                                            if ($ret[3] >= 1 && $ret[3] <= 5) {
                                                $day = $ret[3];
                                            }
                                            if (strtolower($ret[3]) == 'all') {
                                                $day = 'all';
                                            }
                                        }
                                        if ($xh && $pw) {
                                            $url = 'http://phpdo9.nat123.net:52182/helper/kb/kb.php?xh=' . $xh . '&pw=' . $pw . '&day=' . $day;
                                            $content = file_get_contents($url);
                                        } elseif (!$xh || !$pw) {
                                            // $content="【现已支持所有校区】\n按照以下格式获取课表\n\n【今天课表】\n课表#学号#密码\n\n【周X课表】\n课表#学号#密码#X\n\n(X为1-5,或者是all,否则均默认为当天,周六、日显示全部课表)\n\n【例如】\n获取今天课表:\n课表#1207511199#1207511199\n\n获取周1课表:\n课表#1207511199#1207511199#1\n\n获取全部课表:\n课表#1207511199#1207511199#all";
                                            $content = "【现已支持所有校区】\n按照以下格式获取课表\n\n【今天课表】\n课表#学号#密码\n\n【周X课表】\n课表#学号#密码#X\n\n(X为1-5,或者是all,否则均默认为当天,周六、日显示全部课表)\n\n【例如】\n获取今天课表:\n课表#1207511199#1207511199\n\n获取周1课表:\n课表#1207511199#1207511199#1";
                                        } else {
                                            // $content="【现已支持所有校区】\n按照以下格式获取课表\n\n【今天课表】\n课表#学号#密码\n\n【周X课表】\n课表#学号#密码#X\n\n(X为1-5,或者是all,否则均默认为当天,周六、日显示全部课表)\n\n【例如】\n获取今天课表:\n课表#1207511199#1207511199\n\n获取周1课表:\n课表#1207511199#1207511199#1\n\n获取全部课表:\n课表#1207511199#1207511199#all";
                                            $content = "【现已支持所有校区】\n按照以下格式获取课表\n\n【今天课表】\n课表#学号#密码\n\n【周X课表】\n课表#学号#密码#X\n\n(X为1-5,或者是all,否则均默认为当天,周六、日显示全部课表)\n\n【例如】\n获取今天课表:\n课表#1207511199#1207511199\n\n获取周1课表:\n课表#1207511199#1207511199#1";
                                        }
                                        return $content;
                                    } else {
                                        if ($content == "11" || strstr($content, "选修")) {
                                            $content = str_replace('#', '#', $content);
                                            $ret = explode('#', $content);
                                            $xh = $ret[1];
                                            $pw = $ret[2];
                                            if ($xh && $pw) {
                                                $url = 'http://phpdo9.nat123.net:52182/helper/jwc/wx.xuanxiu.api.php?xh=' . $xh . '&pw=' . $pw;
                                                $content = file_get_contents($url);
                                            } elseif (!$xh || !$pw) {
                                                $content = "请确认【格式】是否正确\n\n选修#学号#密码";
                                            } else {
                                                $content = "请确认【格式】是否正确\n\n选修#学号#密码";
                                            }
                                            return $content;
                                        } else {
                                            if (strstr($content, "cet") || strstr($content, "Cet") || strstr($content, "四级") || strstr($content, "六级")) {
                                                if (strstr($content, "cet") || strstr($content, "Cet") || strstr($content, "四级") || strstr($content, "六级")) {
                                                    $content = trim($content);
                                                    $content = str_replace('#', '#', $content);
                                                    $ret = explode('#', $content);
                                                    $zkzh = trim($ret[1]);
                                                    $xm = trim($ret[2]);
                                                    if ($zkzh == '' || $xm == '') {
                                                        $content = "【CET4,6级查询】\nby Ourstudio工作室\n请检查格式是否正确\n发送\n\ncet#准考证号#姓名\n\n即可查询";
                                                    }
                                                    if ($zkzh && $xm) {
                                                        $url = 'http://ours.123nat.com:59832/helper/chengji/cet_wx.php?zkzh=' . $zkzh . '&xm=' . $xm;
                                                        $content = file_get_contents($url);
                                                        if ($content == "") {
                                                            $content = "无法查找到你的成绩,请检查学号、姓名是否正确\n";
                                                        }
                                                        return $content;
                                                        //  $content="请确认信息全部正确,比如名字一定要全称,不能简写。收到最新消息称要到9点各网站才开通查询4,6级成绩";
                                                    }
                                                }
                                            } else {
                                                if (strstr($content, "动漫") || $content == "5") {
                                                    $url = 'http://110.75.189.200/chris/helper/media_update.php';
                                                    $content = file_get_contents($url);
                                                    return $content;
                                                } else {
                                                    if (strstr($content, "外卖") || strstr($content, "KFC") || strstr($content, "快餐")) {
                                                        $content = "1、龙旺食府 1884214432 短号:66694\n9块钱3肉一菜";
                                                        return $content;
                                                    } else {
                                                        if (strstr($content, "建议") || strstr($content, "意见") || strstr($content, "投诉")) {
                                                            // $content = "请打开网站:<a>http://av.jejeso.com/helper/api/add_advices/commit.html</a>,进去提建议,谢谢:)";
                                                            $content = "http://av.jejeso.com/helper/api/add_advices/commit.html\n复制网址到您的浏览器中\n即可建议\n感谢您宝贵的建议:)";
                                                            return $content;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        //menu内容
        if ($flag == "menu" || strstr($content, "查询")) {
            $content = MENU;
        } else {
            if ($flag == "text") {
                $content = TEXT;
            } else {
                if ($flag == "6" || $content == "6") {
                    // if($flag=="6"){$content=ltrim($content,"网号");}
                    // $url = 'http://zlgc.gdpu.edu.cn/gdpuer/api.php?flag='.$flag.'&content='.$content;
                    //     $content= file_get_contents($url);
                    if ($flag == "6") {
                        $content = "查询接口http://www.gzekt.com";
                    }
                } else {
                    if ($flag == "gdpuapi") {
                        $g = new WebAPI();
                        if ($content == "1") {
                            $content = $g->get_gdpu_news();
                        } else {
                            if ($content == "2") {
                                // $content="开发中";
                                $content = $g->get_gdpu_jobs();
                            } else {
                                if ($content == "9") {
                                    $content = $g->get_gdpu_partime();
                                } else {
                                    if (strstr($content, "图书") || $content == "3") {
                                        $keyword = str_replace("图书", "", $content);
                                        $content = $g->get_lib_book($keyword);
                                    } else {
                                        if ($content == "4" || strstr($content, "还")) {
                                            $array = explode("#", $content);
                                            $xh = $array[1];
                                            if ($xh == '') {
                                                $content = "查询正确格式为:\n还书#学号";
                                            } else {
                                                // $keyword=str_replace("还书","",$content);
                                                // $content=$g->get_lib_boorowbook($keyword);
                                                $content = $g->get_lib_boorowbook($xh);
                                            }
                                        } else {
                                            $content = "未知外网接口!";
                                        }
                                    }
                                }
                            }
                        }
                    } else {
                        if ($flag == "webapi") {
                            $o = new WebAPI();
                            if ($content == "4" || strstr($content, "cet") || strstr($content, "Cet") || strstr($content, "四级") || strstr($content, "六级")) {
                                if ($content == "4" || strstr($content, "cet") || strstr($content, "Cet") || strstr($content, "四级") || strstr($content, "六级")) {
                                    $content = trim($content);
                                    $content = str_replace('#', '#', $content);
                                    $ret = explode('#', $content);
                                    $zkzh = trim($ret[1]);
                                    $xm = trim($ret[2]);
                                    if ($zkzh == '' || $xm == '') {
                                        $content = "【CET4,6级查询】\nby Ourstudio工作室\n请检查格式是否正确\n发送\n\ncet#准考证号#姓名\n\n即可查询";
                                    }
                                    if ($zkzh && $xm) {
                                        $url = 'http://av.jejeso.com/helper/chengji/cet_wx.php?zkzh=' . $zkzh . '&xm=' . $xm;
                                        $content = file_get_contents($url);
                                        if ($content == "") {
                                            $content = "无法查找到你的成绩,请检查学号、姓名是否正确\n";
                                        }
                                        return $content;
                                        //  $content="请确认信息全部正确,比如名字一定要全称,不能简写。收到最新消息称要到9点各网站才开通查询4,6级成绩";
                                    }
                                }
                                /*
                                  $content=ltrim($content,"cet");
                                  $regex = '/[0-9]*$/';
                                  preg_match($regex, $content, $zkzh);
                                  $xm=rtrim($content,$zkzh[0]);
                                  $content=$o->get_ours_cet($zkzh[0],$xm);
                                */
                            } else {
                                if (strstr($content, "手机") || $content == "i" || $content == "I") {
                                    $date = explode("#", $content);
                                    $number = $date[1];
                                    if ($number == '') {
                                        $content = "查归属地格式:手机#手机号\n即可查询归属地";
                                    } else {
                                        $content = $o->get_ours_mobile($number);
                                    }
                                } else {
                                    if (strstr($content, "解梦") || $content == "g" || $content == "G") {
                                        // $key=str_replace('解梦','',$content);
                                        $date = explode("#", $content);
                                        $key = $date[1];
                                        if ($key == '') {
                                            $content = "发送格式:解梦#关键词\n即可解开你的梦境";
                                        } else {
                                            $content = $o->get_ours_dream($key);
                                        }
                                    } else {
                                        if ($content == "l" || $content == "L") {
                                            $content = $o->get_ours_award();
                                        } else {
                                            if (strstr($content, "身份") || $content == "j" || $content == "J") {
                                                $date = explode("#", $content);
                                                // $no=str_replace('身份证','',$content);
                                                $no = $date[1];
                                                if ($no == '') {
                                                    $content = "查看身份:\n输入\t身份#身份证";
                                                } else {
                                                    $content = $o->get_ours_idcard($no);
                                                }
                                            } else {
                                                if (strstr($content, "快递") || $content == "F" || $content == "f") {
                                                    $date = explode("#", $content);
                                                    $com = $date[1];
                                                    $no = $date[2];
                                                    if ($com == '' || $no == '') {
                                                        $content = "输入格式:\n快递#快递公司#单号\n即可查询您的包裹\n最新状态";
                                                    } else {
                                                        $content = $o->kuaidi($com, $no);
                                                    }
                                                } else {
                                                    if ($content == "A" || $content == "a") {
                                                        $content = $o->get_song_random();
                                                    } else {
                                                        if (strstr($content, "公交") || $content == "B" || $content == "b") {
                                                            $date = explode("#", $content);
                                                            $city = $date[1];
                                                            $no = $date[2];
                                                            if ($city == '' || $no == '') {
                                                                $content = "输入:公交#城市#公交线路\n即可获得线路";
                                                            } else {
                                                                $content = $o->get_bus($city, $no);
                                                            }
                                                        } else {
                                                            if (strstr($content, "翻译") || $content == "E" || $content == "e") {
                                                                $date = explode("#", $content);
                                                                $key = $date[1];
                                                                if ($key == '') {
                                                                    $content = "输入:翻译#英文\n或者直接告诉小助手你想知道的英文单词\n小助手即刻帮您翻译";
                                                                } else {
                                                                    $content = $o->enTozh($key);
                                                                }
                                                            } else {
                                                                if (strstr($content, "找找帮") || ($content = "8")) {
                                                                    $text = str_replace('找找帮', '', $content);
                                                                    $content = $o->send_ours_zzbon($text, $from);
                                                                } else {
                                                                    if (strstr($content, "音乐")) {
                                                                        $content = $o->get_song_tencent($content);
                                                                        $content = mb_convert_encoding($content, 'utf-8', 'gbk');
                                                                    } else {
                                                                        if (strstr($content, "视频")) {
                                                                            $content = $o->get_video_youku($content);
                                                                        } else {
                                                                            if (strstr($content, "表白")) {
                                                                                $content = $o->get_biaobai($content, $from);
                                                                            } else {
                                                                                $content = "未知外部接口!";
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        } else {
                            //表情处理
                            $content = $w->biaoqing($content);
                            //如果有星标的标记则设为星标(用于留言)
                            if (strstr($content, FLAG)) {
                                $w->set_funcflag();
                            }
                            //  $url = 'http://xiao.douqq.com/api.php?msg='.$content.'&type=txt';
                            $url = 'http://www.tuling123.com/openapi/api?key=2de48f93cfa6fb3fff1c0ede2ac8b953&info=' . $content;
                            $content = file_get_contents($url);
                            preg_match_all('/{"code":100000,"text":"(.+?)"}/is', $content, $core);
                            $content = $core[1][0];
                            if (YOURNICK) {
                                $content = str_replace('小豆', YOURNICK, $content);
                            }
                            if ($content == "") {
                                $content = "你说的话太深奥了,教我如何答你好呢?\n命令:问...答...\n";
                            }
                        }
                    }
                }
            }
        }
    } else {
        if ($welcome != '') {
            $content = WELCOME;
        }
    }
    //音乐地址
    if (strstr($content, 'murl')) {
        //音乐
        $a = array();
        foreach (explode('#', $content) as $content) {
            list($k, $v) = explode('|', $content);
            $a[$k] = $v;
        }
        $content = $a;
    } elseif (strstr($content, 'pic')) {
        $a = array();
        $b = array();
        $c = array();
        $n = 0;
        $contents = $content;
        foreach (explode('@t', $content) as $b[$n]) {
            if (strstr($contents, '@t')) {
                $b[$n] = str_replace("itle", "title", $b[$n]);
                $b[$n] = str_replace("ttitle", "title", $b[$n]);
            }
            foreach (explode('#', $b[$n]) as $content) {
                list($k, $v) = explode('|', $content);
                $a[$k] = $v;
                $d .= $k;
            }
            $c[$n] = $a;
            $n++;
        }
        $content = $c;
    }
    //最后返回
    return $content;
}
Beispiel #6
0
function reply_cb($request, $w)
{
    $to = $request['ToUserName'];
    $from = $request['FromUserName'];
    $time = $w->get_creattime();
    if ($w->get_msg_type() == "location") {
        $lacation = "x@" . (string) $request['Location_X'] . "@" . (string) $request['Location_Y'];
        $lacation = urlencode(str_replace('\\.', '\\\\.', $lacation));
        $lacation = urldecode(xiaojo($lacation, $from, $to));
        return $lacation;
    } else {
        if ($w->get_msg_type() == "image") {
            $PicUrl = $request['PicUrl'];
            $pic = urldecode(xiaojo("&" . $PicUrl, $from, $to));
            //$w->set_funcflag();
            return $pic;
        } else {
            if ($w->get_msg_type() == "voice") {
                return array("title" => "你好", "description" => "亲爱的主人", "murl" => "http://weixen-file.stor.sinaapp.com/b/xiaojo.mp3", "hqurl" => "http://weixen-file.stor.sinaapp.com/b/xiaojo.mp3");
            } else {
                if ($w->get_msg_type() == "event") {
                    if ($w->get_event_type() == "subscribe") {
                        $sql_flag = "replace`weixin_flag` (`openid`,`flag`,`vote`,`nickname`) VALUES ('{$from}','-1','1','{$nicheng}')";
                        mysql_query($sql_flag);
                        include "sub.php";
                        $sisi = "title|【{$nickname}】欢迎关注我们的平台#pic|http://f.hiphotos.baidu.com/pic/w%3D230/sign=a34574e90d3387449cc5287f610ed937/30adcbef76094b36f9ce3154a2cc7cd98d109d2e.jpg@title|1.\t上墙#pic|@title|2.\t投票#pic|@title|回复对应的数字进入对应的模块#pic|@title|回复【取消】或【退出】返回主菜单";
                        //开场百
                        $sub = media(urldecode($sisi));
                        if ($nickname == "") {
                            $sub = "欢迎关注,回复1进入上墙模式";
                        }
                        return $sub;
                        //include './baeinsert.php';//可以在这里进行保存的
                    } elseif ($w->get_event_type() == "unsubscribe") {
                        $sql_flag = "replace`weixin_flag` (`openid`,`flag`,`vote`,`nickname`) VALUES ('{$from}','-1','1','{$nicheng}')";
                        mysql_query($sql_flag);
                        $unsub = media(urldecode(MOREN));
                        return $unsub;
                    } elseif ($w->get_event_type() == "click") {
                        $menukey = $w->get_event_key();
                        $menu = xiaojo($menukey, $from, $to);
                        return $menu;
                    } else {
                        $menukey = $w->get_event_key();
                        return $menukey;
                    }
                }
            }
        }
    }
    $content = trim($request['Content']);
    $firsttime = $content;
    if ($content !== "") {
        //$w->set_funcflag(); //如果有必要的话,加星标,方便在web处理
        $content = $w->biaoqing($content);
        //表情处理
        if (strstr($content, FLAG)) {
            $w->set_funcflag();
        }
        /*
        //执行判断,1进入上墙系统,2是投票
        //
        */
        $sql_check = "SELECT * FROM `weixin_flag` where `openid` = '{$from}'";
        $query_check = mysql_query($sql_check);
        $check = mysql_fetch_row($query_check);
        if (!$check[0]) {
            $sql_flag = "replace`weixin_flag` (`openid`,`flag`,`vote`,`nickname`) VALUES ('{$from}','-1','1','{$nicheng}')";
            mysql_query($sql_flag);
        }
        if ($content == '取消' || $content == '退出') {
            $reply = "title|欢迎关注{$weixin_name}#pic|@title|1.\t上墙#pic|@title|2.\t投票#pic|@title|回复对应的数字进入对应的模块#pic|@title|回复【取消】或【退出】返回主菜单";
            $sql_flag = "UPDATE  `weixin_flag` SET `flag` = '-1'  WHERE  `openid` =  '{$from}';";
            mysql_query($sql_flag);
        }
        if ($check[1] == 1) {
            if ($content == '取消' || $content == '退出') {
                $reply = "title|欢迎关注{$weixin_name}#pic|@title|1.\t上墙#pic|@title|2.\t投票#pic|@title|回复对应的数字进入对应的模块#pic|@title|回复【取消】或【退出】返回主菜单";
                $sql_flag = "UPDATE  `weixin_flag` SET `flag` = '-1'  WHERE  `openid` =  '{$from}';";
                mysql_query($sql_flag);
            } else {
                file_get_contents("http://www.bestchoice88.com/Wall/1.php");
                //该地址为1.php上传后的地址
                $sql_name = "UPDATE  `weixin_flag` SET `nickname` = '{$nicheng}'  WHERE  `openid` =  '{$from}';";
                mysql_query($sql_name);
                $reply = "title|发送成功#pic|#url|{$weixin_wxq}@title|你已经成功发送,等待审核通过即可上墙了\n\nPs:点击查看大屏幕#url|{$weixin_wxq}@title|回复【取消】或【退出】返回主菜单";
            }
        }
        if ($check[1] == '2' || $check[1] == '4') {
            $sql_vote_check = "SELECT * FROM `weixin_flag` where `openid` = '{$from}'";
            $query_vote_check = mysql_query($sql_vote_check);
            $vote_check = mysql_fetch_row($query_vote_check);
            $vote_check = $vote_check[2];
            $sql_vote = "SELECT * FROM `weixin_vote` ";
            $query_vote = mysql_query($sql_vote);
            if ($content == '取消' || $content == '退出') {
                $reply = "title|欢迎关注{$weixin_name}#pic|@title|1.\t上墙#pic|@title|2.\t投票#pic|@title|回复对应的数字进入对应的模块#pic|@title|回复【取消】或【退出】返回主菜单";
                $sql_flag = "UPDATE  `weixin_flag` SET `flag` = '-1'  WHERE  `openid` =  '{$from}';";
                mysql_query($sql_flag);
            } elseif ($content == '投票' && $vote_check == '1') {
                while ($vote = mysql_fetch_row($query_vote)) {
                    $name = $vote[1];
                    $id = $vote[0];
                    $idout .= "【" . $id . "】" . $name . "\n";
                }
                $reply = "title|投票系统\n每人只能投一票#pic|@title|输入选手名字面的序号进行投票\n\n" . $idout . "@title|回复【取消】或【退出】返回主菜单";
            } elseif ($vote_check !== '9' && ($content == '1' || $content == '2' || $content == '3' || $content == '4' || $content == '5' || $content == '6' || $content == '7' || $content == '8' || $content == '9' || $content == '10' || $content == '11' || $content == '12' || $content == '13' || $content == '14' || $content == '15')) {
                $sql_tou = "UPDATE  `weixin_vote` SET `res` = `res`+1  WHERE  `id` =  '{$content}';";
                mysql_query($sql_tou);
                $sql_vote_yes = "UPDATE  `weixin_flag` SET `vote` = '9'  WHERE  `openid` =  '{$from}';";
                mysql_query($sql_vote_yes);
                $sql_vote = "SELECT * FROM `weixin_vote` WHERE  `id` =  '{$content}';";
                $query_vote = mysql_query($sql_vote);
                $vote = mysql_fetch_row($query_vote);
                $name = $vote[1];
                $res = $vote[2];
                $reply = "title|投票成功#pic|#url|{$weixin_vote}@title|你成功地把宝贵的一票投给了\n\n【{$content}】号选手【{$name}】\n\nTa目前有【{$res}】票\n\n点击得票查看详情#url|{$weixin_vote}@title|发送【结果】查看最新数据#url|{$weixin_vote}@title|回复【取消】或【退出】返回主菜单";
            } elseif ($vote_check == '9' && ($content == '1' || $content == '2' || $content == '3' || $content == '4' || $content == '5' || $content == '6' || $content == '7' || $content == '8' || $content == '9' || $content == '10' || $content == '11' || $content == '12' || $content == '13' || $content == '14' || $content == '15')) {
                $sql_vote = "SELECT * FROM `weixin_vote` WHERE  `id` =  '{$content}';";
                $query_vote = mysql_query($sql_vote);
                $vote = mysql_fetch_row($query_vote);
                $name = $vote[1];
                $res = $vote[2];
                $reply = "title|投票失败\n每人只能投一票#pic|#url|{$weixin_vote}@title|你已经投了1票给\n\n【{$content}】号选手【{$name}】\n\nTa目前有【{$res}】票\n\n点击查看得票详情#url|{$weixin_vote}@title|发送【结果】查看最新数据#url|{$weixin_vote}@title|回复【取消】或【退出】返回主菜单";
            } elseif ($content == '结果' && $vote_check == '9' || $content == '投票' && $vote_check == '9') {
                while ($vote = mysql_fetch_row($query_vote)) {
                    $name = $vote[1];
                    $res = $vote[2];
                    $resout .= $name . "------>    【" . $res . "】票\n";
                }
                $reply = "title|你已经投过票了\n每人只能投一票#pic|#url|{$weixin_vote}@title|投票结果\n\n" . $resout . "\n\n点击得票查看详情#url|{$weixin_vote}@title|回复【取消】或【退出】返回主菜单";
            } else {
                $reply = "title|投票模式#pic|@title|你已经进入了投票模式\n\n发送【投票】进行投票,每人一票\n\n点击查看得票详情@title|回复【取消】或【退出】返回主菜单";
            }
        }
        if ($check[1] !== '1' && $check[1] !== '2') {
            if ($content == "1") {
                $sql_check = "UPDATE  `weixin_flag` SET `flag` = '1'  WHERE  `openid` =  '{$from}';";
                mysql_query($sql_check);
                $reply = "title|上墙模式#pic|#url|{$weixin_wxq}@title|你已经进入了上墙模式\n\n直接发送内容就可以有机会上墙了#url|{$weixin_wxq}@title|回复【取消】或【退出】返回主菜单#url|{$weixin_wxq}";
            } else {
                if ($content == "2") {
                    $sql_check = "UPDATE  `weixin_flag` SET `flag` = '2'  WHERE  `openid` =  '{$from}';";
                    mysql_query($sql_check);
                    $reply = "title|投票模式#pic|#url|{$weixin_vote}@title|你已经进入了投票模式\n\n发送【投票】进行投票,每人一票@title|回复【取消】或【退出】返回主菜单";
                } else {
                    $reply = MOREN;
                }
            }
        }
        /*
                
        		if($reply=="")
        		{
        			$reply = MOREN ;
        		}*/
        $reply = media(urldecode($reply));
        return $reply;
    } else {
        return MOREN;
    }
}