File: /home/ednermusika/ednergranados.com/admin/galeriaaudios_detalle_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_audios = $_POST['gad_ruta'];
/*echo $_POST['gad_ruta']."works";*/
$carpeta_audios_archivo = "gad_".$_POST['gad_consecutivo'];
if (!is_dir($raiz.$carpeta_audios))
mkdir($raiz.$carpeta_audios, 0777);
if (!is_dir($raiz.$carpeta_audios.$slash.$carpeta_audios_archivo))
mkdir($raiz.$carpeta_audios.$slash.$carpeta_audios_archivo, 0777);
$archivo_media = $_FILES['gad_audio']['name'];
if ($archivo_media==""){
$archivo_media = $_POST['gad_audio_anterior'];
}
else{
$temporal = $_FILES['gad_audio']['tmp_name'];
$archivo_subir = $raiz.$carpeta_audios.$slash.$carpeta_audios_archivo.$slash.$archivo_media;
$upload = f_subir_archivo ( $temporal, $archivo_subir );
if (!$upload) {
echo "<h5>Error al tratar de subir el archivo</h5>";
}
}
echo '<h3>Procesando...</h3>';
//RECUPERANDO LOS VALORES
$ruta = $carpeta_audios.$carpeta_audios_archivo.$slash;
/*$gad_anio = substr($_POST['gad_vigencia'],6,4);
$gad_mes = substr($_POST['gad_vigencia'],3,2);
$gad_dia = substr($_POST['gad_vigencia'],0,2);
$gad_vigencia = $gad_anio.'/'.$gad_mes.'/'.$gad_dia;*/
/*if ($_POST['gad_relevante']==1){
$querySQL = sprintf("UPDATE audios SET gad_relevante=0");
mysql_select_db($database_con_edner, $con_edner);
$Result1 = mysql_query($querySQL, $con_edner) or die(mysql_error());
}*/
//
//echo ($temporal."works" );
echo $carpeta_audios;
if($_POST['accion']=='A'){
$querySQL = sprintf("INSERT INTO galeria_audio_detalle (gaa_consecutivo, gad_consecutivo, gad_titulo, gad_descripcion, gad_autor, gad_fecha, gad_ruta, gad_audio, gad_activo) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['gaa_consecutivo'], "int"),
GetSQLValueString($_POST['gad_consecutivo'], "int"),
GetSQLValueString($_POST['gad_titulo'],"text"),
GetSQLValueString($_POST['gad_descripcion'], "text"),
GetSQLValueString($_POST['gad_autor'], "text"),
GetSQLValueString($_POST['gad_fecha'], "date"),
GetSQLValueString($ruta, "text"),
GetSQLValueString($archivo_media, "text"),
GetSQLValueString($_POST['gad_activo'], "int"));
}
else{
$querySQL = sprintf("UPDATE galeria_audio_detalle SET gad_titulo=%s, gad_descripcion=%s, gad_autor=%s, gad_fecha=%s, gad_ruta=%s, gad_audio=%s, gad_activo=%s WHERE gad_consecutivo=%s and gaa_consecutivo=%s",
GetSQLValueString($_POST['gad_titulo'],"text"),
GetSQLValueString($_POST['gad_descripcion'], "text"),
GetSQLValueString($_POST['gad_autor'], "text"),
GetSQLValueString($_POST['gad_fecha'], "date"),
GetSQLValueString($ruta, "text"),
GetSQLValueString($archivo_media, "text"),
GetSQLValueString($_POST['gad_activo'], "int"),
GetSQLValueString($_POST['gaa_consecutivo'], "int"),
GetSQLValueString($_POST['gad_consecutivo'], "int"));
}
mysql_select_db($database_con_edner, $con_edner);
$Result1 = mysql_query($querySQL, $con_edner) or die(mysql_error());
$queryGoTo = "galeriaaudios_detalle_admin.php?gaa_consecutivo=".$_POST['gaa_consecutivo'];
if (isset($_SERVER['QUERY_STRING'])) {
$queryGoTo .= (strpos($queryGoTo, '?')) ? "&" : "?";
$queryGoTo .= $_SERVER['QUERY_STRING'];
}
?>
<script type="text/javascript">
document.location.href="<?php echo $queryGoTo ?>";
</script>