'FRCSESSION', 'use_strict_mode' => true, 'cookie_httponly' => true, 'cookie_samesite' => 'Strict']); /** * Add a message to be displayed at the top of the page * * @param string $level The level (type) of the message * @param string $message The message itself */ function add_message(string $level, string $message): void { if (!array_key_exists(Key::USER_MSG, $_SESSION)) $_SESSION[Key::USER_MSG] = array(); $_SESSION[Key::USER_MSG][] = ['level' => $level, 'message' => $message]; } /** * Add an error message to be displayed at the top of the page * * @param string $message The message to be displayed */ function add_error(string $message): void { add_message('ERROR', $message); } /** * Add an error message to be displayed at the top of the page * * @param string $message The message to be displayed */ function add_info(string $message): void { add_message('INFO', $message); } /** @var bool $is_htmx True if this request was initiated by htmx, false if not */ $is_htmx = array_key_exists('HTTP_HX_REQUEST', $_SERVER) && !array_key_exists('HTTP_HX_HISTORY_RESTORE_REQUEST', $_SERVER); /** * Render the title bar for the page */ function title_bar(): void { $version = match (true) { str_ends_with(FRC_VERSION, '.0.0') => substr(FRC_VERSION, 0, strlen(FRC_VERSION) - 4), str_ends_with(FRC_VERSION, '.0') => substr(FRC_VERSION, 0, strlen(FRC_VERSION) - 2), default => FRC_VERSION }; ?>
Feed Reader Centralv
prepare(<<<'SQL' SELECT EXISTS( SELECT 1 FROM item INNER JOIN feed ON item.feed_id = feed.id WHERE feed.user_id = :id AND item.is_bookmarked = 1) SQL); $bookQuery->bindValue(':id', $_SESSION[Key::USER_ID]); $bookResult = $bookQuery->execute(); $hasBookmarks = $bookResult ? $bookResult->fetchArray(SQLITE3_NUM)[0] : false; ?> | | Log Off | close(); } } else { ?> |
<?=$title?> | Feed Reader Central 0) { ?>
{$msg['level']}
"?>
format(DATE_TIME_FORMAT); } catch (Exception) { return '(invalid date)'; } } /** * Create an anchor tag with both `href` and `hx-get` attributes * * @param string $url The URL to which navigation should occur * @param string $text The text for the link * @param string $extraAttrs Extra attributes for the anchor tag (must be attribute-encoded) * @return string The anchor tag with both `href` and `hx-get` attributes */ function hx_get(string $url, string $text, string $extraAttrs = ''): string { $attrs = $extraAttrs != '' ? " $extraAttrs" : ''; return "$text"; } /** * Return a 404 Not Found */ #[NoReturn] function not_found(): void { http_response_code(404); die('Not Found'); }