include 'include/dbconnect.php';
include 'include/settings.php';
include 'include/functions.php';
define('LANGUAGE', getLanguage($_COOKIE['language']));
function xmlEntities($string) {
$translationTable = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES);
foreach ($translationTable as $char => $entity) {
$from[] = $entity;
$to[] = ''.ord($char).';';
}
return str_replace($from, $to, $string);
}
function remEntities($str) {
if(substr_count($str, '&') && substr_count($str, ';')) {
// Find amper
$amp_pos = strpos($str, '&');
//Find the ;
$semi_pos = strpos($str, ';');
// Only if the ; is after the &
if($semi_pos > $amp_pos) {
//is a HTML entity, try to remove
$tmp = substr($str, 0, $amp_pos);
$tmp = $tmp. substr($str, $semi_pos + 1, strlen($str));
$str = $tmp;
//Has another entity in it?
if(substr_count($str, '&') && substr_count($str, ';'))
$str = remEntities($tmp);
}
}
return $str;
}
$sql = "SELECT * FROM sitemap LIMIT 1 ";
$result = mysql_query($sql);
if (mysql_num_rows($result) > 0) {
$row = mysql_fetch_assoc($result);
if($row['rss'] == 1){
header ("content-type: text/xml");
$sql = "SELECT * FROM pages WHERE active = '1' && url = '' ORDER BY id";
$result = mysql_query($sql);
echo '
' . SITE_NAME . '
http://' . $_SERVER['HTTP_HOST']. '
' . str_replace('&','',remEntities(xmlEntities(getTheSEOcontent(0, 'description')))) . '
';
if (mysql_num_rows($result) > 0) {
while($page = mysql_fetch_assoc($result)) {
$content = mysql_query("SELECT * FROM pageContent WHERE page_id = '" . $page['id'] . "' ");
$howMuchContent = mysql_num_rows($content);
if($howMuchContent > 0){
$url = '/' . $page['id'] . '/';
$url .= strtoupper(clean_url(getTheSEOcontent($page['id'], 'pageTitle'))) . '/';
$cKeys = getTheSEOcontent($page['id'], 'keywords');
$countKey = 0;
if(count($cKeys) > 0){
foreach($cKeys as &$keys){
$countKey = $countKey + 1;
if(trim($keys) != '' && $countKey < 4)
$url .= clean_url($keys) . '-';
}
}
if($countKey > 0){
$url = substr($url,0,-1);
$url .= '/';
}
$cTitles = getTheSEOcontent($page['id'], 'contentTitle');
$cTitle = false;
if(count($cTitles) > 0){
foreach($cTitles as &$contentTitle){
if(trim($contentTitle) != ''){
$url .= clean_url($contentTitle) . '-' ;
$cTitle = true;
}
}
}
if($cTitle = true){
$url = substr($url,0,-1);
$url .= '/';
}
echo '
-
' . SITE_NAME . ' | ' . strtoupper(getTheSEOcontent($page['id'], 'pageTitle')) . ' | ';
$cTitles = getTheSEOcontent($page['id'], 'contentTitle');
if(count($cTitles) > 0){
foreach($cTitles as &$contentTitle){
if(trim($contentTitle) != '')
echo $contentTitle . ' |' ;
}
}
$cKeys = getTheSEOcontent($page['id'], 'keywords');
$countKey = 0;
$theKeyString = '';
if(count($cKeys) > 0){
foreach($cKeys as &$keys){
$countKey = $countKey + 1;
if(trim($keys) != '' && $countKey < 4)
echo ' - ' . $keys;
if(trim($keys) != '')
$theKeyString .= $keys . ', ';
}
}
echo '
http://' . $_SERVER['HTTP_HOST'] . htmlchars($url) . '
' . str_replace('&','',remEntities(xmlEntities(getTheSEOcontent($page['id'], 'description')))) . '
';
}
}
}
echo'
';
}else{
echo '
RSS-sitemap
Uitgeschakeld
';
}
}
?>