Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 03 Dec 2019, 17:06
cronjob78 cronjob78 is offline
 
Join Date: Mar 2005
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.
Reply With Quote
  #2  
Old 03 Dec 2019, 17:12
Dave Dave is offline
 
Join Date: Jun 2010
Real name: Dave
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?
__________________
https://technidev.com - security, development, exploits, vBulletin
dave[at]technidev[dot]com

Contact me for custom vBulletin 3/4 work & server/website management.
Reply With Quote
  #3  
Old Yesterday, 12:08
cronjob78 cronjob78 is offline
 
Join Date: Mar 2005
Thanks for the reply Dave. I have solved the problem.


For years, using this code in the plugin window, had worked fine for me:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

and I then included $var in my template, where I wanted the content of my PHP file to appear.
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:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

$_SERVER['HTTP_USER_AGENT'] will return the user's IP correctly.
Reply With Quote
  #4  
Old Yesterday, 12:12
Dave Dave is offline
 
Join Date: Jun 2010
Real name: Dave
Ah that makes more sense. Yes, you'd have to do it like that.
__________________
https://technidev.com - security, development, exploits, vBulletin
dave[at]technidev[dot]com

Contact me for custom vBulletin 3/4 work & server/website management.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 03:49.

Layout Options | Width: Wide Color: