/[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.46 by dpavlin, Mon Oct 29 16:20:28 2001 UTC revision 1.53 by dpavlin, Fri Jan 11 10:06:28 2002 UTC
# Line 174  global $gblDateFmt, $gblTimeFmt, $gblUse Line 174  global $gblDateFmt, $gblTimeFmt, $gblUse
174  <B><?= date($gblDateFmt) ?> -  <B><?= date($gblDateFmt) ?> -
175  <?= date($gblTimeFmt) ?> -  <?= date($gblTimeFmt) ?> -
176  <?= $gblUserName ?>  <?= $gblUserName ?>
177  <small> [<a href="<?= $PHP_SELF ?>?relogin=<?= $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                    $url .= "&force_login=1";
188            } else {
189                    $url_title="relogin";
190            }
191    ?>
192    <small> [<a href="<?= $url ?>"><?= $url_title ?></a>]</small>
193  </B>  </B>
194  <BR><small>  <BR><small>
195  Document Manager <?= $gblVersion ?>, based on ANYPORTAL(php) Site Manager  Document Manager <?= $gblVersion ?>, based on ANYPORTAL(php) Site Manager
196  <br>  <br>
197  &copy; 1999 by <A HREF="http://www.anyportal.com">ANYPORTAL</A>,  &copy; 1999 by <A HREF="http://www.anyportal.com">ANYPORTAL</A>,
198  &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>,
199  &copy; 2000 by <A HREF="http://www.rot13.org/~dpavlin/">DbP</A>  &copy; 2000-2002 by <A HREF="http://www.rot13.org/~dpavlin/">DbP</A>
200  </small>  </small>
201  </P>  </P>
202  <BR>  <BR>
# Line 371  echo($fstr) ; ?></TEXTAREA> Line 386  echo($fstr) ; ?></TEXTAREA>
386                  $log=fopen($logname,"r");                  $log=fopen($logname,"r");
387                  $cl1=" class=LST"; $cl2="";                  $cl1=" class=LST"; $cl2="";
388                  $logarr = array();                  $logarr = array();
389                  while($line = fgetcsv($log,255,"\t")) {                  while($line = fgetcsv($log,512,"\t")) {
390                          $cl=$cl1; $cl1=$cl2; $cl2=$cl;                          $cl=$cl1; $cl1=$cl2; $cl2=$cl;
391                          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]));
392                  }                  }
# Line 701  function Navigate($fsRoot,$relDir) { Line 716  function Navigate($fsRoot,$relDir) {
716                  CELLSPACING=3 WIDTH=\"100%\">" ;                  CELLSPACING=3 WIDTH=\"100%\">" ;
717    
718          // updir bar              // updir bar    
719          if ($fsDir != $fsRoot) {          if (chopsl($fsDir) != chopsl($fsRoot)) {
720                  $parent = dirname($relDir) ;                  $parent = dirname($relDir) ;
721                  if ($parent == "") $parent = "/" ;                  if ($parent == "") $parent = "/" ;
722  ?>  ?>
# Line 849  function plural($name,$count) { Line 864  function plural($name,$count) {
864  <?  <?
865          }          }
866    
867          if ($emptyDir) {          if ($emptyDir && $relDir != "") {
868  ?>  ?>
869    
870  <FORM METHOD="POST" ACTION="<?= $self ?>">  <FORM METHOD="POST" ACTION="<?= $self ?>">
# Line 950  function NoEntry() { Line 965  function NoEntry() {
965    
966          $title = "(401 Unauthorized)" ;          $title = "(401 Unauthorized)" ;
967          $text  = "No trespassing !" ;          $text  = "No trespassing !" ;
968    
969            global $PHP_AUTH_USER,$PHP_AUTH_PW,$gblPw,$relogin;
970          StartHTML($title,$text) ;          StartHTML($title,$text) ;
971    
972          EndHTML() ;          EndHTML() ;
# Line 1145  function ChangeLog($target,$msg) { Line 1162  function ChangeLog($target,$msg) {
1162          $log=fopen("$gblFsRoot/.changelog","a+");          $log=fopen("$gblFsRoot/.changelog","a+");
1163          if (substr($target,0,strlen($gblFsRoot)) == $gblFsRoot)          if (substr($target,0,strlen($gblFsRoot)) == $gblFsRoot)
1164                  $target=substr($target,strlen($gblFsRoot),strlen($target)-strlen($gblFsRoot));                  $target=substr($target,strlen($gblFsRoot),strlen($target)-strlen($gblFsRoot));
1165            $msg=str_replace("\t"," ",$msg);
1166          fputs($log,time()."\t$target\t$GLOBALS[gblUserName]\t$msg\n");          fputs($log,time()."\t$target\t$GLOBALS[gblUserName]\t$msg\n");
1167          fclose($log);          fclose($log);
1168    
# Line 1156  function DisplayChangeLog($day) { Line 1174  function DisplayChangeLog($day) {
1174          if (!file_exists("$gblFsRoot/.changelog")) return;          if (!file_exists("$gblFsRoot/.changelog")) return;
1175          $log=fopen("$gblFsRoot/.changelog","r");          $log=fopen("$gblFsRoot/.changelog","r");
1176          $logarr = array();          $logarr = array();
1177          while($line = fgetcsv($log,255,"\t")) {          while($line = fgetcsv($log,512,"\t")) {
1178                    $line[0] .= sizeof($line);
1179                    while (sizeof($line) > 4) {
1180                            $tmp = array_pop($line);
1181                            $line.=" $tmp";
1182                    }
1183                  if ($day!=1 || ($day==1 && (time()-$line[0] < 24*60*60))) {                  if ($day!=1 || ($day==1 && (time()-$line[0] < 24*60*60))) {
1184                          array_unshift($logarr,array($line[0],$line[1],$line[2],$line[3]));                          array_unshift($logarr,array($line[0],$line[1],$line[2],$line[3]));
1185                  }                  }
# Line 1199  function Download($path) { Line 1222  function Download($path) {
1222    
1223  //////////////////////////////////////////////////////////////////  //////////////////////////////////////////////////////////////////
1224    
1225    function chopsl($path) {
1226            if (substr($path,strlen($path)-1,1) == "/") $path=substr($path,0,strlen($path)-1);
1227            $path=str_replace("//","/",$path);
1228            return $path;
1229    }
1230    
1231    //////////////////////////////////////////////////////////////////
1232  // MAIN PROGRAM  // MAIN PROGRAM
1233  // ============  // ============
1234  // query parameters: capital letters  // query parameters: capital letters
# Line 1213  function Download($path) { Line 1243  function Download($path) {
1243    
1244          // forks before authentication: style sheet and hash          // forks before authentication: style sheet and hash
1245          // creation if password not yet set.          // creation if password not yet set.
1246          if ($STYLE == "get") { CSS() ; exit ; }          if (isset($STYLE) && $STYLE == "get") { CSS() ; exit ; }
1247    
1248          $fsScriptDir  = dirname($SCRIPT_FILENAME) ;              $fsScriptDir  = dirname($SCRIPT_FILENAME) ;    
1249          // i.e. /home/httpd/html/docman          // i.e. /home/httpd/html/docman
# Line 1230  function Download($path) { Line 1260  function Download($path) {
1260                  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>");
1261          }          }
1262    
1263            // if no password, or empty password logout
1264            if (
1265                    isset($PHP_AUTH_USER) && (
1266                            !isset($relogin) || (
1267                                    isset($relogin) && $relogin != md5($PHP_AUTH_USER.$PHP_AUTH_PW)
1268                            )
1269                    ) && (
1270                            $PHP_AUTH_PW == "" || !isset($PHP_AUTH_PW)
1271                    ) && !isset($force_login)
1272               ) {
1273                    StartHTML("Logout completed","Your login credentials has been erased") ;
1274                    EndHTML() ;
1275                    exit ;
1276            }
1277    
1278          // authentication failure          // authentication failure
1279          if ( md5($PHP_AUTH_USER.$PHP_AUTH_PW) != $gblPw ||          if ( md5($PHP_AUTH_USER.$PHP_AUTH_PW) != $gblPw ||
1280                  isset($relogin) && $gblPw == $relogin ) {                  isset($relogin) && $gblPw == $relogin) {
1281                  header("WWW-authenticate: basic realm=\"$HTTP_HOST\"") ;                  $realm="$HTTP_HOST";
1282                    header("WWW-authenticate: basic realm=\"$realm\"") ;
1283                  header("HTTP/1.0 401 Unauthorized") ;                  header("HTTP/1.0 401 Unauthorized") ;
1284                  NoEntry() ;                  NoEntry() ;
1285                  exit ;                  exit ;
# Line 1456  function Download($path) { Line 1502  function Download($path) {
1502          // $A=Co : checkout file $D/$F          // $A=Co : checkout file $D/$F
1503          // $A=Ci : checkin file $D/$F          // $A=Ci : checkin file $D/$F
1504          // $A=V : view file (do nothing except log)          // $A=V : view file (do nothing except log)
1505            // $A=I : include file .$F.php from $gblFsRoot
1506          // default : display directory $D          // default : display directory $D
1507    
1508          switch ($A) {          switch ($A) {
# Line 1515  function Download($path) { Line 1562  function Download($path) {
1562                  DisplayChangeLog(1);                  DisplayChangeLog(1);
1563                  EndHTML() ;                  EndHTML() ;
1564                  exit;                  exit;
1565            case "I" :
1566                    $F=stripSlashes($F);
1567                    $inc_file="${gblFsRoot}/.${F}.php";
1568                    if (!isset($F) || $F == "" || !file_exists($inc_file)) Error("Fatal error $inc_file"); // can't find file to include
1569                    if (!is_readable($inc_file))
1570                            Error("Read access to include file denied",".${F}.php");
1571                    $text  = "Your include file should define \$text variable which holds this text and \$title variable which is page title";
1572                    $title = "You should define \$title variable with page title";
1573                    include($inc_file);
1574                    StartHTML($title, $text) ;
1575                    print "<p>".GifIcon(up)." Back to <a href=$GLOBALS[PHP_SELF]>front page</a>.</p>";
1576                    EndHTML() ;
1577                    exit ;
1578          }          }
1579    
1580          // default: display directory $relDir          // default: display directory $relDir

Legend:
Removed from v.1.46  
changed lines
  Added in v.1.53

  ViewVC Help
Powered by ViewVC 1.1.26