]> git.wh0rd.org - tt-rss.git/blobdiff - update.php
af_zz_imgproxy: implement a whitelist of known sites that have optional SSL
[tt-rss.git] / update.php
index 65cf9f06efbea909b923a305abf6d954dca1b020..2601e965c7731dd856012e4c62cc91a462216e78 100755 (executable)
@@ -38,6 +38,7 @@
                        "debug-feed:",
                        "force-refetch",
                        "force-rehash",
+                       "decrypt-feeds",
                        "help");
 
        foreach (PluginHost::getInstance()->get_commands() as $command => $data) {
@@ -65,7 +66,7 @@
                <div class="floatingLogo"><img src="images/logo_small.png"></div>
                <h1><?php echo __("Tiny Tiny RSS data update script.") ?></h1>
 
-               <?php print_error("Please run this script from the command line. Use option \"-help\" to display command help if this error is displayed erroneously."); ?>
+               <?php print_error("Please run this script from the command line. Use option \"--help\" to display command help if this error is displayed erroneously."); ?>
 
                </body></html>
        <?php
@@ -91,6 +92,7 @@
                print "  --debug-feed N       - perform debug update of feed N\n";
                print "  --force-refetch      - debug update: force refetch feed data\n";
                print "  --force-rehash       - debug update: force rehash articles\n";
+               print "  --decrypt-feeds      - decrypt feed passwords\n";
                print "  --help               - show this help\n";
                print "Plugin options:\n";
 
                update_rss_feed($feed);
        }
 
+       if (isset($options["decrypt-feeds"])) {
+               $result = db_query("SELECT id, auth_pass FROM ttrss_feeds WHERE auth_pass_encrypted = true");
+
+               if (!function_exists("mcrypt_decrypt")) {
+                       _debug("mcrypt functions not available.");
+                       return;
+               }
+
+               require_once "crypt.php";
+
+               $total = 0;
+
+               db_query("BEGIN");
+
+               while ($line = db_fetch_assoc($result)) {
+                       _debug("processing feed id " . $line["id"]);
+
+                       $auth_pass = db_escape_string(decrypt_string($line["auth_pass"]));
+
+                       db_query("UPDATE ttrss_feeds SET auth_pass_encrypted = false, auth_pass = '$auth_pass'
+                               WHERE id = " . $line["id"]);
+
+                       ++$total;
+               }
+
+               db_query("COMMIT");
+
+               _debug("$total feeds processed.");
+       }
+
        PluginHost::getInstance()->run_commands($options);
 
        if (file_exists(LOCK_DIRECTORY . "/$lock_filename"))