9 这个代码片段可以方便你禁止某些特定的 IP 地址访问你的网站
摘要:function deny() { if (!file_exists('blocked_ips.txt')) { $deny_ips = array( '127.0.0.1', '192.168.1.1', '83.76.27.9', '192.168.1.163' ); } else { $deny_ips = f...
阅读全文
posted @
2017-06-06 17:23
泪滴
阅读(181)
推荐(0)
8 URL 字符串就可以自动的转换为超链接
摘要:function makeClickableLinks($text) { $text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_+.~#?&//=]+)', '\1', $text); $text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_+.~#?&//=]+)'...
阅读全文
posted @
2017-06-06 17:22
泪滴
阅读(176)
推荐(0)
6 验证邮箱地址
摘要:function is_validemail($email) { $check = 0; if (filter_var($email, FILTER_VALIDATE_EMAIL)) { $check = 1; } return $check; }
阅读全文
posted @
2017-06-06 17:21
泪滴
阅读(115)
推荐(0)
7 获取用户的真实的IP
摘要:function getRealIpAddr() { if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { //to check ip is pass from pro...
阅读全文
posted @
2017-06-06 17:21
泪滴
阅读(103)
推荐(0)
获取任意 Web 页面的 HTML 代码
摘要:function display_sourcecode($url) { $lines = file($url); $output = ""; foreach ($lines as $line_num => $line) { // loop thru each line and prepend line numbers $output .= "Line #{$line_...
阅读全文
posted @
2017-06-06 17:20
泪滴
阅读(183)
推荐(0)
检测用户是那个城市访问你的网站的
摘要:function detect_city($ip) { $default = 'UNKNOWN'; $curlopt_useragent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)'; $url = 'ht...
阅读全文
posted @
2017-06-06 17:19
泪滴
阅读(117)
推荐(0)