getMessage())); } $stop = false; 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) { debug('Error in SQL query: ' . sprintf($e->getMessage())); } echo << window.onload = function() { $("#weight").ionRangeSlider(); $("#podmin_notify_level").ionRangeSlider(); }




EOF; $stop = true; } } if (!$stop) { $link = 'https://' . $_domain . '/nodeinfo/1.0'; $nodeinfo = curl('https://' . $_domain . '/.well-known/nodeinfo'); if ($info = json_decode($nodeinfo['body'] ?: '', true)) { $link = max($info['links'])['href']; } $output = curl($link, true); if ($output['body'] && stripos($output['body'], '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['podmin_notify_level'] = $_podmin_notify_level; $p['publickey'] = $publickey; R::store($p); } catch (\RedBeanPHP\RedException $e) { debug('Error in SQL query: ' . sprintf($e->getMessage())); } if ($_email) { $to = c('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'; } }