Skip to content
This repository has been archived by the owner on Apr 24, 2023. It is now read-only.

Commit

Permalink
v1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekVolsk committed Feb 10, 2019
1 parent a6ec58f commit ed79209
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 23 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

- (upd 1.2.0) reading PHP error log file (provided that it is installed in php.ini and available for reading from the site)

- (upd 1.3.0) archiving a log file to an archive with a log file name + current datetime (assuming the php-zip extension is connected), the log file is not cleared or deleted, the archive is saved next to the log

**Requirements**:

- Joomla 3.2 or later (com_ajax involved)
Expand Down
18 changes: 10 additions & 8 deletions README.ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,25 @@

**Возможности**:

чтение файлов логов и вывод их содержимого в табличном виде в админке
- чтение файлов логов и вывод их содержимого в табличном виде в админке

авторазворачивание json-строки сообщения при просмотре лога в админке,<br>(upd 1.1.0) корректный вывод json с глубокой вложенностью объектов,<br>(upd 1.1.1) сворачивание (аккордеон) блока json-сообщения для экономии экранного пространства
- авторазворачивание json-строки сообщения при просмотре лога в админке,<br>(upd 1.1.0) корректный вывод json с глубокой вложенностью объектов,<br>(upd 1.1.1) сворачивание (аккордеон) блока json-сообщения для экономии экранного пространства

возможность скачать файл лога в формате CVS (два варианта: классический и специально для открытия в excel без плясок с бубном)
- возможность скачать файл лога в формате CVS (два варианта: классический и специально для открытия в excel без плясок с бубном)

возможность удалить файл лога
- возможность удалить файл лога

(upd 1.1.0) корректное чтение файлов логов с нестандартными колонками
- (upd 1.1.0) корректное чтение файлов логов с нестандартными колонками

– (upd 1.2.0) чтение файла лога ошибок PHP (при условии, что он установлен в php.ini и доступен для чтения с сайта)
- (upd 1.2.0) чтение файла лога ошибок PHP (при условии, что он установлен в php.ini и доступен для чтения с сайта)

- (upd 1.3.0) архивирование файла лога в архив с именем файла лога + текущая дата и время (при условии подключенного расширения php-zip), файл лога при этом не очищается и не удаляется, архив сохраняется рядом с логом

**Требования**:

Joomla 3.2 и выше (задействован com_ajax)
- Joomla 3.2 и выше (задействован com_ajax)

PHP 5.6 и выше
- PHP 5.6 и выше

**Минус**: файл лога читается и выводится целиком, если он большой, то это займет время, создаст нагрузку на ресурсы и трафик, поэтому

