<?
// OekakiPoteto Ban Script
// Made for Ranmaguy's Oekaki Poteto system
// by Travis Skare
// hide@address.com
// TO INSTALL:
// -Upload this file and two text files to the same directory.
// hosts.txt - hostnames you want to ban.
// ips.txt - ips you want to ban.
// - Use this file as an include on necessary pages.
if (!strstr($siteflags,"O")) {
// Get user's hostname.
$hostname = gethostbyaddr($REMOTE_ADDR);
// File for hostnames.
$fd = fopen ("hosts.txt", "r");
// File is open and there are more names.
while (!feof ($fd)) {
// Assign current name to test variable.
$buffer = fgets($fd, 4096);
$pos = strpos ($buffer, "*");
if ($pos === false) {
// asterisk not found.
// use the old string compare.
if ($buffer == $hostname)
{
// Just a plug for our favorite people :)
$url="banned.php";
header("Location: $url");
}
}
else
{
// There was an asterisk.
// $pos contains the first (and only) occurance
// of an asterisk, so we can compare the rightmost
// positions of the strings.
// Step one: see how many characters are to the right of the *.
// Length of string: strlen($buffer);
// First position of asterisk: $pos
// Number of characters to the right of the *:
// (strlen($buffer)-($pos+1));
$rightmost=(strlen($buffer)-($pos+1));
// Compare rightmost parts of the two strings.
if(substr($buffer, strlen($buffer)-$rightmost)==substr($hostname, strlen($hostname)-$rightmost))
{
// Just a plug for our favorite people :)
$url="banned.php";
header("Location: $url");
}
}
}
fclose ($fd);
// Check for IPs
$fe = fopen ("ips.txt", "r");
// File is open and there are more ips
while (!feof ($fe)) {
// Assign current name to test variable.
$buffer = fgets($fe, 4096);
$pos = strpos ($buffer, "*");
if ($pos === false) {
// asterisk not found.
// use the old string compare.
if ($buffer == $REMOTE_ADDR)
{
// Just a plug for our favorite people :)
$url="banned.php";
header("Location: $url");
}
}
else
{
// Asterisk found.
// Position will be how many characters are to the left.
// This makes things easy.
if(substr($buffer,0, $pos)==substr("$REMOTE_ADDR", 0,$pos))
{
// Just a plug for our favorite people :)
$url="banned.php";
header("Location: $url");
}
}
}
fclose ($fe);
}
?>