/** * Get the locations for the rest of the site to use. */ public static function getLocations($rootdir = NULL, $basedir = NULL) { Profiler::StartTimer("ConfigManager::getLocations()", 3); if ($rootdir === NULL) { $rootdir = self::$rootdir; } else { self::$rootdir = $rootdir; } if (empty($rootdir)) { return null; } if (!empty(self::$locations)) { $locations = self::$locations; } else { $cfgfile = NULL; if (file_exists("config/locations.cfg")) { $cfgfile = "config/locations.cfg"; } else { if (file_exists("/etc/elation/locations.cfg")) { $cfgfile = "/etc/elation/locations.cfg"; } } if ($cfgfile !== NULL) { $mtime = filemtime($cfgfile); $fileid = md5($cfgfile); if (!empty($mtime)) { $apcenabled = ini_get("apc.enabled"); $apckey = "config.locations.{$fileid}.{$mtime}"; if ($apcenabled && ($apccontents = apc_fetch($apckey)) != false) { //print "found in apc, unserialize ($apccontents)<br />"; $locations = json_decode($apccontents, true); } else { //print "not found in apc, parse it<br />"; $locations = parse_ini_file($cfgfile, true); $locations["root"] = $rootdir; if ($apcenabled) { apc_store($apckey, json_encode($locations)); } } } } if (empty($locations)) { // If we couldn't load anything from APC or any of the config files, use some hardcoded defaults $locations = array("root" => $rootdir, "htdocs" => "{$rootdir}/htdocs", "images" => "{$rootdir}/htdocs/images", "scripts" => "{$rootdir}/htdocs/scripts", "css" => "{$rootdir}/htdocs/css", "resources" => "{$rootdir}/resources", "config" => "{$rootdir}/config", "tmp" => "{$rootdir}/tmp", "templates" => "{$rootdir}/templates", "htdocswww" => "{$basedir}", "imageswww" => "{$basedir}/images", "scriptswww" => "{$basedir}/scripts", "csswww" => "{$basedir}/css"); } } if (isset($this) && isset($this->servers["dependencies"]) && $this->servers["dependencies"]["cdn"]["enabled"] == 1 && $this->current["dependencies"]["cdn"]["enabled"] == 1) { $cdn_ini = $this->servers["dependencies"]["cdn"]; $cdn_cobrand = $this->current["dependencies"]["cdn"]; $cdnhost = any($cdn_cobrand["host"], $cdn_ini["host"], ""); $cdnscheme = any($cdn_cobrand["scheme"], $cdn_ini["scheme"], ""); //$cdnscheme = (!empty($cdnhost) ? $webapp->request["scheme"] . "://" : ""); //$cdnpath = any($cdn_cobrand["path"], $cdn_ini["path"], "/images"); $cdnprefix = (!empty($cdnscheme) ? $cdnscheme . ":" : "") . "//" . $cdnhost; if (any($cdn_cobrand["images"], $cdn_ini["images"]) == 1) { $locations["imageswww"] = $cdnprefix . $locations["imageswww"]; } if (any($cdn_cobrand["css"], $cdn_ini["css"]) == 1) { $locations["csswww"] = $cdnprefix . $locations["csswww"]; } if (any($cdn_cobrand["scripts"], $cdn_ini["scripts"]) == 1) { $locations["scriptswww"] = $cdnprefix . $locations["scriptswww"]; } } self::$locations = $locations; Profiler::StopTimer("ConfigManager::getLocations()"); return $locations; }