* @property-read integer $packageID id of the package which delivers the application
* @property-read string $domainName domain used to access the application (may not contain path components, see `$domainPath`)
* @property-read string $domainPath path used to access the application
- * @property-read string $cookieDomain domain used to set cookies (corresponds to `domain` cookie property; may not contain path components, see `$cookiePath`)
- * @property-read string $cookiePath path of the cookie (corresponds to `path` cookie property)
+ * @property-read string $cookieDomain domain used to set cookies (corresponds to `domain` cookie property; may not contain path components)
* @property-read integer $isTainted is `1` if the application is being uninstalled and thus should not be loaded during uninstallation, otherwise `0`
*/
class Application extends DatabaseObject {
public $applicationEditor;
/**
- * Assigns a list of applications to a group and computes cookie domain and path.
+ * Assigns a list of applications to a group and computes cookie domain.
*/
public function rebuild() {
if (empty($this->objects)) {
}
$sql = "UPDATE wcf".WCF_N."_application
- SET cookieDomain = ?,
- cookiePath = ?
+ SET cookieDomain = ?
WHERE packageID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
- // calculate cookie path
- $domains = [];
+ // calculate cookie domain
$regex = new Regex(':[0-9]+');
+ WCF::getDB()->beginTransaction();
foreach ($this->getObjects() as $application) {
$domainName = $application->domainName;
if (StringUtil::endsWith($regex->replace($domainName, ''), $application->cookieDomain)) {
$domainName = $application->cookieDomain;
}
- if (!isset($domains[$domainName])) {
- $domains[$domainName] = [];
- }
-
- $domains[$domainName][$application->packageID] = explode('/', FileUtil::removeLeadingSlash(FileUtil::removeTrailingSlash($application->domainPath)));
- }
-
- WCF::getDB()->beginTransaction();
- foreach ($domains as $domainName => $data) {
- $path = null;
- foreach ($data as $domainPath) {
- if ($path === null) {
- $path = $domainPath;
- }
- else {
- foreach ($path as $i => $part) {
- if (!isset($domainPath[$i]) || $domainPath[$i] != $part) {
- // remove all following elements including current one
- foreach ($path as $j => $innerPart) {
- if ($j >= $i) {
- unset($path[$j]);
- }
- }
-
- // skip to next domain
- continue 2;
- }
- }
- }
- }
-
- $path = FileUtil::addLeadingSlash(FileUtil::addTrailingSlash(implode('/', $path)));
-
- foreach (array_keys($data) as $packageID) {
- $statement->execute([
- $domainName,
- $path,
- $packageID
- ]);
- }
+ $statement->execute([
+ $domainName,
+ $application->packageID
+ ]);
}
WCF::getDB()->commitTransaction();
'domainName' => $host,
'domainPath' => $path,
'cookieDomain' => $host,
- 'cookiePath' => $path,
'packageID' => $package->packageID
]);
}
// update application path
$application = new Application($this->getPackage()->packageID);
$applicationEditor = new ApplicationEditor($application);
- $applicationEditor->update([
- 'domainPath' => $domainPath,
- 'cookiePath' => $domainPath
- ]);
+ $applicationEditor->update(['domainPath' => $domainPath]);
// create directory and set permissions
@mkdir($packageDir, 0777, true);
$application = ApplicationHandler::getInstance()->getActiveApplication();
$addDomain = (mb_strpos($application->cookieDomain, '.') === false || StringUtil::endsWith($application->cookieDomain, '.lan') || StringUtil::endsWith($application->cookieDomain, '.local')) ? false : true;
- @header('Set-Cookie: '.rawurlencode(COOKIE_PREFIX.$name).'='.rawurlencode($value).($expire ? '; expires='.gmdate('D, d-M-Y H:i:s', $expire).' GMT; max-age='.($expire - TIME_NOW) : '').'; path='.$application->cookiePath.($addDomain ? '; domain='.$application->cookieDomain : '').(RouteHandler::secureConnection() ? '; secure' : '').'; HttpOnly', false);
+ @header('Set-Cookie: '.rawurlencode(COOKIE_PREFIX.$name).'='.rawurlencode($value).($expire ? '; expires='.gmdate('D, d-M-Y H:i:s', $expire).' GMT; max-age='.($expire - TIME_NOW) : '').'; path=/'.($addDomain ? '; domain='.$application->cookieDomain : '').(RouteHandler::secureConnection() ? '; secure' : '').'; HttpOnly', false);
}
/**
domainName VARCHAR(255) NOT NULL,
domainPath VARCHAR(255) NOT NULL DEFAULT '/',
cookieDomain VARCHAR(255) NOT NULL,
- cookiePath VARCHAR(255) NOT NULL DEFAULT '/',
isTainted TINYINT(1) NOT NULL DEFAULT 0
);