protected function actionDebug($params) { if (empty(GO::session()->values['debug'])) { // if(!GO::user()->isAdmin()) // throw new \GO\Base\Exception\AccessDenied("Debugging can only be enabled by an admin. Tip: You can enable it as admin and switch to any user with the 'Switch user' module."); GO::session()->values['debug'] = true; } GO::session()->values['debugSql'] = !empty($params['debugSql']); // The default length of the tail command, when passing the "length" parameter this can be increased or decreased $length = 300; if (isset($params['length'])) { $length = $params['length']; } $debugFile = new \GO\Base\Fs\File(GO::config()->file_storage_path . 'log/debug.log'); if (!$debugFile->exists()) { $debugFile->touch(true); } $errorFile = new \GO\Base\Fs\File(GO::config()->file_storage_path . 'log/error.log'); if (!$errorFile->exists()) { $errorFile->touch(true); } $debugLog = nl2br(str_replace('[' . GO::user()->username . '] ', '', htmlspecialchars($debugFile->tail($length)))); $debugLog = str_replace('--------------------', '<hr />', $debugLog); return array('success' => true, 'debugLog' => $debugLog, 'errorLog' => str_replace('----------------', '<hr />', nl2br(htmlspecialchars($errorFile->tail($length))))); }