From 909b697f70f26c5e9835cbfa7076b0e7c6089c67 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 11 Aug 2014 00:24:57 +0200 Subject: [PATCH] Added URL corrections --- com.woltlab.wcf/templates/editHistory.tpl | 2 +- com.woltlab.wcf/templates/membersList.tpl | 2 +- com.woltlab.wcf/templates/usersOnlineList.tpl | 2 +- .../files/acp/templates/dataImport.tpl | 2 +- .../files/acp/templates/exceptionLogView.tpl | 2 +- .../files/acp/templates/templateDiff.tpl | 2 +- .../files/lib/form/LoginForm.class.php | 5 ++ .../install/files/lib/form/MailForm.class.php | 2 + .../files/lib/page/AbstractPage.class.php | 90 ++++++++++++++++--- .../files/lib/page/AttachmentPage.class.php | 7 ++ .../files/lib/page/MembersListPage.class.php | 7 ++ .../install/files/lib/page/UserPage.class.php | 2 + .../lib/page/UsersOnlineListPage.class.php | 6 ++ 13 files changed, 112 insertions(+), 19 deletions(-) diff --git a/com.woltlab.wcf/templates/editHistory.tpl b/com.woltlab.wcf/templates/editHistory.tpl index cdd73d9607..1fc8253ebb 100644 --- a/com.woltlab.wcf/templates/editHistory.tpl +++ b/com.woltlab.wcf/templates/editHistory.tpl @@ -53,7 +53,7 @@ {/if} -
+
{assign var='versionCount' value=$objects|count} diff --git a/com.woltlab.wcf/templates/membersList.tpl b/com.woltlab.wcf/templates/membersList.tpl index 4eeb957380..f98c3d5c27 100644 --- a/com.woltlab.wcf/templates/membersList.tpl +++ b/com.woltlab.wcf/templates/membersList.tpl @@ -68,7 +68,7 @@
- +
diff --git a/com.woltlab.wcf/templates/usersOnlineList.tpl b/com.woltlab.wcf/templates/usersOnlineList.tpl index 3b05477753..90bb553f5e 100644 --- a/com.woltlab.wcf/templates/usersOnlineList.tpl +++ b/com.woltlab.wcf/templates/usersOnlineList.tpl @@ -32,7 +32,7 @@ {capture assign='sidebar'}
- +
diff --git a/wcfsetup/install/files/acp/templates/dataImport.tpl b/wcfsetup/install/files/acp/templates/dataImport.tpl index 999fe73c41..de937ef16a 100644 --- a/wcfsetup/install/files/acp/templates/dataImport.tpl +++ b/wcfsetup/install/files/acp/templates/dataImport.tpl @@ -91,7 +91,7 @@ {/if} - +
{lang}wcf.acp.dataImport.selectExporter{/lang} diff --git a/wcfsetup/install/files/acp/templates/exceptionLogView.tpl b/wcfsetup/install/files/acp/templates/exceptionLogView.tpl index c764877962..1626fdebe1 100644 --- a/wcfsetup/install/files/acp/templates/exceptionLogView.tpl +++ b/wcfsetup/install/files/acp/templates/exceptionLogView.tpl @@ -27,7 +27,7 @@ {include file='formError'} {if !$logFiles|empty} - +
{lang}wcf.acp.exceptionLog.search{/lang}
diff --git a/wcfsetup/install/files/acp/templates/templateDiff.tpl b/wcfsetup/install/files/acp/templates/templateDiff.tpl index fb58acdae7..2b516ac5f1 100644 --- a/wcfsetup/install/files/acp/templates/templateDiff.tpl +++ b/wcfsetup/install/files/acp/templates/templateDiff.tpl @@ -6,7 +6,7 @@ {include file='formError'} - +
{lang}wcf.acp.template.group{/lang} diff --git a/wcfsetup/install/files/lib/form/LoginForm.class.php b/wcfsetup/install/files/lib/form/LoginForm.class.php index 6946c567f7..b7389c4da8 100644 --- a/wcfsetup/install/files/lib/form/LoginForm.class.php +++ b/wcfsetup/install/files/lib/form/LoginForm.class.php @@ -101,5 +101,10 @@ class LoginForm extends \wcf\acp\form\LoginForm { if (mb_strpos($this->url, '?') !== false) $this->url .= SID_ARG_2ND_NOT_ENCODED; else $this->url .= SID_ARG_1ST; } + + // drop index.php + if (!URL_LEGACY_MODE) { + $this->url = preg_replace('~index\.php~', '', $this->url); + } } } diff --git a/wcfsetup/install/files/lib/form/MailForm.class.php b/wcfsetup/install/files/lib/form/MailForm.class.php index 50b5254ded..12b2d63cad 100644 --- a/wcfsetup/install/files/lib/form/MailForm.class.php +++ b/wcfsetup/install/files/lib/form/MailForm.class.php @@ -78,6 +78,8 @@ class MailForm extends AbstractCaptchaForm { if (WCF::getUser()->userID && $this->user->isIgnoredUser(WCF::getUser()->userID)) { throw new PermissionDeniedException(); } + + $this->canonicalURL = LinkHandler::getInstance()->getLink('Mail', array('object' => $this->user->getDecoratedObject())); } /** diff --git a/wcfsetup/install/files/lib/page/AbstractPage.class.php b/wcfsetup/install/files/lib/page/AbstractPage.class.php index 993d4ce6e2..dd50573732 100644 --- a/wcfsetup/install/files/lib/page/AbstractPage.class.php +++ b/wcfsetup/install/files/lib/page/AbstractPage.class.php @@ -7,6 +7,7 @@ use wcf\system\menu\acp\ACPMenu; use wcf\system\menu\page\PageMenu; use wcf\system\request\RequestHandler; use wcf\system\WCF; +use wcf\util\HeaderUtil; /** * Abstract implementation of a page which fires the default event actions of a @@ -25,28 +26,28 @@ use wcf\system\WCF; */ abstract class AbstractPage implements IPage, ITrackablePage { /** - * name of the template for the called page + * name of the active menu item * @var string */ - public $templateName = ''; + public $activeMenuItem = ''; /** - * enables template usage + * value of the given action parameter * @var string */ - public $useTemplate = true; + public $action = ''; /** - * name of the active menu item + * canonical URL of this page * @var string */ - public $activeMenuItem = ''; + public $canonicalURL = ''; /** - * value of the given action parameter - * @var string + * enables the tracking of this page + * @var boolean */ - public $action = ''; + public $enableTracking = false; /** * indicates if you need to be logged in to access this page @@ -63,14 +64,20 @@ abstract class AbstractPage implements IPage, ITrackablePage { /** * needed permissions to view this page * @var array - */ + */ public $neededPermissions = array(); /** - * enables the tracking of this page - * @var boolean + * name of the template for the called page + * @var string */ - public $enableTracking = false; + public $templateName = ''; + + /** + * enables template usage + * @var string + */ + public $useTemplate = true; /** * @see \wcf\form\IPage::__run() @@ -166,6 +173,63 @@ abstract class AbstractPage implements IPage, ITrackablePage { throw new PermissionDeniedException(); } + // check if current request URL matches the canonical URL + if ($this->canonicalURL && empty($_POST)) { + $canoncialURL = parse_url($this->canonicalURL); + $requestURL = parse_url(WCF::getRequestURI()); + + $redirect = false; + if ($canoncialURL['path'] != $requestURL['path']) { + $redirect = true; + } + else if (isset($canoncialURL['query'])) { + parse_str($canoncialURL['query'], $cQueryString); + parse_str($requestURL['query'], $rQueryString); + + foreach ($cQueryString as $key => $value) { + if (!isset($rQueryString[$key]) || $rQueryString[$key] != $value) { + $redirect = true; + break; + } + } + } + + if ($redirect) { + $redirectURL = $this->canonicalURL; + if (!empty($requestURL['query'])) { + $queryString = $requestURL['query']; + parse_str($requestURL['query'], $rQueryString); + + if (!empty($canoncialURL['query'])) { + parse_str($canoncialURL['query'], $cQueryString); + + // clean query string + foreach ($cQueryString as $key => $value) { + if (isset($rQueryString[$key])) { + unset($rQueryString[$key]); + } + } + } + + // drop route data from query + if (!URL_LEGACY_MODE) { + foreach ($rQueryString as $key => $value) { + if ($value === '') { + unset($rQueryString[$key]); + } + } + } + + if (!empty($rQueryString)) { + $redirectURL .= (mb_strpos($redirectURL, '?') === false ? '?' : '&') . http_build_query($rQueryString, '', '&'); + } + } + + HeaderUtil::redirect($redirectURL); + exit; + } + } + // sets the active menu item $this->setActiveMenuItem(); diff --git a/wcfsetup/install/files/lib/page/AttachmentPage.class.php b/wcfsetup/install/files/lib/page/AttachmentPage.class.php index 99f0dff8f8..11cc4e9cf2 100644 --- a/wcfsetup/install/files/lib/page/AttachmentPage.class.php +++ b/wcfsetup/install/files/lib/page/AttachmentPage.class.php @@ -4,6 +4,7 @@ use wcf\data\attachment\Attachment; use wcf\data\attachment\AttachmentEditor; use wcf\system\exception\IllegalLinkException; use wcf\system\exception\PermissionDeniedException; +use wcf\system\request\LinkHandler; use wcf\system\WCF; use wcf\util\FileReader; @@ -72,6 +73,12 @@ class AttachmentPage extends AbstractPage { } if (isset($_REQUEST['tiny']) && $this->attachment->tinyThumbnailType) $this->tiny = intval($_REQUEST['tiny']); if (isset($_REQUEST['thumbnail']) && $this->attachment->thumbnailType) $this->thumbnail = intval($_REQUEST['thumbnail']); + + $this->canonicalURL = LinkHandler::getInstance()->getLink('Attachment', array( + 'object' => $this->attachment, + 'thumbnail' => $this->thumbnail, + 'tiny' => $this->tiny + )); } /** diff --git a/wcfsetup/install/files/lib/page/MembersListPage.class.php b/wcfsetup/install/files/lib/page/MembersListPage.class.php index 82869b93c1..db29d8f6a0 100644 --- a/wcfsetup/install/files/lib/page/MembersListPage.class.php +++ b/wcfsetup/install/files/lib/page/MembersListPage.class.php @@ -4,8 +4,10 @@ use wcf\data\search\Search; use wcf\system\dashboard\DashboardHandler; use wcf\system\database\PostgreSQLDatabase; use wcf\system\exception\IllegalLinkException; +use wcf\system\request\LinkHandler; use wcf\system\user\collapsible\content\UserCollapsibleContentHandler; use wcf\system\WCF; +use wcf\util\HeaderUtil; /** * Shows members page. @@ -105,6 +107,11 @@ class MembersListPage extends SortablePage { throw new IllegalLinkException(); } } + + if (!empty($_POST)) { + HeaderUtil::redirect(LinkHandler::getInstance()->getLink('MembersList', array(), 'sortField=' . $this->sortField . '&sortOrder=' . $this->sortOrder)); + exit; + } } /** diff --git a/wcfsetup/install/files/lib/page/UserPage.class.php b/wcfsetup/install/files/lib/page/UserPage.class.php index 1836cb7aa7..7d4baf4eb5 100644 --- a/wcfsetup/install/files/lib/page/UserPage.class.php +++ b/wcfsetup/install/files/lib/page/UserPage.class.php @@ -103,6 +103,8 @@ class UserPage extends AbstractPage { } if (isset($_REQUEST['editOnInit'])) $this->editOnInit = true; + + $this->canonicalURL = LinkHandler::getInstance()->getLink('User', array('object' => $this->user)); } /** diff --git a/wcfsetup/install/files/lib/page/UsersOnlineListPage.class.php b/wcfsetup/install/files/lib/page/UsersOnlineListPage.class.php index 3770c9d851..93f3c92248 100644 --- a/wcfsetup/install/files/lib/page/UsersOnlineListPage.class.php +++ b/wcfsetup/install/files/lib/page/UsersOnlineListPage.class.php @@ -6,6 +6,7 @@ use wcf\system\dashboard\DashboardHandler; use wcf\system\request\LinkHandler; use wcf\system\user\collapsible\content\UserCollapsibleContentHandler; use wcf\system\WCF; +use wcf\util\HeaderUtil; /** * Shows page which lists all users who are online. @@ -69,6 +70,11 @@ class UsersOnlineListPage extends SortablePage { $this->validSortFields[] = 'ipAddress'; $this->validSortFields[] = 'userAgent'; } + + if (!empty($_POST)) { + HeaderUtil::redirect(LinkHandler::getInstance()->getLink('UsersOnlineList', array(), 'sortField=' . $this->sortField . '&sortOrder=' . $this->sortOrder)); + exit; + } } /** -- 2.20.1