From 9238825e1bc4a774040d698728f2cc09512396c1 Mon Sep 17 00:00:00 2001 From: zhaoxiang Date: Thu, 23 Aug 2018 11:37:10 +0800 Subject: [PATCH] =?UTF-8?q?modified=20=E6=B7=BB=E5=8A=A0=E9=83=A8=E5=88=86?= =?UTF-8?q?WEB=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/util/StrRandom.php | 46 ++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/application/util/StrRandom.php b/application/util/StrRandom.php index 22b7c2d..5735ee1 100644 --- a/application/util/StrRandom.php +++ b/application/util/StrRandom.php @@ -58,4 +58,50 @@ class StrRandom { return $ip = long2ip(mt_rand($ipLong[$randKey][0], $ipLong[$randKey][1])); } + /** + * 随机生成一个 URL 协议 + * @return mixed + * @author zhaoxiang + */ + public static function randomProtocol() { + $proArr = [ + 'http', + 'ftp', + 'gopher', + 'mailto', + 'mid', + 'cid', + 'news', + 'nntp', + 'prospero', + 'telnet', + 'rlogin', + 'tn3270', + 'wais' + ]; + shuffle($proArr); + + return $proArr[0]; + } + + /** + * + * @author zhaoxiang + */ + public static function randomTld() { + $tldArr = [ + 'com', 'cn', 'xin', 'net', 'top', '在线', + 'xyz', 'wang', 'shop', 'site', 'club', 'cc', + 'fun', 'online', 'biz', 'red', 'link', 'ltd', + 'mobi', 'info', 'org', 'edu', 'com.cn', 'net.cn', + 'org.cn', 'gov.cn', 'name', 'vip', 'pro', 'work', + 'tv', 'co', 'kim', 'group', 'tech', 'store', 'ren', + 'ink', 'pub', 'live', 'wiki', 'design', '中文网', + '我爱你', '中国', '网址', '网店', '公司', '网络', '集团', 'app' + ]; + shuffle($tldArr); + + return $tldArr[0]; + } + }