NSA phone spying program ruled illegal by US court