?
"Warning": please do not change without permission
//-----------------------------------------------------------------------------------
-------
//-----------------------------------------------------------------------------------
-------
//
"FileName": c_check.inc
"Role": a set of common detection functions
"Author": Sky Ash
//
"Last Modified Date": 2001/05/11[cxx]
"Variable definition rule": ' C_ ' = character type, ' i_ ' = integral type, ' n_ ' = numeric, ' L_ ' = boolean, ' a_ ' = number
Group type
//-----------------------------------------------------------------------------------
-------
//-----------------------------------------------------------------------------------
-------
※checkmoney ($C _money) checks whether the data is
99999.99 format
※CHECKEMAILADDR ($C _mailaddr) to determine if it is a valid message
Access
※CHECKWEBADDR ($C _weburl) to determine whether it is a valid URL
※checkempty ($C _char) to determine whether the string is empty
※checklengthbetween ($C _char, $I _len1, $I _len2=100) determines whether the specified length of
String
※checkuser ($C _user) to determine whether a legitimate user name
※checkpassword ($C _passwd) to determine whether a legal user is secret
Code
※checktelephone ($C _telephone) to determine whether a legal telephone number
Code
※checkvaluebetween ($N _var, $N _val1, $N _val2) to determine whether a range of
Legal value
※checkpost ($C _post) to determine whether the legal ZIP code (solid
Fixed length)
※checkextendname ($C _filename, $A _extend) to determine the extension of the uploaded file
※checkimagesize ($ImageFileName, $LimitSize) Check the size of uploaded pictures
※alertexit ($C _alert, $I _goback=0) Illegal operation warning and exiting
※alert ($C _alert, $I _goback=0) Illegal operation warning
※replacespacialchar ($C _char) special character substitution function
※exchangemoney ($N _money) Capital conversion function
※windowlocation ($C _url, $C _get= "", $C _getother= "") Window.location in PHP
Function
//-----------------------------------------------------------------------------------
-------
//-----------------------------------------------------------------------------------
-------
Function name: Checkmoney ($C _money)
Function: Check whether the data is 99999.99 format
Parameters: $C _money (number to be detected)
Return Value: Boolean value
Note: none
//-----------------------------------------------------------------------------------
-------
function Checkmoney ($C _money)
{
if (!ereg ("^[0-9][.] [0-9]$ ", $C _money)) return false;
return true;
}
//-----------------------------------------------------------------------------------
-------
//-----------------------------------------------------------------------------------
-------
Function name: checkemailaddr ($C _mailaddr)
Role: Determine if a valid mailing address
Parameters: $C _mailaddr (email address to be detected)
Return Value: Boolean value
Note: none
//-----------------------------------------------------------------------------------
-------
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;
}
//-----------------------------------------------------------------------------------
-------
//-----------------------------------------------------------------------------------
-------
Function name: checkwebaddr ($C _weburl)
Role: To determine whether a valid Web site
Parameters: $C _weburl (URLs to be detected)
Return Value: Boolean value
Note: none
//-----------------------------------------------------------------------------------
-------
function checkwebaddr ($C _weburl)
{
if (!ereg () ^http://[_a-za-z0-9-]+ (. [ _a-za-z0-9-]+) *$ ", $C _weburl))
{
return false;
}
return true;
}
//-----------------------------------------------------------------------------------
-------
//-----------------------------------------------------------------------------------
-------
Function name: Checkempty ($C _char)
Role: Determine if the string is empty
Parameters: $C _char (string to be detected)
Return Value: Boolean value
Note: none
//-----------------------------------------------------------------------------------
-------
function checkemptystring ($C _char)
{
if (!is_string ($C _char)) return false; Whether it is a string type
if (Empty ($C _char)) return false; Whether it has been set
if ($C _char== ') return false; is empty
return true;
}
//-----------------------------------------------------------------------------------
-------
//-----------------------------------------------------------------------------------
-------
Function name: Checklengthbetween ($C _char, $I _len1, $I _len2=100)
Role: Determine whether the string within the specified length
Parameters: $C _char (string to be detected)
$I _len1 (lower bound of the length of the target string)
$I _len2 (upper limit of target string length)
Return Value: Boolean value
Note: none
//-----------------------------------------------------------------------------------
-------
function Checklengthbetween ($C _cahr, $I _len1, $I _len2=100)
{
$C _cahr = Trim ($C _cahr);
if (strlen ($C _cahr) < $I _len1) return false;
if (strlen ($C _cahr) > $I _len2) return false;
return true;
}
//-----------------------------------------------------------------------------------
-------
//-----------------------------------------------------------------------------------
-------
Function name: CheckUser ($C _user)
Role: To determine whether a legitimate user name
Parameters: $C _user (user name to be detected)
Return Value: Boolean value
Note: none
//-----------------------------------------------------------------------------------
-------
function CheckUser ($C _user)
{
if (! Checklengthbetween ($C _user, 4)) return false; Width test
if (!ereg ("^[_a-za-z0-9]*$", $C _user)) return false; Special character test
return true;
}
//-----------------------------------------------------------------------------------
-------
//-----------------------------------------------------------------------------------
-------
Function name: Checkpassword ($C _passwd)
Role: Determine if the password is a legitimate user
Parameters: $C _passwd (password to be detected)
Return Value: Boolean value
Note: none
//-----------------------------------------------------------------------------------
-------
function Checkpassword ($C _passwd)
{
if (! Checklengthbetween ($C _passwd, 4)) return false; Width detection
if (!ereg ("^[_a-za-z0-9]*$", $C _passwd)) return false; Special character detection
return true;
}
//-----------------------------------------------------------------------------------
-------
Current 1/3 page
123 Next read the full text