Skip to content

Commit

Permalink
fix download, clean, delete functions when selected subfolders (#158)
Browse files Browse the repository at this point in the history
* Refactoring, use encrypt helper method.

* Fixes #157.

* Rollback encrypt helper method for Lumen support.
  • Loading branch information
sskl authored and rap2hpoutre committed Jul 17, 2018
1 parent 41b91a1 commit 4502f4e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
9 changes: 8 additions & 1 deletion src/controllers/LogViewerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ public function index()
*/
private function earlyReturn()
{
if ($this->request->input('f')) {
$this->log_viewer->setFolder(Crypt::decrypt($this->request->input('f')));
}

if ($this->request->input('dl')) {
return $this->download($this->pathFromInput('dl'));
} elseif ($this->request->has('clean')) {
Expand All @@ -90,7 +94,10 @@ private function earlyReturn()
app('files')->delete($this->pathFromInput('del'));
return $this->redirect($this->request->url());
} elseif ($this->request->has('delall')) {
foreach ($this->log_viewer->getFiles(true) as $file) {
$files = ($this->log_viewer->getFolderName())
? $this->log_viewer->getFolderFiles(true)
: $this->log_viewer->getFiles(true);
foreach ($files as $file) {
app('files')->delete($this->log_viewer->pathToLogFile($file));
}
return $this->redirect($this->request->url());
Expand Down
8 changes: 4 additions & 4 deletions src/views/log.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,20 +147,20 @@ class="float-right expand btn btn-outline-dark btn-sm mb-2 ml-2"
@endif
<div class="p-3">
@if($current_file)
<a href="?dl={{ \Illuminate\Support\Facades\Crypt::encrypt($current_file) }}">
<a href="?dl={{ \Illuminate\Support\Facades\Crypt::encrypt($current_file) }}{{ ($current_folder) ? '&f=' . \Illuminate\Support\Facades\Crypt::encrypt($current_folder) : '' }}">
<span class="fa fa-download"></span> Download file
</a>
-
<a id="clean-log" href="?clean={{ \Illuminate\Support\Facades\Crypt::encrypt($current_file) }}">
<a id="clean-log" href="?clean={{ \Illuminate\Support\Facades\Crypt::encrypt($current_file) }}{{ ($current_folder) ? '&f=' . \Illuminate\Support\Facades\Crypt::encrypt($current_folder) : '' }}">
<span class="fa fa-sync"></span> Clean file
</a>
-
<a id="delete-log" href="?del={{ \Illuminate\Support\Facades\Crypt::encrypt($current_file) }}">
<a id="delete-log" href="?del={{ \Illuminate\Support\Facades\Crypt::encrypt($current_file) }}{{ ($current_folder) ? '&f=' . \Illuminate\Support\Facades\Crypt::encrypt($current_folder) : '' }}">
<span class="fa fa-trash"></span> Delete file
</a>
@if(count($files) > 1)
-
<a id="delete-all-log" href="?delall=true">
<a id="delete-all-log" href="?delall=true{{ ($current_folder) ? '&f=' . \Illuminate\Support\Facades\Crypt::encrypt($current_folder) : '' }}">
<span class="fa fa-trash-alt"></span> Delete all files
</a>
@endif
Expand Down

0 comments on commit 4502f4e

Please sign in to comment.