]> git.wh0rd.org - tt-rss.git/blobdiff - classes/handler/public.php
add command-line db schema updater
[tt-rss.git] / classes / handler / public.php
index 84d6aa18ee368534828880212c8a8894c5790919..3d3d6727d8d7be97d56acac99e10196d2bf5b612 100644 (file)
@@ -12,24 +12,41 @@ class Handler_Public extends Handler {
                        "padding : 5px; border-style : dashed; border-color : #e7d796;".
                        "margin-bottom : 1em; color : #9a8c59;";
 
-               if (!$limit) $limit = 100;
+               if (!$limit) $limit = 60;
 
-               if (get_pref($this->link, "SORT_HEADLINES_BY_FEED_DATE", $owner_uid)) {
-                       $date_sort_field = "updated";
-               } else {
-                       $date_sort_field = "date_entered";
-               }
+               $date_sort_field = "date_entered DESC, updated DESC";
 
                if ($feed == -2)
-                       $date_sort_field = "last_published";
+                       $date_sort_field = "last_published DESC";
                else if ($feed == -1)
-                       $date_sort_field = "last_marked";
+                       $date_sort_field = "last_marked DESC";
+
+               $qfh_ret = queryFeedHeadlines($this->link, $feed,
+                       1, $view_mode, $is_cat, $search, $search_mode,
+                       $date_sort_field, $offset, $owner_uid,
+                       false, 0, false, true);
+
+               $result = $qfh_ret[0];
+
+               if (db_num_rows($result) != 0) {
+                       $ts = strtotime(db_fetch_result($result, 0, "date_entered"));
+
+                       if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) &&
+                                       strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $ts) {
+                     header('HTTP/1.0 304 Not Modified');
+                     return;
+                       }
+
+                       $last_modified = gmdate("D, d M Y H:i:s", $ts) . " GMT";
+                       header("Last-Modified: $last_modified", true);
+               }
 
                $qfh_ret = queryFeedHeadlines($this->link, $feed,
                        $limit, $view_mode, $is_cat, $search, $search_mode,
-                       "$date_sort_field DESC", $offset, $owner_uid,
+                       $date_sort_field, $offset, $owner_uid,
                        false, 0, false, true);
 
+
                $result = $qfh_ret[0];
                $feed_title = htmlspecialchars($qfh_ret[1]);
                $feed_site_url = $qfh_ret[2];
