diff --git a/conf/config.php b/conf/config.php index a0416fa..af10c6d 100644 --- a/conf/config.php +++ b/conf/config.php @@ -1,4 +1,4 @@ - diff --git a/manifest.json b/manifest.json index e529598..83c7c20 100644 --- a/manifest.json +++ b/manifest.json @@ -10,6 +10,7 @@ "fr": "Un lecteur de flux en PHP et Ajax" }, "url": "http://tt-rss.org", + "version": "17.1", "maintainer": { "name": "titoko", "email": "titoko@titoko.fr" diff --git a/scripts/_common.sh b/scripts/_common.sh new file mode 100644 index 0000000..ebab136 --- /dev/null +++ b/scripts/_common.sh @@ -0,0 +1,32 @@ +# +# Common variables +# + +APPNAME="ttrss" + +# ttrss version +VERSION="17.1" + +# Remote URL to fetch ttrss tarball +TTRSS_BINARY_URL="https://tt-rss.org/gitlab/fox/tt-rss/repository/archive.zip?ref=${VERSION}" + +# +# Common helpers +# + +# Download and extract ttrss binary to the given directory +# usage: extract_ttrss DESTDIR +extract_ttrss() { + local DESTDIR=$1 + local TMPDIR=$(mktemp -d) + + # retrieve and extract ttrss tarball + ttrss_tarball="/tmp/ttrss.zip" + rm -f "$ttrss_tarball" + wget -q -O "$ttrss_tarball" "$TTRSS_BINARY_URL" \ + || ynh_die "Unable to download ttrss tarball" + unzip -q "$ttrss_tarball" -d "$TMPDIR" \ + || ynh_die "Unable to extract ttrss tarball" + sudo rsync -a "$TMPDIR"/tt-rss.git/* "$DESTDIR" + rm -rf "$ttrss_tarball" "$TMPDIR" +} diff --git a/scripts/install b/scripts/install index e4f8308..b0ca8a5 100644 --- a/scripts/install +++ b/scripts/install @@ -3,6 +3,10 @@ # causes the shell to exit if any subcommand or pipeline returns a non-zero status set -e +# Load common variables +source ./_common.sh + + # Retrieve arguments domain=$1 path=$2 @@ -18,22 +22,21 @@ fi deskey=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d 'A-Za-z0-9' | sed -n 's/\(.\{24\}\).*/\1/p') db_pwd=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d 'A-Za-z0-9' | sed -n 's/\(.\{24\}\).*/\1/p') -# Use 'ttrss' as database name and user -db_user=$app - -# Initialize database and store mysql password for upgrade -sudo yunohost app initdb $db_user -p $db_pwd -s $(readlink -e ../source/schema/TTRSS_schema_mysql.sql) -sudo yunohost app setting $app mysqlpwd -v $db_pwd - # Copy files to the right place final_path=/var/www/$app sudo mkdir -p $final_path -sudo cp -r ../source/* $final_path +extract_ttrss $final_path sudo cp ../conf/config.php $final_path/ sudo cp ../conf/*.patch /tmp/ sudo patch -d $final_path -p0 < /tmp/update.patch sudo patch -d $final_path/plugins/auth_remote/ -p0 < /tmp/init.patch +# Use 'ttrss' as database name and user +db_user=$app + +# Initialize database and store mysql password for upgrade +sudo yunohost app initdb $db_user -p $db_pwd -s $(readlink -e $final_path/schema/ttrss_schema_mysql.sql) +sudo yunohost app setting $app mysqlpwd -v $db_pwd # Change variables in ttrss configuration sudo sed -i "s/yunouser/$db_user/g" $final_path/config.php @@ -74,4 +77,8 @@ sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf # Reload Nginx and regenerate SSOwat conf sudo service nginx reload + +# Update database schema +sudo sudo -u www-data php ${final_path}/update.php --update-schema + sudo yunohost app setting $app skipped_uris -v "/public.php,/api" diff --git a/scripts/upgrade b/scripts/upgrade index 762cba0..227271f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -3,6 +3,9 @@ # causes the shell to exit if any subcommand or pipeline returns a non-zero status set -e +# Load common variables +source ./_common.sh + app=${!#} domain=$(sudo yunohost app setting $app domain) @@ -14,7 +17,8 @@ db_pwd=$(sudo yunohost app setting $app mysqlpwd) final_path=/var/www/$app sudo mkdir -p $final_path -sudo cp -a ../source/* $final_path +extract_ttrss $final_path + sudo cp ../conf/config.php $final_path/ sudo cp ../conf/*.patch /tmp/ sudo patch -d $final_path -p0 < /tmp/update.patch diff --git a/source/.htaccess b/source/.htaccess deleted file mode 100644 index 22b33f0..0000000 --- a/source/.htaccess +++ /dev/null @@ -1,3 +0,0 @@ -AddType image/svg+xml svg -AddType image/svg+xml svgz - diff --git a/source/LICENSE b/source/LICENSE deleted file mode 100644 index d511905..0000000 --- a/source/LICENSE +++ /dev/null @@ -1,339 +0,0 @@ - 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. diff --git a/source/README.md b/source/README.md deleted file mode 100644 index 0c3176f..0000000 --- a/source/README.md +++ /dev/null @@ -1,41 +0,0 @@ -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 diff --git a/source/api/index.php b/source/api/index.php deleted file mode 100644 index facdf82..0000000 --- a/source/api/index.php +++ /dev/null @@ -1,74 +0,0 @@ -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(); -?> diff --git a/source/atom-to-html.xsl b/source/atom-to-html.xsl deleted file mode 100644 index 1b827bb..0000000 --- a/source/atom-to-html.xsl +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - <xsl:value-of select="atom:title"/> - - - - - - - - -
- -

- -

This feed has been exported from - Tiny Tiny RSS. - It contains the following items:

- - -

- -
- -
- - -

Extra...

-
- - -
- -
- - - -
- -
- diff --git a/source/backend.php b/source/backend.php deleted file mode 100644 index 84abc97..0000000 --- a/source/backend.php +++ /dev/null @@ -1,154 +0,0 @@ - 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))); - -?> diff --git a/source/cache/.htaccess b/source/cache/.htaccess deleted file mode 100755 index 93169e4..0000000 --- a/source/cache/.htaccess +++ /dev/null @@ -1,2 +0,0 @@ -Order deny,allow -Deny from all diff --git a/source/cache/export/.empty b/source/cache/export/.empty deleted file mode 100755 index e69de29..0000000 diff --git a/source/cache/images/.empty b/source/cache/images/.empty deleted file mode 100755 index e69de29..0000000 diff --git a/source/cache/js/.empty b/source/cache/js/.empty deleted file mode 100755 index e69de29..0000000 diff --git a/source/cache/simplepie/.empty b/source/cache/simplepie/.empty deleted file mode 100755 index e69de29..0000000 diff --git a/source/cache/upload/.empty b/source/cache/upload/.empty deleted file mode 100644 index e69de29..0000000 diff --git a/source/classes/.htaccess b/source/classes/.htaccess deleted file mode 100644 index 93169e4..0000000 --- a/source/classes/.htaccess +++ /dev/null @@ -1,2 +0,0 @@ -Order deny,allow -Deny from all diff --git a/source/classes/api.php b/source/classes/api.php deleted file mode 100644 index 3c5d084..0000000 --- a/source/classes/api.php +++ /dev/null @@ -1,833 +0,0 @@ -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 - user_error("Failed login attempt for $login from {$_SERVER['REMOTE_ADDR']}", E_USER_WARNING); - $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"]); - $force_update = sql_bool_to_bool($_REQUEST["force_update"]); - $has_sandbox = sql_bool_to_bool($_REQUEST["has_sandbox"]); - $excerpt_length = (int)$this->dbh->escape_string($_REQUEST["excerpt_length"]); - - $_SESSION['hasSandbox'] = $has_sandbox; - - $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, $force_update, $excerpt_length); - - $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" => (int) $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" => (int) $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, $force_update = false, $excerpt_length = 100) { - - if ($force_update && $feed_id > 0 && is_numeric($feed_id)) { - // Update the feed if required with some basic flood control - - $result = db_query( - "SELECT cache_images,".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated - FROM ttrss_feeds WHERE id = '$feed_id'"); - - if (db_num_rows($result) != 0) { - $last_updated = strtotime(db_fetch_result($result, 0, "last_updated")); - $cache_images = sql_bool_to_bool(db_fetch_result($result, 0, "cache_images")); - - if (!$cache_images && time() - $last_updated > 120) { - include "rssfuncs.php"; - update_rss_feed($feed_id, true, true); - } else { - db_query("UPDATE ttrss_feeds SET last_updated = '1970-01-01', last_update_started = '1970-01-01' - WHERE id = '$feed_id'"); - } - } - } - - $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"]), $excerpt_length); - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { - $line = $p->hook_query_headlines($line, $excerpt_length, true); - } - - $is_updated = ($line["last_read"] == "" && - ($line["unread"] != "t" && $line["unread"] != "1")); - - $tags = explode(",", $line["tag_cache"]); - - $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($line["id"]); - - //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; - } - - -} - -?> diff --git a/source/classes/article.php b/source/classes/article.php deleted file mode 100644 index 9aef107..0000000 --- a/source/classes/article.php +++ /dev/null @@ -1,345 +0,0 @@ -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"]); - - // 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 - guid = '$guid' 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 "
"; - - print "
"; - - print " "; - print ""; - 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); - } - - - -} diff --git a/source/classes/auth/base.php b/source/classes/auth/base.php deleted file mode 100644 index 69acd09..0000000 --- a/source/classes/auth/base.php +++ /dev/null @@ -1,61 +0,0 @@ -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; - } - - } -} - -?> diff --git a/source/classes/backend.php b/source/classes/backend.php deleted file mode 100644 index 7737df0..0000000 --- a/source/classes/backend.php +++ /dev/null @@ -1,119 +0,0 @@ -"; - } - - 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 ""; - print "
"; - - /* if (file_exists("help/$topic.php")) { - include("help/$topic.php"); - } else { - print "

