From 9bdc9f1b5a923f1fa341f5b574ec82ee097da7ef Mon Sep 17 00:00:00 2001 From: Adnan ELARAJI Date: Fri, 13 Dec 2024 17:22:52 +0100 Subject: [PATCH 1/5] Fix warnings on webmention endpoint. --- views/webmention_endpoint.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/views/webmention_endpoint.php b/views/webmention_endpoint.php index addbc60..3670c60 100644 --- a/views/webmention_endpoint.php +++ b/views/webmention_endpoint.php @@ -5,12 +5,13 @@ // Set path to your mentions twtxt file: //$logfile = './mentions.txt'; /* Make sure file is writeable */ +require_once("partials/base.php"); $logfile = $config['webmentions_txt_path']; if (!isset($_POST['source']) || !isset($_POST['target'])) { - print('Please send a propper webmention to this endpoint'); header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request'); + print('Please send a propper webmention to this endpoint'); exit; } From 7ac946e0a1280889d97fe982c303dcf775445f2e Mon Sep 17 00:00:00 2001 From: Adnan ELARAJI Date: Fri, 13 Dec 2024 17:42:10 +0100 Subject: [PATCH 2/5] switching to a parse_ini_file instead of requiring full the base.php file for defining $config. --- views/webmention_endpoint.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/webmention_endpoint.php b/views/webmention_endpoint.php index 3670c60..61da4ca 100644 --- a/views/webmention_endpoint.php +++ b/views/webmention_endpoint.php @@ -5,7 +5,7 @@ // Set path to your mentions twtxt file: //$logfile = './mentions.txt'; /* Make sure file is writeable */ -require_once("partials/base.php"); +$config = parse_ini_file('private/config.ini'); $logfile = $config['webmentions_txt_path']; From 69df3c2fdfade9f2ce65c879fcee04959868913d Mon Sep 17 00:00:00 2001 From: Adnan ELARAJI Date: Fri, 13 Dec 2024 18:22:09 +0100 Subject: [PATCH 3/5] Fix Warning in the `Webfinger lookup` input box on the Add `Feed page` --- partials/webfinger_lookup.php | 1 + 1 file changed, 1 insertion(+) diff --git a/partials/webfinger_lookup.php b/partials/webfinger_lookup.php index dd538e6..c407630 100644 --- a/partials/webfinger_lookup.php +++ b/partials/webfinger_lookup.php @@ -15,6 +15,7 @@ $wf_acct = ""; $wf_nick = ""; $wf_url = ""; $wf_error = ""; +$wf_request = ""; if(isset($_POST['submit'])) { $wf_request = $_POST["webfinger"]; From d3ce716e9a554392b267794fad8502dc98845d95 Mon Sep 17 00:00:00 2001 From: "eapl.mx" Date: Sat, 14 Dec 2024 14:34:54 -0600 Subject: [PATCH 4/5] fix(webmentions): call to undefined function getMentionsFromTwt() --- partials/webmentions_send.php | 9 +++--- views/new_twt.php | 59 +++++++++++++++-------------------- 2 files changed, 30 insertions(+), 38 deletions(-) diff --git a/partials/webmentions_send.php b/partials/webmentions_send.php index e09588f..ba8fa3b 100644 --- a/partials/webmentions_send.php +++ b/partials/webmentions_send.php @@ -1,7 +1,8 @@ No endpoint found in: ".$mention["url"]."

"; } else { - $new_twt_url = $public_txt_url."#:~:text=".$datetime; + $new_twt_url = $public_txt_url."#:~:text=".$datetime; //$target_url = $mention["url"]; $payload = "source=".$new_twt_url."&target=".$mention["url"]; //echo $payload; - + $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $targets_webmention_endpoint); curl_setopt($curl, CURLOPT_POST, TRUE); diff --git a/views/new_twt.php b/views/new_twt.php index a9562d2..f90980b 100644 --- a/views/new_twt.php +++ b/views/new_twt.php @@ -2,7 +2,6 @@ // TODO: Give a warning if the file is not found $config = parse_ini_file('private/config.ini'); - if ($config['debug_mode']) { ini_set('display_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']; $timezone = $config['timezone']; -require_once('libs/session.php'); - -// if (!has_valid_session()) { -// header('Location: /login.php'); -// exit(); -// } +require_once 'libs/session.php'; if (!isset($_SESSION['password'])) { header('Location: ./login'); exit(); } - if (isset($_POST['submit'])) { $new_post = filter_input(INPUT_POST, 'new_post'); $new_post = trim($new_post); @@ -53,7 +46,7 @@ if (isset($_POST['submit'])) { /*if (!date_default_timezone_set($timezone)) { 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')); //$twt = $datetime . "\t$new_post\n"; @@ -72,16 +65,16 @@ if (isset($_POST['submit'])) { // Fall back if the marker is not found. $contents .= $twt; }*/ - + // Append twt at the end of file $contents .= $twt; - + // TODO: Add error handling if write to the file fails // 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 - $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 + $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 // Send webmentions include_once 'partials/webmentions_send.php'; @@ -91,33 +84,31 @@ if (isset($_POST['submit'])) { //exit; } else { - require_once("partials/base.php"); + require_once "partials/base.php"; $title = "New post - ".$title; include_once 'partials/header.php'; + if (!isset($textareaValue)) { + $textareaValue = ''; + } -if (!isset($textareaValue)) { - $textareaValue = ''; -} + if (isset($_GET['hash'])) { + $hash = $_GET['hash']; + $textareaValue = "(#$hash) "; -if (isset($_GET['hash'])) { - $hash = $_GET['hash']; - $textareaValue = "(#$hash) "; + // COPY from conv.php + // TODO: make into a partial or global function + // 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 - // TODO: make into a partial or global function - // 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'; -} + //$textareaValue .= print_r($twts); + //$textareaValue .= $twts["nick"]; + include_once 'partials/timeline.php'; + } ?>
@@ -140,7 +131,7 @@ if (isset($_GET['hash'])) { element: "toolbar", editor: tinyMDE, commands: ['bold', 'italic', 'strikethrough', 'ul', 'ol', 'blockquote', 'code', '|', 'insertLink', 'insertImage'], - + }); From 79f43372f7735de709944be4de53e24779b4c7eb Mon Sep 17 00:00:00 2001 From: "eapl.mx" Date: Wed, 18 Dec 2024 16:45:05 -0600 Subject: [PATCH 5/5] feat(header): add base_url to logo link * Also made some cleanup and style fixing --- partials/base.php | 19 ++++++++----------- partials/header.php | 24 ++++++++++++------------ 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/partials/base.php b/partials/base.php index f6485d8..5e5fa93 100644 --- a/partials/base.php +++ b/partials/base.php @@ -1,5 +1,6 @@ mainURL] = $parsedTwtxtFile; } - } else { // Show timeline for the URL $parsedTwtxtFiles = []; foreach ($fileLines as $currentLine) { @@ -141,7 +138,7 @@ if (!empty($_GET['search'])) { $twts = array_filter($twts, function ($twt) use ($pattern) { return preg_match($pattern, $twt->content); }); -} +} */ // TODO: (re)move or rename `?hash=` to something/where else? diff --git a/partials/header.php b/partials/header.php index d5f514b..c5f03e9 100644 --- a/partials/header.php +++ b/partials/header.php @@ -1,9 +1,8 @@ - - @@ -12,8 +11,7 @@ $profile = getTwtsFromTwtxtString($config['public_txt_url']); - - + @@ -26,31 +24,33 @@ $profile = getTwtsFromTwtxtString($config['public_txt_url']);

- + - -

+ + --> +