示例#1
0
 function importOpml()
 {
     header("Content-Type: text/html");
     # required for iframe
     print __("If you have imported labels and/or filters, you might need to reload preferences to see your new data.") . "</p>";
     print "<div class=\"prefFeedOPMLHolder\">";
     $owner_uid = $_SESSION["uid"];
     db_query($this->link, "BEGIN");
     print "<ul class='nomarks'>";
     $opml = new Opml($this->link, $_REQUEST);
     $opml->opml_import($_SESSION["uid"]);
     print "</ul>";
     print "</div>";
     print "<div align='center'>";
     print "<button dojoType=\"dijit.form.Button\"\n\t\t\tonclick=\"dijit.byId('opmlImportDlg').execute()\">" . __('Close this window') . "</button>";
     print "</div>";
     print "</div>";
     //return;
 }
示例#2
0
 function pubOPMLUrl()
 {
     $url_path = Opml::opml_publish_url();
     print __("Your Public OPML URL is:");
     print "<div class=\"tagCloudContainer\">";
     print "<a id='pub_opml_url' href='{$url_path}' target='_blank'>{$url_path}</a>";
     print "</div>";
     print "<div align='center'>";
     print "<button dojoType=\"dijit.form.Button\" onclick=\"return opmlRegenKey()\">" . __('Generate new URL') . "</button> ";
     print "<button dojoType=\"dijit.form.Button\" onclick=\"return closeInfoBox()\">" . __('Close this window') . "</button>";
     print "</div>";
     //return;
 }
示例#3
0
文件: feeds.php 项目: AHinMaine/ttrss
 function regenOPMLKey()
 {
     $this->update_feed_access_key('OPML:Publish', false, $_SESSION["uid"]);
     $new_link = Opml::opml_publish_url();
     print json_encode(array("link" => $new_link));
 }
示例#4
0
 /**
  * Convert opml array into more convenient array with xmlUrl as key
  *
  * @param array $array       Array obtained from Opml file
  * @param array $listFolders List of current folders
  *
  * @return array             New formated array
  */
 public static function convertOpmlArray($array, $listFolders = array())
 {
     $newArray = array();
     for ($i = 0, $len = count($array); $i < $len; $i++) {
         if (isset($array[$i]['outline']) && (isset($array[$i]['text']) || isset($array[$i]['title']))) {
             // here is a folder
             if (isset($array[$i]['text'])) {
                 $listFolders[] = $array[$i]['text'];
             } else {
                 $listFolders[] = $array[$i]['title'];
             }
             $newArray = array_merge($newArray, Opml::convertOpmlArray($array[$i]['outline'], $listFolders));
             array_pop($listFolders);
         } else {
             if (isset($array[$i]['xmlUrl'])) {
                 // here is a feed
                 $xmlUrl = MyTool::smallHash($array[$i]['xmlUrl']);
                 if (isset($newArray[$xmlUrl])) {
                     //feed already exists
                     foreach ($listFolders as $val) {
                         // add folder to the feed
                         if (!in_array($val, $newArray[$xmlUrl]['folders'])) {
                             $newArray[$xmlUrl]['folders'][] = $val;
                         }
                     }
                 } else {
                     // here is a new feed
                     foreach ($array[$i] as $attr => $val) {
                         $newArray[$xmlUrl][$attr] = $val;
                     }
                     $newArray[$xmlUrl]['folders'] = $listFolders;
                 }
             }
         }
     }
     return $newArray;
 }
示例#5
0
<?php

