index.php

Go to the documentation of this file.
00001 <?php 
00002 /***************************************************************************
00003 
00004 snif 1.5.2
00005 "snif is not an index file"
00006 "simple and nice index file"
00007 (c) Kai Blankenhorn
00008 www.bitfolge.de
00009 kaib@bitfolge.de
00010 
00011 
00012 THIS IS THE REAL SNIF INDEX.PHP FILE.
00013 
00014 
00015 This program is free software; you can redistribute it and/or
00016 modify it under the terms of the GNU General Public License
00017 as published by the Free Software Foundation; either version 2
00018 of the License, or (at your option) any later version.
00019 
00020 This program is distributed in the hope that it will be useful,
00021 but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 GNU General Public License for more details: <http://www.gnu.org/licenses/gpl.txt>
00024 
00025 ****************************************************************************
00026 
00027         +------------------------------------------------------------------------+
00028         | TRANSLATIONS:                                                          |
00029         +------------------------------------------------------------------------+
00030         | If you'd like to translate snif into your language, have a look at     |
00031         | the $languageStrings variable at the end of the advanced settings, add |
00032         | your language and send me the PHP snippet containing your translation. |
00033         +------------------------------------------------------------------------+
00034         
00035 To do:
00036 Make download icon bigger?
00037 pdf and ppt and xls should have own icons as well not just listed as binary
00038 
00039 
00040 Changelog:
00041 
00042 v1.5.2  10-11-04
00043         added a Czech translation (thanks to Jan Pinkas)
00044         added an Italian translation (thanks to Luca Soltoggio)
00045         fixed an XHTML glitch in thumbnail tags
00046 
00047 v1.5.1   07-18-04
00048         fixed XHTML validity
00049         fixed back link not displayed
00050 
00051 v1.5     07-18-04
00052         added color configuration using an external stylesheet file
00053         added central configuration file for multiple installations of snif on one server
00054         added a Brazilian-Portuguese translation (thanks to Caio Begotti)
00055         added a Greek translation (thanks to George Yiftoyiannis)
00056         added a Spanish translation (thanks to Martinp and Genaro Paez)
00057         tweaked the file extensions
00058         fixed some problems with access rights for thumbnail files and directory
00059         fixed line-break issues in long descriptions
00060         fixed a strange unicode bug that could cause broken images in Mozilla
00061         fixed a bug with pictures and directories with special characters
00062         fixed a download bug (download link was broken sometimes)
00063         improved display for files with both thumbnail and description
00064 
00065 v1.4.8  06-24-04
00066         added a Japanese translation (thanks to hjbdnpmo)
00067         added a Danish translation (thanks to Svend Rugaard)
00068         improved fail-safe behaviour when creating the .snifthumbs directory has failed
00069         improved backwards compatibility with default date format
00070 
00071 v1.4.7  06-21-04
00072         fixed multiple problems with special characters in file and path names
00073         fixed a bug with downloading files with spaces or quotes in their names (thanks to Derick Ng)
00074         added a maximum thumbnail width (thanks to Nasim)
00075 
00076 v1.4.6  06-18-04
00077         thumbnails now link to the original image file
00078         added a Russian translation (thanks to Neptune)
00079         added a Hungarian translation (thanks to Gabor Funk)
00080         added a French translation (thanks to Marc Nadeau)
00081 
00082 v1.4.5  06-14-04
00083         added server-side thumbnail caching (needs some testing, but it seems to work well)
00084         all columns (including filetype icon) can now be hidden and reordered
00085         added an optional CVS version column (thanks to Holger "Holgi" Szillat)
00086         added a Dutch translation (thanks to Rogier van Epen)
00087         added a Norwegian translation (thanks to Kyrre Liaaen)
00088         added a Polish translation (thanks to Slawomir Jucht)
00089         added a Swedish translation (thanks to Elias Hedberg)
00090         improved translation instructions
00091         fixed some strings that were not translatable
00092         added an option to always use a specific translation
00093         fixed preview of animated GIFs
00094         added an option to hide all directories containing a .htaccess file, no matter its contents
00095         fixed default settings, forgot to reset my debug settings :-/
00096 
00097 v1.4    05-04-04
00098         easy translation system (language is selected automatically depending on the
00099                 user's browser's language setting)
00100         added a German translation
00101         option to reorder and hide columns
00102         option to display "[ back ]" instead of ".."
00103         option to always use the full width of the screen
00104         special icon for the .. link
00105         improved directory sorting: .. now always on first position
00106         truncation of long file names (and an option for it)
00107         added number of files contained in subdirectories
00108         improved error messages
00109         fixed possible bug with hidden files
00110         fixed a bug with descriptions containing non-ASCII characters
00111         thanks to Rogier van Epen for the comments
00112 
00113 v1.3.2  01-19-04
00114         improved HTTP cacheability of icons, thumbnails and downloads, major speedup!
00115         added directory navigation in the header
00116         added a thumbnail size setting
00117         different index files in subdirectories are now possible
00118 
00119 v1.3.1  01-14-04
00120         added splitting directories on multiple pages
00121         fixed some bugs with file links
00122         better support for international file names
00123         restored compatibility with older PHP versions (< 4.2.0, thank to Glen Solsberry)
00124 
00125 v1.3    01-05-04
00126         added automatic thumbnails for images (optional, requires GDlib 2)
00127         added an option for case insensitive description assignment
00128         added XHTML 1.1 and CSS 2.0 conformance
00129         fixed a sorting bug
00130         once more fixed special characters in file names
00131         reduced resulting HTML size (15-20% smaller for large directories)
00132 
00133 v1.2.9  12-20-03
00134         stupid date format bug fixed
00135         fixed download of files with special characters in their name
00136         code cleanup
00137 
00138 v1.2.8  12-13-03
00139         settings have been split in basic and advanced settings
00140         added configurable server name instead of what PHP detects (thanks to Paul Munn)
00141         added configurable date and time format (thanks to Paul Munn)
00142         improved default hidden file wildcards, now also hides emacs temp files (thanks to Paul Munn)
00143         notices are now always suppressed
00144         fixed various HTML and CSS glitches (thanks to Paul Munn)
00145         fixed a bug which caused the sorting arrow not to be displayed (thanks to Paul Munn)
00146         renamed and reorganized stylesheets (thanks to Paul Munn)
00147 
00148 v1.2.7  12-09-03
00149         cross site scripting bug fixed (thanks to Justin Hagstrom for reporting)
00150         fixed a bug with the new hidden file wildcards
00151 
00152 v1.2.6  12-06-03
00153         improved external icons: you may now mix external and internal icons 
00154         improved directory sorting (thanks to mpember at mpember dot net dot au)
00155         improved default hidden files wildcards, now also hides .* (thanks to Charles Hill)
00156         fixed a minor bug in file type detection (thanks to Charles Hill)
00157         added more file extensions (thanks to Charles Hill)
00158 
00159 v1.2.5  11-26-03
00160         security fix: download would allow paths above snif directory
00161 
00162 v1.2.4  11-16-03
00163         added configurable separation string for description files
00164         added option to use external icons
00165 
00166 v1.2.3  11-15-03
00167         fixed minor typos and HTML glitches
00168 
00169 v1.2.2  11-11-03
00170         fixed a bug where the current path wasn't properly shown in the heading
00171 
00172 v1.2.1  11-10-03
00173         fixed files without extension
00174         suppressed warning when io functions fail
00175         experimental handling of symbolic links (completely untested! Please give feedback.)
00176 
00177 v1.2    11-04-03
00178         put a simple file into subdirectories to have snif handle direct requests to them
00179         minor bugfix
00180 
00181 v1.1a   11-03-03
00182         file download for Opera fixed
00183 
00184 v1.1    11-03-03
00185         download files instead of opening
00186         better documentation
00187         code cleanup
00188 
00189 v1.0    10-19-03
00190         initial release
00191 
00192 
00193 
00194 ****************************************************************************
00195 **  DESCRIPTION FILE FORMAT                                               **
00196 ****************************************************************************
00197 
00198 Hardcore definition:
00199 
00200 <descriptionfile>  ::= <line>*
00201 <line>             ::= <filename><separationString><description><EOL>
00202 <filename>         ::= <anythingExceptSeparationString>+
00203 <separationString> ::= defined by the $separationString variable, default "\t"
00204 <description>      ::= <anyting>+
00205 <EOL>              ::= "\r\n" | "\n"                    // OS dependent
00206 
00207 
00208 Simple example:
00209 
00210 .       This directory contains downloadable files for MyProgram 12.0.
00211 myprogram_12.0.exe      Installer version of MyProgram 12.0 (recommended)
00212 myprogram_12.0.zip      Zip file distribution of MyProgram 12.0
00213 releasenotes.txt        Release notes for MyProgram 12.0
00214 
00215 
00216 Please note that the room between the filename and the description is not
00217 filled with multiple spaces, but with one single tab. It doesn't matter if
00218 the descriptions in a file align or not, just use one tab.
00219 If you use a description for the current directory (.) as in the first line
00220 in the above example, it will be used as a heading in the directory listing.
00221 
00222 Put your descriptions in a text file within the same directory as the files 
00223 to describe. Then put the text file's name in the $useDescriptionsFrom 
00224 variable below. It is suggested that you use the same description file name
00225 in all subdirectories you want to list. Reason: Read the next paragraph.
00226 
00227 To make it even easier: For my download folder at 
00228 http://www.bitfolge.de/download, I have put the description file at
00229 http://www.bitfolge.de/download/descript.ion
00230 You can download it and use it as another example.
00231 
00232 Filenames in the description file are case insensitive as of 1.2.10. This
00233 means that myprogram.zip and MyProgram.ZIP both are regarded as the same
00234 file. If case sensitivity matters for you, you can disable this with the
00235 $descriptionFilenamesCaseSensitive variable in the advanced settings.
00236 
00237 
00238 ****************************************************************************
00239 **  HANDLING SUBDIRECTORY LISTINGS                                        **
00240 ****************************************************************************
00241 
00242 Say you've put the snif index.php into www.yourhost.com/download.
00243 Now somebody makes a request to www.yourhost.com/download/releases. In
00244 order to deal with this properly, you would have to copy the snif index.php
00245 to that directory, too. But this will prevent the user to go to 
00246 www.yourhost.com/download from www.yourhost.com/download/releases
00247 directly by selecting the .. link.
00248 
00249 If you have this situation, use the index.php file from the subdirectory
00250 called "subdir" in the snif archive file. All it does is automatically 
00251 forward the user to the parent directory and set URL parameters so that
00252 the real snif will handle the request.
00253 
00254 OK, that may be confusing. Again, a simple example:
00255 
00256 
00257 /download/descript.ion                       << descriptions for /download/*.*
00258 /download/index.php                          << this file you're reading now, >25 KB
00259 /download/license.txt
00260 /download/notes.txt
00261 /download/releases/bigprogram_2.0.zip
00262 /download/releases/descript.ion              << descriptions for /download/releases/*.*
00263 /download/releases/index.php                 << subdir/index.php, <2 KB
00264 /download/releases/nightly/2.1_20031103.zip
00265 /download/releases/nightly/2.1_20031104.zip
00266 /download/releases/nightly/index.php         << subdir/index.php, <2 KB
00267 
00268 
00269 If a users points his browser to
00270   www.yourhost.com/download/releases/nightly/
00271   
00272 The small index.php will forward him to
00273   www.yourhost.com/download/releases/?path=nightly/
00274 
00275 And then the index file in that directory will forward him again, this time to
00276   www.yourhost.com/download/?path=releases/nightly/
00277 
00278 Now we've reached the directory with the real snif (should get a copyright on
00279 that phrase ;-)), which will take over and miraculously lists the directory
00280 the user typed as an URL.
00281 
00282 
00283 
00284 /***************************************************************************/
00286 /***************************************************************************/
00287 
00288 
00289 
00290 /**************  BASIC SETTINGS  *******************************************/
00291 /* These settings configure the most basic functions of snif. You should   */
00292 /* be able to understand them quickly.                                     */
00293 /***************************************************************************/
00294 
00301 $hiddenFilesWildcards = Array("*.php", "*~");
00302 
00307 $allowSubDirs = true;
00308 
00315 $allowPHPDownloads = false;
00316 
00317 
00322 $useAutoThumbnails = true;
00323 
00324 
00333 $cacheThumbnails = true;
00334 
00335 
00336 /**************  ADVANCED SETTINGS  ****************************************/
00337 /* Usually you won't need to change these, but you may have a look if you  */
00338 /* want snif to do something you think it can't. Maybe there's a setting   */
00339 /* which lets you do it.                                                   */
00340 /***************************************************************************/
00341 
00347 $snifServer = $_SERVER['HTTP_HOST'];
00348 //$snifServer = 'www.yourdomain.com';
00349 
00356 $snifDateFormat = 'd-m-y';
00357 
00363 $hiddenFilesRegex = Array();
00364  
00368 $useDescriptionsFrom = "descript.ion";
00369 
00374 $separationString = "\t";
00375 
00381 $useExternalImages = false;
00382 
00389 $externalIcons = Array (
00390         "archive"       => "",
00391         "binary"        => "",
00392         "dirup"   => "",
00393         "folder"        => "",
00394         "HTML"          => "",
00395         "image"         => "",
00396         "text"          => "",
00397         "unknown"       => "",
00398         "download"      => "",   // 7x16 pixels
00399         "asc"           => "",       // 5x3 pixels
00400         "desc"          => ""      // 5x3 pixels
00401 );
00402 
00409 $externalStylesheet = "";
00410 
00428 $externalConfig = "";
00429 
00437 $descriptionFilenamesCaseSensitive = false;
00438 
00444 $usePaging = 0;
00445 
00453 $directDirectoryLinks = false;
00454 
00460 $thumbnailHeight = 50;
00461 $thumbnailWidth = 150;
00462 
00466 $useBackForDirUp = true;
00467 
00484 $displayColumns = Array(
00485         "download",
00486         "icon",
00487         "name",
00488         "type",
00489         "size",
00490         "date",
00491         "description"
00492 );
00493 
00498 $tableWidth100Percent = false;
00499 
00506 $descriptionColumnWidth = 0;
00507 
00512 $truncateLength = 30;
00513 
00521 $protectDirsWithHtaccess = true;
00522 
00530 $alwaysUseLanguage = "";
00531 
00532 
00533 /***************************************************************************/
00535 /***************************************************************************/
00536 
00537 $languageStrings = Array(
00538         "en" => Array(
00539                 // only serves as the default language, no translations needed
00540                 // if you don't translate a string, the english version will be used
00541                 
00542                 "Index of" => "", // displayed in the page title
00543                 "name" => "", // column name in the file listing
00544                 "type" => "", // column name in the file listing
00545                 "size" => "", // column name in the file listing
00546                 "date" => "", // column name in the file listing
00547                 "description" => "", // column name in the file listing
00548                 "DATEFORMAT" => $snifDateFormat, // special string, sets the format of the date (see http://www.php.net/manual/en/function.date.php)
00549                 "folder" => "", // a folder in the file listing
00550                 "archive" => "", // an archive file in the file listing
00551                 "image" => "", // an image file in the file listing
00552                 "text" => "", // a text file in the file listing
00553                 "HTML" => "", // an archive file in the file listing
00554                 "unknown" => "", // an unknown file in the file listing
00555                 "valid" => "", // used for "valid XHTML, valid CSS"
00556                 "binary" => "", // a binary file
00557                 "dirup" => "", // tooltip of the .. folder icon
00558                 "download" => "", // tooltip of the download icon to the left
00559                 "asc" => "", // sort in ascending order
00560                 "desc" => "", // sort in descending order
00561                 "[ back ]" => "", // special name displayed for the .. folder
00562                 "1 item" => "", // displayed when a subdirectory contains exactly one file or directory
00563                 "%d items" => "", // 0 items, 42 items; displays the number of files and directories in a subdirectory. Leave %d as it is.
00564                 "%s is not a subdirectory of the current directory." => "", // leave %s as it is, it is replaced by the directory name
00565                 "File not found: %s" => "",  // leave %s as it is, it is replaced by the file name
00566                 "Illegal characters detected in URL, ignoring." => "", // displayed when an URL parameter contains HTML special characters
00567                 "Illegal path specified, ignoring." => "", // displayed when the path URL parameter contains a potentially dangerous path
00568                 "Bytes" => "", // appended to the exact file size in the tooltip ("462 Bytes")
00569                 "B" => "", // abbreviation of Bytes ("462 B")
00570                 "KB" => "", // abbreviation of kilobyte ("12.4 KB")
00571                 "MB" => "", // abbreviation of megabyte ("3.4 MB")
00572                 "GB" => "", // abbreviation of gigabyte ("4.3 GB")
00573                 "TB" => "",  // abbreviation of terabyte ("820 TB")
00574                 "pages" => "", // as in "4 pages"
00575                 "previous" => "", // as in "previous page"
00576                 "next" => "" // as in "next page"
00577         ),
00578         
00579         // Brazilian Portuguese translation by Caio Begotti
00580         "br" => Array(
00581                 "Index of" => "Índice de",
00582                 "name" => "nome",
00583                 "type" => "tipo",
00584                 "size" => "tam.",
00585                 "date" => "data",
00586                 "description" => "descrição",
00587                 "DATEFORMAT" => "d/m/y",
00588                 "folder" => "diretório",
00589                 "archive" => "arquivo",
00590                 "image" => "imagem",
00591                 "text" => "texto",
00592                 "HTML" => "HTML",
00593                 "unknown" => "desconhecido",
00594                 "valid" => "validar",
00595                 "binary" => "binário",
00596                 "dirup" => "subir um nível",
00597                 "download" => "download",
00598                 "asc" => "ascendente",
00599                 "desc" => "descendente",
00600                 "[ back ]" => "[ voltar ]",
00601                 "1 item" => "1 item",
00602                 "% items" => "%d itens",
00603                 "%s is not a subdirectory of the current directory." => "%s não é um subdiretório da localização atual.",
00604                 "File not found: %s" => "Arquivo não encontrado: %s",
00605                 "Illegal characters detected in URL, ignoring." => "Ignorando caracteres ilegais da URL...",
00606                 "Illegal path specified, ignoring." => "Ignorando o caminho ilegal especificado...",
00607                 "Bytes" => "Bytes",
00608                 "B" => "B",
00609                 "KB" => "KB",
00610                 "MB" => "MB",
00611                 "GB" => "GB",
00612                 "TB" => "TB",
00613                 "pages" => "páginas",
00614                 "previous" => "retornar",
00615                 "next" => "avançar"
00616         ),
00617         
00618         // Czech translation by Jan Pinkas
00619         "cz" => Array(
00620                 "Index of" => "Vpis", // displayed in the page title
00621                 "name" => "jmno", // column name in the file listing
00622                 "type" => "typ", // column name in the file listing
00623                 "size" => "velikost", // column name in the file listing
00624                 "date" => "datum", // column name in the file listing
00625                 "description" => "popis", // column name in the file listing
00626                 "DATEFORMAT" => $snifDateFormat, // special string, sets the format of the date (see http://www.php.net/manual/en/function.date.php)
00627                 "folder" => "adresr", // a folder in the file listing
00628                 "archive" => "archiv", // an archive file in the file listing
00629                 "image" => "obrzek", // an image file in the file listing
00630                 "text" => "text", // a text file in the file listing
00631                 "HTML" => "html", // an archive file in the file listing
00632                 "unknown" => "nezm", // an unknown file in the file listing
00633                 "valid" => "platn", // used for "valid XHTML, valid CSS"
00634                 "binary" => "binrn", // a binary file
00635                 "dirup" => "nahoru", // tooltip of the .. folder icon
00636                 "download" => "sthnout", // tooltip of the download icon to the left
00637                 "asc" => "sestupne", // sort in ascending order
00638                 "desc" => "vzestupne", // sort in descending order
00639                 "[ back ]" => "[ zpet ]", // special name displayed for the .. folder
00640                 "1 item" => "1 poloka", // displayed when a subdirectory contains exactly one file or directory
00641                 "%d items" => "%d poloky", // 0 items, 42 items; displays the number of files and directories in a subdirectory. Leave %d as it is.
00642                 "%s is not a subdirectory of the current directory." => "%s nen podaresr toho adresre", // leave %s as it is, it is replaced by the directory name
00643                 "File not found: %s" => "Soubor nenalezen: %s",  // leave %s as it is, it is replaced by the file name
00644                 "Illegal characters detected in URL, ignoring." => "Neplatn znaky v URL, preskakuju", // displayed when an URL parameter contains HTML special characters
00645                 "Illegal path specified, ignoring." => "Neplatn cesta, ignoruju", // displayed when the path URL parameter contains a potentially dangerous path
00646                 "Bytes" => "Bajtu", // appended to the exact file size in the tooltip ("462 Bytes")
00647                 "B" => "B", // abbreviation of Bytes ("462 B")
00648                 "KB" => "KB", // abbreviation of kilobyte ("12.4 KB")
00649                 "MB" => "MB", // abbreviation of megabyte ("3.4 MB")
00650                 "GB" => "GB", // abbreviation of gigabyte ("4.3 GB")
00651                 "TB" => "TB",  // abbreviation of terabyte ("820 TB")
00652                 "pages" => "strnky", // as in "4 pages"
00653                 "previous" => "predchoz", // as in "previous page"
00654                 "next" => "nsledujc" // as in "next page"
00655         ),
00656         
00657         "de" => Array(
00658                 "Index of" => "Inhalt von",
00659                 "name" => "Name",
00660                 "type" => "Typ",
00661                 "size" => "Größe",
00662                 "date" => "Datum",
00663                 "DATEFORMAT" => "d.m.y", // special string, sets the format of the date (see http://www.php.net/manual/en/function.date.php)
00664                 "description" => "Beschreibung",
00665                 "folder" => "Verzeichnis",
00666                 "archive" => "Archiv",
00667                 "image" => "Bild",
00668                 "text" => "Text-Datei",
00669                 "HTML" => "HTML-Datei",
00670                 "unknown" => "unbekannt",
00671                 "valid" => "gültiges",
00672                 "binary" => "Binärdatei",
00673                 "dirup" => "Aufwärts",
00674                 "download" => "Download",
00675                 "asc" => "aufsteigend",
00676                 "desc" => "absteigend",
00677                 "[ back ]" => "[ aufwärts ]",
00678                 "1 item" => "1 Eintrag",
00679                 "%d items" => "%d Einträge",
00680                 "%s is not a subdirectory of the current directory." => "%s ist kein Unterverzeichnis des momentanen Verzeichnisses.",
00681                 "File not found: %s" => "Die Datei '%s' wurde konnte nicht gefunden werden.",
00682                 "Illegal characters detected in URL, ignoring." => "Ungültige Zeichen in der URL wurden ignoriert.",
00683                 "Illegal path specified, ignoring." => "Ein ungültiger Pfad in einem Parameter wurde bereinigt.",
00684                 "Bytes" => "Bytes",
00685                 "B" => "",
00686                 "KB" => "",
00687                 "MB" => "",
00688                 "GB" => "",
00689                 "TB" => "",
00690                 "pages" => "Seiten",
00691                 "previous" => "vorherige",
00692                 "next" => "nächste"
00693         ),
00694 
00695         // Danish translation by Svend Rugaard
00696         "dk" => Array(
00697                 "Index of" => "Indholdet i ",
00698                 "name" => "Navn",
00699                 "type" => "Type",
00700                 "size" => "strrelse",
00701                 "date" => "Dato",
00702                 "description" => "Beskrivelse",
00703                 "DATEFORMAT" => "d-m-y",
00704                 "folder" => "mappe",
00705                 "archive" => "arkiv",
00706                 "image" => "billede",
00707                 "text" => "tekst",
00708                 "HTML" => "HTML Dato",
00709                 "unknown" => "Ukendt",
00710                 "valid" => "Korrekt",
00711                 "binary" => "Bionr",
00712                 "dirup" => "En mappe tilbage",
00713                 "download" => "Download",
00714                 "asc" => "Vilkrlig Rkkeflge",
00715                 "desc" => "Uvilkrlig",
00716                 "[ back ]" => "[ Tilbage ]",
00717                 "1 item" => "1 fil",
00718                 "%d items" => "%d filer",
00719                 "%s is not a subdirectory of the current directory." => "%s er ikke en undermappe, af nuvrende mappe",
00720                 "File not found: %s" => "Filen er ikke fundet",
00721                 "Illegal characters detected in URL, ignoring." => "Forkerte karakter opdaget i URL, Ignoreret ", 
00722                 "Illegal path specified, ignoring." => "Forkert mappe navn valgt, ignoreres",
00723                 "Bytes" => "Bytes", 
00724                 "B" => "Bytes",
00725                 "KB" => "Kilobytes",
00726                 "MB" => "Megabytes",
00727                 "GB" => "Gigabytes",
00728                 "TB" => "Terabytes",
00729                 "pages" => "Sider",
00730                 "previous" => "Forrige",
00731                 "next" => "Nste"
00732         ),
00733         
00734         // Spanish translation by Martinp and Genaro Paez
00735         "es" => Array(
00736                 "Index of" => "Indice de",
00737                 "name" => "nombre", 
00738                 "type" => "tipo", 
00739                 "size" => "tama&ntilde;o", 
00740                 "date" => "fecha", 
00741                 "description" => "Descripci&oacute;n", 
00742                 "DATEFORMAT" => $snifDateFormat, 
00743                 "folder" => "directorio", 
00744                 "archive" => "archivo", 
00745                 "image" => "imagen", 
00746                 "text" => "texto", 
00747                 "HTML" => "HTML", 
00748                 "unknown" => "desconocido", 
00749                 "valid" => "valido", 
00750                 "binary" => "binario", 
00751                 "dirup" => "subir directorio", 
00752                 "download" => "descargar", 
00753                 "asc" => "ascendente", 
00754                 "desc" => "descendente", 
00755                 "[ back ]" => "[ atras ]", 
00756                 "1 item" => "1 objeto", 
00757                 "%d items" => "%d objetos", 
00758                 "%s is not a subdirectory of the current directory." => "%s no es un subdirectorio del directorio actual.", 
00759                 "File not found: %s" => "Archivo no encontrado: %s", 
00760                 "Illegal characters detected in URL, ignoring." => "Caract&eacute;res ilegales en la URL ha sido ignorados.",
00761                 "Illegal path specified, ignoring." => "Ruta ilegal especificada ha sido ignorada", 
00762                 "Bytes" => "", 
00763                 "B" => "B",
00764                 "KB" => "KB",
00765                 "MB" => "MB",
00766                 "GB" => "GB",
00767                 "TB" => "TB",
00768                 "pages" => "p&aacute;ginas",
00769                 "previous" => "anterior",
00770                 "next" => "siguiente"
00771         ),
00772         
00773         // French translation by Marc Nadeau
00774         "fr" => Array(
00775                 "Index of" => "Index de",
00776                 "name" => "nom",
00777                 "type" => "type",
00778                 "size" => "taille",
00779                 "date" => "date",
00780                 "description" => "description",
00781                 "DATEFORMAT" => "d-m-y",
00782                 "folder" => "r&eacute;pertoire",
00783                 "archive" => "archive",
00784                 "image" => "image",
00785                 "text" => "texte",
00786                 "HTML" => "HTML",
00787                 "unknown" => "inconnu",
00788                 "valid" => "valide",
00789                 "binary" => "binaire",
00790                 "dirup" => "niveau sup&eacute;rieur",
00791                 "download" => "t&eacute;l&eacute;charger",
00792                 "asc" => "asc",
00793                 "desc" => "desc",
00794                 "[ back ]" => "[ niveau sup&eacute;rieur ]",
00795                 "1 item" => "1 item",
00796                 "%d items" => "%d items",
00797                 "%s is not a subdirectory of the current directory." => "%s n 'est pas un sous-r&eacute;pertoire du r&eacute;pertoire courant",
00798                 "File not found: %s" => "Fichier non trouv.: %s",
00799                 "Illegal characters detected in URL, ignoring." => "Caractre ill&eacute;gal dans l'url, ignor&eacute;.",
00800                 "Illegal path specified, ignoring." => "Chemin d'accs ill&eacute;gal, ignor&eacute;.",
00801                 "Bytes" => "bytes",
00802                 "B" => "b",
00803                 "KB" => "Kb",
00804                 "MB" => "Mb",
00805                 "GB" => "Gb",
00806                 "TB" => "Tb",
00807                 "pages" => "pages",
00808                 "previous" => "pr&eacute;c&eacute;dente",
00809                 "next" => "suivante"
00810         ),
00811         
00812         // Greek translation by George Yiftoyiannis
00813         "gr" => Array( 
00814                 "Index of" => "Περιεχόμενα του", // 
00815                 "name" => "όνομα", //  
00816                 "type" => "τύπος", //  
00817                 "size" => "μέγεθος", // 
00818                 "date" => "ημερομηνία", //  
00819                 "description" => "περιγραφή", // 
00820                 "DATEFORMAT" => "d-m-y", //  
00821                 "folder" => "φάκελος", // 
00822                 "archive" => "αρχείο", // 
00823                 "image" => "εικόνα", // 
00824                 "text" => "κείμενο", // 
00825                 "HTML" => "HTML", // 
00826                 "unknown" => "άγνωστο", // *
00827                 "valid" => "έγκυρη", //  *
00828                 "binary" => "δυαδικό", // *
00829                 "dirup" => "ένα επίπεδο επάνω", // 
00830                 "download" => "κατέβασμα", //  
00831                 "asc" => "αύξ", // *
00832                 "desc" => "φθίν", // *
00833                 "[ back ]" => "[ πίσω ]", //  
00834                 "1 item" => "1 αντικείμενο", //  
00835                 "%d items" => "%d αντικείμενα", //  
00836                 "%s is not a subdirectory of the current directory." => "Το %s δεν είναι υποκατάλογος του τρέχοντος καταλόγου", // 
00837                 "File not found: %s" => "Το αρχείο δεν βρέθηκε:%s",  // 
00838                 "Illegal characters detected in URL, ignoring." => "Μη επιτρεπτοί χαρακτήρες βρέθηκαν στο URL και θ' αγνοηθούν.", // *
00839                 "Illegal path specified, ignoring." => "Μη επιτρεπτή διαδρομή καταλόγου. Αγνοήθηκε.", // *
00840                 "Bytes" => "Bytes", // 
00841                 "B" => "B", // 
00842                 "KB" => "KB", // 
00843                 "MB" => "MB", // 
00844                 "GB" => "GB", // 
00845                 "TB" => "TB",  //  
00846                 "pages" => "σελίδες", // *
00847                 "previous" => "προηγούμενη", // *
00848                 "next" => "επόμενη" // *
00849         ), 
00850         
00851         // Hungarian language settings. v1.0, 2004.06.15, funk.gabor@hunetkft.hu
00852         "hu" => Array(
00853                 "Index of" => "Könyvtár:",
00854                 "name" => "név",
00855                 "type" => "típus",
00856                 "size" => "méret",
00857                 "date" => "dátum",
00858                 "description" => "leírás",
00859                 "DATEFORMAT" => "y-m-d",
00860                 "folder" => "alkönyvtár",
00861                 "archive" => "archívum",
00862                 "image" => "kép",
00863                 "text" => "szöveg",
00864                 "HTML" => "html",
00865                 "unknown" => "ismeretlen",
00866                 "valid" => "érvényes",
00867                 "binary" => "bináris",
00868                 "dirup" => "vissza a szülõkönyvtárba",
00869                 "download" => "letöltés",
00870                 "asc" => "növekvõ",
00871                 "desc" => "csökkenõ",
00872                 "[ back ]" => "[..]",
00873                 "1 item" => "1 fájl",
00874                 "%d items" => "%d fájl",
00875                 "%s is not a subdirectory of the current directory." => "%d nem alkönyvtár",
00876                 "File not found: %s" => "Fájl nem található",
00877                 "Illegal characters detected in URL, ignoring." => "Érvénytelen karakterek az URL-ben, kihagyva.",
00878                 "Illegal path specified, ignoring." => "Érvénytelen útvonalspecifikáció, kihagyva.",
00879                 "Bytes" => "Bájt",
00880                 "B" => "",
00881                 "KB" => "",
00882                 "MB" => "",
00883                 "GB" => "",
00884                 "TB" => "",
00885                 "pages" => "oldal",
00886                 "previous" => "elõzõ",
00887                 "next" => "következõ"
00888         ),
00889         
00890         // Italian translation by Luca Soltoggio
00891         "it" => Array(
00892                 "Index of" => "Contenuto di",
00893                 "name" => "nome",
00894                 "type" => "tipo",
00895                 "size" => "dimensione",
00896                 "date" => "data",
00897                 "description" => "descrizione",
00898                 "DATEFORMAT" => "d-m-y",
00899                 "folder" => "cartella",
00900                 "archive" => "archivio",
00901                 "image" => "immagine",
00902                 "text" => "testo",
00903                 "HTML" => "HTML",
00904                 "unknown" => "sconosciuto",
00905                 "valid" => "valido",
00906                 "binary" => "binario",
00907                 "dirup" => "directory superiore",
00908                 "download" => "download",
00909                 "asc" => "ascendente",
00910                 "desc" => "discendente",
00911                 "[ back ]" => "[ indietro ]",
00912                 "1 item" => "1 oggetto",
00913                 "%d items" => "%d oggetti",
00914                 "%s is not a subdirectory of the current directory." => "%s non &egrave una sottocartella della cartella corrente.",
00915                 "File not found: %s" => "File non trovato: %s",
00916                 "Illegal characters detected in URL, ignoring." => "Caratteri non validi nell'URL ignorati.",
00917                 "Illegal path specified, ignoring." => "Percorso specificato non valido ignorato.",
00918                 "Bytes" => "Bytes", 
00919                 "B" => "Bytes",
00920                 "KB" => "KB",
00921                 "MB" => "MB",
00922                 "GB" => "GB",
00923                 "TB" => "TB",
00924                 "pages" => "pagine",
00925                 "previous" => "precedente",
00926                 "next" => "seguente"
00927   ),
00928         
00929         // Japanese translation by hjbdnpmo Version 20040624
00930         "jp" => Array(
00931                 "Index of" => "Index of",
00932                 "name" => "ネーム",
00933                 "type" => "タイプ",
00934                 "size" => "サイズ",
00935                 "date" => "日付",
00936                 "description" => "記述",
00937                 "DATEFORMAT" => "y/m/d",
00938                 "folder" => "ディレクトリ",
00939                 "archive" => "アーカイブ",
00940                 "image" => "イメージ",
00941                 "text" => "テキスト",
00942                 "HTML" => "HTML",
00943                 "unknown" => "不明",
00944                 "valid" => "valid",
00945                 "binary" => "バイナリ",
00946                 "dirup" => "上のディレクトリへ移動",
00947                 "download" => "ダウンロード",
00948                 "asc" => "昇順でソート",
00949                 "desc" => "降順でソート",
00950                 "[ back ]" => "[ 戻る ]",
00951                 "1 item" => "1 アイテム",
00952                 "%d items" => "%d アイテム",
00953                 "%s is not a subdirectory of the current directory." => "%sはカレントディレクトリのサブディレクトリではありません。",
00954                 "File not found: %s" => "ファイルが見つかりません: %s",
00955                 "Illegal characters detected in URL, ignoring." => "URLに不正な文字が検出されました、無視します。",
00956                 "Illegal path specified, ignoring." => "不正なパスが指定されました、無視します。",
00957                 "Bytes" => "Bytes",
00958                 "B" => "Bytes",
00959                 "KB" => "KB",
00960                 "MB" => "MB",
00961                 "GB" => "GB",
00962                 "TB" => "TB",
00963                 "pages" => "ページ",
00964                 "previous" => "前へ",
00965                 "next" => "次へ"
00966         ),
00967         
00968         // dutch translation by Rogier van Epen
00969         "nl" => Array(
00970                 "Index of" => "Inhoud van",
00971                 "name" => "Naam",
00972                 "type" => "Type",
00973                 "size" => "Grootte",
00974                 "date" => "Datum",
00975                 "DATEFORMAT" => "d.m.y",
00976                 "description" => "Beschrijving",
00977                 "folder" => "Map",
00978                 "archive" => "Archief",
00979                 "image" => "Beeld",
00980                 "text" => "Text",
00981                 "HTML" => "HTML",
00982                 "unknown" => "Onbekend",
00983                 "valid" => "Geldig",
00984                 "binary" => "Binary",
00985                 "dirup" => "Onderliggende map",
00986                 "download" => "Download",
00987                 "asc" => "Oplopend",
00988                 "desc" => "Aflopend",
00989                 "[ back ]" => "[ Terug ]",
00990                 "1 item" => "1 Onderdeel",
00991                 "%d items" => "%d Onderdelen",
00992                 "%s is not a subdirectory of the current directory." => "%s is geen submap van de huidige map.",
00993                 "File not found: %s" => "Het bestand '%s' kon niet gevonden worden.",
00994                 "Illegal characters detected in URL, ignoring." => "Ongeldige karakters gevonden in de URL, deze worden genegeerd.",
00995                 "Illegal path specified, ignoring." => "Ongeldige locatie, deze locatie zal worden genegeerd.",
00996                 "Bytes" => "",
00997                 "B" => "",
00998                 "KB" => "",
00999                 "MB" => "",
01000                 "GB" => "",
01001                 "TB" => "",
01002                 "pages" => "",
01003                 "previous" => "",
01004                 "next" => ""
01005         ),
01006 
01007         // Norwegian translation by Kyrre Liaaen
01008         "no" => Array(
01009                 "Index of" => "Innholdet i",
01010                 "name" => "navn",
01011                 "type" => "type",
01012                 "size" => "st&oslash;rrelse",
01013                 "date" => "dato",
01014                 "description" => "beskrivelse",
01015                 "DATEFORMAT" => "d-m-y",
01016                 "folder" => "mappe",
01017                 "archive" => "arkiv",
01018                 "image" => "bilde",
01019                 "text" => "tekst",
01020                 "HTML" => "HTML",
01021                 "unknown" => "ukjent",
01022                 "valid" => "gyldig",
01023                 "binary" => "bin&aelig;r",
01024                 "dirup" => "opp en mappe",
01025                 "download" => "last ned",
01026                 "asc" => "stigende",
01027                 "desc" => "synkende",
01028                 "[ back ]" => "[ tilbake ]",
01029                 "1 item" => "1 enhet",
01030                 "%d items" => "%d enheter",
01031                 "%s is not a subdirectory of the current directory." => "%s er ikke en mappe underlagt denne mappen",
01032                 "File not found: %s" => "Kan ikke finne filen: %s",
01033                 "Illegal characters detected in URL, ignoring." => "Ugyldige tegn er funnet i URL'en, utelater.",
01034                 "Illegal path specified, ignoring." => "Ugyldig sti opgitt, utelater.",
01035                 "Bytes" => "octets",
01036                 "B" => "",
01037                 "KB" => "",
01038                 "MB" => "",
01039                 "GB" => "",
01040                 "TB" => "", 
01041                 "pages" => "sider", 
01042                 "previous" => "forrige side",
01043                 "next" => "neste side"
01044         ),
01045         
01046         // Polish translation by Slawomir Jucht
01047         "pl" => Array(
01048                 "Index of" => "Zawarto",
01049                 "name" => "Nazwa",
01050                 "type" => "Typ",
01051                 "size" => "Rozmiar",
01052                 "date" => "Data",
01053                 "description" => "Miniatura",
01054                 "DATEFORMAT" => "d-m-Y",
01055                 "folder" => "Katalog",
01056                 "archive" => "Archiwum",
01057                 "image" => "Zobacz",
01058                 "text" => "Tekst",
01059                 "HTML" => "HTML",
01060                 "unknown" => "Nieznany",
01061                 "valid" => "Odpowiedni",
01062                 "binary" => "Binarium",
01063                 "dirup" => "Do gry",
01064                 "download" => "Pobierz",
01065                 "asc" => "ASCI",
01066                 "desc" => "Opis",
01067                 "[ back ]" => "[ Wstecz ]",
01068                 "1 item" => "1 plik",
01069                 "%d items" => "%d plikw",
01070                 "%s is not a subdirectory of the current directory." => "%s nie jest podkatalogiem biecego katalogu.",
01071                 "File not found: %s" => "Plik nie znaleziony: %s",
01072                 "Illegal characters detected in URL, ignoring." => "Wystpi niepoprawny znak w kodzie HTML - zignorowany.",
01073                 "Illegal path specified, ignoring." => "Niepoprawna cieka - zignorowana."
01074         ),
01075         
01076 // Russian translation by Neptune
01077         "ru" => Array(
01078                 "Index of" => "Содержимое",
01079                 "name" => "Имя",
01080                 "type" => "Тип",
01081                 "size" => "Размер",
01082                 "date" => "Дата",
01083                 "description" => "Описание",
01084                 "DATEFORMAT" => "d.m.y",
01085                 "folder" => "директория",
01086                 "archive" => "архив",
01087                 "image" => "изображение",
01088                 "text" => "текст",
01089                 "HTML" => "HTML",
01090                 "unknown" => "неизвестно",
01091                 "valid" => "valid",             // No good translation
01092                 "binary" => "бинарный",
01093                 "dirup" => "Вверх",
01094                 "download" => "Скачать",
01095                 "asc" => "возрастание",
01096                 "desc" => "убывание",
01097                 "[ back ]" => "[ назад ]",
01098                 "1 item" => "1 элемент",
01099                 "%d items" => "элементов: %d",   // Would be great to increase column width a bit.
01100                                                 // This format is used due to "4 items and 5 items" is not the same word in russian.
01101                 "%s is not a subdirectory of the current directory." => "%s не найдена в текущей директории.",
01102                 "File not found: %s" => "Файл не найден: %s",
01103                 "Illegal characters detected in URL, ignoring." => "Неверные символы в URL, игнорируется.",
01104                 "Illegal path specified, ignoring." => "Указан неверный путь, игнорируется.",
01105                 "Bytes" => "байт",
01106                 "B" => "B",
01107                 "KB" => "kB",
01108                 "MB" => "MB",
01109                 "GB" => "GB",
01110                 "TB" => "TB",
01111                 "pages" => "страница", 
01112                 "previous" => "предыдущая",
01113                 "next" => "следующая"
01114         ),
01115         
01116         // Swedish translation by Elias Hedberg
01117         "sv" => Array( 
01118                 "Index of" => "F&ouml;rteckning &ouml;ver",
01119                 "name" => "namn",
01120                 "type" => "typ",
01121                 "size" => "storlek",
01122                 "date" => "datum",
01123                 "DATEFORMAT" => "y-m-d",
01124                 "description" => "beskrivning",
01125                 "folder" => "mapp",
01126                 "archive" => "arkiv",
01127                 "image" => "bild",
01128                 "text" => "textfil",
01129                 "HTML" => "HTML-fil",
01130                 "unknown" => "ok&auml;nd",
01131                 "valid" => "giltig",
01132                 "binary" => "bin&auml;rfil",
01133                 "dirup" => "upp&aring;t",
01134                 "download" => "ladda ned",
01135                 "asc" => "stigande",
01136                 "desc" => "fallande",
01137                 "[ back ]" => "[ bak&aring;t ]",
01138                 "1 item" => 
01139                 "1 objekt",
01140                 "%d items" => "%d objekt",
01141                 "%s is not a subdirectory of the current directory." => "%s &auml;r inte en undermapp till aktuell mapp.",
01142                 "File not found: %s" => "Filen '%s' hittades inte.",
01143                 "Illegal characters detected in URL, ignoring." => "Ogiltiga tecken i URL:en, de ignoreras.",
01144                 "Illegal path specified, ignoring." => "Ogiltig s&ouml;kv&auml;g angiven, ignoreras.",
01145                 "Bytes" => "byte",
01146                 "B" => "B",
01147                 "KB" => "kB",
01148                 "MB" => "MB",
01149                 "GB" => "GB",
01150                 "TB" => "TB",
01151                 "pages" => "sidor", // as in "4 pages"
01152                 // (if you'd ever need the singular it's "page" => "sida",
01153                 // which works in both "page 2 of 4" (where "of" => "av")
01154                 // and in "1 page")
01155                 "previous" => "f&ouml;reg&aring;ende",
01156                 "next" => "n&auml;sta"
01157         )
01158 );
01159 
01160 
01161 
01162 
01163 /***************************************************************************/
01165 /***************************************************************************/
01166 
01167 
01168 /***************************************************************************/
01170 /***************************************************************************/
01171 
01172 function translate($string) {
01173         GLOBAL $languageStrings, $alwaysUseLanguage;
01174         static $requestLanguage;
01175         
01176         if ($requestLanguage=="") {
01177                 $validLanguages = array_keys($languageStrings);
01178                 if ($alwaysUseLanguage!="" && in_array($alwaysUseLanguage, $validLanguages)) {
01179                         $requestLanguage = $alwaysUseLanguage;
01180                 } else {
01181                         if ($requestLanguage == "") {
01182                                 $acceptLanguages = explode(",", $_SERVER["HTTP_ACCEPT_LANGUAGE"]);
01183                                 for ($i=0; $i<count($acceptLanguages) AND $requestLanguage==""; $i++) {
01184                                         $al = substr($acceptLanguages[$i],0,2);
01185                                         if (in_Array($al,$validLanguages)) {
01186                                                 $requestLanguage = $al;
01187                                         }
01188                                 }
01189                                 if ($requestLanguage=="") {
01190                                         $requestLanguage = $validLanguages[0];
01191                                 }
01192                         }
01193                 }
01194         }
01195         
01196         $stringTranslated = $languageStrings[$requestLanguage][$string];
01197         if ($stringTranslated!="") {
01198                 return $stringTranslated;
01199         } else {
01200                 return $string;
01201         }
01202 }
01203 
01204 
01205 /***************************************************************************/
01207 /***************************************************************************/
01208 
01209 // make sure all the notices don't come up in some configurations
01210 error_reporting (E_ALL ^ E_NOTICE);
01211 
01212 $displayError = Array();
01213 
01214 // safify all GET variables
01215 foreach($_GET AS $key => $value) {
01216         $_GET[$key] = strip_tags($value);
01217         if ($_GET[$key] != $value) {
01218                 $displayError[] = translate("Illegal characters detected in URL, ignoring.");
01219         }
01220         if (!get_magic_quotes_gpc()) {
01221                 $_GET[$key] = stripslashes($value);
01222         }
01223 }
01224 
01225 
01226 // read external config file
01227 if ($externalConfig!="") {
01228         include($externalConfig);
01229 }
01230 
01231 
01232 // first of all, security: prevent any unauthorized paths
01233 // if sub directories are forbidden, ignore any path setting
01234 if (!$allowSubDirs) {
01235         $path = "";
01236 } else {
01237         $path = $_GET["path"];
01238         
01239         // ignore any potentially malicious paths
01240         $path = safeDirectory($path);
01241 }
01242 
01243 // default sorting is by name
01244 if ($_GET["sort"]=="") 
01245         $_GET["sort"] = "name";
01246 
01247 // default order is ascending
01248 if ($_GET["order"]=="") {
01249         $_GET["order"] = "asc";
01250 } else {
01251         $_GET["order"] = strtolower($_GET["order"]);
01252 }
01253 
01254 // hide descriptions column if no description file is specified
01255 if ($useDescriptionsFrom=="") {
01256         $index = array_search("description", $displayColumns);
01257         if ($index!==false && $index!==null) {
01258                 unset($displayColumns[$index]);
01259         }
01260 }
01261         
01262 // add files used by snif to hidden file list
01263 if ($useDescriptionsFrom!="") {
01264         $hiddenFilesWildcards[] = $useDescriptionsFrom;
01265 }
01266 if ($externalStylesheet!="") {
01267         $hiddenFilesWildcards[] = $externalStylesheet;
01268 }
01269 $hiddenFilesWildcards[] = ".";
01270 $hiddenFilesWildcards[] = basename($_SERVER["PHP_SELF"]);
01271 
01272 // build hidden files regular expression
01273 for ($i=0;$i<count($hiddenFilesWildcards);$i++) {
01274         $translate = Array(
01275                 "." => "\\.",
01276                 "*" => ".*",
01277                 "?" => ".?",
01278                 "+" => "\\+",
01279                 "[" => "\\[",
01280                 "]" => "\\]",
01281                 "(" => "\\(",
01282                 ")" => "\\)",
01283                 "{" => "\\{",
01284                 "}" => "\\}",
01285                 "^" => "\\^",
01286                 "\$" => "\\\$",
01287                 "\\" => "\\\\",
01288         );
01289         $hiddenFilesRegex[] = "^".strtr($hiddenFilesWildcards[$i],$translate)."$";
01290 }
01291 // hide .*
01292 $hiddenFilesRegex[] = "^\\.[^.].*$";
01293 $hiddenFilesWholeRegex = "/".join("|",$hiddenFilesRegex)."/i";
01294 
01295 
01296 
01297 /***************************************************************************/
01299 /***************************************************************************/
01300 
01301 // handle image requests
01302 if ($_GET["getimage"]!="") {
01303         $imagesEncoded = Array(
01304                 "archive"  => "R0lGODlhEAAQAJECAAAAAP///////wAAACH5BAEAAAIALAAAAAAQABAAAAI3lA+pxxgfUhNKPRAbhimu2kXiRUGeFwIlN47qdlnuarokbG46nV937UO9gDMHsMLAcSYU0GJSAAA7",
01305                 "asc"      => "R0lGODlhBQADAIABAN3d3f///yH5BAEAAAEALAAAAAAFAAMAAAIFTGAHuF0AOw==",
01306                 "binary"   => "R0lGODlhEAAQAJECAAAAAP///////wAAACH5BAEAAAIALAAAAAAQABAAAAI0lICZxgYBY0DNyfhAfROrxoVQBo5mpzFih5bsFLoX5iLYWK6xyur5ubPAbhPZrKhSKCmCAgA7",
01307                 "desc"     => "R0lGODlhBQADAIABAN3d3f///yH5BAEAAAEALAAAAAAFAAMAAAIFhB0XC1sAOw==",
01308                 "dirup"    => "R0lGODlhEAAQAJECAAAAAP///////wAAACH5BAEAAAIALAAAAAAQABAAAAIulI+JwKAJggzuiThl2wbnT3WZN4oaA1bYRobXCLpkq5nnVr9xqe85C2xYhkRFAQA7",
01309                 "folder"   => "R0lGODlhEAAQAJECAAAAAP///////wAAACH5BAEAAAIALAAAAAAQABAAAAIplI+JwKAJggzuiThl2wbnT3UgWHmjJp5Tqa5py7bhJc/mWW46Z/V+UgAAOw==",
01310                 "HTML"     => "R0lGODlhEAAQAKIHABsb/2ho/4CA/0BA/zY2/wAAAP///////yH5BAEAAAcALAAAAAAQABAAAANEeFfcrVAVQ6thUdo6S57b9UBgSHmkyUWlMAzCmlKxAZ9s5Q5AjWqGwIAS8OVsNYJxJgDwXrHfQoVLEa7Y6+Wokjq+owQAOw==",
01311                 "image"    => "R0lGODlhEAAQAKIEAK6urmRkZAAAAP///////wAAAAAAAAAAACH5BAEAAAQALAAAAAAQABAAAANCSCTcrVCJQetgUdo6RZ7b9UBgSHnkAKwscEZTy74pG9zuBavA7dOanu+H0gyGxN0RGdClKEjgwvKTlkzFhWOLISQAADs=",
01312                 "text"     => "R0lGODlhEAAQAJECAAAAAP///////wAAACH5BAEAAAIALAAAAAAQABAAAAI0lICZxgYBY0DNyfhAfXcuxnWQBnoKMjXZ6qUlFroWLJHzGNtHnat87cOhRkGRbGc8npakAgA7",
01313                 "download" => "R0lGODlhBwAQAIABAAAAAP///yH5BAEAAAEALAAAAAAHABAAAAISjI+pywb6UkQzgHsPls3h2gUFADs=",
01314                 "blank"    => "R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==",
01315                 "unknown"  => "R0lGODlhEAAQAJECAAAAAP///////wAAACH5BAEAAAIALAAAAAAQABAAAAI1lICZxgYBY0DNyfhAfXcuxnkI1nCjB2lgappld6qWdE4vFtprR+4sffv1ZjwdkSc7KJYUQQEAOw=="
01316         );
01317         $imageDataEnc = $imagesEncoded[$_GET["getimage"]];
01318         if ($imageDataEnc) {
01319                 $maxAge = 31536000; // one year
01320                 doConditionalGet($_GET["getimage"], gmmktime(1,0,0,1,1,2004));
01321                 $imageDataRaw = base64_decode($imageDataEnc);
01322                 Header("Content-Type: image/gif");
01323                 Header("Content-Length: ".strlen($imageDataRaw));
01324                 Header("Cache-Control: public, max-age=$maxAge, must-revalidate");
01325                 Header("Expires: ".createHTTPDate(time()+$maxAge));
01326                 echo $imageDataRaw;
01327         }
01328         
01329         die();
01330 }
01331 
01332 // handle thumbnail creation
01333 if ($_GET["thumbnail"]!="") {
01334         GLOBAL $thumbnailHeight, $cacheThumbnails;
01335         $thumbnailCacheSubdir = ".snifthumbs";
01336         
01337         $file = safeDirectory(urldecode($_GET["thumbnail"]));
01338         doConditionalGet($_GET["thumbnail"],filemtime($file));
01339 
01340         $thumbDir = dirname($file)."/".$thumbnailCacheSubdir;
01341         $thumbFile = $thumbDir."/".basename($file);
01342         if ($cacheThumbnails) {
01343                 if (file_exists($thumbDir)) {
01344                         if (!is_dir($thumbDir)) {
01345                                 $cacheThumbnails = false;
01346                         }
01347                 } else {
01348                         if (@mkdir($thumbDir)) {
01349                                 chmod($thumbDir, "0777");
01350                         } else {
01351                                 $cacheThumbnails = false;
01352                         }
01353                 }
01354                 if (file_exists($thumbFile)) {
01355                         if (filemtime($thumbFile)>=filemtime($file)) {
01356                                 Header("Location: ".dirname($_SERVER["PHP_SELF"])."/".$thumbFile);
01357                                 die();
01358                         }
01359                 }
01360         }
01361         $contentType = "";
01362         $extension = strtolower(substr(strrchr($file, "."), 1));
01363         switch ($extension) {
01364                 case "gif":             $src = imagecreatefromgif($file); $contentType="image/gif"; break;
01365                 case "jpg":             // fall through
01366                 case "jpeg":    $src = imagecreatefromjpeg($file); $contentType="image/jpeg"; break;
01367                 case "png":             $src = imagecreatefrompng($file); $contentType="image/png"; break;
01368                 default:        die(); break;
01369         }
01370         $srcWidth = imagesx($src);
01371         $srcHeight = imagesy($src);
01372         $srcAspectRatio = $srcWidth / $srcHeight;
01373         
01374         $maxAge = 3600; // one hour
01375         Header("Cache-Control: public, max-age=$maxAge, must-revalidate");
01376         Header("Expires: ".createHTTPDate(time()+$maxAge));
01377 
01378         if ($srcHeight<=$thumbnailHeight AND $srcWidth<=$thumbnailWidth) {
01379                 Header("Content-Type: $contentType");
01380                 readfile($file);
01381         } else {
01382                 if ($srcWidth > $srcHeight) {
01383                         $thumbWidth = $thumbnailWidth;
01384                         $thumbHeight = $thumbWidth / $srcAspectRatio;
01385                 } else {
01386                         $thumbHeight = $thumbnailHeight;
01387                         $thumbWidth = $thumbHeight * $srcAspectRatio;
01388                 }
01389                 if (function_exists('imagecreatetruecolor')) {
01390                         $thumb = imagecreatetruecolor($thumbWidth, $thumbHeight);
01391                 } else {
01392                         $thumb = imagecreate($thumbWidth, $thumbHeight);
01393                 } 
01394                 imagecopyresampled($thumb, $src, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $srcWidth, $srcHeight);
01395                 Header("Content-Type: image/jpeg");
01396                 if ($cacheThumbnails) {
01397                         imagejpeg($thumb, $thumbFile);
01398                         chmod($thumbFile, "0777");
01399                         readfile($thumbFile);
01400                 } else {
01401                         imagejpeg($thumb);
01402                 }
01403         }
01404         die();
01405 }
01406 
01407 // handle download requests
01408 if ($_GET["download"]!="") {
01409         $download = stripslashes($_GET["download"]);
01410         $filename = safeDirectory($path.rawurldecode($download));
01411         if (
01412                 !file_exists($filename)
01413                 OR fileIsHidden($filename)
01414                 OR (substr(strtolower($filename), -4)==".php" AND !$allowPHPDownloads)) {
01415                 
01416                 Header("HTTP/1.0 404 Not Found");
01417                 $displayError[] = sprintf(translate("File not found: %s"), $filename);
01418         } else {
01419                 //doConditionalGet($filename, filemtime($filename));
01420                 Header("Content-Length: ".filesize($filename));
01421                 Header("Content-Type: application/x-download");
01422                 Header("Content-Disposition: attachment; filename=\"".rawurlencode($download)."\"");
01423                 readfile($filename);
01424                 die();
01425         }
01426 }
01427 
01428 
01429 
01430 /***************************************************************************/
01432 /***************************************************************************/
01433 
01434 // create a HTTP conform date
01435 function createHTTPDate($time) {
01436         return gmdate("D, d M Y H:i:s", $time)." GMT";
01437 }
01438 
01439 
01440 // this function is from http://simon.incutio.com/archive/2003/04/23/conditionalGet
01441 function doConditionalGet($file, $timestamp) {
01442         $last_modified = createHTTPDate($timestamp);
01443         $etag = '"'.md5($file.$last_modified).'"';
01444         // Send the headers
01445         Header("Last-Modified: $last_modified");
01446         Header("ETag: $etag");
01447         // See if the client has provided the required headers
01448         $if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ?
01449                 stripslashes($_SERVER['HTTP_IF_MODIFIED_SINCE']) :
01450                 false;
01451         $if_none_match = isset($_SERVER['HTTP_IF_NONE_MATCH']) ?
01452                 stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) : 
01453                 false;
01454         if (!$if_modified_since && !$if_none_match) {
01455                 return;
01456         }
01457         // At least one of the headers is there - check them
01458         if ($if_none_match && $if_none_match != $etag) {
01459                 return; // etag is there but doesn't match
01460         }
01461         if ($if_modified_since && $if_modified_since != $last_modified) {
01462                 return; // if-modified-since is there but doesn't match
01463         }
01464         // Nothing has changed since their last request - serve a 304 and exit
01465         Header('HTTP/1.0 304 Not Modified');
01466         die();
01467 }
01468 
01469 
01470 function safeDirectory($path) {
01471         GLOBAL $displayError;
01472         $result = $path;
01473         if (strpos($path,"..")!==false)
01474                 $result = "";
01475         if (substr($path,0,1)=="/") {
01476                 $result = "";
01477         }
01478         if ($result!=$path) {
01479                 $displayError[] = translate("Illegal path specified, ignoring.");
01480         }
01481         return $result;
01482 }
01483 
01484 
01488 function niceSize($size) {
01489         define("SIZESTEP", 1024.0);
01490         static $sizeUnits = Array();
01491         if (count($sizeUnits)==0) {
01492                 $sizeUnits[] = "&nbsp;".translate("B");
01493                 $sizeUnits[] = translate("KB");
01494                 $sizeUnits[] = translate("MB");
01495                 $sizeUnits[] = translate("GB");
01496                 $sizeUnits[] = translate("TB");
01497         }
01498         
01499         if ($size==="")
01500                 return "";
01501         
01502         $unitIndex = 0;
01503         while ($size>SIZESTEP) {
01504                 $size = $size / SIZESTEP;
01505                 $unitIndex++;
01506         }
01507         
01508         if ($unitIndex==0) {
01509                 return number_format($size, 0)."&nbsp;".$sizeUnits[$unitIndex];
01510         } else {
01511                 return number_format($size, 1, ".", ",")."&nbsp;".$sizeUnits[$unitIndex];
01512         }
01513 }
01514 
01518 function myCompare($arrA, $arrB, $caseSensitive=false) {
01519         $a = $arrA[$_GET["sort"]];
01520         $b = $arrB[$_GET["sort"]];
01521         
01522         // sort .. first
01523         if ($arrA["isBack"]) return -1;
01524         if ($arrB["isBack"]) return 1;
01525         // sort directories above everything else
01526         if ($arrA["isDirectory"]!=$arrB["isDirectory"]) {
01527                 $result = $arrB["isDirectory"]-$arrA["isDirectory"];
01528         } else if ($arrA["isDirectory"] && $arrB["isDirectory"] && ($_GET["sort"]=="type" || $_GET["sort"]=="size")) {
01529                 $result = 0;
01530         } else {
01531                 if (is_string($a) OR is_string($b)) {
01532                         if (!$caseSensitive) {
01533                                 $a = strtoupper($a);
01534                                 $b = strtoupper($b);
01535                         }
01536                         $result = strcoll($a,$b);
01537                 } else {
01538                         $result = $a-$b;
01539                 }
01540         }
01541         
01542         if (strtolower($_GET["order"])=="desc") {
01543                 return -$result;
01544         } else {
01545                 return $result;
01546         }
01547 }
01548 
01549 
01555 function myEncode($path, $filename) {
01556         // % must be the first, as it is the escape character
01557         /*
01558         $from = Array("%"," ","#","&");
01559         $to = Array("%25","%20","%23","%26");
01560         return str_replace($from, $to, $string);
01561         */
01562         return $path.rawurlencode($filename);
01563 }
01564 
01565 
01569 function getNewSortURL($newSort) {
01570         GLOBAL $path;
01571         $base = $_SERVER["PHP_SELF"];
01572         $url = $base."?sort=$newSort";
01573         if ($newSort==$_GET["sort"]) {
01574                 if ($_GET["order"]=="asc" OR $_GET["order"]=="") {
01575                         $url.= "&amp;order=desc";
01576                 }
01577         }
01578         if ($path!="") {
01579                 $url.= "&amp;path=$path";
01580         }
01581         return $url;
01582 }
01583 
01587 function getFileType($fileInfo) {
01588         // put any additional extensions in here
01589         $extension = $fileInfo["type"];
01590         static $fileTypes = Array(
01591                 "HTML"          => Array("html","htm"),
01592                 "image"         => Array("gif","jpg","jpeg","png","tif","tiff","bmp","art"),
01593                 "text"          => Array("asp","c","cfg","cpp","css","csv","conf","cue","diz","h","inf","ini","java","js","log","nfo","php","phps","pl","py","rdf","rss","rtf","sql","txt","vbs","xml"),
01594                 //"code"                => Array("asp","c","cpp","h","java","js","php","phps","pl","py","sql","vbs"),
01595                 //"xml"                 => Array("rdf","rss","xml"),
01596                 "binary"        => Array("asf","au","avi","bin","class","divx","doc","exe","mov","mpg","mpeg","mp3","ogg","ogm","pdf","ppt","ps","rm","swf","wmf","wmv","xls"),
01597                 //"document"=> Array("doc","pdf","ppt","ps","rtf","xls"),
01598                 "archive"       => Array("ace","arc","bz2","cab","gz","lha","jar","rar","sit","tar","tbz2","tgz","z","zip","zoo")
01599         );
01600         static $extensions = null;
01601 
01602         if ($extensions==null) {
01603                 $extensions = Array();
01604                 foreach($fileTypes AS $keyType => $value) {
01605                         foreach($value AS $ext) $extensions[$ext] = $keyType;
01606                 }
01607         }
01608 
01609         if ($fileInfo["isDirectory"]) {
01610                 if ($fileInfo["isBack"]) {
01611                         return "dirup";
01612                 } else {
01613                         return "folder";
01614                 }
01615         }
01616         
01617         $type = $extensions[strtolower($extension)];
01618         if ($type=="") {
01619                 return "unknown";
01620         } else {
01621                 return $type;
01622         }
01623 }
01624 
01625 function getIcon($fileType) {
01626         GLOBAL $useExternalImages, $externalIcons;
01627         if ($useExternalImages && $externalIcons[$fileType]!="") {
01628                 return $externalIcons[$fileType];
01629         } else {
01630                 return $_SERVER["PHP_SELF"]."?getimage=$fileType";
01631         }
01632 }
01633 
01634 function dirContainsHtAccess($dirname) {
01635         if(is_dir($dirname)) {
01636                 if ($dirname=="." || $dirname=="..") return false;
01637                 $d = dir($dirname);
01638                 while($f = $d->read()) {
01639                         if ($f==".htaccess")
01640                                 return true;
01641                 }
01642         }
01643         return false;
01644 }
01645 
01646 // checks if a file is hidden from view
01647 function fileIsHidden($filename) {
01648         GLOBAL $hiddenFilesWholeRegex,$protectDirsWithHtaccess;
01649         
01650         if (is_dir($filename) && $protectDirsWithHtaccess) {
01651                 if (!($filename=="." || $filename=="..")) {
01652                         $d = dir($filename);
01653                         while($f = $d->read()) {
01654                                 if ($f==".htaccess")
01655                                         return true;
01656                         }
01657                 }
01658         }
01659         return preg_match($hiddenFilesWholeRegex,$filename);
01660 }
01661 
01662 
01663 function getVersion($filename) {
01664         $version = "&ndash;";
01665         $contents = file_get_contents($filename);
01666         $no_matches = preg_match("/Id: (\S+) (\d+.\d+)/i", $contents, $matches);
01667         if ($no_matches>0) $version = $matches[2];
01668         return $version;
01669 }
01670 
01671 
01675 function getDescription($filename) {
01676         GLOBAL $descriptions, $descriptionFilenamesCaseSensitive;
01677         
01678         if (!$descriptionFilenamesCaseSensitive) {
01679                 $filename = strtolower($filename);
01680         }
01681         return $descriptions[$filename];
01682 }
01683 
01684 function getPageLink($startNumber, $linkText, $linkTitle="") {
01685         GLOBAL $snifServer, $path;
01686         $url = "http://".$snifServer.$_SERVER["PHP_SELF"]."?path=".$path."&sort=".$_GET["sort"]."&order=".$_GET["order"]."&start=".$startNumber;
01687         if ($linkTitle!="") {
01688                 $titleAttribute = " title=\"$linkTitle\"";
01689         } else {
01690                 $titleAttribute = "";
01691         }
01692         return "<a href=\"$url\"$titleAttribute>$linkText</a>&nbsp;";
01693 }
01694 
01695 function getPagingHeader() {
01696         GLOBAL $pageStart, $usePaging, $pagingNumberOfPages, $pagingActualPage, $pageNumber, $files;
01697         static $displayPages = Array();
01698         if (count($displayPages)==0) {
01699                 $displayPages[] = 0;
01700                 for ($i=$pagingActualPage-1; $i<$pagingActualPage+3; $i++) {
01701                         if ($i>=0 && $i<$pagingNumberOfPages) {
01702                                 $displayPages[] = $i;
01703                         }
01704                 }
01705                 $displayPages[] = $pagingNumberOfPages-1;
01706                 $displayPages = array_unique($displayPages);
01707         }
01708         
01709         $header = translate("pages")."&nbsp;&nbsp;";
01710         if ($pageStart>0) {
01711                 $header.= getPageLink($pageStart-$usePaging, "&laquo;", translate("previous"));
01712         }
01713         if ($pageStart+$usePaging<count($files)) {
01714                 $header.= getPageLink($pageStart+$usePaging, "&raquo;", translate("next"));
01715         }
01716         foreach($displayPages as $i => $pageNumber) {
01717                 if ($pageNumber-$displayPages[$i-1] > 1) {
01718                         $header.= ".. ";
01719                 }
01720                 if ($pageNumber==$pagingActualPage) {
01721                         $header.= "<span class=\"snWhite\">".($pageNumber+1)."&nbsp;</span>";
01722                 } else {
01723                         $header.= getPageLink($pageNumber*$usePaging, $pageNumber+1);
01724                 }
01725         }
01726         
01727         return $header;
01728 }
01729 
01730 function getPathLink($directory) {
01731         GLOBAL $directDirectoryLinks;
01732         if ($directDirectoryLinks) {
01733                 return $directory."/";
01734         } else {
01735                 return $_SERVER["PHP_SELF"]."?path=".urlEncode($directory)."/";
01736         }
01737 }
01738 
01751 function iTrunc($string, $length) {
01752         if ($length==0) {
01753                 return $string;
01754         }
01755         if (strlen($string)<=$length) {
01756                 return $string;
01757         }
01758         
01759         $pos = strrpos($string,".");
01760         if ($pos>=$length-4) {
01761                 $string = substr($string,0,$length-4);
01762                 $pos = strrpos($string,".");
01763         }
01764         if ($pos>=$length*0.4) {
01765                 return substr($string,0,$pos+1)."...";
01766         }
01767         
01768         $pos = strrpos($string," ");
01769         if ($pos>=$length-4) {
01770                 $string = substr($string,0,$length-4);
01771                 $pos = strrpos($string," ");
01772         }
01773         if ($pos>=$length*0.4) {
01774                 return substr($string,0,$pos)."...";
01775         }
01776         
01777         return substr($string,0,$length-4)."...";
01778 }
01779 
01780 
01781 function getDirSize($dirname) {
01782         $dir = dir($dirname);
01783         $fileCount = 0;
01784         while ($filename = $dir->read()) {
01785                 if (!fileIsHidden($dirname."/".$filename)) 
01786                         $fileCount++;
01787         }
01788         return $fileCount-2; // . and .. do not count
01789 }
01790 
01791 
01792 /***************************************************************************/
01794 /***************************************************************************/
01795 
01796 // change directory
01797 // must be done before description file is parsed
01798 if ($path!="") {
01799         $hidden = fileIsHidden(substr($path,0,-1));
01800         if ($hidden || !@chdir($path)) {
01801                 $displayError[] = sprintf(translate("%s is not a subdirectory of the current directory."), $path);
01802                 $path = "";
01803         }
01804 } 
01805 $dir = dir(".");
01806 
01807 // parsing description file
01808 $descriptions = Array();
01809 if ($useDescriptionsFrom!="") {
01810         $descriptionsFile = @file($useDescriptionsFrom);
01811         if ($descriptionsFile!==false) {
01812                 for ($i=0;$i<count($descriptionsFile);$i++) {
01813                         $d = explode($separationString,$descriptionsFile[$i]);
01814                         if (!$descriptionFilenamesCaseSensitive) {
01815                                 $d[0] = strtolower($d[0]);
01816                         }
01817                         $descriptions[$d[0]] = htmlentities(join($separationString, array_slice($d, 1)));
01818                 }
01819         }
01820 }
01821 
01822 // build a two dimensional array containing the files in the chosen directory and their meta data
01823 $files = Array();
01824 while($entry = $dir->read()) {
01825         // if the filename matches one of the hidden files wildcards, skip the file
01826         if (fileIsHidden($entry))
01827                 continue;
01828                 
01829         // if the file is a directory and if directories are forbidden, skip it
01830         if (!$allowSubDirs AND is_dir($entry))
01831                 continue;
01832         
01833         $f = Array();
01834 
01835         $f["name"] = $entry;
01836         $f["isDownloadable"] = (substr(strtolower($entry), -4)!=".php") || $allowPHPDownloads;
01837         $f["isDirectory"] = is_dir($entry);
01838         $fDate = @filemtime($entry);
01839         $f["date"] = $fDate;
01840         $f["fullDate"] = date("r", $fDate);
01841         $f["shortDate"] = date(translate("DATEFORMAT"), $fDate);
01842         //setlocale(LC_ALL,"German");
01843         //$f["shortDate"] = strftime("%x");
01844         $f["description"] = getDescription($entry);
01845         if ($f["isDirectory"]) {
01846                 $f["type"] = "&lt;DIR&gt;";
01847                 $f["size"] = "";
01848                 $f["niceSize"] = "";
01849                 
01850                 // building the link
01851                 if ($entry=="..") {
01852                         // strip the last directory from the path
01853                         $pathArr = explode("/",$path);
01854                         $link = implode("/",array_slice($pathArr,0,count($pathArr)-2));
01855                         
01856                         // if there is no path set, don't add it to the link
01857                         if ($link=="") {
01858                                 // we're already in $baseDir, so skip the file
01859                                 if ($path=="")
01860                                         continue;
01861                                 $f["link"] = $_SERVER["PHP_SELF"];
01862                         } else {
01863                                 $link.= "/";
01864                                 $f["link"] = $_SERVER["PHP_SELF"]."?path=".urlEncode($link);
01865                         }
01866                         $f["isBack"] = true;
01867                         if ($useBackForDirUp) {
01868                                 $f["displayName"] = translate("[ back ]");
01869                         }
01870                 } else {
01871                         $filesInDir = getDirSize($entry);
01872                         if ($filesInDir==1) {
01873                                 $f["niceSize"] = translate("1 item");
01874                         } else {
01875                                 $f["niceSize"] = sprintf(translate("%d items"),$filesInDir);
01876                         }
01877                         $f["link"] = getPathLink($path.$entry);
01878                 }
01879         } else {
01880                 if (is_link($entry)) {
01881                         $linkTarget = readlink($entry);
01882                         $pi = pathinfo($linkTarget);
01883                         $scriptDir = dirname($_SERVER["SCRIPT_FILENAME"]);
01884                         if (strpos($pi["dirname"], $scriptDir)===0) {
01885                                 $f["type"] = "&lt;LINK&gt;";
01886                                 // links have no date, so take the target's date
01887                                 $f["date"] = filemtime($linkTarget);
01888                                 $f["link"] = $path.urlencode(substr($linkTarget, strlen($scriptDir)+1));
01889                         } else {
01890                                 // link target is outside of script directory, so skip it
01891                                 continue;
01892                         }
01893                 } else {
01894                         $fSize = @filesize($entry);
01895                         $f["size"] = $fSize;
01896                         $f["fullSize"] = number_format($fSize,0,".",",");
01897                         $f["niceSize"] = nicesize($fSize);
01898                         $pi = pathinfo($entry);
01899                         $f["type"] = $pi["extension"];
01900                         $f["link"] = myEncode($path,$entry);
01901                         if (in_array("cvsversion", $displayColumns)) {
01902                                 $f["cvsversion"] = getVersion($entry);
01903                         }
01904                 }
01905         }
01906         if (!$f["isBack"]) {
01907                 $f["displayName"] = htmlentities(iTrunc($f["name"], $truncateLength));
01908         }
01909         $f["filetype"] = getFileType($f);
01910         $f["icon"] = getIcon($f["filetype"]);
01911         if ($useAutoThumbnails && $f["filetype"]=="image") {
01912                 $f["thumbnail"] = "<a href=\"".urldecode($f["link"])."\"><img src=\"".$PHP_SELF."?thumbnail=".urlencode($path.$f["name"])."\" style=\"text-align: left;\" alt=\"\"/></a>";
01913         }
01914 
01915         $files[] = $f;
01916 }
01917 
01918 usort($files, "myCompare");
01919 
01920 
01921 $pagingInEffect = $usePaging>0 && count($files)>$usePaging;
01922 if ($usePaging>0) {
01923         $pageStart = $_GET["start"];
01924         if ($pageStart=="" || $pageStart<0 || $pageStart>count($files))
01925                 $pageStart = 0;
01926         $pagingActualPage = floor($pageStart / $usePaging);
01927         $pagingNumberOfPages = ceil(count($files) / $usePaging);
01928 } else {
01929         $pageStart = 0;
01930         $usePaging = count($files);
01931 }
01932 $pageEnd = min(count($files),$pageStart+$usePaging);
01933 
01934 
01935 
01936 /***************************************************************************/
01938 /***************************************************************************/
01939 
01940 $columns = count($displayColumns);
01941 
01942 Header("Content-Type: text/html; charset=UTF-8");
01943 echo "<?php xml version=\"1.0\" encoding=\"UTF-8\"?>";
01944 ?>
01945 
01946 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
01947 <html xmlns="http://www.w3.org/1999/xhtml">
01948         <head>
01949                 <title><?php echo translate("Index of")." ".htmlentities(dirname($_SERVER["PHP_SELF"])."/".$path);?></title>
01950                 <?php 
01951                 if ($externalStylesheet!="") {
01952                         ?>
01953                         <link rel="stylesheet" type="text/css" href="<?php echo $externalStylesheet?>" />
01954                         <?php 
01955                 }
01956                 ?>
01957                 <style type="text/css">
01958                 
01959                         /*** COLORS ***/
01960                         <?php 
01961                         if ($externalStylesheet=="") {
01962                         ?>
01963                         body.snif {
01964                                 background: #ffffff;             /* background behind table */
01965                         }
01966                         table.snif {
01967                                 border: 1px solid #444444;       /* main table border style */
01968                         }
01969                         td.snDir {
01970                                 color: #ffffff;                  /* table header text color */
01971                                 background-color: #000000;       /* table header background color */
01972                         }
01973                         td.snDir a {
01974                                 color:white;                     /* link text color within table header */
01975                         }
01976                         tr.snHeading, td.snHeading, td.snHeading a {
01977                                 color: #dddddd;                  /* column headings text color */
01978                                 background-color: #444444;       /* column headings background color */
01979                         }
01980                         tr.snF td a {
01981                                 color: #000000;                  /* file listing link text color (filename)*/
01982                         }
01983                         tr.snF td a:hover, a.snif:hover {
01984                                 background-color: #bbbbee;       /* file listing link hover background color */
01985                         }
01986                         tr.snEven {
01987                                 background-color: #eeeeee;       /* file listing background color for even numbered rows */
01988                         }
01989                         tr.snOdd {
01990                                 background-color: #dddddd;       /* file listing background color for odd numbered rows */
01991                         }
01992                         tr.snF td {
01993                                 color: #444444;                  /* file listing text color */
01994                         }
01995                         .snCopyright * {
01996                                 color: #bbbbbb;                  /* copyright notice text color */
01997                         }
01998                         .snWhite {
01999                                 color: white;                    /* active page in paging header */
02000                         }
02001                         <?php 
02002                         }
02003                         ?>
02004                         
02005                         /*** FONTS ***/
02006                         .snif * {
02007                                 font-family: Tahoma, Sans-Serif;
02008                                 font-size: 10pt;
02009                         }
02010                         .snif a, a.snif {
02011                                 text-decoration: none;
02012                         }
02013                         .snif a:hover, a.snif:hover {
02014                                 text-decoration: underline;
02015                         }
02016                         .snCopyright * {
02017                                 font-size: 8pt;
02018                         }
02019                         .snifSmaller {
02020                                 font-weight: normal;
02021                                 font-size: 8pt;
02022                         }
02023                         td.snDir {
02024                                 font-weight: bold;
02025                         }
02026                         tr.snHeading, td.snHeading, td.snHeading a {
02027                                 font-weight: bold;
02028                         }
02029                         
02030                         
02031                         /*** MARGINS AND POSITIONS ***/
02032                         table.snif {
02033                                 <?php 
02034                                 if ($tableWidth100Percent) {
02035                                         echo "width:100%;";
02036                                 }
02037                                 ?>
02038                         }
02039                         table.snif td {
02040                                 padding-left: 10px;
02041                                 padding-right: 10px;
02042                         }
02043                         table.snif td.littlepadding {
02044                                 padding-left: 4px;
02045                                 padding-right: 0px;
02046                         }
02047                         td.snDir {
02048                                 padding-top: 3px;
02049                                 padding-bottom: 3px;
02050                         }
02051                         tr.snHeading, td.snHeading, td.snHeading a {
02052                                 padding-top: 3px;
02053                                 padding-bottom: 3px;
02054                         }
02055                         tr.snF td {
02056                                 padding-top: 2px;
02057                                 padding-bottom: 2px;
02058                                 vertical-align: top;
02059                                 padding-left: 10px;
02060                                 padding-right: 10px;
02061                                 white-space: nowrap;
02062                         }
02063                         .snif img {
02064                                 border:none;
02065                         }
02066                         .snW {
02067                                 white-space: normal;
02068                         }
02069                 </style>
02070         </head>
02071 <body class="snif">
02072 <?php 
02073 if (count($displayError)>0) {
02074         foreach($displayError AS $error) {
02075                 echo "<b style=\"color:red\">$error</b><br/>";
02076         }
02077         echo "<br/>";
02078 }
02079 ?>
02080 <table cellpadding="0" cellspacing="0" class="snif">
02081         <tr>
02082                 <td class="snDir" colspan="<?php echo count($displayColumns)?>">
02083                         <?php 
02084                         $baseDirname = $snifServer.htmlentities(dirname($_SERVER["PHP_SELF"]));
02085                         $pathToSnif = explode("/",$baseDirname);
02086                         echo "http://".join("/",array_slice($pathToSnif, 0, -1))."/";
02087                         echo "<a href=\"".dirname($_SERVER["PHP_SELF"])."/\">".join("/",array_slice($pathToSnif, -1))."</a>";
02088                         $pathArr = explode("/",$path);
02089                         for ($i=0; $i<count($pathArr)-1; $i++) {
02090                                 $dirLink = getPathLink(join("/",array_slice($pathArr, 0, $i+1)));
02091                                 echo "/<a href=\"$dirLink\">".htmlentities($pathArr[$i])."</a>";
02092                         }
02093                         ?><br/>
02094                         <span class="snifSmaller"><?php echo $descriptions["."];?></span>
02095                 </td>
02096         </tr>
02097         <?php 
02098         if ($pagingInEffect) {
02099         ?>
02100         <tr class="snHeading">
02101                 <td class="snHeading" colspan="<?php echo count($displayColumns)?>">
02102                         <?php 
02103                         echo getPagingHeader();
02104                         ?>
02105                 </td>
02106         </tr>
02107 <?php 
02108         }
02109 ?>
02110         <tr class="snHeading">
02111                 <?php 
02112                 foreach($displayColumns AS $column) {
02113                         switch ($column) {
02114                                 case "download":
02115                                         ?>
02116                                         <td class="snHeading littlepadding">&nbsp;</td>
02117                                         <?php 
02118                                         break;
02119                                 case "icon":
02120                                         ?>
02121                                         <td class="snHeading littlepadding">&nbsp;</td>
02122                                         <?php 
02123                                         break;
02124                                 case "name":
02125                                         ?>
02126                                         <td class="snHeading">
02127                                                 <!--<img src="<?php echo $PHP_SELF?>?getimage=blank" alt="" width="30" height="16" style="vertical-align:middle;"/>--><a href="<?php echo getNewSortURL("name");?>"><?php echo translate("name");?></a>
02128                                                 <?php 
02129                                                 $sort = $_GET["sort"];
02130                                                 if ($sort=="name")
02131                                                         echo "<img src=\"".getIcon($_GET["order"])."\" width=\"5\" height=\"3\" style=\"vertical-align:middle;\" alt=\"".translate($_GET["order"])."\"/>";
02132                                                 ?>
02133                                         </td>
02134                                         <?php 
02135                                         break;
02136                                 case "type":
02137                                         ?>
02138                                         <td class="snHeading">
02139                                                 <a href="<?php echo getNewSortURL("type");?>"><?php echo translate("type");?></a>
02140                                                 <?php 
02141                                                 if ($sort=="type")
02142                                                         echo "<img src=\"".getIcon($_GET["order"])."\" width=\"5\" height=\"3\" style=\"vertical-align:middle;\" alt=\"".translate($_GET["order"])."\"/>";
02143                                                 ?>
02144                                         </td>
02145                                         <?php 
02146                                         break;
02147                                 case "size":
02148                                         ?>
02149                                         <td class="snHeading" align="right">
02150                                                 <?php 
02151                                                 if ($sort=="size")
02152                                                         echo "<img src=\"".getIcon($_GET["order"])."\" width=\"5\" height=\"3\" style=\"vertical-align:middle;\" alt=\"".translate($_GET["order"])."\"/>";
02153                                                 ?>
02154                                                 <a href="<?php echo getNewSortURL("size");?>"><?php echo translate("size");?></a>
02155                                         </td>
02156                                         <?php 
02157                                         break;
02158                                 case "date":
02159                                         ?>
02160                                         <td class="snHeading">
02161                                                 <a href="<?php echo getNewSortURL("date");?>"><?php echo translate("date");?></a>
02162                                                 <?php 
02163                                                 if ($sort=="date")
02164                                                         echo "<img src=\"".getIcon($_GET["order"])."\" width=\"5\" height=\"3\" style=\"vertical-align:20%;\" alt=\"".translate($_GET["order"])."\"/>";
02165                                                 ?>
02166                                         </td>
02167                                         <?php 
02168                                         break;
02169                                 case "description":
02170                                         ?>
02171                                         <td class="snHeading"<?php if ($descriptionColumnWidth>0) echo " style=\"width:".$descriptionColumnWidth."px;\"";?>><?php echo translate("description");?></td>
02172                                         <?php 
02173                                         break;
02174                                 case "cvsversion":
02175                                         ?>
02176                                         <td class="snHeading"><?php echo translate("CVS");?></td>
02177                                         <?php 
02178                                         break;
02179                         }
02180                 }
02181                 ?>
02182         </tr>
02183         <?php 
02184         for ($i=$pageStart;$i<$pageEnd;$i++) {
02185         ?>
02186         <tr class="snF <?php echo ($i%2==0) ? "snEven" : "snOdd"?>">
02187                 <?php 
02188                 foreach($displayColumns AS $column) {
02189                         switch ($column) {
02190                                 case "download":
02191                                         echo "<td class=\"littlepadding\">";
02192                                         if ($files[$i]["isDirectory"] OR !$files[$i]["isDownloadable"]) {
02193                                         ?>
02194                                                 <img src="<?php echo $PHP_SELF?>?getimage=blank" alt="" width="7" height="16" style="vertical-align:middle;"/>
02195                                         <?php 
02196                                         } else {
02197                                         ?>
02198                                                 <a href="<?php echo $PHP_SELF?>?path=<?php echo rawurlencode($path)?>&amp;download=<?php echo rawurlencode($files[$i]["name"]);?>"><img src="<?php echo getIcon("download")?>" alt="<?php echo translate("download");?>" title="<?php echo translate("download");?>" width="7" height="16" style="vertical-align:middle;"/></a>
02199                                         <?php 
02200                                         }
02201                                         echo "</td>";
02202                                         break;
02203                                 case "icon":
02204                                         echo "<td class=\"littlepadding\">";
02205                                         ?>
02206                                         <a href="<?php echo $files[$i]["link"];?>" title="<?php echo htmlentities($files[$i]["name"]);?>"><img src="<?php echo $files[$i]["icon"]?>" alt="" title="<?php echo translate($files[$i]["filetype"])?>" width="16" height="16" style="vertical-align:middle;"/></a>
02207                                         <?php 
02208                                         echo "</td>";
02209                                         break;
02210                                 case "name":
02211                                         echo "<td>";
02212                                         ?><a href="<?php echo $files[$i]["link"];?>" title="<?php echo htmlentities($files[$i]["name"]);?>"><?php 
02213                                         echo $files[$i]["displayName"]."&nbsp;</a>";
02214                                         echo "</td>";
02215                                         break;
02216                                 
02217                                 case "type":
02218                                         echo "<td>";
02219                                         echo $files[$i]["type"];
02220                                         echo "</td>";
02221                                         break;
02222                                 
02223                                 case "size":
02224                                         echo "<td align=\"right\">";
02225                                         if ($files[$i]["fullSize"]!="") echo "  <span title=\"".$files[$i]["fullSize"]." ".translate("Bytes")."\">";
02226                                         echo $files[$i]["niceSize"];
02227                                         if ($files[$i]["fullSize"]!="") echo "  </span>";
02228                                         echo "</td>";
02229                                         break;
02230                                 
02231                                 case "date":
02232                                         echo "<td>";
02233                                         echo "<span title=\"".$files[$i]["fullDate"]."\">".$files[$i]["shortDate"]."</span>";
02234                                         echo "</td>";
02235                                         break;
02236                                 
02237                                 case "description":
02238                                         ?><td class="snW" style="white-space: normal;">
02239                                         <?php 
02240                                         if ($files[$i]["filetype"]=="image") {
02241                                                 echo $files[$i]["thumbnail"];
02242                                         }
02243                                         ?>
02244                                         <?php echo $files[$i]["description"];?>
02245                                         </td><?php 
02246                                         break;
02247                                 
02248                                 case "cvsversion":
02249                                         echo "<td>";
02250                                         echo $files[$i]["cvsversion"];
02251                                         echo "</td>";
02252                                         break;
02253                         }
02254                 }
02255                 ?>
02256         </tr><?php 
02257         }
02258         if ($pagingInEffect) {
02259         ?>
02260         <tr class="snHeading">
02261                 <td class="snHeading" colspan="<?php echo $columns?>">
02262                         <?php 
02263                         echo getPagingHeader();
02264                         ?>
02265                 </td>
02266         </tr>
02267 <?php 
02268         }
02269 ?>
02270 </table>
02271 <div class="snCopyright">
02272 <br/>
02273 <a href="http://www.bitfolge.de/snif">
02274 snif 1.5.2
02275 &copy; 2003-04 Kai Blankenhorn</a><br/>
02276 <a href="http://validator.w3.org/check/referer"><?php echo translate("valid");?> XHTML 1.1</a>
02277 <a href="http://jigsaw.w3.org/css-validator/check/referer"><?php echo translate("valid");?> CSS 2</a>
02278 </div>
02279 </body>
02280 </html>

Generated on Fri Jun 6 22:21:09 2008 for CrocoPat by  doxygen 1.5.1