[SOLVED] escaping in fwrite() and fopen()
Moderator: General Moderators
-
Daisy Cutter
- Forum Commoner
- Posts: 75
- Joined: Sun Aug 01, 2004 9:51 am
escaping in fwrite() and fopen()
how can I stop fwrite and fopen from escaping charachters, or print them without escaping? me and a friend are working on a programming project and I set up a "notepad" type program for us to leave messages/code for eachother but we can't copy and paste code because quotes and slashes get escaped. 
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
-
Daisy Cutter
- Forum Commoner
- Posts: 75
- Joined: Sun Aug 01, 2004 9:51 am
sorry for being so dense but could anyone tell me how I would apply stripslashes to the output of this? Or how can I disable magicquotes via .htaccess?
Code: Select all
<form id="fwrite" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<!-- open: <input type="text" name="filename" size="25">.txt<br /> -->
<?php
$filename = "cody.txt";
$somecontent = $_POST['writer'];
if ($_POST['overwrite'] == true) {
$wr = 'w'; }
else{
$wr = 'a'; }
if (is_writable($filename)) {
if (!$handle = fopen($filename, $wr)) {
echo "Cannot open file ($filename)";
exit; }
// Write $somecontent to our opened file.
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit; }
echo "Success";
fclose($handle); }
else {
echo "The file $filename is not writable";
}
?>
<br />
<textarea name="writer" rows="25" cols="75">
<?php
include $filename;
?>
</textarea><br />
<input type="checkbox" name="overwrite" value="x" />overwrite?<br />
<input type="submit" value="save" />
</form>
?>-
Daisy Cutter
- Forum Commoner
- Posts: 75
- Joined: Sun Aug 01, 2004 9:51 am