Exemple #1
0
function setCreditsForUser($credits, $cliid)
{
    global $config;
    $servidor = $config['db']['servidor'];
    $usuario = $config['db']['usuario'];
    $pwd = $config['db']['pwd'];
    $bd = $config['db']['DBGlobal'];
    dataIO::conectar($servidor, $usuario, $pwd, $bd);
    $cliente = new Cliente();
    $query = $cliente->getClientByid($cliid);
    try {
        $result = dataIO::executeQuery($query);
        $fila = mysqli_fetch_assoc($result);
        if ($fila != null) {
            $cliente = new Cliente($fila);
            $credits += $cliente->getCreditos();
            $query = $cliente->getUpdateCredits($credits, $cliid);
            $result = dataIO::executeQuery($query);
        }
        return true;
    } catch (Exception $e) {
        return false;
    }
}
Exemple #2
0
 public function getCliente()
 {
     global $config;
     $servidor = $config['db']['servidor'];
     $usuario = $config['db']['usuario'];
     $pwd = $config['db']['pwd'];
     $bd = $config['db']['DBGlobal'];
     dataIO::conectar($servidor, $usuario, $pwd, $bd);
     //no pregunto por pass porq todavia no lo uso
     if (isset($_GET['nick'])) {
         $nick = (string) $_GET['nick'];
         $pass = (string) $_GET['pass'];
     } else {
         if (isset($_POST['nick'])) {
             $nick = (string) $_POST['nick'];
             $pass = (string) $_POST['pass'];
         }
     }
     //escapamos el nick y pass para prevenir inyeccion sql ya que son strings
     $nick = mysqli_real_escape_string(dataIO::isConnected(), $nick);
     $pass = mysqli_real_escape_string(dataIO::isConnected(), $pass);
     //fin escape
     $usuario = new Usuario();
     $cliente = new Cliente();
     $query = $usuario->getUserByName($nick);
     try {
         $result = dataIO::executeQuery($query);
         $fila = mysqli_fetch_assoc($result);
         $usuario = new Usuario($fila);
         $query2 = $cliente->getClientByid($usuario->getId());
         $result2 = dataIO::executeQuery($query2);
         $fila2 = mysqli_fetch_assoc($result2);
         $cliente = new Cliente($fila2);
         echo json_encode($cliente->getJSon());
     } catch (Exception $e) {
         echo json_encode(null);
     }
 }