/[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.10 by dpavlin, Fri Aug 4 11:23:07 2000 UTC revision 1.18 by dpavlin, Thu Sep 7 10:17:35 2000 UTC
# Line 66  TODO: Line 66  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          retrieve old versions of files (overwritten)          retrieve old versions of files (overwritten)
69            show last lock date
70            
71  */  */
72    
73  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
# Line 106  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 118  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 293  echo($fstr) ; ?></TEXTAREA> Line 299  echo($fstr) ; ?></TEXTAREA>
299    
300  <?php  <?php
301          }          }
302          if ( !$file_lock && strstr(join(" ",$gblImages),$ext) ) {            if ( !$file_lock && $ext!="" && strstr(join(' ',$gblImages),$ext) ) {  
303                  $info  = getimagesize($fsPath) ;                  $info  = getimagesize($fsPath) ;
304                  $tstr = "<IMG SRC=\"".urlpath($relPath)."\" BORDER=0 " ;                  $tstr = "<IMG SRC=\"".urlpath($relPath)."\" BORDER=0 " ;
305                  $tstr .= $info[3] . " ALT=\"" . $fn . " - " ;                  $tstr .= $info[3] . " ALT=\"" . $fn . " - " ;
# Line 640  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 689  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 755  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 843  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 1098  function safe_rename($from,$to) { Line 1105  function safe_rename($from,$to) {
1105    
1106  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
1107    
1108    // recursivly delete directory
1109    
1110    function rrmdir($dir) {
1111            $handle=opendir($dir);
1112            while ($file = readdir($handle)) {
1113                    if ($file != "." && $file != "..") {
1114                            if (is_dir("$dir/$file"))
1115                                    rrmdir("$dir/$file");
1116                            else
1117                                    if (! @unlink("$dir/$file")) return(0);
1118                    }
1119            }
1120            closedir($handle);
1121            return @rmdir($dir);
1122    }
1123    
1124    //////////////////////////////////////////////////////////////////
1125    
1126    function ChangeLog($target,$msg) {
1127    
1128            global $gblFsRoot;
1129            $log=fopen("$gblFsRoot/.changelog","a+");
1130            if (substr($target,0,strlen($gblFsRoot)) == $gblFsRoot)
1131                    $target=substr($target,strlen($gblFsRoot),strlen($target)-strlen($gblFsRoot));
1132            fputs($log,time()."\t$target\t$GLOBALS[gblUserName]\t$msg\n");
1133            fclose($log);
1134    
1135    }
1136    
1137    function DisplayChangeLog($day) {
1138    
1139            global $gblFsRoot;
1140            $log=fopen("$gblFsRoot/.changelog","r");
1141            $logarr = array();
1142            while($line = fgetcsv($log,255,"\t")) {
1143                    if ($day!=1 || $day==1 && $line[0]-time() < 24*60) {
1144                            array_unshift($logarr,array($line[0],$line[1],$line[2],$line[3]));
1145                    }
1146            }
1147            fclose($log);
1148            $cl1=" class=lst"; $cl2="";
1149            print "<table border=0 width=100%>\n";
1150            while ($e = array_shift($logarr)) {
1151                    $cl=$cl1; $cl1=$cl2; $cl2=$cl;
1152                    $date = date("$GLOBALS[gblDateFmt]", $e[0]);
1153                    $time = date("$GLOBALS[gblTimeFmt]", $e[0]);
1154                    $dir = dirname($e[1]);
1155                    $file = basename($e[1]);
1156                    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";
1157            }
1158            print "</table>";
1159    }
1160    
1161    //////////////////////////////////////////////////////////////////
1162    
1163  // MAIN PROGRAM  // MAIN PROGRAM
1164  // ============  // ============
1165  // query parameters: capital letters  // query parameters: capital letters
# Line 1191  function safe_rename($from,$to) { Line 1253  function safe_rename($from,$to) {
1253                  if (isset($FILENAME)) {                  if (isset($FILENAME)) {
1254                          Unlock($target);                          Unlock($target);
1255                  }                  }
1256                    ChangeLog($target,"updated");
1257                  break ;                  break ;
1258    
1259          case "SAVE" :          case "SAVE" :
1260                  $path = $gblFsRoot . escapeshellcmd($RELPATH) ;                  $path = $gblFsRoot . $RELPATH ;
1261                  $writable = is_writeable($path) ;                  $writable = is_writeable($path) ;
1262                  $legaldir = is_writeable(dirname($path)) ;                  $legaldir = is_writeable(dirname($path)) ;
1263                  $exists   = (file_exists($path)) ? 1 : 0 ;                  $exists   = (file_exists($path)) ? 1 : 0 ;
# Line 1206  function safe_rename($from,$to) { Line 1269  function safe_rename($from,$to) {
1269                  fclose($fh) ;                  fclose($fh) ;
1270                  clearstatcache() ;                  clearstatcache() ;
1271                  Logit($path,"saved changes");                  Logit($path,"saved changes");
1272                    ChangeLog($path,"saved changes");
1273                  break ;                  break ;
1274    
1275          case "CREATE" :          case "CREATE" :
# Line 1236  function safe_rename($from,$to) { Line 1300  function safe_rename($from,$to) {
1300                          }                          }
1301                          $tstr = "$PHP_SELF?A=E&D=".urlencode($relDir)."&F=".urlencode($FN) ;                          $tstr = "$PHP_SELF?A=E&D=".urlencode($relDir)."&F=".urlencode($FN) ;
1302                          header("Location: " . $tstr) ;                          header("Location: " . $tstr) ;
1303                            ChangeLog($target,"created");
1304                          exit ;                          exit ;
1305                  }                  }
1306                  break ;                  break ;
# Line 1268  function safe_rename($from,$to) { Line 1333  function safe_rename($from,$to) {
1333                          }                          }
1334                  }                  }
1335                  else {  // delete directory                  else {  // delete directory
1336                    if ( ! @rmdir($fsDir) ) {                    if ( ! @rrmdir($fsDir) ) {
1337                      Error("Rmdir failed", $tstr . $fsDir) ;                      Error("Rmdir failed", $tstr . $fsDir) ;
1338                    }                    }
1339                    else {                    else {
# Line 1299  function safe_rename($from,$to) { Line 1364  function safe_rename($from,$to) {
1364                  safe_rename("$fsDir/.log/$FN","$fsDir/.log/$NEWNAME");                  safe_rename("$fsDir/.log/$FN","$fsDir/.log/$NEWNAME");
1365                  safe_rename("$fsDir/.note/$FN","$fsDir/.note/$NEWNAME");                  safe_rename("$fsDir/.note/$FN","$fsDir/.note/$NEWNAME");
1366                  safe_rename("$fsDir/.lock/$FN","$fsDir/.lock/$NEWNAME");                  safe_rename("$fsDir/.lock/$FN","$fsDir/.lock/$NEWNAME");
1367                    for($i=0;$i<=$GLOBALS[gblNumBackups];$i++) {
1368                            safe_rename("$fsDir/.bak/$i/$FN","$fsDir/.bak/$i/$NEWNAME");
1369                    }
1370    
1371                  break ;                  break ;
1372    
# Line 1353  function safe_rename($from,$to) { Line 1421  function safe_rename($from,$to) {
1421          case "Co" :          case "Co" :
1422                  // checkout                  // checkout
1423                  Lock("$gblFsRoot/$relDir/$F");                  Lock("$gblFsRoot/$relDir/$F");
1424                    header("Content-Disposition: attachment; filename=$F" );
1425                  Header("Location: ".urlpath("$relDir/$F"));                  Header("Location: ".urlpath("$relDir/$F"));
1426                  exit;                  exit;
1427          case "Ci" :          case "Ci" :
# Line 1368  function safe_rename($from,$to) { Line 1437  function safe_rename($from,$to) {
1437          case "V" :          case "V" :
1438                  // view                  // view
1439                  LogIt("$gblFsRoot/$relDir/$F","viewed");                  LogIt("$gblFsRoot/$relDir/$F","viewed");
1440                    header("Content-Disposition: attachment; filename=$F" );
1441                  Header("Location: ".urlpath("$relDir/$F"));                  Header("Location: ".urlpath("$relDir/$F"));
1442                  exit;                  exit;
1443            case "Ch" :
1444                    StartHTML("(File changes)","All changes chronologicaly...");
1445                    DisplayChangeLog(0);    // all
1446                    EndHTML() ;
1447                    exit;
1448            case "Ch1" :
1449                    StartHTML("(File changes)","Changes to files in last day...");
1450                    DisplayChangeLog(1);
1451                    EndHTML() ;
1452                    exit;
1453          }          }
1454    
1455          // default: display directory $relDir          // default: display directory $relDir

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.18

  ViewVC Help
Powered by ViewVC 1.1.26