Warning: filemtime(): stat failed for ./data/secure/tokens/5061157af5a3730214d69126a4d556b1fac0d9aa4701d9f22654b26612707c591570f6c86e84e498441c88c8bc68f4e5a02ae95e26a48a266f6ec292fd1ccc0f.token in /home/sigesthaxo/snippetvamp/assets/php/class/Helium_secure_class.php on line 831

Warning: filemtime(): stat failed for ./data/secure/tokens/ab4ff60e12df057905fac2f826ea648359107f352d50e292bbc89d3e60bf74fe4c1a3aef2f18d837b2ae30fb594487c747617c7286918b03d66e387e2b0804e7.token in /home/sigesthaxo/snippetvamp/assets/php/class/Helium_secure_class.php on line 831

Warning: filemtime(): stat failed for ./data/secure/tokens/b7b7a02a6cbb03d2e98cab19ec99bbf1359ed629dc6ff186877e3f0533dedfc93ad3f29c60cd9259df665abf87fd7ff28f7bbb922f4abb8ed3ae7f0f631bed0b.token in /home/sigesthaxo/snippetvamp/assets/php/class/Helium_secure_class.php on line 831

Warning: filemtime(): stat failed for ./data/secure/tokens/cbafd9af4ad5ba9e8346a2edcd1002f41ada53ab3f1957afe08f7df2d80229af402519e37125b7af7c8df6a90500bdb1bbf37140cf4e5dcac1a11e668732a8dd.token in /home/sigesthaxo/snippetvamp/assets/php/class/Helium_secure_class.php on line 831

Warning: filemtime(): stat failed for ./data/secure/tokens/d44d0515a685622435310b0a7de27271eada0e51927247f28e8039a91e5228433689f5e330f0f335715848dcefc44318b8cde32631aafb3b0afed55b704ee8c7.token in /home/sigesthaxo/snippetvamp/assets/php/class/Helium_secure_class.php on line 831

Warning: filemtime(): stat failed for ./data/secure/tokens/def0de061b9ce0d1ab53728e059f4f43462d6c223b0f97c5e0a27776a1d1c997c3b578a040e2f54274039d2f5a7734eb2bc7613cc6366e3d058a4e57f25b9901.token in /home/sigesthaxo/snippetvamp/assets/php/class/Helium_secure_class.php on line 831

Warning: filemtime(): stat failed for ./data/secure/tokens/e12a64076ff6771600a0de83dee50aa6ec30d198fcd13dd1ed1be48874a304540cf17f7a68096eab6ec7595effd9e7c544d9a869867df2a6c278b2f2c813eded.token in /home/sigesthaxo/snippetvamp/assets/php/class/Helium_secure_class.php on line 831

Warning: filemtime(): stat failed for ./data/secure/tokens/f56808197655bab3c309c208049306714119799d0be54f5ab16d556d87560d8be88cacf476e4286ff0a1d3195ac677cf1a1319dbcaa12508bd8535fb117773c7.token in /home/sigesthaxo/snippetvamp/assets/php/class/Helium_secure_class.php on line 831

Warning: filemtime(): stat failed for ./data/secure/tokens/ffbaba32e996a2c7f010cf6a8e6058df49b1729bbab0bcd3e2469bdefeeef33ee41d08e18d8b7eab4ad733cc25124a80d78bb236eb8bf3c7638bf878b4b4cc34.token in /home/sigesthaxo/snippetvamp/assets/php/class/Helium_secure_class.php on line 831
SnippetVamp - open
#key - array2feed
# Array2feed 
# @author: bronco@warriordudimanche.net
# @version 0.1
# @license  free and opensource
# @inspired by  http://milletmaxime.net/syndexport/
# @use: $items=feed2array('http://sebsauvage.net/links/index.php?do=rss');
# @doc:
	# the array must have an index 'infos' and another called 'items'
	#info key
		# for rss type feed, infos must have at least the 'title', 'description', 'guid' keys
		# for atom type feed, infos must have at least the 'title', 'id', 'subtitle', 'link' keys
	# items key => array
		# for rss type feed, each item must have the 'title', 'description', 'pubDate' and 'link' keys
		# for atom type feed, info must have the 'title', 'id', 'updated, 'link' & 'content' keys 

