note 42951 added to function.count

From: Date: Fri, 04 Jun 2004 14:30:19 +0000
Subject: note 42951 added to function.count
Groups: php.notes 
Request: Send a blank email to php-notes+get-70701@lists.php.net to get a copy of this message
I have found on upload scripts or on file manipulation scripts that people can trick a classic file type filter: example: $filename="bob.jpg.wav"; $bits= explode(".",$filename); $extention= $bits[1]; if($extention == "jpg"){ echo"Not correct"; exit; } This returns the filename extention as jpg not wav. One way to change this is to use count() : example: $filename="bob.jpg.wav"; $bits= explode(".",$filename); $extention= $bits[count($bits) - 1]; if($extention == "jpg"){ echo"Not correct"; exit; } This returns the filename extention as wav not jpg. ---- Manual Page -- http://www.php.net/manual/en/function.count.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+42951 Delete -- http://master.php.net/manage/user-notes.php?action=delete+42951&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+42951&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#70701) next »