Changeset 31375


Ignore:
Timestamp:
Feb 28, 2016, 5:06:58 PM (5 years ago)
Author:
ddtddt
Message:

[extensions] - BanIP - add delete all

Location:
extensions/BanIP
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • extensions/BanIP/admin.php

    r31373 r31375  
    9292
    9393
    94 if (isset($_POST['submitaddipban2'])) {
    95         $query = 'UPDATE ' . BANIP_TABLE .' SET ip= "'.$_POST['inserip'].'" WHERE id = '.$_POST['invisibleID'].';';
    96         $result = pwg_query($query);
    97         $_SESSION['page_infos'] = array(l10n('Ip ban update'));
     94if (isset($_POST['submitdeleteall'])) {
     95        $query = 'DELETE FROM ' . BANIP_TABLE . ';';
     96    pwg_query($query);
    9897        redirect($admin_base_url);
    9998}
     
    111110
    112111if (isset($_POST['submitaddipban'])) {
    113         $query = 'INSERT INTO ' . BANIP_TABLE .'(ip) VALUES ("' . $_POST['inserip'] . '");';
    114         $result = pwg_query($query);
    115         $_SESSION['page_infos'] = array(l10n('Ip ban insert'));
    116         redirect($admin_base_url);
    117 }
    118                
    119        
     112  $plage= explode(".", $_POST['inserip']);
     113  if(count($plage)!=4)
     114        {
     115          $_SESSION['page_errors'] = array(l10n('This Isn\'t an IP'));
     116          redirect($admin_base_url);
     117        }
     118  if($plage[3]=='*')
     119        {
     120          $query = 'SELECT COUNT(*) AS verif_exist FROM ' . BANIP_TABLE . ' WHERE ip = \'' . $_POST['inserip'] . '\';';
     121          $result = pwg_query($query);
     122      $exist=pwg_db_fetch_array($result);
     123          if($exist['verif_exist']>0)
     124                {
     125                  $_SESSION['page_errors'] = array(l10n('Range IP already banned'));
     126                  redirect($admin_base_url);
     127                }
     128        }
     129  $ipaddinrange=$plage[0].".".$plage[1].".".$plage[2].".*";
     130  $query = 'SELECT COUNT(*) AS verif_exist FROM ' . BANIP_TABLE . ' WHERE ip = \'' . $ipaddinrange . '\';';
     131  $result = pwg_query($query);
     132  $exist=pwg_db_fetch_array($result);
     133  if($exist['verif_exist']>0)
     134        {
     135          $_SESSION['page_errors'] = array(l10n('IP is in a range banned'));
     136          redirect($admin_base_url);
     137        }
     138  $query = 'SELECT COUNT(*) AS verif_exist FROM ' . BANIP_TABLE . ' WHERE ip = \'' . $_POST['inserip'] . '\';';
     139  $result = pwg_query($query);
     140  $exist=pwg_db_fetch_array($result);
     141  if($exist['verif_exist']>0)
     142        {
     143          $_SESSION['page_errors'] = array(l10n('IP already banned'));
     144          redirect($admin_base_url);
     145        }
     146  if($plage[3]=='*')
     147    {
     148          $oldip=$plage[0].".".$plage[1].".".$plage[2].".";
     149          $query = 'DELETE FROM ' . BANIP_TABLE . ' WHERE ip LIKE "' . $oldip . '%";';
     150    pwg_query($query);
     151          $_SESSION['page_infos'] = array(l10n('Range Ip ban insert'));
     152        }
     153  else
     154    {
     155          $_SESSION['page_infos'] = array(l10n('Ip ban insert'));
     156        }
     157  $query = 'INSERT INTO ' . BANIP_TABLE .'(ip) VALUES ("' . $_POST['inserip'] . '");';
     158  $result = pwg_query($query);
     159  redirect($admin_base_url);
     160}
     161
     162if (isset($_POST['submitaddipban2'])) {
     163  $plage= explode(".", $_POST['inserip']);
     164  if(count($plage)!=4)
     165        {
     166          $_SESSION['page_errors'] = array(l10n('This Isn\'t an IP'));
     167          redirect($admin_base_url);
     168        }
     169  if($plage[3]=='*')
     170        {
     171          $query = 'SELECT COUNT(*) AS verif_exist FROM ' . BANIP_TABLE . ' WHERE ip = \'' . $_POST['inserip'] . '\';';
     172          $result = pwg_query($query);
     173      $exist=pwg_db_fetch_array($result);
     174          if($exist['verif_exist']>0)
     175                {
     176                  $_SESSION['page_errors'] = array(l10n('Range IP already banned'));
     177                  redirect($admin_base_url);
     178                }
     179        }
     180  $ipaddinrange=$plage[0].".".$plage[1].".".$plage[2].".*";
     181  $query = 'SELECT COUNT(*) AS verif_exist FROM ' . BANIP_TABLE . ' WHERE ip = \'' . $ipaddinrange . '\';';
     182  $result = pwg_query($query);
     183  $exist=pwg_db_fetch_array($result);
     184  if($exist['verif_exist']>0)
     185        {
     186          $_SESSION['page_errors'] = array(l10n('IP is in a range banned'));
     187          redirect($admin_base_url);
     188        }
     189  $query = 'SELECT COUNT(*) AS verif_exist FROM ' . BANIP_TABLE . ' WHERE ip = \'' . $_POST['inserip'] . '\';';
     190  $result = pwg_query($query);
     191  $exist=pwg_db_fetch_array($result);
     192  if($exist['verif_exist']>0)
     193        {
     194          $_SESSION['page_errors'] = array(l10n('IP already banned'));
     195          redirect($admin_base_url);
     196        }
     197  if($plage[3]=='*')
     198    {
     199          $oldip=$plage[0].".".$plage[1].".".$plage[2].".";
     200          $query = 'DELETE FROM ' . BANIP_TABLE . ' WHERE ip LIKE "' . $oldip . '%";';
     201    pwg_query($query);
     202          $_SESSION['page_infos'] = array(l10n('Range Ip ban update'));
     203        }
     204  else
     205    {
     206          $_SESSION['page_infos'] = array(l10n('Ip ban update'));
     207        }
     208  $query = 'UPDATE ' . BANIP_TABLE .' SET ip= "'.$_POST['inserip'].'" WHERE id = '.$_POST['invisibleID'].';';
     209  $result = pwg_query($query);
     210  redirect($admin_base_url);
     211}
     212
    120213        break;
    121214}
  • extensions/BanIP/admin.tpl

    r31373 r31375  
    66        <fieldset>
    77                <input class="submit" name="submitipban" type="submit" value="{'Add IP ban or IP address range'|@translate}" />
     8                <input class="submit" name="submitdeleteall" type="submit" onclick="return confirm('{'Are you sure?'|@translate|@escape:'javascript'}');" value="{'Delete all IP Ban'|@translate}"/>
    89        </fieldset>
    910</form>
  • extensions/BanIP/language/en_UK/description.txt

    r31368 r31375  
    1 Ban IP
     1Ban adresse IP or range adresse IP
  • extensions/BanIP/language/en_UK/plugin.lang.php

    r31373 r31375  
    2929$lang['List IP banned and IP address range'] = 'List IP banned and IP address range';
    3030$lang['Edit IP banned or IP address range'] = 'Edit IP banned or IP address range';
    31 $lang['Add IP ban or IP address range'] = 'Add IP ban or IP address range';
    3231$lang['IP'] = 'IP';
    3332$lang['Ban IP'] = 'Ban IP';
    3433$lang['Range IP address banned'] = 'Range IP address banned';
     34$lang['Delete all IP Ban'] = 'Delete all IP Ban';
     35$lang['This Isn\'t an IP'] = 'This Isn\'t an IP';
     36$lang['Range IP already banned'] = 'Range IP already banned';
     37$lang['IP is in a range banned'] = 'IP is in a range banned';
     38$lang['IP is in a range banned'] = 'IP is in a range banned';
     39$lang['IP already banned'] = 'IP already banned';
     40$lang['Range Ip ban update'] = 'Range Ip ban update';
Note: See TracChangeset for help on using the changeset viewer.