<?PHP
 
    //SET XML HEADER
    header('Content-type: text/xml');
 
    //CONSTRUCT RSS FEED HEADERS
    $output = '<rss version="2.0">';
    $output .= '<channel>';
    $output .= '<title>Oy konewuorio Ab:n uutisia</title>';
    $output .= '<description>Uutisia</description>';
    $output .= '<link>http://www.konewuorio.fi/</link>';
    $output .= '<copyright>Konewuorio oy 2009</copyright>';
 
require_once('Connections/conn_konewuorio.php'); 
// Original PHP code by Chirp Internet: www.chirp.com.au
// Please acknowledge use of this code by including this header. 
function myTruncate($string, $limit, $break=".", $pad="...")
{
// return with no change if string is shorter than $limit  
if(strlen($string) <= $limit) return $string; 
// is $break present between $limit and the end of the string?  
if(false !== ($breakpoint = strpos($string, $break, $limit))) {
	if($breakpoint < strlen($string) - 1) {
		$string = substr($string, 0, $breakpoint) . $pad;
		}
	}
return $string; }

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_conn_konewuorio, $conn_konewuorio);
$query_rs_nyheter = "SELECT * FROM tbl_nyheter";
$rs_nyheter = mysql_query($query_rs_nyheter, $conn_konewuorio) or die(mysql_error());
$row_rs_nyheter = mysql_fetch_assoc($rs_nyheter);
$totalRows_rs_nyheter = mysql_num_rows($rs_nyheter);
 
 
    //BODY OF RSS FEED
do {
   $output .= '<item>';
        $output .= '<title>'.$row_rs_nyheter['Rubrik_FIN'].'</title>';
        $output .= '<link>http://www.konewuorio.fi/nyhet.php?id='.$row_rs_nyheter['id'].'</link>';
        $output .= '<pubDate>'.$row_rs_nyheter['Syns_fran'].'</pubDate>';
        $output .= '<description>'.strip_tags($row_rs_nyheter['Nyhet_FIN']).'</description>';
   $output .= '</item> ';
} while ($row_rs_nyheter = mysql_fetch_assoc($rs_nyheter));
 
    //CLOSE RSS FEED
   $output .= '</channel>';
   $output .= '</rss>';
 
    //SEND COMPLETE RSS FEED TO BROWSER
    echo($output);
 
?>
