summaryrefslogtreecommitdiff
path: root/classes/handler/public.php
diff options
context:
space:
mode:
Diffstat (limited to 'classes/handler/public.php')
-rwxr-xr-xclasses/handler/public.php52
1 files changed, 32 insertions, 20 deletions
diff --git a/classes/handler/public.php b/classes/handler/public.php
index 3fef4c2b9..190c806be 100755
--- a/classes/handler/public.php
+++ b/classes/handler/public.php
@@ -76,7 +76,7 @@ class Handler_Public extends Handler {
"/public.php?op=rss&id=$feed&key=" .
Feeds::_get_access_key($feed, false, $owner_uid);
- if (!$feed_site_url) $feed_site_url = get_self_url_prefix();
+ if (!$feed_site_url) $feed_site_url = Config::get_self_url();
if ($format == 'atom') {
$tpl = new Templator();
@@ -87,7 +87,7 @@ class Handler_Public extends Handler {
$tpl->setVariable('VERSION', Config::get_version(), true);
$tpl->setVariable('FEED_URL', htmlspecialchars($feed_self_url), true);
- $tpl->setVariable('SELF_URL', htmlspecialchars(get_self_url_prefix()), true);
+ $tpl->setVariable('SELF_URL', htmlspecialchars(Config::get_self_url()), true);
while ($line = $result->fetch()) {
$line["content_preview"] = Sanitizer::sanitize(truncate_string(strip_tags($line["content"]), 100, '...'));
@@ -128,13 +128,13 @@ class Handler_Public extends Handler {
$tpl->setVariable('ARTICLE_CONTENT', $content, true);
$tpl->setVariable('ARTICLE_UPDATED_ATOM',
- date('c', strtotime($line["updated"])), true);
+ date('c', strtotime($line["updated"] ?? '')), true);
$tpl->setVariable('ARTICLE_UPDATED_RFC822',
- date(DATE_RFC822, strtotime($line["updated"])), true);
+ date(DATE_RFC822, strtotime($line["updated"] ?? '')), true);
$tpl->setVariable('ARTICLE_AUTHOR', htmlspecialchars($line['author']), true);
- $tpl->setVariable('ARTICLE_SOURCE_LINK', htmlspecialchars($line['site_url'] ? $line["site_url"] : get_self_url_prefix()), true);
+ $tpl->setVariable('ARTICLE_SOURCE_LINK', htmlspecialchars($line['site_url'] ? $line["site_url"] : Config::get_self_url()), true);
$tpl->setVariable('ARTICLE_SOURCE_TITLE', htmlspecialchars($line['feed_title'] ?? $feed_title), true);
foreach ($line["tags"] as $tag) {
@@ -214,11 +214,16 @@ class Handler_Public extends Handler {
$article['title'] = $line['title'];
$article['excerpt'] = $line["content_preview"];
$article['content'] = Sanitizer::sanitize($line["content"], false, $owner_uid, $feed_site_url, null, $line["id"]);
- $article['updated'] = date('c', strtotime($line["updated"]));
+ $article['updated'] = date('c', strtotime($line["updated"] ?? ''));
if (!empty($line['note'])) $article['note'] = $line['note'];
if (!empty($line['author'])) $article['author'] = $line['author'];
+ $article['source'] = [
+ 'link' => $line['site_url'] ? $line["site_url"] : Config::get_self_url(),
+ 'title' => $line['feed_title'] ?? $feed_title
+ ];
+
if (count($line["tags"]) > 0) {
$article['tags'] = array();
@@ -312,7 +317,7 @@ class Handler_Public extends Handler {
$login, $user_id);
if (!$redirect_url)
- $redirect_url = get_self_url_prefix() . "/index.php";
+ $redirect_url = Config::get_self_url() . "/index.php";
header("Location: " . $redirect_url);
} else {
@@ -389,11 +394,7 @@ class Handler_Public extends Handler {
if (UserHelper::authenticate($login, $password)) {
$_POST["password"] = "";
- if (get_schema_version() >= 120) {
- $_SESSION["language"] = get_pref(Prefs::USER_LANGUAGE, $_SESSION["uid"]);
- }
-
- $_SESSION["ref_schema_version"] = get_schema_version();
+ $_SESSION["ref_schema_version"] = Config::get_schema_version();
$_SESSION["bw_limit"] = !!clean($_POST["bw_limit"] ?? false);
$_SESSION["safe_mode"] = $safe_mode;
@@ -412,13 +413,12 @@ class Handler_Public extends Handler {
if (session_status() != PHP_SESSION_ACTIVE)
session_start();
- if (!isset($_SESSION["login_error_msg"]))
- $_SESSION["login_error_msg"] = __("Incorrect username or password");
+ $_SESSION["login_error_msg"] ??= __("Incorrect username or password");
}
$return = clean($_REQUEST['return']);
- if ($_REQUEST['return'] && mb_strpos($return, Config::get(Config::SELF_URL_PATH)) === 0) {
+ if ($_REQUEST['return'] && mb_strpos($return, Config::get_self_url()) === 0) {
header("Location: " . clean($_REQUEST['return']));
} else {
header("Location: " . Config::get_self_url());
@@ -563,7 +563,7 @@ class Handler_Public extends Handler {
print_notice("Password reset instructions are being sent to your email address.");
$resetpass_token = sha1(get_random_bytes(128));
- $resetpass_link = get_self_url_prefix() . "/public.php?op=forgotpass&hash=" . $resetpass_token .
+ $resetpass_link = Config::get_self_url() . "/public.php?op=forgotpass&hash=" . $resetpass_token .
"&login=" . urlencode($login);
$tpl = new Templator();
@@ -572,7 +572,7 @@ class Handler_Public extends Handler {
$tpl->setVariable('LOGIN', $login);
$tpl->setVariable('RESETPASS_LINK', $resetpass_link);
- $tpl->setVariable('TTRSS_HOST', Config::get(Config::SELF_URL_PATH));
+ $tpl->setVariable('TTRSS_HOST', Config::get_self_url());
$tpl->addBlock('message');
@@ -759,7 +759,7 @@ class Handler_Public extends Handler {
// we do not allow files with extensions at the moment
$filename = str_replace(".", "", $filename);
- $cache = new DiskCache($cache_dir);
+ $cache = DiskCache::instance($cache_dir);
if ($cache->exists($filename)) {
$cache->send($filename);
@@ -769,6 +769,18 @@ class Handler_Public extends Handler {
}
}
+ function feed_icon() : void {
+ $id = (int)$_REQUEST['id'];
+ $cache = DiskCache::instance('feed-icons');
+
+ if ($cache->exists((string)$id)) {
+ $cache->send((string)$id);
+ } else {
+ header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
+ echo "File not found.";
+ }
+ }
+
private function _make_article_tag_uri(int $id, string $timestamp): string {
$timestamp = date("Y-m-d", strtotime($timestamp));
@@ -785,7 +797,7 @@ class Handler_Public extends Handler {
$plugin_name = basename(clean($_REQUEST["plugin"]));
$method = clean($_REQUEST["pmethod"]);
- $host->load($plugin_name, PluginHost::KIND_USER, 0);
+ $host->load($plugin_name, PluginHost::KIND_ALL, 0);
//$host->load_data();
$plugin = $host->get_plugin($plugin_name);
@@ -807,7 +819,7 @@ class Handler_Public extends Handler {
} else {
user_error("PluginHandler[PUBLIC]: Requested method '$method' of unknown plugin '$plugin_name'.", E_USER_WARNING);
header("Content-Type: text/json");
- print Errors::to_json(Errors::E_UNKNOWN_PLUGIN);
+ print Errors::to_json(Errors::E_UNKNOWN_PLUGIN, ['plugin' => $plugin_name]);
}
}