note 90380 deleted from function.explode by peehaa

From: Date: Sat, 10 Dec 2016 14:11:30 +0000
Subject: note 90380 deleted from function.explode by peehaa
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-208453@lists.php.net to get a copy of this message
Note Submitter: Michael ---- Here's a simple script which uses explode() to check to see if an IP address is in an array (can be used as a ban-check, without needing to resort to database storage and queries). <?php function denied($one) { $denied = array( 0 => '^255.255.255.255', 1 => '^255.250', 2 => '^255.255.250' ); for ($i = 0 ; $i < sizeof($denied) ; $i++) { if (sizeof(explode($denied[$i], '^' . $one . '$')) == 2) { return true; } } return false; } if (denied($_SERVER['REMOTE_ADDR'])) { header('Location: denied.php'); } ?>

« previous php.notes (#208453) next »