Location: PHPKode > scripts > EXPOW > expow/autoindex.php
<?php
/*
  autoindex.php                                             Part of Expow 0.8
  Copyright (c) 2000-2001 Rémy Lalanne.

  I___OVERVIEW_______________________________________________________________
  This file produces an html document that presents a view of a directory.
  This script makes a c_browser_gui_html object under $c_browser variable,
  and outputs its html table.

  II__FEATURES_______________________________________________________________
  Based on class.browser.php and its viewer browser_viewer.php.
  Defines some more variables for mostly gui part.
  Configured for using as an Apache auto_index script by default.
  You can also ask this script for a filename in $path variable.

  III_DIFFERENCES_WITH_APACHE_AUTOINDEX_______________________________________
   - Opens sub trees.
   - Unreadable files are not clickable.
   - No more "up" directory. Instead, upper directories appear in a left bar.
   - Doesn't support AddIcon, instead it uses c_browser_gui icon management.
   - Define file colors and overall view in style sheets.

  IV__CONFIG FILES___________________________________________________________
  Looks in different places for config file:
             - in the expow.conf file of the same directory
             - in $cfg_file value

  V___THIS PAGE HTML TAGS____________________________________________________
  <body>,<table>,<tr>,<th>,<td>,<div>,<div.side>,<form>,<input>,<a>,<br>
  edit class.browser.php to see its html tags.

  VI__LICENSE TERMS__________________________________________________________
  This file is under GNU GPL License. 
  The author is Rémy Lalanne.
*/

include("src/class.browser.php"); // the browser class to use
include("src/browser_functions.php");
$c_browser = new c_browser_gui_html();

#
# Default values, in case we cannot find expow.conf. Do not edit.
# Edit expow.conf for configuration, where variables are documented.
#
# default values for this file
$visu_gui = false;            
$side_gui = false; 
$root_is_url = true; 
# default values for autoindex
$indexof = true;
$readme_name = "README";        
$dir_info = true; 
# default values for c_browser
$c_browser->DOCUMENT_ROOT = $DOCUMENT_ROOT;
$c_browser->root_URL = "/";
$c_browser->path = urldecode(substr(str_replace("?$QUERY_STRING","",$REQUEST_URI),1));
# DIRECT SCRIPT CALL MODE
# In case this file is not default autoindex, we use $path variable.
# not autoindexed
if (!strcmp(str_replace("?$QUERY_STRING","",$REQUEST_URI),$PHP_SELF) ){
  # $c_browser->path = false;
  $c_browser->path = urldecode($path);
  if (isset($path))
    $c_browser->href_args .= "&path=$path";  # if $path is specified we keep it
}
$c_browser->sub_path = urldecode($sub);
$c_browser->subpath_var = "sub";
# default values for c_browser_gui_html
$c_browser->anchor1->props["target"] = "_self";
# Force sub click to same URI
# Do to a Gecko bug we must place this before "?" :
$c_browser->anchor2->props["href"] = str_replace("?$QUERY_STRING","",$REQUEST_URI);

#
# Extern config file
# if $cfg_file is valid we keep it
#
include("expow.conf");
if (isset($cfg_file))
  if (!include($cfg_file))
    echo "The specified config file was not found.\n";
  else
    $c_browser->href_args = "&cfg_file=$cfg_file";

if($overlib_file) $c_browser->ol_flag = true;

if ($debug){
  echo "true DOCUMENT_ROOT=".$DOCUMENT_ROOT."<br>";
  echo "QUERY_STRING: ".$QUERY_STRING."<br>";
  echo "cwd=".getcwd()."<br>";
  echo "DOCUMENT_ROOT=".$c_browser->DOCUMENT_ROOT."<br>";
  echo "root_URI=".$c_browser->root_URL."<br>";
  echo "path=".$c_browser->path."<br>";
  echo "sub_path=".$c_browser->sub_path."<br>";
  echo "icon_dir=".$c_browser->icon_dir."<br>";
}

if (!$c_browser->DOCUMENT_ROOT){
  echo "You need to set the browser's DOCUMENT_ROOT variable.
        Please edit expow.conf.";
  exit;
}
$side_w = $side_width;
while($side_w){
  $ruller .= "O";
  $side_w--;
}

