tt-rss-1.11/ 0000755 0000000 0000000 00000000000 12254274074 011375 5 ustar root root tt-rss-1.11/.buildpath 0000644 0000000 0000000 00000000256 12254274074 013355 0 ustar root root
tt-rss-1.11/.gitignore 0000644 0000000 0000000 00000000320 12254274074 013360 0 ustar root root /messages.mo
*~
*.DS_Store
#*
.idea/*
config.php
feed-icons/*
cache/*/*
lock/*
tags
plugins/fever
cache/htmlpurifier/*/*ser
lib/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer/*/*ser
web.config
tt-rss-1.11/.htaccess 0000644 0000000 0000000 00000000066 12254274074 013175 0 ustar root root AddType image/svg+xml svg
AddType image/svg+xml svgz
tt-rss-1.11/.project 0000644 0000000 0000000 00000001300 12254274074 013036 0 ustar root root
tt-rss
org.eclipse.wst.jsdt.core.javascriptValidator
org.eclipse.wst.validation.validationbuilder
org.eclipse.dltk.core.scriptbuilder
org.eclipse.php.core.PHPNature
org.eclipse.wst.jsdt.core.jsNature
tt-rss-1.11/LICENSE 0000644 0000000 0000000 00000043103 12254274074 012403 0 ustar root root GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
tt-rss-1.11/README.md 0000644 0000000 0000000 00000002631 12254274074 012656 0 ustar root root Tiny Tiny RSS
=============
Web-based news feed aggregator, designed to allow you to read news from
any location, while feeling as close to a real desktop application as possible.
http://tt-rss.org (http://mirror.tt-rss.org)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Copyright (c) 2005 Andrew Dolgov (unless explicitly stated otherwise).
Uses Silk icons by Mark James: http://www.famfamfam.com/lab/icons/silk/
## Requirements
* Compatible web browser (http://tt-rss.org/wiki/CompatibleBrowsers)
* Web server, for example Apache
* PHP (with support for mbstring functions)
* PostgreSQL (tested on 8.3) or MySQL (InnoDB and version 4.1+ required)
## Installation Notes
http://tt-rss.org/wiki/InstallationNotes
## See also
* FAQ: http://tt-rss.org/wiki/FrequentlyAskedQuestions
* Forum: http://tt-rss.org/forum
* Wiki: http://tt-rss.org/wiki/WikiStart
tt-rss-1.11/api/ 0000755 0000000 0000000 00000000000 12254274074 012146 5 ustar root root tt-rss-1.11/api/index.php 0000644 0000000 0000000 00000003236 12254274074 013772 0 ustar root root before($method)) {
if ($method && method_exists($handler, $method)) {
$handler->$method();
} else if (method_exists($handler, 'index')) {
$handler->index($method);
}
$handler->after();
}
header("Api-Content-Length: " . ob_get_length());
ob_end_flush();
?>
tt-rss-1.11/atom-to-html.xsl 0000644 0000000 0000000 00000002370 12254274074 014451 0 ustar root root
&
tt-rss-1.11/backend.php 0000644 0000000 0000000 00000007302 12254274074 013477 0 ustar root root array("code" => 6)));
return;
}
load_user_plugins( $_SESSION["uid"]);
}
$purge_intervals = array(
0 => __("Use default"),
-1 => __("Never purge"),
5 => __("1 week old"),
14 => __("2 weeks old"),
31 => __("1 month old"),
60 => __("2 months old"),
90 => __("3 months old"));
$update_intervals = array(
0 => __("Default interval"),
-1 => __("Disable updates"),
15 => __("Each 15 minutes"),
30 => __("Each 30 minutes"),
60 => __("Hourly"),
240 => __("Each 4 hours"),
720 => __("Each 12 hours"),
1440 => __("Daily"),
10080 => __("Weekly"));
$update_intervals_nodefault = array(
-1 => __("Disable updates"),
15 => __("Each 15 minutes"),
30 => __("Each 30 minutes"),
60 => __("Hourly"),
240 => __("Each 4 hours"),
720 => __("Each 12 hours"),
1440 => __("Daily"),
10080 => __("Weekly"));
$access_level_names = array(
0 => __("User"),
5 => __("Power User"),
10 => __("Administrator"));
#$error = sanity_check();
#if ($error['code'] != 0 && $op != "logout") {
# print json_encode(array("error" => $error));
# return;
#}
$op = str_replace("-", "_", $op);
$override = PluginHost::getInstance()->lookup_handler($op, $method);
if (class_exists($op) || $override) {
if ($override) {
$handler = $override;
} else {
$handler = new $op($_REQUEST);
}
if ($handler && implements_interface($handler, 'IHandler')) {
if (validate_csrf($csrf_token) || $handler->csrf_ignore($method)) {
if ($handler->before($method)) {
if ($method && method_exists($handler, $method)) {
$handler->$method();
} else {
if (method_exists($handler, "catchall")) {
$handler->catchall($method);
}
}
$handler->after();
return;
} else {
header("Content-Type: text/json");
print json_encode(array("error" => array("code" => 6)));
return;
}
} else {
header("Content-Type: text/json");
print json_encode(array("error" => array("code" => 6)));
return;
}
}
}
header("Content-Type: text/json");
print json_encode(array("error" => array("code" => 7)));
?>
tt-rss-1.11/cache/ 0000755 0000000 0000000 00000000000 12254274074 012440 5 ustar root root tt-rss-1.11/cache/.htaccess 0000755 0000000 0000000 00000000037 12254274074 014241 0 ustar root root Order deny,allow
Deny from all
tt-rss-1.11/cache/export/ 0000755 0000000 0000000 00000000000 12254274074 013761 5 ustar root root tt-rss-1.11/cache/export/.empty 0000755 0000000 0000000 00000000000 12254274074 015111 0 ustar root root tt-rss-1.11/cache/images/ 0000755 0000000 0000000 00000000000 12254274074 013705 5 ustar root root tt-rss-1.11/cache/images/.empty 0000755 0000000 0000000 00000000000 12254274074 015035 0 ustar root root tt-rss-1.11/cache/js/ 0000755 0000000 0000000 00000000000 12254274074 013054 5 ustar root root tt-rss-1.11/cache/js/.empty 0000755 0000000 0000000 00000000000 12254274074 014204 0 ustar root root tt-rss-1.11/cache/simplepie/ 0000755 0000000 0000000 00000000000 12254274074 014427 5 ustar root root tt-rss-1.11/cache/simplepie/.empty 0000755 0000000 0000000 00000000000 12254274074 015557 0 ustar root root tt-rss-1.11/cache/upload/ 0000755 0000000 0000000 00000000000 12254274074 013724 5 ustar root root tt-rss-1.11/cache/upload/.empty 0000644 0000000 0000000 00000000000 12254274074 015051 0 ustar root root tt-rss-1.11/classes/ 0000755 0000000 0000000 00000000000 12254274074 013032 5 ustar root root tt-rss-1.11/classes/.htaccess 0000644 0000000 0000000 00000000037 12254274074 014630 0 ustar root root Order deny,allow
Deny from all
tt-rss-1.11/classes/api.php 0000644 0000000 0000000 00000053514 12254274074 014324 0 ustar root root wrap(self::STATUS_ERR, array("error" => 'NOT_LOGGED_IN'));
return false;
}
if ($_SESSION["uid"] && $method != "logout" && !get_pref('ENABLE_API_ACCESS')) {
$this->wrap(self::STATUS_ERR, array("error" => 'API_DISABLED'));
return false;
}
$this->seq = (int) $_REQUEST['seq'];
return true;
}
return false;
}
function wrap($status, $reply) {
print json_encode(array("seq" => $this->seq,
"status" => $status,
"content" => $reply));
}
function getVersion() {
$rv = array("version" => VERSION);
$this->wrap(self::STATUS_OK, $rv);
}
function getApiLevel() {
$rv = array("level" => self::API_LEVEL);
$this->wrap(self::STATUS_OK, $rv);
}
function login() {
@session_destroy();
@session_start();
$login = $this->dbh->escape_string($_REQUEST["user"]);
$password = $_REQUEST["password"];
$password_base64 = base64_decode($_REQUEST["password"]);
if (SINGLE_USER_MODE) $login = "admin";
$result = $this->dbh->query("SELECT id FROM ttrss_users WHERE login = '$login'");
if ($this->dbh->num_rows($result) != 0) {
$uid = $this->dbh->fetch_result($result, 0, "id");
} else {
$uid = 0;
}
if (!$uid) {
$this->wrap(self::STATUS_ERR, array("error" => "LOGIN_ERROR"));
return;
}
if (get_pref("ENABLE_API_ACCESS", $uid)) {
if (authenticate_user($login, $password)) { // try login with normal password
$this->wrap(self::STATUS_OK, array("session_id" => session_id(),
"api_level" => self::API_LEVEL));
} else if (authenticate_user($login, $password_base64)) { // else try with base64_decoded password
$this->wrap(self::STATUS_OK, array("session_id" => session_id(),
"api_level" => self::API_LEVEL));
} else { // else we are not logged in
$this->wrap(self::STATUS_ERR, array("error" => "LOGIN_ERROR"));
}
} else {
$this->wrap(self::STATUS_ERR, array("error" => "API_DISABLED"));
}
}
function logout() {
logout_user();
$this->wrap(self::STATUS_OK, array("status" => "OK"));
}
function isLoggedIn() {
$this->wrap(self::STATUS_OK, array("status" => $_SESSION["uid"] != ''));
}
function getUnread() {
$feed_id = $this->dbh->escape_string($_REQUEST["feed_id"]);
$is_cat = $this->dbh->escape_string($_REQUEST["is_cat"]);
if ($feed_id) {
$this->wrap(self::STATUS_OK, array("unread" => getFeedUnread($feed_id, $is_cat)));
} else {
$this->wrap(self::STATUS_OK, array("unread" => getGlobalUnread()));
}
}
/* Method added for ttrss-reader for Android */
function getCounters() {
$this->wrap(self::STATUS_OK, getAllCounters());
}
function getFeeds() {
$cat_id = $this->dbh->escape_string($_REQUEST["cat_id"]);
$unread_only = sql_bool_to_bool($_REQUEST["unread_only"]);
$limit = (int) $this->dbh->escape_string($_REQUEST["limit"]);
$offset = (int) $this->dbh->escape_string($_REQUEST["offset"]);
$include_nested = sql_bool_to_bool($_REQUEST["include_nested"]);
$feeds = $this->api_get_feeds($cat_id, $unread_only, $limit, $offset, $include_nested);
$this->wrap(self::STATUS_OK, $feeds);
}
function getCategories() {
$unread_only = sql_bool_to_bool($_REQUEST["unread_only"]);
$enable_nested = sql_bool_to_bool($_REQUEST["enable_nested"]);
$include_empty = sql_bool_to_bool($_REQUEST['include_empty']);
// TODO do not return empty categories, return Uncategorized and standard virtual cats
if ($enable_nested)
$nested_qpart = "parent_cat IS NULL";
else
$nested_qpart = "true";
$result = $this->dbh->query("SELECT
id, title, order_id, (SELECT COUNT(id) FROM
ttrss_feeds WHERE
ttrss_feed_categories.id IS NOT NULL AND cat_id = ttrss_feed_categories.id) AS num_feeds,
(SELECT COUNT(id) FROM
ttrss_feed_categories AS c2 WHERE
c2.parent_cat = ttrss_feed_categories.id) AS num_cats
FROM ttrss_feed_categories
WHERE $nested_qpart AND owner_uid = " .
$_SESSION["uid"]);
$cats = array();
while ($line = $this->dbh->fetch_assoc($result)) {
if ($include_empty || $line["num_feeds"] > 0 || $line["num_cats"] > 0) {
$unread = getFeedUnread($line["id"], true);
if ($enable_nested)
$unread += getCategoryChildrenUnread($line["id"]);
if ($unread || !$unread_only) {
array_push($cats, array("id" => $line["id"],
"title" => $line["title"],
"unread" => $unread,
"order_id" => (int) $line["order_id"],
));
}
}
}
foreach (array(-2,-1,0) as $cat_id) {
if ($include_empty || !$this->isCategoryEmpty($cat_id)) {
$unread = getFeedUnread($cat_id, true);
if ($unread || !$unread_only) {
array_push($cats, array("id" => $cat_id,
"title" => getCategoryTitle($cat_id),
"unread" => $unread));
}
}
}
$this->wrap(self::STATUS_OK, $cats);
}
function getHeadlines() {
$feed_id = $this->dbh->escape_string($_REQUEST["feed_id"]);
if ($feed_id != "") {
$limit = (int)$this->dbh->escape_string($_REQUEST["limit"]);
if (!$limit || $limit >= 200) $limit = 200;
$offset = (int)$this->dbh->escape_string($_REQUEST["skip"]);
$filter = $this->dbh->escape_string($_REQUEST["filter"]);
$is_cat = sql_bool_to_bool($_REQUEST["is_cat"]);
$show_excerpt = sql_bool_to_bool($_REQUEST["show_excerpt"]);
$show_content = sql_bool_to_bool($_REQUEST["show_content"]);
/* all_articles, unread, adaptive, marked, updated */
$view_mode = $this->dbh->escape_string($_REQUEST["view_mode"]);
$include_attachments = sql_bool_to_bool($_REQUEST["include_attachments"]);
$since_id = (int)$this->dbh->escape_string($_REQUEST["since_id"]);
$include_nested = sql_bool_to_bool($_REQUEST["include_nested"]);
$sanitize_content = !isset($_REQUEST["sanitize"]) ||
sql_bool_to_bool($_REQUEST["sanitize"]);
$override_order = false;
switch ($_REQUEST["order_by"]) {
case "title":
$override_order = "ttrss_entries.title";
break;
case "date_reverse":
$override_order = "score DESC, date_entered, updated";
break;
case "feed_dates":
$override_order = "updated DESC";
break;
}
/* do not rely on params below */
$search = $this->dbh->escape_string($_REQUEST["search"]);
$search_mode = $this->dbh->escape_string($_REQUEST["search_mode"]);
$headlines = $this->api_get_headlines($feed_id, $limit, $offset,
$filter, $is_cat, $show_excerpt, $show_content, $view_mode, $override_order,
$include_attachments, $since_id, $search, $search_mode,
$include_nested, $sanitize_content);
$this->wrap(self::STATUS_OK, $headlines);
} else {
$this->wrap(self::STATUS_ERR, array("error" => 'INCORRECT_USAGE'));
}
}
function updateArticle() {
$article_ids = array_filter(explode(",", $this->dbh->escape_string($_REQUEST["article_ids"])), is_numeric);
$mode = (int) $this->dbh->escape_string($_REQUEST["mode"]);
$data = $this->dbh->escape_string($_REQUEST["data"]);
$field_raw = (int)$this->dbh->escape_string($_REQUEST["field"]);
$field = "";
$set_to = "";
switch ($field_raw) {
case 0:
$field = "marked";
$additional_fields = ",last_marked = NOW()";
break;
case 1:
$field = "published";
$additional_fields = ",last_published = NOW()";
break;
case 2:
$field = "unread";
$additional_fields = ",last_read = NOW()";
break;
case 3:
$field = "note";
};
switch ($mode) {
case 1:
$set_to = "true";
break;
case 0:
$set_to = "false";
break;
case 2:
$set_to = "NOT $field";
break;
}
if ($field == "note") $set_to = "'$data'";
if ($field && $set_to && count($article_ids) > 0) {
$article_ids = join(", ", $article_ids);
$result = $this->dbh->query("UPDATE ttrss_user_entries SET $field = $set_to $additional_fields WHERE ref_id IN ($article_ids) AND owner_uid = " . $_SESSION["uid"]);
$num_updated = $this->dbh->affected_rows($result);
if ($num_updated > 0 && $field == "unread") {
$result = $this->dbh->query("SELECT DISTINCT feed_id FROM ttrss_user_entries
WHERE ref_id IN ($article_ids)");
while ($line = $this->dbh->fetch_assoc($result)) {
ccache_update($line["feed_id"], $_SESSION["uid"]);
}
}
if ($num_updated > 0 && $field == "published") {
if (PUBSUBHUBBUB_HUB) {
$rss_link = get_self_url_prefix() .
"/public.php?op=rss&id=-2&key=" .
get_feed_access_key(-2, false);
$p = new Publisher(PUBSUBHUBBUB_HUB);
$pubsub_result = $p->publish_update($rss_link);
}
}
$this->wrap(self::STATUS_OK, array("status" => "OK",
"updated" => $num_updated));
} else {
$this->wrap(self::STATUS_ERR, array("error" => 'INCORRECT_USAGE'));
}
}
function getArticle() {
$article_id = join(",", array_filter(explode(",", $this->dbh->escape_string($_REQUEST["article_id"])), is_numeric));
if ($article_id) {
$query = "SELECT id,title,link,content,feed_id,comments,int_id,
marked,unread,published,score,note,lang,
".SUBSTRING_FOR_DATE."(updated,1,16) as updated,
author,(SELECT title FROM ttrss_feeds WHERE id = feed_id) AS feed_title
FROM ttrss_entries,ttrss_user_entries
WHERE id IN ($article_id) AND ref_id = id AND owner_uid = " .
$_SESSION["uid"] ;
$result = $this->dbh->query($query);
$articles = array();
if ($this->dbh->num_rows($result) != 0) {
while ($line = $this->dbh->fetch_assoc($result)) {
$attachments = get_article_enclosures($line['id']);
$article = array(
"id" => $line["id"],
"title" => $line["title"],
"link" => $line["link"],
"labels" => get_article_labels($line['id']),
"unread" => sql_bool_to_bool($line["unread"]),
"marked" => sql_bool_to_bool($line["marked"]),
"published" => sql_bool_to_bool($line["published"]),
"comments" => $line["comments"],
"author" => $line["author"],
"updated" => (int) strtotime($line["updated"]),
"content" => $line["content"],
"feed_id" => $line["feed_id"],
"attachments" => $attachments,
"score" => (int)$line["score"],
"feed_title" => $line["feed_title"],
"note" => $line["note"],
"lang" => $line["lang"]
);
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_API) as $p) {
$article = $p->hook_render_article_api(array("article" => $article));
}
array_push($articles, $article);
}
}
$this->wrap(self::STATUS_OK, $articles);
} else {
$this->wrap(self::STATUS_ERR, array("error" => 'INCORRECT_USAGE'));
}
}
function getConfig() {
$config = array(
"icons_dir" => ICONS_DIR,
"icons_url" => ICONS_URL);
$config["daemon_is_running"] = file_is_locked("update_daemon.lock");
$result = $this->dbh->query("SELECT COUNT(*) AS cf FROM
ttrss_feeds WHERE owner_uid = " . $_SESSION["uid"]);
$num_feeds = $this->dbh->fetch_result($result, 0, "cf");
$config["num_feeds"] = (int)$num_feeds;
$this->wrap(self::STATUS_OK, $config);
}
function updateFeed() {
require_once "include/rssfuncs.php";
$feed_id = (int) $this->dbh->escape_string($_REQUEST["feed_id"]);
update_rss_feed($feed_id, true);
$this->wrap(self::STATUS_OK, array("status" => "OK"));
}
function catchupFeed() {
$feed_id = $this->dbh->escape_string($_REQUEST["feed_id"]);
$is_cat = $this->dbh->escape_string($_REQUEST["is_cat"]);
catchup_feed($feed_id, $is_cat);
$this->wrap(self::STATUS_OK, array("status" => "OK"));
}
function getPref() {
$pref_name = $this->dbh->escape_string($_REQUEST["pref_name"]);
$this->wrap(self::STATUS_OK, array("value" => get_pref($pref_name)));
}
function getLabels() {
//$article_ids = array_filter(explode(",", $this->dbh->escape_string($_REQUEST["article_ids"])), is_numeric);
$article_id = (int)$_REQUEST['article_id'];
$rv = array();
$result = $this->dbh->query("SELECT id, caption, fg_color, bg_color
FROM ttrss_labels2
WHERE owner_uid = '".$_SESSION['uid']."' ORDER BY caption");
if ($article_id)
$article_labels = get_article_labels($article_id);
else
$article_labels = array();
while ($line = $this->dbh->fetch_assoc($result)) {
$checked = false;
foreach ($article_labels as $al) {
if (feed_to_label_id($al[0]) == $line['id']) {
$checked = true;
break;
}
}
array_push($rv, array(
"id" => (int)label_to_feed_id($line['id']),
"caption" => $line['caption'],
"fg_color" => $line['fg_color'],
"bg_color" => $line['bg_color'],
"checked" => $checked));
}
$this->wrap(self::STATUS_OK, $rv);
}
function setArticleLabel() {
$article_ids = array_filter(explode(",", $this->dbh->escape_string($_REQUEST["article_ids"])), is_numeric);
$label_id = (int) $this->dbh->escape_string($_REQUEST['label_id']);
$assign = (bool) $this->dbh->escape_string($_REQUEST['assign']) == "true";
$label = $this->dbh->escape_string(label_find_caption(
feed_to_label_id($label_id), $_SESSION["uid"]));
$num_updated = 0;
if ($label) {
foreach ($article_ids as $id) {
if ($assign)
label_add_article($id, $label, $_SESSION["uid"]);
else
label_remove_article($id, $label, $_SESSION["uid"]);
++$num_updated;
}
}
$this->wrap(self::STATUS_OK, array("status" => "OK",
"updated" => $num_updated));
}
function index($method) {
$plugin = PluginHost::getInstance()->get_api_method(strtolower($method));
if ($plugin && method_exists($plugin, $method)) {
$reply = $plugin->$method();
$this->wrap($reply[0], $reply[1]);
} else {
$this->wrap(self::STATUS_ERR, array("error" => 'UNKNOWN_METHOD', "method" => $method));
}
}
function shareToPublished() {
$title = $this->dbh->escape_string(strip_tags($_REQUEST["title"]));
$url = $this->dbh->escape_string(strip_tags($_REQUEST["url"]));
$content = $this->dbh->escape_string(strip_tags($_REQUEST["content"]));
if (Article::create_published_article($title, $url, $content, "", $_SESSION["uid"])) {
$this->wrap(self::STATUS_OK, array("status" => 'OK'));
} else {
$this->wrap(self::STATUS_ERR, array("error" => 'Publishing failed'));
}
}
static function api_get_feeds($cat_id, $unread_only, $limit, $offset, $include_nested = false) {
$feeds = array();
/* Labels */
if ($cat_id == -4 || $cat_id == -2) {
$counters = getLabelCounters(true);
foreach (array_values($counters) as $cv) {
$unread = $cv["counter"];
if ($unread || !$unread_only) {
$row = array(
"id" => $cv["id"],
"title" => $cv["description"],
"unread" => $cv["counter"],
"cat_id" => -2,
);
array_push($feeds, $row);
}
}
}
/* Virtual feeds */
if ($cat_id == -4 || $cat_id == -1) {
foreach (array(-1, -2, -3, -4, -6, 0) as $i) {
$unread = getFeedUnread($i);
if ($unread || !$unread_only) {
$title = getFeedTitle($i);
$row = array(
"id" => $i,
"title" => $title,
"unread" => $unread,
"cat_id" => -1,
);
array_push($feeds, $row);
}
}
}
/* Child cats */
if ($include_nested && $cat_id) {
$result = db_query("SELECT
id, title FROM ttrss_feed_categories
WHERE parent_cat = '$cat_id' AND owner_uid = " . $_SESSION["uid"] .
" ORDER BY id, title");
while ($line = db_fetch_assoc($result)) {
$unread = getFeedUnread($line["id"], true) +
getCategoryChildrenUnread($line["id"]);
if ($unread || !$unread_only) {
$row = array(
"id" => $line["id"],
"title" => $line["title"],
"unread" => $unread,
"is_cat" => true,
);
array_push($feeds, $row);
}
}
}
/* Real feeds */
if ($limit) {
$limit_qpart = "LIMIT $limit OFFSET $offset";
} else {
$limit_qpart = "";
}
if ($cat_id == -4 || $cat_id == -3) {
$result = db_query("SELECT
id, feed_url, cat_id, title, order_id, ".
SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
FROM ttrss_feeds WHERE owner_uid = " . $_SESSION["uid"] .
" ORDER BY cat_id, title " . $limit_qpart);
} else {
if ($cat_id)
$cat_qpart = "cat_id = '$cat_id'";
else
$cat_qpart = "cat_id IS NULL";
$result = db_query("SELECT
id, feed_url, cat_id, title, order_id, ".
SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
FROM ttrss_feeds WHERE
$cat_qpart AND owner_uid = " . $_SESSION["uid"] .
" ORDER BY cat_id, title " . $limit_qpart);
}
while ($line = db_fetch_assoc($result)) {
$unread = getFeedUnread($line["id"]);
$has_icon = feed_has_icon($line['id']);
if ($unread || !$unread_only) {
$row = array(
"feed_url" => $line["feed_url"],
"title" => $line["title"],
"id" => (int)$line["id"],
"unread" => (int)$unread,
"has_icon" => $has_icon,
"cat_id" => (int)$line["cat_id"],
"last_updated" => (int) strtotime($line["last_updated"]),
"order_id" => (int) $line["order_id"],
);
array_push($feeds, $row);
}
}
return $feeds;
}
static function api_get_headlines($feed_id, $limit, $offset,
$filter, $is_cat, $show_excerpt, $show_content, $view_mode, $order,
$include_attachments, $since_id,
$search = "", $search_mode = "",
$include_nested = false, $sanitize_content = true) {
$qfh_ret = queryFeedHeadlines($feed_id, $limit,
$view_mode, $is_cat, $search, $search_mode,
$order, $offset, 0, false, $since_id, $include_nested);
$result = $qfh_ret[0];
$feed_title = $qfh_ret[1];
$headlines = array();
while ($line = db_fetch_assoc($result)) {
$line["content_preview"] = truncate_string(strip_tags($line["content"]), 100);
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) {
$line = $p->hook_query_headlines($line, 100, true);
}
$is_updated = ($line["last_read"] == "" &&
($line["unread"] != "t" && $line["unread"] != "1"));
$tags = explode(",", $line["tag_cache"]);
$labels = json_decode($line["label_cache"], true);
//if (!$tags) $tags = get_article_tags($line["id"]);
//if (!$labels) $labels = get_article_labels($line["id"]);
$headline_row = array(
"id" => (int)$line["id"],
"unread" => sql_bool_to_bool($line["unread"]),
"marked" => sql_bool_to_bool($line["marked"]),
"published" => sql_bool_to_bool($line["published"]),
"updated" => (int) strtotime($line["updated"]),
"is_updated" => $is_updated,
"title" => $line["title"],
"link" => $line["link"],
"feed_id" => $line["feed_id"],
"tags" => $tags,
);
if ($include_attachments)
$headline_row['attachments'] = get_article_enclosures(
$line['id']);
if ($show_excerpt)
$headline_row["excerpt"] = $line["content_preview"];
if ($show_content) {
if ($sanitize_content) {
$headline_row["content"] = sanitize(
$line["content"],
sql_bool_to_bool($line['hide_images']),
false, $line["site_url"], false, $line["id"]);
} else {
$headline_row["content"] = $line["content"];
}
}
// unify label output to ease parsing
if ($labels["no-labels"] == 1) $labels = array();
$headline_row["labels"] = $labels;
$headline_row["feed_title"] = $line["feed_title"] ? $line["feed_title"] :
$feed_title;
$headline_row["comments_count"] = (int)$line["num_comments"];
$headline_row["comments_link"] = $line["comments"];
$headline_row["always_display_attachments"] = sql_bool_to_bool($line["always_display_enclosures"]);
$headline_row["author"] = $line["author"];
$headline_row["score"] = (int)$line["score"];
$headline_row["note"] = $line["note"];
$headline_row["lang"] = $line["lang"];
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_API) as $p) {
$headline_row = $p->hook_render_article_api(array("headline" => $headline_row));
}
array_push($headlines, $headline_row);
}
return $headlines;
}
function unsubscribeFeed() {
$feed_id = (int) $this->dbh->escape_string($_REQUEST["feed_id"]);
$result = $this->dbh->query("SELECT id FROM ttrss_feeds WHERE
id = '$feed_id' AND owner_uid = ".$_SESSION["uid"]);
if ($this->dbh->num_rows($result) != 0) {
Pref_Feeds::remove_feed($feed_id, $_SESSION["uid"]);
$this->wrap(self::STATUS_OK, array("status" => "OK"));
} else {
$this->wrap(self::STATUS_ERR, array("error" => "FEED_NOT_FOUND"));
}
}
function subscribeToFeed() {
$feed_url = $this->dbh->escape_string($_REQUEST["feed_url"]);
$category_id = (int) $this->dbh->escape_string($_REQUEST["category_id"]);
$login = $this->dbh->escape_string($_REQUEST["login"]);
$password = $this->dbh->escape_string($_REQUEST["password"]);
if ($feed_url) {
$rc = subscribe_to_feed($feed_url, $category_id, $login, $password);
$this->wrap(self::STATUS_OK, array("status" => $rc));
} else {
$this->wrap(self::STATUS_ERR, array("error" => 'INCORRECT_USAGE'));
}
}
function getFeedTree() {
$include_empty = sql_bool_to_bool($_REQUEST['include_empty']);
$pf = new Pref_Feeds($_REQUEST);
$_REQUEST['mode'] = 2;
$_REQUEST['force_show_empty'] = $include_empty;
if ($pf){
$data = $pf->makefeedtree();
$this->wrap(self::STATUS_OK, array("categories" => $data));
} else {
$this->wrap(self::STATUS_ERR, array("error" =>
'UNABLE_TO_INSTANTIATE_OBJECT'));
}
}
// only works for labels or uncategorized for the time being
private function isCategoryEmpty($id) {
if ($id == -2) {
$result = $this->dbh->query("SELECT COUNT(*) AS count FROM ttrss_labels2
WHERE owner_uid = " . $_SESSION["uid"]);
return $this->dbh->fetch_result($result, 0, "count") == 0;
} else if ($id == 0) {
$result = $this->dbh->query("SELECT COUNT(*) AS count FROM ttrss_feeds
WHERE cat_id IS NULL AND owner_uid = " . $_SESSION["uid"]);
return $this->dbh->fetch_result($result, 0, "count") == 0;
}
return false;
}
}
?>
tt-rss-1.11/classes/article.php 0000644 0000000 0000000 00000022733 12254274074 015175 0 ustar root root dbh->escape_string($_REQUEST['id']);
$result = $this->dbh->query("SELECT link FROM ttrss_entries, ttrss_user_entries
WHERE id = '$id' AND id = ref_id AND owner_uid = '".$_SESSION['uid']."'
LIMIT 1");
if ($this->dbh->num_rows($result) == 1) {
$article_url = $this->dbh->fetch_result($result, 0, 'link');
$article_url = str_replace("\n", "", $article_url);
header("Location: $article_url");
return;
} else {
print_error(__("Article not found."));
}
}
function view() {
$id = $this->dbh->escape_string($_REQUEST["id"]);
$cids = explode(",", $this->dbh->escape_string($_REQUEST["cids"]));
$mode = $this->dbh->escape_string($_REQUEST["mode"]);
$omode = $this->dbh->escape_string($_REQUEST["omode"]);
// in prefetch mode we only output requested cids, main article
// just gets marked as read (it already exists in client cache)
$articles = array();
if ($mode == "") {
array_push($articles, format_article($id, false));
} else if ($mode == "zoom") {
array_push($articles, format_article($id, true, true));
} else if ($mode == "raw") {
if ($_REQUEST['html']) {
header("Content-Type: text/html");
print ' ';
}
$article = format_article($id, false);
print $article['content'];
return;
}
$this->catchupArticleById($id, 0);
if (!$_SESSION["bw_limit"]) {
foreach ($cids as $cid) {
if ($cid) {
array_push($articles, format_article($cid, false, false));
}
}
}
print json_encode($articles);
}
private function catchupArticleById($id, $cmode) {
if ($cmode == 0) {
$this->dbh->query("UPDATE ttrss_user_entries SET
unread = false,last_read = NOW()
WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
} else if ($cmode == 1) {
$this->dbh->query("UPDATE ttrss_user_entries SET
unread = true
WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
} else {
$this->dbh->query("UPDATE ttrss_user_entries SET
unread = NOT unread,last_read = NOW()
WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
}
$feed_id = getArticleFeed($id);
ccache_update($feed_id, $_SESSION["uid"]);
}
static function create_published_article($title, $url, $content, $labels_str,
$owner_uid) {
$guid = 'SHA1:' . sha1("ttshared:" . $url . $owner_uid); // include owner_uid to prevent global GUID clash
$content_hash = sha1($content);
if ($labels_str != "") {
$labels = explode(",", $labels_str);
} else {
$labels = array();
}
$rc = false;
if (!$title) $title = $url;
if (!$title && !$url) return false;
if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) return false;
db_query("BEGIN");
// only check for our user data here, others might have shared this with different content etc
$result = db_query("SELECT id FROM ttrss_entries, ttrss_user_entries WHERE
link = '$url' AND ref_id = id AND owner_uid = '$owner_uid' LIMIT 1");
if (db_num_rows($result) != 0) {
$ref_id = db_fetch_result($result, 0, "id");
$result = db_query("SELECT int_id FROM ttrss_user_entries WHERE
ref_id = '$ref_id' AND owner_uid = '$owner_uid' LIMIT 1");
if (db_num_rows($result) != 0) {
$int_id = db_fetch_result($result, 0, "int_id");
db_query("UPDATE ttrss_entries SET
content = '$content', content_hash = '$content_hash' WHERE id = '$ref_id'");
db_query("UPDATE ttrss_user_entries SET published = true,
last_published = NOW() WHERE
int_id = '$int_id' AND owner_uid = '$owner_uid'");
} else {
db_query("INSERT INTO ttrss_user_entries
(ref_id, uuid, feed_id, orig_feed_id, owner_uid, published, tag_cache, label_cache,
last_read, note, unread, last_published)
VALUES
('$ref_id', '', NULL, NULL, $owner_uid, true, '', '', NOW(), '', false, NOW())");
}
if (count($labels) != 0) {
foreach ($labels as $label) {
label_add_article($ref_id, trim($label), $owner_uid);
}
}
$rc = true;
} else {
$result = db_query("INSERT INTO ttrss_entries
(title, guid, link, updated, content, content_hash, date_entered, date_updated)
VALUES
('$title', '$guid', '$url', NOW(), '$content', '$content_hash', NOW(), NOW())");
$result = db_query("SELECT id FROM ttrss_entries WHERE guid = '$guid'");
if (db_num_rows($result) != 0) {
$ref_id = db_fetch_result($result, 0, "id");
db_query("INSERT INTO ttrss_user_entries
(ref_id, uuid, feed_id, orig_feed_id, owner_uid, published, tag_cache, label_cache,
last_read, note, unread, last_published)
VALUES
('$ref_id', '', NULL, NULL, $owner_uid, true, '', '', NOW(), '', false, NOW())");
if (count($labels) != 0) {
foreach ($labels as $label) {
label_add_article($ref_id, trim($label), $owner_uid);
}
}
$rc = true;
}
}
db_query("COMMIT");
return $rc;
}
function editArticleTags() {
print __("Tags for this article (separated by commas):")." ";
$param = $this->dbh->escape_string($_REQUEST['param']);
$tags = get_article_tags($this->dbh->escape_string($param));
$tags_str = join(", ", $tags);
print " ";
print " ";
print " ";
print "";
print "";
print "".__('Save')." ";
print "".__('Cancel')." ";
print "
";
}
function setScore() {
$ids = $this->dbh->escape_string($_REQUEST['id']);
$score = (int)$this->dbh->escape_string($_REQUEST['score']);
$this->dbh->query("UPDATE ttrss_user_entries SET
score = '$score' WHERE ref_id IN ($ids) AND owner_uid = " . $_SESSION["uid"]);
print json_encode(array("id" => $ids,
"score_pic" => get_score_pic($score)));
}
function setArticleTags() {
$id = $this->dbh->escape_string($_REQUEST["id"]);
$tags_str = $this->dbh->escape_string($_REQUEST["tags_str"]);
$tags = array_unique(trim_array(explode(",", $tags_str)));
$this->dbh->query("BEGIN");
$result = $this->dbh->query("SELECT int_id FROM ttrss_user_entries WHERE
ref_id = '$id' AND owner_uid = '".$_SESSION["uid"]."' LIMIT 1");
if ($this->dbh->num_rows($result) == 1) {
$tags_to_cache = array();
$int_id = $this->dbh->fetch_result($result, 0, "int_id");
$this->dbh->query("DELETE FROM ttrss_tags WHERE
post_int_id = $int_id AND owner_uid = '".$_SESSION["uid"]."'");
foreach ($tags as $tag) {
$tag = sanitize_tag($tag);
if (!tag_is_valid($tag)) {
continue;
}
if (preg_match("/^[0-9]*$/", $tag)) {
continue;
}
// print "";
if ($tag != '') {
$this->dbh->query("INSERT INTO ttrss_tags
(post_int_id, owner_uid, tag_name) VALUES ('$int_id', '".$_SESSION["uid"]."', '$tag')");
}
array_push($tags_to_cache, $tag);
}
/* update tag cache */
sort($tags_to_cache);
$tags_str = join(",", $tags_to_cache);
$this->dbh->query("UPDATE ttrss_user_entries
SET tag_cache = '$tags_str' WHERE ref_id = '$id'
AND owner_uid = " . $_SESSION["uid"]);
}
$this->dbh->query("COMMIT");
$tags = get_article_tags($id);
$tags_str = format_tags_string($tags, $id);
$tags_str_full = join(", ", $tags);
if (!$tags_str_full) $tags_str_full = __("no tags");
print json_encode(array("id" => (int)$id,
"content" => $tags_str, "content_full" => $tags_str_full));
}
function completeTags() {
$search = $this->dbh->escape_string($_REQUEST["search"]);
$result = $this->dbh->query("SELECT DISTINCT tag_name FROM ttrss_tags
WHERE owner_uid = '".$_SESSION["uid"]."' AND
tag_name LIKE '$search%' ORDER BY tag_name
LIMIT 10");
print "";
while ($line = $this->dbh->fetch_assoc($result)) {
print "" . $line["tag_name"] . " ";
}
print " ";
}
function assigntolabel() {
return $this->labelops(true);
}
function removefromlabel() {
return $this->labelops(false);
}
private function labelops($assign) {
$reply = array();
$ids = explode(",", $this->dbh->escape_string($_REQUEST["ids"]));
$label_id = $this->dbh->escape_string($_REQUEST["lid"]);
$label = $this->dbh->escape_string(label_find_caption($label_id,
$_SESSION["uid"]));
$reply["info-for-headlines"] = array();
if ($label) {
foreach ($ids as $id) {
if ($assign)
label_add_article($id, $label, $_SESSION["uid"]);
else
label_remove_article($id, $label, $_SESSION["uid"]);
$labels = get_article_labels($id, $_SESSION["uid"]);
array_push($reply["info-for-headlines"],
array("id" => $id, "labels" => format_article_labels($labels, $id)));
}
}
$reply["message"] = "UPDATE_COUNTERS";
print json_encode($reply);
}
}
tt-rss-1.11/classes/auth/ 0000755 0000000 0000000 00000000000 12254274074 013773 5 ustar root root tt-rss-1.11/classes/auth/base.php 0000644 0000000 0000000 00000002620 12254274074 015416 0 ustar root root dbh = Db::get();
}
function check_password($owner_uid, $password) {
return false;
}
function authenticate($login, $password) {
return false;
}
// Auto-creates specified user if allowed by system configuration
// Can be used instead of find_user_by_login() by external auth modules
function auto_create_user($login, $password = false) {
if ($login && defined('AUTH_AUTO_CREATE') && AUTH_AUTO_CREATE) {
$user_id = $this->find_user_by_login($login);
if (!$password) $password = make_password();
if (!$user_id) {
$login = $this->dbh->escape_string($login);
$salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
$pwd_hash = encrypt_password($password, $salt, true);
$query = "INSERT INTO ttrss_users
(login,access_level,last_login,created,pwd_hash,salt)
VALUES ('$login', 0, null, NOW(), '$pwd_hash','$salt')";
$this->dbh->query($query);
return $this->find_user_by_login($login);
} else {
return $user_id;
}
}
return $this->find_user_by_login($login);
}
function find_user_by_login($login) {
$login = $this->dbh->escape_string($login);
$result = $this->dbh->query("SELECT id FROM ttrss_users WHERE
login = '$login'");
if ($this->dbh->num_rows($result) > 0) {
return $this->dbh->fetch_result($result, 0, "id");
} else {
return false;
}
}
}
?>
tt-rss-1.11/classes/backend.php 0000644 0000000 0000000 00000005335 12254274074 015140 0 ustar root root ";
}
function digestTest() {
header("Content-type: text/html");
require_once "digest.php";
$rv = prepare_headlines_digest($_SESSION['uid'], 1, 1000);
$rv[3] = "" . $rv[3] . " ";
print_r($rv);
}
private function display_main_help() {
$info = get_hotkeys_info();
$imap = get_hotkeys_map();
$omap = array();
foreach ($imap[1] as $sequence => $action) {
if (!isset($omap[$action])) $omap[$action] = array();
array_push($omap[$action], $sequence);
}
print_notice("".
__("Other interface tips are available in the Tiny Tiny RSS wiki.") .
" ");
print "";
print "" . __("Keyboard Shortcuts") . " ";
foreach ($info as $section => $hotkeys) {
print "" . $section . " ";
foreach ($hotkeys as $action => $description) {
if (is_array($omap[$action])) {
foreach ($omap[$action] as $sequence) {
if (strpos($sequence, "|") !== FALSE) {
$sequence = substr($sequence,
strpos($sequence, "|")+1,
strlen($sequence));
} else {
$keys = explode(" ", $sequence);
for ($i = 0; $i < count($keys); $i++) {
if (strlen($keys[$i]) > 1) {
$tmp = '';
foreach (str_split($keys[$i]) as $c) {
switch ($c) {
case '*':
$tmp .= __('Shift') . '+';
break;
case '^':
$tmp .= __('Ctrl') . '+';
break;
default:
$tmp .= $c;
}
}
$keys[$i] = $tmp;
}
}
$sequence = join(" ", $keys);
}
print "";
print "$sequence ";
print $description;
print " ";
}
}
}
}
print " ";
}
function help() {
$topic = basename($_REQUEST["topic"]);
switch ($topic) {
case "main":
$this->display_main_help();
break;
case "prefs":
//$this->display_prefs_help();
break;
default:
print "".__("Help topic not found.")."
";
}
print "";
print "".
__('Close this window')." ";
print "
";
/* if (file_exists("help/$topic.php")) {
include("help/$topic.php");
} else {
print "".__("Help topic not found.")."
";
} */
/* print "
".
__('Close this window')."
"; */
}
}
?>
tt-rss-1.11/classes/db.php 0000644 0000000 0000000 00000004126 12254274074 014133 0 ustar root root adapter = new Db_PDO();
} else {
switch (DB_TYPE) {
case "mysql":
if (function_exists("mysqli_connect")) {
$this->adapter = new Db_Mysqli();
} else {
$this->adapter = new Db_Mysql();
}
break;
case "pgsql":
$this->adapter = new Db_Pgsql();
break;
default:
die("Unknown DB_TYPE: " . DB_TYPE);
}
}
if (!$this->adapter) die("Error initializing database adapter for " . DB_TYPE);
$this->link = $this->adapter->connect(DB_HOST, DB_USER, DB_PASS, DB_NAME, defined('DB_PORT') ? DB_PORT : "");
if (!$this->link) {
die("Error connecting through adapter: " . $this->adapter->last_error());
}
error_reporting($er);
}
private function __clone() {
//
}
public static function get() {
if (self::$instance == null)
self::$instance = new self();
return self::$instance;
}
static function quote($str){
return("'$str'");
}
function reconnect() {
$this->link = $this->adapter->connect(DB_HOST, DB_USER, DB_PASS, DB_NAME, defined('DB_PORT') ? DB_PORT : "");
}
function connect($host, $user, $pass, $db, $port) {
//return $this->adapter->connect($host, $user, $pass, $db, $port);
return ;
}
function escape_string($s, $strip_tags = true) {
return $this->adapter->escape_string($s, $strip_tags);
}
function query($query, $die_on_error = true) {
return $this->adapter->query($query, $die_on_error);
}
function fetch_assoc($result) {
return $this->adapter->fetch_assoc($result);
}
function num_rows($result) {
return $this->adapter->num_rows($result);
}
function fetch_result($result, $row, $param) {
return $this->adapter->fetch_result($result, $row, $param);
}
function close() {
return $this->adapter->close();
}
function affected_rows($result) {
return $this->adapter->affected_rows($result);
}
function last_error() {
return $this->adapter->last_error();
}
}
?>
tt-rss-1.11/classes/db/ 0000755 0000000 0000000 00000000000 12254274074 013417 5 ustar root root tt-rss-1.11/classes/db/mysql.php 0000644 0000000 0000000 00000003070 12254274074 015275 0 ustar root root link = mysql_connect($host, $user, $pass);
if ($this->link) {
$result = mysql_select_db($db, $this->link);
if (!$result) {
die("Can't select DB: " . mysql_error($this->link));
}
$this->init();
return $this->link;
} else {
die("Unable to connect to database (as $user to $host, database $db): " . mysql_error());
}
}
function escape_string($s, $strip_tags = true) {
if ($strip_tags) $s = strip_tags($s);
return mysql_real_escape_string($s, $this->link);
}
function query($query, $die_on_error = true) {
$result = @mysql_query($query, $this->link);
if (!$result) {
$error = @mysql_error($this->link);
@mysql_query("ROLLBACK", $this->link);
user_error("Query $query failed: " . ($this->link ? $error : "No connection"),
$die_on_error ? E_USER_ERROR : E_USER_WARNING);
}
return $result;
}
function fetch_assoc($result) {
return mysql_fetch_assoc($result);
}
function num_rows($result) {
return mysql_num_rows($result);
}
function fetch_result($result, $row, $param) {
return mysql_result($result, $row, $param);
}
function close() {
return mysql_close($this->link);
}
function affected_rows($result) {
return mysql_affected_rows($this->link);
}
function last_error() {
return mysql_error();
}
function init() {
$this->query("SET time_zone = '+0:0'");
if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) {
$this->query("SET NAMES " . MYSQL_CHARSET);
}
return true;
}
}
?>
tt-rss-1.11/classes/db/mysqli.php 0000644 0000000 0000000 00000003203 12254274074 015444 0 ustar root root link = mysqli_connect($host, $user, $pass, $db, $port);
else
$this->link = mysqli_connect($host, $user, $pass, $db);
if ($this->link) {
$this->init();
return $this->link;
} else {
die("Unable to connect to database (as $user to $host, database $db): " . mysqli_connect_error());
}
}
function escape_string($s, $strip_tags = true) {
if ($strip_tags) $s = strip_tags($s);
return mysqli_real_escape_string($this->link, $s);
}
function query($query, $die_on_error = true) {
$result = @mysqli_query($this->link, $query);
if (!$result) {
$error = @mysqli_error($this->link);
@mysqli_query($this->link, "ROLLBACK");
user_error("Query $query failed: " . ($this->link ? $error : "No connection"),
$die_on_error ? E_USER_ERROR : E_USER_WARNING);
}
return $result;
}
function fetch_assoc($result) {
return mysqli_fetch_assoc($result);
}
function num_rows($result) {
return mysqli_num_rows($result);
}
function fetch_result($result, $row, $param) {
if (mysqli_data_seek($result, $row)) {
$line = mysqli_fetch_assoc($result);
return $line[$param];
} else {
return false;
}
}
function close() {
return mysqli_close($this->link);
}
function affected_rows($result) {
return mysqli_affected_rows($this->link);
}
function last_error() {
return mysqli_error();
}
function init() {
$this->query("SET time_zone = '+0:0'");
if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) {
$this->query("SET NAMES " . MYSQL_CHARSET);
}
return true;
}
}
?>
tt-rss-1.11/classes/db/pdo.php 0000644 0000000 0000000 00000003700 12254274074 014712 0 ustar root root pdo = new PDO($connstr, $user, $pass);
$this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$this->init();
} catch (PDOException $e) {
die($e->getMessage());
}
return $this->pdo;
}
function escape_string($s, $strip_tags = true) {
if ($strip_tags) $s = strip_tags($s);
$qs = $this->pdo->quote($s);
return mb_substr($qs, 1, mb_strlen($qs)-2);
}
function query($query, $die_on_error = true) {
try {
return new Db_Stmt($this->pdo->query($query));
} catch (PDOException $e) {
user_error($e->getMessage(), $die_on_error ? E_USER_ERROR : E_USER_WARNING);
}
}
function fetch_assoc($result) {
try {
if ($result) {
return $result->fetch();
} else {
return null;
}
} catch (PDOException $e) {
user_error($e->getMessage(), E_USER_WARNING);
}
}
function num_rows($result) {
try {
if ($result) {
return $result->rowCount();
} else {
return false;
}
} catch (PDOException $e) {
user_error($e->getMessage(), E_USER_WARNING);
}
}
function fetch_result($result, $row, $param) {
return $result->fetch_result($row, $param);
}
function close() {
$this->pdo = null;
}
function affected_rows($result) {
try {
if ($result) {
return $result->rowCount();
} else {
return null;
}
} catch (PDOException $e) {
user_error($e->getMessage(), E_USER_WARNING);
}
}
function last_error() {
return join(" ", $this->pdo->errorInfo());
}
function init() {
switch (DB_TYPE) {
case "pgsql":
$this->query("set client_encoding = 'UTF-8'");
$this->query("set datestyle = 'ISO, european'");
$this->query("set TIME ZONE 0");
case "mysql":
$this->query("SET time_zone = '+0:0'");
return;
}
return true;
}
}
?>
tt-rss-1.11/classes/db/pgsql.php 0000644 0000000 0000000 00000003264 12254274074 015263 0 ustar root root 0) {
$string = "$string port=" . $port;
}
$this->link = pg_connect($string);
if (!$this->link) {
die("Unable to connect to database (as $user to $host, database $db):" . pg_last_error());
}
$this->init();
return $this->link;
}
function escape_string($s, $strip_tags = true) {
if ($strip_tags) $s = strip_tags($s);
return pg_escape_string($s);
}
function query($query, $die_on_error = true) {
$result = @pg_query($this->link, $query);
if (!$result) {
$error = @pg_last_error($this->link);
@pg_query($this->link, "ROLLBACK");
$query = htmlspecialchars($query); // just in case
user_error("Query $query failed: " . ($this->link ? $error : "No connection"),
$die_on_error ? E_USER_ERROR : E_USER_WARNING);
}
return $result;
}
function fetch_assoc($result) {
return pg_fetch_assoc($result);
}
function num_rows($result) {
return pg_num_rows($result);
}
function fetch_result($result, $row, $param) {
return pg_fetch_result($result, $row, $param);
}
function close() {
return pg_close($this->link);
}
function affected_rows($result) {
return pg_affected_rows($result);
}
function last_error() {
return pg_last_error($this->link);
}
function init() {
$this->query("set client_encoding = 'UTF-8'");
pg_set_client_encoding("UNICODE");
$this->query("set datestyle = 'ISO, european'");
$this->query("set TIME ZONE 0");
return true;
}
}
?>
tt-rss-1.11/classes/db/prefs.php 0000644 0000000 0000000 00000011005 12254274074 015244 0 ustar root root dbh = Db::get();
$this->cache = array();
if ($_SESSION["uid"]) $this->cache();
}
private function __clone() {
//
}
public static function get() {
if (self::$instance == null)
self::$instance = new self();
return self::$instance;
}
function cache() {
$profile = false;
$user_id = $_SESSION["uid"];
@$profile = $_SESSION["profile"];
if ($profile) {
$profile_qpart = "profile = '$profile' AND";
} else {
$profile_qpart = "profile IS NULL AND";
}
if (get_schema_version() < 63) $profile_qpart = "";
$result = db_query("SELECT
value,ttrss_prefs_types.type_name as type_name,ttrss_prefs.pref_name AS pref_name
FROM
ttrss_user_prefs,ttrss_prefs,ttrss_prefs_types
WHERE
$profile_qpart
ttrss_prefs.pref_name NOT LIKE '_MOBILE%' AND
ttrss_prefs_types.id = type_id AND
owner_uid = '$user_id' AND
ttrss_user_prefs.pref_name = ttrss_prefs.pref_name");
while ($line = db_fetch_assoc($result)) {
if ($user_id == $_SESSION["uid"]) {
$pref_name = $line["pref_name"];
$this->cache[$pref_name]["type"] = $line["type_name"];
$this->cache[$pref_name]["value"] = $line["value"];
}
}
}
function read($pref_name, $user_id = false, $die_on_error = false) {
$pref_name = db_escape_string($pref_name);
$profile = false;
if (!$user_id) {
$user_id = $_SESSION["uid"];
@$profile = $_SESSION["profile"];
} else {
$user_id = sprintf("%d", $user_id);
}
if (isset($this->cache[$pref_name])) {
$tuple = $this->cache[$pref_name];
return $this->convert($tuple["value"], $tuple["type"]);
}
if ($profile) {
$profile_qpart = "profile = '$profile' AND";
} else {
$profile_qpart = "profile IS NULL AND";
}
if (get_schema_version() < 63) $profile_qpart = "";
$result = db_query("SELECT
value,ttrss_prefs_types.type_name as type_name
FROM
ttrss_user_prefs,ttrss_prefs,ttrss_prefs_types
WHERE
$profile_qpart
ttrss_user_prefs.pref_name = '$pref_name' AND
ttrss_prefs_types.id = type_id AND
owner_uid = '$user_id' AND
ttrss_user_prefs.pref_name = ttrss_prefs.pref_name");
if (db_num_rows($result) > 0) {
$value = db_fetch_result($result, 0, "value");
$type_name = db_fetch_result($result, 0, "type_name");
if ($user_id == $_SESSION["uid"]) {
$this->cache[$pref_name]["type"] = $type_name;
$this->cache[$pref_name]["value"] = $value;
}
return $this->convert($value, $type_name);
} else {
user_error("Fatal error, unknown preferences key: $pref_name (owner: $user_id)", $die_on_error ? E_USER_ERROR : E_USER_WARNING);
return null;
}
}
function convert($value, $type_name) {
if ($type_name == "bool") {
return $value == "true";
} else if ($type_name == "integer") {
return (int)$value;
} else {
return $value;
}
}
function write($pref_name, $value, $user_id = false, $strip_tags = true) {
$pref_name = db_escape_string($pref_name);
$value = db_escape_string($value, $strip_tags);
if (!$user_id) {
$user_id = $_SESSION["uid"];
@$profile = $_SESSION["profile"];
} else {
$user_id = sprintf("%d", $user_id);
$prefs_cache = false;
}
if ($profile) {
$profile_qpart = "AND profile = '$profile'";
} else {
$profile_qpart = "AND profile IS NULL";
}
if (get_schema_version() < 63) $profile_qpart = "";
$type_name = "";
$current_value = "";
if (isset($this->cache[$pref_name])) {
$type_name = $this->cache[$pref_name]["type"];
$current_value = $this->cache[$pref_name]["value"];
}
if (!$type_name) {
$result = db_query("SELECT type_name
FROM ttrss_prefs,ttrss_prefs_types
WHERE pref_name = '$pref_name' AND type_id = ttrss_prefs_types.id");
if (db_num_rows($result) > 0)
$type_name = db_fetch_result($result, 0, "type_name");
} else if ($current_value == $value) {
return;
}
if ($type_name) {
if ($type_name == "bool") {
if ($value == "1" || $value == "true") {
$value = "true";
} else {
$value = "false";
}
} else if ($type_name == "integer") {
$value = sprintf("%d", $value);
}
if ($pref_name == 'USER_TIMEZONE' && $value == '') {
$value = 'UTC';
}
db_query("UPDATE ttrss_user_prefs SET
value = '$value' WHERE pref_name = '$pref_name'
$profile_qpart
AND owner_uid = " . $_SESSION["uid"]);
if ($user_id == $_SESSION["uid"]) {
$this->cache[$pref_name]["type"] = $type_name;
$this->cache[$pref_name]["value"] = $value;
}
}
}
}
?>
tt-rss-1.11/classes/db/stmt.php 0000644 0000000 0000000 00000001032 12254274074 015113 0 ustar root root stmt = $stmt;
$this->cache = false;
}
function fetch_result($row, $param) {
if (!$this->cache) {
$this->cache = $this->stmt->fetchAll();
}
if (isset($this->cache[$row])) {
return $this->cache[$row][$param];
} else {
user_error("Unable to jump to row $row", E_USER_WARNING);
return false;
}
}
function rowCount() {
return $this->stmt->rowCount();
}
function fetch() {
return $this->stmt->fetch();
}
}
?>
tt-rss-1.11/classes/dbupdater.php 0000644 0000000 0000000 00000002445 12254274074 015522 0 ustar root root dbh = $dbh;
$this->db_type = $db_type;
$this->need_version = (int) $need_version;
}
function getSchemaVersion() {
$result = db_query("SELECT schema_version FROM ttrss_version");
return (int) db_fetch_result($result, 0, "schema_version");
}
function isUpdateRequired() {
return $this->getSchemaVersion() < $this->need_version;
}
function getSchemaLines($version) {
$filename = "schema/versions/".$this->db_type."/$version.sql";
if (file_exists($filename)) {
return explode(";", preg_replace("/[\r\n]/", "", file_get_contents($filename)));
} else {
return false;
}
}
function performUpdateTo($version) {
if ($this->getSchemaVersion() == $version - 1) {
$lines = $this->getSchemaLines($version);
if (is_array($lines)) {
db_query("BEGIN");
foreach ($lines as $line) {
if (strpos($line, "--") !== 0 && $line) {
db_query($line);
}
}
$db_version = $this->getSchemaVersion();
if ($db_version == $version) {
db_query("COMMIT");
return true;
} else {
db_query("ROLLBACK");
return false;
}
} else {
return true;
}
} else {
return false;
}
}
} ?>
tt-rss-1.11/classes/dlg.php 0000644 0000000 0000000 00000017330 12254274074 014315 0 ustar root root param = $this->dbh->escape_string($_REQUEST["param"]);
return true;
}
return false;
}
function importOpml() {
print __("If you have imported labels and/or filters, you might need to reload preferences to see your new data.") . "
";
print "";
$owner_uid = $_SESSION["uid"];
$this->dbh->query("BEGIN");
print "
";
$opml = new Opml($_REQUEST);
$opml->opml_import($_SESSION["uid"]);
$this->dbh->query("COMMIT");
print " ";
print "
";
print "";
print "".
__('Close this window')." ";
print "
";
print "";
//return;
}
function pubOPMLUrl() {
$url_path = Opml::opml_publish_url();
print __("Your Public OPML URL is:");
print "";
print "";
print "".
__('Generate new URL')." ";
print "".
__('Close this window')." ";
print "
";
//return;
}
function explainError() {
print "";
if ($this->param == 1) {
print __("Update daemon is enabled in configuration, but daemon process is not running, which prevents all feeds from updating. Please start the daemon process or contact instance owner.");
$stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp");
print "
" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp);
}
if ($this->param == 3) {
print __("Update daemon is taking too long to perform a feed update. This could indicate a problem like crash or a hang. Please check the daemon process or contact instance owner.");
$stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp");
print "
" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp);
}
print "
";
print "";
print "".
__('Close this window')." ";
print "
";
//return;
}
function printTagCloud() {
print "";
// from here: http://www.roscripts.com/Create_tag_cloud-71.html
$query = "SELECT tag_name, COUNT(post_int_id) AS count
FROM ttrss_tags WHERE owner_uid = ".$_SESSION["uid"]."
GROUP BY tag_name ORDER BY count DESC LIMIT 50";
$result = $this->dbh->query($query);
$tags = array();
while ($line = $this->dbh->fetch_assoc($result)) {
$tags[$line["tag_name"]] = $line["count"];
}
if(count($tags) == 0 ){ return; }
ksort($tags);
$max_size = 32; // max font size in pixels
$min_size = 11; // min font size in pixels
// largest and smallest array values
$max_qty = max(array_values($tags));
$min_qty = min(array_values($tags));
// find the range of values
$spread = $max_qty - $min_qty;
if ($spread == 0) { // we don't want to divide by zero
$spread = 1;
}
// set the font-size increment
$step = ($max_size - $min_size) / ($spread);
// loop through the tag array
foreach ($tags as $key => $value) {
// calculate font-size
// find the $value in excess of $min_qty
// multiply by the font-size increment ($size)
// and add the $min_size set above
$size = round($min_size + (($value - $min_qty) * $step));
$key_escaped = str_replace("'", "\\'", $key);
echo "
' . $key . ' ';
}
print "
";
print "";
print "".
__('Close this window')." ";
print "
";
}
function printTagSelect() {
print __("Match:"). " " .
" ";
print "".__("Any")." ";
print " ";
print " ";
print "".__("All tags.")."";
print "";
$result = $this->dbh->query("SELECT DISTINCT tag_name FROM ttrss_tags WHERE owner_uid = ".$_SESSION['uid']."
AND LENGTH(tag_name) <= 30 ORDER BY tag_name ASC");
while ($row = $this->dbh->fetch_assoc($result)) {
$tmp = htmlspecialchars($row["tag_name"]);
print "$tmp ";
}
print " ";
print "";
print "" . __('Display entries') . " ";
print " ";
print "" .
__('Close this window') . " ";
print "
";
}
function generatedFeed() {
$this->params = explode(":", $this->param, 3);
$feed_id = $this->dbh->escape_string($this->params[0]);
$is_cat = (bool) $this->params[1];
$key = get_feed_access_key($feed_id, $is_cat);
$url_path = htmlspecialchars($this->params[2]) . "&key=" . $key;
print "".__("You can view this feed as RSS using the following URL:")." ";
print "";
print "";
print "".
__('Generate new URL')." ";
print "".
__('Close this window')." ";
print "
";
//return;
}
function newVersion() {
$version_data = check_for_update();
$version = $version_data['version'];
$id = $version_data['version_id'];
if ($version && $id) {
print "";
print T_sprintf("New version of Tiny Tiny RSS is available (%s).",
"$version ");
print "
";
$details = "http://tt-rss.org/redmine/versions/$id";
$download = "http://tt-rss.org/#Download";
print "".__("You can update using built-in updater in the Preferences or by using update.php")."
";
print "";
print "
".__("See the release notes")." ";
print "
".__("Download")." ";
print "
".
__('Close this window')." ";
} else {
print "
";
print "
".__("Error receiving version information or no new version available.")."
";
print "
";
print "
";
print "".
__('Close this window')." ";
print "
";
}
print "
";
}
}
?>
tt-rss-1.11/classes/feedenclosure.php 0000644 0000000 0000000 00000000140 12254274074 016361 0 ustar root root
tt-rss-1.11/classes/feeditem.php 0000644 0000000 0000000 00000000643 12254274074 015330 0 ustar root root
tt-rss-1.11/classes/feeditem/ 0000755 0000000 0000000 00000000000 12254274074 014614 5 ustar root root tt-rss-1.11/classes/feeditem/atom.php 0000644 0000000 0000000 00000010734 12254274074 016272 0 ustar root root elem->getElementsByTagName("id")->item(0);
if ($id) {
return $id->nodeValue;
} else {
return $this->get_link();
}
}
function get_date() {
$updated = $this->elem->getElementsByTagName("updated")->item(0);
if ($updated) {
return strtotime($updated->nodeValue);
}
$published = $this->elem->getElementsByTagName("published")->item(0);
if ($published) {
return strtotime($published->nodeValue);
}
$date = $this->xpath->query("dc:date", $this->elem)->item(0);
if ($date) {
return strtotime($date->nodeValue);
}
}
function get_link() {
$links = $this->elem->getElementsByTagName("link");
foreach ($links as $link) {
if ($link && $link->hasAttribute("href") &&
(!$link->hasAttribute("rel")
|| $link->getAttribute("rel") == "alternate"
|| $link->getAttribute("rel") == "standout")) {
$base = $this->xpath->evaluate("string(ancestor-or-self::*[@xml:base][1]/@xml:base)", $link);
if ($base)
return rewrite_relative_url($base, $link->getAttribute("href"));
else
return $link->getAttribute("href");
}
}
}
function get_title() {
$title = $this->elem->getElementsByTagName("title")->item(0);
if ($title) {
return $title->nodeValue;
}
}
function get_content() {
$content = $this->elem->getElementsByTagName("content")->item(0);
if ($content) {
if ($content->hasAttribute('type')) {
if ($content->getAttribute('type') == 'xhtml') {
for ($i = 0; $i < $content->childNodes->length; $i++) {
$child = $content->childNodes->item($i);
if ($child->hasChildNodes()) {
return $this->doc->saveXML($child);
}
}
}
}
return $content->nodeValue;
}
}
function get_description() {
$content = $this->elem->getElementsByTagName("summary")->item(0);
if ($content) {
if ($content->hasAttribute('type')) {
if ($content->getAttribute('type') == 'xhtml') {
for ($i = 0; $i < $content->childNodes->length; $i++) {
$child = $content->childNodes->item($i);
if ($child->hasChildNodes()) {
return $this->doc->saveXML($child);
}
}
}
}
return $content->nodeValue;
}
}
function get_categories() {
$categories = $this->elem->getElementsByTagName("category");
$cats = array();
foreach ($categories as $cat) {
if ($cat->hasAttribute("term"))
array_push($cats, $cat->getAttribute("term"));
}
$categories = $this->xpath->query("dc:subject", $this->elem);
foreach ($categories as $cat) {
array_push($cats, $cat->nodeValue);
}
return $cats;
}
function get_enclosures() {
$links = $this->elem->getElementsByTagName("link");
$encs = array();
foreach ($links as $link) {
if ($link && $link->hasAttribute("href") && $link->hasAttribute("rel")) {
if ($link->getAttribute("rel") == "enclosure") {
$enc = new FeedEnclosure();
$enc->type = $link->getAttribute("type");
$enc->link = $link->getAttribute("href");
$enc->length = $link->getAttribute("length");
array_push($encs, $enc);
}
}
}
$enclosures = $this->xpath->query("media:content", $this->elem);
foreach ($enclosures as $enclosure) {
$enc = new FeedEnclosure();
$enc->type = $enclosure->getAttribute("type");
$enc->link = $enclosure->getAttribute("url");
$enc->length = $enclosure->getAttribute("length");
$desc = $this->xpath->query("media:description", $enclosure)->item(0);
if ($desc) $enc->title = strip_tags($desc->nodeValue);
array_push($encs, $enc);
}
$enclosures = $this->xpath->query("media:group", $this->elem);
foreach ($enclosures as $enclosure) {
$enc = new FeedEnclosure();
$content = $this->xpath->query("media:content", $enclosure)->item(0);
$enc->type = $content->getAttribute("type");
$enc->link = $content->getAttribute("url");
$enc->length = $content->getAttribute("length");
$desc = $this->xpath->query("media:description", $content)->item(0);
if ($desc) {
$enc->title = strip_tags($desc->nodeValue);
} else {
$desc = $this->xpath->query("media:description", $enclosure)->item(0);
if ($desc) $enc->title = strip_tags($desc->nodeValue);
}
array_push($encs, $enc);
}
$enclosures = $this->xpath->query("media:thumbnail", $this->elem);
foreach ($enclosures as $enclosure) {
$enc = new FeedEnclosure();
$enc->type = "image/generic";
$enc->link = $enclosure->getAttribute("url");
array_push($encs, $enc);
}
return $encs;
}
}
?>
tt-rss-1.11/classes/feeditem/common.php 0000644 0000000 0000000 00000002173 12254274074 016620 0 ustar root root elem = $elem;
$this->xpath = $xpath;
$this->doc = $doc;
try {
$source = $elem->getElementsByTagName("source")->item(0);
// we don't need element
if ($source)
$elem->removeChild($source);
} catch (DOMException $e) {
//
}
}
function get_author() {
$author = $this->elem->getElementsByTagName("author")->item(0);
if ($author) {
$name = $author->getElementsByTagName("name")->item(0);
if ($name) return $name->nodeValue;
$email = $author->getElementsByTagName("email")->item(0);
if ($email) return $email->nodeValue;
if ($author->nodeValue)
return $author->nodeValue;
}
$author = $this->xpath->query("dc:creator", $this->elem)->item(0);
if ($author) {
return $author->nodeValue;
}
}
// todo
function get_comments_url() {
}
function get_comments_count() {
$comments = $this->xpath->query("slash:comments", $this->elem)->item(0);
if ($comments) {
return $comments->nodeValue;
}
}
}
?>
tt-rss-1.11/classes/feeditem/rss.php 0000644 0000000 0000000 00000007460 12254274074 016143 0 ustar root root elem->getElementsByTagName("guid")->item(0);
if ($id) {
return $id->nodeValue;
} else {
return $this->get_link();
}
}
function get_date() {
$pubDate = $this->elem->getElementsByTagName("pubDate")->item(0);
if ($pubDate) {
return strtotime($pubDate->nodeValue);
}
$date = $this->xpath->query("dc:date", $this->elem)->item(0);
if ($date) {
return strtotime($date->nodeValue);
}
}
function get_link() {
$links = $this->xpath->query("atom:link", $this->elem);
foreach ($links as $link) {
if ($link && $link->hasAttribute("href") &&
(!$link->hasAttribute("rel")
|| $link->getAttribute("rel") == "alternate"
|| $link->getAttribute("rel") == "standout")) {
return $link->getAttribute("href");
}
}
$link = $this->elem->getElementsByTagName("guid")->item(0);
if ($link && $link->hasAttributes() && $link->getAttribute("isPermaLink") == "true") {
return $link->nodeValue;
}
$link = $this->elem->getElementsByTagName("link")->item(0);
if ($link) {
return $link->nodeValue;
}
}
function get_title() {
$title = $this->elem->getElementsByTagName("title")->item(0);
if ($title) {
return $title->nodeValue;
}
}
function get_content() {
$content = $this->xpath->query("content:encoded", $this->elem)->item(0);
if ($content) {
return $content->nodeValue;
}
$content = $this->elem->getElementsByTagName("description")->item(0);
if ($content) {
return $content->nodeValue;
}
}
function get_description() {
$summary = $this->elem->getElementsByTagName("description")->item(0);
if ($summary) {
return $summary->nodeValue;
}
}
function get_categories() {
$categories = $this->elem->getElementsByTagName("category");
$cats = array();
foreach ($categories as $cat) {
array_push($cats, $cat->nodeValue);
}
$categories = $this->xpath->query("dc:subject", $this->elem);
foreach ($categories as $cat) {
array_push($cats, $cat->nodeValue);
}
return $cats;
}
function get_enclosures() {
$enclosures = $this->elem->getElementsByTagName("enclosure");
$encs = array();
foreach ($enclosures as $enclosure) {
$enc = new FeedEnclosure();
$enc->type = $enclosure->getAttribute("type");
$enc->link = $enclosure->getAttribute("url");
$enc->length = $enclosure->getAttribute("length");
array_push($encs, $enc);
}
$enclosures = $this->xpath->query("media:content", $this->elem);
foreach ($enclosures as $enclosure) {
$enc = new FeedEnclosure();
$enc->type = $enclosure->getAttribute("type");
$enc->link = $enclosure->getAttribute("url");
$enc->length = $enclosure->getAttribute("length");
$desc = $this->xpath->query("media:description", $enclosure)->item(0);
if ($desc) $enc->title = strip_tags($desc->nodeValue);
array_push($encs, $enc);
}
$enclosures = $this->xpath->query("media:group", $this->elem);
foreach ($enclosures as $enclosure) {
$enc = new FeedEnclosure();
$content = $this->xpath->query("media:content", $enclosure)->item(0);
$enc->type = $content->getAttribute("type");
$enc->link = $content->getAttribute("url");
$enc->length = $content->getAttribute("length");
$desc = $this->xpath->query("media:description", $content)->item(0);
if ($desc) {
$enc->title = strip_tags($desc->nodeValue);
} else {
$desc = $this->xpath->query("media:description", $enclosure)->item(0);
if ($desc) $enc->title = strip_tags($desc->nodeValue);
}
array_push($encs, $enc);
}
$enclosures = $this->xpath->query("media:thumbnail", $this->elem);
foreach ($enclosures as $enclosure) {
$enc = new FeedEnclosure();
$enc->type = "image/generic";
$enc->link = $enclosure->getAttribute("url");
array_push($encs, $enc);
}
return $encs;
}
}
?>
tt-rss-1.11/classes/feedparser.php 0000644 0000000 0000000 00000014576 12254274074 015700 0 ustar root root )/s', $data, $matches) === 1) {
$data = mb_convert_encoding($data, 'UTF-8', $matches[2]);
$data = preg_replace('/^<\?xml[\t\n\r ].*?\?>/s', $matches[1] . "UTF-8" . $matches[3] , $data);
}
return $data;
}
function __construct($data) {
libxml_use_internal_errors(true);
libxml_clear_errors();
$this->doc = new DOMDocument();
$this->doc->loadXML($data);
mb_substitute_character("none");
$error = libxml_get_last_error();
// libxml compiled without iconv?
if ($error && $error->code == 32) {
$data = $this->normalize_encoding($data);
if ($data) {
libxml_clear_errors();
$this->doc = new DOMDocument();
$this->doc->loadXML($data);
$error = libxml_get_last_error();
}
}
// some terrible invalid unicode entity?
if ($error) {
foreach (libxml_get_errors() as $err) {
if ($err->code == 9) {
// if the source feed is not in utf8, next conversion will fail
$data = $this->normalize_encoding($data);
// remove dangling bytes
$data = mb_convert_encoding($data, 'UTF-8', 'UTF-8');
// apparently not all UTF-8 characters are valid for XML
$data = preg_replace('/[^\x{0009}\x{000a}\x{000d}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}]+/u', ' ', $data);
if ($data) {
libxml_clear_errors();
$this->doc = new DOMDocument();
$this->doc->loadXML($data);
$error = libxml_get_last_error();
}
break;
}
}
}
if ($error) {
foreach (libxml_get_errors() as $error) {
if ($error->level == LIBXML_ERR_FATAL) {
if(!isset($this->error)) //currently only the first error is reported
$this->error = $this->format_error($error);
$this->libxml_errors [] = $this->format_error($error);
}
}
}
libxml_clear_errors();
$this->items = array();
}
function init() {
$root = $this->doc->firstChild;
$xpath = new DOMXPath($this->doc);
$xpath->registerNamespace('atom', 'http://www.w3.org/2005/Atom');
$xpath->registerNamespace('atom03', 'http://purl.org/atom/ns#');
$xpath->registerNamespace('media', 'http://search.yahoo.com/mrss/');
$xpath->registerNamespace('rdf', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#');
$xpath->registerNamespace('slash', 'http://purl.org/rss/1.0/modules/slash/');
$xpath->registerNamespace('dc', 'http://purl.org/dc/elements/1.1/');
$xpath->registerNamespace('content', 'http://purl.org/rss/1.0/modules/content/');
$this->xpath = $xpath;
$root = $xpath->query("(//atom03:feed|//atom:feed|//channel|//rdf:rdf|//rdf:RDF)");
if ($root && $root->length > 0) {
$root = $root->item(0);
if ($root) {
switch (mb_strtolower($root->tagName)) {
case "rdf:rdf":
$this->type = $this::FEED_RDF;
break;
case "channel":
$this->type = $this::FEED_RSS;
break;
case "feed":
$this->type = $this::FEED_ATOM;
break;
default:
if( !isset($this->error) ){
$this->error = "Unknown/unsupported feed type";
}
return;
}
}
switch ($this->type) {
case $this::FEED_ATOM:
$title = $xpath->query("//atom:feed/atom:title")->item(0);
if (!$title)
$title = $xpath->query("//atom03:feed/atom03:title")->item(0);
if ($title) {
$this->title = $title->nodeValue;
}
$link = $xpath->query("//atom:feed/atom:link[not(@rel)]")->item(0);
if (!$link)
$link = $xpath->query("//atom03:feed/atom03:link[not(@rel)]")->item(0);
if ($link && $link->hasAttributes()) {
$this->link = $link->getAttribute("href");
}
$articles = $xpath->query("//atom:entry");
if (!$articles || $articles->length == 0)
$articles = $xpath->query("//atom03:entry");
foreach ($articles as $article) {
array_push($this->items, new FeedItem_Atom($article, $this->doc, $this->xpath));
}
break;
case $this::FEED_RSS:
$title = $xpath->query("//channel/title")->item(0);
if ($title) {
$this->title = $title->nodeValue;
}
$link = $xpath->query("//channel/link")->item(0);
if ($link) {
if ($link->getAttribute("href"))
$this->link = $link->getAttribute("href");
else if ($link->nodeValue)
$this->link = $link->nodeValue;
}
$articles = $xpath->query("//channel/item");
foreach ($articles as $article) {
array_push($this->items, new FeedItem_RSS($article, $this->doc, $this->xpath));
}
break;
case $this::FEED_RDF:
$xpath->registerNamespace('rssfake', 'http://purl.org/rss/1.0/');
$title = $xpath->query("//rssfake:channel/rssfake:title")->item(0);
if ($title) {
$this->title = $title->nodeValue;
}
$link = $xpath->query("//rssfake:channel/rssfake:link")->item(0);
if ($link) {
$this->link = $link->nodeValue;
}
$articles = $xpath->query("//rssfake:item");
foreach ($articles as $article) {
array_push($this->items, new FeedItem_RSS($article, $this->doc, $this->xpath));
}
break;
}
} else {
if( !isset($this->error) ){
$this->error = "Unknown/unsupported feed type";
}
return;
}
}
function format_error($error) {
if ($error) {
return sprintf("LibXML error %s at line %d (column %d): %s",
$error->code, $error->line, $error->column,
$error->message);
} else {
return "";
}
}
function error() {
return $this->error;
}
function errors() {
return $this->libxml_errors;
}
function get_link() {
return $this->link;
}
function get_title() {
return $this->title;
}
function get_items() {
return $this->items;
}
function get_links($rel) {
$rv = array();
switch ($this->type) {
case $this::FEED_ATOM:
$links = $this->xpath->query("//atom:feed/atom:link");
foreach ($links as $link) {
if (!$rel || $link->hasAttribute('rel') && $link->getAttribute('rel') == $rel) {
array_push($rv, $link->getAttribute('href'));
}
}
break;
case $this::FEED_RSS:
$links = $this->xpath->query("//atom:link");
foreach ($links as $link) {
if (!$rel || $link->hasAttribute('rel') && $link->getAttribute('rel') == $rel) {
array_push($rv, $link->getAttribute('href'));
}
}
break;
}
return $rv;
}
} ?>
tt-rss-1.11/classes/feeds.php 0000644 0000000 0000000 00000113102 12254274074 014627 0 ustar root root ";
$reply .= " ";
$reply .= "";
if ($feed_site_url) {
$last_updated = T_sprintf("Last updated: %s",
$feed_last_updated);
$target = "target=\"_blank\"";
$reply .= "".
truncate_string($feed_title,30)." ";
if ($error) {
$error = htmlspecialchars($error);
$reply .= " ";
}
} else {
$reply .= $feed_title;
}
$reply .= " ";
$reply .= "
";
$reply .= "";
// left part
$reply .= __('Select:')."
".__('All')." ,
".__('Unread')." ,
".__('Invert')." ,
".__('None')." ";
$reply .= " ";
$reply .= "";
$reply .= "".__('More...')." ";
$reply .= "".__('Selection toggle:')." ";
$reply .= "".__('Unread')."
".__('Starred')."
".__('Published')." ";
$reply .= "".__('Selection:')." ";
$reply .= "".__('Mark as read')." ";
$reply .= "".__('Set score')." ";
if ($feed_id != "0") {
$reply .= "".__('Archive')." ";
} else {
$reply .= "".__('Move back')." ";
$reply .= "".__('Delete')." ";
}
if (PluginHost::getInstance()->get_plugin("mail")) {
$reply .= "".__('Forward by email').
" ";
}
if (PluginHost::getInstance()->get_plugin("mailto")) {
$reply .= "".__('Forward by email').
" ";
}
$reply .= "".__('Feed:')." ";
//$reply .= "".__('Mark as read')." ";
$reply .= "".__('View as RSS')." ";
$reply .= " ";
//$reply .= "";
//$reply .= "get_hooks(PluginHost::HOOK_HEADLINE_TOOLBAR_BUTTON) as $p) {
echo $p->hook_headline_toolbar_button($feed_id, $is_cat);
}
return $reply;
}
private function format_headlines_list($feed, $method, $view_mode, $limit, $cat_view,
$next_unread_feed, $offset, $vgr_last_feed = false,
$override_order = false, $include_children = false) {
if (isset($_REQUEST["DevForceUpdate"]))
header("Content-Type: text/plain; charset=utf-8");
$disable_cache = false;
$reply = array();
$rgba_cache = array();
$timing_info = microtime(true);
$topmost_article_ids = array();
if (!$offset) $offset = 0;
if ($method == "undefined") $method = "";
$method_split = explode(":", $method);
if ($method == "ForceUpdate" && $feed > 0 && is_numeric($feed)) {
// Update the feed if required with some basic flood control
$result = $this->dbh->query(
"SELECT cache_images,".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated
FROM ttrss_feeds WHERE id = '$feed'");
if ($this->dbh->num_rows($result) != 0) {
$last_updated = strtotime($this->dbh->fetch_result($result, 0, "last_updated"));
$cache_images = sql_bool_to_bool($this->dbh->fetch_result($result, 0, "cache_images"));
if (!$cache_images && time() - $last_updated > 120 || isset($_REQUEST['DevForceUpdate'])) {
include "rssfuncs.php";
update_rss_feed($feed, true, true);
} else {
$this->dbh->query("UPDATE ttrss_feeds SET last_updated = '1970-01-01', last_update_started = '1970-01-01'
WHERE id = '$feed'");
}
}
}
if ($method_split[0] == "MarkAllReadGR") {
catchup_feed($method_split[1], false);
}
// FIXME: might break tag display?
if (is_numeric($feed) && $feed > 0 && !$cat_view) {
$result = $this->dbh->query(
"SELECT id FROM ttrss_feeds WHERE id = '$feed' LIMIT 1");
if ($this->dbh->num_rows($result) == 0) {
$reply['content'] = "".__('Feed not found.')."
";
}
}
@$search = $this->dbh->escape_string($_REQUEST["query"]);
if ($search) {
$disable_cache = true;
}
@$search_mode = $this->dbh->escape_string($_REQUEST["search_mode"]);
if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H0", $timing_info);
// error_log("format_headlines_list: [" . $feed . "] method [" . $method . "]");
if($search_mode == '' && $method != '' ){
$search_mode = $method;
}
// error_log("search_mode: " . $search_mode);
if (!$cat_view && is_numeric($feed) && $feed < PLUGIN_FEED_BASE_INDEX && $feed > LABEL_BASE_INDEX) {
$handler = PluginHost::getInstance()->get_feed_handler(
PluginHost::feed_to_pfeed_id($feed));
// function queryFeedHeadlines($feed, $limit, $view_mode, $cat_view, $search, $search_mode, $override_order = false, $offset = 0, $owner_uid = 0, $filter = false, $since_id = 0, $include_children = false, $ignore_vfeed_group = false) {
if ($handler) {
$options = array(
"limit" => $limit,
"view_mode" => $view_mode,
"cat_view" => $cat_view,
"search" => $search,
"search_mode" => $search_mode,
"override_order" => $override_order,
"offset" => $offset,
"owner_uid" => $_SESSION["uid"],
"filter" => false,
"since_id" => 0,
"include_children" => $include_children);
$qfh_ret = $handler->get_headlines(PluginHost::feed_to_pfeed_id($feed),
$options);
}
} else {
$qfh_ret = queryFeedHeadlines($feed, $limit, $view_mode, $cat_view,
$search, $search_mode, $override_order, $offset, 0,
false, 0, $include_children);
}
if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H1", $timing_info);
$result = $qfh_ret[0];
$feed_title = $qfh_ret[1];
$feed_site_url = $qfh_ret[2];
$last_error = $qfh_ret[3];
$last_updated = strpos($qfh_ret[4], '1970-') === FALSE ?
make_local_datetime($qfh_ret[4], false) : __("Never");
$highlight_words = $qfh_ret[5];
$vgroup_last_feed = $vgr_last_feed;
$reply['toolbar'] = $this->format_headline_subtoolbar($feed_site_url,
$feed_title,
$feed, $cat_view, $search, $search_mode, $view_mode,
$last_error, $last_updated);
$headlines_count = $this->dbh->num_rows($result);
/* if (get_pref('COMBINED_DISPLAY_MODE')) {
$button_plugins = array();
foreach (explode(",", ARTICLE_BUTTON_PLUGINS) as $p) {
$pclass = "button_" . trim($p);
if (class_exists($pclass)) {
$plugin = new $pclass();
array_push($button_plugins, $plugin);
}
}
} */
if ($this->dbh->num_rows($result) > 0) {
$lnum = $offset;
$num_unread = 0;
$cur_feed_title = '';
$fresh_intl = get_pref("FRESH_ARTICLE_MAX_AGE") * 60 * 60;
if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PS", $timing_info);
$expand_cdm = get_pref('CDM_EXPANDED');
while ($line = $this->dbh->fetch_assoc($result)) {
$line["content_preview"] = "— " . truncate_string(strip_tags($line["content"]), 250);
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) {
$line = $p->hook_query_headlines($line, 250, false);
}
if (get_pref('SHOW_CONTENT_PREVIEW')) {
$content_preview = $line["content_preview"];
}
$id = $line["id"];
$feed_id = $line["feed_id"];
$label_cache = $line["label_cache"];
$labels = false;
if ($label_cache) {
$label_cache = json_decode($label_cache, true);
if ($label_cache) {
if ($label_cache["no-labels"] == 1)
$labels = array();
else
$labels = $label_cache;
}
}
if (!is_array($labels)) $labels = get_article_labels($id);
$labels_str = "";
$labels_str .= format_article_labels($labels, $id);
$labels_str .= " ";
if (count($topmost_article_ids) < 3) {
array_push($topmost_article_ids, $id);
}
$class = "";
if (sql_bool_to_bool($line["unread"])) {
$class .= " Unread";
++$num_unread;
}
if (sql_bool_to_bool($line["marked"])) {
$marked_pic = " ";
$class .= " marked";
} else {
$marked_pic = " ";
}
if (sql_bool_to_bool($line["published"])) {
$published_pic = " ";
$class .= " published";
} else {
$published_pic = " ";
}
# $content_link = "" .
# $line["title"] . " ";
# $content_link = "" .
# $line["title"] . " ";
# $content_link = "" .
# $line["title"] . " ";
$updated_fmt = make_local_datetime($line["updated"], false);
$date_entered_fmt = T_sprintf("Imported at %s",
make_local_datetime($line["date_entered"], false));
$score = $line["score"];
$score_pic = "images/" . get_score_pic($score);
/* $score_title = __("(Click to change)");
$score_pic = " "; */
$score_pic = " ";
if ($score > 500) {
$hlc_suffix = "high";
} else if ($score < -100) {
$hlc_suffix = "low";
} else {
$hlc_suffix = "";
}
$entry_author = $line["author"];
if ($entry_author) {
$entry_author = " — $entry_author";
}
$has_feed_icon = feed_has_icon($feed_id);
if ($has_feed_icon) {
$feed_icon_img = " ";
} else {
$feed_icon_img = " ";
}
$entry_site_url = $line["site_url"];
//setting feed headline background color, needs to change text color based on dark/light
$fav_color = $line['favicon_avg_color'];
require_once "colors.php";
if ($fav_color && $fav_color != 'fail') {
if (!isset($rgba_cache[$feed_id])) {
$rgba_cache[$feed_id] = join(",", _color_unpack($fav_color));
}
}
if (!get_pref('COMBINED_DISPLAY_MODE')) {
if (get_pref('VFEED_GROUP_BY_FEED')) {
if ($feed_id != $vgroup_last_feed && $line["feed_title"]) {
$cur_feed_title = $line["feed_title"];
$vgroup_last_feed = $feed_id;
$cur_feed_title = htmlspecialchars($cur_feed_title);
$vf_catchup_link = "".__('mark feed as read')." ";
$reply['content'] .= "";
}
}
$mouseover_attrs = "onmouseover='postMouseIn(event, $id)'
onmouseout='postMouseOut($id)'";
$reply['content'] .= "";
$reply['content'] .= "
";
$reply['content'] .= " ";
$reply['content'] .= "$marked_pic";
$reply['content'] .= "$published_pic";
$reply['content'] .= "
";
$reply['content'] .= "
";
$reply['content'] .= "
";
if (!get_pref('VFEED_GROUP_BY_FEED')) {
if (@$line["feed_title"]) {
$rgba = @$rgba_cache[$feed_id];
$reply['content'] .= "".
truncate_string($line["feed_title"],30)." ";
}
}
$reply['content'] .= "$updated_fmt
";
$reply['content'] .= "
";
$reply['content'] .= $score_pic;
if ($line["feed_title"] && !get_pref('VFEED_GROUP_BY_FEED')) {
$reply['content'] .= "
$feed_icon_img";
}
$reply['content'] .= "
";
$reply['content'] .= "
";
} else {
if ($line["tag_cache"])
$tags = explode(",", $line["tag_cache"]);
else
$tags = false;
$line["content"] = sanitize($line["content"],
sql_bool_to_bool($line['hide_images']), false, $entry_site_url, $highlight_words, $line["id"]);
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_CDM) as $p) {
$line = $p->hook_render_article_cdm($line);
}
if (get_pref('VFEED_GROUP_BY_FEED') && $line["feed_title"]) {
if ($feed_id != $vgroup_last_feed) {
$cur_feed_title = $line["feed_title"];
$vgroup_last_feed = $feed_id;
$cur_feed_title = htmlspecialchars($cur_feed_title);
$vf_catchup_link = "".__('mark feed as read')." ";
$has_feed_icon = feed_has_icon($feed_id);
if ($has_feed_icon) {
$feed_icon_img = " ";
} else {
//$feed_icon_img = " ";
}
$reply['content'] .= "";
}
}
$mouseover_attrs = "onmouseover='postMouseIn(event, $id)'
onmouseout='postMouseOut($id)'";
$expanded_class = $expand_cdm ? "expanded" : "expandable";
$reply['content'] .= "";
$reply['content'] .= "";
$reply['content'] .= "
";
$reply['content'] .= "
";
if ($line['note']) {
$reply['content'] .= format_article_note($id, $line['note']);
}
$reply['content'] .= "
";
if (!$line['lang']) $line['lang'] = 'en';
$reply['content'] .= "
";
if ($line["orig_feed_id"]) {
$tmp_result = $this->dbh->query("SELECT * FROM ttrss_archived_feeds
WHERE id = ".$line["orig_feed_id"]);
if ($this->dbh->num_rows($tmp_result) != 0) {
$reply['content'] .= "
";
$reply['content'] .= __("Originally from:");
$reply['content'] .= " ";
$tmp_line = $this->dbh->fetch_assoc($tmp_result);
$reply['content'] .= "
" .
$tmp_line['title'] . " ";
$reply['content'] .= " ";
$reply['content'] .= "
";
$reply['content'] .= " ";
$reply['content'] .= "
";
}
}
$reply['content'] .= "
";
// if (!$expand_cdm) {
$reply['content'] .= "";
$reply['content'] .= htmlspecialchars($line["content"]);
$reply['content'] .= "";
$always_display_enclosures = sql_bool_to_bool($line["always_display_enclosures"]);
$reply['content'] .= format_article_enclosures($id, $always_display_enclosures, $line["content"], sql_bool_to_bool($line["hide_images"]));
$reply['content'] .= " ";
$reply['content'] .= "";
$reply['content'] .= "
";
$reply['content'] .= "
";
}
++$lnum;
}
if ($_REQUEST["debug"]) $timing_info = print_checkpoint("PE", $timing_info);
} else {
$message = "";
switch ($view_mode) {
case "unread":
$message = __("No unread articles found to display.");
break;
case "updated":
$message = __("No updated articles found to display.");
break;
case "marked":
$message = __("No starred articles found to display.");
break;
default:
if ($feed < LABEL_BASE_INDEX) {
$message = __("No articles found to display. You can assign articles to labels manually from article header context menu (applies to all selected articles) or use a filter.");
} else {
$message = __("No articles found to display.");
}
}
if (!$offset && $message) {
$reply['content'] .= "$message";
$reply['content'] .= "
";
$result = $this->dbh->query("SELECT ".SUBSTRING_FOR_DATE."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds
WHERE owner_uid = " . $_SESSION['uid']);
$last_updated = $this->dbh->fetch_result($result, 0, "last_updated");
$last_updated = make_local_datetime($last_updated, false);
$reply['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated);
$result = $this->dbh->query("SELECT COUNT(id) AS num_errors
FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
$num_errors = $this->dbh->fetch_result($result, 0, "num_errors");
if ($num_errors > 0) {
$reply['content'] .= " ";
$reply['content'] .= "".
__('Some feeds have update errors (click for details)')." ";
}
$reply['content'] .= "
";
}
}
if ($_REQUEST["debug"]) $timing_info = print_checkpoint("H2", $timing_info);
return array($topmost_article_ids, $headlines_count, $feed, $disable_cache,
$vgroup_last_feed, $reply);
}
function catchupAll() {
$this->dbh->query("UPDATE ttrss_user_entries SET
last_read = NOW(), unread = false WHERE unread = true AND owner_uid = " . $_SESSION["uid"]);
ccache_zero_all($_SESSION["uid"]);
}
function view() {
$timing_info = microtime(true);
$reply = array();
if ($_REQUEST["debug"]) $timing_info = print_checkpoint("0", $timing_info);
$omode = $this->dbh->escape_string($_REQUEST["omode"]);
$feed = $this->dbh->escape_string($_REQUEST["feed"]);
$method = $this->dbh->escape_string($_REQUEST["m"]);
$view_mode = $this->dbh->escape_string($_REQUEST["view_mode"]);
$limit = 30;
@$cat_view = $_REQUEST["cat"] == "true";
@$next_unread_feed = $this->dbh->escape_string($_REQUEST["nuf"]);
@$offset = $this->dbh->escape_string($_REQUEST["skip"]);
@$vgroup_last_feed = $this->dbh->escape_string($_REQUEST["vgrlf"]);
$order_by = $this->dbh->escape_string($_REQUEST["order_by"]);
if (is_numeric($feed)) $feed = (int) $feed;
/* Feed -5 is a special case: it is used to display auxiliary information
* when there's nothing to load - e.g. no stuff in fresh feed */
if ($feed == -5) {
print json_encode($this->generate_dashboard_feed());
return;
}
$result = false;
if ($feed < LABEL_BASE_INDEX) {
$label_feed = feed_to_label_id($feed);
$result = $this->dbh->query("SELECT id FROM ttrss_labels2 WHERE
id = '$label_feed' AND owner_uid = " . $_SESSION['uid']);
} else if (!$cat_view && is_numeric($feed) && $feed > 0) {
$result = $this->dbh->query("SELECT id FROM ttrss_feeds WHERE
id = '$feed' AND owner_uid = " . $_SESSION['uid']);
} else if ($cat_view && is_numeric($feed) && $feed > 0) {
$result = $this->dbh->query("SELECT id FROM ttrss_feed_categories WHERE
id = '$feed' AND owner_uid = " . $_SESSION['uid']);
}
if ($result && $this->dbh->num_rows($result) == 0) {
print json_encode($this->generate_error_feed(__("Feed not found.")));
return;
}
/* Updating a label ccache means recalculating all of the caches
* so for performance reasons we don't do that here */
if ($feed >= 0) {
ccache_update($feed, $_SESSION["uid"], $cat_view);
}
set_pref("_DEFAULT_VIEW_MODE", $view_mode);
set_pref("_DEFAULT_VIEW_ORDER_BY", $order_by);
/* bump login timestamp if needed */
if (time() - $_SESSION["last_login_update"] > 3600) {
$this->dbh->query("UPDATE ttrss_users SET last_login = NOW() WHERE id = " .
$_SESSION["uid"]);
$_SESSION["last_login_update"] = time();
}
if (!$cat_view && is_numeric($feed) && $feed > 0) {
$this->dbh->query("UPDATE ttrss_feeds SET last_viewed = NOW()
WHERE id = '$feed' AND owner_uid = ".$_SESSION["uid"]);
}
$reply['headlines'] = array();
if (!$next_unread_feed)
$reply['headlines']['id'] = $feed;
else
$reply['headlines']['id'] = $next_unread_feed;
$reply['headlines']['is_cat'] = (bool) $cat_view;
$override_order = false;
switch ($order_by) {
case "title":
$override_order = "ttrss_entries.title";
break;
case "date_reverse":
$override_order = "score DESC, date_entered, updated";
break;
case "feed_dates":
$override_order = "updated DESC";
break;
}
if ($_REQUEST["debug"]) $timing_info = print_checkpoint("04", $timing_info);
$ret = $this->format_headlines_list($feed, $method,
$view_mode, $limit, $cat_view, $next_unread_feed, $offset,
$vgroup_last_feed, $override_order, true);
//$topmost_article_ids = $ret[0];
$headlines_count = $ret[1];
$returned_feed = $ret[2];
$disable_cache = $ret[3];
$vgroup_last_feed = $ret[4];
$reply['headlines']['content'] =& $ret[5]['content'];
$reply['headlines']['toolbar'] =& $ret[5]['toolbar'];
if ($_REQUEST["debug"]) $timing_info = print_checkpoint("05", $timing_info);
$reply['headlines-info'] = array("count" => (int) $headlines_count,
"vgroup_last_feed" => $vgroup_last_feed,
"disable_cache" => (bool) $disable_cache);
if ($_REQUEST["debug"]) $timing_info = print_checkpoint("30", $timing_info);
$reply['runtime-info'] = make_runtime_info();
print json_encode($reply);
}
private function generate_dashboard_feed() {
$reply = array();
$reply['headlines']['id'] = -5;
$reply['headlines']['is_cat'] = false;
$reply['headlines']['toolbar'] = '';
$reply['headlines']['content'] = "".__('No feed selected.');
$reply['headlines']['content'] .= "
";
$result = $this->dbh->query("SELECT ".SUBSTRING_FOR_DATE."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds
WHERE owner_uid = " . $_SESSION['uid']);
$last_updated = $this->dbh->fetch_result($result, 0, "last_updated");
$last_updated = make_local_datetime($last_updated, false);
$reply['headlines']['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated);
$result = $this->dbh->query("SELECT COUNT(id) AS num_errors
FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
$num_errors = $this->dbh->fetch_result($result, 0, "num_errors");
if ($num_errors > 0) {
$reply['headlines']['content'] .= " ";
$reply['headlines']['content'] .= "".
__('Some feeds have update errors (click for details)')." ";
}
$reply['headlines']['content'] .= "
";
$reply['headlines-info'] = array("count" => 0,
"vgroup_last_feed" => '',
"unread" => 0,
"disable_cache" => true);
return $reply;
}
private function generate_error_feed($error) {
$reply = array();
$reply['headlines']['id'] = -6;
$reply['headlines']['is_cat'] = false;
$reply['headlines']['toolbar'] = '';
$reply['headlines']['content'] = "
". $error . "
";
$reply['headlines-info'] = array("count" => 0,
"vgroup_last_feed" => '',
"unread" => 0,
"disable_cache" => true);
return $reply;
}
function quickAddFeed() {
print "
";
print "
";
print "
";
print_notice("Provided URL is a HTML page referencing multiple feeds, please select required feed from the dropdown menu below.");
print "
";
print "
".__("Feed or site URL")."
";
print "
";
print "
";
print "
";
print "
";
if (get_pref('ENABLE_FEED_CATS')) {
print __('Place in category:') . " ";
print_feed_cat_select("cat", false, 'dojoType="dijit.form.Select"');
}
print "
";
print '
' . __('Available feeds') . '
'.
'
'.
'
';
print "
";
print "
".
__('This feed requires authentication.')."
";
print "";
print "
".__('Subscribe')." ";
if (!(defined('_DISABLE_FEED_BROWSER') && _DISABLE_FEED_BROWSER)) {
print "".__('More feeds')." ";
}
print "".__('Cancel')."
";
//return;
}
function feedBrowser() {
if (defined('_DISABLE_FEED_BROWSER') && _DISABLE_FEED_BROWSER) return;
$browser_search = $this->dbh->escape_string($_REQUEST["search"]);
print "
";
print "
";
print "
";
print "
" . __('Popular feeds') . "
" . __('Feed archive') . "
";
print __("limit:");
print "
";
foreach (array(25, 50, 100, 200) as $l) {
$issel = ($l == $limit) ? "selected=\"1\"" : "";
print "$l ";
}
print " ";
print "
";
$owner_uid = $_SESSION["uid"];
require_once "feedbrowser.php";
print "
";
print make_feed_browser($search, 25);
print " ";
print "
".__('Subscribe')."
".__('Remove')."
".__('Cancel')."
";
}
function search() {
$this->params = explode(":", $this->dbh->escape_string($_REQUEST["param"]), 2);
$active_feed_id = sprintf("%d", $this->params[0]);
$is_cat = $this->params[1] != "false";
print "
".__('Look for')."
";
print "
";
print " ";
print "
".__('Limit search to:')." ";
print "
".__('All feeds')." ";
$feed_title = getFeedTitle($active_feed_id);
if (!$is_cat) {
$feed_cat_title = getFeedCatTitle($active_feed_id);
} else {
$feed_cat_title = getCategoryTitle($active_feed_id);
}
if ($active_feed_id && !$is_cat) {
print "$feed_title ";
} else {
print "".__('This feed')." ";
}
if ($is_cat) {
$cat_preselected = "selected=\"1\"";
}
if (get_pref('ENABLE_FEED_CATS') && ($active_feed_id > 0 || $is_cat)) {
print "$feed_cat_title ";
} else {
//print "".__('This category')." ";
}
print " ";
print "";
print "
";
}
}
?>
tt-rss-1.11/classes/handler.php 0000644 0000000 0000000 00000000461 12254274074 015161 0 ustar root root dbh = Db::get();
$this->args = $args;
}
function csrf_ignore($method) {
return true;
}
function before($method) {
return true;
}
function after() {
return true;
}
}
?>
tt-rss-1.11/classes/handler/ 0000755 0000000 0000000 00000000000 12254274074 014447 5 ustar root root tt-rss-1.11/classes/handler/protected.php 0000644 0000000 0000000 00000000213 12254274074 017145 0 ustar root root
tt-rss-1.11/classes/handler/public.php 0000644 0000000 0000000 00000072204 12254274074 016443 0 ustar root root dbh->num_rows($result) != 0) {
$ts = strtotime($this->dbh->fetch_result($result, 0, $date_check_field));
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) &&
strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $ts) {
header('HTTP/1.0 304 Not Modified');
return;
}
$last_modified = gmdate("D, d M Y H:i:s", $ts) . " GMT";
header("Last-Modified: $last_modified", true);
}
$qfh_ret = queryFeedHeadlines($feed,
$limit, $view_mode, $is_cat, $search, $search_mode,
$date_sort_field, $offset, $owner_uid,
false, 0, false, true);
$result = $qfh_ret[0];
$feed_title = htmlspecialchars($qfh_ret[1]);
$feed_site_url = $qfh_ret[2];
$last_error = $qfh_ret[3];
$feed_self_url = get_self_url_prefix() .
"/public.php?op=rss&id=$feed&key=" .
get_feed_access_key($feed, false, $owner_uid);
if (!$feed_site_url) $feed_site_url = get_self_url_prefix();
if ($format == 'atom') {
$tpl = new MiniTemplator;
$tpl->readTemplateFromFile("templates/generated_feed.txt");
$tpl->setVariable('FEED_TITLE', $feed_title, true);
$tpl->setVariable('VERSION', VERSION, true);
$tpl->setVariable('FEED_URL', htmlspecialchars($feed_self_url), true);
if (PUBSUBHUBBUB_HUB && $feed == -2) {
$tpl->setVariable('HUB_URL', htmlspecialchars(PUBSUBHUBBUB_HUB), true);
$tpl->addBlock('feed_hub');
}
$tpl->setVariable('SELF_URL', htmlspecialchars(get_self_url_prefix()), true);
while ($line = $this->dbh->fetch_assoc($result)) {
$line["content_preview"] = truncate_string(strip_tags($line["content"]), 100, '...');
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) {
$line = $p->hook_query_headlines($line);
}
$tpl->setVariable('ARTICLE_ID',
htmlspecialchars($orig_guid ? $line['link'] :
get_self_url_prefix() .
"/public.php?url=" . urlencode($line['link'])), true);
$tpl->setVariable('ARTICLE_LINK', htmlspecialchars($line['link']), true);
$tpl->setVariable('ARTICLE_TITLE', htmlspecialchars($line['title']), true);
$tpl->setVariable('ARTICLE_EXCERPT', $line["content_preview"], true);
$content = sanitize($line["content"], false, $owner_uid);
if ($line['note']) {
$content = "
Article note: " . $line['note'] . "
" .
$content;
$tpl->setVariable('ARTICLE_NOTE', htmlspecialchars($line['note']), true);
}
$tpl->setVariable('ARTICLE_CONTENT', $content, true);
$tpl->setVariable('ARTICLE_UPDATED_ATOM',
date('c', strtotime($line["updated"])), true);
$tpl->setVariable('ARTICLE_UPDATED_RFC822',
date(DATE_RFC822, strtotime($line["updated"])), true);
$tpl->setVariable('ARTICLE_AUTHOR', htmlspecialchars($line['author']), true);
$tpl->setVariable('ARTICLE_SOURCE_LINK', htmlspecialchars($line['site_url']), true);
$tpl->setVariable('ARTICLE_SOURCE_TITLE', htmlspecialchars($line['feed_title'] ? $line['feed_title'] : $feed_title), true);
$tags = get_article_tags($line["id"], $owner_uid);
foreach ($tags as $tag) {
$tpl->setVariable('ARTICLE_CATEGORY', htmlspecialchars($tag), true);
$tpl->addBlock('category');
}
$enclosures = get_article_enclosures($line["id"]);
foreach ($enclosures as $e) {
$type = htmlspecialchars($e['content_type']);
$url = htmlspecialchars($e['content_url']);
$length = $e['duration'];
$tpl->setVariable('ARTICLE_ENCLOSURE_URL', $url, true);
$tpl->setVariable('ARTICLE_ENCLOSURE_TYPE', $type, true);
$tpl->setVariable('ARTICLE_ENCLOSURE_LENGTH', $length, true);
$tpl->addBlock('enclosure');
}
$tpl->addBlock('entry');
}
$tmp = "";
$tpl->addBlock('feed');
$tpl->generateOutputToString($tmp);
if (@!$_REQUEST["noxml"]) {
header("Content-Type: text/xml; charset=utf-8");
} else {
header("Content-Type: text/plain; charset=utf-8");
}
print $tmp;
} else if ($format == 'json') {
$feed = array();
$feed['title'] = $feed_title;
$feed['version'] = VERSION;
$feed['feed_url'] = $feed_self_url;
if (PUBSUBHUBBUB_HUB && $feed == -2) {
$feed['hub_url'] = PUBSUBHUBBUB_HUB;
}
$feed['self_url'] = get_self_url_prefix();
$feed['articles'] = array();
while ($line = $this->dbh->fetch_assoc($result)) {
$line["content_preview"] = truncate_string(strip_tags($line["content_preview"]), 100, '...');
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) {
$line = $p->hook_query_headlines($line, 100);
}
$article = array();
$article['id'] = $line['link'];
$article['link'] = $line['link'];
$article['title'] = $line['title'];
$article['excerpt'] = $line["content_preview"];
$article['content'] = sanitize($line["content"], false, $owner_uid);
$article['updated'] = date('c', strtotime($line["updated"]));
if ($line['note']) $article['note'] = $line['note'];
if ($article['author']) $article['author'] = $line['author'];
$tags = get_article_tags($line["id"], $owner_uid);
if (count($tags) > 0) {
$article['tags'] = array();
foreach ($tags as $tag) {
array_push($article['tags'], $tag);
}
}
$enclosures = get_article_enclosures($line["id"]);
if (count($enclosures) > 0) {
$article['enclosures'] = array();
foreach ($enclosures as $e) {
$type = $e['content_type'];
$url = $e['content_url'];
$length = $e['duration'];
array_push($article['enclosures'], array("url" => $url, "type" => $type, "length" => $length));
}
}
array_push($feed['articles'], $article);
}
header("Content-Type: text/json; charset=utf-8");
print json_encode($feed);
} else {
header("Content-Type: text/plain; charset=utf-8");
print json_encode(array("error" => array("message" => "Unknown format")));
}
}
function getUnread() {
$login = $this->dbh->escape_string($_REQUEST["login"]);
$fresh = $_REQUEST["fresh"] == "1";
$result = $this->dbh->query("SELECT id FROM ttrss_users WHERE login = '$login'");
if ($this->dbh->num_rows($result) == 1) {
$uid = $this->dbh->fetch_result($result, 0, "id");
print getGlobalUnread($uid);
if ($fresh) {
print ";";
print getFeedArticles(-3, false, true, $uid);
}
} else {
print "-1;User not found";
}
}
function getProfiles() {
$login = $this->dbh->escape_string($_REQUEST["login"]);
$result = $this->dbh->query("SELECT ttrss_settings_profiles.* FROM ttrss_settings_profiles,ttrss_users
WHERE ttrss_users.id = ttrss_settings_profiles.owner_uid AND login = '$login' ORDER BY title");
print "
";
print "" . __("Default profile") . " ";
while ($line = $this->dbh->fetch_assoc($result)) {
$id = $line["id"];
$title = $line["title"];
print "$title ";
}
print " ";
}
function pubsub() {
$mode = $this->dbh->escape_string($_REQUEST['hub_mode']);
if (!$mode) $mode = $this->dbh->escape_string($_REQUEST['hub.mode']);
$feed_id = (int) $this->dbh->escape_string($_REQUEST['id']);
$feed_url = $this->dbh->escape_string($_REQUEST['hub_topic']);
if (!$feed_url) $feed_url = $this->dbh->escape_string($_REQUEST['hub.topic']);
if (!PUBSUBHUBBUB_ENABLED) {
header('HTTP/1.0 404 Not Found');
echo "404 Not found (Disabled by server)";
return;
}
// TODO: implement hub_verifytoken checking
// TODO: store requested rel=self or whatever for verification
// (may be different from stored feed url) e.g. http://url/ or http://url
$result = $this->dbh->query("SELECT feed_url FROM ttrss_feeds
WHERE id = '$feed_id'");
if ($this->dbh->num_rows($result) != 0) {
$check_feed_url = $this->dbh->fetch_result($result, 0, "feed_url");
// ignore url checking for the time being
if ($check_feed_url && (true || $check_feed_url == $feed_url || !$feed_url)) {
if ($mode == "subscribe") {
$this->dbh->query("UPDATE ttrss_feeds SET pubsub_state = 2
WHERE id = '$feed_id'");
print $_REQUEST['hub_challenge'];
return;
} else if ($mode == "unsubscribe") {
$this->dbh->query("UPDATE ttrss_feeds SET pubsub_state = 0
WHERE id = '$feed_id'");
print $_REQUEST['hub_challenge'];
return;
} else if (!$mode) {
// Received update ping, schedule feed update.
//update_rss_feed($feed_id, true, true);
$this->dbh->query("UPDATE ttrss_feeds SET
last_update_started = '1970-01-01',
last_updated = '1970-01-01' WHERE id = '$feed_id'");
}
} else {
header('HTTP/1.0 404 Not Found');
echo "404 Not found (URL check failed)";
}
} else {
header('HTTP/1.0 404 Not Found');
echo "404 Not found (Feed not found)";
}
}
function logout() {
logout_user();
header("Location: index.php");
}
function share() {
$uuid = $this->dbh->escape_string($_REQUEST["key"]);
$result = $this->dbh->query("SELECT ref_id, owner_uid FROM ttrss_user_entries WHERE
uuid = '$uuid'");
if ($this->dbh->num_rows($result) != 0) {
header("Content-Type: text/html");
$id = $this->dbh->fetch_result($result, 0, "ref_id");
$owner_uid = $this->dbh->fetch_result($result, 0, "owner_uid");
$article = format_article($id, false, true, $owner_uid);
print_r($article['content']);
} else {
print "Article not found.";
}
}
function rss() {
$feed = $this->dbh->escape_string($_REQUEST["id"]);
$key = $this->dbh->escape_string($_REQUEST["key"]);
$is_cat = sql_bool_to_bool($_REQUEST["is_cat"]);
$limit = (int)$this->dbh->escape_string($_REQUEST["limit"]);
$offset = (int)$this->dbh->escape_string($_REQUEST["offset"]);
$search = $this->dbh->escape_string($_REQUEST["q"]);
$search_mode = $this->dbh->escape_string($_REQUEST["smode"]);
$view_mode = $this->dbh->escape_string($_REQUEST["view-mode"]);
$order = $this->dbh->escape_string($_REQUEST["order"]);
$format = $this->dbh->escape_string($_REQUEST['format']);
$orig_guid = sql_bool_to_bool($_REQUEST["orig_guid"]);
if (!$format) $format = 'atom';
if (SINGLE_USER_MODE) {
authenticate_user("admin", null);
}
$owner_id = false;
if ($key) {
$result = $this->dbh->query("SELECT owner_uid FROM
ttrss_access_keys WHERE access_key = '$key' AND feed_id = '$feed'");
if ($this->dbh->num_rows($result) == 1)
$owner_id = $this->dbh->fetch_result($result, 0, "owner_uid");
}
if ($owner_id) {
$this->generate_syndicated_feed($owner_id, $feed, $is_cat, $limit,
$offset, $search, $search_mode, $view_mode, $format, $order, $orig_guid);
} else {
header('HTTP/1.1 403 Forbidden');
}
}
function updateTask() {
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", $op);
}
function housekeepingTask() {
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_HOUSE_KEEPING, "hook_house_keeping", $op);
}
function globalUpdateFeeds() {
RPC::updaterandomfeed_real($this->dbh);
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", $op);
}
function sharepopup() {
if (SINGLE_USER_MODE) {
login_sequence();
}
header('Content-Type: text/html; charset=utf-8');
print "
Tiny Tiny RSS
";
stylesheet_tag("css/utility.css");
javascript_tag("lib/prototype.js");
javascript_tag("lib/scriptaculous/scriptaculous.js?load=effects,dragdrop,controls");
print "
";
$action = $_REQUEST["action"];
if ($_SESSION["uid"]) {
if ($action == 'share') {
$title = $this->dbh->escape_string(strip_tags($_REQUEST["title"]));
$url = $this->dbh->escape_string(strip_tags($_REQUEST["url"]));
$content = $this->dbh->escape_string(strip_tags($_REQUEST["content"]));
$labels = $this->dbh->escape_string(strip_tags($_REQUEST["labels"]));
Article::create_published_article($title, $url, $content, $labels,
$_SESSION["uid"]);
print "";
} else {
$title = htmlspecialchars($_REQUEST["title"]);
$url = htmlspecialchars($_REQUEST["url"]);
?>
dbh->escape_string($_POST["login"]);
$password = $_POST["password"];
$remember_me = $_POST["remember_me"];
if ($remember_me) {
session_set_cookie_params(SESSION_COOKIE_LIFETIME);
} else {
session_set_cookie_params(0);
}
@session_start();
if (authenticate_user($login, $password)) {
$_POST["password"] = "";
if (get_schema_version() >= 120) {
$_SESSION["language"] = get_pref("USER_LANGUAGE", $_SESSION["uid"]);
}
$_SESSION["ref_schema_version"] = get_schema_version(true);
$_SESSION["bw_limit"] = !!$_POST["bw_limit"];
if ($_POST["profile"]) {
$profile = $this->dbh->escape_string($_POST["profile"]);
$result = $this->dbh->query("SELECT id FROM ttrss_settings_profiles
WHERE id = '$profile' AND owner_uid = " . $_SESSION["uid"]);
if ($this->dbh->num_rows($result) != 0) {
$_SESSION["profile"] = $profile;
}
}
} else {
$_SESSION["login_error_msg"] = __("Incorrect username or password");
user_error("Failed login attempt from {$_SERVER['REMOTE_ADDR']}", E_USER_WARNING);
}
if ($_REQUEST['return']) {
header("Location: " . $_REQUEST['return']);
} else {
header("Location: " . SELF_URL_PATH);
}
}
}
function subscribe() {
if (SINGLE_USER_MODE) {
login_sequence();
}
if ($_SESSION["uid"]) {
$feed_url = $this->dbh->escape_string(trim($_REQUEST["feed_url"]));
header('Content-Type: text/html; charset=utf-8');
print "
Tiny Tiny RSS
".__("Subscribe to feed...")." ";
$rc = subscribe_to_feed($feed_url);
switch ($rc['code']) {
case 0:
print_warning(T_sprintf("Already subscribed to
%s .", $feed_url));
break;
case 1:
print_notice(T_sprintf("Subscribed to
%s .", $feed_url));
break;
case 2:
print_error(T_sprintf("Could not subscribe to
%s .", $feed_url));
break;
case 3:
print_error(T_sprintf("No feeds found in
%s .", $feed_url));
break;
case 4:
print_notice(__("Multiple feed URLs found."));
$feed_urls = $rc["feeds"];
break;
case 5:
print_error(T_sprintf("Could not subscribe to
%s .
Can't download the Feed URL.", $feed_url));
break;
}
if ($feed_urls) {
print "
";
}
$tp_uri = get_self_url_prefix() . "/prefs.php";
$tt_uri = get_self_url_prefix();
if ($rc['code'] <= 2){
$result = $this->dbh->query("SELECT id FROM ttrss_feeds WHERE
feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
$feed_id = $this->dbh->fetch_result($result, 0, "id");
} else {
$feed_id = 0;
}
print "
";
if ($feed_id) {
print "
";
}
print "
";
print "
";
} else {
render_login_form();
}
}
function subscribe2() {
$feed_url = $this->dbh->escape_string(trim($_REQUEST["feed_url"]));
$cat_id = $this->dbh->escape_string($_REQUEST["cat_id"]);
$from = $this->dbh->escape_string($_REQUEST["from"]);
$feed_urls = array();
/* only read authentication information from POST */
$auth_login = $this->dbh->escape_string(trim($_POST["auth_login"]));
$auth_pass = $this->dbh->escape_string(trim($_POST["auth_pass"]));
$rc = subscribe_to_feed($feed_url, $cat_id, $auth_login, $auth_pass);
switch ($rc) {
case 1:
print_notice(T_sprintf("Subscribed to
%s .", $feed_url));
break;
case 2:
print_error(T_sprintf("Could not subscribe to
%s .", $feed_url));
break;
case 3:
print_error(T_sprintf("No feeds found in
%s .", $feed_url));
break;
case 0:
print_warning(T_sprintf("Already subscribed to
%s .", $feed_url));
break;
case 4:
print_notice(__("Multiple feed URLs found."));
$contents = @fetch_file_contents($url, false, $auth_login, $auth_pass);
if (is_html($contents)) {
$feed_urls = get_feeds_from_html($url, $contents);
}
break;
case 5:
print_error(T_sprintf("Could not subscribe to
%s .
Can't download the Feed URL.", $feed_url));
break;
}
if ($feed_urls) {
print "
";
}
$tp_uri = get_self_url_prefix() . "/prefs.php";
$tt_uri = get_self_url_prefix();
if ($rc <= 2){
$result = $this->dbh->query("SELECT id FROM ttrss_feeds WHERE
feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
$feed_id = $this->dbh->fetch_result($result, 0, "id");
} else {
$feed_id = 0;
}
print "
";
if ($feed_id) {
print "
";
}
print "
";
print "