Take back my plugin - fix a bunch of bugs which counters not updating,
clean things up, sync back with ttrss source
This commit is contained in:
1774
fever/fever_api.php
1774
fever/fever_api.php
File diff suppressed because it is too large
Load Diff
@@ -1,59 +1,67 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// do not support refresh command, this could take ages.
|
// do not support refresh command, this could take ages.
|
||||||
if (isset($_REQUEST["refresh"]))
|
if (isset($_REQUEST["refresh"]))
|
||||||
{
|
{
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
error_reporting(E_ERROR | E_PARSE);
|
/* api/index.php */
|
||||||
|
error_reporting(E_ERROR | E_PARSE);
|
||||||
|
|
||||||
$tt_root = dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME'])));
|
require_once "../../config.php";
|
||||||
$tt_root2 = $tt_root;
|
|
||||||
if (file_exists($tt_root."/config.php")) {
|
|
||||||
require_once $tt_root."/config.php";
|
|
||||||
} else { //if (file_exists("../../config.php")) {
|
|
||||||
$tt_root = "../..";
|
|
||||||
$tt_root2 = dirname(dirname(dirname(__FILE__)));
|
|
||||||
require_once $tt_root."/config.php";
|
|
||||||
}
|
|
||||||
|
|
||||||
set_include_path(dirname(__FILE__) . PATH_SEPARATOR .
|
set_include_path(dirname(__FILE__) . PATH_SEPARATOR .
|
||||||
$tt_root2 . PATH_SEPARATOR .
|
dirname(dirname(dirname(__FILE__))) . PATH_SEPARATOR .
|
||||||
$tt_root2 . "/include" . PATH_SEPARATOR .
|
dirname(dirname(dirname(__FILE__))) . "/include" . PATH_SEPARATOR .
|
||||||
get_include_path());
|
get_include_path());
|
||||||
|
|
||||||
chdir($tt_root);
|
chdir("../..");
|
||||||
|
|
||||||
define('NO_SESSION_AUTOSTART', true);
|
define('TTRSS_SESSION_NAME', 'ttrss_api_sid');
|
||||||
|
define('NO_SESSION_AUTOSTART', true);
|
||||||
|
|
||||||
require_once "autoload.php";
|
require_once "autoload.php";
|
||||||
require_once "db.php";
|
require_once "db.php";
|
||||||
require_once "db-prefs.php";
|
require_once "db-prefs.php";
|
||||||
require_once "functions.php";
|
require_once "functions.php";
|
||||||
require_once "fever_api.php";
|
require_once "sessions.php";
|
||||||
|
|
||||||
define('AUTH_DISABLE_OTP', true);
|
require_once "fever_api.php";
|
||||||
|
|
||||||
if (defined('ENABLE_GZIP_OUTPUT') && ENABLE_GZIP_OUTPUT &&
|
ini_set("session.gc_maxlifetime", 86400);
|
||||||
function_exists("ob_gzhandler")) {
|
|
||||||
|
|
||||||
ob_start("ob_gzhandler");
|
define('AUTH_DISABLE_OTP', true);
|
||||||
} else {
|
|
||||||
ob_start();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!init_plugins()) return;
|
if (defined('ENABLE_GZIP_OUTPUT') && ENABLE_GZIP_OUTPUT &&
|
||||||
|
function_exists("ob_gzhandler")) {
|
||||||
|
|
||||||
$handler = new FeverAPI(Db::get(), $_REQUEST);
|
ob_start("ob_gzhandler");
|
||||||
|
} else {
|
||||||
|
ob_start();
|
||||||
|
}
|
||||||
|
|
||||||
if ($handler->before($method)) {
|
if ($_REQUEST["sid"]) {
|
||||||
if (method_exists($handler, 'index')) {
|
session_id($_REQUEST["sid"]);
|
||||||
$handler->index($method);
|
@session_start();
|
||||||
}
|
} else if (defined('_API_DEBUG_HTTP_ENABLED')) {
|
||||||
$handler->after();
|
@session_start();
|
||||||
}
|
}
|
||||||
|
|
||||||
ob_end_flush();
|
startup_gettext();
|
||||||
|
|
||||||
|
if (!init_plugins()) return;
|
||||||
|
|
||||||
|
$handler = new FeverAPI($_REQUEST);
|
||||||
|
|
||||||
|
if ($handler->before()) {
|
||||||
|
if (method_exists($handler, 'index')) {
|
||||||
|
$handler->index();
|
||||||
|
}
|
||||||
|
$handler->after();
|
||||||
|
}
|
||||||
|
|
||||||
|
header("Api-Content-Length: " . ob_get_length());
|
||||||
|
|
||||||
|
ob_end_flush();
|
||||||
?>
|
?>
|
||||||
122
fever/init.php
122
fever/init.php
@@ -1,88 +1,80 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Fever extends Plugin {
|
class Fever extends Plugin {
|
||||||
private $host;
|
private $host;
|
||||||
|
|
||||||
function about() {
|
function about() {
|
||||||
return array(1.47,
|
return array(2.0,
|
||||||
"Emulates the Fever API for Tiny Tiny RSS",
|
"Emulates the Fever API for Tiny Tiny RSS",
|
||||||
"digitaldj & murphy");
|
"DigitalDJ & murphy");
|
||||||
}
|
}
|
||||||
|
|
||||||
function init($host) {
|
function init($host) {
|
||||||
$this->host = $host;
|
$this->host = $host;
|
||||||
$host->add_hook($host::HOOK_PREFS_TAB, $this);
|
|
||||||
}
|
|
||||||
|
|
||||||
function before($method) {
|
$host->add_hook($host::HOOK_PREFS_TAB, $this);
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function csrf_ignore($method) {
|
/* plugins/main/init.php hook_prefs_tab */
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function hook_prefs_tab($args) {
|
function hook_prefs_tab($args) {
|
||||||
if ($args != "prefPrefs") return;
|
if ($args != "prefPrefs") return;
|
||||||
|
|
||||||
print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"" . __("Fever Emulation") . "\">";
|
print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"" . __("Fever Emulation") . "\">";
|
||||||
|
|
||||||
print "<h3>" . __("Fever Emulation") . "</h3>";
|
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>" . __("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>" . __("Set a password to login with Fever:") . "</p>";
|
||||||
|
|
||||||
print "<form dojoType=\"dijit.form.Form\">";
|
print "<form dojoType=\"dijit.form.Form\">";
|
||||||
|
|
||||||
print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">
|
print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
if (this.validate()) {
|
if (this.validate()) {
|
||||||
new Ajax.Request('backend.php', {
|
new Ajax.Request('backend.php', {
|
||||||
parameters: dojo.objectToQuery(this.getValues()),
|
parameters: dojo.objectToQuery(this.getValues()),
|
||||||
onComplete: function(transport) {
|
onComplete: function(transport) {
|
||||||
notify_info(transport.responseText);
|
notify_info(transport.responseText);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//this.reset();
|
//this.reset();
|
||||||
}
|
}
|
||||||
</script>";
|
</script>";
|
||||||
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pluginhandler\" />";
|
|
||||||
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"save\" />";
|
|
||||||
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"plugin\" value=\"fever\" />";
|
|
||||||
print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" type=\"password\" name=\"password\" />";
|
|
||||||
print "<button dojoType=\"dijit.form.Button\" type=\"submit\">" . __("Set Password") . "</button>";
|
|
||||||
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_hidden("op", "pluginhandler");
|
||||||
print "<p>" . __("Additional details can be found at ") . "<a href=\"http://www.feedafever.com/api\" target=\"_blank\">http://www.feedafever.com/api</a></p>";
|
print_hidden("method", "save");
|
||||||
|
print_hidden("plugin", "fever");
|
||||||
|
|
||||||
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 "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" type=\"password\" name=\"password\" />";
|
||||||
|
print "<button dojoType=\"dijit.form.Button\" type=\"submit\">" . __("Set Password") . "</button>";
|
||||||
|
print "</form>";
|
||||||
|
|
||||||
print "</div>";
|
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>";
|
||||||
|
|
||||||
function save()
|
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>";
|
||||||
{
|
|
||||||
if (isset($_POST["password"]) && isset($_SESSION["uid"]))
|
|
||||||
{
|
|
||||||
$result = db_query("SELECT login FROM ttrss_users WHERE id = '" . db_escape_string($_SESSION["uid"]) . "'");
|
|
||||||
if ($line = db_fetch_assoc($result))
|
|
||||||
{
|
|
||||||
$password = md5($line["login"] . ":" . $_POST["password"]);
|
|
||||||
$this->host->set($this, "password", $password);
|
|
||||||
echo __("Password saved.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function after() {
|
print "</div>";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
function save()
|
||||||
|
{
|
||||||
|
if (isset($_POST["password"]) && isset($_SESSION["uid"]))
|
||||||
|
{
|
||||||
|
$result = db_query("SELECT login FROM ttrss_users WHERE id = '" . db_escape_string($_SESSION["uid"]) . "'");
|
||||||
|
if ($line = db_fetch_assoc($result))
|
||||||
|
{
|
||||||
|
$password = md5($line["login"] . ":" . $_POST["password"]);
|
||||||
|
$this->host->set($this, "password", $password);
|
||||||
|
echo __("Password saved.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function api_version() {
|
function api_version() {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user