Cardiff came from 4-1 down to beat Burnley 5-4.