]> git.wh0rd.org - tt-rss.git/blobdiff - opml.php
add Public_Handler
[tt-rss.git] / opml.php
index 40ea2637a379da8b3580de8e849c68e90c392494..ab71493b1fba3e8690a0e07839b620461ec2164d 100644 (file)
--- a/opml.php
+++ b/opml.php
@@ -1,4 +1,6 @@
 <?php
+       set_include_path(get_include_path() . PATH_SEPARATOR . "include");
+
        require_once "functions.php";
        require_once "sessions.php";
        require_once "sanity_check.php";
 
        $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
 
-       init_connection($link);
+       if (!init_connection($link)) return;
 
-       function opml_export($link, $owner_uid, $hide_private_feeds=false, $include_settings=true) {
+       function opml_export($link, $name, $owner_uid, $hide_private_feeds=false, $include_settings=true) {
                if (!$_REQUEST["debug"]) {
                        header("Content-type: application/xml+opml");
                } else {
                        header("Content-type: text/xml");
                }
+        header("Content-Disposition: attachment; filename=" . $name );
+
                print "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
 
                print "<opml version=\"1.0\">";
        // FIXME there are some brackets issues here
 
        $op = $_REQUEST["op"];
+    if (!$op) $op = "Export";
+
+    $output_name = $_REQUEST["filename"];
+       if (!$output_name) $output_name = "TinyTinyRSS.opml";
 
-       if (!$op) $op = "Export";
+    $show_settings = $_REQUEST["settings"];
 
        if ($op == "Export") {
 
                login_sequence($link);
                $owner_uid = $_SESSION["uid"];
-               return opml_export($link, $owner_uid);
+               return opml_export($link, $output_name, $owner_uid, false, ($show_settings == 1));
        }
 
        if ($op == "publish"){
 
                if (db_num_rows($result) == 1) {
                        $owner_uid = db_fetch_result($result, 0, "owner_uid");
-                       return opml_export($link, $owner_uid, true, false);
+                       return opml_export($link, "", $owner_uid, true, false);
                } else {
                        print "<error>User not found</error>";
                }
                                <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
                        </head>
                        <body>
-                       <div class=\"floatingLogo\"><img src=\"images/logo.png\"></div>
+                       <div class=\"floatingLogo\"><img src=\"images/logo_wide.png\"></div>
                        <h1>".__('OPML Utility')."</h1>";
 
                db_query($link, "BEGIN");