note 72842 added to ref.filter

From: Date: Fri, 02 Feb 2007 20:15:39 +0000
Subject: note 72842 added to ref.filter
Groups: php.notes 
Request: Send a blank email to php-notes+get-122576@lists.php.net to get a copy of this message
Below is some code using filter API to restrict access to LAN by IPv4 private address range. These notes may save someone else a little time: filter_input_array() is useless for running multiple filters on the same key. No way to chain or negate filters. <?php /* Merciful comment! */ function FILTER_NEGATE_HACK($_){ return (bool)!$_; } function client_is_private_ipv4(){ return (filter_input(INPUT_SERVER, 'REMOTE_ADDR', FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) && FILTER_NEGATE_HACK(filter_input(INPUT_SERVER, 'REMOTE_ADDR', FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE)); } if (! client_is_private_ipv4()) exit('This application is restricted to local network users'); ?> ---- Server IP: 69.147.83.197 Probable Submitter: 80.3.128.6 (proxied: 82.9.252.105) ---- Manual Page -- http://www.php.net/manual/en/ref.filter.php Edit -- https://master.php.net/note/edit/72842 Del: integrated -- https://master.php.net/note/delete/72842/integrated Del: useless -- https://master.php.net/note/delete/72842/useless Del: bad code -- https://master.php.net/note/delete/72842/bad+code Del: spam -- https://master.php.net/note/delete/72842/spam Del: non-english -- https://master.php.net/note/delete/72842/non-english Del: in docs -- https://master.php.net/note/delete/72842/in+docs Del: other reasons-- https://master.php.net/note/delete/72842 Reject -- https://master.php.net/note/reject/72842 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#122576) next »