예제 #1
0
파일: system.php 프로젝트: Verisor/tt-rss
 function index()
 {
     print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">";
     print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"" . __('Error Log') . "\">";
     if (LOG_DESTINATION == "sql") {
         $result = $this->dbh->query("SELECT errno, errstr, filename, lineno,\n\t\t\t\tcreated_at, login FROM ttrss_error_log\n\t\t\t\tLEFT JOIN ttrss_users ON (owner_uid = ttrss_users.id)\n\t\t\t\tORDER BY ttrss_error_log.id DESC\n\t\t\t\tLIMIT 100");
         print "<button dojoType=\"dijit.form.Button\"\n\t\t\t\tonclick=\"updateSystemList()\">" . __('Refresh') . "</button> ";
         print "&nbsp;<button dojoType=\"dijit.form.Button\"\n\t\t\t\tonclick=\"clearSqlLog()\">" . __('Clear log') . "</button> ";
         print "<p><table width=\"100%\" cellspacing=\"10\" class=\"prefErrorLog\">";
         print "<tr class=\"title\">\n\t\t\t\t<td width='5%'>" . __("Error") . "</td>\n\t\t\t\t<td>" . __("Filename") . "</td>\n\t\t\t\t<td>" . __("Message") . "</td>\n\t\t\t\t<td width='5%'>" . __("User") . "</td>\n\t\t\t\t<td width='5%'>" . __("Date") . "</td>\n\t\t\t\t</tr>";
         while ($line = $this->dbh->fetch_assoc($result)) {
             print "<tr class=\"errrow\">";
             foreach ($line as $k => $v) {
                 $line[$k] = htmlspecialchars($v);
             }
             print "<td class='errno'>" . Logger::$errornames[$line["errno"]] . " (" . $line["errno"] . ")</td>";
             print "<td class='filename'>" . $line["filename"] . ":" . $line["lineno"] . "</td>";
             print "<td class='errstr'>" . $line["errstr"] . "</td>";
             print "<td class='login'>" . $line["login"] . "</td>";
             print "<td class='timestamp'>" . make_local_datetime($line["created_at"], false) . "</td>";
             print "</tr>";
         }
         print "</table>";
     } else {
         print_notice("Please set LOG_DESTINATION to 'sql' in config.php to enable database logging.");
     }
     print "</div>";
     PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, "hook_prefs_tab", "prefSystem");
     print "</div>";
     #container
 }
예제 #2
0
 function getfeedtree()
 {
     $search = $_SESSION["prefs_feed_search"];
     if ($search) {
         $search_qpart = " AND LOWER(title) LIKE LOWER('%{$search}%')";
     }
     $root = array();
     $root['id'] = 'root';
     $root['name'] = __('Feeds');
     $root['items'] = array();
     $root['type'] = 'category';
     if (get_pref($this->link, 'ENABLE_FEED_CATS')) {
         $show_empty_cats = get_pref($this->link, '_PREFS_SHOW_EMPTY_CATS');
         $result = db_query($this->link, "SELECT id, title FROM ttrss_feed_categories\n\t\t\t\tWHERE owner_uid = " . $_SESSION["uid"] . " ORDER BY order_id, title");
         while ($line = db_fetch_assoc($result)) {
             $cat = array();
             $cat['id'] = 'CAT:' . $line['id'];
             $cat['bare_id'] = $feed_id;
             $cat['name'] = $line['title'];
             $cat['items'] = array();
             $cat['checkbox'] = false;
             $cat['type'] = 'category';
             $feed_result = db_query($this->link, "SELECT id, title, last_error,\n\t\t\t\t\t" . SUBSTRING_FOR_DATE . "(last_updated,1,19) AS last_updated\n\t\t\t\t\tFROM ttrss_feeds\n\t\t\t\t\tWHERE cat_id = '" . $line['id'] . "' AND owner_uid = " . $_SESSION["uid"] . "{$search_qpart} ORDER BY order_id, title");
             while ($feed_line = db_fetch_assoc($feed_result)) {
                 $feed = array();
                 $feed['id'] = 'FEED:' . $feed_line['id'];
                 $feed['bare_id'] = $feed_line['id'];
                 $feed['name'] = $feed_line['title'];
                 $feed['checkbox'] = false;
                 $feed['error'] = $feed_line['last_error'];
                 $feed['icon'] = getFeedIcon($feed_line['id']);
                 $feed['param'] = make_local_datetime($this->link, $feed_line['last_updated'], true);
                 array_push($cat['items'], $feed);
             }
             $cat['param'] = T_sprintf('(%d feeds)', count($cat['items']));
             if (count($cat['items']) > 0 || $show_empty_cats) {
                 array_push($root['items'], $cat);
             }
             $root['param'] += count($cat['items']);
         }
         /* Uncategorized is a special case */
         $cat = array();
         $cat['id'] = 'CAT:0';
         $cat['bare_id'] = 0;
         $cat['name'] = __("Uncategorized");
         $cat['items'] = array();
         $cat['type'] = 'category';
         $cat['checkbox'] = false;
         $feed_result = db_query($this->link, "SELECT id, title,last_error,\n\t\t\t\t" . SUBSTRING_FOR_DATE . "(last_updated,1,19) AS last_updated\n\t\t\t\tFROM ttrss_feeds\n\t\t\t\tWHERE cat_id IS NULL AND owner_uid = " . $_SESSION["uid"] . "{$search_qpart} ORDER BY order_id, title");
         while ($feed_line = db_fetch_assoc($feed_result)) {
             $feed = array();
             $feed['id'] = 'FEED:' . $feed_line['id'];
             $feed['bare_id'] = $feed_line['id'];
             $feed['name'] = $feed_line['title'];
             $feed['checkbox'] = false;
             $feed['error'] = $feed_line['last_error'];
             $feed['icon'] = getFeedIcon($feed_line['id']);
             $feed['param'] = make_local_datetime($this->link, $feed_line['last_updated'], true);
             array_push($cat['items'], $feed);
         }
         $cat['param'] = T_sprintf('(%d feeds)', count($cat['items']));
         if (count($cat['items']) > 0 || $show_empty_cats) {
             array_push($root['items'], $cat);
         }
         $root['param'] += count($cat['items']);
         $root['param'] = T_sprintf('(%d feeds)', $root['param']);
     } else {
         $feed_result = db_query($this->link, "SELECT id, title, last_error,\n\t\t\t\t" . SUBSTRING_FOR_DATE . "(last_updated,1,19) AS last_updated\n\t\t\t\tFROM ttrss_feeds\n\t\t\t\tWHERE owner_uid = " . $_SESSION["uid"] . "{$search_qpart} ORDER BY order_id, title");
         while ($feed_line = db_fetch_assoc($feed_result)) {
             $feed = array();
             $feed['id'] = 'FEED:' . $feed_line['id'];
             $feed['bare_id'] = $feed_line['id'];
             $feed['name'] = $feed_line['title'];
             $feed['checkbox'] = false;
             $feed['error'] = $feed_line['last_error'];
             $feed['icon'] = getFeedIcon($feed_line['id']);
             $feed['param'] = make_local_datetime($this->link, $feed_line['last_updated'], true);
             array_push($root['items'], $feed);
         }
         $root['param'] = T_sprintf('(%d feeds)', count($root['items']));
     }
     $fl = array();
     $fl['identifier'] = 'id';
     $fl['label'] = 'name';
     $fl['items'] = array($root);
     print json_encode($fl);
     return;
 }
예제 #3
0
 function index()
 {
     global $access_level_names;
     print "<div id=\"pref-user-wrap\" dojoType=\"dijit.layout.BorderContainer\" gutters=\"false\">";
     print "<div id=\"pref-user-header\" dojoType=\"dijit.layout.ContentPane\" region=\"top\">";
     print "<div id=\"pref-user-toolbar\" dojoType=\"dijit.Toolbar\">";
     $user_search = $this->dbh->escape_string($_REQUEST["search"]);
     if (array_key_exists("search", $_REQUEST)) {
         $_SESSION["prefs_user_search"] = $user_search;
     } else {
         $user_search = $_SESSION["prefs_user_search"];
     }
     print "<div style='float : right; padding-right : 4px;'>\n\t\t\t\t<input dojoType=\"dijit.form.TextBox\" id=\"user_search\" size=\"20\" type=\"search\"\n\t\t\t\t\tvalue=\"{$user_search}\">\n\t\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"updateUsersList()\">" . __('Search') . "</button>\n\t\t\t\t</div>";
     $sort = $this->dbh->escape_string($_REQUEST["sort"]);
     if (!$sort || $sort == "undefined") {
         $sort = "login";
     }
     print "<div dojoType=\"dijit.form.DropDownButton\">" . "<span>" . __('Select') . "</span>";
     print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
     print "<div onclick=\"selectTableRows('prefUserList', 'all')\"\n\t\t\t\tdojoType=\"dijit.MenuItem\">" . __('All') . "</div>";
     print "<div onclick=\"selectTableRows('prefUserList', 'none')\"\n\t\t\t\tdojoType=\"dijit.MenuItem\">" . __('None') . "</div>";
     print "</div></div>";
     print "<button dojoType=\"dijit.form.Button\" onclick=\"addUser()\">" . __('Create user') . "</button>";
     print "\n\t\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"selectedUserDetails()\">" . __('Details') . "</button dojoType=\"dijit.form.Button\">\n\t\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"editSelectedUser()\">" . __('Edit') . "</button dojoType=\"dijit.form.Button\">\n\t\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"removeSelectedUsers()\">" . __('Remove') . "</button dojoType=\"dijit.form.Button\">\n\t\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"resetSelectedUserPass()\">" . __('Reset password') . "</button dojoType=\"dijit.form.Button\">";
     PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "hook_prefs_tab_section", "prefUsersToolbar");
     print "</div>";
     #toolbar
     print "</div>";
     #pane
     print "<div id=\"pref-user-content\" dojoType=\"dijit.layout.ContentPane\" region=\"center\">";
     print "<div id=\"sticky-status-msg\"></div>";
     if ($user_search) {
         $user_search = explode(" ", $user_search);
         $tokens = array();
         foreach ($user_search as $token) {
             $token = trim($token);
             array_push($tokens, "(UPPER(login) LIKE UPPER('%{$token}%'))");
         }
         $user_search_query = "(" . join($tokens, " AND ") . ") AND ";
     } else {
         $user_search_query = "";
     }
     $result = $this->dbh->query("SELECT\n\t\t\t\t\tid,login,access_level,email,\n\t\t\t\t\t" . SUBSTRING_FOR_DATE . "(last_login,1,16) as last_login,\n\t\t\t\t\t" . SUBSTRING_FOR_DATE . "(created,1,16) as created\n\t\t\t\tFROM\n\t\t\t\t\tttrss_users\n\t\t\t\tWHERE\n\t\t\t\t\t{$user_search_query}\n\t\t\t\t\tid > 0\n\t\t\t\tORDER BY {$sort}");
     if ($this->dbh->num_rows($result) > 0) {
         print "<p><table width=\"100%\" cellspacing=\"0\"\n\t\t\t\tclass=\"prefUserList\" id=\"prefUserList\">";
         print "<tr class=\"title\">\n\t\t\t\t\t\t<td align='center' width=\"5%\">&nbsp;</td>\n\t\t\t\t\t\t<td width='30%'><a href=\"#\" onclick=\"updateUsersList('login')\">" . __('Login') . "</a></td>\n\t\t\t\t\t\t<td width='30%'><a href=\"#\" onclick=\"updateUsersList('access_level')\">" . __('Access Level') . "</a></td>\n\t\t\t\t\t\t<td width='20%'><a href=\"#\" onclick=\"updateUsersList('created')\">" . __('Registered') . "</a></td>\n\t\t\t\t\t\t<td width='20%'><a href=\"#\" onclick=\"updateUsersList('last_login')\">" . __('Last login') . "</a></td></tr>";
         $lnum = 0;
         while ($line = $this->dbh->fetch_assoc($result)) {
             $uid = $line["id"];
             print "<tr id=\"UMRR-{$uid}\">";
             $line["login"] = htmlspecialchars($line["login"]);
             $line["created"] = make_local_datetime($line["created"], false);
             $line["last_login"] = make_local_datetime($line["last_login"], false);
             print "<td align='center'><input onclick='toggleSelectRow2(this);'\n\t\t\t\t\tdojoType=\"dijit.form.CheckBox\" type=\"checkbox\"\n\t\t\t\t\tid=\"UMCHK-{$uid}\"></td>";
             $onclick = "onclick='editUser({$uid}, event)' title='" . __('Click to edit') . "'";
             print "<td {$onclick}><img src='images/user.png' class='markedPic' alt=''> " . $line["login"] . "</td>";
             if (!$line["email"]) {
                 $line["email"] = "&nbsp;";
             }
             print "<td {$onclick}>" . $access_level_names[$line["access_level"]] . "</td>";
             print "<td {$onclick}>" . $line["created"] . "</td>";
             print "<td {$onclick}>" . $line["last_login"] . "</td>";
             print "</tr>";
             ++$lnum;
         }
         print "</table>";
     } else {
         print "<p>";
         if (!$user_search) {
             print_warning(__('No users defined.'));
         } else {
             print_warning(__('No matching users found.'));
         }
         print "</p>";
     }
     print "</div>";
     #pane
     PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, "hook_prefs_tab", "prefUsers");
     print "</div>";
     #container
 }
