Revision: 3320
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at July 8, 2007 18:19 by Jaymoon
Initial Code
<?php $loadcontent = "test-edit.php"; if($_POST['save_file']) { $savecontent = stripslashes($_POST['savecontent']); $fp = @fopen($loadcontent, "w"); if ($fp) { fwrite($fp, $savecontent); fclose($fp); print "<html><head><META http-equiv=\"refresh\" content=\"0;URL=$_SERVER[PHP_SELF]\"></head><body>"; } } $fp = @fopen($loadcontent, "r"); $loadcontent = fread($fp, filesize($loadcontent)); $lines = explode("\n", $loadcontent); $count = count($lines); $loadcontent = htmlspecialchars($loadcontent); fclose($fp); for ($a = 1; $a < $count+1; $a++) { $line .= "$a\n"; } ?> <p><font face="tahoma">Simply edit the page and hit save!</font></p> <form method=post action="<?=$_SERVER[PHP_SELF]?>"> <input type="submit" name="save_file" value="Save"><br /><br /> <table width="100%" valign="top" border="0" cellspacing="1" cellpadding="1"> <tr> <td width="3%" align="right" valign="top"><pre style="text-align: right; padding: 4px; overflow: auto; border: 0px groove; font-size: 12px; font-face:verdana;" name="lines" cols="4" rows="<?=$count+3;?>"><?=$line;?></pre></td> <td width="97%" align="left" valign="top"><textarea style="text-align: left; padding: 0px; overflow: auto; border: 3px groove; font-size: 12px; font-face:verdana;" name="savecontent" cols="150" rows="<?=$count;?>" wrap="OFF"><?=$loadcontent?>
Initial URL
http://www.dreamincode.net/code/snippet99.htm
Initial Description
The original code was meant to be used with register_globals=on. If you cannot or don't want to turn that on, then I have modified the code to work with register_globals=off.
Initial Title
PHP File Editor
Initial Tags
php, file, files
Initial Language
PHP