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