Changeset 21542
- Timestamp:
- Mar 14, 2013, 4:23:37 PM (11 years ago)
- Location:
- extensions/GuestBook/include
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/GuestBook/include/functions.inc.php
r20181 r21542 1 1 <?php 2 3 2 if (!defined('GUESTBOOK_PATH')) die('Hacking attempt!'); 4 5 function gb_is_valid_email($mail_address)6 {7 if (function_exists('email_check_format'))8 {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 else16 {17 $atom = '[-a-z0-9!#$%&\'*+\\/=?^_`{|}~]'; // before arobase18 $domain = '([a-z0-9]([-a-z0-9]*[a-z0-9]+)?)'; // domain name19 $regex = '/^' . $atom . '+' . '(\.' . $atom . '+)*' . '@' . '(' . $domain . '{1,63}\.)+' . $domain . '{2,63}$/i';20 21 return (bool)preg_match($regex, $mail_address);22 }23 }24 25 function gb_is_valid_url($url)26 {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)32 {33 return filter_var($url, FILTER_VALIDATE_URL)!==false;34 }35 else36 {37 $regex = '#^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$#i';38 39 return (bool)preg_match($regex, $url);40 }41 }42 3 43 4 function get_stars($score, $path) -
extensions/GuestBook/include/functions_comment.inc.php
r20181 r21542 74 74 $comm['email'] = $user['email']; 75 75 } 76 else if ( !empty($comm['email']) and ! gb_is_valid_email($comm['email']) )76 else if ( !empty($comm['email']) and !email_check_format($comm['email']) ) 77 77 { 78 78 array_push($page['errors'], l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)')); … … 85 85 $comm['website'] = 'http://'.$comm['website']; 86 86 } 87 if ( !empty($comm['website']) and ! gb_is_valid_url($comm['website']) )87 if ( !empty($comm['website']) and !url_check_format($comm['website']) ) 88 88 { 89 89 array_push($page['errors'], l10n('invalid website address'));
Note: See TracChangeset
for help on using the changeset viewer.