mirror of
https://github.com/sorenpeter/timeline.git
synced 2025-12-15 10:57:01 +00:00
Webmention with support for twt-mentions
This commit is contained in:
parent
6c69dd89af
commit
4aa23baaa2
1 changed files with 23 additions and 1 deletions
|
|
@ -18,6 +18,27 @@ curl_close($ch);
|
||||||
$source = ob_get_contents();
|
$source = ob_get_contents();
|
||||||
ob_end_clean();
|
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 "@<nick url>"
|
||||||
|
|
||||||
|
return preg_match($pattern);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (str_contains($url, ".txt#")) {
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
if (stristr($source, $_POST['target'])) {
|
if (stristr($source, $_POST['target'])) {
|
||||||
header($_SERVER['SERVER_PROTOCOL'] . ' 202 Accepted');
|
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"
|
$log = date("Y-m-d\TH:i:s\Z") . "\t"
|
||||||
."Recived webmention from ".$_POST['source']
|
."Recived webmention from ".$_POST['source']
|
||||||
." mentioning ".$_POST['target']
|
." mentioning ".$_POST['target']
|
||||||
." (IP: ".$_SERVER['REMOTE_ADDR'].")".PHP_EOL;
|
//." (IP: ".$_SERVER['REMOTE_ADDR'].")"
|
||||||
|
.PHP_EOL;
|
||||||
file_put_contents($logfile, $log, FILE_APPEND);
|
file_put_contents($logfile, $log, FILE_APPEND);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue