add domains flder and functionality

tpm1
Suvodip 2025-03-25 20:34:34 +05:30
parent e8838d0277
commit 4e939b87fe
7 changed files with 134 additions and 2 deletions

2
.gitignore vendored
View File

@ -5,7 +5,7 @@ dist/
# dependencies
node_modules/
public/host-api/
# logs
npm-debug.log*
yarn-debug.log*

BIN
dist.zip Normal file

Binary file not shown.

View File

@ -6,7 +6,8 @@
"dev": "astro dev",
"build": "astro build",
"preview": "astro preview",
"astro": "astro"
"astro": "astro",
"push-s33": "rsync -rv --exclude .hta_config/conf.php dist/ dev2@siliconpin.s33.siliconpin.com:/home/dev2/domains/siliconpin.s33.siliconpin.com/public_html/"
},
"dependencies": {
"@astrojs/react": "^4.2.1",

View File

@ -0,0 +1,27 @@
---
import Layout from "../../layouts/Layout.astro"
---
<Layout title="">
<div>
<pre id="get-response">Adding domain, please wait...</pre>
</div>
<script is:inline>
fetch('/host-api/add-domain/')
.then(response => {
if (!response.ok) throw new Error('Network error');
return response.json();
})
.then(data => {
const resultElement = document.getElementById('get-response');
if (data.status === 'success') {
resultElement.textContent = `✅ ${data.message}\n${data.output || ''}`;
} else {
resultElement.textContent = `❌ ${data.message}`;
}
})
.catch(error => {
document.getElementById('get-response').textContent = `❌ Fetch Error: ${error.message}`;
});
</script>
</Layout>

View File

@ -0,0 +1,45 @@
---
import Layout from "../../layouts/Layout.astro"
---
<Layout title="">
<div>
<h2>Delete Domain</h2>
<form id="deleteDomainForm">
<input type="text" id="domainName" placeholder="example.com" required>
<button type="submit">Delete Domain</button>
</form>
<pre id="deleteResponse"></pre>
</div>
<script is:inline>
document.getElementById('deleteDomainForm').addEventListener('submit', async (e) => {
e.preventDefault();
const domain = document.getElementById('domainName').value;
const responseElement = document.getElementById('deleteResponse');
responseElement.textContent = "Deleting domain...";
try {
const response = await fetch('/host-api/delete-domain/', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: `domain=${encodeURIComponent(domain)}`
});
const data = await response.json();
if (data.status === 'success') {
responseElement.textContent = `✅ ${data.message}\nDomain: ${data.domain}`;
// Refresh domain list if needed
setTimeout(() => window.location.reload(), 1500);
} else {
responseElement.textContent = `❌ ${data.message}\nError: ${data.error || 'Unknown error'}`;
}
} catch (error) {
responseElement.textContent = `❌ Network Error: ${error.message}`;
}
});
</script>
</Layout>

View File

@ -0,0 +1,40 @@
---
import Layout from "../../layouts/Layout.astro"
---
<Layout title="">
<div>
<pre id="get-response">Loading domains...</pre>
</div>
<script is:inline>
fetch('/host-api/list-domain/')
.then(response => {
if (!response.ok) throw new Error('Network error');
return response.json();
})
.then(data => {
const pre = document.getElementById('get-response');
if (data.status === 'success') {
// Format domains as a table
let output = 'DOMAINS LIST:\n\n';
output += 'Domain'.padEnd(40) + 'IP'.padEnd(15) + 'SSL'.padEnd(5) + 'Status\n';
output += '-'.repeat(70) + '\n';
if (Object.keys(data.domains).length > 0) {
Object.entries(data.domains).forEach(([domain, info]) => {
output += `${domain.padEnd(40)}${info.IP.padEnd(15)}${info.SSL.padEnd(5)}${info.SUSPENDED === 'no' ? 'Active' : 'Suspended'}\n`;
});
} else {
output += 'No domains found for this user\n';
}
pre.textContent = output;
} else {
pre.textContent = `❌ Error: ${data.message}\nDebug: ${data.debug || ''}\nJSON Error: ${data.json_error || ''}`;
}
})
.catch(error => {
document.getElementById('get-response').textContent = `❌ Fetch Error: ${error.message}`;
});
</script>
</Layout>

19
src/pages/profile.astro Normal file
View File

@ -0,0 +1,19 @@
---
import Layout from "../layouts/Layout.astro";
const phpHello = `$_SESSION['userName']`;
---
<Layout title="Profile Page">
<div class="flex items-center justify-center min-h-screen bg-gray-700">
<div class="w-96 p-6 shadow-lg rounded-lg bg-white text-center">
<img class="w-24 h-24 rounded-full border-4 border-blue-500 mx-auto" src="/profile.jpg" alt="Profile Picture" />
<h2 class="text-2xl font-semibold mt-4" set:html={phpHello ? phpHello : 'User Name'}></h2>
<p class="text-gray-600">Frontend Developer</p>
<p class="text-gray-500 text-sm mt-2">"Building amazing UI experiences one component at a time."</p>
<div class="flex justify-center space-x-4 mt-4">
<button class="bg-blue-500 text-white px-4 py-2 rounded-lg">Follow</button>
<button class="bg-gray-200 text-black px-4 py-2 rounded-lg">Message</button>
</div>
</div>
</div>
</Layout>