if (is_file(CONS_PATH_LOGS . $_SESSION['CODE'] . "/out" . $previousDay . ".log")) { $temp .= nl2br(cReadFile(CONS_PATH_LOGS . $_SESSION['CODE'] . "/out" . $previousDay . ".log")); } // 1 day ago $previousDay = datecalc(date("Y-m-d"), 0, 0, -1); $previousDay = str_replace("-", "", $previousDay); if (is_file(CONS_PATH_LOGS . $_SESSION['CODE'] . "/err" . $previousDay . ".log")) { appendErrors($core, $temp, $template, explode("\n", cReadFile(CONS_PATH_LOGS . $_SESSION['CODE'] . "/err" . $previousDay . ".log"))); } if (is_file(CONS_PATH_LOGS . $_SESSION['CODE'] . "/out" . $previousDay . ".log")) { $temp .= nl2br(cReadFile(CONS_PATH_LOGS . $_SESSION['CODE'] . "/out" . $previousDay . ".log")); } # Today $previousDay = date("Ymd"); if (is_file(CONS_PATH_LOGS . $_SESSION['CODE'] . "/err" . $previousDay . ".log")) { appendErrors($core, $temp, $template, explode("\n", cReadFile(CONS_PATH_LOGS . $_SESSION['CODE'] . "/err" . $previousDay . ".log"))); } if (is_file(CONS_PATH_LOGS . $_SESSION['CODE'] . "/out" . $previousDay . ".log")) { $temp .= nl2br(cReadFile(CONS_PATH_LOGS . $_SESSION['CODE'] . "/out" . $previousDay . ".log")); } if (CONS_HTTPD_ERRFILE != '') { $httpderrlog = str_replace("{Y}", date("Y"), CONS_HTTPD_ERRFILE); $httpderrlog = str_replace("{m}", date("m"), $httpderrlog); $httpderrlog = str_replace("{d}", date("d"), $httpderrlog); if (is_file(CONS_HTTPD_ERRDIR . $httpderrlog)) { $temp .= "<div style='font-color:red;margin-top:5px'>HTTPD errors detected on {$httpderrlog} log file:</div><br/><pre>"; $temp .= cReadFile(CONS_HTTPD_ERRDIR . $httpderrlog); $temp .= "</pre>"; } } $core->template->assign("_error", $temp);
function log($die = true) { function appendErrors(&$core, &$output, &$template, $data) { foreach ($data as $line) { $line = explode("|", $line); # date|id_client|uri|errCode|module|parameters|extended parameters|log[|...] $thisData = array(); $thisData['date'] = array_shift($line); $thisData['id_client'] = array_shift($line); $thisData['uri'] = array_shift($line); $thisData['errCode'] = array_shift($line); $thisData['module'] = array_shift($line); $thisData['parameters'] = array_shift($line); $thisData['extended'] = array_shift($line); $thisData['log'] = implode("|", $line); if (is_numeric($thisData['errCode']) && isset($core->errorControl->ERRORS[$thisData['errCode']])) { $errorLevel = $core->errorControl->ERRORS[$thisData['errCode']]; $thisData['level'] = $errorLevel < 10 ? 0 : ($errorLevel < 20 ? 1 : 2); $output .= $template->techo($thisData); } } } $outputTemplate = "<div style='line-height:25px;border-bottom:1px solid #999999;margin-bottom:3px;'>{date} {id_client}: <span style='color:red'>{errCode} ({_t}e{errCode}{/t})</span> [{module}] {parameters} (<strong>{extended}</strong>) @ {uri}</div>"; $template = new CKTemplate($this->parent->template); $template->tbreak($outputTemplate); $this->parent->close(false); $temp = ""; // 1 day ago $previousDay = datecalc(date("Y-m-d"), 0, 0, -1); $previousDay = str_replace("-", "", $previousDay); if (is_file(CONS_PATH_LOGS . $_SESSION['CODE'] . "/err" . $previousDay . ".log")) { appendErrors($this->parent, $temp, $template, explode("\n", cReadFile(CONS_PATH_LOGS . $_SESSION['CODE'] . "/err" . $previousDay . ".log"))); } # Today $previousDay = date("Ymd"); if (is_file(CONS_PATH_LOGS . $_SESSION['CODE'] . "/err" . $previousDay . ".log")) { appendErrors($this->parent, $temp, $template, explode("\n", cReadFile(CONS_PATH_LOGS . $_SESSION['CODE'] . "/err" . $previousDay . ".log"))); } if (is_file(CONS_PATH_LOGS . $_SESSION['CODE'] . "/out" . $previousDay . ".log")) { $temp .= nl2br(cReadFile(CONS_PATH_LOGS . $_SESSION['CODE'] . "/out" . $previousDay . ".log")); } echo "Log files are located at " . CONS_PATH_LOGS . $_SESSION['CODE'] . "/<br/><br/>"; echo $temp; echo "<br/><hr>"; # httpd log? if (CONS_HTTPD_ERRFILE != '') { $httpderrlog = str_replace("{Y}", date("Y"), CONS_HTTPD_ERRFILE); $httpderrlog = str_replace("{m}", date("m"), $httpderrlog); $httpderrlog = str_replace("{d}", date("d"), $httpderrlog); if (is_file(CONS_HTTPD_ERRDIR . $httpderrlog)) { echo "<div style='font-color:red;margin-top:5px'>HTTPD errors detected on {$httpderrlog} log file:</div><br/><pre>"; echo cReadFile(CONS_HTTPD_ERRDIR . $httpderrlog); echo "</pre>"; } } if ($die) { $this->parent->close(true); die; } }
} $code = $_REQUEST['code']; $logs = ""; $template = $core->template->get("_error"); if (is_file(CONS_PATH_LOGS . $code . "/err" . date('Ymd') . ".log")) { function appendErrors(&$core, &$output, &$template, $data) { foreach ($data as $line) { $line = explode("|", $line); # date|id_client|uri|errCode|module|parameters|extended parameters|log[|...] $coreData = array(); $coreData['date'] = array_shift($line); $coreData['id_client'] = array_shift($line); $coreData['uri'] = array_shift($line); $coreData['errCode'] = array_shift($line); $coreData['module'] = array_shift($line); $coreData['parameters'] = array_shift($line); $coreData['extended'] = array_shift($line); $coreData['log'] = implode("|", $line); if (is_numeric($coreData['errCode']) && isset($core->errorControl->ERRORS[$coreData['errCode']])) { $errorLevel = $core->errorControl->ERRORS[$coreData['errCode']]; $coreData['level'] = $errorLevel < 10 ? 0 : ($errorLevel < 20 ? 1 : 2); $output .= $template->techo($coreData); } } } appendErrors($core, $logs, $template, explode("\n", cReadFile(CONS_PATH_LOGS . $code . "/err" . date('Ymd') . ".log"))); } else { $logs = "No log"; } $core->template->assign("_error", $logs);