PHP generates Google Map code
<title>google Sitemap Builder </title>
<style type= "Text/css" >
<!--
. Agreement {
border:1px solid #666666;
}
. Green {
Color: #00CC00;
Font-weight:bold;
}
. Red {color: #FF0000; font-weight:bold;}
#scroll {
border:1px solid #0000FF;
line-height:25px;
height:25px;
width:280px;
Text-align:left;
}
. red{
Background-color: #999999;
Text-align:center;
Filter:alpha (opacity=80);/* Transparency * *
}
#act {
Background-image:url ([img]yun_qi_img/loading.gif[/img]);
height:27px;
width:282px;
}
-->
</style>
<script>
var MyMar;
function monitoring ()
{
if (document.readystate = = ' complete ')
{
window.location= ' i= ' +query_get ();
}
}
function Query_get ()
{
var querystr = window.location.href.split ("=");
if (! Number (querystr[1]))
{
var value=0;
}else{
var value=number (querystr[1]);
}
return number (value) +1;
}
Mymar=setinterval (' monitoring () ', 3000);
</script>
<div style= "Text-align:center;" id=all_a>
<div align= "center" id=act>
<div align= "center" id=scroll>
<div class= "Red" style= "width:1%;" ></div>
</div>
</div>
</div>
<div align= "center" >
Retrieving: <span id=link></span>
</div>
<div id= "Logs" class= "agreement" style= "height:420px"; Overflow:auto; " >
?
/*===========================================================
= Copyright Agreement:
= GPL ()
=------------------------------------------------------------
= Summary: URL collection function PHP5
= Version: 1.0
=------------------------------------------------------------
= Open Source Stal project group
= Update Author: jd808
= Last Date: 2008-4-18
============================================================*/
$file = ' sitemap.xml '; GOOGLE needs to execute the file to do the first page of the temporary URL to store files
$temp _file= ' temp.xml ';//inner page URL temporary storage file
$url = "http://www.gyqpw.com/"; Web site to search for
$timea =time ()//Start time users do not need to ignore the above 3 parameters can be
if (!$_get[' I '])
{
File_put_contents ($file, ");
File_put_contents ($temp _file, ");
File_put_contents ($file, con ($url, $timea));
echo "<script>
window.location= ' I=bak ';
</script> ";
}else{
Consts ($_get[' i '), $timea, $file, $url);
}
function con ($url, $timea)//control
{
echo "<script>
document.getElementById (' link '). innerhtml= ' collecting '. $url. "Information! ';
</script> ";
$str = file_get_contents ($url);
$collection _url=collection_url ($str, $url);
$collection _url=array_flip ($collection _url);
foreach ($collection _url as $key => $value)
{
If Count (Explode ($url, $key)) ==2)
{
$strurl. = $key. " \ n ";
}
}
return $strurl;
}
function consts ($i, $timea, $file, $urlys)
{
$str =file_get_contents ($file); Reading page data and producing strings
$url =explode ("\ n", $str);
$sum =count ($url)-1;
if ($i = = ' bak ')
{
$i = 0;
}
/* Progress bar * *
$wid =round ($i/$sum *100,2). " %";
$div = "<div class= ' red ' style= ' width:". $wid. "; ' > $wid </div> ";
Echo ' <script>
document.getElementById ("scroll"). Innerhtml= "'. $div; '";
</script> ';
Ob_flush ()//Free cache
Flush (); Send the data that is no longer cached to the browser
/* Progress bar End * *
for ($j = $i; $j < $sum; $j + +)
{
if (! $url [$j])
{
Continue
}
if (!detection_url ($url [$j]))//detection URL is legal
{
Continue
}
$timeb =time ()//Tracking time
if (($timeb-$timea) >=25)
{
Memory ($collection _url, $j); Storing data
}
/* URL Display tracking * *
echo "<script>
document.getElementById (' link '). innerhtml= ' ". $url [$j]."
</script> ";
Ob_flush ()//Free cache
Flush (); Send the data that is no longer cached to the browser
/* URL Display tracking end*/
$urlstr = @file_get_contents ($url [$j]);
$collection _url[]=collection_url ($urlstr, $urlys);
$timec =time ()//Tracking time
if (($timec-$timea) >=25)
{
Memory ($collection _url, $j); Storing data
}
if ($j = = $sum-1)
{
Memorys (); Storing data is primarily about generating formal XML
}
}
}
function Collection_url ($STR, $url)//collect URL and return an array (Main page)
{
Preg_match_all ('/<a.*?href= "(. +?)" /is ', $str, $matches);
$urlexp = $matches [1];
for ($j =0; $j <count ($URLEXP); $j + +)
{
$urlexp [$j]=ltrim (Str_replace ("\ r \ n", ", $urlexp [$j])";
$urlexp [$j]=ltrim (Str_replace ("\ n", ', $urlexp [$j])];
$urlexp [$j]=ltrim (Str_replace ("\ R", ', $urlexp [$j]);
if ($urlexp [$j]== ' # ')
{
Continue
}
if ($urlexp [$j]== '/# ')
{
Continue
}
if (!STRCHR ($urlexp [$j], ' http://'))
{//no http://
$urlall []= $url. $urlexp [$j];
echo $url. $urlexp [$j]. ' <br> ';
Print "<script>document.getelementbyid (' logs '). scrolltop = document.getElementById (' logs '). scrollheight; </script> ";
Ob_flush ()//Free cache
Flush (); Send the data that is no longer cached to the browser
}else{
if (Explode ($url, $urlexp [$j]) ==2)
{
$urlall []= $urlexp [$j];
echo $urlexp [$j]. ' <br> ';
Print "<script>document.getelementbyid (' logs '). scrolltop = document.getElementById (' logs '). scrollheight; </script> ";
Ob_flush ()//Free cache
Flush (); Send the data that is no longer cached to the browser
}else{
Unset ($urlexp [$j]);
}
}
}
return $urlall; Return to this page to search for the resulting array
}
function memory ($collection _url, $i)
{
Global $temp _file;
if (Is_array ($collection _url))
{
for ($h =0; $h <count ($collection _url); $h + +)
{
For ($l =0 $l <count ($collection _url[$h]); $l + +)
{
$strts. = $collection _url[$h] [$l]. " \ n ";
}
}
$wstr =file_get_contents ($temp _file);
File_put_contents ($temp _file, $wstr. $strts);
if ($i ==0)
{
$i = 2;
}
$k = $i-1;
echo "<script>
Window.location= ' i= '. $k. "';
</script> ";
Exit
}
}
function Memorys ()//primarily generates formal XML
{
Global $temp _file, $file;
$file _arr=array_flip (file ($file));
$temp _file_arr=array_flip (file ($temp _file));
$xmla = ' <?xml version= ' 1.0 ' encoding= ' UTF-8 '?> '. \ r \ n ". ' <urlset xmlns= "'" >http://www.google.com/schemas/sitemap/0.84 ">";
$XMLC = "\r\n</urlset>";
foreach ($file _arr as $keya => $valuea)
{
$keya =ltrim (Str_replace ("\ r \ n", ", $keya)");
$keya =ltrim (str_replace ("\ n", ", $keya)");
$keya =ltrim (Str_replace ("R", ", $keya)");
$xml. = ' <url>
<loc> '. $keya. ' </loc>
<lastmod> '. Date ("Y-m-d", Time ()). ' </lastmod>
<changefreq>daily</changefreq>
</url> ';
}
foreach ($temp _file_arr as $keyb => $valueb)
{
$keyb =ltrim (Str_replace ("\ r \ n", ", $keyb)");
$keyb =ltrim (str_replace ("\ n", ", $keyb)");
$keyb =ltrim (Str_replace ("R", ", $keyb)");
$xml. = ' <url>
<loc> '. $keyb. ' </loc>
<lastmod> '. Date ("Y-m-d", Time ()). ' </lastmod>
<changefreq>daily</changefreq>
</url> ';
}
$strts = $xmla. $xml. $XMLC;
File_put_contents ($file, $strts);
echo "<script>
Clearinterval (MyMar);
document.getElementById (' link '). innerhtml= ' URL has been collected and completed! ';
document.getElementById (' all_a '). Innerhtml= ' <b>xml build completed! </b> ';
</script> ";
}
function Detection_url ($url)
{
if (STRRCHR ($url, ' = '))
{
return true;
}
if (substr ($url, strlen ($url) -1,1) = = '/')
{
return true;
}
$postfix = STRRCHR ($url, '. ');
Switch ($postfix)
{
Case ". php":
return true;
Break
Case ". html":
return true;
Break
Case ". htm":
return true;
Break
Case ". asp":
return true;
Break
Case ". aspx":
return true;
Break
Case ". sHTML":
return true;
Break
}
return false;
}
?>
</div>