Page 1 of 1

have problem in filesystem code

Posted: Sat Feb 18, 2006 10:30 am
by fastwings
feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


mm its go like this first the code

Code: Select all

?>
 <script type="text/javascript">
		  <!--
		  d = new dTree('d');
		  d.config.closeSameLevel=true;
		  d.config.useCookies=false;
		  d.add(0,-1,'The Gallerys');
		  <?
		  $dir  ="../Gallerys/";
		  if (is_dir($dir)) {
		  	if ($dh = opendir($dir)) {
		  		while (($file = readdir($dh)) !== false) {
		  			if ($file!="."&&$file!=".."&&$file!="index.html"&&$file!="index.htm"&&$file!="666"&&$file!="Base") {
		  				$i++;
		  				echo "d.add($i,0,'$file');\n\r";
		  				$x = $i;
		  				$dir2 = $dir.$file."/storage/albums/";
		  				if (is_dir($dir2)) {
		  					if ($dh1 = opendir($dir2)) {
		  						while (($file1 = readdir($dh1)) !== false) {
		  							if ($file1!="."&&$file1!=".."&&$file1!="index.html"&&$file1!="index.htm") {
		  								$dir3 = $dir2.$file1;	
		  								if (is_dir($dir3)) {
		  									if ($dh2 = opendir($dir3)) {
		  										while (($file2 = readdir($dh2)) !== false) {
		  											if ($file2!="."&&$file2!=".."&&$file2!="index.html"&&$file2!="index.htm") {
		  												$dir4 = $dir3."/".$file2;
		  												if (is_dir($dir4)) {
		  													$i++;
		  													$r = $i;
		  													if ($set) {
		  														$set = true;
			  													echo "d.add($i,$x,'$file1');\n";
		  														$i++;
		  														echo "d.add($i,$r,'$file2','index.php?atc=pic&lp=$file/$file1/$file2');\n";
		  													}
		  													else {
		  														$i++;
		  														echo "d.add($i,$x,'$file1','index.php?atc=pic&lp=$file/$file1');\n";
		  													}
		  												}
		  											}
		  										}
		  									}
		  								}
		  								unset($set);
		  							}
		  						}
		  					}
		  				}
		  			}
		  		}
		  	}
		  }
		  closedir($dh);
		  ?>
		  document.write(d);
		  //-->
		  </script>
now the problem what i have is the file system that he reads not rigth cuz its give me the every lib like 10-20 times
and i need that its show me just one time also its not read in the 3 lvl dir
its like he read the base -> first lvl -> secand lvl and here its stuck
i need he will read also the 3 lvl and give me every dir(not give no metter what lvl just the dir) one time,
do u know how i can fix this i have try so many times its dont look like working at all
thx in advens to all the healers


feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Sat Feb 18, 2006 10:40 am
by feyd
your code is written such that $set will never be true nor set.

Posted: Sat Feb 18, 2006 11:21 am
by fastwings
ok but how i can do at in such a way that it will be set cuz i have problom i have fillter all incoming file names and that directory's names pass them in the scriipt and have no idea what to do can u help me plz

Posted: Sat Feb 18, 2006 5:37 pm
by Ambush Commander
That looks really nasty. First thing you should do is make it easier to read. What you want to do first is create a substitute for scandir() so that you divide the number of loops by about three. Cut duplication.

I really don't understand what your specifications are. Can you provide some examples of expected output?