that doesnt work either, im just going to post the 3 includes here also. Please test the script out for me. THanks!
<?php
//common.inc
$default_dir = "./";
$default_filename = "new.txt";
$edit_form_cols = 80;
$edit_form_rows = 25;
$text_file_array = array( "txt", "htm", "html", "php", "inc", "dat" );
$image_file_array = array("gif", "jpeg", "jpg", "png");
function html_header() {
?>
<HEAD><TITLE>Welcome to Web Text Editor</TITLE></HEAD>
<BODY>
<?php
}
function html_footer() {
?>
</BODY>
<?php
}
function error_message($msg) {
html_header();
echo "<SCRIPT>alert(\"$msg\"); history.go(-1)</SCRIPT>";
html_footer();
exit;
}
function date_str($timestamp) {
$date_str = getdate($timestamp);
$year = $date_str["year"];
$mon = $date_str["mon"];
$mday = $date_str["mday"];
$hours = $date_str["hours"];
$minutes = $date_str["minutes"];
$seconds = $date_str["seconds"];
return "$hours:$minutes:$seconds $mday/$mon/$year";
}
function file_info($file) {
global $text_file_array, $WINDIR;
$file_info_array["filesize"] = number_format(filesize($file)) . " bytes.";
$file_info_array["filectime"] = date_str(filectime($file));
$file_info_array["filemtime"] = date_str(filemtime($file));
if(!isset($WINDIR)) {
$file_info_array["fileatime"] = date_str(fileatime($file));
$file_info_array["filegroup"] = filegroup($file);
$file_info_array["fileowner"] = fileowner($file);
} else {
$file_info_array["fileatime"] = "not available";
$file_info_array["filegroup"] = "not available";
$file_info_array["fileowner"] = "not available";
}
$extension = array_pop(explode(".", $file));
if(in_array($extension, $text_file_array))
$file_info_array["filetype"] = "text";
else $file_info_array["filetype"] = "binary";
return $file_info_array;
}
?>
here's editor.inc-
<?php
//editor.php
//include "./common.inc";
function editor_form($dir, $filename, $is_new) {
global $PHP_SELF, $edit_form_cols, $edit_form_rows;
$filepath = "$dir/$filename";
if(!$is_new) $filebody = implode("",file($filepath));
$file_info_array = file_info("$filepath");
$editable = 1;
if($file_info_array["filetype"] != "text") {
$filebody = $filepath . " is not a text file.
You had better not edit it.";
$editable = 0;
}
if($editable) {
?>
<CENTER>
<FORM NAME="edit_form" METHOD="POST" action="<?php echo $PHP_SELF ?>">
<INPUT TYPE="HIDDEN" NAME="action" VALUE="save_file">
<INPUT TYPE="HIDDEN" NAME="dir" VALUE="<?php echo "$dir" ?>">
<TEXTAREA ROWS="<?php echo $edit_form_rows ?>" NAME="filebody"
COLS="<?php echo $edit_form_cols ?>" WRAP="soft">
<?php echo "$filebody"; ?>
</TEXTAREA><BR>
Filename: <?php echo "<STRONG>$dir/</STRONG>"; ?>
<INPUT TYPE="TEXT" NAME="filename" VALUE="<?php echo $filename ?>"
SIZE="30">
<INPUT TYPE="SUBMIT" VALUE="Save" NAME="Submit">
</FORM>
</CENTER>
<?php
}
else {
echo "<CENTER><STRONG><FONT COLOR=\"RED\">$filebody</FONT></STRONG></CENTER>\n";
}
}
function edit_new_form() {
global $PHP_SELF, $default_dir, $dir;
?>
<CENTER><FORM METHOD="POST" ACTION="<?php echo $PHP_SELF ?>">
<INPUT TYPE="HIDDEN" NAME="action" VALUE="editor_page">
<INPUT TYPE="HIDDEN" NAME="dir" VALUE="<?php echo $dir ?>">
<INPUT TYPE="SUBMIT" VALUE="Edit New"></FORM></CENTER>
<?php
}
function save_file() {
global $filename, $filebody, $dir, $PHP_SELF, $new_file;
if(file_exists("$dir/$filename")) {
if($new_file=0){
echo "<SCRIPT>result=confirm(\"Overwrite '$dir/$filename'?\");
if(!result) history.go(-1);</SCRIPT>";
}
else{
$new_file=0;
}
}
if($file = fopen("$dir/$filename", "w")) {
fputs($file, $filebody);
fclose($file);
if(file_exists("$dir/$filename")) echo " file now exists...";
}
else {
error_message("Can't save file $dir/$filename.");
}
echo "<SCRIPT>parent.location.href='$PHP_SELF?action=dir_page\&dir=$dir';</SCRIPT>";
echo "<SCRIPT>self.location.href='$PHP_SELF?action=editor_page\&dir=$dir\&filename=$filename';</SCRIPT>";
}
function editor_page() {
global $dir, $filename, $default_filename;
$is_new = 0;
if($filename == '') {
$filename = $default_filename;
$is_new = 1;
}
if(!file_exists("$dir/$filename")) $is_new = 1;
if(!$is_new) {
edit_new_form();
?>
<TABLE BORDER="1" WIDTH="100%">
<TR><TH WIDTH="100%" COLSPAN="2">
<CENTER><STRONG>Stats for <?php echo "$dir/$filename" ?>
</TD></TR>
<?php
$file_info_array = file_info("$dir/$filename");
foreach($file_info_array as $key=>$val) {
echo "<TR><TH WIDTH=\"30%\">". ucfirst($key) .
"</TD><TD WIDTH=\"70%\">" . $val .
"</TD></TR>\n";
}
?>
</TABLE>
<?php
} else {
echo "<CENTER><STRONG>Editing a new file</STRONG></CENTER>\n";
}
editor_form($dir, $filename, $is_new);
}
$def_length=strlen($default_dir);
if(!empty($dir)) $dir_test=substr($dir, 0, $def_length);
if(empty($dir) || ($dir_test!=$default_dir)) {
$dir = $default_dir;
}
?>
and here's navigator.inc
<?php
//navigator.php
//include "common.inc";
function mkdir_form() {
global $PHP_SELF, $dir;
?>
<CENTER>
<FORM METHOD="POST"
ACTION="<?php echo "$PHP_SELF?action=make_dir&dir=$dir"; ?>">
<INPUT TYPE="HIDDEN" NAME="action" VALUE="make_dir">
<INPUT TYPE="HIDDEN" NAME="dir" VALUE="<? echo $dir ?>">
<?php
echo "<STRONG>$dir</STRONG>"
?>
<BR>
<INPUT TYPE="TEXT" NAME="new_dir" SIZE="10">
<INPUT TYPE="SUBMIT" VALUE="Make Dir" NAME="Submit">
</FORM>
</CENTER>
<?php
}
function make_dir() {
global $dir, $new_dir;
if(!@mkdir("$dir/$new_dir", 0700)) {
error_message("Can't create the directory $dir/$new_dir.");
}
html_header();
dir_page();
html_footer();
}
function display() {
global $filename, $dir, $text_file_array, $image_file_array;
$extension = array_pop(explode(".", $filename));
if(in_array($extension, $text_file_array)) {
readfile("$dir/$filename");
}
else if(in_array($extension, $image_file_array)) {
echo "<IMG SRC=\"$dir/$filename\">";
}
else echo "Cannot be displayed. $dir/$filename has not been
recognised as a text file, nor as a valid image file. ";
}
function dir_page() {
global $dir, $default_dir, $PHP_SELF, $default_filename;
if($dir == '') {
$dir = $default_dir;
}
$dp = opendir($dir);
?>
<TABLE BORDER="0" WIDTH="100%" CELLSPACING="0" CELLPADDING="0">
<?php
while($file = readdir($dp)) $filenames[] = $file;
sort($filenames);
for($i = 0; $i < count($filenames); $i++)
{
$file = $filenames[$i];
if($dir == $default_dir && ($file == "." || $file == ".."))
continue;
if(is_dir("$dir/$file") && $file == ".")
continue;
if(is_dir("$dir/$file")) {
if($file == ".."){
$current_dir = basename($dir);
$parent_dir = ereg_replace("/$current_dir$","",$dir);
echo "<TR><TD WIDTH=\"100%\" NOWRAP>
<A HREF=\"$PHP_SELF?action=dir_page&dir=$parent_dir\">$file/
</A></TD></TR>\n";
}
else echo "<TR><TD WIDTH=\"100%\" NOWRAP>
<A HREF=\"$PHP_SELF?action=dir_page&dir=$dir/$file\">$file/
</A></TD></TR>\n";
}
else echo "<TR><TD WIDTH=\"100%\" NOWRAP>
<A HREF=\"$PHP_SELF?action=editor_page&dir=$dir&filename=$file\"
TARGET=\"main\">$file
</A></TD></TR>\n";
}
?>
</TABLE>
<?php
mkdir_form();
}
$def_length=strlen($default_dir);
if(!empty($dir)) $dir_test=substr($dir, 0, $def_length);
if(empty($dir) || ($dir_test!=$default_dir)) {
$dir = $default_dir;
}
?>
PLEASE PLEASE PLEASE HELP ME!