hi all
I am trying to create a very simple/basic online sidewide html/PHP editor, i have a form which inputs the variable $editfile, which is the path to the file (ie ../articles/alancohen/article62.php), the script opens the file without a problem and i can change the text in the textarea, however when i click on the edit button at the bottom i get these error's
Warning: fopen("../articles/alancohen/article62.php", "w+") - Permission denied in /home/.sites/28/site1/web/editing/edit.php on line 27
Warning: fwrite(): supplied argument is not a valid File-Handle resource in /home/.sites/28/site1/web/editing/edit.php on line 28
Warning: fclose(): supplied argument is not a valid File-Handle resource in /home/.sites/28/site1/web/editing/edit.php on line 29
and the file does not get updated with the new text in the textarea,
any ideas?
cheers
steve
PHP Code:<html>
<head><title>Edit Page</title></head>
<body bgcolor="#cccccc" text="#000000" link="#000000" alink="#000000" vlink="#000000">
<font face="verdana, arial, helvetica" size=2>
<?PHP
if ($_POST['pw']!="") {$pw=$_POST['pw'];}else{$pw=$_GET['pw'];}
$newcontent=$_POST['newcontent'];
$filelocation = "$editfile";
if (!file_exists($filelocation)) {
echo "Couldn't find datafile, please contact administrator!";
}
else {
$newfile = fopen($filelocation,"r");
$content = fread($newfile, filesize($filelocation));
fclose($newfile);
}
$content = stripslashes($content);
$content = htmlentities($content);
$pass="password";
if (!$pw || $pw != $pass){
$content = nl2br($content);
}
else {
if ($newcontent){
$newcontent = stripslashes($newcontent);
$newfile = fopen($filelocation,"w+");
fwrite($newfile, $newcontent);
fclose($newfile);
echo "Text was edited.<form><input type=\"submit\" value=\"see changes\"></form>";
}
else{
echo "<form method=\"post\">
<textarea name=\"newcontent\" cols=50 rows=15 wrap=\"virtual\">";
echo $content;
echo "</textarea><input type=\"hidden\" name=\"pw\" value=\"$pass\"><br><input type=\"submit\" value=\"edit\"></form>";
}
}
?>
</font>
</body>
</html>





Bookmarks