getFiles() public static method

public static getFiles ( boolean $basename = false ) : array
$basename boolean
return array
 public function index()
 {
     if (Input::get('l')) {
         LaravelLogViewer::setFile(Crypt::decrypt(Input::get('l')));
     }
     return view('admin.logs', ['logs' => LaravelLogViewer::all(), 'files' => LaravelLogViewer::getFiles(true), 'current_file' => LaravelLogViewer::getFileName()]);
 }
 public function index()
 {
     if (Input::get('l')) {
         LaravelLogViewer::setFile(base64_decode(Input::get('l')));
     }
     if (Input::get('dl')) {
         return Response::download(storage_path() . '/logs/' . base64_decode(Input::get('dl')));
     }
     $logs = LaravelLogViewer::all();
     return View::make('laravel-log-viewer::log', ['logs' => $logs, 'files' => LaravelLogViewer::getFiles(true), 'current_file' => LaravelLogViewer::getFileName()]);
 }
 public function index()
 {
     if (request()->input('l')) {
         LaravelLogViewer::setFile(base64_decode(request()->input('l')));
     }
     if (request()->input('dl')) {
         return Response::download(storage_path() . '/logs/' . base64_decode(request()->input('dl')));
     } elseif (request()->has('del')) {
         File::delete(storage_path() . '/logs/' . base64_decode(request()->input('del')));
         return Redirect::to(Request::url());
     }
     $logs = LaravelLogViewer::all();
     return View::make('laravel-log-viewer::log', ['logs' => $logs, 'files' => LaravelLogViewer::getFiles(true), 'current_file' => LaravelLogViewer::getFileName()]);
 }
Example #4
0
 /**
  * Show logs only if current environment is local or the current authenticated user is the superuser.
  *
  * @param  Request  $request
  *
  * @return Response
  */
 public function showLogs(Request $request)
 {
     // Check permissions
     $isSuperUser = $request->user() and $request->user()->id === 1;
     if (!app()->environment('local') and !$isSuperUser) {
         abort(404);
     }
     // Check parameters
     if ($request->input('l')) {
         LaravelLogViewer::setFile(base64_decode($request->input('l')));
     }
     if ($request->input('dl')) {
         return Response::download(storage_path() . '/logs/' . base64_decode($request->input('dl')));
     }
     return view('logs', ['title' => 'Logs', 'logs' => LaravelLogViewer::all(), 'files' => LaravelLogViewer::getFiles(true), 'current_file' => LaravelLogViewer::getFileName()]);
 }
 /**
  * @param bool $basename
  * @return array
  */
 public static function getFiles($basename = false)
 {
     $files = glob(storage_path() . '/logs/*');
     $files = array_reverse($files);
     $files = array_merge(array_filter($files, 'is_file'), self::recursiveFiles(array_filter($files, 'is_dir')));
     if ($basename && is_array($files)) {
         foreach ($files as $k => $file) {
             $files[$k] = [basename($file), $file];
         }
     }
     $allFiles = array_values($files);
     if (!empty($allFiles)) {
         return $allFiles;
     }
     return parent::getFiles($basename);
 }
 public function index()
 {
     if (Request::input('l')) {
         LaravelLogViewer::setFile(base64_decode(Request::input('l')));
     }
     if (Request::input('dl')) {
         Log::notice('perm.log.site.download - SiteLog downloaded', ['user_id' => Request::user()->user_id]);
         return Response::download(LaravelLogViewer::pathToLogFile(base64_decode(Request::input('dl'))));
     } elseif (Request::has('del')) {
         File::delete(LaravelLogViewer::pathToLogFile(base64_decode(Request::input('del'))));
         Log::notice('perm.log.site.delete - SiteLog deleted', ['user_id' => Request::user()->user_id]);
         return Redirect::to(Request::url());
     }
     $logs = LaravelLogViewer::all();
     Log::notice('perm.log.site.view - SiteLog opened', ['user_id' => Request::user()->user_id]);
     return View::make('laravel-log-viewer::log', ['logs' => $logs, 'files' => LaravelLogViewer::getFiles(true), 'current_file' => LaravelLogViewer::getFileName()]);
 }
 public function getIndex()
 {
     AssetManager::addScript('admin::default/js/datatables/jquery.dataTables.min.js');
     AssetManager::addScript('admin::default/js/datatables/jquery.dataTables_bootstrap.js');
     AssetManager::addScript('admin::default/js/notify-combined.min.js');
     AssetManager::addStyle('admin::default/css/dataTables.bootstrap.css');
     if (Input::get('l')) {
         LaravelLogViewer::setFile(base64_decode(Input::get('l')));
     }
     if (Input::get('dl')) {
         return Response::download(storage_path() . '/logs/' . base64_decode(Input::get('dl')));
     } elseif (Input::has('del')) {
         File::delete(storage_path() . '/logs/' . base64_decode(Input::get('del')));
         return Redirect::to(Request::url());
     }
     $logs = LaravelLogViewer::all();
     $view = View::make('an-admin::page.log-viewer', ['logs' => $logs, 'files' => LaravelLogViewer::getFiles(true), 'current_file' => LaravelLogViewer::getFileName()]);
     return Admin::view($view, trans('an-admin::lang.log-viewer.title'));
 }
 public function index()
 {
     if (\Input::get('l')) {
         LaravelLogViewer::setFile(base64_decode(\Input::get('l')));
     }
     if (\Input::get('dl')) {
         return \Response::download(storage_path() . '/logs/' . base64_decode(\Input::get('dl')));
     }
     if (\Input::get('del')) {
         $file = storage_path() . '/logs/' . base64_decode(\Input::get('del'));
         try {
             if (file_exists($file)) {
                 unlink($file);
             }
         } catch (\Exception $ex) {
             // DO NOTHING
         }
         $url = parse_url(\Request::getRequestUri(), PHP_URL_HOST) . parse_url(\Request::getRequestUri(), PHP_URL_PATH);
         return \Redirect::to($url);
     }
     $logs = LaravelLogViewer::all();
     return View::make('laravel-log-viewer::log', ['logs' => $logs, 'files' => LaravelLogViewer::getFiles(true), 'current_file' => LaravelLogViewer::getFileName()]);
 }
