class sitemap{
private $resconns;
private $sitemappath ="../sitemap.xml";
public $arrmaxurl;
public function wsuoyinxml($sitemappath,$resconns,$arrmaxurl){
if(file_exists($sitemappath)){
$ressuoyin = file_get_contents($sitemappath);
return existsloc($ressuoyin,$resconns,$arrmaxurl);
}
}
public function existsloc($ressuoyin,$resconns,$arrmaxurl){
$strstart = strrpos($ressuoyin, "");
$strlocend = strrpos($ressuoyin, "");
$fileurl = substr($ressuoyin,$strlocend+5,$strstart-121);
$xiegang = "../xml".strrchr($fileurl,"/");
return wsitemapxml($xiegang,$resconns,$arrmaxurl);
}
public function wsitemapxml($sitemapurl,$resconns,$arar){
if(file_exists($sitemapurl)){
$redfilecon = file_get_contents($sitemapurl);
$redfileconlen = strlen($redfilecon);
$deleteurlset = substr($redfilecon, 0,$redfileconlen-9);
$countloc = substr_count($deleteurlset, "");
$resconnnum = substr_count($resconns, "");
$loccountnums = $countloc+$resconnnum;
if($loccountnums>49990){
$basename = basename($sitemapurl);
$xmlfilexuhao = preg_match("[\d*]",$basename);
$xmlfilexuhaojia = $xmlfilexuhao+1;
$newfilename = "../xml/site".$xmlfilexuhaojia.".xml";
fopen($newfilename, "w");
fclose($newfilename);
if(file_exists($newfilename)){
$newsitejiacon = "".PHP_EOL."".PHP_EOL.$resconns."";
file_put_contents($newfilename,$newsitejiacon);
$suoyinfile = "../sitemap.xml";
$suoyinfilecon = file_get_contents($suoyinfile);
$suoyinstr = "".PHP_EOL."https://www.1586f.com/xml/site".$xmlfilexuhaojia.".xml".PHP_EOL."".date('Y-m-d H:i:s')."".PHP_EOL."".PHP_EOL."";
$addsitemaploc = str_replace("",$suoyinstr, $suoyinfilecon);
file_put_contents($suoyinfile, $addsitemaploc);
if(0$newfilename), "")){
mysql_query($sqlinterset);
if(mysql_affected_rows()>0){
echo "创建路径为".$newfilename."的文件! xml表记录更新成功"."
"."sitemap.xml更新成功!";
}else{
echo "创建路径为".$newfilename."的文件! xml表记录插入失败"."
"."sitemap.xml更新成功!";
}
}
}
}else{
$urlleftcount = substr_count($deleteurlset,"");
$urlrightcount = substr_count($deleteurlset, "");
if(isset($urlleftcount) && isset($urlrightcount) && $urlleftcount==$urlrightcount){
file_put_contents($sitemapurl, $deleteurlset.$resconns."");
if($countloc$sitemapurl), "")){
$sqlinterset = "Insert into zzcms_writsitemap(zx,main,pp,tv,vip,wsdk,wssp,wsyx,zh,zhcompany,zhzixun,dateday) values('".$arar["zxmaxid"]."','".$arar["zsmaxid"]."','".$arar["ppmaxid"]."','".$arar["tvmaxid"]."','".$arar["vipmaxid"]."','".$arar["wsdkmaxid"]."','".$arar["wsspmaxid"]."','".$arar["wsyxmaxid"]."','".$arar["zhmaxid"]."','".$arar["zhcompanymaxid"]."','".$arar["zhzixunmaxid"]."','".date('Y-m-d H:i:s')."')";
mysql_query($sqlinterset);
if(mysql_affected_rows()>0){
echo "xml表记录更新成功"."
"."sitemap.xml更新成功!";
}else{
echo "表记录插入失败"."
"."sitemap.xml更新成功!";
}
}
}
}
}
}
}