summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Prodromou <evan@controlyourself.ca>2009-06-18 16:19:26 -0700
committerEvan Prodromou <evan@controlyourself.ca>2009-06-18 16:19:26 -0700
commit597df6a2345ad61e7e0f21277d97866bdb2116a4 (patch)
tree4ae37107909b2ccd870535d4ed050bcb24a9f608
parent68b34b32667025b6d3ab74c0a6b5b356d1f24b10 (diff)
better calculation of path
-rw-r--r--lib/common.php14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/common.php b/lib/common.php
index eb8a2b873..702da8235 100644
--- a/lib/common.php
+++ b/lib/common.php
@@ -55,13 +55,25 @@ require_once(INSTALLDIR.'/lib/language.php');
require_once(INSTALLDIR.'/lib/event.php');
require_once(INSTALLDIR.'/lib/plugin.php');
+function _sn_to_path($sn)
+{
+ $past_root = substr($sn, 1);
+ $last_slash = strrpos($past_root, '/');
+ if ($last_slash > 0) {
+ $p = substr($past_root, 0, $last_slash);
+ } else {
+ $p = '';
+ }
+ return $p;
+}
+
// try to figure out where we are
$_server = array_key_exists('SERVER_NAME', $_SERVER) ?
strtolower($_SERVER['SERVER_NAME']) :
null;
$_path = array_key_exists('SCRIPT_NAME', $_SERVER) ?
- substr($_SERVER['SCRIPT_NAME'], 1, strrpos($_SERVER['SCRIPT_NAME'], '/') - 1) :
+ _sn_to_path($_SERVER['SCRIPT_NAME']) :
null;
// default configuration, overwritten in config.php