/[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.38 by dpavlin, Tue Mar 27 10:54:02 2001 UTC revision 1.47 by dpavlin, Wed Oct 31 08:23:35 2001 UTC
# Line 78  TODO: Line 78  TODO:
78          // from where to include auth_*.php modules?          // from where to include auth_*.php modules?
79          $gblIncDir = "/home/httpd/docman";          $gblIncDir = "/home/httpd/docman";
80    
81            // do we want to force download? (default is 0 for backward
82            // compatibility, but it's defined as 1 in docman.conf for all
83            // future applications!
84            $gblForceDownload = 0;
85    
86          // username/password should not be system          // username/password should not be system
87          // usernames/passwords !!          // usernames/passwords !!
88    
# Line 120  TODO: Line 125  TODO:
125          $gblImages   = array( ".jpg",".jpeg",".gif",".png",".ico",          $gblImages   = array( ".jpg",".jpeg",".gif",".png",".ico",
126                                ".bmp",".xbm") ;                                ".bmp",".xbm") ;
127    
128            // which files to hide (separated by ,)
129            $gblHide = "";
130    
131            // Where are users? (by default in .htusers file)
132            $gblUsers = "htusers_file";
133    
134  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
135    
136            $gblVersion = "1.8-dev";
137    
138  function StartHTML($title,$text="") {  function StartHTML($title,$text="") {
139    
140          $title = "Document Manager " . $title ;          $title = "Document Manager " . $title ;
# Line 132  function StartHTML($title,$text="") { Line 145  function StartHTML($title,$text="") {
145  <HTML>  <HTML>
146  <HEAD>  <HEAD>
147   <TITLE><?= $host . " " . $title ?></TITLE>   <TITLE><?= $host . " " . $title ?></TITLE>
148   <META NAME="description" CONTENT="PHP port of AnyPortal Site Manager">   <META NAME="description" CONTENT="Document Manager">
149   <META NAME="keywords" CONTENT="site manager, web site maintenance">   <META NAME="keywords" CONTENT="site manager, web site maintenance">
150   <META NAME="robots" CONTENT="noindex">   <META NAME="robots" CONTENT="noindex">
151   <META HTTP-EQUIV="expires" CONTENT="0">   <META HTTP-EQUIV="expires" CONTENT="0">
# Line 151  function StartHTML($title,$text="") { Line 164  function StartHTML($title,$text="") {
164  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
165    
166  function EndHTML() {  function EndHTML() {
167    
168    global $gblDateFmt, $gblTimeFmt, $gblUserName, $PHP_SELF, $gblPw, $gblVersion;
169    
170  ?>  ?>
171    
172  <HR>  <HR>
173  <P CLASS=FTR>  <P CLASS=FTR>
174  <B><?= date($GLOBALS[gblDateFmt]) ?> -  <B><?= date($gblDateFmt) ?> -
175  <?= date($GLOBALS[gblTimeFmt]) ?> -  <?= date($gblTimeFmt) ?> -
176  <?= $GLOBALS[gblUserName] ?>  <?= $gblUserName ?>
177  <small> [<a href="<?= $GLOBALS["PHP_SELF"] ?>?relogin=<?= $GLOBALS[gblPw] ?>">logout</a>]</small>  <small> [<a href="<?= $PHP_SELF ?>?relogin=<?= $gblPw ?>">logout</a>]</small>
178  </B>  </B>
179  <BR>ANYPORTAL(php) Site Manager  <BR><small>
180  <br><small>  Document Manager <?= $gblVersion ?>, based on ANYPORTAL(php) Site Manager
181    <br>
182  &copy; 1999 by <A HREF="http://www.anyportal.com">ANYPORTAL</A>,  &copy; 1999 by <A HREF="http://www.anyportal.com">ANYPORTAL</A>,
183  &copy; 2000 by <A HREF="http://da.nger.org">d@nger.org</A>,  &copy; 2000 by <A HREF="http://da.nger.org">d@nger.org</A>,
184  &copy; 2000 by <A HREF="http://www.rot13.org/~dpavlin/">DbP</A>  &copy; 2000 by <A HREF="http://www.rot13.org/~dpavlin/">DbP</A>
# Line 630  function GifIcon($txt) { Line 647  function GifIcon($txt) {
647    
648  function Navigate($fsRoot,$relDir) {  function Navigate($fsRoot,$relDir) {
649    
650          global $gblEditable, $gblIcon, $gblModDays, $webRoot ;          global $gblEditable, $gblIcon, $gblModDays, $webRoot, $gblHide ;
651    
652          $self     = $GLOBALS["PHP_SELF"] ;          $self     = $GLOBALS["PHP_SELF"] ;
653    
# Line 638  function Navigate($fsRoot,$relDir) { Line 655  function Navigate($fsRoot,$relDir) {
655    
656          if (!is_dir($fsDir)) Error("Dir not found",$relDir) ;          if (!is_dir($fsDir)) Error("Dir not found",$relDir) ;
657    
658            $hide_items=",$gblHide,";
659    
660          // read directory contents          // read directory contents
661          if ( !($dir = @opendir($fsDir)) )          if ( !($dir = @opendir($fsDir)) )
662                  Error("Read Access denied",$relDir) ;                  Error("Read Access denied",$relDir) ;
663          while ($item = readdir($dir)) {          while ($item = readdir($dir)) {
664                  if ( $item == ".." || $item == "." || substr($item,0,1) == "." ) continue ;                  if ( substr($item,0,1) == "." || strstr($hide_items,",$item,") ) continue ;
665                  if ( is_dir($fsDir . $item) ) {                  if ( is_dir($fsDir . $item) ) {
666                          $dirList[] = $item ;                          $dirList[] = $item ;
667                  } else if ( is_file($fsDir . $item) ) {                  } else if ( is_file($fsDir . $item) ) {
# Line 661  function Navigate($fsRoot,$relDir) { Line 680  function Navigate($fsRoot,$relDir) {
680          // scan deleted files          // scan deleted files
681          if ( $GLOBALS[show_deleted] == 1 && ($dir = @opendir("$fsDir/.del")) ) {          if ( $GLOBALS[show_deleted] == 1 && ($dir = @opendir("$fsDir/.del")) ) {
682                  while ($item = readdir($dir)) {                  while ($item = readdir($dir)) {
683                          if ( substr($item,0,1) == "." ) continue ;                          if ( substr($item,0,1) == "." || strstr($hide_items,",$item,") ) continue ;
684                          $fileList[] = ".del/$item" ;                                      $fileList[] = ".del/$item" ;            
685                  }                  }
686                  closedir($dir) ;                  closedir($dir) ;
# Line 694  function Navigate($fsRoot,$relDir) { Line 713  function Navigate($fsRoot,$relDir) {
713  <?php  <?php
714          }          }
715    
716    function plural($name,$count) {
717            $out="$count $name";
718            if ($count > 1) {
719                    $out.="s";
720            }
721            return $out;
722    }
723    
724          // output subdirs          // output subdirs
725          if (sizeof($dirList) > 0) {          if (sizeof($dirList) > 0) {
726                  sort($dirList) ;                  sort($dirList) ;
727  ?>  ?>
728    
729  <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>
730    
731  <?php  <?php
732                  while (list($key,$dir) = each($dirList)) {                  while (list($key,$dir) = each($dirList)) {
# Line 724  function Navigate($fsRoot,$relDir) { Line 751  function Navigate($fsRoot,$relDir) {
751    
752  <TR><TD></TD><TD COLSPAN=5><HR><B><?= $webRoot . $relDir ?>  <TR><TD></TD><TD COLSPAN=5><HR><B><?= $webRoot . $relDir ?>
753  </B></TD></TR>  </B></TD></TR>
754  <TR><TD></TD><TD CLASS=TOP>DOCUMENT NAME</TD>  <TR><TD></TD><TD CLASS=TOP>DOCUMENT NAME (<?= plural("file",sizeof($fileList)) ?>)</TD>
755  <TD><?= $gblIcon("blank").$gblIcon("blank") ?></TD>  <TD><?= $gblIcon("blank").$gblIcon("blank") ?></TD>
756  <TD CLASS=TOP>NOTE</TD>  <TD CLASS=TOP>NOTE</TD>
757  <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 822  function Navigate($fsRoot,$relDir) { Line 849  function Navigate($fsRoot,$relDir) {
849  <?  <?
850          }          }
851    
852          if ($emptyDir) {          if ($emptyDir && $relDir != "") {
853  ?>  ?>
854    
855  <FORM METHOD="POST" ACTION="<?= $self ?>">  <FORM METHOD="POST" ACTION="<?= $self ?>">
# Line 856  if (file_exists(".info.inc")) { Line 883  if (file_exists(".info.inc")) {
883   <NOBR>NAME <INPUT TYPE="TEXT" NAME="FN" SIZE=14>   <NOBR>NAME <INPUT TYPE="TEXT" NAME="FN" SIZE=14>
884   <INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="CREATE">   <INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="CREATE">
885   <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>">   <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>">
886   <INPUT TYPE="SUBMIT" VALUE="CREATE"></NOBR>   <INPUT TYPE="SUBMIT" VALUE="CREATE" NAME="CREATE">
887     </NOBR>
888   <NOBR>OR <A HREF="<?= $self ?>?A=U&D=<?= urlencode($relDir) ?>">UPLOAD</A> A FILE   <NOBR>OR <A HREF="<?= $self ?>?A=U&D=<?= urlencode($relDir) ?>">UPLOAD</A> A FILE
889   </NOBR>   </NOBR>
890  </TD></TR>  </TD></TR>
# Line 976  function ReadNote($target) { Line 1004  function ReadNote($target) {
1004                  $msg=fgets($note,4096);                  $msg=fgets($note,4096);
1005                  fclose($note);                  fclose($note);
1006          }          }
1007          return StripSlashes($msg);          return HtmlSpecialChars(StripSlashes($msg));
1008    
1009  }  }
1010    
# Line 1059  function urlpath($url) { Line 1087  function urlpath($url) {
1087    
1088  function safe_rename($fromdir,$fromfile,$tofile) {  function safe_rename($fromdir,$fromfile,$tofile) {
1089          function try_rename($from,$to) {          function try_rename($from,$to) {
1090                  print "$from -> $to\n";  #               print "$from -> $to\n";
1091                  if (file_exists($from) && is_writeable(dirname($to))) {                  if (file_exists($from) && is_writeable(dirname($to))) {
1092                          rename($from,$to);                          rename($from,$to);
1093                  }                  }
# Line 1075  function safe_rename($fromdir,$fromfile, Line 1103  function safe_rename($fromdir,$fromfile,
1103          $todir=dirname($to);          $todir=dirname($to);
1104          $tofile=basename($to);          $tofile=basename($to);
1105    
1106          print "<pre>$fromdir / $fromfile -> $todir / $tofile\n\n";  #       print "<pre>$fromdir / $fromfile -> $todir / $tofile\n\n";
1107    
1108          try_rename("$fromdir/$fromfile","$todir/$tofile");          try_rename("$fromdir/$fromfile","$todir/$tofile");
1109          try_dir("$todir/.log");          try_dir("$todir/.log");
# Line 1150  function DisplayChangeLog($day) { Line 1178  function DisplayChangeLog($day) {
1178    
1179  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
1180    
1181    function Download($path) {
1182            global $HTTP_USER_AGENT;
1183            $file=basename($path);
1184            $size = filesize($path);
1185            //header("Content-Type: application/octet-stream");
1186            header("Content-Type: application/force-download");
1187            header("Content-Length: $size");
1188            // IE5.5 just downloads index.php if we don't do this
1189            if(preg_match("/MSIE 5.5/", $HTTP_USER_AGENT)) {
1190                    header("Content-Disposition: filename=$file");
1191            } else {
1192                    header("Content-Disposition: attachment; filename=$file");
1193            }
1194            header("Content-Transfer-Encoding: binary");
1195            $fh = fopen($path, "r");
1196            fpassthru($fh);
1197    }
1198    
1199    
1200    //////////////////////////////////////////////////////////////////
1201    
1202  // MAIN PROGRAM  // MAIN PROGRAM
1203  // ============  // ============
1204  // query parameters: capital letters  // query parameters: capital letters
# Line 1166  function DisplayChangeLog($day) { Line 1215  function DisplayChangeLog($day) {
1215          // creation if password not yet set.          // creation if password not yet set.
1216          if ($STYLE == "get") { CSS() ; exit ; }          if ($STYLE == "get") { CSS() ; exit ; }
1217    
1218          $htusers_file=dirname($SCRIPT_FILENAME)."/.htusers";          $fsScriptDir  = dirname($SCRIPT_FILENAME) ;    
1219          if (! file_exists($htusers_file)) {          // i.e. /home/httpd/html/docman
1220                  if (is_writeable(dirname($SCRIPT_FILENAME))) {  
1221                          $htusers=fopen($htusers_file,"a+");          // read user-defined configuration
1222                          fputs($htusers,"# Change owner of $htusers_file to root !!\n");          if (file_exists("$fsScriptDir/.docman.conf")) {
1223                          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;  
                 }  
1224          }          }
1225          $htusers=fopen($htusers_file,"r");  
1226          while($user = fgetcsv($htusers,255,":")) {          // where do we get users from?
1227                  if ($user[0] == $GLOBALS["PHP_AUTH_USER"]) {          if (file_exists("$gblIncDir/$gblUsers.php")) {
1228                          $gblUserName=$user[1];                  include("$gblIncDir/$gblUsers.php");
1229                          $gblPw=$user[2];          } else {
1230                          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 ;  
                 }  
1231          }          }
         fclose($htusers);  
1232    
1233          // authentication failure          // authentication failure
1234          if ( md5($PHP_AUTH_USER.$PHP_AUTH_PW) != $gblPw ||          if ( md5($PHP_AUTH_USER.$PHP_AUTH_PW) != $gblPw ||
# Line 1229  function DisplayChangeLog($day) { Line 1260  function DisplayChangeLog($day) {
1260          $relScriptDir = dirname($SCRIPT_NAME) ;                  $relScriptDir = dirname($SCRIPT_NAME) ;        
1261          // i.e. /docman          // i.e. /docman
1262    
         $fsScriptDir  = dirname($SCRIPT_FILENAME) ;      
         // i.e. /home/httpd/html/docman  
   
1263          // start on server root          // start on server root
1264  //      $gblFsRoot = substr($fsScriptDir,0, strlen($fsScriptDir)-strlen($relScriptDir)) ;  //      $gblFsRoot = substr($fsScriptDir,0, strlen($fsScriptDir)-strlen($relScriptDir)) ;
1265          // or on script root          // or on script root
# Line 1250  function DisplayChangeLog($day) { Line 1278  function DisplayChangeLog($day) {
1278    
1279          $FN=stripSlashes($FN);          $FN=stripSlashes($FN);
1280    
         if (file_exists("$fsScriptDir/.docman.conf")) {  
                 include("$fsScriptDir/.docman.conf");  
         }  
1281    
1282          switch ($POSTACTION) {          switch ($POSTACTION) {
1283          case "UPLOAD" :          case "UPLOAD" :
# Line 1457  function DisplayChangeLog($day) { Line 1482  function DisplayChangeLog($day) {
1482          case "Co" :          case "Co" :
1483                  // checkout                  // checkout
1484                  Lock("$gblFsRoot/$relDir/$F");                  Lock("$gblFsRoot/$relDir/$F");
1485                  header("Content-Disposition: attachment; filename=$F" );                  Download("$gblFsRoot/$relDir/$F");
                 Header("Location: $webRoot".urlpath("$relDir/$F"));  
1486                  exit;                  exit;
1487          case "Ci" :          case "Ci" :
1488                  $F=stripSlashes($F);                  $F=stripSlashes($F);
# Line 1474  function DisplayChangeLog($day) { Line 1498  function DisplayChangeLog($day) {
1498          case "V" :          case "V" :
1499                  // view                  // view
1500                  LogIt("$gblFsRoot/$relDir/$F","viewed");                  LogIt("$gblFsRoot/$relDir/$F","viewed");
1501                  header("Content-Disposition: attachment; filename=$F" );                  if ($gblForceDownload) {
1502                  Header("Location: $webRoot".urlpath("$relDir/$F"));                          Download("$gblFsRoot/$relDir/$F");
1503                    } else {
1504                            header("Content-Disposition: attachment; filename=$F" );
1505                            Header("Location: $webRoot".urlpath("$relDir/$F"));
1506                    }
1507                  exit;                  exit;
1508          case "Ch" :          case "Ch" :
1509                  StartHTML("(File changes)","All changes chronologicaly...");                  StartHTML("(File changes)","All changes chronologicaly...");

Legend:
Removed from v.1.38  
changed lines
  Added in v.1.47

  ViewVC Help
Powered by ViewVC 1.1.26