The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
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. |
#2
|
|||
|
|||
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?
|
#3
|
|||
|
|||
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(); include('path/to/this/file/myfile.php'); $includedphp = ob_get_contents(); ob_end_clean(); |
#4
|
|||
|
|||
Ah that makes more sense. Yes, you'd have to do it like that.
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|