]>
Commit | Line | Data |
---|---|---|
97aba8ec AD |
1 | <? |
2 | /* | |
3 | Exports your starred articles in schema-neutral XML format. | |
4 | */ | |
5 | ||
6 | require_once "config.php"; | |
7 | require_once "functions.php"; | |
8 | require_once "db.php"; | |
9 | ||
10 | define('SCHEMA_VERSION', 1); | |
11 | ||
12 | header("Content-Type: application/xml"); | |
13 | ?> | |
14 | ||
15 | <xmldb> | |
16 | ||
17 | <? | |
18 | $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); | |
19 | ||
20 | if (!$link) { | |
21 | if (DB_TYPE == "mysql") { | |
22 | print mysql_error(); | |
23 | } | |
24 | // PG seems to display its own errors just fine by default. | |
25 | return; | |
26 | } | |
27 | ||
28 | if (DB_TYPE == "pgsql") { | |
29 | pg_query("set client_encoding = 'utf-8'"); | |
30 | } | |
31 | ||
32 | $result = db_query($link, "SELECT schema_version FROM ttrss_version"); | |
33 | ||
34 | $schema_version = db_fetch_result($result, 0, "schema_version"); | |
35 | ||
36 | if ($schema_version != SCHEMA_VERSION) { | |
ebb510ce AD |
37 | print "<error>Source database schema is invalid |
38 | (got version $schema_version; expected ".SCHEMA_VERSION.")</error>"; | |
39 | print "</xmldb>"; | |
97aba8ec AD |
40 | return; |
41 | } | |
42 | ||
43 | print "<schema_version>$schema_version</schema_version>"; | |
44 | ||
45 | ?> | |
46 | ||
47 | <articles> | |
48 | ||
49 | <? | |
50 | $result = db_query($link, "SELECT | |
51 | ttrss_entries.title AS title, | |
52 | content, | |
53 | marked, | |
54 | unread, | |
55 | updated, | |
56 | guid, | |
57 | link, | |
58 | date_entered, | |
59 | last_read, | |
60 | comments, | |
61 | ttrss_feeds.feed_url AS feed_url, | |
62 | ttrss_feeds.title AS feed_title | |
63 | FROM | |
64 | ttrss_entries,ttrss_feeds | |
65 | WHERE | |
66 | feed_id = ttrss_feeds.id AND marked = true"); | |
67 | ||
68 | ||
69 | while ($line = db_fetch_assoc($result)) { | |
70 | print "<article>"; | |
71 | ||
72 | foreach (array_keys($line) as $key) { | |
73 | print "<$key><![CDATA[".$line[$key]."]]></$key>"; | |
74 | ||
75 | } | |
76 | ||
77 | print "</article>"; | |
78 | } | |
79 | ||
80 | ?> | |
81 | </articles> | |
82 | ||
83 | </xmldb> |