tt-rss/classes/article.php

70 lines
1.8 KiB
PHP
Raw Normal View History

2011-12-12 21:20:53 +01:00
<?php
2011-12-13 11:15:42 +01:00
class Article extends Protected_Handler {
2011-12-13 07:58:30 +01:00
2011-12-26 09:02:52 +01:00
function csrf_ignore($method) {
$csrf_ignored = array("redirect");
return array_search($method, $csrf_ignored) !== false;
}
2011-12-13 07:58:30 +01:00
function redirect() {
2011-12-12 21:20:53 +01:00
$id = db_escape_string($_REQUEST['id']);
2011-12-13 07:58:30 +01:00
2011-12-12 21:20:53 +01:00
$result = db_query($this->link, "SELECT link FROM ttrss_entries, ttrss_user_entries
WHERE id = '$id' AND id = ref_id AND owner_uid = '".$_SESSION['uid']."'
LIMIT 1");
2011-12-13 07:58:30 +01:00
2011-12-12 21:20:53 +01:00
if (db_num_rows($result) == 1) {
$article_url = db_fetch_result($result, 0, 'link');
$article_url = str_replace("\n", "", $article_url);
2011-12-13 07:58:30 +01:00
2011-12-12 21:20:53 +01:00
header("Location: $article_url");
return;
2011-12-13 07:58:30 +01:00
2011-12-12 21:20:53 +01:00
} else {
print_error(__("Article not found."));
}
}
function view() {
$id = db_escape_string($_REQUEST["id"]);
$cids = explode(",", db_escape_string($_REQUEST["cids"]));
$mode = db_escape_string($_REQUEST["mode"]);
$omode = db_escape_string($_REQUEST["omode"]);
2011-12-13 07:58:30 +01:00
2011-12-12 21:20:53 +01:00
// in prefetch mode we only output requested cids, main article
// just gets marked as read (it already exists in client cache)
2011-12-13 07:58:30 +01:00
2011-12-12 21:20:53 +01:00
$articles = array();
2011-12-13 07:58:30 +01:00
2011-12-12 21:20:53 +01:00
if ($mode == "") {
array_push($articles, format_article($this->link, $id, false));
} else if ($mode == "zoom") {
array_push($articles, format_article($this->link, $id, true, true));
} else if ($mode == "raw") {
if ($_REQUEST['html']) {
header("Content-Type: text/html");
print '<link rel="stylesheet" type="text/css" href="tt-rss.css"/>';
}
2011-12-13 07:58:30 +01:00
2011-12-12 21:20:53 +01:00
$article = format_article($this->link, $id, false);
print $article['content'];
return;
}
2011-12-13 07:58:30 +01:00
2011-12-12 21:20:53 +01:00
catchupArticleById($this->link, $id, 0);
2011-12-13 07:58:30 +01:00
2011-12-12 21:20:53 +01:00
if (!$_SESSION["bw_limit"]) {
foreach ($cids as $cid) {
if ($cid) {
array_push($articles, format_article($this->link, $cid, false, false));
}
}
}
2011-12-13 07:58:30 +01:00
2011-12-12 21:20:53 +01:00
print json_encode($articles);
2011-12-13 07:58:30 +01:00
2011-12-12 21:20:53 +01:00
}
2011-12-13 07:58:30 +01:00
}