$_SERVER["DOCUMENT_ROOT"]."/cache/pagecache/", "lifeTime" => 600, "automaticCleaningFactor" => 50 ); $Cache_Lite = new Cache_Lite($options); $currenturlinfo = parse_url($_SERVER["REQUEST_URI"]); $currentpath = $currenturlinfo["path"]; $cachekey = $_SERVER["HTTP_HOST"]."/".$currentpath.$get_md5_key.$isMobileCacheKey; if ($_GET["LIVE"]) { $Cache_Lite->remove($cachekey); } else { $testvar = 4; $cachedcontent = $Cache_Lite->get($cachekey); /* if ($_SERVER["REMOTE_ADDR"] == "95.209.145.215") { print "key: :".$cachekey.":"; } */ if ($cachedcontent) { $testvar = 5; /* ob_start(); print "-------------------------- Generating cache ---------------------- \n"; print "Path: ".$_SERVER["REQUEST_URI"]."\n"; print "Time: ".date("Y-m-d H:i:s")."\n"; print "testvar: ".$testvar."\n"; print "Host: ".$_SERVER["HTTP_HOST"]."\n"; print $_SERVER["REMOTE_ADDR"]."\n\n"; print_r($_GET); print "\n"; print_r($_POST); print "\n"; $log = ob_get_contents(); ob_end_clean(); $fp = fopen($_SERVER["DOCUMENT_ROOT"]."/martinlog_cache.txt","a"); fwrite($fp,$log); fclose($fp); */ /* if ($_SERVER["REMOTE_ADDR"] == "95.209.145.215") { print "cacheused: ".$cachekey; } */ print $cachedcontent; exit; } } } } else { if ($_SERVER["REMOTE_ADDR"] == "89.236.47.66") { /* ob_start(); print_r($_GET); print_r($_POST); $log = ob_get_contents(); ob_end_clean(); $fp = fopen($_SERVER["DOCUMENT_ROOT"]."/martinlog.txt","a"); fwrite($fp,$log); fclose($fp); */ /* include_once($_SERVER["DOCUMENT_ROOT"]."/cms/class/class.debug.php"); Debug::start(); print "test
Test"; print "
"; Debug::end("martin@siteloom.dk","Test af cache"); exit; */ } } // } /* ob_start(); print "-------------------------- Generating cache ---------------------- \n"; print "Path: ".$_SERVER["REQUEST_URI"]."\n"; print "Time: ".date("Y-m-d H:i:s")."\n"; print "testvar: ".$testvar."\n"; print "Host: ".$_SERVER["HTTP_HOST"]."\n"; print $_SERVER["REMOTE_ADDR"]."\n\n"; print_r($_GET); print "\n"; print_r($_POST); print "\n"; $log = ob_get_contents(); ob_end_clean(); $fp = fopen($_SERVER["DOCUMENT_ROOT"]."/martinlog.txt","a"); fwrite($fp,$log); fclose($fp); */ // redirect file $redirectFile = $_SERVER["DOCUMENT_ROOT"]."/files/design/php/redirect/redirects.php"; if (file_exists($redirectFile)) { require_once($redirectFile); if (count($pageArray) > 0 && is_array($pageArray)) { $parseUrl = parse_url($_SERVER["REQUEST_URI"]); if (substr($parseUrl["path"],-1) == "/") { $parseUrl["path"] = substr($parseUrl["path"],0,-1); } foreach ($pageArray as $redirectPage) { if(substr($redirectPage["oldpath"],-1) == "/") { $redirectPage["oldpath"] = substr($redirectPage["oldpath"],0,-1); } if((($redirectPage["oldpath"] == $parseUrl["path"] || $redirectPage["oldpath"] == $_SERVER["REQUEST_URI"]) && $redirectPage["olddomain"] == $_SERVER["HTTP_HOST"]) || ($redirectPage["starsearch"] == "true" && strpos($_SERVER["REQUEST_URI"],$redirectPage["oldpath"]) === 0) ) { if($redirectPage["newdomain"] == "") { $redirectPage["newdomain"] = $_SITELOOM["website"]; } header("HTTP/1.1 301 Moved Permanently"); Header("Location: http://".$redirectPage["newdomain"].$redirectPage["newpath"]); exit(); break; } } } } session_start(); require_once($_SERVER["DOCUMENT_ROOT"]."/config.php"); /** * Function to ensure that the database-connection is only be opened if needed (and not on cached pages) */ function makeSureDatabaseIsInitialized($connection) { if (!$connection) { global $mysql_host,$mysql_user,$mysql_pass, $mysql_db, $connection; require_once($_SERVER["DOCUMENT_ROOT"]."/cms/db.inc.php"); $GLOBALS["connection"] = $connection; } global $CMS; if ($CMS) { $CMS->setDB($connection); } } /** * Function to put edit session back to what it was before */ function enableEditModeSession() { $_SESSION["edit"] = true; } if (!$_REQUEST["siteloomEditMode"] && $_SESSION["edit"]) { // $_SESSION["logged_in_but_viewing_through_frontend"] = true; // unset($_SESSION["edit"]); // register_shutdown_function('enableEditModeSession'); // Only while fixing - remove this line below after unset($_SESSION["logged_in_but_viewing_through_frontend"]); } else { unset($_SESSION["logged_in_but_viewing_through_frontend"]); } if ($_SESSION["edit"]) { makeSureDatabaseIsInitialized($connection); } // You can specifiy a custom header in config.php for sending specific headers, like UTF-8 or ISO headers. if ($_SITELOOM["CUSTOM_HEADER"]) { header($_SITELOOM["CUSTOM_HEADER"]); } if (substr($_SERVER["REQUEST_URI"],0,7) == "/files/" || substr($_SERVER["REQUEST_URI"],0,6) == "files/") { header("HTTP/1.0 404 Not Found"); print "This page does not exist."; exit; } // Check for "wrong" paths $parsed_script_filename = basename($_SERVER["REQUEST_URI"]); if (strpos($parsed_script_filename,"index.php") !== false) { if ($_SESSION["edit"] || $_SESSION["logged_in_but_viewing_through_frontend"]) { } else { $parsed_path = dirname($_SERVER["REQUEST_URI"]); if ($parsed_path && $parsed_path != "/" && $parsed_path != "\\") { if (is_numeric($_REQUEST["pageid"])) { $locationstr = "http://".$_SERVER["HTTP_HOST"]."/index.php?pageid=".$_REQUEST["pageid"]; } else { $locationstr = "http://".$_SERVER["HTTP_HOST"].$parsed_path; } header("HTTP/1.1 301 Moved Permanently"); header("Location: ".$locationstr); exit; } else { if (!$_SESSION["current_language_id"]) { // User has just typed "index.php" without anything else makeSureDatabaseIsInitialized($connection); require_once($_SERVER["DOCUMENT_ROOT"]."/cms/class/class.cms.php"); $_SESSION["current_language_id"] = $_SITELOOM['default_language']; $pageid = $_REQUEST["pageid"]; $trypage = new Page($pageid); $path = $trypage->path; if ($path) { header("HTTP/1.1 301 Moved Permanently"); header("Location: http://".$_SERVER["HTTP_HOST"]."/".$path); exit; // http://www.greenland-travel.dk/index.php?pageid=257 } } } } } if (is_array($_SITELOOM["main_domains"]) && !in_array($_SERVER["HTTP_HOST"],$_SITELOOM["main_domains"]) || !$_SITELOOM["runs_single_website"] && !$_SESSION["edit"] && !$_SESSION["logged_in_but_viewing_through_frontend"]) { makeSureDatabaseIsInitialized($connection); require_once($_SERVER["DOCUMENT_ROOT"]."/cms/class/class.domainredirects.php"); // See as one of the first things if we're on a domain that should be redirected $try_domains = DomainRedirects::getDomains(); if (is_array($try_domains)) { foreach($try_domains as $try_domain) { if ($try_domain["domainname"] == $_SERVER["HTTP_HOST"]) { if (!trim($try_domain["redirectto"])) { require_once($_SERVER["DOCUMENT_ROOT"]."/cms/class/class.page.php"); $page = new Page($try_domain["pageid"]); $domains = explode("|",$page->config); $newdomainfound = false; foreach ($domains as $domain) { if ($domain == "www.".$_SERVER["HTTP_HOST"]) { $redirectto = $domain; $newdomainfound = true; break; } } if (!$newdomainfound) { $redirectto = $domains[0]; } } else { $redirectto = $try_domain["redirectto"]; } $locationstr = "http://".$redirectto.$_SERVER["REQUEST_URI"]; header("HTTP/1.1 301 Moved Permanently"); header("Location: ".$locationstr); exit; } } } } /********************************************************************************************************************* * Cache start *********************************************************************************************************************/ if (!isset($_SESSION["edit"]) || $_SESSION["logged_in_but_viewing_through_frontend"] == true) { if (include_once($_SERVER["DOCUMENT_ROOT"]."/cms/class/pear/Cache/Lite.php")) { if ($_SESSION["exclude_cache"]) { } else { if ($_SITELOOM["default_cache_all_pages"]) { $CACHE_ENABLED = true; $pageidstocache = array(); } else { if ($_SITELOOM["pageids_to_cache"]) { $pageidstocache = $_SITELOOM["pageids_to_cache"]; $CACHE_ENABLED = true; } } } } } /********************************************************************************************************************* * Cache end *********************************************************************************************************************/ if ($_SITELOOM["usegzhandler"]) { ob_start("ob_gzhandler"); // If the user accepts gzip encoding, then send the page to him compressed (saves loadingtime + bandwidth). } else { ob_start(); } // You can specifiy a custom index_include in config.php for including special header functionality. if ($_SITELOOM["index_include_after_session"]) { require_once($_SITELOOM["index_include_after_session"]); } /* if (true) { require_once($_SERVER["DOCUMENT_ROOT"]."/cms/class/class.profiler.php"); $core_profiler = new Profiler(); $startmicro = $core_profiler->getmicrotime(); print "test:::".round($startmicro - $core_profiler->getmicrotime(),4).":::"; } */ $protocol = "http"; if ($_SERVER["HTTPS"] == "on") { $protocol = "https"; } /******************************************************************************************************************* * HTTPS *******************************************************************************************************************/ if (!isset($_SESSION["administrative_user"]) || !$_SESSION["administrative_user"]) { if ($_SITELOOM["only_https"] && !isset($_SESSION["edit"]) && !$_SESSION["logged_in_but_viewing_through_frontend"]) { if ($_SERVER["HTTPS"] != "on") { header("location: https://".$_SITELOOM["website"]); exit; } } } /******************************************************************************************************************* * Permissions *******************************************************************************************************************/ if (isset($_SESSION["administrative_user"])) { require_once($_SERVER["DOCUMENT_ROOT"]."/cms/class/class.permissions.php"); $permissions = new Permissions(); } if ($_REQUEST["stop_edit_session_temporary"] == "true") { unset($_SESSION["edit"]); } if ($_REQUEST["stop_edit_session"] == "true") { unset($_SESSION["edit"]); } else if ($_REQUEST["start_edit_session"] == "true") { $_SESSION["edit"] = true; } require_once($_SERVER["DOCUMENT_ROOT"]."/cms/class/class.cms.php"); if (!$_SITELOOM["disable_stats"]) { require_once($_SERVER["DOCUMENT_ROOT"]."/cms/class/class.BrowserDetector.php"); require_once($_SERVER["DOCUMENT_ROOT"]."/cms/class/class.stats.php"); } if (isset($_SESSION["edit"]) && !$_SESSION["logged_in_but_viewing_through_frontend"]) { require_once($_SERVER["DOCUMENT_ROOT"]."/cms/class/class.profiler.php"); $profiler = new Profiler(); } if (isset($_SESSION["edit"]) && !$_SESSION["logged_in_but_viewing_through_frontend"]) { $_SITELOOM["userplatform"] = "siteloom"; // require_once($_SITELOOM["skins_path"].$_SITELOOM["userplatform"]."/misc.php"); // require_once($_SITELOOM["skins_path"].$_SITELOOM["userplatform"]."/boxes.php"); $profiler->start(); $profiler->enter("document","","Starter dokumentet"); } $objects = array(); $CMS = new CMS(); // Only enable stats if opentracker is not enabled. if (!$_SITELOOM["opentracker_enabled"] && !$_SITELOOM["disable_stats"]) { $STATS = new Stats(); } /* // Create the database connection. if (!isset($connection)) { print ""; print ""; print ""; print "Databasefejl"; print ""; print ""; print ""; print "Vi beklager