function array2feed($array=null){


	if (!$array){return false;}
	if (empty($array['infos']['type'])){$array['infos']['type']='rss';}else{$array['infos']['type']=strtolower($array['infos']['type']);}
	if (empty($array['infos']['description'])){$array['infos']['description']='';}
	$r="n";$t="t";
	$tpl=array('rss'=>array(),'atom'=>array());
	$tpl['rss']['header']=''.$r.''.$r.$t.''.$r;
	$tpl['atom']['header']=''.$r;
	$tpl['rss']['footer']=$t.''.$r;
	$tpl['atom']['footer']=''.$r;
	$tpl['rss']['content-type']='Content-Type: application/rss+xml';
	$tpl['atom']['content-type']='Content-Type: application/atom+xml;charset=utf-8';

	header($tpl[$array['infos']['type']]['content-type']);
	$feed=$tpl[$array['infos']['type']]['header'];
		//create the feed's info content
		foreach($array['infos'] as $key=>$value){
			if ($array['infos']['type']=='atom'){ // ATOM
				if ($key=='link'){$feed.=$t.$t.''.$r;}
				elseif ($key=='author'){$feed.=$t.$t.''.$value.''.$r;}
				elseif ($key=='licence'){$feed.=$t.$t.'<'.$key.' href="'.$value.'" rel="license"/>'.$r;} // in atom feed, licence is the link to the licence type
				elseif ($key!='version'&&$key!='type'){$feed.=$t.$t.'<'.$key.'>'.$value.''.$r;}
			}else{ // RSS
				if ($key!='version'&&$key!='type'){$feed.=$t.$t.'<'.$key.'>'.$value.''.$r;}
			}
		}

		//then the items content
		foreach ($array['items'] as $item){
			if ($array['infos']['type']=='atom'){ $feed.=$t.$t.$t.''.$r;}else{$feed.=$t.$t.$t.''.$r;}
				foreach($item as $key=>$value){
					if ($array['infos']['type']=='atom'){ // ATOM
						if ($key=='link'){$feed.=$t.$t.$t.$t.''.$r;}
						elseif ($key=='content'){$feed.=$t.$t.$t.$t.''.htmlspecialchars($value).''.$r;}
						else{$feed.=$t.$t.$t.$t.'<'.$key.'>'.$value.''.$r;}
					}else{ // RSS
						if ($key=='date'||$key=='pubDate'||$key=='title'||$key=='link'){$feed.=$t.$t.$t.$t.'<'.$key.'>'.htmlspecialchars($value).''.$r;}
						elseif($key=='guid'){ $feed.=$t.$t.$t.$t.''.$value.''.$r;}
						else{$feed.=$t.$t.$t.$t.'<'.$key.'>'.$r;}
					}
				}
			if ($array['infos']['type']=='atom'){ $feed.=$t.$t.$t.''.$r;}else{$feed.=$t.$t.$t.''.$r;}
		}


	$feed.=$tpl[$array['infos']['type']]['footer'];
	return $feed;
}

$array=array(
	'infos'=>array(
			'type'=>'rss',
			'description'=>'Ceci est le test ultime de la mort',
			'title'=>'test de création de flux rss',
			'link'=>'http://www.warriordudimanche.net',
		),
	'items'=>array(
		0=>array(
				'description'=>'Ceci est le premier item du flux',
				'title'=>'item 1 : le titre',
				'link'=>'http://www.warriordudimanche.net',
				'guid'=>'http://www.warriordudimanche.net#1',
				'pubDate'=>@date('r'),// Be carefull, the rss pubDate format is specific ! RFC 2822 (see http://www.faqs.org/rfcs/rfc2822.html)
			),
		1=>array(
				'description'=>'Ceci est le second item du flux',
				'title'=>'item 2 : le retour',
				'link'=>'http://www.warriordudimanche.net',
				'guid'=>'http://www.warriordudimanche.net#2',
				'pubDate'=>@date('r'),
			),
		2=>array(
				'description'=>'Ceci est le troisième item du flux',
				'title'=>'item 3 : la revanche',
				'link'=>'http://www.warriordudimanche.net',
				'guid'=>'http://www.warriordudimanche.net#3',
				'pubDate'=>@date('r'),
			),

		)
	);



echo array2feed($array);