twtxt.txt file does not exist. Check your config.ini
");
$contents = file_get_contents($txt_file_path);
/*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
//$datetime = gmdate('Y-m-d\TH:i:s\Z', $date->format('U'));
//$twt = $datetime . "\t$new_post\n";
//$twt = date('c') . "\t$new_post\n";
$datetime = date('Y-m-d\TH:i:sp'); // abracting to be used for webmentions
$twt = "\n$datetime\t$new_post"; // NB: only works with PHP 8
// TODO: Delete?
/*if (strpos($contents, NEW_TWT_MARKER) !== false) {
// Add the previous marker
// Take note that doesn't not work if twtxt file has CRLF line ending
// (which is wrong anyway)
$twt = NEW_TWT_MARKER . $twt;
$contents = str_replace(NEW_TWT_MARKER, $twt, $contents);
} else {
// 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
// Send webmentions
include_once 'partials/webmentions_send.php';
//header('Refresh:0; url=.');
//header("Location: refresh?url=".$public_txt_url); // Trying to fix issue with douple posting
//exit;
//$_SESSION["message"] = $msg;
header('Location: '.$_SERVER['QUERY_STRING']);
exit;
} else {
require_once "partials/base.php";
$title = "New post - $title";
include_once 'partials/header.php';
$textareaValue = $textareaValue ?? '';
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);
//$textareaValue .= print_r($twts);
//$textareaValue .= $twts["nick"];
include_once 'partials/timeline.php';
}
?>