From 6af83e3881b3f38104027275913f7fc55251d020 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 12 Feb 2021 21:43:38 +0300 Subject: drop ENABLE_GZIP_OUTPUT; system prefs: load php info only if needed --- api/index.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'api/index.php') diff --git a/api/index.php b/api/index.php index 77552af46..9e998df84 100644 --- a/api/index.php +++ b/api/index.php @@ -22,13 +22,7 @@ ini_set('session.use_cookies', 0); ini_set("session.gc_maxlifetime", 86400); - if (defined('ENABLE_GZIP_OUTPUT') && ENABLE_GZIP_OUTPUT && - function_exists("ob_gzhandler")) { - - ob_start("ob_gzhandler"); - } else { - ob_start(); - } + ob_start(); $input = file_get_contents("php://input"); -- cgit v1.2.3 From 9f55454f63b11ad8d2b2e0a8264a0f0dae919f6b Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 15 Feb 2021 16:51:35 +0300 Subject: remove the rest of db.php; rename some leftover methods in feeds --- api/index.php | 1 - 1 file changed, 1 deletion(-) (limited to 'api/index.php') diff --git a/api/index.php b/api/index.php index 9e998df84..664e92abe 100644 --- a/api/index.php +++ b/api/index.php @@ -14,7 +14,6 @@ define('NO_SESSION_AUTOSTART', true); require_once "autoload.php"; - require_once "db.php"; require_once "db-prefs.php"; require_once "functions.php"; require_once "sessions.php"; -- cgit v1.2.3 From 9d7ba773ec97bfb44601348c07e818f1a1d2c841 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 16 Feb 2021 17:13:16 +0300 Subject: move session-related functions to their own namespace --- api/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'api/index.php') diff --git a/api/index.php b/api/index.php index 664e92abe..eb79422f9 100644 --- a/api/index.php +++ b/api/index.php @@ -50,7 +50,7 @@ if (!init_plugins()) return; if (!empty($_SESSION["uid"])) { - if (!validate_session()) { + if (!\Sessions\validate_session()) { header("Content-Type: text/json"); print json_encode(array("seq" => -1, -- cgit v1.2.3 From be4e7b13403666fc477d4b563ea8c075d0fd2022 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 22 Feb 2021 14:41:09 +0300 Subject: fix several issues reported by phpstan --- api/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'api/index.php') diff --git a/api/index.php b/api/index.php index eb79422f9..1b713d561 100644 --- a/api/index.php +++ b/api/index.php @@ -18,8 +18,8 @@ require_once "functions.php"; require_once "sessions.php"; - ini_set('session.use_cookies', 0); - ini_set("session.gc_maxlifetime", 86400); + ini_set('session.use_cookies', "0"); + ini_set("session.gc_maxlifetime", "86400"); ob_start(); -- cgit v1.2.3 From 42173386b39bed4b06c5ac6c2fc0da510673b354 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 22 Feb 2021 17:38:46 +0300 Subject: dirname(__FILE__) -> __DIR__ --- api/index.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'api/index.php') diff --git a/api/index.php b/api/index.php index 1b713d561..6b0071141 100644 --- a/api/index.php +++ b/api/index.php @@ -3,9 +3,9 @@ require_once "../config.php"; - set_include_path(dirname(__FILE__) . PATH_SEPARATOR . - dirname(dirname(__FILE__)) . PATH_SEPARATOR . - dirname(dirname(__FILE__)) . "/include" . PATH_SEPARATOR . + set_include_path(__DIR__ . PATH_SEPARATOR . + dirname(__DIR__) . PATH_SEPARATOR . + dirname(__DIR__) . "/include" . PATH_SEPARATOR . get_include_path()); chdir(".."); -- cgit v1.2.3 From 12bcf826e4f2672afbda85264a970fb4735d97f1 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 22 Feb 2021 22:39:20 +0300 Subject: don't include config.php everywhere --- api/index.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'api/index.php') diff --git a/api/index.php b/api/index.php index 6b0071141..333c64830 100644 --- a/api/index.php +++ b/api/index.php @@ -1,8 +1,6 @@ Date: Mon, 22 Feb 2021 23:25:14 +0300 Subject: move db-prefs shortcut functions to functions.php --- api/index.php | 1 - 1 file changed, 1 deletion(-) (limited to 'api/index.php') diff --git a/api/index.php b/api/index.php index 333c64830..d1e02bbd4 100644 --- a/api/index.php +++ b/api/index.php @@ -12,7 +12,6 @@ define('NO_SESSION_AUTOSTART', true); require_once "autoload.php"; - require_once "db-prefs.php"; require_once "functions.php"; require_once "sessions.php"; -- cgit v1.2.3 From 2ae0b7059f2ed56b92a8f396c63224b36f71df09 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 23 Feb 2021 09:01:27 +0300 Subject: cleanup some defined-stuff --- api/index.php | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'api/index.php') diff --git a/api/index.php b/api/index.php index d1e02bbd4..4e2c06b9d 100644 --- a/api/index.php +++ b/api/index.php @@ -8,7 +8,6 @@ chdir(".."); - define('TTRSS_SESSION_NAME', 'ttrss_api_sid'); define('NO_SESSION_AUTOSTART', true); require_once "autoload.php"; @@ -20,26 +19,11 @@ ob_start(); - $input = file_get_contents("php://input"); - - if (defined('_API_DEBUG_HTTP_ENABLED') && _API_DEBUG_HTTP_ENABLED) { - // Override $_REQUEST with JSON-encoded data if available - // fallback on HTTP parameters - if ($input) { - $input = json_decode($input, true); - if ($input) $_REQUEST = $input; - } - } else { - // Accept JSON only - $input = json_decode((string)$input, true); - $_REQUEST = $input; - } + $_REQUEST = json_decode((string)file_get_contents("php://input"), true); if (!empty($_REQUEST["sid"])) { session_id($_REQUEST["sid"]); @session_start(); - } else if (defined('_API_DEBUG_HTTP_ENABLED')) { - @session_start(); } startup_gettext(); -- cgit v1.2.3 From 8d2e3c2528e67f8650c122f014364a34bf690d2a Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 23 Feb 2021 22:26:07 +0300 Subject: drop errors.php and simplify error handling --- api/index.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'api/index.php') diff --git a/api/index.php b/api/index.php index 4e2c06b9d..d85a1103c 100644 --- a/api/index.php +++ b/api/index.php @@ -34,9 +34,11 @@ if (!\Sessions\validate_session()) { header("Content-Type: text/json"); - print json_encode(array("seq" => -1, - "status" => 1, - "content" => array("error" => "NOT_LOGGED_IN"))); + print json_encode([ + "seq" => -1, + "status" => API::STATUS_ERR, + "content" => [ "error" => API::E_NOT_LOGGED_IN ] + ]); return; } -- cgit v1.2.3