2005-11-30 08:05:43 +00:00
|
|
|
<?
|
2006-03-02 08:10:43 +00:00
|
|
|
require_once "sessions.php";
|
2005-12-07 12:50:16 +00:00
|
|
|
|
2006-02-12 10:20:22 +00:00
|
|
|
define('MAX_SCHEMA_VERSION', 5);
|
2005-12-29 18:06:23 +00:00
|
|
|
|
2005-11-30 08:05:43 +00:00
|
|
|
require_once "config.php";
|
|
|
|
require_once "functions.php";
|
|
|
|
require_once "db.php";
|
|
|
|
|
2005-11-30 14:22:05 +00:00
|
|
|
if ($_GET["export"]) {
|
|
|
|
header("Content-Type: application/xml");
|
|
|
|
}
|
2006-02-12 10:20:22 +00:00
|
|
|
|
|
|
|
$link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
|
|
|
|
|
|
|
|
if (!$link) {
|
|
|
|
if (DB_TYPE == "mysql") {
|
|
|
|
print mysql_error();
|
|
|
|
}
|
|
|
|
// PG seems to display its own errors just fine by default.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (DB_TYPE == "pgsql") {
|
|
|
|
pg_query("set client_encoding = 'utf-8'");
|
|
|
|
}
|
|
|
|
|
|
|
|
$result = db_query($link, "SELECT schema_version FROM ttrss_version");
|
|
|
|
|
|
|
|
$schema_version = db_fetch_result($result, 0, "schema_version");
|
|
|
|
|
|
|
|
if ($schema_version > 1) login_sequence($link);
|
|
|
|
|
2005-11-30 08:05:43 +00:00
|
|
|
?>
|
|
|
|
|
2005-11-30 14:22:05 +00:00
|
|
|
<? if (!$_GET["export"]) { ?>
|
|
|
|
|
|
|
|
<html>
|
2005-12-02 08:19:14 +00:00
|
|
|
<head>
|
|
|
|
<title>XML Export</title>
|
|
|
|
<link rel="stylesheet" href="opml.css" type="text/css">
|
|
|
|
</head>
|
2005-11-30 14:22:05 +00:00
|
|
|
<body>
|
2005-12-02 08:19:14 +00:00
|
|
|
<h1><img src="images/ttrss_logo.png"></h1>
|
|
|
|
|
|
|
|
<div class="opmlBody">
|
|
|
|
<h2>XML Export</h2>
|
|
|
|
<form method="GET">
|
|
|
|
Limit to: <input type="checkbox" checked name="marked"> starred,
|
|
|
|
<input type="checkbox" name="unread"> unread.<br>
|
|
|
|
<p><input type="submit" class="button" name="export" value="Export"></p>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
|
2005-11-30 14:22:05 +00:00
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|
|
|
|
<? } else { ?>
|
|
|
|
|
2005-11-30 08:05:43 +00:00
|
|
|
<xmldb>
|
|
|
|
|
|
|
|
<?
|
|
|
|
|
2005-11-30 14:22:05 +00:00
|
|
|
/* if ($schema_version != SCHEMA_VERSION) {
|
2005-11-30 08:36:54 +00:00
|
|
|
print "<error>Source database schema is invalid
|
|
|
|
(got version $schema_version; expected ".SCHEMA_VERSION.")</error>";
|
|
|
|
print "</xmldb>";
|
2005-11-30 08:05:43 +00:00
|
|
|
return;
|
2005-11-30 14:22:05 +00:00
|
|
|
} */
|
2005-11-30 08:05:43 +00:00
|
|
|
|
|
|
|
print "<schema_version>$schema_version</schema_version>";
|
|
|
|
|
2005-12-29 18:08:12 +00:00
|
|
|
if ($schema_version > 1) {
|
2005-11-30 14:22:05 +00:00
|
|
|
$owner_uid = $_SESSION["uid"];
|
|
|
|
print "<owner_uid>$owner_uid</owner_uid>";
|
|
|
|
}
|
2005-11-30 08:05:43 +00:00
|
|
|
|
2005-11-30 14:22:05 +00:00
|
|
|
print "<exported>" . time() . "</exported>";
|
|
|
|
?>
|
2005-11-30 08:05:43 +00:00
|
|
|
|
|
|
|
<?
|
2005-11-30 14:22:05 +00:00
|
|
|
if ($_GET["marked"]) {
|
|
|
|
$marked_qpart = "AND marked = true";
|
|
|
|
}
|
2005-11-30 08:05:43 +00:00
|
|
|
|
2005-11-30 14:22:05 +00:00
|
|
|
if ($_GET["unread"]) {
|
|
|
|
$unread_qpart = "AND unread = true";
|
|
|
|
}
|
2005-11-30 08:05:43 +00:00
|
|
|
|
2005-11-30 14:22:05 +00:00
|
|
|
if ($schema_version == 1) {
|
|
|
|
|
|
|
|
$result = db_query($link, "SELECT
|
|
|
|
ttrss_entries.title AS title,
|
|
|
|
content,
|
|
|
|
marked,
|
|
|
|
unread,
|
|
|
|
updated,
|
|
|
|
guid,
|
|
|
|
link,
|
2005-12-02 08:33:03 +00:00
|
|
|
SUBSTRING(date_entered,1,16) AS date_entered,
|
|
|
|
SUBSTRING(last_read,1,16) AS last_read,
|
2005-11-30 14:22:05 +00:00
|
|
|
comments,
|
|
|
|
ttrss_feeds.feed_url AS feed_url,
|
|
|
|
ttrss_feeds.title AS feed_title
|
|
|
|
FROM
|
|
|
|
ttrss_entries,ttrss_feeds
|
|
|
|
WHERE
|
2005-12-02 08:33:03 +00:00
|
|
|
feed_id = ttrss_feeds.id $marked_qpart $unread_qpart
|
|
|
|
ORDER BY ttrss_entries.id");
|
2005-11-30 14:22:05 +00:00
|
|
|
|
2005-12-29 18:08:12 +00:00
|
|
|
} else if ($schema_version >= 2 && $schema_version <= MAX_SCHEMA_VERSION) {
|
2005-11-30 14:22:05 +00:00
|
|
|
|
|
|
|
$result = db_query($link, "SELECT
|
|
|
|
ttrss_entries.title AS title,
|
|
|
|
content,
|
|
|
|
marked,
|
|
|
|
unread,
|
|
|
|
updated,
|
|
|
|
guid,
|
|
|
|
link,
|
2005-12-02 08:33:03 +00:00
|
|
|
SUBSTRING(date_entered,1,16) AS date_entered,
|
|
|
|
SUBSTRING(last_read,1,16) AS last_read,
|
2005-11-30 14:22:05 +00:00
|
|
|
comments,
|
|
|
|
ttrss_feeds.feed_url AS feed_url,
|
|
|
|
ttrss_feeds.title AS feed_title
|
|
|
|
FROM
|
|
|
|
ttrss_entries,ttrss_feeds,ttrss_user_entries
|
|
|
|
WHERE
|
|
|
|
ttrss_user_entries.owner_uid = '$owner_uid' AND
|
|
|
|
ref_id = ttrss_entries.id AND
|
2005-12-02 08:33:03 +00:00
|
|
|
feed_id = ttrss_feeds.id $marked_qpart $unread_qpart
|
|
|
|
ORDER BY ttrss_entries.id");
|
2005-11-30 14:22:05 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// BAD SCHEMA, NO COOKIE
|
|
|
|
|
|
|
|
print "<error>Source database schema is invalid
|
|
|
|
(got version $schema_version)</error>";
|
|
|
|
}
|
|
|
|
|
|
|
|
print "<total_articles>" . db_num_rows($result) . "</total_articles>";
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
<articles>
|
|
|
|
|
|
|
|
<?
|
2005-11-30 08:05:43 +00:00
|
|
|
while ($line = db_fetch_assoc($result)) {
|
|
|
|
print "<article>";
|
|
|
|
|
|
|
|
foreach (array_keys($line) as $key) {
|
2005-11-30 14:22:05 +00:00
|
|
|
$line[$key] = str_replace("<![CDATA[", "", $line[$key]);
|
|
|
|
$line[$key] = str_replace("]]>", "", $line[$key]);
|
|
|
|
|
2005-11-30 08:05:43 +00:00
|
|
|
print "<$key><![CDATA[".$line[$key]."]]></$key>";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
print "</article>";
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
|
|
|
</articles>
|
|
|
|
|
|
|
|
</xmldb>
|
2005-11-30 14:22:05 +00:00
|
|
|
|
|
|
|
<? } ?>
|