Location: PHPKode > projects > HuMo-gen > birthday_rss.php
<?php
// programma: verjaardag_rss.php
// auteur: Louis Ywema
// datum: 31-07-2007
// doel: rssfeed met de jarigen van vandaag
// opnemen in header-sectie html-pagina:
// <link rel="alternate" type="application/rss+xml" href="verjaardag_rss.php" title="RSS feed voor verjaardagskalender" />     

// Update by: Huub Mons.
// Added multiple languages.

include("include/db_login.php"); //Inloggen database.
include("include/settings_global.php"); //Variabelen

include('include/person_cls.php');
include("include/safe.php");

if(function_exists('date_default_timezone_set')){
	date_default_timezone_set('Europe/Amsterdam');
}

$vandaag = date("d M Y");
$maandnaam = date("F");
$dagvandaag = date("d");
$maandnummer = date ("M");
$jaar = date("Y");
$newline ="\n";
// meta-info

/*
header ("Content-Type: application/rss+xml; charset=UTF-8");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
echo "<rss version=\"2.0\"
			xmlns:dc=\"http://purl.org/dc/elements/1.1/\"
			xmlns:content=\"http://purl.org/rss/1.0/modules/content/\"
			xmlns:sy=\"http://purl.org/rss/1.0/modules/syndication/\">\n";
*/

$language_rss="nl";
if (isset($_GET['lang']) AND file_exists('languages/'.$_GET['lang'].'/language.php')){ $language_rss=$_GET['lang']; }
// *** Extra controle of taal wel bestaat ***
if (file_exists('languages/'.$language_rss.'/language.php')){
	$language = array();
	include('languages/'.$language_rss.'/language.php'); //Taal
}

header("Content-Type: application/xml; charset=iso-8859-1");
echo '<?xml version="1.0" encoding="iso-8859-1"?>';
echo '<rss version="2.0">';

// channel info
echo "<channel>\n";
echo "<title>".$language["birtday_rss_title"]."</title>".$newline;
echo '<link>'.$humo_option["rss_link"].'</link>'.$newline;
echo "<description>".$language["birtday_rss_text"]."</description>".$newline;
echo "<language>".$language["birtday_rss_language"]."</language>".$newline;

// mysql query
$counter=0;
$datasql = mysql_query("SELECT * FROM humo_trees ORDER BY tree_order",$db);
while ($dataDb=mysql_fetch_object($datasql)){
	$sql="SELECT *,
		substring(pers_birth_date,1,2) as dag,
		substring(pers_birth_date,8,4) as gebjaar,
		substring(pers_death_date,8,4) as ovljaar
		FROM ".veilig($dataDb->tree_prefix)."person
		WHERE pers_birth_date!=''
		AND substring(pers_birth_date,4,3) = '$maandnummer'
		AND substring(pers_birth_date,1,2) ='$dagvandaag' order by pers_lastname";

	$query = mysql_query ($sql)
		or die("database-error (1): ".mysql_error());

	// loop results
	while ($record=mysql_fetch_object($query)){
		$dood = $record->pers_death_date;
		if ($dood !=''){
			$dood =' (&#8224; '.$dood.')';
			$leeftijd = ' ('.($record->ovljaar-$record->gebjaar).')';
		}
		else{
			$dood = '';
			$leeftijd = ' ('.($jaar - $record->gebjaar).')';
		}

		$persoon_cls = New persoon_cls;
		$title = $persoon_cls->naam($record);

		$title = str_replace('&', '&amp;', $title);  // Los & teken niet toegestaan in RSS
		$title.=$leeftijd.$dood;

		$url = 'gezin.php?database='.$dataDb->tree_prefix.'&amp;id='.$record->pers_indexnr;
		 
		// show content
		echo "<item>".$newline;
		echo "<title>".$title."</title>".$newline;
		echo "<link>".$humo_option["rss_link"]."/".$url."</link>".$newline;
		echo "</item>".$newline;
		$counter++;
	}  // close channel and rss

}  // Einde meerdere databases

// *** No results found ***
if ($counter==0){
	echo "<item>".$newline;
	echo "<title>".$language["birtday_rss_no_results"]."</title>".$newline;
	echo "</item>".$newline;
}

echo "</channel>".$newline;
echo "</rss>";
?>
Return current item: HuMo-gen