public static function getSitePath() { if (isset(self::$site_path) && strlen(self::$site_path)) { return self::$site_path; } // Attempt to use the first web directory on current path, otherwise use the web ("document") root $web_pos = strrpos($_SERVER['SCRIPT_FILENAME'], self::$web_directory); if ($web_pos !== false) { self::$site_web_path = substr($_SERVER['SCRIPT_FILENAME'], 0, $web_pos + strlen(self::$web_directory)); } else { if (isset($_SERVER['DOCUMENT_ROOT'])) { self::$site_web_path = $_SERVER['DOCUMENT_ROOT']; } } // Usually site path is one directory up from the site web path self::$site_path = dirname(self::$site_web_path); //echo 'DEBUG site path: '.self::$site_path."<br/>"; return self::$site_path; }