Gimme a min and I'll write a script for you...
---------- Post added at 19:33 ---------- Previous post was at 18:52 ----------
Here ya go.
Simple create the text file, modify the script to reflect the new filename, change the permissions so the webserver can read and write to it and you're done.
If you're not sure on the permissions thing, set it to 777 (all can read/write) - this should give the correct permissions to the file.
If you have shell access, do something like:
Code:
chown nobody:nobody textfile.txt
That should do it, if not find out which user Apache is running under by doing:
Code:
ps aux | grep httpd
OR
Code:
ps aux | grep apache
PHP Code:
<?php
// Stop the addslashes()
if (get_magic_quotes_gpc()) {
$process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
while (list($key, $val) = each($process)) {
foreach ($val as $k => $v) {
unset($process[$key][$k]);
if (is_array($v)) {
$process[$key][stripslashes($k)] = $v;
$process[] = &$process[$key][stripslashes($k)];
} else {
$process[$key][stripslashes($k)] = stripslashes($v);
}
}
}
unset($process);
}
?>
<?php
// Edit this if you need to, change the filename to whatever you need
define ('TEXT_FILE', 'filename.txt');
define ('BYTES', 4096); // Expected max size of the file in bytes
$message = '<br />Edit the file and click Save.<br />';
?>
<html>
<head>
<title>Text Editor</title>
</head>
<body>
<?php
if ($_POST['action'] == 'save') {
$fileWrite = fopen(TEXT_FILE, "w");
$text = $_POST['text'];
fwrite($fileWrite, $text);
$message = '<br />File saved, contents were: <pre>' . $text . '</pre><br />';
}
if (is_resource($fileWrite)) {
fclose($fileWrite);
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<?php
$file = fopen(TEXT_FILE, "r");
echo '<textarea name="text" rows="12" cols="60">';
$contents = fread($file, BYTES);
echo $contents;
if (is_resource($file)) {
fclose($file);
}
?>
</textarea>
<br />
<input type="hidden" name="action" value="save" />
<input type="submit" value="Save" />
</form>
<?php
echo $message;
?>
</body>
</html>
Rather elegant I feel, will have to remember to keep this one for my own use.