format('d/m/Y H:i:s'); $strRequestURIaux = str_replace('//' , '/' , $_SERVER['REQUEST_URI']); if ($boolDEBUG) file_put_contents($strLogFileName , $sDtHr . ' - _SERVER[REQUEST_URI] : ' . $_SERVER['REQUEST_URI'] . PHP_EOL, FILE_APPEND); if ($boolDEBUG) file_put_contents($strLogFileName , ' ' . PHP_EOL, FILE_APPEND); // Futuramente tratar exceções aqui, como as chamadas AJAX! // Apenas um comment if ($strRequestURIaux == 'TratarExcecoesAqui!!!'){ $bool = true; }else{ if (!in_array($_SERVER['REQUEST_URI'] , $arrExclusions)){ $post = file_get_contents('php://input'); define('baseURL' , '/'); //define('mainURL' , 'https://peterles.com/'); if (stripos($strRequestURIaux , '?')){ $arrRequestURIaux = explode('?' , $strRequestURIaux); $strRequestURIaux = $arrRequestURIaux[0]; unset($arrRequestURIaux); } // Caso a chamada tenha sido GET e contenha valores, vou desmembrar e povoar um valor de SESSION com GET_ define('REQUEST_URI', $strRequestURIaux); if ($boolDEBUG){ file_put_contents($strLogFileName , ' ' . PHP_EOL, FILE_APPEND); file_put_contents($strLogFileName , str_repeat('=' , 100) . PHP_EOL, FILE_APPEND); file_put_contents($strLogFileName , '_SERVER[REQUEST_URI]: "' . $_SERVER['REQUEST_URI'] . '"' . PHP_EOL, FILE_APPEND); file_put_contents($strLogFileName , 'strRequestURIaux: "' . $strRequestURIaux . '"' . PHP_EOL, FILE_APPEND); if ($post){ //foreach($_POST as $index => $value){ // file_put_contents($strLogFileName , 'POST =>' . $value . '<=' . PHP_EOL, FILE_APPEND); //} foreach($_GET as $index => $value){ if (gettype($value)=='string'){ file_put_contents($strLogFileName , 'GET =>' . $value . '<=' . PHP_EOL, FILE_APPEND); }else{ ob_start(); var_dump($value); $valueOut = ob_get_clean(); $this->doDEBUG($strScriptAndMethodName , 'GET - index =>' . $index . '<= value =>' . $valueOut . '<=' ); file_put_contents($strLogFileName , 'POST =>' . $value . '<=' . PHP_EOL, FILE_APPEND); } } } //file_put_contents($strLogFileName , 'IP Origem: "' . $_SERVER['REMOTE_ADDR'] . '"' . PHP_EOL, FILE_APPEND); // Mostra sempre o IP do balanceador/roteador file_put_contents($strLogFileName , ' ' . PHP_EOL, FILE_APPEND); } $_aURLpatterns = [ baseURL . '' => 'index.php', // baseURL . 'DeskApp' => 'MyLABS/DeskApp/index.php', baseURL . 'getPHPinfo' => 'getPHPinfo.php', // baseURL . 'Gretong' => 'MyLABS/Gretong/index.php', // baseURL . 'MyLABS' => 'MyLABS/index.php', // baseURL . 'MyLABS/DeskApp' => 'MyLABS/DeskApp/index.php', // baseURL . 'MyLABS/Gretong' => 'MyLABS/Gretong/index.php', baseURL . 'jmb' => 'JMB/index.php', baseURL . 'loja' => 'loja/index.php', baseURL . 'loja' . '/' => 'loja/index.php', baseURL . 'reage' . '/' => 'reage/Router.php', baseURL . 'rentals' . '/' => 'rentals/index.php', baseURL . 'Rents' . '/' => 'rents/index.php', baseURL . '/rents' => 'rents/index.php', baseURL . 'Rents/items' => 'rents/items/index.php', baseURL . 'rents/items' => 'rents/items/index.php', baseURL . 'rents/items' . '/' => 'rents/items/index.php', baseURL . 'testCURL' => 'JMB/app/__Tests/testCURL.php', baseURL . 'Maintenance' => 'Maintenance/index.php', ]; /** * Adaptado de Função Responsável pelo tratamento da URL * * @author Camilo Teixeira de Melo * @link http://www.camilotx.com.br * @param string $_aURLpatterns array com os modelos de url * @return void **/ function getURLresponse($_aURLpatterns=[]){ global $boolDEBUG; global $sDtHr; global $strLogFileName; if(substr(REQUEST_URI , 0 , 9) == '/__Files/'){/* Considerando os casos de viewContentFile */ require_once(__DIR__ . REQUEST_URI); exit; }else{ foreach($_aURLpatterns as $pcre=>$app){ if ($boolDEBUG) file_put_contents($strLogFileName , $sDtHr . ' - getURLresponse - Comparando "' . REQUEST_URI . '" com "' . $pcre . '"' . PHP_EOL, FILE_APPEND); if(preg_match("@^{$pcre}$@",REQUEST_URI,$post) || stripos(REQUEST_URI , 'ViewLogsDoGet_')){ if(stripos(REQUEST_URI , 'ViewLogsDoGet_')){ $app = str_replace('ViewLogsDoGet_' , '' , REQUEST_URI); } if ($boolDEBUG) file_put_contents($strLogFileName , $sDtHr . ' - getURLresponse - ACHEI! => - Carregando "' . __DIR__ . '/' . $app . '"' . PHP_EOL, FILE_APPEND); if ($boolDEBUG) file_put_contents($strLogFileName , str_repeat('#' , 100) . PHP_EOL, FILE_APPEND); //if ($app == '#'){ //$arrAddress = explode('/' , REQUEST_URI); //if ($boolDEBUG) file_put_contents($strLogFileName , $sDtHr . ' - getURLresponse - Chamando "' . baseURL . '' . $arrAddress[count($arrAddress)-1] . '"' . PHP_EOL, FILE_APPEND); //header('Location: ' . mainURL . baseURL . '' . $arrAddress[count($arrAddress)-1]); //}else{ //if ($boolDEBUG) file_put_contents($strLogFileName , $sDtHr . ' - getURLresponse - Carregando "' . __DIR__ . '/' . $app . '"' . PHP_EOL, FILE_APPEND); require_once(__DIR__ . '/' . $app); //} exit; } } } if ($boolDEBUG) file_put_contents($strLogFileName , $sDtHr . ' - getURLresponse - NÃO ACHEI!' . PHP_EOL, FILE_APPEND); if ($boolDEBUG) file_put_contents(str_replace('.log' , '_NAO_ACHADOS.log' , $strLogFileName) , $sDtHr . ' - getURLresponse - "' . REQUEST_URI . '"' . PHP_EOL, FILE_APPEND); //if (stripos(REQUEST_URI, 'Monitorer_') || stripos(REQUEST_URI, 'Monitored_')){ // if ($boolDEBUG) file_put_contents($strLogFileName , $sDtHr . ' - getURLresponse - Devolvendo teSTATUS="Rota Inexistente!" ao APP!' . PHP_EOL, FILE_APPEND); // $arrReturn['teRESULTS'] = []; // $arrReturn['teSTATUS'] = 'Rota Inexistente!'; // $strReturn = json_encode($arrReturn); // header('Content-Type: application/json'); // echo $strReturn; //}else{ if ($boolDEBUG) file_put_contents($strLogFileName , $sDtHr . ' - getURLresponse - Chamando "' . baseURL . '"' . PHP_EOL, FILE_APPEND); header('Location: ' . baseURL); //} if ($boolDEBUG) file_put_contents($strLogFileName , str_repeat('#' , 100) . PHP_EOL, FILE_APPEND); exit(); } getURLresponse($_aURLpatterns); } }