[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/plugins/system/log/ -> log.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Plugin
   5   * @subpackage  System.log
   6   *
   7   * @copyright   (C) 2007 Open Source Matters, Inc. <https://www.joomla.org>
   8   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   9  
  10   * @phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
  11   */
  12  
  13  use Joomla\CMS\Authentication\Authentication;
  14  use Joomla\CMS\Log\Log;
  15  use Joomla\CMS\Plugin\CMSPlugin;
  16  
  17  // phpcs:disable PSR1.Files.SideEffects
  18  \defined('_JEXEC') or die;
  19  // phpcs:enable PSR1.Files.SideEffects
  20  
  21  /**
  22   * Joomla! System Logging Plugin.
  23   *
  24   * @since  1.5
  25   */
  26  class PlgSystemLog extends CMSPlugin
  27  {
  28      /**
  29       * Called if user fails to be logged in.
  30       *
  31       * @param   array  $response  Array of response data.
  32       *
  33       * @return  void
  34       *
  35       * @since   1.5
  36       */
  37      public function onUserLoginFailure($response)
  38      {
  39          $errorlog = array();
  40  
  41          switch ($response['status']) {
  42              case Authentication::STATUS_SUCCESS:
  43                  $errorlog['status']  = $response['type'] . ' CANCELED: ';
  44                  $errorlog['comment'] = $response['error_message'];
  45                  break;
  46  
  47              case Authentication::STATUS_FAILURE:
  48                  $errorlog['status']  = $response['type'] . ' FAILURE: ';
  49  
  50                  if ($this->params->get('log_username', 0)) {
  51                      $errorlog['comment'] = $response['error_message'] . ' ("' . $response['username'] . '")';
  52                  } else {
  53                      $errorlog['comment'] = $response['error_message'];
  54                  }
  55                  break;
  56  
  57              default:
  58                  $errorlog['status']  = $response['type'] . ' UNKNOWN ERROR: ';
  59                  $errorlog['comment'] = $response['error_message'];
  60                  break;
  61          }
  62  
  63          Log::addLogger(array(), Log::INFO);
  64  
  65          try {
  66              Log::add($errorlog['comment'], Log::INFO, $errorlog['status']);
  67          } catch (Exception $e) {
  68              // If the log file is unwriteable during login then we should not go to the error page
  69              return;
  70          }
  71      }
  72  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer