Manually triggering an "access" hit?

Discussion in 'Integration' started by amadeus, Jun 17, 2009.

  1. amadeus

    amadeus Member

    Joined:
    Jan 16, 2009
    Messages:
    42
    I'm writing a custom integration for my software. Right now I have come up with a way to check if a person has a valid subscription using something like this:
    Code:
    $login = 'Username';
    $pass = 'password';
    
    include "/path/to/amember/config.inc.php";
    
    $member_id='';
    if($db->check_login($login, $pass, $member_id))
    {
      $user = $db->get_user($member_id);  // $user - associative array of user info;
       ......
       ......
       ......
    
    However, I was wondering if there was an easy way to register a 'hit' on the access logs for that user. Something like:
    Code:
    // (pseudocode)
    $db->register_access($member_id,$url);
    
    Hopefully my question makes sense. I just want to be able to utilize the nice 'access tracking' system even though my users aren't really logging in and browsing pages, per se.
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    You have to create this code yourself.
    amember have log_access function:
    Code:
    $db->log_access($member_id);
    
    But it can take only $member_id as argument, url will be extracted from $_SERVER array.
  3. amadeus

    amadeus Member

    Joined:
    Jan 16, 2009
    Messages:
    42
    I don't suppose the code for log_access() is available, huh? I could certainly adjust it for my needs if I had it. I could write a routine to add to the MySQL table directly I guess ...but, it'd sure be easier to mimic the same procedure that aMember is doing already for more "traditional" access counting.

    Otherwise, I hope you'll consider providing more optional arguments for that function so we can manually set the information we wish to see (including IP, URL, "custom field", etc.)



    EDIT:
    -----
    It appears that calling that function from within my script creates a nasty warning :( ...any way to supress it?
    Code:
    <b>WARNING:</b> gethostbyaddr(): Address is not a valid IPv4 or IPv6 address
    in line 1605 of file mysql.inc.php<br />
    


    EDIT 2:
    ------
    Now that I went and looked at the 'access_log' table of the aMember database, I think it might be easier than I had originally thought. I didn't realize it had so few fields! But ..then again, if you have the source handy and don't mind sharing that little function, it'd save me half an hour :)
  4. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Have a look at /amember/plugins/db/mysql/mysql.inc.php

Share This Page