aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.htaccess10
-rw-r--r--lib/functions.php138
-rw-r--r--snippets/footer.snippet.php2
-rw-r--r--snippets/header.snippet.php7
-rw-r--r--templates/postform.inc.php2
-rw-r--r--templates/single.inc.php7
6 files changed, 0 insertions, 166 deletions
diff --git a/.htaccess b/.htaccess
index c63c0cd..adaefdc 100644
--- a/.htaccess
+++ b/.htaccess
@@ -1,9 +1,3 @@
-AddCharset UTF-8 .xml
-AddCharset UTF-8 .json
-
-AddType application/atom+xml .xml
-AddType application/json .json
-
<Files ~ "\.db$">
<IfModule !mod_authz_core.c>
Order allow,deny
@@ -18,10 +12,6 @@ AddType application/json .json
RewriteEngine On
RewriteBase /
-# friendly URLs
-RewriteRule ^feed/json/?$ feed/feed.json [L]
-RewriteRule ^feed/atom/?$ feed/feed.xml [L]
-
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php [L]
diff --git a/lib/functions.php b/lib/functions.php
index 608d473..70bbe17 100644
--- a/lib/functions.php
+++ b/lib/functions.php
@@ -459,144 +459,6 @@ function filter_tags($html) {
return strip_tags($html, $allowed);
}
-/* function that pings the official micro.blog endpoint for feed refreshes */
-function ping_microblog() {
- global $config;
- $ping_url = 'https://micro.blog/ping';
- $feed_url = $config['url'].'/feed/json';
-
- $ch = curl_init($ping_url);
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POSTFIELDS, 'url='.urlencode($feed_url));
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
- curl_setopt($ch, CURLOPT_HEADER, true);
- curl_setopt($ch, CURLOPT_NOBODY, true);
- curl_setopt($ch, CURLOPT_TIMEOUT, 10);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
-
- $response = curl_exec($ch);
- $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
-
- return ($status == 200) ? true : false;
-}
-
-function rebuild_feeds($amount=10) {
-
- $posts = db_select_posts(NOW+60, $amount, 'desc');
-
- rebuild_json_feed($posts);
- rebuild_atom_feed($posts);
-}
-
-function rebuild_json_feed($posts=[]) {
- global $config;
-
- if (!file_exists(ROOT.DS.'feed')) {
- mkdir(ROOT.DS.'feed', 0755);
- }
-
- $filename = ROOT.DS.'feed'.DS.'feed.json';
-
- $feed = array(
- 'version' => 'https://jsonfeed.org/version/1',
- 'title' => 'status updates by '.$config['microblog_account'],
- 'description' => '',
- 'home_page_url' => $config['url'],
- 'feed_url' => $config['url'].'/feed/feed.json',
- 'user_comment' => '',
- 'favicon' => '',
- 'author' => array('name' => $config['microblog_account']),
- 'items' => array()
- );
-
- $post_ids = array_column($posts, 'id');
- $attached_files = db_get_attached_files($post_ids);
-
- foreach($posts as $post) {
-
- // $attachments = db_get_attached_files($post['id']);
- $attachments = !empty($attached_files[$post['id']]) ? $attached_files[$post['id']] : [];
- $post_attachments = [];
- if(!empty($attachments)) {
- foreach ($attachments as $a) {
- $post_attachments[] = [
- 'url' => $config['url'] .'/'. get_file_path($a),
- 'mime_type' => $a['file_mime_type'],
- 'size_in_bytes' => $a['file_size']
- ];
- }
- }
-
- $post_images = array_filter($post_attachments, function($v) {
- return strpos($v['mime_type'], 'image') === 0;
- });
-
- $feed['items'][] = array(
- 'id' => ($post['post_guid'] ? 'urn:uuid:'.$post['post_guid'] : $config['url'].'/'.$post['id']),
- 'url' => $config['url'].'/'.$post['id'],
- 'title' => '',
- 'content_html' => $post['post_content'],
- 'date_published' => gmdate('Y-m-d\TH:i:s\Z', $post['post_timestamp']),
- 'image' => !empty($post_images) ? $post_images[0]['url'] : '',
- 'attachments' => $post_attachments
- );
- }
-
- if(file_put_contents($filename, json_encode($feed, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES))) {
- return true;
- } else return false;
-}
-
-function rebuild_atom_feed($posts=[]) {
- global $config;
-
- if (!file_exists(ROOT.DS.'feed')) {
- mkdir(ROOT.DS.'feed', 0755);
- }
-
- $filename = ROOT.DS.'feed'.DS.'feed.xml';
-
- $feed = '<?xml version="1.0" encoding="UTF-8" ?'.'>'.NL;
- $feed .= '<feed xmlns="http://www.w3.org/2005/Atom">'.NL;
- $feed .= '<author><name>'.$config['microblog_account'].'</name></author>'.NL;
- $feed .= '<title>status updates by '.$config['microblog_account'].'</title>'.NL;
- $feed .= '<id>'.$config['url'].'</id>'.NL;
- $feed .= '<updated>'.gmdate('Y-m-d\TH:i:s\Z').'</updated>'.NL;
-
- $post_ids = array_column($posts, 'id');
- $attached_files = db_get_attached_files($post_ids);
-
- foreach($posts as $post) {
-
- $post_images = !empty($attached_files[$post['id']]) ? $attached_files[$post['id']] : [];
-
- $published = gmdate('Y-m-d\TH:i:s\Z', $post['post_timestamp']);
- $updated = ($post['post_edited'] > $post['post_timestamp']) ? gmdate('Y-m-d\TH:i:s\Z', $post['post_edited']) : $published;
-
- $feed .= '<entry>'.NL;
- $feed .= '<title type="text">'.date('Y-m-d H:i', $post['post_timestamp']).'</title>'.NL;
- $feed .= '<link rel="alternate" type="text/html" href="'.$config['url'].'/'.$post['id'].'" />'.NL;
- $feed .= '<id>'.($post['post_guid'] ? 'urn:uuid:'.$post['post_guid'] : $config['url'].'/'.$post['id']).'</id>'.NL;
- $feed .= '<updated>'.$updated.'</updated>'.NL;
- $feed .= '<published>'.$published.'</published>'.NL;
-
- if(!empty($post_images)) {
- // todo: render attached images
- $feed .= '<content type="text">'.$post['post_content'].'</content>'.NL;
- } else {
- $feed .= '<content type="text">'.$post['post_content'].'</content>'.NL;
- }
-
- $feed .= '</entry>'.NL;
- }
-
- $feed .= '</feed>';
-
- if(file_put_contents($filename, $feed)) {
- return true;
- } else return false;
-}
-
function uuidv4($data = null) { // https://stackoverflow.com/a/15875555/3625228
$data = $data ?? openssl_random_pseudo_bytes(16);
diff --git a/snippets/footer.snippet.php b/snippets/footer.snippet.php
index e595781..397c2fb 100644
--- a/snippets/footer.snippet.php
+++ b/snippets/footer.snippet.php
@@ -1,8 +1,6 @@
<footer>
<nav>
<ul>
- <li><a href="<?= $config['url'] ?>/feed/atom">ATOM Feed</a></li>
- <li><a href="<?= $config['url'] ?>/feed/json">JSON Feed</a></li>
<?php if($config['logged_in']): ?><li><a href="<?= $config['url'] ?>/logout">Logout</a></li><?php endif; ?>
</ul>
</nav>
diff --git a/snippets/header.snippet.php b/snippets/header.snippet.php
index 3d83eb3..6c4f6ce 100644
--- a/snippets/header.snippet.php
+++ b/snippets/header.snippet.php
@@ -22,13 +22,6 @@
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="apple-mobile-web-app-title" content="<?= $config['site_title'] ?>">
- <link rel="alternate" type="application/json" title="JSON Feed" href="<?= $config['url'] ?>/feed/json" />
- <link rel="alternate" type="application/atom+xml" title="Atom Feed" href="<?= $config['url'] ?>/feed/atom" />
-
- <?php if(!empty($config['microblog_account'])): ?>
- <link href="https://micro.blog/<?= ltrim($config['microblog_account'], '@') ?>" rel="me" />
- <?php endif; ?>
-
<link rel="icon" href="<?= $config['url'] ?>/favicon.ico" />
<link rel="stylesheet" href="<?= $config['url'] ?>/css/<?= $css ?>/<?= $css ?>.css" />
diff --git a/templates/postform.inc.php b/templates/postform.inc.php
index 63e3901..282e9dc 100644
--- a/templates/postform.inc.php
+++ b/templates/postform.inc.php
@@ -24,8 +24,6 @@
attach_uploaded_files($_FILES['attachments'], $id);
}
- rebuild_feeds();
-
header('Location: '.$config['url']);
die();
}
diff --git a/templates/single.inc.php b/templates/single.inc.php
index a1344b0..438aa27 100644
--- a/templates/single.inc.php
+++ b/templates/single.inc.php
@@ -19,9 +19,6 @@
if(!$result) {
$error = 'Post could not be deleted!';
} else {
-
- rebuild_feeds();
-
header('Location: '.$config['url']);
die();
}
@@ -33,8 +30,6 @@
if(!$result) {
$error = 'Post could not be restored!';
- } else {
- rebuild_feeds();
}
}
@@ -72,8 +67,6 @@
if(!$result) {
$error = 'Post could not be updated!';
} else {
- rebuild_feeds();
-
header('Location: '.$config['url'].'/'.$_POST['id']);
die();
}