Computer Love > Security

Disposable Email Addresses

<< < (2/3) > >>

Chen Zhen:
I can show you a quick edit to an existing SMF file that will allow you to add multiple email addresses as ban triggers to an existing ban group.
After the edit what you do is create a new ban group (name) but only add 1 email address to it. Then you modify that same ban group/name where you can add multiple email addresses separated by a comma.

Here are the edits..

File: ../Sources/ManageBans.php

find:

--- Code: --- elseif ($_POST['bantype'] == 'email_ban')
{
if (preg_match('/[^\w.\-\+*@]/', $_POST['email']) == 1)
fatal_lang_error('invalid_email', false);
$_POST['email'] = strtolower(str_replace('*', '%', $_POST['email']));

// Check the user is not banning an admin.
$request = $smcFunc['db_query']('', '
SELECT id_member
FROM {db_prefix}members
WHERE (id_group = {int:admin_group} OR FIND_IN_SET({int:admin_group}, additional_groups) != 0)
AND email_address LIKE {string:email}
LIMIT 1',
array(
'admin_group' => 1,
'email' => $_POST['email'],
)
);
if ($smcFunc['db_num_rows']($request) != 0)
fatal_lang_error('no_ban_admin', 'critical');
$smcFunc['db_free_result']($request);

$values['email_address'] = $_POST['email'];

$modlogInfo['email'] = $_POST['email'];
}

--- End code ---

replace with:

--- Code: --- elseif ($_POST['bantype'] == 'email_ban')
{
$emails = explode(',', $_POST['email']);
foreach ($emails as $email)
{
list($email, $check) = array(trim($email), false);

if (preg_match('/[^\w.\-\+*@]/', $email) == 1)
fatal_lang_error('invalid_email', false);

$email = strtolower(str_replace('*', '%', $email));

// Check the user is not banning an admin.
$request = $smcFunc['db_query']('', '
SELECT id_member
FROM {db_prefix}members
WHERE (id_group = {int:admin_group} OR FIND_IN_SET({int:admin_group}, additional_groups) != 0)
AND email_address LIKE {string:email}
LIMIT 1',
array(
'admin_group' => 1,
'email' => $email,
)
);

if ($smcFunc['db_num_rows']($request) != 0)
fatal_lang_error('no_ban_admin', 'critical');

$smcFunc['db_free_result']($request);

$request = $smcFunc['db_query']('', '
SELECT email_address
FROM {db_prefix}ban_items
WHERE id_ban_group = {int:ban_group} AND email_address LIKE {string:email}
LIMIT 1',
array(
'ban_group' => (int)$_REQUEST['bg'],
'email' => $email,
)
);

while ($row = $smcFunc['db_fetch_assoc']($request))
$check = $row['email_address'];

$smcFunc['db_free_result']($request);

if (!empty($check))
continue;

$values['email_address'] = $email;
$modlogInfo['email'] = $email;

if ($email !== $emails[count($emails)-1])
{
if ($newBan)
{
$smcFunc['db_insert']('',
'{db_prefix}ban_items',
$insertKeys,
$values,
array('id_ban')
);
}
else
$smcFunc['db_query']('', '
UPDATE {db_prefix}ban_items
SET ' . $updateString . '
WHERE id_ban = {int:ban_item}
AND id_ban_group = {int:id_ban_group}',
array_merge($values, array(
'ban_item' => (int) $_REQUEST['bi'],
))
);

// Log the addion of the ban entry into the moderation log.
logAction('ban', $modlogInfo + array(
'new' => $newBan,
'type' => $_POST['bantype'],
));

list($values['email_address'], $modlogInfo['email']) = array('', '');
}
else
$_POST['email'] = $email;
}
}

--- End code ---


find:

--- Code: --- else
fatal_lang_error('no_bantype_selected', false);

--- End code ---

add AFTER above code

--- Code: --- if (!empty($check) && empty($modlogInfo))
fatal_lang_error('no_bantype_selected', false);

--- End code ---

Regards.

Skhilled:
Sounds great! Thanks! I'll give it a shot. It will be easier than entering then one by one.

EDIT: When I try to add a 2nd one and save it, it says:

(There are currently no ban triggers.)

And there's no triggers.

Ken.:
Thanks for that code Underdog.

Maxx:
Thanks Gents!

great post!

regards,
Maxx

Chen Zhen:
Skhilled,

  I just checked the file I instructed to edit and there was no edit done to it.
If you want it to work as I explained then you have to follow my instructions regarding the 2 edits.
Anyhow, I just edited the file for you and added all the emails from your first post to the #Disposable Emails group.
I added them all at once separated by commas as I previously instructed.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version