Commit 2ae94956 authored by Guillaume Rousse's avatar Guillaume Rousse

project files reorganisation

- config files are now in etc subdirectory
- web files are now in www subdirectory
- library files are now in lib subdirectory
- script files are now in bin subdirectory
parent 8b0040aa
......@@ -53,7 +53,7 @@ Installation
This file contains the list of Identity Providers that that can be
configured by hand
3. Enure that permissions for the files:
3. Ensure that permissions for the files:
- SProvider.metadata.php
- IDProvider.metadata.php
- metadata.lock
......@@ -64,12 +64,12 @@ Installation
4. Adapt the SWITCHwayf configuration in config.php. There are comments in that
file that should help you make suitable choices for your use case.
5. If Apache 2 is used, add the following statement to the Apache configugration:
5. If Apache 2 is used, add the following statement to the Apache configuration:
--
Alias /SWITCHaai /#YOUR-PATH-TO#/SWITCHwayf
<Directory /#YOUR-PATH-TO#/SWITCHwayf>
Alias /SWITCHaai /#YOUR-PATH-TO#/SWITCHwayf/www
<Directory /#YOUR-PATH-TO#/SWITCHwayf/www>
Options Indexes MultiViews
AllowOverride None
Order allow,deny
......@@ -83,6 +83,7 @@ Alias /SWITCHaai /#YOUR-PATH-TO#/SWITCHwayf
</Directory>
--
Beware, only the www subdirectory should be exposed, not the top-level directory.
Alternatively, one also could rename the file 'WAYF' to 'WAYF.php'.
......
......@@ -7,19 +7,25 @@ if (isset($_SERVER['REMOTE_ADDR'])){
exit('No direct script access allowed');
}
if (!file_exists('config.dist.php')) {
die('The default configuration file config.dist.php does not exist in this directory!');
$toplevelDir = dirname(__DIR__);
$distConfigFilePath = $topLevelDir . '/etc/config.dist.php');
$newConfigFilePath = $topLevelDir . '/etc/config.new.php');
$currentConfigFilePath = $topLevelDir . '/etc/config.php');
if (!file_exists($distConfigFilePath)) {
die("The default configuration file 'config.dist.php' does not exist in configuration directory!");
}
if (!file_exists('config.php')) {
die('The configuration file config.php does not exist in this directory!');
if (!file_exists($currentConfigFilePath)) {
die("The configuration file 'config.php' does not exist in configuration directory!");
}
require_once('config.php');
require_once($currentConfigFilePath);
echo "Parsing current configuration and default configuration...\n";
$fp = fopen('config.new.php', 'w') or die("Cannot open file 'config.new.php' for writing!") ;
$distConfigFile = file('config.dist.php');
$currentConfigFile = file('config.php');
$fp = fopen($newConfigFilePath, 'w')
or die("Cannot open file 'config.new.php' for writing!") ;
$distConfigFile = file($distConfigFilePath);
$currentConfigFile = file($currentConfigFilePath);
$configSettings = Array();
foreach ($currentConfigFile as $line){
......
......@@ -44,8 +44,10 @@ Argument Description
PAGE;
require_once('functions.php');
require_once('readMetadata.php');
$toplevelDir = dirname(__DIR__);
require_once($topLevelDir . '/lib/functions.php');
require_once($topLevelDir . '/lib/readMetadata.php');
// Script options
$longopts = array(
......
......@@ -185,6 +185,7 @@
// 4. Files and path Settings
//***************************
// all relatives paths are resolved relatively to configuration directory
// Set both config files to the same value if you don't want to use the
// the WAYF to read a (potential) automatically generated file that undergoes
......
......@@ -55,6 +55,7 @@ function initConfigOptions(){
global $kerberosRedirectURL;
global $instanceIdentifier;
global $developmentMode;
global $topLevelDir;
// Set independet default configuration options
......@@ -124,6 +125,17 @@ function initConfigOptions(){
$$key = $value;
}
}
// Turn relatives paths into absolute ones
$files = array(
'IDPConfigFile', 'backupIDPConfigFile', 'metadataFile',
'metadataIDPFile', 'metadataSPFile', 'metadataLockFile'
);
foreach($files as $file) {
if (substr($$file, 0, 1) != '/') {
$$file = $topLevelDir . '/etc/' . $$file;
}
}
}
/******************************************************************************/
......
......@@ -13,21 +13,23 @@ Web site: https://www.switch.ch/aai/support/tools/wayf/
// Load general configuration and template file
/*------------------------------------------------*/
$topLevelDir = dirname(__DIR__);
if (isset($_SERVER{'SWITCHWAYF_CONFIG'})){
require_once($_SERVER{'SWITCHWAYF_CONFIG'});
} else {
require_once('config.php');
require_once($topLevelDir . '/etc/config.php');
}
require_once('languages.php');
require_once('functions.php');
require_once('templates.php');
require_once($topLevelDir . '/lib/languages.php');
require_once($topLevelDir . '/lib/functions.php');
require_once($topLevelDir . '/lib/templates.php');
// Set default config options
initConfigOptions();
// Read custom locales
if (file_exists('custom-languages.php')){
require_once('custom-languages.php');
if (file_exists($topLevelDir . '/lib/custom-languages.php')){
require_once($topLevelDir . '/lib/custom-languages.php');
}
/*------------------------------------------------*/
......@@ -62,7 +64,7 @@ if ($IDPConfigFile == $backupIDPConfigFile){
// Read metadata file if configuration option is set
if($useSAML2Metadata && function_exists('xml_parser_create')){
require('readMetadata.php');
require($topLevelDir . '/lib/readMetadata.php');
updateMetadata();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment