Esempio n. 1
0
        $action = 'Index';
    } else {
        $action = ucfirst(!empty($params['_action']) ? $params['_action'] : 'Index');
    }
}
// permission check
$objPermissions = Permissions::getInstance();
$hasPermission = $objPermissions->actionAllowed($controller, $action, $objAuthentication->user_id);
if (!$hasPermission) {
    $controller = 'Error';
    $action = 'Permission';
}
// start up
try {
    $objSettings->loadSettings();
    $objDispatcher->setDirectory('backend');
    $objDispatcher->setController($controller);
    $objDispatcher->setAction($action);
    $objDispatcher->setParams($params);
    $objDispatcher->dispatch();
} catch (Exception $e) {
    $objEmail = new Emailer();
    $objEmail->addTO(ERROR_EMAIL);
    $objEmail->setFrom(ERROR_EMAIL);
    $objEmail->setSubject('FATAL ERROR | Exception thrown on ' . URL);
    $objEmail->setBody('Fatal Exception! ' . $e->getMessage());
    $objEmail->sendMail();
    die('Error<br/>' . $e->getMessage() . '<br/><a href="http://' . URL . '">' . PRODUCT_NAME . '</a>');
}
// time to clean up
$dbQueries = $objDatabase->getNumbQueries();
Esempio n. 2
0
    //$objEmail->sendMail();
    die('Unable to connect to database.');
}
$objAuthentication = Authentication::getInstance();
$objSettings = Settings::getInstance();
$objDispatcher = new Dispatcher();
// custom url rewriting
$objUrls = new FriendlyurlModel();
$objUrls->parseRequest($params['_urlrequest']);
if (!empty($objUrls->requestParams)) {
    $params = array_merge($params, $objUrls->requestParams);
}
// start up
try {
    $objSettings->loadSettings();
    $objDispatcher->setDirectory('frontend');
    $objDispatcher->setController($objUrls->requestController);
    $objDispatcher->setAction($objUrls->requestAction);
    $objDispatcher->setParams($params);
    $objDispatcher->dispatch();
} catch (Exception $e) {
    $objEmail = new Emailer();
    $objEmail->addTO(ERROR_EMAIL);
    $objEmail->setFrom(ERROR_EMAIL);
    $objEmail->setSubject('FATAL ERROR | Exception thrown on ' . URL);
    $objEmail->setBody('Fatal Exception! ' . $e->getMessage() . print_r($params, true));
    //$objEmail->sendMail();
    die('Error<br/>' . $e->getMessage() . '<br/><a href="http://' . URL . '">' . PRODUCT_NAME . '</a>');
}
// time to clean up
$dbQueries = $objDatabase->getNumbQueries();
Esempio n. 3
0
 function actionSubmit($params2 = '')
 {
     // loading $params from global so that the View can load the proper _urlrequest
     global $params;
     $params = array_merge($params, $params2);
     $hasError = false;
     $formErrors = array();
     if (!empty($params['formSubmit'])) {
         $objEmail = new EmailSender();
         $objForm = new FormModel();
         if (!empty($params['formSubmit']['id'])) {
             $formInfo = $objForm->loadForm($params['formSubmit']['id']);
             // validate forms fields
             if (!empty($formInfo['fields'])) {
                 foreach ($formInfo['fields'] as $formField) {
                     if ($formField['required'] == 1) {
                         if (empty($params['formSubmit']['fields'][$formField['id']])) {
                             $hasError = true;
                             $formError = array('field_id' => $formField['id'], 'errorMsg' => $formField['name'] . ' is required.');
                             $formErrors[] = $formError;
                         }
                     }
                 }
             }
             if ($hasError) {
                 // return to page with error message
                 if (!empty($params['returnUrlRequest']) && $params['returnUrlRequest'] != 'Form/submit') {
                     $objDispatcher = new Dispatcher();
                     $objFriendlyUrl = new FriendlyurlModel();
                     $objFriendlyUrl->parseRequest($params['returnUrlRequest']);
                     $controller = $objFriendlyUrl->requestController;
                     $action = $objFriendlyUrl->requestAction;
                     $params = array_merge($params, $objFriendlyUrl->requestParams);
                     $params['_urlrequest'] = $params['returnUrlRequest'];
                     $params['formErrors'] = $formErrors;
                     $objDispatcher->setDirectory('frontend');
                     $objDispatcher->setController($controller);
                     $objDispatcher->setAction($action);
                     $objDispatcher->setParams($params);
                     $objDispatcher->dispatch();
                     exit;
                 } else {
                     die('Please go back and retry submitting the form. Errors: ' . print_r($formErrors));
                 }
             }
             // save to database
             $submission_id = $this->saveToDb($params);
             if ($submission_id) {
                 $params['submission_id'] = $submission_id;
             }
             // email notification
             $objEmail->sendForm($params);
             // return to page with thanks message
             if (!empty($params['returnUrlRequest'])) {
                 header("Location: http://" . URL . '/' . $params['returnUrlRequest'] . '?formSubmitted=true');
             } else {
                 header("Location: http://" . URL . '/');
             }
         }
     }
 }