note 60422 added to function.highlight-file

From: Date: Fri, 06 Jan 2006 13:21:50 +0000
Subject: note 60422 added to function.highlight-file
Groups: php.notes 
Request: Send a blank email to php-notes+get-101307@lists.php.net to get a copy of this message
I think it will be better if the variable contains the files that are allowed to be viewed. There can always befound a way to pass the name of a forbiddedn file that is not in the prohibited array. Thus the code will be: <?php //array with files to allow $allowed = array('index.php', 'menu.php', 'about.php'); // get the filename $file = $_GET[file]; if(file_Exists($file)){ if(in_array($file, $allowed)){ // check if it is part of the allowed list highlight_file($file); //highlight file } else{ // not allowed. just die. do not warn ;) die(""); } } else{ // file doesnt exist echo "The file does not exist."; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.highlight-file.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+60422 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60422&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60422&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60422&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60422&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60422&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60422&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60422&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+60422&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#101307) next »