add --opml-export to update.php
This commit is contained in:
parent
5e77d0062b
commit
7a2e9bef77
|
@ -125,15 +125,16 @@ class Opml extends Handler_Protected {
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
function opml_export($name, $owner_uid, $hide_private_feeds = false, $include_settings = true) {
|
function opml_export($filename, $owner_uid, $hide_private_feeds = false, $include_settings = true, $file_output = false) {
|
||||||
if (!$owner_uid) return;
|
if (!$owner_uid) return;
|
||||||
|
|
||||||
if (!isset($_REQUEST["debug"])) {
|
if (!$file_output)
|
||||||
header("Content-type: application/xml+opml");
|
if (!isset($_REQUEST["debug"])) {
|
||||||
header("Content-Disposition: attachment; filename=" . $name );
|
header("Content-type: application/xml+opml");
|
||||||
} else {
|
header("Content-Disposition: attachment; filename=$filename");
|
||||||
header("Content-type: text/xml");
|
} else {
|
||||||
}
|
header("Content-type: text/xml");
|
||||||
|
}
|
||||||
|
|
||||||
$out = "<?xml version=\"1.0\" encoding=\"utf-8\"?".">";
|
$out = "<?xml version=\"1.0\" encoding=\"utf-8\"?".">";
|
||||||
|
|
||||||
|
@ -288,7 +289,10 @@ class Opml extends Handler_Protected {
|
||||||
'return str_repeat("\t", intval(strlen($matches[0])/2));'),
|
'return str_repeat("\t", intval(strlen($matches[0])/2));'),
|
||||||
$res); */
|
$res); */
|
||||||
|
|
||||||
print $res;
|
if ($file_output)
|
||||||
|
return file_put_contents($filename, $res) > 0;
|
||||||
|
else
|
||||||
|
print $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Import
|
// Import
|
||||||
|
|
60
update.php
60
update.php
|
@ -85,6 +85,7 @@
|
||||||
"debug-feed:",
|
"debug-feed:",
|
||||||
"force-refetch",
|
"force-refetch",
|
||||||
"force-rehash",
|
"force-rehash",
|
||||||
|
"opml-export:",
|
||||||
"help");
|
"help");
|
||||||
|
|
||||||
foreach (PluginHost::getInstance()->get_commands() as $command => $data) {
|
foreach (PluginHost::getInstance()->get_commands() as $command => $data) {
|
||||||
|
@ -122,29 +123,30 @@
|
||||||
if (count($options) == 0 || isset($options["help"]) ) {
|
if (count($options) == 0 || isset($options["help"]) ) {
|
||||||
print "Tiny Tiny RSS data update script.\n\n";
|
print "Tiny Tiny RSS data update script.\n\n";
|
||||||
print "Options:\n";
|
print "Options:\n";
|
||||||
print " --feeds - update feeds\n";
|
print " --feeds - update feeds\n";
|
||||||
print " --daemon - start single-process update daemon\n";
|
print " --daemon - start single-process update daemon\n";
|
||||||
print " --task N - create lockfile using this task id\n";
|
print " --task N - create lockfile using this task id\n";
|
||||||
print " --cleanup-tags - perform tags table maintenance\n";
|
print " --cleanup-tags - perform tags table maintenance\n";
|
||||||
print " --quiet - don't output messages to stdout\n";
|
print " --quiet - don't output messages to stdout\n";
|
||||||
print " --log FILE - log messages to FILE\n";
|
print " --log FILE - log messages to FILE\n";
|
||||||
print " --log-level N - log verbosity level\n";
|
print " --log-level N - log verbosity level\n";
|
||||||
print " --indexes - recreate missing schema indexes\n";
|
print " --indexes - recreate missing schema indexes\n";
|
||||||
print " --update-schema - update database schema\n";
|
print " --update-schema - update database schema\n";
|
||||||
print " --gen-search-idx - generate basic PostgreSQL fulltext search index\n";
|
print " --gen-search-idx - generate basic PostgreSQL fulltext search index\n";
|
||||||
print " --convert-filters - convert type1 filters to type2\n";
|
print " --convert-filters - convert type1 filters to type2\n";
|
||||||
print " --send-digests - send pending email digests\n";
|
print " --send-digests - send pending email digests\n";
|
||||||
print " --force-update - force update of all feeds\n";
|
print " --force-update - force update of all feeds\n";
|
||||||
print " --list-plugins - list all available plugins\n";
|
print " --list-plugins - list all available plugins\n";
|
||||||
print " --debug-feed N - perform debug update of feed N\n";
|
print " --debug-feed N - perform debug update of feed N\n";
|
||||||
print " --force-refetch - debug update: force refetch feed data\n";
|
print " --force-refetch - debug update: force refetch feed data\n";
|
||||||
print " --force-rehash - debug update: force rehash articles\n";
|
print " --force-rehash - debug update: force rehash articles\n";
|
||||||
print " --help - show this help\n";
|
print " --opml-export \"USER FILE\" - export feeds of selected user to OPML\n";
|
||||||
|
print " --help - show this help\n";
|
||||||
print "Plugin options:\n";
|
print "Plugin options:\n";
|
||||||
|
|
||||||
foreach (PluginHost::getInstance()->get_commands() as $command => $data) {
|
foreach (PluginHost::getInstance()->get_commands() as $command => $data) {
|
||||||
$args = $data['arghelp'];
|
$args = $data['arghelp'];
|
||||||
printf(" --%-19s - %s\n", "$command $args", $data["description"]);
|
printf(" --%-26s - %s\n", "$command $args", $data["description"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -483,6 +485,26 @@
|
||||||
Digest::send_headlines_digests();
|
Digest::send_headlines_digests();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($options["opml-export"])) {
|
||||||
|
list ($user, $filename) = explode(" ", $options["opml-export"], 2);
|
||||||
|
|
||||||
|
Debug::log("Exporting feeds of user $user to $filename as OPML...");
|
||||||
|
|
||||||
|
$sth = $pdo->prepare("SELECT id FROM ttrss_users WHERE login = ?");
|
||||||
|
$sth->execute([$user]);
|
||||||
|
|
||||||
|
if ($res = $sth->fetch()) {
|
||||||
|
$opml = new OPML("");
|
||||||
|
|
||||||
|
$rc = $opml->opml_export($filename, $res["id"], false, true, true);
|
||||||
|
|
||||||
|
Debug::log($rc ? "Success." : "Failed.");
|
||||||
|
} else {
|
||||||
|
Debug::log("User not found: $user");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
PluginHost::getInstance()->run_commands($options);
|
PluginHost::getInstance()->run_commands($options);
|
||||||
|
|
||||||
if (file_exists(LOCK_DIRECTORY . "/$lock_filename"))
|
if (file_exists(LOCK_DIRECTORY . "/$lock_filename"))
|
||||||
|
|
Loading…
Reference in New Issue