mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
185 lines
4.5 KiB
PHP
185 lines
4.5 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers;
|
|
|
|
class Test extends BaseController
|
|
{
|
|
|
|
|
|
function __construct()
|
|
{
|
|
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
$request = \Config\Services::request();
|
|
$uri = new \CodeIgniter\HTTP\URI('https://sk-jjo.imnavajas.es/impresion/impresioncliente');
|
|
|
|
|
|
$language = \Config\Services::language();
|
|
$language->setLocale(session()->lang);
|
|
|
|
$getWhiteList = $this->whiteListController();
|
|
|
|
foreach ($getWhiteList as $item){
|
|
if(strtolower($item) == $uri->getSegment(1)){
|
|
|
|
|
|
echo '<pre>';
|
|
var_dump('1');
|
|
echo '</pre>';
|
|
dd();
|
|
|
|
return true;
|
|
}
|
|
}
|
|
|
|
$getRules = json_decode(session()->get('rules')??'[]');
|
|
|
|
foreach ($this->whiteListMethod() as $item){
|
|
if(strtolower($item) == $uri->getSegment(2)){
|
|
|
|
echo '<pre>';
|
|
var_dump('2');
|
|
echo '</pre>';
|
|
dd();
|
|
|
|
return true;
|
|
}
|
|
}
|
|
|
|
foreach ($getRules as $key=>$value){
|
|
if(strtolower($key) == $uri->getSegment(1)){
|
|
if($uri->getTotalSegments() <= 1){
|
|
|
|
echo '<pre>';
|
|
var_dump('3');
|
|
echo '</pre>';
|
|
dd();
|
|
|
|
return true;
|
|
}
|
|
|
|
foreach ($value as $item){
|
|
if(strtolower($item) == $uri->getSegment(2)){
|
|
|
|
echo '<pre>';
|
|
var_dump('4');
|
|
echo '</pre>';
|
|
dd();
|
|
|
|
return true;
|
|
}
|
|
}
|
|
|
|
}
|
|
else{
|
|
foreach($this->controllerFolderList() as $folder){
|
|
if(strtolower($folder) == $uri->getSegment(1)){
|
|
var_dump($key);
|
|
if(strtolower($key) == $uri->getSegment(2)){
|
|
if($uri->getTotalSegments() <= 2){
|
|
|
|
echo '<pre>';
|
|
var_dump('5');
|
|
echo '</pre>';
|
|
dd();
|
|
|
|
return true;
|
|
}
|
|
|
|
foreach ($value as $item){
|
|
if(strtolower($item) == $uri->getSegment(3)){
|
|
|
|
echo '<pre>';
|
|
var_dump('6');
|
|
echo '</pre>';
|
|
dd();
|
|
|
|
return true;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
echo '<pre>';
|
|
var_dump($uri->getSegment(1));
|
|
var_dump($uri->getSegment(2));
|
|
var_dump($uri->getSegment(3));
|
|
echo '</pre>';
|
|
dd();
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* Returns the white list of allowed controllers.
|
|
*/
|
|
public function whiteListController(){
|
|
return [
|
|
'',
|
|
'BaseController',
|
|
'Home',
|
|
'Login',
|
|
'Oauth',
|
|
'Language',
|
|
'Api',
|
|
'Cron',
|
|
'lang',
|
|
'Ajax',
|
|
'Integration',
|
|
'Migrate',
|
|
'Test',
|
|
|
|
];
|
|
}
|
|
|
|
/**
|
|
* JJO
|
|
* Returns the controller folder list
|
|
*/
|
|
public function controllerFolderList(){
|
|
return [
|
|
'impresion',
|
|
];
|
|
}
|
|
|
|
|
|
/**
|
|
* Returns the whitelist of public controllers.
|
|
*/
|
|
public function ignoreListController(){
|
|
return [
|
|
];
|
|
}
|
|
|
|
public function validateIgnoreControllerAccess(){
|
|
$request = \Config\Services::request();
|
|
$uri = $request->uri;
|
|
|
|
$getList = $this->ignoreListController();
|
|
foreach ($getList as $item){
|
|
if(strtolower($item) == $uri->getSegment(1)){
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public function whiteListMethod(){
|
|
return [
|
|
'initController',
|
|
'__construct',
|
|
'validateControllerAccess',
|
|
'whiteListController',
|
|
'whiteListMethod'
|
|
];
|
|
}
|
|
}
|