aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--controllers/archive.php10
-rw-r--r--views/archive/index.php24
-rw-r--r--views/home/index.php2
3 files changed, 35 insertions, 1 deletions
diff --git a/controllers/archive.php b/controllers/archive.php
new file mode 100644
index 0000000..a54387b
--- /dev/null
+++ b/controllers/archive.php
@@ -0,0 +1,10 @@
+<?php
+
+function on_get() {
+ global $page;
+ try {
+ $page = Database\Webpage::fromDB($_GET["page_url"]);
+ $page->incrementVisits();
+ }
+ catch(Exception $e) {}
+}
diff --git a/views/archive/index.php b/views/archive/index.php
new file mode 100644
index 0000000..7e85c70
--- /dev/null
+++ b/views/archive/index.php
@@ -0,0 +1,24 @@
+<?php
+ include '../meta.php';
+ $page = null;
+ runController('archive');
+?>
+
+<?php if ($page !== null): ?>
+ <iframe>
+ <!-- /archives/$page->WID -->
+ </iframe>
+ <?php foreach (Database\Webpage::allArchives($page->URL) as $page): ?>
+ <section>
+ <?php echo $page->Date ?>
+ </section>
+ <?php endforeach; ?>
+
+<?php else: ?>
+ <h2>This page hasn't been archived yet!</h2>
+ <form action="/sample_archive/index.php" method="POST">
+ <input type="hidden" name="page_url" value="<?php echo $_GET["page_url"] ?>">
+ <input type="submit" value="Archive Now!">
+ </form>
+
+<?php endif; ?>
diff --git a/views/home/index.php b/views/home/index.php
index 33f123d..4883a91 100644
--- a/views/home/index.php
+++ b/views/home/index.php
@@ -4,7 +4,7 @@
<section class="highlight separate-margin">
<h2>Explore the archives or add a new page</h2>
- <form action="/sample_archive/index.php" method="POST" class="font-125 flex-row width-100 center-margin">
+ <form action="/archive/index.php" method="GET" class="font-125 flex-row width-100 center-margin">
<input type="text" name="page_url" placeholder="Enter a URL" class="flex-expand">
<input type="submit" name="archive_page_button" value="Search">
</form>