//-----------------------------------------------------------------------------------
-------
// Function name: CheckTelephone($C_telephone)
// Function: determine whether it is a legal phone number
// Parameter: $C_telephone (phone number to be detected)
// Return value: Boolean value
// Note: None
//-----------------------------------------------------------------------------------
-------
function CheckTelephone($C_telephone)
{
if (!ereg("^[+]?[0-9]+([xX-][0-9]+)*$", $C_telephone)) return false;
return true;
}
//-----------------------------------------------------------------------------------
-------
//-----------------------------------------------------------------------------------
-------
// Function name: CheckValueBetween($N_var, $N_val1, $N_val2)
// Function: determine whether it is a legal value within a certain range.
// Parameter: $N_var Value to be detected
// $N_var1 Upper limit of the value to be detected
// $N_var2 The lower limit of the value to be detected
// Return value: Boolean value
// Note: None
//-----------------------------------------------------------------------------------
-------
function CheckValueBetween($N_var, $N_val1, $N_val2)
{
if ($N_var < $N_var1 ││ $N_var > $N_var2)
{
return false;
}
return true;
}
//-----------------------------------------------------------------------------------
-------
//-----------------------------------------------------------------------------------
-------
// Function name: CheckPost($C_post)
// Function: determine whether it is a legal postal code (fixed length)
// Parameter: $C_post (zip code to be checked)
// Return value: Boolean value
// Note: None
//-----------------------------------------------------------------------------------
-------
function CheckPost($C_post)
{
$C_post=trim($C_post);
if (strlen($C_post) == 6)
{
if(!ereg("^[+]?[_0-9]*$",$C_post))
{
return true;;
}else
{
return false;
}
}else
{
return false;;
}
}
//-----------------------------------------------------------------------------------
-------
//-----------------------------------------------------------------------------------
-------
// Function name: CheckExtendName($C_filename,$A_extend)
// Function: judgment of the extension of uploaded file
// Parameter: $C_filename Uploaded file name
// $A_extend Required extension
// Return value: Boolean value
// Note: None
//-----------------------------------------------------------------------------------
-------
function CheckExtendName($C_filename,$A_extend)
{
if(strlen(trim($C_filename)) < 5)
{
return 0; //Return 0 means that the picture was not uploaded.
}
$lastdot = strrpos($C_filename, "."); //Take it out. The last location
$extended = substr($C_filename, $lastdot+1); //Take out the extension
for($i=0;$i<count($A_extend);$i++)//Check
{
if (trim(strtolower($extended)) == trim(strtolower($A_extend[$i]))) //Convert large
Lowercase and detection
{
$flag=1; //Add success flag
$i=count($A_extend); //Stop detection when detected
}
}
if($flag<>1)
{
for($j=0;$j<count($A_extend);$j++) // List the types of extensions that are allowed to be uploaded
{
$alarm .= $A_extend[$j]." ";
}
AlertExit('Only upload '.$alarm.' files! And what you upload is a file of type '.$extended.');
return -1; //Return-1 means that the type of uploaded image does not match.
}
return 1; //Return 1 means that the type of the picture meets the requirements
}
//-----------------------------------------------------------------------------------
-------
//-----------------------------------------------------------------------------------
-------
// Function name: CheckImageSize($ImageFileName,$LimitSize)
// Function: Check the size of uploaded pictures
// Parameter: $ImageFileName Uploaded image name
// $LimitSize Required Size
// Return value: Boolean value
// Note: None
//-----------------------------------------------------------------------------------
-------
function CheckImageSize($ImageFileName,$LimitSize)
{
$size=GetImageSize($ImageFileName);
if ($size[0]>$LimitSize[0] ││ $size[1]>$LimitSize[1])
{
AlertExit('The image is too large');
return false;
}
return true;
}
//-----------------------------------------------------------------------------------
-------
//-----------------------------------------------------------------------------------
-------
// Function name: Alert($C_alert,$I_goback=0)
// Function: Illegal operation warning
// Parameter: $C_alert (Error message prompted)
//$I_goback (return to that page)
// Return value: string
// Note: None
//-----------------------------------------------------------------------------------
-------
function Alert($C_alert,$I_goback=0)
{
if($I_goback<>0)
{
echo "<script>alert('$C_alert');($I_goback);</script>";
}
else
{
echo "<script>alert('$C_alert');</script>";
}
}
//-----------------------------------------------------------------------------------
-------
Previous page123Next pageRead the full text