diff --git a/config/constant.php b/config/constant.php index 1a5d42c..71abd7d 100644 --- a/config/constant.php +++ b/config/constant.php @@ -18,43 +18,6 @@ */ define('ROOT', str_replace('index.php', '', $_SERVER['SCRIPT_FILENAME'])); -/** - * Get App domain - * define default domain - */ -/** - * Get host domain ip address - * @return string - */ -function getDomainIP(): string -{ - $ip = $_SERVER['REMOTE_ADDR']; - - if (!empty($_SERVER['HTTP_CLIENT_IP'])) { - $ip = $_SERVER['HTTP_CLIENT_IP']; - } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { - $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; - } elseif ($ip == '::1') { - $ip = gethostbyname(getHostName()); - } - return $ip; -} - -/** - * Get server information's - * @return object - */ -function serverDomain(): object -{ - $server_name = $_SERVER['SERVER_NAME']; - $protocol = isset($_SERVER['SERVER_PROTOCOL']) ? strtolower(explode('/', $_SERVER['SERVER_PROTOCOL'])[0]) : 'http'; - $domain = getDomainIp() === '127.0.0.1' ? "$protocol://$server_name" : $server_name; - return (object)[ - 'server_name' => $server_name, - 'protocol' => $protocol, - 'domain' => $domain - ]; -} /** * Define default domain diff --git a/config/init.php b/config/init.php index 2d5e1dc..1f1c73f 100644 --- a/config/init.php +++ b/config/init.php @@ -5,6 +5,47 @@ session_start(); +/** + * Get App domain + * define default domain + */ +/** + * Get host domain ip address + * @return string + */ +function getDomainIP(): string +{ + $ip = $_SERVER['REMOTE_ADDR']; + + if (!empty($_SERVER['HTTP_CLIENT_IP'])) { + $ip = $_SERVER['HTTP_CLIENT_IP']; + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { + $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; + } elseif ($ip == '::1') { + $ip = gethostbyname(getHostName()); + } + return $ip; +} + +/** + * Get server information's + * @return object + */ +function serverDomain(): object +{ + $server_name = $_SERVER['SERVER_NAME']; + $protocol = isset($_SERVER['SERVER_PROTOCOL']) ? strtolower(explode('/', $_SERVER['SERVER_PROTOCOL'])[0]) : 'http'; + $domain = getDomainIp() === '127.0.0.1' ? "$protocol://$server_name" : $server_name; + return (object)[ + 'server_name' => $server_name, + 'protocol' => $protocol, + 'domain' => $domain + ]; +} + +/* + * + */ require_once $ROOT_DIR . '/config/constant.php'; /** * Application Global Configuration