-<?
- // FIXME there are some brackets issues here
+<?php
+ set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR .
+ get_include_path());
- $op = $_GET["op"];
- if ($op == "export") {
- header("Content-type: application/xml");
- }
-
- require_once "config.php";
+ require_once "autoload.php";
require_once "functions.php";
+ require_once "sessions.php";
+ require_once "sanity_check.php";
+ require_once "config.php";
+ require_once "db.php";
+ require_once "db-prefs.php";
- $link = pg_connect(DB_CONN);
-
- pg_query($link, "set client_encoding = 'utf-8'");
+ if (!init_plugins()) return;
- if ($op == "export") {
- print "<?xml version=\"1.0\"?>";
- print "<opml version=\"1.0\">";
- print "<head><dateCreated>" . date("r", time()) . "</dateCreated></head>";
- print "<body>";
+ $op = $_REQUEST['op'];
- $result = pg_query("SELECT * FROM ttrss_feeds ORDER BY title");
+ if ($op == "publish"){
+ $key = $_REQUEST["key"];
+ $pdo = Db::pdo();
- while ($line = pg_fetch_assoc($result)) {
- $title = $line["title"];
- $url = $line["feed_url"];
+ $sth = $pdo->prepare( "SELECT owner_uid
+ FROM ttrss_access_keys WHERE
+ access_key = ? AND feed_id = 'OPML:Publish'");
+ $sth->execute([$key]);
- print "<outline text=\"$title\" xmlUrl=\"$url\"/>";
- }
+ if ($row = $sth->fetch()) {
+ $owner_uid = $row['owner_uid'];
+
+ $opml = new Opml($_REQUEST);
+ $opml->opml_export("", $owner_uid, true, false);
- print "</body></opml>";
+ } else {
+ print "<error>User not found</error>";
+ }
}
?>