Where is the best place to catch useragent?

You can use the filter template_include. wp-includes/template-loader.php is where template is included.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)