From 5ad4b37c1906906fa138755fa072c96ca7bdc9a9 Mon Sep 17 00:00:00 2001 From: Max Pozdeev Date: Sat, 6 Feb 2010 17:51:44 +0300 Subject: [PATCH] - bugfix: mytinytodo was not working when opened like 'path/index.php' --- src/common.php | 9 +++++++++ src/index.php | 8 ++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/common.php b/src/common.php index bd289d7..c6dc061 100644 --- a/src/common.php +++ b/src/common.php @@ -140,4 +140,13 @@ function formatDate3($format, $ay, $am, $ad, $lang) return strtr($format, array('Y'=>$Y, 'F'=>$F, 'M'=>$M, 'n'=>$n, 'm'=>$m, 'd'=>$d, 'j'=>$j)); } +function url_dir($url) +{ + $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); + return '/'; +} + ?> \ No newline at end of file diff --git a/src/index.php b/src/index.php index eeaf965..3e5ce76 100644 --- a/src/index.php +++ b/src/index.php @@ -46,13 +46,13 @@ function get_mttinfo($v) switch($v) { case 'template_uri': - $_mttinfo['template_uri'] = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH). 'themes/'. Config::get('template') . '/'; + $_mttinfo['template_uri'] = url_dir($_SERVER['REQUEST_URI']). 'themes/'. Config::get('template') . '/'; return $_mttinfo['template_uri']; case 'template_url': - $_mttinfo['template_url'] = get_mttinfo('siteurl'). 'themes/'. Config::get('template') . '/'; + $_mttinfo['template_url'] = get_mttinfo('url'). 'themes/'. Config::get('template') . '/'; return $_mttinfo['template_url']; - case 'siteurl': - $_mttinfo['siteurl'] = 'http://'.$_SERVER['HTTP_HOST'] .($_SERVER['SERVER_PORT'] != 80 ? ':'.$_SERVER['SERVER_PORT'] : ''). parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); + case 'url': + $_mttinfo['siteurl'] = 'http://'.$_SERVER['HTTP_HOST'] .($_SERVER['SERVER_PORT'] != 80 ? ':'.$_SERVER['SERVER_PORT'] : ''). url_dir($_SERVER['REQUEST_URI']); return $_mttinfo['siteurl']; case 'title': $_mttinfo['title'] = (Config::get('title') != '') ? htmlarray(Config::get('title')) : $lang->get('My Tiny Todolist');