To get the domain you're currently visiting with php, you can use $_SERVER['SERVER_NAME']
.
Your question about bulk registration depends on your domain registrar and whether they do provide an API. If they do, documentation and help should be available from them.