ClaveAudio_Web/admin/shoop/marcas_db.php

83 lines
2.4 KiB
PHP
Raw Normal View History

<?php
session_start();
if (!session_is_registered("clave_audio")) {
include("../login.php");
if (!$continuar){
header('Location: productos.php');
exit;
}
}
include('../db.php');
include('../../_incl/code.php');
include('upload.php');
if(isset($_REQUEST['op'])){
$operacion = $_REQUEST['op'];
} else { // no han pasado un c<>digo de operaci<63>n. bad yuyu
header('Location: marcas.php');
exit;
}
$id = (int) $_REQUEST['id'];
// here I read the variables passed by the calling page.
if (!get_magic_quotes_gpc()) {
$fab_nombre = addslashes($_REQUEST['fab_nombre']);
$fab_url = addslashes($_REQUEST['fab_url']);
$fab_descripcion = addslashes($_REQUEST['fab_descripcion']);
} else {
$fab_nombre = $_REQUEST['fab_nombre'];
$fab_url = $_REQUEST['fab_url'];
$fab_descripcion = $_REQUEST['fab_descripcion'];
}
$conn = db_connect();
if($conn) {
switch($operacion) {
case "add":
mysql_query('INSERT INTO shoop_fabricantes(fab_nombre, fab_url, fab_descripcion) VALUES("' . $fab_nombre . '", "' . $fab_url . '", "' . $fab_descripcion . '")');
$id = mysql_insert_id();
// subo la imagen
uploadImagenMarca($id, 81, 38);
break;
case "edit":
mysql_query('UPDATE shoop_fabricantes SET fab_nombre="' . $fab_nombre . '", fab_url="' . $fab_url . '", fab_descripcion="' . $fab_descripcion . '" WHERE fab_id = ' . $id);
// subo la imagen
uploadImagenMarca($id, 81, 38);
break;
case "del":
mysql_query('DELETE FROM shoop_fabricantes WHERE fab_id = ' . $_REQUEST['id']);
break;
default:
break;
}
exit;
// regenero el menu de marcas
$resultado = '';
// tengo que leer primero todos los c<>digos de secciones
$query = "SELECT fab_id, fab_nombre FROM shoop_fabricantes ORDER BY fab_nombre";
$result = mysql_query($query, $conn);
$num_results = mysql_num_rows($result);
for ($i=0; $i <$num_results; $i++){
$row = mysql_fetch_array($result);
$resultado .= '<option value="' . $row['fab_id'] . '">' . htmlentities($row['fab_nombre']) . '</option>' . "\n";
} // FOR
// aqu<71> tengo un texto o la nada
if(strlen($resultado)) {
// grabo el texto a un archivo
// OJO para poder grabar el archivo tiene que estar en modo 666
saveFile("../../marcas.htm", $resultado);
}
}
header('Location: marcas.php');
?>