Auto commit: 2025-09-30T13:07:05.495Z
This commit is contained in:
parent
a02383af1b
commit
e0029497ac
58
api/chat.php
Normal file
58
api/chat.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?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]);
|
||||
171
assets/css/custom.css
Normal file
171
assets/css/custom.css
Normal file
@ -0,0 +1,171 @@
|
||||
|
||||
<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>
|
||||
64
assets/js/main.js
Normal file
64
assets/js/main.js
Normal file
@ -0,0 +1,64 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -1,17 +1,43 @@
|
||||
<?php
|
||||
// Generated by setup_mariadb_project.sh — edit as needed.
|
||||
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');
|
||||
function db_connect() {
|
||||
static $pdoconn;
|
||||
|
||||
function db() {
|
||||
static $pdo;
|
||||
if (!$pdo) {
|
||||
$pdo = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8mb4', DB_USER, DB_PASS, [
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
||||
]);
|
||||
}
|
||||
return $pdo;
|
||||
if ($pdoconn) {
|
||||
return $pdoconn;
|
||||
}
|
||||
|
||||
$config = [
|
||||
'host' => '127.0.0.1',
|
||||
'dbname' => 'app',
|
||||
'user' => 'app',
|
||||
'password' => 'app'
|
||||
];
|
||||
|
||||
$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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
6
db/migrations/001_create_messages_table.sql
Normal file
6
db/migrations/001_create_messages_table.sql
Normal file
@ -0,0 +1,6 @@
|
||||
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
|
||||
);
|
||||
177
index.php
177
index.php
@ -1,131 +1,62 @@
|
||||
<?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');
|
||||
require_once __DIR__ . '/db/config.php';
|
||||
run_migrations();
|
||||
?>
|
||||
<!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">
|
||||
|
||||
<!-- SEO & Meta Tags -->
|
||||
<title>EvolveX - AI Guide</title>
|
||||
<meta name="description" content="Chat with the EvolveX AI guide to explore tutorials on AI, coding, productivity, and more. Built with Flatlogic Generator.">
|
||||
<meta name="keywords" content="ai chatbot, php chatbot, learn ai, coding tutorials, productivity hacks, digital marketing, cybersecurity training, wellness skills, entrepreneurship guide, Flatlogic">
|
||||
|
||||
<!-- Open Graph / Facebook -->
|
||||
<meta property="og:type" content="website">
|
||||
<meta property="og:title" content="EvolveX - AI Guide">
|
||||
<meta property="og:description" content="Chat with the EvolveX AI guide to explore tutorials on AI, coding, productivity, and more.">
|
||||
<meta property="og:image" content="">
|
||||
|
||||
<!-- Twitter -->
|
||||
<meta property="twitter:card" content="summary_large_image">
|
||||
<meta property="twitter:title" content="EvolveX - AI Guide">
|
||||
<meta property="twitter:description" content="Chat with the EvolveX AI guide to explore tutorials on AI, coding, productivity, and more.">
|
||||
<meta property="twitter:image" content="">
|
||||
|
||||
<!-- Styles -->
|
||||
<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?v=<?php echo time(); ?>">
|
||||
|
||||
</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"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWiZZy' : '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>
|
||||
|
||||
<div class="chat-container">
|
||||
<header class="main-header">
|
||||
<h1>EvolveX AI Guide</h1>
|
||||
</header>
|
||||
|
||||
<div class="messages">
|
||||
<div class="message bot">
|
||||
<div class="message-content">
|
||||
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>
|
||||
</main>
|
||||
<footer>
|
||||
Page updated: <?= htmlspecialchars($now) ?> (UTC)
|
||||
</footer>
|
||||
|
||||
<footer class="main-footer">
|
||||
Built with Flatlogic Generator
|
||||
</footer>
|
||||
|
||||
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
Loading…
x
Reference in New Issue
Block a user