Add lib/config.php and merge with lib/autoload.php

This commit is contained in:
Victor LABORIE 2017-12-13 17:40:02 +01:00
parent 2b79e7449b
commit f7f028ffd1
7 changed files with 45 additions and 26 deletions

View file

@ -10,12 +10,12 @@
* @version 1.0
*/
// Load config and autoload class
require_once("lib/config.php");
// Force authentication on this page
require_once("lib/auth.php");
// Autoload class from lib/class.*.php
require_once("lib/autoload.php");
/**
* Path
*/

View file

@ -10,12 +10,12 @@
* @version 1.0
*/
// Load config and autoload class
require_once("lib/config.php");
// Force authentication on this page
require_once("lib/auth.php");
// Autoload class from lib/class.*.php
require_once("lib/autoload.php");
/**
* Path
*/

View file

@ -10,12 +10,12 @@
* @version 1.0
*/
// Load config and autoload class
require_once("lib/config.php");
// Force authentication on this page
require_once("lib/auth.php");
// Autoload class from lib/class.*.php
require_once("lib/autoload.php");
/**
* Path
*/

View file

@ -10,12 +10,12 @@
* @version 1.0
*/
// Load config and autoload class
require_once("lib/config.php");
// Force authentication on this page
require_once("lib/auth.php");
// Autoload class from lib/class.*.php
require_once("lib/autoload.php");
/**
* Path
*/
@ -29,7 +29,7 @@ define('EVOADMIN_BASE','./');
include EVOADMIN_BASE . 'inc/haut.php';
include EVOADMIN_BASE . 'inc/debut.php';
if ( (!superadmin($login)) || ($conf['domaines']['driver'] != 'ldap') ) {
if ( (!$server->isSuperAdmin()) || ($conf['domaines']['driver'] != 'ldap') ) {
print "<div class=\"alert alert-danger\" role=\"alert\">Vous n'avez pas les droits pour cette page</div>";
EvoLog::log("Access denied on domaine.php");

View file

@ -10,12 +10,12 @@
* @version 1.0
*/
// Load config and autoload class
require_once("lib/config.php");
// Force authentication on this page
require_once("lib/auth.php");
// Autoload class from lib/class.*.php
require_once("lib/autoload.php");
/**
* Path
*/

View file

@ -1,10 +0,0 @@
<?php
spl_autoload_register(function ($class) {
if (file_exists("vendor/evolibs/$class.php")) {
include_once("vendor/evolibs/$class.php");
} else {
$class = strtolower($class);
include_once("lib/class.$class.php");
}
});

29
htdocs/lib/config.php Normal file
View file

@ -0,0 +1,29 @@
<?php
const CONFIG_FILE = './config/conf.php';
const CONNECT_FILE = './config/connect.php';
spl_autoload_register(function ($class) {
if (file_exists("vendor/evolibs/$class.php")) {
include_once("vendor/evolibs/$class.php");
} else {
$class = strtolower($class);
include_once("lib/class.$class.php");
}
});
if (file_exists(CONFIG_FILE)) {
require_once(CONFIG_FILE);
global $conf;
if ($conf['domaines']['driver'] == 'ldap') {
if (file_exists(CONNECT_FILE)) {
require_once(CONNECT_FILE);
} else {
# EvoLog::log('You must create '.CONNECT_FILE);
return false;
}
}
} else {
# EvoLog::log('You must create '.CONFIG_FILE);
return false;
}