25 |
// from where to include auth_*.php modules? |
// from where to include auth_*.php modules? |
26 |
$gblIncDir = "/data/docman2"; |
$gblIncDir = "/data/docman2"; |
27 |
|
|
28 |
// force download (so it won't open in associated application) |
// force download on view (so it won't open in associated application) |
29 |
$gblForceDownload = 1; |
$gblForceDownload = 0; |
30 |
|
|
31 |
// date format |
// date format |
32 |
$gblDateFmt="Y-m-d"; |
$gblDateFmt="Y-m-d"; |
84 |
LoadLanguage($HTTP_SERVER_VARS["HTTP_ACCEPT_LANGUAGE"]); |
LoadLanguage($HTTP_SERVER_VARS["HTTP_ACCEPT_LANGUAGE"]); |
85 |
|
|
86 |
// for security and configuration |
// for security and configuration |
87 |
$realm="$HTTP_HOST"; // FIX |
$realm=$HTTP_SERVER_VARS[HTTP_HOST]; |
88 |
|
|
89 |
$fsDocumentRoot = dirname($HTTP_SERVER_VARS[SCRIPT_FILENAME]); |
$fsDocumentRoot = dirname($HTTP_SERVER_VARS[SCRIPT_FILENAME]); |
90 |
if ($fsDocumentRoot == "") Error("Configuration error","Can't get SCRIPT_FILENAME from your web server. Please set <tt>\$fsDocumentRoot</tt> in <tt>\$</tt>"); |
if ($fsDocumentRoot == "") Error("Configuration error","Can't get SCRIPT_FILENAME from your web server. Please set <tt>\$fsDocumentRoot</tt> in <tt>\$</tt>",1); |
91 |
|
|
92 |
// globals for later |
// globals for later |
93 |
$gblLogin = $PHP_AUTH_USER; |
$gblLogin = $HTTP_SERVER_VARS[PHP_AUTH_USER]; |
94 |
$gblPasswd = $PHP_AUTH_PW; |
$gblPasswd = $HTTP_SERVER_VARS[PHP_AUTH_PW]; |
95 |
|
|
96 |
////////////////////////////////////////////////////////////////// |
////////////////////////////////////////////////////////////////// |
97 |
|
|
109 |
|
|
110 |
function StartHTML($title,$text="") { |
function StartHTML($title,$text="") { |
111 |
|
|
112 |
global $html,$fsDocumentRoot; |
global $html,$fsDocumentRoot,$HTTP_SERVER_VARS; |
113 |
|
|
114 |
$title = $gblTitle." ".$title ; |
$title = $gblTitle." ".$title ; |
115 |
$host = $GLOBALS["HTTP_HOST"] ; |
$host = $HTTP_SERVER_VARS["HTTP_HOST"] ; |
116 |
$self = $GLOBALS["PHP_SELF"] ; |
$self = $HTTP_SERVER_VARS["PHP_SELF"] ; |
117 |
|
|
118 |
if (file_exists("$fsDocumentRoot/docman.css")) { |
if (file_exists("$fsDocumentRoot/docman.css")) { |
119 |
$css=dirname($self)."/docman.css"; |
$css=dirname($self)."/docman.css"; |
120 |
} else { |
} else { |
121 |
$css=$self."?STYLE=get&css=$css"; |
$css=$self."?STYLE=get"; |
122 |
} |
} |
123 |
|
|
124 |
include("$html/head.html"); |
include("$html/head.html"); |
145 |
$url_title="relogin"; |
$url_title="relogin"; |
146 |
} |
} |
147 |
include("$html/footer.html"); |
include("$html/footer.html"); |
148 |
//phpinfo(); |
|
149 |
|
global $debug; |
150 |
|
if ($debug) print $debug; |
151 |
} // end function EndHTML |
} // end function EndHTML |
152 |
|
|
153 |
////////////////////////////////////////////////////////////////// |
////////////////////////////////////////////////////////////////// |
154 |
|
|
155 |
function DetailPage($fsRoot,$relDir,$fn) { |
function DetailPage($fsRoot,$relDir,$fn) { |
156 |
|
|
157 |
global $gblEditable, $gblImages, $webRoot, $html ; |
global $gblEditable, $gblImages, $webRoot, $html, $HTTP_SERVER_VARS ; |
158 |
$self = $GLOBALS["PHP_SELF"] ; |
$self = $HTTP_SERVER_VARS["PHP_SELF"] ; |
159 |
|
|
160 |
$relPath = $relDir . "/" . $fn ; |
$relPath = $relDir . "/" . $fn ; |
161 |
$fsPath = $fsRoot . $relPath ; |
$fsPath = $fsRoot . $relPath ; |
163 |
|
|
164 |
$exists = file_exists($fsPath) ; |
$exists = file_exists($fsPath) ; |
165 |
$ext = strtolower(strrchr($relPath,".")) ; |
$ext = strtolower(strrchr($relPath,".")) ; |
166 |
$editable = ( $ext=="" || strstr(join(" ",$gblEditable),$ext)) ; |
$editable = ( $ext=="" || strstr(join(" ",$gblEditable),$ext)) && |
167 |
$writable = is_writeable($fsPath) ; |
check_perm($relPath,trperm_w); |
168 |
|
$writable = is_writeable($fsPath) && check_perm($relPath,trperm_w) ; |
169 |
|
$writable_dir = is_writeable($fsDir) && check_perm($relDir,trperm_w) ; |
170 |
$file_lock = CheckLock($fsPath); |
$file_lock = CheckLock($fsPath); |
171 |
|
|
172 |
if (!$editable && !$exists) |
if (!$editable && !$exists) |
173 |
Error(_("Creation unsupported for type"),$relPath) ; |
Error("Creation denied","Can't create <tt>$relPath</tt>") ; |
174 |
if (!exists && !is_writeable($fsDir) ) |
if (!$exists && !$writable_dir ) |
175 |
Error(_("Creation denied"),$relDir) ; |
Error("Creation denied","Can't write in directory <tt>$relDir</tt> while creating <tt>$relPath</tt>for which user has permissions.",1); |
176 |
|
|
177 |
$text = _("Use this page to view, modify or ") ; |
$text = _("Use this page to view, modify or ") ; |
178 |
if (is_dir($fsPath)) { |
if (is_dir($fsPath)) { |
205 |
$fstr = htmlentities( $fstr ) ; |
$fstr = htmlentities( $fstr ) ; |
206 |
?> |
?> |
207 |
|
|
208 |
<FORM ACTION="<?= $self ; ?>" METHOD="POST"> |
<FORM ACTION="<?= $self ?>" METHOD="POST"> |
209 |
<SPAN TITLE="Click [SAVE] to store updated contents."> |
<SPAN TITLE="Click [SAVE] to store updated contents."> |
210 |
<B>DOCUMENT CONTENTS</B> |
<B>DOCUMENT CONTENTS</B> |
211 |
</SPAN><BR> |
</SPAN><BR> |
576 |
function Navigate($fsRoot,$relDir) { |
function Navigate($fsRoot,$relDir) { |
577 |
|
|
578 |
global $gblEditable, $gblIcon, $gblModDays, $webRoot, $gblHide, |
global $gblEditable, $gblIcon, $gblModDays, $webRoot, $gblHide, |
579 |
$HTTP_GET_VARS, $html; |
$gblIgnoreUnknownFileType, $gblRepositoryDir, |
580 |
|
$fsRealmDir, $realm, $realm_sep, |
581 |
$self = $GLOBALS["PHP_SELF"] ; |
$HTTP_GET_VARS, $html, $realm_config; |
582 |
|
|
583 |
if ($relDir == "") $relDir = "/"; |
$self = $HTTP_SERVER_VARS["PHP_SELF"] ; |
584 |
|
|
585 |
$fsDir = $fsRoot.$relDir."/"; // current directory |
$fsDir = $fsRoot.$relDir."/"; // current directory |
586 |
|
|
587 |
if (!is_dir($fsDir)) Error("Dir not found",$relDir) ; |
if (!is_dir($fsDir)) Error("Dir not found",$relDir,1) ; |
588 |
|
|
589 |
$hide_items=",$gblHide,"; |
$hide_items=",$gblHide,"; |
590 |
|
|
|
#display_all_trustee(); |
|
|
print "-- $fsDir --"; |
|
|
|
|
591 |
// read directory contents |
// read directory contents |
592 |
if ( !($dir = @opendir($fsDir)) ) |
if ( !($dir = @opendir($fsDir)) ) |
593 |
Error("Read Access denied",$relDir) ; |
Error("Read Access denied",$relDir,1) ; |
594 |
while ($item = readdir($dir)) { |
while ($item = readdir($dir)) { |
|
print "$item, "; |
|
595 |
if ( substr($item,0,1) == "." || strstr($hide_items,",$item,") ) continue ; |
if ( substr($item,0,1) == "." || strstr($hide_items,",$item,") ) continue ; |
596 |
if ((is_dir($fsDir.$item) || is_link ($fsDir.$item)) && check_perm($relDir.$item,trperm_b)) { |
if (is_dir($fsDir.$item) || is_link ($fsDir.$item)) { |
597 |
$dirList[$item] = $item ; |
if (check_perm($relDir.$item,trperm_b)) { |
598 |
$dirNote[$item] = ReadNote($fsDir.$item); |
$dirList[$item] = $item ; |
599 |
} else if ( is_file($fsDir.$item) && check_perm($relDir.$item,trperm_r) ) { |
$dirNote[$item] = ReadNote($fsDir.$item); |
600 |
$fileList[$item] = $item ; |
} |
601 |
$fileDate[$item] = filemtime($fsDir.$item) ; |
} else if (is_file($fsDir.$item)) { |
602 |
$fileSize[$item] = filesize($fsDir.$item) ; |
if (check_perm($relDir.$item,trperm_r)) { |
603 |
$fileNote[$item] = ReadNote($fsDir.$item); |
$fileList[$item] = $item ; |
604 |
|
$fileDate[$item] = filemtime($fsDir.$item) ; |
605 |
|
$fileSize[$item] = filesize($fsDir.$item) ; |
606 |
|
$fileNote[$item] = ReadNote($fsDir.$item); |
607 |
|
} |
608 |
} else { |
} else { |
609 |
// unknown file type |
if (! $gblIgnoreUnknownFileType) Error("File Type Error", "Item <tt>".$fsDir.$item."</tt> is not file, directory or link. If you want to ignore errors like this, set <tt>\$gblIgnoreUnknownFileType = 1</tt> in <tt>$realm_config</tt>.",1); |
|
// $text = "Could not determine file type of " ; |
|
|
// Error("File Error", $text.$relDir."/".$item) ; |
|
|
// exit ; |
|
610 |
} |
} |
611 |
} |
} |
612 |
closedir($dir) ; |
closedir($dir) ; |
613 |
|
|
614 |
// scan deleted files |
// scan deleted files |
615 |
if ( $GLOBALS[show_deleted] == 1 && ($dir = @opendir("$fsDir/.del")) ) { |
if ( $HTTP_GET_VARS["show_deleted"] == 1 && ($dir = @opendir("$fsDir/.del")) ) { |
616 |
while ($item = readdir($dir)) { |
while ($item = readdir($dir)) { |
617 |
if ( substr($item,0,1) == "." || strstr($hide_items,",$item,") || !check_perm($relDir.$item,trperm_w) ) continue ; |
if ( substr($item,0,1) == "." || strstr($hide_items,",$item,") || !check_perm($relDir.$item,trperm_w) ) continue ; |
618 |
$fileList[$item] = ".del/$item" ; |
$fileList[$item] = ".del/$item" ; |
627 |
|
|
628 |
// start navigation page |
// start navigation page |
629 |
$text = "Use this page to add, delete"; |
$text = "Use this page to add, delete"; |
630 |
if (! isset($show_deleted)) { |
if (! isset($HTTP_GET_VARS[show_deleted])) { |
631 |
$text .= ", <a href=$self?D=".urlencode($relDir)."&show_deleted=1>undelete</a>"; |
$text .= ", <a href=$self?D=".urlencode($relDir)."&show_deleted=1>undelete</a>"; |
632 |
} |
} |
633 |
$text .= " or revise files on this web site." ; |
$text .= " or revise files on this web site." ; |
637 |
echo "<TABLE BORDER=0 CELLPADDING=2 |
echo "<TABLE BORDER=0 CELLPADDING=2 |
638 |
CELLSPACING=3 WIDTH=\"100%\">" ; |
CELLSPACING=3 WIDTH=\"100%\">" ; |
639 |
|
|
640 |
// updir bar |
// updir (parent) bar |
641 |
if (chopsl($fsDir) != chopsl($fsRoot)) { |
if (chopsl($fsDir) != chopsl($fsRoot)) { |
642 |
$parent = dirname($relDir) ; |
$parent = dirname($relDir) ; |
643 |
if ($parent == "") $parent = "/" ; |
if ($parent == "") $parent = "/" ; |
716 |
|
|
717 |
$dir = $dirList[$key]; |
$dir = $dirList[$key]; |
718 |
|
|
719 |
$info_url=self_args(array("A" => "A=E", "F" => "F=".urlencode($dir))); |
$info_url=self_args(array("A"=>"A=E", "F"=>"F=".urlencode($dir), "D"=>$D)); |
720 |
$dir_url=$self."?D=".urlencode($relDir.$dir); |
$dir_url=$self."?D=".urlencode(chopsl($relDir)."/".$dir); |
721 |
include("$html/Navigate-dirEntry.html"); |
include("$html/Navigate-dirEntry.html"); |
722 |
|
|
723 |
} // iterate over dirs |
} // iterate over dirs |
789 |
|
|
790 |
$file_lock=CheckLock($path); |
$file_lock=CheckLock($path); |
791 |
|
|
792 |
$file_url_html="<A HREF=\"$self?A=V&F=".urlencode($file); |
$file_url_html="<A HREF=\"$self?A=V&D=".urlencode($relDir)."&F=".urlencode($file); |
|
$file_url_html.="&D=".urlencode($relDir); |
|
793 |
$file_url_html.="\" TITLE=\"View file\">" ; |
$file_url_html.="\" TITLE=\"View file\">" ; |
794 |
|
|
795 |
if (substr($file,0,5) != ".del/") { |
if (substr($file,0,5) != ".del/") { |
804 |
|
|
805 |
if ($file_lock) { |
if ($file_lock) { |
806 |
if ($file_lock == $GLOBALS[gblUserName]) { |
if ($file_lock == $GLOBALS[gblUserName]) { |
807 |
$b.="<A HREF=\"$self?A=Ci&F=".urlencode($file); |
$b.="<A HREF=\"$self?A=Ci&D=".urlencode($relDir)."&F=".urlencode($file); |
|
$b.="&D=".urlencode($relDir); |
|
808 |
$b.="\" TITLE=\"Checkin (update) file on server\">" ; |
$b.="\" TITLE=\"Checkin (update) file on server\">" ; |
809 |
$file_url_html=$b; |
$file_url_html=$b; |
810 |
$b.=$gblIcon("checkin")."</A>" ; |
$b.=$gblIcon("checkin")."</A>" ; |
818 |
$file_url_html = "$file $a"; |
$file_url_html = "$file $a"; |
819 |
} |
} |
820 |
} else { |
} else { |
821 |
$b.="<A HREF=\"$self?A=Co&F=".urlencode($file); |
$b.="<A HREF=\"$self?A=Co&D=".urlencode($relDir)."&F=".urlencode($file); |
|
$b.="&D=".urlencode($relDir); |
|
822 |
$b.="\" TITLE=\"Checkout file for edit\">" ; |
$b.="\" TITLE=\"Checkout file for edit\">" ; |
823 |
$b.=$gblIcon("checkout")."</A>" ; |
$b.=$gblIcon("checkout")."</A>"; |
824 |
|
|
825 |
if ( $ext=="" || strstr(join(" ",$gblEditable),$ext) ) { |
if ( $ext=="" || strstr(join(" ",$gblEditable),$ext) ) { |
826 |
$b.="<A HREF=\"$self?A=C&F=".urlencode($file); |
$b.="<A HREF=\"$self?A=C&D=".urlencode($relDir)."&F=".urlencode($file); |
|
$b.="&D=".urlencode($relDir); |
|
827 |
$b.="\" TITLE=\"List contents\">" ; |
$b.="\" TITLE=\"List contents\">" ; |
828 |
$b.=$gblIcon("view")."</A>" ; |
$b.=$gblIcon("view")."</A>" ; |
829 |
} else { |
} else { |
863 |
<TR><TD></TD><TD COLSPAN=5><HR></TD></TR> |
<TR><TD></TD><TD COLSPAN=5><HR></TD></TR> |
864 |
|
|
865 |
<? |
<? |
866 |
if (file_exists(".info.inc")) { |
|
867 |
|
if (file_exists("$fsRealmDir/$realm".$realm_sep."info.inc")) { |
868 |
print "<TR><TD></TD><TD COLSPAN=5>"; |
print "<TR><TD></TD><TD COLSPAN=5>"; |
869 |
include(".info.inc"); |
include("$fsRealmDir/$realm".$realm_sep."info.inc"); |
870 |
print "</TD></TR> |
print "</TD></TR><TR><TD></TD><TD COLSPAN=5><HR></TD></TR>"; |
871 |
<TR><TD></TD><TD COLSPAN=5><HR></TD></TR>"; |
} elseif (file_exists("$gblRepositoryDir/.info.inc")) { |
872 |
|
print "<TR><TD></TD><TD COLSPAN=5>"; |
873 |
|
include("$gblRepositoryDir/.info.inc"); |
874 |
|
print "</TD></TR><TR><TD></TD><TD COLSPAN=5><HR></TD></TR>"; |
875 |
} |
} |
876 |
|
|
877 |
|
|
878 |
?> |
?> |
879 |
|
|
880 |
<FORM METHOD="POST" ACTION="<?= $self ?>"> |
<FORM METHOD="POST" ACTION="<?= $self ?>"> |
899 |
|
|
900 |
function UploadPage($fsRoot, $relDir, $filename="") { |
function UploadPage($fsRoot, $relDir, $filename="") { |
901 |
|
|
902 |
$self = $GLOBALS["PHP_SELF"] ; |
global $html, $HTTP_SERVER_VARS; |
|
if ($relDir == "") $relDir = "/" ; |
|
|
?> |
|
903 |
|
|
904 |
<P><TABLE BORDER=0 CELLPADDING=5><TR><TD WIDTH=5></TD><TD CLASS=BAR> |
$self = $HTTP_SERVER_VARS["PHP_SELF"] ; |
905 |
<FORM ENCTYPE="multipart/form-data" METHOD="POST" |
include("$html/UploadPage.html"); |
|
ACTION="<?= $self ?>"> |
|
|
DESTINATION DIRECTORY:<B><?= " " . $relDir ?></B> |
|
|
<? if (isset($filename) && $filename!="") { ?> |
|
|
<br>DESTINATION FILE:<B><?= " " . $filename ?></B> |
|
|
<INPUT TYPE="HIDDEN" NAME="FILENAME" VALUE="<?= $filename ?>"> |
|
|
<? } ?> |
|
|
<P>PATHNAME OF LOCAL FILE<BR> |
|
|
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>"> |
|
|
<INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="UPLOAD"> |
|
|
<INPUT SIZE=30 TYPE="FILE" NAME="FN"></P> |
|
|
<P><INPUT TYPE="SUBMIT" VALUE="UPLOAD"></P> |
|
|
<P>If the <B>[BROWSE...]</B> button is not displayed,<BR> |
|
|
you must upgrade to an RFC1867-compliant browser.</P> |
|
|
<P>Your browser:<BR><?= $GLOBALS["HTTP_USER_AGENT"] ?></P> |
|
|
</FORM> |
|
|
</TD></TR> |
|
|
<TR><TD></TD><TD> |
|
|
<FORM METHOD="POST" ACTION="<?= $self ?>"> |
|
|
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>"><BR> |
|
|
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="CANCEL"> |
|
|
</FORM> |
|
|
</TD></TR></TABLE></P> |
|
906 |
|
|
|
<?php |
|
907 |
} // end function UploadPage |
} // end function UploadPage |
908 |
|
|
909 |
////////////////////////////////////////////////////////////////// |
////////////////////////////////////////////////////////////////// |
910 |
|
|
911 |
function Error($title,$text="") { |
// Error with sysadmin flag are reported to error_log or hidden from |
912 |
StartHTML("(".$title.")",$text) ; |
// users |
913 |
echo "<P ALIGN=center>Hit your Browser's Back Button.</P>" ; |
|
914 |
EndHTML() ; |
function Error($title,$text="",$sysadmin=0,$no_404=0) { |
915 |
|
global $gblSeparateAdminMessages, |
916 |
|
$gblMailAdminMessages,$realm, |
917 |
|
$HTTP_SERVER_VARS; |
918 |
|
if (! headers_sent() && ! $no_404) header("HTTP/1.0 404 Not Found"); |
919 |
|
if ($sysadmin) { |
920 |
|
if ($gblSeparateAdminMessages) { |
921 |
|
$user="Your administrator "; |
922 |
|
if ($gblMailAdminMessages) { |
923 |
|
mail($HTTP_SERVER_VARS["SERVER_ADMIN"], "docman $realm error message: $title", strip_tags($text)); |
924 |
|
$user.="<tt>".$HTTP_SERVER_VARS["SERVER_ADMIN"]."</tt> "; |
925 |
|
} |
926 |
|
$user.="has been notified about error" ; |
927 |
|
StartHTML("($title)",$user); |
928 |
|
echo "<P ALIGN=center>Hit your Browser's Back Button.</P>" ; |
929 |
|
EndHTML(); |
930 |
|
error_log("docman $realm: ".strip_tags($text)); |
931 |
|
} else { |
932 |
|
StartHTML("ADMIN: ".$title,$text) ; |
933 |
|
echo "<P ALIGN=center>Hit your Browser's Back Button.</P>" ; |
934 |
|
EndHTML(); |
935 |
|
} |
936 |
|
} else { |
937 |
|
StartHTML("(".$title.")",$text) ; |
938 |
|
echo "<P ALIGN=center>Hit your Browser's Back Button.</P>" ; |
939 |
|
EndHTML() ; |
940 |
|
} |
941 |
exit ; |
exit ; |
942 |
} // end function Error |
} // end function Error |
943 |
|
|
944 |
////////////////////////////////////////////////////////////////// |
function LogIt($target,$msg, $changelog=0) { |
|
|
|
|
function LogIt($target,$msg) { |
|
945 |
|
|
946 |
$dir=dirname($target); |
$dir=dirname($target); |
947 |
if (! file_exists($dir."/.log")) { |
if (! file_exists($dir."/.log")) { |
948 |
if (! @mkdir($dir."/.log",0700)) Error("docman installation problem","can't create log directory <tt>$dir/.log</tt>"); |
if (! @mkdir($dir."/.log",0700)) Error("docman installation problem","can't create log directory <tt>$dir/.log</tt>",1); |
949 |
} |
} |
950 |
$file=basename($target); |
$file=basename($target); |
951 |
|
|
954 |
"\t$GLOBALS[gblUserName]\t$msg\n"); |
"\t$GLOBALS[gblUserName]\t$msg\n"); |
955 |
fclose($log); |
fclose($log); |
956 |
|
|
957 |
|
if (! $changelog) return; |
958 |
|
|
959 |
|
global $gblFsRoot; |
960 |
|
$log=fopen("$gblFsRoot/.changelog","a+"); |
961 |
|
if (substr($target,0,strlen($gblFsRoot)) == $gblFsRoot) |
962 |
|
$target=substr($target,strlen($gblFsRoot),strlen($target)-strlen($gblFsRoot)); |
963 |
|
$msg=str_replace("\t"," ",$msg); |
964 |
|
fputs($log,time()."\t$target\t$GLOBALS[gblUserName]\t$msg\n"); |
965 |
|
fclose($log); |
966 |
|
|
967 |
|
// FIX: implement e-mail notification based on $changelog |
968 |
|
// permission |
969 |
} |
} |
970 |
|
|
971 |
|
|
984 |
fputs($note,"$msg\n"); |
fputs($note,"$msg\n"); |
985 |
fclose($note); |
fclose($note); |
986 |
|
|
987 |
Logit($target,"added note $msg"); |
LogIt($target,"added note $msg"); |
988 |
|
|
989 |
} |
} |
990 |
|
|
1029 |
$file=basename($target); |
$file=basename($target); |
1030 |
|
|
1031 |
if (file_exists("$dir/.lock/$file")) { |
if (file_exists("$dir/.lock/$file")) { |
1032 |
Logit($target,"attempt to locked allready locked file!"); |
LogIt($target,"attempt to locked allready locked file!"); |
1033 |
} else { |
} else { |
1034 |
$lock=fopen("$dir/.lock/$file","w"); |
$lock=fopen("$dir/.lock/$file","w"); |
1035 |
fputs($lock,"$GLOBALS[gblUserName]\n"); |
fputs($lock,"$GLOBALS[gblUserName]\n"); |
1036 |
fclose($lock); |
fclose($lock); |
1037 |
|
|
1038 |
Logit($target,"file locked"); |
LogIt($target,"file locked"); |
1039 |
} |
} |
1040 |
|
|
1041 |
} |
} |
1062 |
$file=basename($target); |
$file=basename($target); |
1063 |
if (file_exists($dir."/.lock/$file")) { |
if (file_exists($dir."/.lock/$file")) { |
1064 |
unlink("$dir/.lock/$file"); |
unlink("$dir/.lock/$file"); |
1065 |
Logit($target,"file unlocked"); |
LogIt($target,"file unlocked"); |
1066 |
} else { |
} else { |
1067 |
Logit($target,"attempt to unlocked non-locked file!"); |
LogIt($target,"attempt to unlocked non-locked file!"); |
1068 |
} |
} |
1069 |
|
|
1070 |
} |
} |
1084 |
function try_rename($from,$to) { |
function try_rename($from,$to) { |
1085 |
# print "$from -> $to\n"; |
# print "$from -> $to\n"; |
1086 |
if (file_exists($from) && is_writeable(dirname($to))) { |
if (file_exists($from) && is_writeable(dirname($to))) { |
1087 |
rename($from,$to); |
return rename($from,$to); |
1088 |
|
} else { |
1089 |
|
return 0; |
1090 |
} |
} |
1091 |
} |
} |
1092 |
|
|
1093 |
function try_dir($todir) { |
function try_dir($todir) { |
1094 |
if (! file_exists($todir)) { |
if (! file_exists($todir)) { |
1095 |
mkdir($todir,0700); |
@mkdir($todir,0700); |
1096 |
} |
} |
1097 |
} |
} |
1098 |
|
|
1102 |
|
|
1103 |
# print "<pre>$fromdir / $fromfile -> $todir / $tofile\n\n"; |
# print "<pre>$fromdir / $fromfile -> $todir / $tofile\n\n"; |
1104 |
|
|
1105 |
try_rename("$fromdir/$fromfile","$todir/$tofile"); |
if (! try_rename("$fromdir/$fromfile","$todir/$tofile")) Error("Rename error","Can't rename file <tt>$fromfile</tt> to <tt>$tofile</tt>",1); |
1106 |
try_dir("$todir/.log"); |
try_dir("$todir/.log"); |
1107 |
try_rename("$fromdir/.log/$fromfile","$todir/.log/$tofile"); |
try_rename("$fromdir/.log/$fromfile","$todir/.log/$tofile"); |
1108 |
try_dir("$todir/.note"); |
try_dir("$todir/.note"); |
1136 |
|
|
1137 |
////////////////////////////////////////////////////////////////// |
////////////////////////////////////////////////////////////////// |
1138 |
|
|
|
function ChangeLog($target,$msg) { |
|
|
|
|
|
global $gblFsRoot; |
|
|
$log=fopen("$gblFsRoot/.changelog","a+"); |
|
|
if (substr($target,0,strlen($gblFsRoot)) == $gblFsRoot) |
|
|
$target=substr($target,strlen($gblFsRoot),strlen($target)-strlen($gblFsRoot)); |
|
|
$msg=str_replace("\t"," ",$msg); |
|
|
fputs($log,time()."\t$target\t$GLOBALS[gblUserName]\t$msg\n"); |
|
|
fclose($log); |
|
|
|
|
|
} |
|
|
|
|
1139 |
function DisplayChangeLog($day) { |
function DisplayChangeLog($day) { |
1140 |
|
|
1141 |
global $gblFsRoot; |
global $gblFsRoot,$HTTP_SERVER_VARS; |
1142 |
|
|
1143 |
if (!file_exists("$gblFsRoot/.changelog")) return; |
if (!file_exists("$gblFsRoot/.changelog")) return; |
1144 |
$log=fopen("$gblFsRoot/.changelog","r"); |
$log=fopen("$gblFsRoot/.changelog","r"); |
1145 |
$logarr = array(); |
$logarr = array(); |
1161 |
$time = date("$GLOBALS[gblTimeFmt]", $e[0]); |
$time = date("$GLOBALS[gblTimeFmt]", $e[0]); |
1162 |
$dir = dirname($e[1]); |
$dir = dirname($e[1]); |
1163 |
$file = basename($e[1]); |
$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"; |
print "<tr><td$cl>$date</td><td$cl>$time</td><td$cl><a href=\"$HTTP_SERVER_VARS[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>"; |
print "</table>"; |
1167 |
print "<p>".GifIcon(up)." Back to <a href=$GLOBALS[PHP_SELF]>front page</a>.</p>"; |
print "<p>".GifIcon(up)." Back to <a href=$HTTP_SERVER_VARS[PHP_SELF]>front page</a>.</p>"; |
1168 |
} |
} |
1169 |
|
|
1170 |
////////////////////////////////////////////////////////////////// |
////////////////////////////////////////////////////////////////// |
1171 |
|
|
1172 |
function Download($path) { |
function Download($path,$force=0) { |
1173 |
global $HTTP_USER_AGENT; |
global $HTTP_SERVER_VARS,$mime_type; |
1174 |
$file=basename($path); |
|
1175 |
|
// default transfer-encoding |
1176 |
|
$encoding = "binary"; |
1177 |
|
|
1178 |
|
// known transfer encodings |
1179 |
|
$encoding_ext = array( |
1180 |
|
"gz" => "x-gzip", |
1181 |
|
"Z" => "x-compress", |
1182 |
|
); |
1183 |
|
|
1184 |
|
$file = basename($path); |
1185 |
$size = filesize($path); |
$size = filesize($path); |
1186 |
//header("Content-Type: application/octet-stream"); |
|
1187 |
header("Content-Type: application/force-download"); |
$ext_arr = explode(".",$file); |
1188 |
header("Content-Length: $size"); |
$ext = array_pop($ext_arr); |
1189 |
|
if ($encoding_ext[$ext]) { |
1190 |
|
$encoding = $encoding_ext[$ext]; |
1191 |
|
$ext = array_pop($ext_arr); |
1192 |
|
} |
1193 |
|
|
1194 |
|
if ($force || !isset($mime_type[$ext])) { |
1195 |
|
header("Content-Type: application/force-download"); |
1196 |
|
} else { |
1197 |
|
header("Content-Type: $mime_type[$ext]"); |
1198 |
|
} |
1199 |
|
|
1200 |
// IE5.5 just downloads index.php if we don't do this |
// IE5.5 just downloads index.php if we don't do this |
1201 |
if(preg_match("/MSIE 5.5/", $HTTP_USER_AGENT)) { |
if(preg_match("/MSIE 5.5/", $HTTP_SERVER_VARS[HTTP_USER_AGENT])) { |
1202 |
header("Content-Disposition: filename=$file"); |
header("Content-Disposition: filename=$file"); |
1203 |
} else { |
} else { |
1204 |
header("Content-Disposition: attachment; filename=$file"); |
header("Content-Disposition: attachment; filename=$file"); |
1205 |
} |
} |
1206 |
header("Content-Transfer-Encoding: binary"); |
|
1207 |
|
header("Content-Transfer-Encoding: $encoding"); |
1208 |
$fh = fopen($path, "r"); |
$fh = fopen($path, "r"); |
1209 |
fpassthru($fh); |
fpassthru($fh); |
1210 |
} |
} |
1213 |
////////////////////////////////////////////////////////////////// |
////////////////////////////////////////////////////////////////// |
1214 |
|
|
1215 |
function chopsl($path) { |
function chopsl($path) { |
|
if (substr($path,strlen($path)-1,1) == "/") $path=substr($path,0,strlen($path)-1); |
|
1216 |
$path=str_replace("//","/",$path); |
$path=str_replace("//","/",$path); |
1217 |
|
if (substr($path,strlen($path)-1,1) == "/") $path=substr($path,0,strlen($path)-1); |
1218 |
return $path; |
return $path; |
1219 |
} |
} |
1220 |
|
|
1294 |
$groups_arr = array(); |
$groups_arr = array(); |
1295 |
$perm_arr = array(); |
$perm_arr = array(); |
1296 |
|
|
|
$error=0; |
|
|
|
|
1297 |
$tr_arr = array(); |
$tr_arr = array(); |
1298 |
|
|
1299 |
while (! feof($fp_conf)) { |
while (! feof($fp_conf)) { |
1361 |
} |
} |
1362 |
|
|
1363 |
if ($error) { |
if ($error) { |
1364 |
Error("Trustee error",$error); |
Error("Trustee error",$error,1); |
1365 |
} else { |
} else { |
1366 |
include("$trustee_php"); |
include("$trustee_php"); |
1367 |
} |
} |
1371 |
}//init_trustee |
}//init_trustee |
1372 |
|
|
1373 |
function in_group($user,$group) { |
function in_group($user,$group) { |
1374 |
return in_array($groups[$group],$user); |
global $groups; |
1375 |
|
return in_array($user,$groups[$group]); |
1376 |
} |
} |
1377 |
|
|
1378 |
// helper function |
// helper function |
1440 |
|
|
1441 |
function check_perm($path,$trperm) { |
function check_perm($path,$trperm) { |
1442 |
global $gblLogin,$HAVE_TRUSTEE; |
global $gblLogin,$HAVE_TRUSTEE; |
1443 |
print "<br>check_perm: <tt>$path</tt> test perm ".display_trustee($perm)."<br>\n"; |
|
1444 |
|
global $debug; |
1445 |
|
$debug.="<br>check_perm: <tt>$path</tt> test perm ".display_trustee($perm)."<br>\n"; |
1446 |
|
|
1447 |
$return = ! $HAVE_TRUSTEE; |
$return = ! $HAVE_TRUSTEE; |
1448 |
if ($HAVE_TRUSTEE) { |
if ($HAVE_TRUSTEE) { |
1449 |
$perm = check_trustee($gblLogin,$path); |
$perm = check_trustee($gblLogin,$path); |
1450 |
print " d: $perm[deny] (".display_trustee($perm[deny]).") a: $perm[allow] (".display_trustee($perm[allow]).") perm: $trperm"; |
$debug.=" d: $perm[deny] (".display_trustee($perm[deny]).") a: $perm[allow] (".display_trustee($perm[allow]).") perm: $trperm"; |
1451 |
if ($perm[deny] & $trperm) $return=0; |
if ($perm[deny] & $trperm) $return=0; |
1452 |
elseif ($perm[allow] & $trperm) $return=1; |
elseif ($perm[allow] & $trperm) $return=1; |
1453 |
} |
} |
1454 |
print " return: $return<br>\n"; |
$debug.=" return: $return<br>\n"; |
1455 |
return($return); |
return($return); |
1456 |
} |
} |
1457 |
|
|
1458 |
|
////////////////////////////////////////////////////////////////// |
1459 |
|
|
1460 |
|
function readMime() { |
1461 |
|
global $mime_type; |
1462 |
|
|
1463 |
|
if (! isset($gblMimeTypes)) { |
1464 |
|
$gblMimeTypes = "/etc/mime.types"; |
1465 |
|
} |
1466 |
|
|
1467 |
|
$mime = @fopen($gblMimeTypes,"r"); |
1468 |
|
|
1469 |
|
if (! $mime) Error("Can't read MIME types","<tt>$gblMimeTypes</tt> file not found. You can setup other <tt>mime.types</tt> file using <tt>\$gblMimeTypes</tt> in <tt>$realm_config</tt>"); |
1470 |
|
|
1471 |
|
while($line = fgets($mime,80)) { |
1472 |
|
if (substr($line,0,1) == "#") continue; // skip comment |
1473 |
|
$arr = preg_split("/[\s\t]+/",$line); |
1474 |
|
$type = array_shift($arr); |
1475 |
|
while ($ext = array_shift($arr)) { |
1476 |
|
$mime_type[$ext] = $type; |
1477 |
|
} |
1478 |
|
} |
1479 |
|
|
1480 |
|
fclose($mime); |
1481 |
|
} |
1482 |
|
|
1483 |
|
////////////////////////////////////////////////////////////////// |
1484 |
|
|
1485 |
|
// check for invalid characters in filename and dirname (.. and /) |
1486 |
|
|
1487 |
|
function check_dirname($file) { |
1488 |
|
if (strstr($file,"..")) Error("Security violation","No parent dir <tt>..</tt> allowed in directory name <tt>$file</tt>",1); |
1489 |
|
} |
1490 |
|
|
1491 |
|
function check_filename($file) { |
1492 |
|
if (strstr($file,"..")) Error("Security violation","No parent dir <tt>..</tt> allowed in file name <tt>$file</tt>",1); |
1493 |
|
if (strstr($file,"/")) Error("Security violation","No slashes <tt>/</tt> allowed in file name <tt>$file</tt>",1); |
1494 |
|
} |
1495 |
|
|
1496 |
////////////////////////////////////////////////////////////////// |
////////////////////////////////////////////////////////////////// |
1497 |
// MAIN PROGRAM |
// MAIN PROGRAM |
1499 |
$gblFilePerms = 0640 ; // default for new files |
$gblFilePerms = 0640 ; // default for new files |
1500 |
$gblDirPerms = 0750 ; // default for new dirs |
$gblDirPerms = 0750 ; // default for new dirs |
1501 |
|
|
1502 |
|
$STYLE = $HTTP_GET_VARS[STYLE]; |
1503 |
if (isset($STYLE) && $STYLE == "get") { |
if (isset($STYLE) && $STYLE == "get") { |
1504 |
include("$html/docman.css"); |
include("$html/docman.css"); |
1505 |
exit; |
exit; |
1518 |
if (! isset($fsRealmDir)) { |
if (! isset($fsRealmDir)) { |
1519 |
$fsRealmDir = "$gblIncDir/realm"; |
$fsRealmDir = "$gblIncDir/realm"; |
1520 |
} |
} |
1521 |
$realm_config = "$fsRealmDir/$realm.conf"; |
|
1522 |
|
// try to add dir to script name to realm var |
1523 |
|
if (is_dir("$fsRealmDir/$realm/".dirname($HTTP_SERVER_VARS[SCRIPT_NAME]))) { |
1524 |
|
$realm .= dirname($HTTP_SERVER_VARS[SCRIPT_NAME]); |
1525 |
|
$realm_sep = "/"; |
1526 |
|
} else { |
1527 |
|
$realm_sep = "."; |
1528 |
|
} |
1529 |
|
|
1530 |
|
$realm_config = $fsRealmDir."/".$realm.$realm_sep."conf"; |
1531 |
|
|
1532 |
// read user-defined configuration |
// read user-defined configuration |
1533 |
if (file_exists($realm_config)) { |
if (file_exists($realm_config)) { |
1560 |
exit ; |
exit ; |
1561 |
} |
} |
1562 |
|
|
1563 |
|
if (!is_dir($gblRepositoryDir)) Error("Repository dir not found","Can't find repository directory <tt>$gblRepositoryDir</tt>. Please fix that in <tt>$realm_config</tt> variable <tt>\$gblRepositoryDir</tt>.",1); |
1564 |
|
|
1565 |
// trustee (ACL) file configuration |
// trustee (ACL) file configuration |
1566 |
$trustee_conf="$gblIncDir/realm/$realm.trustee"; |
$trustee_conf="$fsRealmDir/$realm".$realm_sep."trustee"; |
1567 |
// compiled version of trustee file |
// compiled version of trustee file |
1568 |
$trustee_php="$gblRepositoryDir/.trustee.php"; |
$trustee_php="$gblRepositoryDir/.trustee.php"; |
1569 |
// get ACL informations |
// get ACL informations |
1570 |
$HAVE_TRUSTEE = init_trustee(); |
$HAVE_TRUSTEE = init_trustee(); |
1571 |
|
|
1572 |
|
// take additional login vars |
1573 |
|
$relogin = $HTTP_GET_VARS[relogin]; |
1574 |
|
$force_login = $HTTP_GET_VARS[force_login]; |
1575 |
|
|
1576 |
if (strtolower($gblLogin) == "anonymous" || !isset($gblPasswd)) { |
if (strtolower($gblLogin) == "anonymous" || !isset($gblPasswd)) { |
1577 |
$perm = check_trustee($gblLogin,$path); |
$perm = check_trustee("anonymous",$path); |
1578 |
// browsing must be explicitly allowed for root directory |
// browsing must be explicitly allowed for root directory |
1579 |
// of repository for anonymous user to work! |
// of repository for anonymous user to work! |
1580 |
if ($perm[allow] & trperm_b) { |
if ($perm[allow] & trperm_b) { |
1588 |
isset($relogin) && $secHash == $relogin) { |
isset($relogin) && $secHash == $relogin) { |
1589 |
header("WWW-authenticate: basic realm=\"$realm\"") ; |
header("WWW-authenticate: basic realm=\"$realm\"") ; |
1590 |
header("HTTP/1.0 401 Unauthorized") ; |
header("HTTP/1.0 401 Unauthorized") ; |
1591 |
Error("401 Unauthorized","No trespassing !"); |
Error("401 Unauthorized","No trespassing !",0,1); |
|
exit ; |
|
1592 |
} |
} |
1593 |
|
|
1594 |
// get current directory relative to $gblFsRoot |
|
1595 |
$relDir = $DIR ; // from POST |
// read mime.types |
1596 |
if ($relDir == "") { // not defined in POST ? |
readMime(); |
1597 |
$relDir = urldecode($D) ; // then use GET |
|
1598 |
} |
if ($HTTP_SERVER_VARS["REQUEST_METHOD"] == "POST") { |
1599 |
|
// take variables from server |
1600 |
$relDir=stripSlashes($relDir); |
$FN=stripSlashes($HTTP_POST_VARS["FN"]); |
1601 |
|
$DIR=stripSlashes($HTTP_POST_VARS["DIR"]); |
1602 |
if ($relDir == "/") $relDir = "" ; |
$RELPATH=stripSlashes($HTTP_POST_VARS["RELPATH"]); |
1603 |
// default : website root = "" |
$T=stripSlashes($HTTP_POST_VARS["T"]); |
1604 |
|
$CONFIRM=stripSlashes($HTTP_POST_VARS["CONFIRM"]); |
1605 |
if (strstr($relDir,"..")) Error("No updirs allowed"); |
|
1606 |
|
check_filename($FN); |
1607 |
// full paths contain "fs" or "Fs". Paths realitve to root of |
check_dirname($DIR); |
1608 |
// website contain "rel" or "Rel". The script won't let you |
check_dirname($RELPATH); |
1609 |
// edit anything above directory equal to http://server.com |
|
1610 |
// i.e. below $gblFsRoot. |
$relDir = $DIR; |
1611 |
|
} else { |
1612 |
|
// get |
1613 |
|
$A=stripSlashes($HTTP_GET_VARS["A"]); |
1614 |
|
$D=stripSlashes(urldecode($HTTP_GET_VARS["D"])); |
1615 |
|
$F=stripSlashes($HTTP_GET_VARS["F"]); |
1616 |
|
|
1617 |
|
check_filename($F); |
1618 |
|
check_dirname($D); |
1619 |
|
|
1620 |
|
$relDir = $D; |
1621 |
|
} |
1622 |
|
|
1623 |
$relScriptDir = dirname($SCRIPT_NAME) ; |
$relScriptDir = dirname($SCRIPT_NAME) ; |
1624 |
// i.e. /docman |
// i.e. /docman |
1625 |
|
|
1626 |
// start on server root |
// start on server root |
1627 |
$gblFsRoot = $gblRepositoryDir; |
$gblFsRoot = $gblRepositoryDir; |
1628 |
// i.e. /home/httpd/html |
// i.e. /home/httpd/repository |
1629 |
|
|
1630 |
$fsDir = $gblFsRoot . $relDir ; // current directory |
$fsDir = $gblFsRoot . $relDir ; // current directory |
1631 |
if ( !is_dir($fsDir) ) Error("Dir not found",$relDir) ; |
if ( !is_dir($fsDir) ) Error("Dir not found","Can't find <tt>$relDir</tt> which points to <tt>$fsDir</tt>",1) ; |
1632 |
|
|
1633 |
if (isset($GLOBALS["HTTPS"]) && $GLOBALS["HTTPS"] == "on") { |
if (isset($HTTP_SERVER_VARS["HTTPS"]) && $HTTP_SERVER_VARS["HTTPS"] == "on") { |
1634 |
$webRoot = "https://"; |
$webRoot = "https://"; |
1635 |
} else { |
} else { |
1636 |
$webRoot = "http://"; |
$webRoot = "http://"; |
1637 |
} |
} |
1638 |
$webRoot .= $GLOBALS["HTTP_HOST"] . $relScriptDir; |
$webRoot .= $HTTP_SERVER_VARS["HTTP_HOST"] . $relScriptDir; |
|
|
|
|
$FN=stripSlashes($FN); |
|
1639 |
|
|
1640 |
switch ($POSTACTION) { |
switch ($HTTP_POST_VARS["POSTACTION"]) { |
1641 |
case "UPLOAD" : |
case "UPLOAD" : |
1642 |
|
$FN_name=stripSlashes($HTTP_POST_FILES["FN"]["tmp_name"]); |
1643 |
|
$FN=stripSlashes($HTTP_POST_FILES["FN"]["name"]); |
1644 |
if (!is_writeable($fsDir)) Error("Write denied",$relDir) ; |
if (!is_writeable($fsDir)) Error("Write denied",$relDir) ; |
1645 |
if (strstr($FN_name,"/")) |
|
1646 |
Error("Non-conforming filename") ; |
$source = $FN_name ; |
|
// TODO : should rather check for escapeshellcmds |
|
|
// but maybe RFC 18xx asserts safe filenames .... |
|
|
$source = $FN ; |
|
1647 |
if (! file_exists($source)) { |
if (! file_exists($source)) { |
1648 |
Error("You must select file with browse to upload it!"); |
Error("You must select file with browse to upload it!"); |
1649 |
} |
} |
1650 |
|
|
1651 |
|
$FILENAME = $HTTP_POST_VARS["FILENAME"]; |
1652 |
|
check_filename($FILENAME); |
1653 |
|
|
1654 |
if (! isset($FILENAME)) { // from update file |
if (! isset($FILENAME)) { // from update file |
1655 |
$target = "$fsDir/$FN_name" ; |
$target = "$fsDir/".basename($FN); |
1656 |
} else { |
} else { |
1657 |
$target = "$fsDir/$FILENAME"; |
$target = "$fsDir/$FILENAME"; |
1658 |
} |
} |
1674 |
copy($source,$target) ; |
copy($source,$target) ; |
1675 |
chmod($target,$gblFilePerms) ; |
chmod($target,$gblFilePerms) ; |
1676 |
clearstatcache() ; |
clearstatcache() ; |
|
Logit($target,"uploaded"); |
|
1677 |
if (isset($FILENAME)) { |
if (isset($FILENAME)) { |
1678 |
|
LogIt($target,"check-in",trperm_r | trperm_w); |
1679 |
Unlock($target); |
Unlock($target); |
1680 |
|
} else { |
1681 |
|
LogIt($target,"uploaded",trperm_r | trperm_w); |
1682 |
} |
} |
|
ChangeLog($target,"updated"); |
|
1683 |
break ; |
break ; |
1684 |
|
|
1685 |
case "SAVE" : |
case "SAVE" : |
1696 |
fwrite($fh,$FILEDATA) ; |
fwrite($fh,$FILEDATA) ; |
1697 |
fclose($fh) ; |
fclose($fh) ; |
1698 |
clearstatcache() ; |
clearstatcache() ; |
1699 |
Logit($path,"saved changes"); |
LogIt($path,"saved changes",trperm_r); |
|
ChangeLog($path,"saved changes"); |
|
1700 |
break ; |
break ; |
1701 |
|
|
1702 |
case "CREATE" : |
case "CREATE" : |
1709 |
case "D" : // create a directory |
case "D" : // create a directory |
1710 |
if ( ! @mkdir($path,$gblDirPerms) ) |
if ( ! @mkdir($path,$gblDirPerms) ) |
1711 |
Error("Mkdir failed",$relPath) ; // eg. if it exists |
Error("Mkdir failed",$relPath) ; // eg. if it exists |
1712 |
|
else |
1713 |
|
LogIt($path."/","dir created",trperm_w); |
1714 |
clearstatcache() ; |
clearstatcache() ; |
1715 |
break ; |
break ; |
1716 |
case "F" : // create a new file |
case "F" : // create a new file |
1723 |
if ($fh) { |
if ($fh) { |
1724 |
fputs($fh,"\n"); |
fputs($fh,"\n"); |
1725 |
fclose($fh) ; |
fclose($fh) ; |
1726 |
LogIt($path,"file created"); |
LogIt($path,"file created",trperm_r | trperm_w); |
1727 |
} else { |
} else { |
1728 |
Error("Creation of file $relPath failed -- $path"); |
Error("Creation of file $relPath failed -- $path"); |
1729 |
} |
} |
1730 |
$tstr = "$PHP_SELF?A=E&D=".urlencode($relDir)."&F=".urlencode($FN) ; |
$tstr = "$PHP_SELF?A=E&D=".urlencode($relDir)."&F=".urlencode($FN) ; |
1731 |
header("Location: " . $tstr) ; |
header("Location: " . $tstr) ; |
|
ChangeLog($target,"created"); |
|
1732 |
exit ; |
exit ; |
1733 |
} |
} |
1734 |
break ; |
break ; |
1750 |
|
|
1751 |
// if ( ! @unlink($path) ) { |
// if ( ! @unlink($path) ) { |
1752 |
if ( ! rename($path,"$dir/.del/$file") ) { |
if ( ! rename($path,"$dir/.del/$file") ) { |
1753 |
|
LogIt($path,"file delete failed"); |
1754 |
Error("File delete failed", $tstr . $path) ; |
Error("File delete failed", $tstr . $path) ; |
|
Logit($path,"file delete failed"); |
|
|
exit ; |
|
1755 |
} else { |
} else { |
1756 |
Logit($path,"file deleted"); |
LogIt($path,"file deleted",trperm_w); |
1757 |
MoveTo("$dir/.log/$file","$dir/.del/.log/"); |
MoveTo("$dir/.log/$file","$dir/.del/.log/"); |
1758 |
MoveTo("$dir/.note/$file","$dir/.del/.note/"); |
MoveTo("$dir/.note/$file","$dir/.del/.note/"); |
1759 |
MoveTo("$dir/.lock/$file","$dir/.del/.lock/"); |
MoveTo("$dir/.lock/$file","$dir/.del/.lock/"); |
1760 |
} |
} |
1761 |
} |
} else { // delete directory |
1762 |
else { // delete directory |
if ( ! @rrmdir($fsDir) ) { |
1763 |
if ( ! @rrmdir($fsDir) ) { |
Error("Rmdir failed", $tstr . $fsDir) ; |
1764 |
Error("Rmdir failed", $tstr . $fsDir) ; |
} else { |
1765 |
} |
LogIt($path,"dir deleted",trperm_w); |
1766 |
else { |
$relDir = dirname($relDir) ; // move up |
1767 |
$relDir = dirname($relDir) ; // move up |
} |
|
} |
|
1768 |
} |
} |
1769 |
break ; |
break ; |
1770 |
|
|
1774 |
if (substr($FN,0,4) != ".del") break ; |
if (substr($FN,0,4) != ".del") break ; |
1775 |
$file=substr($FN,4,strlen($FN)-4); |
$file=substr($FN,4,strlen($FN)-4); |
1776 |
|
|
1777 |
Logit("$fsDir/.del/$file","undeleted"); |
LogIt("$fsDir/.del/$file","undeleted",trperm_w); |
1778 |
MoveTo("$fsDir/.del/$file","$fsDir/"); |
MoveTo("$fsDir/.del/$file","$fsDir/"); |
1779 |
MoveTo("$fsDir/.del/.log/$file","$fsDir/.log/"); |
MoveTo("$fsDir/.del/.log/$file","$fsDir/.log/"); |
1780 |
MoveTo("$fsDir/.del/.note/$file","$fsDir/.note/"); |
MoveTo("$fsDir/.del/.note/$file","$fsDir/.note/"); |
1785 |
case "RENAME" : |
case "RENAME" : |
1786 |
if ( $CONFIRM != "on" ) break ; |
if ( $CONFIRM != "on" ) break ; |
1787 |
|
|
1788 |
Logit("$fsDir/$FN","renamed $FN to $NEWNAME"); |
$NEWNAME=stripSlashes($HTTP_POST_VARS["NEWNAME"]); |
1789 |
|
LogIt("$fsDir/$FN","renamed $FN to $NEWNAME",trperm_r); |
1790 |
safe_rename($fsDir,$FN,$NEWNAME); |
safe_rename($fsDir,$FN,$NEWNAME); |
1791 |
break ; |
break ; |
1792 |
|
|
1793 |
case "NOTE" : |
case "NOTE" : |
1794 |
|
$NOTE=stripSlashes($HTTP_POST_VARS["NOTE"]); |
1795 |
WriteNote("$fsDir/$FN","$NOTE"); |
WriteNote("$fsDir/$FN","$NOTE"); |
1796 |
break ; |
break ; |
1797 |
|
|
1818 |
// $A=Co : checkout file $D/$F |
// $A=Co : checkout file $D/$F |
1819 |
// $A=Ci : checkin file $D/$F |
// $A=Ci : checkin file $D/$F |
1820 |
// $A=V : view file (do nothing except log) |
// $A=V : view file (do nothing except log) |
1821 |
// $A=I : include file .$F.php from $gblFsRoot |
// $A=I : include file .$F.php from [$gblIncDir|realm]/include_php |
1822 |
// default : display directory $D |
// default : display directory $D |
1823 |
|
|
1824 |
switch ($A) { |
switch ($A) { |
1825 |
case "U" : |
case "U" : |
1826 |
// upload to $relDir |
// upload to $relDir |
1827 |
|
if (! check_perm($relDir, trperm_w)) |
1828 |
|
Error("Write access denied","You don't have permission to write in <tt>$relDir</tt>"); |
1829 |
if (!is_writeable($gblFsRoot . $relDir)) |
if (!is_writeable($gblFsRoot . $relDir)) |
1830 |
Error("Write access denied",$relDir) ; |
Error("Write access denied","User <tt>$gblLogin</tt> has permission on <tt>$relDir</tt>, but directory is not writable",1); |
1831 |
$text = "Use this page to upload a single " ; |
$text = "Use this page to upload a single " ; |
1832 |
$text .= "file to <B>$HTTP_HOST</B>." ; |
$text .= "file to <B>$realm</B>." ; |
1833 |
StartHTML("(Upload Page)", $text) ; |
StartHTML("(Upload Page)", $text) ; |
1834 |
UploadPage($gblFsRoot, $relDir) ; |
UploadPage($gblFsRoot, $relDir) ; |
1835 |
EndHTML() ; |
EndHTML() ; |
1836 |
exit ; |
exit ; |
1837 |
case "E" : |
case "E" : |
|
$F=stripSlashes($F); |
|
1838 |
// detail of $relDir/$F |
// detail of $relDir/$F |
1839 |
if (is_file("$gblFsRoot/$relDir/$F") || is_dir("$gblFsRoot/$relDir/$F")) DetailPage($gblFsRoot, $relDir, $F) ; |
if (is_file("$gblFsRoot/$relDir/$F") || is_dir("$gblFsRoot/$relDir/$F")) DetailPage($gblFsRoot, $relDir, $F) ; |
1840 |
exit ; |
exit ; |
1846 |
case "Co" : |
case "Co" : |
1847 |
// checkout |
// checkout |
1848 |
Lock("$gblFsRoot/$relDir/$F"); |
Lock("$gblFsRoot/$relDir/$F"); |
1849 |
Download("$gblFsRoot/$relDir/$F"); |
Download("$gblFsRoot/$relDir/$F",1); |
1850 |
exit; |
exit; |
1851 |
case "Ci" : |
case "Ci" : |
1852 |
$F=stripSlashes($F); |
$F=stripSlashes($F); |
1854 |
if (!is_writeable($gblFsRoot . $relDir)) |
if (!is_writeable($gblFsRoot . $relDir)) |
1855 |
Error("Write access denied",$relDir) ; |
Error("Write access denied",$relDir) ; |
1856 |
$text = "Use this page to update a single " ; |
$text = "Use this page to update a single " ; |
1857 |
$text .= "file to <B>$HTTP_HOST</B>." ; |
$text .= "file to <B>$realm</B>." ; |
1858 |
StartHTML("(Update file Page)", $text) ; |
StartHTML("(Update file Page)", $text) ; |
1859 |
UploadPage($gblFsRoot, $relDir, $F) ; |
UploadPage($gblFsRoot, $relDir, $F) ; |
1860 |
EndHTML() ; |
EndHTML() ; |
1862 |
case "V" : |
case "V" : |
1863 |
// view |
// view |
1864 |
LogIt("$gblFsRoot/$relDir/$F","viewed"); |
LogIt("$gblFsRoot/$relDir/$F","viewed"); |
1865 |
if ($gblForceDownload) { |
Download("$gblFsRoot/$relDir/$F",$gblForceDownload); |
|
Download("$gblFsRoot/$relDir/$F"); |
|
|
} else { |
|
|
header("Content-Disposition: attachment; filename=$F" ); |
|
|
Header("Location: $webRoot".urlpath("$relDir/$F")); |
|
|
} |
|
1866 |
exit; |
exit; |
1867 |
case "Ch" : |
case "Ch" : |
1868 |
StartHTML("(File changes)","All changes chronologicaly..."); |
StartHTML("(File changes)","All changes chronologicaly..."); |
1875 |
EndHTML() ; |
EndHTML() ; |
1876 |
exit; |
exit; |
1877 |
case "I" : |
case "I" : |
1878 |
$F=stripSlashes($F); |
if (! isset($F) || $F == "") |
1879 |
$inc_file="${gblFsRoot}/.${F}.php"; |
Error("Can't find file to include","Your request didn't specify file to include which should be in variable <tt>F</tt> like <tt>$HTTP_SERVER_VARS[REQUEST_URI]<b>&F=include_php_file</b></tt>",1); |
1880 |
if (!isset($F) || $F == "" || !file_exists($inc_file)) Error("Fatal error $inc_file"); // can't find file to include |
$inc_file="$fsRealmDir/$realm".$realm_sep.$F.".php"; |
1881 |
|
if (! file_exists($inc_file)) { |
1882 |
|
Error("Can't find file to include","Can't find include file <tt>$F.php</tt> in <tt>$fsRealmDir/$realm/</tt>. Meybe you should copy <tt>$gblIncDir/include_php/$F.php</tt> to <tt>$inc_file<tt> ?",1); |
1883 |
|
} |
1884 |
if (!is_readable($inc_file)) |
if (!is_readable($inc_file)) |
1885 |
Error("Read access to include file denied",".${F}.php"); |
Error("Read access to include file denied","Can't read PHP include file <tt>$inc_file</tt>. Fix permissions on it.",1); |
1886 |
$text = "Your include file should define \$text variable which holds this text and \$title variable which is page title"; |
$text = "Your include file should define \$text variable which holds this text and \$title variable which is page title"; |
1887 |
$title = "You should define \$title variable with page title"; |
$title = "You should define \$title variable with page title"; |
1888 |
include($inc_file); |
include($inc_file); |
1889 |
StartHTML($title, $text) ; |
StartHTML($title, $text) ; |
1890 |
print "<p>".GifIcon(up)." Back to <a href=$GLOBALS[PHP_SELF]>front page</a>.</p>"; |
print "<p>".GifIcon(up)." Back to <a href=$HTTP_SERVER_VARS[PHP_SELF]>front page</a>.</p>"; |
1891 |
EndHTML() ; |
EndHTML() ; |
1892 |
exit ; |
exit ; |
1893 |
} |
} |
1896 |
Navigate($gblFsRoot,$relDir) ; |
Navigate($gblFsRoot,$relDir) ; |
1897 |
exit ; |
exit ; |
1898 |
|
|
1899 |
Error("Whooah!","By cartesian logic, this never happens") ; |
Error("Whooah!","By cartesian logic, this never happens",1) ; |
1900 |
?> |
?> |