]>
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, $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=$feed&key=" .
69 get_feed_access_key($feed, 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);
88 $line["content_preview"] = truncate_string(strip_tags($line["content_preview"]), 100, '...');
89 while ($line = $this->dbh
->fetch_assoc($result)) {
90 foreach (PluginHost
::getInstance()->get_hooks(PluginHost
::HOOK_QUERY_HEADLINES
) as $p) {
91 $line = $p->hook_query_headlines($line);
94 $tpl->setVariable('ARTICLE_ID',
95 htmlspecialchars($orig_guid ?
$line['link'] :
96 get_self_url_prefix() .
97 "/public.php?url=" . urlencode($line['link'])), true);
98 $tpl->setVariable('ARTICLE_LINK', htmlspecialchars($line['link']), true);
99 $tpl->setVariable('ARTICLE_TITLE', htmlspecialchars($line['title']), true);
100 $tpl->setVariable('ARTICLE_EXCERPT', $line["content_preview"], true);
102 $content = sanitize($line["content"], false, $owner_uid);
105 $content = "<div style=\"$note_style\">Article note: " . $line['note'] . "</div>" .
107 $tpl->setVariable('ARTICLE_NOTE', htmlspecialchars($line['note']), true);
110 $tpl->setVariable('ARTICLE_CONTENT', $content, true);
112 $tpl->setVariable('ARTICLE_UPDATED_ATOM',
113 date('c', strtotime($line["updated"])), true);
114 $tpl->setVariable('ARTICLE_UPDATED_RFC822',
115 date(DATE_RFC822
, strtotime($line["updated"])), true);
117 $tpl->setVariable('ARTICLE_AUTHOR', htmlspecialchars($line['author']), true);
119 $tpl->setVariable('ARTICLE_SOURCE_LINK', htmlspecialchars($line['site_url']), true);
120 $tpl->setVariable('ARTICLE_SOURCE_TITLE', htmlspecialchars($line['feed_title']), true);
122 $tags = get_article_tags($line["id"], $owner_uid);
124 foreach ($tags as $tag) {
125 $tpl->setVariable('ARTICLE_CATEGORY', htmlspecialchars($tag), true);
126 $tpl->addBlock('category');
129 $enclosures = get_article_enclosures($line["id"]);
131 foreach ($enclosures as $e) {
132 $type = htmlspecialchars($e['content_type']);
133 $url = htmlspecialchars($e['content_url']);
134 $length = $e['duration'];
136 $tpl->setVariable('ARTICLE_ENCLOSURE_URL', $url, true);
137 $tpl->setVariable('ARTICLE_ENCLOSURE_TYPE', $type, true);
138 $tpl->setVariable('ARTICLE_ENCLOSURE_LENGTH', $length, true);
140 $tpl->addBlock('enclosure');
143 $tpl->addBlock('entry');
148 $tpl->addBlock('feed');
149 $tpl->generateOutputToString($tmp);
151 if (@!$_REQUEST["noxml"]) {
152 header("Content-Type: text/xml; charset=utf-8");
154 header("Content-Type: text/plain; charset=utf-8");
158 } else if ($format == 'json') {
162 $feed['title'] = $feed_title;
163 $feed['version'] = VERSION
;
164 $feed['feed_url'] = $feed_self_url;
166 if (PUBSUBHUBBUB_HUB
&& $feed == -2) {
167 $feed['hub_url'] = PUBSUBHUBBUB_HUB
;
170 $feed['self_url'] = get_self_url_prefix();
172 $feed['articles'] = array();
174 while ($line = $this->dbh
->fetch_assoc($result)) {
175 $line["content_preview"] = truncate_string(strip_tags($line["content_preview"]), 100, '...');
176 foreach (PluginHost
::getInstance()->get_hooks(PluginHost
::HOOK_QUERY_HEADLINES
) as $p) {
177 $line = $p->hook_query_headlines($line, 100);
181 $article['id'] = $line['link'];
182 $article['link'] = $line['link'];
183 $article['title'] = $line['title'];
184 $article['excerpt'] = $line["content_preview"];
185 $article['content'] = sanitize($line["content"], false, $owner_uid);
186 $article['updated'] = date('c', strtotime($line["updated"]));
188 if ($line['note']) $article['note'] = $line['note'];
189 if ($article['author']) $article['author'] = $line['author'];
191 $tags = get_article_tags($line["id"], $owner_uid);
193 if (count($tags) > 0) {
194 $article['tags'] = array();
196 foreach ($tags as $tag) {
197 array_push($article['tags'], $tag);
201 $enclosures = get_article_enclosures($line["id"]);
203 if (count($enclosures) > 0) {
204 $article['enclosures'] = array();
206 foreach ($enclosures as $e) {
207 $type = $e['content_type'];
208 $url = $e['content_url'];
209 $length = $e['duration'];
211 array_push($article['enclosures'], array("url" => $url, "type" => $type, "length" => $length));
215 array_push($feed['articles'], $article);
218 header("Content-Type: text/json; charset=utf-8");
219 print json_encode($feed);
222 header("Content-Type: text/plain; charset=utf-8");
223 print json_encode(array("error" => array("message" => "Unknown format")));
227 function getUnread() {
228 $login = $this->dbh
->escape_string($_REQUEST["login"]);
229 $fresh = $_REQUEST["fresh"] == "1";
231 $result = $this->dbh
->query("SELECT id FROM ttrss_users WHERE login = '$login'");
233 if ($this->dbh
->num_rows($result) == 1) {
234 $uid = $this->dbh
->fetch_result($result, 0, "id");
236 print getGlobalUnread($uid);
240 print getFeedArticles(-3, false, true, $uid);
244 print "-1;User not found";
249 function getProfiles() {
250 $login = $this->dbh
->escape_string($_REQUEST["login"]);
252 $result = $this->dbh
->query("SELECT ttrss_settings_profiles.* FROM ttrss_settings_profiles,ttrss_users
253 WHERE ttrss_users.id = ttrss_settings_profiles.owner_uid AND login = '$login' ORDER BY title");
255 print "<select dojoType='dijit.form.Select' style='width : 220px; margin : 0px' name='profile'>";
257 print "<option value='0'>" . __("Default profile") . "</option>";
259 while ($line = $this->dbh
->fetch_assoc($result)) {
261 $title = $line["title"];
263 print "<option value='$id'>$title</option>";
270 $mode = $this->dbh
->escape_string($_REQUEST['hub_mode']);
271 $feed_id = (int) $this->dbh
->escape_string($_REQUEST['id']);
272 $feed_url = $this->dbh
->escape_string($_REQUEST['hub_topic']);
274 if (!PUBSUBHUBBUB_ENABLED
) {
275 header('HTTP/1.0 404 Not Found');
276 echo "404 Not found";
280 // TODO: implement hub_verifytoken checking
282 $result = $this->dbh
->query("SELECT feed_url FROM ttrss_feeds
283 WHERE id = '$feed_id'");
285 if ($this->dbh
->num_rows($result) != 0) {
287 $check_feed_url = $this->dbh
->fetch_result($result, 0, "feed_url");
289 if ($check_feed_url && ($check_feed_url == $feed_url ||
!$feed_url)) {
290 if ($mode == "subscribe") {
292 $this->dbh
->query("UPDATE ttrss_feeds SET pubsub_state = 2
293 WHERE id = '$feed_id'");
295 print $_REQUEST['hub_challenge'];
298 } else if ($mode == "unsubscribe") {
300 $this->dbh
->query("UPDATE ttrss_feeds SET pubsub_state = 0
301 WHERE id = '$feed_id'");
303 print $_REQUEST['hub_challenge'];
308 // Received update ping, schedule feed update.
309 //update_rss_feed($feed_id, true, true);
311 $this->dbh
->query("UPDATE ttrss_feeds SET
312 last_update_started = '1970-01-01',
313 last_updated = '1970-01-01' WHERE id = '$feed_id'");
317 header('HTTP/1.0 404 Not Found');
318 echo "404 Not found";
321 header('HTTP/1.0 404 Not Found');
322 echo "404 Not found";
329 header("Location: index.php");
333 $uuid = $this->dbh
->escape_string($_REQUEST["key"]);
335 $result = $this->dbh
->query("SELECT ref_id, owner_uid FROM ttrss_user_entries WHERE
338 if ($this->dbh
->num_rows($result) != 0) {
339 header("Content-Type: text/html");
341 $id = $this->dbh
->fetch_result($result, 0, "ref_id");
342 $owner_uid = $this->dbh
->fetch_result($result, 0, "owner_uid");
344 $article = format_article($id, false, true, $owner_uid);
346 print_r($article['content']);
349 print "Article not found.";
355 $feed = $this->dbh
->escape_string($_REQUEST["id"]);
356 $key = $this->dbh
->escape_string($_REQUEST["key"]);
357 $is_cat = sql_bool_to_bool($_REQUEST["is_cat"]);
358 $limit = (int)$this->dbh
->escape_string($_REQUEST["limit"]);
359 $offset = (int)$this->dbh
->escape_string($_REQUEST["offset"]);
361 $search = $this->dbh
->escape_string($_REQUEST["q"]);
362 $search_mode = $this->dbh
->escape_string($_REQUEST["smode"]);
363 $view_mode = $this->dbh
->escape_string($_REQUEST["view-mode"]);
364 $order = $this->dbh
->escape_string($_REQUEST["order"]);
366 $format = $this->dbh
->escape_string($_REQUEST['format']);
367 $orig_guid = !sql_bool_to_bool($_REQUEST["no_orig_guid"]);
369 if (!$format) $format = 'atom';
371 if (SINGLE_USER_MODE
) {
372 authenticate_user("admin", null);
378 $result = $this->dbh
->query("SELECT owner_uid FROM
379 ttrss_access_keys WHERE access_key = '$key' AND feed_id = '$feed'");
381 if ($this->dbh
->num_rows($result) == 1)
382 $owner_id = $this->dbh
->fetch_result($result, 0, "owner_uid");
386 $this->generate_syndicated_feed($owner_id, $feed, $is_cat, $limit,
387 $offset, $search, $search_mode, $view_mode, $format, $order, $orig_guid);
389 header('HTTP/1.1 403 Forbidden');
393 function globalUpdateFeeds() {
394 include "rssfuncs.php";
395 // Update all feeds needing a update.
396 update_daemon_common(0, true, false);
397 housekeeping_common(false);
399 PluginHost
::getInstance()->run_hooks(PluginHost
::HOOK_UPDATE_TASK
, "hook_update_task", $op);
403 function sharepopup() {
404 if (SINGLE_USER_MODE
) {
408 header('Content-Type: text/html; charset=utf-8');
409 print "<html><head><title>Tiny Tiny RSS</title>";
411 stylesheet_tag("css/utility.css");
412 javascript_tag("lib/prototype.js");
413 javascript_tag("lib/scriptaculous/scriptaculous.js?load=effects,dragdrop,controls");
414 print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
415 </head><body id='sharepopup'>";
417 $action = $_REQUEST["action"];
419 if ($_SESSION["uid"]) {
421 if ($action == 'share') {
423 $title = $this->dbh
->escape_string(strip_tags($_REQUEST["title"]));
424 $url = $this->dbh
->escape_string(strip_tags($_REQUEST["url"]));
425 $content = $this->dbh
->escape_string(strip_tags($_REQUEST["content"]));
426 $labels = $this->dbh
->escape_string(strip_tags($_REQUEST["labels"]));
428 Article
::create_published_article($title, $url, $content, $labels,
431 print "<script type='text/javascript'>";
432 print "window.close();";
436 $title = htmlspecialchars($_REQUEST["title"]);
437 $url = htmlspecialchars($_REQUEST["url"]);
441 <table height
='100%' width
='100%'><tr
><td colspan
='2'>
442 <h1
><?php
echo __("Share with Tiny Tiny RSS") ?
></h1
>
445 <form id
='share_form' name
='share_form'>
447 <input type
="hidden" name
="op" value
="sharepopup">
448 <input type
="hidden" name
="action" value
="share">
450 <tr
><td align
='right'><?php
echo __("Title:") ?
></td
>
451 <td width
='80%'><input name
='title' value
="<?php echo $title ?>"></td
></tr
>
452 <tr
><td align
='right'><?php
echo __("URL:") ?
></td
>
453 <td
><input name
='url' value
="<?php echo $url ?>"></td
></tr
>
454 <tr
><td align
='right'><?php
echo __("Content:") ?
></td
>
455 <td
><input name
='content' value
=""></td
></tr
>
456 <tr
><td align
='right'><?php
echo __("Labels:") ?
></td
>
457 <td
><input name
='labels' id
="labels_value"
458 placeholder
='Alpha, Beta, Gamma' value
="">
462 <div
class="autocomplete" id
="labels_choices"
463 style
="display : block"></div
></td
></tr
>
465 <script type
='text/javascript'>document
.forms
[0].title
.focus();</script
>
467 <script type
='text/javascript'>
468 new Ajax
.Autocompleter('labels_value', 'labels_choices',
469 "backend.php?op=rpc&method=completeLabels",
470 { tokens
: ',', paramName
: "search" });
474 <div style
='float : right' class='insensitive-small'>
475 <?php
echo __("Shared article will appear in the Published feed.") ?
>
477 <button type
="submit"><?php
echo __('Share') ?
></button
>
478 <button onclick
="return window.close()"><?php
echo __('Cancel') ?
></button
>
490 $return = urlencode($_SERVER["REQUEST_URI"])
493 <form action
="public.php?return=<?php echo $return ?>"
494 method
="POST" id
="loginForm" name
="loginForm">
496 <input type
="hidden" name
="op" value
="login">
498 <table height
='100%' width
='100%'><tr
><td colspan
='2'>
499 <h1
><?php
echo __("Not logged in") ?
></h1
></td
></tr
>
501 <tr
><td align
="right"><?php
echo __("Login:") ?
></td
>
502 <td align
="right"><input name
="login"
503 value
="<?php echo $_SESSION["fake_login
"] ?>"></td
></tr
>
504 <tr
><td align
="right"><?php
echo __("Password:") ?
></td
>
505 <td align
="right"><input type
="password" name
="password"
506 value
="<?php echo $_SESSION["fake_password
"] ?>"></td
></tr
>
508 <button type
="submit">
509 <?php
echo __('Log in') ?
></button
>
511 <button onclick
="return window.close()">
512 <?php
echo __('Cancel') ?
></button
>
522 if (!SINGLE_USER_MODE
) {
524 $login = $this->dbh
->escape_string($_POST["login"]);
525 $password = $_POST["password"];
526 $remember_me = $_POST["remember_me"];
529 session_set_cookie_params(SESSION_COOKIE_LIFETIME
);
531 session_set_cookie_params(0);
536 if (authenticate_user($login, $password)) {
537 $_POST["password"] = "";
539 if (get_schema_version() >= 120) {
540 $_SESSION["language"] = get_pref("USER_LANGUAGE", $_SESSION["uid"]);
543 $_SESSION["ref_schema_version"] = get_schema_version(true);
544 $_SESSION["bw_limit"] = !!$_POST["bw_limit"];
546 if ($_POST["profile"]) {
548 $profile = $this->dbh
->escape_string($_POST["profile"]);
550 $result = $this->dbh
->query("SELECT id FROM ttrss_settings_profiles
551 WHERE id = '$profile' AND owner_uid = " . $_SESSION["uid"]);
553 if ($this->dbh
->num_rows($result) != 0) {
554 $_SESSION["profile"] = $profile;
558 $_SESSION["login_error_msg"] = __("Incorrect username or password");
559 user_error("Failed login attempt from {$_SERVER['REMOTE_ADDR']}", E_USER_WARNING
);
562 if ($_REQUEST['return']) {
563 header("Location: " . $_REQUEST['return']);
565 header("Location: " . SELF_URL_PATH
);
570 function subscribe() {
571 if (SINGLE_USER_MODE
) {
575 if ($_SESSION["uid"]) {
577 $feed_url = $this->dbh
->escape_string(trim($_REQUEST["feed_url"]));
579 header('Content-Type: text/html; charset=utf-8');
582 <title>Tiny Tiny RSS</title>
583 <link rel=\"stylesheet\" type=\"text/css\" href=\"css/utility.css\">
584 <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
587 <img class=\"floatingLogo\" src=\"images/logo_small.png\"
588 alt=\"Tiny Tiny RSS\"/>
589 <h1>".__("Subscribe to feed...")."</h1><div class='content'>";
591 $rc = subscribe_to_feed($feed_url);
593 switch ($rc['code']) {
595 print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url));
598 print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url));
601 print_error(T_sprintf("Could not subscribe to <b>%s</b>.", $feed_url));
604 print_error(T_sprintf("No feeds found in <b>%s</b>.", $feed_url));
607 print_notice(__("Multiple feed URLs found."));
608 $feed_urls = $rc["feeds"];
611 print_error(T_sprintf("Could not subscribe to <b>%s</b>.<br>Can't download the Feed URL.", $feed_url));
617 print "<form action=\"public.php\">";
618 print "<input type=\"hidden\" name=\"op\" value=\"subscribe\">";
620 print "<select name=\"feed_url\">";
622 foreach ($feed_urls as $url => $name) {
623 $url = htmlspecialchars($url);
624 $name = htmlspecialchars($name);
626 print "<option value=\"$url\">$name</option>";
629 print "<input type=\"submit\" value=\"".__("Subscribe to selected feed").
635 $tp_uri = get_self_url_prefix() . "/prefs.php";
636 $tt_uri = get_self_url_prefix();
638 if ($rc['code'] <= 2){
639 $result = $this->dbh
->query("SELECT id FROM ttrss_feeds WHERE
640 feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
642 $feed_id = $this->dbh
->fetch_result($result, 0, "id");
649 print "<form method=\"GET\" style='display: inline'
651 <input type=\"hidden\" name=\"tab\" value=\"feedConfig\">
652 <input type=\"hidden\" name=\"method\" value=\"editFeed\">
653 <input type=\"hidden\" name=\"methodparam\" value=\"$feed_id\">
654 <input type=\"submit\" value=\"".__("Edit subscription options")."\">
658 print "<form style='display: inline' method=\"GET\" action=\"$tt_uri\">
659 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
662 print "</div></body></html>";
669 function subscribe2() {
670 $feed_url = $this->dbh
->escape_string(trim($_REQUEST["feed_url"]));
671 $cat_id = $this->dbh
->escape_string($_REQUEST["cat_id"]);
672 $from = $this->dbh
->escape_string($_REQUEST["from"]);
673 $feed_urls = array();
675 /* only read authentication information from POST */
677 $auth_login = $this->dbh
->escape_string(trim($_POST["auth_login"]));
678 $auth_pass = $this->dbh
->escape_string(trim($_POST["auth_pass"]));
680 $rc = subscribe_to_feed($feed_url, $cat_id, $auth_login, $auth_pass);
684 print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url));
687 print_error(T_sprintf("Could not subscribe to <b>%s</b>.", $feed_url));
690 print_error(T_sprintf("No feeds found in <b>%s</b>.", $feed_url));
693 print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url));
696 print_notice(__("Multiple feed URLs found."));
697 $contents = @fetch_file_contents
($url, false, $auth_login, $auth_pass);
698 if (is_html($contents)) {
699 $feed_urls = get_feeds_from_html($url, $contents);
703 print_error(T_sprintf("Could not subscribe to <b>%s</b>.<br>Can't download the Feed URL.", $feed_url));
708 print "<form action=\"backend.php\">";
709 print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">";
710 print "<input type=\"hidden\" name=\"quiet\" value=\"1\">";
711 print "<input type=\"hidden\" name=\"method\" value=\"add\">";
713 print "<select name=\"feed_url\">";
715 foreach ($feed_urls as $url => $name) {
716 $url = htmlspecialchars($url);
717 $name = htmlspecialchars($name);
718 print "<option value=\"$url\">$name</option>";
721 print "<input type=\"submit\" value=\"".__("Subscribe to selected feed")."\">";
725 $tp_uri = get_self_url_prefix() . "/prefs.php";
726 $tt_uri = get_self_url_prefix();
729 $result = $this->dbh
->query("SELECT id FROM ttrss_feeds WHERE
730 feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
732 $feed_id = $this->dbh
->fetch_result($result, 0, "id");
740 print "<form method=\"GET\" style='display: inline'
742 <input type=\"hidden\" name=\"tab\" value=\"feedConfig\">
743 <input type=\"hidden\" name=\"method\" value=\"editFeed\">
744 <input type=\"hidden\" name=\"methodparam\" value=\"$feed_id\">
745 <input type=\"submit\" value=\"".__("Edit subscription options")."\">
749 print "<form style='display: inline' method=\"GET\" action=\"$tt_uri\">
750 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
753 print "</body></html>";
757 header("Content-Type: text/plain");
758 print json_encode(array("error" => array("code" => 7)));
761 function forgotpass() {
764 header('Content-Type: text/html; charset=utf-8');
765 print "<html><head><title>Tiny Tiny RSS</title>";
767 stylesheet_tag("css/utility.css");
768 javascript_tag("lib/prototype.js");
770 print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
771 </head><body id='forgotpass'>";
773 print '<div class="floatingLogo"><img src="images/logo_small.png"></div>';
774 print "<h1>".__("Password recovery")."</h1>";
775 print "<div class='content'>";
777 @$method = $_POST['method'];
780 print_notice(__("You will need to provide valid account name and email. New password will be sent on your email address."));
782 print "<form method='POST' action='public.php'>";
783 print "<input type='hidden' name='method' value='do'>";
784 print "<input type='hidden' name='op' value='forgotpass'>";
787 print "<label>".__("Login:")."</label>";
788 print "<input type='text' name='login' value='' required>";
792 print "<label>".__("Email:")."</label>";
793 print "<input type='email' name='email' value='' required>";
797 print "<label>".__("How much is two plus two:")."</label>";
798 print "<input type='text' name='test' value='' required>";
802 print "<button type='submit'>".__("Reset password")."</button>";
805 } else if ($method == 'do') {
807 $login = $this->dbh
->escape_string($_POST["login"]);
808 $email = $this->dbh
->escape_string($_POST["email"]);
809 $test = $this->dbh
->escape_string($_POST["test"]);
811 if (($test != 4 && $test != 'four') ||
!$email ||
!$login) {
812 print_error(__('Some of the required form parameters are missing or incorrect.'));
814 print "<form method=\"GET\" action=\"public.php\">
815 <input type=\"hidden\" name=\"op\" value=\"forgotpass\">
816 <input type=\"submit\" value=\"".__("Go back")."\">
821 $result = $this->dbh
->query("SELECT id FROM ttrss_users
822 WHERE login = '$login' AND email = '$email'");
824 if ($this->dbh
->num_rows($result) != 0) {
825 $id = $this->dbh
->fetch_result($result, 0, "id");
827 Pref_Users
::resetUserPassword($id, false);
831 print "<p>"."Completed."."</p>";
833 print "<form method=\"GET\" action=\"index.php\">
834 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
838 print_error(__("Sorry, login and email combination not found."));
840 print "<form method=\"GET\" action=\"public.php\">
841 <input type=\"hidden\" name=\"op\" value=\"forgotpass\">
842 <input type=\"submit\" value=\"".__("Go back")."\">
856 function dbupdate() {
859 if (!SINGLE_USER_MODE
&& $_SESSION["access_level"] < 10) {
860 $_SESSION["login_error_msg"] = __("Your access level is insufficient to run this script.");
867 <title
>Database Updater
</title
>
868 <meta http
-equiv
="Content-Type" content
="text/html; charset=utf-8"/>
869 <link rel
="stylesheet" type
="text/css" href
="css/utility.css"/>
871 <style type
="text/css">
872 span
.ok
{ color
: #009000; font-weight : bold; }
873 span
.err
{ color
: #ff0000; font-weight : bold; }
876 <script type
='text/javascript'>
877 function confirmOP() {
878 return confirm("Update the database?");
882 <div
class="floatingLogo"><img src
="images/logo_small.png"></div
>
884 <h1
><?php
echo __("Database Updater") ?
></h1
>
886 <div
class="content">
889 @$op = $_REQUEST["subop"];
890 $updater = new DbUpdater(Db
::get(), DB_TYPE
, SCHEMA_VERSION
);
892 if ($op == "performupdate") {
893 if ($updater->isUpdateRequired()) {
895 print "<h2>Performing updates</h2>";
897 print "<h3>Updating to schema version " . SCHEMA_VERSION
. "</h3>";
901 for ($i = $updater->getSchemaVersion() +
1; $i <= SCHEMA_VERSION
; $i++
) {
902 print "<li>Performing update up to version $i...";
904 $result = $updater->performUpdateTo($i);
907 print "<span class='err'>FAILED!</span></li></ul>";
909 print_warning("One of the updates failed. Either retry the process or perform updates manually.");
910 print "<p><form method=\"GET\" action=\"index.php\">
911 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
916 print "<span class='ok'>OK!</span></li>";
922 print_notice("Your Tiny Tiny RSS database is now updated to the latest version.");
924 print "<p><form method=\"GET\" action=\"index.php\">
925 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
929 print "<h2>Your database is up to date.</h2>";
931 print "<p><form method=\"GET\" action=\"index.php\">
932 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
936 if ($updater->isUpdateRequired()) {
938 print "<h2>Database update required</h2>";
941 printf("Your Tiny Tiny RSS database needs update to the latest version: %d to %d.",
942 $updater->getSchemaVersion(), SCHEMA_VERSION
);
945 print_warning("Please backup your database before proceeding.");
947 print "<form method='POST'>
948 <input type='hidden' name='subop' value='performupdate'>
949 <input type='submit' onclick='return confirmOP()' value='".__("Perform updates")."'>
954 print_notice("Tiny Tiny RSS database is up to date.");
956 print "<p><form method=\"GET\" action=\"index.php\">
957 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">