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

Commit

Permalink
v1.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekVolsk committed Feb 13, 2019
1 parent ed79209 commit d63d9ad
Show file tree
Hide file tree
Showing 6 changed files with 607 additions and 45 deletions.
1 change: 1 addition & 0 deletions admin/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<config>
<fieldset name="global" label="JGLOBAL_FIELDSET_OPTIONS">
<field name="slen" type="text" label="COM_VLOGS_PRM_STRLEN" class="inputbox" default="32768"/>
<field name="apath" type="fileselect" folder="/" folderonly="true" label="COM_VLOGS_PRM_ARCHPATH" class="inputbox" default="tmp" addfieldpath="/administrator/components/com_vlogs/models/fields"/>
</fieldset>
<fieldset name="permissions" label="JCONFIG_PERMISSIONS_LABEL" description="JCONFIG_PERMISSIONS_DESC">
<field name="rules" type="rules" label="JCONFIG_PERMISSIONS_LABEL" validate="rules" filter="rules" component="com_vlogs" section="component"/>
Expand Down
21 changes: 17 additions & 4 deletions admin/models/ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,8 @@ public function DelFile()

if ($file !== 'PHP error log')
{
$this->printJson(JText::_('COM_VLOGS_DELETEFILE_ALERT'), unlink($log_path . '/' . $file));
$result = unlink($log_path . '/' . $file);
$this->printJson($result ? JText::sprintf('COM_VLOGS_DELETEFILE_SUCCESS', $file) : JText::_('COM_VLOGS_DELETEFILE_ALERT'), $result);
}
else
{
Expand All @@ -397,6 +398,18 @@ public function DelFile()

public function ArchiveFile()
{
$apath = JComponentHelper::getParams('com_vlogs')->get('apath', 'tmp');

if (!$apath) {
$this->printJson(JText::_('COM_VLOGS_ARCHIVEFILE_NO_FOLDER'), false);
}

$apath = str_replace('\\', '/', JPATH_ROOT . '/' . $apath);

if (!is_dir($apath)) {
$this->printJson(JText::_('COM_VLOGS_ARCHIVEFILE_NO_EXISTS_FOLDER'), false);
}

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

Expand All @@ -408,8 +421,8 @@ public function ArchiveFile()

$zip = new ZipArchive();

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

if ($zip->open($archPath, ZIPARCHIVE::CREATE) !== true) {
$this->printJson(JText::_('COM_VLOGS_ARCHIVEFILE_ERROR_CREATE'), false);
Expand All @@ -418,7 +431,7 @@ public function ArchiveFile()
$zip->close();
}

$this->printJson(JText::sprintf('COM_VLOGS_ARCHIVEFILE_ALERT', $file, $archFile), true);
$this->printJson(JText::sprintf('COM_VLOGS_ARCHIVEFILE_ALERT', $file, $archPath), true);
}
else
{
Expand Down
Loading

0 comments on commit d63d9ad

Please sign in to comment.