X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=opml.php;h=709cfd4ccb79fbffc9e23ad10f14f243255d4e51;hb=404e2e3603c852a3f82a21c14b8888005e2b3f99;hp=f29b19023758597f8d888e56bf17fc870aa66fc1;hpb=9f311df6262c206a56f47a593244336e6ba1f54c;p=tt-rss.git diff --git a/opml.php b/opml.php index f29b1902..709cfd4c 100644 --- a/opml.php +++ b/opml.php @@ -1,119 +1,39 @@ -"; - print ""; - print "" . date("r", time()) . ""; - print ""; - - $result = pg_query("SELECT * FROM ttrss_feeds ORDER BY title"); - - while ($line = pg_fetch_assoc($result)) { - $title = $line["title"]; - $url = $line["feed_url"]; - - print ""; - } - - print ""; - } - - function startElement($parser, $name, $attrs) { - if ($name == "OUTLINE") { - $title = pg_escape_string($attrs['TEXT']); - $url = pg_escape_string($attrs['XMLURL']); - - print "Feed $title ($url)... "; - - $result = pg_query("SELECT id FROM ttrss_feeds WHERE - title = '$title' OR feed_url = '$url'"); - - if (pg_num_rows($result) > 0) { - - print " Already imported.
"; - - } else { - - $result = pg_query("INSERT INTO ttrss_feeds (title, feed_url) VALUES - ('$title', '$url')"); - - print "Done.
"; - - } - - } - } - - function endElement($parser, $name) { - - - } - - if ($op == "Import") { - print " - - - -

Importing OPML...

-
"; - - if (is_file($_FILES['opml_file']['tmp_name'])) { - - $xml_parser = xml_parser_create(); - - xml_set_element_handler($xml_parser, "startElement", "endElement"); - - $fp = fopen($_FILES['opml_file']['tmp_name'], "r"); - - if ($fp) { - - while ($data = fread($fp, 4096)) { + $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); - if (!xml_parse($xml_parser, $data, feof($fp))) { - - print sprintf("Unable to parse OPML file, XML error: %s at line %d", - xml_error_string(xml_get_error_code($xml_parser)), - xml_get_current_line_number($xml_parser)); + if (!init_plugins($link)) return; - print "

- Return to preferences"; + $op = $_REQUEST['op']; - return; + if ($op == "publish"){ + $key = db_escape_string($link, $_REQUEST["key"]); - } - } + $result = db_query($link, "SELECT owner_uid + FROM ttrss_access_keys WHERE + access_key = '$key' AND feed_id = 'OPML:Publish'"); - xml_parser_free($xml_parser); - fclose($fp); + if (db_num_rows($result) == 1) { + $owner_uid = db_fetch_result($result, 0, "owner_uid"); - } else { - print("Error: Could not open OPML input."); - } + $opml = new Opml($link, $_REQUEST); + $opml->opml_export("", $owner_uid, true, false); - } else { - print "Error: please upload OPML file."; + } else { + print "User not found"; } - - print "

- Return to preferences"; - - print "

"; - } - pg_close($link); + db_close($link); ?>