예제 #4
0
 private function generate_dashboard_feed()
 {
     $reply = array();
     $reply['headlines']['id'] = -5;
     $reply['headlines']['is_cat'] = false;
     $reply['headlines']['toolbar'] = '';
     $reply['headlines']['content'] = "<div class='whiteBox'>" . __('No feed selected.');
     $reply['headlines']['content'] .= "<p><span class=\"insensitive\">";
     $result = $this->dbh->query("SELECT " . SUBSTRING_FOR_DATE . "(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds\n\t\t\tWHERE owner_uid = " . $_SESSION['uid']);
     $last_updated = $this->dbh->fetch_result($result, 0, "last_updated");
     $last_updated = make_local_datetime($last_updated, false);
     $reply['headlines']['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated);
     $result = $this->dbh->query("SELECT COUNT(id) AS num_errors\n\t\t\tFROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION["uid"]);
     $num_errors = $this->dbh->fetch_result($result, 0, "num_errors");
     if ($num_errors > 0) {
         $reply['headlines']['content'] .= "<br/>";
         $reply['headlines']['content'] .= "<a class=\"insensitive\" href=\"#\" onclick=\"showFeedsWithErrors()\">" . __('Some feeds have update errors (click for details)') . "</a>";
     }
     $reply['headlines']['content'] .= "</span></p>";
     $reply['headlines-info'] = array("count" => 0, "vgroup_last_feed" => '', "unread" => 0, "disable_cache" => true);
     return $reply;
 }
예제 #5
0
function module_pref_users($link)
{
    global $access_level_names;
    if (!SINGLE_USER_MODE && $_SESSION["access_level"] < 10) {
        print __("Your access level is insufficient to open this tab.");
        return;
    }
    $subop = $_REQUEST["subop"];
    if ($subop == "user-details") {
        header("Content-Type: text/xml");
        print "<dlg id=\"{$subop}\">";
        $uid = sprintf("%d", $_REQUEST["id"]);
        print "<title>" . __('User details') . "</title>";
        print "<content><![CDATA[";
        $result = db_query($link, "SELECT login,\n\t\t\t\t" . SUBSTRING_FOR_DATE . "(last_login,1,16) AS last_login,\n\t\t\t\taccess_level,\n\t\t\t\t(SELECT COUNT(int_id) FROM ttrss_user_entries\n\t\t\t\t\tWHERE owner_uid = id) AS stored_articles,\n\t\t\t\t" . SUBSTRING_FOR_DATE . "(created,1,16) AS created\n\t\t\t\tFROM ttrss_users\n\t\t\t\tWHERE id = '{$uid}'");
        if (db_num_rows($result) == 0) {
            print "<h1>" . __('User not found') . "</h1>";
            return;
        }
        // print "<h1>User Details</h1>";
        $login = db_fetch_result($result, 0, "login");
        print "<table width='100%'>";
        $last_login = make_local_datetime($link, db_fetch_result($result, 0, "last_login"), true);
        $created = make_local_datetime($link, db_fetch_result($result, 0, "created"), true);
        $access_level = db_fetch_result($result, 0, "access_level");
        $stored_articles = db_fetch_result($result, 0, "stored_articles");
        print "<tr><td>" . __('Registered') . "</td><td>{$created}</td></tr>";
        print "<tr><td>" . __('Last logged in') . "</td><td>{$last_login}</td></tr>";
        $result = db_query($link, "SELECT COUNT(id) as num_feeds FROM ttrss_feeds\n\t\t\t\tWHERE owner_uid = '{$uid}'");
        $num_feeds = db_fetch_result($result, 0, "num_feeds");
        print "<tr><td>" . __('Subscribed feeds count') . "</td><td>{$num_feeds}</td></tr>";
        print "</table>";
        print "<h1>" . __('Subscribed feeds') . "</h1>";
        $result = db_query($link, "SELECT id,title,site_url FROM ttrss_feeds\n\t\t\t\tWHERE owner_uid = '{$uid}' ORDER BY title");
        print "<ul class=\"userFeedList\">";
        $row_class = "odd";
        while ($line = db_fetch_assoc($result)) {
            $icon_file = ICONS_URL . "/" . $line["id"] . ".ico";
            if (file_exists($icon_file) && filesize($icon_file) > 0) {
                $feed_icon = "<img class=\"tinyFeedIcon\" src=\"{$icon_file}\">";
            } else {
                $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">";
            }
            print "<li class=\"{$row_class}\">{$feed_icon}&nbsp;<a href=\"" . $line["site_url"] . "\">" . $line["title"] . "</a></li>";
            $row_class = toggleEvenOdd($row_class);
        }
        if (db_num_rows($result) < $num_feeds) {
            // FIXME - add link to show ALL subscribed feeds here somewhere
            print "<li><img\n\t\t\t\t\tclass=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">&nbsp;...</li>";
        }
        print "</ul>";
        print "<div align='center'>\n\t\t\t\t<button onclick=\"closeInfoBox()\">" . __("Close this window") . "</button></div>";
        print "]]></content></dlg>";
        return;
    }
    if ($subop == "edit") {
        header("Content-Type: text/xml");
        $id = db_escape_string($_REQUEST["id"]);
        print "<dlg id=\"{$subop}\">";
        print "<title>" . __('User Editor') . "</title>";
        print "<content><![CDATA[";
        print "<form id=\"user_edit_form\" onsubmit='return false'>";
        print "<input type=\"hidden\" name=\"id\" value=\"{$id}\">";
        print "<input type=\"hidden\" name=\"op\" value=\"pref-users\">";
        print "<input type=\"hidden\" name=\"subop\" value=\"editSave\">";
        $result = db_query($link, "SELECT * FROM ttrss_users WHERE id = '{$id}'");
        $login = db_fetch_result($result, 0, "login");
        $access_level = db_fetch_result($result, 0, "access_level");
        $email = db_fetch_result($result, 0, "email");
        $sel_disabled = $id == $_SESSION["uid"] ? "disabled" : "";
        print "<div class=\"dlgSec\">" . __("User") . "</div>";
        print "<div class=\"dlgSecCont\">";
        if ($sel_disabled) {
            print "<input type=\"hidden\" name=\"login\" value=\"{$login}\">";
            print "<input size=\"30\" style=\"font-size : 16px\"\n\t\t\t\t\tonkeypress=\"return filterCR(event, userEditSave)\" {$sel_disabled}\n\t\t\t\t\tvalue=\"{$login}\">";
        } else {
            print "<input size=\"30\" style=\"font-size : 16px\"\n\t\t\t\t\tonkeypress=\"return filterCR(event, userEditSave)\" {$sel_disabled}\n\t\t\t\t\tname=\"login\" value=\"{$login}\">";
        }
        print "</div>";
        print "<div class=\"dlgSec\">" . __("Authentication") . "</div>";
        print "<div class=\"dlgSecCont\">";
        print __('Access level: ') . " ";
        if (!$sel_disabled) {
            print_select_hash("access_level", $access_level, $access_level_names, $sel_disabled);
        } else {
            print_select_hash("", $access_level, $access_level_names, $sel_disabled);
            print "<input type=\"hidden\" name=\"access_level\" value=\"{$access_level}\">";
        }
        print "<br/>";
        print __('Change password to') . " <input size=\"20\" onkeypress=\"return filterCR(event, userEditSave)\"\n\t\t\t\tname=\"password\">";
        print "</div>";
        print "<div class=\"dlgSec\">" . __("Options") . "</div>";
        print "<div class=\"dlgSecCont\">";
        print __('E-mail: ') . " <input size=\"30\" name=\"email\" onkeypress=\"return filterCR(event, userEditSave)\"\n\t\t\t\tvalue=\"{$email}\">";
        print "</div>";
        print "</table>";
        print "</form>";
        print "<div class=\"dlgButtons\">\n\t\t\t\t<button onclick=\"return userEditSave()\">" . __('Save') . "</button>\n\t\t\t\t<button onclick=\"return userEditCancel()\">" . __('Cancel') . "</button></div>";
        print "]]></content></dlg>";
        return;
    }
    if ($subop == "editSave") {
        if ($_SESSION["access_level"] >= 10) {
            $login = db_escape_string(trim($_REQUEST["login"]));
            $uid = db_escape_string($_REQUEST["id"]);
            $access_level = (int) $_REQUEST["access_level"];
            $email = db_escape_string(trim($_REQUEST["email"]));
            $password = db_escape_string(trim($_REQUEST["password"]));
            if ($password) {
                $pwd_hash = encrypt_password($password, $login);
                $pass_query_part = "pwd_hash = '{$pwd_hash}', ";
                $status_msg = format_notice(T_sprintf('Changed password of user <b>%s</b>.', $login));
            } else {
                $pass_query_part = "";
            }
            db_query($link, "UPDATE ttrss_users SET {$pass_query_part} login = '******',\n\t\t\t\t\taccess_level = '{$access_level}', email = '{$email}' WHERE id = '{$uid}'");
        }
    } else {
        if ($subop == "remove") {
            if ($_SESSION["access_level"] >= 10) {
                $ids = split(",", db_escape_string($_REQUEST["ids"]));
                foreach ($ids as $id) {
                    if ($id != $_SESSION["uid"] && $id != 1) {
                        db_query($link, "DELETE FROM ttrss_tags WHERE owner_uid = '{$id}'");
                        db_query($link, "DELETE FROM ttrss_feeds WHERE owner_uid = '{$id}'");
                        db_query($link, "DELETE FROM ttrss_users WHERE id = '{$id}'");
                    }
                }
            }
        } else {
            if ($subop == "add") {
                if ($_SESSION["access_level"] >= 10) {
                    $login = db_escape_string(trim($_REQUEST["login"]));
                    $tmp_user_pwd = make_password(8);
                    $pwd_hash = encrypt_password($tmp_user_pwd, $login);
                    $result = db_query($link, "SELECT id FROM ttrss_users WHERE\n\t\t\t\t\tlogin = '******'");
                    if (db_num_rows($result) == 0) {
                        db_query($link, "INSERT INTO ttrss_users\n\t\t\t\t\t\t(login,pwd_hash,access_level,last_login,created)\n\t\t\t\t\t\tVALUES ('{$login}', '{$pwd_hash}', 0, null, NOW())");
                        $result = db_query($link, "SELECT id FROM ttrss_users WHERE\n\t\t\t\t\t\tlogin = '******' AND pwd_hash = '{$pwd_hash}'");
                        if (db_num_rows($result) == 1) {
                            $new_uid = db_fetch_result($result, 0, "id");
                            $status_msg = format_notice(T_sprintf("Added user <b>%s</b> with password <b>%s</b>", $login, $tmp_user_pwd));
                            initialize_user($link, $new_uid);
                        } else {
                            $status_msg = format_warning(T_sprintf("Could not create user <b>%s</b>", $login));
                        }
                    } else {
                        $status_msg = format_warning(T_sprintf("User <b>%s</b> already exists.", $login));
                    }
                }
            } else {
                if ($subop == "resetPass") {
                    if ($_SESSION["access_level"] >= 10) {
                        $uid = db_escape_string($_REQUEST["id"]);
                        $result = db_query($link, "SELECT login,email\n\t\t\t\t\tFROM ttrss_users WHERE id = '{$uid}'");
                        $login = db_fetch_result($result, 0, "login");
                        $email = db_fetch_result($result, 0, "email");
                        $tmp_user_pwd = make_password(8);
                        $pwd_hash = encrypt_password($tmp_user_pwd, $login);
                        db_query($link, "UPDATE ttrss_users SET pwd_hash = '{$pwd_hash}'\n\t\t\t\t\tWHERE id = '{$uid}'");
                        $status_msg = format_notice(T_sprintf("Changed password of user <b>%s</b>\n\t\t\t\t\t to <b>%s</b>", $login, $tmp_user_pwd));
                        if ($email) {
                            $status_msg += format_notice(T_sprintf("Notifying <b>%s</b>.", $email));
                            require_once "lib/MiniTemplator.class.php";
                            $tpl = new MiniTemplator();
                            $tpl->readTemplateFromFile("templates/resetpass_template.txt");
                            $tpl->setVariable('LOGIN', $login);
                            $tpl->setVariable('NEWPASS', $tmp_user_pwd);
                            $tpl->addBlock('message');
                            $message = "";
                            $tpl->generateOutputToString($message);
                            $mail = new PHPMailer();
                            $mail->PluginDir = "lib/phpmailer/";
                            $mail->SetLanguage("en", "lib/phpmailer/language/");
                            $mail->CharSet = "UTF-8";
                            $mail->From = DIGEST_FROM_ADDRESS;
                            $mail->FromName = DIGEST_FROM_NAME;
                            $mail->AddAddress($email, $login);
                            if (DIGEST_SMTP_HOST) {
                                $mail->Host = DIGEST_SMTP_HOST;
                                $mail->Mailer = "smtp";
                                $mail->SMTPAuth = DIGEST_SMTP_LOGIN != '';
                                $mail->Username = DIGEST_SMTP_LOGIN;
                                $mail->Password = DIGEST_SMTP_PASSWORD;
                            }
                            $mail->IsHTML(false);
                            $mail->Subject = __("[tt-rss] Password change notification");
                            $mail->Body = $message;
                            $rc = $mail->Send();
                            if (!$rc) {
                                print_error($mail->ErrorInfo);
                            }
                            /*					mail("$login <$email>", "Password reset notification",
                            						"Hi, $login.\n".
                            						"\n".
                            						"Your password for this TT-RSS installation was reset by".
                            							" an administrator.\n".
                            						"\n".
                            						"Your new password is $tmp_user_pwd, please remember".
                            							" it for later reference.\n".
                            						"\n".
                            						"Sincerely, TT-RSS Mail Daemon.", "From: " . MAIL_FROM); */
                        }
                        print "</div>";
                    }
                }
            }
        }
    }
    print "<div id=\"pref-user-wrap\" dojoType=\"dijit.layout.BorderContainer\" gutters=\"false\">";
    print "<div id=\"pref-user-header\" dojoType=\"dijit.layout.ContentPane\" region=\"top\">";
    print "<div id=\"pref-user-toolbar\" dojoType=\"dijit.Toolbar\">";
    $user_search = db_escape_string($_REQUEST["search"]);
    if (array_key_exists("search", $_REQUEST)) {
        $_SESSION["prefs_user_search"] = $user_search;
    } else {
        $user_search = $_SESSION["prefs_user_search"];
    }
    print "<div style='float : right; padding-right : 4px;'>\n\t\t\t<input dojoType=\"dijit.form.TextBox\" id=\"user_search\" size=\"20\" type=\"search\"\n\t\t\t\tvalue=\"{$user_search}\">\n\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"javascript:updateUsersList()\">" . __('Search') . "</button>\n\t\t\t</div>";
    $sort = db_escape_string($_REQUEST["sort"]);
    if (!$sort || $sort == "undefined") {
        $sort = "login";
    }
    print "<div dojoType=\"dijit.form.DropDownButton\">" . "<span>" . __('Select') . "</span>";
    print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
    print "<div onclick=\"selectTableRows('prefUserList', 'all')\"\n\t\t\tdojoType=\"dijit.MenuItem\">" . __('All') . "</div>";
    print "<div onclick=\"selectTableRows('prefUserList', 'none')\"\n\t\t\tdojoType=\"dijit.MenuItem\">" . __('None') . "</div>";
    print "</div></div>";
    print "<button dojoType=\"dijit.form.Button\" onclick=\"javascript:addUser()\">" . __('Create user') . "</button>";
    print "\n\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"javascript:selectedUserDetails()\">" . __('Details') . "</button dojoType=\"dijit.form.Button\">\n\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"javascript:editSelectedUser()\">" . __('Edit') . "</button dojoType=\"dijit.form.Button\">\n\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"javascript:removeSelectedUsers()\">" . __('Remove') . "</button dojoType=\"dijit.form.Button\">\n\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"javascript:resetSelectedUserPass()\">" . __('Reset password') . "</button dojoType=\"dijit.form.Button\">";
    print "</div>";
    #toolbar
    print "</div>";
    #pane
    print "<div id=\"pref-user-content\" dojoType=\"dijit.layout.ContentPane\" region=\"center\">";
    print "<p>{$status_msg}";
    if ($user_search) {
        $user_search = split(" ", $user_search);
        $tokens = array();
        foreach ($user_search as $token) {
            $token = trim($token);
            array_push($tokens, "(UPPER(login) LIKE UPPER('%{$token}%'))");
        }
        $user_search_query = "(" . join($tokens, " AND ") . ") AND ";
    } else {
        $user_search_query = "";
    }
    $result = db_query($link, "SELECT\n\t\t\t\tid,login,access_level,email,\n\t\t\t\t" . SUBSTRING_FOR_DATE . "(last_login,1,16) as last_login,\n\t\t\t\t" . SUBSTRING_FOR_DATE . "(created,1,16) as created\n\t\t\tFROM\n\t\t\t\tttrss_users\n\t\t\tWHERE\n\t\t\t\t{$user_search_query}\n\t\t\t\tid > 0\n\t\t\tORDER BY {$sort}");
    if (db_num_rows($result) > 0) {
        print "<p><table width=\"100%\" cellspacing=\"0\"\n\t\t\tclass=\"prefUserList\" id=\"prefUserList\">";
        print "<tr class=\"title\">\n\t\t\t\t\t<td align='center' width=\"5%\">&nbsp;</td>\n\t\t\t\t\t<td width=''><a href=\"#\" onclick=\"updateUsersList('login')\">" . __('Login') . "</a></td>\n\t\t\t\t\t<td width='20%'><a href=\"#\" onclick=\"updateUsersList('access_level')\">" . __('Access Level') . "</a></td>\n\t\t\t\t\t<td width='20%'><a href=\"#\" onclick=\"updateUsersList('created')\">" . __('Registered') . "</a></td>\n\t\t\t\t\t<td width='20%'><a href=\"#\" onclick=\"updateUsersList('last_login')\">" . __('Last login') . "</a></td></tr>";
        $lnum = 0;
        while ($line = db_fetch_assoc($result)) {
            $class = $lnum % 2 ? "even" : "odd";
            $uid = $line["id"];
            $edit_uid = $_REQUEST["id"];
            if ($subop == "edit" && $uid != $edit_uid) {
                $class .= " Grayed";
                $this_row_id = "";
            } else {
                $this_row_id = "id=\"UMRR-{$uid}\"";
            }
            print "<tr class=\"{$class}\" {$this_row_id}>";
            $line["login"] = htmlspecialchars($line["login"]);
            $line["created"] = make_local_datetime($link, $line["created"], false);
            $line["last_login"] = make_local_datetime($link, $line["last_login"], false);
            print "<td align='center'><input onclick='toggleSelectRow(this);'\n\t\t\t\ttype=\"checkbox\" id=\"UMCHK-{$uid}\"></td>";
            $onclick = "onclick='editUser({$uid}, event)' title='" . __('Click to edit') . "'";
            print "<td {$onclick}>" . $line["login"] . "</td>";
            if (!$line["email"]) {
                $line["email"] = "&nbsp;";
            }
            print "<td {$onclick}>" . $access_level_names[$line["access_level"]] . "</td>";
            print "<td {$onclick}>" . $line["created"] . "</td>";
            print "<td {$onclick}>" . $line["last_login"] . "</td>";
            print "</tr>";
            ++$lnum;
        }
        print "</table>";
    } else {
        print "<p>";
        if (!$user_search) {
            print_warning(__('No users defined.'));
        } else {
            print_warning(__('No matching users found.'));
        }
        print "</p>";
    }
    print "</div>";
    #pane
    print "</div>";
    #container
}
예제 #6
0
 function index()
 {
     if (!function_exists('curl_init')) {
         print "<div style='padding : 1em'>";
         print_error("This functionality requires CURL functions. Please enable CURL in your PHP configuration (you might also want to disable open_basedir in php.ini) and reload this page.");
         print "</div>";
     }
     print "<div id=\"pref-instance-wrap\" dojoType=\"dijit.layout.BorderContainer\" gutters=\"false\">";
     print "<div id=\"pref-instance-header\" dojoType=\"dijit.layout.ContentPane\" region=\"top\">";
     print "<div id=\"pref-instance-toolbar\" dojoType=\"dijit.Toolbar\">";
     $sort = db_escape_string($_REQUEST["sort"]);
     if (!$sort || $sort == "undefined") {
         $sort = "access_url";
     }
     print "<div dojoType=\"dijit.form.DropDownButton\">" . "<span>" . __('Select') . "</span>";
     print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
     print "<div onclick=\"selectTableRows('prefInstanceList', 'all')\"\n\t\t\tdojoType=\"dijit.MenuItem\">" . __('All') . "</div>";
     print "<div onclick=\"selectTableRows('prefInstanceList', 'none')\"\n\t\t\tdojoType=\"dijit.MenuItem\">" . __('None') . "</div>";
     print "</div></div>";
     print "<button dojoType=\"dijit.form.Button\" onclick=\"addInstance()\">" . __('Link instance') . "</button>";
     print "<button dojoType=\"dijit.form.Button\" onclick=\"editSelectedInstance()\">" . __('Edit') . "</button>";
     print "<button dojoType=\"dijit.form.Button\" onclick=\"removeSelectedInstances()\">" . __('Remove') . "</button>";
     print "</div>";
     #toolbar
     $result = db_query($this->link, "SELECT *,\n\t\t\t(SELECT COUNT(*) FROM ttrss_linked_feeds\n\t\t\t\tWHERE instance_id = ttrss_linked_instances.id) AS num_feeds\n\t\t\tFROM ttrss_linked_instances\n\t\t\tORDER BY {$sort}");
     print "<p class=\"insensitive\" style='margin-left : 1em;'>" . __("You can connect other instances of Tiny Tiny RSS to this one to share Popular feeds. Link to this instance of Tiny Tiny RSS by using this URL:");
     print " <a href=\"#\" onclick=\"alert('" . htmlspecialchars(get_self_url_prefix()) . "')\">(display url)</a>";
     print "<p><table width='100%' id='prefInstanceList' class='prefInstanceList' cellspacing='0'>";
     print "<tr class=\"title\">\n\t\t\t<td align='center' width=\"5%\">&nbsp;</td>\n\t\t\t<td width=''><a href=\"#\" onclick=\"updateInstanceList('access_url')\">" . __('Instance URL') . "</a></td>\n\t\t\t<td width='20%'><a href=\"#\" onclick=\"updateInstanceList('access_key')\">" . __('Access key') . "</a></td>\n\t\t\t<td width='10%'><a href=\"#\" onclick=\"updateUsersList('last_connected')\">" . __('Last connected') . "</a></td>\n\t\t\t<td width='10%'><a href=\"#\" onclick=\"updateUsersList('last_status_out')\">" . __('Status') . "</a></td>\n\t\t\t<td width='10%'><a href=\"#\" onclick=\"updateUsersList('num_feeds')\">" . __('Stored feeds') . "</a></td>\n\t\t\t</tr>";
     $lnum = 0;
     while ($line = db_fetch_assoc($result)) {
         $class = $lnum % 2 ? "even" : "odd";
         $id = $line['id'];
         $this_row_id = "id=\"LIRR-{$id}\"";
         $line["last_connected"] = make_local_datetime($this->link, $line["last_connected"], false);
         print "<tr class=\"{$class}\" {$this_row_id}>";
         print "<td align='center'><input onclick='toggleSelectRow(this);'\n\t\t\t\ttype=\"checkbox\" id=\"LICHK-{$id}\"></td>";
         $onclick = "onclick='editInstance({$id}, event)' title='" . __('Click to edit') . "'";
         $access_key = mb_substr($line['access_key'], 0, 4) . '...' . mb_substr($line['access_key'], -4);
         print "<td {$onclick}>" . htmlspecialchars($line['access_url']) . "</td>";
         print "<td {$onclick}>" . htmlspecialchars($access_key) . "</td>";
         print "<td {$onclick}>" . htmlspecialchars($line['last_connected']) . "</td>";
         print "<td {$onclick}>" . $this->status_codes[$line['last_status_out']] . "</td>";
         print "<td {$onclick}>" . htmlspecialchars($line['num_feeds']) . "</td>";
         print "</tr>";
         ++$lnum;
     }
     print "</table>";
     print "</div>";
     #pane
     print "</div>";
     #container
 }
function render_article($link, $id, $feed_id, $cat_id, $is_cat)
{
    $query = "SELECT title,link,content,feed_id,comments,int_id,\n\t\t\tmarked,unread,published,\n\t\t\t" . SUBSTRING_FOR_DATE . "(updated,1,16) as updated,\n\t\t\tauthor\n\t\t\tFROM ttrss_entries,ttrss_user_entries\n\t\t\tWHERE\tid = '{$id}' AND ref_id = id AND owner_uid = " . $_SESSION["uid"];
    $result = db_query($link, $query);
    if (db_num_rows($result) != 0) {
        $line = db_fetch_assoc($result);
        $tmp_result = db_query($link, "UPDATE ttrss_user_entries\n\t\t\t\tSET unread = false,last_read = NOW()\n\t\t\t\tWHERE ref_id = '{$id}'\n\t\t\t\tAND owner_uid = " . $_SESSION["uid"]);
        $updated_fmt = make_local_datetime($link, $line['updated'], false);
        $title = $line["title"];
        $article_link = $line["link"];
        if (!$is_cat) {
            $feed_title = getFeedTitle($link, $feed_id);
        } else {
            $feed_title = getCategoryTitle($link, $feed_id);
        }
        print "<div class=\"panel\" id=\"article-{$id}\" title=\"{$title}\"\n\t\t\t\tselected=\"true\"\n\t\t\t\tmyBackLabel='{$feed_title}' myBackHref='feed.php?id={$feed_id}&cat={$cat_id}&is_cat={$is_cat}'>";
        if ($line['feed_id'] != $feed_id) {
            $real_feed_title = getFeedTitle($link, $line['feed_id']);
            $real_feed_id = $line['feed_id'];
            $feed_link = "(<a href=\"feed.php?id={$real_feed_id}\">{$real_feed_title}</a>)";
        }
        //			print "<fieldset>";
        print "<div style='float : right'>({$updated_fmt})</div>";
        print "<h2><a target='_blank' href='{$article_link}'>{$title}</a> {$feed_link}</h2>";
        print "<hr>";
        /*			print "<div class=\"row\">";
        			print "<label id='title'><a target='_blank' href='$article_link'>$title</a></label>";
        			print "</div>"; */
        $is_starred = sql_bool_to_bool($line["marked"]) ? "true" : "false";
        $is_published = sql_bool_to_bool($line["published"]) ? "true" : "false";
        //print "<div class=\"row\">";
        //print "<label id='updated'>Updated:</label>";
        //print "<input type='text' enabled='false' name='updated' disabled value='$updated_fmt'/>";
        //print "</div>";
        //			print "</fieldset>";
        $content = sanitize($link, $line["content"]);
        $content = preg_replace("/href=/i", "target=\"_blank\" href=", $content);
        if (!mobile_get_pref($link, "SHOW_IMAGES")) {
            $content = preg_replace('/<img[^>]+>/is', '', $content);
        }
        print "<p>{$content}</p>";
        print "<div class='nav'>\n                    <label>Navigation</label>\n                    <div class='button left' onclick='goPrev({$id}, {$feed_id}, this)'>Prev</div>\n                    <div class='button right' onclick='goNext({$id}, {$feed_id}, this)'>Next</div>\n                  </div>";
        print "<fieldset>";
        print "<div class=\"row\">\n\t                <label>Starred</label>\n\t                <div class=\"toggle\" onclick=\"toggleMarked({$id}, this)\" toggled=\"{$is_starred}\"><span class=\"thumb\"></span><span class=\"toggleOn\">ON</span><span class=\"toggleOff\">OFF</span></div>\n\t            </div>";
        print "<div class=\"row\">\n\t                <label>Published</label>\n\t                <div class=\"toggle\" onclick=\"togglePublished({$id}, this)\" toggled=\"{$is_published}\"><span class=\"thumb\"></span><span class=\"toggleOn\">ON</span><span class=\"toggleOff\">OFF</span></div>\n\t            </div>";
        print "<div class=\"row\">\n\t                <label>Unread</label>\n\t                <div class=\"toggle\" onclick=\"toggleUnread({$id}, this)\" toggled=\"{$is_unread}\"><span class=\"thumb\"></span><span class=\"toggleOn\">ON</span><span class=\"toggleOff\">OFF</span></div>\n\t            </div>";
        print "</fieldset>";
        print "</div>";
    }
}
예제 #8
0
function getFeedCounters($active_feed = false)
{
    $ret_arr = array();
    $query = "SELECT ttrss_feeds.id,\n\t\t\t\tttrss_feeds.title,\n\t\t\t\t" . SUBSTRING_FOR_DATE . "(ttrss_feeds.last_updated,1,19) AS last_updated,\n\t\t\t\tlast_error, value AS count\n\t\t\tFROM ttrss_feeds, ttrss_counters_cache\n\t\t\tWHERE ttrss_feeds.owner_uid = " . $_SESSION["uid"] . "\n\t\t\t\tAND ttrss_counters_cache.owner_uid = ttrss_feeds.owner_uid\n\t\t\t\tAND ttrss_counters_cache.feed_id = id";
    $result = db_query($query);
    while ($line = db_fetch_assoc($result)) {
        $id = $line["id"];
        $count = $line["count"];
        $last_error = htmlspecialchars($line["last_error"]);
        $last_updated = make_local_datetime($line['last_updated'], false);
        $has_img = feed_has_icon($id);
        if (date('Y') - date('Y', strtotime($line['last_updated'])) > 2) {
            $last_updated = '';
        }
        $cv = array("id" => $id, "updated" => $last_updated, "counter" => (int) $count, "has_img" => (int) $has_img);
        if ($last_error) {
            $cv["error"] = $last_error;
        }
        //			if (get_pref('EXTENDED_FEEDLIST'))
        //				$cv["xmsg"] = getFeedArticles($id)." ".__("total");
        if ($active_feed && $id == $active_feed) {
            $cv["title"] = truncate_string($line["title"], 30);
        }
        array_push($ret_arr, $cv);
    }
    return $ret_arr;
}
예제 #9
0
 function getfeedtree()
 {
     $search = $_SESSION["prefs_feed_search"];
     if ($search) {
         $search_qpart = " AND LOWER(title) LIKE LOWER('%{$search}%')";
     }
     $root = array();
     $root['id'] = 'root';
     $root['name'] = __('Feeds');
     $root['items'] = array();
     $root['type'] = 'category';
     $enable_cats = get_pref($this->link, 'ENABLE_FEED_CATS');
     if ($_REQUEST['mode'] == 2) {
         if ($enable_cats) {
             $cat_hidden = get_pref($this->link, "_COLLAPSED_SPECIAL");
             $cat = $this->feedlist_init_cat(-1, $cat_hidden);
         } else {
             $cat['items'] = array();
         }
         foreach (array(-4, -3, -1, -2, 0, -6) as $i) {
             array_push($cat['items'], $this->feedlist_init_feed($i));
         }
         if ($enable_cats) {
             array_push($root['items'], $cat);
         } else {
             $root['items'] = array_merge($root['items'], $cat['items']);
         }
         $result = db_query($this->link, "SELECT * FROM\n\t\t\t\tttrss_labels2 WHERE owner_uid = " . $_SESSION['uid'] . " ORDER by caption");
         if (db_num_rows($result) > 0) {
             if (get_pref($this->link, 'ENABLE_FEED_CATS')) {
                 $cat_hidden = get_pref($this->link, "_COLLAPSED_LABELS");
                 $cat = $this->feedlist_init_cat(-2, $cat_hidden);
             } else {
                 $cat['items'] = array();
             }
             while ($line = db_fetch_assoc($result)) {
                 $label_id = -$line['id'] - 11;
                 $count = getFeedUnread($this->link, $label_id);
                 $feed = $this->feedlist_init_feed($label_id, false, $count);
                 $feed['fg_color'] = $line['fg_color'];
                 $feed['bg_color'] = $line['bg_color'];
                 array_push($cat['items'], $feed);
             }
             if ($enable_cats) {
                 array_push($root['items'], $cat);
             } else {
                 $root['items'] = array_merge($root['items'], $cat['items']);
             }
         }
     }
     if ($enable_cats) {
         $show_empty_cats = $_REQUEST['mode'] != 2 && get_pref($this->link, '_PREFS_SHOW_EMPTY_CATS');
         $result = db_query($this->link, "SELECT id, title, collapsed FROM ttrss_feed_categories\n\t\t\t\tWHERE owner_uid = " . $_SESSION["uid"] . " AND parent_cat IS NULL ORDER BY order_id, title");
         while ($line = db_fetch_assoc($result)) {
             $cat = array();
             $cat['id'] = 'CAT:' . $line['id'];
             $cat['bare_id'] = (int) $line['id'];
             $cat['name'] = $line['title'];
             $cat['items'] = array();
             $cat['checkbox'] = false;
             $cat['hidden'] = sql_bool_to_bool($line['collapsed']);
             $cat['type'] = 'category';
             $cat['unread'] = 0;
             $cat['child_unread'] = 0;
             $cat['items'] = $this->get_category_items($line['id']);
             $cat['param'] = T_sprintf('(%d feeds)', count($cat['items']));
             if (count($cat['items']) > 0 || $show_empty_cats) {
                 array_push($root['items'], $cat);
             }
             $root['param'] += count($cat['items']);
         }
         /* Uncategorized is a special case */
         $cat = array();
         $cat['id'] = 'CAT:0';
         $cat['bare_id'] = 0;
         $cat['name'] = __("Uncategorized");
         $cat['items'] = array();
         $cat['hidden'] = get_pref($this->link, "_COLLAPSED_UNCAT");
         $cat['type'] = 'category';
         $cat['checkbox'] = false;
         $cat['unread'] = 0;
         $cat['child_unread'] = 0;
         $feed_result = db_query($this->link, "SELECT id, title,last_error,\n\t\t\t\t" . SUBSTRING_FOR_DATE . "(last_updated,1,19) AS last_updated\n\t\t\t\tFROM ttrss_feeds\n\t\t\t\tWHERE cat_id IS NULL AND owner_uid = " . $_SESSION["uid"] . "{$search_qpart} ORDER BY order_id, title");
         while ($feed_line = db_fetch_assoc($feed_result)) {
             $feed = array();
             $feed['id'] = 'FEED:' . $feed_line['id'];
             $feed['bare_id'] = (int) $feed_line['id'];
             $feed['name'] = $feed_line['title'];
             $feed['checkbox'] = false;
             $feed['error'] = $feed_line['last_error'];
             $feed['icon'] = getFeedIcon($feed_line['id']);
             $feed['param'] = make_local_datetime($this->link, $feed_line['last_updated'], true);
             $feed['unread'] = 0;
             $feed['type'] = 'feed';
             array_push($cat['items'], $feed);
         }
         $cat['param'] = T_sprintf('(%d feeds)', count($cat['items']));
         if (count($cat['items']) > 0 || $show_empty_cats) {
             array_push($root['items'], $cat);
         }
         $root['param'] += count($cat['items']);
         $root['param'] = T_sprintf('(%d feeds)', $root['param']);
     } else {
         $feed_result = db_query($this->link, "SELECT id, title, last_error,\n\t\t\t\t" . SUBSTRING_FOR_DATE . "(last_updated,1,19) AS last_updated\n\t\t\t\tFROM ttrss_feeds\n\t\t\t\tWHERE owner_uid = " . $_SESSION["uid"] . "{$search_qpart} ORDER BY order_id, title");
         while ($feed_line = db_fetch_assoc($feed_result)) {
             $feed = array();
             $feed['id'] = 'FEED:' . $feed_line['id'];
             $feed['bare_id'] = (int) $feed_line['id'];
             $feed['name'] = $feed_line['title'];
             $feed['checkbox'] = false;
             $feed['error'] = $feed_line['last_error'];
             $feed['icon'] = getFeedIcon($feed_line['id']);
             $feed['param'] = make_local_datetime($this->link, $feed_line['last_updated'], true);
             $feed['unread'] = 0;
             $feed['type'] = 'feed';
             array_push($root['items'], $feed);
         }
         $root['param'] = T_sprintf('(%d feeds)', count($root['items']));
     }
     $fl = array();
     $fl['identifier'] = 'id';
     $fl['label'] = 'name';
     if ($_REQUEST['mode'] != 2) {
         $fl['items'] = array($root);
     } else {
         $fl['items'] =& $root['items'];
     }
     print json_encode($fl);
     return;
 }
예제 #10
0
function module_popup_dialog($link)
{
    $id = $_REQUEST["id"];
    $param = db_escape_string($_REQUEST["param"]);
    print "<dlg id=\"{$id}\">";
    if ($id == "importOpml") {
        print "<div class=\"prefFeedOPMLHolder\">";
        header("Content-Type: text/html");
        # required for iframe
        $owner_uid = $_SESSION["uid"];
        db_query($link, "BEGIN");
        /* create Imported feeds category just in case */
        $result = db_query($link, "SELECT id FROM\n\t\t\t\tttrss_feed_categories WHERE title = 'Imported feeds' AND\n\t\t\t\towner_uid = '{$owner_uid}' LIMIT 1");
        if (db_num_rows($result) == 0) {
            db_query($link, "INSERT INTO ttrss_feed_categories\n\t\t\t\t\t(title,owner_uid)\n\t\t\t\t\t\tVALUES ('Imported feeds', '{$owner_uid}')");
        }
        db_query($link, "COMMIT");
        /* Handle OPML import by DOMXML/DOMDocument */
        if (function_exists('domxml_open_file')) {
            print "<ul class='nomarks'>";
            print "<li>" . __("Importing using DOMXML.") . "</li>";
            require_once "opml_domxml.php";
            opml_import_domxml($link, $owner_uid);
            print "</ul>";
        } else {
            if (PHP_VERSION >= 5) {
                print "<ul class='nomarks'>";
                print "<li>" . __("Importing using DOMDocument.") . "</li>";
                require_once "opml_domdoc.php";
                opml_import_domdoc($link, $owner_uid);
                print "</ul>";
            } else {
                print_error(__("DOMXML extension is not found. It is required for PHP versions below 5."));
            }
        }
        print "</div>";
        print "<div align='center'>";
        print "<button dojoType=\"dijit.form.Button\"\n\t\t\t\tonclick=\"dijit.byId('opmlImportDlg').hide()\">" . __('Close this window') . "</button>";
        print "</div>";
        print "</div>";
        //return;
    }
    if ($id == "editPrefProfiles") {
        print "<div dojoType=\"dijit.Toolbar\">";
        #			TODO: depends on selectTableRows() being broken for this list
        #			print "<div dojoType=\"dijit.form.DropDownButton\">".
        #				"<span>" . __('Select')."</span>";
        #			print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
        #			print "<div onclick=\"selectTableRows('prefFeedProfileList', 'all')\"
        #				dojoType=\"dijit.MenuItem\">".__('All')."</div>";
        #			print "<div onclick=\"selectTableRows('prefFeedProfileList', 'none')\"
        #				dojoType=\"dijit.MenuItem\">".__('None')."</div>";
        #			print "</div></div>";
        #			print "<div style='float : right'>";
        print "<input name=\"newprofile\" dojoType=\"dijit.form.ValidationTextBox\"\n\t\t\t\t\trequired=\"1\">\n\t\t\t\t<button dojoType=\"dijit.form.Button\"\n\t\t\t\tonclick=\"dijit.byId('profileEditDlg').addProfile()\">" . __('Create profile') . "</button></div>";
        #			print "</div>";
        $result = db_query($link, "SELECT title,id FROM ttrss_settings_profiles\n\t\t\t\tWHERE owner_uid = " . $_SESSION["uid"] . " ORDER BY title");
        print "<div class=\"prefFeedCatHolder\">";
        print "<form id=\"profile_edit_form\" onsubmit=\"return false\">";
        print "<table width=\"100%\" class=\"prefFeedProfileList\"\n\t\t\t\tcellspacing=\"0\" id=\"prefFeedProfileList\">";
        print "<tr class=\"\" id=\"FCATR-0\">";
        #odd
        print "<td width='5%' align='center'><input\n\t\t\t\tonclick='toggleSelectRow2(this);'\n\t\t\t\tdojoType=\"dijit.form.CheckBox\"\n\t\t\t\ttype=\"checkbox\"></td>";
        if (!$_SESSION["profile"]) {
            $is_active = __("(active)");
        } else {
            $is_active = "";
        }
        print "<td><span>" . __("Default profile") . " {$is_active}</span></td>";
        print "</tr>";
        $lnum = 1;
        while ($line = db_fetch_assoc($result)) {
            $class = $lnum % 2 ? "even" : "odd";
            $profile_id = $line["id"];
            $this_row_id = "id=\"FCATR-{$profile_id}\"";
            print "<tr class=\"\" {$this_row_id}>";
            $edit_title = htmlspecialchars($line["title"]);
            print "<td width='5%' align='center'><input\n\t\t\t\t\tonclick='toggleSelectRow2(this);'\n\t\t\t\t\tdojoType=\"dijit.form.CheckBox\"\n\t\t\t\t\ttype=\"checkbox\"></td>";
            if ($_SESSION["profile"] == $line["id"]) {
                $is_active = __("(active)");
            } else {
                $is_active = "";
            }
            print "<td><span dojoType=\"dijit.InlineEditBox\"\n\t\t\t\t\twidth=\"300px\" autoSave=\"false\"\n\t\t\t\t\tprofile-id=\"{$profile_id}\">" . $edit_title . "<script type=\"dojo/method\" event=\"onChange\" args=\"item\">\n\t\t\t\t\t\tvar elem = this;\n\t\t\t\t\t\tdojo.xhrPost({\n\t\t\t\t\t\t\turl: 'backend.php',\n\t\t\t\t\t\t\tcontent: {op: 'rpc', subop: 'saveprofile',\n\t\t\t\t\t\t\t\tvalue: this.value,\n\t\t\t\t\t\t\t\tid: this.srcNodeRef.getAttribute('profile-id')},\n\t\t\t\t\t\t\t\tload: function(response) {\n\t\t\t\t\t\t\t\t\telem.attr('value', response);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t</script>\n\t\t\t\t</span> {$is_active}</td>";
            print "</tr>";
            ++$lnum;
        }
        print "</table>";
        print "</form>";
        print "</div>";
        print "<div class='dlgButtons'>\n\t\t\t\t<div style='float : left'>\n\t\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('profileEditDlg').removeSelected()\">" . __('Remove selected profiles') . "</button>\n\t\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('profileEditDlg').activateProfile()\">" . __('Activate profile') . "</button>\n\t\t\t\t</div>";
        print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('profileEditDlg').hide()\">" . __('Close this window') . "</button>";
        print "</div>";
    }
    if ($id == "pubOPMLUrl") {
        print "<title>" . __('Public OPML URL') . "</title>";
        print "<content><![CDATA[";
        $url_path = opml_publish_url($link);
        print __("Your Public OPML URL is:");
        print "<div class=\"tagCloudContainer\">";
        print "<a id='pub_opml_url' href='{$url_path}' target='_blank'>{$url_path}</a>";
        print "</div>";
        print "<div align='center'>";
        print "<button dojoType=\"dijit.form.Button\" onclick=\"return opmlRegenKey()\">" . __('Generate new URL') . "</button> ";
        print "<button dojoType=\"dijit.form.Button\" onclick=\"return closeInfoBox()\">" . __('Close this window') . "</button>";
        print "</div>";
        print "]]></content>";
        //return;
    }
    if ($id == "explainError") {
        print "<title>" . __('Notice') . "</title>";
        print "<content><![CDATA[";
        print "<div class=\"errorExplained\">";
        if ($param == 1) {
            print __("Update daemon is enabled in configuration, but daemon process is not running, which prevents all feeds from updating. Please start the daemon process or contact instance owner.");
            $stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp");
            print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp);
        }
        if ($param == 3) {
            print __("Update daemon is taking too long to perform a feed update. This could indicate a problem like crash or a hang. Please check the daemon process or contact instance owner.");
            $stamp = (int) file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp");
            print "<p>" . __("Last update:") . " " . date("Y.m.d, G:i", $stamp);
        }
        print "</div>";
        print "<div align='center'>";
        print "<button onclick=\"return closeInfoBox()\">" . __('Close this window') . "</button>";
        print "</div>";
        print "]]></content>";
        //return;
    }
    if ($id == "quickAddFeed") {
        print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
        print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"subop\" value=\"addfeed\">";
        print "<div class=\"dlgSec\">" . __("Feed") . "</div>";
        print "<div class=\"dlgSecCont\">";
        print "<input style=\"font-size : 16px; width : 20em;\"\n\t\t\t\tplaceHolder=\"" . __("Feed URL") . "\"\n\t\t\t\tdojoType=\"dijit.form.ValidationTextBox\" required=\"1\" name=\"feed\" id=\"feedDlg_feedUrl\">";
        print "<hr/>";
        if (get_pref($link, 'ENABLE_FEED_CATS')) {
            print __('Place in category:') . " ";
            print_feed_cat_select($link, "cat", false, 'dojoType="dijit.form.Select"');
        }
        print "</div>";
        print '<div id="feedDlg_feedsContainer" style="display : none">

					<div class="dlgSec">' . __('Available feeds') . '</div>
					<div class="dlgSecCont">' . '<select id="feedDlg_feedContainerSelect"
						dojoType="dijit.form.Select" size="3">
						<script type="dojo/method" event="onChange" args="value">
							dijit.byId("feedDlg_feedUrl").attr("value", value);
						</script>
					</select>' . '</div></div>';
        print "<div id='feedDlg_loginContainer' style='display : none'>\n\n\t\t\t\t\t<div class=\"dlgSec\">" . __("Authentication") . "</div>\n\t\t\t\t\t<div class=\"dlgSecCont\">" . " <input dojoType=\"dijit.form.TextBox\" name='login'\"\n\t\t\t\t\t\tplaceHolder=\"" . __("Login") . "\"\n\t\t\t\t\t\tstyle=\"width : 10em;\"> " . " <input\n\t\t\t\t\t\tplaceHolder=\"" . __("Password") . "\"\n\t\t\t\t\t\tdojoType=\"dijit.form.TextBox\" type='password'\n\t\t\t\t\t\tstyle=\"width : 10em;\" name='pass'\">\n\t\t\t\t</div></div>";
        print "<div style=\"clear : both\">\n\t\t\t\t<input type=\"checkbox\" dojoType=\"dijit.form.CheckBox\" id=\"feedDlg_loginCheck\"\n\t\t\t\t\t\tonclick='checkboxToggleElement(this, \"feedDlg_loginContainer\")'>\n\t\t\t\t\t<label for=\"feedDlg_loginCheck\">" . __('This feed requires authentication.') . "</div>";
        print "</form>";
        print "<div class=\"dlgButtons\">\n\t\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedAddDlg').execute()\">" . __('Subscribe') . "</button>\n\t\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"return feedBrowser()\">" . __('More feeds') . "</button>\n\t\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedAddDlg').hide()\">" . __('Cancel') . "</button>\n\t\t\t\t</div>";
        //return;
    }
    if ($id == "feedBrowser") {
        $browser_search = db_escape_string($_REQUEST["search"]);
        #			print "<form onsubmit='return false;' display='inline'
        #				name='feed_browser' id='feed_browser'>";
        print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
        print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"subop\" value=\"updateFeedBrowser\">";
        print "<div dojoType=\"dijit.Toolbar\">\n\t\t\t\t<div style='float : right'>\n\t\t\t\t<img style='display : none'\n\t\t\t\t\tid='feed_browser_spinner' src='" . theme_image($link, 'images/indicator_white.gif') . "'>\n\t\t\t\t<input name=\"search\" dojoType=\"dijit.form.TextBox\" size=\"20\" type=\"search\"\n\t\t\t\t\tonchange=\"dijit.byId('feedBrowserDlg').update()\" value=\"{$browser_search}\">\n\t\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').update()\">" . __('Search') . "</button>\n\t\t\t</div>";
        print " <select name=\"mode\" dojoType=\"dijit.form.Select\" onchange=\"dijit.byId('feedBrowserDlg').update()\">\n\t\t\t\t<option value='1'>" . __('Popular feeds') . "</option>\n\t\t\t\t<option value='2'>" . __('Feed archive') . "</option>\n\t\t\t\t</select> ";
        print __("limit:");
        print " <select dojoType=\"dijit.form.Select\" name=\"limit\" onchange=\"dijit.byId('feedBrowserDlg').update()\">";
        foreach (array(25, 50, 100, 200) as $l) {
            $issel = $l == $limit ? "selected=\"1\"" : "";
            print "<option {$issel} value=\"{$l}\">{$l}</option>";
        }
        print "</select> ";
        print "</div>";
        $owner_uid = $_SESSION["uid"];
        print "<ul class='browseFeedList' id='browseFeedList'>";
        print make_feed_browser($link, $search, 25);
        print "</ul>";
        print "<div align='center'>\n\t\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').execute()\">" . __('Subscribe') . "</button>\n\t\t\t\t<button dojoType=\"dijit.form.Button\" style='display : none' id='feed_archive_remove' onclick=\"dijit.byId('feedBrowserDlg').removeFromArchive()\">" . __('Remove') . "</button>\n\t\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedBrowserDlg').hide()\" >" . __('Cancel') . "</button></div>";
    }
    if ($id == "search") {
        $params = explode(":", db_escape_string($_REQUEST["param"]), 2);
        $active_feed_id = sprintf("%d", $params[0]);
        $is_cat = $params[1] != "false";
        print "<div class=\"dlgSec\">" . __('Look for') . "</div>";
        print "<div class=\"dlgSecCont\">";
        if (!SPHINX_ENABLED) {
            print "<input dojoType=\"dijit.form.ValidationTextBox\"\n\t\t\t\t\tstyle=\"font-size : 16px; width : 12em;\"\n\t\t\t\t\trequired=\"1\" name=\"query\" type=\"search\" value=''>";
            print " " . __('match on') . " ";
            $search_fields = array("title" => __("Title"), "content" => __("Content"), "both" => __("Title or content"));
            print_select_hash("match_on", 3, $search_fields, 'dojoType="dijit.form.Select"');
        } else {
            print "<input dojoType=\"dijit.form.ValidationTextBox\"\n\t\t\t\t\tstyle=\"font-size : 16px; width : 20em;\"\n\t\t\t\t\trequired=\"1\" name=\"query\" type=\"search\" value=''>";
        }
        print "<hr/>" . __('Limit search to:') . " ";
        print "<select name=\"search_mode\" dojoType=\"dijit.form.Select\">\n\t\t\t\t<option value=\"all_feeds\">" . __('All feeds') . "</option>";
        $feed_title = getFeedTitle($link, $active_feed_id);
        if (!$is_cat) {
            $feed_cat_title = getFeedCatTitle($link, $active_feed_id);
        } else {
            $feed_cat_title = getCategoryTitle($link, $active_feed_id);
        }
        if ($active_feed_id && !$is_cat) {
            print "<option selected=\"1\" value=\"this_feed\">{$feed_title}</option>";
        } else {
            print "<option disabled=\"1\" value=\"false\">" . __('This feed') . "</option>";
        }
        if ($is_cat) {
            $cat_preselected = "selected=\"1\"";
        }
        if (get_pref($link, 'ENABLE_FEED_CATS') && ($active_feed_id > 0 || $is_cat)) {
            print "<option {$cat_preselected} value=\"this_cat\">{$feed_cat_title}</option>";
        } else {
            //print "<option disabled>".__('This category')."</option>";
        }
        print "</select>";
        print "</div>";
        print "<div class=\"dlgButtons\">";
        if (!SPHINX_ENABLED) {
            print "<div style=\"float : left\">\n\t\t\t\t\t<a class=\"visibleLink\" target=\"_blank\" href=\"http://tt-rss.org/redmine/wiki/tt-rss/SearchSyntax\">Search syntax</a>\n\t\t\t\t\t</div>";
        }
        print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('searchDlg').execute()\">" . __('Search') . "</button>\n\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('searchDlg').hide()\">" . __('Cancel') . "</button>\n\t\t\t</div>";
    }
    if ($id == "quickAddFilter") {
        $active_feed_id = db_escape_string($_REQUEST["param"]);
        print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-filters\">";
        print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"quiet\" value=\"1\">";
        print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"subop\" value=\"add\">";
        $result = db_query($link, "SELECT id,description\n\t\t\t\tFROM ttrss_filter_types ORDER BY description");
        $filter_types = array();
        while ($line = db_fetch_assoc($result)) {
            //array_push($filter_types, $line["description"]);
            $filter_types[$line["id"]] = __($line["description"]);
        }
        print "<div class=\"dlgSec\">" . __("Match") . "</div>";
        print "<div class=\"dlgSecCont\">";
        print "<span id=\"filterDlg_dateModBox\" style=\"display : none\">";
        $filter_params = array("before" => __("before"), "after" => __("after"));
        print_select_hash("filter_date_modifier", "before", $filter_params, 'dojoType="dijit.form.Select"');
        print "&nbsp;</span>";
        print "<input dojoType=\"dijit.form.ValidationTextBox\"\n\t\t\t\t required=\"true\" id=\"filterDlg_regExp\"\n\t\t\t\t style=\"font-size : 16px\"\n\t\t\t\t name=\"reg_exp\" value=\"{$reg_exp}\"/>";
        print "<span id=\"filterDlg_dateChkBox\" style=\"display : none\">";
        print "&nbsp;<button dojoType=\"dijit.form.Button\"\n\t\t\t\tonclick=\"return filterDlgCheckDate()\">" . __('Check it') . "</button>";
        print "</span>";
        print "<hr/>" . __("on field") . " ";
        print_select_hash("filter_type", 1, $filter_types, 'onchange="filterDlgCheckType(this)" dojoType="dijit.form.Select"');
        print "<hr/>";
        print __("in") . " ";
        print_feed_select($link, "feed_id", $active_feed_id, 'dojoType="dijit.form.FilteringSelect"');
        print "</div>";
        print "<div class=\"dlgSec\">" . __("Perform Action") . "</div>";
        print "<div class=\"dlgSecCont\">";
        print "<select name=\"action_id\" dojoType=\"dijit.form.Select\"\n\t\t\t\tonchange=\"filterDlgCheckAction(this)\">";
        $result = db_query($link, "SELECT id,description FROM ttrss_filter_actions\n\t\t\t\tORDER BY name");
        while ($line = db_fetch_assoc($result)) {
            printf("<option value='%d'>%s</option>", $line["id"], __($line["description"]));
        }
        print "</select>";
        print "<span id=\"filterDlg_paramBox\" style=\"display : none\">";
        print " " . __("with parameters:") . " ";
        print "<input dojoType=\"dijit.form.TextBox\"\n\t\t\t\tid=\"filterDlg_actionParam\"\n\t\t\t\tname=\"action_param\">";
        print_label_select($link, "action_param_label", $action_param, 'id="filterDlg_actionParamLabel" dojoType="dijit.form.Select"');
        print "</span>";
        print "&nbsp;";
        // tiny layout hack
        print "</div>";
        print "<div class=\"dlgSec\">" . __("Options") . "</div>";
        print "<div class=\"dlgSecCont\">";
        print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"enabled\" id=\"enabled\" checked=\"1\">\n\t\t\t\t\t<label for=\"enabled\">" . __('Enabled') . "</label><hr/>";
        print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"inverse\" id=\"inverse\">\n\t\t\t\t<label for=\"inverse\">" . __('Inverse match') . "</label>";
        print "</div>";
        print "<div class=\"dlgButtons\">";
        print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').test()\">" . __('Test') . "</button> ";
        print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').execute()\">" . __('Create') . "</button> ";
        print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').hide()\">" . __('Cancel') . "</button>";
        print "</div>";
        //return;
    }
    if ($id == "inactiveFeeds") {
        if (DB_TYPE == "pgsql") {
            $interval_qpart = "NOW() - INTERVAL '3 months'";
        } else {
            $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)";
        }
        $result = db_query($link, "SELECT ttrss_feeds.title, ttrss_feeds.site_url,\n\t\t\t  \t\tttrss_feeds.feed_url, ttrss_feeds.id, MAX(updated) AS last_article\n\t\t\t\tFROM ttrss_feeds, ttrss_entries, ttrss_user_entries WHERE\n\t\t\t\t\t(SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE\n\t\t\t\t\t\tttrss_entries.id = ref_id AND\n\t\t\t\t\t\t\tttrss_user_entries.feed_id = ttrss_feeds.id) < {$interval_qpart}\n\t\t\t\tAND ttrss_feeds.owner_uid = " . $_SESSION["uid"] . " AND\n\t\t\t\t\tttrss_user_entries.feed_id = ttrss_feeds.id AND\n\t\t\t\t\tttrss_entries.id = ref_id\n\t\t\t\tGROUP BY ttrss_feeds.title, ttrss_feeds.id, ttrss_feeds.site_url, ttrss_feeds.feed_url\n\t\t\t\tORDER BY last_article");
        print __("These feeds have not been updated with new content for 3 months (oldest first):");
        print "<div class=\"inactiveFeedHolder\">";
        print "<table width=\"100%\" cellspacing=\"0\" id=\"prefInactiveFeedList\">";
        $lnum = 1;
        while ($line = db_fetch_assoc($result)) {
            $class = $lnum % 2 ? "even" : "odd";
            $feed_id = $line["id"];
            $this_row_id = "id=\"FUPDD-{$feed_id}\"";
            print "<tr class=\"\" {$this_row_id}>";
            $edit_title = htmlspecialchars($line["title"]);
            print "<td width='5%' align='center'><input\n\t\t\t\t\tonclick='toggleSelectRow2(this);' dojoType=\"dijit.form.CheckBox\"\n\t\t\t\t\ttype=\"checkbox\"></td>";
            print "<td>";
            print "<a class=\"visibleLink\" href=\"#\" " . "title=\"" . __("Click to edit feed") . "\" " . "onclick=\"editFeed(" . $line["id"] . ")\">" . htmlspecialchars($line["title"]) . "</a>";
            print "</td><td class=\"insensitive\" align='right'>";
            print make_local_datetime($link, $line['last_article'], false);
            print "</td>";
            print "</tr>";
            ++$lnum;
        }
        print "</table>";
        print "</div>";
        print "<div class='dlgButtons'>";
        print "<div style='float : left'>";
        print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('inactiveFeedsDlg').removeSelected()\">" . __('Unsubscribe from selected feeds') . "</button> ";
        print "</div>";
        print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('inactiveFeedsDlg').hide()\">" . __('Close this window') . "</button>";
        print "</div>";
    }
    if ($id == "feedsWithErrors") {
        #			print "<title>".__('Feeds with update errors')."</title>";
        #			print "<content><![CDATA[";
        print __("These feeds have not been updated because of errors:");
        $result = db_query($link, "SELECT id,title,feed_url,last_error,site_url\n\t\t\tFROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION["uid"]);
        print "<div class=\"inactiveFeedHolder\">";
        print "<table width=\"100%\" cellspacing=\"0\" id=\"prefErrorFeedList\">";
        $lnum = 1;
        while ($line = db_fetch_assoc($result)) {
            $class = $lnum % 2 ? "even" : "odd";
            $feed_id = $line["id"];
            $this_row_id = "id=\"FUPDD-{$feed_id}\"";
            print "<tr class=\"\" {$this_row_id}>";
            $edit_title = htmlspecialchars($line["title"]);
            print "<td width='5%' align='center'><input\n\t\t\t\t\tonclick='toggleSelectRow2(this);' dojoType=\"dijit.form.CheckBox\"\n\t\t\t\t\ttype=\"checkbox\"></td>";
            print "<td>";
            print "<a class=\"visibleLink\" href=\"#\" " . "title=\"" . __("Click to edit feed") . "\" " . "onclick=\"editFeed(" . $line["id"] . ")\">" . htmlspecialchars($line["title"]) . "</a>: ";
            print "<span class=\"insensitive\">";
            print htmlspecialchars($line["last_error"]);
            print "</span>";
            print "</td>";
            print "</tr>";
            ++$lnum;
        }
        print "</table>";
        print "</div>";
        print "<div class='dlgButtons'>";
        print "<div style='float : left'>";
        print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('errorFeedsDlg').removeSelected()\">" . __('Unsubscribe from selected feeds') . "</button> ";
        print "</div>";
        print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('errorFeedsDlg').hide()\">" . __('Close this window') . "</button>";
        print "</div>";
    }
    if ($id == "editArticleTags") {
        #			print "<form id=\"tag_edit_form\" onsubmit='return false'>";
        print __("Tags for this article (separated by commas):") . "<br>";
        $tags = get_article_tags($link, $param);
        $tags_str = join(", ", $tags);
        print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"id\" value=\"{$param}\">";
        print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
        print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"subop\" value=\"setArticleTags\">";
        print "<table width='100%'><tr><td>";
        print "<textarea dojoType=\"dijit.form.SimpleTextarea\" rows='4'\n\t\t\t\tstyle='font-size : 12px; width : 100%' id=\"tags_str\"\n\t\t\t\tname='tags_str'>{$tags_str}</textarea>\n\t\t\t<div class=\"autocomplete\" id=\"tags_choices\"\n\t\t\t\t\tstyle=\"display:none\"></div>";
        print "</td></tr></table>";
        #			print "</form>";
        print "<div class='dlgButtons'>";
        print "<button dojoType=\"dijit.form.Button\"\n\t\t\t\tonclick=\"dijit.byId('editTagsDlg').execute()\">" . __('Save') . "</button> ";
        print "<button dojoType=\"dijit.form.Button\"\n\t\t\t\tonclick=\"dijit.byId('editTagsDlg').hide()\">" . __('Cancel') . "</button>";
        print "</div>";
    }
    if ($id == "printTagCloud") {
        print "<title>" . __('Tag Cloud') . "</title>";
        print "<content><![CDATA[";
        #			print __("Showing most popular tags ")." (<a
        #			href='javascript:toggleTags(true)'>".__('more tags')."</a>):<br/>";
        print "<div class=\"tagCloudContainer\">";
        printTagCloud($link);
        print "</div>";
        print "<div align='center'>";
        print "<button dojoType=\"dijit.form.Button\"\n\t\t\t\tonclick=\"return closeInfoBox()\">" . __('Close this window') . "</button>";
        print "</div>";
        print "]]></content>";
    }
    if ($id == 'printTagSelect') {
        print "<title>" . __('Select item(s) by tags') . "</title>";
        print "<content><![CDATA[";
        print __("Match:") . "&nbsp;" . "<input class=\"noborder\" dojoType=\"dijit.form.RadioButton\" type=\"radio\" checked value=\"any\" name=\"tag_mode\">&nbsp;Any&nbsp;";
        print "<input class=\"noborder\" dojoType=\"dijit.form.RadioButton\" type=\"radio\" value=\"all\" name=\"tag_mode\">&nbsp;All&nbsp;";
        print "&nbsp;tags.";
        print "<select id=\"all_tags\" name=\"all_tags\" title=\"" . __('Which Tags?') . "\" multiple=\"multiple\" size=\"10\" style=\"width : 100%\">";
        $result = db_query($link, "SELECT DISTINCT tag_name FROM ttrss_tags WHERE owner_uid = " . $_SESSION['uid'] . "\n\t\t\t\tAND LENGTH(tag_name) <= 30 ORDER BY tag_name ASC");
        while ($row = db_fetch_assoc($result)) {
            $tmp = htmlspecialchars($row["tag_name"]);
            print "<option value=\"" . str_replace(" ", "%20", $tmp) . "\">{$tmp}</option>";
        }
        print "</select>";
        print "<div align='right'>";
        print "<button dojoType=\"dijit.form.Button\" onclick=\"viewfeed(get_all_tags(\$('all_tags')),\n\t\t\t\tget_radio_checked(\$('tag_mode')));\">" . __('Display entries') . "</button>";
        print "&nbsp;";
        print "<button dojoType=\"dijit.form.Button\"\n\t\t\tonclick=\"return closeInfoBox()\">" . __('Close this window') . "</button>";
        print "</div>";
        print "]]></content>";
    }
    if ($id == "emailArticle") {
        $secretkey = sha1(uniqid(rand(), true));
        $_SESSION['email_secretkey'] = $secretkey;
        print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"secretkey\" value=\"{$secretkey}\">";
        print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
        print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"subop\" value=\"sendEmail\">";
        $result = db_query($link, "SELECT email, full_name FROM ttrss_users WHERE\n\t\t\t\tid = " . $_SESSION["uid"]);
        $user_email = htmlspecialchars(db_fetch_result($result, 0, "email"));
        $user_name = htmlspecialchars(db_fetch_result($result, 0, "full_name"));
        if (!$user_name) {
            $user_name = $_SESSION['name'];
        }
        $_SESSION['email_replyto'] = $user_email;
        $_SESSION['email_fromname'] = $user_name;
        require_once "lib/MiniTemplator.class.php";
        $tpl = new MiniTemplator();
        $tpl_t = new MiniTemplator();
        $tpl->readTemplateFromFile("templates/email_article_template.txt");
        $tpl->setVariable('USER_NAME', $_SESSION["name"]);
        $tpl->setVariable('USER_EMAIL', $user_email);
        $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"]);
        //			$tpl->addBlock('header');
        $result = db_query($link, "SELECT link, content, title\n\t\t\t\tFROM ttrss_user_entries, ttrss_entries WHERE id = ref_id AND\n\t\t\t\tid IN ({$param}) AND owner_uid = " . $_SESSION["uid"]);
        if (db_num_rows($result) > 1) {
            $subject = __("[Forwarded]") . " " . __("Multiple articles");
        }
        while ($line = db_fetch_assoc($result)) {
            if (!$subject) {
                $subject = __("[Forwarded]") . " " . htmlspecialchars($line["title"]);
            }
            $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"]));
            $tpl->setVariable('ARTICLE_URL', strip_tags($line["link"]));
            $tpl->addBlock('article');
        }
        $tpl->addBlock('email');
        $content = "";
        $tpl->generateOutputToString($content);
        print "<table width='100%'><tr><td>";
        print __('From:');
        print "</td><td>";
        print "<input dojoType=\"dijit.form.TextBox\" disabled=\"1\" style=\"width : 30em;\"\n\t\t\t\t\tvalue=\"{$user_name} <{$user_email}>\">";
        print "</td></tr><tr><td>";
        print __('To:');
        print "</td><td>";
        print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"true\"\n\t\t\t\t\tstyle=\"width : 30em;\"\n\t\t\t\t\tname=\"destination\" id=\"emailArticleDlg_destination\">";
        print "<div class=\"autocomplete\" id=\"emailArticleDlg_dst_choices\"\n\t\t\t\t\tstyle=\"z-index: 30; display : none\"></div>";
        print "</td></tr><tr><td>";
        print __('Subject:');
        print "</td><td>";
        print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"true\"\n\t\t\t\t\tstyle=\"width : 30em;\"\n\t\t\t\t\tname=\"subject\" value=\"{$subject}\" id=\"subject\">";
        print "</td></tr>";
        print "<tr><td colspan='2'><textarea dojoType=\"dijit.form.SimpleTextarea\" style='font-size : 12px; width : 100%' rows=\"20\"\n\t\t\t\tname='content'>{$content}</textarea>";
        print "</td></tr></table>";
        print "<div class='dlgButtons'>";
        print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('emailArticleDlg').execute()\">" . __('Send e-mail') . "</button> ";
        print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('emailArticleDlg').hide()\">" . __('Cancel') . "</button>";
        print "</div>";
        //return;
    }
    if ($id == "generatedFeed") {
        print "<title>" . __('View as RSS') . "</title>";
        print "<content><![CDATA[";
        $params = explode(":", $param, 3);
        $feed_id = db_escape_string($params[0]);
        $is_cat = (bool) $params[1];
        $key = get_feed_access_key($link, $feed_id, $is_cat);
        $url_path = htmlspecialchars($params[2]) . "&key=" . $key;
        print __("You can view this feed as RSS using the following URL:");
        print "<div class=\"tagCloudContainer\">";
        print "<a id='gen_feed_url' href='{$url_path}' target='_blank'>{$url_path}</a>";
        print "</div>";
        print "<div align='center'>";
        print "<button dojoType=\"dijit.form.Button\" onclick=\"return genUrlChangeKey('{$feed_id}', '{$is_cat}')\">" . __('Generate new URL') . "</button> ";
        print "<button dojoType=\"dijit.form.Button\" onclick=\"return closeInfoBox()\">" . __('Close this window') . "</button>";
        print "</div>";
        print "]]></content>";
        //return;
    }
    if ($id == "newVersion") {
        $version_data = check_for_update($link);
        $version = $version_data['version'];
        $id = $version_data['version_id'];
        print "<div class='tagCloudContainer'>";
        print T_sprintf("New version of Tiny Tiny RSS is available (%s).", "<b>{$version}</b>");
        print "</div>";
        $details = "http://tt-rss.org/redmine/versions/show/{$id}";
        $download = "http://tt-rss.org/#Download";
        print "<div style='text-align : center'>";
        print "<button dojoType=\"dijit.form.Button\"\n\t\t\t\tonclick=\"return window.open('{$details}')\">" . __("Details") . "</button>";
        print "<button dojoType=\"dijit.form.Button\"\n\t\t\t\tonclick=\"return window.open('{$download}')\">" . __("Download") . "</button>";
        print "<button dojoType=\"dijit.form.Button\"\n\t\t\t\tonclick=\"return dijit.byId('newVersionDlg').hide()\">" . __('Close this window') . "</button>";
        print "</div>";
    }
    if ($id == "customizeCSS") {
        $value = get_pref($link, "USER_STYLESHEET");
        $value = str_replace("<br/>", "\n", $value);
        print T_sprintf("You can override colors, fonts and layout of your currently selected theme with custom CSS declarations here. <a target=\"_blank\" class=\"visibleLink\" href=\"%s\">This file</a> can be used as a baseline.", "tt-rss.css");
        print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
        print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"subop\" value=\"setpref\">";
        print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"key\" value=\"USER_STYLESHEET\">";
        print "<table width='100%'><tr><td>";
        print "<textarea dojoType=\"dijit.form.SimpleTextarea\"\n\t\t\t\tstyle='font-size : 12px; width : 100%; height: 200px;'\n\t\t\t\tplaceHolder='body#ttrssMain { font-size : 14px; };'\n\t\t\t\tname='value'>{$value}</textarea>";
        print "</td></tr></table>";
        print "<div class='dlgButtons'>";
        print "<button dojoType=\"dijit.form.Button\"\n\t\t\t\tonclick=\"dijit.byId('cssEditDlg').execute()\">" . __('Save') . "</button> ";
        print "<button dojoType=\"dijit.form.Button\"\n\t\t\t\tonclick=\"dijit.byId('cssEditDlg').hide()\">" . __('Cancel') . "</button>";
        print "</div>";
    }
    if ($id == "editArticleNote") {
        $result = db_query($link, "SELECT note FROM ttrss_user_entries WHERE\n\t\t\t\tref_id = '{$param}' AND owner_uid = " . $_SESSION['uid']);
        $note = db_fetch_result($result, 0, "note");
        print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"id\" value=\"{$param}\">";
        print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
        print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"subop\" value=\"setNote\">";
        print "<table width='100%'><tr><td>";
        print "<textarea dojoType=\"dijit.form.SimpleTextarea\"\n\t\t\t\tstyle='font-size : 12px; width : 100%; height: 100px;'\n\t\t\t\tplaceHolder='body#ttrssMain { font-size : 14px; };'\n\t\t\t\tname='note'>{$note}</textarea>";
        print "</td></tr></table>";
        print "<div class='dlgButtons'>";
        print "<button dojoType=\"dijit.form.Button\"\n\t\t\t\tonclick=\"dijit.byId('editNoteDlg').execute()\">" . __('Save') . "</button> ";
        print "<button dojoType=\"dijit.form.Button\"\n\t\t\t\tonclick=\"dijit.byId('editNoteDlg').hide()\">" . __('Cancel') . "</button>";
        print "</div>";
    }
    if ($id == "about") {
        print "<table width='100%'><tr><td align='center'>";
        print "<img src=\"images/logo_big.png\">";
        print "</td>";
        print "<td width='70%'>";
        print "<h1>Tiny Riny RSS</h1>\n\t\t\t\t<strong>Version " . VERSION . "</strong>\n\t\t\t\t<p>Copyright &copy; 2005-" . date('Y') . "\n\t\t\t\t<a target=\"_blank\" class=\"visibleLink\"\n\t\t\t\thref=\"http://fakecake.org/\">Andrew Dolgov</a>\n\t\t\t\tand other contributors.</p>\n\t\t\t\t<p class=\"insensitive\">Licensed under GNU GPL version 2.</p>";
        print "<p class=\"insensitive\">\n\t\t\t\t<a class=\"visibleLink\" target=\"_blank\"\n\t\t\t\t\thref=\"http://tt-rss.org/\">Official site</a> &mdash;\n\t\t\t\t<a href=\"http://tt-rss.org/redmine/wiki/tt-rss/Donate\"\n\t\t\t\ttarget=\"_blank\" class=\"visibleLink\">\n\t\t\t\tSupport the project.</a></p>";
        print "</td></tr>";
        print "</table>";
        print "<div align='center'>";
        print "<button dojoType=\"dijit.form.Button\"\n\t\t\t\ttype=\"submit\">" . __('Close this window') . "</button>";
        print "</div>";
    }
    if ($id == "addInstance") {
        print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\"  name=\"op\" value=\"pref-instances\">";
        print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\"  name=\"subop\" value=\"add\">";
        print "<div class=\"dlgSec\">" . __("Instance") . "</div>";
        print "<div class=\"dlgSecCont\">";
        /* URL */
        print __("URL:") . " ";
        print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\"\n\t\t\t\tplaceHolder=\"" . __("Instance URL") . "\"\n\t\t\t\tregExp='^(http|https)://.*'\n\t\t\t\tstyle=\"font-size : 16px; width: 20em\" name=\"access_url\">";
        print "<hr/>";
        $access_key = sha1(uniqid(rand(), true));
        /* Access key */
        print __("Access key:") . " ";
        print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\"\n\t\t\t\tplaceHolder=\"" . __("Access key") . "\" regExp='\\w{40}'\n\t\t\t\tstyle=\"width: 20em\" name=\"access_key\" id=\"instance_add_key\"\n\t\t\t\tvalue=\"{$access_key}\">";
        print "<p class='insensitive'>" . __("Use one access key for both linked instances.");
        print "</div>";
        print "<div class=\"dlgButtons\">\n\t\t\t\t<div style='float : left'>\n\t\t\t\t\t<button dojoType=\"dijit.form.Button\"\n\t\t\t\t\t\tonclick=\"return dijit.byId('instanceAddDlg').regenKey()\">" . __('Generate new key') . "</button>\n\t\t\t\t</div>\n\t\t\t\t<button dojoType=\"dijit.form.Button\"\n\t\t\t\t\tonclick=\"return dijit.byId('instanceAddDlg').execute()\">" . __('Create link') . "</button>\n\t\t\t\t<button dojoType=\"dijit.form.Button\"\n\t\t\t\t\tonclick=\"return dijit.byId('instanceAddDlg').hide()\"\">" . __('Cancel') . "</button></div>";
        return;
    }
    if ($id == "shareArticle") {
        $result = db_query($link, "SELECT uuid, ref_id FROM ttrss_user_entries WHERE int_id = '{$param}'\n\t\t\t\tAND owner_uid = " . $_SESSION['uid']);
        if (db_num_rows($result) == 0) {
            print "Article not found.";
        } else {
            $uuid = db_fetch_result($result, 0, "uuid");
            $ref_id = db_fetch_result($result, 0, "ref_id");
            if (!$uuid) {
                $uuid = db_escape_string(sha1(uniqid(rand(), true)));
                db_query($link, "UPDATE ttrss_user_entries SET uuid = '{$uuid}' WHERE int_id = '{$param}'\n\t\t\t\t\t\tAND owner_uid = " . $_SESSION['uid']);
            }
            print __("You can share this article by the following unique URL:");
            $url_path = get_self_url_prefix();
            $url_path .= "/public.php?op=share&key={$uuid}";
            print "<div class=\"tagCloudContainer\">";
            print "<a id='pub_opml_url' href='{$url_path}' target='_blank'>{$url_path}</a>";
            print "</div>";
            /* if (!label_find_id($link, __('Shared'), $_SESSION["uid"]))
            					label_create($link, __('Shared'), $_SESSION["uid"]);
            
            				label_add_article($link, $ref_id, __('Shared'), $_SESSION['uid']); */
        }
        print "<div align='center'>";
        print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('shareArticleDlg').hide()\">" . __('Close this window') . "</button>";
        print "</div>";
        return;
    }
    print "</dlg>";
}
function prepare_headlines_digest($link, $user_id, $days = 1, $limit = 1000)
{
    require_once "lib/MiniTemplator.class.php";
    $tpl = new MiniTemplator();
    $tpl_t = new MiniTemplator();
    $tpl->readTemplateFromFile("templates/digest_template_html.txt");
    $tpl_t->readTemplateFromFile("templates/digest_template.txt");
    $user_tz_string = get_pref($link, 'USER_TIMEZONE', $user_id);
    $local_ts = convert_timestamp(time(), 'UTC', $user_tz_string);
    $tpl->setVariable('CUR_DATE', date('Y/m/d', $local_ts));
    $tpl->setVariable('CUR_TIME', date('G:i', $local_ts));
    $tpl_t->setVariable('CUR_DATE', date('Y/m/d', $local_ts));
    $tpl_t->setVariable('CUR_TIME', date('G:i', $local_ts));
    $affected_ids = array();
    if (DB_TYPE == "pgsql") {
        $interval_query = "ttrss_entries.date_updated > NOW() - INTERVAL '{$days} days'";
    } else {
        if (DB_TYPE == "mysql") {
            $interval_query = "ttrss_entries.date_updated > DATE_SUB(NOW(), INTERVAL {$days} DAY)";
        }
    }
    $result = db_query($link, "SELECT ttrss_entries.title,\n\t\t\t\tttrss_feeds.title AS feed_title,\n\t\t\t\tCOALESCE(ttrss_feed_categories.title, '" . __('Uncategorized') . "') AS cat_title,\n\t\t\t\tdate_updated,\n\t\t\t\tttrss_user_entries.ref_id,\n\t\t\t\tlink,\n\t\t\t\tscore,\n\t\t\t\tcontent,\n\t\t\t\t" . SUBSTRING_FOR_DATE . "(last_updated,1,19) AS last_updated\n\t\t\tFROM\n\t\t\t\tttrss_user_entries,ttrss_entries,ttrss_feeds\n\t\t\tLEFT JOIN\n\t\t\t\tttrss_feed_categories ON (cat_id = ttrss_feed_categories.id)\n\t\t\tWHERE\n\t\t\t\tref_id = ttrss_entries.id AND feed_id = ttrss_feeds.id\n\t\t\t\tAND include_in_digest = true\n\t\t\t\tAND {$interval_query}\n\t\t\t\tAND ttrss_user_entries.owner_uid = {$user_id}\n\t\t\t\tAND unread = true\n\t\t\t\tAND score >= 0\n\t\t\tORDER BY ttrss_feed_categories.title, ttrss_feeds.title, score DESC, date_updated DESC\n\t\t\tLIMIT {$limit}");
    $cur_feed_title = "";
    $headlines_count = db_num_rows($result);
    $headlines = array();
    while ($line = db_fetch_assoc($result)) {
        array_push($headlines, $line);
    }
    for ($i = 0; $i < sizeof($headlines); $i++) {
        $line = $headlines[$i];
        array_push($affected_ids, $line["ref_id"]);
        $updated = make_local_datetime($link, $line['last_updated'], false, $user_id);
        /*			if ($line["score"] != 0) {
        				if ($line["score"] > 0) $line["score"] = '+' . $line["score"];
        
        				$line["title"] .= " (".$line['score'].")";
        			} */
        if (get_pref($link, 'ENABLE_FEED_CATS', $user_id)) {
            $line['feed_title'] = $line['cat_title'] . " / " . $line['feed_title'];
        }
        $tpl->setVariable('FEED_TITLE', $line["feed_title"]);
        $tpl->setVariable('ARTICLE_TITLE', $line["title"]);
        $tpl->setVariable('ARTICLE_LINK', $line["link"]);
        $tpl->setVariable('ARTICLE_UPDATED', $updated);
        $tpl->setVariable('ARTICLE_EXCERPT', truncate_string(strip_tags($line["content"]), 300));
        //			$tpl->setVariable('ARTICLE_CONTENT',
        //				strip_tags($article_content));
        $tpl->addBlock('article');
        $tpl_t->setVariable('FEED_TITLE', $line["feed_title"]);
        $tpl_t->setVariable('ARTICLE_TITLE', $line["title"]);
        $tpl_t->setVariable('ARTICLE_LINK', $line["link"]);
        $tpl_t->setVariable('ARTICLE_UPDATED', $updated);
        //			$tpl_t->setVariable('ARTICLE_EXCERPT',
        //				truncate_string(strip_tags($line["excerpt"]), 100));
        $tpl_t->addBlock('article');
        if ($headlines[$i]['feed_title'] != $headlines[$i + 1]['feed_title']) {
            $tpl->addBlock('feed');
            $tpl_t->addBlock('feed');
        }
    }
    $tpl->addBlock('digest');
    $tpl->generateOutputToString($tmp);
    $tpl_t->addBlock('digest');
    $tpl_t->generateOutputToString($tmp_t);
    return array($tmp, $headlines_count, $affected_ids, $tmp_t);
}
예제 #12
0
function render_headlines($link)
{
    $feed = db_escape_string($_GET["id"]);
    $limit = db_escape_string($_GET["limit"]);
    $view_mode = db_escape_string($_GET["viewmode"]);
    $cat_view = db_escape_string($_GET["cat"]);
    $subop = $_GET["subop"];
    $catchup_op = $_GET["catchup_op"];
    if (!$view_mode) {
        if ($_SESSION["mobile:viewmode"]) {
            $view_mode = $_SESSION["mobile:viewmode"];
        } else {
            $view_mode = "adaptive";
        }
    }
    $_SESSION["mobile:viewmode"] = $view_mode;
    if (!$limit) {
        $limit = 30;
    }
    if (!$feed) {
        $feed = 0;
    }
    if (preg_match("/^-?[0-9][0-9]*\$/", $feed) != false) {
        $result = db_query($link, "SELECT rtl_content FROM ttrss_feeds\n\t\t\t\tWHERE id = '{$feed}' AND owner_uid = " . $_SESSION["uid"]);
        if (db_num_rows($result) == 1) {
            $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content"));
        } else {
            $rtl_content = false;
        }
        if ($rtl_content) {
            $rtl_tag = "dir=\"RTL\"";
        } else {
            $rtl_tag = "";
        }
    } else {
        $rtl_content = false;
        $rtl_tag = "";
    }
    print "<div id=\"headlines\" {$rtl_tag}>";
    if ($subop == "ForceUpdate" && sprintf("%d", $feed) > 0) {
        update_generic_feed($link, $feed, $cat_view, true);
    }
    if ($subop == "MarkAllRead" || $catchup_op == "feed") {
        catchup_feed($link, $feed, $cat_view);
    }
    if ($catchup_op == "selection") {
        if (is_array($_GET["sel_ids"])) {
            $ids_to_mark = array_keys($_GET["sel_ids"]);
            if ($ids_to_mark) {
                foreach ($ids_to_mark as $id) {
                    db_query($link, "UPDATE ttrss_user_entries SET \n\t\t\t\t\t\t\tunread = false,last_read = NOW()\n\t\t\t\t\t\t\tWHERE ref_id = '{$id}' AND owner_uid = " . $_SESSION["uid"]);
                }
            }
        }
    }
    if ($subop == "MarkPageRead" || $catchup_op == "page") {
        $ids_to_mark = $_SESSION["last_page_ids.{$feed}"];
        if ($ids_to_mark) {
            foreach ($ids_to_mark as $id) {
                db_query($link, "UPDATE ttrss_user_entries SET \n\t\t\t\t\t\tunread = false,last_read = NOW()\n\t\t\t\t\t\tWHERE ref_id = '{$id}' AND owner_uid = " . $_SESSION["uid"]);
            }
        }
    }
    /// START /////////////////////////////////////////////////////////////////////////////////
    $search = db_escape_string($_GET["query"]);
    $search_mode = db_escape_string($_GET["search_mode"]);
    $match_on = db_escape_string($_GET["match_on"]);
    if (!$match_on) {
        $match_on = "both";
    }
    $real_offset = $offset * $limit;
    if ($_GET["debug"]) {
        $timing_info = print_checkpoint("H0", $timing_info);
    }
    $qfh_ret = queryFeedHeadlines($link, $feed, $limit, $view_mode, $cat_view, $search, $search_mode, $match_on, false, $real_offset);
    if ($_GET["debug"]) {
        $timing_info = print_checkpoint("H1", $timing_info);
    }
    $result = $qfh_ret[0];
    $feed_title = $qfh_ret[1];
    $feed_site_url = $qfh_ret[2];
    $last_error = $qfh_ret[3];
    /// STOP //////////////////////////////////////////////////////////////////////////////////
    if (!$result) {
        print "<div align='center'>" . __("Could not display feed (query failed). Please check label match syntax or local configuration.") . "</div>";
        return;
    }
    print "<div id=\"heading\">";
    #		if (!$cat_view && file_exists("../icons/$feed.ico") && filesize("../icons/$feed.ico") > 0) {
    #			print "<img class=\"feedIcon\" src=\"../icons/$feed.ico\">";
    #		}
    print "{$feed_title} <span id=\"headingAddon\">(";
    print "<a href=\"index.php\">" . __("Back") . "</a>, ";
    print "<a href=\"index.php?go=sform&aid={$feed}&ic={$cat_view}\">" . __("Search") . "</a>, ";
    print "<a href=\"index.php?go=vf&id={$feed}&subop=ForceUpdate\">" . __("Update") . "</a>";
    #		print "Mark as read: ";
    #		print "<a href=\"index.php?go=vf&id=$feed&subop=MarkAsRead\">Page</a>, ";
    #		print "<a href=\"index.php?go=vf&id=$feed&subop=MarkAllRead\">Feed</a>";
    print ")</span>";
    print "&nbsp;" . __('View:');
    print "<form style=\"display : inline\" method=\"GET\" action=\"index.php\">";
    /* print "<select name=\"viewmode\">
    			<option selected value=\"adaptive\"> " . __('Adaptive') . "</option>
    			<option value=\"all_articles\">" . __('All Articles') . "</option>
    			<option value=\"marked\">" . __('Starred') . "</option>
    			<option value=\"unread\">" . __('Unread') . "</option>
    			</select>"; */
    $sel_values = array("adaptive" => __("Adaptive"), "all_articles" => __("All Articles"), "unread" => __("Unread"), "marked" => __("Starred"));
    print_select_hash("viewmode", $view_mode, $sel_values);
    print "<input type=\"hidden\" name=\"id\" value=\"{$feed}\">\n\t\t<input type=\"hidden\" name=\"cat\" value=\"{$cat_view}\">\n\t\t<input type=\"hidden\" name=\"go\" value=\"vf\">\n\t\t<input type=\"submit\" value=\"" . __('Refresh') . "\">";
    print "</form>";
    print "</div>";
    if (db_num_rows($result) > 0) {
        print "<form method=\"GET\" action=\"index.php\">";
        print "<input type=\"hidden\" name=\"go\" value=\"vf\">";
        print "<input type=\"hidden\" name=\"id\" value=\"{$feed}\">";
        print "<input type=\"hidden\" name=\"cat\" value=\"{$cat_view}\">";
        print "<ul class=\"headlines\" id=\"headlines\">";
        $page_art_ids = array();
        $lnum = 0;
        error_reporting(DEFAULT_ERROR_LEVEL);
        $num_unread = 0;
        while ($line = db_fetch_assoc($result)) {
            $class = $lnum % 2 ? "even" : "odd";
            $id = $line["id"];
            $feed_id = $line["feed_id"];
            array_push($page_art_ids, $id);
            if ($line["last_read"] == "" && ($line["unread"] != "t" && $line["unread"] != "1")) {
                $update_pic = "<img id='FUPDPIC-{$id}' src=\"images/updated.png\" \n\t\t\t\t\t\talt=\"" . __("Updated") . "\">";
            } else {
                $update_pic = "<img id='FUPDPIC-{$id}' src=\"images/blank_icon.gif\" \n\t\t\t\t\t\talt=\"" . __("Updated") . "\">";
            }
            if ($line["unread"] == "t" || $line["unread"] == "1") {
                $class .= "Unread";
                ++$num_unread;
                $is_unread = true;
            } else {
                $is_unread = false;
            }
            if ($line["marked"] == "t" || $line["marked"] == "1") {
                $marked_pic = "<img alt=\"S\" class='marked' src=\"../../images/mark_set.png\">";
            } else {
                $marked_pic = "<img alt=\"s\" class='marked' src=\"../../images/mark_unset.png\">";
            }
            if ($line["published"] == "t" || $line["published"] == "1") {
                $published_pic = "<img alt=\"P\" class='marked' src=\"../../images/pub_set.gif\">";
            } else {
                $published_pic = "<img alt=\"p\" class='marked' src=\"../../images/pub_unset.gif\">";
            }
            $content_link = "<a href=\"?go=view&id={$id}&cat={$cat_view}&ret_feed={$feed}&feed={$feed_id}\">" . $line["title"] . "</a>";
            $updated_fmt = make_local_datetime($link, $line['updated'], false);
            print "<li class='{$class}' id=\"HROW-{$id}\">";
            print "<input type=\"checkbox\" name=\"sel_ids[{$id}]\"\n\t\t\t\t  \tid=\"HSCB-{$id}\" onchange=\"toggleSelectRow(this, {$id})\">";
            print "<a href=\"?go=vf&id={$feed}&ts={$id}&cat={$cat_view}\">{$marked_pic}</a>";
            print "<a href=\"?go=vf&id={$feed}&tp={$id}&cat={$cat_view}\">{$published_pic}</a>";
            print $content_link;
            if ($line["feed_title"]) {
                print " (<a href='?go=vf&id={$feed_id}'>" . $line["feed_title"] . "</a>)";
            }
            print "<span class='hlUpdated'> ({$updated_fmt})</span>";
            print "</li>";
            ++$lnum;
        }
        print "</ul>";
        print "<div class='footerAddon'>";
        $_SESSION["last_page_ids.{$feed}"] = $page_art_ids;
        /*			print "<a href=\"index.php?go=vf&id=$feed&subop=MarkPageRead\">Page</a>, ";
        			print "<a href=\"index.php?go=vf&id=$feed&subop=MarkAllRead\">Feed</a></div>"; */
        print "Select: \n\t\t\t\t<a href=\"javascript:selectHeadlines(1)\">" . __("All") . "</a>,\n\t\t\t\t<a href=\"javascript:selectHeadlines(2)\">" . __("Unread") . "</a>,\n\t\t\t\t<a href=\"javascript:selectHeadlines(3)\">" . __("None") . "</a>,\n\t\t\t\t<a href=\"javascript:selectHeadlines(4)\">" . __("Invert") . "</a>";
        print " ";
        print "<select name=\"catchup_op\">\n\t\t\t\t<option value=\"selection\">" . __("Selection") . "</option>\n\t\t\t\t<option value=\"page\">" . __("Page") . "</option>\n\t\t\t\t<option value=\"feed\">" . __("Entire feed") . "</option>\n\t\t\t</select>\n\t\t\t<input type=\"hidden\" name=\"cat\" value=\"{$cat_view}\">\n\t\t\t<input type=\"submit\" value=\"" . __("Mark as read") . "\">";
        print "</form>";
    } else {
        print "<div align='center'>No articles found.</div>";
    }
}
예제 #13
0
function module_pref_instances($link)
{
    if (!SINGLE_USER_MODE && $_SESSION["access_level"] < 10) {
        print __("Your access level is insufficient to open this tab.");
        return;
    }
    $subop = $_REQUEST['subop'];
    if ($subop == "remove") {
        $ids = db_escape_string($_REQUEST['ids']);
        db_query($link, "DELETE FROM ttrss_linked_instances WHERE\n\t\t\t\tid IN ({$ids})");
        return;
    }
    if ($subop == "add") {
        $id = db_escape_string($_REQUEST["id"]);
        $access_url = db_escape_string($_REQUEST["access_url"]);
        $access_key = db_escape_string($_REQUEST["access_key"]);
        db_query($link, "BEGIN");
        $result = db_query($link, "SELECT id FROM ttrss_linked_instances\n\t\t\t\tWHERE access_url = '{$access_url}'");
        if (db_num_rows($result) == 0) {
            db_query($link, "INSERT INTO ttrss_linked_instances\n\t\t\t\t\t(access_url, access_key, last_connected, last_status_in, last_status_out)\n\t\t\t\t\tVALUES\n\t\t\t\t\t('{$access_url}', '{$access_key}', '1970-01-01', -1, -1)");
        }
        db_query($link, "COMMIT");
        return;
    }
    if ($subop == "edit") {
        $id = db_escape_string($_REQUEST["id"]);
        $result = db_query($link, "SELECT * FROM ttrss_linked_instances WHERE\n\t\t\t\tid = '{$id}'");
        print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\"  name=\"id\" value=\"{$id}\">";
        print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\"  name=\"op\" value=\"pref-instances\">";
        print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\"  name=\"subop\" value=\"editSave\">";
        print "<div class=\"dlgSec\">" . __("Instance") . "</div>";
        print "<div class=\"dlgSecCont\">";
        /* URL */
        $access_url = htmlspecialchars(db_fetch_result($result, 0, "access_url"));
        print __("URL:") . " ";
        print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\"\n\t\t\t\tplaceHolder=\"" . __("Instance URL") . "\"\n\t\t\t\tregExp='^(http|https)://.*'\n\t\t\t\tstyle=\"font-size : 16px; width: 20em\" name=\"access_url\"\n\t\t\t\tvalue=\"{$access_url}\">";
        print "<hr/>";
        $access_key = htmlspecialchars(db_fetch_result($result, 0, "access_key"));
        /* Access key */
        print __("Access key:") . " ";
        print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\"\n\t\t\t\tplaceHolder=\"" . __("Access key") . "\" regExp='\\w{40}'\n\t\t\t\tstyle=\"width: 20em\" name=\"access_key\" id=\"instance_edit_key\"\n\t\t\t\tvalue=\"{$access_key}\">";
        print "<p class='insensitive'>" . __("Use one access key for both linked instances.");
        print "</div>";
        print "<div class=\"dlgButtons\">\n\t\t\t\t<div style='float : left'>\n\t\t\t\t\t<button dojoType=\"dijit.form.Button\"\n\t\t\t\t\t\tonclick=\"return dijit.byId('instanceEditDlg').regenKey()\">" . __('Generate new key') . "</button>\n\t\t\t\t</div>\n\t\t\t\t<button dojoType=\"dijit.form.Button\"\n\t\t\t\t\tonclick=\"return dijit.byId('instanceEditDlg').execute()\">" . __('Save') . "</button>\n\t\t\t\t<button dojoType=\"dijit.form.Button\"\n\t\t\t\t\tonclick=\"return dijit.byId('instanceEditDlg').hide()\"\">" . __('Cancel') . "</button></div>";
        return;
    }
    if ($subop == "editSave") {
        $id = db_escape_string($_REQUEST["id"]);
        $access_url = db_escape_string($_REQUEST["access_url"]);
        $access_key = db_escape_string($_REQUEST["access_key"]);
        db_query($link, "UPDATE ttrss_linked_instances SET\n\t\t\t\taccess_key = '{$access_key}', access_url = '{$access_url}',\n\t\t\t\tlast_connected = '1970-01-01'\n\t\t\t\tWHERE id = '{$id}'");
        return;
    }
    if (!function_exists('curl_init')) {
        print "<div style='padding : 1em'>";
        print_error("This functionality requires CURL functions. Please enable CURL in your PHP configuration (you might also want to disable open_basedir in php.ini) and reload this page.");
        print "</div>";
    }
    print "<div id=\"pref-instance-wrap\" dojoType=\"dijit.layout.BorderContainer\" gutters=\"false\">";
    print "<div id=\"pref-instance-header\" dojoType=\"dijit.layout.ContentPane\" region=\"top\">";
    print "<div id=\"pref-instance-toolbar\" dojoType=\"dijit.Toolbar\">";
    $sort = db_escape_string($_REQUEST["sort"]);
    if (!$sort || $sort == "undefined") {
        $sort = "access_url";
    }
    print "<div dojoType=\"dijit.form.DropDownButton\">" . "<span>" . __('Select') . "</span>";
    print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
    print "<div onclick=\"selectTableRows('prefInstanceList', 'all')\"\n\t\t\tdojoType=\"dijit.MenuItem\">" . __('All') . "</div>";
    print "<div onclick=\"selectTableRows('prefInstanceList', 'none')\"\n\t\t\tdojoType=\"dijit.MenuItem\">" . __('None') . "</div>";
    print "</div></div>";
    print "<button dojoType=\"dijit.form.Button\" onclick=\"addInstance()\">" . __('Link instance') . "</button>";
    print "<button dojoType=\"dijit.form.Button\" onclick=\"editSelectedInstance()\">" . __('Edit') . "</button>";
    print "<button dojoType=\"dijit.form.Button\" onclick=\"removeSelectedInstances()\">" . __('Remove') . "</button>";
    print "</div>";
    #toolbar
    $result = db_query($link, "SELECT *,\n\t\t\t(SELECT COUNT(*) FROM ttrss_linked_feeds\n\t\t\t\tWHERE instance_id = ttrss_linked_instances.id) AS num_feeds\n\t\t\tFROM ttrss_linked_instances\n\t\t\tORDER BY {$sort}");
    print "<p class=\"insensitive\" style='margin-left : 1em;'>" . __("You can connect other instances of Tiny Tiny RSS to this one to share Popular feeds. Link to this instance of Tiny Tiny RSS by using this URL:");
    print " <a href=\"#\" onclick=\"alert('" . htmlspecialchars(get_self_url_prefix()) . "')\">(display url)</a>";
    print "<p><table width='100%' id='prefInstanceList' class='prefInstanceList' cellspacing='0'>";
    print "<tr class=\"title\">\n\t\t\t<td align='center' width=\"5%\">&nbsp;</td>\n\t\t\t<td width=''><a href=\"#\" onclick=\"updateInstanceList('access_url')\">" . __('Instance URL') . "</a></td>\n\t\t\t<td width='20%'><a href=\"#\" onclick=\"updateInstanceList('access_key')\">" . __('Access key') . "</a></td>\n\t\t\t<td width='10%'><a href=\"#\" onclick=\"updateUsersList('last_connected')\">" . __('Last connected') . "</a></td>\n\t\t\t<td width='10%'><a href=\"#\" onclick=\"updateUsersList('num_feeds')\">" . __('Stored feeds') . "</a></td>\n\t\t\t</tr>";
    $lnum = 0;
    while ($line = db_fetch_assoc($result)) {
        $class = $lnum % 2 ? "even" : "odd";
        $id = $line['id'];
        $this_row_id = "id=\"LIRR-{$id}\"";
        $line["last_connected"] = make_local_datetime($link, $line["last_connected"], false);
        print "<tr class=\"{$class}\" {$this_row_id}>";
        print "<td align='center'><input onclick='toggleSelectRow(this);'\n\t\t\t\ttype=\"checkbox\" id=\"LICHK-{$id}\"></td>";
        $onclick = "onclick='editInstance({$id}, event)' title='" . __('Click to edit') . "'";
        $access_key = mb_substr($line['access_key'], 0, 4) . '...' . mb_substr($line['access_key'], -4);
        print "<td {$onclick}>" . htmlspecialchars($line['access_url']) . "</td>";
        print "<td {$onclick}>" . htmlspecialchars($access_key) . "</td>";
        print "<td {$onclick}>" . htmlspecialchars($line['last_connected']) . "</td>";
        print "<td {$onclick}>" . htmlspecialchars($line['num_feeds']) . "</td>";
        print "</tr>";
        ++$lnum;
    }
    print "</table>";
    print "</div>";
    #pane
    print "</div>";
    #container
}
예제 #14
0
function format_article($link, $id, $mark_as_read = true, $zoom_mode = false, $owner_uid = false)
{
    if (!$owner_uid) {
        $owner_uid = $_SESSION["uid"];
    }
    $rv = array();
    $rv['id'] = $id;
    /* we can figure out feed_id from article id anyway, why do we
     * pass feed_id here? let's ignore the argument :( */
    $result = db_query($link, "SELECT feed_id FROM ttrss_user_entries\n\t\t\tWHERE ref_id = '{$id}'");
    $feed_id = (int) db_fetch_result($result, 0, "feed_id");
    $rv['feed_id'] = $feed_id;
    //if (!$zoom_mode) { print "<article id='$id'><![CDATA["; };
    if ($mark_as_read) {
        $result = db_query($link, "UPDATE ttrss_user_entries\n\t\t\t\tSET unread = false,last_read = NOW()\n\t\t\t\tWHERE ref_id = '{$id}' AND owner_uid = {$owner_uid}");
        ccache_update($link, $feed_id, $owner_uid);
    }
    $result = db_query($link, "SELECT id,title,link,content,feed_id,comments,int_id,\n\t\t\t" . SUBSTRING_FOR_DATE . "(updated,1,16) as updated,\n\t\t\t(SELECT site_url FROM ttrss_feeds WHERE id = feed_id) as site_url,\n\t\t\tnum_comments,\n\t\t\ttag_cache,\n\t\t\tauthor,\n\t\t\torig_feed_id,\n\t\t\tnote,\n\t\t\tcached_content\n\t\t\tFROM ttrss_entries,ttrss_user_entries\n\t\t\tWHERE\tid = '{$id}' AND ref_id = id AND owner_uid = {$owner_uid}");
    if ($result) {
        $line = db_fetch_assoc($result);
        $tag_cache = $line["tag_cache"];
        $line["tags"] = get_article_tags($link, $id, $owner_uid, $line["tag_cache"]);
        unset($line["tag_cache"]);
        $line["content"] = sanitize($link, $line["content"], false, $owner_uid, $line["site_url"]);
        global $pluginhost;
        foreach ($pluginhost->get_hooks($pluginhost::HOOK_RENDER_ARTICLE) as $p) {
            $line = $p->hook_render_article($line);
        }
        $num_comments = $line["num_comments"];
        $entry_comments = "";
        if ($num_comments > 0) {
            if ($line["comments"]) {
                $comments_url = htmlspecialchars($line["comments"]);
            } else {
                $comments_url = htmlspecialchars($line["link"]);
            }
            $entry_comments = "<a target='_blank' href=\"{$comments_url}\">{$num_comments} comments</a>";
        } else {
            if ($line["comments"] && $line["link"] != $line["comments"]) {
                $entry_comments = "<a target='_blank' href=\"" . htmlspecialchars($line["comments"]) . "\">comments</a>";
            }
        }
        if ($zoom_mode) {
            header("Content-Type: text/html");
            $rv['content'] .= "<html><head>\n\t\t\t\t\t\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\n\t\t\t\t\t\t<title>Tiny Tiny RSS - " . $line["title"] . "</title>\n\t\t\t\t\t\t<link rel=\"stylesheet\" type=\"text/css\" href=\"tt-rss.css\">\n\t\t\t\t\t</head><body>";
        }
        $title_escaped = htmlspecialchars($line['title']);
        $rv['content'] .= "<div id=\"PTITLE-FULL-{$id}\" style=\"display : none\">" . strip_tags($line['title']) . "</div>";
        $rv['content'] .= "<div class=\"postReply\" id=\"POST-{$id}\">";
        $rv['content'] .= "<div class=\"postHeader\" id=\"POSTHDR-{$id}\">";
        $entry_author = $line["author"];
        if ($entry_author) {
            $entry_author = __(" - ") . $entry_author;
        }
        $parsed_updated = make_local_datetime($link, $line["updated"], true, $owner_uid, true);
        $rv['content'] .= "<div class=\"postDate\">{$parsed_updated}</div>";
        if ($line["link"]) {
            $rv['content'] .= "<div class='postTitle'><a target='_blank'\n\t\t\t\t\ttitle=\"" . htmlspecialchars($line['title']) . "\"\n\t\t\t\t\thref=\"" . htmlspecialchars($line["link"]) . "\">" . $line["title"] . "<span class='author'>{$entry_author}</span></a></div>";
        } else {
            $rv['content'] .= "<div class='postTitle'>" . $line["title"] . "{$entry_author}</div>";
        }
        $tags_str = format_tags_string($line["tags"], $id);
        $tags_str_full = join(", ", $line["tags"]);
        if (!$tags_str_full) {
            $tags_str_full = __("no tags");
        }
        if (!$entry_comments) {
            $entry_comments = "&nbsp;";
        }
        # placeholder
        $rv['content'] .= "<div class='postTags' style='float : right'>\n\t\t\t\t<img src='" . theme_image($link, 'images/tag.png') . "'\n\t\t\t\tclass='tagsPic' alt='Tags' title='Tags'>&nbsp;";
        if (!$zoom_mode) {
            $rv['content'] .= "<span id=\"ATSTR-{$id}\">{$tags_str}</span>\n\t\t\t\t\t<a title=\"" . __('Edit tags for this article') . "\"\n\t\t\t\t\thref=\"#\" onclick=\"editArticleTags({$id}, {$feed_id})\">(+)</a>";
            $rv['content'] .= "<div dojoType=\"dijit.Tooltip\"\n\t\t\t\t\tid=\"ATSTRTIP-{$id}\" connectId=\"ATSTR-{$id}\"\n\t\t\t\t\tposition=\"below\">{$tags_str_full}</div>";
            global $pluginhost;
            foreach ($pluginhost->get_hooks($pluginhost::HOOK_ARTICLE_BUTTON) as $p) {
                $rv['content'] .= $p->hook_article_button($line);
            }
        } else {
            $tags_str = strip_tags($tags_str);
            $rv['content'] .= "<span id=\"ATSTR-{$id}\">{$tags_str}</span>";
        }
        $rv['content'] .= "</div>";
        $rv['content'] .= "<div clear='both'>{$entry_comments}</div>";
        if ($line["orig_feed_id"]) {
            $tmp_result = db_query($link, "SELECT * FROM ttrss_archived_feeds\n\t\t\t\t\tWHERE id = " . $line["orig_feed_id"]);
            if (db_num_rows($tmp_result) != 0) {
                $rv['content'] .= "<div clear='both'>";
                $rv['content'] .= __("Originally from:");
                $rv['content'] .= "&nbsp;";
                $tmp_line = db_fetch_assoc($tmp_result);
                $rv['content'] .= "<a target='_blank'\n\t\t\t\t\t\thref=' " . htmlspecialchars($tmp_line['site_url']) . "'>" . $tmp_line['title'] . "</a>";
                $rv['content'] .= "&nbsp;";
                $rv['content'] .= "<a target='_blank' href='" . htmlspecialchars($tmp_line['feed_url']) . "'>";
                $rv['content'] .= "<img title='" . __('Feed URL') . "'class='tinyFeedIcon' src='images/pub_set.svg'></a>";
                $rv['content'] .= "</div>";
            }
        }
        $rv['content'] .= "</div>";
        $rv['content'] .= "<div id=\"POSTNOTE-{$id}\">";
        if ($line['note']) {
            $rv['content'] .= format_article_note($id, $line['note'], !$zoom_mode);
        }
        $rv['content'] .= "</div>";
        $rv['content'] .= "<div class=\"postContent\">";
        // N-grams
        if (DB_TYPE == "pgsql" and defined('_NGRAM_TITLE_RELATED_THRESHOLD')) {
            $ngram_result = db_query($link, "SELECT id,title FROM\n\t\t\t\t\t\tttrss_entries,ttrss_user_entries\n\t\t\t\t\tWHERE ref_id = id AND updated >= NOW() - INTERVAL '7 day'\n\t\t\t\t\t\tAND similarity(title, '{$title_escaped}') >= " . _NGRAM_TITLE_RELATED_THRESHOLD . "\n\t\t\t\t\t\tAND title != '{$title_escaped}'\n\t\t\t\t\t\tAND owner_uid = {$owner_uid}");
            if (db_num_rows($ngram_result) > 0) {
                $rv['content'] .= "<div dojoType=\"dijit.form.DropDownButton\">" . "<span>" . __('Related') . "</span>";
                $rv['content'] .= "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
                while ($nline = db_fetch_assoc($ngram_result)) {
                    $rv['content'] .= "<div onclick=\"hlOpenInNewTab(null," . $nline['id'] . ")\"\n\t\t\t\t\t\t\tdojoType=\"dijit.MenuItem\">" . $nline['title'] . "</div>";
                }
                $rv['content'] .= "</div></div><br/";
            }
        }
        if ($cache_content && $line["cached_content"] != "") {
            $line["content"] =& $line["cached_content"];
        }
        $rv['content'] .= $line["content"];
        $rv['content'] .= format_article_enclosures($link, $id, $always_display_enclosures, $line["content"]);
        $rv['content'] .= "</div>";
        $rv['content'] .= "</div>";
    }
    if ($zoom_mode) {
        $rv['content'] .= "\n\t\t\t\t<div style=\"text-align : center\">\n\t\t\t\t<button onclick=\"return window.close()\">" . __("Close this window") . "</button></div>";
        $rv['content'] .= "</body></html>";
    }
    return $rv;
}
예제 #15
0
 private function outputFeedList($special = true)
 {
     $feedlist = array();
     $enable_cats = get_pref($this->link, 'ENABLE_FEED_CATS');
     $feedlist['identifier'] = 'id';
     $feedlist['label'] = 'name';
     $feedlist['items'] = array();
     $owner_uid = $_SESSION["uid"];
     /* virtual feeds */
     if ($special) {
         if ($enable_cats) {
             $cat_hidden = get_pref($this->link, "_COLLAPSED_SPECIAL");
             $cat = $this->feedlist_init_cat(-1, $cat_hidden);
         } else {
             $cat['items'] = array();
         }
         foreach (array(-4, -3, -1, -2, 0) as $i) {
             array_push($cat['items'], $this->feedlist_init_feed($i));
         }
         if ($enable_cats) {
             array_push($feedlist['items'], $cat);
         } else {
             $feedlist['items'] = array_merge($feedlist['items'], $cat['items']);
         }
         $result = db_query($this->link, "SELECT * FROM\r\n\t\t\t\tttrss_labels2 WHERE owner_uid = '{$owner_uid}' ORDER by caption");
         if (db_num_rows($result) > 0) {
             if (get_pref($this->link, 'ENABLE_FEED_CATS')) {
                 $cat_hidden = get_pref($this->link, "_COLLAPSED_LABELS");
                 $cat = $this->feedlist_init_cat(-2, $cat_hidden);
             } else {
                 $cat['items'] = array();
             }
             while ($line = db_fetch_assoc($result)) {
                 $label_id = -$line['id'] - 11;
                 $count = getFeedUnread($this->link, $label_id);
                 $feed = $this->feedlist_init_feed($label_id, false, $count);
                 $feed['fg_color'] = $line['fg_color'];
                 $feed['bg_color'] = $line['bg_color'];
                 array_push($cat['items'], $feed);
             }
             if ($enable_cats) {
                 array_push($feedlist['items'], $cat);
             } else {
                 $feedlist['items'] = array_merge($feedlist['items'], $cat['items']);
             }
         }
     }
     /*		if (get_pref($this->link, 'ENABLE_FEED_CATS')) {
     			if (get_pref($this->link, "FEEDS_SORT_BY_UNREAD")) {
     				$order_by_qpart = "order_id,category,unread DESC,title";
     			} else {
     				$order_by_qpart = "order_id,category,title";
     			}
     		} else {
     			if (get_pref($this->link, "FEEDS_SORT_BY_UNREAD")) {
     				$order_by_qpart = "unread DESC,title";
     			} else {
     				$order_by_qpart = "title";
     			}
     		} */
     /* real feeds */
     if ($enable_cats) {
         $order_by_qpart = "ttrss_feed_categories.order_id,category,\r\n\t\t\t\tttrss_feeds.order_id,title";
     } else {
         $order_by_qpart = "title";
     }
     $query = "SELECT ttrss_feeds.id, ttrss_feeds.title,\r\n\t\t\t" . SUBSTRING_FOR_DATE . "(last_updated,1,19) AS last_updated_noms,\r\n\t\t\tcat_id,last_error,\r\n\t\t\tCOALESCE(ttrss_feed_categories.title, '" . __('Uncategorized') . "') AS category,\r\n\t\t\tttrss_feed_categories.collapsed,\r\n\t\t\tvalue AS unread\r\n\t\t\tFROM ttrss_feeds LEFT JOIN ttrss_feed_categories\r\n\t\t\t\tON (ttrss_feed_categories.id = cat_id)\r\n\t\t\tLEFT JOIN ttrss_counters_cache\r\n\t\t\t\tON\r\n\t\t\t\t\t(ttrss_feeds.id = feed_id)\r\n\t\t\tWHERE\r\n\t\t\t\tttrss_feeds.owner_uid = '{$owner_uid}'\r\n\t\t\tORDER BY {$order_by_qpart}";
     $result = db_query($this->link, $query);
     $actid = $_REQUEST["actid"];
     if (db_num_rows($result) > 0) {
         $category = "";
         if (!$enable_cats) {
             $cat['items'] = array();
         } else {
             $cat = false;
         }
         while ($line = db_fetch_assoc($result)) {
             $feed = htmlspecialchars(trim($line["title"]));
             if (!$feed) {
                 $feed = "[Untitled]";
             }
             $feed_id = $line["id"];
             $unread = $line["unread"];
             $cat_id = $line["cat_id"];
             $tmp_category = $line["category"];
             if ($category != $tmp_category && $enable_cats) {
                 $category = $tmp_category;
                 $collapsed = sql_bool_to_bool($line["collapsed"]);
                 // workaround for NULL category
                 if ($category == __("Uncategorized")) {
                     $collapsed = get_pref($this->link, "_COLLAPSED_UNCAT");
                 }
                 if ($cat) {
                     array_push($feedlist['items'], $cat);
                 }
                 $cat = $this->feedlist_init_cat($cat_id, $collapsed);
             }
             $updated = make_local_datetime($this->link, $line["updated_noms"], false);
             array_push($cat['items'], $this->feedlist_init_feed($feed_id, $feed, $unread, $line['last_error'], $updated));
         }
         if ($enable_cats) {
             array_push($feedlist['items'], $cat);
         } else {
             $feedlist['items'] = array_merge($feedlist['items'], $cat['items']);
         }
     }
     return $feedlist;
 }
예제 #16
0
 private function format_headlines_list($feed, $method, $view_mode, $limit, $cat_view, $next_unread_feed, $offset, $vgr_last_feed = false, $override_order = false, $include_children = false)
 {
     $disable_cache = false;
     $reply = array();
     $timing_info = getmicrotime();
     $topmost_article_ids = array();
     if (!$offset) {
         $offset = 0;
     }
     if ($method == "undefined") {
         $method = "";
     }
     $method_split = explode(":", $method);
     if ($method == "ForceUpdate" && $feed && is_numeric($feed) > 0) {
         include "rssfuncs.php";
         update_rss_feed($this->link, $feed, true);
     }
     if ($method_split[0] == "MarkAllReadGR") {
         catchup_feed($this->link, $method_split[1], false);
     }
     // FIXME: might break tag display?
     if (is_numeric($feed) && $feed > 0 && !$cat_view) {
         $result = db_query($this->link, "SELECT id FROM ttrss_feeds WHERE id = '{$feed}' LIMIT 1");
         if (db_num_rows($result) == 0) {
             $reply['content'] = "<div align='center'>" . __('Feed not found.') . "</div>";
         }
     }
     if (is_numeric($feed) && $feed > 0) {
         $result = db_query($this->link, "SELECT rtl_content FROM ttrss_feeds\r\n\t\t\t\tWHERE id = '{$feed}' AND owner_uid = " . $_SESSION["uid"]);
         if (db_num_rows($result) == 1) {
             $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content"));
         } else {
             $rtl_content = false;
         }
         if ($rtl_content) {
             $rtl_tag = "dir=\"RTL\"";
         } else {
             $rtl_tag = "";
         }
     } else {
         $rtl_tag = "";
         $rtl_content = false;
     }
     @($search = db_escape_string($_REQUEST["query"]));
     if ($search) {
         $disable_cache = true;
     }
     @($search_mode = db_escape_string($_REQUEST["search_mode"]));
     @($match_on = db_escape_string($_REQUEST["match_on"]));
     if (!$match_on) {
         $match_on = "both";
     }
     if ($_REQUEST["debug"]) {
         $timing_info = print_checkpoint("H0", $timing_info);
     }
     //		error_log("format_headlines_list: [" . $feed . "] method [" . $method . "]");
     if ($search_mode == '' && $method != '') {
         $search_mode = $method;
     }
     //		error_log("search_mode: " . $search_mode);
     $qfh_ret = queryFeedHeadlines($this->link, $feed, $limit, $view_mode, $cat_view, $search, $search_mode, $match_on, $override_order, $offset, 0, false, 0, $include_children);
     if ($_REQUEST["debug"]) {
         $timing_info = print_checkpoint("H1", $timing_info);
     }
     $result = $qfh_ret[0];
     $feed_title = $qfh_ret[1];
     $feed_site_url = $qfh_ret[2];
     $last_error = $qfh_ret[3];
     $vgroup_last_feed = $vgr_last_feed;
     //		if (!$offset) {
     if (db_num_rows($result) > 0) {
         $reply['toolbar'] = $this->format_headline_subtoolbar($feed_site_url, $feed_title, $feed, $cat_view, $search, $match_on, $search_mode, $view_mode, $last_error);
     }
     //		}
     $headlines_count = db_num_rows($result);
     if (get_pref($this->link, 'COMBINED_DISPLAY_MODE')) {
         $button_plugins = array();
         foreach (explode(",", ARTICLE_BUTTON_PLUGINS) as $p) {
             $pclass = trim("button_{$p}");
             if (class_exists($pclass)) {
                 $plugin = new $pclass($link);
                 array_push($button_plugins, $plugin);
             }
         }
     }
     if (db_num_rows($result) > 0) {
         $lnum = $offset;
         $num_unread = 0;
         $cur_feed_title = '';
         $fresh_intl = get_pref($this->link, "FRESH_ARTICLE_MAX_AGE") * 60 * 60;
         if ($_REQUEST["debug"]) {
             $timing_info = print_checkpoint("PS", $timing_info);
         }
         while ($line = db_fetch_assoc($result)) {
             $class = $lnum % 2 ? "even" : "odd";
             $id = $line["id"];
             $feed_id = $line["feed_id"];
             $label_cache = $line["label_cache"];
             $labels = false;
             if ($label_cache) {
                 $label_cache = json_decode($label_cache, true);
                 if ($label_cache) {
                     if ($label_cache["no-labels"] == 1) {
                         $labels = array();
                     } else {
                         $labels = $label_cache;
                     }
                 }
             }
             if (!is_array($labels)) {
                 $labels = get_article_labels($this->link, $id);
             }
             $labels_str = "<span id=\"HLLCTR-{$id}\">";
             $labels_str .= format_article_labels($labels, $id);
             $labels_str .= "</span>";
             if (count($topmost_article_ids) < 3) {
                 array_push($topmost_article_ids, $id);
             }
             if ($line["last_read"] == "" && !sql_bool_to_bool($line["unread"])) {
                 $update_pic = "<img id='FUPDPIC-{$id}' src=\"" . theme_image($this->link, 'images/updated.png') . "\"\r\n\t\t\t\t\t\talt=\"Updated\">";
             } else {
                 $update_pic = "<img id='FUPDPIC-{$id}' src=\"images/blank_icon.gif\"\r\n\t\t\t\t\t\talt=\"Updated\">";
             }
             if (sql_bool_to_bool($line["unread"]) && time() - strtotime($line["updated_noms"]) < $fresh_intl) {
                 $update_pic = "<img id='FUPDPIC-{$id}' src=\"" . theme_image($this->link, 'images/fresh_sign.png') . "\" alt=\"Fresh\">";
             }
             if ($line["unread"] == "t" || $line["unread"] == "1") {
                 $class .= " Unread";
                 ++$num_unread;
                 $is_unread = true;
             } else {
                 $is_unread = false;
             }
             if ($line["marked"] == "t" || $line["marked"] == "1") {
                 $marked_pic = "<img id=\"FMPIC-{$id}\"\r\n\t\t\t\t\t\tsrc=\"" . theme_image($this->link, 'images/mark_set.png') . "\"\r\n\t\t\t\t\t\tclass=\"markedPic\" alt=\"Unstar article\"\r\n\t\t\t\t\t\tonclick='javascript:toggleMark({$id})'>";
             } else {
                 $marked_pic = "<img id=\"FMPIC-{$id}\"\r\n\t\t\t\t\t\tsrc=\"" . theme_image($this->link, 'images/mark_unset.png') . "\"\r\n\t\t\t\t\t\tclass=\"markedPic\" alt=\"Star article\"\r\n\t\t\t\t\t\tonclick='javascript:toggleMark({$id})'>";
             }
             if ($line["published"] == "t" || $line["published"] == "1") {
                 $published_pic = "<img id=\"FPPIC-{$id}\" src=\"" . theme_image($this->link, 'images/pub_set.png') . "\"\r\n\t\t\t\t\t\tclass=\"markedPic\"\r\n\t\t\t\t\t\talt=\"Unpublish article\" onclick='javascript:togglePub({$id})'>";
             } else {
                 $published_pic = "<img id=\"FPPIC-{$id}\" src=\"" . theme_image($this->link, 'images/pub_unset.png') . "\"\r\n\t\t\t\t\t\tclass=\"markedPic\"\r\n\t\t\t\t\t\talt=\"Publish article\" onclick='javascript:togglePub({$id})'>";
             }
             #				$content_link = "<a target=\"_blank\" href=\"".$line["link"]."\">" .
             #					$line["title"] . "</a>";
             #				$content_link = "<a
             #					href=\"" . htmlspecialchars($line["link"]) . "\"
             #					onclick=\"view($id,$feed_id);\">" .
             #					$line["title"] . "</a>";
             #				$content_link = "<a href=\"javascript:viewContentUrl('".$line["link"]."');\">" .
             #					$line["title"] . "</a>";
             $updated_fmt = make_local_datetime($this->link, $line["updated_noms"], false);
             if (get_pref($this->link, 'SHOW_CONTENT_PREVIEW')) {
                 $content_preview = truncate_string(strip_tags($line["content_preview"]), 100);
             }
             $score = $line["score"];
             $score_pic = theme_image($this->link, "images/" . get_score_pic($score));
             /*				$score_title = __("(Click to change)");
             				$score_pic = "<img class='hlScorePic' src=\"images/$score_pic\"
             					onclick=\"adjustArticleScore($id, $score)\" title=\"$score $score_title\">"; */
             $score_pic = "<img class='hlScorePic' src=\"{$score_pic}\"\r\n\t\t\t\t\ttitle=\"{$score}\">";
             if ($score > 500) {
                 $hlc_suffix = "H";
             } else {
                 if ($score < -100) {
                     $hlc_suffix = "L";
                 } else {
                     $hlc_suffix = "";
                 }
             }
             $entry_author = $line["author"];
             if ($entry_author) {
                 $entry_author = " - {$entry_author}";
             }
             $has_feed_icon = feed_has_icon($feed_id);
             if ($has_feed_icon) {
                 $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL . "/{$feed_id}.ico\" alt=\"\">";
             } else {
                 $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"images/feed-icon-12x12.png\" alt=\"\">";
             }
             if (!get_pref($this->link, 'COMBINED_DISPLAY_MODE')) {
                 if (get_pref($this->link, 'VFEED_GROUP_BY_FEED')) {
                     if ($feed_id != $vgroup_last_feed && $line["feed_title"]) {
                         $cur_feed_title = $line["feed_title"];
                         $vgroup_last_feed = $feed_id;
                         $cur_feed_title = htmlspecialchars($cur_feed_title);
                         $vf_catchup_link = "(<a onclick='catchupFeedInGroup({$feed_id});' href='#'>" . __('mark as read') . "</a>)";
                         $reply['content'] .= "<div class='cdmFeedTitle'>" . "<div style=\"float : right\">{$feed_icon_img}</div>" . "<a href=\"#\" onclick=\"viewfeed({$feed_id})\">" . $line["feed_title"] . "</a> {$vf_catchup_link}</div>";
                     }
                 }
                 $mouseover_attrs = "onmouseover='postMouseIn({$id})'\r\n\t\t\t\t\t\tonmouseout='postMouseOut({$id})'";
                 $reply['content'] .= "<div class='{$class}' id='RROW-{$id}' {$mouseover_attrs}>";
                 $reply['content'] .= "<div class='hlUpdPic'>{$update_pic}</div>";
                 $reply['content'] .= "<div class='hlLeft'>";
                 $reply['content'] .= "<input type=\"checkbox\" onclick=\"tSR(this)\"\r\n\t\t\t\t\t\t\tid=\"RCHK-{$id}\">";
                 $reply['content'] .= "{$marked_pic}";
                 $reply['content'] .= "{$published_pic}";
                 $reply['content'] .= "</div>";
                 $reply['content'] .= "<div onclick='return hlClicked(event, {$id})'\r\n\t\t\t\t\t\tclass=\"hlTitle\"><span class='hlContent{$hlc_suffix}'>";
                 $reply['content'] .= "<a id=\"RTITLE-{$id}\"\r\n\t\t\t\t\t\thref=\"" . htmlspecialchars($line["link"]) . "\"\r\n\t\t\t\t\t\tonclick=\"\">" . truncate_string($line["title"], 200);
                 if (get_pref($this->link, 'SHOW_CONTENT_PREVIEW')) {
                     if ($content_preview) {
                         $reply['content'] .= "<span class=\"contentPreview\"> - {$content_preview}</span>";
                     }
                 }
                 $reply['content'] .= "</a></span>";
                 $reply['content'] .= $labels_str;
                 if (!get_pref($this->link, 'VFEED_GROUP_BY_FEED') && defined('_SHOW_FEED_TITLE_IN_VFEEDS')) {
                     if (@$line["feed_title"]) {
                         $reply['content'] .= "<span class=\"hlFeed\">\r\n\t\t\t\t\t\t\t\t(<a href=\"#\" onclick=\"viewfeed({$feed_id})\">" . $line["feed_title"] . "</a>)\r\n\t\t\t\t\t\t\t</span>";
                     }
                 }
                 $reply['content'] .= "</div>";
                 $reply['content'] .= "<span class=\"hlUpdated\">{$updated_fmt}</span>";
                 $reply['content'] .= "<div class=\"hlRight\">";
                 $reply['content'] .= $score_pic;
                 if ($line["feed_title"] && !get_pref($this->link, 'VFEED_GROUP_BY_FEED')) {
                     $reply['content'] .= "<span onclick=\"viewfeed({$feed_id})\"\r\n\t\t\t\t\t\t\tstyle=\"cursor : pointer\"\r\n\t\t\t\t\t\t\ttitle=\"" . htmlspecialchars($line['feed_title']) . "\">\r\n\t\t\t\t\t\t\t{$feed_icon_img}<span>";
                 }
                 $reply['content'] .= "</div>";
                 $reply['content'] .= "</div>";
             } else {
                 if (get_pref($this->link, 'VFEED_GROUP_BY_FEED') && $line["feed_title"]) {
                     if ($feed_id != $vgroup_last_feed) {
                         $cur_feed_title = $line["feed_title"];
                         $vgroup_last_feed = $feed_id;
                         $cur_feed_title = htmlspecialchars($cur_feed_title);
                         $vf_catchup_link = "(<a onclick='javascript:catchupFeedInGroup({$feed_id});' href='#'>" . __('mark as read') . "</a>)";
                         $has_feed_icon = feed_has_icon($feed_id);
                         if ($has_feed_icon) {
                             $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"" . ICONS_URL . "/{$feed_id}.ico\" alt=\"\">";
                         } else {
                             //$feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\" alt=\"\">";
                         }
                         $reply['content'] .= "<div class='cdmFeedTitle'>" . "<div style=\"float : right\">{$feed_icon_img}</div>" . "<a href=\"#\" onclick=\"viewfeed({$feed_id})\">" . $line["feed_title"] . "</a> {$vf_catchup_link}</div>";
                     }
                 }
                 $expand_cdm = get_pref($this->link, 'CDM_EXPANDED');
                 $mouseover_attrs = "onmouseover='postMouseIn({$id})'\r\n\t\t\t\t\t\tonmouseout='postMouseOut({$id})'";
                 $reply['content'] .= "<div class=\"{$class}\"\r\n\t\t\t\t\t\tid=\"RROW-{$id}\" {$mouseover_attrs}'>";
                 $reply['content'] .= "<div class=\"cdmHeader\">";
                 $reply['content'] .= "<div>";
                 $reply['content'] .= "<input type=\"checkbox\" onclick=\"toggleSelectRowById(this,\r\n\t\t\t\t\t\t\t'RROW-{$id}')\" id=\"RCHK-{$id}\"/>";
                 $reply['content'] .= "{$marked_pic}";
                 $reply['content'] .= "{$published_pic}";
                 $reply['content'] .= "</div>";
                 $reply['content'] .= "<div id=\"PTITLE-FULL-{$id}\" style=\"display : none\">" . strip_tags($line['title']) . "</div>";
                 $reply['content'] .= "<span id=\"RTITLE-{$id}\"\r\n\t\t\t\t\t\tonclick=\"return cdmClicked(event, {$id});\"\r\n\t\t\t\t\t\tclass=\"titleWrap{$hlc_suffix}\">\r\n\t\t\t\t\t\t<a class=\"title\"\r\n\t\t\t\t\t\ttitle=\"" . htmlspecialchars($line['title']) . "\"\r\n\t\t\t\t\t\ttarget=\"_blank\" href=\"" . htmlspecialchars($line["link"]) . "\">" . truncate_string($line["title"], 100) . " {$entry_author}</a>";
                 $reply['content'] .= $labels_str;
                 if (!get_pref($this->link, 'VFEED_GROUP_BY_FEED') && defined('_SHOW_FEED_TITLE_IN_VFEEDS')) {
                     if (@$line["feed_title"]) {
                         $reply['content'] .= "<span class=\"hlFeed\">\r\n\t\t\t\t\t\t\t\t(<a href=\"#\" onclick=\"viewfeed({$feed_id})\">" . $line["feed_title"] . "</a>)\r\n\t\t\t\t\t\t\t</span>";
                     }
                 }
                 if (!$expand_cdm) {
                     $content_hidden = "style=\"display : none\"";
                 } else {
                     $excerpt_hidden = "style=\"display : none\"";
                 }
                 $reply['content'] .= "<span {$excerpt_hidden}\r\n\t\t\t\t\t\tid=\"CEXC-{$id}\" class=\"cdmExcerpt\"> - {$content_preview}</span>";
                 $reply['content'] .= "</span>";
                 $reply['content'] .= "<div>";
                 $reply['content'] .= "<span class='updated'>{$updated_fmt}</span>";
                 $reply['content'] .= "{$score_pic}";
                 if (!get_pref($this->link, "VFEED_GROUP_BY_FEED") && $line["feed_title"]) {
                     $reply['content'] .= "<span style=\"cursor : pointer\"\r\n\t\t\t\t\t\t\ttitle=\"" . htmlspecialchars($line["feed_title"]) . "\"\r\n\t\t\t\t\t\t\tonclick=\"viewfeed({$feed_id})\">{$feed_icon_img}</span>";
                 }
                 $reply['content'] .= "<div class=\"updPic\">{$update_pic}</div>";
                 $reply['content'] .= "</div>";
                 $reply['content'] .= "</div>";
                 $reply['content'] .= "<div class=\"cdmContent\" {$content_hidden}\r\n\t\t\t\t\t\tonclick=\"return cdmClicked(event, {$id});\"\r\n\t\t\t\t\t\tid=\"CICD-{$id}\">";
                 $reply['content'] .= "<div class=\"cdmContentInner\">";
                 if ($line["orig_feed_id"]) {
                     $tmp_result = db_query($this->link, "SELECT * FROM ttrss_archived_feeds\r\n\t\t\t\t\tWHERE id = " . $line["orig_feed_id"]);
                     if (db_num_rows($tmp_result) != 0) {
                         $reply['content'] .= "<div clear='both'>";
                         $reply['content'] .= __("Originally from:");
                         $reply['content'] .= "&nbsp;";
                         $tmp_line = db_fetch_assoc($tmp_result);
                         $reply['content'] .= "<a target='_blank'\r\n\t\t\t\t\t\t\t\thref=' " . htmlspecialchars($tmp_line['site_url']) . "'>" . $tmp_line['title'] . "</a>";
                         $reply['content'] .= "&nbsp;";
                         $reply['content'] .= "<a target='_blank' href='" . htmlspecialchars($tmp_line['feed_url']) . "'>";
                         $reply['content'] .= "<img title='" . __('Feed URL') . "'class='tinyFeedIcon' src='images/pub_set.png'></a>";
                         $reply['content'] .= "</div>";
                     }
                 }
                 $feed_site_url = $line["site_url"];
                 $article_content = sanitize($this->link, $line["content_preview"], false, false, $feed_site_url);
                 $reply['content'] .= "<div id=\"POSTNOTE-{$id}\">";
                 if ($line['note']) {
                     $reply['content'] .= format_article_note($id, $line['note']);
                 }
                 $reply['content'] .= "</div>";
                 $reply['content'] .= "<span id=\"CWRAP-{$id}\">";
                 $reply['content'] .= $expand_cdm ? $article_content : '';
                 $reply['content'] .= "</span>";
                 /*					$tmp_result = db_query($this->link, "SELECT always_display_enclosures FROM
                 						ttrss_feeds WHERE id = ".
                 						(($line['feed_id'] == null) ? $line['orig_feed_id'] :
                 							$line['feed_id'])." AND owner_uid = ".$_SESSION["uid"]);
                 
                 					$always_display_enclosures = sql_bool_to_bool(db_fetch_result($tmp_result,
                 						0, "always_display_enclosures")); */
                 $always_display_enclosures = sql_bool_to_bool($line["always_display_enclosures"]);
                 $reply['content'] .= format_article_enclosures($this->link, $id, $always_display_enclosures, $article_content);
                 $reply['content'] .= "</div>";
                 $reply['content'] .= "<div class=\"cdmFooter\">";
                 $tag_cache = $line["tag_cache"];
                 $tags_str = format_tags_string(get_article_tags($this->link, $id, $_SESSION["uid"], $tag_cache), $id);
                 $reply['content'] .= "<img src='" . theme_image($this->link, 'images/tag.png') . "' alt='Tags' title='Tags'>\r\n\t\t\t\t\t\t<span id=\"ATSTR-{$id}\">{$tags_str}</span>\r\n\t\t\t\t\t\t<a title=\"" . __('Edit tags for this article') . "\"\r\n\t\t\t\t\t\thref=\"#\" onclick=\"editArticleTags({$id}, {$feed_id}, true)\">(+)</a>";
                 $num_comments = $line["num_comments"];
                 $entry_comments = "";
                 if ($num_comments > 0) {
                     if ($line["comments"]) {
                         $comments_url = $line["comments"];
                     } else {
                         $comments_url = $line["link"];
                     }
                     $entry_comments = "<a target='_blank' href=\"{$comments_url}\">{$num_comments} comments</a>";
                 } else {
                     if ($line["comments"] && $line["link"] != $line["comments"]) {
                         $entry_comments = "<a target='_blank' href=\"" . $line["comments"] . "\">comments</a>";
                     }
                 }
                 if ($entry_comments) {
                     $reply['content'] .= "&nbsp;({$entry_comments})";
                 }
                 $reply['content'] .= "<div style=\"float : right\">";
                 $reply['content'] .= "<img src=\"images/art-zoom.png\"\r\n\t\t\t\t\t\tonclick=\"zoomToArticle(event, {$id})\"\r\n\t\t\t\t\t\tstyle=\"cursor : pointer\"\r\n\t\t\t\t\t\talt='Zoom'\r\n\t\t\t\t\t\ttitle='" . __('Open article in new tab') . "'>";
                 //$note_escaped = htmlspecialchars($line['note'], ENT_QUOTES);
                 foreach ($button_plugins as $p) {
                     $reply['content'] .= $p->render($id, $line);
                 }
                 $reply['content'] .= "<img src=\"images/digest_checkbox.png\"\r\n\t\t\t\t\t\tstyle=\"cursor : pointer\" style=\"cursor : pointer\"\r\n\t\t\t\t\t\tonclick=\"dismissArticle({$id})\"\r\n\t\t\t\t\t\ttitle='" . __('Close article') . "'>";
                 $reply['content'] .= "</div>";
                 $reply['content'] .= "</div>";
                 $reply['content'] .= "</div>";
                 $reply['content'] .= "</div>";
             }
             ++$lnum;
         }
         if ($_REQUEST["debug"]) {
             $timing_info = print_checkpoint("PE", $timing_info);
         }
     } else {
         $message = "";
         switch ($view_mode) {
             case "unread":
                 $message = __("No unread articles found to display.");
                 break;
             case "updated":
                 $message = __("No updated articles found to display.");
                 break;
             case "marked":
                 $message = __("No starred articles found to display.");
                 break;
             default:
                 if ($feed < -10) {
                     $message = __("No articles found to display. You can assign articles to labels manually (see the Actions menu above) or use a filter.");
                 } else {
                     $message = __("No articles found to display.");
                 }
         }
         if (!$offset && $message) {
             $reply['content'] .= "<div class='whiteBox'>{$message}";
             $reply['content'] .= "<p class=\"small\"><span class=\"insensitive\">";
             $result = db_query($this->link, "SELECT " . SUBSTRING_FOR_DATE . "(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds\r\n\t\t\t\t\tWHERE owner_uid = " . $_SESSION['uid']);
             $last_updated = db_fetch_result($result, 0, "last_updated");
             $last_updated = make_local_datetime($this->link, $last_updated, false);
             $reply['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated);
             $result = db_query($this->link, "SELECT COUNT(id) AS num_errors\r\n\t\t\t\t\tFROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION["uid"]);
             $num_errors = db_fetch_result($result, 0, "num_errors");
             if ($num_errors > 0) {
                 $reply['content'] .= "<br/>";
                 $reply['content'] .= "<a class=\"insensitive\" href=\"#\" onclick=\"showFeedsWithErrors()\">" . __('Some feeds have update errors (click for details)') . "</a>";
             }
             $reply['content'] .= "</span></p></div>";
         }
     }
     if ($_REQUEST["debug"]) {
         $timing_info = print_checkpoint("H2", $timing_info);
     }
     return array($topmost_article_ids, $headlines_count, $feed, $disable_cache, $vgroup_last_feed, $reply);
 }
function format_article($id, $mark_as_read = true, $zoom_mode = false, $owner_uid = false)
{
    if (!$owner_uid) {
        $owner_uid = $_SESSION["uid"];
    }
    $rv = array();
    $rv['id'] = $id;
    /* we can figure out feed_id from article id anyway, why do we
     * pass feed_id here? let's ignore the argument :(*/
    $result = db_query("SELECT feed_id FROM ttrss_user_entries\n\t\t\tWHERE ref_id = '{$id}'");
    $feed_id = (int) db_fetch_result($result, 0, "feed_id");
    $rv['feed_id'] = $feed_id;
    //if (!$zoom_mode) { print "<article id='$id'><![CDATA["; };
    if ($mark_as_read) {
        $result = db_query("UPDATE ttrss_user_entries\n\t\t\t\tSET unread = false,last_read = NOW()\n\t\t\t\tWHERE ref_id = '{$id}' AND owner_uid = {$owner_uid}");
        ccache_update($feed_id, $owner_uid);
    }
    $result = db_query("SELECT id,title,link,content,feed_id,comments,int_id,\n\t\t\t" . SUBSTRING_FOR_DATE . "(updated,1,16) as updated,\n\t\t\t(SELECT site_url FROM ttrss_feeds WHERE id = feed_id) as site_url,\n\t\t\t(SELECT hide_images FROM ttrss_feeds WHERE id = feed_id) as hide_images,\n\t\t\t(SELECT always_display_enclosures FROM ttrss_feeds WHERE id = feed_id) as always_display_enclosures,\n\t\t\tnum_comments,\n\t\t\ttag_cache,\n\t\t\tauthor,\n\t\t\torig_feed_id,\n\t\t\tnote\n\t\t\tFROM ttrss_entries,ttrss_user_entries\n\t\t\tWHERE\tid = '{$id}' AND ref_id = id AND owner_uid = {$owner_uid}");
    if ($result) {
        $line = db_fetch_assoc($result);
        $tag_cache = $line["tag_cache"];
        $line["tags"] = get_article_tags($id, $owner_uid, $line["tag_cache"]);
        unset($line["tag_cache"]);
        $line["content"] = sanitize($line["content"], sql_bool_to_bool($line['hide_images']), $owner_uid, $line["site_url"]);
        foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE) as $p) {
            $line = $p->hook_render_article($line);
        }
        $num_comments = $line["num_comments"];
        $entry_comments = "";
        if ($num_comments > 0) {
            if ($line["comments"]) {
                $comments_url = htmlspecialchars($line["comments"]);
            } else {
                $comments_url = htmlspecialchars($line["link"]);
            }
            $entry_comments = "<a target='_blank' href=\"{$comments_url}\">{$num_comments} comments</a>";
        } else {
            if ($line["comments"] && $line["link"] != $line["comments"]) {
                $entry_comments = "<a target='_blank' href=\"" . htmlspecialchars($line["comments"]) . "\">comments</a>";
            }
        }
        if ($zoom_mode) {
            header("Content-Type: text/html");
            $rv['content'] .= "<html><head>\n\t\t\t\t\t\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\n\t\t\t\t\t\t<title>Tiny Tiny RSS - " . $line["title"] . "</title>\n\t\t\t\t\t\t<link rel=\"stylesheet\" type=\"text/css\" href=\"css/tt-rss.css\">\n\t\t\t\t\t\t<script type=\"text/javascript\">\n\t\t\t\t\t\tfunction openSelectedAttachment(elem) {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tvar url = elem[elem.selectedIndex].value;\n\n\t\t\t\t\t\t\t\tif (url) {\n\t\t\t\t\t\t\t\t\twindow.open(url);\n\t\t\t\t\t\t\t\t\telem.selectedIndex = 0;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\t\t\texception_error(\"openSelectedAttachment\", e);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t</script>\n\t\t\t\t\t</head><body id=\"ttrssZoom\">";
        }
        $rv['content'] .= "<div class=\"postReply\" id=\"POST-{$id}\">";
        $rv['content'] .= "<div class=\"postHeader\" id=\"POSTHDR-{$id}\">";
        $entry_author = $line["author"];
        if ($entry_author) {
            $entry_author = __(" - ") . $entry_author;
        }
        $parsed_updated = make_local_datetime($line["updated"], true, $owner_uid, true);
        $rv['content'] .= "<div class=\"postDate\">{$parsed_updated}</div>";
        if ($line["link"]) {
            $rv['content'] .= "<div class='postTitle'><a target='_blank'\n\t\t\t\t\ttitle=\"" . htmlspecialchars($line['title']) . "\"\n\t\t\t\t\thref=\"" . htmlspecialchars($line["link"]) . "\">" . $line["title"] . "</a>" . "<span class='author'>{$entry_author}</span></div>";
        } else {
            $rv['content'] .= "<div class='postTitle'>" . $line["title"] . "{$entry_author}</div>";
        }
        $tags_str = format_tags_string($line["tags"], $id);
        $tags_str_full = join(", ", $line["tags"]);
        if (!$tags_str_full) {
            $tags_str_full = __("no tags");
        }
        if (!$entry_comments) {
            $entry_comments = "&nbsp;";
        }
        # placeholder
        $rv['content'] .= "<div class='postTags' style='float : right'>\n\t\t\t\t<img src='images/tag.png'\n\t\t\t\tclass='tagsPic' alt='Tags' title='Tags'>&nbsp;";
        if (!$zoom_mode) {
            $rv['content'] .= "<span id=\"ATSTR-{$id}\">{$tags_str}</span>\n\t\t\t\t\t<a title=\"" . __('Edit tags for this article') . "\"\n\t\t\t\t\thref=\"#\" onclick=\"editArticleTags({$id}, {$feed_id})\">(+)</a>";
            $rv['content'] .= "<div dojoType=\"dijit.Tooltip\"\n\t\t\t\t\tid=\"ATSTRTIP-{$id}\" connectId=\"ATSTR-{$id}\"\n\t\t\t\t\tposition=\"below\">{$tags_str_full}</div>";
            foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_BUTTON) as $p) {
                $rv['content'] .= $p->hook_article_button($line);
            }
        } else {
            $tags_str = strip_tags($tags_str);
            $rv['content'] .= "<span id=\"ATSTR-{$id}\">{$tags_str}</span>";
        }
        $rv['content'] .= "</div>";
        $rv['content'] .= "<div clear='both'>";
        foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_LEFT_BUTTON) as $p) {
            $rv['content'] .= $p->hook_article_left_button($line);
        }
        $rv['content'] .= "{$entry_comments}</div>";
        if ($line["orig_feed_id"]) {
            $tmp_result = db_query("SELECT * FROM ttrss_archived_feeds\n\t\t\t\t\tWHERE id = " . $line["orig_feed_id"]);
            if (db_num_rows($tmp_result) != 0) {
                $rv['content'] .= "<div clear='both'>";
                $rv['content'] .= __("Originally from:");
                $rv['content'] .= "&nbsp;";
                $tmp_line = db_fetch_assoc($tmp_result);
                $rv['content'] .= "<a target='_blank'\n\t\t\t\t\t\thref=' " . htmlspecialchars($tmp_line['site_url']) . "'>" . $tmp_line['title'] . "</a>";
                $rv['content'] .= "&nbsp;";
                $rv['content'] .= "<a target='_blank' href='" . htmlspecialchars($tmp_line['feed_url']) . "'>";
                $rv['content'] .= "<img title='" . __('Feed URL') . "'class='tinyFeedIcon' src='images/pub_set.svg'></a>";
                $rv['content'] .= "</div>";
            }
        }
        $rv['content'] .= "</div>";
        $rv['content'] .= "<div id=\"POSTNOTE-{$id}\">";
        if ($line['note']) {
            $rv['content'] .= format_article_note($id, $line['note'], !$zoom_mode);
        }
        $rv['content'] .= "</div>";
        $rv['content'] .= "<div class=\"postContent\">";
        $rv['content'] .= $line["content"];
        $rv['content'] .= format_article_enclosures($id, sql_bool_to_bool($line["always_display_enclosures"]), $line["content"], sql_bool_to_bool($line["hide_images"]));
        $rv['content'] .= "</div>";
        $rv['content'] .= "</div>";
    }
    if ($zoom_mode) {
        $rv['content'] .= "\n\t\t\t\t<div class='footer'>\n\t\t\t\t<button onclick=\"return window.close()\">" . __("Close this window") . "</button></div>";
        $rv['content'] .= "</body></html>";
    }
    return $rv;
}
예제 #18
0
파일: feeds.php 프로젝트: AHinMaine/ttrss
 function inactiveFeeds()
 {
     if (DB_TYPE == "pgsql") {
         $interval_qpart = "NOW() - INTERVAL '3 months'";
     } else {
         $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)";
     }
     $result = $this->dbh->query("SELECT ttrss_feeds.title, ttrss_feeds.site_url,\n\t\t  \t\tttrss_feeds.feed_url, ttrss_feeds.id, MAX(updated) AS last_article\n\t\t\tFROM ttrss_feeds, ttrss_entries, ttrss_user_entries WHERE\n\t\t\t\t(SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE\n\t\t\t\t\tttrss_entries.id = ref_id AND\n\t\t\t\t\t\tttrss_user_entries.feed_id = ttrss_feeds.id) < {$interval_qpart}\n\t\t\tAND ttrss_feeds.owner_uid = " . $_SESSION["uid"] . " AND\n\t\t\t\tttrss_user_entries.feed_id = ttrss_feeds.id AND\n\t\t\t\tttrss_entries.id = ref_id\n\t\t\tGROUP BY ttrss_feeds.title, ttrss_feeds.id, ttrss_feeds.site_url, ttrss_feeds.feed_url\n\t\t\tORDER BY last_article");
     print "<p" . __("These feeds have not been updated with new content for 3 months (oldest first):") . "</p>";
     print "<div dojoType=\"dijit.Toolbar\">";
     print "<div dojoType=\"dijit.form.DropDownButton\">" . "<span>" . __('Select') . "</span>";
     print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
     print "<div onclick=\"selectTableRows('prefInactiveFeedList', 'all')\"\n\t\t\tdojoType=\"dijit.MenuItem\">" . __('All') . "</div>";
     print "<div onclick=\"selectTableRows('prefInactiveFeedList', 'none')\"\n\t\t\tdojoType=\"dijit.MenuItem\">" . __('None') . "</div>";
     print "</div></div>";
     print "</div>";
     #toolbar
     print "<div class=\"inactiveFeedHolder\">";
     print "<table width=\"100%\" cellspacing=\"0\" id=\"prefInactiveFeedList\">";
     $lnum = 1;
     while ($line = $this->dbh->fetch_assoc($result)) {
         $feed_id = $line["id"];
         $this_row_id = "id=\"FUPDD-{$feed_id}\"";
         # class needed for selectTableRows()
         print "<tr class=\"placeholder\" {$this_row_id}>";
         # id needed for selectTableRows()
         print "<td width='5%' align='center'><input\n\t\t\t\tonclick='toggleSelectRow2(this);' dojoType=\"dijit.form.CheckBox\"\n\t\t\t\ttype=\"checkbox\" id=\"FUPDC-{$feed_id}\"></td>";
         print "<td>";
         print "<a class=\"visibleLink\" href=\"#\" " . "title=\"" . __("Click to edit feed") . "\" " . "onclick=\"editFeed(" . $line["id"] . ")\">" . htmlspecialchars($line["title"]) . "</a>";
         print "</td><td class=\"insensitive\" align='right'>";
         print make_local_datetime($line['last_article'], false);
         print "</td>";
         print "</tr>";
         ++$lnum;
     }
     print "</table>";
     print "</div>";
     print "<div class='dlgButtons'>";
     print "<div style='float : left'>";
     print "<button class=\"danger\" dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('inactiveFeedsDlg').removeSelected()\">" . __('Unsubscribe from selected feeds') . "</button> ";
     print "</div>";
     print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('inactiveFeedsDlg').hide()\">" . __('Close this window') . "</button>";
     print "</div>";
 }
