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:
@ -13,60 +13,72 @@ class Test extends BaseController
|
||||
|
||||
public function index()
|
||||
{
|
||||
try {
|
||||
helper('filesystem');
|
||||
helper('directory');
|
||||
if(strtolower(PHP_OS) == 'linux'){
|
||||
$compatibility = '/';
|
||||
}else{
|
||||
$compatibility = '\\';
|
||||
$request = \Config\Services::request();
|
||||
$uri = 'https://sk-jjo.imnavajas.es/tarifas';
|
||||
|
||||
$language = \Config\Services::language();
|
||||
$language->setLocale(session()->lang);
|
||||
|
||||
$getWhiteList = $this->whiteListController();
|
||||
|
||||
foreach ($getWhiteList as $item){
|
||||
if(strtolower($item) == $uri->getSegment(1)){
|
||||
return true;
|
||||
}
|
||||
|
||||
if(empty($controller)){
|
||||
$map = directory_map(APPPATH.'Controllers');
|
||||
foreach ($map as $key=>$item)
|
||||
{
|
||||
if(!strpos(strtolower($key),$compatibility)){
|
||||
var_dump($key);
|
||||
$name = str_replace('.php', '', $item);
|
||||
if(!getIgnoreController($name)){
|
||||
$controllers[] = [
|
||||
'name' => $name,
|
||||
'path' => '',
|
||||
'methods' => get_class_methods('App\Controllers\\'.$name)
|
||||
];
|
||||
}
|
||||
}else{
|
||||
foreach ($item as $subitem){
|
||||
$name = str_replace('.php', '', $subitem);
|
||||
if(!getIgnoreController($name)) {
|
||||
$controllers[] = [
|
||||
'name' => $name,
|
||||
'path' => $key,
|
||||
'methods' => get_class_methods('App\Controllers\\' . str_replace('/', '\\', $key) . $name)
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$getRules = json_decode(session()->get('rules')??'[]');
|
||||
|
||||
foreach ($this->whiteListMethod() as $item){
|
||||
if(strtolower($item) == $uri->getSegment(2)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($getRules as $key=>$value){
|
||||
if(strtolower($key) == $uri->getSegment(1)){
|
||||
if($uri->getTotalSegments() <= 1){
|
||||
return true;
|
||||
}
|
||||
foreach ($value as $item){
|
||||
if(strtolower($item) == $uri->getSegment(2)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}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',
|
||||
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user