DragonPrime - LoGD Resource Community

Modules, Themes and other customizations for your game => v0.9.7 Modification Discussions => Topic started by: Hadriel on September 26, 2005, 11:05:30 AM



Title: Charakter Ban
Post by: Hadriel on September 26, 2005, 11:05:30 AM
Hi, today on my way to piano lesson, i had an idea:

Why the hell no one had the idea to make character specific bans?
A time later, i completed this mod.

Enjoy it!

Code:
user.php

search :

$sql = "SELECT name,lastip,uniqueid FROM accounts WHERE acctid=\"$_GET[userid]\"";

replace with:
$sql = "SELECT name,lastip,uniqueid,login FROM accounts WHERE acctid=\"$_GET[userid]\"";

search:

    output("<input type='radio' value='ip' name='type' checked> IP: <input name='ip' value=\"".HTMLEntities($row[lastip])."\">`n",true);

add before:

output("<input type='radio' value='name' name='type'> Name: <input name='name' value=\"".HTMLEntities($row[login])."\">`n",true);

search:

    $sql = "INSERT INTO bans (";
    if ($_POST[type]=="ip"){
        $sql.="ipfilter";
    }else{
        $sql.="uniqueid";
    }
    $sql.=",banexpire,banreason) VALUES (";
    if ($_POST[type]=="ip"){
        $sql.="\"$_POST[ip]\"";
    }else{
        $sql.="\"$_POST[id]\"";
    }

replace it with:

if ($_POST[type]=="ip"){
      $sql.="ipfilter";
   }else if ($_POST[type]=="id"){
      $sql.="uniqueid";
   }else{
        $sql.="bannedchar";
        }
   $sql.=",banexpire,banreason) VALUES (";
   if ($_POST[type]=="ip"){
      $sql.="\"$_POST[ip]\"";
   }else if ($_POST[type]=="id"){
      $sql.="\"$_POST[id]\"";
   }else{
        $sql.="\"$_POST[name]\"";
        }

common.php

Code:
search:

function checkban($login=false){
    global $session;
    if ($session['banoverride']) return false;
    if ($login===false){
        $ip=$_SERVER[REMOTE_ADDR];
        $id=$_COOKIE[lgi];
        //echo "<br>Orig output: $ip, $id<br>";
    }else{
        $sql = "SELECT lastip,uniqueid,banoverride FROM accounts WHERE login='$login'";
        $result = db_query($sql) or die(db_error(LINK));
        $row = db_fetch_assoc($result);
        if ($row['banoverride']){
            $session['banoverride']=true;
            //echo "`nYou are absolved of your bans, son.";
            return false;
        }else{
            //echo "`nNo absolution here, son.";
        }
        db_free_result($result);
        $ip=$row[lastip];
        $id=$row[uniqueid];
        //echo "<br>Secondary output: $ip, $id<br>";
    }
    $sql = "select * from bans where ((substring('$ip',1,length(ipfilter))=ipfilter AND ipfilter<>'') OR (uniqueid='$id' AND uniqueid<>'')) AND (banexpire='0000-00-00' OR banexpire>'".date("Y-m-d")."')";
    //echo $sql;
    $result = db_query($sql) or die(db_error(LINK));
    if (db_num_rows($result)>0){
        // $msg.=$session['message'];
        $session=array();
        //$session['message'] = $msg;
        //echo "Session Abandonment";
        $session[message].="`n`4You fall under a ban currently in place on this website:`n";
        for ($i=0;$i<db_num_rows($result);$i++){
            $row = db_fetch_assoc($result);
            $session[message].=$row[banreason];
            if ($row[banexpire]=="0000-00-00") $session[message].="  `\$This ban is permanent!`0";
            if ($row[banexpire]!="0000-00-00") $session[message].="  `^This ban will be removed on ".date("M d, Y",strtotime($row[banexpire]))."`0";
            $session[message].="`n";
        }
        $session[message].="`4If you wish, you may appeal your ban with the petition link.";
        header("Location: index.php");
        exit();
    }
    db_free_result($result);
}

replace it with:

