diff --git a/LICENSE.txt b/LICENSE.txt
old mode 100644
new mode 100755
index 450aee1091f92cbb8023bf43acbd6f279a30bb40..1a1efdfbf31aeed2befe6ad665135dd10ab7691b
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -6,7 +6,7 @@
  of this license document, but changing it is not allowed.
 
                             Preamble
-
+  
   The GNU General Public License is a free, copyleft license for
 software and other kinds of works.
  
diff --git a/apps/maarch_entreprise/define.php b/apps/maarch_entreprise/define.php
new file mode 100644
index 0000000000000000000000000000000000000000..c8926c55a5fead26bdc4e9609e83c0c8fdf0f617
--- /dev/null
+++ b/apps/maarch_entreprise/define.php
@@ -0,0 +1,95 @@
+<?php
+/*
+*    Copyright 2008-2017 Maarch
+*
+*  This file is part of Maarch Framework.
+*
+*   Maarch Framework is free software: you can redistribute it and/or modify
+*   it under the terms of the GNU General Public License as published by
+*   the Free Software Foundation, either version 3 of the License, or
+*   (at your option) any later version.
+*
+*   Maarch Framework is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details.
+*
+*   You should have received a copy of the GNU General Public License
+*    along with Maarch Framework.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * Ce fichier a placer dans custom/[CUSTOM]/define_local.php permet de mettre des definitions spécifique au serveur
+ **/
+if ( !empty($_SESSION['custom_override_id']) && file_exists("{$_SESSION['config']['corepath']}custom/{$_SESSION['custom_override_id']}/define_local.php") ) {
+	require_once "{$_SESSION['config']['corepath']}custom/{$_SESSION['custom_override_id']}/define_local.php";
+}
+
+/**
+ * Ce fichier a mettre en paralléle dans le custom, permet de mettre des definitions spécifique au custom (exemple langue ou remplacement de define de ce fichier de base)
+ **/
+require_once 'apps/maarch_entreprise/define_custom.php';
+
+if ( ! defined('DEBUG') ) {
+	define('DEBUG', false);
+}
+if ( DEBUG ) {
+	if (!ini_get('display_errors')) {
+	    ini_set('display_errors', 1);
+	}
+	if ( defined('E_ERROR_REPORTING') ) {
+		error_reporting(E_ERROR_REPORTING);
+	} else {
+		error_reporting(E_ALL);
+	}
+}
+if ( @$_SERVER['HTTP_USER_AGENT'] == 'TestU' ) {
+	ini_set('display_errors', 1);
+	error_reporting(E_ALL & ~ E_NOTICE);
+}
+
+if ( ! defined('HEADER_USER_UID_SALT') ) {
+	define('HEADER_USER_UID_SALT', '%s');
+}
+
+// BaseUrl for Web side :
+if ( ! defined('URL_IMG') ){
+	define('URL_IMG', '');
+}
+
+function return_bytes ($size_str)
+{
+    switch (substr ($size_str, -1))
+    {
+        case 'M': case 'm': return (int)$size_str * 1048576;
+        case 'K': case 'k': return (int)$size_str * 1024;
+        case 'G': case 'g': return (int)$size_str * 1073741824;
+        default: return $size_str;
+    }
+}
+// hom many file may we can upload :
+if ( ! defined('UPLOAD_FILE_LIMIT_COUNT') ){
+	define('UPLOAD_FILE_LIMIT_COUNT', 100);
+}
+if ( ! defined('UPLOAD_FILES_MAX_SIZE') ) {
+	define('UPLOAD_FILES_MAX_SIZE', min(
+		return_bytes(ini_get('upload_max_filesize')),
+		return_bytes(ini_get('post_max_size'))
+		));
+}
+if ( ! defined('UPLOAD_FILE_MAX_SIZE') ) {
+	define('UPLOAD_FILE_MAX_SIZE', min(
+		UPLOAD_FILES_MAX_SIZE,
+		return_bytes(ini_get('upload_max_filesize')),
+		return_bytes(ini_get('post_max_size'))
+		));
+}
+
+if ( ! defined('HEADER_USER_UID') ) {
+	define('HEADER_USER_UID', 'UID');
+}
+
+
+if ( ! defined('DEFAULT_PAGE') ) {
+    define('DEFAULT_PAGE', 'index.php');
+}
diff --git a/apps/maarch_entreprise/define_custom.php b/apps/maarch_entreprise/define_custom.php
new file mode 100644
index 0000000000000000000000000000000000000000..b4af7c17220fc0690b361a18e73ea36885e93910
--- /dev/null
+++ b/apps/maarch_entreprise/define_custom.php
@@ -0,0 +1,21 @@
+<?php
+/*
+*    Copyright 2008-2016 Maarch
+*
+*  This file is part of Maarch Framework.
+*
+*   Maarch Framework is free software: you can redistribute it and/or modify
+*   it under the terms of the GNU General Public License as published by
+*   the Free Software Foundation, either version 3 of the License, or
+*   (at your option) any later version.
+*
+*   Maarch Framework is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details.
+*
+*   You should have received a copy of the GNU General Public License
+*    along with Maarch Framework.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+// Write your custom define
diff --git a/apps/maarch_entreprise/services/Table.php b/apps/maarch_entreprise/services/Table.php
new file mode 100644
index 0000000000000000000000000000000000000000..801a085dee9badf04976c51ae1d2f6df11ae3900
--- /dev/null
+++ b/apps/maarch_entreprise/services/Table.php
@@ -0,0 +1,313 @@
+<?php
+/*
+*    Copyright 2017 Maarch
+*
+*  This file is part of Maarch Framework.
+*
+*   Maarch Framework is free software: you can redistribute it and/or modify
+*   it under the terms of the GNU General Public License as published by
+*   the Free Software Foundation, either version 3 of the License, or
+*   (at your option) any later version.
+*
+*   Maarch Framework is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details.
+*
+*   You should have received a copy of the GNU General Public License
+*    along with Maarch Framework.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+require_once 'core/services/Abstract.php';
+
+// Prés-requis BDD :
+require_once 'core/core_tables.php';
+require_once 'core/class/class_functions.php';
+require_once 'core/class/class_db_pdo.php';
+require_once 'core/services/Logs.php';
+
+/**
+ * Fonctions pour réaliser le CRUD sur la base de donnees
+ */
+class Apps_Table_Service extends Core_Abstract_Service {
+    /**
+     * Récupération de la liste des méthodes disponibles via api
+     * 
+     * @return string[] La liste des méthodes
+     */
+    public static function getApiMethod() {
+        $aApiMethod = parent::getApiMethod();
+        return $aApiMethod;
+    }
+
+    /**
+     * Permet de faire un select en BDD
+     * @api apiurl
+     * @param array $args donnée sur l'attachement
+     *  - from/table : FROM [table]
+     *  - string/array select : SELECT [select]
+     *  - string/array where : WHERE [where]
+     *  - data : for remplace ? on query
+     *  - array conditions : [condition => valeur]
+     * @return [type]       [description]
+     */
+    public static function select(array $args=[]){
+        // Table :
+        if ( !empty($args['from']) ) {
+            $args['table'] = $args['from'];
+        }
+        if ( empty($args['table']) ) {
+            throw new Core_SipolException_Service('table empty');
+        }
+        if ( is_array($args['table']) ) {
+            if (empty($args['table'][0])) {
+                $args['table'] = array_values($args['table']);
+            }
+            $tmpTable = $args['table'];
+            if (!empty($args['left_join'])) {
+                $keywordJoin = ' LEFT JOIN ';
+                $args['table'] = $args['table'][0];
+                $args['join'] = $args['left_join'];
+            } else {
+                $keywordJoin = ' JOIN ';
+                $args['table'] = $args['table'][0];
+            }
+            
+            // Join :
+            if ( ! empty($args['join']) ) {
+                if ( ! is_array($args['join']) ) {
+                    throw new Core_SipolException_Service('where must be an array');
+                } else if (count($tmpTable) - 1 != count($args['join'])) {
+                    throw new Core_SipolException_Service('Number of tables doesn\'t match with number of joins');
+                }
+                $z = 1;
+                foreach ($args['join'] as $cond) {
+                    if ( empty($args['where']) ) {
+                        $args['where'] = [];
+                    }
+                    $args['table'] .=  $keywordJoin . $tmpTable[$z] . ' ON '.  $cond;
+                    $z++;
+                }
+
+            }
+        }
+        if ( defined(strtoupper($args['table']).'_TABLE')) {
+            $tablename = constant(strtoupper($args['table']).'_TABLE');
+        } else {
+            //throw new Core_SipolException_Service('table ('.$args['table'].') not defined');
+            $tablename = $args['table'];
+        }
+        // Select :
+        if ( ! empty($args['select']) ) {
+            if ( is_array($args['select']) )
+                $args['select'] = implode(',', $args['select']);
+            if ( ! is_string($args['select']) ) {
+                throw new Core_SipolException_Service('select must be : string or array');
+            }
+        }
+        $select = empty($args['select']) ? '*' : $args['select'];
+        // Where :
+        if ( empty($args['where']) ) {
+            $args['where'] = [];
+        }
+        if ( is_string($args['where']) ) {
+            $args['where'] = [$args['where']];
+        }
+        $aWhere = $args['where'];
+        if ( ! is_array($aWhere) ) {
+            throw new Core_SipolException_Service('where must be : string or array');
+        }
+        // Data :
+        if ( empty($args['data']) ) {
+            $args['data'] = [];
+        }
+        if ( ! is_array($args['data']) ) {
+            throw new Core_SipolException_Service('data must be an array');
+        }
+        $data = $args['data'];
+        // Conditions :
+        if ( ! empty($args['conditions']) ) {
+            if ( ! is_array($args['conditions']) ) {
+                throw new Core_SipolException_Service('where must be an array');
+            }
+            foreach ($args['conditions'] as $cond => $value) {
+                $aWhere[] = $cond;
+                $data[] = $value;
+            }
+        }
+        // Fusion des données de recherche :
+        $where = empty($aWhere) ? '' : ' WHERE '.implode(' AND ', $aWhere);
+
+        // GroupBy :
+        if ( empty($args['group_by']) ) {
+            $group_by = '';
+        } else {
+            if ( is_array($args['group_by']) )
+                $args['group_by'] = implode(',', $args['group_by']);
+            if ( ! is_string($args['group_by']) ) {
+                throw new Core_SipolException_Service('group_by must be : string or array');
+            }
+            $group_by = ' GROUP BY '.$args['group_by'];
+        }
+        // OrderBy :
+        if ( empty($args['order_by']) ) {
+            $order_by = '';
+        } else {
+            if ( is_array($args['order_by']) )
+                $args['order_by'] = implode(',', $args['order_by']);
+            if ( ! is_string($args['order_by']) ) {
+                throw new Core_SipolException_Service('order_by must be : string or array');
+            }
+            $order_by = ' ORDER BY '.$args['order_by'];
+        }
+        // Limit :
+        if ( empty($args['limit']) ) {
+            $limit = '';
+        } else {
+            if ( ! is_numeric($args['limit']) ) {
+                throw new Core_SipolException_Service('limit must be : numeric');
+            }
+            $limit = ' LIMIT '.$args['limit'];
+        }
+        // Query :
+        $queryExt = "SELECT $select FROM $tablename $where $group_by $order_by $limit";
+        //Core_Logs_Service::debug(['message'=>'Requête:'.$queryExt]); 
+        //echo "the query " . $queryExt . PHP_EOL;var_export($data). PHP_EOL;
+        if(!isset($GLOBALS['configFile'])){
+            $GLOBALS['configFile'] = null;
+        }
+        $db = new Database($GLOBALS['configFile']);
+        $stmt = empty($data) ? $db->query($queryExt) : $db->query($queryExt, $data);
+        //var_dump($stmt);
+        $rowset = [];
+        while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
+            $rowset[] = $row;
+        }
+        return $rowset;
+    }
+
+    /**
+     * Ajoute un row dans la base de données
+     * @param array $aData donnée a ajouter
+     * @param array $table table de l'ajout
+     * @param string $getLastId
+     * @return [type]        [description]
+     */
+    public static function insertInto(array $aData, $table, $getLastId = null){
+        if ( ! is_string($table) ) {
+            throw new Core_SipolException_Service('$table is not a string');
+        }
+        $queryExtFields = [];
+        $queryExtJokers = [];
+        $queryExtValues = [];
+        foreach ($aData as $key => $value) {
+            $queryExtFields[] = $key;
+            $queryExtJokers[] = '?';
+            $queryExtValues[] = $value;
+        }
+        $queryExt = 'INSERT INTO '.$table.'('.implode(',', $queryExtFields).')values('.implode(',', $queryExtJokers).')';
+        //echo "the query " . $queryExt . PHP_EOL;var_export($queryExtFields). PHP_EOL;var_export($queryExtValues). PHP_EOL;
+        $db = new Database();
+        $return = $db->query($queryExt, $queryExtValues);
+        if (!empty($getLastId)) {
+            return $db->lastInsertId($getLastId);
+        }
+        return $return;
+    }
+
+    /**
+     * [updateTable description]
+     * @param  array  $aData  [description]
+     * @param  string $table  [description]
+     * @param  array  $aWhere [description]
+     * @return [type]         [description]
+     */
+    public static function updateTable(array $aData, $table, $aWhere = []){
+        // Prés-requis :
+        if ( ! is_string($table) ) {
+            throw new Core_SipolException_Service('$table not a string');
+        }
+        if ( ! is_array($aData) ) {
+            throw new Core_SipolException_Service('$aData not an array');
+        }
+        if ( empty($aData) ) {
+            throw new Core_SipolException_Service('$aData empty');
+        }
+        // Initialisation :
+        $queryExtUpdate = [];
+        $queryExtWhere  = [];
+        $queryExtValues = [];
+        // SET :
+        foreach ($aData as $key => $value) {
+            $queryExtUpdate[$key] = "{$key}=?";
+            $queryExtValues[] = $value;
+        }
+        // Where :
+        foreach ($aWhere as $key => $value) {
+            if ( strpos($key, '?')===false )
+                $key = "{$key}=?";
+            $queryExtWhere[$key] = $key;
+            $queryExtValues[] = $value;
+        }
+
+        $sWhere = empty($aWhere)?'': ' WHERE '.implode(' AND ', $queryExtWhere);
+        $queryExt = 'UPDATE '.$table.' SET '.implode(',', $queryExtUpdate).$sWhere;
+        $db = new Database();
+        return $db->query($queryExt, $queryExtValues);
+    }
+
+    /**
+     * Supprime un row dans la base de données
+     * @param array $aWhere données where
+     * @param array $table table de l'ajout
+     * @return [type]        [description]
+     */
+    public static function deleteInto(array $aWhere, $table){
+        if ( ! is_string($table) ) {
+            throw new Core_SipolException_Service('$table not a string');
+        }
+        $queryExtWhere = [];
+        $queryExtValues = [];
+        // Where :
+        foreach ($aWhere as $key => $value) {
+            $queryExtWhere[$key] = "{$key}=?";
+            $queryExtValues[] = $value;
+        }
+        $sWhere = empty($aWhere)?'': ' WHERE '.implode(' AND ', $queryExtWhere);
+        $queryExt = 'DELETE FROM '.$table.$sWhere;
+        $db = new Database();
+        return $db->query($queryExt, $queryExtValues);
+    }
+
+    /**
+     * Fonction de suppression dans la base de données
+     * @param array $args
+     * @throws Core_SipolException_Service if Table Argument is empty or is not a string
+     * @throws Core_SipolException_Service if Where Argument is empty or is not an array
+     * @throws Core_SipolException_Service if Data Argument is not an array
+     *
+     * @return bool
+     */
+    public static function deleteFrom(array $args = []){
+        if (empty($args['table']) || !is_string($args['table'])) {
+            throw new Core_SipolException_Service('Table Argument is empty or is not a string.');
+        }
+        if (empty($args['where']) || !is_array($args['where'])) {
+            throw new Core_SipolException_Service('Where Argument is empty or is not an array.');
+        }
+
+        if (empty($args['data'])) {
+            $args['data'] = [];
+        }
+        if (!is_array($args['data'])) {
+            throw new Core_SipolException_Service('Data Argument is not an array.');
+        }
+
+        $queryExt = 'DELETE FROM ' .$args['table']. ' WHERE ' . implode(' AND ', $args['where']);
+
+        $db = new Database();
+        $db->query($queryExt, $args['data']);
+
+        return true;
+    }
+}
diff --git a/core/services/Abstract.php b/core/services/Abstract.php
new file mode 100644
index 0000000000000000000000000000000000000000..8f7a8270bd9a05a877afaa07b1072b6995c3735a
--- /dev/null
+++ b/core/services/Abstract.php
@@ -0,0 +1,337 @@
+<?php
+
+/**
+*   @copyright 2017 Maarch
+*
+*   This file is part of Maarch Framework.
+*
+*   Maarch Framework is free software: you can redistribute it and/or modify
+*   it under the terms of the GNU General Public License as published by
+*   the Free Software Foundation, either version 3 of the License, or
+*   (at your option) any later version.
+*
+*   Maarch Framework is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details.
+*
+*   You should have received a copy of the GNU General Public License
+*   along with Maarch Framework.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+require_once 'core/class/class_core_tools.php';
+require_once 'core/services/MaarchException.php';
+
+/**
+ * 
+ */
+abstract class Core_Abstract_Service {
+	/**
+	 * Récupération de la liste des méthodes disponibles via api
+	 * 
+	 * @return string[] La liste des méthodes
+	 */
+	public static function getApiMethod() {
+		return [
+			'getApiMethod' => 'getApiMethod',
+		];
+	}
+
+	/**
+	 * Vérifie que l'user est bien les droits requis
+	 * @param array $aRequired
+	 * @return boolean true
+	 * @throws Exception denied
+	**/
+	protected static function checkAllow(array $aRequired) {
+		$core = new core_tools();
+		foreach ($aRequired as $permission) {
+			if ( ! $core->test_service($permission, 'apps', false) ) {
+				throw new Core_MaarchException_Service('missing permission required : '.$permission);
+			}
+		}
+		return true;
+	}
+
+	/**
+	 * Vérifie que l'argument est bien existant
+	 * @param array $aArgs
+	 * @param array $aRequired
+	 * @param string $sErrorTxt
+	**/
+	protected static function checkIsset(array $aArgs, $aRequired, $sErrorTxt='$required is not set') {
+		if ( is_string($aRequired) ) {
+			$aRequired = [$aRequired];
+		}
+		if ( ! is_array($aRequired) ) {
+			throw new Core_MaarchException_Service("aRequired is not a array", 1);
+		}
+		foreach ($aRequired as $required) {
+			if ( !isset($aArgs[$required]) ) {
+				throw new Core_MaarchException_Service(str_replace('$required', $required, $sErrorTxt));
+			}
+		}
+		return true;
+	}
+
+	/**
+	 * Vérifie que l'argument est bien rempli
+	 * @param array $aArgs
+	 * @param array $aRequired
+	 * @param string $sErrorTxt
+	**/
+	protected static function checkRequired(array $aArgs, $aRequired, $sErrorTxt='$required is required') {
+		if ( is_string($aRequired) ) {
+			$aRequired = [$aRequired];
+		}
+		if ( ! is_array($aRequired) ) {
+			throw new Core_MaarchException_Service("aRequired is not a array", 1);
+		}
+		foreach ($aRequired as $required) {
+			if ( !isset($aArgs[$required]) ) {
+				throw new Core_MaarchException_Service(str_replace('$required', $required, $sErrorTxt));
+			}
+			if ( empty($aArgs[$required]) ) {
+				throw new Core_MaarchException_Service(str_replace('$required', $required, $sErrorTxt));
+			}
+		}
+		return true;
+	}
+
+	/**
+	 * Vérifie que l'argument est bien inexistant ou un string
+	 * @param array $aArgs
+	 * @param array $aTry
+	 * @param string $sErrorTxt
+	**/
+	protected static function checkString(array $aArgs, $aTry, $sErrorTxt='$try must be a string') {
+		if ( is_string($aTry) ) {
+			$aTry = [$aTry];
+		}
+		if ( ! is_array($aTry) ) {
+			throw new Core_MaarchException_Service("aTry is not a array", 1);
+		}
+		foreach ($aTry as $try) {
+			if ( !isset($aArgs[$try]) ) {
+				continue;
+			}
+			if ( empty($aArgs[$try]) ) {
+				continue;
+			}
+			if ( ! is_string($aArgs[$try]) ) {
+				throw new Core_MaarchException_Service(str_replace('$try', $try, $sErrorTxt));
+			}
+		}
+		return true;
+	}
+
+	/**
+	 * Vérifie que l'argument est bien inexistant ou un nombre
+	 * @param array $aArgs
+	 * @param array $aTry
+	 * @param string $sErrorTxt
+	**/
+	protected static function checkNumeric(array $aArgs, $aTry, $sErrorTxt='$try must be a number') {
+		if ( is_string($aTry) ) {
+			$aTry = [$aTry];
+		}
+		if ( ! is_array($aTry) ) {
+			throw new Core_MaarchException_Service("aTry is not a array", 1);
+		}
+		foreach ($aTry as $try) {
+			if ( !isset($aArgs[$try]) ) {
+				continue;
+			}
+			if ( empty($aArgs[$try]) ) {
+				continue;
+			}
+			if ( ! is_numeric($aArgs[$try]) ) {
+				throw new Core_MaarchException_Service(str_replace('$try', $try, $sErrorTxt));
+			}
+		}
+		return true;
+	}
+
+	/**
+	 * Vérifie que l'argument est bien inexistant ou un tableau
+	 * @param array $aArgs
+	 * @param array $aTry
+	 * @param string $sErrorTxt
+	**/
+	protected static function checkArray(array $aArgs, $aTry, $sErrorTxt='$try must be a array') {
+		if ( is_string($aTry) ) {
+			$aTry = [$aTry];
+		}
+		if ( ! is_array($aTry) ) {
+			throw new Core_MaarchException_Service("aTry is not a array", 1);
+		}
+		foreach ($aTry as $try) {
+			if ( !isset($aArgs[$try]) ) {
+				continue;
+			}
+			if ( empty($aArgs[$try]) ) {
+				continue;
+			}
+			if ( ! is_array($aArgs[$try]) ) {
+				throw new Core_MaarchException_Service(str_replace('$try', $try, $sErrorTxt));
+			}
+		}
+		return true;
+	}
+
+	/**
+	 * Vérifie que l'argument est bien inexistant ou une instance
+	 * @param array $aArgs
+	 * @param array $aTry
+	 * @param string $sErrorTxt
+	**/
+	protected static function checkObject(array $aArgs, $aTry, $sErrorTxt='$try must be an instance') {
+		if ( is_string($aTry) ) {
+			$aTry = [$aTry];
+		}
+		if ( ! is_array($aTry) ) {
+			throw new Core_MaarchException_Service("aTry is not a array", 1);
+		}
+		foreach ($aTry as $try) {
+			if ( !isset($aArgs[$try]) ) {
+				continue;
+			}
+			if ( empty($aArgs[$try]) ) {
+				continue;
+			}
+			if ( ! is_object($aArgs[$try]) ) {
+				throw new Core_MaarchException_Service(str_replace('$try', $try, $sErrorTxt));
+			}
+		}
+		return true;
+	}
+	protected static function formatDatestring($sDate) {
+		$sDate = trim($sDate);
+		$sDate = preg_replace('#^(\w{2})/(\w{2})/(\w{4})\s(\d{2}):(\d{2})#', '$3-$2-$1 $4:$5:00', $sDate);
+		$sDate = preg_replace('#^(\w{2})/(\w{2})/(\w{4})$#', '$3-$2-$1', $sDate);
+		return $sDate;
+	}
+
+	/**
+	 * Vérifie que l'argument est bien inexistant ou un string representant une date
+	 * @param array $aArgs
+	 * @param array $aTry
+	 * @param string $sErrorTxt
+	**/
+	protected static function checkDatestring(array $aArgs, $aTry, $sErrorTxt='$try must be a date (string) : $value') {
+		if ( is_string($aTry) ) {
+			$aTry = [$aTry];
+		}
+		if ( ! is_array($aTry) ) {
+			throw new Core_MaarchException_Service("aTry is not a array", 1);
+		}
+		self::checkString($aArgs, $aTry, $sErrorTxt);
+		foreach ($aTry as $try) {
+			if ( !isset($aArgs[$try]) ) {
+				continue;
+			}
+			$aArgs[$try] = trim($aArgs[$try]);
+			if ( empty($aArgs[$try]) ) {
+				continue;
+			}
+			if ( ! strtotime($aArgs[$try]) ) {
+				throw new Core_MaarchException_Service(str_replace(['$try','$value',], [$try,$aArgs[$try],], $sErrorTxt));
+			}
+		}
+		return true;
+	}
+
+	/**
+	 * Vérifie que l'argument est bien inexistant ou un objet Date
+	 * @param array $aArgs
+	 * @param array $aTry
+	 * @param string $sErrorTxt
+	**/
+	protected static function checkDateobject(array $aArgs, $aTry, $sErrorTxt='$try must be a date (instance)') {
+		if ( is_string($aTry) ) {
+			$aTry = [$aTry];
+		}
+		if ( ! is_array($aTry) ) {
+			throw new Core_MaarchException_Service("aTry is not a array", 1);
+		}
+		self::checkObject($aArgs, $aTry, $sErrorTxt);
+		foreach ($aTry as $try) {
+			if ( !isset($aArgs[$try]) ) {
+				continue;
+			}
+			if ( empty($aArgs[$try]) ) {
+				continue;
+			}
+			if ( $aArgs[$try] instanceof \Date || $aArgs[$try] instanceof \DateTime ) {
+				throw new Core_MaarchException_Service(str_replace('$try', $try, $sErrorTxt));
+			}
+		}
+		return true;
+	}
+
+	/**
+	 * Vérifie que l'argument est bien inexistant ou un tableau de string
+	 * @param array $aArgs
+	 * @param array $aTry
+	 * @param string $sErrorTxt
+	**/
+	protected static function checkArrayString(array $aArgs, $aTry, $sErrorTxt='$try must be a array of string') {
+		self::checkArray($aArgs, $aTry, $sErrorTxt); // Je testerai que la sous partie des tableaux, et je délégue la vérification du typage tableau
+		if ( is_string($aTry) ) {
+			$aTry = [$aTry];
+		}
+		if ( ! is_array($aTry) ) {
+			throw new Core_MaarchException_Service("aTry is not a array", 1);
+		}
+		foreach ($aTry as $array) {
+			if ( empty($aArgs[$array]) ) {
+				continue;
+			}
+			foreach ($aArgs[$array] as $try) {
+				if ( !isset($aArgs[$try]) ) {
+					continue;
+				}
+				if ( empty($aArgs[$try]) ) {
+					continue;
+				}
+				if ( ! is_string($aArgs[$try]) ) {
+					throw new Core_MaarchException_Service(str_replace('$try', $try, $sErrorTxt));
+				}
+			}
+		}
+		return true;
+	}
+
+	/**
+	 * Vérifie que l'argument est bien inexistant ou un tableau de numeric
+	 * @param array $aArgs
+	 * @param array $aTry
+	 * @param string $sErrorTxt
+	**/
+	protected static function checkArrayNumeric(array $aArgs, $aTry, $sErrorTxt='$try must be a array of numeric') {
+		self::checkArray($aArgs, $aTry, $sErrorTxt); // Je testerai que la sous partie des tableaux, et je délégue la vérification du typage tableau
+		if ( is_string($aTry) ) {
+			$aTry = [$aTry];
+		}
+		if ( ! is_array($aTry) ) {
+			throw new Core_MaarchException_Service("aTry is not a array", 1);
+		}
+		foreach ($aTry as $array) {
+			if ( empty($aArgs[$array]) ) {
+				continue;
+			}
+			foreach ($aArgs[$array] as $try) {
+				if ( !isset($aArgs[$try]) ) {
+					continue;
+				}
+				if ( empty($aArgs[$try]) ) {
+					continue;
+				}
+				if ( ! is_numeric($aArgs[$try]) ) {
+					throw new Core_MaarchException_Service(str_replace('$try', $try, $sErrorTxt));
+				}
+			}
+		}
+		return true;
+	}
+}
diff --git a/core/services/CoreConfig.php b/core/services/CoreConfig.php
new file mode 100644
index 0000000000000000000000000000000000000000..449b67d10095285b0f713d6f2b28ee2432568f40
--- /dev/null
+++ b/core/services/CoreConfig.php
@@ -0,0 +1,28 @@
+<?php
+/**
+*   @copyright 2017 Maarch
+*
+*   This file is part of Maarch Framework.
+*
+*   Maarch Framework is free software: you can redistribute it and/or modify
+*   it under the terms of the GNU General Public License as published by
+*   the Free Software Foundation, either version 3 of the License, or
+*   (at your option) any later version.
+*
+*   Maarch Framework is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details.
+*
+*   You should have received a copy of the GNU General Public License
+*   along with Maarch Framework.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+require_once 'core/services/CoreConfigAbstract.php';
+
+/**
+ * Service de configuration du core
+ */
+class Core_CoreConfig_Service extends Core_CoreConfigAbstract_Service{
+    // Do your stuff
+}
diff --git a/core/services/CoreConfigAbstract.php b/core/services/CoreConfigAbstract.php
new file mode 100644
index 0000000000000000000000000000000000000000..977aeef4f3d3e9173d7e91ddc9ffdfc79653a609
--- /dev/null
+++ b/core/services/CoreConfigAbstract.php
@@ -0,0 +1,910 @@
+<?php
+
+/**
+*   @copyright 2017 Maarch
+*
+*   This file is part of Maarch Framework.
+*
+*   Maarch Framework is free software: you can redistribute it and/or modify
+*   it under the terms of the GNU General Public License as published by
+*   the Free Software Foundation, either version 3 of the License, or
+*   (at your option) any later version.
+*
+*   Maarch Framework is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details.
+*
+*   You should have received a copy of the GNU General Public License
+*   along with Maarch Framework.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+require_once 'core' . DIRECTORY_SEPARATOR . 'services' . DIRECTORY_SEPARATOR . 'Abstract.php';
+require_once 'core' . DIRECTORY_SEPARATOR . 'services' . DIRECTORY_SEPARATOR . 'CoreConfig.php';
+require_once 'core' . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'class_core_tools.php';
+
+/**
+ * Service de configuration du core
+ */
+class Core_CoreConfigAbstract_Service extends Core_Abstract_Service {
+	/**
+	 * Get TableName from the core/xml/config.xml file to load Maarch core configuration into session 
+	 * @param  string $pathtoxmlcore path to the xml core config file
+	 * @return array the list of TableName
+	 */
+	private static function getTableName($pathtoxmlcore)
+	{
+		$xmlconfig = simplexml_load_file($pathtoxmlcore);
+		$TABLENAME = $xmlconfig->TABLENAME ;
+		return $TABLENAME;
+	}
+
+     /**
+     * Load Maarch core configuration into sessions vars from the core/xml/config.xml file
+     * @param  string $pathtoxmlcore path to the xml core config file
+     */
+    public static function buildCoreConfig($pathtoxmlcore)
+    {
+        // Get TableName from xml file
+        $TABLENAME = SELF::getTableName($pathtoxmlcore);
+
+        // Loads  core tables into session ($_SESSION['tablename'] array)
+        $_SESSION['tablename']['actions']            = (string) $TABLENAME->actions;
+        $_SESSION['tablename']['authors']            = (string) $TABLENAME->authors;
+        $_SESSION['tablename']['docservers']         = (string) $TABLENAME->docservers;
+        $_SESSION['tablename']['doctypes']           = (string) $TABLENAME->doctypes;
+        $_SESSION['tablename']['ext_docserver']      = (string) $TABLENAME->extdocserver;
+        $_SESSION['tablename']['fulltext']           = (string) $TABLENAME->fulltext;
+        $_SESSION['tablename']['groupsecurity']      = (string) $TABLENAME->groupsecurity;
+        $_SESSION['tablename']['history']            = (string) $TABLENAME->history;
+        $_SESSION['tablename']['history_batch']      = (string) $TABLENAME->history_batch;
+        $_SESSION['tablename']['param']              = (string) $TABLENAME->param;
+        $_SESSION['tablename']['resgroups']          = (string) $TABLENAME->resgroups;
+        $_SESSION['tablename']['resgroup_content']   = (string) $TABLENAME->resgroup_content;
+        $_SESSION['tablename']['security']           = (string) $TABLENAME->security;
+        $_SESSION['tablename']['status']             = (string) $TABLENAME->status;
+        $_SESSION['tablename']['usergroups']         = (string) $TABLENAME->usergroups;
+        $_SESSION['tablename']['usergroup_content']  = (string) $TABLENAME->usergroupcontent;
+        $_SESSION['tablename']['usergroup_services'] = (string) $TABLENAME->usergroups_services;
+        $_SESSION['tablename']['users']              = (string) $TABLENAME->users;
+    }
+
+    /**
+    * Build Maarch business app configuration into sessions vars with a xml
+    * configuration file
+    */
+    public static function buildBusinessAppConfig()
+    {
+        // build Maarch business app configuration into sessions vars
+
+        $core = new core_tools();
+
+       // $_SESSION['config']['app_id']='maarch_entreprise';
+        require_once 'apps' . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id'] . DIRECTORY_SEPARATOR  . 'class' . DIRECTORY_SEPARATOR . 'class_business_app_tools.php';
+        $businessAppTools = new business_app_tools();
+
+        if (file_exists(
+            $_SESSION['config']['corepath'] . 'custom' . DIRECTORY_SEPARATOR
+            . $_SESSION['custom_override_id'] . DIRECTORY_SEPARATOR . 'apps'
+            . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id']
+            . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'config.xml'
+        )
+        ) {
+            $path = $_SESSION['config']['corepath'] . 'custom'
+                  . DIRECTORY_SEPARATOR . $_SESSION['custom_override_id']
+                  . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR
+                  . $_SESSION['config']['app_id'] . DIRECTORY_SEPARATOR . 'xml'
+                  . DIRECTORY_SEPARATOR . 'config.xml';
+        } else {
+            $path = 'apps' . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id']
+                  . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR
+                  . 'config.xml';
+        }
+        $xmlconfig = @simplexml_load_file($path);
+        if ( ! $xmlconfig ) {
+            throw new \Exception('conf not-found : '.$path);
+        }
+        if ($xmlconfig <> false) {
+            $config = $xmlconfig->CONFIG;
+            $uriBeginning = strpos($_SERVER['SCRIPT_NAME'], 'apps');
+            if (empty($uriBeginning)) {
+                $_SESSION['config']['businessappurl'] = $_SESSION['config']['coreurl']
+                    . 'apps/maarch_entreprise/';
+            } else {
+                $url = $_SESSION['config']['coreurl']
+                    .substr($_SERVER['SCRIPT_NAME'], $uriBeginning);
+                $_SESSION['config']['businessappurl'] = str_replace(
+                    'index.php', '', $url
+                );    
+            }
+            
+            //echo $_SESSION['config']['businessappurl'];exit;
+
+            $_SESSION['config']['databaseserver'] =
+                (string) $config->databaseserver;
+            $_SESSION['config']['databaseserverport'] =
+                (string) $config->databaseserverport;
+            $_SESSION['config']['databasetype'] =
+                (string) $config->databasetype;
+            $_SESSION['config']['databasename'] =
+                (string) $config->databasename;
+            $_SESSION['config']['databaseschema'] =
+                (string) $config->databaseschema;
+            $_SESSION['config']['databaseuser'] =
+                (string) $config->databaseuser;
+            $_SESSION['config']['databasepassword'] =
+                (string) $config->databasepassword;
+            $_SESSION['config']['databasesearchlimit'] =
+                (string) $config->databasesearchlimit;
+            $_SESSION['config']['nblinetoshow'] =
+                (string) $config->nblinetoshow;
+            $_SESSION['config']['limitcharsearch'] =
+                (string) $config->limitcharsearch;
+            $_SESSION['config']['lang']                = (string) $config->lang;
+            $_SESSION['config']['adminmail']           = (string) $config->adminmail;
+            $_SESSION['config']['adminname']           = (string) $config->adminname;
+            $_SESSION['config']['debug']               = (string) $config->debug;
+            $_SESSION['config']['applicationname']     = (string) $config->applicationname;
+            $_SESSION['config']['defaultPage']         = (string) $config->defaultPage;
+            $_SESSION['config']['exportdirectory']     = (string) $config->exportdirectory;
+            $_SESSION['config']['cookietime']          = (string) $config->CookieTime;
+            $_SESSION['config']['ldap']                = (string) $config->ldap;
+            $_SESSION['config']['userdefaultpassword'] = (string) $config->userdefaultpassword;
+            $_SESSION['config']['usePDO']              = (string) $config->usePDO;
+            $_SESSION['config']['usePHPIDS']           = (string) $config->usePHPIDS;
+            if (isset($config->showfooter)) {
+                $_SESSION['config']['showfooter'] = (string) $config->showfooter;
+            } else {
+                $_SESSION['config']['showfooter'] = 'true';
+            }
+            //$_SESSION['config']['databaseworkspace'] = (string) $config->databaseworkspace;
+
+            $tablename = $xmlconfig->TABLENAME;
+            $_SESSION['tablename']['doctypes_first_level']  = (string) $tablename->doctypes_first_level;
+            $_SESSION['tablename']['doctypes_second_level'] = (string) $tablename->doctypes_second_level;
+            $_SESSION['tablename']['mlb_doctype_ext']       = (string) $tablename->mlb_doctype_ext;
+            $_SESSION['tablename']['doctypes_indexes']      = (string) $tablename->doctypes_indexes;
+            $_SESSION['tablename']['saved_queries']         = (string) $tablename->saved_queries;
+            $_SESSION['tablename']['contacts_v2']           = (string) $tablename->contacts_v2;
+            $_SESSION['tablename']['contact_types']         = (string) $tablename->contact_types;
+            $_SESSION['tablename']['contact_purposes']      = (string) $tablename->contact_purposes;
+            $_SESSION['tablename']['contact_addresses']     = (string) $tablename->contact_addresses;
+            $_SESSION['tablename']['tags']                  = (string) $tablename->tags;
+            
+            $_SESSION['config']['tmppath'] = $_SESSION['config']['corepath'] . 'apps' 
+                . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id']
+                . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR;
+            
+            $i = 0;
+
+            if ( isset($_SESSION['custom_override_id']) && file_exists(
+                'custom/' . $_SESSION['custom_override_id'] . '/'
+                . $_SESSION['config']['lang'] . '.php'
+            )
+            ) {
+               include_once 'custom/' . $_SESSION['custom_override_id'] . '/'
+                . $_SESSION['config']['lang'] . '.php';
+            }
+            include_once 'apps' . DIRECTORY_SEPARATOR
+                    . $_SESSION['config']['app_id'] . DIRECTORY_SEPARATOR
+                    . 'lang' . DIRECTORY_SEPARATOR . $_SESSION['config']['lang']
+                    . '.php';
+            $_SESSION['collections'] = array();
+            $_SESSION['coll_categories'] = array();
+            foreach ($xmlconfig->COLLECTION as $col) {
+                $tmp = (string) $col->label;
+                if (!empty($tmp) && defined($tmp) && constant($tmp) <> NULL) {
+                    $tmp = constant($tmp);
+                }
+                $extensions = $col->extensions;
+                $collId = (string) $col->id;
+                $tab = array();
+
+                if ($extensions->count()) {
+                    $extensionTables = $extensions->table;
+                    if ($extensionTables->count() > 0) {
+                        foreach ($extensions->table as $table) {
+                            if (strlen($extensionTables) > 0) {
+                                array_push($tab, (string) $table);
+                            }
+                        }
+                    }
+                }
+                if (isset($col->table) && ! empty($col->table)) {
+                    $_SESSION['collections'][$i] = array(
+                        'id'                   => (string) $col->id,
+                        'label'                => (string) $tmp,
+                        'table'                => (string) $col->table,
+                        'version_table'        => (string) $col->version_table,
+                        'view'                 => (string) $col->view,
+                        'adr'                  => (string) $col->adr,
+                        'index_file'           => (string) $col->index_file,
+                        'script_add'           => (string) $col->script_add,
+                        'script_search'        => (string) $col->script_search,
+                        'script_search_result' => (string) $col->script_search_result,
+                        'script_details'       => (string) $col->script_details,
+                        'path_to_lucene_index' => (string) $col->path_to_lucene_index,
+                        'extensions'           => $tab,
+                    );
+                    
+                    $categories = $col->categories;
+                    
+                    if (count($categories) > 0) {
+                        foreach ($categories->category as $cat) {
+                            $label = (string) $cat->label;
+                            if (!empty($label) && defined($label)
+                                && constant($label) <> NULL
+                             ) {
+                                $label = constant($label);
+                            }
+                            $_SESSION['coll_categories'][$collId][(string) $cat->id] = $label;
+                        }
+                        $_SESSION['coll_categories'][$collId]['default_category'] = (string) $categories->default_category;
+                    }
+                    $i++;
+                } else {
+                    $_SESSION['collections'][$i] = array(
+                        'id'                   => (string) $col->id,
+                        'label'                => (string) $tmp,
+                        'view'                 => (string) $col->view,
+                        'adr'                  => (string) $col->adr,
+                        'index_file'           => (string) $col->index_file,
+                        'script_add'           => (string) $col->script_add,
+                        'script_search'        => (string) $col->script_search,
+                        'script_search_result' => (string) $col->script_search_result,
+                        'script_details'       => (string) $col->script_details,
+                        'path_to_lucene_index' => (string) $col->path_to_lucene_index,
+                        'extensions'           => $tab,
+                    );
+                }
+            }
+            $history = $xmlconfig->HISTORY;
+            $_SESSION['history']['usersdel']        = (string) $history->usersdel;
+            $_SESSION['history']['usersban']        = (string) $history->usersban;
+            $_SESSION['history']['usersadd']        = (string) $history->usersadd;
+            $_SESSION['history']['usersup']         = (string) $history->usersup;
+            $_SESSION['history']['usersval']        = (string) $history->usersval;
+            $_SESSION['history']['doctypesdel']     = (string) $history->doctypesdel;
+            $_SESSION['history']['doctypesadd']     = (string) $history->doctypesadd;
+            $_SESSION['history']['doctypesup']      = (string) $history->doctypesup;
+            $_SESSION['history']['doctypesval']     = (string) $history->doctypesval;
+            $_SESSION['history']['doctypesprop']    = (string) $history->doctypesprop;
+            $_SESSION['history']['usergroupsdel']   = (string) $history->usergroupsdel;
+            $_SESSION['history']['usergroupsban']   = (string) $history->usergroupsban;
+            $_SESSION['history']['usergroupsadd']   = (string) $history->usergroupsadd;
+            $_SESSION['history']['usergroupsup']    = (string) $history->usergroupsup;
+            $_SESSION['history']['usergroupsval']   = (string) $history->usergroupsval;
+            $_SESSION['history']['structuredel']    = (string) $history->structuredel;
+            $_SESSION['history']['structureadd']    = (string) $history->structureadd;
+            $_SESSION['history']['structureup']     = (string) $history->structureup;
+            $_SESSION['history']['subfolderdel']    = (string) $history->subfolderdel;
+            $_SESSION['history']['subfolderadd']    = (string) $history->subfolderadd;
+            $_SESSION['history']['subfolderup']     = (string) $history->subfolderup;
+            $_SESSION['history']['resadd']          = (string) $history->resadd;
+            $_SESSION['history']['resup']           = (string) $history->resup;
+            $_SESSION['history']['resdel']          = (string) $history->resdel;
+            $_SESSION['history']['resview']         = (string) $history->resview;
+            $_SESSION['history']['userlogin']       = (string) $history->userlogin;
+            $_SESSION['history']['userlogout']      = (string) $history->userlogout;
+            $_SESSION['history']['actionadd']       = (string) $history->actionadd;
+            $_SESSION['history']['actionup']        = (string) $history->actionup;
+            $_SESSION['history']['actiondel']       = (string) $history->actiondel;
+            $_SESSION['history']['contactadd']      = (string) $history->contactadd;
+            $_SESSION['history']['contactup']       = (string) $history->contactup;
+            $_SESSION['history']['contactdel']      = (string) $history->contactdel;
+            $_SESSION['history']['statusadd']       = (string) $history->statusadd;
+            $_SESSION['history']['statusup']        = (string) $history->statusup;
+            $_SESSION['history']['statusdel']       = (string) $history->statusdel;
+            $_SESSION['history']['docserversadd']   = (string) $history->docserversadd;
+            $_SESSION['history']['docserversdel']   = (string) $history->docserversdel;
+            $_SESSION['history']['docserversallow'] = (string) $history->docserversallow;
+            $_SESSION['history']['docserversban']   = (string) $history->docserversban;
+            //$_SESSION['history']['docserversclose']        = (string) $history->docserversclose;
+            $_SESSION['history']['docserverslocationsadd']   = (string) $history->docserverslocationsadd;
+            $_SESSION['history']['docserverslocationsdel']   = (string) $history->docserverslocationsdel;
+            $_SESSION['history']['docserverslocationsallow'] = (string) $history->docserverslocationsallow;
+            $_SESSION['history']['docserverslocationsban']   = (string) $history->docserverslocationsban;
+            $_SESSION['history']['docserverstypesadd']       = (string) $history->docserverstypesadd;
+            $_SESSION['history']['docserverstypesdel']       = (string) $history->docserverstypesdel;
+            $_SESSION['history']['docserverstypesallow']     = (string) $history->docserverstypesallow;
+            $_SESSION['history']['docserverstypesban']       = (string) $history->docserverstypesban;
+            $_SESSION['history']['contact_types_del']        = (string) $history->contact_types_del;
+            $_SESSION['history']['contact_types_add']        = (string) $history->contact_types_add;
+            $_SESSION['history']['contact_types_up']         = (string) $history->contact_types_up;
+            $_SESSION['history']['contact_purposes_del']     = (string) $history->contact_purposes_del;
+            $_SESSION['history']['contact_purposes_add']     = (string) $history->contact_purposes_add;
+            $_SESSION['history']['contact_purposes_up']      = (string) $history->contact_purposes_up;
+            $_SESSION['history']['contact_addresses_del']    = (string) $history->contact_addresses_del;
+            $_SESSION['history']['contact_addresses_add']    = (string) $history->contact_addresses_add;
+            $_SESSION['history']['contact_addresses_up']     = (string) $history->contact_addresses_up;
+            $_SESSION['history_keywords'] = array();
+            foreach ($xmlconfig->KEYWORDS as $keyword) {
+                $tmp = (string) $keyword->label;
+                if (!empty($tmp) && defined($tmp) && constant($tmp) <> NULL) {
+                    $tmp = constant($tmp);
+                }
+
+                array_push(
+                    $_SESSION['history_keywords'],
+                    array(
+                        'id'    => (string) $keyword->id,
+                        'label' => $tmp,
+                    )
+                );
+            }
+
+            $i = 0;
+            foreach ($xmlconfig->MODULES as $modules) {
+
+                $_SESSION['modules'][$i] = array(
+                    'moduleid' => (string) $modules->moduleid,
+                    //,"comment" => (string) $MODULES->comment
+                );
+                $i ++;
+            }
+            $businessAppTools->_loadActionsPages();
+        }
+
+        if ($_SESSION['config']['usePHPIDS'] == 'true') {
+            $businessAppTools->_loadPHPIDSExludes();
+        }
+    }
+
+   /**
+    * Load Maarch modules configuration into sessions vars from modules/module_name/xml/config.xml files
+    * @param  array  $modules    Enabled modules of the application
+    * @param  boolean $mode_batch [description]
+    */
+    public static function loadModulesConfig($modules, $mode_batch=false)
+    {
+        require_once "core/class/class_request.php";
+        $coreTools = new core_tools();
+
+        // Browses enabled modules
+        for ($i = 0; $i < count($modules); $i ++) {
+            if (file_exists(
+                $_SESSION['config']['corepath'] . 'custom' . DIRECTORY_SEPARATOR
+                . $_SESSION['custom_override_id'] . DIRECTORY_SEPARATOR
+                . 'modules' . DIRECTORY_SEPARATOR . $modules[$i]['moduleid']
+                . DIRECTORY_SEPARATOR . "xml" . DIRECTORY_SEPARATOR
+                . "config.xml"
+            )
+            ) {
+                $configPath = $_SESSION['config']['corepath'] . 'custom'
+                    . DIRECTORY_SEPARATOR . $_SESSION['custom_override_id']
+                    . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR
+                    . $modules[$i]['moduleid'] . DIRECTORY_SEPARATOR . "xml"
+                    . DIRECTORY_SEPARATOR . "config.xml";
+            } else {
+                $configPath = 'modules' . DIRECTORY_SEPARATOR
+                    . $modules[$i]['moduleid'] . DIRECTORY_SEPARATOR . "xml"
+                    . DIRECTORY_SEPARATOR . "config.xml";
+            }
+
+            if (file_exists('modules'.DIRECTORY_SEPARATOR.$modules[$i]['moduleid'].DIRECTORY_SEPARATOR.'lang'.DIRECTORY_SEPARATOR.$_SESSION['config']['lang'].'.php')) {
+                include_once 'modules'.DIRECTORY_SEPARATOR.$modules[$i]['moduleid'].DIRECTORY_SEPARATOR.'lang'.DIRECTORY_SEPARATOR.$_SESSION['config']['lang'].'.php';
+            }
+
+            // Reads the config.xml file of the current module
+            if ( ! file_exists($configPath) ) {
+                throw new \Exception($configPath.' not-found');
+            }
+
+            $xmlconfig = simplexml_load_file($configPath);
+            // Loads into $_SESSION['modules_loaded'] module's informations
+            foreach ($xmlconfig->CONFIG as $CONFIG) {
+                $_SESSION['modules_loaded'][$modules[$i]['moduleid']]['name'] =
+                    (string) $CONFIG->name;
+                $_SESSION['modules_loaded'][$modules[$i]['moduleid']]['path'] =
+                    'modules' . DIRECTORY_SEPARATOR . $modules[$i]['moduleid']
+                    . DIRECTORY_SEPARATOR;
+                $comment = (string) $CONFIG->comment;
+                if ( !empty($comment) && defined($comment)
+                    && constant($comment) <> NULL
+                ) {
+                    $comment = constant($comment);
+                }
+                $_SESSION['modules_loaded'][$modules[$i]['moduleid']]['comment'] =
+                    $comment;
+
+                $_SESSION['modules_loaded'][$modules[$i]['moduleid']]['fileprefix'] = (string) $CONFIG->fileprefix;
+                $_SESSION['modules_loaded'][$modules[$i]['moduleid']]['loaded'] = (string) $CONFIG->loaded;
+            }
+
+            if (file_exists(
+                $_SESSION['config']['corepath'] . 'custom'
+                    . DIRECTORY_SEPARATOR . $_SESSION['custom_override_id']
+                    . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR
+                    . $modules[$i]['moduleid'] . DIRECTORY_SEPARATOR . "class"
+                    . DIRECTORY_SEPARATOR . "class_modules_tools.php"
+            )
+            ) {
+                $path_module_tools = $_SESSION['config']['corepath'] . 'custom'
+                    . DIRECTORY_SEPARATOR . $_SESSION['custom_override_id']
+                    . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR
+                    . $modules[$i]['moduleid'] . DIRECTORY_SEPARATOR . "class"
+                    . DIRECTORY_SEPARATOR . "class_modules_tools.php";
+            } else {
+                $path_module_tools = 'modules' . DIRECTORY_SEPARATOR
+                    . $modules[$i]['moduleid'] . DIRECTORY_SEPARATOR . "class"
+                    . DIRECTORY_SEPARATOR . "class_modules_tools.php";
+            }
+
+            if (file_exists($path_module_tools)) {
+                require_once($path_module_tools);
+                $modules_tools = new $modules[$i]['moduleid'];
+                //Loads the tables of the module into session
+                $modules_tools->build_modules_tables();
+                //Loads log keywords of the module
+            }
+
+            foreach ($xmlconfig->KEYWORDS as $keyword) {
+                $tmp = (string) $keyword->label;
+                if ( !empty($tmp) && defined($tmp) && constant($tmp) <> NULL ) {
+                    $tmp = constant($tmp);
+                }
+
+                $id = (string) $keyword->id;
+
+                if (!$coreTools->is_var_in_history_keywords_tab($id)) {
+                    array_push(
+                        $_SESSION['history_keywords'],
+                        array(
+                            'id' => $id,
+                            'label' => $tmp
+                        )
+                    );
+                }
+            }
+        }
+
+//        if (!$mode_batch) {
+//            //Loads logs keywords of the actions
+//            $db = new Database();
+//            $stmt = $db->query(
+//                "select id, label_action from "
+//                . $_SESSION['tablename']['actions']
+//                . " where enabled = 'Y' and history = 'Y'"
+//            );
+//            while ($res = $stmt->fetchObject()) {
+//                array_push(
+//                    $_SESSION['history_keywords'],
+//                    array(
+//                        'id' =>'ACTION#' . $res->id,
+//                        'label' => $coreTools->show_string($res->label_action)
+//                    )
+//                );
+//            }
+//        }
+    }
+
+    /**
+     * Loads the modules specific vars into session
+     * @param  array $modules  Enabled modules of the application
+     * @param  [type] $userData [description]
+     */
+    public static function loadVarSession($modules, $userData)
+    {
+        for ($i = 0; $i < count($modules); $i ++) {
+            if (file_exists(
+                $_SESSION['config']['corepath'] . 'custom'
+                    . DIRECTORY_SEPARATOR . $_SESSION['custom_override_id']
+                    . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR
+                    . $modules[$i]['moduleid'] . DIRECTORY_SEPARATOR . "class"
+                    . DIRECTORY_SEPARATOR . "class_modules_tools.php"
+            )
+            ) {
+                $path_module_tools = $_SESSION['config']['corepath'] . 'custom'
+                    . DIRECTORY_SEPARATOR . $_SESSION['custom_override_id']
+                    . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR
+                    . $modules[$i]['moduleid'] . DIRECTORY_SEPARATOR . "class"
+                    . DIRECTORY_SEPARATOR . "class_modules_tools.php";
+            } else {
+                $path_module_tools = 'modules' . DIRECTORY_SEPARATOR
+                    . $modules[$i]['moduleid'] . DIRECTORY_SEPARATOR . "class"
+                    . DIRECTORY_SEPARATOR . "class_modules_tools.php";
+            }
+            if (file_exists($path_module_tools)) {
+                require_once $path_module_tools;
+                $modules_tools = new $modules[$i]['moduleid'];
+                if (method_exists(
+                    $modules[$i]['moduleid'], 'load_module_var_session'
+                )
+                ) {
+                    $modules_tools->load_module_var_session($userData);
+                }
+            }
+            //$coreTools = new core_tools();
+            //$coreTools->show_array($_SESSION['user']['baskets']);
+        }
+    }
+
+    /**
+    * Loads menu items of each module and the application into session from menu.xml files
+    * @param  array $modules Enabled modules of the application
+    * @return [type]          [description]
+    */
+    public static  function loadMenu($modules)
+    {
+        $k = 0;
+        if (file_exists(
+            $_SESSION['config']['corepath'] . 'custom' . DIRECTORY_SEPARATOR
+            . $_SESSION['custom_override_id'] . DIRECTORY_SEPARATOR . 'apps'
+            . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id']
+            . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'menu.xml'
+        )
+        ) {
+            $path = $_SESSION['config']['corepath'] . 'custom'
+                . DIRECTORY_SEPARATOR . $_SESSION['custom_override_id']
+                . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR
+                . $_SESSION['config']['app_id'] . DIRECTORY_SEPARATOR . 'xml'
+                . DIRECTORY_SEPARATOR . 'menu.xml';
+        } else {
+            $path = 'apps' . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id']
+                . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'menu.xml';
+        }
+        // Reads the apps/apps_name/xml/menu.xml file  and loads into session
+        $xmlconfig = simplexml_load_file($path);
+        foreach ($xmlconfig->MENU as $MENU2) {
+            $_SESSION['menu'][$k]['id'] = (string) $MENU2->id;
+            if (isset($_SESSION['menu'][$k]['id'])
+                && isset($_SESSION['user']['services'][$_SESSION['menu'][$k]['id']])
+                && $_SESSION['user']['services'][$_SESSION['menu'][$k]['id']] == true
+            ) { // Menu Identifier must be equal to the Service identifier
+                $libmenu = (string) $MENU2->libconst;
+                if ( !empty($libmenu) && defined($libmenu)
+                    && constant($libmenu) <> NULL
+                ) {
+                    $libmenu  = constant($libmenu);
+                }
+                $_SESSION['menu'][$k]['libconst'] = $libmenu;
+                $_SESSION['menu'][$k]['url'] = $_SESSION['config']['businessappurl']
+                    . (string) $MENU2->url;
+                if (trim((string) $MENU2->target) <> "") {
+                    $tmp = preg_replace(
+                        '/\/core\/$/', '/', $_SESSION['urltocore']
+                    );
+                    $_SESSION['menu'][$k]['url'] = $tmp. (string) $MENU2->url;
+                    $_SESSION['menu'][$k]['target'] = (string) $MENU2->target;
+                }
+                $_SESSION['menu'][$k]['style'] = (string) $MENU2->style;
+                $_SESSION['menu'][$k]['show'] = true;
+            } else {
+                $_SESSION['menu'][$k]['libconst'] ='';
+                $_SESSION['menu'][$k]['url'] ='';
+                $_SESSION['menu'][$k]['style'] = '';
+                $_SESSION['menu'][$k]['show'] = false;
+            }
+            $k ++;
+        }
+        // Browses the enabled modules array
+        for ($i = 0; $i < count($modules); $i ++) {
+            if (file_exists(
+                $_SESSION['config']['corepath'] . 'custom' . DIRECTORY_SEPARATOR
+                . $_SESSION['custom_override_id'] . DIRECTORY_SEPARATOR
+                . 'modules' . DIRECTORY_SEPARATOR . $modules[$i]['moduleid']
+                . DIRECTORY_SEPARATOR . "xml" . DIRECTORY_SEPARATOR . "menu.xml"
+                )
+            ) {
+                $menuPath = $_SESSION['config']['corepath'] . 'custom'
+                    . DIRECTORY_SEPARATOR . $_SESSION['custom_override_id']
+                    . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR
+                    . $modules[$i]['moduleid'] . DIRECTORY_SEPARATOR . "xml"
+                    . DIRECTORY_SEPARATOR . "menu.xml";
+            } else {
+                $menuPath = 'modules' . DIRECTORY_SEPARATOR
+                    . $modules[$i]['moduleid'] . DIRECTORY_SEPARATOR . "xml"
+                    . DIRECTORY_SEPARATOR . "menu.xml";
+            }
+
+            if (file_exists(
+                $_SESSION['config']['corepath'] . 'modules'
+                . DIRECTORY_SEPARATOR . $modules[$i]['moduleid']
+                . DIRECTORY_SEPARATOR . "xml" . DIRECTORY_SEPARATOR . "menu.xml"
+            ) || file_exists(
+                $_SESSION['config']['corepath'] . 'custom' . DIRECTORY_SEPARATOR
+                . $_SESSION['custom_override_id'] . DIRECTORY_SEPARATOR
+                . 'modules' . DIRECTORY_SEPARATOR . $modules[$i]['moduleid']
+                . DIRECTORY_SEPARATOR . "xml" . DIRECTORY_SEPARATOR . "menu.xml"
+            )
+            ) {
+                $xmlconfig = simplexml_load_file($menuPath);
+                foreach ($xmlconfig->MENU as $MENU) {
+                    $_SESSION['menu'][$k]['id'] = (string) $MENU->id;
+                    if (isset(
+                        $_SESSION['user']['services'][$_SESSION['menu'][$k]['id']]
+                    )
+                    && $_SESSION['user']['services'][$_SESSION['menu'][$k]['id']] == true
+                    ) {
+                        $libmenu = (string) $MENU->libconst;
+                        if ( !empty($libmenu) && defined($libmenu)
+                            && constant($libmenu) <> NULL
+                        ) {
+                            $libmenu  = constant($libmenu);
+                        }
+                        $_SESSION['menu'][$k]['libconst'] = $libmenu;
+                        $_SESSION['menu'][$k]['url'] = $_SESSION['config']['businessappurl']
+                            . (string) $MENU->url;
+                        if (trim((string) $MENU->target) <> "") {
+                            $tmp = preg_replace(
+                                '/\/core\/$/', '/', $_SESSION['urltocore']
+                            );
+                            $_SESSION['menu'][$k]['url'] = $tmp
+                                . (string) $MENU->url;
+                            $_SESSION['menu'][$k]['target'] = (string) $MENU->target;
+                        }
+                        $_SESSION['menu'][$k]['style'] = (string) $MENU->style;
+                        $_SESSION['menu'][$k]['show'] = true;
+                    } else {
+                        $_SESSION['menu'][$k]['libconst'] = '';
+                        $_SESSION['menu'][$k]['url'] = '';
+                        $_SESSION['menu'][$k]['style'] = '';
+                        $_SESSION['menu'][$k]['show'] = false;
+                    }
+                    $k ++;
+                }
+            }
+        }
+
+        $coreTools = new core_tools();
+        $coreTools->load_quicklaunch($modules);
+    }
+
+    /**
+    * Loads application services into session
+    */
+    public static  function loadAppServices()
+    {
+        // Reads the application config.xml file
+        if (file_exists(
+            $_SESSION['config']['corepath'] . 'custom' . DIRECTORY_SEPARATOR
+            . $_SESSION['custom_override_id'] . DIRECTORY_SEPARATOR . 'apps'
+            . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id']
+            . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'services.xml'
+        )
+        ) {
+            $path = $_SESSION['config']['corepath'] . 'custom'
+                . DIRECTORY_SEPARATOR . $_SESSION['custom_override_id']
+                . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR
+                . $_SESSION['config']['app_id'] . DIRECTORY_SEPARATOR . 'xml'
+                . DIRECTORY_SEPARATOR . 'services.xml';
+        } else {
+            $path = 'apps' . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id']
+                . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR
+                . 'services.xml';
+        }
+        $xmlconfig = simplexml_load_file($path);
+        $k = 0;
+        $m = 0;
+        include_once 'apps/' .$_SESSION['config']['app_id']. '/lang/' . $_SESSION['config']['lang'].'.php' ;
+        // Browses the services in that file and loads $_SESSION['app_services']
+        foreach ($xmlconfig->SERVICE as $service) {
+            $_SESSION['app_services'][$k] = array();
+            $_SESSION['app_services'][$k]['id'] = (string) $service->id;
+            $name = (string) $service->name;
+            if ( !empty($name) && defined($name) && constant($name) <> NULL ) {
+                $name  = constant($name);
+            }
+            $_SESSION['app_services'][$k]['name'] = $name;
+            $comment = (string) $service->comment;
+            if ( !empty($comment) && defined($comment)
+                && constant($comment) <> NULL
+            ) {
+                $comment  = constant($comment);
+            }
+            $_SESSION['app_services'][$k]['comment'] = $comment;
+            if (isset($service->servicepage)) {
+                $_SESSION['app_services'][$k]['servicepage'] = (string) $service->servicepage;
+                $_SESSION['app_services'][$k]['servicepage'] = preg_replace(
+                    '/&admin/', '&amp;admin',
+                    $_SESSION['app_services'][$k]['servicepage']
+                );
+                $_SESSION['app_services'][$k]['servicepage'] = preg_replace(
+                    '/&module/', '&amp;module',
+                    $_SESSION['app_services'][$k]['servicepage']
+                );
+            }
+            $_SESSION['app_services'][$k]['servicetype'] = (string) $service->servicetype;
+
+            if (isset($service->style)) {
+                $_SESSION['app_services'][$k]['style'] = (string) $service->style;
+            }
+
+            $systemService = (string) $service->system_service;
+            if ($systemService == "false") {
+                $_SESSION['app_services'][$k]['system_service'] = false;
+            } else {
+                $_SESSION['app_services'][$k]['system_service'] = true;
+            }
+            $_SESSION['app_services'][$k]['enabled'] = (string) $service->enabled;
+            $l = 0;
+            foreach ($service->WHEREAMIUSED as $whereAmIUsed) {
+                if (isset($whereAmIUsed)) {
+                    $_SESSION['app_services'][$k]['whereamiused'][$l]['page'] = (string) $whereAmIUsed->page;
+                    $_SESSION['app_services'][$k]['whereamiused'][$l]['nature'] = (string) $whereAmIUsed->nature;
+                    if (isset($whereAmIUsed->button_label)) {
+                        $_SESSION['app_services'][$k]['whereamiused'][$l]['button_label'] = (string) $whereAmIUsed->button_label;
+                    }
+                    if (isset($whereAmIUsed->tab_label)) {
+                        $label = (string) $whereAmIUsed->tab_label;
+                        if ( !empty($label) && defined($label)
+                            && constant($label) <> NULL
+                        ) {
+                            $label  = constant($label);
+                        }
+                        $_SESSION['app_services'][$k]['whereamiused'][$l]['tab_label'] = $label;
+                    }
+                    if (isset($whereAmIUsed->tab_order)) {
+                        $_SESSION['app_services'][$k]['whereamiused'][$l]['tab_order'] = (string) $whereAmIUsed->tab_order;
+                    }
+                    if (isset($whereAmIUsed->width)) {
+                        $_SESSION['app_services'][$k]['whereamiused'][$l]['width'] = (string) $whereAmIUsed->width;
+                    }
+                    if (isset($whereAmIUsed->frame_id)) {
+                        $_SESSION['app_services'][$k]['whereamiused'][$l]['frame_id'] = (string) $whereAmIUsed->frame_id;
+                    }
+                    if (isset($whereAmIUsed->height)) {
+                        $_SESSION['app_services'][$k]['whereamiused'][$l]['height'] = (string) $whereAmIUsed->height;
+                    }
+                    if (isset($whereAmIUsed->scrolling)){
+                        $_SESSION['app_services'][$k]['whereamiused'][$l]['scrolling'] = (string) $whereAmIUsed->scrolling;
+                    }
+                    if (isset($whereAmIUsed->style)) {
+                        $_SESSION['app_services'][$k]['whereamiused'][$l]['style'] = (string) $whereAmIUsed->style;
+                    }
+                    if (isset($whereAmIUsed->border)) {
+                        $_SESSION['app_services'][$k]['whereamiused'][$l]['border'] = (string) $whereAmIUsed->border;
+                    }
+                    $l ++;
+                }
+            }
+            $m = 0;
+            // Loads preprocess and postprocess
+            foreach ($service->PROCESSINBACKGROUND as $processInBackground) {
+                $_SESSION['app_services'][$k]['processinbackground'][$m]['page'] = (string) $processInBackground->page;
+                if ((string) $processInBackground->preprocess <> "") {
+                    $_SESSION['app_services'][$k]['processinbackground'][$m]['preprocess'] = (string) $processInBackground->preprocess;
+                }
+                if ((string) $processInBackground->postprocess <> "") {
+                    $_SESSION['app_services'][$k]['processinbackground'][$m]['postprocess'] = (string) $processInBackground->postprocess;
+                }
+                $_SESSION['app_services'][$k]['processinbackground'][$m]['processorder'] = (string) $processInBackground->processorder;
+                $m++;
+            }
+            $k ++;
+        }
+    }
+
+    /**
+    * Loads the services of each module into session
+    *
+    * @param array $modules Enabled modules of the application
+    */
+    public static  function loadModulesServices($modules)
+    {
+        // Browses the enabled modules array
+        for ($i = 0; $i < count($modules); $i ++) {
+            // Reads the module config.xml file
+            if (file_exists(
+                $_SESSION['config']['corepath'] . 'custom' . DIRECTORY_SEPARATOR
+                . $_SESSION['custom_override_id'] . DIRECTORY_SEPARATOR
+                . 'modules' . DIRECTORY_SEPARATOR . $modules[$i]['moduleid']
+                . DIRECTORY_SEPARATOR . "xml" . DIRECTORY_SEPARATOR
+                . "services.xml"
+            )
+            ) {
+                $path = $_SESSION['config']['corepath'] . 'custom'
+                    . DIRECTORY_SEPARATOR  . $_SESSION['custom_override_id']
+                    . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR
+                    . $modules[$i]['moduleid'] . DIRECTORY_SEPARATOR . "xml"
+                    . DIRECTORY_SEPARATOR . "services.xml";
+            } else {
+                $path = 'modules' . DIRECTORY_SEPARATOR
+                    . $modules[$i]['moduleid'] . DIRECTORY_SEPARATOR . "xml"
+                    . DIRECTORY_SEPARATOR . "services.xml";
+            }
+            $xmlconfig = simplexml_load_file($path);
+            $k = 0;
+            $m = 0;
+            foreach ($xmlconfig->SERVICE as $service) {
+                if ((string) $service->enabled == "true") {
+                    $_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['id'] = (string) $service->id;
+                    $name = (string) $service->name;
+                    if ( !empty($name) && defined($name)
+                        && constant($name) <> NULL
+                    ) {
+                        $name  = constant($name);
+                    }
+                    $_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['name'] =
+                        $name;
+
+                    $comment = (string) $service->comment;
+                    if ( !empty($comment) && defined($comment)
+                        && constant($comment) <> NULL
+                    ) {
+                        $comment  = constant($comment);
+                    }
+                    $_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['comment'] =
+                        $comment;
+
+                    if (isset($service->servicepage)) {
+                        $_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['servicepage'] = (string) $service->servicepage;
+                    }
+                    $_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['servicetype'] = (string) $service->servicetype;
+
+                    if (isset($service->style)) {
+                        $_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['style'] = (string) $service->style;
+                    }
+                    $systemService =  (string) $service->system_service;
+                    if ($systemService == "false") {
+                        $_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['system_service'] = false;
+                    } else {
+                        $_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['system_service'] = true;
+                    }
+                    $_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['enabled'] = (string) $service->enabled;
+
+                    $l = 0;
+                    foreach ($service->WHEREAMIUSED as $whereAmIUsed) {
+                        $_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['whereamiused'][$l]['page'] = (string) $whereAmIUsed->page;
+                        $_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['whereamiused'][$l]['nature'] = (string) $whereAmIUsed->nature;
+                        if (isset($whereAmIUsed->button_label)) {
+                            $label = (string) $whereAmIUsed->button_label;
+                            if ( !empty($label) && defined($label)
+                                && constant($label) <> NULL
+                            ) {
+                                $label  = constant($label);
+                            }
+                            $_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['whereamiused'][$l]['button_label'] =
+                                $label;
+                        }
+                        if (isset($whereAmIUsed->tab_label)) {
+                            $label = (string) $whereAmIUsed->tab_label;
+                            if ( !empty($label) && defined($label)
+                                && constant($label) <> NULL
+                            ) {
+                                $label  = constant($label);
+                            }
+                            $_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['whereamiused'][$l]['tab_label'] =
+                                $label;
+                        }
+                        if (isset($whereAmIUsed->tab_order)) {
+                            $_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['whereamiused'][$l]['tab_order'] = (string) $whereAmIUsed->tab_order;
+                        }
+                        if (isset($whereAmIUsed->frame_id)) {
+                            $_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['whereamiused'][$l]['frame_id'] = (string) $whereAmIUsed->frame_id;
+                        }
+                        if (isset($whereAmIUsed->width)) {
+                            $_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['whereamiused'][$l]['width'] = (string) $whereAmIUsed->width;
+                        }
+                        if (isset($whereAmIUsed->height)) {
+                            $_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['whereamiused'][$l]['height'] = (string) $whereAmIUsed->height;
+                        }
+                        if (isset($whereAmIUsed->scrolling)) {
+                            $_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['whereamiused'][$l]['scrolling'] = (string) $whereAmIUsed->scrolling;
+                        }
+                        if (isset($whereAmIUsed->style)) {
+                            $_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['whereamiused'][$l]['style'] = (string) $whereAmIUsed->style;
+                        }
+                        if (isset($whereAmIUsed->border)) {
+                            $_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['whereamiused'][$l]['border'] = (string) $whereAmIUsed->border;
+                        }
+                        $l ++;
+                    }
+                    $m = 0;
+                    foreach ($service->PROCESSINBACKGROUND as $processInBackground) {
+                        $_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['processinbackground'][$m]['page'] = (string) $processInBackground->page;
+                        if ((string) $processInBackground->preprocess <> "") {
+                            $_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['processinbackground'][$m]['preprocess'] = (string) $processInBackground->preprocess;
+                        }
+                        if ((string) $processInBackground->postprocess <> "") {
+                            $_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['processinbackground'][$m]['postprocess'] = (string) $processInBackground->postprocess;
+                        }
+                        $_SESSION['modules_services'][$modules[$i]['moduleid']][$k]['processinbackground'][$m]['processorder'] = (string) $processInBackground->processorder;
+                        $m ++;
+                    }
+                    $k ++;
+                }
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/core/services/Logs.php b/core/services/Logs.php
new file mode 100644
index 0000000000000000000000000000000000000000..1866155df0c58cb11eb0b5b298ebf8e60185d417
--- /dev/null
+++ b/core/services/Logs.php
@@ -0,0 +1,26 @@
+<?php
+
+/**
+*   @copyright 2016 capgemini
+*
+*   This file is part of Maarch Framework.
+*
+*   Maarch Framework is free software: you can redistribute it and/or modify
+*   it under the terms of the GNU General Public License as published by
+*   the Free Software Foundation, either version 3 of the License, or
+*   (at your option) any later version.
+*
+*   Maarch Framework is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details.
+*
+*   You should have received a copy of the GNU General Public License
+*   along with Maarch Framework.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+require_once 'core'. DIRECTORY_SEPARATOR . 'services'. DIRECTORY_SEPARATOR . 'LogsAbstract.php';
+
+class Core_Logs_Service extends Core_LogsAbstract_Service {
+	// Do your stuff
+}
diff --git a/core/services/LogsAbstract.php b/core/services/LogsAbstract.php
new file mode 100644
index 0000000000000000000000000000000000000000..1468c7de5e0595654ddc68577fa7a496475a6692
--- /dev/null
+++ b/core/services/LogsAbstract.php
@@ -0,0 +1,331 @@
+<?php
+
+/**
+*   @copyright 2017 Maarch
+*
+*   This file is part of Maarch Framework.
+*
+*   Maarch Framework is free software: you can redistribute it and/or modify
+*   it under the terms of the GNU General Public License as published by
+*   the Free Software Foundation, either version 3 of the License, or
+*   (at your option) any later version.
+*
+*   Maarch Framework is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details.
+*
+*   You should have received a copy of the GNU General Public License
+*   along with Maarch Framework.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+require_once 'core'. DIRECTORY_SEPARATOR . 'services'. DIRECTORY_SEPARATOR . 'Abstract.php';
+require_once 'core'. DIRECTORY_SEPARATOR . 'services'. DIRECTORY_SEPARATOR . 'String.php';
+if (!defined('_LOG4PHP'))
+    define(
+        '_LOG4PHP',
+        'log4php'
+    );
+
+if (!defined('_BDD'))
+    define(
+        '_BDD',
+        'database'
+    );
+
+if (!defined('_LOGGER_NAME_TECH_DEFAULT'))
+    define(
+        '_LOGGER_NAME_TECH_DEFAULT',
+        'loggerTechnique'
+    );
+
+if (!defined('_LOGGER_NAME_FUNC_DEFAULT'))
+    define(
+        '_LOGGER_NAME_FUNC_DEFAULT',
+        'loggerFonctionnel'
+    );
+require_once 'apps'. DIRECTORY_SEPARATOR . 'maarch_entreprise'. DIRECTORY_SEPARATOR . 'tools'. DIRECTORY_SEPARATOR . 'log4php'. DIRECTORY_SEPARATOR . 'Logger.php';
+
+class Core_LogsAbstract_Service extends Core_Abstract_Service {
+
+    protected static function getLoggingMethodConfFile()
+    {
+        $xmlFileName = 'logging_method.xml';
+        if (file_exists($sLoggingMethodConfFile = 'custom'
+            .DIRECTORY_SEPARATOR.$_SESSION['custom_override_id']
+            .DIRECTORY_SEPARATOR . 'apps'
+            .DIRECTORY_SEPARATOR.$_SESSION['config']['app_id']
+            .DIRECTORY_SEPARATOR.'xml'
+            .DIRECTORY_SEPARATOR.$xmlFileName
+        )) {
+            return $sLoggingMethodConfFile;
+        }
+        if (file_exists($sLoggingMethodConfFile =
+            'apps'
+            .DIRECTORY_SEPARATOR.$_SESSION['config']['app_id']
+            .DIRECTORY_SEPARATOR.'xml'
+            .DIRECTORY_SEPARATOR.$xmlFileName
+        )) {
+            return $sLoggingMethodConfFile;
+        }
+        return null;
+    }
+    public static function getLoggingFormat(array $aArgs = []) {
+    	self::checkRequired($aArgs,['key']);
+    	self::checkNumeric($aArgs,['key']);
+    	$logging_methods = self::getLoggingMethod($aArgs);
+    	return empty($logging_methods[$aArgs['key']]['LOG_FORMAT']) ? '[%RESULT%][%CODE_METIER%][%WHERE%][%ID%][%HOW%][%USER%][%WHAT%][%ID_MODULE%][%REMOTE_IP%]' : $logging_methods[$aArgs['key']]['LOG_FORMAT'];
+    }
+    public static function getLoggingCodeMetier(array $aArgs = []) {
+    	self::checkRequired($aArgs,['key']);
+    	self::checkNumeric($aArgs,['key']);
+    	$logging_methods = self::getLoggingFormat($aArgs);
+    	return empty($logging_methods[$aArgs['key']]['CODE_METIER']) ? '[%RESULT%][%CODE_METIER%][%WHERE%][%ID%][%HOW%][%USER%][%WHAT%][%ID_MODULE%][%REMOTE_IP%]' : $logging_methods[$aArgs['key']]['CODE_METIER'];
+    }
+    /**
+    * Get the logging method in the configuration file
+    */
+    protected static function getLoggingMethod(array $aArgs = []) {
+        $sLoggingMethodConfFile = self::getLoggingMethodConfFile();
+
+        $logging_methods = [];
+    	if ( ! $sLoggingMethodConfFile = self::getLoggingMethodConfFile() ) {
+            $logging_methods[0]['ID']               = 'database';
+            $logging_methods[0]['ACTIVATED']        = true;
+            $logging_methods[1]['ID']               = 'log4php';
+            $logging_methods[1]['ACTIVATED']        = true;
+            $logging_methods[1]['LOGGER_NAME_TECH'] = 'loggerTechnique';
+            $logging_methods[1]['LOGGER_NAME_FUNC'] = 'loggerFonctionnel';
+            $logging_methods[1]['LOG_FORMAT']       = '[%RESULT%][%CODE_METIER%][%WHERE%][%ID%][%HOW%][%USER%][%WHAT%][%ID_MODULE%][%REMOTE_IP%]';
+            $logging_methods[1]['CODE_METIER']      = 'MAARCH';
+            return $logging_methods;
+        }
+
+        if (! file_exists($sLoggingMethodConfFile) ) {
+            throw new \Exception('not file_exists : '.$sLoggingMethodConfFile);
+        }
+        $xmlConfig = @simplexml_load_file($sLoggingMethodConfFile);
+        if (! $xmlConfig) {
+            throw new \Exception('simplexml_load_file failed : '.$sLoggingMethodConfFile);
+        }
+        if (! $xmlConfig->METHOD) {
+            throw new \Exception('no data METHOD found : '.$sLoggingMethodConfFile);
+        }
+
+        foreach ($xmlConfig->METHOD as $METHOD) {
+            $id = ((string)$METHOD->ID);
+            $activated = ((boolean)$METHOD->ENABLED);
+            $loggerNameTech = ((string)$METHOD->LOGGER_NAME_TECH);
+            $loggerNameFunc = ((string)$METHOD->LOGGER_NAME_FUNC);
+            $logFormat = ((string)$METHOD->APPLI_LOG_FORMAT);
+            $codeMetier = ((string)$METHOD->CODE_METIER);
+
+            array_push(
+                $logging_methods,
+                array(
+                    'ID'         => $id,
+                    'ACTIVATED'  => $activated,
+                    'LOGGER_NAME_TECH' => $loggerNameTech,
+                    'LOGGER_NAME_FUNC' => $loggerNameFunc,
+                    'LOG_FORMAT'    => $logFormat,
+                    'CODE_METIER'   => $codeMetier
+                )
+            );
+        }
+
+        return $logging_methods;
+    }
+
+	protected static function getConfFile(array $aArgs = []) {
+		if ( empty($_SESSION['config']['app_id']) ) {
+			$_SESSION['config']['app_id'] = 'maarch_entreprise';
+		}
+        if (
+        	!empty($_SESSION['config']['corepath']) && !empty($_SESSION['custom_override_id'])
+        	&& file_exists($configFileLog4PHP =
+            $_SESSION['config']['corepath']. DIRECTORY_SEPARATOR . 'custom'
+            . DIRECTORY_SEPARATOR . $_SESSION['custom_override_id']
+            . DIRECTORY_SEPARATOR . 'apps'
+            . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id']
+            . DIRECTORY_SEPARATOR . 'xml'
+            . DIRECTORY_SEPARATOR . 'log4php.xml'
+        )) {
+            return $configFileLog4PHP;
+        }
+        if (file_exists($configFileLog4PHP =
+            'apps'
+            . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id']
+            . DIRECTORY_SEPARATOR . 'xml'
+            . DIRECTORY_SEPARATOR . 'log4php.xml'
+        )) {
+            return $configFileLog4PHP;
+        }
+        return 'apps'
+            . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id']
+            . DIRECTORY_SEPARATOR . 'xml'
+            . DIRECTORY_SEPARATOR . 'log4php.default.xml';
+	}
+
+	protected static function format_message(array &$aArgs) {
+		$aArgs['message'] = @$aArgs['message'];
+		switch (true) {
+			case is_object($aArgs['message']):
+                if ( $aArgs['message'] instanceof \Exception ) {
+                    $e = $aArgs['message'];
+                    $aArgs['code'] = $e->getCode();
+                    $aArgs['message'] = 'Exception: '.$e->getMessage();
+                    $aArgs['debug'] = $e->getTraceAsString();
+                    break;
+                }
+				$aArgs['message'] = '--object--';
+				break;
+			case is_array($aArgs['message']):
+				$aArgs['message'] = '--array--';
+				break;
+			default:
+				$aArgs['message'] = (string)$aArgs['message'];
+				break;
+		}
+		$aArgs['message'] = str_replace("\n", '\n', $aArgs['message']);
+
+		// Old method :
+        $formatter = new functions();
+        $aArgs['message'] = $formatter->wash_html(
+            $aArgs['message'],
+            ''
+        );
+        $aArgs['message'] = Core_String_Service::wd_remove_accents($aArgs['message']);
+
+        if(!empty($_SESSION['user']['UserId'])){
+            $aArgs['message'] = '[' . $_SESSION['user']['UserId'] . '] ' . $aArgs['message'];
+        }
+
+		return $aArgs;
+	}
+	protected static function logs(array $aArgs = []) {
+		// Initialisation du Logger :
+		Logger::configure(
+            self::getConfFile()
+        );
+        if ( @$aArgs['class'] ) {
+            Logger::getLogger($aArgs['class']);
+        }
+        $aLoggingMethods = self::getLoggingMethod();
+
+        $aArgs = self::format_message($aArgs);
+            if ( @$aArgs['class'] ) {
+                $sLog .= "[class:{$aArgs['class']}]";
+                Logger::getLogger($aArgs['class']);
+            }
+
+        foreach ($aLoggingMethods as $logging_method) {
+            if ( ! $logging_method['ACTIVATED'] ) {
+                continue;
+            }
+
+            if (isset($aArgs['isTech']) && $aArgs['isTech']) {
+                $logger = Logger::getLogger(
+                    $logging_method['LOGGER_NAME_TECH']
+                );
+            } else {
+                if(!isset($logging_method['LOGGER_NAME_FUNC'])){
+                    $logging_method['LOGGER_NAME_FUNC'] = 'loggerFonctionnel';
+                }
+                $logger = Logger::getLogger(
+                    $logging_method['LOGGER_NAME_FUNC']
+                );
+            }
+            if ( empty($logger) ) {
+            	throw new \Exception('logger not-loading', 1);
+            }
+            // Format :
+    		$sLog = '';
+    		if ( @$aArgs['file'] ) {
+    			$sLog .= "[file:{$aArgs['file']}]";
+    		}
+    		if ( @$aArgs['class'] ) {
+    			$sLog .= "[class:{$aArgs['class']}]";
+    		}
+    		if ( @$aArgs['function'] ) {
+    			$sLog .= "[function:{$aArgs['function']}]";
+    		}
+    		if ( @$aArgs['code'] ) {
+    			$aArgs['code'] = (int)$aArgs['code'];
+    			$sLog .= "[code:{$aArgs['code']}]";
+    		}
+
+            if(!isset($logging_method['CODE_METIER'])){
+                $logging_method['CODE_METIER'] = 'SIPol';
+            }
+            $sLog = str_replace('%CODE_METIER%', $logging_method['CODE_METIER'], "{$sLog}{$aArgs['message']}");
+
+            // Log :
+            switch ($aArgs['type']) {
+            	case 'debug':
+                case _LEVEL_DEBUG:
+                    $logger->debug($sLog);
+                    break;
+
+            	case 'info':
+                case _LEVEL_INFO:
+                    $logger->info($sLog);
+                    break;
+
+            	case 'warning':
+                case _LEVEL_WARN:
+                    $logger->warn($sLog);
+                    break;
+
+            	case 'error':
+                case _LEVEL_ERROR:
+                    $logger->error($sLog);
+                    break;
+
+                case _LEVEL_FATAL:
+                    $logger->fatal($sLog);
+                    break;
+
+                default:
+                    $logger->error($sLog);
+            }
+        }
+		return true;
+	}
+	public static function debug(array $aArgs = []) {
+		$aArgs['type'] = 'debug';
+		return self::logs($aArgs);
+	}
+	public static function info(array $aArgs = []) {
+		$aArgs['type'] = 'info';
+		return self::logs($aArgs);
+	}
+	public static function warning(array $aArgs = []) {
+		$aArgs['type'] = 'warning';
+		return self::logs($aArgs);
+	}
+    public static function error(array $aArgs = []) {
+        $aArgs['type'] = 'error';
+        return self::logs($aArgs);
+    }
+    public static function fatal(array $aArgs = []) {
+        $aArgs['type'] = _LEVEL_FATAL;
+        return self::logs($aArgs);
+    }
+
+    /*
+    timestart : timestamp Debut
+    timeend : timestamp Fin
+    level : level log4php
+    message : message dans les logs
+    */
+    public static function executionTimeLog($timestart, $timeend, $level, $message){
+        if(empty($timeend)){
+            $timeend = microtime(true);
+        }
+        $time = $timeend - $timestart;
+
+        self::$level(['message' => $message.'. Done in ' . number_format($time, 3) . ' secondes.']);
+
+    }
+}
+
diff --git a/core/services/MaarchException.php b/core/services/MaarchException.php
new file mode 100644
index 0000000000000000000000000000000000000000..04f2e57fd2ace818b9dbb4a06841fd0f1d6d44ea
--- /dev/null
+++ b/core/services/MaarchException.php
@@ -0,0 +1,25 @@
+<?php
+
+/**
+*   @copyright 2016 capgemini
+*
+*   This file is part of Maarch Framework.
+*
+*   Maarch Framework is free software: you can redistribute it and/or modify
+*   it under the terms of the GNU General Public License as published by
+*   the Free Software Foundation, either version 3 of the License, or
+*   (at your option) any later version.
+*
+*   Maarch Framework is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details.
+*
+*   You should have received a copy of the GNU General Public License
+*   along with Maarch Framework.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+require_once 'core/services/MaarchExceptionAbstract.php';
+
+class Core_MaarchException_Service extends Core_MaarchExceptionAbstract_Service{
+}
diff --git a/core/services/MaarchExceptionAbstract.php b/core/services/MaarchExceptionAbstract.php
new file mode 100644
index 0000000000000000000000000000000000000000..c030fa1c93a84d1a66ff699e71d6f146fbc68e8b
--- /dev/null
+++ b/core/services/MaarchExceptionAbstract.php
@@ -0,0 +1,38 @@
+<?php
+
+/**
+*   @copyright 2016 capgemini
+*
+*   This file is part of Maarch Framework.
+*
+*   Maarch Framework is free software: you can redistribute it and/or modify
+*   it under the terms of the GNU General Public License as published by
+*   the Free Software Foundation, either version 3 of the License, or
+*   (at your option) any later version.
+*
+*   Maarch Framework is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details.
+*
+*   You should have received a copy of the GNU General Public License
+*   along with Maarch Framework.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * Service de gestion des données en session
+ */
+class Core_MaarchExceptionAbstract_Service extends Exception {
+
+    // Redéfinissez l'exception ainsi le message n'est pas facultatif
+    public function __construct($message, $code = 0, Exception $previous = null) {
+
+        // assurez-vous que tout a été assigné proprement
+        parent::__construct($message, $code, $previous);
+    }
+
+    // chaîne personnalisée représentant l'objet
+    public function __toString() {
+        return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
+    }
+}
diff --git a/core/services/Modules.php b/core/services/Modules.php
new file mode 100644
index 0000000000000000000000000000000000000000..b4129d12de0b9d21ecb01649132a11dbda530dcd
--- /dev/null
+++ b/core/services/Modules.php
@@ -0,0 +1,26 @@
+<?php
+
+/**
+*   @copyright 2016 capgemini
+*
+*   This file is part of Maarch Framework.
+*
+*   Maarch Framework is free software: you can redistribute it and/or modify
+*   it under the terms of the GNU General Public License as published by
+*   the Free Software Foundation, either version 3 of the License, or
+*   (at your option) any later version.
+*
+*   Maarch Framework is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details.
+*
+*   You should have received a copy of the GNU General Public License
+*   along with Maarch Framework.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+require_once 'core/services/ModulesAbstract.php';
+
+class Core_Modules_Service extends Core_ModulesAbstract_Service {
+	// Do your stuff
+}
\ No newline at end of file
diff --git a/core/services/ModulesAbstract.php b/core/services/ModulesAbstract.php
new file mode 100644
index 0000000000000000000000000000000000000000..5343ea8f4a58163bb92cf7dafd3f247eb0be441b
--- /dev/null
+++ b/core/services/ModulesAbstract.php
@@ -0,0 +1,133 @@
+<?php
+
+/**
+*   @copyright 2017 Maarch
+*
+*   This file is part of Maarch Framework.
+*
+*   Maarch Framework is free software: you can redistribute it and/or modify
+*   it under the terms of the GNU General Public License as published by
+*   the Free Software Foundation, either version 3 of the License, or
+*   (at your option) any later version.
+*
+*   Maarch Framework is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details.
+*
+*   You should have received a copy of the GNU General Public License
+*   along with Maarch Framework.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+require_once 'core/services/Abstract.php';
+
+class Core_ModulesAbstract_Service extends Core_Abstract_Service {
+	public static function getApiMethod() {
+		$aMethod = parent::getApiMethod();
+		$aMethod['getList'] = 'getList';
+		return $aMethod;
+	}
+	/**
+	 * Renvoie la liste des modules
+	 * @throw \Exception $e
+	 * @param array $args
+	 * @return array $aModules
+	 **/
+	public static function getList(array $args = []) {
+		if ( ! file_exists('modules') ) {
+			throw new \Exception('path modules not-found');
+		}
+		$aDir = scandir('modules');
+		$aModules = [];
+		foreach ($aDir as $dir) {
+			if ( '.'==$dir[0]) continue;
+			if ( !is_dir("modules/$dir") ) continue;
+			$aModules[$dir] = $dir;
+		}
+		return $aModules;
+	}
+	/**
+	 * Renvoie la liste des services
+	 * @param array $args
+	 * 	- require : inclue directement la definition du service si ce n'ai pas fait
+	 * @return array $aModules
+	 **/
+	public static function getServicesList(array $args = []) {
+		// Initialisation :
+		$aServices = [];
+		$aServices['apps'] = [];
+		// Recherche dans Apps :
+		foreach ([
+			$_SESSION['config']['corepath'].'custom'.DIRECTORY_SEPARATOR.$_SESSION['custom_override_id']."/apps/maarch_entreprise/services",
+			"apps/maarch_entreprise/services",
+			] as $sPathModuleService) {
+			if ( is_dir($sPathModuleService) ) {
+				$aDir = scandir($sPathModuleService);
+				foreach ($aDir as $dir) {
+					if ( '.'==$dir[0]) continue;
+					if ( preg_match('/svn-commit/', $dir) ) continue;
+					if ( !is_file("$sPathModuleService/$dir") ) continue;
+					$sService = preg_replace('/\.php$/', '', $dir);
+					$sService = 'Apps_'.ucfirst($sService).'_Service';
+					if ( !empty($aServices['apps'][$sService]) ) continue; // Déjà fait
+					if ( !class_exists($sService) && !empty($args['require']) ) require_once "$sPathModuleService/$dir";
+					$aServices['apps'][$sService] = $sService;
+				}
+			}
+		}
+		if ( empty($aServices['apps']) ) {
+			unset($aServices['apps']);
+		}
+		// Recherche dans Core :
+		$aServices['core'] = [];
+		foreach ([
+			$_SESSION['config']['corepath'].'custom'.DIRECTORY_SEPARATOR.$_SESSION['custom_override_id']."/core/services",
+			"core/services",
+			] as $sPathModuleService) {
+			if ( is_dir($sPathModuleService) ) {
+				$aDir = scandir($sPathModuleService);
+				foreach ($aDir as $dir) {
+					if ( '.'==$dir[0]) continue;
+					if ( preg_match('/svn-commit/', $dir) ) continue;
+					if ( !is_file("$sPathModuleService/$dir") ) continue;
+					$sService = preg_replace('/\.php$/', '', $dir);
+					$sService = 'Core_'.ucfirst($sService).'_Service';
+					if ( !empty($aServices['core'][$sService]) ) continue; // Déjà fait
+					if ( !class_exists($sService) && !empty($args['require']) ) require_once "$sPathModuleService/$dir";
+					$aServices['core'][$sService] = $sService;
+				}
+			}
+		}
+		if ( empty($aServices['core']) ) {
+			unset($aServices['core']);
+		}
+		// Recherche dans tous les modules :
+		$aModules = self::getList();
+		foreach ($aModules as $sModule) {
+			// Recherche dans maarch + custom :
+			foreach ([
+				$_SESSION['config']['corepath'].'custom'.DIRECTORY_SEPARATOR.$_SESSION['custom_override_id']."/modules/{$sModule}/services",
+				"modules/{$sModule}/services",
+				] as $sPathModuleService) {
+				if ( is_dir($sPathModuleService) ) {
+					$aDir = scandir($sPathModuleService);
+					foreach ($aDir as $dir) {
+						if ( '.'==$dir[0]) continue;
+						if ( preg_match('/svn-commit/', $dir) ) continue;
+						if ( !is_file("$sPathModuleService/$dir") ) continue;
+						$sService = preg_replace('/\.php$/', '', $dir);
+						$sService = ucfirst($sModule).'_'.ucfirst($sService).'_Service';
+						if ( !empty($aServices[$sModule][$sService]) ) continue; // Déjà fait
+						if ( !class_exists($sService) && !empty($args['require']) ) require_once "$sPathModuleService/$dir";
+						$aServices[$sModule][$sService] = $sService;
+					}
+				}
+			}
+			if ( empty($aServices[$sModule]) ) {
+				unset($aServices[$sModule]);
+			}
+		}
+		// Retour :
+		return $aServices;
+	}
+}
\ No newline at end of file
diff --git a/core/services/Rest.php b/core/services/Rest.php
new file mode 100644
index 0000000000000000000000000000000000000000..44041a5a5b7bdd67d1997d44a0d71a4b3445e0a0
--- /dev/null
+++ b/core/services/Rest.php
@@ -0,0 +1,125 @@
+<?php
+
+/**
+*   @copyright 2017 Maarch
+*
+*   This file is part of Maarch Framework.
+*
+*   Maarch Framework is free software: you can redistribute it and/or modify
+*   it under the terms of the GNU General Public License as published by
+*   the Free Software Foundation, either version 3 of the License, or
+*   (at your option) any later version.
+*
+*   Maarch Framework is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details.
+*
+*   You should have received a copy of the GNU General Public License
+*   along with Maarch Framework.  If not, see <http://www.gnu.org/licenses/>.
+*/
+require_once 'core/services/Logs.php';
+
+/**
+ * Service des gestion des appels rest
+ */
+class Core_Rest_Service {
+	/**
+	 * Constructeur
+	 */
+	public function __construct() {
+	}
+
+	/**
+	 * Encodage en json
+	 * @param  array $json Liste d'arguments
+	 *	- string status [description]
+	 *	- string result [description]
+	 *	- string errors [description]
+	 *	- string debug [description]
+	 */
+	public function json(array $json) {
+		header('Content-Type: application/json');
+		if ( !isset($json['status']) ) {
+			throw new \Exception('$oServiceRest->return([...]) : status not-isset');
+		}
+		if ( !isset($json['result']) ) {
+			throw new \Exception('$oServiceRest->return([...]) : result not-isset');
+		}
+		if ( !isset($json['errors']) ) {
+			throw new \Exception('$oServiceRest->return([...]) : error not-isset');
+		}
+		if ( empty($json['debug']) ) {
+			$json['debug'] = null;
+		}
+		if ( is_array($json['result']) ) {
+			$json['result_count'] = count($json['result']);
+		}
+		echo json_encode($json);
+    	exit;
+	}
+
+	/**
+	 * Renvoi avec succès des données encodées en json
+	 * @param  array $json Liste d'arguments
+	 *	- string status [description]
+	 *	- string result [description]
+	 *	- string errors [description]
+	 *	- string debug [description]
+	 */
+	public function returnSuccess(array $json) {
+		$this->json([
+			'status' => empty($json['status']) ? 0 : $json['status'],
+			'result' => $json['result'],
+			'errors' => [],
+			'debug'  => empty($json['debug'])? null : $json['debug'],
+		]);
+	}
+
+	/**
+	 * Renvoi avec erreur des données encodées en json
+	 * @param  array $json Liste d'arguments
+	 *	- string status [description]
+	 *	- string result [description]
+	 *	- string errors [description]
+	 *	- string debug [description]
+	 */
+	public function returnError(array $json) {
+		if ( is_string($json['errors'])) {
+			$json['errors'] = [$json['errors']];
+		}
+		$json['status'] = empty($json['status']) ? -1 : $json['status'];
+		$json['debug'] = empty($json['debug'])? null : $json['debug'];
+		Core_Logs_Service::error([
+			'message' => 'Exception : '.$json['errors'][0]."\n".$json['debug'],
+			'code'    => $json['status'],
+			'file'    => __FILE__,
+		]);
+		$this->json([
+			'status' => $json['status'],
+			'result' => false,
+			'errors' => $json['errors'],
+			'debug'  => DEBUG ? $json['debug'] : null,
+		]);
+	}
+
+	public function returnWarning(array $json) {
+		if ( is_string($json['errors'])) {
+			$json['errors'] = [$json['errors']];
+		}
+		$json['status'] = empty($json['status']) ? -1 : $json['status'];
+		$json['debug'] = empty($json['debug'])? null : $json['debug'];
+		Core_Logs_Service::warning([
+			'message' => 'Exception : '.$json['errors'][0]."\n".$json['debug'],
+			'code'    => $json['status'],
+			'file'    => __FILE__,
+		]);
+		$this->json([
+			'status' => $json['status'],
+			'result' => false,
+			'errors' => $json['errors'],
+			'debug'  => DEBUG ? $json['debug'] : null,
+		]);
+	}
+
+}
diff --git a/core/services/Session.php b/core/services/Session.php
new file mode 100644
index 0000000000000000000000000000000000000000..b8f6c7d638cba357a6d06dd783586b75f202a28c
--- /dev/null
+++ b/core/services/Session.php
@@ -0,0 +1,26 @@
+<?php
+
+/**
+*   @copyright 2017 Maarch
+*
+*   This file is part of Maarch Framework.
+*
+*   Maarch Framework is free software: you can redistribute it and/or modify
+*   it under the terms of the GNU General Public License as published by
+*   the Free Software Foundation, either version 3 of the License, or
+*   (at your option) any later version.
+*
+*   Maarch Framework is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details.
+*
+*   You should have received a copy of the GNU General Public License
+*   along with Maarch Framework.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+require_once 'core/services/SessionAbstract.php';
+
+class Core_Session_Service extends Core_SessionAbstract_Service{
+	// Do your stuff
+}
diff --git a/core/services/SessionAbstract.php b/core/services/SessionAbstract.php
new file mode 100644
index 0000000000000000000000000000000000000000..1cd99e60d98a0fbdee868c1e1b4990c03b1fefa9
--- /dev/null
+++ b/core/services/SessionAbstract.php
@@ -0,0 +1,310 @@
+<?php
+
+/**
+*   @copyright 2017 Maarch
+*
+*   This file is part of Maarch Framework.
+*
+*   Maarch Framework is free software: you can redistribute it and/or modify
+*   it under the terms of the GNU General Public License as published by
+*   the Free Software Foundation, either version 3 of the License, or
+*   (at your option) any later version.
+*
+*   Maarch Framework is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details.
+*
+*   You should have received a copy of the GNU General Public License
+*   along with Maarch Framework.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+require_once 'core/services/Abstract.php';
+require_once 'core/class/class_functions.php';
+require_once 'core/class/class_security.php';
+
+/**
+ * Service de gestion des données en session
+ */
+class Core_SessionAbstract_Service extends Core_Abstract_Service {
+    
+    /**
+     * Récupération de la liste des méthodes disponibles via api
+     * 
+     * @return string[] La liste des méthodes
+     */
+    public static function getApiMethod() {
+        $aApiMethod = parent::getApiMethod();
+        $aApiMethod['getUserId']          = 'getUserId';
+        $aApiMethod['getUserEntitiesLst'] = 'getUserEntitiesLst';
+        $aApiMethod['InitializeAntiXss']  = 'InitializeAntiXss';
+        return $aApiMethod;
+    }
+    
+    /**
+     * Renvoie les informations de l'utilisateur courant dans la session
+     * @api rest.php?module=core&service=Core_Session_Service&method=getUser
+     * @throw \Exception $e
+     * @param array $args
+     * @return array $aUser
+     **/
+    public static function getUser(array $args = []) {
+        return empty($_SESSION['user'])?null:$_SESSION['user'];
+    }
+
+    /**
+     * Renvoie la valeur de la session anti_xss. on la définie si elle n'existe pas
+     * @api rest.php?module=core&service=Core_Session_Service&method=InitializeAntiXss
+     * @throw \Exception $e
+     * @param array $args
+     * @return array $aUser
+     **/
+    public static function InitializeAntiXss(array $args = []){
+        if(empty($_SESSION['anti_xss'])){
+            $_SESSION['anti_xss'] = uniqid();
+        }
+        return $_SESSION['anti_xss'];
+    }
+    
+    /**
+     * Renvoie le userid courant dans la session
+     * @throw \Exception $e
+     * @param array $args
+     *  - none
+     * @return string $sUserId
+     **/
+    public static function getUserId(array $args = []) {
+        $aUser = self::getUser();
+        if ( !empty($aUser['UserId']) ){
+            return $aUser['UserId'];
+        }
+
+        $userSSOHeader = '';
+        if (!empty($_SERVER['HTTP_'.HEADER_USER_UID])) {
+            $userSSOHeader = $_SERVER['HTTP_' .HEADER_USER_UID];
+        } else if (!empty($_SERVER['HTTP_' .HEADER_USER_NIGEND])) {
+            $userSSOHeader = $_SERVER['HTTP_' .HEADER_USER_NIGEND];
+        }
+        return $userSSOHeader;
+    }
+
+    /**
+     * Renvoie les entité de l'utilisateur en session
+     * @throw \Exception $e
+     * @param array $args
+     * @return array $aEntities [aEntitie]
+     **/
+    public static function getUserEntities(array $args = []) {
+        return $_SESSION['user']['entities'];
+    }
+
+    /**
+     * Renvoie la liste des entités de l'utilisateur en session (juste leur name)
+     * @throw \Exception $e
+     * @param array $args
+     * @return array $aEntities [string ENTITY_ID,string ENTITY_ID,...]
+     **/
+    public static function getUserEntitiesLst(array $args = []) {
+        $aUserEntities = self::getUserEntities();
+        $aLst = [];
+        foreach ($aUserEntities as $aEntitie) {
+            $aLst[] = $aEntitie['ENTITY_ID'];
+        }
+        return $aLst;
+    }
+
+    /**
+     * Renvoie les entité de l'utilisateur en session
+     * @throw \Exception $e
+     * @param array $args
+     * @return string $sEntities
+     **/
+    public static function getUserPrimaryentity(array $args = []) {
+        return $_SESSION['user']['primaryentity'];
+    }
+
+    /**
+     * Authentification d'un utilisateur
+     * - Vérifie que l'utilisateur existe (pas son code)
+     * - Charge l'utilisateur en session (le connecte)
+     * @param string $userId identifiant de l'utilisateur
+     * @return false|array false en cas d'echec, un tableau avec l'utilisateur sinon
+     */
+    public function authentication($userId) {
+        if ( empty($userId) ) {
+            return false;
+        }
+        if ( ! is_string($userId) ) {
+            return false;
+        }
+        $authenticated = false;
+        $func = new functions();
+
+        $connexion = new Database();
+
+        $_SESSION['user']['UserId'] = $userId;
+        $userID = str_replace('\'', '', $_SESSION['user']['UserId']);
+        $userID = str_replace('=', '', $userID);
+        $userID = str_replace('"', '', $userID);
+        $userID = str_replace('*', '', $userID);
+        $userID = str_replace(';', '', $userID);
+        $userID = str_replace('--', '', $userID);
+        $userID = str_replace(',', '', $userID);
+        $userID = str_replace('$', '', $userID);
+        $userID = str_replace('>', '', $userID);
+        $userID = str_replace('<', '', $userID);
+
+        $sec = new security();
+        $query = "SELECT * FROM users WHERE user_id = ? AND STATUS <> 'DEL'";
+
+        $stmt = $connexion->query(
+            $query, 
+            [$userID]
+        );
+
+        if ($stmt->rowCount() <= 0) {
+            return false;
+        }
+        $array = array();
+        $error = '';
+        $uc = new users_controler();
+
+        $database = new Database();
+        $comp = " and STATUS <>:status";
+        $params = array('status' => 'DEL');
+        $s_login = $userId;
+        $user = $uc->getWithComp($s_login, $comp, $params);
+        if (empty($user)) {
+            return false;
+        }
+        if ($user->__get('enabled') != 'Y') {
+            return false;
+        }
+        $ugc = new usergroups_controler();
+        $sec_controler = new SecurityControler();
+        $serv_controler = new ServiceControler();
+        if (isset($_SESSION['modules_loaded']['visa'])) {
+            if ($user->__get('signature_path') <> '' 
+                && $user->__get('signature_file_name') <> '' 
+            ) {
+                $_SESSION['user']['signature_path'] = $user->__get('signature_path');
+                $_SESSION['user']['signature_file_name'] = $user->__get('signature_file_name');
+                $db = new Database();
+                $query = "select path_template from " 
+                    . _DOCSERVERS_TABLE_NAME 
+                    . " where docserver_id = 'TEMPLATES'";
+                $stmt = $db->query($query);
+                $resDs = $stmt->fetchObject();
+                $pathToDs = $resDs->path_template;
+                $_SESSION['user']['pathToSignature'] = $pathToDs . str_replace(
+                        "#", 
+                        DIRECTORY_SEPARATOR, 
+                        $_SESSION['user']['signature_path']
+                    )
+                    . $_SESSION['user']['signature_file_name'];
+            }
+        }
+
+        $array = array(
+            'change_pass'         => $user->__get('change_password'),
+            'UserId'              => $user->__get('user_id'),
+            'FirstName'           => $user->__get('firstname'),
+            'LastName'            => $user->__get('lastname'),
+            'Phone'               => $user->__get('phone'),
+            'Mail'                => $user->__get('mail'),
+            'department'          => $user->__get('department'),
+            'thumbprint'          => $user->__get('thumbprint'),
+            'signature_path'      => $user->__get('signature_path'),
+            'signature_file_name' => $user->__get('signature_file_name'),
+            'pathToSignature'     => empty($_SESSION['user']['pathToSignature'])?'':$_SESSION['user']['pathToSignature'],
+            'Status'              => $user->__get('status'),
+            'cookie_date'         => $user->__get('cookie_date'),
+        );
+
+        $array['primarygroup'] = $ugc ->getPrimaryGroup(
+            $array['UserId']
+        );
+        $tmp = $sec_controler->load_security(
+            $array['UserId']
+        );
+        $array['collections'] = $tmp['collections'];
+        $array['security'] = $tmp['security'];
+        $serv_controler->loadEnabledServices();
+        $business_app_tools = new business_app_tools();
+        $core_tools = new core_tools();
+        $business_app_tools->load_app_var_session($array);
+        Core_CoreConfig_Service::loadVarSession($_SESSION['modules'], $array);
+        
+        /************Temporary fix*************/ 
+        if (isset($_SESSION['user']['baskets'])) {
+            $array['baskets'] = $_SESSION['user']['baskets'];
+        }
+        if (isset($_SESSION['user']['entities'])) {
+            $array['entities'] = $_SESSION['user']['entities'];
+        }
+        if (isset($_SESSION['user']['primaryentity'])) {
+            $array['primaryentity'] = $_SESSION['user']['primaryentity'];
+        }
+
+        if (isset($_SESSION['user']['redirect_groupbasket'])) {
+            $array['redirect_groupbasket'] = $_SESSION['user']['redirect_groupbasket'];
+        }
+        /*************************************/
+        $array['services'] = $serv_controler->loadUserServices(
+            $array['UserId']
+        );
+        
+        if ($_SESSION['history']['userlogin'] == 'true') {
+            //add new instance in history table for the user's connexion
+            $hist = new history();
+            if(!isset($_SERVER['REMOTE_ADDR'])){
+                $ip = 'testU';
+            } else {
+				$ip = $_SERVER['REMOTE_ADDR'];
+			}
+
+            $_SESSION['user']['UserId']       = $s_login;
+            $_SESSION['user']['department']   = $array['department'];
+            $_SESSION['user']['thumbprint']   = $array['thumbprint'];
+            $_SESSION['user']['primarygroup'] = $array['primarygroup'];
+            $hist->add(
+                $_SESSION['tablename']['users'],
+                $s_login,
+                'LOGIN','userlogin',
+                _LOGIN_HISTORY . ' '. $s_login . ' IP : ' . $ip,
+                $_SESSION['config']['databasetype']
+            );
+        }
+
+        return array(
+            'user'  => $array/*,
+            'error' => $error,
+            'url'   => 'index.php?' . $_SESSION['requestUri']*/
+        );
+
+/*
+        if ($array['change_pass'] == 'Y') {
+            return array(
+                'user'  => $array,
+                'error' => $error,
+                'url'   => 'index.php?display=true&page=change_pass'
+            );
+        }else if (isset($_SESSION['requestUri'])
+            && trim($_SESSION['requestUri']) <> ''
+            && ! preg_match('/page=login/', $_SESSION['requestUri'])) {
+            return array(
+                'user'  => $array,
+                'error' => $error,
+                'url'   => 'index.php?' . $_SESSION['requestUri']
+            );
+        } else {
+            return array(
+                'user'  => $array,
+                'error' => $error,
+                'url'   => 'index.php'
+            );
+        }
+*/
+        return true;
+    }
+}
\ No newline at end of file
diff --git a/core/services/String.php b/core/services/String.php
new file mode 100644
index 0000000000000000000000000000000000000000..54e7868b95da737657032eefde2b0c9a1499813c
--- /dev/null
+++ b/core/services/String.php
@@ -0,0 +1,26 @@
+<?php
+
+/**
+*   @copyright 2016 capgemini
+*
+*   This file is part of Maarch Framework.
+*
+*   Maarch Framework is free software: you can redistribute it and/or modify
+*   it under the terms of the GNU General Public License as published by
+*   the Free Software Foundation, either version 3 of the License, or
+*   (at your option) any later version.
+*
+*   Maarch Framework is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details.
+*
+*   You should have received a copy of the GNU General Public License
+*   along with Maarch Framework.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+require_once 'core'. DIRECTORY_SEPARATOR . 'services'. DIRECTORY_SEPARATOR . 'StringAbstract.php';
+
+class Core_String_Service extends Core_StringAbstract_Service {
+	// Do your stuff
+}
diff --git a/core/services/StringAbstract.php b/core/services/StringAbstract.php
new file mode 100644
index 0000000000000000000000000000000000000000..816e92e1d4eb649b52a2f3de820d9bcc448155fc
--- /dev/null
+++ b/core/services/StringAbstract.php
@@ -0,0 +1,62 @@
+<?php
+
+/**
+*   @copyright 2016 capgemini
+*
+*   This file is part of Maarch Framework.
+*
+*   Maarch Framework is free software: you can redistribute it and/or modify
+*   it under the terms of the GNU General Public License as published by
+*   the Free Software Foundation, either version 3 of the License, or
+*   (at your option) any later version.
+*
+*   Maarch Framework is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details.
+*
+*   You should have received a copy of the GNU General Public License
+*   along with Maarch Framework.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+require_once 'core'. DIRECTORY_SEPARATOR . 'services'. DIRECTORY_SEPARATOR . 'Abstract.php';
+
+class Core_StringAbstract_Service extends Core_Abstract_Service {
+
+    /**
+    * Delete accents
+    *
+    * @param  $str (string)
+    * @param  [$charset = 'utf-8'] (string)
+    *
+    * @return  $str (string)
+    */
+    public static function wd_remove_accents(
+        $str,
+        $charset ='utf-8'
+    )
+    {
+        $str = htmlentities(
+            $str,
+            ENT_NOQUOTES,
+            "utf-8"
+        );
+        $str = preg_replace(
+            '#\&([A-za-z])(?:uml|circ|tilde|acute|grave|cedil|ring)\;#',
+            '\1',
+            $str
+        );
+        $str = preg_replace(
+            '#\&([A-za-z]{2})(?:lig)\;#',
+            '\1',
+            $str
+        );
+        $str = preg_replace(
+            '#\&[^;]+\;#',
+            '',
+            $str
+        );
+
+        return $str;
+    }
+}
diff --git a/rest.php b/rest.php
new file mode 100644
index 0000000000000000000000000000000000000000..f51be58e96be729154df822ef2e0b949e79d610d
--- /dev/null
+++ b/rest.php
@@ -0,0 +1,196 @@
+<?php
+/**
+*   Copyright 2017 Maarch
+*
+*   This file is part of Maarch Framework.
+*
+*   Maarch Framework is free software: you can redistribute it and/or modify
+*   it under the terms of the GNU General Public License as published by
+*   the Free Software Foundation, either version 3 of the License, or
+*   (at your option) any later version.
+*
+*   Maarch Framework is distributed in the hope that it will be useful,
+*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*   GNU General Public License for more details.
+*
+*   You should have received a copy of the GNU General Public License
+*   along with Maarch Framework.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+* @file
+* @author Florian Azizian
+* @date $date$
+* @version $Revision$
+* @ingroup core
+* @doc https://fr.wikipedia.org/wiki/Representational_State_Transfer
+*/
+header('Content-Type: text/html; charset=utf-8');
+
+//create session if NO SESSION
+if ( empty($_SESSION['user']) ) {
+	require_once('core/class/class_functions.php');
+	include_once('core/init.php');
+	require_once('core/class/class_portal.php');
+	require_once('core/class/class_db.php');
+	require_once('core/class/class_request.php');
+	require_once('core/class/class_core_tools.php');
+	require_once('core/class/web_service/class_web_service.php');
+	require_once('core/services/CoreConfig.php');
+
+	//load Maarch session vars
+	$portal = new portal();
+	$portal->unset_session();
+	$portal->build_config();
+	$coreTools = new core_tools();
+	$_SESSION['custom_override_id'] = $coreTools->get_custom_id();
+	if (isset($_SESSION['custom_override_id'])
+	    && ! empty($_SESSION['custom_override_id'])
+	    && isset($_SESSION['config']['corepath'])
+	    && ! empty($_SESSION['config']['corepath'])
+	) {
+	    $path = $_SESSION['config']['corepath'] . 'custom' . DIRECTORY_SEPARATOR
+	        . $_SESSION['custom_override_id'] . DIRECTORY_SEPARATOR;
+	    set_include_path(
+	        $path . PATH_SEPARATOR . $_SESSION['config']['corepath']
+	        . PATH_SEPARATOR . get_include_path()
+	    );
+	} else if (isset($_SESSION['config']['corepath'])
+	    && ! empty($_SESSION['config']['corepath'])
+	) {
+	    set_include_path(
+	        $_SESSION['config']['corepath'] . PATH_SEPARATOR . get_include_path()
+	    );
+	}
+	// Load configuration from xml into session
+	Core_CoreConfig_Service::buildCoreConfig('core' . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . 'config.xml');
+	$_SESSION['config']['app_id'] = $_SESSION['businessapps'][0]['appid'];
+	require_once('apps' . DIRECTORY_SEPARATOR . $_SESSION['businessapps'][0]['appid'] 
+	    . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR 
+	    . 'class_business_app_tools.php'
+	);
+	Core_CoreConfig_Service::buildBusinessAppConfig();
+	
+	// Load Modules configuration from xml into session
+	Core_CoreConfig_Service::loadModulesConfig($_SESSION['modules']);
+	Core_CoreConfig_Service::loadAppServices();
+	Core_CoreConfig_Service::loadModulesServices($_SESSION['modules']);
+}
+
+require_once('apps/maarch_entreprise/define.php');
+require_once('core/services/Rest.php');
+require_once('core/services/Session.php');
+$lifetime=3600;
+setcookie(session_name(),session_id(),time()+$lifetime);
+
+// Rest :
+$oApi = new Core_Rest_Service();
+if (!file_exists('installed.lck') && is_dir('install')) {
+    $oApi->returnError(['errors'=>'Not installed']);
+}
+
+$userSSOHeader = '';
+if (!empty($_SERVER['HTTP_'.HEADER_USER_UID])) {
+	$userSSOHeader = $_SERVER['HTTP_' .HEADER_USER_UID];
+} else if (!empty($_SERVER['HTTP_' .HEADER_USER_NIGEND])) {
+	$userSSOHeader = $_SERVER['HTTP_' .HEADER_USER_NIGEND];
+}
+$timestart_authentification = microtime(true);
+if ( empty($_SESSION['user']) || (!empty($userSSOHeader) && $_SESSION['user']['UserId'] != $userSSOHeader )) {
+	$oSessionService = new \Core_Session_Service();
+	if (!empty($userSSOHeader)) {
+		$auth = $oSessionService->authentication($userSSOHeader);
+	} else {
+		$auth = false;
+	}
+
+	if (!$auth) {
+		$oApi->returnWarning(['errors'=>'User Not connected']);
+	} else {
+		$_SESSION['user'] = $auth['user'];
+	}
+}
+
+try {
+	// Vérification du module :
+	if ( empty($_GET['module']) ) {
+		$oApi->returnError([
+			'errors'=>'module arg missing',
+			'debug'=>[
+				'module args : $_GET[module]',
+				],
+			]);
+	}
+	require_once('core/services/Modules.php');
+
+	$aModules = Core_Modules_Service::getList();
+	$aModules['apps'] = 'apps';
+	$aModules['core'] = 'core';
+	if ( !isset($aModules[$_GET['module']]) ) {
+		$oApi->returnError([
+			'errors'=>'module Not installed',
+			'debug'=>[
+				'module asked : '.$_GET['module'],
+				],
+			]);
+	}
+	$sModule = $aModules[$_GET['module']];
+	
+	// Vérification du service :
+	if ( empty($_GET['service']) ) {
+		$oApi->returnError([
+			'errors'=>'service arg missing',
+			'debug'=>[
+				'service args : $_GET[service]',
+				],
+			]);
+	}
+	$aServices = Core_Modules_Service::getServicesList(['require'=>'once']);
+	if ( !isset($aServices[$sModule][$_GET['service']]) ) {
+		$oApi->returnError([
+			'errors'=>'service Not exists',
+			'debug'=>[
+				'service asked : '.$_GET['service'],
+				'service exist : '.var_export($aServices[$sModule],true),
+				],
+			]);
+	}
+	$oService = new $aServices[$sModule][$_GET['service']]();
+
+	// Vérification de la methode
+	if ( empty($_GET['method']) ) {
+		$oApi->returnError([
+			'errors'=>'method arg missing',
+			'debug'=>[
+				'method args : $_GET[method]',
+				],
+			]);
+	}
+
+	$aMethodes = $oService::getApiMethod();
+	if ( !isset($aMethodes[$_GET['method']]) ) {
+		$oApi->returnError([
+			'errors'=>'method Not installed',
+			'debug'=>[
+				'method asked : '.$_GET['method'],
+				],
+			]);
+	}
+	$sMethode = $aMethodes[$_GET['method']];
+
+	$resultMethode = $oService->{$sMethode}($_POST);
+
+	if ( isset($resultMethode['result']) ) {
+		// Renvoi du résultat avec le résult spécifié dans la réponse du service
+		$oApi->returnSuccess($resultMethode);
+	}else{
+		// Renvoi du résultat en tant que result
+		$oApi->returnSuccess([
+			'result' => $resultMethode
+		]);
+	}
+} catch (\Exception $e) {
+	$oApi->returnError(['errors'=>'Exception : '.$e->getMessage(), 'status'=>$e->getCode(), 'debug'=>$e->getTraceAsString(), ]);
+}
+exit;