Location: PHPKode > projects > Open ShareLive > F3-OSL-pre_alpha-2005_05_30/bancheck.php
<?php
/******************************************************************************
*
*    Open ShareLive (main site code)
*    Copyright (C) 2002-2005  ShareLive
*
*    This program is free software; you can redistribute it and/or
*    modify it under the terms of the GNU General Public License
*    as published by the Free Software Foundation; either version 2
*    of the License, or (at your option) any later version.
*
*    This program is distributed in the hope that it will be useful,
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*    GNU General Public License for more details.
*
*    You should have received a copy of the GNU General Public License
*    along with this program; if not, write to the Free Software
*    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*
******************************************************************************/// this script will check if the user is banned.

// first, we should check for an explicit IP ban.

		// Get users IP Address
		include_once('ipaddress.php');

		$users_ip = GetUsersIP();
		//$users_ip = $_GET['ip'];
//echo "IP: ".$users_ip;
$q = mysql_query("SELECT * FROM sl_banned WHERE `ip` = '".$users_ip."' AND `level` = '2'");
	if ($q && mysql_num_rows($q)) {
		while ($row = mysql_fetch_array($q)) {
			header('Location: http://66.90.103.97/banlevel2.php');			
		}
	}
	//$users_ip = GetUsersIP();
$q = mysql_query("SELECT * FROM sl_banned WHERE `ip` = '".$users_ip."' AND `level` = '3'");
	if ($q && mysql_num_rows($q)) {
		while ($row = mysql_fetch_array($q)) {
			header('Location: http://66.90.103.97/main.php');
		}
	}

//now, for the purpose of IP range blocking we need to convert IP addy to numerals
$strng = "";
	$tok = strtok($users_ip,".");
	

		if (strlen($tok) == '1') {

		$strng = $strng."00".$tok;
		}
		if (strlen($tok) == '2') {

		$strng = $strng."0".$tok;
		}
		if (strlen($tok) == '3') {

		$strng = $strng.$tok;
		}
		$tok = strtok(".");
	

		if (strlen($tok) == '1') {

		$strng = $strng."00".$tok;
		}
		if (strlen($tok) == '2') {

		$strng = $strng."0".$tok;
		}
		if (strlen($tok) == '3') {

		$strng = $strng.$tok;
		}
		$tok = strtok(".");


		if (strlen($tok) == '1') {

		$strng = $strng."00".$tok;
		}
		if (strlen($tok) == '2') {

		$strng = $strng."0".$tok;
		}
		if (strlen($tok) == '3') {

		$strng = $strng.$tok;
		}
		$tok = strtok(".");
;
		if (strlen($tok) == '1') {

		$strng = $strng."00".$tok;
		}
		if (strlen($tok) == '2') {

		$strng = $strng."0".$tok;
		}
		if (strlen($tok) == '3') {

		$strng = $strng.$tok;
		}

// that should do the trick
//
$strng = $strng."1";
$q = mysql_query("SELECT * FROM sl_banned");
	if ($q && mysql_num_rows($q)) {
		while ($row = mysql_fetch_array($q)) {
			//ok, lets get the upper and lower entity
			$ent = $row[0];
			$lower = strtok($ent,"-");
			$higher= strtok("-");
			$lower = $lower."1";
			$higher = $higher."1";
			
			//echo "Lower is ".$lower;
			//echo "Higher is ".$higher;
			//are we higher than the lower?
			if ($strng > $lower) {
			
			if ($strng < $higher) {
			//we're fucking banned!
			header('Location: sharelive/index.php');
			} else {
			
			}
			}
		}
	}
		
?>
Return current item: Open ShareLive