예제 #1
0
파일: dbupdater.php 프로젝트: kucrut/tt-rss
 function performUpdateTo($version, $html_output = true)
 {
     if ($this->getSchemaVersion() == $version - 1) {
         $lines = $this->getSchemaLines($version);
         if (is_array($lines)) {
             db_query("BEGIN");
             foreach ($lines as $line) {
                 if (strpos($line, "--") !== 0 && $line) {
                     if (!db_query($line, false)) {
                         if ($html_output) {
                             print_notice("Query: {$line}");
                             print_error("Error: " . db_last_query_error());
                         } else {
                             _debug("Query: {$line}");
                             _debug("Error: " . db_last_query_error());
                         }
                         return false;
                     }
                 }
             }
             $db_version = $this->getSchemaVersion();
             if ($db_version == $version) {
                 db_query("COMMIT");
                 return true;
             } else {
                 db_query("ROLLBACK");
                 return false;
             }
         } else {
             return true;
         }
     } else {
         return false;
     }
 }
예제 #2
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
 }
예제 #3
0
파일: init.php 프로젝트: kucrut/tt-rss
 function hook_prefs_tab($args)
 {
     if ($args != "prefFeeds") {
         return;
     }
     print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"" . __('af_readability settings') . "\">";
     print_notice("Enable the plugin for specific feeds in the feed editor.");
     print "<form dojoType=\"dijit.form.Form\">";
     print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">\n\t\t\tevt.preventDefault();\n\t\t\tif (this.validate()) {\n\t\t\t\tconsole.log(dojo.objectToQuery(this.getValues()));\n\t\t\t\tnew Ajax.Request('backend.php', {\n\t\t\t\t\tparameters: dojo.objectToQuery(this.getValues()),\n\t\t\t\t\tonComplete: function(transport) {\n\t\t\t\t\t\tnotify_info(transport.responseText);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\t//this.reset();\n\t\t\t}\n\t\t\t</script>";
     print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pluginhandler\">";
     print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"save\">";
     print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"plugin\" value=\"af_readability\">";
     $enable_share_anything = $this->host->get($this, "enable_share_anything");
     $enable_share_anything_checked = $enable_share_anything ? "checked" : "";
     print "<input dojoType=\"dijit.form.CheckBox\"\n\t\t\t{$enable_share_anything_checked} name=\"enable_share_anything\" id=\"enable_share_anything\">\n\t\t\t<label for=\"enable_share_anything\">" . __("Use Readability for pages shared via bookmarklet.") . "</label>";
     print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">" . __("Save") . "</button>";
     print "</form>";
     $enabled_feeds = $this->host->get($this, "enabled_feeds");
     if (!is_array($enabled_feeds)) {
         $enabled_feeds = array();
     }
     $enabled_feeds = $this->filter_unknown_feeds($enabled_feeds);
     $this->host->set($this, "enabled_feeds", $enabled_feeds);
     if (count($enabled_feeds) > 0) {
         print "<h3>" . __("Currently enabled for (click to edit):") . "</h3>";
         print "<ul class=\"browseFeedList\" style=\"border-width : 1px\">";
         foreach ($enabled_feeds as $f) {
             print "<li>" . "<img src='images/pub_set.png'\n\t\t\t\t\t\tstyle='vertical-align : middle'> <a href='#'\n\t\t\t\t\t\tonclick='editFeed({$f})'>" . getFeedTitle($f) . "</a></li>";
         }
         print "</ul>";
     }
     print "</div>";
 }
예제 #4
0
 private function display_main_help()
 {
     $info = get_hotkeys_info();
     $imap = get_hotkeys_map();
     $omap = array();
     foreach ($imap[1] as $sequence => $action) {
         if (!isset($omap[$action])) {
             $omap[$action] = array();
         }
         array_push($omap[$action], $sequence);
     }
     print_notice("<a target=\"_blank\" href=\"http://tt-rss.org/wiki/InterfaceTips\">" . __("Other interface tips are available in the Tiny Tiny RSS wiki.") . "</a>");
     print "<ul class='helpKbList' id='helpKbList'>";
     print "<h2>" . __("Keyboard Shortcuts") . "</h2>";
     foreach ($info as $section => $hotkeys) {
         print "<li><h3>" . $section . "</h3></li>";
         foreach ($hotkeys as $action => $description) {
             if (is_array($omap[$action])) {
                 foreach ($omap[$action] as $sequence) {
                     if (strpos($sequence, "|") !== FALSE) {
                         $sequence = substr($sequence, strpos($sequence, "|") + 1, strlen($sequence));
                     } else {
                         $keys = explode(" ", $sequence);
                         for ($i = 0; $i < count($keys); $i++) {
                             if (strlen($keys[$i]) > 1) {
                                 $tmp = '';
                                 foreach (str_split($keys[$i]) as $c) {
                                     switch ($c) {
                                         case '*':
                                             $tmp .= __('Shift') . '+';
                                             break;
                                         case '^':
                                             $tmp .= __('Ctrl') . '+';
                                             break;
                                         default:
                                             $tmp .= $c;
                                     }
                                 }
                                 $keys[$i] = $tmp;
                             }
                         }
                         $sequence = join(" ", $keys);
                     }
                     print "<li>";
                     print "<span class='hksequence'>{$sequence}</span>";
                     print $description;
                     print "</li>";
                 }
             }
         }
     }
     print "</ul>";
 }
예제 #5
0
파일: init.php 프로젝트: AHinMaine/ttrss
 function hook_prefs_tab($args)
 {
     if ($args != "prefFeeds") {
         return;
     }
     print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"" . __('Import and export') . "\">";
     print_notice(__("You can export and import your Starred and Archived articles for safekeeping or when migrating between tt-rss instances of same version."));
     print "<p>";
     print "<button dojoType=\"dijit.form.Button\" onclick=\"return exportData()\">" . __('Export my data') . "</button> ";
     print "<hr>";
     print "<iframe id=\"data_upload_iframe\"\n\t\t\tname=\"data_upload_iframe\" onload=\"dataImportComplete(this)\"\n\t\t\tstyle=\"width: 400px; height: 100px; display: none;\"></iframe>";
     print "<form name=\"import_form\" style='display : block' target=\"data_upload_iframe\"\n\t\t\tenctype=\"multipart/form-data\" method=\"POST\"\n\t\t\taction=\"backend.php\">\n\t\t\t<input id=\"export_file\" name=\"export_file\" type=\"file\">&nbsp;\n\t\t\t<input type=\"hidden\" name=\"op\" value=\"pluginhandler\">\n\t\t\t<input type=\"hidden\" name=\"plugin\" value=\"import_export\">\n\t\t\t<input type=\"hidden\" name=\"method\" value=\"dataimport\">\n\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"return importData();\" type=\"submit\">" . __('Import') . "</button>";
     print "</form>";
     print "</p>";
     print "</div>";
     # pane
 }
 function hook_prefs_tab($args)
 {
     if ($args == "prefFeeds") {
         print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"" . __('Bookmarklets') . "\">";
         print_notice(__("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."));
         $bm_subscribe_url = str_replace('%s', '', add_feed_url());
         $confirm_str = str_replace("'", "\\'", __('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 "<p>";
         print "<a href=\"{$bm_url}\" class='bookmarklet'>" . __('Subscribe in Tiny Tiny RSS') . "</a>";
         print "</p>";
         print_notice(__("Use this bookmarklet to publish arbitrary pages using Tiny Tiny RSS"));
         print "<p>";
         $bm_url = htmlspecialchars("javascript:(function(){var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='" . SELF_URL_PATH . "/public.php?op=sharepopup',l=d.location,e=encodeURIComponent,g=f+'&title='+((e(s))?e(s):e(document.title))+'&url='+e(l.href);function a(){if(!w.open(g,'t','toolbar=0,resizable=0,scrollbars=1,status=1,width=500,height=250')){l.href=g;}}a();})()");
         print "<a href=\"{$bm_url}\" class='bookmarklet'>" . __('Share with Tiny Tiny RSS') . "</a>";
         print "</p>";
         print "</div>";
         #pane
     }
 }
예제 #7
0
 function hook_prefs_tab($args)
 {
     if ($args != "prefFeeds") {
         return;
     }
     print "<div id=\"af_redditimgur_prefs\" dojoType=\"dijit.layout.AccordionPane\" title=\"" . __('af_redditimgur settings') . "\">";
     $enable_readability = $this->host->get($this, "enable_readability");
     $enable_readability_checked = $enable_readability ? "checked" : "";
     print "<form dojoType=\"dijit.form.Form\">";
     print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">\n\t\t\tevt.preventDefault();\n\t\t\tif (this.validate()) {\n\t\t\t\tconsole.log(dojo.objectToQuery(this.getValues()));\n\t\t\t\tnew Ajax.Request('backend.php', {\n\t\t\t\t\tparameters: dojo.objectToQuery(this.getValues()),\n\t\t\t\t\tonComplete: function(transport) {\n\t\t\t\t\t\tnotify_info(transport.responseText);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\t//this.reset();\n\t\t\t}\n\t\t\t</script>";
     print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pluginhandler\">";
     print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"save\">";
     print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"plugin\" value=\"af_redditimgur\">";
     print "<h3>" . __("Global settings") . "</h3>";
     print_notice("Uses Readability (full-text-rss) implementation by <a target='_blank' href='https://bitbucket.org/fivefilters/'>FiveFilters.org</a>");
     print "<p/>";
     print "<input dojoType=\"dijit.form.CheckBox\" id=\"enable_readability\"\n\t\t\t{$enable_readability_checked} name=\"enable_readability\">&nbsp;";
     print "<label for=\"enable_readability\">" . __("Extract missing content using Readability") . "</label>";
     print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">" . __("Save") . "</button>";
     print "</form>";
     print "</div>";
 }
예제 #8
0
파일: init.php 프로젝트: Verisor/tt-rss
 function hook_prefs_tab($args)
 {
     if ($args != "prefFeeds") {
         return;
     }
     print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"" . __('af_readability settings') . "\">";
     print_notice("Enable the plugin for specific feeds in the feed editor.");
     $enabled_feeds = $this->host->get($this, "enabled_feeds");
     if (!array($enabled_feeds)) {
         $enabled_feeds = array();
     }
     $enabled_feeds = $this->filter_unknown_feeds($enabled_feeds);
     $this->host->set($this, "enabled_feeds", $enabled_feeds);
     if (count($enabled_feeds) > 0) {
         print "<h3>" . __("Currently enabled for (click to edit):") . "</h3>";
         print "<ul class=\"browseFeedList\" style=\"border-width : 1px\">";
         foreach ($enabled_feeds as $f) {
             print "<li>" . "<img src='images/pub_set.png'\n\t\t\t\t\t\tstyle='vertical-align : middle'> <a href='#'\n\t\t\t\t\t\tonclick='editFeed({$f})'>" . getFeedTitle($f) . "</a></li>";
         }
         print "</ul>";
     }
     print "</div>";
 }
예제 #9
0
                    }
                }
            } else {
                print_error('Plese check the form again, you have failed the robot test.');
                print "<p><form method=\"GET\" action=\"index.php\">\n\t\t\t\t<input type=\"submit\" value=\"" . __("Return to Tiny Tiny RSS") . "\">\n\t\t\t\t</form>";
            }
        }
    }
    ?>

<?php 
} else {
    ?>

	<?php 
    print_notice(__('New user registrations are currently closed.'));
    ?>

	<?php 
    print "<p><form method=\"GET\" action=\"index.php\">\n\t\t\t\t<input type=\"submit\" value=\"" . __("Return to Tiny Tiny RSS") . "\">\n\t\t\t\t</form>";
    ?>

<?php 
}
?>

	</div>

</body>
</html>
예제 #10
0
    function quickAddFeed()
    {
        print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
        print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"addfeed\">";
        print "<div id='fadd_multiple_notify' style='display : none'>";
        print_notice("Provided URL is a HTML page referencing multiple feeds, please select required feed from the dropdown menu below.");
        print "<p></div>";
        print "<div class=\"dlgSec\">" . __("Feed or site URL") . "</div>";
        print "<div class=\"dlgSecCont\">";
        print "<div style='float : right'>\n\t\t\t<img style='display : none'\n\t\t\t\tid='feed_add_spinner' src='images/indicator_white.gif'></div>";
        print "<input style=\"font-size : 16px; width : 20em;\"\n\t\t\tplaceHolder=\"" . __("Feed or site URL") . "\"\n\t\t\tdojoType=\"dijit.form.ValidationTextBox\" required=\"1\" name=\"feed\" id=\"feedDlg_feedUrl\">";
        print "<hr/>";
        if (get_pref('ENABLE_FEED_CATS')) {
            print __('Place in category:') . " ";
            print_feed_cat_select("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<div class=\"dlgSec\">" . __("Authentication") . "</div>\n\t\t\t\t<div class=\"dlgSecCont\">" . " <input dojoType=\"dijit.form.TextBox\" name='login'\"\n\t\t\t\t\tplaceHolder=\"" . __("Login") . "\"\n\t\t\t\t\tstyle=\"width : 10em;\"> " . " <input\n\t\t\t\t\tplaceHolder=\"" . __("Password") . "\"\n\t\t\t\t\tdojoType=\"dijit.form.TextBox\" type='password'\n\t\t\t\t\tstyle=\"width : 10em;\" name='pass'\">\n\t\t\t</div></div>";
        print "<div style=\"clear : both\">\n\t\t\t<input type=\"checkbox\" name=\"need_auth\" dojoType=\"dijit.form.CheckBox\" id=\"feedDlg_loginCheck\"\n\t\t\t\t\tonclick='checkboxToggleElement(this, \"feedDlg_loginContainer\")'>\n\t\t\t\t<label for=\"feedDlg_loginCheck\">" . __('This feed requires authentication.') . "</div>";
        print "</form>";
        print "<div class=\"dlgButtons\">\n\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedAddDlg').execute()\">" . __('Subscribe') . "</button>";
        if (!(defined('_DISABLE_FEED_BROWSER') && _DISABLE_FEED_BROWSER)) {
            print "<button dojoType=\"dijit.form.Button\" onclick=\"return feedBrowser()\">" . __('More feeds') . "</button>";
        }
        print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('feedAddDlg').hide()\">" . __('Cancel') . "</button>\n\t\t\t</div>";
        //return;
    }
 function customizeCSS()
 {
     $value = get_pref("USER_STYLESHEET");
     $value = str_replace("<br/>", "\n", $value);
     print_notice(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.", "css/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=\"method\" 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\tstyle='font-size : 12px; width : 100%; height: 200px;'\n\t\t\tplaceHolder='body#ttrssMain { font-size : 14px; };'\n\t\t\tname='value'>{$value}</textarea>";
     print "</td></tr></table>";
     print "<div class='dlgButtons'>";
     print "<button dojoType=\"dijit.form.Button\"\n\t\t\tonclick=\"dijit.byId('cssEditDlg').execute()\">" . __('Save') . "</button> ";
     print "<button dojoType=\"dijit.form.Button\"\n\t\t\tonclick=\"dijit.byId('cssEditDlg').hide()\">" . __('Cancel') . "</button>";
     print "</div>";
 }
    function dbupdate()
    {
        startup_gettext();
        if (!SINGLE_USER_MODE && $_SESSION["access_level"] < 10) {
            $_SESSION["login_error_msg"] = __("Your access level is insufficient to run this script.");
            render_login_form();
            exit;
        }
        ?>
<html>
			<head>
			<title>Database Updater</title>
			<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
			<link rel="stylesheet" type="text/css" href="css/utility.css"/>
			</head>
			<style type="text/css">
				span.ok { color : #009000; font-weight : bold; }
				span.err { color : #ff0000; font-weight : bold; }
			</style>
		<body>
			<script type='text/javascript'>
			function confirmOP() {
				return confirm("Update the database?");
			}
			</script>

			<div class="floatingLogo"><img src="images/logo_small.png"></div>

			<h1><?php 
        echo __("Database Updater");
        ?>
</h1>

			<div class="content">

			<?php 
        @($op = $_REQUEST["subop"]);
        $updater = new DbUpdater(Db::get(), DB_TYPE, SCHEMA_VERSION);
        if ($op == "performupdate") {
            if ($updater->isUpdateRequired()) {
                print "<h2>Performing updates</h2>";
                print "<h3>Updating to schema version " . SCHEMA_VERSION . "</h3>";
                print "<ul>";
                for ($i = $updater->getSchemaVersion() + 1; $i <= SCHEMA_VERSION; $i++) {
                    print "<li>Performing update up to version {$i}...";
                    $result = $updater->performUpdateTo($i);
                    if (!$result) {
                        print "<span class='err'>FAILED!</span></li></ul>";
                        print_warning("One of the updates failed. Either retry the process or perform updates manually.");
                        print "<p><form method=\"GET\" action=\"index.php\">\n\t\t\t\t\t\t\t\t<input type=\"submit\" value=\"" . __("Return to Tiny Tiny RSS") . "\">\n\t\t\t\t\t\t\t\t</form>";
                        break;
                    } else {
                        print "<span class='ok'>OK!</span></li>";
                    }
                }
                print "</ul>";
                print_notice("Your Tiny Tiny RSS database is now updated to the latest version.");
                print "<p><form method=\"GET\" action=\"index.php\">\n\t\t\t\t\t\t<input type=\"submit\" value=\"" . __("Return to Tiny Tiny RSS") . "\">\n\t\t\t\t\t\t</form>";
            } else {
                print "<h2>Your database is up to date.</h2>";
                print "<p><form method=\"GET\" action=\"index.php\">\n\t\t\t\t\t\t<input type=\"submit\" value=\"" . __("Return to Tiny Tiny RSS") . "\">\n\t\t\t\t\t\t</form>";
            }
        } else {
            if ($updater->isUpdateRequired()) {
                print "<h2>Database update required</h2>";
                print "<h3>";
                printf("Your Tiny Tiny RSS database needs update to the latest version: %d to %d.", $updater->getSchemaVersion(), SCHEMA_VERSION);
                print "</h3>";
                print_warning("Please backup your database before proceeding.");
                print "<form method='POST'>\n\t\t\t\t\t\t\t<input type='hidden' name='subop' value='performupdate'>\n\t\t\t\t\t\t\t<input type='submit' onclick='return confirmOP()' value='" . __("Perform updates") . "'>\n\t\t\t\t\t\t</form>";
            } else {
                print_notice("Tiny Tiny RSS database is up to date.");
                print "<p><form method=\"GET\" action=\"index.php\">\n\t\t\t\t\t\t\t<input type=\"submit\" value=\"" . __("Return to Tiny Tiny RSS") . "\">\n\t\t\t\t\t\t</form>";
            }
        }
        ?>

			</div>
			</body>
			</html>
		<?php 
    }
예제 #13
0
function module_pref_filters($link)
{
    $subop = $_REQUEST["subop"];
    $quiet = $_REQUEST["quiet"];
    if ($subop == "edit") {
        $filter_id = db_escape_string($_REQUEST["id"]);
        $result = db_query($link, "SELECT * FROM ttrss_filters WHERE id = '{$filter_id}' AND owner_uid = " . $_SESSION["uid"]);
        $reg_exp = htmlspecialchars(db_fetch_result($result, 0, "reg_exp"));
        $filter_type = db_fetch_result($result, 0, "filter_type");
        $feed_id = db_fetch_result($result, 0, "feed_id");
        $action_id = db_fetch_result($result, 0, "action_id");
        $action_param = db_fetch_result($result, 0, "action_param");
        $filter_param = db_fetch_result($result, 0, "filter_param");
        $enabled = sql_bool_to_bool(db_fetch_result($result, 0, "enabled"));
        $inverse = sql_bool_to_bool(db_fetch_result($result, 0, "inverse"));
        print "<div id=\"infoBoxTitle\">" . __('Filter Editor') . "</div>";
        print "<div class=\"infoBoxContents\">";
        print "<form id=\"filter_edit_form\" onsubmit='return false'>";
        print "<input type=\"hidden\" name=\"op\" value=\"pref-filters\">";
        print "<input type=\"hidden\" name=\"id\" value=\"{$filter_id}\">";
        print "<input type=\"hidden\" name=\"subop\" value=\"editSave\">";
        $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\">";
        if ($filter_type != 5) {
            $date_ops_invisible = 'style="display : none"';
        }
        print "<span id=\"filter_dlg_date_mod_box\" {$date_ops_invisible}>";
        print __("Date") . " ";
        $filter_params = array("before" => __("before"), "after" => __("after"));
        print_select_hash("filter_date_modifier", $filter_param, $filter_params);
        print "&nbsp;</span>";
        print "<input onkeypress=\"return filterCR(event, filterEditSave)\"\n\t\t\t\t\t name=\"reg_exp\" size=\"30\" value=\"{$reg_exp}\">";
        print "<span id=\"filter_dlg_date_chk_box\" {$date_ops_invisible}>";
        print "&nbsp;<input class=\"button\"\n\t\t\t\ttype=\"submit\" onclick=\"return filterDlgCheckDate()\" \n\t\t\t\tvalue=\"" . __('Check it') . "\">";
        print "</span>";
        print "<br/> " . __("on field") . " ";
        print_select_hash("filter_type", $filter_type, $filter_types, 'onchange="filterDlgCheckType(this)"');
        print "<br/>";
        print __("in") . " ";
        print_feed_select($link, "feed_id", $feed_id);
        print "</div>";
        print "<div class=\"dlgSec\">" . __("Perform Action") . "</div>";
        print "<div class=\"dlgSecCont\">";
        print "<select name=\"action_id\"\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)) {
            $is_sel = $line["id"] == $action_id ? "selected" : "";
            printf("<option value='%d' {$is_sel}>%s</option>", $line["id"], __($line["description"]));
        }
        print "</select>";
        $param_hidden = $action_id == 4 || $action_id == 6 || $action_id == 7 ? "" : "display : none";
        print "<span id=\"filter_dlg_param_box\" style=\"{$param_hidden}\">";
        print " " . __("with parameters:") . " ";
        $param_int_hidden = $action_id != 7 ? "" : "display : none";
        print "<input size=\"20\" style=\"{$param_int_hidden}\"\n\t\t\t\t\tonkeypress=\"return filterCR(event, filterEditSave)\"\t\t\n\t\t\t\t\tname=\"action_param\" value=\"{$action_param}\">";
        $param_int_hidden = $action_id == 7 ? "" : "display : none";
        print_label_select($link, "action_param_label", $action_param, $param_int_hidden);
        print "</span>";
        print "&nbsp;";
        // tiny layout hack
        print "</div>";
        print "<div class=\"dlgSec\">" . __("Options") . "</div>";
        print "<div class=\"dlgSecCont\">";
        print "<div style=\"line-height : 100%\">";
        if ($enabled) {
            $checked = "checked";
        } else {
            $checked = "";
        }
        print "<input type=\"checkbox\" name=\"enabled\" id=\"enabled\" {$checked}>\n\t\t\t\t\t<label for=\"enabled\">" . __('Enabled') . "</label><br/>";
        if ($inverse) {
            $checked = "checked";
        } else {
            $checked = "";
        }
        print "<input type=\"checkbox\" name=\"inverse\" id=\"inverse\" {$checked}>\n\t\t\t\t<label for=\"inverse\">" . __('Inverse match') . "</label>";
        print "</div>";
        print "</div>";
        print "<div class=\"dlgButtons\">";
        $reg_exp = htmlspecialchars($reg_exp, ENT_QUOTES);
        // second escaping seems to be needed for javascript
        print "<div style=\"float : left\">";
        print "<button onclick='return removeFilter({$filter_id}, \"{$reg_exp}\")'>" . __('Remove') . "</button>";
        print "</div>";
        print "<button onclick=\"return filterEditSave()\">" . __('Save') . "</button> ";
        print "<button onclick=\"return filterEditCancel()\">" . __('Cancel') . "</button>";
        print "</div>";
        return;
    }
    if ($subop == "editSave") {
        global $memcache;
        if ($memcache) {
            $memcache->flush();
        }
        $reg_exp = db_escape_string(trim($_REQUEST["reg_exp"]));
        $filter_type = db_escape_string(trim($_REQUEST["filter_type"]));
        $filter_id = db_escape_string($_REQUEST["id"]);
        $feed_id = db_escape_string($_REQUEST["feed_id"]);
        $action_id = db_escape_string($_REQUEST["action_id"]);
        $action_param = db_escape_string($_REQUEST["action_param"]);
        $action_param_label = db_escape_string($_REQUEST["action_param_label"]);
        $enabled = checkbox_to_sql_bool(db_escape_string($_REQUEST["enabled"]));
        $inverse = checkbox_to_sql_bool(db_escape_string($_REQUEST["inverse"]));
        # for the time being, no other filters use params anyway...
        $filter_param = db_escape_string($_REQUEST["filter_date_modifier"]);
        if (!$feed_id) {
            $feed_id = 'NULL';
        } else {
            $feed_id = sprintf("'%s'", db_escape_string($feed_id));
        }
        /* When processing 'assign label' filters, action_param_label dropbox
         * overrides action_param */
        if ($action_id == 7) {
            $action_param = $action_param_label;
        }
        $result = db_query($link, "UPDATE ttrss_filters SET \n\t\t\t\t\treg_exp = '{$reg_exp}', \n\t\t\t\t\tfeed_id = {$feed_id},\n\t\t\t\t\taction_id = '{$action_id}',\n\t\t\t\t\tfilter_type = '{$filter_type}',\n\t\t\t\t\tenabled = {$enabled},\n\t\t\t\t\tinverse = {$inverse},\n\t\t\t\t\taction_param = '{$action_param}',\n\t\t\t\t\tfilter_param = '{$filter_param}'\n\t\t\t\t\tWHERE id = '{$filter_id}' AND owner_uid = " . $_SESSION["uid"]);
        if (db_affected_rows($link, $result) != 0) {
            print_notice(T_sprintf("Saved filter <b>%s</b>", htmlspecialchars($reg_exp)));
        }
    }
    if ($subop == "remove") {
        if ($memcache) {
            $memcache->flush();
        }
        $ids = split(",", db_escape_string($_REQUEST["ids"]));
        foreach ($ids as $id) {
            db_query($link, "DELETE FROM ttrss_filters WHERE id = '{$id}' AND owner_uid = " . $_SESSION["uid"]);
        }
    }
    if ($subop == "add") {
        if ($memcache) {
            $memcache->flush();
        }
        $regexp = db_escape_string(trim($_REQUEST["reg_exp"]));
        $filter_type = db_escape_string(trim($_REQUEST["filter_type"]));
        $feed_id = db_escape_string($_REQUEST["feed_id"]);
        $action_id = db_escape_string($_REQUEST["action_id"]);
        $action_param = db_escape_string($_REQUEST["action_param"]);
        $action_param_label = db_escape_string($_REQUEST["action_param_label"]);
        $inverse = checkbox_to_sql_bool(db_escape_string($_REQUEST["inverse"]));
        # for the time being, no other filters use params anyway...
        $filter_param = db_escape_string($_REQUEST["filter_date_modifier"]);
        if (!$regexp) {
            return;
        }
        if (!$feed_id) {
            $feed_id = 'NULL';
        } else {
            $feed_id = sprintf("'%s'", db_escape_string($feed_id));
        }
        /* When processing 'assign label' filters, action_param_label dropbox
         * overrides action_param */
        if ($action_id == 7) {
            $action_param = $action_param_label;
        }
        $result = db_query($link, "INSERT INTO ttrss_filters (reg_exp,filter_type,owner_uid,feed_id,\n\t\t\t\t\taction_id, action_param, inverse, filter_param) \n\t\t\t\tVALUES \n\t\t\t\t\t('{$regexp}', '{$filter_type}','" . $_SESSION["uid"] . "', \n\t\t\t\t\t\t{$feed_id}, '{$action_id}', '{$action_param}', {$inverse}, '{$filter_param}')");
        if (db_affected_rows($link, $result) != 0) {
            print T_sprintf("Created filter <b>%s</b>", htmlspecialchars($regexp));
        }
        return;
    }
    if ($quiet) {
        return;
    }
    set_pref($link, "_PREFS_ACTIVE_TAB", "filterConfig");
    $sort = db_escape_string($_REQUEST["sort"]);
    if (!$sort || $sort == "undefined") {
        $sort = "reg_exp";
    }
    //		print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>";
    $result = db_query($link, "SELECT id,description \n\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"];
    }
    $filter_search = db_escape_string($_REQUEST["search"]);
    if (array_key_exists("search", $_REQUEST)) {
        $_SESSION["prefs_filter_search"] = $filter_search;
    } else {
        $filter_search = $_SESSION["prefs_filter_search"];
    }
    print "<div style='float : right'>\n\t\t\t<input id=\"filter_search\" size=\"20\" type=\"search\"\n\t\t\t\tonfocus=\"javascript:disableHotkeys();\" \n\t\t\t\tonblur=\"javascript:enableHotkeys();\"\n\t\t\t\tonchange=\"javascript:updateFilterList()\" value=\"{$filter_search}\">\n\t\t\t<button onclick=\"javascript:updateFilterList()\">" . __('Search') . "</button>\n\t\t\t&nbsp;\n\t\t\t<a class='helpLinkPic' href=\"javascript:displayHelpInfobox(2)\">\n\t\t\t<img style='vertical-align : top;' src='" . theme_image($link, "images/sign_quest.png") . "'></a>\n\t\t</div>";
    print "<button onclick=\"return quickAddFilter()\">" . __('Create filter') . "</button> ";
    print "<button onclick=\"return editSelectedFilter()\">" . __('Edit') . "</button> ";
    print "<button onclick=\"return removeSelectedFilters()\">" . __('Remove') . "</button> ";
    print "<button onclick=\"rescore_all_feeds()\">" . __('Rescore articles') . "</button> ";
    if ($filter_search) {
        $filter_search = split(' ', db_escape_string($filter_search));
        $tokens = array();
        foreach ($filter_search as $token) {
            $token = trim($token);
            array_push($tokens, "(\n\t\t\t\t\tUPPER(ttrss_filter_actions.description) LIKE UPPER('%{$token}%') OR \n\t\t\t\t\tUPPER(reg_exp) LIKE UPPER('%{$token}%') OR \n\t\t\t\t\tUPPER(action_param) LIKE UPPER('%{$token}%') OR \n\t\t\t\t\tUPPER(ttrss_feeds.title) LIKE UPPER('%{$token}%') OR\n\t\t\t\t\tUPPER(ttrss_filter_types.description) LIKE UPPER('%{$token}%'))");
        }
        $filter_search_query = "(" . join($tokens, " AND ") . ") AND ";
    } else {
        $filter_search_query = "";
    }
    $result = db_query($link, "SELECT \n\t\t\t\tttrss_filters.id AS id,reg_exp,\n\t\t\t\tttrss_filter_types.name AS filter_type_name,\n\t\t\t\tttrss_filter_types.description AS filter_type_descr,\n\t\t\t\tenabled,\n\t\t\t\tinverse,\n\t\t\t\tfeed_id,\n\t\t\t\tfilter_param,\n\t\t\t\tfilter_type,\n\t\t\t\tttrss_filter_actions.description AS action_description,\n\t\t\t\tttrss_feeds.title AS feed_title,\n\t\t\t\tttrss_filter_actions.name AS action_name,\n\t\t\t\tttrss_filters.action_param AS action_param\n\t\t\tFROM \n\t\t\t\tttrss_filter_types,ttrss_filter_actions,ttrss_filters LEFT JOIN\n\t\t\t\t\tttrss_feeds ON (ttrss_filters.feed_id = ttrss_feeds.id)\n\t\t\tWHERE\n\t\t\t\tfilter_type = ttrss_filter_types.id AND\n\t\t\t\t{$filter_search_query}\n\t\t\t\tttrss_filter_actions.id = action_id AND\n\t\t\t\tttrss_filters.owner_uid = " . $_SESSION["uid"] . "\n\t\t\tORDER by action_description, {$sort}");
    if (db_num_rows($result) != 0) {
        print "<p><table width=\"100%\" cellspacing=\"0\" class=\"prefFilterList\" \n\t\t\t\tid=\"prefFilterList\">";
        print "<tr><td class=\"selectPrompt\" colspan=\"8\">\n\t\t\t\t" . __('Select:') . " \n\t\t\t\t\t<a href=\"javascript:selectPrefRows('filter', true)\">" . __('All') . "</a>,\n\t\t\t\t\t<a href=\"javascript:selectPrefRows('filter', false)\">" . __('None') . "</a>\n\t\t\t\t</td</tr>";
        $lnum = 0;
        $cur_action_description = "";
        while ($line = db_fetch_assoc($result)) {
            $filter_id = $line["id"];
            $edit_filter_id = $_REQUEST["id"];
            $enabled = sql_bool_to_bool($line["enabled"]);
            $inverse = sql_bool_to_bool($line["inverse"]);
            $this_row_id = "id=\"FILRR-{$filter_id}\"";
            $line["filter_type_descr"] = __($line["filter_type_descr"]);
            $line["action_description"] = __($line["action_description"]);
            if ($line["action_description"] != $cur_action_description) {
                $cur_action_description = $line["action_description"];
                print "<tr><td class='filterEditCat' colspan='6'>{$cur_action_description}</td></tr>";
                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=\"20%\"><a href=\"javascript:updateFilterList('reg_exp')\">" . __('Match') . "</a></td>\n\t\t\t\t\t\t<td width=\"\"><a href=\"javascript:updateFilterList('feed_title')\">" . __('Feed') . "</a></td>\n\t\t\t\t\t\t<td width=\"20%\"><a href=\"javascript:updateFilterList('filter_type')\">" . __('Field') . "</a></td>\n\t\t\t\t\t\t<td width=\"20%\"><a href=\"javascript:updateFilterList('action_param')\">" . __('Params') . "</a></td>";
                $lnum = 0;
            }
            $class = $lnum % 2 ? "even" : "odd";
            print "<tr class=\"{$class}\" {$this_row_id}>";
            $line["reg_exp"] = htmlspecialchars($line["reg_exp"]);
            if (!$line["feed_title"]) {
                $line["feed_title"] = __("All feeds");
            }
            if (!$line["action_param"]) {
                $line["action_param"] = "&mdash;";
            } else {
                if ($line["action_name"] == "score") {
                    $score_pic = theme_image($link, "images/" . get_score_pic($line["action_param"]));
                    $score_pic = "<img class='hlScorePic' src=\"{$score_pic}\">";
                    $line["action_param"] = "{$score_pic} " . $line["action_param"];
                }
            }
            $line["feed_title"] = htmlspecialchars($line["feed_title"]);
            print "<td align='center'><input onclick='toggleSelectPrefRow(this, \"filter\");' \n\t\t\t\t\ttype=\"checkbox\" id=\"FICHK-" . $line["id"] . "\"></td>";
            $filter_params = array("before" => __("before"), "after" => __("after"));
            if ($line["action_name"] == 'label') {
                $tmp_result = db_query($link, "SELECT fg_color, bg_color\n\t\t\t\t\t\tFROM ttrss_labels2 WHERE caption = '" . db_escape_string($line["action_param"]) . "' AND\n\t\t\t\t\t\t\towner_uid = " . $_SESSION["uid"]);
                $fg_color = db_fetch_result($tmp_result, 0, "fg_color");
                $bg_color = db_fetch_result($tmp_result, 0, "bg_color");
                $tmp = "<div class='labelColorIndicator' id='LICID-{$id}' \n\t\t\t\t\t\tstyle='color : {$fg_color}; background-color : {$bg_color}'>\n\t\t\t\t\t\t&alpha;";
                $tmp .= "</div>";
                $line["action_param"] = "{$tmp} " . $line["action_param"];
            }
            if ($line["filter_type"] == 5) {
                if (!strtotime($line["reg_exp"])) {
                    $line["reg_exp"] = "<span class=\"filterDateError\">" . $line["reg_exp"] . "</span>";
                }
                $line["reg_exp"] = __("Date") . " " . $filter_params[$line['filter_param']] . " " . $line["reg_exp"];
            }
            if (!$enabled) {
                $line["reg_exp"] = "<span class=\"insensitive\">" . $line["reg_exp"] . " " . __("(Disabled)") . "</span>";
                $line["feed_title"] = "<span class=\"insensitive\">" . $line["feed_title"] . "</span>";
                $line["filter_type_descr"] = "<span class=\"insensitive\">" . $line["filter_type_descr"] . "</span>";
                $line["action_description"] = "<span class=\"insensitive\">" . $line["action_description"] . "</span>";
                $line["action_param"] = "<span class=\"insensitive\">" . $line["action_param"] . "</span>";
            }
            $onclick = "onclick='editFilter({$filter_id})' title='" . __('Click to edit') . "'";
            $inverse_label = "";
            if ($inverse) {
                $inverse_label = " <span class='insensitive'>" . __('(Inverse)') . "</span>";
            }
            print "<td {$onclick}>" . $line["reg_exp"] . "{$inverse_label}</td>";
            print "<td {$onclick}>" . $line["feed_title"] . "</td>";
            print "<td {$onclick}>" . $line["filter_type_descr"] . "</td>";
            print "<td {$onclick}>" . $line["action_param"] . "</td>";
            print "</tr>";
            ++$lnum;
        }
        print "</table>";
    } else {
        print "<p>";
        if (!$filter_search) {
            print_warning(__('No filters defined.'));
        } else {
            print_warning(__('No matching filters found.'));
        }
        print "</p>";
    }
}
예제 #14
0
 function hook_prefs_tab($args)
 {
     if ($args != "prefFeeds") {
         return;
     }
     print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"" . __('Mark similar articles as read') . "\">";
     if (DB_TYPE != "pgsql") {
         print_error("Database type not supported.");
     }
     $result = db_query("select 'similarity'::regproc");
     if (db_num_rows($result) == 0) {
         print_error("pg_trgm extension not found.");
     }
     $similarity = $this->host->get($this, "similarity");
     $min_title_length = $this->host->get($this, "min_title_length");
     $enable_globally = $this->host->get($this, "enable_globally");
     if (!$similarity) {
         $similarity = '0.75';
     }
     if (!$min_title_length) {
         $min_title_length = '32';
     }
     $enable_globally_checked = $enable_globally ? "checked" : "";
     print "<form dojoType=\"dijit.form.Form\">";
     print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">\n\t\t\tevt.preventDefault();\n\t\t\tif (this.validate()) {\n\t\t\t\tconsole.log(dojo.objectToQuery(this.getValues()));\n\t\t\t\tnew Ajax.Request('backend.php', {\n\t\t\t\t\tparameters: dojo.objectToQuery(this.getValues()),\n\t\t\t\t\tonComplete: function(transport) {\n\t\t\t\t\t\tnotify_info(transport.responseText);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\t//this.reset();\n\t\t\t}\n\t\t\t</script>";
     print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pluginhandler\">";
     print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"save\">";
     print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"plugin\" value=\"af_psql_trgm\">";
     print_notice("PostgreSQL trigram extension returns string similarity as a floating point number (0-1). Setting it too low might produce false positives, zero disables checking.");
     print "<br/>";
     print_notice("Enable the plugin for specific feeds in the feed editor.");
     print "<h3>" . __("Global settings") . "</h3>";
     print "<table>";
     print "<tr><td width=\"40%\">" . __("Minimum similarity:") . "</td>";
     print "<td>\n\t\t\t<input dojoType=\"dijit.form.ValidationTextBox\"\n\t\t\tplaceholder=\"0.75\"\n\t\t\trequired=\"1\" name=\"similarity\" value=\"{$similarity}\"></td></tr>";
     print "<tr><td width=\"40%\">" . __("Minimum title length:") . "</td>";
     print "<td>\n\t\t\t<input dojoType=\"dijit.form.ValidationTextBox\"\n\t\t\tplaceholder=\"32\"\n\t\t\trequired=\"1\" name=\"min_title_length\" value=\"{$min_title_length}\"></td></tr>";
     print "<tr><td width=\"40%\">" . __("Enable for all feeds:") . "</td>";
     print "<td>\n\t\t\t<input dojoType=\"dijit.form.CheckBox\"\n\t\t\t{$enable_globally_checked} name=\"enable_globally\"></td></tr>";
     print "</table>";
     print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">" . __("Save") . "</button>";
     print "</form>";
     $enabled_feeds = $this->host->get($this, "enabled_feeds");
     if (!array($enabled_feeds)) {
         $enabled_feeds = array();
     }
     $enabled_feeds = $this->filter_unknown_feeds($enabled_feeds);
     $this->host->set($this, "enabled_feeds", $enabled_feeds);
     if (count($enabled_feeds) > 0) {
         print "<h3>" . __("Currently enabled for (click to edit):") . "</h3>";
         print "<ul class=\"browseFeedList\" style=\"border-width : 1px\">";
         foreach ($enabled_feeds as $f) {
             print "<li>" . "<img src='images/pub_set.png'\n\t\t\t\t\t\tstyle='vertical-align : middle'> <a href='#'\n\t\t\t\t\t\tonclick='editFeed({$f})'>" . getFeedTitle($f) . "</a></li>";
         }
         print "</ul>";
     }
     print "</div>";
 }
예제 #15
0
파일: init.php 프로젝트: Verisor/tt-rss
 function hook_prefs_tab($args)
 {
     if ($args != "prefFeeds") {
         return;
     }
     print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"" . __("Import starred or shared items from Google Reader") . "\">";
     print_notice("Your imported articles will appear in Starred (in file is named starred.json) and Archived feeds.");
     print "<p>" . __("Paste your starred.json or shared.json into the form below.") . "</p>";
     print "<iframe id=\"starred_upload_iframe\"\n\t\t\tname=\"starred_upload_iframe\" onload=\"starredImportComplete(this)\"\n\t\t\tstyle=\"width: 400px; height: 100px; display: none;\"></iframe>";
     print "<form name=\"starred_form\" style='display : block' target=\"starred_upload_iframe\"\n\t\t\tenctype=\"multipart/form-data\" method=\"POST\"\n\t\t\taction=\"backend.php\">\n\t\t\t<input id=\"starred_file\" name=\"starred_file\" type=\"file\">&nbsp;\n\t\t\t<input type=\"hidden\" name=\"op\" value=\"pluginhandler\">\n\t\t\t<input type=\"hidden\" name=\"method\" value=\"import\">\n\t\t\t<input type=\"hidden\" name=\"plugin\" value=\"googlereaderimport\">\n\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"return starredImport();\" type=\"submit\">" . __('Import my Starred items') . "</button>";
     print "</form>";
     print "</div>";
     #pane
 }
예제 #16
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") {
        $uid = sprintf("%d", $_REQUEST["id"]);
        print "<div id=\"infoBoxTitle\">" . __('User details') . "</div>";
        print "<div class='infoBoxContents'>";
        $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 = date(get_pref($link, 'LONG_DATE_FORMAT'), strtotime(db_fetch_result($result, 0, "last_login")));
        $created = date(get_pref($link, 'LONG_DATE_FORMAT'), strtotime(db_fetch_result($result, 0, "created")));
        $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 "</div>";
        return;
    }
    if ($subop == "edit") {
        $id = db_escape_string($_REQUEST["id"]);
        print "<div id=\"infoBoxTitle\">" . __('User Editor') . "</div>";
        print "<div class=\"infoBoxContents\">";
        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 "</div>";
        return;
    }
    if ($subop == "editSave") {
        if (!WEB_DEMO_MODE && $_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}', ";
                print_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"]) {
                        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");
                            print_notice(T_sprintf("Added user <b>%s</b> with password <b>%s</b>", $login, $tmp_user_pwd));
                            initialize_user($link, $new_uid);
                        } else {
                            print_warning(T_sprintf("Could not create user <b>%s</b>", $login));
                        }
                    } else {
                        print_warning(T_sprintf("User <b>%s</b> already exists.", $login));
                    }
                }
            } else {
                if ($subop == "resetPass") {
                    if (!WEB_DEMO_MODE && $_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}'");
                        print_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) {
                            print_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>";
                    }
                }
            }
        }
    }
    set_pref($link, "_PREFS_ACTIVE_TAB", "userConfig");
    $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'>\n\t\t\t<input id=\"user_search\" size=\"20\" type=\"search\"\n\t\t\t\tonfocus=\"javascript:disableHotkeys();\" \n\t\t\t\tonblur=\"javascript:enableHotkeys();\"\n\t\t\t\tonchange=\"javascript:updateUsersList()\" value=\"{$user_search}\">\n\t\t\t<button onclick=\"javascript:updateUsersList()\">" . __('Search') . "</button>\n\t\t\t</div>";
    $sort = db_escape_string($_REQUEST["sort"]);
    if (!$sort || $sort == "undefined") {
        $sort = "login";
    }
    print "<button onclick=\"javascript:addUser()\">" . __('Create user') . "</button>";
    print "\n\t\t\t<button onclick=\"javascript:selectedUserDetails()\">" . __('Details') . "</button>\n\t\t\t<button onclick=\"javascript:editSelectedUser()\">" . __('Edit') . "</button>\n\t\t\t<button onclick=\"javascript:removeSelectedUsers()\">" . __('Remove') . "</button>\n\t\t\t<button onclick=\"javascript:resetSelectedUserPass()\">" . __('Reset password') . "</button>";
    print "</div>";
    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 "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>";
        print "<p><table width=\"100%\" cellspacing=\"0\" \n\t\t\tclass=\"prefUserList\" id=\"prefUserList\">";
        print "<tr><td class=\"selectPrompt\" colspan=\"8\">\n\t\t\t\t" . __('Select:') . " \n\t\t\t\t\t<a href=\"javascript:selectPrefRows('user', true)\">" . __('All') . "</a>,\n\t\t\t\t\t<a href=\"javascript:selectPrefRows('user', false)\">" . __('None') . "</a>\n\t\t\t\t</td</tr>";
        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=\"javascript:updateUsersList('login')\">" . __('Login') . "</a></td>\n\t\t\t\t\t<td width='20%'><a href=\"javascript:updateUsersList('access_level')\">" . __('Access Level') . "</a></td>\n\t\t\t\t\t<td width='20%'><a href=\"javascript:updateUsersList('created')\">" . __('Registered') . "</a></td>\n\t\t\t\t\t<td width='20%'><a href=\"javascript: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["last_login"] = date(get_pref($link, 'SHORT_DATE_FORMAT'),
            #				strtotime($line["last_login"]));
            if (get_pref($link, 'HEADLINES_SMART_DATE')) {
                $line["last_login"] = smart_date_time(strtotime($line["last_login"]));
                $line["created"] = smart_date_time(strtotime($line["created"]));
            } else {
                $line["last_login"] = date(get_pref($link, 'SHORT_DATE_FORMAT'), strtotime($line["last_login"]));
                $line["created"] = date(get_pref($link, 'SHORT_DATE_FORMAT'), strtotime($line["created"]));
            }
            print "<td align='center'><input onclick='toggleSelectPrefRow(this, \"user\");' \n\t\t\t\ttype=\"checkbox\" id=\"UMCHK-{$uid}\"></td>";
            $onclick = "onclick='editUser({$uid})' 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>";
    }
}
 function hook_prefs_tab($args)
 {
     if ($args != "prefPrefs") {
         return;
     }
     if (($_SESSION["access_level"] >= 10 || SINGLE_USER_MODE) && CHECK_FOR_NEW_VERSION) {
         print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"" . __('Update Tiny Tiny RSS') . "\">";
         if ($_SESSION["pref_last_version_check"] + 86400 + rand(-1000, 1000) < time()) {
             $_SESSION["version_data"] = @check_for_update($this->link);
             $_SESSION["pref_last_version_check"] = time();
         }
         if (is_array($_SESSION["version_data"])) {
             $version = $_SESSION["version_data"]["version"];
             print_notice(T_sprintf("New version of Tiny Tiny RSS is available (%s).", "<b>{$version}</b>"));
             print "<p><button dojoType=\"dijit.form.Button\" onclick=\"return updateSelf()\">" . __('Update Tiny Tiny RSS') . "</button></p>";
         } else {
             print_notice(__("Your Tiny Tiny RSS installation is up to date."));
         }
         print "</div>";
         #pane
     }
     function updateSelf()
     {
         print "<form style='display : block' name='self_update_form' id='self_update_form'>";
         print "<div class='error'>" . __("Do not close this dialog until updating is finished. Backup your tt-rss directory before continuing.") . "</div>";
         print "<ul class='selfUpdateList' id='self_update_log'>";
         print "<li>" . __("Ready to update.") . "</li>";
         print "</ul>";
         print "<div class='dlgButtons'>";
         print "<button id=\"self_update_start_btn\" dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('updateSelfDlg').start()\" >" . __("Start update") . "</button>";
         print "<button id=\"self_update_stop_btn\" onclick=\"return dijit.byId('updateSelfDlg').close()\" dojoType=\"dijit.form.Button\">" . __("Close this window") . "</button>";
         print "</div>";
         print "</form>";
     }
     function performUpdate()
     {
         $step = (int) $_REQUEST["step"];
         $params = json_decode($_REQUEST["params"], true);
         $force = (bool) $_REQUEST["force"];
         if (($_SESSION["access_level"] >= 10 || SINGLE_USER_MODE) && CHECK_FOR_NEW_VERSION) {
             print json_encode($this->update_self_step($this->link, $step, $params, $force));
         }
     }
 }
