[dev] $webroot & symlinks

Stuart Bingë s.binge at codefusion.co.za
Thu Jun 3 03:53:16 PDT 2004


With regards to the new dynamically calculated $webroot variable; it has been 
noted on the Kolab lists that the current calculation scheme does not 
properly handle symlinks when they are used as the horde webroot.

I've done some experimentation around the issue and found the following code 
to provide a reasonable solution. The reason I'm not commiting this is that I 
am not entirely sure it will work with other setups; so far I've only tested 
it on my system - there is a '/horde' symlink in my document root directory 
pointing to my horde installation. Another reason is that it is not the most 
efficient code :-). Perhaps if registry.php is cached, as has been discussed 
previously on the list, this solution would be viable.

Comments would be appreciated.

<?php
// horde/config/registry.php.dist

if (isset($_SERVER['PHP_SELF'])) {
    $webroot = strstr(dirname(__FILE__), '/' . array_shift(preg_split(';/;',
        $_SERVER['PHP_SELF'], 2, PREG_SPLIT_NO_EMPTY)));
    $webroot = ($webroot !== false ? preg_replace(';/config$;', '',
        $webroot) : '/horde');
} else {
    $webroot = '/horde';
}

-- 
Stuart Bingë
Code Fusion cc.

Office: +27 11 673 0411
Mobile: +27 83 298 9727
Email: s.binge at codefusion.co.za

Tailored email solutions; Kolab specialists.
http://www.codefusion.co.za/


More information about the dev mailing list