From ced75b805a3a280e456298d7f23c8cd520b8bb67 Mon Sep 17 00:00:00 2001 From: maxpozdeev Date: Fri, 24 Mar 2023 18:51:46 +0300 Subject: [PATCH] can setup web api url to use PATH_INFO --- src/docker-config.php | 4 ++++ src/includes/classes.php | 2 +- src/index.php | 2 +- src/init.php | 7 ++++++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/docker-config.php b/src/docker-config.php index 0d2d954..7b810be 100644 --- a/src/docker-config.php +++ b/src/docker-config.php @@ -17,3 +17,7 @@ else if (getenv('MTT_DB_TYPE') == 'sqlite') { } define("MTT_SALT", "Put Random Text Here"); +//define("MTT_DISABLE_EXT", 1); +if (getenv('MTT_API_USE_PATH_INFO')) { + define("MTT_API_USE_PATH_INFO", 1); +} diff --git a/src/includes/classes.php b/src/includes/classes.php index be2685a..dec7f1d 100644 --- a/src/includes/classes.php +++ b/src/includes/classes.php @@ -14,7 +14,7 @@ class ApiRequest public $jsonBody; function __construct() { - if (defined('MTT_API_USE_PATH_INFO') && MTT_API_USE_PATH_INFO) { + if (defined('MTT_API_USE_PATH_INFO')) { $this->path = $_SERVER['PATH_INFO']; } else { diff --git a/src/index.php b/src/index.php index 5b90d96..c5d0ecd 100644 --- a/src/index.php +++ b/src/index.php @@ -79,7 +79,7 @@ function js_options() "lang" => Lang::instance()->jsStrings(), "mttUrl" => get_mttinfo('mtt_url'), "homeUrl" => get_mttinfo('url'), -// "apiUrl" => get_mttinfo('api_url'), + "apiUrl" => get_mttinfo('api_url'), "needAuth" => need_auth() ? true : false, "isLogged" => is_logged() ? true : false, "showdate" => Config::get('showdate') ? true : false, diff --git a/src/init.php b/src/init.php index 1d9bac1..ea8a145 100644 --- a/src/init.php +++ b/src/init.php @@ -352,7 +352,12 @@ function get_unsafe_mttinfo($v) /* URL for API, like http://localhost/mytinytodo/api/. No need to set by default. */ $_mttinfo['api_url'] = Config::getUrl('api_url'); // need to have a trailing slash if ($_mttinfo['api_url'] == '') { - $_mttinfo['api_url'] = get_unsafe_mttinfo('mtt_url'). 'api.php?_path=/'; + if (defined('MTT_API_USE_PATH_INFO')) { + $_mttinfo['api_url'] = get_unsafe_mttinfo('mtt_url'). 'api/'; + } + else { + $_mttinfo['api_url'] = get_unsafe_mttinfo('mtt_url'). 'api.php?_path=/'; + } } return $_mttinfo['api_url']; case 'title':