".__("Help topic not found.")."

"; - } */ - /* print "
-
"; */ - - } -} -?> diff --git a/source/classes/db.php b/source/classes/db.php deleted file mode 100644 index 695ca6e..0000000 --- a/source/classes/db.php +++ /dev/null @@ -1,98 +0,0 @@ -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(); - } - -} -?> diff --git a/source/classes/db/mysql.php b/source/classes/db/mysql.php deleted file mode 100644 index d4b45b9..0000000 --- a/source/classes/db/mysql.php +++ /dev/null @@ -1,76 +0,0 @@ -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; - } - -} -?> diff --git a/source/classes/db/mysqli.php b/source/classes/db/mysqli.php deleted file mode 100644 index c685b75..0000000 --- a/source/classes/db/mysqli.php +++ /dev/null @@ -1,80 +0,0 @@ -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; - } - -} -?> diff --git a/source/classes/db/pdo.php b/source/classes/db/pdo.php deleted file mode 100644 index 126f515..0000000 --- a/source/classes/db/pdo.php +++ /dev/null @@ -1,100 +0,0 @@ -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; - } - -} -?> diff --git a/source/classes/db/pgsql.php b/source/classes/db/pgsql.php deleted file mode 100644 index ba37f83..0000000 --- a/source/classes/db/pgsql.php +++ /dev/null @@ -1,85 +0,0 @@ - 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; - } -} -?> diff --git a/source/classes/db/prefs.php b/source/classes/db/prefs.php deleted file mode 100644 index 3e92bb8..0000000 --- a/source/classes/db/prefs.php +++ /dev/null @@ -1,190 +0,0 @@ -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; - } - } - } - -} -?> diff --git a/source/classes/db/stmt.php b/source/classes/db/stmt.php deleted file mode 100644 index 4d3596e..0000000 --- a/source/classes/db/stmt.php +++ /dev/null @@ -1,32 +0,0 @@ -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(); - } -} -?> diff --git a/source/classes/dbupdater.php b/source/classes/dbupdater.php deleted file mode 100644 index a319da0..0000000 --- a/source/classes/dbupdater.php +++ /dev/null @@ -1,65 +0,0 @@ -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; - } - } - -} ?> diff --git a/source/classes/dlg.php b/source/classes/dlg.php deleted file mode 100644 index 25a194b..0000000 --- a/source/classes/dlg.php +++ /dev/null @@ -1,271 +0,0 @@ -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 "
"; - - $this->dbh->query("BEGIN"); - - print "
    "; - - $opml = new Opml($_REQUEST); - - $opml->opml_import($_SESSION["uid"]); - - $this->dbh->query("COMMIT"); - - print "
"; - print "
"; - - print "
"; - print ""; - print "
"; - - print ""; - - //return; - } - - function pubOPMLUrl() { - $url_path = Opml::opml_publish_url(); - - print __("Your Public OPML URL is:"); - - print "
"; - print "$url_path"; - print "
"; - - print "
"; - - print " "; - - print ""; - - 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 ""; - - 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 ""; - print "
"; - - } - - function printTagSelect() { - - print __("Match:"). " " . - ""; - print ""; - print " "; - print ""; - print "