I think a huge disengagement is in order from the EU and North America and also from the Muslim world. Western institutions can't be applied by force in the middle east. Life sucks in Afghanistan and other parts of the middle east, but it is they who have to fight the civil wars and
Here is what I would do if I were European or North American.
Have value tests for people who come into your country.
etc. If they answer wrongly throw away their file and get the next candidate. Throw away those useless people who behave like human vermin.
Withdraw from the Refugee Convention(Explicitly, or in practice). Ideally, what happens is that refugees need a safe place until their home country settles down. So the receiving country builds refugee camps until that happens. This happens in the rest of the world but not in Europe/NA. In Europe/NA the process is like this:
So unless these countries accept that being a refugee is temporary. It is permanent uncontrolled immigration in practice.
Build physical barriers around your country that prevents illegal trespassers. Whether it is dangerous animals, an invading army, or Islamist parasites(I keep repeating myself), a state has the obligation to defend its borders from undesirable elements. Get your act together and have a combination of active duty border control officers/surveillance drones/Early warning detection systems that's enough to stop people from circumventing the system. Send the message that we are compassionate, but that we have a system that you must follow. And if we see the scenes that we saw in Europe late last year, have the courage to shoot on sight to send the message.
Although my solution is hard to imagine, I don't know of another way of doing this.