* GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) */ namespace Panel\Cert; class CertsAdd extends \Panel\Cert { function beforeRoute($f3) { parent::beforeRoute($f3); } static function get($f3) { if ($f3->exists('PARAMS.cert')) { $domain = $f3->get('PARAMS.cert'); if ($f3->call('\Panel::validateDomain', $domain)) { if ($certdomain_dns = dns_get_record("$domain", DNS_A)) { if ($certdomain_dns[0]['ip'] == $_SERVER['SERVER_ADDR']) { if (is_dir('/var/tmp/letsencrypt/')) { if (is_writable('/var/tmp/letsencrypt/')) { touch("/var/tmp/letsencrypt/$domain"); $messages = $f3->get('SESSION.messages'); $messages[] = "A background job to create a Security Certificate for $domain has been started."; $messages[] = "It can take a few seconds, up to one minute, for this job to complete."; $messages[] = "Wait few seconds and then reload this page to check for the new Security Certificate."; $f3->set('SESSION.messages', $messages); } else { $messages = $f3->get('SESSION.messages'); $messages[] = "System error with Security Certificate system."; $messages[] = "Please try again later."; $f3->set('SESSION.messages', $messages); } } else { $messages = $f3->get('SESSION.messages'); $messages[] = "System error with Security Certificate system."; $messages[] = "Please try again later."; $f3->set('SESSION.messages', $messages); } } else { $messages = $f3->get('SESSION.messages'); $messages[] = "DNS for $domain does not point to this server IP."; $messages[] = "Please update DNS and try again."; $f3->set('SESSION.messages', $messages); } } else { $messages = $f3->get('SESSION.messages'); $messages[] = "Error verifying DNS, try again later."; $f3->set('SESSION.messages', $messages); } } parse_str($f3->get('QUERY'), $output); if (isset($output['r'])) { $f3->reroute($output['r']); } } /* default reroute as fallback */ $f3->reroute('/'); } }