php xml site map script
<?php
$url="walllook.com"; //site url
//Fetch the page using the CURL Library
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$store = curl_exec ($ch);
curl_close ($ch);
//Print website information (optional)
print <<<END
<h1>Sitemap links Information for a given website</h1>
Website: $url<br /><br />
END;
//Strip the Host name from the Url and echo it (used later)
preg_match('@^(?:http://)?([^/]+)@i',$url, $matches);
$host = $matches[1];
echo '<br />Host: '.$host;
//Take out the directory name of your url
if(strrpos($url, "/") > 10)
$root= substr($url,0,strrpos($url, "/"));
else $root= $url;
echo '<br />Root: '.$root;
//Create an array to save urls
$links=array();
//Strip all links from the page
preg_match_all('/<a href="(.*)"/U',$store, $matches, PREG_SET_ORDER);
//Loop inside the links and rebuild the corresponding full urls.
foreach ($matches as $val)
{
if(strpos($val[1],'#') === FALSE && strpos($val[1],'http://') === FALSE && strpos($val[1],'@') === FALSE)
if(!in_array(trim($val[1]),$links))
if(strpos(trim($val[1]),'/') == 0 && strpos(trim($val[1]),'/') !== FALSE)
$links[]='http://'.$host.trim($val[1]);
else
$links[]='http://'.$root.'/'.trim($val[1]);
}
$date=date('Y-m-d');
//Print all results inside a textarea box:
echo '<textarea rows="40" name="sitemap" cols="120">';
echo '<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.google.com/schemas/sitemap/0.84 http://www.google.com/schemas/sitemap/0.84/sitemap.xsd">
';
//Loop inside all links and add them to the sitemap using a default priority as 0.9 and a default changefreq as daily.
foreach ($links as $val)
{
print "<url>
<loc>$val</loc>
<lastmod>$date</lastmod>
<changefreq>daily</changefreq>
<priority>0.9</priority>
</url>
";
}
print '</urlset>';
echo '</textarea>';
?>
x-xmax
Country UNITEDSTATES
City Ohio
Posted On 27/01/2012
5
Other Pages
- php word limit
- sql replace
- PHP prepend leading zero before single digit number
- All About Mysql with example advance query
- jquery add new input field
- WordPress Get Specific Page content
- WordPress Get resent post
- php whois domain checking simple script
- simple css horizontal menu code
- youtube php api to reading title & length
- div Tab menu using CSS
- Textarea resize on hove and mouse click
- Create Tab Menu Using Div
- simple javascript lightbox code
- Renaming & reading file name using .bat
- simple jquery slider code
- rewrite rules htaccess or how to create short url in php
- php Set Timezone by country
- javascript new tab on popup window code
- simple jquery for date picker
- php remove spacial characters
- single page website
- simple dropdown menu without javascript
- php deleting multiple data using checkbox
- SELECT OR DESELECT Multiple Checkbox
- php image re-size script
- php read file from directory
- php connect to mysql
- PHP tips and tricks
- Get and output the source of the homepage of a website
- php login scrpit
- php image watermark script
- PHP to Force a File Download
- php pagination script
- Use a javascript confirm box to ask the user if they want to delete
- simple php file upload code
- How to set a div to auto adjust it's height with available browser height
- php script send email with attachment
- Testing interview questions and answers
- Mysql interview questions and answers
- CSS3 interview questions and answers
- HTML5 interview questions and answers
- PHP interview questions and answers
- How do I clear all the entries from just one table in MySQL with PHP
- PHP Reading a file line by line
- filter email id from a string
- php mysql how to get unique data from table
- php how to short array by alphabetical order
- javascrpit iframe break code
- php defining maximum character of string
- php Remove extension from a filename
- Do you know you can watch Star wars Text movie from your computer.
- Interesting Computer tricks -- try it
- how to Clear default value of text input using Javascript
- improve your internet speed using gpedit.msc
- php xml site map script