set_include_path(dirname(__FILE__) . "/include" . PATH_SEPARATOR . get_include_path());
require_once "vendor/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";
if (!init_plugins()) {
    return;
}
$op = $_REQUEST['op'];
if ($op == "publish") {
    $key = db_escape_string($_REQUEST["key"]);
    $result = db_query("SELECT owner_uid\n        FROM ttrss_access_keys WHERE\n        access_key = '{$key}' AND feed_id = 'OPML:Publish'");
    if (db_num_rows($result) == 1) {
        $owner_uid = db_fetch_result($result, 0, "owner_uid");
        $opml = new Opml($_REQUEST);
        $opml->opml_export("", $owner_uid, true, false);
    } else {
        print "<error>User not found</error>";
    }
}
示例#6
0
        exit;
    } else {
        if (isset($_POST['cancel'])) {
            MyTool::redirect();
        } else {
            $pb->assign('pagetitle', Intl::msg('Import') . ' - ' . strip_tags($kfc->title));
            $pb->assign('maxsize', MyTool::getMaxFileSize());
            $pb->assign('humanmaxsize', MyTool::humanBytes(MyTool::getMaxFileSize()));
            $pb->assign('token', Session::getToken());
            $pb->renderPage('import');
        }
    }
} elseif (isset($_GET['export']) && $kfc->isLogged()) {
    // Export
    $kf->loadData();
    Opml::exportOpml($kf->getFeeds(), $kf->getFolders());
} elseif (isset($_GET['add']) && $kfc->isLogged()) {
    // Add feed
    $kf->loadData();
    if (isset($_POST['newfeed']) && !empty($_POST['newfeed'])) {
        $addc = $kf->addChannel($_POST['newfeed']);
        if (empty($addc['error'])) {
            // Add success
            $folders = array();
            if (!empty($_POST['folders'])) {
                foreach ($_POST['folders'] as $hashFolder) {
                    $folders[] = $hashFolder;
                }
            }
            if (!empty($_POST['newfolder'])) {
                $newFolderHash = MyTool::smallHash($_POST['newfolder']);
示例#7
0
文件: action.php 项目: Chouchen/Leed
 case 'changeFolderState':
     if ($myUser == false) {
         exit(_t('YOU_MUST_BE_CONNECTED_ACTION'));
     }
     $folderManager->change(array('isopen' => $_['isopen']), array('id' => $_['id']));
     break;
 case 'importFeed':
     // On ne devrait pas mettre de style ici.
     echo "<html>\n            <style>\n                a {\n                    color:#F16529;\n                }\n\n                html,body{\n                        font-family:Verdana;\n                        font-size: 11px;\n                }\n                .error{\n                        background-color:#C94141;\n                        color:#ffffff;\n                        padding:5px;\n                        border-radius:5px;\n                        margin:10px 0px 10px 0px;\n                        box-shadow: 0 0 3px 0 #810000;\n                    }\n                .error a{\n                        color:#ffffff;\n                }\n                </style>\n            </style><body>\n\n";
     if ($myUser == false) {
         exit(_t('YOU_MUST_BE_CONNECTED_ACTION'));
     }
     if (!isset($_POST['importButton'])) {
         break;
     }
     $opml = new Opml();
     echo "<h3>" . _t('IMPORT') . "</h3><p>" . _t('PENDING') . "</p>\n";
     try {
         $errorOutput = $opml->import($_FILES['newImport']['tmp_name']);
     } catch (Exception $e) {
         $errorOutput = array($e->getMessage());
     }
     if (empty($errorOutput)) {
         echo "<p>" . _t('IMPORT_NO_PROBLEM') . "</p>\n";
     } else {
         echo "<div class='error'>" . _t('IMPORT_ERROR') . "\n";
         foreach ($errorOutput as $line) {
             echo "<p>{$line}</p>\n";
         }
         echo "</div>";
     }
示例#8
0
文件: Feed.php 项目: hisaboh/w2t
 /**
  * フィードを取得
  *
  * @param string $src
  * @return Atom
  */
 public static function parse($src)
 {
     try {
         return Atom::parse($src);
     } catch (Exception $e) {
         try {
             return Rss::parse($src)->atom();
         } catch (Exception $e) {
             try {
                 return Opml::parse($src)->atom();
             } catch (Exception $e) {
                 throw new Exception("no feed");
             }
         }
     }
     /***
     			$src = text('
     				<feed xmlns="http://www.w3.org/2005/Atom">
     				<title>atom10 feed</title>
     				<subtitle>atom10 sub title</subtitle>
     				<updated>2007-07-18T16:16:31+00:00</updated>
     				<generator>tokushima</generator>
     				<link href="http://tokushimakazutaka.com" rel="abc" type="xyz" />
     
     				<author>
     					<url>http://tokushimakazutaka.com</url>
     					<name>tokushima</name>
     					<email>tokushima@hoge.hoge</email>
     				</author>
     
     				<entry>
     					<title>rhaco</title>
     					<summary type="xml" xml:lang="ja">summary test</summary>
     					<content type="text/xml" mode="abc" xml:lang="ja" xml:base="base">atom content</content>
     					<link href="http://rhaco.org" rel="abc" type="xyz" />
     					<link href="http://conveyor.rhaco.org" rel="abc" type="conveyor" />
     					<link href="http://lib.rhaco.org" rel="abc" type="lib" />
     
     					<updated>2007-07-18T16:16:31+00:00</updated>
     				 	<issued>2007-07-18T16:16:31+00:00</issued>
     				 	<published>2007-07-18T16:16:31+00:00</published>
     				 	<id>rhaco</id>
     				<author>
     					<url>http://rhaco.org</url>
     					<name>rhaco</name>
     					<email>rhaco@rhaco.org</email>
     				</author>
     				</entry>
     
     				<entry>
     					<title>django</title>
     					<summary type="xml" xml:lang="ja">summary test</summary>
     					<content type="text/xml" mode="abc" xml:lang="ja" xml:base="base">atom content</content>
     					<link href="http://djangoproject.jp" rel="abc" type="xyz" />
     
     				 <updated>2007-07-18T16:16:31+00:00</updated>
     				 <issued>2007-07-18T16:16:31+00:00</issued>
     				 <published>2007-07-18T16:16:31+00:00</published>
     				 <id>django</id>
     				<author>
     					<url>http://www.everes.net</url>
     					<name>everes</name>
     					<email>everes@hoge.hoge</email>
     				</author>
     				</entry>
     
     				</feed>
     			');
     
     			$xml = Feed::parse($src);
     			$result = text('
     							<feed xmlns="http://www.w3.org/2005/Atom">
     							<title>atom10 feed</title>
     							<subtitle>atom10 sub title</subtitle>
     							<id>rhaco</id>
     							<generator>tokushima</generator>
     							<updated>2007-07-18T16:16:31Z</updated>
     							<link rel="abc" type="xyz" href="http://tokushimakazutaka.com" />
     							<entry>
     								<id>rhaco</id>
     								<title>rhaco</title>
     								<published>2007-07-18T16:16:31Z</published>
     								<updated>2007-07-18T16:16:31Z</updated>
     								<issued>2007-07-18T16:16:31Z</issued>
     								<content type="text/xml" mode="abc" xml:lang="ja" xml:base="base">atom content</content>
     								<summary type="xml" xml:lang="ja">summary test</summary>
     								<link rel="abc" type="xyz" href="http://rhaco.org" />
     								<link rel="abc" type="conveyor" href="http://conveyor.rhaco.org" />
     								<link rel="abc" type="lib" href="http://lib.rhaco.org" />
     								<author>
     									<name>rhaco</name>
     									<url>http://rhaco.org</url>
     									<email>rhaco@rhaco.org</email>
     								</author>
     							</entry>
     							<entry>
     								<id>django</id>
     								<title>django</title>
     								<published>2007-07-18T16:16:31Z</published>
     								<updated>2007-07-18T16:16:31Z</updated>
     								<issued>2007-07-18T16:16:31Z</issued>
     								<content type="text/xml" mode="abc" xml:lang="ja" xml:base="base">atom content</content>
     								<summary type="xml" xml:lang="ja">summary test</summary>
     								<link rel="abc" type="xyz" href="http://djangoproject.jp" />
     								<author>
     									<name>everes</name>
     									<url>http://www.everes.net</url>
     									<email>everes@hoge.hoge</email>
     								</author>
     							</entry>
     							<author>
     								<name>tokushima</name>
     								<url>http://tokushimakazutaka.com</url>
     								<email>tokushima@hoge.hoge</email>
     							</author>
     							</feed>
     						');
     			$result = str_replace(array("\n","\t"),"",$result);
     			eq($result,(string)$xml);
     		*/
 }