예제 #19
0
function module_pref_feeds($link)
{
    global $update_intervals;
    global $purge_intervals;
    global $update_methods;
    $subop = $_REQUEST["subop"];
    $quiet = $_REQUEST["quiet"];
    $mode = $_REQUEST["mode"];
    if ($subop == "renamecat") {
        $title = db_escape_string($_REQUEST['title']);
        $id = db_escape_string($_REQUEST['id']);
        if ($title) {
            db_query($link, "UPDATE ttrss_feed_categories SET\n\t\t\t\t\ttitle = '{$title}' WHERE id = '{$id}' AND owner_uid = " . $_SESSION["uid"]);
        }
        return;
    }
    if ($subop == "remtwitterinfo") {
        db_query($link, "UPDATE ttrss_users SET twitter_oauth = NULL\n\t\t\t\tWHERE id = " . $_SESSION['uid']);
        return;
    }
    if ($subop == "getfeedtree") {
        $search = $_SESSION["prefs_feed_search"];
        if ($search) {
            $search_qpart = " AND LOWER(title) LIKE LOWER('%{$search}%')";
        }
        $root = array();
        $root['id'] = 'root';
        $root['name'] = __('Feeds');
        $root['items'] = array();
        $root['type'] = 'category';
        if (get_pref($link, 'ENABLE_FEED_CATS')) {
            $result = db_query($link, "SELECT id, title FROM ttrss_feed_categories\n\t\t\t\t\tWHERE owner_uid = " . $_SESSION["uid"] . " ORDER BY order_id, title");
            while ($line = db_fetch_assoc($result)) {
                $cat = array();
                $cat['id'] = 'CAT:' . $line['id'];
                $cat['bare_id'] = $feed_id;
                $cat['name'] = $line['title'];
                $cat['items'] = array();
                $cat['checkbox'] = false;
                $cat['type'] = 'category';
                $feed_result = db_query($link, "SELECT id, title, last_error,\n\t\t\t\t\t\t" . SUBSTRING_FOR_DATE . "(last_updated,1,19) AS last_updated\n\t\t\t\t\t\tFROM ttrss_feeds\n\t\t\t\t\t\tWHERE cat_id = '" . $line['id'] . "' AND owner_uid = " . $_SESSION["uid"] . "{$search_qpart} ORDER BY order_id, title");
                while ($feed_line = db_fetch_assoc($feed_result)) {
                    $feed = array();
                    $feed['id'] = 'FEED:' . $feed_line['id'];
                    $feed['bare_id'] = $feed_line['id'];
                    $feed['name'] = $feed_line['title'];
                    $feed['checkbox'] = false;
                    $feed['error'] = $feed_line['last_error'];
                    $feed['icon'] = getFeedIcon($feed_line['id']);
                    $feed['param'] = make_local_datetime($link, $feed_line['last_updated'], true);
                    array_push($cat['items'], $feed);
                }
                $cat['param'] = T_sprintf('(%d feeds)', count($cat['items']));
                if (count($cat['items']) > 0) {
                    array_push($root['items'], $cat);
                }
                $root['param'] += count($cat['items']);
            }
            /* Uncategorized is a special case */
            $cat = array();
            $cat['id'] = 'CAT:0';
            $cat['bare_id'] = 0;
            $cat['name'] = __("Uncategorized");
            $cat['items'] = array();
            $cat['type'] = 'category';
            $cat['checkbox'] = false;
            $feed_result = db_query($link, "SELECT id, title,last_error,\n\t\t\t\t\t" . SUBSTRING_FOR_DATE . "(last_updated,1,19) AS last_updated\n\t\t\t\t\tFROM ttrss_feeds\n\t\t\t\t\tWHERE cat_id IS NULL AND owner_uid = " . $_SESSION["uid"] . "{$search_qpart} ORDER BY order_id, title");
            while ($feed_line = db_fetch_assoc($feed_result)) {
                $feed = array();
                $feed['id'] = 'FEED:' . $feed_line['id'];
                $feed['bare_id'] = $feed_line['id'];
                $feed['name'] = $feed_line['title'];
                $feed['checkbox'] = false;
                $feed['error'] = $feed_line['last_error'];
                $feed['icon'] = getFeedIcon($feed_line['id']);
                $feed['param'] = make_local_datetime($link, $feed_line['last_updated'], true);
                array_push($cat['items'], $feed);
            }
            $cat['param'] = T_sprintf('(%d feeds)', count($cat['items']));
            if (count($cat['items']) > 0) {
                array_push($root['items'], $cat);
            }
            $root['param'] += count($cat['items']);
            $root['param'] = T_sprintf('(%d feeds)', $root['param']);
        } else {
            $feed_result = db_query($link, "SELECT id, title, last_error,\n\t\t\t\t\t" . SUBSTRING_FOR_DATE . "(last_updated,1,19) AS last_updated\n\t\t\t\t\tFROM ttrss_feeds\n\t\t\t\t\tWHERE owner_uid = " . $_SESSION["uid"] . "{$search_qpart} ORDER BY order_id, title");
            while ($feed_line = db_fetch_assoc($feed_result)) {
                $feed = array();
                $feed['id'] = 'FEED:' . $feed_line['id'];
                $feed['bare_id'] = $feed_line['id'];
                $feed['name'] = $feed_line['title'];
                $feed['checkbox'] = false;
                $feed['error'] = $feed_line['last_error'];
                $feed['icon'] = getFeedIcon($feed_line['id']);
                $feed['param'] = make_local_datetime($link, $feed_line['last_updated'], true);
                array_push($root['items'], $feed);
            }
            $root['param'] = T_sprintf('(%d feeds)', count($root['items']));
        }
        $fl = array();
        $fl['identifier'] = 'id';
        $fl['label'] = 'name';
        $fl['items'] = array($root);
        print json_encode($fl);
        return;
    }
    if ($subop == "catsortreset") {
        db_query($link, "UPDATE ttrss_feed_categories\n\t\t\t\t\tSET order_id = 0 WHERE owner_uid = " . $_SESSION["uid"]);
        return;
    }
    if ($subop == "feedsortreset") {
        db_query($link, "UPDATE ttrss_feeds\n\t\t\t\t\tSET order_id = 0 WHERE owner_uid = " . $_SESSION["uid"]);
        return;
    }
    if ($subop == "savefeedorder") {
        #			if ($_POST['payload']) {
        #				file_put_contents("/tmp/blahblah.txt", $_POST['payload']);
        #				$data = json_decode($_POST['payload'], true);
        #			} else {
        #				$data = json_decode(file_get_contents("/tmp/blahblah.txt"), true);
        #			}
        $data = json_decode($_POST['payload'], true);
        if (is_array($data) && is_array($data['items'])) {
            $cat_order_id = 0;
            $data_map = array();
            foreach ($data['items'] as $item) {
                if ($item['id'] != 'root') {
                    if (is_array($item['items'])) {
                        if (isset($item['items']['_reference'])) {
                            $data_map[$item['id']] = array($item['items']);
                        } else {
                            $data_map[$item['id']] =& $item['items'];
                        }
                    }
                }
            }
            foreach ($data['items'][0]['items'] as $item) {
                $id = $item['_reference'];
                $bare_id = substr($id, strpos($id, ':') + 1);
                ++$cat_order_id;
                if ($bare_id > 0) {
                    db_query($link, "UPDATE ttrss_feed_categories\n\t\t\t\t\t\t\tSET order_id = '{$cat_order_id}' WHERE id = '{$bare_id}' AND\n\t\t\t\t\t\t\towner_uid = " . $_SESSION["uid"]);
                }
                $feed_order_id = 0;
                if (is_array($data_map[$id])) {
                    foreach ($data_map[$id] as $feed) {
                        $id = $feed['_reference'];
                        $feed_id = substr($id, strpos($id, ':') + 1);
                        if ($bare_id != 0) {
                            $cat_query = "cat_id = '{$bare_id}'";
                        } else {
                            $cat_query = "cat_id = NULL";
                        }
                        db_query($link, "UPDATE ttrss_feeds\n\t\t\t\t\t\t\t\tSET order_id = '{$feed_order_id}',\n\t\t\t\t\t\t\t\t{$cat_query}\n\t\t\t\t\t\t\t\tWHERE id = '{$feed_id}' AND\n\t\t\t\t\t\t\t\t\towner_uid = " . $_SESSION["uid"]);
                        ++$feed_order_id;
                    }
                }
            }
        }
        return;
    }
    if ($subop == "removeicon") {
        $feed_id = db_escape_string($_REQUEST["feed_id"]);
        $result = db_query($link, "SELECT id FROM ttrss_feeds\n\t\t\t\tWHERE id = '{$feed_id}' AND owner_uid = " . $_SESSION["uid"]);
        if (db_num_rows($result) != 0) {
            unlink(ICONS_DIR . "/{$feed_id}.ico");
        }
        return;
    }
    if ($subop == "uploadicon") {
        $icon_file = $_FILES['icon_file']['tmp_name'];
        $feed_id = db_escape_string($_REQUEST["feed_id"]);
        if (is_file($icon_file) && $feed_id) {
            if (filesize($icon_file) < 20000) {
                $result = db_query($link, "SELECT id FROM ttrss_feeds\n\t\t\t\t\t\tWHERE id = '{$feed_id}' AND owner_uid = " . $_SESSION["uid"]);
                if (db_num_rows($result) != 0) {
                    unlink(ICONS_DIR . "/{$feed_id}.ico");
                    move_uploaded_file($icon_file, ICONS_DIR . "/{$feed_id}.ico");
                    $rc = 0;
                } else {
                    $rc = 2;
                }
            } else {
                $rc = 1;
            }
        } else {
            $rc = 2;
        }
        print "<script type=\"text/javascript\">";
        print "parent.uploadIconHandler({$rc});";
        print "</script>";
        return;
    }
    if ($subop == "editfeed") {
        $feed_id = db_escape_string($_REQUEST["id"]);
        $result = db_query($link, "SELECT * FROM ttrss_feeds WHERE id = '{$feed_id}' AND\n\t\t\t\t\towner_uid = " . $_SESSION["uid"]);
        $title = htmlspecialchars(db_fetch_result($result, 0, "title"));
        print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"id\" value=\"{$feed_id}\">";
        print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-feeds\">";
        print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"subop\" value=\"editSave\">";
        print "<div class=\"dlgSec\">" . __("Feed") . "</div>";
        print "<div class=\"dlgSecCont\">";
        /* Title */
        print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\"\n\t\t\t\tplaceHolder=\"" . __("Feed Title") . "\"\n\t\t\t\tstyle=\"font-size : 16px; width: 20em\" name=\"title\" value=\"{$title}\">";
        /* Feed URL */
        $feed_url = db_fetch_result($result, 0, "feed_url");
        $feed_url = htmlspecialchars(db_fetch_result($result, 0, "feed_url"));
        print "<hr/>";
        print __('URL:') . " ";
        print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\"\n\t\t\t\tplaceHolder=\"" . __("Feed URL") . "\"\n\t\t\t\tregExp='^(http|https)://.*' style=\"width : 20em\"\n\t\t\t\tname=\"feed_url\" value=\"{$feed_url}\">";
        $last_error = db_fetch_result($result, 0, "last_error");
        if ($last_error) {
            print "&nbsp;<span title=\"" . htmlspecialchars($last_error) . "\"\n\t\t\t\t\tclass=\"feed_error\">(error)</span>";
        }
        /* Category */
        if (get_pref($link, 'ENABLE_FEED_CATS')) {
            $cat_id = db_fetch_result($result, 0, "cat_id");
            print "<hr/>";
            print __('Place in category:') . " ";
            print_feed_cat_select($link, "cat_id", $cat_id, 'dojoType="dijit.form.Select"');
        }
        print "</div>";
        print "<div class=\"dlgSec\">" . __("Update") . "</div>";
        print "<div class=\"dlgSecCont\">";
        /* Update Interval */
        $update_interval = db_fetch_result($result, 0, "update_interval");
        print_select_hash("update_interval", $update_interval, $update_intervals, 'dojoType="dijit.form.Select"');
        /* Update method */
        $update_method = db_fetch_result($result, 0, "update_method", 'dojoType="dijit.form.Select"');
        print " " . __('using') . " ";
        print_select_hash("update_method", $update_method, $update_methods, 'dojoType="dijit.form.Select"');
        $purge_interval = db_fetch_result($result, 0, "purge_interval");
        /* Purge intl */
        print "<hr/>";
        print __('Article purging:') . " ";
        print_select_hash("purge_interval", $purge_interval, $purge_intervals, 'dojoType="dijit.form.Select" ' . (FORCE_ARTICLE_PURGE == 0 ? "" : 'disabled="1"'));
        print "</div>";
        print "<div class=\"dlgSec\">" . __("Authentication") . "</div>";
        print "<div class=\"dlgSecCont\">";
        $auth_login = htmlspecialchars(db_fetch_result($result, 0, "auth_login"));
        #			print "<table>";
        #			print "<tr><td>" . __('Login:'******'<b>Hint:</b> you need to fill in your login information if your feed requires authentication, except for Twitter feeds.') . "\n\t\t\t\t</div>";
        #			print "</td></tr></table>";
        print "</div>";
        print "<div class=\"dlgSec\">" . __("Options") . "</div>";
        print "<div class=\"dlgSecCont\">";
        #			print "<div style=\"line-height : 100%\">";
        $private = sql_bool_to_bool(db_fetch_result($result, 0, "private"));
        if ($private) {
            $checked = "checked=\"1\"";
        } else {
            $checked = "";
        }
        print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"private\" id=\"private\"\n\t\t\t\t{$checked}>&nbsp;<label for=\"private\">" . __('Hide from Popular feeds') . "</label>";
        $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content"));
        if ($rtl_content) {
            $checked = "checked=\"1\"";
        } else {
            $checked = "";
        }
        print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"rtl_content\" name=\"rtl_content\"\n\t\t\t\t{$checked}>&nbsp;<label for=\"rtl_content\">" . __('Right-to-left content') . "</label>";
        $include_in_digest = sql_bool_to_bool(db_fetch_result($result, 0, "include_in_digest"));
        if ($include_in_digest) {
            $checked = "checked=\"1\"";
        } else {
            $checked = "";
        }
        print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"include_in_digest\"\n\t\t\t\tname=\"include_in_digest\"\n\t\t\t\t{$checked}>&nbsp;<label for=\"include_in_digest\">" . __('Include in e-mail digest') . "</label>";
        $always_display_enclosures = sql_bool_to_bool(db_fetch_result($result, 0, "always_display_enclosures"));
        if ($always_display_enclosures) {
            $checked = "checked";
        } else {
            $checked = "";
        }
        print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"always_display_enclosures\"\n\t\t\t\tname=\"always_display_enclosures\"\n\t\t\t\t{$checked}>&nbsp;<label for=\"always_display_enclosures\">" . __('Always display image attachments') . "</label>";
        $cache_images = sql_bool_to_bool(db_fetch_result($result, 0, "cache_images"));
        if ($cache_images) {
            $checked = "checked=\"1\"";
        } else {
            $checked = "";
        }
        if (SIMPLEPIE_CACHE_IMAGES) {
            print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"cache_images\"\n\t\t\t\tname=\"cache_images\"\n\t\t\t\t{$checked}>&nbsp;<label for=\"cache_images\">" . __('Cache images locally (SimplePie only)') . "</label>";
        }
        $mark_unread_on_update = sql_bool_to_bool(db_fetch_result($result, 0, "mark_unread_on_update"));
        if ($mark_unread_on_update) {
            $checked = "checked";
        } else {
            $checked = "";
        }
        print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"mark_unread_on_update\"\n\t\t\t\tname=\"mark_unread_on_update\"\n\t\t\t\t{$checked}>&nbsp;<label for=\"mark_unread_on_update\">" . __('Mark updated articles as unread') . "</label>";
        $update_on_checksum_change = sql_bool_to_bool(db_fetch_result($result, 0, "update_on_checksum_change"));
        if ($update_on_checksum_change) {
            $checked = "checked";
        } else {
            $checked = "";
        }
        print "<hr/><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"update_on_checksum_change\"\n\t\t\t\tname=\"update_on_checksum_change\"\n\t\t\t\t{$checked}>&nbsp;<label for=\"update_on_checksum_change\">" . __('Mark posts as updated on content change') . "</label>";
        #			print "</div>";
        print "</div>";
        /* Icon */
        print "<div class=\"dlgSec\">" . __("Icon") . "</div>";
        print "<div class=\"dlgSecCont\">";
        print "<iframe name=\"icon_upload_iframe\"\n\t\t\t\tstyle=\"width: 400px; height: 100px; display: none;\"></iframe>";
        print "<form style='display : block' target=\"icon_upload_iframe\"\n\t\t\t\tenctype=\"multipart/form-data\" method=\"POST\"\n\t\t\t\taction=\"backend.php\">\n\t\t\t\t<input id=\"icon_file\" size=\"10\" name=\"icon_file\" type=\"file\">\n\t\t\t\t<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">\n\t\t\t\t<input type=\"hidden\" name=\"feed_id\" value=\"{$feed_id}\">\n\t\t\t\t<input type=\"hidden\" name=\"subop\" value=\"uploadicon\">\n\t\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"return uploadFeedIcon();\"\n\t\t\t\t\ttype=\"submit\">" . __('Replace') . "</button>\n\t\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"return removeFeedIcon({$feed_id});\"\n\t\t\t\t\ttype=\"submit\">" . __('Remove') . "</button>\n\t\t\t\t</form>";
        print "</div>";
        $title = htmlspecialchars($title, ENT_QUOTES);
        print "<div class='dlgButtons'>\n\t\t\t\t<div style=\"float : left\">\n\t\t\t\t<button dojoType=\"dijit.form.Button\" onclick='return unsubscribeFeed({$feed_id}, \"{$title}\")'>" . __('Unsubscribe') . "</button>";
        if (PUBSUBHUBBUB_ENABLED) {
            $pubsub_state = db_fetch_result($result, 0, "pubsub_state");
            $pubsub_btn_disabled = $pubsub_state == 2 ? "" : "disabled=\"1\"";
            print "<button dojoType=\"dijit.form.Button\" id=\"pubsubReset_Btn\" {$pubsub_btn_disabled}\n\t\t\t\t\t\tonclick='return resetPubSub({$feed_id}, \"{$title}\")'>" . __('Resubscribe to push updates') . "</button>";
        }
        print "</div>";
        print "<div dojoType=\"dijit.Tooltip\" connectId=\"pubsubReset_Btn\" position=\"below\">" . __('Resets PubSubHubbub subscription status for push-enabled feeds.') . "</div>";
        print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedEditDlg').execute()\">" . __('Save') . "</button>\n\t\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedEditDlg').hide()\">" . __('Cancel') . "</button>\n\t\t\t</div>";
        return;
    }
    if ($subop == "editfeeds") {
        $feed_ids = db_escape_string($_REQUEST["ids"]);
        print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"ids\" value=\"{$feed_ids}\">";
        print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-feeds\">";
        print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"subop\" value=\"batchEditSave\">";
        print "<div class=\"dlgSec\">" . __("Feed") . "</div>";
        print "<div class=\"dlgSecCont\">";
        /* Title */
        print "<input dojoType=\"dijit.form.ValidationTextBox\"\n\t\t\t\tdisabled=\"1\" style=\"font-size : 16px; width : 20em;\" required=\"1\"\n\t\t\t\tname=\"title\" value=\"{$title}\">";
        batch_edit_cbox("title");
        /* Feed URL */
        print "<br/>";
        print __('URL:') . " ";
        print "<input dojoType=\"dijit.form.ValidationTextBox\" disabled=\"1\"\n\t\t\t\trequired=\"1\" regExp='^(http|https)://.*' style=\"width : 20em\"\n\t\t\t\tname=\"feed_url\" value=\"{$feed_url}\">";
        batch_edit_cbox("feed_url");
        /* Category */
        if (get_pref($link, 'ENABLE_FEED_CATS')) {
            print "<br/>";
            print __('Place in category:') . " ";
            print_feed_cat_select($link, "cat_id", $cat_id, 'disabled="1" dojoType="dijit.form.Select"');
            batch_edit_cbox("cat_id");
        }
        print "</div>";
        print "<div class=\"dlgSec\">" . __("Update") . "</div>";
        print "<div class=\"dlgSecCont\">";
        /* Update Interval */
        print_select_hash("update_interval", $update_interval, $update_intervals, 'disabled="1" dojoType="dijit.form.Select"');
        batch_edit_cbox("update_interval");
        /* Update method */
        print " " . __('using') . " ";
        print_select_hash("update_method", $update_method, $update_methods, 'disabled="1" dojoType="dijit.form.Select"');
        batch_edit_cbox("update_method");
        /* Purge intl */
        if (FORCE_ARTICLE_PURGE == 0) {
            print "<br/>";
            print __('Article purging:') . " ";
            print_select_hash("purge_interval", $purge_interval, $purge_intervals, 'disabled="1" dojoType="dijit.form.Select"');
            batch_edit_cbox("purge_interval");
        }
        print "</div>";
        print "<div class=\"dlgSec\">" . __("Authentication") . "</div>";
        print "<div class=\"dlgSecCont\">";
        print "<input dojoType=\"dijit.form.TextBox\"\n\t\t\t\tplaceHolder=\"" . __("Login") . "\" disabled=\"1\"\n\t\t\t\tname=\"auth_login\" value=\"{$auth_login}\">";
        batch_edit_cbox("auth_login");
        print "<br/><input dojoType=\"dijit.form.TextBox\" type=\"password\" name=\"auth_pass\"\n\t\t\t\tplaceHolder=\"" . __("Password") . "\" disabled=\"1\"\n\t\t\t\tvalue=\"{$auth_pass}\">";
        batch_edit_cbox("auth_pass");
        print "</div>";
        print "<div class=\"dlgSec\">" . __("Options") . "</div>";
        print "<div class=\"dlgSecCont\">";
        print "<input disabled=\"1\" type=\"checkbox\" name=\"private\" id=\"private\"\n\t\t\t\tdojoType=\"dijit.form.CheckBox\">&nbsp;<label id=\"private_l\" class='insensitive' for=\"private\">" . __('Hide from Popular feeds') . "</label>";
        print "&nbsp;";
        batch_edit_cbox("private", "private_l");
        print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"rtl_content\" name=\"rtl_content\"\n\t\t\t\tdojoType=\"dijit.form.CheckBox\">&nbsp;<label class='insensitive' id=\"rtl_content_l\" for=\"rtl_content\">" . __('Right-to-left content') . "</label>";
        print "&nbsp;";
        batch_edit_cbox("rtl_content", "rtl_content_l");
        print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"include_in_digest\"\n\t\t\t\tname=\"include_in_digest\"\n\t\t\t\tdojoType=\"dijit.form.CheckBox\">&nbsp;<label id=\"include_in_digest_l\" class='insensitive' for=\"include_in_digest\">" . __('Include in e-mail digest') . "</label>";
        print "&nbsp;";
        batch_edit_cbox("include_in_digest", "include_in_digest_l");
        print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"always_display_enclosures\"\n\t\t\t\tname=\"always_display_enclosures\"\n\t\t\t\tdojoType=\"dijit.form.CheckBox\">&nbsp;<label id=\"always_display_enclosures_l\" class='insensitive' for=\"always_display_enclosures\">" . __('Always display image attachments') . "</label>";
        print "&nbsp;";
        batch_edit_cbox("always_display_enclosures", "always_display_enclosures_l");
        if (SIMPLEPIE_CACHE_IMAGES) {
            print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"cache_images\"\n\t\t\t\t\tname=\"cache_images\"\n\t\t\t\t\tdojoType=\"dijit.form.CheckBox\">&nbsp;<label class='insensitive' id=\"cache_images_l\"\n\t\t\t\t\tfor=\"cache_images\">" . __('Cache images locally') . "</label>";
            print "&nbsp;";
            batch_edit_cbox("cache_images", "cache_images_l");
        }
        print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"mark_unread_on_update\"\n\t\t\t\tname=\"mark_unread_on_update\"\n\t\t\t\tdojoType=\"dijit.form.CheckBox\">&nbsp;<label id=\"mark_unread_on_update_l\" class='insensitive' for=\"mark_unread_on_update\">" . __('Mark updated articles as unread') . "</label>";
        print "&nbsp;";
        batch_edit_cbox("mark_unread_on_update", "mark_unread_on_update_l");
        print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"update_on_checksum_change\"\n\t\t\t\tname=\"update_on_checksum_change\"\n\t\t\t\tdojoType=\"dijit.form.CheckBox\">&nbsp;<label id=\"update_on_checksum_change_l\" class='insensitive' for=\"update_on_checksum_change\">" . __('Mark posts as updated on content change') . "</label>";
        print "&nbsp;";
        batch_edit_cbox("update_on_checksum_change", "update_on_checksum_change_l");
        print "</div>";
        print "<div class='dlgButtons'>\n\t\t\t\t<button dojoType=\"dijit.form.Button\"\n\t\t\t\t\tonclick=\"return dijit.byId('feedEditDlg').execute()\">" . __('Save') . "</button>\n\t\t\t\t<button dojoType=\"dijit.form.Button\"\n\t\t\t\tonclick=\"return dijit.byId('feedEditDlg').hide()\">" . __('Cancel') . "</button>\n\t\t\t\t</div>";
        return;
    }
    if ($subop == "editSave" || $subop == "batchEditSave") {
        $feed_title = db_escape_string(trim($_POST["title"]));
        $feed_link = db_escape_string(trim($_POST["feed_url"]));
        $upd_intl = (int) db_escape_string($_POST["update_interval"]);
        $purge_intl = (int) db_escape_string($_POST["purge_interval"]);
        $feed_id = (int) db_escape_string($_POST["id"]);
        /* editSave */
        $feed_ids = db_escape_string($_POST["ids"]);
        /* batchEditSave */
        $cat_id = (int) db_escape_string($_POST["cat_id"]);
        $auth_login = db_escape_string(trim($_POST["auth_login"]));
        $auth_pass = db_escape_string(trim($_POST["auth_pass"]));
        $private = checkbox_to_sql_bool(db_escape_string($_POST["private"]));
        $rtl_content = checkbox_to_sql_bool(db_escape_string($_POST["rtl_content"]));
        $include_in_digest = checkbox_to_sql_bool(db_escape_string($_POST["include_in_digest"]));
        $cache_images = checkbox_to_sql_bool(db_escape_string($_POST["cache_images"]));
        $update_method = (int) db_escape_string($_POST["update_method"]);
        $always_display_enclosures = checkbox_to_sql_bool(db_escape_string($_POST["always_display_enclosures"]));
        $mark_unread_on_update = checkbox_to_sql_bool(db_escape_string($_POST["mark_unread_on_update"]));
        $update_on_checksum_change = checkbox_to_sql_bool(db_escape_string($_POST["update_on_checksum_change"]));
        if (get_pref($link, 'ENABLE_FEED_CATS')) {
            if ($cat_id && $cat_id != 0) {
                $category_qpart = "cat_id = '{$cat_id}',";
                $category_qpart_nocomma = "cat_id = '{$cat_id}'";
            } else {
                $category_qpart = 'cat_id = NULL,';
                $category_qpart_nocomma = 'cat_id = NULL';
            }
        } else {
            $category_qpart = "";
            $category_qpart_nocomma = "";
        }
        if (SIMPLEPIE_CACHE_IMAGES) {
            $cache_images_qpart = "cache_images = {$cache_images},";
        } else {
            $cache_images_qpart = "";
        }
        if ($subop == "editSave") {
            $result = db_query($link, "UPDATE ttrss_feeds SET\n\t\t\t\t\t{$category_qpart}\n\t\t\t\t\ttitle = '{$feed_title}', feed_url = '{$feed_link}',\n\t\t\t\t\tupdate_interval = '{$upd_intl}',\n\t\t\t\t\tpurge_interval = '{$purge_intl}',\n\t\t\t\t\tauth_login = '******',\n\t\t\t\t\tauth_pass = '******',\n\t\t\t\t\tprivate = {$private},\n\t\t\t\t\trtl_content = {$rtl_content},\n\t\t\t\t\t{$cache_images_qpart}\n\t\t\t\t\tinclude_in_digest = {$include_in_digest},\n\t\t\t\t\talways_display_enclosures = {$always_display_enclosures},\n\t\t\t\t\tmark_unread_on_update = {$mark_unread_on_update},\n\t\t\t\t\tupdate_on_checksum_change = {$update_on_checksum_change},\n\t\t\t\t\tupdate_method = '{$update_method}'\n\t\t\t\t\tWHERE id = '{$feed_id}' AND owner_uid = " . $_SESSION["uid"]);
        } else {
            if ($subop == "batchEditSave") {
                $feed_data = array();
                foreach (array_keys($_POST) as $k) {
                    if ($k != "op" && $k != "subop" && $k != "ids") {
                        $feed_data[$k] = $_POST[$k];
                    }
                }
                db_query($link, "BEGIN");
                foreach (array_keys($feed_data) as $k) {
                    $qpart = "";
                    switch ($k) {
                        case "title":
                            $qpart = "title = '{$feed_title}'";
                            break;
                        case "feed_url":
                            $qpart = "feed_url = '{$feed_link}'";
                            break;
                        case "update_interval":
                            $qpart = "update_interval = '{$upd_intl}'";
                            break;
                        case "purge_interval":
                            $qpart = "purge_interval = '{$purge_intl}'";
                            break;
                        case "auth_login":
                            $qpart = "auth_login = '******'";
                            break;
                        case "auth_pass":
                            $qpart = "auth_pass = '******'";
                            break;
                        case "private":
                            $qpart = "private = '{$private}'";
                            break;
                        case "include_in_digest":
                            $qpart = "include_in_digest = '{$include_in_digest}'";
                            break;
                        case "always_display_enclosures":
                            $qpart = "always_display_enclosures = '{$always_display_enclosures}'";
                            break;
                        case "mark_unread_on_update":
                            $qpart = "mark_unread_on_update = '{$mark_unread_on_update}'";
                            break;
                        case "update_on_checksum_change":
                            $qpart = "update_on_checksum_change = '{$update_on_checksum_change}'";
                            break;
                        case "cache_images":
                            $qpart = "cache_images = '{$cache_images}'";
                            break;
                        case "rtl_content":
                            $qpart = "rtl_content = '{$rtl_content}'";
                            break;
                        case "update_method":
                            $qpart = "update_method = '{$update_method}'";
                            break;
                        case "cat_id":
                            $qpart = $category_qpart_nocomma;
                            break;
                    }
                    if ($qpart) {
                        db_query($link, "UPDATE ttrss_feeds SET {$qpart} WHERE id IN ({$feed_ids})\n\t\t\t\t\t\t\tAND owner_uid = " . $_SESSION["uid"]);
                        print "<br/>";
                    }
                }
                db_query($link, "COMMIT");
            }
        }
        return;
    }
    if ($subop == "resetPubSub") {
        $ids = db_escape_string($_REQUEST["ids"]);
        db_query($link, "UPDATE ttrss_feeds SET pubsub_state = 0 WHERE id IN ({$ids})\n\t\t\t\tAND owner_uid = " . $_SESSION["uid"]);
        return;
    }
    if ($subop == "remove") {
        $ids = split(",", db_escape_string($_REQUEST["ids"]));
        foreach ($ids as $id) {
            remove_feed($link, $id, $_SESSION["uid"]);
        }
        return;
    }
    if ($subop == "clear") {
        $id = db_escape_string($_REQUEST["id"]);
        clear_feed_articles($link, $id);
    }
    if ($subop == "rescore") {
        $ids = split(",", db_escape_string($_REQUEST["ids"]));
        foreach ($ids as $id) {
            $filters = load_filters($link, $id, $_SESSION["uid"], 6);
            $result = db_query($link, "SELECT\n\t\t\t\t\ttitle, content, link, ref_id, author," . SUBSTRING_FOR_DATE . "(updated, 1, 19) AS updated\n\t\t\t\t  \tFROM\n\t\t\t\t\t\tttrss_user_entries, ttrss_entries\n\t\t\t\t\t\tWHERE ref_id = id AND feed_id = '{$id}' AND\n\t\t\t\t\t\t\towner_uid = " . $_SESSION['uid'] . "\n\t\t\t\t\t\t");
            $scores = array();
            while ($line = db_fetch_assoc($result)) {
                $tags = get_article_tags($link, $line["ref_id"]);
                $article_filters = get_article_filters($filters, $line['title'], $line['content'], $line['link'], strtotime($line['updated']), $line['author'], $tags);
                $new_score = calculate_article_score($article_filters);
                if (!$scores[$new_score]) {
                    $scores[$new_score] = array();
                }
                array_push($scores[$new_score], $line['ref_id']);
            }
            foreach (array_keys($scores) as $s) {
                if ($s > 1000) {
                    db_query($link, "UPDATE ttrss_user_entries SET score = '{$s}',\n\t\t\t\t\t\t\tmarked = true WHERE\n\t\t\t\t\t\t\tref_id IN (" . join(',', $scores[$s]) . ")");
                } else {
                    if ($s < -500) {
                        db_query($link, "UPDATE ttrss_user_entries SET score = '{$s}',\n\t\t\t\t\t\t\tunread = false WHERE\n\t\t\t\t\t\t\tref_id IN (" . join(',', $scores[$s]) . ")");
                    } else {
                        db_query($link, "UPDATE ttrss_user_entries SET score = '{$s}' WHERE\n\t\t\t\t\t\t\tref_id IN (" . join(',', $scores[$s]) . ")");
                    }
                }
            }
        }
        print __("All done.");
    }
    if ($subop == "rescoreAll") {
        $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE owner_uid = " . $_SESSION['uid']);
        while ($feed_line = db_fetch_assoc($result)) {
            $id = $feed_line["id"];
            $filters = load_filters($link, $id, $_SESSION["uid"], 6);
            $tmp_result = db_query($link, "SELECT\n\t\t\t\t\ttitle, content, link, ref_id, author," . SUBSTRING_FOR_DATE . "(updated, 1, 19) AS updated\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\tttrss_user_entries, ttrss_entries\n\t\t\t\t\t\tWHERE ref_id = id AND feed_id = '{$id}' AND\n\t\t\t\t\t\t\towner_uid = " . $_SESSION['uid'] . "\n\t\t\t\t\t\t");
            $scores = array();
            while ($line = db_fetch_assoc($tmp_result)) {
                $tags = get_article_tags($link, $line["ref_id"]);
                $article_filters = get_article_filters($filters, $line['title'], $line['content'], $line['link'], strtotime($line['updated']), $line['author'], $tags);
                $new_score = calculate_article_score($article_filters);
                if (!$scores[$new_score]) {
                    $scores[$new_score] = array();
                }
                array_push($scores[$new_score], $line['ref_id']);
            }
            foreach (array_keys($scores) as $s) {
                if ($s > 1000) {
                    db_query($link, "UPDATE ttrss_user_entries SET score = '{$s}',\n\t\t\t\t\t\t\tmarked = true WHERE\n\t\t\t\t\t\t\tref_id IN (" . join(',', $scores[$s]) . ")");
                } else {
                    db_query($link, "UPDATE ttrss_user_entries SET score = '{$s}' WHERE\n\t\t\t\t\t\t\tref_id IN (" . join(',', $scores[$s]) . ")");
                }
            }
        }
        print __("All done.");
    }
    if ($subop == "add") {
        $feed_url = db_escape_string(trim($_REQUEST["feed_url"]));
        $cat_id = db_escape_string($_REQUEST["cat_id"]);
        $p_from = db_escape_string($_REQUEST["from"]);
        /* only read authentication information from POST */
        $auth_login = db_escape_string(trim($_POST["auth_login"]));
        $auth_pass = db_escape_string(trim($_POST["auth_pass"]));
        if ($p_from != 'tt-rss') {
            header("Content-Type: text/html");
            print "<html>\n\t\t\t\t\t<head>\n\t\t\t\t\t\t<title>Tiny Tiny RSS</title>\n\t\t\t\t\t\t<link rel=\"stylesheet\" type=\"text/css\" href=\"utility.css\">\n\t\t\t\t\t</head>\n\t\t\t\t\t<body>\n\t\t\t\t\t<img class=\"floatingLogo\" src=\"images/ttrss_logo.png\"\n\t\t\t\t  \t\talt=\"Tiny Tiny RSS\"/>\n\t\t\t\t\t<h1>Subscribe to feed...</h1>";
        }
        $rc = subscribe_to_feed($link, $feed_url, $cat_id, $auth_login, $auth_pass);
        switch ($rc) {
            case 1:
                print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url));
                break;
            case 2:
                print_error(T_sprintf("Could not subscribe to <b>%s</b>.", $feed_url));
                break;
            case 3:
                print_error(T_sprintf("No feeds found in <b>%s</b>.", $feed_url));
                break;
            case 0:
                print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url));
                break;
            case 4:
                print_notice("Multiple feed URLs found.");
                $feed_urls = get_feeds_from_html($feed_url);
                break;
            case 5:
                print_error(T_sprintf("Could not subscribe to <b>%s</b>.<br>Can't download the Feed URL.", $feed_url));
                break;
        }
        if ($p_from != 'tt-rss') {
            if ($feed_urls) {
                print "<form action=\"backend.php\">";
                print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">";
                print "<input type=\"hidden\" name=\"quiet\" value=\"1\">";
                print "<input type=\"hidden\" name=\"subop\" value=\"add\">";
                print "<select name=\"feed_url\">";
                foreach ($feed_urls as $url => $name) {
                    $url = htmlspecialchars($url);
                    $name = htmlspecialchars($name);
                    print "<option value=\"{$url}\">{$name}</option>";
                }
                print "<input type=\"submit\" value=\"" . __("Subscribe to selected feed") . "\">";
                print "</form>";
            }
            $tp_uri = get_self_url_prefix() . "/prefs.php";
            $tt_uri = get_self_url_prefix();
            if ($rc <= 2) {
                $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE\n\t\t\t\t\t\tfeed_url = '{$feed_url}' AND owner_uid = " . $_SESSION["uid"]);
                $feed_id = db_fetch_result($result, 0, "id");
            } else {
                $feed_id = 0;
            }
            print "<p>";
            if ($feed_id) {
                print "<form method=\"GET\" style='display: inline'\n\t\t\t\t\t\taction=\"{$tp_uri}\">\n\t\t\t\t\t\t<input type=\"hidden\" name=\"tab\" value=\"feedConfig\">\n\t\t\t\t\t\t<input type=\"hidden\" name=\"subop\" value=\"editFeed\">\n\t\t\t\t\t\t<input type=\"hidden\" name=\"subopparam\" value=\"{$feed_id}\">\n\t\t\t\t\t\t<input type=\"submit\" value=\"" . __("Edit subscription options") . "\">\n\t\t\t\t\t\t</form>";
            }
            print "<form style='display: inline' method=\"GET\" action=\"{$tt_uri}\">\n\t\t\t\t\t<input type=\"submit\" value=\"" . __("Return to Tiny Tiny RSS") . "\">\n\t\t\t\t\t</form></p>";
            print "</body></html>";
            return;
        }
    }
    if ($subop == "categorize") {
        $ids = split(",", db_escape_string($_REQUEST["ids"]));
        $cat_id = db_escape_string($_REQUEST["cat_id"]);
        if ($cat_id == 0) {
            $cat_id_qpart = 'NULL';
        } else {
            $cat_id_qpart = "'{$cat_id}'";
        }
        db_query($link, "BEGIN");
        foreach ($ids as $id) {
            db_query($link, "UPDATE ttrss_feeds SET cat_id = {$cat_id_qpart}\n\t\t\t\t\tWHERE id = '{$id}'\n\t\t\t\t  \tAND owner_uid = " . $_SESSION["uid"]);
        }
        db_query($link, "COMMIT");
    }
    if ($subop == "editCats") {
        $action = $_REQUEST["action"];
        if ($action == "save") {
            $cat_title = db_escape_string(trim($_REQUEST["value"]));
            $cat_id = db_escape_string($_REQUEST["cid"]);
            db_query($link, "BEGIN");
            $result = db_query($link, "SELECT title FROM ttrss_feed_categories\n\t\t\t\t\tWHERE id = '{$cat_id}' AND owner_uid = " . $_SESSION["uid"]);
            if (db_num_rows($result) == 1) {
                $old_title = db_fetch_result($result, 0, "title");
                if ($cat_title != "") {
                    $result = db_query($link, "UPDATE ttrss_feed_categories SET\n\t\t\t\t\t\t\ttitle = '{$cat_title}' WHERE id = '{$cat_id}' AND\n\t\t\t\t\t\t\towner_uid = " . $_SESSION["uid"]);
                    print $cat_title;
                } else {
                    print $old_title;
                }
            } else {
                print $_REQUEST["value"];
            }
            db_query($link, "COMMIT");
            return;
        }
        if ($action == "add") {
            $feed_cat = db_escape_string(trim($_REQUEST["cat"]));
            if (!add_feed_category($link, $feed_cat)) {
                print_warning(T_sprintf("Category <b>\$%s</b> already exists in the database.", $feed_cat));
            }
        }
        if ($action == "remove") {
            $ids = split(",", db_escape_string($_REQUEST["ids"]));
            foreach ($ids as $id) {
                remove_feed_category($link, $id, $_SESSION["uid"]);
            }
        }
        print "<div dojoType=\"dijit.Toolbar\">\n\t\t\t\t<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" name=\"newcat\">\n\t\t\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedCatEditDlg').addCategory()\">" . __('Create category') . "</button></div>";
        $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories\n\t\t\t\tWHERE owner_uid = " . $_SESSION["uid"] . "\n\t\t\t\tORDER BY title");
        #			print "<p>";
        if (db_num_rows($result) != 0) {
            print "<div class=\"prefFeedCatHolder\">";
            #				print "<form id=\"feed_cat_edit_form\" onsubmit=\"return false\">";
            print "<table width=\"100%\" class=\"prefFeedCatList\"\n\t\t\t\t\tcellspacing=\"0\" id=\"prefFeedCatList\">";
            $lnum = 0;
            while ($line = db_fetch_assoc($result)) {
                $class = $lnum % 2 ? "even" : "odd";
                $cat_id = $line["id"];
                $this_row_id = "id=\"FCATR-{$cat_id}\"";
                print "<tr class=\"\" {$this_row_id}>";
                $edit_title = htmlspecialchars($line["title"]);
                print "<td width='5%' align='center'><input\n\t\t\t\t\t\tonclick='toggleSelectRow2(this);' dojoType=\"dijit.form.CheckBox\"\n\t\t\t\t\t\ttype=\"checkbox\"></td>";
                print "<td>";
                #					print "<span id=\"FCATT-$cat_id\">" .
                #						$edit_title . "</span>";
                print "<span dojoType=\"dijit.InlineEditBox\"\n\t\t\t\t\t\twidth=\"300px\" autoSave=\"false\"\n\t\t\t\t\t\tcat-id=\"{$cat_id}\">" . $edit_title . "<script type=\"dojo/method\" event=\"onChange\" args=\"item\">\n\t\t\t\t\t\t\tvar elem = this;\n\t\t\t\t\t\t\tdojo.xhrPost({\n\t\t\t\t\t\t\t\turl: 'backend.php',\n\t\t\t\t\t\t\t\tcontent: {op: 'pref-feeds', subop: 'editCats',\n\t\t\t\t\t\t\t\t\taction: 'save',\n\t\t\t\t\t\t\t\t\tvalue: this.value,\n\t\t\t\t\t\t\t\t\tcid: this.srcNodeRef.getAttribute('cat-id')},\n\t\t\t\t\t\t\t\t\tload: function(response) {\n\t\t\t\t\t\t\t\t\t\telem.attr('value', response);\n\t\t\t\t\t\t\t\t\t\tupdateFeedList();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t</script>\n\t\t\t\t\t</span>";
                print "</td></tr>";
                ++$lnum;
            }
            print "</table>";
            #				print "</form>";
            print "</div>";
        } else {
            print "<p>" . __('No feed categories defined.') . "</p>";
        }
        print "<div class='dlgButtons'>\n\t\t\t\t<div style='float : left'>\n\t\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedCatEditDlg').removeSelected()\">" . __('Remove selected categories') . "</button>\n\t\t\t\t</div>";
        print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedCatEditDlg').hide()\">" . __('Close this window') . "</button></div>";
        return;
    }
    if ($quiet) {
        return;
    }
    print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">";
    print "<div id=\"pref-feeds-feeds\" dojoType=\"dijit.layout.AccordionPane\" title=\"" . __('Feeds') . "\">";
    /* print "<div dojoType=\"dijit.layout.BorderContainer\">";
    		print "<
    			print "</div>"; */
    $result = db_query($link, "SELECT COUNT(id) AS num_errors\n\t\t\tFROM ttrss_feeds WHERE last_error != '' AND owner_uid = " . $_SESSION["uid"]);
    $num_errors = db_fetch_result($result, 0, "num_errors");
    if ($num_errors > 0) {
        $error_button = "<button dojoType=\"dijit.form.Button\"\n\t\t\t  \t\tonclick=\"showFeedsWithErrors()\" id=\"errorButton\">" . __("Feeds with errors") . "</button>";
        //			print format_notice("<a href=\"javascript:showFeedsWithErrors()\">".
        //				__('Some feeds have update errors (click for details)')."</a>");
    }
    if (DB_TYPE == "pgsql") {
        $interval_qpart = "NOW() - INTERVAL '3 months'";
    } else {
        $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)";
    }
    $result = db_query($link, "SELECT COUNT(*) AS num_inactive FROM ttrss_feeds WHERE\n\t\t\t\t\t(SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE\n\t\t\t\t\t\tttrss_entries.id = ref_id AND\n\t\t\t\t\t\t\tttrss_user_entries.feed_id = ttrss_feeds.id) < {$interval_qpart} AND\n\t\t\tttrss_feeds.owner_uid = " . $_SESSION["uid"]);
    $num_inactive = db_fetch_result($result, 0, "num_inactive");
    if ($num_inactive > 0) {
        $inactive_button = "<button dojoType=\"dijit.form.Button\"\n\t\t\t  \t\tonclick=\"showInactiveFeeds()\">" . __("Inactive feeds") . "</button>";
    }
    $feed_search = db_escape_string($_REQUEST["search"]);
    if (array_key_exists("search", $_REQUEST)) {
        $_SESSION["prefs_feed_search"] = $feed_search;
    } else {
        $feed_search = $_SESSION["prefs_feed_search"];
    }
    print '<div dojoType="dijit.layout.BorderContainer" gutters="false">';
    print "<div region='top' dojoType=\"dijit.Toolbar\">";
    #toolbar
    print "<div style='float : right; padding-right : 4px;'>\n\t\t\t<input dojoType=\"dijit.form.TextBox\" id=\"feed_search\" size=\"20\" type=\"search\"\n\t\t\t\tvalue=\"{$feed_search}\">\n\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"updateFeedList()\">" . __('Search') . "</button>\n\t\t\t</div>";
    print "<div dojoType=\"dijit.form.DropDownButton\">" . "<span>" . __('Select') . "</span>";
    print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
    print "<div onclick=\"dijit.byId('feedTree').model.setAllChecked(true)\"\n\t\t\tdojoType=\"dijit.MenuItem\">" . __('All') . "</div>";
    print "<div onclick=\"dijit.byId('feedTree').model.setAllChecked(false)\"\n\t\t\tdojoType=\"dijit.MenuItem\">" . __('None') . "</div>";
    print "</div></div>";
    print "<div dojoType=\"dijit.form.DropDownButton\">" . "<span>" . __('Feeds') . "</span>";
    print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
    print "<div onclick=\"quickAddFeed()\"\n\t\t\tdojoType=\"dijit.MenuItem\">" . __('Subscribe to feed') . "</div>";
    print "<div onclick=\"editSelectedFeed()\"\n\t\t\tdojoType=\"dijit.MenuItem\">" . __('Edit selected feeds') . "</div>";
    print "<div onclick=\"resetFeedOrder()\"\n\t\t\tdojoType=\"dijit.MenuItem\">" . __('Reset sort order') . "</div>";
    print "</div></div>";
    if (get_pref($link, 'ENABLE_FEED_CATS')) {
        print "<div dojoType=\"dijit.form.DropDownButton\">" . "<span>" . __('Categories') . "</span>";
        print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
        print "<div onclick=\"editFeedCats()\"\n\t\t\t\tdojoType=\"dijit.MenuItem\">" . __('Edit categories') . "</div>";
        print "<div onclick=\"resetCatOrder()\"\n\t\t\t\tdojoType=\"dijit.MenuItem\">" . __('Reset sort order') . "</div>";
        print "</div></div>";
    }
    print $error_button;
    print $inactive_button;
    print "<button dojoType=\"dijit.form.Button\" onclick=\"removeSelectedFeeds()\">" . __('Unsubscribe') . "</button dojoType=\"dijit.form.Button\"> ";
    if (defined('_ENABLE_FEED_DEBUGGING')) {
        print "<select id=\"feedActionChooser\" onchange=\"feedActionChange()\">\n\t\t\t\t<option value=\"facDefault\" selected>" . __('More actions...') . "</option>";
        if (FORCE_ARTICLE_PURGE == 0) {
            print "<option value=\"facPurge\">" . __('Manual purge') . "</option>";
        }
        print "\n\t\t\t\t<option value=\"facClear\">" . __('Clear feed data') . "</option>\n\t\t\t\t<option value=\"facRescore\">" . __('Rescore articles') . "</option>";
        print "</select>";
    }
    print "</div>";
    # toolbar
    //print '</div>';
    print '<div dojoType="dijit.layout.ContentPane" region="center">';
    print "<div id=\"feedlistLoading\">\n\t\t<img src='images/indicator_tiny.gif'>" . __("Loading, please wait...") . "</div>";
    print "<div dojoType=\"fox.PrefFeedStore\" jsId=\"feedStore\"\n\t\t\turl=\"backend.php?op=pref-feeds&subop=getfeedtree\">\n\t\t</div>\n\t\t<div dojoType=\"lib.CheckBoxStoreModel\" jsId=\"feedModel\" store=\"feedStore\"\n\t\tquery=\"{id:'root'}\" rootId=\"root\" rootLabel=\"Feeds\"\n\t\t\tchildrenAttrs=\"items\" checkboxStrict=\"false\" checkboxAll=\"false\">\n\t\t</div>\n\t\t<div dojoType=\"fox.PrefFeedTree\" id=\"feedTree\"\n\t\t\tdndController=\"dijit.tree.dndSource\"\n\t\t\tbetweenThreshold=\"5\"\n\t\t\tmodel=\"feedModel\" openOnClick=\"false\">\n\t\t<script type=\"dojo/method\" event=\"onClick\" args=\"item\">\n\t\t\tvar id = String(item.id);\n\t\t\tvar bare_id = id.substr(id.indexOf(':')+1);\n\n\t\t\tif (id.match('FEED:')) {\n\t\t\t\teditFeed(bare_id);\n\t\t\t} else if (id.match('CAT:')) {\n\t\t\t\teditCat(bare_id, item);\n\t\t\t}\n\t\t</script>\n\t\t<script type=\"dojo/method\" event=\"onLoad\" args=\"item\">\n\t\t\tElement.hide(\"feedlistLoading\");\n\t\t</script>\n\t\t</div>";
    print "<div dojoType=\"dijit.Tooltip\" connectId=\"feedTree\" position=\"below\">\n\t\t\t" . __('<b>Hint:</b> you can drag feeds and categories around.') . "\n\t\t\t</div>";
    print '</div>';
    print '</div>';
    print "</div>";
    # feeds pane
    print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"" . __('OPML') . "\">";
    print "<p>" . __("Using OPML you can export and import your feeds and Tiny Tiny RSS settings.") . " ";
    print "<span class=\"insensitive\">" . __("Note: Only main settings profile can be migrated using OPML.") . "</span>";
    print "</p>";
    print "<h3>" . __("Import") . "</h3>";
    print "<br/><iframe id=\"upload_iframe\"\n\t\t\tname=\"upload_iframe\" onload=\"opmlImportComplete(this)\"\n\t\t\tstyle=\"width: 400px; height: 100px; display: none;\"></iframe>";
    print "<form  name=\"opml_form\" style='display : block' target=\"upload_iframe\"\n\t\t\tenctype=\"multipart/form-data\" method=\"POST\"\n\t\t\t\taction=\"backend.php\">\n\t\t\t<input id=\"opml_file\" name=\"opml_file\" type=\"file\">&nbsp;\n\t\t\t<input type=\"hidden\" name=\"op\" value=\"dlg\">\n\t\t\t<input type=\"hidden\" name=\"id\" value=\"importOpml\">\n\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"return opmlImport();\" type=\"submit\">" . __('Import') . "</button>";
    print "<h3>" . __("Export") . "</h3>";
    print "<p>" . __('Filename:') . " <input type=\"text\" id=\"filename\" value=\"TinyTinyRSS.opml\" />&nbsp;" . __('Include settings') . "<input type=\"checkbox\" id=\"settings\" CHECKED />" . "<button dojoType=\"dijit.form.Button\"\n\t\t\tonclick=\"gotoExportOpml(document.opml_form.filename.value, document.opml_form.settings.checked)\" >" . __('Export') . "</button></p></form>";
    print "<h3>" . __("Publish") . "</h3>";
    print "<p>" . __('Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.') . " ";
    print "<span class=\"insensitive\">" . __("Note: Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds.") . "</span>" . "</p>";
    print "<button dojoType=\"dijit.form.Button\" onclick=\"return displayDlg('pubOPMLUrl')\">" . __('Display URL') . "</button> ";
    print "</div>";
    # pane
    if (strpos($_SERVER['HTTP_USER_AGENT'], "Firefox") !== false) {
        print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"" . __('Firefox integration') . "\">";
        print "<p>" . __('This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.') . "</p>";
        print "<p>";
        print "<button onclick='window.navigator.registerContentHandler(" . "\"application/vnd.mozilla.maybe.feed\", " . "\"" . add_feed_url() . "\", " . " \"Tiny Tiny RSS\")'>" . __('Click here to register this site as a feed reader.') . "</button>";
        print "</p>";
        print "</div>";
        # pane
    }
    print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"" . __('Subscribing using bookmarklet') . "\">";
    print "<p>" . __("Drag the link below to your browser toolbar, open the feed you're interested in in your browser and click on the link to subscribe to it.") . "</p>";
    $bm_subscribe_url = str_replace('%s', '', add_feed_url());
    $confirm_str = __('Subscribe to %s in Tiny Tiny RSS?');
    $bm_url = htmlspecialchars("javascript:{if(confirm('{$confirm_str}'.replace('%s',window.location.href)))window.location.href='{$bm_subscribe_url}'+window.location.href}");
    print "<a href=\"{$bm_url}\" class='bookmarklet'>" . __('Subscribe in Tiny Tiny RSS') . "</a>";
    print "</div>";
    #pane
    print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"" . __('Published & shared articles and generated feeds') . "\">";
    print "<h3>" . __("Published articles and generated feeds") . "</h3>";
    print "<p>" . __('Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.') . "</p>";
    $rss_url = '-2::' . htmlspecialchars(get_self_url_prefix() . "/public.php?op=rss&id=-2&view-mode=all_articles");
    print "<button dojoType=\"dijit.form.Button\" onclick=\"return displayDlg('generatedFeed', '{$rss_url}')\">" . __('Display URL') . "</button> ";
    print "<button dojoType=\"dijit.form.Button\" onclick=\"return clearFeedAccessKeys()\">" . __('Clear all generated URLs') . "</button> ";
    print "<h3>" . __("Articles shared by URL") . "</h3>";
    print "<p>" . __("You can disable all articles shared by unique URLs here.") . "</p>";
    print "<button dojoType=\"dijit.form.Button\" onclick=\"return clearArticleAccessKeys()\">" . __('Unshare all articles') . "</button> ";
    print "</div>";
    #pane
    if (defined('CONSUMER_KEY') && CONSUMER_KEY != '') {
        print "<div id=\"pref-feeds-twitter\" dojoType=\"dijit.layout.AccordionPane\" title=\"" . __('Twitter') . "\">";
        $result = db_query($link, "SELECT COUNT(*) AS cid FROM ttrss_users\n\t\t\t\tWHERE twitter_oauth IS NOT NULL AND twitter_oauth != '' AND\n\t\t\t\tid = " . $_SESSION['uid']);
        $is_registered = db_fetch_result($result, 0, "cid") != 0;
        if (!$is_registered) {
            print_notice(__('Before you can update your Twitter feeds, you must register this instance of Tiny Tiny RSS with Twitter.com.'));
        } else {
            print_notice(__('You have been successfully registered with Twitter.com and should be able to access your Twitter feeds.'));
        }
        print "<button dojoType=\"dijit.form.Button\" onclick=\"window.location.href = 'twitter.php?op=register'\">" . __("Register with Twitter.com") . "</button>";
        print " ";
        print "<button dojoType=\"dijit.form.Button\"\n\t\t\t\tonclick=\"return clearTwitterCredentials()\">" . __("Clear stored credentials") . "</button>";
        print "</div>";
        # pane
    }
    print "</div>";
    #container
}