function checkban($login=false){
   global $session;
   if ($session['banoverride']) return false;
   if ($login===false){
      $ip=$_SERVER[REMOTE_ADDR];
      $id=$_COOKIE[lgi];
      //echo "<br>Orig output: $ip, $id<br>";
   }else{
      $sql = "SELECT lastip,uniqueid,login,banoverride FROM accounts WHERE login='$login'";
      $result = db_query($sql) or die(db_error(LINK));
      $row = db_fetch_assoc($result);
      if ($row['banoverride']){
         $session['banoverride']=true;
         //echo "`nYou are absolved of your bans, son.";
         return false;
      }else{
         //echo "`nNo absolution here, son.";
      }
      db_free_result($result);
      $ip=$row['lastip'];
      $id=$row['uniqueid'];
                $name=$row['login'];
      //echo "<br>Secondary output: $ip, $id<br>";
   }
   $sql = "select * from bans where ((substring('$ip',1,length(ipfilter))=ipfilter AND ipfilter<>'') OR (uniqueid='$id' AND uniqueid<>'') OR (bannedchar='$name' AND bannedchar<>'')) AND (banexpire='0000-00-00' OR banexpire>'".date("Y-m-d")."')";
   //echo $sql;
   $result = db_query($sql) or die(db_error(LINK));
   if (db_num_rows($result)>0){
       // $msg.=$session['message'];
      $session=array();
      //$session['message'] = $msg;
      //echo "Session Abandonment";
      $session[message].="`n`4You fall under a ban currently in place on this website:`n";
      for ($i=0;$i<db_num_rows($result);$i++){
         $row = db_fetch_assoc($result);
         $session[message].=$row[banreason];
         if ($row[banexpire]=="0000-00-00") $session[message].="  `\$This ban is permanent!`0";
         if ($row[banexpire]!="0000-00-00") $session[message].="  `^This ban will be removed on ".date("M d, Y",strtotime($row[banexpire]))."`0";
         $session[message].="`n";
      }
      $session[message].="`4If you wish, you may appeal your ban with the petition link.";
      header("Location: index.php");
      exit();
   }
   db_free_result($result);
}

SQL:

Code:
ALTER TABLE `bans` ADD `bannedchar` VARCHAR( 255 ) NOT NULL

~Hadriel


Title: Re:Charakter Ban
Post by: Elessa on September 26, 2005, 11:12:22 AM
isn't that essentially what the brendan blocker is?

here is the  thread  (http://dragonprime.net/index.php?board=17;action=display;threadid=2011) discussing its features.  or does it only work in the 1.0.x environment?


Title: Re:Charakter Ban
Post by: Hadriel on September 26, 2005, 11:16:29 AM
i dont showed other threads about character specific bans. But the one you had posted is for 1.x.x only


dit: fixed 2 little bugs


Title: Re:Charakter Ban
Post by: Excalibur on December 31, 2005, 01:11:42 AM
Just a little visualisation fix.
The name of the char banned doesn't show up in the list.
Open user.php, find:
Code:
      $sql = "SELECT DISTINCT accounts.name FROM bans, accounts WHERE (ipfilter='".addslashes($row['ipfilter'])."' AND bans.uniqueid='".addslashes($row['uniqueid'])."') AND ((substring(accounts.lastip,1,length(ipfilter))=ipfilter AND ipfilter<>'') OR (bans.uniqueid=accounts.uniqueid AND bans.uniqueid<>''))";
       $r = db_query($sql);
       for ($x=0;$x<db_num_rows($r);$x++){
          $ro = db_fetch_assoc($r);
          output("`0{$ro['name']}`n");
       }
and replace it with:
Code:
       if ($row[bannedchar] == ""){
           $sql = "SELECT DISTINCT accounts.name FROM bans, accounts WHERE (ipfilter='".addslashes($row['ipfilter'])."' AND bans.uniqueid='".addslashes($row['uniqueid'])."') AND ((substring(accounts.lastip,1,length(ipfilter))=ipfilter AND ipfilter<>'') OR (bans.uniqueid=accounts.uniqueid AND bans.uniqueid<>''))";
           $r = db_query($sql);
           for ($x=0;$x<db_num_rows($r);$x++){
             $ro = db_fetch_assoc($r);
             output("`0{$ro['name']}`n");
           }
        } else {
           output("`0".$row[bannedchar]."`n");
        }
That do the trick. Now even player banned with specific char ban show up in the list.

Excalibur

© 2018 DragonPrime - LoGD Resource Community
Email Talisman: talisman -at- gmail.com
&oeXs)2U7=V BmܲV.U e=;p\}eG )Jj} C5EH7ˤH=j } mo|*Ŋw{drV_@IV>/- TFQJ׀̀Ve}l1,V O iNYx͘$e$;
Forums: Powered by SMF 1.1.21 | SMF © 2006-2007, Simple Machines