} 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 } } } /** * Simple function used to assign a value to a key for the response * * This function will assign the given value to the key which will later be used for sending a response to the client. * * @param string $key The key to use * @param mixed $value The value to assign to the given key */ function set($key, $value) { global $_RESPONSE;
Lightwork::Done(0, 'CRONJOBS_DONE'); // We are done here, output proper exit code } else { Lightwork::Done(0, 'CRONJOBS_IDLE'); } // No cronjobs were executed - we are idling } else { if (isset($cronjob['status']) && isset($cronjob['message'])) { Lightwork::Done($cronjob['status'], $cronjob['message']); } else { if (is_file(CRONJOB_DIR . $cronjob['path'] . '.php')) { execute($cronjob); // Cronjob exists and we can execute it Lightwork::Done(0, 'CRONJOB_DONE'); } else { Lightwork::Done(1, 'CRONJOB_VANISHED'); } // File could not be found } } function execute($cronjob) { ob_start(); // Start output caching require CRONJOB_DIR . $cronjob['path'] . '.php'; // Require cronjob ob_end_clean(); // Omit cached output Lightwork::Log('Cronjob executed: ' . $cronjob['name']); // Log success Database::Query(LWC::QUERY_CRONJOB_UPDATE, [':id', $cronjob['id'], PDO::PARAM_INT]);
$read = 8192; } // Still plenty of bytes left - use default 8192 as chunk size echo fread($stream, $read); // Read the bytes from the stream $done += $read; // Add read bytes to done bytes flush(); // Flush this chunk to the browser to allow an instant download start } if ($file['buffer']) { $file['limit'] = $file['limit'] / 8; // Since we enabled a buffering boost earlier we need to "reset" it now $file['buffer'] = false; // Disable buffering for the next read } sleep(1); // Sleep one second to meet kB/s limitation } else { echo fread($stream, 8192); // No download limit is applied, keep reading in small chunks till the end flush(); } } } else { Lightwork::Done(404, 'ERROR_FILE_VANISHED'); } // File exists in database but not on disk } } }
if (!$page['partial']) { echo '</div>'; } // Close the open container div (if this is no partial site) if ($success) { if ($page['cache']) { $content = ob_get_flush(); // The page was created successfully and we can flush it Cache::Write('pages/' . Translation::Language() . '/' . $page['id'], $content, $page['cacheduration'], true); // Write the successfully embeded page to cache } } else { ob_end_clean(); Lightwork::Log('Page is missing: ' . $page['path'] . '.', Lightwork::LOG_WARN); // Page is missing, log this Lightwork::Done(404, 'ERROR_PAGE_VANISHED'); // Page did not embed successfully - it is supposed to be there but isn't } } } } } function embed($page) { if ($page['type'] == 'static' && is_file(PAGES_DIR . $page['path'] . '.html')) { readfile(PAGES_DIR . $page['path'] . '.html'); } else { if ($page['type'] == 'dynamic' && is_file(PAGES_DIR . $page['path'] . '.php')) { require PAGES_DIR . $page['path'] . '.php'; } else { if ($page['type'] == 'handler' && is_file(PAGES_DIR . $page['path'] . DIRECTORY_SEPARATOR . 'handler.php')) {