Changeset 3385


Ignore:
Timestamp:
06/01/09 22:40:57 (10 years ago)
Author:
Eric
Message:

V2.10.9 :
Bug fixed - Missing english translation
Bug fixed - Notice on forbidden characters function use
Bug fixed - Audit on forbidden characters in username didn't work
Adding of email provider exclusion (like *@hotmail.com) - Warning ! -> Known bug : This feature doesn't work on user profile page. So, already registered users can change their email address to a forbidden one. If someone has a solution...

Location:
extensions/NBC_UserAdvManager
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • extensions/NBC_UserAdvManager/admin/UserAdvManager_admin.php

    r3352 r3385  
    1818  $_POST['UserAdvManager_ConfirmMail_Text'] = str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UserAdvManager_ConfirmMail_Text'])); 
    1919 
    20     $newconf_nbc_UserAdvManager = $_POST['UserAdvManager_Mail_Info'].';'.$_POST['UserAdvManager_No_Casse'].';'.$_POST['UserAdvManager_Confirm_Mail'].';'.(isset($_POST['UserAdvManager_No_Confirm_Group'])?$_POST['UserAdvManager_No_Confirm_Group']:'').';'.(isset($_POST['UserAdvManager_Validated_Group'])?$_POST['UserAdvManager_Validated_Group']:'').';'.(isset($_POST['UserAdvManager_Validated_Status'])?$_POST['UserAdvManager_Validated_Status']:'').';'.$_POST['UserAdvManager_No_Comment_Anonymous'].';'.$_POST['UserAdvManager_Username_Char'].';'.$_POST['UserAdvManager_Username_List'].';'.(isset($_POST['UserAdvManager_No_Confirm_Status'])?$_POST['UserAdvManager_No_Confirm_Status']:'').';'.$_POST['UserAdvManager_MailInfo_Text'].';'.$_POST['UserAdvManager_ConfirmMail_Text']; 
     20    $newconf_nbc_UserAdvManager = $_POST['UserAdvManager_Mail_Info'].';'.$_POST['UserAdvManager_No_Casse'].';'.$_POST['UserAdvManager_Confirm_Mail'].';'.(isset($_POST['UserAdvManager_No_Confirm_Group'])?$_POST['UserAdvManager_No_Confirm_Group']:'').';'.(isset($_POST['UserAdvManager_Validated_Group'])?$_POST['UserAdvManager_Validated_Group']:'').';'.(isset($_POST['UserAdvManager_Validated_Status'])?$_POST['UserAdvManager_Validated_Status']:'').';'.$_POST['UserAdvManager_No_Comment_Anonymous'].';'.$_POST['UserAdvManager_Username_Char'].';'.$_POST['UserAdvManager_Username_List'].';'.(isset($_POST['UserAdvManager_No_Confirm_Status'])?$_POST['UserAdvManager_No_Confirm_Status']:'').';'.$_POST['UserAdvManager_MailInfo_Text'].';'.$_POST['UserAdvManager_ConfirmMail_Text'].';'.$_POST['UserAdvManager_MailExclusion'].';'.$_POST['UserAdvManager_MailExclusion_List']; 
    2121 
    2222  $conf['nbc_UserAdvManager'] = $newconf_nbc_UserAdvManager; 
     
    140140    'UserAdvManager_NO_COMMENT_ANO_TRUE'  => $conf_nbc_UserAdvManager[6]=='true' ?  'checked="checked"' : '' , 
    141141    'UserAdvManager_NO_COMMENT_ANO_FALSE' => $conf_nbc_UserAdvManager[6]=='false' ?  'checked="checked"' : '' , 
     142    'UserAdvManager_MAILEXCLUSION_TRUE'   => $conf_nbc_UserAdvManager[12]=='true' ?  'checked="checked"' : '' , 
     143    'UserAdvManager_MAILEXCLUSION_FALSE'  => $conf_nbc_UserAdvManager[12]=='false' ?  'checked="checked"' : '' , 
     144    'UserAdvManager_MAILEXCLUSION_LIST'   => $conf_nbc_UserAdvManager[13], 
    142145  ) 
    143146); 
    144147 
    145 function Audit_UserAdvManager() 
    146 { 
    147   global $page, $conf, $errors; 
    148  
    149   $page_UserAdvMAnager_admin = get_admin_plugin_menu_link(__FILE__); 
    150  
     148 
     149if ( isset($_POST['audit']) or isset($_POST['submit']) ) 
     150{ 
    151151  $msg_error1 = ''; 
    152   $msg_error2 = ''; 
    153   $msg_ok_Audit = ''; 
    154   $msg_error_Audit = ''; 
    155  
    156   /* Usename non case sensitive */   
    157   if (isset($conf_nbc_UserAdvManager[1]) and $conf_nbc_UserAdvManager[1] == 'true') 
     152     
     153  /* username insensible a la casse */ 
     154  if (isset($conf_nbc_UserAdvManager[3]) and $conf_nbc_UserAdvManager[3] == 'true') 
    158155  { 
    159156    $query = " 
     
    168165    ;"; 
    169166    $result = pwg_query($query); 
    170   while($row = mysql_fetch_array($result)) 
    171     $msg_error1 .= '<br/>'.l10n('Err_audit_no_casse').$row['username']; 
    172      
    173   if ($msg_error1 == '') 
    174     array_push($page['infos'], l10n('UserAdvManager_audit_ok')); 
    175   else 
    176     $msg_error1 = l10n('Err_audit_no_casse').$row['username']; 
    177   } 
    178  
     167   
     168    while($row = mysql_fetch_array($result)) 
     169    { 
     170      $msg_error1 .= (($msg_error1 <> '') ? '<br/>' : '') . l10n('Err_audit_no_casse').$row['username']; 
     171    } 
     172  } 
     173 
     174 
     175 
     176  $msg_error2 = ''; 
     177   
    179178  /* Username without forbidden keys */ 
    180179  if ( isset($conf_nbc_UserAdvManager[7]) and $conf_nbc_UserAdvManager[7] == 'true' ) 
     
    186185    $result = pwg_query($query); 
    187186 
    188   while($row = mysql_fetch_array($result)) 
    189     $msg_error2 .= '<br/>'.l10n('Err_audit_username_char').$row['username'].' ('.$row['mail_address'].')'; 
    190  
    191   if ($msg_error2 == '') 
    192     array_push($page['infos'], l10n('UserAdvManager_audit_ok')); 
    193   else 
    194     $msg_error2 = l10n('Err_audit_username_char').$row['username'].' ('.$row['mail_address'].')'; 
    195   } 
    196  
     187    while($row = mysql_fetch_array($result)) 
     188    { 
     189      if ( !ValidateUsername($row['username']) ) 
     190        $msg_error2 .= (($msg_error2 <> '') ? '<br/>' : '') . l10n('Err_audit_username_char').$row['username']; 
     191    } 
     192  } 
     193 
     194 
     195  $msg_error3 = ''; 
     196   
     197  /* Email without forbidden domain */ 
     198  if ( isset($conf_nbc_UserAdvManager[12]) and $conf_nbc_UserAdvManager[12] == 'true' ) 
     199  { 
     200    $query = " 
     201      SELECT ".$conf['user_fields']['username'].", ".$conf['user_fields']['email']." 
     202      FROM ".USERS_TABLE." 
     203    ;"; 
     204    $result = pwg_query($query); 
     205 
     206    while($row = mysql_fetch_array($result)) 
     207    { 
     208    $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); 
     209        $conf_nbc_MailExclusion = split (",",$conf_nbc_UserAdvManager[13]); 
     210        for ($i = 0 ; $i < count($conf_nbc_MailExclusion) ; $i++) 
     211                { 
     212                        if (ereg($conf_nbc_MailExclusion[$i], $row['mail_address'])) 
     213                        { 
     214                        $msg_error3 .=  (($msg_error3 <> '') ? '<br/>' : '') . l10n('Err_audit_email_forbidden').$row['username'].' ('.$row['mail_address'].')'; 
     215                        } 
     216                } 
     217    } 
     218  } 
     219    
    197220  if ($msg_error1 <> '') 
    198221    $errors[] = $msg_error1.'<br/><br/>'; 
     222 
    199223  if ($msg_error2 <> '') 
    200224    $errors[] = $msg_error2.'<br/><br/>'; 
    201225 
    202   if ($msg_error1 <> '' or $msg_error2 <> '') 
    203     $errors[] = l10n('Err_audit_advise'); 
     226  if ($msg_error3 <> '') 
     227    $errors[] = $msg_error3.'<br/><br/>'; 
     228 
     229 
     230  if ($msg_error1 <> '' or $msg_error2 <> '' or $msg_error3 <> '') 
     231    array_push($page['errors'], l10n('Err_audit_advise')); 
    204232  else 
    205233    array_push($page['infos'], l10n('UserAdvManager_audit_ok')); 
    206234} 
    207235 
    208 if ( isset($_POST['audit']) or isset($_POST['submit']) ) 
    209 { 
    210         Audit_UserAdvManager(); 
    211 } 
     236 
    212237// +-----------------------------------------------------------------------+ 
    213238// |                             errors display                            | 
     
    218243  foreach ($errors as $error) 
    219244  { 
    220     $template->assign('errors.error', array('ERROR'=>$error)); 
     245        array_push($page['errors'], $error); 
    221246  } 
    222247} 
  • extensions/NBC_UserAdvManager/admin/UserAdvManager_admin.tpl

    r3352 r3385  
    5656        <input type="radio" value="false" {$UserAdvManager_NO_COMMENT_ANO_FALSE} name="UserAdvManager_No_Comment_Anonymous"/>{'UserAdvManager_No_Comment_Anonymous_false'|@translate}<br/> 
    5757        </li> 
    58  
     58        <br/> 
     59        <li><label>{'UserAdvManager_MailExclusion'|@translate}</label><br/> 
     60        <input type="radio" value="true" {$UserAdvManager_MAILEXCLUSION_TRUE} name="UserAdvManager_MailExclusion"/>{'UserAdvManager_MailExclusion_true'|@translate}<br/> 
     61        <input type="radio" value="false" {$UserAdvManager_MAILEXCLUSION_FALSE} name="UserAdvManager_MailExclusion"/>{'UserAdvManager_MailExclusion_false'|@translate}<br/> 
     62        <br/> 
     63        <li><label>{'UserAdvManager_MailExclusion_List'|@translate}</label><br/> 
     64        <textarea name="UserAdvManager_MailExclusion_List" id="UserAdvManager_MailExclusion_List" rows="10" cols="80" {$TAG_INPUT_ENABLED}>{$UserAdvManager_MAILEXCLUSION_LIST}</textarea> 
     65        </li> 
     66        </li> 
    5967    </ul> 
    6068        <div align="center"><input class="submit" type="submit" value="{'audit'|@translate}" name="audit" /> <input class="submit" type="submit" value="{'submit'|@translate}" name="submit" {$TAG_INPUT_ENABLED} /></div> 
  • extensions/NBC_UserAdvManager/include/functions_UserAdvManager.inc.php

    r3352 r3385  
    9090{ 
    9191  global $conf; 
    92    $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); 
     92  $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); 
    9393  $Confirm_Mail_ID = FindAvailableConfirmMailID(); 
    9494 
     
    295295  global $conf; 
    296296 
    297   $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['UserAdvManager']) : array(); 
     297  $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); 
    298298 
    299299  if ( isset($login) and isset($conf_nbc_UserAdvManager[8]) and $conf_nbc_UserAdvManager[8] <> '' ) 
     
    310310} 
    311311 
     312 
     313function ValidateEmailProvider($email) 
     314{ 
     315  global $conf; 
     316 
     317        $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); 
     318        if (isset($conf_nbc_UserAdvManager[12])) 
     319        { 
     320                $conf_nbc_MailExclusion = split (",",$conf_nbc_UserAdvManager[13]); 
     321                for ($i = 0 ; $i < count($conf_nbc_MailExclusion) ; $i++) 
     322                        { 
     323                                if (ereg($conf_nbc_MailExclusion[$i], $email)) 
     324                                        return false; 
     325                                else 
     326                                        return true; 
     327                        } 
     328        } 
     329} 
    312330?> 
  • extensions/NBC_UserAdvManager/language/en_UK/plugin.lang.php

    r3352 r3385  
    4141$lang['UserAdvManager_No_Comment_Anonymous_true'] = ' The author field have to be filled to send a comment.'; 
    4242$lang['UserAdvManager_No_Comment_Anonymous_false'] = ' Use the default Piwigo settings on comments sending.'; 
     43$lang['UserAdvManager_MailExclusion'] = 'Email provider exclusion'; 
     44$lang['UserAdvManager_MailExclusion_true'] = ' Set the email provider exclusion ON (i.e. : @hotmail.* or @msn.*)'; 
     45$lang['UserAdvManager_MailExclusion_false'] = ' Set the email provider exclusion OFF.'; 
     46$lang['UserAdvManager_MailExclusion_List'] = ' If email provider exclusion is set to ON, fill the email domains to exclude below. You have to use the following format :<br/>@[domaine_name].[domaine_extension] - Example : @hotmail.com<br/>Seperate the different domains with a comma (,)<br/>'; 
     47 
     48$lang['audit'] = 'Audit'; 
     49$lang['submit'] = 'Submit'; 
    4350 
    4451$lang['Err_audit_no_casse'] = '<b>These accounts are identical to the case closely :</b> '; 
    4552$lang['Err_audit_username_char'] = '<b>This account uses one or more forbidden characters :</b> '; 
     53$lang['Err_audit_email_forbidden'] = '<b>This account uses a forbidden email provider :</b> '; 
    4654$lang['Err_audit_advise'] = '<b>you make a correction to comply with new rules that you have activated.<br>use a utility géstion database to correct user accounts directly in the table ### _USERS'; 
    4755$lang['UserAdvManager_audit_ok'] = 'Audit OK'; 
     
    5260if ( isset($conf_UserAdvManager[1]) and $conf_UserAdvManager[1] == 'true' ) 
    5361  $lang['reg_err_login5'] = 'user name is already taken, attention name is insensitive (Shift = Tiny).'; 
     62$lang['reg_err_login6'] = 'Username does not contain the following characters: '; 
     63$lang['reg_err_login7'] = 'Your email provider is banned for registration. Banned email providers are: '; 
    5464 
    5565$lang['invalid_pwd'] = 'User name or password invalid !'; 
  • extensions/NBC_UserAdvManager/language/fr_FR/plugin.lang.php

    r3352 r3385  
    4141$lang['UserAdvManager_No_Comment_Anonymous_true'] = ' Le champs auteur doit être renseigné pour enregistrer un commentaire.'; 
    4242$lang['UserAdvManager_No_Comment_Anonymous_false'] = ' Laisser le fonctionnement par défaut pour enregistrer un commentaire.'; 
     43$lang['UserAdvManager_MailExclusion'] = 'Exclusion des domaines de messagerie'; 
     44$lang['UserAdvManager_MailExclusion_true'] = ' Activer l\'exclusion des domaines de messagerie (par exemple @hotmail.* ou @msn.*)'; 
     45$lang['UserAdvManager_MailExclusion_false'] = ' Désactiver l\'exclusion des domaines de messagerie.'; 
     46$lang['UserAdvManager_MailExclusion_List'] = ' Si l\'exclusion de domaines de messagerie est activée, saisissez les domaines à exclure ici. Il faut respecter le format suivant :<br/>@[nom_du_domaine].[extension_du_domaine] - Exemple : @hotmail.com<br/>Séparez les domaines par une virgule<br/>'; 
    4347 
    4448$lang['audit'] = 'Audit'; 
     
    4751$lang['Err_audit_no_casse'] = '<b>Ces comptes sont identiques à la casse près :</b> '; 
    4852$lang['Err_audit_username_char'] = '<b>Ce compte contient un ou des caractères interdits :</b> '; 
     53$lang['Err_audit_email_forbidden'] = '<b>Ce compte contient des domaines de messagerie interdit :</b> '; 
    4954$lang['Err_audit_advise'] = '<b>Vous avez des corrections a faire pour respecter les nouvelles règles que vous avez activé<br>utilisez un utilitaire de gestion de base de données pour corriger les comptes utilisateurs directement dans la table ###_USERS si nécessaire.</b>'; 
    5055$lang['UserAdvManager_audit_ok'] = 'Audit OK'; 
     
    5661        $lang['new_reg_err_login5'] = 'ce nom utilisateur est déjà pris, ATTENTION le nom est insensible à la casse (Majuscule = Minuscule).'; 
    5762$lang['reg_err_login6'] = 'le nom utilisateur ne doit pas contenir les caractère suivants : '; 
     63$lang['reg_err_login7'] = 'L\'adresse email est issue d\'un prestataire interdit. Les prestataires d\'adresses email interdits à l\'inscription sont : '; 
    5864 
    5965$lang['invalid_pwd'] = 'Nom utilisateur ou Mot de passe invalide !'; 
  • extensions/NBC_UserAdvManager/main.inc.php

    r3352 r3385  
    22/* 
    33Plugin Name: NBC UserAdvManager 
    4 Version: 2.10.8 
     4Version: 2.10.9 
    55Description: Permet de renforcer les possibilités de gestion des utilisateurs - Enforce users management 
    66Plugin URI: http://fr.piwigo.org/ext/extension_view.php?eid=216 
     
    2929-- 2.10.8 : ConfirmMail page looks better (Sylvia theme only) 
    3030                        Improved code for checking author on guest comments 
     31 
     32-- 2.10.9 : Bug fixed - Missing english translation 
     33                        Bug fixed - Notice on forbidden characters function use 
     34                        Bug fixed - Audit on forbidden characters in username didn't work 
     35                        Adding of email provider exclusion (like *@hotmail.com) - Warning ! -> Known bug : This feature doesn't work on user profile page. So, already registered users can change their email address to a forbiden one. 
    3136 
    3237*/ 
     
    5358        ++ (...) 
    5459 
    55 -- Password control ans enforcement 
     60-- Password control and enforcement 
    5661  -- Empty password (done in Piwigo 2.x) 
    5762  ++ Can not be the same as username 
     
    127132function UserAdvManager_InitPage() 
    128133{ 
     134  load_language('plugin.lang', NBC_UserAdvManager_PATH); 
    129135  global $conf, $template, $page, $lang; 
    130136 
     
    172178        $_POST['login'] = ''; 
    173179      } 
     180 
     181      /* Email without forbidden domains */ 
     182      /* This don't work on call of ValidateEmailProvider() function - Why ?? -> Due to the "return = false|true" in function ?*/ 
     183      //if (isset($conf_nbc_UserAdvManager[12]) and $conf_nbc_UserAdvManager[12] == 'true' and !empty($_POST['email']) and !ValidateEmailProvider($_POST['email'])) 
     184      //{ 
     185      //  $lang['reg_err_login1'] = l10n('reg_err_login7')."'".$conf_nbc_UserAdvManager[13]."'"; 
     186          //  $_POST['login'] = ''; 
     187          //} 
     188      /* This work with a code copy of ValidateEmailProvider() function */ 
     189          if (isset($conf_nbc_UserAdvManager[12]) and $conf_nbc_UserAdvManager[12] == 'true' and !empty($_POST['email'])) 
     190                { 
     191                  $conf_nbc_MailExclusion = split (",",$conf_nbc_UserAdvManager[13]); 
     192                  for ($i = 0 ; $i < count($conf_nbc_MailExclusion) ; $i++) 
     193                    { 
     194                          if (ereg($conf_nbc_MailExclusion[$i], $_POST['email'])) 
     195                            { 
     196                          $lang['reg_err_login1'] = l10n('reg_err_login7')."'".$conf_nbc_UserAdvManager[13]."'"; 
     197                          $_POST['login'] = ''; 
     198                                } 
     199                        } 
     200                } 
    174201    } 
    175202  } 
     
    194221        $_POST['login'] = ''; 
    195222      } 
     223 
     224 
     225      /* Email without forbidden domains */ 
     226      /* This don't work on call of ValidateEmailProvider() function - Why ?? -> Due to the "return = false|true" in function ?*/ 
     227      //if (isset($conf_nbc_UserAdvManager[12]) and $conf_nbc_UserAdvManager[12] == 'true' and !empty($_POST['mail_address']) and !ValidateEmailProvider($_POST['mail_address'])) 
     228      //{ 
     229      //  $lang['reg_err_mail_address'] = l10n('reg_err_login7')."'".$conf_nbc_UserAdvManager[13]."'"; 
     230      //  $_POST['mail_address'] = ''; 
     231      //} 
     232      /* This work with a code copy of ValidateEmailProvider() function */ 
     233                if (isset($conf_nbc_UserAdvManager[12]) and $conf_nbc_UserAdvManager[12] == 'true' and !empty($_POST['mail_address'])) 
     234                  { 
     235                    $conf_nbc_MailExclusion = split (",",$conf_nbc_UserAdvManager[13]); 
     236                        for ($i = 0 ; $i < count($conf_nbc_MailExclusion) ; $i++) 
     237                          { 
     238                            if (ereg($conf_nbc_MailExclusion[$i], $_POST['mail_address'])) 
     239                                  { 
     240                                    $lang['reg_err_login1'] = l10n('reg_err_login7')."'".$conf_nbc_UserAdvManager[13]."'"; 
     241                                        $_POST['login'] = ''; 
     242                                  } 
     243                          } 
     244                  } 
    196245    } 
    197246  } 
     
    247296            $errors[] = $mail_error; 
    248297          } 
    249         } 
     298        /* This don't work on user's profile page - Why ?? */ 
     299                if (isset($conf_nbc_UserAdvManager[12]) and $conf_nbc_UserAdvManager[12] == 'true' and !empty($_POST['mail_address'])) 
     300                  { 
     301                    $conf_nbc_MailExclusion = split (",",$conf_nbc_UserAdvManager[13]); 
     302                        for ($i = 0 ; $i < count($conf_nbc_MailExclusion) ; $i++) 
     303                          { 
     304                            if (ereg($conf_nbc_MailExclusion[$i], $_POST['mail_address'])) 
     305                                  { 
     306                                    $mail_error = l10n('reg_err_login7')."'".$conf_nbc_UserAdvManager[13]."'"; 
     307                                  } 
     308                          } 
     309                  } 
     310              if (!empty($mail_error)) 
     311          { 
     312            $errors[] = $mail_error; 
     313          } 
     314        } 
     315                /* This don't work on call of ValidateEmailProvider() function - Why ?? -> Due to the "return = false|true" in function ?*/ 
     316        //if (isset($_POST['mail_address'])) 
     317        //{ 
     318        //  $mail_error = ValidateEmailProvider($_POST['mail_address']); 
     319        //  if (!empty($mail_error)) 
     320        //  { 
     321        //    $errors[] = $mail_error; 
     322        //  } 
     323        //} 
    250324 
    251325        $typemail = 3; 
  • extensions/NBC_UserAdvManager/maintain.inc.php

    r3352 r3385  
    1010  $q = ' 
    1111    INSERT INTO '.CONFIG_TABLE.' (param, value, comment) 
    12     VALUES ("nbc_UserAdvManager","true;false;false;-1;-1;-1;false;false;;-1;;","Parametres du plugin nbc UserAdvManager") 
     12    VALUES ("nbc_UserAdvManager","true;false;false;-1;-1;-1;false;false;;-1;;;false;;","Parametres du plugin nbc UserAdvManager") 
    1313  ;'; 
    1414  pwg_query($q); 
Note: See TracChangeset for help on using the changeset viewer.