Changeset 21542


Ignore:
Timestamp:
03/14/13 16:23:37 (7 years ago)
Author:
mistic100
Message:

directly use Piwigo functions for email and url check (break compatibility < 2.5)

Location:
extensions/GuestBook/include
Files:
2 edited

Legend:

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

    r20181 r21542  
    11<?php 
    2  
    32if (!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   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'; 
    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   else 
    36   { 
    37     $regex = '#^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$#i'; 
    38  
    39     return (bool)preg_match($regex, $url); 
    40   } 
    41 } 
    423 
    434function get_stars($score, $path) 
  • extensions/GuestBook/include/functions_comment.inc.php

    r20181 r21542  
    7474    $comm['email'] = $user['email']; 
    7575  } 
    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']) ) 
    7777  { 
    7878    array_push($page['errors'], l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)')); 
     
    8585    $comm['website'] = 'http://'.$comm['website']; 
    8686  } 
    87   if ( !empty($comm['website']) and !gb_is_valid_url($comm['website']) ) 
     87  if ( !empty($comm['website']) and !url_check_format($comm['website']) ) 
    8888  { 
    8989    array_push($page['errors'], l10n('invalid website address')); 
Note: See TracChangeset for help on using the changeset viewer.