<?php
require_once 'config.php';

$socket = '/opt/lampp/var/mysql/mysql.sock';
$conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME, 3306, $socket);

if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

$services = [

    [
        'name' => "Chimney Construction",
        'category_id' => 6,
        'slug' => "chimney-construction",
        'description' => "Chimney construction builds a durable and safe chimney from the ground up, ensuring proper ventilation, structural integrity, and compliance with safety standards.",
        'content' => "<h3>What Is Chimney Construction?</h3><p>Chimney construction involves designing and building a new chimney system, including the flue, masonry, and structural framework. Proper construction ensures safety, optimal airflow, and long-lasting performance.</p><p>Crest Chimney professionals carefully plan, measure, and build chimneys to meet local building codes and the homeowner's requirements.</p><p>Professional construction guarantees a durable, safe, and efficient chimney that enhances your home’s heating system.</p>",
        'url' => "/our-services/chimney-construction/"
    ],
    [
        'name' => "Chimney Framing Rebuild",
        'category_id' => 6,
        'slug' => "chimney-framing-rebuild",
        'description' => "Chimney framing rebuild restores the structural support of your chimney, preventing collapse and ensuring safe, long-lasting operation.",
        'content' => "<h3>What Is Chimney Framing Rebuild?</h3><p>Chimney framing rebuild involves repairing or reconstructing the wooden or metal framework that supports the chimney structure. Proper framing ensures stability and alignment of the chimney and flue.</p><p>Crest Chimney experts assess structural damage, replace compromised framing, and reinforce the chimney to maintain safety and longevity.</p><p>Rebuilding the framing prevents structural failure and supports safe, reliable chimney operation.</p>",
        'url' => "/our-services/chimney-framing-rebuild/"
    ],
    [
        'name' => "Chimney Rebuild",
        'category_id' => 6,
        'slug' => "chimney-rebuild",
        'description' => "Chimney rebuild restores a damaged or deteriorated chimney, ensuring safety, efficiency, and structural integrity while extending its lifespan.",
        'content' => "<h3>What Is Chimney Rebuild?</h3><p>Chimney rebuild involves removing damaged sections of masonry and reconstructing them with high-quality materials. This process restores the chimney’s stability, appearance, and functionality.</p><p>Crest Chimney technicians carefully reconstruct the flue, chimney crown, and exterior walls to meet safety and performance standards.</p><p>Professional rebuilding ensures a safe, long-lasting chimney capable of withstanding weather and heat exposure.</p>",
        'url' => "/our-services/chimney-rebuild/"
    ],
    [
        'name' => "Chimney Restoration",
        'category_id' => 6,
        'slug' => "chimney-restoration",
        'description' => "Chimney restoration repairs and preserves aging chimneys, addressing structural, aesthetic, and functional issues to extend its life and improve safety.",
        'content' => "<h3>What Is Chimney Restoration?</h3><p>Chimney restoration involves repairing masonry, replacing damaged components, and addressing water damage or cracks to return the chimney to a stable and functional condition.</p><p>Crest Chimney professionals use restoration techniques that preserve the chimney’s integrity and original appearance while improving safety and efficiency.</p><p>Restoration prolongs the life of the chimney, enhances performance, and maintains the architectural charm of your home.</p>",
        'url' => "/our-services/chimney-restoration/"
    ],
    [
        'name' => "Smoke Chamber Rebuild",
        'category_id' => 6,
        'slug' => "smoke-chamber-rebuild",
        'description' => "Smoke chamber rebuild improves airflow, reduces smoke problems, and enhances the efficiency and safety of your fireplace system.",
        'content' => "<h3>What Is Smoke Chamber Rebuild?</h3><p>Smoke chamber rebuild involves reconstructing the angled portion of the chimney above the fireplace, which directs smoke from the firebox to the flue. Proper shaping and masonry prevent downdrafts and improve draft efficiency.</p><p>Crest Chimney experts carefully remove deteriorated masonry and rebuild the chamber to precise specifications, ensuring smooth airflow.</p><p>Rebuilding the smoke chamber improves safety, reduces smoke problems, and enhances the overall efficiency of your chimney system.</p>",
        'url' => "/our-services/smoke-chamber-rebuild/"
    ]
];



$stmt = $conn->prepare("INSERT INTO services (category_id, name, slug, description, content, url) VALUES (?, ?, ?, ?, ?, ?)");

foreach ($services as $service) {
    $stmt->bind_param(
        "isssss",
        $service['category_id'],
        $service['name'],
        $service['slug'],
        $service['description'],
        $service['content'],
        $service['url']
    );

    if ($stmt->execute()) {
        echo "Service '{$service['name']}' added successfully!\n";
    } else {
        echo "Error adding service '{$service['name']}': " . $stmt->error . "\n";
    }
}

$stmt->close();
$conn->close();
?>