How to programmatically do the following operations related to a new site creation programmatically


I wish to create a custom plugin for a custom billing solution that does the following, basically all the following are operations related to creating a new user site under my WPMU site-
(1) I wish to do all of the above programmatically-- ie. not through the WPMU dashboard, but via PHP code- this code can be either made part of my WPMU install (as a plugin) or it can be external code (on another server) that connects to the WPMU database and does the above.
Please let me know which approach you recommend and why(ie code as plugin of the WPMU install or code external to that WPMU install which basically directly does DB operations). Please provide answers to the other points according to your answer to this point.
(2) Create a new site for specified user- with specified user id/email id/name/password.
(3) Assign title and description for this site.
(4) Link either a subdomain/subfolder/regular domain to the newly created site within my WPMU install.
(5) Assign a specific theme (from all available existing WPMU themes) to this user.
(6) Enable or disable theme editing/uploads for that site only.
(7) Enable some specified plugins for that site only.
(8) Enable or disable plugin editing/uploads/deletions for that site only.
(9) Does the domain assignment change if I use a plugin like W3Total Cache? What should I do then?

How can I do all of the above? If you can provide me with clear instructions that would be a great help.

Yours sincerely,