Results 1 to 6 of 6
-
29th Sep 2010, 07:29 AM #1OPmmm mmm!
php: Hide *. php from the listing of files.
Hello, i'm sitting here and playing and trying to make a "pool" to a website in php.
What I'm going is to show the contents of a folder using php. So far I have managed to list all files in selected folder using:
PHP Code:<?php
if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != "..")
{
$thelist .= '<a href="'.$file.'">«'.$file.'» <br></a>';
}
}
closedir($handle);
}
?>
I'm struggling to really figure this out, because I am completely blank on the field....Daniel Reviewed by Daniel on . php: Hide *. php from the listing of files. Hello, i'm sitting here and playing and trying to make a "pool" to a website in php. What I'm going is to show the contents of a folder using php. So far I have managed to list all files in selected folder using: <?php if ($handle = opendir('.')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $thelist .= '<a href="'.$file.'">«'.$file.'» <br></a>'; Rating: 5HATERS GONNA probably bring up some valid points considering I am an ignorant little twat so far up my own ass that i blame my problems on everyone and if you criticize me you're automatically wrong.
-
29th Sep 2010, 08:02 AM #2It begins...PHP Code:
<?php
$list = array(); //define an empty array
if ($handle = opendir('.'))
{
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != "..")
{
array_push($list, $file);
}
}
closedir($handle);
sort($list);
}
foreach ($list as $file)
{
$ext = substr(strrchr($file, '.'), 1);
if ($ext !== 'php')
{
echo '<a href="'.$file.'">«'.$file.'» </a><br>';
}
}
?>
-
29th Sep 2010, 08:16 AM #3MemberWebsite's:
somik.org sborg.us
-
29th Sep 2010, 08:28 AM #4OPmmm mmm!
That one prints only the files that are NOT php, if I have understood your code correctly?
HATERS GONNA probably bring up some valid points considering I am an ignorant little twat so far up my own ass that i blame my problems on everyone and if you criticize me you're automatically wrong.
-
29th Sep 2010, 08:36 AM #5MemberWebsite's:
somik.org sborg.usYep.
Add more extentions to hide as such
PHP Code:($ext != 'cgi') || ($ext != 'pl') || ($ext != 'html') || ($ext != 'htm')
If you want to store these files list to a array,
PHP Code:<?php
$myList = array(); //Blank array to store non PHP files
$list = scandir('.');
foreach ($list as $file){
$ext = pathinfo($file,PATHINFO_EXTENSION);
if( ($file != ".") || ($file != "..") || ($ext != 'php') ){
$myList[] = $file;
}
}
?>
-
29th Sep 2010, 08:23 PM #6MemberWebsite's:
litewarez.net litewarez.com triniwarez.comwhy dont you just use glob ?
PHP Code:glob('files/*.{!php}');
note you might need to use GLOB_BRACE depending on your OS
PHP Code:glob('files/*.{!php}',GLOB_BRACE);
Join Litewarez.net today and become apart of the community.
Unique | Clean | Advanced (All with you in mind)
Downloads | Webmasters
Notifications,Forum,Chat,Community all at Litewarez Webmasters
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
i need your help for directory listing
By softpk in forum Web Development AreaReplies: 1Last Post: 17th Mar 2012, 02:26 AM -
Filehost listing
By SlingFile in forum File Host DiscussionReplies: 2Last Post: 22nd Nov 2011, 04:25 PM -
Hide your kids, Hide your wife
By ACE in forum General DiscussionReplies: 7Last Post: 8th Aug 2010, 06:39 PM -
Litewarez'es Top Tip! (Hide your files)
By litewarez in forum Webmaster ResourcesReplies: 2Last Post: 25th Oct 2009, 08:23 PM
themaPoster - post to forums and...
Version 5.23 released. Open older version (or...