File manager - Edit - /usr/local/cpanel/base/frontend/jupiter/cpguard/scanner/scanner_data.php
Back
<?php include_once dirname(__DIR__) . "/includes/init.php"; include_once $base_dir . "/classes/language.class.php"; $lang = new Language('scanner_logs'); include_once dirname(__DIR__) . "/classes/api.class.php"; $api = new Api($current_user); $request = []; /* * **************************************************************************** * ACTIONS ON SINGLE/MULTIPLE SELECTED ROWS * **************************************************************************** */ $start = filter_var($_POST['start']); $length = filter_var($_POST['length']); $column_index = filter_var($_POST['order'][0]['column']); // Column index $column_name = filter_var($_POST['columns'][$column_index]['data']); // Column name $column_sort_order = filter_var($_POST['order'][0]['dir']); // asc or desc $request = [ 'page' => ($start / $length) + 1, 'length' => $length, 'sort' => [$column_name => $column_sort_order] ]; if (!empty($_POST['table_action']) && !empty($_POST['table_action_ids'])) { $table_action = filter_var($_POST['table_action']); $table_action_ids = filter_var($_POST['table_action_ids']); $request['action'] = filter_var($_POST['table_action']); if (!in_array(trim($request['action']), ['delete', 'quarantine', 'disable', 'report'])) { return $this->response->error('Invalid action', 417); } if ($_POST['table_action'] == 'report') { $request['ids'] = [filter_var($_POST['table_action_ids'])]; } else { $request['ids'] = explode(',', filter_var($_POST['table_action_ids'])); } } ## Search if (!empty($_POST['filter_filepath'])) { $request['filter']['path'] = filter_var($_POST['filter_filepath']); } if (!empty($_POST['filter_category'])) { $request['filter']['reason'] = filter_var($_POST['filter_category']); } if (!empty($_POST['filter_description'])) { $request['filter']['definition'] = filter_var($_POST['filter_description']); } if (!empty($_POST['filter_time_from'])) { $request['filter']['time_from'] = filter_var($_POST['filter_time_from']); } if (!empty($_POST['filter_time_to'])) { $request['filter']['time_to'] = filter_var($_POST['filter_time_to']); } if (!empty($_POST['search']['value'])) { $request['filter']['query'] = filter_var($_POST['search']['value']); } if (!empty($_POST['mscan_id'])) { $request['scan_id'] = filter_var($_POST['mscan_id']); } if (!empty($_POST['export'])) { if (!empty($_POST['table_action_ids'])) { $request['filter']['export_ids'] = $_POST['table_action_ids']; } $result = $api->request('scannerExport', $request); if (!empty($result)) { ob_start(); header("Cache-Control: no-store"); header("X-Accel-Buffering: no"); header('Content-Type: text/csv'); header('Content-Disposition: attachment; filename="waf_logs.csv"'); $fp = fopen('php://output', 'wb'); fputcsv($fp, ['ID', 'Path', 'User', 'Reason', 'Definition', 'File Status', 'Time']); ob_flush(); flush(); foreach ($result as $row) { fputcsv($fp, $row, ','); ob_flush(); flush(); } fclose($fp); } } else { $result = $api->request('scannerData', $request); function render_status($file_status) { /* * Status codes: * 0 - No action * 1 - Quarantined * 2 - Disabled * 3 - Cleaned * 4 - Deleted */ switch ($file_status) { case 0: $status = '<span class="label label-danger">NO ACTION</span>'; break; case 1: $status = '<span class="label label-success">QUARANTINED</span>'; break; case 2: $status = '<span class="label label-default">DISABLED</span>'; break; case 3: $status = ' <span class="label label-info">CLEANED</span>'; break; case 4: $status = '<span class="label label-warning">DELETED</span>'; break; default: $status = '<span class="label label-danger">NO ACTION</span>'; break; } return $status; } function renderActions($row, Language $lang) { global $directory_quarantine; $filepath = $row['file_status'] == 1 ? $directory_quarantine . $row['identifier'] . '-' . basename($row['path']) : ($row['file_status'] == 0 ? $row['path'] : null); $virus_detail = "<a title=\"View virus details\" data-toggle=\"tooltip\" data-placement=\"left\" class=\"view-detail pull-left\" data-id=\"" . $row['id'] . "\" ><i class=\"la la-file-alt\"></i></a>" . PHP_EOL; $actions = ''; $actions .= ($filepath !== null || $row['file_status'] != 4 ? '<li><a class="table-action" data-id="' . $row['id'] . '" data-action="delete" data-loading="' . $lang->_('multiselect.button.delete_loading', true) . '">' . $lang->_('multiselect.button.delete_text', true) . '</a></li>' : ''); $actions .= ($row['file_status'] == 0 || $row['file_status'] == 3 ? '<li><a class="table-action" data-id="' . $row['id'] . '" data-action="quarantine" data-loading="' . $lang->_('multiselect.button.quarantine_loading', true) . '" >' . $lang->_('multiselect.button.quarantine_text', true) . '</a></li>' : ''); $actions .= ($row['file_status'] == 0 ? '<li><a class="table-action" data-id="' . $row['id'] . '" data-action="disable" data-loading="' . $lang->_('multiselect.button.disable_loading', true) . '" >' . $lang->_('multiselect.button.disable_text', true) . '</a></li>' : ''); if (empty(trim($actions))) { $actions = '<div class="more-row-options" style="padding: 0 7px;padding-top: 2px;"><a class="pull-left"><i class="fa fa-ellipsis-v" style="color:#ccc;"></i></a>'; } else { $actions = '<div class="more-row-options" style="padding: 0 7px;padding-top: 2px;"><a data-toggle="dropdown"><i class="fa fa-ellipsis-v"></i></a> <ul class="dropdown-menu">' . $actions . '</ul></div>'; } return $virus_detail . $actions; } $response = array(); if (!empty($result['records']) && is_array($result['records'])) { foreach ($result['records'] as $row) { $file_name = basename($row['path']); $response[] = array( "id" => $row['id'], "file_name" => '<span title="' . $row['path'] . '" data-toggle="tooltip" data-placement="bottom">' . $file_name . '</span>', "reason" => $row['reason'], "definition" => str_replace('.UNOFFICIAL', '', $row['definition']), "file_status" => render_status($row['file_status']), "time" => $row['time'], "actions" => renderActions($row, $lang) ); } } ## Response echo json_encode( array( "draw" => intval(filter_var($_POST['draw'])), "iTotalRecords" => !empty($result['meta']['total']) ? $result['meta']['total'] : 0, "iTotalDisplayRecords" => !empty($result['meta']['total']) ? $result['meta']['total'] : 0, "aaData" => $response ) ); }
| ver. 1.4 |
Github
|
.
| PHP 8.1.34 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings