SCORPiON'S iNDEXER 1.0

Dieses Thema im Forum "Programmierung & Entwicklung" wurde erstellt von TrONiX, 7. Januar 2005 .

Schlagworte:
  1. 7. Januar 2005
    Einfach folgenden Code in ne xyz.php Datei speichern und aufrufen.

    Erzeugt euch ne schöne Verseichnisstrucktur.

    In diesem Sinne,
    cheers


    PHP:
    <?












    $hiddenFilesWildcards  = Array( "*.php" "*~" );


    $allowSubDirs  true ;


    $allowPHPDownloads  false ;



    $useAutoThumbnails  true ;









    $snifServer  $_SERVER [ 'HTTP_HOST' ];
    //$snifServer = 'www.yourdomain.com';


    $snifDateFormat  'd.m.y' ;


    $hiddenFilesRegex  = Array();
     

    $useDescriptionsFrom  "descript.ion" ;


    $separationString  "\t" ;


    $useExternalImages  true ;


    $externalIcons  = Array (
        
    "archive"     =>  "" ,
        
    "binary"     =>  "" ,
        
    "folder"     =>  "" ,
        
    "html"         =>  "" ,
        
    "image"         =>  "" ,
        
    "text"         =>  "" ,
        
    "unknown"     =>  "" ,
        
    "download"     =>  "" ,    // 7x16 pixels
        
    "asc"         =>  "" ,        // 5x3 pixels
        
    "desc"         =>  ""       // 5x3 pixels
    );


    $descriptionFilenamesCaseSensitive  false ;


    $usePaging  0 ;


    $directDirectoryLinks  false ;


    $thumbnailHeight  50 ;






    // INITIALISATION

    // make sure all the notices don't come up in some configurations
    error_reporting  ( E_ALL  E_NOTICE );

    $displayError  "" ;

    // safify all GET variables
    foreach( $_GET  AS  $key  =>  $value ) {
        
    $_GET [ $key ] =  strip_tags ( $value );
    }

    // first of all, security: prevent any unauthorized paths
    // if sub directories are forbidden, ignore any path setting
    if (! $allowSubDirs ) {
        
    $path  "" ;
    } else {
        
    $path  $_GET [ "path" ];
        
        
    // ignore any potentially malicious paths
        
    $path  safeDirectory ( $path );
    }

    // default sorting is by name
    if ( $_GET [ "sort" ]== ""
        
    $_GET [ "sort" ] =  "name" ;

    // default order is ascending
    if ( $_GET [ "order" ]== "" ) {
        
    $_GET [ "order" ] =  "asc" ;
    } else {
        
    $_GET [ "order" ] =  strtolower ( $_GET [ "order" ]);
    }
        
    // add files used by snif to hidden file list
    $hiddenFilesWildcards [] =  $useDescriptionsFrom ;
    $hiddenFilesWildcards [] =  "." ;
    $hiddenFilesWildcards [] =  basename ( $_SERVER [ "PHP_SELF" ]);

    // build hidden files regular expression
    for ( $i = 0 ; $i < count ( $hiddenFilesWildcards ); $i ++) {
        
    $translate  = Array(
            
    "."  =>  "\\." ,
            
    "*"  =>  ".*" ,
            
    "?"  =>  ".?" ,
            
    "+"  =>  "\\+" ,
            
    "["  =>  "\\[" ,
            
    "]"  =>  "\\]" ,
            
    "("  =>  "\\(" ,
            
    ")"  =>  "\\)" ,
            
    "{"  =>  "\\{" ,
            
    "}"  =>  "\\}" ,
            
    "^"  =>  "\\^" ,
            
    "\$"  =>  "\\\$" ,
            
    "\\"  =>  "\\\\" ,
        );
        
    $hiddenFilesRegex [] =  "^" . strtr ( $hiddenFilesWildcards [ $i ], $translate ). "$" ;
    }
    // hide .*
    $hiddenFilesRegex [] =  "^\\.[^.].*$" ;
    $hiddenFilesWholeRegex  "/" . join ( "|" , $hiddenFilesRegex ). "/i" ;


    // handle image requests
    if ( $_GET [ "getimage" ]!= "" ) {
        
    $imagesEncoded  = Array(
            
    "archive"   =>  "R0lGODlhEAAQAJECAAAAAP///////wAAACH5BAEAAAIALAAAAAAQABAAAAI3lA+pxxgfUhNKPRAbhimu2kXiRUGeFwIlN47qdlnuarokbG46nV937UO9gDMHsMLAcSYU0GJSAAA7" ,
            
    "asc"       =>  "R0lGODlhBQADAIABAN3d3f///yH5BAEAAAEALAAAAAAFAAMAAAIFTGAHuF0AOw==" ,
            
    "binary"    =>  "R0lGODlhEAAQAJECAAAAAP///////wAAACH5BAEAAAIALAAAAAAQABAAAAI0lICZxgYBY0DNyfhAfROrxoVQBo5mpzFih5bsFLoX5iLYWK6xyur5ubPAbhPZrKhSKCmCAgA7" ,
            
    "desc"      =>  "R0lGODlhBQADAIABAN3d3f///yH5BAEAAAEALAAAAAAFAAMAAAIFhB0XC1sAOw==" ,
            
    "folder"    =>  "R0lGODlhEAAQAJECAAAAAP///////wAAACH5BAEAAAIALAAAAAAQABAAAAIplI+JwKAJggzuiThl2wbnT3UgWHmjJp5Tqa5py7bhJc/mWW46Z/V+UgAAOw==" ,
            
    "html"      =>  "R0lGODlhEAAQAKIHABsb/2ho/4CA/0BA/zY2/wAAAP///////yH5BAEAAAcALAAAAAAQABAAAANEeFfcrVAVQ6thUdo6S57b9UBgSHmkyUWlMAzCmlKxAZ9s5Q5AjWqGwIAS8OVsNYJxJgDwXrHfQoVLEa7Y6+Wokjq+owQAOw==" ,
            
    "image"     =>  "R0lGODlhEAAQAKIEAK6urmRkZAAAAP///////wAAAAAAAAAAACH5BAEAAAQALAAAAAAQABAAAANCSCTcrVCJQetgUdo6RZ7b9UBgSHnkAKwscEZTy74pG9zuBavA7dOanu+H0gyGxN0RGdClKEjgwvKTlkzFhWOLISQAADs=" ,
            
    "text"      =>  "R0lGODlhEAAQAJECAAAAAP///////wAAACH5BAEAAAIALAAAAAAQABAAAAI0lICZxgYBY0DNyfhAfXcuxnWQBnoKMjXZ6qUlFroWLJHzGNtHnat87cOhRkGRbGc8npakAgA7" ,
            
    "download"  =>  "R0lGODlhBwAQAIABAAAAAP///yH5BAEAAAEALAAAAAAHABAAAAISjI+pywb6UkQzgHsPls3h2gUFADs=" ,
            
    "blank"     =>  "R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" ,
            
    "unknown"   =>  "R0lGODlhEAAQAJECAAAAAP///////wAAACH5BAEAAAIALAAAAAAQABAAAAI1lICZxgYBY0DNyfhAfXcuxnkI1nCjB2lgappld6qWdE4vFtprR+4sffv1ZjwdkSc7KJYUQQEAOw=="
        
    );
        
    $imageDataEnc  $imagesEncoded [ $_GET [ "getimage" ]];
        if (
    $imageDataEnc ) {
            
    $maxAge  31536000 // one year
            
    doConditionalGet ( $_GET [ "getimage" ],  gmmktime ( 1 , 0 , 0 , 1 , 1 , 2004 ));
            
    $imageDataRaw  base64_decode ( $imageDataEnc );
            
    Header ( "Content-Type: image/gif" );
            
    Header ( "Content-Length: " . strlen ( $imageDataRaw ));
            
    Header ( "Cache-Control: public, max-age= $maxAge , must-revalidate" );
            
    Header ( "Expires: " . createHTTPDate ( time ()+ $maxAge ));
            echo 
    $imageDataRaw ;
        }
        
        die();
    }


    // handle thumbnail creation
    if ( $_GET [ "thumbnail" ]!= "" ) {
        GLOBAL 
    $thumbnailHeight ;
        
        
    $file  safeDirectory ( $_GET [ "thumbnail" ]);
        
    doConditionalGet ( $_GET [ "thumbnail" ], filemtime ( $file ));
        
        
    $extension  strtolower ( substr ( strrchr ( $file "." ),  1 ));
        switch (
    $extension ) {
            case 
    "gif" :         $src  imagecreatefromgif ( $file ); break;
            case 
    "jpg" :         // fall through
            
    case  "jpeg" :     $src  imagecreatefromjpeg ( $file ); break;
            case 
    "png" :         $src  imagecreatefrompng ( $file ); break;
        }
        
    $srcWidth  imagesx ( $src );
        
    $srcHeight  imagesy ( $src );
        
    $srcAspectRatio  $srcWidth  $srcHeight ;
        
        if (
    $srcHeight <= $thumbnailHeight ) {
            
    $thumb  $src ;
        } else {
            
    $thumbHeight  $thumbnailHeight ;
            
    $thumbWidth  $thumbHeight  $srcAspectRatio ;
            if (
    function_exists ( 'imagecreatetruecolor' )) {
                
    $thumb  imagecreatetruecolor ( $thumbWidth $thumbHeight );
            } else {
                
    $thumb  imagecreate ( $thumbWidth $thumbHeight );
            } 
            
    imagecopyresampled ( $thumb $src 0 0 0 0 $thumbWidth $thumbHeight $srcWidth $srcHeight );
        }
        
        
    $maxAge  3600 // one hour
        
    Header ( "Content-Type: image/jpeg" );
        
    Header ( "Cache-Control: public, max-age= $maxAge , must-revalidate" );
        
    Header ( "Expires: " . createHTTPDate ( time ()+ $maxAge ));
        
    imagejpeg ( $thumb );
        die();
    }


    // handle download requests
    if ( $_GET [ "download" ]!= "" ) {
        
    $filename  safeDirectory ( $path . $_GET [ "download" ]);
        if (
            !
    file_exists ( $filename )
            OR 
    fileIsHidden ( $filename )
            OR (
    substr ( strtolower ( $filename ), - 4 )== ".php"  AND ! $allowPHPDownloads )) {
            
            
    Header ( "HTTP/1.0 404 Not Found" );
            
    $displayError  "File not found:  $filename " ;
        } else {
            
    doConditionalGet ( $filename filemtime ( $filename ));
            
    Header ( "Content-Length: " . filesize ( $filename ));
            
    Header ( "Content-Type: application/x-download" );
            
    Header ( "Content-Disposition: attachment; filename=" . $_GET [ "download" ]);
            
    readfile ( $filename );
            die();
        }
    }


    // create a HTTP conform date
    function  createHTTPDate ( $time ) {
        return 
    gmdate ( "D, d M Y H:i:s" $time ). " GMT" ;
    }


    // this function is from http://simon.incutio.com/archive/2003/04/23/conditionalGet
    function  doConditionalGet ( $file $timestamp ) {
        
    $last_modified  createHTTPDate ( $timestamp );
        
    $etag  '"' . md5 ( $file . $last_modified ). '"' ;
        
    // Send the headers
        
    Header ( "Last-Modified:  $last_modified " );
        
    Header ( "ETag:  $etag " );
        
    // See if the client has provided the required headers
        
    $if_modified_since  = isset( $_SERVER [ 'HTTP_IF_MODIFIED_SINCE' ]) ?
            
    stripslashes ( $_SERVER [ 'HTTP_IF_MODIFIED_SINCE' ]) :
            
    false ;
        
    $if_none_match  = isset( $_SERVER [ 'HTTP_IF_NONE_MATCH' ]) ?
            
    stripslashes ( $_SERVER [ 'HTTP_IF_NONE_MATCH' ]) : 
            
    false ;
        if (!
    $if_modified_since  && ! $if_none_match ) {
            return;
        }
        
    // At least one of the headers is there - check them
        
    if ( $if_none_match  &&  $if_none_match  !=  $etag ) {
            return; 
    // etag is there but doesn't match
        
    }
        if (
    $if_modified_since  &&  $if_modified_since  !=  $last_modified ) {
            return; 
    // if-modified-since is there but doesn't match
        
    }
        
    // Nothing has changed since their last request - serve a 304 and exit
        
    Header ( 'HTTP/1.0 304 Not Modified' );
        die();
    }


    function 
    safeDirectory ( $path ) {
        
    $result  $path ;
        if (
    strpos ( $path , ".." )!== false )
            
    $result  "" ;
        if (
    substr ( $path , 0 , 1 )== "/" ) {
            
    $result  "" ;
        }
        return 
    $result ;
    }



    function  niceSize ( $size ) {
        
    define ( "SIZESTEP" 1024.0 );
        static 
    $sizeUnits  = Array( "&nbsp;B" , "KB" , "MB" , "GB" , "TB" );
        
        if (
    $size === "" )
            return 
    "" ;
        
        
    $unitIndex  0 ;
        while (
    $size > SIZESTEP ) {
            
    $size  $size  SIZESTEP ;
            
    $unitIndex ++;
        }
        
        if (
    $unitIndex == 0 ) {
            return 
    number_format ( $size 0 ). "&nbsp;" . $sizeUnits [ $unitIndex ];
        } else {
            return 
    number_format ( $size 1 "." "," ). "&nbsp;" . $sizeUnits [ $unitIndex ];
        }
    }


    function  myCompare ( $arrA $arrB $caseSensitive = false ) {
        
    $a  $arrA [ $_GET [ "sort" ]];
        
    $b  $arrB [ $_GET [ "sort" ]];
        
        
    // sort directories above everything else
        
    if ( $arrA [ "isDirectory" ]!= $arrB [ "isDirectory" ]) {
            
    $result  $arrB [ "isDirectory" ]- $arrA [ "isDirectory" ];
        } else if (
    $arrA [ "isDirectory" ] &&  $arrB [ "isDirectory" ] && ( $_GET [ "sort" ]== "type"  ||  $_GET [ "sort" ]== "size" )) {
            
    $result  0 ;
        } else {
            if (
    is_string ( $a ) OR  is_string ( $b )) {
                if (!
    $caseSensitive ) {
                    
    $a  strtoupper ( $a );
                    
    $b  strtoupper ( $b );
                }
                
    $result  strcoll ( $a , $b );
            } else {
                
    $result  $a - $b ;
            }
        }
        
        if (
    strtolower ( $_GET [ "order" ])== "desc" ) {
            return -
    $result ;
        } else {
            return 
    $result ;
        }
    }



    function  myEncode ( $string ) {
        
    // % must be the first, as it is the escape character
        
    $from  = Array( "%" , " " , "#" , "&" );
        
    $to  = Array( "%25" , "%20" , "%23" , "%26" );
        return 
    str_replace ( $from $to $string );
    }



    function  getNewSortURL ( $newSort ) {
        GLOBAL 
    $path ;
        
    $base  $_SERVER [ "PHP_SELF" ];
        
    $url  $base . "?sort= $newSort " ;
        if (
    $newSort == $_GET [ "sort" ]) {
            if (
    $_GET [ "order" ]== "asc"  OR  $_GET [ "order" ]== "" ) {
                
    $url .=  "&amp;order=desc" ;
            }
        }
        if (
    $path != "" ) {
            
    $url .=  "&amp;path= $path " ;
        }
        return 
    $url ;
    }


    function  getFileType ( $extension $isDir ) {
        
    // put any additional extensions in here
        
    static  $fileTypes  = Array(
            
    "html"         => Array( "html" , "htm" ),
            
    "image"         => Array( "gif" , "jpg" , "jpeg" , "png" , "tif" , "tiff" , "bmp" , "art" ),
            
    "text"         => Array( "asp" , "c" , "cfg" , "cpp" , "css" , "csv" , "conf" , "cue" , "diz" , "h" , "inf" , "ini" , "java" , "js" , "log" , "nfo" , "php" , "phps" , "pl" , "rdf" , "rss" , "rtf" , "sql" , "txt" , "vbs" , "xml" ),
            
    "binary"     => Array( "asf" , "au" , "avi" , "bin" , "class" , "divx" , "doc" , "exe" , "mov" , "mpg" , "mpeg" , "mp3" , "ogg" , "ogm" , "pdf" , "ppt" , "ps" , "rm" , "swf" , "wmf" , "wmv" , "xls" ),
            
    "archive"     => Array( "ace" , "arc" , "bz2" , "cab" , "gz" , "lha" , "jar" , "rar" , "sit" , "tar" , "tbz2" , "tgz" , "z" , "zip" , "zoo" )
        );
        static 
    $extensions  null ;

        if (
    $extensions == null ) {
            
    $extensions  = Array();
            foreach(
    $fileTypes  AS  $keyType  =>  $value ) {
                foreach(
    $value  AS  $ext $extensions [ $ext ] =  $keyType ;
            }
        }

        if (
    $isDir )
            return 
    "folder" ;
        
        
    $type  $extensions [ strtolower ( $extension )];
        if (
    $type == "" ) {
            return 
    "unknown" ;
        } else {
            return 
    $type ;
        }
    }

    function 
    getIcon ( $fileType ) {
        GLOBAL 
    $useExternalImages $externalIcons ;
        if (
    $useExternalImages  &&  $externalIcons [ $fileType ]!= "" ) {
            return 
    $externalIcons [ $fileType ];
        } else {
            return 
    $_SERVER [ "PHP_SELF" ]. "?getimage= $fileType " ;
        }
    }

    // checks if a file is hidden from view
    function  fileIsHidden ( $filename ) {
        GLOBAL 
    $hiddenFilesWholeRegex ;
        return 
    preg_match ( $hiddenFilesWholeRegex , $filename );
    }


    function  getDescription ( $filename ) {
        GLOBAL 
    $descriptions $descriptionFilenamesCaseSensitive ;
        
        if (!
    $descriptionFilenamesCaseSensitive ) {
            
    $filename  strtolower ( $filename );
        }
        return 
    $descriptions [ $filename ];
    }

    function 
    getPageLink ( $startNumber $linkText $linkTitle = "" ) {
        GLOBAL 
    $snifServer $path ;
        
    $url  "http://" . $snifServer . $_SERVER [ "PHP_SELF" ]. "?path=" . $path . "&sort=" . $_GET [ "sort" ]. "&order=" . $_GET [ "order" ]. "&start=" . $startNumber ;
        if (
    $linkTitle != "" ) {
            
    $titleAttribute  " title=\" $linkTitle \"" ;
        } else {
            
    $titleAttribute  "" ;
        }
        return 
    "<a href=\" $url \" $titleAttribute > $linkText </a>&nbsp;" ;
    }

    function 
    getPagingHeader () {
        GLOBAL 
    $pageStart $usePaging $pagingNumberOfPages $pagingActualPage $pageNumber $files ;
        static 
    $displayPages  = Array();
        if (
    count ( $displayPages )== 0 ) {
            
    $displayPages [] =  0 ;
            for (
    $i = $pagingActualPage - 1 $i < $pagingActualPage + 3 $i ++) {
                if (
    $i >= &&  $i < $pagingNumberOfPages ) {
                    
    $displayPages [] =  $i ;
                }
            }
            
    $displayPages [] =  $pagingNumberOfPages - 1 ;
            
    $displayPages  array_unique ( $displayPages );
        }
        
        
    $header  "pages&nbsp;&nbsp;" ;
        if (
    $pageStart > 0 ) {
            
    $header .=  getPageLink ( $pageStart - $usePaging "&laquo;" "previous" );
        }
        if (
    $pageStart + $usePaging < count ( $files )) {
            
    $header .=  getPageLink ( $pageStart + $usePaging "&raquo;" "next" );
        }
        foreach(
    $displayPages  as  $i  =>  $pageNumber ) {
            if (
    $pageNumber - $displayPages [ $i - 1 ] >  1 ) {
                
    $header .=  ".. " ;
            }
            if (
    $pageNumber != $pagingActualPage ) {
                
    $header .=  getPageLink ( $pageNumber * $usePaging $pageNumber + 1 );
            } else {
                
    $header .=  "<span class=\"snWhite\">" .( $pageNumber + 1 ). "&nbsp;</span>" ;
            }
        }
        
        return 
    $header ;
    }

    function 
    getPathLink ( $directory ) {
        GLOBAL 
    $directDirectoryLinks ;
        if (
    $directDirectoryLinks ) {
            return 
    $directory . "/" ;
        } else {
            return 
    $_SERVER [ "PHP_SELF" ]. "?path=" . urlEncode ( $directory ). "/" ;
        }
    }



    // change directory
    // must be done before description file is parsed
    if ( $path != "" ) {
        if (!@
    chdir ( $path )) {
            
    $displayError  " $path  is not a subdirectory of the current directory." ;
            
    $path  "" ;
        }

    $dir  dir ( "." );

    // parsing description file
    $descriptions  = Array();
    if (
    $useDescriptionsFrom != "" ) {
        
    $descriptionsFile  = @ file ( $useDescriptionsFrom );
        if (
    $descriptionsFile !== false ) {
            for (
    $i = 0 ; $i < count ( $descriptionsFile ); $i ++) {
                
    $d  explode ( $separationString , $descriptionsFile [ $i ]);
                if (!
    $descriptionFilenamesCaseSensitive ) {
                    
    $d [ 0 ] =  strtolower ( $d [ 0 ]);
                }
                
    $descriptions [ $d [ 0 ]] =  join ( $separationString array_slice ( $d 1 ));
            }
        }
    }

    // build a two dimensional array containing the files in the chosen directory and their meta data
    $files  = Array();
    while(
    $entry  $dir -> read ()) {
        
    // if the filename matches one of the hidden files wildcards, skip the file
        
    if ( fileIsHidden ( $entry ))
            continue;
            
        
    // if the file is a directory and if directories are forbidden, skip it
        
    if (! $allowSubDirs  AND  is_dir ( $entry ))
            continue;
        
        
    $f  = Array();

        
    $f [ "name" ] =  $entry ;
        
    $f [ "isDownloadable" ] = ( substr ( strtolower ( $entry ), - 4 )!= ".php" ) ||  $allowPHPDownloads ;
        
    $f [ "isDirectory" ] =  is_dir ( $entry );
        
    $fDate  = @ filemtime ( $entry );
        
    $f [ "date" ] =  $fDate ;
        
    $f [ "fullDate" ] =  date ( "r" $fDate );
        
    $f [ "shortDate" ] =  date ( $snifDateFormat $fDate );
        
    $f [ "description" ] =  getDescription ( $entry );
        if (
    is_dir ( $entry )) {
            
    $f [ "type" ] =  "&lt;DIR&gt;" ;
            
    $f [ "size" ] =  "" ;
            
    $f [ "nicesize" ] =  "" ;
            
            
    // building the link
            
    if ( $entry == ".." ) {
                
    // strip the last directory from the path
                
    $pathArr  explode ( "/" , $path );
                
    $link  implode ( "/" , array_slice ( $pathArr , 0 , count ( $pathArr )- 2 ));
                
                
    // if there is no path set, don't add it to the link
                
    if ( $link == "" ) {
                    
    // we're already in $baseDir, so skip the file
                    
    if ( $path == "" )
                        continue;
                    
    $f [ "link" ] =  $_SERVER [ "PHP_SELF" ];
                } else {
                    
    $link .=  "/" ;
                    
    $f [ "link" ] =  $_SERVER [ "PHP_SELF" ]. "?path=" . urlEncode ( $link );
                }
            } else {
                
    $f [ "link" ] =  getPathLink ( $path . $entry );
            }
        } else {
            if (
    is_link ( $entry )) {
                
    $linkTarget  readlink ( $entry );
                
    $pi  pathinfo ( $linkTarget );
                
    $scriptDir  dirname ( $_SERVER [ "SCRIPT_FILENAME" ]);
                if (
    strpos ( $pi [ "dirname" ],  $scriptDir )=== 0 ) {
                    
    $f [ "type" ] =  "&lt;LINK&gt;" ;
                    
    // links have no date, so take the target's date
                    
    $f [ "date" ] =  filemtime ( $linkTarget );
                    
    $f [ "link" ] =  $path . urlencode ( substr ( $linkTarget strlen ( $scriptDir )+ 1 ));
                } else {
                    
    // link target is outside of script directory, so skip it
                    
    continue;
                }
            } else {
                
    $fSize  = @ filesize ( $entry );
                
    $f [ "size" ] =  $fSize ;
                
    $f [ "fullSize" ] =  number_format ( $fSize , 0 , "." , "," );
                
    $f [ "niceSize" ] =  nicesize ( $fSize );
                
    $pi  pathinfo ( $entry );
                
    $f [ "type" ] =  $pi [ "extension" ];
                
    $f [ "link" ] =  myEncode ( $path . $entry );
            }
        }
        
    $f [ "filetype" ] =  getFileType ( $f [ "type" ],  is_dir ( $entry ));
        
    $f [ "icon" ] =  getIcon ( $f [ "filetype" ]);
        if (
    $useAutoThumbnails  &&  $f [ "filetype" ]== "image" ) {
            
    $f [ "thumbnail" ] =  "<img src=\"" . $PHP_SELF . "?thumbnail=" . $path . $f [ "name" ]. "\"/>" ;
        }
        
    $files [] =  $f ;
    }

    usort ( $files "myCompare" );


    $pagingInEffect  $usePaging > &&  count ( $files )> $usePaging ;
    if (
    $usePaging > 0 ) {
        
    $pageStart  $_GET [ "start" ];
        if (
    $pageStart == ""  ||  $pageStart < ||  $pageStart > count ( $files ))
            
    $pageStart  0 ;
        
    $pagingActualPage  floor ( $pageStart  $usePaging );
        
    $pagingNumberOfPages  ceil ( count ( $files ) /  $usePaging );
    } else {
        
    $pageStart  0 ;
        
    $usePaging  count ( $files );
    }
    $pageEnd  min ( count ( $files ), $pageStart + $usePaging );


    $columns  4 ;
    if (
    $useDescriptionsFrom != "" )
        
    $columns ++;

    echo 
    "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" ;
    ?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <title>Index of <? echo  htmlentities ( dirname ( $_SERVER [ "PHP_SELF" ]). "/" . $path ); ?></title>
            <style type="text/css">
                .snif * {
                    font-family: Tahoma, Sans-Serif;
                    font-size: 10pt;
                }
                .snif img {
                    border:none;
                }
                .snif a {
                    text-decoration: none;
                }
                .snif a:hover {
                    text-decoration: underline;
                }
                body.snif {
                    background: #ffffff;
                }
                table.snif {
                    border: 1px solid #444444;
                }
                table.snif td {
                    padding-left: 10px;
                    padding-right: 10px;
                }
                td.snifDir {
                    font-weight: bold;
                    color: #ffffff;
                    background-color: #000000;
                    padding-top: 3px;
                    padding-bottom: 3px;
                }
                td.snifDir a {
                    color:white;
                }
                tr.snifHeading, td.snifHeading, td.snifHeading a {
                    font-weight: bold;
                    color: #dddddd;
                    background-color: #444444;
                    padding-top: 3px;
                    padding-bottom: 3px;
                }
                tr.snF td {
                    color: #444444;
                    padding-top: 2px;
                    padding-bottom: 2px;
                    vertical-align: top;
                    padding-left: 10px;
                    padding-right: 10px;
                    white-space:nowrap;
                }
                tr.snF td a {
                    color: #000000;
                }
                tr.snF td a:hover {
                    background-color: #bbbbee;
                }
                tr.snifEven {
                    background-color: #eeeeee;
                }
                tr.snifOdd {
                    background-color: #dddddd;
                }
                .snifCopyright * {
                    color: #bbbbbb;
                    font-size: 8pt;
                }
                .snifSmaller {
                    font-weight: normal;
                    font-size: 8pt;
                }
                .snWhite {
                    color: white;
                }
                .snW {
                    white-space:normal;
                }
            </style>
        </head>
    <body class="snif">
    <?
    if ( $displayError != "" ) {
        echo 
    "<b style=\"color:red\"> $displayError </b><br/><br/>" ;
    }
    ?>
    <table cellpadding="0" cellspacing="0" class="snif">
        <tr>
            <td class="snifDir" colspan="<? echo  $columns?>">
                <?
                $baseDirname 
    $snifServer . htmlentities ( dirname ( $_SERVER [ "PHP_SELF" ]));
                
    $pathToSnif  explode ( "/" , $baseDirname );
                echo 
    "http://" . join ( "/" , array_slice ( $pathToSnif 0 , - 1 )). "/" ;
                echo 
    "<a href=\"" . dirname ( $_SERVER [ "PHP_SELF" ]). "\">" . join ( "/" , array_slice ( $pathToSnif , - 1 )). "</a>" ;
                
    $pathArr  explode ( "/" , $path );
                for (
    $i = 0 $i < count ( $pathArr )- 1 $i ++) {
                    
    $dirLink  getPathLink ( join ( "/" , array_slice ( $pathArr 0 $i + 1 )));
                    echo 
    "/<a href=\" $dirLink \">" . $pathArr [ $i ]. "</a>" ;
                }
                
    ?><br/>
                <span class="snifSmaller"><? echo  $descriptions [ "." ]; ?></span>
            </td>
        </tr>
        <?
        
    if ( $pagingInEffect ) {
        
    ?>
        <tr class="snifHeading">
            <td class="snifHeading" colspan="<? echo  $columns?>">
                <?
                
    echo  getPagingHeader ();
                
    ?>
            </td>
        </tr>
        <?
        
    }
        
    ?>
        <tr class="snifHeading">
            <td class="snifHeading">
                <img src="<? echo  $PHP_SELF?>?getimage=blank" alt="" width="30" height="16" style="vertical-align:middle;"/><a href="<? echo  getNewSortURL ( "name" ); ?>">Name</a>
                <?
                $sort 
    $_GET [ "sort" ];
                if (
    $sort == "name" )
                    echo 
    "<img src=\"" . getIcon ( $_GET [ "order" ]). "\" width=\"5\" height=\"3\" style=\"vertical-align:middle;\" alt=\"" . $_GET [ "order" ]. "\"/>" ;
                
    ?>
            </td>
            <td class="snifHeading">
                <a href="<? echo  getNewSortURL ( "type" ); ?>">Typ</a>
                <?
                
    if ( $sort == "type" )
                    echo 
    "<img src=\"" . getIcon ( $_GET [ "order" ]). "\" width=\"5\" height=\"3\" style=\"vertical-align:middle;\" alt=\"" . $_GET [ "order" ]. "\"/>" ;
                
    ?>
            </td>
            <td class="snifHeading" align="right">
                <?
                
    if ( $sort == "size" )
                    echo 
    "<img src=\"" . getIcon ( $_GET [ "order" ]). "\" width=\"5\" height=\"3\" style=\"vertical-align:middle;\" alt=\"" . $_GET [ "order" ]. "\"/>" ;
                
    ?>
                <a href="<? echo  getNewSortURL ( "size" ); ?>">Grösse</a>
            </td>
            <td class="snifHeading">
                <a href="<? echo  getNewSortURL ( "date" ); ?>">Datum</a>
                <?
                
    if ( $sort == "date" )
                    echo 
    "<img src=\"" . getIcon ( $_GET [ "order" ]). "\" width=\"5\" height=\"3\" style=\"vertical-align:20%;\" alt=\"" . $_GET [ "order" ]. "\"/>" ;
                
    ?>
            </td>
            <?
            
    if ( $useDescriptionsFrom != "" ) {
            
    ?>
            <td class="snifHeading">Beschreibung</td>
            <?
            
    }
            
    ?>
        </tr>
        <?
        
    for ( $i = $pageStart ; $i < $pageEnd ; $i ++) {
        
    ?>
        <tr class="snF <? echo ( $i % 2 == 0 ) ?  "snifEven"  "snifOdd" ?>">
            <td><?
                
    if ( $files [ $i ][ "isDirectory" ] OR ! $files [ $i ][ "isDownloadable" ]) {
                
    ?><img src="<? echo  $PHP_SELF?>?getimage=blank" alt="" width="7" height="16" style="vertical-align:middle;"/>
                <?
                
    } else {
                
    ?><a href="<? echo  $PHP_SELF?>?path=<? echo  rawurlencode ( $path ) ?>&amp;download=<? echo  rawurlencode ( $files [ $i ][ "name" ]); ?>"><img src="<? echo  getIcon ( "download" ) ?>" alt="download" title="download" width="7" height="16" style="vertical-align:middle;"/></a>
                <?
                
    }
                
    ?><a href="<? echo  $files [ $i ][ "link" ]; ?>"><img src="<? echo  $files [ $i ][ "icon" ] ?>" alt="" title="<? echo  $files [ $i ][ "filetype" ] ?>" width="16" height="16" style="vertical-align:middle;"/>&nbsp;<? echo  htmlentities ( $files [ $i ][ "name" ]); ?>&nbsp;</a>
            </td>
            <td><? echo  $files [ $i ][ "type" ]; ?></td>
            <td align="right"><span title="<? echo  $files [ $i ][ "fullSize" ]; ?> Bytes"><? echo  $files [ $i ][ "niceSize" ]; ?></span></td>
            <td><span title="<? echo  $files [ $i ][ "fullDate" ]; ?>"><? echo  $files [ $i ][ "shortDate" ]; ?></span></td>
            <?
            
    if ( $useDescriptionsFrom != "" ) {
            
    ?><td class="snW"><? echo  $files [ $i ][ "description" ]; ?>
            <?
            
    if ( $files [ $i ][ "filetype" ]== "image" ) {
                
    ?>
                <img src="<? echo  $PHP_SELF?>?thumbnail=<? echo  $path . $files [ $i ][ "name" ] ?>" alt=""/>
                <?
            
    }
            
    ?></td><?
            
    }
            
    ?>
        </tr><?
        
    }
        if (
    $pagingInEffect ) {
        
    ?>
        <tr class="snifHeading">
            <td class="snifHeading" colspan="<? echo  $columns?>">
                <?
                
    echo  getPagingHeader ();
                
    ?>
            </td>
        </tr>
    <?
    }
    ?>
    </table>
    </body>
    </html>
     
  2. 8. Januar 2005
    Schön kommentiert (vorallem das english, aber ich denke das ist ok..)
    , gibts das auch als unkommentiert?
    den 50-100 kb's mehr stören einfach
     
  3. Video Script

    Videos zum Themenbereich

    * gefundene Videos auf YouTube, anhand der Überschrift.