<?

	function cut($text)
	{	
		if (strlen($text) >= 300)
		{
			$text = substr($text, 0, 300);
			$pos = strrpos($text, " ");
			$text = substr($text, 0, $pos)." ...";
		}
			
		return $text;	
	}
		
	function minutes($secs) 
	{
		if ($secs<0) return false;
		    
		$m = (int)($secs / 60); 
		$s = $secs % 60;
		$h = (int)($m / 60); 
		$m = $m % 60;
		    
		$text = "";
		if ($h > 0)
			$text = $h.":";
		        
		if (strlen($s)==1)
		   	$s = "0".$s;
		return $text.$m.":".$s;
	}
		
		
	function getContent($url) 
	{
		$sesion = curl_init($url);

		curl_setopt($sesion, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($sesion, CURLOPT_FOLLOWLOCATION, 1);
		curl_setopt($sesion, CURLOPT_TIMEOUT, 5);
		curl_setopt($sesion, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7');
		
		$result = curl_exec($sesion);
		
		curl_close($sesion);
		
		return $result;
	}
	
	
	function getFeed($feed) 
	{
		$content = getContent($feed);
		$dom = new DOMDocument('1.0', 'utf-8');
		@$dom->loadXML($content);
		return $dom;
	}
		
?>