Best Way To Make User Defined Theme Module


I am wanting to create a place where users can upload their own theme to design / style a certain area of a web app I am creating.

What is the best way to do this?

Basically they upload their html / css with some variables in it which is populated from the PHP which they do not have access to. The variables may need to contain loops and if statements etc.