/** * Locate, parse and display the latest error logged in the main error_log file. * * @return array A list of pseudo-variables and values that will replace them in the HTML template. */ function sucuriscan_infosys_errorlogs() { $template_variables = array('ErrorLog.Path' => '', 'ErrorLog.Exists' => 'No', 'ErrorLog.NoItemsVisibility' => 'hidden', 'ErrorLog.DisabledVisibility' => 'hidden', 'ErrorLog.InvalidFormatVisibility' => 'hidden', 'ErrorLog.LogsLimit' => '0', 'ErrorLog.FileSize' => '0B', 'ErrorLog.List' => ''); $error_log_path = false; $log_filename = SucuriScan::ini_get('error_log'); $errorlogs_limit = SucuriScanOption::get_option(':errorlogs_limit'); $template_variables['ErrorLog.LogsLimit'] = $errorlogs_limit; $errorlogs_counter = 0; if ($log_filename) { $error_log_path = @realpath(ABSPATH . '/' . $log_filename); } if (SucuriScanOption::is_disabled(':parse_errorlogs')) { $template_variables['ErrorLog.DisabledVisibility'] = 'visible'; } if ($error_log_path) { $template_variables['ErrorLog.Path'] = $error_log_path; $template_variables['ErrorLog.Exists'] = 'Yes'; $template_variables['ErrorLog.FileSize'] = SucuriScan::human_filesize(filesize($error_log_path)); $last_lines = SucuriScanFileInfo::tail_file($error_log_path, $errorlogs_limit); $error_logs = SucuriScanFSScanner::parse_error_logs($last_lines); $error_logs = array_reverse($error_logs); $errorlogs_counter = 0; foreach ($error_logs as $error_log) { $css_class = $errorlogs_counter % 2 == 0 ? '' : 'alternate'; $template_variables['ErrorLog.List'] .= SucuriScanTemplate::get_snippet('infosys-errorlogs', array('ErrorLog.CssClass' => $css_class, 'ErrorLog.DateTime' => SucuriScan::datetime($error_log->timestamp), 'ErrorLog.ErrorType' => SucuriScan::escape($error_log->error_type), 'ErrorLog.ErrorCode' => SucuriScan::escape($error_log->error_code), 'ErrorLog.ErrorAbbr' => strtoupper(substr($error_log->error_code, 0, 1)), 'ErrorLog.ErrorMessage' => SucuriScan::escape($error_log->error_message), 'ErrorLog.FilePath' => SucuriScan::escape($error_log->file_path), 'ErrorLog.LineNumber' => SucuriScan::escape($error_log->line_number))); $errorlogs_counter += 1; } if ($errorlogs_counter <= 0) { $template_variables['ErrorLog.InvalidFormatVisibility'] = 'visible'; } } else { $template_variables['ErrorLog.NoItemsVisibility'] = 'visible'; } return SucuriScanTemplate::get_section('infosys-errorlogs', $template_variables); }
public static function cachePage($nonce) { $params = array(); $fpath = SucuriScan::datastore_folder_path('sucuri-sitecheck.php'); if ($nonce) { // Reset SiteCheck results cache. if (SucuriScanRequest::post(':sitecheck_cache')) { if (file_exists($fpath)) { if (@unlink($fpath)) { $message = 'Malware scanner cache was successfully reset.'; SucuriScanEvent::report_debug_event($message); SucuriScanInterface::info($message); } else { SucuriScanInterface::error('Count not reset the cache, delete manually.'); } } else { SucuriScanInterface::error('The cache file does not exists.'); } } } $params['SiteCheck.CacheSize'] = SucuriScan::human_filesize(@filesize($fpath)); $params['SiteCheck.CacheLifeTime'] = SUCURISCAN_SITECHECK_LIFETIME; return SucuriScanTemplate::getSection('settings-sitecheck-cache', $params); }