added define to determine if script was called via the api
moved api functions to inc/functions.php
sessions are no longer started if script was called through api
outputs error in json or xml if unable to connect to database and script is called with api
fixed bug causing script not to exit properly if database connection couldn't be opened
fixed bug with get_error() outputing error in wrong format (json or xml)