//iniciarTransaccion if ($bandera) { mensajeSuccess(); } else { mensajeError(1, $db->obtenerResultado()); } } else { mensajeError(2, "Numero de transaccion invalido"); } } } } } } } else { mensajeError(2, $db->obtenerResultado()); } function mensajeError($error, $object) { $resArray = array(); http_response_code(403); if ($error == 1) { $separado_por_comas = implode(",", $object); $resArray['error'] = $separado_por_comas; print json_encode($resArray); } else { if ($error == 2) { $resArray['error'] = $object; print json_encode($resArray); } else { $resArray['error'] = 'informacion no recibida';
function comprarAlerta($id_contenido, $user_agent) { array_push($this->_debug, "Iniciando..."); $this->id_contenido = $id_contenido; $this->user_agent = $user_agent; $sql = "SELECT * FROM vivaBolivia.ventas_wap_billing WHERE "; $sql .= " descarga=$this->id_contenido "; $sql .= " AND celular='$this->numero_celular' "; $sql .= " AND useragent='$this->user_agent' "; $sql .= " AND CONCAT(fecha, ' ', hora) >= DATE_SUB(NOW(), INTERVAL 1 HOUR) "; $sql .= " AND cobrado=1 "; array_push($this->_debug, "(DBG) - [$this->id_transaccion] $sql"); $rs = mysql_query($sql, $this->db); if ($row = mysql_fetch_array($rs)) { $this->id_transaccion = $row["pk_ventas_wap_billing"]; array_push($this->_debug, "(DBG) - [$this->id_transaccion] DOBLE-CLICK Detected! Returning =)"); if (DEBUG_LVL) $this->dump_debug(); return true; } $cobrado = false; $err_msg = ""; $sql = ""; $sql .= "SELECT p.* FROM alertas.alertas_precios p, alertas.alertas_alertas a "; $sql .= " WHERE p.fk_id_alerta=" . $this->id_contenido; $sql .= " AND a.operadora='viva_bo' "; $sql .= " AND a.id=p.fk_id_alerta "; $rs = mysql_query($sql, $this->db); array_push($this->_debug, "(DBG) - TARIFF_CODE QUERY: $sql"); while ($obj = mysql_fetch_object($rs)){ $this->tariff_code = $obj->wap; // sc alertas sms } $this->nombre_contenido = "Alerta WAP"; $this->provider = "0"; // shortcode ok $sql = "INSERT INTO vivaBolivia.ventas_wap_billing SET "; $sql .= "descarga=$this->id_contenido, ". "celular='$this->numero_celular', ". "useragent='$this->user_agent', ". "id_cobro='$this->tariff_code',". "fecha=CURDATE(), ". "hora=CURTIME(), ". "tipo_venta='alerta', ". "error_msg='$err_msg' "; array_push($this->_debug, "(DBG) - [$this->id_transaccion] $sql"); $rs = mysql_query($sql, $this->db); $pk_ventas_wap_billing = mysql_insert_id($this->db); $this->id_transaccion = $pk_ventas_wap_billing; array_push($this->_debug, "(DBG) - ID_TRANSACCION: $pk_ventas_wap_billing"); if ($this->id_transaccion == "0") { // error sql array_push($this->_debug, "(CRIT) - BAD_ID_TRANSACCION :: Posible error en SQL."); if (DEBUG_LVL) $this->dump_debug(); return mensajeError(); } else { // todo bien return $this->comprar(); } }
if ($bandera) { mensajeSuccess("Se ha actualizado la informacion"); } else { mensajeError(1, $db->obtenerResultado()); } $db->finalizarTransaccion(); } else { mensajeError(2, "Numero de transaccion invalido"); } } } } } } } else { mensajeError(2, "Faltan parametros para realizar una actualizacion"); } function mensajeError($error, $object) { $resArray = array(); http_response_code(403); if ($error == 1) { $separado_por_comas = implode(",", $object); $resArray['error'] = $separado_por_comas; print json_encode($resArray); } else { if ($error == 2) { $resArray['error'] = $object; print json_encode($resArray); } else { $resArray['error'] = 'informacion no recibida';