Compare commits

..

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

6 changed files with 137 additions and 393 deletions

View File

@ -1,58 +0,0 @@
<?php
header('Content-Type: application/json');
require_once __DIR__ . '/../db/config.php';
// Basic validation
if (!isset($_POST['message']) || empty(trim($_POST['message']))) {
echo json_encode(['error' => 'Message is required.']);
http_response_code(400);
exit;
}
$userMessage = trim($_POST['message']);
$botReply = '';
// Simple rule-based responses
$lowerMessage = strtolower($userMessage);
if (str_contains($lowerMessage, 'hello') || str_contains($lowerMessage, 'hi')) {
$botReply = 'Hi there! I am the EvolveX guide. Ask me about our categories like AI, coding, or wellness.';
} elseif (str_contains($lowerMessage, 'money')) {
$botReply = 'Money management is key to financial freedom. Our tutorials cover budgeting, investing, and saving strategies.';
} elseif (str_contains($lowerMessage, 'ai') || str_contains($lowerMessage, 'artificial intelligence')) {
$botReply = 'Artificial Intelligence is transforming the world. We have tutorials on machine learning, neural networks, and AI ethics.';
} elseif (str_contains($lowerMessage, 'code') || str_contains($lowerMessage, 'coding')) {
$botReply = 'Our coding tutorials focus on future-relevant skills, including Python, JavaScript, and smart contract development.';
} elseif (str_contains($lowerMessage, 'productivity')) {
$botReply = 'Boost your efficiency! Our productivity section covers tools, techniques, and workflows to help you achieve more.';
} elseif (str_contains($lowerMessage, 'marketing')) {
$botReply = 'Digital marketing is always evolving. Learn about SEO, content marketing, and social media strategies with us.';
} elseif (str_contains($lowerMessage, 'cybersecurity')) {
$botReply = 'Protecting digital assets is crucial. Our cybersecurity path covers network security, ethical hacking, and data protection.';
} elseif (str_contains($lowerMessage, 'wellness') || str_contains($lowerMessage, 'skills')) {
$botReply = 'Invest in yourself. We cover everything from mindfulness and mental health to learning new practical skills for personal growth.';
} elseif (str_contains($lowerMessage, 'entrepreneurship')) {
$botReply = 'Ready to build something new? Our entrepreneurship guides cover business planning, fundraising, and scaling your venture.';
} else {
$botReply = 'That is a great question. While I am still in training, EvolveX offers a wide range of tutorials on AI, coding, wellness, and more. Which category interests you most?';
}
try {
$pdo = db_connect();
// Save user message
$stmt = $pdo->prepare("INSERT INTO messages (role, content) VALUES (?, ?)");
$stmt->execute(['user', $userMessage]);
// Save bot reply
$stmt = $pdo->prepare("INSERT INTO messages (role, content) VALUES (?, ?)");
$stmt->execute(['bot', $botReply]);
} catch (PDOException $e) {
// In a real app, you would log this error. For this stub, we'll ignore it so the chat still works.
// http_response_code(500);
// echo json_encode(['error' => 'Database error.']);
// exit;
}
echo json_encode(['reply' => $botReply]);

View File

