| 1234567891011121314151617181920212223242526272829 |
- <?php
- namespace application\controllers;
- class GetSSLDaysController {
- public static function getSSLDays($data): void {
- $domain = $data['domain'] ?? '';
- if (empty($domain)) {
- http_response_code(400);
- echo json_encode(['error' => 'Missing required parameter: domain']);
- return;
- }
- exec("sudo certbot certificates --cert-name $domain | grep 'Expiry' | grep 'Expiry'", $phpOutput, $phpReturnCode);
- if(empty($phpOutput)){
- echo json_encode([
- 'ssl_expiry' => "-",
- 'ssl_remaining' => "-"
- ]);
- } else {
- $sslData = explode(" ",$phpOutput[0]);
- echo json_encode([
- 'ssl_expiry' => $sslData[6],
- 'ssl_remaining' => $sslData[9]
- ]);
- }
- }
- }
|