summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid T. Sadler <davidtsadler@googlemail.com>2021-11-09 20:47:01 +0000
committerDavid T. Sadler <davidtsadler@googlemail.com>2021-11-09 20:47:01 +0000
commit80d9e02ea47bfb783cc2033162ae9231551e5654 (patch)
tree46ff8224aba31db47a5c3094a0609a297cf33ec3
parentb15a095c0e5f980b63c1b229b0671227bfc64316 (diff)
Delete files that are no longer neededrewrite
-rw-r--r--make_bookmarklet/index.php36
-rw-r--r--public/read/index.php33
-rw-r--r--scripts/email_bookmarks.php49
3 files changed, 0 insertions, 118 deletions
diff --git a/make_bookmarklet/index.php b/make_bookmarklet/index.php
deleted file mode 100644
index 67dea14..0000000
--- a/make_bookmarklet/index.php
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-
-error_reporting(E_ALL);
-
-$config = require_once(__DIR__.'/../config.php');
-
-$booklet = <<< EOF_JS
-javascript: (() => {
- async function bookmarkPage(page) {
- const response = await fetch('{$config['site']}/add/', {
- method: 'POST',
- mode: 'cors',
- cache: 'no-cache',
- headers: {
- 'Content-Type': 'application/x-www-form-urlencoded',
- 'Authorization': 'Bearer {$config['bearer_token']}',
- },
- redirect: 'follow',
- referrerPolicy: 'no-referrer',
- body: page
- });
- return response;
- }
-
- bookmarkPage(`url=\${encodeURIComponent(window.location.href)}`)
- .then(data => {
- if (data.status === 201) {
- alert('Page bookmarked');
- } else {
- alert(`Failed with status \${data.status} \${data.statusText}`);
- }
- });
-})();
-EOF_JS;
-
-echo $booklet;
diff --git a/public/read/index.php b/public/read/index.php
deleted file mode 100644
index 74bb4ed..0000000
--- a/public/read/index.php
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php declare(strict_types=1);
-
-error_reporting(E_ALL);
-
-require_once(__DIR__.'/../../includes/functions.php');
-
-$config = require_once(__DIR__.'/../../config.php');
-
-if ('GET' !== filter_input(INPUT_SERVER, 'REQUEST_METHOD')) {
- respondAndExit(405, 'Method Not Allowed');
-}
-
-$requestedUrl = filter_input(INPUT_GET, 'url', FILTER_VALIDATE_URL);
-
-if (!$requestedUrl || strlen($requestedUrl) > $config['max_url_length']) {
- respondAndExit(400, 'Bad Request');
-}
-
-$urls = file($config['path_to_file'], FILE_IGNORE_NEW_LINES);
-
-// Remove requested url from list if present.
-$remaingUrls = array_diff($urls, [$requestedUrl]);
-
-// Count will not have changed if requested url doesn't exist in the list.
-if (count($remaingUrls) === count($urls)) {
- respondAndExit(404, 'Not Found');
-}
-
-if (!file_put_contents($config['path_to_file'], implode("\n", $remaingUrls)."\n")) {
- respondAndExit(500, 'Internal Server Error');
-}
-
-respondAndExit(308, 'Permanent Redirect', ["Location: $requestedUrl"]);
diff --git a/scripts/email_bookmarks.php b/scripts/email_bookmarks.php
deleted file mode 100644
index 9a63d94..0000000
--- a/scripts/email_bookmarks.php
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php declare(strict_types=1);
-
-error_reporting(E_ALL);
-
-$config = require_once(__DIR__.'/../config.php');
-
-$urls = file($config['path_to_file'], FILE_IGNORE_NEW_LINES);
-
-$urls = array_slice($urls, 0, $config['num_urls_to_read']);
-
-if (!count($urls)) {
- exit();
-}
-
-$email = $config['email'];
-
-mail(
- $email['to'],
- $email['subject'],
- buildMessage($urls, $config['site']),
- [
- 'From' => $email['from'],
- 'MIME-Version' => '1.0',
- 'Content-Type' => 'text/html; charset=UTF-8',
- ]
-);
-
-function buildMessage(array $urls, string $site): string
-{
- $urls = array_map(function ($url) use ($site) {
- return sprintf(
- '<li><a href="%s/read?url=%s">%s</a></li>',
- $site,
- urlencode($url),
- htmlentities($url)
- );
- }, $urls);
-
- $urls = sprintf('<ol>%s</ol>', implode('', $urls));
-
- return <<< EOF_HTML
-<html>
- <body>
- <p>Below are today's bookmarks for reading.</p>
- $urls
- </body>
-</html>
-EOF_HTML;
-}