/    Sign up×
Community /Pin to ProfileBookmark

How to ignore/avoid empty folders in PHP ?

Hello,
Here is a simple PHP recursive file list (with interactive and visual FX)
[url]http://acc.jexiste.ch/[/url]
[url]http://acc.jexiste.ch/JPN/RecurciveDIR12.RAR[/url]

  • 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 ?
    [url]http://www.mways.co.uk/prog/hidemail.php[/url]

  • 4. Is my SpamPoison tag useful if I set it a#SP{display:none;} in the CSS ?
    No contact link in their page ;(( [url]http://spampoison.com/[/url]
  • Thanks and regards.

    [CODE]<?PHP
    //********************* RecurciveDIR 1.2 – Recursive PHP File List With Interactive & Visual Effects
    //error_reporting(1);
    function DirContent($Path,$Level=0){
    $DEBUG=false;//***** For DEBUGGING
    $ind=str_repeat(” “,$Level);
    $FisrtLevel=$Level<1;
    $Folders2Show=array(“JPN”);//***** CUSTOMIZE: Root Folders To Show
    if($folder=opendir($Path)){
    if($FisrtLevel){
    echo “<H1>Sam’s Files : “.date(“Y.m.d”).”</H1>n”;//Main Title
    }
    while(false!==($file=readdir($folder))){
    $PathS=$Path.”/”.$file;
    //Recursive Traitement For Sub-Folders
    if(is_dir($Path.”/”.$file) && $file!=’.’ && $file!=’..’){
    if((in_array($file,$Folders2Show) && $FisrtLevel) || !$FisrtLevel){
    $Fid=rand(100000,999999);
    $BoderW=max(1,3-$Level);
    $Hn=min(6,$Level+2);
    $atH=” id=’h$Fid'”;
    $inH2=substr($PathS,strrpos($PathS,”/”)+1);
    echo $ind.”<H$Hn $atH>”.$inH2.”</H$Hn>n”;
    $atD=”style=’border-width:”.$BoderW.”Px'”;
    $atD.=” id=’d”.$Fid.”‘ class=’on'”;
    echo $ind.”<DIV “.$atD.”>n”;
    DirContent($PathS,$Level+1);
    echo $ind.”</DIV>n”;
    }
    }
    if(!is_dir($PathS) && $file!=”.” && $file!=”..”){
    if(!$FisrtLevel){
    $Ext2Hide=array(“PHP”,”HTM”,”HTML”); //Extensions To Hide = Viewable Files
    $Ext=strtoupper(substr($file,strrpos($file,”.”)+1));
    $Title=””;
    if(in_array($Ext,$Ext2Hide)){
    $Filename=substr($file,0,strrpos($file,”.”));//Hide The Extension
    //$Title=”title=’ View “.$file.”‘”;
    }else{
    $Filename=$file; //Show The Extension
    $Title=”title=’ Download “.$file.”‘”;
    }
    $href=$DEBUG?”#”:$PathS;
    echo $ind.”<P><a href='”.$href.”‘ $Title>”.$Filename.”</a></P>n”;//Link To The File
    }
    }
    }
    closedir($folder);
    }
    }
    //*************************************************************************************** Link List!
    function LinksLIST(){
    $LinkFN=”LiNKS.LOG”;
    }
    ?>
    <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>
    <html>
    <head>
    <meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
    <title>Sam’s Files</title>
    <style type=”text/css”>
    <!–
    HTML,*{margin:0Px;padding:0Px}
    BODY {font-family:”Trebuchet MS”,Arial,sans-serif;font-size:13Px;margin:20Px;cursor:default;}
    H1,H2,H3,H4,H5,H6 {margin-top:5Px;}
    H2,H3,H4,H5,H6 {cursor:pointer;}
    H1{font-size:20Px;margin-bottom:15Px}
    H2{font-size:17Px;}
    H3{font-size:16Px;}
    H4{font-size:15Px;}
    H5{font-size:14Px;}
    H6{font-size:13Px;}
    HR{height:1Px;color:#666666;}
    P {padding:4Px 0 0 0;}
    A {text-decoration:none;color:#0000CC;}
    A:hover {color:#993300;}
    DIV {padding-left:8Px;border-color:#979748;border-left-style:solid;}
    DIV.on {display:block;font-weight:normal}
    DIV.off {display:none; font-weight:bold ;}
    DIV.over{background-color:#F1F1E2;}
    DIV.out {}
    DIV#foot a#SP{display:none;}
    DIV#foot a{margin:0 0 0 9Px;vertical-align:top;}
    DIV#foot{font-size:14Px;text-align:right;border:solid #999999;border-width:1Px 0 0 0;margin-top:8Px}
    –>
    </style>
    <script language=”JavaScript” type=”text/javascript”>
    <!–
    //Interactive Sub-Folders FX
    function SwitchDIV(){
    var Elems=new Array(“H2″,”H3″,”H4″,”H5″,”H6″);//Elements To Affect Rollover FX
    var HideS=” Hide this folder’s content ! “;
    var ShowS=” Show this folder’s content ! “;
    if(document.getElementsByTagName){
    for(n=0;n<Elems.length;n++){
    var el=document.getElementsByTagName(Elems[n]);
    for(var i=0;i<el.length;i++){
    el[i].show=true;
    el[i].title=HideS;
    el[i].Fname=el[i].innerHTML;
    el[i].innerHTML=”- “+el[i].Fname;
    el[i].cible=document.getElementById(“d”+el[i].id.substr(1));//Sub-Folder’s DIV
    el[i].onmouseover=function(){//Rollover FX
    if(this.show){
    this.cible.className=”over”;
    }
    }
    el[i].onmouseout=function(){//Rollout FX
    if(this.show){
    this.cible.className=”out”;
    }
    }
    el[i].onclick=function(){//Hide/Show Sub-Folders Content
    if(this.show){
    this.show=false;
    this.title=ShowS;
    this.cible.className=”off”;
    this.innerHTML=”+ “+this.Fname;
    }else{
    this.show=true;
    this.title=HideS;
    this.cible.className=”on over”;
    this.innerHTML=”- “+this.Fname;
    }
    }
    }
    }
    }
    }
    //Blur All Links OnCLICK To Hide Dotted Borders
    function BlurLNK(){
    var linkE=document.getElementsByTagName(“a”);
    if(document.getElementsByTagName){
    for(i=0;i<linkE.length;i++){
    linkE[i].onclick=function(){this.blur();}
    }
    }
    }
    // –>
    </script>
    </head>
    <body onload=”SwitchDIV();BlurLNK()”>

    <?PHP DirContent(“.”); ?>

    <div id=”foot”>
    <a href=”mailto:%41%6c%66%2e%30%32%32%40%47%6d%61%69%6c%2e%63%6f%6d”> &#67;&#111;&#109;&#109;&#101;&#110;&#116; &#63;&#33; </a>
    <a id=”SP” href=”http://french-145495639767.spampoison.com”><img src=”http://pics4.inxhost.com/images/sticker.gif” border=”0″/></a>
    </div>
    </body>
    </html>[/CODE]

    to post a comment
    PHP

    1 Comments(s)

    Copy linkTweet thisAlerts:
    @SyCoNov 24.2008 — I suppose instead of echoing the content of the dir, you could assign the files list to an array (less . and ..) and count it. If it's less than 1 don't display the folder.
    ×

    Success!

    Help @samz spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 4.28,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,

    tipper: @Samric24,
    tipped: article
    amount: 1000 SATS,
    )...