This is PHP (3 or 4 actually) => see http://www.php.net/ See http://web-file-viewer.sourceforge.net/ for details. Request possible parameters (only one at once): d: the path of the current directory f: the path of the file to display or download t: the path of a image file to display the associated thumbnail picture Data you can adapt: */ $max_col_number=4; # Maximum number of columns in the table // Icon path directory (without trailing /): $icP='/.Icons'; /* Colors: purple bg (wheat=#f7dfb5): $Color=Array('text' => '#fff', 'bgcolor' => '#504050', 'link' => '#80BBFF', 'vlink' => '#f7dfb5', 'alink' => '#fff', 'shift' => '#403040', 'box' => '#fff', 'highlight' => '#fff', 'em' => '#504050', 'low' => '#D0D0D0'); // Colors: orange bg: $Color=Array('text' => '#000', 'bgcolor' => '#fb8', 'link' => '#c13', 'vlink' => '#000', 'alink' => '#fff', 'shift' => '#c13', 'box' => '#c13', 'highlight' => '#fff', 'em' => '#000', 'low' => '#eee'); */ // Colors: light grey bg: $Color=Array( 'text' => '#000', 'bgcolor' => '#eee', 'link' => '#000', 'vlink' => '#777', 'alink' => '#000', 'shift' => '#aaa', 'box' => '#777', 'highlight' => '#fff', 'em' => '#000', 'low' => '#eee'); $max_width=160; # Maximum width for thumbnails (in pixels) $max_height=120; # Maximum height for thumbnails (in pixels) $max_x2display=800; # Maximum image width to display (in pixels) $max_size2display=200; # Maximum file size to display (in kBytes) $min_height2target=350; # Minimum height for pictures to set a anchor # Filenames filters (case insensitive regular expresions to exclude): $filter=Array('^\.', '\.ico$', 'css$', 'index\.*', 'CVS', 'Thumbs.db'); $confile='.wfvrc.php'; # Specific directory configuration file (optional) $globconf='.wfvgrc.php'; # Global configuration filename $global_intro='.global-intro.html'; # Introduction HTML file $dir_intro='.dir-intro.html'; # Introduction HTML file $thumbdir='.thumbnails'; # Thumbnails directory #$refresh_delay=60; # Number of seconds to wait before refresh /******** End of what users can change (use configuration files as well) ******/ if (array_key_exists('t', $_REQUEST)) { if (function_exists('exif_thumbnail')) { $image=exif_thumbnail($_REQUEST['t'], $width, $height, $type); if ($image!==false) { header('Content-type: ' .image_type_to_mime_type($type)); echo $image; exit; } else die('No thumbnail available in this picture.'); } else die('PHP version too old!'); } ?> $msg\n\tPlease, go back.\n\n"; #echo "\n"; exit; } # For a better presentation of warnings: function warning ($msg) { echo "
$msg
\n\n"; } # Display information in DEBUG mode: function comment ($debug_msg, $indent_string='') { global $DEBUG; if ($DEBUG) echo "$indent_string\n"; } # Display variable content in DEBUG mode: function dispVar ($var_name) { global $DEBUG, $$var_name; comment("dispVar(): $var_name = '".$$var_name."'"); } if ($REQUEST_URI=='') foreach($_SERVER as $key => $val) if (!is_numeric($key)) $$key=$val; $DEBUG=($SERVER_NAME=='127.0.0.1'); # Debug mode # Constants for HTML <-> texte translations: if (function_exists('get_html_translation_table')) { $TXT2HTML=get_html_translation_table(HTML_ENTITIES); $HTML2TXT=array_flip($TXT2HTML); } dispVar('SERVER_NAME'); dispVar('REQUEST_URI'); $dir_name=$REQUEST_URI; $dir_name=ereg_replace('\?.*$', '', $dir_name); # Hide parameters dispVar('dir_name'); $dir_name=ereg_replace('^.*://[^/]*/', '', $dir_name); # Hide domain name dispVar('dir_name'); #$dir_name=ereg_replace('/$', '', $dir_name); $dir_name=ereg_replace('/[^/]*$', '', $dir_name); dispVar('dir_name'); $d=stripSlashes($_REQUEST[d]); if (isset($_REQUEST[f])) { $f=stripSlashes($_REQUEST[f]); if (ereg('\/', $f)) $d=ereg_replace('\/[^\/]*$', '', $f); else $d=''; } dispVar('d'); dispVar('PHP_SELF'); $this_file=ereg_replace('^.*/', '', $PHP_SELF); dispVar('this_file'); $h1_title='/'.basename($dir_name); dispVar('h1_title'); if ($h1_title=='/') $h1_title="/$HTTP_HOST"; if (!$d) $d='.'; else { $dir_name.="/$d"; $h1_title.="/$d"; } $h1_title=strtr($h1_title, '_', ' '); $page_title=basename($h1_title); $h1_title=ereg_replace('/', ' > ', $h1_title); dispVar('page_title'); // Read the configuration file: // - the global one: if (is_readable($globconf)) { include $globconf; comment("Global configuration file: \"$globconf\" read"); } // - the directory specific one: $confile="$d/$confile"; if (is_readable($confile)) { include $confile; comment("Configuration file: \"$confile\" read"); } $nbfilters=sizeof($filter); if ($DEBUG) { for($j=0; $j<$nbfilters; $j++) echo "\n"; # Debug display } # Supported file extensions (in lowercase here ; uppercase are also supported): $Ext=Array( 'text' => Array('txt', 'sh', 'csv', 'conf', 'cfg', 'ini', 'sql', 'btab'), 'img' => Array('jpg', 'jpeg', 'gif', 'png') ); if ($d!='.') $page_title=strtr(basename($d), '_', ' '); dispVar('page_title'); if (empty($page_title)) $page_title=$HTTP_HOST; if (empty($h1_title)) $h1_title=$HTTP_HOST; // Security check: if (ereg('\.\.', $d) || ereg('^/', $d)) { $alert=1; $page_title="$d Access denied!"; $h1_title='Unauthorized access detected!'; } else $alert=0; // Set colors (example: textCol='White'): reset($Color); while(list($type, $color)=each($Color)) ${$type.'Col'}=$color; ?> <?=$page_title?> 0) echo " \n"; // Here is the style sheet where you can change the decoration: ?>

