Urgh you have magicquotes turned on. Use this:
PHP Code:
<?php
set_magic_quotes_runtime(0);
function stripslashes_deep($value)
{
$value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
return $value;
}
if(get_magic_quotes_gpc())
{
$_GET = array_map('stripslashes_deep', $_GET);
$_REQUEST = array_map('stripslashes_deep', $_REQUEST);
$_POST = array_map('stripslashes_deep', $_POST);
$_COOKIE = array_map('stripslashes_deep', $_COOKIE);
}
$filepath = 'test.txt';
$password = 'Dean_is_cool';
if(empty($_POST['do']))
{
$handle = fopen($filepath, 'r');
while(!feof($handle))
{
$buffer = fgets($handle, 4096);
$contents .= $buffer;;
}
fclose($handle);
echo '<form action="' . $_SERVER['PHP_SELF'] . '" method="post">';
echo '<input type="hidden" name="do" value="send" />';
echo 'Contents<br />';
echo '<textarea name="contents" rows="20" cols="70">' . $contents . '</textarea>';
echo '<br /><br />Password: <input type="password" name="pswd" value="" /><br /><br />';
echo '<input type="submit" name="submit" value="Submit" />';
echo '</form>';
}
else
{
$contents = $_POST['contents'];
$pswd = $_POST['pswd'];
if($password == $pswd)
{
$handle = fopen($filepath, 'w');
if(fwrite($handle, $contents) === FALSE)
{
echo 'File could not be written';
exit;
}
fclose($handle);
echo 'All done';
}
else
{
echo 'Wrong password';
}
}
?>