Changeset 6758


Ignore:
Timestamp:
Aug 15, 2010, 3:03:21 AM (10 years ago)
Author:
Eric
Message:
  • Bug 1511 fixed - New function to blacklist excluded IPs or ranged IPs for registration
  • Bug 1792 fixed (Thx to TOnin)
Location:
extensions/nbc_HistoryIPExcluder/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • extensions/nbc_HistoryIPExcluder/trunk/admin/HIPE_admin.php

    r5615 r6758  
    3737  pwg_query($query);
    3838
     39  if (!isset($_POST['HIPE_chkb'])) $_POST['HIPE_chkb'] = '0';
     40  $newconf_HIPE = array(
     41    'Blacklist' => $_POST['HIPE_chkb'],
     42    'Version'   => $version,
     43  );
     44 
     45  $conf['HistoryIPConfig'] = serialize($newconf_HIPE);
     46
     47  $query = '
     48    UPDATE '.CONFIG_TABLE.'
     49    SET value="'.addslashes($conf['HistoryIPConfig']).'"
     50    WHERE param="HistoryIPConfig"
     51    LIMIT 1';
     52  pwg_query($query);
     53
    3954  // information message
    4055  array_push($page['infos'], l10n('HIPE_save_config'));
     
    85100  while ($subrow = pwg_db_fetch_assoc($subresult))
    86101  {
    87     $template->assign(
     102    $template->append(
    88103      'resultat',
    89104      array(
     
    125140  while ($subrow = pwg_db_fetch_assoc($subresult))
    126141  {
    127     $template->assign(
     142    $template->append(
    128143      'resultat',
    129144      array(
     
    158173  while ($subrow = pwg_db_fetch_assoc($subresult))
    159174  {
    160     $template->assign(
     175    $template->append(
    161176      'resultat',
    162177      array(
     
    172187elseif ( isset($_POST['HIPE_MemberForIp']) and isset($_POST['HIPE_input']))
    173188{
    174   $template->assign(
     189  $template->append(
    175190    array(
    176191      'HIPE_DESCRIPTION2' => l10n('HIPE_MemberForIp_description'),
     
    205220
    206221$conf_HIPE = explode("," , $conf['HistoryIPExcluder']);
     222$HIPE_Config = unserialize($conf['HistoryIPConfig']);
    207223
    208224$template->assign(
     
    215231);
    216232
     233  if ($HIPE_Config['Blacklist'] == 1) $template->assign(array('HIPE_IPBlacklisted' => 'checked="checked"'));
     234
    217235  $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/HIPE_admin.tpl');
    218236  $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
  • extensions/nbc_HistoryIPExcluder/trunk/admin/HIPE_admin.tpl

    r5615 r6758  
    1515    <div style="text-align:center;">
    1616      <textarea name="HIPE_IPs_Excluded" rows="10" cols="30" {$TAG_INPUT_ENABLED}>{$IPs_EXCLUDED}</textarea>
     17    </div>
    1718
    18     </div>
     19    <fieldset>
     20    <legend>{'HIPE_IPBlacklist_title'|@translate}</legend>
     21      <ul>
     22                    <li><input type="checkbox" name="HIPE_chkb" {$HIPE_IPBlacklisted} value="1">&nbsp;{'HIPE_IPBlacklisted'|@translate}</li>
     23      </ul>
     24    </fieldset>
    1925   
    2026    <p><input type="submit" name="submit" value="{'submit'|@translate}" class="bouton" {$TAG_INPUT_ENABLED}> <input type="submit" name="CleanHist" value="{'HIPE_CleanHist'|@translate}" class="bouton" {$TAG_INPUT_ENABLED}></p>
     
    4450      <table>
    4551      <!-- BEGIN resultat -->
    46         <tr>
    47           <td>{$resultat.HIPE_RESULTAT1}</td>
    48           <td>{$resultat.HIPE_RESULTAT2}</td>
    49           <td>{$resultat.HIPE_RESULTAT3}</td>
    50           <td>{$resultat.HIPE_RESULTAT4}</td>
    51           <td>{$resultat.HIPE_RESULTAT5}</td>
     52      {foreach from=$resultat item=result}
     53        <tr style="color: red;">
     54          <td>{$result.HIPE_RESULTAT1}</td>
     55          <td>{$result.HIPE_RESULTAT2}</td>
     56          <td>{$result.HIPE_RESULTAT3}</td>
     57          <td>{$result.HIPE_RESULTAT4}</td>
     58          <td>{$result.HIPE_RESULTAT5}</td>
    5259        </tr>
     60      {/foreach}
    5361      <!-- END resultat -->
    5462      </table>
  • extensions/nbc_HistoryIPExcluder/trunk/language/fr_FR/plugin.lang.php

    r5615 r6758  
    3030$lang['HIPE_version'] = ' - Version: ';
    3131// --------- End: New or revised $lang ---- from version 2.1.0
     32
     33// --------- Starting below: New or revised $lang ---- from version 2.1.1
     34$lang['HIPE_IPBlacklist_title'] = 'Exclusion à l\'inscription';
     35$lang['HIPE_IPBlacklisted'] = ' Empêcher l\'inscription à la galerie des IP exclues de l\'historique (Blacklistage)';
     36$lang['Error_HIPE_BlacklistedIP'] = 'Erreur! Votre IP a été bannie. Vous ne pouvez plus vous inscrire à cette galerie. Contactez l\'administrateur pour de plus amples détails.';
     37// --------- End: New or revised $lang ---- from version 2.1.1
    3238?>
  • extensions/nbc_HistoryIPExcluder/trunk/main.inc.php

    r5615 r6758  
    22/*
    33Plugin Name: History IP Excluder
    4 Version: 2.1.0
    5 Description: Permet l'exclusion d'une IP ou d'une plage d'IP de l historique - Excludes one IP or a range of IP from the history.
     4Version: 2.1.1
     5Description: Permet l'exclusion d'une IP ou d'une plage d'IP de l historique et de les blacklister à l'inscription - Base MySql seulement! / Excludes one IP or a range of IP from the history and to blacklist them on registration - MySql database only!
    66Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=147
    77Author: Nicco, Eric
     
    2020                  - Removing "nbc_" prefix in plugin code and display in piwigo's plugin manager
    2121                  - Displaying the good plugin name and current version in admin panel
     22                 
     232.1.1             - Bug 1792 fixed (Thx to TOnin)
     24                  - Bug 1511 fixed - New function to blacklist excluded IPs or ranged IPs for registration
    2225
    2326--------------------------------------------------------------------------------
     
    8689  }
    8790}
     91
     92/* Check users registration */
     93add_event_handler('register_user_check', 'HIPE_RegistrationCheck', EVENT_HANDLER_PRIORITY_NEUTRAL +2, 2);
     94
     95function HIPE_RegistrationCheck($err, $user)
     96{
     97  global $errors, $conf;
     98  load_language('plugin.lang', HIPE_PATH);
     99 
     100  if (count($err)!=0 ) return $err;
     101 
     102  $IP_Client = explode('.', $_SERVER['REMOTE_ADDR']);
     103  $HIPE_Config = unserialize($conf['HistoryIPConfig']);
     104  $conf_HIPE = explode("," , $conf['HistoryIPExcluder']);
     105 
     106  if (isset($HIPE_Config['Blacklist']) and $HIPE_Config['Blacklist'] == true)
     107  {
     108    foreach ($conf_HIPE as $Exclusion)
     109    {
     110      $IP_Exclude = explode('.', $Exclusion);
     111 
     112      if (
     113        (($IP_Client[0] == $IP_Exclude[0]) or ($IP_Exclude[0] == '%')) and
     114        (!isset($IP_Exclude[1]) or ($IP_Client[1] == $IP_Exclude[1]) or ($IP_Exclude[1] == '%')) and
     115        (!isset($IP_Exclude[2]) or ($IP_Client[2] == $IP_Exclude[2]) or ($IP_Exclude[2] == '%')) and
     116        (!isset($IP_Exclude[3]) or ($IP_Client[3] == $IP_Exclude[3]) or ($IP_Exclude[3] == '%'))
     117      )
     118      {
     119        $err = l10n('Error_HIPE_BlacklistedIP');
     120      }
     121    }
     122    return $err;
     123  }
     124}
    88125?>
  • extensions/nbc_HistoryIPExcluder/trunk/maintain.inc.php

    r5615 r6758  
    1010INSERT INTO '.CONFIG_TABLE.' (param,value,comment)
    1111VALUES ("HistoryIPExcluder","","History IP Excluder parameters");
     12';
     13     
     14  pwg_query($q);
     15
     16$default = array (
     17  'Blacklist' => "0",
     18  'Version'=> "2.1.1",
     19);
     20
     21  $q = '
     22INSERT INTO '.CONFIG_TABLE.' (param,value,comment)
     23VALUES ("HistoryIPConfig","'.addslashes(serialize($default)).'","History IP Excluder options");
    1224';
    1325     
     
    3143        if ($count == 1)
    3244        {
    33   /* upgrade from branch 2.0.0 to 2.0.1 */
     45  /* upgrade from branch 2.0.0 to 2.0.1   */
    3446  /* ************************************ */
    3547                upgrade_200();
     48        }
     49
     50        $query = '
     51SELECT param
     52  FROM '.CONFIG_TABLE.'
     53WHERE param = "HistoryIPConfig"
     54;';
     55  $count = pwg_db_num_rows(pwg_query($query));
     56
     57        if ($count == 0)
     58        {
     59  /* upgrade from branch 2.1.0 to 2.1.1   */
     60  /* ************************************ */
     61                upgrade_210();
    3662        }
    3763}
     
    4268  global $conf;
    4369
    44   if (isset($conf['nbc_HistoryIPExcluder']))
     70  if (isset($conf['HistoryIPExcluder']))
    4571  {
    4672    $q = '
    4773DELETE FROM '.CONFIG_TABLE.'
    48 WHERE param="nbc_HistoryIPExcluder" LIMIT 1;
     74WHERE param="HistoryIPExcluder" LIMIT 1;
    4975';
    5076
    5177    pwg_query($q);
    5278  }
     79  if (isset($conf['HistoryIPConfig']))
     80  {
     81    $q = '
     82DELETE FROM '.CONFIG_TABLE.'
     83WHERE param="HistoryIPConfig" LIMIT 1;
     84';
     85
     86    pwg_query($q);
     87  } 
    5388}
    5489
     
    71106;';
    72107  pwg_query($q);
     108
     109  upgrade_210();
     110}
     111
     112function upgrade_210()
     113{
     114  global $conf;
     115 
     116  $default = array (
     117    'Blacklist' => "0",
     118    'Version'=> "2.1.1",
     119  );
     120
     121  $q = '
     122INSERT INTO '.CONFIG_TABLE.' (param,value,comment)
     123VALUES ("HistoryIPConfig","'.addslashes(serialize($default)).'","History IP Excluder options");
     124';
     125     
     126  pwg_query($q);
    73127}
    74128?>
Note: See TracChangeset for help on using the changeset viewer.