<= Parent directory"; echo " |\n"; echo "\tHome"; } else echo "\t "; ?> Directory revision date: '; echo date('G:i:s T.', $stat_id[9]); ?>
0) { $unit='second'; if ($refresh_delay>=3600 && $refresh_delay%3600==0) { $refresh_delay/=3600; $unit='hour'; } elseif ($refresh_delay>=60 && $refresh_delay%60==0) { $refresh_delay/=60; $unit='minute'; } if ($refresh_delay>1) $unit.='s'; else $refresh_delay=''; echo "( Auto refresh every $refresh_delay $unit )"; } else echo ' '; ?>
1024) { $file_size=(int)($file_size/1024); $unit='k'; } $extl=strToLower($ext); if (inArray($extl, $Ext['img'])) { # Get the images width & height: $size=@getImageSize($file); if (is_array($size)) { $width=$size[0]; $height=$size[1]; $reduce=' '.$size[3]; $type=$size[2]; $comment=$width."x$height $file_size$unit"; # Retreive EXIF information if available (JPEG only): $exif_data=''; if ($type==2 && function_exists('read_exif_data')) { $exif=read_exif_data($file); $exif_data='/ '; $EmData=Array('ApertureValue', 'ExposureTime', 'FocalLength', 'Make', 'Model', 'ExifImageWidth', 'ExifImageLength', 'ISOSpeedRatings'); while(list($k, $v)=each($exif)) { if (is_array($v)) $v=implode(' ; ', $v); else $v=str_replace(' ', ' ', $v); $addon="$k: $v /\n "; foreach($EmData as $emData) if ($k==$emData) { $addon="$addon"; break; } $addon=ereg_replace('f/([0-9.]+)', 'f/\\1', $addon); $v=trim($v); if ($v!='' && $k!='FileName' && $k!='ModeArray' && // Filter $k!='ImageInfo' && strpos($k, 'UndefinedTag')===FALSE && ctype_print($v)) $exif_data.=$addon; } } $alt=ereg_replace('[-_]', ' ', $sufx); $title="$name ($comment)"; $name=ucfirst($name); $f = str_replace(' ', '%20', $f); echo " \"$alt\"\n
\n"; } else $title='Image does not exist!'; echo " $title
\n"; echo " $exif_data
\n
\n"; } elseif (inArray($extl, $Ext['text'])) { echo "
\n"; $fcontent=join( '', file( $file ) ); if (eregi('\n", $fcontent); $fcontent=preg_replace( '/([">]) /', '\\1 ', $fcontent); $fcontent=preg_replace( '/ ([":;!])/', ' \\1', $fcontent); $fcontent="

\n$fcontent

"; } ?>

Show/Download this file as plain text ]

\n\n"; echo "
\n"; } else { ?>

Download  ]

