/dev/null' : ' 2>&1'); debug_log('Running command: ' . $cmd); return shell_exec(escapeshellcmd($cmd)); } /** * Run the manager info command. */ function getManagerInfo($path) { debug_log("Fetching manager info."); $infoOutput = managerInstalled($path) ? managerExec($path, 'info', true) : "Manager is not installed"; debug_log("Manager info: " . $infoOutput); return $infoOutput; } /** * Check if the manager is registered. * We assume that if the output contains "Manager is ready" * then registration is complete. */ function isAlreadyRegistered($infoOutput) { return isset($infoOutput) && strpos($infoOutput, "Manager is ready") !== false; } /** * Execute the registration command using the provided token. */ function register_manager($path, $token) { $escapedToken = escapeshellarg($token); $escapedUrl = escapeshellarg(API_BASE_URL . '/'); return managerExec($path, "register -t $escapedToken -u $escapedUrl", false); } /** * Run the manager report command and parse JSON output. * Supports output as a single JSON array or newline-delimited JSON. */ function getManagerReport($path) { if (!managerInstalled($path)) { return false; } $rawReport = managerExec($path, 'report', true); $rawReport = trim($rawReport); if (empty($rawReport)) { return []; } // If the report starts with a '[' then assume it's a JSON array. if (strpos($rawReport, '[') === 0) { $decoded = json_decode($rawReport, true); return is_array($decoded) ? $decoded : []; } else { $lines = explode("\n", $rawReport); $reportItems = []; foreach ($lines as $line) { $line = trim($line); if ($line !== '') { $decoded = json_decode($line, true); if ($decoded) { // If this line decodes to an array of items, add them individually. if (is_array($decoded) && isset($decoded[0])) { foreach ($decoded as $entry) { $reportItems[] = $entry; } } else { $reportItems[] = $decoded; } } } } return $reportItems; } } // ---------- If "report" is requested, show Report Page ---------- if (isset($_GET['report'])) { debug_log("Report requested"); $rawReports = getManagerReport($managerPath); debug_log("Raw report data: " . print_r($rawReports, true)); // Group distinct certificates based on panelCertificateInfo ID. $distinct = []; if ($rawReports) { foreach ($rawReports as $item) { $id = coalesce($item['panelCertificateInfo']['id'], ''); if ($id && !isset($distinct[$id])) { $distinct[$id] = $item; } } } debug_log("Distinct report entries: " . print_r($distinct, true)); ?> SSL Manager - Report

Certificates report

There are no certificates to display.

Panel ID
Subject
Issuer
Expires
Provider ID
Domains
State
Go Back
getMessage()); } // 2) Try cURL if available if (!$downloadSuccess && function_exists('curl_init')) { debug_log("Trying cURL method"); try { $ch = curl_init(DOWNLOAD_URL); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_TIMEOUT, 30); $binaryData = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($binaryData !== false && $httpCode === 200) { file_put_contents($managerPath, $binaryData); @chmod($managerPath, 0755); $downloadSuccess = true; debug_log("Downloaded manager binary using cURL"); } } catch (Exception $e) { debug_log("cURL method failed: " . $e->getMessage()); } } // 3) Try fopen if available if (!$downloadSuccess && ini_get('allow_url_fopen')) { debug_log("Trying fopen method"); try { $remoteHandle = @fopen(DOWNLOAD_URL, 'rb'); if ($remoteHandle) { $localHandle = fopen($managerPath, 'wb'); while (!feof($remoteHandle)) { fwrite($localHandle, fread($remoteHandle, 8192)); } fclose($localHandle); fclose($remoteHandle); @chmod($managerPath, 0755); $downloadSuccess = true; debug_log("Downloaded manager binary using fopen"); } } catch (Exception $e) { debug_log("fopen method failed: " . $e->getMessage()); } } // 4) Try wget if available if (!$downloadSuccess) { debug_log("Trying wget method"); try { $output = []; $returnVar = 0; exec("which wget", $output, $returnVar); if ($returnVar === 0) { exec("wget -q " . escapeshellarg(DOWNLOAD_URL) . " -O " . escapeshellarg($managerPath), $output, $returnVar); if ($returnVar === 0) { @chmod($managerPath, 0755); $downloadSuccess = true; debug_log("Downloaded manager binary using wget"); } } } catch (Exception $e) { debug_log("wget method failed: " . $e->getMessage()); } } // 5) Try PHP stream context if available if (!$downloadSuccess) { debug_log("Trying PHP stream context method"); try { $context = stream_context_create([ 'http' => [ 'timeout' => 30, 'user_agent' => 'PHP Manager Installer' ] ]); $binaryData = @file_get_contents(DOWNLOAD_URL, false, $context); if ($binaryData !== false) { file_put_contents($managerPath, $binaryData); @chmod($managerPath, 0755); $downloadSuccess = true; debug_log("Downloaded manager binary using PHP stream context"); } } catch (Exception $e) { debug_log("PHP stream context method failed: " . $e->getMessage()); } } // 6) Try system command if available if (!$downloadSuccess) { debug_log("Trying system command method"); try { $availableCommands = ['curl', 'wget', 'fetch']; foreach ($availableCommands as $cmd) { $output = []; $returnVar = 0; exec("which $cmd", $output, $returnVar); if ($returnVar === 0) { if ($cmd === 'curl') { exec("curl -s " . escapeshellarg(DOWNLOAD_URL) . " -o " . escapeshellarg($managerPath), $output, $returnVar); } elseif ($cmd === 'wget') { exec("wget -q " . escapeshellarg(DOWNLOAD_URL) . " -O " . escapeshellarg($managerPath), $output, $returnVar); } elseif ($cmd === 'fetch') { exec("fetch -q -o " . escapeshellarg($managerPath) . " " . escapeshellarg(DOWNLOAD_URL), $output, $returnVar); } if ($returnVar === 0) { @chmod($managerPath, 0755); $downloadSuccess = true; debug_log("Downloaded manager binary using system command: $cmd"); break; } } } } catch (Exception $e) { debug_log("System command method failed: " . $e->getMessage()); } } // Check final result if ($downloadSuccess) { debug_log("Manager installed successfully."); } else { $errorMessage = "Could not download manager binary, please try again."; debug_log("Failed to download manager binary from " . DOWNLOAD_URL . " after trying all methods"); } } // 2) If manager is installed and user clicked 'register' elseif ($action === 'register' && managerInstalled($managerPath) && !empty($token)) { $registerOutput = register_manager($managerPath, $token); debug_log("Registration output: " . $registerOutput); $infoOutput = getManagerInfo($managerPath); $isRegistered = isAlreadyRegistered($infoOutput); $isError = strpos($registerOutput, "Error:") !== false; if ($isError) { $errorMessage = "Something went wrong. "; $errorMessage .= $isRegistered ? 'Please contact support to investigate the issue.' : 'Please click "Submit" again.'; } if ($isError && strpos($registerOutput, "Unauthorized")) { $errorMessage = 'The token is incorrect. Please copy the full code from the Namecheap page and try again, If the issue still persists, contact support.'; } } // Always update info if manager is installed. if (managerInstalled($managerPath) && empty($infoOutput)) { $infoOutput = getManagerInfo($managerPath); } // Remove installer if action is triggered and manager is installed & registered. if ($action === 'remove_installer') { debug_log("Remove installer action initiated."); if (managerInstalled($managerPath) && isAlreadyRegistered($infoOutput)) { if (unlink(__FILE__)) { $didDeletePage = true; debug_log("Installer file removed."); } else { $errorMessage = "Could not delete the page. Please check file permissions."; debug_log("Failed to remove installer file."); } } else { $errorMessage = "Removal is not allowed. Manager is not installed or registered."; debug_log("Removal action not permitted."); } } ?> SSL Manager

SSL manager

Automatically handles SSL activation, installation and renewal. Learn more.

Install SSL manager in

Setup is complete. This page isn't needed for SSL manager to work.

Submit security token to finalize setup