LICENSE 0000644 0000155 0177776 00000002712 12230302131 012010 0 ustar jenkins nogroup Copyright (c) 2013, Maximilian Mader
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
- Neither the name of wbbaddons nor the names of its contributors may be used to
endorse or promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
acpMenu.xml 0000644 0000155 0177776 00000000773 12233020447 013134 0 ustar jenkins nogroup
wcf.acp.menu.link.user.management
admin.system.canEditOption
acptemplate.tar 0000644 0000155 0177776 00000024000 12254143335 014023 0 ustar jenkins nogroup otuList.tpl 0000644 0000155 0177776 00000006131 12240521663 013204 0 ustar jenkins nogroup {include file='header' pageTitle='wcf.acp.user.otu.list'}
{lang}wcf.acp.user.otu.list{/lang}
{pages print=true assign=pagesLinks controller="OTUList" link="pageNo=%d&sortField=$sortField&sortOrder=$sortOrder"}
{hascontent}
{content}
{event name='contentNavigationButtonsTop'}
{/content}
{/hascontent}
{if $objects|count}
{lang}wcf.acp.user.otu.list{/lang} {#$items}
{@$pagesLinks}
{hascontent}
{content}
{event name='contentNavigationButtonsBottom'}
{/content}
{/hascontent}
{else}
{lang}wcf.global.noItems{/lang}
{/if}
{include file='footer'}
eventListener.xml 0000644 0000155 0177776 00000003600 12233043071 014361 0 ustar jenkins nogroup
wcf\data\user\UserAction
finalizeAction
wcf\system\event\listener\UserActionFinalizeOTUListener
user
wcf\data\user\UserAction
finalizeAction
wcf\system\event\listener\UserActionFinalizeOTUListener
admin
wcf\system\cronjob\DailyCleanUpCronjob
execute
wcf\system\event\listener\DailyCleanUpCronjobExecuteOTUCleanUpListener
user
wcf\system\cronjob\DailyCleanUpCronjob
execute
wcf\system\event\listener\DailyCleanUpCronjobExecuteOTUCleanUpListener
admin
wcf\system\option\OptionHandler
afterReadCache
wcf\system\event\listener\OptionEditOTUListener
admin
wcf\acp\form\OptionForm
saved
wcf\system\event\listener\OptionEditOTUListener
admin
file.tar 0000644 0000155 0177776 00000074000 12254143335 012450 0 ustar jenkins nogroup acp/ 0000755 0000155 0177776 00000000000 12254141360 011557 5 ustar jenkins nogroup acp/be.bastelstu.max.wcf.otu.install.php 0000644 0000155 0177776 00000003037 12254141360 020503 0 ustar jenkins nogroup
* @package be.bastelstu.max.wcf.otu
*/
// @codingStandardsIgnoreFile
// little workaround, options have already been loaded and the constant won't be defined
if (!defined('OTU_BLACKLIST_LIFETIME')) define('OTU_BLACKLIST_LIFETIME', 182);
// We don't check for "lastUsernameChange > 0", if this isn't set (how ever this may happen) TIME_NOW will be used.
$sql = "SELECT userID, oldUsername, lastUsernameChange
FROM wcf".WCF_N."_user
WHERE oldUsername <> ?
ORDER BY oldUsername ASC";
$stmt = \wcf\system\WCF::getDB()->prepareStatement($sql);
$stmt->execute(array(''));
$entries = array();
while ($row = $stmt->fetchArray()) {
$entries[] = array('username' => $row['oldUsername'], 'time' => $row['lastUsernameChange'], 'userID' => $row['userID']);
}
// blacklist the usernames that have been used before
\wcf\system\WCF::getDB()->beginTransaction();
$sql = "INSERT INTO wcf".WCF_N."_user_otu_blacklist_entry
(username, time, userID)
VALUES (?, ?, ?)";
$stmt = \wcf\system\WCF::getDB()->prepareStatement($sql);
foreach ($entries as $entry) {
$stmt->execute(array($entry['username'], ($entry['time'] > 0) ? $entry['time'] : TIME_NOW, $entry['userID']));
}
\wcf\system\WCF::getDB()->commitTransaction();
// rebuild the corresponding option
\wcf\data\user\otu\blacklist\entry\UserOtuBlacklistEntryEditor::resetCache();
lib/ 0000755 0000155 0177776 00000000000 12233004371 011557 5 ustar jenkins nogroup lib/acp/ 0000755 0000155 0177776 00000000000 12233004371 012322 5 ustar jenkins nogroup lib/acp/page/ 0000755 0000155 0177776 00000000000 12233055627 013250 5 ustar jenkins nogroup lib/acp/page/OTUListPage.class.php 0000644 0000155 0177776 00000002201 12233055627 017160 0 ustar jenkins nogroup
* @package be.bastelstu.max.wcf.otu
* @subpackage acp.page
* @category Community Framework
*/
class OTUListPage extends SortablePage {
/**
* @see \wcf\page\AbstractPage::$activeMenuItem
*/
public $activeMenuItem = 'wcf.acp.menu.link.user.management.otu';
/**
* @see \wcf\page\SortablePage::$defaultSortField
*/
public $defaultSortField = 'username';
/**
* @see \wcf\page\AbstractPage::$neededPermissions
*/
public $neededPermissions = array('admin.system.canEditOption');
/**
* @see \wcf\page\MultipleLinkPage::$objectListClassName
*/
public $objectListClassName = '\wcf\data\user\otu\blacklist\entry\UserOtuBlacklistEntryList';
/**
* @see \wcf\page\AbstractPage::$templateName
*/
public $templateName = 'otuList';
/**
* @see \wcf\page\SortablePage::$validSortFields
*/
public $validSortFields = array('username', 'time', 'lastOwner', 'userID', 'entryID');
}
lib/data/ 0000755 0000155 0177776 00000000000 12233004371 012470 5 ustar jenkins nogroup lib/data/user/ 0000755 0000155 0177776 00000000000 12233004371 013446 5 ustar jenkins nogroup lib/data/user/otu/ 0000755 0000155 0177776 00000000000 12233004371 014255 5 ustar jenkins nogroup lib/data/user/otu/blacklist/ 0000755 0000155 0177776 00000000000 12233004371 016225 5 ustar jenkins nogroup lib/data/user/otu/blacklist/entry/ 0000755 0000155 0177776 00000000000 12252405653 017377 5 ustar jenkins nogroup lib/data/user/otu/blacklist/entry/UserOtuBlacklistEntryAction.class.php 0000644 0000155 0177776 00000005223 12252405653 026635 0 ustar jenkins nogroup
* @package be.bastelstu.max.wcf.otu
* @subpackage data.user.otu.blacklist.entry
*/
class UserOtuBlacklistEntryAction extends \wcf\data\AbstractDatabaseObjectAction {
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$className
*/
protected $className = '\wcf\data\user\otu\blacklist\entry\UserOtuBlacklistEntryEditor';
/**
* @see \wcf\data\AbstractDatabaseObjectAction::$permissionsDelete
*/
protected $permissionsDelete = array('admin.system.canEditOption');
/**
* Resets cache if any of the listed actions is invoked
* @var array
*/
protected $resetCache = array('create', 'delete', 'toggle', 'update', 'updatePosition', 'prune', 'bulkCreate');
/**
* Adds the given usernames to the OTU-blacklist
*/
public function bulkCreate() {
if (empty($this->parameters['data'])) return;
\wcf\system\WCF::getDB()->beginTransaction();
// prevent duplicate entries
$condition = new \wcf\system\database\util\PreparedStatementConditionBuilder();
$condition->add('username IN(?)', array(array_map(function($element) {
return $element['username'];
}, $this->parameters['data'])));
$sql = "SELECT ".call_user_func(array($this->className, 'getDatabaseTableIndexName'))."
FROM ".call_user_func(array($this->className, 'getDatabaseTableName'))."
".$condition."
FOR UPDATE";
$stmt = \wcf\system\WCF::getDB()->prepareStatement($sql);
$stmt->execute($condition->getParameters());
$entryIDs = array();
while ($entryID = $stmt->fetchColumn()) $entryIDs[] = $entryID;
call_user_func(array($this->className, 'deleteAll'), $entryIDs);
foreach ($this->parameters['data'] as $entry) {
call_user_func(array($this->className, 'create'), $entry);
}
\wcf\system\WCF::getDB()->commitTransaction();
}
/**
* Removes expired entries from One-Time-Username blacklist
*
* @return integer Number of deleted usernames
*/
public function prune() {
if (OTU_BLACKLIST_LIFETIME == -1) return 0;
$sql = "SELECT ".call_user_func(array($this->className, 'getDatabaseTableIndexName'))."
FROM ".call_user_func(array($this->className, 'getDatabaseTableName'))."
WHERE time < ?";
$stmt = \wcf\system\WCF::getDB()->prepareStatement($sql);
$stmt->execute(array(TIME_NOW - OTU_BLACKLIST_LIFETIME * 86400));
$entryIDs = array();
while ($entryID = $stmt->fetchColumn()) $entryIDs[] = $entryID;
return call_user_func(array($this->className, 'deleteAll'), $entryIDs);
}
}
lib/data/user/otu/blacklist/entry/UserOtuBlacklistEntry.class.php 0000644 0000155 0177776 00000002622 12233045611 025470 0 ustar jenkins nogroup
* @package be.bastelstu.max.wcf.otu
* @subpackage data.user.otu.blacklist.entry
*/
class UserOtuBlacklistEntry extends \wcf\data\DatabaseObject {
/**
* @see \wcf\data\DatabaseObject::$databaseTableName
*/
protected static $databaseTableName = 'user_otu_blacklist_entry';
/**
* @see \wcf\data\DatabaseObject::$databaseTableIndexName
*/
protected static $databaseTableIndexName = 'entryID';
/**
* Removes contents between OTU start and end marks (e.g. ",One-Time-Username-Start-DO-NOT-REMOVE").
*
* @return string Text without contents between OTU marks
*/
public static function replaceOTUTextList($text, $replacement = '\\1') {
static $regex = null;
if ($regex === null) {
$regex = new \wcf\system\Regex('(?:^|\n),One-Time-Username-Start-DO-NOT-REMOVE\n.*\n,One-Time-Username-End-DO-NOT-REMOVE(\n|$)', \wcf\system\Regex::DOT_ALL);
}
$text = $regex->replace($text, $replacement);
// list was broken, delete leftover start or end marks
// everything on the list will be treated as blacklisted by hand!
return str_replace(array(',One-Time-Username-Start-DO-NOT-REMOVE', ',One-Time-Username-End-DO-NOT-REMOVE'), '', $text);
}
}
lib/data/user/otu/blacklist/entry/UserOtuBlacklistEntryEditor.class.php 0000644 0000155 0177776 00000004161 12236443606 026650 0 ustar jenkins nogroup
* @package be.bastelstu.max.wcf.otu
* @subpackage data.user.otu.blacklist.entry
*/
class UserOtuBlacklistEntryEditor extends \wcf\data\DatabaseObjectEditor implements \wcf\data\IEditableCachedObject {
/**
* @see \wcf\data\DatabaseObjectDecorator::$baseClass
*/
protected static $baseClass = '\wcf\data\user\otu\blacklist\entry\UserOtuBlacklistEntry';
/**
* Clears the room cache.
*/
public static function resetCache() {
// get options
$options = \wcf\data\option\Option::getOptions();
// delete One-Time-Usernames from WCF username blacklist
$blacklist = UserOtuBlacklistEntry::replaceOTUTextList($options['REGISTER_FORBIDDEN_USERNAMES']->optionValue);
// read One-Time-Username blacklist from database
$condition = new \wcf\system\database\util\PreparedStatementConditionBuilder();
if (OTU_BLACKLIST_LIFETIME > -1) $condition->add('time > ?', array(TIME_NOW - OTU_BLACKLIST_LIFETIME * 86400));
else $condition->add('1 = 1');
$sql = "SELECT username
FROM wcf".WCF_N."_user_otu_blacklist_entry
".$condition."
ORDER BY username ASC";
$stmt = \wcf\system\WCF::getDB()->prepareStatement($sql);
$stmt->execute($condition->getParameters());
$otUsernames = '';
while ($username = $stmt->fetchColumn()) {
$otUsernames .= $username . "\n";
}
// add One-Time-Usernames to blacklist
if ($otUsernames !== '') {
// leading comma, because it isn't a valid username
$blacklist .= "\n,One-Time-Username-Start-DO-NOT-REMOVE\n";
$blacklist .= $otUsernames;
$blacklist .= ',One-Time-Username-End-DO-NOT-REMOVE';
}
// trim empty lines
$blacklist = preg_replace("~\n+~", "\n", \wcf\util\StringUtil::trim($blacklist));
// save blacklist
$optionAction = new \wcf\data\option\OptionAction(array(), 'import', array('data' => array(
'register_forbidden_usernames' => $blacklist
)));
$optionAction->executeAction();
}
}
lib/data/user/otu/blacklist/entry/UserOtuBlacklistEntryList.class.php 0000644 0000155 0177776 00000001511 12233031160 026312 0 ustar jenkins nogroup
* @package be.bastelstu.max.wcf.otu
* @subpackage data.user.otu.blacklist.entry
*/
class UserOtuBlacklistEntryList extends \wcf\data\DatabaseObjectList {
/**
* @see \wcf\data\DatabaseObjectList::$className
*/
public $className = '\wcf\data\user\otu\blacklist\entry\UserOtuBlacklistEntry';
/**
* @see \wcf\data\DatabaseObjectList::$sqlSelects
*/
public $sqlSelects = "user.username AS lastOwner";
public function __construct() {
parent::__construct();
$this->sqlJoins = "LEFT JOIN wcf".WCF_N."_user user ON user.userID = user_otu_blacklist_entry.userID";
}
}
lib/system/ 0000755 0000155 0177776 00000000000 12233004371 013103 5 ustar jenkins nogroup lib/system/event/ 0000755 0000155 0177776 00000000000 12230302131 014214 5 ustar jenkins nogroup lib/system/event/listener/ 0000755 0000155 0177776 00000000000 12240521234 016051 5 ustar jenkins nogroup lib/system/event/listener/OptionEditOTUListener.class.php 0000644 0000155 0177776 00000002110 12233043071 024034 0 ustar jenkins nogroup
* @package be.bastelstu.max.wcf.otu
* @subpackage system.event.listener
*/
class OptionEditOTUListener implements \wcf\system\event\IEventListener {
/**
* @see \wcf\system\event\IEventListener::execute()
*/
public function execute($eventObj, $className, $eventName) {
if ($className == 'wcf\system\option\OptionHandler' && $eventName == 'afterReadCache' && isset($eventObj->cachedOptions['register_forbidden_usernames'])) {
$eventObj->cachedOptions['register_forbidden_usernames']->optionValue = \wcf\data\user\otu\blacklist\entry\UserOtuBlacklistEntry::replaceOTUTextList($eventObj->cachedOptions['register_forbidden_usernames']->optionValue);
}
else if ($className == 'wcf\acp\form\OptionForm' && $eventName == 'saved') {
\wcf\data\user\otu\blacklist\entry\UserOtuBlacklistEntryEditor::resetCache();
}
}
}
lib/system/event/listener/UserActionFinalizeOTUListener.class.php 0000644 0000155 0177776 00000003161 12240521234 025523 0 ustar jenkins nogroup
* @package be.bastelstu.max.wcf.otu
* @subpackage system.event.listener
*/
class UserActionFinalizeOTUListener implements \wcf\system\event\IEventListener {
/**
* @see \wcf\system\event\IEventListener::execute()
*/
public function execute($eventObj, $className, $eventName) {
if ($className == 'wcf\data\user\UserAction' && $eventName == 'finalizeAction') {
$action = $eventObj->getActionName();
$parameters = $eventObj->getParameters();
if (($action == 'update' && isset($parameters['data']) && isset($parameters['data']['username'])) || $action == 'delete') {
// Users have been updated or deleted, therefore blacklist their (old) usernames.
// If updated, only add the usernames to the One-Time-Username blacklist
// if username has been changed (username parameter is set).
$entries = array();
foreach ($eventObj->getObjects() as $object) {
if ($object instanceof \wcf\data\user\UserEditor) {
if ($action == 'update' && $parameters['data']['username'] == $object->username) continue;
$entries[] = array('username' => $object->username, 'time' => TIME_NOW, 'userID' => ($action != 'delete') ? $object->userID : null);
}
}
$blacklistEntryAction = new \wcf\data\user\otu\blacklist\entry\UserOtuBlacklistEntryAction(array(), 'bulkCreate', array('data' => $entries));
$blacklistEntryAction->executeAction();
}
}
}
}
lib/system/event/listener/DailyCleanUpCronjobExecuteOTUCleanUpListener.class.php 0000644 0000155 0177776 00000001252 12233004371 030406 0 ustar jenkins nogroup
* @package be.bastelstu.max.wcf.otu
* @subpackage system.event.listener
*/
class DailyCleanUpCronjobExecuteOTUCleanUpListener implements \wcf\system\event\IEventListener {
/**
* @see \wcf\system\event\IEventListener::execute()
*/
public function execute($eventObj, $className, $eventName) {
$blacklistEntryAction = new \wcf\data\user\otu\blacklist\entry\UserOtuBlacklistEntryAction(array(), 'prune');
$blacklistEntryAction->executeAction();
}
}
install.sql 0000644 0000155 0177776 00000000614 12233045611 013203 0 ustar jenkins nogroup DROP TABLE IF EXISTS wcf1_user_otu_blacklist_entry;
CREATE TABLE wcf1_user_otu_blacklist_entry (
entryID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(255) NOT NULL,
time INT(10) NOT NULL,
userID INT(10) DEFAULT NULL,
KEY (username),
KEY (time)
);
ALTER TABLE wcf1_user_otu_blacklist_entry ADD FOREIGN KEY (userID) REFERENCES wcf1_user (userID) ON DELETE SET NULL;
language/ 0000755 0000155 0177776 00000000000 12233031160 012570 5 ustar jenkins nogroup language/en.xml 0000644 0000155 0177776 00000002172 12233031160 013716 0 ustar jenkins nogroup
- username}” from the blacklist?]]>
language/de.xml 0000644 0000155 0177776 00000002256 12233031160 013707 0 ustar jenkins nogroup
- username}“ wirklich freigeben?]]>
option.xml 0000644 0000155 0177776 00000000771 12230302131 013040 0 ustar jenkins nogroup
user.ban
integer
182
-1
1
package.xml 0000644 0000155 0177776 00000005535 12254143335 013145 0 ustar jenkins nogroup
0
1.0.0 RC 4
2013-12-17
]]>
com.woltlab.wcf
install.sql
file.tar
acptemplate.tar
eventListener.xml
option.xml
acpMenu.xml
language/*.xml
acp/be.bastelstu.max.wcf.otu.install.php
install.sql
update_b1.sql
file.tar
acptemplate.tar
acpMenu.xml
file.tar
acptemplate.tar
file.tar
file.tar
file.tar
update_b1.sql 0000644 0000155 0177776 00000000211 12233020447 013372 0 ustar jenkins nogroup INSERT INTO wcf1_user_otu_blacklist_entry (username, time) SELECT username, time FROM wcf1_otu_blacklist;
DROP TABLE wcf1_otu_blacklist;