DragonPrime - LoGD Resource Community
Welcome Guest
  • Good evening, Guest.
    Please log in, or register.
  • October 17, 2018, 05:25:46 PM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
Search

Pages: [1]   Go Down
  Print  
Author Topic: Charakter Ban  (Read 3936 times)
0 Members and 1 Guest are viewing this topic.
Hadriel
Guest
« 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
« Last Edit: September 26, 2005, 11:28:23 AM by Hadriel » Logged
Elessa
Faerie
Mod God
*****
Offline Offline

Posts: 3598


short, sweet and to the point


View Profile
« Reply #1 on: September 26, 2005, 11:12:22 AM »

isn't that essentially what the brendan blocker is?

here is the thread discussing its features.  or does it only work in the 1.0.x environment?
« Last Edit: September 26, 2005, 11:12:53 AM by Elessa » Logged

Uuma ma ten rashwe, ta tuluva a lle

Play the latest beta version here on LoGD DragonPrime - Axebridge
Hadriel
Guest
« Reply #2 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
« Last Edit: September 26, 2005, 11:28:44 AM by Hadriel » Logged
Excalibur
Member
Mod God
*****
Offline Offline

Posts: 573


I'm a newbie, plz forgive me!


View Profile WWW
« Reply #3 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
Logged

Spock: Random chance seems to have operated in our favor.
McCoy: In plain, non-Vulcan English, we've been lucky.
Spock: I believe I said that, Doctor.
Pages: [1]   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Play LoGD on Dragonprime

Support Us
No funds raised yet this year
Your help is greatly appreciated!
Recent Topics
DragonPrime LoGD
Who's Online
35 Guests, 0 Users
Home Forums News Downloads Login Register Advanced Search