<?php
header('Content-type: text/xml; charset=windows-1252');
				     
function UBB($string) {
	
//Functie moet nog wel Xhtmlproof worden gemaakt.

//HTML escapen
$string = htmlentities($string);
//Enters toevoegen. Ik maak gebruik van nl2br aangezien die <br /> oplevert
//$string = nl2br($string);

//Extra spatie om alles in goede banen te leiden.
$string = ' '.$string;

$tags = array("b","i","B","I","td","th","pre","code","sup","sub","ul","li","strong","em","small");

for ($i = 0; $i < sizeof($tags); $i++) {
   $t = $tags[$i];
   $open1 = quotemeta("[$t]"); $close1 = quotemeta("[/$t]");
   $open2 = "<$t>"; $close2 = "</$t>";
   $expression = "!$open1(.*)$close1!Ui";
   $replacement = "$open2\\1$close2";
   $string = preg_replace($expression, $replacement, $string);
}

//Enters toe voegen


// Patterns and replacements for URL and email tags..
	$patterns = array();
	$replacements = array();
	
	
		
	//URL in de tekst zonder tags
	$patterns[] = "#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#";
	$replacements[] = "\\1<a href=\"\\2\">\\2</a>";
	
	//URL in de tekst zonder tags
	//$patterns[] = "#(^|[\n ])(.*?\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#";
	//$replacements[] = "\\1<a href=\"http://\\2\">\\2</a>";
	
	
	
	// matches a [url]xxxx://www.phpbb.com[/url] code..
	$patterns[] = "#\[url\]([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*?)\[/url\]#";
	$replacements[] = "<a href=\"\\1\">\\1</a>";

	// [url]xxx.phpbb.com[/url] code.. (no xxxx:// prefix).
	$patterns[] = "#\[url\](.*?[\w\#$%&~/.\-;:=,?@\[\]+]*?)\[/url\]#";
	$replacements[] = "<a href=\"http://\\1\">\\1</a>";

	// [url=xxxx://www.phpbb.com]phpBB[/url] code..
	$patterns[] = "#\[url=([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*?)\]([^?\n\r\t].*?)\[/url\]#";
	$replacements[] = "<a href=\"\\1\">\\2</a>";

	// [url=xxx.phpbb.com]phpBB[/url] code.. (no xxxx:// prefix).
	$patterns[] = "#\[url=(.*?\.[\w\#$%&~/.\-;:=,?@\[\]+]*?)\]([^?\n\r\t].*?)\[/url\]#";
	$replacements[] = "<a href=\"http://\\1\">\\2</a>";
	
	//Internal URL, just index.php bla (no xxxx:// prefix).
	$patterns[] = "#\[urlint=(.*?)\](.*?)\[/urlint\]#";
	$replacements[] = "<a href=\"\\1\">\\2</a>";
	
	// [email]user@domain.tld[/email] code..
	$patterns[] = "#\[email=([a-z0-9&\-_.]+?@[\w\-]+\.([\w\-\.]+\.)?[\w]+)\](.*?)\[/email\]#si";
	$replacements[] = "<a href=\"mailto:\\1\">\\3</a>";
	
	// [email]user@domain.tld[/email] code..
	//$patterns[] = "#\[email\]([a-z0-9&\-_.]+?@[\w\-]+\.([\w\-\.]+\.)?[\w]+)\[/email\]#si";
	//$replacements[] = "<span class=\"email\">\\1</span>";
	
		
	$patterns[] = "#\[tr\](.*?)\[/tr\]#";
	$replacements[] = "<tr>\\1</tr>";
	//Ul
	$patterns[] = "#\[ul\](.*?)\[/ul\]#";
	$replacements[] = "<ul>\\1</ul>";
	//Blockquote
	$patterns[] = "#\[blockquote\](.*?)\[/blockquote\]#";
	$replacements[] = "<blockquote>\\1</blockquote>";
	
	 
	//$string = str_replace("@", "[at]",preg_replace($patterns, $replacements, $string));
	$string = preg_replace($patterns, $replacements, $string);
	
	$string = str_replace('[table]', '<table>', $string);
	$string = str_replace('[/table]', '</table>', $string);
	$string = str_replace('&', '&amp;', $string);
	
	//Extra enter weer verwijderen.
	$string = substr($string, 1);
return $string;
}


$database = 'mdb00383';
$user = 'mu000383';
$pass = '9kL7fjVp';
$dbserver = '172.16.110.131';
$dbconnect=mysql_connect($dbserver,$user,$pass);
mysql_select_db($database,$dbconnect);
?>
<rss version="2.0">
<channel>
<title>Kuorkesite</title>
<description>De officiele homepage van korfbalclub Kc de Pein uit Opeinde</description>
<link>http://www.kcdepein.nl/php</link>
<copyright>Johan van der Heide (japaveh@gmail.com)</copyright>
<language>nl-NL</language>
<managingEditor>japaveh@gmail.com</managingEditor>
<webMaster>japaveh@gmail.com</webMaster>
<?php
$getItems="SELECT nieuwsid,
    						submitter.username,
    						submitter,
    						aanpasser.username AS naam_aanpasser,
    						aantal_aangepast,
    						IP_log,
    						titel,
    						text,
    						nieuws_type.type_naam,
    						nieuws_type.type_image,
    						datum,
    						sticky
    				FROM 
    						welkom
    				LEFT JOIN nieuws_type ON nieuws_type.type_id = welkom.type
    				LEFT JOIN users AS aanpasser ON aanpasser.id = welkom.aanpasser
    				LEFT JOIN users AS submitter ON submitter.id = welkom.submitter
    				WHERE 
    						sticky <> 2 OR
    						sticky = 1
    				ORDER BY datum DESC LIMIT 10";
$doGet=mysql_query($getItems);

while($item=mysql_fetch_array($doGet))
 {
  $id=$item['nieuwsid'];
  $titel=strip_tags($item['titel']);
  $body=strip_tags($item['text']);
  $body=str_replace('&', '&amp;', $item['text']);
  $pubDate=date("d M Y",$item['datum']);
  $pubDate=strftime("%a, %d %b %Y %T %z",$item['pubDate']);

  // output to client
	
?>

  <item>
  <title><?php print $titel; ?></title>
  <description><?php print $body; ?></description>
  <link>http://www.kcdepein.nl/index.php?page=welkom&amp;mode=view_reactie&amp;berichtid=<?php print $id; ?></link> 
  </item>

<?php
  } 
?>

</channel>
</rss>
