...

View Full Version : Magically adding slashes?



Dalsor
09-09-2003, 04:30 PM
Greetings, all.

I have a series of pages on a site I maintain that are used to allow easy end-user updates. Recently I noticed they've developed a ton of extra slashes when the pages are updated, and for the life of me, I can't figure out where they're coming from.

This is one block of links off of the admin page. The user selects a link to edit which calls edit.php to handle that link's content. Please overlook some of the bad CSS. :)


Select a link to edit:
<p align="left">

<!-- Informative stuff -->

<table border="0" cellspacing="0" cellpadding="0" style="border-left:1px">
<tr style="border-left:1px; border-color:#FFCCFF;">
<td class="boxContents" style="border-left:1px">
&nbsp;<strong><em> </em></strong>
<font class="menuText">
&nbsp;<a href="edit.php?page=text/index.txt">Affiliate Home</a>
</font><br>
&nbsp;<strong><em> </em></strong>
<font class="menuText">
&nbsp;<a href="edit.php?page=text/komenfacts.txt">Komen Facts</a>
</font><br>
&nbsp;<strong><em> </em></strong>
<font class="menuText">
&nbsp;<a href="edit.php?page=text/bcfacts.txt">Breast Cancer Facts</a>
</font><br>
&nbsp;<strong><em> </em></strong>
<font class="menuText">
&nbsp;<a href="edit.php?page=text/selfexam.txt">Breast Self-Exam</a>
</font><br><br>
</td>
</tr>
</table>


Edit.php then looks like this.. Simple page.



<body bgcolor="#FFFFFF">

<?php
error_reporting(E_ALL);
$filename = $page;
$handle = fopen($filename, "r");
$contents = fread($handle, filesize ($filename));
fclose($handle);
?>

<FORM ACTION="update.php" METHOD=POST>

<strong>
<font size="+1">Editting: <?php echo $page; ?></font>
</strong>
<BR>
<TEXTAREA COLS="79" ROWS="30" NAME="contents">

<?php echo $contents; ?>

</TEXTAREA>

<input value="<?php echo $page; ?>" type=HIDDEN name="pagename">
<P>
<INPUT TYPE=SUBMIT VALUE="submit">
</FORM>


Once the user submits the changes, update.php is called.


<?php
error_reporting(E_ALL);

$page = $_POST['pagename'];
$filename = $page;

if (is_writable($filename))
{

if (!$handle = fopen($filename, 'w'))
{
exit;
}

if (!fwrite($handle, $_POST['contents']))
{
exit;
}

fclose($handle);
echo "Process completed... Finished writing " . $filename . "<br><br>";
echo "<a href=http://www.upstateraceforthecure.org/inc/admin.php>Admin</a> | ";
echo "<a href=http://www.upstateraceforthecure.org>Home</a>";

}
else
{
echo "Cannot open file " .$filename . " for writing. Check permissions.";
echo "<a href=http://www.upstateraceforthecure.org/inc/admin.php>Admin</a> | ";
echo "<a href=http://www.upstateraceforthecure.org>Home</a>";
}
?>


I can't see where these slashes are coming from, but when the pages are updated, anything with a " gets a \" and after several updates, end up looking like:

The leading slashes are being stripped by the board, but there are also slashes before the first "justify in this example.


<p class=\\\\\\\\\\\\\\\"justify\\\\\\\\\\\\\\\">


Thanks for any advice!

Eric

Spookster
09-09-2003, 04:33 PM
Ironically enought it is magic.....well magic_quotes anyways. See previous thread on this

http://www.codingforums.com/showthread.php?s=&threadid=25516

Dalsor
09-09-2003, 04:40 PM
ahhh foot! Thanks Spookster!

That did the trick.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum