RealBomber
Member
+1|6575|Norway
Has anyone made a script to bild a database over bans?
Either from banlist.con or mm_bans.xml on the BF2-server,
or a locally stored backup of the banlist.

Some big server-operators have ban times like this:

TEAMKILL
1. time - 3 days
2. time - 1 week
3. time - 2 weeks
4. time - Perm.

PTK
1. time - 1 day
2. time - 1 week
3. time - 2 weeks

BLOCKING HW
1. time - 1 day
2. time - 1 week
3. time - 2 weeks

SMACKTARD/LANGUAGE/

1. time - 1 day
2. time - 3 days
3. time - 1 week

How do they keep track of all those bans????
Trigger_Happy_92
Uses the TV missle too much
+394|6921
its in the "banlist.xml" if your running a client like bf2cc or such
RealBomber
Member
+1|6575|Norway
This has nothing to do with accidental tk's or punish.
This is tk's that are deliberate and that admins see ingame or on the battlerecorder.

The goal is not to ban as many players as possible from the server but rather
give them a wakeup call that e.g. teamkilling to get the jet is not acceptable.

But when it comes to SOB's that systematically ruin the game for us, they will receive a longer ban time.
There is no way that we will forgive the player the second or third time when they
come crying: “It was an accident, I didn’t mean to snipe the pilot out of the plane”

All I need is a simple way to check if the player has been banned before
without the need to thumb thru 180 backupfiles of the banlist (take backup every day)


The ideal solution would be to have something similar to the script we
use to harvest hash-keys from the players.
The first part of the script writes the data to a MySQL database:

Originally posted on www.bf2cc.com
<?php

/*
LogHash.php
Created by Mugzy
email: Mugzy@mugzy.org

--Usage--
This script will connect to your BF2 server and record the hashes to a MySQL DB.

--Setup--
Create a new MySQL database and run the following SQL to create the required table:
CREATE TABLE `bf2hash` (
  `iname` varchar(255) NOT NULL default '',
  `hash` varchar(255) NOT NULL default '',
  `date` datetime default NULL
) TYPE=MyISAM;

--Configuration--
Enter your servers ip, port, and rcon password.
Enter the database server, username, password, and database name.
*/

session_start();
putenv("TZ=US/Eastern");

buildlist("ip","rconport","rconpassword");

function buildlist($server, $port, $password)
{
   ob_start();

   $dbserver = "ip";
   $dbuser = "user";
   $dbPass = "pass";
   $dbName = "dbname";
   $dbTable = "bf2hash";
   $link = mysql_connect ($dbserver, $dbuser, $dbPass)
        or die ("Could not connect");
   $results = mysql_select_db($dbName,$link)
      or die('failed because '.mysql_error());
   $timeout = 5;

   if(!$handle = @fsockopen($server, $port, $errno, $errstr, $timeout))
      {
         echo "Could not connect to server: " . $server . "<br>";
         ob_end_flush();
         flush();
      }
      else
      {
         socket_set_timeout($handle, $timeout);
         @fread($handle,128);
         $keyzeile = @fread($handle,33);
         $key = str_replace("### Digest seed: ", "", $keyzeile);
         $pass_send = "login " . digest($key, $password) . "\n";

         @fwrite($handle, $pass_send);
         @fgets($handle);
         @fgets($handle);
         $antwort = @fgets($handle);
         if(substr_count($antwort, "failed"))
           {
              echo "Login failed<br>";
              ob_end_flush();
              flush();
              return;
           }

         $cmd = "exec admin.listPlayers\n";
         @fwrite($handle, $cmd);
         $eofplist = false;
         echo "Building Player List...<br>";
         flush();
         while( !$eofplist )
            {
               $result = @fgets($handle);

               if(trim($result) == "")
               {
                  return;
                  $eofplist = true;
               }
               else
               {
                  $result = str_replace("  ", " ", $result);
        $columns = explode(" ", trim($result));
        if(count($columns)==10)$columns[3]=$columns[3]." ".$columns[4]; // add this line
        $result2 = @fgets($handle);
        $columns2 = explode(" ", trim($result2));
                  $ipcolumn = explode(":", $columns[7]);
                     {
                        $sql="select count(hash) as cnt, hash from $dbTable where iname = '$columns[3]' group by iname";
                        $result=MySQL_query($sql,$link) or die('failed because '.mysql_error());

                        $myrow=MySQL_fetch_array($result);
                        if($myrow['cnt'] > 0)
                           {
                              echo "$columns[3] is already in database<br>";
                           }
                           else
                           {
                              echo "Adding " . $columns[3] . " " . $columns2[2] . " to database<br>";
                              mysql_select_db($dbName,$link);
                              $sql="insert into $dbTable (iname, hash, date) VALUES('$columns[3]', '$columns2[2]', SYSDATE())";
                              $result=MySQL_query($sql,$link) or die('failed because '.mysql_error());

                              flush();
                           }
                        }
                  }
            }
      }
}