#
# VISUALISATION GUI
#
if ($visu_gui){
  /* process result from zoom and view mode guis */
  if (!strcmp($zoom_manip,"+"))
    $c_browser->zoom_percent = $zoom*2;
    //$c_browser->zoom_percent = $zoom = $zoom*2;
  if (!strcmp($zoom_manip,"-"))
    $c_browser->zoom_percent = $zoom/2;
    //$c_browser->zoom_percent = $zoom = $zoom/2;
  ob_start();
?>
<!-- VISU GUI START -->
<form method=post enctype="multipart/form-data">
 visu:
 <input type=submit name=view_mode value=lines>
 <input type=submit name=view_mode value=icons>
</form>
<form method=post enctype="multipart/form-data">
 zoom:<?php echo $c_browser->zoom_percent;?>%
 <input type=submit name=zoom_manip value="-">
 <input type=submit name=zoom_manip value="+">
 <input type=hidden name=zoom value="<?php echo $c_browser->zoom_percent;?>">
 <input type=hidden name=view_mode value="<?php echo $view_mode;?>">
</form>
<!-- VISU GUI END -->
<?php
  $visu = ob_get_contents();
  ob_end_clean();
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
 <title>[EXPO] Index of <?php echo $c_browser->root_URL.$c_browser->path;?></title>
 <meta name="generator" content="Expow http://explow.multimania.com">
 <link rel="stylesheet" href="<?php echo $style_sheet; ?>" type="text/css">
 <link rel="stylesheet" href="<?php echo $file_css; ?>" type="text/css">
</head>
<body>
<?php if ($overlib_file){ ?>
<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
<script language="JavaScript" src="<?php echo $overlib_file;?>"><!-- overLIB (c) Erik Bosrup --></script>
<?php } ?>

<?php if ($edition_file && is_writeable($c_browser->get_intern_path())){ ?>
<!-- EDITION BEGINS -->
<?php include($edition_file); ?>
<!-- EDITION ENDS -->
<?php } ?>

<?php
if ($visu_gui == "top")
  echo $visu;
if ($side_gui){
#
# SIDE
#
?>
<table cellspacing=0>
 <tr>
  <td valign=top>
   <!-- SIDE BEGINS -->
   <div class="side">
    <table cellspacing=0 height=100%>
     <tr>
      <td valign=top class=side>
       <!-- SIDE TREE START -->
       <?php echo side_tree($c_browser, $side_width, $root_is_url); ?>
       <!-- SIDE TREE END -->
       <small>
        url: <a href="<?php echo $c_browser->get_url();?>">open</a><br><br>
        <hr>
        <?php if ($visu_gui == "side") echo $visu; ?>
       </small>
       <hr>
       <?php echo $side_html; ?>
       <font class=ruller><?php echo $ruller;?></font>
      </td>
     </tr>
    </table>
   </div>
   <font class=ruller><?php echo $ruller;?></font>
   <!-- SIDE ENDS -->
  </td>
  <td valign=top width=100%>
<?php
}
#
# CONVENTIONNAL INDEX #######
#
# $debug = 1;
?>

<?php if ($indexof){ ?>
   <!-- INDEX MENUBAR START -->
   <h1>Index of 
    <?php echo $c_browser->root_URL.$c_browser->path;?>
    <?php if ($c_browser->sub_path) echo " [ ".$c_browser->sub_path." ]"; ?>
   </h1>
   <!-- INDEX MENUBAR END -->
<?php } ?>

   <!-- C_BROWSER VIEWER START -->
   <table cellspacing=0 width=100% class=browser>
<?php switch($view_mode) {
  case "icons": ?>
    <tr>
     <td>
      <?php $nb_files = output_icons($c_browser); ?>
     </td>
    </tr>
<?php
    break;
  default:
    $c_browser->line_head();
    $nb_files = sub_tree_output($c_browser->sub_tree_nblevels(),$c_browser);
    break;
}
?>
   </table>
   <!-- C_BROWSER VIEWER END -->

<? if ($dir_info){ ?>
   <!-- DIR PROPERTIES START -->
   <table width=100%>
    <tr>
     <th align=left>
      <?php echo $nb_files; ?> File(s).
     </th>
     <th align=right>
      Disk free space: <?php echo FormatTailleFichier(diskfreespace($c_browser->get_intern_path())); ?>
     </th>
    </tr>
   </table>
   <!-- DIR PROPERTIES END -->

<?php }

if ($readme_name && is_readable($c_browser->get_intern_path($readme_name))){ ?> 
   <!-- README FILE START -->
   <pre>
<?php readfile($c_browser->get_intern_path($readme_name)); ?>
   </pre>
   <!-- README FILE END -->
<?php }

if ($signature){ ?>
   <?php echo $SERVER_SIGNATURE; ?>
<?php }

if ($side_gui){ ?>
  </td>
 </tr>
</table>
<?php } ?>
</body>
</html>
Return current item: EXPOW