'; $pag_title='Blog - probagro.com'; $pag_img='https://probagro.com/templates/yoo_avanti/apple_touch_icon.png'; $pag_metakey=''; $pag_metadesc=''; $to_print=''; if ($articulo=="" && $categoria=="") {///////////////SE MUESTRA EL BLOG COMPLETO $archivo = file_get_contents('https://blog.medioscorp.net/api/?key='.$api_key.'&pag='.$api_url.''); $archivo = preg_replace('/\s+/', ' ', $archivo); $archivo = str_replace("\n", "", $archivo); $archivo = str_replace("'", '"', $archivo); for ($i = 0; $i <= 31; ++$i) { $archivo = str_replace(chr($i), "", $archivo); } $archivo = str_replace(chr(127), "", $archivo); if (0 === strpos(bin2hex($archivo), 'efbbbf')) { $archivo = substr($archivo, 3); } $jsonData = json_decode($archivo); if (!empty($jsonData->categorias)) {//////////////////////VISTA DE CATEGORIAS foreach ($jsonData->categorias as $key => $value) { //echo "

".$key.";

"; $cat_nombre = utf8_decode($value->nombre); $cat_alias = utf8_decode($value->alias); $cat_descripcion = utf8_decode($value->descripcion); $cat_img = utf8_decode($value->img); $cat_portada = utf8_decode($value->portada); $cat_articulos = utf8_decode($value->articulos); $to_print.='

'.$cat_nombre.'

'; } }/////////////////////////////////////////////////////////VISTA DE CATEGORIAS elseif (!empty($jsonData->articulos)) {///////////////////VISTA DE ARTICULOS foreach ($jsonData->articulos as $key => $value) { $status = intval($value->status); if ($status === 1) continue; $art_publish_down = utf8_decode($value->publish_down); if (comprobarFecha($art_publish_down) === false) continue; $art_catego = utf8_decode($value->catego); $art_titulo = utf8_decode($value->titulo); $art_alias = utf8_decode($value->alias); $art_introtext = utf8_decode($value->introtext); $art_created = utf8_decode($value->created); $art_publish_up = utf8_decode($value->publish_up); $art_img_b = utf8_decode($value->img_b); $img_t = utf8_decode($value->img_t); $to_print.='

'.$art_titulo.'

'; }/////////////////////////////////////////////////////////VISTA DE ARTICULOS } }//////////////////////////////////SE MUESTRA EL BLOG COMPLETO elseif($categoria!="") {//////////////////////////////SE MUESTRA LOS ARTICULOS DE 1NA SOLA CATEGORIA $archivo_cat = file_get_contents('https://blog.medioscorp.net/api/?key='.$api_key.'&pag='.$api_url.'&alias_cat='. $categoria .''); $archivo_cat = preg_replace('/\s+/', ' ', $archivo_cat); $archivo_cat = str_replace("\n", "", $archivo_cat); $archivo_cat = str_replace("'", '"', $archivo_cat); for ($i = 0; $i <= 31; ++$i) { $archivo_cat = str_replace(chr($i), "", $archivo_cat); } $archivo_cat = str_replace(chr(127), "", $archivo_cat); if (0 === strpos(bin2hex($archivo_cat), 'efbbbf')) { $archivo_cat = substr($archivo_cat, 3); } $jsonData_cat = json_decode($archivo_cat); if (!empty($jsonData_cat->categoria)) {//////////////////////VISTA DE CATEGORIAS foreach ($jsonData_cat->categoria as $key => $value) { //echo "

".$key.";

"; $cat_nombre = utf8_decode($value->nombre); $cat_alias = utf8_decode($value->alias); $cat_descripcion = utf8_decode($value->descripcion); $cat_img = utf8_decode($value->img); $cat_portada = utf8_decode($value->portada); if ($cat_portada !== "Sin imagen") { $to_print.=''; } $to_print.=$SHARE_BUTTONSS; $to_print.='

'.$cat_nombre.'

