├── 1.0 ├── .DS_Store ├── Datebase.md ├── api │ ├── .DS_Store │ ├── CityID.xml │ ├── baiduNews_api.php │ ├── baike_api.php │ ├── bing.php │ ├── bing_api.php │ ├── douban_book_api.php │ ├── douban_movie_api.php │ ├── douban_music_api.php │ ├── dream_api.php │ ├── en_sentence_api.php │ ├── jokes_api.php │ ├── lottery_api.php │ ├── phoneNumber_api.php │ ├── picRec_api.php │ ├── qrcode_api.php │ ├── simsimi_api.php │ ├── translate_api.php │ ├── weather_api.php │ └── wiki_api.php ├── index.php └── wechat-api.php ├── 2.0-SAE ├── .DS_Store ├── api │ ├── .DS_Store │ ├── 0x50sec.php │ ├── 91ri.php │ ├── bilibili.php │ ├── book.php │ ├── fileIO.php │ ├── freebuf.php │ ├── ghoststory.php │ ├── ghoststory_read.php │ ├── ifanr.php │ ├── matrix67.php │ ├── mysql.php │ ├── nginx.php │ ├── reddit.php │ ├── saelocation.php │ ├── shejidaren.php │ ├── songshuhui.php │ ├── stackoverflow.php │ ├── wooyun.php │ ├── xiaodoubi.php │ └── yyets.php ├── config.yaml ├── index.php ├── urinx.sinaapp.com │ ├── .DS_Store │ ├── function.py │ └── index.wsgi └── wechat-api.php ├── 3.0 ├── .DS_Store ├── index.php └── wechat-api.php ├── LICENSE └── README.md /1.0/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Urinx/weChat_php/7fa1b48b8e1bc3eb676acaab6eda1775af705590/1.0/.DS_Store -------------------------------------------------------------------------------- /1.0/Datebase.md: -------------------------------------------------------------------------------- 1 | DatebaseName 2 | ============= 3 | 4 | tables: 5 | ------------- 6 | 7 | ###wechat 8 | >ID 9 | >FromUserName 10 | >weacount 11 | >alias 12 | >Location_X 13 | >Location_Y 14 | >photo 15 | ####moments 16 | >ID 17 | >FromUserName 18 | >alias 19 | >moment 20 | >photo 21 | >time 22 | >date 23 | 24 | 25 | -------------------------------------------------------------------------------- /1.0/api/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Urinx/weChat_php/7fa1b48b8e1bc3eb676acaab6eda1775af705590/1.0/api/.DS_Store -------------------------------------------------------------------------------- /1.0/api/baiduNews_api.php: -------------------------------------------------------------------------------- 1 | [^\s>]+)"[^>]*target="_blank">(?[^>]+)</a> <span>(?<resrc>[^>]+)</span>#i'; 10 | preg_match_all($reg, $result, $matches); 11 | $matches[resrc]=str_replace(' ',' ',$matches[resrc]); 12 | for ($i=0; $i < 5; $i++) { 13 | $matches[title][$i]=iconv('gbk','utf-8',$matches[title][$i]); 14 | $matches[resrc][$i]=iconv('gbk','utf-8',$matches[resrc][$i]); 15 | } 16 | return $matches; 17 | } 18 | print_r(baiduNews());//url,title,resrc 19 | ?> -------------------------------------------------------------------------------- /1.0/api/baike_api.php: -------------------------------------------------------------------------------- 1 | <?php 2 | header("content-Type: text/html; charset=utf-8"); 3 | 4 | function baike($word){ 5 | $baike_api_url='http://www.baidu.com/s?wd='.$word.'%20百度百科'; 6 | $result=file_get_contents($baike_api_url); 7 | 8 | $reg='#data="{title : \'.+\', link : \'(.+)\'}"#i'; 9 | if (preg_match_all($reg, $result, $matches)) { 10 | $baike_url=$matches[1][0]; 11 | } 12 | elseif (preg_match_all('#mu="(.+)" data-op=#i', $result, $matches)) { 13 | $baike_url=$matches[1][0]; 14 | } 15 | elseif (preg_match_all('#<a href="(http://www.baidu.com/link\?url=.+)" target="_blank"#i', $result, $matches)){ 16 | $baike_url=$matches[1][0]; 17 | } 18 | else{ 19 | exit('404'); 20 | } 21 | 22 | $baike=file_get_contents($baike_url); 23 | if (preg_match_all('#<title>(.+)#i', $baike, $baike_title)) { 24 | $title=$baike_title[1][0]; 25 | } 26 | if (preg_match_all('#$title,'description'=>$description,'url'=>$baike_url); 32 | return $baikes; 33 | } 34 | 35 | $baike=baike('Euler'); 36 | echo($baike['description']); 37 | ?> -------------------------------------------------------------------------------- /1.0/api/bing.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | PHP Bing 5 | 6 | 7 |
8 | Type in a search: 9 | 10 | 22 | 23 | 24 | array( 36 | 'request_fulluri' => true, 37 | 'header' => "Authorization: Basic " . base64_encode($accountKey . ":" . $accountKey) 38 | ) 39 | )); 40 | 41 | $request = $WebSearchURL . urlencode( '\'' . $_POST["searchText"] . '\''); 42 | 43 | echo($request); 44 | 45 | $response = file_get_contents($request, 0, $context); 46 | 47 | $jsonobj = json_decode($response); 48 | 49 | echo('"); 59 | } 60 | ?> 61 | 62 | 63 | -------------------------------------------------------------------------------- /1.0/api/bing_api.php: -------------------------------------------------------------------------------- 1 | array( 26 | 'request_fulluri' => true, 27 | 'header' => "Authorization: Basic ".base64_encode($accountKey.":".$accountKey) 28 | ) 29 | )); 30 | $request = $WebSearchURL.urlencode('\''.$query.'\''); 31 | 32 | $response = file_get_contents($request, 0, $context); 33 | $jsonobj = json_decode($response); 34 | 35 | $arr=array(); 36 | if ($type=='Image') { 37 | foreach($jsonobj->d->results as $value){ 38 | array_push($arr, $value->Thumbnail->MediaUrl); 39 | } 40 | } 41 | elseif($type=='Web'){ 42 | foreach($jsonobj->d->results as $value){ 43 | array_push($arr, array('title'=>$value->Title,'description'=>$value->Description,'url'=>$value->Url)); 44 | } 45 | } 46 | return $arr; 47 | } 48 | 49 | //$image_url=bing('loli','Image'); 50 | //print_r($image_url); 51 | $web=bing('dudulu','Web'); 52 | print_r($web[0]['title']); 53 | ?> -------------------------------------------------------------------------------- /1.0/api/douban_book_api.php: -------------------------------------------------------------------------------- 1 | books as $value) { 10 | array_push($book, array('average'=>$value->rating->average,'author'=>$value->author,'pubdate'=>$value->pubdate,'images'=>$value->images,'alt'=>$value->alt,'title'=>$value->title,'publisher'=>$value->publisher,'summary'=>$value->summary,'price'=>$value->price,'tags'=>$value->tags,'id'=>$value->id)); 11 | } 12 | return $book; 13 | } 14 | 15 | function doubanBook($id){ 16 | $doubanBook_api_url='https://api.douban.com/v2/book/'; 17 | $result=file_get_contents($doubanBook_api_url.$id); 18 | $jsondata=json_decode($result); 19 | $book=array('average'=>$jsondata->rating->average,'author'=>$jsondata->author,'pubdate'=>$jsondata->pubdate,'images'=>$jsondata->images,'alt'=>$jsondata->alt,'title'=>$jsondata->title,'publisher'=>$jsondata->publisher,'summary'=>$jsondata->summary,'price'=>$jsondata->price,'tags'=>$jsondata->tags); 20 | return $book; 21 | } 22 | $m=doubanBooks('日本文学'); 23 | print_r($m); 24 | ?> -------------------------------------------------------------------------------- /1.0/api/douban_movie_api.php: -------------------------------------------------------------------------------- 1 | 'top250','北美票房榜'=>'us_box','口碑榜'=>'weekly','新片榜'=>'new_movies','正在上映'=>'nowplaying','即将上映'=>'coming'); 6 | $doubanMovie_api_url='http://api.douban.com/v2/movie/'; 7 | if (!isset($list[$word])) { 8 | $result=file_get_contents($doubanMovie_api_url.'search?q='.$word); 9 | } 10 | else{ 11 | $result=file_get_contents($doubanMovie_api_url.$list[$word]); 12 | } 13 | $jsondata=json_decode($result); 14 | $movie=array(); 15 | //top250,search,us_box 16 | foreach ($jsondata->subjects as $value) { 17 | if ($list[$word]=='us_box') { 18 | $value=$value->subject; 19 | } 20 | array_push($movie, array('average'=>$value->rating->average,'title'=>$value->title,'original_title'=>$value->original_title,'year'=>$value->year,'images'=>$value->images,'alt'=>$value->alt,'id'=>$value->id)); 21 | } 22 | return $movie;//{average,title,original_title,year,images,alt,id} 23 | } 24 | 25 | function doubanMovie($id){ 26 | $doubanMovie_api_url='http://api.douban.com/v2/movie/subject/'; 27 | $result=file_get_contents($doubanMovie_api_url.$id); 28 | $jsondata=json_decode($result); 29 | $movie=array('average'=>$jsondata->rating->average,'year'=>$jsondata->year,'images'=>$jsondata->images->large,'mobile_url'=>$jsondata->mobile_url,'title'=>$jsondata->title,'genres'=>$jsondata->genres,'countries'=>$jsondata->countries,'summary'=>$jsondata->summary,'aka'=>$jsondata->aka,'directors'=>$jsondata->directors,'casts'=>$jsondata->casts); 30 | return $movie; 31 | } 32 | $m=doubanMovie(1764796); 33 | print_r($m['directors'][0]->avatars); 34 | ?> -------------------------------------------------------------------------------- /1.0/api/douban_music_api.php: -------------------------------------------------------------------------------- 1 | musics as $value) { 10 | array_push($music, array('average'=>$value->rating->average,'author'=>$value->author,'pubdate'=>$value->attrs->pubdate,'image'=>$value->image,'alt'=>$value->alt,'title'=>$value->title,'publisher'=>$value->attrs->publisher,'singer'=>$value->attrs->singer,'version'=>$value->attrs->version,'id'=>$value->id)); 11 | } 12 | return $music; 13 | } 14 | 15 | function doubanMusic($id){ 16 | $doubanMusic_api_url='https://api.douban.com/v2/music/'; 17 | $result=file_get_contents($doubanMusic_api_url.$id); 18 | $jsondata=json_decode($result); 19 | $music=array('average'=>$jsondata->rating->average,'author'=>$jsondata->author,'summary'=>$jsondata->summary,'image'=>$jsondata->image,'mobile_link'=>$jsondata->mobile_link,'title'=>$jsondata->title,'id'=>$jsondata->id,'publisher'=>$jsondata->attrs->publisher,'singer'=>$jsondata->attrs->singer,'version'=>$jsondata->attrs->version,'pubdate'=>$jsondata->attrs->pubdate,'tags'=>$jsondata->tags); 20 | return $music; 21 | } 22 | $m=doubanMusic(25722147); 23 | print_r($m); 24 | ?> -------------------------------------------------------------------------------- /1.0/api/dream_api.php: -------------------------------------------------------------------------------- 1 | text->content; 9 | } 10 | echo dream('神'); 11 | ?> -------------------------------------------------------------------------------- /1.0/api/en_sentence_api.php: -------------------------------------------------------------------------------- 1 | channel->item->en_sentence."\n"; 10 | $en_sentence.=$enxml->channel->item->cn_sentence."\n"; 11 | $en_sentence.='Update time:'.$enxml->channel->pubDate."\n"; 12 | $en_sentence.='
朗读'; 13 | return $en_sentence; 14 | } 15 | echo str_replace("\n", '
', en_sentenceAPI()); 16 | ?> -------------------------------------------------------------------------------- /1.0/api/jokes_api.php: -------------------------------------------------------------------------------- 1 | content=str_replace(array(' ','
'), '', trim($xmldata->content)); 9 | return $xmldata->content; 10 | } 11 | echo jokes(); 12 | ?> -------------------------------------------------------------------------------- /1.0/api/lottery_api.php: -------------------------------------------------------------------------------- 1 | text->content; 9 | } 10 | function lottery(){ 11 | $lotteryArray=array('双色球','七乐彩','大乐透','七星彩','排列3','排列5','胜负彩','六场半全场'); 12 | foreach ($lotteryArray as $value) { 13 | $lottery.=lotterySearch($value)."\n"; 14 | } 15 | return $lottery; 16 | } 17 | 18 | $lottery=lottery(); 19 | print_r($lottery); 20 | ?> -------------------------------------------------------------------------------- /1.0/api/phoneNumber_api.php: -------------------------------------------------------------------------------- 1 | $phone->province,'city'=>$phone->city,'corp'=>$phone->corp); 9 | return $phoneNum; 10 | } 11 | print_r(phoneNumber('18202750298')); 12 | ?> -------------------------------------------------------------------------------- /1.0/api/picRec_api.php: -------------------------------------------------------------------------------- 1 | text->content; 9 | } 10 | 11 | echo picRec('http://img.hb.aicdn.com/1fbb370153a4948d922d206c2acd608e7ea42b0c2fb27-8lGtP5_fw580'); 12 | ?> -------------------------------------------------------------------------------- /1.0/api/qrcode_api.php: -------------------------------------------------------------------------------- 1 | '); 7 | ?> -------------------------------------------------------------------------------- /1.0/api/simsimi_api.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /1.0/api/translate_api.php: -------------------------------------------------------------------------------- 1 | ', translateAPI('词典')); 62 | ?> -------------------------------------------------------------------------------- /1.0/api/weather_api.php: -------------------------------------------------------------------------------- 1 | 2 | result->addressComponent->province); 8 | $city=str_replace(array('市','县','区'), array('','',''), $mapxml->result->addressComponent->city); 9 | 10 | if(file_exists('CityID.xml')){ 11 | $wxml = simplexml_load_file('CityID.xml'); 12 | for ($i=0; $i < 34; $i++) { 13 | if($province==$wxml->Province[$i][Name]){ 14 | for ($j=0; $j < count($wxml->Province[$i]->City); $j++) { 15 | if ($city==$wxml->Province[$i]->City[$j][Name]) { 16 | $cityID=$wxml->Province[$i]->City[$j][ID]; 17 | } 18 | } 19 | } 20 | } 21 | } 22 | else{} 23 | 24 | $weather_api_url='http://m.weather.com.cn/data/'.$cityID.'.html'; 25 | $weather=file_get_contents($weather_api_url); 26 | $wea=json_decode($weather,1); 27 | 28 | $weaData=$wea['weatherinfo']['city']."\n"; 29 | $weaData.='发布日期:'.$wea['weatherinfo']['date_y'].' '.$wea['weatherinfo']['week']."\n"; 30 | $weaData.='今日气温:'.$wea['weatherinfo']['temp1'].'/'.$wea['weatherinfo']['tempF1']."\n"; 31 | $weaData.='天气:'.$wea['weatherinfo']['weather1']."\n"; 32 | $weaData.='状态:'.$wea['weatherinfo']['index']."\n"; 33 | $weaData.='建议:'.$wea['weatherinfo']['index_d']."\n"; 34 | $weaData.='风向风力:'.$wea['weatherinfo']['wind1']."\n"; 35 | $weaData.='紫外线:'.$wea['weatherinfo']['index_uv']."\n"; 36 | $weaData.='洗车指数:'.$wea['weatherinfo']['index_xc']."\n"; 37 | $weaData.='旅游指数:'.$wea['weatherinfo']['index_tr']."\n"; 38 | $weaData.='舒适指数:'.$wea['weatherinfo']['index_co']."\n"; 39 | $weaData.='晨练指数:'.$wea['weatherinfo']['index_cl']."\n"; 40 | $weaData.='晾晒指数:'.$wea['weatherinfo']['index_ls']."\n"; 41 | $weaData.='感冒指数:'.$wea['weatherinfo']['index_ag']."\n"; 42 | $weaData.="\n".'未来几天天气'."\n"; 43 | $weaData.='明日:'.$wea['weatherinfo']['temp2'].'/'.$wea['weatherinfo']['tempF2']."\n"; 44 | $weaData.=$wea['weatherinfo']['weather2']."\n"; 45 | $weaData.=$wea['weatherinfo']['wind2']."\n"; 46 | $weaData.='第三日:'.$wea['weatherinfo']['temp3'].'/'.$wea['weatherinfo']['tempF3']."\n"; 47 | $weaData.=$wea['weatherinfo']['weather3']."\n"; 48 | $weaData.=$wea['weatherinfo']['wind3']."\n"; 49 | $weaData.='第四日:'.$wea['weatherinfo']['temp4'].'/'.$wea['weatherinfo']['tempF4']."\n"; 50 | $weaData.=$wea['weatherinfo']['weather4']."\n"; 51 | $weaData.=$wea['weatherinfo']['wind4']."\n"; 52 | $weaData.='第五日:'.$wea['weatherinfo']['temp5'].'/'.$wea['weatherinfo']['tempF5']."\n"; 53 | $weaData.=$wea['weatherinfo']['weather5']."\n"; 54 | $weaData.=$wea['weatherinfo']['wind5']."\n"; 55 | $weaData.='第六日:'.$wea['weatherinfo']['temp6'].'/'.$wea['weatherinfo']['tempF6']."\n"; 56 | $weaData.=$wea['weatherinfo']['weather6']."\n"; 57 | $weaData.=$wea['weatherinfo']['wind6']."\n"; 58 | 59 | return $weaData; 60 | } 61 | // for test 62 | /* 63 | echo weatherAPI(30.5321,105.2323); 64 | */ 65 | ?> 66 | 67 | 68 | -------------------------------------------------------------------------------- /1.0/api/wiki_api.php: -------------------------------------------------------------------------------- 1 | http://zh.wikipedia.org/wiki/title 4 | //China:zh;English:en 5 | 6 | function wiki($srsearch,$lng){ 7 | $wiki_api_url='http://'.$lng.'.wikipedia.org/w/api.php?action=query&list=search&srwhat=text&format=xml&srsearch='.$srsearch; 8 | $result=file_get_contents($wiki_api_url); 9 | $xmldata=simplexml_load_string($result); 10 | 11 | $arr=array(); 12 | foreach ($xmldata->query->search->p as $value) { 13 | $value['snippet']=str_replace(array('','',' '), '', $value['snippet']); 14 | array_push($arr,array('title'=>$value['title'],'snippet'=>$value['snippet'])); 15 | } 16 | return $arr; 17 | } 18 | 19 | print_r(wiki('人人','zh')); 20 | ?> -------------------------------------------------------------------------------- /1.0/index.php: -------------------------------------------------------------------------------- 1 | Content)); 16 | $type=strtolower($xml->MsgType); 17 | $openid=$xml->FromUserName; 18 | $web='http://paiplace.5gbfree.com/wechat'; 19 | $mp='http://mp.weixin.qq.com/mp/appmsg/show'; 20 | $xiaoU=array( 21 | array('title'=>'Uri','cover'=>$web.'/img/xiaou.jpg','link'=>$mp.'?__biz=MzA3MjAzMTgyMA==&appmsgid=10000058&itemidx=1&sign=93bf84e650d4df87196988b342b65644&uin=MTg0MTcyODUwMQ%3D%3D&key=1f75b224f2ddfcb63ee0ec9833578cef7b1a67f0a5b8764f174219e1dea6ff39600f23b296cd7601a031fb617c173721&devicetype=android-17&version=25000104&lang=zh_CN'), 22 | array('title'=>'功能介绍','cover'=>$web.'/img/function.png','link'=>$mp.'?__biz=MzA3MjAzMTgyMA==&appmsgid=10000058&itemidx=2&sign=aa817cfb12b9117cb518d4ab268d28b9&uin=MTg0MTcyODUwMQ%3D%3D&key=a45a7c15a542fe6fc8cb6988104ee36150747c2ada475afb2ac31bce5694e6c3926bef8e4a56de8e63d7ca0e91c68a1f&devicetype=android-17&version=25000104&lang=zh_CN'), 23 | array('title'=>'任务进度','cover'=>$web.'/img/taskprocess.png','link'=>$mp.'?__biz=MzA3MjAzMTgyMA==&appmsgid=10000058&itemidx=3&sign=5edb8953ca274271a239626c434df4a2&uin=MTg0MTcyODUwMQ%3D%3D&key=1f75b224f2ddfcb6c670a05130da7f8843902f3277a89843ae023cec9a770260f883566234a1185fec8257197f241425&devicetype=android-17&version=25000104&lang=zh_CN'), 24 | array('title'=>'联系我们','cover'=>$web.'/img/contactme.png','link'=>$mp.'?__biz=MzA3MjAzMTgyMA==&appmsgid=10000058&itemidx=4&sign=a7d37be0a672e5c2085330799836992b&uin=MTg0MTcyODUwMQ%3D%3D&key=1f75b224f2ddfcb62c58bc42a307d4f512acd5bfc822af05b55a2f55325983e93e612b5c098985be9b9909a57e7eab5e&devicetype=android-17&version=25000104&lang=zh_CN') 25 | ); 26 | $biaoqing=array( 27 | '/::)','/::~','/::B','/::|','/:8-)','/::<','/::$','/::X','/::Z','/::\'(','/::-|', 28 | '/::@','/::P','/::D','/::O','/::(','/::+','/:--b','/::Q','/::T','/:,@P','/:,@-D', 29 | '/::d','/:,@o','/::g','/:|-)','/::!','/::L','/::>','/::,@','/:,@f','/::-S','/:?', 30 | '/:,@x','/:,@@','/::8','/:,@!','/:!!!','/:xx','/:bye','/:wipe','/:dig','/:handclap', 31 | '/:&-(','/:B-)','/:<@','/:@>','/::-O','/:>-|','/:P-(','/::\'|','/:X-)','/::*','/:@x', 32 | '/:8*'); 33 | 34 | // 接收位置 35 | if($type=='location'){ 36 | $uriID='oTHwbt_9H0QVjJn8AdI-fmkHdKgM'; 37 | $X=$xml->Location_X; 38 | $Y=$xml->Location_Y; 39 | 40 | $res=mysql_query("SELECT * FROM wechat WHERE FromUserName='{$uriID}'"); 41 | $row=mysql_fetch_row($res); 42 | $pre_X=$row[4]; 43 | $pre_Y=$row[5]; 44 | 45 | $wData=weatherAPI($X,$Y);//天气查询 46 | $distance=W::getDistance($X,$Y,$pre_X,$pre_Y);//计算距离 47 | 48 | if ($openid == $uriID) { 49 | mysql_query("UPDATE wechat SET Location_X='{$X}',Location_Y='{$Y}' WHERE FromUserName='{$uriID}'"); 50 | $data='主人的位置已上传'."\n".'X:'.$X."\n".'Y:'.$Y."\n".'相距上次位置'.$distance.'km'; 51 | } 52 | else{ 53 | $data='哦哦,你和我的距离只有'.$distance.'km哟'; 54 | } 55 | $data.="\n".'------------------------------'."\n".$wData; 56 | } 57 | 58 | //接收文字 59 | elseif($type=='text'){ 60 | if(ctype_alpha($content)) { 61 | $data=translateAPI($content); 62 | } 63 | //phoneNumber 64 | elseif(ctype_alnum($content)){ 65 | $phoneNum=phoneNumber($num); 66 | $data=$phoneNum['city']."\n".$phoneNum['corp']; 67 | } 68 | elseif($content=='小u'){ 69 | $data=$xiaoU; 70 | } 71 | elseif($content=='帮助'){ 72 | $data='这是目前小u有的功能:'."\n".'-----------------'."\n".'[小u]'."\n".':查看小u的基本信息,以及功能介绍和近期更新'."\n".'-----------------'."\n".'[帮助]'."\n".':查看使用帮助'."\n".'-----------------'."\n".'[查水表]'."\n".':查询寝室的水电费(华科)'."\n".'-----------------'."\n".'[每日一句]'."\n".':每天更新一句英语,中英对照'."\n".'-----------------'."\n".'[点歌]'."\n".':小u每天会为大家推荐好的歌曲,希望大家喜欢。如果想给某人点歌的话,可以直接跟我说哦'."\n".'-----------------'."\n".'[笑话]'."\n".':郁闷时看看笑话吧,小u这里有好多笑话等着你呢'."\n".'-----------------'."\n".'[新闻]'."\n".':没事的时候大家多看看新闻吧,小u不懈的为你奉送中'."\n".'-----------------'."\n".'[彩票]'."\n".':每天的彩票信息一目了然'."\n".'-----------------'."\n".'翻译'."\n".':发送"#+你要翻译的内容",即可收到详细结果,例如:#doofus'."\n".'-----------------'."\n".'天气+找小u'."\n".':点击下面的“+”,发送你的的位置信息,即可收到本地的天气预报,并且看到你和小u的距离哟。'."\n".'-----------------'."\n".'bing搜索'."\n".':发送"%+你要搜索的内容",即可收到详细结果,例如:%dweeb'."\n".'-----------------'."\n".'维基百科'."\n".':发送"&+你要搜索的内容",小u会根据你的输入自动判断查询中文维基或是英文,(*^__^*) 嘻嘻。例如:&spaz'."\n".'-----------------'."\n".'二维码'."\n".':发送"*+你要生成的内容",小u会返回生成的二维码。例如:*嘟嘟噜'."\n".'-----------------'; 73 | $data.="\n".'豆瓣'."\n".'1.书'."\n".' bs:关键字 搜索相关的书籍'."\n".' b:书名 查看详细内容'."\n".'2.音乐'."\n".' ms:关键字 搜索相关的音乐'."\n".' m:音乐名 查看详细内容'."\n".'3.电影'."\n".' vs:关键字 搜索相关的电影'."\n".' v:电影名 查看详细内容'."\n".'-----------------'; 74 | $data.="\n".'动态'."\n".':发送":+你要分享的文字"即可,大家可以回复[动态]查看,都可以看到哦。例如 :这是我发的第一个说说'."\n".'-----------------'; 75 | $data.="\n".'美女识别'."\n".':上传图片,看看小u的眼力吧'."\n".'-----------------'."\n".'周公解梦'."\n".':发送"梦到xxx",小u来预测吉凶,例如"梦到小u"'."\n".'-----------------'."\n".'手机号码查询'."\n".':直接发送手机号'."\n".'-----------------'; 76 | $data.="\n".'#[xx]内的内容xx是指你发送给小u的'; 77 | } 78 | elseif($content=='查水表'){ 79 | $data='查询电费请点击这里:'."\n".'查电费。'."\n".'低余电费自动提醒功能请点击这里:'."\n".'邮件提醒'; 80 | } 81 | elseif($content=='点歌'){ 82 | $data =array('title'=>'你给的甜', 'description'=>'何艺纱', 'musicurl'=>'http://data7.5sing.com/T1aMbeBXbT1R47IVrK.mp3', 'HQmusicurl'=>'http://data7.5sing.com/T1aMbeBXbT1R47IVrK.mp3'); 83 | } 84 | elseif($content=='每日一句'){ 85 | $data=en_sentenceAPI(); 86 | } 87 | elseif($content=='笑话'){ 88 | $data=jokes(); 89 | } 90 | elseif($content=='彩票'){ 91 | $data=lottery(); 92 | } 93 | elseif($content=='新闻'){ 94 | $news=baiduNews(); 95 | $data=array(); 96 | for ($i=0;$i<5;$i++){ 97 | array_push($data,array('title'=>$news[title][$i]."\n".'------------------------------------------','note'=>$news[resrc][$i],'link'=>$news[url][$i])); 98 | } 99 | } 100 | //dream 101 | elseif(preg_match('/^(梦到)(.+)/i', $content, $matches)){ 102 | $data=dream($matches[2]); 103 | } 104 | //translate 105 | elseif(preg_match('/^(#)(.+)/i', $content, $matches)){ 106 | $data=translateAPI($matches[2]); 107 | } 108 | //bing web search 109 | elseif(preg_match('/^(%)(.+)/i',$content,$matches)){ 110 | $bingweb=bing($matches[2],'Web'); 111 | $bingimage=bing($matches[2],'Image'); 112 | $data=array( 113 | array('title'=>$matches[2],'note'=>'','cover'=>$bingimage[0],'link'=>'') 114 | ); 115 | //max:7 116 | for ($i=0;$i<5;$i++){ 117 | array_push($data,array('title'=>$bingweb[$i]['title']."\n".'------------------------------------------','note'=>$bingweb[$i]['description'],'cover'=>'','link'=>$bingweb[$i]['url'])); 118 | } 119 | } 120 | //wiki 121 | elseif (preg_match('/^(&)(.+)/i',$content,$matches)){ 122 | $wiki=wiki($matches[2],$lng); 123 | $data=array(); 124 | for ($i=0;$i<5;$i++){ 125 | array_push($data,array('title'=>$wiki[$i]['title']."\n".'------------------------------------------','note'=>$wiki[$i]['snippet'],'cover'=>'','link'=>'http://zh.wikipedia.org/wiki/'.$wiki[$i]['title'])); 126 | } 127 | } 128 | //qrcode 129 | elseif(preg_match('/^(\*)(.+)/i',$content,$matches)){ 130 | $qrcode='http://chart.apis.google.com/chart?cht=qr&chs=400x400&choe=UTF-8&chl='.$matches[2]; 131 | $data=array( 132 | array('title'=>$matches[2],'cover'=>$qrcode,'link'=>$qrcode) 133 | ); 134 | } 135 | //doubanMovie 136 | elseif(preg_match('/^(vs:)(.+)/i',$content,$matches)){ 137 | $m=doubanMovies($matches[2]); 138 | $data=array(array('title'=>$m[0]['title'],'note'=>$m[0]['year'].' '.$m[0]['average'],'cover'=>$m[0]['images']->large,'link'=>$m[0]['alt'])); 139 | for ($i=1;$i<=5;$i++){ 140 | array_push($data,array('title'=>$m[$i]['title'],'note'=>'又名:'.$m[$i]['original_title']."\n".'上映日期:'.$m[$i]['year']."\n".'评价:'.$m[$i]['average'],'cover'=>$m[$i]['images']->small,'link'=>$m[$i]['alt'])); 141 | } 142 | } 143 | elseif(preg_match('/^(v:)(.+)/i',$content,$matches)){ 144 | $m=doubanMovies($matches[2]); 145 | $movie=doubanMovie($m[0]['id']); 146 | $xinxi='又名:'; 147 | foreach ($movie['aka'] as $value) { 148 | $xinxi.=$value.'/'; 149 | } 150 | $xinxi.="\n".'上映日期:'.$movie['year']."\n".'制片国家:'; 151 | foreach ($movie['countries'] as $value) { 152 | $xinxi.=$value.'/'; 153 | } 154 | $xinxi.="\n".'类型:'; 155 | foreach ($movie['genres'] as $value) { 156 | $xinxi.=$value.'/'; 157 | } 158 | $xinxi.="\n".'评价:'.$movie['average']; 159 | $data=array( 160 | array('title'=>$movie['title'],'cover'=>$movie['images'],'link'=>$movie['mobile_url']), 161 | array('note'=>$xinxi,'link'=>$movie['mobile_url']), 162 | array('title'=>'简介','note'=>$movie['summary'],'link'=>$movie['mobile_url']), 163 | array('title'=>'导演','note'=>$movie['directors'][0]->name,'cover'=>$movie['directors'][0]->avatars->small,'link'=>$movie['directors'][0]->alt), 164 | array('title'=>'主演','note'=>$movie['casts'][0]->name,'cover'=>$movie['casts'][0]->avatars->small,'link'=>$movie['casts'][0]->alt) 165 | ); 166 | } 167 | //doubanBook 168 | elseif(preg_match('/^(bs:)(.+)/i',$content,$matches)){ 169 | $b=doubanBooks($matches[2]); 170 | $data=array(array('title'=>$b[0]['title'],'note'=>$b[0]['author'][0].' '.$b[0]['average'],'cover'=>$b[0]['images']->large,'link'=>$b[0]['alt'])); 171 | for ($i=1;$i<=4;$i++){ 172 | array_push($data,array('title'=>$b[$i]['title'],'note'=>'作者:'.$b[$i]['author'][0]."\n".'出版社:'.$b[$i]['publisher']."\n".'出版日期:'.$b[$i]['pubdate']."\n".'价格:'.$b[$i]['price']."\n".'评价:'.$b[$i]['average']."\n".'导言:'.$b[$i]['summary'],'cover'=>$b[$i]['images']->small,'link'=>$b[$i]['alt'])); 173 | } 174 | } 175 | elseif(preg_match('/^(b:)(.+)/i',$content,$matches)){ 176 | $b=doubanBooks($matches[2]); 177 | $bk=doubanBook($b[0]['id']); 178 | $data=array( 179 | array('title'=>$bk['title'],'cover'=>$bk['images'],'link'=>$bk['alt']), 180 | array('note'=>'作者:'.$bk['author'][0]."\n".'出版社:'.$bk['publisher']."\n".'出版日期:'.$bk['pubdate']."\n".'价格:'.$bk['price']."\n".'评价:'.$bk['average'],'link'=>$bk['alt']), 181 | array('title'=>'导言:','note'=>$bk['summary'],'link'=>$bk['alt']) 182 | ); 183 | } 184 | //doubanMusic 185 | elseif(preg_match('/^(ms:)(.+)/i',$content,$matches)){ 186 | $m=doubanMusics($matches[2]); 187 | $data=array(array('title'=>$m[0]['title'],'note'=>$m[0]['average'],'cover'=>$m[0]['image'],'link'=>$m[0]['alt'])); 188 | for ($i=1;$i<=4;$i++){ 189 | array_push($data,array('title'=>$m[$i]['title'],'note'=>'作者:'.$m[$i]['author'][0]->name."\n".'出版社:'.$m[$i]['publisher'][0]."\n".'出版日期:'.$m[$i]['pubdate'][0]."\n".'表演者:'.$m[$i]['singer'][0]."\n".'评价:'.$m[$i]['average']."\n".'类型:'.$m[$i]['version'][0],'cover'=>$m[$i]['image'],'link'=>$m[$i]['alt'])); 190 | } 191 | } 192 | elseif(preg_match('/^(m:)(.+)/i',$content,$matches)){ 193 | $m=doubanMusics($matches[2]); 194 | $mu=doubanMusic($m[0]['id']); 195 | $data=array( 196 | array('title'=>$mu['title'],'cover'=>$mu['image'],'link'=>$mu['mobile_link']), 197 | array('note'=>'表演者:'.$mu['singer'][0]."\n".'专辑类型:'.$mu['version'][0]."\n".'发行时间:'.$mu['pubdate'][0]."\n".'作者:'.$mu['author'][0]->name."\n".'出版者:'.$mu['publisher'][0]."\n".'评价:'.$mu['average'],'link'=>$mu['mobile_link']), 198 | array('title'=>'简介:','note'=>$mu['summary'],'link'=>$mu['mobile_link']) 199 | ); 200 | } 201 | //moments 202 | elseif(preg_match('/^(:)(.+)/i',$content,$matches)){ 203 | $moment=$matches[2]; 204 | $time=time(); 205 | $date=date("Y-m-d H:i:s",time()); 206 | 207 | $res=mysql_query("SELECT * FROM wechat WHERE FromUserName='{$openid}'"); 208 | $row=mysql_fetch_array($res); 209 | $alias=$row['alias']; 210 | if (!$alias) { 211 | $data='由于你是第一次发送动态,请按照以下格式回复基本信息:'."\n".'昵称:+你的昵称'; 212 | } 213 | else{ 214 | mysql_query("INSERT INTO moments(FromUserName,alias,moment,time,date) VALUES ('{$openid}','{$alias}','{$moment}',{$time},'{$date}')"); 215 | $data="发送成功,你可以现在上传一张图片作为配图,当然也可以不上传啦。回复[动态]查看"; 216 | } 217 | } 218 | elseif($content=='动态'){ 219 | $res=mysql_query("SELECT * FROM moments ORDER BY ID DESC"); 220 | $data=array(array('title'=>'动态','cover'=>$web.'/img/meizi/2.jpg')); 221 | for ($i=0; $i < 5; $i++) { 222 | if ($row=mysql_fetch_array($res)) { 223 | array_push($data, array('title'=>$row['alias'].':','note'=>$row['moment']."\n".$row['date'],'cover'=>$row['photo'])); 224 | } 225 | } 226 | } 227 | elseif(preg_match('/^(昵称:)(.+)/i',$content,$matches)){ 228 | $alias=$matches[2]; 229 | $res=mysql_query("SELECT * FROM wechat"); 230 | while ($row=mysql_fetch_array($res)) { 231 | if ($alias==$row['alias'] || $alias=='小u' || $alias=='urinx') { 232 | $t=1; 233 | } 234 | elseif ($openid==$row['FromUserName']) { 235 | $u=1; 236 | } 237 | } 238 | if ($t) { 239 | $data='该用户名已被注册,请重新输入'; 240 | } 241 | else{ 242 | if ($u) { 243 | mysql_query("UPDATE wechat SET alias='{$alias}' WHERE FromUserName='{$openid}'"); 244 | $data='更改成功!'; 245 | } 246 | else{ 247 | mysql_query("INSERT INTO wechat(FromUserName,alias) VALUES ('{$openid}','{$alias}')"); 248 | $data='注册成功!'; 249 | } 250 | } 251 | } 252 | //biaoqing 253 | elseif (preg_match('#(/:)#i',$content)) { 254 | $data=$biaoqing[rand(0,count($biaoqing)-1)]; 255 | } 256 | } 257 | 258 | //接收图片 259 | elseif($type=='image'){ 260 | $picurl=$xml->PicUrl; 261 | mysql_query("UPDATE moments SET photo='{$picurl}' WHERE FromUserName='{$openid}'"); 262 | $data='你的图片已上传成功!'; 263 | $data.="\n".picRec($picurl); 264 | } 265 | 266 | //接收事件 267 | elseif($type=='event'){ 268 | $event=strtolower($xml->Event); 269 | if($event=='subscribe'){ 270 | $data=$xiaoU; 271 | } 272 | } 273 | 274 | //贱鸡自动回复 275 | if ($data) { 276 | if (is_array($data)) { 277 | if ($data['musicurl']) { 278 | exit(W::response($xml,$data,'music')); 279 | } 280 | exit(W::response($xml,$data,'news')); 281 | } 282 | else{exit(W::response($xml,$data));} 283 | } 284 | else{ 285 | if (rand(1,8)==6){ 286 | switch (rand(1,4)) { 287 | case 1: 288 | exit(W::response($xml,"聊了这么久小u给你讲个笑话吧:\n".jokes())); 289 | break; 290 | 291 | case 2: 292 | $news=baiduNews(); 293 | $data=array(array('title'=>'关心国家大事,了解天下奇谈,小u给你播报新闻啦!')); 294 | for ($i=0;$i<5;$i++){ 295 | array_push($data,array('title'=>$news[title][$i]."\n".'------------------------------------------','note'=>$news[resrc][$i],'link'=>$news[url][$i])); 296 | } 297 | exit(W::response($xml,$data,'news')); 298 | break; 299 | 300 | case 3: 301 | exit(W::response($xml,"四六级没考过吧孩子,还是乖乖跟我学英语,嗯哼:\n".en_sentenceAPI()."\n哎哟,你还可以发英语单词考我哦,没有我不知道的,嘻嘻/:B-)")); 302 | break; 303 | 304 | case 4: 305 | exit(W::response($xml,"妹子爆个照吧,小u想看看嘛,看了会说话嘛/:8*")); 306 | break; 307 | 308 | default: 309 | break; 310 | } 311 | } 312 | else{ 313 | exit(W::response($xml,simsimi($content))); 314 | } 315 | } 316 | } 317 | 318 | ?> -------------------------------------------------------------------------------- /1.0/wechat-api.php: -------------------------------------------------------------------------------- 1 | '; 8 | $xmltpl['text'].='%s0'; 9 | $xmltpl['item']='<![CDATA[%s]]>'; 10 | $xmltpl['news']='%s'; 11 | $xmltpl['news'].='%s%s1'; 12 | $xmltpl['music']='%s'; 13 | $xmltpl['music'].='<![CDATA[%s]]>'; 14 | $xmltpl['image']='%s1234567890123456'; 15 | 16 | if($type == 'text'){ 17 | return sprintf($xmltpl['text'],$xml->FromUserName,$xml->ToUserName,$time,$data); 18 | } 19 | 20 | elseif($type=='news'){ 21 | if(is_array($data)){ 22 | $items=''; 23 | if(count($data) > 1){ 24 | foreach($data as $e){ 25 | $title=trim($e['title']."\n".$e['note'],"\n"); 26 | $items.=sprintf($xmltpl['item'],$title,'',$e['cover'],$e['link']); 27 | } 28 | } 29 | elseif(count($data) == 1){ 30 | foreach($data as $e){ 31 | $items=sprintf($xmltpl['item'],$e['title'],$e['note'],$e['cover'],$e['link']); 32 | } 33 | } 34 | else{ 35 | return self::response($xml,'没有数据'); 36 | } 37 | return sprintf($xmltpl['news'],$xml->FromUserName,$xml->ToUserName,$time,count($data),$items); 38 | } 39 | return self::response($xml,'没有数据'); 40 | } 41 | 42 | elseif($type == 'music'){ 43 | return sprintf($xmltpl['music'],$xml->FromUserName,$xml->ToUserName,$time,$data['title'],$data['description'],$data['musicurl'],$data['HQmusicurl']); 44 | } 45 | 46 | //这个目前不能用 47 | elseif($type == 'image'){ 48 | return sprintf($xmltpl['image'],$xml->FromUserName,$xml->ToUserName,$time,$data); 49 | } 50 | 51 | return self::response($xml,'主人不在家,如果有什么事的话,你可以直接对[小u]说。'); 52 | } 53 | 54 | /** 55 | **已知两点的经纬度,计算两点间的距离(公里) 56 | **/ 57 | static function getDistance($lat1,$lng1,$lat2,$lng2){ 58 | $lat1=(double)$lat1; 59 | $lat2=(double)$lat2; 60 | $lng1=(double)$lng1; 61 | $lng2=(double)$lng2; 62 | $EARTH_RADIUS=6378.137; 63 | $radLat1=$lat1*pi()/180.0; 64 | $radLat2=$lat2*pi()/180.0; 65 | $a=$radLat1-$radLat2; 66 | $b=$lng1*pi()/180.0-$lng2*pi()/180.0; 67 | $s=2*asin(sqrt(pow(sin($a/2),2)+ 68 | cos($radLat1)*cos($radLat2)*pow(sin($b/2),2))); 69 | $s=$s*$EARTH_RADIUS; 70 | $s=round($s*10000)/10000; 71 | return number_format($s,2,'.',''); 72 | } 73 | 74 | static function requestMethod() { 75 | return $_SERVER['REQUEST_METHOD']; 76 | } 77 | 78 | static function isGET() { 79 | return self::requestMethod() == 'GET'; 80 | } 81 | 82 | static function isPOST() { 83 | return self::requestMethod() == 'POST'; 84 | } 85 | 86 | /** 87 | * POST 请求指定URL 88 | */ 89 | static function fpost($url, $post = '', $limit = 0, $cookie = '', $ip = '', $timeout = 15, $block = TRUE) { 90 | $return=''; 91 | $matches=parse_url($url); 92 | !isset($matches['host']) && $matches['host'] = ''; 93 | !isset($matches['path']) && $matches['path'] = ''; 94 | !isset($matches['query']) && $matches['query'] = ''; 95 | !isset($matches['port']) && $matches['port'] = ''; 96 | $host = $matches['host']; 97 | $path = $matches['path'] ? $matches['path'].($matches['query'] ? '?'.$matches['query'] : '') : '/'; 98 | $port = !empty($matches['port']) ? $matches['port'] : 80; 99 | if($post) { 100 | $out = "POST $path HTTP/1.0\r\n"; 101 | $out .= "Accept: */*\r\n"; 102 | $out .= "Accept-Language: zh-cn\r\n"; 103 | $out .= "Content-Type: application/x-www-form-urlencoded\r\n"; 104 | $out .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n"; 105 | $out .= "Host: $host\r\n"; 106 | $out .= 'Content-Length: '.strlen($post)."\r\n"; 107 | $out .= "Connection: Close\r\n"; 108 | $out .= "Cache-Control: no-cache\r\n"; 109 | $out .= "Cookie: $cookie\r\n\r\n"; 110 | $out .= $post; 111 | } 112 | else { 113 | $out = "GET $path HTTP/1.0\r\n"; 114 | $out .= "Accept: */*\r\n"; 115 | $out .= "Accept-Language: zh-cn\r\n"; 116 | $out .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n"; 117 | $out .= "Host: $host\r\n"; 118 | $out .= "Connection: Close\r\n"; 119 | $out .= "Cookie: $cookie\r\n\r\n"; 120 | } 121 | 122 | if(function_exists('fsockopen')) { 123 | $fp = @fsockopen(($ip ? $ip : $host), $port, $errno, $errstr, $timeout); 124 | } 125 | elseif (function_exists('pfsockopen')) { 126 | $fp = @pfsockopen(($ip ? $ip : $host), $port, $errno, $errstr, $timeout); 127 | } 128 | else { 129 | $fp = false; 130 | } 131 | 132 | if(!$fp) { 133 | return ''; 134 | } 135 | else { 136 | stream_set_blocking($fp, $block); 137 | stream_set_timeout($fp, $timeout); 138 | @fwrite($fp, $out); 139 | $status = stream_get_meta_data($fp); 140 | if(!$status['timed_out']) { 141 | while (!feof($fp)) { 142 | if(($header = @fgets($fp)) && ($header == "\r\n" || $header == "\n")) { 143 | break; 144 | } 145 | } 146 | 147 | $stop = false; 148 | while(!feof($fp) && !$stop) { 149 | $data = fread($fp, ($limit == 0 || $limit > 8192 ? 8192 : $limit)); 150 | $return .= $data; 151 | if($limit) { 152 | $limit -= strlen($data); 153 | $stop = $limit <= 0; 154 | } 155 | } 156 | } 157 | @fclose($fp); 158 | return $return; 159 | } 160 | } 161 | 162 | } 163 | 164 | function weatherAPI($Location_X,$Location_Y){ 165 | $map_api_url='http://api.map.baidu.com/geocoder?coord_type=wgs84&location='.$Location_X.','.$Location_Y; 166 | $output=file_get_contents($map_api_url); 167 | $mapxml=simplexml_load_string($output); 168 | $province=str_replace('省','',$mapxml->result->addressComponent->province); 169 | $city=str_replace(array('市','县','区'),array('','',''),$mapxml->result->addressComponent->city); 170 | 171 | if(file_exists('CityID.xml')){ 172 | $wxml=simplexml_load_file('CityID.xml'); 173 | for ($i=0; $i < 34; $i++) { 174 | if($province==$wxml->Province[$i][Name]){ 175 | for ($j=0; $j < count($wxml->Province[$i]->City); $j++) { 176 | if ($city==$wxml->Province[$i]->City[$j][Name]) { 177 | $cityID=$wxml->Province[$i]->City[$j][ID]; 178 | } 179 | } 180 | } 181 | } 182 | } 183 | else{} 184 | 185 | $weather_api_url='http://m.weather.com.cn/data/'.$cityID.'.html'; 186 | $weather=file_get_contents($weather_api_url); 187 | $wea=json_decode($weather,1); 188 | 189 | $weaData=$wea['weatherinfo']['city']."\n"; 190 | $weaData.='发布日期:'.$wea['weatherinfo']['date_y'].' '.$wea['weatherinfo']['week']."\n"; 191 | $weaData.='今日气温:'.$wea['weatherinfo']['temp1'].'/'.$wea['weatherinfo']['tempF1']."\n"; 192 | $weaData.='天气:'.$wea['weatherinfo']['weather1']."\n"; 193 | $weaData.='状态:'.$wea['weatherinfo']['index']."\n"; 194 | $weaData.='建议:'.$wea['weatherinfo']['index_d']."\n"; 195 | $weaData.='风向风力:'.$wea['weatherinfo']['wind1']."\n"; 196 | $weaData.='紫外线:'.$wea['weatherinfo']['index_uv']."\n"; 197 | $weaData.='洗车指数:'.$wea['weatherinfo']['index_xc']."\n"; 198 | $weaData.='旅游指数:'.$wea['weatherinfo']['index_tr']."\n"; 199 | $weaData.='舒适指数:'.$wea['weatherinfo']['index_co']."\n"; 200 | $weaData.='晨练指数:'.$wea['weatherinfo']['index_cl']."\n"; 201 | $weaData.='晾晒指数:'.$wea['weatherinfo']['index_ls']."\n"; 202 | $weaData.='感冒指数:'.$wea['weatherinfo']['index_ag']."\n"; 203 | $weaData.="\n".'未来几天天气'."\n"; 204 | $weaData.='明日:'.$wea['weatherinfo']['temp2'].'/'.$wea['weatherinfo']['tempF2']."\n"; 205 | $weaData.=$wea['weatherinfo']['weather2']."\n"; 206 | $weaData.=$wea['weatherinfo']['wind2']."\n"; 207 | $weaData.='第三日:'.$wea['weatherinfo']['temp3'].'/'.$wea['weatherinfo']['tempF3']."\n"; 208 | $weaData.=$wea['weatherinfo']['weather3']."\n"; 209 | $weaData.=$wea['weatherinfo']['wind3']."\n"; 210 | $weaData.='第四日:'.$wea['weatherinfo']['temp4'].'/'.$wea['weatherinfo']['tempF4']."\n"; 211 | $weaData.=$wea['weatherinfo']['weather4']."\n"; 212 | $weaData.=$wea['weatherinfo']['wind4']."\n"; 213 | $weaData.='第五日:'.$wea['weatherinfo']['temp5'].'/'.$wea['weatherinfo']['tempF5']."\n"; 214 | $weaData.=$wea['weatherinfo']['weather5']."\n"; 215 | $weaData.=$wea['weatherinfo']['wind5']."\n"; 216 | $weaData.='第六日:'.$wea['weatherinfo']['temp6'].'/'.$wea['weatherinfo']['tempF6']."\n"; 217 | $weaData.=$wea['weatherinfo']['weather6']."\n"; 218 | $weaData.=$wea['weatherinfo']['wind6']."\n"; 219 | 220 | return $weaData; 221 | } 222 | 223 | function translateAPI($words){ 224 | $data=$words."\n"; 225 | $words=urlencode($words); 226 | 227 | $fanyi_api_url='http://fanyi.youdao.com/openapi.do?keyfrom=urinxs&key=836837635&type=data&doctype=json&version=1.1&q='; 228 | $transjson=file_get_contents($fanyi_api_url.$words); 229 | $translated=json_decode($transjson,1); 230 | $errorcode=$translated['errorCode']; 231 | 232 | if (isset($errorcode)) { 233 | switch ($errorcode) { 234 | case 0: 235 | $data.='翻译:'.$translated['translation'][0]."\n"; 236 | $data.='基本词典:'."\n"; 237 | $data.='读音:['.$translated['basic']['phonetic'].']'."\n"; 238 | 239 | foreach ($translated['basic']['explains'] as $value) { 240 | $explains.=$value."\n"; 241 | } 242 | $data.='解释:'."\n".$explains."\n";// 243 | 244 | $data.='网络释义:'."\n"; 245 | foreach ($translated['web'] as $arr1) { 246 | $webdata.=$arr1['key']."\n"; 247 | foreach ($arr1['value'] as $value) { 248 | $webdata.=$value.' '; 249 | } 250 | $webdata.="\n"; 251 | } 252 | $data.=$webdata; 253 | break; 254 | 255 | case 20: 256 | $data='要翻译的文本过长'; 257 | break; 258 | 259 | case 30: 260 | $data='无法进行有效的翻译'; 261 | break; 262 | 263 | case 40: 264 | $data='不支持的语言类型'; 265 | break; 266 | 267 | case 50: 268 | $data='无效的key'; 269 | break; 270 | 271 | default: 272 | $data='出现异常'; 273 | break; 274 | } 275 | } 276 | return $data; 277 | } 278 | 279 | function en_sentenceAPI(){ 280 | $en_api_url='http://dict.hjenglish.com/rss/daily/en'; 281 | $en_output=file_get_contents($en_api_url); 282 | $enxml=simplexml_load_string($en_output); 283 | 284 | $en_sentence=$enxml->channel->item->en_sentence."\n"; 285 | $en_sentence.=$enxml->channel->item->cn_sentence."\n"; 286 | $en_sentence.='Update time:'.$enxml->channel->pubDate."\n"; 287 | $en_sentence.='朗读'; 288 | return $en_sentence; 289 | } 290 | 291 | function simsimi($word){ 292 | $key='f615a561-6579-4ce8-a2df-b5b8d9093282'; 293 | $simsimi_api_url='http://sandbox.api.simsimi.com/request.p?key='.$key.'&lc=ch&ft=0.0&text='.$word; 294 | $simjson=file_get_contents($simsimi_api_url); 295 | $simsimi=json_decode($simjson,1); 296 | 297 | if($simsimi['result']=='100') { 298 | $backws=$simsimi['response']; 299 | } 300 | elseif ($simsimi['result']=='400') { 301 | $backws='400-'.$simsimi['msg']; 302 | } 303 | elseif ($simsimi['result']=='401') { 304 | $backws='401-'.$simsimi['msg']."\n".'看来小u的Trial-key到期了,快提醒我吧。'; 305 | } 306 | elseif ($simsimi['result']=='404') { 307 | if(preg_match('/。。/i', $word)) { 308 | $backws='(*^__^*) 嘻嘻……'.'/:B-)'; 309 | } 310 | else{$backws='404-'.$simsimi['msg']."\n".'这也能遇上404!!'.'/::|';} 311 | } 312 | elseif ($simsimi['result']=='500') { 313 | $backws='500-'.$simsimi['msg']."\n".'服务器出问题,小u表示无能为力。'; 314 | } 315 | else{ 316 | $backws='小u还不会回答这个问题的说...'; 317 | } 318 | $backws=str_replace(array('贱鸡','小黄鸡','黄鸡','xhjchat'), array('小u','小u','小u','urinx'), $backws); 319 | if(preg_match('/微信/i',$backws)) { 320 | $backws='该消息被防火长城,不对。。是被小u消音了,原因你懂的。。保护你的身体,有爱你的健康'.'/:B-)'; 321 | $backws.="\n如果你发现有害身心健康的信息,请及时截图报告小u,小u全力进行封杀。"; 322 | } 323 | return $backws; 324 | } 325 | 326 | function bing($query,$type){ 327 | $accountKey='T7m/69vghK1gjxMTPkGqX5Lfz9fn50YXTc7S6ykGTdY'; 328 | 329 | $ServiceRootURL='https://api.datamarket.azure.com/Bing/Search/'; 330 | $WebSearchURL=$ServiceRootURL.$type.'?$format=json&Query='; 331 | $context=stream_context_create( 332 | array( 333 | 'http' => array( 334 | 'request_fulluri' => true, 335 | 'header' => "Authorization: Basic ".base64_encode($accountKey.":".$accountKey) 336 | ) 337 | )); 338 | $request=$WebSearchURL.urlencode('\''.$query.'\''); 339 | 340 | $response=file_get_contents($request, 0, $context); 341 | $jsonobj=json_decode($response); 342 | 343 | $arr=array(); 344 | if ($type=='Image') { 345 | foreach($jsonobj->d->results as $value){ 346 | array_push($arr, $value->Thumbnail->MediaUrl); 347 | } 348 | } 349 | elseif($type=='Web'){ 350 | foreach($jsonobj->d->results as $value){ 351 | array_push($arr, array('title'=>$value->Title,'description'=>$value->Description,'url'=>$value->Url)); 352 | } 353 | } 354 | return $arr; 355 | } 356 | 357 | function wiki($srsearch,$lng){ 358 | if (ctype_alnum($srsearch)) { 359 | $lng='en'; 360 | } 361 | else{ 362 | $lng='zh'; 363 | $srsearch=urlencode($srsearch); 364 | } 365 | $wiki_api_url='http://'.$lng.'.wikipedia.org/w/api.php?action=query&list=search&srwhat=text&format=xml&srsearch='.$srsearch; 366 | $result=file_get_contents($wiki_api_url); 367 | $xmldata=simplexml_load_string($result); 368 | 369 | $arr=array(); 370 | foreach ($xmldata->query->search->p as $value) { 371 | $value['snippet']=str_replace(array('','','','',' '), '', $value['snippet']); 372 | array_push($arr,array('title'=>$value['title'],'snippet'=>$value['snippet'])); 373 | } 374 | return $arr; 375 | } 376 | 377 | function jokes(){ 378 | $jokes_api_url='http://www.djdkx.com/open/randxml'; 379 | $result=file_get_contents($jokes_api_url); 380 | $xmldata=simplexml_load_string($result,'SimpleXMLElement',LIBXML_NOCDATA); 381 | $xmldata->content=str_replace(array(' ','
'), '', trim($xmldata->content)); 382 | return $xmldata->content; 383 | } 384 | 385 | function baiduNews(){ 386 | $word='最新'; 387 | $num=5; 388 | $baidunews_api_url='http://news.baidu.com/ns?tn=newsfcu&from=news&cl=2&ct=0&rn='.$num.'&word='.$word; 389 | $result=file_get_contents($baidunews_api_url); 390 | $reg='#[^\s>]+)"[^>]*target="_blank">(?[^>]+)</a> <span>(?<resrc>[^>]+)</span>#i'; 391 | preg_match_all($reg, $result, $matches); 392 | $matches[resrc]=str_replace(' ',' ',$matches[resrc]); 393 | for ($i=0; $i < 5; $i++) { 394 | $matches[title][$i]=iconv('gbk','utf-8',$matches[title][$i]); 395 | $matches[resrc][$i]=iconv('gbk','utf-8',$matches[resrc][$i]); 396 | } 397 | return $matches; 398 | } 399 | 400 | function doubanMovies($word){ 401 | $list=array('top10'=>'top250','北美票房榜'=>'us_box'); 402 | $doubanMovie_api_url='http://api.douban.com/v2/movie/'; 403 | if (!isset($list[$word])) { 404 | $result=file_get_contents($doubanMovie_api_url.'search?q='.$word); 405 | } 406 | else{ 407 | $result=file_get_contents($doubanMovie_api_url.$list[$word]); 408 | } 409 | $jsondata=json_decode($result); 410 | $movie=array(); 411 | foreach ($jsondata->subjects as $value) { 412 | if ($list[$word]=='us_box') { 413 | $value=$value->subject; 414 | } 415 | array_push($movie, array('average'=>$value->rating->average,'title'=>$value->title,'original_title'=>$value->original_title,'year'=>$value->year,'images'=>$value->images,'alt'=>$value->alt,'id'=>$value->id)); 416 | } 417 | return $movie; 418 | } 419 | 420 | function doubanMovie($id){ 421 | $doubanMovie_api_url='http://api.douban.com/v2/movie/subject/'; 422 | $result=file_get_contents($doubanMovie_api_url.$id); 423 | $jsondata=json_decode($result); 424 | $movie=array('average'=>$jsondata->rating->average,'year'=>$jsondata->year,'images'=>$jsondata->images->large,'mobile_url'=>$jsondata->mobile_url,'title'=>$jsondata->title,'genres'=>$jsondata->genres,'countries'=>$jsondata->countries,'summary'=>$jsondata->summary,'aka'=>$jsondata->aka,'directors'=>$jsondata->directors,'casts'=>$jsondata->casts); 425 | return $movie; 426 | } 427 | 428 | function doubanBooks($word){ 429 | $doubanBook_api_url='https://api.douban.com/v2/book/search?count=5&q='; 430 | $result=file_get_contents($doubanBook_api_url.$word); 431 | $jsondata=json_decode($result); 432 | $book=array(); 433 | foreach ($jsondata->books as $value) { 434 | array_push($book, array('average'=>$value->rating->average,'author'=>$value->author,'pubdate'=>$value->pubdate,'images'=>$value->images,'alt'=>$value->alt,'title'=>$value->title,'publisher'=>$value->publisher,'summary'=>$value->summary,'price'=>$value->price,'tags'=>$value->tags,'id'=>$value->id)); 435 | } 436 | return $book; 437 | } 438 | 439 | function doubanBook($id){ 440 | $doubanBook_api_url='https://api.douban.com/v2/book/'; 441 | $result=file_get_contents($doubanBook_api_url.$id); 442 | $jsondata=json_decode($result); 443 | $book=array('average'=>$jsondata->rating->average,'author'=>$jsondata->author,'pubdate'=>$jsondata->pubdate,'images'=>$jsondata->images->large,'alt'=>$jsondata->alt,'title'=>$jsondata->title,'publisher'=>$jsondata->publisher,'summary'=>$jsondata->summary,'price'=>$jsondata->price,'tags'=>$jsondata->tags); 444 | return $book; 445 | } 446 | 447 | function doubanMusics($word){ 448 | $doubanMusic_api_url='https://api.douban.com/v2/music/search?count=5&q='; 449 | $result=file_get_contents($doubanMusic_api_url.$word); 450 | $jsondata=json_decode($result); 451 | $music=array(); 452 | foreach ($jsondata->musics as $value) { 453 | array_push($music, array('average'=>$value->rating->average,'author'=>$value->author,'pubdate'=>$value->attrs->pubdate,'image'=>$value->image,'alt'=>$value->alt,'title'=>$value->title,'publisher'=>$value->attrs->publisher,'singer'=>$value->attrs->singer,'version'=>$value->attrs->version,'id'=>$value->id)); 454 | } 455 | return $music; 456 | } 457 | 458 | function doubanMusic($id){ 459 | $doubanMusic_api_url='https://api.douban.com/v2/music/'; 460 | $result=file_get_contents($doubanMusic_api_url.$id); 461 | $jsondata=json_decode($result); 462 | $music=array('average'=>$jsondata->rating->average,'author'=>$jsondata->author,'summary'=>$jsondata->summary,'image'=>$jsondata->image,'mobile_link'=>$jsondata->mobile_link,'title'=>$jsondata->title,'id'=>$jsondata->id,'publisher'=>$jsondata->attrs->publisher,'singer'=>$jsondata->attrs->singer,'version'=>$jsondata->attrs->version,'pubdate'=>$jsondata->attrs->pubdate,'tags'=>$jsondata->tags); 463 | return $music; 464 | } 465 | 466 | function dream($word){ 467 | $dream_api_url='http://api2.sinaapp.com/search/dream/?appkey=2989441965&appsecert=4e5e32eb22617e691165e16d6a152a18&reqtype=text&keyword='.urlencode($word); 468 | $result=file_get_contents($dream_api_url); 469 | $dream=json_decode($result); 470 | return $dream->text->content; 471 | } 472 | 473 | function phoneNumber($num){ 474 | $phoneNum_api_url='http://cz.115.com/?ct=index&ac=get_mobile_local&mobile='.$num; 475 | $result=str_replace(array('(',')'), '', file_get_contents($phoneNum_api_url)); 476 | $phone=json_decode($result); 477 | $phoneNum=array('province'=>$phone->province,'city'=>$phone->city,'corp'=>$phone->corp); 478 | return $phoneNum; 479 | } 480 | 481 | function lotterySearch($word){ 482 | $lottery_api_url='http://api2.sinaapp.com/search/lottery/?appkey=2989441965&appsecert=4e5e32eb22617e691165e16d6a152a18&reqtype=text&keyword='.urlencode($word); 483 | $result=file_get_contents($lottery_api_url); 484 | $lottery=json_decode($result); 485 | return $lottery->text->content; 486 | } 487 | function lottery(){ 488 | $lotteryArray=array('双色球','七乐彩','大乐透','七星彩','排列3','排列5','胜负彩','六场半全场'); 489 | foreach ($lotteryArray as $value) { 490 | $lottery.=lotterySearch($value)."\n"; 491 | } 492 | return $lottery; 493 | } 494 | 495 | function picRec($url){ 496 | $picRec_api_url='http://api2.sinaapp.com/recognize/picture/?appkey=2989441965&appsecert=4e5e32eb22617e691165e16d6a152a18&reqtype=text&keyword='.$url; 497 | $result=file_get_contents($picRec_api_url); 498 | $pic=json_decode($result); 499 | return $pic->text->content; 500 | } 501 | ?> -------------------------------------------------------------------------------- /2.0-SAE/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Urinx/weChat_php/7fa1b48b8e1bc3eb676acaab6eda1775af705590/2.0-SAE/.DS_Store -------------------------------------------------------------------------------- /2.0-SAE/api/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Urinx/weChat_php/7fa1b48b8e1bc3eb676acaab6eda1775af705590/2.0-SAE/api/.DS_Store -------------------------------------------------------------------------------- /2.0-SAE/api/0x50sec.php: -------------------------------------------------------------------------------- 1 | <?php 2 | header('Content-type:text/html;charset=utf-8'); 3 | function sec0x50(){ 4 | $data=array(); 5 | $url='http://www.0x50sec.org/feed/'; 6 | $result=file_get_contents($url); 7 | $xml=simplexml_load_string($result,'SimpleXMLElement', LIBXML_NOCDATA); 8 | 9 | for ($i=0; $i < 6; $i++) { 10 | array_push($data,array('title'=>$xml->channel->item[$i]->title,'description'=>$xml->channel->item[$i]->description,'link'=>$xml->channel->item[$i]->link)); 11 | } 12 | 13 | return $data; 14 | } 15 | 16 | print_r(sec0x50()); 17 | 18 | ?> -------------------------------------------------------------------------------- /2.0-SAE/api/91ri.php: -------------------------------------------------------------------------------- 1 | <?php 2 | header('Content-type:text/html;charset=utf-8'); 3 | function ri91(){ 4 | $data=array(); 5 | $url='http://www.91ri.org/feed'; 6 | $result=file_get_contents($url); 7 | $xml=simplexml_load_string($result,'SimpleXMLElement', LIBXML_NOCDATA); 8 | 9 | for ($i=0; $i < 6; $i++) { 10 | array_push($data,array('title'=>$xml->channel->item[$i]->title,'description'=>$xml->channel->item[$i]->description,'link'=>$xml->channel->item[$i]->link)); 11 | } 12 | 13 | return $data; 14 | } 15 | 16 | print_r(ri91()); 17 | 18 | ?> -------------------------------------------------------------------------------- /2.0-SAE/api/bilibili.php: -------------------------------------------------------------------------------- 1 | <?php 2 | header('Content-type:text/html;charset=utf-8'); 3 | function bilibili(){ 4 | $data=array(); 5 | $category=array('1'=>'动画','3'=>'音乐','4'=>'游戏','5'=>'娱乐','11'=>'专辑','13'=>'新番连载'); 6 | foreach ($category as $key=>$value){ 7 | $url='http://www.bilibili.tv/rss-'.$key.'.xml'; 8 | $result=file_get_contents($url); 9 | $xml=simplexml_load_string($result,'SimpleXMLElement', LIBXML_NOCDATA); 10 | array_push($data,array('title'=>$xml->channel->item->title[0],'description'=>$xml->channel->item->description[0],'category'=>$value,'link'=>$xml->channel->item->link[0])); 11 | } 12 | return $data; 13 | } 14 | 15 | print_r(bilibili()); 16 | 17 | ?> 18 | -------------------------------------------------------------------------------- /2.0-SAE/api/book.php: -------------------------------------------------------------------------------- 1 | <?php 2 | header('Content-type:text/html;charset=utf-8'); 3 | function bookrank(){ 4 | $data=array(); 5 | $url='http://rss.sina.com.cn/book/history_rank.xml'; 6 | $result=file_get_contents($url); 7 | $xml=simplexml_load_string($result,'SimpleXMLElement', LIBXML_NOCDATA); 8 | 9 | for ($i=0; $i < 6; $i++) { 10 | array_push($data,array('title'=>$xml->channel->item[$i]->title,'description'=>$xml->channel->item[$i]->description,'link'=>$xml->channel->item[$i]->link)); 11 | } 12 | 13 | return $data; 14 | } 15 | 16 | print_r(bookrank()); 17 | 18 | ?> -------------------------------------------------------------------------------- /2.0-SAE/api/fileIO.php: -------------------------------------------------------------------------------- 1 | <?php 2 | $s = new SaeStorage(); 3 | #$s->upload( 'example' , 'remote_file.txt' , 'local_file.txt' ); 4 | 5 | #echo $s->read( 'example' , 'thebook') ; 6 | // will echo 'bookcontent!'; 7 | 8 | #echo $s->getUrl( 'example' , 'thebook' ); 9 | // will echo 'http://appname-example.stor.sinaapp.com/thebook'; 10 | //$s->write('simsimi','simi.txt','f306b663-b937-47e3-a4a8-415c7ca87a52'); 11 | echo $s->read('simsimi','simi.txt'); 12 | ?> 13 | -------------------------------------------------------------------------------- /2.0-SAE/api/freebuf.php: -------------------------------------------------------------------------------- 1 | <?php 2 | header('Content-type:text/html;charset=utf-8'); 3 | function freebuf(){ 4 | $data=array(); 5 | $url='http://www.freebuf.com/feed'; 6 | $result=file_get_contents($url); 7 | $xml=simplexml_load_string($result,'SimpleXMLElement', LIBXML_NOCDATA); 8 | 9 | for ($i=0; $i < 6; $i++) { 10 | array_push($data,array('title'=>$xml->channel->item[$i]->title,'description'=>htmlspecialchars_decode($xml->channel->item[$i]->description),'link'=>$xml->channel->item[$i]->link)); 11 | } 12 | 13 | return $data; 14 | } 15 | 16 | print_r(freebuf()); 17 | 18 | ?> -------------------------------------------------------------------------------- /2.0-SAE/api/ghoststory.php: -------------------------------------------------------------------------------- 1 | <?php 2 | header('Content-type:text/html;charset=utf-8'); 3 | $ghost=array('短篇鬼故事'=>1,'长篇鬼故事'=>2,'校园鬼故事'=>3,'医院鬼故事'=>4,'家里鬼故事'=>5, 4 | '民间鬼故事'=>6,'灵异事件'=>7,'听鬼故事'=>10,'中国灵异'=>25,'灵异知识库'=>26,'推理小说'=>46); 5 | 6 | function ghost_story($w='灵异知识库'){ 7 | global $ghost; 8 | $data=array(); 9 | $url='http://www.gui44.com/data/rss/'.$ghost[$w].'.xml'; 10 | $xml=simplexml_load_file($url,'SimpleXMLElement',LIBXML_NOCDATA); 11 | 12 | if($xml){ 13 | for ($i=0; $i < 6; $i++) { 14 | $j=$xml->channel->item[$i]; 15 | array_push($data,array('title'=>$j->title,'description'=>$j->description,'link'=>$j->link,'pubDate'=>$j->pubDate,'author'=>$j->author)); 16 | } 17 | } 18 | else{ 19 | $result=file_get_contents($url); 20 | $result=iconv('gb2312','gbk',$result); 21 | $result=iconv('gbk','utf-8',$result); 22 | preg_match_all( "/\<item\>(.*?)\<\/item\>/s",$result,$items); 23 | for ($i=0; $i < 6; $i++){ 24 | preg_match_all( "/\<title\>\<\!\[CDATA\[(.*?)\]\]\>\<\/title\>/",$items[0][$i],$title); 25 | $title=$title[1][0]; 26 | preg_match_all( "/\<description\>\<\!\[CDATA\[(.*?)\]\]\>\<\/description\>/",$items[0][$i],$description); 27 | $description=$description[1][0]; 28 | preg_match_all( "/\<link\>(.*?)\<\/link\>/",$items[0][$i],$link); 29 | $link=$link[1][0]; 30 | preg_match_all( "/\<pubDate\>(.*?)\<\/pubDate\>/",$items[0][$i],$pubDate); 31 | $pubDate=$pubDate[1][0]; 32 | preg_match_all( "/\<author\>(.*?)\<\/author\>/",$items[0][$i],$author); 33 | $author=$author[1][0]; 34 | array_push($data,array('title'=>$title,'description'=>$description,'link'=>$link,'pubDate'=>$pubDate,'author'=>$author)); 35 | } 36 | } 37 | 38 | return $data; 39 | } 40 | 41 | function zhangzhen($i){ 42 | $xml=simplexml_load_file('http://www.gui44.com/data/rss/10.xml','SimpleXMLElement',LIBXML_NOCDATA); 43 | preg_match_all('#flashvars="son=(.*?)&autoplay=1&autoreplay=0"#s',file_get_contents($xml->channel->item[$i]->link),$u); 44 | $title=str_replace(array('张震讲鬼故事系列之','张震讲鬼故事系列','张震鬼故事之','张震讲鬼故事'), '',$xml->channel->item[$i]->title); 45 | return array('title'=>$title,'description'=>'张震','musicurl'=>$u[1][0],'HQmusicurl'=>$u[1][0]); 46 | } 47 | 48 | //print_r(ghost_story()); 49 | print_r(zhangzhen((int)'0')); 50 | 51 | ?> -------------------------------------------------------------------------------- /2.0-SAE/api/ghoststory_read.php: -------------------------------------------------------------------------------- 1 | <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no,target-densitydpi=high-dpi"> 2 | <link rel="stylesheet" media="screen and (orientation:portrait) and (min-width:960px)"> 3 | 4 | <style type="text/css"> 5 | body{ 6 | background: black; 7 | color: white; 8 | font-size: 1.8em; 9 | font-weight: bolder; 10 | } 11 | a{ 12 | color: gray; 13 | } 14 | </style> 15 | <?php 16 | header('Content-type:text/html;charset=utf-8'); 17 | $res=file_get_contents($_GET['url']); 18 | $res=iconv('gb2312','utf-8',$res); 19 | //$res=preg_replace('#<div class=\'\w\w\w\d\d\d\'>.*?</div>#s','',$res); 20 | preg_match_all( '#<div class="arzw">(.*?)</div>\s*<div#s',$res,$arzw); 21 | preg_match_all( '/共(\d)页:/s',$arzw[1][0],$n); 22 | 23 | $del=array('#<script.*?></script>#s','#<div class="jogger">.+#s','#dedecms.com#s','#织梦好,好织梦#s','#本文来自织梦#s','#copyright dedecms#s','#内容来自dedecms#s','#织梦内容管理系统#s'); 24 | $article=preg_replace($del,'',$arzw[1][0]); 25 | $article=preg_replace('<div class="arwzks">','hr',$article); 26 | 27 | echo $article; 28 | echo '<hr>'; 29 | 30 | if(isset($n[1][0])){ 31 | preg_match_all( '#(.*?)(\d+)\.html#s',$_GET['url'],$m); 32 | if ((int)$m[2][0]<(int)$n[1][0]) { 33 | $next=$_SERVER['PHP_SELF'].'?url='.$m[1][0].((int)$m[2][0]+1).'.html'; 34 | echo '共'.$n[1][0].'页 <a href="'.$next.'">下一页</a>'; 35 | } 36 | elseif ($m[2][0]==$n[1][0]) { 37 | echo '共'.$n[1][0].'页 完'; 38 | } 39 | else{ 40 | $next=$_SERVER['PHP_SELF'].'?url='.$m[1][0].$m[2][0].'_2.html'; 41 | echo '共'.$n[1][0].'页 <a href="'.$next.'">下一页</a>'; 42 | } 43 | } 44 | else{ 45 | echo '完'; 46 | } 47 | ?> -------------------------------------------------------------------------------- /2.0-SAE/api/ifanr.php: -------------------------------------------------------------------------------- 1 | <?php 2 | header('Content-type:text/html;charset=utf-8'); 3 | function ifanr(){ 4 | $data=array(); 5 | $url='http://www.ifanr.com/feed'; 6 | $result=file_get_contents($url); 7 | $xml=simplexml_load_string($result,'SimpleXMLElement', LIBXML_NOCDATA); 8 | 9 | for ($i=0; $i < 6; $i++) { 10 | $reg='#(.+)题图来自#i'; 11 | preg_match_all($reg, $xml->channel->item[$i]->description, $matches); 12 | array_push($data,array('title'=>$xml->channel->item[$i]->title,'description'=>$matches[1],'cover'=>$xml->channel->item[$i]->image,'link'=>$xml->channel->item[$i]->link)); 13 | } 14 | 15 | return $data; 16 | } 17 | 18 | print_r(ifanr()); 19 | 20 | ?> -------------------------------------------------------------------------------- /2.0-SAE/api/matrix67.php: -------------------------------------------------------------------------------- 1 | <?php 2 | header('Content-type:text/html;charset=utf-8'); 3 | function matrix67(){ 4 | $data=array(); 5 | $url='http://www.matrix67.com/blog/feed'; 6 | $result=file_get_contents($url); 7 | $xml=simplexml_load_string($result,'SimpleXMLElement', LIBXML_NOCDATA); 8 | 9 | for ($i=0; $i < 6; $i++) { 10 | array_push($data,array('title'=>$xml->channel->item[$i]->title,'description'=>str_replace(' ','',$xml->channel->item[$i]->description),'link'=>$xml->channel->item[$i]->link)); 11 | } 12 | 13 | return $data; 14 | } 15 | 16 | print_r(matrix67()); 17 | 18 | ?> -------------------------------------------------------------------------------- /2.0-SAE/api/mysql.php: -------------------------------------------------------------------------------- 1 | <?php 2 | header('Content-type:text/html;charset=utf-8'); 3 | function UriSql($a,$arr=null){ 4 | $mysql=new SaeMysql(); 5 | if($a=='s'){ 6 | $sql="SELECT * FROM moments ORDER BY ID DESC LIMIT 5"; 7 | $data=$mysql->getData($sql); 8 | return $data; 9 | } 10 | elseif($a=='i'){ 11 | $sql="INSERT INTO info(FromUserName,alias) VALUES ('23123','dgsdfr')"; 12 | $mysql->runSql($sql); 13 | } 14 | elseif($mysql->errno()!=0){ 15 | die("Error:".$mysql->errmsg()); 16 | } 17 | $mysql->closeDb(); 18 | } 19 | 20 | ////////////// 21 | #define(‘DB_HOST’,$_SERVER['HTTP_MYSQLPORT'].’.mysql.sae.sina.com.cn:’.$_SERVER['HTTP_MYSQLPORT']); 22 | #$query=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD); 23 | 24 | $mysql=new SaeMysql(); 25 | 26 | #$sql="SELECT * FROM `sharelinks` ORDER BY `ID` DESC LIMIT 4"; 27 | #$data=$mysql->getData($sql); 28 | #print_r($data); 29 | #$title='dudulu'; 30 | #$url='www'; 31 | #$sql="INSERT INTO `sharelinks` (`title`,`time`,`url`) VALUES ('".$title."',NOW(),'".$url."')"; 32 | #$mysql->runSql($sql); 33 | if($mysql->errno()!=0){ 34 | die("Error:".$mysql->errmsg()); 35 | } 36 | $mysql->closeDb(); 37 | ?> 38 | -------------------------------------------------------------------------------- /2.0-SAE/api/nginx.php: -------------------------------------------------------------------------------- 1 | <?php 2 | header('Content-type:text/html;charset=utf-8'); 3 | function nginx(){ 4 | $data=array(); 5 | $url='http://www.nginx.cn/feed'; 6 | $result=file_get_contents($url); 7 | $xml=simplexml_load_string($result,'SimpleXMLElement', LIBXML_NOCDATA); 8 | 9 | for ($i=0; $i < 6; $i++) { 10 | array_push($data,array('title'=>$xml->channel->item[$i]->title,'description'=>$xml->channel->item[$i]->description,'link'=>$xml->channel->item[$i]->link)); 11 | } 12 | 13 | return $data; 14 | } 15 | 16 | print_r(nginx()); 17 | 18 | ?> -------------------------------------------------------------------------------- /2.0-SAE/api/reddit.php: -------------------------------------------------------------------------------- 1 | <?php 2 | function reddit(){ 3 | $num=5; 4 | $stack_url='http://www.reddit.com/'; 5 | $result=file_get_contents($stack_url); 6 | 7 | $mainreg='#<a[\s]+class="title[\s]*"[\s]+href="(\S+)" tabindex="1" [A-Za-z""=\s]*>[A-Za-z\s]+</a>#i'; 8 | $title='#>[A-Za-z\s]+</a>#i'; 9 | $votereg='#<div class="score unvoted">(\d+)</div>#i'; 10 | $imgreg='#<img[\s]+src="(http://[a-z].thumbs.redditmedia.com/\S+)"[\s]+width=\'\d+\'[\s]+height=\'\d+\'[\s]+alt=""/>#i'; 11 | //$imgreg='#http://[a-z].thumbs.redditmedia.com/(\S+)#i'; 12 | $viewreg='#<div class="mini-counts">(\d+)</div>[\s]+<div>view[s]*</div>#i'; 13 | /* 14 | $arr=array($mainreg,$votereg,$answerreg,$viewreg); 15 | $res=array(); 16 | $data=array(); 17 | 18 | foreach ($arr as $reg){ 19 | preg_match_all($reg, $result, $matches); 20 | array_push($res,$matches[1]); 21 | } 22 | 23 | for ($i=0; $i < 5; $i++) { 24 | list($id,$title)=preg_split('#/#',$res[0][$i]); 25 | array_push($data,array('id'=>$id,'title'=>$title,'vote'=>$res[1][$i],'answer'=>$res[2][$i],'view'=>$res[3][$i])); 26 | } 27 | return $data;*/ 28 | preg_match_all($mainreg, $result, $matches); 29 | return $matches; 30 | } 31 | 32 | print_r(reddit()); 33 | 34 | ?> 35 | -------------------------------------------------------------------------------- /2.0-SAE/api/saelocation.php: -------------------------------------------------------------------------------- 1 | <?php 2 | header('Content-type:text/html;charset=utf-8'); 3 | 4 | $SaeLocationObj = new SaeLocation(); 5 | 6 | /* 7 | //根据起点与终点数据查询自驾车路线信息 8 | $drive_route_arr = array('begin_coordinate'=>'116.317245,39.981437','end_coordinate'=>'116.328422,40.077796'); 9 | $drive_route = $SaeLocationObj->getDriveRoute($drive_route_arr); 10 | echo 'drive_rote: '; 11 | print_r($drive_route); 12 | echo '</br>'; 13 | */ 14 | 15 | /* 16 | // 失败时输出错误码和错误信息 17 | if ($bus_route === false) 18 | var_dump($SaeLocationObj->errno(), $SaeLocationObj->errmsg()); 19 | */ 20 | 21 | 22 | /* 23 | 24 | //根据起点与终点数据查询公交乘坐路线信息 25 | $bus_route_arr = array('begin_coordinate'=>'116.317245,39.981437','end_coordinate'=>'116.328422,40.077796'); 26 | $bus_route = $SaeLocationObj->getBusRoute($bus_route_arr); 27 | echo 'bus_rote: '; 28 | print_r($bus_route); 29 | echo '</br>'; 30 | 31 | 32 | // 根据关键词查询公交线路及其站点信息 33 | $bus_line_arr = array('q'=>'320路区间'); 34 | $bus_line = $SaeLocationObj->getBusLine($bus_line_arr); 35 | echo 'bus_line: '; 36 | print_r($bus_line); 37 | echo '</br>'; 38 | 39 | 40 | //根据关键词查询公交线路 41 | $bus_station_arr = array('q'=>'回龙观'); 42 | $bus_station = $SaeLocationObj->getBusStation($bus_station_arr); 43 | echo 'bus_station: '; 44 | print_r($bus_station); 45 | echo '</br>'; 46 | */ 47 | 48 | //根据IP地址返回地理信息坐标 49 | $ip_to_geo_arr = array('ip'=>'202.106.0.20,202.108.5.20'); 50 | $ip_to_geo = $SaeLocationObj->getIpToGeo($ip_to_geo_arr); 51 | echo 'ip_to_geo: '; 52 | print_r($ip_to_geo); 53 | echo '</br>'; 54 | 55 | ?> 56 | -------------------------------------------------------------------------------- /2.0-SAE/api/shejidaren.php: -------------------------------------------------------------------------------- 1 | <?php 2 | header('Content-type:text/html;charset=utf-8'); 3 | function shejidaren(){ 4 | $data=array(); 5 | $url='http://www.shejidaren.com/feed'; 6 | $result=file_get_contents($url); 7 | $xml=simplexml_load_string($result,'SimpleXMLElement', LIBXML_NOCDATA); 8 | 9 | for ($i=0; $i < 6; $i++) { 10 | $reg='#<img src="(http://images\.shejidaren\.com/wp-content/uploads/.+)"[\s]+class#i'; 11 | preg_match_all($reg,$xml->channel->item[$i]->description,$matches); 12 | array_push($data,array('title'=>$xml->channel->item[$i]->title,'cover'=>$matches[1][0],'link'=>$xml->channel->item[$i]->link)); 13 | } 14 | 15 | return $data; 16 | } 17 | 18 | print_r(shejidaren()); 19 | 20 | ?> -------------------------------------------------------------------------------- /2.0-SAE/api/songshuhui.php: -------------------------------------------------------------------------------- 1 | <?php 2 | header('Content-type:text/html;charset=utf-8'); 3 | function songshu(){ 4 | $data=array(); 5 | $url='http://songshuhui.net/feed'; 6 | $result=file_get_contents($url); 7 | $xml=simplexml_load_string($result,'SimpleXMLElement', LIBXML_NOCDATA); 8 | 9 | for ($i=0; $i < 6; $i++) { 10 | array_push($data,array('title'=>$xml->channel->item[$i]->title,'description'=>$xml->channel->item[$i]->description,'link'=>$xml->channel->item[$i]->link)); 11 | } 12 | 13 | return $data; 14 | } 15 | 16 | print_r(songshu()); 17 | 18 | ?> -------------------------------------------------------------------------------- /2.0-SAE/api/stackoverflow.php: -------------------------------------------------------------------------------- 1 | <?php 2 | function stackoverflow(){ 3 | $num=5; 4 | $stack_url='http://stackoverflow.com/'; 5 | $result=file_get_contents($stack_url); 6 | 7 | $mainreg='#<div[\s]+onclick="window.location.href=\'/questions/(\d+/.+)\'"[\s]+class="cp"[\s]*>#i'; 8 | $votereg='#<div class="mini-counts">(\d+)</div>[\s]+<div>votes</div>#i'; 9 | $answerreg='#<div class="mini-counts">(\d+)</div>[\s]+<div>answers</div>#i'; 10 | $viewreg='#<div class="mini-counts">(\d+)</div>[\s]+<div>view[s]*</div>#i'; 11 | 12 | $arr=array($mainreg,$votereg,$answerreg,$viewreg); 13 | $res=array(); 14 | $data=array(); 15 | 16 | foreach ($arr as $reg){ 17 | preg_match_all($reg, $result, $matches); 18 | array_push($res,$matches[1]); 19 | } 20 | 21 | for ($i=0; $i < 5; $i++) { 22 | list($id,$title)=preg_split('#/#',$res[0][$i]); 23 | array_push($data,array('id'=>$id,'title'=>$title,'vote'=>$res[1][$i],'answer'=>$res[2][$i],'view'=>$res[3][$i])); 24 | } 25 | return $data; 26 | } 27 | 28 | function test(){ 29 | return file_get_contents('http://stackoverflow.com/questions/20988299/'); 30 | } 31 | 32 | print_r(stackoverflow()); 33 | 34 | ?> 35 | -------------------------------------------------------------------------------- /2.0-SAE/api/wooyun.php: -------------------------------------------------------------------------------- 1 | <?php 2 | header('Content-type:text/html;charset=utf-8'); 3 | function wooyun(){ 4 | $data=array(); 5 | $url='http://www.wooyun.org/feeds/submit'; 6 | $result=file_get_contents($url); 7 | $xml=simplexml_load_string($result,'SimpleXMLElement', LIBXML_NOCDATA); 8 | 9 | for ($i=0; $i < 6; $i++) { 10 | $reg='#<strong>简要描述:</strong><br/>(.+)<br/><strong>详细说明#i'; 11 | preg_match_all($reg,$xml->channel->item[$i]->description, $matches); 12 | array_push($data,array('title'=>$xml->channel->item[$i]->title,'description'=>'简要描述:'.$matches[1][0],'link'=>$xml->channel->item[$i]->link)); 13 | } 14 | 15 | return $data; 16 | } 17 | 18 | print_r(wooyun()); 19 | 20 | ?> -------------------------------------------------------------------------------- /2.0-SAE/api/xiaodoubi.php: -------------------------------------------------------------------------------- 1 | <?php 2 | function xiaodoubi($words){ 3 | $xiaodoubi_url='http://www.xiaodoubi.com/bot/chat.php'; 4 | $fields_post=array('chat'=>$words, ); 5 | $fields_string=http_build_query($fields_post,'&'); 6 | 7 | $ch=curl_init(); 8 | curl_setopt($ch,CURLOPT_POST,1); 9 | curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); 10 | curl_setopt($ch,CURLOPT_HEADER,0); 11 | curl_setopt($ch,CURLOPT_URL,$xiaodoubi_url); 12 | curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string); 13 | $backws=curl_exec($ch); 14 | curl_close($ch); 15 | 16 | if(preg_match('/微信/i',$backws)) { 17 | $backws='该消息被防火长城,不对。。是被小u消音了,原因你懂的。。保护你的身体,有爱你的健康'.'/:B-)'; 18 | $backws.="\n如果你发现有害身心健康的信息,请及时截图报告小u,小u全力进行封杀。"; 19 | } 20 | 21 | return $backws; 22 | } 23 | 24 | echo xiaodoubi('haha'); 25 | ?> -------------------------------------------------------------------------------- /2.0-SAE/api/yyets.php: -------------------------------------------------------------------------------- 1 | <?php 2 | header('Content-type:text/html;charset=utf-8'); 3 | function yyets(){ 4 | $data=array(); 5 | $url='http://www.yyets.com/rss/feed/'; 6 | $result=file_get_contents($url); 7 | $xml=simplexml_load_string($result,'SimpleXMLElement', LIBXML_NOCDATA); 8 | 9 | for ($i=0; $i < 6; $i++) { 10 | $r=file_get_contents($xml->channel->item[$i]->link); 11 | $reg='#<img[\s]+src="(http://res\.yyets\.com/ftp/.+\.jpg)"[\s]+/>#i'; 12 | preg_match_all($reg, $r, $matches); 13 | 14 | array_push($data,array('title'=>$xml->channel->item[$i]->title,'description'=>$xml->channel->item[$i]->description,'cover'=>$matches[1][0],'link'=>$xml->channel->item[$i]->link)); 15 | } 16 | 17 | return $data; 18 | } 19 | 20 | print_r(yyets()); 21 | 22 | ?> -------------------------------------------------------------------------------- /2.0-SAE/config.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | name: xiaouri 3 | version: 1 4 | ... -------------------------------------------------------------------------------- /2.0-SAE/urinx.sinaapp.com/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Urinx/weChat_php/7fa1b48b8e1bc3eb676acaab6eda1775af705590/2.0-SAE/urinx.sinaapp.com/.DS_Store -------------------------------------------------------------------------------- /2.0-SAE/urinx.sinaapp.com/function.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | import sae 3 | import sae.mail 4 | import os,sys,cgi,urllib,urllib2,httplib,re,time,math,datetime,httplib,zipfile,pwd 5 | 6 | def env(environ): 7 | content='' 8 | for param in os.environ.keys(): 9 | content+=param+':'+os.environ[param]+'\n' 10 | 11 | content+='='*20+'\n' 12 | for i in environ.keys(): 13 | content+=i+':'+str(environ[i])+'\n' 14 | 15 | return content 16 | 17 | def fetchurl(url): 18 | return urllib2.urlopen(url).read() 19 | 20 | def mysqlhelp(): 21 | return "sae.const.MYSQL_DB#数据库名\nsae.const.MYSQL_USER#用户名\nsae.const.MYSQL_PASS#密码\nsae.const.MYSQL_HOST#主库域名(可读写)\nsae.const.MYSQL_PORT#端口,类型为,请根据框架要求自行转换为int\nsae.const.MYSQL_HOST_S#从库域名(只读)" 22 | 23 | def mysqlinfo(): 24 | str='数据库名:'+sae.const.MYSQL_DB+'\n'+'用户名:'+sae.const.MYSQL_USER+'\n'+'密码:'+sae.const.MYSQL_PASS+'\n'+'主库域名:'+sae.const.MYSQL_HOST+'\n'+'端口'+sae.const.MYSQL_PORT+'\n'+'从库域名:'+sae.const.MYSQL_HOST_S 25 | return str 26 | 27 | def mail(to,subject,body): 28 | #sae.mail.send_mail((to,subject,body,("smtp.qq.com", 465, "1336006643@qq.com", pw, False)) 29 | pass 30 | 31 | def gmail(to,subject,body): 32 | sae.mail.send_mail(to,subject,body,('smtp.gmail.com', 587, 'uri.lqy@gmail.com', 'password', True)) 33 | return '发送成功!' 34 | 35 | def fenci(chinese_text): 36 | #chinese_text = '这里填上需要分词的文本' 37 | _SEGMENT_BASE_URL='http://segment.sae.sina.com.cn/urlclient.php' 38 | payload = urllib.urlencode([('context', chinese_text),]) 39 | args = urllib.urlencode([('word_tag', 1), ('encoding', 'UTF-8'),]) 40 | url = _SEGMENT_BASE_URL + '?' + args 41 | result = urllib2.urlopen(url, payload).read() 42 | return result 43 | -------------------------------------------------------------------------------- /2.0-SAE/urinx.sinaapp.com/index.wsgi: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | import sae 3 | import sae.mail 4 | import os,sys,cgi,urllib,urllib2,httplib,re,time,math,datetime,httplib,zipfile,pwd 5 | 6 | from function import * 7 | 8 | def app(environ, start_response): 9 | status = '200 OK' 10 | response_headers = [('Content-type', 'text/plain')] 11 | start_response(status, response_headers) 12 | 13 | shell=environ['PATH_INFO'][1:] 14 | 15 | if shell=='modules': 16 | return ','.join(sys.modules) 17 | 18 | elif shell=='env': 19 | return env(environ) 20 | 21 | elif re.search('http://|www',shell): 22 | return fetchurl(shell) 23 | 24 | elif shell=='mysql -h': 25 | return mysqlhelp() 26 | 27 | elif shell=='mysql -i': 28 | return mysqlinfo() 29 | 30 | #elif shell=='mail': 31 | # mail() 32 | # return 'success' 33 | 34 | #elif shell=='gmail': 35 | # gmail() 36 | # return 'success' 37 | 38 | elif shell=='test': 39 | conn = httplib.HTTPConnection('http://www.baidu.com:80') 40 | httpres = conn.getresponse() 41 | #print httpres.status 42 | #print httpres.reason 43 | #print httpres.read 44 | return httpres.read() 45 | 46 | elif eval(shell): 47 | return str(eval(environ['PATH_INFO'][1:])) 48 | 49 | application = sae.create_wsgi_app(app) 50 | -------------------------------------------------------------------------------- /2.0-SAE/wechat-api.php: -------------------------------------------------------------------------------- 1 | <?php 2 | 3 | class w { 4 | //响应请求 5 | static function response($xml,$data,$type='text') { 6 | $time=time(); 7 | $xmltpl['text']='<xml><ToUserName><![CDATA[%s]]></ToUserName><FromUserName><![CDATA[%s]]></FromUserName>'; 8 | $xmltpl['text'].='<CreateTime>%s</CreateTime><MsgType><![CDATA[text]]></MsgType><Content><![CDATA[%s]]></Content><FuncFlag>0</FuncFlag></xml>'; 9 | $xmltpl['item']='<item><Title><![CDATA[%s]]>'; 10 | $xmltpl['news']='%s'; 11 | $xmltpl['news'].='%s%s1'; 12 | $xmltpl['music']='%s'; 13 | $xmltpl['music'].='<![CDATA[%s]]>'; 14 | $xmltpl['image']='%s1234567890123456'; 15 | 16 | if($type == 'text'){ 17 | return sprintf($xmltpl['text'],$xml->FromUserName,$xml->ToUserName,$time,$data); 18 | } 19 | 20 | elseif($type=='news'){ 21 | if(is_array($data)){ 22 | $items=''; 23 | if(count($data) > 1){ 24 | foreach($data as $e){ 25 | $title=trim($e['title']."\n".$e['note'],"\n"); 26 | $items.=sprintf($xmltpl['item'],$title,'',$e['cover'],$e['link']); 27 | } 28 | } 29 | elseif(count($data) == 1){ 30 | foreach($data as $e){ 31 | $items=sprintf($xmltpl['item'],$e['title'],$e['note'],$e['cover'],$e['link']); 32 | } 33 | } 34 | else{ 35 | return self::response($xml,'没有数据'); 36 | } 37 | return sprintf($xmltpl['news'],$xml->FromUserName,$xml->ToUserName,$time,count($data),$items); 38 | } 39 | return self::response($xml,'没有数据'); 40 | } 41 | 42 | elseif($type == 'music'){ 43 | return sprintf($xmltpl['music'],$xml->FromUserName,$xml->ToUserName,$time,$data['title'],$data['description'],$data['musicurl'],$data['HQmusicurl']); 44 | } 45 | 46 | //这个目前不能用 47 | elseif($type == 'image'){ 48 | return sprintf($xmltpl['image'],$xml->FromUserName,$xml->ToUserName,$time,$data); 49 | } 50 | 51 | return self::response($xml,'主人不在家,如果有什么事的话,你可以直接对[小u]说。'); 52 | } 53 | 54 | /** 55 | **已知两点的经纬度,计算两点间的距离(公里) 56 | **/ 57 | static function getDistance($lat1,$lng1,$lat2,$lng2){ 58 | $lat1=(double)$lat1; 59 | $lat2=(double)$lat2; 60 | $lng1=(double)$lng1; 61 | $lng2=(double)$lng2; 62 | $EARTH_RADIUS=6378.137; 63 | $radLat1=$lat1*pi()/180.0; 64 | $radLat2=$lat2*pi()/180.0; 65 | $a=$radLat1-$radLat2; 66 | $b=$lng1*pi()/180.0-$lng2*pi()/180.0; 67 | $s=2*asin(sqrt(pow(sin($a/2),2)+ 68 | cos($radLat1)*cos($radLat2)*pow(sin($b/2),2))); 69 | $s=$s*$EARTH_RADIUS; 70 | $s=round($s*10000)/10000; 71 | return number_format($s,2,'.',''); 72 | } 73 | 74 | static function requestMethod() { 75 | return $_SERVER['REQUEST_METHOD']; 76 | } 77 | 78 | static function isGET() { 79 | return self::requestMethod() == 'GET'; 80 | } 81 | 82 | static function isPOST() { 83 | return self::requestMethod() == 'POST'; 84 | } 85 | 86 | /** 87 | * POST 请求指定URL 88 | */ 89 | static function fpost($url, $post = '', $limit = 0, $cookie = '', $ip = '', $timeout = 15, $block = TRUE) { 90 | $return=''; 91 | $matches=parse_url($url); 92 | !isset($matches['host']) && $matches['host'] = ''; 93 | !isset($matches['path']) && $matches['path'] = ''; 94 | !isset($matches['query']) && $matches['query'] = ''; 95 | !isset($matches['port']) && $matches['port'] = ''; 96 | $host = $matches['host']; 97 | $path = $matches['path'] ? $matches['path'].($matches['query'] ? '?'.$matches['query'] : '') : '/'; 98 | $port = !empty($matches['port']) ? $matches['port'] : 80; 99 | if($post) { 100 | $out = "POST $path HTTP/1.0\r\n"; 101 | $out .= "Accept: */*\r\n"; 102 | $out .= "Accept-Language: zh-cn\r\n"; 103 | $out .= "Content-Type: application/x-www-form-urlencoded\r\n"; 104 | $out .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n"; 105 | $out .= "Host: $host\r\n"; 106 | $out .= 'Content-Length: '.strlen($post)."\r\n"; 107 | $out .= "Connection: Close\r\n"; 108 | $out .= "Cache-Control: no-cache\r\n"; 109 | $out .= "Cookie: $cookie\r\n\r\n"; 110 | $out .= $post; 111 | } 112 | else { 113 | $out = "GET $path HTTP/1.0\r\n"; 114 | $out .= "Accept: */*\r\n"; 115 | $out .= "Accept-Language: zh-cn\r\n"; 116 | $out .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n"; 117 | $out .= "Host: $host\r\n"; 118 | $out .= "Connection: Close\r\n"; 119 | $out .= "Cookie: $cookie\r\n\r\n"; 120 | } 121 | 122 | if(function_exists('fsockopen')) { 123 | $fp = @fsockopen(($ip ? $ip : $host), $port, $errno, $errstr, $timeout); 124 | } 125 | elseif (function_exists('pfsockopen')) { 126 | $fp = @pfsockopen(($ip ? $ip : $host), $port, $errno, $errstr, $timeout); 127 | } 128 | else { 129 | $fp = false; 130 | } 131 | 132 | if(!$fp) { 133 | return ''; 134 | } 135 | else { 136 | stream_set_blocking($fp, $block); 137 | stream_set_timeout($fp, $timeout); 138 | @fwrite($fp, $out); 139 | $status = stream_get_meta_data($fp); 140 | if(!$status['timed_out']) { 141 | while (!feof($fp)) { 142 | if(($header = @fgets($fp)) && ($header == "\r\n" || $header == "\n")) { 143 | break; 144 | } 145 | } 146 | 147 | $stop = false; 148 | while(!feof($fp) && !$stop) { 149 | $data = fread($fp, ($limit == 0 || $limit > 8192 ? 8192 : $limit)); 150 | $return .= $data; 151 | if($limit) { 152 | $limit -= strlen($data); 153 | $stop = $limit <= 0; 154 | } 155 | } 156 | } 157 | @fclose($fp); 158 | return $return; 159 | } 160 | } 161 | 162 | } 163 | 164 | function weatherAPI($Location_X,$Location_Y){ 165 | $map_api_url='http://api.map.baidu.com/geocoder?coord_type=wgs84&location='.$Location_X.','.$Location_Y; 166 | $output=file_get_contents($map_api_url); 167 | $mapxml=simplexml_load_string($output); 168 | $province=str_replace('省','',$mapxml->result->addressComponent->province); 169 | $city=str_replace(array('市','县','区'),array('','',''),$mapxml->result->addressComponent->city); 170 | 171 | if(file_exists('CityID.xml')){ 172 | $wxml=simplexml_load_file('CityID.xml'); 173 | for ($i=0; $i < 34; $i++) { 174 | if($province==$wxml->Province[$i][Name]){ 175 | for ($j=0; $j < count($wxml->Province[$i]->City); $j++) { 176 | if ($city==$wxml->Province[$i]->City[$j][Name]) { 177 | $cityID=$wxml->Province[$i]->City[$j][ID]; 178 | } 179 | } 180 | } 181 | } 182 | } 183 | else{} 184 | 185 | $weather_api_url='http://m.weather.com.cn/data/'.$cityID.'.html'; 186 | $weather=file_get_contents($weather_api_url); 187 | $wea=json_decode($weather,1); 188 | 189 | $weaData=$wea['weatherinfo']['city']."\n"; 190 | $weaData.='发布日期:'.$wea['weatherinfo']['date_y'].' '.$wea['weatherinfo']['week']."\n"; 191 | $weaData.='今日气温:'.$wea['weatherinfo']['temp1'].'/'.$wea['weatherinfo']['tempF1']."\n"; 192 | $weaData.='天气:'.$wea['weatherinfo']['weather1']."\n"; 193 | $weaData.='状态:'.$wea['weatherinfo']['index']."\n"; 194 | $weaData.='建议:'.$wea['weatherinfo']['index_d']."\n"; 195 | $weaData.='风向风力:'.$wea['weatherinfo']['wind1']."\n"; 196 | $weaData.='紫外线:'.$wea['weatherinfo']['index_uv']."\n"; 197 | $weaData.='洗车指数:'.$wea['weatherinfo']['index_xc']."\n"; 198 | $weaData.='旅游指数:'.$wea['weatherinfo']['index_tr']."\n"; 199 | $weaData.='舒适指数:'.$wea['weatherinfo']['index_co']."\n"; 200 | $weaData.='晨练指数:'.$wea['weatherinfo']['index_cl']."\n"; 201 | $weaData.='晾晒指数:'.$wea['weatherinfo']['index_ls']."\n"; 202 | $weaData.='感冒指数:'.$wea['weatherinfo']['index_ag']."\n"; 203 | $weaData.="\n".'未来几天天气'."\n"; 204 | $weaData.='明日:'.$wea['weatherinfo']['temp2'].'/'.$wea['weatherinfo']['tempF2']."\n"; 205 | $weaData.=$wea['weatherinfo']['weather2']."\n"; 206 | $weaData.=$wea['weatherinfo']['wind2']."\n"; 207 | $weaData.='第三日:'.$wea['weatherinfo']['temp3'].'/'.$wea['weatherinfo']['tempF3']."\n"; 208 | $weaData.=$wea['weatherinfo']['weather3']."\n"; 209 | $weaData.=$wea['weatherinfo']['wind3']."\n"; 210 | $weaData.='第四日:'.$wea['weatherinfo']['temp4'].'/'.$wea['weatherinfo']['tempF4']."\n"; 211 | $weaData.=$wea['weatherinfo']['weather4']."\n"; 212 | $weaData.=$wea['weatherinfo']['wind4']."\n"; 213 | $weaData.='第五日:'.$wea['weatherinfo']['temp5'].'/'.$wea['weatherinfo']['tempF5']."\n"; 214 | $weaData.=$wea['weatherinfo']['weather5']."\n"; 215 | $weaData.=$wea['weatherinfo']['wind5']."\n"; 216 | $weaData.='第六日:'.$wea['weatherinfo']['temp6'].'/'.$wea['weatherinfo']['tempF6']."\n"; 217 | $weaData.=$wea['weatherinfo']['weather6']."\n"; 218 | $weaData.=$wea['weatherinfo']['wind6']."\n"; 219 | 220 | return $weaData; 221 | } 222 | 223 | function translateAPI($words){ 224 | $data=$words."\n"; 225 | $words=urlencode($words); 226 | 227 | $fanyi_api_url='http://fanyi.youdao.com/openapi.do?keyfrom=urinxs&key=836837635&type=data&doctype=json&version=1.1&q='; 228 | $transjson=file_get_contents($fanyi_api_url.$words); 229 | $translated=json_decode($transjson,1); 230 | $errorcode=$translated['errorCode']; 231 | 232 | if (isset($errorcode)) { 233 | switch ($errorcode) { 234 | case 0: 235 | $data.='翻译:'.$translated['translation'][0]."\n"; 236 | $data.='基本词典:'."\n"; 237 | $data.='读音:['.$translated['basic']['phonetic'].']'."\n"; 238 | 239 | foreach ($translated['basic']['explains'] as $value) { 240 | $explains.=$value."\n"; 241 | } 242 | $data.='解释:'."\n".$explains."\n";// 243 | 244 | $data.='网络释义:'."\n"; 245 | foreach ($translated['web'] as $arr1) { 246 | $webdata.=$arr1['key']."\n"; 247 | foreach ($arr1['value'] as $value) { 248 | $webdata.=$value.' '; 249 | } 250 | $webdata.="\n"; 251 | } 252 | $data.=$webdata; 253 | break; 254 | 255 | case 20: 256 | $data='要翻译的文本过长'; 257 | break; 258 | 259 | case 30: 260 | $data='无法进行有效的翻译'; 261 | break; 262 | 263 | case 40: 264 | $data='不支持的语言类型'; 265 | break; 266 | 267 | case 50: 268 | $data='无效的key'; 269 | break; 270 | 271 | default: 272 | $data='出现异常'; 273 | break; 274 | } 275 | } 276 | return $data; 277 | } 278 | 279 | function en_sentenceAPI(){ 280 | $en_api_url='http://dict.hjenglish.com/rss/daily/en'; 281 | $en_output=file_get_contents($en_api_url); 282 | $enxml=simplexml_load_string($en_output); 283 | 284 | $en_sentence=$enxml->channel->item->en_sentence."\n"; 285 | $en_sentence.=$enxml->channel->item->cn_sentence."\n"; 286 | $en_sentence.='Update time:'.$enxml->channel->pubDate."\n"; 287 | $en_sentence.='朗读'; 288 | return $en_sentence; 289 | } 290 | 291 | function simsimi($word){ 292 | $s = new SaeStorage(); 293 | $key=$s->read('simsimi','simi.txt'); 294 | $simsimi_api_url='http://sandbox.api.simsimi.com/request.p?key='.$key.'&lc=ch&ft=0.0&text='.$word; 295 | $simjson=file_get_contents($simsimi_api_url); 296 | $simsimi=json_decode($simjson,1); 297 | 298 | if($simsimi['result']=='100') { 299 | $backws=$simsimi['response']; 300 | } 301 | elseif ($simsimi['result']=='400') { 302 | $backws='400-'.$simsimi['msg']; 303 | } 304 | elseif ($simsimi['result']=='401') { 305 | $backws='401-'.$simsimi['msg']."\n".'看来小u的Trial-key到期了,快提醒我吧。'; 306 | } 307 | elseif ($simsimi['result']=='404') { 308 | if(preg_match('/。。/i', $word)) { 309 | $backws='(*^__^*) 嘻嘻……'.'/:B-)'; 310 | } 311 | else{$backws='404-'.$simsimi['msg']."\n".'这也能遇上404!!'.'/::|';} 312 | } 313 | elseif ($simsimi['result']=='500') { 314 | $backws='500-'.$simsimi['msg']."\n".'服务器出问题,小u表示无能为力。'; 315 | } 316 | else{ 317 | $backws='小u还不会回答这个问题的说...'; 318 | } 319 | $backws=str_replace(array('贱鸡','小黄鸡','黄鸡','xhjchat'), array('小u','小u','小u','urinx'), $backws); 320 | if(preg_match('/微信/i',$backws)) { 321 | $backws='该消息被防火长城,不对。。是被小u消音了,原因你懂的。。保护你的身体,有爱你的健康'.'/:B-)'; 322 | $backws.="\n如果你发现有害身心健康的信息,请及时截图报告小u,小u全力进行封杀。"; 323 | } 324 | return $backws; 325 | } 326 | 327 | function bing($query,$type){ 328 | $accountKey='T7m/69vghK1gjxMTPkGqX5Lfz9fn50YXTc7S6ykGTdY'; 329 | 330 | $ServiceRootURL='https://api.datamarket.azure.com/Bing/Search/'; 331 | $WebSearchURL=$ServiceRootURL.$type.'?$format=json&Query='; 332 | $context=stream_context_create( 333 | array( 334 | 'http' => array( 335 | 'request_fulluri' => true, 336 | 'header' => "Authorization: Basic ".base64_encode($accountKey.":".$accountKey) 337 | ) 338 | )); 339 | $request=$WebSearchURL.urlencode('\''.$query.'\''); 340 | 341 | $response=file_get_contents($request, 0, $context); 342 | $jsonobj=json_decode($response); 343 | 344 | $arr=array(); 345 | if ($type=='Image') { 346 | foreach($jsonobj->d->results as $value){ 347 | array_push($arr, $value->Thumbnail->MediaUrl); 348 | } 349 | } 350 | elseif($type=='Web'){ 351 | foreach($jsonobj->d->results as $value){ 352 | array_push($arr, array('title'=>$value->Title,'description'=>$value->Description,'url'=>$value->Url)); 353 | } 354 | } 355 | return $arr; 356 | } 357 | 358 | function wiki($srsearch){ 359 | if (ctype_alnum($srsearch)) { 360 | $lng='en'; 361 | } 362 | else{ 363 | $lng='zh'; 364 | $srsearch=urlencode($srsearch); 365 | return '中文维基被墙啦!'; 366 | } 367 | $wiki_api_url='http://'.$lng.'.wikipedia.org/w/api.php?action=query&list=search&srwhat=text&format=xml&rawcontinue&srsearch='.$srsearch; 368 | $result=file_get_contents($wiki_api_url); 369 | $xmldata=simplexml_load_string($result); 370 | 371 | $arr=array(); 372 | foreach ($xmldata->query->search->p as $value) { 373 | $value['snippet']=str_replace(array('','','',''), '', $value['snippet']); 374 | $value['snippet']=html_entity_decode($value['snippet'], ENT_QUOTES); 375 | array_push($arr,array('title'=>$value['title'],'snippet'=>$value['snippet'],'link'=>'http://'.$lng.'.wikipedia.org/wiki/'.$value['title'])); 376 | } 377 | return $arr; 378 | } 379 | 380 | function jokes(){ 381 | $jokes_api_url='http://www.djdkx.com/open/randxml'; 382 | $result=file_get_contents($jokes_api_url); 383 | $xmldata=simplexml_load_string($result,'SimpleXMLElement',LIBXML_NOCDATA); 384 | $xmldata->content=str_replace(array(' ','
'), '', trim($xmldata->content)); 385 | return $xmldata->content; 386 | } 387 | 388 | function baiduNews(){ 389 | $word='最新'; 390 | $num=5; 391 | $baidunews_api_url='http://news.baidu.com/ns?tn=newsfcu&from=news&cl=2&ct=0&rn='.$num.'&word='.$word; 392 | $result=file_get_contents($baidunews_api_url); 393 | $reg='#[^\s>]+)"[^>]*target="_blank">(?[^>]+)</a> <span>(?<resrc>[^>]+)</span>#i'; 394 | preg_match_all($reg, $result, $matches); 395 | $matches[resrc]=str_replace(' ',' ',$matches[resrc]); 396 | for ($i=0; $i < 5; $i++) { 397 | $matches[title][$i]=iconv('gbk','utf-8',$matches[title][$i]); 398 | $matches[resrc][$i]=iconv('gbk','utf-8',$matches[resrc][$i]); 399 | } 400 | return $matches; 401 | } 402 | 403 | function doubanMovies($word){ 404 | $list=array('top10'=>'top250','北美票房榜'=>'us_box'); 405 | $doubanMovie_api_url='http://api.douban.com/v2/movie/'; 406 | if (!isset($list[$word])) { 407 | $result=file_get_contents($doubanMovie_api_url.'search?q='.$word); 408 | } 409 | else{ 410 | $result=file_get_contents($doubanMovie_api_url.$list[$word]); 411 | } 412 | $jsondata=json_decode($result); 413 | $movie=array(); 414 | foreach ($jsondata->subjects as $value) { 415 | if ($list[$word]=='us_box') { 416 | $value=$value->subject; 417 | } 418 | array_push($movie, array('average'=>$value->rating->average,'title'=>$value->title,'original_title'=>$value->original_title,'year'=>$value->year,'images'=>$value->images,'alt'=>$value->alt,'id'=>$value->id)); 419 | } 420 | return $movie; 421 | } 422 | 423 | function doubanMovie($id){ 424 | $doubanMovie_api_url='http://api.douban.com/v2/movie/subject/'; 425 | $result=file_get_contents($doubanMovie_api_url.$id); 426 | $jsondata=json_decode($result); 427 | $movie=array('average'=>$jsondata->rating->average,'year'=>$jsondata->year,'images'=>$jsondata->images->large,'mobile_url'=>$jsondata->mobile_url,'title'=>$jsondata->title,'genres'=>$jsondata->genres,'countries'=>$jsondata->countries,'summary'=>$jsondata->summary,'aka'=>$jsondata->aka,'directors'=>$jsondata->directors,'casts'=>$jsondata->casts); 428 | return $movie; 429 | } 430 | 431 | function doubanBooks($word){ 432 | $doubanBook_api_url='https://api.douban.com/v2/book/search?count=5&q='; 433 | $result=file_get_contents($doubanBook_api_url.$word); 434 | $jsondata=json_decode($result); 435 | $book=array(); 436 | foreach ($jsondata->books as $value) { 437 | array_push($book, array('average'=>$value->rating->average,'author'=>$value->author,'pubdate'=>$value->pubdate,'images'=>$value->images,'alt'=>$value->alt,'title'=>$value->title,'publisher'=>$value->publisher,'summary'=>$value->summary,'price'=>$value->price,'tags'=>$value->tags,'id'=>$value->id)); 438 | } 439 | return $book; 440 | } 441 | 442 | function doubanBook($id){ 443 | $doubanBook_api_url='https://api.douban.com/v2/book/'; 444 | $result=file_get_contents($doubanBook_api_url.$id); 445 | $jsondata=json_decode($result); 446 | $book=array('average'=>$jsondata->rating->average,'author'=>$jsondata->author,'pubdate'=>$jsondata->pubdate,'images'=>$jsondata->images->large,'alt'=>$jsondata->alt,'title'=>$jsondata->title,'publisher'=>$jsondata->publisher,'summary'=>$jsondata->summary,'price'=>$jsondata->price,'tags'=>$jsondata->tags); 447 | return $book; 448 | } 449 | 450 | function doubanMusics($word){ 451 | $doubanMusic_api_url='https://api.douban.com/v2/music/search?count=5&q='; 452 | $result=file_get_contents($doubanMusic_api_url.$word); 453 | $jsondata=json_decode($result); 454 | $music=array(); 455 | foreach ($jsondata->musics as $value) { 456 | array_push($music, array('average'=>$value->rating->average,'author'=>$value->author,'pubdate'=>$value->attrs->pubdate,'image'=>$value->image,'alt'=>$value->alt,'title'=>$value->title,'publisher'=>$value->attrs->publisher,'singer'=>$value->attrs->singer,'version'=>$value->attrs->version,'id'=>$value->id)); 457 | } 458 | return $music; 459 | } 460 | 461 | function doubanMusic($id){ 462 | $doubanMusic_api_url='https://api.douban.com/v2/music/'; 463 | $result=file_get_contents($doubanMusic_api_url.$id); 464 | $jsondata=json_decode($result); 465 | $music=array('average'=>$jsondata->rating->average,'author'=>$jsondata->author,'summary'=>$jsondata->summary,'image'=>$jsondata->image,'mobile_link'=>$jsondata->mobile_link,'title'=>$jsondata->title,'id'=>$jsondata->id,'publisher'=>$jsondata->attrs->publisher,'singer'=>$jsondata->attrs->singer,'version'=>$jsondata->attrs->version,'pubdate'=>$jsondata->attrs->pubdate,'tags'=>$jsondata->tags); 466 | return $music; 467 | } 468 | 469 | function dream($word){ 470 | $dream_api_url='http://api2.sinaapp.com/search/dream/?appkey=2989441965&appsecert=4e5e32eb22617e691165e16d6a152a18&reqtype=text&keyword='.urlencode($word); 471 | $result=file_get_contents($dream_api_url); 472 | $dream=json_decode($result); 473 | return $dream->text->content; 474 | } 475 | 476 | function phoneNumber($num){ 477 | $phoneNum_api_url='http://cz.115.com/?ct=index&ac=get_mobile_local&mobile='.$num; 478 | $result=str_replace(array('(',')'), '', file_get_contents($phoneNum_api_url)); 479 | $phone=json_decode($result); 480 | $phoneNum=array('province'=>$phone->province,'city'=>$phone->city,'corp'=>$phone->corp); 481 | return $phoneNum; 482 | } 483 | 484 | function lotterySearch($word){ 485 | $lottery_api_url='http://api2.sinaapp.com/search/lottery/?appkey=2989441965&appsecert=4e5e32eb22617e691165e16d6a152a18&reqtype=text&keyword='.urlencode($word); 486 | $result=file_get_contents($lottery_api_url); 487 | $lottery=json_decode($result); 488 | return $lottery->text->content; 489 | } 490 | function lottery(){ 491 | $lotteryArray=array('双色球','七乐彩','大乐透','七星彩','排列3','排列5','胜负彩','六场半全场'); 492 | foreach ($lotteryArray as $value) { 493 | $lottery.=lotterySearch($value)."\n"; 494 | } 495 | return $lottery; 496 | } 497 | 498 | function picRec($url){ 499 | $picRec_api_url='http://api2.sinaapp.com/recognize/picture/?appkey=2989441965&appsecert=4e5e32eb22617e691165e16d6a152a18&reqtype=text&keyword='.$url; 500 | $result=file_get_contents($picRec_api_url); 501 | $pic=json_decode($result); 502 | return $pic->text->content; 503 | } 504 | 505 | function python($cmd){ 506 | $url='http://urinx.sinaapp.com/'.$cmd; 507 | $result=file_get_contents($url); 508 | return $result; 509 | } 510 | 511 | function stackoverflow(){ 512 | $num=5; 513 | $stack_url='http://stackoverflow.com/'; 514 | $result=file_get_contents($stack_url); 515 | 516 | $mainreg='#<div[\s]+onclick="window.location.href=\'/questions/(\d+/.+)\'"[\s]+class="cp"[\s]*>#i'; 517 | $votereg='#<div class="mini-counts">(\d+)</div>[\s]+<div>votes</div>#i'; 518 | $answerreg='#<div class="mini-counts">(\d+)</div>[\s]+<div>answers</div>#i'; 519 | $viewreg='#<div class="mini-counts">(\d+)</div>[\s]+<div>view[s]*</div>#i'; 520 | 521 | $arr=array($mainreg,$votereg,$answerreg,$viewreg); 522 | $res=array(); 523 | $data=array(); 524 | 525 | foreach ($arr as $reg){ 526 | preg_match_all($reg, $result, $matches); 527 | array_push($res,$matches[1]); 528 | } 529 | 530 | for ($i=0; $i < 5; $i++) { 531 | list($id,$title)=preg_split('#/#',$res[0][$i]); 532 | array_push($data,array('id'=>$id,'title'=>$title,'vote'=>$res[1][$i],'answer'=>$res[2][$i],'view'=>$res[3][$i])); 533 | } 534 | return $data; 535 | } 536 | 537 | function bilibili(){ 538 | $data=array(); 539 | $category=array('1'=>'动画','3'=>'音乐','4'=>'游戏','5'=>'娱乐','11'=>'专辑','13'=>'新番连载'); 540 | foreach ($category as $key=>$value){ 541 | $url='http://www.bilibili.tv/rss-'.$key.'.xml'; 542 | $result=file_get_contents($url); 543 | $xml=simplexml_load_string($result,'SimpleXMLElement', LIBXML_NOCDATA); 544 | array_push($data,array('title'=>$xml->channel->item->title,'description'=>$xml->channel->item->description,'category'=>$value,'link'=>$xml->channel->item->link)); 545 | } 546 | return $data; 547 | } 548 | 549 | function yyets(){ 550 | $data=array(); 551 | $url='http://www.yyets.com/rss/feed/'; 552 | $result=file_get_contents($url); 553 | $xml=simplexml_load_string($result,'SimpleXMLElement', LIBXML_NOCDATA); 554 | 555 | for ($i=0; $i < 6; $i++) { 556 | $r=file_get_contents($xml->channel->item[$i]->link); 557 | $reg='#<img[\s]+src="(http://res\.yyets\.com/ftp/.+\.jpg)"[\s]+/>#i'; 558 | preg_match_all($reg, $r, $matches); 559 | 560 | array_push($data,array('title'=>$xml->channel->item[$i]->title,'description'=>$xml->channel->item[$i]->description,'cover'=>$matches[1][0],'link'=>$xml->channel->item[$i]->link)); 561 | } 562 | 563 | return $data; 564 | } 565 | 566 | function songshu(){ 567 | $data=array(); 568 | $url='http://songshuhui.net/feed'; 569 | $result=file_get_contents($url); 570 | $xml=simplexml_load_string($result,'SimpleXMLElement', LIBXML_NOCDATA); 571 | 572 | for ($i=0; $i < 6; $i++) { 573 | array_push($data,array('title'=>$xml->channel->item[$i]->title,'description'=>$xml->channel->item[$i]->description,'link'=>$xml->channel->item[$i]->link)); 574 | } 575 | 576 | return $data; 577 | } 578 | 579 | function ifanr(){ 580 | $data=array(); 581 | $url='http://www.ifanr.com/feed'; 582 | $result=file_get_contents($url); 583 | $xml=simplexml_load_string($result,'SimpleXMLElement', LIBXML_NOCDATA); 584 | 585 | for ($i=0; $i < 6; $i++) { 586 | $reg='#(.+)题图来自#i'; 587 | preg_match_all($reg, $xml->channel->item[$i]->description, $matches); 588 | array_push($data,array('title'=>$xml->channel->item[$i]->title,'description'=>$matches[1],'cover'=>$xml->channel->item[$i]->image,'link'=>$xml->channel->item[$i]->link)); 589 | } 590 | 591 | return $data; 592 | } 593 | 594 | function bookrank(){ 595 | $data=array(); 596 | $url='http://rss.sina.com.cn/book/history_rank.xml'; 597 | $result=file_get_contents($url); 598 | $xml=simplexml_load_string($result,'SimpleXMLElement', LIBXML_NOCDATA); 599 | 600 | for ($i=0; $i < 6; $i++) { 601 | array_push($data,array('title'=>$xml->channel->item[$i]->title,'description'=>$xml->channel->item[$i]->description,'link'=>$xml->channel->item[$i]->link)); 602 | } 603 | 604 | return $data; 605 | } 606 | 607 | function matrix67(){ 608 | $data=array(); 609 | $url='http://www.matrix67.com/blog/feed'; 610 | $result=file_get_contents($url); 611 | $xml=simplexml_load_string($result,'SimpleXMLElement', LIBXML_NOCDATA); 612 | 613 | for ($i=0; $i < 6; $i++) { 614 | array_push($data,array('title'=>$xml->channel->item[$i]->title,'description'=>str_replace(' ','',$xml->channel->item[$i]->description),'link'=>$xml->channel->item[$i]->link)); 615 | } 616 | 617 | return $data; 618 | } 619 | 620 | function freebuf(){ 621 | $data=array(); 622 | $url='http://www.freebuf.com/feed'; 623 | $result=file_get_contents($url); 624 | $xml=simplexml_load_string($result,'SimpleXMLElement', LIBXML_NOCDATA); 625 | 626 | for ($i=0; $i < 6; $i++) { 627 | array_push($data,array('title'=>$xml->channel->item[$i]->title,'description'=>htmlspecialchars_decode($xml->channel->item[$i]->description),'link'=>$xml->channel->item[$i]->link)); 628 | } 629 | 630 | return $data; 631 | } 632 | 633 | function nginx(){ 634 | $data=array(); 635 | $url='http://www.nginx.cn/feed'; 636 | $result=file_get_contents($url); 637 | $xml=simplexml_load_string($result,'SimpleXMLElement', LIBXML_NOCDATA); 638 | 639 | for ($i=0; $i < 6; $i++) { 640 | array_push($data,array('title'=>$xml->channel->item[$i]->title,'description'=>$xml->channel->item[$i]->description,'link'=>$xml->channel->item[$i]->link)); 641 | } 642 | 643 | return $data; 644 | } 645 | 646 | function shejidaren(){ 647 | $data=array(); 648 | $url='http://www.shejidaren.com/feed'; 649 | $result=file_get_contents($url); 650 | $xml=simplexml_load_string($result,'SimpleXMLElement', LIBXML_NOCDATA); 651 | 652 | for ($i=0; $i < 6; $i++) { 653 | $reg='#<img src="(http://images\.shejidaren\.com/wp-content/uploads/.+)"[\s]+class#i'; 654 | preg_match_all($reg,$xml->channel->item[$i]->description,$matches); 655 | array_push($data,array('title'=>$xml->channel->item[$i]->title,'cover'=>$matches[1][0],'link'=>$xml->channel->item[$i]->link)); 656 | } 657 | 658 | return $data; 659 | } 660 | 661 | function ri91(){ 662 | $data=array(); 663 | $url='http://www.91ri.org/feed'; 664 | $result=file_get_contents($url); 665 | $xml=simplexml_load_string($result,'SimpleXMLElement', LIBXML_NOCDATA); 666 | 667 | for ($i=0; $i < 6; $i++) { 668 | array_push($data,array('title'=>$xml->channel->item[$i]->title,'description'=>$xml->channel->item[$i]->description,'link'=>$xml->channel->item[$i]->link)); 669 | } 670 | 671 | return $data; 672 | } 673 | 674 | function wooyun(){ 675 | $data=array(); 676 | $url='http://www.wooyun.org/feeds/submit'; 677 | $result=file_get_contents($url); 678 | $xml=simplexml_load_string($result,'SimpleXMLElement', LIBXML_NOCDATA); 679 | 680 | for ($i=0; $i < 6; $i++) { 681 | $reg='#<strong>简要描述:</strong><br/>(.+)<br/><strong>详细说明#i'; 682 | preg_match_all($reg,$xml->channel->item[$i]->description, $matches); 683 | array_push($data,array('title'=>$xml->channel->item[$i]->title,'description'=>'简要描述:'.$matches[1][0],'link'=>$xml->channel->item[$i]->link)); 684 | } 685 | 686 | return $data; 687 | } 688 | 689 | function sec0x50(){ 690 | $data=array(); 691 | $url='http://www.0x50sec.org/feed/'; 692 | $result=file_get_contents($url); 693 | $xml=simplexml_load_string($result,'SimpleXMLElement', LIBXML_NOCDATA); 694 | 695 | for ($i=0; $i < 6; $i++) { 696 | array_push($data,array('title'=>$xml->channel->item[$i]->title,'description'=>$xml->channel->item[$i]->description,'link'=>$xml->channel->item[$i]->link)); 697 | } 698 | 699 | return $data; 700 | } 701 | 702 | function ghost_story($w='灵异知识库'){ 703 | global $ghost; 704 | $data=array(); 705 | $url='http://www.gui44.com/data/rss/'.$ghost[$w].'.xml'; 706 | $xml=simplexml_load_file($url,'SimpleXMLElement',LIBXML_NOCDATA); 707 | 708 | if($xml){ 709 | if($w=='听鬼故事'){ 710 | for ($i=0; $i < 5; $i++) { 711 | $j=$xml->channel->item[$i]; 712 | array_push($data,array('title'=>$i.'. '.$j->title,'description'=>'','link'=>$j->link,'pubDate'=>$j->pubDate,'author'=>$j->author)); 713 | } 714 | array_push($data,array('title'=>'5...49 还有更多')); 715 | array_push($data,array('title'=>'回复关键字[张震]随机收听'."\n".'回复[张震 序号]指定收听第几个')); 716 | } 717 | else{ 718 | for ($i=0; $i < 6; $i++) { 719 | $j=$xml->channel->item[$i]; 720 | array_push($data,array('title'=>$j->title,'description'=>$j->description,'link'=>$j->link,'pubDate'=>$j->pubDate,'author'=>$j->author)); 721 | } 722 | } 723 | } 724 | else{ 725 | $result=file_get_contents($url); 726 | $result=iconv('gb2312','gbk',$result); 727 | $result=iconv('gbk','utf-8',$result); 728 | preg_match_all( "/\<item\>(.*?)\<\/item\>/s",$result,$items); 729 | for ($i=0; $i < 6; $i++){ 730 | preg_match_all( "/\<title\>\<\!\[CDATA\[(.*?)\]\]\>\<\/title\>/",$items[0][$i],$title); 731 | $title=$title[1][0]; 732 | preg_match_all( "/\<description\>\<\!\[CDATA\[(.*?)\]\]\>\<\/description\>/",$items[0][$i],$description); 733 | $description=$description[1][0]; 734 | preg_match_all( "/\<link\>(.*?)\<\/link\>/",$items[0][$i],$link); 735 | $link=$link[1][0]; 736 | preg_match_all( "/\<pubDate\>(.*?)\<\/pubDate\>/",$items[0][$i],$pubDate); 737 | $pubDate=$pubDate[1][0]; 738 | preg_match_all( "/\<author\>(.*?)\<\/author\>/",$items[0][$i],$author); 739 | $author=$author[1][0]; 740 | array_push($data,array('title'=>$title,'description'=>$description,'link'=>$link,'pubDate'=>$pubDate,'author'=>$author)); 741 | } 742 | } 743 | 744 | return $data; 745 | } 746 | 747 | function zhangzhen($i){ 748 | $xml=simplexml_load_file('http://www.gui44.com/data/rss/10.xml','SimpleXMLElement',LIBXML_NOCDATA); 749 | preg_match_all('#flashvars="son=(.*?)&autoplay=1&autoreplay=0"#s',file_get_contents($xml->channel->item[$i]->link),$u); 750 | $title=str_replace(array('张震讲鬼故事系列之','张震讲鬼故事系列','张震鬼故事之','张震讲鬼故事'), '',$xml->channel->item[$i]->title); 751 | return array('title'=>$title,'description'=>'张震','musicurl'=>$u[1][0],'HQmusicurl'=>$u[1][0]); 752 | } 753 | 754 | function xiaodoubi($words){ 755 | $xiaodoubi_url='http://www.xiaodoubi.com/bot/chat.php'; 756 | $fields_post=array('chat'=>$words, ); 757 | $fields_string=http_build_query($fields_post,'&'); 758 | 759 | $ch=curl_init(); 760 | curl_setopt($ch,CURLOPT_POST,1); 761 | curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); 762 | curl_setopt($ch,CURLOPT_HEADER,0); 763 | curl_setopt($ch,CURLOPT_URL,$xiaodoubi_url); 764 | curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string); 765 | $backws=curl_exec($ch); 766 | curl_close($ch); 767 | 768 | if(preg_match('/微信/i',$backws)) { 769 | $backws='该消息被防火长城,不对。。是被小u消音了,原因你懂的。。保护你的身体,有爱你的健康'.'/:B-)'; 770 | $backws.="\n如果你发现有害身心健康的信息,请及时截图报告小u,小u全力进行封杀。"; 771 | } 772 | 773 | return $backws; 774 | } 775 | ?> -------------------------------------------------------------------------------- /3.0/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Urinx/weChat_php/7fa1b48b8e1bc3eb676acaab6eda1775af705590/3.0/.DS_Store -------------------------------------------------------------------------------- /3.0/index.php: -------------------------------------------------------------------------------- 1 | <?php 2 | error_reporting(E_ALL & ~E_DEPRECATED & ~E_NOTICE); 3 | header('Content-Type: text/html; charset=utf-8'); 4 | 5 | $appdir=dirname(__FILE__); 6 | require $appdir . '/wechat-api.php'; 7 | 8 | $mysql=new SaeMysql(); 9 | $s = new SaeStorage(); 10 | $f = new SaeFetchurl(); 11 | ########################Constant######################## 12 | $web='http://paiplace.5gbfree.com/wechat'; 13 | $mp='http://mp.weixin.qq.com/mp/appmsg/show'; 14 | $xiaoU=array( 15 | array('title'=>'Uri','cover'=>$web.'/img/xiaou.jpg','link'=>$mp.'?__biz=MzA3MjAzMTgyMA==&appmsgid=10000058&itemidx=1&sign=93bf84e650d4df87196988b342b65644&uin=MTg0MTcyODUwMQ%3D%3D&key=1f75b224f2ddfcb63ee0ec9833578cef7b1a67f0a5b8764f174219e1dea6ff39600f23b296cd7601a031fb617c173721&devicetype=android-17&version=25000104&lang=zh_CN'), 16 | array('title'=>'功能介绍','cover'=>$web.'/img/function.png','link'=>$mp.'?__biz=MzA3MjAzMTgyMA==&appmsgid=10000058&itemidx=2&sign=aa817cfb12b9117cb518d4ab268d28b9&uin=MTg0MTcyODUwMQ%3D%3D&key=a45a7c15a542fe6fc8cb6988104ee36150747c2ada475afb2ac31bce5694e6c3926bef8e4a56de8e63d7ca0e91c68a1f&devicetype=android-17&version=25000104&lang=zh_CN'), 17 | array('title'=>'任务进度','cover'=>$web.'/img/taskprocess.png','link'=>$mp.'?__biz=MzA3MjAzMTgyMA==&appmsgid=10000058&itemidx=3&sign=5edb8953ca274271a239626c434df4a2&uin=MTg0MTcyODUwMQ%3D%3D&key=1f75b224f2ddfcb6c670a05130da7f8843902f3277a89843ae023cec9a770260f883566234a1185fec8257197f241425&devicetype=android-17&version=25000104&lang=zh_CN'), 18 | array('title'=>'联系我们','cover'=>$web.'/img/contactme.png','link'=>$mp.'?__biz=MzA3MjAzMTgyMA==&appmsgid=10000058&itemidx=4&sign=a7d37be0a672e5c2085330799836992b&uin=MTg0MTcyODUwMQ%3D%3D&key=1f75b224f2ddfcb62c58bc42a307d4f512acd5bfc822af05b55a2f55325983e93e612b5c098985be9b9909a57e7eab5e&devicetype=android-17&version=25000104&lang=zh_CN') 19 | ); 20 | $biaoqing=array( 21 | '/::)','/::~','/::B','/::|','/:8-)','/::<','/::$','/::X','/::Z','/::\'(','/::-|', 22 | '/::@','/::P','/::D','/::O','/::(','/::+','/:--b','/::Q','/::T','/:,@P','/:,@-D', 23 | '/::d','/:,@o','/::g','/:|-)','/::!','/::L','/::>','/::,@','/:,@f','/::-S','/:?', 24 | '/:,@x','/:,@@','/::8','/:,@!','/:!!!','/:xx','/:bye','/:wipe','/:dig','/:handclap', 25 | '/:&-(','/:B-)','/:<@','/:@>','/::-O','/:>-|','/:P-(','/::\'|','/:X-)','/::*','/:@x', 26 | '/:8*'); 27 | $pythonWelcome='Python 2.7.5 (default, Aug 25 2013, 00:04:04) 28 | [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin 29 | Type "help", "copyright", "credits" or "license" for more information.'; 30 | $mysqlWelcome="Welcome to the MySQL monitor. Commands end with ; or \g. 31 | Server version: 5.0.45-community-nt MySQL Community Edition (GPL) 32 | Type 'help;' or '\h' for help. Type '\c' to clear the buffer."; 33 | $sqliWelcome="sqli beta1.0\nWelcome to the sqli platform for you to leran SQL injection.We wish you enjoin this and have fun.\n\nsend 'login' to start."; 34 | $welcome=array($pythonWelcome,$mysqlWelcome,$sqliWelcome); 35 | $help='这是目前小u有的功能:'."\n".'-----------------'."\n".'[小u]'."\n".':查看小u的基本信息,以及功能介绍和近期更新'."\n".'-----------------'."\n".'[帮助]'."\n".':查看使用帮助'."\n".'-----------------'."\n".'[查水表]'."\n".':查询寝室的水电费(华科)'."\n".'-----------------'."\n".'[每日一句]'."\n".':每天更新一句英语,中英对照'."\n".'-----------------'."\n".'[点歌]'."\n".':小u每天会为大家推荐好的歌曲,希望大家喜欢。如果想给某人点歌的话,可以直接跟我说哦'."\n".'-----------------'."\n".'[笑话]'."\n".':郁闷时看看笑话吧,小u这里有好多笑话等着你呢'."\n".'-----------------'."\n".'[新闻]'."\n".':没事的时候大家多看看新闻吧,小u不懈的为你奉送中'."\n".'-----------------'."\n".'[彩票]'."\n".':每天的彩票信息一目了然'."\n".'-----------------'."\n".'翻译'."\n".':发送"#+你要翻译的内容",即可收到详细结果,例如:#doofus'."\n".'-----------------'."\n".'天气+找小u'."\n".':点击下面的“+”,发送你的的位置信息,即可收到本地的天气预报,并且看到你和小u的距离哟。'."\n".'-----------------'."\n".'bing搜索'."\n".':发送"%+你要搜索的内容",即可收到详细结果,例如:%dweeb'."\n".'-----------------'."\n".'维基百科'."\n".':发送"&+你要搜索的内容",小u会根据你的输入自动判断查询中文维基或是英文,(*^__^*) 嘻嘻。例如:&spaz'."\n".'-----------------'."\n".'二维码'."\n".':发送"*+你要生成的内容",小u会返回生成的二维码。例如:*嘟嘟噜'."\n".'-----------------'; 36 | $help.="\n".'豆瓣'."\n".'1.书'."\n".' bs:关键字 搜索相关的书籍'."\n".' b:书名 查看详细内容'."\n".'2.音乐'."\n".' ms:关键字 搜索相关的音乐'."\n".' m:音乐名 查看详细内容'."\n".'3.电影'."\n".' vs:关键字 搜索相关的电影'."\n".' v:电影名 查看详细内容'."\n".'-----------------'; 37 | $help.="\n".'动态'."\n".':发送":+你要分享的文字"即可,大家可以回复[动态]查看,都可以看到哦。例如 :这是我发的第一个说说'."\n".'-----------------'; 38 | $help.="\n".'美女识别'."\n".':上传图片,看看小u的眼力吧'."\n".'-----------------'."\n".'周公解梦'."\n".':发送"梦到xxx",小u来预测吉凶,例如"梦到小u"'."\n".'-----------------'."\n".'手机号码查询'."\n".':直接发送手机号'."\n".'-----------------'; 39 | $help.="\n".'#[xx]内的内容xx是指你发送给小u的'; 40 | $waterbiao='查询电费请点击这里:'."\n".'<a href="http://42.120.22.130/dianfei.php">查电费</a>。'."\n".'低余电费自动提醒功能请点击这里:'."\n".'<a href="http://42.120.22.130:8822/">邮件提醒</a>'; 41 | $terminal=array('>python'=>1,'>mysql'=>2,'>sqli'=>3); 42 | $keywords=array( 43 | '小u'=>$xiaoU, 44 | '点歌'=>array('title'=>'你给的甜', 'description'=>'何艺纱', 'musicurl'=>'http://data7.5sing.com/T1aMbeBXbT1R47IVrK.mp3', 'HQmusicurl'=>'http://data7.5sing.com/T1aMbeBXbT1R47IVrK.mp3'), 45 | '每日一句'=>en_sentenceAPI(), 46 | '笑话'=>jokes(), 47 | '新闻'=>baiduNews(), 48 | '动态'=>moment(), 49 | 'bilibili'=>bilibili(), 50 | 'stack'=>stackoverflow(), 51 | '小幽'=>'在!', 52 | '彩票'=>lottery(), 53 | '帮助'=>$help, 54 | '查水表'=>$waterbiao, 55 | ); 56 | $rss_arr=array( 57 | '0x50sec'=>array('title'=>'Web安全手册,专注Web安全','cover'=>$web.'/img/0x50sec.png'), 58 | '91ri'=>array('title'=>'网络安全攻防研究室','cover'=>$web.'/img/91ri.gif'), 59 | 'freebuf'=>array('title'=>'Freebuf','cover'=>$web.'/img/freebuf.jpg'), 60 | 'matrix67'=>array('cover'=>$web.'/img/matrix67.png'), 61 | '读书'=>array('title'=>'读书排行榜','cover'=>$web.'/img/meizi/'.mt_rand(0,9).'.jpg'), 62 | '松鼠'=>array('title'=>'科学松鼠会','cover'=>$web.'/img/songshu.gif'), 63 | '爱范'=>array('title'=>'爱范儿 · Beats of Bits','cover'=>$web.'/img/ifanr.gif'), 64 | '人人影视'=>array('title'=>'人人影视','cover'=>$web.'/img/yyets.png'), 65 | '设计达人'=>array('title'=>'设计达人-爱设计,爱分享。','cover'=>$web.'/img/meizi/'.mt_rand(0,9).'.jpg'), 66 | '运维'=>array('title'=>'好的架构减少运维,好的运维反哺架构','cover'=>$web.'/img/meizi/'.mt_rand(0,9).'.jpg'), 67 | '乌云'=>array('title'=>'wooyun.org 最新提交漏洞','cover'=>$web.'/img/wooyun.png'), 68 | ); 69 | $reg_arr=array( 70 | '/^(梦到)(.+)/i'=>'dream', 71 | '/^(#)(.+)/i'=>'translate', 72 | '#(/:)#i'=>'biaoqingbiaoqing', 73 | '#^(simi:)(.+)#i'=>'changeSimsimiKey', 74 | '#^(md5:)(.+)#i'=>'md5', 75 | '/^(\*)(.+)/i'=>'qrcode', 76 | '/^(%)(.+)/i'=>'bingSearch', 77 | '/^(&)(.+)/i'=>'wiki', 78 | '/^(vs:)(.+)/i'=>'doubanMovie1', 79 | '/^(v:)(.+)/i'=>'doubanMovie2', 80 | '/^(bs:)(.+)/i'=>'doubanBook1', 81 | '/^(b:)(.+)/i'=>'doubanBook2', 82 | '/^(ms:)(.+)/i'=>'doubanMusic1', 83 | '/^(m:)(.+)/i'=>'doubanMusic2', 84 | '/^(:)(.+)/i'=>'moments1', 85 | '/^(昵称:)(.+)/i'=>'moments2', 86 | ); 87 | ######################################################## 88 | //Define function 89 | /*---------------------------------------------------*/ 90 | function changeStatu($openid,$num){ 91 | $mysql=new SaeMysql(); 92 | $result=$mysql->getData("SELECT * FROM python WHERE FromUserName='{$openid}'"); 93 | if (!$result[0]){ 94 | $mysql->runSql("INSERT INTO python(FromUserName,state) VALUES ('{$openid}',{$num})"); 95 | } 96 | else{ 97 | $mysql->runSql("UPDATE python SET state={$num} WHERE FromUserName='{$openid}'"); 98 | } 99 | } 100 | function moment(){ 101 | $mysql=new SaeMysql(); 102 | $res=$mysql->getData("SELECT * FROM moments ORDER BY ID DESC LIMIT 5"); 103 | $data=array(array('title'=>'动态','cover'=>$web.'/img/meizi/2.jpg')); 104 | for ($i=0; $i < count($data); $i++) { 105 | if ($res[$i]) { 106 | array_push($data, array('title'=>$res[$i]['alias'].':','note'=>$res[$i]['moment']."\n".$res[$i]['date'],'cover'=>$res[$i]['photo'])); 107 | } 108 | } 109 | return $data; 110 | } 111 | function mysqlc($content){ 112 | $mysql=new SaeMysql(); 113 | if($content=='help'){ 114 | $data='Select'."\n".'Insert'."\n".'Update'."\n".'Delete'."\n".'Create'."\n".'Drop'."\n".'Index'."\n".'Alter'; 115 | } 116 | else{ 117 | if(preg_match('#^(select)#i',$content)){ 118 | $sqlresult=$mysql->getData($content); 119 | if($mysql->errno()!=0){ 120 | $data="Error:".$mysql->errmsg(); 121 | } 122 | else{ 123 | $data='mysql> '.$content."\n".'-----------------'."\n"; 124 | foreach($sqlresult as $row){ 125 | foreach($row as $key=>$value){ 126 | $data.=$key.':'.$value."\n"; 127 | } 128 | $data.='------------------'."\n"; 129 | } 130 | } 131 | } 132 | else{ 133 | $mysql->runSql($content); 134 | if($mysql->errno()!=0){ 135 | $data="Error:".$mysql->errmsg(); 136 | } 137 | } 138 | } 139 | return $data; 140 | } 141 | function sqli($content){ 142 | if($content=='login'){ 143 | $data=array(array('title'=>'第一关','note'=>'try to login','cover'=>'http://xiaouri-wephoto.stor.sinaapp.com/QQ20140110-4.png','link'=>'http://xiaouri.sinaapp.com/test.php')); 144 | } 145 | elseif($content=='shift2'){ 146 | $data=array(array('title'=>'第二关','note'=>'正在制作中...','cover'=>'','link'=>'')); 147 | } 148 | elseif($content=='test'){ 149 | $data=array(array('title'=>'测试','note'=>'test','link'=>'http://xiaouri.sinaapp.com/test2.php')); 150 | } 151 | else{ 152 | $data='...'; 153 | } 154 | return $data; 155 | } 156 | function terminalEngine($content,$openid){ 157 | global $terminal,$welcome; 158 | $mysql=new SaeMysql(); 159 | $result=$mysql->getData("SELECT * FROM python WHERE FromUserName='{$openid}'"); 160 | if (!$result[0]['state']) { 161 | if ($terminal[$content]){ 162 | changeStatu($openid,$terminal[$content]); 163 | return $welcome[$terminal[$content]-1]; 164 | } 165 | } 166 | elseif ($content=='quit'){ 167 | $mysql->runSql("UPDATE python SET state=0 WHERE FromUserName='{$openid}'"); 168 | return '已退出终端...'; 169 | } 170 | else{ 171 | switch ($result[0]['state']) { 172 | case 1://python 173 | $data=python($content); 174 | break; 175 | 176 | case 2://mysql 177 | $data=mysqlc($content); 178 | break; 179 | 180 | case 3://sqli 181 | $data=sqli($content); 182 | break; 183 | 184 | default: 185 | # code... 186 | break; 187 | } 188 | return $data; 189 | } 190 | } 191 | function keywordsEngine($content){ 192 | $content=strtolower(trim($content)); 193 | global $keywords,$rss_arr; 194 | if ($keywords[$content]) { 195 | $data=$keywords[$content]; 196 | } 197 | elseif ($rss_arr[$content]) { 198 | $data=rss($content); 199 | array_unshift($data,$rss_arr[$content]); 200 | } 201 | else{ 202 | if (ctype_alpha($content)) { 203 | $data=translateAPI($content); 204 | } 205 | } 206 | return $data; 207 | } 208 | function matchEngine($content){ 209 | global $reg_arr,$biaoqing; 210 | foreach ($reg_arr as $key => $value) { 211 | if(preg_match($key, $content, $matches)){ 212 | switch ($value) { 213 | case 'dream': 214 | $data=dream($matches[2]); 215 | break; 216 | 217 | case 'translate': 218 | $data=translateAPI($matches[2]); 219 | break; 220 | 221 | case 'biaoqing': 222 | $data=$biaoqing[rand(0,count($biaoqing)-1)]; 223 | break; 224 | 225 | case 'changeSimsimiKey': 226 | $s = new SaeStorage(); 227 | $s->write('simsimi','simi.txt',$matches[2]); 228 | $data='更改成功!'; 229 | break; 230 | 231 | case 'md5': 232 | $data=md5($matches[2]); 233 | break; 234 | 235 | case 'qrcode': 236 | $qrcode='http://chart.apis.google.com/chart?cht=qr&chs=400x400&choe=UTF-8&chl='.$matches[2]; 237 | $data=array( 238 | array('title'=>$matches[2],'cover'=>$qrcode,'link'=>$qrcode) 239 | ); 240 | break; 241 | 242 | case 'bingSearch': 243 | $bingweb=bing($matches[2],'Web'); 244 | $bingimage=bing($matches[2],'Image'); 245 | $data=array( 246 | array('title'=>$matches[2],'note'=>'','cover'=>$bingimage[0],'link'=>'') 247 | ); 248 | //max:7 249 | for ($i=0;$i<5;$i++){ 250 | array_push($data,array('title'=>$bingweb[$i]['title']."\n".'------------------------------------------','note'=>$bingweb[$i]['description'],'cover'=>'','link'=>$bingweb[$i]['url'])); 251 | } 252 | break; 253 | 254 | case 'wiki': 255 | $wiki=wiki($matches[2],$lng); 256 | $data=array(); 257 | for ($i=0;$i<5;$i++){ 258 | array_push($data,array('title'=>$wiki[$i]['title']."\n".'------------------------------------------','note'=>$wiki[$i]['snippet'],'cover'=>'','link'=>'http://zh.wikipedia.org/wiki/'.$wiki[$i]['title'])); 259 | } 260 | break; 261 | 262 | case 'doubanMovie1': 263 | $m=doubanMovies($matches[2]); 264 | $data=array(array('title'=>$m[0]['title'],'note'=>$m[0]['year'].' '.$m[0]['average'],'cover'=>$m[0]['images']->large,'link'=>$m[0]['alt'])); 265 | for ($i=1;$i<=5;$i++){ 266 | array_push($data,array('title'=>$m[$i]['title'],'note'=>'又名:'.$m[$i]['original_title']."\n".'上映日期:'.$m[$i]['year']."\n".'评价:'.$m[$i]['average'],'cover'=>$m[$i]['images']->small,'link'=>$m[$i]['alt'])); 267 | } 268 | break; 269 | 270 | case 'doubanMovie2': 271 | $m=doubanMovies($matches[2]); 272 | $movie=doubanMovie($m[0]['id']); 273 | $xinxi='又名:'; 274 | foreach ($movie['aka'] as $value) { 275 | $xinxi.=$value.'/'; 276 | } 277 | $xinxi.="\n".'上映日期:'.$movie['year']."\n".'制片国家:'; 278 | foreach ($movie['countries'] as $value) { 279 | $xinxi.=$value.'/'; 280 | } 281 | $xinxi.="\n".'类型:'; 282 | foreach ($movie['genres'] as $value) { 283 | $xinxi.=$value.'/'; 284 | } 285 | $xinxi.="\n".'评价:'.$movie['average']; 286 | $data=array( 287 | array('title'=>$movie['title'],'cover'=>$movie['images'],'link'=>$movie['mobile_url']), 288 | array('note'=>$xinxi,'link'=>$movie['mobile_url']), 289 | array('title'=>'简介','note'=>$movie['summary'],'link'=>$movie['mobile_url']), 290 | array('title'=>'导演','note'=>$movie['directors'][0]->name,'cover'=>$movie['directors'][0]->avatars->small,'link'=>$movie['directors'][0]->alt), 291 | array('title'=>'主演','note'=>$movie['casts'][0]->name,'cover'=>$movie['casts'][0]->avatars->small,'link'=>$movie['casts'][0]->alt) 292 | ); 293 | break; 294 | 295 | case 'doubanBook1': 296 | $b=doubanBooks($matches[2]); 297 | $data=array(array('title'=>$b[0]['title'],'note'=>$b[0]['author'][0].' '.$b[0]['average'],'cover'=>$b[0]['images']->large,'link'=>$b[0]['alt'])); 298 | for ($i=1;$i<=4;$i++){ 299 | array_push($data,array('title'=>$b[$i]['title'],'note'=>'作者:'.$b[$i]['author'][0]."\n".'出版社:'.$b[$i]['publisher']."\n".'出版日期:'.$b[$i]['pubdate']."\n".'价格:'.$b[$i]['price']."\n".'评价:'.$b[$i]['average']."\n".'导言:'.$b[$i]['summary'],'cover'=>$b[$i]['images']->small,'link'=>$b[$i]['alt'])); 300 | } 301 | break; 302 | 303 | case 'doubanBook2': 304 | $b=doubanBooks($matches[2]); 305 | $bk=doubanBook($b[0]['id']); 306 | $data=array( 307 | array('title'=>$bk['title'],'cover'=>$bk['images'],'link'=>$bk['alt']), 308 | array('note'=>'作者:'.$bk['author'][0]."\n".'出版社:'.$bk['publisher']."\n".'出版日期:'.$bk['pubdate']."\n".'价格:'.$bk['price']."\n".'评价:'.$bk['average'],'link'=>$bk['alt']), 309 | array('title'=>'导言:','note'=>$bk['summary'],'link'=>$bk['alt']) 310 | ); 311 | break; 312 | 313 | case 'doubanMusic1': 314 | $m=doubanMusics($matches[2]); 315 | $data=array(array('title'=>$m[0]['title'],'note'=>$m[0]['average'],'cover'=>$m[0]['image'],'link'=>$m[0]['alt'])); 316 | for ($i=1;$i<=4;$i++){ 317 | array_push($data,array('title'=>$m[$i]['title'],'note'=>'作者:'.$m[$i]['author'][0]->name."\n".'出版社:'.$m[$i]['publisher'][0]."\n".'出版日期:'.$m[$i]['pubdate'][0]."\n".'表演者:'.$m[$i]['singer'][0]."\n".'评价:'.$m[$i]['average']."\n".'类型:'.$m[$i]['version'][0],'cover'=>$m[$i]['image'],'link'=>$m[$i]['alt'])); 318 | } 319 | break; 320 | 321 | case 'doubanMusic2': 322 | $m=doubanMusics($matches[2]); 323 | $mu=doubanMusic($m[0]['id']); 324 | $data=array( 325 | array('title'=>$mu['title'],'cover'=>$mu['image'],'link'=>$mu['mobile_link']), 326 | array('note'=>'表演者:'.$mu['singer'][0]."\n".'专辑类型:'.$mu['version'][0]."\n".'发行时间:'.$mu['pubdate'][0]."\n".'作者:'.$mu['author'][0]->name."\n".'出版者:'.$mu['publisher'][0]."\n".'评价:'.$mu['average'],'link'=>$mu['mobile_link']), 327 | array('title'=>'简介:','note'=>$mu['summary'],'link'=>$mu['mobile_link']) 328 | ); 329 | break; 330 | 331 | case 'moments1': 332 | $moment=$matches[2]; 333 | $time=time(); 334 | $date=date("Y-m-d H:i:s",time()); 335 | $mysql=new SaeMysql(); 336 | $res=$mysql->getData("SELECT alias FROM info WHERE FromUserName='{$openid}'"); 337 | $alias=$res[0]['alias']; 338 | if (!$alias) { 339 | $data='由于你是第一次发送动态,请按照以下格式回复基本信息:'."\n".'昵称:+你的昵称'; 340 | } 341 | else{ 342 | $mysql->runSql("INSERT INTO moments(FromUserName,alias,moment,time,date) VALUES ('{$openid}','{$alias}','{$moment}',{$time},'{$date}')"); 343 | $data="发送成功,你可以现在上传一张图片作为配图,当然也可以不上传啦。回复[动态]查看"; 344 | } 345 | break; 346 | 347 | case 'moments2': 348 | $alias=$matches[2]; 349 | $mysql=new SaeMysql(); 350 | $res=$mysql->getData("SELECT * FROM info"); 351 | $num=0; 352 | while ($res[$num]) { 353 | if ($alias==$res[$num]['alias'] || $alias=='小u' || $alias=='urinx') { 354 | $t=1; 355 | } 356 | elseif ($openid==$res[$num]['FromUserName']) { 357 | $u=1; 358 | } 359 | $num++; 360 | } 361 | if ($t) { 362 | $data='该用户名已被注册,请重新输入'; 363 | } 364 | else{ 365 | if ($u) { 366 | $mysql->runSql("UPDATE info SET alias='{$alias}' WHERE FromUserName='{$openid}'"); 367 | $data='更改成功!'; 368 | } 369 | else{ 370 | $mysql->runSql("INSERT INTO info(FromUserName,alias) VALUES ('{$openid}','{$alias}')"); 371 | $data='注册成功!'; 372 | } 373 | } 374 | break; 375 | 376 | default: 377 | # code... 378 | break; 379 | } 380 | } 381 | } 382 | return $data; 383 | } 384 | function randEngine(){ 385 | global $keywords,$rss_arr; 386 | for ($i=0; $i < 4; $i++) { 387 | array_pop($keywords); 388 | } 389 | $a=count($keywords); 390 | $b=count($rss_arr); 391 | if (rand(1,$a+$b)<=$b) { 392 | $key=array_rand($rss_arr,1); 393 | $data=rss($key); 394 | array_unshift($data,$rss_arr[$key]); 395 | } 396 | else{ 397 | $data=$keywords[array_rand($keywords,1)]; 398 | } 399 | return $data; 400 | } 401 | /*---------------------------------------------------*/ 402 | if(W::isPOST()){ 403 | $post=$GLOBALS["HTTP_RAW_POST_DATA"]; 404 | $xml=simplexml_load_string($post, 'SimpleXMLElement', LIBXML_NOCDATA); 405 | $content=trim($xml->Content); 406 | $type=strtolower($xml->MsgType); 407 | $openid=$xml->FromUserName; 408 | 409 | // 接收位置 410 | if($type=='location'){ 411 | $uriID='oTHwbt_9H0QVjJn8AdI-fmkHdKgM'; 412 | $X=$xml->Location_X; 413 | $Y=$xml->Location_Y; 414 | 415 | $sql="SELECT Location_X,Location_Y FROM info WHERE FromUserName='{$uriID}'"; 416 | $sqlback=$mysql->getData($sql); 417 | $pre_X=$sqlback[0]['Location_X']; 418 | $pre_Y=$sqlback[0]['Location_Y']; 419 | 420 | $wData=weatherAPI($X,$Y);//天气查询 421 | $distance=W::getDistance($X,$Y,$pre_X,$pre_Y);//计算距离 422 | 423 | if ($openid == $uriID) { 424 | $mysql->runSql("UPDATE info SET Location_X='{$X}',Location_Y='{$Y}' WHERE FromUserName='{$uriID}'"); 425 | $data='主人的位置已上传'."\n".'X:'.$X."\n".'Y:'.$Y."\n".'相距上次位置'.$distance.'km'; 426 | } 427 | else{ 428 | $data='哦哦,你和我的距离只有'.$distance.'km哟'; 429 | } 430 | $data.="\n".'------------------------------'."\n".$wData; 431 | } 432 | 433 | //接收文字 434 | elseif($type=='text'){ 435 | //$data=terminalEngine($content,$openid); 436 | $data=keywordsEngine($content); 437 | $data=matchEngine($content); 438 | } 439 | 440 | //接收图片 441 | elseif($type=='image'){ 442 | $picurl=$xml->PicUrl; 443 | $img_data=$f->fetch($picurl); 444 | if($f->errno()==0){ 445 | $img_name=$openid.date(YmdHis).'.jpg'; 446 | $s->write('wephoto',$img_name,$img_data); 447 | $picUrl=$s->getUrl('wephoto',$img_name); 448 | $mysql->runSql("UPDATE moments SET photo='{$picUrl}' WHERE FromUserName='{$openid}'"); 449 | $data='你的图片已上传成功!'; 450 | $data.="\n".picRec($picurl); 451 | } 452 | else{ 453 | $data='failed'; 454 | } 455 | } 456 | 457 | //接收语音 458 | elseif($type=='voice'){ 459 | $data='小u听不懂人话的说。。'; 460 | } 461 | 462 | //接收事件 463 | elseif($type=='event'){ 464 | $event=strtolower($xml->Event); 465 | if($event=='subscribe'){ 466 | $data=$xiaoU; 467 | } 468 | } 469 | $mysql->closeDb(); 470 | 471 | //贱鸡自动回复 472 | if ($data) { 473 | if (is_array($data)) { 474 | if ($data['musicurl']) { 475 | exit(W::response($xml,$data,'music')); 476 | } 477 | exit(W::response($xml,$data,'news')); 478 | } 479 | else{exit(W::response($xml,$data));} 480 | } 481 | else{ 482 | if (rand(1,10)==6){ 483 | $data=randEngine(); 484 | if (is_array($data)) { 485 | if ($data['musicurl']) { 486 | exit(W::response($xml,$data,'music')); 487 | } 488 | exit(W::response($xml,$data,'news')); 489 | } 490 | else{exit(W::response($xml,$data));} 491 | } 492 | else{ 493 | $simiword=simsimi($content); 494 | if ($simiword=='404') { 495 | $data=randEngine(); 496 | if (is_array($data)) { 497 | if ($data['musicurl']) { 498 | exit(W::response($xml,$data,'music')); 499 | } 500 | exit(W::response($xml,$data,'news')); 501 | } 502 | else{exit(W::response($xml,$data));} 503 | } 504 | exit(W::response($xml,$simiword)); 505 | } 506 | } 507 | } 508 | 509 | ?> -------------------------------------------------------------------------------- /3.0/wechat-api.php: -------------------------------------------------------------------------------- 1 | <?php 2 | 3 | class w { 4 | //响应请求 5 | static function response($xml,$data,$type='text') { 6 | $time=time(); 7 | $xmltpl['text']='<xml><ToUserName><![CDATA[%s]]></ToUserName><FromUserName><![CDATA[%s]]></FromUserName>'; 8 | $xmltpl['text'].='<CreateTime>%s</CreateTime><MsgType><![CDATA[text]]></MsgType><Content><![CDATA[%s]]></Content><FuncFlag>0</FuncFlag></xml>'; 9 | $xmltpl['item']='<item><Title><![CDATA[%s]]>'; 10 | $xmltpl['news']='%s'; 11 | $xmltpl['news'].='%s%s1'; 12 | $xmltpl['music']='%s'; 13 | $xmltpl['music'].='<![CDATA[%s]]>'; 14 | $xmltpl['image']='%s1234567890123456'; 15 | 16 | if($type == 'text'){ 17 | return sprintf($xmltpl['text'],$xml->FromUserName,$xml->ToUserName,$time,$data); 18 | } 19 | 20 | elseif($type=='news'){ 21 | if(is_array($data)){ 22 | $items=''; 23 | if(count($data) > 1){ 24 | foreach($data as $e){ 25 | $title=trim($e['title']."\n".$e['note'],"\n"); 26 | $items.=sprintf($xmltpl['item'],$title,'',$e['cover'],$e['link']); 27 | } 28 | } 29 | elseif(count($data) == 1){ 30 | foreach($data as $e){ 31 | $items=sprintf($xmltpl['item'],$e['title'],$e['note'],$e['cover'],$e['link']); 32 | } 33 | } 34 | else{ 35 | return self::response($xml,'没有数据'); 36 | } 37 | return sprintf($xmltpl['news'],$xml->FromUserName,$xml->ToUserName,$time,count($data),$items); 38 | } 39 | return self::response($xml,'没有数据'); 40 | } 41 | 42 | elseif($type == 'music'){ 43 | return sprintf($xmltpl['music'],$xml->FromUserName,$xml->ToUserName,$time,$data['title'],$data['description'],$data['musicurl'],$data['HQmusicurl']); 44 | } 45 | 46 | //这个目前不能用 47 | elseif($type == 'image'){ 48 | return sprintf($xmltpl['image'],$xml->FromUserName,$xml->ToUserName,$time,$data); 49 | } 50 | 51 | return self::response($xml,'主人不在家,如果有什么事的话,你可以直接对[小u]说。'); 52 | } 53 | 54 | /** 55 | **已知两点的经纬度,计算两点间的距离(公里) 56 | **/ 57 | static function getDistance($lat1,$lng1,$lat2,$lng2){ 58 | $lat1=(double)$lat1; 59 | $lat2=(double)$lat2; 60 | $lng1=(double)$lng1; 61 | $lng2=(double)$lng2; 62 | $EARTH_RADIUS=6378.137; 63 | $radLat1=$lat1*pi()/180.0; 64 | $radLat2=$lat2*pi()/180.0; 65 | $a=$radLat1-$radLat2; 66 | $b=$lng1*pi()/180.0-$lng2*pi()/180.0; 67 | $s=2*asin(sqrt(pow(sin($a/2),2)+ 68 | cos($radLat1)*cos($radLat2)*pow(sin($b/2),2))); 69 | $s=$s*$EARTH_RADIUS; 70 | $s=round($s*10000)/10000; 71 | return number_format($s,2,'.',''); 72 | } 73 | 74 | static function requestMethod() { 75 | return $_SERVER['REQUEST_METHOD']; 76 | } 77 | 78 | static function isGET() { 79 | return self::requestMethod() == 'GET'; 80 | } 81 | 82 | static function isPOST() { 83 | return self::requestMethod() == 'POST'; 84 | } 85 | 86 | /** 87 | * POST 请求指定URL 88 | */ 89 | static function fpost($url, $post = '', $limit = 0, $cookie = '', $ip = '', $timeout = 15, $block = TRUE) { 90 | $return=''; 91 | $matches=parse_url($url); 92 | !isset($matches['host']) && $matches['host'] = ''; 93 | !isset($matches['path']) && $matches['path'] = ''; 94 | !isset($matches['query']) && $matches['query'] = ''; 95 | !isset($matches['port']) && $matches['port'] = ''; 96 | $host = $matches['host']; 97 | $path = $matches['path'] ? $matches['path'].($matches['query'] ? '?'.$matches['query'] : '') : '/'; 98 | $port = !empty($matches['port']) ? $matches['port'] : 80; 99 | if($post) { 100 | $out = "POST $path HTTP/1.0\r\n"; 101 | $out .= "Accept: */*\r\n"; 102 | $out .= "Accept-Language: zh-cn\r\n"; 103 | $out .= "Content-Type: application/x-www-form-urlencoded\r\n"; 104 | $out .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n"; 105 | $out .= "Host: $host\r\n"; 106 | $out .= 'Content-Length: '.strlen($post)."\r\n"; 107 | $out .= "Connection: Close\r\n"; 108 | $out .= "Cache-Control: no-cache\r\n"; 109 | $out .= "Cookie: $cookie\r\n\r\n"; 110 | $out .= $post; 111 | } 112 | else { 113 | $out = "GET $path HTTP/1.0\r\n"; 114 | $out .= "Accept: */*\r\n"; 115 | $out .= "Accept-Language: zh-cn\r\n"; 116 | $out .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n"; 117 | $out .= "Host: $host\r\n"; 118 | $out .= "Connection: Close\r\n"; 119 | $out .= "Cookie: $cookie\r\n\r\n"; 120 | } 121 | 122 | if(function_exists('fsockopen')) { 123 | $fp = @fsockopen(($ip ? $ip : $host), $port, $errno, $errstr, $timeout); 124 | } 125 | elseif (function_exists('pfsockopen')) { 126 | $fp = @pfsockopen(($ip ? $ip : $host), $port, $errno, $errstr, $timeout); 127 | } 128 | else { 129 | $fp = false; 130 | } 131 | 132 | if(!$fp) { 133 | return ''; 134 | } 135 | else { 136 | stream_set_blocking($fp, $block); 137 | stream_set_timeout($fp, $timeout); 138 | @fwrite($fp, $out); 139 | $status = stream_get_meta_data($fp); 140 | if(!$status['timed_out']) { 141 | while (!feof($fp)) { 142 | if(($header = @fgets($fp)) && ($header == "\r\n" || $header == "\n")) { 143 | break; 144 | } 145 | } 146 | 147 | $stop = false; 148 | while(!feof($fp) && !$stop) { 149 | $data = fread($fp, ($limit == 0 || $limit > 8192 ? 8192 : $limit)); 150 | $return .= $data; 151 | if($limit) { 152 | $limit -= strlen($data); 153 | $stop = $limit <= 0; 154 | } 155 | } 156 | } 157 | @fclose($fp); 158 | return $return; 159 | } 160 | } 161 | 162 | } 163 | 164 | function weatherAPI($Location_X,$Location_Y){ 165 | $map_api_url='http://api.map.baidu.com/geocoder?coord_type=wgs84&location='.$Location_X.','.$Location_Y; 166 | $output=file_get_contents($map_api_url); 167 | $mapxml=simplexml_load_string($output); 168 | $province=str_replace('省','',$mapxml->result->addressComponent->province); 169 | $city=str_replace(array('市','县','区'),array('','',''),$mapxml->result->addressComponent->city); 170 | 171 | if(file_exists('CityID.xml')){ 172 | $wxml=simplexml_load_file('CityID.xml'); 173 | for ($i=0; $i < 34; $i++) { 174 | if($province==$wxml->Province[$i][Name]){ 175 | for ($j=0; $j < count($wxml->Province[$i]->City); $j++) { 176 | if ($city==$wxml->Province[$i]->City[$j][Name]) { 177 | $cityID=$wxml->Province[$i]->City[$j][ID]; 178 | } 179 | } 180 | } 181 | } 182 | } 183 | else{} 184 | 185 | $weather_api_url='http://m.weather.com.cn/data/'.$cityID.'.html'; 186 | $weather=file_get_contents($weather_api_url); 187 | $wea=json_decode($weather,1); 188 | 189 | $weaData=$wea['weatherinfo']['city']."\n"; 190 | $weaData.='发布日期:'.$wea['weatherinfo']['date_y'].' '.$wea['weatherinfo']['week']."\n"; 191 | $weaData.='今日气温:'.$wea['weatherinfo']['temp1'].'/'.$wea['weatherinfo']['tempF1']."\n"; 192 | $weaData.='天气:'.$wea['weatherinfo']['weather1']."\n"; 193 | $weaData.='状态:'.$wea['weatherinfo']['index']."\n"; 194 | $weaData.='建议:'.$wea['weatherinfo']['index_d']."\n"; 195 | $weaData.='风向风力:'.$wea['weatherinfo']['wind1']."\n"; 196 | $weaData.='紫外线:'.$wea['weatherinfo']['index_uv']."\n"; 197 | $weaData.='洗车指数:'.$wea['weatherinfo']['index_xc']."\n"; 198 | $weaData.='旅游指数:'.$wea['weatherinfo']['index_tr']."\n"; 199 | $weaData.='舒适指数:'.$wea['weatherinfo']['index_co']."\n"; 200 | $weaData.='晨练指数:'.$wea['weatherinfo']['index_cl']."\n"; 201 | $weaData.='晾晒指数:'.$wea['weatherinfo']['index_ls']."\n"; 202 | $weaData.='感冒指数:'.$wea['weatherinfo']['index_ag']."\n"; 203 | $weaData.="\n".'未来几天天气'."\n"; 204 | $weaData.='明日:'.$wea['weatherinfo']['temp2'].'/'.$wea['weatherinfo']['tempF2']."\n"; 205 | $weaData.=$wea['weatherinfo']['weather2']."\n"; 206 | $weaData.=$wea['weatherinfo']['wind2']."\n"; 207 | $weaData.='第三日:'.$wea['weatherinfo']['temp3'].'/'.$wea['weatherinfo']['tempF3']."\n"; 208 | $weaData.=$wea['weatherinfo']['weather3']."\n"; 209 | $weaData.=$wea['weatherinfo']['wind3']."\n"; 210 | $weaData.='第四日:'.$wea['weatherinfo']['temp4'].'/'.$wea['weatherinfo']['tempF4']."\n"; 211 | $weaData.=$wea['weatherinfo']['weather4']."\n"; 212 | $weaData.=$wea['weatherinfo']['wind4']."\n"; 213 | $weaData.='第五日:'.$wea['weatherinfo']['temp5'].'/'.$wea['weatherinfo']['tempF5']."\n"; 214 | $weaData.=$wea['weatherinfo']['weather5']."\n"; 215 | $weaData.=$wea['weatherinfo']['wind5']."\n"; 216 | $weaData.='第六日:'.$wea['weatherinfo']['temp6'].'/'.$wea['weatherinfo']['tempF6']."\n"; 217 | $weaData.=$wea['weatherinfo']['weather6']."\n"; 218 | $weaData.=$wea['weatherinfo']['wind6']."\n"; 219 | 220 | return $weaData; 221 | } 222 | 223 | function translateAPI($words){ 224 | $data=$words."\n"; 225 | $words=urlencode($words); 226 | 227 | $fanyi_api_url='http://fanyi.youdao.com/openapi.do?keyfrom=urinxs&key=836837635&type=data&doctype=json&version=1.1&q='; 228 | $transjson=file_get_contents($fanyi_api_url.$words); 229 | $translated=json_decode($transjson,1); 230 | $errorcode=$translated['errorCode']; 231 | 232 | if (isset($errorcode)) { 233 | switch ($errorcode) { 234 | case 0: 235 | $data.='翻译:'.$translated['translation'][0]."\n"; 236 | $data.='基本词典:'."\n"; 237 | $data.='读音:['.$translated['basic']['phonetic'].']'."\n"; 238 | 239 | foreach ($translated['basic']['explains'] as $value) { 240 | $explains.=$value."\n"; 241 | } 242 | $data.='解释:'."\n".$explains."\n";// 243 | 244 | $data.='网络释义:'."\n"; 245 | foreach ($translated['web'] as $arr1) { 246 | $webdata.=$arr1['key']."\n"; 247 | foreach ($arr1['value'] as $value) { 248 | $webdata.=$value.' '; 249 | } 250 | $webdata.="\n"; 251 | } 252 | $data.=$webdata; 253 | break; 254 | 255 | case 20: 256 | $data='要翻译的文本过长'; 257 | break; 258 | 259 | case 30: 260 | $data='无法进行有效的翻译'; 261 | break; 262 | 263 | case 40: 264 | $data='不支持的语言类型'; 265 | break; 266 | 267 | case 50: 268 | $data='无效的key'; 269 | break; 270 | 271 | default: 272 | $data='出现异常'; 273 | break; 274 | } 275 | } 276 | return $data; 277 | } 278 | 279 | function en_sentenceAPI(){ 280 | $en_api_url='http://dict.hjenglish.com/rss/daily/en'; 281 | $en_output=file_get_contents($en_api_url); 282 | $enxml=simplexml_load_string($en_output); 283 | 284 | $en_sentence=$enxml->channel->item->en_sentence."\n"; 285 | $en_sentence.=$enxml->channel->item->cn_sentence."\n"; 286 | $en_sentence.='Update time:'.$enxml->channel->pubDate."\n"; 287 | $en_sentence.='朗读'; 288 | return $en_sentence; 289 | } 290 | 291 | function simsimi($word){ 292 | $s = new SaeStorage(); 293 | $key=$s->read('simsimi','simi.txt'); 294 | $simsimi_api_url='http://sandbox.api.simsimi.com/request.p?key='.$key.'&lc=ch&ft=0.0&text='.$word; 295 | $simjson=file_get_contents($simsimi_api_url); 296 | $simsimi=json_decode($simjson,1); 297 | 298 | switch ($simsimi['result']) { 299 | case '100': 300 | $backws=$simsimi['response']; 301 | break; 302 | 303 | case '400': 304 | $backws='400-'.$simsimi['msg']; 305 | break; 306 | 307 | case '401': 308 | $backws='401-'.$simsimi['msg']."\n".'小u is sleeping now.请不要吵醒我!'; 309 | break; 310 | 311 | case '404': 312 | if(preg_match('/。。/i', $word)) { 313 | $backws='(*^__^*) 嘻嘻……'.'/:B-)'; 314 | } 315 | else{$backws='404';} 316 | break; 317 | 318 | case '500': 319 | $backws='500-'.$simsimi['msg']."\n".'服务器出问题,小u表示无能为力。'; 320 | break; 321 | 322 | default: 323 | $backws='404'; 324 | break; 325 | } 326 | $backws=str_replace(array('贱鸡','小黄鸡','黄鸡','xhjchat'), array('小u','小u','小u','urinx'), $backws); 327 | if(preg_match('/微信/i',$backws)) { 328 | $backws='该消息被防火长城,不对。。是被小u消音了,原因你懂的。。保护你的身体,有爱你的健康'.'/:B-)'; 329 | $backws.="\n如果你发现有害身心健康的信息,请及时截图报告小u,小u全力进行封杀。"; 330 | } 331 | return $backws; 332 | } 333 | 334 | function bing($query,$type){ 335 | $accountKey='T7m/69vghK1gjxMTPkGqX5Lfz9fn50YXTc7S6ykGTdY'; 336 | 337 | $ServiceRootURL='https://api.datamarket.azure.com/Bing/Search/'; 338 | $WebSearchURL=$ServiceRootURL.$type.'?$format=json&Query='; 339 | $context=stream_context_create( 340 | array( 341 | 'http' => array( 342 | 'request_fulluri' => true, 343 | 'header' => "Authorization: Basic ".base64_encode($accountKey.":".$accountKey) 344 | ) 345 | )); 346 | $request=$WebSearchURL.urlencode('\''.$query.'\''); 347 | 348 | $response=file_get_contents($request, 0, $context); 349 | $jsonobj=json_decode($response); 350 | 351 | $arr=array(); 352 | if ($type=='Image') { 353 | foreach($jsonobj->d->results as $value){ 354 | array_push($arr, $value->Thumbnail->MediaUrl); 355 | } 356 | } 357 | elseif($type=='Web'){ 358 | foreach($jsonobj->d->results as $value){ 359 | array_push($arr, array('title'=>$value->Title,'description'=>$value->Description,'url'=>$value->Url)); 360 | } 361 | } 362 | return $arr; 363 | } 364 | 365 | function wiki($srsearch,$lng){ 366 | if (ctype_alnum($srsearch)) { 367 | $lng='en'; 368 | } 369 | else{ 370 | $lng='zh'; 371 | $srsearch=urlencode($srsearch); 372 | } 373 | $wiki_api_url='http://'.$lng.'.wikipedia.org/w/api.php?action=query&list=search&srwhat=text&format=xml&srsearch='.$srsearch; 374 | $result=file_get_contents($wiki_api_url); 375 | $xmldata=simplexml_load_string($result); 376 | 377 | $arr=array(); 378 | foreach ($xmldata->query->search->p as $value) { 379 | $value['snippet']=str_replace(array('','','','',' '), '', $value['snippet']); 380 | array_push($arr,array('title'=>$value['title'],'snippet'=>$value['snippet'])); 381 | } 382 | return $arr; 383 | } 384 | 385 | function jokes(){ 386 | $jokes_api_url='http://www.djdkx.com/open/randxml'; 387 | $result=file_get_contents($jokes_api_url); 388 | $xmldata=simplexml_load_string($result,'SimpleXMLElement',LIBXML_NOCDATA); 389 | $xmldata->content=str_replace(array(' ','
'), '', trim($xmldata->content)); 390 | return $xmldata->content; 391 | } 392 | 393 | function baiduNews(){ 394 | $word='最新'; 395 | $num=5; 396 | $baidunews_api_url='http://news.baidu.com/ns?tn=newsfcu&from=news&cl=2&ct=0&rn='.$num.'&word='.$word; 397 | $result=file_get_contents($baidunews_api_url); 398 | $reg='#[^\s>]+)"[^>]*target="_blank">(?[^>]+)</a> <span>(?<resrc>[^>]+)</span>#i'; 399 | preg_match_all($reg, $result, $matches); 400 | $matches[resrc]=str_replace(' ',' ',$matches[resrc]); 401 | $data=array(array('title'=>'关心国家大事,了解天下奇谈,小u给你播报新闻啦!')); 402 | for ($i=0; $i < 5; $i++) { 403 | $matches[title][$i]=iconv('gbk','utf-8',$matches[title][$i]); 404 | $matches[resrc][$i]=iconv('gbk','utf-8',$matches[resrc][$i]); 405 | array_push($data,array('title'=>$matches[title][$i]."\n".'------------------------------------------','note'=>$matches[resrc][$i],'link'=>$matches[url][$i])); 406 | } 407 | return $data; 408 | } 409 | 410 | function doubanMovies($word){ 411 | $list=array('top10'=>'top250','北美票房榜'=>'us_box'); 412 | $doubanMovie_api_url='http://api.douban.com/v2/movie/'; 413 | if (!isset($list[$word])) { 414 | $result=file_get_contents($doubanMovie_api_url.'search?q='.$word); 415 | } 416 | else{ 417 | $result=file_get_contents($doubanMovie_api_url.$list[$word]); 418 | } 419 | $jsondata=json_decode($result); 420 | $movie=array(); 421 | foreach ($jsondata->subjects as $value) { 422 | if ($list[$word]=='us_box') { 423 | $value=$value->subject; 424 | } 425 | array_push($movie, array('average'=>$value->rating->average,'title'=>$value->title,'original_title'=>$value->original_title,'year'=>$value->year,'images'=>$value->images,'alt'=>$value->alt,'id'=>$value->id)); 426 | } 427 | return $movie; 428 | } 429 | 430 | function doubanMovie($id){ 431 | $doubanMovie_api_url='http://api.douban.com/v2/movie/subject/'; 432 | $result=file_get_contents($doubanMovie_api_url.$id); 433 | $jsondata=json_decode($result); 434 | $movie=array('average'=>$jsondata->rating->average,'year'=>$jsondata->year,'images'=>$jsondata->images->large,'mobile_url'=>$jsondata->mobile_url,'title'=>$jsondata->title,'genres'=>$jsondata->genres,'countries'=>$jsondata->countries,'summary'=>$jsondata->summary,'aka'=>$jsondata->aka,'directors'=>$jsondata->directors,'casts'=>$jsondata->casts); 435 | return $movie; 436 | } 437 | 438 | function doubanBooks($word){ 439 | $doubanBook_api_url='https://api.douban.com/v2/book/search?count=5&q='; 440 | $result=file_get_contents($doubanBook_api_url.$word); 441 | $jsondata=json_decode($result); 442 | $book=array(); 443 | foreach ($jsondata->books as $value) { 444 | array_push($book, array('average'=>$value->rating->average,'author'=>$value->author,'pubdate'=>$value->pubdate,'images'=>$value->images,'alt'=>$value->alt,'title'=>$value->title,'publisher'=>$value->publisher,'summary'=>$value->summary,'price'=>$value->price,'tags'=>$value->tags,'id'=>$value->id)); 445 | } 446 | return $book; 447 | } 448 | 449 | function doubanBook($id){ 450 | $doubanBook_api_url='https://api.douban.com/v2/book/'; 451 | $result=file_get_contents($doubanBook_api_url.$id); 452 | $jsondata=json_decode($result); 453 | $book=array('average'=>$jsondata->rating->average,'author'=>$jsondata->author,'pubdate'=>$jsondata->pubdate,'images'=>$jsondata->images->large,'alt'=>$jsondata->alt,'title'=>$jsondata->title,'publisher'=>$jsondata->publisher,'summary'=>$jsondata->summary,'price'=>$jsondata->price,'tags'=>$jsondata->tags); 454 | return $book; 455 | } 456 | 457 | function doubanMusics($word){ 458 | $doubanMusic_api_url='https://api.douban.com/v2/music/search?count=5&q='; 459 | $result=file_get_contents($doubanMusic_api_url.$word); 460 | $jsondata=json_decode($result); 461 | $music=array(); 462 | foreach ($jsondata->musics as $value) { 463 | array_push($music, array('average'=>$value->rating->average,'author'=>$value->author,'pubdate'=>$value->attrs->pubdate,'image'=>$value->image,'alt'=>$value->alt,'title'=>$value->title,'publisher'=>$value->attrs->publisher,'singer'=>$value->attrs->singer,'version'=>$value->attrs->version,'id'=>$value->id)); 464 | } 465 | return $music; 466 | } 467 | 468 | function doubanMusic($id){ 469 | $doubanMusic_api_url='https://api.douban.com/v2/music/'; 470 | $result=file_get_contents($doubanMusic_api_url.$id); 471 | $jsondata=json_decode($result); 472 | $music=array('average'=>$jsondata->rating->average,'author'=>$jsondata->author,'summary'=>$jsondata->summary,'image'=>$jsondata->image,'mobile_link'=>$jsondata->mobile_link,'title'=>$jsondata->title,'id'=>$jsondata->id,'publisher'=>$jsondata->attrs->publisher,'singer'=>$jsondata->attrs->singer,'version'=>$jsondata->attrs->version,'pubdate'=>$jsondata->attrs->pubdate,'tags'=>$jsondata->tags); 473 | return $music; 474 | } 475 | 476 | function dream($word){ 477 | $dream_api_url='http://api2.sinaapp.com/search/dream/?appkey=2989441965&appsecert=4e5e32eb22617e691165e16d6a152a18&reqtype=text&keyword='.urlencode($word); 478 | $result=file_get_contents($dream_api_url); 479 | $dream=json_decode($result); 480 | return $dream->text->content; 481 | } 482 | 483 | function phoneNumber($num){ 484 | $phoneNum_api_url='http://cz.115.com/?ct=index&ac=get_mobile_local&mobile='.$num; 485 | $result=str_replace(array('(',')'), '', file_get_contents($phoneNum_api_url)); 486 | $phone=json_decode($result); 487 | $phoneNum=array('province'=>$phone->province,'city'=>$phone->city,'corp'=>$phone->corp); 488 | return $phoneNum; 489 | } 490 | 491 | function lotterySearch($word){ 492 | $lottery_api_url='http://api2.sinaapp.com/search/lottery/?appkey=2989441965&appsecert=4e5e32eb22617e691165e16d6a152a18&reqtype=text&keyword='.urlencode($word); 493 | $result=file_get_contents($lottery_api_url); 494 | $lottery=json_decode($result); 495 | return $lottery->text->content; 496 | } 497 | function lottery(){ 498 | $lotteryArray=array('双色球','七乐彩','大乐透','七星彩','排列3','排列5','胜负彩','六场半全场'); 499 | foreach ($lotteryArray as $value) { 500 | $lottery.=lotterySearch($value)."\n"; 501 | } 502 | return $lottery; 503 | } 504 | 505 | function picRec($url){ 506 | $picRec_api_url='http://api2.sinaapp.com/recognize/picture/?appkey=2989441965&appsecert=4e5e32eb22617e691165e16d6a152a18&reqtype=text&keyword='.$url; 507 | $result=file_get_contents($picRec_api_url); 508 | $pic=json_decode($result); 509 | return $pic->text->content; 510 | } 511 | 512 | function python($cmd){ 513 | $url='http://urinx.sinaapp.com/'.$cmd; 514 | $result=file_get_contents($url); 515 | return $result; 516 | } 517 | 518 | function stackoverflow(){ 519 | $num=5; 520 | $stack_url='http://stackoverflow.com/'; 521 | $result=file_get_contents($stack_url); 522 | 523 | $mainreg='#<div[\s]+onclick="window.location.href=\'/questions/(\d+/.+)\'"[\s]+class="cp"[\s]*>#i'; 524 | $votereg='#<div class="mini-counts">(\d+)</div>[\s]+<div>votes</div>#i'; 525 | $answerreg='#<div class="mini-counts">(\d+)</div>[\s]+<div>answers</div>#i'; 526 | $viewreg='#<div class="mini-counts">(\d+)</div>[\s]+<div>view[s]*</div>#i'; 527 | 528 | $arr=array($mainreg,$votereg,$answerreg,$viewreg); 529 | $res=array(); 530 | $data=array(array('title'=>'Stack Overflow','cover'=>$web.'/img/meizi/'.mt_rand(0,9).'.jpg')); 531 | $raw=array(); 532 | 533 | foreach ($arr as $reg){ 534 | preg_match_all($reg, $result, $matches); 535 | array_push($res,$matches[1]); 536 | } 537 | 538 | for ($i=0; $i < 5; $i++) { 539 | list($id,$title)=preg_split('#/#',$res[0][$i]); 540 | array_push($raw,array('id'=>$id,'title'=>$title,'vote'=>$res[1][$i],'answer'=>$res[2][$i],'view'=>$res[3][$i])); 541 | } 542 | 543 | for ($i=0; $i < 5; $i++) { 544 | array_push($data, array('title'=>str_replace('-',' ',$raw[$i]['title']),'note'=>'votes:'.$raw[$i]['vote'].' answers:'.$raw[$i]['answer'].' views:'.$raw[$i]['view'],'link'=>'http://stackoverflow.com/questions/'.$raw[$i]['id'])); 545 | } 546 | return $data; 547 | } 548 | 549 | function bilibili(){ 550 | $data=array(array('title'=>'Bilibili','cover'=>$web.'/img/bili/'.mt_rand(0,10).'.jpg')); 551 | $res=array(); 552 | $category=array('1'=>'动画','3'=>'音乐','4'=>'游戏','5'=>'娱乐','11'=>'专辑','13'=>'新番连载'); 553 | foreach ($category as $key=>$value){ 554 | $url='http://www.bilibili.tv/rss-'.$key.'.xml'; 555 | $result=file_get_contents($url); 556 | $xml=simplexml_load_string($result,'SimpleXMLElement', LIBXML_NOCDATA); 557 | array_push($res,array('title'=>$xml->channel->item->title,'description'=>$xml->channel->item->description,'category'=>$value,'link'=>$xml->channel->item->link)); 558 | } 559 | for ($i=0; $i < count($res); $i++) { 560 | array_push($data, array('title'=>$res[$i]['category'].':'.$res[$i]['title'],'note'=>$res[$i]['description'],'link'=>$res[$i]['link'])); 561 | } 562 | return $data; 563 | } 564 | 565 | function rss($keyws){ 566 | $url_arr=array('0x50sec'=>'http://www.0x50sec.org/feed/','乌云'=>'http://www.wooyun.org/feeds/submit','91ri'=>'http://www.91ri.org/feed','设计达人'=>'http://www.shejidaren.com/feed','运维'=>'http://www.nginx.cn/feed','freebuf'=>'http://www.freebuf.com/feed','matrix67'=>'http://www.matrix67.com/blog/feed','读书'=>'http://rss.sina.com.cn/book/history_rank.xml','松鼠'=>'http://songshuhui.net/feed','爱范'=>'http://www.ifanr.com/feed','人人影视'=>'http://www.yyets.com/rss/feed/'); 567 | $reg=array('乌云'=>'#<strong>简要描述:</strong><br/>(.+)<br/><strong>详细说明#i','设计达人'=>'#<img src="(http://images\.shejidaren\.com/wp-content/uploads/.+)"[\s]+class#i','爱范'=>'#(.+)题图来自#i','人人影视'=>'#<img[\s]+src="(http://res\.yyets\.com/ftp/.+\.jpg)"[\s]+/>#i',''=>'',); 568 | $data=array(); 569 | $result=file_get_contents($url_arr[$keyws]); 570 | $xml=simplexml_load_string($result,'SimpleXMLElement', LIBXML_NOCDATA); 571 | 572 | for ($i=0; $i < 6; $i++) { 573 | $n=''; 574 | $c=''; 575 | if (isset($reg[$keyws])) { 576 | preg_match_all($reg[$keyws],$xml->channel->item[$i]->description, $matches); 577 | switch ($keyws) { 578 | case '乌云': 579 | $n='简要描述:'.$matches[1][0]; 580 | break; 581 | 582 | case '设计达人': 583 | $c=$matches[1][0]; 584 | break; 585 | 586 | case '爱范': 587 | $n=$matches[1]; 588 | $c=$xml->channel->item[$i]->image; 589 | break; 590 | 591 | case '人人影视': 592 | $n=$xml->channel->item[$i]->description; 593 | preg_match_all($reg[$keyws], file_get_contents($xml->channel->item[$i]->link), $matches); 594 | $c=$matches[1][0]; 595 | break; 596 | 597 | default: 598 | # code... 599 | break; 600 | } 601 | } 602 | else{ 603 | $n=htmlspecialchars_decode(str_replace(' ','',$xml->channel->item[$i]->description)); 604 | } 605 | array_push($data,array('title'=>$xml->channel->item[$i]->title,'note'=>$n,'link'=>$xml->channel->item[$i]->link,'cover'=>$c)); 606 | } 607 | 608 | return $data; 609 | } 610 | ?> -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/> 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #weChat_php 2 | 3 | 自己的一个微信后台代码 4 | =================== 5 | 6 | ![]('http://mmbiz.qpic.cn/mmbiz/icv3Y2jicj1r5zVuHbibOR7ztYtd6tl8zShn0ibKxLCavToicWMuQ8iaJ9wiaK5AqB19KdDOvGXvPQibKfnFABtWIVpwtQ/0?wxfrom=5') 7 | 8 | 欢迎大家关注我的微信公众号:[urinx](http://weixin.sogou.com/gzh?openid=oIWsFt6BhfHwKUIyFvNp6A6JEsGM) 9 | --------------------------- 10 | 11 | ###文件说明 12 | >1.0 13 | >>//主文件 14 | >> 15 | >>index.php 16 | >> 17 | >>//整合各api 18 | >> 19 | >>wechat-api.php 20 | >> 21 | >>//该文件夹下放的是各api的演示ph 22 | >> 23 | >>./api/ 24 | > 25 | >2.0 based on SAE 26 | >>//主文件 27 | >> 28 | >>index.php 29 | >> 30 | >>//整合各api 31 | >> 32 | >>wechat-api.php 33 | >> 34 | >>//该文件夹下放的是各api的演示ph 35 | >> 36 | >>./api/ 37 | >> 38 | >>//python脚本提供的api 39 | >> 40 | >>./urinx.sinaapp.com 41 | 42 | ###实现的功能 43 | [小u] 44 | :查看基本信息,以及功能介绍和近期更新 45 | 46 | [帮助] 47 | :查看使用帮助 48 | 49 | [查水表] 50 | :查询寝室的水电费(华科) 51 | 52 | [每日一句] 53 | :每天更新一句英语,中英对照 54 | 55 | [点歌] 56 | :为大家推荐好的歌曲 57 | 58 | [笑话] 59 | :每次返回一个笑话 60 | 61 | [新闻] 62 | :每次返回5条新闻 63 | 64 | [彩票] 65 | :每天的彩票信息一目了然 66 | 67 | [stack] 68 | :查看stack overflow上的最新内容 69 | 70 | [>python] 71 | :在微信上使用python终端 72 | 73 | [>mysql] 74 | :在微信上简单的操作后台mysql 75 | 76 | [>sqli] 77 | :练习sql injection用,目前完善中... 78 | 79 | [bilibili] 80 | :给你提供最新的b站资讯 81 | 82 | [人人影视] 83 | :给那些追美剧日剧看片的孩子的必备! 84 | 85 | [松鼠] 86 | :每一个孩纸心目中都有属于自己的科学松鼠会 87 | 88 | [爱范] 89 | :爱科技,爱爱范,在这里看到全球最新的科技资讯 90 | 91 | [读书] 92 | :品茗读书,人生一大乐事,排行榜的每一本书,不知你曾否读过,不留遗憾,享受人生 93 | 94 | [matrix67] 95 | :那些年我们一起看过他的博客,他启发了一代又一代有志青年,发现数学的美妙,探索无穷的智慧 96 | 97 | [freebuf] 98 | :黑客与画家,技术与艺术。在这里,你能学到更多 99 | 100 | [运维] 101 | :好的架构减少运维,好的运维反哺架构。架构狮必看! 102 | 103 | [设计达人] 104 | :爱设计,爱分享。玩转前端,欣赏最美的艺术 105 | 106 | [91ri] 107 | :网络安全攻防研究室,干货必备 108 | 109 | [乌云] 110 | :寻找最新的提交漏洞 111 | 112 | [0x50sec] 113 | :Web安全手册,专注Web安全 114 | 115 | [鬼故事] 116 | :小u精心为你准备的鬼故事哟,超吓人的说,午夜凌晨看一看好阔怕。。 117 | 118 | [短篇鬼故事] 119 | :让喜欢鬼故事的读者在这里快速感受到不一样的诡异,篇幅较短,适合想快速阅读完鬼故事的朋友 120 | 121 | [长篇鬼故事] 122 | :篇幅较长,情节曲折,剧情跌宕起伏,一个好的长篇鬼故事,就是一次刺激的心灵旅行 123 | 124 | [校园鬼故事] 125 | :这里的鬼故事都与校园有关或者是发生在学校里的鬼故事,让喜爱鬼故事的读者了解更多的校园鬼故事 126 | 127 | [医院鬼故事] 128 | :我们在恐怖鬼片里也常见到发生在医院里的鬼故事事件,但有更多的鬼故事等待你去发现,一起来看医院鬼故事吧 129 | 130 | [家里鬼故事] 131 | :发生在家里的鬼故事比较多,快来看看都有哪些恐怖的家里鬼故事吧 132 | 133 | [民间鬼故事] 134 | :中国民间鬼故事来源于古代的传奇小说,和现代的民间流传奇闻中。同时鬼故事网也搜集了国外吸血鬼的故事,欢迎大家阅读民间鬼故事 135 | 136 | [灵异事件] 137 | :灵异事件在世界各地每个角落经常发生,你身边是否也有灵异事件呢?灵异事件频道最全面的记录最新真实灵异事件,中国灵异事件,国外灵异事件,灵异鬼故事大全,带你进入灵异鬼故事的世界 138 | 139 | [中国灵异] 140 | :整理最全的中国真实灵异事件大全,将会带您走入从古到今发生在中国的灵异事件 141 | 142 | [灵异知识库] 143 | :灵异知识大全,例如如何避鬼,招鬼,阵法、鬼魂禁忌等等详细内容 144 | 145 | [推理小说] 146 | :内容涵盖惊悚、悬疑、侦探、武侠等,一切以推理为出发点,挑战思维极限,考验缜密的逻辑。风格:先锋、酷炫、丰富多彩、可读性强。杂志力推原创,名家新秀携手亮相,联手打造包罗万象,令人耳目一新、心驰神往的异度空间 147 | 148 | [听鬼故事] 149 | :张震讲鬼故事,吓死你不偿命 150 | 151 | 翻译:发送"#+你要翻译的内容",即可收到详细结果,如果是英文,可以直接发送英文。例如:doofus,#doofus,#笨蛋 152 | 153 | 天气+找小u:点击下面的“+”,发送你的的位置信息,即可收到本地的天气预报,并且看到你和小u的距离 154 | 155 | bing搜索:发送"%+你要搜索的内容",即可收到详细结果,例如:%dweeb 156 | 157 | 维基百科:发送"&+你要百科的内容",根据你的输入自动判断查询中文维基或是英文,例如:&spaz 158 | 159 | 二维码:发送"*+你要生成的内容",返回生成的二维码。例如:*嘟嘟噜 160 | 161 | md5加密:发送"md5:+你要加密的文字",返回32位的hash。例如:md5:123456 162 | 163 | 豆瓣<br/> 164 | 1.书<br/> 165 | bs:关键字 搜索相关的书籍<br/> 166 | b:书名 查看详细内容<br/> 167 | 2.音乐<br/> 168 | ms:关键字 搜索相关的音乐<br/> 169 | m:音乐名 查看详细内容<br/> 170 | 3.电影<br/> 171 | vs:关键字 搜索相关的电影<br/> 172 | v:电影名 查看详细内容<br/> 173 | 174 | 动态:发送":+你要分享的文字"即可,大家可以回复[动态]查看。例如 :这是我发的第一个说说 175 | 176 | 美女识别:上传图片,看看小u的眼力吧 177 | 178 | 周公解梦:发送"梦到xxx",小u来预测吉凶,例如"梦到小u" 179 | 180 | 手机号码查询:直接发送手机号 181 | 182 | Note:[xx]内的内容xx是指你发送的 183 | 184 | ###主页 185 | http://urinx.github.io/ 186 | 187 | ###contact me 188 | >QQ:1336006643 189 | > 190 | >Wechat:google-2 191 | --------------------------------------------------------------------------------