Activity Stream
48,167 MEMBERS
6726 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 6 of 6
  1.     
    #1
    mmm mmm!

    Default 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.'">&laquo;'.$file.'&raquo;  <br></a>';
              }
           }
      
    closedir($handle);
      }
    ?>
    It is so far a list good enough for my purposes, except for one thing. I want to hide files with specifix extensions, specifically *. php.
    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.'">&laquo;'.$file.'&raquo; <br></a>'; Rating: 5
    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.

  2.   Sponsored Links

  3.     
    #2
    It 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.'">&laquo;'.$file.'&raquo; </a><br>';
        }
    }

    ?>

  4.     
    #3
    Member
    Website's:
    somik.org sborg.us
    Or you can shorten up the code to have the same effect

    PHP Code: 
    <?php
    $list 
    scandir('.');
    foreach (
    $list as $file){
        
    $ext pathinfo($file,PATHINFO_EXTENSION);
        if( (
    $file != ".") || ($file != "..") || ($ext != 'php') ){
            echo 
    '<a href="'.$file.'">&laquo;'.$file.'&raquo; </a><br>';
        }
    }
    ?>

  5.     
    #4
    mmm 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.

  6.     
    #5
    Member
    Website's:
    somik.org sborg.us
    Yep.

    Add more extentions to hide as such
    PHP Code: 
    ($ext != 'cgi') || ($ext != 'pl') || ($ext != 'html') || ($ext != 'htm'
    This will hide cgi, pl, html and html files aswell.

    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;
        }
    }
    ?>

  7.     
    #6
    Member
    Website's:
    litewarez.net litewarez.com triniwarez.com
    why dont you just use glob ?

    PHP Code: 
    glob('files/*.{!php}'); 
    http://www.jedit.org/users-guide/globs.html

    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


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. i need your help for directory listing
    By softpk in forum Web Development Area
    Replies: 1
    Last Post: 17th Mar 2012, 02:26 AM
  2. Filehost listing
    By SlingFile in forum File Host Discussion
    Replies: 2
    Last Post: 22nd Nov 2011, 04:25 PM
  3. Hide your kids, Hide your wife
    By ACE in forum General Discussion
    Replies: 7
    Last Post: 8th Aug 2010, 06:39 PM
  4. Litewarez'es Top Tip! (Hide your files)
    By litewarez in forum Webmaster Resources
    Replies: 2
    Last Post: 25th Oct 2009, 08:23 PM

Tags for this Thread

BE SOCIAL