Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e200fc0f11 | ||
|
|
7d516df61b | ||
|
|
416c5781de | ||
|
|
38881c7a8f |
33
assets/css/custom.css
Normal file
33
assets/css/custom.css
Normal file
@ -0,0 +1,33 @@
|
||||
:root {
|
||||
--primary-color: #4F46E5;
|
||||
--secondary-color: #10B981;
|
||||
--background-color: #F9FAFB;
|
||||
--surface-color: #FFFFFF;
|
||||
--text-color: #1F2937;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: var(--background-color);
|
||||
color: var(--text-color);
|
||||
font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background-color: var(--primary-color);
|
||||
border-color: var(--primary-color);
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background-color: var(--secondary-color);
|
||||
border-color: var(--secondary-color);
|
||||
}
|
||||
|
||||
.card {
|
||||
border-radius: 0.75rem;
|
||||
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
|
||||
}
|
||||
|
||||
header {
|
||||
background-image: linear-gradient(to right, var(--primary-color), var(--secondary-color));
|
||||
color: white;
|
||||
}
|
||||
76
assets/js/main.js
Normal file
76
assets/js/main.js
Normal file
@ -0,0 +1,76 @@
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const beautyVotes = [];
|
||||
const funnyVotes = [];
|
||||
|
||||
const beautyInput = document.getElementById('website_number_beauty');
|
||||
const funnyInput = document.getElementById('website_number_funny');
|
||||
const toastLiveExample = document.getElementById('liveToast');
|
||||
const toast = new bootstrap.Toast(toastLiveExample);
|
||||
|
||||
document.querySelectorAll('.form-check-input[data-category]').forEach(checkbox => {
|
||||
checkbox.addEventListener('change', function() {
|
||||
const category = this.dataset.category;
|
||||
const websiteNumber = this.dataset.websiteNumber;
|
||||
const votes = (category === 'beauty') ? beautyVotes : funnyVotes;
|
||||
const input = (category === 'beauty') ? beautyInput : funnyInput;
|
||||
|
||||
if (this.checked) {
|
||||
if (votes.length >= 3) {
|
||||
this.checked = false;
|
||||
alert('You can only select up to 3 websites per category.');
|
||||
return;
|
||||
}
|
||||
votes.push(websiteNumber);
|
||||
} else {
|
||||
const index = votes.indexOf(websiteNumber);
|
||||
if (index > -1) {
|
||||
votes.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
votes.sort((a, b) => a - b);
|
||||
input.value = votes.join(', ');
|
||||
});
|
||||
});
|
||||
|
||||
const handleFormSubmit = (form, event) => {
|
||||
event.preventDefault();
|
||||
const formData = new FormData(form);
|
||||
const data = Object.fromEntries(formData.entries());
|
||||
|
||||
fetch('submit_vote.php', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(result => {
|
||||
if (result.success) {
|
||||
toast.show();
|
||||
form.reset();
|
||||
|
||||
// Clear the votes and checkboxes for the submitted category
|
||||
if (data.category === 'beauty') {
|
||||
beautyVotes.length = 0;
|
||||
document.querySelectorAll('input[data-category="beauty"]').forEach(cb => cb.checked = false);
|
||||
beautyInput.value = '';
|
||||
} else {
|
||||
funnyVotes.length = 0;
|
||||
document.querySelectorAll('input[data-category="funny"]').forEach(cb => cb.checked = false);
|
||||
funnyInput.value = '';
|
||||
}
|
||||
} else {
|
||||
alert('Error: ' + result.error);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error);
|
||||
alert('An error occurred while submitting your votes.');
|
||||
});
|
||||
};
|
||||
|
||||
document.getElementById('beautiful-form').addEventListener('submit', (event) => handleFormSubmit(event.target, event));
|
||||
document.getElementById('funny-form').addEventListener('submit', (event) => handleFormSubmit(event.target, event));
|
||||
});
|
||||
380
index.php
380
index.php
@ -1,131 +1,263 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
@ini_set('display_errors', '1');
|
||||
@error_reporting(E_ALL);
|
||||
@date_default_timezone_set('UTC');
|
||||
|
||||
$phpVersion = PHP_VERSION;
|
||||
$now = date('Y-m-d H:i:s');
|
||||
?>
|
||||
<!doctype html>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>New Style</title>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
:root {
|
||||
--bg-color-start: #6a11cb;
|
||||
--bg-color-end: #2575fc;
|
||||
--text-color: #ffffff;
|
||||
--card-bg-color: rgba(255, 255, 255, 0.01);
|
||||
--card-border-color: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: 'Inter', sans-serif;
|
||||
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
|
||||
color: var(--text-color);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
body::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path d="M-10 10L110 10M10 -10L10 110" stroke-width="1" stroke="rgba(255,255,255,0.05)"/></svg>');
|
||||
animation: bg-pan 20s linear infinite;
|
||||
z-index: -1;
|
||||
}
|
||||
@keyframes bg-pan {
|
||||
0% { background-position: 0% 0%; }
|
||||
100% { background-position: 100% 100%; }
|
||||
}
|
||||
main {
|
||||
padding: 2rem;
|
||||
}
|
||||
.card {
|
||||
background: var(--card-bg-color);
|
||||
border: 1px solid var(--card-border-color);
|
||||
border-radius: 16px;
|
||||
padding: 2rem;
|
||||
backdrop-filter: blur(20px);
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
.loader {
|
||||
margin: 1.25rem auto 1.25rem;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border: 3px solid rgba(255, 255, 255, 0.25);
|
||||
border-top-color: #fff;
|
||||
border-radius: 50%;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
@keyframes spin {
|
||||
from { transform: rotate(0deg); }
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
.hint {
|
||||
opacity: 0.9;
|
||||
}
|
||||
.sr-only {
|
||||
position: absolute;
|
||||
width: 1px; height: 1px;
|
||||
padding: 0; margin: -1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
white-space: nowrap; border: 0;
|
||||
}
|
||||
h1 {
|
||||
font-size: 3rem;
|
||||
font-weight: 700;
|
||||
margin: 0 0 1rem;
|
||||
letter-spacing: -1px;
|
||||
}
|
||||
p {
|
||||
margin: 0.5rem 0;
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
code {
|
||||
background: rgba(0,0,0,0.2);
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
}
|
||||
footer {
|
||||
position: absolute;
|
||||
bottom: 1rem;
|
||||
font-size: 0.8rem;
|
||||
opacity: 0.7;
|
||||
}
|
||||
</style>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Flatlogic Website Awards</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="assets/css/custom.css">
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<div class="card">
|
||||
<h1>Analyzing your requirements and generating your website…</h1>
|
||||
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
|
||||
<span class="sr-only">Loading…</span>
|
||||
</div>
|
||||
<p class="hint">Flatlogic AI is collecting your requirements and applying the first changes.</p>
|
||||
<p class="hint">This page will update automatically as the plan is implemented.</p>
|
||||
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
|
||||
|
||||
<header class="text-center py-5">
|
||||
<div class="container">
|
||||
<h1 class="display-4">Flatlogic Website Awards</h1>
|
||||
<p class="lead">Vote for the most beautiful and most funny/interesting websites!</p>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main class="container">
|
||||
<div class="row mb-5">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title text-center">Websites for Voting</h2>
|
||||
<ol class="list-group list-group-numbered">
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<a href="https://counterwars.dev.flatlogic.app" target="_blank">https://counterwars.dev.flatlogic.app</a>
|
||||
<div class="form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" data-category="beauty" data-website-number="1"><label class="form-check-label">Beauty</label>
|
||||
<input class="form-check-input" type="checkbox" data-category="funny" data-website-number="1"><label class="form-check-label">Funny</label>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<a href="https://justvibing.dev.flatlogic.app" target="_blank">https://justvibing.dev.flatlogic.app</a>
|
||||
<div class="form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" data-category="beauty" data-website-number="2"><label class="form-check-label">Beauty</label>
|
||||
<input class="form-check-input" type="checkbox" data-category="funny" data-website-number="2"><label class="form-check-label">Funny</label>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<a href="https://flower-shop.dev.flatlogic.app" target="_blank">https://flower-shop.dev.flatlogic.app</a>
|
||||
<div class="form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" data-category="beauty" data-website-number="3"><label class="form-check-label">Beauty</label>
|
||||
<input class="form-check-input" type="checkbox" data-category="funny" data-website-number="3"><label class="form-check-label">Funny</label>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<a href="https://pizzaslicer.dev.flatlogic.app" target="_blank">https://pizzaslicer.dev.flatlogic.app</a>
|
||||
<div class="form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" data-category="beauty" data-website-number="4"><label class="form-check-label">Beauty</label>
|
||||
<input class="form-check-input" type="checkbox" data-category="funny" data-website-number="4"><label class="form-check-label">Funny</label>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<a href="https://vm-34156.dev.flatlogic.app" target="_blank">https://vm-34156.dev.flatlogic.app</a>
|
||||
<div class="form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" data-category="beauty" data-website-number="5"><label class="form-check-label">Beauty</label>
|
||||
<input class="form-check-input" type="checkbox" data-category="funny" data-website-number="5"><label class="form-check-label">Funny</label>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<a href="https://digital-museum.dev.flatlogic.app" target="_blank">https://digital-museum.dev.flatlogic.app</a>
|
||||
<div class="form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" data-category="beauty" data-website-number="6"><label class="form-check-label">Beauty</label>
|
||||
<input class="form-check-input" type="checkbox" data-category="funny" data-website-number="6"><label class="form-check-label">Funny</label>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<a href="https://sell-product.dev.flatlogic.app" target="_blank">https://sell-product.dev.flatlogic.app</a>
|
||||
<div class="form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" data-category="beauty" data-website-number="7"><label class="form-check-label">Beauty</label>
|
||||
<input class="form-check-input" type="checkbox" data-category="funny" data-website-number="7"><label class="form-check-label">Funny</label>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<a href="https://my-portfolio.dev.flatlogic.app" target="_blank">https://my-portfolio.dev.flatlogic.app</a>
|
||||
<div class="form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" data-category="beauty" data-website-number="8"><label class="form-check-label">Beauty</label>
|
||||
<input class="form-check-input" type="checkbox" data-category="funny" data-website-number="8"><label class="form-check-label">Funny</label>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<a href="https://project-manager.dev.flatlogic.app" target="_blank">https://project-manager.dev.flatlogic.app</a>
|
||||
<div class="form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" data-category="beauty" data-website-number="9"><label class="form-check-label">Beauty</label>
|
||||
<input class="form-check-input" type="checkbox" data-category="funny" data-website-number="9"><label class="form-check-label">Funny</label>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<a href="https://codeninja.dev.flatlogic.app" target="_blank">https://codeninja.dev.flatlogic.app</a>
|
||||
<div class="form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" data-category="beauty" data-website-number="10"><label class="form-check-label">Beauty</label>
|
||||
<input class="form-check-input" type="checkbox" data-category="funny" data-website-number="10"><label class="form-check-label">Funny</label>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<a href="https://vibecoder-lab.dev.flatlogic.app" target="_blank">https://vibecoder-lab.dev.flatlogic.app</a>
|
||||
<div class="form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" data-category="beauty" data-website-number="11"><label class="form-check-label">Beauty</label>
|
||||
<input class="form-check-input" type="checkbox" data-category="funny" data-website-number="11"><label class="form-check-label">Funny</label>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<a href="https://check-grammar.dev.flatlogic.app" target="_blank">https://check-grammar.dev.flatlogic.app</a>
|
||||
<div class="form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" data-category="beauty" data-website-number="12"><label class="form-check-label">Beauty</label>
|
||||
<input class="form-check-input" type="checkbox" data-category="funny" data-website-number="12"><label class="form-check-label">Funny</label>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<a href="https://magicv.dev.flatlogic.app" target="_blank">https://magicv.dev.flatlogic.app</a>
|
||||
<div class="form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" data-category="beauty" data-website-number="13"><label class="form-check-label">Beauty</label>
|
||||
<input class="form-check-input" type="checkbox" data-category="funny" data-website-number="13"><label class="form-check-label">Funny</label>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<a href="https://personal-landing-page.dev.flatlogic.app" target="_blank">https://personal-landing-page.dev.flatlogic.app</a>
|
||||
<div class="form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" data-category="beauty" data-website-number="14"><label class="form-check-label">Beauty</label>
|
||||
<input class="form-check-input" type="checkbox" data-category="funny" data-website-number="14"><label class="form-check-label">Funny</label>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<a href="https://fern.dev.flatlogic.app" target="_blank">https://fern.dev.flatlogic.app</a>
|
||||
<div class="form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" data-category="beauty" data-website-number="15"><label class="form-check-label">Beauty</label>
|
||||
<input class="form-check-input" type="checkbox" data-category="funny" data-website-number="15"><label class="form-check-label">Funny</label>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<a href="https://todo.dev.flatlogic.app" target="_blank">https://todo.dev.flatlogic.app</a>
|
||||
<div class="form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" data-category="beauty" data-website-number="16"><label class="form-check-label">Beauty</label>
|
||||
<input class="form-check-input" type="checkbox" data-category="funny" data-website-number="16"><label class="form-check-label">Funny</label>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<a href="https://hirebridge.dev.flatlogic.app" target="_blank">https://hirebridge.dev.flatlogic.app</a>
|
||||
<div class="form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" data-category="beauty" data-website-number="17"><label class="form-check-label">Beauty</label>
|
||||
<input class="form-check-input" type="checkbox" data-category="funny" data-website-number="17"><label class="form-check-label">Funny</label>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<a href="https://ice-cream-shop.dev.flatlogic.app" target="_blank">https://ice-cream-shop.dev.flatlogic.app</a>
|
||||
<div class="form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" data-category="beauty" data-website-number="18"><label class="form-check-label">Beauty</label>
|
||||
<input class="form-check-input" type="checkbox" data-category="funny" data-website-number="18"><label class="form-check-label">Funny</label>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<a href="https://snake.dev.flatlogic.app" target="_blank">https://snake.dev.flatlogic.app</a>
|
||||
<div class="form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" data-category="beauty" data-website-number="19"><label class="form-check-label">Beauty</label>
|
||||
<input class="form-check-input" type="checkbox" data-category="funny" data-website-number="19"><label class="form-check-label">Funny</label>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<a href="https://mindful-garden.dev.flatlogic.app" target="_blank">https://mindful-garden.dev.flatlogic.app</a>
|
||||
<div class="form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" data-category="beauty" data-website-number="20"><label class="form-check-label">Beauty</label>
|
||||
<input class="form-check-input" type="checkbox" data-category="funny" data-website-number="20"><label class="form-check-label">Funny</label>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<a href="https://vm-34034.dev.flatlogic.app" target="_blank">https://vm-34034.dev.flatlogic.app</a>
|
||||
<div class="form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" data-category="beauty" data-website-number="21"><label class="form-check-label">Beauty</label>
|
||||
<input class="form-check-input" type="checkbox" data-category="funny" data-website-number="21"><label class="form-check-label">Funny</label>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<a href="https://memory-flip.dev.flatlogic.app" target="_blank">https://memory-flip.dev.flatlogic.app</a>
|
||||
<div class="form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" data-category="beauty" data-website-number="22"><label class="form-check-label">Beauty</label>
|
||||
<input class="form-check-input" type="checkbox" data-category="funny" data-website-number="22"><label class="form-check-label">Funny</label>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<a href="https://nestboard.dev.flatlogic.app" target="_blank">https://nestboard.dev.flatlogic.app</a>
|
||||
<div class="form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" data-category="beauty" data-website-number="23"><label class="form-check-label">Beauty</label>
|
||||
<input class="form-check-input" type="checkbox" data-category="funny" data-website-number="23"><label class="form-check-label">Funny</label>
|
||||
</div>
|
||||
</li>
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<a href="https://test-web.dev.flatlogic.app" target="_blank">https://test-web.dev.flatlogic.app</a>
|
||||
<div class="form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" data-category="beauty" data-website-number="24"><label class="form-check-label">Beauty</label>
|
||||
<input class="form-check-input" type="checkbox" data-category="funny" data-website-number="24"><label class="form-check-label">Funny</label>
|
||||
</div>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="card mb-4">
|
||||
<img src="https://picsum.photos/seed/beautiful-vote/800/600" class="card-img-top" alt="An aesthetically pleasing abstract design.">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title">Most Beautiful Website</h2>
|
||||
<form id="beautiful-form">
|
||||
<div class="mb-3">
|
||||
<label for="beautiful-name" class="form-label">Your Name</label>
|
||||
<input type="text" class="form-control" id="beautiful-name" name="voter_name" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="website_number_beauty" class="form-label">Selected Websites (up to 3)</label>
|
||||
<input type="text" class="form-control" id="website_number_beauty" name="website_numbers" readonly required>
|
||||
</div>
|
||||
<input type="hidden" name="category" value="beauty">
|
||||
<button type="submit" class="btn btn-primary">Submit Votes</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="card mb-4">
|
||||
<img src="https://picsum.photos/seed/funny-vote/800/600" class="card-img-top" alt="A quirky and amusing abstract design.">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title">Most Funny/Interesting Website</h2>
|
||||
<form id="funny-form">
|
||||
<div class="mb-3">
|
||||
<label for="funny-name" class="form-label">Your Name</label>
|
||||
<input type="text" class="form-control" id="funny-name" name="voter_name" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="website_number_funny" class="form-label">Selected Websites (up to 3)</label>
|
||||
<input type="text" class="form-control" id="website_number_funny" name="website_numbers" readonly required>
|
||||
</div>
|
||||
<input type="hidden" name="category" value="funny">
|
||||
<button type="submit" class="btn btn-secondary">Submit Votes</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer class="text-center py-4 mt-5">
|
||||
<p><a href="results.php">View Results</a></p>
|
||||
<p>© 2025 Flatlogic. All rights reserved.</p>
|
||||
</footer>
|
||||
|
||||
<div class="toast-container position-fixed bottom-0 end-0 p-3">
|
||||
<div id="liveToast" class="toast" role="alert" aria-live="assertive" aria-atomic="true">
|
||||
<div class="toast-header">
|
||||
<strong class="me-auto">Notification</strong>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="toast-body">
|
||||
Your votes have been submitted successfully!
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<footer>
|
||||
Page updated: <?= htmlspecialchars($now) ?> (UTC)
|
||||
</footer>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
||||
</body>
|
||||
</html>
|
||||
179
results.php
Normal file
179
results.php
Normal file
@ -0,0 +1,179 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
// Hardcoded password for demonstration
|
||||
$password = 'flatlogic1863'; // Replace with a secure password management
|
||||
$error = '';
|
||||
$message = '';
|
||||
|
||||
// Handle login
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['password'])) {
|
||||
if ($_POST['password'] === $password) {
|
||||
$_SESSION['loggedin'] = true;
|
||||
header('Location: results.php'); // Redirect to avoid form resubmission
|
||||
exit;
|
||||
} else {
|
||||
$error = 'Invalid password';
|
||||
}
|
||||
}
|
||||
|
||||
// Handle cleanup
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['cleanup'])) {
|
||||
if (isset($_SESSION['loggedin']) && $_SESSION['loggedin']) {
|
||||
require_once 'db/config.php';
|
||||
$pdo = db();
|
||||
$pdo->exec('TRUNCATE TABLE votes');
|
||||
$message = 'All votes have been cleared.';
|
||||
} else {
|
||||
// Optional: handle unauthorized cleanup attempt
|
||||
}
|
||||
}
|
||||
|
||||
// Handle logout
|
||||
if (isset($_GET['logout'])) {
|
||||
session_destroy();
|
||||
header('Location: results.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
$is_loggedin = isset($_SESSION['loggedin']) && $_SESSION['loggedin'];
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Voting Results</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container mt-5">
|
||||
<?php if ($is_loggedin): ?>
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1 class="mb-0">Voting Results</h1>
|
||||
<a href="results.php?logout=true" class="btn btn-secondary">Logout</a>
|
||||
</div>
|
||||
|
||||
<?php if ($message): ?>
|
||||
<div class="alert alert-success"><?php echo $message; ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title">Most Beautiful Website</h2>
|
||||
<?php
|
||||
require_once 'db/config.php';
|
||||
$pdo = db();
|
||||
$stmt = $pdo->query("SELECT website_number, COUNT(*) as votes FROM votes WHERE category = 'beauty' GROUP BY website_number ORDER BY votes DESC");
|
||||
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
if (empty($results)):
|
||||
echo "<p>No votes yet for this category.</p>";
|
||||
else:
|
||||
?>
|
||||
<ul class="list-group list-group-flush">
|
||||
<?php foreach ($results as $row): ?>
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
Website <?php echo htmlspecialchars($row['website_number']); ?>
|
||||
<span class="badge bg-primary rounded-pill"><?php echo htmlspecialchars($row['votes']); ?> votes</span>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title">Most Funny/Interesting Website</h2>
|
||||
<?php
|
||||
$stmt = $pdo->query("SELECT website_number, COUNT(*) as votes FROM votes WHERE category = 'funny' GROUP BY website_number ORDER BY votes DESC");
|
||||
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
if (empty($results)):
|
||||
echo "<p>No votes yet for this category.</p>";
|
||||
else:
|
||||
?>
|
||||
<ul class="list-group list-group-flush">
|
||||
<?php foreach ($results as $row): ?>
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
Website <?php echo htmlspecialchars($row['website_number']); ?>
|
||||
<span class="badge bg-primary rounded-pill"><?php echo htmlspecialchars($row['votes']); ?> votes</span>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card mt-4">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title">Raw Votes</h2>
|
||||
<?php
|
||||
$stmt = $pdo->query("SELECT id, voter_name, category, website_number, created_at FROM votes ORDER BY created_at DESC");
|
||||
$raw_votes = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
if (empty($raw_votes)):
|
||||
echo "<p>No votes have been cast yet.</p>";
|
||||
else:
|
||||
?>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Voter Name</th>
|
||||
<th>Category</th>
|
||||
<th>Website Number</th>
|
||||
<th>Timestamp</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($raw_votes as $vote): ?>
|
||||
<tr>
|
||||
<td><?php echo htmlspecialchars($vote['id']); ?></td>
|
||||
<td><?php echo htmlspecialchars($vote['voter_name']); ?></td>
|
||||
<td><?php echo htmlspecialchars($vote['category']); ?></td>
|
||||
<td><?php echo htmlspecialchars($vote['website_number']); ?></td>
|
||||
<td><?php echo htmlspecialchars($vote['created_at']); ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4">
|
||||
<form method="POST" onsubmit="return confirm('Are you sure you want to delete all votes?');">
|
||||
<button type="submit" name="cleanup" value="true" class="btn btn-danger">Clear All Votes</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<?php else: ?>
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h1 class="card-title text-center">View Results</h1>
|
||||
<p class="text-center text-muted">You must be logged in to see the voting results.</p>
|
||||
<form method="POST">
|
||||
<div class="mb-3">
|
||||
<label for="password" class="form-label">Password</label>
|
||||
<input type="password" name="password" id="password" class="form-control" required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary w-100">Login</button>
|
||||
<?php if ($error): ?>
|
||||
<p class="text-danger mt-2 text-center"><?php echo $error; ?></p>
|
||||
<?php endif; ?>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
57
submit_vote.php
Normal file
57
submit_vote.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
require_once 'db/config.php';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Create table if it doesn't exist
|
||||
try {
|
||||
$pdo = db();
|
||||
$sql = "
|
||||
CREATE TABLE IF NOT EXISTS votes (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
voter_name VARCHAR(255) NOT NULL,
|
||||
category VARCHAR(50) NOT NULL,
|
||||
website_number INT NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);";
|
||||
$pdo->exec($sql);
|
||||
} catch (PDOException $e) {
|
||||
echo json_encode(['success' => false, 'error' => 'Database error: ' . $e->getMessage()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
|
||||
if (!$data) {
|
||||
echo json_encode(['success' => false, 'error' => 'Invalid input']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$voterName = $data['voter_name'] ?? '';
|
||||
$category = $data['category'] ?? '';
|
||||
$website_numbers_str = $data['website_numbers'] ?? '';
|
||||
$website_numbers = !empty($website_numbers_str) ? array_map('trim', explode(',', $website_numbers_str)) : [];
|
||||
|
||||
if (empty($voterName) || empty($category) || !in_array($category, ['beauty', 'funny'])) {
|
||||
echo json_encode(['success' => false, 'error' => 'Invalid data provided.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
$pdo = db();
|
||||
$stmt = $pdo->prepare("INSERT INTO votes (voter_name, category, website_number) VALUES (:voter_name, :category, :website_number)");
|
||||
|
||||
foreach ($website_numbers as $number) {
|
||||
if ($number >= 1 && $number <= 30) {
|
||||
$stmt->execute([
|
||||
':voter_name' => $voterName,
|
||||
':category' => $category,
|
||||
':website_number' => $number
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode(['success' => true]);
|
||||
} catch (PDOException $e) {
|
||||
echo json_encode(['success' => false, 'error' => 'Database error: ' . $e->getMessage()]);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user