Reworked 'nodir'-function a bit and included it in the Page-class instead. Started working on a way to edit content files
This commit is contained in:
34
user/editfile.php
Normal file
34
user/editfile.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
require ("../includes/content.php");
|
||||
require ("../includes/miscfunc.php");
|
||||
require ("../includes/htmlcode.php");
|
||||
$filename = $_GET['file'];
|
||||
$file = Page::$parentDir . Page::$contentFolder . $filename;
|
||||
|
||||
$filehandle = fopen ("$file", "rw");
|
||||
$content = fread($filehandle, filesize($file));
|
||||
|
||||
start_html("Edit file");
|
||||
print "<form action=\"$_SERVER[PHP_SELF]\" method='post'>
|
||||
Text: <br />
|
||||
<textarea cols='80' rows='30' name='file'>$content</textarea>
|
||||
<br />
|
||||
<input type='submit' value='Save file'>
|
||||
</form>
|
||||
";
|
||||
|
||||
if (!isset($_POST['post']))
|
||||
{
|
||||
end_html();
|
||||
die;
|
||||
}
|
||||
|
||||
if (fwrite($filehandle, $_POST['post']) === FALSE)
|
||||
{
|
||||
echo "Cannot write to file ($file)";
|
||||
exit;
|
||||
}
|
||||
|
||||
echo "Success, saved file ($file)";
|
||||
fclose($filehandle);
|
||||
?>
|
Reference in New Issue
Block a user