// WARNING】: Do not modify it without permission // ------------------------------- -------------------------------------------------- ------- // ----------------------------------------- ----------------------------------- / / / / [File name]: c_check.inc // [role]: universal detection function set // 【Author】: Tianshi // // [final modification date]: 2001/05/11 [cxx] // [ Variable definition rules]: 'c _' = character type, 'i _' = integer, 'n _' = digital type, 'l _' = Boolean, 'a _' = array type // --------- -------------------------------------------------- ------------------------------------- -------------------------------------------------- --------------------- // ※ Checkmoney ($ c_money) Check the data is 99999.99 format // ※ CheckemailAddr ($ c_mailaddr) Judging whether it is a valid message Address // ※ CheckWebAddr ($ c_weburl) Judging whether the string is empty // ※ Checkempty ($ C_CHAR) CHECKEMPTY ($ c_char) CHECKLENGTHBEEN ($ C_CHAR, $ I_LEN1, $ I_LEN2 = 100) Judgment is within the specified length String // ※ Checkuser ($ c_user) Judging whether it is a legal username // ※ checkpassword ($ c_passwd) determined if the legitimate user password // ※ checktelephone determines whether it is a legal phone number // ※ CheckValuebetWeen ($ CHECKVALUEBETWEEN N_VAR, $ N_VAL1, $ N_VAL2) Judge whether it is a legal value in a certain range / / ※ CheckPost ($ c_post) determines if it is a legal zip (fixed length) // ※ CheckextendName ($ C_FILENAME, $ A_EXTEND) Judging the extension of the upload file // ※ CheckImagesize ($ imagefilename, $ limited "checks the size of the upload picture // ※ Alertexit ($ c_alert, $ i_goback = 0) illegal operation warning and exit / / ※ ALERT ($ Calert, $ I_GOBACK = 0) illegal operation warning // ※ ReplacessPacialchar ($ c_char) Special character replacement function // ※ ExchangeMoney ($ n_money) fund conversion function // ※ WindowLocation ($ c_URL, $ c_GET = " ", $ C_GETOTHER =" "" in the Window.Location function in PHP ------------------------------- -------------------------------------------------- -------
/ / -------------------------------------------------------------------------------------------- ----------------------------------- ------- // Function Name: Checkmoney ($ C_money) // Role: Check if the data is 9999.99 format // Parameters: $ c_money (the number to be detected) // Return value: Boolean // Note: None // -------------- -------------------------------------------------- --------------------------- Function Checkmoney ($ C_MONEY) {if (! EREG ("^ [0-9] [.] [0-9] $ ", $ c_money) Return false; return true;} // ----------------------------- -------------------------------------------------- ---- ------- // ------------------------------------- ---------------------------------------------- ---- --- // Function Name: Checkemailaddr ($ c_mailaddr) // Role: Judgment is a valid email address // Parameter: $ c_mailaddr (the email address to be detected) // Return Value: Boolean // Note: No // -------------------------------------------------- -------------------------------------- Function Checkema de-($ C_MAILADDR) {if (! EREGI ("^ [_ a-z0-9 -] (. [_ a-z0-9 -] ) * @ [A-Z0-9 -] (. [A-Z0-9 -] ) * $ ", $ C_mailaddr) // (`! "^ [_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: Judgment is a valid URL // Parameter: $ c_Weburl (URL to be detected) // Return Value: Boolean // Note: None // ------------- -------------------------------------------------- -------------------- ------- Function Checkwebaddr ($ c_Weburl) {if (! EREG ("^ http: // [_A-ZA- Z0-9 -] (. [_ A-ZA-Z0-9 -] ) * $ ", $ c_Weburl) {Return true;} // ----------- -------------------------------------------------- --------------------------- // ------------------- -------------------------------------------------- -------------- ------- // Function Name: Checkeempty ($ c_char) // Role: Judgment string is empty // Parameters: $ c_char (to be tested String) // Return Value: Boolean // Remarks: No // -------------------------------- -------------------------------------------------- - ------- Function Checkemptystring ($ c_char) {if (! is_string ($ c_char)) Return False; // Is it a string type if (Empty ($ c_char)) return false; // Has already set IF ($ c_char == ') return false; // is empty return true;} // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----- -------------------------------------------------- - -------
/ / -------------------------------------------------------------------------------------------- ----------------------------------- ------- // Function Name: Checklengthbetween ($ C_CHAR, $ I_LEN1, $ I_LEN2 = 100) // Role: Judgment whether to specify the string // parameter: $ c_char (string to be detected) // $ i_len1 (Lower target string length) // $ I_len2 (the upper limit of the target string length) // Return value: Boolean // Note: No // --------------------------- -------------------------------------------------- ----------- 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;} // ----------------------------------------------------------------------------------------------------------------------- -------------------------------------------------- ---- ------- // ------------------------------------- ---------------------------------------------- ---- --- // Function Name: Checkuser // Role: Judgment is a legal user name // Parameters: $ c_user (username to be detected) // Return Value: Boolean // Note: No // -------------------------------------------------- --------------------------------------- Function Checkuser ($ C_USER) {if (! Checklengthbetween ($ C_USER, 4, 20) RETURN FALS e; // Width test if (! EREG ("^ [^ [A-ZA-ZA-Z0-9] * $", $ C_USER)) Return False; // Special Character Test Return True;} // ------------------------ -------------------------------------------------- ---------------------------------
/ / -------------------------------------------------------------------------------------------- ----------------------------------- ------- // Function Name: Checkpassword ($ C_passwd) // Role: Determine if it is a legitimate user password // parameter: $ c_passwd (password to be detected) // Return value: Boolean // Note: No // -------------- -------------------------------------------------- --------------------------- Function Checkpassword ($ c_passwd) {if (! ChecklengthbetWeen ($ C_PASSWD, 4, 20)) Return False ; // Width detection if (! EREG ("^ [^ [_ za-za-z0-9] * $", $ c_passwd)) Return false; // Special character detection return true;} // ------- -------------------------------------------------- ------------------------------- // --------------- -------------------------------------------------- ------------------ ------- // Function Name: CheckTelephone / / Role: Judgment is a legal phone number / / parameter: $ C_TELEPHONE (phone number to be detected) // Return Value: Boolean // Note: No // ---------------------------- -------------------------------------------------- ----- ------- 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) // Role: Decision is a legitimate value of a certain range / / parameter: $ n_var to be detected // $ n_var1 to be detected on the upper limit // $ n_var2 to be detected Lower limit // Return value: Boolean // Remarks: No // -------------------------------------------------------------------------------------------------- ------------------------------------- ---- 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) // Role: Judgment Whether is a legal zip (fixed length) // Parameters: $ c_post (postal code to be check) // Return value: Boolean // Note: No // --------------- -------------------------------------------------- ------------------ ------- Function CheckPost {$ c_post = trim ($ c_post); if (Strlen ($ c_post) == 6) {if ("g (" ^ [ ]? [_ 0-9] * $ ", $ c_post)) {return true ;;} else {return false;}} else {returnaf false ;;}} // -------------------------------------------------- ---------------------------------------
/ / -------------------------------------------------------------------------------------------- ----------------------------------- ------- // Function Name: CheckeextendName ($ C_FileName, $ A_EXTEND) // Role: Upload Document Extension Judgment // Parameters: $ c_filename Uploaded File Name // $ A_EXTEND Requirements Screen // Return Value: Boolean // Note: None // --- -------------------------------------------------- ----------------------------------- Function CheckExtendName ($ C_FILENAME, $ A_EXTEND) {IF (Strlen (TRIM ($ c_filename)) <5) {return 0; // Returned 0 indicates no upload picture} $ lastdot = Strrpos ($ c_filename, "."); // Remove. Last location $ extended = SUBSTR ($ C_FileName, $ lastdot 1); // Take out the extension
For ($ I = 0; $ I IF ($ flag <> 1) {for ($ j = 0; $ j / / -------------------------------------------------------------------------------------------- ----------------------------------- ------- // Function Name: CheckImageSize ($ ImageFileName, $ LIMITSIZE) / / Role: Test the size of the upload picture // Parameters: $ imageFileName uploaded image name // $ limited to the size of the required size // Return value: Boolean // Note: None // ----- -------------------------------------------------- ---------------------------- ------- Function CheckImageSize ($ size = getImagesize) {$ size = getimagesize $ ImageFileName); IF ($ size [0]> $ limited [0] ││ $ size [1]> $ limited [1]) {Alertexit ('image size is too big "; return false;} return true;} Return true; / / -------------------------------------------------------------------------------------------- ----------------------------------------- / / -------------------------------------------------------------------------------------------- ----------------------------------- ------- // Function Name: Alert ($ C_lert, $ I_GOBACK = 0) // Role: illegal operation warning // Parameters: $ c_lert (prompt error message) // $ i_goback (return to that page) // Return Value: String // Note: None / / --------------------------------------------------- ---------------------------------- ------- Function Alert ($ c_alert, $ i_goback = 0) {IF ($ I_GOBACK <> 0) {echo "