Commit d475e8fd authored by Sebastian Reichel's avatar Sebastian Reichel

Imported Upstream version 1.7.9+dfsg

parent e8a849ca
/messages.mo
*~
*.DS_Store
#*
......
AddType image/svg+xml svg
AddType image/svg+xml svgz
......@@ -11,7 +11,9 @@
chdir("..");
define('TTRSS_SESSION_NAME', 'ttrss_api_sid');
define('NO_SESSION_AUTOSTART', true);
require_once "autoload.php";
require_once "db.php";
require_once "db-prefs.php";
require_once "functions.php";
......@@ -29,8 +31,6 @@
ob_start();
}
$link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
$input = file_get_contents("php://input");
if (defined('_API_DEBUG_HTTP_ENABLED') && _API_DEBUG_HTTP_ENABLED) {
......@@ -53,11 +53,11 @@
@session_start();
}
if (!init_connection($link)) return;
if (!init_plugins()) return;
$method = strtolower($_REQUEST["op"]);
$handler = new API($link, $_REQUEST);
$handler = new API($_REQUEST);
if ($handler->before($method)) {
if ($method && method_exists($handler, $method)) {
......@@ -68,8 +68,6 @@
$handler->after();
}
db_close($link);
header("Api-Content-Length: " . ob_get_length());
ob_end_flush();
......
......@@ -37,6 +37,7 @@
@$csrf_token = $_REQUEST['csrf_token'];
require_once "autoload.php";
require_once "sessions.php";
require_once "functions.php";
require_once "config.php";
......@@ -47,9 +48,7 @@
$script_started = microtime(true);
$link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
if (!init_connection($link)) return;
if (!init_plugins()) return;
header("Content-Type: text/json; charset=utf-8");
......@@ -58,11 +57,16 @@
}
if (SINGLE_USER_MODE) {
authenticate_user($link, "admin", null);
authenticate_user( "admin", null);
}
if ($_SESSION["uid"]) {
load_user_plugins($link, $_SESSION["uid"]);
if (!validate_session()) {
header("Content-Type: text/json");
print json_encode(array("error" => array("code" => 6)));
return;
}
load_user_plugins( $_SESSION["uid"]);
}
$purge_intervals = array(
......@@ -100,7 +104,7 @@
5 => __("Power User"),
10 => __("Administrator"));
#$error = sanity_check($link);
#$error = sanity_check();
#if ($error['code'] != 0 && $op != "logout") {
# print json_encode(array("error" => $error));
......@@ -109,15 +113,14 @@
$op = str_replace("-", "_", $op);
global $pluginhost;
$override = $pluginhost->lookup_handler($op, $method);
$override = PluginHost::getInstance()->lookup_handler($op, $method);
if (class_exists($op) || $override) {
if ($override) {
$handler = $override;
} else {
$handler = new $op($link, $_REQUEST);
$handler = new $op($_REQUEST);
}
if ($handler && implements_interface($handler, 'IHandler')) {
......@@ -148,6 +151,4 @@
header("Content-Type: text/json");
print json_encode(array("error" => array("code" => 7)));
// We close the connection to database.
db_close($link);
?>
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
......@@ -55,11 +55,13 @@ div.cdmContent a:hover {
div.cdmContentInner {
margin : 10px;
line-height : 20px;
}
div.cdmContentInner img {
border-width : 0px;
max-width : 98%;
height : auto;
}
div.cdmFooter {
......@@ -69,53 +71,78 @@ div.cdmFooter {
clear : both;
}
div.cdm {
border-width : 0px 1px 1px 0px;
border-collapse : collapse;
border-color : #c0c0c0;
border-style : solid;
background : #fafafa;
div.cdm.expanded {
margin-top : 4px;
margin-bottom : 4px;
}
div.cdm.expandable {
background : #f0f0f0;
background-color : #f0f0f0;
border-width : 0px 0px 1px 0px;
border-color : #c0c0c0;
border-style : solid;
}
div.cdm.expanded, div.cdm.expandable {
margin : 4px 4px 0px 4px;
border-width : 1px;
border-color : #c0c0c0;
box-shadow : 0px 0px 3px #ccc;
div.cdm.expandable > hr {
display : none;
}
div.cdm.expanded div.cdmHeader {
background : #e0e0e0;
div.cdm.expanded > hr {
margin-top : 0px;
margin-bottom : 0px;
}
div.cdm.Unread {
background : white;
}
div.cdm.Unread div.cdmHeader {
background : #ecf4ff;
}
div.cdm.active {
border-color : #88b0f0;
background : white ! important;
box-shadow : 0px 0px 3px #4684ff;
}
div.cdm.active div.cdmHeader {
background : #ecf4ff;
div.cdm.expandable div.cdmHeader a.title {
font-weight : bold;
color : gray;
}
div.cdm.expandable.Unread div.cdmHeader a.title {
color : black;
}
div.cdm.active div.cdmHeader a.title {
div.cdm.expandable.active div.cdmHeader a.title {
color : #4684ff;
}
div.cdm.expanded div.cdmHeader {
background : transparent ! important;
}
div.cdm.expanded div.cdmHeader a.title {
font-size : 14px;
color : gray;
font-weight : bold;
}
div.cdm.expanded.active div.cdmHeader a.title {
color : #4684ff;
}
div.cdm.expanded.Unread div.cdmHeader a.title {
color : black;
}
div.cdm.expanded div.cdmContent {
color : gray;
}
div.cdm.expanded.Unread div.cdmContent {
color : black;
}
div.cdm.active div.cdmContent {
background : white;
color : black;
}
span.cdmExcerpt {
......@@ -144,6 +171,7 @@ div.cdmFeedTitle a.title {
font-style : italic;
font-weight : bold;
}
div.cdmFeedTitle a {
color : gray;
}
......@@ -152,10 +180,6 @@ div.cdmFeedTitle a:hover {
color : #4684ff;
}
div.articleNote {
border-style : dashed none dashed none;
}
div.cdmHeader span.hlFeed {
float : right;
font-weight : normal;
......@@ -170,12 +194,14 @@ div.cdmHeader div.hlFeed, div.cdmHeader div.hlFeed a {
font-size : 11px;
}
div.cdmContentInner p {
max-width : 650px;
div.cdm .hlFeed a {
border-radius : 4px;
display : inline-block;
padding : 1px 4px 1px 4px;
}
.Unread div.cdmHeader {
font-weight : bold;
div.cdmContentInner p {
max-width : 650px;
}
div.cdmContentInner iframe {
......@@ -188,8 +214,4 @@ div.cdmHeader span.author {
font-weight : normal;
}
div.cdm.expanded div.cdmHeader a.title, div.cdm.active div.cdmHeader a.title {
font-size : 13px;
}
Order deny,allow
Deny from all
This diff is collapsed.
This diff is collapsed.
<?php
class Auth_Base {
protected $link;
private $dbh;
function __construct($link) {
$this->link = $link;
function __construct() {
$this->dbh = Db::get();
}
function check_password($owner_uid, $password) {
......@@ -16,12 +16,14 @@ class Auth_Base {
// Auto-creates specified user if allowed by system configuration
// Can be used instead of find_user_by_login() by external auth modules
function auto_create_user($login) {
function auto_create_user($login, $password = false) {
if ($login && defined('AUTH_AUTO_CREATE') && AUTH_AUTO_CREATE) {
$user_id = $this->find_user_by_login($login);
if (!$password) $password = make_password();
if (!$user_id) {
$login = db_escape_string($this->link, $login);
$login = $this->dbh->escape_string($login);
$salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
$pwd_hash = encrypt_password($password, $salt, true);
......@@ -29,7 +31,7 @@ class Auth_Base {
(login,access_level,last_login,created,pwd_hash,salt)
VALUES ('$login', 0, null, NOW(), '$pwd_hash','$salt')";
db_query($this->link, $query);
$this->dbh->query($query);
return $this->find_user_by_login($login);
......@@ -42,13 +44,13 @@ class Auth_Base {
}
function find_user_by_login($login) {
$login = db_escape_string($this->link, $login);
$login = $this->dbh->escape_string($login);
$result = db_query($this->link, "SELECT id FROM ttrss_users WHERE
$result = $this->dbh->query("SELECT id FROM ttrss_users WHERE
login = '$login'");
if (db_num_rows($result) > 0) {
return db_fetch_result($result, 0, "id");
if ($this->dbh->num_rows($result) > 0) {
return $this->dbh->fetch_result($result, 0, "id");
} else {
return false;
}
......
......@@ -11,7 +11,7 @@ class Backend extends Handler {
require_once "digest.php";
$rv = prepare_headlines_digest($this->link, $_SESSION['uid'], 1, 1000);
$rv = prepare_headlines_digest($_SESSION['uid'], 1, 1000);
$rv[3] = "<pre>" . $rv[3] . "</pre>";
......@@ -19,8 +19,8 @@ class Backend extends Handler {
}
private function display_main_help() {
$info = get_hotkeys_info($this->link);
$imap = get_hotkeys_map($this->link);
$info = get_hotkeys_info();
$imap = get_hotkeys_map();
$omap = array();
foreach ($imap[1] as $sequence => $action) {
......
<?php
class Db implements IDb {
private static $instance;
private $adapter;
private $link;
private function __construct() {
$er = error_reporting(E_ALL);
if (defined('_ENABLE_PDO') && _ENABLE_PDO && class_exists("PDO")) {
$this->adapter = new Db_PDO();
} else {
switch (DB_TYPE) {
case "mysql":
if (function_exists("mysqli_connect")) {
$this->adapter = new Db_Mysqli();
} else {
$this->adapter = new Db_Mysql();
}
break;
case "pgsql":
$this->adapter = new Db_Pgsql();
break;
default:
die("Unknown DB_TYPE: " . DB_TYPE);
}
}
if (!$this->adapter) die("Error initializing database adapter for " . DB_TYPE);
$this->link = $this->adapter->connect(DB_HOST, DB_USER, DB_PASS, DB_NAME, defined('DB_PORT') ? DB_PORT : "");
if (!$this->link) {
die("Error connecting through adapter: " . $this->adapter->last_error());
}
error_reporting($er);
}
private function __clone() {
//
}
public static function get() {
if (self::$instance == null)
self::$instance = new self();
return self::$instance;
}
static function quote($str){
return("'$str'");
}
function reconnect() {
$this->link = $this->adapter->connect(DB_HOST, DB_USER, DB_PASS, DB_NAME, defined('DB_PORT') ? DB_PORT : "");
}
function connect($host, $user, $pass, $db, $port) {
//return $this->adapter->connect($host, $user, $pass, $db, $port);
return ;
}
function escape_string($s, $strip_tags = true) {
return $this->adapter->escape_string($s, $strip_tags);
}
function query($query, $die_on_error = true) {
return $this->adapter->query($query, $die_on_error);
}
function fetch_assoc($result) {
return $this->adapter->fetch_assoc($result);
}
function num_rows($result) {
return $this->adapter->num_rows($result);
}
function fetch_result($result, $row, $param) {
return $this->adapter->fetch_result($result, $row, $param);
}
function close() {
return $this->adapter->close();
}
function affected_rows($result) {
return $this->adapter->affected_rows($result);
}
function last_error() {
return $this->adapter->last_error();
}
}
?>
<?php
class Db_Mysql implements IDb {
private $link;
function connect($host, $user, $pass, $db, $port) {
$this->link = mysql_connect($host, $user, $pass);
if ($this->link) {
$result = mysql_select_db($db, $this->link);
if (!$result) {
die("Can't select DB: " . mysql_error($this->link));
}
$this->init();
return $this->link;
} else {
die("Unable to connect to database (as $user to $host, database $db): " . mysql_error());
}
}
function escape_string($s, $strip_tags = true) {
if ($strip_tags) $s = strip_tags($s);
return mysql_real_escape_string($s, $this->link);
}
function query($query, $die_on_error = true) {
$result = mysql_query($query, $this->link);
if (!$result) {
user_error("Query $query failed: " . ($this->link ? mysql_error($this->link) : "No connection"),
$die_on_error ? E_USER_ERROR : E_USER_WARNING);
}
return $result;
}
function fetch_assoc($result) {
return mysql_fetch_assoc($result);
}
function num_rows($result) {
return mysql_num_rows($result);
}
function fetch_result($result, $row, $param) {
return mysql_result($result, $row, $param);
}
function close() {
return mysql_close($this->link);
}
function affected_rows($result) {
return mysql_affected_rows($this->link);
}
function last_error() {
return mysql_error();
}
function init() {
$this->query("SET time_zone = '+0:0'");
if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) {
$this->query("SET NAMES " . MYSQL_CHARSET);
}
return true;
}
}
?>
<?php
class Db_Mysqli implements IDb {
private $link;
function connect($host, $user, $pass, $db, $port) {
if ($port)
$this->link = mysqli_connect($host, $user, $pass, $db, $port);
else
$this->link = mysqli_connect($host, $user, $pass, $db);
if ($this->link) {
$this->init();
return $this->link;
} else {
die("Unable to connect to database (as $user to $host, database $db): " . mysqli_error());
}
}
function escape_string($s, $strip_tags = true) {