]> git.wh0rd.org - tt-rss.git/blobdiff - backend.php
add persistent storage for toolbar view options, bump schema
[tt-rss.git] / backend.php
index 0437ce819fe696703406a889739c3a5bbf841b44..45c9780234416d78fe1264d7017c3df3af855d7c 100644 (file)
@@ -1,13 +1,9 @@
 <?php
+       error_reporting(E_ERROR | E_WARNING | E_PARSE);
+
        require_once "sessions.php";
        require_once "modules/backend-rpc.php";
-       
-       header("Cache-Control: no-cache, must-revalidate");
-       header("Cache-Control: no-cache, must-revalidate");
 
-       header("Pragma: no-cache");
-       header("Expires: -1");
-       
 /*     if ($_GET["debug"]) {
                define('DEFAULT_ERROR_LEVEL', E_ALL);
        } else {
@@ -16,9 +12,7 @@
        
        error_reporting(DEFAULT_ERROR_LEVEL); */
 
-       $op = $_REQUEST["op"];
-
-       define('SCHEMA_VERSION', 13);
+       define('SCHEMA_VERSION', 15);
 
        require_once "sanity_check.php";
        require_once "config.php";
        require_once "db-prefs.php";
        require_once "functions.php";
 
+       no_cache_incantation();
+       startup_gettext();
+
+       $script_started = getmicrotime();
+
+       $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); 
+
+       if (!$link) {
+               if (DB_TYPE == "mysql") {
+                       print mysql_error();
+               }
+               // PG seems to display its own errors just fine by default.             
+               return;
+       }
+
+       if (DB_TYPE == "pgsql") {
+               pg_query("set client_encoding = 'UTF-8'");
+               pg_set_client_encoding("UNICODE");
+       }
+
+       $op = $_REQUEST["op"];
+
        $print_exec_time = false;
 
        if ((!$op || $op == "rpc" || $op == "rss" || $op == "digestSend" ||
@@ -40,8 +56,9 @@
                header("Content-Type: application/xml");
                print_error_xml(7); exit;
        }
-
-       if (!$_SESSION["uid"] && $op != "globalUpdateFeeds" && $op != "rss" && $op != "getUnread") {
+       
+       if (!($_SESSION["uid"] && validate_session($link)) && $op != "globalUpdateFeeds" 
+                       && $op != "rss" && $op != "getUnread") {
 
                if ($op == "rpc") {
                        print_error_xml(6); die;
@@ -51,9 +68,9 @@
                                <p>Error: Not logged in.</p>
                                <script type=\"text/javascript\">
                                        if (parent.window != 'undefined') {
-                                               parent.window.location = \"login.php\";         
+                                               parent.window.location = \"tt-rss.php\";                
                                        } else {
-                                               window.location = \"login.php\";
+                                               window.location = \"tt-rss.php\";
                                        }
                                </script>
                        </body></html>
        }
 
        $purge_intervals = array(
-               0  => _("Use default"),
-               -1 => _("Never purge"),
-               5  => _("1 week old"),
-               14 => _("2 weeks old"),
-               31 => _("1 month old"),
-               60 => _("2 months old"),
-               90 => _("3 months old"));
+               0  => __("Use default"),
+               -1 => __("Never purge"),
+               5  => __("1 week old"),
+               14 => __("2 weeks old"),
+               31 => __("1 month old"),
+               60 => __("2 months old"),
+               90 => __("3 months old"));
 
        $update_intervals = array(
-               0   => _("Use default"),
-               -1  => _("Disable updates"),
-               30  => _("Each 30 minutes"),
-               60  => _("Hourly"),
-               240 => _("Each 4 hours"),
-               720 => _("Each 12 hours"),
-               1440 => _("Daily"),
-               10080 => _("Weekly"));
+               0   => __("Use default"),
+               -1  => __("Disable updates"),
+               30  => __("Each 30 minutes"),
+               60  => __("Hourly"),
+               240 => __("Each 4 hours"),
+               720 => __("Each 12 hours"),
+               1440 => __("Daily"),
+               10080 => __("Weekly"));
 
 
        $access_level_names = array(
-               0 => _("User"), 
-               10 => _("Administrator"));
+               0 => __("User"), 
+               10 => __("Administrator"));
 
        require_once "modules/pref-prefs.php";
        require_once "modules/popup-dialog.php";
        require_once "modules/pref-users.php";
        require_once "modules/pref-feed-browser.php"; 
 
-       $script_started = getmicrotime();
-
-       $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); 
-
-       if (!$link) {
-               if (DB_TYPE == "mysql") {
-                       print mysql_error();
-               }
-               // PG seems to display its own errors just fine by default.             
-               return;
-       }
-
-       if (DB_TYPE == "pgsql") {
-               pg_query("set client_encoding = 'utf-8'");
-       }
 
        if (!sanity_check($link)) { return; }
 
                        $entry_author = $line["author"];
 
                        if ($entry_author) {
-                               $entry_author = _(" - by ") . $entry_author;
+                               $entry_author = __(" - by ") . $entry_author;
                        }
 
                        $parsed_updated = date(get_pref($link, 'LONG_DATE_FORMAT'), 
 
                        if (!$entry_comments) $entry_comments = "&nbsp;"; # placeholder
 
-                       if (!$tags_str) $tags_str = '<span class="tagList">'._('no tags').'</span>';
+                       if (!$tags_str) $tags_str = '<span class="tagList">'.__('no tags').'</span>';
 
                        print "<div style='float : right'>$tags_str 
                                <a title=\"Edit tags for this article\" 
                        print "<div class=\"postContent\">";
                        
                        if (db_num_rows($tmp_result) > 0) {
-                               print "<div id=\"allEntryTags\">"._('Tags:')."$f_tags_str</div>";
+                               print "<div id=\"allEntryTags\">".__('Tags:')."$f_tags_str</div>";
                        }
 
                        if (get_pref($link, 'OPEN_LINKS_IN_NEW_WINDOW')) {
 
                if (!$offset) $offset = 0;
 
+               set_pref($link, "_DEFAULT_VIEW_MODE", $view_mode);
+               set_pref($link, "_DEFAULT_VIEW_LIMIT", $limit);
+
                if ($subop == "undefined") $subop = "";
 
                if ($subop == "CatchupSelected") {
                                "SELECT id FROM ttrss_feeds WHERE id = '$feed' LIMIT 1");
                
                        if (db_num_rows($result) == 0) {
-                               print "<div align='center'>"._('Feed not found.')."</div>";
+                               print "<div align='center'>".__('Feed not found.')."</div>";
                                return;
                        }
                }
                print "<div id=\"headlinesContainer\" $rtl_tag>";
 
                if (!$result) {
-                       print "<div align='center'>"._("Could not display feed (query failed). Please check label match syntax or local configuration.")."</div>";
+                       print "<div align='center'>".__("Could not display feed (query failed). Please check label match syntax or local configuration.")."</div>";
                        return;
                }
 
                print_headline_subtoolbar($link, $feed_site_url, $feed_title, false, 
-                       $rtl_content, $feed, $cat_view, $search, $match_on, $search_mode, $offset);
+                       $rtl_content, $feed, $cat_view, $search, $match_on, $search_mode, 
+                       $offset, $limit);
 
                print "<div id=\"headlinesInnerContainer\">";
 
 
 
                } else {
-                       print "<div class='whiteBox'>"._('No articles found.')."</div>";
+                       print "<div class='whiteBox'>".__('No articles found.')."</div>";
                }
 
                print "</div>";