search
Homephp教程php手册php通用检测函数集合第1/3页

php通用检测函数集合第1/3页

Jun 13, 2016 pm 12:28 PM
phpRevisefunctionnot yetDetectionwarnUniversalgather

 
//【警告】:未经许可请勿随便修改 
//----------------------------------------------------------------------------------- 
------- 
//----------------------------------------------------------------------------------- 
------- 
// 
// 【文件名】: c_check.inc 
// 【作 用】: 通用检测函数集 
// 【作 者】: 天灰 
// 
// 【最后修改日期】: 2001/05/11[cxx] 
// 【变量定义规则】:‘C_'=字符型,‘I_'=整型,‘N_'=数字型,‘L_'=布尔型,‘A_'=数 
组型 
//----------------------------------------------------------------------------------- 
------- 
//----------------------------------------------------------------------------------- 
------- 
// ※CheckMoney($C_Money) 检查数据是否是 
99999.99格式 
// ※CheckEmailAddr($C_mailaddr) 判断是否为有效邮件地 
址 
// ※CheckWebAddr($C_weburl) 判断是否为有效网址 
// ※CheckEmpty($C_char) 判断字符串是否为空 
// ※CheckLengthBetween($C_char, $I_len1, $I_len2=100) 判断是否为指定长度内 
字符串 
// ※CheckUser($C_user) 判断是否为合法用户名 
// ※CheckPassword($C_passwd) 判断是否为合法用户密 
码 
// ※CheckTelephone($C_telephone) 判断是否为合法电话号 
码 
// ※CheckValueBetween($N_var, $N_val1, $N_val2) 判断是否是某一范围内的 
合法值 
// ※CheckPost($C_post) 判断是否为合法邮编(固 
定长度) 
// ※CheckExtendName($C_filename,$A_extend) 判断上传文件的扩展名 
// ※CheckImageSize($ImageFileName,$LimitSize) 检验上传图片的大小 
// ※AlertExit($C_alert,$I_goback=0) 非法操作警告并退出 
// ※Alert($C_alert,$I_goback=0) 非法操作警告 
// ※ReplaceSpacialChar($C_char) 特殊字符替换函数 
// ※ExchangeMoney($N_money) 资金转换函数 
// ※WindowLocation($C_url,$C_get="",$C_getOther="") PHP中的window.location 
函数 
//----------------------------------------------------------------------------------- 
------- 


//----------------------------------------------------------------------------------- 
------- 
// 函数名:CheckMoney($C_Money) 
// 作 用:检查数据是否是99999.99格式 
// 参 数:$C_Money(待检测的数字) 
// 返回值:布尔值 
// 备 注:无 
//----------------------------------------------------------------------------------- 
------- 
function CheckMoney($C_Money) 

if (!ereg("^[0-9][.][0-9]$", $C_Money)) return false; 
return true; 

//----------------------------------------------------------------------------------- 
------- 


//----------------------------------------------------------------------------------- 
------- 
// 函数名:CheckEmailAddr($C_mailaddr) 
// 作 用:判断是否为有效邮件地址 
// 参 数:$C_mailaddr(待检测的邮件地址) 
// 返回值:布尔值 
// 备 注:无 
//----------------------------------------------------------------------------------- 
------- 
function CheckEmailAddr($C_mailaddr) 

if (!eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*$", 
$C_mailaddr)) 
//(!ereg("^[_a-zA-Z0-9-]+(.[_a-zA-Z0-9-]+)*@[_a-zA-Z0-9-]+(.[_a-zA-Z0-9-]+)*$", 
$c_mailaddr)) 

return false; 

return true; 

//----------------------------------------------------------------------------------- 
------- 


//----------------------------------------------------------------------------------- 
------- 
// 函数名:CheckWebAddr($C_weburl) 
// 作 用:判断是否为有效网址 
// 参 数:$C_weburl(待检测的网址) 
// 返回值:布尔值 
// 备 注:无 
//----------------------------------------------------------------------------------- 
------- 
function CheckWebAddr($C_weburl) 

if (!ereg("^http://[_a-zA-Z0-9-]+(.[_a-zA-Z0-9-]+)*$", $C_weburl)) 

return false; 

return true; 

//----------------------------------------------------------------------------------- 
------- 


//----------------------------------------------------------------------------------- 
------- 
// 函数名:CheckEmpty($C_char) 
// 作 用:判断字符串是否为空 
// 参 数:$C_char(待检测的字符串) 
// 返回值:布尔值 
// 备 注:无 
//----------------------------------------------------------------------------------- 
------- 
function CheckEmptyString($C_char) 

if (!is_string($C_char)) return false; //是否是字符串类型 
if (empty($C_char)) return false; //是否已设定 
if ($C_char=='') return false; //是否为空 
return true; 

//----------------------------------------------------------------------------------- 
------- 

//----------------------------------------------------------------------------------- 
------- 
// 函数名:CheckLengthBetween($C_char, $I_len1, $I_len2=100) 
// 作 用:判断是否为指定长度内字符串 
// 参 数:$C_char(待检测的字符串) 
// $I_len1 (目标字符串长度的下限) 
// $I_len2 (目标字符串长度的上限) 
// 返回值:布尔值 
// 备 注:无 
//----------------------------------------------------------------------------------- 
------- 
function CheckLengthBetween($C_cahr, $I_len1, $I_len2=100) 

$C_cahr = trim($C_cahr); 
if (strlen($C_cahr) if (strlen($C_cahr) > $I_len2) return false; 
return true; 

//----------------------------------------------------------------------------------- 
------- 

//----------------------------------------------------------------------------------- 
------- 
// 函数名:CheckUser($C_user) 
// 作 用:判断是否为合法用户名 
// 参 数:$C_user(待检测的用户名) 
// 返回值:布尔值 
// 备 注:无 
//----------------------------------------------------------------------------------- 
------- 
function CheckUser($C_user) 

if (!CheckLengthBetween($C_user, 4, 20)) return false; //宽度检验 
if (!ereg("^[_a-zA-Z0-9]*$", $C_user)) return false; //特殊字符检验 
return true; 

//----------------------------------------------------------------------------------- 
------- 

//----------------------------------------------------------------------------------- 
------- 
// 函数名:CheckPassword($C_passwd) 
// 作 用:判断是否为合法用户密码 
// 参 数:$C_passwd(待检测的密码) 
// 返回值:布尔值 
// 备 注:无 
//----------------------------------------------------------------------------------- 
------- 
function CheckPassword($C_passwd) 

if (!CheckLengthBetween($C_passwd, 4, 20)) return false; //宽度检测 
if (!ereg("^[_a-zA-Z0-9]*$", $C_passwd)) return false; //特殊字符检测 
return true; 

//----------------------------------------------------------------------------------- 
------- 

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),