public static function export() { // Set default handlers set_error_handler(array('Ai1wm_Error', 'error_handler')); set_exception_handler(array('Ai1wm_Error', 'exception_handler')); // Get options if (isset($_POST['options']) && ($options = $_POST['options'])) { // Log options Ai1wm_Logger::debug(AI1WM_EXPORT_OPTIONS, $options); // Export site $model = new Ai1wm_Export($options); $file = $model->export(); // Send the file to the user header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename=' . self::filename()); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . $file->getSize()); // Clear output buffering and read file content while (@ob_end_clean()) { } // Load file content $handle = fopen($file->getName(), 'rb'); while (!feof($handle)) { echo fread($handle, 8192); } fclose($handle); // Flush storage StorageArea::getInstance()->flush(); exit; } }