Esempio n. 1
0
    $data_exist = $r->num_rows;
} else {
    unset($session->data['finish']);
}
if ($data_exist && empty($session->data['finish'])) {
    header('Location: ../');
}
if (!empty($session->data['finish']) && $session->data['finish'] == 'true') {
    $request->get['rt'] = 'finish';
}
try {
    // Document
    $document = new ADocument();
    $document->setBase(HTTP_SERVER);
    $registry->set('document', $document);
    // Page Controller
    $page_controller = new APage($registry);
    // Router
    if (!empty($request->get['rt'])) {
        $dispatch = $request->get['rt'];
    } else {
        $dispatch = 'license';
    }
    $page_controller->build('pages/' . $dispatch);
    // Output
    $response->output();
} catch (AException $e) {
    ac_exception_handler($e);
}
//display debug info
ADebug::display();
Esempio n. 2
0
 private function _route()
 {
     $path_nodes = explode('/', $this->rt);
     //Identify what resource do we load explicitely. Page, Responce or API type
     //Check the path. If started with p/, r/ or a/ -> This is explicit call of page, responce or API
     if ($path_nodes[0] == 'p') {
         $this->request_type = 'page';
         $this->rt = preg_replace('/^p\\//', '', $this->rt);
     } else {
         if ($path_nodes[0] == 'r') {
             $this->request_type = 'response';
             $this->rt = preg_replace('/^r\\//', '', $this->rt);
         } else {
             if ($path_nodes[0] == 'a') {
                 $this->request_type = 'api';
                 $this->rt = preg_replace('/^a\\//', '', $this->rt);
             } else {
                 if ($path_nodes[0] == 'task') {
                     $this->request_type = 'task';
                     $this->rt = preg_replace('/^task\\//', '', $this->rt);
                 } else {
                     //find implicit path of controller
                     //Pages section has priority
                     if ($this->_detect_controller("pages")) {
                         $this->request_type = 'page';
                     } else {
                         if ($this->_detect_controller("responses")) {
                             $this->request_type = 'response';
                         } else {
                             if ($this->_detect_controller("api")) {
                                 $this->request_type = 'api';
                             }
                         }
                     }
                 }
             }
         }
     }
     if ($this->request_type == 'page') {
         $page_controller = new APage($this->registry);
         if (!defined('IS_ADMIN') || !IS_ADMIN) {
             //Load required controller for storefront
             $page_controller->addPreDispatch('common/maintenance');
             $page_controller->addPreDispatch('common/seo_url');
         } else {
             //Load required controller for admin
             $page_controller->addPreDispatch('common/home/login');
             $page_controller->addPreDispatch('common/ant');
             $page_controller->addPreDispatch('common/home/permission');
         }
         //Validate controller only. If does not exist process not found
         if ($this->_detect_controller("pages")) {
             // Build the page
             $page_controller->build($this->rt);
         } else {
             $page_controller->build('error/not_found');
         }
     } else {
         if ($this->request_type == 'response') {
             $resp_controller = new ATypeResponse($this->registry);
             if (!defined('IS_ADMIN') || !IS_ADMIN) {
                 //Load required controller for storefront
             } else {
                 //Load required controller for admin
                 $resp_controller->addPreDispatch('responses/common/access/login');
                 $resp_controller->addPreDispatch('responses/common/access/permission');
             }
             //Validate controller only. If does not exist process not found
             if ($this->_detect_controller("responses")) {
                 // Build the response
                 $resp_controller->build($this->rt);
             } else {
                 $resp_controller->build('error/not_found');
             }
         } else {
             if ($this->request_type == 'api') {
                 $api_controller = new AAPI($this->registry);
                 if (!defined('IS_ADMIN') || !IS_ADMIN) {
                     //CORS preflight request
                     $api_controller->addPreDispatch('api/common/preflight');
                     //validate access
                     $api_controller->addPreDispatch('api/common/access');
                 } else {
                     //CORS preflight request
                     $api_controller->addPreDispatch('api/common/preflight');
                     //Validate Admin access, login and permissions
                     $api_controller->addPreDispatch('api/common/access');
                     $api_controller->addPreDispatch('api/common/access/login');
                     $api_controller->addPreDispatch('api/common/access/permission');
                 }
                 //Validate controller only. If does not exist process not found
                 if ($this->_detect_controller("api")) {
                     // Build the response
                     $api_controller->build($this->rt);
                 } else {
                     $api_controller->build('error/not_found');
                 }
             } else {
                 if ($this->request_type == 'task') {
                     $task_controller = new ATypeTask($this->registry);
                     if (!defined('IS_ADMIN') || !IS_ADMIN) {
                         // do not allow to call task controllers from SF-side
                         $resp_controller = new ATypeResponse($this->registry);
                         $resp_controller->build('error/not_found');
                     } else {
                         //Load required controller for admin and check authorization
                         $resp_controller = new ATypeResponse($this->registry);
                         $resp_controller->addPreDispatch('responses/common/access/login');
                         $resp_controller->addPreDispatch('responses/common/access/permission');
                     }
                     //Validate controller only. If does not exist process not found
                     if ($this->_detect_controller("task")) {
                         // Build the response
                         $task_controller->build($this->rt);
                     } else {
                         $resp_controller = new ATypeResponse($this->registry);
                         $resp_controller->build('error/not_found');
                     }
                 } else {
                     //Security: this is not main controller. Do not allow to run it.
                     $this->request_type = 'page';
                     $this->controller = 'error/not_found';
                     $this->method = '';
                     $page_controller = new APage($this->registry);
                     $page_controller->build($this->controller);
                 }
             }
         }
     }
 }