/[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.19 by dpavlin, Thu Sep 7 10:19:34 2000 UTC revision 1.25 by dpavlin, Thu Dec 21 07:30:04 2000 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 65  IMPORTANT INSTALLATION NOTE: Line 57  IMPORTANT INSTALLATION NOTE:
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";
# 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 976  the source<BR>of this file.<BR><BR> Line 972  the source<BR>of this file.<BR><BR>
972    
973  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
974    
975  function Logit($target,$msg) {  function LogIt($target,$msg) {
976    
977          $dir=dirname($target);          $dir=dirname($target);
978          if (! file_exists($dir."/.log")) {          if (! file_exists($dir."/.log")) {
# Line 996  function Logit($target,$msg) { Line 992  function Logit($target,$msg) {
992    
993  function WriteNote($target,$msg) {  function WriteNote($target,$msg) {
994    
995            $target=stripSlashes($target);
996          $dir=dirname($target);          $dir=dirname($target);
997          if (! file_exists($dir."/.note")) {          if (! file_exists($dir."/.note")) {
998                  mkdir($dir."/.note",0700);                  mkdir($dir."/.note",0700);
# Line 1012  function WriteNote($target,$msg) { Line 1009  function WriteNote($target,$msg) {
1009    
1010  function ReadNote($target) {  function ReadNote($target) {
1011    
1012            $target=stripSlashes($target);
1013          $dir=dirname($target);          $dir=dirname($target);
1014          $file=basename($target);          $file=basename($target);
1015          $msg="";          $msg="";
# Line 1028  function ReadNote($target) { Line 1026  function ReadNote($target) {
1026    
1027  function MoveTo($source,$folder) {  function MoveTo($source,$folder) {
1028    
1029            $source=stripSlashes($source);
1030          $file=basename($source);          $file=basename($source);
1031          if (! file_exists($folder)) {          if (! file_exists($folder)) {
1032                  mkdir($folder,0700);                  mkdir($folder,0700);
# Line 1041  function MoveTo($source,$folder) { Line 1040  function MoveTo($source,$folder) {
1040    
1041  function Lock($target) {  function Lock($target) {
1042    
1043            $target=stripSlashes($target);
1044          $dir=dirname($target);          $dir=dirname($target);
1045          if (! file_exists($dir."/.lock")) {          if (! file_exists($dir."/.lock")) {
1046                  mkdir($dir."/.lock",0700);                  mkdir($dir."/.lock",0700);
# Line 1061  function Lock($target) { Line 1061  function Lock($target) {
1061    
1062  function CheckLock($target) {  function CheckLock($target) {
1063    
1064            $target=stripSlashes($target);
1065          $dir=dirname($target);          $dir=dirname($target);
1066          $file=basename($target);          $file=basename($target);
1067          $msg=0;          $msg=0;
# Line 1075  function CheckLock($target) { Line 1076  function CheckLock($target) {
1076    
1077  function Unlock($target) {  function Unlock($target) {
1078    
1079            $target=stripSlashes($target);
1080          $dir=dirname($target);          $dir=dirname($target);
1081          $file=basename($target);          $file=basename($target);
1082          if (file_exists($dir."/.lock/$file")) {          if (file_exists($dir."/.lock/$file")) {
# Line 1137  function ChangeLog($target,$msg) { Line 1139  function ChangeLog($target,$msg) {
1139  function DisplayChangeLog($day) {  function DisplayChangeLog($day) {
1140    
1141          global $gblFsRoot;          global $gblFsRoot;
1142          if (!file_exists("gblFsRoot/.changelog")) return;          if (!file_exists("$gblFsRoot/.changelog")) return;
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 && $line[0]-time() < 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          }          }
# Line 1157  function DisplayChangeLog($day) { Line 1159  function DisplayChangeLog($day) {
1159                  print "<tr><td$cl>$date</td><td$cl>$time</td><td$cl><a href=\"$GLOBALS[PHP_SELF]?D=".urlencode($dir)."\">$dir</a>/$file</td><td$cl>$e[2]</td><td$cl>$e[3]</td></tr>\n";                  print "<tr><td$cl>$date</td><td$cl>$time</td><td$cl><a href=\"$GLOBALS[PHP_SELF]?D=".urlencode($dir)."\">$dir</a>/$file</td><td$cl>$e[2]</td><td$cl>$e[3]</td></tr>\n";
1160          }          }
1161          print "</table>";          print "</table>";
1162            print "<p>".GifIcon(up)." Back to <a href=$GLOBALS[PHP_SELF]>front page</a>.</p>";
1163  }  }
1164    
1165  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
# Line 1184  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 1207  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 1259  function DisplayChangeLog($day) { Line 1266  function DisplayChangeLog($day) {
1266    
1267          case "SAVE" :          case "SAVE" :
1268                  $path = $gblFsRoot . $RELPATH ;                  $path = $gblFsRoot . $RELPATH ;
1269                    $path=stripSlashes($path);
1270                  $writable = is_writeable($path) ;                  $writable = is_writeable($path) ;
1271                  $legaldir = is_writeable(dirname($path)) ;                  $legaldir = is_writeable(dirname($path)) ;
1272                  $exists   = (file_exists($path)) ? 1 : 0 ;                  $exists   = (file_exists($path)) ? 1 : 0 ;
# Line 1266  function DisplayChangeLog($day) { Line 1274  function DisplayChangeLog($day) {
1274                  if (!($writable || (!$exists && $legaldir)))                  if (!($writable || (!$exists && $legaldir)))
1275                          Error("Write denied",$RELPATH) ;                          Error("Write denied",$RELPATH) ;
1276                  $fh = fopen($path, "w") ;                  $fh = fopen($path, "w") ;
1277                    $FILEDATA=stripSlashes($FILEDATA);
1278                  fwrite($fh,$FILEDATA) ;                  fwrite($fh,$FILEDATA) ;
1279                  fclose($fh) ;                  fclose($fh) ;
1280                  clearstatcache() ;                  clearstatcache() ;
# Line 1399  function DisplayChangeLog($day) { Line 1408  function DisplayChangeLog($day) {
1408          // $A=Ci : checkin file $D/$F          // $A=Ci : checkin file $D/$F
1409          // $A=V : view file (do nothing except log)          // $A=V : view file (do nothing except log)
1410          // default : display directory $D          // default : display directory $D
1411            
1412          switch ($A) {          switch ($A) {
1413          case "U" :          case "U" :
1414                  // upload to $relDir                  // upload to $relDir
1415                  if (!is_writeable($gblFsRoot . $relDir))                  if (!is_writeable($gblFsRoot . $relDir))
1416                          Error("Write access denied",$relDir) ;                          Error("Write access denied",$relDir) ;
1417                  $text  = "Use this page to upload a single " ;                  $text  = "Use this page to upload a single " ;
1418                  $text .= "file to <B>$SERVER_NAME</B>." ;                  $text .= "file to <B>$HTTP_HOST</B>." ;
1419                  StartHTML("(Upload Page)", $text) ;                  StartHTML("(Upload Page)", $text) ;
1420                  UploadPage($gblFsRoot, $relDir) ;                  UploadPage($gblFsRoot, $relDir) ;
1421                  EndHTML() ;                  EndHTML() ;
1422                  exit ;                  exit ;
1423          case "E" :          case "E" :
1424                    $F=stripSlashes($F);
1425                  // detail of $relDir/$F                  // detail of $relDir/$F
1426                  if (is_file("$gblFsRoot/$relDir/$F")) DetailPage($gblFsRoot, $relDir, $F) ;                  if (is_file("$gblFsRoot/$relDir/$F")) DetailPage($gblFsRoot, $relDir, $F) ;
1427                  exit ;                  exit ;
1428          case "C" :          case "C" :
1429                    $F=stripSlashes($F);
1430                  // listing of $relDir/$F                  // listing of $relDir/$F
1431                  DisplayCode($gblFsRoot, $relDir, $F) ;                  DisplayCode($gblFsRoot, $relDir, $F) ;
1432                  exit ;                  exit ;
# Line 1426  function DisplayChangeLog($day) { Line 1437  function DisplayChangeLog($day) {
1437                  Header("Location: ".urlpath("$relDir/$F"));                  Header("Location: ".urlpath("$relDir/$F"));
1438                  exit;                  exit;
1439          case "Ci" :          case "Ci" :
1440                    $F=stripSlashes($F);
1441                  // upload && update to $relDir                  // upload && update to $relDir
1442                  if (!is_writeable($gblFsRoot . $relDir))                  if (!is_writeable($gblFsRoot . $relDir))
1443                          Error("Write access denied",$relDir) ;                          Error("Write access denied",$relDir) ;
1444                  $text  = "Use this page to update a single " ;                  $text  = "Use this page to update a single " ;
1445                  $text .= "file to <B>$SERVER_NAME</B>." ;                  $text .= "file to <B>$HTTP_HOST</B>." ;
1446                  StartHTML("(Update file Page)", $text) ;                  StartHTML("(Update file Page)", $text) ;
1447                  UploadPage($gblFsRoot, $relDir, $F) ;                  UploadPage($gblFsRoot, $relDir, $F) ;
1448                  EndHTML() ;                  EndHTML() ;

Legend:
Removed from v.1.19  
changed lines
  Added in v.1.25

  ViewVC Help
Powered by ViewVC 1.1.26