From 6d5cc010394b6d28c9292fc67d2756ff82438da7 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 17 Oct 2012 18:22:17 +0200 Subject: [PATCH] Added isInternalURL() to ApplicationHandler --- .../application/ApplicationHandler.class.php | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/lib/system/application/ApplicationHandler.class.php b/wcfsetup/install/files/lib/system/application/ApplicationHandler.class.php index 66f8f3c411..d8a6b556b1 100644 --- a/wcfsetup/install/files/lib/system/application/ApplicationHandler.class.php +++ b/wcfsetup/install/files/lib/system/application/ApplicationHandler.class.php @@ -2,12 +2,13 @@ namespace wcf\system\application; use wcf\system\cache\CacheHandler; use wcf\system\SingletonFactory; +use wcf\util\StringUtil; /** * Handles multi-application environments. * * @author Alexander Ebert - * @copyright 2001-20121 WoltLab GmbH + * @copyright 2001-2012 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage system.application @@ -20,6 +21,12 @@ class ApplicationHandler extends SingletonFactory { */ protected $cache = null; + /** + * list of page URLs + * @var array + */ + protected $pageURLs = array(); + /** * Initializes cache. */ @@ -137,4 +144,33 @@ class ApplicationHandler extends SingletonFactory { return null; } + + /** + * Returns true, if given $url is an internal URL. + * + * @param string $url + * @return boolean + */ + public function isInternalURL($url) { + if (empty($this->pageURLs)) { + foreach ($this->getApplications() as $application) { + $this->pageURLs[] = $application->getPageURL(); + } + + if (defined('PAGE_URLS') && PAGE_URLS != '') { + $pageURLs = explode("\n", StringUtil::unifyNewlines(PAGE_URLS)); + foreach ($pageURLs as $url) { + $this->pageURLs[] = StringUtil::trim($url); + } + } + } + + foreach ($this->pageURLs as $pageURL) { + if (stripos($url, $pageURL) === 0) { + return true; + } + } + + return false; + } } -- 2.20.1