/**
  * Build the current server URL
  * @param bool $withURI
  * @static
  * @return string
  */
 public static function detectServerURL($withURI = false)
 {
     $setUrl = ConfService::getCoreConf("SERVER_URL");
     if (!empty($setUrl)) {
         return $setUrl;
     }
     if (php_sapi_name() == "cli") {
         AJXP_Logger::debug("WARNING, THE SERVER_URL IS NOT SET, WE CANNOT BUILD THE MAIL ADRESS WHEN WORKING IN CLI");
     }
     $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http';
     $port = $protocol === 'http' && $_SERVER['SERVER_PORT'] == 80 || $protocol === 'https' && $_SERVER['SERVER_PORT'] == 443 ? "" : ":" . $_SERVER['SERVER_PORT'];
     $name = $_SERVER["SERVER_NAME"];
     if (!$withURI) {
         return "{$protocol}://{$name}{$port}";
     } else {
         $uri = dirname($_SERVER["REQUEST_URI"]);
         $api = ConfService::currentContextIsRestAPI();
         if (!empty($api)) {
             // Keep only before api base
             $explode = explode("/" . $api . "/", $uri);
             $uri = array_shift($explode);
         }
         return "{$protocol}://{$name}{$port}" . $uri;
     }
 }
Exemple #2
0
$confPlugin = ConfService::getInstance()->confPluginSoftLoad($pServ);
$pServ->loadPluginsRegistry(AJXP_INSTALL_PATH . "/plugins", $confPlugin);
ConfService::start();
$confStorageDriver = ConfService::getConfStorageImpl();
require_once $confStorageDriver->getUserClassFileName();
//session_name("AjaXplorer");
//session_start();
AJXP_PluginsService::getInstance()->initActivePlugins();
AuthService::preLogUser(array_merge($_GET, $_POST));
if (AuthService::getLoggedUser() == null) {
    header('HTTP/1.0 401 Unauthorized');
    echo 'You are not authorized to access this API.';
    exit;
}
$authDriver = ConfService::getAuthDriverImpl();
ConfService::currentContextIsRestAPI("api");
$uri = $_SERVER["REQUEST_URI"];
$scriptUri = ltrim(AJXP_Utils::safeDirname($_SERVER["SCRIPT_NAME"]), '/') . "/api/";
$uri = substr($uri, strlen($scriptUri));
$uri = explode("/", trim($uri, "/"));
// GET REPO ID
$repoID = array_shift($uri);
// GET ACTION NAME
$action = array_shift($uri);
$path = "/" . implode("/", $uri);
if ($repoID == 'pydio') {
    ConfService::switchRootDir();
    $repo = ConfService::getRepository();
} else {
    $repo = ConfService::findRepositoryByIdOrAlias($repoID);
    if ($repo == null) {