]>
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) {
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', htmlspecialchars($line['link']), true);
92 $tpl->setVariable('ARTICLE_LINK', htmlspecialchars($line['link']), true);
93 $tpl->setVariable('ARTICLE_TITLE', htmlspecialchars($line['title']), true);
94 $tpl->setVariable('ARTICLE_EXCERPT',
95 truncate_string(strip_tags($line["content_preview"]), 100, '...'), true);
97 $content = sanitize($line["content_preview"], false, $owner_uid);
100 $content = "<div style=\"$note_style\">Article note: " . $line['note'] . "</div>" .
102 $tpl->setVariable('ARTICLE_NOTE', htmlspecialchars($line['note']), true);
105 $tpl->setVariable('ARTICLE_CONTENT', $content, true);
107 $tpl->setVariable('ARTICLE_UPDATED_ATOM',
108 date('c', strtotime($line["updated"])), true);
109 $tpl->setVariable('ARTICLE_UPDATED_RFC822',
110 date(DATE_RFC822
, strtotime($line["updated"])), true);
112 $tpl->setVariable('ARTICLE_AUTHOR', htmlspecialchars($line['author']), true);
114 $tags = get_article_tags($line["id"], $owner_uid);
116 foreach ($tags as $tag) {
117 $tpl->setVariable('ARTICLE_CATEGORY', htmlspecialchars($tag), true);
118 $tpl->addBlock('category');
121 $enclosures = get_article_enclosures($line["id"]);
123 foreach ($enclosures as $e) {
124 $type = htmlspecialchars($e['content_type']);
125 $url = htmlspecialchars($e['content_url']);
126 $length = $e['duration'];
128 $tpl->setVariable('ARTICLE_ENCLOSURE_URL', $url, true);
129 $tpl->setVariable('ARTICLE_ENCLOSURE_TYPE', $type, true);
130 $tpl->setVariable('ARTICLE_ENCLOSURE_LENGTH', $length, true);
132 $tpl->addBlock('enclosure');
135 $tpl->addBlock('entry');
140 $tpl->addBlock('feed');
141 $tpl->generateOutputToString($tmp);
143 if (@!$_REQUEST["noxml"]) {
144 header("Content-Type: text/xml; charset=utf-8");
146 header("Content-Type: text/plain; charset=utf-8");
150 } else if ($format == 'json') {
154 $feed['title'] = $feed_title;
155 $feed['version'] = VERSION
;
156 $feed['feed_url'] = $feed_self_url;
158 if (PUBSUBHUBBUB_HUB
&& $feed == -2) {
159 $feed['hub_url'] = PUBSUBHUBBUB_HUB
;
162 $feed['self_url'] = get_self_url_prefix();
164 $feed['articles'] = array();
166 while ($line = $this->dbh
->fetch_assoc($result)) {
169 $article['id'] = $line['link'];
170 $article['link'] = $line['link'];
171 $article['title'] = $line['title'];
172 $article['excerpt'] = truncate_string(strip_tags($line["content_preview"]), 100, '...');
173 $article['content'] = sanitize($line["content_preview"], false, $owner_uid);
174 $article['updated'] = date('c', strtotime($line["updated"]));
176 if ($line['note']) $article['note'] = $line['note'];
177 if ($article['author']) $article['author'] = $line['author'];
179 $tags = get_article_tags($line["id"], $owner_uid);
181 if (count($tags) > 0) {
182 $article['tags'] = array();
184 foreach ($tags as $tag) {
185 array_push($article['tags'], $tag);
189 $enclosures = get_article_enclosures($line["id"]);
191 if (count($enclosures) > 0) {
192 $article['enclosures'] = array();
194 foreach ($enclosures as $e) {
195 $type = $e['content_type'];
196 $url = $e['content_url'];
197 $length = $e['duration'];
199 array_push($article['enclosures'], array("url" => $url, "type" => $type, "length" => $length));
203 array_push($feed['articles'], $article);
206 header("Content-Type: text/json; charset=utf-8");
207 print json_encode($feed);
210 header("Content-Type: text/plain; charset=utf-8");
211 print json_encode(array("error" => array("message" => "Unknown format")));
215 function getUnread() {
216 $login = $this->dbh
->escape_string($_REQUEST["login"]);
217 $fresh = $_REQUEST["fresh"] == "1";
219 $result = $this->dbh
->query("SELECT id FROM ttrss_users WHERE login = '$login'");
221 if ($this->dbh
->num_rows($result) == 1) {
222 $uid = $this->dbh
->fetch_result($result, 0, "id");
224 print getGlobalUnread($uid);
228 print getFeedArticles(-3, false, true, $uid);
232 print "-1;User not found";
237 function getProfiles() {
238 $login = $this->dbh
->escape_string($_REQUEST["login"]);
240 $result = $this->dbh
->query("SELECT ttrss_settings_profiles.* FROM ttrss_settings_profiles,ttrss_users
241 WHERE ttrss_users.id = ttrss_settings_profiles.owner_uid AND login = '$login' ORDER BY title");
243 print "<select dojoType='dijit.form.Select' style='width : 220px; margin : 0px' name='profile'>";
245 print "<option value='0'>" . __("Default profile") . "</option>";
247 while ($line = $this->dbh
->fetch_assoc($result)) {
249 $title = $line["title"];
251 print "<option value='$id'>$title</option>";
258 $mode = $this->dbh
->escape_string($_REQUEST['hub_mode']);
259 $feed_id = (int) $this->dbh
->escape_string($_REQUEST['id']);
260 $feed_url = $this->dbh
->escape_string($_REQUEST['hub_topic']);
262 if (!PUBSUBHUBBUB_ENABLED
) {
263 header('HTTP/1.0 404 Not Found');
264 echo "404 Not found";
268 // TODO: implement hub_verifytoken checking
270 $result = $this->dbh
->query("SELECT feed_url FROM ttrss_feeds
271 WHERE id = '$feed_id'");
273 if ($this->dbh
->num_rows($result) != 0) {
275 $check_feed_url = $this->dbh
->fetch_result($result, 0, "feed_url");
277 if ($check_feed_url && ($check_feed_url == $feed_url ||
!$feed_url)) {
278 if ($mode == "subscribe") {
280 $this->dbh
->query("UPDATE ttrss_feeds SET pubsub_state = 2
281 WHERE id = '$feed_id'");
283 print $_REQUEST['hub_challenge'];
286 } else if ($mode == "unsubscribe") {
288 $this->dbh
->query("UPDATE ttrss_feeds SET pubsub_state = 0
289 WHERE id = '$feed_id'");
291 print $_REQUEST['hub_challenge'];
296 // Received update ping, schedule feed update.
297 //update_rss_feed($feed_id, true, true);
299 $this->dbh
->query("UPDATE ttrss_feeds SET
300 last_update_started = '1970-01-01',
301 last_updated = '1970-01-01' WHERE id = '$feed_id'");
305 header('HTTP/1.0 404 Not Found');
306 echo "404 Not found";
309 header('HTTP/1.0 404 Not Found');
310 echo "404 Not found";
317 header("Location: index.php");
321 $uuid = $this->dbh
->escape_string($_REQUEST["key"]);
323 $result = $this->dbh
->query("SELECT ref_id, owner_uid FROM ttrss_user_entries WHERE
326 if ($this->dbh
->num_rows($result) != 0) {
327 header("Content-Type: text/html");
329 $id = $this->dbh
->fetch_result($result, 0, "ref_id");
330 $owner_uid = $this->dbh
->fetch_result($result, 0, "owner_uid");
332 $article = format_article($id, false, true, $owner_uid);
334 print_r($article['content']);
337 print "Article not found.";
343 $feed = $this->dbh
->escape_string($_REQUEST["id"]);
344 $key = $this->dbh
->escape_string($_REQUEST["key"]);
345 $is_cat = $_REQUEST["is_cat"] != false;
346 $limit = (int)$this->dbh
->escape_string($_REQUEST["limit"]);
347 $offset = (int)$this->dbh
->escape_string($_REQUEST["offset"]);
349 $search = $this->dbh
->escape_string($_REQUEST["q"]);
350 $search_mode = $this->dbh
->escape_string($_REQUEST["smode"]);
351 $view_mode = $this->dbh
->escape_string($_REQUEST["view-mode"]);
352 $order = $this->dbh
->escape_string($_REQUEST["order"]);
354 $format = $this->dbh
->escape_string($_REQUEST['format']);
356 if (!$format) $format = 'atom';
358 if (SINGLE_USER_MODE
) {
359 authenticate_user("admin", null);
365 $result = $this->dbh
->query("SELECT owner_uid FROM
366 ttrss_access_keys WHERE access_key = '$key' AND feed_id = '$feed'");
368 if ($this->dbh
->num_rows($result) == 1)
369 $owner_id = $this->dbh
->fetch_result($result, 0, "owner_uid");
373 $this->generate_syndicated_feed($owner_id, $feed, $is_cat, $limit,
374 $offset, $search, $search_mode, $view_mode, $format, $order);
376 header('HTTP/1.1 403 Forbidden');
380 function globalUpdateFeeds() {
381 include "rssfuncs.php";
382 // Update all feeds needing a update.
383 update_daemon_common(0, true, false);
384 housekeeping_common(false);
386 PluginHost
::getInstance()->run_hooks(PluginHost
::HOOK_UPDATE_TASK
, "hook_update_task", $op);
390 function sharepopup() {
391 if (SINGLE_USER_MODE
) {
395 header('Content-Type: text/html; charset=utf-8');
396 print "<html><head><title>Tiny Tiny RSS</title>";
398 stylesheet_tag("css/utility.css");
399 javascript_tag("lib/prototype.js");
400 javascript_tag("lib/scriptaculous/scriptaculous.js?load=effects,dragdrop,controls");
401 print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
402 </head><body id='sharepopup'>";
404 $action = $_REQUEST["action"];
406 if ($_SESSION["uid"]) {
408 if ($action == 'share') {
410 $title = $this->dbh
->escape_string(strip_tags($_REQUEST["title"]));
411 $url = $this->dbh
->escape_string(strip_tags($_REQUEST["url"]));
412 $content = $this->dbh
->escape_string(strip_tags($_REQUEST["content"]));
413 $labels = $this->dbh
->escape_string(strip_tags($_REQUEST["labels"]));
415 Article
::create_published_article($title, $url, $content, $labels,
418 print "<script type='text/javascript'>";
419 print "window.close();";
423 $title = htmlspecialchars($_REQUEST["title"]);
424 $url = htmlspecialchars($_REQUEST["url"]);
428 <table height
='100%' width
='100%'><tr
><td colspan
='2'>
429 <h1
><?php
echo __("Share with Tiny Tiny RSS") ?
></h1
>
432 <form id
='share_form' name
='share_form'>
434 <input type
="hidden" name
="op" value
="sharepopup">
435 <input type
="hidden" name
="action" value
="share">
437 <tr
><td align
='right'><?php
echo __("Title:") ?
></td
>
438 <td width
='80%'><input name
='title' value
="<?php echo $title ?>"></td
></tr
>
439 <tr
><td align
='right'><?php
echo __("URL:") ?
></td
>
440 <td
><input name
='url' value
="<?php echo $url ?>"></td
></tr
>
441 <tr
><td align
='right'><?php
echo __("Content:") ?
></td
>
442 <td
><input name
='content' value
=""></td
></tr
>
443 <tr
><td align
='right'><?php
echo __("Labels:") ?
></td
>
444 <td
><input name
='labels' id
="labels_value"
445 placeholder
='Alpha, Beta, Gamma' value
="">
449 <div
class="autocomplete" id
="labels_choices"
450 style
="display : block"></div
></td
></tr
>
452 <script type
='text/javascript'>document
.forms
[0].title
.focus();</script
>
454 <script type
='text/javascript'>
455 new Ajax
.Autocompleter('labels_value', 'labels_choices',
456 "backend.php?op=rpc&method=completeLabels",
457 { tokens
: ',', paramName
: "search" });
461 <div style
='float : right' class='insensitive-small'>
462 <?php
echo __("Shared article will appear in the Published feed.") ?
>
464 <button type
="submit"><?php
echo __('Share') ?
></button
>
465 <button onclick
="return window.close()"><?php
echo __('Cancel') ?
></button
>
477 $return = urlencode($_SERVER["REQUEST_URI"])
480 <form action
="public.php?return=<?php echo $return ?>"
481 method
="POST" id
="loginForm" name
="loginForm">
483 <input type
="hidden" name
="op" value
="login">
485 <table height
='100%' width
='100%'><tr
><td colspan
='2'>
486 <h1
><?php
echo __("Not logged in") ?
></h1
></td
></tr
>
488 <tr
><td align
="right"><?php
echo __("Login:") ?
></td
>
489 <td align
="right"><input name
="login"
490 value
="<?php echo $_SESSION["fake_login
"] ?>"></td
></tr
>
491 <tr
><td align
="right"><?php
echo __("Password:") ?
></td
>
492 <td align
="right"><input type
="password" name
="password"
493 value
="<?php echo $_SESSION["fake_password
"] ?>"></td
></tr
>
495 <button type
="submit">
496 <?php
echo __('Log in') ?
></button
>
498 <button onclick
="return window.close()">
499 <?php
echo __('Cancel') ?
></button
>
509 if (!SINGLE_USER_MODE
) {
511 $login = $this->dbh
->escape_string($_POST["login"]);
512 $password = $_POST["password"];
513 $remember_me = $_POST["remember_me"];
516 session_set_cookie_params(SESSION_COOKIE_LIFETIME
);
518 session_set_cookie_params(0);
523 if (authenticate_user($login, $password)) {
524 $_POST["password"] = "";
526 if (get_schema_version() >= 120) {
527 $_SESSION["language"] = get_pref("USER_LANGUAGE", $_SESSION["uid"]);
530 $_SESSION["ref_schema_version"] = get_schema_version(true);
531 $_SESSION["bw_limit"] = !!$_POST["bw_limit"];
533 if ($_POST["profile"]) {
535 $profile = $this->dbh
->escape_string($_POST["profile"]);
537 $result = $this->dbh
->query("SELECT id FROM ttrss_settings_profiles
538 WHERE id = '$profile' AND owner_uid = " . $_SESSION["uid"]);
540 if ($this->dbh
->num_rows($result) != 0) {
541 $_SESSION["profile"] = $profile;
545 $_SESSION["login_error_msg"] = __("Incorrect username or password");
548 if ($_REQUEST['return']) {
549 header("Location: " . $_REQUEST['return']);
551 header("Location: " . SELF_URL_PATH
);
556 function subscribe() {
557 if (SINGLE_USER_MODE
) {
561 if ($_SESSION["uid"]) {
563 $feed_url = $this->dbh
->escape_string(trim($_REQUEST["feed_url"]));
565 header('Content-Type: text/html; charset=utf-8');
568 <title>Tiny Tiny RSS</title>
569 <link rel=\"stylesheet\" type=\"text/css\" href=\"css/utility.css\">
570 <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
573 <img class=\"floatingLogo\" src=\"images/logo_small.png\"
574 alt=\"Tiny Tiny RSS\"/>
575 <h1>".__("Subscribe to feed...")."</h1><div class='content'>";
577 $rc = subscribe_to_feed($feed_url);
579 switch ($rc['code']) {
581 print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url));
584 print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url));
587 print_error(T_sprintf("Could not subscribe to <b>%s</b>.", $feed_url));
590 print_error(T_sprintf("No feeds found in <b>%s</b>.", $feed_url));
593 print_notice(__("Multiple feed URLs found."));
594 $feed_urls = $rc["feeds"];
597 print_error(T_sprintf("Could not subscribe to <b>%s</b>.<br>Can't download the Feed URL.", $feed_url));
603 print "<form action=\"public.php\">";
604 print "<input type=\"hidden\" name=\"op\" value=\"subscribe\">";
606 print "<select name=\"feed_url\">";
608 foreach ($feed_urls as $url => $name) {
609 $url = htmlspecialchars($url);
610 $name = htmlspecialchars($name);
612 print "<option value=\"$url\">$name</option>";
615 print "<input type=\"submit\" value=\"".__("Subscribe to selected feed").
621 $tp_uri = get_self_url_prefix() . "/prefs.php";
622 $tt_uri = get_self_url_prefix();
624 if ($rc['code'] <= 2){
625 $result = $this->dbh
->query("SELECT id FROM ttrss_feeds WHERE
626 feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
628 $feed_id = $this->dbh
->fetch_result($result, 0, "id");
635 print "<form method=\"GET\" style='display: inline'
637 <input type=\"hidden\" name=\"tab\" value=\"feedConfig\">
638 <input type=\"hidden\" name=\"method\" value=\"editFeed\">
639 <input type=\"hidden\" name=\"methodparam\" value=\"$feed_id\">
640 <input type=\"submit\" value=\"".__("Edit subscription options")."\">
644 print "<form style='display: inline' method=\"GET\" action=\"$tt_uri\">
645 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
648 print "</div></body></html>";
655 function subscribe2() {
656 $feed_url = $this->dbh
->escape_string(trim($_REQUEST["feed_url"]));
657 $cat_id = $this->dbh
->escape_string($_REQUEST["cat_id"]);
658 $from = $this->dbh
->escape_string($_REQUEST["from"]);
659 $feed_urls = array();
661 /* only read authentication information from POST */
663 $auth_login = $this->dbh
->escape_string(trim($_POST["auth_login"]));
664 $auth_pass = $this->dbh
->escape_string(trim($_POST["auth_pass"]));
666 $rc = subscribe_to_feed($feed_url, $cat_id, $auth_login, $auth_pass);
670 print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url));
673 print_error(T_sprintf("Could not subscribe to <b>%s</b>.", $feed_url));
676 print_error(T_sprintf("No feeds found in <b>%s</b>.", $feed_url));
679 print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url));
682 print_notice(__("Multiple feed URLs found."));
683 $contents = @fetch_file_contents
($url, false, $auth_login, $auth_pass);
684 if (is_html($contents)) {
685 $feed_urls = get_feeds_from_html($url, $contents);
689 print_error(T_sprintf("Could not subscribe to <b>%s</b>.<br>Can't download the Feed URL.", $feed_url));
694 print "<form action=\"backend.php\">";
695 print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">";
696 print "<input type=\"hidden\" name=\"quiet\" value=\"1\">";
697 print "<input type=\"hidden\" name=\"method\" value=\"add\">";
699 print "<select name=\"feed_url\">";
701 foreach ($feed_urls as $url => $name) {
702 $url = htmlspecialchars($url);
703 $name = htmlspecialchars($name);
704 print "<option value=\"$url\">$name</option>";
707 print "<input type=\"submit\" value=\"".__("Subscribe to selected feed")."\">";
711 $tp_uri = get_self_url_prefix() . "/prefs.php";
712 $tt_uri = get_self_url_prefix();
715 $result = $this->dbh
->query("SELECT id FROM ttrss_feeds WHERE
716 feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
718 $feed_id = $this->dbh
->fetch_result($result, 0, "id");
726 print "<form method=\"GET\" style='display: inline'
728 <input type=\"hidden\" name=\"tab\" value=\"feedConfig\">
729 <input type=\"hidden\" name=\"method\" value=\"editFeed\">
730 <input type=\"hidden\" name=\"methodparam\" value=\"$feed_id\">
731 <input type=\"submit\" value=\"".__("Edit subscription options")."\">
735 print "<form style='display: inline' method=\"GET\" action=\"$tt_uri\">
736 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
739 print "</body></html>";
743 header("Content-Type: text/plain");
744 print json_encode(array("error" => array("code" => 7)));
747 function forgotpass() {
750 header('Content-Type: text/html; charset=utf-8');
751 print "<html><head><title>Tiny Tiny RSS</title>";
753 stylesheet_tag("css/utility.css");
754 javascript_tag("lib/prototype.js");
756 print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
757 </head><body id='forgotpass'>";
759 print '<div class="floatingLogo"><img src="images/logo_small.png"></div>';
760 print "<h1>".__("Password recovery")."</h1>";
761 print "<div class='content'>";
763 @$method = $_POST['method'];
766 print_notice(__("You will need to provide valid account name and email. New password will be sent on your email address."));
768 print "<form method='POST' action='public.php'>";
769 print "<input type='hidden' name='method' value='do'>";
770 print "<input type='hidden' name='op' value='forgotpass'>";
773 print "<label>".__("Login:")."</label>";
774 print "<input type='text' name='login' value='' required>";
778 print "<label>".__("Email:")."</label>";
779 print "<input type='email' name='email' value='' required>";
783 print "<label>".__("How much is two plus two:")."</label>";
784 print "<input type='text' name='test' value='' required>";
788 print "<button type='submit'>".__("Reset password")."</button>";
791 } else if ($method == 'do') {
793 $login = $this->dbh
->escape_string($_POST["login"]);
794 $email = $this->dbh
->escape_string($_POST["email"]);
795 $test = $this->dbh
->escape_string($_POST["test"]);
797 if (($test != 4 && $test != 'four') ||
!$email ||
!$login) {
798 print_error(__('Some of the required form parameters are missing or incorrect.'));
800 print "<form method=\"GET\" action=\"public.php\">
801 <input type=\"hidden\" name=\"op\" value=\"forgotpass\">
802 <input type=\"submit\" value=\"".__("Go back")."\">
807 $result = $this->dbh
->query("SELECT id FROM ttrss_users
808 WHERE login = '$login' AND email = '$email'");
810 if ($this->dbh
->num_rows($result) != 0) {
811 $id = $this->dbh
->fetch_result($result, 0, "id");
813 Pref_Users
::resetUserPassword($id, false);
817 print "<p>"."Completed."."</p>";
819 print "<form method=\"GET\" action=\"index.php\">
820 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
824 print_error(__("Sorry, login and email combination not found."));
826 print "<form method=\"GET\" action=\"public.php\">
827 <input type=\"hidden\" name=\"op\" value=\"forgotpass\">
828 <input type=\"submit\" value=\"".__("Go back")."\">
842 function dbupdate() {
845 if (!SINGLE_USER_MODE
&& $_SESSION["access_level"] < 10) {
846 $_SESSION["login_error_msg"] = __("Your access level is insufficient to run this script.");
853 <title
>Database Updater
</title
>
854 <meta http
-equiv
="Content-Type" content
="text/html; charset=utf-8"/>
855 <link rel
="stylesheet" type
="text/css" href
="css/utility.css"/>
857 <style type
="text/css">
858 span
.ok
{ color
: #009000; font-weight : bold; }
859 span
.err
{ color
: #ff0000; font-weight : bold; }
862 <script type
='text/javascript'>
863 function confirmOP() {
864 return confirm("Update the database?");
868 <div
class="floatingLogo"><img src
="images/logo_small.png"></div
>
870 <h1
><?php
echo __("Database Updater") ?
></h1
>
872 <div
class="content">
875 @$op = $_REQUEST["subop"];
876 $updater = new DbUpdater(Db
::get(), DB_TYPE
, SCHEMA_VERSION
);
878 if ($op == "performupdate") {
879 if ($updater->isUpdateRequired()) {
881 print "<h2>Performing updates</h2>";
883 print "<h3>Updating to schema version " . SCHEMA_VERSION
. "</h3>";
887 for ($i = $updater->getSchemaVersion() +
1; $i <= SCHEMA_VERSION
; $i++
) {
888 print "<li>Performing update up to version $i...";
890 $result = $updater->performUpdateTo($i);
893 print "<span class='err'>FAILED!</span></li></ul>";
895 print_warning("One of the updates failed. Either retry the process or perform updates manually.");
896 print "<p><form method=\"GET\" action=\"index.php\">
897 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
902 print "<span class='ok'>OK!</span></li>";
908 print_notice("Your Tiny Tiny RSS database is now updated to the latest version.");
910 print "<p><form method=\"GET\" action=\"index.php\">
911 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
915 print "<h2>Your database is up to date.</h2>";
917 print "<p><form method=\"GET\" action=\"index.php\">
918 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
922 if ($updater->isUpdateRequired()) {
924 print "<h2>Database update required</h2>";
927 printf("Your Tiny Tiny RSS database needs update to the latest version: %d to %d.",
928 $updater->getSchemaVersion(), SCHEMA_VERSION
);
931 print_warning("Please backup your database before proceeding.");
933 print "<form method='POST'>
934 <input type='hidden' name='subop' value='performupdate'>
935 <input type='submit' onclick='return confirmOP()' value='".__("Perform updates")."'>
940 print_notice("Tiny Tiny RSS database is up to date.");
942 print "<p><form method=\"GET\" action=\"index.php\">
943 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">