ComunicAPI/init.php

70 lines
1.6 KiB
PHP
Raw Normal View History

2017-05-17 11:48:24 +00:00
<?php
/**
* Page initiator
*
* @author Pierre HUBERT
2017-05-17 11:51:22 +00:00
*/
//Define the base of the project
define("PROJECT_PATH", __DIR__."/");
//Include classes
foreach(glob(PROJECT_PATH."classes/*.php") as $classFile){
require_once $classFile;
}
//Include functions
foreach(glob(PROJECT_PATH."functions/*.php") as $funcFile){
require_once $funcFile;
}
2017-05-25 13:16:34 +00:00
//Include helpers
foreach(glob(PROJECT_PATH."helpers/*.php") as $funcFile){
require_once $funcFile;
}
2017-05-17 11:51:22 +00:00
//Create root object
2017-05-17 12:01:36 +00:00
$cs = new CS();
//Create configuration element
$config = new config();
$cs->register("config", $config);
//Include configuration
foreach(glob(PROJECT_PATH."config/*.php") as $confFile){
require $confFile;
}
//Reload overwrite config if any
if(file_exists(PROJECT_PATH."config/overwrite.php"))
require PROJECT_PATH."config/overwrite.php";
2017-05-17 12:43:12 +00:00
unset($config);
2017-05-17 12:01:36 +00:00
//Connexion to the database
$db = new DBLibrary(($cs->config->get("site_mode") == "debug"));
$cs->register("db", $db);
$db->openMYSQL($cs->config->get('mysql')['host'],
$cs->config->get('mysql')['user'],
$cs->config->get('mysql')['password'],
$cs->config->get('mysql')['database']);
2017-05-27 08:52:12 +00:00
define("DBprefix", $cs->config->get("dbprefix"));
2017-05-17 12:43:12 +00:00
unset($db);
2017-05-17 12:01:36 +00:00
2017-05-17 12:43:12 +00:00
//Add token object
2018-05-07 16:50:50 +00:00
$clients = new APIClients();
$cs->register("clients", $clients);
unset($clients);
2017-05-17 12:43:12 +00:00
2018-02-03 14:17:25 +00:00
//Include models
foreach(glob(PROJECT_PATH."classes/models/*.php") as $classFile){
require_once $classFile;
}
2017-05-26 08:23:55 +00:00
//Include components
foreach(glob(PROJECT_PATH."classes/components/*.php") as $classFile){
require_once $classFile;
}
//Add components object
$components = new Components();
$cs->register("components", $components);
unset($components);