"; print "Vores website, ".$_SERVER["HTTP_HOST"].", er pt. ikke tilgeng嫩gt, da der desv屲e tekniske vanskeligheder med databasen.

"; print "
"; print ""; exit; } */ if ($GLOBALS["override_pageid"]) { $pageid = $GLOBALS["override_pageid"]; } // If the precise pageid has been specified, we don't need to look up the subdomain. else if (isset($_REQUEST["pageid"]) && is_array($_SITELOOM["PAGES_WITHOUT_SUBDOMAIN_LOOKUP"]) && in_array($_REQUEST["pageid"],$_SITELOOM["PAGES_WITHOUT_SUBDOMAIN_LOOKUP"])) { $pageid = $_REQUEST["pageid"]; } else { if ($CACHE_ENABLED) { $options = array( "cacheDir" => $_SERVER["DOCUMENT_ROOT"]."/cache/", "lifeTime" => 300, "automaticCleaningFactor" => 50 ); $Cache_Lite = new Cache_Lite($options); $cachekey = "core_subdomains"; if ($_GET["LIVE"]) { $Cache_Lite->remove($cachekey); } else { $savesubdomains = $Cache_Lite->get($cachekey); } if ($savesubdomains) { $savesubdomains = unserialize($savesubdomains); } else if (!$savesubdomains) { makeSureDatabaseIsInitialized($connection); $subdomains = $CMS->retrieveAllSubdomains(); $savesubdomains = array(); foreach($subdomains as $savesubdomain) { $savesubdomains["d_".strtolower($savesubdomain->subdomain)] = $savesubdomain; } $Cache_Lite->save(serialize($savesubdomains),$cachekey); // print "test"; } $subdomain = $savesubdomains["d_".strtolower($_SERVER["HTTP_HOST"])]; if (!$subdomain) { $subdomain = $savesubdomains["d_"]; } } else { makeSureDatabaseIsInitialized($connection); $subdomain = $CMS->retrieveSubdomain($_SERVER["HTTP_HOST"]); } } function resolvePageByID($pageids) { global $_SITELOOM; // If multiple paths is found, find the one on the current domain and in the current languageid. if (is_array($pageids) && sizeof($pageids) > 1) { $currentdomain = $_SERVER["HTTP_HOST"]; foreach($pageids as $possiblepageid_array) { $possiblepageid = $possiblepageid_array[0]; $possiblepageid_languageid = $possiblepageid_array[1]; $pagechain = Page::getPageIDChain($possiblepageid); $trypageid = $pagechain[sizeof($pagechain) - 1]; $trypage = new Page($trypageid); if ($trypage->type == "website" && $trypage->config) { // Tag højde for om der er flere domæner i config $domains = explode("|",$trypage->config); if (in_array($currentdomain,$domains)) { // Før blev der checket på default sprog... Hvorfor? // if (($_SESSION["current_language_id"] && $possiblepageid_languageid == $_SESSION["current_language_id"]) || (!$_SESSION["current_language_id"] && $possiblepageid_languageid == $_SITELOOM["default_language"])) { if (($_SESSION["current_language_id"] && $possiblepageid_languageid == $_SESSION["current_language_id"]) || (!$_SESSION["current_language_id"])) { $_SESSION["current_language_id"] = $possiblepageid_languageid; // print "sprog: ".$_SESSION["current_language_id"]."
\n"; $pageid = $possiblepageid; continue; } } } else { $pageid = $possiblepageid; } } } else { $possiblepageid = $pageids[0][0]; $possiblepageid_languageid = $pageids[0][1]; $pageid = $possiblepageid; if ($possiblepageid_languageid) { $_SESSION["current_language_id"] = $possiblepageid_languageid; } // print "sprog2: ".$_SESSION["current_language_id"]."
\n"; } return $pageid; } // The user entered the site by eg. // www.nano.dk/produkter/siteloom/ if (!isset($pageid) && !isset($_REQUEST["pageid"]) && isset($_REQUEST["path"]) && strlen($_REQUEST["path"]) > 1) { makeSureDatabaseIsInitialized($connection); $path = $_REQUEST["path"]; if (substr($path,0,1) == "/") { $path = substr($path,1); } // Resolving of path. $pageids = Page::findPageWithPath($path); $pageid = resolvePageByID($pageids); /* if (is_array($pageids) && sizeof($pageids) == 1) { $pagepath = $pageids[0][2]; if ($pagepath != $path) { header("HTTP/1.1 301 Moved Permanently"); header("Location: http://".$_SERVER["HTTP_HOST"]."/".$pagepath); exit; } } */ // If we didn't find a pageid, then maybe it exists with, or without / at the end. if (!$pageid) { if (substr($path,-1) == "/") { // print $path."
"; $path = substr($path,0,-1); // print $path; $pageids = Page::findPageWithPath($path); } else { $path = $path."/"; $pageids = Page::findPageWithPath($path); } $pageid = resolvePageByID($pageids); } } // bruger kommet ind via. f.eks. www.nano.dk (altså uden sideid). else if (!isset($_REQUEST["pageid"]) && !isset($GLOBALS["override_pageid"])) { if ($subdomain) { // print $subdomain->pageid; $pageid = $subdomain->pageid; } else { makeSureDatabaseIsInitialized($connection); // Find out if any of the lookup plugins is activated. require_once($_SERVER["DOCUMENT_ROOT"]."/cms/class/class.domainhandler.php"); $domainHandler = new DomainHandler(); $domainHandler->loadPlugins($_SITELOOM["domain_handlers"]); $pageid = $domainHandler->lookupDomain($_SERVER["HTTP_HOST"]); if (!$pageid) { print "Invalid subdomain"; print "Invalid subdomain."; print ""; exit; } } } else if ($GLOBALS["override_pageid"]) { } // Bruger gået ind via. f.eks. www.nano.dk/index.php?pageid=1 else if (!$_SESSION["edit"] && !$_SESSION["logged_in_but_viewing_through_frontend"]) { $_REQUEST["pageid"] = intval($_REQUEST["pageid"]); $pageid = $_REQUEST["pageid"]; if (sizeof($_GET) == 1 && sizeof($_POST) == 0) { if (!$_SESSION["current_language_id"]) { $_SESSION["current_language_id"] = $_SITELOOM["default_language"]; } $pathpage = new Page($pageid); if ($pathpage->path) { $redirecturl = "http://".$_SERVER["HTTP_HOST"]; if (substr($pathpage->path,0,1) != "/") { $redirecturl = $redirecturl."/"; } $redirecturl = $redirecturl.$pathpage->path; header("HTTP/1.1 301 Moved Permanently"); header("Location: ".$redirecturl); exit; } } else if (sizeof($_POST) > 0) { /* require_once($_SERVER["DOCUMENT_ROOT"]."/cms/class/class.mailutil.php"); MailUtil::sendMail(array( "email" => "jeppe@siteloom.dk", "fromName" => "SiteLoom Index", "fromEmail" => "martin@siteloom.dk", "subject" => "Gammel formular i SiteLoom: ".$_SERVER["HTTP_HOST"], "body" => "Pageid: ".$pageid."
Referer: ".$_SERVER["HTTP_REFERER"]."
request_uri: ".$_SERVER["REQUEST_URI"]."
\n", "charset" => "UTF-8" )); */ } } else { $pageid = $_REQUEST["pageid"]; } /******************************************************************************************************************* * Site resolving (SEO) * If a path is on another registered domain. Redirect to that one. *******************************************************************************************************************/ // If we haven't checked the domain yet, do it now. if (!$_SITELOOM["runs_single_website"] && !$_SESSION["edit"] && !$_SESSION["logged_in_but_viewing_through_frontend"] && !$isOnCurrentDomain && $_SERVER["REQUEST_URI"] != "/") { makeSureDatabaseIsInitialized($connection); // Kun på svensk site pt. // $swedish = strpos($_SERVER["HTTP_HOST"],".se"); // if ($swedish !== false) { $currentdomain = $_SERVER["HTTP_HOST"]; $pagechain = Page::getPageIDChain($pageid); $trypageid = $pagechain[sizeof($pagechain) - 1]; $trypage = new Page($trypageid); if ($trypage->id == $pageid && $trypage->type == "website" && $trypage->config) { $domains = explode("|",$trypage->config); header("HTTP/1.1 301 Moved Permanently"); header("Location: http://".$domains[0]); exit; } if ($trypage->type == "website" && $trypage->config) { $domains = explode("|",$trypage->config); if (in_array($currentdomain,$domains)) { $isOnCurrentDomain = true; } else { if (!$path) { $path = "index.php?pageid=".$pageid; } // First lets check if one of the domains is the same one, but with/without www. foreach($domains as $domain) { if (str_replace("www.","",$currentdomain) == str_replace("www.","",$domain)) { // Found a match. header("HTTP/1.1 301 Moved Permanently"); header("Location: http://".$domain."/".$path); exit; } } // Otherwise we redirect to the first one. header("HTTP/1.1 301 Moved Permanently"); header("Location: http://".$domains[0]."/".$path); exit; // header("HTTP/1.0 404 Not Found"); } } // } $isOnCurrentDomain = true; } if (!$isOnCurrentDomain) { // return; } /******************************************************************************************************************* * Language resolving *******************************************************************************************************************/ if ($_REQUEST["new_language"] && in_array($_REQUEST["new_language"],$_SITELOOM["available_languages"])) { $oldlanguage = $_SESSION["current_language_id"]; $_SITELOOM["current_language_id"] = $_REQUEST["new_language"]; $_SESSION["current_language_id"] = $_REQUEST["new_language"]; if ($oldlanguage != $_REQUEST["new_language"]) { $languagepage = new page($pageid); if ($languagepage->path != $path && !$_SESSION["edit"] && !$_SESSION["logged_in_but_viewing_through_frontend"]) { header("HTTP/1.1 301 Moved Permanently"); $redirectpath = $languagepage->path; if ($redirectpath == "/") { $redirectpath = ""; } header("Location: http://".$_SERVER["HTTP_HOST"]."/".$redirectpath); exit; } } } else { if (($_SESSION["current_language_id"] < 1) && $subdomain && $subdomain->languageid != 0) { $_SITELOOM["current_language_id"] = $subdomain->languageid; $_SESSION["current_language_id"] = $subdomain->languageid; } else { if ($_SESSION["current_language_id"] < 1) { $_SITELOOM["current_language_id"] = $_SITELOOM["default_language"]; $_SESSION["current_language_id"] = $_SITELOOM["default_language"]; } if (!$_SESSION["current_language_id"]) { $_SITELOOM["current_language_id"] = $_SITELOOM["default_language"]; $_SESSION["current_language_id"] = $_SITELOOM["default_language"]; } } } if (!$_SESSION["USER_LANGUAGE"] && $_SESSION["current_language_id"] == 1) { $_SESSION["USER_LANGUAGE"] = "ENG"; } else if (!$_SESSION["USER_LANGUAGE"] && $_SESSION["current_language_id"] == 2) { $_SESSION["USER_LANGUAGE"] = "DK"; } /******************************************************************************************************************* * Language resolving end *******************************************************************************************************************/ /** * User login management. */ if ($_REQUEST["siteloom_login_email"]) { require_once($_SERVER["DOCUMENT_ROOT"]."/cms/class/class.webgroupsandusers.php"); $userobject = WebGroupsAndUsers::getUserByEmail($_REQUEST["siteloom_login_email"]); if ($userobject) { $_REQUEST["siteloom_login_username"] = $userobject["username"]; } } if ($_REQUEST["siteloom_login_username"] && $_REQUEST["siteloom_login_password"]) { $_SESSION["siteloomuser"] = $_REQUEST["siteloom_login_username"]; $_SESSION["siteloompass"] = $_REQUEST["siteloom_login_password"]; if ($_REQUEST["siteloom_login_rememberlogin"] == 1) { setcookie("siteloom_saved_user", $_REQUEST["siteloom_login_username"],time()+60*60*24*180); setcookie("siteloom_saved_pass", $_REQUEST["siteloom_login_password"],time()+60*60*24*180); } } if ($_COOKIE["siteloom_saved_user"] && $_COOKIE["siteloom_saved_pass"]) { $_SESSION["siteloomuser"] = $_COOKIE["siteloom_saved_user"]; $_SESSION["siteloompass"] = $_COOKIE["siteloom_saved_pass"]; if ($_COOKIE["siteloom_saved_user_has_logged_in"] != "true") { $_REQUEST["siteloom_login_username"] = $_COOKIE["siteloom_saved_user"]; $_REQUEST["siteloom_login_password"] = $_COOKIE["siteloom_saved_pass"]; setcookie("siteloom_saved_user_has_logged_in","true"); } } if ($_SESSION["siteloomuser"] && $_SESSION["siteloompass"]) { makeSureDatabaseIsInitialized($connection); require_once($_SERVER["DOCUMENT_ROOT"]."/cms/class/class.webgroupsandusers.php"); if (!$userobject) { $userobject = WebGroupsAndUsers::validateUser($_SESSION["siteloomuser"],$_SESSION["siteloompass"]); } if ($userobject && $userobject["active"] == "true") { $_SESSION["webgroupuser_logged_in"] = true; $_SESSION["webgroup_userid"] = $userobject["id"]; $GLOBALS["user"] = $userobject; WebGroupsAndUsers::updateLastAction($GLOBALS["user"]["id"]); $frontendPermissions = WebGroupsAndUsers::getFrontendEditingPermissionsForUser($pageid,$GLOBALS["user"]["id"]); $GLOBALS["frontend_editing"] = $frontendPermissions; if ($_REQUEST["login_pageid"]) { header("Location: ".$protocol."://".$_SERVER["HTTP_HOST"]."/index.php?pageid=".$_REQUEST["login_pageid"]); exit; } else { // Send user to the startpage of the group he is in. $startpageid = WebGroupsAndUsers::getStartPageForUser($userobject["id"]); if ($_REQUEST["siteloom_login_username"] && $_REQUEST["siteloom_login_password"] && $startpageid != 0 && $pageid != $startpageid) { WebGroupsAndUsers::updateLastLogin($GLOBALS["user"]["id"]); header("Location: ".$protocol."://".$_SERVER["HTTP_HOST"]."/index.php?pageid=".$startpageid); exit; } } } else { require_once($_SERVER["DOCUMENT_ROOT"]."/cms/class/class.mailutil.php"); MailUtil::sendMail(array( "email" => "test@siteloom.dk", "fromName" => "SiteLoom Index", "fromEmail" => "test@siteloom.dk", "subject" => "Bruger med forkert password: ".$_SESSION["siteloomuser"], "body" => "Pageid: ".$pageid."
Username: ".$_SESSION["siteloomuser"]."
pass: ".$_SESSION["siteloompass"]."
\n", "charset" => "UTF-8" )); $wronglogin = true; $_SESSION["wronguser"] = $_SESSION["siteloomuser"]; $_SESSION["wrongpass"] = $_SESSION["siteloompass"]; } } else if ($_SESSION["webgroupuser_logged_in"]) { makeSureDatabaseIsInitialized($connection); require_once($_SERVER["DOCUMENT_ROOT"]."/cms/class/class.webgroupsandusers.php"); $userobject = WebgroupsAndUsers::getUserById($_SESSION["webgroup_userid"]); if ($userobject) { $GLOBALS["user"] = $userobject; } } if ($_REQUEST["siteloom_logout"] || $wronglogin) { // header("HTTP/1.0 401 Unauthorized"); $_SESSION["webgroupuser_logged_in"] = false; $_SESSION["siteloomuser"] = ""; $_SESSION["siteloompass"] = ""; $_SESSION["webgroup_userid"] = false; $_SERVER["PHP_AUTH_USER"] = ""; $_SERVER["PHP_AUTH_PW"] = ""; $GLOBALS["user"] = ""; setCookie("siteloom_saved_user",""); setCookie("siteloom_saved_pass",""); } if ($_REQUEST["siteloom_logout"]) { if (is_numeric($_REQUEST["logout_pageid"])) { $logoutpage = new Page($_REQUEST["logout_pageid"]); $path = $logoutpage->getPathRepresentation(); if (substr($path,0,1) != "/") { $path = "/".$path; } header("Location: ".$protocol."://".$_SERVER["HTTP_HOST"].$path); exit; } else { header("Location: ".$protocol."://".$_SERVER["HTTP_HOST"]."/"); exit; } } if (($_REQUEST["wronglogin_pageid"] && ($wronglogin && $pageid != $_SITELOOM["wrongloginpageid"])) || $wronglogin && $pageid != $_SITELOOM["wrongloginpageid"]) { if ($_REQUEST["wronglogin_pageid"] == 0) { } else if ($_REQUEST["wronglogin_pageid"]) { header("Location: ".$protocol."://".$_SERVER["HTTP_HOST"]."/index.php?pageid=".$_REQUEST["wronglogin_pageid"]); exit; } else { header("Location: ".$protocol."://".$_SERVER["HTTP_HOST"]."/index.php?pageid=".$_SITELOOM["wrongloginpageid"]); exit; } } // Changes the page the user is working on. if ($_SESSION["edit"] && $_REQUEST["siteloom_change_working_page_version"]) { $_SESSION["working_on_page_versions"][$pageid] = $_REQUEST["siteloom_change_working_page_version"]; } // Changes the live page. if ($_SESSION["edit"] && $_REQUEST["siteloom_change_live_page_version"]) { Page::changeLiveVersion($pageid,$_REQUEST["siteloom_change_live_page_version"]); } if (!$pageid) { // See if there's a dynamic url with this path. $dynamicurl = false; if ($_SERVER["REQUEST_URI"]) { if (!$parseUrl) { $parseUrl = parse_url($_SERVER["REQUEST_URI"]); } $dynamicurl = $CMS->findDynamicURL($parseUrl); } if ($dynamicurl) { if ($dynamicurl["action"] == "gotopage" && is_numeric($dynamicurl["pageid"])) { $pageid = $dynamicurl["pageid"]; } } else { // Find a suitable 404 page. $_SITELOOM["error"] = "404"; $websitepageid = Page::findPageWithConfig($_SERVER["HTTP_HOST"]); $errorpage_pageids = Page::findPageWithPath("404",$websitepageid); if (is_array($errorpage_pageids)) { foreach($errorpage_pageids as $errorpage_pageid_try) { if ($_SESSION["current_language_id"] && $_SESSION["current_language_id"] == $errorpage_pageid_try[1]) { $errorpage_pageid = $errorpage_pageid_try[0]; } else if ($_SITELOOM["default_language"] == $errorpage_pageid_try[1]) { $errorpage_pageid = $errorpage_pageid_try[0]; } } } if (!$errorpage_pageid) { $errorpage_pageid = Page::findPageWithPath("404","NULL"); if ($errorpage_pageid) { $errorpage_pageid = $errorpage_pageid[0][0]; } } header("HTTP/1.0 404 Not Found"); if ($errorpage_pageid) { $pageid = $errorpage_pageid; } else { exit; } } } // Retrieval of the page object if ($CACHE_ENABLED && !$_SESSION["edit"]) { $options = array( "cacheDir" => $_SERVER["DOCUMENT_ROOT"]."/cache/", "lifeTime" => 300, "automaticCleaningFactor" => 50 ); $Cache_Lite = new Cache_Lite($options); $cachekey = "core_pageobject_".$pageid."_".$_SESSION["current_language_id"]; if ($_GET["LIVE"]) { $Cache_Lite->remove($cachekey); } else { $page = $Cache_Lite->get($cachekey); } if ($page) { $page = unserialize($page); } else if (!$page) { makeSureDatabaseIsInitialized($connection); $page = $CMS->retrievePage($pageid); $Cache_Lite->save(serialize($page),$cachekey); } } else { makeSureDatabaseIsInitialized($connection); $page = $CMS->retrievePage($pageid); } // $page = $CMS->retrievePage($pageid); // Check if the page exists on the language if (!$_SESSION["edit"] && !$_SESSION["logged_in_but_viewing_through_frontend"] && $_SESSION["current_language_id"]) { if (is_array($page->languageid)) { if (!in_array($_SESSION["current_language_id"],$page->languageid) && !in_array(0,$page->languageid)) { $pagechain = Page::getPageIDChain($page->id); $pagefound = false; // print_r($pagechain); for($i=1;$ilanguageid) || in_array(0,$testpage->languageid)) { // print "ja: ".$testpage->id."
\n"; // We found a page in the chain that has either the current language or "all" as language. We'll redirect to that. header("Location: http://".$_SERVER["HTTP_HOST"]."/".$testpage->path); exit; } } } } } if ($_SESSION["edit"] && !$_SESSION["working_on_page_versions"][$page->id]) { $_SESSION["working_on_page_versions"][$page->id] = $page->version; } // print "working on: ".$_SESSION["working_on_page_versions"][$pageid]; if ($page->type == "website") { if (!isset($_SESSION["edit"]) && !$_SESSION["logged_in_but_viewing_through_frontend"]) { header("HTTP/1.1 301 Moved Permanently"); header("Location: http://".$page->config); exit; } else { // If logged in, we'll display the administration for the website. $currentpage = $page; require_once($_SERVER["DOCUMENT_ROOT"]."/cms/system/pages/redirectconfiguration.php"); exit; } } else if ($page->type == "url" || $page->type == "url_blank") { if (!isset($_SESSION["edit"]) && !$_SESSION["logged_in_but_viewing_through_frontend"]) { header("HTTP/1.1 301 Moved Permanently"); header("Location: ".$page->config); exit; } else { print "Desværre"; print ""; print "
"; print "Eksternt link
"; print "Denne side er et link, og peger på en ekstern kilde.

