not linking correctly (fread etc..)
Posted: Thu Nov 13, 2003 10:11 pm
Edit.php:
I made this for my friend.
I host his site (because he needed a guestbook and freewebs doesnt allow php), but i dont want to give him ftp access, since he doesnt know what he's doing, so i made a page that allows him to select which page to edit and then edit it inside of a textarea.
Only problem is when you use <a href="http://www.site.com"></a> the quotes get escaped.. and even trying to escape them (typing <a href=\"site.com\"> just makes it worse..
any ideas on how to save the text file with the quotes intact?
-thanks
btw, here's links.html (a page that is editable), so you can see what happens:
(it adds more \s everytime i load and save it)
Code: Select all
<?php
if($pass!="***"){
echo "
Please Enter The Password to Continute:
<form action='$PHP_SELF' name="passform" method="post">
<input type="text" name="pass" value="Enter Password" size="20">
<input type="hidden" name="s1d" value="yes">
<input type="submit" value="Submit" name="submit">
</form>
";
}
else if($pass=="****"){
if($page!=""){
if($save == "Save"){
$filename = "$page.html";
$file = fopen( $filename, "w");
fwrite($file, $textarea);
fclose( $file );
header('location: index.php');
}
else{
$filename = "$page.html";
$file = fopen( $filename, "r" );
$filesize = filesize( $filename );
$text = fread( $file, $filesize );
fclose ( $file );
echo ("<form name="form" method="post" action="">\n");
echo ("<textarea name="textarea" cols="100" rows="20">\n");
echo $text;
echo ("</textarea>\n");
echo ("<br>\n<input type="submit" name="save" value="Save">\n");
echo ("<input type="hidden" name="page" value="$page"\n>");
echo ("<input type="hidden" name="pass" value="$pass"\n>");
echo ("</form>\n");
}
}
else{
echo "
<form action='$PHP_SELF' name="pageform" method="post">
<table width="400" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" width="100">Page Name:</td>
<td valign="top" width="100"><input type="text" name="page" size="20"></td>
</tr>
<tr>
<td></td>
<td valign="top" width="100"><input type="hidden" name="pass" value="$pass"><input type="submit" value="Log-In"></td>
</tr>
</table>
</form>
Page Key:<br>
Home Page = homepage<br>
Method = method<br>
Links = links<br>
Stats = stats<br>
";
}
}
else
{
echo "Error In Processing. Please press back and try again";
}
?>I host his site (because he needed a guestbook and freewebs doesnt allow php), but i dont want to give him ftp access, since he doesnt know what he's doing, so i made a page that allows him to select which page to edit and then edit it inside of a textarea.
Only problem is when you use <a href="http://www.site.com"></a> the quotes get escaped.. and even trying to escape them (typing <a href=\"site.com\"> just makes it worse..
any ideas on how to save the text file with the quotes intact?
-thanks
btw, here's links.html (a page that is editable), so you can see what happens:
Code: Select all
Links:<br>
- <a href="e;http://www.404-design.net/pbk/index.php"e;>Home Page</a><br>
- <a href="e;http://www.404-design.net/pbk/method.php"e;>Trophy Method</a><br>
- <a href="e;http://www.404-design.net/pbk/guestbook.php"e;>Guestbook</a><br>
- <a href="e;http://www.xxxx/page.php?x=996468"e; target="e;_blank"e;>Support the Site</a><br>
- <a href="e;http://www.stock-wars.com/"e; target="e;_blank"e;>Stock-Wars</a><br>