如何跟踪使用PHP热接头的IP地址 [英] How can i track hot linkers ip address using php

查看:105
本文介绍了如何跟踪使用PHP热接头的IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的服务器名为/images/pic.jpg图片。我想跟踪用户谁试图直接通过网址LIK www.domain.com/images/pic.jpg访问PIC的IP地址。我可以跟踪用户手动的通过IP地址:

 < PHP $ ip地址= $ _ SERVER ['REMOTE_ADDR']; ?>
 

解决方案

您可以创建一个拦截PHP脚本这将是负责处理针对其存储在一个特定的文件夹中的图像的所有请求。比方说所有的图像都位于图片/ 文件夹内。您只需要创建一个重写规则,这将为该文件夹中文件的所有请求重定向到一个PHP脚本。

 重写规则的图像/ \(JPG | GIF | PNG)(+)。?images.php图像= $ 1. $ 2
 

这种方式,你仍然保留使用你的作品里面的标记,你以前那样的方式的能力。

 < IMG SRC =图像/ logo.png/>
 

不要考虑,这种方法可能对你的系统性能,因为对图像资源的所有请求正在建立处理开销产生了严重影响,由于PHP是调用每次事实。

have a picture in my server named /images/pic.jpg . I want to track ip address of users who try to access that pic directly through url lik www.domain.com/images/pic.jpg. I can track ip address of manual user by:

<?php $ipAddress = $_SERVER['REMOTE_ADDR']; ?>

解决方案

You could create an intercept PHP script which would be responsible for handling all requests for images which are stored in a specific folder. Lets say all your images are located inside the images/ folder. You would simply need to create a rewrite rule which will redirect all requests for files inside that folder to a PHP script.

RewriteRule images/(.+)\.(jpg|gif|png) images.php?image=$1.$2

This way you would still retain the ability to use your images inside markup the way you did before.

<img src="images/logo.png" />

Do take into consideration that this approach might have a heavy impact on your system performance because all requests for image resources are now creating processing overhead due to the fact that PHP is invoked every time.

这篇关于如何跟踪使用PHP热接头的IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