note 99494 added to function.eregi

From: Date: Fri, 20 Aug 2010 05:23:16 +0000
Subject: note 99494 added to function.eregi
Groups: php.notes 
Request: Send a blank email to php-notes+get-171871@lists.php.net to get a copy of this message
<?php /* just small additional for "prevent possible any XSS attack and others via $_GET." and its also works to for $_REQUEST, $_POST, and $_COOCKIE. Example $_GET url: http://example.com/?link=page or http://example.com/?link=page&id=1 example to use: $url = $_GET[url]; $url = GetVar($url); here my simply code. */ function GetVar($get) { if ($get) { $banwords = array ("'", ",", ";", "--", "\"", "%", "+","<",">"); // bad words $get = strip_tags($get); if (!ereg("^[-a-zA-Z0-9_=\?]{0,50}$", $get)) { // you ca //echo $get; $get = str_replace ( $banwords, '', $get); // replace badwords to null //var_dump($get); //echo $get; } return $get; } else { return false; } } // its also works $url = $_GET[url]; $url = GetVar($url); // or $link = $_GET[link]; $link = GetVar($link); ?> ---- Server IP: 202.158.52.162 Probable Submitter: 122.144.3.3 ---- Manual Page -- http://www.php.net/manual/en/function.eregi.php Edit -- https://master.php.net/note/edit/99494 Del: integrated -- https://master.php.net/note/delete/99494/integrated Del: useless -- https://master.php.net/note/delete/99494/useless Del: bad code -- https://master.php.net/note/delete/99494/bad+code Del: spam -- https://master.php.net/note/delete/99494/spam Del: non-english -- https://master.php.net/note/delete/99494/non-english Del: in docs -- https://master.php.net/note/delete/99494/in+docs Del: other reasons-- https://master.php.net/note/delete/99494 Reject -- https://master.php.net/note/reject/99494 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#171871) next »