Get Site ID by subdomain on server side

Hey all,

I need to determine the piwik site id on the server side.
Subdomain is sent as a tracking parameter and the php code needs to determine the according site id.

Can you tell me where the best place in the source code would be to add the needed code. (In my opinion the place would be inside the piwik.php file)

Regards,
Johannes