0) { $prefix = ' '; $suffix = ''; if($_GET['page'] == 1) { $xml = ' http://www.topmodel.bg/ '.date("Y-m-d").' always 1.0 '; $xml .= ' http://www.topmodel.bg/members/registration 0.9 http://www.topmodel.bg/pages/tags 0.9 '; } $offset = ($_GET['page']-1)*$limit; $sql = "(SELECT articles.id AS link,articles.pubDate AS stamp, 'article' AS t FROM articles WHERE articles.active = 1 ORDER BY articles.id DESC) UNION (SELECT members.username AS link,members.last_action AS stamp, 'member' AS t FROM members WHERE members.active = 1 ORDER BY members.id DESC) UNION (SELECT tags.tag AS link,UNIX_TIMESTAMP() AS stamp, 'tag' AS t FROM tags) LIMIT $offset,$limit"; $arr = $GLOBALS['db']->GetAll($sql); foreach($arr as $row) { $xml .= ''; if($row['t'] == 'member') $xml .= 'http://www.topmodel.bg/'.$row['link'].''; else if($row['t'] == 'article') $xml .= 'http://www.topmodel.bg/articles/view/'.$row['link'].''; else if($row['t'] == 'tag') { $link = str_replace(' ','-',str_replace('-','--',$row['link'])); $xml .= 'http://www.topmodel.bg/articles/tags/'.htmlspecialchars($link).''; } $xml .= ''.date("Y-m-d",$row['stamp']).''; if($row['t'] == 'member') $xml .= 'always 0.9'; else $xml .= '0.8'; $xml .= ''; } $value = $prefix.$xml.$suffix; $gzvalue = gzencode($value,9); if(!$_GET['gz']) { header("Content-type: text/xml; charset=UTF-8"); header('Content-length: ' . strlen($value)); echo $value; } else { header('Content-description: File Transfer'); header('Content-type: application/x-gzip'); header('Content-disposition: attachment; ". "filename=sitemap.xml.gz'); header('Content-length: ' . strlen($gzvalue)); echo $gzvalue; } } else { $sql = "SELECT count(*) FROM members WHERE active = 1"; $count_members = $GLOBALS['db']->GetOne($sql); $sql = "SELECT count(*) FROM articles WHERE active = 1"; $count_articles = $GLOBALS['db']->GetOne($sql); $sql = "SELECT count(*) FROM tags"; $count_tags = $GLOBALS['db']->GetOne($sql); $count = $count_members + $count_articles + $count_tags; $num = ceil($count/$limit); $xml = ' '; for($i=1;$i<=$num;$i++) { $xml .= ' http://www.topmodel.bg/sitemap.php?page='.$i.' '.date("Y-m-d").' '; } $xml .= ''; header("Content-type: text/xml; charset=UTF-8"); header('Content-length: ' . strlen($xml)); echo $xml; } ?>