예제 #18
0
<?php 
if ($op == 'register') {
    ?>

<p><?php 
    print_error(__('Could not connect to Twitter. Refresh the page or try again later.'));
    ?>
</p>

<?php 
} else {
    if ($op == 'callback') {
        ?>

	<?php 
        print_notice(__('Congratulations! You have successfully registered with Twitter.'));
        ?>
		</p>

	<form method="GET" action="prefs.php">
		<input type="hidden" name="tab" value="feedConfig">
		<button type="submit"><?php 
        echo __('Return to Tiny Tiny RSS');
        ?>
</button>
	</form>

<?php 
    } else {
        ?>
예제 #19
0
파일: index.php 프로젝트: XelaRellum/tt-rss
			<?php 
        } else {
            print_error("Unfortunately, parent directory is not writable, so we're unable to save config.php automatically.");
        }
        print_notice("You can generate the file again by changing the form above.");
    } else {
        if ($op == "saveconfig") {
            print "<h2>Saving configuration file to parent directory...</h2>";
            if (!file_exists("../config.php")) {
                $fp = fopen("../config.php", "w");
                if ($fp) {
                    $written = fwrite($fp, make_config($DB_TYPE, $DB_HOST, $DB_USER, $DB_NAME, $DB_PASS, $DB_PORT, $SELF_URL_PATH));
                    if ($written > 0) {
                        print_notice("Successfully saved config.php. You can try <a href=\"..\">loading tt-rss now</a>.");
                    } else {
                        print_notice("Unable to write into config.php in tt-rss directory.");
                    }
                    fclose($fp);
                } else {
                    print_error("Unable to open config.php in tt-rss directory for writing.");
                }
            } else {
                print_error("config.php already present in tt-rss directory, refusing to overwrite.");
            }
        }
    }
}
?>

