Jump to content

How to make script ignore parsing differences


Airborne328

Recommended Posts

Evening,

 

First off, if this request for help is in the wrong spot then I sicnerely apologize.

 

I am an online gamer who plays America's Army.  I created with the help of someone who is no longer available a tool/block that one could use to search for bans, etc.. on individual players an clans.

 

The update.php script was made to "not sure of correct wording" to use and see specific things.  However some of the anti-cheat organizations have mistakes "small in-differences" in some of their banlines.

 

Instead of getting them to correct each one as they come up, I am trying to figure out how to have my update script/php page ignore/bypass these indifferences and still log them.

 

I am stumped,  I am not sure what is needed to help anyone here understand the kind of tool/site block.  So I willpost several things including a zip file that is in itself the block tool that I offer to my Repo Depot Admins @ www.aaorepodepot.us in the downloads area.

 

Here is an example of what I see when trying to update the 4 AC banlists for the site block, using update.php.

 

http://www.combatlifesavers.us/aabansblock/update.php

 

Updating 4 ban lists:

 

--------------------------------------------------------------------------------

 

 

Updating the ACI ban list...

Warning: Unable to parse: // 20081909a - ACI Banlist

Warning: Unable to parse:

Warning: Unable to parse: [2008.05.18 23:36:28] d70abed08404835aad92f231e6afe408 "Dark-Strike" "75.155.116.119"

Warning: Unable to parse: [2008.05.20 11:48:52] e56b1dd7cee9c603c8096e9a6039f0da "[PTuga]sos" "213.22.248.101"

Warning: Unable to parse: [2008.08.23 00:36:11] 9026d5f91ec7e75785895663d59ba4f6 "maxsimiljone" "90.190.138.82"

Warning: Unable to parse:

Updated the ACI ban list with 37539 bans

 

 

--------------------------------------------------------------------------------

 

 

Updating the AON ban list...

Warning: Unable to parse:

Updated the AON ban list with 33192 bans

 

--------------------------------------------------------------------------------

 

 

Updating the PSB ban list...

Warning: Unable to parse: ; PunksBusted Public Master Ban List - http://www.punksbusted.com

Warning: Unable to parse: ; Updated at 09/19/2008 22:00

Warning: Unable to parse: ; Our latest, live ban list is available through Auto-MBL for streaming members.

Warning: Unable to parse: ; Please see our web site for more details. This ban list is delayed by 30 days.

Warning: Unable to parse:

Warning: Unable to parse: [PsB:10002 V0104B556] 4f4ecb69b897a2d1c1737300ebc00efc "!^!Kromi!^!" "89.174.125.237" MD5TOOL #9002 (default.lua)

Warning: Unable to parse: [PsB:10719 V01346EE3] 34edb71779061c3456f6ab9ce7612416 "ThePro06" "220.255.217.123" MULTIHACK #70496

Warning: Unable to parse: [PsB:10831 V0139D24B] c692b9287284c74bdf0956e6d147f8ed "Feikko" "89.57.172.176" MD5TOOL #9002 (Botfile.dll)

Warning: Unable to parse: [PsB:10872 V0139D87F] d6bf385e293cd063cb23420312f34531 "American_Communist" "84.249.41.218" MD5TOOL #9002

 

----------------------------------------------------

 

Updating the AASA ban list...

Warning: Unable to parse: ; Version 1063 -- 19 September 2008 -- 41107 bans

Warning: Unable to parse: [1998.12.31 21:24:18] 3be4902eec86a39b080c6ef6ae767e24

Warning: Unable to parse: [1999.01.13 19:20:17] f39ba127a452e701d4860aac0a07b272

Warning: Unable to parse: [1999.02.01 07:43:33] f6070bf350cc453e0ba7763b2f2cd7bc

 

http://www.aaorepodepot.us/downloads/Repo_Ban_Search_Block.zip

 

 

 

These inadvertant mistakes are simple like a missing colon or a date timestamp reversed.?  Whichis causing all of the unable to parse and leaving alot of bans out of the search block.

 

 

Much thanks for any direction you could point me or help.  I am seriously hoping I am asking the right questions for what I am trying to fix.

 

8)

 

 

Link to comment
Share on other sites

To try and makke this easier and hopefully more beneficial to solving this.  I am going to post the 2 php files that the update.php call for.  The config.php, "which specifally functions to call the 4 banlists from their locations".  And the classes.php " which I believe is the file that has within it the coding that governs the parsing.

 

 

 

