You are here

private function SpiController::getLastUsers in Acquia Connector 8

Same name and namespace in other branches
  1. 8.2 src/Controller/SpiController.php \Drupal\acquia_connector\Controller\SpiController::getLastUsers()
  2. 3.x src/Controller/SpiController.php \Drupal\acquia_connector\Controller\SpiController::getLastUsers()

Get last 15 users created.

Useful for determining if your site is compromised.

Return value

array The details of last 15 users created.

1 call to SpiController::getLastUsers()
SpiController::get in src/Controller/SpiController.php
Gather site profile information about this site.

File

src/Controller/SpiController.php, line 384

Class

SpiController
SPI Controller class.

Namespace

Drupal\acquia_connector\Controller

Code

private function getLastUsers() {
  $last_five_users = [];
  $result = Database::getConnection()
    ->select('users_field_data', 'u')
    ->fields('u', [
    'uid',
    'name',
    'mail',
    'created',
  ])
    ->condition('u.created', \Drupal::time()
    ->getRequestTime() - 3600, '>')
    ->orderBy('created', 'DESC')
    ->range(0, 15)
    ->execute();
  $count = 0;
  foreach ($result as $record) {
    $last_five_users[$count]['uid'] = $record->uid;
    $last_five_users[$count]['name'] = $record->name;
    $last_five_users[$count]['email'] = $record->mail;
    $last_five_users[$count]['created'] = $record->created;
    $count++;
  }
  return $last_five_users;
}