</head><body>";
}
- // FIXME: check for null value here
-
- $result = db_query($link, "SELECT *,SUBSTRING(last_updated,1,16) as last_updated_s,
- EXTRACT(EPOCH FROM NOW()) - EXTRACT(EPOCH FROM last_updated) as update_timeout
- FROM ttrss_feeds WHERE id = '$feed'");
+ if (DB_TYPE == "pgsql") {
+ $result = db_query($link,
+ "SELECT *,SUBSTRING(last_updated,1,16) as last_updated_s,
+ EXTRACT(EPOCH FROM NOW()) - EXTRACT(EPOCH FROM last_updated) as update_timeout
+ FROM ttrss_feeds WHERE id = '$feed'");
+ } else {
+ $result = db_query($link,
+ "SELECT *,SUBSTRING(last_updated,1,16) as last_updated_s
+ FROM ttrss_feeds WHERE id = '$feed'");
+ }
if ($result) {
$limit_query_part = "LIMIT " . $limit;
}
+ if (DB_TYPE == "pgsql") {
+ $extract_epoch_qpart = "
+ ,EXTRACT(EPOCH FROM last_read) AS last_read_ts,
+ EXTRACT(EPOCH FROM updated) AS updated_ts";
+ }
+
$result = db_query($link, "SELECT
- id,title,updated,unread,feed_id,marked,link,
- EXTRACT(EPOCH FROM last_read) AS last_read_ts,
- EXTRACT(EPOCH FROM updated) AS updated_ts
+ id,title,updated,unread,feed_id,marked,link
+ $extract_epoch_qpart
FROM
ttrss_entries
WHERE
alt=\"Updated\">";
}
- if ($line["unread"] == "t") {
+ if ($line["unread"] == "t" || $line["unread"] == "1") {
$class .= "Unread";
++$num_unread;
}
- if ($line["marked"] == "t") {
+ if ($line["marked"] == "t" || $line["marked"] == "1") {
$marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_set.png\"
alt=\"Reset mark\" onclick='javascript:toggleMark($id, false)'>";
} else {
<input type=\"submit\" class=\"button\"
onclick=\"javascript:feedEditCancel()\" value=\"Cancel\">
<input type=\"submit\" class=\"button\"
- onclickf=\"javascript:feedEditSave()\" value=\"Save\">";
+ onclick=\"javascript:feedEditSave()\" value=\"Save\">";
} else {
print "
print "
All feeds:
<input type=\"submit\"
- class=\"button\" onclick=\"opml.php?op=Export\" value=\"Export OPML\">";
+ class=\"button\" onclick=\"gotoExportOpml()\" value=\"Export OPML\">";
}
if (!WEB_DEMO_MODE) {
- $regexp = db_escape_string($_GET["reg_exp"]);
+ $regexp = db_escape_string($_GET["regexp"]);
$match = db_escape_string($_GET["match"]);
$result = db_query($link,
if (DB_TYPE == "pgsql") {
return pg_escape_string($s);
} else {
- return mysql_escape_string($s);
+ return mysql_real_escape_string($s);
}
}
}
}
+function db_query_2($query) {
+ if (DB_TYPE == "pgsql") {
+ return pg_query($query);
+ } else if (DB_TYPE == "mysql") {
+ return mysql_query($link);
+ }
+}
+
function db_fetch_assoc($result) {
if (DB_TYPE == "pgsql") {
return pg_fetch_assoc($result);
function db_num_rows($result) {
if (DB_TYPE == "pgsql") {
- return pg_num_rows($link, $query);
+ return pg_num_rows($result);
} else if (DB_TYPE == "mysql") {
- return mysql_num_rows($link, $query);
+ return mysql_num_rows($result);
}
}
document.location.href = "tt-rss.php";
}
-
+function gotoExportOpml() {
+ document.location.href = "opml.php?op=Export";
+}
$entry_guid = db_escape_string($entry_guid);
+ if (DB_TYPE == "pgsql") {
+ $extract_ts_qpart = ",EXTRACT(EPOCH FROM updated) as updated_timestamp";
+ }
+
$result = db_query($link, "
SELECT
- id,last_read,no_orig_date,title,feed_id,content_hash,
- EXTRACT(EPOCH FROM updated) as updated_timestamp
+ id,last_read,no_orig_date,title,feed_id,content_hash
+ $extract_ts_qpart
FROM
ttrss_entries
WHERE
}
require_once "config.php";
- require_once "functions.php";
+ require_once "db.php";
- $link = pg_connect(DB_CONN);
+ $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
- pg_query($link, "set client_encoding = 'utf-8'");
+ if (DB_TYPE == "pgsql") {
+ pg_query($link, "set client_encoding = 'utf-8'");
+ }
if ($op == "Export") {
print "<opml version=\"1.0\">";
print "<head><dateCreated>" . date("r", time()) . "</dateCreated></head>";
print "<body>";
- $result = pg_query("SELECT * FROM ttrss_feeds ORDER BY title");
+ $result = db_query($link, "SELECT * FROM ttrss_feeds ORDER BY title");
- while ($line = pg_fetch_assoc($result)) {
+ while ($line = db_fetch_assoc($result)) {
$title = $line["title"];
$url = $line["feed_url"];
}
function startElement($parser, $name, $attrs) {
+
if ($name == "OUTLINE") {
- $title = pg_escape_string($attrs['TEXT']);
- $url = pg_escape_string($attrs['XMLURL']);
+ $title = db_escape_string($attrs['TEXT']);
+ $url = db_escape_string($attrs['XMLURL']);
if (!$title || !$url) return;
print "Feed <b>$title</b> ($url)... ";
- $result = pg_query("SELECT id FROM ttrss_feeds WHERE
+ $result = db_query_2("SELECT id FROM ttrss_feeds WHERE
title = '$title' OR feed_url = '$url'");
- if (pg_num_rows($result) > 0) {
+ if (db_num_rows($result) > 0) {
print " Already imported.<br>";
} else {
- $result = pg_query("INSERT INTO ttrss_feeds (title, feed_url) VALUES
+ $result = db_query_2("INSERT INTO ttrss_feeds (title, feed_url) VALUES
('$title', '$url')");
print "<b>Done.</b><br>";
}
- pg_close($link);
+ db_close($link);
?>
}
*/
+function checkActiveFeedId() {
-function refetch_callback() {
+ var actfeedid = frames["feeds-frame"].document.getElementById("ACTFEEDID");
- if (xmlhttp_rpc.readyState == 4) {
+ if (actfeedid) {
+ active_feed_id = actfeedid.innerHTML;
+ }
+}
- var actfeedid = frames["feeds-frame"].document.getElementById("ACTFEEDID");
+function refetch_callback() {
- if (actfeedid) {
- active_feed_id = actfeedid.innerHTML;
- }
+ if (xmlhttp_rpc.readyState == 4) {
document.title = "Tiny Tiny RSS";
notify("All feeds updated.");
}
function search() {
+ checkActiveFeedId();
if (active_feed_id) {
viewfeed(active_feed_id, 0, "");
} else {
updateFeedList(false, false);
document.onkeydown = hotkey_handler;
- setTimeout("timeout()", 1800*1000);
- scheduleFeedUpdate(true);
+// setTimeout("timeout()", 1800*1000);
+// scheduleFeedUpdate(true);
var content = document.getElementById("content");
title varchar(200) not null unique,
feed_url varchar(250) unique not null,
icon_url varchar(250) not null default '',
- last_updated timestamp default null) TYPE=InnoDB;
+ last_updated datetime default '') TYPE=InnoDB;
insert into ttrss_feeds (title,feed_url) values ('Footnotes', 'http://gnomedesktop.org/node/feed');
insert into ttrss_feeds (title,feed_url) values ('Freedesktop.org', 'http://planet.freedesktop.org/rss20.xml');
'http://syndication.technocrat.net/rss');
create table ttrss_entries (id integer not null primary key auto_increment,
- feed_id integer not null,
- updated timestamp not null,
+ feed_id integer not null references ttrss_feeds(id),
+ updated datetime not null,
title varchar(250) not null,
guid varchar(250) not null unique,
link varchar(250) not null,
content text not null,
content_hash varchar(250) not null,
- last_read timestamp,
- marked bool not null default 'false',
- date_entered timestamp not null,
- no_orig_date bool not null default 'false',
+ last_read datetime,
+ marked bool not null default 0,
+ date_entered datetime not null,
+ no_orig_date bool not null default 0,
comments varchar(250) not null default '',
- unread bool not null default 'true') TYPE=InnoDB;
+ unread bool not null default 1) TYPE=InnoDB;
drop table if exists ttrss_filters;
drop table if exists ttrss_filter_types;
'Title or Content');
create table ttrss_filters (id integer primary key auto_increment,
- filter_type integer not null,
+ filter_type integer not null references ttrss_filter_types(id),
reg_exp varchar(250) not null,
description varchar(250) not null default '') TYPE=InnoDB;