assign('error', I18N::get('You have no permissions for this action!')); exit(); } if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest') { Response::addHeader('Content-Type', 'text/plain; charset=UTF-8'); switch($_POST['action']) { case 'refresh': print json_encode($list); break; case 'file': $file = $_POST['file']; $content = null; if(!file_exists($file)) { $content = null; } if(!is_readable($file)) { $content = false; } if(!empty($file)) { try { $content = @file_get_contents($file); } catch(\Exception $e) { $content = false; } } if($content === false) { $content = shell_exec(sprintf('cat %s 2>&1', $file)); if(str_starts_with($content, 'cat:') && str_contains($content, 'Permission denied')) { $content = false; } } print json_encode([ 'file' => $file, 'content' => $content ]); break; } exit(); } } $template->assign('list', $list); $template->getFiles()->addJavascript('terminal', $this->url('js/terminal.js'), '1.0.0'); ?>