<?php header("content-Type: text/html; charset=utf-8"); function lotterySearch($word) { $lottery_api_url = 'http://api2.sinaapp.com/search/lottery/?appkey=2989441965&appsecert=4e5e32eb22617e691165e16d6a152a18&reqtype=text&keyword=' . urlencode($word); $result = file_get_contents($lottery_api_url); $lottery = json_decode($result); return $lottery->text->content; } function lottery() { $lotteryArray = array('双色球', '七乐彩', '大乐透', '七星彩', '排列3', '排列5', '胜负彩', '六场半全场'); foreach ($lotteryArray as $value) { $lottery .= lotterySearch($value) . "\n"; } return $lottery; } $lottery = lottery(); print_r($lottery);
<?php error_reporting(E_ALL); ini_set("display_errors", "On"); require_once 'functions.php'; $square = squared_numbers(15); $fibo = fibonacci(100); $name = name('greetings', 'gertrude'); $lotto = lottery(); var_dump($lotto);
$data = $xiaoU; } elseif ($content == '小幽') { $data = '在!'; } elseif ($content == '帮助') { $data = array(array('title' => '小u帮助指南', 'cover' => $web . 'icv3Y2jicj1r5zVuHbibOR7ztYtd6tl8zShn0ibKxLCavToicWMuQ8iaJ9wiaK5AqB19KdDOvGXvPQibKfnFABtWIVpwtQ/0?wxfrom=5', 'link' => $mp . '?__biz=MzA3MjAzMTgyMA==&mid=10000058&idx=2&sn=aa817cfb12b9117cb518d4ab268d28b9#rd')); array_push($data, array('title' => $help)); } elseif ($content == '查水表') { $data = '查询电费请点击这里:' . "\n" . '<a href="http://42.120.22.130/dianfei.php">查电费</a>。' . "\n" . '低余电费自动提醒功能请点击这里:' . "\n" . '<a href="http://42.120.22.130:8822/">邮件提醒</a>'; } elseif ($content == '点歌') { $data = array('title' => '你给的甜', 'description' => '何艺纱', 'musicurl' => 'http://data7.5sing.com/T1aMbeBXbT1R47IVrK.mp3', 'HQmusicurl' => 'http://data7.5sing.com/T1aMbeBXbT1R47IVrK.mp3'); } elseif ($content == '每日一句') { $data = en_sentenceAPI(); } elseif ($content == '笑话') { $data = jokes(); } elseif ($content == '彩票') { $data = lottery(); } elseif ($content == '新闻') { $news = baiduNews(); $data = array(); for ($i = 0; $i < 5; $i++) { array_push($data, array('title' => $news[title][$i] . "\n" . '------------------------------------------', 'note' => $news[resrc][$i], 'link' => $news[url][$i])); } } elseif (preg_match('/^(梦到)(.+)/i', $content, $matches)) { $data = dream($matches[2]); } elseif (preg_match('/^(#)(.+)/i', $content, $matches)) { $data = translateAPI($matches[2]); } elseif (preg_match('/^(%)(.+)/i', $content, $matches)) { $bingweb = bing($matches[2], 'Web'); $bingimage = bing($matches[2], 'Image'); $data = array(array('title' => $matches[2], 'note' => '', 'cover' => $bingimage[0], 'link' => '')); //max:7
$xiaoU = array(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'), 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'), 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'), 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')); $biaoqing = array('/::)', '/::~', '/::B', '/::|', '/:8-)', '/::<', '/::$', '/::X', '/::Z', '/::\'(', '/::-|', '/::@', '/::P', '/::D', '/::O', '/::(', '/::+', '/:--b', '/::Q', '/::T', '/:,@P', '/:,@-D', '/::d', '/:,@o', '/::g', '/:|-)', '/::!', '/::L', '/::>', '/::,@', '/:,@f', '/::-S', '/:?', '/:,@x', '/:,@@', '/::8', '/:,@!', '/:!!!', '/:xx', '/:bye', '/:wipe', '/:dig', '/:handclap', '/:&-(', '/:B-)', '/:<@', '/:@>', '/::-O', '/:>-|', '/:P-(', '/::\'|', '/:X-)', '/::*', '/:@x', '/:8*'); $pythonWelcome = 'Python 2.7.5 (default, Aug 25 2013, 00:04:04) [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin Type "help", "copyright", "credits" or "license" for more information.'; $mysqlWelcome = "Welcome to the MySQL monitor. Commands end with ; or \\g.\nServer version: 5.0.45-community-nt MySQL Community Edition (GPL)\nType 'help;' or '\\h' for help. Type '\\c' to clear the buffer."; $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."; $welcome = array($pythonWelcome, $mysqlWelcome, $sqliWelcome); $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" . '-----------------'; $help .= "\n" . '豆瓣' . "\n" . '1.书' . "\n" . ' bs:关键字 搜索相关的书籍' . "\n" . ' b:书名 查看详细内容' . "\n" . '2.音乐' . "\n" . ' ms:关键字 搜索相关的音乐' . "\n" . ' m:音乐名 查看详细内容' . "\n" . '3.电影' . "\n" . ' vs:关键字 搜索相关的电影' . "\n" . ' v:电影名 查看详细内容' . "\n" . '-----------------'; $help .= "\n" . '动态' . "\n" . ':发送":+你要分享的文字"即可,大家可以回复[动态]查看,都可以看到哦。例如 :这是我发的第一个说说' . "\n" . '-----------------'; $help .= "\n" . '美女识别' . "\n" . ':上传图片,看看小u的眼力吧' . "\n" . '-----------------' . "\n" . '周公解梦' . "\n" . ':发送"梦到xxx",小u来预测吉凶,例如"梦到小u"' . "\n" . '-----------------' . "\n" . '手机号码查询' . "\n" . ':直接发送手机号' . "\n" . '-----------------'; $help .= "\n" . '#[xx]内的内容xx是指你发送给小u的'; $waterbiao = '查询电费请点击这里:' . "\n" . '<a href="http://42.120.22.130/dianfei.php">查电费</a>。' . "\n" . '低余电费自动提醒功能请点击这里:' . "\n" . '<a href="http://42.120.22.130:8822/">邮件提醒</a>'; $terminal = array('>python' => 1, '>mysql' => 2, '>sqli' => 3); $keywords = array('小u' => $xiaoU, '点歌' => array('title' => '你给的甜', 'description' => '何艺纱', 'musicurl' => 'http://data7.5sing.com/T1aMbeBXbT1R47IVrK.mp3', 'HQmusicurl' => 'http://data7.5sing.com/T1aMbeBXbT1R47IVrK.mp3'), '每日一句' => en_sentenceAPI(), '笑话' => jokes(), '新闻' => baiduNews(), '动态' => moment(), 'bilibili' => bilibili(), 'stack' => stackoverflow(), '小幽' => '在!', '彩票' => lottery(), '帮助' => $help, '查水表' => $waterbiao); $rss_arr = array('0x50sec' => array('title' => 'Web安全手册,专注Web安全', 'cover' => $web . '/img/0x50sec.png'), '91ri' => array('title' => '网络安全攻防研究室', 'cover' => $web . '/img/91ri.gif'), 'freebuf' => array('title' => 'Freebuf', 'cover' => $web . '/img/freebuf.jpg'), 'matrix67' => array('cover' => $web . '/img/matrix67.png'), '读书' => array('title' => '读书排行榜', 'cover' => $web . '/img/meizi/' . mt_rand(0, 9) . '.jpg'), '松鼠' => array('title' => '科学松鼠会', 'cover' => $web . '/img/songshu.gif'), '爱范' => array('title' => '爱范儿 · Beats of Bits', 'cover' => $web . '/img/ifanr.gif'), '人人影视' => array('title' => '人人影视', 'cover' => $web . '/img/yyets.png'), '设计达人' => array('title' => '设计达人-爱设计,爱分享。', 'cover' => $web . '/img/meizi/' . mt_rand(0, 9) . '.jpg'), '运维' => array('title' => '好的架构减少运维,好的运维反哺架构', 'cover' => $web . '/img/meizi/' . mt_rand(0, 9) . '.jpg'), '乌云' => array('title' => 'wooyun.org 最新提交漏洞', 'cover' => $web . '/img/wooyun.png')); $reg_arr = array('/^(梦到)(.+)/i' => 'dream', '/^(#)(.+)/i' => 'translate', '#(/:)#i' => 'biaoqingbiaoqing', '#^(simi:)(.+)#i' => 'changeSimsimiKey', '#^(md5:)(.+)#i' => 'md5', '/^(\\*)(.+)/i' => 'qrcode', '/^(%)(.+)/i' => 'bingSearch', '/^(&)(.+)/i' => 'wiki', '/^(vs:)(.+)/i' => 'doubanMovie1', '/^(v:)(.+)/i' => 'doubanMovie2', '/^(bs:)(.+)/i' => 'doubanBook1', '/^(b:)(.+)/i' => 'doubanBook2', '/^(ms:)(.+)/i' => 'doubanMusic1', '/^(m:)(.+)/i' => 'doubanMusic2', '/^(:)(.+)/i' => 'moments1', '/^(昵称:)(.+)/i' => 'moments2'); ######################################################## //Define function /*---------------------------------------------------*/ function changeStatu($openid, $num) { $mysql = new SaeMysql(); $result = $mysql->getData("SELECT * FROM python WHERE FromUserName='******'"); if (!$result[0]) { $mysql->runSql("INSERT INTO python(FromUserName,state) VALUES ('{$openid}',{$num})"); } else { $mysql->runSql("UPDATE python SET state={$num} WHERE FromUserName='******'"); } }
case JSON_ERROR_STATE_MISMATCH: echo '无效或异常的 JSON'; break; case JSON_ERROR_CTRL_CHAR: echo '控制字符错误,可能是编码不对'; break; case JSON_ERROR_SYNTAX: echo '语法错误'; break; case JSON_ERROR_UTF8: echo '异常的 UTF-8 字符,也许是因为不正确的编码。'; break; default: echo '未知错误'; break; } return json_decode($result, $isArr); } function getRandomText($text, $len) { $arr = str_split($text); shuffle($arr); $rst = implode("", $arr); return substr($rst, 0, $len); } //test lottery for ($i = 0; $i < $totalTimes; $i++) { lottery(); } //$return='{"result":"0","code":"1","id":0,"path":"","msg":"\u62bd\u5230\u4e86!","prizeNum":5}'; //$data=json_decode($return);
<?php /* Mr. Rahim bought some lottery tickets. The lottery draw has been published and it is said that, if the total sum of the digits in the lottery is a multiple of 7 then they will win 5000 Taka. Write a program to help Mr. Rahim to find out if he won. */ function lottery($digits) { $numbers = str_split($digits); $sum = 0; foreach ($numbers as $val) { $sum += $val; } if ($sum % 7 == 0) { echo "Your Lottry Number:" . $digits . " is Devided by 7"; } } lottery(1006);