| 1 |
<?php |
|---|
| 2 |
error_reporting(E_ERROR | E_WARNING | E_PARSE); |
|---|
| 3 |
|
|---|
| 4 |
require_once "sessions.php"; |
|---|
| 5 |
require_once "sanity_check.php"; |
|---|
| 6 |
require_once "functions.php"; |
|---|
| 7 |
require_once "config.php"; |
|---|
| 8 |
require_once "db.php"; |
|---|
| 9 |
require_once "db-prefs.php"; |
|---|
| 10 |
|
|---|
| 11 |
$link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); |
|---|
| 12 |
|
|---|
| 13 |
if (DB_TYPE == "pgsql") { |
|---|
| 14 |
pg_query($link, "set client_encoding = 'utf-8'"); |
|---|
| 15 |
pg_set_client_encoding("UNICODE"); |
|---|
| 16 |
} else { |
|---|
| 17 |
if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) { |
|---|
| 18 |
db_query($link, "SET NAMES " . MYSQL_CHARSET); |
|---|
| 19 |
|
|---|
| 20 |
} |
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
login_sequence($link); |
|---|
| 24 |
|
|---|
| 25 |
$owner_uid = $_SESSION["uid"]; |
|---|
| 26 |
|
|---|
| 27 |
opml_export($link, $owner_uid) { |
|---|
| 28 |
header("Content-type: application/xml+opml"); |
|---|
| 29 |
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"; |
|---|
| 30 |
|
|---|
| 31 |
"<opml version=\"1.0\">"; |
|---|
| 32 |
"<head> |
|---|
| 33 |
. date("r", time()) . "</dateCreated> |
|---|
| 34 |
|
|---|
| 35 |
; |
|---|
| 36 |
"<body>"; |
|---|
| 37 |
|
|---|
| 38 |
$cat_mode = false; |
|---|
| 39 |
|
|---|
| 40 |
get_pref($link, 'ENABLE_FEED_CATS')) { |
|---|
| 41 |
$cat_mode = true; |
|---|
| 42 |
$result = db_query($link, "SELECT |
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
); |
|---|
| 49 |
|
|---|
| 50 |
$result = db_query($link, "SELECT * FROM ttrss_feeds |
|---|
| 51 |
); |
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
$old_cat_title = ""; |
|---|
| 55 |
|
|---|
| 56 |
$line = db_fetch_assoc($result)) { |
|---|
| 57 |
$title = htmlspecialchars($line["title"]); |
|---|
| 58 |
$url = htmlspecialchars($line["feed_url"]); |
|---|
| 59 |
$site_url = htmlspecialchars($line["site_url"]); |
|---|
| 60 |
|
|---|
| 61 |
$cat_mode) { |
|---|
| 62 |
$cat_title = htmlspecialchars($line["cat_title"]); |
|---|
| 63 |
|
|---|
| 64 |
$old_cat_title != $cat_title) { |
|---|
| 65 |
$old_cat_title) { |
|---|
| 66 |
"</outline>\n"; |
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
$cat_title) { |
|---|
| 70 |
"<outline title=\"$cat_title\">\n"; |
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
$old_cat_title = $cat_title; |
|---|
| 74 |
|
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 |
$site_url) { |
|---|
| 78 |
$html_url_qpart = "htmlUrl=\"$site_url\""; |
|---|
| 79 |
|
|---|
| 80 |
$html_url_qpart = ""; |
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
"<outline text=\"$title\" xmlUrl=\"$url\" $html_url_qpart/>\n"; |
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 |
$cat_mode && $old_cat_title) { |
|---|
| 87 |
"</outline>\n"; |
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
"</body></opml>"; |
|---|
| 91 |
|
|---|
| 92 |
|
|---|
| 93 |
|
|---|
| 94 |
|
|---|
| 95 |
$op = $_REQUEST["op"]; |
|---|
| 96 |
|
|---|
| 97 |
$op) $op = "Export"; |
|---|
| 98 |
|
|---|
| 99 |
$op == "Export") { |
|---|
| 100 |
opml_export($link, $owner_uid); |
|---|
| 101 |
|
|---|
| 102 |
|
|---|
| 103 |
$op == "Import") { |
|---|
| 104 |
|
|---|
| 105 |
"<html> |
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 |
.__("OPML Utility")."</title> |
|---|
| 109 |
|
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
.__('OPML Utility')."</h1>"; |
|---|
| 113 |
|
|---|
| 114 |
db_query($link, "BEGIN"); |
|---|
| 115 |
|
|---|
| 116 |
|
|---|
| 117 |
|
|---|
| 118 |
$result = db_query($link, "SELECT id FROM |
|---|
| 119 |
|
|---|
| 120 |
); |
|---|
| 121 |
|
|---|
| 122 |
db_num_rows($result) == 0) { |
|---|
| 123 |
db_query($link, "INSERT INTO ttrss_feed_categories |
|---|
| 124 |
|
|---|
| 125 |
); |
|---|
| 126 |
|
|---|
| 127 |
|
|---|
| 128 |
db_query($link, "COMMIT"); |
|---|
| 129 |
|
|---|
| 130 |
|
|---|
| 131 |
|
|---|
| 132 |
if (function_exists('domxml_open_file')) { |
|---|
| 133 |
"<p>".__("Importing OPML (using DOMXML extension)...")."</p>"; |
|---|
| 134 |
"modules/opml_domxml.php"; |
|---|
| 135 |
opml_import_domxml($link, $owner_uid); |
|---|
| 136 |
PHP_VERSION >= 5) { |
|---|
| 137 |
"<p>".__("Importing OPML (using DOMDocument extension)...")."</p>"; |
|---|
| 138 |
"modules/opml_domdoc.php"; |
|---|
| 139 |
opml_import_domdoc($link, $owner_uid); |
|---|
| 140 |
|
|---|
| 141 |
print_error(__("DOMXML extension is not found. It is required for PHP versions below 5.")); |
|---|
| 142 |
|
|---|
| 143 |
|
|---|
| 144 |
"<br><form method=\"GET\" action=\"prefs.php\"> |
|---|
| 145 |
.__("Return to preferences")."\"> |
|---|
| 146 |
; |
|---|
| 147 |
|
|---|
| 148 |
"</body></html>"; |
|---|
| 149 |
|
|---|
| 150 |
|
|---|
| 151 |
|
|---|
| 152 |
|
|---|
| 153 |
|
|---|
| 154 |
?> |
|---|
| 155 |
|
|---|