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

Commit

Permalink
v1.3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekVolsk committed Aug 3, 2019
1 parent 6fc7264 commit 5455021
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 25 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# View logs

![Version](https://img.shields.io/badge/VERSION-1.3.6-0366d6.svg?style=for-the-badge)
![Version](https://img.shields.io/badge/VERSION-1.3.7-0366d6.svg?style=for-the-badge)
![Joomla](https://img.shields.io/badge/joomla-3.2+-1A3867.svg?style=for-the-badge)
![Php](https://img.shields.io/badge/php-5.6+-8892BF.svg?style=for-the-badge)

Expand Down
2 changes: 1 addition & 1 deletion README.ru.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# View logs

![Version](https://img.shields.io/badge/VERSION-1.3.6-0366d6.svg?style=for-the-badge)
![Version](https://img.shields.io/badge/VERSION-1.3.7-0366d6.svg?style=for-the-badge)
![Joomla](https://img.shields.io/badge/joomla-3.2+-1A3867.svg?style=for-the-badge)
![Php](https://img.shields.io/badge/php-5.6+-8892BF.svg?style=for-the-badge)

Expand Down
70 changes: 49 additions & 21 deletions admin/models/ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ private function getPhpLog()
$a = [];

if (($handle = fopen(ini_get('error_log'), 'r')) !== false) {
while (($data = fgets($handle)) !== false) {
$a[] = $data;
while (!feof($handle)) {
$data = fgets($handle);
if ($data !== false) {
$a[] = $data;
}
}
fclose($handle);
}
Expand All @@ -41,8 +44,11 @@ private function getCSV($file, $delimiter = ';')
$slen = JComponentHelper::getParams('com_vlogs')->get('slen', 32768);

if (($handle = fopen($file, 'r')) !== false) {
while (($data = fgetcsv($handle, $slen, $delimiter)) !== false) {
$a[] = $data;
while (!feof($handle)) {
$data = fgetcsv($handle, $slen, $delimiter);
if ($data !== false) {
$a[] = $data;
}
}
fclose($handle);
}
Expand Down Expand Up @@ -78,7 +84,7 @@ private function file_force_download($file)
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
return (bool)readfile($file);
return (bool) readfile($file);
} else {
return false;
}
Expand All @@ -102,15 +108,29 @@ protected function ListPHPEL()
continue;
}
$tmp = explode('] ', $item);
$date = substr($tmp[0], 1, strlen($tmp[0]) - 1);
$date = explode(' ', $date);
$date = new DateTime($date[0] . 'T' . $date[1], new DateTimeZone($date[2]));
$date = date_format($date, 'Y-m-d H:i:s');
[$type, $msg] = explode(': ', $tmp[1]);
try {
if ($tmp[0][0] == '[') {
$date = substr($tmp[0], 1, strlen($tmp[0]) - 1);
$date = explode(' ', $date);
$date = new DateTime($date[0] . 'T' . $date[1], new DateTimeZone($date[2]));
$date = date_format($date, 'Y-m-d H:i:s');
} else {
$date = '';
}
} catch (Exception $e) {
$date = '';
}
if ($date && count($tmp) > 0) {
[$type, $msg] = explode(': ', $tmp[1]);
} else {
$type = '';
$msg = $item;
}
$html[] = '<tr>';
$html[] = '<td>' . $date . '</td>';
switch ($type) {
case 'PHP Error':
case 'PHP Fatal error':
$html[] = '<td class="text-error">' . $type . '</td>';
break;
case 'PHP Warning':
Expand All @@ -137,7 +157,7 @@ protected function ListPHPEL()
public function List()
{
$log_path = str_replace('\\', '/', JFactory::getConfig()->get('log_path'));
$file = (string)filter_input(INPUT_GET, 'filename');
$file = (string) filter_input(INPUT_GET, 'filename');
if ($file === 'PHP error log') {
$this->ListPHPEL();
}
Expand Down Expand Up @@ -203,7 +223,11 @@ public function List()

foreach ($data as $i => $item) {
if (count($item) == 1) {
$item = explode(' ', $item[0]);
$html[] = '<tr class="row' . ($i % 2) . '">';
$html[] = str_repeat('<td></td>', count($columns) - 1);
$html[] = '<td>' . $item[0] . '</td>';
$html[] = '</tr>';
continue;
}

if (count($item) < count($columns)) {
Expand All @@ -219,9 +243,14 @@ public function List()
foreach ($item as $j => $dataitem) {
switch (strtolower($columns[$j])) {
case 'datetime':
$date = new DateTime($dataitem);
$dataitem = $date->format('U');
$html[] = '<td class="nowrap">' . JHtml::_('date', $dataitem, 'Y-m-d H:i:s') . '</td>';
try {
$date = new DateTime($dataitem);
$dataitem = $date->format('U');
$date = JHtml::_('date', $dataitem, 'Y-m-d H:i:s');
} catch (Exception $e) {
$date = '';
}
$html[] = '<td class="nowrap">' . $date . '</td>';
break;
case 'priority':
switch (strtolower($dataitem)) {
Expand Down Expand Up @@ -266,7 +295,6 @@ public function List()
}

$html[] = '</tbody></table>';

} else {
$html[] = '<div class="alert">' . JText::_('COM_VLOGS_DATA_EMPTY') . '</div>';
}
Expand All @@ -278,7 +306,7 @@ public function dwFile()
{
$log_path = str_replace('\\', '/', JFactory::getConfig()->get('log_path'));
$file = filter_input(INPUT_GET, 'filename');
$bom = (bool)filter_input(INPUT_GET, 'bom');
$bom = (bool) filter_input(INPUT_GET, 'bom');
$fpath = str_replace('\\', '/', JFactory::getConfig()->get('tmp_path'));

if ($file === 'PHP error log') {
Expand Down Expand Up @@ -358,7 +386,7 @@ public function DelFile()
public function ArchiveFile()
{
$apath = JComponentHelper::getParams('com_vlogs')->get('apath', 'tmp');
$delAfterArch = (int)JComponentHelper::getParams('com_vlogs')->get('delafterarch', 0);
$delAfterArch = (int) JComponentHelper::getParams('com_vlogs')->get('delafterarch', 0);

if (!$apath) {
$this->printJson(JText::_('COM_VLOGS_ARCHIVEFILE_NO_FOLDER'), false);
Expand Down Expand Up @@ -396,9 +424,9 @@ public function ArchiveFile()
}

$this->printJson(
JText::sprintf('COM_VLOGS_ARCHIVEFILE_ALERT_' . (int)($delAfterArch && $resultDel), $file, str_replace(str_replace('\\', '/', JPATH_ROOT), '', $archPath)),
true,
['del' => (int)($delAfterArch && $resultDel)]
JText::sprintf('COM_VLOGS_ARCHIVEFILE_ALERT_' . (int) ($delAfterArch && $resultDel), $file, str_replace(str_replace('\\', '/', JPATH_ROOT), '', $archPath)),
true,
['del' => (int) ($delAfterArch && $resultDel)]
);
} else {
$this->printJson(JText::_('COM_VLOGS_NO_ARCHIVE_PHP_LOG') . ' ' . $file, false);
Expand Down
4 changes: 2 additions & 2 deletions vlogs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<authorUrl>https://alekvolsk.pw</authorUrl>
<copyright>© 2019 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.3.6</version>
<version>1.3.7</version>
<description>COM_VLOGS_DESC</description>
<creationDate>July 2019</creationDate>
<creationDate>August 2019</creationDate>
<administration>
<menu>COM_VLOGS</menu>
<files folder="admin">
Expand Down

0 comments on commit 5455021

Please sign in to comment.