Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected function createSitemapFile($file_name, $urls){
- $output_file=$file_name;
- $ret ='<?xml version="1.0" encoding="UTF-8"?>'."\n";
- $ret.='<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'."\n";
- if(count($urls)>0){
- $domain=$_SERVER['HTTP_HOST'];
- foreach($urls as $u){
- if(preg_match('/^http:/', $u['url'])){
- if(parse_url($u['url'], PHP_URL_HOST)==$domain){
- $ret.='<url>'."\n";
- $ret.='<loc>'.$u['url'].'</loc>'."\n";
- $ret.='<lastmod>'.date('Y-m-d',time()).'</lastmod>'."\n";
- $ret.='<changefreq>'.$u['changefreq'].'</changefreq>'."\n";
- $ret.='<priority>'.$u['priority'].'</priority>'."\n";
- $ret.='</url>'."\n";
- }else{
- continue;
- }
- }elseif($u['url']==='#'){
- continue;
- }else{
- $ret.='<url>'."\n";
- $ret.='<loc>'.$this->site_link.$u['url'].'</loc>'."\n";
- $ret.='<lastmod>'.date('Y-m-d',time()).'</lastmod>'."\n";
- $ret.='<changefreq>'.$u['changefreq'].'</changefreq>'."\n";
- $ret.='<priority>'.$u['priority'].'</priority>'."\n";
- $ret.='</url>'."\n";
- }
- }
- }
- $ret.='</urlset>'."\n";
- $host=$_SERVER['HTTP_HOST'];
- if($host=='erver.ru' || preg_match('/([a-z]+).erver.ru/', $host)){
- if($host!='erver.ru'){
- $output_file=str_replace('erver.ru', $host, $output_file);
- }
- }
- $f=fopen($output_file,'w');
- fwrite($f, SiteBill::iconv(SITE_ENCODING, 'utf-8', $ret));
- fclose($f);
- chmod($output_file, 0755);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement