예제 #1
0
try {
    // Objeto de requisição
    $request = new CoreExt_Controller_Request();
    // Helper de URL. Auxilia para criar uma URL no formato http://www.example.org/module
    $url = CoreExt_View_Helper_UrlHelper::getInstance();
    $url = $url->url($request->get('REQUEST_URI'), array('components' => CoreExt_View_Helper_UrlHelper::URL_HOST));
    // Configura o baseurl da request
    $request->setBaseurl(sprintf('%s/module', $url));
    // Configura o DataMapper para usar uma instância de clsBanco com fetch de resultados
    // usando o tipo FETCH_ASSOC
    CoreExt_DataMapper::setDefaultDbAdapter(new clsBanco(array('fetchMode' => clsBanco::FETCH_ASSOC)));
    // Inicia o Front Controller
    $frontController = CoreExt_Controller_Front::getInstance();
    $frontController->setRequest($request);
    // Configura o caminho aonde os módulos estão instalados
    $frontController->setOptions(array('basepath' => PROJECT_ROOT . DS . 'modules'));
    $frontController->dispatch();
    // Resultado
    print $frontController->getViewContents();
} catch (Exception $e) {
    $lastError = error_get_last();
    @session_start();
    $_SESSION['last_error_message'] = $e->getMessage();
    $_SESSION['last_php_error_message'] = $lastError['message'];
    $_SESSION['last_php_error_line'] = $lastError['line'];
    $_SESSION['last_php_error_file'] = $lastError['file'];
    @session_write_close();
    error_log("Erro inesperado (pego em /module/index.php): " . $e->getMessage());
    NotificationMailer::unexpectedError($e->getMessage());
    die("<script>document.location.href = '/module/Error/unexpected';</script>");
}
예제 #2
0
 function MakeAll()
 {
     try {
         $cronometro = new clsCronometro();
         $cronometro->marca('inicio');
         $liberado = TRUE;
         $saida_geral = '';
         if ($this->convidado) {
             @session_start();
             $_SESSION['convidado'] = TRUE;
             $_SESSION['id_pessoa'] = '0';
             session_write_close();
         }
         $controlador = new clsControlador();
         if ($controlador->Logado() && $liberado || $this->convidado) {
             $this->Formular();
             $this->VerificaPermicao();
             $this->CadastraAcesso();
             $saida_geral = $this->MakeHeadHtml();
             if ($this->renderMenu) {
                 $saida_geral .= $this->MakeBody();
             } else {
                 foreach ($this->clsForm as $form) {
                     $saida_geral .= $form->RenderHTML();
                 }
             }
             $saida_geral .= $this->MakeFootHtml();
             if ($_GET['suspenso'] == 1 || $_SESSION['suspenso'] == 1 || $_SESSION["tipo_menu"] == 1) {
                 if ($this->renderMenuSuspenso) {
                     $saida_geral = str_replace("<!-- #&MENUSUSPENSO&# -->", $this->makeMenuSuspenso(), $saida_geral);
                 }
                 if ($_GET['suspenso'] == 1) {
                     @session_start();
                     $_SESSION['suspenso'] = 1;
                     @session_write_close();
                 }
             }
         } elseif (empty($_POST['login']) || empty($_POST['senha']) && $liberado) {
             $saida_geral .= $this->MakeHeadHtml();
             $controlador->Logar(FALSE);
             $saida_geral .= $this->MakeFootHtml();
         } else {
             $controlador->Logar(TRUE);
             if ($controlador->Logado() && $liberado) {
                 $this->Formular();
                 $this->VerificaPermicao();
                 $this->CadastraAcesso();
                 $saida_geral = $this->MakeHeadHtml();
                 $saida_geral .= $this->MakeBody();
                 $saida_geral .= $this->MakeFootHtml();
             } else {
                 $saida_geral = $this->MakeHeadHtml();
                 $controlador->Logar(false);
                 $saida_geral .= $this->MakeFootHtml();
             }
         }
         echo $saida_geral;
         $cronometro->marca('fim');
         $tempoTotal = $cronometro->getTempoTotal();
         $tempoTotal += 0;
         $objConfig = new clsConfig();
         if ($tempoTotal > $objConfig->arrayConfig["intSegundosProcessaPagina"]) {
             $conteudo = "<table border=\"1\" width=\"100%\">";
             $conteudo .= "<tr><td><b>Data</b>:</td><td>" . date("d/m/Y H:i:s", time()) . "</td></tr>";
             $conteudo .= "<tr><td><b>Script</b>:</td><td>{$_SERVER["PHP_SELF"]}</td></tr>";
             $conteudo .= "<tr><td><b>Tempo de processamento</b>:</td><td>{$tempoTotal} segundos</td></tr>";
             $conteudo .= "<tr><td><b>Tempo max permitido</b>:</td><td>{$objConfig->arrayConfig["intSegundosProcessaPagina"]} segundos</td></tr>";
             $conteudo .= "<tr><td><b>URL get</b>:</td><td>{$_SERVER['QUERY_STRING']}</td></tr>";
             $conteudo .= "<tr><td><b>Metodo</b>:</td><td>{$_SERVER["REQUEST_METHOD"]}</td></tr>";
             if ($_SERVER["REQUEST_METHOD"] == "POST") {
                 $conteudo .= "<tr><td><b>POST vars</b>:</td><td>";
                 foreach ($_POST as $var => $val) {
                     $conteudo .= "{$var} => {$val}<br>";
                 }
                 $conteudo .= "</td></tr>";
             } elseif ($_SERVER["REQUEST_METHOD"] == "GET") {
                 $conteudo .= "<tr><td><b>GET vars</b>:</td><td>";
                 foreach ($_GET as $var => $val) {
                     $conteudo .= "{$var} => {$val}<br>";
                 }
                 $conteudo .= "</td></tr>";
             }
             if ($_SERVER['HTTP_REFERER']) {
                 $conteudo .= "<tr><td><b>Referrer</b>:</td><td>{$_SERVER["HTTP_REFERER"]}</td></tr>";
             }
             $conteudo .= "</table>";
             $objMail = new clsEmail($objConfig->arrayConfig['ArrStrEmailsAdministradores'], "[INTRANET - PMI] Desempenho de pagina", $conteudo);
             $objMail->envia();
         }
     } catch (Exception $e) {
         $lastError = error_get_last();
         @session_start();
         $_SESSION['last_error_message'] = $e->getMessage();
         $_SESSION['last_php_error_message'] = $lastError['message'];
         $_SESSION['last_php_error_line'] = $lastError['line'];
         $_SESSION['last_php_error_file'] = $lastError['file'];
         @session_write_close();
         error_log("Erro inesperado (pego em clsBase): " . $e->getMessage());
         NotificationMailer::unexpectedError($e->getMessage());
         die("<script>document.location.href = '/module/Error/unexpected';</script>");
     }
 }
예제 #3
0
 /**
  * Mostra a mensagem de erro e interrompe a execução do script.
  * @param  string $msg
  * @param  bool   $getError
  */
 function Interrompe($appErrorMsg, $getError = FALSE)
 {
     $lastError = error_get_last();
     @session_start();
     $_SESSION['last_php_error_message'] = $lastError['message'];
     $_SESSION['last_php_error_line'] = $lastError['line'];
     $_SESSION['last_php_error_file'] = $lastError['file'];
     @session_write_close();
     $pgErrorMsg = $getError ? pg_result_error($this->bConsulta_ID) : '';
     NotificationMailer::unexpectedDataBaseError($appErrorMsg, $pgErrorMsg, $this->strStringSQL);
     die("<script>document.location.href = '/module/Error/unexpected';</script>");
 }