Add a error line to the logger, and by default exit page
try { $challenges = new Challenges($domain); $challenges->solveChallenge(); $log->log('Successfully completed challenge for ' . $domain->getDomain()); $domain->createKeys(); $domain->requestCertificate(null, $domain->config('subdomains')); $log->log('Successfully received certificate from Let\'s Encrypt'); $domain->applyCertificates(); $log->log('Successfully applied certificate and CA certificates to DirectAdmin'); $domain->config('domain', $domain->getDomain()); $domain->config('subdomains', $domain->getSubdomains()); $domain->config('status', 'applied to DirectAdmin (renewed)'); $domain->config('expire', date('Y-m-d', strtotime('+50 days'))); $log->log('Reissued domain ' . $domain->getDomain() . ' with success.'); } catch (\Exception $e) { $log->error($e->getMessage(), null, false); } } } // Rewrite and restart HTTPD files $queue = 'action=rewrite&value=httpd' . PHP_EOL; $queue .= 'action=httpd&value=graceful' . PHP_EOL; file_put_contents('/usr/local/directadmin/data/task.queue', $queue, FILE_APPEND); $log->log('Added rewrite and reload to Task.queue'); // Send notification to admin $latestId = array_pop(scandir('/usr/local/directadmin/data/tickets')); $id = array_pop(scandir('/usr/local/directadmin/data/tickets/' . $latestId)) + 1; $path = '/usr/local/directadmin/data/tickets/' . substr(sprintf("%09d", $id), 0, 6); if (!file_exists($path)) { mkdir($path); chmod($path, 0700);
<?php global $_POST, $_GET; use DirectAdmin\LetsEncrypt\Lib\Logger; require_once dirname(__DIR__) . '/vendor/autoload.php'; $servers = ['live' => 'https://acme-v01.api.letsencrypt.org/directory', 'staging' => 'https://acme-staging.api.letsencrypt.org/directory']; if (!defined('CRON')) { parse_str(getenv('QUERY_STRING'), $_GET); parse_str(getenv('POST'), $_POST); if (!isset($_SERVER['SESSION_SELECTED_DOMAIN']) || empty($_SERVER['SESSION_SELECTED_DOMAIN'])) { if ($_SERVER['RUNNING_AS'] != 'admin') { $log = new Logger(); $log->error('Please select a domain first at the DirectAdmin homepage.'); } } }