#43 DATA_PATH corrected with root dir

1.3.x
closed
None
5
2012-10-11
2002-12-19
No

Hello,

if you put the phpwiki in the root-dir of your domain, then
the DATA_PATH is set to '/'.
This causes some trouble with the CSS-Path of the
themes, beacuse they assumed, that the DATA_PATH
has NO slash at the end!

The reason is the behaviour of dirname. This function
has changed in PHP 4.0.3. Now it may also return an
slash at the end.

Here is a fix for the DATA_PATH definition in config.php:

Replase in lib/config.php the line
<old>
if (!defined('DATA_PATH')) define('DATA_PATH',
dirname(SCRIPT_NAME));
</old>

with this
<new>
if (!defined('DATA_PATH')) {
// WARNING: dirname changed in PHP 4.0.3!
// It may now return a slash at the end!

$temp = dirname(SCRIPT_NAME);
// Check if the dir-name contains a '/' or '\' in the last
character
// If it has one, remove it
// If the DATA_PATH has a '/' or '\' at the end, then the
CSS-Path is returned wrong!

if ( strchr($temp, '/') == strlen($temp)-1)
$temp = substr($temp, 1, strlen($temp)-1);

if (strchr($temp, '\') == strlen($temp)-1)
$temp = substr($temp, 1, strlen($temp)-1);

// If the string is now empty, we return a dot.
if (strlen($temp) <= 0)
$temp = '.';

define('DATA_PATH', $temp);
}
</new>

Greetings
Jochen

Discussion

  • Jochen Kalmbach

    Jochen Kalmbach - 2002-12-19

    Logged In: YES
    user_id=509272

    It is better to return an empty string instad of '.'... (like the old
    dirname behaviour).

    <new>
    if (!defined('DATA_PATH')) {
    // WARNING: dirname changed in PHP 4.0.3!
    // It may now return a slash at the end!

    $temp = dirname(SCRIPT_NAME);
    // Check if the dir-name contains a '/' or '\' in the last
    character
    // If it has one, remove it
    // If the DATA_PATH has a '/' or '\' at the end, then the
    CSS-Path is returned wrong!

    if ( strchr($temp, '/') == strlen($temp)-1)
    $temp = substr($temp, 1, strlen($temp)-1);

    if (strchr($temp, '\') == strlen($temp)-1)
    $temp = substr($temp, 1, strlen($temp)-1);

    define('DATA_PATH', $temp);
    }
    </new>

    Greetings
    Jochen

     
  • Reini Urban

    Reini Urban - 2004-05-02

    Logged In: YES
    user_id=13755

    fixed in current CVS

     

Log in to post a comment.