mirror of
https://github.com/rmontanana/inventario2.git
synced 2025-08-16 07:56:00 +00:00
Fix escape string deprectaed method
This commit is contained in:
20
Ajax.php
20
Ajax.php
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package Inventario
|
* @package Inventario
|
||||||
* @copyright Copyright (c) 2008, Ricardo Montañana Gómez
|
* @copyright Copyright (c) 2008, Ricardo Montañana Gómez
|
||||||
@@ -25,7 +26,8 @@ require_once 'Sql.php';
|
|||||||
$ajax = new Ajax();
|
$ajax = new Ajax();
|
||||||
echo $ajax->procesa();
|
echo $ajax->procesa();
|
||||||
|
|
||||||
class Ajax {
|
class Ajax
|
||||||
|
{
|
||||||
private $sql;
|
private $sql;
|
||||||
private $tabla;
|
private $tabla;
|
||||||
|
|
||||||
@@ -46,8 +48,10 @@ class Ajax {
|
|||||||
{
|
{
|
||||||
$opc = $_GET['opc'];
|
$opc = $_GET['opc'];
|
||||||
switch ($opc) {
|
switch ($opc) {
|
||||||
case "get": return $this->obtiene();
|
case "get":
|
||||||
case "put": return $this->actualiza();
|
return $this->obtiene();
|
||||||
|
case "put":
|
||||||
|
return $this->actualiza();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private function mensaje($exito, $texto)
|
private function mensaje($exito, $texto)
|
||||||
@@ -56,8 +60,8 @@ class Ajax {
|
|||||||
}
|
}
|
||||||
private function actualiza()
|
private function actualiza()
|
||||||
{
|
{
|
||||||
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
|
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
|
||||||
$comando = "update " . mysql_escape_string($this->tabla) . " set " . mysql_escape_string($_POST['name']) . " = '" . mysql_escape_string($_POST['value']) . "' where id = '" . mysql_escape_string($_POST['pk']). "';";
|
$comando = "update " . $this->sql->filtra($this->tabla) . " set " . $this->sql->filtra($_POST['name']) . " = '" . $this->sql->filtra($_POST['value']) . "' where id = '" . $this->sql->filtra($_POST['pk']) . "';";
|
||||||
$this->sql->ejecuta($comando);
|
$this->sql->ejecuta($comando);
|
||||||
$exito = !$this->sql->error();
|
$exito = !$this->sql->error();
|
||||||
$mensaje = $this->sql->mensajeError();
|
$mensaje = $this->sql->mensajeError();
|
||||||
@@ -67,7 +71,7 @@ class Ajax {
|
|||||||
}
|
}
|
||||||
private function obtiene()
|
private function obtiene()
|
||||||
{
|
{
|
||||||
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
|
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
|
||||||
$comando = "select id, descripcion from " . $this->tabla . " order by descripcion asc;";
|
$comando = "select id, descripcion from " . $this->tabla . " order by descripcion asc;";
|
||||||
$this->sql->ejecuta($comando);
|
$this->sql->ejecuta($comando);
|
||||||
$exito = !$this->sql->error();
|
$exito = !$this->sql->error();
|
||||||
@@ -76,7 +80,7 @@ class Ajax {
|
|||||||
return $this->respuesta($this->mensaje($exito, $mensaje));
|
return $this->respuesta($this->mensaje($exito, $mensaje));
|
||||||
}
|
}
|
||||||
$filas = array();
|
$filas = array();
|
||||||
while($r = $this->sql->procesaResultado()) {
|
while ($r = $this->sql->procesaResultado()) {
|
||||||
$filas[] = array($r['id'] => $r['descripcion']);
|
$filas[] = array($r['id'] => $r['descripcion']);
|
||||||
}
|
}
|
||||||
$resp = json_encode($filas);
|
$resp = json_encode($filas);
|
||||||
@@ -84,5 +88,3 @@ class Ajax {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
Reference in New Issue
Block a user