/[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.45 by dpavlin, Thu Jun 21 08:56:35 2001 UTC revision 1.51 by dpavlin, Mon Dec 17 10:00:51 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 128  TODO: Line 133  TODO:
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 138  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 157  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>  <?php
178            global $PHP_AUTH_USER,$PHP_AUTH_PW;
179            $url = $PHP_SELF."?relogin=";
180            if (isset($gblPw) && $gblPw != "") {
181                    $url .= $gblPw;
182            } else {
183                    $url .= md5($PHP_AUTH_USER.$PHP_AUTH_PW);
184            }
185            if (isset($PHP_AUTH_USER) && $PHP_AUTH_USER != "" && ($PHP_AUTH_PW == "" || !isset($PHP_AUTH_PW))) {
186                    $url_title="login";
187            } else {
188                    $url_title="relogin";
189            }
190    ?>
191    <small> [<a href="<?= $url ?>"><?= $url_title ?></a>]</small>
192  </B>  </B>
193  <BR>ANYPORTAL(php) Site Manager  <BR><small>
194  <br><small>  Document Manager <?= $gblVersion ?>, based on ANYPORTAL(php) Site Manager
195    <br>
196  &copy; 1999 by <A HREF="http://www.anyportal.com">ANYPORTAL</A>,  &copy; 1999 by <A HREF="http://www.anyportal.com">ANYPORTAL</A>,
197  &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>,
198  &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 360  echo($fstr) ; ?></TEXTAREA> Line 385  echo($fstr) ; ?></TEXTAREA>
385                  $log=fopen($logname,"r");                  $log=fopen($logname,"r");
386                  $cl1=" class=LST"; $cl2="";                  $cl1=" class=LST"; $cl2="";
387                  $logarr = array();                  $logarr = array();
388                  while($line = fgetcsv($log,255,"\t")) {                  while($line = fgetcsv($log,512,"\t")) {
389                          $cl=$cl1; $cl1=$cl2; $cl2=$cl;                          $cl=$cl1; $cl1=$cl2; $cl2=$cl;
390                          array_unshift($logarr,array($cl,$line[0],$line[1],$line[2],$line[3]));                          array_unshift($logarr,array($cl,$line[0],$line[1],$line[2],$line[3]));
391                  }                  }
# Line 690  function Navigate($fsRoot,$relDir) { Line 715  function Navigate($fsRoot,$relDir) {
715                  CELLSPACING=3 WIDTH=\"100%\">" ;                  CELLSPACING=3 WIDTH=\"100%\">" ;
716    
717          // updir bar              // updir bar    
718          if ($fsDir != $fsRoot) {          if (chopsl($fsDir) != chopsl($fsRoot)) {
719                  $parent = dirname($relDir) ;                  $parent = dirname($relDir) ;
720                  if ($parent == "") $parent = "/" ;                  if ($parent == "") $parent = "/" ;
721  ?>  ?>
# Line 838  function plural($name,$count) { Line 863  function plural($name,$count) {
863  <?  <?
864          }          }
865    
866          if ($emptyDir) {          if ($emptyDir && $relDir != "") {
867  ?>  ?>
868    
869  <FORM METHOD="POST" ACTION="<?= $self ?>">  <FORM METHOD="POST" ACTION="<?= $self ?>">
# Line 939  function NoEntry() { Line 964  function NoEntry() {
964    
965          $title = "(401 Unauthorized)" ;          $title = "(401 Unauthorized)" ;
966          $text  = "No trespassing !" ;          $text  = "No trespassing !" ;
967    
968            global $PHP_AUTH_USER,$PHP_AUTH_PW,$gblPw,$relogin;
969          StartHTML($title,$text) ;          StartHTML($title,$text) ;
970    
971          EndHTML() ;          EndHTML() ;
# Line 1134  function ChangeLog($target,$msg) { Line 1161  function ChangeLog($target,$msg) {
1161          $log=fopen("$gblFsRoot/.changelog","a+");          $log=fopen("$gblFsRoot/.changelog","a+");
1162          if (substr($target,0,strlen($gblFsRoot)) == $gblFsRoot)          if (substr($target,0,strlen($gblFsRoot)) == $gblFsRoot)
1163                  $target=substr($target,strlen($gblFsRoot),strlen($target)-strlen($gblFsRoot));                  $target=substr($target,strlen($gblFsRoot),strlen($target)-strlen($gblFsRoot));
1164            $msg=str_replace("\t"," ",$msg);
1165          fputs($log,time()."\t$target\t$GLOBALS[gblUserName]\t$msg\n");          fputs($log,time()."\t$target\t$GLOBALS[gblUserName]\t$msg\n");
1166          fclose($log);          fclose($log);
1167    
# Line 1145  function DisplayChangeLog($day) { Line 1173  function DisplayChangeLog($day) {
1173          if (!file_exists("$gblFsRoot/.changelog")) return;          if (!file_exists("$gblFsRoot/.changelog")) return;
1174          $log=fopen("$gblFsRoot/.changelog","r");          $log=fopen("$gblFsRoot/.changelog","r");
1175          $logarr = array();          $logarr = array();
1176          while($line = fgetcsv($log,255,"\t")) {          while($line = fgetcsv($log,512,"\t")) {
1177                    $line[0] .= sizeof($line);
1178                    while (sizeof($line) > 4) {
1179                            $tmp = array_pop($line);
1180                            $line.=" $tmp";
1181                    }
1182                  if ($day!=1 || ($day==1 && (time()-$line[0] < 24*60*60))) {                  if ($day!=1 || ($day==1 && (time()-$line[0] < 24*60*60))) {
1183                          array_unshift($logarr,array($line[0],$line[1],$line[2],$line[3]));                          array_unshift($logarr,array($line[0],$line[1],$line[2],$line[3]));
1184                  }                  }
# Line 1167  function DisplayChangeLog($day) { Line 1200  function DisplayChangeLog($day) {
1200    
1201  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
1202    
1203    function Download($path) {
1204            global $HTTP_USER_AGENT;
1205            $file=basename($path);
1206            $size = filesize($path);
1207            //header("Content-Type: application/octet-stream");
1208            header("Content-Type: application/force-download");
1209            header("Content-Length: $size");
1210            // IE5.5 just downloads index.php if we don't do this
1211            if(preg_match("/MSIE 5.5/", $HTTP_USER_AGENT)) {
1212                    header("Content-Disposition: filename=$file");
1213            } else {
1214                    header("Content-Disposition: attachment; filename=$file");
1215            }
1216            header("Content-Transfer-Encoding: binary");
1217            $fh = fopen($path, "r");
1218            fpassthru($fh);
1219    }
1220    
1221    
1222    //////////////////////////////////////////////////////////////////
1223    
1224    function chopsl($path) {
1225            if (substr($path,strlen($path)-1,1) == "/") $path=substr($path,0,strlen($path)-1);
1226            $path=str_replace("//","/",$path);
1227            return $path;
1228    }
1229    
1230    //////////////////////////////////////////////////////////////////
1231  // MAIN PROGRAM  // MAIN PROGRAM
1232  // ============  // ============
1233  // query parameters: capital letters  // query parameters: capital letters
# Line 1198  function DisplayChangeLog($day) { Line 1259  function DisplayChangeLog($day) {
1259                  Error("Configuration error","Can't find user handling module at <tt>$gblIncDir/$gblUsers.php</tt> ! Please fix <tt>$fsScriptDir/.docman.conf</tt>");                  Error("Configuration error","Can't find user handling module at <tt>$gblIncDir/$gblUsers.php</tt> ! Please fix <tt>$fsScriptDir/.docman.conf</tt>");
1260          }          }
1261    
1262            // if no password, or empty password logout
1263            if (
1264                    isset($PHP_AUTH_USER) && (
1265                            !isset($relogin) || (
1266                                    isset($relogin) && $relogin != md5($PHP_AUTH_USER.$PHP_AUTH_PW)
1267                            )
1268                    ) && (
1269                            $PHP_AUTH_PW == "" || !isset($PHP_AUTH_PW)
1270                    )
1271               ) {
1272                    StartHTML("Logout completed","Your login credentials has been erased") ;
1273                    EndHTML() ;
1274                    exit ;
1275            }
1276    
1277          // authentication failure          // authentication failure
1278          if ( md5($PHP_AUTH_USER.$PHP_AUTH_PW) != $gblPw ||          if ( md5($PHP_AUTH_USER.$PHP_AUTH_PW) != $gblPw ||
1279                  isset($relogin) && $gblPw == $relogin ) {                  isset($relogin) && $gblPw == $relogin) {
1280                  header("WWW-authenticate: basic realm=\"$HTTP_HOST\"") ;                  header("WWW-authenticate: basic realm=\"$HTTP_HOST\"") ;
1281                  header("HTTP/1.0 401 Unauthorized") ;                  header("HTTP/1.0 401 Unauthorized") ;
1282                  NoEntry() ;                  NoEntry() ;
# Line 1424  function DisplayChangeLog($day) { Line 1500  function DisplayChangeLog($day) {
1500          // $A=Co : checkout file $D/$F          // $A=Co : checkout file $D/$F
1501          // $A=Ci : checkin file $D/$F          // $A=Ci : checkin file $D/$F
1502          // $A=V : view file (do nothing except log)          // $A=V : view file (do nothing except log)
1503            // $A=I : include file .$F.php from $gblFsRoot
1504          // default : display directory $D          // default : display directory $D
1505    
1506          switch ($A) {          switch ($A) {
# Line 1450  function DisplayChangeLog($day) { Line 1527  function DisplayChangeLog($day) {
1527          case "Co" :          case "Co" :
1528                  // checkout                  // checkout
1529                  Lock("$gblFsRoot/$relDir/$F");                  Lock("$gblFsRoot/$relDir/$F");
1530                  header("Content-Disposition: attachment; filename=$F" );                  Download("$gblFsRoot/$relDir/$F");
                 Header("Location: $webRoot".urlpath("$relDir/$F"));  
1531                  exit;                  exit;
1532          case "Ci" :          case "Ci" :
1533                  $F=stripSlashes($F);                  $F=stripSlashes($F);
# Line 1467  function DisplayChangeLog($day) { Line 1543  function DisplayChangeLog($day) {
1543          case "V" :          case "V" :
1544                  // view                  // view
1545                  LogIt("$gblFsRoot/$relDir/$F","viewed");                  LogIt("$gblFsRoot/$relDir/$F","viewed");
1546                  header("Content-Disposition: attachment; filename=$F" );                  if ($gblForceDownload) {
1547                  Header("Location: $webRoot".urlpath("$relDir/$F"));                          Download("$gblFsRoot/$relDir/$F");
1548                    } else {
1549                            header("Content-Disposition: attachment; filename=$F" );
1550                            Header("Location: $webRoot".urlpath("$relDir/$F"));
1551                    }
1552                  exit;                  exit;
1553          case "Ch" :          case "Ch" :
1554                  StartHTML("(File changes)","All changes chronologicaly...");                  StartHTML("(File changes)","All changes chronologicaly...");
# Line 1480  function DisplayChangeLog($day) { Line 1560  function DisplayChangeLog($day) {
1560                  DisplayChangeLog(1);                  DisplayChangeLog(1);
1561                  EndHTML() ;                  EndHTML() ;
1562                  exit;                  exit;
1563            case "I" :
1564                    $F=stripSlashes($F);
1565                    $inc_file="${gblFsRoot}/.${F}.php";
1566                    if (!isset($F) || $F == "" || !file_exists($inc_file)) Error("Fatal error $inc_file"); // can't find file to include
1567                    if (!is_readable($inc_file))
1568                            Error("Read access to include file denied",".${F}.php");
1569                    $text  = "Your include file should define \$text variable which holds this text and \$title variable which is page title";
1570                    $title = "You should define \$title variable with page title";
1571                    include($inc_file);
1572                    StartHTML($title, $text) ;
1573                    print "<p>".GifIcon(up)." Back to <a href=$GLOBALS[PHP_SELF]>front page</a>.</p>";
1574                    EndHTML() ;
1575                    exit ;
1576          }          }
1577    
1578          // default: display directory $relDir          // default: display directory $relDir

Legend:
Removed from v.1.45  
changed lines
  Added in v.1.51

  ViewVC Help
Powered by ViewVC 1.1.26