add a .ini loader in lassospkit_config.inc.php
This commit is contained in:
parent
be331ab5c1
commit
3604b913d3
|
@ -74,6 +74,7 @@ function finish($return_url = null) {
|
|||
function finishWithMethod($method, $relay_state_name)
|
||||
{
|
||||
if ($method == LASSO_HTTP_METHOD_SOAP) {
|
||||
echo 'coin';
|
||||
finish();
|
||||
} else {
|
||||
LassoSPKitUtilsSession::setRelayState($relay_state_name, getReturnUrl());
|
||||
|
@ -135,7 +136,7 @@ function slo() {
|
|||
$saml2 = new LassoSPKitSAML2($session);
|
||||
$method = LASSO_HTTP_METHOD_SOAP;
|
||||
$ret = $saml2->initiateSLO($method);
|
||||
$headers = headers_list();
|
||||
echo 'coin';
|
||||
finishWithMethod($method, 'slo');
|
||||
}
|
||||
function sloSoap() {
|
||||
|
|
|
@ -17,7 +17,7 @@ class LassoSPKitAutoPersistentSession extends LassoSPKitDummySession {
|
|||
}
|
||||
function findFederation($nameID) {
|
||||
if (! $nameID) {
|
||||
$nameID = array_pop(LassoSPKitUtilsSession::getNameID());
|
||||
$nameID = @array_pop(LassoSPKitUtilsSession::getNameID());
|
||||
if (! $nameID) {
|
||||
$userID = LassoSPKitUtilsSession::getUserID();
|
||||
if ($userID) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?
|
||||
require_once('lassospkit_datadir.inc.php');
|
||||
require_once('lassospkit_debug.inc.php');
|
||||
|
||||
/** This class represents the non-SAML-metadata part
|
||||
* of the config of the spkit. */
|
||||
|
@ -30,42 +31,43 @@ class LassoSPKitConfig {
|
|||
|
||||
function __construct() {
|
||||
}
|
||||
static function writeIni($path, $table) {
|
||||
$content = "";
|
||||
foreach ($table as $k => $v) {
|
||||
if ($v == null) {
|
||||
$content .= "$k=null\n";
|
||||
} else {
|
||||
$content .= "$k=$v\n";
|
||||
}
|
||||
}
|
||||
file_put_contents($path, $content);
|
||||
|
||||
}
|
||||
static function loadIni($path) {
|
||||
$table = array();
|
||||
$content = file_get_contents($path);
|
||||
if ($content === FALSE) {
|
||||
lassospkit_debuglog("Cannot read $path");
|
||||
throw new Exception("Cannot read $path");
|
||||
}
|
||||
$lines = split("\n", $content);
|
||||
foreach ($lines as $line) {
|
||||
$pair = split("=", $line, 2);
|
||||
if (count($pair) == 2) {
|
||||
if ($pair[1] == 'null') {
|
||||
$pair[1] = null;
|
||||
}
|
||||
$table[$pair[0]] = $pair[1];
|
||||
}
|
||||
}
|
||||
return $table;
|
||||
}
|
||||
static function init() {
|
||||
self::$file = lassospkit_datadir() . '/lassospkit_config.ini';
|
||||
if (! self::$instance) {
|
||||
self::$instance = array();
|
||||
$ph = @dba_open(self::$file, 'rl', 'inifile');
|
||||
if ($ph) {
|
||||
try {
|
||||
foreach (self::$default_values as $k => $v) {
|
||||
if (dba_exists($k, $ph)) {
|
||||
self::$instance[$k] = dba_fetch($k, $ph);
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
dba_close($ph);
|
||||
throw $e;
|
||||
}
|
||||
dba_close($ph);
|
||||
}
|
||||
}
|
||||
self::$instance = self::loadIni(self::$file);
|
||||
}
|
||||
static function commit() {
|
||||
$ph = dba_open(self::$file, 'nl', 'inifile');
|
||||
if (! $ph) {
|
||||
throw Exception('Cannot open the config file for writing');
|
||||
}
|
||||
try {
|
||||
foreach (self::$instance as $k => $v) {
|
||||
if (isset(self::$default_values[$k])) {
|
||||
dba_replace($k, $v, $ph);
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
dba_close($ph);
|
||||
throw $e;
|
||||
}
|
||||
dba_close($ph);
|
||||
self::writeIni(self::$file, self::$instance);
|
||||
}
|
||||
function setDefault($name) {
|
||||
self::init();
|
||||
|
|
Reference in New Issue