$link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
- if (DB_TYPE == "pgsql") {
- pg_query($link, "set client_encoding = 'utf-8'");
- pg_set_client_encoding("UNICODE");
- }
-
+ init_connection($link);
login_sequence($link);
$owner_uid = $_SESSION["uid"];
function opml_export($link, $owner_uid) {
header("Content-type: application/xml+opml");
- print "<?xml version=\"1.0\"?>";
+ print "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
print "<opml version=\"1.0\">";
print "<head>
<div class=\"floatingLogo\"><img src=\"images/ttrss_logo.png\"></div>
<h1>".__('OPML Utility')."</h1>";
+ db_query($link, "BEGIN");
+
+ /* create Imported feeds category just in case */
+
+ $result = db_query($link, "SELECT id FROM
+ ttrss_feed_categories WHERE title = 'Imported feeds' AND
+ owner_uid = '$owner_uid' LIMIT 1");
+
+ if (db_num_rows($result) == 0) {
+ db_query($link, "INSERT INTO ttrss_feed_categories
+ (title,owner_uid)
+ VALUES ('Imported feeds', '$owner_uid')");
+ }
+
+ db_query($link, "COMMIT");
+
+ /* Handle OPML import by DOMXML/DOMDocument */
+
if (function_exists('domxml_open_file')) {
print "<p>".__("Importing OPML (using DOMXML extension)...")."</p>";
require_once "modules/opml_domxml.php";
opml_import_domxml($link, $owner_uid);
- } else {
+ } else if (PHP_VERSION >= 5) {
print "<p>".__("Importing OPML (using DOMDocument extension)...")."</p>";
require_once "modules/opml_domdoc.php";
opml_import_domdoc($link, $owner_uid);
+ } else {
+ print_error(__("DOMXML extension is not found. It is required for PHP versions below 5."));
}
print "<br><form method=\"GET\" action=\"prefs.php\">