Expand Down
7 changes: 6 additions & 1 deletion admin/language/en-GB/en-GB.com_vlogs.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,9 @@ COM_VLOGS_DOWNLOAD_BUTTON="Download as CSV"
COM_VLOGS_DOWNLOAD_BOM_BUTTON="Download as CSV (for MS Excel)"
COM_VLOGS_DELETEFILE_BUTTON="Delete log file"
COM_VLOGS_DELETEFILE_ALERT="Error deleting file. Delete the file prochnow."
COM_VLOGS_NO_DELETE_PHP_LOG="You cannot delete a PHP log file from the site administration panel. Please use the control panel or your server console to do this."
COM_VLOGS_NO_DELETE_PHP_LOG="You can't delete a PHP log file from the site administration panel. Please use the control panel or the console of your server."
COM_VLOGS_ARCHIVEFILE_BUTTON="Archive active log"
COM_VLOGS_ARCHIVEFILE_ALERT="Log file <strong>%s</strong> successfully packaged in <strong>%s</strong>.<br>Please note: the source file is not deleted or cleared, the archive is saved near the source file."
COM_VLOGS_NO_ARCHIVE_PHP_LOG="You can't archive a PHP file log from the site administration panel. Please use the control panel or the console of your server."
COM_VLOGS_NO_PHPZIP="The php-zip library is not installed, archiving is not possible."
COM_VLOGS_ARCHIVEFILE_ERROR_CREATE="Error creating archive file %s."
5 changes: 5 additions & 0 deletions admin/language/ru-RU/ru-RU.com_vlogs.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@ COM_VLOGS_DOWNLOAD_BOM_BUTTON="Скачать как CSV (для MS Excel)"
COM_VLOGS_DELETEFILE_BUTTON="Удалить файл лога"
COM_VLOGS_DELETEFILE_ALERT="Ошибка удаления файла. Удалите файл фручную."
COM_VLOGS_NO_DELETE_PHP_LOG="Нельзя удалить файл лога PHP из административной панели сайта. Пожалуйста, воспользуйтесь для этого панелью управлением или консолью вашего сервера."
COM_VLOGS_ARCHIVEFILE_BUTTON="Архирировать текущий лог"
COM_VLOGS_ARCHIVEFILE_ALERT="Файл лога <strong>%s</strong> успешно упакован в <strong>%s</strong>.<br>Обратите внимание: исходный файл не удаляется и не очищается, архив сохраняется рядом с исходным файлом."
COM_VLOGS_NO_ARCHIVE_PHP_LOG="Нельзя архивировать файллога PHP из административной панели сайта. Пожалуйста, воспользуйтесь для этого панелью управлением или консолью вашего сервера."
COM_VLOGS_NO_PHPZIP="Библиотекак php-zip не установлена, архивирование невозможно."
COM_VLOGS_ARCHIVEFILE_ERROR_CREATE="Ошибка создания файла архива %s."
38 changes: 31 additions & 7 deletions admin/models/ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@
* @copyright Copyright (C) 2018 Aleksey A. Morozov (AlekVolsk). All rights reserved.
* @license GNU General Public License version 3 or later; see http://www.gnu.org/licenses/gpl-3.0.txt
*/
function savefile($fname, $val)
{
$file = fopen( $fname, 'w' );
fwrite( $file, print_r( $val, true ) );
flush();
fclose( $file );
}

class VlogsModelAjax extends JModelList
{
Expand Down Expand Up @@ -401,4 +394,35 @@ public function DelFile()
$this->printJson(JText::_('COM_VLOGS_NO_DELETE_PHP_LOG') . ' ' . $file, false);
}
}

