‪TYPO3CMS  10.4
NumberOfFailedLoginsDataProvider.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
22 use ‪TYPO3\CMS\Core\SysLog\Action\Login as SystemLogLoginAction;
23 use ‪TYPO3\CMS\Core\SysLog\Error as SystemLogErrorClassification;
24 use ‪TYPO3\CMS\Core\SysLog\Type as SystemLogType;
27 
29 {
30  public function ‪getNumber(int $secondsBack = 86400): int
31  {
32  $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
33  $queryBuilder = $connectionPool->getQueryBuilderForTable('sys_log');
34 
35  return (int)$queryBuilder->count('uid')
36  ->from('sys_log')
37  ->where(
38  $queryBuilder->expr()->eq(
39  'type',
40  $queryBuilder->createNamedParameter(SystemLogType::LOGIN, ‪Connection::PARAM_INT)
41  ),
42  $queryBuilder->expr()->eq(
43  'action',
44  $queryBuilder->createNamedParameter(SystemLogLoginAction::ATTEMPT, ‪Connection::PARAM_INT)
45  ),
46  $queryBuilder->expr()->neq(
47  'error',
48  $queryBuilder->createNamedParameter(SystemLogErrorClassification::MESSAGE, ‪Connection::PARAM_INT)
49  ),
50  $queryBuilder->expr()->gt(
51  'tstamp',
52  $queryBuilder->createNamedParameter(‪$GLOBALS['EXEC_TIME'] - $secondsBack, ‪Connection::PARAM_INT)
53  )
54  )
55  ->execute()
56  ->fetchColumn();
57  }
58 }
‪TYPO3\CMS\Core\Database\Connection\PARAM_INT
‪const PARAM_INT
Definition: Connection.php:47
‪TYPO3\CMS\Dashboard\Widgets\NumberWithIconDataProviderInterface
Definition: NumberWithIconDataProviderInterface.php:24
‪TYPO3\CMS\Core\SysLog\Action\Login
Definition: Login.php:24
‪TYPO3\CMS\Dashboard\Widgets\Provider\NumberOfFailedLoginsDataProvider
Definition: NumberOfFailedLoginsDataProvider.php:29
‪TYPO3\CMS\Core\SysLog\Error
Definition: Error.php:24
‪TYPO3\CMS\Core\Database\Connection
Definition: Connection.php:36
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Dashboard\Widgets\Provider
Definition: ButtonProvider.php:18
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:46
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Dashboard\Widgets\Provider\NumberOfFailedLoginsDataProvider\getNumber
‪getNumber(int $secondsBack=86400)
Definition: NumberOfFailedLoginsDataProvider.php:30
‪TYPO3\CMS\Core\SysLog\Type
Definition: Type.php:24