Skip to content

Commit

Permalink
update for pdo support
Browse files Browse the repository at this point in the history
  • Loading branch information
joshp23 committed Jan 15, 2018
1 parent 11811e1 commit 9f0203a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 34 deletions.
24 changes: 13 additions & 11 deletions wallabag_v2/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down Expand Up @@ -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';

Expand Down
49 changes: 26 additions & 23 deletions wallabag_v2/wallabag_v2.js
Original file line number Diff line number Diff line change
@@ -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: <em>" + ti.title + "</em>");
} else {
notify_error("<strong>Error saving to Wallabag!</strong>: ("+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: <em>" + ti.title + "</em>");
} else {
notify_error("<strong>Error saving to Wallabag!</strong>: ("+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);
}
}

0 comments on commit 9f0203a

Please sign in to comment.