mirror of
https://github.com/maxpozdeev/mytinytodo.git
synced 2026-03-11 08:55:27 +00:00
* do not use PATH_INFO in http api by default
This commit is contained in:
parent
3daa661adb
commit
11d2ad4139
4 changed files with 5 additions and 15 deletions
|
|
@ -151,7 +151,7 @@ var mytinytodo = window.mytinytodo = _mtt = {
|
|||
delete options.apiUrl;
|
||||
}
|
||||
else {
|
||||
this.apiUrl = this.mttUrl + 'api.php/';
|
||||
this.apiUrl = this.mttUrl + 'api.php?_path=/';
|
||||
}
|
||||
if (options.hasOwnProperty('db')) {
|
||||
delete options.db;
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ MytinytodoAjaxApi.prototype =
|
|||
if (params.setCompl && params.setCompl != 0) q += '&setCompl=1';
|
||||
if (params.saveSort && params.saveSort != 0) q += '&saveSort=1';
|
||||
|
||||
$.getJSON(mtt.apiUrl + 'tasks?list='+params.list+'&compl='+params.compl+'&sort='+params.sort+q, callback);
|
||||
$.getJSON(mtt.apiUrl + 'tasks' + (mtt.apiUrl.indexOf('?') > -1 ? '&' : '?') + 'list='+params.list+'&compl='+params.compl+'&sort='+params.sort+q, callback);
|
||||
},
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -14,21 +14,11 @@ class ApiRequest
|
|||
public $jsonBody;
|
||||
|
||||
function __construct() {
|
||||
if (isset($_SERVER['PATH_INFO'])) {
|
||||
if (defined('MTT_API_USE_PATH_INFO') && MTT_API_USE_PATH_INFO) {
|
||||
$this->path = $_SERVER['PATH_INFO'];
|
||||
}
|
||||
else {
|
||||
$uri = $_SERVER['REQUEST_URI'];
|
||||
if (false !== $p = strpos($uri, '?')) {
|
||||
$uri = substr($uri, 0, $p);
|
||||
}
|
||||
$script = $_SERVER['SCRIPT_NAME'];
|
||||
if (0 === $p = strpos($uri, $script)) {
|
||||
$this->path = substr($uri, strlen($script));
|
||||
}
|
||||
else {
|
||||
$this->path = '';
|
||||
}
|
||||
$this->path = $_GET['_path'] ?? '';
|
||||
}
|
||||
$this->method = isset($_SERVER['REQUEST_METHOD']) ? strtoupper($_SERVER['REQUEST_METHOD']) : 'GET';
|
||||
$this->contentType = $_SERVER['CONTENT_TYPE'] ?? '';
|
||||
|
|
|
|||
|
|
@ -349,7 +349,7 @@ 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/';
|
||||
$_mttinfo['api_url'] = get_unsafe_mttinfo('mtt_url'). 'api.php?_path=/';
|
||||
}
|
||||
return $_mttinfo['api_url'];
|
||||
case 'title':
|
||||
|
|
|
|||
Loading…
Reference in a new issue