66 lines
3.5 KiB
PHP
66 lines
3.5 KiB
PHP
<?php
|
|
|
|
// Directory structure for subpages and their content
|
|
$pages = [
|
|
'home.php' => '<h1>Welcome to Wizdom Networks</h1><p>Your trusted partner for IT Consulting and Services.</p><p><a href="/services" class="btn btn-primary">Explore Our Services</a></p>',
|
|
'about.php' => '<h1>About Wizdom Networks</h1><p>At Wizdom Networks, we specialize in delivering top-notch IT solutions to help your business thrive.</p>',
|
|
'contact.php' => '<h1>Contact Us</h1><form method="POST" action="/submit-contact"><div class="mb-3"><label for="name" class="form-label">Your Name</label><input type="text" name="name" id="name" class="form-control" required></div><div class="mb-3"><label for="email" class="form-label">Your Email</label><input type="email" name="email" id="email" class="form-control" required></div><div class="mb-3"><label for="message" class="form-label">Your Message</label><textarea name="message" id="message" class="form-control" rows="5" required></textarea></div><button type="submit" class="btn btn-primary">Send Message</button></form>',
|
|
'testimonials.php' => '<h1>Testimonials</h1><p>Here\'s what our clients have to say about us.</p>',
|
|
'error.php' => '<h1>Page Not Found</h1><p>The page you are looking for does not exist. Please check the URL or go back to the <a href=\"/\">home page</a>.</p>',
|
|
'services/it_consulting.php' => '<h1>IT Consulting</h1><p>Our IT consulting services provide businesses with tailored solutions to maximize productivity and efficiency.</p>',
|
|
'services/emergency_support.php' => '<h1>Emergency Support</h1><p>We offer 24/7 emergency IT support to ensure your business operations run smoothly.</p>',
|
|
'services/managed_services.php' => '<h1>Managed Services</h1><p>We provide end-to-end managed IT services to keep your business running efficiently.</p>',
|
|
'services/online_brand_management.php' => '<h1>Online Brand Management</h1><p>Enhance your online presence with our expert brand management services.</p>',
|
|
'services/project_management.php' => '<h1>Project Management</h1><p>Efficient project management to ensure your IT projects are delivered on time and within budget.</p>'
|
|
];
|
|
|
|
// Use the agreed directory structure for pages
|
|
$basePath = realpath(__DIR__ . '/../resources/views/pages');
|
|
|
|
if (!$basePath) {
|
|
die("Error: The base directory for pages does not exist. Please ensure the directory structure is correct.\n");
|
|
}
|
|
|
|
foreach ($pages as $file => $content) {
|
|
$filePath = $basePath . '/' . $file;
|
|
$dirPath = dirname($filePath);
|
|
|
|
// Ensure the directory exists
|
|
if (!is_dir($dirPath)) {
|
|
mkdir($dirPath, 0755, true);
|
|
echo "Created directory: $dirPath\n";
|
|
}
|
|
|
|
$title = ucwords(str_replace(['_', '.php'], [' ', ''], basename($file))) . ' - Wizdom Networks';
|
|
|
|
// Create the PHP file with the correct structure
|
|
$template = <<<PHP
|
|
<?php
|
|
|
|
\$title = '$title';
|
|
\$content = <<<HTML
|
|
$content
|
|
HTML;
|
|
|
|
include '../layouts/main.php';
|
|
PHP;
|
|
|
|
if (file_exists($filePath)) {
|
|
$currentContent = file_get_contents($filePath);
|
|
|
|
// Check if the file already has the correct content
|
|
if (trim($currentContent) === trim($template)) {
|
|
echo "File already has correct content: $filePath\n";
|
|
continue;
|
|
}
|
|
|
|
// If the file has placeholder content, overwrite it
|
|
echo "File exists with different content. Updating: $filePath\n";
|
|
} else {
|
|
echo "Creating new file: $filePath\n";
|
|
}
|
|
|
|
file_put_contents($filePath, $template);
|
|
echo "Generated or updated: $filePath\n";
|
|
}
|