diff --git a/src/content/themes/default/index.php b/src/content/themes/default/index.php
index 2dfa2ab..4c9a958 100644
--- a/src/content/themes/default/index.php
+++ b/src/content/themes/default/index.php
@@ -31,6 +31,7 @@ $().ready(function(){
title: "",
lang: makeJS() ?>,
mttUrl: "",
+ homeUrl: "",
db: mytinytodoStorageAjax,
needAuth: ,
isLogged: ,
diff --git a/src/content/themes/ie8/index.php b/src/content/themes/ie8/index.php
index f1a3ce4..cd0d2df 100644
--- a/src/content/themes/ie8/index.php
+++ b/src/content/themes/ie8/index.php
@@ -1,7 +1,7 @@
-
+
@@ -30,6 +30,7 @@ $().ready(function(){
title: "",
lang: makeJS() ?>,
mttUrl: "",
+ homeUrl: "",
db: mytinytodoStorageAjax,
needAuth: ,
isLogged: ,
@@ -215,7 +216,7 @@ $().ready(function(){
-
+
@@ -229,8 +230,8 @@ $().ready(function(){
diff --git a/src/includes/common.php b/src/includes/common.php
index 89651a2..88b194c 100644
--- a/src/includes/common.php
+++ b/src/includes/common.php
@@ -193,13 +193,23 @@ function formatDate3($format, $ay, $am, $ad, $lang)
return strtr($format, array('Y'=>$Y, 'y'=>$y, 'F'=>$F, 'M'=>$M, 'n'=>$n, 'm'=>$m, 'd'=>$d, 'j'=>$j));
}
-function url_dir($url)
+function url_dir($url, $onlyPath = 1)
{
- if(false !== $p = strpos($url, '?')) $url = substr($url,0,$p); # to avoid parse errors on strange query strings
- $p = parse_url($url, PHP_URL_PATH);
- if($p == '') return '/';
- if(substr($p,-1) == '/') return $p;
- if(false !== $pos = strrpos($p,'/')) return substr($p,0,$pos+1);
+ if (false !== $p = strpos($url, '?')) {
+ $url = substr($url, 0, $p); # to avoid parse errors on strange query strings
+ }
+ if ($onlyPath) {
+ $url = parse_url($url, PHP_URL_PATH);
+ }
+ if ($url == '') {
+ return '/';
+ }
+ if (substr($url, -1) == '/') {
+ return $url;
+ }
+ if (false !== $p = strrpos($url, '/')) {
+ return substr($url, 0, $p+1);
+ }
return '/';
}
diff --git a/src/includes/mytinytodo.js b/src/includes/mytinytodo.js
index b3b9fa9..21273b0 100644
--- a/src/includes/mytinytodo.js
+++ b/src/includes/mytinytodo.js
@@ -49,6 +49,7 @@ var mytinytodo = window.mytinytodo = _mtt = {
actions: {},
menus: {},
mttUrl: '',
+ homeUrl: '',
options: {
title: '',
openList: 0,
@@ -122,6 +123,13 @@ var mytinytodo = window.mytinytodo = _mtt = {
this.db = new options.db(this);
delete options.db;
}
+ if (options.hasOwnProperty('homeUrl')) {
+ this.homeUrl = options.homeUrl;
+ delete options.homeUrl;
+ }
+ else {
+ this.homeUrl = this.mttUrl;
+ }
jQuery.extend(this.options, options);
@@ -2399,7 +2407,7 @@ function saveSettings(frm)
if(json.saved) {
flashInfo(_mtt.lang.get('settingsSaved'));
setTimeout( function(){
- window.location.assign(_mtt.mttUrl); //window.location.reload();
+ window.location.assign(_mtt.homeUrl); //window.location.reload();
}, 1000);
}
}, 'json');
diff --git a/src/init.php b/src/init.php
index e435956..b5bd32f 100644
--- a/src/init.php
+++ b/src/init.php
@@ -165,8 +165,10 @@ function get_unsafe_mttinfo($v)
$_mttinfo['includes_url'] = get_unsafe_mttinfo('mtt_url'). 'includes/';
return $_mttinfo['includes_url'];
case 'url':
- /* homepage, directory with root index.php. Used in external links. Have to be set in config if custom port is used or wrong detection. */
- $_mttinfo['url'] = Config::getUrl('url'); // need to have a trailing slash
+ /* full url to homepage: directory with root index.php or custom index file in the root. */
+ /* ex: http://my.site/mytinytodo/ or https://my.site/mytinytodo/home_for_2nd_theme.php */
+ /* Should not contain a query string. Have to be set in config if custom port is used or wrong detection. */
+ $_mttinfo['url'] = Config::getUrl('url');
if ($_mttinfo['url'] == '') {
$is_https = (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') ? true : false;
$_mttinfo['url'] = ($is_https ? 'https://' : 'http://'). $_SERVER['HTTP_HOST']. url_dir(getRequestUri());
@@ -182,10 +184,10 @@ function get_unsafe_mttinfo($v)
$_mttinfo['desktop_url'] = get_unsafe_mttinfo('url'). '?desktop';
return $_mttinfo['desktop_url'];
case 'mtt_url':
- /* directory with ajax.php */
+ /* Directory with ajax.php. No need to set if you use default directory structure. */
$_mttinfo['mtt_url'] = Config::getUrl('mtt_url'); // need to have a trailing slash
if ($_mttinfo['mtt_url'] == '') {
- $_mttinfo['mtt_url'] = url_dir(getRequestUri());
+ $_mttinfo['mtt_url'] = url_dir( get_unsafe_mttinfo('url'), 0 );
}
return $_mttinfo['mtt_url'];
case 'title':
@@ -205,6 +207,12 @@ function get_mttinfo($v)
return htmlspecialchars( get_unsafe_mttinfo($v) );
}
+function reset_mttinfo($key)
+{
+ global $_mttinfo;
+ unset( $_mttinfo[$key] );
+}
+
function getRequestUri()
{
// Do not use HTTP_X_REWRITE_URL due to CVE-2018-14773