Ignore:
Timestamp:
Nov 19, 2009, 10:54:46 PM (15 years ago)
Author:
Eric
Message:

[NBC_UserAdvManager] Merged from trunk to branch 2.12
Bug 1238 fixed - Simple custom email text wasn't send when Extended Description plugin wasn't set
Bug 1245 fixed - Semicolons (;) are no longer allowed in text areas (mail info text, ConfirmMail text, reminder text,...). They'll be replaced by dots (.).
Bug 1248 fixed - Php notice on user registration with a forbidden email domain
Bug 1250 fixed - Email provider didn't work after the third exclusion in list

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/NBC_UserAdvManager/branches/2.12/main.inc.php

    r4250 r4317  
    22/*
    33Plugin Name: NBC UserAdvManager
    4 Version: 2.12.6
     4Version: 2.12.7
    55Description: Renforcer les possibilités de gestion des utilisateurs - Enforce users management
    66Plugin URI: http://fr.piwigo.org/ext/extension_view.php?eid=216
     
    9999-- 2.12.6 : Bug 1236 fixed -  Admins was unable to add a new user in the user_list page.
    100100            Beginning of IT translations
     101           
     102-- 2.12.7 : Bug 1238 fixed - Simple custom email text wasn't send when Extended Description plugin wasn't set
     103            Bug 1245 fixed - Semicolons (;) are no longer allowed in text areas (mail info text, ConfirmMail text, reminder text,...). They'll be replaced by dots (.).
     104            Bug 1248 fixed - Php notice on user registration with a forbidden email domain
     105            Bug 1250 fixed - Email provider didn't work after the third exclusion in list
     106            Escaping all special characters typed in login name and recover them
    101107*/
    102108
     
    286292from '.USERS_TABLE.'
    287293where upper('.$conf['user_fields']['email'].') = upper(\''.$_POST['email'].'\');';
    288       list($count) = mysql_fetch_array(pwg_query($query));
    289       if ($count != 0)
    290       {
    291         return l10n('reg_err_mail_address_dbl');
    292       }
    293     }
    294   }
    295   else
    296   {
    297     /* ***************************** */
    298     /* Standard Piwigo's email check */
    299     /* ***************************** */
    300     $atom   = '[-a-z0-9!#$%&\'*+\\/=?^_`{|}~]';   // before  arobase
    301     $domain = '([a-z0-9]([-a-z0-9]*[a-z0-9]+)?)'; // domain name
    302     $regex = '/^' . $atom . '+' . '(\.' . $atom . '+)*' . '@' . '(' . $domain . '{1,63}\.)+' . $domain . '{2,63}$/i';
    303 
    304     if (!preg_match($regex, $_POST['mail_address']))
    305     {
    306       return l10n('reg_err_mail_address');
    307     }
    308    
    309     if (!empty($_POST['mail_address']))
    310     {
    311       $query = '
    312 select count(*)
    313 from '.USERS_TABLE.'
    314 where upper('.$conf['user_fields']['email'].') = upper(\''.$_POST['mail_address'].'\');';
    315       list($count) = mysql_fetch_array(pwg_query($query));
     294      list($count) = mysql_fetch_assoc(pwg_query($query));
    316295      if ($count != 0)
    317296      {
     
    372351
    373352  /* Email without forbidden domains */
    374   if (isset($conf_nbc_UserAdvManager[12]) and $conf_nbc_UserAdvManager[12] == 'true' and !empty($_POST['mail_address']) and !ValidateEmailProvider($_POST['mail_address']))
    375   {
    376     //$_POST['mail_address'] = '';
    377     return($lang['reg_err_login1'] = l10n('reg_err_login7')."'".$conf_nbc_UserAdvManager[13]."'");
    378   }
     353  /* This doesn't work */
     354//  if (isset($conf_nbc_UserAdvManager[12]) and $conf_nbc_UserAdvManager[12] == 'true' and !empty($_POST['mail_address']) and !ValidateEmailProvider($_POST['mail_address']))
     355//  {
     356//    $_POST['mail_address'] = '';
     357//    return($lang['reg_err_login1'] = l10n('reg_err_login7')."'".$conf_nbc_UserAdvManager[13]."'");
     358//  }
     359  /* This work with a code copy of ValidateEmailProvider() function */
     360  if (isset($conf_nbc_UserAdvManager[12]) and $conf_nbc_UserAdvManager[12] == 'true' and !empty($_POST['mail_address']))
     361  {
     362    $ncsemail = strtolower($_POST['mail_address']);
     363    $conf_nbc_MailExclusion = preg_split("/[\s,]+/",$conf_nbc_UserAdvManager[13]);
     364    for ($i = 0 ; $i < count($conf_nbc_MailExclusion) ; $i++)
     365    {
     366      $pattern = '/'.$conf_nbc_MailExclusion[$i].'/';
     367      if (preg_match($pattern, $ncsemail))
     368      {
     369        $_POST['mail_address'] = '';                             
     370        return($lang['reg_err_login1'] = l10n('reg_err_login7')."'".$conf_nbc_UserAdvManager[13]."'");
     371      }
     372    }
     373        } 
    379374}
    380375
     
    393388    {
    394389      /* Email without forbidden domains */
    395       if (isset($conf_nbc_UserAdvManager[12]) and $conf_nbc_UserAdvManager[12] == 'true' and !empty($_POST['mail_address']))
    396       {
    397         if (!ValidateEmailProvider($_POST['mail_address']))
     390      /* This doesn't work */
     391//      if (isset($conf_nbc_UserAdvManager[12]) and $conf_nbc_UserAdvManager[12] == 'true' and !empty($_POST['mail_address']))
     392//      {
     393//        if (!ValidateEmailProvider($_POST['mail_address']))
     394//        {
     395//          $template->append('errors', l10n('reg_err_login7')."'".$conf_nbc_UserAdvManager[13]."'");
     396//          unset($_POST['validate']);
     397//        }
     398//      }
     399        /* This work with a code copy of ValidateEmailProvider() function */
     400        if (isset($conf_nbc_UserAdvManager[12]) and $conf_nbc_UserAdvManager[12] == 'true' and !empty($_POST['mail_address']))
    398401        {
    399           $template->append('errors', l10n('reg_err_login7')."'".$conf_nbc_UserAdvManager[13]."'");
    400           unset($_POST['validate']);
     402          $ncsemail = strtolower($_POST['mail_address']);
     403          $conf_nbc_MailExclusion = preg_split("/[\s,]+/",$conf_nbc_UserAdvManager[13]);
     404          for ($i = 0 ; $i < count($conf_nbc_MailExclusion) ; $i++)
     405          {
     406            $pattern = '/'.$conf_nbc_MailExclusion[$i].'/';
     407            if (preg_match($pattern, $ncsemail))
     408            {                           
     409              $template->append('errors', l10n('reg_err_login7')."'".$conf_nbc_UserAdvManager[13]."'");
     410              unset($_POST['validate']);
     411            }
     412          }
    401413        }
    402       }
    403414
    404415      $typemail = 3;
     
    424435     
    425436      /* Sending registration confirmation by email */
    426       if (( isset($conf_nbc_UserAdvManager[0]) and $conf_nbc_UserAdvManager[0] == 'true') or ( isset($conf_nbc_UserAdvManager[2]) and $conf_nbc_UserAdvManager[2] == 'true'))
     437      if ((isset($conf_nbc_UserAdvManager[0]) and $conf_nbc_UserAdvManager[0] == 'true') or (isset($conf_nbc_UserAdvManager[2]) and $conf_nbc_UserAdvManager[2] == 'true'))
    427438      {
    428439        $confirm_mail_need = false;
    429440             
    430         if (!empty($_POST['mail_address']) and ValidateEmailProvider($_POST['mail_address']))
     441        if (!empty($_POST['mail_address']))
    431442        {
    432443          $query = '
     
    438449          list($current_email) = mysql_fetch_row(pwg_query($query));
    439450     
    440           if ( $_POST['mail_address'] != $current_email and ( isset($conf_nbc_UserAdvManager[2]) and $conf_nbc_UserAdvManager[2] == 'true') )
     451          if ($_POST['mail_address'] != $current_email and ( isset($conf_nbc_UserAdvManager[2]) and $conf_nbc_UserAdvManager[2] == 'true'))
    441452       
    442453            $confirm_mail_need = true;
    443454        }
    444455       
    445         if ((!empty($_POST['use_new_pwd']) and ( isset($conf_nbc_UserAdvManager[0]) and $conf_nbc_UserAdvManager[0] == 'true') or $confirm_mail_need) )
     456        if ((!empty($_POST['use_new_pwd']) and (isset($conf_nbc_UserAdvManager[0]) and $conf_nbc_UserAdvManager[0] == 'true') or $confirm_mail_need))
    446457        {
    447458          $query = '
     
    513524
    514525      /* Email without forbidden domains */
    515       if (isset($conf_nbc_UserAdvManager[12]) and $conf_nbc_UserAdvManager[12] == 'true' and !empty($_POST['email']) and !ValidateEmailProvider($_POST['email']))
    516       {
    517         $template->append('errors', l10n('reg_err_login7')."'".$conf_nbc_UserAdvManager[13]."'");
    518         unset($_POST['submit_add']);
     526      /* This doesn't work */
     527//      if (isset($conf_nbc_UserAdvManager[12]) and $conf_nbc_UserAdvManager[12] == 'true' and !empty($_POST['email']) and !ValidateEmailProvider($_POST['email']))
     528//      {
     529//        $template->append('errors', l10n('reg_err_login7')."'".$conf_nbc_UserAdvManager[13]."'");
     530//        unset($_POST['submit_add']);
     531//      }
     532      /* This work with a code copy of ValidateEmailProvider() function */
     533      if (isset($conf_nbc_UserAdvManager[12]) and $conf_nbc_UserAdvManager[12] == 'true' and !empty($_POST['email']))
     534      {
     535        $ncsemail = strtolower($_POST['email']);
     536        $conf_nbc_MailExclusion = preg_split("/[\s,]+/",$conf_nbc_UserAdvManager[13]);
     537        for ($i = 0 ; $i < count($conf_nbc_MailExclusion) ; $i++)
     538        {
     539          $pattern = '/'.$conf_nbc_MailExclusion[$i].'/';
     540          if (preg_match($pattern, $ncsemail))
     541          {                     
     542            $template->append('errors', l10n('reg_err_login7')."'".$conf_nbc_UserAdvManager[13]."'");
     543            unset($_POST['submit_add']);
     544          }
     545        }
    519546      }
    520547    }
Note: See TracChangeset for help on using the changeset viewer.