09 Username Blacklist

Started by Mindless, July 21, 2012, 05:47:14 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


Credits to putyn.
Xhtml valid.

A simple mod that allows staff to create a blacklist with usernames that users are not allowed to use on signup the code is pretty simple - usernames are saved inside a file

first open bittorrent.php add this at the bottom :

Code (php) Select
//made by putyn@tbdev
function blacklist($fo) {
global $TBDEV;
$blacklist = file_exists($TBDEV['nameblacklist']) && is_array(unserialize(file_get_contents($TBDEV['nameblacklist']))) ? unserialize(file_get_contents($TBDEV['nameblacklist'])) : array();
if(isset($blacklist[$fo]) && $blacklist[$fo] == 1)
return false;

return true;

now open config.php and add this

Code (php) Select
$TBDEV['nameblacklist'] = ROOT_PATH.'/cache/nameblacklist.txt';

now create a new file name it nameblacklist.php add this code

Code (php) Select
//made by putyn@tbdev
if ( ! defined'IN_TBDEV_ADMIN' ) )
$HTMLOUT .= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
<html xmlns='http://www.w3.org/1999/xhtml'>
<div style='font-size:33px;color:white;background-color:red;text-align:center;'>Incorrect access<br />You cannot access this file directly.</div>
print $HTMLOUT;

$blacklist file_exists($TBDEV['nameblacklist']) && is_array(unserialize(file_get_contents($TBDEV['nameblacklist'])))  ? unserialize(file_get_contents($TBDEV['nameblacklist'])) : array();


$badnames = isset($_POST['badnames']) && !empty($_POST['badnames']) ? trim($_POST['badnames']) : '';
stderr('Hmm','I think you forgot the name');
if(strpos($badnames,',')) {
foreach(explode(',',$badnames) as $badname)
$blacklist[$badname] = (int)1;
} else
$blacklist[$badnames] = (int)1;

if(file_put_contents($TBDEV['nameblacklist'],serialize($blacklist))) {
header('Refresh:2; url=admin.php?action=nameblacklist');
stderr('Success','The file was written...wait for redirect');
} else
stderr('Error','There was an error while saving the file check if this file <b>'.$TBDEV['nameblacklist'].'</b> is writable');
} else {

$out begin_main_frame();
$out .= stdmsg('Current words on blacklist',count($blacklist) ? join(', ',array_keys($blacklist)) : 'There is no username on the blacklist');
$out .= stdmsg('Add word','<form action="admin.php?action=nameblacklist" method="post"><table width="90%" cellspacing="2" cellpadding="5" align="center" style="border-collapse:separate">
<tr><td align="center"><textarea rows="3" cols="100" name="badnames"></textarea></td></tr>
    <tr><td align="center">Note if you want to submit more then one bad nick at a time separate them with a semicol</td></tr>
<tr> <td align="center"><input type="submit" value="Update"/></td></tr>
$out .= end_main_frame();
stdhead('Username blacklist').$out.stdfoot());

and add it inside admin directory
then open admin.php and add

Code (php) Select
'nameblacklist'   => 'nameblacklist',

inside $ad_actions array

then open index.php from admin directory and add where you want it

Code (php) Select
<span class='btn'><a href='admin.php?action=stats'>{$lang['index_blacklist']}</a></span>

then open lang_ad_index.php

Code (php) Select
'index_blacklist' => 'Blacklist',

then open takesignup.php and add

Code (php) Select

add it under

Code (php) Select
if (empty($wantusername) || empty($wantpassword) || empty($email))
      stderr($lang['takesignup_user_error'], $lang['takesignup_blank']);

then open lang_takesignup.php
and add

Code (php) Select
'takesignup_badusername' => "The username your trying to use <b>(%s)</b> is on our black list chose another one",

Now you can control the usernames your users will use on you tracker.