How can php determine the client IP address in each request? We need to perform IP address verification for each request, that is, to identify whether the IP address has changed after the user logs on.
I want to implement it in PHP_RINIT_FUNCTION on the c layer, but I cannot find an interface in the C library that can get the client IP address.
The php layer can be obtained through $ _ SERVER ['remote _ add'], but the php code does not have a unified entry, so it is necessary to ADD judgment to all existing html, php, and js.
Could you please advise me if I have any good solutions to implement this function?
Reply to discussion (solution)
But HTTP_REMOTE_ADD is the environment variable of CGI gateway. php only places it in $ _ SERVER ['remote _ add '].
C can naturally be obtained.
But HTTP_REMOTE_ADD is the environment variable of CGI gateway. php only places it in $ _ SERVER ['remote _ add '].
C can naturally be obtained.
Thanks to the moderator for replying, does php provide the C interface? Or which part of the php code is involved?
Isn't your C php code? What else can I get with $ _ SERVER ['remote _ add?
Isn't your C php code? What else can I get with $ _ SERVER ['remote _ add?
After all, PHP code cannot be directly called in PHP_RINIT_FUNCTION in Part c, but the c interface is still required.
After reading the php source code, you can find the value of $ _ SERVER ['remote _ add'] through zend hash. Done.
Thank you!