Skip to content

Commit

Permalink
Use roundcube table_name() to be able to use db_prefix.
Browse files Browse the repository at this point in the history
  • Loading branch information
dsoares committed May 10, 2016
1 parent b90ab77 commit 7efa676
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lastlogin.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public function write_log($args) //array('name' => $name, 'date' => $date, 'lin
$geo = $this->get_geo($ip);
$dns = $this->get_dns($ip);

$sql = "INSERT INTO " . $this->log_table .
$sql = "INSERT INTO " . $this->table_name() .
"(id, user_id, username, session_id, ip, real_ip, hostname, geoloc) ".
"VALUES (\N, ?, ?, ?, ?, ?, ?, ?);";

Expand All @@ -184,7 +184,7 @@ public function load_log()
{
$sql = "SELECT if(real_ip!='',real_ip,ip) AS `from`, hostname, ".
"UNIX_TIMESTAMP(timestamp) AS `date`, geoloc AS `geo` FROM " .
$this->log_table . " WHERE user_id=? ORDER BY id DESC LIMIT " .
$this->table_name() . " WHERE user_id=? ORDER BY id DESC LIMIT " .
$this->rc->config->get('lastlogin_lastrecords', 10);
$sth = $this->rc->db->query($sql, $this->rc->user->ID);

Expand Down Expand Up @@ -401,4 +401,12 @@ private function _format_date($date)

return $this->rc->format_date($date, "$weekday, d F Y, H:i");
}

/**
* Get table name.
*/
private function table_name()
{
return $this->rc->db->table_name($this->log_table, true);
}
}

0 comments on commit 7efa676

Please sign in to comment.