Config.php

 

<?php
if (!defined("CLS_BANSEARCH"))
{
	Header("HTTP/1.1 403 Forbidden");
	Die("You do not have premission to access this resource");
}

define("ORIGINAL_LINE_OFFSET", 0);
define("DATE_TIME_OFFSET", 1);
define("GUID_OFFSET", 4);
define("NAME_OFFSET", 5);
define("IP_OFFSET", 6);
define("REASON_OFFSET", 7);

define("MIN_QUERY_LEN", 3);

$BanLists[] = new BanList("ACI", "http://www.anticheatinc.com/tex/MBLs/pbbans.txt", "./cache/aci.txt", "http://www.anticheatinc.com/");
$BanLists[] = new BanList("AON", "http://emailcart.net/mbl/aon_bans.dat", "./cache/aon.txt", "http://www.airdaleops.com/");
$BanLists[] = new BanList("PSB", "http://www.punksbusted.com/cgi-bin/membership/publicbans.cgi/AA_pbbans.dat?key=1&remove=0", "./cache/psb.txt", "http://www.punksbusted.com/");
        $BanLists[] = new BanList("AASA", "http://appeals.aaserveradmins.net/aasaprivbanguid.txt", "./cache/aasa.txt", "http://www.aaserveradmins.com/");

$BanListPattern = "/^\[" .
		"((PsB\:[0-9]{4} [A-Z]{1}[A-Fa-f0-9]{8})|" . "([0-9]{4}\.[0-9]{2}\.[0-9]{2} [0-9]{2}\:[0-9]{2}\:[0-9]{2}))" . 
		"\] ([A-Fa-f0-9]{32}) \"([\x01-\xFF]{0,32})\" \"([0-9\.\?]{1,15})\" (.*)/i";
?>

 

 

Classes.php

 

<?php
if (!defined("CLS_BANSEARCH"))
{
	Header("HTTP/1.1 403 Forbidden");
	Die("You do not have premission to access this resource");
}

class BanList
{
	var $Name;	/*Name of the ban list (e.g. AASA, ACI, AON, etc...)*/
	var $Source;	/*Location of the original ban list source*/
	var $Cache;	/*Local location where the ban list is cached*/
	var $Link;	/*Public link to the website that host the ban list*/

	function BanList($Name, $Source, $Cache, $Link)
	{
		$this->Name = $Name;
		$this->Source = $Source;
		$this->Cache = $Cache;
		$this->Link = $Link;
	}

