vue Tuto bannir IP
Kommunauty
Connexion
Inscription

Tuto bannir IP


arno Messages : 83

bonjour,

Dans admin ,créer banadmin.php :

<?php


define('INSIDE' , true);
define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/common.php';
includeLang('admin/banned');

if ($user['authlevel'] >= 3) {
if ($_GET['x'] == 'add') {
if ($_POST['add']){

$ip = $_POST['ip'];
if (!$ip){
message($lang['add_no_ip'], $lang['error']);
}
addban($ip,$_POST[reason],$_POST[legnth]);

}else{
$page1 .= parsetemplate(gettemplate('admin/bannedipform'), $lang);
display($page1, $lang['ip_ban_sys'], false, '', true );
}
}
if ($_GET['x'] == 'delete') {
if ($_GET['id']){
delban($_GET['id']);
}else{
// show error
message($lang['rem_no_ip'], $lang['error']);
}
}
$listbanned = doquery("SELECT * FROM {{table}}", 'bannedip');
$i = 0;
$banned_list = '';
while ($r = mysql_fetch_array($listbanned)){
$i++;
$r['i'] = $i;
$r['razon'] = $r['reason'];
$r['borrar'] = "<a href="./banadmin.php?x=delete&id={$r[id]}">$lang['banadmin_unban']</a>";
$banned_list .= parsetemplate(gettemplate('admin/bannedip_row'), $r);
}
$lang['lista'] = $banned_list;
$page .= parsetemplate(gettemplate('admin/bannedip'), $lang);
display($page, $lang['ip_ban_sys'], false, '', true );
}else{
message($lang['no_admin'], $lang['error']);
}

?>

Dans language/admin créer banned.mo :

<?php

$lang['add_ip_ban_ok']         = "Le% s IP est banni avec succès.";
$lang['add_ip_ban']    = "Ajout d'interdiction IP";
$lang['addb']         = "Ajouter";
$lang['rem_ip_ban_ok']         = "Le% s IP a été correctement levée de l'interdiction.";
$lang['rem_ip_ban']            = "interdiction IP révoqués à";
$lang['remb']                  = "Annulation de l'enregistrement";
$lang['error']                 = "Erreur";
$lang['add_no_ip']             = "Vous n'avez pas ou uuml UNG%; entré IP non valide.";
$lang['rem_no_ip']             = "Erreur, vous avez besoin d'une adresse IP pour débannir sélectionnez.";
$lang['no_admin']              = "Vous avez pas le pouvoir de.";

$lang['banadmin_unban'] = "approbation de l'interdiction";

?>

dans templates/OpenGame/admin créer trois fichiers :

bannedip.tpl :

<table width="600"><tr><td class="c" colspan="11"><font color=yellow><center>système de ban IP</center></font></td></tr>
<tr>
  <td class="c" colspan="8"><center><a href="banadmin.php?x=add">Ajout ou sortie</a></center></td>
</tr>
<br>
<tr>
     <th>Nombre</th>   
     <th>IP</th>   
     <th>Basic</th>
     <th>Fin de l'interdiction</th>
   </tr>
<br>
{liste}
<br>

</table>

bannedip_row.tpl :

<tr>
     <th> {i} </th>
      <th>{ip}</th>
     <th>{raison}</th>
     <th>{supprimer}</th>
</tr>

bannedipform.tpl :

<br><br>
<table width="600"><tr><td class="c" colspan="11"><font color=yellow><center>Ajout d'interdiction IP</center></font></td></tr>
<form method='post' action="banadmin.php?x=add">
<tr>
   <th width="129">IP-Adresse</th>
   <th width="268"><input type='text' name='ip'></th>
</tr><tr>
   <th>Basic</th>
   <th><input type='text' name='motif'></th>
</tr><tr>
   <th>Durée</th>
   <th><input type='text' name='legnth'></th>
</tr><tr>
   <th colspan="2"><input type='submit' name='add' value='Ajouter'></th>
</tr>
</form>
</table>

et la requete sql a effectuer via phpAdmin :

CREATE TABLE IF NOT EXISTS `game_bannedip` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `ip` varchar(255) NOT NULL DEFAULT '',
  `time` varchar(255) NOT NULL DEFAULT '',
  `long` varchar(255) NOT NULL DEFAULT '',
  `reason` text NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

ne pas oublier de changer si besoin pour eviter des bugs au niveau du fichier banadmin.php:

define('INSIDE' , true);
define('INSTALL' , false);
define('IN_ADMIN', true);
require_once dirname(dirname(__FILE__)) .'/common.php';

define('INSIDE'  , true);
define('INSTALL' , false);
define('IN_ADMIN', true);

$xnova_root_path = './../';
include($xnova_root_path . 'extension.inc');
include($xnova_root_path . 'common.' . $phpEx);

arno

dimanche 24 octobre 2010

Mizur Messages : 6615

Et ça permet de bannir une IP du jeu, c'est ça?

Il est testé et fonctionnel?

Merci du partage en tout cas !

lundi 25 octobre 2010

arno Messages : 83

oui et fonctionnel sur mon serveur

mardi 26 octobre 2010 (Dernière édition mercredi 27 octobre 2010)

Darkevil Messages : 221

Très utile merci

lundi 17 janvier 2011

oasis Messages : 55

Merci pour ce mod qui est tres utile

lundi 26 mai 2014

Répondre Pour répondre, tu dois d'abord t'inscrire rapidement sur Kommunauty. Rejoins-nous vite !