PDA

View Full Version : Limit 1 account per IP.



KuJoe
02-02-10, 11:11 AM
I am trying to create a custom hook to check the tblclients table when a client tries to register and check against the IP field to see if that IP is associated with an account already. My developer has been busy with non-work related things so I turn to you for some guidance. Here is the code I currently have which is a mash of examples I've found all over:



<?php

add_hook("ClientDetailsValidation",0,"checkIPIsValid","");

function checkIPIsValid($vars)
{
$regip = $_SERVER['REMOTE_ADDR'];
$result = select_query("tblclients","id",array("ip"=>$regip));
while ($row = mysql_fetch_array($result))
{
if ($regip = $result)
{
$errormessage .= "<li>This IP has already registered an account, please login to that account to place an order.";
}
}
}
?>

KuJoe
02-05-10, 03:23 AM
Bump... :(

sparky
02-05-10, 04:04 AM
Remember most clients would have dynamic IP's so it would change most of the time.
This should work for you.



<?php
if (!defined("WHMCS")) die("This file cannot be accessed directly");
function checkIPIsValid($vars) {
global $errormessage,$remote_ip;
$result = select_query("tblclients","ip",array("ip"=>$remote_ip));
while ($row = mysql_fetch_array($result)) {
if ($remote_ip = $row["ip"]) {
$errormessage .= "<li>Your IP has already been used to register an account, please login to that account to place an order.";
}
}
}
add_hook("ClientDetailsValidation",0,"checkIPIsValid","");
?>

KuJoe
02-05-10, 06:23 PM
Thanks! Works perfect! :)