From 15d4e6d1249487c633b42898407b567b9061b116 Mon Sep 17 00:00:00 2001
From: Christian Weiske <cweiske@cweiske.de>
Date: Sun, 7 Jan 2018 20:51:34 +0100
Subject: [PATCH] Allow linkback endpoint configuration

Supports pingback and webmention
---
 data/config.php.dist | 3 +++
 www/comment.php      | 5 +++++
 www/www-header.php   | 1 +
 3 files changed, 9 insertions(+)

diff --git a/data/config.php.dist b/data/config.php.dist
index d1eec0d..6a98718 100644
--- a/data/config.php.dist
+++ b/data/config.php.dist
@@ -3,4 +3,7 @@ $title  = 'anoweco';
 $dbdsn  = 'mysql:dbname=FIXME;host=127.0.0.1';
 $dbuser = 'FIXME';
 $dbpass = 'FIXME';
+
+//optional
+//$linkbackEndpoint = 'http://stapibas.example.org/xmlrpc.php';
 ?>
diff --git a/www/comment.php b/www/comment.php
index beaad96..e384361 100644
--- a/www/comment.php
+++ b/www/comment.php
@@ -58,5 +58,10 @@ if ($rowComment->comment_type == 'like') {
     $vars['htmlContent'] = $htmlContent;
 }
 
+if (isset($linkbackEndpoint) && $linkbackEndpoint) {
+    header('X-Pingback: ' . $linkbackEndpoint);
+    header('Link: <' . $linkbackEndpoint . '>; rel="webmention"');
+}
+
 render($template, $vars);
 ?>
diff --git a/www/www-header.php b/www/www-header.php
index 1b4a685..466870d 100644
--- a/www/www-header.php
+++ b/www/www-header.php
@@ -1,4 +1,5 @@
 <?php
+require __DIR__ . '/../data/config.php';
 require_once __DIR__ . '/../src/anoweco/autoload.php';
 
 \Twig_Autoloader::register();
-- 
2.30.2