Corrections suite aux pb relevés par le serveur

This commit is contained in:
xdrm-brackets 2016-07-24 19:18:55 +02:00
parent 1f79d4c7b4
commit 33a0df3065
12 changed files with 36 additions and 35 deletions

View File

@ -6,10 +6,12 @@
class Database{ class Database{
/* ATTRIBUTS STATIQUES */ /* ATTRIBUTS STATIQUES */
public static $config_path = [ public static function config_path(){
return [
'local' => __ROOT__.'/config/database-local.json', 'local' => __ROOT__.'/config/database-local.json',
'remote' => __ROOT__.'/config/database.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']);

View File

@ -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 ){

View File

@ -19,7 +19,7 @@
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,7 +595,7 @@
// 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];

View File

@ -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 ){

View File

@ -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{

View File

@ -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 ),

View File

@ -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() )

View File

@ -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
]); ]);

View File

@ -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,

View File

@ -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
]); ]);

View File

@ -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() )

View File

@ -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',