Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Order IP Address


mes

Recommended Posts

I have put it in the invoice as

 

<?php echo tep_get_ip_address(); ?>

 

but i just get the following error?

 

Fatal error: Call to undefined function: tep_get_ip_address()

 

any ideas?

 

thanks

 

mes

Link to comment
Share on other sites

I have put it in the invoice as

 

<?php echo tep_get_ip_address(); ?>

 

but i just get the following error?

 

Fatal error: Call to undefined function: tep_get_ip_address()

 

any ideas?

 

thanks

 

mes

 

 

this function should be defined in your general.php file.

It is in the default install.

 

function tep_get_ip_address() {

if (isset($_SERVER)) {

if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {

$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];

} elseif (isset($_SERVER['HTTP_CLIENT_IP'])) {

$ip = $_SERVER['HTTP_CLIENT_IP'];

} else {

$ip = $_SERVER['REMOTE_ADDR'];

}

} else {

if (getenv('HTTP_X_FORWARDED_FOR')) {

$ip = getenv('HTTP_X_FORWARDED_FOR');

} elseif (getenv('HTTP_CLIENT_IP')) {

$ip = getenv('HTTP_CLIENT_IP');

} else {

$ip = getenv('REMOTE_ADDR');

}

}

 

return $ip;

}

Treasurer MFC

Link to comment
Share on other sites

I have put it in the invoice as

 

<?php echo tep_get_ip_address(); ?>

 

but i just get the following error?

 

Fatal error: Call to undefined function: tep_get_ip_address()

 

 

I just tried inserting this in admin/orders.php, and got the same error message. Yes, the function is defined in catalog/includes/functions/general.php...it is also called in includes/application_top.php.

 

Wouldn't it also need to be defined in /catalog/admin/includes/functions/general.php if you're calling from an admin page? Just checking... :)

"Buy the ticket, take the ride..." -HST

Link to comment
Share on other sites

I just tried inserting this in admin/orders.php, and got the same error message. Yes, the function is defined in catalog/includes/functions/general.php...it is also called in includes/application_top.php.

 

Wouldn't it also need to be defined in /catalog/admin/includes/functions/general.php if you're calling from an admin page? Just checking... :)

 

not really,

 

this function gets the ip address of the person online.

when you are in orders.php to look at orders, this function would get your ip address.

 

if you want the ip address of the person who ordered to show in orders.php then you will have to use this function in checkout_process.php and insert it in the database when saving the order. Then in orders.php you can retrieve it again from the database to display it in your admin section.

Treasurer MFC

Link to comment
Share on other sites

not really,

 

this function gets the ip address of the person online.

when you are in orders.php to look at orders, this function would get your ip address.

 

if you want the ip address of the person who ordered to show in orders.php then you will have to use this function in checkout_process.php and insert it in the database when saving the order. Then in orders.php you can retrieve it again from the database to display it in your admin section.

 

Thanks, got it...with a little help from the Order IP Recorder contribution.

 

But I'm still puzzled by tep_get_ip_address();

 

Not used in Order IP Recorder, nor in Who's Online. It seems to be called only by application_top.php for the Check IP Address feature. What else is it good for, and how to use it without getting a fatal error?

"Buy the ticket, take the ride..." -HST

Link to comment
Share on other sites

Found another call, in the Contact Us Choice contribution (catalog/contact_us.php).

 

// add IP address and preamble text to message body
  $enquiry = sprintf(EMAIL_PREAMBLE_TEXT, $sender_type) . " " . tep_get_ip_address() . "\n-----------------------\n" . $enquiry;

"Buy the ticket, take the ride..." -HST

Link to comment
Share on other sites

  • 3 months later...

I found this thread to be helpful and I can understand the process of calling the IP a little better now.

 

I have used tep_get_ip_address();

to call the IP address for my page footer, it appears to call the IP OK but before the IP it always displays "unknown,"

 

eg Your IP address is:unknown, 203.219.255.2

 

I have looked at the defines for the tep_get_ip_address(); but cannot find any refeence to "unknown"

 

Here is the define

 

function tep_get_ip_address() {

if (isset($_SERVER)) {

if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {

$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];

} elseif (isset($_SERVER['HTTP_CLIENT_IP'])) {

$ip = $_SERVER['HTTP_CLIENT_IP'];

} else {

$ip = $_SERVER['REMOTE_ADDR'];

}

} else {

if (getenv('HTTP_X_FORWARDED_FOR')) {

$ip = getenv('HTTP_X_FORWARDED_FOR');

} elseif (getenv('HTTP_CLIENT_IP')) {

$ip = getenv('HTTP_CLIENT_IP');

} else {

$ip = getenv('REMOTE_ADDR');

}

}

 

return $ip;

 

Any idea why it displays "unknown" and can I resolve / remove this

 

thanks Geoff

Geoff

 

Telegraph Point 2441

Australia

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...