Wap Directory Listing Script

Started on the old forum in August 2008 · view the original in the archive · old links redirect here

1 reply · 789 views · started 18 years ago · 1 min read

phpfan Newbie · 4 posts #1

hello friends 🙂 can any 1 plzzz give me wap directory listing with image preview like 177352(dot)freehostia(dot)com/img/bollytop/ plzzz if u can give me plzzzzzzzzzzzzz

Guest #2

hello friends 🙂 can any 1 plzzz give me wap directory listing with image preview like 177352(dot)freehostia(dot)com/img/bollytop/ plzzz if u can give me plzzzzzzzzzzzzz

This is for my script.. I using it to listing all off files thats was array on one directory where this script located here is script:

<?php
  // Explore the files via a web interface.   
  $script = basename(__FILE__); // the name of this script

  $path = !empty($_REQUEST['path']) ? $_REQUEST['path'] : dirname(__FILE__); // the path the script should access

  $page = !empty($_REQUEST['page']) ? $_REQUEST['page'] : 0; //The page number to display

  ///////////////////////////////////  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// MAKSIMAL LINK PER HALAMAN
/// LINK DI KURANG 1

 $MaxFilePerPage = 6;  //Numbers of file per page
   ///////////////////////////////////  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  

function getDirectoryListing($dirname, $sortorder = "a", $show_subdirs = 0, $show_subdirfiles = 0, $exts = "", $ext_save = 1) 

{

  if (!$exts || empty($exts) || $exts == "") {
       $exts = array("jpg", "gif", "jpeg", "png");
   }
   if ($handle = opendir($dirname)) {
       $filelist = array();
       while (false !== ($file = readdir($handle))) {

           // Filter out higher directory references
           if ($file != "." && $file != "..") {
               // Only look at directories or files, filter out symbolic links
               if ( filetype ($dirname."/".$file) != "link") {
                   // If it's a file, check against valid extentions and add to the list
                   if ( filetype ($dirname."/".$file) == "file" ) {
                       if (checkFileExtention($file, $exts, $ext_save)) {
                                       $filelist[] = $file;
                       }
                   }
                   // If it's a directory and either subdirs should be listed or files from subdirs add relevant names to the 

//list
                   else if ( filetype ($dirname."/".$file) == "dir" && ($show_subdirs == 1 || $show_subdirfiles == 1)) {
                       if ($show_subdirs == 1) {
                           $filelist[] = $file;
                       }
                       if ($show_subdirfiles == 1) {
                           $subdirname = $file;
                           $subdirfilelist = getDirectoryListing($dirname."/".$subdirname."/", $sortorder, $show_subdirs,
						   $show_subdirfiles, $exts, $ext_save);
                           for ($i = 0 ; $i < count($subdirfilelist) ; $i++) {
                               $subdirfilelist[$i] = $subdirname."/".$subdirfilelist[$i];
                           }
                           $filelist = array_merge($filelist, $subdirfilelist);
                       }

                   }

               }
           }
       }
       closedir($handle);

       // Sort the results
       if (count($filelist) > 1) {
           natcasesort($filelist);
           if ($sortorder == "d" || $sortorder == "r" ) {
               $filelist = array_reverse($filelist, TRUE);
           }
       }
       return $filelist;
   }
   else {
       return false;
   }
}

function checkFileExtention($filename, $exts, $ext_save = 1) {
   $passed = FALSE;
   if ($ext_save == 1) {
       if (preg_match("/^\./", $filename)) {
           return $passed;
       }
   }
   if ($exts == "all") {
                   $passed = TRUE;
       return $passed;
   }
   if (is_string($exts)) {
       if (eregi("\.". $exts ."$", $filename)) {
                       $passed = TRUE;
           return $passed;
       }
   } else if (is_array($exts)) {
       foreach ($exts as $theExt) {
           if (eregi("\.". $theExt ."$", $filename)) {
               $passed = TRUE;
               return $passed;
           }
       }
   }
   return $passed;
} 

  $files = array(); //Array to hold the files

  
  ////// EDIT DISINI
  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  $ftype = array("rm", "RM", "zip", "ZIP", "rar", 
				"RAR", "3gp", "3GP", "txt", "TXT", 
				"mp3", "MP3", "jpg", "JPG", "gif",
				"GIF"); //File type to show  
				
  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

  $files = getDirectoryListing($path, "a", 0, 0, $ftype , 1); //Get the files into $files array

  if ($files == false) {
     print "<p class=\"error\">Directory handle could not be obtained.</p>"; 
  } 
  else 
  {
     $NumOfFiles = count($files);

if ($NumOfFiles > 0)
     {
        $StartFileNo = $page * $MaxFilePerPage;

        $EndFileNo = $StartFileNo + $MaxFilePerPage;

        if ($EndFileNo > $NumOfFiles) {
           $EndFileNo = $NumOfFiles;
        }
        //Display the file
        for ($i=$StartFileNo; $i<$EndFileNo;$i++)
            echo "<a href=\"$files[$i]\">$files[$i]</a>
\n";
			
			

    if ($page > 0) {
           $PrevPage = $page-1;
		   echo " \n";
           echo "||<a href=\"$script?page=$PrevPage\">Prev</a>||\n";
		   echo " \n";
		}

    if ($EndFileNo < $NumOfFiles) {
           $NextPage = $page+1;
		  echo " \n";
          echo "||<a href=\"$script?page=$NextPage\">Next</a>||\n";
		  echo " \n";
        }    

     } else {
        print "<p class=\"error\">No files.</p>"; 
     }
}
?>

it can modified by preview as link or by image that you want to..

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close