38211-vm/db/init.php
2026-02-05 14:21:11 +00:00

102 lines
4.9 KiB
PHP

<?php
require_once __DIR__ . '/config.php';
try {
$pdo = db();
// Contact requests table
$sql = "CREATE TABLE IF NOT EXISTS contact_requests (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL,
type VARCHAR(50) DEFAULT NULL,
message TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
$pdo->exec($sql);
// Projects table for rich content
$sql = "CREATE TABLE IF NOT EXISTS projects (
id INT AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(255) NOT NULL,
slug VARCHAR(255) NOT NULL UNIQUE,
category VARCHAR(100) NOT NULL,
short_description TEXT NOT NULL,
full_content LONGTEXT NOT NULL,
image_url VARCHAR(255) NOT NULL,
client_name VARCHAR(255) DEFAULT NULL,
project_date VARCHAR(50) DEFAULT NULL,
tech_stack TEXT DEFAULT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
$pdo->exec($sql);
// Clear existing projects to ensure we have exactly what we want
$pdo->exec("TRUNCATE TABLE projects");
$categories = ['fintech', 'web', 'app'];
$images = [
'fintech' => [
'https://images.pexels.com/photos/6770610/pexels-photo-6770610.jpeg',
'https://images.pexels.com/photos/6801874/pexels-photo-6801874.jpeg',
'https://images.pexels.com/photos/7567443/pexels-photo-7567443.jpeg',
'https://images.pexels.com/photos/8370752/pexels-photo-8370752.jpeg',
'https://images.pexels.com/photos/6771664/pexels-photo-6771664.jpeg'
],
'web' => [
'https://images.pexels.com/photos/251225/pexels-photo-251225.jpeg',
'https://images.pexels.com/photos/1779487/pexels-photo-1779487.jpeg',
'https://images.pexels.com/photos/326503/pexels-photo-326503.jpeg',
'https://images.pexels.com/photos/1092644/pexels-photo-1092644.jpeg',
'https://images.pexels.com/photos/3183150/pexels-photo-3183150.jpeg'
],
'app' => [
'https://images.pexels.com/photos/1181244/pexels-photo-1181244.jpeg',
'https://images.pexels.com/photos/1181671/pexels-photo-1181671.jpeg',
'https://images.pexels.com/photos/1181263/pexels-photo-1181263.jpeg',
'https://images.pexels.com/photos/3861969/pexels-photo-3861969.jpeg',
'https://images.pexels.com/photos/546819/pexels-photo-546819.jpeg'
]
];
$titles = [
'fintech' => [
'Global Payments Gateway', 'Crypto Asset Manager', 'Algo Trading Terminal', 'Risk Assessment Engine',
'DeFi Liquidity Pool', 'Real-time Clearing House', 'Credit Scoring AI', 'Wealth Management Hub',
'Mobile Banking Core', 'Institutional Trading API'
],
'web' => [
'Luxury Real Estate Portal', 'High-end Fashion Boutique', 'Architectural Showcase', 'Global Consulting Landing',
'Art Gallery Digital Experience', 'Premium Car Configurator', 'Exclusive Travel Concierge', 'Modern Media Platform',
'Corporate Governance Site', 'Creative Portfolio Engine'
],
'app' => [
'Supply Chain ERP', 'Telemedicine Platform', 'Smart City Dashboard', 'Enterprise HR Portal',
'IoT Monitoring System', 'Cloud Infrastructure Manager', 'Retail Logistics App', 'AI Customer Service Hub',
'Project Management Suite', 'Real-time Collaboration Tool'
]
];
$stmt = $pdo->prepare("INSERT INTO projects (title, slug, category, short_description, full_content, image_url, client_name, project_date, tech_stack) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
for ($i = 1; $i <= 30; $i++) {
$cat = $categories[($i - 1) % 3];
$titleIndex = floor(($i - 1) / 3);
$title = $titles[$cat][$titleIndex];
$slug = strtolower(str_replace(' ', '-', $title)) . '-' . $i;
$desc = "Advanced $cat solution designed for high-performance and scalability in the modern digital landscape.";
$content = "<h3>Overview</h3><p>This project represents a milestone in $cat development, focusing on delivering exceptional value through technical excellence.</p><h3>Key Features</h3><ul><li>High availability architecture</li><li>Secure data processing</li><li>Seamless third-party integrations</li><li>Intuitive user experience</li></ul>";
$img = $images[$cat][rand(0, 4)];
$client = "Global " . ucfirst($cat) . " Corp";
$date = "2023." . str_pad((string)rand(1, 12), 2, '0', STR_PAD_LEFT);
$stack = "PHP, React, Cloud, SQL";
$stmt->execute([$title, $slug, $cat, $desc, $content, $img, $client, $date, $stack]);
}
echo "Successfully seeded 30 projects.";
} catch (PDOException $e) {
error_log("Database initialization error: " . $e->getMessage());
echo "Error: " . $e->getMessage();
}