@ -1,171 +0,0 @@
<style>
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
:root {
--background: #111827;
--surface: rgba(31, 41, 55, 0.5);
--primary: #38BDF8;
--text-primary: #F9FAFB;
--text-secondary: #9CA3AF;
--user-msg-bg: #374151;
--bot-msg-bg: #1F2937;
--border-color: rgba(55, 65, 81, 0.6);
}
body {
background-color: var(--background);
color: var(--text-primary);
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
margin: 0;
display: flex;
flex-direction: column;
height: 100vh;
overflow: hidden;
}
.chat-container {
display: flex;
flex-direction: column;
flex-grow: 1;
max-width: 800px;
width: 100%;
margin: 0 auto;
padding: 1rem;
}
header.main-header {
text-align: center;
padding: 1rem;
border-bottom: 1px solid var(--border-color);
}
header.main-header h1 {
font-size: 1.5rem;
font-weight: 700;
color: var(--primary);
margin: 0;
}
.messages {
flex-grow: 1;
overflow-y: auto;
padding: 1rem 0;
display: flex;
flex-direction: column;
gap: 1rem;
}
.message {
display: flex;
align-items: flex-end;
gap: 0.5rem;
max-width: 85%;
animation: fadeIn 0.3s ease-in-out;
}
.message-content {
padding: 0.75rem 1rem;
border-radius: 12px;
line-height: 1.5;
}
.message.user {
align-self: flex-end;
}
.message.user .message-content {
background-color: var(--user-msg-bg);
border-bottom-right-radius: 4px;
}
.message.bot {
align-self: flex-start;
}
.message.bot .message-content {
background-color: var(--bot-msg-bg);
border-bottom-left-radius: 4px;
}
.message.typing {
align-self: flex-start;
color: var(--text-secondary);
font-style: italic;
}
.message-form {
display: flex;
gap: 0.5rem;
padding: 1rem 0;
border-top: 1px solid var(--border-color);
}
.message-form-wrapper {
background: var(--surface);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
border: 1px solid var(--border-color);
border-radius: 12px;
padding: 0.5rem 1rem;
flex-grow: 1;
display: flex;
align-items: center;
}
#message-input {
background: transparent;
border: none;
outline: none;
color: var(--text-primary);
flex-grow: 1;
font-size: 1rem;
}
#message-input::placeholder {
color: var(--text-secondary);
}
button.send-btn {
background-color: var(--primary);
color: var(--background);
border: none;
border-radius: 8px;
padding: 0.5rem 1rem;
font-size: 1rem;
font-weight: 600;
cursor: pointer;
transition: background-color 0.2s;
}
button.send-btn:hover {
background-color: #7dd3fc; /* Lighter sky blue */
}
footer.main-footer {
text-align: center;
padding: 1rem;
color: var(--text-secondary);
font-size: 0.875rem;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
/* Scrollbar styles */
::-webkit-scrollbar {
width: 8px;
}
::-webkit-scrollbar-track {
background: transparent;
}
::-webkit-scrollbar-thumb {
background: #2d3748;
border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
background: #4a5568;
}
</style>

View File

@ -1,64 +0,0 @@
document.addEventListener('DOMContentLoaded', () => {
const chatForm = document.getElementById('chat-form');
const messageInput = document.getElementById('message-input');
const messagesContainer = document.querySelector('.messages');
chatForm.addEventListener('submit', (e) => {
e.preventDefault();
const messageText = messageInput.value.trim();
if (messageText === '') return;
appendMessage('user', messageText);
messageInput.value = '';
showTypingIndicator();
fetch('/api/chat.php', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: `message=${encodeURIComponent(messageText)}`
})
.then(response => response.json())
.then(data => {
removeTypingIndicator();
if (data.reply) {
appendMessage('bot', data.reply);
}
})
.catch(error => {
removeTypingIndicator();
appendMessage('bot', 'Sorry, something went wrong. Please try again.');
console.error('Error:', error);
});
});
function appendMessage(role, text) {
const messageElement = document.createElement('div');
messageElement.classList.add('message', role);
const contentElement = document.createElement('div');
contentElement.classList.add('message-content');
contentElement.textContent = text;
messageElement.appendChild(contentElement);
messagesContainer.appendChild(messageElement);
messagesContainer.scrollTop = messagesContainer.scrollHeight;
}
function showTypingIndicator() {
const typingIndicator = document.createElement('div');
typingIndicator.id = 'typing-indicator';
typingIndicator.classList.add('message', 'typing');
typingIndicator.textContent = 'EvolveX is typing...';
messagesContainer.appendChild(typingIndicator);
messagesContainer.scrollTop = messagesContainer.scrollHeight;
}
function removeTypingIndicator() {
const typingIndicator = document.getElementById('typing-indicator');
if (typingIndicator) {
typingIndicator.remove();
}
}
});

View File

