print "<html>
<head>
- <link rel=\"stylesheet\" href=\"utility.css\" type=\"text/css\">
+ <link rel=\"stylesheet\" href=\"css/utility.css\" type=\"text/css\">
<title>".__("OPML Utility")."</title>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
</head>
$html_url_qpart = "";
}
- $out .= "<outline text=\"$title\" xmlUrl=\"$url\" $html_url_qpart/>\n";
+ $out .= "<outline type=\"rss\" text=\"$title\" xmlUrl=\"$url\" $html_url_qpart/>\n";
}
if ($cat_title) $out .= "</outline>\n";
WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY id");
while ($line = $this->dbh->fetch_assoc($result)) {
- foreach (array('enabled', 'match_any_rule') as $b) {
+ foreach (array('enabled', 'match_any_rule', 'inverse') as $b) {
$line[$b] = sql_bool_to_bool($line[$b]);
}
$cat_filter = sql_bool_to_bool($tmp_line["cat_filter"]);
if ($cat_filter && $tmp_line["cat_id"] || $tmp_line["feed_id"]) {
- $tmp_line["feed"] = getFeedTitle(
+ $tmp_line["feed"] = Feeds::getFeedTitle(
$cat_filter ? $tmp_line["cat_id"] : $tmp_line["feed_id"],
$cat_filter);
} else {
}
$tmp_line["cat_filter"] = sql_bool_to_bool($tmp_line["cat_filter"]);
+ $tmp_line["inverse"] = sql_bool_to_bool($tmp_line["inverse"]);
unset($tmp_line["feed_id"]);
unset($tmp_line["cat_id"]);
// Import
- private function opml_import_feed($doc, $node, $cat_id, $owner_uid) {
+ private function opml_import_feed($node, $cat_id, $owner_uid) {
$attrs = $node->attributes;
$feed_title = $this->dbh->escape_string(mb_substr($attrs->getNamedItem('text')->nodeValue, 0, 250));
if (!$feed_title) $feed_title = $this->dbh->escape_string(mb_substr($attrs->getNamedItem('title')->nodeValue, 0, 250));
- $feed_url = $this->dbh->escape_string(mb_substr($attrs->getNamedItem('xmlUrl')->nodeValue, 0, 250));
- if (!$feed_url) $feed_url = $this->dbh->escape_string(mb_substr($attrs->getNamedItem('xmlURL')->nodeValue, 0, 250));
+ $feed_url = $this->dbh->escape_string($attrs->getNamedItem('xmlUrl')->nodeValue);
+ if (!$feed_url) $feed_url = $this->dbh->escape_string($attrs->getNamedItem('xmlURL')->nodeValue);
$site_url = $this->dbh->escape_string(mb_substr($attrs->getNamedItem('htmlUrl')->nodeValue, 0, 250));
}
}
- private function opml_import_label($doc, $node, $owner_uid) {
+ private function opml_import_label($node, $owner_uid) {
$attrs = $node->attributes;
$label_name = $this->dbh->escape_string($attrs->getNamedItem('label-name')->nodeValue);
$fg_color = $this->dbh->escape_string($attrs->getNamedItem('label-fg-color')->nodeValue);
$bg_color = $this->dbh->escape_string($attrs->getNamedItem('label-bg-color')->nodeValue);
- if (!label_find_id($label_name, $_SESSION['uid'])) {
+ if (!Labels::find_id($label_name, $_SESSION['uid'])) {
$this->opml_notice(T_sprintf("Adding label %s", htmlspecialchars($label_name)));
- label_create($label_name, $fg_color, $bg_color, $owner_uid);
+ Labels::create($label_name, $fg_color, $bg_color, $owner_uid);
} else {
$this->opml_notice(T_sprintf("Duplicate label: %s", htmlspecialchars($label_name)));
}
}
}
- private function opml_import_preference($doc, $node, $owner_uid) {
+ private function opml_import_preference($node) {
$attrs = $node->attributes;
$pref_name = $this->dbh->escape_string($attrs->getNamedItem('pref-name')->nodeValue);
}
}
- private function opml_import_filter($doc, $node, $owner_uid) {
+ private function opml_import_filter($node) {
$attrs = $node->attributes;
$filter_type = $this->dbh->escape_string($attrs->getNamedItem('filter-type')->nodeValue);
if ($filter) {
$match_any_rule = bool_to_sql_bool($filter["match_any_rule"]);
$enabled = bool_to_sql_bool($filter["enabled"]);
+ $inverse = bool_to_sql_bool($filter["inverse"]);
+ $title = db_escape_string($filter["title"]);
$this->dbh->query("BEGIN");
- $this->dbh->query("INSERT INTO ttrss_filters2 (match_any_rule,enabled,owner_uid)
- VALUES ($match_any_rule, $enabled,".$_SESSION["uid"].")");
+ $this->dbh->query("INSERT INTO ttrss_filters2 (match_any_rule,enabled,inverse,title,owner_uid)
+ VALUES ($match_any_rule, $enabled, $inverse, '$title',
+ ".$_SESSION["uid"].")");
$result = $this->dbh->query("SELECT MAX(id) AS id FROM ttrss_filters2 WHERE
owner_uid = ".$_SESSION["uid"]);
$cat_filter = bool_to_sql_bool($rule["cat_filter"]);
$reg_exp = $this->dbh->escape_string($rule["reg_exp"]);
$filter_type = (int)$rule["filter_type"];
+ $inverse = bool_to_sql_bool($rule["inverse"]);
- $this->dbh->query("INSERT INTO ttrss_filters2_rules (feed_id,cat_id,filter_id,filter_type,reg_exp,cat_filter)
- VALUES ($feed_id, $cat_id, $filter_id, $filter_type, '$reg_exp', $cat_filter)");
+ $this->dbh->query("INSERT INTO ttrss_filters2_rules (feed_id,cat_id,filter_id,filter_type,reg_exp,cat_filter,inverse)
+ VALUES ($feed_id, $cat_id, $filter_id, $filter_type, '$reg_exp', $cat_filter,$inverse)");
}
foreach ($filter["actions"] as $action) {
}
private function opml_import_category($doc, $root_node, $owner_uid, $parent_id) {
- $body = $doc->getElementsByTagName('body');
-
- $default_cat_id = (int) get_feed_category('Imported feeds', false);
+ $default_cat_id = (int) $this->get_feed_category('Imported feeds', false);
if ($root_node) {
$cat_title = $this->dbh->escape_string(mb_substr($root_node->attributes->getNamedItem('text')->nodeValue, 0, 250));
$cat_title = $this->dbh->escape_string(mb_substr($root_node->attributes->getNamedItem('title')->nodeValue, 0, 250));
if (!in_array($cat_title, array("tt-rss-filters", "tt-rss-labels", "tt-rss-prefs"))) {
- $cat_id = get_feed_category($cat_title, $parent_id);
+ $cat_id = $this->get_feed_category($cat_title, $parent_id);
$this->dbh->query("BEGIN");
if ($cat_id === false) {
add_feed_category($cat_title, $parent_id);
- $cat_id = get_feed_category($cat_title, $parent_id);
+ $cat_id = $this->get_feed_category($cat_title, $parent_id);
}
$this->dbh->query("COMMIT");
} else {
switch ($cat_title) {
case "tt-rss-prefs":
- $this->opml_import_preference($doc, $node, $owner_uid);
+ $this->opml_import_preference($node);
break;
case "tt-rss-labels":
- $this->opml_import_label($doc, $node, $owner_uid);
+ $this->opml_import_label($node, $owner_uid);
break;
case "tt-rss-filters":
- $this->opml_import_filter($doc, $node, $owner_uid);
+ $this->opml_import_filter($node);
break;
default:
- $this->opml_import_feed($doc, $node, $dst_cat_id, $owner_uid);
+ $this->opml_import_feed($node, $dst_cat_id, $owner_uid);
}
}
}
function opml_import($owner_uid) {
if (!$owner_uid) return;
- $debug = isset($_REQUEST["debug"]);
$doc = false;
-# if ($debug) $doc = DOMDocument::load("/tmp/test.opml");
-
if ($_FILES['opml_file']['error'] != 0) {
print_error(T_sprintf("Upload failed with error code %d",
$_FILES['opml_file']['error']));
return;
}
- $tmp_file = false;
-
if (is_uploaded_file($_FILES['opml_file']['tmp_name'])) {
$tmp_file = tempnam(CACHE_DIR . '/upload', 'opml');
if (is_file($tmp_file)) {
$doc = new DOMDocument();
+ libxml_disable_entity_loader(false);
$doc->load($tmp_file);
+ libxml_disable_entity_loader(true);
unlink($tmp_file);
} else if (!$doc) {
print_error(__('Error: unable to find moved OPML file.'));
return $url_path;
}
+ function get_feed_category($feed_cat, $parent_cat_id = false) {
+ if ($parent_cat_id) {
+ $parent_qpart = "parent_cat = '$parent_cat_id'";
+ $parent_insert = "'$parent_cat_id'";
+ } else {
+ $parent_qpart = "parent_cat IS NULL";
+ $parent_insert = "NULL";
+ }
+
+ $result = db_query(
+ "SELECT id FROM ttrss_feed_categories
+ WHERE $parent_qpart AND title = '$feed_cat' AND owner_uid = ".$_SESSION["uid"]);
+
+ if (db_num_rows($result) == 0) {
+ return false;
+ } else {
+ return db_fetch_result($result, 0, "id");
+ }
+ }
+
}
-?>