Skip to content

Commit eedd801

Browse files
authored
Merge pull request #43 from nliautaud/33-relpath
Fix #33 css path breaking on some server configurations
2 parents 932f047 + 37eaba5 commit eedd801

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

p01-contact/src/P01contact.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,19 @@ public function __construct()
2626

2727
define('P01C\SERVERNAME', $_SERVER['SERVER_NAME']);
2828
define('P01C\SERVERPORT', $_SERVER['SERVER_PORT']);
29+
define('P01C\SCRIPTNAME', $_SERVER['SCRIPT_NAME']);
30+
define('P01C\SCRIPTPATH', get_included_files()[0]);
31+
2932
define('P01C\HTTPS', !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off');
3033
define('P01C\PORT', SERVERPORT && SERVERPORT != 80 && SERVERPORT != 443 ? ':'.SERVERPORT : '');
3134
define('P01C\PROTOCOL', HTTPS || SERVERPORT == 443 ? 'https' : 'http');
3235
define('P01C\SERVER', PROTOCOL . '://' . SERVERNAME . PORT);
3336
define('P01C\PAGEURI', $_SERVER['REQUEST_URI']);
3437
define('P01C\PAGEURL', SERVER . PAGEURI);
3538

36-
define('P01C\PATH', dirname(dirname(__FILE__)) . '/');
37-
define('P01C\RELPATH', substr(PATH, strlen($_SERVER['DOCUMENT_ROOT'])));
39+
define('P01C\PATH', dirname(__DIR__) . '/');
40+
define('P01C\ROOT', str_replace(SCRIPTNAME,'', SCRIPTPATH));
41+
define('P01C\RELPATH', str_replace(ROOT, '', PATH));
3842

3943
define('P01C\LANGSPATH', PATH . 'lang/');
4044
define('P01C\TPLPATH', PATH . 'src/templates/');

0 commit comments

Comments
 (0)