Ver Mensaje Individual
  #11 (permalink)  
Antiguo 14/03/2012, 10:29
mateo_disseny
 
Fecha de Ingreso: marzo-2012
Mensajes: 8
Antigüedad: 12 años, 1 mes
Puntos: 0
Respuesta: addslashes, mysql_real_escape_string o similare

Código PHP:
Ver original
  1. {
  2.                     $imagen = $old['id_imagen'];
  3.                 }
  4.  
  5.  
  6.  
  7.                 if ($oValidador -> validation())
  8.                 {
  9.                                         $id = $ofertas -> edit($id,$titulos,$descripciones1,$descripciones2,$precio,$link,$imagen);
  10.  
  11.  
  12.                     if($old['id_imagen']!= $imagen){
  13.                                             echo "eliminar imagen";
  14.                         @unlink(IMAGENES.$old['id_imagen']);
  15.                     }
  16.  
  17.                     unset($_POST);
  18.                     unset($titulos);
  19.                     unset($descripciones1);
  20.                     unset($descripciones2);
  21.                                         unset($precio);
  22.                     unset($link);
  23.                     unset($imagen);
  24.  
  25.                     mysql_close($dao -> Link_ID);
  26.                     header('location: ofertas.php?option=list');
  27.                     die;
  28.  
  29.                 }
  30.                 else
  31.                 {
  32.                     if(isset($bProcesada)) @unlink(IMAGENES.$imagen);
  33.  
  34.                     $aMensaje = $oValidador -> messages;
  35.                 }
  36.             }
  37.             else
  38.             {
  39.  
  40.                 $oferta     = $ofertas->get(getValue($_GET['o']));
  41.                                 //echo "<pre>";print_r($oferta);echo "</pre>";
  42.                 $imagen     = $ofertas->get_imagen($oferta['id_imagen']);
  43.  
  44.                                 $lang = array();
  45.                                 foreach($aIdiomas as $idioma){
  46.                                     $lang[$idioma['sub']] = $ofertas->get_lang($oferta['id'],$idioma['id']);
  47.                                 }
  48.                                 //echo "<pre>";var_dump($lang);echo "</pre>";
  49.  
  50.             }
  51.  
  52.  
  53.  
  54.             break;
  55.         case 'add':
  56.                         $aOpciones['add'] = ' class="selected"';
  57.                         $subBody = T_ADD;
  58.                         $foto_oferta = false;
  59.  
  60.  
  61.             if(!empty($_POST))
  62.             {
  63.                                 //echo "<pre>";print_r($_POST);echo "</pre>";
  64.  
  65.                 $oValidador = new Validate_fields();
  66.                 $oValidador -> language = 1;//CASTELLANO
  67.                 $oValidador -> check_4html = true;
  68.  
  69.  
  70.                 foreach ($aIdiomas as $idioma)
  71.                 {
  72.                                         $titulos[$idioma['sub']] = trim(getValue($_POST['titulo_'.$idioma['sub']]));
  73.                     $oValidador -> add_text_field('Título en '.$idioma['nombre'], $titulos[$idioma['sub']], 'text', $idioma['obligatorio']);
  74.                                         $descripciones1[$idioma['sub']] = trim(getValue($_POST['descripcion1_'.$idioma['sub']]));
  75.                     $oValidador -> add_text_field('Descripción (Línea 1) en '.$idioma['nombre'], $descripciones1[$idioma['sub']], 'text', $idioma['obligatorio']);
  76.                                         $descripciones2[$idioma['sub']] = trim(getValue($_POST['descripcion2_'.$idioma['sub']]));
  77.                     $oValidador -> add_text_field('Descripción (Línea 2) en '.$idioma['nombre'], $descripciones2[$idioma['sub']], 'text', $idioma['obligatorio']);
  78.                 };
  79.  
  80.                                 $precio = getValue($_POST['precio']);
  81.                                 $oValidador ->add_num_field("Precio ", $precio,'y');
  82.                                 $link = getValue($_POST['link_oferta']);
  83.                                 $oValidador ->add_text_field("Link ", $link,'y');
  84.                                
  85.  
  86.                 $handle = new Upload($_FILES['imagen']);
  87.  
  88.                 if($handle->uploaded)
  89.                 {
  90.  
  91.                                     $handle -> image_ratio_fill = true;
  92.                                     $handle -> image_background_color = '#ffffff';
  93.                                     $handle -> image_resize     = true;
  94.                     $handle -> image_x          = 84;
  95.                     $handle -> image_y          = 79;
  96.  
  97.                     $handle -> image_convert    = 'jpg';
  98.                                     $handle -> jpeg_quality     = 85;
  99.  
  100.                                     $handle -> process(IMAGENES);
  101.                                     $new_name = $handle->file_src_name_body;
  102.  
  103.                                     if($handle->processed)
  104.                                     {
  105.                                             $imagen = $handle ->file_dst_name;
  106.                                             $handle -> clean();
  107.                                     }
  108.                                     else
  109.                                     {
  110.                                             $oValidador -> setError('Imagen',2,$handle->error);
  111.                                     }
  112.  
  113.                 }
  114.                 else
  115.                 {
  116.                     $imagen = null;
  117.                                 }
  118.  
  119.                 if ($oValidador -> validation())
  120.                 {
  121.                                         $id = $ofertas -> add($titulos,$descripciones1,$descripciones2,$precio,$link,$imagen);
  122.  
  123.                     unset($_POST);
  124.                     unset($titulos);
  125.                     unset($descripciones1);
  126.                     unset($descripciones2);
  127.                                         unset($precio);
  128.                     unset($link);
  129.                     unset($imagen);
  130.  
  131.                     $bAdd = true;
  132.                                         $aMensaje[0] = utf8_encode("Oferta añadida");
  133.  
  134.                 }
  135.                 else
  136.                 {
  137.                     $aMensaje = $oValidador -> messages;
  138.                 }
  139.  
  140.             }else{
  141.                             $foto_oferta = false;
  142.                         }
  143.             break;
  144.  
  145.         case 'add_home':
  146.                        
  147.                         $aOpciones['add_home'] = ' class="selected"';
  148.                         $subBody = T_LISTADO;
  149.                         $mensaje = "";
  150.  
  151.                         $id = getValue($_GET['o']);
  152.                         if(!$ofertas->add_home($id))
  153.                             $mensaje = "&add_oferta=false";
  154.  
  155.                         mysql_close($dao -> Link_ID);
  156.                         header('location: ofertas.php?option=list'.$mensaje);
  157.                         die;
  158.                         break;
  159.  
  160.         case 'del_home':
  161.  
  162.                         $aOpciones['del_home'] = ' class="selected"';
  163.                         $subBody = T_LISTADO;
  164.                         $mensaje = "";
  165.  
  166.                         $id = getValue($_GET['o']);
  167.                         $ofertas->del_home($id);
  168.  
  169.                         mysql_close($dao -> Link_ID);
  170.                         header('location: ofertas.php?option=list'.$mensaje);
  171.                         die;
  172.                         break;
  173.  
  174.         case 'list':
  175.                 default :
  176.  
  177.                         $subBody = T_LISTADO;
  178.  
  179.                         if(isset($_GET['add_oferta']))
  180.                             $add_oferta = getValue($_GET['add_oferta']);
  181.                         else
  182.                             $add_oferta = true;
  183.  
  184.                         if(!intval($add_oferta))
  185.                             $mensaje = 'Debe eliminar una oferta antes de añadir otra a la home.';
  186.                         else
  187.                             $mensaje = '';
  188.  
  189.             isset($_GET['num_pag']) ? $num_pag = $_GET['num_pag'] : $num_pag = 1;
  190.             $elementos_por_pagina   = 3;
  191.             $limite                 = ($elementos_por_pagina*$num_pag)-$elementos_por_pagina;
  192.             $total_elementos        = $ofertas->get_numero_ofertas();
  193.             $aLista                 = $ofertas->_get_lista($limite,$elementos_por_pagina);
  194.             $num_elements           = count($aLista);
  195.  
  196.                         $oPaginar = new paginar();
  197.                         $sNavega_paginas = $oPaginar -> paginacion('ofertas.php?&option=list&num_pag=%d','ofertas.php?&option=list',$total_elementos,$elementos_por_pagina,$num_pag);
  198.  
  199.                         break;
  200.     }
  201.  
  202. }
  203. else
  204. {
  205.     $body = TEMPLATES_ADMIN.'t_menu.php';
  206. }
  207.  
  208. (ID_USUARI=='1') ? include(HEADER_ROOT) : include(HEADER_ADMIN);
  209.  
  210. $_POST['form_oferta_add'] = stripslashes($_POST['form_oferta_add']);
  211. }
  212. $nombre_campo_escapado = mysql_real_escape_string($_POST['form_oferta_add'])
  213.  
  214.  
  215. include(BODY);
  216. include(FOOTER_ADMIN);
  217.  
  218.  
  219. //******Incluir esta linea al final todos los scripts***********
  220. include($_SERVER['DOCUMENT_ROOT'].'/inicio/final.php');
  221. //**************************************************************
  222. ?>