]>
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) { | |
37 | print "Error: database schema is invalid | |
38 | (got version $schema_version; expected ".SCHEMA_VERSION.")"; | |
39 | return; | |
40 | } | |
41 | ||
42 | print "<schema_version>$schema_version</schema_version>"; | |
43 | ||
44 | ?> | |
45 | ||
46 | <articles> | |
47 | ||
48 | <? | |
49 | $result = db_query($link, "SELECT | |
50 | ttrss_entries.title AS title, | |
51 | content, | |
52 | marked, | |
53 | unread, | |
54 | updated, | |
55 | guid, | |
56 | link, | |
57 | date_entered, | |
58 | last_read, | |
59 | comments, | |
60 | ttrss_feeds.feed_url AS feed_url, | |
61 | ttrss_feeds.title AS feed_title | |
62 | FROM | |
63 | ttrss_entries,ttrss_feeds | |
64 | WHERE | |
65 | feed_id = ttrss_feeds.id AND marked = true"); | |
66 | ||
67 | ||
68 | while ($line = db_fetch_assoc($result)) { | |
69 | print "<article>"; | |
70 | ||
71 | foreach (array_keys($line) as $key) { | |
72 | print "<$key><![CDATA[".$line[$key]."]]></$key>"; | |
73 | ||
74 | } | |
75 | ||
76 | print "</article>"; | |
77 | } | |
78 | ||
79 | ?> | |
80 | </articles> | |
81 | ||
82 | </xmldb> |