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
100
fever/index.php
100
fever/index.php
@@ -1,59 +1,67 @@
|
||||
<?php
|
||||
|
||||
// do not support refresh command, this could take ages.
|
||||
if (isset($_REQUEST["refresh"]))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
// do not support refresh command, this could take ages.
|
||||
if (isset($_REQUEST["refresh"]))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/* api/index.php */
|
||||
error_reporting(E_ERROR | E_PARSE);
|
||||
|
||||
error_reporting(E_ERROR | E_PARSE);
|
||||
require_once "../../config.php";
|
||||
|
||||
set_include_path(dirname(__FILE__) . PATH_SEPARATOR .
|
||||
dirname(dirname(dirname(__FILE__))) . PATH_SEPARATOR .
|
||||
dirname(dirname(dirname(__FILE__))) . "/include" . PATH_SEPARATOR .
|
||||
get_include_path());
|
||||
|
||||
$tt_root = dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME'])));
|
||||
$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";
|
||||
}
|
||||
chdir("../..");
|
||||
|
||||
set_include_path(dirname(__FILE__) . PATH_SEPARATOR .
|
||||
$tt_root2 . PATH_SEPARATOR .
|
||||
$tt_root2 . "/include" . PATH_SEPARATOR .
|
||||
get_include_path());
|
||||
define('TTRSS_SESSION_NAME', 'ttrss_api_sid');
|
||||
define('NO_SESSION_AUTOSTART', true);
|
||||
|
||||
chdir($tt_root);
|
||||
require_once "autoload.php";
|
||||
require_once "db.php";
|
||||
require_once "db-prefs.php";
|
||||
require_once "functions.php";
|
||||
require_once "sessions.php";
|
||||
|
||||
require_once "fever_api.php";
|
||||
|
||||
define('NO_SESSION_AUTOSTART', true);
|
||||
ini_set("session.gc_maxlifetime", 86400);
|
||||
|
||||
require_once "autoload.php";
|
||||
require_once "db.php";
|
||||
require_once "db-prefs.php";
|
||||
require_once "functions.php";
|
||||
require_once "fever_api.php";
|
||||
define('AUTH_DISABLE_OTP', true);
|
||||
|
||||
define('AUTH_DISABLE_OTP', true);
|
||||
if (defined('ENABLE_GZIP_OUTPUT') && ENABLE_GZIP_OUTPUT &&
|
||||
function_exists("ob_gzhandler")) {
|
||||
|
||||
if (defined('ENABLE_GZIP_OUTPUT') && ENABLE_GZIP_OUTPUT &&
|
||||
function_exists("ob_gzhandler")) {
|
||||
ob_start("ob_gzhandler");
|
||||
} else {
|
||||
ob_start();
|
||||
}
|
||||
|
||||
if ($_REQUEST["sid"]) {
|
||||
session_id($_REQUEST["sid"]);
|
||||
@session_start();
|
||||
} else if (defined('_API_DEBUG_HTTP_ENABLED')) {
|
||||
@session_start();
|
||||
}
|
||||
|
||||
startup_gettext();
|
||||
|
||||
ob_start("ob_gzhandler");
|
||||
} else {
|
||||
ob_start();
|
||||
}
|
||||
if (!init_plugins()) return;
|
||||
|
||||
$handler = new FeverAPI($_REQUEST);
|
||||
|
||||
if (!init_plugins()) return;
|
||||
if ($handler->before()) {
|
||||
if (method_exists($handler, 'index')) {
|
||||
$handler->index();
|
||||
}
|
||||
$handler->after();
|
||||
}
|
||||
|
||||
header("Api-Content-Length: " . ob_get_length());
|
||||
|
||||
$handler = new FeverAPI(Db::get(), $_REQUEST);
|
||||
|
||||
if ($handler->before($method)) {
|
||||
if (method_exists($handler, 'index')) {
|
||||
$handler->index($method);
|
||||
}
|
||||
$handler->after();
|
||||
}
|
||||
|
||||
ob_end_flush();
|
||||
|
||||
?>
|
||||
ob_end_flush();
|
||||
?>
|
||||
130
fever/init.php
130
fever/init.php
@@ -1,88 +1,80 @@
|
||||
<?php
|
||||
|
||||
class Fever extends Plugin {
|
||||
private $host;
|
||||
private $host;
|
||||
|
||||
function about() {
|
||||
return array(1.47,
|
||||
"Emulates the Fever API for Tiny Tiny RSS",
|
||||
"digitaldj & murphy");
|
||||
}
|
||||
function about() {
|
||||
return array(2.0,
|
||||
"Emulates the Fever API for Tiny Tiny RSS",
|
||||
"DigitalDJ & murphy");
|
||||
}
|
||||
|
||||
function init($host) {
|
||||
$this->host = $host;
|
||||
$host->add_hook($host::HOOK_PREFS_TAB, $this);
|
||||
}
|
||||
function init($host) {
|
||||
$this->host = $host;
|
||||
|
||||
$host->add_hook($host::HOOK_PREFS_TAB, $this);
|
||||
}
|
||||
|
||||
/* plugins/main/init.php hook_prefs_tab */
|
||||
|
||||
function before($method) {
|
||||
return true;
|
||||
}
|
||||
function hook_prefs_tab($args) {
|
||||
if ($args != "prefPrefs") return;
|
||||
|
||||
function csrf_ignore($method) {
|
||||
return true;
|
||||
}
|
||||
print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"" . __("Fever Emulation") . "\">";
|
||||
|
||||
function hook_prefs_tab($args) {
|
||||
if ($args != "prefPrefs") return;
|
||||
print "<h3>" . __("Fever Emulation") . "</h3>";
|
||||
|
||||
print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"" . __("Fever Emulation") . "\">";
|
||||
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 "<h3>" . __("Fever Emulation") . "</h3>";
|
||||
print "<p>" . __("Set a password to login with Fever:") . "</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 "<form dojoType=\"dijit.form.Form\">";
|
||||
|
||||
print "<p>" . __("Set a password to login with Fever:") . "</p>";
|
||||
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_info(transport.responseText);
|
||||
}
|
||||
});
|
||||
//this.reset();
|
||||
}
|
||||
</script>";
|
||||
|
||||
print_hidden("op", "pluginhandler");
|
||||
print_hidden("method", "save");
|
||||
print_hidden("plugin", "fever");
|
||||
|
||||
print "<form dojoType=\"dijit.form.Form\">";
|
||||
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 "<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_info(transport.responseText);
|
||||
}
|
||||
});
|
||||
//this.reset();
|
||||
}
|
||||
</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 "<p>" . __("Additional details can be found at ") . "<a href=\"http://www.feedafever.com/api\" target=\"_blank\">https://feedafever.com/api</a></p>";
|
||||
|
||||
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\">http://www.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 "<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>";
|
||||
}
|
||||
|
||||
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 after() {
|
||||
|
||||
}
|
||||
|
||||
function api_version() {
|
||||
return 2;
|
||||
}
|
||||
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() {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user