From: Marcel Werk Date: Mon, 8 Apr 2013 23:30:25 +0000 (+0200) Subject: Added user ban function X-Git-Tag: 2.0.0_Beta_1~396 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=b1356a27daa0c9028d248480401e65a5f514b1a4;p=GitHub%2FWoltLab%2FWCF.git Added user ban function --- diff --git a/wcfsetup/install/files/lib/system/WCF.class.php b/wcfsetup/install/files/lib/system/WCF.class.php index dc5feddc67..f075bcd885 100644 --- a/wcfsetup/install/files/lib/system/WCF.class.php +++ b/wcfsetup/install/files/lib/system/WCF.class.php @@ -8,7 +8,9 @@ use wcf\data\package\PackageEditor; use wcf\system\application\ApplicationHandler; use wcf\system\cache\builder\CoreObjectCacheBuilder; use wcf\system\cronjob\CronjobScheduler; +use wcf\system\exception\AJAXException; use wcf\system\exception\IPrintableException; +use wcf\system\exception\NamedUserException; use wcf\system\exception\PermissionDeniedException; use wcf\system\exception\SystemException; use wcf\system\language\LanguageFactory; @@ -369,6 +371,16 @@ class WCF { throw new PermissionDeniedException(); } } + + // handle banned users + if (WCF::getUser()->userID && WCF::getUser()->banned) { + if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest')) { + throw new AJAXException(WCF::getLanguage()->getDynamicVariable('wcf.user.error.isBanned'), AJAXException::INSUFFICIENT_PERMISSIONS); + } + else { + throw new NamedUserException(WCF::getLanguage()->getDynamicVariable('wcf.user.error.isBanned')); + } + } } /** diff --git a/wcfsetup/install/files/lib/system/request/RequestHandler.class.php b/wcfsetup/install/files/lib/system/request/RequestHandler.class.php index 2e973ea22b..9780c340cf 100644 --- a/wcfsetup/install/files/lib/system/request/RequestHandler.class.php +++ b/wcfsetup/install/files/lib/system/request/RequestHandler.class.php @@ -51,7 +51,7 @@ class RequestHandler extends SingletonFactory { // handle offline mode if (!$isACPRequest && defined('OFFLINE') && OFFLINE) { if (!WCF::getSession()->getPermission('admin.general.canViewPageDuringOfflineMode') && !$this->activeRequest->isAvailableDuringOfflineMode()) { - if (isset($_SERVER['X-Requested-With']) && ($_SERVER['X-Requested-With'] == 'XMLHttpRequest')) { + if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest')) { throw new AJAXException(WCF::getLanguage()->get('wcf.ajax.error.permissionDenied'), AJAXException::INSUFFICIENT_PERMISSIONS); } else { diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 8cf5d91262..b90e8a00a4 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -982,5 +982,6 @@ + user->banReason}: {@$__wcf->user->banReason|htmlspecialchars|nl2br}{else}.{/if}]]> diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index da2a3ce378..9b0167ca96 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -974,5 +974,6 @@ + user->banReason}: {@$__wcf->user->banReason|htmlspecialchars|nl2br}{else}.{/if}]]> diff --git a/wcfsetup/setup/db/install.sql b/wcfsetup/setup/db/install.sql index 56c35bbd9a..82e592e516 100644 --- a/wcfsetup/setup/db/install.sql +++ b/wcfsetup/setup/db/install.sql @@ -620,6 +620,8 @@ CREATE TABLE wcf1_user ( languageID INT(10) NOT NULL DEFAULT 0, registrationDate INT(10) NOT NULL DEFAULT 0, styleID INT(10) NOT NULL DEFAULT 0, + banned TINYINT(1) NOT NULL DEFAULT 0, + banReason MEDIUMTEXT NULL, KEY username (username), KEY registrationDate (registrationDate),