Basically these are just authorized "indulgences" called by another name, and hiding behind a different color of cloth, but the "brothel" example is still happening in some places today, not hundreds of years ago...
It’s called Nikah Mutah and Nikah Misyar, in Shia and Sunni Islamic traditions... basically, Sharia-sanctioned prostitution.
Discuss this with your friendly neighbourhood Muzzie, and watch them cringe.