</div>
예제 #20
0
 function index()
 {
     global $access_level_names;
     $prefs_blacklist = array("HIDE_READ_FEEDS", "FEEDS_SORT_BY_UNREAD", "STRIP_UNSAFE_TAGS");
     $profile_blacklist = array("ALLOW_DUPLICATE_POSTS", "PURGE_OLD_DAYS", "PURGE_UNREAD_ARTICLES", "DIGEST_ENABLE", "DIGEST_CATCHUP", "BLACKLISTED_TAGS", "ENABLE_API_ACCESS", "UPDATE_POST_ON_CHECKSUM_CHANGE", "DEFAULT_UPDATE_INTERVAL", "USER_TIMEZONE", "SORT_HEADLINES_BY_FEED_DATE", "SSL_CERT_SERIAL", "DIGEST_PREFERRED_TIME");
     $_SESSION["prefs_op_result"] = "";
     print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">";
     print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"" . __('Personal data / Authentication') . "\">";
     print "<form dojoType=\"dijit.form.Form\" id=\"changeUserdataForm\">";
     print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">\n\t\tevt.preventDefault();\n\t\tif (this.validate()) {\n\t\t\tnotify_progress('Saving data...', true);\n\n\t\t\tnew Ajax.Request('backend.php', {\n\t\t\t\tparameters: dojo.objectToQuery(this.getValues()),\n\t\t\t\tonComplete: function(transport) {\n\t\t\t\t\tnotify_callback2(transport);\n\t\t\t} });\n\n\t\t}\n\t\t</script>";
     print "<table width=\"100%\" class=\"prefPrefsList\">";
     $result = db_query($this->link, "SELECT email,full_name,\n\t\t\taccess_level FROM ttrss_users\n\t\t\tWHERE id = " . $_SESSION["uid"]);
     $email = htmlspecialchars(db_fetch_result($result, 0, "email"));
     $full_name = htmlspecialchars(db_fetch_result($result, 0, "full_name"));
     print "<tr><td width=\"40%\">" . __('Full name') . "</td>";
     print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" name=\"full_name\" required=\"1\"\n\t\t\tvalue=\"{$full_name}\"></td></tr>";
     print "<tr><td width=\"40%\">" . __('E-mail') . "</td>";
     print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" name=\"email\" required=\"1\" value=\"{$email}\"></td></tr>";
     if (!SINGLE_USER_MODE && !(ALLOW_REMOTE_USER_AUTH && AUTO_LOGIN)) {
         $access_level = db_fetch_result($result, 0, "access_level");
         print "<tr><td width=\"40%\">" . __('Access level') . "</td>";
         print "<td>" . $access_level_names[$access_level] . "</td></tr>";
     }
     print "</table>";
     print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">";
     print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"changeemail\">";
     print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">" . __("Save data") . "</button>";
     print "</form>";
     if (!SINGLE_USER_MODE && !(ALLOW_REMOTE_USER_AUTH && AUTO_LOGIN)) {
         $result = db_query($this->link, "SELECT id FROM ttrss_users\n\t\t\t\tWHERE id = " . $_SESSION["uid"] . " AND pwd_hash\n\t\t\t\t= 'SHA1:5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8'");
         if (db_num_rows($result) != 0) {
             print format_warning(__("Your password is at default value, please change it."), "default_pass_warning");
         }
         print "<form dojoType=\"dijit.form.Form\">";
         print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">\n\t\t\tevt.preventDefault();\n\t\t\tif (this.validate()) {\n\t\t\t\tnotify_progress('Changing password...', true);\n\n\t\t\t\tnew Ajax.Request('backend.php', {\n\t\t\t\t\tparameters: dojo.objectToQuery(this.getValues()),\n\t\t\t\t\tonComplete: function(transport) {\n\t\t\t\t\t\tnotify('');\n\t\t\t\t\t\tif (transport.responseText.indexOf('ERROR: ') == 0) {\n\t\t\t\t\t\t\tnotify_error(transport.responseText.replace('ERROR: ', ''));\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnotify_info(transport.responseText);\n\t\t\t\t\t\t\tvar warn = \$('default_pass_warning');\n\t\t\t\t\t\t\tif (warn) Element.hide(warn);\n\t\t\t\t\t\t}\n\t\t\t\t}});\n\t\t\t\tthis.reset();\n\t\t\t}\n\t\t\t</script>";
         print "<table width=\"100%\" class=\"prefPrefsList\">";
         print "<tr><td width=\"40%\">" . __("Old password") . "</td>";
         print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" type=\"password\" required=\"1\" name=\"old_password\"></td></tr>";
         print "<tr><td width=\"40%\">" . __("New password") . "</td>";
         print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" type=\"password\" required=\"1\"\n\t\t\t\tname=\"new_password\"></td></tr>";
         print "<tr><td width=\"40%\">" . __("Confirm password") . "</td>";
         print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" type=\"password\" required=\"1\" name=\"confirm_password\"></td></tr>";
         print "</table>";
         print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">";
         print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"changepassword\">";
         print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">" . __("Change password") . "</button>";
         print "</form>";
     }
     print "</div>";
     #pane
     print "<div dojoType=\"dijit.layout.AccordionPane\" selected=\"true\" title=\"" . __('Preferences') . "\">";
     print "<form dojoType=\"dijit.form.Form\" id=\"changeSettingsForm\">";
     print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">\n\t\tevt.preventDefault();\n\t\tif (this.validate()) {\n\t\t\tconsole.log(dojo.objectToQuery(this.getValues()));\n\n\t\t\tnew Ajax.Request('backend.php', {\n\t\t\t\tparameters: dojo.objectToQuery(this.getValues()),\n\t\t\t\tonComplete: function(transport) {\n\t\t\t\t\tvar msg = transport.responseText;\n\t\t\t\t\tif (msg.match('PREFS_THEME_CHANGED')) {\n\t\t\t\t\t\twindow.location.reload();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnotify_info(msg);\n\t\t\t\t\t}\n\t\t\t} });\n\t\t}\n\t\t</script>";
     print '<div dojoType="dijit.layout.BorderContainer" gutters="false">';
     print '<div dojoType="dijit.layout.ContentPane" region="center" style="overflow-y : auto">';
     if ($_SESSION["profile"]) {
         print_notice("Some preferences are only available in default profile.");
     }
     if ($_SESSION["profile"]) {
         initialize_user_prefs($this->link, $_SESSION["uid"], $_SESSION["profile"]);
         $profile_qpart = "profile = '" . $_SESSION["profile"] . "'";
     } else {
         initialize_user_prefs($this->link, $_SESSION["uid"]);
         $profile_qpart = "profile IS NULL";
     }
     $result = db_query($this->link, "SELECT DISTINCT\n\t\t\tttrss_user_prefs.pref_name,short_desc,help_text,value,type_name,\n\t\t\tsection_name,def_value,section_id\n\t\t\tFROM ttrss_prefs,ttrss_prefs_types,ttrss_prefs_sections,ttrss_user_prefs\n\t\t\tWHERE type_id = ttrss_prefs_types.id AND\n\t\t\t\t{$profile_qpart} AND\n\t\t\t\tsection_id = ttrss_prefs_sections.id AND\n\t\t\t\tttrss_user_prefs.pref_name = ttrss_prefs.pref_name AND\n\t\t\t\tshort_desc != '' AND\n\t\t\t\towner_uid = " . $_SESSION["uid"] . "\n\t\t\tORDER BY section_id,short_desc");
     $lnum = 0;
     $active_section = "";
     while ($line = db_fetch_assoc($result)) {
         if (in_array($line["pref_name"], $prefs_blacklist)) {
             continue;
         }
         if ($_SESSION["profile"] && in_array($line["pref_name"], $profile_blacklist)) {
             continue;
         }
         if ($active_section != $line["section_name"]) {
             if ($active_section != "") {
                 print "</table>";
             }
             print "<table width=\"100%\" class=\"prefPrefsList\">";
             $active_section = $line["section_name"];
             print "<tr><td colspan=\"3\"><h3>" . __($active_section) . "</h3></td></tr>";
             if ($line["section_id"] == 2) {
                 print "<tr><td width=\"40%\">" . __("Select theme") . "</td>";
                 $user_theme = get_pref($this->link, "_THEME_ID");
                 $themes = get_all_themes();
                 print "<td><select name=\"_THEME_ID\" dojoType=\"dijit.form.Select\">";
                 print "<option value='Default'>" . __('Default') . "</option>";
                 print "<option value='----------------' disabled=\"1\">--------</option>";
                 foreach ($themes as $t) {
                     $base = $t['base'];
                     $name = $t['name'];
                     if ($base == $user_theme) {
                         $selected = "selected=\"1\"";
                     } else {
                         $selected = "";
                     }
                     print "<option {$selected} value='{$base}'>{$name}</option>";
                 }
                 print "</select></td></tr>";
             }
             $lnum = 0;
         }
         print "<tr>";
         $type_name = $line["type_name"];
         $pref_name = $line["pref_name"];
         $value = $line["value"];
         $def_value = $line["def_value"];
         $help_text = $line["help_text"];
         print "<td width=\"40%\" class=\"prefName\" id=\"{$pref_name}\">" . __($line["short_desc"]);
         if ($help_text) {
             print "<div class=\"prefHelp\">" . __($help_text) . "</div>";
         }
         print "</td>";
         print "<td class=\"prefValue\">";
         if ($pref_name == "USER_TIMEZONE") {
             $timezones = explode("\n", file_get_contents("lib/timezones.txt"));
             print_select($pref_name, $value, $timezones, 'dojoType="dijit.form.FilteringSelect"');
         } else {
             if ($pref_name == "USER_STYLESHEET") {
                 print "<button dojoType=\"dijit.form.Button\"\n\t\t\t\t\tonclick=\"customizeCSS()\">" . __('Customize') . "</button>";
             } else {
                 if ($pref_name == "DEFAULT_ARTICLE_LIMIT") {
                     $limits = array(15, 30, 45, 60);
                     print_select($pref_name, $value, $limits, 'dojoType="dijit.form.Select"');
                 } else {
                     if ($pref_name == "DEFAULT_UPDATE_INTERVAL") {
                         global $update_intervals_nodefault;
                         print_select_hash($pref_name, $value, $update_intervals_nodefault, 'dojoType="dijit.form.Select"');
                     } else {
                         if ($type_name == "bool") {
                             if ($value == "true") {
                                 $value = __("Yes");
                             } else {
                                 $value = __("No");
                             }
                             if ($pref_name == "PURGE_UNREAD_ARTICLES" && FORCE_ARTICLE_PURGE != 0) {
                                 $disabled = "disabled=\"1\"";
                                 $value = __("Yes");
                             } else {
                                 $disabled = "";
                             }
                             print_radio($pref_name, $value, __("Yes"), array(__("Yes"), __("No")), $disabled);
                         } else {
                             if (array_search($pref_name, array('FRESH_ARTICLE_MAX_AGE', 'DEFAULT_ARTICLE_LIMIT', 'PURGE_OLD_DAYS', 'LONG_DATE_FORMAT', 'SHORT_DATE_FORMAT')) !== false) {
                                 $regexp = $type_name == 'integer' ? 'regexp="^\\d*$"' : '';
                                 if ($pref_name == "PURGE_OLD_DAYS" && FORCE_ARTICLE_PURGE != 0) {
                                     $disabled = "disabled=\"1\"";
                                     $value = FORCE_ARTICLE_PURGE;
                                 } else {
                                     $disabled = "";
                                 }
                                 print "<input dojoType=\"dijit.form.ValidationTextBox\"\n\t\t\t\t\trequired=\"1\" {$regexp} {$disabled}\n\t\t\t\t\tname=\"{$pref_name}\" value=\"{$value}\">";
                             } else {
                                 if ($pref_name == "SSL_CERT_SERIAL") {
                                     print "<input dojoType=\"dijit.form.ValidationTextBox\"\n\t\t\t\t\tid=\"SSL_CERT_SERIAL\" readonly=\"1\"\n\t\t\t\t\tname=\"{$pref_name}\" value=\"{$value}\">";
                                     $cert_serial = htmlspecialchars(get_ssl_certificate_id());
                                     $has_serial = $cert_serial ? "false" : "true";
                                     print " <button dojoType=\"dijit.form.Button\" disabled=\"{$has_serial}\"\n\t\t\t\t\tonclick=\"insertSSLserial('{$cert_serial}')\">" . __('Register') . "</button>";
                                     print " <button dojoType=\"dijit.form.Button\"\n\t\t\t\t\tonclick=\"insertSSLserial('')\">" . __('Clear') . "</button>";
                                 } else {
                                     if ($pref_name == 'DIGEST_PREFERRED_TIME') {
                                         print "<input dojoType=\"dijit.form.ValidationTextBox\"\n\t\t\t\t\tid=\"{$pref_name}\" regexp=\"[012]?\\d:\\d\\d\" placeHolder=\"12:00\"\n\t\t\t\t\tname=\"{$pref_name}\" value=\"{$value}\"><div class=\"insensitive\">" . T_sprintf("Current server time: %s (UTC)", date("H:i")) . "</div>";
                                     } else {
                                         $regexp = $type_name == 'integer' ? 'regexp="^\\d*$"' : '';
                                         print "<input dojoType=\"dijit.form.ValidationTextBox\"\n\t\t\t\t\t{$regexp}\n\t\t\t\t\tname=\"{$pref_name}\" value=\"{$value}\">";
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         print "</td>";
         print "</tr>";
         $lnum++;
     }
     print "</table>";
     print '</div>';
     # inside pane
     print '<div dojoType="dijit.layout.ContentPane" region="bottom">';
     print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">";
     print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"saveconfig\">";
     print "<button dojoType=\"dijit.form.Button\" type=\"submit\">" . __('Save configuration') . "</button> ";
     print "<button dojoType=\"dijit.form.Button\" onclick=\"return editProfiles()\">" . __('Manage profiles') . "</button> ";
     print "<button dojoType=\"dijit.form.Button\" onclick=\"return validatePrefsReset()\">" . __('Reset to defaults') . "</button>";
     print '</div>';
     # inner pane
     print '</div>';
     # border container
     print "</form>";
     print "</div>";
     #pane
     print "</div>";
     #container
 }
 function hook_prefs_tab($args)
 {
     if ($args != "prefPrefs") {
         return;
     }
     if (($_SESSION["access_level"] >= 10 || SINGLE_USER_MODE) && CHECK_FOR_NEW_VERSION) {
         print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"" . __('Update Tiny Tiny RSS') . "\">";
         if ($_SESSION["pref_last_version_check"] + 86400 + rand(-1000, 1000) < time()) {
             $_SESSION["version_data"] = @check_for_update();
             $_SESSION["pref_last_version_check"] = time();
         }
         if (is_array($_SESSION["version_data"])) {
             $version = $_SESSION["version_data"]["version"];
             $version_id = $_SESSION["version_data"]["version_id"];
             print_notice(T_sprintf("New version of Tiny Tiny RSS is available (%s).", "<b>{$version}</b>"));
             $details = "http://tt-rss.org/redmine/versions/{$version_id}";
             print "<p><button onclick=\"window.open('{$details}')\" dojoType=\"dijit.form.Button\">" . __("See the release notes") . "</button>";
             print " <button dojoType=\"dijit.form.Button\" onclick=\"return updateSelf()\">" . __('Update Tiny Tiny RSS') . "</button></p>";
         } else {
             print_notice(__("Your Tiny Tiny RSS installation is up to date."));
         }
         print "</div>";
         #pane
     }
 }
예제 #22
0
$update_versions = array();
foreach ($update_files as $f) {
    $m = array();
    preg_match_all("/schema\\/versions\\/" . DB_TYPE . "\\/(\\d*)\\.sql/", $f, $m, PREG_PATTERN_ORDER);
    if ($m[1][0]) {
        $update_versions[$m[1][0]] = $f;
    }
}
ksort($update_versions, SORT_NUMERIC);
$latest_version = max(array_keys($update_versions));
if ($version == $latest_version) {
    if ($version != SCHEMA_VERSION) {
        print_error(__("Could not update database"));
        print "<p>" . __("Could not find necessary schema file, need version:") . " " . SCHEMA_VERSION . __(", found: ") . $latest_version . "</p>";
    } else {
        print_notice(__("Tiny Tiny RSS database is up to date."));
        print "<form method=\"GET\" action=\"index.php\">\n\t\t\t\t<input type=\"submit\" value=\"" . __("Return to Tiny Tiny RSS") . "\">\n\t\t\t\t</form>";
    }
} else {
    if ($version <= $latest_version && !$op) {
        print_warning(__("Please backup your database before proceeding."));
        print "<p>" . T_sprintf("Your Tiny Tiny RSS database needs update to the latest version (<b>%d</b> to <b>%d</b>).", $version, $latest_version) . "</p>";
        /*		print "<p>Available incremental updates:";
        
        		foreach (array_keys($update_versions) as $v) {
        			if ($v > $version) {
        				print " <a href='$update_versions[$v]'>$v</a>";
        			}
        		} */
        print "</p>";
        print "<form method='POST'>\n\t\t\t<input type='hidden' name='op' value='do'>\n\t\t\t<input type='submit' onclick='return confirmOP()' value='" . __("Perform updates") . "'>\n\t\t\t</form>";
예제 #23
0
 static function resetUserPassword($uid, $show_password)
 {
     $result = db_query("SELECT login,email\n\t\t\t\tFROM ttrss_users WHERE id = '{$uid}'");
     $login = db_fetch_result($result, 0, "login");
     $email = db_fetch_result($result, 0, "email");
     $salt = db_fetch_result($result, 0, "salt");
     $new_salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
     $tmp_user_pwd = make_password(8);
     $pwd_hash = encrypt_password($tmp_user_pwd, $new_salt, true);
     db_query("UPDATE ttrss_users SET pwd_hash = '{$pwd_hash}', salt = '{$new_salt}', otp_enabled = false\n\t\t\t\tWHERE id = '{$uid}'");
     if ($show_password) {
         print T_sprintf("Changed password of user <b>%s</b> to <b>%s</b>", $login, $tmp_user_pwd);
     } else {
         print_notice(T_sprintf("Sending new password of user <b>%s</b> to <b>%s</b>", $login, $email));
     }
     require_once 'classes/ttrssmailer.php';
     if ($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 ttrssMailer();
         $rc = $mail->quickMail($email, $login, __("[tt-rss] Password change notification"), $message, false);
         if (!$rc) {
             print_error($mail->ErrorInfo);
         }
     }
 }
 function subscribe2()
 {
     $feed_url = db_escape_string(trim($_REQUEST["feed_url"]));
     $cat_id = db_escape_string($_REQUEST["cat_id"]);
     $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"]));
     $rc = subscribe_to_feed($this->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 ($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=\"method\" 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($this->link, "SELECT id FROM ttrss_feeds WHERE\n\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\taction=\"{$tp_uri}\">\n\t\t\t\t<input type=\"hidden\" name=\"tab\" value=\"feedConfig\">\n\t\t\t\t<input type=\"hidden\" name=\"method\" value=\"editFeed\">\n\t\t\t\t<input type=\"hidden\" name=\"methodparam\" value=\"{$feed_id}\">\n\t\t\t\t<input type=\"submit\" value=\"" . __("Edit subscription options") . "\">\n\t\t\t\t</form>";
     }
     print "<form style='display: inline' method=\"GET\" action=\"{$tt_uri}\">\n\t\t\t<input type=\"submit\" value=\"" . __("Return to Tiny Tiny RSS") . "\">\n\t\t\t</form></p>";
     print "</body></html>";
 }
예제 #25
0
 function index()
 {
     print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">";
     print "<div id=\"pref-feeds-feeds\" dojoType=\"dijit.layout.AccordionPane\" title=\"" . __('Feeds') . "\">";
     $result = db_query($this->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>";
     }
     if (DB_TYPE == "pgsql") {
         $interval_qpart = "NOW() - INTERVAL '3 months'";
     } else {
         $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)";
     }
     $result = db_query($this->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 onclick=\"batchSubscribe()\"\n\t\t\tdojoType=\"dijit.MenuItem\">" . __('Batch subscribe') . "</div>";
     print "</div></div>";
     if (get_pref($this->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=\"toggleHiddenFeedCats()\"\n\t\t\t\tdojoType=\"dijit.MenuItem\">" . __('(Un)hide empty 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&method=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=\"" . __('Import and export') . "\">";
     print "<h3>" . __("OPML") . "</h3>";
     print "<p>" . __("Using OPML you can export and import your feeds, filters, labels and Tiny Tiny RSS settings.") . " ";
     print __("Only main settings profile can be migrated using OPML.") . "</p>";
     print "<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\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=\"method\" value=\"importOpml\">\n\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"return opmlImport();\" type=\"submit\">" . __('Import my OPML') . "</button>";
     print "<hr>";
     print "<p>" . __('Filename:') . " <input type=\"text\" id=\"filename\" value=\"TinyTinyRSS.opml\" />&nbsp;" . __('Include settings') . "<input type=\"checkbox\" id=\"settings\" checked=\"1\"/>";
     print "</p><button dojoType=\"dijit.form.Button\"\n\t\t\tonclick=\"gotoExportOpml(document.opml_form.filename.value, document.opml_form.settings.checked)\" >" . __('Export OPML') . "</button></p></form>";
     print "<hr>";
     print "<p>" . __('Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.') . " ";
     print __("Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds.") . "</p>";
     print "<button dojoType=\"dijit.form.Button\" onclick=\"return displayDlg('pubOPMLUrl')\">" . __('Display published OPML URL') . "</button> ";
     print "<h3>" . __("Article archive") . "</h3>";
     print "<p>" . __("You can export and import your Starred and Archived articles for safekeeping or when migrating between tt-rss instances.") . "</p>";
     print "<button dojoType=\"dijit.form.Button\" onclick=\"return exportData()\">" . __('Export my data') . "</button> ";
     print "<hr>";
     print "<iframe id=\"data_upload_iframe\"\n\t\t\tname=\"data_upload_iframe\" onload=\"dataImportComplete(this)\"\n\t\t\tstyle=\"width: 400px; height: 100px; display: none;\"></iframe>";
     print "<form name=\"import_form\" style='display : block' target=\"data_upload_iframe\"\n\t\t\tenctype=\"multipart/form-data\" method=\"POST\"\n\t\t\taction=\"backend.php\">\n\t\t\t<input id=\"export_file\" name=\"export_file\" type=\"file\">&nbsp;\n\t\t\t<input type=\"hidden\" name=\"op\" value=\"dlg\">\n\t\t\t<input type=\"hidden\" name=\"method\" value=\"dataimport\">\n\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"return importData();\" type=\"submit\">" . __('Import') . "</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 = str_replace("'", "\\'", __('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 / 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($this->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
 }
예제 #26
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 == "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 == "massSubscribe") {
    			$ids = split(",", db_escape_string($_REQUEST["ids"]));
    
    			$subscribed = array();
    
    			foreach ($ids as $id) {
    
    				if ($mode == 1) {
    					$result = db_query($link, "SELECT feed_url,title FROM ttrss_feeds
    						WHERE id = '$id'");
    				} else if ($mode == 2) {
    					$result = db_query($link, "SELECT * FROM ttrss_archived_feeds
    						WHERE id = '$id' AND owner_uid = " . $_SESSION["uid"]);
    					$orig_id = db_escape_string(db_fetch_result($result, 0, "id"));
    					$site_url = db_escape_string(db_fetch_result($result, 0, "site_url"));
    				}
    	
    				$feed_url = db_escape_string(db_fetch_result($result, 0, "feed_url"));
    				$title = db_escape_string(db_fetch_result($result, 0, "title"));
    	
    				$title_orig = db_fetch_result($result, 0, "title");
    	
    				$result = db_query($link, "SELECT id FROM ttrss_feeds WHERE
    						feed_url = '$feed_url' AND owner_uid = " . $_SESSION["uid"]);
    	
    				if (db_num_rows($result) == 0) {			
    					if ($mode == 1) {
    						$result = db_query($link,
    							"INSERT INTO ttrss_feeds (owner_uid,feed_url,title,cat_id) 
    							VALUES ('".$_SESSION["uid"]."', '$feed_url', '$title', NULL)");
    					} else if ($mode == 2) {
    						$result = db_query($link,
    							"INSERT INTO ttrss_feeds (id,owner_uid,feed_url,title,cat_id,site_url) 
    							VALUES ('$orig_id','".$_SESSION["uid"]."', '$feed_url', '$title', NULL, '$site_url')");
    					}
    					array_push($subscribed, $title_orig);
    				}
    			}
    
    			if (count($subscribed) > 0) {
    				$msg = "<b>".__('Subscribed to feeds:')."</b>".
    					"<ul class=\"nomarks\">";
    
    				foreach ($subscribed as $title) {
    					$msg .= "<li>$title</li>";
    				}
    				$msg .= "</ul>";
    
    				print format_notice($msg);
    			}
    
    			return;
    		} */
    /*		if ($subop == "browse") {
    
    			print "<div id=\"infoBoxTitle\">".__('Feed Browser')."</div>";
    			
    			print "<div class=\"infoBoxContents\">";
    
    			$browser_search = db_escape_string($_REQUEST["search"]);
    
    			//print "<p>".__("Showing top 25 registered feeds, sorted by popularity:")."</p>";
    
    			print "<form onsubmit='return false;' display='inline' name='feed_browser' id='feed_browser'>";
    
    			print "
    				<div style='float : right'>
    				<img style='display : none' 
    					id='feed_browser_spinner' src='images/indicator_white.gif'>
    				<input name=\"search\" size=\"20\" type=\"search\"
    					onchange=\"javascript:updateFeedBrowser()\" value=\"$browser_search\">
    				<button onclick=\"javascript:updateFeedBrowser()\">".__('Search')."</button>
    			</div>";
    
    			print " <select name=\"mode\" onchange=\"updateFeedBrowser()\">
    				<option value='1'>" . __('Popular feeds') . "</option>
    				<option value='2'>" . __('Feed archive') . "</option>
    				</select> ";
    
    			print __("limit:");
    
    			print " <select name=\"limit\" onchange='updateFeedBrowser()'>";
    
    			foreach (array(25, 50, 100, 200) as $l) {
    				$issel = ($l == $limit) ? "selected" : "";
    				print "<option $issel>$l</option>";
    			}
    			
    			print "</select> ";
    
    			print "<p>";
    
    			$owner_uid = $_SESSION["uid"];
    
    			print "<ul class='browseFeedList' id='browseFeedList'>";
    			print_feed_browser($link, $search, 25);
    			print "</ul>";
    
    			print "<div align='center'>
    				<button onclick=\"feedBrowserSubscribe()\">".__('Subscribe')."</button>
    				<button onclick=\"closeInfoBox()\" >".__('Cancel')."</button></div>";
    
    			print "</div>";
    			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"));
        $icon_file = ICONS_DIR . "/{$feed_id}.ico";
        if (file_exists($icon_file) && filesize($icon_file) > 0) {
            $feed_icon = "<img width=\"16\" height=\"16\"\n\t\t\t\t\t\tsrc=\"" . ICONS_URL . "/{$feed_id}.ico\">";
        } else {
            $feed_icon = "";
        }
        print "<div id=\"infoBoxTitle\">" . __('Feed Editor') . "</div>";
        print "<div class=\"infoBoxContents\">";
        print "<form id=\"edit_feed_form\" onsubmit=\"return false\">";
        print "<input type=\"hidden\" name=\"id\" value=\"{$feed_id}\">";
        print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">";
        print "<input type=\"hidden\" name=\"subop\" value=\"editSave\">";
        print "<div class=\"dlgSec\">" . __("Feed") . "</div>";
        print "<div class=\"dlgSecCont\">";
        /* Title */
        print "<input style=\"font-size : 16px\" size=\"40\" onkeypress=\"return filterCR(event, feedEditSave)\"\n\t\t\t\t            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 "<br/>";
        print __('URL:') . " ";
        print "<input size=\"40\" onkeypress=\"return filterCR(event, feedEditSave)\"\n\t\t\t\tname=\"feed_url\" value=\"{$feed_url}\">";
        /* Category */
        if (get_pref($link, 'ENABLE_FEED_CATS')) {
            $cat_id = db_fetch_result($result, 0, "cat_id");
            print "<br/>";
            print __('Place in category:') . " ";
            $parent_feed = db_fetch_result($result, 0, "parent_feed");
            if (sprintf("%d", $parent_feed) > 0) {
                $disabled = "disabled";
            } else {
                $disabled = "";
            }
            print_feed_cat_select($link, "cat_id", $cat_id, $disabled);
        }
        /* Link to */
        print "<br/>";
        print __('Link to feed:') . " ";
        $tmp_result = db_query($link, "SELECT COUNT(id) AS count\n\t\t\t\tFROM ttrss_feeds WHERE parent_feed = '{$feed_id}'");
        $linked_count = db_fetch_result($tmp_result, 0, "count");
        $parent_feed = db_fetch_result($result, 0, "parent_feed");
        if ($linked_count > 0) {
            $disabled = "disabled";
        } else {
            $disabled = "";
        }
        print "<select {$disabled} name=\"parent_feed\">";
        print "<option value=\"0\">" . __('Not linked') . "</option>";
        if (get_pref($link, 'ENABLE_FEED_CATS')) {
            if ($cat_id) {
                $cat_qpart = "AND cat_id = '{$cat_id}'";
            } else {
                $cat_qpart = "AND cat_id IS NULL";
            }
        }
        $tmp_result = db_query($link, "SELECT id,title FROM ttrss_feeds\n\t\t\t\tWHERE id != '{$feed_id}' AND owner_uid = " . $_SESSION["uid"] . " AND\n\t\t\t  \t\t(SELECT COUNT(id) FROM ttrss_feeds AS T2 WHERE T2.id = ttrss_feeds.parent_feed) = 0\n\t\t\t\t\t{$cat_qpart} ORDER BY title");
        if (db_num_rows($tmp_result) > 0) {
            print "<option disabled>--------</option>";
        }
        while ($tmp_line = db_fetch_assoc($tmp_result)) {
            if ($tmp_line["id"] == $parent_feed) {
                $is_selected = "selected";
            } else {
                $is_selected = "";
            }
            $linked_title = truncate_string(htmlspecialchars($tmp_line["title"]), 40);
            printf("<option {$is_selected} value='%d'>%s</option>", $tmp_line["id"], $linked_title);
        }
        print "</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);
        /* Update method */
        if (ALLOW_SELECT_UPDATE_METHOD) {
            $update_method = db_fetch_result($result, 0, "update_method");
            print " " . __('using') . " ";
            print_select_hash("update_method", $update_method, $update_methods);
        }
        $purge_interval = db_fetch_result($result, 0, "purge_interval");
        if (FORCE_ARTICLE_PURGE == 0) {
            /* Purge intl */
            print "<br/>";
            print __('Article purging:') . " ";
            print_select_hash("purge_interval", $purge_interval, $purge_intervals);
        } else {
            print "<input type='hidden' name='purge_interval' value='{$purge_interval}'>";
        }
        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:'******'Hide from Popular feeds') . "</label>";
        $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content"));
        if ($rtl_content) {
            $checked = "checked";
        } else {
            $checked = "";
        }
        print "<br/><input 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";
        } else {
            $checked = "";
        }
        print "<br/><input 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 "<br/><input 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";
        } else {
            $checked = "";
        }
        if (ENABLE_SIMPLEPIE && SIMPLEPIE_CACHE_IMAGES) {
            $disabled = "";
            $label_class = "";
        } else {
            $disabled = "disabled";
            $label_class = "class='insensitive'";
        }
        print "<br/><input type=\"checkbox\" id=\"cache_images\" \n\t\t\t\tname=\"cache_images\" {$disabled}\n\t\t\t\t{$checked}>&nbsp;<label {$label_class} for=\"cache_images\">" . __('Cache images locally') . "</label>";
        print "</div>";
        print "</div>";
        print "</form>";
        /* Icon */
        print "<br/>";
        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 onclick=\"return uploadFeedIcon();\"\n\t\t\t\t\ttype=\"submit\">" . __('Replace') . "</button>\n\t\t\t\t<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 onclick='return unsubscribeFeed({$feed_id}, \"{$title}\")'>" . __('Unsubscribe') . "</button>\n\t\t\t\t</div>\n\t\t\t\t<button onclick=\"return feedEditSave()\">" . __('Save') . "</button>\n\t\t\t\t<button onclick=\"return feedEditCancel()\">" . __('Cancel') . "</button>\n\t\t\t\t</div>";
        return;
    }
    if ($subop == "editfeeds") {
        $feed_ids = db_escape_string($_REQUEST["ids"]);
        print "<div id=\"infoBoxTitle\">" . __('Multiple Feed Editor') . "</div>";
        print "<div class=\"infoBoxContents\">";
        print "<form id=\"batch_edit_feed_form\" onsubmit=\"return false\">";
        print "<input type=\"hidden\" name=\"ids\" value=\"{$feed_ids}\">";
        print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">";
        print "<input type=\"hidden\" name=\"subop\" value=\"batchEditSave\">";
        print "<div class=\"dlgSec\">" . __("Feed") . "</div>";
        print "<div class=\"dlgSecCont\">";
        /* Title */
        print "<input disabled style=\"font-size : 16px\" size=\"35\" onkeypress=\"return filterCR(event, feedEditSave)\"\n\t\t\t\t            name=\"title\" value=\"{$title}\">";
        batch_edit_cbox("title");
        /* Feed URL */
        print "<br/>";
        print __('URL:') . " ";
        print "<input disabled size=\"40\" onkeypress=\"return filterCR(event, feedEditSave)\"\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");
            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");
        batch_edit_cbox("update_interval");
        /* Update method */
        if (ALLOW_SELECT_UPDATE_METHOD) {
            print " " . __('using') . " ";
            print_select_hash("update_method", $update_method, $update_methods, "disabled");
            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");
            batch_edit_cbox("purge_interval");
        }
        print "</div>";
        print "<div class=\"dlgSec\">" . __("Authentication") . "</div>";
        print "<div class=\"dlgSecCont\">";
        print __('Login:'******'insensitive' for=\"private\">" . __('Hide from Popular feeds') . "</label>";
        print "&nbsp;";
        batch_edit_cbox("private", "private_l");
        print "<br/><input disabled type=\"checkbox\" id=\"rtl_content\" name=\"rtl_content\"\n\t\t\t\t{$checked}>&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 type=\"checkbox\" id=\"include_in_digest\" \n\t\t\t\tname=\"include_in_digest\" \n\t\t\t\t{$checked}>&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 type=\"checkbox\" id=\"always_display_enclosures\" \n\t\t\t\tname=\"always_display_enclosures\" \n\t\t\t\t{$checked}>&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");
        print "<br/><input disabled type=\"checkbox\" id=\"cache_images\" \n\t\t\t\tname=\"cache_images\" \n\t\t\t\t{$checked}>&nbsp;<label class='insensitive' id=\"cache_images_l\" \n\t\t\t\t\tfor=\"cache_images\">" . __('Cache images locally') . "</label>";
        if (ENABLE_SIMPLEPIE && SIMPLEPIE_CACHE_IMAGES) {
            print "&nbsp;";
            batch_edit_cbox("cache_images", "cache_images_l");
        }
        print "</div>";
        print "</div>";
        print "</form>";
        print "<div class='dlgButtons'>\n\t\t\t\t<input type=\"submit\" class=\"button\" \n\t\t\t\tonclick=\"return feedsEditSave()\" value=\"" . __('Save') . "\">\n\t\t\t\t<input type='submit' class='button'\t\t\t\n\t\t\t\tonclick=\"return feedEditCancel()\" value=\"" . __('Cancel') . "\">\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 = db_escape_string($_POST["update_interval"]);
        $purge_intl = db_escape_string($_POST["purge_interval"]);
        $feed_id = db_escape_string($_POST["id"]);
        /* editSave */
        $feed_ids = db_escape_string($_POST["ids"]);
        /* batchEditSave */
        $cat_id = db_escape_string($_POST["cat_id"]);
        $auth_login = db_escape_string(trim($_POST["auth_login"]));
        $auth_pass = db_escape_string(trim($_POST["auth_pass"]));
        $parent_feed = db_escape_string($_POST["parent_feed"]);
        $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"]));
        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 ($parent_feed && $parent_feed != 0) {
            $parent_qpart = "parent_feed = '{$parent_feed}'";
        } else {
            $parent_qpart = 'parent_feed = NULL';
        }
        if (ENABLE_SIMPLEPIE && 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} {$parent_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\tupdate_method = '{$update_method}'\n\t\t\t\t\tWHERE id = '{$feed_id}' AND owner_uid = " . $_SESSION["uid"]);
            if (get_pref($link, 'ENABLE_FEED_CATS')) {
                # update linked feed categories
                $result = db_query($link, "UPDATE ttrss_feeds SET\n\t\t\t\t\t\t{$category_qpart_nocomma} WHERE parent_feed = '{$feed_id}' AND\n\t\t\t\t\t\towner_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 "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");
            }
        }
    }
    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 title, content, link, ref_id FROM\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)) {
                $article_filters = get_article_filters($filters, $line['title'], $line['content'], $line['link']);
                $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 title, content, link, ref_id FROM\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)) {
                $article_filters = get_article_filters($filters, $line['title'], $line['content'], $line['link']);
                $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') {
            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\"/>\t\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 0:
                print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url));
                break;
        }
        if ($p_from != 'tt-rss') {
            $tt_uri = ($_SERVER['HTTPS'] != "on" ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . preg_replace('/backend\\.php.*$/', 'tt-rss.php', $_SERVER["REQUEST_URI"]);
            $tp_uri = ($_SERVER['HTTPS'] != "on" ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . preg_replace('/backend\\.php.*$/', 'prefs.php', $_SERVER["REQUEST_URI"]);
            $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE\n\t\t\t\t\tfeed_url = '{$feed_url}' AND owner_uid = " . $_SESSION["uid"]);
            $feed_id = db_fetch_result($result, 0, "id");
            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") {
        if (!WEB_DEMO_MODE) {
            $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\t\tWHERE id = '{$id}' AND parent_feed IS NULL\n\t\t\t\t\t  \tAND owner_uid = " . $_SESSION["uid"]);
                # update linked feed categories
                db_query($link, "UPDATE ttrss_feeds SET\n\t\t\t\t\t\tcat_id = {$cat_id_qpart} WHERE parent_feed = '{$id}' AND \n\t\t\t\t\t\towner_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;
        }
        print "<div id=\"infoBoxTitle\">" . __('Category editor') . "</div>";
        print "<div class=\"infoBoxContents\">";
        if ($action == "add") {
            if (!WEB_DEMO_MODE) {
                $feed_cat = db_escape_string(trim($_REQUEST["cat"]));
                $result = db_query($link, "SELECT id FROM ttrss_feed_categories\n\t\t\t\t\t\tWHERE title = '{$feed_cat}' AND owner_uid = " . $_SESSION["uid"]);
                if (db_num_rows($result) == 0) {
                    $result = db_query($link, "INSERT INTO ttrss_feed_categories (owner_uid,title) \n\t\t\t\t\t\t\tVALUES ('" . $_SESSION["uid"] . "', '{$feed_cat}')");
                } else {
                    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>\n\t\t\t\t<input id=\"fadd_cat\" \n\t\t\t\t\tonkeypress=\"return filterCR(event, addFeedCat)\"\n\t\t\t\t\tsize=\"40\">\n\t\t\t\t\t<button onclick=\"javascript:addFeedCat()\">" . __('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 __('Select:') . " \n\t\t\t\t\t<a href=\"javascript:selectPrefRows('fcat', true)\">" . __('All') . "</a>,\n\t\t\t\t\t<a href=\"javascript:selectPrefRows('fcat', false)\">" . __('None') . "</a>";
            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=\"{$class}\" {$this_row_id}>";
                $edit_title = htmlspecialchars($line["title"]);
                print "<td width='5%' align='center'><input \n\t\t\t\t\t\tonclick='toggleSelectPrefRow(this, \"fcat\");' \n\t\t\t\t\t\ttype=\"checkbox\" id=\"FCCHK-{$cat_id}\"></td>";
                print "<td><span id=\"FCATT-{$cat_id}\">" . $edit_title . "</span></td>";
                print "</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 onclick=\"return removeSelectedFeedCats()\">" . __('Remove') . "</button>\n\t\t\t\t</div>";
        print "<button onclick=\"selectTab('feedConfig')\">" . __('Close this window') . "</button></div>";
        print "</div>";
        return;
    }
    if ($quiet) {
        return;
    }
    set_pref($link, "_PREFS_ACTIVE_TAB", "feedConfig");
    $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) {
        print format_notice("<a href=\"javascript:showFeedsWithErrors()\">" . __('Some feeds have update errors (click for details)') . "</a>");
    }
    $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 style='float : right'> \n\t\t\t<input id=\"feed_search\" size=\"20\" type=\"search\"\n\t\t\t\tonfocus=\"javascript:disableHotkeys();\" \n\t\t\t\tonblur=\"javascript:enableHotkeys();\"\n\t\t\t\tonchange=\"javascript:updateFeedList()\" value=\"{$feed_search}\">\n\t\t\t<button onclick=\"javascript:updateFeedList()\">" . __('Search') . "</button>\n\t\t\t</div>";
    print "<button onclick=\"quickAddFeed()\">" . __('Subscribe to feed') . "</button> ";
    print "<button onclick=\"editSelectedFeed()\">" . __('Edit feeds') . "</button> ";
    if (get_pref($link, 'ENABLE_FEED_CATS')) {
        print "<button onclick=\"javascript:editFeedCats()\">" . __('Edit categories') . "</button> ";
    }
    print "<button onclick=\"javascript:removeSelectedFeeds()\">" . __('Unsubscribe') . "</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>";
    }
    $feeds_sort = db_escape_string($_REQUEST["sort"]);
    if (!$feeds_sort || $feeds_sort == "undefined") {
        $feeds_sort = $_SESSION["pref_sort_feeds"];
        if (!$feeds_sort) {
            $feeds_sort = "title";
        }
    }
    $_SESSION["pref_sort_feeds"] = $feeds_sort;
    if ($feed_search) {
        $feed_search = split(" ", $feed_search);
        $tokens = array();
        foreach ($feed_search as $token) {
            $token = trim($token);
            array_push($tokens, "(UPPER(F1.title) LIKE UPPER('%{$token}%') OR\n\t\t\t\t\tUPPER(C1.title) LIKE UPPER('%{$token}%') OR\n\t\t\t\t\tUPPER(F1.feed_url) LIKE UPPER('%{$token}%'))");
        }
        $search_qpart = "(" . join($tokens, " AND ") . ") AND ";
    } else {
        $search_qpart = "";
    }
    $show_last_article_info = false;
    $show_last_article_checked = "";
    $show_last_article_qpart = "";
    if ($_REQUEST["slat"] == "true") {
        $show_last_article_info = true;
        $show_last_article_checked = "checked";
        $show_last_article_qpart = ", (SELECT " . SUBSTRING_FOR_DATE . "(MAX(updated),1,16) FROM ttrss_user_entries,\n\t\t\t\tttrss_entries WHERE ref_id = ttrss_entries.id\n\t\t\t\tAND feed_id = F1.id) AS last_article";
    } else {
        if ($feeds_sort == "last_article") {
            $feeds_sort = "title";
        }
    }
    if (get_pref($link, 'ENABLE_FEED_CATS')) {
        $order_by_qpart = "category,{$feeds_sort},title";
    } else {
        $order_by_qpart = "{$feeds_sort},title";
    }
    $result = db_query($link, "SELECT \n\t\t\t\tF1.id,\n\t\t\t\tF1.title,\n\t\t\t\tF1.feed_url,\n\t\t\t\t" . SUBSTRING_FOR_DATE . "(F1.last_updated,1,16) AS last_updated,\n\t\t\t\tF1.parent_feed,\n\t\t\t\tF1.update_interval,\n\t\t\t\tF1.last_error,\n\t\t\t\tF1.purge_interval,\n\t\t\t\tF1.cat_id,\n\t\t\t\tF2.title AS parent_title,\n\t\t\t\tC1.title AS category,\n\t\t\t\tF1.include_in_digest\n\t\t\t\t{$show_last_article_qpart}\n\t\t\tFROM \n\t\t\t\tttrss_feeds AS F1 \n\t\t\t\tLEFT JOIN ttrss_feeds AS F2\n\t\t\t\t\tON (F1.parent_feed = F2.id)\n\t\t\t\tLEFT JOIN ttrss_feed_categories AS C1\n\t\t\t\t\tON (F1.cat_id = C1.id)\n\t\t\tWHERE \n\t\t\t\t{$search_qpart} F1.owner_uid = '" . $_SESSION["uid"] . "' \t\t\t\n\t\t\tORDER by {$order_by_qpart}");
    if (db_num_rows($result) != 0) {
        //			print "<div id=\"infoBoxShadow\"><div id=\"infoBox\">PLACEHOLDER</div></div>";
        print "<p><table width=\"100%\" cellspacing=\"0\" \n\t\t\t\tclass=\"prefFeedList\" id=\"prefFeedList\">";
        print "<tr><td class=\"selectPrompt\" colspan=\"8\">" . "<div style='float : right'>" . "<input id='show_last_article_times' type='checkbox' onchange='feedlistToggleSLAT()'\n\t\t\t\t{$show_last_article_checked}><label \n\t\t\t\t\tfor='show_last_article_times'>" . __('Show last article times') . "</label></div>" . __('Select:') . "\n\t\t\t\t\t<a href=\"javascript:selectPrefRows('feed', true)\">" . __('All') . "</a>,\n\t\t\t\t\t<a href=\"javascript:selectPrefRows('feed', false)\">" . __('None') . "</a>\n\t\t\t\t</td</tr>";
        if (!get_pref($link, 'ENABLE_FEED_CATS')) {
            print "<tr class=\"title\">\n\t\t\t\t\t<td width='5%' align='center'>&nbsp;</td>";
            if (get_pref($link, 'ENABLE_FEED_ICONS')) {
                print "<td width='3%'>&nbsp;</td>";
            }
            print "<td width='60%'><a href=\"javascript:updateFeedList('title')\">" . __('Title') . "</a></td>";
            if ($show_last_article_info) {
                print "<td width='20%' align='right'><a href=\"javascript:updateFeedList('last_article')\">" . __('Last&nbsp;Article') . "</a></td>";
            }
            print "<td width='20%' align='right'><a href=\"javascript:updateFeedList('last_updated')\">" . __('Updated') . "</a></td>";
        }
        $lnum = 0;
        $cur_cat_id = -1;
        while ($line = db_fetch_assoc($result)) {
            $feed_id = $line["id"];
            $cat_id = $line["cat_id"];
            $edit_title = htmlspecialchars($line["title"]);
            $edit_cat = htmlspecialchars($line["category"]);
            $last_error = $line["last_error"];
            if (!$edit_cat) {
                $edit_cat = __("Uncategorized");
            }
            $last_updated = $line["last_updated"];
            if (!$last_updated) {
                $last_updated = "&mdash;";
            } else {
                if (get_pref($link, 'HEADLINES_SMART_DATE')) {
                    $last_updated = smart_date_time(strtotime($last_updated));
                } else {
                    $short_date = get_pref($link, 'SHORT_DATE_FORMAT');
                    $last_updated = date($short_date, strtotime($last_updated));
                }
            }
            $last_article = $line["last_article"];
            if (!$last_article) {
                $last_article = "&mdash;";
            } else {
                if (get_pref($link, 'HEADLINES_SMART_DATE')) {
                    $last_article = smart_date_time(strtotime($last_article));
                } else {
                    $short_date = get_pref($link, 'SHORT_DATE_FORMAT');
                    $last_article = date($short_date, strtotime($last_article));
                }
            }
            if (get_pref($link, 'ENABLE_FEED_CATS') && $cur_cat_id != $cat_id) {
                $lnum = 0;
                print "<tr><td colspan=\"6\" class=\"feedEditCat\">{$edit_cat}</td></tr>";
                print "<tr class=\"title\">\n\t\t\t\t\t\t<td width='5%'>&nbsp;</td>";
                if (get_pref($link, 'ENABLE_FEED_ICONS')) {
                    print "<td width='3%'>&nbsp;</td>";
                }
                print "<td width='60%'><a href=\"javascript:updateFeedList('title')\">" . __('Title') . "</a></td>";
                if ($show_last_article_info) {
                    print "<td width='20%' align='right'>\n\t\t\t\t\t\t\t<a href=\"javascript:updateFeedList('last_article')\">" . __('Last&nbsp;Article') . "</a></td>";
                }
                print "<td width='20%' align='right'>\n\t\t\t\t\t\t<a href=\"javascript:updateFeedList('last_updated')\">" . __('Updated') . "</a></td>";
                $cur_cat_id = $cat_id;
            }
            $class = $lnum % 2 ? "even" : "odd";
            $this_row_id = "id=\"FEEDR-{$feed_id}\"";
            print "<tr class=\"{$class}\" {$this_row_id}>";
            $icon_file = ICONS_DIR . "/{$feed_id}.ico";
            if (file_exists($icon_file) && filesize($icon_file) > 0) {
                $feed_icon = "<img class=\"tinyFeedIcon\"\tsrc=\"" . ICONS_URL . "/{$feed_id}.ico\">";
            } else {
                $feed_icon = "<img class=\"tinyFeedIcon\" src=\"images/blank_icon.gif\">";
            }
            print "<td class='feedSelect'><input onclick='toggleSelectPrefRow(this, \"feed\");' \n\t\t\t\ttype=\"checkbox\" id=\"FRCHK-" . $line["id"] . "\"></td>";
            $onclick = "onclick='editFeed({$feed_id})' title='" . __('Click to edit') . "'";
            if (get_pref($link, 'ENABLE_FEED_ICONS')) {
                print "<td {$onclick} class='feedIcon'>{$feed_icon}</td>";
            }
            if ($last_error) {
                $edit_title = "<span class=\"feed_error\">{$edit_title}</span>";
                $last_updated = "<span class=\"feed_error\">{$last_updated}</span>";
                $last_article = "<span class=\"feed_error\">{$last_article}</span>";
            }
            $parent_title = $line["parent_title"];
            if ($parent_title) {
                $linked_to = sprintf(__("(linked to %s)"), $parent_title);
                $parent_title = "<span class='groupPrompt'>{$linked_to}</span>";
            }
            print "<td {$onclick}>" . "{$edit_title} {$parent_title}" . "</td>";
            if ($show_last_article_info) {
                print "<td align='right' {$onclick}>" . "{$last_article}</td>";
            }
            print "<td {$onclick} align='right'>{$last_updated}</td>";
            print "</tr>";
            ++$lnum;
        }
        print "</table>";
        print "<p>";
    } else {
        print "<p>";
        if (!$feed_search) {
            print_warning(__("You don't have any subscribed feeds."));
        } else {
            print_warning(__('No matching feeds found.'));
        }
        print "</p>";
    }
    print "<h3>" . __('OPML') . "</h3>";
    /*		print "<div style='float : left'>
    		<form	enctype=\"multipart/form-data\" method=\"POST\" action=\"opml.php\">
    		".__('File:')." <input id=\"opml_file\" name=\"opml_file\" type=\"file\">&nbsp;
    			<input type=\"hidden\" name=\"op\" value=\"Import\">
    			<button onclick=\"return validateOpmlImport();\"
    				type=\"submit\">".__('Import')."</button>
    				</form></div>";
    
    		print "&nbsp;"; */
    print "<iframe name=\"upload_iframe\"\n\t\t\tstyle=\"width: 400px; height: 100px; display: none;\"></iframe>";
    print "<div style='float : left'>";
    print "<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 onclick=\"return opmlImport();\"\n\t\t\t\ttype=\"submit\">" . __('Import') . "</button>\n\t\t\t</form>";
    print "</div>&nbsp;";
    print "<button onclick=\"gotoExportOpml()\">" . __('Export OPML') . "</button>";
    print "<h3>" . __("Firefox Integration") . "</h3>";
    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 "<h3>" . __("Published articles") . "</h3>";
    if (!get_pref($link, "_PREFS_PUBLISH_KEY")) {
        set_pref($link, "_PREFS_PUBLISH_KEY", generate_publish_key());
    }
    if (!get_pref($link, "_PREFS_OPML_PUBLISH_KEY")) {
        set_pref($link, "_PREFS_OPML_PUBLISH_KEY", generate_publish_key());
    }
    print "<p>" . __('Published articles are exported as a public RSS feed and can be subscribed by anyone who knows the URL specified below.') . "</p>";
    print "<button onclick=\"return displayDlg('pubUrl')\">" . __('Display URL') . "</button> ";
    print "<p>" . __('Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.') . "</p>";
    print "<button onclick=\"return displayDlg('pubOPMLUrl')\">" . __('Display URL') . "</button> ";
}
예제 #27
0
function module_pref_prefs($link)
{
    global $access_level_names;
    $subop = $_REQUEST["subop"];
    $prefs_blacklist = array("HIDE_FEEDLIST", "SYNC_COUNTERS", "ENABLE_LABELS", "ENABLE_SEARCH_TOOLBAR", "HIDE_READ_FEEDS");
    $profile_blacklist = array("ALLOW_DUPLICATE_POSTS", "PURGE_OLD_DAYS", "PURGE_UNREAD_ARTICLES", "DIGEST_ENABLE", "DIGEST_CATCHUP", "BLACKLISTED_TAGS", "ENABLE_FEED_ICONS", "ENABLE_API_ACCESS", "UPDATE_POST_ON_CHECKSUM_CHANGE", "DEFAULT_UPDATE_INTERVAL", "MARK_UNREAD_ON_UPDATE");
    if (FORCE_ARTICLE_PURGE != 0) {
        array_push($prefs_blacklist, "PURGE_OLD_DAYS");
        array_push($prefs_blacklist, "PURGE_UNREAD_ARTICLES");
    }
    if ($subop == "change-password") {
        $old_pw = $_POST["OLD_PASSWORD"];
        $new_pw = $_POST["NEW_PASSWORD"];
        $con_pw = $_POST["CONFIRM_PASSWORD"];
        if ($old_pw == "") {
            print "ERROR: " . __("Old password cannot be blank.");
            return;
        }
        if ($new_pw == "") {
            print "ERROR: " . __("New password cannot be blank.");
            return;
        }
        if ($new_pw != $con_pw) {
            print "ERROR: " . __("Entered passwords do not match.");
            return;
        }
        $old_pw_hash1 = encrypt_password($_POST["OLD_PASSWORD"]);
        $old_pw_hash2 = encrypt_password($_POST["OLD_PASSWORD"], $_SESSION["name"]);
        $new_pw_hash = encrypt_password($_POST["NEW_PASSWORD"], $_SESSION["name"]);
        $active_uid = $_SESSION["uid"];
        if ($old_pw && $new_pw) {
            $login = db_escape_string($_SERVER['PHP_AUTH_USER']);
            $result = db_query($link, "SELECT id FROM ttrss_users WHERE \n\t\t\t\t\tid = '{$active_uid}' AND (pwd_hash = '{$old_pw_hash1}' OR \n\t\t\t\t\t\tpwd_hash = '{$old_pw_hash2}')");
            if (db_num_rows($result) == 1) {
                db_query($link, "UPDATE ttrss_users SET pwd_hash = '{$new_pw_hash}' \n\t\t\t\t\t\tWHERE id = '{$active_uid}'");
                $_SESSION["pwd_hash"] = $new_pw_hash;
                print __("Password has been changed.");
            } else {
                print "ERROR: " . __('Old password is incorrect.');
            }
        }
        return;
    } else {
        if ($subop == "save-config") {
            #			$_SESSION["prefs_op_result"] = "save-config";
            $_SESSION["prefs_cache"] = false;
            //			print_r($_POST);
            $orig_theme = get_pref($link, "_THEME_ID");
            foreach (array_keys($_POST) as $pref_name) {
                $pref_name = db_escape_string($pref_name);
                $value = db_escape_string($_POST[$pref_name]);
                set_pref($link, $pref_name, $value);
            }
            if ($orig_theme != get_pref($link, "_THEME_ID")) {
                print "PREFS_THEME_CHANGED";
            } else {
                print __("The configuration was saved.");
            }
            return;
        } else {
            if ($subop == "getHelp") {
                $pref_name = db_escape_string($_REQUEST["pn"]);
                $result = db_query($link, "SELECT help_text FROM ttrss_prefs\n\t\t\t\tWHERE pref_name = '{$pref_name}'");
                if (db_num_rows($result) > 0) {
                    $help_text = db_fetch_result($result, 0, "help_text");
                    print $help_text;
                } else {
                    printf(__("Unknown option: %s"), $pref_name);
                }
            } else {
                if ($subop == "change-email") {
                    $email = db_escape_string($_POST["email"]);
                    $active_uid = $_SESSION["uid"];
                    db_query($link, "UPDATE ttrss_users SET email = '{$email}' \n\t\t\t\tWHERE id = '{$active_uid}'");
                    print __("E-mail has been changed.");
                    return;
                } else {
                    if ($subop == "reset-config") {
                        $_SESSION["prefs_op_result"] = "reset-to-defaults";
                        if ($_SESSION["profile"]) {
                            $profile_qpart = "profile = '" . $_SESSION["profile"] . "'";
                        } else {
                            $profile_qpart = "profile IS NULL";
                        }
                        db_query($link, "DELETE FROM ttrss_user_prefs \n\t\t\t\tWHERE {$profile_qpart} AND owner_uid = " . $_SESSION["uid"]);
                        initialize_user_prefs($link, $_SESSION["uid"], $_SESSION["profile"]);
                        print "PREFS_THEME_CHANGED";
                        //			print __("The configuration was reset to defaults.");
                        return;
                    } else {
                        set_pref($link, "_PREFS_ACTIVE_TAB", "genConfig");
                        if ($_SESSION["profile"]) {
                            print_notice("Some preferences are only available in default profile.");
                        }
                        if (!SINGLE_USER_MODE) {
                            $result = db_query($link, "SELECT id FROM ttrss_users\n\t\t\t\t\tWHERE id = " . $_SESSION["uid"] . " AND pwd_hash \n\t\t\t\t\t= 'SHA1:5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8'");
                            if (db_num_rows($result) != 0) {
                                print format_warning(__("Your password is at default value, \n\t\t\t\t\t\tplease change it."), "default_pass_warning");
                            }
                            /*				if ($_SESSION["pwd_change_result"] == "failed") {
                            					print format_warning("Could not change the password.");
                            				}
                            
                            				if ($_SESSION["pwd_change_result"] == "ok") {
                            					print format_notice("Password was changed.");
                            				}
                            
                            				$_SESSION["pwd_change_result"] = ""; */
                            /*				if ($_SESSION["prefs_op_result"] == "reset-to-defaults") {
                            					print format_notice(__("The configuration was reset to defaults."));
                            } */
                            #				if ($_SESSION["prefs_op_result"] == "save-config") {
                            #					print format_notice(__("The configuration was saved."));
                            #				}
                            $_SESSION["prefs_op_result"] = "";
                            print "<form onsubmit='return false' id='change_email_form'>";
                            print "<table width=\"100%\" class=\"prefPrefsList\">";
                            print "<tr><td colspan='3'><h3>" . __("Personal data") . "</h3></tr></td>";
                            $result = db_query($link, "SELECT email,access_level FROM ttrss_users\n\t\t\t\t\tWHERE id = " . $_SESSION["uid"]);
                            $email = db_fetch_result($result, 0, "email");
                            print "<tr><td width=\"40%\">" . __('E-mail') . "</td>";
                            print "<td class=\"prefValue\"><input class=\"editbox\" name=\"email\" \n\t\t\t\t\tonfocus=\"javascript:disableHotkeys();\" \n\t\t\t\t\tonblur=\"javascript:enableHotkeys();\"\n\t\t\t\t\tonkeypress=\"return filterCR(event, changeUserEmail)\"\n\t\t\t\t\tvalue=\"{$email}\"></td></tr>";
                            if (!SINGLE_USER_MODE) {
                                $access_level = db_fetch_result($result, 0, "access_level");
                                print "<tr><td width=\"40%\">" . __('Access level') . "</td>";
                                print "<td>" . $access_level_names[$access_level] . "</td></tr>";
                            }
                            print "</table>";
                            print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">";
                            print "<input type=\"hidden\" name=\"subop\" value=\"change-email\">";
                            print "</form>";
                            print "<p><button onclick=\"return changeUserEmail()\">" . __("Change e-mail") . "</button>";
                            print "<form onsubmit=\"return false\" \n\t\t\t\t\tname=\"change_pass_form\" id=\"change_pass_form\">";
                            print "<table width=\"100%\" class=\"prefPrefsList\">";
                            print "<tr><td colspan='3'><h3>" . __("Authentication") . "</h3></tr></td>";
                            print "<tr><td width=\"40%\">" . __("Old password") . "</td>";
                            print "<td class=\"prefValue\"><input class=\"editbox\" type=\"password\"\n\t\t\t\t\tonfocus=\"javascript:disableHotkeys();\" \n\t\t\t\t\tonblur=\"javascript:enableHotkeys();\"\n\t\t\t\t\tonkeypress=\"return filterCR(event, changeUserPassword)\"\n\t\t\t\t\tname=\"OLD_PASSWORD\"></td></tr>";
                            print "<tr><td width=\"40%\">" . __("New password") . "</td>";
                            print "<td class=\"prefValue\"><input class=\"editbox\" type=\"password\"\n\t\t\t\t\tonfocus=\"javascript:disableHotkeys();\" \n\t\t\t\t\tonblur=\"javascript:enableHotkeys();\"\n\t\t\t\t\tonkeypress=\"return filterCR(event, changeUserPassword)\"\n\t\t\t\t\tname=\"NEW_PASSWORD\"></td></tr>";
                            print "<tr><td width=\"40%\">" . __("Confirm password") . "</td>";
                            print "<td class=\"prefValue\"><input class=\"editbox\" type=\"password\"\n\t\t\t\t\tonfocus=\"javascript:disableHotkeys();\" \n\t\t\t\t\tonblur=\"javascript:enableHotkeys();\"\n\t\t\t\t\tonkeypress=\"return filterCR(event, changeUserPassword)\"\n\t\t\t\t\tname=\"CONFIRM_PASSWORD\"></td></tr>";
                            print "</table>";
                            print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">";
                            print "<input type=\"hidden\" name=\"subop\" value=\"change-password\">";
                            print "</form>";
                            print "<p><button\tonclick=\"return changeUserPassword()\">" . __("Change password") . "</button>";
                        }
                        if ($_SESSION["profile"]) {
                            initialize_user_prefs($link, $_SESSION["uid"], $_SESSION["profile"]);
                            $profile_qpart = "profile = '" . $_SESSION["profile"] . "'";
                        } else {
                            initialize_user_prefs($link, $_SESSION["uid"]);
                            $profile_qpart = "profile IS NULL";
                        }
                        $result = db_query($link, "SELECT \n\t\t\t\tttrss_user_prefs.pref_name,short_desc,help_text,value,type_name,\n\t\t\t\tsection_name,def_value,section_id\n\t\t\t\tFROM ttrss_prefs,ttrss_prefs_types,ttrss_prefs_sections,ttrss_user_prefs\n\t\t\t\tWHERE type_id = ttrss_prefs_types.id AND \n\t\t\t\t\t{$profile_qpart} AND\n\t\t\t\t\tsection_id = ttrss_prefs_sections.id AND\n\t\t\t\t\tttrss_user_prefs.pref_name = ttrss_prefs.pref_name AND\n\t\t\t\t\tshort_desc != '' AND\n\t\t\t\t\towner_uid = " . $_SESSION["uid"] . "\n\t\t\t\tORDER BY section_id,short_desc");
                        print "<form onsubmit='return false' action=\"backend.php\" \n\t\t\t\tmethod=\"POST\" id=\"pref_prefs_form\">";
                        $lnum = 0;
                        $active_section = "";
                        while ($line = db_fetch_assoc($result)) {
                            if (in_array($line["pref_name"], $prefs_blacklist)) {
                                continue;
                            }
                            if ($_SESSION["profile"] && in_array($line["pref_name"], $profile_blacklist)) {
                                continue;
                            }
                            if ($active_section != $line["section_name"]) {
                                if ($active_section != "") {
                                    print "</table>";
                                }
                                print "<p><table width=\"100%\" class=\"prefPrefsList\">";
                                $active_section = $line["section_name"];
                                print "<tr><td colspan=\"3\"><h3>" . __($active_section) . "</h3></td></tr>";
                                if ($line["section_id"] == 2) {
                                    print "<tr><td width=\"40%\">" . __("Select theme") . "</td>";
                                    $user_theme = get_pref($link, "_THEME_ID");
                                    $themes = get_all_themes();
                                    print "<td><select name=\"_THEME_ID\">";
                                    print "<option value=''>" . __('Default') . "</option>";
                                    print "<option disabled>--------</option>";
                                    foreach ($themes as $t) {
                                        $base = $t['base'];
                                        $name = $t['name'];
                                        if ($base == $user_theme) {
                                            $selected = "selected=\"1\"";
                                        } else {
                                            $selected = "";
                                        }
                                        print "<option {$selected} value='{$base}'>{$name}</option>";
                                    }
                                    print "</select></td></tr>";
                                }
                                //					print "<tr class=\"title\">
                                //						<td width=\"25%\">Option</td><td>Value</td></tr>";
                                $lnum = 0;
                            }
                            //				$class = ($lnum % 2) ? "even" : "odd";
                            print "<tr>";
                            $type_name = $line["type_name"];
                            $pref_name = $line["pref_name"];
                            $value = $line["value"];
                            $def_value = $line["def_value"];
                            $help_text = $line["help_text"];
                            print "<td width=\"40%\" class=\"prefName\" id=\"{$pref_name}\">" . __($line["short_desc"]);
                            if ($help_text) {
                                print "<div class=\"prefHelp\">" . __($help_text) . "</div>";
                            }
                            print "</td>";
                            print "<td class=\"prefValue\">";
                            if ($pref_name == "DEFAULT_UPDATE_INTERVAL") {
                                global $update_intervals_nodefault;
                                print_select_hash($pref_name, $value, $update_intervals_nodefault);
                            } else {
                                if ($type_name == "bool") {
                                    //					print_select($pref_name, $value, array("true", "false"));
                                    if ($value == "true") {
                                        $value = __("Yes");
                                    } else {
                                        $value = __("No");
                                    }
                                    print_radio($pref_name, $value, __("Yes"), array(__("Yes"), __("No")));
                                } else {
                                    print "<input class=\"editbox\"\n\t\t\t\t\t\tonfocus=\"javascript:disableHotkeys();\" \n\t\t\t\t\t\tonblur=\"javascript:enableHotkeys();\"  \n\t\t\t\t\t\tname=\"{$pref_name}\" value=\"{$value}\">";
                                }
                            }
                            print "</td>";
                            print "</tr>";
                            $lnum++;
                        }
                        print "</table>";
                        print "<input type=\"hidden\" name=\"op\" value=\"pref-prefs\">";
                        print "<p><button onclick=\"return validatePrefsSave()\">" . __('Save configuration') . "</button> ";
                        print "<button onclick=\"return editProfiles()\">" . __('Manage profiles') . "</button> ";
                        print "<button onclick=\"return validatePrefsReset()\">" . __('Reset to defaults') . "</button></p>";
                        print "</form>";
                    }
                }
            }
        }
    }
}
 function index()
 {
     global $access_level_names;
     $prefs_blacklist = array("HIDE_READ_FEEDS", "FEEDS_SORT_BY_UNREAD", "STRIP_UNSAFE_TAGS");
     $profile_blacklist = array("ALLOW_DUPLICATE_POSTS", "PURGE_OLD_DAYS", "PURGE_UNREAD_ARTICLES", "DIGEST_ENABLE", "DIGEST_CATCHUP", "BLACKLISTED_TAGS", "ENABLE_API_ACCESS", "UPDATE_POST_ON_CHECKSUM_CHANGE", "DEFAULT_UPDATE_INTERVAL", "USER_TIMEZONE", "SORT_HEADLINES_BY_FEED_DATE", "SSL_CERT_SERIAL", "DIGEST_PREFERRED_TIME");
     $_SESSION["prefs_op_result"] = "";
     print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">";
     print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"" . __('Personal data / Authentication') . "\">";
     print "<form dojoType=\"dijit.form.Form\" id=\"changeUserdataForm\">";
     print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">\n\t\tevt.preventDefault();\n\t\tif (this.validate()) {\n\t\t\tnotify_progress('Saving data...', true);\n\n\t\t\tnew Ajax.Request('backend.php', {\n\t\t\t\tparameters: dojo.objectToQuery(this.getValues()),\n\t\t\t\tonComplete: function(transport) {\n\t\t\t\t\tnotify_callback2(transport);\n\t\t\t} });\n\n\t\t}\n\t\t</script>";
     print "<table width=\"100%\" class=\"prefPrefsList\">";
     print "<h2>" . __("Personal data") . "</h2>";
     $result = db_query($this->link, "SELECT email,full_name,otp_enabled,\n\t\t\taccess_level FROM ttrss_users\n\t\t\tWHERE id = " . $_SESSION["uid"]);
     $email = htmlspecialchars(db_fetch_result($result, 0, "email"));
     $full_name = htmlspecialchars(db_fetch_result($result, 0, "full_name"));
     $otp_enabled = sql_bool_to_bool(db_fetch_result($result, 0, "otp_enabled"));
     print "<tr><td width=\"40%\">" . __('Full name') . "</td>";
     print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" name=\"full_name\" required=\"1\"\n\t\t\tvalue=\"{$full_name}\"></td></tr>";
     print "<tr><td width=\"40%\">" . __('E-mail') . "</td>";
     print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" name=\"email\" required=\"1\" value=\"{$email}\"></td></tr>";
     if (!SINGLE_USER_MODE && !$_SESSION["hide_hello"]) {
         $access_level = db_fetch_result($result, 0, "access_level");
         print "<tr><td width=\"40%\">" . __('Access level') . "</td>";
         print "<td>" . $access_level_names[$access_level] . "</td></tr>";
     }
     print "</table>";
     print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">";
     print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"changeemail\">";
     print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">" . __("Save data") . "</button>";
     print "</form>";
     if ($_SESSION["auth_module"]) {
         global $pluginhost;
         $authenticator = $pluginhost->get_plugin($_SESSION["auth_module"]);
     } else {
         $authenticator = false;
     }
     if ($authenticator && method_exists($authenticator, "change_password")) {
         print "<h2>" . __("Password") . "</h2>";
         $result = db_query($this->link, "SELECT id FROM ttrss_users\n\t\t\t\tWHERE id = " . $_SESSION["uid"] . " AND pwd_hash\n\t\t\t\t= 'SHA1:5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8'");
         if (db_num_rows($result) != 0) {
             print format_warning(__("Your password is at default value, please change it."), "default_pass_warning");
         }
         print "<form dojoType=\"dijit.form.Form\">";
         print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">\n\t\t\tevt.preventDefault();\n\t\t\tif (this.validate()) {\n\t\t\t\tnotify_progress('Changing password...', true);\n\n\t\t\t\tnew Ajax.Request('backend.php', {\n\t\t\t\t\tparameters: dojo.objectToQuery(this.getValues()),\n\t\t\t\t\tonComplete: function(transport) {\n\t\t\t\t\t\tnotify('');\n\t\t\t\t\t\tif (transport.responseText.indexOf('ERROR: ') == 0) {\n\t\t\t\t\t\t\tnotify_error(transport.responseText.replace('ERROR: ', ''));\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnotify_info(transport.responseText);\n\t\t\t\t\t\t\tvar warn = \$('default_pass_warning');\n\t\t\t\t\t\t\tif (warn) Element.hide(warn);\n\t\t\t\t\t\t}\n\t\t\t\t}});\n\t\t\t\tthis.reset();\n\t\t\t}\n\t\t\t</script>";
         if ($otp_enabled) {
             print_notice("Changing your current password will disable OTP.");
         }
         print "<table width=\"100%\" class=\"prefPrefsList\">";
         print "<tr><td width=\"40%\">" . __("Old password") . "</td>";
         print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" type=\"password\" required=\"1\" name=\"old_password\"></td></tr>";
         print "<tr><td width=\"40%\">" . __("New password") . "</td>";
         print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" type=\"password\" required=\"1\"\n\t\t\t\tname=\"new_password\"></td></tr>";
         print "<tr><td width=\"40%\">" . __("Confirm password") . "</td>";
         print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" type=\"password\" required=\"1\" name=\"confirm_password\"></td></tr>";
         print "</table>";
         print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">";
         print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"changepassword\">";
         print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">" . __("Change password") . "</button>";
         print "</form>";
         if ($_SESSION["auth_module"] == "auth_internal") {
             print "<h2>" . __("One time passwords / Authenticator") . "</h2>";
             if ($otp_enabled) {
                 print_notice("One time passwords are currently enabled. Enter your current password below to disable.");
                 print "<form dojoType=\"dijit.form.Form\">";
                 print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">\n\t\t\t\tevt.preventDefault();\n\t\t\t\tif (this.validate()) {\n\t\t\t\t\tnotify_progress('Disabling OTP', true);\n\n\t\t\t\t\tnew Ajax.Request('backend.php', {\n\t\t\t\t\t\tparameters: dojo.objectToQuery(this.getValues()),\n\t\t\t\t\t\tonComplete: function(transport) {\n\t\t\t\t\t\t\tnotify('');\n\t\t\t\t\t\t\tif (transport.responseText.indexOf('ERROR: ') == 0) {\n\t\t\t\t\t\t\t\tnotify_error(transport.responseText.replace('ERROR: ', ''));\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\twindow.location.reload();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t}});\n\t\t\t\t\tthis.reset();\n\t\t\t\t}\n\t\t\t\t</script>";
                 print "<table width=\"100%\" class=\"prefPrefsList\">";
                 print "<tr><td width=\"40%\">" . __("Enter your password") . "</td>";
                 print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" type=\"password\" required=\"1\"\n\t\t\t\t\tname=\"password\"></td></tr>";
                 print "</table>";
                 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">";
                 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"otpdisable\">";
                 print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">" . __("Disable OTP") . "</button>";
                 print "</form>";
             } else {
                 print "<p>" . __("You will need a compatible Authenticator to use this. Changing your password would automatically disable OTP.") . "</p>";
                 print "<p>" . __("Scan the following code by the Authenticator application:") . "</p>";
                 $csrf_token = $_SESSION["csrf_token"];
                 print "<img src=\"backend.php?op=pref-prefs&method=otpqrcode&csrf_token={$csrf_token}\">";
                 print "<form dojoType=\"dijit.form.Form\" id=\"changeOtpForm\">";
                 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">";
                 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"otpenable\">";
                 print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">\n\t\t\t\t\tevt.preventDefault();\n\t\t\t\t\tif (this.validate()) {\n\t\t\t\t\t\tnotify_progress('Saving data...', true);\n\n\t\t\t\t\t\tnew Ajax.Request('backend.php', {\n\t\t\t\t\t\t\tparameters: dojo.objectToQuery(this.getValues()),\n\t\t\t\t\t\t\tonComplete: function(transport) {\n\t\t\t\t\t\t\t\tnotify('');\n\t\t\t\t\t\t\t\tif (transport.responseText.indexOf('ERROR: ') == 0) {\n\t\t\t\t\t\t\t\t\tnotify_error(transport.responseText.replace('ERROR: ', ''));\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\twindow.location.reload();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} });\n\n\t\t\t\t\t}\n\t\t\t\t\t</script>";
                 print "<table width=\"100%\" class=\"prefPrefsList\">";
                 print "<tr><td width=\"40%\">" . __("Enter your password") . "</td>";
                 print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" type=\"password\" required=\"1\"\n\t\t\t\t\t\tname=\"password\"></td></tr>";
                 print "<tr><td colspan=\"2\">";
                 print "<input dojoType=\"dijit.form.CheckBox\" required=\"1\"\n\t\t\t\t\t\ttype=\"checkbox\" id=\"enable_otp\" name=\"enable_otp\"/> ";
                 print "<label for=\"enable_otp\">" . __("I have scanned the code and would like to enable OTP") . "</label>";
                 print "</td></tr><tr><td colspan=\"2\">";
                 print "</td></tr>";
                 print "</table>";
                 print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">" . __("Enable OTP") . "</button>";
                 print "</form>";
             }
         }
     }
     global $pluginhost;
     $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB_SECTION, "hook_prefs_tab_section", "prefPrefsAuth");
     print "</div>";
     #pane
     print "<div dojoType=\"dijit.layout.AccordionPane\" selected=\"true\" title=\"" . __('Preferences') . "\">";
     print "<form dojoType=\"dijit.form.Form\" id=\"changeSettingsForm\">";
     print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">\n\t\tevt.preventDefault();\n\t\tif (this.validate()) {\n\t\t\tconsole.log(dojo.objectToQuery(this.getValues()));\n\n\t\t\tnew Ajax.Request('backend.php', {\n\t\t\t\tparameters: dojo.objectToQuery(this.getValues()),\n\t\t\t\tonComplete: function(transport) {\n\t\t\t\t\tvar msg = transport.responseText;\n\t\t\t\t\tif (msg.match('PREFS_THEME_CHANGED')) {\n\t\t\t\t\t\twindow.location.reload();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnotify_info(msg);\n\t\t\t\t\t}\n\t\t\t} });\n\t\t}\n\t\t</script>";
     print '<div dojoType="dijit.layout.BorderContainer" gutters="false">';
     print '<div dojoType="dijit.layout.ContentPane" region="center" style="overflow-y : auto">';
     if ($_SESSION["profile"]) {
         print_notice("Some preferences are only available in default profile.");
     }
     if ($_SESSION["profile"]) {
         initialize_user_prefs($this->link, $_SESSION["uid"], $_SESSION["profile"]);
         $profile_qpart = "profile = '" . $_SESSION["profile"] . "'";
     } else {
         initialize_user_prefs($this->link, $_SESSION["uid"]);
         $profile_qpart = "profile IS NULL";
     }
     if ($_SESSION["prefs_show_advanced"]) {
         $access_query = "true";
     } else {
         $access_query = "(access_level = 0 AND section_id != 3)";
     }
     $result = db_query($this->link, "SELECT DISTINCT\n\t\t\tttrss_user_prefs.pref_name,short_desc,help_text,value,type_name,\n\t\t\tttrss_prefs_sections.order_id,\n\t\t\tsection_name,def_value,section_id\n\t\t\tFROM ttrss_prefs,ttrss_prefs_types,ttrss_prefs_sections,ttrss_user_prefs\n\t\t\tWHERE type_id = ttrss_prefs_types.id AND\n\t\t\t\t{$profile_qpart} AND\n\t\t\t\tsection_id = ttrss_prefs_sections.id AND\n\t\t\t\tttrss_user_prefs.pref_name = ttrss_prefs.pref_name AND\n\t\t\t\t{$access_query} AND\n\t\t\t\tshort_desc != '' AND\n\t\t\t\towner_uid = " . $_SESSION["uid"] . "\n\t\t\tORDER BY ttrss_prefs_sections.order_id,short_desc");
     $lnum = 0;
     $active_section = "";
     while ($line = db_fetch_assoc($result)) {
         if (in_array($line["pref_name"], $prefs_blacklist)) {
             continue;
         }
         if ($_SESSION["profile"] && in_array($line["pref_name"], $profile_blacklist)) {
             continue;
         }
         if ($active_section != $line["section_name"]) {
             if ($active_section != "") {
                 print "</table>";
             }
             print "<table width=\"100%\" class=\"prefPrefsList\">";
             $active_section = $line["section_name"];
             print "<tr><td colspan=\"3\"><h3>" . __($active_section) . "</h3></td></tr>";
             $lnum = 0;
         }
         print "<tr>";
         $type_name = $line["type_name"];
         $pref_name = $line["pref_name"];
         $value = $line["value"];
         $def_value = $line["def_value"];
         $help_text = $line["help_text"];
         print "<td width=\"40%\" class=\"prefName\" id=\"{$pref_name}\">" . __($line["short_desc"]);
         if ($help_text) {
             print "<div class=\"prefHelp\">" . __($help_text) . "</div>";
         }
         print "</td>";
         print "<td class=\"prefValue\">";
         if ($pref_name == "USER_TIMEZONE") {
             $timezones = explode("\n", file_get_contents("lib/timezones.txt"));
             print_select($pref_name, $value, $timezones, 'dojoType="dijit.form.FilteringSelect"');
         } else {
             if ($pref_name == "USER_STYLESHEET") {
                 print "<button dojoType=\"dijit.form.Button\"\n\t\t\t\t\tonclick=\"customizeCSS()\">" . __('Customize') . "</button>";
             } else {
                 if ($pref_name == "DEFAULT_ARTICLE_LIMIT") {
                     $limits = array(15, 30, 45, 60);
                     print_select($pref_name, $value, $limits, 'dojoType="dijit.form.Select"');
                 } else {
                     if ($pref_name == "DEFAULT_UPDATE_INTERVAL") {
                         global $update_intervals_nodefault;
                         print_select_hash($pref_name, $value, $update_intervals_nodefault, 'dojoType="dijit.form.Select"');
                     } else {
                         if ($type_name == "bool") {
                             if ($value == "true") {
                                 $value = __("Yes");
                             } else {
                                 $value = __("No");
                             }
                             if ($pref_name == "PURGE_UNREAD_ARTICLES" && FORCE_ARTICLE_PURGE != 0) {
                                 $disabled = "disabled=\"1\"";
                                 $value = __("Yes");
                             } else {
                                 $disabled = "";
                             }
                             print_radio($pref_name, $value, __("Yes"), array(__("Yes"), __("No")), $disabled);
                         } else {
                             if (array_search($pref_name, array('FRESH_ARTICLE_MAX_AGE', 'DEFAULT_ARTICLE_LIMIT', 'PURGE_OLD_DAYS', 'LONG_DATE_FORMAT', 'SHORT_DATE_FORMAT')) !== false) {
                                 $regexp = $type_name == 'integer' ? 'regexp="^\\d*$"' : '';
                                 if ($pref_name == "PURGE_OLD_DAYS" && FORCE_ARTICLE_PURGE != 0) {
                                     $disabled = "disabled=\"1\"";
                                     $value = FORCE_ARTICLE_PURGE;
                                 } else {
                                     $disabled = "";
                                 }
                                 print "<input dojoType=\"dijit.form.ValidationTextBox\"\n\t\t\t\t\trequired=\"1\" {$regexp} {$disabled}\n\t\t\t\t\tname=\"{$pref_name}\" value=\"{$value}\">";
                             } else {
                                 if ($pref_name == "SSL_CERT_SERIAL") {
                                     print "<input dojoType=\"dijit.form.ValidationTextBox\"\n\t\t\t\t\tid=\"SSL_CERT_SERIAL\" readonly=\"1\"\n\t\t\t\t\tname=\"{$pref_name}\" value=\"{$value}\">";
                                     $cert_serial = htmlspecialchars(get_ssl_certificate_id());
                                     $has_serial = $cert_serial ? "false" : "true";
                                     print " <button dojoType=\"dijit.form.Button\" disabled=\"{$has_serial}\"\n\t\t\t\t\tonclick=\"insertSSLserial('{$cert_serial}')\">" . __('Register') . "</button>";
                                     print " <button dojoType=\"dijit.form.Button\"\n\t\t\t\t\tonclick=\"insertSSLserial('')\">" . __('Clear') . "</button>";
                                 } else {
                                     if ($pref_name == 'DIGEST_PREFERRED_TIME') {
                                         print "<input dojoType=\"dijit.form.ValidationTextBox\"\n\t\t\t\t\tid=\"{$pref_name}\" regexp=\"[012]?\\d:\\d\\d\" placeHolder=\"12:00\"\n\t\t\t\t\tname=\"{$pref_name}\" value=\"{$value}\"><div class=\"insensitive\">" . T_sprintf("Current server time: %s (UTC)", date("H:i")) . "</div>";
                                     } else {
                                         $regexp = $type_name == 'integer' ? 'regexp="^\\d*$"' : '';
                                         print "<input dojoType=\"dijit.form.ValidationTextBox\"\n\t\t\t\t\t{$regexp}\n\t\t\t\t\tname=\"{$pref_name}\" value=\"{$value}\">";
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         print "</td>";
         print "</tr>";
         $lnum++;
     }
     print "</table>";
     global $pluginhost;
     $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB_SECTION, "hook_prefs_tab_section", "prefPrefsPrefsInside");
     print '</div>';
     # inside pane
     print '<div dojoType="dijit.layout.ContentPane" region="bottom">';
     print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">";
     print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"saveconfig\">";
     print "<button dojoType=\"dijit.form.Button\" type=\"submit\">" . __('Save configuration') . "</button> ";
     print "<button dojoType=\"dijit.form.Button\" onclick=\"return editProfiles()\">" . __('Manage profiles') . "</button> ";
     print "<button dojoType=\"dijit.form.Button\" onclick=\"return validatePrefsReset()\">" . __('Reset to defaults') . "</button>";
     print "&nbsp;";
     $checked = $_SESSION["prefs_show_advanced"] ? "checked='1'" : "";
     print "<input onclick='toggleAdvancedPrefs()'\n\t\t\t\tid='prefs_show_advanced'\n\t\t\t\tdojoType=\"dijit.form.CheckBox\"\n\t\t\t\t{$checked}\n\t\t\t\ttype=\"checkbox\"></input>\n\t\t\t\t<label for='prefs_show_advanced'>" . __("Show additional preferences") . "</label>";
     global $pluginhost;
     $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB_SECTION, "hook_prefs_tab_section", "prefPrefsPrefsOutside");
     print "</form>";
     print '</div>';
     # inner pane
     print '</div>';
     # border container
     print "</div>";
     #pane
     print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"" . __('Plugins') . "\">";
     print "<h2>" . __("Plugins") . "</h2>";
     print_notice("You will need to reload Tiny Tiny RSS for plugin changes to take effect.");
     print "<form dojoType=\"dijit.form.Form\" id=\"changePluginsForm\">";
     print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">\n\t\tevt.preventDefault();\n\t\tif (this.validate()) {\n\t\t\tnotify_progress('Saving data...', true);\n\n\t\t\tnew Ajax.Request('backend.php', {\n\t\t\t\tparameters: dojo.objectToQuery(this.getValues()),\n\t\t\t\tonComplete: function(transport) {\n\t\t\t\t\tnotify('');\n\t\t\t\t\tif (confirm(__('Selected plugins have been enabled. Reload?'))) {\n\t\t\t\t\t\twindow.location.reload();\n\t\t\t\t\t}\n\t\t\t} });\n\n\t\t}\n\t\t</script>";
     print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">";
     print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"setplugins\">";
     print "<table width='100%' class='prefPluginsList'>";
     print "<tr><td colspan='4'><h3>" . __("System plugins") . "</h3></td></tr>";
     print "<tr class=\"title\">\n\t\t\t\t<td width=\"5%\">&nbsp;</td>\n\t\t\t\t<td width='10%'>" . __('Plugin') . "</td>\n\t\t\t\t<td width=''>" . __('Description') . "</td>\n\t\t\t\t<td width='5%'>" . __('Version') . "</td>\n\t\t\t\t<td width='10%'>" . __('Author') . "</td></tr>";
     $system_enabled = array_map("trim", explode(",", PLUGINS));
     $user_enabled = array_map("trim", explode(",", get_pref($this->link, "_ENABLED_PLUGINS")));
     $tmppluginhost = new PluginHost($this->link);
     $tmppluginhost->load_all($tmppluginhost::KIND_ALL, $_SESSION["uid"]);
     $tmppluginhost->load_data(true);
     foreach ($tmppluginhost->get_plugins() as $name => $plugin) {
         $about = $plugin->about();
         if ($about[3] && strpos($name, "example") === FALSE) {
             if (in_array($name, $system_enabled)) {
                 $checked = "checked='1'";
             } else {
                 $checked = "";
             }
             print "<tr>";
             print "<td align='center'><input disabled='1'\n\t\t\t\t\t\tdojoType=\"dijit.form.CheckBox\" {$checked}\n\t\t\t\t\t\ttype=\"checkbox\"></td>";
             print "<td>{$name}</td>";
             print "<td>" . htmlspecialchars($about[1]) . "</td>";
             print "<td>" . htmlspecialchars(sprintf("%.2f", $about[0])) . "</td>";
             print "<td>" . htmlspecialchars($about[2]) . "</td>";
             if (count($tmppluginhost->get_all($plugin)) > 0) {
                 if (in_array($name, $system_enabled)) {
                     print "<td><a href='#' onclick=\"clearPluginData('{$name}')\"\n\t\t\t\t\t\t\tclass='visibleLink'>" . __("Clear data") . "</a></td>";
                 }
             }
             print "</tr>";
         }
     }
     print "<tr><td colspan='4'><h3>" . __("User plugins") . "</h3></td></tr>";
     print "<tr class=\"title\">\n\t\t\t\t<td width=\"5%\">&nbsp;</td>\n\t\t\t\t<td width='10%'>" . __('Plugin') . "</td>\n\t\t\t\t<td width=''>" . __('Description') . "</td>\n\t\t\t\t<td width='5%'>" . __('Version') . "</td>\n\t\t\t\t<td width='10%'>" . __('Author') . "</td></tr>";
     foreach ($tmppluginhost->get_plugins() as $name => $plugin) {
         $about = $plugin->about();
         if (!$about[3] && strpos($name, "example") === FALSE) {
             if (in_array($name, $system_enabled)) {
                 $checked = "checked='1'";
                 $disabled = "disabled='1'";
                 $rowclass = '';
             } else {
                 if (in_array($name, $user_enabled)) {
                     $checked = "checked='1'";
                     $disabled = "";
                     $rowclass = "Selected";
                 } else {
                     $checked = "";
                     $disabled = "";
                     $rowclass = '';
                 }
             }
             print "<tr class='{$rowclass}'>";
             print "<td align='center'><input id='FPCHK-{$name}' name='plugins[]' value='{$name}' onclick='toggleSelectRow2(this);'\n\t\t\t\t\tdojoType=\"dijit.form.CheckBox\" {$checked} {$disabled}\n\t\t\t\t\ttype=\"checkbox\"></td>";
             print "<td><label for='FPCHK-{$name}'>{$name}</label></td>";
             print "<td><label for='FPCHK-{$name}'>" . htmlspecialchars($about[1]) . "</label></td>";
             print "<td>" . htmlspecialchars(sprintf("%.2f", $about[0])) . "</td>";
             print "<td>" . htmlspecialchars($about[2]) . "</td>";
             if (count($tmppluginhost->get_all($plugin)) > 0) {
                 if (in_array($name, $system_enabled) || in_array($name, $user_enabled)) {
                     print "<td><a href='#' onclick=\"clearPluginData('{$name}')\" class='visibleLink'>" . __("Clear data") . "</a></td>";
                 }
             }
             print "</tr>";
         }
     }
     print "</table>";
     print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">" . __("Enable selected plugins") . "</button></p>";
     print "</form>";
     print "</div>";
     #pane
     global $pluginhost;
     $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB, "hook_prefs_tab", "prefPrefs");
     print "</div>";
     #container
 }
예제 #29
0
파일: feeds.php 프로젝트: AHinMaine/ttrss
 function index()
 {
     print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">";
     print "<div id=\"pref-feeds-feeds\" dojoType=\"dijit.layout.AccordionPane\" title=\"" . __('Feeds') . "\">";
     $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) {
         $error_button = "<button dojoType=\"dijit.form.Button\"\n\t\t\t  \t\tonclick=\"showFeedsWithErrors()\" id=\"errorButton\">" . __("Feeds with errors") . "</button>";
     }
     $inactive_button = "<button dojoType=\"dijit.form.Button\"\n\t\t\t\tid=\"pref_feeds_inactive_btn\"\n\t\t\t\tstyle=\"display : none\"\n\t\t\t\tonclick=\"showInactiveFeeds()\">" . __("Inactive feeds") . "</button>";
     $feed_search = $this->dbh->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 onclick=\"batchSubscribe()\"\n\t\t\tdojoType=\"dijit.MenuItem\">" . __('Batch subscribe') . "</div>";
     print "<div dojoType=\"dijit.MenuItem\" onclick=\"removeSelectedFeeds()\">" . __('Unsubscribe') . "</div> ";
     print "</div></div>";
     if (get_pref('ENABLE_FEED_CATS')) {
         print "<div dojoType=\"dijit.form.DropDownButton\">" . "<span>" . __('Categories') . "</span>";
         print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
         print "<div onclick=\"createCategory()\"\n\t\t\t\tdojoType=\"dijit.MenuItem\">" . __('Add category') . "</div>";
         print "<div onclick=\"resetCatOrder()\"\n\t\t\t\tdojoType=\"dijit.MenuItem\">" . __('Reset sort order') . "</div>";
         print "<div onclick=\"removeSelectedCategories()\"\n\t\t\t\tdojoType=\"dijit.MenuItem\">" . __('Remove selected') . "</div>";
         print "</div></div>";
     }
     print $error_button;
     print $inactive_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&method=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\n\t\t\tcheckInactiveFeeds();\n\t\t</script>\n\t\t</div>";
     #		print "<div dojoType=\"dijit.Tooltip\" connectId=\"feedTree\" position=\"below\">
     #			".__('<b>Hint:</b> you can drag feeds and categories around.')."
     #			</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, filters, labels and Tiny Tiny RSS settings.") . __("Only main settings profile can be migrated using OPML.") . "</p>";
     print "<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\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=\"method\" value=\"importOpml\">\n\t\t\t<button dojoType=\"dijit.form.Button\" onclick=\"return opmlImport();\" type=\"submit\">" . __('Import my OPML') . "</button>";
     print "<hr>";
     $opml_export_filename = "TinyTinyRSS_" . date("Y-m-d") . ".opml";
     print "<p>" . __('Filename:') . " <input type=\"text\" id=\"filename\" value=\"{$opml_export_filename}\" />&nbsp;" . __('Include settings') . "<input type=\"checkbox\" id=\"settings\" checked=\"1\"/>";
     print "</p><button dojoType=\"dijit.form.Button\"\n\t\t\tonclick=\"gotoExportOpml(document.opml_form.filename.value, document.opml_form.settings.checked)\" >" . __('Export OPML') . "</button></p></form>";
     print "<hr>";
     print "<p>" . __('Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.') . "</p>";
     print_warning("Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds.");
     print "<button dojoType=\"dijit.form.Button\" onclick=\"return displayDlg('" . __("Public OPML URL") . "','pubOPMLUrl')\">" . __('Display published OPML URL') . "</button> ";
     PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "hook_prefs_tab_section", "prefFeedsOPML");
     print "</div>";
     # pane
     if (strpos($_SERVER['HTTP_USER_AGENT'], "Firefox") !== false) {
         print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"" . __('Firefox integration') . "\">";
         print_notice(__('This Tiny Tiny RSS site can be used as a Firefox Feed Reader by clicking the link below.'));
         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=\"" . __('Published & shared articles / Generated feeds') . "\">";
     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 "<p>";
     print "<button dojoType=\"dijit.form.Button\" onclick=\"return displayDlg('" . __("View as RSS") . "','generatedFeed', '{$rss_url}')\">" . __('Display URL') . "</button> ";
     print "<button class=\"warning\" dojoType=\"dijit.form.Button\" onclick=\"return clearFeedAccessKeys()\">" . __('Clear all generated URLs') . "</button> ";
     print "</p>";
     PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "hook_prefs_tab_section", "prefFeedsPublishedGenerated");
     print "</div>";
     #pane
     PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, "hook_prefs_tab", "prefFeeds");
     print "</div>";
     #container
 }
예제 #30
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
}