Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/SSilence/selfoss
Browse files Browse the repository at this point in the history
  • Loading branch information
tamizhgeek committed Aug 8, 2013
2 parents eb31de3 + e99222b commit d4dabf9
Show file tree
Hide file tree
Showing 14 changed files with 189 additions and 78 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ selfoss
Copyright (c) 2013 Tobias Zeising, tobias.zeising@aditu.de
http://selfoss.aditu.de
Licensed under the GPLv3 license
Version 2.8-SNAPSHOT
Version 2.9-SNAPSHOT


INSTALLATION
Expand Down Expand Up @@ -50,7 +50,12 @@ Visit the page http://yourselfossurl.com/opml for importing your OPML File. If y
CHANGELOG
---------

Version 2.8-SNAPSHOT
Version 2.9-SNAPSHOT
* New configuration parameter for share buttons (thanks a lot to becevka)
* new Ukrainian translation (thanks a lot to becevka)
* fix Italian translation

Version 2.8
* new Polish translation (thanks a lot to Piotr Dymacz)
* improved Expires section and Compression in .htaccess (thanks a lot to S Anand)
* make api item listing, tags and sources stats accessible for non loggedin users in public mode
Expand All @@ -61,6 +66,8 @@ Version 2.8-SNAPSHOT
* support ssl proxy (thanks a lot to zajad)
* new readability support (thanks a lot to hayk)
* pass original url to external sites except for opening the anonymized url (thanks a lot to bbeardsley)
* new finnish translation (thanks a lot to jukper)
* new spanish translation (thanks a lot to Matias Perrone)

Version 2.7
* new spout for instapaper (thanks a lot to janeczku)
Expand Down
12 changes: 10 additions & 2 deletions _docs/website/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ <h1 id="header-name"><span>selfoss</span></h1>
<li class="documentation">documentation</li>
<li class="about">about</li>
<li class="forum"><a href="/forum">forum</a></li>
<li class="download"><a href="selfoss-2.7.zip">download</a></li>
<li class="download"><a href="selfoss-2.8.zip">download</a></li>
</ul>

<a id="header-fork" href="https://github.com/SSilence/selfoss"></a>
Expand All @@ -37,7 +37,7 @@ <h1 id="header-name"><span>selfoss</span></h1>

<div id="header-just-updated"></div>

<a id="header-download" href="selfoss-2.7.zip"><span>download selfoss 2.7</span></a>
<a id="header-download" href="selfoss-2.8.zip"><span>download selfoss 2.8</span></a>

<a id="header-donate" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LR67F3T9DMSC8"><span>donate</span></a>

