I think "safe" is really a matter of choosing the right one. I've heard lots of stories of people getting sugar pills, or nothing at all. Did a quick search, there's plenty of sites that do reviews of them like
this one that seems to be pretty in depth.
As far as legality, I've got no clue but it seems it will depend on source and whether or not you have a script?