Last active
November 12, 2019 02:16
-
-
Save nawawi/1d0c9914f5cfd1ae8511db1ede2b96c9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function _basehost() { | |
| if ( !empty($_SERVER["HTTP_HOST"]) ) { | |
| $schema = ( !empty($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"]) == "on") ? "https://": "http://"; | |
| $host = $_SERVER["HTTP_HOST"]; | |
| return $schema.$host; | |
| } | |
| return null; | |
| } | |
| function _baseurl() { | |
| if ( !empty($_SERVER['SCRIPT_NAME']) ) { | |
| $base = substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], "/")+1); | |
| if ( $base != '/') $base = rtrim($base,'/'); | |
| $host = _basehost(); | |
| $base = ( !empty($host) ? ( ( $base != '/' ) ? $host.$base : $host."/".$base ) : ( ( $base != '/' ) ? $base : "" ) ); | |
| return rtrim($base,'/'); | |
| } | |
| return null; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment