Public Function Isemail ($str) {$j = "/^[\w|\.] [email protected]\w+\.\w+/i], if (Preg_match ($j, $STR)) return $str; else return false;} Public Function Istelphone ($str) {$j = "/^\d+-?\d+/i"; if (Preg_match ($j, $STR)) return $str; else return false;} Public Function Iszipcode ($str) {$j = "/^\d{6}/i"; if (Preg_match ($j, $STR)) return $str; else return false;} Public Function Isusername ($STR) {if (HE = = ' Utf-8 ') {//if (eregi (' ^[\u0391-\uffe5|\w]{2,40}$ ', $str)) if (Preg_match ('/^ [\x7f-\xff|\w] {2,40}$/i ', $str)) return $str; else return false;} else return true;} Public Function Isallowkey ($STR) {//$j = "/^[\w|\[|\]|\-|_]+$/i"; $j = "/^[\w|\-|_]+$/i"; if (Preg_match ($j, $str)) return $str; else return false;} Public Function Ispassword ($STR) {if (strlen ($STR) >=6) return $str; else return false;} Public Function Isurl ($str) {$j = "/^http:\/\/.+/i"; if (Preg_match ($j, $STR)) return $str; else return false;} Public Function subString ($STR, $lenth, $start = 0) {if (strlen ($STR) < $lenth &&! $start) return $str; if (HE = = ' UT F-8 ') $l =3;else $l = 2; $k = 1;if ($start) {$m = $start, while ($k) if (Ord ($str [--$m]) <) $k = 0; $k = $l-($lenth-$m)% $l; $start = $start + $k;} $t = substr ($str, $start, $lenth); $m = $lenth; $k = 1;while ($k) if (Ord ($t [--$m]) <) $k = 0; $k = ($lenth-$m)% $l; if ($k) $ t = substr ($t, 0, $lenth-$k); if ($start) return $t; Elsereturn $t. ' ... ';} Public Function hexstring ($str, $hex = +) {$tmp = ""; $e = strlen ($STR); if (! $e) return false;for ($i =0; $i < $e; $i + +) {$t = ba Se_convert (Ord ($str [$i]), 10,16); $tmp. = "\x{$t}";} return $tmp;} Public function encode ($info) {$info = serialize ($info), $key = CS, $kl = strlen ($key), $il = strlen ($info); for ($i = 0; $i < ; $il; $i + +) {$p = $i% $kl; $info [$i] = Chr (Ord ($info [$i]) +ord ($key [$p]));} Return UrlEncode ($info);} Public function decode ($info) {$key = CS, $info = UrlDecode ($info); $kl = strlen ($key); $il = strlen ($info); for ($i = 0; $i < ; $il; $i + +) {$p = $i% $kl; $info [$i] = Chr (Ord ($info [$i])-ord ($key [$p]));} $info = Unserialize ($info); return $info;} Public Function Enstr ($str) {$str = baSe64_encode ($STR); $str = str_replace (Array (' + ', '/', ' = '), array ('-', ' _ ', '), $str); return $str;} Public Function Destr ($str) {$str = Str_replace (Array ('-', ' _ '), Array (' + ', '/'), $str); $str = Base64_decode ($STR); return $str;}
Phone number, e-mail, postal code judgment