"; @ob_flush(); @flush(); //Loop through the matches and create a page for each one echo "Creating pages in: $dir
"; @ob_flush(); @flush(); if($dir) { for($i = 0; $i < count($matches); $i++) { createPage($i, $matches, $dir); } } //Create the sitemap using the directory made, the array of matches and specified page priority echo "Creating sitemap for: $dir
"; @ob_flush(); @flush(); $sitemap = createSiteMap($dir, $matches, 0.9); //Update main sitemap of all sitemaps each with specified page priority echo "Updating main sitemap.xml. Adding: $sitemap

"; @ob_end_flush(); @flush(); updateMainSiteMap($sitemap); set_time_limit(20); } echo "

Script completed successfully.

"; } while(is_dir($prefix."_".$i)) { $i++; } if(mkdir($prefix."_".$i)) { return $prefix."_".$i; } else { return false; } } //This function fixes the array keys, since array_unique preserves the keys and unsets the duplicates, //leaving gaps in the keys. This shifts them back in order. function cleanArrayKeys($arr) { foreach($arr as $a) { if(isset($a)) { $result[] = $a; } } return $result; } "; for($i = 1; $i < 5; $i++) { $next = (($index) * 4 + $i) % count($matches); $page .= "$matches[$next]\n"; } $page .=" "; $filename = $dir . "/" . urlencode($matches[$index]) . ".html"; if($filename == "output/.html") { echo $index."\n"; } $handle = fopen($filename, "w"); fwrite($handle, $page); fclose($handle); } //Build the xml sitemap with the corresponding filename function createSiteMap($dir, $matches, $priority) { if(!is_dir("sitemaps")) mkdir("sitemaps"); $filename = explode("_", $dir); $filename = "sitemaps/sitemap_" . $filename[count($filename) - 1] . ".xml"; $xml = " > 1.000 \n"; foreach($matches as $match) { } $xml .= ""; $handle = fopen($filename, "w"); fwrite($handle, $xml); fclose($handle); return $filename; } //Read in current sitemap.xml file, strip end tag, append new sitemap, add end tag, write to file. function updateMainSiteMap($path) { if(is_file("sitemap.xml")) { $file = file_get_contents("sitemap.xml"); $remove = ""; $file = substr($file, 0, -strlen($remove)); } else { $file = " \n"; } "; $handle = fopen("sitemap.xml", "w"); fwrite($handle, $file); fclose($handle); } ?>