}
else {
// resolve path relative to document root
- $relativePath = str_replace(FileUtil::unifyDirSeparator($_SERVER['DOCUMENT_ROOT']), '', FileUtil::unifyDirSeparator(INSTALL_SCRIPT_DIR));
+ $relativePath = FileUtil::getRelativePath($_SERVER['DOCUMENT_ROOT'], INSTALL_SCRIPT_DIR);
foreach ($packages as $application => $packageData) {
self::$directories[$application] = $relativePath . ($application === 'wcf' ? '' : $packageData['directory'] . '/');
}
}
else {
// regular file
- $fileInserts[] = str_replace(WCF_DIR, '', $file);
+ $fileInserts[] = preg_replace('/^'.preg_quote(WCF_DIR, '/').'/', '', $file);
}
}
$wcfDomainPath = $row['domainPath'];
}
- $documentRoot = str_replace($wcfDomainPath, '', FileUtil::unifyDirSeparator(WCF_DIR));
- $domainPath = str_replace($documentRoot, '', $packageDir);
+ $documentRoot = '';
+
+ // strip longest common suffix
+ $a = strrev(FileUtil::unifyDirSeparator($wcfDomainPath));
+ $b = strrev($documentRoot = FileUtil::unifyDirSeparator(WCF_DIR));
+ for ($i = 0, $max = min(strlen($a), strlen($b)); $i < $max; $i++) {
+ if ($a{$i} !== $b{$i}) {
+ $documentRoot = substr(strrev($b), 0, -$i);
+ break;
+ }
+ }
+
+ $domainPath = FileUtil::addLeadingSlash(FileUtil::getRelativePath($documentRoot, $packageDir));
// update application path
$application = new Application($this->getPackage()->packageID);