Example #9
0
 /**
  * Log viewer.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Yajra\Datatables\Datatables $datatables
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\View\View|\Symfony\Component\HttpFoundation\BinaryFileResponse
  * @throws \Exception
  */
 public function logs(Request $request, Datatables $datatables)
 {
     if ($request->input('l')) {
         LaravelLogViewer::setFile(base64_decode($request->input('l')));
     }
     if ($request->input('dl')) {
         return response()->download(LaravelLogViewer::pathToLogFile(base64_decode($request->input('dl'))));
     } elseif ($request->has('del')) {
         File::delete(LaravelLogViewer::pathToLogFile(base64_decode($request->input('del'))));
         return redirect()->to($request->url());
     }
     $logs = LaravelLogViewer::all();
     if ($request->wantsJson()) {
         return $datatables->collection(collect($logs))->editColumn('stack', '{!! nl2br($stack) !!}')->editColumn('level', function ($log) {
             $content = $this->html->tag('span', '', ['class' => "glyphicon glyphicon-{$log['level_img']}-sign"]);
             $content .= ' ' . $log['level'];
             return $this->html->tag('span', $content, ['class' => "text-{$log['level_class']}"]);
         })->addColumn('content', function ($log) {
             $html = '';
             if ($log['stack']) {
                 $html = '<a class="pull-right expand btn btn-default btn-xs"><span class="glyphicon glyphicon-search"></span></a>';
             }
             $html .= $log['text'];
             if (isset($log['in_file'])) {
                 $html .= '<br>' . $log['in_file'];
             }
             return $html;
         })->make(true);
     }
     return view('administrator.utilities.log', ['logs' => $logs, 'files' => LaravelLogViewer::getFiles(true), 'current_file' => LaravelLogViewer::getFileName()]);
 }