A Model of Solar Flares