diff --git a/automate.php b/automate.php index 6e7cf89..1014be3 100755 --- a/automate.php +++ b/automate.php @@ -3,13 +3,10 @@ use \manager\ModuleRequest; use \manager\ResourceDispatcher; + use \manager\sessionManager; use \manager\ManagerError; use \manager\Repo; - use \manager\module\callLog; - - debug(); - @@ -26,7 +23,7 @@ /* [2] On cree la requete =========================================================*/ - $request = new ModuleRequest('callLog/unserialize', array($file_content)); + $request = new ModuleRequest('call_log/unserialize', array($file_content)); $answer = $request->dispatch(); // on l'execute /* [3] Si erreur @@ -70,4 +67,5 @@ parseCallLog(); + ?> \ No newline at end of file diff --git a/config/modules.json b/config/modules.json index 5a23a2d..79a9639 100755 --- a/config/modules.json +++ b/config/modules.json @@ -1,56 +1,17 @@ { - "callLog": [ - + "call_log": [ "unserialize" - ], "charts": [ - "network_data", "network_render" - ], - "userDefault" :[ - "create", - - "link", - "unlink", - - "search", - - "getAll", - "getById", - "getByCode", - "getByUsername", - - "getClusters", - - "edit", - - "delete" - ], - - "machineDefault" :[ - "create", - - "link", - "unlink", - - "search", - - "getAll", - "getById", - "getByCode", - "getByName", - - "getClusters", - - "edit", - - "delete" + "token" :[ + "remove", + "generate" ] } \ No newline at end of file diff --git a/config/repositories.json b/config/repositories.json index 64d94f5..88d148c 100755 --- a/config/repositories.json +++ b/config/repositories.json @@ -1,6 +1,16 @@ { "Personnes": [ "getById" + ], + + + "token": [ + "getAll", + "getById", + + "check", + "generate", + "remove" ] } \ No newline at end of file diff --git a/css/container.css b/css/container.css index afefeeb..fe5fcfe 100755 --- a/css/container.css +++ b/css/container.css @@ -1,2 +1,2 @@ -#WRAPPER>#CONTAINER>section{display:none;position:relative;flex-grow:1;padding:1.5em;border-radius:5px;background-color:#fff;color:#000;font-size:1.2em}#WRAPPER>#CONTAINER>section.active{display:block}#WRAPPER>#CONTAINER>section h6{color:#848484;font-size:1.2em;text-transform:uppercase;font-weight:300;letter-spacing:.2em;margin:0;padding:0}#WRAPPER>#CONTAINER>section input[type="radio"],#WRAPPER>#CONTAINER>section input[type="checkbox"]{display:none}#WRAPPER>#CONTAINER>section input[type="radio"]+label[for],#WRAPPER>#CONTAINER>section input[type="checkbox"]+label[for]{padding-left:.8em;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}#WRAPPER>#CONTAINER>section input[type="radio"]+label[for]:before,#WRAPPER>#CONTAINER>section input[type="checkbox"]+label[for]:before{content:'';display:inline-block;position:relative;top:.1em;left:-.8em;width:calc( 1em - 2*.15em );height:calc( 1em - 2*.15em );border-radius:50% / 50%;border:0.15em solid #53d192;background:#fff center center no-repeat;background-image:none;background-size:70% auto;transition:background .2s ease-in-out;cursor:pointer}#WRAPPER>#CONTAINER>section input[type="radio"]:checked+label[for]:before,#WRAPPER>#CONTAINER>section input[type="checkbox"]:checked+label[for]:before{background-color:#53d192;background-image:url("/f/svg/checked/st/container")}#WRAPPER>#CONTAINER>section input[type="checkbox"]+label[for]:before{border-radius:3px}#WRAPPER>#CONTAINER>section input[type="button"]{margin:.5em;padding:.5em;border-radius:5px;border:3px solid #515151;font-weight:bold;color:#515151;background-color:#fff;transition:background .1s ease-in-out, color .1s ease-in-out}#WRAPPER>#CONTAINER>section input[type="button"]:active{background-color:#515151;color:#fff}#WRAPPER>#CONTAINER>section input[type="button"].primary{border-color:#53d192;color:#53d192;background-color:#fff}#WRAPPER>#CONTAINER>section input[type="button"].primary:active{background-color:#53d192;color:#fff} +#WRAPPER>#CONTAINER>section{display:none;position:relative;flex-grow:1;padding:1em;border-radius:3px;background-color:#fff;color:#000;font-size:1em}#WRAPPER>#CONTAINER>section.active{display:block}#WRAPPER>#CONTAINER>section h6{color:#848484;font-size:1.2em;text-transform:uppercase;font-weight:300;letter-spacing:.2em;margin:0;padding:0}#WRAPPER>#CONTAINER>section h6:before{content:'- '}#WRAPPER>#CONTAINER>section h6:after{content:' -'}#WRAPPER>#CONTAINER>section h6.center{text-align:center}#WRAPPER>#CONTAINER>section input[type="radio"],#WRAPPER>#CONTAINER>section input[type="checkbox"]{display:none}#WRAPPER>#CONTAINER>section input[type="radio"]+label[for],#WRAPPER>#CONTAINER>section input[type="checkbox"]+label[for]{padding-left:.8em;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}#WRAPPER>#CONTAINER>section input[type="radio"]+label[for]:before,#WRAPPER>#CONTAINER>section input[type="checkbox"]+label[for]:before{content:'';display:inline-block;position:relative;top:.1em;left:-.8em;width:calc( 1em - 2*.15em );height:calc( 1em - 2*.15em );border-radius:50% / 50%;border:0.15em solid #53d192;background:#fff center center no-repeat;background-image:none;background-size:70% auto;transition:background .2s ease-in-out;cursor:pointer}#WRAPPER>#CONTAINER>section input[type="radio"]:checked+label[for]:before,#WRAPPER>#CONTAINER>section input[type="checkbox"]:checked+label[for]:before{background-color:#53d192;background-image:url("/f/svg/checked/st/container")}#WRAPPER>#CONTAINER>section input[type="checkbox"]+label[for]:before{border-radius:3px}#WRAPPER>#CONTAINER>section input[type="button"]{margin:.5em 0;padding:.3em .5em;border-radius:3px;border:1px solid #515151;font-weight:bold;color:#515151;background-color:#fff;transition:background .1s ease-in-out, color .1s ease-in-out}#WRAPPER>#CONTAINER>section input[type="button"]:hover{background-color:#515151;color:#fff}#WRAPPER>#CONTAINER>section input[type="button"].primary{border-color:#53d192;color:#53d192;background-color:#fff}#WRAPPER>#CONTAINER>section input[type="button"].primary:hover{background-color:#53d192;color:#fff} /*# sourceMappingURL=container.css.map */ diff --git a/css/container.css.map b/css/container.css.map index 2288800..f0e7180 100755 --- a/css/container.css.map +++ b/css/container.css.map @@ -1,6 +1,6 @@ { "version": 3, -"mappings": "AAMC,2BAAW,CACV,OAAO,CAAE,IAAI,CAKb,QAAQ,CAAE,QAAQ,CAClB,SAAS,CAAE,CAAC,CAEZ,OAAO,CAAE,KAAK,CAEd,aAAa,CAAE,GAAG,CAElB,gBAAgB,CAAE,IAAI,CAEtB,KAAK,CAAE,IA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AU,CAAE,4BAA4B,CACxC,gBAAgB,CAAE,IAAI,CACtB,eAAe,CAAE,QAAQ,CAEzB,UAAU,CAAE,0BAA0B,CAEtC,MAAM,CAAE,OAAO,CAKjB,sJACoD,CACnD,gBAAgB,CC5FA,OAAO,CD6FvB,gBAAgB,CAAE,kCAAkC,CAKrD,oEAA4C,CAC3C,aAAa,CAAE,GAAG,CASnB,gDAAsB,CACrB,MAAM,CAAE,MAAM,CACd,OAAO,CAAE,SAAS,CAElB,aAAa,CAAE,GAAG,CAClB,MAAM,CAAE,iBAAmB,CAE3B,WAAW,CAAE,IAAI,CACjB,KAAK,CCrHW,OAAO,CDuHvB,gBAAgB,CAAE,IAAI,CAEtB,UAAU,CAAE,iDAAiD,CAG7D,sDAAO,CACN,gBAAgB,CC7HD,OAAO,CD8HtB,KAAK,CAAE,IAAI,CAKZ,wDAAS,CACR,YAAY,CCnIG,OAAO,CDoItB,KAAK,CCpIU,OAAO,CDqItB,gBAAgB,CAAE,IAAI,CAItB,8DAAO,CACN,gBAAgB,CC1IF,OAAO,CD2IrB,KAAK,CAAE,IAAI", "sources": ["container.scss","constants.scss"], "names": [], "file": "container.css" diff --git a/css/container.scss b/css/container.scss index c306593..a895999 100755 --- a/css/container.scss +++ b/css/container.scss @@ -13,14 +13,14 @@ position: relative; flex-grow: 1; - padding: 1.5em; + padding: 1em; - border-radius: 5px; + border-radius: 3px; background-color: #fff; color: #000; - font-size: 1.2em; + font-size: 1em; @@ -36,8 +36,13 @@ margin: 0; padding: 0; - // &:before{content:'- ';} - // &:after{content:' -';} + &:before{content:'- ';} + &:after{content:' -';} + + // quand centré + &.center{ + text-align: center; + } } @@ -108,11 +113,11 @@ /* [5] Boutons de submit =========================================================*/ & input[type="button"]{ - margin: .5em; - padding: .5em; + margin: .5em 0; + padding: .3em .5em; - border-radius: 5px; - border: 3px solid $theme-fg; + border-radius: 3px; + border: 1px solid $theme-fg; font-weight: bold; color: $theme-fg; @@ -121,8 +126,8 @@ transition: background .1s ease-in-out, color .1s ease-in-out; - /* (1) Animation de @active */ - &:active{ + /* (1) Animation de @hover */ + &:hover{ background-color: $theme-fg; color: #fff; } @@ -135,8 +140,8 @@ background-color: #fff; - /* (3) Animation de @active pour bouton primaire */ - &:active{ + /* (3) Animation de @hover pour bouton primaire */ + &:hover{ background-color: $theme-fg-primary; color: #fff; } diff --git a/css/global.css b/css/global.css index fb5e5ad..449a68e 100755 --- a/css/global.css +++ b/css/global.css @@ -1,2 +1,2 @@ - +section[data-panel-list]{display:block;position:relative;border-radius:3px;border:1px solid #ccc;background-color:#fff;font-size:.8em}section[data-panel-list]>div[data-header]{display:flex;position:relative;flex-direction:row;flex-wrap:nowrap;justify-content:space-between;align-items:center;padding:.5em .7em;border-radius:3px 3px 0 0;border-bottom:1px solid #ccc;background-color:#f5f5f5;box-shadow:inset 0 0 5px #eee}section[data-panel-list]>div[data-header]>span,section[data-panel-list]>div[data-header]>button{color:#333;font-weight:bold;line-height:2em}section[data-panel-list]>div[data-header]>button{padding:.1em .7em;border-radius:3px;border:1px solid #555;background:#f5f5f5;transition:all .2s ease-in-out}section[data-panel-list]>div[data-header]>button:hover{background:#333;color:#fff}section[data-panel-list]>div[data-description]{display:block;position:relative;border-bottom:1px solid #ccc;padding:.7em .7em;color:#666}section[data-panel-list]>ul[data-list]{display:flex;position:relative;flex-direction:column;justify-content:flex-start;flex-wrap:nowrap;margin:0;padding:0;list-style:none}section[data-panel-list]>ul[data-list]>li[data-element]{display:flex;flex-direction:row;justify-content:space-between;align-items:center;flex-wrap:nowrap;padding:1em}section[data-panel-list]>ul[data-list]>li[data-element]:not(:last-child){border-bottom:1px solid #ccc}section[data-panel-list]>ul[data-list]>li[data-element]>div:nth-child(1){display:flex;width:10em;height:6em;flex-direction:column;justify-content:flex-end;align-items:center;background:url("/f/svg/token/st/container/666666") center 1em no-repeat;background-size:auto 50%}section[data-panel-list]>ul[data-list]>li[data-element]>div:nth-child(1).active{background-image:url("/f/svg/token/st/container/4cbf86")}section[data-panel-list]>ul[data-list]>li[data-element]>div:nth-child(1)>span{display:block;padding:0 .4em;border-radius:3px;border:1px solid #ddd;font-size:.8em;color:#666;text-transform:uppercase;font-weight:bold}section[data-panel-list]>ul[data-list]>li[data-element]>div:nth-child(n+2){display:flex;position:relative;flex:10em;padding:1em;flex-direction:column;justify-content:flex-start;align-items:flex-start;font-size:.9em;color:#666;font-weight:bold}section[data-panel-list]>ul[data-list]>li[data-element]>div:nth-child(n+2)>span[data-prefix]:before{content:attr(data-prefix) ": ";font-weight:normal}section[data-panel-list]>ul[data-list]>li[data-element]>button{padding:.1em .7em;height:2em;border-radius:3px;border:1px solid #de2b08;background:#fff;color:#de2b08;font-weight:bold;transition:all .2s ease-in-out}section[data-panel-list]>ul[data-list]>li[data-element]>button:hover{background:#de2b08;color:#fff}section[data-panel-list]>div[data-add]{display:none;position:relative;padding:1em;border-bottom:1px solid #ccc;background-color:#f5f5f5;font-weight:bold}section[data-panel-list]>div[data-add].active{display:block}section[data-panel-list]>div[data-add]>input[type='text']{margin:1em 0;padding:.3em .5em;border-radius:3px;border:1px solid #999;background-color:#fff;color:#000;font-weight:normal} /*# sourceMappingURL=global.css.map */ diff --git a/css/global.css.map b/css/global.css.map index 48ce0fa..be7223f 100755 --- a/css/global.css.map +++ b/css/global.css.map @@ -1,7 +1,7 @@ { "version": 3, -"mappings": "", -"sources": [], +"mappings": "AAEA,wBAAwB,CACvB,OAAO,CAAE,KAAK,CACd,QAAQ,CAAE,QAAQ,CAElB,aAAa,CAAE,GAAG,CAClB,MAAM,CAAE,cAAc,CAEtB,gBAAgB,CAAE,IAAI,CAEtB,SAAS,CAAE,IAAI,CAIf,yCAAoB,CACnB,OAAO,CAAE,IAAI,CACb,QAAQ,CAAE,QAAQ,CAGlB,cAAc,CAAE,GAAG,CACnB,SAAS,CAAE,MAAM,CACjB,eAAe,CAAE,aAAa,CAC9B,WAAW,CAAE,MAAM,CAEnB,OAAO,CAAE,SAAS,CAElB,aAAa,CAAE,WAAW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M,CAEf,aAAa,CAAE,GAAG,CAClB,MAAM,CAAE,cAAc,CAEtB,SAAS,CAAE,IAAI,CACf,KAAK,CAAE,IAAI,CACX,cAAc,CAAE,SAAS,CACzB,WAAW,CAAE,IAAI,CAMnB,0EAAsB,CACrB,OAAO,CAAE,IAAI,CACb,QAAQ,CAAE,QAAQ,CAElB,IAAI,CAAE,IAAI,CAEV,OAAO,CAAE,GAAG,CAGZ,cAAc,CAAE,MAAM,CACtB,eAAe,CAAE,UAAU,CAC3B,WAAW,CAAE,UAAU,CAEvB,SAAS,CAAE,IAAI,CACf,KAAK,CAAE,IAAI,CACX,WAAW,CAAE,IAAI,CAGjB,mGAA4B,CAC3B,OAAO,CAAE,sBAAsB,CAC/B,WAAW,CAAE,MAAM,CAKrB,8DAAU,CACT,OAAO,CAAE,SAAS,CACjB,MAAM,CAAE,GAAG,CAEZ,aAAa,CAAE,GAAG,CAClB,MAAM,CAAE,iBAAiB,CAEzB,UAAU,CAAE,IAAI,CAEhB,KAAK,CAAE,OAAO,CACd,WAAW,CAAE,IAAI,CAEjB,UAAU,CAAE,mBAAmB,CAG/B,oEAAO,CACN,UAAU,CAAE,OAAO,CACnB,KAAK,CAAE,IAAI,CASf,sCAAiB,CAChB,OAAO,CAAE,IAAI,CAOb,QAAQ,CAAE,QAAQ,CAElB,OAAO,CAAE,GAAG,CAEZ,aAAa,CAAE,cAAc,CAE7B,gBAAgB,CAAE,OAAO,CAEzB,WAAW,CAAE,IAAI,CAZjB,6CAAQ,CACP,OAAO,CAAE,KAAK,CAef,yDAAsB,CACrB,MAAM,CAAE,KAAK,CACb,OAAO,CAAE,SAAS,CAElB,aAAa,CAAE,GAAG,CAClB,MAAM,CAAE,cAAc,CAEtB,gBAAgB,CAAE,IAAI,CAEtB,KAAK,CAAE,IAAI,CACX,WAAW,CAAE,MAAM", +"sources": ["global.scss"], "names": [], "file": "global.css" } \ No newline at end of file diff --git a/css/global.scss b/css/global.scss index e69de29..9f0890f 100755 --- a/css/global.scss +++ b/css/global.scss @@ -0,0 +1,233 @@ +/* [1] Panneau d'ajout/suppression d'elements +=========================================================*/ +section[data-panel-list]{ + display: block; + position: relative; + + border-radius: 3px; + border: 1px solid #ccc; + + background-color: #fff; + + font-size: .8em; + + + /* (1) Header (titre + ajout) */ + & > div[data-header]{ + display: flex; + position: relative; + + // flex properties + flex-direction: row; + flex-wrap: nowrap; + justify-content: space-between; + align-items: center; + + padding: .5em .7em; + + border-radius: 3px 3px 0 0; + border-bottom: 1px solid #ccc; + + background-color: #f5f5f5; + box-shadow: inset 0 0 5px #eee; + + // Libelle du panel + & > span, + & > button{ + color: #333; + font-weight: bold; + line-height: 2em; + } + + // Bouton ajouter + & > button{ + padding: .1em .7em; + + border-radius: 3px; + border: 1px solid #555; + + background: #f5f5f5; + + transition: all .2s ease-in-out; + + // Animation de @hover + &:hover{ + background: #333; + color: #fff; + } + } + + } + + + /* (2) Description (sous le header) */ + & > div[data-description]{ + display: block; + position: relative; + + border-bottom: 1px solid #ccc; + + padding: .7em .7em; + + color: #666; + } + + + + /* (3) Liste des elements */ + & > ul[data-list]{ + display: flex; + position: relative; + + // flex properties + flex-direction: column; + justify-content: flex-start; + flex-wrap: nowrap; + + margin: 0; + padding: 0; + + list-style: none; + + + /* (4) Chaque element de la liste */ + & > li[data-element]{ + display: flex; + + // flex properties + flex-direction: row; + justify-content: space-between; + align-items: center; + flex-wrap: nowrap; + + padding: 1em; + + // rebord en bas sauf dernier + &:not(:last-child){ + border-bottom: 1px solid #ccc; + } + + /* (4.1) Logo et type d'element */ + & > div:nth-child(1){ + display: flex; + width: 10em; + height: 6em; + + // flex properties + flex-direction: column; + justify-content: flex-end; + align-items: center; + + background: url('/f/svg/token/st/container/666666') center 1em no-repeat; + background-size: auto 50%; + + // Si le token est actif + &.active{ + background-image: url('/f/svg/token/st/container/4cbf86'); + } + + + // Texte pour le type d'element + & > span{ + display: block; + + padding: 0 .4em; + + border-radius: 3px; + border: 1px solid #ddd; + + font-size: .8em; + color: #666; + text-transform: uppercase; + font-weight: bold; + } + + } + + /* (4.2) Donnees descriptives */ + & > div:nth-child(n+2){ + display: flex; + position: relative; + + flex: 10em; + + padding: 1em; + + // flex properties + flex-direction: column; + justify-content: flex-start; + align-items: flex-start; + + font-size: .9em; + color: #666; + font-weight: bold; + + // On prefixe chaque donnee + & > span[data-prefix]:before{ + content: attr(data-prefix) ": "; + font-weight: normal; + } + } + + /* (4.3) Bouton de suppression */ + & > button{ + padding: .1em .7em; + height: 2em; + + border-radius: 3px; + border: 1px solid #de2b08; + + background: #fff; + + color: #de2b08; + font-weight: bold; + + transition: all .2s ease-in-out; + + // Animation de @hover + &:hover{ + background: #de2b08; + color: #fff; + } + } + + } + } + + + /* (5) Formulaire d'ajout d'un nouvel element */ + & > div[data-add]{ + display: none; + + // Affichage quand .active + &.active{ + display: block; + } + + position: relative; + + padding: 1em; + + border-bottom: 1px solid #ccc; + + background-color: #f5f5f5; + + font-weight: bold; + + + /* (5.1) Champs de texte */ + & > input[type='text']{ + margin: 1em 0; + padding: .3em .5em; + + border-radius: 3px; + border: 1px solid #999; + + background-color: #fff; + + color: #000; + font-weight: normal; + } + } + +} \ No newline at end of file diff --git a/css/layout.css b/css/layout.css index 36f2bbc..8840469 100755 --- a/css/layout.css +++ b/css/layout.css @@ -1,2 +1,2 @@ -#WRAPPER{display:block;position:fixed;top:0;left:0;width:100%;height:100%;background-color:#e8e8e8;font-family:'Open Sans'}#WRAPPER>#HEADER{display:flex;position:absolute;top:0;left:15em;width:calc( 100% - 15em );height:calc( 5em - 1px );border-bottom:1px solid #e5e5e5;background-color:#fff;flex-direction:row;justify-content:flex-end;align-content:space-around;z-index:10}#WRAPPER>#MENU-SIDE{display:block;position:absolute;top:0;left:0;width:15em;height:100%;box-shadow:2px 1px 3px #ddd;background-color:#32323a;transition:all .3s;z-index:9}#WRAPPER>#CONTAINER{display:flex;position:absolute;top:5em;left:15em;width:calc( 100% - 15em - 2*1em );height:calc( 100% - 15em - 2*1em );padding:1em;flex-direction:row;justify-content:space-between;overflow-x:none;overflow-y:auto} +#WRAPPER{display:block;position:fixed;top:0;left:0;width:100%;height:100%;background-color:#e8e8e8;font-family:'Open Sans';font-size:15px;overflow-x:hidden;overflow-y:auto}#WRAPPER>#HEADER{display:flex;position:absolute;top:0;left:15em;width:calc( 100% - 15em );height:calc( 5em - 1px );border-bottom:1px solid #e5e5e5;background-color:#fff;flex-direction:row;justify-content:flex-end;align-content:space-around;z-index:10}#WRAPPER>#MENU-SIDE{display:block;position:fixed;top:0;left:0;width:15em;height:100%;box-shadow:2px 1px 3px #ddd;background-color:#32323a;transition:all .3s;z-index:9}#WRAPPER>#CONTAINER{display:flex;position:absolute;top:5em;left:15em;width:calc( 100% - 15em - 2*1em );min-height:calc( 100% - 5em - 2*1em );padding:1em;flex-direction:row;justify-content:space-between;overflow-x:none;overflow-y:auto} /*# sourceMappingURL=layout.css.map */ diff --git a/css/layout.css.map b/css/layout.css.map index e554b26..a0f5c89 100755 --- a/css/layout.css.map +++ b/css/layout.css.map @@ -1,6 +1,6 @@ { "version": 3, -"mappings": "AAEA,QAAQ,CACP,OAAO,CAAE,KAAK,CACd,QAAQ,CAAE,KAAK,CACd,GAAG,CAAE,CAAC,CACN,IAAI,CAAE,CAAC,CACP,KAAK,CAAE,IAAI,CACX,MAAM,CAAE,IAAI,CAEb,gBAAgB,CCPE,OAAO,CDSzB,WAAW,CAAE,WAAW,CAKxB,gBAAW,CACV,OAAO,CAAE,IAAI,CACb,QAAQ,CAAE,QAAQ,CACjB,GAAG,CAAE,CAAC,CACN,IAAI,CCHW,IAAI,CDInB,KAAK,CAAE,mBAAkC,CACzC,MAAM,CAAE,iBAA+B,CAExC,aAAa,CAAE,iBAA8B,CAE7C,gBAAgB,CCvBC,IAAO,CD0BxB,cAAc,CAAE,GAAG,CACnB,eAAe,CAAE,QAAQ,CACzB,aAAa,CAAE,YAAY,CAE3B,OAAO,CAAE,EAAE,CAQZ,mBAAc,CACb,OAAO,CAAE,KAA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C,CACP,KAAK,CCjCU,IAAI,CDkCnB,MAAM,CAAE,IAAI,CAEb,UAAU,CAAE,gBAAgB,CAE5B,gBAAgB,CC/CA,OAAO,CDiDvB,UAAU,CAAE,OAAO,CAEnB,OAAO,CAAE,CAAC,CAMX,mBAAc,CACb,OAAO,CAAE,IAAI,CACb,QAAQ,CAAE,QAAQ,CACjB,GAAG,CClDY,GAAG,CDmDlB,IAAI,CCpDW,IAAI,CDqDnB,KAAK,CAAE,2BAA0C,CACjD,UAAU,CAAE,0BAAwC,CACrD,OAAO,CAAE,GAAG,CAGZ,cAAc,CAAE,GAAG,CACnB,eAAe,CAAE,aAAa,CAE9B,UAAU,CAAE,IAAI,CAChB,UAAU,CAAE,IAAI", "sources": ["layout.scss","constants.scss"], "names": [], "file": "layout.css" diff --git a/css/layout.scss b/css/layout.scss index ae58152..11cdfa4 100755 --- a/css/layout.scss +++ b/css/layout.scss @@ -11,6 +11,10 @@ background-color: $theme-bg; font-family: 'Open Sans'; + font-size: 15px; + + overflow-x: hidden; + overflow-y: auto; /* [1] Header de la page @@ -42,7 +46,7 @@ // Gestion du menu & > #MENU-SIDE{ display: block; - position: absolute; + position: fixed; top: 0; left: 0; width: $menu-side-width; @@ -66,7 +70,7 @@ top: $header-height; left: $menu-side-width; width: calc( 100% - #{$menu-side-width} - 2*1em ); - height: calc( 100% - #{$menu-side-width} - 2*1em ); + min-height: calc( 100% - #{$header-height} - 2*1em ); padding: 1em; // Flex properties diff --git a/js/action-script.js b/js/action-script.js index af400fb..c90f70d 100755 --- a/js/action-script.js +++ b/js/action-script.js @@ -197,4 +197,9 @@ + /* [6] Gestion du rechargement de page + =========================================================*/ + function reload(){ navMenu( pageManager.page ); } + + // } \ No newline at end of file diff --git a/js/lib/api.js b/js/lib/api.js index b9209bc..ba2df59 100755 --- a/js/lib/api.js +++ b/js/lib/api.js @@ -10,6 +10,7 @@ APIClass.prototype = { * * @param pRequest l'objet passé en JSON à http://host/api/ * @param pHandler fonction qui s'éxécutera lors de la réponse (1 argument -> réponse) + * @param pToken si donne, token d'auth pour l'api * * @return answer l'objet retourné par http://host/api/ via pHandler (1er argument) * @@ -26,7 +27,7 @@ APIClass.prototype = { * 3. on passe une fonction qui utilise un argument (sera la réponse de http://host/api/) (sous forme d'objet) * */ - send: function(pRequest, pHandler){ + send: function(pRequest, pHandler, pToken){ // Si le chemin de delegation n'est pas renseigne, on renvoie une erreur if( !pRequest.hasOwnProperty('path') ) @@ -77,7 +78,16 @@ APIClass.prototype = { if( pRequest.hasOwnProperty('data') ) form.append('data', JSON.stringify(pRequest.data) ); + + this.xhr[i].open('POST', this.target, true); + + + // Gestion du token optionnel + if( pToken != null ) this.xhr[i].setRequestHeader('Authorization', 'Digest '+pToken); + + + this.xhr[i].send( form ); } diff --git a/manager/Database.php b/manager/Database.php index 0892cfb..89f874b 100755 --- a/manager/Database.php +++ b/manager/Database.php @@ -191,10 +191,18 @@ return $checker && is_numeric($value) && $value <= 2147483647 && $value >= -2147483647; break; + case 'int': + return $checker && is_numeric($value) && $value <= 2147483647 && $value >= 0; + break; + case 'varchar(255)': return $checker && is_string($value) && strlen($value) <= 255; break; + case 'varchar(50)': + return $checker && is_string($value) && strlen($value) <= 50; + break; + /* (2) Utilisateur */ case 'user.code': case 'machine.code': @@ -216,7 +224,7 @@ return $checker && is_string($value) && strlen($value) <= 50 && preg_match('/^[\w\.-]+@[\w\.-]+\.[a-z]{2,4}$/i', $value); break; - case 'user.password': + case 'sha1': return $checker && is_string($value) && preg_match('/^[\da-f]{40}$/i', $value); break; @@ -231,5 +239,42 @@ } + //////////////////////////////////// + // _ _ + // __| | __ _| |_ ___ ___ + // / _` |/ _` | __/ _ \/ __| + // | (_| | (_| | || __/\__ \ + // \__,_|\__,_|\__\___||___/ + // + //////////////////////////////////// + // 1) Convertis une date en en francais explicite + public static function frDate($date){ + /* [1] On definit les traductions + =========================================================*/ + // Jours de la semaine + $days = array("Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi", "Dimanche"); + // Mois de l'annee + $months = array("Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"); + + /* [2] On recupere le timestamp et les indices + =========================================================*/ + $time = strtotime($date); // timestamp + $daynum = intval( date('N', $time)-1 ); // jour dans la semaine + $monthnum = intval( date('n', $time)-1 ); // numero du mois dans l'annee + + + /* [3] On recupere les infos independemment + =========================================================*/ + $result = array( + $days[$daynum], // nom de jour + date('j', $time), // jour du mois + $months[$monthnum], // nom du mois + date('Y', $time), // annee + ); + + + return implode(" ", $result); + } + } ?> diff --git a/manager/ManagerError.php b/manager/ManagerError.php index f26f8f6..83c6547 100755 --- a/manager/ManagerError.php +++ b/manager/ManagerError.php @@ -60,6 +60,10 @@ // Erreur lors de la creation d'un objet PDO (connection) const PDOConnection = 14; + /* API token */ + // Token inexistant ou faux + const TokenError = 15; + /* EXPLICITE UN CODE D'ERREUR * @@ -90,6 +94,8 @@ case self::PDOConnection: return "La connexion avec la base de donnees a echoue"; break; + case self::TokenError: return "Le token de connection est absent ou errone"; break; + // default: return "Erreur inconnue..."; break; } diff --git a/manager/ModuleAnswer.php b/manager/ModuleAnswer.php index 808a4b3..7869be7 100755 --- a/manager/ModuleAnswer.php +++ b/manager/ModuleAnswer.php @@ -137,7 +137,7 @@ public function serialize(){ // On rajoute l'erreur au message - $returnData = array_merge( array('ModuleError' => $this->error), $this->data ); + $returnData = array_merge( array('ModuleError' => $this->error, 'ErrorDescription' => ManagerError::explicit($this->error)), $this->data ); return json_encode($returnData); diff --git a/manager/ModuleRequest.php b/manager/ModuleRequest.php index cc7dab3..5171a5e 100755 --- a/manager/ModuleRequest.php +++ b/manager/ModuleRequest.php @@ -167,6 +167,25 @@ * */ public static function fromPost($post){ + /* [0] Verification de l'authentification + =========================================================*/ + /* (1) Si le token n'est pas dans le header */ + if( !isset($_SERVER['PHP_AUTH_DIGEST']) ){ + $tmp = new ModuleRequest(); + $tmp->error = ManagerError::TokenError; + return $tmp; + } + + /* (2) Si le token n'est pas dans la BDD */ + $checkToken = new Repo('token/check', array($_SERVER['PHP_AUTH_DIGEST']) ); + $valid_token = $checkToken->answer(); + + if( !$valid_token ){ + $tmp = new ModuleRequest(); + $tmp->error = ManagerError::TokenError; + return $tmp; + } + /* [1] On verifie que le @path est renseigne =========================================================*/ if( !isset($post['path']) ) diff --git a/manager/ResourceDispatcher.php b/manager/ResourceDispatcher.php index 4a21abb..4f907fb 100755 --- a/manager/ResourceDispatcher.php +++ b/manager/ResourceDispatcher.php @@ -1,6 +1,8 @@ header); // On recupere le contenu - $svg_content = file_get_contents($this->path); + $content = file_get_contents($this->path); + + + + //////////////////////////////////////// + ///////////// SI FICHIER JS //////////// + //////////////////////////////////////// + if( $this->flags['extension'] == 'js' ) + $content = 'var js_access_token = "'. substr($_SESSION['session_token'], 0, 40) .'";' . "\n\n" . $content; + + + // On affiche tout - echo str_replace( '', $this->stylesheet.'', $svg_content ); + echo str_replace( '', $this->stylesheet.'', $content ); } @@ -263,10 +276,10 @@ // On inclut le contenu - $svg_content = file_get_contents($this->path); + $content = file_get_contents($this->path); // On retourne tout - return str_replace( '', $this->stylesheet.'', $svg_content ); + return str_replace( '', $this->stylesheet.'', $content ); } diff --git a/manager/module/callLog.php b/manager/module/call_log.php similarity index 99% rename from manager/module/callLog.php rename to manager/module/call_log.php index a7d7071..5cd6ac8 100644 --- a/manager/module/callLog.php +++ b/manager/module/call_log.php @@ -6,7 +6,7 @@ use \manager\ManagerError; use \manager\Repo; - class callLog{ + class call_log{ /* DESERIALISATION D'UN JOURNAL D'APPEL diff --git a/manager/module/charts.php b/manager/module/charts.php old mode 100644 new mode 100755 diff --git a/manager/module/token.php b/manager/module/token.php new file mode 100755 index 0000000..437bd9b --- /dev/null +++ b/manager/module/token.php @@ -0,0 +1,92 @@ + UID du token en question + * + * @return status Retourne l'etat de la suppression (VRAI -> fait/FAUX -> erreur) + * + */ + public static function remove($id_token){ + /* [0] Verification des INPUT + =========================================================*/ + if( !Database::check('id', $id_token) ) return array('ModuleError' => ManagerError::ParamError); + + + /* [1] Suppression du token + =========================================================*/ + $remove = new Repo('token/remove', array($id_token)); + // On renvoie une erreur si une erreur intervient pendant la suppression + if( !$remove->answer() ) return array('ModuleError' => ManagerError::ModuleError); + + + /* [n] Gestion du retour quand tout est normal + =========================================================*/ + return array( 'ModuleError' => ManagerError::Success ); + } + + + + + + + /* GENERE UN NOUVEAU TOKEN DE NOM ET EXPIRATION SPECIFIEE + * + * @name Nom attribue au token + * @duration Duree du token en jours + * + * @return id_token Renvoie l'id du token cree + * @return FALSE Renvoie FALSE si erreur + * + */ + public static function generate($name, $duration){ + /* [0] Verification des INPUT + =========================================================*/ + if( !Database::check('varchar(50)', $name) || !Database::check('numeric', $duration) ) + return array('ModuleError' => ManagerError::ParamError); // erreur de parametre + + + /* [1] On cree le token et recupere son id ou FAUX + =========================================================*/ + $create = new Repo('token/generate', array($name, $duration)); + $created = $create->answer(); + + + // Si erreur de creation + if( $created === false ) return array('ModuleError' => ManagerError::ModuleError ); + + + /* [2] Gestion du retour + =========================================================*/ + return array( + 'ModuleError' => ManagerError::Success, + 'id_token' => $created + ); + } + + + + + + + + + + + + } + + +?> \ No newline at end of file diff --git a/manager/repo/Token.php b/manager/repo/Token.php deleted file mode 100644 index f305209..0000000 --- a/manager/repo/Token.php +++ /dev/null @@ -1,65 +0,0 @@ - UID de la personne en question - * - * @return personne Tableau associatif contenant les informations utiles de la personne - * @return FALSE Si une erreur occure ou qu'aucune personne n'est trouvee, retourne FALSE - * - */ - public static function getById($id_personne=null){ - /* [0] Verification des INPUT - =========================================================*/ - if( !Database::check('id', $id_personne) ) return false; - - /* [1] On prepare et execute la requete - =========================================================*/ - $request = Database::getPDO()->prepare("SELECT idPersonne as id, pseudo, nom, prenom, id_facebook, telephone - FROM Personnes - WHERE idPersonne = :uid"); - $request->execute(array( - ':uid' => $id_personne - )); - - - /* [2] On recupere le resultat - =========================================================*/ - // si aucun resultat, on retourne FALSE - if( ($personne=$request->fetch()) === false ) return false; - - - /* [3] On retourne les donnees - =========================================================*/ - return Database::delNumeric( $personne, true ); - } - - - - - - - } - - -?> \ No newline at end of file diff --git a/manager/repo/token.php b/manager/repo/token.php new file mode 100644 index 0000000..545e996 --- /dev/null +++ b/manager/repo/token.php @@ -0,0 +1,212 @@ + Liste de tous les tokens + * + */ + public static function getAll(){ + /* [1] On prepare et execute la requete + =========================================================*/ + $request = Database::getPDO()->query("SELECT id_token as id, name, token, expires, (CURDATE() > expires) as expired + FROM api_token + ORDER BY expires DESC"); + + + /* [3] On retourne les donnees + =========================================================*/ + return Database::delNumeric( $request->fetchAll() ); + } + + + + /* RETOURNE LE TOKEN D'ID SPECIFIE OU FALSE + * + * @id_token UID du token en question + * + * @return token Retourne les donnees du token ou FALSE si erreur + * + */ + public static function getById($id_token){ + /* [0] Verification des INPUT + =========================================================*/ + if( !Database::check('id', $id_token) ) return false; + + + /* [1] On cherche dans la bdd + =========================================================*/ + $get_token = Database::getPDO()->prepare("SELECT id_token FROM api_token WHERE id_token = :id_token"); + $get_token->execute( array( ':id_token' => $id_token ) ); + + + /* [2] On renvoie la valeur ou FALSE + =========================================================*/ + return $get_token->fetch(); + } + + + + /* VERIFIE SI UN TOKEN EST VALIDE + * + * @token Token en question + * + * @return valid Retourne si VRAI ou FAUX le token est valid + * + */ + public static function check($token){ + /* [0] Verification des INPUT + =========================================================*/ + // si le format est incorrect, on retourne FAUX + if( !Database::check('sha1', $token) ) return false; + + + /* [1] Verification du token local + =========================================================*/ + if( substr($_SESSION['session_token'], 0, 40) == $token ) return true; + + + /* [2] Verification dans la base de donnees + =========================================================*/ + $check = Database::getPDO()->prepare("SELECT id_token + FROM api_token + WHERE CURDATE() <= expires + AND token = :token"); + $check->execute(array( ':token' => $token )); + + + /* [3] On retourne le resultat + =========================================================*/ + return $check->fetch() !== false; + } + + + + + /* GENERE UN NOUVEAU TOKEN DE NOM ET EXPIRATION SPECIFIEE + * + * @name Nom attribue au token + * @duration Duree du token en jours + * + * @return id_token Renvoie l'id du token cree + * @return FALSE Renvoie FALSE si erreur + * + */ + public static function generate($name, $duration){ + /* [0] Verification des INPUT + =========================================================*/ + if( !Database::check('varchar(50)', $name) || !Database::check('int', $duration) ) return false; + + + // On definit la date d'expiration du token + $expiration = date('Y-m-d', time()+$duration*3600*24); + + /* [1] Generation d'un token si pas deja dans la BDD + =========================================================*/ + $token_used = true; + // tant qu'un token a deja la meme valeur + while( $token_used ){ + $token = sessionManager::secure_sha1(uniqid()); + + // Verification dans la BDD + $check = Database::getPDO()->prepare("SELECT id_token FROM api_token WHERE token = :token"); + $check->execute( array( ':token' => $token ) ); + + // VRAI un token est identique + $token_used = $check->fetch() !== false; + } + + + /* [2] On cree le token + =========================================================*/ + $create = Database::getPDO()->prepare("INSERT INTO api_token(id_token, token, name, expires) + VALUES(DEFAULT, :token, :name, :expiration)"); + $create->execute(array( + ':token' => $token, + ':name' => $name, + ':expiration' => $expiration + )); + + /* [3] On verifie qu'il a bien ete cree + =========================================================*/ + $created = Database::getPDO()->prepare("SELECT id_token FROM api_token + WHERE token = :token + AND name = :name"); + $created->execute(array( + ':token' => $token, + ':name' => $name + )); + + $created_data = $created->fetch(); + + // Si pas cree, on retourne une erreur + if( $created_data === false ) return false; + + + /* [4] On retourne l'id du token cree + =========================================================*/ + return $created_data['id_token']; + + } + + + + + /* SUPPRIME UN TOKEN D'ID SPECIFIE + * + * @id_token UID du token en question + * + * @return status VRAI si le token est bien cree sinon FALSE + * + */ + public static function remove($id_token){ + /* [0] Verification des INPUT + =========================================================*/ + if( !Database::check('id', $id_token) ) return false; + + + /* [1] On verifie l'existance du token + =========================================================*/ + if( !self::getById($id_token) ) return false; + + + /* [2] Suppression du token + =========================================================*/ + $remove = Database::getPDO()->prepare("DELETE FROM api_token + WHERE id_token = :id_token"); + $remove->execute(array( ':id_token' => $id_token )); + + + /* [3] On retourne VRAI si le token est bien supprime + =========================================================*/ + return self::getById($id_token) === false; + } + + } + + +?> \ No newline at end of file diff --git a/manager/sessionManager.php b/manager/sessionManager.php index 3963e00..94e0212 100755 --- a/manager/sessionManager.php +++ b/manager/sessionManager.php @@ -20,6 +20,7 @@ /* INITIALISATION DE SESSION */ /*****************************/ private static function reset_session($session_id=null){ + // On ferme la session session_destroy(); @@ -36,7 +37,6 @@ // On met a jour le token self::update_token(); - header('Refresh: 0'); } @@ -85,17 +85,15 @@ if( !$valid_sessid ) self::reset_session( $sessid ); // On initialise la session (bon id session) - - // si id session invalide /* [3] Verification du token ==============================================================*/ // On verifie que le token est valide - $valid_token = $session_token != null; // verification de l'existence du cookie - $valid_token = $valid_token && strpos($session_token, self::$prefix) === 0; // verification des donnes personnelles - $valid_token = $valid_token && isset($_SESSION['session_token']); // verification que la variable session associee existe - $valid_token = $valid_token && $_SESSION['session_token'] == $_COOKIE['session_token']; // verification que la session est coherente + $valid_token = $session_token != null; // verification de l'existence du cookie + $valid_token = $valid_token && strpos($session_token, self::$prefix) === 0; // verification des donnes personnelles + $valid_token = $valid_token && isset($_SESSION['session_token']); // verification que la variable session associee existe + $valid_token = $valid_token && $_SESSION['session_token'] == $_COOKIE['session_token']; // verification que la session est coherente /* [4] Si token inexistant ==============================================================*/ diff --git a/src/static/container/token.svg b/src/static/container/token.svg new file mode 100644 index 0000000..5866d52 --- /dev/null +++ b/src/static/container/token.svg @@ -0,0 +1,49 @@ + +image/svg+xml \ No newline at end of file diff --git a/view.php b/view.php index a21f538..fb0edf6 100755 --- a/view.php +++ b/view.php @@ -61,14 +61,20 @@ CALL LOG Tableau de bord +
+ Presentation +
+ Acquisition
Questionnaire Facebook - Journal d'appel + Journal telephonique
+ Statistiques Visualisation + Paramètres
Gestion des tokens diff --git a/view/dashboard.php b/view/dashboard.php index 85b3edd..4c0ae7f 100755 --- a/view/dashboard.php +++ b/view/dashboard.php @@ -19,7 +19,7 @@ -
+
sexe


