]>
Commit | Line | Data |
---|---|---|
1d3a17c7 | 1 | <?php |
d65981e2 AD |
2 | error_reporting(E_ERROR | E_WARNING | E_PARSE); |
3 | ||
1559e374 | 4 | require_once "sessions.php"; |
66581886 | 5 | require_once "sanity_check.php"; |
4e9f5c24 | 6 | require_once "functions.php"; |
9a4506c8 | 7 | require_once "config.php"; |
8158c57a | 8 | require_once "db.php"; |
a0111294 | 9 | require_once "db-prefs.php"; |
9a4506c8 | 10 | |
8158c57a | 11 | $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); |
9f311df6 | 12 | |
8158c57a AD |
13 | if (DB_TYPE == "pgsql") { |
14 | pg_query($link, "set client_encoding = 'utf-8'"); | |
ef063748 | 15 | pg_set_client_encoding("UNICODE"); |
8158c57a | 16 | } |
9a4506c8 | 17 | |
4e9f5c24 AD |
18 | login_sequence($link); |
19 | ||
20 | $owner_uid = $_SESSION["uid"]; | |
21 | ||
579bf16e | 22 | function opml_export($link, $owner_uid) { |
12ec37f3 | 23 | header("Content-type: application/xml+opml"); |
71d56c50 | 24 | print "<?xml version=\"1.0\"?>"; |
4e9f5c24 | 25 | |
9a4506c8 | 26 | print "<opml version=\"1.0\">"; |
a90005e6 AD |
27 | print "<head> |
28 | <dateCreated>" . date("r", time()) . "</dateCreated> | |
29 | <title>Tiny Tiny RSS Feed Export</title> | |
30 | </head>"; | |
9a4506c8 AD |
31 | print "<body>"; |
32 | ||
da49ccf5 AD |
33 | $cat_mode = false; |
34 | ||
35 | if (get_pref($link, 'ENABLE_FEED_CATS')) { | |
36 | $cat_mode = true; | |
37 | $result = db_query($link, "SELECT | |
fa7b8749 | 38 | title,feed_url,site_url, |
18d37445 AD |
39 | (SELECT title FROM ttrss_feed_categories WHERE id = cat_id) as cat_title |
40 | FROM ttrss_feeds | |
bc15240d AD |
41 | WHERE |
42 | owner_uid = '$owner_uid' | |
18d37445 | 43 | ORDER BY cat_title,title"); |
da49ccf5 AD |
44 | } else { |
45 | $result = db_query($link, "SELECT * FROM ttrss_feeds | |
2513ae2b | 46 | WHERE owner_uid = '$owner_uid' ORDER BY title"); |
da49ccf5 AD |
47 | } |
48 | ||
49 | $old_cat_title = ""; | |
9a4506c8 | 50 | |
8158c57a | 51 | while ($line = db_fetch_assoc($result)) { |
6e0584e9 AD |
52 | $title = htmlspecialchars($line["title"]); |
53 | $url = htmlspecialchars($line["feed_url"]); | |
fa7b8749 | 54 | $site_url = htmlspecialchars($line["site_url"]); |
9a4506c8 | 55 | |
da49ccf5 AD |
56 | if ($cat_mode) { |
57 | $cat_title = htmlspecialchars($line["cat_title"]); | |
58 | ||
59 | if ($old_cat_title != $cat_title) { | |
60 | if ($old_cat_title) { | |
5b9af2b9 | 61 | print "</outline>\n"; |
da49ccf5 AD |
62 | } |
63 | ||
5b9af2b9 AD |
64 | if ($cat_title) { |
65 | print "<outline title=\"$cat_title\">\n"; | |
66 | } | |
da49ccf5 AD |
67 | |
68 | $old_cat_title = $cat_title; | |
69 | } | |
70 | } | |
71 | ||
fa7b8749 AD |
72 | if ($site_url) { |
73 | $html_url_qpart = "htmlUrl=\"$site_url\""; | |
74 | } else { | |
75 | $html_url_qpart = ""; | |
76 | } | |
77 | ||
78 | print "<outline text=\"$title\" xmlUrl=\"$url\" $html_url_qpart/>\n"; | |
9a4506c8 AD |
79 | } |
80 | ||
da49ccf5 | 81 | if ($cat_mode && $old_cat_title) { |
5b9af2b9 | 82 | print "</outline>\n"; |
da49ccf5 AD |
83 | } |
84 | ||
9a4506c8 AD |
85 | print "</body></opml>"; |
86 | } | |
87 | ||
30f782a2 AD |
88 | // FIXME there are some brackets issues here |
89 | ||
90 | $op = $_REQUEST["op"]; | |
91 | ||
92 | if (!$op) $op = "Export"; | |
93 | ||
94 | if ($op == "Export") { | |
579bf16e | 95 | return opml_export($link, $owner_uid); |
30f782a2 AD |
96 | } |
97 | ||
e98a3f65 | 98 | if ($op == "Import") { |
8158c57a | 99 | |
e98a3f65 AD |
100 | print "<html> |
101 | <head> | |
ef59e6e8 | 102 | <link rel=\"stylesheet\" href=\"utility.css\" type=\"text/css\"> |
1025ad87 | 103 | <title>".__("OPML Utility")."</title> |
e98a3f65 | 104 | </head> |
04f6df27 | 105 | <body> |
ef59e6e8 | 106 | <div class=\"floatingLogo\"><img src=\"images/ttrss_logo.png\"></div> |
d1db26aa | 107 | <h1>".__('OPML Utility')."</h1>"; |
9f311df6 | 108 | |
30f782a2 | 109 | if (function_exists('domxml_open_file')) { |
06719138 | 110 | print "<p>".__("Importing OPML (using DOMXML extension)...")."</p>"; |
30f782a2 AD |
111 | require_once "modules/opml_domxml.php"; |
112 | opml_import_domxml($link, $owner_uid); | |
e98a3f65 | 113 | } else { |
06719138 | 114 | print "<p>".__("Importing OPML (using DOMDocument extension)...")."</p>"; |
30f782a2 AD |
115 | require_once "modules/opml_domdoc.php"; |
116 | opml_import_domdoc($link, $owner_uid); | |
9f311df6 AD |
117 | } |
118 | ||
d7c848d9 | 119 | print "<br><form method=\"GET\" action=\"prefs.php\"> |
1025ad87 | 120 | <input type=\"submit\" value=\"".__("Return to preferences")."\"> |
d7c848d9 | 121 | </form>"; |
9f311df6 | 122 | |
30f782a2 | 123 | print "</body></html>"; |
9f311df6 AD |
124 | |
125 | } | |
126 | ||
3d477c2c | 127 | // if ($link) db_close($link); |
9f311df6 | 128 | |
9a4506c8 | 129 | ?> |