By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,914 Members | 1,718 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,914 IT Pros & Developers. It's quick & easy.

How to ignore/avoid empty folders in PHP ?

P: 3
Hello,
Here is a simple PHP recursive file list (with interactive and visual FX)
Sam's Files
http://acc.jexiste.ch/JPN/RecurciveDIR12.RAR

1. How to ignore/avoid empty folders in this PHP script ?
2. How to sort files by filename (and, if possible, folders on top) ?
3. Is this MAILTO hidden tool still useful against the current Spam robots ?
Mysterious Ways - Hide Email Addresses from Spam Harvesters
4. Is my SpamPoison tag useful if I set it a#SP{display:none;} in the CSS ?
No contact link in their page ;(( Anti-Spam - Fight Back Against Spammers | bulk unsolicited unwanted junk email

Thanks and regards.

PS.
I got this error:
Upload Errors
RecursiveDIR12.ZIP:
Exceeds forum quota by 2.2 KB.


Expand|Select|Wrap|Line Numbers
  1. <?PHP
  2. //********************* RecurciveDIR 1.2 - Recursive PHP File List With Interactive & Visual Effects
  3. //error_reporting(1);
  4. function DirContent($Path,$Level=0){
  5.     $DEBUG=false;//***** For DEBUGGING
  6.     $ind=str_repeat(" ",$Level);
  7.     $FisrtLevel=$Level<1;
  8.     $Folders2Show=array("JPN");//***** CUSTOMIZE: Root Folders To Show
  9.     if($folder=opendir($Path)){
  10.         if($FisrtLevel){
  11.             echo "<H1>Sam's Files : ".date("Y.m.d")."</H1>\n";//Main Title
  12.         }
  13.         while(false!==($file=readdir($folder))){
  14.             $PathS=$Path."/".$file;
  15.             //Recursive Traitement For Sub-Folders
  16.             if(is_dir($Path."/".$file) && $file!='.' && $file!='..'){
  17.                 if((in_array($file,$Folders2Show) && $FisrtLevel) || !$FisrtLevel){
  18.                     $Fid=rand(100000,999999);
  19.                     $BoderW=max(1,3-$Level);
  20.                     $Hn=min(6,$Level+2);
  21.                     $atH=" id='h$Fid'";
  22.                     $inH2=substr($PathS,strrpos($PathS,"/")+1);
  23.                     echo $ind."<H$Hn $atH>".$inH2."</H$Hn>\n";
  24.                     $atD="style='border-width:".$BoderW."Px'";
  25.                     $atD.=" id='d".$Fid."' class='on'";
  26.                     echo $ind."<DIV ".$atD.">\n";
  27.                     DirContent($PathS,$Level+1);
  28.                     echo $ind."</DIV>\n";
  29.                 }
  30.             }
  31.             if(!is_dir($PathS) && $file!="." && $file!=".."){
  32.                 if(!$FisrtLevel){
  33.                     $Ext2Hide=array("PHP","HTM","HTML");           //Extensions To Hide = Viewable Files
  34.                     $Ext=strtoupper(substr($file,strrpos($file,".")+1));
  35.                     $Title="";
  36.                     if(in_array($Ext,$Ext2Hide)){
  37.                         $Filename=substr($file,0,strrpos($file,"."));//Hide The Extension
  38.                         //$Title="title=' View  ".$file."'";
  39.                     }else{
  40.                         $Filename=$file;                             //Show The Extension
  41.                         $Title="title=' Download  ".$file."'";
  42.                     }
  43.                     $href=$DEBUG?"#":$PathS;
  44.                     echo $ind."<P><a href='".$href."' $Title>".$Filename."</a></P>\n";//Link To The File
  45.                 }
  46.             }
  47.         }
  48.         closedir($folder);
  49.     }
  50. }
  51. //*************************************************************************************** Link List!
  52. function LinksLIST(){
  53.     $LinkFN="LiNKS.LOG";
  54. }
  55. ?>
  56. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  57. <html>
  58. <head>
  59. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  60. <title>Sam's Files</title>
  61. <style type="text/css">
  62. <!--
  63. HTML,*{margin:0Px;padding:0Px}
  64. BODY  {font-family:"Trebuchet MS",Arial,sans-serif;font-size:13Px;margin:20Px;cursor:default;}
  65. H1,H2,H3,H4,H5,H6   {margin-top:5Px;}
  66. H2,H3,H4,H5,H6      {cursor:pointer;}
  67. H1{font-size:20Px;margin-bottom:15Px}
  68. H2{font-size:17Px;}
  69. H3{font-size:16Px;}
  70. H4{font-size:15Px;}
  71. H5{font-size:14Px;}
  72. H6{font-size:13Px;}
  73. HR{height:1Px;color:#666666;}
  74. P {padding:4Px 0 0 0;}
  75. A {text-decoration:none;color:#0000CC;}
  76. A:hover {color:#993300;}
  77. DIV     {padding-left:8Px;border-color:#979748;border-left-style:solid;}
  78. DIV.on  {display:block;font-weight:normal}
  79. DIV.off {display:none; font-weight:bold ;}
  80. DIV.over{background-color:#F1F1E2;}
  81. DIV.out {}
  82. DIV#foot a#SP{display:none;}
  83. DIV#foot a{margin:0 0 0 9Px;vertical-align:top;}
  84. DIV#foot{font-size:14Px;text-align:right;border:solid #999999;border-width:1Px 0 0 0;margin-top:8Px}
  85. -->
  86. </style>
  87. <script language="JavaScript" type="text/javascript">
  88. <!--
  89. //Interactive Sub-Folders FX
  90. function SwitchDIV(){
  91.     var Elems=new Array("H2","H3","H4","H5","H6");//Elements To Affect Rollover FX
  92.     var HideS=" Hide this folder's content ! ";
  93.     var ShowS=" Show this folder's content ! ";
  94.     if(document.getElementsByTagName){
  95.         for(n=0;n<Elems.length;n++){
  96.             var el=document.getElementsByTagName(Elems[n]);
  97.             for(var i=0;i<el.length;i++){
  98.                 el[i].show=true;
  99.                 el[i].title=HideS;
  100.                 el[i].Fname=el[i].innerHTML;
  101.                 el[i].innerHTML="- "+el[i].Fname;
  102.                 el[i].cible=document.getElementById("d"+el[i].id.substr(1));//Sub-Folder's DIV
  103.                 el[i].onmouseover=function(){//Rollover FX
  104.                     if(this.show){
  105.                         this.cible.className="over";
  106.                     }
  107.                 }
  108.                 el[i].onmouseout=function(){//Rollout FX
  109.                     if(this.show){
  110.                         this.cible.className="out";
  111.                     }
  112.                 }
  113.                 el[i].onclick=function(){//Hide/Show Sub-Folders Content
  114.                     if(this.show){
  115.                         this.show=false;
  116.                         this.title=ShowS;
  117.                         this.cible.className="off";
  118.                         this.innerHTML="+ "+this.Fname;
  119.                     }else{
  120.                         this.show=true;
  121.                         this.title=HideS;
  122.                         this.cible.className="on over";
  123.                         this.innerHTML="- "+this.Fname;
  124.                     }
  125.                 }
  126.             }
  127.         }
  128.     }
  129. }
  130. //Blur All Links OnCLICK To Hide Dotted Borders
  131. function BlurLNK(){
  132.     var linkE=document.getElementsByTagName("a");
  133.     if(document.getElementsByTagName){
  134.         for(i=0;i<linkE.length;i++){
  135.             linkE[i].onclick=function(){this.blur();}
  136.         }
  137.     }
  138. }
  139. // -->
  140. </script>
  141. </head>
  142. <body onload="SwitchDIV();BlurLNK()">
  143.  
  144. <?PHP DirContent("."); ?>
  145.  
  146. <div id="foot">
  147.     <a href="mailto:%41%6c%66%2e%30%32%32%40%47%6d%61%69%6c%2e%63%6f%6d"> Comment ?! </a>
  148.     <a id="SP" href="http://french-145495639767.spampoison.com"><img src="http://pics4.inxhost.com/images/sticker.gif" border="0"/></a>
  149. </div>
  150. </body>
  151. </html>
Nov 23 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.