'gitdir' => __DIR__ . '/../repos/git/',
'workdir' => __DIR__ . '/../repos/work/',
'tpl' => __DIR__ . '/templates/',
- 'baseurl' => '/',
+ 'baseurl' => null,
'avatars' => true,
'css' => '',
'iconpng' => '',//phorkie browser icon (favicon)
return $file;
}
-}
+ public static function detectBaseUrl()
+ {
+ if (!isset($_SERVER['REQUEST_URI'])
+ || !isset($_SERVER['SCRIPT_NAME'])
+ ) {
+ return '/';
+ }
+
+ $scriptName = $_SERVER['SCRIPT_NAME'];
+ $requestUri = $_SERVER['REQUEST_URI'];
+ if (substr($scriptName, -4) != '.php') {
+ //a phar
+ return $scriptName . '/';
+ }
+
+ if (substr($requestUri, -4) != '.php') {
+ $requestUri .= '.php';
+ }
+ $snl = strlen($scriptName);
+ if (substr($requestUri, -$snl) == $scriptName) {
+ return substr($requestUri, 0, -$snl) . '/';
+ }
+
+ return '/';
+ }
+}
?>
);
require_once __DIR__ . '/../data/config.default.php';
-if (file_exists(__DIR__ . '/../data/config.php')) {
- require_once __DIR__ . '/../data/config.php';
+$pharFile = \Phar::running();
+if ($pharFile == '') {
+ $cfgFilePath = __DIR__ . '/../data/config.php';
+} else {
+ //remove phar:// from the path
+ $cfgFilePath = substr($pharFile, 7) . '.config.php';
+}
+$GLOBALS['phorkie']['cfgfiles'][$cfgFilePath] = false;
+if (file_exists($cfgFilePath)) {
+ $GLOBALS['phorkie']['cfgfiles'][$cfgFilePath] = true;
+ require_once $cfgFilePath;
+}
+
+if ($GLOBALS['phorkie']['cfg']['baseurl'] === null) {
+ $GLOBALS['phorkie']['cfg']['baseurl'] = Tools::detectBaseUrl();
}
// Set/Get git commit session variables