Added URL corrections
authorAlexander Ebert <ebert@woltlab.com>
Sun, 10 Aug 2014 22:24:57 +0000 (00:24 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 10 Aug 2014 22:24:57 +0000 (00:24 +0200)
13 files changed:
com.woltlab.wcf/templates/editHistory.tpl
com.woltlab.wcf/templates/membersList.tpl
com.woltlab.wcf/templates/usersOnlineList.tpl
wcfsetup/install/files/acp/templates/dataImport.tpl
wcfsetup/install/files/acp/templates/exceptionLogView.tpl
wcfsetup/install/files/acp/templates/templateDiff.tpl
wcfsetup/install/files/lib/form/LoginForm.class.php
wcfsetup/install/files/lib/form/MailForm.class.php
wcfsetup/install/files/lib/page/AbstractPage.class.php
wcfsetup/install/files/lib/page/AttachmentPage.class.php
wcfsetup/install/files/lib/page/MembersListPage.class.php
wcfsetup/install/files/lib/page/UserPage.class.php
wcfsetup/install/files/lib/page/UsersOnlineListPage.class.php

index cdd73d96076d107237ec7f6e24d6119a70e38c79..1fc8253ebb1425b493eae9f54526f05c17aadc2d 100644 (file)
@@ -53,7 +53,7 @@
 </div></div>
 {/if}
 
-<form action="{link controller='EditHistory'}{/link}" method="get">
+<form action="{link controller='EditHistory'}{/link}" method="post">
        <div class="tabularBox tabularBoxTitle marginTop">
                <header>
                        {assign var='versionCount' value=$objects|count}
index 4eeb957380f35b60ac8f903ea55ac764ab64445f..f98c3d5c27ea72bc6e161143c2f3bd0ea28cb327 100644 (file)
@@ -68,7 +68,7 @@
        </fieldset>
                
        <div>
-               <form method="get" action="{if $searchID}{link controller='MembersList' id=$searchID}{/link}{else}{link controller='MembersList'}{/link}{/if}">
+               <form method="post" action="{if $searchID}{link controller='MembersList' id=$searchID}{/link}{else}{link controller='MembersList'}{/link}{/if}">
                        <fieldset>
                                <legend><label for="sortField">{lang}wcf.user.members.sort{/lang}</label></legend>
                                
index 3b05477753cc55d6fbeda14d1440e404fec5d1a9..90bb553f5e1cdb60f12607d5989a2f724a7ef748 100644 (file)
@@ -32,7 +32,7 @@
 
 {capture assign='sidebar'}
        <div>
-               <form method="get" action="{link controller='UsersOnlineList'}{/link}">
+               <form method="post" action="{link controller='UsersOnlineList'}{/link}">
                        <fieldset>
                                <legend><label for="sortField">{lang}wcf.user.members.sort{/lang}</label></legend>
                                
index 999fe73c41fb59fb7c0cd0226728d8fc2b534d9a..de937ef16a529ccd202c4519b4460c7c279a34fe 100644 (file)
@@ -91,7 +91,7 @@
                        </script>
                {/if}
                
-               <form method="get" action="{link controller='DataImport'}{/link}">
+               <form method="post" action="{link controller='DataImport'}{/link}">
                        <div class="container containerPadding marginTop">
                                <fieldset>
                                        <legend>{lang}wcf.acp.dataImport.selectExporter{/lang}</legend>
index c7648779626b6a90d4f33ccb3666a0be4d944707..1626fdebe165b0ebb8007853445f9cda05925534 100644 (file)
@@ -27,7 +27,7 @@
 {include file='formError'}
 
 {if !$logFiles|empty}
-       <form method="get" action="{link controller='ExceptionLogView'}{/link}">
+       <form method="post" action="{link controller='ExceptionLogView'}{/link}">
                <div class="container containerPadding marginTop">
                        <fieldset><legend>{lang}wcf.acp.exceptionLog.search{/lang}</legend>
                                <dl>
index fb58acdae7e48d4f0fee7581a3cace7892a6fe65..2b516ac5f14899163aec4370ac8c98b810b57f17 100644 (file)
@@ -6,7 +6,7 @@
 
 {include file='formError'}
 
-<form method="get" action="{link controller='TemplateDiff'}{/link}">
+<form method="post" action="{link controller='TemplateDiff'}{/link}">
        <div class="container containerPadding marginTop">
                <fieldset>
                        <legend>{lang}wcf.acp.template.group{/lang}</legend>
index 6946c567f74af6666355bf727281516db4acdf4c..b7389c4da847d81502202ccdcf64a21b6e8a2390 100644 (file)
@@ -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);
+               }
        }
 }
index 50b5254deda4ba77c3c431b9786997aa2873ecf4..12b2d63cad2e2f2ee830fba78a53c4ba465160c6 100644 (file)
@@ -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()));
        }
        
        /**
index 993d4ce6e20d48919ccb66179b78497fad57e11e..dd505737321ce96ff67d1921fb412b4373fbb150 100644 (file)
@@ -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<string>
-        */
+       */
        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();
                
index 99f0dff8f829953b9ce027eadeea49bd7e406f16..11cc4e9cf2884def9288a49a3a199ed100e85c5e 100644 (file)
@@ -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
+               ));
        }
        
        /**
index 82869b93c13c0a612ec6bfc023d83b7b75d60325..db29d8f6a0bf3006a515317e68f71ea22f5bd3f5 100644 (file)
@@ -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;
+               }
        }
        
        /**
index 1836cb7aa711101facb2b7761006648f2c563674..7d4baf4eb5e05c4e4392534019edd5c3b96ddded 100644 (file)
@@ -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));
        }
        
        /**
index 3770c9d8516e8b0297abffcd820c30a2ac1b3391..93f3c92248ce1a055e9c5709ee71a2424e0ac4b2 100644 (file)
@@ -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;
+               }
        }
        
        /**