X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=opml.php;h=ab71493b1fba3e8690a0e07839b620461ec2164d;hb=5f0a3741d0a549849b503eca7b6d7b87d9903069;hp=dd73a84632bffc16ebc140b1d8b0c4503dc731d9;hpb=a885f0ec2a4b20f9a0efb910815684422c15c945;p=tt-rss.git diff --git a/opml.php b/opml.php index dd73a846..ab71493b 100644 --- a/opml.php +++ b/opml.php @@ -1,57 +1,64 @@ "; - } + print ""; - if ($op == "Export") { print ""; print " " . date("r", time()) . " Tiny Tiny RSS Feed Export - "; + "; print ""; $cat_mode = false; - if (get_pref($link, 'ENABLE_FEED_CATS')) { + $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; - $result = db_query($link, "SELECT - title,feed_url,site_url, - (SELECT title FROM ttrss_feed_categories WHERE id = cat_id) as cat_title - FROM ttrss_feeds - WHERE - owner_uid = '$owner_uid' - ORDER BY cat_title,title"); - } else { - $result = db_query($link, "SELECT * FROM ttrss_feeds - WHERE owner_uid = '$owner_uid' ORDER BY title"); + $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"; + + } + else{ + $cat_feed = get_pref($link, 'ENABLE_FEED_CATS'); + print ""; + print ""; + } + + $result = db_query($link, $select." FROM ttrss_feeds ".$where." ".$orderby); + $old_cat_title = ""; while ($line = db_fetch_assoc($result)) { @@ -64,11 +71,11 @@ if ($old_cat_title != $cat_title) { if ($old_cat_title) { - print "\n"; + print "\n"; } if ($cat_title) { - print "\n"; + print "\n"; } $old_cat_title = $cat_title; @@ -85,154 +92,108 @@ } if ($cat_mode && $old_cat_title) { - print "\n"; + print "\n"; } - print ""; - } - - if ($op == "Import") { - - print " - - - - -

-
-

"._('Importing OPML...')."

"; - - if (is_file($_FILES['opml_file']['tmp_name'])) { - $dom = domxml_open_file($_FILES['opml_file']['tmp_name']); - - if ($dom) { - $root = $dom->document_element(); - - $body = $root->get_elements_by_tagname('body'); - - if ($body[0]) { - $body = $body[0]; - - $outlines = $body->get_elements_by_tagname('outline'); - - print ""; - - foreach ($outlines as $outline) { - - $feed_title = db_escape_string($outline->get_attribute('text')); + # export tt-rss settings - if (!$feed_title) { - $feed_title = db_escape_string($outline->get_attribute('title')); - } + if ($include_settings) { + print ""; - $cat_title = db_escape_string($outline->get_attribute('title')); + $result = db_query($link, "SELECT pref_name, value FROM ttrss_user_prefs WHERE + profile IS NULL AND owner_uid = " . $_SESSION["uid"]); - if (!$cat_title) { - $cat_title = db_escape_string($outline->get_attribute('text')); - } - - $feed_url = db_escape_string($outline->get_attribute('xmlUrl')); - $site_url = db_escape_string($outline->get_attribute('htmlUrl')); + while ($line = db_fetch_assoc($result)) { - if ($cat_title && !$feed_url) { + $name = $line["pref_name"]; + $value = htmlspecialchars($line["value"]); - db_query($link, "BEGIN"); - - $result = db_query($link, "SELECT id FROM - ttrss_feed_categories WHERE title = '$cat_title' AND - owner_uid = '$owner_uid' LIMIT 1"); + print ""; - if (db_num_rows($result) == 0) { + print ""; - printf(_("Adding category %s..."), $cat_title); - print "
"; - - db_query($link, "INSERT INTO ttrss_feed_categories - (title,owner_uid) - VALUES ('$cat_title', '$owner_uid')"); - } + } - db_query($link, "COMMIT"); - } + print "
"; + } -// print "$active_category : $feed_title : $feed_url
"; + print ""; + } - if (!$feed_title || !$feed_url) continue; + // FIXME there are some brackets issues here - db_query($link, "BEGIN"); + $op = $_REQUEST["op"]; + if (!$op) $op = "Export"; - $cat_id = null; + $output_name = $_REQUEST["filename"]; + if (!$output_name) $output_name = "TinyTinyRSS.opml"; - $parent_node = $outline->parent_node(); + $show_settings = $_REQUEST["settings"]; - if ($parent_node && $parent_node->node_name() == "outline") { - $element_category = $parent_node->get_attribute('title'); - } else { - $element_category = ''; - } + if ($op == "Export") { - if ($element_category) { + login_sequence($link); + $owner_uid = $_SESSION["uid"]; + return opml_export($link, $output_name, $owner_uid, false, ($show_settings == 1)); + } - $result = db_query($link, "SELECT id FROM - ttrss_feed_categories WHERE title = '$element_category' AND - owner_uid = '$owner_uid' LIMIT 1"); + if ($op == "publish"){ + $key = db_escape_string($_REQUEST["key"]); - if (db_num_rows($result) == 1) { - $cat_id = db_fetch_result($result, 0, "id"); - } - } + $result = db_query($link, "SELECT owner_uid + FROM ttrss_access_keys WHERE + access_key = '$key' AND feed_id = 'OPML:Publish'"); - $result = db_query($link, "SELECT id FROM ttrss_feeds WHERE - (title = '$feed_title' OR feed_url = '$feed_url') - AND owner_uid = '$owner_uid'"); + if (db_num_rows($result) == 1) { + $owner_uid = db_fetch_result($result, 0, "owner_uid"); + return opml_export($link, "", $owner_uid, true, false); + } else { + print "User not found"; + } + } - print ""; + if ($op == "Import") { - if (db_num_rows($result) > 0) { - print ""; - } else { + login_sequence($link); + $owner_uid = $_SESSION["uid"]; - if ($cat_id) { - $add_query = "INSERT INTO ttrss_feeds - (title, feed_url, owner_uid, cat_id, site_url) VALUES - ('$feed_title', '$feed_url', '$owner_uid', - '$cat_id', '$site_url')"; + header('Content-Type: text/html; charset=utf-8'); - } else { - $add_query = "INSERT INTO ttrss_feeds - (title, feed_url, owner_uid, site_url) VALUES - ('$feed_title', '$feed_url', '$owner_uid', '$site_url')"; + print " + + + ".__("OPML Utility")." + + + +
+

".__('OPML Utility')."

"; - } + db_query($link, "BEGIN"); - db_query($link, $add_query); - - print ""; - } + /* create Imported feeds category just in case */ - print ""; - - db_query($link, "COMMIT"); - } + $result = db_query($link, "SELECT id FROM + ttrss_feed_categories WHERE title = 'Imported feeds' AND + owner_uid = '$owner_uid' LIMIT 1"); - print "
$feed_title - (rss)"._("Already imported.").""._('Done.')."
"; + if (db_num_rows($result) == 0) { + db_query($link, "INSERT INTO ttrss_feed_categories + (title,owner_uid) + VALUES ('Imported feeds', '$owner_uid')"); + } - } else { - print "
"._("Error: can't find body element.")."
"; - } - } else { - print "
"._("Error while parsing document.")."
"; - } + db_query($link, "COMMIT"); - } else { - print "
"._("Error: please upload OPML file.")."
"; - } + print "

".__("Importing OPML...")."

"; + require_once "modules/opml_domdoc.php"; + opml_import_domdoc($link, $owner_uid); - print "

- "._("Return to preferences").""; + print "

+ +
"; - print "
"; + print ""; }