@ -1,43 +1,17 @@
<?php <?php
function db_connect() { // Generated by setup_mariadb_project.sh — edit as needed.
static $pdoconn; define('DB_HOST', '127.0.0.1');
define('DB_NAME', 'app_30903');
define('DB_USER', 'app_30903');
define('DB_PASS', '7d2d5a2d-6e5e-4580-a9b7-3f8e7288a494');
if ($pdoconn) { function db() {
return $pdoconn; static $pdo;
} if (!$pdo) {
$pdo = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8mb4', DB_USER, DB_PASS, [
$config = [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
'host' => '127.0.0.1', PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
'dbname' => 'app', ]);
'user' => 'app', }
'password' => 'app' return $pdo;
];
$dsn = "mysql:host={$config['host']};dbname={$config['dbname']};charset=utf8mb4";
$options = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
];
try {
$pdoconn = new PDO($dsn, $config['user'], $config['password'], $options);
return $pdoconn;
} catch (PDOException $e) {
// In a real app, you'd log this error and show a generic message
throw new PDOException($e->getMessage(), (int)$e->getCode());
}
}
function run_migrations() {
$pdo = db_connect();
$migrationsDir = __DIR__ . '/migrations';
$files = glob($migrationsDir . '/*.sql');
sort($files);
foreach ($files as $file) {
$sql = file_get_contents($file);
if ($sql) {
$pdo->exec($sql);
}
}
} }

View File

@ -1,6 +0,0 @@
CREATE TABLE IF NOT EXISTS messages (
id INT AUTO_INCREMENT PRIMARY KEY,
role VARCHAR(20) NOT NULL,
content TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

175
index.php
View File

@ -1,62 +1,131 @@
<?php <?php
require_once __DIR__ . '/db/config.php'; declare(strict_types=1);
run_migrations(); @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"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1" />
<title>New Style</title>
<!-- SEO & Meta Tags --> <link rel="preconnect" href="https://fonts.googleapis.com">
<title>EvolveX - AI Guide</title> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<meta name="description" content="Chat with the EvolveX AI guide to explore tutorials on AI, coding, productivity, and more. Built with Flatlogic Generator."> <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
<meta name="keywords" content="ai chatbot, php chatbot, learn ai, coding tutorials, productivity hacks, digital marketing, cybersecurity training, wellness skills, entrepreneurship guide, Flatlogic"> <style>
:root {
<!-- Open Graph / Facebook --> --bg-color-start: #6a11cb;
<meta property="og:type" content="website"> --bg-color-end: #2575fc;
<meta property="og:title" content="EvolveX - AI Guide"> --text-color: #ffffff;
<meta property="og:description" content="Chat with the EvolveX AI guide to explore tutorials on AI, coding, productivity, and more."> --card-bg-color: rgba(255, 255, 255, 0.01);
<meta property="og:image" content=""> --card-border-color: rgba(255, 255, 255, 0.1);
}
<!-- Twitter --> body {
<meta property="twitter:card" content="summary_large_image"> margin: 0;
<meta property="twitter:title" content="EvolveX - AI Guide"> font-family: 'Inter', sans-serif;
<meta property="twitter:description" content="Chat with the EvolveX AI guide to explore tutorials on AI, coding, productivity, and more."> background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
<meta property="twitter:image" content=""> color: var(--text-color);
display: flex;
<!-- Styles --> justify-content: center;
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet"> align-items: center;
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>"> 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>
</head> </head>
<body> <body>
<main>
<div class="chat-container"> <div class="card">
<header class="main-header"> <h1>Analyzing your requirements and generating your website…</h1>
<h1>EvolveX AI Guide</h1> <div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
</header> <span class="sr-only">Loading…</span>
</div>
<div class="messages"> <p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWiZZy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p>
<div class="message bot"> <p class="hint">This page will update automatically as the plan is implemented.</p>
<div class="message-content"> <p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
Hello! I'm the EvolveX guide. I can help you discover tutorials on money management, AI, coding, and more. What are you interested in learning today?
</div>
</div>
</div>
<form id="chat-form" class="message-form">
<div class="message-form-wrapper">
<input type="text" id="message-input" placeholder="Ask about a category..." autocomplete="off">
</div>
<button type="submit" class="send-btn">Send</button>
</form>
</div> </div>
</main>
<footer class="main-footer"> <footer>
Built with Flatlogic Generator Page updated: <?= htmlspecialchars($now) ?> (UTC)
</footer> </footer>
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
</body> </body>
</html> </html>