update schema, more mysql work
This commit is contained in:
parent
4b3dff6ed5
commit
8158c57a8e
7 changed files with 77 additions and 47 deletions
36
backend.php
36
backend.php
|
@ -288,11 +288,16 @@
|
||||||
</head><body>";
|
</head><body>";
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: check for null value here
|
if (DB_TYPE == "pgsql") {
|
||||||
|
$result = db_query($link,
|
||||||
$result = db_query($link, "SELECT *,SUBSTRING(last_updated,1,16) as last_updated_s,
|
"SELECT *,SUBSTRING(last_updated,1,16) as last_updated_s,
|
||||||
EXTRACT(EPOCH FROM NOW()) - EXTRACT(EPOCH FROM last_updated) as update_timeout
|
EXTRACT(EPOCH FROM NOW()) - EXTRACT(EPOCH FROM last_updated) as update_timeout
|
||||||
FROM ttrss_feeds WHERE id = '$feed'");
|
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) {
|
if ($result) {
|
||||||
|
|
||||||
|
@ -356,10 +361,15 @@
|
||||||
$limit_query_part = "LIMIT " . $limit;
|
$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
|
$result = db_query($link, "SELECT
|
||||||
id,title,updated,unread,feed_id,marked,link,
|
id,title,updated,unread,feed_id,marked,link
|
||||||
EXTRACT(EPOCH FROM last_read) AS last_read_ts,
|
$extract_epoch_qpart
|
||||||
EXTRACT(EPOCH FROM updated) AS updated_ts
|
|
||||||
FROM
|
FROM
|
||||||
ttrss_entries
|
ttrss_entries
|
||||||
WHERE
|
WHERE
|
||||||
|
@ -388,12 +398,12 @@
|
||||||
alt=\"Updated\">";
|
alt=\"Updated\">";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($line["unread"] == "t") {
|
if ($line["unread"] == "t" || $line["unread"] == "1") {
|
||||||
$class .= "Unread";
|
$class .= "Unread";
|
||||||
++$num_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\"
|
$marked_pic = "<img id=\"FMARKPIC-$id\" src=\"images/mark_set.png\"
|
||||||
alt=\"Reset mark\" onclick='javascript:toggleMark($id, false)'>";
|
alt=\"Reset mark\" onclick='javascript:toggleMark($id, false)'>";
|
||||||
} else {
|
} else {
|
||||||
|
@ -648,7 +658,7 @@
|
||||||
<input type=\"submit\" class=\"button\"
|
<input type=\"submit\" class=\"button\"
|
||||||
onclick=\"javascript:feedEditCancel()\" value=\"Cancel\">
|
onclick=\"javascript:feedEditCancel()\" value=\"Cancel\">
|
||||||
<input type=\"submit\" class=\"button\"
|
<input type=\"submit\" class=\"button\"
|
||||||
onclickf=\"javascript:feedEditSave()\" value=\"Save\">";
|
onclick=\"javascript:feedEditSave()\" value=\"Save\">";
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
print "
|
print "
|
||||||
|
@ -668,7 +678,7 @@
|
||||||
print "
|
print "
|
||||||
All feeds:
|
All feeds:
|
||||||
<input type=\"submit\"
|
<input type=\"submit\"
|
||||||
class=\"button\" onclick=\"opml.php?op=Export\" value=\"Export OPML\">";
|
class=\"button\" onclick=\"gotoExportOpml()\" value=\"Export OPML\">";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -710,7 +720,7 @@
|
||||||
|
|
||||||
if (!WEB_DEMO_MODE) {
|
if (!WEB_DEMO_MODE) {
|
||||||
|
|
||||||
$regexp = db_escape_string($_GET["reg_exp"]);
|
$regexp = db_escape_string($_GET["regexp"]);
|
||||||
$match = db_escape_string($_GET["match"]);
|
$match = db_escape_string($_GET["match"]);
|
||||||
|
|
||||||
$result = db_query($link,
|
$result = db_query($link,
|
||||||
|
|
14
db.php
14
db.php
|
@ -20,7 +20,7 @@ function db_escape_string($s) {
|
||||||
if (DB_TYPE == "pgsql") {
|
if (DB_TYPE == "pgsql") {
|
||||||
return pg_escape_string($s);
|
return pg_escape_string($s);
|
||||||
} else {
|
} else {
|
||||||
return mysql_escape_string($s);
|
return mysql_real_escape_string($s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +32,14 @@ function db_query($link, $query) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
function db_fetch_assoc($result) {
|
||||||
if (DB_TYPE == "pgsql") {
|
if (DB_TYPE == "pgsql") {
|
||||||
return pg_fetch_assoc($result);
|
return pg_fetch_assoc($result);
|
||||||
|
@ -43,9 +51,9 @@ function db_fetch_assoc($result) {
|
||||||
|
|
||||||
function db_num_rows($result) {
|
function db_num_rows($result) {
|
||||||
if (DB_TYPE == "pgsql") {
|
if (DB_TYPE == "pgsql") {
|
||||||
return pg_num_rows($link, $query);
|
return pg_num_rows($result);
|
||||||
} else if (DB_TYPE == "mysql") {
|
} else if (DB_TYPE == "mysql") {
|
||||||
return mysql_num_rows($link, $query);
|
return mysql_num_rows($result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -263,4 +263,6 @@ function gotoMain() {
|
||||||
document.location.href = "tt-rss.php";
|
document.location.href = "tt-rss.php";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function gotoExportOpml() {
|
||||||
|
document.location.href = "opml.php?op=Export";
|
||||||
|
}
|
||||||
|
|
|
@ -171,10 +171,14 @@
|
||||||
|
|
||||||
$entry_guid = db_escape_string($entry_guid);
|
$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, "
|
$result = db_query($link, "
|
||||||
SELECT
|
SELECT
|
||||||
id,last_read,no_orig_date,title,feed_id,content_hash,
|
id,last_read,no_orig_date,title,feed_id,content_hash
|
||||||
EXTRACT(EPOCH FROM updated) as updated_timestamp
|
$extract_ts_qpart
|
||||||
FROM
|
FROM
|
||||||
ttrss_entries
|
ttrss_entries
|
||||||
WHERE
|
WHERE
|
||||||
|
|
25
opml.php
25
opml.php
|
@ -8,20 +8,22 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once "config.php";
|
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") {
|
if ($op == "Export") {
|
||||||
print "<opml version=\"1.0\">";
|
print "<opml version=\"1.0\">";
|
||||||
print "<head><dateCreated>" . date("r", time()) . "</dateCreated></head>";
|
print "<head><dateCreated>" . date("r", time()) . "</dateCreated></head>";
|
||||||
print "<body>";
|
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"];
|
$title = $line["title"];
|
||||||
$url = $line["feed_url"];
|
$url = $line["feed_url"];
|
||||||
|
|
||||||
|
@ -32,24 +34,25 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function startElement($parser, $name, $attrs) {
|
function startElement($parser, $name, $attrs) {
|
||||||
|
|
||||||
if ($name == "OUTLINE") {
|
if ($name == "OUTLINE") {
|
||||||
$title = pg_escape_string($attrs['TEXT']);
|
$title = db_escape_string($attrs['TEXT']);
|
||||||
$url = pg_escape_string($attrs['XMLURL']);
|
$url = db_escape_string($attrs['XMLURL']);
|
||||||
|
|
||||||
if (!$title || !$url) return;
|
if (!$title || !$url) return;
|
||||||
|
|
||||||
print "Feed <b>$title</b> ($url)... ";
|
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'");
|
title = '$title' OR feed_url = '$url'");
|
||||||
|
|
||||||
if (pg_num_rows($result) > 0) {
|
if (db_num_rows($result) > 0) {
|
||||||
|
|
||||||
print " Already imported.<br>";
|
print " Already imported.<br>";
|
||||||
|
|
||||||
} else {
|
} 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')");
|
('$title', '$url')");
|
||||||
|
|
||||||
print "<b>Done.</b><br>";
|
print "<b>Done.</b><br>";
|
||||||
|
@ -125,6 +128,6 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pg_close($link);
|
db_close($link);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
19
tt-rss.js
19
tt-rss.js
|
@ -58,17 +58,19 @@ function feedlist_callback() {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
function checkActiveFeedId() {
|
||||||
|
|
||||||
|
var actfeedid = frames["feeds-frame"].document.getElementById("ACTFEEDID");
|
||||||
|
|
||||||
|
if (actfeedid) {
|
||||||
|
active_feed_id = actfeedid.innerHTML;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function refetch_callback() {
|
function refetch_callback() {
|
||||||
|
|
||||||
if (xmlhttp_rpc.readyState == 4) {
|
if (xmlhttp_rpc.readyState == 4) {
|
||||||
|
|
||||||
var actfeedid = frames["feeds-frame"].document.getElementById("ACTFEEDID");
|
|
||||||
|
|
||||||
if (actfeedid) {
|
|
||||||
active_feed_id = actfeedid.innerHTML;
|
|
||||||
}
|
|
||||||
|
|
||||||
document.title = "Tiny Tiny RSS";
|
document.title = "Tiny Tiny RSS";
|
||||||
notify("All feeds updated.");
|
notify("All feeds updated.");
|
||||||
|
|
||||||
|
@ -253,6 +255,7 @@ function resetSearch() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function search() {
|
function search() {
|
||||||
|
checkActiveFeedId();
|
||||||
if (active_feed_id) {
|
if (active_feed_id) {
|
||||||
viewfeed(active_feed_id, 0, "");
|
viewfeed(active_feed_id, 0, "");
|
||||||
} else {
|
} else {
|
||||||
|
@ -315,9 +318,9 @@ function init() {
|
||||||
|
|
||||||
updateFeedList(false, false);
|
updateFeedList(false, false);
|
||||||
document.onkeydown = hotkey_handler;
|
document.onkeydown = hotkey_handler;
|
||||||
setTimeout("timeout()", 1800*1000);
|
|
||||||
|
|
||||||
scheduleFeedUpdate(true);
|
// setTimeout("timeout()", 1800*1000);
|
||||||
|
// scheduleFeedUpdate(true);
|
||||||
|
|
||||||
var content = document.getElementById("content");
|
var content = document.getElementById("content");
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ create table ttrss_feeds (id integer not null auto_increment primary key,
|
||||||
title varchar(200) not null unique,
|
title varchar(200) not null unique,
|
||||||
feed_url varchar(250) unique not null,
|
feed_url varchar(250) unique not null,
|
||||||
icon_url varchar(250) not null default '',
|
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 ('Footnotes', 'http://gnomedesktop.org/node/feed');
|
||||||
insert into ttrss_feeds (title,feed_url) values ('Freedesktop.org', 'http://planet.freedesktop.org/rss20.xml');
|
insert into ttrss_feeds (title,feed_url) values ('Freedesktop.org', 'http://planet.freedesktop.org/rss20.xml');
|
||||||
|
@ -28,19 +28,19 @@ insert into ttrss_feeds (title,feed_url) values ('Technocrat.net',
|
||||||
'http://syndication.technocrat.net/rss');
|
'http://syndication.technocrat.net/rss');
|
||||||
|
|
||||||
create table ttrss_entries (id integer not null primary key auto_increment,
|
create table ttrss_entries (id integer not null primary key auto_increment,
|
||||||
feed_id integer not null,
|
feed_id integer not null references ttrss_feeds(id),
|
||||||
updated timestamp not null,
|
updated datetime not null,
|
||||||
title varchar(250) not null,
|
title varchar(250) not null,
|
||||||
guid varchar(250) not null unique,
|
guid varchar(250) not null unique,
|
||||||
link varchar(250) not null,
|
link varchar(250) not null,
|
||||||
content text not null,
|
content text not null,
|
||||||
content_hash varchar(250) not null,
|
content_hash varchar(250) not null,
|
||||||
last_read timestamp,
|
last_read datetime,
|
||||||
marked bool not null default 'false',
|
marked bool not null default 0,
|
||||||
date_entered timestamp not null,
|
date_entered datetime not null,
|
||||||
no_orig_date bool not null default 'false',
|
no_orig_date bool not null default 0,
|
||||||
comments varchar(250) not null default '',
|
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_filters;
|
||||||
drop table if exists ttrss_filter_types;
|
drop table if exists ttrss_filter_types;
|
||||||
|
@ -56,7 +56,7 @@ insert into ttrss_filter_types (id,name,description) values (3, 'both',
|
||||||
'Title or Content');
|
'Title or Content');
|
||||||
|
|
||||||
create table ttrss_filters (id integer primary key auto_increment,
|
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,
|
reg_exp varchar(250) not null,
|
||||||
description varchar(250) not null default '') TYPE=InnoDB;
|
description varchar(250) not null default '') TYPE=InnoDB;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue