mirror of
https://github.com/sorenpeter/timeline.git
synced 2026-03-11 12:42:17 +00:00
removed TODO about webmentions
This commit is contained in:
commit
e34e18b718
6 changed files with 52 additions and 61 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
# Shows the timeline for a user
|
# Shows the timeline for a user
|
||||||
|
|
||||||
declare (strict_types = 1);
|
declare (strict_types = 1);
|
||||||
|
|
||||||
# Parameters
|
# Parameters
|
||||||
|
|
@ -15,7 +16,6 @@ declare (strict_types = 1);
|
||||||
# If page is higher than N, shows nothing
|
# If page is higher than N, shows nothing
|
||||||
#
|
#
|
||||||
# hash(string) =
|
# hash(string) =
|
||||||
#
|
|
||||||
|
|
||||||
require_once('libs/session.php');
|
require_once('libs/session.php');
|
||||||
require_once('libs/twtxt.php');
|
require_once('libs/twtxt.php');
|
||||||
|
|
@ -36,13 +36,12 @@ if (isset($config['site_title'])) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// HACKED by sp@darch.dk
|
// HACKED by sp@darch.dk
|
||||||
if(!empty($_GET['list'])) {
|
if(!empty($_GET['list'])) {
|
||||||
$url = $baseURL.$_GET['list'];
|
$url = $baseURL.$_GET['list'];
|
||||||
//$url = "https://darch.dk/".$_GET['list'];
|
}
|
||||||
}
|
else {
|
||||||
else {
|
$url = $config['public_txt_url'];
|
||||||
$url = $config['public_txt_url'];
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if(isset($_GET['selectList'])){
|
if(isset($_GET['selectList'])){
|
||||||
|
|
@ -93,12 +92,10 @@ if (!empty($_GET['url'])) { // Show profile for some user
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!empty($twtsURL)) {
|
if (!empty($twtsURL)) {
|
||||||
|
|
||||||
$parsedTwtxtFile = getTwtsFromTwtxtString($twtsURL);
|
$parsedTwtxtFile = getTwtsFromTwtxtString($twtsURL);
|
||||||
if (!is_null($parsedTwtxtFile)) {
|
if (!is_null($parsedTwtxtFile)) {
|
||||||
$parsedTwtxtFiles[$parsedTwtxtFile->mainURL] = $parsedTwtxtFile;
|
$parsedTwtxtFiles[$parsedTwtxtFile->mainURL] = $parsedTwtxtFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else { // Show timeline for the URL
|
} else { // Show timeline for the URL
|
||||||
$parsedTwtxtFiles = [];
|
$parsedTwtxtFiles = [];
|
||||||
foreach ($fileLines as $currentLine) {
|
foreach ($fileLines as $currentLine) {
|
||||||
|
|
@ -141,7 +138,7 @@ if (!empty($_GET['search'])) {
|
||||||
$twts = array_filter($twts, function ($twt) use ($pattern) {
|
$twts = array_filter($twts, function ($twt) use ($pattern) {
|
||||||
return preg_match($pattern, $twt->content);
|
return preg_match($pattern, $twt->content);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// TODO: (re)move or rename `?hash=` to something/where else?
|
// TODO: (re)move or rename `?hash=` to something/where else?
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$profile = getTwtsFromTwtxtString($config['public_txt_url']);
|
$profile = getTwtsFromTwtxtString($config['public_txt_url']);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
|
@ -12,8 +11,7 @@ $profile = getTwtsFromTwtxtString($config['public_txt_url']);
|
||||||
<link rel="icon" type="image/x-icon" href="<?= $baseURL ?>/media/logo.png">
|
<link rel="icon" type="image/x-icon" href="<?= $baseURL ?>/media/logo.png">
|
||||||
<?php if( isset($_SESSION['password'])) { ?>
|
<?php if( isset($_SESSION['password'])) { ?>
|
||||||
<script src="<?= $baseURL ?>/libs/tiny-mde.min.js"></script>
|
<script src="<?= $baseURL ?>/libs/tiny-mde.min.js"></script>
|
||||||
<!-- <link rel="stylesheet" type="text/css" href="<?= $baseURL ?>/libs/tiny-mde.min.css" /> -->
|
<link rel="stylesheet" type="text/css" href="<?= $baseURL ?>/libs/tiny-mde.css" />
|
||||||
<link rel="stylesheet" type="text/css" href="<?= $baseURL ?>/libs/tiny-mde.css" />
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<link rel="stylesheet" type="text/css" href="<?= $baseURL ?>/libs/simple.css">
|
<link rel="stylesheet" type="text/css" href="<?= $baseURL ?>/libs/simple.css">
|
||||||
<link rel="stylesheet" type="text/css" href="<?= $baseURL ?>/libs/timeline.css">
|
<link rel="stylesheet" type="text/css" href="<?= $baseURL ?>/libs/timeline.css">
|
||||||
|
|
@ -26,31 +24,33 @@ $profile = getTwtsFromTwtxtString($config['public_txt_url']);
|
||||||
|
|
||||||
<header>
|
<header>
|
||||||
<p>
|
<p>
|
||||||
<a href="/">
|
<a href="<?= $baseURL ?>">
|
||||||
<img class="logo" src="<?= $baseURL ?>/media/logo.png">
|
<img class="logo" src="<?= $baseURL ?>/media/logo.png">
|
||||||
<?= $config['site_title']; ?>
|
<?= $config['site_title']; ?>
|
||||||
</a>
|
</a>
|
||||||
<!-- <a href="/">
|
<!--
|
||||||
|
<a href="/">
|
||||||
<img class="logo" src="<?= $profile->avatar ?>" alt="" loading="lazy">
|
<img class="logo" src="<?= $profile->avatar ?>" alt="" loading="lazy">
|
||||||
<?= parse_url($profile->mainURL, PHP_URL_HOST); ?>
|
<?= parse_url($profile->mainURL, PHP_URL_HOST); ?>
|
||||||
</a>
|
</a>
|
||||||
<a href="/">
|
<a href="/">
|
||||||
<img class="logo" src="<?= $profile->avatar ?>" alt="" loading="lazy">
|
<img class="logo" src="<?= $profile->avatar ?>" alt="" loading="lazy">
|
||||||
<?= $profile->nick ?>@<?= parse_url($profile->mainURL, PHP_URL_HOST); ?>
|
<?= $profile->nick ?>@<?= parse_url($profile->mainURL, PHP_URL_HOST); ?>
|
||||||
</a> -->
|
</a>
|
||||||
</p>
|
-->
|
||||||
|
</p>
|
||||||
<nav>
|
<nav>
|
||||||
|
|
||||||
<ul class="secondary">
|
<ul class="secondary">
|
||||||
<?php //if ($validSession) { // TODO: Make login seqcure ?>
|
<?php //if ($validSession) { // TODO: Make login secure ?>
|
||||||
<?php if( isset($_SESSION['password'])) { /*
|
<?php if( isset($_SESSION['password'])) { /*
|
||||||
if($_SESSION['password']=="$password") {*/ // Hacky login ?>
|
if($_SESSION['password']=="$password") {*/ // Hacky login ?>
|
||||||
<li><a href="<?= $baseURL ?>/refresh?url=<?= $url ?>"><i class="fa fa-refresh"></i><span>Refresh</span></a></li>
|
<li><a href="<?= $baseURL ?>/refresh?url=<?= $url ?>"><i class="fa fa-refresh"></i><span>Refresh</span></a></li>
|
||||||
<li><a href="<?= $baseURL ?>"><i class="fa fa-comments-o"></i><span>Timeline</span></a></li>
|
<li><a href="<?= $baseURL ?>"><i class="fa fa-comments-o"></i><span>Timeline</span></a></li>
|
||||||
<?php if (!empty($config['public_webmentions'])) { ?>
|
<?php if (!empty($config['public_webmentions'])) { ?>
|
||||||
<li><a href="<?= $baseURL ?>/profile?url=<?= $config['public_webmentions'] ?>"><i class="fa fa-at"></i><span>Mentions</span></a></li>
|
<li><a href="<?= $baseURL ?>/profile?url=<?= $config['public_webmentions'] ?>"><i class="fa fa-at"></i><span>Mentions</span></a></li>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<li><a href="<?= $baseURL ?>/profile"><i class="fa fa-user-circle"></i><span>Profile</span></a></li>
|
<li><a href="<?= $baseURL ?>/profile"><i class="fa fa-user-circle"></i><span>Profile</span></a></li>
|
||||||
<li><a href="<?= $baseURL ?>/gallery?url=<?= $config['public_txt_url'] ?>"><i class="fa fa-picture-o"></i><span>Gallery</span></a></li>
|
<li><a href="<?= $baseURL ?>/gallery?url=<?= $config['public_txt_url'] ?>"><i class="fa fa-picture-o"></i><span>Gallery</span></a></li>
|
||||||
<li><a href="<?= $baseURL ?>/following"><i class="fa fa-users"></i><span>Following <?php // echo count($twtFollowingList); ?></span></a></li>
|
<li><a href="<?= $baseURL ?>/following"><i class="fa fa-users"></i><span>Following <?php // echo count($twtFollowingList); ?></span></a></li>
|
||||||
<li><a href="<?= $baseURL ?>/add"><i class="fa fa-user-plus"></i><span>Add feed</span></a></li>
|
<li><a href="<?= $baseURL ?>/add"><i class="fa fa-user-plus"></i><span>Add feed</span></a></li>
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ $wf_acct = "";
|
||||||
$wf_nick = "";
|
$wf_nick = "";
|
||||||
$wf_url = "";
|
$wf_url = "";
|
||||||
$wf_error = "";
|
$wf_error = "";
|
||||||
|
$wf_request = "";
|
||||||
|
|
||||||
if(isset($_POST['submit'])) {
|
if(isset($_POST['submit'])) {
|
||||||
$wf_request = $_POST["webfinger"];
|
$wf_request = $_POST["webfinger"];
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
require_once "libs/twtxt.php";
|
||||||
|
|
||||||
// Send webmentions
|
// Send webmentions
|
||||||
$new_mentions = getMentionsFromTwt($twt);
|
$new_mentions = getMentionsFromTwt($twt);
|
||||||
|
|
@ -9,17 +10,17 @@ foreach ($new_mentions as $mention) {
|
||||||
|
|
||||||
// Detect webmention endpoint define in twtxt.txt as `# webmention = URL`
|
// Detect webmention endpoint define in twtxt.txt as `# webmention = URL`
|
||||||
$targets_webmention_endpoint = getSingleParameter("webmention", file_get_contents($mention["url"]));
|
$targets_webmention_endpoint = getSingleParameter("webmention", file_get_contents($mention["url"]));
|
||||||
|
|
||||||
if (!isset($targets_webmention_endpoint)) {
|
if (!isset($targets_webmention_endpoint)) {
|
||||||
echo "<p class='notice'>No endpoint found in: ".$mention["url"]."</p>";
|
echo "<p class='notice'>No endpoint found in: ".$mention["url"]."</p>";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$new_twt_url = $public_txt_url."#:~:text=".$datetime;
|
$new_twt_url = $public_txt_url."#:~:text=".$datetime;
|
||||||
//$target_url = $mention["url"];
|
//$target_url = $mention["url"];
|
||||||
$payload = "source=".$new_twt_url."&target=".$mention["url"];
|
$payload = "source=".$new_twt_url."&target=".$mention["url"];
|
||||||
//echo $payload;
|
//echo $payload;
|
||||||
|
|
||||||
$curl = curl_init();
|
$curl = curl_init();
|
||||||
curl_setopt($curl, CURLOPT_URL, $targets_webmention_endpoint);
|
curl_setopt($curl, CURLOPT_URL, $targets_webmention_endpoint);
|
||||||
curl_setopt($curl, CURLOPT_POST, TRUE);
|
curl_setopt($curl, CURLOPT_POST, TRUE);
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
// TODO: Give a warning if the file is not found
|
// TODO: Give a warning if the file is not found
|
||||||
$config = parse_ini_file('private/config.ini');
|
$config = parse_ini_file('private/config.ini');
|
||||||
|
|
||||||
|
|
||||||
if ($config['debug_mode']) {
|
if ($config['debug_mode']) {
|
||||||
ini_set('display_errors', 1);
|
ini_set('display_errors', 1);
|
||||||
ini_set('display_startup_errors', 1);
|
ini_set('display_startup_errors', 1);
|
||||||
|
|
@ -13,19 +12,13 @@ $txt_file_path = $config['txt_file_path'];
|
||||||
$public_txt_url = $config['public_txt_url'];
|
$public_txt_url = $config['public_txt_url'];
|
||||||
$timezone = $config['timezone'];
|
$timezone = $config['timezone'];
|
||||||
|
|
||||||
require_once('libs/session.php');
|
require_once 'libs/session.php';
|
||||||
|
|
||||||
// if (!has_valid_session()) {
|
|
||||||
// header('Location: /login.php');
|
|
||||||
// exit();
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (!isset($_SESSION['password'])) {
|
if (!isset($_SESSION['password'])) {
|
||||||
header('Location: ./login');
|
header('Location: ./login');
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (isset($_POST['submit'])) {
|
if (isset($_POST['submit'])) {
|
||||||
$new_post = filter_input(INPUT_POST, 'new_post');
|
$new_post = filter_input(INPUT_POST, 'new_post');
|
||||||
$new_post = trim($new_post);
|
$new_post = trim($new_post);
|
||||||
|
|
@ -53,7 +46,7 @@ if (isset($_POST['submit'])) {
|
||||||
|
|
||||||
/*if (!date_default_timezone_set($timezone)) {
|
/*if (!date_default_timezone_set($timezone)) {
|
||||||
date_default_timezone_set('UTC');
|
date_default_timezone_set('UTC');
|
||||||
}*/ // Turned this off, so now the server need to have set the right timezone, seem to work for CET
|
}*/ // Turned this off, so now the server need to have set the right timezone, seem to work for CET
|
||||||
|
|
||||||
//$datetime = gmdate('Y-m-d\TH:i:s\Z', $date->format('U'));
|
//$datetime = gmdate('Y-m-d\TH:i:s\Z', $date->format('U'));
|
||||||
//$twt = $datetime . "\t$new_post\n";
|
//$twt = $datetime . "\t$new_post\n";
|
||||||
|
|
@ -72,16 +65,16 @@ if (isset($_POST['submit'])) {
|
||||||
// Fall back if the marker is not found.
|
// Fall back if the marker is not found.
|
||||||
$contents .= $twt;
|
$contents .= $twt;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
// Append twt at the end of file
|
// Append twt at the end of file
|
||||||
$contents .= $twt;
|
$contents .= $twt;
|
||||||
|
|
||||||
// TODO: Add error handling if write to the file fails
|
// TODO: Add error handling if write to the file fails
|
||||||
// For example due to permissions problems
|
// For example due to permissions problems
|
||||||
// https://www.w3docs.com/snippets/php/how-can-i-handle-the-warning-of-file-get-contents-function-in-php.html
|
// https://www.w3docs.com/snippets/php/how-can-i-handle-the-warning-of-file-get-contents-function-in-php.html
|
||||||
|
|
||||||
$file_write_result = file_put_contents($txt_file_path, $contents);
|
$file_write_result = file_put_contents($txt_file_path, $contents);
|
||||||
// TODO: replace with file_put_contents($logfile, $log, FILE_APPEND) -- https://www.w3schools.com/php/func_filesystem_file_put_contents.asp
|
// TODO: replace with file_put_contents($logfile, $log, FILE_APPEND) -- https://www.w3schools.com/php/func_filesystem_file_put_contents.asp
|
||||||
|
|
||||||
// Send webmentions
|
// Send webmentions
|
||||||
include_once 'partials/webmentions_send.php';
|
include_once 'partials/webmentions_send.php';
|
||||||
|
|
@ -91,33 +84,31 @@ if (isset($_POST['submit'])) {
|
||||||
//exit;
|
//exit;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
require_once("partials/base.php");
|
require_once "partials/base.php";
|
||||||
$title = "New post - ".$title;
|
$title = "New post - ".$title;
|
||||||
include_once 'partials/header.php';
|
include_once 'partials/header.php';
|
||||||
|
|
||||||
|
if (!isset($textareaValue)) {
|
||||||
|
$textareaValue = '';
|
||||||
|
}
|
||||||
|
|
||||||
if (!isset($textareaValue)) {
|
if (isset($_GET['hash'])) {
|
||||||
$textareaValue = '';
|
$hash = $_GET['hash'];
|
||||||
}
|
$textareaValue = "(#$hash) ";
|
||||||
|
|
||||||
if (isset($_GET['hash'])) {
|
// COPY from conv.php
|
||||||
$hash = $_GET['hash'];
|
// TODO: make into a partial or global function
|
||||||
$textareaValue = "(#$hash) ";
|
// Get the hashes (both post and replies) as $hash from the router and return an inverted list
|
||||||
|
$twt_op = array_filter($twts, function($twt) use ($hash) {
|
||||||
|
return $twt->hash === $hash; //|| $twt->replyToHash === $hash;
|
||||||
|
});
|
||||||
|
//$twts = array_reverse($twts, true);
|
||||||
|
|
||||||
// COPY from conv.php
|
//$textareaValue .= print_r($twts);
|
||||||
// TODO: make into a partial or global function
|
//$textareaValue .= $twts["nick"];
|
||||||
// Get the hashes (both post and replies) as $hash from the router and return an inverted list
|
|
||||||
$twt_op = array_filter($twts, function($twt) use ($hash) {
|
|
||||||
return $twt->hash === $hash; //|| $twt->replyToHash === $hash;
|
|
||||||
});
|
|
||||||
//$twts = array_reverse($twts, true);
|
|
||||||
|
|
||||||
//$textareaValue .= print_r($twts);
|
|
||||||
//$textareaValue .= $twts["nick"];
|
|
||||||
|
|
||||||
include_once 'partials/timeline.php';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
include_once 'partials/timeline.php';
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<article id="new_twt">
|
<article id="new_twt">
|
||||||
|
|
@ -140,7 +131,7 @@ if (isset($_GET['hash'])) {
|
||||||
element: "toolbar",
|
element: "toolbar",
|
||||||
editor: tinyMDE,
|
editor: tinyMDE,
|
||||||
commands: ['bold', 'italic', 'strikethrough', 'ul', 'ol', 'blockquote', 'code', '|', 'insertLink', 'insertImage'],
|
commands: ['bold', 'italic', 'strikethrough', 'ul', 'ol', 'blockquote', 'code', '|', 'insertLink', 'insertImage'],
|
||||||
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,13 @@
|
||||||
|
|
||||||
// Set path to your mentions twtxt file:
|
// Set path to your mentions twtxt file:
|
||||||
//$logfile = './mentions.txt'; /* Make sure file is writeable */
|
//$logfile = './mentions.txt'; /* Make sure file is writeable */
|
||||||
|
$config = parse_ini_file('private/config.ini');
|
||||||
$logfile = $config['webmentions_txt_path'];
|
$logfile = $config['webmentions_txt_path'];
|
||||||
|
|
||||||
|
|
||||||
if (!isset($_POST['source']) || !isset($_POST['target'])) {
|
if (!isset($_POST['source']) || !isset($_POST['target'])) {
|
||||||
print('Please send a propper webmention to this endpoint');
|
|
||||||
header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request');
|
header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request');
|
||||||
|
print('Please send a propper webmention to this endpoint');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue