You are here

function acquia_spi_get_failed_logins in Acquia Connector 7.2

Same name and namespace in other branches
  1. 6.2 acquia_spi/acquia_spi.module \acquia_spi_get_failed_logins()
  2. 7.3 acquia_spi/acquia_spi.module \acquia_spi_get_failed_logins()

Get the information on failed logins in the last cron interval

Parameters

n/a:

Return value

array

1 call to acquia_spi_get_failed_logins()
acquia_spi_get in acquia_spi/acquia_spi.module
Gather site profile information about this site.

File

acquia_spi/acquia_spi.module, line 1266
Send site profile information (NSPI) and system data to Acquia Insight.

Code

function acquia_spi_get_failed_logins() {
  $last_logins = array();
  $cron_interval = variable_get('acquia_spi_cron_interval', 8 * 60 * 60);
  if (module_exists('dblog')) {
    $result = db_select('watchdog', 'w')
      ->fields('w', array(
      'message',
      'variables',
    ))
      ->condition('w.message', 'login attempty failed%', 'LIKE')
      ->condition('w.timestamp', REQUEST_TIME - $cron_interval, '>')
      ->condition('w.message', array(
      "UPGRADE.txt",
      "MAINTAINERS.txt",
      "README.txt",
      "INSTALL.pgsql.txt",
      "INSTALL.txt",
      "LICENSE.txt",
      "INSTALL.mysql.txt",
      "COPYRIGHT.txt",
      "CHANGELOG.txt",
    ), 'NOT IN')
      ->orderBy('w.timestamp', 'DESC')
      ->range(0, 10)
      ->execute();
    foreach ($result as $record) {
      $variables = unserialize($record->variables);
      $last_logins['failed'][$record->timestamp] = check_plain($variables['%user']);
    }
  }
  return $last_logins;
}