denn wenn ich versuche es zu includen bekomme ich folgen fehler Meldungen "06-Apr-2005 11:10:05] PHP Warning: Unknown(http://xxx.xxxx.xxxxxx.de/abs.php): failed to open stream: HTTP request failed! HTTP/1.1 401 Authorization Required
in N:\www\xampp\htdocs\cms\front_content.php(563) : eval()'d code on line 133
[06-Apr-2005 11:10:05] PHP Warning: (null)(): Failed opening 'http://xxx.xxxx.xxxxxx.de/abs.php' for inclusion (include_path='.;N:\www\xampp\php\pear\') in N:\www\xampp\htdocs\cms\front_content.php(563) : eval()'d code on line 133
"
Code: Alles auswählen
<?php
$version = "2.7.1";
/*****************************************************************************\
 * myExplorer                                                                *
 * http://www.bmitt.com/files/webauthoring/php/                              *
 * ------------------------------------------------------------------------- *
 * written by      : Bernhard Mitterer @: admin@bmitt.com                    *
 * last modified   : 2004-11-25                                              *
 *****************************************************************************
 CHANGES:
    2.2
        - support for special chars in path and filenames
    2.3
        - fixed problem with special chars (htmlentities)
        - validates against XHTML 1.0
        - validates against CSS 2
    2.4
        - added possibility to print statistics
          (filecount, dircount, total filesize )
    2.5
        - different icons for filetypes
        - AAA Bobby Approved
    2.6
        - fixed problem with urlcoding (special chars again)
        - added possibility to handle files depending on their extension
    2.7
        - redesign of code to support userdefined sorting
        - significant performance enhancements
        - ability to benchmark the script
 USAGE:
    1. adapt the Configuration-Section to your needs
    2. thats it!
 CONFIGURATION:
     bool $su (= false)
        su stands for SuperUser and enables
           - relative paths upwards ('../') and
           - going above $rootDir
     string $rootDir (= '')
        use this attribute to specify the root-directory
        of myExplorer relative to this file (the one you
        are reading). it is not possible to view
        directories above $rootDir.
        eg. $rootDir = 'files';
     string $indexDir (= '')
        use this attribute to specify the directory
        (relativ to $rootDir) which myExplorer should
        show when opening this page.
        if you want myExplorer to start in "files/mp3"
        and $rootDir is set to "files" you should set
        $indexDir to 'mp3'.
        if you want myExplorer to start in $rootDir
        you do not have to set this attribute
     string $imgDir (= 'img')
        this attribute specifies the path to the icon-files
        ($imgDir is prepended to the filenames specified in
        $filetypes, $picUp and $picFolder)
     string $referer (= $_SERVER['PHP_SELF'])
        this attibute specifies the url to this page.
        you only will have to set this attribute if
        you have already query-strings in this url
        eg. $referer = 'index.php?pageID=234'
     bool $printCwd (= true)
        this attribute specifies if the current directory
        should be shown (above the table)
     bool $printStat (= true)
        this attribute specifies if filecount, dircount
        and total filesize should be shown (at the bottom
        of the table)
     bool $benchmark (= false)
        this attribute specifies if the processing time of
        the script is measured an printed at the bottom
        
     string $hPic     (= ' ')
     string $hName    (= 'Name')
     string $hSize    (= 'Size')
     string $hType    (= 'Type')
     string $hLastMod (= 'Last Modified')
        these attributes specify the column-headers
        of the table
     bool $showPic     (= true)
     bool $showSize    (= true)
     bool $showType    (= false)
     bool $showLastMod (= true)
        these attributes specify which columns to show
     string $showFiles   (= '*')
     string $hideFiles   (= '.*,index*,*.php')
     string $showFolders (= '*')
     string $hideFolders (= '.*,img')
        specify which files/folders should be shown
        default is 'implicit show'.
        * (asterisk) is the only wildcard allowed and
                     stands for "at least one charakter"
     bool $fastSort (= false)
        true:  the directory content is ALWAYS sorted
               ascending by filename. This option allows
               faster sorting for large directory listings
        false: sorts depending on the choosen column
     string $sortC (= 'N')
        defines default sort-column
          N: names of files/folders
          S: size of files/folders
          M: last modified of files/folders
     string $sortO (= 'A')
        defines default sort-order
          A: ascending
          D: descending
     bool $showSortPic (= true)
        true:  image showing sort direction is shown
               next to the column name
        false: no sort direction is shown
     string $sortPicAsc    (= 'sortasc.gif')
     string $sortPicDesc   (= 'sortdesc.gif')
        define image names for sort direction
     string $picUp     (= 'folderup.gif')
     string $picFolder (= 'folder.gif')
        these attributes specify the names of the folder-icons
     bool $picFile   (= 'true')
        true:  enables different icons for different filetypes
               icons are specified in $picIcons
        false: shows the default icon ( $filetypes['.*'] )
     int $xAction (= false)
     string $xFilename (= 'dofile.php')
        if this attrib $xAction = false you can ignore the
        attrib $xFilename. if you want to do something
        special when clicking on a file, set $xAction = true
        the script specified in $xFilename gets the
        path and filename of the selected file in the
        variable $_GET['file']
     array $filetypes
        each line has the following format:
        '<extension>,<tab><iconfile>,<tab><description>,<tab><xAction>,<tab><xFilename>',
        <extension>   is the filename extension including the point
        <iconfile>    is the name of the icon-file related with <extension>
        <description> filetype description shown when $showType = true
        <xAction>     if true the filename is given by Method GET to the
                      php-script specified in ...
        <xFilename>.
        - each line has to be bordered by single quotes (')
        - each line has to be terminated by a comma (,)
        - a comma has to separate the fields
        Defaults:
            description, xaction and xfilename are OPTIONAL
            if empty the following values are assumed
            <description> = <ext>-File  (eg. TXT-File)
            <xaction>     = $xAction
            <xfilename>   = $xFilename
\*****************************************************************************/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de-at" lang="de-at">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <meta http-equiv="Content-Style-Type" content="text/css" />
  <meta http-equiv="Content-Language" content="de-at" />
  <meta http-equiv="expires" content="0" />
  <meta name="author" content="Bernhard Mitterer" />
  <title>BMITT.com - myExplorer</title>
  <style type="text/css">
  <!--
    table.expl { border-width:2px; width:100%;
        font-family:Verdana,Arial; font-size:12px; }
    table.expl a { color:black; text-decoration:none; }
    table.expl a img { border-width:0px; }
    table.expl a:hover { text-decoration:underline; }
    tr.path td { padding:2px; font-weight:bold; font-size:80%;
        border-style:solid; border-width:1px; border-color:#BBBBBB; }
    tr.stats td { padding:2px; padding-top:10px;
        font-weight:bold; font-size:80%; text-align:right; }
    tr.vspace td { font-size:50%; }
    tr.hExpl { background-color:#888888; color:#FFFFFF; }
    tr.hExpl td { padding:1px; text-transform:uppercase; color:#FFFFFF;
        font-family:Arial,Helvetica,sans-serif; font-weight:bold; font-size:11px; }
    tr.hExpl a { color:white; text-decoration:none; }
    tr.hExpl a:hover { color:yellow; text-decoration:none; }
    tr.hExpl td a img { margin:-1px 2px -1px 2px; }
    tr.folder { ; }
    tr.file { ; }
    td.pic, td.hPic { width:20px; }
    td.name, td.hName { ; }
    td.lastmod, td.hLastMod { width:120px; }
    td.size, td.hSize { width:120px; }
    td.type, td.hType { width:160px; }
    td.hPic { ; }
    td.hName { ; }
    td.hSize { text-align:right; }
    td.hType { ; }
    td.hLastMod { ; }
    td.pic { ; }
    td.name { ; }
    td.size { text-align:right; }
    td.type { ; }
    td.lastmod { ; }
    em { font-style:normal; font-weight:bold; }
    td.pic img { width:20px; height:16px; border-width:0px; display:block; }
    p.benchmark { font-family:Verdana,Arial; font-size:10px; margin:5px; }
  -->
  </style>
</head>
<body>
<?php
/*****************************************************************************\
 * Configuration (adapt this section to your needs)                          *
\*****************************************************************************/
$su            = false;
# paths
$rootDir       = '';
$indexDir      = '';
$imgDir        = 'img';
$referer       = $_SERVER['PHP_SELF'];
# appearance
$printCwd      = true;
$printStat     = true;
$benchmark     = false;
# labels for tableheader
$hPic          = ' ';
$hName         = 'Name';
$hSize         = 'Size';
$hType         = 'Type';
$hLastMod      = 'Last Modified';
# show attributes
$showPic       = true;
$showName      = true;    # makes no sense to hide filename
$showSize      = true;
$showType      = false;
$showLastMod   = true;
# filter
$showFiles     = '*';
$hideFiles     = '.*,index*,*.php';
$showFolders   = '*';
$hideFolders   = '.*,img';
# sort options
$fastSort      = false;
$sortC         = 'N';
$sortO         = 'A';
$showSortPic   = true;
$sortPicAsc    = 'sortasc.gif';
$sortPicDesc   = 'sortdesc.gif';
# pic-names
$picUp         = 'folderup.gif';
$picFolder     = 'folder.gif';
$picFile       = true;
# mode
$xAction       = false;
$xFilename     = 'dofile.php';
# filetypes
$filetypes     = array(
#   Extension   Icon (Pic)      Description (Type)      xAction     xFilename
#   ----------------------------------------------------------------------------------
#   '.ext',     extfile.gif,    EXT-File,               1,          download.php',      <-- EXAMPLE
    '.*,        file.gif,       Unknown',
    '.bz2,      rarfile.gif,    BZ2 Archive',
    '.c,        cfile.gif,      C Sourcefile',
    '.chm,      chmfile.gif,    Windows Helpfile',
    '.cpp,      cppfile.gif,    C++ Sourcefile',
    '.doc,      docfile.gif,    Word Document',
    '.exe,      exefile.gif,    Executable',
    '.h,        hfile.gif,      C/C++ Headerfile',
    '.htm,      htmfile.gif,    HTML Document',
    '.html,     htmfile.gif,    HTML Document',
    '.gif,      imgfile.gif,    GIF Image',
    '.gz,       zipfile.gif,    GZ Archive',
    '.jpg,      imgfile.gif,    JPG Image',
    '.js,       jsfile.gif,     JavaScript File',
    '.m,        mfile.gif,      Matlab File',
    '.mp3,      mpgfile.gif,    MP3 Audiofile',
    '.mpg,      mpgfile.gif,    MPG Videofile',
    '.pdf,      pdffile.gif,    PDF Document',
    '.png,      imgfile.gif,    PNG Image',
    '.pps,      pptfile.gif,    PowerPoint Show',
    '.ppt,      pptfile.gif,    PowerPoint File',
    '.rar,      rarfile.gif,    RAR Archive',
    '.swf,      swffile.gif,    Flash Object',
    '.txt,      txtfile.gif,    Textfile',
    '.xls,      xlsfile.gif,    Excel Chart',
    '.zip,      zipfile.gif,    ZIP Archive',
);
/*****************************************************************************\
 * prepare variables                                                         *
\*****************************************************************************/
// Benchmark START
if( $benchmark )
    $time_start = getmicrotime();
// Check Path Formats ---------------------------------------------------------
$rootDir    = formatDir($rootDir,true,true);
$indexDir   = formatDir($indexDir);
$referer    = addLinker($referer);
$imgDir     = formatDir($imgDir,true);
// ----------------------------------------------------------------------------
// Create Filetype Array ------------------------------------------------------
$filetypes = parseFiletypeConfig( $filetypes );
// ----------------------------------------------------------------------------
// Handle (given) Directory ---------------------------------------------------
# initialize
$dir = $indexDir;
# make lokal variable from HTTP_GET_VARS
if(isset($_GET['dir']))
    $dir = formatDir(rawParam('dir'));
# check given directory if it is valid/allowed
if( !isValidDir("$rootDir$dir") )
    $dir = $indexDir;
# real path ($dir is just fake [relative to $rootDir] for display)
$ldir = formatDir("$rootDir$dir",true);
// ----------------------------------------------------------------------------
// Get Directory Content ------------------------------------------------------
$files = array();
$folders = array();
# unfiltered directory content
getDirContent( $ldir );
# filter arrays
$files = filterArray( $files, $showFiles, $hideFiles );
$folders = filterArray( $folders, $showFolders, '.,..,'.$hideFolders );
# sort only by name
if( $fastSort ) {
    natcasesort( $files );
    natcasesort( $folders );
}
# get file properties
$files   = getFileAttr( $files );
$folders = getFolderAttr( $folders );
// ----------------------------------------------------------------------------
// Sort Directory Content -----------------------------------------------------
# parse sort criteria
if    ( $fastSort )         { $C = 'N'; $O = 'A';       }
#elseif( isset($_GET['D']) ) { $C = 'D'; $O = $_GET[$C]; }
elseif( isset($_GET['M']) ) { $C = 'M'; $O = $_GET[$C]; }
elseif( isset($_GET['S']) ) { $C = 'S'; $O = $_GET[$C]; }
elseif( isset($_GET['N']) ) { $C = 'N'; $O = $_GET[$C]; }
else                        { $C = $sortC; $O = $sortO; }
# sort
if( !$fastSort ) {
    usort( $files, 'cmp' );
    usort( $folders, 'cmp' );
}
# get new order of columns (array)
$neworder = newOrder( $C, $O );
# get sort pic
$sortpic = array();
if( $showSortPic ) {
    $img = ($O=='D') ? $sortPicAsc : $sortPicDesc;
    $sortpic[$C] = '<img src="'.$imgDir.$img.'" alt="" />';
}
// ----------------------------------------------------------------------------
/*****************************************************************************\
 * Output (print table)                                                      *
\*****************************************************************************/
echo '<table cellspacing="3" class="expl" summary="Content of /'.htmlentities($dir).'">',"\n";
// print current directory ----------------------------------------------------
if($printCwd)
{
    echo '  <tr class="path">',"\n";
    echo '    <td colspan="'.($showPic+$showName+$showSize+$showType+$showLastMod).'"><em>/'.htmlentities($dir).'</em></td>',"\n";
    echo '  </tr>',"\n";
}
// ----------------------------------------------------------------------------
// draw tableheader -----------------------------------------------------------
echo '  <tr class="hExpl">',"\n";
if($showPic)
    echo '    <td class="hPic"> '.$hPic.' </td>',"\n";
#if($showName)      // makes no sense to hide filename
    echo '    <td class="hName"><a href="'.$referer.'N='.$neworder['N'].'&dir='.$dir.'"> '.$hName.' '.$sortpic['N'].'</a></td>',"\n";
if($showSize)
    echo '    <td class="hSize"><a href="'.$referer.'S='.$neworder['S'].'&dir='.$dir.'">'.$sortpic['S'].' '.$hSize.' </a></td>',"\n";
if($showLastMod)
    echo '    <td class="hLastMod"><a href="'.$referer.'M='.$neworder['M'].'&dir='.$dir.'"> '.$hLastMod.' '.$sortpic['M'].'</a></td>',"\n";
if($showType)
    echo '    <td class="hType"><a href="'.$referer.'M='.$neworder['D'].'&dir='.$dir.'"> '.$hType.' '.$sortpic['D'].'</a></td>',"\n";
echo '  </tr>',"\n";
// ----------------------------------------------------------------------------
// handle up-button -----------------------------------------------------------
if( $su && (!$dir || (substr($dir,-2)=='..')) )
    $up = formatDir($dir,true).'..';
else
    $up = substr($dir,0,strrpos($dir,'/'));
if( $su || ($dir && ($up!==false)) )
{
    $target = $referer.$C.'='.$O.'&dir='.$up;
    
    echo '  <tr class="folder">',"\n";
    if($showPic)
        echo '    <td class="pic"><a href="'.$target.'&dir='.$up.'"><img src="'.$imgDir.$picUp.'" alt="up" /></a></td>',"\n";
#    if($showName)      // makes no sense to hide filename
        echo '    <td class="name"><a href="'.$target.'"><em>..</em></a></td>',"\n";
    if($showSize)
        echo '    <td class="size"> - </td>',"\n";
    if($showLastMod)
        echo '    <td class="lastmod"> - </td>',"\n";
    if($showType)
        echo '    <td class="type"> Up </td>',"\n";
    echo '  </tr>',"\n";
}
// ----------------------------------------------------------------------------
// print directories ----------------------------------------------------------
$fdir = formatDir($dir,true);
foreach ($folders as $folder)
{
    $target = $referer.$C.'='.$O.'&dir='.rawurlencode($fdir.$folder['name']);
    echo '  <tr class="folder">',"\n";
    if($showPic)
        echo '    <td class="pic"><a href="'.$target.'"><img src="'.$imgDir.$picFolder.'" alt="dir" /></a></td>',"\n";
#    if($showName)      // makes no sense to hide filename
        echo '    <td class="name"><a href="'.$target.'"><em>'.htmlentities($folder['name']).'</em></a></td>',"\n";
    if($showSize)
        echo '    <td class="size"> - </td>',"\n";
    if($showLastMod)
        echo '    <td class="lastmod"> '.date('Y-m-d',$folder['lmod']).' </td>',"\n";
    if($showType)
        echo '    <td class="type"> File Folder </td>',"\n";
    echo '  </tr>',"\n";
}
// ----------------------------------------------------------------------------
// print files ----------------------------------------------------------------
$dirsize = 0;
foreach ($files as $file)
{
    $target = getTarget("$ldir$file[name]");
    $dirsize += $file['size'];              // total filesize in current dir
    $size = ceil($file['size']/1024);       // convert from byte to kilobyte
    $size = "$size KB";                     // add unit
    echo '  <tr class="file">',"\n";
    if($showPic)
        echo '    <td class="pic"><a href="'.$target.'"><img src="'.$imgDir.getIcon($file['name']).'" alt="file" /></a></td>',"\n";
#    if($showName)      // makes no sense to hide filename
        echo '    <td class="name"><a href="'.$target.'">'.htmlentities($file['name']).'</a></td>',"\n";
    if($showSize)
        echo '    <td class="size"> '.$size.' </td>',"\n";
    if($showLastMod)
        echo '    <td class="lastmod"> '.date('Y-m-d',$file['lmod']).' </td>',"\n";
    if($showType)
        echo '    <td class="type"> '.$file['desc'].' </td>',"\n";
    echo '  </tr>',"\n";
}
// ----------------------------------------------------------------------------
// print statistics -----------------------------------------------------------
if($printStat)
{
    echo '  <tr class="stats">',"\n";
    echo '    <td colspan="'.($showPic+$showName+$showSize+$showType+$showLastMod).'"> <em>'.count($folders).' directories | '.count($files).' file(s) | '.ceil($dirsize/1024).' kByte total</em> </td>',"\n";
    echo '  </tr>',"\n";
}
// ----------------------------------------------------------------------------
echo '</table>',"\n";
/*****************************************************************************\
 * Functions                                                                 *
\*****************************************************************************/
// ----------------------------------------------------------------------------
// getDirContent() fills, filter and sort Arrays of files and folders
function getDirContent($dir)
{
    global $files, $folders;
    # fill arrays
    $handle = @opendir($dir);
    while( $file = readdir($handle) ) {
        if( is_dir("$dir/$file") )
            $folders[] = $file;
        elseif( is_file("$dir/$file") )
            $files[] = $file;
    }
    @closedir($handle);
}
// ----------------------------------------------------------------------------
// addLinker()    adds '?' or '&' to the referer
function addLinker($referer)
{
    // assume that last char is not '?' or '&'
    return strchr($referer,'?') ? "$referer&" : "$referer?";
}
// ----------------------------------------------------------------------------
// formatDir()    skip trailing and leading "/" in given $dir-string
//                add
function formatDir($dir, $trailing=false, $leading=false)
{
    $dir = trim($dir,' /');
    if( $trailing && $dir )
        $dir = "$dir/";
    if( $leading ) #&& ($dir[0]!='/') )
        $dir = "./$dir";
    return $dir;
}
// ----------------------------------------------------------------------------
// filterArray()   make regular expression from $filter-string
function filterArray( $arr, $allow, $hide )
{
    $allow = makeRegex($allow);
    $hide  = makeRegex($hide);
    // preg_grep is available since PHP 4.2.0
#    $tmp = preg_grep( "/$allow/", $arr );
#    $tmp = preg_grep( "/$hide/",  $tmp, PREG_GREP_INVERT );
    // for PHP < 4.2.0
    $tmp = array();
    foreach( $arr as $val )
        if( preg_match("/$allow/",$val) && !preg_match("/$hide/",$val) )
            $tmp[] = $val;
    return $tmp;
}
// ----------------------------------------------------------------------------
// makeRegex()   make regular expression from $filter-string
function makeRegex( $filter )
{
    $regex = str_replace('.', '\.', $filter);
    $regex = str_replace('/', '\/', $regex);
    $regex = str_replace('*', '.+', $regex);
    $regex = str_replace(',', '$|^', $regex);
    return "^$regex$";
}
// ----------------------------------------------------------------------------
// isValidDir()   return true if directory is valid/allowed
function isValidDir($dir)
{
    global $su;
    $strErr  = "<p>Requested Directory Not Found</p>\n";
    $strErr .= "\n</body>\n</html>";    #close open tags
    // check if folder exists (when manipulated manually)
    is_dir($dir) or die($strErr);
    // prevent cd with relative path '../'
    return $su ? true : !(strpos($dir,'..')!==false);
}
// ----------------------------------------------------------------------------
// rawParam()
function rawParam( $param )
{
    return ini_get('magic_quotes_gpc') ? stripslashes($_GET[$param]) : $_GET[$param];
}
// ----------------------------------------------------------------------------
// getAttributes()   returns array with fileproperties
//                   (name, size, lastmod and desc)
function getFileAttr( $obj )
{
    global $ldir;
    $tmp = array();
    foreach( $obj as $file ) {
        $tmp[] = array(
            'name' => $file,
            'size' => filesize("$ldir$file"),    // get 'size of file' in bytes
            'lmod' => filemtime("$ldir$file"),   // get 'last modified date'
            'desc' => getDesc("$file")           // get 'file description'
        );
    }
    return $tmp;
}
// ----------------------------------------------------------------------------
// getFolderAttributes()   returns array with fileproperties (name, size and lastmod)
function getFolderAttr( $obj )
{
    global $ldir;
    $tmp = array();
    foreach( $obj as $folder ) {
        $tmp[] = array(
            'name' => $folder,
            'lmod' => filemtime("$ldir$folder"),   // get 'last modified date'
        );
    }
    return $tmp;
}
// ----------------------------------------------------------------------------
// compare()
function cmp($a, $b) {
    global $C, $O;
    $sortKey   = array( 'N'=>'name', 'S'=>'size', 'M'=>'lmod', 'D'=>'desc' );
    $sortOrder = array( 'A'=> 1, 'D'=> -1 );
    // sort by main criteria ($C)
    $ret = $sortOrder[$O] * strnatcasecmp($a[$sortKey[$C]], $b[$sortKey[$C]]);
    // sort equal values by filename
    if( $ret == 0 && $C != 'N' )
        $ret = $sortOrder[$O] * strnatcasecmp($a[$sortKey['N']], $b[$sortKey['N']]);
    return $ret;
}
// ----------------------------------------------------------------------------
// parseFiletypeConfig()   returns 2-dim array from given config-array
function parseFiletypeConfig( $picIcons )
{
    global $xAction, $xFilename;
    foreach( $picIcons as $type ) {
        $tmp = spliti( '[[:blank:]]*,[[:blank:]]*', $type );
        if( $tmp[4]=='' ) $tmp[4] = $xFilename;
        if( $tmp[3]=='' ) $tmp[3] = $xAction;
        $ret[$tmp[0]] = array(
            'icon' => $tmp[1],
            'desc' => $tmp[2],
            'xact' => $tmp[3],
            'xfn'  => $tmp[4]
        );
    }
    return $ret;
}
// ----------------------------------------------------------------------------
// newOrder()   return order of $col for the next klick
function newOrder( $C, $O )
{
    global $imgDir;
    
    $tmp = array(
        'N' => 'A',
        'S' => 'A',
        'M' => 'A',
        'D' => 'A'
    );
    // reverse order of current column
    $tmp[$C] = ($O=='D') ? 'A' : 'D';
    
    return $tmp;
}
// ----------------------------------------------------------------------------
// getTarget()   return target of click
function getTarget( $filename )
{
    global $filetypes;
    // extract filename extension
    $ext = strtolower( strrchr( $filename, '.' ) );
    // handle unknown extensions
    if( !array_key_exists($ext,$filetypes) )
        $ext = '.*';
    // format/encode url
    $filename = str_replace('%2F', '/', rawurlencode($filename));
    // return matching target
    return $filetypes[$ext]['xact'] ? $filetypes[$ext]['xfn']."?file=$filename" : $filename;
}
// ----------------------------------------------------------------------------
// getIcon()   return icon-image based on filename extension
function getIcon( $filename )
{
    global $filetypes, $picFile;
    // extract filename extension
    $ext = strtolower( strrchr( $filename, '.' ) );
    // return default image if $picFile = false or extension is unknown
    if( !$picFile || !array_key_exists($ext,$filetypes) )
        return $filetypes['.*']['icon'];
    // return matching image
    return $filetypes[$ext]['icon'];
}
// ----------------------------------------------------------------------------
// getDesc()   return type-description based on filename extension
function getDesc( $filename )
{
    global $filetypes;
    // extract filename extension
    $ext = strtolower( strrchr( $filename, '.' ) );
    // handle files without extension
    if( !$ext )
        return 'unknown';
    // return default description if extension is unknown
    if( !$filetypes[$ext]['desc'] )
        return substr(strtoupper($ext),1).'-File';
    // return matching description
    return $filetypes[$ext]['desc'];
}
// ----------------------------------------------------------------------------
// getmicrotime()   return float value of unix timestamp in seconds
function getmicrotime()
{
   list($usec, $sec) = explode(" ",microtime());
   return ((float)$usec + (float)$sec);
}
// Benchmark END
if( $benchmark )
    printf("<p class=\"benchmark\">processing time: %.3f seconds</p>", getmicrotime()-$time_start);
?>
</body>
</html>
Code: Alles auswählen