Add link to IP addresses in access log

Discussion in 'aMember Pro v.4' started by 187ci, Mar 4, 2012.

  1. 187ci

    187ci New Member

    Joined:
    Dec 19, 2006
    Messages:
    9
    I have tried to find the code for the access log but I think you moved it to an encrypted section with V4.

    It is very useful to have ip addresses linked to http://www.whois.sc/IPADDRESS that way when I am looking through the logs and am unsure about a user I can see where it is coming from.

    You have to understand an ip address by itself is useless because I must copy and paste it every single time I want to do something with it. If the hostname or country was shown it would be much easier. Can you link the ip addresses as I mentioned or move the code to the public section so that I can edit it myself?

    All I want is for example if there is an ip display 127.0.0.1 then it will be <a href="http://www.whois.sc/127.0.0.1">127.0.0.1</a>
  2. CrackBaby

    CrackBaby Member

    Joined:
    Aug 22, 2006
    Messages:
    154
    +1 very helpful!
  3. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    There is nothing encrypted, code is inside application/default/controllers/AdminLogController.php

    We will add this change to future versions.
  4. 187ci

    187ci New Member

    Joined:
    Dec 19, 2006
    Messages:
    9
    Oh cool. For anyone who wants to do this manually just open up that file and do this:

    Below this
    PHP:
     public function renderAccessMember($record)
        {
            return 
    sprintf('<td><a target="_top" href="%s">%s (%s)</a></td>',
                
    $this->getView()->userUrl($record->user_id), $record->member_login$record->member_name);
        }
    ADD THIS
    PHP:
        public function renderIP($record)
        {
            return 
    sprintf('<td><a target="_blank" href="http://www.whois.sc/%s">%s</a></td>',$record->remote_addr,$record->remote_addr);
        }
    Replace this:
    PHP:
    public function createAccess()
        {
            
    $query = new Am_Query($this->getDi()->accessLogTable);
            
    $query->leftJoin('?_user''m''t.user_id=m.user_id')
                ->
    addField("m.login"'member_login')
                ->
    addField("CONCAT(m.name_f, ' ', m.name_l)"'member_name');
            
    $query->setOrder('time''desc');
            
    $g = new Am_Grid_ReadOnly('_access'___('Access Log'), $query$this->getRequest(), $this->view);
            
    $g->setPermissionId(Am_Auth_Admin::PERM_LOGS);
            
    $g->addGridField(new Am_Grid_Field_Date('time'___('Time'), true''null'10%'));
            
    $g->addGridField(new Am_Grid_Field('member_login'___('User'), true'', array($this'renderAccessMember'), '10%'));
            
    $g->addGridField(new Am_Grid_Field_Expandable('url'___('URL'), true''null'20%'));
            
    $g->addGridField(new Am_Grid_Field('remote_addr'___('IP'), true''null'10%'));
            
    $g->addGridField(new Am_Grid_Field_Expandable('referrer'___('Referrer'), true''null'15%'));
            
    $g->setFilter(new Am_Grid_Filter_Text(___('Filter by IP or Referrer or URL'), array(
                
    'remote_addr' => 'LIKE',
                
    'referrer' => 'LIKE',
                
    'url' => 'LIKE',
            )));
            return 
    $g;
        }
    With this:
    PHP:
     public function createAccess()
        {
            
    $query = new Am_Query($this->getDi()->accessLogTable);
            
    $query->leftJoin('?_user''m''t.user_id=m.user_id')
                ->
    addField("m.login"'member_login')
                ->
    addField("CONCAT(m.name_f, ' ', m.name_l)"'member_name');
            
    $query->setOrder('time''desc');
            
    $g = new Am_Grid_ReadOnly('_access'___('Access Log'), $query$this->getRequest(), $this->view);
            
    $g->setPermissionId(Am_Auth_Admin::PERM_LOGS);
            
    $g->addGridField(new Am_Grid_Field_Date('time'___('Time'), true''null'10%'));
            
    $g->addGridField(new Am_Grid_Field('member_login'___('User'), true'', array($this'renderAccessMember'), '10%'));
            
    $g->addGridField(new Am_Grid_Field('url'___('URL'), true''null'20%'));
            
    $g->addGridField(new Am_Grid_Field('remote_addr'___('IP'), true'', array($this'renderIP'), '10%'));
            
    $g->addGridField(new Am_Grid_Field('referrer'___('Referrer'), true''null'15%'));
            
    $g->setFilter(new Am_Grid_Filter_Text(___('Filter by IP or Referrer or URL'), array(
                
    'remote_addr' => 'LIKE',
                
    'referrer' => 'LIKE',
                
    'url' => 'LIKE',
            )));
            return 
    $g;
        }
  5. CrackBaby

    CrackBaby Member

    Joined:
    Aug 22, 2006
    Messages:
    154
    I would like to add it to the Member info page also, which template is that?

    Example:
    Signup Info: 2012-02-27 08:46:47 / 67.185.39.245

    Also the Error and Admin logs
  6. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    AdminUsersController.php in the same folder, seek for "Signup Info" word.

    All logs are rendered by the same AdminLogsController.php

    I'll appreciate a lot if you send fixed files to me so we incorporate this into the next release.

Share This Page