Filament activity and photospheric magnetic evolution related to flares