This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function genRandomString() { | |
// 验证码的长度 | |
$length = 10; | |
// 验证码包含的字符 | |
$characters = ’0123456789abcdefghijklmnopqrstuvwxyz’; | |
$string = ''; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// $file = "/folder/filename.ext"; | |
function force_download($file) { | |
// 截取文件扩展名 | |
$ext = explode(".", $file); | |
switch($ext[sizeof($ext)-1]) { | |
case 'jar': $mime = "application/java-archive"; break; | |
case 'zip': $mime = "application/zip"; break; | |
case 'jpeg': $mime = "image/jpeg"; break; | |
case 'jpg': $mime = "image/jpg"; break; | |
case 'jad': $mime = "text/vnd.sun.j2me.app-descriptor"; break; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
header("content-type:text/html;charset=utf-8"); | |
//* | |
//文件头 [第一条索引的偏移量 (4byte)] + [最后一条索引的偏移地址 (4byte)] 8字节 | |
//记录区 [结束ip (4byte)] + [地区1] + [地区2] 4字节+不定长 | |
//索引区 [开始ip (4byte)] + [指向记录区的偏移地址 (3byte)] 7字节 | |
//注意:使用之前请去网上下载纯真IP数据库,并改名为 "CoralWry.dat" 放到当前目录下即可. | |
//by 查询吧 www.query8.com | |
//* | |
class ipLocation { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function ClearHtml($content) { | |
$content = preg_replace("/<a[^>]*>/i", "", $content); | |
$content = preg_replace("/<\/a>/i", "", $content); | |
$content = preg_replace("/<div[^>]*>/i", "", $content); | |
$content = preg_replace("/<\/div>/i", "", $content); | |
$content = preg_replace("/<!--[^>]*-->/i", "", $content);//注释内容 | |
$content = preg_replace("/style=.+?['|\"]/i",'',$content);//去除样式 | |
$content = preg_replace("/class=.+?['|\"]/i",'',$content);//去除样式 | |
$content = preg_replace("/id=.+?['|\"]/i",'',$content);//去除样式 | |
$content = preg_replace("/lang=.+?['|\"]/i",'',$content);//去除样式 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isbn_sum($isbn, $len) | |
{ | |
/* | |
* 该函数用于计算ISBN加权和 | |
* 参数说明: | |
* $isbn : isbn码 | |
* $len : isbn码长度 | |
*/ | |
$sum = 0; | |
if ($len == 10) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$url = "代码库 (https://gist.github.com/wdd2007)"; | |
$url = preg_replace("#http://([A-z0-9./-]+)#", '$0', $url); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$d=array( | |
array("a",-20319), | |
array("ai",-20317), | |
array("an",-20304), | |
array("ang",-20295), | |
array("ao",-20292), | |
array("ba",-20283), | |
array("bai",-20265), | |
array("ban",-20257), | |
array("bang",-20242), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* 中文编码集合类库 | |
* | |
* 目前该类库可以实现,简体中文 <-> 繁体中文编码互换,简体中文、繁体中文 -> 拼音单向转换, | |
* 简体中文、繁体中文 <-> UTF8 编码转换,简体中文、繁体中文 -> Unicode单向转换 | |
* | |
* @作者 Hessian(solarischan@21cn.com) | |
* @版本 1.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function hex2rgb( $colour ) { | |
if ( $colour[0] == '#' ) { | |
$colour = substr( $colour, 1 ); | |
} | |
if ( strlen( $colour ) == 6 ) { | |
list( $r, $g, $b ) = array( $colour[0] . $colour[1], $colour[2] . $colour[3], $colour[4] . $colour[5] ); | |
} elseif ( strlen( $colour ) == 3 ) { | |
list( $r, $g, $b ) = array( $colour[0] . $colour[0], $colour[1] . $colour[1], $colour[2] . $colour[2] ); | |
} else { | |
return false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
EXAMPLE: htmlmail('user@domain.com', 'Look ma, HTML e-mails','You just got <a href="http://www.yougotrickrolled.com/">Rick Rolled</a>'); | |
NOTE: $headers is optional, but can be used to set From, CC, etc. | |
*/ | |
function htmlmail($to, $subject, $message, $headers = NULL) | |
{ | |
$mime_boundary = md5(time()); | |
$headers .= "\nMessage-ID: <" . time() . " TheSystem@{$_SERVER['SERVER_NAME']}>\n"; |
OlderNewer