|
94 | 94 | * MantisBT Path Settings *
|
95 | 95 | **************************/
|
96 | 96 |
|
| 97 | +$t_protocol = 'http'; |
| 98 | +$t_host = 'localhost'; |
97 | 99 | if ( isset ( $_SERVER['SCRIPT_NAME'] ) ) {
|
98 |
| - $t_protocol = 'http'; |
99 | 100 | if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) ) {
|
100 | 101 | $t_protocol= $_SERVER['HTTP_X_FORWARDED_PROTO'];
|
101 | 102 | } else if ( !empty( $_SERVER['HTTPS'] ) && ( strtolower( $_SERVER['HTTPS'] ) != 'off' ) ) {
|
|
122 | 123 | $t_host = $_SERVER['SERVER_NAME'] . $t_port;
|
123 | 124 | } else if ( isset( $_SERVER['SERVER_ADDR'] ) ) {
|
124 | 125 | $t_host = $_SERVER['SERVER_ADDR'] . $t_port;
|
125 |
| - } else { |
126 |
| - $t_host = 'localhost'; |
127 | 126 | }
|
128 | 127 |
|
129 | 128 | if ( !isset( $_SERVER['SCRIPT_NAME'] )) {
|
|
132 | 131 | echo ' Please try to add "fastcgi_param SCRIPT_NAME $fastcgi_script_name;" to the nginx server configuration.';
|
133 | 132 | die;
|
134 | 133 | }
|
135 |
| - $t_self = $_SERVER['SCRIPT_NAME']; |
136 |
| - $t_self = filter_var($t_self, FILTER_SANITIZE_STRING); |
| 134 | + $t_self = filter_var( $_SERVER['SCRIPT_NAME'], FILTER_SANITIZE_STRING ); |
137 | 135 | $t_path = str_replace( basename( $t_self ), '', $t_self );
|
138 |
| - $t_path = basename( $t_path ) == "admin" ? rtrim( dirname( $t_path ), '/\\' ) . '/' : $t_path; |
139 |
| - $t_path = basename( $t_path ) == "soap" ? rtrim( dirname( dirname( $t_path ) ), '/\\' ) . '/' : $t_path; |
| 136 | + switch( basename( $t_path ) ) { |
| 137 | + case 'admin': |
| 138 | + $t_path = rtrim( dirname( $t_path ), '/\\' ) . '/'; |
| 139 | + break; |
| 140 | + case 'soap': |
| 141 | + $t_path = rtrim( dirname( dirname( $t_path ) ), '/\\' ) . '/'; |
| 142 | + break; |
| 143 | + case '': |
| 144 | + $t_path = '/'; |
| 145 | + break; |
| 146 | + } |
140 | 147 | if( strpos( $t_path, '&#' ) ) {
|
141 | 148 | echo 'Can not safely determine $g_path. Please set $g_path manually in config_inc.php';
|
142 | 149 | die;
|
143 | 150 | }
|
144 |
| - $t_url = $t_protocol . '://' . $t_host . $t_path; |
145 |
| - |
146 | 151 | } else {
|
147 |
| - $t_path = ''; |
148 |
| - $t_host = ''; |
149 |
| - $t_protocol = ''; |
| 152 | + $t_path = 'mantisbt/'; |
150 | 153 | }
|
151 | 154 |
|
152 | 155 | /**
|
153 | 156 | * path to your installation as seen from the web browser
|
154 | 157 | * requires trailing /
|
155 | 158 | * @global string $g_path
|
156 | 159 | */
|
157 |
| -$g_path = isset( $t_url ) ? $t_url : 'http://localhost/mantisbt/'; |
| 160 | +$g_path = $t_protocol . '://' . $t_host . $t_path; |
158 | 161 |
|
159 | 162 | /**
|
160 | 163 | * path to your images directory (for icons)
|
|
0 commit comments