	function UpdateCache($Source = NULL, $Cache = NULL)
	{
		global $BanListPattern;

		if ($Source == NULL && $this->Source)
			$Source = $this->Source;
		else
			return -1;
		if ($Cache == NULL && $this->Cache)
			$Cache = $this->Cache;
		else
			return -1;

		$cH = curl_init($Source);
		if (!$cH)
			return -1;

		curl_setopt($cH, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($cH, CURLOPT_HEADER, 0);

		$sBanList = curl_exec($cH);
		curl_close($cH);

		$aBanList = explode("\n", $sBanList);
		$aBanListGUID = array();
		unset($sBanList);

		/*Lets sort it so we can do a binary search sort of*/
		$Len = count($aBanList);
		for($i = 0; $i < $Len; $i++)
		{
			$aBanList[$i] = trim($aBanList[$i]);

			if(preg_match($BanListPattern, $aBanList[$i], $Match) == 0)
			{
				print "\n<br><b>Warning</b>: Unable to parse: " . $aBanList[$i];
				continue;
			}

			$GUID = $Match[GUID_OFFSET];
			$aBanListGUID[$GUID] = $aBanList[$i];
		}
		unset($aBanList);

		ksort($aBanListGUID);
		$BanList = implode("\n", $aBanListGUID);
		$Len = count($aBanListGUID);
		unset($aBanListGUID);

		$hCache = fopen($Cache, "w");
		if (!$hCache)
		{
			print "\n<br><b>Warning</b>: Unable to write to cache";
			return -1;	
		}

		fwrite($hCache, $BanList);
		fclose($hCache);

		return $Len;
	}

	function SearchCache($Search, $Type = GUID_OFFSET, $Cache = NULL)
	{
		global $BanListPattern;

		if ($Cache == NULL && $this->Cache)
			$Cache = $this->Cache;
		else
			return false;


		$aBanList = file($Cache);
		if (!$aBanList)
			return false;
		$Len = count($aBanList);
		$Loc = 0;

		$Bans = array();

		switch ($Type)
		{
		case NAME_OFFSET:
		/*Ban list isn't sorted by Name so we got to go through the whole file */
			for(;$Loc < $Len; $Loc++)
			{
				if (preg_match($BanListPattern, $aBanList[$Loc], $Match)
					&& stristr($Match[$Type], $Search) !== false)
					$Bans[] = $Match;
			}
			if (count($Bans) > 0)
				return $Bans;
			return false;



		case IP_OFFSET:
		/*Ban list isn't sorted by IP so we got to go through the whole file */
			for(;$Loc < $Len; $Loc++)
			{
				if (preg_match($BanListPattern, $aBanList[$Loc], $Match)
					&& strncasecmp($Match[$Type], $Search, strlen($Search)) == 0)
					$Bans[] = $Match;
			}
			if (count($Bans) > 0)
				return $Bans;
			return false;



		case GUID_OFFSET:
		default:
		/*Let's try to estimate where it should be on a sorted ban list (usually we'll get within about 50) - much faster than searching through the whole list*/
			$GUID = $Search;
			if (preg_match("/^[A-Fa-f0-9]{32}$/i", $GUID) == 0)
				return false;

			$GUID_FIRST_4_INT = base_convert(substr($GUID, 0, 4), 16, 10);
			$Loc = $Len * (($GUID_FIRST_4_INT & 0x0000FFFF) / 0x0000FFFF);

			preg_match($BanListPattern, $aBanList[$Loc], $Match);
			$CURRENT_GUID_FIRST_4_INT = base_convert(substr($Match[GUID_OFFSET], 0, 4), 16, 10);

			if ($CURRENT_GUID_FIRST_4_INT == $GUID_FIRST_4_INT)
			{
				if (preg_match($BanListPattern, $aBanList[$Loc], $Match)
					&& strtolower($Match[GUID_OFFSET]) == strtolower($GUID))
					return array($Match);

				while($Loc-- > -1 && $CURRENT_GUID_FIRST_4_INT >= $GUID_FIRST_4_INT)
				{
					preg_match($BanListPattern, $aBanList[$Loc], $Match);
					$CURRENT_GUID_FIRST_4_INT = base_convert(substr($Match[GUID_OFFSET], 0, 4), 16, 10);
					if ($GUID_FIRST_4_INT == $CURRENT_GUID_FIRST_4_INT
						&& strtolower($Match[GUID_OFFSET]) == strtolower($GUID))
						return array($Match);
				}
				while($Loc++ < $Len && $CURRENT_GUID_FIRST_4_INT <= $GUID_FIRST_4_INT)
				{
					preg_match($BanListPattern, $aBanList[$Loc], $Match);
					$CURRENT_GUID_FIRST_4_INT = base_convert(substr($Match[GUID_OFFSET], 0, 4), 16, 10);
					if ($GUID_FIRST_4_INT == $CURRENT_GUID_FIRST_4_INT
						&& strtolower($Match[GUID_OFFSET]) == strtolower($GUID))
						return array($Match);

				}

			}
			else if ($CURRENT_GUID_FIRST_4_INT > $GUID_FIRST_4_INT)
			{
				while($Loc-- > -1 && $CURRENT_GUID_FIRST_4_INT >= $GUID_FIRST_4_INT)
				{
					preg_match($BanListPattern, $aBanList[$Loc], $Match);
					$CURRENT_GUID_FIRST_4_INT = base_convert(substr($Match[GUID_OFFSET], 0, 4), 16, 10);
					if ($GUID_FIRST_4_INT == $CURRENT_GUID_FIRST_4_INT
						&& strtolower($Match[GUID_OFFSET]) == strtolower($GUID))
						return array($Match);
				}
			}
			else
			{
				while($Loc++ < $Len && $CURRENT_GUID_FIRST_4_INT <= $GUID_FIRST_4_INT)
				{
					preg_match($BanListPattern, $aBanList[$Loc], $Match);
					$CURRENT_GUID_FIRST_4_INT = base_convert(substr($Match[GUID_OFFSET], 0, 4), 16, 10);
					if ($GUID_FIRST_4_INT == $CURRENT_GUID_FIRST_4_INT
						&& strtolower($Match[GUID_OFFSET]) == strtolower($GUID))
						return array($Match);
				}
			}

			return false;
		}
	}
};
?>

 

 

Thanks and I know this isnt a paid site, however I would be more then willing to pay for and or make a donation for helping solve and stamp this fixed.  8)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.