function fsu_handle_entry_inner( $form_id, $response ) {
    if ( FSU_FORM_ID && intval( $form_id ) !== intval( FSU_FORM_ID ) ) {
        return;
    }

    $entry_id = fsu_get_latest_entry_id( $form_id );
    if ( ! $entry_id ) {
        fsu_log( "No entry found for form $form_id" );
        return;
    }

    $meta_data = fsu_get_raw_meta( $entry_id );
    if ( empty( $meta_data ) ) {
        fsu_log( "No meta rows found for entry_id $entry_id" );
        return;
    }

    $s3 = fsu_get_s3_client();
    if ( ! $s3 ) {
        fsu_log( 'S3 client could not be created - check wp-config.php' );
        return;
    }

    $files_found = 0;

    foreach ( $meta_data as $field_name => $value ) {
        if ( strpos( $field_name, 'upload-' ) !== 0 ) continue;
        if ( ! is_array( $value ) ) continue;

        $file_paths = fsu_extract_file_paths( $value );

        foreach ( $file_paths as $local_path ) {
            $files_found++;

            if ( ! file_exists( $local_path ) ) {
                fsu_log( "Entry $entry_id: file missing on disk ($field_name)" );
                continue;
            }

            $s3_key = 'forminator-uploads/' . $form_id . '/' . $entry_id . '/' . basename( $local_path );

            try {
                $result = $s3->putObject([
                    'Bucket'               => FSU_BUCKET,
                    'Key'                  => $s3_key,
                    'SourceFile'           => $local_path,
                    'ServerSideEncryption' => 'AES256',
                ]);

                if ( $result['@metadata']['statusCode'] === 200 ) {
                    @unlink( $local_path );
                    fsu_log( "Entry $entry_id: uploaded and removed $field_name" );
                } else {
                    fsu_log( "Entry $entry_id: non-200 status for $field_name" );
                }
            } catch ( AwsException $e ) {
                fsu_log( "Entry $entry_id: S3 FAILED for $field_name - " . $e->getMessage() );
            }
        }
    }

    fsu_log( "Entry $entry_id: done, $files_found file(s) processed" );
}<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://policecheckau.com.au/sitemap-stylesheet.xsl"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <sitemap>
    <loc>https://policecheckau.com.au/post-type-elementor-hf-sitemap-1.xml</loc>
    <lastmod>2026-09-06T07:12:39+00:00</lastmod>
  </sitemap>
  <sitemap>
    <loc>https://policecheckau.com.au/post-type-elementor_library-sitemap-1.xml</loc>
    <lastmod>2026-09-06T07:12:39+00:00</lastmod>
  </sitemap>
  <sitemap>
    <loc>https://policecheckau.com.au/post-type-page-sitemap-1.xml</loc>
    <lastmod>2026-09-06T07:12:39+00:00</lastmod>
  </sitemap>
  <sitemap>
    <loc>https://policecheckau.com.au/post-type-post-sitemap-1.xml</loc>
    <lastmod>2026-09-06T07:12:39+00:00</lastmod>
  </sitemap>
  <sitemap>
    <loc>https://policecheckau.com.au/post-type-sureforms_form-sitemap-1.xml</loc>
    <lastmod>2026-09-06T07:12:39+00:00</lastmod>
  </sitemap>
  <sitemap>
    <loc>https://policecheckau.com.au/taxonomy-type-category-sitemap-1.xml</loc>
    <lastmod>2026-09-06T07:12:39+00:00</lastmod>
  </sitemap>
</sitemapindex>
