@@ -33,4 +33,4 @@ |
||
| 33 | 33 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 34 | 34 | */ |
| 35 | 35 | |
| 36 | - |
|
| 37 | 36 | \ No newline at end of file |
| 37 | + |
|
| 38 | 38 | \ No newline at end of file |
@@ -1,16 +1,16 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | abstract class FeedItem { |
| 3 | - abstract function get_id(); |
|
| 4 | - abstract function get_date(); |
|
| 5 | - abstract function get_link(); |
|
| 6 | - abstract function get_title(); |
|
| 7 | - abstract function get_description(); |
|
| 8 | - abstract function get_content(); |
|
| 9 | - abstract function get_comments_url(); |
|
| 10 | - abstract function get_comments_count(); |
|
| 11 | - abstract function get_categories(); |
|
| 12 | - abstract function get_enclosures(); |
|
| 13 | - abstract function get_author(); |
|
| 14 | - abstract function get_language(); |
|
| 3 | + abstract function get_id(); |
|
| 4 | + abstract function get_date(); |
|
| 5 | + abstract function get_link(); |
|
| 6 | + abstract function get_title(); |
|
| 7 | + abstract function get_description(); |
|
| 8 | + abstract function get_content(); |
|
| 9 | + abstract function get_comments_url(); |
|
| 10 | + abstract function get_comments_count(); |
|
| 11 | + abstract function get_categories(); |
|
| 12 | + abstract function get_enclosures(); |
|
| 13 | + abstract function get_author(); |
|
| 14 | + abstract function get_language(); |
|
| 15 | 15 | } |
| 16 | 16 | |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | interface IHandler { |
| 3 | - public function csrf_ignore($method); |
|
| 4 | - public function before($method); |
|
| 5 | - public function after(); |
|
| 3 | + public function csrf_ignore($method); |
|
| 4 | + public function before($method); |
|
| 5 | + public function after(); |
|
| 6 | 6 | } |
@@ -2,59 +2,59 @@ |
||
| 2 | 2 | |
| 3 | 3 | abstract class Plugin { |
| 4 | 4 | |
| 5 | - const API_VERSION_COMPAT = 1; |
|
| 5 | + const API_VERSION_COMPAT = 1; |
|
| 6 | 6 | |
| 7 | - /** |
|
| 8 | - * @var PDO |
|
| 9 | - */ |
|
| 10 | - protected $pdo; |
|
| 7 | + /** |
|
| 8 | + * @var PDO |
|
| 9 | + */ |
|
| 10 | + protected $pdo; |
|
| 11 | 11 | |
| 12 | - abstract function init(PluginHost $host); |
|
| 12 | + abstract function init(PluginHost $host); |
|
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * @return array(version, name, description, author, false) |
|
| 16 | - */ |
|
| 17 | - abstract function about(); |
|
| 14 | + /** |
|
| 15 | + * @return array(version, name, description, author, false) |
|
| 16 | + */ |
|
| 17 | + abstract function about(); |
|
| 18 | 18 | |
| 19 | - public function __construct() { |
|
| 20 | - $this->pdo = Db::pdo(); |
|
| 21 | - } |
|
| 19 | + public function __construct() { |
|
| 20 | + $this->pdo = Db::pdo(); |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - public function flags() { |
|
| 24 | - /* associative array, possible keys: |
|
| 23 | + public function flags() { |
|
| 24 | + /* associative array, possible keys: |
|
| 25 | 25 | needs_curl = boolean |
| 26 | 26 | */ |
| 27 | - return array(); |
|
| 28 | - } |
|
| 27 | + return array(); |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - public function is_public_method() { |
|
| 31 | - return false; |
|
| 32 | - } |
|
| 30 | + public function is_public_method() { |
|
| 31 | + return false; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - public function get_js() { |
|
| 35 | - return ""; |
|
| 36 | - } |
|
| 34 | + public function get_js() { |
|
| 35 | + return ""; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - public function get_prefs_js() { |
|
| 39 | - return ""; |
|
| 40 | - } |
|
| 38 | + public function get_prefs_js() { |
|
| 39 | + return ""; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - public function api_version() { |
|
| 43 | - return Plugin::API_VERSION_COMPAT; |
|
| 44 | - } |
|
| 42 | + public function api_version() { |
|
| 43 | + return Plugin::API_VERSION_COMPAT; |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - public function __($msgid) { |
|
| 47 | - return _dgettext(PluginHost::object_to_domain($this), $msgid); |
|
| 48 | - } |
|
| 46 | + public function __($msgid) { |
|
| 47 | + return _dgettext(PluginHost::object_to_domain($this), $msgid); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - public function _ngettext($singular, $plural, $number) { |
|
| 51 | - return _dngettext(PluginHost::object_to_domain($this), $singular, $plural, $number); |
|
| 52 | - } |
|
| 50 | + public function _ngettext($singular, $plural, $number) { |
|
| 51 | + return _dngettext(PluginHost::object_to_domain($this), $singular, $plural, $number); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - public function T_sprintf() { |
|
| 55 | - $args = func_get_args(); |
|
| 56 | - $msgid = array_shift($args); |
|
| 54 | + public function T_sprintf() { |
|
| 55 | + $args = func_get_args(); |
|
| 56 | + $msgid = array_shift($args); |
|
| 57 | 57 | |
| 58 | - return vsprintf($this->__($msgid), $args); |
|
| 59 | - } |
|
| 58 | + return vsprintf($this->__($msgid), $args); |
|
| 59 | + } |
|
| 60 | 60 | } |
@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class Handler_Protected extends Handler { |
| 3 | 3 | |
| 4 | - public function before($method) { |
|
| 5 | - return parent::before($method) && $_SESSION['uid']; |
|
| 6 | - } |
|
| 4 | + public function before($method) { |
|
| 5 | + return parent::before($method) && $_SESSION['uid']; |
|
| 6 | + } |
|
| 7 | 7 | } |
@@ -1,10 +1,10 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class FeedEnclosure { |
| 3 | - public $link; |
|
| 4 | - public $type; |
|
| 5 | - public $length; |
|
| 6 | - public $title; |
|
| 7 | - public $height; |
|
| 8 | - public $width; |
|
| 3 | + public $link; |
|
| 4 | + public $type; |
|
| 5 | + public $length; |
|
| 6 | + public $title; |
|
| 7 | + public $height; |
|
| 8 | + public $width; |
|
| 9 | 9 | } |
| 10 | 10 | |
@@ -1,4 +1,4 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | interface IAuthModule { |
| 3 | - public function authenticate($login, $password); // + optional third parameter: $service |
|
| 3 | + public function authenticate($login, $password); // + optional third parameter: $service |
|
| 4 | 4 | } |
@@ -1,23 +1,23 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class PluginHandler extends Handler_Protected { |
| 3 | - public function csrf_ignore($method) { |
|
| 4 | - return true; |
|
| 5 | - } |
|
| 3 | + public function csrf_ignore($method) { |
|
| 4 | + return true; |
|
| 5 | + } |
|
| 6 | 6 | |
| 7 | - public function catchall($method) { |
|
| 8 | - $plugin_name = clean($_REQUEST["plugin"]); |
|
| 9 | - $plugin = PluginHost::getInstance()->get_plugin($plugin_name); |
|
| 7 | + public function catchall($method) { |
|
| 8 | + $plugin_name = clean($_REQUEST["plugin"]); |
|
| 9 | + $plugin = PluginHost::getInstance()->get_plugin($plugin_name); |
|
| 10 | 10 | |
| 11 | - if ($plugin) { |
|
| 12 | - if (method_exists($plugin, $method)) { |
|
| 13 | - $plugin->$method(); |
|
| 14 | - } else { |
|
| 15 | - user_error("PluginHandler: Requested unknown method '$method' of plugin '$plugin_name'.", E_USER_WARNING); |
|
| 16 | - print error_json(13); |
|
| 17 | - } |
|
| 18 | - } else { |
|
| 19 | - user_error("PluginHandler: Requested method '$method' of unknown plugin '$plugin_name'.", E_USER_WARNING); |
|
| 20 | - print error_json(14); |
|
| 21 | - } |
|
| 22 | - } |
|
| 11 | + if ($plugin) { |
|
| 12 | + if (method_exists($plugin, $method)) { |
|
| 13 | + $plugin->$method(); |
|
| 14 | + } else { |
|
| 15 | + user_error("PluginHandler: Requested unknown method '$method' of plugin '$plugin_name'.", E_USER_WARNING); |
|
| 16 | + print error_json(13); |
|
| 17 | + } |
|
| 18 | + } else { |
|
| 19 | + user_error("PluginHandler: Requested method '$method' of unknown plugin '$plugin_name'.", E_USER_WARNING); |
|
| 20 | + print error_json(14); |
|
| 21 | + } |
|
| 22 | + } |
|
| 23 | 23 | } |
@@ -1,48 +1,48 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class Auth_Base { |
| 3 | - private $pdo; |
|
| 3 | + private $pdo; |
|
| 4 | 4 | |
| 5 | - const AUTH_SERVICE_API = '_api'; |
|
| 5 | + const AUTH_SERVICE_API = '_api'; |
|
| 6 | 6 | |
| 7 | - public function __construct() { |
|
| 8 | - $this->pdo = Db::pdo(); |
|
| 9 | - } |
|
| 7 | + public function __construct() { |
|
| 8 | + $this->pdo = Db::pdo(); |
|
| 9 | + } |
|
| 10 | 10 | |
| 11 | - // Auto-creates specified user if allowed by system configuration |
|
| 12 | - // Can be used instead of find_user_by_login() by external auth modules |
|
| 13 | - public function auto_create_user($login, $password = false) { |
|
| 14 | - if ($login && defined('AUTH_AUTO_CREATE') && AUTH_AUTO_CREATE) { |
|
| 15 | - $user_id = $this->find_user_by_login($login); |
|
| 11 | + // Auto-creates specified user if allowed by system configuration |
|
| 12 | + // Can be used instead of find_user_by_login() by external auth modules |
|
| 13 | + public function auto_create_user($login, $password = false) { |
|
| 14 | + if ($login && defined('AUTH_AUTO_CREATE') && AUTH_AUTO_CREATE) { |
|
| 15 | + $user_id = $this->find_user_by_login($login); |
|
| 16 | 16 | |
| 17 | - if (!$password) $password = make_password(); |
|
| 17 | + if (!$password) $password = make_password(); |
|
| 18 | 18 | |
| 19 | - if (!$user_id) { |
|
| 20 | - $salt = substr(bin2hex(get_random_bytes(125)), 0, 250); |
|
| 21 | - $pwd_hash = encrypt_password($password, $salt, true); |
|
| 19 | + if (!$user_id) { |
|
| 20 | + $salt = substr(bin2hex(get_random_bytes(125)), 0, 250); |
|
| 21 | + $pwd_hash = encrypt_password($password, $salt, true); |
|
| 22 | 22 | |
| 23 | - $sth = $this->pdo->prepare("INSERT INTO ttrss_users |
|
| 23 | + $sth = $this->pdo->prepare("INSERT INTO ttrss_users |
|
| 24 | 24 | (login,access_level,last_login,created,pwd_hash,salt) |
| 25 | 25 | VALUES (?, 0, null, NOW(), ?,?)"); |
| 26 | - $sth->execute([$login, $pwd_hash, $salt]); |
|
| 26 | + $sth->execute([$login, $pwd_hash, $salt]); |
|
| 27 | 27 | |
| 28 | - return $this->find_user_by_login($login); |
|
| 28 | + return $this->find_user_by_login($login); |
|
| 29 | 29 | |
| 30 | - } else { |
|
| 31 | - return $user_id; |
|
| 32 | - } |
|
| 33 | - } |
|
| 30 | + } else { |
|
| 31 | + return $user_id; |
|
| 32 | + } |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - return $this->find_user_by_login($login); |
|
| 36 | - } |
|
| 35 | + return $this->find_user_by_login($login); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - public function find_user_by_login($login) { |
|
| 39 | - $sth = $this->pdo->prepare("SELECT id FROM ttrss_users WHERE login = ?"); |
|
| 40 | - $sth->execute([$login]); |
|
| 38 | + public function find_user_by_login($login) { |
|
| 39 | + $sth = $this->pdo->prepare("SELECT id FROM ttrss_users WHERE login = ?"); |
|
| 40 | + $sth->execute([$login]); |
|
| 41 | 41 | |
| 42 | - if ($row = $sth->fetch()) { |
|
| 43 | - return $row["id"]; |
|
| 44 | - } else { |
|
| 45 | - return false; |
|
| 46 | - } |
|
| 47 | - } |
|
| 42 | + if ($row = $sth->fetch()) { |
|
| 43 | + return $row["id"]; |
|
| 44 | + } else { |
|
| 45 | + return false; |
|
| 46 | + } |
|
| 47 | + } |
|
| 48 | 48 | } |
@@ -14,7 +14,9 @@ |
||
| 14 | 14 | if ($login && defined('AUTH_AUTO_CREATE') && AUTH_AUTO_CREATE) { |
| 15 | 15 | $user_id = $this->find_user_by_login($login); |
| 16 | 16 | |
| 17 | - if (!$password) $password = make_password(); |
|
| 17 | + if (!$password) { |
|
| 18 | + $password = make_password(); |
|
| 19 | + } |
|
| 18 | 20 | |
| 19 | 21 | if (!$user_id) { |
| 20 | 22 | $salt = substr(bin2hex(get_random_bytes(125)), 0, 250); |