Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 02-15-2011, 05:20 AM
bryanb's Avatar
bryanb bryanb is offline
 
Join Date: Oct 2003
Location: Bierland
Posts: 174
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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
Reply With Quote
  #2  
Old 02-15-2011, 09:53 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 02-16-2011, 05:22 AM
Andy Andy is offline
 
Join Date: Sep 2003
Location: San Francisco
Posts: 138
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you kh99. That is a very useful code.
Reply With Quote
  #4  
Old 11-15-2012, 04:39 PM
sub_ubi sub_ubi is offline
 
Join Date: Dec 2004
Posts: 177
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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");
    }
}
Reply With Quote
  #5  
Old 11-19-2012, 08:09 AM
RedTurtle's Avatar
RedTurtle RedTurtle is offline
 
Join Date: May 2006
Location: California
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Very useful, thanks guys! Any obvious changes needed for it to work on vB4?
Reply With Quote
  #6  
Old 10-19-2013, 04:22 PM
ozzy47's Avatar
ozzy47 ozzy47 is offline
 
Join Date: Jul 2009
Location: USA
Posts: 10,929
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
Reply


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

Forum Jump


All times are GMT. The time now is 04:06 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.08821 seconds
  • Memory Usage 2,207KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete