<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

if (isset($_SERVER['HTTP_REFERER'])) {

    $host_dynamic_array = parse_url($_SERVER['HTTP_REFERER']);
    $host_dynamic = $host_dynamic_array["scheme"] . "://" . $host_dynamic_array["host"] . "/";

    define("APP_SERVER_HOST_URL", $host_dynamic);
    define("SITE_DOMAIN", $host_dynamic_array["host"]);
    
} else if (isset($_SERVER['HTTP_HOST'])) {

    if ($_SERVER['HTTP_HOST'] == APP_DEFAULT_DOMAIN) {
        
        define("APP_SERVER_HOST_URL", "https://" . APP_DEFAULT_DOMAIN . "/");
        define('SITE_DOMAIN', APP_DEFAULT_DOMAIN);
        
    } else {
        
        $ssl = "http://";
        if(ENVIROMENT == 1){
            $ssl = "https://";
        }
        $host_dynamic =  $ssl. $_SERVER['HTTP_HOST'] . "/";
        define("APP_SERVER_HOST_URL", $host_dynamic);
        define('SITE_DOMAIN', $_SERVER['HTTP_HOST']);
        
    }
}else{
    
    define("APP_SERVER_HOST_URL", APP_SERVER_HOST_URL_DEFAULT);
    define('SITE_DOMAIN', APP_DEFAULT_DOMAIN);
}

