1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

A page which logs the IP of the visitor and stores it to the database

Discussion in 'XenForo Development Discussions' started by arcaneex, Aug 19, 2012.

  1. arcaneex

    arcaneex Active Member

    A member , admin or a guest. Every person which visit a page should have his IP logged and stored. Is it possible to do it?
     
  2. arcaneex

    arcaneex Active Member

    Okay I found the code to store/show the IP. But how do I make it work on the page and how to I make it store it on the database?
     
  3. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Which page exactly? You will likely need a small addon to do the IP logging.
     
  4. arcaneex

    arcaneex Active Member

    A simple xenforo page , added using the new page through ACP.
     
  5. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    You can specify a callback for your page node. Code example:

    http://xenforo.com/community/thread...er-custom-fields-on-a-page.33744/#post-384478

    With your callback you can add code to log the IP. Here is code taken from the register controller for logging the IP:

    Code:
    XenForo_Model_Ip::log($user['user_id'], 'user', $user['user_id'], 'register');
    
    You need to pass in your own values when calling this function.
     
  6. arcaneex

    arcaneex Active Member

  7. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    XenForo already has a system for IP logging. Just use the XenForo_Model_Ip class (code example above).
     
  8. arcaneex

    arcaneex Active Member

    Yes but I need it to log Visitor IP's too.
     
  9. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    XenForo_Model_Ip logs the IP of the visitor. Just call that log() function as shown in the above code example. See this file for the class code:

    library/XenForo/Model/Ip.php
     
  10. arcaneex

    arcaneex Active Member

    I really don't understand what this means : ($user['user_id'], 'user', $user['user_id'], 'register'); can you please explain?
     
  11. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

Share This Page