<?xml version="1.0" encoding="utf-8" ?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
<channel>
  <title>Axis Communications technology &amp; product news</title>
  <link>http://www.axis.com</link>
  <description>Axis Communications technology &amp; product news</description>
  <image>
      <title>Axis Communications technology &amp; product news</title>
      <url>http://www.axis.com/core/graphics/axis_logo.gif</url>
      <link>http://www.axis.com</link>
      <width>96</width>
      <height>34</height>
  </image>
<?
$path = $_SERVER[DOCUMENT_ROOT] . '/corporate/press/industry_news/articles';
//$path = '../../corporate/press/industry_news/articles';
$dh = opendir( $path ); 
$maxItems = 10; //how many items to show in feed 
$GAargs = "&amp;utm_source=rss_technology&amp;utm_medium=rss&amp;utm_campaign=rss";

// Loop through the directory     
while(  $file = readdir( $dh )  ){ 
	if( !is_dir($file)){ // Check that this file is not a dir
		if($file != "_derived") // Some hidden folder? Anyway we don't want it in our array
			$file_list[] = $file;
	}
}
closedir($dh);
rsort($file_list);
//var_dump($file_list); //debug

$date_format = "D, d M Y H:i:s O";
$rows = count($file_list);
if($_GET['lines']){
	$rows = $_GET['lines'];
}else{
	$rows = count($file_list);
}

if($rows > $maxItems)
	$rows = $maxItems;

for($i=0;$i < $rows; $i++){
	$line_date_unix = mktime(0,0,0,substr($file_list[$i],2,2),substr($file_list[$i],4,2),substr($file_list[$i],0,2));
	echo("<item>\n");	
		
	$included_file = $_SERVER[DOCUMENT_ROOT]."/corporate/press/industry_news/articles/".$file_list[$i];

	//--- Read the including file ---
	$file = fopen($included_file,"rb");
	$str = fread($file,(filesize($included_file)/2)); //read half of the content in file
	fclose($file);

	//--- Find the title tag ---
	preg_match("/<h1[^>]*>(.*)<\/h1>/i", $str, $arr);
	$title = strip_tags($arr[1]); //what's between the () in regexp
	$title = str_replace("\n", "", $title);
	$title = str_replace("\t", " ", $title);
	$title = str_replace("\r", "", $title);
	//--- Get sample text ---
	$temp = strpos($str, "</h1>");
	$descr = trim(strip_tags(substr($str, $temp, 350)));
	$descr = stripslashes($descr);
	$descr = str_replace("&nbsp;", " ", $descr);
	$descr = str_replace("\n", " ", $descr);
	$descr = str_replace("\r", " ", $descr);
	
	$descr = preg_replace("/[^\w \.,!\?\-\'\(\)\"]/","",$descr);
	
	$position = strrpos($descr, " "); //find the position of last whitespace in string
	$descr = substr($descr, 0, $position); //cut the string to the last whitespace, to avoid that words break in the middle
	echo("<title>".stripslashes($title)."</title>\n");
	echo("<link>http://www.axis.com/corporate/press/industry_news/article.php?article=".$file_list[$i] . $GAargs ."</link>\n");
	echo("<description>" . $descr . " [...]</description>\n");
	$date = date($date_format,$line_date_unix);
	echo("<pubDate>".$date."</pubDate>\n");
	echo("<guid>http://www.axis.com/corporate/press/industry_news/article.php?article=".$file_list[$i]. $GAargs . "</guid>\n");
	echo("</item>\n");
}
?>
</channel>
</rss>
