!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_tdfonline/php/lib/rest/lib/   drwxr-xr-x
Free 13.51 GB of 61.93 GB (21.81%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     ruteador.php (2.79 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php

namespace rest\lib;

class 
ruteador
{
    const 
SUFIJO_COLECCION '_list';

    
/**
     * @var lector_recursos_archivo
     */
    
protected $lector;

    protected 
$instanciador;

    function 
__construct($lector$instanciador)
    {
        
$this->lector $lector;
        
$this->instanciador $instanciador;
    }

    function 
buscar_controlador($method$url)
    {
        
$partes_url explode('/'$url);

        
$instanciador $this->instanciador;
        
//colleccion/id/colleccion...
        
$colecciones = array();
        
$parametros = array();
        foreach (
$partes_url as $key => $valor) {
            if (
trim($valor) == "") { //mal formato. / de mas
                
throw new \Exception("Formato de ruta incorrecto - $url"); //cambiar
            
}
            if (
$key 2) {
                
$parametros[] = $valor;
            } else {
                
$colecciones[] = $valor;
            }
        }

        
//busco la clase que maneja el recurso
        
if (!$recurso $this->lector->get_recurso($colecciones)) {
            
$dir $this->lector->get_directorio_recursos();
            throw new \
Exception("No se encuentra el recurso para $url en el directorio $dir. ¿Ruta mal formada?"); //cambiar
        
}

        
$instanciador->archivo $recurso['archivo'];

        
// Se checkea si matchea con un alias primero
        
if (count($colecciones) == count($parametros)) {
            
$posibles_params $parametros;
            
$alias array_pop($posibles_params); // recurso1/param1/rec2/alias_como_param2

            
$posible_accion $this->get_accion_path($method$recurso['recurso'], $colecciones$posibles_params);;
            
$posible_accion .= '__' $alias;

            if (
$instanciador->existe_metodo($posible_accion)) {
                
$instanciador->accion $posible_accion;
                
$instanciador->parametros $posibles_params;
                return 
$instanciador;
            }
        }

        
//se invoca la accion tipica
        
$accion $this->get_accion_path($method$recurso['recurso'], $colecciones$parametros);
        
$instanciador->accion $accion;
        
$instanciador->parametros $parametros;

        if (
$instanciador->existe_metodo($accion)) { //chequear que exista la accion?
            
return $instanciador;
        }
        if(isset(
$posible_accion)){
            
$error_alias "o el alias '$posible_accion' ";
        }else {
            
$error_alias '';
        }

        throw new \
Exception("No se encuentra el metodo $accion {$error_alias}en la clase {$recurso['archivo']}. ¿Ruta mal formada?");
    }


    protected function 
get_accion_path($metodo$clase$colecciones$parametros)
    {
        
$accion strtolower($metodo);
        
//si hay path faltante lo resuelve en un metodo get_recurso1_recurso2
        
$hay_path_por_resolver array_search(basename($clase'.php'), $colecciones);

        if (
false !== $hay_path_por_resolver && count($colecciones) > ($hay_path_por_resolver 1)) {
            
$path_faltante array_slice($colecciones$hay_path_por_resolver 1);
            
$accion .= '_' implode('_'$path_faltante);
        }

        
//Apunta a la coleccion
        
if (count($colecciones) == count($parametros) + 1) {
            
$accion .= self::SUFIJO_COLECCION;
        }
        return 
$accion;
    }
}

:: 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.6066 ]--