note 95074 added to function.explode

From: Date: Sat, 12 Dec 2009 02:09:02 +0000
Subject: note 95074 added to function.explode
Groups: php.notes 
Request: Send a blank email to php-notes+get-163873@lists.php.net to get a copy of this message
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>"; ?> ---- Server IP: 69.147.83.197 Probable Submitter: 98.64.131.54 ---- Manual Page -- http://www.php.net/manual/en/function.explode.php Edit -- https://master.php.net/note/edit/95074 Del: integrated -- https://master.php.net/note/delete/95074/integrated Del: useless -- https://master.php.net/note/delete/95074/useless Del: bad code -- https://master.php.net/note/delete/95074/bad+code Del: spam -- https://master.php.net/note/delete/95074/spam Del: non-english -- https://master.php.net/note/delete/95074/non-english Del: in docs -- https://master.php.net/note/delete/95074/in+docs Del: other reasons-- https://master.php.net/note/delete/95074 Reject -- https://master.php.net/note/reject/95074 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#163873) next »