1<body>
2<?php
3 define('ROOT_PATH', dirname(__DIR__).'/');
4 include ROOT_PATH.'header.php';
5 include ROOT_PATH.'main.php';
6 include ROOT_PATH.'footer.php';
7?>
8</body>
1function getHtmlRootFolder(string $root = '/var/www/') {
2
3 // -- try to use DOCUMENT_ROOT first --
4 $ret = str_replace(' ', '', $_SERVER['DOCUMENT_ROOT']);
5 $ret = rtrim($ret, '/') . '/';
6
7 // -- if doesn't contain root path, find using this file's loc. path --
8 if (!preg_match("#".$root."#", $ret)) {
9 $root = rtrim($root, '/') . '/';
10 $root_arr = explode("/", $root);
11 $pwd_arr = explode("/", getcwd());
12 $ret = $root . $pwd_arr[count($root_arr) - 1];
13 }
14
15 return (preg_match("#".$root."#", $ret)) ? rtrim($ret, '/') . '/' : null;
16}
17