Changeset 336

Show
Ignore:
Timestamp:
02/28/06 18:21:41 (2 years ago)
Author:
Rickard
Message:

Added an IP flood check to the registering process to prevent DoS attacks.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/upload/register.php

    r236 r336  
    8080else if (isset($_POST['form_sent'])) 
    8181{ 
     82        // Check that someone from this IP didn't register a user within the last hour (DoS prevention) 
     83        $result = $db->query('SELECT 1 FROM '.$db->prefix.'users WHERE registration_ip=\''.get_remote_address().'\' AND registered>'.(time() - 3600)) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); 
     84 
     85        if ($db->num_rows($result)) 
     86                message('A new user was registered with the same IP address as you within the last hour. To prevent registration flooding, at least an hour has to pass between registrations from the same IP. Sorry for the inconvenience.'); 
     87 
     88 
    8289        $username = pun_trim($_POST['req_username']); 
    8390        $email1 = strtolower(trim($_POST['req_email1']));