xml-export: improved interface, fixes
This commit is contained in:
parent
8fd0c7173c
commit
618f424e8f
|
@ -7,11 +7,26 @@
|
||||||
require_once "functions.php";
|
require_once "functions.php";
|
||||||
require_once "db.php";
|
require_once "db.php";
|
||||||
|
|
||||||
define('SCHEMA_VERSION', 1);
|
if ($_GET["export"]) {
|
||||||
|
|
||||||
header("Content-Type: application/xml");
|
header("Content-Type: application/xml");
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
<? if (!$_GET["export"]) { ?>
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<h1>XML Export</h1>
|
||||||
|
<form method="GET">
|
||||||
|
<input type="checkbox" checked name="marked"> Export only starred<br>
|
||||||
|
<input type="checkbox" name="unread"> Export only unread<br>
|
||||||
|
<p><input type="submit" name="export" value="Export"></p>
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
|
<? } else { ?>
|
||||||
|
|
||||||
<xmldb>
|
<xmldb>
|
||||||
|
|
||||||
<?
|
<?
|
||||||
|
@ -33,20 +48,34 @@
|
||||||
|
|
||||||
$schema_version = db_fetch_result($result, 0, "schema_version");
|
$schema_version = db_fetch_result($result, 0, "schema_version");
|
||||||
|
|
||||||
if ($schema_version != SCHEMA_VERSION) {
|
/* if ($schema_version != SCHEMA_VERSION) {
|
||||||
print "<error>Source database schema is invalid
|
print "<error>Source database schema is invalid
|
||||||
(got version $schema_version; expected ".SCHEMA_VERSION.")</error>";
|
(got version $schema_version; expected ".SCHEMA_VERSION.")</error>";
|
||||||
print "</xmldb>";
|
print "</xmldb>";
|
||||||
return;
|
return;
|
||||||
}
|
} */
|
||||||
|
|
||||||
print "<schema_version>$schema_version</schema_version>";
|
print "<schema_version>$schema_version</schema_version>";
|
||||||
|
|
||||||
|
if ($schema_version > 1) {
|
||||||
|
$owner_uid = $_SESSION["uid"];
|
||||||
|
print "<owner_uid>$owner_uid</owner_uid>";
|
||||||
|
}
|
||||||
|
|
||||||
|
print "<exported>" . time() . "</exported>";
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<articles>
|
|
||||||
|
|
||||||
<?
|
<?
|
||||||
|
if ($_GET["marked"]) {
|
||||||
|
$marked_qpart = "AND marked = true";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_GET["unread"]) {
|
||||||
|
$unread_qpart = "AND unread = true";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($schema_version == 1) {
|
||||||
|
|
||||||
$result = db_query($link, "SELECT
|
$result = db_query($link, "SELECT
|
||||||
ttrss_entries.title AS title,
|
ttrss_entries.title AS title,
|
||||||
content,
|
content,
|
||||||
|
@ -63,13 +92,52 @@
|
||||||
FROM
|
FROM
|
||||||
ttrss_entries,ttrss_feeds
|
ttrss_entries,ttrss_feeds
|
||||||
WHERE
|
WHERE
|
||||||
feed_id = ttrss_feeds.id AND marked = true");
|
feed_id = ttrss_feeds.id $marked_qpart $unread_qpart");
|
||||||
|
|
||||||
|
} else if ($schema_version == 2) {
|
||||||
|
|
||||||
|
$result = db_query($link, "SELECT
|
||||||
|
ttrss_entries.title AS title,
|
||||||
|
content,
|
||||||
|
marked,
|
||||||
|
unread,
|
||||||
|
updated,
|
||||||
|
guid,
|
||||||
|
link,
|
||||||
|
date_entered,
|
||||||
|
last_read,
|
||||||
|
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
|
||||||
|
feed_id = ttrss_feeds.id $marked_qpart $unread_qpart");
|
||||||
|
|
||||||
|
} 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>
|
||||||
|
|
||||||
|
<?
|
||||||
while ($line = db_fetch_assoc($result)) {
|
while ($line = db_fetch_assoc($result)) {
|
||||||
print "<article>";
|
print "<article>";
|
||||||
|
|
||||||
foreach (array_keys($line) as $key) {
|
foreach (array_keys($line) as $key) {
|
||||||
|
$line[$key] = str_replace("<![CDATA[", "", $line[$key]);
|
||||||
|
$line[$key] = str_replace("]]>", "", $line[$key]);
|
||||||
|
|
||||||
print "<$key><![CDATA[".$line[$key]."]]></$key>";
|
print "<$key><![CDATA[".$line[$key]."]]></$key>";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -81,3 +149,5 @@
|
||||||
</articles>
|
</articles>
|
||||||
|
|
||||||
</xmldb>
|
</xmldb>
|
||||||
|
|
||||||
|
<? } ?>
|
||||||
|
|
Loading…
Reference in New Issue