]>
git.wh0rd.org - tt-rss.git/blob - classes/handler/public.php
2 class Handler_Public
extends Handler
{
4 private function generate_syndicated_feed($owner_uid, $feed, $is_cat,
5 $limit, $offset, $search,
6 $view_mode = false, $format = 'atom', $order = false, $orig_guid = false, $start_ts = false) {
8 require_once "lib/MiniTemplator.class.php";
10 $note_style = "background-color : #fff7d5;
11 border-width : 1px; ".
12 "padding : 5px; border-style : dashed; border-color : #e7d796;".
13 "margin-bottom : 1em; color : #9a8c59;";
15 if (!$limit) $limit = 60;
17 $date_sort_field = "date_entered DESC, updated DESC";
19 if ($feed == -2 && !$is_cat) {
20 $date_sort_field = "last_published DESC";
21 } else if ($feed == -1 && !$is_cat) {
22 $date_sort_field = "last_marked DESC";
27 $date_sort_field = "ttrss_entries.title, date_entered, updated";
30 $date_sort_field = "date_entered, updated";
33 $date_sort_field = "updated DESC";
37 "owner_uid" => $owner_uid,
40 "view_mode" => $view_mode,
41 "cat_view" => $is_cat,
43 "override_order" => $date_sort_field,
44 "include_children" => true,
45 "ignore_vfeed_group" => true,
47 "start_ts" => $start_ts
50 $qfh_ret = Feeds
::queryFeedHeadlines($params);
52 $result = $qfh_ret[0];
53 $feed_title = htmlspecialchars($qfh_ret[1]);
54 $feed_site_url = $qfh_ret[2];
55 /* $last_error = $qfh_ret[3]; */
57 $feed_self_url = get_self_url_prefix() .
58 "/public.php?op=rss&id=$feed&key=" .
59 get_feed_access_key($feed, false, $owner_uid);
61 if (!$feed_site_url) $feed_site_url = get_self_url_prefix();
63 if ($format == 'atom') {
64 $tpl = new MiniTemplator
;
66 $tpl->readTemplateFromFile("templates/generated_feed.txt");
68 $tpl->setVariable('FEED_TITLE', $feed_title, true);
69 $tpl->setVariable('VERSION', VERSION
, true);
70 $tpl->setVariable('FEED_URL', htmlspecialchars($feed_self_url), true);
72 $tpl->setVariable('SELF_URL', htmlspecialchars(get_self_url_prefix()), true);
73 while ($line = $result->fetch()) {
75 $line["content_preview"] = sanitize(truncate_string(strip_tags($line["content"]), 100, '...'));
77 foreach (PluginHost
::getInstance()->get_hooks(PluginHost
::HOOK_QUERY_HEADLINES
) as $p) {
78 $line = $p->hook_query_headlines($line);
81 foreach (PluginHost
::getInstance()->get_hooks(PluginHost
::HOOK_ARTICLE_EXPORT_FEED
) as $p) {
82 $line = $p->hook_article_export_feed($line, $feed, $is_cat);
85 $tpl->setVariable('ARTICLE_ID',
86 htmlspecialchars($orig_guid ?
$line['link'] :
87 $this->make_article_tag_uri($line['id'], $line['date_entered'])), true);
88 $tpl->setVariable('ARTICLE_LINK', htmlspecialchars($line['link']), true);
89 $tpl->setVariable('ARTICLE_TITLE', htmlspecialchars($line['title']), true);
90 $tpl->setVariable('ARTICLE_EXCERPT', $line["content_preview"], true);
92 $content = sanitize($line["content"], false, $owner_uid,
93 $feed_site_url, false, $line["id"]);
96 $content = "<div style=\"$note_style\">Article note: " . $line['note'] . "</div>" .
98 $tpl->setVariable('ARTICLE_NOTE', htmlspecialchars($line['note']), true);
101 $tpl->setVariable('ARTICLE_CONTENT', $content, true);
103 $tpl->setVariable('ARTICLE_UPDATED_ATOM',
104 date('c', strtotime($line["updated"])), true);
105 $tpl->setVariable('ARTICLE_UPDATED_RFC822',
106 date(DATE_RFC822
, strtotime($line["updated"])), true);
108 $tpl->setVariable('ARTICLE_AUTHOR', htmlspecialchars($line['author']), true);
110 $tpl->setVariable('ARTICLE_SOURCE_LINK', htmlspecialchars($line['site_url'] ?
$line["site_url"] : get_self_url_prefix()), true);
111 $tpl->setVariable('ARTICLE_SOURCE_TITLE', htmlspecialchars($line['feed_title'] ?
$line['feed_title'] : $feed_title), true);
113 $tags = Article
::get_article_tags($line["id"], $owner_uid);
115 foreach ($tags as $tag) {
116 $tpl->setVariable('ARTICLE_CATEGORY', htmlspecialchars($tag), true);
117 $tpl->addBlock('category');
120 $enclosures = Article
::get_article_enclosures($line["id"]);
122 foreach ($enclosures as $e) {
123 $type = htmlspecialchars($e['content_type']);
124 $url = htmlspecialchars($e['content_url']);
125 $length = $e['duration'] ?
$e['duration'] : 1;
127 $tpl->setVariable('ARTICLE_ENCLOSURE_URL', $url, true);
128 $tpl->setVariable('ARTICLE_ENCLOSURE_TYPE', $type, true);
129 $tpl->setVariable('ARTICLE_ENCLOSURE_LENGTH', $length, true);
131 $tpl->addBlock('enclosure');
134 $tpl->addBlock('entry');
139 $tpl->addBlock('feed');
140 $tpl->generateOutputToString($tmp);
142 if (@!clean($_REQUEST["noxml"])) {
143 header("Content-Type: text/xml; charset=utf-8");
145 header("Content-Type: text/plain; charset=utf-8");
149 } else if ($format == 'json') {
153 $feed['title'] = $feed_title;
154 $feed['version'] = VERSION
;
155 $feed['feed_url'] = $feed_self_url;
157 $feed['self_url'] = get_self_url_prefix();
159 $feed['articles'] = array();
161 while ($line = $result->fetch()) {
163 $line["content_preview"] = sanitize(truncate_string(strip_tags($line["content_preview"]), 100, '...'));
165 foreach (PluginHost
::getInstance()->get_hooks(PluginHost
::HOOK_QUERY_HEADLINES
) as $p) {
166 $line = $p->hook_query_headlines($line, 100);
169 foreach (PluginHost
::getInstance()->get_hooks(PluginHost
::HOOK_ARTICLE_EXPORT_FEED
) as $p) {
170 $line = $p->hook_article_export_feed($line, $feed, $is_cat);
175 $article['id'] = $line['link'];
176 $article['link'] = $line['link'];
177 $article['title'] = $line['title'];
178 $article['excerpt'] = $line["content_preview"];
179 $article['content'] = sanitize($line["content"], false, $owner_uid, $feed_site_url, false, $line["id"]);
180 $article['updated'] = date('c', strtotime($line["updated"]));
182 if ($line['note']) $article['note'] = $line['note'];
183 if ($article['author']) $article['author'] = $line['author'];
185 $tags = Article
::get_article_tags($line["id"], $owner_uid);
187 if (count($tags) > 0) {
188 $article['tags'] = array();
190 foreach ($tags as $tag) {
191 array_push($article['tags'], $tag);
195 $enclosures = Article
::get_article_enclosures($line["id"]);
197 if (count($enclosures) > 0) {
198 $article['enclosures'] = array();
200 foreach ($enclosures as $e) {
201 $type = $e['content_type'];
202 $url = $e['content_url'];
203 $length = $e['duration'];
205 array_push($article['enclosures'], array("url" => $url, "type" => $type, "length" => $length));
209 array_push($feed['articles'], $article);
212 header("Content-Type: text/json; charset=utf-8");
213 print json_encode($feed);
216 header("Content-Type: text/plain; charset=utf-8");
217 print json_encode(array("error" => array("message" => "Unknown format")));
221 function getUnread() {
222 $login = clean($_REQUEST["login"]);
223 $fresh = clean($_REQUEST["fresh"]) == "1";
225 $sth = $this->pdo
->prepare("SELECT id FROM ttrss_users WHERE login = ?");
226 $sth->execute([$login]);
228 if ($row = $sth->fetch()) {
231 print Feeds
::getGlobalUnread($uid);
235 print Feeds
::getFeedArticles(-3, false, true, $uid);
239 print "-1;User not found";
243 function getProfiles() {
244 $login = clean($_REQUEST["login"]);
246 $sth = $this->pdo
->prepare("SELECT ttrss_settings_profiles.* FROM ttrss_settings_profiles,ttrss_users
247 WHERE ttrss_users.id = ttrss_settings_profiles.owner_uid AND login = ? ORDER BY title");
248 $sth->execute([$login]);
250 print "<select dojoType='dijit.form.Select' style='width : 220px; margin : 0px' name='profile'>";
252 print "<option value='0'>" . __("Default profile") . "</option>";
254 while ($line = $sth->fetch()) {
256 $title = $line["title"];
258 print "<option value='$id'>$title</option>";
266 header("Location: index.php");
270 $uuid = clean($_REQUEST["key"]);
272 $sth = $this->pdo
->prepare("SELECT ref_id, owner_uid FROM ttrss_user_entries WHERE
274 $sth->execute([$uuid]);
276 if ($row = $sth->fetch()) {
277 header("Content-Type: text/html");
279 $id = $row["ref_id"];
280 $owner_uid = $row["owner_uid"];
282 $article = Article
::format_article($id, false, true, $owner_uid);
284 print_r($article['content']);
287 print "Article not found.";
293 $feed = clean($_REQUEST["id"]);
294 $key = clean($_REQUEST["key"]);
295 $is_cat = clean($_REQUEST["is_cat"]);
296 $limit = (int)clean($_REQUEST["limit"]);
297 $offset = (int)clean($_REQUEST["offset"]);
299 $search = clean($_REQUEST["q"]);
300 $view_mode = clean($_REQUEST["view-mode"]);
301 $order = clean($_REQUEST["order"]);
302 $start_ts = clean($_REQUEST["ts"]);
304 $format = clean($_REQUEST['format']);
305 $orig_guid = clean($_REQUEST["orig_guid"]);
307 if (!$format) $format = 'atom';
309 if (SINGLE_USER_MODE
) {
310 authenticate_user("admin", null);
316 $sth = $this->pdo
->prepare("SELECT owner_uid FROM
317 ttrss_access_keys WHERE access_key = ? AND feed_id = ?");
318 $sth->execute([$key, $feed]);
320 if ($row = $sth->fetch())
321 $owner_id = $row["owner_uid"];
325 $this->generate_syndicated_feed($owner_id, $feed, $is_cat, $limit,
326 $offset, $search, $view_mode, $format, $order, $orig_guid, $start_ts);
328 header('HTTP/1.1 403 Forbidden');
332 function updateTask() {
333 PluginHost
::getInstance()->run_hooks(PluginHost
::HOOK_UPDATE_TASK
, "hook_update_task", false);
336 function housekeepingTask() {
337 PluginHost
::getInstance()->run_hooks(PluginHost
::HOOK_HOUSE_KEEPING
, "hook_house_keeping", false);
340 function globalUpdateFeeds() {
341 RPC
::updaterandomfeed_real();
343 PluginHost
::getInstance()->run_hooks(PluginHost
::HOOK_UPDATE_TASK
, "hook_update_task", false);
346 function sharepopup() {
347 if (SINGLE_USER_MODE
) {
351 header('Content-Type: text/html; charset=utf-8');
352 print "<html><head><title>Tiny Tiny RSS</title>
353 <link rel=\"shortcut icon\" type=\"image/png\" href=\"images/favicon.png\">
354 <link rel=\"icon\" type=\"image/png\" sizes=\"72x72\" href=\"images/favicon-72px.png\">";
356 echo stylesheet_tag("css/default.css");
357 echo javascript_tag("lib/prototype.js");
358 echo javascript_tag("lib/scriptaculous/scriptaculous.js?load=effects,controls");
359 print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
360 </head><body id='sharepopup' class='ttrss_utility'>";
362 $action = clean($_REQUEST["action"]);
364 if ($_SESSION["uid"]) {
366 if ($action == 'share') {
368 $title = strip_tags(clean($_REQUEST["title"]));
369 $url = strip_tags(clean($_REQUEST["url"]));
370 $content = strip_tags(clean($_REQUEST["content"]));
371 $labels = strip_tags(clean($_REQUEST["labels"]));
373 Article
::create_published_article($title, $url, $content, $labels,
376 print "<script type='text/javascript'>";
377 print "window.close();";
381 $title = htmlspecialchars(clean($_REQUEST["title"]));
382 $url = htmlspecialchars(clean($_REQUEST["url"]));
386 <table height
='100%' width
='100%'><tr
><td colspan
='2'>
387 <h1
><?php
echo __("Share with Tiny Tiny RSS") ?
></h1
>
390 <form id
='share_form' name
='share_form'>
392 <input type
="hidden" name
="op" value
="sharepopup">
393 <input type
="hidden" name
="action" value
="share">
395 <tr
><td align
='right'><?php
echo __("Title:") ?
></td
>
396 <td width
='80%'><input name
='title' value
="<?php echo $title ?>"></td
></tr
>
397 <tr
><td align
='right'><?php
echo __("URL:") ?
></td
>
398 <td
><input name
='url' value
="<?php echo $url ?>"></td
></tr
>
399 <tr
><td align
='right'><?php
echo __("Content:") ?
></td
>
400 <td
><input name
='content' value
=""></td
></tr
>
401 <tr
><td align
='right'><?php
echo __("Labels:") ?
></td
>
402 <td
><input name
='labels' id
="labels_value"
403 placeholder
='Alpha, Beta, Gamma' value
="">
407 <div
class="autocomplete" id
="labels_choices"
408 style
="display : block"></div
></td
></tr
>
410 <script type
='text/javascript'>document
.forms
[0].title
.focus();</script
>
412 <script type
='text/javascript'>
413 new Ajax
.Autocompleter('labels_value', 'labels_choices',
414 "backend.php?op=rpc&method=completeLabels",
415 { tokens
: ',', paramName
: "search" });
419 <div style
='float : right' class='insensitive-small'>
420 <?php
echo __("Shared article will appear in the Published feed.") ?
>
422 <button type
="submit"><?php
echo __('Share') ?
></button
>
423 <button onclick
="return window.close()"><?php
echo __('Cancel') ?
></button
>
435 $return = urlencode($_SERVER["REQUEST_URI"])
438 <form action
="public.php?return=<?php echo $return ?>"
439 method
="POST" id
="loginForm" name
="loginForm">
441 <input type
="hidden" name
="op" value
="login">
443 <table height
='100%' width
='100%'><tr
><td colspan
='2'>
444 <h1
><?php
echo __("Not logged in") ?
></h1
></td
></tr
>
446 <tr
><td align
="right"><?php
echo __("Login:") ?
></td
>
447 <td align
="right"><input name
="login"
448 value
="<?php echo $_SESSION["fake_login
"] ?>"></td
></tr
>
449 <tr
><td align
="right"><?php
echo __("Password:") ?
></td
>
450 <td align
="right"><input type
="password" name
="password"
451 value
="<?php echo $_SESSION["fake_password
"] ?>"></td
></tr
>
453 <button type
="submit">
454 <?php
echo __('Log in') ?
></button
>
456 <button onclick
="return window.close()">
457 <?php
echo __('Cancel') ?
></button
>
467 if (!SINGLE_USER_MODE
) {
469 $login = clean($_POST["login"]);
470 $password = clean($_POST["password"]);
471 $remember_me = clean($_POST["remember_me"]);
474 session_set_cookie_params(SESSION_COOKIE_LIFETIME
);
476 session_set_cookie_params(0);
479 if (authenticate_user($login, $password)) {
480 $_POST["password"] = "";
482 if (get_schema_version() >= 120) {
483 $_SESSION["language"] = get_pref("USER_LANGUAGE", $_SESSION["uid"]);
486 $_SESSION["ref_schema_version"] = get_schema_version(true);
487 $_SESSION["bw_limit"] = !!clean($_POST["bw_limit"]);
489 if (clean($_POST["profile"])) {
491 $profile = clean($_POST["profile"]);
493 $sth = $this->pdo
->prepare("SELECT id FROM ttrss_settings_profiles
494 WHERE id = ? AND owner_uid = ?");
495 $sth->execute([$profile, $_SESSION['uid']]);
498 $_SESSION["profile"] = $profile;
503 // start an empty session to deliver login error message
506 if (!isset($_SESSION["login_error_msg"]))
507 $_SESSION["login_error_msg"] = __("Incorrect username or password");
509 user_error("Failed login attempt for $login from {$_SERVER['REMOTE_ADDR']}", E_USER_WARNING
);
512 if (clean($_REQUEST['return'])) {
513 header("Location: " . clean($_REQUEST['return']));
515 header("Location: " . get_self_url_prefix());
520 /* function subtest() {
521 header("Content-type: text/plain; charset=utf-8");
523 $url = clean($_REQUEST["url"]);
528 print_r(get_feeds_from_html($url, fetch_file_contents($url)));
532 function subscribe() {
533 if (SINGLE_USER_MODE
) {
537 if ($_SESSION["uid"]) {
539 $feed_url = trim(clean($_REQUEST["feed_url"]));
541 header('Content-Type: text/html; charset=utf-8');
544 <title>Tiny Tiny RSS</title>";
545 print stylesheet_tag("css/default.css");
547 print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
548 <link rel=\"shortcut icon\" type=\"image/png\" href=\"images/favicon.png\">
549 <link rel=\"icon\" type=\"image/png\" sizes=\"72x72\" href=\"images/favicon-72px.png\">
552 <body class='claro ttrss_utility'>
553 <img class=\"floatingLogo\" src=\"images/logo_small.png\"
554 alt=\"Tiny Tiny RSS\"/>
555 <h1>".__("Subscribe to feed...")."</h1><div class='content'>";
557 $rc = Feeds
::subscribe_to_feed($feed_url);
559 switch ($rc['code']) {
561 print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url));
564 print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url));
567 print_error(T_sprintf("Could not subscribe to <b>%s</b>.", $feed_url));
570 print_error(T_sprintf("No feeds found in <b>%s</b>.", $feed_url));
573 print_notice(__("Multiple feed URLs found."));
574 $feed_urls = $rc["feeds"];
577 print_error(T_sprintf("Could not subscribe to <b>%s</b>.<br>Can't download the Feed URL.", $feed_url));
583 print "<form action=\"public.php\">";
584 print "<input type=\"hidden\" name=\"op\" value=\"subscribe\">";
586 print "<select name=\"feed_url\">";
588 foreach ($feed_urls as $url => $name) {
589 $url = htmlspecialchars($url);
590 $name = htmlspecialchars($name);
592 print "<option value=\"$url\">$name</option>";
595 print "<input type=\"submit\" value=\"".__("Subscribe to selected feed").
601 $tp_uri = get_self_url_prefix() . "/prefs.php";
602 $tt_uri = get_self_url_prefix();
604 if ($rc['code'] <= 2){
605 $sth = $this->pdo
->prepare("SELECT id FROM ttrss_feeds WHERE
606 feed_url = ? AND owner_uid = ?");
607 $sth->execute([$feed_url, $_SESSION['uid']]);
608 $row = $sth->fetch();
610 $feed_id = $row["id"];
617 print "<form method=\"GET\" style='display: inline'
619 <input type=\"hidden\" name=\"tab\" value=\"feedConfig\">
620 <input type=\"hidden\" name=\"method\" value=\"editFeed\">
621 <input type=\"hidden\" name=\"methodparam\" value=\"$feed_id\">
622 <input type=\"submit\" value=\"".__("Edit subscription options")."\">
626 print "<form style='display: inline' method=\"GET\" action=\"$tt_uri\">
627 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
630 print "</div></body></html>";
638 header("Content-Type: text/plain");
639 print error_json(13);
642 function forgotpass() {
645 @$hash = clean($_REQUEST["hash"]);
647 header('Content-Type: text/html; charset=utf-8');
648 print "<html><head><title>Tiny Tiny RSS</title>
649 <link rel=\"shortcut icon\" type=\"image/png\" href=\"images/favicon.png\">
650 <link rel=\"icon\" type=\"image/png\" sizes=\"72x72\" href=\"images/favicon-72px.png\">";
652 echo stylesheet_tag("lib/dijit/themes/claro/claro.css");
653 echo stylesheet_tag("css/default.css");
654 echo javascript_tag("lib/prototype.js");
656 print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
657 </head><body class='claro ttrss_utility'>";
659 print '<div class="floatingLogo"><img src="images/logo_small.png"></div>';
660 print "<h1>".__("Password recovery")."</h1>";
661 print "<div class='content'>";
663 @$method = clean($_POST['method']);
666 $login = clean($_REQUEST["login"]);
669 $sth = $this->pdo
->prepare("SELECT id, resetpass_token FROM ttrss_users
671 $sth->execute([$login]);
673 if ($row = $sth->fetch()) {
675 $resetpass_token_full = $row["resetpass_token"];
676 list($timestamp, $resetpass_token) = explode(":", $resetpass_token_full);
678 if ($timestamp && $resetpass_token &&
679 $timestamp >= time() - 15*60*60 &&
680 $resetpass_token == $hash) {
682 $sth = $this->pdo
->prepare("UPDATE ttrss_users SET resetpass_token = NULL
684 $sth->execute([$id]);
686 Pref_Users
::resetUserPassword($id, true);
688 print "<p>"."Completed."."</p>";
691 print_error("Some of the information provided is missing or incorrect.");
694 print_error("Some of the information provided is missing or incorrect.");
697 print_error("Some of the information provided is missing or incorrect.");
700 print "<form method=\"GET\" action=\"index.php\">
701 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
704 } else if (!$method) {
705 print_notice(__("You will need to provide valid account name and email. A password reset link will be sent to your email address."));
707 print "<form method='POST' action='public.php'>";
708 print "<input type='hidden' name='method' value='do'>";
709 print "<input type='hidden' name='op' value='forgotpass'>";
712 print "<label>".__("Login:")."</label>";
713 print "<input class='input input-text' type='text' name='login' value='' required>";
717 print "<label>".__("Email:")."</label>";
718 print "<input class='input input-text' type='email' name='email' value='' required>";
722 print "<label>".__("How much is two plus two:")."</label>";
723 print "<input class='input input-text' type='text' name='test' value='' required>";
727 print "<button type='submit'>".__("Reset password")."</button>";
730 } else if ($method == 'do') {
732 $login = clean($_POST["login"]);
733 $email = clean($_POST["email"]);
734 $test = clean($_POST["test"]);
736 if (($test != 4 && $test != 'four') ||
!$email ||
!$login) {
737 print_error(__('Some of the required form parameters are missing or incorrect.'));
739 print "<form method=\"GET\" action=\"public.php\">
740 <input type=\"hidden\" name=\"op\" value=\"forgotpass\">
741 <input type=\"submit\" value=\"".__("Go back")."\">
746 print_notice("Password reset instructions are being sent to your email address.");
748 $sth = $this->pdo
->prepare("SELECT id FROM ttrss_users
749 WHERE login = ? AND email = ?");
750 $sth->execute([$login, $email]);
752 if ($row = $sth->fetch()) {
756 $resetpass_token = sha1(get_random_bytes(128));
757 $resetpass_link = get_self_url_prefix() . "/public.php?op=forgotpass&hash=" . $resetpass_token .
758 "&login=" . urlencode($login);
760 require_once 'classes/ttrssmailer.php';
761 require_once "lib/MiniTemplator.class.php";
763 $tpl = new MiniTemplator
;
765 $tpl->readTemplateFromFile("templates/resetpass_link_template.txt");
767 $tpl->setVariable('LOGIN', $login);
768 $tpl->setVariable('RESETPASS_LINK', $resetpass_link);
770 $tpl->addBlock('message');
774 $tpl->generateOutputToString($message);
776 $mail = new ttrssMailer();
778 $rc = $mail->quickMail($email, $login,
779 __("[tt-rss] Password reset request"),
782 if (!$rc) print_error($mail->ErrorInfo
);
784 $resetpass_token_full = time() . ":" . $resetpass_token;
786 $sth = $this->pdo
->prepare("UPDATE ttrss_users
787 SET resetpass_token = ?
788 WHERE login = ? AND email = ?");
790 $sth->execute([$resetpass_token_full, $login, $email]);
792 //Pref_Users::resetUserPassword($id, false);
796 print "<p>"."Completed."."</p>";
798 print_error("User ID not found.");
801 print "<form method=\"GET\" action=\"index.php\">
802 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
806 print_error(__("Sorry, login and email combination not found."));
808 print "<form method=\"GET\" action=\"public.php\">
809 <input type=\"hidden\" name=\"op\" value=\"forgotpass\">
810 <input type=\"submit\" value=\"".__("Go back")."\">
824 function dbupdate() {
827 if (!SINGLE_USER_MODE
&& $_SESSION["access_level"] < 10) {
828 $_SESSION["login_error_msg"] = __("Your access level is insufficient to run this script.");
835 <title
>Database Updater
</title
>
836 <meta http
-equiv
="Content-Type" content
="text/html; charset=utf-8"/>
837 <link rel
="stylesheet" type
="text/css" href
="css/default.css"/>
838 <link rel
=\"shortcut icon\" type
=\"image
/png\" href
=\"images
/favicon
.png\"
>
839 <link rel
=\"icon\" type
=\"image
/png\" sizes
=\"72x72\" href
=\"images
/favicon
-72px
.png\"
>
841 <style type
="text/css">
842 span
.ok
{ color
: #009000; font-weight : bold; }
843 span
.err
{ color
: #ff0000; font-weight : bold; }
845 <body
class="claro ttrss_utility">
846 <script type
='text/javascript'>
847 function confirmOP() {
848 return confirm("Update the database?");
852 <div
class="floatingLogo"><img src
="images/logo_small.png"></div
>
854 <h1
><?php
echo __("Database Updater") ?
></h1
>
856 <div
class="content">
859 @$op = clean($_REQUEST["subop"]);
860 $updater = new DbUpdater(Db
::pdo(), DB_TYPE
, SCHEMA_VERSION
);
862 if ($op == "performupdate") {
863 if ($updater->isUpdateRequired()) {
865 print "<h2>Performing updates</h2>";
867 print "<h3>Updating to schema version " . SCHEMA_VERSION
. "</h3>";
871 for ($i = $updater->getSchemaVersion() +
1; $i <= SCHEMA_VERSION
; $i++
) {
872 print "<li>Performing update up to version $i...";
874 $result = $updater->performUpdateTo($i, true);
877 print "<span class='err'>FAILED!</span></li></ul>";
879 print_warning("One of the updates failed. Either retry the process or perform updates manually.");
880 print "<p><form method=\"GET\" action=\"index.php\">
881 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
886 print "<span class='ok'>OK!</span></li>";
892 print_notice("Your Tiny Tiny RSS database is now updated to the latest version.");
894 print "<p><form method=\"GET\" action=\"index.php\">
895 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
899 print "<h2>Your database is up to date.</h2>";
901 print "<p><form method=\"GET\" action=\"index.php\">
902 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
906 if ($updater->isUpdateRequired()) {
908 print "<h2>Database update required</h2>";
911 sprintf("Your Tiny Tiny RSS database needs update to the latest version: %d to %d.",
912 $updater->getSchemaVersion(), SCHEMA_VERSION
).
915 print_warning("Please backup your database before proceeding.");
917 print "<form method='POST'>
918 <input type='hidden' name='subop' value='performupdate'>
919 <input type='submit' onclick='return confirmOP()' value='".__("Perform updates")."'>
924 print_notice("Tiny Tiny RSS database is up to date.");
926 print "<p><form method=\"GET\" action=\"index.php\">
927 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
940 function cached_url() {
941 @$req_filename = basename($_GET['hash']);
943 // we don't need an extension to find the file, hash is a complete URL
944 $hash = preg_replace("/\.[^\.]*$/", "", $req_filename);
948 $filename = CACHE_DIR
. '/images/' . $hash;
950 if (file_exists($filename)) {
951 header("Content-Disposition: inline; filename=\"$req_filename\"");
953 send_local_file($filename);
956 header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
957 echo "File not found.";
962 private function make_article_tag_uri($id, $timestamp) {
964 $timestamp = date("Y-m-d", strtotime($timestamp));
966 return "tag:" . parse_url(get_self_url_prefix(), PHP_URL_HOST
) . ",$timestamp:/$id";
969 // this should be used very carefully because this endpoint is exposed to unauthenticated users
970 // plugin data is not loaded because there's no user context and owner_uid/session may or may not be available
971 // in general, don't do anything user-related in here and do not modify $_SESSION
972 public function pluginhandler() {
973 $host = new PluginHost();
975 $plugin = basename(clean($_REQUEST["plugin"]));
976 $method = clean($_REQUEST["pmethod"]);
978 $host->load($plugin, PluginHost
::KIND_USER
, 0);
981 $pclass = $host->get_plugin($plugin);
984 if (method_exists($pclass, $method)) {
985 if ($pclass->is_public_method($method)) {
988 header("Content-Type: text/json");
992 header("Content-Type: text/json");
993 print error_json(13);
996 header("Content-Type: text/json");
997 print error_json(14);