protected function getURIVars()
 {
     $baseurl = getWebserverPath('.');
     $url = trim(substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], $baseurl) + strlen($baseurl)), '/');
     $parts = explode('/', $url);
     $vars = array();
     switch (count($parts)) {
         case 0:
             return $_GET;
         case 1:
             return array_merge($_GET, array('page' => $parts[0]));
         default:
             $vars['page'] = array_shift($parts);
     }
     $parts = array_chunk($parts, 2);
     foreach ($parts as $part) {
         if ($part[0]) {
             $part += array(NULL, NULL);
             $vars[$part[0]] = $part[1];
         }
     }
     $vars = array_merge($vars, $_GET);
     return $vars;
 }
Beispiel #2
0
<?php

$GLOBALS['start'] = microtime(TRUE);
include 'system/helpers/bootstrap.php';
Config::set('base_path', __DIR__);
Config::set('webroot', getWebserverPath(__DIR__));
Config::set('profiler_enable', FALSE);
Registry::set('db', new PDOV('orion', 'db', 'db', 'CMS7', 'mysql'));
Registry::get('db')->log_queries = Config::get('profiler_enable');
CMS7_Content_Cache::initCache(new CMS7_Memcached('localhost', '11211'));
$controller = new Controller();
$controller->route();
include 'system/helpers/profiler.php';
<?php

$target_path = '/var/www/test2/index.php';
echo getWebserverPath($target_path);
function getWebserverPath($target_path)
{
    $target_path = realpath($target_path);
    $webserver_path = dirname($_SERVER['SCRIPT_NAME']);
    $local_path = dirname($_SERVER['SCRIPT_FILENAME']);
    $webserver_path_elem = explode('/', ltrim($webserver_path, '/'));
    $local_path_elem = explode(DIRECTORY_SEPARATOR, ltrim($local_path, DIRECTORY_SEPARATOR));
    end($webserver_path_elem);
    end($local_path_elem);
    do {
        if (current($webserver_path_elem) == current($local_path_elem)) {
            array_pop($local_path_elem);
            array_pop($webserver_path_elem);
        }
    } while (prev($webserver_path_elem) && prev($local_path_elem));
    $local_webserver_root = '/' . implode('/', $local_path_elem);
    if (strpos($target_path, $local_webserver_root) !== FALSE) {
        $target_path = implode('/', $webserver_path_elem) . str_replace($local_webserver_root, '', $target_path);
    } else {
        trigger_error('Target path is outside webroot');
        return FALSE;
    }
    return $target_path;
}