Not Solved User IP Log plugin function iplog_exec() problem
#1
Not Solved Bug 
function iplog_exec(), in file iplog.php @ line 72, only works if the login attempt succeeded; otherwise, $user['uid'] is empty, causing an SQL error upon Insert of the uid column data (i.e., '' ) into table iplogs.

Note that iplogs.uid is an Integer column; and besides, what good is logging the IP if you don't know what the uid (or who the user) is.

Proposed fix (which I've just tried successfully):
function iplog_exec()
{
  global $user, $db;
  // ***** Added if() condition to prevent SQL error after failed login
  if ( isset( $user['uid'] ) && !empty( $user['uid'] ) ) {
    $values = array(
      'uid'       => $db->escape_string( $user['uid'] ),
      'ipaddress' => $db->escape_string( get_ip() ),
      'dateline'  => $db->escape_string( time() )
    );
    $db->insert_query( 'iplogs', $values );
  }
}

Thanks.

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)