HEX
Server: Apache
System: Linux pdx1-shared-a1-06 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: ednermusika (2886498)
PHP: 8.4.2
Disabled: NONE
Upload Files
File: /home/ednermusika/ednergranados.com/admin/testimonios_guardar.php
<?php require_once('../Connections/con_edner.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

include('funciones_archivos.php');
$slash					= "/";
$raiz					= "../";
$carpeta_testimonios		= $_POST['tes_ruta'];
$carpeta_testimonios_imagenes	= "testimonio_".$_POST['tes_consecutivo'];
if (!is_dir($raiz.$carpeta_testimonios))
	mkdir($raiz.$carpeta_testimonios, 0777);
if (!is_dir($raiz.$carpeta_testimonios.$slash.$carpeta_testimonios_imagenes))
	mkdir($raiz.$carpeta_testimonios.$slash.$carpeta_testimonios_imagenes, 0777);
$archivo_imagen			= $_FILES['tes_imagen']['name'];
if ($archivo_imagen==""){
	$archivo_imagen	= $_POST['tes_imagen_anterior'];
}
else{
	$temporal 		= $_FILES['tes_imagen']['tmp_name'];
	$archivo_subir	= $raiz.$carpeta_testimonios.$slash.$carpeta_testimonios_imagenes.$slash.$archivo_imagen;
	$upload			= f_subir_archivo ( $temporal, $archivo_subir );
	if (!$upload) {
       echo "<h5>Error al tratar de subir el archivo</h5>";
   	}
	$tn_ancho 	= 200; //210
	$tn_altura	= 200; //170
	//$orientacion	= f_recuperar_orientacion($raiz.$carpeta_testimonios.$slash.$carpeta_testimonios_imagenes.$slash.$archivo_imagen);
	f_generar_thumbnail($raiz.$carpeta_testimonios.$slash.$carpeta_testimonios_imagenes, $archivo_imagen, "tn_", $tn_ancho, $tn_altura);
	$archivo_imagen 		= "tn_".$archivo_imagen;
}
echo '<h3>Procesando...</h3>';
//RECUPERANDO LOS VALORES
$ruta			= $carpeta_testimonios.$slash.$carpeta_testimonios_imagenes.$slash;
$descripcion	= str_replace ( "<p>", "", $_POST['tes_descripcion']);
$descripcion	= str_replace ( "</p>", "", $descripcion);
if($_POST['accion']=='A'){
	$querySQL = sprintf("INSERT INTO testimonio (tes_consecutivo, usu_consecutivo, tes_descripcion, tes_autor, tes_puesto, tes_ruta, tes_imagen, tes_orden, tes_activo) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['tes_consecutivo'], "int"),
                       GetSQLValueString($_POST['usu_consecutivo'], "int"),
					   GetSQLValueString($descripcion, "text"),
					   GetSQLValueString($_POST['tes_autor'],"text"),
                       GetSQLValueString($_POST['tes_puesto'], "text"),
                       GetSQLValueString($ruta, "text"),
                       GetSQLValueString($archivo_imagen, "text"),
                       GetSQLValueString($_POST['tes_orden'], "int"),
                       GetSQLValueString($_POST['tes_activo'], "int"));
}
else{
	$querySQL = sprintf("UPDATE testimonio SET usu_consecutivo=%s, tes_descripcion=%s, tes_autor=%s, tes_puesto=%s, tes_ruta=%s, tes_imagen=%s, tes_orden=%s, tes_activo=%s WHERE tes_consecutivo=%s",
                       GetSQLValueString($_POST['usu_consecutivo'], "int"),
					   GetSQLValueString($descripcion, "text"),
					   GetSQLValueString($_POST['tes_autor'],"text"),
                       GetSQLValueString($_POST['tes_puesto'], "text"),
                       GetSQLValueString($ruta, "text"),
                       GetSQLValueString($archivo_imagen, "text"),
                       GetSQLValueString($_POST['tes_orden'], "int"),
                       GetSQLValueString($_POST['tes_activo'], "int"),
					   GetSQLValueString($_POST['tes_consecutivo'], "int"));
}
mysql_select_db($database_con_edner, $con_edner);
$Result1 = mysql_query($querySQL, $con_edner) or die(mysql_error());

$queryGoTo = "testimonios_admin.php";
if (isset($_SERVER['QUERY_STRING'])) {
	$queryGoTo .= (strpos($queryGoTo, '?')) ? "&" : "?";
	$queryGoTo .= $_SERVER['QUERY_STRING'];
}

?>
<script type="text/javascript">
document.location.href="<?php echo $queryGoTo ?>";
</script>