'; $cat_articulos = $value->articulos; foreach ($cat_articulos as $key => $value) { $status = intval($value->status); if ($status === 1) continue; $art_publish_down = utf8_decode($value->publish_down); if (comprobarFecha($art_publish_down) === false) continue; $art_catego = utf8_decode($value->catego); $art_titulo = utf8_decode($value->titulo); $art_alias = utf8_decode($value->alias); $art_introtext = utf8_decode($value->introtext); $art_created = utf8_decode($value->created); $art_publish_up = utf8_decode($value->publish_up); $art_img_b = utf8_decode($value->img_b); $img_t = utf8_decode($value->img_t); $to_print.='

'.$art_titulo.'

'; } } } }/////////////////////////////////////////////////////SE MUESTRA LOS ARTICULOS DE 1NA SOLA CATEGORIA elseif($articulo!="") {//////////////////////////////SE MUESTRA UN SOLO ARTICULO. $archivo_art = file_get_contents('https://blog.medioscorp.net/api/?key='.$api_key.'&pag='.$api_url.'&alias_art='. $articulo .''); $archivo_art = preg_replace('/\s+/', ' ', $archivo_art); $archivo_art = str_replace("\n", "", $archivo_art); $archivo_art = str_replace("'", '"', $archivo_art); for ($i = 0; $i <= 31; ++$i) { $archivo_art = str_replace(chr($i), "", $archivo_art); } $archivo_art = str_replace(chr(127), "", $archivo_art); if (0 === strpos(bin2hex($archivo_art), 'efbbbf')) { $archivo_art = substr($archivo_art, 3); } //$to_print .= $archivo_art; $jsonData_art = json_decode($archivo_art); if (!empty($jsonData_art->articulo)) { foreach ($jsonData_art->articulo as $key => $value) { $status = intval($value->status); if ($status === 1) break; $art_publish_down = utf8_decode($value->publish_down); if (comprobarFecha($art_publish_down) === false) break; $json_youtube = $value->art_videos; $json_twitter = $value->art_twitters; $json_facebook = $value->art_facebook; $art_id = utf8_decode($value->id); $art_titulo = utf8_decode($value->titulo); $art_alias = utf8_decode($value->alias); $art_introtext = utf8_decode($value->introtext); $art_fulltext = utf8_decode($value->fulltext); $art_texto = $art_introtext . $art_fulltext; $art_texto = ponerVideo($art_texto, $json_youtube, $json_twitter, $json_facebook); /*$art_introtext = ponerVideo($art_introtext, $json_youtube, $json_twitter, $json_facebook); $art_fulltext = ponerVideo($art_fulltext, $json_youtube, $json_twitter, $json_facebook);*/ $art_publish_up = utf8_decode($value->publish_up); $art_img_b = utf8_decode($value->img_b); $art_metakey = utf8_decode($value->metakey); $art_metadesc = utf8_decode($value->metadesc); $art_metadata = utf8_decode($value->metadata); $alias_img = $value->info_img->img_b->alias; $o_img = $value->info_img->img_b->orienta; $t_img = $value->info_img->img_b->tamano; $pag_title = $art_titulo; $pag_img = $art_img_b . ''; $pag_metakey = $art_metakey; $pag_metadesc = $art_metadesc; $formato_text .= addslashes(strip_tags($art_introtext)); $formato_text .= addslashes(strip_tags($art_fulltext)); $fecha_t.= str_replace(' ', 'T', $art_publish_up); $fecha_completa=explode(" ", $art_publish_up); $fecha_sola=$fecha_completa[0]; $fecha_sola_f = date("d/m/Y", strtotime($fecha_sola)); $orienta = (!empty($o_img)) ? "i_" . strtolower($o_img) : "i_centro"; $tamano = (!empty($t_img)) ? "i_" . $t_img : "i_100"; $clases = $orienta . " " . $tamano; $to_print.='

'.$art_titulo.'

'; $to_print.=$SHARE_BUTTONSS; if ($art_img_b !== "Sin imagen") { $to_print.=''. $alias_img .''; } $to_print.='

Fecha de '.utf8_decode('Publicación').': '.$fecha_sola_f.'

