From 9f0203af7c0d76c7666e74526637ba28ccd9d860 Mon Sep 17 00:00:00 2001 From: Joshua P Panter Date: Mon, 15 Jan 2018 16:35:33 -0500 Subject: [PATCH] update for pdo support --- wallabag_v2/init.php | 24 ++++++++++--------- wallabag_v2/wallabag_v2.js | 49 ++++++++++++++++++++------------------ 2 files changed, 39 insertions(+), 34 deletions(-) diff --git a/wallabag_v2/init.php b/wallabag_v2/init.php index 7acb8db..83d57fc 100644 --- a/wallabag_v2/init.php +++ b/wallabag_v2/init.php @@ -3,7 +3,7 @@ class Wallabag_v2 extends Plugin { private $host; function about() { - return array("1.0.2", + return array("1.0.4", "Post articles to a Wallabag v 2.x instance", "joshu@unfettered.net"); } @@ -95,22 +95,24 @@ class='tagsPic' style=\"cursor : pointer\" } function getwallabagInfo() { - $id = db_escape_string($_REQUEST['id']); + $id = $_REQUEST['id']; - $result = db_query("SELECT title, link - FROM ttrss_entries, ttrss_user_entries - WHERE id = '$id' AND ref_id = id AND owner_uid = " .$_SESSION['uid']); + $sth = $this->pdo->prepare("SELECT title, link + FROM ttrss_entries, ttrss_user_entries + WHERE id = ? AND ref_id = id AND owner_uid = ?"); + $sth->execute([$id, $_SESSION['uid']]); - if (db_num_rows($result) != 0) { - $title = truncate_string(strip_tags(db_fetch_result($result, 0, 'title')), - 100, '...'); - $article_link = db_fetch_result($result, 0, 'link'); + if ($row = $sth->fetch()) { + $title = truncate_string(strip_tags($row['title']), 100, '...'); + $article_link = $row['link']; } + + $wallabag_url = $this->host->get($this, "wallabag_url"); $wallabag_username = $this->host->get($this, "wallabag_username"); $wallabag_password = $this->host->get($this, "wallabag_password"); - $wallabag_client_id = $this->host->get($this, "wallabag_client_id"); - $wallabag_client_secret = $this->host->get($this, "wallabag_client_secret"); + $wallabag_client_id = $this->host->get($this, "wallabag_client_id"); + $wallabag_client_secret = $this->host->get($this, "wallabag_client_secret"); include 'oauth.php'; diff --git a/wallabag_v2/wallabag_v2.js b/wallabag_v2/wallabag_v2.js index 9582f8f..39a9561 100644 --- a/wallabag_v2/wallabag_v2.js +++ b/wallabag_v2/wallabag_v2.js @@ -1,28 +1,31 @@ function postArticleToWallabag(id) { try { - notify_progress("Saving to Wallabag …", true); - new Ajax.Request("backend.php", { - parameters: { - 'op': 'pluginhandler', - 'plugin': 'wallabag_v2', - 'method': 'getwallabagInfo', - 'id': param_escape(id) - }, - onSuccess: function(transport) { - var ti = JSON.parse(transport.responseText); - if (ti.wallabag_url && ti.wallabag_url.length && - ti.wallabag_username && ti.wallabag_username.length && - ti.wallabag_password && ti.wallabag_password.length && - ti.wallabag_client_id && ti.wallabag_client_id.length && - ti.wallabag_client_secret && ti.wallabag_client_secret.length) { - if (ti.status=="200") { - notify_info("Saved to Wallabag: " + ti.title + ""); - } else { - notify_error("Error saving to Wallabag!: ("+ti.status+")");} - } else { - notify_error("The Wallabag_v2 plugin needs to be configured. See the README for help", true);} - } }); + notify_progress("Saving to Wallabag …", true); + new Ajax.Request("backend.php", { + parameters: { + 'op': 'pluginhandler', + 'plugin': 'wallabag_v2', + 'method': 'getwallabagInfo', + 'id': param_escape(id) + }, + onSuccess: function(transport) { + var ti = JSON.parse(transport.responseText); + if (ti.wallabag_url && ti.wallabag_url.length && + ti.wallabag_username && ti.wallabag_username.length && + ti.wallabag_password && ti.wallabag_password.length && + ti.wallabag_client_id && ti.wallabag_client_id.length && + ti.wallabag_client_secret && ti.wallabag_client_secret.length) { + if (ti.status=="200") { + notify_info("Saved to Wallabag: " + ti.title + ""); + } else { + notify_error("Error saving to Wallabag!: ("+ti.status+")"); + } + } else { + notify_error("The Wallabag_v2 plugin needs to be configured. See the README for help", true); + } + } + }); } catch (e) { - exception_error("wallabagArticle", e); + exception_error("wallabagArticle", e); } }