]> git.wh0rd.org - tt-rss.git/blame - opml.php
fix layout of login form
[tt-rss.git] / opml.php
CommitLineData
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");
70dcff6b 16 } else {
bddc9788
AD
17 if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) {
18 db_query($link, "SET NAMES " . MYSQL_CHARSET);
75ca1986 19// db_query($link, "SET CHARACTER SET " . MYSQL_CHARSET);
bddc9788 20 }
8158c57a 21 }
9a4506c8 22
4e9f5c24
AD
23 login_sequence($link);
24
25 $owner_uid = $_SESSION["uid"];
26
579bf16e 27 function opml_export($link, $owner_uid) {
12ec37f3 28 header("Content-type: application/xml+opml");
981e8107 29 print "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
4e9f5c24 30
9a4506c8 31 print "<opml version=\"1.0\">";
a90005e6
AD
32 print "<head>
33 <dateCreated>" . date("r", time()) . "</dateCreated>
34 <title>Tiny Tiny RSS Feed Export</title>
35 </head>";
9a4506c8
AD
36 print "<body>";
37
da49ccf5
AD
38 $cat_mode = false;
39
40 if (get_pref($link, 'ENABLE_FEED_CATS')) {
41 $cat_mode = true;
42 $result = db_query($link, "SELECT
fa7b8749 43 title,feed_url,site_url,
18d37445
AD
44 (SELECT title FROM ttrss_feed_categories WHERE id = cat_id) as cat_title
45 FROM ttrss_feeds
bc15240d
AD
46 WHERE
47 owner_uid = '$owner_uid'
18d37445 48 ORDER BY cat_title,title");
da49ccf5
AD
49 } else {
50 $result = db_query($link, "SELECT * FROM ttrss_feeds
2513ae2b 51 WHERE owner_uid = '$owner_uid' ORDER BY title");
da49ccf5
AD
52 }
53
54 $old_cat_title = "";
9a4506c8 55
8158c57a 56 while ($line = db_fetch_assoc($result)) {
6e0584e9
AD
57 $title = htmlspecialchars($line["title"]);
58 $url = htmlspecialchars($line["feed_url"]);
fa7b8749 59 $site_url = htmlspecialchars($line["site_url"]);
9a4506c8 60
da49ccf5
AD
61 if ($cat_mode) {
62 $cat_title = htmlspecialchars($line["cat_title"]);
63
64 if ($old_cat_title != $cat_title) {
65 if ($old_cat_title) {
5b9af2b9 66 print "</outline>\n";
da49ccf5
AD
67 }
68
5b9af2b9
AD
69 if ($cat_title) {
70 print "<outline title=\"$cat_title\">\n";
71 }
da49ccf5
AD
72
73 $old_cat_title = $cat_title;
74 }
75 }
76
fa7b8749
AD
77 if ($site_url) {
78 $html_url_qpart = "htmlUrl=\"$site_url\"";
79 } else {
80 $html_url_qpart = "";
81 }
82
83 print "<outline text=\"$title\" xmlUrl=\"$url\" $html_url_qpart/>\n";
9a4506c8
AD
84 }
85
da49ccf5 86 if ($cat_mode && $old_cat_title) {
5b9af2b9 87 print "</outline>\n";
da49ccf5
AD
88 }
89
9a4506c8
AD
90 print "</body></opml>";
91 }
92
30f782a2
AD
93 // FIXME there are some brackets issues here
94
95 $op = $_REQUEST["op"];
96
97 if (!$op) $op = "Export";
98
99 if ($op == "Export") {
579bf16e 100 return opml_export($link, $owner_uid);
30f782a2
AD
101 }
102
e98a3f65 103 if ($op == "Import") {
8158c57a 104
e98a3f65
AD
105 print "<html>
106 <head>
ef59e6e8 107 <link rel=\"stylesheet\" href=\"utility.css\" type=\"text/css\">
1025ad87 108 <title>".__("OPML Utility")."</title>
e98a3f65 109 </head>
04f6df27 110 <body>
ef59e6e8 111 <div class=\"floatingLogo\"><img src=\"images/ttrss_logo.png\"></div>
d1db26aa 112 <h1>".__('OPML Utility')."</h1>";
9f311df6 113
30f782a2 114 if (function_exists('domxml_open_file')) {
06719138 115 print "<p>".__("Importing OPML (using DOMXML extension)...")."</p>";
30f782a2
AD
116 require_once "modules/opml_domxml.php";
117 opml_import_domxml($link, $owner_uid);
5eb66ed7 118 } else if (PHP_VERSION >= 5) {
06719138 119 print "<p>".__("Importing OPML (using DOMDocument extension)...")."</p>";
30f782a2
AD
120 require_once "modules/opml_domdoc.php";
121 opml_import_domdoc($link, $owner_uid);
5eb66ed7
AD
122 } else {
123 print_error(__("DOMXML extension is not found. It is required for PHP versions below 5."));
9f311df6
AD
124 }
125
d7c848d9 126 print "<br><form method=\"GET\" action=\"prefs.php\">
1025ad87 127 <input type=\"submit\" value=\"".__("Return to preferences")."\">
d7c848d9 128 </form>";
9f311df6 129
30f782a2 130 print "</body></html>";
9f311df6
AD
131
132 }
133
3d477c2c 134// if ($link) db_close($link);
9f311df6 135
9a4506c8 136?>