Compare commits

..

No commits in common. "ai-dev" and "master" have entirely different histories.

7 changed files with 140 additions and 369 deletions

View File

@ -1,47 +0,0 @@
body {
background-color: #FFFFFF;
font-family: 'Poppins', sans-serif;
}
.navbar {
border-bottom: 1px solid #eee;
}
.delulu-card {
background-color: #F8F9FA;
border: none;
border-radius: 1rem;
transition: all 0.2s ease-in-out;
}
.delulu-card:hover {
transform: translateY(-5px);
box-shadow: 0 4px 20px rgba(0,0,0,0.05);
}
.card-title {
color: #A076F9;
font-weight: bold;
}
.card-subtitle {
color: #74C0FC;
}
.btn-primary {
background-color: #A076F9;
border-color: #A076F9;
}
.btn-primary:hover {
background-color: #74C0FC;
border-color: #74C0FC;
}
.gradient-bg {
background: linear-gradient(135deg, #A076F9, #74C0FC);
color: white;
padding: 4rem 2rem;
border-radius: 1rem;
margin-bottom: 2rem;
}

View File

@ -1,62 +0,0 @@
<?php
session_start();
header('Content-Type: application/json');
require __DIR__ . '/vendor/autoload.php'; // Composer Autoloader
use Kreait\Firebase\Factory;
use Kreait\Firebase\Exception\Auth\InvalidToken;
$response = ['status' => 'error', 'message' => 'Invalid request'];
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$input = json_decode(file_get_contents('php://input'), true);
$action = $input['action'] ?? '';
$idToken = $input['idToken'] ?? '';
// Initialize Firebase Admin SDK
// IMPORTANT: Replace 'path/to/your/serviceAccountKey.json' with the actual path to your Firebase service account key file.
// This file contains your project's credentials and should be kept secure.
// You can download it from Firebase Console -> Project settings -> Service accounts -> Generate new private key.
try {
$factory = (new Factory())->withServiceAccount(__DIR__ . '/firebase-service-account.json');
$auth = $factory->createAuth();
} catch (\Exception $e) {
error_log('Firebase Admin SDK initialization error: ' . $e->getMessage());
$response = ['status' => 'error', 'message' => 'Server configuration error.'];
echo json_encode($response);
exit;
}
if ($action === 'signin' && !empty($idToken)) {
try {
$verifiedIdToken = $auth->verifyIdToken($idToken);
$uid = $verifiedIdToken->claims()->get('sub');
$email = $verifiedIdToken->claims()->get('email');
$displayName = $verifiedIdToken->claims()->get('name');
$_SESSION['user_id'] = $uid;
$_SESSION['user_email'] = $email;
$_SESSION['user_name'] = $displayName;
$_SESSION['is_logged_in'] = true;
$response = ['status' => 'success', 'message' => 'Sign-in successful.', 'user' => ['uid' => $uid, 'email' => $email, 'name' => $displayName]];
} catch (InvalidToken $e) {
$response = ['status' => 'error', 'message' => 'Invalid Firebase ID token.'];
error_log('Firebase ID token verification failed: ' . $e->getMessage());
} catch (\Exception $e) {
$response = ['status' => 'error', 'message' => 'Authentication failed.'];
error_log('General authentication error: ' . $e->getMessage());
}
} else if ($action === 'signout') {
session_unset();
session_destroy();
$response = ['status' => 'success', 'message' => 'Sign-out successful. Session destroyed.'];
}
}
echo json_encode($response);
?>

View File

