From 4aa23baaa28ec87ee1357168bc981bf77dabc09a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?s=C3=B8renpeter?= Date: Mon, 27 Nov 2023 18:06:31 +0100 Subject: [PATCH] Webmention with support for twt-mentions --- views/webmention_endpoint.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/views/webmention_endpoint.php b/views/webmention_endpoint.php index 321324a..82dcea6 100644 --- a/views/webmention_endpoint.php +++ b/views/webmention_endpoint.php @@ -18,6 +18,27 @@ curl_close($ch); $source = ob_get_contents(); ob_end_clean(); +/* +function twtFromDate($url) { + // Split URL into fragment and file path, and retrurns twt maching date + $datetime = parse_url($url, PHP_URL_FRAGMENT); + $twtfile = strtok($url, "#"); + return preg_grep($datetime, file($twtfile)); +} + +function twtMentionInSource($url){ + // Tests if twt contains a mentions to target + $pattern = '/@<([^>]+)\s([^>]+)>/'; // Matches "@" + + return preg_match($pattern); +} + +if (str_contains($url, ".txt#")) { + +} +*/ + + if (stristr($source, $_POST['target'])) { header($_SERVER['SERVER_PROTOCOL'] . ' 202 Accepted'); @@ -28,7 +49,8 @@ $logfile = './mentions.txt'; /* Make sure file is writeable */ $log = date("Y-m-d\TH:i:s\Z") . "\t" ."Recived webmention from ".$_POST['source'] ." mentioning ".$_POST['target'] - ." (IP: ".$_SERVER['REMOTE_ADDR'].")".PHP_EOL; + //." (IP: ".$_SERVER['REMOTE_ADDR'].")" + .PHP_EOL; file_put_contents($logfile, $log, FILE_APPEND); }