philippurbschat.de/home/app/controllers/SeoController.php

42 lines
No EOL
1.6 KiB
PHP

<?php
require_once __DIR__ . '/../../core/Controller.php';
class SeoController extends Controller {
// Sitemap Generation
public function sitemap() {
$baseUrl = Config::get('BASE_URL', 'https://philippurbschat.de/');
$pages = ['', 'about', 'imprint', 'privacy'];
$lastMod = date('Y-m-d');
$xml = '<?xml version="1.0" encoding="UTF-8"?>';
$xml .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
foreach ($pages as $page) {
$priority = ($page === '') ? '1.0' : '0.8';
$xml .= '<url>';
$xml .= '<loc>' . $baseUrl . $page . '</loc>';
$xml .= '<lastmod>' . $lastMod . '</lastmod>';
$xml .= '<priority>' . $priority . '</priority>';
$xml .= '</url>';
}
$xml .= '</urlset>';
return $this->xml($xml);
}
// Robots.txt Generation
public function robots() {
$baseUrl = Config::get('BASE_URL', 'https://philippurbschat.de/');
$txt = "User-agent: *\n";
$txt .= "Allow: /\n\n";
$txt .= "Disallow: /admin\n";
$txt .= "Disallow: /admin/\n";
$txt .= "Disallow: /admin/users\n";
$txt .= "Disallow: /admin/settings\n";
$txt .= "Disallow: /login\n";
$txt .= "Disallow: /login/\n";
$txt .= "Disallow: /register\n";
$txt .= "Disallow: /register/\n";
$txt .= "Disallow: /core/\n";
$txt .= "Disallow: /app/\n";
$txt .= "Disallow: /views/\n";
$txt .= "Disallow: /src/\n\n";
$txt .= "Sitemap: " . $baseUrl . "sitemap.xml\n";
return $this->text($txt);
}
}