diff --git a/view/js/settings.js b/view/js/settings.js new file mode 100644 index 0000000..f3a5139 --- /dev/null +++ b/view/js/settings.js @@ -0,0 +1,84 @@ + +/* [1] Gestion des tokens +=========================================================*/ +var TOKEN = { + add: { // Tout ce qui attrait a l'ajout + toggle: document.getElementById('add-token'), // bouton de toggle pour l'affichage du panel + panel: document.querySelector('div[data-add]'), // formulaire de creation + state: true, // etat (visible ou non) du panel + + name: document.getElementById('add-name'), // nom du token a creer + duration: document.getElementById('add-duration'), // duree du token a creer (en jours) + submit: document.getElementById('add-submit') // validation de la creation + }, + + + remove: { + buttons: document.querySelectorAll('.remove-token') + } +}; + + + + + +/* (1) Gestion de la creation de token */ + + /* (1.1) Gestion du toggle pour le panel de creation */ + TOKEN.add.toggle.addEventListener('click', function(e){ + TOKEN.add.panel.className = (TOKEN.add.state) ? 'active' : ''; // toggle de la classe (visibilite) + TOKEN.add.state = !TOKEN.add.state; // switch de l'etat pour le toggle + }, false); + + /* (1.2) Gestion de la creation */ + TOKEN.add.submit.addEventListener('click', function(e){ + // On redige la requete + var request = { // on ecrit la requete + 'path': 'token/generate', + 'data': [TOKEN.add.name.value, TOKEN.add.duration.value] + }; + + // On lance la requete + api.send(request, function(answer){ + console.log(answer); + // Si la generation effectuee, on recharge la page + if( answer.ModuleError == 0 ) + reload(); + + }, js_access_token); + }, false); + + + + + + + + +/* (2) Gestion de la suppression de token */ +for( var i = 0 ; i < TOKEN.remove.buttons.length ; i++ ){ + + /* (2.0) Pour chaque bouton supprimer, on attache un evenement */ + TOKEN.remove.buttons[i].addEventListener('click', function(e){ + var token_id = e.target.parentNode.getData('id'); + + /* (2.1) Si on ne trouve pas l'id, on retourne une erreur */ + if( token_id == false ){ console.warn('id du token non trouvee'); return; } + + /* (2.2) On lance la suppression */ + var request = { // on ecrit la requete + 'path': 'token/remove', + 'data': [token_id] + }; + + // On lance la requete + api.send(request, function(answer){ + // Si la suppression effectuee, on recharge la page + if( answer.ModuleError == 0 ) + reload(); + + }, js_access_token); + + }, false); + +} \ No newline at end of file diff --git a/view/settings.php b/view/settings.php index 4a377cc..aade2fa 100755 --- a/view/settings.php +++ b/view/settings.php @@ -1,13 +1,72 @@ answer(); + ?> -
- Gestion des tokens +
+ +
Gestion des TOKENS

+ + +
+ +
+ Gestion des accès distants + +
+ + +
Liste des accès distants actifs. Ils seront automatiquement désactivés a la date d'expiration. Veuillez toutefois les supprimer.
+ +
+

+

+ +
+ + +
    + + + "; + // Si token actif + if( !$token['expired'] ) + echo "
    actif
    "; + else + echo "
    Expiré
    "; + + + echo "
    "; + echo "".$token['name'].""; + echo "".Database::frDate($token['expires']).""; + echo "".$token['token'].""; + echo "
    "; + + echo ""; + echo ""; + } + ?> + + + +
+ +