<?php
if(!isset($_SERVER) && isset($_ENV) && isset($_ENV['REQUEST_URI']))
{
  $_SERVER = Array('REQUEST_URI' => $_ENV['REQUEST_URI']);
}

%for %%idx, %%user in %%enumerate(%%piwigo_users)
%if %%idx != 0
}
else %slurp
%end if
if(str_starts_with($_SERVER['REQUEST_URI'], '/%%user/')) {
  $prefixe = '%%{user}';
%end for
}
else
{
  $conf['OIDC'] = Array('issuer_url' => 'https://%%oauth2_client_server_domainname/',
                        'client_id' => '%%oauth2_client_id',
                        'client_secret' => '%%oauth2_client_secret',
                        'scope' => 'openid profile email',
                        );
  require_once(PHPWG_ROOT_PATH . 'plugins/OpenIdConnect/oidc.php');
  require_once(PHPWG_ROOT_PATH . 'include/functions.inc.php');
  $oidc = get_oidc_client();
  try {
    $success = $oidc->authenticate();
  } catch (Exception $e) {
  }
  if (isset($_REQUEST['code'])) {
    $token_json = $oidc->getTokenResponse();
    $oidc->setAccessToken($token_json->access_token);
    $name = $oidc->requestUserInfo('nickname');
    if(isset($name)) {
      redirect('/' . $name . '/plugins/OpenIdConnect/auth.php');
    };
    print('unknown album');
    die();
  }
}
$conf['data_location'] = "_data/$prefixe/";
$conf['log_dir'] = "logs/$prefixe";
$conf['upload_dir'] = "./upload/$prefixe";
$conf['graphics_library'] = 'ext_imagick';
$conf['osm_add_osmmap.php'] = false;
$conf['show_exif'] = false;
$conf['derivative_default_size'] = 'large';
#FOR GPX
$conf['upload_form_all_types'] = true;
?>
