Got a bunch of issues trying to use this on ttrss from six months ago (324aef9f6f80e7d1b34f1af2487ab03eebc66f47)
diff --git a/init.php b/init.php
index 7f911c1..ae66293 100644
--- a/init.php
+++ b/init.php
@@ -22,7 +22,7 @@ class af_refspoof extends Plugin {
require_once ("PhCURL.php");
$this->host = $host;
- $this->dbh = Db::get();
+ $this->dbh = Db::pdo();
$host->add_hook($host::HOOK_RENDER_ARTICLE_CDM, $this);
$host->add_hook($host::HOOK_PREFS_TAB, $this);
}
@@ -54,14 +54,9 @@ EOF;
<script type="dojo/method" event="onSubmit" args="evt">
evt.preventDefault();
if (this.validate()) {
- new Ajax.Request('backend.php', {
- parameters: dojo.objectToQuery(this.getValues()),
- onComplete: function(transport) {
- if (transport.responseText.indexOf('error')>=0)
- notify_error(transport.responseText);
- else notify_info(transport.responseText);
- }
- });
+ xhr.post("backend.php", this.getValues(), (reply) => {
+ Notify.info(reply);
+ })
}
</script>
<table>
@@ -118,7 +113,9 @@ EOF;
$entry->setAttribute("srcset", $srcSet);
}
- $url = $backendURL . '&url=' . urlencode($origSrc) . '&ref=' . urlencode($article['link']);
+ //$url = $backendURL . '&url=' . urlencode($origSrc) . '&ref=' . urlencode($article['link']);
+ //TODO: this might be unnecessary
+ $url = $_SERVER['REQUEST_SCHEME'] . "://" . $_SERVER['SERVER_NAME'] . "/" . $backendURL . '&url=' . urlencode($origSrc) . '&ref=' . urlencode($article['link']);
$entry->setAttribute("src",$url);
}
$article["content"] = $doc->saveXML();
@@ -157,11 +154,13 @@ EOF;
protected function getFeeds()
{
$feeds = array();
- $result = $this->dbh->query("SELECT id, title
+ $stmt = $this->dbh->prepare("SELECT id, title
FROM ttrss_feeds
- WHERE owner_uid = ".$_SESSION["uid"].
- " ORDER BY order_id, title");
- while ($line = $this->dbh->fetch_assoc($result)) {
+ WHERE owner_uid = :sessionID
+ ORDER BY order_id, title");
+ $stmt->execute(['sessionID' => $_SESSION["uid"]]);
+ $result = $stmt->fetch();
+ while ($line = $stmt->fetch(PDO::FETCH_ASSOC)) {
$feeds[] = (object) $line;
}
return $feeds;
But now I just get a CSRF error when calling the redirect, and I ran out of time to poke at it today.
I'll keep this issue updated with any progress I may make next time I try to get this working.