/[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.8 by dpavlin, Fri Aug 4 10:20:22 2000 UTC revision 1.21 by dpavlin, Wed Sep 13 08:27:43 2000 UTC
# Line 65  IMPORTANT INSTALLATION NOTE: Line 65  IMPORTANT INSTALLATION NOTE:
65  TODO:  TODO:
66          mixed file/directory output (add type to each entry,          mixed file/directory output (add type to each entry,
67                  real support for links)                  real support for links)
68          add more content-management (like cms.sourceforge.net):          retrieve old versions of files (overwritten)
69                  check-out/check-in/reserve          show last lock date
70                  comments to files          
71  */  */
72    
73  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
# Line 108  TODO: Line 108  TODO:
108                          if ($user[0] == $GLOBALS["PHP_AUTH_USER"]) {                          if ($user[0] == $GLOBALS["PHP_AUTH_USER"]) {
109                                  $gblUserName=$user[1];                                  $gblUserName=$user[1];
110                                  $gblPw=$user[2];                                  $gblPw=$user[2];
111                                    $gblEmail=$user[3];
112                                  continue ;                                  continue ;
113                          }                          }
114                  }                  }
# Line 120  TODO: Line 121  TODO:
121          $gblDateFmt="Y-m-d";          $gblDateFmt="Y-m-d";
122          $gblTimeFmt="H:i:s";          $gblTimeFmt="H:i:s";
123    
124  // Number of backup files to keep          // Number of backup files to keep
125          $gblNumBackups=5;          $gblNumBackups=3;
126    
127            // show red star if newer than ... days
128            $gblModDays=1;
129    
130          // choose GifIcon below unless you have the M$          // choose GifIcon below unless you have the M$
131          // WingDings font installed on your system          // WingDings font installed on your system
# Line 194  function EndHTML() { Line 198  function EndHTML() {
198  </small>  </small>
199  </P>  </P>
200  <BR>  <BR>
201  <? include(".debug.inc") ?>  <? //include(".debug.inc") ?>
202  <BR><BR></BODY></HTML>  <BR><BR></BODY></HTML>
203    
204  <?php  <?php
# Line 294  echo($fstr) ; ?></TEXTAREA> Line 298  echo($fstr) ; ?></TEXTAREA>
298  </FORM>  </FORM>
299    
300  <?php  <?php
301          } else if ( strstr( join(" ",$gblImages), $ext ) ) {            }
302            if ( !$file_lock && $ext!="" && strstr(join(' ',$gblImages),$ext) ) {  
303                  $info  = getimagesize($fsPath) ;                  $info  = getimagesize($fsPath) ;
304                  $tstr  = "<IMG SRC=\"". $relPath . "\" BORDER=0 " ;                  $tstr = "<IMG SRC=\"".urlpath($relPath)."\" BORDER=0 " ;
305                  $tstr .= $info[3] . " ALT=\"" . $fn . " - " ;                  $tstr .= $info[3] . " ALT=\"" . $fn . " - " ;
306                  $tstr .= (int)(($fsize+1023)/1024) . "Kb\">" ;                  $tstr .= (int)(($fsize+1023)/1024) . "Kb\">" ;
307                  echo htmlentities($tstr) . "<BR><BR>" . $tstr ;  //              echo htmlentities($tstr) . "<BR><BR>" . $tstr ;
308                    echo $tstr ;
309          }          }
310    
311  ?>  ?>
# Line 362  echo($fstr) ; ?></TEXTAREA> Line 368  echo($fstr) ; ?></TEXTAREA>
368    
369  <?php  <?php
370                    
371            $name=basename("$fsDir/$fn");
372          $logname=dirname("$fsDir/$fn")."/.log/".basename("$fsDir/$fn");          $logname=dirname("$fsDir/$fn")."/.log/$name";
373            $bakdir=dirname("$fsDir/$fn")."/.bak";
374          if (file_exists($logname)) {          if (file_exists($logname)) {
                 print "<hr><br><b>CHANGES TO THIS FILE</b><br><table border=0 width=100%>\n";  
375                  $log=fopen($logname,"r");                  $log=fopen($logname,"r");
376                  $cl1=" class=lst"; $cl2="";                  $cl1=" class=lst"; $cl2="";
377                    $logarr = array();
378                  while($line = fgetcsv($log,255,"\t")) {                  while($line = fgetcsv($log,255,"\t")) {
379                          $cl=$cl1; $cl1=$cl2; $cl2=$cl;                          $cl=$cl1; $cl1=$cl2; $cl2=$cl;
380                          print "<tr><td$cl>$line[0]</td><td$cl>$line[1]</td><td$cl>$line[2]</td><td$cl>$line[3]</td></tr>\n";                          array_unshift($logarr,array($cl,$line[0],$line[1],$line[2],$line[3]));
381                  }                  }
382                  fclose($log);                  fclose($log);
383                    print "<hr><br><b>CHANGES TO THIS FILE</b><br><table border=0 width=100%>\n";
384                    $bakcount = 0;  // start from 0, skip fist backup (it's current)
385                    while ($e = array_shift($logarr)) {
386                            if (strstr($e[4],"upload")) {
387                                    if (file_exists("$bakdir/$bakcount/$name")) {
388                                            $e[4]="<a href=\"".dirname($relPath)."/.bak/$bakcount/$name\">$e[4]</a>";
389                                    }
390                                    $bakcount++;
391                            }
392                            print "<tr><td$e[0]>$e[1]</td><td$e[0]>$e[2]</td><td$e[0]>$e[3]</td><td$e[0]>$e[4]</td></tr>\n";
393                    }
394                  print "</table>";                  print "</table>";
395          }          }
396    
# Line 628  function GifIcon($txt) { Line 646  function GifIcon($txt) {
646    
647  function Navigate($fsRoot,$relDir) {  function Navigate($fsRoot,$relDir) {
648    
649          global $gblEditable, $gblIcon ;          global $gblEditable, $gblIcon, $gblModDays ;
650    
651          $self     = $GLOBALS["PHP_SELF"] ;          $self     = $GLOBALS["PHP_SELF"] ;
652          if (isset($GLOBALS["HTTPS"]) && $GLOBALS["HTTPS"] == "on") {          if (isset($GLOBALS["HTTPS"]) && $GLOBALS["HTTPS"] == "on") {
# Line 677  function Navigate($fsRoot,$relDir) { Line 695  function Navigate($fsRoot,$relDir) {
695                  $text .= ", <a href=$self?D=".urlencode($relDir)."&show_deleted=1>undelete</a>";                  $text .= ", <a href=$self?D=".urlencode($relDir)."&show_deleted=1>undelete</a>";
696          }          }
697          $text .= " or revise files on this web site." ;          $text .= " or revise files on this web site." ;
698            $text .= "<br>Examine list of files <a href=\"$self?A=Ch1\">changed in last day</a> or <a href=\"$self?A=Ch\">all changes</a>.";
699          StartHTML("(Navigate)",$text) ;          StartHTML("(Navigate)",$text) ;
700    
701          echo "<TABLE BORDER=0 CELLPADDING=2          echo "<TABLE BORDER=0 CELLPADDING=2
# Line 743  function Navigate($fsRoot,$relDir) { Line 762  function Navigate($fsRoot,$relDir) {
762    
763                  $info_url=$self."?A=E&F=".urlencode($file)."&D=".urlencode($relDir);                  $info_url=$self."?A=E&F=".urlencode($file)."&D=".urlencode($relDir);
764    
765                  if ( ($mod + 30*86400) > time() ) {                  if ( ($mod + $gblModDays*86400) > time() ) {
766                          $a  = "<SPAN CLASS=RED TITLE=\"Newer" ;                          $a  = "<SPAN CLASS=RED TITLE=\"Newer" ;
767                          $a .= " than 30 days\"> * </SPAN>" ;                          $a .= " than $gblModDays days\"> * </SPAN>" ;
768                  }                  }
769    
770                  $file_lock=CheckLock($path);                  $file_lock=CheckLock($path);
# Line 831  function Navigate($fsRoot,$relDir) { Line 850  function Navigate($fsRoot,$relDir) {
850  <TR><TD></TD><TD COLSPAN=5><HR></TD></TR>  <TR><TD></TD><TD COLSPAN=5><HR></TD></TR>
851    
852  <TR><TD></TD><TD COLSPAN=5>  <TR><TD></TD><TD COLSPAN=5>
853  To just view file without editing, select it's filename (<b>don't edit files which are opened this way!</b>)<br>  <?
854  To <b>edit</b> file select <?= $gblIcon("checkout") ?> to check-out  if (file_exists(".info.inc")) {
855  and edit it locally. After editing is over, select filename or <?= $gblIcon("checkin") ?> to check-in (update copy of file on server).<br>          include(".info.inc");
856  <by>If you select icon left from filename, you will get detailed information  }
857  about file, as well as delete, rename and annotation options.  ?>
858  </TD></TR>  </TD></TR>
859    
860  <TR><TD></TD><TD COLSPAN=5><HR></TD></TR>  <TR><TD></TD><TD COLSPAN=5><HR></TD></TR>
# Line 848  about file, as well as delete, rename an Line 867  about file, as well as delete, rename an
867   <INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="CREATE">   <INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="CREATE">
868   <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>">   <INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>">
869   <INPUT TYPE="SUBMIT" VALUE="CREATE"></NOBR>   <INPUT TYPE="SUBMIT" VALUE="CREATE"></NOBR>
870   <NOBR>OR <A HREF="<?= $self   <NOBR>OR <A HREF="<?= $self ?>?A=U&D=<?= urlencode($relDir) ?>">UPLOAD</A> A FILE
         ?>?A=U&D=<?= urlencode($relDir) ?>">UPLOAD</A> A FILE  
871   </NOBR>   </NOBR>
872  </TD></TR>  </TD></TR>
873  </FORM>  </FORM>
# Line 958  the source<BR>of this file.<BR><BR> Line 976  the source<BR>of this file.<BR><BR>
976    
977  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
978    
979  function Logit($target,$msg) {  function LogIt($target,$msg) {
980    
981            $target=stripSlashes($target);
982          $dir=dirname($target);          $dir=dirname($target);
983          if (! file_exists($dir."/.log")) {          if (! file_exists($dir."/.log")) {
984                  mkdir($dir."/.log",0700);                  mkdir($dir."/.log",0700);
# Line 978  function Logit($target,$msg) { Line 997  function Logit($target,$msg) {
997    
998  function WriteNote($target,$msg) {  function WriteNote($target,$msg) {
999    
1000            $target=stripSlashes($target);
1001          $dir=dirname($target);          $dir=dirname($target);
1002          if (! file_exists($dir."/.note")) {          if (! file_exists($dir."/.note")) {
1003                  mkdir($dir."/.note",0700);                  mkdir($dir."/.note",0700);
# Line 994  function WriteNote($target,$msg) { Line 1014  function WriteNote($target,$msg) {
1014    
1015  function ReadNote($target) {  function ReadNote($target) {
1016    
1017            $target=stripSlashes($target);
1018          $dir=dirname($target);          $dir=dirname($target);
1019          $file=basename($target);          $file=basename($target);
1020          $msg="";          $msg="";
# Line 1010  function ReadNote($target) { Line 1031  function ReadNote($target) {
1031    
1032  function MoveTo($source,$folder) {  function MoveTo($source,$folder) {
1033    
1034            $source=stripSlashes($source);
1035          $file=basename($source);          $file=basename($source);
1036          if (! file_exists($folder)) {          if (! file_exists($folder)) {
1037                  mkdir($folder,0700);                  mkdir($folder,0700);
# Line 1023  function MoveTo($source,$folder) { Line 1045  function MoveTo($source,$folder) {
1045    
1046  function Lock($target) {  function Lock($target) {
1047    
1048            $target=stripSlashes($target);
1049          $dir=dirname($target);          $dir=dirname($target);
1050          if (! file_exists($dir."/.lock")) {          if (! file_exists($dir."/.lock")) {
1051                  mkdir($dir."/.lock",0700);                  mkdir($dir."/.lock",0700);
# Line 1043  function Lock($target) { Line 1066  function Lock($target) {
1066    
1067  function CheckLock($target) {  function CheckLock($target) {
1068    
1069            $target=stripSlashes($target);
1070          $dir=dirname($target);          $dir=dirname($target);
1071          $file=basename($target);          $file=basename($target);
1072          $msg=0;          $msg=0;
# Line 1057  function CheckLock($target) { Line 1081  function CheckLock($target) {
1081    
1082  function Unlock($target) {  function Unlock($target) {
1083    
1084            $target=stripSlashes($target);
1085          $dir=dirname($target);          $dir=dirname($target);
1086          $file=basename($target);          $file=basename($target);
1087          if (file_exists($dir."/.lock/$file")) {          if (file_exists($dir."/.lock/$file")) {
# Line 1070  function Unlock($target) { Line 1095  function Unlock($target) {
1095    
1096  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
1097    
1098  function redir_to_url($url) {  function urlpath($url) {
1099          $url=urlencode(StripSlashes("$url"));          $url=urlencode(StripSlashes("$url"));
1100          $url=str_replace("%2F","/",$url);          $url=str_replace("%2F","/",$url);
1101          $url=str_replace("+","%20",$url);          $url=str_replace("+","%20",$url);
1102          Header("Location: $url");          return($url);
1103  }  }
1104    
1105  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
# Line 1087  function safe_rename($from,$to) { Line 1112  function safe_rename($from,$to) {
1112    
1113  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
1114    
1115    // recursivly delete directory
1116    
1117    function rrmdir($dir) {
1118            $handle=opendir($dir);
1119            while ($file = readdir($handle)) {
1120                    if ($file != "." && $file != "..") {
1121                            if (is_dir("$dir/$file"))
1122                                    rrmdir("$dir/$file");
1123                            else
1124                                    if (! @unlink("$dir/$file")) return(0);
1125                    }
1126            }
1127            closedir($handle);
1128            return @rmdir($dir);
1129    }
1130    
1131    //////////////////////////////////////////////////////////////////
1132    
1133    function ChangeLog($target,$msg) {
1134    
1135            global $gblFsRoot;
1136            $log=fopen("$gblFsRoot/.changelog","a+");
1137            if (substr($target,0,strlen($gblFsRoot)) == $gblFsRoot)
1138                    $target=substr($target,strlen($gblFsRoot),strlen($target)-strlen($gblFsRoot));
1139            fputs($log,time()."\t$target\t$GLOBALS[gblUserName]\t$msg\n");
1140            fclose($log);
1141    
1142    }
1143    
1144    function DisplayChangeLog($day) {
1145    
1146            global $gblFsRoot;
1147            if (!file_exists("$gblFsRoot/.changelog")) return;
1148            $log=fopen("$gblFsRoot/.changelog","r");
1149            $logarr = array();
1150            while($line = fgetcsv($log,255,"\t")) {
1151                    if ($day!=1 || ($day==1 && (time()-$line[0] < 24*60))) {
1152                            array_unshift($logarr,array($line[0],$line[1],$line[2],$line[3]));
1153                    }
1154            }
1155            fclose($log);
1156            $cl1=" class=lst"; $cl2="";
1157            print "<table border=0 width=100%>\n";
1158            while ($e = array_shift($logarr)) {
1159                    $cl=$cl1; $cl1=$cl2; $cl2=$cl;
1160                    $date = date("$GLOBALS[gblDateFmt]", $e[0]);
1161                    $time = date("$GLOBALS[gblTimeFmt]", $e[0]);
1162                    $dir = dirname($e[1]);
1163                    $file = basename($e[1]);
1164                    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";
1165            }
1166            print "</table>";
1167            print "<p>".GifIcon(up)." Back to <a href=$GLOBALS[PHP_SELF]>front page</a>.</p>";
1168    }
1169    
1170    //////////////////////////////////////////////////////////////////
1171    
1172  // MAIN PROGRAM  // MAIN PROGRAM
1173  // ============  // ============
1174  // query parameters: capital letters  // query parameters: capital letters
# Line 1180  function safe_rename($from,$to) { Line 1262  function safe_rename($from,$to) {
1262                  if (isset($FILENAME)) {                  if (isset($FILENAME)) {
1263                          Unlock($target);                          Unlock($target);
1264                  }                  }
1265                    ChangeLog($target,"updated");
1266                  break ;                  break ;
1267    
1268          case "SAVE" :          case "SAVE" :
1269                  $path = $gblFsRoot . escapeshellcmd($RELPATH) ;                  $path = $gblFsRoot . $RELPATH ;
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 1195  function safe_rename($from,$to) { Line 1278  function safe_rename($from,$to) {
1278                  fclose($fh) ;                  fclose($fh) ;
1279                  clearstatcache() ;                  clearstatcache() ;
1280                  Logit($path,"saved changes");                  Logit($path,"saved changes");
1281                    ChangeLog($path,"saved changes");
1282                  break ;                  break ;
1283    
1284          case "CREATE" :          case "CREATE" :
# Line 1225  function safe_rename($from,$to) { Line 1309  function safe_rename($from,$to) {
1309                          }                          }
1310                          $tstr = "$PHP_SELF?A=E&D=".urlencode($relDir)."&F=".urlencode($FN) ;                          $tstr = "$PHP_SELF?A=E&D=".urlencode($relDir)."&F=".urlencode($FN) ;
1311                          header("Location: " . $tstr) ;                          header("Location: " . $tstr) ;
1312                            ChangeLog($target,"created");
1313                          exit ;                          exit ;
1314                  }                  }
1315                  break ;                  break ;
# Line 1257  function safe_rename($from,$to) { Line 1342  function safe_rename($from,$to) {
1342                          }                          }
1343                  }                  }
1344                  else {  // delete directory                  else {  // delete directory
1345                    if ( ! @rmdir($fsDir) ) {                    if ( ! @rrmdir($fsDir) ) {
1346                      Error("Rmdir failed", $tstr . $fsDir) ;                      Error("Rmdir failed", $tstr . $fsDir) ;
1347                    }                    }
1348                    else {                    else {
# Line 1288  function safe_rename($from,$to) { Line 1373  function safe_rename($from,$to) {
1373                  safe_rename("$fsDir/.log/$FN","$fsDir/.log/$NEWNAME");                  safe_rename("$fsDir/.log/$FN","$fsDir/.log/$NEWNAME");
1374                  safe_rename("$fsDir/.note/$FN","$fsDir/.note/$NEWNAME");                  safe_rename("$fsDir/.note/$FN","$fsDir/.note/$NEWNAME");
1375                  safe_rename("$fsDir/.lock/$FN","$fsDir/.lock/$NEWNAME");                  safe_rename("$fsDir/.lock/$FN","$fsDir/.lock/$NEWNAME");
1376                    for($i=0;$i<=$GLOBALS[gblNumBackups];$i++) {
1377                            safe_rename("$fsDir/.bak/$i/$FN","$fsDir/.bak/$i/$NEWNAME");
1378                    }
1379    
1380                  break ;                  break ;
1381    
# Line 1319  function safe_rename($from,$to) { Line 1407  function safe_rename($from,$to) {
1407          // $A=Ci : checkin file $D/$F          // $A=Ci : checkin file $D/$F
1408          // $A=V : view file (do nothing except log)          // $A=V : view file (do nothing except log)
1409          // default : display directory $D          // default : display directory $D
1410            
1411            $F=stripSlashes($F);
1412    
1413          switch ($A) {          switch ($A) {
1414          case "U" :          case "U" :
1415                  // upload to $relDir                  // upload to $relDir
# Line 1342  function safe_rename($from,$to) { Line 1432  function safe_rename($from,$to) {
1432          case "Co" :          case "Co" :
1433                  // checkout                  // checkout
1434                  Lock("$gblFsRoot/$relDir/$F");                  Lock("$gblFsRoot/$relDir/$F");
1435                  redir_to_url("$relDir/$F");                  header("Content-Disposition: attachment; filename=$F" );
1436                    Header("Location: ".urlpath("$relDir/$F"));
1437                  exit;                  exit;
1438          case "Ci" :          case "Ci" :
1439                  // upload && update to $relDir                  // upload && update to $relDir
# Line 1356  function safe_rename($from,$to) { Line 1447  function safe_rename($from,$to) {
1447                  exit ;                  exit ;
1448          case "V" :          case "V" :
1449                  // view                  // view
1450                  Log("viewed");                  LogIt("$gblFsRoot/$relDir/$F","viewed");
1451                  redir_to_url("$relDir/$F");                  header("Content-Disposition: attachment; filename=$F" );
1452                    Header("Location: ".urlpath("$relDir/$F"));
1453                    exit;
1454            case "Ch" :
1455                    StartHTML("(File changes)","All changes chronologicaly...");
1456                    DisplayChangeLog(0);    // all
1457                    EndHTML() ;
1458                    exit;
1459            case "Ch1" :
1460                    StartHTML("(File changes)","Changes to files in last day...");
1461                    DisplayChangeLog(1);
1462                    EndHTML() ;
1463                  exit;                  exit;
1464          }          }
1465    

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

  ViewVC Help
Powered by ViewVC 1.1.26