File manager - Edit - /usr/local/cpanel/base/frontend/jupiter/cpguard/scanner/cms_list.php
Back
<?php include_once dirname(__DIR__) . "/includes/init.php"; include_once $base_dir . "/classes/language.class.php"; include_once dirname(__DIR__) . "/classes/api.class.php"; $lang = new Language('cms'); $api = new Api($current_user); ## Read value $start = filter_var($_POST['start']); $length = filter_var($_POST['length']); $order = $_POST['order'] ?? []; $columns = $_POST['columns'] ?? []; $sort = []; // Loop through all sorting parameters foreach ($order as $sort_order) { $column_index = $sort_order['column']; $column_name = $columns[$column_index]['data']; $column_sort_order = $sort_order['dir']; // Validate allowed columns to prevent SQL injection $allowed_columns = ['threat_score', 'issues_count', 'theme_outdated_count', 'plugin_outdated_count', 'path', 'domain', 'version', 'version_status']; if (in_array($column_name, $allowed_columns)) { $sort[$column_name] = $column_sort_order; } } // If no sorting is specified, apply default sorting if (empty($sort)) { $sort = ['threat_score' => 'DESC', 'issues_count' => 'DESC', 'plugin_outdated_count' => 'DESC', 'theme_outdated_count' => 'DESC']; } $filter = []; if (!empty($_POST['search']['value'])) { $filter['query'] = filter_var($_POST['search']['value']); } if (!empty($_POST['target'])) { $filter['target'] = filter_var($_POST['target']); } $request = [ 'page' => ($start / $length) + 1, 'length' => $length, 'sort' => $sort, 'status' => isset($_POST['status']) && $_POST['status'] == 0 ? 0 : 1, 'filter' => $filter, ]; $result = $api->request('cmsListTable', $request); function render_level($level) { $colors = array('Low' => '#32CD32', 'Moderate' => '#4169E1', 'Substantial' => '#32CD32', 'Severe' => '#FF8C00', 'Critical' => '#FF0000'); return '<span style="padding: 5px;color:#fff;background-color:' . $colors[$level] . '" class="badge">' . $level . '</span>'; } function renderActions($row) { if ($row['user_status'] == 1) { //$actions = "<a class=\"table-actions\" data-toggle=\"tooltip\" data-placement=\"left\" title=\"Delete entry\" data-infected-count=\"10\" ><i class=\"la la-file-alt\"></i></a> "; $actions = "<a class=\"table-action tooltip-toggle\" data-toggle=\"tooltip\" data-placement=\"left\" title=\"Delete entry\" data-id=\"" . $row['id'] . "\" data-action=\"dismiss\"><i class=\"la la-trash\"></i></a>"; } else { $actions = "<a class=\"table-action tooltip-toggle\" data-toggle=\"tooltip\" data-placement=\"left\" title=\"Restore entry\" data-id=\"" . $row['id'] . "\" data-action=\"retain\"><i class=\"fa fa-recycle\"></i></a>"; } return $actions; } $response = array(); if ($result['records']) { $common_dir = getCommonBaseDirectory($result['records']); foreach ($result['records'] as $row) { $response[] = array( "id" => $row['id'], "domain" => '<i class="la la-' . $row['type'] . ' text-info"></i> ' . $row['domain'] . $row['url'], "path" => '<span title="' . $row['path'] . '" data-toggle="tooltip" data-placement="bottom">' . str_replace($common_dir, '', $row['path']) . '</span> <i data-path="' . $row['path'] . '" class="la la-copy" data-toggle="tooltip" title="copy path"></i>', "user" => $row['user'], "version" => $row['version'], "threat_score" => $row['threat_score'] . ' ' . $row['threat_rating'], "issues_count" => $row['issues_count'], "plugin_outdated_count" => $row['plugin_outdated_count'] == 0 ? $row['plugins_count'] : $row['plugin_outdated_count'] . '/' . $row['plugins_count'] . ' outdated', "theme_outdated_count" => $row['theme_outdated_count'] == 0 ? $row['themes_count'] : $row['theme_outdated_count'] . '/' . $row['themes_count'] . ' outdated', "status" => $row['status'] == 0 ? '<span class="badge badge-danger">broken</span>' : (version_compare($row['version'], $row['latest_version'], '<') == true ? '<span class="badge badge-pill badge-warning"><small>update to</small> ' . $row['latest_version'] . '</span>' : 'latest'), ); } } ## Response echo json_encode( array( "draw" => intval(filter_var($_POST['draw'])), "iTotalRecords" => $result['meta']['total'] ? $result['meta']['total'] : 0, "iTotalDisplayRecords" => $result['meta']['total'] ? $result['meta']['total'] : 0, "aaData" => $response ) ); function getCommonBaseDirectory($associativeArray) { if (empty($associativeArray)) { return ''; } // Extract paths from the associative array $paths = array_column($associativeArray, 'path'); if (empty($paths)) { return ''; } $baseParts = explode(DIRECTORY_SEPARATOR, array_shift($paths)); foreach ($paths as $path) { $pathParts = explode(DIRECTORY_SEPARATOR, $path); $newBaseParts = []; foreach ($baseParts as $index => $part) { if (isset($pathParts[$index]) && $pathParts[$index] === $part) { $newBaseParts[] = $part; } else { break; } } $baseParts = $newBaseParts; if (empty($baseParts)) { break; } } return implode(DIRECTORY_SEPARATOR, $baseParts); }
| ver. 1.4 |
Github
|
.
| PHP 8.1.34 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings