File manager - Edit - /home/opticamezl/www/newok/Logger.zip
Back
PK �"�\f�cx� � InMemoryLogger.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2020 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Log\Logger; use Joomla\CMS\Log\LogEntry; use Joomla\CMS\Log\Logger; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Logger class that keeps all entries in memory * * @since 4.0.0 */ class InMemoryLogger extends Logger { /** * List of collected log entries, grouped by $group * * @var array * @since 4.0.0 */ protected static $logEntries = []; /** * Group name to store the entries * * @var string * @since 4.0.0 */ protected $group = 'default'; /** * Constructor. * * @param array &$options Log object options. * * @since 4.0.0 */ public function __construct(array &$options) { parent::__construct($options); if (!empty($this->options['group'])) { $this->group = $this->options['group']; } } /** * Method to add an entry to the log. * * @param LogEntry $entry The log entry object to add to the log. * * @return void * * @since 4.0.0 */ public function addEntry(LogEntry $entry) { static::$logEntries[$this->group][] = $entry; } /** * Returns a list of collected entries. * * @return array * * @since 4.0.0 */ public function getCollectedEntries() { if (empty(static::$logEntries[$this->group])) { return []; } return static::$logEntries[$this->group]; } } PK �"�\��� MessagequeueLogger.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Log\Logger; use Joomla\CMS\Factory; use Joomla\CMS\Log\Log; use Joomla\CMS\Log\LogEntry; use Joomla\CMS\Log\Logger; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Joomla MessageQueue logger class. * * This class is designed to output logs to a specific MySQL database table. Fields in this * table are based on the Syslog style of log output. This is designed to allow quick and * easy searching. * * @since 1.7.0 */ class MessagequeueLogger extends Logger { /** * Method to add an entry to the log. * * @param LogEntry $entry The log entry object to add to the log. * * @return void * * @since 1.7.0 */ public function addEntry(LogEntry $entry) { switch ($entry->priority) { case Log::EMERGENCY: case Log::ALERT: case Log::CRITICAL: case Log::ERROR: Factory::getApplication()->enqueueMessage($entry->message, 'error'); break; case Log::WARNING: Factory::getApplication()->enqueueMessage($entry->message, 'warning'); break; case Log::NOTICE: Factory::getApplication()->enqueueMessage($entry->message, 'notice'); break; case Log::INFO: Factory::getApplication()->enqueueMessage($entry->message, 'message'); break; default: // Ignore other priorities. break; } } } PK �"�\� �� SyslogLogger.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2011 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Log\Logger; use Joomla\CMS\Log\Log; use Joomla\CMS\Log\LogEntry; use Joomla\CMS\Log\Logger; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Joomla! Syslog Log class * * This class is designed to call the PHP Syslog function call which is then sent to the * system wide log system. For Linux/Unix based systems this is the syslog subsystem, for * the Windows based implementations this can be found in the Event Log. For Windows, * permissions may prevent PHP from properly outputting messages. * * @since 1.7.0 */ class SyslogLogger extends Logger { /** * Translation array for LogEntry priorities to SysLog priority names. * * @var array * @since 1.7.0 */ protected $priorities = [ Log::EMERGENCY => 'EMERG', Log::ALERT => 'ALERT', Log::CRITICAL => 'CRIT', Log::ERROR => 'ERR', Log::WARNING => 'WARNING', Log::NOTICE => 'NOTICE', Log::INFO => 'INFO', Log::DEBUG => 'DEBUG', ]; /** * Constructor. * * @param array &$options Log object options. * * @since 1.7.0 */ public function __construct(array &$options) { // Call the parent constructor. parent::__construct($options); // Ensure that we have an identity string for the Syslog entries. if (empty($this->options['sys_ident'])) { $this->options['sys_ident'] = 'Joomla Platform'; } // If the option to add the process id to Syslog entries is set use it, otherwise default to true. if (isset($this->options['sys_add_pid'])) { $this->options['sys_add_pid'] = (bool) $this->options['sys_add_pid']; } else { $this->options['sys_add_pid'] = true; } // If the option to also send Syslog entries to STDERR is set use it, otherwise default to false. if (isset($this->options['sys_use_stderr'])) { $this->options['sys_use_stderr'] = (bool) $this->options['sys_use_stderr']; } else { $this->options['sys_use_stderr'] = false; } // Build the Syslog options from our log object options. $sysOptions = 0; if ($this->options['sys_add_pid']) { $sysOptions = $sysOptions | LOG_PID; } if ($this->options['sys_use_stderr']) { $sysOptions = $sysOptions | LOG_PERROR; } // Default logging facility is LOG_USER for Windows compatibility. $sysFacility = LOG_USER; // If we have a facility passed in and we're not on Windows, reset it. if (isset($this->options['sys_facility']) && !IS_WIN) { $sysFacility = $this->options['sys_facility']; } // Open the Syslog connection. openlog((string) $this->options['sys_ident'], $sysOptions, $sysFacility); } /** * Destructor. * * @since 1.7.0 */ public function __destruct() { closelog(); } /** * Method to add an entry to the log. * * @param LogEntry $entry The log entry object to add to the log. * * @return void * * @since 1.7.0 */ public function addEntry(LogEntry $entry) { // Generate the value for the priority based on predefined constants. $priority = \constant(strtoupper('LOG_' . $this->priorities[$entry->priority])); // Send the entry to Syslog. syslog($priority, '[' . $entry->category . '] ' . $entry->message); } } PK �"�\��� Q Q W3cLogger.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2011 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Log\Logger; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Joomla! W3C Logging class * * This class is designed to build log files based on the W3C specification. * * @link https://www.w3.org/TR/WD-logfile.html * @since 1.7.0 */ class W3cLogger extends FormattedtextLogger { /** * The format which each entry follows in the log file. * * All fields must be named in all caps and be within curly brackets eg. {FOOBAR}. * * @var string * @since 1.7.0 */ protected $format = '{DATE} {TIME} {PRIORITY} {CLIENTIP} {CATEGORY} {MESSAGE}'; /** * Constructor. * * @param array &$options Log object options. * * @since 1.7.0 */ public function __construct(array &$options) { // The name of the text file defaults to 'error.w3c.php' if not explicitly given. if (empty($options['text_file'])) { $options['text_file'] = 'error.w3c.php'; } // Call the parent constructor. parent::__construct($options); } } PK �"�\��`�! �! FormattedtextLogger.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2011 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Log\Logger; use Joomla\CMS\Factory; use Joomla\CMS\Filesystem\File; use Joomla\CMS\Filesystem\Folder; use Joomla\CMS\Log\LogEntry; use Joomla\CMS\Log\Logger; use Joomla\CMS\Version; use Joomla\Utilities\IpHelper; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Joomla! Formatted Text File Log class * * This class is designed to use as a base for building formatted text files for output. By * default it emulates the Syslog style format output. This is a disk based output format. * * @since 1.7.0 */ class FormattedtextLogger extends Logger { /** * The format which each entry follows in the log file. * * All fields must be named in all caps and be within curly brackets eg. {FOOBAR}. * * @var string * @since 1.7.0 */ protected $format = '{DATETIME} {PRIORITY} {CLIENTIP} {CATEGORY} {MESSAGE}'; /** * The parsed fields from the format string. * * @var array * @since 1.7.0 */ protected $fields = []; /** * The full filesystem path for the log file. * * @var string * @since 1.7.0 */ protected $path; /** * If true, all writes will be deferred as long as possible. * NOTE: Deferred logs may never be written if the application encounters a fatal error. * * @var boolean * @since 3.9.0 */ protected $defer = false; /** * If deferring, entries will be stored here prior to writing. * * @var array * @since 3.9.0 */ protected $deferredEntries = []; /** * Constructor. * * @param array &$options Log object options. * * @since 1.7.0 */ public function __construct(array &$options) { // Call the parent constructor. parent::__construct($options); // The name of the text file defaults to 'error.php' if not explicitly given. if (empty($this->options['text_file'])) { $this->options['text_file'] = 'error.php'; } // The name of the text file path defaults to that which is set in configuration if not explicitly given. if (empty($this->options['text_file_path'])) { $this->options['text_file_path'] = Factory::getApplication()->get('log_path', JPATH_ADMINISTRATOR . '/logs'); } // False to treat the log file as a php file. if (empty($this->options['text_file_no_php'])) { $this->options['text_file_no_php'] = false; } // Build the full path to the log file. $this->path = $this->options['text_file_path'] . '/' . $this->options['text_file']; // Use the default entry format unless explicitly set otherwise. if (!empty($this->options['text_entry_format'])) { $this->format = (string) $this->options['text_entry_format']; } // Wait as long as possible before writing logs if (!empty($this->options['defer'])) { $this->defer = (bool) $this->options['defer']; } // Build the fields array based on the format string. $this->parseFields(); } /** * If deferred, write all pending logs. * * @since 3.9.0 */ public function __destruct() { // Nothing to do if (!$this->defer || empty($this->deferredEntries)) { return; } // Initialise the file if not already done. $this->initFile(); // Format all lines and write to file. $lines = array_map([$this, 'formatLine'], $this->deferredEntries); if (!File::append($this->path, implode("\n", $lines) . "\n")) { throw new \RuntimeException('Cannot write to log file.'); } } /** * Method to add an entry to the log. * * @param LogEntry $entry The log entry object to add to the log. * * @return void * * @since 1.7.0 * @throws \RuntimeException */ public function addEntry(LogEntry $entry) { // Store the entry to be written later. if ($this->defer) { $this->deferredEntries[] = $entry; } else { // Write it immediately. // Initialise the file if not already done. $this->initFile(); // Write the new entry to the file. $line = $this->formatLine($entry); $line .= "\n"; if (!File::append($this->path, $line)) { throw new \RuntimeException('Cannot write to log file.'); } } } /** * Format a line for the log file. * * @param LogEntry $entry The log entry to format as a string. * * @return String * * @since 3.9.0 */ protected function formatLine(LogEntry $entry) { // Set some default field values if not already set. if (!isset($entry->clientIP)) { $ip = IpHelper::getIp(); if ($ip !== '') { $entry->clientIP = $ip; } } // If the time field is missing or the date field isn't only the date we need to rework it. if ((\strlen($entry->date) != 10) || !isset($entry->time)) { // Get the date and time strings in GMT. $entry->datetime = $entry->date->toISO8601(); $entry->time = $entry->date->format('H:i:s', false); $entry->date = $entry->date->format('Y-m-d', false); } // Get a list of all the entry keys and make sure they are upper case. $tmp = array_change_key_case(get_object_vars($entry), CASE_UPPER); // Decode the entry priority into an English string. $tmp['PRIORITY'] = $this->priorities[$entry->priority]; // Fill in field data for the line. $line = $this->format; foreach ($this->fields as $field) { $line = str_replace('{' . $field . '}', $tmp[$field] ?? '-', $line); } return $line; } /** * Method to generate the log file header. * * @return string The log file header * * @since 1.7.0 */ protected function generateFileHeader() { $head = []; // Build the log file header. // If the no php flag is not set add the php die statement. if (empty($this->options['text_file_no_php'])) { // Blank line to prevent information disclose: https://bugs.php.net/bug.php?id=60677 $head[] = '#'; $head[] = '#<?php die(\'Forbidden.\'); ?>'; } $head[] = '#Date: ' . gmdate('Y-m-d H:i:s') . ' UTC'; $head[] = '#Software: ' . (new Version())->getLongVersion(); $head[] = ''; // Prepare the fields string $head[] = '#Fields: ' . strtolower(str_replace('}', '', str_replace('{', '', $this->format))); $head[] = ''; return implode("\n", $head); } /** * Method to initialise the log file. This will create the folder path to the file if it doesn't already * exist and also get a new file header if the file doesn't already exist. If the file already exists it * will simply open it for writing. * * @return void * * @since 1.7.0 * @throws \RuntimeException */ protected function initFile() { // We only need to make sure the file exists if (is_file($this->path)) { return; } // Make sure the folder exists in which to create the log file. Folder::create(\dirname($this->path)); // Build the log file header. $head = $this->generateFileHeader(); if (!File::write($this->path, $head)) { throw new \RuntimeException('Cannot write to log file.'); } } /** * Method to parse the format string into an array of fields. * * @return void * * @since 1.7.0 */ protected function parseFields() { $this->fields = []; $matches = []; // Get all of the available fields in the format string. preg_match_all('/{(.*?)}/i', $this->format, $matches); // Build the parsed fields list based on the found fields. foreach ($matches[1] as $match) { $this->fields[] = strtoupper($match); } } } PK �"�\�: � � EchoLogger.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2011 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Log\Logger; use Joomla\CMS\Log\LogEntry; use Joomla\CMS\Log\Logger; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Joomla Echo logger class. * * @since 1.7.0 */ class EchoLogger extends Logger { /** * Value to use at the end of an echoed log entry to separate lines. * * @var string * @since 1.7.0 */ protected $line_separator = "\n"; /** * Constructor. * * @param array &$options Log object options. * * @since 3.0.0 */ public function __construct(array &$options) { parent::__construct($options); if (!empty($this->options['line_separator'])) { $this->line_separator = $this->options['line_separator']; } } /** * Method to add an entry to the log. * * @param LogEntry $entry The log entry object to add to the log. * * @return void * * @since 1.7.0 */ public function addEntry(LogEntry $entry) { echo $this->priorities[$entry->priority] . ': ' . $entry->message . (empty($entry->category) ? '' : ' [' . $entry->category . ']') . $this->line_separator; } } PK �"�\����. . CallbackLogger.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2012 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Log\Logger; use Joomla\CMS\Log\LogEntry; use Joomla\CMS\Log\Logger; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Joomla! Callback Log class * * This class allows logging to be handled by a callback function. * This allows unprecedented flexibility in the way logging can be handled. * * @since 3.0.1 */ class CallbackLogger extends Logger { /** * The function to call when an entry is added * * @var callable * @since 3.0.1 */ protected $callback; /** * Constructor. * * @param array &$options Log object options. * * @since 3.0.1 * @throws \RuntimeException */ public function __construct(array &$options) { // Call the parent constructor. parent::__construct($options); // Throw an exception if there is not a valid callback if (!isset($this->options['callback']) || !\is_callable($this->options['callback'])) { throw new \RuntimeException(sprintf('%s created without valid callback function.', \get_class($this))); } $this->callback = $this->options['callback']; } /** * Method to add an entry to the log. * * @param LogEntry $entry The log entry object to add to the log. * * @return void * * @since 3.0.1 * @throws \RuntimeException */ public function addEntry(LogEntry $entry) { // Pass the log entry to the callback function \call_user_func($this->callback, $entry); } } PK �"�\vX�) DatabaseLogger.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2011 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Log\Logger; use Joomla\CMS\Factory; use Joomla\CMS\Log\LogEntry; use Joomla\CMS\Log\Logger; use Joomla\Database\DatabaseDriver; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Joomla! MySQL Database Log class * * This class is designed to output logs to a specific MySQL database table. Fields in this * table are based on the Syslog style of log output. This is designed to allow quick and * easy searching. * * @since 1.7.0 */ class DatabaseLogger extends Logger { /** * The name of the database driver to use for connecting to the database. * * @var string * @since 1.7.0 */ protected $driver = 'mysqli'; /** * The host name (or IP) of the server with which to connect for the logger. * * @var string * @since 1.7.0 */ protected $host = '127.0.0.1'; /** * The database server user to connect as for the logger. * * @var string * @since 1.7.0 */ protected $user = 'root'; /** * The password to use for connecting to the database server. * * @var string * @since 1.7.0 */ protected $password = ''; /** * The name of the database table to use for the logger. * * @var string * @since 1.7.0 */ protected $database = 'logging'; /** * The database table prefix of the database store logging entries. * * @var string * @since 4.3.0 */ protected $prefix; /** * The database table to use for logging entries. * * @var string * @since 1.7.0 */ protected $table = 'jos_'; /** * The database driver object for the logger. * * @var DatabaseDriver * @since 1.7.0 */ protected $db; /** * Constructor. * * @param array &$options Log object options. * * @since 1.7.0 */ public function __construct(array &$options) { // Call the parent constructor. parent::__construct($options); // If both the database object and driver options are empty we want to use the system database connection. if (empty($this->options['db_driver'])) { $this->db = Factory::getDbo(); $this->driver = null; $this->host = null; $this->user = null; $this->password = null; $this->database = null; $this->prefix = null; } else { $this->db = null; $this->driver = (empty($this->options['db_driver'])) ? 'mysqli' : $this->options['db_driver']; $this->host = (empty($this->options['db_host'])) ? '127.0.0.1' : $this->options['db_host']; $this->user = (empty($this->options['db_user'])) ? 'root' : $this->options['db_user']; $this->password = (empty($this->options['db_pass'])) ? '' : $this->options['db_pass']; $this->database = (empty($this->options['db_database'])) ? 'logging' : $this->options['db_database']; $this->prefix = (empty($this->options['db_prefix'])) ? 'jos_' : $this->options['db_prefix']; } // The table name is independent of how we arrived at the connection object. $this->table = (empty($this->options['db_table'])) ? '#__log_entries' : $this->options['db_table']; } /** * Method to add an entry to the log. * * @param LogEntry $entry The log entry object to add to the log. * * @return void * * @since 1.7.0 * @throws \RuntimeException */ public function addEntry(LogEntry $entry) { // Connect to the database if not connected. if (empty($this->db)) { $this->connect(); } // Convert the date. $entry->date = $entry->date->toSql(false, $this->db); $this->db->insertObject($this->table, $entry); } /** * Method to connect to the database server based on object properties. * * @return void * * @since 1.7.0 * @throws \RuntimeException */ protected function connect() { // Build the configuration object to use for DatabaseDriver. $options = [ 'driver' => $this->driver, 'host' => $this->host, 'user' => $this->user, 'password' => $this->password, 'database' => $this->database, 'prefix' => $this->prefix, ]; $this->db = DatabaseDriver::getInstance($options); } } PK �"�\f�cx� � InMemoryLogger.phpnu �[��� PK �"�\��� > MessagequeueLogger.phpnu �[��� PK �"�\� �� � SyslogLogger.phpnu �[��� PK �"�\��� Q Q � W3cLogger.phpnu �[��� PK �"�\��`�! �! t# FormattedtextLogger.phpnu �[��� PK �"�\�: � � �E EchoLogger.phpnu �[��� PK �"�\����. . �K CallbackLogger.phpnu �[��� PK �"�\vX�) S DatabaseLogger.phpnu �[��� PK � Zf
| ver. 1.4 |
Github
|
.
| PHP 8.3.23 | Generation time: 0 |
proxy
|
phpinfo
|
Settings