vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Logging IP Addresses - is there a mod for this? (https://vborg.vbsupport.ru/showthread.php?t=258890)

bryanb 02-15-2011 05:20 AM

Logging IP Addresses - is there a mod for this?
 
I have a member who thinks his account has been accessed by someone else. He's been a member for several years and has never posted so only one IP address shows in his account profile. I'm assuming that vB only logs IPs when a user posts (please correct me if I'm wrong).

Is there a mod, or any way to view IPs that have accessed an account over a certain period of time? Any assistance would be truly appreciated. Thanks!

Using 3.8.6 btw :)

kh99 02-15-2011 09:53 PM

I was going to use this for something I was working on: create a plugin with hook location global_complete and this code:

Code:

if ($vbulletin->userinfo['userid'] AND $vbulletin->session->created)
{
    $fp = @fopen('memberips.log', 'a');    // <--- add path to writable directory
    if (!empty($fp))
    {
        fwrite($fp, IPADDRESS . ',' . $vbulletin->userinfo['userid'] . ',' . $vbulletin->db->escape_string($vbulletin->userinfo['username']) . "\n");
        fclose($fp);
    }
}

Note that you probably have to add a path to the front of the file name in fopen() to put the log file in a writable directory.

In any case, this logs the user name, id, and ip whenever a session is created. You would probably want to add the data/time to this.

Note: I think this will be OK but I didn't try it on a busy site. I also don't know if the info might somehow already be available from the web server logs.

ETA: of course you could also add a check for the userid if you only want to log that one user.

Andy 02-16-2011 05:22 AM

Thank you kh99. That is a very useful code.

sub_ubi 11-15-2012 04:39 PM

Thank you very much for this code.

--------------- Added [DATE]1353004307[/DATE] at [TIME]1353004307[/TIME] ---------------

Same thing with timestamps added,

Code:

if ($vbulletin->userinfo['userid'] AND $vbulletin->session->created)
{
    $fp = @fopen('memberips.log', 'a');    // <--- add path to writable directory
    if (!empty($fp))
    {
        fwrite($fp, vbdate($vbulletin->options['dateformat'] . ',' . $vbulletin->options['timeformat']) . ',' . $vbulletin->userinfo['userid'] . ',' . $vbulletin->db->escape_string($vbulletin->userinfo['username']) . ',' . IPADDRESS . "\n");
    }
}


RedTurtle 11-19-2012 08:09 AM

Very useful, thanks guys! Any obvious changes needed for it to work on vB4?

ozzy47 10-19-2013 04:22 PM

One thing I noticed with this, is that it only adds it to one line, there is no carriage return after each entry.

--------------- Added [DATE]1382216131[/DATE] at [TIME]1382216131[/TIME] ---------------

Got it, needed to add \r


All times are GMT. The time now is 11:19 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01196 seconds
  • Memory Usage 1,718KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete