2 class Pref_Prefs extends Handler_Protected {
4 function csrf_ignore($method) {
5 $csrf_ignored = array("index", "updateself");
7 return array_search($method, $csrf_ignored) !== false;
10 function changepassword() {
12 $old_pw = $_POST["old_password"];
13 $new_pw = $_POST["new_password"];
14 $con_pw = $_POST["confirm_password"];
17 print "ERROR: ".__("Old password cannot be blank.");
22 print "ERROR: ".__("New password cannot be blank.");
26 if ($new_pw != $con_pw) {
27 print "ERROR: ".__("Entered passwords do not match.");
32 $authenticator = $pluginhost->get_plugin($_SESSION["auth_module"]);
34 if (method_exists($authenticator, "change_password")) {
35 print $authenticator->change_password($_SESSION["uid"], $old_pw, $new_pw);
37 print "ERROR: ".__("Function not supported by authentication module.");
41 function saveconfig() {
43 $_SESSION["prefs_cache"] = false;
45 foreach (array_keys($_POST) as $pref_name) {
47 $pref_name = db_escape_string($pref_name);
48 $value = db_escape_string($_POST[$pref_name]);
50 if ($pref_name == 'DIGEST_PREFERRED_TIME') {
51 if (get_pref($this->link, 'DIGEST_PREFERRED_TIME') != $value) {
53 db_query($this->link, "UPDATE ttrss_users SET
54 last_digest_sent = NULL WHERE id = " . $_SESSION['uid']);
59 set_pref($this->link, $pref_name, $value);
63 print __("The configuration was saved.");
68 $pref_name = db_escape_string($_REQUEST["pn"]);
70 $result = db_query($this->link, "SELECT help_text FROM ttrss_prefs
71 WHERE pref_name = '$pref_name'");
73 if (db_num_rows($result) > 0) {
74 $help_text = db_fetch_result($result, 0, "help_text");
77 printf(__("Unknown option: %s"), $pref_name);
81 function changeemail() {
83 $email = db_escape_string($_POST["email"]);
84 $full_name = db_escape_string($_POST["full_name"]);
86 $active_uid = $_SESSION["uid"];
88 db_query($this->link, "UPDATE ttrss_users SET email = '$email',
89 full_name = '$full_name' WHERE id = '$active_uid'");
91 print __("Your personal data has been saved.");
96 function resetconfig() {
98 $_SESSION["prefs_op_result"] = "reset-to-defaults";
100 if ($_SESSION["profile"]) {
101 $profile_qpart = "profile = '" . $_SESSION["profile"] . "'";
103 $profile_qpart = "profile IS NULL";
106 db_query($this->link, "DELETE FROM ttrss_user_prefs
107 WHERE $profile_qpart AND owner_uid = ".$_SESSION["uid"]);
109 initialize_user_prefs($this->link, $_SESSION["uid"], $_SESSION["profile"]);
111 print "PREFS_THEME_CHANGED";
116 global $access_level_names;
118 $prefs_blacklist = array("HIDE_READ_FEEDS", "FEEDS_SORT_BY_UNREAD",
119 "STRIP_UNSAFE_TAGS");
121 $profile_blacklist = array("ALLOW_DUPLICATE_POSTS", "PURGE_OLD_DAYS",
122 "PURGE_UNREAD_ARTICLES", "DIGEST_ENABLE", "DIGEST_CATCHUP",
123 "BLACKLISTED_TAGS", "ENABLE_API_ACCESS", "UPDATE_POST_ON_CHECKSUM_CHANGE",
124 "DEFAULT_UPDATE_INTERVAL", "USER_TIMEZONE", "SORT_HEADLINES_BY_FEED_DATE",
125 "SSL_CERT_SERIAL", "DIGEST_PREFERRED_TIME");
128 $_SESSION["prefs_op_result"] = "";
130 print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">";
131 print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Personal data / Authentication')."\">";
133 print "<form dojoType=\"dijit.form.Form\" id=\"changeUserdataForm\">";
135 print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">
136 evt.preventDefault();
137 if (this.validate()) {
138 notify_progress('Saving data...', true);
140 new Ajax.Request('backend.php', {
141 parameters: dojo.objectToQuery(this.getValues()),
142 onComplete: function(transport) {
143 notify_callback2(transport);
149 print "<table width=\"100%\" class=\"prefPrefsList\">";
151 print "<h2>" . __("Personal data") . "</h2>";
153 $result = db_query($this->link, "SELECT email,full_name,otp_enabled,
154 access_level FROM ttrss_users
155 WHERE id = ".$_SESSION["uid"]);
157 $email = htmlspecialchars(db_fetch_result($result, 0, "email"));
158 $full_name = htmlspecialchars(db_fetch_result($result, 0, "full_name"));
159 $otp_enabled = sql_bool_to_bool(db_fetch_result($result, 0, "otp_enabled"));
161 print "<tr><td width=\"40%\">".__('Full name')."</td>";
162 print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" name=\"full_name\" required=\"1\"
163 value=\"$full_name\"></td></tr>";
165 print "<tr><td width=\"40%\">".__('E-mail')."</td>";
166 print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" name=\"email\" required=\"1\" value=\"$email\"></td></tr>";
168 if (!SINGLE_USER_MODE && !$_SESSION["hide_hello"]) {
170 $access_level = db_fetch_result($result, 0, "access_level");
171 print "<tr><td width=\"40%\">".__('Access level')."</td>";
172 print "<td>" . $access_level_names[$access_level] . "</td></tr>";
177 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">";
178 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"changeemail\">";
180 print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">".
181 __("Save data")."</button>";
185 if ($_SESSION["auth_module"]) {
188 $authenticator = $pluginhost->get_plugin($_SESSION["auth_module"]);
191 $authenticator = false;
194 if ($authenticator && method_exists($authenticator, "change_password")) {
196 print "<h2>" . __("Password") . "</h2>";
198 $result = db_query($this->link, "SELECT id FROM ttrss_users
199 WHERE id = ".$_SESSION["uid"]." AND pwd_hash
200 = 'SHA1:5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8'");
202 if (db_num_rows($result) != 0) {
203 print format_warning(__("Your password is at default value, please change it."), "default_pass_warning");
206 print "<form dojoType=\"dijit.form.Form\">";
208 print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">
209 evt.preventDefault();
210 if (this.validate()) {
211 notify_progress('Changing password...', true);
213 new Ajax.Request('backend.php', {
214 parameters: dojo.objectToQuery(this.getValues()),
215 onComplete: function(transport) {
217 if (transport.responseText.indexOf('ERROR: ') == 0) {
218 notify_error(transport.responseText.replace('ERROR: ', ''));
220 notify_info(transport.responseText);
221 var warn = $('default_pass_warning');
222 if (warn) Element.hide(warn);
230 print_notice("Changing your current password will disable OTP.");
233 print "<table width=\"100%\" class=\"prefPrefsList\">";
235 print "<tr><td width=\"40%\">".__("Old password")."</td>";
236 print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" type=\"password\" required=\"1\" name=\"old_password\"></td></tr>";
238 print "<tr><td width=\"40%\">".__("New password")."</td>";
240 print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" type=\"password\" required=\"1\"
241 name=\"new_password\"></td></tr>";
243 print "<tr><td width=\"40%\">".__("Confirm password")."</td>";
245 print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" type=\"password\" required=\"1\" name=\"confirm_password\"></td></tr>";
249 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">";
250 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"changepassword\">";
252 print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">".
253 __("Change password")."</button>";
257 if ($_SESSION["auth_module"] == "auth_internal") {
259 print "<h2>" . __("One time passwords / Authenticator") . "</h2>";
263 print_notice("One time passwords are currently enabled. Enter your current password below to disable.");
265 print "<form dojoType=\"dijit.form.Form\">";
267 print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">
268 evt.preventDefault();
269 if (this.validate()) {
270 notify_progress('Disabling OTP', true);
272 new Ajax.Request('backend.php', {
273 parameters: dojo.objectToQuery(this.getValues()),
274 onComplete: function(transport) {
276 if (transport.responseText.indexOf('ERROR: ') == 0) {
277 notify_error(transport.responseText.replace('ERROR: ', ''));
279 window.location.reload();
286 print "<table width=\"100%\" class=\"prefPrefsList\">";
288 print "<tr><td width=\"40%\">".__("Enter your password")."</td>";
290 print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" type=\"password\" required=\"1\"
291 name=\"password\"></td></tr>";
295 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">";
296 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"otpdisable\">";
298 print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">".
299 __("Disable OTP")."</button>";
305 print "<p>".__("You will need a compatible Authenticator to use this. Changing your password would automatically disable OTP.") . "</p>";
307 print "<p>".__("Scan the following code by the Authenticator application:")."</p>";
309 $csrf_token = $_SESSION["csrf_token"];
311 print "<img src=\"backend.php?op=pref-prefs&method=otpqrcode&csrf_token=$csrf_token\">";
313 print "<form dojoType=\"dijit.form.Form\" id=\"changeOtpForm\">";
315 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">";
316 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"otpenable\">";
318 print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">
319 evt.preventDefault();
320 if (this.validate()) {
321 notify_progress('Saving data...', true);
323 new Ajax.Request('backend.php', {
324 parameters: dojo.objectToQuery(this.getValues()),
325 onComplete: function(transport) {
327 if (transport.responseText.indexOf('ERROR: ') == 0) {
328 notify_error(transport.responseText.replace('ERROR: ', ''));
330 window.location.reload();
337 print "<table width=\"100%\" class=\"prefPrefsList\">";
339 print "<tr><td width=\"40%\">".__("Enter your password")."</td>";
341 print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" type=\"password\" required=\"1\"
342 name=\"password\"></td></tr>";
344 print "<tr><td colspan=\"2\">";
346 print "<input dojoType=\"dijit.form.CheckBox\" required=\"1\"
347 type=\"checkbox\" id=\"enable_otp\" name=\"enable_otp\"/> ";
348 print "<label for=\"enable_otp\">".__("I have scanned the code and would like to enable OTP")."</label>";
350 print "</td></tr><tr><td colspan=\"2\">";
355 print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">".
356 __("Enable OTP")."</button>";
366 $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB_SECTION,
367 "hook_prefs_tab_section", "prefPrefsAuth");
369 print "</div>"; #pane
371 print "<div dojoType=\"dijit.layout.AccordionPane\" selected=\"true\" title=\"".__('Preferences')."\">";
373 print "<form dojoType=\"dijit.form.Form\" id=\"changeSettingsForm\">";
375 print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">
376 evt.preventDefault();
377 if (this.validate()) {
378 console.log(dojo.objectToQuery(this.getValues()));
380 new Ajax.Request('backend.php', {
381 parameters: dojo.objectToQuery(this.getValues()),
382 onComplete: function(transport) {
383 var msg = transport.responseText;
384 if (msg.match('PREFS_THEME_CHANGED')) {
385 window.location.reload();
393 print '<div dojoType="dijit.layout.BorderContainer" gutters="false">';
395 print '<div dojoType="dijit.layout.ContentPane" region="center" style="overflow-y : auto">';
397 if ($_SESSION["profile"]) {
398 print_notice("Some preferences are only available in default profile.");
401 if ($_SESSION["profile"]) {
402 initialize_user_prefs($this->link, $_SESSION["uid"], $_SESSION["profile"]);
403 $profile_qpart = "profile = '" . $_SESSION["profile"] . "'";
405 initialize_user_prefs($this->link, $_SESSION["uid"]);
406 $profile_qpart = "profile IS NULL";
409 if ($_SESSION["prefs_show_advanced"])
410 $access_query = "true";
412 $access_query = "(access_level = 0 AND section_id != 3)";
414 $result = db_query($this->link, "SELECT DISTINCT
415 ttrss_user_prefs.pref_name,short_desc,help_text,value,type_name,
416 ttrss_prefs_sections.order_id,
417 section_name,def_value,section_id
418 FROM ttrss_prefs,ttrss_prefs_types,ttrss_prefs_sections,ttrss_user_prefs
419 WHERE type_id = ttrss_prefs_types.id AND
421 section_id = ttrss_prefs_sections.id AND
422 ttrss_user_prefs.pref_name = ttrss_prefs.pref_name AND
425 owner_uid = ".$_SESSION["uid"]."
426 ORDER BY ttrss_prefs_sections.order_id,short_desc");
430 $active_section = "";
432 while ($line = db_fetch_assoc($result)) {
434 if (in_array($line["pref_name"], $prefs_blacklist)) {
438 if ($_SESSION["profile"] && in_array($line["pref_name"],
439 $profile_blacklist)) {
443 if ($active_section != $line["section_name"]) {
445 if ($active_section != "") {
449 print "<table width=\"100%\" class=\"prefPrefsList\">";
451 $active_section = $line["section_name"];
453 print "<tr><td colspan=\"3\"><h3>".__($active_section)."</h3></td></tr>";
460 $type_name = $line["type_name"];
461 $pref_name = $line["pref_name"];
462 $value = $line["value"];
463 $def_value = $line["def_value"];
464 $help_text = $line["help_text"];
466 print "<td width=\"40%\" class=\"prefName\" id=\"$pref_name\">" . __($line["short_desc"]);
468 if ($help_text) print "<div class=\"prefHelp\">".__($help_text)."</div>";
472 print "<td class=\"prefValue\">";
474 if ($pref_name == "USER_TIMEZONE") {
476 $timezones = explode("\n", file_get_contents("lib/timezones.txt"));
478 print_select($pref_name, $value, $timezones, 'dojoType="dijit.form.FilteringSelect"');
479 } else if ($pref_name == "USER_STYLESHEET") {
481 print "<button dojoType=\"dijit.form.Button\"
482 onclick=\"customizeCSS()\">" . __('Customize') . "</button>";
484 } else if ($pref_name == "DEFAULT_ARTICLE_LIMIT") {
486 $limits = array(15, 30, 45, 60);
488 print_select($pref_name, $value, $limits,
489 'dojoType="dijit.form.Select"');
491 } else if ($pref_name == "DEFAULT_UPDATE_INTERVAL") {
493 global $update_intervals_nodefault;
495 print_select_hash($pref_name, $value, $update_intervals_nodefault,
496 'dojoType="dijit.form.Select"');
498 } else if ($type_name == "bool") {
500 if ($value == "true") {
506 if ($pref_name == "PURGE_UNREAD_ARTICLES" && FORCE_ARTICLE_PURGE != 0) {
507 $disabled = "disabled=\"1\"";
513 print_radio($pref_name, $value, __("Yes"), array(__("Yes"), __("No")),
516 } else if (array_search($pref_name, array('FRESH_ARTICLE_MAX_AGE', 'DEFAULT_ARTICLE_LIMIT',
517 'PURGE_OLD_DAYS', 'LONG_DATE_FORMAT', 'SHORT_DATE_FORMAT')) !== false) {
519 $regexp = ($type_name == 'integer') ? 'regexp="^\d*$"' : '';
521 if ($pref_name == "PURGE_OLD_DAYS" && FORCE_ARTICLE_PURGE != 0) {
522 $disabled = "disabled=\"1\"";
523 $value = FORCE_ARTICLE_PURGE;
528 print "<input dojoType=\"dijit.form.ValidationTextBox\"
529 required=\"1\" $regexp $disabled
530 name=\"$pref_name\" value=\"$value\">";
532 } else if ($pref_name == "SSL_CERT_SERIAL") {
534 print "<input dojoType=\"dijit.form.ValidationTextBox\"
535 id=\"SSL_CERT_SERIAL\" readonly=\"1\"
536 name=\"$pref_name\" value=\"$value\">";
538 $cert_serial = htmlspecialchars(get_ssl_certificate_id());
539 $has_serial = ($cert_serial) ? "false" : "true";
541 print " <button dojoType=\"dijit.form.Button\" disabled=\"$has_serial\"
542 onclick=\"insertSSLserial('$cert_serial')\">" .
543 __('Register') . "</button>";
545 print " <button dojoType=\"dijit.form.Button\"
546 onclick=\"insertSSLserial('')\">" .
547 __('Clear') . "</button>";
549 } else if ($pref_name == 'DIGEST_PREFERRED_TIME') {
550 print "<input dojoType=\"dijit.form.ValidationTextBox\"
551 id=\"$pref_name\" regexp=\"[012]?\d:\d\d\" placeHolder=\"12:00\"
552 name=\"$pref_name\" value=\"$value\"><div class=\"insensitive\">".
553 T_sprintf("Current server time: %s (UTC)", date("H:i")) . "</div>";
555 $regexp = ($type_name == 'integer') ? 'regexp="^\d*$"' : '';
557 print "<input dojoType=\"dijit.form.ValidationTextBox\"
559 name=\"$pref_name\" value=\"$value\">";
572 $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB_SECTION,
573 "hook_prefs_tab_section", "prefPrefsPrefsInside");
575 print '</div>'; # inside pane
576 print '<div dojoType="dijit.layout.ContentPane" region="bottom">';
578 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">";
579 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"saveconfig\">";
581 print "<button dojoType=\"dijit.form.Button\" type=\"submit\">".
582 __('Save configuration')."</button> ";
584 print "<button dojoType=\"dijit.form.Button\" onclick=\"return editProfiles()\">".
585 __('Manage profiles')."</button> ";
587 print "<button dojoType=\"dijit.form.Button\" onclick=\"return validatePrefsReset()\">".
588 __('Reset to defaults')."</button>";
592 $checked = $_SESSION["prefs_show_advanced"] ? "checked='1'" : "";
594 print "<input onclick='toggleAdvancedPrefs()'
595 id='prefs_show_advanced'
596 dojoType=\"dijit.form.CheckBox\"
598 type=\"checkbox\"></input>
599 <label for='prefs_show_advanced'>" .
600 __("Show additional preferences") . "</label>";
603 $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB_SECTION,
604 "hook_prefs_tab_section", "prefPrefsPrefsOutside");
607 print '</div>'; # inner pane
608 print '</div>'; # border container
610 print "</div>"; #pane
612 print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Plugins')."\">";
614 print "<h2>".__("Plugins")."</h2>";
616 print_notice("You will need to reload Tiny Tiny RSS for plugin changes to take effect.");
618 print "<form dojoType=\"dijit.form.Form\" id=\"changePluginsForm\">";
620 print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">
621 evt.preventDefault();
622 if (this.validate()) {
623 notify_progress('Saving data...', true);
625 new Ajax.Request('backend.php', {
626 parameters: dojo.objectToQuery(this.getValues()),
627 onComplete: function(transport) {
629 if (confirm(__('Selected plugins have been enabled. Reload?'))) {
630 window.location.reload();
637 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-prefs\">";
638 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"setplugins\">";
640 print "<table width='100%' class='prefPluginsList'>";
642 print "<tr><td colspan='4'><h3>".__("System plugins")."</h3></td></tr>";
644 print "<tr class=\"title\">
645 <td width=\"5%\"> </td>
646 <td width='10%'>".__('Plugin')."</td>
647 <td width=''>".__('Description')."</td>
648 <td width='5%'>".__('Version')."</td>
649 <td width='10%'>".__('Author')."</td></tr>";
651 $system_enabled = array_map("trim", explode(",", PLUGINS));
652 $user_enabled = array_map("trim", explode(",", get_pref($this->link, "_ENABLED_PLUGINS")));
654 $tmppluginhost = new PluginHost($this->link);
655 $tmppluginhost->load_all($tmppluginhost::KIND_ALL, $_SESSION["uid"]);
656 $tmppluginhost->load_data(true);
658 foreach ($tmppluginhost->get_plugins() as $name => $plugin) {
659 $about = $plugin->about();
661 if ($about[3] && strpos($name, "example") === FALSE) {
662 if (in_array($name, $system_enabled)) {
663 $checked = "checked='1'";
670 print "<td align='center'><input disabled='1'
671 dojoType=\"dijit.form.CheckBox\" $checked
672 type=\"checkbox\"></td>";
674 print "<td>$name</td>";
675 print "<td>" . htmlspecialchars($about[1]) . "</td>";
676 print "<td>" . htmlspecialchars(sprintf("%.2f", $about[0])) . "</td>";
677 print "<td>" . htmlspecialchars($about[2]) . "</td>";
679 if (count($tmppluginhost->get_all($plugin)) > 0) {
680 if (in_array($name, $system_enabled)) {
681 print "<td><a href='#' onclick=\"clearPluginData('$name')\"
682 class='visibleLink'>".__("Clear data")."</a></td>";
691 print "<tr><td colspan='4'><h3>".__("User plugins")."</h3></td></tr>";
693 print "<tr class=\"title\">
694 <td width=\"5%\"> </td>
695 <td width='10%'>".__('Plugin')."</td>
696 <td width=''>".__('Description')."</td>
697 <td width='5%'>".__('Version')."</td>
698 <td width='10%'>".__('Author')."</td></tr>";
701 foreach ($tmppluginhost->get_plugins() as $name => $plugin) {
702 $about = $plugin->about();
704 if (!$about[3] && strpos($name, "example") === FALSE) {
706 if (in_array($name, $system_enabled)) {
707 $checked = "checked='1'";
708 $disabled = "disabled='1'";
710 } else if (in_array($name, $user_enabled)) {
711 $checked = "checked='1'";
713 $rowclass = "Selected";
720 print "<tr class='$rowclass'>";
722 print "<td align='center'><input id='FPCHK-$name' name='plugins[]' value='$name' onclick='toggleSelectRow2(this);'
723 dojoType=\"dijit.form.CheckBox\" $checked $disabled
724 type=\"checkbox\"></td>";
726 print "<td><label for='FPCHK-$name'>$name</label></td>";
727 print "<td><label for='FPCHK-$name'>" . htmlspecialchars($about[1]) . "</label></td>";
728 print "<td>" . htmlspecialchars(sprintf("%.2f", $about[0])) . "</td>";
729 print "<td>" . htmlspecialchars($about[2]) . "</td>";
731 if (count($tmppluginhost->get_all($plugin)) > 0) {
732 if (in_array($name, $system_enabled) || in_array($name, $user_enabled)) {
733 print "<td><a href='#' onclick=\"clearPluginData('$name')\" class='visibleLink'>".__("Clear data")."</a></td>";
747 print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">".
748 __("Enable selected plugins")."</button></p>";
752 print "</div>"; #pane
755 $pluginhost->run_hooks($pluginhost::HOOK_PREFS_TAB,
756 "hook_prefs_tab", "prefPrefs");
758 print "</div>"; #container
761 function toggleAdvanced() {
762 $_SESSION["prefs_show_advanced"] = !$_SESSION["prefs_show_advanced"];
765 function otpqrcode() {
766 require_once "lib/otphp/vendor/base32.php";
767 require_once "lib/otphp/lib/otp.php";
768 require_once "lib/otphp/lib/totp.php";
769 require_once "lib/phpqrcode/phpqrcode.php";
771 $result = db_query($this->link, "SELECT login,salt,otp_enabled
773 WHERE id = ".$_SESSION["uid"]);
775 $base32 = new Base32();
777 $login = db_fetch_result($result, 0, "login");
778 $otp_enabled = sql_bool_to_bool(db_fetch_result($result, 0, "otp_enabled"));
781 $secret = $base32->encode(sha1(db_fetch_result($result, 0, "salt")));
782 $topt = new \OTPHP\TOTP($secret);
783 print QRcode::png($topt->provisioning_uri($login));
787 function otpenable() {
788 $password = db_escape_string($_REQUEST["password"]);
789 $enable_otp = $_REQUEST["enable_otp"] == "on";
792 $authenticator = $pluginhost->get_plugin($_SESSION["auth_module"]);
794 if ($authenticator->check_password($_SESSION["uid"], $password)) {
797 db_query($this->link, "UPDATE ttrss_users SET otp_enabled = true WHERE
798 id = " . $_SESSION["uid"]);
803 print "ERROR: ".__("Incorrect password");
808 function otpdisable() {
809 $password = db_escape_string($_REQUEST["password"]);
812 $authenticator = $pluginhost->get_plugin($_SESSION["auth_module"]);
814 if ($authenticator->check_password($_SESSION["uid"], $password)) {
816 db_query($this->link, "UPDATE ttrss_users SET otp_enabled = false WHERE
817 id = " . $_SESSION["uid"]);
821 print "ERROR: ".__("Incorrect password");
826 function setplugins() {
827 $plugins = join(",", $_REQUEST["plugins"]);
829 set_pref($this->link, "_ENABLED_PLUGINS", $plugins);
832 function clearplugindata() {
833 $name = db_escape_string($_REQUEST["name"]);
836 $pluginhost->clear_data($pluginhost->get_plugin($name));