File manager - Edit - /usr/local/cpanel/base/frontend/jupiter/cpguard/directadmin/admin/index.raw
Back
#!/opt/cpguard/cpg-php-fpm/bin/php <?php /** * DirectAdmin admin plugin entrypoint for cPGuard * - Calls local Go bridge (/opt/cpguard/app/cpg-bridge) * - Expects JSON: { "response": "https://app.opsshield.com/..." } * - Redirects browser to that URL in a new tab (using DA hook target="_blank") */ error_reporting(E_ALL); ini_set('display_errors', 0); // keep this 0 in production $env = getenv(); $user = $env['USERNAME'] ?? ''; if (empty($user) || !in_array($user, ['root', 'diradmin', 'admin'])) { echo "HTTP/1.1 403 Forbidden\n"; echo "Content-Type: text/html; charset=utf-8\n\n"; echo "<h2>Access Denied</h2>"; echo "<p>This script must be run as root or diradmin user.</p>"; exit; } else { echo "HTTP/1.1 200 OK\n"; echo "Content-Type: text/html; charset=utf-8\n\n"; } $payload = [ 'method' => 'portalLogin', 'user' => $user, // system user (diradmin) 'data' => [], ]; $binaryPath = '/opt/cpguard/app/cpg-bridge'; $descriptors = [ 0 => ['pipe', 'r'], // STDIN 1 => ['pipe', 'w'], // STDOUT 2 => ['pipe', 'w'], // STDERR ]; $process = @proc_open($binaryPath, $descriptors, $pipes); if (is_resource($process)) { fwrite($pipes[0], json_encode($payload)); fclose($pipes[0]); $responseRaw = stream_get_contents($pipes[1]); $errorsRaw = stream_get_contents($pipes[2]); fclose($pipes[1]); fclose($pipes[2]); $exitCode = proc_close($process); if ($exitCode === 0) { $json = json_decode($responseRaw); // Valid URL check if ($json && isset($json->response) && filter_var($json->response, FILTER_VALIDATE_URL)) { echo trim($json->response); exit(0); } else { echo "Invalid response from bridge."; } } else { echo "Process failed (Code $exitCode): " . strip_tags($errorsRaw); } } else { echo "Failed to open process."; } die();
| ver. 1.4 |
Github
|
.
| PHP 8.1.34 | Generation time: 0.04 |
proxy
|
phpinfo
|
Settings