Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Logging IP numbers

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 12-04-2002, 01:30 AM
 
Cefko Cefko is offline
 

Advanced Member
  
Join Date: Nov 2002
Posts: 69
 

Default Logging IP numbers

Today I realized that X-cart doesn't log IPs at orders and registrations.

It would help to take out fake users and fake orders - made intentionally, especialy with the different payment options. It would also help with frauds.

Is this just my wish?
Reply With Quote
  #2  
Old 12-04-2002, 06:53 AM
  B00MER's Avatar 
B00MER B00MER is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Keller, TX (Cart-Lab.com)
Posts: 3,165
 

Default

Not too much trouble but...

First we alter the xcart_orders table and add a new field named 'ip'. I did this with phpMyAdmin. Simply copy paste the code snippet into the SQL query box.

Code:
ALTER TABLE `xcart_orders` ADD `ip` VARCHAR( 15 ) NOT NULL ;

Next we open include/func.php, locate the func_place_order(); function, in my 3.2.2pro code its on line 1017.

Code:
# # Insert into orders # db_query("insert into $sql_tbl[orders] (login, total, subtotal, shipping_cost, shippingid, tax, discount, coupon, coupon_discount, date, status, payment_method, flag, details, title, firstname, lastname, company, b_address, b_city, b_state, b_country, b_zipcode, s_address, s_city, s_state, s_country, s_zipcode, phone, fax, email, url, ip) values ('".addslashes($userinfo["login"])."', '$current_order[total_cost]', '$current_order[sub_total]','$current_order[shipping_cost]', '$cart[shippingid]', '$current_order[tax_cost]', '$current_order[discount]', '".addslashes($current_order[coupon])."', '$current_order[coupon_discount]', '".time()."', '$order_status', '".addslashes($payment_method)."', 'N', '".addslashes(text_crypt($order_details))."', '".addslashes($userinfo["title"])."', '".addslashes($userinfo["firstname"])."', '".addslashes($userinfo["lastname"])."', '".addslashes($userinfo["company"])."', '".addslashes($userinfo["b_address"])."', '".addslashes($userinfo["b_city"])."', '".addslashes($userinfo["b_state"])."', '".addslashes($userinfo["b_country"])."', '".addslashes($userinfo["b_zipcode"])."', '".addslashes($userinfo["s_address"])."', '".addslashes($userinfo["s_city"])."', '".addslashes($userinfo["s_state"])."', '".addslashes($userinfo["s_country"])."', '".addslashes($userinfo["s_zipcode"])."', '".addslashes($userinfo["phone"])."', '".addslashes($userinfo["fax"])."', '$userinfo[email]', '".addslashes($userinfo["url"])."','$_SERVER[REMOTE_ADDR]')");

Replace the db_query(); with this one. Note the $_SERVER[REMOTE_ADDR] at the end of the query storing the users remote IP.

Now we want to be able to see the order data in the admin.

Edit [skin1]/main/order_info.tpl add the following where ever you want the IP of the order displayed, I put mine under the email.

Code:
<tr> <td valign="top">IP Address</td> <td valign="top">{ $order.ip }</td> </tr>

Good luck!
Please make a donation if you find this useful.
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
  #3  
Old 12-05-2002, 01:41 AM
 
Cefko Cefko is offline
 

Advanced Member
  
Join Date: Nov 2002
Posts: 69
 

Default

Actually I did that myself before I posted this topic,
but I thought it would be nice if this code would be included in standard
release - since it is very important tool in fight against frauds.

But thank you for the quick response, now I know to who I'll turn when I'll have problems
__________________
X-cart version 4.1.7
Apache/2.0.52 (CentOS)
My SQL 5.0.58
PHP Version 5.1.6
Reply With Quote
  #4  
Old 12-05-2002, 01:56 AM
 
Cefko Cefko is offline
 

Advanced Member
  
Join Date: Nov 2002
Posts: 69
 

Default

Just one question, why would you define ip as varchar(64)?

As system is now, you need 4*3 places + 3 dots = 15 places max?
__________________
X-cart version 4.1.7
Apache/2.0.52 (CentOS)
My SQL 5.0.58
PHP Version 5.1.6
Reply With Quote
  #5  
Old 12-05-2002, 02:53 AM
 
Cefko Cefko is offline
 

Advanced Member
  
Join Date: Nov 2002
Posts: 69
 

Default

Since Boomer posted some code, I think I should too..

To add IP's to customer registration, customer changing profile, and adding to newsletter from profile do following.

In SQL enter
Code:
ALTER TABLE `xcart_customers` ADD `ip` VARCHAR( 15 ) NOT NULL ; ALTER TABLE `xcart_maillist` ADD `ip` VARCHAR( 15 ) NOT NULL ;

Then open INCLUDE/REGISTER.PHP and change (in red)

on line 112
Code:
db_query("delete from $sql_tbl[maillist] where email='$email'"); if($newsletter=="on") db_query("insert into $sql_tbl[maillist] (email, since_date,ip) values ('$email',now(),'$_SERVER[REMOTE_ADDR]')");

on line 122

Code:
db_query("update $sql_tbl[customers] set password='$crypted', password_hint='$password_hint', password_hint_answer='$password_hint_answer', title='$title', firstname='$firstname', lastname='$lastname', company='$company', b_address='$b_address', b_city='$b_city', b_state='$b_state', b_country='$b_country', b_zipcode='$b_zipcode', s_address='$s_address', s_city='$s_city', s_state='$s_state', s_country='$s_country', s_zipcode='$s_zipcode', phone='$phone', email='$email', fax='$fax', url='$url', card_name='$card_name', card_type='$card_type', card_number='".text_crypt($card_number)."', card_expire='$card_expire', card_cvv2='$card_cvv2', pending_membership='$pending_membership', ssn='$ssn', ip='$_SERVER[REMOTE_ADDR]' where login='$login' and usertype='$login_type'");

on line 155

Code:
db_query("insert into $sql_tbl[customers] (login,usertype,membership,password,password_hint,password_hint_answer,title,firstname,lastname,company,b_address,b_city,b_state,b_country,b_zipcode,s_address,s_city,s_state,s_country,s_zipcode,phone,email,fax,url,card_name,card_type,card_number,card_expire,card_cvv2,first_login,status,referer,pending_membership,ssn,ip) values ('$uname','$usertype','$membership','$crypted','$password_hint','$password_hint_answer','$title','$firstname','$lastname','$company','$b_address','$b_city','$b_state','$b_country','$b_zipcode','$s_address','$s_city','$s_state','$s_country','$s_zipcode','$phone','$email','$fax','$url','$card_name','$card_type','".text_crypt($card_number)."','$card_expire','$card_cvv2','".time()."','Y','$RefererCookie','$pending_membership','$ssn','$_SERVER[REMOTE_ADDR]')");

For displaying IP in customer profile, you can add following in MAIN/REGISTER.TPL

Code:
{if $usertype eq "A" or $usertype eq "P"} <tr valign=middle> <td align=right>IP:</td> <td></td> <td nowrap> {$userinfo.ip} </td> </tr> {/if}
You can remove {if} if you want to show your customers, that you log IPs


I'll post code for capturing IP from 'Newsletter signup box' later.[/code]
__________________
X-cart version 4.1.7
Apache/2.0.52 (CentOS)
My SQL 5.0.58
PHP Version 5.1.6
Reply With Quote
  #6  
Old 01-08-2003, 01:37 AM
 
Blind Freddy Blind Freddy is offline
 

Member
  
Join Date: Dec 2002
Posts: 10
 

Default

Hi,

Could someone please tell me if it is possible to take the IP address of the clients who register, do a WHOIS lookup, and then store the country in which their ISP is located into an X-Cart field?

thanks,
Eric G.
Reply With Quote
  #7  
Old 01-08-2003, 09:50 AM
  B00MER's Avatar 
B00MER B00MER is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Keller, TX (Cart-Lab.com)
Posts: 3,165
 

Default

Something like this would need to be implemented before this could happen:

http://phpwhois.org

hth.
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
  #8  
Old 01-31-2003, 01:10 PM
 
jpsowin jpsowin is offline
 

X-Adept
  
Join Date: Sep 2002
Posts: 459
 

Default

That would only work if they had a top-level domain name as their IP, which would be virutally no one. You can't do a WHOIS lookup for a regular IP.. a traceroute would be more the way to go.
__________________
Joshua Sowin
...taking things one TPL at a time.
Reply With Quote
  #9  
Old 01-31-2003, 01:35 PM
 
Blind Freddy Blind Freddy is offline
 

Member
  
Join Date: Dec 2002
Posts: 10
 

Default

Detection of geographical location of a user by the IP number of their ISP connection is now possible.

Have a look at www.geobytes.com

Have a look at the Flash animation.

The the possibilities are amazing!!

Regards,
Eric.
Reply With Quote
  #10  
Old 01-31-2003, 04:29 PM
 
jpsowin jpsowin is offline
 

X-Adept
  
Join Date: Sep 2002
Posts: 459
 

Default

Yes, it's been available for a long time... but a WHOIS won't do it
I've used http://visualroute.visualware.com for years.
__________________
Joshua Sowin
...taking things one TPL at a time.
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 03:33 AM.

   

 
X-Cart forums © 2001-2020