ecshop 中怎么获取客户端ip
开发前,先安装最新IP库版本升级补丁,升级自带的陈旧的IP库。
安装指南
第一步:将安装文件覆盖到网站根目录(覆盖前注意备份)。下载安装文件:《db_net.zip》
第二步:输入”站点路径/db_net.php”,如”http://www.net.com/db_119.php”一键完成安装,安装完成后,请立即删除db_net.php。
第三步:编辑/admin/order.php,添加查询IP
大概在:5041行
/* 查询 */
$sql = "SELECT o.order_id, o.order_sn, o.add_time, o.order_status, o.shipping_status, o.order_amount, o.money_paid, o.ip_address," .
"o.pay_status, o.consignee, o.address, o.email, o.tel, o.extension_code, o.extension_id, " .
"(" . order_amount_field('o.') . ") AS total_fee, " .
"IFNULL(u.user_name, '" .$GLOBALS['_LANG']['anonymous']. "') AS buyer ".
" FROM " . $GLOBALS['ecs']->table('order_info') . " AS o " .
" LEFT JOIN " .$GLOBALS['ecs']->table('users'). " AS u ON u.user_id=o.user_id ". $where .
继续添加大概在5065行:
/* 格式话数据 */
foreach ($row AS $key => $value)
{
$row[$key]['formated_order_amount'] = price_format($value['order_amount']);
$row[$key]['formated_money_paid'] = price_format($value['money_paid']);
$row[$key]['formated_total_fee'] = price_format($value['total_fee']);
$row[$key]['short_order_time'] = local_date('m-d H:i', $value['add_time']);
$ip_area = ecs_geoip($row[$key]['ip_address']); //获取IP对应的地理位置
empty($row[$key]['ip_address']) ? '' : $row[$key]['ip_address'] .= ' [ ' . $ip_area . ' ]';
if ($value['order_status'] == OS_INVALID || $value['order_status'] == OS_CANCELED)
第四步:编辑/admin/templates/order_list.htm,添加显梁世示IP
大概32行左右:
<th><a href="javascript:listTable.sort('add_time', 'DESC'); ">{$lang.order_time}</a>{$sort_order_time}</th>
<th><a href="javascript:listTable.sort('consignee', 'DESC'); ">{$lang.consignee}</a>{$sort_consignee}</th>
烂早 <th><a href="javascript:listTable.sort('ip_address', 'DESC'); ">{$lang.ip_address}</a>{$sort_ip_address}</th>
<th><a href="javascript:listTable.sort('total_fee', 'DESC'); ">{$lang.total_fee}</a>{$sort_total_fee}</th>
<th><a href="javascript:listTable.sort('order_amount', 'DESC'); ">{$lang.order_amount}</a>{$sort_order_amount}</th>
大概45-46行左饥渣雀右:
<td align="left" valign="top" nowrap="nowrap">{$order.ip_address}</td>
第五步:编辑/admin/languages/zh_cn/order.php,添加语言项
$_LANG['ip_address'] = 'IP地址';
第六步:编辑/flow.php,添加获取IP并插入数据库
$order = array(
'ip_address' => real_ip(),
'shipping_id' => intval($_POST['shipping']),
'pay_id' => intval($_POST['payment']),
如图:
2023-07-25 广告