/[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.21 by dpavlin, Wed Sep 13 08:27:43 2000 UTC revision 1.28 by dpavlin, Fri Jan 26 07:54:53 2001 UTC
# Line 35  Line 35 
35  /*             existent address after file modifications.       */  /*             existent address after file modifications.       */
36    
37  /*  /*
         2000-07-25 Dobrica Pavlinusic <dpavlin@rot13.org>  
38    
39          nuked exec calls (unsecure)          This project is now called Directory Manager.
         nuked writeable function (replaced by php is_writeable)  
         added support for https (tested with apache+mod_ssl)  
         added users file  
         date format user-selectable  
         cycle backup files in bak directory  
         support links as directoryes (for now)  
         support of file history logging  
         undelete capabilities (delete moves to .del directory)  
40    
41          2000-07-26 DbP          For more info, please see web pages at
42            http://www.rot13.org/~dpavlin/docman.html
43    
44          added more checking on entered filename (when creating file/dir)          It's relased under GPL by
45          added rename option          Dobrica Pavlinusic <dpavlin@rot13.org>
46    
47    
48  IMPORTANT INSTALLATION NOTE:  IMPORTANT INSTALLATION NOTE:
# Line 59  IMPORTANT INSTALLATION NOTE: Line 51  IMPORTANT INSTALLATION NOTE:
51          deleted files!          deleted files!
52    
53          .htusers is in form:          .htusers is in form:
54          login:Real Name:md5(loginpassword)          login:Real Name:[md5(loginpassword)|auth_*]:email@host.dom
55    
56    
57  TODO:  TODO:
58          mixed file/directory output (add type to each entry,          mixed file/directory output (add type to each entry,
59                  real support for links)                  real support for links)
60          retrieve old versions of files (overwritten)          access controll
61          show last lock date  
           
62  */  */
63    
64  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
# Line 80  TODO: Line 71  TODO:
71    
72  // GLOBAL PARAMETERS  // GLOBAL PARAMETERS
73  // =================  // =================
74  // Make modifications here to suit siteman to your needs  // Make modifications here to suit docman to your needs
75    
76  //      error_reporting(4) ;            // how verbose ?  //      error_reporting(4) ;            // how verbose ?
77    
# Line 367  echo($fstr) ; ?></TEXTAREA> Line 358  echo($fstr) ; ?></TEXTAREA>
358  </FORM>  </FORM>
359    
360  <?php  <?php
361            
362          $name=basename("$fsDir/$fn");          $name=basename("$fsDir/$fn");
363          $logname=dirname("$fsDir/$fn")."/.log/$name";          $logname=dirname("$fsDir/$fn")."/.log/$name";
364          $bakdir=dirname("$fsDir/$fn")."/.bak";          $bakdir=dirname("$fsDir/$fn")."/.bak";
365          if (file_exists($logname)) {          if (file_exists($logname)) {
366                  $log=fopen($logname,"r");                  $log=fopen($logname,"r");
367                  $cl1=" class=lst"; $cl2="";                  $cl1=" class=LST"; $cl2="";
368                  $logarr = array();                  $logarr = array();
369                  while($line = fgetcsv($log,255,"\t")) {                  while($line = fgetcsv($log,255,"\t")) {
370                          $cl=$cl1; $cl1=$cl2; $cl2=$cl;                          $cl=$cl1; $cl1=$cl2; $cl2=$cl;
# Line 385  echo($fstr) ; ?></TEXTAREA> Line 376  echo($fstr) ; ?></TEXTAREA>
376                  while ($e = array_shift($logarr)) {                  while ($e = array_shift($logarr)) {
377                          if (strstr($e[4],"upload")) {                          if (strstr($e[4],"upload")) {
378                                  if (file_exists("$bakdir/$bakcount/$name")) {                                  if (file_exists("$bakdir/$bakcount/$name")) {
379                                          $e[4]="<a href=\"".dirname($relPath)."/.bak/$bakcount/$name\">$e[4]</a>";                                          $e[4]="<a href=\"".urlpath(dirname($relPath)."/.bak/$bakcount/$name")."\">$e[4]</a>";
380                                  }                                  }
381                                  $bakcount++;                                  $bakcount++;
382                          }                          }
# Line 650  function Navigate($fsRoot,$relDir) { Line 641  function Navigate($fsRoot,$relDir) {
641    
642          $self     = $GLOBALS["PHP_SELF"] ;          $self     = $GLOBALS["PHP_SELF"] ;
643          if (isset($GLOBALS["HTTPS"]) && $GLOBALS["HTTPS"] == "on") {          if (isset($GLOBALS["HTTPS"]) && $GLOBALS["HTTPS"] == "on") {
644                  $webRoot  = "https://" . $GLOBALS["SERVER_NAME"] ;                  $webRoot  = "https://" . $GLOBALS["HTTP_HOST"] ;
645          } else {          } else {
646                  $webRoot  = "http://" . $GLOBALS["SERVER_NAME"] ;                  $webRoot  = "http://" . $GLOBALS["HTTP_HOST"] ;
647          }          }
648          $fsDir    = $fsRoot . $relDir . "/" ; // current directory          $fsDir    = $fsRoot . $relDir . "/" ; // current directory
649    
# Line 829  function Navigate($fsRoot,$relDir) { Line 820  function Navigate($fsRoot,$relDir) {
820    
821  <?php  <?php
822            }  // iterate over files            }  // iterate over files
823          }  // end if no files          } else {  // end if no files
824    ?>
825     <TR><TD></TD><TD COLSPAN=5 CLASS=LST>
826      No files in this directory
827     </TD></TR>
828    <?
829            }
830    
831          if ($emptyDir) {          if ($emptyDir) {
832  ?>  ?>
# Line 849  function Navigate($fsRoot,$relDir) { Line 846  function Navigate($fsRoot,$relDir) {
846    
847  <TR><TD></TD><TD COLSPAN=5><HR></TD></TR>  <TR><TD></TD><TD COLSPAN=5><HR></TD></TR>
848    
 <TR><TD></TD><TD COLSPAN=5>  
849  <?  <?
850  if (file_exists(".info.inc")) {  if (file_exists(".info.inc")) {
851            print "<TR><TD></TD><TD COLSPAN=5>";
852          include(".info.inc");          include(".info.inc");
853            print "</TD></TR>
854            <TR><TD></TD><TD COLSPAN=5><HR></TD></TR>";
855  }  }
856  ?>  ?>
 </TD></TR>  
   
 <TR><TD></TD><TD COLSPAN=5><HR></TD></TR>  
857    
858  <FORM METHOD="POST" ACTION="<?= $self ?>">  <FORM METHOD="POST" ACTION="<?= $self ?>">
859  <TR><TD></TD><TD COLSPAN=5 CLASS=BAR>CREATE NEW  <TR><TD></TD><TD COLSPAN=5 CLASS=BAR>CREATE NEW
# Line 879  if (file_exists(".info.inc")) { Line 875  if (file_exists(".info.inc")) {
875    
876  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
877    
878  function UploadPage($fsRoot, $relDir, $filename) {  function UploadPage($fsRoot, $relDir, $filename="") {
879    
880          $self = $GLOBALS["PHP_SELF"] ;          $self = $GLOBALS["PHP_SELF"] ;
881          if ($relDir == "") $relDir = "/" ;          if ($relDir == "") $relDir = "/" ;
# Line 889  function UploadPage($fsRoot, $relDir, $f Line 885  function UploadPage($fsRoot, $relDir, $f
885  <FORM ENCTYPE="multipart/form-data" METHOD="POST"  <FORM ENCTYPE="multipart/form-data" METHOD="POST"
886   ACTION="<?= $self ?>">   ACTION="<?= $self ?>">
887  DESTINATION DIRECTORY:<B><?= " " . $relDir ?></B>  DESTINATION DIRECTORY:<B><?= " " . $relDir ?></B>
888  <? if (isset($filename)) { ?>  <? if (isset($filename) && $filename!="") { ?>
889  <br>DESTINATION FILE:<B><?= " " . $filename ?></B>  <br>DESTINATION FILE:<B><?= " " . $filename ?></B>
890  <INPUT TYPE="HIDDEN" NAME="FILENAME" VALUE="<?= $filename ?>">  <INPUT TYPE="HIDDEN" NAME="FILENAME" VALUE="<?= $filename ?>">
891  <? } ?>  <? } ?>
# Line 978  the source<BR>of this file.<BR><BR> Line 974  the source<BR>of this file.<BR><BR>
974    
975  function LogIt($target,$msg) {  function LogIt($target,$msg) {
976    
         $target=stripSlashes($target);  
977          $dir=dirname($target);          $dir=dirname($target);
978          if (! file_exists($dir."/.log")) {          if (! file_exists($dir."/.log")) {
979                  mkdir($dir."/.log",0700);                  mkdir($dir."/.log",0700);
# Line 1148  function DisplayChangeLog($day) { Line 1143  function DisplayChangeLog($day) {
1143          $log=fopen("$gblFsRoot/.changelog","r");          $log=fopen("$gblFsRoot/.changelog","r");
1144          $logarr = array();          $logarr = array();
1145          while($line = fgetcsv($log,255,"\t")) {          while($line = fgetcsv($log,255,"\t")) {
1146                  if ($day!=1 || ($day==1 && (time()-$line[0] < 24*60))) {                  if ($day!=1 || ($day==1 && (time()-$line[0] < 24*60*60))) {
1147                          array_unshift($logarr,array($line[0],$line[1],$line[2],$line[3]));                          array_unshift($logarr,array($line[0],$line[1],$line[2],$line[3]));
1148                  }                  }
1149          }          }
1150          fclose($log);          fclose($log);
1151          $cl1=" class=lst"; $cl2="";          $cl1=" class=LST"; $cl2="";
1152          print "<table border=0 width=100%>\n";          print "<table border=0 width=100%>\n";
1153          while ($e = array_shift($logarr)) {          while ($e = array_shift($logarr)) {
1154                  $cl=$cl1; $cl1=$cl2; $cl2=$cl;                  $cl=$cl1; $cl1=$cl2; $cl2=$cl;
# Line 1192  function DisplayChangeLog($day) { Line 1187  function DisplayChangeLog($day) {
1187          // authentication if $gblAuth == true          // authentication if $gblAuth == true
1188          if ( $gblAuth && $gblHash($PHP_AUTH_USER.$PHP_AUTH_PW) != $gblPw ||          if ( $gblAuth && $gblHash($PHP_AUTH_USER.$PHP_AUTH_PW) != $gblPw ||
1189                  isset($relogin) && $gblPw == $relogin ) {                  isset($relogin) && $gblPw == $relogin ) {
1190                  header("WWW-authenticate: basic realm=\"$SERVER_NAME\"") ;                  header("WWW-authenticate: basic realm=\"$HTTP_HOST\"") ;
1191                  header("HTTP/1.0 401 Unauthorized") ;                  header("HTTP/1.0 401 Unauthorized") ;
1192                  NoEntry() ;                  NoEntry() ;
1193                  exit ;                  exit ;
# Line 1215  function DisplayChangeLog($day) { Line 1210  function DisplayChangeLog($day) {
1210          // i.e. below $gblFsRoot.          // i.e. below $gblFsRoot.
1211    
1212          $relScriptDir = dirname($SCRIPT_NAME) ;                  $relScriptDir = dirname($SCRIPT_NAME) ;        
1213          // i.e. /siteman          // i.e. /docman
1214    
1215          $fsScriptDir  = dirname($SCRIPT_FILENAME) ;              $fsScriptDir  = dirname($SCRIPT_FILENAME) ;    
1216          // i.e. /home/httpd/html/siteman          // i.e. /home/httpd/html/docman
1217    
1218          $gblFsRoot = substr($fsScriptDir,0,          // start on server root
1219            strlen($fsScriptDir)-strlen($relScriptDir)) ;  //      $gblFsRoot = substr($fsScriptDir,0, strlen($fsScriptDir)-strlen($relScriptDir)) ;
1220            // or on script root
1221            $gblFsRoot = $fsScriptDir;
1222          // i.e. /home/httpd/html          // i.e. /home/httpd/html
1223    
1224          $fsDir = $gblFsRoot . $relDir ; // current directory          $fsDir = $gblFsRoot . $relDir ; // current directory
1225          if ( !is_dir($fsDir) ) Error("Dir not found",$relDir) ;          if ( !is_dir($fsDir) ) Error("Dir not found",$relDir) ;
1226            
1227            $FN=stripSlashes($FN);
1228    
1229          switch ($POSTACTION) {          switch ($POSTACTION) {
1230          case "UPLOAD" :          case "UPLOAD" :
1231                  if (!is_writeable($fsDir)) Error("Write denied",$relDir) ;                  if (!is_writeable($fsDir)) Error("Write denied",$relDir) ;
# Line 1235  function DisplayChangeLog($day) { Line 1234  function DisplayChangeLog($day) {
1234                  // TODO : should rather check for escapeshellcmds                  // TODO : should rather check for escapeshellcmds
1235                  // but maybe RFC 18xx asserts safe filenames ....                  // but maybe RFC 18xx asserts safe filenames ....
1236                  $source = $FN ;                  $source = $FN ;
1237                    if (! file_exists($source)) {
1238                            Error("You must select file with browse to upload it!");
1239                    }
1240                  if (! isset($FILENAME)) {       // from update file                  if (! isset($FILENAME)) {       // from update file
1241                          $target = "$fsDir/$FN_name" ;                          $target = "$fsDir/$FN_name" ;
1242                  } else {                  } else {
# Line 1267  function DisplayChangeLog($day) { Line 1269  function DisplayChangeLog($day) {
1269    
1270          case "SAVE" :          case "SAVE" :
1271                  $path = $gblFsRoot . $RELPATH ;                  $path = $gblFsRoot . $RELPATH ;
1272                    $path=stripSlashes($path);
1273                  $writable = is_writeable($path) ;                  $writable = is_writeable($path) ;
1274                  $legaldir = is_writeable(dirname($path)) ;                  $legaldir = is_writeable(dirname($path)) ;
1275                  $exists   = (file_exists($path)) ? 1 : 0 ;                  $exists   = (file_exists($path)) ? 1 : 0 ;
# Line 1274  function DisplayChangeLog($day) { Line 1277  function DisplayChangeLog($day) {
1277                  if (!($writable || (!$exists && $legaldir)))                  if (!($writable || (!$exists && $legaldir)))
1278                          Error("Write denied",$RELPATH) ;                          Error("Write denied",$RELPATH) ;
1279                  $fh = fopen($path, "w") ;                  $fh = fopen($path, "w") ;
1280                    $FILEDATA=stripSlashes($FILEDATA);
1281                  fwrite($fh,$FILEDATA) ;                  fwrite($fh,$FILEDATA) ;
1282                  fclose($fh) ;                  fclose($fh) ;
1283                  clearstatcache() ;                  clearstatcache() ;
# Line 1408  function DisplayChangeLog($day) { Line 1412  function DisplayChangeLog($day) {
1412          // $A=V : view file (do nothing except log)          // $A=V : view file (do nothing except log)
1413          // default : display directory $D          // default : display directory $D
1414    
         $F=stripSlashes($F);  
   
1415          switch ($A) {          switch ($A) {
1416          case "U" :          case "U" :
1417                  // upload to $relDir                  // upload to $relDir
1418                  if (!is_writeable($gblFsRoot . $relDir))                  if (!is_writeable($gblFsRoot . $relDir))
1419                          Error("Write access denied",$relDir) ;                          Error("Write access denied",$relDir) ;
1420                  $text  = "Use this page to upload a single " ;                  $text  = "Use this page to upload a single " ;
1421                  $text .= "file to <B>$SERVER_NAME</B>." ;                  $text .= "file to <B>$HTTP_HOST</B>." ;
1422                  StartHTML("(Upload Page)", $text) ;                  StartHTML("(Upload Page)", $text) ;
1423                  UploadPage($gblFsRoot, $relDir) ;                  UploadPage($gblFsRoot, $relDir) ;
1424                  EndHTML() ;                  EndHTML() ;
1425                  exit ;                  exit ;
1426          case "E" :          case "E" :
1427                    $F=stripSlashes($F);
1428                  // detail of $relDir/$F                  // detail of $relDir/$F
1429                  if (is_file("$gblFsRoot/$relDir/$F")) DetailPage($gblFsRoot, $relDir, $F) ;                  if (is_file("$gblFsRoot/$relDir/$F")) DetailPage($gblFsRoot, $relDir, $F) ;
1430                  exit ;                  exit ;
1431          case "C" :          case "C" :
1432                    $F=stripSlashes($F);
1433                  // listing of $relDir/$F                  // listing of $relDir/$F
1434                  DisplayCode($gblFsRoot, $relDir, $F) ;                  DisplayCode($gblFsRoot, $relDir, $F) ;
1435                  exit ;                  exit ;
# Line 1436  function DisplayChangeLog($day) { Line 1440  function DisplayChangeLog($day) {
1440                  Header("Location: ".urlpath("$relDir/$F"));                  Header("Location: ".urlpath("$relDir/$F"));
1441                  exit;                  exit;
1442          case "Ci" :          case "Ci" :
1443                    $F=stripSlashes($F);
1444                  // upload && update to $relDir                  // upload && update to $relDir
1445                  if (!is_writeable($gblFsRoot . $relDir))                  if (!is_writeable($gblFsRoot . $relDir))
1446                          Error("Write access denied",$relDir) ;                          Error("Write access denied",$relDir) ;
1447                  $text  = "Use this page to update a single " ;                  $text  = "Use this page to update a single " ;
1448                  $text .= "file to <B>$SERVER_NAME</B>." ;                  $text .= "file to <B>$HTTP_HOST</B>." ;
1449                  StartHTML("(Update file Page)", $text) ;                  StartHTML("(Update file Page)", $text) ;
1450                  UploadPage($gblFsRoot, $relDir, $F) ;                  UploadPage($gblFsRoot, $relDir, $F) ;
1451                  EndHTML() ;                  EndHTML() ;

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.28

  ViewVC Help
Powered by ViewVC 1.1.26