120 |
$gblImages = array( ".jpg",".jpeg",".gif",".png",".ico", |
$gblImages = array( ".jpg",".jpeg",".gif",".png",".ico", |
121 |
".bmp",".xbm") ; |
".bmp",".xbm") ; |
122 |
|
|
123 |
|
// which files to hide (separated by ,) |
124 |
|
$gblHide = ""; |
125 |
|
|
126 |
|
// Where are users? (by default in .htusers file) |
127 |
|
$gblUsers = "htusers_file"; |
128 |
|
|
129 |
////////////////////////////////////////////////////////////////// |
////////////////////////////////////////////////////////////////// |
130 |
|
|
131 |
function StartHTML($title,$text="") { |
function StartHTML($title,$text="") { |
636 |
|
|
637 |
function Navigate($fsRoot,$relDir) { |
function Navigate($fsRoot,$relDir) { |
638 |
|
|
639 |
global $gblEditable, $gblIcon, $gblModDays, $webRoot ; |
global $gblEditable, $gblIcon, $gblModDays, $webRoot, $gblHide ; |
640 |
|
|
641 |
$self = $GLOBALS["PHP_SELF"] ; |
$self = $GLOBALS["PHP_SELF"] ; |
642 |
|
|
644 |
|
|
645 |
if (!is_dir($fsDir)) Error("Dir not found",$relDir) ; |
if (!is_dir($fsDir)) Error("Dir not found",$relDir) ; |
646 |
|
|
647 |
|
$hide_items=",$gblHide,"; |
648 |
|
|
649 |
// read directory contents |
// read directory contents |
650 |
if ( !($dir = @opendir($fsDir)) ) |
if ( !($dir = @opendir($fsDir)) ) |
651 |
Error("Read Access denied",$relDir) ; |
Error("Read Access denied",$relDir) ; |
652 |
while ($item = readdir($dir)) { |
while ($item = readdir($dir)) { |
653 |
if ( $item == ".." || $item == "." || substr($item,0,1) == "." ) continue ; |
if ( substr($item,0,1) == "." || strstr($hide_items,",$item,") ) continue ; |
654 |
if ( is_dir($fsDir . $item) ) { |
if ( is_dir($fsDir . $item) ) { |
655 |
$dirList[] = $item ; |
$dirList[] = $item ; |
656 |
} else if ( is_file($fsDir . $item) ) { |
} else if ( is_file($fsDir . $item) ) { |
669 |
// scan deleted files |
// scan deleted files |
670 |
if ( $GLOBALS[show_deleted] == 1 && ($dir = @opendir("$fsDir/.del")) ) { |
if ( $GLOBALS[show_deleted] == 1 && ($dir = @opendir("$fsDir/.del")) ) { |
671 |
while ($item = readdir($dir)) { |
while ($item = readdir($dir)) { |
672 |
if ( substr($item,0,1) == "." ) continue ; |
if ( substr($item,0,1) == "." || strstr($hide_items,",$item,") ) continue ; |
673 |
$fileList[] = ".del/$item" ; |
$fileList[] = ".del/$item" ; |
674 |
} |
} |
675 |
closedir($dir) ; |
closedir($dir) ; |
1183 |
// creation if password not yet set. |
// creation if password not yet set. |
1184 |
if ($STYLE == "get") { CSS() ; exit ; } |
if ($STYLE == "get") { CSS() ; exit ; } |
1185 |
|
|
1186 |
$htusers_file=dirname($SCRIPT_FILENAME)."/.htusers"; |
$fsScriptDir = dirname($SCRIPT_FILENAME) ; |
1187 |
if (! file_exists($htusers_file)) { |
// i.e. /home/httpd/html/docman |
1188 |
if (is_writeable(dirname($SCRIPT_FILENAME))) { |
|
1189 |
$htusers=fopen($htusers_file,"a+"); |
// read user-defined configuration |
1190 |
fputs($htusers,"# Change owner of $htusers_file to root !!\n"); |
if (file_exists("$fsScriptDir/.docman.conf")) { |
1191 |
fputs($htusers,"demo:full name:[md5_hash|auth_*]:e-mail\n"); |
include("$fsScriptDir/.docman.conf"); |
|
fclose($htusers); |
|
|
Error("Proto user file created!","Please edit <tt>$htusers_file</tt> and set it correct permissions (<B>not writable by web server as it is now!</b>). You can add users using <tt>adduser.pl</tt> script!"); |
|
|
exit; |
|
|
} else { |
|
|
Error("Can't create proto user file!","Please make directory <tt>".dirname($htusers_file)."</tt> writable or create <tt>.htusers</tt> file by hand using <tt>adduser.pl</tt> script!"); |
|
|
exit; |
|
|
} |
|
1192 |
} |
} |
1193 |
$htusers=fopen($htusers_file,"r"); |
|
1194 |
while($user = fgetcsv($htusers,255,":")) { |
// where do we get users from? |
1195 |
if ($user[0] == $GLOBALS["PHP_AUTH_USER"]) { |
if (file_exists("$gblIncDir/$gblUsers.php")) { |
1196 |
$gblUserName=$user[1]; |
include("$gblIncDir/$gblUsers.php"); |
1197 |
$gblPw=$user[2]; |
} else { |
1198 |
if (substr($gblPw,0,5) == "auth_" && file_exists("$gblIncDir/$gblPw.php")) { |
Error("Configuration error","Can't find user handling module at <tt>$gblIncDir/$gblUsers.php</tt> ! Please fix <tt>$fsScriptDir/.docman.conf</tt>"); |
|
require("$gblIncDir/$gblPw.php"); |
|
|
if ($gblPw($user)) { |
|
|
$gblPw=md5($PHP_AUTH_USER.$PHP_AUTH_PW); |
|
|
} else { |
|
|
$gblPw="error".md5($PHP_AUTH_USER.$PHP_AUTH_PW); |
|
|
} |
|
|
} |
|
|
$gblEmail=$user[3]; |
|
|
continue ; |
|
|
} |
|
1199 |
} |
} |
|
fclose($htusers); |
|
1200 |
|
|
1201 |
// authentication failure |
// authentication failure |
1202 |
if ( md5($PHP_AUTH_USER.$PHP_AUTH_PW) != $gblPw || |
if ( md5($PHP_AUTH_USER.$PHP_AUTH_PW) != $gblPw || |
1228 |
$relScriptDir = dirname($SCRIPT_NAME) ; |
$relScriptDir = dirname($SCRIPT_NAME) ; |
1229 |
// i.e. /docman |
// i.e. /docman |
1230 |
|
|
|
$fsScriptDir = dirname($SCRIPT_FILENAME) ; |
|
|
// i.e. /home/httpd/html/docman |
|
|
|
|
1231 |
// start on server root |
// start on server root |
1232 |
// $gblFsRoot = substr($fsScriptDir,0, strlen($fsScriptDir)-strlen($relScriptDir)) ; |
// $gblFsRoot = substr($fsScriptDir,0, strlen($fsScriptDir)-strlen($relScriptDir)) ; |
1233 |
// or on script root |
// or on script root |
1246 |
|
|
1247 |
$FN=stripSlashes($FN); |
$FN=stripSlashes($FN); |
1248 |
|
|
|
if (file_exists("$fsScriptDir/.docman.conf")) { |
|
|
include("$fsScriptDir/.docman.conf"); |
|
|
} |
|
1249 |
|
|
1250 |
switch ($POSTACTION) { |
switch ($POSTACTION) { |
1251 |
case "UPLOAD" : |
case "UPLOAD" : |