From 1ff26f01f7899ed3c4812644e8d32904899d52f8 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Wed, 10 Feb 2016 08:54:23 +0100 Subject: [PATCH] - [.] [/users/view] Affichage basique de liste d'elements complexes (users/machines/journal, ...) - [.] [/machines/view] Idem + Corrections mineures --- automate.php | 65 +++- config/database.json | 4 +- config/generated_machines.json | 402 ++++++++++++++++++++++++ config/jsongenerator_machines.js | 24 ++ config/jsongenerator_users.js | 43 +-- config/modules.json | 23 +- manager/Database.php | 2 +- manager/module/firstModule.php | 39 --- manager/module/machineDefaultModule.php | 21 ++ manager/module/userDefaultModule.php | 25 +- todo.md | 3 + view/machines.php | 51 ++- 12 files changed, 591 insertions(+), 111 deletions(-) create mode 100644 config/generated_machines.json create mode 100755 config/jsongenerator_machines.js delete mode 100755 manager/module/firstModule.php create mode 100644 manager/module/machineDefaultModule.php diff --git a/automate.php b/automate.php index b69448e..2077fdf 100755 --- a/automate.php +++ b/automate.php @@ -20,13 +20,13 @@ * */ function insertUsersFromJSON(){ - $json = manager\ResourcesDispatcher::getRessource('/f/json/generated_users/conf'); + $json = \manager\ResourceDispatcher::getResource('f/json/generated_users/conf'); $json = json_decode( $json, true ); // Pour chaque entree foreach( $json as $user ){ - $insertRequest = manager\Database::getPDO()->prepare("INSERT INTO user(id_user, code, username, firstname, lastname, mail, password, status) + $insertRequest = \manager\Database::getPDO()->prepare("INSERT INTO user(id_user, code, username, firstname, lastname, mail, password, status) VALUES( DEFAULT, :code, @@ -58,6 +58,41 @@ + /* NSERTION DES MACHINES DANS LA BDD DEPUIS JSON + * + * + * @return status TRUE si aucune erreur, sinon FALSE + * + */ + function insertMachinesFromJSON(){ + $json = \manager\ResourceDispatcher::getResource('f/json/generated_machines/conf'); + $json = json_decode( $json, true ); + + // Pour chaque entree + foreach( $json as $machine ){ + + $insertRequest = \manager\Database::getPDO()->prepare("INSERT INTO machine(id_machine, code, name) + VALUES( + DEFAULT, + :code, + :name + )"); + + $status = $insertRequest->execute(array( + ':code' => $machine['code'], + ':name' => $machine['name'] + )); + + var_dump( $status ); + } + + return true; + + }//insertMachinesFromJSON(); + + + + @@ -81,7 +116,31 @@ return true; - }selectUsers(); + }//selectUsers(); + + + + + + + /* AFFICHAGE DES MACHINES DE LA BDD + * + * + * @return status TRUE si aucune erreur, sinon FALSE + * + */ + function selectMachines(){ + + // Creation de la requete + $requete = new manager\ModuleRequest('machineDefaultModule/getAll'); + $answer = $requete->dispatch(); + + var_dump( \manager\ManagerError::explicit($answer->error) ); + var_dump( $answer->get('machines') ); + + return true; + + }selectMachines(); diff --git a/config/database.json b/config/database.json index fe15446..e8b8c69 100755 --- a/config/database.json +++ b/config/database.json @@ -1,6 +1,6 @@ { - "host" : "sql31.free-h.org", + "host" : "xdrm.io", "dbname" : "stefproject", "user" : "php", - "password" : "Hx2c#e77" + "password" : "QbzjZACndQM6NmuD" } \ No newline at end of file diff --git a/config/generated_machines.json b/config/generated_machines.json new file mode 100644 index 0000000..2b1a8ee --- /dev/null +++ b/config/generated_machines.json @@ -0,0 +1,402 @@ +[ + { + "code": "CB-40-70-A0", + "name": "WNTKO" + }, + { + "code": "C9-42-46-45", + "name": "RMUAY" + }, + { + "code": "30-DA-23-C0", + "name": "ZSCMZ" + }, + { + "code": "6B-F0-82-05", + "name": "AWCUX" + }, + { + "code": "C8-67-58-0E", + "name": "HKSWO" + }, + { + "code": "CB-94-1E-F3", + "name": "ASIFJ" + }, + { + "code": "3F-A6-B3-5E", + "name": "CCKEV" + }, + { + "code": "8E-24-B5-24", + "name": "KDVSJ" + }, + { + "code": "27-15-0B-9D", + "name": "VCEWY" + }, + { + "code": "FE-38-93-E9", + "name": "UKWVN" + }, + { + "code": "07-6F-B6-B6", + "name": "FFJDJ" + }, + { + "code": "3A-A8-8E-B1", + "name": "NHCWO" + }, + { + "code": "A3-15-41-38", + "name": "IBRFK" + }, + { + "code": "99-30-04-B1", + "name": "FGLXK" + }, + { + "code": "80-A8-91-C8", + "name": "BUZRV" + }, + { + "code": "97-F3-00-93", + "name": "WKNTM" + }, + { + "code": "C6-F7-45-02", + "name": "SPQOQ" + }, + { + "code": "25-11-D9-70", + "name": "SSRWE" + }, + { + "code": "5B-EF-81-00", + "name": "TIBAH" + }, + { + "code": "74-18-01-AE", + "name": "EKOFT" + }, + { + "code": "07-27-C3-41", + "name": "GJTJW" + }, + { + "code": "23-38-C6-B5", + "name": "XIPNP" + }, + { + "code": "35-49-0B-88", + "name": "FDFXQ" + }, + { + "code": "36-00-7F-1C", + "name": "HSCUZ" + }, + { + "code": "CB-60-BB-1A", + "name": "BYKBF" + }, + { + "code": "FE-5F-E7-FB", + "name": "GNOKK" + }, + { + "code": "54-D1-4D-EC", + "name": "WLSUB" + }, + { + "code": "9D-D8-C8-53", + "name": "DMTTJ" + }, + { + "code": "32-A8-CB-08", + "name": "OCFWD" + }, + { + "code": "A4-B4-FC-74", + "name": "CABWU" + }, + { + "code": "9E-E7-87-A0", + "name": "BUWRJ" + }, + { + "code": "3F-90-8D-56", + "name": "OULIX" + }, + { + "code": "C7-95-56-96", + "name": "XCDYM" + }, + { + "code": "98-5B-99-35", + "name": "LREGF" + }, + { + "code": "C0-1C-52-1E", + "name": "DDLSP" + }, + { + "code": "AE-01-18-81", + "name": "DTGHG" + }, + { + "code": "85-46-39-94", + "name": "BZWUE" + }, + { + "code": "9C-3C-45-AB", + "name": "LGDDS" + }, + { + "code": "14-A5-92-CE", + "name": "ERXMY" + }, + { + "code": "A4-35-C5-76", + "name": "VJGER" + }, + { + "code": "69-8E-6A-11", + "name": "LOXIE" + }, + { + "code": "04-73-52-C8", + "name": "IHARA" + }, + { + "code": "66-48-DF-7B", + "name": "ZIQJQ" + }, + { + "code": "01-D9-22-86", + "name": "ZKUEW" + }, + { + "code": "B4-AC-F6-93", + "name": "BLDTO" + }, + { + "code": "E3-B8-CC-D4", + "name": "OZRQF" + }, + { + "code": "FF-18-3D-CB", + "name": "NWPBM" + }, + { + "code": "68-2D-86-1D", + "name": "OZDYC" + }, + { + "code": "65-AC-44-36", + "name": "ETUZU" + }, + { + "code": "9D-3F-90-E9", + "name": "CNQAB" + }, + { + "code": "8B-DE-55-B5", + "name": "OPIIW" + }, + { + "code": "15-1B-34-D7", + "name": "ACARQ" + }, + { + "code": "0D-E1-41-A8", + "name": "NMHYG" + }, + { + "code": "19-FB-D2-82", + "name": "ASKZD" + }, + { + "code": "C6-55-0A-22", + "name": "QMIJT" + }, + { + "code": "61-E4-51-C7", + "name": "BBDZL" + }, + { + "code": "65-78-34-50", + "name": "WKKYH" + }, + { + "code": "41-9A-BF-99", + "name": "AFHJH" + }, + { + "code": "05-0D-82-31", + "name": "CASXB" + }, + { + "code": "0D-21-6F-00", + "name": "LOXOZ" + }, + { + "code": "F7-84-53-CF", + "name": "ZTUNO" + }, + { + "code": "C2-9A-2D-9A", + "name": "QGQNK" + }, + { + "code": "BE-57-E3-29", + "name": "SVIBS" + }, + { + "code": "13-39-5D-21", + "name": "RSVXL" + }, + { + "code": "A6-3D-D3-AC", + "name": "EMESC" + }, + { + "code": "F2-EF-83-5E", + "name": "BBXON" + }, + { + "code": "52-F5-7D-2B", + "name": "NGLBK" + }, + { + "code": "BA-30-5C-C7", + "name": "MZHBC" + }, + { + "code": "B5-43-98-38", + "name": "OYEPB" + }, + { + "code": "95-AC-FD-6F", + "name": "RQFNK" + }, + { + "code": "E0-12-F0-7D", + "name": "MRUUS" + }, + { + "code": "E2-5F-C1-1F", + "name": "DJDVW" + }, + { + "code": "0B-0B-AF-49", + "name": "SOJEJ" + }, + { + "code": "C1-AF-BE-FD", + "name": "YYSRC" + }, + { + "code": "6B-71-12-94", + "name": "AJNMI" + }, + { + "code": "E0-D3-67-BB", + "name": "IVUSU" + }, + { + "code": "D7-02-23-82", + "name": "VYPUB" + }, + { + "code": "3F-AA-D7-E0", + "name": "SJYUN" + }, + { + "code": "CA-0E-31-E6", + "name": "QRGTG" + }, + { + "code": "D4-92-6B-03", + "name": "LXIFX" + }, + { + "code": "EE-0A-F5-D3", + "name": "YXWTP" + }, + { + "code": "73-EB-04-C8", + "name": "SMEFT" + }, + { + "code": "32-37-21-39", + "name": "HUTUW" + }, + { + "code": "97-13-49-2E", + "name": "DYCLY" + }, + { + "code": "EE-63-92-60", + "name": "VBJWP" + }, + { + "code": "B3-88-BB-2B", + "name": "CZRPO" + }, + { + "code": "F5-7D-F5-7E", + "name": "JCNSP" + }, + { + "code": "AA-A9-B2-83", + "name": "EOKCA" + }, + { + "code": "EA-62-F6-F9", + "name": "PZEAK" + }, + { + "code": "3D-3B-BE-D9", + "name": "ERIMX" + }, + { + "code": "75-57-68-54", + "name": "NGVPC" + }, + { + "code": "0E-F0-AD-27", + "name": "MVONW" + }, + { + "code": "84-39-68-9B", + "name": "ZUHOD" + }, + { + "code": "75-E4-50-0C", + "name": "YIATG" + }, + { + "code": "E8-F6-C1-CF", + "name": "WFQGC" + }, + { + "code": "55-89-B7-34", + "name": "NKZQL" + }, + { + "code": "B2-67-DD-0C", + "name": "EMIWA" + }, + { + "code": "11-7C-2E-A4", + "name": "WOYWY" + }, + { + "code": "CB-D8-B5-A2", + "name": "ZBLQG" + }, + { + "code": "CE-A1-20-27", + "name": "STQYS" + } +] \ No newline at end of file diff --git a/config/jsongenerator_machines.js b/config/jsongenerator_machines.js new file mode 100755 index 0000000..de17976 --- /dev/null +++ b/config/jsongenerator_machines.js @@ -0,0 +1,24 @@ +[ + { + 'repeat:100': { + + + code: function(tags){ + + function randHex(){ return ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'][Math.floor(Math.random()*16)]; } + + return randHex()+randHex()+'-'+randHex()+randHex()+'-'+randHex()+randHex()+'-'+randHex()+randHex(); + }, + + + name: function(tags){ + + function randLet(){ return String.fromCharCode(65+Math.floor(Math.random()*26)); } + + return randLet()+randLet()+randLet()+randLet()+randLet(); + } + + + } + } +] \ No newline at end of file diff --git a/config/jsongenerator_users.js b/config/jsongenerator_users.js index 349ae78..72cad88 100755 --- a/config/jsongenerator_users.js +++ b/config/jsongenerator_users.js @@ -1,24 +1,31 @@ [ - '{{repeat(100)}}', { - code: function(tags){ + 'repeat:100': { - function randHex(){ return ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'][Math.floor(Math.random()*16)]; } + code: function(tags){ + + function randHex(){ return ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'][Math.floor(Math.random()*16)]; } + + return randHex()+randHex()+'-'+randHex()+randHex()+'-'+randHex()+randHex()+'-'+randHex()+randHex(); + }, - return randHex()+randHex()+'-'+randHex()+randHex()+'-'+randHex()+randHex()+'-'+randHex()+randHex(); - }, - - - username: '{{firstName()}}', - firstname: '{{firstName()}}', - lastname: '{{surname()}}', - email: '{{email()}}', - password: function(tags){ - var result = ''; - for(var i = 0 ; i < 40 ; i++ ) - result += ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'][Math.floor(Math.random()*16)]; - return result; - }, - status: '{{integer(0,1)}}' + + username: '{{firstName()}}', + firstname: '{{firstName()}}', + lastname: '{{surname()}}', + email: function (tags) { + // Email tag is deprecated, because now you can produce an email as simple as this: + return this.firstname + '.' + this.lastname + '@gmail.com'; + }, + password: function(tags){ + var result = ''; + for(var i = 0 ; i < 40 ; i++ ) + result += ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'][Math.floor(Math.random()*16)]; + return result; + }, + status: '{{integer(0,1)}}' + + + } } ] \ No newline at end of file diff --git a/config/modules.json b/config/modules.json index 2f12cf6..ab4dbd4 100755 --- a/config/modules.json +++ b/config/modules.json @@ -3,25 +3,8 @@ "getAll" ], - "firstModule" : [ - "getUsers", - "returnvar", - "printvar" - ], - - "secondModule" : [ - "f", - "g", - "h", - "i", - "j" - ], - - "thirdModule" : [ - "k", - "l", - "m", - "n", - "o" + "machineDefaultModule" :[ + "getAll" ] + } \ No newline at end of file diff --git a/manager/Database.php b/manager/Database.php index 7adf270..088da3d 100755 --- a/manager/Database.php +++ b/manager/Database.php @@ -34,7 +34,7 @@ if( self::$instance == null ){ // chargement de la configuration du server SQL - if( $_SERVER['HTTP_HOST'] != 'stefprojectv2' ) + if( $_SERVER['HTTP_HOST'] != 'stefproject' ) $conf = json_decode( ResourceDispatcher::getResource(self::$config_path[0]), true ); else $conf = json_decode( ResourceDispatcher::getResource(self::$config_path[1]), true ); diff --git a/manager/module/firstModule.php b/manager/module/firstModule.php deleted file mode 100755 index 09dabb0..0000000 --- a/manager/module/firstModule.php +++ /dev/null @@ -1,39 +0,0 @@ -query("SELECT * FROM user ORDER BY id_user")->fetchAll(); - } - - - - - - - - - - - - public static function returnvar($var){ - var_dump('return var'); return $var; - } - - - public static function printvar($var){ - var_dump('var = '); var_dump($var); - } - - - - - - - } - - -?> \ No newline at end of file diff --git a/manager/module/machineDefaultModule.php b/manager/module/machineDefaultModule.php new file mode 100644 index 0000000..aae366f --- /dev/null +++ b/manager/module/machineDefaultModule.php @@ -0,0 +1,21 @@ + \manager\Database::delNumeric( \manager\Database::getPDO()->query("SELECT * FROM machine ORDER BY id_machine")->fetchAll() ) + ); + } + + + + + + } + + +?> \ No newline at end of file diff --git a/manager/module/userDefaultModule.php b/manager/module/userDefaultModule.php index 9455b8a..be7ffcc 100755 --- a/manager/module/userDefaultModule.php +++ b/manager/module/userDefaultModule.php @@ -7,34 +7,11 @@ public static function getAll(){ return array( - 'users' => \manager\Database::getPDO()->query("SELECT * FROM user ORDER BY id_user")->fetchAll() + 'users' => \manager\Database::delNumeric( \manager\Database::getPDO()->query("SELECT * FROM user ORDER BY id_user")->fetchAll() ) ); } - - - - - - - - - - public static function returnvar($var){ - var_dump('return var'); return $var; - } - - - public static function printvar($var){ - var_dump('var = '); var_dump($var); - } - - - - - - } diff --git a/todo.md b/todo.md index 1060517..cd2eb89 100755 --- a/todo.md +++ b/todo.md @@ -13,7 +13,10 @@ ############ # EN COURS # ############ +- [ ] Prendre en compte au lieu de SERVER['HTTP_HOST'] l'hote et son dossier source +- [ ] Gestion de l'erreur de chargement ou erreur de nav (page-manager) - [.] [/users/view] Affichage basique de liste d'elements complexes (users/machines/journal, ...) + - [.] [/machines/view] Idem - [x] Conception BDD + ameliorations - [x] Liste des tables - [x] Liste de attributs diff --git a/view/machines.php b/view/machines.php index 49c95da..c8ea6ac 100755 --- a/view/machines.php +++ b/view/machines.php @@ -5,7 +5,7 @@