function sanear_string($string) { $string = trim($string); $string = str_replace( array('á', 'à', 'ä', 'â', 'ª', 'Á', 'À', 'Â', 'Ä'), array('a', 'a', 'a', 'a', 'a', 'A', 'A', 'A', 'A'), $string ); $string = str_replace( array('é', 'è', 'ë', 'ê', 'É', 'È', 'Ê', 'Ë'), array('e', 'e', 'e', 'e', 'E', 'E', 'E', 'E'), $string ); $string = str_replace( array('í', 'ì', 'ï', 'î', 'Í', 'Ì', 'Ï', 'Î'), array('i', 'i', 'i', 'i', 'I', 'I', 'I', 'I'), $string ); $string = str_replace( array('ó', 'ò', 'ö', 'ô', 'Ó', 'Ò', 'Ö', 'Ô'), array('o', 'o', 'o', 'o', 'O', 'O', 'O', 'O'), $string ); $string = str_replace( array('ú', 'ù', 'ü', 'û', 'Ú', 'Ù', 'Û', 'Ü'), array('u', 'u', 'u', 'u', 'U', 'U', 'U', 'U'), $string ); $string = str_replace( array('ñ', 'Ñ', 'ç', 'Ç'), array('n', 'N', 'c', 'C',), $string ); //Esta parte se encarga de eliminar cualquier caracter extraño $string = str_replace( array("\\", "¨", "º", "~", "#", "@", "|", "!", "\"", "·", "$", "%", "&", "/", "(", ")", "?", "'", "¡", "¿", "[", "^", "`", "]", "+", "}", "{", "¨", "´", ">", "< ", ";", ",", ":", "."), '', $string ); return $string; } function clean($string) { $string = str_replace(' ', '-', $string); // Replaces all spaces with hyphens. $string = preg_replace('/[^A-Za-z0-9\- ]/', '', $string); // Removes special chars. return preg_replace('/-+/', '-', $string); // Replaces multiple hyphens with single one. } $mesesShort = array("Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"); $meses = array("Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"); $diasShort = array("Lun","Mar","Mie","Jue","Vie","Sab","Dom"); $dias = array("Lunes","Martes","Miércoles","Jueves","Viernes","Sábado","Domingo"); ?> if (!function_exists('http_response_code')) { function http_response_code($code = NULL) { if ($code !== NULL) { switch ($code) { case 100: $text = 'Continue'; break; case 101: $text = 'Switching Protocols'; break; case 200: $text = 'OK'; break; case 201: $text = 'Created'; break; case 202: $text = 'Accepted'; break; case 203: $text = 'Non-Authoritative Information'; break; case 204: $text = 'No Content'; break; case 205: $text = 'Reset Content'; break; case 206: $text = 'Partial Content'; break; case 300: $text = 'Multiple Choices'; break; case 301: $text = 'Moved Permanently'; break; case 302: $text = 'Moved Temporarily'; break; case 303: $text = 'See Other'; break; case 304: $text = 'Not Modified'; break; case 305: $text = 'Use Proxy'; break; case 400: $text = 'Bad Request'; break; case 401: $text = 'Unauthorized'; break; case 402: $text = 'Payment Required'; break; case 403: $text = 'Forbidden'; break; case 404: $text = 'Not Found'; break; case 405: $text = 'Method Not Allowed'; break; case 406: $text = 'Not Acceptable'; break; case 407: $text = 'Proxy Authentication Required'; break; case 408: $text = 'Request Time-out'; break; case 409: $text = 'Conflict'; break; case 410: $text = 'Gone'; break; case 411: $text = 'Length Required'; break; case 412: $text = 'Precondition Failed'; break; case 413: $text = 'Request Entity Too Large'; break; case 414: $text = 'Request-URI Too Large'; break; case 415: $text = 'Unsupported Media Type'; break; case 500: $text = 'Internal Server Error'; break; case 501: $text = 'Not Implemented'; break; case 502: $text = 'Bad Gateway'; break; case 503: $text = 'Service Unavailable'; break; case 504: $text = 'Gateway Time-out'; break; case 505: $text = 'HTTP Version not supported'; break; default: exit('Unknown http status code "' . htmlentities($code) . '"'); break; } $protocol = (isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0'); header($protocol . ' ' . $code . ' ' . $text); $GLOBALS['http_response_code'] = $code; } else { $code = (isset($GLOBALS['http_response_code']) ? $GLOBALS['http_response_code'] : 200); } return $code; } } switch($seccion){ case "inicio": $pagina="inc_inicio.php"; $estamos="inicio"; $tituloPagina="$tituloSitio | Soluciones IT Corporativas"; $titulo="Inicio"; break; case "404": $pagina="inc_404.php"; $estamos="404"; $tituloPagina="$tituloSitio"; $titulo="Inicio"; break; case "contacto": $pagina="inc_contacto.php"; $tituloPagina="$tituloSitio | Contacto"; break; case "blog": $pagina="inc_blog.php"; $tituloPagina="$tituloSitio | Blog"; break; case "productos": $pagina="inc_productos.php"; $tituloPagina="$tituloSitio | Productos"; break; case "nosotros": $pagina="inc_nosotros.php"; $tituloPagina="$tituloSitio | Nosotros"; break; case "soluciones": $pagina="inc_soluciones.php"; $tituloPagina="$tituloSitio | Soluciones"; break; case "webinar-zimbra": $pagina="inc_webinar_zimbra.php"; $tituloPagina="$tituloSitio | Webinar Zimbra"; break; case "evento-zimbra": $pagina="inc_evento_zimbra.php"; $tituloPagina="$tituloSitio | Evento Zimbra"; break; case "buscar": $pagina="inc_buscar.php"; $tituloPagina="$tituloSitio | Resultados de la búsqueda"; break; default: $pagina="inc_inicio.php"; $estamos="inicio"; $tituloPagina="$tituloSitio | Soluciones IT Corporativas"; $titulo="Inicio"; break; } $error404=0; $existeNovedad=0; if((($seccion=="blog")&($id=="publicacion")&($ss!=""))|($seccion=="blog"&$cs!="")){ if($cs!=""){ $ss=$cs; } $estado=1; $sql = "SELECT novedades.id_novedad, novedades.fecha, novedades.titulo, novedades.copete, novedades.cuerpo, novedades.permalink FROM novedades INNER JOIN paises_relaciones ON paises_relaciones.novedad = novedades.id_novedad WHERE novedades.permalink = ? and novedades.estado= ? and paises_relaciones.pais = '$codigo_pais_web' "; $stmt=$conexion->prepare($sql); $stmt->bind_param('si', $ss, $estado); $stmt->execute(); $stmt->store_result(); $existeNovedad = $stmt->num_rows; $stmt->bind_result($idNovedadDB, $fechaNovedadDB, $tituloNovedadDB, $copeteNovedadDB, $cuerpoNovedadDB, $permalinkNovedadDB); while ($stmt->fetch()) { $idNovedad=$idNovedadDB; $tituloNovedad=stripslashes(htmlspecialchars($tituloNovedadDB)); $fechaNovedad=$fechaNovedadDB; $copeteNovedad=stripslashes($copeteNovedadDB); $cuerpoNovedad=stripslashes($cuerpoNovedadDB); $permalink=$permalinkNovedadDB; //echo $share; $tituloPagina="$tituloSitio | Blog | ".$tituloNovedad; $descripcionPagina=$copeteNovedad; $sql = 'SELECT id_imagen, tipo, video FROM imagenes WHERE id_novedad = ? ORDER BY orden ASC LIMIT 0, 1'; $stmt2=$conexion->prepare($sql); $stmt2->bind_param('i', $idNovedad); $stmt2->execute(); $stmt2->store_result(); $cantImagenesMini = $stmt2->num_rows; if($cantImagenesMini!=0){ $stmt2->bind_result($idImagenDB, $tipoImagenDB, $videoDB); while ($stmt2->fetch()) { $idImagen=$idImagenDB; $tipoImagen=$tipoImagenDB; $video=stripslashes(htmlspecialchars($videoDB)); $urlImagenMini="imagenes_novedades/big/$idImagen.jpg"; } }else{ $urlImagenMini="img/nofoto.jpg"; } $stmt2->close(); } $stmt->close(); if($existeNovedad==0){ $errorProd=1; } else{ $errorProd=0; } if($errorProd==1){ $error404=1; header("HTTP/1.0 404 Not Found"); http_response_code(404); } } if(($seccion=="productos")&($id!="")){ $existeProducto=0; $estado=1; $sql = "SELECT marcas.id, marcas.nombre, marcas.descripcion, marcas.permalink FROM marcas INNER JOIN paises_relaciones ON paises_relaciones.marca = marcas.id WHERE marcas.permalink = ? and marcas.estado = ? and paises_relaciones.pais = '$codigo_pais_web' "; $stmt=$conexion->prepare($sql); $stmt->bind_param('si', $id, $estado); $stmt->execute(); $stmt->store_result(); $existeMarca = $stmt->num_rows; $stmt->bind_result($idMarcaDB, $nombreMarcaDB, $descripcionMarcaDB, $permalinkMarcaDB); while ($stmt->fetch()) { $idMarcaSeccion=$idMarcaDB; $nombreMarcaSeccion=stripslashes(htmlspecialchars($nombreMarcaDB)); //$fechaNovedadSeccion=$fechaNovedadDB; $descripcionMarcaSeccion=stripslashes($descripcionMarcaDB); $permalinkMarcaSeccion=$permalinkMarcaDB; //echo $share; $tituloPagina="$tituloSitio | Productos | ".$nombreMarcaSeccion; //$descripcionPagina=$copeteNovedad; if(file_exists("imagenes_marcas/$idMarcaSeccion.jpg")){ $urlImagenMini="imagenes_marcas/$idMarcaSeccion.jpg"; } if($ss!=""){ // ESTOY DENTRO DE PRODUCTO $sql = "SELECT productos.id, productos.nombre, productos.descripcion, productos.tecnica, productos.codigo, productos.syndication, productos.permalink FROM productos INNER JOIN paises_relaciones ON paises_relaciones.producto = productos.id WHERE productos.permalink = ? and productos.estado = ? and paises_relaciones.pais = '$codigo_pais_web' "; $stmtproducto=$conexion->prepare($sql); $stmtproducto->bind_param('si', $ss, $estado); $stmtproducto->execute(); $stmtproducto->store_result(); $existeProducto = $stmtproducto->num_rows; $stmtproducto->bind_result($idProductoDB, $nombreProductoDB, $descripcionProductoDB, $tecnicaProductoDB, $codigoProductoDB, $syndicationProductoDB, $permalinkProductoDB); while ($stmtproducto->fetch()) { $idProductoSeccion=$idProductoDB; $nombreProductoSeccion=stripslashes(htmlspecialchars($nombreProductoDB)); $descripcionProductoSeccion=stripslashes($descripcionProductoDB); $tecnicaProductoSeccion=stripslashes($tecnicaProductoDB); $codigoProductoSeccion=stripslashes($codigoProductoDB); $codigoProductoSeccion=str_replace('\n',' ',$codigoProductoSeccion); $syndicationProductoSeccion=$syndicationProductoDB; $permalinkProductoSeccion=$permalinkProductoDB; $descripcionProductoSeccion=str_replace('src="/','src="',$descripcionProductoSeccion); if(file_exists("imagenes_productos/$idProductoSeccion.jpg")){ $urlImagenMini="imagenes_productos/$idProductoSeccion.jpg"; } } $stmtproducto->close(); } if($existeProducto>0){ $tituloPagina="$tituloPagina | ".$nombreProductoSeccion; } } $stmt->close(); if($existeMarca==0){ $errorProd=1; } else{ $errorProd=0; } if($errorProd==1){ $error404=1; header("HTTP/1.0 404 Not Found"); http_response_code(404); } } ?>