简体   繁体   中英

Allow only one PC (one IP address) registration on a site

I have a registration site that requires the user to create their account by inputting a username and email address.

I site should only allow one email address to be registered from one PC (one IP address).

If another email account is registered from the same PC it will trigger a message saying "Your PC or PC's IP is already registered to the site" and refuse the account to be created.

function get_client_ip() {
    $ipaddress = '';
    if (getenv('HTTP_CLIENT_IP'))
        $ipaddress = getenv('HTTP_CLIENT_IP');
    else if(getenv('HTTP_X_FORWARDED_FOR'))
        $ipaddress = getenv('HTTP_X_FORWARDED_FOR');
    else if(getenv('HTTP_X_FORWARDED'))
        $ipaddress = getenv('HTTP_X_FORWARDED');
    else if(getenv('HTTP_FORWARDED_FOR'))
        $ipaddress = getenv('HTTP_FORWARDED_FOR');
    else if(getenv('HTTP_FORWARDED'))
       $ipaddress = getenv('HTTP_FORWARDED');
    else if(getenv('REMOTE_ADDR'))
        $ipaddress = getenv('REMOTE_ADDR');
    else
        $ipaddress = 'UNKNOWN';
    return $ipaddress;
}

Use this function to find the IP address and save it to db. Before saving the registration data verify if the IP is already present in DB or not.

However, its always a bad idea as Single IP doesn't mean single PC. Their is single outgoing IP while their may be 1000+ systems using the same IP inside the organisation. Schools, Universities , Enterprises generally have few outgoing IP's while 1000's systems are connected internally.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM