summaryrefslogtreecommitdiff
path: root/classes/handler/public.php
diff options
context:
space:
mode:
Diffstat (limited to 'classes/handler/public.php')
-rwxr-xr-xclasses/handler/public.php64
1 files changed, 24 insertions, 40 deletions
diff --git a/classes/handler/public.php b/classes/handler/public.php
index 318cecd72..eb5363eab 100755
--- a/classes/handler/public.php
+++ b/classes/handler/public.php
@@ -75,7 +75,7 @@ class Handler_Public extends Handler {
$feed_self_url = get_self_url_prefix() .
"/public.php?op=rss&id=$feed&key=" .
- get_feed_access_key($feed, false, $owner_uid);
+ Feeds::get_feed_access_key($feed, false, $owner_uid);
if (!$feed_site_url) $feed_site_url = get_self_url_prefix();
@@ -298,23 +298,25 @@ class Handler_Public extends Handler {
function share() {
$uuid = clean($_REQUEST["key"]);
- $sth = $this->pdo->prepare("SELECT ref_id, owner_uid FROM ttrss_user_entries WHERE
- uuid = ?");
- $sth->execute([$uuid]);
+ if ($uuid) {
+ $sth = $this->pdo->prepare("SELECT ref_id, owner_uid
+ FROM ttrss_user_entries WHERE uuid = ?");
+ $sth->execute([$uuid]);
- if ($row = $sth->fetch()) {
- header("Content-Type: text/html");
+ if ($row = $sth->fetch()) {
+ header("Content-Type: text/html");
- $id = $row["ref_id"];
- $owner_uid = $row["owner_uid"];
+ $id = $row["ref_id"];
+ $owner_uid = $row["owner_uid"];
- print $this->format_article($id, $owner_uid);
+ print $this->format_article($id, $owner_uid);
- } else {
- header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
- print "Article not found.";
+ return;
+ }
}
+ header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
+ print "Article not found.";
}
private function get_article_image($enclosures, $content, $site_url) {
@@ -380,7 +382,7 @@ class Handler_Public extends Handler {
$line = $p->hook_render_article($line);
}
- $line['content'] = rewrite_cached_urls($line['content']);
+ $line['content'] = DiskCache::rewriteUrls($line['content']);
$enclosures = Article::get_article_enclosures($line["id"]);
@@ -728,18 +730,6 @@ class Handler_Public extends Handler {
}
}
- /* function subtest() {
- header("Content-type: text/plain; charset=utf-8");
-
- $url = clean($_REQUEST["url"]);
-
- print "$url\n\n";
-
-
- print_r(get_feeds_from_html($url, fetch_file_contents($url)));
-
- } */
-
function subscribe() {
if (SINGLE_USER_MODE) {
login_sequence();
@@ -1212,24 +1202,18 @@ class Handler_Public extends Handler {
}
function cached_url() {
- @$req_filename = basename($_GET['hash']);
-
- // we don't need an extension to find the file, hash is a complete URL
- $hash = preg_replace("/\.[^\.]*$/", "", $req_filename);
-
- if ($hash) {
-
- $filename = CACHE_DIR . '/images/' . $hash;
+ list ($cache_dir, $filename) = explode("/", $_GET["file"], 2);
- if (file_exists($filename)) {
- header("Content-Disposition: inline; filename=\"$req_filename\"");
+ // we do not allow files with extensions at the moment
+ $filename = str_replace(".", "", $filename);
- send_local_file($filename);
+ $cache = new DiskCache($cache_dir);
- } else {
- header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
- echo "File not found.";
- }
+ if ($cache->exists($filename)) {
+ $cache->send($filename);
+ } else {
+ header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
+ echo "File not found.";
}
}