'.$art_texto.'
'; $to_print.=datos_estructurados('blog?articulo='.$art_alias, $art_titulo, $art_img_b, $formato_text, $fecha_t); $fecha = obtenerFecha(); add_hit($art_id, $fecha); } } }//////////////////////////////////SE MUESTRA UN SOLO ARTICULO if ($to_print == "") { $to_print.= utf8_decode('

Contenido dañado o no existe.

'); } sleep(2); ?> <? echo utf8_encode($pag_title);?>
'; return $texto; } function ponerVideo($texto, $j_youtube, $j_twitter, $j_facebook) { $datos_youtube = array(); $datos_twitter = array(); $datos_facebook = array(); $texto1 = explode("[", $texto); $cont = count($texto1); $id_video = ""; $id_twitter = ""; $id_facebook = ""; for ($i = 0; $i < $cont; $i++) { if (substr($texto1[$i], 0, 10) === "##youtube:") { $info_video = substr($texto1[$i], 10, 11); $img = ""; foreach ($j_youtube->videos as $key => $value ) { if ($info_video === $value->id) { $id_video = $value->id; $img = $value->img; break; } } if ($id_video !== "" && $img !== "") { $video = "[##youtube:" . $id_video . "**]"; $info = '
'; $texto = str_replace($video, $info, $texto); } } else if (substr($texto1[$i], 0, 10) === "##twitter:") { $info_twitter = substr($texto1[$i], 10, 19); $url_twitter = ""; foreach ($j_twitter->twitters as $key => $value ) { if ($info_twitter === $value->id) { $id_twitter = $value->id; $url_twitter = $value->url; break; } } if ($id_twitter !== "" && $url_twitter !== "") { $twitter = "[##twitter:" . $id_twitter . "**]"; $info = '
'; $texto = str_replace($twitter, $info, $texto); } } else if (substr($texto1[$i], 0, 11) === "##facebook:") { //$info_facebook = substr($texto1[$i], 11, (strpos('*') - 11)); $texto_1 = explode(":", $texto1[$i]); $texto_2 = explode("*", $texto_1[1]); $info_facebook = $texto_2[0]; $url_facebook = ""; foreach ($j_facebook->facebook as $key => $value ) { if ($info_facebook === $value->id) { $id_facebook = $value->id; $url_facebook = $value->url; break; } } if ($id_facebook !== "" && $url_facebook !== "") { $facebook = "[##facebook:" . $id_facebook . "**]"; $info = '
'; $texto = str_replace($facebook, $info, $texto); } } } return $texto; } function ponerVideo2($texto) { $texto1 = explode("[", $texto); $cont = count($texto1); $id_video = ""; for ($i = 0; $i < $cont; $i++) { if (strpos($texto1[$i], "##youtube:") !== false) { $id_video = substr($texto1[$i], 10, 11); if ($id_video !== "") { $info = '
'; $texto = str_replace($video, $info, $texto); } } } return $texto; } function prueba($archivo) { $result = str_split($archivo); for ($i = 0; $i < count($result); $i++) { $found = false; if ($result[$i] == '"') { if ($result[$i + 1] != ":" && $result[$i + 1] != "," && $result[$i - 1] != "{" && $result[$i - 1] != '"' && $result[$i + 1] != "}" && $result[$i - 1] != ":" && $result[$i - 1] != ",") $result[$i] = ""; } } $edited = implode("", $result); $edited = str_replace('"' , "" , $edited); $edited = str_replace("\\" , "" , $edited); $edited = str_replace("n" , "" , $edited); return $edited; } function cambiar($archivo) { $archivo = str_replace('\"', '9999', $archivo); $archivo = stripslashes($archivo); } function remplazar($mensaje) { $mensaje = str_replace("á","á",$mensaje); $mensaje = str_replace("é","é",$mensaje); $mensaje = str_replace("í","í",$mensaje); $mensaje = str_replace("ó","ó",$mensaje); $mensaje = str_replace("ú","ú",$mensaje); $mensaje = str_replace("ü","ü",$mensaje); $mensaje = str_replace("ñ","ñ",$mensaje); $mensaje = str_replace("Á","Á",$mensaje); $mensaje = str_replace("É","É",$mensaje); $mensaje = str_replace("Í","Í",$mensaje); $mensaje = str_replace("Ó","Ó",$mensaje); $mensaje = str_replace("Ú","Ú",$mensaje); $mensaje = str_replace("Ü","Ü",$mensaje); $mensaje = str_replace("Ñ","Ñ",$mensaje); return $mensaje; } function comprobarFecha($fecha_desp) { $fecha_default = "0000-00-00 00:00:00"; if (!($fecha_desp === $fecha_default || strcmp($fecha_desp, $fecha_default) === 0)) { return validarFecha($fecha_desp); } else { return true; } } function validarFecha($fecha_desp) { $segundos_diferencia = obtenerSegundos($fecha_desp); return ($segundos_diferencia > 0); } function obtenerSegundos($fecha_desp) { $fechaFinal = $fecha_desp; $segundos = strtotime($fechaFinal) - strtotime("now"); $segundos = $segundos + 25200; return intval($segundos); } function getBrowser(){ $u_agent = $_SERVER['HTTP_USER_AGENT']; $bname = 'Unknown'; $platform = 'Unknown'; $version= ""; //First get the platform? if (preg_match('/linux/i', $u_agent)) { $platform = 'linux'; } elseif (preg_match('/macintosh|mac os x/i', $u_agent)) { $platform = 'mac'; } elseif (preg_match('/windows|win32/i', $u_agent)) { $platform = 'windows'; } echo ""; // Next get the name of the useragent yes seperately and for good reason if(preg_match('/MSIE/i',$u_agent) && !preg_match('/Opera/i',$u_agent)) { $bname = 'Internet Explorer'; $ub = "MSIE"; } elseif(preg_match('/Edge/i',$u_agent)) { $bname = 'Edge'; $ub = "Edge"; } elseif(preg_match('/OPR/i',$u_agent)) { $bname = 'Opera'; $ub = "Opera"; } elseif(preg_match('/Firefox/i',$u_agent)) { $bname = 'Mozilla Firefox'; $ub = "Firefox"; } elseif(preg_match('/Chrome/i',$u_agent)) { $bname = 'Google Chrome'; $ub = "Chrome"; } elseif(preg_match('/Safari/i',$u_agent)) { $bname = 'Apple Safari'; $ub = "Safari"; } elseif(preg_match('/Opera/i',$u_agent)) { $bname = 'Opera'; $ub = "Opera"; } elseif(preg_match('/Netscape/i',$u_agent)) { $bname = 'Netscape'; $ub = "Netscape"; } // finally get the correct version number $known = array('Version', $ub, 'other'); $pattern = '#(?' . join('|', $known) . ')[/ ]+(?[0-9.|a-zA-Z.]*)#'; if (!preg_match_all($pattern, $u_agent, $matches)) { // we have no matching number just continue } // see how many we have $i = count($matches['browser']); if ($i != 1) { //we will have two since we are not using 'other' argument yet //see if version is before or after the name if (strripos($u_agent,"Version") < strripos($u_agent,$ub)){ $version= $matches['version'][0]; } else { $version= $matches['version'][1]; } } else { $version= $matches['version'][0]; } // check if we have a number if ($version==null || $version=="") {$version="?";} return array( 'userAgent' => $u_agent, 'name' => $bname, 'version' => $version, 'platform' => $platform, 'pattern' => $pattern ); } function add_hit($id, $HOY){ $ip=""; if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip = $_SERVER['REMOTE_ADDR']; } $mysqli = new mysqli('blog.medioscorp.net', 'mediosco_blogapi', 'oUkwcGWi.pL9nRqUJ+mF0C', 'mediosco_blog'); $ua=getBrowser(); $query = $mysqli->query(" INSERT INTO `hits` (`artic_id`, `fecha`, `ip`, `browser`, `version`, `platform`, `pattern`, `reports`) VALUES ('".$id."', '".$HOY."', '".$ip."', '".$ua['name']."', '".$ua['version']."', '".$ua['platform']."', '".$ua['pattern']."', '".$ua['userAgent']."'); "); } function obtenerFecha() { $date = new DateTime(); $date->modify('-7 hours'); return $date->format("Y-m-d H:i:s"); } ?>