74 |
////////////////////////////////////////////////////////////////// |
////////////////////////////////////////////////////////////////// |
75 |
|
|
76 |
$gblTitle = "Document Manager"; |
$gblTitle = "Document Manager"; |
77 |
$gblVersion = "2.0-pre1"; |
$gblVersion = "2.0-pre2"; |
78 |
|
|
79 |
$secHash = ""; |
$secHash = ""; |
80 |
|
|
81 |
// location of html files |
// location of html files |
82 |
$html = $gblIncDir."/html"; |
$html = $gblIncDir."/html"; |
83 |
|
|
84 |
LoadLanguage($HTTP_SERVER_VARS["HTTP_ACCEPT_LANGUAGE"]); |
if (isset($HTTP_SERVER_VARS["HTTP_ACCEPT_LANGUAGE"])) { |
85 |
|
LoadLanguage($HTTP_SERVER_VARS["HTTP_ACCEPT_LANGUAGE"]); |
86 |
|
} |
87 |
|
|
88 |
// for security and configuration |
// for security and configuration |
89 |
$realm=$HTTP_SERVER_VARS["HTTP_HOST"]; |
$realm=$HTTP_SERVER_VARS["HTTP_HOST"]; |
149 |
} |
} |
150 |
include("$html/footer.html"); |
include("$html/footer.html"); |
151 |
|
|
152 |
global $debug; |
# global $debug; |
153 |
if ($debug) print $debug; |
# if ($debug) print $debug; |
154 |
} // end function EndHTML |
} // end function EndHTML |
155 |
|
|
156 |
////////////////////////////////////////////////////////////////// |
////////////////////////////////////////////////////////////////// |
159 |
|
|
160 |
global $gblEditable, $gblImages, |
global $gblEditable, $gblImages, |
161 |
$gblDateFmt, $gblTimeFmt, |
$gblDateFmt, $gblTimeFmt, |
162 |
|
$gblPermNote, |
163 |
$webRoot, $html, |
$webRoot, $html, |
164 |
$HTTP_SERVER_VARS ; |
$HTTP_SERVER_VARS ; |
165 |
$self = $HTTP_SERVER_VARS["PHP_SELF"] ; |
$self = $HTTP_SERVER_VARS["PHP_SELF"] ; |
211 |
$fstr = fread($fh,filesize($fsPath)) ; |
$fstr = fread($fh,filesize($fsPath)) ; |
212 |
fclose($fh) ; |
fclose($fh) ; |
213 |
$fstr = htmlentities( $fstr ) ; |
$fstr = htmlentities( $fstr ) ; |
|
?> |
|
214 |
|
|
215 |
<FORM ACTION="<?= $self ?>" METHOD="POST"> |
include("$html/DetailPage-edit.html"); |
|
<SPAN TITLE="Click [SAVE] to store updated contents."> |
|
|
<B>DOCUMENT CONTENTS</B> |
|
|
</SPAN><BR> |
|
|
<TEXTAREA NAME="FILEDATA" ROWS=18 COLS=70 WRAP="OFF"><?php |
|
|
echo($fstr) ; ?></TEXTAREA> |
|
|
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ; ?>"> |
|
|
<INPUT TYPE="HIDDEN" NAME="FN" VALUE="<?= $fn ; ?>"> |
|
|
<INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="SAVE"> |
|
|
<INPUT TYPE="HIDDEN" SIZE=48 MAXLENGTH=255 NAME="RELPATH" |
|
|
VALUE="<?= $relPath ; ?>"> |
|
|
<br> |
|
|
<INPUT TYPE="RESET" VALUE="UNDO ALL CHANGES"> |
|
|
<INPUT TYPE="SUBMIT" VALUE="SAVE"> |
|
|
</FORM> |
|
|
|
|
|
<?php |
|
216 |
} |
} |
217 |
if ( !$file_lock && $ext!="" && strstr(join(' ',$gblImages),$ext) ) { |
if ( !$file_lock && $ext!="" && strstr(join(' ',$gblImages),$ext) ) { |
218 |
$info = getimagesize($fsPath) ; |
$info = getimagesize($fsPath) ; |
219 |
$tstr = "<IMG SRC=\"$webRoot".urlpath($relPath)."\" BORDER=0 " ; |
$tstr = "<IMG SRC=\"$self?A=V&D=".urlpath(dirname($relPath))."&F=".urlpath(basename($relPath))."\" BORDER=0 " ; |
220 |
$tstr .= $info[3] . " ALT=\"" . $fn . " - " ; |
$tstr .= $info[3] . " ALT=\"" . $fn . " - " ; |
221 |
$tstr .= (int)(($fsize+1023)/1024) . "Kb\">" ; |
$tstr .= (int)(($fsize+1023)/1024) . "Kb\">" ; |
222 |
// echo htmlentities($tstr) . "<BR><BR>" . $tstr ; |
// echo htmlentities($tstr) . "<BR><BR>" . $tstr ; |
223 |
echo $tstr ; |
echo $tstr ; |
224 |
} |
} |
225 |
|
|
|
?> |
|
226 |
|
|
227 |
<FORM ACTION="<?= $self ; ?>" METHOD="POST"> |
print '<FORM ACTION="'.$self.'" METHOD="POST"> |
228 |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ; ?>"> |
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="'.$relDir.'"> |
229 |
<INPUT TYPE="HIDDEN" NAME="FN" VALUE="<?= $fn ; ?>"> |
<INPUT TYPE="HIDDEN" NAME="FN" VALUE="'.$fn.'"> |
230 |
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="CANCEL"><BR> |
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="CANCEL"><BR> |
231 |
|
'; |
232 |
<?php |
|
233 |
|
if ($file_lock && check_perm($relDir.$fn,trperm_w)) { |
234 |
if ($file_lock) { |
include("$html/DetailPage-unlock.html"); |
|
?> |
|
|
<hr> |
|
|
<SPAN TITLE="Check OK and click UNLOCK to remove lock on file."> |
|
|
<B>OK TO FORCE LOCK REMOVAL ON "<?= $fn ; ?>" HELD BY <?= $file_lock ?>? </B></SPAN> |
|
|
<INPUT TYPE="CHECKBOX" NAME="CONFIRM"> |
|
|
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="UNLOCK"> |
|
|
<? |
|
235 |
} // file_lock |
} // file_lock |
236 |
|
|
237 |
if (substr($fn,0,4) == ".del") { |
if (substr($fn,0,4) == ".del") { |
243 |
} |
} |
244 |
|
|
245 |
if ($exists && $writable) { |
if ($exists && $writable) { |
246 |
?> |
include("$html/DetailPage-undelete.html"); |
247 |
|
include("$html/DetailPage-rename.html"); |
248 |
|
|
249 |
<HR> |
} |
250 |
<a name="undelete"> |
|
251 |
<SPAN TITLE="Check OK and click [<?= $action ?>] to <?= $desc ?>."> |
if (check_perm($relDir.$fn,$gblPermNote)) { |
252 |
<B>OK TO <?= $action ?> "<?= $fn ; ?>"? </B></SPAN> |
include("$html/DetailPage-note.html"); |
253 |
<INPUT TYPE="CHECKBOX" NAME="CONFIRM"> |
} |
|
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="<?= $action ?>"> |
|
|
|
|
|
<HR> |
|
|
<a name="rename"> |
|
|
<SPAN TITLE="Check OK and click [RENAME] to rename."> |
|
|
<B>OK TO RENAME "<?= $fn ; ?>" TO |
|
|
<INPUT TYPE="TEXT" SIZE=24 MAXLENGTH=255 NAME="NEWNAME" VALUE="<?= $fn ?>"> |
|
|
? </B></SPAN> |
|
|
<INPUT TYPE="CHECKBOX" NAME="CONFIRM"> |
|
|
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="RENAME"> |
|
|
|
|
|
<?php |
|
|
} // exists && writable |
|
|
?> |
|
|
<HR> |
|
|
<a name="note"> |
|
|
<B>NOTE FOR "<?= $fn ; ?>": |
|
|
<INPUT TYPE="TEXT" SIZE=50 MAXLENGTH=255 NAME="NOTE" VALUE="<?= ReadNote($fsPath) ?>"> |
|
|
</B></SPAN> |
|
|
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="NOTE"> |
|
|
|
|
|
</FORM> |
|
254 |
|
|
255 |
<?php |
print "</FORM>"; |
256 |
|
|
257 |
$name=basename("$fsDir/$fn"); |
$name=basename("$fsDir/$fn"); |
258 |
$logname=dirname("$fsDir/$fn")."/.log/$name"; |
$logname=dirname("$fsDir/$fn")."/.log/$name"; |
438 |
|
|
439 |
////////////////////////////////////////////////////////////////// |
////////////////////////////////////////////////////////////////// |
440 |
|
|
441 |
function GifIcon($txt) { |
function GifIcon($txt = "") { |
442 |
global $gblIconLocation ; |
global $gblIconLocation, $gblImages ; |
443 |
|
|
444 |
switch (strtolower($txt)) { |
switch (strtolower($txt)) { |
|
case ".bmp" : |
|
|
case ".gif" : |
|
|
case ".jpg" : |
|
|
case ".jpeg": |
|
|
case ".tif" : |
|
|
case ".tiff": |
|
|
$d = "image2.gif" ; |
|
|
break ; |
|
445 |
case ".doc" : |
case ".doc" : |
446 |
$d = "layout.gif" ; |
$d = "layout.gif" ; |
447 |
break ; |
break ; |
519 |
$d = "quill.gif"; |
$d = "quill.gif"; |
520 |
break; |
break; |
521 |
default : |
default : |
522 |
$d = "generic.gif" ; |
if (in_array(strtolower($txt),$gblImages)) { |
523 |
|
$d = "image2.gif" ; |
524 |
|
} else { |
525 |
|
$d = "generic.gif" ; |
526 |
|
} |
527 |
} |
} |
528 |
|
|
529 |
|
|
530 |
return "<IMG SRC=\"$gblIconLocation" . $d . "\" BORDER=0>" ; |
return "<IMG SRC=\"$gblIconLocation" . $d . "\" BORDER=0>" ; |
531 |
} // end function GifIcon |
} // end function GifIcon |
532 |
|
|
537 |
global $gblEditable, $gblIcon, $gblModDays, $webRoot, $gblHide, |
global $gblEditable, $gblIcon, $gblModDays, $webRoot, $gblHide, |
538 |
$gblIgnoreUnknownFileType, $gblRepositoryDir, |
$gblIgnoreUnknownFileType, $gblRepositoryDir, |
539 |
$gblLogin, $gblUserName, $gblDateFmt, $gblTimeFmt, |
$gblLogin, $gblUserName, $gblDateFmt, $gblTimeFmt, |
540 |
|
$gblPermNote, |
541 |
$fsRealmDir, $realm, $realm_sep, |
$fsRealmDir, $realm, $realm_sep, |
542 |
$html, $realm_config, |
$html, $realm_config, |
543 |
$HTTP_GET_VARS, $HTTP_SERVER_VARS; |
$HTTP_GET_VARS, $HTTP_SERVER_VARS; |
612 |
$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>."; |
$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>."; |
613 |
StartHTML("(Navigate)",$text) ; |
StartHTML("(Navigate)",$text) ; |
614 |
|
|
615 |
echo "<TABLE BORDER=0 CELLPADDING=2 |
print "<TABLE BORDER=0 CELLPADDING=2 CELLSPACING=3 WIDTH=\"100%\">" ; |
|
CELLSPACING=3 WIDTH=\"100%\">" ; |
|
616 |
|
|
617 |
// updir (parent) bar |
// updir (parent) bar |
618 |
if (chopsl($fsDir) != chopsl($fsRoot)) { |
if (chopsl($fsDir) != chopsl($fsRoot)) { |
630 |
return $out; |
return $out; |
631 |
} |
} |
632 |
|
|
633 |
if (! HTTP_GET_VAR("dsort")) $dsort = "name"; // default directory sort |
$dsort = HTTP_GET_VAR("dsort"); |
634 |
|
if (! isset($dsort)) $dsort = "name"; // default directory sort |
635 |
|
|
636 |
$dsort_arr = array( |
$dsort_arr = array( |
637 |
"name" => array ("rname", "note"), |
"name" => array ("rname", "note"), |
640 |
"rnote" => array ("name", "note") |
"rnote" => array ("name", "note") |
641 |
); |
); |
642 |
|
|
643 |
if (! HTTP_GET_VAR("fsort")) $fsort = "name"; // default directory sort |
$fsort = HTTP_GET_VAR("fsort"); |
644 |
|
if (! isset($fsort)) $fsort = "name"; // default directory sort |
645 |
|
|
646 |
$fsort_arr = array( |
$fsort_arr = array( |
647 |
"name" => array ("rname", "note", "date", "size"), |
"name" => array ("rname", "note", "date", "size"), |
703 |
} |
} |
704 |
|
|
705 |
$dir_url=$self."?D=".urlencode(chopsl($relDir)."/".$dir); |
$dir_url=$self."?D=".urlencode(chopsl($relDir)."/".$dir); |
706 |
|
if (check_perm($relDir.$dir,$gblPermNote)) { |
707 |
|
$note_html="<a href=\"$info_url#note\">".$gblIcon("note")."</a>".$dirNote[$key]; |
708 |
|
} else { |
709 |
|
$note_html=$dirNote[$key]; |
710 |
|
} |
711 |
|
|
712 |
|
$dir_html = isBlank($dir,"directory"); |
713 |
|
|
714 |
include("$html/Navigate-dirEntry.html"); |
include("$html/Navigate-dirEntry.html"); |
715 |
|
|
716 |
} // iterate over dirs |
} // iterate over dirs |
786 |
$file_url_html.="\" TITLE=\"View file\">" ; |
$file_url_html.="\" TITLE=\"View file\">" ; |
787 |
|
|
788 |
if (substr($file,0,5) != ".del/") { |
if (substr($file,0,5) != ".del/") { |
789 |
$file_url_html .= $file . "</A>" . $a ; |
$file_url_html .= isBlank($file) . "</A>" . $a ; |
790 |
} else { |
} else { |
791 |
$file_url_html .= substr($file,5,strlen($file)-5) . "</a> <a href=\"$info_url#undelete\"><SPAN CLASS=deleted TITLE=\"deleted\">deleted</span></a>"; |
$file_url_html .= isBlank(substr($file,5,strlen($file)-5)) . "</a> <a href=\"$info_url#undelete\"><SPAN CLASS=deleted TITLE=\"deleted\">deleted</span></a>"; |
792 |
} |
} |
793 |
|
|
794 |
$note_html="<a href=\"$info_url#note\">".$gblIcon("note")."</a>".ReadNote($path); |
if (check_perm($relDir.$file,$gblPermNote)) { |
795 |
|
$note_html="<a href=\"$info_url#note\">".$gblIcon("note")."</a>".$fileNote[$key]; |
796 |
|
} else { |
797 |
|
$note_html=$fileNote[$key]; |
798 |
|
} |
799 |
|
|
800 |
$ext = strtolower(strrchr($file,".")) ; |
$ext = strtolower(strrchr($file,".")) ; |
801 |
|
|
815 |
$file_url_html = "$file $a"; |
$file_url_html = "$file $a"; |
816 |
} |
} |
817 |
} else { |
} else { |
818 |
$b.="<A HREF=\"$self?A=Co&D=".urlencode($relDir)."&F=".urlencode($file); |
if (check_perm($relDir.$file,trperm_w)) { |
819 |
$b.="\" TITLE=\"Checkout file for edit\">" ; |
$b.="<A HREF=\"$self?A=Co&D=".urlencode($relDir)."&F=".urlencode($file); |
820 |
$b.=$gblIcon("checkout")."</A>"; |
$b.="\" TITLE=\"Checkout file for edit\">" ; |
821 |
|
$b.=$gblIcon("checkout")."</A>"; |
822 |
|
} |
823 |
|
|
824 |
if ( $ext=="" || strstr(join(" ",$gblEditable),$ext) ) { |
if ( $ext=="" || strstr(join(" ",$gblEditable),$ext) ) { |
825 |
$b.="<A HREF=\"$self?A=C&D=".urlencode($relDir)."&F=".urlencode($file); |
$b.="<A HREF=\"$self?A=C&D=".urlencode($relDir)."&F=".urlencode($file); |
836 |
|
|
837 |
} // iterate over files |
} // iterate over files |
838 |
} else { // end if no files |
} else { // end if no files |
839 |
?> |
include("$html/Navigate-noFiles.html"); |
|
<TR><TD></TD><TD COLSPAN=5 CLASS=LST> |
|
|
No files in this directory |
|
|
</TD></TR> |
|
|
<? |
|
840 |
} |
} |
841 |
|
|
842 |
if ($emptyDir && $relDir != "") { |
if ($emptyDir && $relDir != "") { |
843 |
?> |
include("$html/Navigate-emptyDir.html"); |
|
|
|
|
<FORM METHOD="POST" ACTION="<?= $self ?>"> |
|
|
<TR><TD></TD><TD COLSPAN=5 CLASS=BAR> |
|
|
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>"> |
|
|
OK TO DELETE THIS EMPTY FOLDER? |
|
|
<INPUT TYPE="CHECKBOX" NAME="CONFIRM"> |
|
|
<INPUT TYPE="SUBMIT" NAME="POSTACTION" VALUE="DELETE"> |
|
|
</TD></TR> |
|
|
</FORM> |
|
|
|
|
|
<?php |
|
844 |
} // end if emptyDir |
} // end if emptyDir |
|
?> |
|
|
|
|
|
<TR><TD></TD><TD COLSPAN=5><HR></TD></TR> |
|
845 |
|
|
846 |
<? |
include("$html/Navigate-hr.html"); |
847 |
|
|
848 |
if (file_exists("$fsRealmDir/$realm".$realm_sep."info.inc")) { |
if (file_exists("$fsRealmDir/$realm".$realm_sep."info.inc")) { |
849 |
print "<TR><TD></TD><TD COLSPAN=5>"; |
print "<TR><TD></TD><TD COLSPAN=5>"; |
850 |
include("$fsRealmDir/$realm".$realm_sep."info.inc"); |
include("$fsRealmDir/$realm".$realm_sep."info.inc"); |
851 |
print "</TD></TR><TR><TD></TD><TD COLSPAN=5><HR></TD></TR>"; |
print "</TD></TR>"; |
852 |
} elseif (file_exists("$gblRepositoryDir/.info.inc")) { |
include("$html/Navigate-hr.html"); |
853 |
print "<TR><TD></TD><TD COLSPAN=5>"; |
} elseif (file_exists("$gblRepositoryDir/.info.inc")) { |
854 |
include("$gblRepositoryDir/.info.inc"); |
print "<TR><TD></TD><TD COLSPAN=5>"; |
855 |
print "</TD></TR><TR><TD></TD><TD COLSPAN=5><HR></TD></TR>"; |
include("$gblRepositoryDir/.info.inc"); |
856 |
} |
print "</TD></TR>"; |
857 |
|
include("$html/Navigate-hr.html"); |
858 |
|
} |
859 |
|
|
860 |
|
include("$html/Navigate-createNew.html"); |
861 |
|
|
862 |
?> |
print "</TABLE>"; |
|
|
|
|
<FORM METHOD="POST" ACTION="<?= $self ?>"> |
|
|
<TR><TD></TD><TD COLSPAN=5 CLASS=BAR>CREATE NEW |
|
|
<INPUT TYPE="RADIO" NAME="T" VALUE="D" CHECKED>DIRECTORY -OR- |
|
|
<INPUT TYPE="RADIO" NAME="T" VALUE="F">FILE : |
|
|
<NOBR>NAME <INPUT TYPE="TEXT" NAME="FN" SIZE=14> |
|
|
<INPUT TYPE="HIDDEN" NAME="POSTACTION" VALUE="CREATE"> |
|
|
<INPUT TYPE="HIDDEN" NAME="DIR" VALUE="<?= $relDir ?>"> |
|
|
<INPUT TYPE="SUBMIT" VALUE="CREATE" NAME="CREATE"> |
|
|
</NOBR> |
|
|
<NOBR>OR <A HREF="<?= $self ?>?A=U&D=<?= urlencode($relDir) ?>">UPLOAD</A> A FILE</NOBR> |
|
|
</TD></TR> |
|
|
</FORM> |
|
|
</TABLE> |
|
863 |
|
|
|
<?php |
|
864 |
EndHTML() ; |
EndHTML() ; |
865 |
} // end function Navigate |
} // end function Navigate |
866 |
|
|
951 |
$file=basename($target); |
$file=basename($target); |
952 |
|
|
953 |
$note=fopen("$dir/.note/$file","w"); |
$note=fopen("$dir/.note/$file","w"); |
954 |
|
if (! $note) { |
955 |
|
Error("Error writing note","Can't open note file <tt>$dir/.note/$file</tt> for writing",1); |
956 |
|
} |
957 |
fputs($note,"$msg\n"); |
fputs($note,"$msg\n"); |
958 |
fclose($note); |
fclose($note); |
959 |
|
|
1167 |
|
|
1168 |
$ext_arr = explode(".",$file); |
$ext_arr = explode(".",$file); |
1169 |
$ext = array_pop($ext_arr); |
$ext = array_pop($ext_arr); |
1170 |
if ($encoding_ext[$ext]) { |
if (isset($encoding_ext[$ext])) { |
1171 |
$encoding = $encoding_ext[$ext]; |
$encoding = $encoding_ext[$ext]; |
1172 |
$ext = array_pop($ext_arr); |
$ext = array_pop($ext_arr); |
1173 |
} |
} |
1179 |
} |
} |
1180 |
|
|
1181 |
// IE5.5 just downloads index.php if we don't do this |
// IE5.5 just downloads index.php if we don't do this |
1182 |
if(preg_match("/MSIE 5.5/", $HTTP_SERVER_VARS[HTTP_USER_AGENT])) { |
if(preg_match("/MSIE 5.5/", $HTTP_SERVER_VARS["HTTP_USER_AGENT"])) { |
1183 |
header("Content-Disposition: filename=$file"); |
header("Content-Disposition: filename=$file"); |
1184 |
} else { |
} else { |
1185 |
header("Content-Disposition: attachment; filename=$file"); |
header("Content-Disposition: attachment; filename=$file"); |
1281 |
$l = trim(fgets($fp_conf,4096)); |
$l = trim(fgets($fp_conf,4096)); |
1282 |
if (substr($l,0,1) == "+") { // no comment |
if (substr($l,0,1) == "+") { // no comment |
1283 |
$arr=explode(":",$l); |
$arr=explode(":",$l); |
1284 |
$groups_arr[$arr[0]] = $arr[1] ; |
$groups_arr[$arr[0]] = str_replace(" ","",$arr[1]) ; |
1285 |
} elseif (substr($l,0,1) != "#") { |
} elseif (substr($l,0,1) != "#") { |
1286 |
$arr=explode(":",$l); |
$arr=explode(":",$l); |
1287 |
$path=array_shift($arr); |
$path=array_shift($arr); |
1406 |
|
|
1407 |
if (isset($tr)) { |
if (isset($tr)) { |
1408 |
// first apply trustee for all |
// first apply trustee for all |
1409 |
if (isset($tr['*'])) { |
if (isset($tr['*']) && $user!="anonymous") { |
1410 |
$perm = unroll_perm($user,$tr['*'],$perm, $one_level); |
$perm = unroll_perm($user,$tr['*'],$perm, $one_level); |
1411 |
unset($tr['*']); |
unset($tr['*']); |
1412 |
} |
} |
1443 |
function check_perm($path,$trperm) { |
function check_perm($path,$trperm) { |
1444 |
global $gblLogin,$HAVE_TRUSTEE; |
global $gblLogin,$HAVE_TRUSTEE; |
1445 |
|
|
1446 |
|
$path = str_replace("//","/",$path); |
1447 |
|
|
1448 |
global $debug; |
global $debug; |
1449 |
$debug.="<br>check_perm: on <tt>$path</tt> for perm ".display_trustee($trperm)."<br>\n"; |
$debug.="<br>check_perm: on <tt>$path</tt> for perm ".display_trustee($trperm)."<br>\n"; |
1450 |
|
|
1499 |
if (strstr($file,"/")) Error("Security violation","No slashes <tt>/</tt> allowed in file name <tt>$file</tt>",1); |
if (strstr($file,"/")) Error("Security violation","No slashes <tt>/</tt> allowed in file name <tt>$file</tt>",1); |
1500 |
} |
} |
1501 |
|
|
1502 |
|
// bla/blo/../foo will return bla/foo |
1503 |
|
function remove_parent($path) { |
1504 |
|
while (preg_match(",/[^/]+/\.\./,",$path)) { |
1505 |
|
$path = preg_replace(",/[^/]+/\.\./,","",$path); |
1506 |
|
} |
1507 |
|
if (substr($path,0,1) != "/") $path = "/".$path; |
1508 |
|
return $path; |
1509 |
|
} |
1510 |
|
|
1511 |
////////////////////////////////////////////////////////////////// |
////////////////////////////////////////////////////////////////// |
1512 |
|
|
1513 |
// functions to move HTTP server variables to global namespace |
// functions to move HTTP server variables to global namespace |
1543 |
} |
} |
1544 |
|
|
1545 |
////////////////////////////////////////////////////////////////// |
////////////////////////////////////////////////////////////////// |
1546 |
|
|
1547 |
|
function isBlank($file,$what = "filename") { |
1548 |
|
if (trim($file) == "") return "<i>whitespace $what</i>"; |
1549 |
|
if ($file == "") return "<i>no $what</i>"; |
1550 |
|
return $file; |
1551 |
|
} |
1552 |
|
|
1553 |
|
////////////////////////////////////////////////////////////////// |
1554 |
// MAIN PROGRAM |
// MAIN PROGRAM |
1555 |
|
|
1556 |
$gblFilePerms = 0640 ; // default for new files |
$gblFilePerms = 0640 ; // default for new files |
1652 |
// read mime.types |
// read mime.types |
1653 |
readMime(); |
readMime(); |
1654 |
|
|
1655 |
HTTP_POST_VAR("FN"); |
if (! isset($gblPermNote)) { |
1656 |
|
$gblPermNote = trperm_r; |
1657 |
|
} |
1658 |
|
|
1659 |
|
HTTP_POST_VAR("FN"); |
1660 |
|
|
1661 |
if ($HTTP_SERVER_VARS["REQUEST_METHOD"] == "POST") { |
if ($HTTP_SERVER_VARS["REQUEST_METHOD"] == "POST") { |
1662 |
// take variables from server |
// take variables from server |
1713 |
|
|
1714 |
$source = $FN_name ; |
$source = $FN_name ; |
1715 |
if (! file_exists($source)) { |
if (! file_exists($source)) { |
1716 |
Error("You must select file with browse to upload it!"); |
Error("You must select file with browse to upload it!","If file is too big, you might need to modify php configuration options <tt>post_max_size</tt> and <tt>upload_max_filesize</tt>",1); |
1717 |
} |
} |
1718 |
|
|
1719 |
if (HTTP_POST_VAR("FILENAME")) check_filename($FILENAME); |
if (HTTP_POST_VAR("FILENAME")) check_filename($FILENAME); |
1724 |
$target = "$fsDir/$FILENAME"; |
$target = "$fsDir/$FILENAME"; |
1725 |
} |
} |
1726 |
|
|
1727 |
|
if (! check_perm("$relDir/".basename($target), trperm_w)) |
1728 |
|
Error("Access denied","User <tt>$gblLogin</tt> tried to upload <tt>$relDir/".basename($target)."</tt> without valid trustee.",1); |
1729 |
|
|
1730 |
// backup old files first |
// backup old files first |
1731 |
$dir=dirname($target); |
$dir=dirname($target); |
1732 |
if (! file_exists($dir."/.bak")) { |
if (! file_exists($dir."/.bak")) { |
1755 |
case "SAVE" : |
case "SAVE" : |
1756 |
$path = $gblFsRoot . $RELPATH ; |
$path = $gblFsRoot . $RELPATH ; |
1757 |
$path=stripSlashes($path); |
$path=stripSlashes($path); |
1758 |
|
|
1759 |
|
if (! check_perm("$RELPATH", trperm_w)) |
1760 |
|
Error("Access denied","User <tt>$gblLogin</tt> tried to save <tt>$RELPATH</tt> without valid trustee.",1); |
1761 |
|
|
1762 |
$writable = is_writeable($path) ; |
$writable = is_writeable($path) ; |
1763 |
$legaldir = is_writeable(dirname($path)) ; |
$legaldir = is_writeable(dirname($path)) ; |
1764 |
$exists = (file_exists($path)) ? 1 : 0 ; |
$exists = (file_exists($path)) ? 1 : 0 ; |
1765 |
// check for legal extension here as well |
// FIX: more verbose error message |
1766 |
if (!($writable || (!$exists && $legaldir))) |
if (!($writable || (!$exists && $legaldir))) |
1767 |
Error("Write denied",$RELPATH) ; |
Error("Write denied",$RELPATH) ; |
1768 |
$fh = fopen($path, "w") ; |
$fh = fopen($path, "w") ; |
1780 |
if ($T == "D") $type = "directory"; |
if ($T == "D") $type = "directory"; |
1781 |
else $type ="file"; |
else $type ="file"; |
1782 |
if ($FN == "") Error("Can't create $type","You must enter name of $type to create it."); |
if ($FN == "") Error("Can't create $type","You must enter name of $type to create it."); |
1783 |
if (!is_writeable($fsDir)) Error("Write denied",$relDir) ; |
if (!is_writeable($fsDir)) Error("Write denied","User <tt>$gblLogin</tt> has trustee to write in <tt>$relDir</tt> but permissions on <tt>$fsDir</tt> are wrong!", 1) ; |
1784 |
$path = $fsDir . "/" . $FN ; // file or dir to create |
$path = "$fsDir/$FN"; // file or dir to create |
1785 |
$relPath = $relDir . "/" . $FN ; |
$relPath = "$relDir/$FN"; |
1786 |
|
|
1787 |
|
if (file_exists($path)) |
1788 |
|
Error("Can't create $type","Object <tt>$relPath</tt> allready exists"); |
1789 |
|
|
1790 |
switch ( $T ) { |
switch ( $T ) { |
1791 |
case "D" : // create a directory |
case "D" : // create a directory |
1792 |
if ( ! @mkdir($path,$gblDirPerms) ) |
if ( ! @mkdir($path,$gblDirPerms) ) |
1800 |
// better keep it here altogether |
// better keep it here altogether |
1801 |
// chmod perms to $gblFilePerms |
// chmod perms to $gblFilePerms |
1802 |
if ( file_exists($path) && !is_writeable($path) ) |
if ( file_exists($path) && !is_writeable($path) ) |
1803 |
Error("File not writable", $relPath) ; |
Error("File not writable", "User <tt>$gblLogin</tt> has trustee to write in <tt>$relPath</tt> but permissions on <tt>$path</tt> are wrong!", 1) ; |
1804 |
$fh = fopen($path, "w+") ; |
$fh = fopen($path, "w+") ; |
1805 |
if ($fh) { |
if ($fh) { |
1806 |
fputs($fh,"\n"); |
fputs($fh,"\n"); |
1807 |
fclose($fh) ; |
fclose($fh) ; |
1808 |
LogIt($path,"file created",trperm_r | trperm_w); |
LogIt($path,"file created",trperm_r | trperm_w); |
1809 |
} else { |
} else { |
1810 |
Error("Creation of file $relPath failed -- $path"); |
Error("Creation of file $relPath failed", "User <tt>$gblLogin</tt> has trustee to write in <tt>$relPath</tt> but creation of <tt>$path</tt> failed!", 1) ; |
1811 |
} |
} |
1812 |
$tstr = $HTTP_SERVER_VARS["PHP_SELF"]."?A=E&D=".urlencode($relDir)."&F=".urlencode($FN) ; |
$tstr = $HTTP_SERVER_VARS["PHP_SELF"]."?A=E&D=".urlencode($relDir)."&F=".urlencode($FN) ; |
1813 |
header("Location: " . $tstr) ; |
header("Location: " . $tstr) ; |
1820 |
|
|
1821 |
if ( isset($FN) && $FN != "") { |
if ( isset($FN) && $FN != "") { |
1822 |
$path=$fsDir."/".$FN; |
$path=$fsDir."/".$FN; |
|
|
|
1823 |
$what = "file"; |
$what = "file"; |
1824 |
if (is_dir($path)) { |
} elseif (isset($DIR)) { |
1825 |
$what = "dir"; |
$path=$gblFsRoot."/".$DIR; |
1826 |
} |
$what = "directory"; |
1827 |
|
} else { |
1828 |
|
Error("Can't delete object","Can't find filename <tt>\$FN</tt> or dirname in <tt>\$DIR</tt>",1); |
1829 |
|
} |
1830 |
|
|
1831 |
if (! check_perm($relDir."/".$FN, trperm_w)) |
if (! check_perm("$relDir/$FN", trperm_w)) |
1832 |
Error("Access denied","User <tt>$gblLogin</tt> tried to erase $what <tt>$relDir/$FN</tt> without valid trustee.",1); |
Error("Access denied","User <tt>$gblLogin</tt> tried to erase $what <tt>$relDir/$FN</tt> without valid trustee.",1); |
1833 |
|
|
1834 |
$tstr = "Attempt to delete non-existing object or " ; |
$tstr = "Attempt to delete non-existing object or insufficient privileges: " ; |
|
$tstr .= "insufficient privileges: " ; |
|
1835 |
|
|
1836 |
$dir=dirname($path); |
$dir=dirname($path); |
1837 |
$file=basename($path); |
$file=basename($path); |
|
if (! file_exists("$dir/.del")) { |
|
|
mkdir("$dir/.del",0700); |
|
|
} |
|
1838 |
|
|
1839 |
// if ( ! @unlink($path) ) { |
if (! file_exists("$dir/.del")) { |
1840 |
if ( ! @rename($path,"$dir/.del/$file") ) { |
mkdir("$dir/.del",0700); |
1841 |
LogIt($path,"$what delete failed"); |
} |
1842 |
Error("Can't delete $what",$tstr.$relDir."/".$FN) ; |
|
1843 |
} else { |
if ( ! @rename($path,"$dir/.del/$file") ) { |
1844 |
LogIt($path,"$what deleted",trperm_w); |
LogIt($path,"$what delete failed"); |
1845 |
MoveTo("$dir/.log/$file","$dir/.del/.log/"); |
Error("Can't delete $what",$tstr."<tt>".$relDir."/".$FN."</tt>") ; |
|
MoveTo("$dir/.note/$file","$dir/.del/.note/"); |
|
|
MoveTo("$dir/.lock/$file","$dir/.del/.lock/"); |
|
|
} |
|
1846 |
} else { |
} else { |
1847 |
Error("Rmdir failed", $tstr . $fsDir) ; |
LogIt($path,"$what deleted",trperm_w); |
1848 |
|
MoveTo("$dir/.log/$file","$dir/.del/.log/"); |
1849 |
|
MoveTo("$dir/.note/$file","$dir/.del/.note/"); |
1850 |
|
MoveTo("$dir/.lock/$file","$dir/.del/.lock/"); |
1851 |
} |
} |
1852 |
break ; |
break ; |
1853 |
|
|
1857 |
if (substr($FN,0,4) != ".del") break ; |
if (substr($FN,0,4) != ".del") break ; |
1858 |
$file=substr($FN,4,strlen($FN)-4); |
$file=substr($FN,4,strlen($FN)-4); |
1859 |
|
|
1860 |
|
if (! check_perm("$relDir/$file", trperm_w)) |
1861 |
|
Error("Access denied","User <tt>$gblLogin</tt> tried to undelete <tt>$relDir/$file</tt> without valid trustee.",1); |
1862 |
|
|
1863 |
LogIt("$fsDir/.del/$file","undeleted",trperm_w); |
LogIt("$fsDir/.del/$file","undeleted",trperm_w); |
1864 |
MoveTo("$fsDir/.del/$file","$fsDir/"); |
MoveTo("$fsDir/.del/$file","$fsDir/"); |
1865 |
MoveTo("$fsDir/.del/.log/$file","$fsDir/.log/"); |
MoveTo("$fsDir/.del/.log/$file","$fsDir/.log/"); |
1871 |
case "RENAME" : |
case "RENAME" : |
1872 |
if ( $CONFIRM != "on" ) break ; |
if ( $CONFIRM != "on" ) break ; |
1873 |
|
|
1874 |
$NEWNAME=stripSlashes($HTTP_POST_VARS["NEWNAME"]); |
if (HTTP_POST_VAR("NEWNAME")) { |
1875 |
|
$dest = remove_parent($relDir.$NEWNAME); |
1876 |
|
if (! check_perm($relDir.$FN, trperm_w) || |
1877 |
|
! check_perm($dest, trperm_w) ) |
1878 |
|
Error("Access denied","User <tt>$gblLogin</tt> tried to rename <tt>$relDir$FN</tt> to <tt>$dest</tt> without valid trustee.",1); |
1879 |
|
} else { |
1880 |
|
Error("Rename error","Can't find new name in var <tt>\$NEWNAME</tt>",1); |
1881 |
|
} |
1882 |
LogIt("$fsDir/$FN","renamed $FN to $NEWNAME",trperm_r); |
LogIt("$fsDir/$FN","renamed $FN to $NEWNAME",trperm_r); |
1883 |
safe_rename($fsDir,$FN,$NEWNAME); |
safe_rename($fsDir,$FN,$NEWNAME); |
1884 |
break ; |
break ; |
1885 |
|
|
1886 |
case "NOTE" : |
case "NOTE" : |
1887 |
$NOTE=stripSlashes($HTTP_POST_VARS["NOTE"]); |
if (! HTTP_POST_VAR("NOTE")) |
1888 |
WriteNote("$fsDir/$FN","$NOTE"); |
Error("Can't add note to object","Can't find var <tt>\$NOTE</tt>",1); |
1889 |
|
if (! check_perm("$relDir/$FN", trperm_w)) |
1890 |
|
Error("Access denied","User <tt>$gblLogin</tt> tried to add note to <tt>$relDir/$FN</tt> without valid trustee.",1); |
1891 |
|
|
1892 |
|
WriteNote("$fsDir/$FN",$NOTE); |
1893 |
break ; |
break ; |
1894 |
|
|
1895 |
case "UNLOCK" : |
case "UNLOCK" : |
1896 |
if ( $CONFIRM != "on" ) break ; |
if ( $CONFIRM != "on" ) break ; |
1897 |
|
if (! check_perm("$relDir/$FN", trperm_w)) |
1898 |
|
Error("Access denied","User <tt>$gblLogin</tt> tried to unlock <tt>$relDir/$FN</tt> without valid trustee.",1); |
1899 |
Unlock("$fsDir/$FN"); |
Unlock("$fsDir/$FN"); |
1900 |
break ; |
break ; |
1901 |
|
|
1909 |
header("Location: ".$tstr) ; |
header("Location: ".$tstr) ; |
1910 |
exit ; |
exit ; |
1911 |
} |
} |
1912 |
|
|
1913 |
// check for mode.. navigate, code display, upload, or detail? |
// check for mode.. navigate, code display, upload, or detail? |
1914 |
// $A=U : upload to path given in $D |
// $A=U : upload to path given in $D |
1915 |
// $A=E : display detail of file $D/$F and edit |
// $A=E : display detail of file $D/$F and edit |