"; print "config."\">".$page->config.".

"; print "
"; print "Bemærk: Du ser kun denne side fordi du er logget ind i administrationsdelen, en normal bruger vil gå direkte til adressen."; print "
"; print "
"; print ""; exit; } } if (!isset($_SESSION["edit"])) { // Check if this page is published. if ($page->pubdate && $page->pubdate != "0000-00-00 00:00:00") { $pubdate = strtotime($page->pubdate); if ($pubdate > time()) { exit; } } if ($page->removedate && $page->removedate != "0000-00-00 00:00:00") { $removedate = strtotime($page->removedate); if ($removedate < time()) { exit; } } } if ($page) { $GLOBALS["current_pageid"] = $pageid; if (!isset($_SESSION["edit"]) && !isset($_SESSION["administrative_user"])) { if ($page->isProtected()) { makeSureDatabaseIsInitialized($connection); $validated = false; require_once($_SERVER["DOCUMENT_ROOT"]."/cms/class/class.ipgroups.php"); $ipgroups = IPGroups::matchIPToGroups($_SERVER["REMOTE_ADDR"]); $valid_ipgroups = Page::getIPGroupsForPage($page->id); foreach($valid_ipgroups as $valid_ipgroup) { foreach($ipgroups as $ipgroup) { if ($ipgroup["id"] == $valid_ipgroup) { $validated = true; } } } // If the user isn't in a successful IP Group, continue to validate, and see if he's in a trusted group. if (!$validated) { $redirectToLoginPage = false; if (!isset($GLOBALS["user"])) { if ($_SITELOOM["use_old_authenticate"]) { header("HTTP/1.0 401 Unauthorized"); header("WWW-Authenticate: Basic realm=\"Protected Area\""); print "You need a username and password to access this area.\n"; exit; } else { $redirectToLoginPage = true; } } else { if ($GLOBALS["user"]) { $groups = WebGroupsAndUsers::getGroupIDsByPage($pageid); if (is_array($groups)) { foreach($groups as $group) { if (WebGroupsAndUsers::userExistsInGroup($group,$_SESSION["siteloomuser"],$_SESSION["siteloompass"])) { $validated = true; } } } if ($validated == false) { $redirectToLoginPage = true; } } else { $redirectToLoginPage = true; } } if ($redirectToLoginPage) { $_SITELOOM["error"] = "403"; $websitepageid = Page::findPageWithConfig($_SERVER["HTTP_HOST"]); $errorpage_pageid = Page::findPageWithPath("403",$websitepageid); if (!$errorpage_pageid) { $errorpage_pageid = Page::findPageWithPath("403","NULL"); } $CACHE_ENABLED = false; /* include_once($_SERVER["DOCUMENT_ROOT"]."/cms/class/class.debug.php"); ob_start(); Debug::start(); print "Sti: ".$_SERVER["REQUEST_URI"]."
\n"; print "IP: ".$_SERVER["REMOTE_ADDR"]."
\n"; print "
";
					print_r($_SESSION);
					print "
"; print "
";
					print_r($_REQUEST);
					print "
"; Debug::end("martin@siteloom.dk","403 side ramt"); ob_get_contents(); ob_end_clean(); */ header("HTTP/1.1 403 Forbidden"); if ($errorpage_pageid) { $pageid = $errorpage_pageid; $page = new Page($pageid); } else { print "

403 Forbidden.

"; print "You do not have the privileges to view this page."; exit; } } } } } if (!isset($_SESSION["edit"]) && $CACHE_ENABLED && (($_SITELOOM["default_cache_all_pages"] && !in_array($pageid,$_SITELOOM["disable_cache_for_pageids"])) || in_array($pageid, $pageidstocache))) { if (!is_dir($_SERVER["DOCUMENT_ROOT"]."/cache/pagecache")) { $oldumask = umask(0); mkdir($_SERVER["DOCUMENT_ROOT"]."/cache/pagecache", 02777); umask($oldumask); } $options = array( "cacheDir" => $_SERVER["DOCUMENT_ROOT"]."/cache/pagecache/", "lifeTime" => 300, "automaticCleaningFactor" => 50 ); $Cache_Lite = new Cache_Lite($options); $currenturlinfo = parse_url($_SERVER["REQUEST_URI"]); $currentpath = $currenturlinfo["path"]; /* $cachekey = $pageid."_".$_SESSION["current_language_id"]."_".$currentpath; if (is_array($_SITELOOM["extra_cache_keys"])) { foreach($_SITELOOM["extra_cache_keys"] as $extra_cache_key) { $cachekey = $cachekey."_".$_REQUEST[$extra_cache_key]; } } */ $currenturlinfo = parse_url($_SERVER["REQUEST_URI"]); $currentpath = $currenturlinfo["path"]; $cachekey = $_SERVER["HTTP_HOST"]."/".$currentpath.$get_md5_key; if ($_GET["LIVE"]) { $Cache_Lite->remove($cachekey); } else { // print "using cache"; $cachedcontent = $Cache_Lite->get($cachekey); } } if (!$cachedcontent) { makeSureDatabaseIsInitialized($connection); // Initialize babelfish require_once($_SERVER["DOCUMENT_ROOT"]."/cms/class/class.babelfish.php"); $babelfish = new Babelfish(); // Check if versioning is enabled. if ($_SITELOOM["versioning_enabled"]) { require_once($_SERVER["DOCUMENT_ROOT"]."/cms/class/class.version.php"); } // Initiate the Parser Object (Distaff) require_once($_SERVER["DOCUMENT_ROOT"]."/cms/class/class.distaff.php"); $distaff = new Distaff($page,$profiler); $distaff->loadPlugins($_SERVER["DOCUMENT_ROOT"]."/cms/distaff/"); if ($page->type == "newsletter") { $distaff->setContextName("newsletter"); } require_once($_SERVER["DOCUMENT_ROOT"]."/cms/system/utils/page_functions.php"); if (isset($_SESSION["edit"]) || $GLOBALS["frontend_editing"]["edit_text"]) { // Note: Måske vi skal til at bruge et array med "js_includes" til det her i stedet? Så slipper // man også for at checke om jquery allerede er required osv. ob_start(); if ($GLOBALS["frontend_editing"]["edit_text"]) { require_once($_SERVER["DOCUMENT_ROOT"]."/cms/system/utils/page_frontend_editing_javascript.php"); } else { require_once($_SERVER["DOCUMENT_ROOT"]."/cms/system/utils/page_javascript.php"); require_once($_SERVER["DOCUMENT_ROOT"]."/cms/system/utils/contextmenu.php"); } $page_javascript = ob_get_contents(); ob_end_clean(); } ob_start(); $template = $page->getTemplate(); if ($_SESSION["mobile_test"]) { // We have mobile template mapping if ($_SITELOOM["mobile_template_mapping"]) { // Remove this and cache_enabled = false when going live $CACHE_ENABLED = false; $_SESSION["exclude_cache"] = true; if (true) { // We check if it's mobile foreach($_SITELOOM["mobile_template_mapping"] as $templateMapping) { if ($templateMapping["template"] == $template->id) { $_SITELOOM["has_mobile_template"] = true; $GLOBALS["has_mobile_template"] = true; $template = new Template($templateMapping["mobile_template"]); } } } } } if ((isset($_GET["print"]) && $_GET["print"] == "true") || (isset($_POST["print"]) && $_POST["print"] == "true")) { $printtemplateid = $template->getPrintTemplate(); $printtemplate = new Template($printtemplateid); $printtemplate->retrieveFromDB(); $content = $printtemplate->getContent(); } else { $content = $template->getContent(); } $content = $distaff->preParse($content); $editablecontent = array(); $content = $distaff->parse($content); $content = $distaff->postParse($content); $distaff->unload(); if (!isset($_SESSION["edit"]) && $_SITELOOM["ajax_transitions_enabled"]) { if (!$GLOBALS["jquery_included"]) { $ajaxstr = "\n"; $GLOBALS["jquery_included"] = true; } $ajaxstr .= "\n"; $ajaxstr .= ""; $content = str_replace(array("",""),$stylestr,$content); } if (isset($_REQUEST["print"]) && $_REQUEST["print"] == "true") { } else if ($page->type == "pdf") { if (isset($GLOBALS["siteloom_add_to_head"]) && sizeof($GLOBALS["siteloom_add_to_head"]) > 0) { // Sort by priority ksort($GLOBALS["siteloom_add_to_head"]); foreach($GLOBALS["siteloom_add_to_head"] as $priority => $head_elements) { foreach($head_elements as $head_element) { $stylestr .= $head_element["full"]; } } } if (isset($_SESSION["edit"])) { $stylestr .= "\n"; $stylestr .= "\n"; $stylestr .= $page_javascript; } $stylestr .= ""; $content = str_replace(array("",""),$stylestr,$content); } else { $stylestr = ""; if ($page->robotnoindex === "true") { $stylestr .= "\n"; } if (is_array($_SITELOOM["PAGES_WITHOUT_STYLESHEET"]) && in_array($pageid,$_SITELOOM["PAGES_WITHOUT_STYLESHEET"])) { } else { if ($_SITELOOM["disable_siteloom_stylesheet"] != true) { if ($_SITELOOM["disable_siteloom_stylesheet_on_frontend"] != true || $_SITELOOM["disable_siteloom_stylesheet_on_frontend"] && $_SESSION["edit"]) { $stylestr = "\n"; } } } if ($_SITELOOM["use_automatic_headline_graphics"]) { $stylestr .= "\n"; } if ($_SITELOOM["mason_enabled"]) { javascript("/web/mason/mason.php?pageid=".$pageid); // $stylestr .= "\n"; } if (isset($GLOBALS["siteloom_add_to_head"]) && sizeof($GLOBALS["siteloom_add_to_head"]) > 0) { // Sort by priority ksort($GLOBALS["siteloom_add_to_head"]); if ($_SITELOOM["performance"]["minify"] && !$_SESSION["edit"]) { // require_once($_SERVER["DOCUMENT_ROOT"]."/system/api/external/magicmin/class.magic-min.php"); require_once($_SERVER["DOCUMENT_ROOT"]."/system/api/minify/class.minify.php"); /* $minified = new Minifier(array( "gzip" => true, "closure" => true, "hashed_filenames" => true, "echo" => false )); */ $minifier = new Minify(); $minify_scripts = array(); $minify_css = array(); foreach($GLOBALS["siteloom_add_to_head"] as $priority => $head_elements) { foreach($head_elements as $head_element) { if ($head_element["type"] == "script") { if (strpos($head_element["file"],".php") === false) { $minifier->addFile($head_element["file"],"js"); // $minify_scripts[] = $_SERVER["DOCUMENT_ROOT"]."/".$head_element["file"]; } else { $stylestr .= "\n"; } } else if ($head_element["type"] == "css") { if (strpos($head_element["file"],".php") === false) { $minifier->addFile($head_element["file"],"css"); // $minify_css[] = $_SERVER["DOCUMENT_ROOT"]."/".$head_element["file"]; } else { $stylestr .= "\n"; } } } } $stylestr .= $minifier->minifyFiles("js"); $stylestr .= $minifier->minifyFiles("css"); // print_r($minify_scripts); /* $minified_js_file = str_replace($_SERVER["DOCUMENT_ROOT"],"",$minifier->mergeFiles($_SERVER["DOCUMENT_ROOT"]."/tmp/website_javascript.js",$minify_scripts)); $stylestr .= "\n"; $minified_css_file = str_replace($_SERVER["DOCUMENT_ROOT"],"",$minifier->mergeFiles($_SERVER["DOCUMENT_ROOT"]."/tmp/website_css.css",$minify_css)); $stylestr .= "\n"; */ // $minified->merge("css/style.css"); // $minified->minify("/files/minifytest/1.js",$_SERVER["DOCUMENT_ROOT"]."/files/minifytest/1.min.js"); // $stylestr .= "\n"; // $stylestr .= "\n"; } else { foreach($GLOBALS["siteloom_add_to_head"] as $priority => $head_elements) { foreach($head_elements as $head_element) { $stylestr .= $head_element["full"]; } } } } if (isset($_SESSION["edit"]) || $GLOBALS["frontend_editing"]["edit_text"]) { $stylestr .= $page_javascript; } if ($GLOBALS["canonical_url"]) { $stylestr .= "\n"; } else if ($_SITELOOM["enable_canonical_url"]) { $canonical_url = str_replace("//","/",$_SERVER["HTTP_HOST"]."/".$page->getPathRepresentation()); $stylestr .= "\n"; } $stylestr .= ""; $content = str_replace(array("",""),$stylestr,$content); } if (isset($_SESSION["edit"])) { if (substr_count($content,"") > 1) { print "Error: 2 </body> tags detected in the template.
Proper template parsing can not take place. - Shutting down."; exit; } else { $initscript = ""; $initscript .= ""; ob_start(); require_once($_SERVER["DOCUMENT_ROOT"]."/cms/system/utils/page_extracontent.php"); $page_end_contents = ob_get_contents(); $initscript .= $page_end_contents; ob_end_clean(); $content = str_replace(array("",""),$initscript."",$content); } } if ($page->type == "pdf" && !isset($_SESSION["edit"])) { require_once($_SERVER["DOCUMENT_ROOT"]."/cms/extend/pagegenerators/generator.pdf.php"); $pdf = new PageGenerator_PDF(); $content = $pdf->parseContent($content); } print $content; $cachedcontent = ob_get_contents(); ob_end_clean(); if (!isset($_SESSION["edit"]) && !$_GET["LIVE"] && $CACHE_ENABLED && (($_SITELOOM["default_cache_all_pages"] && !in_array($pageid,$_SITELOOM["disable_cache_for_pageids"])) || in_array($pageid, $pageidstocache))) { $cachekey = $_SERVER["HTTP_HOST"]."/".$currentpath.$get_md5_key; /* if ($_SERVER["REMOTE_ADDR"] == "95.209.145.215") { print "cachesave: :".$cachekey.":"; } */ // Extra measure if ($CACHE_ENABLED && !$_SESSION["exclude_cache"]) { $Cache_Lite->save($cachedcontent); } } } if (isset($_SESSION["edit"])) { $profiler->leave("document","","Slutter dokumentet"); $cachedcontent = str_replace(array("",""),$profiler->contents."",$cachedcontent); } if ($_SITELOOM["google_analytics_id"]) { $analytics .= "\n"; $cachedcontent = str_replace(array("",""),$analytics."",$cachedcontent); } /* if ($_SERVER["REMOTE_ADDR"] == "95.209.145.215") { print "cachedoh: :".$cachekey.":"; } */ print $cachedcontent; if (!isset($_SESSION["edit"]) && (!isset($_SESSION["administrative_user"]))) { if ($_SITELOOM["opentracker_enabled"]) { makeSureDatabaseIsInitialized($connection); $phpOpenTracker_documentname = (isset($GLOBALS["phpOpenTracker_logname"])) ? $GLOBALS["phpOpenTracker_logname"] : $page->title; phpOpenTracker::log( Array( "document" => $phpOpenTracker_documentname ) ); } else { if (!$_SITELOOM["disable_stats"]) { makeSureDatabaseIsInitialized($connection); $_SITELOOM["viewid"] = $STATS->update($pageid); // Update usage statistics for this page. } } } } /* if ($core_profiler) { print ":::".round($startmicro - $core_profiler->getmicrotime(),4).":::"; } */ if ($_REQUEST["stop_edit_session_temporary"] == "true") { $_SESSION["edit"] = true; } ?>