@ -1,7 +0,0 @@
CREATE TABLE IF NOT EXISTS delulus (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(255) NOT NULL,
title VARCHAR(255) NOT NULL,
body TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

View File

@ -1,34 +0,0 @@
<?php
require_once __DIR__ . '/../db/config.php';
$delulus = [
[
'username' => 'DreamyDolphin',
'title' => 'Manifesting a trip to Japan',
'body' => 'I can already taste the ramen and see the cherry blossoms. My bags are packed (in my head).'
],
[
'username' => 'CosmicCat',
'title' => 'My cat is secretly a world-renowned philosopher',
'body' => 'He just sits there, judging my life choices. I am sure he is pondering the meaning of existence.'
],
[
'username' => 'StarlightSailor',
'title' => 'I am the main character',
'body' => 'The world is my movie, and I am just waiting for the plot twist. It is going to be epic.'
],
[
'username' => 'MoonbeamMoth',
'title' => 'My plants are my therapists',
'body' => 'They listen to all my problems and never talk back. Best therapy session ever.'
],
];
$pdo = db();
$stmt = $pdo->prepare('INSERT INTO delulus (username, title, body) VALUES (?, ?, ?)');
foreach ($delulus as $delulu) {
$stmt->execute([$delulu['username'], $delulu['title'], $delulu['body']]);
}
echo 'Database seeded successfully!';

View File

@ -1,29 +0,0 @@
{ "type": "service_account", "project_id": "dululu-fe617", "private_key_id": "f994dbe9213123675911cb1556e73579f9a2d5b0", "private_key": "-----BEGIN PRIVATE KEY-----
MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDIakeW+EiZZZXx
sbJ2NTkXDk6zbiyUHb3XGsVzfgaTVRIjltV6aFJLKa9qz/hHvUAZn0sr0o95gz+8
B1bBLVTABS54Sx1flhcCbVIFCZ9s25yDbV2OvL22QG1RjrhUoTMwvLaAW43kud77
OzS3tlL4pDiv+77jE17fC96VfTlmpRzpIJWdEdMN87UZlsnSdXh7Gp0U0+s6bnTv
5YuB5L38dxPYcsze7s/cbcm1S5sW1eCDWmlX+V4l77AgzJ4RzMoRxGqoN5tykzHR
wRnaX+yu60SkN4rXgubfZdIkTI1+hpsxJtSt5P/etJ/4dxwpyAFZStbAk1EQ0rzu
WZ9Ce+kDAgMBAAECggEABteJb7SiWwCRnBvKQ4z6UMGvf/3y9zmFkGgF7FmoAIai
d0Bt6pYZk/oI+0ThmxQ6saCqMKoEx8KzhvXam5FE01kVXYxjgGWI1yHfAb1y3Bcq
Yn8aiVhMVW/YECLv+ejNf17OfaAHGdxkBS4WniWJ8yyq7MMc6dIVQf1hiACG6sgI
7Mf+ojrtRfKu/H4I6bxsN8OM52qrk0ECFkR+hxwo5TG7XA9AdoG2nsGUyjG5jBaj
pLec9qOo1ohBFx4wojr4r6SPnttMm74BMWH65huS+bfBSoXhTDZMBMNz6TRmjf7o
+/2qLRAMxxAbYyy5JWZSZZNA3aZT347mMwxAczMniQKBgQDn+Q1KLuV7lI3E/Fy6
EktNR+DPfB/3bTA/9Ssuh7cbTvDBOE/EeS9ETppSvlqh5+JycVhK5GSYi62CFQE4
2TI/iGv962X1Iw1fRLpSMJQ7caHC8Uj0qdGrU0Bz8D/Ct7oD4J9orLvC4iEOYL5K
6nrX3Pp4yeVBJoME5hSE4wvVCQKBgQDdLHMdicyDkr05VNt8vwoQC3Er9Nw+5zDM
DHADXaEX8W1Qz3xxHKNCsi48ZhMoVGsvgb5SAo9t7RraqhJZKsFB8rDAfqo8WBl7
TTeWyZM1QX0WIt1pTo2MPWUlT155o73O/dfMuKIkWUdSOGvdjL5OetNcaeVTIlir
4p94mpK8qwKBgHJcKL4aso2jJeUoGLquzCrUNbN0WPoM/U16m4g75fxzhWNsVH7i
03eUXKZQK7RH8i5DTKjXQfSmX6qSmmChSxFhOwQaadBZMH14D3b3dgx8L6hAdZwQ
oEobJ9pAZd6j3vOMaGodRg+ElZFWBlo+kMMcsOqddgURbGQc3Z7JpAqpAoGARawr
80EmeMgv7bCKl+iCXf2MwCEZhINFvvGoE5daGPXHzu4dsHAqCeehYwtwu4KkZUnE
z4bY8fMAQ6PRtd8fFAxEm88LB4llNY9klI6ZXexpilOfVf4V3vi0NSWkiEMJlvwm
D+qVwUeSjRcS+67LgGN206TURfUK49K3E8H1uZMCgYBRXJd64BKViLPUFUJBdmz8
NHKrnGQiVo57NLx/eXvvvI3/Yd3AGkUdapgkT2sCTHh9aoczgHXcjmlIcho1Q5Jz
0fkUZkjFwuSn5XjPyVDipHA46M+UqHXZ7E88TNisXTzZApj2YhlgUQNQfR8wCDup
Ccwcz12GqS1ZWpK9SoWAFw==
-----END PRIVATE KEY-----
", "client_email": "firebase-adminsdk-fbsvc @dululu-fe617.iam.gserviceaccount.com", "client_id": "104495485400716482072", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "token_uri": "https://oauth2.googleapis.com/token", "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-fbsvc%40dululu-fe617.iam.gserviceaccount.com", "universe_domain": "googleapis.com" }

View File

@ -1,15 +0,0 @@
<?php
// firebase_config.php
// This file will hold your Firebase project configuration.
// You need to replace the placeholder values with your actual Firebase project settings.
// You can find these values in your Firebase project console under Project settings -> General -> Your apps.
return [
'apiKey' => 'AIzaSyCwEATlIVGKEvm-Ph1oH0-fOySmx7hBYkg',
'authDomain' => 'dululu-fe617.firebaseapp.com',
'projectId' => 'dululu-fe617',
'storageBucket' => 'dululu-fe617.firebasestorage.app',
'messagingSenderId' => '553086833572',
'appId' => '1:553086833572:web:2536751230886bd8552731',
'measurementId' => 'G-5DJ9LXGSZZ' // Optional, if you use Google Analytics for Firebase
];

313
index.php
View File

@ -1,185 +1,150 @@
<?php <?php
declare(strict_types=1); declare(strict_types=1);
require_once __DIR__ . '/db/config.php'; @ini_set('display_errors', '1');
require_once __DIR__ . '/includes/firebase_config.php'; @error_reporting(E_ALL);
@date_default_timezone_set('UTC');
$firebaseConfig = require __DIR__ . '/includes/firebase_config.php'; $phpVersion = PHP_VERSION;
$now = date('Y-m-d H:i:s');
$delulus = [];
try {
$pdo = db();
$stmt = $pdo->query('SELECT username, title, body, created_at FROM delulus ORDER BY created_at DESC');
$delulus = $stmt->fetchAll();
} catch (PDOException $e) {
// For now, we just show an error. In a real app, you'd log this.
error_log($e->getMessage());
}
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'A playful social space where imagination meets validation.';
$projectTitle = 'Delulu is the New Sululu';
?> ?>
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<title><?= htmlspecialchars($projectTitle) ?></title> <title>New Style</title>
<?php
<meta name="description" content="<?= htmlspecialchars($projectDescription) ?>" /> // Read project preview data from environment
<meta property="og:title" content="<?= htmlspecialchars($projectTitle) ?>" /> $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" /> $projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
<meta property="twitter:card" content="summary_large_image" /> ?>
<meta property="twitter:title" content="<?= htmlspecialchars($projectTitle) ?>" /> <?php if ($projectDescription): ?>
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" /> <!-- Meta description -->
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
<?php if (!empty($_SERVER['PROJECT_IMAGE_URL'])): ?> <!-- Open Graph meta tags -->
<meta property="og:image" content="<?= htmlspecialchars($_SERVER['PROJECT_IMAGE_URL']) ?>" /> <meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
<meta property="twitter:image" content="<?= htmlspecialchars($_SERVER['PROJECT_IMAGE_URL']) ?>" /> <!-- Twitter meta tags -->
<?php endif; ?> <meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
<?php endif; ?>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet"> <?php if ($projectImageUrl): ?>
<link rel="preconnect" href="https://fonts.googleapis.com"> <!-- Open Graph image -->
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap" rel="stylesheet"> <!-- Twitter image -->
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>"> <meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
<?php endif; ?>
<script type="module"> <link rel="preconnect" href="https://fonts.googleapis.com">
// Import the functions you need from the SDKs you need <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.12.2/firebase-app.js"; <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
import { getAuth, GoogleAuthProvider, signInWithPopup, signOut, onAuthStateChanged } from "https://www.gstatic.com/firebasejs/10.12.2/firebase-auth.js"; <style>
// TODO: Add SDKs for Firebase products that you want to use :root {
// https://firebase.google.com/docs/web/setup#available-libraries --bg-color-start: #6a11cb;
--bg-color-end: #2575fc;
// Your web app's Firebase configuration --text-color: #ffffff;
const firebaseConfig = <?= json_encode($firebaseConfig) ?>; --card-bg-color: rgba(255, 255, 255, 0.01);
--card-border-color: rgba(255, 255, 255, 0.1);
// Initialize Firebase }
const app = initializeApp(firebaseConfig); body {
const auth = getAuth(app); margin: 0;
const provider = new GoogleAuthProvider(); font-family: 'Inter', sans-serif;
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
const authUi = document.getElementById('auth-ui'); color: var(--text-color);
const signInButton = document.getElementById('signInButton'); display: flex;
justify-content: center;
// Update UI based on auth state align-items: center;
onAuthStateChanged(auth, (user) => { min-height: 100vh;
if (user) { text-align: center;
// User is signed in overflow: hidden;
authUi.innerHTML = ` position: relative;
<span class="navbar-text me-3">Welcome, \${user.displayName}</span> }
<button id="signOutButton" class="btn btn-outline-danger">Sign Out</button> body::before {
`; content: '';
document.getElementById('signOutButton').addEventListener('click', () => { position: absolute;
signOut(auth).then(() => { top: 0;
// Sign-out successful. left: 0;
console.log('User signed out'); width: 100%;
}).catch((error) => { height: 100%;
// An error happened. 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>');
console.error('Sign out error:', error); animation: bg-pan 20s linear infinite;
}); z-index: -1;
}); }
// After successful sign-in, send ID token to backend for session management @keyframes bg-pan {
user.getIdToken().then(idToken => { 0% { background-position: 0% 0%; }
fetch('auth.php', { 100% { background-position: 100% 100%; }
method: 'POST', }
headers: { main {
'Content-Type': 'application/json', padding: 2rem;
}, }
body: JSON.stringify({ idToken: idToken, action: 'signin' }), .card {
}) background: var(--card-bg-color);
.then(response => response.json()) border: 1px solid var(--card-border-color);
.then(data => { border-radius: 16px;
if (data.status === 'success') { padding: 2rem;
console.log('Backend session established:', data.message); backdrop-filter: blur(20px);
} else { -webkit-backdrop-filter: blur(20px);
console.error('Backend session error:', data.message); box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
} }
}) .loader {
.catch(error => { margin: 1.25rem auto 1.25rem;
console.error('Error sending token to backend:', error); width: 48px;
}); height: 48px;
}); border: 3px solid rgba(255, 255, 255, 0.25);
border-top-color: #fff;
} else { border-radius: 50%;
// User is signed out animation: spin 1s linear infinite;
authUi.innerHTML = `<button id="signInButton" class="btn btn-primary">Sign in with Google</button>`; }
document.getElementById('signInButton').addEventListener('click', () => { @keyframes spin {
signInWithPopup(auth, provider) from { transform: rotate(0deg); }
.then((result) => { to { transform: rotate(360deg); }
// This gives you a Google Access Token. You can use it to access the Google API. }
const credential = GoogleAuthProvider.credentialFromResult(result); .hint {
const token = credential.accessToken; opacity: 0.9;
// The signed-in user info. }
const user = result.user; .sr-only {
console.log('User signed in:', user.displayName); position: absolute;
}).catch((error) => { width: 1px; height: 1px;
// Handle Errors here. padding: 0; margin: -1px;
const errorCode = error.code; overflow: hidden;
const errorMessage = error.message; clip: rect(0, 0, 0, 0);
// The email of the user's account used. white-space: nowrap; border: 0;
const email = error.customData.email; }
// The AuthCredential type that was used. h1 {
const credential = GoogleAuthProvider.credentialFromError(error); font-size: 3rem;
console.error('Sign-in error:', errorMessage); font-weight: 700;
}); margin: 0 0 1rem;
}); letter-spacing: -1px;
} }
}); p {
</script> 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>
</head> </head>
<body> <body>
<main>
<nav class="navbar navbar-expand-lg navbar-light bg-white"> <div class="card">
<div class="container"> <h1>Analyzing your requirements and generating your website…</h1>
<a class="navbar-brand" href="#" style="color: #A076F9; font-weight: bold;"><?= htmlspecialchars($projectTitle) ?></a> <div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"> <span class="sr-only">Loading…</span>
<span class="navbar-toggler-icon"></span> </div>
</button> <p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p>
<div class="collapse navbar-collapse" id="navbarNav"> <p class="hint">This page will update automatically as the plan is implemented.</p>
<ul class="navbar-nav ms-auto"> <p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
<li class="nav-item" id="auth-ui"> </div>
<!-- Authentication UI will be rendered here --> </main>
<button id="signInButton" class="btn btn-primary">Sign in with Google</button> <footer>
</li> Page updated: <?= htmlspecialchars($now) ?> (UTC)
</ul> </footer>
</div>
</div>
</nav>
<main class="container my-5">
<div class="text-center gradient-bg">
<h1 class="display-4">Welcome to the Delulu Space</h1>
<p class="lead">Share your dreams, manifest your future, and find your sululu.</p>
</div>
<div class="row">
<?php if (empty($delulus)): ?>
<div class="col">
<div class="alert alert-info">No delulus posted yet. Be the first!</div>
</div>
<?php else: ?>
<?php foreach ($delulus as $delulu): ?>
<div class="col-md-6 col-lg-4 mb-4">
<div class="card delulu-card h-100">
<div class="card-body">
<h5 class="card-title"><?= htmlspecialchars($delulu['title']) ?></h5>
<h6 class="card-subtitle mb-2 text-muted">@<?= htmlspecialchars($delulu['username']) ?></h6>
<p class="card-text"><?= nl2br(htmlspecialchars(substr($delulu['body'], 0, 100))) . (strlen($delulu['body']) > 100 ? '...' : '') ?></p>
</div>
<div class="card-footer bg-transparent border-0 text-end">
<small class="text-muted"><?= date('M j, Y', strtotime($delulu['created_at'])) ?></small>
</div>
</div>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
</main>
<footer class="text-center py-4">
<p>&copy; <?= date('Y') ?> <?= htmlspecialchars($projectTitle) ?>. All rights reserved.</p>
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body> </body>
</html> </html>