示例#1
0
// FIXME there are some brackets issues here
$op = $_REQUEST["op"];
if (!$op) {
    $op = "Export";
}
if ($op == "Export") {
    login_sequence($link);
    $owner_uid = $_SESSION["uid"];
    return opml_export($link, $owner_uid);
}
if ($op == "publish") {
    $key = db_escape_string($_REQUEST["key"]);
    $result = db_query($link, "SELECT login, owner_uid \n\t\t\t\tFROM ttrss_user_prefs, ttrss_users WHERE\n\t\t\t\tpref_name = '_PREFS_PUBLISH_KEY' AND \n\t\t\t\tvalue = '{$key}' AND \n\t\t\t\tttrss_users.id = owner_uid");
    if (db_num_rows($result) == 1) {
        $owner = db_fetch_result($result, 0, "owner_uid");
        return opml_export($link, $owner, True);
    } else {
        print "<error>User not found</error>";
    }
}
if ($op == "Import") {
    login_sequence($link);
    $owner_uid = $_SESSION["uid"];
    print "<html>\n\t\t\t<head>\n\t\t\t\t<link rel=\"stylesheet\" href=\"utility.css\" type=\"text/css\">\n\t\t\t\t<title>" . __("OPML Utility") . "</title>\n\t\t\t</head>\n\t\t\t<body>\n\t\t\t<div class=\"floatingLogo\"><img src=\"images/ttrss_logo.png\"></div>\n\t\t\t<h1>" . __('OPML Utility') . "</h1>";
    db_query($link, "BEGIN");
    /* create Imported feeds category just in case */
    $result = db_query($link, "SELECT id FROM\n\t\t\tttrss_feed_categories WHERE title = 'Imported feeds' AND\n\t\t\towner_uid = '{$owner_uid}' LIMIT 1");
    if (db_num_rows($result) == 0) {
        db_query($link, "INSERT INTO ttrss_feed_categories\n\t\t\t\t\t(title,owner_uid) \n\t\t\t\t\t\tVALUES ('Imported feeds', '{$owner_uid}')");
    }
    db_query($link, "COMMIT");
示例#2
0
        // TODO
    }
    header('location: settings.php');
    exit;
}
// Handle OPML export
if (isset($_POST['export']) && !empty($_POST['token']) && check_token(600, 'export_form')) {
    $feeds = array();
    foreach ($_POST['export'] as $feed_id) {
        $feeds[] = get_feed($feed_id);
    }
    require_once 'inc/opml.php';
    $now = new DateTime();
    header('Content-disposition: attachment; filename="freeder_export_' . $now->format('d-m-Y_H-i') . '.xml"');
    header('Content-type: "text/xml"; charset="utf8"');
    exit(opml_export($feeds));
}
// Handle OPML import
if (isset($_FILES['import']) && isset($_POST['import_tags_opml']) && !empty($_POST['token']) && check_token(600, 'import_form')) {
    if ($_FILES['import']['error'] > 0) {
        $error = array();
        $error['type'] = 'error';
        $error['title'] = 'OPML import error';
        $error['content'] = '<p>The OPML file could not be imported.</p>';
        $tpl->assign('error', $error, RainTPL::RAINTPL_IGNORE_SANITIZE);
        $tpl->draw('settings');
        exit;
    }
    if ($_FILES['import']['size'] > 1048576) {
        $error = array();
        $error['type'] = 'error';
示例#3
0
$output_name = $_REQUEST["filename"];
if (!$output_name) {
    $output_name = "TinyTinyRSS.opml";
}
$show_settings = $_REQUEST["settings"];
if ($op == "Export") {
    login_sequence($link);
    $owner_uid = $_SESSION["uid"];
    return opml_export($link, $output_name, $owner_uid, false, $show_settings == 1);
}
if ($op == "publish") {
    $key = db_escape_string($_REQUEST["key"]);
    $result = db_query($link, "SELECT owner_uid\n\t\t\t\tFROM ttrss_access_keys WHERE\n\t\t\t\taccess_key = '{$key}' AND feed_id = 'OPML:Publish'");
    if (db_num_rows($result) == 1) {
        $owner_uid = db_fetch_result($result, 0, "owner_uid");
        return opml_export($link, "", $owner_uid, true, false);
    } else {
        print "<error>User not found</error>";
    }
}
if ($op == "Import") {
    login_sequence($link);
    $owner_uid = $_SESSION["uid"];
    header('Content-Type: text/html; charset=utf-8');
    print "<html>\n\t\t\t<head>\n\t\t\t\t<link rel=\"stylesheet\" href=\"utility.css\" type=\"text/css\">\n\t\t\t\t<title>" . __("OPML Utility") . "</title>\n\t\t\t\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\n\t\t\t</head>\n\t\t\t<body>\n\t\t\t<div class=\"floatingLogo\"><img src=\"images/logo_wide.png\"></div>\n\t\t\t<h1>" . __('OPML Utility') . "</h1>";
    db_query($link, "BEGIN");
    /* create Imported feeds category just in case */
    $result = db_query($link, "SELECT id FROM\n\t\t\tttrss_feed_categories WHERE title = 'Imported feeds' AND\n\t\t\towner_uid = '{$owner_uid}' LIMIT 1");
    if (db_num_rows($result) == 0) {
        db_query($link, "INSERT INTO ttrss_feed_categories\n\t\t\t\t\t(title,owner_uid)\n\t\t\t\t\t\tVALUES ('Imported feeds', '{$owner_uid}')");
    }