]>
git.wh0rd.org - tt-rss.git/blob - classes/handler/public.php
403e20ca588bc3d4220500c7b53383dfd9b4b8a0
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";
18 $date_check_field = "date_entered";
20 if ($feed == -2 && !$is_cat) {
21 $date_sort_field = "last_published DESC";
22 $date_check_field = "last_published";
23 } else if ($feed == -1 && !$is_cat) {
24 $date_sort_field = "last_marked DESC";
25 $date_check_field = "last_marked";
30 $date_sort_field = "ttrss_entries.title";
33 $date_sort_field = "date_entered, updated";
36 $date_sort_field = "updated DESC";
41 "owner_uid" => $owner_uid,
44 "view_mode" => $view_mode,
45 "cat_view" => $is_cat,
47 "override_order" => $date_sort_field,
48 "include_children" => true,
49 "ignore_vfeed_group" => true,
51 "start_ts" => $start_ts
54 $qfh_ret = Feeds
::queryFeedHeadlines($params);
56 $result = $qfh_ret[0];
58 if ($this->dbh
->num_rows($result) != 0) {
60 $ts = strtotime($this->dbh
->fetch_result($result, 0, $date_check_field));
62 if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) &&
63 strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $ts) {
64 header('HTTP/1.0 304 Not Modified');
68 $last_modified = gmdate("D, d M Y H:i:s", $ts) . " GMT";
69 header("Last-Modified: $last_modified", true);
73 "owner_uid" => $owner_uid,
76 "view_mode" => $view_mode,
77 "cat_view" => $is_cat,
79 "override_order" => $date_sort_field,
80 "include_children" => true,
81 "ignore_vfeed_group" => true,
83 "start_ts" => $start_ts
86 $qfh_ret = Feeds
::queryFeedHeadlines($params);
88 $result = $qfh_ret[0];
89 $feed_title = htmlspecialchars($qfh_ret[1]);
90 $feed_site_url = $qfh_ret[2];
91 /* $last_error = $qfh_ret[3]; */
93 $feed_self_url = get_self_url_prefix() .
94 "/public.php?op=rss&id=$feed&key=" .
95 get_feed_access_key($feed, false, $owner_uid);
97 if (!$feed_site_url) $feed_site_url = get_self_url_prefix();
99 if ($format == 'atom') {
100 $tpl = new MiniTemplator
;
102 $tpl->readTemplateFromFile("templates/generated_feed.txt");
104 $tpl->setVariable('FEED_TITLE', $feed_title, true);
105 $tpl->setVariable('VERSION', VERSION
, true);
106 $tpl->setVariable('FEED_URL', htmlspecialchars($feed_self_url), true);
108 $tpl->setVariable('SELF_URL', htmlspecialchars(get_self_url_prefix()), true);
109 while ($line = $this->dbh
->fetch_assoc($result)) {
111 $line["content_preview"] = sanitize(truncate_string(strip_tags($line["content"]), 100, '...'));
113 foreach (PluginHost
::getInstance()->get_hooks(PluginHost
::HOOK_QUERY_HEADLINES
) as $p) {
114 $line = $p->hook_query_headlines($line);
117 foreach (PluginHost
::getInstance()->get_hooks(PluginHost
::HOOK_ARTICLE_EXPORT_FEED
) as $p) {
118 $line = $p->hook_article_export_feed($line, $feed, $is_cat);
121 $tpl->setVariable('ARTICLE_ID',
122 htmlspecialchars($orig_guid ?
$line['link'] :
123 $this->make_article_tag_uri($line['id'], $line['date_entered'])), true);
124 $tpl->setVariable('ARTICLE_LINK', htmlspecialchars($line['link']), true);
125 $tpl->setVariable('ARTICLE_TITLE', htmlspecialchars($line['title']), true);
126 $tpl->setVariable('ARTICLE_EXCERPT', $line["content_preview"], true);
128 $content = sanitize($line["content"], false, $owner_uid,
129 $feed_site_url, false, $line["id"]);
132 $content = "<div style=\"$note_style\">Article note: " . $line['note'] . "</div>" .
134 $tpl->setVariable('ARTICLE_NOTE', htmlspecialchars($line['note']), true);
137 $tpl->setVariable('ARTICLE_CONTENT', $content, true);
139 $tpl->setVariable('ARTICLE_UPDATED_ATOM',
140 date('c', strtotime($line["updated"])), true);
141 $tpl->setVariable('ARTICLE_UPDATED_RFC822',
142 date(DATE_RFC822
, strtotime($line["updated"])), true);
144 $tpl->setVariable('ARTICLE_AUTHOR', htmlspecialchars($line['author']), true);
146 $tpl->setVariable('ARTICLE_SOURCE_LINK', htmlspecialchars($line['site_url'] ?
$line["site_url"] : get_self_url_prefix()), true);
147 $tpl->setVariable('ARTICLE_SOURCE_TITLE', htmlspecialchars($line['feed_title'] ?
$line['feed_title'] : $feed_title), true);
149 $tags = Article
::get_article_tags($line["id"], $owner_uid);
151 foreach ($tags as $tag) {
152 $tpl->setVariable('ARTICLE_CATEGORY', htmlspecialchars($tag), true);
153 $tpl->addBlock('category');
156 $enclosures = Article
::get_article_enclosures($line["id"]);
158 foreach ($enclosures as $e) {
159 $type = htmlspecialchars($e['content_type']);
160 $url = htmlspecialchars($e['content_url']);
161 $length = $e['duration'] ?
$e['duration'] : 1;
163 $tpl->setVariable('ARTICLE_ENCLOSURE_URL', $url, true);
164 $tpl->setVariable('ARTICLE_ENCLOSURE_TYPE', $type, true);
165 $tpl->setVariable('ARTICLE_ENCLOSURE_LENGTH', $length, true);
167 $tpl->addBlock('enclosure');
170 $tpl->addBlock('entry');
175 $tpl->addBlock('feed');
176 $tpl->generateOutputToString($tmp);
178 if (@!$_REQUEST["noxml"]) {
179 header("Content-Type: text/xml; charset=utf-8");
181 header("Content-Type: text/plain; charset=utf-8");
185 } else if ($format == 'json') {
189 $feed['title'] = $feed_title;
190 $feed['version'] = VERSION
;
191 $feed['feed_url'] = $feed_self_url;
193 $feed['self_url'] = get_self_url_prefix();
195 $feed['articles'] = array();
197 while ($line = $this->dbh
->fetch_assoc($result)) {
199 $line["content_preview"] = sanitize(truncate_string(strip_tags($line["content_preview"]), 100, '...'));
201 foreach (PluginHost
::getInstance()->get_hooks(PluginHost
::HOOK_QUERY_HEADLINES
) as $p) {
202 $line = $p->hook_query_headlines($line, 100);
205 foreach (PluginHost
::getInstance()->get_hooks(PluginHost
::HOOK_ARTICLE_EXPORT_FEED
) as $p) {
206 $line = $p->hook_article_export_feed($line, $feed, $is_cat);
211 $article['id'] = $line['link'];
212 $article['link'] = $line['link'];
213 $article['title'] = $line['title'];
214 $article['excerpt'] = $line["content_preview"];
215 $article['content'] = sanitize($line["content"], false, $owner_uid, $feed_site_url, false, $line["id"]);
216 $article['updated'] = date('c', strtotime($line["updated"]));
218 if ($line['note']) $article['note'] = $line['note'];
219 if ($article['author']) $article['author'] = $line['author'];
221 $tags = Article
::get_article_tags($line["id"], $owner_uid);
223 if (count($tags) > 0) {
224 $article['tags'] = array();
226 foreach ($tags as $tag) {
227 array_push($article['tags'], $tag);
231 $enclosures = Article
::get_article_enclosures($line["id"]);
233 if (count($enclosures) > 0) {
234 $article['enclosures'] = array();
236 foreach ($enclosures as $e) {
237 $type = $e['content_type'];
238 $url = $e['content_url'];
239 $length = $e['duration'];
241 array_push($article['enclosures'], array("url" => $url, "type" => $type, "length" => $length));
245 array_push($feed['articles'], $article);
248 header("Content-Type: text/json; charset=utf-8");
249 print json_encode($feed);
252 header("Content-Type: text/plain; charset=utf-8");
253 print json_encode(array("error" => array("message" => "Unknown format")));
257 function getUnread() {
258 $login = $this->dbh
->escape_string($_REQUEST["login"]);
259 $fresh = $_REQUEST["fresh"] == "1";
261 $result = $this->dbh
->query("SELECT id FROM ttrss_users WHERE login = '$login'");
263 if ($this->dbh
->num_rows($result) == 1) {
264 $uid = $this->dbh
->fetch_result($result, 0, "id");
266 print Feeds
::getGlobalUnread($uid);
270 print Feeds
::getFeedArticles(-3, false, true, $uid);
274 print "-1;User not found";
279 function getProfiles() {
280 $login = $this->dbh
->escape_string($_REQUEST["login"]);
282 $result = $this->dbh
->query("SELECT ttrss_settings_profiles.* FROM ttrss_settings_profiles,ttrss_users
283 WHERE ttrss_users.id = ttrss_settings_profiles.owner_uid AND login = '$login' ORDER BY title");
285 print "<select dojoType='dijit.form.Select' style='width : 220px; margin : 0px' name='profile'>";
287 print "<option value='0'>" . __("Default profile") . "</option>";
289 while ($line = $this->dbh
->fetch_assoc($result)) {
291 $title = $line["title"];
293 print "<option value='$id'>$title</option>";
301 header("Location: index.php");
305 $uuid = $this->dbh
->escape_string($_REQUEST["key"]);
307 $result = $this->dbh
->query("SELECT ref_id, owner_uid FROM ttrss_user_entries WHERE
310 if ($this->dbh
->num_rows($result) != 0) {
311 header("Content-Type: text/html");
313 $id = $this->dbh
->fetch_result($result, 0, "ref_id");
314 $owner_uid = $this->dbh
->fetch_result($result, 0, "owner_uid");
316 $article = Article
::format_article($id, false, true, $owner_uid);
318 print_r($article['content']);
321 print "Article not found.";
327 $feed = $this->dbh
->escape_string($_REQUEST["id"]);
328 $key = $this->dbh
->escape_string($_REQUEST["key"]);
329 $is_cat = sql_bool_to_bool($_REQUEST["is_cat"]);
330 $limit = (int)$this->dbh
->escape_string($_REQUEST["limit"]);
331 $offset = (int)$this->dbh
->escape_string($_REQUEST["offset"]);
333 $search = $this->dbh
->escape_string($_REQUEST["q"]);
334 $view_mode = $this->dbh
->escape_string($_REQUEST["view-mode"]);
335 $order = $this->dbh
->escape_string($_REQUEST["order"]);
336 $start_ts = $this->dbh
->escape_string($_REQUEST["ts"]);
338 $format = $this->dbh
->escape_string($_REQUEST['format']);
339 $orig_guid = sql_bool_to_bool($_REQUEST["orig_guid"]);
341 if (!$format) $format = 'atom';
343 if (SINGLE_USER_MODE
) {
344 authenticate_user("admin", null);
350 $result = $this->dbh
->query("SELECT owner_uid FROM
351 ttrss_access_keys WHERE access_key = '$key' AND feed_id = '$feed'");
353 if ($this->dbh
->num_rows($result) == 1)
354 $owner_id = $this->dbh
->fetch_result($result, 0, "owner_uid");
358 $this->generate_syndicated_feed($owner_id, $feed, $is_cat, $limit,
359 $offset, $search, $view_mode, $format, $order, $orig_guid, $start_ts);
361 header('HTTP/1.1 403 Forbidden');
365 function updateTask() {
366 PluginHost
::getInstance()->run_hooks(PluginHost
::HOOK_UPDATE_TASK
, "hook_update_task", false);
369 function housekeepingTask() {
370 PluginHost
::getInstance()->run_hooks(PluginHost
::HOOK_HOUSE_KEEPING
, "hook_house_keeping", false);
373 function globalUpdateFeeds() {
374 RPC
::updaterandomfeed_real($this->dbh
);
376 PluginHost
::getInstance()->run_hooks(PluginHost
::HOOK_UPDATE_TASK
, "hook_update_task", false);
379 function sharepopup() {
380 if (SINGLE_USER_MODE
) {
384 header('Content-Type: text/html; charset=utf-8');
385 print "<html><head><title>Tiny Tiny RSS</title>
386 <link rel=\"shortcut icon\" type=\"image/png\" href=\"images/favicon.png\">
387 <link rel=\"icon\" type=\"image/png\" sizes=\"72x72\" href=\"images/favicon-72px.png\">";
389 echo stylesheet_tag("css/utility.css");
390 echo stylesheet_tag("css/dijit.css");
391 echo javascript_tag("lib/prototype.js");
392 echo javascript_tag("lib/scriptaculous/scriptaculous.js?load=effects,controls");
393 print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
394 </head><body id='sharepopup'>";
396 $action = $_REQUEST["action"];
398 if ($_SESSION["uid"]) {
400 if ($action == 'share') {
402 $title = $this->dbh
->escape_string(strip_tags($_REQUEST["title"]));
403 $url = $this->dbh
->escape_string(strip_tags($_REQUEST["url"]));
404 $content = $this->dbh
->escape_string(strip_tags($_REQUEST["content"]));
405 $labels = $this->dbh
->escape_string(strip_tags($_REQUEST["labels"]));
407 Article
::create_published_article($title, $url, $content, $labels,
410 print "<script type='text/javascript'>";
411 print "window.close();";
415 $title = htmlspecialchars($_REQUEST["title"]);
416 $url = htmlspecialchars($_REQUEST["url"]);
420 <table height
='100%' width
='100%'><tr
><td colspan
='2'>
421 <h1
><?php
echo __("Share with Tiny Tiny RSS") ?
></h1
>
424 <form id
='share_form' name
='share_form'>
426 <input type
="hidden" name
="op" value
="sharepopup">
427 <input type
="hidden" name
="action" value
="share">
429 <tr
><td align
='right'><?php
echo __("Title:") ?
></td
>
430 <td width
='80%'><input name
='title' value
="<?php echo $title ?>"></td
></tr
>
431 <tr
><td align
='right'><?php
echo __("URL:") ?
></td
>
432 <td
><input name
='url' value
="<?php echo $url ?>"></td
></tr
>
433 <tr
><td align
='right'><?php
echo __("Content:") ?
></td
>
434 <td
><input name
='content' value
=""></td
></tr
>
435 <tr
><td align
='right'><?php
echo __("Labels:") ?
></td
>
436 <td
><input name
='labels' id
="labels_value"
437 placeholder
='Alpha, Beta, Gamma' value
="">
441 <div
class="autocomplete" id
="labels_choices"
442 style
="display : block"></div
></td
></tr
>
444 <script type
='text/javascript'>document
.forms
[0].title
.focus();</script
>
446 <script type
='text/javascript'>
447 new Ajax
.Autocompleter('labels_value', 'labels_choices',
448 "backend.php?op=rpc&method=completeLabels",
449 { tokens
: ',', paramName
: "search" });
453 <div style
='float : right' class='insensitive-small'>
454 <?php
echo __("Shared article will appear in the Published feed.") ?
>
456 <button type
="submit"><?php
echo __('Share') ?
></button
>
457 <button onclick
="return window.close()"><?php
echo __('Cancel') ?
></button
>
469 $return = urlencode($_SERVER["REQUEST_URI"])
472 <form action
="public.php?return=<?php echo $return ?>"
473 method
="POST" id
="loginForm" name
="loginForm">
475 <input type
="hidden" name
="op" value
="login">
477 <table height
='100%' width
='100%'><tr
><td colspan
='2'>
478 <h1
><?php
echo __("Not logged in") ?
></h1
></td
></tr
>
480 <tr
><td align
="right"><?php
echo __("Login:") ?
></td
>
481 <td align
="right"><input name
="login"
482 value
="<?php echo $_SESSION["fake_login
"] ?>"></td
></tr
>
483 <tr
><td align
="right"><?php
echo __("Password:") ?
></td
>
484 <td align
="right"><input type
="password" name
="password"
485 value
="<?php echo $_SESSION["fake_password
"] ?>"></td
></tr
>
487 <button type
="submit">
488 <?php
echo __('Log in') ?
></button
>
490 <button onclick
="return window.close()">
491 <?php
echo __('Cancel') ?
></button
>
501 if (!SINGLE_USER_MODE
) {
503 $login = $this->dbh
->escape_string($_POST["login"]);
504 $password = $_POST["password"];
505 $remember_me = $_POST["remember_me"];
508 session_set_cookie_params(SESSION_COOKIE_LIFETIME
);
510 session_set_cookie_params(0);
515 if (authenticate_user($login, $password)) {
516 $_POST["password"] = "";
518 if (get_schema_version() >= 120) {
519 $_SESSION["language"] = get_pref("USER_LANGUAGE", $_SESSION["uid"]);
522 $_SESSION["ref_schema_version"] = get_schema_version(true);
523 $_SESSION["bw_limit"] = !!$_POST["bw_limit"];
525 if ($_POST["profile"]) {
527 $profile = $this->dbh
->escape_string($_POST["profile"]);
529 $result = $this->dbh
->query("SELECT id FROM ttrss_settings_profiles
530 WHERE id = '$profile' AND owner_uid = " . $_SESSION["uid"]);
532 if ($this->dbh
->num_rows($result) != 0) {
533 $_SESSION["profile"] = $profile;
537 $_SESSION["login_error_msg"] = __("Incorrect username or password");
538 user_error("Failed login attempt for $login from {$_SERVER['REMOTE_ADDR']}", E_USER_WARNING
);
541 if ($_REQUEST['return']) {
542 header("Location: " . $_REQUEST['return']);
544 header("Location: " . SELF_URL_PATH
);
549 /* function subtest() {
550 header("Content-type: text/plain; charset=utf-8");
552 $url = $_REQUEST["url"];
557 print_r(get_feeds_from_html($url, fetch_file_contents($url)));
561 function subscribe() {
562 if (SINGLE_USER_MODE
) {
566 if ($_SESSION["uid"]) {
568 $feed_url = $this->dbh
->escape_string(trim($_REQUEST["feed_url"]));
570 header('Content-Type: text/html; charset=utf-8');
573 <title>Tiny Tiny RSS</title>
574 <link rel=\"stylesheet\" type=\"text/css\" href=\"css/utility.css\">
575 <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
576 <link rel=\"shortcut icon\" type=\"image/png\" href=\"images/favicon.png\">
577 <link rel=\"icon\" type=\"image/png\" sizes=\"72x72\" href=\"images/favicon-72px.png\">
581 <img class=\"floatingLogo\" src=\"images/logo_small.png\"
582 alt=\"Tiny Tiny RSS\"/>
583 <h1>".__("Subscribe to feed...")."</h1><div class='content'>";
585 $rc = Feeds
::subscribe_to_feed($feed_url);
587 switch ($rc['code']) {
589 print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url));
592 print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url));
595 print_error(T_sprintf("Could not subscribe to <b>%s</b>.", $feed_url));
598 print_error(T_sprintf("No feeds found in <b>%s</b>.", $feed_url));
601 print_notice(__("Multiple feed URLs found."));
602 $feed_urls = $rc["feeds"];
605 print_error(T_sprintf("Could not subscribe to <b>%s</b>.<br>Can't download the Feed URL.", $feed_url));
611 print "<form action=\"public.php\">";
612 print "<input type=\"hidden\" name=\"op\" value=\"subscribe\">";
614 print "<select name=\"feed_url\">";
616 foreach ($feed_urls as $url => $name) {
617 $url = htmlspecialchars($url);
618 $name = htmlspecialchars($name);
620 print "<option value=\"$url\">$name</option>";
623 print "<input type=\"submit\" value=\"".__("Subscribe to selected feed").
629 $tp_uri = get_self_url_prefix() . "/prefs.php";
630 $tt_uri = get_self_url_prefix();
632 if ($rc['code'] <= 2){
633 $result = $this->dbh
->query("SELECT id FROM ttrss_feeds WHERE
634 feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
636 $feed_id = $this->dbh
->fetch_result($result, 0, "id");
643 print "<form method=\"GET\" style='display: inline'
645 <input type=\"hidden\" name=\"tab\" value=\"feedConfig\">
646 <input type=\"hidden\" name=\"method\" value=\"editFeed\">
647 <input type=\"hidden\" name=\"methodparam\" value=\"$feed_id\">
648 <input type=\"submit\" value=\"".__("Edit subscription options")."\">
652 print "<form style='display: inline' method=\"GET\" action=\"$tt_uri\">
653 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
656 print "</div></body></html>";
664 header("Content-Type: text/plain");
665 print error_json(13);
668 function forgotpass() {
671 @$hash = $_REQUEST["hash"];
673 header('Content-Type: text/html; charset=utf-8');
674 print "<html><head><title>Tiny Tiny RSS</title>
675 <link rel=\"shortcut icon\" type=\"image/png\" href=\"images/favicon.png\">
676 <link rel=\"icon\" type=\"image/png\" sizes=\"72x72\" href=\"images/favicon-72px.png\">";
678 echo stylesheet_tag("css/utility.css");
679 echo javascript_tag("lib/prototype.js");
681 print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
682 </head><body id='forgotpass'>";
684 print '<div class="floatingLogo"><img src="images/logo_small.png"></div>';
685 print "<h1>".__("Password recovery")."</h1>";
686 print "<div class='content'>";
688 @$method = $_POST['method'];
691 $login = $_REQUEST["login"];
694 $result = $this->dbh
->query("SELECT id, resetpass_token FROM ttrss_users
695 WHERE login = '$login'");
697 if ($this->dbh
->num_rows($result) != 0) {
698 $id = $this->dbh
->fetch_result($result, 0, "id");
699 $resetpass_token_full = $this->dbh
->fetch_result($result, 0, "resetpass_token");
700 list($timestamp, $resetpass_token) = explode(":", $resetpass_token_full);
702 if ($timestamp && $resetpass_token &&
703 $timestamp >= time() - 15*60*60 &&
704 $resetpass_token == $hash) {
706 $result = $this->dbh
->query("UPDATE ttrss_users SET resetpass_token = NULL
709 Pref_Users
::resetUserPassword($id, true);
711 print "<p>"."Completed."."</p>";
714 print_error("Some of the information provided is missing or incorrect.");
717 print_error("Some of the information provided is missing or incorrect.");
720 print_error("Some of the information provided is missing or incorrect.");
723 print "<form method=\"GET\" action=\"index.php\">
724 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
727 } else if (!$method) {
728 print_notice(__("You will need to provide valid account name and email. A password reset link will be sent to your email address."));
730 print "<form method='POST' action='public.php'>";
731 print "<input type='hidden' name='method' value='do'>";
732 print "<input type='hidden' name='op' value='forgotpass'>";
735 print "<label>".__("Login:")."</label>";
736 print "<input type='text' name='login' value='' required>";
740 print "<label>".__("Email:")."</label>";
741 print "<input type='email' name='email' value='' required>";
745 print "<label>".__("How much is two plus two:")."</label>";
746 print "<input type='text' name='test' value='' required>";
750 print "<button type='submit'>".__("Reset password")."</button>";
753 } else if ($method == 'do') {
755 $login = $this->dbh
->escape_string($_POST["login"]);
756 $email = $this->dbh
->escape_string($_POST["email"]);
757 $test = $this->dbh
->escape_string($_POST["test"]);
759 if (($test != 4 && $test != 'four') ||
!$email ||
!$login) {
760 print_error(__('Some of the required form parameters are missing or incorrect.'));
762 print "<form method=\"GET\" action=\"public.php\">
763 <input type=\"hidden\" name=\"op\" value=\"forgotpass\">
764 <input type=\"submit\" value=\"".__("Go back")."\">
769 print_notice("Password reset instructions are being sent to your email address.");
771 $result = $this->dbh
->query("SELECT id FROM ttrss_users
772 WHERE login = '$login' AND email = '$email'");
774 if ($this->dbh
->num_rows($result) != 0) {
775 $id = $this->dbh
->fetch_result($result, 0, "id");
778 $resetpass_token = sha1(get_random_bytes(128));
779 $resetpass_link = get_self_url_prefix() . "/public.php?op=forgotpass&hash=" . $resetpass_token .
780 "&login=" . urlencode($login);
782 require_once 'classes/ttrssmailer.php';
783 require_once "lib/MiniTemplator.class.php";
785 $tpl = new MiniTemplator
;
787 $tpl->readTemplateFromFile("templates/resetpass_link_template.txt");
789 $tpl->setVariable('LOGIN', $login);
790 $tpl->setVariable('RESETPASS_LINK', $resetpass_link);
792 $tpl->addBlock('message');
796 $tpl->generateOutputToString($message);
798 $mail = new ttrssMailer();
800 $rc = $mail->quickMail($email, $login,
801 __("[tt-rss] Password reset request"),
804 if (!$rc) print_error($mail->ErrorInfo
);
806 $resetpass_token_full = $this->dbh
->escape_string(time() . ":" . $resetpass_token);
808 $result = $this->dbh
->query("UPDATE ttrss_users
809 SET resetpass_token = '$resetpass_token_full'
810 WHERE login = '$login' AND email = '$email'");
812 //Pref_Users::resetUserPassword($id, false);
816 print "<p>"."Completed."."</p>";
818 print_error("User ID not found.");
821 print "<form method=\"GET\" action=\"index.php\">
822 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
826 print_error(__("Sorry, login and email combination not found."));
828 print "<form method=\"GET\" action=\"public.php\">
829 <input type=\"hidden\" name=\"op\" value=\"forgotpass\">
830 <input type=\"submit\" value=\"".__("Go back")."\">
844 function dbupdate() {
847 if (!SINGLE_USER_MODE
&& $_SESSION["access_level"] < 10) {
848 $_SESSION["login_error_msg"] = __("Your access level is insufficient to run this script.");
855 <title
>Database Updater
</title
>
856 <meta http
-equiv
="Content-Type" content
="text/html; charset=utf-8"/>
857 <link rel
="stylesheet" type
="text/css" href
="css/utility.css"/>
858 <link rel
=\"shortcut icon\" type
=\"image
/png\" href
=\"images
/favicon
.png\"
>
859 <link rel
=\"icon\" type
=\"image
/png\" sizes
=\"72x72\" href
=\"images
/favicon
-72px
.png\"
>
861 <style type
="text/css">
862 span
.ok
{ color
: #009000; font-weight : bold; }
863 span
.err
{ color
: #ff0000; font-weight : bold; }
866 <script type
='text/javascript'>
867 function confirmOP() {
868 return confirm("Update the database?");
872 <div
class="floatingLogo"><img src
="images/logo_small.png"></div
>
874 <h1
><?php
echo __("Database Updater") ?
></h1
>
876 <div
class="content">
879 @$op = $_REQUEST["subop"];
880 $updater = new DbUpdater(Db
::get(), DB_TYPE
, SCHEMA_VERSION
);
882 if ($op == "performupdate") {
883 if ($updater->isUpdateRequired()) {
885 print "<h2>Performing updates</h2>";
887 print "<h3>Updating to schema version " . SCHEMA_VERSION
. "</h3>";
891 for ($i = $updater->getSchemaVersion() +
1; $i <= SCHEMA_VERSION
; $i++
) {
892 print "<li>Performing update up to version $i...";
894 $result = $updater->performUpdateTo($i, true);
897 print "<span class='err'>FAILED!</span></li></ul>";
899 print_warning("One of the updates failed. Either retry the process or perform updates manually.");
900 print "<p><form method=\"GET\" action=\"index.php\">
901 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
906 print "<span class='ok'>OK!</span></li>";
912 print_notice("Your Tiny Tiny RSS database is now updated to the latest version.");
914 print "<p><form method=\"GET\" action=\"index.php\">
915 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
919 print "<h2>Your database is up to date.</h2>";
921 print "<p><form method=\"GET\" action=\"index.php\">
922 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
926 if ($updater->isUpdateRequired()) {
928 print "<h2>Database update required</h2>";
931 sprintf("Your Tiny Tiny RSS database needs update to the latest version: %d to %d.",
932 $updater->getSchemaVersion(), SCHEMA_VERSION
).
935 print_warning("Please backup your database before proceeding.");
937 print "<form method='POST'>
938 <input type='hidden' name='subop' value='performupdate'>
939 <input type='submit' onclick='return confirmOP()' value='".__("Perform updates")."'>
944 print_notice("Tiny Tiny RSS database is up to date.");
946 print "<p><form method=\"GET\" action=\"index.php\">
947 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
960 function cached_url() {
961 @$hash = basename($_GET['hash']);
963 // we don't need an extension to find the file, hash is a complete URL
964 $hash = preg_replace("/\.[^\.]*$/", "", $hash);
968 $filename = CACHE_DIR
. '/images/' . $hash;
970 if (file_exists($filename)) {
971 header("Content-Disposition: inline; filename=\"$hash\"");
972 $mimetype = mime_content_type($filename);
974 /* See if we can use X-Sendfile */
976 if (function_exists('apache_get_modules') &&
977 array_search('mod_xsendfile', apache_get_modules()))
981 header("X-Sendfile: $filename");
982 header("Content-type: $mimetype");
983 header('Content-Disposition: inline; filename="' . basename($filename) . '"');
985 header("Content-type: $mimetype");
986 $stamp = gmdate("D, d M Y H:i:s", filemtime($filename)). " GMT";
987 header("Last-Modified: $stamp", true);
991 header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
992 echo "File not found.";
997 private function make_article_tag_uri($id, $timestamp) {
999 $timestamp = date("Y-m-d", strtotime($timestamp));
1001 return "tag:" . parse_url(get_self_url_prefix(), PHP_URL_HOST
) . ",$timestamp:/$id";
1004 // this should be used very carefully because this endpoint is exposed to unauthenticated users
1005 // plugin data is not loaded because there's no user context and owner_uid/session may or may not be available
1006 // in general, don't do anything user-related in here and do not modify $_SESSION
1007 public function pluginhandler() {
1008 $host = new PluginHost();
1010 $plugin = basename($_REQUEST["plugin"]);
1011 $method = $_REQUEST["pmethod"];
1013 $host->load($plugin, PluginHost
::KIND_USER
, 0);
1016 $pclass = $host->get_plugin($plugin);
1019 if (method_exists($pclass, $method)) {
1020 if ($pclass->is_public_method($method)) {
1023 header("Content-Type: text/json");
1024 print error_json(6);
1027 header("Content-Type: text/json");
1028 print error_json(13);
1031 header("Content-Type: text/json");
1032 print error_json(14);