Expand Down Expand Up @@ -197,6 +197,10 @@ <h2>Configuration</h2>
<td class="documentation-first-column">db_password</td>
<td>database password</td>
</tr>
<tr>
<td class="documentation-first-column">db_prefix</td>
<td>table prefix for MySQL/SQLite databases</td>
</tr>
<tr>
<td class="documentation-first-column">db_port</td>
<td>port for database connections (3306 for mysql, 5432 for PostgreSQL</td>
Expand Down Expand Up @@ -273,6 +277,10 @@ <h2>Configuration</h2>
<td class="documentation-first-column">allow_public_update_access</td>
<td>set allow_public_update_access=1 for allowing public access for /update (anybody can access and start the update job).</td>
</tr>
<tr>
<td class="documentation-first-column">share</td>
<td>share defines which share buttons beneath the entry are visible. Default is share=gtfprde (g = google, f = facebook, t = twitter, p = pocket, r = readability, d = delicious, e = email). When you would like to show only facebook and twitter share button use share=ft.</td>
</tr>
</table>
</div>

Expand Down
28 changes: 14 additions & 14 deletions daos/mysql/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public function __construct() {
foreach($table as $key=>$value)
$tables[] = $value;

if(!in_array('items', $tables))
if(!in_array(\F3::get('db_prefix').'items', $tables))
\F3::get('db')->exec('
CREATE TABLE items (
CREATE TABLE '.\F3::get('db_prefix').'items (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
datetime DATETIME NOT NULL ,
title TEXT NOT NULL ,
Expand All @@ -61,9 +61,9 @@ public function __construct() {
');

$isNewestSourcesTable = false;
if(!in_array('sources', $tables)) {
if(!in_array(\F3::get('db_prefix').'sources', $tables)) {
\F3::get('db')->exec('
CREATE TABLE sources (
CREATE TABLE '.\F3::get('db_prefix').'sources (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
title TEXT NOT NULL ,
tags TEXT,
Expand All @@ -77,40 +77,40 @@ public function __construct() {
}

// version 1 or new
if(!in_array('version', $tables)) {
if(!in_array(\F3::get('db_prefix').'version', $tables)) {
\F3::get('db')->exec('
CREATE TABLE version (
CREATE TABLE '.\F3::get('db_prefix').'version (
version INT
) ENGINE = MYISAM DEFAULT CHARSET=utf8;
');

\F3::get('db')->exec('
INSERT INTO version (version) VALUES (3);
INSERT INTO '.\F3::get('db_prefix').'version (version) VALUES (3);
');

\F3::get('db')->exec('
CREATE TABLE tags (
CREATE TABLE '.\F3::get('db_prefix').'tags (
tag TEXT NOT NULL,
color VARCHAR(7) NOT NULL
) DEFAULT CHARSET=utf8;
) ENGINE = MYISAM DEFAULT CHARSET=utf8;
');

if($isNewestSourcesTable===false) {
\F3::get('db')->exec('
ALTER TABLE sources ADD tags TEXT;
ALTER TABLE '.\F3::get('db_prefix').'sources ADD tags TEXT;
');
}
}
else{
$version = @\F3::get('db')->exec('SELECT version FROM version ORDER BY version DESC LIMIT 0, 1');
$version = @\F3::get('db')->exec('SELECT version FROM '.\F3::get('db_prefix').'version ORDER BY version DESC LIMIT 0, 1');
$version = $version[0]['version'];

if($version == "2"){
\F3::get('db')->exec('
ALTER TABLE sources ADD lastupdate INT;
ALTER TABLE '.\F3::get('db_prefix').'sources ADD lastupdate INT;
');
\F3::get('db')->exec('
INSERT INTO version (version) VALUES (3);
INSERT INTO '.\F3::get('db_prefix').'version (version) VALUES (3);
');
}
}
Expand All @@ -128,6 +128,6 @@ public function __construct() {
* @return void
*/
public function optimize() {
@\F3::get('db')->exec("OPTIMIZE TABLE `sources`, `items`");
@\F3::get('db')->exec('OPTIMIZE TABLE `'.\F3::get('db_prefix').'sources`, `'.\F3::get('db_prefix').'items`');
}
}
40 changes: 20 additions & 20 deletions daos/mysql/Items.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function mark($id) {
$id = implode(",", $id);

// i used string concatenation after validating $id
\F3::get('db')->exec('UPDATE items SET unread=0 WHERE id IN (' . $id . ')');
\F3::get('db')->exec('UPDATE '.\F3::get('db_prefix').'items SET unread=0 WHERE id IN (' . $id . ')');
}


Expand All @@ -51,7 +51,7 @@ public function unmark($id) {
} else if(!is_numeric($id)) {
return;
}
\F3::get('db')->exec('UPDATE items SET unread=1 WHERE id IN (:id)',
\F3::get('db')->exec('UPDATE '.\F3::get('db_prefix').'items SET unread=1 WHERE id IN (:id)',
array(':id' => $id));
}

Expand All @@ -63,7 +63,7 @@ public function unmark($id) {
* @param int $id the item
*/
public function starr($id) {
\F3::get('db')->exec('UPDATE items SET starred=1 WHERE id=:id',
\F3::get('db')->exec('UPDATE '.\F3::get('db_prefix').'items SET starred=1 WHERE id=:id',
array(':id' => $id));
}

Expand All @@ -75,7 +75,7 @@ public function starr($id) {
* @param int $id the item
*/
public function unstarr($id) {
\F3::get('db')->exec('UPDATE items SET starred=0 WHERE id=:id',
\F3::get('db')->exec('UPDATE '.\F3::get('db_prefix').'items SET starred=0 WHERE id=:id',
array(':id' => $id));
}

Expand All @@ -91,7 +91,7 @@ public function add($values) {
if($this->exists($values['uid'])===true)
return;

\F3::get('db')->exec('INSERT INTO items (
\F3::get('db')->exec('INSERT INTO '.\F3::get('db_prefix').'items (
datetime,
title,
content,
Expand Down Expand Up @@ -137,7 +137,7 @@ public function add($values) {
* @param string $uid
*/
public function exists($uid) {
$res = \F3::get('db')->exec('SELECT COUNT(*) AS amount FROM items WHERE uid=:uid',
$res = \F3::get('db')->exec('SELECT COUNT(*) AS amount FROM '.\F3::get('db_prefix').'items WHERE uid=:uid',
array( ':uid' => array($uid, \PDO::PARAM_STR) ) );
return $res[0]['amount']>0;
}
Expand All @@ -150,10 +150,10 @@ public function exists($uid) {
* @param DateTime $date date to delete all items older than this value [optional]
*/
public function cleanup(\DateTime $date = NULL) {
\F3::get('db')->exec('DELETE FROM items USING items LEFT JOIN sources
\F3::get('db')->exec('DELETE items FROM '.\F3::get('db_prefix').'items AS items LEFT JOIN '.\F3::get('db_prefix').'sources AS sources
ON items.source=sources.id WHERE sources.id IS NULL');
if ($date !== NULL)
\F3::get('db')->exec('DELETE FROM items WHERE starred=0 AND datetime<:date',
\F3::get('db')->exec('DELETE FROM '.\F3::get('db_prefix').'items WHERE starred=0 AND datetime<:date',
array(':date' => $date->format('Y-m-d').' 00:00:00'));
}

Expand Down Expand Up @@ -208,15 +208,15 @@ public function get($options = array()) {

// first check whether more items are available
$result = \F3::get('db')->exec('SELECT items.id
FROM items, sources
FROM '.\F3::get('db_prefix').'items AS items, '.\F3::get('db_prefix').'sources AS sources
WHERE items.source=sources.id '.$where.'
LIMIT ' . ($options['offset']+$options['items']) . ', 1', $params);
$this->hasMore = count($result);

// get items from database
return \F3::get('db')->exec('SELECT
items.id, datetime, items.title AS title, content, unread, starred, source, thumbnail, icon, uid, link, sources.title as sourcetitle, sources.tags as tags
FROM items, sources
FROM '.\F3::get('db_prefix').'items AS items, '.\F3::get('db_prefix').'sources AS sources
WHERE items.source=sources.id '.$where.'
ORDER BY items.datetime DESC
LIMIT ' . $options['offset'] . ', ' . $options['items'], $params);
Expand All @@ -242,7 +242,7 @@ public function hasMore() {
public function getThumbnails() {
$thumbnails = array();
$result = \F3::get('db')->exec('SELECT thumbnail
FROM items
FROM '.\F3::get('db_prefix').'items
WHERE thumbnail!=""');
foreach($result as $thumb)
$thumbnails[] = $thumb['thumbnail'];
Expand All @@ -258,7 +258,7 @@ public function getThumbnails() {
public function getIcons() {
$icons = array();
$result = \F3::get('db')->exec('SELECT icon
FROM items
FROM '.\F3::get('db_prefix').'items
WHERE icon!=""');
foreach($result as $icon)
$icons[] = $icon['icon'];
Expand All @@ -274,7 +274,7 @@ public function getIcons() {
*/
public function hasThumbnail($thumbnail) {
$res = \F3::get('db')->exec('SELECT count(*) AS amount
FROM items
FROM '.\F3::get('db_prefix').'items
WHERE thumbnail=:thumbnail',
array(':thumbnail' => $thumbnail));
$amount = $res[0]['amount'];
Expand All @@ -292,7 +292,7 @@ public function hasThumbnail($thumbnail) {
*/
public function hasIcon($icon) {
$res = \F3::get('db')->exec('SELECT count(*) AS amount
FROM items
FROM '.\F3::get('db_prefix').'items
WHERE icon=:icon',
array(':icon' => $icon));
return $res[0]['amount']>0;
Expand Down Expand Up @@ -338,7 +338,7 @@ public function getLastIcon($sourceid) {
if(is_numeric($sourceid)===false)
return false;

$res = \F3::get('db')->exec('SELECT icon FROM items WHERE source=:sourceid AND icon!=0 AND icon!="" ORDER BY ID DESC LIMIT 0,1',
$res = \F3::get('db')->exec('SELECT icon FROM '.\F3::get('db_prefix').'items WHERE source=:sourceid AND icon!=0 AND icon!="" ORDER BY ID DESC LIMIT 0,1',
array(':sourceid' => $sourceid));
if(count($res)==1)
return $res[0]['icon'];
Expand All @@ -353,7 +353,7 @@ public function getLastIcon($sourceid) {
* @return int amount of entries in database
*/
public function numberOfItems() {
$res = \F3::get('db')->exec('SELECT count(*) AS amount FROM items');
$res = \F3::get('db')->exec('SELECT count(*) AS amount FROM '.\F3::get('db_prefix').'items');
return $res[0]['amount'];
}

Expand All @@ -365,7 +365,7 @@ public function numberOfItems() {
*/
public function numberOfUnread() {
$res = \F3::get('db')->exec('SELECT count(*) AS amount
FROM items
FROM '.\F3::get('db_prefix').'items
WHERE unread=1');
return $res[0]['amount'];
}
Expand All @@ -378,7 +378,7 @@ public function numberOfUnread() {
*/
public function numberOfStarred() {
$res = \F3::get('db')->exec('SELECT count(*) AS amount
FROM items
FROM '.\F3::get('db_prefix').'items
WHERE starred=1');
return $res[0]['amount'];
}
Expand All @@ -390,7 +390,7 @@ public function numberOfStarred() {
* @return int amount of entries in database per tag
*/
public function numberOfUnreadForTag($tag) {
$select = 'SELECT count(*) AS amount FROM items, sources';
$select = 'SELECT count(*) AS amount FROM '.\F3::get('db_prefix').'items AS items, '.\F3::get('db_prefix').'sources AS sources';
$where = ' WHERE items.source=sources.id AND unread=1';
if ( \F3::get( 'db_type' ) == 'mysql' ) {
$where .= " AND ( CONCAT( ',' , sources.tags , ',' ) LIKE :tag ) ";
Expand All @@ -410,7 +410,7 @@ public function numberOfUnreadForTag($tag) {
*/
public function numberOfUnreadForSource($sourceid) {
$res = \F3::get('db')->exec(
'SELECT count(*) AS amount FROM items WHERE source=:source AND unread=1',
'SELECT count(*) AS amount FROM '.\F3::get('db_prefix').'items WHERE source=:source AND unread=1',
array(':source' => $sourceid));
return $res[0]['amount'];
}
Expand Down
Loading

0 comments on commit d4dabf9

Please sign in to comment.