/**
* Log a user login
*
* @param \Phire\Table\UserTypes $type
* @param \Phire\Table\Users $user
* @return void
*/
protected function log($type, $user)
{
$exclude = array();
if ($type->log_exclude != '') {
$exclude = explode(',', $type->log_exclude);
}
$domain = str_replace('www.', '', $_SERVER['HTTP_HOST']);
if (!in_array($_SERVER['REMOTE_ADDR'], $exclude)) {
$emails = explode(',', $type->log_emails);
$noreply = Table\Config::findById('reply_email')->value;
$options = array('subject' => 'Phire CMS ' . ucfirst(strtolower($type->type)) . ' ' . $this->i18n->__('Login Notification') . ' (' . $domain . ')', 'headers' => array('From' => $noreply . ' <' . $noreply . '>', 'Reply-To' => $noreply . ' <' . $noreply . '>'));
$msg = $this->i18n->__('Someone has logged in as a %1 from %2 using %3.', array(strtolower($type->type), $_SERVER['REMOTE_ADDR'], $user->username));
$logger = new Log\Logger(new Log\Writer\Mail($emails));
$logger->notice($msg, $options);
}
}