diff --git a/README.md b/README.md index 07d8b98..d34c78a 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/README.ru.md b/README.ru.md index a9cc329..90a9fb6 100644 --- a/README.ru.md +++ b/README.ru.md @@ -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) diff --git a/admin/models/ajax.php b/admin/models/ajax.php index bcefcc6..de8d2fb 100644 --- a/admin/models/ajax.php +++ b/admin/models/ajax.php @@ -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); } @@ -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); } @@ -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; } @@ -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[] = ''; $html[] = '' . $date . ''; switch ($type) { case 'PHP Error': + case 'PHP Fatal error': $html[] = '' . $type . ''; break; case 'PHP Warning': @@ -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(); } @@ -203,7 +223,11 @@ public function List() foreach ($data as $i => $item) { if (count($item) == 1) { - $item = explode(' ', $item[0]); + $html[] = ''; + $html[] = str_repeat('', count($columns) - 1); + $html[] = '' . $item[0] . ''; + $html[] = ''; + continue; } if (count($item) < count($columns)) { @@ -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[] = '' . JHtml::_('date', $dataitem, 'Y-m-d H:i:s') . ''; + try { + $date = new DateTime($dataitem); + $dataitem = $date->format('U'); + $date = JHtml::_('date', $dataitem, 'Y-m-d H:i:s'); + } catch (Exception $e) { + $date = ''; + } + $html[] = '' . $date . ''; break; case 'priority': switch (strtolower($dataitem)) { @@ -266,7 +295,6 @@ public function List() } $html[] = ''; - } else { $html[] = '
' . JText::_('COM_VLOGS_DATA_EMPTY') . '
'; } @@ -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') { @@ -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); @@ -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); diff --git a/vlogs.xml b/vlogs.xml index cc6b49c..6d715ab 100644 --- a/vlogs.xml +++ b/vlogs.xml @@ -6,9 +6,9 @@ https://alekvolsk.pw © 2019 Aleksey A. Morozov. All right reserved. GNU General Public License version 3 or later; see http://www.gnu.org/licenses/gpl-3.0.txt - 1.3.6 + 1.3.7 COM_VLOGS_DESC - July 2019 + August 2019 COM_VLOGS