note 95074 deleted from function.explode by danbrown

From: Date: Sat, 12 Dec 2009 18:42:39 +0000
Subject: note 95074 deleted from function.explode by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-163890@lists.php.net to get a copy of this message
Note Submitter: cj at burn2u dot com ---- A simple script that can check against a blacklist log. Easily configurable on any installation. make "bl.txt" or rename whatever in the code. <?php $command = $_GET['c']; if (!$command) { $ref = $_SERVER['HTTP_REFERER']; if ($ref == "") { $ref = $_GET['ref']; } $this1 = fopen("bl.txt", "r"); $cont = fread($this1, filesize("bl.txt")); fclose($this1); $blacklist = explode(";", $cont); $start = 0; $max = count($blacklist); echo "Referer: " . $ref . "\r\n" . "<br><br>"; while ($start!=$max) { $check = strpos($ref, $blacklist[$start]); if ($check === false) { echo $blacklist[$start] . " :: " . "No match<br>"; } else { echo $blacklist[$start] . " :: " . "Match found!<br>"; } $start++; } } else { $ref = $_GET['ref']; if (!$ref) { die("No referrer to blacklist. Use 'c=add&ref=blacklisted.whatever'."); } $filename = fopen("bl.txt", "a"); $domain = $ref; fwrite($filename, ";" . $ref); fclose($filename); echo "Domain <b>" . $ref . "</b><br>added to blacklist log."; } echo "<br><br><div style=\"margin-left: auto; margin-right: auto; width: 400px; background-color: silver; border: solid 1px red; font-family: Arial;\"><center>Help</center><br><br>Add domain to blacklist: \"ref.php?c=add&ref=thedomain.com\"<br><br>Check domain against blacklist log: \"ref.php?ref=thedomain.com\" <b>OR</b> access this script with a valid referer header.</div>"; ?>

« previous php.notes (#163890) next »