function cw_mobile_get_domain_data_by_alias(&$host_data)
{
    global $tables, $app_dir;
    if (isset($host_data['mobile_host'])) {
        return $host_data;
    }
    $host_value = cw_mobile_get_host();
    if (isset($host_data['domain_id'])) {
        $host_data['mobile_host'] = cw_mobile_get_mobile_host_attr_by_domain_id($host_data['domain_id']);
    } else {
        // Get domain by HTTP_HOST
        $result = cw_mobile_get_domain_by_mobile_host_attr($host_value);
    }
    if (!empty($result)) {
        $host_data = $result;
    }
    if ($host_data['mobile_host'] == $host_value && is_dir($app_dir . $host_data['skin'] . mobile_addon_skin_prefix)) {
        $host_data['http_host'] = $host_data['mobile_host'];
        $host_data['skin'] .= mobile_addon_skin_prefix;
    }
    return $host_data;
}
$domain = cw_mobile_get_domain_data();
$domain_mobile_host = $HTTPS ? 'https://' : 'http://';
$domain_mobile_host .= !empty($domain['mobile_host']) ? $domain['mobile_host'] : $domain['http_host'];
$domain_full_host = $HTTPS ? $domain['https_host'] : $domain['http_host'];
// if user select mobile version
if ($mobile_mobile_flag == 'on' || cw_mobile_get_host() == $domain['mobile_host'] && $mobile_mobile_flag != 'on' && $mobile_select_type == 2) {
    $mobile_select_type = 1;
} else {
    if ($mobile_mobile_flag == 'off' || cw_mobile_get_host() == $domain_full_host && $mobile_mobile_flag != 'off' && $mobile_select_type == 1) {
        $mobile_select_type = 2;
    } else {
        if ($mobile_device_type == 'mobile' && !$mobile_was_redirect) {
            if (!empty($domain) && is_dir($app_dir . $domain['skin'] . mobile_addon_skin_prefix)) {
                $param = '';
                // if mobile host not set or have equal host, but have mobile skin folder, then mobile_mobile_flag set to on
                if (empty($domain['mobile_host']) || !empty($domain['mobile_host']) && $domain['mobile_host'] == cw_mobile_get_host()) {
                    $mobile_mobile_flag = 'on';
                    $param = '/index.php?mobile_version=on';
                }
                $mobile_select_type = 1;
                $mobile_was_redirect = 1;
                if (!empty($REQUEST_URI)) {
                    $redirect = $domain_mobile_host . $REQUEST_URI;
                } else {
                    $redirect = $domain_mobile_host . $domain['web_dir'] . $param;
                }
                cw_header_location($redirect);
            }
        }
    }
}