]>
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') {
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";
24 $qfh_ret = queryFeedHeadlines($feed,
25 1, $view_mode, $is_cat, $search, $search_mode,
26 $date_sort_field, $offset, $owner_uid,
27 false, 0, false, true);
29 $result = $qfh_ret[0];
31 if ($this->dbh
->num_rows($result) != 0) {
32 $ts = strtotime($this->dbh
->fetch_result($result, 0, "date_entered"));
34 if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) &&
35 strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $ts) {
36 header('HTTP/1.0 304 Not Modified');
40 $last_modified = gmdate("D, d M Y H:i:s", $ts) . " GMT";
41 header("Last-Modified: $last_modified", true);
44 $qfh_ret = queryFeedHeadlines($feed,
45 $limit, $view_mode, $is_cat, $search, $search_mode,
46 $date_sort_field, $offset, $owner_uid,
47 false, 0, false, true);
50 $result = $qfh_ret[0];
51 $feed_title = htmlspecialchars($qfh_ret[1]);
52 $feed_site_url = $qfh_ret[2];
53 $last_error = $qfh_ret[3];
55 $feed_self_url = get_self_url_prefix() .
56 "/public.php?op=rss&id=-2&key=" .
57 get_feed_access_key(-2, false, $owner_uid);
59 if (!$feed_site_url) $feed_site_url = get_self_url_prefix();
61 if ($format == 'atom') {
62 $tpl = new MiniTemplator
;
64 $tpl->readTemplateFromFile("templates/generated_feed.txt");
66 $tpl->setVariable('FEED_TITLE', $feed_title, true);
67 $tpl->setVariable('VERSION', VERSION
, true);
68 $tpl->setVariable('FEED_URL', htmlspecialchars($feed_self_url), true);
70 if (PUBSUBHUBBUB_HUB
&& $feed == -2) {
71 $tpl->setVariable('HUB_URL', htmlspecialchars(PUBSUBHUBBUB_HUB
), true);
72 $tpl->addBlock('feed_hub');
75 $tpl->setVariable('SELF_URL', htmlspecialchars(get_self_url_prefix()), true);
77 while ($line = $this->dbh
->fetch_assoc($result)) {
79 $tpl->setVariable('ARTICLE_ID', htmlspecialchars($line['link']), true);
80 $tpl->setVariable('ARTICLE_LINK', htmlspecialchars($line['link']), true);
81 $tpl->setVariable('ARTICLE_TITLE', htmlspecialchars($line['title']), true);
82 $tpl->setVariable('ARTICLE_EXCERPT',
83 truncate_string(strip_tags($line["content_preview"]), 100, '...'), true);
85 $content = sanitize($line["content_preview"], false, $owner_uid);
88 $content = "<div style=\"$note_style\">Article note: " . $line['note'] . "</div>" .
90 $tpl->setVariable('ARTICLE_NOTE', htmlspecialchars($line['note']), true);
93 $tpl->setVariable('ARTICLE_CONTENT', $content, true);
95 $tpl->setVariable('ARTICLE_UPDATED_ATOM',
96 date('c', strtotime($line["updated"])), true);
97 $tpl->setVariable('ARTICLE_UPDATED_RFC822',
98 date(DATE_RFC822
, strtotime($line["updated"])), true);
100 $tpl->setVariable('ARTICLE_AUTHOR', htmlspecialchars($line['author']), true);
102 $tags = get_article_tags($line["id"], $owner_uid);
104 foreach ($tags as $tag) {
105 $tpl->setVariable('ARTICLE_CATEGORY', htmlspecialchars($tag), true);
106 $tpl->addBlock('category');
109 $enclosures = get_article_enclosures($line["id"]);
111 foreach ($enclosures as $e) {
112 $type = htmlspecialchars($e['content_type']);
113 $url = htmlspecialchars($e['content_url']);
114 $length = $e['duration'];
116 $tpl->setVariable('ARTICLE_ENCLOSURE_URL', $url, true);
117 $tpl->setVariable('ARTICLE_ENCLOSURE_TYPE', $type, true);
118 $tpl->setVariable('ARTICLE_ENCLOSURE_LENGTH', $length, true);
120 $tpl->addBlock('enclosure');
123 $tpl->addBlock('entry');
128 $tpl->addBlock('feed');
129 $tpl->generateOutputToString($tmp);
131 if (@!$_REQUEST["noxml"]) {
132 header("Content-Type: text/xml; charset=utf-8");
134 header("Content-Type: text/plain; charset=utf-8");
138 } else if ($format == 'json') {
142 $feed['title'] = $feed_title;
143 $feed['version'] = VERSION
;
144 $feed['feed_url'] = $feed_self_url;
146 if (PUBSUBHUBBUB_HUB
&& $feed == -2) {
147 $feed['hub_url'] = PUBSUBHUBBUB_HUB
;
150 $feed['self_url'] = get_self_url_prefix();
152 $feed['articles'] = array();
154 while ($line = $this->dbh
->fetch_assoc($result)) {
157 $article['id'] = $line['link'];
158 $article['link'] = $line['link'];
159 $article['title'] = $line['title'];
160 $article['excerpt'] = truncate_string(strip_tags($line["content_preview"]), 100, '...');
161 $article['content'] = sanitize($line["content_preview"], false, $owner_uid);
162 $article['updated'] = date('c', strtotime($line["updated"]));
164 if ($line['note']) $article['note'] = $line['note'];
165 if ($article['author']) $article['author'] = $line['author'];
167 $tags = get_article_tags($line["id"], $owner_uid);
169 if (count($tags) > 0) {
170 $article['tags'] = array();
172 foreach ($tags as $tag) {
173 array_push($article['tags'], $tag);
177 $enclosures = get_article_enclosures($line["id"]);
179 if (count($enclosures) > 0) {
180 $article['enclosures'] = array();
182 foreach ($enclosures as $e) {
183 $type = $e['content_type'];
184 $url = $e['content_url'];
185 $length = $e['duration'];
187 array_push($article['enclosures'], array("url" => $url, "type" => $type, "length" => $length));
191 array_push($feed['articles'], $article);
194 header("Content-Type: text/json; charset=utf-8");
195 print json_encode($feed);
198 header("Content-Type: text/plain; charset=utf-8");
199 print json_encode(array("error" => array("message" => "Unknown format")));
203 function getUnread() {
204 $login = $this->dbh
->escape_string($_REQUEST["login"]);
205 $fresh = $_REQUEST["fresh"] == "1";
207 $result = $this->dbh
->query("SELECT id FROM ttrss_users WHERE login = '$login'");
209 if ($this->dbh
->num_rows($result) == 1) {
210 $uid = $this->dbh
->fetch_result($result, 0, "id");
212 print getGlobalUnread($uid);
216 print getFeedArticles(-3, false, true, $uid);
220 print "-1;User not found";
225 function getProfiles() {
226 $login = $this->dbh
->escape_string($_REQUEST["login"]);
228 $result = $this->dbh
->query("SELECT * FROM ttrss_settings_profiles,ttrss_users
229 WHERE ttrss_users.id = ttrss_settings_profiles.owner_uid AND login = '$login' ORDER BY title");
231 print "<select dojoType='dijit.form.Select' style='width : 220px; margin : 0px' name='profile'>";
233 print "<option value='0'>" . __("Default profile") . "</option>";
235 while ($line = $this->dbh
->fetch_assoc($result)) {
237 $title = $line["title"];
239 print "<option value='$id'>$title</option>";
246 $mode = $this->dbh
->escape_string($_REQUEST['hub_mode']);
247 $feed_id = (int) $this->dbh
->escape_string($_REQUEST['id']);
248 $feed_url = $this->dbh
->escape_string($_REQUEST['hub_topic']);
250 if (!PUBSUBHUBBUB_ENABLED
) {
251 header('HTTP/1.0 404 Not Found');
252 echo "404 Not found";
256 // TODO: implement hub_verifytoken checking
258 $result = $this->dbh
->query("SELECT feed_url FROM ttrss_feeds
259 WHERE id = '$feed_id'");
261 if ($this->dbh
->num_rows($result) != 0) {
263 $check_feed_url = $this->dbh
->fetch_result($result, 0, "feed_url");
265 if ($check_feed_url && ($check_feed_url == $feed_url ||
!$feed_url)) {
266 if ($mode == "subscribe") {
268 $this->dbh
->query("UPDATE ttrss_feeds SET pubsub_state = 2
269 WHERE id = '$feed_id'");
271 print $_REQUEST['hub_challenge'];
274 } else if ($mode == "unsubscribe") {
276 $this->dbh
->query("UPDATE ttrss_feeds SET pubsub_state = 0
277 WHERE id = '$feed_id'");
279 print $_REQUEST['hub_challenge'];
284 // Received update ping, schedule feed update.
285 //update_rss_feed($feed_id, true, true);
287 $this->dbh
->query("UPDATE ttrss_feeds SET
288 last_update_started = '1970-01-01',
289 last_updated = '1970-01-01' WHERE id = '$feed_id'");
293 header('HTTP/1.0 404 Not Found');
294 echo "404 Not found";
297 header('HTTP/1.0 404 Not Found');
298 echo "404 Not found";
305 header("Location: index.php");
309 $uuid = $this->dbh
->escape_string($_REQUEST["key"]);
311 $result = $this->dbh
->query("SELECT ref_id, owner_uid FROM ttrss_user_entries WHERE
314 if ($this->dbh
->num_rows($result) != 0) {
315 header("Content-Type: text/html");
317 $id = $this->dbh
->fetch_result($result, 0, "ref_id");
318 $owner_uid = $this->dbh
->fetch_result($result, 0, "owner_uid");
320 $article = format_article($id, false, true, $owner_uid);
322 print_r($article['content']);
325 print "Article not found.";
331 $feed = $this->dbh
->escape_string($_REQUEST["id"]);
332 $key = $this->dbh
->escape_string($_REQUEST["key"]);
333 $is_cat = $_REQUEST["is_cat"] != false;
334 $limit = (int)$this->dbh
->escape_string($_REQUEST["limit"]);
335 $offset = (int)$this->dbh
->escape_string($_REQUEST["offset"]);
337 $search = $this->dbh
->escape_string($_REQUEST["q"]);
338 $search_mode = $this->dbh
->escape_string($_REQUEST["smode"]);
339 $view_mode = $this->dbh
->escape_string($_REQUEST["view-mode"]);
341 $format = $this->dbh
->escape_string($_REQUEST['format']);
343 if (!$format) $format = 'atom';
345 if (SINGLE_USER_MODE
) {
346 authenticate_user("admin", null);
352 $result = $this->dbh
->query("SELECT owner_uid FROM
353 ttrss_access_keys WHERE access_key = '$key' AND feed_id = '$feed'");
355 if ($this->dbh
->num_rows($result) == 1)
356 $owner_id = $this->dbh
->fetch_result($result, 0, "owner_uid");
360 $this->generate_syndicated_feed($owner_id, $feed, $is_cat, $limit,
361 $offset, $search, $search_mode, $view_mode, $format);
363 header('HTTP/1.1 403 Forbidden');
367 function globalUpdateFeeds() {
368 include "rssfuncs.php";
369 // Update all feeds needing a update.
370 update_daemon_common(0, true, false);
372 // Update feedbrowser
373 update_feedbrowser_cache();
375 // Purge orphans and cleanup tags
378 cleanup_tags(14, 50000);
380 PluginHost
::getInstance()->run_hooks(PluginHost
::HOOK_UPDATE_TASK
, "hook_update_task", $op);
384 function sharepopup() {
385 if (SINGLE_USER_MODE
) {
389 header('Content-Type: text/html; charset=utf-8');
390 print "<html><head><title>Tiny Tiny RSS</title>";
392 print stylesheet_tag("utility.css");
393 print javascript_tag("lib/prototype.js");
394 print javascript_tag("lib/scriptaculous/scriptaculous.js?load=effects,dragdrop,controls");
395 print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
396 </head><body id='sharepopup'>";
398 $action = $_REQUEST["action"];
400 if ($_SESSION["uid"]) {
402 if ($action == 'share') {
404 $title = $this->dbh
->escape_string(strip_tags($_REQUEST["title"]));
405 $url = $this->dbh
->escape_string(strip_tags($_REQUEST["url"]));
406 $content = $this->dbh
->escape_string(strip_tags($_REQUEST["content"]));
407 $labels = $this->dbh
->escape_string(strip_tags($_REQUEST["labels"]));
409 Article
::create_published_article($title, $url, $content, $labels,
412 print "<script type='text/javascript'>";
413 print "window.close();";
417 $title = htmlspecialchars($_REQUEST["title"]);
418 $url = htmlspecialchars($_REQUEST["url"]);
422 <table height
='100%' width
='100%'><tr
><td colspan
='2'>
423 <h1
><?php
echo __("Share with Tiny Tiny RSS") ?
></h1
>
426 <form id
='share_form' name
='share_form'>
428 <input type
="hidden" name
="op" value
="sharepopup">
429 <input type
="hidden" name
="action" value
="share">
431 <tr
><td align
='right'><?php
echo __("Title:") ?
></td
>
432 <td width
='80%'><input name
='title' value
="<?php echo $title ?>"></td
></tr
>
433 <tr
><td align
='right'><?php
echo __("URL:") ?
></td
>
434 <td
><input name
='url' value
="<?php echo $url ?>"></td
></tr
>
435 <tr
><td align
='right'><?php
echo __("Content:") ?
></td
>
436 <td
><input name
='content' value
=""></td
></tr
>
437 <tr
><td align
='right'><?php
echo __("Labels:") ?
></td
>
438 <td
><input name
='labels' id
="labels_value"
439 placeholder
='Alpha, Beta, Gamma' value
="">
443 <div
class="autocomplete" id
="labels_choices"
444 style
="display : block"></div
></td
></tr
>
446 <script type
='text/javascript'>document
.forms
[0].title
.focus();</script
>
448 <script type
='text/javascript'>
449 new Ajax
.Autocompleter('labels_value', 'labels_choices',
450 "backend.php?op=rpc&method=completeLabels",
451 { tokens
: ',', paramName
: "search" });
455 <div style
='float : right' class='insensitive-small'>
456 <?php
echo __("Shared article will appear in the Published feed.") ?
>
458 <button type
="submit"><?php
echo __('Share') ?
></button
>
459 <button onclick
="return window.close()"><?php
echo __('Cancel') ?
></button
>
471 $return = urlencode($_SERVER["REQUEST_URI"])
474 <form action
="public.php?return=<?php echo $return ?>"
475 method
="POST" id
="loginForm" name
="loginForm">
477 <input type
="hidden" name
="op" value
="login">
479 <table height
='100%' width
='100%'><tr
><td colspan
='2'>
480 <h1
><?php
echo __("Not logged in") ?
></h1
></td
></tr
>
482 <tr
><td align
="right"><?php
echo __("Login:") ?
></td
>
483 <td align
="right"><input name
="login"
484 value
="<?php echo $_SESSION["fake_login
"] ?>"></td
></tr
>
485 <tr
><td align
="right"><?php
echo __("Password:") ?
></td
>
486 <td align
="right"><input type
="password" name
="password"
487 value
="<?php echo $_SESSION["fake_password
"] ?>"></td
></tr
>
488 <tr
><td align
="right"><?php
echo __("Language:") ?
></td
>
491 print_select_hash("language", $_COOKIE["ttrss_lang"], get_translations(),
492 "style='width : 100%''");
497 <button type
="submit">
498 <?php
echo __('Log in') ?
></button
>
500 <button onclick
="return window.close()">
501 <?php
echo __('Cancel') ?
></button
>
511 if (!SINGLE_USER_MODE
) {
513 $login = $this->dbh
->escape_string($_POST["login"]);
514 $password = $_POST["password"];
515 $remember_me = $_POST["remember_me"];
518 session_set_cookie_params(SESSION_COOKIE_LIFETIME
);
520 session_set_cookie_params(0);
525 if (authenticate_user($login, $password)) {
526 $_POST["password"] = "";
528 $_SESSION["language"] = $_POST["language"];
529 $_SESSION["ref_schema_version"] = get_schema_version(true);
530 $_SESSION["bw_limit"] = !!$_POST["bw_limit"];
532 if ($_POST["profile"]) {
534 $profile = $this->dbh
->escape_string($_POST["profile"]);
536 $result = $this->dbh
->query("SELECT id FROM ttrss_settings_profiles
537 WHERE id = '$profile' AND owner_uid = " . $_SESSION["uid"]);
539 if ($this->dbh
->num_rows($result) != 0) {
540 $_SESSION["profile"] = $profile;
544 $_SESSION["login_error_msg"] = __("Incorrect username or password");
547 if ($_REQUEST['return']) {
548 header("Location: " . $_REQUEST['return']);
550 header("Location: " . SELF_URL_PATH
);
555 function subscribe() {
556 if (SINGLE_USER_MODE
) {
560 if ($_SESSION["uid"]) {
562 $feed_url = $this->dbh
->escape_string(trim($_REQUEST["feed_url"]));
564 header('Content-Type: text/html; charset=utf-8');
567 <title>Tiny Tiny RSS</title>
568 <link rel=\"stylesheet\" type=\"text/css\" href=\"utility.css\">
569 <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
572 <img class=\"floatingLogo\" src=\"images/logo_small.png\"
573 alt=\"Tiny Tiny RSS\"/>
574 <h1>".__("Subscribe to feed...")."</h1><div class='content'>";
576 $rc = subscribe_to_feed($feed_url);
578 switch ($rc['code']) {
580 print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url));
583 print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url));
586 print_error(T_sprintf("Could not subscribe to <b>%s</b>.", $feed_url));
589 print_error(T_sprintf("No feeds found in <b>%s</b>.", $feed_url));
592 print_notice(__("Multiple feed URLs found."));
593 $feed_urls = $rc["feeds"];
596 print_error(T_sprintf("Could not subscribe to <b>%s</b>.<br>Can't download the Feed URL.", $feed_url));
602 print "<form action=\"public.php\">";
603 print "<input type=\"hidden\" name=\"op\" value=\"subscribe\">";
605 print "<select name=\"feed_url\">";
607 foreach ($feed_urls as $url => $name) {
608 $url = htmlspecialchars($url);
609 $name = htmlspecialchars($name);
611 print "<option value=\"$url\">$name</option>";
614 print "<input type=\"submit\" value=\"".__("Subscribe to selected feed").
620 $tp_uri = get_self_url_prefix() . "/prefs.php";
621 $tt_uri = get_self_url_prefix();
623 if ($rc['code'] <= 2){
624 $result = $this->dbh
->query("SELECT id FROM ttrss_feeds WHERE
625 feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
627 $feed_id = $this->dbh
->fetch_result($result, 0, "id");
634 print "<form method=\"GET\" style='display: inline'
636 <input type=\"hidden\" name=\"tab\" value=\"feedConfig\">
637 <input type=\"hidden\" name=\"method\" value=\"editFeed\">
638 <input type=\"hidden\" name=\"methodparam\" value=\"$feed_id\">
639 <input type=\"submit\" value=\"".__("Edit subscription options")."\">
643 print "<form style='display: inline' method=\"GET\" action=\"$tt_uri\">
644 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
647 print "</div></body></html>";
654 function subscribe2() {
655 $feed_url = $this->dbh
->escape_string(trim($_REQUEST["feed_url"]));
656 $cat_id = $this->dbh
->escape_string($_REQUEST["cat_id"]);
657 $from = $this->dbh
->escape_string($_REQUEST["from"]);
659 /* only read authentication information from POST */
661 $auth_login = $this->dbh
->escape_string(trim($_POST["auth_login"]));
662 $auth_pass = $this->dbh
->escape_string(trim($_POST["auth_pass"]));
664 $rc = subscribe_to_feed($feed_url, $cat_id, $auth_login, $auth_pass);
668 print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url));
671 print_error(T_sprintf("Could not subscribe to <b>%s</b>.", $feed_url));
674 print_error(T_sprintf("No feeds found in <b>%s</b>.", $feed_url));
677 print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url));
680 print_notice(__("Multiple feed URLs found."));
682 $feed_urls = get_feeds_from_html($feed_url);
685 print_error(T_sprintf("Could not subscribe to <b>%s</b>.<br>Can't download the Feed URL.", $feed_url));
690 print "<form action=\"backend.php\">";
691 print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">";
692 print "<input type=\"hidden\" name=\"quiet\" value=\"1\">";
693 print "<input type=\"hidden\" name=\"method\" value=\"add\">";
695 print "<select name=\"feed_url\">";
697 foreach ($feed_urls as $url => $name) {
698 $url = htmlspecialchars($url);
699 $name = htmlspecialchars($name);
700 print "<option value=\"$url\">$name</option>";
703 print "<input type=\"submit\" value=\"".__("Subscribe to selected feed")."\">";
707 $tp_uri = get_self_url_prefix() . "/prefs.php";
708 $tt_uri = get_self_url_prefix();
711 $result = $this->dbh
->query("SELECT id FROM ttrss_feeds WHERE
712 feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
714 $feed_id = $this->dbh
->fetch_result($result, 0, "id");
722 print "<form method=\"GET\" style='display: inline'
724 <input type=\"hidden\" name=\"tab\" value=\"feedConfig\">
725 <input type=\"hidden\" name=\"method\" value=\"editFeed\">
726 <input type=\"hidden\" name=\"methodparam\" value=\"$feed_id\">
727 <input type=\"submit\" value=\"".__("Edit subscription options")."\">
731 print "<form style='display: inline' method=\"GET\" action=\"$tt_uri\">
732 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
735 print "</body></html>";
739 header("Content-Type: text/plain");
740 print json_encode(array("error" => array("code" => 7)));
743 function forgotpass() {
744 header('Content-Type: text/html; charset=utf-8');
745 print "<html><head><title>Tiny Tiny RSS</title>";
747 print stylesheet_tag("utility.css");
748 print javascript_tag("lib/prototype.js");
750 print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
751 </head><body id='forgotpass'>";
753 print '<div class="floatingLogo"><img src="images/logo_small.png"></div>';
754 print "<h1>".__("Password recovery")."</h1>";
755 print "<div class='content'>";
757 @$method = $_POST['method'];
760 print_notice(__("You will need to provide valid account name and email. New password will be sent on your email address."));
762 print "<form method='POST' action='public.php'>";
763 print "<input type='hidden' name='method' value='do'>";
764 print "<input type='hidden' name='op' value='forgotpass'>";
767 print "<label>".__("Login:")."</label>";
768 print "<input type='text' name='login' value='' required>";
772 print "<label>".__("Email:")."</label>";
773 print "<input type='email' name='email' value='' required>";
777 print "<label>".__("How much is two plus two:")."</label>";
778 print "<input type='text' name='test' value='' required>";
782 print "<button type='submit'>".__("Reset password")."</button>";
785 } else if ($method == 'do') {
787 $login = $this->dbh
->escape_string($_POST["login"]);
788 $email = $this->dbh
->escape_string($_POST["email"]);
789 $test = $this->dbh
->escape_string($_POST["test"]);
791 if (($test != 4 && $test != 'four') ||
!$email ||
!$login) {
792 print_error(__('Some of the required form parameters are missing or incorrect.'));
794 print "<form method=\"GET\" action=\"public.php\">
795 <input type=\"hidden\" name=\"op\" value=\"forgotpass\">
796 <input type=\"submit\" value=\"".__("Go back")."\">
801 $result = $this->dbh
->query("SELECT id FROM ttrss_users
802 WHERE login = '$login' AND email = '$email'");
804 if ($this->dbh
->num_rows($result) != 0) {
805 $id = $this->dbh
->fetch_result($result, 0, "id");
807 Pref_Users
::resetUserPassword($id, false);
811 print "<p>"."Completed."."</p>";
813 print "<form method=\"GET\" action=\"index.php\">
814 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
818 print_error(__("Sorry, login and email combination not found."));
820 print "<form method=\"GET\" action=\"public.php\">
821 <input type=\"hidden\" name=\"op\" value=\"forgotpass\">
822 <input type=\"submit\" value=\"".__("Go back")."\">
836 function dbupdate() {
837 if (!SINGLE_USER_MODE
&& $_SESSION["access_level"] < 10) {
838 $_SESSION["login_error_msg"] = __("Your access level is insufficient to run this script.");
845 <title
>Database Updater
</title
>
846 <meta http
-equiv
="Content-Type" content
="text/html; charset=utf-8"/>
847 <link rel
="stylesheet" type
="text/css" href
="utility.css"/>
849 <style type
="text/css">
850 span
.ok
{ color
: #009000; font-weight : bold; }
851 span
.err
{ color
: #ff0000; font-weight : bold; }
854 <script type
='text/javascript'>
855 function confirmOP() {
856 return confirm("Update the database?");
860 <div
class="floatingLogo"><img src
="images/logo_small.png"></div
>
862 <h1
><?php
echo __("Database Updater") ?
></h1
>
864 <div
class="content">
867 @$op = $_REQUEST["subop"];
868 $updater = new DbUpdater(Db
::get(), DB_TYPE
, SCHEMA_VERSION
);
870 if ($op == "performupdate") {
871 if ($updater->isUpdateRequired()) {
873 print "<h2>Performing updates</h2>";
875 print "<h3>Updating to schema version " . SCHEMA_VERSION
. "</h3>";
879 for ($i = $updater->getSchemaVersion() +
1; $i <= SCHEMA_VERSION
; $i++
) {
880 print "<li>Performing update up to version $i...";
882 $result = $updater->performUpdateTo($i);
885 print "<span class='err'>FAILED!</span></li></ul>";
887 print_warning("One of the updates failed. Either retry the process or perform updates manually.");
888 print "<p><form method=\"GET\" action=\"index.php\">
889 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
894 print "<span class='ok'>OK!</span></li>";
900 print_notice("Your Tiny Tiny RSS database is now updated to the latest version.");
902 print "<p><form method=\"GET\" action=\"index.php\">
903 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
907 print "<h2>Your database is up to date.</h2>";
909 print "<p><form method=\"GET\" action=\"index.php\">
910 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
914 if ($updater->isUpdateRequired()) {
916 print "<h2>Database update required</h2>";
919 printf("Your Tiny Tiny RSS database needs update to the latest version: %d to %d.",
920 $updater->getSchemaVersion(), SCHEMA_VERSION
);
923 print_warning("Please backup your database before proceeding.");
925 print "<form method='POST'>
926 <input type='hidden' name='subop' value='performupdate'>
927 <input type='submit' onclick='return confirmOP()' value='".__("Perform updates")."'>
932 print_notice("Tiny Tiny RSS database is up to date.");
934 print "<p><form method=\"GET\" action=\"index.php\">
935 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">