Corrections suite aux pb relevés par le serveur
This commit is contained in:
parent
1f79d4c7b4
commit
33a0df3065
|
@ -6,10 +6,12 @@
|
||||||
class Database{
|
class Database{
|
||||||
|
|
||||||
/* ATTRIBUTS STATIQUES */
|
/* ATTRIBUTS STATIQUES */
|
||||||
public static $config_path = [
|
public static function config_path(){
|
||||||
'local' => __ROOT__.'/config/database-local.json',
|
return [
|
||||||
'remote' => __ROOT__.'/config/database.json'
|
'local' => __ROOT__.'/config/database-local.json',
|
||||||
];
|
'remote' => __ROOT__.'/config/database.json'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
private static $pdo;
|
private static $pdo;
|
||||||
private static $instance;
|
private static $instance;
|
||||||
|
@ -49,9 +51,9 @@
|
||||||
|
|
||||||
// chargement de la configuration du server SQL
|
// chargement de la configuration du server SQL
|
||||||
if( !checkdnsrr($_SERVER['SERVER_NAME'], 'NS') )
|
if( !checkdnsrr($_SERVER['SERVER_NAME'], 'NS') )
|
||||||
$conf = json_decode( file_get_contents(self::$config_path['local']), true );
|
$conf = json_decode( file_get_contents(self::config_path()['local']), true );
|
||||||
else
|
else
|
||||||
$conf = json_decode( file_get_contents(self::$config_path['remote']), true );
|
$conf = json_decode( file_get_contents(self::config_path()['remote']), true );
|
||||||
|
|
||||||
// creation de l'instance en fonction des parametres
|
// creation de l'instance en fonction des parametres
|
||||||
self::$instance = new DataBase($conf['host'], $conf['dbname'], $conf['user'], $conf['password']);
|
self::$instance = new DataBase($conf['host'], $conf['dbname'], $conf['user'], $conf['password']);
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
class ModuleRequest{
|
class ModuleRequest{
|
||||||
|
|
||||||
// Constantes
|
// Constantes
|
||||||
public static $config_path = __ROOT__.'/config/modules.json';
|
public static function config_path(){ return __ROOT__.'/config/modules.json'; }
|
||||||
public static $default_options = [
|
public static $default_options = [
|
||||||
'download' => false
|
'download' => false
|
||||||
];
|
];
|
||||||
|
@ -47,7 +47,7 @@
|
||||||
/* [0] On met a jour la configuration
|
/* [0] On met a jour la configuration
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
// Modules specifies
|
// Modules specifies
|
||||||
$this->modules = json_decode( file_get_contents(self::$config_path), true );
|
$this->modules = json_decode( file_get_contents(self::config_path()), true );
|
||||||
|
|
||||||
// Gestion de l'erreur de parsage
|
// Gestion de l'erreur de parsage
|
||||||
if( $this->modules == null ){
|
if( $this->modules == null ){
|
||||||
|
|
|
@ -10,16 +10,16 @@
|
||||||
|
|
||||||
|
|
||||||
/* CONSTANTES */
|
/* CONSTANTES */
|
||||||
const COND_EQUAL = '__=__';
|
const COND_EQUAL = '__=__';
|
||||||
const COND_NOTEQ = '__<>__';
|
const COND_NOTEQ = '__<>__';
|
||||||
const COND_INF = '__<__';
|
const COND_INF = '__<__';
|
||||||
const COND_SUP = '__>__';
|
const COND_SUP = '__>__';
|
||||||
const COND_INFEQ = '__<=__';
|
const COND_INFEQ = '__<=__';
|
||||||
const COND_SUPEQ = '__>=__';
|
const COND_SUPEQ = '__>=__';
|
||||||
const COND_LIKE = '__LIKE__';
|
const COND_LIKE = '__LIKE__';
|
||||||
const COND_IN = '__IN__';
|
const COND_IN = '__IN__';
|
||||||
|
|
||||||
const DEFAULT = '__DEFAULT__'; // Valeur DEFAULT (pour insertion)
|
const INSERT_DEFAULT = '__DEFAULT__'; // Valeur DEFAULT (pour insertion)
|
||||||
|
|
||||||
/* Attributs */
|
/* Attributs */
|
||||||
private $where; // Tableau associatif contenant les conditions
|
private $where; // Tableau associatif contenant les conditions
|
||||||
|
@ -550,11 +550,11 @@
|
||||||
$type = $this->schema['columns'][$field]['type'];
|
$type = $this->schema['columns'][$field]['type'];
|
||||||
|
|
||||||
// {1} Si de type INT/FLOAT et pas numérique, on retire le champ //
|
// {1} Si de type INT/FLOAT et pas numérique, on retire le champ //
|
||||||
if( in_array($type, ['int', 'float']) && !is_numeric($value) && $value != self::DEFAULT )
|
if( in_array($type, ['int', 'float']) && !is_numeric($value) && $value != self::INSERT_DEFAULT )
|
||||||
unset($cleared[$i][$field]);
|
unset($cleared[$i][$field]);
|
||||||
|
|
||||||
// {2} Si de type TEXT/VARCHAR et pas string, on retire le champ //
|
// {2} Si de type TEXT/VARCHAR et pas string, on retire le champ //
|
||||||
if( in_array($type, ['text', 'varchar']) && !is_string($value) && $value != self::DEFAULT )
|
if( in_array($type, ['text', 'varchar']) && !is_string($value) && $value != self::INSERT_DEFAULT )
|
||||||
unset($cleared[$i][$field]);
|
unset($cleared[$i][$field]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -595,8 +595,8 @@
|
||||||
|
|
||||||
// Si l'entrée est donnée
|
// Si l'entrée est donnée
|
||||||
if( isset($set[$field]) )
|
if( isset($set[$field]) )
|
||||||
if( $set[$field] == self::DEFAULT ) $requestS .= 'DEFAULT'; // On insère directement les valeurs 'DEFAULT'
|
if( $set[$field] == self::INSERT_DEFAULT ) $requestS .= 'DEFAULT'; // On insère directement les valeurs 'DEFAULT'
|
||||||
else $requestS .= ':insert_'.$field.'_'.$i;
|
else $requestS .= ':insert_'.$field.'_'.$i;
|
||||||
else
|
else
|
||||||
$requestS .= 'DEFAULT';
|
$requestS .= 'DEFAULT';
|
||||||
|
|
||||||
|
@ -620,7 +620,7 @@
|
||||||
/* (1) On bind les paramètres */
|
/* (1) On bind les paramètres */
|
||||||
foreach($cleared as $i=>$set)
|
foreach($cleared as $i=>$set)
|
||||||
foreach($this->schema['columns'] as $field=>$column)
|
foreach($this->schema['columns'] as $field=>$column)
|
||||||
if( isset($set[$field]) && $set[$field] != self::DEFAULT )
|
if( isset($set[$field]) && $set[$field] != self::INSERT_DEFAULT )
|
||||||
$bound[':insert_'.$field.'_'.$i] = $set[$field];
|
$bound[':insert_'.$field.'_'.$i] = $set[$field];
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
class Repo{
|
class Repo{
|
||||||
|
|
||||||
// Constantes
|
// Constantes
|
||||||
public static $config_path = __ROOT__.'/config/repositories.json';
|
public static function config_path(){ return __ROOT__.'/config/repositories.json'; }
|
||||||
|
|
||||||
|
|
||||||
// Attributs prives utiles (initialisation)
|
// Attributs prives utiles (initialisation)
|
||||||
|
@ -56,7 +56,7 @@
|
||||||
/* [0] On met a jour la configuration
|
/* [0] On met a jour la configuration
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
// Modules specifies
|
// Modules specifies
|
||||||
$this->repositories = json_decode( file_get_contents(self::$config_path), true );
|
$this->repositories = json_decode( file_get_contents(self::config_path()), true );
|
||||||
|
|
||||||
// Gestion de l'erreur de parsage
|
// Gestion de l'erreur de parsage
|
||||||
if( $this->repositories == null ){
|
if( $this->repositories == null ){
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
use \manager\sessionManager;
|
use \manager\sessionManager;
|
||||||
use \manager\ManagerError;
|
use \manager\ManagerError;
|
||||||
use \manager\Repo;
|
use \manager\Repo;
|
||||||
use \manager\repo\cluster as clusterRepo;
|
|
||||||
|
|
||||||
class userDefault{
|
class userDefault{
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$inserted = Table::get('admin')
|
$inserted = Table::get('admin')
|
||||||
->insert([
|
->insert([
|
||||||
'id_admin' => Rows::DEFAULT,
|
'id_admin' => Rows::INSERT_DEFAULT,
|
||||||
'username' => $username,
|
'username' => $username,
|
||||||
'mail' => $mail,
|
'mail' => $mail,
|
||||||
'password' => sessionManager::secure_hash( $password ),
|
'password' => sessionManager::secure_hash( $password ),
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
/* [1] Creation de la machine
|
/* [1] Creation de la machine
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$inserted = Table::get('machine')->insert([
|
$inserted = Table::get('machine')->insert([
|
||||||
'id_machine' => Rows::DEFAULT,
|
'id_machine' => Rows::INSERT_DEFAULT,
|
||||||
'id_warehouse' => $id_warehouse,
|
'id_warehouse' => $id_warehouse,
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'token' => sessionManager::secure_hash( uniqid() )
|
'token' => sessionManager::secure_hash( uniqid() )
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$inserted = Table::get('machine_cluster')
|
$inserted = Table::get('machine_cluster')
|
||||||
->insert([
|
->insert([
|
||||||
'id_machine_cluster' => Rows::DEFAULT,
|
'id_machine_cluster' => Rows::INSERT_DEFAULT,
|
||||||
'id_warehouse' => $id_warehouse,
|
'id_warehouse' => $id_warehouse,
|
||||||
'name' => $name
|
'name' => $name
|
||||||
]);
|
]);
|
||||||
|
@ -109,7 +109,7 @@
|
||||||
/* (1) On insère la relation */
|
/* (1) On insère la relation */
|
||||||
$inserted = Table::get('machine_cluster_merge')
|
$inserted = Table::get('machine_cluster_merge')
|
||||||
->insert([
|
->insert([
|
||||||
'id_machine_cluster_merge' => Rows::DEFAULT,
|
'id_machine_cluster_merge' => Rows::INSERT_DEFAULT,
|
||||||
'id_machine_cluster' => $id_machine_cluster,
|
'id_machine_cluster' => $id_machine_cluster,
|
||||||
'id_machine' => $id_machine
|
'id_machine' => $id_machine
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
/* [1] On retourne l'id_user ou FALSE si erreur
|
/* [1] On retourne l'id_user ou FALSE si erreur
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$inserted = Table::get('user')->insert([
|
$inserted = Table::get('user')->insert([
|
||||||
'id_user' => Rows::DEFAULT,
|
'id_user' => Rows::INSERT_DEFAULT,
|
||||||
'id_warehouse' => $id_warehouse,
|
'id_warehouse' => $id_warehouse,
|
||||||
'code' => $code,
|
'code' => $code,
|
||||||
'username' => $username,
|
'username' => $username,
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$inserted = Table::get('user_cluster')
|
$inserted = Table::get('user_cluster')
|
||||||
->insert([
|
->insert([
|
||||||
'id_user_cluster' => Rows::DEFAULT,
|
'id_user_cluster' => Rows::INSERT_DEFAULT,
|
||||||
'id_warehouse' => $id_warehouse,
|
'id_warehouse' => $id_warehouse,
|
||||||
'name' => $name
|
'name' => $name
|
||||||
]);
|
]);
|
||||||
|
@ -109,7 +109,7 @@
|
||||||
/* (1) On insère la relation */
|
/* (1) On insère la relation */
|
||||||
$inserted = Table::get('user_cluster_merge')
|
$inserted = Table::get('user_cluster_merge')
|
||||||
->insert([
|
->insert([
|
||||||
'id_user_cluster_merge' => Rows::DEFAULT,
|
'id_user_cluster_merge' => Rows::INSERT_DEFAULT,
|
||||||
'id_user_cluster' => $id_user_cluster,
|
'id_user_cluster' => $id_user_cluster,
|
||||||
'id_user' => $id_user
|
'id_user' => $id_user
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$created = Table::get('warehouse')
|
$created = Table::get('warehouse')
|
||||||
->insert([
|
->insert([
|
||||||
'id_warehouse' => Rows::DEFAULT,
|
'id_warehouse' => Rows::INSERT_DEFAULT,
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'password' => sessionManager::secure_hash( $password ),
|
'password' => sessionManager::secure_hash( $password ),
|
||||||
'token' => sessionManager::secure_hash( uniqid() )
|
'token' => sessionManager::secure_hash( uniqid() )
|
||||||
|
|
|
@ -404,7 +404,7 @@
|
||||||
// $insert = Table::get('user')
|
// $insert = Table::get('user')
|
||||||
// ->insert([
|
// ->insert([
|
||||||
// [
|
// [
|
||||||
// 'id_user' => Rows::DEFAULT,
|
// 'id_user' => Rows::INSERT_DEFAULT,
|
||||||
// 'id_warehouse' => 7,
|
// 'id_warehouse' => 7,
|
||||||
// 'code' => 'AA-AA-AA-AA',
|
// 'code' => 'AA-AA-AA-AA',
|
||||||
// 'username' => 'AA',
|
// 'username' => 'AA',
|
||||||
|
@ -413,7 +413,7 @@
|
||||||
// 'mail' => 'AA@AA.AA'
|
// 'mail' => 'AA@AA.AA'
|
||||||
// ],
|
// ],
|
||||||
// [
|
// [
|
||||||
// 'id_user' => Rows::DEFAULT,
|
// 'id_user' => Rows::INSERT_DEFAULT,
|
||||||
// 'id_warehouse' => 7,
|
// 'id_warehouse' => 7,
|
||||||
// 'code' => 'BB-BB-BB-BB',
|
// 'code' => 'BB-BB-BB-BB',
|
||||||
// 'username' => 'BB',
|
// 'username' => 'BB',
|
||||||
|
|
Loading…
Reference in New Issue