Changeset 20181 for extensions/GuestBook/include
- Timestamp:
- Jan 16, 2013, 2:15:29 AM (12 years ago)
- Location:
- extensions/GuestBook/include
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/GuestBook/include/functions.inc.php
r17495 r20181 3 3 if (!defined('GUESTBOOK_PATH')) die('Hacking attempt!'); 4 4 5 if (!function_exists('is_valid_email'))5 function gb_is_valid_email($mail_address) 6 6 { 7 function is_valid_email($mail_address)7 if (function_exists('email_check_format')) 8 8 { 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'; 18 20 19 if (!preg_match($regex, $mail_address)) return false; 20 return true; 21 } 21 return (bool)preg_match($regex, $mail_address); 22 22 } 23 23 } 24 24 25 function is_valid_url($url)25 function gb_is_valid_url($url) 26 26 { 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) 28 32 { 29 33 return filter_var($url, FILTER_VALIDATE_URL)!==false; … … 33 37 $regex = '#^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$#i'; 34 38 35 if (!preg_match($regex, $url)) return false; 36 return true; 39 return (bool)preg_match($regex, $url); 37 40 } 38 41 } -
extensions/GuestBook/include/functions_comment.inc.php
r16000 r20181 6 6 EVENT_HANDLER_PRIORITY_NEUTRAL, 2); 7 7 8 function insert_user_comment_guestbook( &$comm, $key , &$infos)8 function insert_user_comment_guestbook( &$comm, $key ) 9 9 { 10 10 global $conf, $user, $page; … … 16 16 ) 17 17 ); 18 19 $infos = array(); 18 20 19 if (!$conf['guestbook']['comments_validation'] or is_admin()) 21 20 { … … 75 74 $comm['email'] = $user['email']; 76 75 } 77 else if ( !empty($comm['email']) and ! is_valid_email($comm['email']) )76 else if ( !empty($comm['email']) and !gb_is_valid_email($comm['email']) ) 78 77 { 79 78 array_push($page['errors'], l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)')); … … 86 85 $comm['website'] = 'http://'.$comm['website']; 87 86 } 88 if ( !empty($comm['website']) and ! is_valid_url($comm['website']) )87 if ( !empty($comm['website']) and !gb_is_valid_url($comm['website']) ) 89 88 { 90 89 array_push($page['errors'], l10n('invalid website address')); … … 121 120 if ($counter > 0) 122 121 { 123 array_push( $infos, l10n('Anti-flood system : please wait for a moment before trying to post another comment') );122 array_push($page['errors'], l10n('Anti-flood system : please wait for a moment before trying to post another comment') ); 124 123 $comment_action='reject'; 125 124 } -
extensions/GuestBook/include/guestbook.inc.php
r17717 r20181 1 1 <?php 2 2 if (!defined('GUESTBOOK_PATH')) die('Hacking attempt!'); 3 4 global $user; 3 5 4 6 include(GUESTBOOK_PATH . '/include/functions.inc.php'); … … 116 118 include_once(GUESTBOOK_PATH.'include/functions_comment.inc.php'); 117 119 118 $comment_action = insert_user_comment_guestbook($comm, @$_POST['key'] , $page['infos']);120 $comment_action = insert_user_comment_guestbook($comm, @$_POST['key']); 119 121 120 122 switch ($comment_action) … … 303 305 } 304 306 } 307 if (is_classic_user()) 308 { 309 $author = $user['username']; 310 $email = $user['email']; 311 } 312 if (empty($conf['comments_email_mandatory'])) // < 2.5 compatibility 313 { 314 $conf['comments_email_mandatory'] = false; 315 } 316 305 317 $template->assign('comment_add', 306 318 array( … … 308 320 'KEY' => get_ephemeral_key(3), 309 321 'CONTENT' => $content, 310 ' SHOW_AUTHOR' => !is_classic_user(),311 'AUTHOR' => $author 312 'WEBSITE' => $website 313 'EMAIL' => $email 322 'IS_LOGGED' => is_classic_user(), 323 'AUTHOR' => $author, 324 'WEBSITE' => $website, 325 'EMAIL' => $email, 314 326 'ACTIVATE_RATING' => $conf['guestbook']['activate_rating'], 327 'EMAIL_MANDATORY' => $conf['comments_email_mandatory'], 315 328 )); 316 329 } … … 319 332 $template->assign('GUESTBOOK_PATH', GUESTBOOK_PATH); 320 333 321 $template->assign('clear_themes', array(322 'clear',323 'gally-minimalist',324 'hr_os',325 'hr_os_xl',326 'kardon',327 'montblancxl',328 'Naive',329 'OS_glass_clear',330 'p0w0',331 'Pure_autumn',332 'Pure_clear_blue',333 'Pure_sky',334 'Pure_tr_clear_blue',335 'simple-white',336 'VerticalWhite',337 ));338 339 334 $template->set_filename('index', dirname(__FILE__).'/../template/guestbook.tpl'); 340 335
Note: See TracChangeset
for help on using the changeset viewer.