function digest($seed, $pw)
{
   $m = md5($seed . $pw);
   return $m;
}

?>
The second part is where you send enquirys to the database:
Originally posted on www.bf2cc.com
<?php
/*
Findhash.php
Created by Mugzy
email: Mugzy@mugzy.org

Usage: This script will allow you to lookup players by name or hash.

Configuration: Just enter the database server, username, and database name.
*/

session_start();
putenv("TZ=US/Eastern");

//---Configuration for database where hashes are stored.---

$dbserver = "ip";
$dbuser = "user";
$dbPass = "pass";
$dbName = "dbname";
$dbTable = "bf2hash";

//---End configuration---


//...connect to the database...
$link = mysql_connect ($dbserver, $dbuser, $dbPass)
        or die ("Could not connect");
mysql_select_db($dbName,$link);


echo "<title>BF2 Hash Lookup</title><strong><font size=5 face=Arial, Helvetica, sans-serif>BF2 Hash Lookup<br></font></strong>Created by <A href=mailto:mugzy@mugzy.org>Mugzy</a><p>";


if ($name == "") //...If $name is empty, we display the form...
   {
      $sql="select count(*) as count from $dbTable"; //...Get a count of records in the database...
      $result=MySQL_query($sql,$link);
      $row = mysql_fetch_array($result);
      echo "This system currently has the CD hash value for <b>" . $row['count'] . "</b> players.<br>";
      echo "<form method=get>Enter part of a player's name or CD hash:<br><input type=text name=name><br><input type=radio name=type value=name checked>Name        <input type=radio name=type value=hash>Hash<br><br><input type=submit value=Submit></form>";
   }
   else
   {
      if(strlen($name) < 3) //..Make them enter at least 3 characters of a name to search on.
         {
            echo "Error, you must enter at least 3 characters!<br>";
            echo "<a href=?>Back</a>";
            exit();
         }

      if ($type == "name")  //...If they searched for a name..
         {
            $sql="select * from $dbTable where iname like '%". $name ."%' order by iname";
         }
         else //..They searched for a hash...
         {
            $sql="select * from $dbTable where hash like '%". $name ."%' order by iname";
         }

      $result=MySQL_query($sql,$link) or die('failed because '.mysql_error());
          echo "<a href=?>Back</a>";

//...Lets build the results table...
      echo "<table cellpadding=3 bordercolor=black border=2><tr><td><b>Name</b></td><td><b>Hash</b></td><td><b>Date Added</b></td></tr>";

      while($myrow=MySQL_fetch_array($result))
         {
            echo "<tr><td>" . $myrow['iname'] . "</td><td>" . $myrow['hash'] . "</td><td>" . $myrow['date'] . "</td>";
            echo "</tr>";
            $x1 = 1;
         }
         if($x1 != 1)
            {
               echo "<tr><td colspan=5><b>No records found for " . $name . ".</b></td></tr>";
            }
         echo "</table>";
   }
?>
We got the script from www.bf2cc.com and it works perfectly!!

I am unfortunately a complete noob when it comes to scripts so I
was hoping that some of you guys have any ideas....?

Last edited by RealBomber (2007-01-27 18:14:13)

Board footer

Privacy Policy - © 2025 Jeff Minard