My idea - check email domain ban before register

Do you have an idea for the Joomla community that you can help implement? Discuss in here.
Locked
Dmitry Zhuk
Joomla! Apprentice
Joomla! Apprentice
Posts: 24
Joined: Wed Apr 20, 2011 11:32 am

My idea - check email domain ban before register

Post by Dmitry Zhuk » Sat Mar 16, 2013 9:13 pm

Hi.

The last few weeks I delete a lot of spam posts in my forum. The most of posts is created by users, which email is generated (or not) from a few domains.
And today I decided to block on registration new user level, and I added a few code lines into components\com_users\models\registration.php file.

I found a function

Code: Select all

public function register
and add my checking code before line // Bind the data

This is my lines (may be with extra checks)

Code: Select all

// Add before
// Bind the data.

		if (1==1)
		{
			$cur_banned = array('sina.com', 'ukpayday24.com', 'kidalylose.pl', 'lylilupuzy.pl');
			$cur_email = $data['email'];
			if ($cur_email == "")
			{
				$this->setError("Email is null");
				return false;
			}
			$cur_email_at = strpos($cur_email, "@");
			if ($cur_email_at === false)
			{
				$this->setError("Email does not contain @");
				return false;
			}
			
			$cur_email_domain = strtolower(substr($cur_email, $cur_email_at+1));
			
			if (in_array($cur_email_domain, $cur_banned))
			{
				$this->setError("Email domain is banned!");
				return false;
			}
			
		}
And I suggest you to create a new menu item in "Users" block for entering domains, which you want to ban.

After then add into registration options new parameter - use ban list.
And in my code change 1==1 to check this parameter.
And variable $cur_banned fill by query your domain list.


With this featues you can not only block definite user, but can have easy way to stop registering new spam users from domains you know

User avatar
raazlancer
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 204
Joined: Thu Mar 07, 2013 8:28 pm
Location: Dhaka, Bangladesh
Contact:

Re: My idea - check email domain ban before register

Post by raazlancer » Sat Mar 16, 2013 9:18 pm

Nice solution.. Thanks for sharing.
Hire Me On Freelancer.com : https://www.freelancer.com/u/dezefy
Visit My Website : https://dezefy.com

User avatar
raazlancer
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 204
Joined: Thu Mar 07, 2013 8:28 pm
Location: Dhaka, Bangladesh
Contact:

Re: My idea - check email domain ban before register

Post by raazlancer » Sat Mar 16, 2013 9:28 pm

Just tested works well.
Hire Me On Freelancer.com : https://www.freelancer.com/u/dezefy
Visit My Website : https://dezefy.com

Dmitry Zhuk
Joomla! Apprentice
Joomla! Apprentice
Posts: 24
Joined: Wed Apr 20, 2011 11:32 am

Re: My idea - check email domain ban before register

Post by Dmitry Zhuk » Tue Nov 12, 2013 10:12 am

I extended it in two places
1 - added blocking by IP array (like the domain array)
2 - change registration message - now it sends to admin with static text and IP address (I remove username from email subject) - I group it in inbox, and if I got more than 4-5 daily letters - I'm analyze it and block registering by IP. For example once I block registration attempts for 20-30 users from one IP (I think it was program registration)

User avatar
stutteringp0et
Joomla! Ace
Joomla! Ace
Posts: 1389
Joined: Sat Oct 28, 2006 11:16 pm
Location: Texas
Contact:

Re: My idea - check email domain ban before register

Post by stutteringp0et » Sun Nov 24, 2013 5:35 am

Or you could skip altering core files (always a bad idea) and use an existing plugin to do the job. Search "Domain Restriction" in the JED - which offers:

1. Allowed Domains (email, domain or TLD based - all others are denied)
2. Restricted Domains (email, domain or TLD based - all others are allowed)
3. Automatic Group Assignment on an email, domain or TLD basis. Also has a provision for ignored groups - users belonging to selected groups are immune to automatic group assignment.

Why re-invent the wheel?

Full Disclosure: Domain Restriction is one of my extensions. I was trolling the ideas forum for ideas worth building when I found this - an idea I'd already built.
My extensions: http://extensions.joomla.org/profile/pr ... ails/18398
Honk if this signature offends you.

Dmitry Zhuk
Joomla! Apprentice
Joomla! Apprentice
Posts: 24
Joined: Wed Apr 20, 2011 11:32 am

Re: My idea - check email domain ban before register

Post by Dmitry Zhuk » Mon Nov 25, 2013 6:54 am

I didn't find it (your extension) when was searching solution, and therefore I post my solution into "Joomla Idea Pool".
And I mean, that have built in restriction ability into joomla's engine - therefore I show my code, little changes (a few code lines)

User avatar
stutteringp0et
Joomla! Ace
Joomla! Ace
Posts: 1389
Joined: Sat Oct 28, 2006 11:16 pm
Location: Texas
Contact:

Re: My idea - check email domain ban before register

Post by stutteringp0et » Thu Dec 05, 2013 10:37 pm

It's always a bad idea to modify the joomla core. If a joomla update occurs - your changes are lost. Doing it through a plugin - the changes remain after an update.

My plugin is open source, and the code is available for all to see - as is a requirement for joomla extensions in the JED.
My extensions: http://extensions.joomla.org/profile/pr ... ails/18398
Honk if this signature offends you.


Locked

Return to “Joomla! Ideas Forum”