![]() |
Cant get user's IP address when calling a script from a plugin
I have a plugin that displays events from another part of my website unrelated to vBulletin. I want to write each information about each time an event is displayed to a database table and include the user's IP address in the data.
I'm adding the plugin as "global_start" and calling a variable called $show_event in my template files. In the plugin code I assign $show_event = implode('', 'www.mywebsite.com/forums/event.php'); $_SERVER['REMOTE_ADDR'] gives me my server's IP rather than the user's IP because of the way vBulletin calls up the plugins. I need the user's IP. I note that plugins using "style_fetch" as the hook location use $_SERVER['REMOTE_ADDR'] successfully, but I have to use "global_start". I can't access any global variables from event.php. If anyone can suggest anything I'd appreciate it. |
If the script is visited as expect in a browser then the proper IP should always be present in $_SERVER['REMOTE_ADDR'], unless you use some sort of proxy. Can you access the IPADDRESS or ALT_IP constants?
|
Thanks for the reply Dave. I have solved the problem.
For years, using this code in the plugin window, had worked fine for me: Code:
$var = implode('', file('path/to/this/file/myfile.php1')); However, when you try to access the $_SERVER['HTTP_USER_AGENT'] in that PHP file it will return the results of the server's IP rather than that of the client IP. However, if you use this code for your plugin instead: Code:
ob_start(); |
Ah that makes more sense. Yes, you'd have to do it like that.
|
All times are GMT. The time now is 10:39 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|