Ignore:
Timestamp:
Jan 16, 2013, 2:15:29 AM (11 years ago)
Author:
mistic100
Message:

impove display, add LiveValidation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/GuestBook/include/functions.inc.php

    r17495 r20181  
    33if (!defined('GUESTBOOK_PATH')) die('Hacking attempt!');
    44
    5 if (!function_exists('is_valid_email'))
     5function gb_is_valid_email($mail_address)
    66{
    7   function is_valid_email($mail_address)
     7  if (function_exists('email_check_format'))
    88  {
    9     if (version_compare(PHP_VERSION, '5.2.0') >= 0)
    10     {
    11       return filter_var($mail_address, FILTER_VALIDATE_EMAIL)!==false;
    12     }
    13     else
    14     {
    15       $atom   = '[-a-z0-9!#$%&\'*+\\/=?^_`{|}~]';   // before  arobase
    16       $domain = '([a-z0-9]([-a-z0-9]*[a-z0-9]+)?)'; // domain name
    17       $regex = '/^' . $atom . '+' . '(\.' . $atom . '+)*' . '@' . '(' . $domain . '{1,63}\.)+' . $domain . '{2,63}$/i';
     9    return email_check_format($email_address);
     10  }
     11  else if (version_compare(PHP_VERSION, '5.2.0') >= 0)
     12  {
     13    return filter_var($mail_address, FILTER_VALIDATE_EMAIL)!==false;
     14  }
     15  else
     16  {
     17    $atom   = '[-a-z0-9!#$%&\'*+\\/=?^_`{|}~]';   // before  arobase
     18    $domain = '([a-z0-9]([-a-z0-9]*[a-z0-9]+)?)'; // domain name
     19    $regex = '/^' . $atom . '+' . '(\.' . $atom . '+)*' . '@' . '(' . $domain . '{1,63}\.)+' . $domain . '{2,63}$/i';
    1820
    19       if (!preg_match($regex, $mail_address)) return false;
    20       return true;
    21     }
     21    return (bool)preg_match($regex, $mail_address);
    2222  }
    2323}
    2424
    25 function is_valid_url($url)
     25function gb_is_valid_url($url)
    2626{
    27   if (version_compare(PHP_VERSION, '5.2.0') >= 0)
     27  if (function_exists('url_check_format'))
     28  {
     29    return url_check_format($url);
     30  }
     31  else if (version_compare(PHP_VERSION, '5.2.0') >= 0)
    2832  {
    2933    return filter_var($url, FILTER_VALIDATE_URL)!==false;
     
    3337    $regex = '#^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$#i';
    3438
    35     if (!preg_match($regex, $url)) return false;
    36     return true;
     39    return (bool)preg_match($regex, $url);
    3740  }
    3841}
Note: See TracChangeset for help on using the changeset viewer.