Uutiset:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu
Advertisement:

Imposing E-mail Registration Limitations

Aloittaja steveironpump, syyskuu 16, 2011, 08:56:35 IP

« edellinen - seuraava »

steveironpump

I am building a forum where I want to limit the e-mail addresses of people that can register on the forum to college students at universities in the area.  Is there any way that I can do this?

ApplianceJunk

Is this Mark?

Mark Zuckerberg, lol....

No built in feature, buy maybe this mod would be helpful to you?

http://custom.simplemachines.org/mods/index.php?mod=1493

MrPhil

Another approach would be to manually modify the appropriate code, so the sense of the block list (block by email domain or TLD) is reversed and only the listed domains or TLDs are permitted.

steveironpump

Thanks for the help guys. I'll try to install the mod. Not sure how to modify the code to accomplish that MrPhil. Care to give specifics?

I'm basically creating a forum for college students in a college town that has only 3 colleges. Before even putting up a site, I had an SMF forum in a directory and it got spammed by some dork who was trying to create backlinks to his site. I had about 50 registrations in a few days from the same IP address. I can ban the IP address, but as long as there is room for people to create backlinks to their sites, I'm going to have to deal with random registrations. If I can simply narrow it down to just college students with student e-mail accounts, then I won't have to worry about people registering and spamming the site.

Also, with the mod, do I need to have the exact version that it says it is compatible with or will it still work?

Illori

you can use version emulation if needed if the mod will not install on your version take a look at Package Manager for a start

MrPhil

Lainaus käyttäjältä: steveironpump - syyskuu 18, 2011, 06:13:26 AP
Thanks for the help guys. I'll try to install the mod. Not sure how to modify the code to accomplish that MrPhil. Care to give specifics?

I haven't actually tried it myself, but I think the following should come close to doing what you want (some assembly required). Here is the chunk of code in Sources/Security.php which appears to be checking if a given email address is on the ban list. Note that it may vary in your particular version of the code:

// ...and add to that the email address you're trying to register.
$request = db_query("
SELECT bi.ID_BAN, bg.$restriction, bg.cannot_access, bg.reason
FROM ({$db_prefix}ban_items AS bi, {$db_prefix}ban_groups AS bg)
WHERE bg.ID_BAN_GROUP = bi.ID_BAN_GROUP
AND '$email' LIKE bi.email_address
AND (bg.$restriction = 1 OR bg.cannot_access = 1)", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
{
if (!empty($row['cannot_access']))
{
$_SESSION['ban']['cannot_access']['ids'][] = $row['ID_BAN'];
$_SESSION['ban']['cannot_access']['reason'] = $row['reason'];
}
if (!empty($row[$restriction]))
{
<<< if get to here, the email address was found in the ban_item table, so BAN it
$ban_ids[] = $row['ID_BAN'];
$ban_reason = $row['reason'];
}
}
mysql_free_result($request);

Let's try the following to invert the sense of the test:

// ...and add to that the email address you're trying to register.
$request = db_query("
SELECT bi.ID_BAN, bg.$restriction, bg.cannot_access, bg.reason
FROM ({$db_prefix}ban_items AS bi, {$db_prefix}ban_groups AS bg)
WHERE bg.ID_BAN_GROUP = bi.ID_BAN_GROUP
AND '$email' LIKE bi.email_address
AND (bg.$restriction = 1 OR bg.cannot_access = 1)", __FILE__, __LINE__);
$in_the_list = false;
while ($row = mysql_fetch_assoc($request))
{
if (!empty($row['cannot_access']))
{
$_SESSION['ban']['cannot_access']['ids'][] = $row['ID_BAN'];
$_SESSION['ban']['cannot_access']['reason'] = $row['reason'];
}
if (!empty($row[$restriction]))
{
$in_the_list = true;
// $ban_ids[] = $row['ID_BAN'];
// $ban_reason = $row['reason'];
}
}
if (! $in_the_list) {
  // was NOT found in the list, so we we want to ban it
  $ban_ids[] = $email;
  $ban_reason = "Not in permitted group of email domains";
}
mysql_free_result($request);

I think that will do it, but you may have to do some tinkering. Have you looked to see if there is a mod for this? I'm sure I've seen it discussed at least once before.

Before changing the code, check if SMF is accepting something like "*@smithcollege.edu" (or maybe just "@smithcollege.edu") for bans. The exact syntax may vary. You would want to be able to "ban" an entire domain, not just a specific user. Once you figure out how to specify that, you can try inverting the test as discussed above, and see if it works for you.

Advertisement: