getMessage()); } foreach ($pods as $pod) { if ($pod['domain'] === $_domain) { if ($pod['email']) { die('domain already exists and is registered to an owner, use the edit function to modify'); } $digtxt = exec(escapeshellcmd('dig ' . $_domain . ' TXT +short')); if (strpos($digtxt, $pod['publickey']) === false) { die('domain already exists, you can claim the domain by adding a DNS TXT record that states
' . $_domain . ' IN TXT "' . $pod['publickey'] . '"'); } echo 'domain validated, you can now add details '; $uuid = md5(uniqid($_domain, true)); $expire = time() + 2700; try { $p = R::load('pods', $pod['id']); $p['token'] = $uuid; $p['tokenexpire'] = date('Y-m-d H:i:s', $expire); R::store($p); } catch (\RedBeanPHP\RedException $e) { die('Error in SQL query: ' . $e->getMessage()); } echo << window.onload = function() { $("#weight").ionRangeSlider(); }



EOF; $stop = 1; } } if (!$stop) { $link = 'https://' . $_domain . '/nodeinfo/1.0'; if ($infos = file_get_contents('https://' . $_domain . '/.well-known/nodeinfo')) { $info = json_decode($infos, true); $link = max($info['links'])['href']; } $chss = curl_init(); curl_setopt($chss, CURLOPT_URL, $link); curl_setopt($chss, CURLOPT_POST, 0); curl_setopt($chss, CURLOPT_HEADER, 0); curl_setopt($chss, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($chss, CURLOPT_RETURNTRANSFER, 1); curl_setopt($chss, CURLOPT_NOBODY, 0); $outputssl = curl_exec($chss); curl_close($chss); if ($outputssl && stripos($outputssl, 'openRegistrations') !== false) { echo 'Your pod has ssl and is valid
'; $publickey = md5(uniqid($_domain, true)); try { $p = R::dispense('pods'); $p['domain'] = $_domain; $p['email'] = $_email; $p['podmin_statement'] = $_podmin_statement; $p['podmin_notify'] = $_podmin_notify; $p['publickey'] = $publickey; R::store($p); } catch (\RedBeanPHP\RedException $e) { die('Error in SQL query: ' . $e->getMessage()); } if ($_email) { $to = $adminemail; $subject = 'New pod added to ' . $_SERVER['HTTP_HOST']; $headers = ['From: ' . $_email, 'Reply-To: ' . $_email, 'Cc: ' . $_email]; $message_lines = [ 'https://' . $_SERVER['HTTP_HOST'], 'Your pod ' . $_domain . ' will not show up right away, as it needs to pass a few checks first.', 'Give it a few hours!', ]; @mail($to, $subject, implode("\r\n", $message_lines), implode("\r\n", $headers)); } echo 'Data successfully inserted! Your pod will be checked and live on the list in a few hours!'; } else { echo 'Could not validate your pod, check your setup!
Take a look at your /nodeinfo'; } }