// open filename\n"; print "?:man // display this help file\n"; print "?:ls[path] // list files in directory\n"; print "?:nl // show file with line numbers\n"; print "?:mkdir[path/to/] // make directory\n"; print "?:rmdir[path/to/] // delete (empty) directory\n"; print "\nSubmitting a blank file deletes it.\n"; print "\nIn some browsers, ctrl-/ or alt-/ when editing a file hits done.\n"; die; } // delete empty file if( $fnam && !$text ) { if( file_exists("$fnam") ) { if( !@unlink("$fnam") ) { print "couldn't delete $fnam"; die; } } header("Location: $default"); die; } // write to file if( $fnam && $text ) { if( !file_exists("$fnam") ) { if( !@touch("$fnam") ) { print "couldn't create $fnam"; die; } chmod("$path$fnam", 0777); } $text = stripslashes($text); if (!$fp = @fopen("$fnam","w")) { print "couldn't open $fnam for writing"; die; } $text = str_replace("\r\n", "\n", $text); fwrite($fp, $text); fclose($fp); header("Location: $fnam"); exit; } // show dir contents if (preg_match("/^:ls(.*)/", $s, $regs)) { header('Content-type: text/plain'); $lfl = $path.$regs[1]; if (!file_exists("$lfl")) { print "Path not found: $regs[1]"; die; } print "$lfl\n"; system("ls -alhF $lfl"); die; } // print file with line numbers if (preg_match("/^:nl(.*)/", $s, $regs)) { $lfl = $path.$regs[1]; if (!file_exists("$lfl")) { print "Path not found: $regs[1]"; die; } else if (is_dir("$lfl")) { header("Location: ?:ls$lfl"); die; } header('Content-type: text/plain'); print "$lfl\n"; system("nl -p -b a $lfl"); die; } // make directory if( preg_match("/^:mkdir(.+)/", $s, $regs) ) { if ( !file_exists($regs[1]) ) { mkdir($regs[1]); } header("Location: ?:ls$regs[1]"); die; } // remove directory if( preg_match("/^:rmdir(.+)/", $s, $regs) ) { if ( !file_exists($regs[1]) ) { print "$regs[1] does not exist."; die; } if ( !is_dir($regs[1]) ) { print "$regs[1] is not a directory."; die; } if ( !@rmdir($regs[1]) ) { print "directory not empty or permission error."; die; } else { header("Location: $default"); die; } } $s = str_replace(":", "", $s); $slength = strlen($s); // see if file exists and get contents if ($slength !== 0) { if( is_dir("$s") ) { header("Location: ?:ls$s"); die; } if ( file_exists("$s") ) { if( !$contents = @file_get_contents("$s") ) { print "can't read $s"; die; } } // print file contents in text area ?> <?php print "$s"; ?> "; print ""; print ""; print ""; } else { header("Location: $default"); }