Jump to content

Help with Limiting Product IDs to IP hook


Serenade

Recommended Posts

I found this hook to limit one account per IP. It works perfectly, except I would like to limit it only to specific products (pid=1, and pid=2).

 

If anyone has any ideas and are willing to help it'd be greatly appreciated!

 

<?php
if (!defined("WHMCS")) die("This file cannot be accessed directly");	


function checkIPIsValid($vars) {	
$result = select_query("tblorders","id",array("ipaddress"=>$_SERVER['REMOTE_ADDR']));
if (mysql_num_rows($result) != 0) {
  return  "It looks like your IP has already been used to register an account.";
}
}

add_hook("ClientDetailsValidation",1,"checkIPIsValid");
?>

Link to comment
Share on other sites

if the above code work for then this modification will do too,

 

<?php
if (!defined("WHMCS")) die("This file cannot be accessed directly");     


function checkIPIsValid($vars) {
   $result = full_query("SELECT `tblorders`.`userid` FROM `tblorders`,`tblhosting` WHERE `tblorders`.`ipaddress`='".addslashes($_SERVER['REMOTE_ADDR'])."' AND `tblorders`.`id`=`tblhosting`.`orderid` AND `tblhosting`.`packageid` IN (1,2)"); 
   if (mysql_num_rows($result) != 0) { 
     return  "It looks like your IP has already been used to register an account."; 
   } 
} 

add_hook("ClientDetailsValidation",1,"checkIPIsValid"); 
?>

Link to comment
Share on other sites

Thanks for the quick reply! It looks like the hook is properly checking if the IP exists, however it seems the hook is limiting all of my Products IDs and not just 1 and 2. I only want the hook to stop if the order is for Product 1 or 2. If the order is product 3 or anything else, the order should proceed.

 

Thanks a lot!

 

if the above code work for then this modification will do too,

 

<?php
if (!defined("WHMCS")) die("This file cannot be accessed directly");     


function checkIPIsValid($vars) {
   $result = full_query("SELECT `tblorders`.`userid` FROM `tblorders`,`tblhosting` WHERE `tblorders`.`ipaddress`='".addslashes($_SERVER['REMOTE_ADDR'])."' AND `tblorders`.`id`=`tblhosting`.`orderid` AND `tblhosting`.`packageid` IN (1,2)"); 
   if (mysql_num_rows($result) != 0) { 
     return  "It looks like your IP has already been used to register an account."; 
   } 
} 

add_hook("ClientDetailsValidation",1,"checkIPIsValid"); 
?>

Edited by Serenade
Typo
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated