!C99Shell v. 2.1 [PHP 8 Update] [02.02.2022]!

Software: Apache/2.4.53 (Unix) OpenSSL/1.1.1o PHP/7.4.29 mod_perl/2.0.12 Perl/v5.34.1. PHP/7.4.29 

uname -a: Linux vps-2738122-x 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:30:12 UTC 2023 x86_64 

uid=1(daemon) gid=1(daemon) grupos=1(daemon) 

Safe-mode: OFF (not secure)

/opt/apex_led/proyectos/toba_usuarios/php/lib/   drwxrwxr-x
Free 14.39 GB of 61.93 GB (23.24%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     rest_arai_usuarios.php (5.04 KB)      -rwxrwxr-x
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php

use GuzzleHttp\Client;
use 
GuzzleHttp\Exception\RequestException;

/**
 * ACCESO y MANEJO de los servicios REST de ARAI-Usuarios.
 * 
 */
class rest_arai_usuarios
{
    static private 
$instancia;
    protected 
$cliente;
        
    
/**
     * Metodo para instanciar la clase rest_arai_usuarios
     * @param boolean $recargar Flag que determina si recarga la instancia
     * @return rest_arai_usuarios
     */
    
static function instancia($recargar=false)
    {
        if (!isset(
self::$instancia) || $recargar) {
            
self::$instancia = new rest_arai_usuarios($recargar);    
        }
        return 
self::$instancia;    
    }

    
/**
    *    Eliminar la instancia actual
    */
    
static function eliminar_instancia()
    {
        
self::$instancia null;
    }

    
/**
    *    Constructor de la clase rest_arai_usuarios
    *    @param boolean $recargar Flag que determina si recarga la instancia
    */
    
private function __construct($recargar)
    {
        
$this->cliente $this->get_cliente_rest();
    }
    
    
//-----------------------------------------------------------------------------------
    //---- Auxiliares -------------------------------------------------------------------
    //-----------------------------------------------------------------------------------
    
    /**
     * Ver http://docs.guzzlephp.org/en/latest/docs.html
     * @return GuzzleHttp\Client
     */
    
protected function get_cliente_rest()
    {
        try {
            
$opciones = array();
            
$cliente toba::servicio_web_rest('rest_arai_usuarios'$opciones);
            return 
$cliente->guzzle();
        } catch (
toba_error $e) {
            throw new 
toba_error_usuario("Hay un problema de configuracion del cliente REST. Por favor asegurese de configurarlo correctamente en el archivo cliente.ini.\n<br/><br/>Mensaje: " $e->get_mensaje());
        }
    }
    
    private function 
manejar_excepcion_request(RequestException $e)
    {
        
$msg $e->getMessage() . "\n" $e->getRequest() . "\n";

        if (
$e->hasResponse()) {
            
$msg .= $e->getResponse() . "\n";
        }
        throw new 
toba_error($msg);
    }
    
    public function 
get_usuarios($filtro=array(), $excluir_aplicacion null)
    {
        try {
            
$query = array();
            
$url "usuarios";

            if (isset(
$filtro)) {
                foreach (
$filtro as $id => $campo) {
                    if (
is_array($campo['valor'])) {
                        
$valor $campo['valor']['desde'] . ';' $campo['valor']['hasta'];
                    } else {
                        
$valor $campo['valor'];
                    }
                    
$query[$id] = $campo['condicion'] . ';' $valor;
                }
            }
            if (isset(
$excluir_aplicacion)) {
                
$query['excluir_aplicacion'] = $excluir_aplicacion;
            }
            
// obtengo la respuesta
            
$response $this->cliente->get($url, array('query' => $query));
            
$datos rest_decode($response->json());
            
            foreach(
$datos as $clave => $dato) {
                
$datos[$clave]['nombre_apellido'] = $dato['nombre'] . ' ' $dato['apellido'];
            }
            return 
$datos;
        } catch (
RequestException $e) {
            
$this->manejar_excepcion_request($e);
        } catch (
Exception $e) {
            throw new 
toba_error($e);
        }
    }
    
    public function 
get_usuario($identificador)
    {
        try {
            
$url "usuarios/$identificador";

            
// obtengo la respuesta
            
$response $this->cliente->get($url);
            
$datos rest_decode($response->json());            
            if (!empty(
$datos)) {
                
$datos['nombre_apellido'] = $datos['nombre'] . ' ' $datos['apellido'];
            }
            return 
$datos;
        } catch (
RequestException $e) {
            
$this->manejar_excepcion_request($e);
        } catch (
Exception $e) {
            throw new 
toba_error($e);
        }
    }
    
    public function 
get_cuenta($identificador_aplicacion$cuenta)
    {
        try {
            
$url "aplicaciones/$identificador_aplicacion/cuentas/$cuenta";

            
// obtengo la respuesta
            
$response $this->cliente->get($url);
            
$datos rest_decode($response->json());            
            return 
$datos;
        } catch (
RequestException $e) {
            if (
$e->getCode() == 404) {
                return array();
            }
            
$this->manejar_excepcion_request($e);
        } catch (
Exception $e) {
            throw new 
toba_error($e);
        }
    }
    
    public function 
agregar_cuenta($identificador_aplicacion$datos_cuenta)
    {
        try {
            
$url "aplicaciones/$identificador_aplicacion/cuentas";
            
            
// obtengo la respuesta
            
$response $this->cliente->post($url, array('body' => rest_encode($datos_cuenta)));
            
$datos rest_decode($response->json());            
            return 
$datos;
        } catch (
RequestException $e) {
            
$this->manejar_excepcion_request($e);
        } catch (
Exception $e) {
            throw new 
toba_error($e);
        }
    }
    
    public function 
eliminar_cuenta($identificador_aplicacion$cuenta)
    {
        try {
            
$url "aplicaciones/$identificador_aplicacion/cuentas/$cuenta";
            
            
// obtengo la respuesta
            
$response $this->cliente->delete($url);
        } catch (
RequestException $e) {
            
$this->manejar_excepcion_request($e);
        } catch (
Exception $e) {
            throw new 
toba_error($e);
        }
    }
    
    public function 
get_nombre_apellido_usuario($identificador)
    {
        
$datos $this->get_usuario($identificador);
        if (isset(
$datos) && !empty($datos)) {
            return 
$datos['nombre_apellido'];
        } else {
            return 
'';
        }
    }
    
    public function 
get_identificador_x_aplicacion_cuenta($identificador_aplicacion$cuenta) {
        
$datos $this->get_cuenta($identificador_aplicacion$cuenta);
        if (isset(
$datos) && !empty($datos)) {
            return 
$datos['identificador_usuario'];
        } else {
            return 
null;
        }
    }
    
}
?>

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.1 [PHP 8 Update] [02.02.2022] maintained byC99Shell Github | Generation time: 0.609 ]--