403 ) ); } $file = sanitize_file_name( wp_unslash( (string) $_GET['download'] ) ); if ( '' === $file || false !== strpos( $file, '..' ) ) { wp_die( esc_html__( 'Invalid file name.', 'backupino' ), '', array( 'response' => 400 ) ); } $packages_dir = Plugin::instance()->paths()->packages(); $path = $packages_dir . '/' . $file; if ( preg_match( '/(?:^|-)installer\.php$/i', $file ) ) { $stem = preg_replace( '/(?:^|-)installer\.php$/i', '', $file ); $archive_path = $packages_dir . '/' . $stem . '.zip'; if ( is_readable( $archive_path ) ) { $builder = new InstallerBuilder(); $code = $builder->build_for_package( $archive_path, Plugin::instance()->settings() ); if ( '' !== $code ) { Fs::stream_string_download( $code, 'installer.php' ); } } if ( is_readable( $path ) ) { Fs::stream_download( $path, 'installer.php' ); } wp_die( esc_html__( 'This package no longer exists on the server.', 'backupino' ), '', array( 'response' => 404 ) ); } if ( ! is_readable( $path ) ) { wp_die( esc_html__( 'This package no longer exists on the server.', 'backupino' ), '', array( 'response' => 404 ) ); } Fs::stream_download( $path ); } }