]>
git.wh0rd.org - tt-rss.git/blob - opml.php
2 require_once "sessions.php";
3 require_once "sanity_check.php";
4 require_once "functions.php";
5 require_once "config.php";
7 require_once "db-prefs.php";
9 $link = db_connect(DB_HOST
, DB_USER
, DB_PASS
, DB_NAME
);
11 if (DB_TYPE
== "pgsql") {
12 pg_query($link, "set client_encoding = 'utf-8'");
13 pg_set_client_encoding("UNICODE");
16 login_sequence($link);
18 $owner_uid = $_SESSION["uid"];
20 function opml_export($link, $owner_uid) {
21 header("Content-type: application/xml+opml");
22 print "<?phpxml version=\"1.0\"?>";
24 print "<opml version=\"1.0\">";
26 <dateCreated>" . date("r", time()) . "</dateCreated>
27 <title>Tiny Tiny RSS Feed Export</title>
33 if (get_pref($link, 'ENABLE_FEED_CATS')) {
35 $result = db_query($link, "SELECT
36 title,feed_url,site_url,
37 (SELECT title FROM ttrss_feed_categories WHERE id = cat_id) as cat_title
40 owner_uid = '$owner_uid'
41 ORDER BY cat_title,title");
43 $result = db_query($link, "SELECT * FROM ttrss_feeds
44 WHERE owner_uid = '$owner_uid' ORDER BY title");
49 while ($line = db_fetch_assoc($result)) {
50 $title = htmlspecialchars($line["title"]);
51 $url = htmlspecialchars($line["feed_url"]);
52 $site_url = htmlspecialchars($line["site_url"]);
55 $cat_title = htmlspecialchars($line["cat_title"]);
57 if ($old_cat_title != $cat_title) {
63 print "<outline title=\"$cat_title\">\n";
66 $old_cat_title = $cat_title;
71 $html_url_qpart = "htmlUrl=\"$site_url\"";
76 print "<outline text=\"$title\" xmlUrl=\"$url\" $html_url_qpart/>\n";
79 if ($cat_mode && $old_cat_title) {
83 print "</body></opml>";
86 // FIXME there are some brackets issues here
88 $op = $_REQUEST["op"];
90 if (!$op) $op = "Export";
92 if ($op == "Export") {
93 return opml_export($link, $owner_uid);
96 if ($op == "Import") {
100 <link rel=\"stylesheet\" href=\"utility.css\" type=\"text/css\">
101 <title>OPML Utility</title>
104 <div class=\"floatingLogo\"><img src=\"images/ttrss_logo.png\"></div>
105 <h1>"._('OPML Utility')."</h1>";
107 if (function_exists('domxml_open_file')) {
108 print "<p>Importing OPML (using DOMXML extension)...</p>";
109 require_once "modules/opml_domxml.php";
110 opml_import_domxml($link, $owner_uid);
112 print "<p>Importing OPML (using DOMDocument extension)...</p>";
113 require_once "modules/opml_domdoc.php";
114 opml_import_domdoc($link, $owner_uid);
117 print "<br><form method=\"GET\" action=\"prefs.php\">
118 <input type=\"submit\" value=\"Return to preferences\">
121 print "</body></html>";
125 // if ($link) db_close($link);