/[docman]/docman.php
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /docman.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.40 by dpavlin, Fri Apr 6 08:46:42 2001 UTC revision 1.45 by dpavlin, Thu Jun 21 08:56:35 2001 UTC
# Line 120  TODO: Line 120  TODO:
120          $gblImages   = array( ".jpg",".jpeg",".gif",".png",".ico",          $gblImages   = array( ".jpg",".jpeg",".gif",".png",".ico",
121                                ".bmp",".xbm") ;                                ".bmp",".xbm") ;
122    
123            // which files to hide (separated by ,)
124            $gblHide = "";
125    
126            // Where are users? (by default in .htusers file)
127            $gblUsers = "htusers_file";
128    
129  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
130    
131  function StartHTML($title,$text="") {  function StartHTML($title,$text="") {
# Line 630  function GifIcon($txt) { Line 636  function GifIcon($txt) {
636    
637  function Navigate($fsRoot,$relDir) {  function Navigate($fsRoot,$relDir) {
638    
639          global $gblEditable, $gblIcon, $gblModDays, $webRoot ;          global $gblEditable, $gblIcon, $gblModDays, $webRoot, $gblHide ;
640    
641          $self     = $GLOBALS["PHP_SELF"] ;          $self     = $GLOBALS["PHP_SELF"] ;
642    
# Line 638  function Navigate($fsRoot,$relDir) { Line 644  function Navigate($fsRoot,$relDir) {
644    
645          if (!is_dir($fsDir)) Error("Dir not found",$relDir) ;          if (!is_dir($fsDir)) Error("Dir not found",$relDir) ;
646    
647            $hide_items=",$gblHide,";
648    
649          // read directory contents          // read directory contents
650          if ( !($dir = @opendir($fsDir)) )          if ( !($dir = @opendir($fsDir)) )
651                  Error("Read Access denied",$relDir) ;                  Error("Read Access denied",$relDir) ;
652          while ($item = readdir($dir)) {          while ($item = readdir($dir)) {
653                  if ( $item == ".." || $item == "." || substr($item,0,1) == "." ) continue ;                  if ( substr($item,0,1) == "." || strstr($hide_items,",$item,") ) continue ;
654                  if ( is_dir($fsDir . $item) ) {                  if ( is_dir($fsDir . $item) ) {
655                          $dirList[] = $item ;                          $dirList[] = $item ;
656                  } else if ( is_file($fsDir . $item) ) {                  } else if ( is_file($fsDir . $item) ) {
# Line 661  function Navigate($fsRoot,$relDir) { Line 669  function Navigate($fsRoot,$relDir) {
669          // scan deleted files          // scan deleted files
670          if ( $GLOBALS[show_deleted] == 1 && ($dir = @opendir("$fsDir/.del")) ) {          if ( $GLOBALS[show_deleted] == 1 && ($dir = @opendir("$fsDir/.del")) ) {
671                  while ($item = readdir($dir)) {                  while ($item = readdir($dir)) {
672                          if ( substr($item,0,1) == "." ) continue ;                          if ( substr($item,0,1) == "." || strstr($hide_items,",$item,") ) continue ;
673                          $fileList[] = ".del/$item" ;                                      $fileList[] = ".del/$item" ;            
674                  }                  }
675                  closedir($dir) ;                  closedir($dir) ;
# Line 694  function Navigate($fsRoot,$relDir) { Line 702  function Navigate($fsRoot,$relDir) {
702  <?php  <?php
703          }          }
704    
705    function plural($name,$count) {
706            $out="$count $name";
707            if ($count > 1) {
708                    $out.="s";
709            }
710            return $out;
711    }
712    
713          // output subdirs          // output subdirs
714          if (sizeof($dirList) > 0) {          if (sizeof($dirList) > 0) {
715                  sort($dirList) ;                  sort($dirList) ;
716  ?>  ?>
717    
718  <TR><TD></TD><TD COLSPAN=2 CLASS=TOP>DIRECTORY NAME</TD><TD COLSPAN=3 CLASS=TOP>DIRECTORY NOTE</TR>  <TR><TD></TD><TD COLSPAN=2 CLASS=TOP>DIRECTORY NAME (<?= plural("dir",sizeof($dirList)) ?>)</TD><TD COLSPAN=3 CLASS=TOP>DIRECTORY NOTE</TR>
719    
720  <?php  <?php
721                  while (list($key,$dir) = each($dirList)) {                  while (list($key,$dir) = each($dirList)) {
# Line 724  function Navigate($fsRoot,$relDir) { Line 740  function Navigate($fsRoot,$relDir) {
740    
741  <TR><TD></TD><TD COLSPAN=5><HR><B><?= $webRoot . $relDir ?>  <TR><TD></TD><TD COLSPAN=5><HR><B><?= $webRoot . $relDir ?>
742  </B></TD></TR>  </B></TD></TR>
743  <TR><TD></TD><TD CLASS=TOP>DOCUMENT NAME</TD>  <TR><TD></TD><TD CLASS=TOP>DOCUMENT NAME (<?= plural("file",sizeof($fileList)) ?>)</TD>
744  <TD><?= $gblIcon("blank").$gblIcon("blank") ?></TD>  <TD><?= $gblIcon("blank").$gblIcon("blank") ?></TD>
745  <TD CLASS=TOP>NOTE</TD>  <TD CLASS=TOP>NOTE</TD>
746  <TD CLASS=TOP>LAST UPDATE</TD><TD CLASS=TOP>FILE SIZE</TD></TR>  <TD CLASS=TOP>LAST UPDATE</TD><TD CLASS=TOP>FILE SIZE</TD></TR>
# Line 977  function ReadNote($target) { Line 993  function ReadNote($target) {
993                  $msg=fgets($note,4096);                  $msg=fgets($note,4096);
994                  fclose($note);                  fclose($note);
995          }          }
996          return StripSlashes($msg);          return HtmlSpecialChars(StripSlashes($msg));
997    
998  }  }
999    
# Line 1167  function DisplayChangeLog($day) { Line 1183  function DisplayChangeLog($day) {
1183          // creation if password not yet set.          // creation if password not yet set.
1184          if ($STYLE == "get") { CSS() ; exit ; }          if ($STYLE == "get") { CSS() ; exit ; }
1185    
1186          $htusers_file=dirname($SCRIPT_FILENAME)."/.htusers";          $fsScriptDir  = dirname($SCRIPT_FILENAME) ;    
1187          if (! file_exists($htusers_file)) {          // i.e. /home/httpd/html/docman
1188                  if (is_writeable(dirname($SCRIPT_FILENAME))) {  
1189                          $htusers=fopen($htusers_file,"a+");          // read user-defined configuration
1190                          fputs($htusers,"# Change owner of $htusers_file to root !!\n");          if (file_exists("$fsScriptDir/.docman.conf")) {
1191                          fputs($htusers,"demo:full name:[md5_hash|auth_*]:e-mail\n");                  include("$fsScriptDir/.docman.conf");
                         fclose($htusers);  
                         Error("Proto user file created!","Please edit <tt>$htusers_file</tt> and set it correct permissions (<B>not writable by web server as it is now!</b>). You can add users using <tt>adduser.pl</tt> script!");  
                         exit;  
                 } else {  
                         Error("Can't create proto user file!","Please make directory <tt>".dirname($htusers_file)."</tt> writable or create <tt>.htusers</tt> file by hand using <tt>adduser.pl</tt> script!");  
                         exit;  
                 }  
1192          }          }
1193          $htusers=fopen($htusers_file,"r");  
1194          while($user = fgetcsv($htusers,255,":")) {          // where do we get users from?
1195                  if ($user[0] == $GLOBALS["PHP_AUTH_USER"]) {          if (file_exists("$gblIncDir/$gblUsers.php")) {
1196                          $gblUserName=$user[1];                  include("$gblIncDir/$gblUsers.php");
1197                          $gblPw=$user[2];          } else {
1198                          if (substr($gblPw,0,5) == "auth_" && file_exists("$gblIncDir/$gblPw.php")) {                  Error("Configuration error","Can't find user handling module at <tt>$gblIncDir/$gblUsers.php</tt> ! Please fix <tt>$fsScriptDir/.docman.conf</tt>");
                                 require("$gblIncDir/$gblPw.php");  
                                 if ($gblPw($user)) {  
                                         $gblPw=md5($PHP_AUTH_USER.$PHP_AUTH_PW);  
                                 } else {  
                                         $gblPw="error".md5($PHP_AUTH_USER.$PHP_AUTH_PW);  
                                 }  
                         }  
                         $gblEmail=$user[3];  
                         continue ;  
                 }  
1199          }          }
         fclose($htusers);  
1200    
1201          // authentication failure          // authentication failure
1202          if ( md5($PHP_AUTH_USER.$PHP_AUTH_PW) != $gblPw ||          if ( md5($PHP_AUTH_USER.$PHP_AUTH_PW) != $gblPw ||
# Line 1230  function DisplayChangeLog($day) { Line 1228  function DisplayChangeLog($day) {
1228          $relScriptDir = dirname($SCRIPT_NAME) ;                  $relScriptDir = dirname($SCRIPT_NAME) ;        
1229          // i.e. /docman          // i.e. /docman
1230    
         $fsScriptDir  = dirname($SCRIPT_FILENAME) ;      
         // i.e. /home/httpd/html/docman  
   
1231          // start on server root          // start on server root
1232  //      $gblFsRoot = substr($fsScriptDir,0, strlen($fsScriptDir)-strlen($relScriptDir)) ;  //      $gblFsRoot = substr($fsScriptDir,0, strlen($fsScriptDir)-strlen($relScriptDir)) ;
1233          // or on script root          // or on script root
# Line 1251  function DisplayChangeLog($day) { Line 1246  function DisplayChangeLog($day) {
1246    
1247          $FN=stripSlashes($FN);          $FN=stripSlashes($FN);
1248    
         if (file_exists("$fsScriptDir/.docman.conf")) {  
                 include("$fsScriptDir/.docman.conf");  
         }  
1249    
1250          switch ($POSTACTION) {          switch ($POSTACTION) {
1251          case "UPLOAD" :          case "UPLOAD" :

Legend:
Removed from v.1.40  
changed lines
  Added in v.1.45

  ViewVC Help
Powered by ViewVC 1.1.26