]>
git.wh0rd.org - tt-rss.git/blob - classes/handler/public.php
0d6ef11c0896988525c99d3066e649b76ef0591b
2 class Handler_Public
extends Handler
{
4 private function generate_syndicated_feed($owner_uid, $feed, $is_cat,
5 $limit, $offset, $search, $search_mode,
6 $view_mode = false, $format = 'atom', $order = false, $orig_guid = 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";
20 $date_sort_field = "last_published DESC";
22 $date_sort_field = "last_marked DESC";
26 $date_sort_field = "ttrss_entries.title";
29 $date_sort_field = "date_entered, updated";
32 $date_sort_field = "updated DESC";
36 $qfh_ret = queryFeedHeadlines($feed,
37 1, $view_mode, $is_cat, $search, $search_mode,
38 $date_sort_field, $offset, $owner_uid,
39 false, 0, false, true);
41 $result = $qfh_ret[0];
43 if ($this->dbh
->num_rows($result) != 0) {
44 $ts = strtotime($this->dbh
->fetch_result($result, 0, "date_entered"));
46 if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) &&
47 strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $ts) {
48 header('HTTP/1.0 304 Not Modified');
52 $last_modified = gmdate("D, d M Y H:i:s", $ts) . " GMT";
53 header("Last-Modified: $last_modified", true);
56 $qfh_ret = queryFeedHeadlines($feed,
57 $limit, $view_mode, $is_cat, $search, $search_mode,
58 $date_sort_field, $offset, $owner_uid,
59 false, 0, false, true);
62 $result = $qfh_ret[0];
63 $feed_title = htmlspecialchars($qfh_ret[1]);
64 $feed_site_url = $qfh_ret[2];
65 $last_error = $qfh_ret[3];
67 $feed_self_url = get_self_url_prefix() .
68 "/public.php?op=rss&id=-2&key=" .
69 get_feed_access_key(-2, false, $owner_uid);
71 if (!$feed_site_url) $feed_site_url = get_self_url_prefix();
73 if ($format == 'atom') {
74 $tpl = new MiniTemplator
;
76 $tpl->readTemplateFromFile("templates/generated_feed.txt");
78 $tpl->setVariable('FEED_TITLE', $feed_title, true);
79 $tpl->setVariable('VERSION', VERSION
, true);
80 $tpl->setVariable('FEED_URL', htmlspecialchars($feed_self_url), true);
82 if (PUBSUBHUBBUB_HUB
&& $feed == -2) {
83 $tpl->setVariable('HUB_URL', htmlspecialchars(PUBSUBHUBBUB_HUB
), true);
84 $tpl->addBlock('feed_hub');
87 $tpl->setVariable('SELF_URL', htmlspecialchars(get_self_url_prefix()), true);
89 while ($line = $this->dbh
->fetch_assoc($result)) {
91 $tpl->setVariable('ARTICLE_ID',
92 htmlspecialchars($orig_guid ?
$line['link'] :
93 get_self_url_prefix() .
94 "/public.php?url=" . urlencode($line['link'])), true);
95 $tpl->setVariable('ARTICLE_LINK', htmlspecialchars($line['link']), true);
96 $tpl->setVariable('ARTICLE_TITLE', htmlspecialchars($line['title']), true);
97 $tpl->setVariable('ARTICLE_EXCERPT',
98 truncate_string(strip_tags($line["content_preview"]), 100, '...'), true);
100 $content = sanitize($line["content_preview"], false, $owner_uid);
103 $content = "<div style=\"$note_style\">Article note: " . $line['note'] . "</div>" .
105 $tpl->setVariable('ARTICLE_NOTE', htmlspecialchars($line['note']), true);
108 $tpl->setVariable('ARTICLE_CONTENT', $content, true);
110 $tpl->setVariable('ARTICLE_UPDATED_ATOM',
111 date('c', strtotime($line["updated"])), true);
112 $tpl->setVariable('ARTICLE_UPDATED_RFC822',
113 date(DATE_RFC822
, strtotime($line["updated"])), true);
115 $tpl->setVariable('ARTICLE_AUTHOR', htmlspecialchars($line['author']), true);
117 $tpl->setVariable('ARTICLE_SOURCE_LINK', htmlspecialchars($line['site_url']), true);
118 $tpl->setVariable('ARTICLE_SOURCE_TITLE', htmlspecialchars($line['feed_title']), true);
120 $tags = get_article_tags($line["id"], $owner_uid);
122 foreach ($tags as $tag) {
123 $tpl->setVariable('ARTICLE_CATEGORY', htmlspecialchars($tag), true);
124 $tpl->addBlock('category');
127 $enclosures = get_article_enclosures($line["id"]);
129 foreach ($enclosures as $e) {
130 $type = htmlspecialchars($e['content_type']);
131 $url = htmlspecialchars($e['content_url']);
132 $length = $e['duration'];
134 $tpl->setVariable('ARTICLE_ENCLOSURE_URL', $url, true);
135 $tpl->setVariable('ARTICLE_ENCLOSURE_TYPE', $type, true);
136 $tpl->setVariable('ARTICLE_ENCLOSURE_LENGTH', $length, true);
138 $tpl->addBlock('enclosure');
141 $tpl->addBlock('entry');
146 $tpl->addBlock('feed');
147 $tpl->generateOutputToString($tmp);
149 if (@!$_REQUEST["noxml"]) {
150 header("Content-Type: text/xml; charset=utf-8");
152 header("Content-Type: text/plain; charset=utf-8");
156 } else if ($format == 'json') {
160 $feed['title'] = $feed_title;
161 $feed['version'] = VERSION
;
162 $feed['feed_url'] = $feed_self_url;
164 if (PUBSUBHUBBUB_HUB
&& $feed == -2) {
165 $feed['hub_url'] = PUBSUBHUBBUB_HUB
;
168 $feed['self_url'] = get_self_url_prefix();
170 $feed['articles'] = array();
172 while ($line = $this->dbh
->fetch_assoc($result)) {
175 $article['id'] = $line['link'];
176 $article['link'] = $line['link'];
177 $article['title'] = $line['title'];
178 $article['excerpt'] = truncate_string(strip_tags($line["content_preview"]), 100, '...');
179 $article['content'] = sanitize($line["content_preview"], false, $owner_uid);
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 = 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 = 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 = $this->dbh
->escape_string($_REQUEST["login"]);
223 $fresh = $_REQUEST["fresh"] == "1";
225 $result = $this->dbh
->query("SELECT id FROM ttrss_users WHERE login = '$login'");
227 if ($this->dbh
->num_rows($result) == 1) {
228 $uid = $this->dbh
->fetch_result($result, 0, "id");
230 print getGlobalUnread($uid);
234 print getFeedArticles(-3, false, true, $uid);
238 print "-1;User not found";
243 function getProfiles() {
244 $login = $this->dbh
->escape_string($_REQUEST["login"]);
246 $result = $this->dbh
->query("SELECT ttrss_settings_profiles.* FROM ttrss_settings_profiles,ttrss_users
247 WHERE ttrss_users.id = ttrss_settings_profiles.owner_uid AND login = '$login' ORDER BY title");
249 print "<select dojoType='dijit.form.Select' style='width : 220px; margin : 0px' name='profile'>";
251 print "<option value='0'>" . __("Default profile") . "</option>";
253 while ($line = $this->dbh
->fetch_assoc($result)) {
255 $title = $line["title"];
257 print "<option value='$id'>$title</option>";
264 $mode = $this->dbh
->escape_string($_REQUEST['hub_mode']);
265 $feed_id = (int) $this->dbh
->escape_string($_REQUEST['id']);
266 $feed_url = $this->dbh
->escape_string($_REQUEST['hub_topic']);
268 if (!PUBSUBHUBBUB_ENABLED
) {
269 header('HTTP/1.0 404 Not Found');
270 echo "404 Not found";
274 // TODO: implement hub_verifytoken checking
276 $result = $this->dbh
->query("SELECT feed_url FROM ttrss_feeds
277 WHERE id = '$feed_id'");
279 if ($this->dbh
->num_rows($result) != 0) {
281 $check_feed_url = $this->dbh
->fetch_result($result, 0, "feed_url");
283 if ($check_feed_url && ($check_feed_url == $feed_url ||
!$feed_url)) {
284 if ($mode == "subscribe") {
286 $this->dbh
->query("UPDATE ttrss_feeds SET pubsub_state = 2
287 WHERE id = '$feed_id'");
289 print $_REQUEST['hub_challenge'];
292 } else if ($mode == "unsubscribe") {
294 $this->dbh
->query("UPDATE ttrss_feeds SET pubsub_state = 0
295 WHERE id = '$feed_id'");
297 print $_REQUEST['hub_challenge'];
302 // Received update ping, schedule feed update.
303 //update_rss_feed($feed_id, true, true);
305 $this->dbh
->query("UPDATE ttrss_feeds SET
306 last_update_started = '1970-01-01',
307 last_updated = '1970-01-01' WHERE id = '$feed_id'");
311 header('HTTP/1.0 404 Not Found');
312 echo "404 Not found";
315 header('HTTP/1.0 404 Not Found');
316 echo "404 Not found";
323 header("Location: index.php");
327 $uuid = $this->dbh
->escape_string($_REQUEST["key"]);
329 $result = $this->dbh
->query("SELECT ref_id, owner_uid FROM ttrss_user_entries WHERE
332 if ($this->dbh
->num_rows($result) != 0) {
333 header("Content-Type: text/html");
335 $id = $this->dbh
->fetch_result($result, 0, "ref_id");
336 $owner_uid = $this->dbh
->fetch_result($result, 0, "owner_uid");
338 $article = format_article($id, false, true, $owner_uid);
340 print_r($article['content']);
343 print "Article not found.";
349 $feed = $this->dbh
->escape_string($_REQUEST["id"]);
350 $key = $this->dbh
->escape_string($_REQUEST["key"]);
351 $is_cat = sql_bool_to_bool($_REQUEST["is_cat"]);
352 $limit = (int)$this->dbh
->escape_string($_REQUEST["limit"]);
353 $offset = (int)$this->dbh
->escape_string($_REQUEST["offset"]);
355 $search = $this->dbh
->escape_string($_REQUEST["q"]);
356 $search_mode = $this->dbh
->escape_string($_REQUEST["smode"]);
357 $view_mode = $this->dbh
->escape_string($_REQUEST["view-mode"]);
358 $order = $this->dbh
->escape_string($_REQUEST["order"]);
360 $format = $this->dbh
->escape_string($_REQUEST['format']);
361 $orig_guid = !sql_bool_to_bool($_REQUEST["no_orig_guid"]);
363 if (!$format) $format = 'atom';
365 if (SINGLE_USER_MODE
) {
366 authenticate_user("admin", null);
372 $result = $this->dbh
->query("SELECT owner_uid FROM
373 ttrss_access_keys WHERE access_key = '$key' AND feed_id = '$feed'");
375 if ($this->dbh
->num_rows($result) == 1)
376 $owner_id = $this->dbh
->fetch_result($result, 0, "owner_uid");
380 $this->generate_syndicated_feed($owner_id, $feed, $is_cat, $limit,
381 $offset, $search, $search_mode, $view_mode, $format, $order, $orig_guid);
383 header('HTTP/1.1 403 Forbidden');
387 function globalUpdateFeeds() {
388 include "rssfuncs.php";
389 // Update all feeds needing a update.
390 update_daemon_common(0, true, false);
391 housekeeping_common(false);
393 PluginHost
::getInstance()->run_hooks(PluginHost
::HOOK_UPDATE_TASK
, "hook_update_task", $op);
397 function sharepopup() {
398 if (SINGLE_USER_MODE
) {
402 header('Content-Type: text/html; charset=utf-8');
403 print "<html><head><title>Tiny Tiny RSS</title>";
405 stylesheet_tag("css/utility.css");
406 javascript_tag("lib/prototype.js");
407 javascript_tag("lib/scriptaculous/scriptaculous.js?load=effects,dragdrop,controls");
408 print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
409 </head><body id='sharepopup'>";
411 $action = $_REQUEST["action"];
413 if ($_SESSION["uid"]) {
415 if ($action == 'share') {
417 $title = $this->dbh
->escape_string(strip_tags($_REQUEST["title"]));
418 $url = $this->dbh
->escape_string(strip_tags($_REQUEST["url"]));
419 $content = $this->dbh
->escape_string(strip_tags($_REQUEST["content"]));
420 $labels = $this->dbh
->escape_string(strip_tags($_REQUEST["labels"]));
422 Article
::create_published_article($title, $url, $content, $labels,
425 print "<script type='text/javascript'>";
426 print "window.close();";
430 $title = htmlspecialchars($_REQUEST["title"]);
431 $url = htmlspecialchars($_REQUEST["url"]);
435 <table height
='100%' width
='100%'><tr
><td colspan
='2'>
436 <h1
><?php
echo __("Share with Tiny Tiny RSS") ?
></h1
>
439 <form id
='share_form' name
='share_form'>
441 <input type
="hidden" name
="op" value
="sharepopup">
442 <input type
="hidden" name
="action" value
="share">
444 <tr
><td align
='right'><?php
echo __("Title:") ?
></td
>
445 <td width
='80%'><input name
='title' value
="<?php echo $title ?>"></td
></tr
>
446 <tr
><td align
='right'><?php
echo __("URL:") ?
></td
>
447 <td
><input name
='url' value
="<?php echo $url ?>"></td
></tr
>
448 <tr
><td align
='right'><?php
echo __("Content:") ?
></td
>
449 <td
><input name
='content' value
=""></td
></tr
>
450 <tr
><td align
='right'><?php
echo __("Labels:") ?
></td
>
451 <td
><input name
='labels' id
="labels_value"
452 placeholder
='Alpha, Beta, Gamma' value
="">
456 <div
class="autocomplete" id
="labels_choices"
457 style
="display : block"></div
></td
></tr
>
459 <script type
='text/javascript'>document
.forms
[0].title
.focus();</script
>
461 <script type
='text/javascript'>
462 new Ajax
.Autocompleter('labels_value', 'labels_choices',
463 "backend.php?op=rpc&method=completeLabels",
464 { tokens
: ',', paramName
: "search" });
468 <div style
='float : right' class='insensitive-small'>
469 <?php
echo __("Shared article will appear in the Published feed.") ?
>
471 <button type
="submit"><?php
echo __('Share') ?
></button
>
472 <button onclick
="return window.close()"><?php
echo __('Cancel') ?
></button
>
484 $return = urlencode($_SERVER["REQUEST_URI"])
487 <form action
="public.php?return=<?php echo $return ?>"
488 method
="POST" id
="loginForm" name
="loginForm">
490 <input type
="hidden" name
="op" value
="login">
492 <table height
='100%' width
='100%'><tr
><td colspan
='2'>
493 <h1
><?php
echo __("Not logged in") ?
></h1
></td
></tr
>
495 <tr
><td align
="right"><?php
echo __("Login:") ?
></td
>
496 <td align
="right"><input name
="login"
497 value
="<?php echo $_SESSION["fake_login
"] ?>"></td
></tr
>
498 <tr
><td align
="right"><?php
echo __("Password:") ?
></td
>
499 <td align
="right"><input type
="password" name
="password"
500 value
="<?php echo $_SESSION["fake_password
"] ?>"></td
></tr
>
502 <button type
="submit">
503 <?php
echo __('Log in') ?
></button
>
505 <button onclick
="return window.close()">
506 <?php
echo __('Cancel') ?
></button
>
516 if (!SINGLE_USER_MODE
) {
518 $login = $this->dbh
->escape_string($_POST["login"]);
519 $password = $_POST["password"];
520 $remember_me = $_POST["remember_me"];
523 session_set_cookie_params(SESSION_COOKIE_LIFETIME
);
525 session_set_cookie_params(0);
530 if (authenticate_user($login, $password)) {
531 $_POST["password"] = "";
533 if (get_schema_version() >= 120) {
534 $_SESSION["language"] = get_pref("USER_LANGUAGE", $_SESSION["uid"]);
537 $_SESSION["ref_schema_version"] = get_schema_version(true);
538 $_SESSION["bw_limit"] = !!$_POST["bw_limit"];
540 if ($_POST["profile"]) {
542 $profile = $this->dbh
->escape_string($_POST["profile"]);
544 $result = $this->dbh
->query("SELECT id FROM ttrss_settings_profiles
545 WHERE id = '$profile' AND owner_uid = " . $_SESSION["uid"]);
547 if ($this->dbh
->num_rows($result) != 0) {
548 $_SESSION["profile"] = $profile;
552 $_SESSION["login_error_msg"] = __("Incorrect username or password");
553 user_error("Failed login attempt from {$_SERVER['REMOTE_ADDR']}", E_USER_WARNING
);
556 if ($_REQUEST['return']) {
557 header("Location: " . $_REQUEST['return']);
559 header("Location: " . SELF_URL_PATH
);
564 function subscribe() {
565 if (SINGLE_USER_MODE
) {
569 if ($_SESSION["uid"]) {
571 $feed_url = $this->dbh
->escape_string(trim($_REQUEST["feed_url"]));
573 header('Content-Type: text/html; charset=utf-8');
576 <title>Tiny Tiny RSS</title>
577 <link rel=\"stylesheet\" type=\"text/css\" href=\"css/utility.css\">
578 <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
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 = 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>";
663 function subscribe2() {
664 $feed_url = $this->dbh
->escape_string(trim($_REQUEST["feed_url"]));
665 $cat_id = $this->dbh
->escape_string($_REQUEST["cat_id"]);
666 $from = $this->dbh
->escape_string($_REQUEST["from"]);
667 $feed_urls = array();
669 /* only read authentication information from POST */
671 $auth_login = $this->dbh
->escape_string(trim($_POST["auth_login"]));
672 $auth_pass = $this->dbh
->escape_string(trim($_POST["auth_pass"]));
674 $rc = subscribe_to_feed($feed_url, $cat_id, $auth_login, $auth_pass);
678 print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url));
681 print_error(T_sprintf("Could not subscribe to <b>%s</b>.", $feed_url));
684 print_error(T_sprintf("No feeds found in <b>%s</b>.", $feed_url));
687 print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url));
690 print_notice(__("Multiple feed URLs found."));
691 $contents = @fetch_file_contents
($url, false, $auth_login, $auth_pass);
692 if (is_html($contents)) {
693 $feed_urls = get_feeds_from_html($url, $contents);
697 print_error(T_sprintf("Could not subscribe to <b>%s</b>.<br>Can't download the Feed URL.", $feed_url));
702 print "<form action=\"backend.php\">";
703 print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">";
704 print "<input type=\"hidden\" name=\"quiet\" value=\"1\">";
705 print "<input type=\"hidden\" name=\"method\" value=\"add\">";
707 print "<select name=\"feed_url\">";
709 foreach ($feed_urls as $url => $name) {
710 $url = htmlspecialchars($url);
711 $name = htmlspecialchars($name);
712 print "<option value=\"$url\">$name</option>";
715 print "<input type=\"submit\" value=\"".__("Subscribe to selected feed")."\">";
719 $tp_uri = get_self_url_prefix() . "/prefs.php";
720 $tt_uri = get_self_url_prefix();
723 $result = $this->dbh
->query("SELECT id FROM ttrss_feeds WHERE
724 feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
726 $feed_id = $this->dbh
->fetch_result($result, 0, "id");
734 print "<form method=\"GET\" style='display: inline'
736 <input type=\"hidden\" name=\"tab\" value=\"feedConfig\">
737 <input type=\"hidden\" name=\"method\" value=\"editFeed\">
738 <input type=\"hidden\" name=\"methodparam\" value=\"$feed_id\">
739 <input type=\"submit\" value=\"".__("Edit subscription options")."\">
743 print "<form style='display: inline' method=\"GET\" action=\"$tt_uri\">
744 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
747 print "</body></html>";
751 header("Content-Type: text/plain");
752 print json_encode(array("error" => array("code" => 7)));
755 function forgotpass() {
758 header('Content-Type: text/html; charset=utf-8');
759 print "<html><head><title>Tiny Tiny RSS</title>";
761 stylesheet_tag("css/utility.css");
762 javascript_tag("lib/prototype.js");
764 print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
765 </head><body id='forgotpass'>";
767 print '<div class="floatingLogo"><img src="images/logo_small.png"></div>';
768 print "<h1>".__("Password recovery")."</h1>";
769 print "<div class='content'>";
771 @$method = $_POST['method'];
774 print_notice(__("You will need to provide valid account name and email. New password will be sent on your email address."));
776 print "<form method='POST' action='public.php'>";
777 print "<input type='hidden' name='method' value='do'>";
778 print "<input type='hidden' name='op' value='forgotpass'>";
781 print "<label>".__("Login:")."</label>";
782 print "<input type='text' name='login' value='' required>";
786 print "<label>".__("Email:")."</label>";
787 print "<input type='email' name='email' value='' required>";
791 print "<label>".__("How much is two plus two:")."</label>";
792 print "<input type='text' name='test' value='' required>";
796 print "<button type='submit'>".__("Reset password")."</button>";
799 } else if ($method == 'do') {
801 $login = $this->dbh
->escape_string($_POST["login"]);
802 $email = $this->dbh
->escape_string($_POST["email"]);
803 $test = $this->dbh
->escape_string($_POST["test"]);
805 if (($test != 4 && $test != 'four') ||
!$email ||
!$login) {
806 print_error(__('Some of the required form parameters are missing or incorrect.'));
808 print "<form method=\"GET\" action=\"public.php\">
809 <input type=\"hidden\" name=\"op\" value=\"forgotpass\">
810 <input type=\"submit\" value=\"".__("Go back")."\">
815 $result = $this->dbh
->query("SELECT id FROM ttrss_users
816 WHERE login = '$login' AND email = '$email'");
818 if ($this->dbh
->num_rows($result) != 0) {
819 $id = $this->dbh
->fetch_result($result, 0, "id");
821 Pref_Users
::resetUserPassword($id, false);
825 print "<p>"."Completed."."</p>";
827 print "<form method=\"GET\" action=\"index.php\">
828 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
832 print_error(__("Sorry, login and email combination not found."));
834 print "<form method=\"GET\" action=\"public.php\">
835 <input type=\"hidden\" name=\"op\" value=\"forgotpass\">
836 <input type=\"submit\" value=\"".__("Go back")."\">
850 function dbupdate() {
853 if (!SINGLE_USER_MODE
&& $_SESSION["access_level"] < 10) {
854 $_SESSION["login_error_msg"] = __("Your access level is insufficient to run this script.");
861 <title
>Database Updater
</title
>
862 <meta http
-equiv
="Content-Type" content
="text/html; charset=utf-8"/>
863 <link rel
="stylesheet" type
="text/css" href
="css/utility.css"/>
865 <style type
="text/css">
866 span
.ok
{ color
: #009000; font-weight : bold; }
867 span
.err
{ color
: #ff0000; font-weight : bold; }
870 <script type
='text/javascript'>
871 function confirmOP() {
872 return confirm("Update the database?");
876 <div
class="floatingLogo"><img src
="images/logo_small.png"></div
>
878 <h1
><?php
echo __("Database Updater") ?
></h1
>
880 <div
class="content">
883 @$op = $_REQUEST["subop"];
884 $updater = new DbUpdater(Db
::get(), DB_TYPE
, SCHEMA_VERSION
);
886 if ($op == "performupdate") {
887 if ($updater->isUpdateRequired()) {
889 print "<h2>Performing updates</h2>";
891 print "<h3>Updating to schema version " . SCHEMA_VERSION
. "</h3>";
895 for ($i = $updater->getSchemaVersion() +
1; $i <= SCHEMA_VERSION
; $i++
) {
896 print "<li>Performing update up to version $i...";
898 $result = $updater->performUpdateTo($i);
901 print "<span class='err'>FAILED!</span></li></ul>";
903 print_warning("One of the updates failed. Either retry the process or perform updates manually.");
904 print "<p><form method=\"GET\" action=\"index.php\">
905 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
910 print "<span class='ok'>OK!</span></li>";
916 print_notice("Your Tiny Tiny RSS database is now updated to the latest version.");
918 print "<p><form method=\"GET\" action=\"index.php\">
919 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
923 print "<h2>Your database is up to date.</h2>";
925 print "<p><form method=\"GET\" action=\"index.php\">
926 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
930 if ($updater->isUpdateRequired()) {
932 print "<h2>Database update required</h2>";
935 printf("Your Tiny Tiny RSS database needs update to the latest version: %d to %d.",
936 $updater->getSchemaVersion(), SCHEMA_VERSION
);
939 print_warning("Please backup your database before proceeding.");
941 print "<form method='POST'>
942 <input type='hidden' name='subop' value='performupdate'>
943 <input type='submit' onclick='return confirmOP()' value='".__("Perform updates")."'>
948 print_notice("Tiny Tiny RSS database is up to date.");
950 print "<p><form method=\"GET\" action=\"index.php\">
951 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">