]>
git.wh0rd.org - tt-rss.git/blob - classes/handler/public.php
3c65b992b7f72e468525cd55de3256995f811ae1
2 class Handler_Public
extends Handler
{
4 private function generate_syndicated_feed($owner_uid, $feed, $is_cat,
5 $limit, $offset, $search,
6 $view_mode = false, $format = 'atom', $order = false, $orig_guid = false, $start_ts = 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";
18 $date_check_field = "date_entered";
20 if ($feed == -2 && !$is_cat) {
21 $date_sort_field = "last_published DESC";
22 $date_check_field = "last_published";
23 } else if ($feed == -1 && !$is_cat) {
24 $date_sort_field = "last_marked DESC";
25 $date_check_field = "last_marked";
30 $date_sort_field = "ttrss_entries.title, date_entered, updated";
33 $date_sort_field = "date_entered, updated";
36 $date_sort_field = "updated DESC";
40 "owner_uid" => $owner_uid,
43 "view_mode" => $view_mode,
44 "cat_view" => $is_cat,
46 "override_order" => $date_sort_field,
47 "include_children" => true,
48 "ignore_vfeed_group" => true,
50 "start_ts" => $start_ts
53 $qfh_ret = Feeds
::queryFeedHeadlines($params);
55 $result = $qfh_ret[0];
56 $feed_title = htmlspecialchars($qfh_ret[1]);
57 $feed_site_url = $qfh_ret[2];
58 /* $last_error = $qfh_ret[3]; */
60 $feed_self_url = get_self_url_prefix() .
61 "/public.php?op=rss&id=$feed&key=" .
62 get_feed_access_key($feed, false, $owner_uid);
64 if (!$feed_site_url) $feed_site_url = get_self_url_prefix();
66 if ($format == 'atom') {
67 $tpl = new MiniTemplator
;
69 $tpl->readTemplateFromFile("templates/generated_feed.txt");
71 $tpl->setVariable('FEED_TITLE', $feed_title, true);
72 $tpl->setVariable('VERSION', VERSION
, true);
73 $tpl->setVariable('FEED_URL', htmlspecialchars($feed_self_url), true);
75 $tpl->setVariable('SELF_URL', htmlspecialchars(get_self_url_prefix()), true);
76 while ($line = $result->fetch()) {
78 $line["content_preview"] = sanitize(truncate_string(strip_tags($line["content"]), 100, '...'));
80 foreach (PluginHost
::getInstance()->get_hooks(PluginHost
::HOOK_QUERY_HEADLINES
) as $p) {
81 $line = $p->hook_query_headlines($line);
84 foreach (PluginHost
::getInstance()->get_hooks(PluginHost
::HOOK_ARTICLE_EXPORT_FEED
) as $p) {
85 $line = $p->hook_article_export_feed($line, $feed, $is_cat);
88 $tpl->setVariable('ARTICLE_ID',
89 htmlspecialchars($orig_guid ?
$line['link'] :
90 $this->make_article_tag_uri($line['id'], $line['date_entered'])), true);
91 $tpl->setVariable('ARTICLE_LINK', htmlspecialchars($line['link']), true);
92 $tpl->setVariable('ARTICLE_TITLE', htmlspecialchars($line['title']), true);
93 $tpl->setVariable('ARTICLE_EXCERPT', $line["content_preview"], true);
95 $content = sanitize($line["content"], false, $owner_uid,
96 $feed_site_url, false, $line["id"]);
99 $content = "<div style=\"$note_style\">Article note: " . $line['note'] . "</div>" .
101 $tpl->setVariable('ARTICLE_NOTE', htmlspecialchars($line['note']), true);
104 $tpl->setVariable('ARTICLE_CONTENT', $content, true);
106 $tpl->setVariable('ARTICLE_UPDATED_ATOM',
107 date('c', strtotime($line["updated"])), true);
108 $tpl->setVariable('ARTICLE_UPDATED_RFC822',
109 date(DATE_RFC822
, strtotime($line["updated"])), true);
111 $tpl->setVariable('ARTICLE_AUTHOR', htmlspecialchars($line['author']), true);
113 $tpl->setVariable('ARTICLE_SOURCE_LINK', htmlspecialchars($line['site_url'] ?
$line["site_url"] : get_self_url_prefix()), true);
114 $tpl->setVariable('ARTICLE_SOURCE_TITLE', htmlspecialchars($line['feed_title'] ?
$line['feed_title'] : $feed_title), true);
116 $tags = Article
::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 = Article
::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'] ?
$e['duration'] : 1;
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 $feed['self_url'] = get_self_url_prefix();
162 $feed['articles'] = array();
164 while ($line = $result->fetch()) {
166 $line["content_preview"] = sanitize(truncate_string(strip_tags($line["content_preview"]), 100, '...'));
168 foreach (PluginHost
::getInstance()->get_hooks(PluginHost
::HOOK_QUERY_HEADLINES
) as $p) {
169 $line = $p->hook_query_headlines($line, 100);
172 foreach (PluginHost
::getInstance()->get_hooks(PluginHost
::HOOK_ARTICLE_EXPORT_FEED
) as $p) {
173 $line = $p->hook_article_export_feed($line, $feed, $is_cat);
178 $article['id'] = $line['link'];
179 $article['link'] = $line['link'];
180 $article['title'] = $line['title'];
181 $article['excerpt'] = $line["content_preview"];
182 $article['content'] = sanitize($line["content"], false, $owner_uid, $feed_site_url, false, $line["id"]);
183 $article['updated'] = date('c', strtotime($line["updated"]));
185 if ($line['note']) $article['note'] = $line['note'];
186 if ($article['author']) $article['author'] = $line['author'];
188 $tags = Article
::get_article_tags($line["id"], $owner_uid);
190 if (count($tags) > 0) {
191 $article['tags'] = array();
193 foreach ($tags as $tag) {
194 array_push($article['tags'], $tag);
198 $enclosures = Article
::get_article_enclosures($line["id"]);
200 if (count($enclosures) > 0) {
201 $article['enclosures'] = array();
203 foreach ($enclosures as $e) {
204 $type = $e['content_type'];
205 $url = $e['content_url'];
206 $length = $e['duration'];
208 array_push($article['enclosures'], array("url" => $url, "type" => $type, "length" => $length));
212 array_push($feed['articles'], $article);
215 header("Content-Type: text/json; charset=utf-8");
216 print json_encode($feed);
219 header("Content-Type: text/plain; charset=utf-8");
220 print json_encode(array("error" => array("message" => "Unknown format")));
224 function getUnread() {
225 $login = $_REQUEST["login"];
226 $fresh = $_REQUEST["fresh"] == "1";
228 $sth = $this->pdo
->prepare("SELECT id FROM ttrss_users WHERE login = ?");
229 $sth->execute([$login]);
231 if ($row = $sth->fetch()) {
234 print Feeds
::getGlobalUnread($uid);
238 print Feeds
::getFeedArticles(-3, false, true, $uid);
242 print "-1;User not found";
246 function getProfiles() {
247 $login = $_REQUEST["login"];
249 $sth = $this->pdo
->prepare("SELECT ttrss_settings_profiles.* FROM ttrss_settings_profiles,ttrss_users
250 WHERE ttrss_users.id = ttrss_settings_profiles.owner_uid AND login = ? ORDER BY title");
251 $sth->execute([$login]);
253 print "<select dojoType='dijit.form.Select' style='width : 220px; margin : 0px' name='profile'>";
255 print "<option value='0'>" . __("Default profile") . "</option>";
257 while ($line = $sth->fetch()) {
259 $title = $line["title"];
261 print "<option value='$id'>$title</option>";
269 header("Location: index.php");
273 $uuid = $_REQUEST["key"];
275 $sth = $this->pdo
->prepare("SELECT ref_id, owner_uid FROM ttrss_user_entries WHERE
277 $sth->execute([$uuid]);
279 if ($row = $sth->fetch()) {
280 header("Content-Type: text/html");
282 $id = $row["ref_id"];
283 $owner_uid = $row["owner_uid"];
285 $article = Article
::format_article($id, false, true, $owner_uid);
287 print_r($article['content']);
290 print "Article not found.";
296 $feed = $_REQUEST["id"];
297 $key = $_REQUEST["key"];
298 $is_cat = sql_bool_to_bool($_REQUEST["is_cat"]);
299 $limit = (int)$_REQUEST["limit"];
300 $offset = (int)$_REQUEST["offset"];
302 $search = $_REQUEST["q"];
303 $view_mode = $_REQUEST["view-mode"];
304 $order = $_REQUEST["order"];
305 $start_ts = $_REQUEST["ts"];
307 $format = $_REQUEST['format'];
308 $orig_guid = sql_bool_to_bool($_REQUEST["orig_guid"]);
310 if (!$format) $format = 'atom';
312 if (SINGLE_USER_MODE
) {
313 authenticate_user("admin", null);
319 $sth = $this->pdo
->prepare("SELECT owner_uid FROM
320 ttrss_access_keys WHERE access_key = ? AND feed_id = ?");
321 $sth->execute([$key, $feed]);
323 if ($row = $sth->fetch())
324 $owner_id = $row["owner_uid"];
328 $this->generate_syndicated_feed($owner_id, $feed, $is_cat, $limit,
329 $offset, $search, $view_mode, $format, $order, $orig_guid, $start_ts);
331 header('HTTP/1.1 403 Forbidden');
335 function updateTask() {
336 PluginHost
::getInstance()->run_hooks(PluginHost
::HOOK_UPDATE_TASK
, "hook_update_task", false);
339 function housekeepingTask() {
340 PluginHost
::getInstance()->run_hooks(PluginHost
::HOOK_HOUSE_KEEPING
, "hook_house_keeping", false);
343 function globalUpdateFeeds() {
344 RPC
::updaterandomfeed_real($this->dbh
);
346 PluginHost
::getInstance()->run_hooks(PluginHost
::HOOK_UPDATE_TASK
, "hook_update_task", false);
349 function sharepopup() {
350 if (SINGLE_USER_MODE
) {
354 header('Content-Type: text/html; charset=utf-8');
355 print "<html><head><title>Tiny Tiny RSS</title>
356 <link rel=\"shortcut icon\" type=\"image/png\" href=\"images/favicon.png\">
357 <link rel=\"icon\" type=\"image/png\" sizes=\"72x72\" href=\"images/favicon-72px.png\">";
359 echo stylesheet_tag("css/utility.css");
360 echo stylesheet_tag("css/default.css");
361 echo javascript_tag("lib/prototype.js");
362 echo javascript_tag("lib/scriptaculous/scriptaculous.js?load=effects,controls");
363 print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
364 </head><body id='sharepopup'>";
366 $action = $_REQUEST["action"];
368 if ($_SESSION["uid"]) {
370 if ($action == 'share') {
372 $title = strip_tags($_REQUEST["title"]);
373 $url = strip_tags($_REQUEST["url"]);
374 $content = strip_tags($_REQUEST["content"]);
375 $labels = strip_tags($_REQUEST["labels"]);
377 Article
::create_published_article($title, $url, $content, $labels,
380 print "<script type='text/javascript'>";
381 print "window.close();";
385 $title = htmlspecialchars($_REQUEST["title"]);
386 $url = htmlspecialchars($_REQUEST["url"]);
390 <table height
='100%' width
='100%'><tr
><td colspan
='2'>
391 <h1
><?php
echo __("Share with Tiny Tiny RSS") ?
></h1
>
394 <form id
='share_form' name
='share_form'>
396 <input type
="hidden" name
="op" value
="sharepopup">
397 <input type
="hidden" name
="action" value
="share">
399 <tr
><td align
='right'><?php
echo __("Title:") ?
></td
>
400 <td width
='80%'><input name
='title' value
="<?php echo $title ?>"></td
></tr
>
401 <tr
><td align
='right'><?php
echo __("URL:") ?
></td
>
402 <td
><input name
='url' value
="<?php echo $url ?>"></td
></tr
>
403 <tr
><td align
='right'><?php
echo __("Content:") ?
></td
>
404 <td
><input name
='content' value
=""></td
></tr
>
405 <tr
><td align
='right'><?php
echo __("Labels:") ?
></td
>
406 <td
><input name
='labels' id
="labels_value"
407 placeholder
='Alpha, Beta, Gamma' value
="">
411 <div
class="autocomplete" id
="labels_choices"
412 style
="display : block"></div
></td
></tr
>
414 <script type
='text/javascript'>document
.forms
[0].title
.focus();</script
>
416 <script type
='text/javascript'>
417 new Ajax
.Autocompleter('labels_value', 'labels_choices',
418 "backend.php?op=rpc&method=completeLabels",
419 { tokens
: ',', paramName
: "search" });
423 <div style
='float : right' class='insensitive-small'>
424 <?php
echo __("Shared article will appear in the Published feed.") ?
>
426 <button type
="submit"><?php
echo __('Share') ?
></button
>
427 <button onclick
="return window.close()"><?php
echo __('Cancel') ?
></button
>
439 $return = urlencode($_SERVER["REQUEST_URI"])
442 <form action
="public.php?return=<?php echo $return ?>"
443 method
="POST" id
="loginForm" name
="loginForm">
445 <input type
="hidden" name
="op" value
="login">
447 <table height
='100%' width
='100%'><tr
><td colspan
='2'>
448 <h1
><?php
echo __("Not logged in") ?
></h1
></td
></tr
>
450 <tr
><td align
="right"><?php
echo __("Login:") ?
></td
>
451 <td align
="right"><input name
="login"
452 value
="<?php echo $_SESSION["fake_login
"] ?>"></td
></tr
>
453 <tr
><td align
="right"><?php
echo __("Password:") ?
></td
>
454 <td align
="right"><input type
="password" name
="password"
455 value
="<?php echo $_SESSION["fake_password
"] ?>"></td
></tr
>
457 <button type
="submit">
458 <?php
echo __('Log in') ?
></button
>
460 <button onclick
="return window.close()">
461 <?php
echo __('Cancel') ?
></button
>
471 if (!SINGLE_USER_MODE
) {
473 $login = $_POST["login"];
474 $password = $_POST["password"];
475 $remember_me = $_POST["remember_me"];
478 session_set_cookie_params(SESSION_COOKIE_LIFETIME
);
480 session_set_cookie_params(0);
485 if (authenticate_user($login, $password)) {
486 $_POST["password"] = "";
488 if (get_schema_version() >= 120) {
489 $_SESSION["language"] = get_pref("USER_LANGUAGE", $_SESSION["uid"]);
492 $_SESSION["ref_schema_version"] = get_schema_version(true);
493 $_SESSION["bw_limit"] = !!$_POST["bw_limit"];
495 if ($_POST["profile"]) {
497 $profile = $_POST["profile"];
499 $sth = $this->pdo
->prepare("SELECT id FROM ttrss_settings_profiles
500 WHERE id = ? AND owner_uid = ?");
501 $sth->execute([$profile, $_SESSION['uid']]);
504 $_SESSION["profile"] = $profile;
508 $_SESSION["login_error_msg"] = __("Incorrect username or password");
509 user_error("Failed login attempt for $login from {$_SERVER['REMOTE_ADDR']}", E_USER_WARNING
);
512 if ($_REQUEST['return']) {
513 header("Location: " . $_REQUEST['return']);
515 header("Location: " . get_self_url_prefix());
520 /* function subtest() {
521 header("Content-type: text/plain; charset=utf-8");
523 $url = $_REQUEST["url"];
528 print_r(get_feeds_from_html($url, fetch_file_contents($url)));
532 function subscribe() {
533 if (SINGLE_USER_MODE
) {
537 if ($_SESSION["uid"]) {
539 $feed_url = trim($_REQUEST["feed_url"]);
541 header('Content-Type: text/html; charset=utf-8');
544 <title>Tiny Tiny RSS</title>
545 <link rel=\"stylesheet\" type=\"text/css\" href=\"css/utility.css\">
546 <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
547 <link rel=\"shortcut icon\" type=\"image/png\" href=\"images/favicon.png\">
548 <link rel=\"icon\" type=\"image/png\" sizes=\"72x72\" href=\"images/favicon-72px.png\">
552 <img class=\"floatingLogo\" src=\"images/logo_small.png\"
553 alt=\"Tiny Tiny RSS\"/>
554 <h1>".__("Subscribe to feed...")."</h1><div class='content'>";
556 $rc = Feeds
::subscribe_to_feed($feed_url);
558 switch ($rc['code']) {
560 print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url));
563 print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url));
566 print_error(T_sprintf("Could not subscribe to <b>%s</b>.", $feed_url));
569 print_error(T_sprintf("No feeds found in <b>%s</b>.", $feed_url));
572 print_notice(__("Multiple feed URLs found."));
573 $feed_urls = $rc["feeds"];
576 print_error(T_sprintf("Could not subscribe to <b>%s</b>.<br>Can't download the Feed URL.", $feed_url));
582 print "<form action=\"public.php\">";
583 print "<input type=\"hidden\" name=\"op\" value=\"subscribe\">";
585 print "<select name=\"feed_url\">";
587 foreach ($feed_urls as $url => $name) {
588 $url = htmlspecialchars($url);
589 $name = htmlspecialchars($name);
591 print "<option value=\"$url\">$name</option>";
594 print "<input type=\"submit\" value=\"".__("Subscribe to selected feed").
600 $tp_uri = get_self_url_prefix() . "/prefs.php";
601 $tt_uri = get_self_url_prefix();
603 if ($rc['code'] <= 2){
604 $sth = $this->pdo
->prepare("SELECT id FROM ttrss_feeds WHERE
605 feed_url = ? AND owner_uid = ?");
606 $sth->execute([$feed_url, $_SESSION['uid']]);
607 $row = $sth->fetch();
609 $feed_id = $row["id"];
616 print "<form method=\"GET\" style='display: inline'
618 <input type=\"hidden\" name=\"tab\" value=\"feedConfig\">
619 <input type=\"hidden\" name=\"method\" value=\"editFeed\">
620 <input type=\"hidden\" name=\"methodparam\" value=\"$feed_id\">
621 <input type=\"submit\" value=\"".__("Edit subscription options")."\">
625 print "<form style='display: inline' method=\"GET\" action=\"$tt_uri\">
626 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
629 print "</div></body></html>";
637 header("Content-Type: text/plain");
638 print error_json(13);
641 function forgotpass() {
644 @$hash = $_REQUEST["hash"];
646 header('Content-Type: text/html; charset=utf-8');
647 print "<html><head><title>Tiny Tiny RSS</title>
648 <link rel=\"shortcut icon\" type=\"image/png\" href=\"images/favicon.png\">
649 <link rel=\"icon\" type=\"image/png\" sizes=\"72x72\" href=\"images/favicon-72px.png\">";
651 echo stylesheet_tag("css/utility.css");
652 echo javascript_tag("lib/prototype.js");
654 print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
655 </head><body id='forgotpass'>";
657 print '<div class="floatingLogo"><img src="images/logo_small.png"></div>';
658 print "<h1>".__("Password recovery")."</h1>";
659 print "<div class='content'>";
661 @$method = $_POST['method'];
664 $login = $_REQUEST["login"];
667 $sth = $this->pdo
->prepare("SELECT id, resetpass_token FROM ttrss_users
669 $sth->execute([$login]);
671 if ($row = $sth->fetch()) {
673 $resetpass_token_full = $row["resetpass_token"];
674 list($timestamp, $resetpass_token) = explode(":", $resetpass_token_full);
676 if ($timestamp && $resetpass_token &&
677 $timestamp >= time() - 15*60*60 &&
678 $resetpass_token == $hash) {
680 $sth = $this->pdo
->prepare("UPDATE ttrss_users SET resetpass_token = NULL
682 $sth->execute([$id]);
684 Pref_Users
::resetUserPassword($id, true);
686 print "<p>"."Completed."."</p>";
689 print_error("Some of the information provided is missing or incorrect.");
692 print_error("Some of the information provided is missing or incorrect.");
695 print_error("Some of the information provided is missing or incorrect.");
698 print "<form method=\"GET\" action=\"index.php\">
699 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
702 } else if (!$method) {
703 print_notice(__("You will need to provide valid account name and email. A password reset link will be sent to your email address."));
705 print "<form method='POST' action='public.php'>";
706 print "<input type='hidden' name='method' value='do'>";
707 print "<input type='hidden' name='op' value='forgotpass'>";
710 print "<label>".__("Login:")."</label>";
711 print "<input type='text' name='login' value='' required>";
715 print "<label>".__("Email:")."</label>";
716 print "<input type='email' name='email' value='' required>";
720 print "<label>".__("How much is two plus two:")."</label>";
721 print "<input type='text' name='test' value='' required>";
725 print "<button type='submit'>".__("Reset password")."</button>";
728 } else if ($method == 'do') {
730 $login = $_POST["login"];
731 $email = $_POST["email"];
732 $test = $_POST["test"];
734 if (($test != 4 && $test != 'four') ||
!$email ||
!$login) {
735 print_error(__('Some of the required form parameters are missing or incorrect.'));
737 print "<form method=\"GET\" action=\"public.php\">
738 <input type=\"hidden\" name=\"op\" value=\"forgotpass\">
739 <input type=\"submit\" value=\"".__("Go back")."\">
744 print_notice("Password reset instructions are being sent to your email address.");
746 $sth = $this->pdo
->prepare("SELECT id FROM ttrss_users
747 WHERE login = ? AND email = ?");
748 $sth->execute([$login, $email]);
750 if ($row = $sth->fetch()) {
754 $resetpass_token = sha1(get_random_bytes(128));
755 $resetpass_link = get_self_url_prefix() . "/public.php?op=forgotpass&hash=" . $resetpass_token .
756 "&login=" . urlencode($login);
758 require_once 'classes/ttrssmailer.php';
759 require_once "lib/MiniTemplator.class.php";
761 $tpl = new MiniTemplator
;
763 $tpl->readTemplateFromFile("templates/resetpass_link_template.txt");
765 $tpl->setVariable('LOGIN', $login);
766 $tpl->setVariable('RESETPASS_LINK', $resetpass_link);
768 $tpl->addBlock('message');
772 $tpl->generateOutputToString($message);
774 $mail = new ttrssMailer();
776 $rc = $mail->quickMail($email, $login,
777 __("[tt-rss] Password reset request"),
780 if (!$rc) print_error($mail->ErrorInfo
);
782 $resetpass_token_full = time() . ":" . $resetpass_token;
784 $sth = $this->pdo
->prepare("UPDATE ttrss_users
785 SET resetpass_token = ?
786 WHERE login = ? AND email = ?");
788 $sth->execute([$resetpass_token_full, $login, $email]);
790 //Pref_Users::resetUserPassword($id, false);
794 print "<p>"."Completed."."</p>";
796 print_error("User ID not found.");
799 print "<form method=\"GET\" action=\"index.php\">
800 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
804 print_error(__("Sorry, login and email combination not found."));
806 print "<form method=\"GET\" action=\"public.php\">
807 <input type=\"hidden\" name=\"op\" value=\"forgotpass\">
808 <input type=\"submit\" value=\"".__("Go back")."\">
822 function dbupdate() {
825 if (!SINGLE_USER_MODE
&& $_SESSION["access_level"] < 10) {
826 $_SESSION["login_error_msg"] = __("Your access level is insufficient to run this script.");
833 <title
>Database Updater
</title
>
834 <meta http
-equiv
="Content-Type" content
="text/html; charset=utf-8"/>
835 <link rel
="stylesheet" type
="text/css" href
="css/utility.css"/>
836 <link rel
=\"shortcut icon\" type
=\"image
/png\" href
=\"images
/favicon
.png\"
>
837 <link rel
=\"icon\" type
=\"image
/png\" sizes
=\"72x72\" href
=\"images
/favicon
-72px
.png\"
>
839 <style type
="text/css">
840 span
.ok
{ color
: #009000; font-weight : bold; }
841 span
.err
{ color
: #ff0000; font-weight : bold; }
844 <script type
='text/javascript'>
845 function confirmOP() {
846 return confirm("Update the database?");
850 <div
class="floatingLogo"><img src
="images/logo_small.png"></div
>
852 <h1
><?php
echo __("Database Updater") ?
></h1
>
854 <div
class="content">
857 @$op = $_REQUEST["subop"];
858 $updater = new DbUpdater(Db
::get(), DB_TYPE
, SCHEMA_VERSION
);
860 if ($op == "performupdate") {
861 if ($updater->isUpdateRequired()) {
863 print "<h2>Performing updates</h2>";
865 print "<h3>Updating to schema version " . SCHEMA_VERSION
. "</h3>";
869 for ($i = $updater->getSchemaVersion() +
1; $i <= SCHEMA_VERSION
; $i++
) {
870 print "<li>Performing update up to version $i...";
872 $result = $updater->performUpdateTo($i, true);
875 print "<span class='err'>FAILED!</span></li></ul>";
877 print_warning("One of the updates failed. Either retry the process or perform updates manually.");
878 print "<p><form method=\"GET\" action=\"index.php\">
879 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
884 print "<span class='ok'>OK!</span></li>";
890 print_notice("Your Tiny Tiny RSS database is now updated to the latest version.");
892 print "<p><form method=\"GET\" action=\"index.php\">
893 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
897 print "<h2>Your database is up to date.</h2>";
899 print "<p><form method=\"GET\" action=\"index.php\">
900 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
904 if ($updater->isUpdateRequired()) {
906 print "<h2>Database update required</h2>";
909 sprintf("Your Tiny Tiny RSS database needs update to the latest version: %d to %d.",
910 $updater->getSchemaVersion(), SCHEMA_VERSION
).
913 print_warning("Please backup your database before proceeding.");
915 print "<form method='POST'>
916 <input type='hidden' name='subop' value='performupdate'>
917 <input type='submit' onclick='return confirmOP()' value='".__("Perform updates")."'>
922 print_notice("Tiny Tiny RSS database is up to date.");
924 print "<p><form method=\"GET\" action=\"index.php\">
925 <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
938 function cached_url() {
939 @$hash = basename($_GET['hash']);
941 // we don't need an extension to find the file, hash is a complete URL
942 $hash = preg_replace("/\.[^\.]*$/", "", $hash);
946 $filename = CACHE_DIR
. '/images/' . $hash;
948 if (file_exists($filename)) {
949 header("Content-Disposition: inline; filename=\"$hash\"");
951 send_local_file($filename);
954 header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
955 echo "File not found.";
960 private function make_article_tag_uri($id, $timestamp) {
962 $timestamp = date("Y-m-d", strtotime($timestamp));
964 return "tag:" . parse_url(get_self_url_prefix(), PHP_URL_HOST
) . ",$timestamp:/$id";
967 // this should be used very carefully because this endpoint is exposed to unauthenticated users
968 // plugin data is not loaded because there's no user context and owner_uid/session may or may not be available
969 // in general, don't do anything user-related in here and do not modify $_SESSION
970 public function pluginhandler() {
971 $host = new PluginHost();
973 $plugin = basename($_REQUEST["plugin"]);
974 $method = $_REQUEST["pmethod"];
976 $host->load($plugin, PluginHost
::KIND_USER
, 0);
979 $pclass = $host->get_plugin($plugin);
982 if (method_exists($pclass, $method)) {
983 if ($pclass->is_public_method($method)) {
986 header("Content-Type: text/json");
990 header("Content-Type: text/json");
991 print error_json(13);
994 header("Content-Type: text/json");
995 print error_json(14);