domain updtae

This commit is contained in:
devdatt 2025-12-12 06:11:28 +05:30
parent 20c3144572
commit 489d09b42f
3 changed files with 36 additions and 40 deletions

View File

@ -1,4 +1,22 @@
<?php include 'header.php'; ?> <?php include 'header.php'; ?>
<?php
$jsonFile = __DIR__ . '/domain.json';
$defaults = [
'domain' => 'example.com',
'subdomain' => 'www.example.com',
'email' => 'name@example.com',
];
if (file_exists($jsonFile)) {
$raw = file_get_contents($jsonFile);
$data = json_decode($raw, true);
if (!is_array($data)) $data = $defaults;
} else {
$data = $defaults;
}
?>
<body> <body>
<style> <style>
:root { :root {
@ -116,14 +134,13 @@
<div class="card"> <div class="card">
<form method="post" action="request_cert.php"> <form method="post" action="request_cert.php">
<label for="domain">Primary domain</label> <label for="domain">Primary domain</label>
<input id="domain" name="domain" type="text" placeholder="example.com" required pattern="^[A-Za-z0-9.-]{1,253}$" /> <input id="domain" name="domain" type="text" placeholder="example.com" required pattern="^[A-Za-z0-9.-]{1,253}$" value="<?php if ($data['domain'] !== "example.com") echo $data['domain']; ?>" />
<label for="subdomains" class="muted">Subdomains</label> <label for="subdomains" class="muted">Subdomains</label>
<input id="subdomains" name="subdomains" type="text" placeholder="www,stream,yourapp (optional)" /> <input id="subdomains" name="subdomains" type="text" placeholder="example.com (optional)" value="<?php if ($data['domain'] !== "www.example.com") echo $data['subdomain']; ?>" />
<label for="email">Contact email (for Let\'s Encrypt notices)</label> <label for="email">Contact email (for Let\'s Encrypt notices)</label>
<input id="email" name="email" type="email" placeholder="admin@example.com" required /> <input id="email" name="email" type="email" placeholder="your_name@example.com" value="<?php if ($data['email'] !== "name@example.com") echo $data['email']; ?>" required />
<div class="row"> <div class="row">

View File

@ -8,7 +8,8 @@
$FORM_PAGE = "domain.php"; // redirect back to your form $FORM_PAGE = "domain.php"; // redirect back to your form
function alert_and_back($message) { function alert_and_back($message)
{
global $FORM_PAGE; global $FORM_PAGE;
// SAFELY escape entire message for JavaScript (supports newlines, quotes, etc.) // SAFELY escape entire message for JavaScript (supports newlines, quotes, etc.)
@ -43,8 +44,18 @@ $subdomains_raw = trim($_POST['subdomains'] ?? '');
$email = trim($_POST['email'] ?? ''); $email = trim($_POST['email'] ?? '');
$staging = ($_POST['staging'] ?? "0") === "1" ? 1 : 0; $staging = ($_POST['staging'] ?? "0") === "1" ? 1 : 0;
$jsonFile = __DIR__ . '/domain.json';
$new = [
'domain' => $domain,
'subdomain' => $subdomains_raw,
'email' => $email,
];
$json = json_encode($new, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
file_put_contents($jsonFile, $json, LOCK_EX);
// Validation helpers // Validation helpers
function valid_domain_name($d) { function valid_domain_name($d)
{
return (bool) preg_match( return (bool) preg_match(
'/^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/i', '/^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/i',
$d $d
@ -97,8 +108,8 @@ foreach ($domains as $d) {
// Build certbot command // Build certbot command
$certbot = "/usr/bin/certbot"; $certbot = "/usr/bin/certbot";
$cmd = "sudo $certbot --nginx --agree-tos --non-interactive --email " $cmd = "sudo $certbot --nginx --agree-tos --non-interactive --email "
. escapeshellarg($email) . escapeshellarg($email)
. " $dargs"; . " $dargs";
if ($staging === 1) { if ($staging === 1) {
$cmd .= " --staging"; $cmd .= " --staging";
@ -127,5 +138,3 @@ if ($reload_rc !== 0) {
// Success // Success
alert_and_back("Certificate installed successfully for:\n" . implode(", ", $domains)); alert_and_back("Certificate installed successfully for:\n" . implode(", ", $domains));
?>

View File

@ -623,36 +623,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
</div> </div>
</div> </div>
<div class="card wide">
<div class="card-row">
<div class="card-left">
<div class="hls-player-wrapper">
<video
class="hls-video"
controls
autoplay
playsinline
src="<?php echo "https://live.newzroom.in/hls/shree/bhattji.m3u8"; ?>">
Your browser does not support HTML5 HLS playback.
</video>
</div>
</div>
<div class="card-right">
<div class="hls-player-wrapper">
<video
class="hls-video"
controls
autoplay
playsinline
src="<?php echo "https://live.newzroom.in/hls/shreeshree/bhattji.m3u8"; ?>">
Your browser does not support HTML5 HLS playback.
</video>
</div>
</div>
</div>
</div>
</div> </div>
</div> </div>