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'])) {
         $storage = new StorageArea();
         // Export archive
         $model = new Ai1wm_Export();
         $file = $model->export($storage, $options);
         // Send the file to the user
         header('Content-Description: File Transfer');
         header('Content-Type: application/octet-stream');
         header(sprintf('Content-Disposition: attachment; filename=%s-%s.%s', Ai1wm_Export::EXPORT_ARCHIVE_NAME, time(), 'zip'));
         header('Content-Transfer-Encoding: binary');
         header('Expires: 0');
         header('Cache-Control: must-revalidate');
         header('Pragma: public');
         header('Content-Length: ' . filesize($file->getAs('string')));
         // Clear output buffering and read file content
         if (ob_get_length() > 0) {
             @ob_end_clean();
         }
         readfile($file->getAs('string'));
         $storage->flush();
         exit;
     }
 }
 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;
     }
 }