<?php
$U = $_REQUEST['url'];
preg_match("/http/", $U,$match);
$U = count($match)>0 ? $U : "http://".$U;
$U .= (substr($U,strlen($U)-1,1) == "/") ? "sitemap.xml" : "/sitemap.xml";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $U);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
$result = curl_exec($ch);
preg_match_all("/<loc>(.*?)<\/loc>/iu", $result, $matches);
$csv = "";
foreach ($matches[1] as $o)
{
$oo = preg_split("[\/]", $o, -1, PREG_SPLIT_NO_EMPTY);
$ox = $oo[count($oo)-1];
$ox = str_replace("-", " ", $ox);
$ox = str_replace(",", "", $ox);
$ox = str_replace(".html", "", $ox);
$ox = str_replace(".com", "", $ox);
$csv .= ucwords($ox).",".$o."\n";
}
header('Content-type: application/ms-excel');
header('Content-Disposition: attachment; filename='.$_POST['url'].".csv");
echo $csv;
exit();
?>