__NAME__'; $navpage_template = ''; $site_dirs = array_diff(scandir($static_page_dir), array('.', '..')); $nav_out = ""; foreach($site_dirs as $site_dir){ $pages_dir = array_diff(scandir("$static_page_dir$site_dir"), array('.', '..')); $navsite = $navsite_template; $site_location = "$protocol$site_dir.$domain.$tld/$default_page"; $site_class = "class=\"navsite_link\""; $site_name = str_replace("_", " ", $site_dir); $navsite = str_replace("__CLASS__", $site_class, $navsite); $navsite = str_replace("__LOCATION__", $site_location, $navsite); $navsite = str_replace("__NAME__", $site_name, $navsite); if($subdomain == $site_dir){ //this is the current page $site_class = "class=\"navsite_link active\""; } $navpages = ""; foreach($pages_dir as $page_dir){ $navpage = $navpage_template; $page_class = "class=\"navpage_link\""; if($subdomain == $site_dir && $page_name == $page_dir){ $page_class = "class=\"navpage_link active\""; } $page_location = "$protocol$site_dir.$domain.$tld/$page_dir"; $page_name = str_replace("_", " ", $page_dir); $page_name = explode(".", $page_name)[0]; $navpage = str_replace("__CLASS__", $page_class, $navpage); $navpage = str_replace("__LOCATION__", $page_location, $navpage); $navpage = str_replace("__NAME__", $page_name, $navpage); $navpages .= $navpage; } $navsite = str_replace("__NAVPAGES__", $navpages, $navsite); $nav_out .= $navsite; } return $nav_out; ?>