Re: does this code look like it would check a file extensions, and disallow php files or exe files to be attached

From: Date: Thu, 14 Jun 2007 12:41:10 +0000
Subject: Re: does this code look like it would check a file extensions, and disallow php files or exe files to be attached
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-256987@lists.php.net to get a copy of this message
why don't you run it and find out. with errors turned on you will have quickly found out if it worked or not
$filelinks=t3lib_div::_POST('file_name'); // the posting of the file name
ok Ive never seen syntax like that before, maybe some else can help, looks like your doing this code from within a class that inherits from another class.
$exttypes = "php3,php,exe";                                     // list of
extensions that shouldnt be used
$fileextension = substr($filelinks,0,strpos($filelinks,"."));     //get the
no should be: fileextension = substr($filelinks, strpos($filelinks,".")+1 , strlen($filelinks));
extension after the .
if ($fileextension == $exttypes['php']['php3']['exe']) {         //if the
hmm not sure about this either, you could do: $exttypes = "|php3|php|exe|"; if (strstr( $exttypes, "|fileextension|")) { } else { } or use explode() and in_array()
file extension equals php, php3, or exe
   echo "mime type doesn't work";                                 //if the
extension is php, php3, exe, than echo doesn't work }
   if ($fileextension != $extypes['php']['php3']['exe']) {     //if the
file extension doesn't equal php, php3, or exe than
                                                               // store the
file
       $filelinks = $this->storeFile();
       }
?>
{No electrons were harmed in the creation, transmission or reading of this email. However, many were excited and some may well have enjoyed the experience.}

« previous php.general (#256987) next »