Languages :: PHP :: Sort dirs by creation date |
|||
| By: PHP newbee |
Date: 11/03/2003 00:00:00 |
Points: 120 | Status: Answered Quality : Excellent |
|
On my site, I have a php page that lists all directories. How can I sort that list in creation order? |
|||
| By: VGR | Date: 11/03/2003 01:07:00 | Type : Comment |
|
| the function to get their creation time is (surprinsingly) ctime() to sort them requires a usort() trick or a "normal" sorting, or some other technique I suggest you let the OS do the work like this : $directory2=str_replace('/','\\',$directory); $d = @popen ("dir /ON /B $directory2", "r"); // triés par ordre alphabétique while (!feof ($d)) { $buffer = fgets($d, 4096); $entry=chop($buffer); if (($entry<>'.') and ($entry<>'..') and ($entry<>'')) { // do your stuff on $entry // you may want to use is_dir() to treat only directories (but not . nor ..) } // if affichage } // while $toto=@pclose($d); |
|||
| By: PHP newbee | Date: 11/03/2003 02:52:00 | Type : Comment |
|
Alright, that worked somewhat good, but, maybe I should have been more specific. This is the code I use for the page to generate a table with names based on text-files in dirs. <?php $numberOfColumn=3; function getAlbumTableList($before="", $after="") { global $browse; echo "<div id=\"albumbrowser\">\n$before"; print_table($browse); echo "$after</div>"; } # **************************************************************************************** # 'Private' functions # **************************************************************************************** function print_table($starting_directory, $toBePrinted="") { global $display_abstract, $album_php_config, $lang, $numberOfColumn; $to_print=""; include('inc/album_config.php'); $directory_link=$starting_directory; if ($directory_link==".") { $directory_link=""; } if (file_exists("$directory_link$album_php_config")) { include("$directory_link$album_php_config"); } $is_picture_directory=false; $down_printed=false; $all_dir = array(); if($d_obj = dir($starting_directory)) { while($this_entry = $d_obj->read()) { if ($this_entry != "." && $this_entry != ".." && $this_entry != $thumb_dir) { if(is_dir("$directory_link$this_entry")) { if (isValidPictureDirectory("$directory_link$this_entry")) { $all_dir[] = $this_entry; } } if (is_file("$directory_link$this_entry")) { if (isValidPictureFile("$directory_link$this_entry") != boolean) { $is_picture_directory=true; } } } } $d_obj->close(); } else { echo "Error! Couldn't list directory $starting_directory for some reason!<br />"; exit; } $keep_going=true; $x=0; $y=0; $z=0; $width=round(100/$numberOfColumn); echo "<table id=\"albumsListTable\" width=\"476\">\n"; while ($keep_going) { echo " <tr class=\"albumsLine\">\n"; while ($y < $numberOfColumn) { if ($z<sizeof($all_dir)) { echo "<td class=\"albumsCell\" width=\"$width%\" align=\"center\" valign=\"top\">"; echo "<a href=\"album.php?album="; echo $all_dir[$z]; echo "\">"; echo getAlbumTitleText("$all_dir[$z]/"); } else { echo "<td class=\"noAlbumsCell\" width=\"$width%\" align=\"center\" valign=\"top\"> </td>\n"; $keep_going=false; } $y++; $z++; } $x++; $y=0; echo " </tr>\n"; } echo "</table>\n"; } ?> Any way to make it sort the dirs, (i.e. the info in the album.txt-file), chronological? /Helen |
|||
| By: VGR | Date: 11/03/2003 03:36:00 | Type : Comment |
|
| note that this line doesn't work as you expected : if ($this_entry != "." && $this_entry != ".." && $this_entry != $thumb_dir) { $thumb_dir is undefined in print_table() |
|||
| By: VGR | Date: 11/03/2003 03:40:00 | Type : Comment |
|
| to solve your ordering problem, I would replace these lines : if($d_obj = dir($starting_directory)) { while($this_entry = $d_obj->read()) { by those : if($d_obj = @popen ("dir /ON /B $starting_directory", "r") ) { while (!feof ($d_obj)) { $buffer = fgets($d_obj, 4096); $this_entry=chop($buffer); and I would replace also $d_obj->close(); by $toto=@pclose($d_obj); |
|||
| By: PHP newbee | Date: 11/03/2003 08:39:00 | Type : Comment |
|
| sorry, didn't work. It dosn't show any columns. I'm really bad at php, so please be really specific when you ask me to change code =) |
|||
| By: VGR | Date: 11/03/2003 09:51:00 | Type : Comment |
|
| ok, full source then <?php $numberOfColumn=3; function getAlbumTableList($before="", $after="") { global $browse; echo "<div id=\"albumbrowser\">\n$before"; print_table($browse); echo "$after</div>"; } # **************************************************************************************** # 'Private' functions # **************************************************************************************** function print_table($starting_directory, $toBePrinted="") { global $display_abstract, $album_php_config, $lang, $numberOfColumn; $to_print=""; include('inc/album_config.php'); $directory_link=$starting_directory; if ($directory_link==".") { $directory_link=""; } if (file_exists("$directory_link$album_php_config")) { include("$directory_link$album_php_config"); } $is_picture_directory=false; $down_printed=false; $all_dir = array(); if($d_obj = @popen ("dir /ON /B $starting_directory", "r") ) { while (!feof ($d_obj)) { $buffer = fgets($d_obj, 4096); $this_entry=chop($buffer); if ($this_entry != "." && $this_entry != ".." && $this_entry != $thumb_dir) { if(is_dir("$directory_link$this_entry")) { if (isValidPictureDirectory("$directory_link$this_entry")) { $all_dir[] = $this_entry; } } if (is_file("$directory_link$this_entry")) { if (isValidPictureFile("$directory_link$this_entry") != boolean) { $is_picture_directory=true; } } } } $toto=@pclose($d_obj); } else { echo "Error! Couldn't list directory $starting_directory for some reason!<br />"; exit; } $keep_going=true; $x=0; $y=0; $z=0; $width=round(100/$numberOfColumn); echo "<table id=\"albumsListTable\" width=\"476\">\n"; while ($keep_going) { echo " <tr class=\"albumsLine\">\n"; while ($y < $numberOfColumn) { if ($z<sizeof($all_dir)) { echo "<td class=\"albumsCell\" width=\"$width%\" align=\"center\" valign=\"top\">"; echo "<a href=\"album.php?album="; echo $all_dir[$z]; echo "\">"; echo getAlbumTitleText("$all_dir[$z]/"); } else { echo "<td class=\"noAlbumsCell\" width=\"$width%\" align=\"center\" valign=\"top\"> </td>\n"; $keep_going=false; } $y++; $z++; } $x++; $y=0; echo " </tr>\n"; } echo "</table>\n"; } ?> |
|||
| By: VGR | Date: 11/03/2003 09:52:00 | Type : Comment |
|
| as far as columns are concerned, it shouldn't change anything. I only modified the way you get $this_entry |
|||
| By: PHP newbee | Date: 11/03/2003 18:53:00 | Type : Comment |
|
| Still, doesn't display anything. Maybe there's another way? |
|||
| By: PHP newbee | Date: 12/03/2003 20:01:00 | Type : Comment |
|
| Cant use fileatime to compare it and display the oldest first? |
|||
| By: VGR | Date: 12/03/2003 20:03:00 | Type : Comment |
|
| 1)"Alright, that worked somewhat good" : so my code does display the files (and directories) in the order you want 2)"Still, doesn't display anything." : ??? I just slightly modified your code (supposed to display something, right ? :D ) so that files (rather "directories") are taken differently. The rest (display etc) is 100% your code So I don't understand. PS : toBePrinted is not used at all in print_table() PPS : I'm trying to run the script, yours, mine, and the combination. Later. |
|||
| By: VGR | Date: 12/03/2003 20:05:00 | Type : Comment |
|
| could I see file 'inc/album_config.php' ? |
|||
| By: PHP newbee | Date: 12/03/2003 20:21:00 | Type : Comment |
|
| perhaps adopt this code??? Found it somehwre but cant apply it... $directory = "$album/"; $files = array(); $columnSpan = 4; $handle = opendir($directory); $i = 0; while($filename = readdir($handle)) { if ($filename <> '.' && $filename <> '..') { $files[$i] = array(filemtime($directory .$filename), $filename); $i ++; } } arsort($files); reset($files); |
|||
| By: VGR | Date: 12/03/2003 20:27:00 | Type : Comment |
|
| yes archker, but it should use ctime() not mtime() AFAIK |
|||
| By: PHP newbee | Date: 12/03/2003 21:13:00 | Type : Comment |
|
| then how would the code look in the whole context? |
|||
| By: VGR | Date: 12/03/2003 22:48:00 | Type : Comment |
|
| As I wrote above when I said "full code" I'm still waiting for the 'inc/album_config.php' file to be able to run the scripts Listening... |
|||
| By: PHP newbee | Date: 12/03/2003 23:11:00 | Type : Comment |
|
| well, it just doesn't display any colums, it's just blank, but at least it doesnt say any error messeges, so it's somewhat good I guess =) you can get all the other files from <A HREF="http://www.chevillat.ch/sp/soft/picsPHP/">http://www.chevillat.ch/sp/soft/picsPHP/</a> I modified it of cource ALOT but all the files u need should be there. |
|||
| By: VGR | Date: 12/03/2003 23:11:00 | Type : Comment |
|
| <A HREF="http://www.chevillat.ch/sp/soft/picsPHP/inc/album_config.php">http://www.chevillat.ch/sp/soft/picsPHP/inc/album_config.php</a> ? |
|||
| By: VGR | Date: 12/03/2003 23:24:00 | Type : Comment |
|
| I need the PHP script, NOT THE HTML FILE THAT WILL BE RETURNED IN MY BROWSER I tried to directly include the above URL but to no avail It's not very serious to ask for help on a script that can't be run 8-) |
|||
| By: PHP newbee | Date: 13/03/2003 00:10:00 | Type : Comment |
|
| It can be run.... sigh, but it consist of multiple files! (download the entire thing from <A HREF="http://www.chevillat.ch/sp/soft/picsPHP/download.php">http://www.chevillat.ch/sp/soft/picsPHP/download.php</a> ) that's what I meant. But sure =), if you think the album_config will help: <?php # **************************************************************************************** # # **************************************************************************************** # number of lines and columns per page for the pictures index $lines=4; $cols=3; # number besides the thumbnail # 1: yes, 2: no $display_number=0; # stylesheet $album_stylesheets=array('default.css'); # Are the thumbnails available somewhere ? # 1: yes, 0: no # If not the original pictures will be resized by the browser (not suitable)! $thumb=1; # if yes, which repertory are they ? and what is the 'prefix' of the thumbnails ? $thumb_dir=""; $thumb_prefix="t_"; # if not, what percentage the thumbnails should be ? # 100%= the thumbnails are the same size than the picture itself. # 50%=half of the original size # 0%=not a valid value $thumb_resize=50; $nb_thumb_navigation=5; ?> |
|||
| By: VGR | Date: 13/03/2003 00:47:00 | Type : Comment |
|
| sorry for having not found download.php by myself 8-)) testing... I hope default.css is not essential also 8-) |
|||
| By: VGR | Date: 13/03/2003 00:49:00 | Type : Comment |
|
| Sorry, but some definition of those variables is missing : if (file_exists("$directory_link$album_php_config")) { include("$directory_link$album_php_config"); |
|||
| By: VGR | Date: 13/03/2003 00:51:00 | Type : Comment |
|
| in your script, the variables $directory_link and $album_php_config are not set, are not declared, are not set up by an include file, are not passed as parameters to the print_table() function, are not global variables (no session_start(); at the beginning)... HOW COULD THIS WORK ???!!?? |
|||
| By: VGR | Date: 13/03/2003 00:57:00 | Type : Comment |
|
| Sorry also, but your downloaded files produce this : Warning: getimagesize: Unable to open '/' for reading. in ***\picsphp\inc\functions.php on line 223 I don't have time to re-configure all your includes I maintain that IF your code did produce results before we touched it, and IF my code did "perform well" (sic) for sorting the directories the way you wanted, THEN combining both the way I did above SHOULD WORK. |
|||
| By: PHP newbee | Date: 13/03/2003 03:23:00 | Type : Comment |
|
| hmmm, odd. Becouse when I use the code you gave me, the table that displeyed all dirs just comes up totally blank. Go here to get all the files I use, if you want to help me: <A HREF="http://www.fantasygallery.net/php.zip">http://www.fantasygallery.net/php.zip</a> I really appriciate the help you're giving me. I really don't think there's alot of undefined functions, u just have to look at all the php-pages included. It's sort-of annoingly complicated I guess. (explaination: there is an index.php and and album.php and a picture.php that calls for several files that in their turn calls for several files, which has several functions and draws their definitions from perhaps not their own files but other files which also are included.......) It is index.php that calls for this list of directiories. /Helen |
|||
| By: VGR | Date: 13/03/2003 19:12:00 | Type : Comment |
|
| i would like to see the HTML source of the page "totally blank", PLEASE |
|||
| By: PHP newbee | Date: 13/03/2003 19:42:00 | Type : Comment |
|
| that's the index.php file in the zip file |
|||
| By: VGR | Date: 13/03/2003 19:47:00 | Type : Comment |
|
| not the PHP source, the source (HTML code) of the GENERATED PAGE execute my script, it comes "blank" - fine. Do rightclick/view source and copy-paste this here thanks |
|||
| By: PHP newbee | Date: 13/03/2003 19:55:00 | Type : Comment |
|
| or I mean: fantasygallery.net =) changed the code to your model now... (btw it's the album_special_functions.php which holds the code for the table) |
|||
| By: PHP newbee | Date: 13/03/2003 20:02:00 | Type : Comment |
|
| perhaps you have to have a few subdirectories to where you place the files. IE a few dirs with images, and in each dir a file named album.txt only with one line of text, fx a name or so. =) |
|||
| By: PHP newbee | Date: 13/03/2003 20:04:00 | Type : Comment |
|
| sorry, I keep misunderstanding you. I guess I'm just really stupid sometimes. |
|||
| By: VGR | Date: 13/03/2003 20:48:00 | Type : Comment |
|
| run my script "that performed well" the page is supposed to come out BLANK GET THE SOURCE HTML OF THAT PAGE BY RIGHT-CLICKING IN THE BROWSER'S WINDOW AND choosing "view page source" and COPY-PASTE WHAT YOU OBTAIN HERE |
|||
| By: PHP newbee | Date: 14/03/2003 20:00:00 | Type : Comment |
|
| sure I just figured it's be easier if you looked at the page instead of posting alot of unnessesery code here... <html> <head> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<A HREF="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>"> <title>Fantasy Art Gallery</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href="inc/css/default.css" rel="stylesheet" type="text/css"> <link REL="SHORTCUT ICON" HREF="<A HREF="http://www.fantasygallery.net/inc/gal.ico">http://www.fantasygallery.net/inc/gal.ico</a>"> </head> <div align="left"> <table width="720" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="left" valign="top" style="background-color:#000000; background-image: url(/inc/drake.gif);background-repeat: no-repeat;"> <table width="720" cellspacing="0" cellpadding="0" style="border:3px;border-style:solid;border-color:#000000"> <tr> <td width="121" height="112"> </td> <td valign="bottom" width="599" height="112" align="left" background="/inc/logo.jpg"><img src="/inc/black.gif" height="4" width="100%" style="border:0px"></td> </tr> <tr> <td width="121"><img src="/inc/invis.gif" width="121" style="border:0px"></td> <td background="/inc/bg.gif" valign="top" align="right" width="599"> <div align="right"> <table width="536" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="center"> --- ::: ------ :::: --------- :::::::::::::::::::::::::: --------- :::: ------ ::: --- --- ::: ------ :::: --------- :::::::::::::::::::::::::: --------- :::: ------ ::: --- <div id="albumbrowser"> <table id="albumsListTable" width="476"> <tr class="albumsLine"> <td class="noAlbumsCell" width="33%" align="center" valign="top"> </td> <td class="noAlbumsCell" width="33%" align="center" valign="top"> </td> <td class="noAlbumsCell" width="33%" align="center" valign="top"> </td> </tr> </table> </div>--- ::: ------ :::: --------- :::::::::::::::::::::::::: --------- :::: ------ ::: --- Old masters will be added soon --- ::: ------ :::: --------- :::::::::::::::::::::::::: --------- :::: ------ ::: --- </td> </tr> </table> </div> </td> </tr> <tr> <td width="121"><img src="/inc/invis.gif" width="121" style="border:0px"></td> <td background="/inc/down.jpg" valign="top" align="right" width="599" height="116"> </td> </tr> </table> </td> </tr> </table> </div> </body> </html> |
|||
| By: VGR | Date: 14/03/2003 20:13:00 | Type : Comment |
|
| so sizeof($all_dir)) =0 as per your code I suggest to debug the part just before : } //test $DEBUGTEST=1; // $is_picture_directory=false; $down_printed=false; $all_dir = array(); if ($DEBUGTEST==1) echo "all_dir[] cleaned "; if($d_obj = dir($starting_directory)) { if ($DEBUGTEST==1) echo "ok getdir of '$starting_directory' "; while($this_entry = $d_obj->read()) { if ($DEBUGTEST==1) echo "entry '$this_entry' found "; if ($this_entry != "." && $this_entry != ".." && $this_entry != $thumb_dir) { if ($DEBUGTEST==1) echo "entry '$this_entry' accepted as candidate "; if(is_dir("$directory_link$this_entry")) { if ($DEBUGTEST==1) echo "entry '$this_entry' is a directory "; if (isValidPictureDirectory("$directory_link$this_entry")) { if ($DEBUGTEST==1) echo "entry '$this_entry' passed isValidPictureDirectory, added to all_dir "; $all_dir[] = $this_entry; } } if (is_file("$directory_link$this_entry")) { if ($DEBUGTEST==1) echo "entry '$this_entry' is a file "; if (isValidPictureFile("$directory_link$this_entry") != boolean) { if ($DEBUGTEST==1) echo "entry '$this_entry' passed absurd test "; $is_picture_directory=true; } } } } $d_obj->close(); if ($DEBUGTEST==1) echo "end of directories search "; } else { echo "Error! Couldn't list directory $starting_directory for some reason!<br />"; exit; } PS : what does mean this code part ??? if (isValidPictureFile("$directory_link$this_entry") != boolean) boolean is undefined ! is isValidPuctureFile returns a Boolean, then the test should be written as : if (isValidPictureFile("$directory_link$this_entry")) |
|||
| By: PHP newbee | Date: 14/03/2003 21:02:00 | Type : Comment |
|
| yes well, boolean was just a leftover from some insane moment of mine. I'll try and debug now... |
|||
| By: PHP newbee | Date: 14/03/2003 21:17:00 | Type : Comment |
|
| well, it finds everything when I run my old code of course: all_dir[] cleaned ok getdir of '.' entry '.' found entry '..' found entry 'lockwood' found entry 'lockwood' accepted as candidate entry 'lockwood' is a directory entry 'lockwood' passed isValidPictureDirectory, added to all_dir entry 'alexander' found entry 'alexander' accepted as candidate entry 'alexander' is a directory entry 'alexander' passed isValidPictureDirectory, added to all_dir entry 'myalbums.php' found entry 'myalbums.php' accepted as candidate entry 'myalbums.php' is a file und so weiter... end of directories search but when I run the code you altered it only says: all_dir[] cleaned ok getdir of '.' end of directories search ? |
|||
| By: VGR | Date: 14/03/2003 21:36:00 | Type : Comment |
|
| ok, just to make sure we write about the same code, I reproduce what I think should be the code so far function print_table($starting_directory, $toBePrinted="") { global $display_abstract, $album_php_config, $lang, $numberOfColumn; $to_print=""; include('inc/album_config.php'); //test $DEBUGTEST=1; // $directory_link=$starting_directory; if ($directory_link==".") { $directory_link=""; } if (file_exists("$directory_link$album_php_config")) { include("$directory_link$album_php_config"); } $is_picture_directory=false; $down_printed=false; $all_dir = array(); if ($DEBUGTEST==1) echo "VGR all_dir[] cleaned "; if($d_obj = @popen ("dir /ON /B $starting_directory", "r") ) { if ($DEBUGTEST==1) echo "VGR ok getdir of '$starting_directory' "; while (!feof ($d_obj)) { $buffer = fgets($d_obj, 4096); $this_entry=chop($buffer); if ($DEBUGTEST==1) echo "VGR entry '$this_entry' found "; if ($this_entry != "." && $this_entry != ".." && $this_entry != $thumb_dir) { if ($DEBUGTEST==1) echo "VGR entry '$this_entry' accepted as candidate "; if(is_dir("$directory_link$this_entry")) { if ($DEBUGTEST==1) echo "VGR entry '$this_entry' is a directory "; if (isValidPictureDirectory("$directory_link$this_entry")) { if ($DEBUGTEST==1) echo "VGR entry '$this_entry' passed isValidPictureDirectory, added to all_dir "; $all_dir[] = $this_entry; } } if (is_file("$directory_link$this_entry")) { if ($DEBUGTEST==1) echo "VGR entry '$this_entry' is a file "; if (isValidPictureFile("$directory_link$this_entry")) { // CHECK TEST if ($DEBUGTEST==1) echo "VGR entry '$this_entry' is valid picture file "; $is_picture_directory=true; } } } } $toto=@pclose($d_obj); if ($DEBUGTEST==1) echo "VGR end of directories search, ".count($all_dir)." elements found. "; } else { echo "Error! Couldn't list directory $starting_directory for some reason!<br />"; exit; } $keep_going=true; $x=0; $y=0; $z=0; $width=round(100/$numberOfColumn); echo "<table id=\"albumsListTable\" width=\"476\">\n"; while ($keep_going) { echo " <tr class=\"albumsLine\">\n"; while ($y < $numberOfColumn) { if ($z<sizeof($all_dir)) { echo "<td class=\"albumsCell\" width=\"$width%\" align=\"center\" valign=\"top\">"; echo "<a href=\"album.php?album="; echo $all_dir[$z]; echo "\">"; echo getAlbumTitleText("$all_dir[$z]/"); } else { echo "<td class=\"noAlbumsCell\" width=\"$width%\" align=\"center\" valign=\"top\"> </td>\n"; $keep_going=false; } $y++; $z++; } $x++; $y=0; echo " </tr>\n"; } echo "</table>\n"; } ?> just fix the "strange test with != boolean" and run it. Thanks |
|||
| By: PHP newbee | Date: 15/03/2003 22:04:00 | Type : Comment |
|
| now it says VGR all_dir[] cleaned VGR ok getdir of '.' VGR entry '' found VGR end of directories search, 0 elements found. |
|||
| By: VGR | Date: 15/03/2003 22:55:00 | Type : Comment |
|
| Well, I tested this code : <? $directory='.'; $directory2=str_replace('/','\\',$directory); $d = @popen ("dir /ON /B $directory2", "r"); // triis par ordre alphabitique while (!feof ($d)) { $buffer = fgets($d, 4096); $entry=chop($buffer); if (($entry<>'.') and ($entry<>'..') and ($entry<>'')) { // do your stuff on $entry echo "found $entry "; // you may want to use is_dir() to treat only directories (but not . nor ..) } // if affichage } // while $toto=@pclose($d); ?> and it produced : found aigle2 found Babou found bebel found bin found blank.html found discserver found doc <snip> found favicon.ico found testdir.php // this script found testprint.bak So you can see that I have all the directories, all the files... The instrumented code should work... On Windows platform... I now copy-pasted the code you tried and I did this (I commented out some parts because of missing functions etc) <? $starting_directory='.'; $DEBUGTEST=1; $all_dir = array(); if ($DEBUGTEST==1) echo "VGR all_dir[] cleaned "; if($d_obj = @popen ("dir /ON /B $starting_directory", "r") ) { if ($DEBUGTEST==1) echo "VGR ok getdir of '$starting_directory' "; while (!feof ($d_obj)) { $buffer = fgets($d_obj, 4096); $this_entry=chop($buffer); if ($DEBUGTEST==1) echo "VGR entry '$this_entry' found "; if ($this_entry != "." && $this_entry != ".." && $this_entry != $thumb_dir) { if ($DEBUGTEST==1) echo "VGR entry '$this_entry' accepted as candidate "; if(is_dir("$directory_link$this_entry")) { if ($DEBUGTEST==1) echo "VGR entry '$this_entry' is a directory "; // if (isValidPictureDirectory("$directory_link$this_entry")) { //if ($DEBUGTEST==1) echo "VGR entry '$this_entry' passed isValidPictureDirectory, added to all_dir "; // // $all_dir[] = $this_entry; // } } if (is_file("$directory_link$this_entry")) { if ($DEBUGTEST==1) echo "VGR entry '$this_entry' is a file "; // if (isValidPictureFile("$directory_link$this_entry")) { // CHECK TEST //if ($DEBUGTEST==1) echo "VGR entry '$this_entry' is valid picture file "; // $is_picture_directory=true; // } } } } $toto=@pclose($d_obj); if ($DEBUGTEST==1) echo "VGR end of directories search, ".count($all_dir)." elements found. "; } else { echo "Error! Couldn't list directory $starting_directory for some reason!<br />"; exit; } ?> And it produced... WHAT I WAS EXPECTING : VGR all_dir[] cleaned VGR ok getdir of '.' VGR entry 'aigle2' found VGR entry 'aigle2' accepted as candidate VGR entry 'aigle2' is a directory VGR entry 'Babou' found VGR entry 'Babou' accepted as candidate VGR entry 'Babou' is a directory VGR entry 'bebel' found VGR entry 'bebel' accepted as candidate VGR entry 'bebel' is a directory VGR entry 'bedes' found VGR entry 'bedes' accepted as candidate VGR entry 'bedes' is a directory VGR entry 'bin' found VGR entry 'bin' accepted as candidate VGR entry 'bin' is a directory VGR entry 'blank.html' found VGR entry 'blank.html' accepted as candidate VGR entry 'blank.html' is a file <snip> VGR entry '' found VGR end of directories search, 0 elements found. // that's normal, I commented out the filling in of $all_dir[] IT WORKS !!! |
|||
| By: VGR | Date: 15/03/2003 22:55:00 | Type : Comment |
|
| So My guess is that there are no files in your current ('.') directory... Have you chdir()-ed ? |
|||
| By: PHP newbee | Date: 15/03/2003 23:57:00 | Type : Comment |
|
| there's alot of files in my current dir, 18 or so... chkdir()-ed???? what? |
|||
| By: PHP newbee | Date: 16/03/2003 00:00:00 | Type : Comment |
|
| =) you know what, I have my site on a unix platform... |
|||
| By: VGR | Date: 16/03/2003 00:30:00 | Type : Answer |
|
| I knew it 8-)) It could not have been anything else 8-) STUPID BOTH OF US !!! anyway, my technique should work fi you replace "dir /ON /B $directory2" by something like "ls -ltraH $directory2' (depending on your OS level) try to get the command line with ls to list files and/or directories in the order you want, then substitute it to "dir /ON /B $directory2" and you are done 8-) |
|||
| By: PHP newbee | Date: 16/03/2003 00:38:00 | Type : Comment |
|
| $directory2 ...? |
|||
| By: VGR | Date: 16/03/2003 00:46:00 | Type : Comment |
|
| it's the PHP variable. Just put '.' for your testing purposes |
|||
| By: VGR | Date: 16/03/2003 00:46:00 | Type : Comment |
|
| start with : ls -ltra . and expand from that with reading "man ls" |
|||
| By: PHP newbee | Date: 16/03/2003 00:48:00 | Type : Comment |
|
| ...hihi... IT WORKED!!!!!!!!!!! changed it to: ls -t $starting_directory thank you! |
|||
| By: VGR | Date: 16/03/2003 00:58:00 | Type : Comment |
|
| Let me just say that if you had not answered "Alright, that worked somewhat good, but, maybe I should have been more specific" to my first posting with "DIR /OD", I would have understood that you were not on Windows :D I think I merited my points on this one question :/ |
|||
| By: VGR | Date: 16/03/2003 00:59:00 | Type : Comment |
|
| just change this line and you are done : $DEBUGTEST=0; |
|||
| By: PHP newbee | Date: 16/03/2003 01:29:00 | Type : Comment |
|
| hehe... well... thats life... |
|||
| By: PHP newbee | Date: 16/03/2003 01:32:00 | Type : Comment |
|
| thanks for not giving up =) |
|||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








