/
home2
/
reumatologia
/
public_html
/
admin
/
Upload File
HOME
<?php require_once('../inc_library.php'); /* obtenemos datos enviados */ $IdContenido = intval($_REQUEST['IdContenido']); $IdCategoria = intval($_REQUEST['IdCategoria']); $IdSeccion = intval($_REQUEST['IdSeccion']); $IdSubseccion = intval($_REQUEST['IdSubseccion']); $Fecha = strval($_REQUEST['Fecha']); $Titulo = strval($_REQUEST['Titulo']); $Cuerpo = strval($_REQUEST['Cuerpo']); $Disponible = intval($_REQUEST['Disponible']); $Orden = intval($_REQUEST['Orden']); $arrKeywords = $_REQUEST['keyword']; $Submit = (isset($_REQUEST['Submitted'])); /* declaramos e instanciamos variables necesarias */ $err = 0; $oContenidos = new Contenidos(); $oKeywords = new Keywords(); /* verificamos si existe el registro */ if (!$oContenido = $oContenidos->GetById($IdContenido)) { header('Location: json-registros.php' . $strParams); exit; } /* validaciones... */ if ($Fecha == '') $err |= 2; if ($Titulo == '') $err |= 4; /* si no hay ningun error... */ if ($err == 0) { $Archivo = $_FILES['Archivo']; /* si no hay errores... */ if ($Archivo['name'] != '') { if ($Archivo['error'] != 1) { $oUpload = new Up ( $Archivo['name'], $Archivo['tmp_name'], $Archivo['size'], $Archivo['type'], Contenido::PathFile ); } } if (!$oUpload || $oUpload->UploadFile()) { $oContenido->IdCategoria = $IdCategoria; $oContenido->IdSeccion = $IdSeccion; $oContenido->IdSubseccion = $IdSubseccion; $oContenido->Fecha = $Fecha; $oContenido->Titulo = $Titulo; $oContenido->Cuerpo = $Cuerpo; $oContenido->Disponible = $Disponible; $oContenido->Orden = $Orden; $oContenido->Archivo = $oUpload ? $oUpload->GetNombre() : $oContenido->Archivo; /* modificamos el registro */ $oContenidos->Update($oContenido); $oKeywords->DeleteByIdContenido($oContenido->IdContenido); if ($arrKeywords) { foreach ($arrKeywords as $keyword) { $oKeyword = new Keyword(); $oKeyword->IdContenido = $oContenido->IdContenido; $oKeyword->Nombre = $keyword; $oKeywords->Create($oKeyword); } } header('Content-type: application/json'); echo json_encode(array("Success" => true, "Error" => "")); } else { print_r($oUpload); header('Content-type: application/json'); echo json_encode(array("Success" => false, "Error" => utf8_encode($err. "Error al procesar el archivo."))); } } else { header('Content-type: application/json'); echo json_encode(array("Success" => false, "Error" => utf8_encode($err. "Error al crear el evento."))); } ?>