diff --git a/includes/content.php b/includes/content.php index 4a05be9..4e0da0f 100644 --- a/includes/content.php +++ b/includes/content.php @@ -2,6 +2,7 @@ class Page { public $name, $filename; + public static $parentDir = "../"; public static $contentFolder = "content/"; public function __construct($name, $filename) @@ -26,11 +27,24 @@ class Page return $this->filename; } + public function nodir($item) + { + return (!is_dir(Page::$parentDir . Page::$contentFolder . $item)); + } + + public static function fileList() + { + $dirContent = scandir(Page::$parentDir . Page::$contentFolder); + $files = (array_filter($dirContent, "Page::nodir")); + return $files; + } + // For future-uses... public function getName() { return $this->name; } + } ?> diff --git a/includes/htmlcode.php b/includes/htmlcode.php index 133e862..4d3f4de 100644 --- a/includes/htmlcode.php +++ b/includes/htmlcode.php @@ -3,7 +3,7 @@ function start_html($title) { print " - + $title diff --git a/includes/miscfunc.php b/includes/miscfunc.php index a74dd99..c646bb8 100644 --- a/includes/miscfunc.php +++ b/includes/miscfunc.php @@ -3,6 +3,7 @@ function terminate($message="") { print "$message\n"; footer(); - exit(1); + exit(0); } + ?> diff --git a/index.php b/index.php index 53b4302..f85e333 100644 --- a/index.php +++ b/index.php @@ -78,7 +78,6 @@ $contactPage = new Page("Contact", "contact.html"); } $dirContent = scandir(Page::$contentFolder); - $files = (array_filter($dirContent, "nodir")); // Iterate through all the files for a match (from ?content=) diff --git a/user/editfile.php b/user/editfile.php new file mode 100644 index 0000000..9d086af --- /dev/null +++ b/user/editfile.php @@ -0,0 +1,34 @@ + +Text:
+ +
+ + +"; + +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); +?> diff --git a/user/editfiles.php b/user/editfiles.php new file mode 100644 index 0000000..6fc110c --- /dev/null +++ b/user/editfiles.php @@ -0,0 +1,10 @@ +$file
\n"; +} +?> diff --git a/user/index.php b/user/index.php index 2f4515f..b8ae4ec 100644 --- a/user/index.php +++ b/user/index.php @@ -12,6 +12,9 @@ include "../includes/login.inc"; Edit existing post

+Edit content files +

+

Logout

diff --git a/user/updatefile.php b/user/updatefile.php new file mode 100644 index 0000000..afd2c48 --- /dev/null +++ b/user/updatefile.php @@ -0,0 +1,17 @@ +