X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=opml.php;h=ab71493b1fba3e8690a0e07839b620461ec2164d;hb=5f0a3741d0a549849b503eca7b6d7b87d9903069;hp=0e601e111040b68d90440c761babefc530ea4842;hpb=20fcff19c63288054253b80ebe99c510990462cb;p=tt-rss.git
diff --git a/opml.php b/opml.php
index 0e601e11..ab71493b 100644
--- a/opml.php
+++ b/opml.php
@@ -1,135 +1,202 @@
-
- // FIXME there are some brackets issues here
-
- $op = $_REQUEST["op"];
- if ($op == "Export") {
- header("Content-type: application/xml");
- print "";
- }
+";
- if ($op == "Export") {
print "";
- print "" . date("r", time()) . "";
+ print "
+ " . date("r", time()) . "
+ Tiny Tiny RSS Feed Export
+ ";
print "";
- $result = db_query($link, "SELECT * FROM ttrss_feeds ORDER BY title");
+ $cat_mode = false;
- while ($line = db_fetch_assoc($result)) {
- $title = $line["title"];
- $url = $line["feed_url"];
+ $select = "SELECT * ";
+ $where = "WHERE owner_uid = '$owner_uid'";
+ $orderby = "ORDER BY title";
+ if ($hide_private_feeds){
+ $where = "WHERE owner_uid = '$owner_uid' AND private IS false AND
+ auth_login = '' AND auth_pass = ''";
+ }
+
+
+
+ if (get_pref($link, 'ENABLE_FEED_CATS', $owner_uid) == true) {
+ $cat_mode = true;
+ $select = "SELECT
+ title, feed_url, site_url,
+ (SELECT title FROM ttrss_feed_categories WHERE id = cat_id) as cat_title";
+ $orderby = "ORDER BY cat_title, title";
- print "";
}
+ else{
+ $cat_feed = get_pref($link, 'ENABLE_FEED_CATS');
+ print "";
+ print "";
- print "";
- }
+ }
- function startElement($parser, $name, $attrs) {
- if ($name == "OUTLINE") {
- $title = db_escape_string($attrs['TEXT']);
- $url = db_escape_string($attrs['XMLURL']);
+ $result = db_query($link, $select." FROM ttrss_feeds ".$where." ".$orderby);
- if (!$title || !$url) return;
+ $old_cat_title = "";
- print "Feed $title ($url)... ";
+ while ($line = db_fetch_assoc($result)) {
+ $title = htmlspecialchars($line["title"]);
+ $url = htmlspecialchars($line["feed_url"]);
+ $site_url = htmlspecialchars($line["site_url"]);
- $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
+ if ($cat_mode) {
+ $cat_title = htmlspecialchars($line["cat_title"]);
- $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE
- title = '$title' OR feed_url = '$url'");
+ if ($old_cat_title != $cat_title) {
+ if ($old_cat_title) {
+ print "\n";
+ }
- if ($result && db_num_rows($result) > 0) {
-
- print " Already imported.
";
+ if ($cat_title) {
+ print "\n";
+ }
+ $old_cat_title = $cat_title;
+ }
+ }
+
+ if ($site_url) {
+ $html_url_qpart = "htmlUrl=\"$site_url\"";
} else {
-
- $result = db_query($link, "INSERT INTO ttrss_feeds (title, feed_url) VALUES
- ('$title', '$url')");
+ $html_url_qpart = "";
+ }
+
+ print "\n";
+ }
+
+ if ($cat_mode && $old_cat_title) {
+ print "\n";
+ }
+
+ # export tt-rss settings
- print "Done.
";
+ if ($include_settings) {
+ print "";
+
+ $result = db_query($link, "SELECT pref_name, value FROM ttrss_user_prefs WHERE
+ profile IS NULL AND owner_uid = " . $_SESSION["uid"]);
+
+ while ($line = db_fetch_assoc($result)) {
+
+ $name = $line["pref_name"];
+ $value = htmlspecialchars($line["value"]);
+
+ print "";
+
+ print "";
}
+ print "";
}
+
+ print "
Importing OPML...
- ";
+ if ($op == "Export") {
- if (WEB_DEMO_MODE) {
- print "OPML import is disabled in demo-mode.";
- print "
- Return to preferences
";
}
- function endElement($parser, $name) {
+ // FIXME there are some brackets issues here
+ $op = $_REQUEST["op"];
+ if (!$op) $op = "Export";
- }
+ $output_name = $_REQUEST["filename"];
+ if (!$output_name) $output_name = "TinyTinyRSS.opml";
- if ($op == "Import") {
+ $show_settings = $_REQUEST["settings"];
- print "
-