Commit d475e8fd authored by Sebastian Reichel's avatar Sebastian Reichel

Imported Upstream version 1.7.9+dfsg

parent e8a849ca
/messages.mo
*~ *~
*.DS_Store *.DS_Store
#* #*
......
AddType image/svg+xml svg
AddType image/svg+xml svgz
...@@ -11,7 +11,9 @@ ...@@ -11,7 +11,9 @@
chdir(".."); chdir("..");
define('TTRSS_SESSION_NAME', 'ttrss_api_sid'); define('TTRSS_SESSION_NAME', 'ttrss_api_sid');
define('NO_SESSION_AUTOSTART', true);
require_once "autoload.php";
require_once "db.php"; require_once "db.php";
require_once "db-prefs.php"; require_once "db-prefs.php";
require_once "functions.php"; require_once "functions.php";
...@@ -29,8 +31,6 @@ ...@@ -29,8 +31,6 @@
ob_start(); ob_start();
} }
$link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
$input = file_get_contents("php://input"); $input = file_get_contents("php://input");
if (defined('_API_DEBUG_HTTP_ENABLED') && _API_DEBUG_HTTP_ENABLED) { if (defined('_API_DEBUG_HTTP_ENABLED') && _API_DEBUG_HTTP_ENABLED) {
...@@ -53,11 +53,11 @@ ...@@ -53,11 +53,11 @@
@session_start(); @session_start();
} }
if (!init_connection($link)) return; if (!init_plugins()) return;
$method = strtolower($_REQUEST["op"]); $method = strtolower($_REQUEST["op"]);
$handler = new API($link, $_REQUEST); $handler = new API($_REQUEST);
if ($handler->before($method)) { if ($handler->before($method)) {
if ($method && method_exists($handler, $method)) { if ($method && method_exists($handler, $method)) {
...@@ -68,8 +68,6 @@ ...@@ -68,8 +68,6 @@
$handler->after(); $handler->after();
} }
db_close($link);
header("Api-Content-Length: " . ob_get_length()); header("Api-Content-Length: " . ob_get_length());
ob_end_flush(); ob_end_flush();
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
@$csrf_token = $_REQUEST['csrf_token']; @$csrf_token = $_REQUEST['csrf_token'];
require_once "autoload.php";
require_once "sessions.php"; require_once "sessions.php";
require_once "functions.php"; require_once "functions.php";
require_once "config.php"; require_once "config.php";
...@@ -47,9 +48,7 @@ ...@@ -47,9 +48,7 @@
$script_started = microtime(true); $script_started = microtime(true);
$link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); if (!init_plugins()) return;
if (!init_connection($link)) return;
header("Content-Type: text/json; charset=utf-8"); header("Content-Type: text/json; charset=utf-8");
...@@ -58,11 +57,16 @@ ...@@ -58,11 +57,16 @@
} }
if (SINGLE_USER_MODE) { if (SINGLE_USER_MODE) {
authenticate_user($link, "admin", null); authenticate_user( "admin", null);
} }
if ($_SESSION["uid"]) { 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( $purge_intervals = array(
...@@ -100,7 +104,7 @@ ...@@ -100,7 +104,7 @@
5 => __("Power User"), 5 => __("Power User"),
10 => __("Administrator")); 10 => __("Administrator"));
#$error = sanity_check($link); #$error = sanity_check();
#if ($error['code'] != 0 && $op != "logout") { #if ($error['code'] != 0 && $op != "logout") {
# print json_encode(array("error" => $error)); # print json_encode(array("error" => $error));
...@@ -109,15 +113,14 @@ ...@@ -109,15 +113,14 @@
$op = str_replace("-", "_", $op); $op = str_replace("-", "_", $op);
global $pluginhost; $override = PluginHost::getInstance()->lookup_handler($op, $method);
$override = $pluginhost->lookup_handler($op, $method);
if (class_exists($op) || $override) { if (class_exists($op) || $override) {
if ($override) { if ($override) {
$handler = $override; $handler = $override;
} else { } else {
$handler = new $op($link, $_REQUEST); $handler = new $op($_REQUEST);
} }
if ($handler && implements_interface($handler, 'IHandler')) { if ($handler && implements_interface($handler, 'IHandler')) {
...@@ -148,6 +151,4 @@ ...@@ -148,6 +151,4 @@
header("Content-Type: text/json"); header("Content-Type: text/json");
print json_encode(array("error" => array("code" => 7))); 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 { ...@@ -55,11 +55,13 @@ div.cdmContent a:hover {
div.cdmContentInner { div.cdmContentInner {
margin : 10px; margin : 10px;
line-height : 20px;
} }
div.cdmContentInner img { div.cdmContentInner img {
border-width : 0px; border-width : 0px;
max-width : 98%; max-width : 98%;
height : auto;
} }
div.cdmFooter { div.cdmFooter {
...@@ -69,53 +71,78 @@ div.cdmFooter { ...@@ -69,53 +71,78 @@ div.cdmFooter {
clear : both; clear : both;
} }
div.cdm { div.cdm.expanded {
border-width : 0px 1px 1px 0px; margin-top : 4px;
border-collapse : collapse; margin-bottom : 4px;
border-color : #c0c0c0;
border-style : solid;
background : #fafafa;
} }
div.cdm.expandable { 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 { div.cdm.expandable > hr {
margin : 4px 4px 0px 4px; display : none;
border-width : 1px;
border-color : #c0c0c0;
box-shadow : 0px 0px 3px #ccc;
} }
div.cdm.expanded div.cdmHeader { div.cdm.expanded > hr {
background : #e0e0e0; margin-top : 0px;
margin-bottom : 0px;
} }
div.cdm.Unread { div.cdm.Unread {
background : white; background : white;
} }
div.cdm.Unread div.cdmHeader {
background : #ecf4ff;
}
div.cdm.active { div.cdm.active {
border-color : #88b0f0; border-color : #88b0f0;
background : white ! important; background : white ! important;
box-shadow : 0px 0px 3px #4684ff;
} }
div.cdm.active div.cdmHeader { div.cdm.expandable div.cdmHeader a.title {
background : #ecf4ff; 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; 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 { div.cdm.active div.cdmContent {
background : white; color : black;
} }
span.cdmExcerpt { span.cdmExcerpt {
...@@ -144,6 +171,7 @@ div.cdmFeedTitle a.title { ...@@ -144,6 +171,7 @@ div.cdmFeedTitle a.title {
font-style : italic; font-style : italic;
font-weight : bold; font-weight : bold;
} }
div.cdmFeedTitle a { div.cdmFeedTitle a {
color : gray; color : gray;
} }
...@@ -152,10 +180,6 @@ div.cdmFeedTitle a:hover { ...@@ -152,10 +180,6 @@ div.cdmFeedTitle a:hover {
color : #4684ff; color : #4684ff;
} }
div.articleNote {
border-style : dashed none dashed none;
}
div.cdmHeader span.hlFeed { div.cdmHeader span.hlFeed {
float : right; float : right;
font-weight : normal; font-weight : normal;
...@@ -170,12 +194,14 @@ div.cdmHeader div.hlFeed, div.cdmHeader div.hlFeed a { ...@@ -170,12 +194,14 @@ div.cdmHeader div.hlFeed, div.cdmHeader div.hlFeed a {
font-size : 11px; font-size : 11px;
} }
div.cdmContentInner p { div.cdm .hlFeed a {
max-width : 650px; border-radius : 4px;
display : inline-block;
padding : 1px 4px 1px 4px;
} }
.Unread div.cdmHeader { div.cdmContentInner p {
font-weight : bold; max-width : 650px;
} }
div.cdmContentInner iframe { div.cdmContentInner iframe {
...@@ -188,8 +214,4 @@ div.cdmHeader span.author { ...@@ -188,8 +214,4 @@ div.cdmHeader span.author {
font-weight : normal; 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 <?php
class Auth_Base { class Auth_Base {
protected $link; private $dbh;
function __construct($link) { function __construct() {
$this->link = $link; $this->dbh = Db::get();
} }
function check_password($owner_uid, $password) { function check_password($owner_uid, $password) {
...@@ -16,12 +16,14 @@ class Auth_Base { ...@@ -16,12 +16,14 @@ class Auth_Base {
// Auto-creates specified user if allowed by system configuration // Auto-creates specified user if allowed by system configuration
// Can be used instead of find_user_by_login() by external auth modules // 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) { if ($login && defined('AUTH_AUTO_CREATE') && AUTH_AUTO_CREATE) {
$user_id = $this->find_user_by_login($login); $user_id = $this->find_user_by_login($login);
if (!$password) $password = make_password();
if (!$user_id) { 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); $salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
$pwd_hash = encrypt_password($password, $salt, true); $pwd_hash = encrypt_password($password, $salt, true);
...@@ -29,7 +31,7 @@ class Auth_Base { ...@@ -29,7 +31,7 @@ class Auth_Base {
(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 ('$login', 0, null, NOW(), '$pwd_hash','$salt')";
db_query($this->link, $query); $this->dbh->query($query);
return $this->find_user_by_login($login); return $this->find_user_by_login($login);
...@@ -42,13 +44,13 @@ class Auth_Base { ...@@ -42,13 +44,13 @@ class Auth_Base {
} }
function find_user_by_login($login) { 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'"); login = '$login'");
if (db_num_rows($result) > 0) { if ($this->dbh->num_rows($result) > 0) {
return db_fetch_result($result, 0, "id"); return $this->dbh->fetch_result($result, 0, "id");
} else { } else {
return false; return false;
} }
......
...@@ -11,7 +11,7 @@ class Backend extends Handler { ...@@ -11,7 +11,7 @@ class Backend extends Handler {
require_once "digest.php"; 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>"; $rv[3] = "<pre>" . $rv[3] . "</pre>";
...@@ -19,8 +19,8 @@ class Backend extends Handler { ...@@ -19,8 +19,8 @@ class Backend extends Handler {
} }
private function display_main_help() { private function display_main_help() {
$info = get_hotkeys_info($this->link); $info = get_hotkeys_info();
$imap = get_hotkeys_map($this->link); $imap = get_hotkeys_map();
$omap = array(); $omap = array();
foreach ($imap[1] as $sequence => $action) { 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 ;
}