\n"; readfile($global_intro); echo " \n\n"; } # Insert the introduction file if it exists in the current directory: $dir_intro="$d/$dir_intro"; if (!empty($dir_intro) && file_exists($dir_intro)) { echo " \n"; readfile($dir_intro); echo " \n\n"; } ?> \n"; $tr_closed=1; // Read filenames to sort them first: dispVar('alert'); dispVar('d'); if (!$alert && $dir=@opendir($d)) { $nb_td=0; $Files=Array(); $dirMark=' 0_DIR_0 '; $markLength=strLen($dirMark); while($file=readdir($dir)) { if (is_dir("$d/$file")) $file="$dirMark$file"; // To place first directories $Files[]=$file; } closedir($dir); sort($Files); # And then display them: $i=0; $L=sizeof($Files); while($i<=$L && $name=$Files[$i++]) { if (ereg("^$dirMark", $name)) $name=subStr($name, $markLength); $basename=$name; if ($d=='.') $file=$name; else $file="$d/$name"; dispVar('file'); $isDir=is_dir($file); # Is this file readable? if (!is_readable($file)) continue; $perms=filePerms($file); // 33188=readable | 33184=not readable comment("File $i/$L: \"$basename\", mod=$perms", "\n\t"); if ($perms==33184 || $perms==33152) continue; for($j=0; $j<$nbfilters; $j++) { #comment("Filter $j/$nbfilters: $filter[$j]"); if (eregi($filter[$j], $basename)) continue 2; } #comment('After filtering', "\t"); $ext=''; $sep='.'; $link = str_replace(' ', '%20', $file); #$basename=ereg_replace('^.*\/', '', $file); if ($isDir) { # Directory case: $link="?d=$link"; $file="$file/"; $sep='/'; $name=ucfirst($name); $byte_file_size=0; } else { # Simple file case: if (ereg('\.', $basename)) { $ext=ereg_replace('^.*\.([^\.]*)$', '\\1', $basename); $name=ereg_replace('^(.*)\.[^\.]*$', '\\1', $basename); } # Get the file size: $stats=stat($file); $byte_file_size=$stats[7]; $unit='B'; $file_size=$byte_file_size; if ($file_size>1024) { $file_size=(int)($file_size/1024); $unit='k'; } if ($file_size>1024) { $file_size=(int)($file_size/1024); $unit='M'; } } # If we need a new line: if (!$nb_td) { echo ' '; $tr_closed=0; } else echo ' '; echo '"; if (++$nb_td>=$max_col_number) { # End of line: echo "\n"; $tr_closed=1; $nb_td=0; } else echo "\n\t"; continue; } if (!is_readable($thumb) && ($width>$max_width || $height>$max_height)) { if ($width-$max_width<$height-$max_height) $reduce=" height=\"$max_height\""; else $reduce=" width=\"$max_width\""; } $link = str_replace(' ', '%20', $link); $file = str_replace(' ', '%20', $file); echo "($comment)
\n"; echo "\t \"$alt\"\n";
"; } else echo "
"; echo "$name"; if ($isDir || !empty($ext)) echo "$sep$ext"; if (!$isDir) echo "
($file_size$unit)"; echo '
'; if (++$nb_td>=$max_col_number) { echo "\n"; $tr_closed=1; $nb_td=0; } else echo "\n\t"; } if (!$tr_closed) { echo "\n"; $tr_closed=1; } } elseif (!$dir) error("\"$d\" directory cannot be read!"); ?>

'; $extl=strtolower($ext); if (inArray($extl, $Ext['text'])) $link="?f=$link#t"; if ($isDir) $name="'. "
\n\t\t$name"; # Is this a showable image file? if ($ext=='url') { $fid=fopen($file, 'r'); $link=fgetss($fid, 512); fclose($fid); $link=trim($link); $link = preg_replace('@&([^a])@', '&\1', $link); echo ""; /* $name="'. "
\n\t\t$name"; */ } elseif (inArray($extl, $Ext['img'])) { $tlink="?t=$link"; $link = str_replace(' ', '%20', $link); $link="?f=$link"; $name=ucfirst($name); # Get the images width & height: if ($byte_file_size) { $size=getImageSize($file); $width=$size[0]; $height=$size[1]; $reduce=' '.$size[3]; #$type=$size[2]; $comment=$width."x$height"; } else $comment='File empty!'; if ($height>$min_height2target) $link.='#t'; $title=$comment; #$alt='Loading...'; $sufx=ereg_replace('\.[^\.\/]*$', '', $basename); $alt=ereg_replace('[-_]', ' ', $sufx); # Get the thumbnail if it exists: $thumb="$d/$thumbdir/$basename"; #dispVar('reduce'); # If image file is empty or too big: if (is_readable($thumb)) { comment('Use file thumbnail.'); if ($width>$max_x2display) $link=$file; $file=$thumb; $reduce=''; } elseif ($byte_file_size && ($extl=='jpg' || $ext=='jpeg') && function_exists('exif_thumbnail') && exif_thumbnail($file, $w, $h, $t)!==false) { comment('Use EXIF thumbnail.'); if ($width>$max_x2display) $link=$file; $file=$tlink; $reduce=''; } elseif ($byte_file_size && $width<=$max_x2display && ($byte_file_size/1024)<$max_size2display) { comment('Reduce the picture size with HTML...'); if ($width>$max_x2display) $link=$file; #$file=$link; $reduce=''; } else { comment('Thumbnail not available.'); $file = str_replace(' ', '%20', $file); if ($byte_file_size) echo ""; echo $name; if ($byte_file_size) echo '
'; echo "$sep$ext
\n"; echo "\t ($comment - $file_size $unit)

Powered by Web File Viewer W3C XHTML 1.1 certified W3C CSS valid WFV revision date: