Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Frontainer
#45
(2020-04-13, 08:02:32)Stéphane Wrote: I had some troubles, few yeas ago, with a register form and tones of new fakes members...

Yeah, that can be annoying. However, there are many ways to prevent this.

1. Since most bots are really very stupid and not able to handle JavaScript, so you can prevent the registration with a simple JS by submitting a string when sending the form with JS. You can then check the string when you receive the data. I promise that you will catch 99,9% bot registrations with this method.

Another one and an even simpler method is to write an ItemManager function that will check if a user has been registered for more than one day but has not yet verified with an email address, and if so, this user gets deleted:
PHP Code:
/**
 * Remove expired user registrations
 * 
 * @var int $days - Number of days allowed without verification.
 */
function remove_unverifiedint $days 1)
{
 
   if(!isset($_POST['name']) || !isset($_POST['email'])) return;

 
   $imanager imanager();
 
   $users $imanager->getCategoryMapper()->getCategory('name=Users');
 
   $itemMapper $imanager->getItemMapper();
  
  $itemMapper->alloc($users->id);

 
   $nonVerified $itemMapper->getSimpleItems('active=0');
 
   if(!$nonVerified) return;

 
   $dt = new \DateTime();
 
   $now = new \DateTime();

 
   foreach($nonVerified as $account) {
 
       $dt->setTimestamp($account->created);
 
       // The date was more than $days ago?
 
       if($dt->diff($now)->days $days) {
 
           $imanager->deleteItem($account->id$users->id);
 
       }
 
    }


You can add it to your functions.php and call it every time the registration form is sent (a kind of lazy cron). Than, just extend your Frontainer code in functions.php as follows:

PHP Code:
if(function_exists('frontainer_get_content')) {
 
   remove_unverified();
 
   $fcontent frontainer_get_content();

 
   ...

Reply


Messages In This Thread
Frontainer - by Bigin - 2016-02-22, 23:48:10
RE: Frontainer - by Tzvook - 2016-02-24, 07:20:45
RE: Frontainer - by Bigin - 2016-02-24, 07:25:28
RE: Frontainer - by Tzvook - 2016-02-24, 07:39:28
RE: Frontainer - by Bigin - 2016-02-24, 07:50:04
RE: Frontainer - by Tzvook - 2016-02-24, 07:54:03
RE: Frontainer - by Bigin - 2016-02-24, 07:59:36
RE: Frontainer - by DesruX - 2016-04-12, 07:55:41
RE: Frontainer - by Bigin - 2016-04-12, 17:41:37
RE: Frontainer - by Bigin - 2016-04-13, 00:17:33
RE: Frontainer - by DesruX - 2016-04-13, 00:36:22
RE: Frontainer - by Bigin - 2016-04-13, 01:37:49
RE: Frontainer - by DesruX - 2016-04-13, 04:24:49
RE: Frontainer - by Bigin - 2016-04-13, 05:25:05
RE: Frontainer - by DesruX - 2016-04-13, 05:32:45
RE: Frontainer - by Bigin - 2016-04-13, 05:51:48
RE: Frontainer - by DesruX - 2016-04-15, 06:45:34
RE: Frontainer - by Bigin - 2016-04-15, 19:39:53
RE: Frontainer - by Bigin - 2016-04-12, 18:08:27
RE: Frontainer - by DesruX - 2016-04-12, 23:49:06
RE: Frontainer - by Bigin - 2016-04-13, 00:20:00
RE: Frontainer - by DesruX - 2016-04-13, 00:31:16
RE: Frontainer - by Bigin - 2016-04-12, 20:14:09
RE: Frontainer - by Bigin - 2016-04-15, 20:12:41
RE: Frontainer - by jeckyl - 2017-02-07, 01:55:19
RE: Frontainer - by Bigin - 2017-02-07, 03:58:00
RE: Frontainer - by jeckyl - 2017-02-07, 04:36:08
RE: Frontainer - by Bigin - 2017-02-07, 05:16:52
RE: Frontainer - by jeckyl - 2017-02-07, 06:13:24
RE: Frontainer - by Bigin - 2017-02-07, 08:49:33
RE: Frontainer - by jeckyl - 2017-02-07, 09:14:22
RE: Frontainer - by nicco - 2017-05-12, 19:26:45
RE: Frontainer - by Bigin - 2017-05-12, 20:38:15
RE: Frontainer - by nicco - 2017-05-12, 23:28:17
RE: Frontainer - by Bigin - 2017-05-13, 00:58:52
RE: Frontainer - by nicco - 2017-05-13, 02:11:24
RE: Frontainer - by Bigin - 2017-05-13, 02:51:45
RE: Frontainer - by nicco - 2017-05-13, 03:04:30
RE: Frontainer - by Bigin - 2017-05-13, 03:09:48
RE: Frontainer - by Carlos - 2017-05-13, 03:19:09
RE: Frontainer - by Bigin - 2017-05-13, 03:28:10
RE: Frontainer - by Stéphane - 2020-04-13, 03:40:16
RE: Frontainer - by Bigin - 2020-04-13, 04:16:35
RE: Frontainer - by Stéphane - 2020-04-13, 08:02:32
RE: Frontainer - by Bigin - 2020-04-13, 20:32:51
RE: Frontainer - by Stéphane - 2020-04-13, 22:46:48



Users browsing this thread: 1 Guest(s)