Advertisement
Guest User

Untitled

a guest
May 30th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.08 KB | None | 0 0
  1. function alphanumericAndSpace( $string )
  2.     {
  3.         return preg_replace('/[^a-zA-Z0-9\s]/', '', $string);
  4.     }
  5.  
  6. function cp_filter($text) {
  7.     $text = strip_tags($text);
  8.     $text = trim($text);
  9.     $char_limit = 5000;
  10.     if( strlen( $text ) > $char_limit ) {
  11.         $text = substr( $text, 0, $char_limit );
  12.     }
  13.     return $text;
  14. }
  15.  
  16. function cp_check_email($email) {
  17.     if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
  18.         return false;
  19.     }
  20.     $email_array = explode("@", $email);
  21.     $local_array = explode(".", $email_array[0]);
  22.     for ($i = 0; $i < sizeof($local_array); $i++) {
  23.         if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) {
  24.             return false;
  25.         }
  26.     }
  27.     if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) {
  28.         $domain_array = explode(".", $email_array[1]);
  29.         if (sizeof($domain_array) < 2) {
  30.             return false;
  31.         }
  32.         for ($i = 0; $i < sizeof($domain_array); $i++) {
  33.             if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) {
  34.                 return false;
  35.             }
  36.         }
  37.     }
  38.     return true;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement