Difference between revisions of "How to define maximum number of registrations allowed per IP within 24 hours"

From aMember Pro Documentation
Jump to: navigation, search
(Created page with "Create file /amember/application/configs/site.php with this code: <source> <?php Am_Di::getInstance()->hook->add(Am_Event::LOAD_SIGNUP_FORM, function(Am_Event $e) { $reg_...")
 
Line 1: Line 1:
Create file /amember/application/configs/site.php with this code:  
+
Add this code to [[site.php file]]:
 
<source>
 
<source>
 
<?php
 
<?php

Revision as of 03:44, 28 October 2015

Add this code to site.php file:

<?php
Am_Di::getInstance()->hook->add(Am_Event::LOAD_SIGNUP_FORM, function(Am_Event $e) {
    $reg_max = 10;
    $reg_num = $e->getDi()->db->selectCell("SELECT COUNT(*) FROM ?_user WHERE remote_addr = ? AND added>?",
        $_SERVER['REMOTE_ADDR'], sqlTime('- 24 hours'));
    if ($reg_num > $reg_max) {
        throw new Am_Exception_InputError(___('Registration from you IP is temporary disabled'));
    }
});