$idioma = $_GET['lang']; if ($idioma != "") { setcookie("cabello_idioma", $idioma, time()+3600*24*365); $_COOKIE['cabello_idioma'] = $idioma; } if ($_COOKIE['cabello_idioma'] != "") { $lengua = $_COOKIE['cabello_idioma']; } ?> function truncate2($string, $limit, $break=".", $pad="...") { if(strlen($string) <= $limit) return $string; if(false !== ($breakpoint = strpos($string, $break, $limit))) { if($breakpoint < strlen($string) - 1) { $string = substr($string, 0, $breakpoint) . $pad; } } return $string; } function lectorRSS($url,$elementos=6,$inicio=0) { $cache_version = "cache/" . basename($url); $archivo = fopen($url, 'r'); stream_set_blocking($archivo,true); stream_set_timeout($archivo, 5); $datos = stream_get_contents($archivo); $status = stream_get_meta_data($archivo); fclose($archivo); /*$datos=file_get_contents($url); echo strlen($datos);*/ if ($status['timed_out']) { $noticias = simplexml_load_file($cache_version); } else { $archivo_cache = fopen($cache_version, 'w'); fwrite($archivo_cache, $datos); fclose($archivo_cache); $noticias = simplexml_load_string($datos); } $ContadorNoticias=1; foreach ($noticias->channel->item as $noticia) { if($ContadorNoticias<$elementos){ if($ContadorNoticias>$inicio){ $pubDate = $noticia->pubDate; $pubDate = strftime("%d-%m-%Y", strtotime($pubDate)); if (str_word_count($noticia->description) < 30) { $noticia->description = "Accede para leer la noticia"; } echo "
".truncate2(($noticia->description), 200, " ", " [..]")."
"; echo ""; } $ContadorNoticias = $ContadorNoticias + 1; } } } ?>