pcw Posted March 17, 2009 Share Posted March 17, 2009 Hi, I am using this script to list all the folders in the selected directory, it is part of a templates modification script I have written: <?php $directory = "templates/"; $handle = opendir($directory); while ($folder = readdir($handle)) { $folders[] = $folder; } closedir($handle); sort($folders); print "<form action='admin.php?cmd=file' method='POST'>"; print "<select name='temp_folder'>"; print "<option>Choose folder</option>"; foreach ($folders as $folder) { if (($folder != ".") And ($folder != "..")) { print sprintf("<option value='$directory/%s'>%s</option>", $folder, $folder); } } print "</select>"; print "<input type='submit' name='tmpupdate' value='update'>"; print "</form>"; ?> However, I would like to exclude a folder from this list, as it contains folders that I do not want the user to be able to edit. Is this possible, and how do i do it? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/149888-solved-excluding-files-from-menu/ Share on other sites More sharing options...
samshel Posted March 17, 2009 Share Posted March 17, 2009 $directory = "templates/"; $arrNotAllowed = array("config", "includes"); $handle = opendir($directory); while ($folder = readdir($handle)) { if(!in_array($folder, $arrNotAllowed)) { $folders[] = $folder; } } something like this..Note tested. you may face some issues with paths though Quote Link to comment https://forums.phpfreaks.com/topic/149888-solved-excluding-files-from-menu/#findComment-787152 Share on other sites More sharing options...
laffin Posted March 17, 2009 Share Posted March 17, 2009 Either tag it somehow, keeping an array list of files. or tag anything that starts with a . (files in linux that start with . are hidden) to not display if (($folder[0] != ".")) should do the trick Quote Link to comment https://forums.phpfreaks.com/topic/149888-solved-excluding-files-from-menu/#findComment-787156 Share on other sites More sharing options...
pcw Posted March 17, 2009 Author Share Posted March 17, 2009 Thanks Samshel, that worked great Quote Link to comment https://forums.phpfreaks.com/topic/149888-solved-excluding-files-from-menu/#findComment-787173 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.