@@ -57,7 +74,8 @@ class Handler_Public extends Handler {
 
                        $tpl->setVariable('SELF_URL', htmlspecialchars(get_self_url_prefix()), true);
 
-                       while ($line = db_fetch_assoc($result)) {
+                       while ($line = db_fetch_assoc($result)) {
+
                                $tpl->setVariable('ARTICLE_ID', htmlspecialchars($line['link']), true);
                                $tpl->setVariable('ARTICLE_LINK', htmlspecialchars($line['link']), true);
                                $tpl->setVariable('ARTICLE_TITLE', htmlspecialchars($line['title']), true);
@@ -69,7 +87,8 @@ class Handler_Public extends Handler {
                                if ($line['note']) {
                                        $content = "<div style=\"$note_style\">Article note: " . $line['note'] . "</div>" .
                                                $content;
-}
+                                       $tpl->setVariable('ARTICLE_NOTE', htmlspecialchars($line['note']), true);
+                               }
 
                                $tpl->setVariable('ARTICLE_CONTENT', $content, true);
 
@@ -369,15 +388,13 @@ class Handler_Public extends Handler {
                }
 
                header('Content-Type: text/html; charset=utf-8');
-               print "<html>
-                               <head>
-                                       <title>Tiny Tiny RSS</title>
-                                       <link rel=\"stylesheet\" type=\"text/css\" href=\"utility.css\">
-                                       <script type=\"text/javascript\" src=\"lib/prototype.js\"></script>
-                                       <script type=\"text/javascript\" src=\"lib/scriptaculous/scriptaculous.js?load=effects,dragdrop,controls\"></script>
-                                       <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
-                               </head>
-                               <body id='sharepopup'>";
+               print "<html><head><title>Tiny Tiny RSS</title>";
+
+               print stylesheet_tag("utility.css");
+               print javascript_tag("lib/prototype.js");
+               print javascript_tag("lib/scriptaculous/scriptaculous.js?load=effects,dragdrop,controls");
+               print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
+                       </head><body id='sharepopup'>";
 
                $action = $_REQUEST["action"];
 
@@ -729,30 +746,24 @@ class Handler_Public extends Handler {
 
        function forgotpass() {
                header('Content-Type: text/html; charset=utf-8');
-               print "<html>
-                               <head>
-                                       <title>Tiny Tiny RSS</title>
-                                       <link rel=\"stylesheet\" type=\"text/css\" href=\"utility.css\">
-                                       <script type=\"text/javascript\" src=\"lib/prototype.js\"></script>
-                                       <script type=\"text/javascript\" src=\"lib/scriptaculous/scriptaculous.js?load=effects,dragdrop,controls\"></script>
-                                       <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
-                               </head>
-                               <body id='forgotpass'>";
+               print "<html><head><title>Tiny Tiny RSS</title>";
+
+               print stylesheet_tag("utility.css");
+               print javascript_tag("lib/prototype.js");
+
+               print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
+                       </head><body id='forgotpass'>";
 
                print '<div class="floatingLogo"><img src="images/logo_small.png"></div>';
-               print "<h1>".__("Reset password")."</h1>";
+               print "<h1>".__("Password recovery")."</h1>";
                print "<div class='content'>";
 
-               print "<p>".__("You will need to provide valid account name and email. New password will be sent on your email address.")."</p>";
-
                @$method = $_POST['method'];
 
                if (!$method) {
-                       $secretkey = uniqid();
-                       $_SESSION["secretkey"] = $secretkey;
+                       print_notice(__("You will need to provide valid account name and email. New password will be sent on your email address."));
 
                        print "<form method='POST' action='public.php'>";
-                       print "<input type='hidden' name='secretkey' value='$secretkey'>";
                        print "<input type='hidden' name='method' value='do'>";
                        print "<input type='hidden' name='op' value='forgotpass'>";
 
@@ -777,7 +788,6 @@ class Handler_Public extends Handler {
                        print "</form>";
                } else if ($method == 'do') {
 
-                       $secretkey = $_POST["secretkey"];
                        $login = db_escape_string($this->link, $_POST["login"]);
                        $email = db_escape_string($this->link, $_POST["email"]);
                        $test = db_escape_string($this->link, $_POST["test"]);
@@ -785,9 +795,12 @@ class Handler_Public extends Handler {
                        if (($test != 4 && $test != 'four') || !$email || !$login) {
                                print_error(__('Some of the required form parameters are missing or incorrect.'));
 
-                               print "<p><a href=\"public.php?op=forgotpass\">".__("Go back")."</a></p>";
+                               print "<form method=\"GET\" action=\"public.php\">
+                                       <input type=\"hidden\" name=\"op\" value=\"forgotpass\">
+                                       <input type=\"submit\" value=\"".__("Go back")."\">
+                                       </form>";
 
-                       } else if ($_SESSION["secretkey"] == $secretkey) {
+                       } else {
 
                                $result = db_query($this->link, "SELECT id FROM ttrss_users
                                        WHERE login = '$login' AND email = '$email'");
@@ -797,17 +810,23 @@ class Handler_Public extends Handler {
 
                                        Pref_Users::resetUserPassword($this->link, $id, false);
 
-                                       print "<p>".__("Completed.")."</p>";
+                                       print "<p>";
+
+                                       print "<p>"."Completed."."</p>";
+
+                                       print "<form method=\"GET\" action=\"index.php\">
+                                               <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
+                                               </form>";
 
                                } else {
                                        print_error(__("Sorry, login and email combination not found."));
-                                       print "<p><a href=\"public.php?op=forgotpass\">".__("Go back")."</a></p>";
-                               }
 
-                       } else {
-                               print_error(__("Form secret key incorrect. Please enable cookies and try again."));
-                               print "<p><a href=\"public.php?op=forgotpass\">".__("Go back")."</a></p>";
+                                       print "<form method=\"GET\" action=\"public.php\">
+                                               <input type=\"hidden\" name=\"op\" value=\"forgotpass\">
+                                               <input type=\"submit\" value=\"".__("Go back")."\">
+                                               </form>";
 
+                               }
                        }
 
                }
@@ -816,6 +835,15 @@ class Handler_Public extends Handler {
                print "</body>";
                print "</html>";
 
+       }
+
+       function dbupdate() {
+
+
+
+
+
+
        }
 
 }