]>
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 $tpl->setVariable('ARTICLE_SOURCE_TITLE', htmlspecialchars($line['feed_title']), true);
116 $tags = get_article_tags($line["id"], $owner_uid);
118 foreach ($tags as $tag) {
119 $tpl->setVariable('ARTICLE_CATEGORY', htmlspecialchars($tag), true);
120 $tpl->addBlock('category');
123 $enclosures = get_article_enclosures($line["id"]);
125 foreach ($enclosures as $e) {
126 $type = htmlspecialchars($e['content_type']);
127 $url = htmlspecialchars($e['content_url']);
128 $length = $e['duration'];
130 $tpl->setVariable('ARTICLE_ENCLOSURE_URL', $url, true);
131 $tpl->setVariable('ARTICLE_ENCLOSURE_TYPE', $type, true);
132 $tpl->setVariable('ARTICLE_ENCLOSURE_LENGTH', $length, true);
134 $tpl->addBlock('enclosure');
137 $tpl->addBlock('entry');
142 $tpl->addBlock('feed');
143 $tpl->generateOutputToString($tmp);
145 if (@!$_REQUEST["noxml"]) {
146 header("Content-Type: text/xml; charset=utf-8");
148 header("Content-Type: text/plain; charset=utf-8");
152 } else if ($format == 'json') {
156 $feed['title'] = $feed_title;
157 $feed['version'] = VERSION
;
158 $feed['feed_url'] = $feed_self_url;
160 if (PUBSUBHUBBUB_HUB
&& $feed == -2) {
161 $feed['hub_url'] = PUBSUBHUBBUB_HUB
;
164 $feed['self_url'] = get_self_url_prefix();
166 $feed['articles'] = array();
168 while ($line = $this->dbh
->fetch_assoc($result)) {
171 $article['id'] = $line['link'];
172 $article['link'] = $line['link'];
173 $article['title'] = $line['title'];
174 $article['excerpt'] = truncate_string(strip_tags($line["content_preview"]), 100, '...');
175 $article['content'] = sanitize($line["content_preview"], false, $owner_uid);
176 $article['updated'] = date('c', strtotime($line["updated"]));
178 if ($line['note']) $article['note'] = $line['note'];
179 if ($article['author']) $article['author'] = $line['author'];
181 $tags = get_article_tags($line["id"], $owner_uid);
183 if (count($tags) > 0) {
184 $article['tags'] = array();
186 foreach ($tags as $tag) {
187 array_push($article['tags'], $tag);
191 $enclosures = get_article_enclosures($line["id"]);
193 if (count($enclosures) > 0) {
194 $article['enclosures'] = array();
196 foreach ($enclosures as $e) {
197 $type = $e['content_type'];
198 $url = $e['content_url'];
199 $length = $e['duration'];
201 array_push($article['enclosures'], array("url" => $url, "type" => $type, "length" => $length));
205 array_push($feed['articles'], $article);
208 header("Content-Type: text/json; charset=utf-8");
209 print json_encode($feed);
212 header("Content-Type: text/plain; charset=utf-8");
213 print json_encode(array("error" => array("message" => "Unknown format")));
217 function getUnread() {
218 $login = $this->dbh
->escape_string($_REQUEST["login"]);
219 $fresh = $_REQUEST["fresh"] == "1";
221 $result = $this->dbh
->query("SELECT id FROM ttrss_users WHERE login = '$login'");
223 if ($this->dbh
->num_rows($result) == 1) {
224 $uid = $this->dbh
->fetch_result($result, 0, "id");
226 print getGlobalUnread($uid);
230 print getFeedArticles(-3, false, true, $uid);
234 print "-1;User not found";
239 function getProfiles() {
240 $login = $this->dbh
->escape_string($_REQUEST["login"]);
242 $result = $this->dbh
->query("SELECT ttrss_settings_profiles.* FROM ttrss_settings_profiles,ttrss_users
243 WHERE ttrss_users.id = ttrss_settings_profiles.owner_uid AND login = '$login' ORDER BY title");
245 print "<select dojoType='dijit.form.Select' style='width : 220px; margin : 0px' name='profile'>";
247 print "<option value='0'>" . __("Default profile") . "</option>";
249 while ($line = $this->dbh
->fetch_assoc($result)) {
251 $title = $line["title"];
253 print "<option value='$id'>$title</option>";
260 $mode = $this->dbh
->escape_string($_REQUEST['hub_mode']);
261 $feed_id = (int) $this->dbh
->escape_string($_REQUEST['id']);
262 $feed_url = $this->dbh
->escape_string($_REQUEST['hub_topic']);
264 if (!PUBSUBHUBBUB_ENABLED
) {
265 header('HTTP/1.0 404 Not Found');
266 echo "404 Not found";
270 // TODO: implement hub_verifytoken checking
272 $result = $this->dbh
->query("SELECT feed_url FROM ttrss_feeds
273 WHERE id = '$feed_id'");
275 if ($this->dbh
->num_rows($result) != 0) {
277 $check_feed_url = $this->dbh
->fetch_result($result, 0, "feed_url");
279 if ($check_feed_url && ($check_feed_url == $feed_url ||
!$feed_url)) {
280 if ($mode == "subscribe") {
282 $this->dbh
->query("UPDATE ttrss_feeds SET pubsub_state = 2
283 WHERE id = '$feed_id'");
285 print $_REQUEST['hub_challenge'];
288 } else if ($mode == "unsubscribe") {
290 $this->dbh
->query("UPDATE ttrss_feeds SET pubsub_state = 0
291 WHERE id = '$feed_id'");
293 print $_REQUEST['hub_challenge'];
298 // Received update ping, schedule feed update.
299 //update_rss_feed($feed_id, true, true);
301 $this->dbh
->query("UPDATE ttrss_feeds SET
302 last_update_started = '1970-01-01',
303 last_updated = '1970-01-01' WHERE id = '$feed_id'");
307 header('HTTP/1.0 404 Not Found');
308 echo "404 Not found";
311 header('HTTP/1.0 404 Not Found');
312 echo "404 Not found";
319 header("Location: index.php");
323 $uuid = $this->dbh
->escape_string($_REQUEST["key"]);
325 $result = $this->dbh
->query("SELECT ref_id, owner_uid FROM ttrss_user_entries WHERE
328 if ($this->dbh
->num_rows($result) != 0) {
329 header("Content-Type: text/html");
331 $id = $this->dbh
->fetch_result($result, 0, "ref_id");
332 $owner_uid = $this->dbh
->fetch_result($result, 0, "owner_uid");
334 $article = format_article($id, false, true, $owner_uid);
336 print_r($article['content']);
339 print "Article not found.";
345 $feed = $this->dbh
->escape_string($_REQUEST["id"]);
346 $key = $this->dbh
->escape_string($_REQUEST["key"]);
347 $is_cat = $_REQUEST["is_cat"] != false;
348 $limit = (int)$this->dbh
->escape_string($_REQUEST["limit"]);
349 $offset = (int)$this->dbh
->escape_string($_REQUEST["offset"]);
351 $search = $this->dbh
->escape_string($_REQUEST["q"]);
352 $search_mode = $this->dbh
->escape_string($_REQUEST["smode"]);
353 $view_mode = $this->dbh
->escape_string($_REQUEST["view-mode"]);
354 $order = $this->dbh
->escape_string($_REQUEST["order"]);
356 $format = $this->dbh
->escape_string($_REQUEST['format']);
358 if (!$format) $format = 'atom';
360 if (SINGLE_USER_MODE
) {
361 authenticate_user("admin", null);
367 $result = $this->dbh
->query("SELECT owner_uid FROM
368 ttrss_access_keys WHERE access_key = '$key' AND feed_id = '$feed'");
370 if ($this->dbh
->num_rows($result) == 1)
371 $owner_id = $this->dbh
->fetch_result($result, 0, "owner_uid");
375 $this->generate_syndicated_feed($owner_id, $feed, $is_cat, $limit,
376 $offset, $search, $search_mode, $view_mode, $format, $order);
378 header('HTTP/1.1 403 Forbidden');
382 function globalUpdateFeeds() {
383 include "rssfuncs.php";
384 // Update all feeds needing a update.
385 update_daemon_common(0, true, false);
386 housekeeping_common(false);
388 PluginHost
::getInstance()->run_hooks(PluginHost
::HOOK_UPDATE_TASK
, "hook_update_task", $op);
392 function sharepopup() {
393 if (SINGLE_USER_MODE
) {
397 header('Content-Type: text/html; charset=utf-8');
398 print "<html><head><title>Tiny Tiny RSS</title>";
400 stylesheet_tag("css/utility.css");
401 javascript_tag("lib/prototype.js");
402 javascript_tag("lib/scriptaculous/scriptaculous.js?load=effects,dragdrop,controls");
403 print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
404 </head><body id='sharepopup'>";
406 $action = $_REQUEST["action"];
408 if ($_SESSION["uid"]) {
410 if ($action == 'share') {
412 $title = $this->dbh
->escape_string(strip_tags($_REQUEST["title"]));
413 $url = $this->dbh
->escape_string(strip_tags($_REQUEST["url"]));
414 $content = $this->dbh
->escape_string(strip_tags($_REQUEST["content"]));
415 $labels = $this->dbh
->escape_string(strip_tags($_REQUEST["labels"]));
417 Article
::create_published_article($title, $url, $content, $labels,
420 print "<script type='text/javascript'>";
421 print "window.close();";
425 $title = htmlspecialchars($_REQUEST["title"]);
426 $url = htmlspecialchars($_REQUEST["url"]);
430 <table height
='100%' width
='100%'><tr
><td colspan
='2'>
431 <h1
><?php
echo __("Share with Tiny Tiny RSS") ?
></h1
>
434 <form id
='share_form' name
='share_form'>
436 <input type
="hidden" name
="op" value
="sharepopup">
437 <input type
="hidden" name
="action" value
="share">
439 <tr
><td align
='right'><?php
echo __("Title:") ?
></td
>
440 <td width
='80%'><input name
='title' value
="<?php echo $title ?>"></td
></tr
>
441 <tr
><td align
='right'><?php
echo __("URL:") ?
></td
>
442 <td
><input name
='url' value
="<?php echo $url ?>"></td
></tr
>
443 <tr
><td align
='right'><?php
echo __("Content:") ?
></td
>
444 <td
><input name
='content' value
=""></td
></tr
>
445 <tr
><td align
='right'><?php
echo __("Labels:") ?
></td
>
446 <td
><input name
='labels' id
="labels_value"
447 placeholder
='Alpha, Beta, Gamma' value
="">
451 <div
class="autocomplete" id
="labels_choices"
452 style
="display : block"></div
></td
></tr
>
454 <script type
='text/javascript'>document
.forms
[0].title
.focus();</script
>
456 <script type
='text/javascript'>
457 new Ajax
.Autocompleter('labels_value', 'labels_choices',
458 "backend.php?op=rpc&method=completeLabels",
459 { tokens
: ',', paramName
: "search" });
463 <div style
='float : right' class='insensitive-small'>
464 <?php
echo __("Shared article will appear in the Published feed.") ?
>
466 <button type
="submit"><?php
echo __('Share') ?
></button
>
467 <button onclick
="return window.close()"><?php
echo __('Cancel') ?
></button
>
479 $return = urlencode($_SERVER["REQUEST_URI"])
482 <form action
="public.php?return=<?php echo $return ?>"
483 method
="POST" id
="loginForm" name
="loginForm">
485 <input type
="hidden" name
="op" value
="login">
487 <table height
='100%' width
='100%'><tr
><td colspan
='2'>
488 <h1
><?php
echo __("Not logged in") ?
></h1
></td
></tr
>
490 <tr
><td align
="right"><?php
echo __("Login:") ?
></td
>
491 <td align
="right"><input name
="login"
492 value
="<?php echo $_SESSION["fake_login
"] ?>"></td
></tr
>
493 <tr
><td align
="right"><?php
echo __("Password:") ?
></td
>
494 <td align
="right"><input type
="password" name
="password"
495 value
="<?php echo $_SESSION["fake_password
"] ?>"></td
></tr
>
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 if (get_schema_version() >= 120) {
529 $_SESSION["language"] = get_pref("USER_LANGUAGE", $_SESSION["uid"]);
532 $_SESSION["ref_schema_version"] = get_schema_version(true);
533 $_SESSION["bw_limit"] = !!$_POST["bw_limit"];
535 if ($_POST["profile"]) {
537 $profile = $this->dbh
->escape_string($_POST["profile"]);
539 $result = $this->dbh
->query("SELECT id FROM ttrss_settings_profiles
540 WHERE id = '$profile' AND owner_uid = " . $_SESSION["uid"]);
542 if ($this->dbh
->num_rows($result) != 0) {
543 $_SESSION["profile"] = $profile;
547 $_SESSION["login_error_msg"] = __("Incorrect username or password");
548 user_error("Failed login attempt from {$_SERVER['REMOTE_ADDR']}", E_USER_WARNING
);
551 if ($_REQUEST['return']) {
552 header("Location: " . $_REQUEST['return']);
554 header("Location: " . SELF_URL_PATH
);
559 function subscribe() {
560 if (SINGLE_USER_MODE
) {
564 if ($_SESSION["uid"]) {
566 $feed_url = $this->dbh
->escape_string(trim($_REQUEST["feed_url"]));
568 header('Content-Type: text/html; charset=utf-8');
571 <title>Tiny Tiny RSS</title>
572 <link rel=\"stylesheet\" type=\"text/css\" href=\"css/utility.css\">
573 <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
576 <img class=\"floatingLogo\" src=\"images/logo_small.png\"
577 alt=\"Tiny Tiny RSS\"/>
578 <h1>".__("Subscribe to feed...")."</h1><div class='content'>";
580 $rc = subscribe_to_feed($feed_url);
582 switch ($rc['code']) {
584 print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url));
587 print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url));
590 print_error(T_sprintf("Could not subscribe to <b>%s</b>.", $feed_url));
593 print_error(T_sprintf("No feeds found in <b>%s</b>.", $feed_url));
596 print_notice(__("Multiple feed URLs found."));
597 $feed_urls = $rc["feeds"];
600 print_error(T_sprintf("Could not subscribe to <b>%s</b>.<br>Can't download the Feed URL.", $feed_url));
606 print "<form action=\"public.php\">";
607 print "<input type=\"hidden\" name=\"op\" value=\"subscribe\">";
609 print "<select name=\"feed_url\">";
611 foreach ($feed_urls as $url => $name) {
612 $url = htmlspecialchars($url);
613 $name = htmlspecialchars($name);
615 print "<option value=\"$url\">$name</option>";
618 print "<input type=\"submit\" value=\"".__("Subscribe to selected feed").
624 $tp_uri = get_self_url_prefix() . "/prefs.php";
625 $tt_uri = get_self_url_prefix();
627 if ($rc['code'] <= 2){
628 $result = $this->dbh
->query("SELECT id FROM ttrss_feeds WHERE
629 feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
631 $feed_id = $this->dbh
->fetch_result($result, 0, "id");
638 print "<form method=\"GET\" style='display: inline'
640 <input type=\"hidden\" name=\"tab\" value=\"feedConfig\">
641 <input type=\"hidden\" name=\"method\" value=\"editFeed\">
642 <input type=\"hidden\" name=\"methodparam\" value=\"$feed_id\">
643 <input type=\"submit\" value=\"".__("Edit subscription options")."\">
647 print "<form style='display: inline' method=\"GET\" action=\"$tt_uri\">
648 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
651 print "</div></body></html>";
658 function subscribe2() {
659 $feed_url = $this->dbh
->escape_string(trim($_REQUEST["feed_url"]));
660 $cat_id = $this->dbh
->escape_string($_REQUEST["cat_id"]);
661 $from = $this->dbh
->escape_string($_REQUEST["from"]);
662 $feed_urls = array();
664 /* only read authentication information from POST */
666 $auth_login = $this->dbh
->escape_string(trim($_POST["auth_login"]));
667 $auth_pass = $this->dbh
->escape_string(trim($_POST["auth_pass"]));
669 $rc = subscribe_to_feed($feed_url, $cat_id, $auth_login, $auth_pass);
673 print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url));
676 print_error(T_sprintf("Could not subscribe to <b>%s</b>.", $feed_url));
679 print_error(T_sprintf("No feeds found in <b>%s</b>.", $feed_url));
682 print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url));
685 print_notice(__("Multiple feed URLs found."));
686 $contents = @fetch_file_contents
($url, false, $auth_login, $auth_pass);
687 if (is_html($contents)) {
688 $feed_urls = get_feeds_from_html($url, $contents);
692 print_error(T_sprintf("Could not subscribe to <b>%s</b>.<br>Can't download the Feed URL.", $feed_url));
697 print "<form action=\"backend.php\">";
698 print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">";
699 print "<input type=\"hidden\" name=\"quiet\" value=\"1\">";
700 print "<input type=\"hidden\" name=\"method\" value=\"add\">";
702 print "<select name=\"feed_url\">";
704 foreach ($feed_urls as $url => $name) {
705 $url = htmlspecialchars($url);
706 $name = htmlspecialchars($name);
707 print "<option value=\"$url\">$name</option>";
710 print "<input type=\"submit\" value=\"".__("Subscribe to selected feed")."\">";
714 $tp_uri = get_self_url_prefix() . "/prefs.php";
715 $tt_uri = get_self_url_prefix();
718 $result = $this->dbh
->query("SELECT id FROM ttrss_feeds WHERE
719 feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
721 $feed_id = $this->dbh
->fetch_result($result, 0, "id");
729 print "<form method=\"GET\" style='display: inline'
731 <input type=\"hidden\" name=\"tab\" value=\"feedConfig\">
732 <input type=\"hidden\" name=\"method\" value=\"editFeed\">
733 <input type=\"hidden\" name=\"methodparam\" value=\"$feed_id\">
734 <input type=\"submit\" value=\"".__("Edit subscription options")."\">
738 print "<form style='display: inline' method=\"GET\" action=\"$tt_uri\">
739 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
742 print "</body></html>";
746 header("Content-Type: text/plain");
747 print json_encode(array("error" => array("code" => 7)));
750 function forgotpass() {
753 header('Content-Type: text/html; charset=utf-8');
754 print "<html><head><title>Tiny Tiny RSS</title>";
756 stylesheet_tag("css/utility.css");
757 javascript_tag("lib/prototype.js");
759 print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
760 </head><body id='forgotpass'>";
762 print '<div class="floatingLogo"><img src="images/logo_small.png"></div>';
763 print "<h1>".__("Password recovery")."</h1>";
764 print "<div class='content'>";
766 @$method = $_POST['method'];
769 print_notice(__("You will need to provide valid account name and email. New password will be sent on your email address."));
771 print "<form method='POST' action='public.php'>";
772 print "<input type='hidden' name='method' value='do'>";
773 print "<input type='hidden' name='op' value='forgotpass'>";
776 print "<label>".__("Login:")."</label>";
777 print "<input type='text' name='login' value='' required>";
781 print "<label>".__("Email:")."</label>";
782 print "<input type='email' name='email' value='' required>";
786 print "<label>".__("How much is two plus two:")."</label>";
787 print "<input type='text' name='test' value='' required>";
791 print "<button type='submit'>".__("Reset password")."</button>";
794 } else if ($method == 'do') {
796 $login = $this->dbh
->escape_string($_POST["login"]);
797 $email = $this->dbh
->escape_string($_POST["email"]);
798 $test = $this->dbh
->escape_string($_POST["test"]);
800 if (($test != 4 && $test != 'four') ||
!$email ||
!$login) {
801 print_error(__('Some of the required form parameters are missing or incorrect.'));
803 print "<form method=\"GET\" action=\"public.php\">
804 <input type=\"hidden\" name=\"op\" value=\"forgotpass\">
805 <input type=\"submit\" value=\"".__("Go back")."\">
810 $result = $this->dbh
->query("SELECT id FROM ttrss_users
811 WHERE login = '$login' AND email = '$email'");
813 if ($this->dbh
->num_rows($result) != 0) {
814 $id = $this->dbh
->fetch_result($result, 0, "id");
816 Pref_Users
::resetUserPassword($id, false);
820 print "<p>"."Completed."."</p>";
822 print "<form method=\"GET\" action=\"index.php\">
823 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
827 print_error(__("Sorry, login and email combination not found."));
829 print "<form method=\"GET\" action=\"public.php\">
830 <input type=\"hidden\" name=\"op\" value=\"forgotpass\">
831 <input type=\"submit\" value=\"".__("Go back")."\">
845 function dbupdate() {
848 if (!SINGLE_USER_MODE
&& $_SESSION["access_level"] < 10) {
849 $_SESSION["login_error_msg"] = __("Your access level is insufficient to run this script.");
856 <title
>Database Updater
</title
>
857 <meta http
-equiv
="Content-Type" content
="text/html; charset=utf-8"/>
858 <link rel
="stylesheet" type
="text/css" href
="css/utility.css"/>
860 <style type
="text/css">
861 span
.ok
{ color
: #009000; font-weight : bold; }
862 span
.err
{ color
: #ff0000; font-weight : bold; }
865 <script type
='text/javascript'>
866 function confirmOP() {
867 return confirm("Update the database?");
871 <div
class="floatingLogo"><img src
="images/logo_small.png"></div
>
873 <h1
><?php
echo __("Database Updater") ?
></h1
>
875 <div
class="content">
878 @$op = $_REQUEST["subop"];
879 $updater = new DbUpdater(Db
::get(), DB_TYPE
, SCHEMA_VERSION
);
881 if ($op == "performupdate") {
882 if ($updater->isUpdateRequired()) {
884 print "<h2>Performing updates</h2>";
886 print "<h3>Updating to schema version " . SCHEMA_VERSION
. "</h3>";
890 for ($i = $updater->getSchemaVersion() +
1; $i <= SCHEMA_VERSION
; $i++
) {
891 print "<li>Performing update up to version $i...";
893 $result = $updater->performUpdateTo($i);
896 print "<span class='err'>FAILED!</span></li></ul>";
898 print_warning("One of the updates failed. Either retry the process or perform updates manually.");
899 print "<p><form method=\"GET\" action=\"index.php\">
900 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
905 print "<span class='ok'>OK!</span></li>";
911 print_notice("Your Tiny Tiny RSS database is now updated to the latest version.");
913 print "<p><form method=\"GET\" action=\"index.php\">
914 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
918 print "<h2>Your database is up to date.</h2>";
920 print "<p><form method=\"GET\" action=\"index.php\">
921 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
925 if ($updater->isUpdateRequired()) {
927 print "<h2>Database update required</h2>";
930 printf("Your Tiny Tiny RSS database needs update to the latest version: %d to %d.",
931 $updater->getSchemaVersion(), SCHEMA_VERSION
);
934 print_warning("Please backup your database before proceeding.");
936 print "<form method='POST'>
937 <input type='hidden' name='subop' value='performupdate'>
938 <input type='submit' onclick='return confirmOP()' value='".__("Perform updates")."'>
943 print_notice("Tiny Tiny RSS database is up to date.");
945 print "<p><form method=\"GET\" action=\"index.php\">
946 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">