mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Estudiando como implementar subfolders
This commit is contained in:
@ -28,7 +28,7 @@ $routes->setAutoRoute(true);
|
|||||||
* Route Definitions
|
* Route Definitions
|
||||||
* --------------------------------------------------------------------
|
* --------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
// JJO $routes->get('cliente', 'Impresion\Cliente::index');
|
||||||
// We get a performance increase by specifying the default
|
// We get a performance increase by specifying the default
|
||||||
// route since we don't have to scan directories.
|
// route since we don't have to scan directories.
|
||||||
|
|
||||||
|
|||||||
@ -3,17 +3,18 @@
|
|||||||
namespace App\Controllers\Impresion;
|
namespace App\Controllers\Impresion;
|
||||||
use App\Controllers\BaseController;
|
use App\Controllers\BaseController;
|
||||||
|
|
||||||
class Clientes extends BaseController
|
|
||||||
|
class Cliente extends BaseController
|
||||||
{
|
{
|
||||||
function __construct()
|
function __construct()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
echo 'Hola2';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
20
ci4/app/Controllers/Tarifas.php
Normal file
20
ci4/app/Controllers/Tarifas.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controllers;
|
||||||
|
use App\Controllers\BaseController;
|
||||||
|
|
||||||
|
class Tarifas extends BaseController
|
||||||
|
{
|
||||||
|
function __construct()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
|
||||||
|
echo 'Hola';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@ -13,60 +13,72 @@ class Test extends BaseController
|
|||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
try {
|
$request = \Config\Services::request();
|
||||||
helper('filesystem');
|
$uri = 'https://sk-jjo.imnavajas.es/tarifas';
|
||||||
helper('directory');
|
|
||||||
if(strtolower(PHP_OS) == 'linux'){
|
$language = \Config\Services::language();
|
||||||
$compatibility = '/';
|
$language->setLocale(session()->lang);
|
||||||
}else{
|
|
||||||
$compatibility = '\\';
|
$getWhiteList = $this->whiteListController();
|
||||||
|
|
||||||
|
foreach ($getWhiteList as $item){
|
||||||
|
if(strtolower($item) == $uri->getSegment(1)){
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if(empty($controller)){
|
|
||||||
$map = directory_map(APPPATH.'Controllers');
|
$getRules = json_decode(session()->get('rules')??'[]');
|
||||||
foreach ($map as $key=>$item)
|
|
||||||
{
|
foreach ($this->whiteListMethod() as $item){
|
||||||
if(!strpos(strtolower($key),$compatibility)){
|
if(strtolower($item) == $uri->getSegment(2)){
|
||||||
var_dump($key);
|
return true;
|
||||||
$name = str_replace('.php', '', $item);
|
}
|
||||||
if(!getIgnoreController($name)){
|
}
|
||||||
$controllers[] = [
|
|
||||||
'name' => $name,
|
foreach ($getRules as $key=>$value){
|
||||||
'path' => '',
|
if(strtolower($key) == $uri->getSegment(1)){
|
||||||
'methods' => get_class_methods('App\Controllers\\'.$name)
|
if($uri->getTotalSegments() <= 1){
|
||||||
];
|
return true;
|
||||||
}
|
}
|
||||||
}else{
|
foreach ($value as $item){
|
||||||
foreach ($item as $subitem){
|
if(strtolower($item) == $uri->getSegment(2)){
|
||||||
$name = str_replace('.php', '', $subitem);
|
return true;
|
||||||
if(!getIgnoreController($name)) {
|
|
||||||
$controllers[] = [
|
|
||||||
'name' => $name,
|
|
||||||
'path' => $key,
|
|
||||||
'methods' => get_class_methods('App\Controllers\\' . str_replace('/', '\\', $key) . $name)
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
|
||||||
$array = explode('/',$controller);
|
|
||||||
$dir = count($array) > 1 ? $array[0] : '';
|
|
||||||
$name = count($array) > 1 ? '\\'.$array[1] : $array[0];
|
|
||||||
$controllers[] = [
|
|
||||||
'name' => $name,
|
|
||||||
'path' => $dir,
|
|
||||||
'methods' => get_class_methods('App\Controllers\\'.str_replace('/','\\',$dir).$name)
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
/*echo '<pre>';
|
|
||||||
var_dump($controllers);
|
|
||||||
echo '<pre>';
|
|
||||||
dd();
|
|
||||||
*/
|
|
||||||
} catch (Exception $e) {
|
|
||||||
return [];
|
|
||||||
}
|
}
|
||||||
|
session()->setFlashdata('sweet', ['error',lang("App.dashboard_alert_rules")]);
|
||||||
|
header('Location: /home');
|
||||||
|
exit();
|
||||||
|
|
||||||
|
echo '<pre>';
|
||||||
|
var_dump($controllers);
|
||||||
|
echo '</pre>';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the white list of allowed controllers.
|
||||||
|
*/
|
||||||
|
public function whiteListController(){
|
||||||
|
return [
|
||||||
|
'',
|
||||||
|
'BaseController',
|
||||||
|
'Home',
|
||||||
|
'Login',
|
||||||
|
'Oauth',
|
||||||
|
'Language',
|
||||||
|
'Api',
|
||||||
|
'Cron',
|
||||||
|
'lang',
|
||||||
|
'Ajax',
|
||||||
|
'Integration',
|
||||||
|
'Migrate',
|
||||||
|
'Test',
|
||||||
|
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,12 +66,22 @@ class LoginAuthFilter implements FilterInterface
|
|||||||
if($uri->getTotalSegments() <= 1){
|
if($uri->getTotalSegments() <= 1){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
foreach ($value as $item){
|
echo '<pre>';
|
||||||
|
var_dump($value);
|
||||||
|
/*var_dump($uri->getSegment(0));
|
||||||
|
var_dump($uri->getSegment(1));
|
||||||
|
var_dump($uri->getSegment(2));
|
||||||
|
var_dump($uri->getTotalSegments());*/
|
||||||
|
echo '</pre>';
|
||||||
|
|
||||||
|
/*foreach ($value as $item){
|
||||||
if(strtolower($item) == $uri->getSegment(2)){
|
if(strtolower($item) == $uri->getSegment(2)){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
dd();
|
||||||
}
|
}
|
||||||
session()->setFlashdata('sweet', ['error',lang("App.dashboard_alert_rules")]);
|
session()->setFlashdata('sweet', ['error',lang("App.dashboard_alert_rules")]);
|
||||||
header('Location: /home');
|
header('Location: /home');
|
||||||
@ -84,8 +94,6 @@ class LoginAuthFilter implements FilterInterface
|
|||||||
public function whiteListController(){
|
public function whiteListController(){
|
||||||
return [
|
return [
|
||||||
'',
|
'',
|
||||||
'Clientes',
|
|
||||||
|
|
||||||
'BaseController',
|
'BaseController',
|
||||||
'Home',
|
'Home',
|
||||||
'Login',
|
'Login',
|
||||||
|
|||||||
@ -155,6 +155,8 @@ function getDictionary($word=''){
|
|||||||
'view' => lang("App.group_rules_label_view"),
|
'view' => lang("App.group_rules_label_view"),
|
||||||
'oauth_store' => lang("App.group_rules_label_oauth_store"),
|
'oauth_store' => lang("App.group_rules_label_oauth_store"),
|
||||||
'template_store' => lang("App.group_rules_label_template_store"),
|
'template_store' => lang("App.group_rules_label_template_store"),
|
||||||
|
'Tarifas' => 'Tarifas',
|
||||||
|
'Cliente' => 'Cliente'
|
||||||
];
|
];
|
||||||
return array_key_exists($word,$dictionary)?$dictionary[$word] : $word;
|
return array_key_exists($word,$dictionary)?$dictionary[$word] : $word;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user