ADMIN MODE"; } // To add a new page add its basename without an extension to this pagearr array (only needed so we can control the GET vars like with google translate or Facebook and for canonical) -- pages in array that start with x are for testing new layouts when the symlink and posts/page exists. $pagearr = array('core-values', 'installation-implementation-services', 'resource-management', 'network-support-services', 'security-services', 'careers', 'contact-us', 'about-us', 'engineering-support-center', 'privacy-policy', 'terms-conditions', 'cards', 'test', 'template', 'resume-and-interview-tips', 'customer-testimonials', 'test', 'restart', 'rogers', 'template', 'xmain', 'xinstallation-implementation-services', 'xresource-management', 'xnetwork-support-services', 'xcareers', 'xengineering-support-center', 'xabout-us' ); //some configs $siteurl = 'kcitelecom.com';// used when its easier to do rather than typing it all the time //Figure out what is in the URL $uripath = $_SERVER["REQUEST_URI"]; $uripath = explode('/', $uripath); $page = $uripath[1]; //TODO CHANGE BACK TO 1 FOR PRODUCTION $subpage = $uripath[2]; $tripage = $uripath[2]; //some default vars that will eventually get gleened from the content page that is included $title = "KCI Telecommunications | Designed for Success, Engineered for Reliability"; $content = "TEST"; $description = "KCI LLC leads the way in the telecom industry."; if(in_array($page, $pagearr)){ $contentpage = "./posts/$page.php"; }else{ $contentpage = "./posts/main.php"; } $pagescripts = ""; $pagescriptsoveride= ""; $pagestyles = ""; $pagestylesoveride = ""; // redirect back to ctac.kcitelecom.com if page is helpdesk if($page === "helpdesk" || $page === "testpdesk" || $page === "gitproject" || $page === "IntraPortal" ){ $uri = $_SERVER['REQUEST_URI']; $uri = preg_replace('/^\/kci/', '', $uri);// TODO only needed on dev server header("HTTP/1.1 301 Moved Permanently"); header("Location: https://ctac.kcitelecom.com$uri"); } // displaying the orange dot div under the logo with php to prevent CLS when doing with JS $dotdisp = ""; if($page){ $dotdisp = "style='display: none;'"; } // This is to segregate the new xdesign so later we can just set it to true - for future designs do something similar $xmain = true; if(str_starts_with($page, 'x') || $page === "template" ){ $xmain = true; } //make a random string for cache busting while in dev mode function rand_str($len = 10, $chars = 'abcdefghijklmnopqrstuvwxyz0123456789') { $num_chars = strlen($chars); $ret = ''; for($i = 0; $i < $len; ++$i) { $ret .= $chars[mt_rand(0, $num_chars)]; } return $ret; } $rs = rand_str(6); $rs = "?r=$rs"; //$rs = ""; $debug = 'debug'; // REDIRECT if page starts with page string and there is a GET but page doesnt match because there is no trailing slashlash then redirect to add a slash and re-add the GET so we can show the correct content page thanks alot google! foreach($pagearr as $p){ if(preg_match("/^$p/", $page)){ //$debug = 'matches'; $pfrag = $page; $plink = "https://$siteurl/$page/"; if(strstr($page, '?')){ $dget = explode('?', $page); $pfrag = $dget[0];// the pagefrag $getfrag = $dget[1]; //$debug = "wt $dget"; $debug = "https://$siteurl/$pfrag/?$getfrag"; $plink = "https://$siteurl/$pfrag/?$getfrag"; header("HTTP/1.1 301 Moved Permanently"); header("Location: $plink"); } if(strstr($page, '&') ){ if(!strstr($page, '?') ){ $dget = explode('&', $page); $pfrag = $dget[0];// the pagefrag $getfrag = $dget[1]; //$debug = "wt $dget"; $debug = "https://$siteurl/$pfrag/&$getfrag"; $plink = "https://$siteurl/$pfrag/&$getfrag"; header("HTTP/1.1 301 Moved Permanently"); header("Location: $plink"); } } } } // end foreach //redirection for blog pages that do not have a trailing slash // if page and there is no trailing slash then redirect it to one that does $rt = $_SERVER['REQUEST_URI']; if(in_array($page, $pagearr)){ if($debug === 'debug'){ // if debug wasn't set above if( substr($rt,-1) !== '/' ){ header("HTTP/1.1 301 Moved Permanently"); header("Location: https://$siteurl/$page/"); } } } // End REDIRECTS $navcss = "navactive"; // Fall back PAGE INFO for pages that can't do heredocs or are not defined switch($page){ case "test": $title = "THE TEST PAGE"; $description = "TEST descriptioin"; break; case "another-fake-page": $title = "KCI Telecommunications | Professional Services"; $description = "Minimize risk and maximize performance for you and your customers with a variety of professional services from KCI."; break; default: $title = "KCI Telecommunications | Designed for Success, Engineered for Reliability"; $description = "KCI LLC leads the way in the telecom industry."; break; } // Include the content page // no page in URL so it's main if(!$page){ $contentpage = "./posts/main.php";// TODO prefix with kci/posts/main.php for kci server include $contentpage; } //not main so include the content page if it exists if( $page && file_exists($contentpage)){ include $contentpage; } ?>