...
 
Commits (602)

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.
[*]
end_of_line = lf
insert_final_newline = true
[*.php]
indent_style = tab
phpmd:
image: php:5.6
when: manual
script:
- sh utils/gitlab-ci/php-lint.sh
- curl -o /usr/bin/phpmd -L http://static.phpmd.org/php/2.6.0/phpmd.phar
- chmod +x /usr/bin/phpmd
- sh utils/gitlab-ci/phpmd.sh
schema:
image: fox/selenium-ci
when: manual
script:
- /etc/init.d/postgresql start
- /usr/local/sbin/init-database.sh
- sh ./utils/gitlab-ci/check-schema.sh
phpunit_basic:
image: fox/selenium-ci
when: manual
script:
- /etc/init.d/postgresql start
- /usr/local/sbin/init-database.sh
- sh ./utils/gitlab-ci/check-schema.sh
- cp utils/gitlab-ci/config-template.php config.php
- su -s /bin/bash www-data -c "php ./update.php --debug-feed 1"
- wget -O /usr/bin/phpunit https://phar.phpunit.de/phpunit-5.7.phar
- chmod +x /usr/bin/phpunit
- phpunit tests/*.php
phpunit_functional:
image: fox/selenium-ci
when: manual
script:
- /etc/init.d/postgresql start
- /etc/init.d/nginx start
- /etc/init.d/php5-fpm start
- /usr/local/sbin/init-database.sh
- sh ./utils/gitlab-ci/check-schema.sh
- ln -s `pwd` ../../tt-rss
- cp utils/gitlab-ci/config-template.php config.php
- chmod -R 777 cache lock feed-icons
- /usr/local/sbin/init-selenium.sh
- phpunit tests/functional/*.php
## Contributing code the right way
TLDR: it works pretty much like Github.
1. Make an account on Gogs
2. Fork the repository you're interested in
3. Do the needful
4. File a pull request with your changes against master branch.
This diff is collapsed.
...@@ -87,4 +87,4 @@ ...@@ -87,4 +87,4 @@
header("Api-Content-Length: " . ob_get_length()); header("Api-Content-Length: " . ob_get_length());
ob_end_flush(); ob_end_flush();
?>
...@@ -9,11 +9,11 @@ ...@@ -9,11 +9,11 @@
<html> <html>
<head> <head>
<title><xsl:value-of select="atom:title"/></title> <title><xsl:value-of select="atom:title"/></title>
<link rel="stylesheet" type="text/css" href="css/utility.css"/> <link rel="stylesheet" type="text/css" href="css/default.css"/>
<script language="javascript" src="lib/xsl_mop-up.js"></script> <script language="javascript" src="lib/xsl_mop-up.js"></script>
</head> </head>
<body onload="go_decoding()"> <body onload="go_decoding()" class="ttrss_utility">
<div id="cometestme" style="display:none;"> <div id="cometestme" style="display:none;">
<xsl:text disable-output-escaping="yes">&amp;amp;</xsl:text> <xsl:text disable-output-escaping="yes">&amp;amp;</xsl:text>
......
This diff is collapsed.
This diff is collapsed.
<?php <?php
class Auth_Base { class Auth_Base {
private $dbh; private $pdo;
function __construct() { function __construct() {
$this->dbh = Db::get(); $this->pdo = Db::pdo();
} }
/**
* @SuppressWarnings(unused)
*/
function check_password($owner_uid, $password) { function check_password($owner_uid, $password) {
return false; return false;
} }
/**
* @SuppressWarnings(unused)
*/
function authenticate($login, $password) { function authenticate($login, $password) {
return false; return false;
} }
...@@ -27,15 +33,13 @@ class Auth_Base { ...@@ -27,15 +33,13 @@ class Auth_Base {
if (!$password) $password = make_password(); if (!$password) $password = make_password();
if (!$user_id) { if (!$user_id) {
$login = $this->dbh->escape_string($login);
$salt = substr(bin2hex(get_random_bytes(125)), 0, 250); $salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
$pwd_hash = encrypt_password($password, $salt, true); $pwd_hash = encrypt_password($password, $salt, true);
$query = "INSERT INTO ttrss_users $sth = $this->pdo->prepare("INSERT INTO ttrss_users
(login,access_level,last_login,created,pwd_hash,salt) (login,access_level,last_login,created,pwd_hash,salt)
VALUES ('$login', 0, null, NOW(), '$pwd_hash','$salt')"; VALUES (?, 0, null, NOW(), ?,?)");
$sth->execute([$login, $pwd_hash, $salt]);
$this->dbh->query($query);
return $this->find_user_by_login($login); return $this->find_user_by_login($login);
...@@ -48,18 +52,15 @@ class Auth_Base { ...@@ -48,18 +52,15 @@ class Auth_Base {
} }
function find_user_by_login($login) { function find_user_by_login($login) {
$login = $this->dbh->escape_string($login); $sth = $this->pdo->prepare("SELECT id FROM ttrss_users WHERE
login = ?");
$result = $this->dbh->query("SELECT id FROM ttrss_users WHERE $sth->execute([$login]);
login = '$login'");
if ($this->dbh->num_rows($result) > 0) { if ($row = $sth->fetch()) {
return $this->dbh->fetch_result($result, 0, "id"); return $row["id"];
} else { } else {
return false; return false;
} }
} }
} }
?>
...@@ -9,9 +9,7 @@ class Backend extends Handler { ...@@ -9,9 +9,7 @@ class Backend extends Handler {
function digestTest() { function digestTest() {
header("Content-type: text/html"); header("Content-type: text/html");
require_once "digest.php"; $rv = Digest::prepare_headlines_digest($_SESSION['uid'], 1, 1000);
$rv = prepare_headlines_digest($_SESSION['uid'], 1, 1000);
$rv[3] = "<pre>" . $rv[3] . "</pre>"; $rv[3] = "<pre>" . $rv[3] . "</pre>";
...@@ -86,7 +84,7 @@ class Backend extends Handler { ...@@ -86,7 +84,7 @@ class Backend extends Handler {
} }
function help() { function help() {
$topic = basename($_REQUEST["topic"]); $topic = basename(clean($_REQUEST["topic"]));
switch ($topic) { switch ($topic) {
case "main": case "main":
...@@ -115,5 +113,4 @@ class Backend extends Handler { ...@@ -115,5 +113,4 @@ class Backend extends Handler {
__('Close this window')."</button></div>"; */ __('Close this window')."</button></div>"; */
} }
} }
?> \ No newline at end of file
<?php
class CCache {
static function zero_all($owner_uid) {
$pdo = Db::pdo();
$sth = $pdo->prepare("UPDATE ttrss_counters_cache SET
value = 0 WHERE owner_uid = ?");
$sth->execute([$owner_uid]);
$sth = $pdo->prepare("UPDATE ttrss_cat_counters_cache SET
value = 0 WHERE owner_uid = ?");
$sth->execute([$owner_uid]);
}
static function remove($feed_id, $owner_uid, $is_cat = false) {
$feed_id = (int) $feed_id;
if (!$is_cat) {
$table = "ttrss_counters_cache";
} else {
$table = "ttrss_cat_counters_cache";
}
$pdo = Db::pdo();
$sth = $pdo->prepare("DELETE FROM $table WHERE
feed_id = ? AND owner_uid = ?");
$sth->execute([$feed_id, $owner_uid]);
}
static function update_all($owner_uid) {
$pdo = Db::pdo();
if (get_pref('ENABLE_FEED_CATS', $owner_uid)) {
$sth = $pdo->prepare("SELECT feed_id FROM ttrss_cat_counters_cache
WHERE feed_id > 0 AND owner_uid = ?");
$sth->execute([$owner_uid]);
while ($line = $sth->fetch()) {
CCache::update($line["feed_id"], $owner_uid, true);
}
/* We have to manually include category 0 */
CCache::update(0, $owner_uid, true);
} else {
$sth = $pdo->prepare("SELECT feed_id FROM ttrss_counters_cache
WHERE feed_id > 0 AND owner_uid = ?");
$sth->execute([$owner_uid]);
while ($line = $sth->fetch()) {
print CCache::update($line["feed_id"], $owner_uid);
}
}
}
static function find($feed_id, $owner_uid, $is_cat = false,
$no_update = false) {
// "" (null) is valid and should be cast to 0 (uncategorized)
// everything else i.e. tags are not
if (!is_numeric($feed_id) && $feed_id)
return;
$feed_id = (int) $feed_id;
if (!$is_cat) {
$table = "ttrss_counters_cache";
} else {
$table = "ttrss_cat_counters_cache";
}
$pdo = Db::pdo();
$sth = $pdo->prepare("SELECT value FROM $table
WHERE owner_uid = ? AND feed_id = ?
LIMIT 1");
$sth->execute([$owner_uid, $feed_id]);
if ($row = $sth->fetch()) {
return $row["value"];
} else {
if ($no_update) {
return -1;
} else {
return CCache::update($feed_id, $owner_uid, $is_cat);
}
}
}
static function update($feed_id, $owner_uid, $is_cat = false,
$update_pcat = true, $pcat_fast = false) {
// "" (null) is valid and should be cast to 0 (uncategorized)
// everything else i.e. tags are not
if (!is_numeric($feed_id) && $feed_id)
return;
$feed_id = (int) $feed_id;
$prev_unread = CCache::find($feed_id, $owner_uid, $is_cat, true);
/* When updating a label, all we need to do is recalculate feed counters
* because labels are not cached */
if ($feed_id < 0) {
CCache::update_all($owner_uid);
return;
}
if (!$is_cat) {
$table = "ttrss_counters_cache";
} else {
$table = "ttrss_cat_counters_cache";
}
$pdo = Db::pdo();
if ($is_cat && $feed_id >= 0) {
/* Recalculate counters for child feeds */
if (!$pcat_fast) {
$sth = $pdo->prepare("SELECT id FROM ttrss_feeds
WHERE owner_uid = :uid AND
(cat_id = :cat OR (:cat = 0 AND cat_id IS NULL))");
$sth->execute([":uid" => $owner_uid, ":cat" => $feed_id]);
while ($line = $sth->fetch()) {
CCache::update((int)$line["id"], $owner_uid, false, false);
}
}
$sth = $pdo->prepare("SELECT SUM(value) AS sv
FROM ttrss_counters_cache, ttrss_feeds
WHERE id = feed_id AND
(cat_id = :cat OR (:cat = 0 AND cat_id IS NULL)) AND
ttrss_counters_cache.owner_uid = :uid AND
ttrss_feeds.owner_uid = :uid");
$sth->execute([":uid" => $owner_uid, ":cat" => $feed_id]);
$row = $sth->fetch();
$unread = (int) $row["sv"];
} else {
$unread = (int) Feeds::getFeedArticles($feed_id, $is_cat, true, $owner_uid);
}
$tr_in_progress = false;
try {
$pdo->beginTransaction();
} catch (Exception $e) {
$tr_in_progress = true;
}
$sth = $pdo->prepare("SELECT feed_id FROM $table
WHERE owner_uid = ? AND feed_id = ? LIMIT 1");
$sth->execute([$owner_uid, $feed_id]);
if ($sth->fetch()) {
$sth = $pdo->prepare("UPDATE $table SET
value = ?, updated = NOW() WHERE
feed_id = ? AND owner_uid = ?");
$sth->execute([$unread, $feed_id, $owner_uid]);
} else {
$sth = $pdo->prepare("INSERT INTO $table
(feed_id, value, owner_uid, updated)
VALUES
(?, ?, ?, NOW())");
$sth->execute([$feed_id, $unread, $owner_uid]);
}
if (!$tr_in_progress) $pdo->commit();
if ($feed_id > 0 && $prev_unread != $unread) {
if (!$is_cat) {
/* Update parent category */
if ($update_pcat) {
$sth = $pdo->prepare("SELECT cat_id FROM ttrss_feeds
WHERE owner_uid = ? AND id = ?");
$sth->execute([$owner_uid, $feed_id]);
if ($row = $sth->fetch()) {
CCache::update((int)$row["cat_id"], $owner_uid, true, true, true);
}
}
}
} else if ($feed_id < 0) {
CCache::update_all($owner_uid);
}
return $unread;
}
}
\ No newline at end of file
<?php
class Counters {
static function getAllCounters() {
$data = Counters::getGlobalCounters();
$data = array_merge($data, Counters::getVirtCounters());
$data = array_merge($data, Counters::getLabelCounters());
$data = array_merge($data, Counters::getFeedCounters());
$data = array_merge($data, Counters::getCategoryCounters<