Example #1
0
     Lightwork::Done($script['status'], $script['message']);
 } else {
     if ($script['method'] != METHOD && $script['method'] != 'ANY') {
         Lightwork::Done('error', 'SCRIPT_METHOD_NOT_ALLOWED');
     }
     // The allowed method (GET, POST, PUT, ...) doesn't match with this request
     prepare();
     // This will modify the request so it is easier to parse
     if (!is_null($script['validator'])) {
         $form = new Form($script['validator']);
         // Initialize a new form
         if (!$form->checkHoneypot()) {
             // Check the honeypot (if form has one)
             Lightwork::Done('error', 'SCRIPT_HONEYPOT_ERROR');
         } else {
             if (!$form->checkFields()) {
                 // Check the actual data according to form settings (will do server-side validation of fields)
                 Lightwork::Done('error', 'SCRIPT_BAD_REQUEST');
             }
         }
     }
     if (is_file(SCRIPTS_DIR . $script['path'] . '.php')) {
         ob_start();
         require SCRIPTS_DIR . $script['path'] . '.php';
         // Require the script if it exists
     } else {
         Lightwork::Done('error', 'SCRIPT_VANISHED');
     }
     // Script should be there according to database but isn't
     Lightwork::Done('error', 'SCRIPT_UNDONE');
     // The script didn't call done function after executing