This repository has been archived by the owner on Feb 20, 2021. It is now read-only.
forked from dasmurphy/tinytinyrss-fever-plugin
-
Notifications
You must be signed in to change notification settings - Fork 5
/
init.php
89 lines (68 loc) · 3.28 KB
/
init.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
class Fever extends Plugin
{
private $host;
public function about()
{
return array(2.3,
"Emulates the Fever API for Tiny Tiny RSS",
"DigitalDJ, mestrode, murphy, eric-pierce, HenryQW");
}
public function init($host)
{
$this->host = $host;
$host->add_hook($host::HOOK_PREFS_TAB, $this);
}
/* plugins/main/init.php hook_prefs_tab */
public function hook_prefs_tab($args)
{
if ($args != "prefPrefs") {
return;
}
print "<div dojoType=\"dijit.layout.AccordionPane\"
title=\"<i class='material-icons'>extension</i> ".__('Fever Emulation')."\">";
print "<h3>" . __("Fever Emulation") . "</h3>";
print "<p>" . __("Since the Fever API uses a different authentication mechanism to Tiny Tiny RSS, you must set a separate password to login. This password may be the same as your Tiny Tiny RSS password.") . "</p>";
print "<p>" . __("Set a password to login with Fever:") . "</p>";
print "<p><b>" . __("WARNING: The Fever API uses an UNSECURE unsalted MD5 hash. Consider the use of a disposable application-specific password and use HTTPS.") . "</b></p>";
print "<form dojoType=\"dijit.form.Form\">";
print "<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) {
Notify.msg(transport.responseText);
}
});
//this.reset();
}
</script>";
print_hidden("op", "pluginhandler");
print_hidden("method", "save");
print_hidden("plugin", "fever");
print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" type=\"password\" name=\"password\" />";
print_button("submit", __("Set Password"), "class='alt-primary'");
print "</form>";
print "<p>" . __("To login with the Fever API, set your server details in your favourite RSS application to: ") . get_self_url_prefix() . "/plugins/fever/" . "</p>";
print "<p>" . __("Additional details can be found at ") . "<a href=\"http://www.feedafever.com/api\" target=\"_blank\">https://feedafever.com/api</a></p>";
print "<p>" . __("Note: Due to the limitations of the API and some RSS clients (for example, Reeder on iOS), some features are unavailable: \"Special\" Feeds (Published / Tags / Labels / Fresh / Recent), Nested Categories (hierarchy is flattened)") . "</p>";
print "</div>";
}
public function save()
{
if (isset($_POST["password"]) && isset($_SESSION["uid"])) {
$sth = $this->pdo->prepare("SELECT login FROM ttrss_users WHERE id = ?");
$sth->execute([clean($_SESSION["uid"])]);
if ($line = $sth->fetch()) {
$password = md5($line["login"] . ":" . $_POST["password"]);
$this->host->set($this, "password", $password);
echo __("Password saved.");
}
}
}
public function api_version()
{
return 2;
}
}