diff options
author | Andrew Dolgov <[email protected]> | 2021-03-02 09:31:23 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2021-03-02 09:31:23 +0300 |
commit | 3bab5ca6b11db5c14c44e1a1b891de591f5efa73 (patch) | |
tree | 55d02c4936f4f3d94d9b53a8e9def7211744730f /classes | |
parent | f195e86be320f49e326293fe0b3077cfba87d548 (diff) |
article/redirect: use orm
Diffstat (limited to 'classes')
-rwxr-xr-x | classes/article.php | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/classes/article.php b/classes/article.php index a6a6efebb..4b4051d36 100755 --- a/classes/article.php +++ b/classes/article.php @@ -5,26 +5,23 @@ class Article extends Handler_Protected { const ARTICLE_KIND_YOUTUBE = 3; function redirect() { - $id = (int) clean($_REQUEST['id'] ?? 0); - - $sth = $this->pdo->prepare("SELECT link FROM ttrss_entries, ttrss_user_entries - WHERE id = ? AND id = ref_id AND owner_uid = ? - LIMIT 1"); - $sth->execute([$id, $_SESSION['uid']]); + $article = ORM::for_table('ttrss_entries') + ->table_alias('e') + ->join('ttrss_user_entries', [ 'ref_id', '=', 'e.id'], 'ue') + ->where('ue.owner_uid', $_SESSION['uid']) + ->find_one($_REQUEST['id']); - if ($row = $sth->fetch()) { - $article_url = UrlHelper::validate(str_replace("\n", "", $row['link'])); + if ($article) { + $article_url = UrlHelper::validate($article->link); if ($article_url) { header("Location: $article_url"); - } else { - header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found"); - print "URL of article $id is blank."; + return; } - - } else { - print_error(__("Article not found.")); } + + header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found"); + print "Article not found or has an empty URL."; } static function _create_published_article($title, $url, $content, $labels_str, |