Файловый менеджер - Редактировать - /var/www/html/actionlogs.zip
Ðазад
PK ! �,U�i4 i4 src/Extension/ActionLogs.phpnu �[��� <?php /** * @package Joomla.Plugins * @subpackage System.actionlogs * * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Plugin\System\ActionLogs\Extension; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Event\Application\AfterInitialiseEvent; use Joomla\CMS\Event\Model; use Joomla\CMS\Event\User; use Joomla\CMS\Form\Form; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; use Joomla\CMS\Plugin\CMSPlugin; use Joomla\CMS\Plugin\PluginHelper; use Joomla\CMS\User\UserFactoryAwareTrait; use Joomla\Component\Actionlogs\Administrator\Helper\ActionlogsHelper; use Joomla\Database\DatabaseAwareTrait; use Joomla\Database\Exception\ExecutionFailureException; use Joomla\Database\ParameterType; use Joomla\Event\Priority; use Joomla\Event\SubscriberInterface; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Joomla! Users Actions Logging Plugin. * * @since 3.9.0 */ final class ActionLogs extends CMSPlugin implements SubscriberInterface { use DatabaseAwareTrait; use UserFactoryAwareTrait; /** * Returns an array of events this subscriber will listen to. * * @return array * * @since 5.3.0 */ public static function getSubscribedEvents(): array { return [ 'onAfterInitialise' => ['onAfterInitialise', Priority::ABOVE_NORMAL], 'onContentPrepareForm' => 'onContentPrepareForm', 'onContentPrepareData' => 'onContentPrepareData', 'onUserAfterSave' => 'onUserAfterSave', 'onUserAfterDelete' => 'onUserAfterDelete', 'onExtensionAfterSave' => 'onExtensionAfterSave', ]; } /** * After initialise listener. * * @param AfterInitialiseEvent $event The event instance. * * @return void * * @since 5.3.0 */ public function onAfterInitialise(AfterInitialiseEvent $event): void { // Import actionlog plugin group so that these plugins will be triggered for events PluginHelper::importPlugin('actionlog', null, true, $event->getApplication()->getDispatcher()); } /** * Adds additional fields to the user editing form for logs e-mail notifications * * @param Model\PrepareFormEvent $event The event instance. * * @return void * * @since 3.9.0 * * @throws \Exception */ public function onContentPrepareForm(Model\PrepareFormEvent $event): void { $form = $event->getForm(); $data = $event->getData(); $formName = $form->getName(); $allowedFormNames = [ 'com_users.profile', 'com_users.user', ]; if (!\in_array($formName, $allowedFormNames, true)) { return; } /** * We only allow users who have Super User permission to change this setting for themselves or for other * users who have the same Super User permission */ $user = $this->getApplication()->getIdentity(); if (!$user || !$user->authorise('core.admin')) { return; } // Load plugin language files. $this->loadLanguage(); // If we are on the save command, no data is passed to $data variable, we need to get it directly from request $jformData = $this->getApplication()->getInput()->get('jform', [], 'array'); if ($jformData && !$data) { $data = $jformData; } if (\is_array($data)) { $data = (object) $data; } if (empty($data->id) || !$this->getUserFactory()->loadUserById($data->id)->authorise('core.admin')) { return; } Form::addFormPath(JPATH_PLUGINS . '/' . $this->_type . '/' . $this->_name . '/forms'); if ((!PluginHelper::isEnabled('actionlog', 'joomla')) && ($this->getApplication()->isClient('administrator'))) { $form->loadFile('information', false); return; } if (!PluginHelper::isEnabled('actionlog', 'joomla')) { return; } $form->loadFile('actionlogs', false); } /** * Runs on content preparation * * @param Model\PrepareDataEvent $event The event instance. * * @return void * * @since 3.9.0 */ public function onContentPrepareData(Model\PrepareDataEvent $event): void { $context = $event->getContext(); if (!\in_array($context, ['com_users.profile', 'com_users.user'])) { return; } $data = $event->getData(); if (\is_array($data)) { $data = (object) $data; } if (empty($data->id) || !$this->getUserFactory()->loadUserById($data->id)->authorise('core.admin')) { return; } $db = $this->getDatabase(); $id = (int) $data->id; $query = $db->getQuery(true) ->select($db->quoteName(['notify', 'extensions'])) ->from($db->quoteName('#__action_logs_users')) ->where($db->quoteName('user_id') . ' = :userid') ->bind(':userid', $id, ParameterType::INTEGER); try { $values = $db->setQuery($query)->loadObject(); } catch (ExecutionFailureException) { return; } if (!$values) { return; } // Load plugin language files. $this->loadLanguage(); $data->actionlogs = new \stdClass(); $data->actionlogs->actionlogsNotify = $values->notify; $data->actionlogs->actionlogsExtensions = $values->extensions; if (!HTMLHelper::isRegistered('users.actionlogsNotify')) { HTMLHelper::register('users.actionlogsNotify', [__CLASS__, 'renderActionlogsNotify']); } if (!HTMLHelper::isRegistered('users.actionlogsExtensions')) { HTMLHelper::register('users.actionlogsExtensions', [__CLASS__, 'renderActionlogsExtensions']); } } /** * Utility method to act on a user after it has been saved. * * @param User\AfterSaveEvent $event The event instance. * * @return void * * @since 3.9.0 */ public function onUserAfterSave(User\AfterSaveEvent $event): void { if (!$event->getSavingResult()) { return; } $user = $event->getUser(); // Clear access rights in case user groups were changed. $userObject = $this->getUserFactory()->loadUserById($user['id']); $userObject->clearAccessRights(); $authorised = $userObject->authorise('core.admin'); $userid = (int) $user['id']; $db = $this->getDatabase(); $query = $db->getQuery(true) ->select('COUNT(*)') ->from($db->quoteName('#__action_logs_users')) ->where($db->quoteName('user_id') . ' = :userid') ->bind(':userid', $userid, ParameterType::INTEGER); try { $exists = (bool) $db->setQuery($query)->loadResult(); } catch (ExecutionFailureException $e) { return; } $query->clear(); // If preferences don't exist, insert. if (!$exists && $authorised && isset($user['actionlogs'])) { $notify = (int) $user['actionlogs']['actionlogsNotify']; $values = [':userid', ':notify']; $bind = [$userid, $notify]; $columns = ['user_id', 'notify']; $query->bind($values, $bind, ParameterType::INTEGER); if (isset($user['actionlogs']['actionlogsExtensions'])) { $values[] = ':extension'; $columns[] = 'extensions'; $extension = json_encode($user['actionlogs']['actionlogsExtensions']); $query->bind(':extension', $extension); } $query->insert($db->quoteName('#__action_logs_users')) ->columns($db->quoteName($columns)) ->values(implode(',', $values)); } elseif ($exists && $authorised && isset($user['actionlogs'])) { // Update preferences. $notify = (int) $user['actionlogs']['actionlogsNotify']; $values = [$db->quoteName('notify') . ' = :notify']; $query->bind(':notify', $notify, ParameterType::INTEGER); if (isset($user['actionlogs']['actionlogsExtensions'])) { $values[] = $db->quoteName('extensions') . ' = :extension'; $extension = json_encode($user['actionlogs']['actionlogsExtensions']); $query->bind(':extension', $extension); } $query->update($db->quoteName('#__action_logs_users')) ->set($values) ->where($db->quoteName('user_id') . ' = :userid') ->bind(':userid', $userid, ParameterType::INTEGER); } elseif ($exists && !$authorised) { // Remove preferences if user is not authorised. $query->delete($db->quoteName('#__action_logs_users')) ->where($db->quoteName('user_id') . ' = :userid') ->bind(':userid', $userid, ParameterType::INTEGER); } else { return; } try { $db->setQuery($query)->execute(); } catch (ExecutionFailureException) { // Do nothing. } } /** * Removes user preferences * * Method is called after user data is deleted from the database * * @param User\AfterDeleteEvent $event The event instance. * * @return void * * @since 3.9.0 */ public function onUserAfterDelete(User\AfterDeleteEvent $event): void { if (!$event->getDeletingResult()) { return; } $user = $event->getUser(); $db = $this->getDatabase(); $userid = (int) $user['id']; $query = $db->getQuery(true) ->delete($db->quoteName('#__action_logs_users')) ->where($db->quoteName('user_id') . ' = :userid') ->bind(':userid', $userid, ParameterType::INTEGER); try { $db->setQuery($query)->execute(); } catch (ExecutionFailureException) { // Do nothing. } } /** * Method to render a value. * * @param integer|string $value The value (0 or 1). * * @return string The rendered value. * * @since 3.9.16 */ public static function renderActionlogsNotify($value) { return Text::_($value ? 'JYES' : 'JNO'); } /** * Method to render a list of extensions. * * @param array|string $extensions Array of extensions or an empty string if none selected. * * @return string The rendered value. * * @since 3.9.16 */ public static function renderActionlogsExtensions($extensions) { // No extensions selected. if (!$extensions) { return Text::_('JNONE'); } foreach ($extensions as &$extension) { // Load extension language files and translate extension name. ActionlogsHelper::loadTranslationFiles($extension); $extension = Text::_($extension); } return implode(', ', $extensions); } /** * On Saving extensions logging method. * Method is called when an extension is being saved * * @param Model\AfterSaveEvent $event The event instance. * * @return void * * @since 5.1.0 */ public function onExtensionAfterSave(Model\AfterSaveEvent $event): void { $context = $event->getContext(); $table = $event->getItem(); if ($context !== 'com_config.component' || $table->name !== 'com_actionlogs') { return; } $params = ComponentHelper::getParams('com_actionlogs'); $globalExt = (array) $params->get('loggable_extensions', []); $db = $this->getDatabase(); $query = $db->getQuery(true) ->select($db->quoteName(['user_id', 'notify', 'extensions'])) ->from($db->quoteName('#__action_logs_users')); try { $values = $db->setQuery($query)->loadObjectList(); } catch (ExecutionFailureException) { return; } foreach ($values as $item) { $userExt = substr($item->extensions, 2); $userExt = substr($userExt, 0, -2); $user = explode('","', $userExt); $common = array_intersect($globalExt, $user); $extension = json_encode(array_values($common)); $query->clear() ->update($db->quoteName('#__action_logs_users')) ->set($db->quoteName('extensions') . ' = :extension') ->where($db->quoteName('user_id') . ' = :userid') ->bind(':userid', $item->user_id, ParameterType::INTEGER) ->bind(':extension', $extension); try { $db->setQuery($query)->execute(); } catch (ExecutionFailureException) { // Do nothing. } } } } PK ! .}H� � services/provider.phpnu �[��� <?php /** * @package Joomla.Plugin * @subpackage System.actionlogs * * @copyright (C) 2023 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ \defined('_JEXEC') or die; use Joomla\CMS\Extension\PluginInterface; use Joomla\CMS\Factory; use Joomla\CMS\Plugin\PluginHelper; use Joomla\CMS\User\UserFactoryInterface; use Joomla\Database\DatabaseInterface; use Joomla\DI\Container; use Joomla\DI\ServiceProviderInterface; use Joomla\Plugin\System\ActionLogs\Extension\ActionLogs; return new class () implements ServiceProviderInterface { /** * Registers the service provider with a DI container. * * @param Container $container The DI container. * * @return void * * @since 4.4.0 */ public function register(Container $container): void { $container->set( PluginInterface::class, function (Container $container) { $plugin = new ActionLogs( (array) PluginHelper::getPlugin('system', 'actionlogs') ); $plugin->setApplication(Factory::getApplication()); $plugin->setDatabase($container->get(DatabaseInterface::class)); $plugin->setUserFactory($container->get(UserFactoryInterface::class)); return $plugin; } ); } }; PK ! d� � actionlogs.xmlnu �[��� <?xml version="1.0" encoding="UTF-8"?> <extension type="plugin" group="system" method="upgrade"> <name>plg_system_actionlogs</name> <author>Joomla! Project</author> <creationDate>2018-05</creationDate> <copyright>(C) 2018 Open Source Matters, Inc.</copyright> <license>GNU General Public License version 2 or later; see LICENSE.txt</license> <authorEmail>admin@joomla.org</authorEmail> <authorUrl>www.joomla.org</authorUrl> <version>3.9.0</version> <description>PLG_SYSTEM_ACTIONLOGS_XML_DESCRIPTION</description> <namespace path="src">Joomla\Plugin\System\ActionLogs</namespace> <files> <folder>forms</folder> <folder plugin="actionlogs">services</folder> <folder>src</folder> </files> <languages> <language tag="en-GB">language/en-GB/plg_system_actionlogs.ini</language> <language tag="en-GB">language/en-GB/plg_system_actionlogs.sys.ini</language> </languages> </extension> PK ! � {�� � forms/information.xmlnu �[��� <?xml version="1.0" encoding="UTF-8"?> <form> <fields name="params"> <fieldset name="information" label="PLG_SYSTEM_ACTIONLOGS_OPTIONS"> <field addfieldprefix="Joomla\Component\Actionlogs\Administrator\Field" name="Information" type="plugininfo" label="PLG_SYSTEM_ACTIONLOGS_INFO_LABEL" description="PLG_SYSTEM_ACTIONLOGS_INFO_DESC" /> </fieldset> </fields> </form> PK ! � forms/actionlogs.xmlnu �[��� <?xml version="1.0" encoding="UTF-8"?> <form> <fieldset name="actionlogs" label="PLG_SYSTEM_ACTIONLOGS_OPTIONS" addfieldprefix="Joomla\Component\Actionlogs\Administrator\Field"> <fields name="actionlogs"> <field name="actionlogsNotify" type="radio" label="PLG_SYSTEM_ACTIONLOGS_NOTIFICATIONS" layout="joomla.form.field.radio.switcher" default="0" filter="integer" > <option value="0">JNO</option> <option value="1">JYES</option> </field> <field name="actionlogsExtensions" type="userlogtype" label="PLG_SYSTEM_ACTIONLOGS_EXTENSIONS_NOTIFICATIONS" multiple="true" validate="options" layout="joomla.form.field.list-fancy-select" showon="actionlogsNotify:1" default="com_content" /> </fields> </fieldset> </form> PK ! ���`� � default.xmlnu �[��� <?xml version="1.0" encoding="UTF-8"?> <metadata> <layout title="COM_ACTIONLOGS_VIEW_DEFAULT_TITLE"> <message> <![CDATA[COM_ACTIONLOGS_VIEW_DEFAULT_DESC]]> </message> </layout> </metadata> PK ! FT*) ) default.phpnu �[��� <?php /** * @package Joomla.Administrator * @subpackage com_actionlogs * * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; use Joomla\CMS\Layout\LayoutHelper; use Joomla\CMS\Router\Route; use Joomla\Component\Actionlogs\Administrator\Helper\ActionlogsHelper; use Joomla\Component\Actionlogs\Administrator\View\Actionlogs\HtmlView; /** @var HtmlView $this */ $listOrder = $this->escape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); /** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ $wa = $this->getDocument()->getWebAssetManager(); $wa->useScript('keepalive') ->useScript('table.columns') ->useScript('multiselect') ->useScript('com_actionlogs.admin-actionlogs'); ?> <form action="<?php echo Route::_('index.php?option=com_actionlogs&view=actionlogs'); ?>" method="post" name="adminForm" id="adminForm"> <div id="j-main-container" class="j-main-container"> <?php // Search tools bar ?> <?php echo LayoutHelper::render('joomla.searchtools.default', ['view' => $this]); ?> <?php if (empty($this->items)) : ?> <div class="alert alert-info"> <span class="icon-info-circle" aria-hidden="true"></span><span class="visually-hidden"><?php echo Text::_('INFO'); ?></span> <?php echo Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?> </div> <?php else : ?> <table class="table" id="logsList"> <caption class="visually-hidden"> <?php echo Text::_('COM_ACTIONLOGS_TABLE_CAPTION'); ?>, <span id="orderedBy"><?php echo Text::_('JGLOBAL_SORTED_BY'); ?> </span>, <span id="filteredBy"><?php echo Text::_('JGLOBAL_FILTERED_BY'); ?></span> </caption> <thead> <tr> <td class="w-1 text-center"> <?php echo HTMLHelper::_('grid.checkall'); ?> </td> <th scope="col" class="d-md-table-cell"> <?php echo HTMLHelper::_('searchtools.sort', 'COM_ACTIONLOGS_ACTION', 'a.message', $listDirn, $listOrder); ?> </th> <th scope="col" class="w-15 d-none d-md-table-cell"> <?php echo HTMLHelper::_('searchtools.sort', 'COM_ACTIONLOGS_EXTENSION', 'a.extension', $listDirn, $listOrder); ?> </th> <th scope="col" class="w-15 d-none d-md-table-cell"> <?php echo HTMLHelper::_('searchtools.sort', 'COM_ACTIONLOGS_DATE', 'a.log_date', $listDirn, $listOrder); ?> </th> <th scope="col" class="w-10 d-md-table-cell"> <?php echo HTMLHelper::_('searchtools.sort', 'COM_ACTIONLOGS_NAME', 'a.user_id', $listDirn, $listOrder); ?> </th> <?php if ($this->showIpColumn) : ?> <th scope="col" class="w-10 d-none d-md-table-cell"> <?php echo HTMLHelper::_('searchtools.sort', 'COM_ACTIONLOGS_IP_ADDRESS', 'a.ip_address', $listDirn, $listOrder); ?> </th> <?php endif; ?> <th scope="col" class="w-1 d-none d-md-table-cell"> <?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?> </th> </tr> </thead> <tbody> <?php foreach ($this->items as $i => $item) : $extension = strtok($item->extension, '.'); ActionlogsHelper::loadTranslationFiles($extension); ?> <tr class="row<?php echo $i % 2; ?>"> <td class="text-center"> <?php echo HTMLHelper::_('grid.id', $i, $item->id); ?> </td> <th scope="row" class="d-md-table-cell"> <?php echo ActionlogsHelper::getHumanReadableLogMessage($item); ?> </th> <td class="d-none d-md-table-cell"> <?php echo $this->escape(Text::_($extension)); ?> </td> <td class="d-none d-md-table-cell"> <?php if ($this->dateRelative) : ?> <?php echo HTMLHelper::_('date.relative', $item->log_date); ?> <div class="small"> <?php endif; ?> <?php echo HTMLHelper::_('date', $item->log_date, Text::_('DATE_FORMAT_LC6')); ?> <?php if ($this->dateRelative) : ?> </div> <?php endif; ?> </td> <td class="d-md-table-cell"> <?php echo $this->escape($item->name); ?> </td> <?php if ($this->showIpColumn) : ?> <td class="d-none d-md-table-cell"> <?php echo Text::_($this->escape($item->ip_address)); ?> </td> <?php endif;?> <td class="d-none d-md-table-cell"> <?php echo (int) $item->id; ?> </td> </tr> <?php endforeach; ?> </tbody> </table> <?php // Load the pagination. ?> <?php echo $this->pagination->getListFooter(); ?> <?php endif;?> <input type="hidden" name="task" value="" /> <input type="hidden" name="boxchecked" value="0" /> <?php echo HTMLHelper::_('form.token'); ?> </div> </form> <form action="<?php echo Route::_('index.php?option=com_actionlogs&view=actionlogs'); ?>" method="post" name="exportForm" id="exportForm"> <input type="hidden" name="task" value="" /> <input type="hidden" name="cids" value="" /> <?php echo HTMLHelper::_('form.token'); ?> </form> PK ! �,U�i4 i4 src/Extension/ActionLogs.phpnu �[��� PK ! .}H� � �4 services/provider.phpnu �[��� PK ! d� � �: actionlogs.xmlnu �[��� PK ! � {�� � Z>