public function ArchiveFile()
{
$log_path = str_replace('\\', '/', JFactory::getConfig()->get('log_path'));
$file = filter_input(INPUT_GET, 'filename');

if ($file !== 'PHP error log')
{
if (!extension_loaded('zip')) {
$this->printJson(JText::_('COM_VLOGS_NO_PHPZIP'), false);
}

$zip = new ZipArchive();

$archFile = pathinfo($log_path . '/' . $file, PATHINFO_FILENAME) . '__' . date('Y-m-d_h-i-s') . '.zip';
$archPath = $log_path . '/' . $archFile;

if ($zip->open($archPath, ZIPARCHIVE::CREATE) !== true) {
$this->printJson(JText::_('COM_VLOGS_ARCHIVEFILE_ERROR_CREATE'), false);
} else {
$zip->addFile($log_path . '/' . $file, $file);
$zip->close();
}

$this->printJson(JText::sprintf('COM_VLOGS_ARCHIVEFILE_ALERT', $file, $archFile), true);
}
else
{
$this->printJson(JText::_('COM_VLOGS_NO_ARCHIVE_PHP_LOG') . ' ' . $file, false);
}
}
}
32 changes: 28 additions & 4 deletions admin/views/items/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@
.com_vlogs pre {box-sizing:border-box;max-width:100%;width:100%;}
</style>
<script>
jQuery(document).ready(function($)
document.addEventListener('DOMContentLoaded', function()
{
getLog = function(vfile)
{
Joomla.removeMessages();

document.querySelector('#view_items_list').innerHTML = '';
document.querySelector('#view_count_items').innerHTML = '0';

$.getJSON('index.php', {option:'com_vlogs', task:'getAjax', action:'List', filename:vfile}, function(response)
jQuery.getJSON('index.php', {option:'com_vlogs', task:'getAjax', action:'List', filename:vfile}, function(response)
{
document.querySelector('#view_items_list').innerHTML = response.message;
document.querySelector('#view_count_items').innerHTML = response.count;
Expand All @@ -43,17 +45,20 @@

document.querySelector('#view_download_file').addEventListener('click', function(e)
{
Joomla.removeMessages();
document.location.href = 'index.php?option=com_vlogs&task=getAjax&action=dwFile&bom=0&filename=' + document.querySelector('#view_select_files').value;
});

document.querySelector('#view_download_bom_file').addEventListener('click', function(e)
{
Joomla.removeMessages();
document.location.href = 'index.php?option=com_vlogs&task=getAjax&action=dwFile&bom=1&filename=' + document.querySelector('#view_select_files').value;
});

document.querySelector('#view_delete_file').addEventListener('click', function(e)
{
$.getJSON('index.php', {option:'com_vlogs', task:'getAjax', action:'DelFile', filename:document.querySelector('#view_select_files').value}, function(response)
Joomla.removeMessages();
jQuery.getJSON('index.php', {option:'com_vlogs', task:'getAjax', action:'DelFile', filename:document.querySelector('#view_select_files').value}, function(response)
{
if (response.result)
{
Expand All @@ -63,7 +68,8 @@
}
else
{
alert(response.message);
Joomla.JText.load({error:"<?php echo JText::_('ERROR'); ?>"});
Joomla.renderMessages({'error':[response.message]});
}
});
});
Expand All @@ -72,6 +78,24 @@
{
getLog(e.target.value);
});

document.querySelector('#view_archive_file').addEventListener('click', function(e)
{
Joomla.removeMessages();
jQuery.getJSON('index.php', {option:'com_vlogs', task:'getAjax', action:'ArchiveFile', filename:document.querySelector('#view_select_files').value}, function(response)
{
if (response.result)
{
Joomla.JText.load({info:"<?php echo JText::_('INFO'); ?>"});
Joomla.renderMessages({'info':[response.message]});
}
else
{
Joomla.JText.load({error:"<?php echo JText::_('ERROR'); ?>"});
Joomla.renderMessages({'error':[response.message]});
}
});
});

getLog(document.querySelector('#view_select_files').value);
});
Expand Down
5 changes: 5 additions & 0 deletions admin/views/items/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public function display($tpl = null)
$custom_button_html = '<button id="view_delete_file" type="button" class="btn btn-small"><span class="icon-delete"></span>' . JText::_('COM_VLOGS_DELETEFILE_BUTTON') . '</button>';
JToolBar::getInstance('toolbar')->appendButton('Custom', $custom_button_html, 'custom');

if (extension_loaded('zip')) {
$custom_button_html = '<button id="view_archive_file" type="button" class="btn btn-small"><span class="icon-cube"></span>' . JText::_('COM_VLOGS_ARCHIVEFILE_BUTTON') . '</button>';
JToolBar::getInstance('toolbar')->appendButton('Custom', $custom_button_html, 'custom');
}

$custom_button_html = '<span style="display:inline-block;padding:0 15px;font-size:12px;line-height:25.5px;border:1px solid #d6e9c6;border-radius:3px;background-color:#dff0d8;color:#3c763d;">' . JText::_('COM_VLOGS_COUNT_ITEMS_VIEW') . ' <span id="view_count_items">0</span></span>';
JToolBar::getInstance('toolbar')->appendButton('Custom', $custom_button_html, 'options');

Expand Down
6 changes: 3 additions & 3 deletions vlogs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<author>Aleksey A. Morozov</author>
<authorEmail>[email protected]</authorEmail>
<authorUrl>https://alekvolsk.pw</authorUrl>
<copyright2018 Aleksey A. Morozov. All right reserved.</copyright>
<copyright2019 Aleksey A. Morozov. All right reserved.</copyright>
<license>GNU General Public License version 3 or later; see http://www.gnu.org/licenses/gpl-3.0.txt</license>
<version>1.2.1</version>
<version>1.3.0</version>
<description>COM_VLOGS_DESC</description>
<creationDate>March 2018</creationDate>
<creationDate>February 2019</creationDate>
<administration>
<menu>COM_VLOGS</menu>
<files folder="admin">
Expand Down

0 comments on commit ed79209

Please sign in to comment.