Index: branches/web-klask/css/bluesky.css
===================================================================
--- branches/web-klask/css/bluesky.css	(revision 40)
+++ branches/web-klask/css/bluesky.css	(revision 40)
@@ -0,0 +1,385 @@
+/* 
+** BLUE:SKY - main stylesheet
+** This CSS file makes the webpage look pretty ;-)
+** 
+** March 5, 2006 - (version 1.0)
+** 
+** this is a part of the open source layout by 
+** Jonas John (www.jonasjohn.de) ~ made for oswd.org !
+*/
+
+/* page overall: */
+
+html * { 
+    margin: 0; 
+    padding: 0; 
+    border: 0;
+}
+ 
+body {
+    margin: 0.5em 0em 2em 0em;
+
+    font-size: 100%;
+    font-family: "Lucida Grande", Verdana, Arial, sans-serif;
+    line-height: 1.1em;
+    text-align: center;
+    
+    background-color: #A5DDF8;
+    background-image: url(../images/background.png);
+    background-repeat: repeat-x;
+}
+ 
+#page { 
+    width: 95%; 
+    text-align: left;  
+    margin-left: auto; 
+    margin-right: auto;  
+} 
+
+
+/* header: */
+
+#header {
+    position: relative; 
+    width: 100%;
+    height: 2.8em;
+    color: #fff;
+    vertical-align: middle;
+    text-align: left;
+} 
+
+#header a:link, #header a:visited {
+    color: #FFFFFF;
+    text-decoration: none;
+    font-family: "Trebuchet MS", Arial, Tahoma, sans-serif;
+    font-weight: bold;
+    font-size: 1.9em;
+    letter-spacing: -0.1em !important;
+    letter-spacing: -0.2em;
+    line-height: 1.2em;
+}
+
+
+/* left column: */
+
+#left {
+    width: 24%; 
+    float: left; 
+    position: relative; 
+    font-size: 0.8em;
+}
+
+div#nav {
+    background-color: #fff;
+    width: 90%;   
+    border-right: 0.18em solid #4284B5;
+    border-bottom: 0.16em solid #4284B5;
+}
+    
+#nav ul {
+    list-style-type: none;
+    padding: 0.5em 0em 0.9em 0em;
+}
+
+#nav ul li {
+    padding: 0.2em 0em 0.2em 0.9em;
+    margin-right: 0.3em;
+}
+
+#nav a:link, #nav a:visited {
+    color: #2E668B;
+}
+ 
+#nav a:hover, #nav a:active {
+    color: #000;
+}
+
+div.left_box {
+    background-color: #fff;
+    width: 90%;
+    margin-top: 1em;
+    border-right: 0.18em solid #4284B5;
+    border-bottom: 0.16em solid #4284B5;
+
+}
+
+div.left_box h3, div#nav h3 {
+    margin: 0em;
+    padding: 0.2em 0em 0.2em 1em;
+    font-size: 0.8em;
+    color: #fff;
+    border-top: 0.1em solid #65B6E3;   
+    border-left: 0.1em solid #65B6E3;   
+    background-color: #4284B5;
+    text-transform: uppercase;
+    font-family: Verdana, Arial, sans-serif;
+}
+
+div.left_box p {
+    margin: 0em;
+    padding: 1em 1em 1em 1em;
+}
+
+div.left_box a:link {
+    color: #2E668B;
+}
+    
+div.left_box a:visited {
+    color: #254A65; 
+}
+ 
+div.left_box a:hover, div.left_box a:active {
+    color: #000;
+}
+
+div.inner_box {
+    border-right: 0.15em solid #7BA5C6;
+    border-bottom: 0.15em solid #7BA5C6;
+}
+
+
+
+/* content column: */
+
+#content {
+    float: right; 
+    display: inline; 
+    position: relative; 
+    width: 75%; 
+    font-size: 0.75em;
+    
+    background-color: #fff;
+
+    border-right: 0.2em solid #4284B5;
+    border-bottom: 0.2em solid #4284B5;
+}
+
+#content h1 {
+    clear: both;
+    margin: 0em 0em 0em 0em;
+    padding: 0.5em 0em 0em 0.1em;
+    font-size: 1.7em;
+    font-family: "Trebuchet MS", Arial, sans-serif;
+    color: #FF6300;
+    border-bottom: 0.05em solid #FF9853;
+    line-height: 1em;
+}
+
+#content p {
+    margin: 0em 0em 0.5em 0em;
+    padding: 0.35em;
+}
+
+#path {
+    font-family: Verdana, Arial, sans-serif;
+    margin: 0em 0em 0em 0em;
+    padding: 0.4em 0.6em 0.4em 0.6em;
+    font-size: 0.9em;
+    color: #2F5E80;
+    background-color: #D0E7F4;
+    border-right: 0.23em solid #7BA5C6;
+}
+
+#content a:link {
+    color: #2E668B;
+}
+    
+#content a:visited {
+    color: #255270; 
+}
+ 
+#content a:hover, #content a:active {
+    color: #000;
+}
+
+#content acronym {
+    border-bottom: 1px dotted #4284B5;
+    cursor: help;
+    margin: 0;
+    padding: 0;
+}
+
+#main {
+    padding: 0.5em 1.5em 1.5em 0.7em;
+    border-bottom: 0.2em solid #7BA5C6;
+    border-right: 0.2em solid #7BA5C6;
+}
+
+INPUT {
+     color:#000000;
+     background-color:#D0E7F4;
+     font-size:15px;
+     font-family:arial;
+	font-weight: normal;  
+}
+
+INPUT#login {
+     color:#000000;
+     background-color:#D0E7F4;
+     font-size:12px;
+     font-family:arial;
+	 font-weight: normal;  
+}
+
+SELECT {
+     color:#000000;
+     background-color:#D0E7F4;
+     font-size:15px;
+     font-family:arial;
+	 font-weight: normal; 
+	 
+	 
+}
+
+TABLE {
+#border: medium solid #6495ed;
+#border-collapse: collapse;
+width: 100%;
+font-size: 8px;
+}
+
+TABLE#klask {
+#border: medium solid #6495ed;
+#border-collapse: collapse;
+width: 100%;
+font-size: 8px;
+}
+
+TR{
+font-family: sans-serif;
+font-size: 15px;
+border: thin solid #6495ed;
+width: 50%;
+padding: 5px;
+text-align: center;
+background-color: #ffffff;
+}
+
+TD{
+font-family: sans-serif;
+font-size: 14px;
+#border: thin solid #6495ed;
+width: 10%;
+padding: 5px;
+text-align: left;
+background-color: #ffffff;
+#font-weight: bold;
+}
+
+TD#title{
+font-family: sans-serif;
+font-size: 15px;
+#border: thin solid #6495ed;
+width: 10%;
+padding: 5px;
+text-align: left;
+background-color: #ffffff;
+font-weight: bold;
+}
+
+TD#klask{
+font-family: sans-serif;
+font-size: 10px;
+#border: thin solid #6495ed;
+width: 10%;
+padding: 5px;
+text-align: left;
+background-color: #ffffff;
+font-weight: bold;
+}
+
+TD#submit{
+font-family: sans-serif;
+font-size: 15px;
+#border: thin solid #6495ed;
+width: 50%;
+padding: 5px;
+text-align: center;
+background-color: #ffffff;
+font-weight: bold;
+}
+
+
+TABLE#login {
+#border: medium solid #6495ed;
+#border-collapse: collapse;
+width: 100%;
+font-size: 12px;
+}
+
+TR#login{
+font-family: sans-serif;
+font-size: 12px;
+border: thin solid #6495ed;
+width: 50%;
+padding: 5px;
+text-align: center;
+background-color: #ffffff;
+}
+
+TD#login{
+font-family: sans-serif;
+font-size: 12px;
+#border: thin solid #6495ed;
+width: 50%;
+padding: 5px;
+text-align: left;
+background-color: #ffffff;
+font-weight: bold;
+}
+
+div.img_left, div.img_right {
+    border-bottom: 0.09em solid #4284B5;
+    border-right: 0.1em solid #4284B5;
+}
+
+div.img_left {
+    float: left; 
+    margin: 0.5em 0.8em 0em 0em;
+}
+
+div.img_right {
+    float: right; 
+    margin: 0.5em 0em 0em 0.8em;
+}
+
+
+div.img_left img, div.img_right img {
+    display: block;
+    border: 0.35em solid #7BA5C6;
+    margin: 0;
+    padding: 0;
+}
+
+/* this clears floating (e.g images) */
+br.clear {
+    clear: both;
+    display: none;
+}
+
+
+/* footer: */
+
+#footer { 
+    margin: 0em;
+    padding: 0em;
+    font-size: 0.6em;
+    clear: both;
+    color: #027BC1;
+    text-align: right;
+} 
+
+#footer p {
+    margin: 0em;
+    padding: 0.1em;
+}
+
+#footer a:link, #footer a:visited { 
+    color: #027BC1;
+} 
+
+#footer a:hover, #footer a:active { 
+    color: #000000;
+} 
+
+
Index: branches/web-klask/css/bluesky.css.ori
===================================================================
--- branches/web-klask/css/bluesky.css.ori	(revision 40)
+++ branches/web-klask/css/bluesky.css.ori	(revision 40)
@@ -0,0 +1,378 @@
+/* 
+** BLUE:SKY - main stylesheet
+** This CSS file makes the webpage look pretty ;-)
+** 
+** March 5, 2006 - (version 1.0)
+** 
+** this is a part of the open source layout by 
+** Jonas John (www.jonasjohn.de) ~ made for oswd.org !
+*/
+
+/* page overall: */
+
+html * { 
+    margin: 0; 
+    padding: 0; 
+    border: 0;
+}
+ 
+body {
+    margin: 0.5em 0em 2em 0em;
+
+    font-size: 100%;
+    font-family: "Lucida Grande", Verdana, Arial, sans-serif;
+    line-height: 1.1em;
+    text-align: center;
+    
+    background-color: #A5DDF8;
+    background-image: url(../images/background.png);
+    background-repeat: repeat-x;
+}
+ 
+#page { 
+    width: 95%; 
+    text-align: left;  
+    margin-left: auto; 
+    margin-right: auto;  
+} 
+
+
+/* header: */
+
+#header {
+    position: relative; 
+    width: 100%;
+    height: 2.8em;
+    color: #fff;
+    vertical-align: middle;
+    text-align: left;
+} 
+
+#header a:link, #header a:visited {
+    color: #FFFFFF;
+    text-decoration: none;
+    font-family: "Trebuchet MS", Arial, Tahoma, sans-serif;
+    font-weight: bold;
+    font-size: 1.9em;
+    letter-spacing: -0.1em !important;
+    letter-spacing: -0.2em;
+    line-height: 1.2em;
+}
+
+
+/* left column: */
+
+#left {
+    width: 24%; 
+    float: left; 
+    position: relative; 
+    font-size: 0.8em;
+}
+
+div#nav {
+    background-color: #fff;
+    width: 90%;   
+    border-right: 0.18em solid #4284B5;
+    border-bottom: 0.16em solid #4284B5;
+}
+    
+#nav ul {
+    list-style-type: none;
+    padding: 0.5em 0em 0.9em 0em;
+}
+
+#nav ul li {
+    padding: 0.2em 0em 0.2em 0.9em;
+    margin-right: 0.3em;
+}
+
+#nav a:link, #nav a:visited {
+    color: #2E668B;
+}
+ 
+#nav a:hover, #nav a:active {
+    color: #000;
+}
+
+div.left_box {
+    background-color: #fff;
+    width: 90%;
+    margin-top: 1em;
+    border-right: 0.18em solid #4284B5;
+    border-bottom: 0.16em solid #4284B5;
+
+}
+
+div.left_box h3, div#nav h3 {
+    margin: 0em;
+    padding: 0.2em 0em 0.2em 1em;
+    font-size: 0.8em;
+    color: #fff;
+    border-top: 0.1em solid #65B6E3;   
+    border-left: 0.1em solid #65B6E3;   
+    background-color: #4284B5;
+    text-transform: uppercase;
+    font-family: Verdana, Arial, sans-serif;
+}
+
+div.left_box p {
+    margin: 0em;
+    padding: 1em 1em 1em 1em;
+}
+
+div.left_box a:link {
+    color: #2E668B;
+}
+    
+div.left_box a:visited {
+    color: #254A65; 
+}
+ 
+div.left_box a:hover, div.left_box a:active {
+    color: #000;
+}
+
+div.inner_box {
+    border-right: 0.15em solid #7BA5C6;
+    border-bottom: 0.15em solid #7BA5C6;
+}
+
+
+
+/* content column: */
+
+#content {
+    float: right; 
+    display: inline; 
+    position: relative; 
+    width: 75%; 
+    font-size: 0.75em;
+    
+    background-color: #fff;
+
+    border-right: 0.2em solid #4284B5;
+    border-bottom: 0.2em solid #4284B5;
+}
+
+#content h1 {
+    clear: both;
+    margin: 0em 0em 0em 0em;
+    padding: 0.5em 0em 0em 0.1em;
+    font-size: 1.7em;
+    font-family: "Trebuchet MS", Arial, sans-serif;
+    color: #FF6300;
+    border-bottom: 0.05em solid #FF9853;
+    line-height: 1em;
+}
+
+#content p {
+    margin: 0em 0em 0.5em 0em;
+    padding: 0.35em;
+}
+
+#path {
+    font-family: Verdana, Arial, sans-serif;
+    margin: 0em 0em 0em 0em;
+    padding: 0.4em 0.6em 0.4em 0.6em;
+    font-size: 0.9em;
+    color: #2F5E80;
+    background-color: #D0E7F4;
+    border-right: 0.23em solid #7BA5C6;
+}
+
+#content a:link {
+    color: #2E668B;
+}
+    
+#content a:visited {
+    color: #255270; 
+}
+ 
+#content a:hover, #content a:active {
+    color: #000;
+}
+
+#content acronym {
+    border-bottom: 1px dotted #4284B5;
+    cursor: help;
+    margin: 0;
+    padding: 0;
+}
+
+#main {
+    padding: 0.5em 1.5em 1.5em 0.7em;
+    border-bottom: 0.2em solid #7BA5C6;
+    border-right: 0.2em solid #7BA5C6;
+}
+
+INPUT {
+     color:#000000;
+     background-color:#D0E7F4;
+     font-size:15px;
+     font-family:arial;
+	font-weight: normal;  
+}
+
+INPUT#login {
+     color:#000000;
+     background-color:#D0E7F4;
+     font-size:12px;
+     font-family:arial;
+	 font-weight: normal;  
+}
+
+SELECT {
+     color:#000000;
+     background-color:#D0E7F4;
+     font-size:15px;
+     font-family:arial;
+	 font-weight: normal; 
+	 
+	 
+}
+
+TABLE {
+#border: medium solid #6495ed;
+#border-collapse: collapse;
+width: 100%;
+font-size: 8px;
+}
+
+TR{
+font-family: sans-serif;
+font-size: 15px;
+border: thin solid #6495ed;
+width: 50%;
+padding: 5px;
+text-align: center;
+background-color: #ffffff;
+}
+
+TD{
+font-family: sans-serif;
+font-size: 14px;
+#border: thin solid #6495ed;
+width: 10%;
+padding: 5px;
+text-align: left;
+background-color: #ffffff;
+#font-weight: bold;
+}
+
+TD#title{
+font-family: sans-serif;
+font-size: 15px;
+#border: thin solid #6495ed;
+width: 10%;
+padding: 5px;
+text-align: left;
+background-color: #ffffff;
+font-weight: bold;
+}
+
+TD#klask{
+font-family: sans-serif;
+font-size: 10px;
+#border: thin solid #6495ed;
+width: 10%;
+padding: 5px;
+text-align: left;
+background-color: #ffffff;
+font-weight: bold;
+}
+
+TD#submit{
+font-family: sans-serif;
+font-size: 15px;
+#border: thin solid #6495ed;
+width: 50%;
+padding: 5px;
+text-align: center;
+background-color: #ffffff;
+font-weight: bold;
+}
+
+
+TABLE#login {
+#border: medium solid #6495ed;
+#border-collapse: collapse;
+width: 100%;
+font-size: 12px;
+}
+
+TR#login{
+font-family: sans-serif;
+font-size: 12px;
+border: thin solid #6495ed;
+width: 50%;
+padding: 5px;
+text-align: center;
+background-color: #ffffff;
+}
+
+TD#login{
+font-family: sans-serif;
+font-size: 12px;
+#border: thin solid #6495ed;
+width: 50%;
+padding: 5px;
+text-align: left;
+background-color: #ffffff;
+font-weight: bold;
+}
+
+div.img_left, div.img_right {
+    border-bottom: 0.09em solid #4284B5;
+    border-right: 0.1em solid #4284B5;
+}
+
+div.img_left {
+    float: left; 
+    margin: 0.5em 0.8em 0em 0em;
+}
+
+div.img_right {
+    float: right; 
+    margin: 0.5em 0em 0em 0.8em;
+}
+
+
+div.img_left img, div.img_right img {
+    display: block;
+    border: 0.35em solid #7BA5C6;
+    margin: 0;
+    padding: 0;
+}
+
+/* this clears floating (e.g images) */
+br.clear {
+    clear: both;
+    display: none;
+}
+
+
+/* footer: */
+
+#footer { 
+    margin: 0em;
+    padding: 0em;
+    font-size: 0.6em;
+    clear: both;
+    color: #027BC1;
+    text-align: right;
+} 
+
+#footer p {
+    margin: 0em;
+    padding: 0.1em;
+}
+
+#footer a:link, #footer a:visited { 
+    color: #027BC1;
+} 
+
+#footer a:hover, #footer a:active { 
+    color: #000000;
+} 
+
+
Index: branches/web-klask/css/bluesky_large.css
===================================================================
--- branches/web-klask/css/bluesky_large.css	(revision 40)
+++ branches/web-klask/css/bluesky_large.css	(revision 40)
@@ -0,0 +1,26 @@
+/* 
+** BLUE:SKY - lage css stylesheet
+** This CSS file enlarges the text sizes
+** 
+** March 6, 2006 - (version 1.0)
+** 
+** this is a part of the open source layout by 
+** Jonas John (www.jonasjohn.de) ~ made for oswd.org !
+*/
+
+/* import orginal css stylesheet */
+@import url(bluesky.css);
+
+/* then modify it: */
+
+body {
+	font-size: 120%;
+}
+ 
+#header a:link, #header a:visited {
+	letter-spacing: -0.08em;
+}
+
+#footer {
+	font-size: 0.7em;
+}
Index: branches/web-klask/css/handheld.css
===================================================================
--- branches/web-klask/css/handheld.css	(revision 40)
+++ branches/web-klask/css/handheld.css	(revision 40)
@@ -0,0 +1,135 @@
+/* 
+** BLUE:SKY - compact css stylesheet
+** This CSS file makes the webpage look good on
+** small display areas (eg: handheld devices)...
+** 
+** March 6, 2006 - (version 1.0)
+** 
+** this is a part of the open source layout by 
+** Jonas John (www.jonasjohn.de) ~ made for oswd.org !
+*/
+
+body {
+	color: gray;
+	background-color: white;
+	font-family: Verdana, helvetica, arial, sans-serif;
+	font-size: 70%;
+	margin: 0;
+	padding: 0;
+}
+
+#header {
+	margin: 0.3em 1em 0.2em 1em;
+	padding: 0.2em 0em 0.25em 0em;
+	font-size: 1.3em;
+	font-weight: bold;
+}
+
+#header a:link, #header a:visited {
+	color: #004072;
+	text-decoration: none;
+}
+
+#path {
+	color: gray;
+	margin: 0.2em 0em 1em 0em;
+	padding: 0.3em 0.2em 0.3em 0.2em;
+	border: 1px solid #81AFD1;
+}
+
+#content {
+	text-align: justify;
+	line-height: 1.5em;
+	margin: 0 1em 0em 1em;
+	padding: 0;
+}
+
+#content p {
+	margin: 0 0 1.5em 0;
+	padding: 0;
+	line-height: 1.35em;
+}
+
+#content a {
+	color: gray;
+	background-color: transparent;
+	text-decoration: underline;
+}
+
+#content a:hover {
+	color: #4682B4;
+	background-color: transparent;
+	text-decoration: none;
+}
+
+#content h1 {
+	clear: both;
+	font-family: Verdana, helvetica, arial, sans-serif;
+	font-size: 1.45em;
+	font-weight: bold;
+	margin: 1em 0em 0.3em 0em;
+	padding: 0.5em 0em 0em 0em;
+}
+
+div.img_left {
+    float: left;     
+	margin: 0.5em 0.8em 0em 0em;
+}
+
+div.img_right {
+    float: right;     
+	margin: 0.5em 0em 0em 0.8em;
+}
+
+div.img_left img, div.img_right img {
+    display: block;
+    border: 0.35em solid #7BA5C6;
+    padding: 0;
+	
+	/* 
+	experimental: 
+	width: 70%;
+	height: 70%;
+	*/
+}
+
+br.clear {
+	display: none;
+	clear: both;
+}
+
+acronym {
+	border-bottom: 0.06em dotted #666;
+}
+
+.left_box {
+	display: none;
+}
+
+#nav {
+	clear: both;
+	margin: 0.3em 1em 0.2em 1em;
+}
+
+#nav a:link, #nav a:visited {
+	color: #004072;
+	line-height: 1.4em;
+}
+
+#footer {
+  color: #CCC;
+  margin: 0;
+  padding: 0.25em 5mm 1.25ex 4mm;
+  clear: both;
+}
+
+#footer a {
+  color: #CCC;
+  text-decoration: underline;
+}
+
+#footer a:hover {
+  color: #4682B4;
+  text-decoration: none;
+}
+
Index: branches/web-klask/css/print.css
===================================================================
--- branches/web-klask/css/print.css	(revision 40)
+++ branches/web-klask/css/print.css	(revision 40)
@@ -0,0 +1,120 @@
+/* 
+** BLUE:SKY - css print stylesheet
+** This CSS file makes sure that the page is looking
+** good when it gets printed. 
+** 
+** March 5, 2006 - (version 1.0)
+** 
+** this is a part of the open source layout by 
+** Jonas John (www.jonasjohn.de) ~ made for oswd.org !
+*/
+
+html * { 
+	margin: 0; 
+	padding: 0; 
+	border: 0;
+}
+
+body { 
+    background: none; 
+    font-size: 100%; 
+    color: #000000;
+    font-family: "Lucida Grande", Verdana, Arial, sans-serif;
+}
+
+
+/* hide these page elements: */
+#left, #path {
+    display:none;
+} 
+
+
+#header {     
+    border-bottom: 0.05em solid #666;
+}
+
+#header a:link, #header a:visited {
+    color: #666666;
+    text-decoration: none;
+    font-family: "Trebuchet MS", Arial, Tahoma, sans-serif;
+    font-weight: bold;
+    font-size: 1.8em;
+    letter-spacing: -0.1em;
+    line-height: 1.2em;
+}
+
+
+#page {
+    width: 100%; 
+    margin: 0em; 
+    background-color: transparent; 
+}
+
+#content {
+    width: 100%; 
+    font-size: 0.95em;
+}
+
+#content h1 {
+    border: none; 
+    clear: both;
+    margin: 0em 0em 0em 0em;
+    padding: 0.5em 0em 0em 0.1em;
+    font-size: 1.4em;
+    font-family: "Trebuchet MS", Arial, sans-serif;
+    color: #666666;
+}
+
+#content p {
+    margin: 0em 0em 0.5em 0em;
+    padding: 0.2em;
+}
+
+#content a:link, #content a:visited {
+    color: #000080;
+}
+
+/* special features (mozilla only) */
+
+/* Prints the link url after the link text (mozilla/ff only) */
+#content p a[href]:after {  
+    content: " < " attr(href) ">";
+    font-size: 0.7em;
+}
+
+/* Prints the title after the acronyms (mozilla/ff only) */
+acronym:after { 
+    content: " (" attr(title) ")";
+    font-style: normal;
+}
+    
+div.img_left {
+    float: left; 
+    margin: 0.5em 0.8em 0em 0em;
+    border: none;
+}
+
+div.img_right {
+    float: right; 
+    margin: 0.5em 0em 0em 0.8em;
+    border: none;
+}
+
+div.img_left img, div.img_right img {
+    border: 0.2em solid #CCCCCC;
+}
+
+br.clear {
+    clear:both;
+    display: none;
+}
+
+
+#footer {     
+    border-top: 0.1em solid #666;
+    color: #000;
+    font-size: 0.8em; 
+    text-align: right;
+    margin: 2.3em 0em 0.5em 0em;
+}
+
Index: branches/web-klask/ctrl.php
===================================================================
--- branches/web-klask/ctrl.php	(revision 40)
+++ branches/web-klask/ctrl.php	(revision 40)
@@ -0,0 +1,103 @@
+<?
+
+function ctrlAuth() {
+	//session_start();
+	if ((!isset($_SESSION['login'])) or (!isset($_SESSION['passwd']))) {
+		
+		return 0;
+	}else{
+		return 1;
+	}
+}
+
+function auth($idLogin, $passwd) {
+
+   if ( $idLogin == $GLOBALS['adminApp'] ) {
+		$GLOBALS['auth'] = "classic" ;
+	}
+
+   if ( $GLOBALS['auth'] == "ldap" ) {
+	  // must exist in database user
+	  $resultat = selectUser($idLogin);
+	  if ( !is_string($resultat) ) {
+                while ( $row = mysql_fetch_assoc($resultat) ) {
+                   if ( $row['idUser'] == $idLogin ) {
+                      return auth_ldap($idLogin, $passwd) ;
+		   }
+		 }
+                return "ACCESS DENIED FOR USER $idLogin";
+           }
+         
+	   
+	}else{
+		if (  $GLOBALS['auth'] == "classic" ) {
+			
+			return  auth_user($idLogin, $passwd);
+		}
+	}
+	
+}
+
+function ctrlEmpty($value, $saisie) {
+	if (empty($value) ) {
+		return "le champs $saisie est obligatoire";
+	}else{
+		return 1;
+	}
+}
+
+function ctrlUnixAccount($idLogin) {
+	$command='id '.$idLogin ;
+	
+	if ( exec($command) ) {
+		return  1;
+	}else{
+		return 0;
+	}	
+}
+
+function ctrlIP($ip){
+	
+	$Tsplit= split("[.]" , $ip ) ;
+
+	if ( count($Tsplit) != 4 ) {
+		return "Adresse IP non valide";
+	}
+	return 1;
+}
+
+function ctrlMac($mac) {
+	$Tsplit = split("[:]", $mac);
+	
+	if ( count($Tsplit ) != 6 ) {
+		return "Adresse MAC non valide";
+	}
+	
+	return 1;
+	
+}
+
+
+function ctrlAddressNetwork($addressNetwork) {
+	
+	$Tsplit = split("[/]", $addressNetwork); 
+	if ( count($Tsplit) != 2) {
+		return "Adresse Network non valide : netmask non saisie";
+	}
+	
+	if ( !is_numeric($Tsplit[1]) ) {
+		return "Adresse Network non valide : netmask non valide";
+	}
+	
+	$TsplitIP= split("[.]" , $Tsplit[0] ) ;
+
+	if ( count($TsplitIP) != 4 ) {
+		return "Adresse Network non valide";
+	}
+	
+	return 1;
+}
+
+
+      
+?>
Index: branches/web-klask/index-inc.php
===================================================================
--- branches/web-klask/index-inc.php	(revision 40)
+++ branches/web-klask/index-inc.php	(revision 40)
@@ -0,0 +1,178 @@
+<?
+
+require('./conf/config.php');
+require('./ctrl.php');
+require('./libDisplay.php');
+
+
+
+if ( !empty($_GET['section']) ) {
+	if ( $_GET['section'] == "checkAuth" )
+	{
+		
+		
+		
+		$result = auth ($_POST['textIdLogin'], $_POST['textPasswd']) ;
+		if ( $result == 1 )  {
+			
+			$buffer = "<TABLE>";
+			$_SESSION['login']=$_POST['textIdLogin'];
+			$_SESSION['passwd']=$_POST['textPasswd'];
+			
+			$buffer .= "<TR><TD>" . contentdefault() . "</TD></TR>"  ;
+			//header('Refresh: 2; url=./index.php');
+			$buffer .= "</TABLE>" ;
+		}else{
+			$buffer = "<h1>Authentification</h1>";
+			$buffer .= "<TABLE>";
+			$buffer .= "<TR><TD>$result</TD></TR>" ;
+			$buffer .= "</TABLE>" ;
+		}
+		
+		echo $buffer ;
+	}else{
+	   if ( empty($_SESSION['login'])) {
+			echo "ACCESS DENIED";
+			return;
+	   }   
+	   if ( $_GET['section'] =="addUser") {
+			echo displayAddUser();
+	   }else{
+		   if (    $_GET['section'] =="addService" ) {
+			   echo displayAddService();
+			}else{
+				if ( $_GET['section'] =="addSwitch" ) {
+					echo displayAddSwitch();
+				}else{
+					if ( $_GET['section'] =="addPower" ) {
+						echo displayAddPower();
+					}else{
+						if ( $_GET['section'] =="addPowerUser" ) {
+							echo displayAddUserPower();
+						}else{
+							if ( $_GET['section'] =="addUserService" ) {
+								echo displayAddUserService();
+							}else{
+								if ( $_GET['section'] =="addSwitchService" ) {
+								echo displayAddSwitchService();
+								}else{
+									if ( $_GET['section'] =="addPowerService" ) {
+										echo displayAddPowerService();
+									}else{
+										
+										if ( $_GET['section'] =="allService" ) {
+											echo displayAllService();
+										}else{
+											if ( $_GET['section'] =="allSwitch" ) {
+												echo displayAllSwitch();
+											}else{
+												if ( $_GET['section'] =="powerUser" ) {
+													echo displayPowerUser("","");
+												}else{
+													if ( $_GET['section'] =="powerService" ) {
+														echo displayPowerService("","");
+													}else{
+														 if ( $_GET['section'] =="delUser") {
+															echo displayDelUser();
+														}else{
+															if ( $_GET['section'] =="delPower" ) {
+																echo displayDelPower();
+															}else{
+																if ( $_GET['section'] =="delService" ) {
+																	echo displayDelService();
+																}else{
+																	if ( $_GET['section'] =="delSwitch" ) {
+																		echo displayDelSwitch();
+																	}else{
+																		if ( $_GET['section'] =="addNetwork" ) {
+																			echo displayAddNetwork();
+																		}else{
+																			
+																			if ( $_GET['section'] =="addDevice" ) {
+																				echo displayAddDevice();
+																			}else{
+																				if ( $_GET['section'] =="allDevice" ) {
+																					echo displayAllDevice();
+																				}else{
+																					if ( $_GET['section'] =="allNetwork" ) {
+																						echo displayAllNetwork();
+																					}else{
+																						if ( $_GET['section'] =="delDevice" ) {
+																							echo displayDelDevice();
+																						}else{
+																							if ( $_GET['section'] =="delNetwork" ) {
+																								echo displayDelNetwork();
+																							}else{
+																								
+																								if ( $_GET['section'] =="genKlaskConf" ) {
+																									echo displayGenKlaskConf();
+																								}else{
+																									
+																									if ( $_GET['section'] =="klaskExportdb" ) {
+																										echo displayKlaskExportdb();
+																									}else{
+																										if ( $_GET['section'] =="klaskUpdatesw" ) {
+																											echo displayKlaskUpdateSw() ;
+																										}else{
+																											if ( $_GET['section'] =="klaskUpdatedb" ) {
+																												echo displayKlaskUpdateDb() ;
+																											}else{
+																												
+																												if ( $_GET['section'] =="klaskExportsw" ) {
+																													echo displayKlaskExportSw() ;
+																												}else{
+																													if ( $_GET['section'] =="klaskGenmap" ) {
+																														echo displayKlaskGenMap() ;
+																													}else{
+																														if ( $_GET['section'] =="updateSwitch" ) {
+																															echo displayUpdateSwitch($_GET['switch']); 
+																														}else{
+																															if ( $_GET['section'] =="klaskSearch" ) {
+																																echo displaySearch(); 
+																															}else{
+																																if ( ctrlAuth() == 0 ) {
+																																	echo displayAuthUser();
+																																}
+																															}
+																														}
+																													}
+																												}
+																											}
+																										}
+																									}
+																								}
+																							}
+																						}
+																					}
+																				}
+																			}
+																		}
+																	}
+																}
+															}
+														}
+													}
+												}
+											}
+										}
+									}
+								}
+							}
+						}
+					}
+				}
+		   }   
+	    }
+	   
+	}
+
+}else{
+	echo contentdefault();
+}
+
+
+
+
+
+
+?>
Index: branches/web-klask/index.php
===================================================================
--- branches/web-klask/index.php	(revision 40)
+++ branches/web-klask/index.php	(revision 40)
@@ -0,0 +1,169 @@
+<?php
+session_start();
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+    <title>Web Klask</title>
+    
+    <meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
+    
+    <meta name="generator" content="Jonas John" />
+    <meta name="description" content="put a good description in here" />
+    <meta name="keywords" content="good,keywords" />
+    
+    <link rel="stylesheet" type="text/css" href="css/bluesky.css" media="screen, tv, projection" title="Default" />
+    <link rel="alternative stylesheet" type="text/css" href="css/bluesky_large.css" media="screen, projection, tv" title="Larger Fonts" />
+    
+    <link rel="alternative stylesheet" type="text/css" href="css/print.css" media="screen" title="Print Preview" />
+    <link rel="alternative stylesheet" type="text/css" href="css/handheld.css" media="screen" title="Small Layout Preview" />
+    
+    <link rel="stylesheet" type="text/css" href="css/handheld.css" media="handheld" title="Small Layout" />
+    <link rel="stylesheet" type="text/css" href="css/print.css" media="print" />
+
+    <!-- Navigational metadata (an accessibility feature - preview in opera) -->
+    <link rel="top" href="index.html" title="Homepage" />
+    <link rel="up" href="index.html" title="Up" />
+    <link rel="first" href="index.html" title="First page" />
+    <link rel="previous" href="index.html" title="Previous page" />
+    <link rel="next" href="index.html" title="Next page" />
+    <link rel="last" href="index.html" title="Last page" />
+    <link rel="toc" href="index.html" title="Table of contents" />
+    <link rel="index" href="index.html" title="Site map" />
+	
+</head>
+<body>
+
+<div id="page">
+    
+    <div id="header">
+        <a href="index.php">ENS LYON</a>
+    </div>
+    
+<!--    <div id="wrapper"> -->
+        
+        <div id="content">
+        
+            <div id="path">
+                <a href="./index.php">HomePage</a>
+            </div>
+    
+            <div id="main">
+
+                <!-- <h1>Welcome !</h1> -->
+					
+                <!--<p>-->
+                  <?
+					
+					include('./index-inc.php');
+				
+					?>
+                <!--</p>-->
+                
+            </div>
+
+        </div>
+        
+        <div id="left">
+
+            <div id="nav">
+            
+                <h3>Klask</h3>
+
+                <div class="inner_box">
+
+                    <ul>
+						<li>
+						<?
+							//mettre ici l'include du menu de navigation
+							//session_start();
+							if ( ctrlAuth() == 0 ) {
+								echo displayAuthUser();
+							}else{
+								echo navKlask();
+							}
+						?>
+                        </li>
+                    </ul>                
+                </div>
+                
+				<h3>AFFICHER</h3>
+				
+				<div class="inner_box">
+
+                    <ul>
+						<li>
+						<?
+							//mettre ici l'include du menu de navigation
+							//session_start();
+							if ( ctrlAuth() == 0 ) {
+								//echo displayAuthUser();
+							}else{
+								echo navDisplay();
+							}
+						?>
+                        </li>
+                    </ul>                
+                </div>
+				
+				 <h3>AJOUTER</h3>
+				
+				<div class="inner_box">
+
+                    <ul>
+						<li>
+						<?
+							//mettre ici l'include du menu de navigation
+							//session_start();
+							if ( ctrlAuth() == 0 ) {
+								//echo displayAuthUser();
+							}else{
+								echo navAdd();
+							}
+						?>
+                        </li>
+                    </ul>                
+                </div>
+				
+				
+				<h3>Supprimer</h3>
+				
+				<div class="inner_box">
+
+                    <ul>
+						<li>
+						<?
+							//mettre ici l'include du menu de navigation
+							//session_start();
+							if ( ctrlAuth() == 0 ) {
+								//echo displayAuthUser();
+							}else{
+								echo navDel();
+							}
+						?>
+                        </li>
+                    </ul>                
+                </div>
+				
+                <!-- i love clean source code -->
+                
+            </div>
+        </div>
+
+<!--    </div> -->
+    
+    <div id="footer">
+        <p>
+             License GPL V2 <a href="index.html">WebKlask</a>. 
+            Webdesign disponible sur <a href="http://www.oswd.org">Open Source Web Design</a>  by <a href="http://www.jonasjohn.de/">Jonas John</a>. 
+            
+            <!-- please leave a small credit to the author - thanks :-) ! -->
+            
+        </p>
+    </div>
+
+</div>
+
+</body>
+</html>
Index: branches/web-klask/install-inc.php
===================================================================
--- branches/web-klask/install-inc.php	(revision 40)
+++ branches/web-klask/install-inc.php	(revision 40)
@@ -0,0 +1,148 @@
+<?
+
+require('./libInstall.php');
+require('./ctrl.php');
+require('./libDisplay.php');
+
+if ( empty($_GET['section'] )) {
+	
+   echo displaySaisieDB() ;
+}
+
+if ($_GET['section'] == "selectAuth" ) {
+	
+	echo displayChooseAuth() ;
+}
+
+if ( $_GET['section'] == "auth") {
+	
+	if ( $_POST['radioAuth'] == "ldap" ) {
+		echo displaySaisieLDAP() ;
+	}else{
+			$buffer = "<h1>Fin de l'installation</h1>";
+			$buffer .= "<TABLE>";
+			$buffer .= "<TR><TD>PrÃ©-requis pour l'application fonctionne</TD></TR>";
+			$buffer .= "<TR><TD> - klask fonctionnel en ligne de commande</TD></TR>";
+			$buffer .= "<TR><TD> - klask doit Ãªtre configurÃ© avec le bon path pour le fichier klask.conf /var/www/guiKlask/klask/klask.conf</TD></TR>";
+			$buffer .= "<TR><TD> - Utilisateur www-data dans le fichier sudoer UNIQUEMENT pour la commande /usr/sbin/klask</TD></TR>";
+			$buffer .= "<TR><TD><a href=\"./index.php\">Poursuivre</a></TD></TR></TABLE>";
+			echo $buffer ;
+	}
+	
+}
+
+
+
+
+if ( $_GET['section'] == "saisieDB" ) {
+	
+	$buffer = "<h1>Installation: RÃ©sultat de la saisie des paramÃštres</h1>";
+	$buffer .= "<TABLE>";
+	if ( empty($_POST['textHostDB']) or empty($_POST['textNameDB']) or empty($_POST['textUserCreateDB']) or empty($_POST['textPasswdCreateDB']) or empty($_POST['textUserDB' ]) or empty($_POST['textPasswdDB']) or empty($_POST['textAdminApp']) or empty($_POST['textPasswdAdminApp']) ) {
+		
+		$buffer .= "<TR><TD>Les champs hÃŽte, nom de la base, utilisateur autorisÃ© Ã  crÃ©er une base, mot de passe de l'utilisateur autorisÃ©, nom de lutilisateur pour l'accÃšs de l'application Ã  la base de donnÃ©es, et le mot de passe de l'utilisateur pour l'accÃšs Ã  la base de donnÃ©es sont OBLIGATOIRES.</TD></TR> ";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR>";
+		
+    }else{
+	    
+       $resultat = createDatabase($_POST['textHostDB'], $_POST['textNameDB'], $_POST['textUserCreateDB'], $_POST['textPasswdCreateDB'], $_POST['textUserDB'], $_POST['textPasswdDB'] , $_POST['textAdminApp'], $_POST['textPasswdAdminApp']);
+
+	   if ( $resultat == 1 ) {
+		  
+		  $buffer .= "<TR><TD>CREATE DATABASE: [OK]</TD></TR>";
+		  $buffer .= "<TR><TD>CREATE ACCESS DATABASE FOR " . $_POST['textUserDB'] .": [OK]</TD></TR>";
+		  $buffer .= "<TR><TD>CREATE TABLE USER: [OK]</TD></TR>";
+		  $buffer .= "<TR><TD>CREATE TABLE SERVICE: [OK]</TD></TR>";  
+		  $buffer .= "<TR><TD>CREATE TABLE SERVICEUSER: [OK]</TD></TR>"; 
+		  $buffer .= "<TR><TD>CREATE TABLE POWER: [OK]</TD></TR>";  
+		  $buffer .= "<TR><TD>CREATE TABLE CMDUSER: [OK]</TD></TR>";
+		  $buffer .= "<TR><TD>CREATE TABLE CMDSERVICE: [OK]</TD></TR>";
+		  $buffer .= "<TR><TD>CREATE TABLE SWITCH: [OK]</TD></TR>";  
+		  $buffer .= "<TR><TD>CREATE TABLE CMDSWITCH: [OK]</TD></TR>";
+		  $buffer .= "<TR><TD>CREATE TABLE SERVICESWITCH: [OK]</TD></TR>";
+		$buffer .= "<TR><TD>CREATE TABLE NETWORK: [OK]</TD></TR>";
+		$buffer .= "<TR><TD>CREATE TABLE DEVICE: [OK]</TD></TR>";
+		  $buffer .= "<TR><TD>INSERT POWER FOR TABLE SERVICESWITCH: [OK]</TD></TR>";  
+		  $buffer .= "<TR><TD>INSERT ADMIN ACCOUNT FOR TABLE USER: [OK]</TD></TR>";    
+		  
+		  $resultat = createFileConfig($_POST['textHostDB'], $_POST['textNameDB'], $_POST['textUserDB'], $_POST['textPasswdDB'], $_POST['textAdminApp']);
+		
+		  if ( $resultat == 1 ) {
+			$buffer .="<TR><TD>CREATE FILE ./conf/config.php: [OK]</TD></TR>";
+   		  }else{
+			  $buffer .= "<TR><TD>$resultat</TD></TR>" ;
+			  $buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR>";
+		  }
+		
+		$buffer .= "<TR><TD><a href=\"./install.php?section=selectAuth\">Etape suivante</a></TD></TR>";  
+		
+		}else{
+			$buffer .= "<TR><TD>$resultat</TD></TR>" ;
+			$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR>";
+		}
+
+   }
+	
+	$buffer .= "</TABLE>";
+	echo $buffer ;
+	
+}
+
+  if ( $_GET['section'] == "createFileAuth" ) {
+	
+	$buffer ="<h1>Installation: RÃ©sultat de la  saisie des parmÃštres</h1>";
+	$buffer .= "<TABLE>";
+	if ( empty($_POST['textHostLdap']) or empty($_POST['textBindUser']) or empty($_POST['textService'] ) ) {
+		
+		$buffer .= "<TR><TD>Les champs Nom du serveur LDAP, Bind des Utilisateurs, champs du service d'affectation de l'utilisateur sont obligatoires</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR>";
+	}else{
+		
+		$resultat = createFileLDAP($_POST['textHostLdap'], $_POST['textBindUser'], $_POST['textService']) ;
+		if ( $resultat == 1 ) {
+			$buffer .= "<TR><TD>Fin de l'installation</TD></TR>";
+			$buffer .= "<TR><TD>PrÃ©-requis pour l'application fonctionne</TD></TR>";
+			$buffer .= "<TR><TD> - klask fonctionnel en ligne de commande</TD></TR>";
+			$buffer .= "<TR><TD> - klask doit Ãªtre configurÃ© avec le bon path pour le fichier klask.conf /var/www/guiKlask/klask/klask.conf</TD></TR>";
+			$buffer .= "<TR><TD> - Utilisateur www-data dans le fichier sudoer UNIQUEMENT pour la commande /usr/sbin/klask</TD></TR>";
+			$buffer .= "<TR><TD><a href=\"./index.php\">Poursuivre</a></TD></TR>";
+			$buffer .= "<TR><TD>CREATE FILE ./ldap/auth_ldap.php : [OK]</TD></TR>";
+			
+		}else{
+			
+			$buffer .= "<TR><TD>$resultat</TD></TR>";
+			$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR>";
+			
+		}
+		
+	}
+	
+	$buffer .= "</TABLE>";
+	
+	echo $buffer;
+	
+}
+
+	
+function displaySaisieInstall() {
+	
+	//Nom de la base
+	//Nom de l'utilisateur pour la crÃ©ation de la base
+	//Password de l'utilisateur pour la crÃ©ation de la base
+	//CrÃ©ation de la base
+	
+	//Demande si c'est une auth LDAP ou mysql avec comme contrainte d'exister dans le /etc/passwd
+	
+}
+
+
+
+
+
+
+
+
+
+
+
+?>
Index: branches/web-klask/install.php
===================================================================
--- branches/web-klask/install.php	(revision 40)
+++ branches/web-klask/install.php	(revision 40)
@@ -0,0 +1,83 @@
+<?
+session_start();
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+    <title>blue:sky - welcome</title>
+    
+    <meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
+    
+    <meta name="generator" content="Jonas John" />
+    <meta name="description" content="put a good description in here" />
+    <meta name="keywords" content="good,keywords" />
+    
+    <link rel="stylesheet" type="text/css" href="css/bluesky.css" media="screen, tv, projection" title="Default" />
+    <link rel="alternative stylesheet" type="text/css" href="css/bluesky_large.css" media="screen, projection, tv" title="Larger Fonts" />
+    
+    <link rel="alternative stylesheet" type="text/css" href="css/print.css" media="screen" title="Print Preview" />
+    <link rel="alternative stylesheet" type="text/css" href="css/handheld.css" media="screen" title="Small Layout Preview" />
+    
+    <link rel="stylesheet" type="text/css" href="css/handheld.css" media="handheld" title="Small Layout" />
+    <link rel="stylesheet" type="text/css" href="css/print.css" media="print" />
+
+    <!-- Navigational metadata (an accessibility feature - preview in opera) -->
+    <link rel="top" href="index.html" title="Homepage" />
+    <link rel="up" href="index.html" title="Up" />
+    <link rel="first" href="index.html" title="First page" />
+    <link rel="previous" href="index.html" title="Previous page" />
+    <link rel="next" href="index.html" title="Next page" />
+    <link rel="last" href="index.html" title="Last page" />
+    <link rel="toc" href="index.html" title="Table of contents" />
+    <link rel="index" href="index.html" title="Site map" />
+	
+</head>
+<body>
+
+<div id="page">
+    
+    <div id="header">
+        <a href="index.html">ENS LYON</a>
+    </div>
+    
+    <div id="wrapper"> 
+        
+        <div id="content">
+        
+            <div id="path">
+                A NICE GUI FOR KLASK
+            </div>
+    
+            <div id="main">
+
+                <!-- <h1>Welcome !</h1> -->
+					
+                <p>
+                  <?
+					
+					include('./install-inc.php');
+				
+					?>
+                </p>
+                
+            </div>
+
+        </div>
+        
+	</div>
+    
+    <div id="footer">
+        <p>
+             License GPL V2 <a href="index.html">WebKlask</a>.
+            Webdesign disponible sur <a href="http://www.oswd.org">Open Source Web Design</a>  by <a href="http://www.jonasjohn.de/">Jonas John</a>.
+            
+            <!-- please leave a small credit to the author - thanks :-) ! -->
+            
+        </p>
+    </div>
+
+</div>
+
+</body>
+</html>
Index: branches/web-klask/libDevice.php
===================================================================
--- branches/web-klask/libDevice.php	(revision 40)
+++ branches/web-klask/libDevice.php	(revision 40)
@@ -0,0 +1,177 @@
+<?
+
+
+
+
+function addDevice($mac, $hostname, $ip, $type) {
+	$link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	return $buffer;
+}
+
+
+$db_selected = @mysql_select_db($GLOBALS['nameDB'], $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sÃ©lectionner la base de donnÃ©es :$nameDB"  . mysql_error();
+    }
+
+
+
+//Add switch
+$sql = "INSERT INTO DEVICE VALUE('$mac', '$hostname', '$ip', '$type');";
+
+if (mysql_query($sql, $link)) {
+   $buffer = 1;
+} else {
+   $buffer = "CREATE DEVICE $idSwicth: [FAILED] :" . mysql_error() ;
+}
+
+return $buffer;
+}
+	
+
+
+
+
+
+function selectDevice($filter) {
+//connect DB
+$link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	return $buffer;
+}
+
+
+$db_selected = @mysql_select_db($GLOBALS['nameDB'], $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sÃ©lectionner la base de donnÃ©es :$nameDB"  . mysql_error();
+    }
+
+	
+	if (empty($filter)) {
+		$sql = "SELECT * FROM DEVICE";
+	}else{
+		$sql = "SELECT * FROM DEVICE WHERE $filter ;"  ;
+	}
+
+
+if ($result = mysql_query($sql, $link)) {
+	//test if $return is_array
+    return  $result ;
+
+} else {
+   $buffer = "SELECT DEVICE : [FAILED] :" . mysql_error() ;
+    return $buffer ;   
+}
+
+
+}
+
+
+
+
+
+function delDevice($hostname) {
+
+$buffer = "";
+
+//connect DB
+$link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	return $buffer;
+}
+
+
+$db_selected = @mysql_select_db($GLOBALS['nameDB'], $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sÃ©lectionner la base de donnÃ©es :$nameDB"  . mysql_error();
+    }
+
+
+//Before  del user of Table USER, del user in all others Table
+//del switch from CMDSWITCH
+$sql="DELETE FROM CMDSWITCH WHERE idSwitch='$hostname';";
+if (mysql_query($sql, $link)) {
+   $buffer .= "DELETE SWITCH $hostname FROM CMDSWITCH: [OK]<BR />";
+} else {
+   $buffer = "DELETE SWITCH $hostname FROM CMDSWITCH: [FAILED] :" . mysql_error() ;
+    return $buffer;
+}
+
+//del switch from SERVICESWITCH
+$sql = "DELETE FROM  SERVICESWITCH WHERE idSwitch='$hostname'";
+if (mysql_query($sql, $link)) {
+   $buffer .= "DELETE SWITCH $hostname FROM SERVICESWITCH: [OK]<BR />";
+} else {
+   $buffer = "DELETE SWITCH $hostname FROM SERVICESWITCH: [FAILED] :" . mysql_error() ;
+   return $buffer;
+}
+
+
+//del switch
+$sql = "DELETE FROM SWITCH WHERE idswitch='$hostname';";
+
+if (mysql_query($sql, $link)) {
+   $buffer .= "DELETE SWITCH $hostname: [OK]<BR />";
+} else {
+   $buffer = "DELETE SWITCH $hostname: [FAILED] :" . mysql_error() ;
+    return $buffer;   
+}
+
+//dev Device
+$sql = "DELETE FROM DEVICE WHERE hostname='$hostname';";
+
+if (mysql_query($sql, $link)) {
+   $buffer .= "DELETE DEVICE $hostname: [OK]<BR />";
+} else {
+   $buffer = "DELETE DEVICE $hostname: [FAILED] :" . mysql_error() ;
+    return $buffer;   
+}
+
+
+return $buffer;
+}
+
+
+function updateDevice($hostname, $mac, $ip, $type) {
+
+//connect DB^M
+$link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+        return $buffer;
+}
+
+
+$db_selected = @mysql_select_db($GLOBALS['nameDB'], $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sÃ©lectionner la base de donnÃ©es :$nameDB"  . mysql_error();
+    }
+
+
+//update Device
+$sql = "UPDATE DEVICE SET 
+        mac='$mac',
+        ip='$ip',
+        type='$type',
+        hostname='$hostname'
+        WHERE hostname='$hostname' ;" ;
+
+if (mysql_query($sql, $link)) {
+   $buffer = 1;
+} else {
+   $buffer = "UPDATE DEVICE $hostname: [FAILED] :" . mysql_error() ;
+}
+
+
+
+return $buffer;
+
+
+}
+
+
+?>
Index: branches/web-klask/libDisplay.php
===================================================================
--- branches/web-klask/libDisplay.php	(revision 40)
+++ branches/web-klask/libDisplay.php	(revision 40)
@@ -0,0 +1,2437 @@
+<?
+require('./libUser.php');
+require('./libService.php');
+require('./libRight.php');
+require('./libSwitch.php');
+require('./libDevice.php');
+require('./libNetwork.php');
+require('./libKlask.php');
+if ($GLOBALS['auth'] == "ldap") {
+	require('./ldap/auth_ldap.php');
+	require('./libLDAP.php');
+}
+
+/***************************************************************************************
+displayAuthUser()
+displayAddUser()
+displayResultAdduser($idLogin, $passwdUser, $service)
+displayDelUser()
+displayResultDelUser($idLogin)
+displayAddSwitch()
+displayResultAddSwitch($idSwitch, $ip, $mac, $type, $location, $level, $portIgnore, $service)
+displayDelSwitch()
+displayResultDelSwitch($idSwitch) 
+displayUpdateSwitch($idSwitch)
+displayResultUpdateSwitch($idSwitch, $ip, $mac, $type, $location, $level, $portIgnore)
+displayAllSwitch()
+displayAddService()
+displayResultAddService($idService) 
+displayDelService()
+displayResultDelService($service)
+displayAllService() 
+displayAddPower()
+displayResultAddPower($idPower, $descPower)
+displayDelPower()
+displayResultDelPower($power) 
+displayAddUserPower() 
+displayResultAddUserPower($user, $power)
+displayDelUserPower()
+displayResultDelUserPower($user, $power)
+displayResultDelUserPowerBydisplayAllPower($userPower)
+displayPowerUser($idLogin)
+displayPowerService($idService) 
+displayAddPowerService()
+displayResultAddPowerService($power, $service)
+displayResultDelUserPowerBydisplayAllPower($servicePower)
+displayAddUserService()
+displayResultAddUserService($user, $service)
+displayAddSwitchService() 
+displayResultAddSwitchService($switch, $service)
+displayAddNetwork()
+displayAllNetwork()
+displayResultAddNetwork($addressNetwork, $nameNetwork, $interface,  $routeur) 
+displayDelNetwork()
+displayResultDelNetwork($network) 
+displayAllDevice()
+displayAddDevice()
+displayResultAddDevice($hostname, $mac, $ip,  $type)
+displayDelDevice() 
+displayResultDelDevice($device)
+
+	
+****************************************************************************************/
+
+function contentdefault() {
+	$buffer = "<h1>WEB KLASK</h1>";
+	$buffer .= "De trÃšs nombreux outils rÃ©seaux existent mais la plupart permettent de tracer des cartographies de rÃ©seau basÃ©es sur la notion de route. Au niveau d'un rÃ©seau local commutÃ©, cette notion de route n'apporte rien et ce genre d'outil n'est en gÃ©nÃ©ral pas capable de structurer la carte locale des machines. L'administrateur d'un site de taille moyenne, quelques bÃ¢timents, une quinzaine de commutateurs, se retrouvent rapidement devant les problÃ©matiques suivantes :<BR /><BR />";
+	$buffer .="- OÃ¹ est positionnÃ©e la machine X ? Elle est Ã  l'origine d'un problÃšme rÃ©seau urgent Ã  traiter, quitte Ã  la dÃ©connecter en dÃ©sactivant le port du commutateur ;<BR />";
+	$buffer .= "- Deux machines A et B de mon rÃ©seau local ne dialoguent pas. Quel est le chemin physique menant de la machine A vers la machine B ?<BR /><BR />";
+	$buffer .= "Rapidement, lorsque son parc machine augmente, il devient difficile de maintenir une version papier Ã  jour de son rÃ©seau local, notamment s'il y a des mouvements de personnel... Il est possible d'amÃ©liorer les choses en configurant le matÃ©riel actif de maniÃšre Ã  n'associer certaines adresses physiques (MAC) de machine qu'Ã  certains ports de commutateur.Cependant, cela ne rÃ©sout pas forcÃ©ment tous les problÃšmes, notamment le second.<BR /><BR />"; 
+	
+	$buffer .= "Klask est un petit outil, dans l'esprit des outils UNIX, de ne se prÃ©occuper que des connections sur le rÃ©seau local. Cependant, Klask fonctionne sur un rÃ©seau comportant plusieurs classe rÃ©seau et plusieurs VLAN. Pour configurer Klask, consulter la page MultiVlan.<BR /><BR />";
+	
+//	$buffer .= "<b><a href=\"./install.php\">Pour lancer la procÃ©dure d'installation</a></b>";
+	return $buffer ;
+}
+
+
+
+function navAdd() {
+	
+		$buffer  = "<a href=\"./index.php?section=addUser\">Utilisateur</a><BR />";
+		$buffer  .= "<a href=\"./index.php?section=addDevice\">Device</a><BR />";
+		$buffer  .= "<a href=\"./index.php?section=addService\">Service</a><BR />";
+		$buffer  .= "<a href=\"./index.php?section=addSwitch\">Switch</a><BR />";
+//		$buffer  .= "<a href=\"./index.php?section=addPower\">Droits</a><BR />";
+		$buffer  .= "<a href=\"./index.php?section=addNetwork\">RÃ©seau</a><BR />";
+		
+		$buffer  .= "<a href=\"./index.php?section=addUserService\">Service Ã  un utilisateur</a><BR />";
+		$buffer  .= "<a href=\"./index.php?section=addSwitchService\">Service Ã  un switch</a><BR />";
+		$buffer  .= "<a href=\"./index.php?section=addPowerUser\">Droits Ã  un utilisateur</a><BR />";
+		$buffer  .= "<a href=\"./index.php?section=addPowerService\">Droits Ã  un service</a><BR />";
+		
+		
+		
+	
+//		$buffer  .= "<a href=\"./index.php?section=delPower\">Supprimer un droit ou commande</a><BR><BR>";
+		return $buffer ;
+	
+}
+
+
+function navDel() {
+	
+		$buffer  = "<a href=\"./index.php?section=delUser\">Supprimer un utilisateur</a><BR />";
+		$buffer  .= "<a href=\"./index.php?section=delService\">Supprimer un Service</a><BR />";
+		$buffer  .= "<a href=\"./index.php?section=delDevice\">Supprimer un Device</a><BR />";
+		$buffer  .= "<a href=\"./index.php?section=delSwitch\">Supprimer un Switch</a><BR />";
+		$buffer  .= "<a href=\"./index.php?section=delNetwork\">Supprimer un RÃ©seau</a><BR />";
+		return $buffer ;
+	
+}
+
+
+function navDisplay() {
+	
+		$buffer  = "<a href=\"./index.php?section=allDevice\">Afficher les Devices</a><BR />";
+		$buffer  .= "<a href=\"./index.php?section=allNetwork\">Afficher les RÃ©seaux</a><BR />";
+		$buffer  .= "<a href=\"./index.php?section=allService\">Afficher les services</a><BR />";
+		$buffer  .= "<a href=\"./index.php?section=allSwitch\">Afficher les switchs</a><BR />";
+		$buffer  .= "<a href=\"./index.php?section=powerUser\">Afficher les droits des utilisateurs</a><BR />";
+		$buffer  .= "<a href=\"./index.php?section=powerService\">Afficher les droits des services</a><BR />";
+		return $buffer ;
+		
+}
+
+
+function navklask() {
+	$buffer  = "<a href=\"./index.php?section=genKlaskConf\">GÃ©nÃ©rer le fichier klask</a><BR />";
+	$buffer  .= "<a href=\"./index.php?section=klaskExportdb\">Liste des machines</a><BR />";
+	$buffer  .= "<a href=\"./index.php?section=klaskExportsw\">Liste des switch et de leurs liaisons</a><BR />";
+	$buffer  .= "<a href=\"./index.php?section=klaskUpdatesw\">Mise Ã  jour de lase base des Switch</a><BR />";
+	$buffer  .= "<a href=\"./index.php?section=klaskUpdatedb\">Detection de machines</a><BR />";
+	$buffer  .= "<a href=\"./index.php?section=klaskGenmap\">GÃ©nÃ©rer la carte du rÃ©seau</a><BR />";
+#	$buffer  .= "<a href=\"./index.php?section=klaskSearch\">Rechercher une machine sur le rÃ©seau</a><BR />";
+	return $buffer ;
+}
+
+
+function displayAuthUser() {
+	
+	$buffer = "<FORM METHOD=\"POST\" ACTION=\"./index.php?section=checkAuth\">";
+	$buffer .= "<TABLE id='login'>";
+	$buffer .= "<TR><TD id='login'>Authentification</TD></TR>";
+	$buffer .= "<TR><TD id='login'>Login</TD></TR>";
+	$buffer .= "<TR><TD id='login'><INPUT id='login' TYPE=\"TEXT\" NAME=\"textIdLogin\"></INPUT></TD></TR>";
+	$buffer .= "<TR><TD id='login'>Mot de passe</TD></TR>";
+	$buffer .= "<TR><TD id='login'><INPUT id='login' TYPE=\"PASSWORD\" NAME=\"textPasswd\"></INPUT></TD></TR>";
+	$buffer .= "<TR><TD id='login'><INPUT id='login' TYPE=\"SUBMIT\" VALUE=\"VALIDER\"></TD></TR>";
+	$buffer .= "</TABLE></FORM>";
+  
+    return $buffer;  
+		
+}
+
+
+
+function displayAddUser() {
+	
+	$buffer = "<h1>AJout d'un utlisateur</h1>";
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "addUser", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR> </TABLE>";
+		return $buffer ;
+	}
+	
+	$buffer .= "<FORM METHOD=\"POST\" ACTION=\"./resultat.php?section=addUser\">";
+	
+	$buffer .= "<TABLE id=\"Add\">";
+	
+	$buffer .= "<TR><TD id=title>Login de l'uilisateur (ID): </TD><TD><INPUT TYPE=\"TEXT\" NAME=\"textIdLogin\"></INPUT></TD></TR>";
+	//TODO: attention si auth ldap, ne pas aller ici 
+	
+    if ( $GLOBALS['auth'] == "classic" ) {
+		
+		$buffer .= "<TR><TD id=title>Mot de passe: </TD><TD><INPUT TYPE=\"TEXT\" NAME=\"textPasswdUser\"></INPUT></TD></TR>";
+		
+		$resultat = selectService("") ;
+		//display for debugger
+	    //echo "type de ressources: " .get_resource_type($resultat);
+		if ( !is_string($resultat) ) {
+			$buffer .= "<TR><TD id=title>Service</TD><TD><SELECT  NAME=\"selectIdService[]\" MULTIPLE SIZE=5>";
+			while ( $row = mysql_fetch_assoc($resultat) ) {
+				$buffer .= "<OPTION VALUE=\"".$row['idService']. "\">".$row['idService']."</OPTION>";
+			}
+			$buffer .= "</SELECT></TD></TR>";
+		}else{
+			$buffer .="<TD>$resultat</TD></TR>";
+		}
+		
+	}
+	
+	$buffer .= "<TR><TD id='submit' COLSPAN=2><INPUT TYPE=\"SUBMIT\" NAME=\"AJOUTER\"></INPUT></TD></TR></TABLE></FORM>";
+	
+	return $buffer;
+	
+}
+
+function displayResultAdduser($idLogin, $passwdUser, $service) {
+	
+	$buffer = "<h1>Resultat de la commande</h1>";
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "addUser", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR> </TABLE>";
+		return $buffer ;
+	}
+	
+	
+	$buffer .= "<TABLE>";
+	$resultat = 0;
+	$resultat = ctrlEmpty($idLogin,  "Login Utilisateur");
+	if ( $resultat != 1 ){
+		
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	if ( ctrlUnixAccount($idLogin) == 0 and $GLOBALS['auth'] == "ldap" ) {
+	
+	$buffer .= "<TR></TD>L'utilisateur n'existe pas dans l'annuaire</TD></TR>";
+	$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+	return $buffer ;
+	}
+
+	
+	//if auth classic, ctrl user's passwd
+	 if ( $GLOBALS['auth'] == "classic" )  {
+		$resultat = 0;
+		$resultat = ctrlEmpty($passwdUser,  "Mot de passe");
+		if ( $resultat != 1 ){
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR> </TABLE>";
+		return $buffer ;
+		}
+	}
+	
+	//if auth ldap get user's service
+	 if ( $GLOBALS['auth'] == "ldap" )  {
+		$service = getServiceLDAP($idLogin);
+	}	
+	$resultat = 0;
+	$resultat = ctrlEmpty($service,  "Service");
+	if ( $resultat != 1 ){
+		
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR> </TABLE>";
+		return $buffer ;
+	}
+	
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "addUser", "" );
+	if ( $resultat != 1 ){
+		
+		$buffer .="<TR><TD>ACCESS DENIED FOR THIS COMMAND $idPower FOR ". $_SESSION['login'] ."</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR> </TABLE>";
+		return $buffer ;
+		
+	}
+	
+	//TODO: to clear
+	//echo "libDisplay.resultaddUser.php md5 saisie passe: " .  md5($passwdUser) . " et md5 adm " .md5("adm") . "<br>";
+	$resultat = 0;
+	$resultat = addUserDB($idLogin, $passwdUser);
+	if ($resultat == 1 ) {
+	   	$buffer .= "<TR><TD>CREATE USER $idLogin: [OK]</TD></TR>";
+		
+	}else{
+		$buffer .= "<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR>";
+		return $buffer ."</TABLE>";
+	}
+	
+	if ( $GLOBALS['auth'] == "ldap" )  {
+
+		for ( $cpt=0;$cpt<$service['count'];$cpt++) {
+		//foreach ( $service as $idService ) {
+			//Verify if service exist. If service not exist then add service.
+			//This function is only avalaible for ldap auth 
+			$resultat = selectService($service[$cpt]) ;
+			if (  !is_string($resultat) ) {
+				$rowService = mysql_fetch_assoc($resultat) ;
+				if ( $rowService['idService'] != $service[$cpt] ) {
+					$resService = addService($service[$cpt]) ;
+					if ($resService == 1 ) {
+						$buffer .= "<TR><TD>ADD SERVICE $service[$cpt] : [OK]</TD></TR>";		
+					}else{
+						$buffer .= "<TR><TD>$resService</TD></TR>";
+						$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR>";
+						return $buffer ."</TABLE>";
+					}
+				}
+			}
+			$resultat = addUserService($idLogin, $service[$cpt]);
+			if ($resultat == 1 ) {
+				$buffer .= "<TR><TD>ADD SERVICE $service[$cpt] FOR $idLogin: [OK]</TD></TR>";		
+			}else{
+				$buffer .= "<TR><TD>$resultat</TD></TR>";
+				$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR>";
+				return $buffer ."</TABLE>";
+			}
+		}
+	}else{
+		foreach ( $service as $idService ) {
+			$resultat = addUserService($idLogin, $idService);
+			if ($resultat == 1 ) {
+				$buffer .= "<TR><TD>ADD SERVICE $idService FOR $idLogin: [OK]</TD></TR>";		
+			}else{
+				$buffer .= "<TR><TD>$resultat</TD></TR>";
+			$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR>";
+		    return $buffer ."</TABLE>";
+			}
+		}
+		
+		
+	}
+	
+	$buffer .="</TABLE>";
+	return $buffer;
+}
+
+function displayDelUser() {
+	
+	$buffer = "<h1>Utilisateur(s) Ã  supprimer: </h1>";
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "delUser", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	
+	$buffer .= "<FORM METHOD=\"POST\" ACTION=\"./resultat.php?section=delUser\">";
+    $buffer .= "<TABLE>";	
+	
+	
+	$resultat = selectUser("") ;
+	//TODO display for debugger
+	//echo "type de ressources: " .get_resource_type($resultat);
+	if ( !is_string($resultat) ) {
+		$buffer .= "<TR><TD id=title>Utilisateurs</TD><TD><SELECT  NAME=\"selectUser[]\" MULTIPLE SIZE=5>";
+	   while ( $row = mysql_fetch_assoc($resultat) ) {
+         $buffer .= "<OPTION VALUE=\"".$row['idUser']."\">".$row['idUser']."</OPTION>";
+	   }
+	    $buffer .= "</SELECT></TD></TR>";
+		$buffer .= "<TR><TD id='submit' COLSPAN=2><INPUT TYPE=\"SUBMIT\" VALUE=\"SUPPRIMER\"></TD></TR>";
+	}else{
+		$buffer .="<TD>$resultat</TD></TR>";
+	}
+	$buffer .= "</TABLE></FORM>";
+	return $buffer ;
+	
+}
+
+
+function displayResultDelUser($idLogin) {
+	
+	$buffer = "<h1>Utilisateur(s) Ã  supprimer: </h1>";
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "delUser", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+   $buffer .= "<TABLE>";
+   $resultat = ctrlEmpty($idLogin, "Login Utilisateur");
+	if ( $resultat != 1 ){
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}   
+   foreach ($idLogin as $value) {
+       $resultat = delUserDB($value);
+	   $buffer .= "<TR><TD>$resultat</TD></TR>";  
+   }
+   $buffer .= "</TABLE>";
+   return $buffer ;
+}
+
+
+function displayAddSwitch() {
+
+	$buffer = "<h1>AJout d'un switch </h1>";
+//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "addSwitch", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+
+    $buffer .= "<FORM METHOD=\"POST\" ACTION=\"./resultat.php?section=addSwitch\">";
+	$buffer .= "<TABLE>";
+	
+	$buffer .= "<TR><TD id=title>Nom du switch (ID): </TD><TD><SELECT NAME=\"selectIdSwitch\">";
+
+	$filter = "(type = 'switch' OR type = 'routeur') AND hostname NOT IN (SELECT idSwitch FROM SWITCH) ; ";	
+	//$filter = "type = 'switch'";
+	$resultat = selectDevice($filter) ;
+	if ( !is_string($resultat) ) {
+		
+	   while ( $rowDevice = mysql_fetch_assoc($resultat) ) {
+				$buffer .= "<OPTION VALUE=\"" . $rowDevice['hostname'] . "\">" . $rowDevice['hostname'] . "</OPTION>" ;
+		}
+		
+    }
+	$buffer .= "</SELECT></TD></TR>";
+
+
+	$buffer .= "<TR><TD id=title>Location: </TD><TD><INPUT TYPE=\"TEXT\" NAME=\"textLocation\"></INPUT></TD></TR>";
+	$buffer .= "<TR><TD id=title>Level: </TD><TD><INPUT TYPE=\"TEXT\" NAME=\"textLevel\"></INPUT></TD></TR>";
+	$buffer .= "<TR><TD id=title>Port Ã  Ignorer: </TD><TD><INPUT TYPE=\"TEXT\" NAME=\"textPortIgnore\"></INPUT></TD></TR>";
+	
+	//TODO verifier la cohÃ©rence du code pour l'affectation d'un ou plusieurs services Ã  un switch
+	$buffer .= "<TR><TD id=title>Service (choix multiple maintenir la touche ctrl): </TD>";
+	
+	
+	$resultat = selectService("") ;
+	//display for debugger
+	//echo "type de ressources: " .get_resource_type($resultat);
+	if ( !is_string($resultat) ) {
+		$buffer .= "<TD><SELECT NAME=\"selectIdService[]\" MULTIPLE SIZE=5>";
+	   while ( $row = mysql_fetch_assoc($resultat) ) {
+         $buffer .= "<OPTION VALUE=\"".$row['idService']."\">".$row['idService']."</OPTION>";
+	   }
+	    $buffer .= "</SELECT></TD></TR>";
+	}else{
+		$buffer .="<TD>$resultat</TD></TR>";
+	}
+	
+	
+	
+	$buffer .= "<TR><TD id='submit' COLSPAN=2><INPUT TYPE=\"SUBMIT\" NAME=\"AJOUTER\"></INPUT></TD></TR></TABLE></FORM>";
+	
+	return $buffer;
+
+}
+
+function displayResultAddSwitch($idSwitch, $location, $level, $portIgnore, $service) {
+    
+	$buffer = "<h1>RÃ©sultat de la commande</h1>";
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "addSwitch", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	
+	$buffer .= "<TABLE>";
+	
+	$resultat = ctrlEmpty($idSwitch, "Nom du Switch");
+	if ( $resultat != 1 ){
+		$buffer .= "<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	/*$resultat = ctrlIP($ip) ;
+	if ( $resultat != 1 ) {
+		return "<TR><TD>$resultat</TD></TR></TABLE>";
+	}
+	
+	$resultat = ctrlEmpty($mac, "Adresse Mac");
+	if ( $resultat != 1 ){
+		return "<TR><TD>$resultat</TD></TR></TABLE>";
+	}
+	
+	$resultat = ctrlMac($mac);
+	if ( $resultat != 1 ){
+		return "<TR><TD>$resultat</TD></TR></TABLE>";
+	}*/
+	
+	$resultat = ctrlEmpty($service, "service du switch");
+	if ( $resultat != 1 ){
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	
+	$resultat = addSwitch($idSwitch, $location, $level, $portIgnore, $service);
+	
+	if ($resultat == 1 ) {
+	   	$buffer .= "<TR><TD>CREATE SWITCH $idSwitch, $location, $level, $portIgnore: [OK]</TD></TR>";
+	}else{
+		$buffer .= "<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR>";
+	}
+	
+	//link switch to a service
+	foreach ( $service as $idService) {
+		
+	   $resultat = addSwitchService($idSwitch, $idService);
+		if ( $resultat == 1 ) {
+			$buffer .= "<TR><TD>Switch $idSwitch linked to $idService: [OK]</TD</TR>";
+		
+        }else {
+		    $buffer .= "<TR><TD>$resultat</TD></TR>";
+		}
+		
+	 }
+	$buffer .="</TABLE>";
+	return $buffer;
+
+}
+
+function displayDelSwitch() {
+	
+	$buffer = "<h1>Switch(s) Ã  supprimer: </h1>";
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "delSwitch", "" );
+	if ( $resultat != 1 ){
+		$buffer = "<TABLE>";
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	$buffer .= "<FORM METHOD=\"POST\" ACTION=\"./resultat.php?section=delSwitch\">";
+	//$buffer = "<FORM METHOD=\"POST\" ACTION=\"./resultat.php?section=delSwitch\">";
+	$buffer .= "<TABLE>";	
+	
+	
+	$resultat = selectSwitch("") ;
+	//display for debugger
+    //echo "type de ressources: " .get_resource_type($resultat);
+	if ( !is_string($resultat) ) {
+		$buffer .= "<TR><TD id=title>Switch</TD><TD><SELECT  NAME=\"selectSwitch[]\" MULTIPLE SIZE=5>";
+	   while ( $row = mysql_fetch_assoc($resultat) ) {
+         $buffer .= "<OPTION VALUE=\"".$row['idSwitch']."\">".$row['idSwitch']."</OPTION>";
+	   }
+	    $buffer .= "</SELECT></TD></TR>";
+		$buffer .= "<TR><TD id='submit' COLSPAN=2><INPUT TYPE=\"SUBMIT\" VALUE=\"SUPPRIMER\"></TD></TR>";
+	}else{
+		$buffer .="<TD>$resultat</TD></TR>";
+	}
+	$buffer .= "</TABLE></FORM>";
+	return $buffer ;
+}
+
+
+function displayResultDelSwitch($idSwitch) {
+	
+	$buffer = "<h1>RÃ©sultat de la commande</h1>";
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "delSwitch", "$idSwitch" );
+	if ( $resultat != 1 ){
+		$buffer = "<TABLE>";
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+   $buffer .= "<TABLE>";
+   $resultat = ctrlEmpty($idSwitch, "Nom du switch");
+	if ( $resultat != 1 ){
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+
+   foreach ($idSwitch as $value) {
+       $resultat = delSwitch($value);
+	   $buffer .= "<TR><TD>$resultat</TD></TR>";  
+   }
+   $buffer .= "</TABLE>";
+   return $buffer;
+}
+
+
+function displayUpdateSwitch($idSwitch) {
+
+	$buffer = "<h1>Mise Ã  jour du switch $idSwitch </h1>";
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "updateSwitch", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+    
+    $buffer .= "<FORM METHOD=\"POST\" ACTION=\"./resultat.php?section=updateSwitch\">";
+	$buffer .= "<TABLE>";
+	
+	
+	$resultat = selectSwitch($idSwitch) ;
+	
+	//echo "type de ressources: " .get_resource_type($resultat);
+	if ( !is_string($resultat) ) {
+		
+	   while ( $row = mysql_fetch_assoc($resultat) ) {
+	      		
+		  $buffer .= "<TR><TD id=title>Nom du switch (ID): </TD><TD><INPUT TYPE=\"TEXT\" NAME=\"textIdSwitch\" VALUE=\"".$row['idSwitch']."\"></INPUT></TD></TR>";
+	      $buffer .= "<TR><TD id=title>IP du switch: </TD><TD><INPUT TYPE=\"TEXT\" NAME=\"textIP\" VALUE=\"".$row['ip']."\"></INPUT></TD></TR>";
+		  $buffer .= "<TR><TD id=title>Adresse Mac du switch (ID): </TD><TD><INPUT TYPE=\"TEXT\" NAME=\"textMac\" VALUE=\"".$row['mac']."\"></INPUT></TD></TR>";
+		  $buffer .= "<TR><TD id=title>Type: </TD><TD><SELECT NAME=\"selectType\">
+					  <OPTION VALUE=\"switch\">Switch</OPTION>
+					  <OPTION VALUE=\"router\">Router</OPTION></SELECT></TD></TR>";
+		  $buffer .= "<TR><TD id=title>Location: </TD><TD><INPUT TYPE=\"TEXT\" NAME=\"textLocation\" VALUE=\"".$row['location']."\"></INPUT></TD></TR>";
+	      $buffer .= "<TR><TD id=title>Level: </TD><TD><INPUT TYPE=\"TEXT\" NAME=\"textLevel\" VALUE=\"".$row['level']."\"></INPUT></TD></TR>";
+	      $buffer .= "<TR><TD id=title>Port Ã  Ignorer: </TD><TD><INPUT TYPE=\"TEXT\" NAME=\"textportIgnore\" VALUE=\"".$row['portIgnore']."\"></INPUT></TD></TR>";
+		
+	   }
+		$buffer .= "<TR><TD id='submit' COLSPAN=7><INPUT TYPE=\"SUBMIT\" VALUE=\"UPDATE\"></TD></TR>";
+	}else{
+		$buffer .="<TD>$resultat</TD></TR>";
+	}
+	
+	
+	$buffer .= "<TR><TD id='submit'><SUBMIT NAME=\"UPDATE\"></TD></TR></TABLE></FORM>";
+	
+	return $buffer;
+
+}
+
+
+function displayResultUpdateSwitch($idSwitch, $ip, $mac, $type, $location, $level, $portIgnore) {
+	
+	$buffer = "<h1>RÃ©sultat de la commande</h1>";
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "updateSwitch", "$idSwitch" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .= "<TR><TD>" . $resultat ."</TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	$buffer .= "<TABLE>";
+	
+	$resultat = ctrlEmpty($idSwitch, "Nom du Switch");
+	if ( $resultat != 1 ){
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	$resultat = ctrlEmpty($ip, "Adresse IP");
+	if ( $resultat != 1 ){
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+
+	$resultat = ctrlIP($ip) ;
+        if ( $resultat != 1 ) {
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+                $buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+                return $buffer ;
+        }
+	
+	$resultat = ctrlEmpty($mac, "Adresse Mac");
+	if ( $resultat != 1 ){
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+
+	$resultat = ctrlMac($mac);
+        if ( $resultat != 1 ){
+                $buffer .="<TR><TD>$resultat</TD></TR>";
+                $buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+                return $buffer ;
+        }
+
+	
+	$resultat = updateSwitch($idSwitch, $location, $level, $portIgnore);
+	
+	
+	if ($resultat == 1 ) {
+	   	$buffer .= "<TR><TD>UPDATE SWITCH $idSwitch, $ip, $mac, $type, $location, $level, $portIgnore: [OK]</TD></TR>";
+	}else{
+		$buffer .= "<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR>";
+	}
+
+
+        //update Device
+        $resultat = updateDevice($idSwitch, $mac, $ip, $type);
+        if ($resultat == 1 ) {
+                $buffer .= "<TR><TD>UPDATE DEVICE $idSwitch, $ip, $mac, $type: [OK]</TD></TR>";
+        }else{
+                $buffer .= "<TR><TD>$resultat</TD></TR>";
+                $buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR>";
+        }
+
+
+
+	$buffer .="</TABLE>";
+	return $buffer;
+
+}
+
+
+function displayAllSwitch() {
+	
+	$buffer = "<h1>Liste des Switch</h1>";
+   $buffer .= "<TABLE>";
+   $buffer .= "<TR><TD id=title>Nom du switch (ID): </TD>
+                              <TD id=title>IP</TD>
+							  <TD id=title>Mac</TD>
+							  <TD id=title>Type</TD>
+                              <TD id=title>Location</TD>
+							  <TD id=title>Level</TD>
+							  <TD id=title>Port Ã  Ignorer</TD>
+                              <TD id=title>Service(s)</TD>
+					  </TR>";
+   $resultat = selectSwitch("") ;
+	
+	//echo "type de ressources: " .get_resource_type($resultat);
+	if ( !is_string($resultat) ) {
+		
+	   while ( $rowSwitch = mysql_fetch_assoc($resultat) ) {
+			
+			//select switch's services
+			$service = "";
+			
+			$resService = selectSwitchService($rowSwitch['idSwitch'], "");
+			//echo "type de ressources: " .get_resource_type($resService);
+			 if ( !is_string($resService) ) {
+				while ( $row = mysql_fetch_assoc($resService) ) {
+				    $service .= $row['idService'] . " ";	
+				}
+			}
+		    $buffer .= "<TR><TD id=klask><a href=\"./index.php?section=updateSwitch&switch=".$rowSwitch['idSwitch']."\">".$rowSwitch['idSwitch']."</a></TD>
+							            <TD id=klask>".$rowSwitch['ip']."</TD>
+                                        <TD id=klask>".$rowSwitch['mac']."</TD>
+                                        <TD id=klask>".$rowSwitch['type']."</TD>
+                                        <TD id=klask>".$rowSwitch['location']."</TD>
+                                        <TD id=klask>".$rowSwitch['level']."</TD>
+										<TD id=klask>".$rowSwitch['portignore']."</TD>
+                                        <TD id=klask>".$service."</TD></TR>";
+	   }
+    }
+	$buffer .= "</TABLE>";
+	return $buffer ;
+}
+
+
+
+function displayAddService() {
+	
+	$buffer = "<h1>AJout d'un service</h1>";
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "addService", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	
+	$buffer .= "<FORM METHOD=\"POST\" ACTION=\"./resultat.php?section=addService\">";
+	$buffer .= "<TABLE>";
+	
+	$buffer .= "<TR><TD id=title>Nom du service: </TD><TD><INPUT TYPE=\"TEXT\" NAME=\"textIdService\"></INPUT></TD></TR>";
+	//$buffer .= "<TR><TD>Description: </TD><TD><INPUT TYPE=\"TEXT\" NAME=\"textDescService\"></INPUT></TD></TR>";
+	$buffer .= "<TR><TD id='submit' COLSPAN=2><INPUT TYPE=\"SUBMIT\" NAME=\"AJOUTER\"></TD></TR></TABLE></FORM>";
+	
+	return $buffer;
+	
+}
+
+function displayResultAddService($idService) {
+	
+	$buffer = "<h1>RÃ©sultat de la commande</h1>";
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "addService", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	$buffer .= "<TABLE>";
+	$resultat = ctrlEmpty($idService, "Service");
+	if ( $resultat != 1 ){
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	$resultat = addService($idService);
+	
+	if ($resultat == 1 ) {
+	   	$buffer .= "<TR><TD>CREATE SERVICE $idService: [OK]</TD></TR>";
+	}else{
+		$buffer .= "<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR>";
+	}
+
+	$buffer .="</TABLE>";
+
+	return $buffer;
+}
+
+
+function displayDelService() {
+	
+	$buffer = "<h1>Service(s) Ã  supprimer: </h1>";
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "delService", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	$buffer .= "<FORM METHOD=\"POST\" ACTION=\"./resultat.php?section=delService\">";
+    $buffer .= "<TABLE>";	
+	
+	
+	$resultat = selectService("") ;
+	//TODO display for debugger
+    //echo "type de ressources: " .get_resource_type($resultat);
+	if ( !is_string($resultat) ) {
+		$buffer .= "<TR><TD id=title>Services</TD><TD><SELECT NAME=\"selectService[]\" MULTIPLE SIZE=5>";
+	   while ( $row = mysql_fetch_assoc($resultat) ) {
+         $buffer .= "<OPTION VALUE=\"".$row['idService']."\">". $row['idService']."</OPTION>";
+	   }
+	    $buffer .= "</SELECT></TD></TR>";
+		$buffer .= "<TR><TD id='submit' COLSPAN=2><INPUT TYPE=\"SUBMIT\" VALUE=\"SUPPRIMER\"></TD></TR>";
+	}else{
+		$buffer .="<TD>$resultat</TD></TR>";
+	}
+	$buffer .= "</TABLE></FORM>";
+	return $buffer ;
+	
+}
+
+function displayResultDelService($service) {
+	
+	$buffer = "<h1>RÃ©sultat de la commande</h1>";
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "delSwitch", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+   $buffer .= "<TABLE>";
+
+   $resultat = ctrlEmpty($service, "Service");
+	if ( $resultat != 1 ){
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+
+   foreach ($service as $idService) {
+       $resultat = delService($idService);
+	   $buffer .= "<TR><TD>$resultat</TD></TR>";  
+   }
+   $buffer .= "</TABLE>";
+   return $buffer ;
+}
+
+
+function displayAllService() {
+	
+   
+	
+   $resultat = selectService("") ;
+	//TODO  to clean
+	//echo "type de ressources: " .get_resource_type($resultat);
+	$bufferSwitchService = "";
+	$bufferUserService = "";
+	if ( !is_string($resultat) ) {
+		
+	   while ( $row = mysql_fetch_assoc($resultat) ) {
+			//SERVICE WITH USER
+			//display checkbox delete for a classic authentification
+				
+			$resUserService = selectUserService("", $row['idService']);
+			if ( !is_string($resUserService) ){
+				//$user = "<TABLE>";
+				$user = "";
+				$checkDelUser = "";
+				$bufferUserService .= "<TR><TD>" .  $row['idService'] . "</TD>";
+				while ( $rowUserService = mysql_fetch_assoc($resUserService) ) {
+					if ($GLOBALS['auth'] == "classic" ) {
+						//$user .= "<TR><TD>" . $rowUserService['idUser'] . "</TD><TD><INPUT TYPE=\"CHECKBOX\" NAME=\"checkUserService[]\" VALUE=\"". $rowUserService['idUser'] . "@" . $row['idService'] . "\" ></TD></TR>";
+						$user .= $rowUserService['idUser'] ."<BR />";
+						$checkDelUser .= "<INPUT TYPE=\"CHECKBOX\" NAME=\"checkUserService[]\" VALUE=\"". $rowUserService['idUser'] . "@" . $row['idService'] . "\" ></INPUT><BR />";
+					}else{
+						//$user .= "<TR><TD>" . $rowUserService['idUser'] . "</TD></TR>";
+						$user .= $rowUserService['idUser'] ."<BR />";
+						
+					}
+				}
+				//$user .= "</TABLE>";
+				$bufferUserService .= "<TD>$user</TD><TD>$checkDelUser</TD></TR>" ;
+			}else{
+				$user = $resUserService ;
+			}
+			
+			//SERVICE WITH SWITCH
+			$resSwitchService = selectSwitchService("", $row['idService']);
+			if ( !is_string($resSwitchService) ){
+				//$switch = "<TABLE>";
+				$switch = "";
+				$checkDel = "";
+				$bufferSwitchService .= "<TR><TD>" .  $row['idService'] . "</TD>";
+				while ( $rowSwitchService = mysql_fetch_assoc($resSwitchService) ) {
+					//$switch .= "<TR><TD>" . $rowSwitchService['idSwitch'] . "</TD><TD><INPUT TYPE=\"CHECKBOX\" NAME=\"checkSwitchService[]\" VALUE=\"". $rowSwitchService['idSwitch'] . "@" . $row['idService'] . "\" ></TD></TR></TR>";
+					
+					$switch .=  $rowSwitchService['idSwitch'] ."<BR />";
+					
+					$checkDel .= "<INPUT TYPE=\"CHECKBOX\" NAME=\"checkSwitchService[]\" VALUE=\"". $rowSwitchService['idSwitch'] . "@" . $row['idService'] . "\" ></INPUT><BR />";
+				}
+				
+				//$switch .="</TABLE>";
+				$bufferSwitchService .= "<TD>$switch</TD><TD>$checkDel</TD></TR>" ;
+				
+			}else{
+					$switch = $resSwitchService ;
+			}
+			
+			
+		   
+	   }
+		
+		$buffer = "<h1>Liste des Services par Utilisateurs</h1>";
+		$buffer .= "<FORM METHOD=\"POST\" ACTION=\"./resultat.php?section=delUserSwitchService\"><TABLE>";
+		$buffer .= "<TR><TD id=title>Nom du service: </TD><TD id=title>Utilisateurs</TD><TD id=title>Supprimer</TD></TR>";
+		$buffer .= $bufferUserService ;
+		$buffer .= "</TABLE>";
+		
+		$buffer .= "<h1>Liste des Services par Switch</h1>";
+		$buffer .= "<TABLE>";
+		$buffer .= "<TR><TD id=title>Nom du service: </TD><TD id=title>Switch</TD><TD id=title>Cocher pour supprimer</TD></TR>";
+		$buffer .= $bufferSwitchService ;
+		
+			$buffer .= "<TR><TD id='submit' COLSPAN=2><INPUT TYPE=\"SUBMIT\" VALUE=\"VALIDER\"></INPUT></TD></TR>";
+		$buffer .="</TABLE></FORM>";
+		
+   }
+
+	return $buffer ;
+	
+}
+
+
+
+function displayAddPower() {
+	
+	$buffer = "<h1>AJout de Droits</h1>";
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "addRight", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	$buffer .= "<FORM METHOD=\"POST\" ACTION=\"./resultat.php?section=addPower\">";
+	$buffer .= "<TABLE>";
+	
+	$buffer .= "<TR><TD id=title>Nom du droit ou commande: </TD><TD><INPUT TYPE=\"TEXT\" NAME=\"textIdPower\"></INPUT></TD></TR>";
+	$buffer .= "<TR><TD id=title>Description du droit ou commande: </TD><TD><INPUT TYPE=\"TEXT\" NAME=\"textDescPower\"></INPUT></TD></TR>";
+	$buffer .= "<TR><TD id='submit' COLSPAN=2><INPUT TYPE=\"SUBMIT\" NAME=\"AJOUTER\" VALUE=\"VALIDER\"></TD></TR></TABLE></FORM>";
+	
+	return $buffer;
+	
+}
+
+
+function displayResultAddPower($idPower, $descPower) {
+	
+	$buffer = "<h1>RÃ©sultat de la commande</h1>";
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "addRight", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	$buffer .= "<TABLE>";
+	$resultat = ctrlEmpty($idPower, "Nom du droit ou de la commande");
+	if ( $resultat != 1 ){
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	$resultat = addPower($idPower, $descPower);
+
+	if ($resultat == 1 ) {
+	   	$buffer .= "<TR><TD>CREATE POWER $idPower: [OK]</TD></TR>";
+	}else{
+		$buffer .= "<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR>";
+	}
+	$buffer .="</TABLE>";
+	return $buffer;
+}
+
+
+
+function displayDelPower() {
+	
+	$buffer = "<h1>Droit(s) ou commande(s) Ã  supprimer: </h1>";
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "delRight", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	$buffer .= "<FORM METHOD=Â \"POST\" ACTION=\"./resultat.php\">";
+    $buffer .= "<TABLE>";	
+	
+	
+	$resultat = selectPower("") ;
+	//TODO display for debugger
+	//echo "type de ressources: " .get_resource_type($resultat);
+	if ( !is_string($resultat) ) {
+		$buffer .= "<TR><TD id=title>Droits</TD><TD><SELECT  NAME=\"selectPower[]\" MULTIPLE SIZE=5>";
+	   while ( $row = mysql_fetch_assoc($resultat) ) {
+         $buffer .= "<OPTION VALUE=\"".$row['idPower']."\">".$row['idPower']."</OPTION>";
+	   }
+	    $buffer .= "</SELECT></TD></TR>";
+		$buffer .= "<TR><TD id='submit' COLSPAN=2><INPUT TYPE=\"SUBMIT\" VALUE=\"SUPPRIMER\"></TD></TR>";
+	}else{
+		$buffer .="<TD>$resultat</TD></TR>";
+	}
+	$buffer .= "</TABLE></FORM>";
+	return $buffer ;	
+}
+
+
+function displayResultDelPower($power) {
+	
+	$buffer = "<h1>RÃ©sultat de la commande</h1>";
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "delRight", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+   $buffer .= "<TABLE>";
+   $resultat = ctrlEmpty($power, "Nom du droit ou de la commande");
+	if ( $resultat != 1 ){
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}   
+   foreach ($power as $idPower) {
+       $resultat = delPower($idPower);
+	   $buffer .= "<TR><TD>$resultat</TD></TR>";  
+   }
+   $buffer .= "</TABLE>";
+   return $buffer ;
+}
+
+
+
+function displayAddUserPower()  {
+	
+	$buffer = "<h1>Ajout de Droits pour un Utilisateur: </h1>";
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "addRight", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	$buffer .= "<FORM METHOD=\"POST\" ACTION=\"./resultat.php?section=addPowerUser\">";
+	$buffer .= "<TABLE>";
+	
+	$resultat = selectUser("") ;
+	//TODO display for debugger
+	//echo "type de ressources: " .get_resource_type($resultat);
+	if ( !is_string($resultat) ) {
+		$buffer .= "<TR><TD id=title>Utilisateur</TD>";
+		$buffer .= "<TD><SELECT NAME=\"selectUser[]\" MULTIPLE SIZE=5>";
+	   while ( $row = mysql_fetch_assoc($resultat) ) {
+         $buffer .= "<OPTION VALUE=\"". $row['idUser']."\">".$row['idUser']."</OPTION>";
+	   }
+	    $buffer .= "</SELECT></TD></TR>";
+	}else{
+		$buffer .="<TD>$resultat</TD></TR>";
+	}
+	
+	$resultat = selectPower("") ;
+	//TODO display for debugger
+	//echo "type de ressources: " .get_resource_type($resultat);
+	if ( !is_string($resultat) ) {
+		$buffer .= "<TR><TD id=title>Droits ou Commandes</TD>";
+		$buffer .= "<TD><SELECT NAME=\"selectPower[]\" MULTIPLE SIZE=5>";
+	   while ( $row = mysql_fetch_assoc($resultat) ) {
+         $buffer .= "<OPTION VALUE=\"".$row['idPower']."\">".$row['idPower']."</OPTION>";
+	   }
+	    $buffer .= "</SELECT></TD></TR>";
+	}else{
+		$buffer .="<TD>$resultat</TD></TR>";
+	}
+	
+	//$buffer .= "</TR>";
+	$buffer .= "<TR><TD id='submit' COLSPAN=2><INPUT TYPE=\"SUBMIT\" VALUE=\"AJOUTER\"></TD></TR>";
+	$buffer .= "</TABLE></FORM>";
+	
+	return $buffer ;
+	
+}
+
+
+function displayResultAddUserPower($user, $power) {
+	
+	$buffer = "<h1>RÃ©sultat de la commande</h1>";
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "addRight", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	
+	$buffer .= "<TABLE>";
+	$resultat = ctrlEmpty($power, "Nom du droit ou de la commande");
+	if ( $resultat != 1 ){
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	$resultat = ctrlEmpty($user, "Login Utilisateur");
+	if ( $resultat != 1 ){
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	foreach ( $user as $idLogin) {
+		foreach ($power as $idPower) {
+		   $resultat = addUserCMD($idLogin, $idPower);
+		   if ($resultat == 1 ) {
+	   	      $buffer .= "<TR><TD id=title>ADD POWER $idPower FOR $idLogin: [OK]</TD></TR>";
+	       }else{
+			  $buffer .= "<TR><TD>$resultat</TD></TR>";
+		      //$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR>";
+	        } 
+		}   
+	}
+	
+	$buffer .="</TABLE>";
+	return $buffer;
+}
+
+function displayDelUserPower()  {
+	
+	$buffer = "<h1>Suppression de Droits: </h1>";
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "delRight", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	
+	$buffer .= "<FORM METHOD=\"POST\" ACTION=\"./resultat.php?section=delUserPower\">";
+	$buffer .= "<TABLE>";
+	
+	$resultat = selectUser("") ;
+	//TODO display for debugger
+	//echo "type de ressources: " .get_resource_type($resultat);
+	if ( !is_string($resultat) ) {
+		$buffer .= "<TD><SELECT NAME=\"selectidLogin[]\" MULTIPLE SIZE=5>";
+	   while ( $row = mysql_fetch_assoc($resultat) ) {
+         $buffer .= "<OPTION VALUE=\"".$row['idLogin']."\">".$row['idLogin']."</OPTION>";
+	   }
+	    $buffer .= "</SELECT></TD>";
+	}else{
+		$buffer .="<TD>$resultat</TD>";
+	}
+	
+	$resultat = selectPower("") ;
+	//TODO display for debugger
+	//echo "type de ressources: " .get_resource_type($resultat);
+	if ( !is_string($resultat) ) {
+		$buffer .= "<TD><SELECT NAME=\"selectPower[]\" MULTIPLE SIZE=5>";
+	   while ( $row = mysql_fetch_assoc($resultat) ) {
+         $buffer .= "<OPTION VALUE=\"".$row['idPower']."\">".$row['idPower']."</OPTION>";
+	   }
+	    $buffer .= "</SELECT></TD>";
+	}else{
+		$buffer .="<TD>$resultat</TD>";
+	}
+	
+	$buffer .= "</TR>";
+	$buffer .= "<TR><TD id='submit'><INPUT TYPE=\"SUBMIT\" VALUE=\"AJOUTER\"></TD></TR>";
+	$buffer .= "</TABLE></FORM>";
+	
+	return $buffer ;
+	
+}
+
+
+function displayResultDelUserPower($user, $power) {
+	
+	$buffer = "<h1>RÃ©sultat de la commande</h1>";
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "delRight", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	$buffer = "<TABLE>";
+	$resultat = ctrlEmpty($power, "Nom du droit ou de la commande");
+	if ( $resultat != 1 ){
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	$resultat = ctrlEmpty($user, "Login Utilisateur");
+	if ( $resultat != 1 ){
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	foreach ( $user as $idLogin) {
+		foreach ($power as $idPower) {
+		   $resultat = delUserCMD($idLogin, $idPower);
+		   if ($resultat == 1 ) {
+	   	      $buffer .= "<TR><TD>DEL POWER $idPower FOR $idLogin: [OK]</TD></TR>";
+	       }else{
+			  $buffer .= "<TR><TD>$resultat</TD></TR>";
+		      $buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR>";
+	        } 
+		}   
+	}
+	
+	$buffer .="</TABLE>";
+	return $buffer;
+}
+
+
+
+function displayPowerUser($idLogin, $idPower) {
+	
+	$buffer = "<h1>Liste des utilisateurs et de leurs droits </h1>";
+	$buffer .= "<FORM METHOD=\"POST\" ACTION=\"./resultat.php?section=delPowerUserByAllPower\">";
+	$buffer .= "<TABLE>";
+	
+	$buffer .= "<TR><TD id=title>UTILISATEUR</TD><TD id=title>DROITS</TD><TD id=title>cocher pour supprimer</TD></TR>";
+	$resultat = selectUserCMD($idLogin, $idPower);
+    if ( !is_string($resultat) ) {
+		
+	   while ( $row = mysql_fetch_assoc($resultat) ) {
+          $buffer .= "<TR><TD>".$row['idUser']."</TD><TD>".$row['idPower']."</TD>";
+		  $buffer .= "<TD> <INPUT TYPE=\"CHECKBOX\" NAME=\"checkPowerUser[]\" VALUE=\"". $row['idUser'] . "@" . $row['idPower'] . "\" ></TD></TR>";
+	   }
+	   
+	}else{
+		$buffer .="<TD>$resultat</TD>";
+	}
+	$buffer .= "<TR><TD id='submit'><INPUT TYPE=\"SUBMIT\" VALUE=\"SUPPRIMER\"></INPUT></TD></TR>";
+	$buffer .= "</TABLE></FORM>";
+	return $buffer ;
+}
+
+function displayResultDelUserPowerBydisplayAllPower($userPower) {
+//check if user can do this command
+	$buffer = "<h1>RÃ©sultat de la commande</h1>";
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "delRight", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	$buffer .= "<TABLE>";
+	
+	foreach ($userPower as $value) {
+		
+		$Tsplit = split("[@]", $value) ;
+		$idLogin = $Tsplit[0] ;
+		$idPower = $Tsplit[1];
+		
+		$resultat = ctrlEmpty($idPower, "Nom du droit ou de la commande");
+		if ( $resultat != 1 ){
+			$buffer .="<TR><TD>$resultat</TD></TR>";
+			$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+			return $buffer ;
+		}
+	
+		$resultat = ctrlEmpty($idLogin, "Login Utilisateur");
+		if ( $resultat != 1 ){
+			$buffer .="<TR><TD>$resultat</TD></TR>";
+			$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+			return $buffer ;
+		}
+	
+		$resultat = delUserCMD($idLogin, $idPower);
+		if ($resultat == 1 ) {
+			$buffer .= "<TR><TD>DEL POWER $idPower FOR $idLogin: [OK]</TD></TR>";
+		}else{
+			$buffer .= "<TR><TD>$resultat</TD></TR>";
+			$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR>";
+		} 
+		   
+	}
+	
+	$buffer .="</TABLE>";
+	return $buffer;
+}
+
+
+function displayPowerService($idService, $idPower) {
+	$buffer = "<h1>Liste des droits par services</h1>";
+	$buffer .= "<FORM METHOD=\"POST\" ACTION=\"./resultat.php?section=delPowerService\">";
+	$buffer .= "<TABLE>";
+	
+	$buffer .= "<TR><TD id=title>SERVICE</TD><TD id=title>DROITS</TD></TR>";
+	$resultat = selectCMDService($idService, $idPower);
+    if ( !is_string($resultat) ) {
+		
+	   while ( $row = mysql_fetch_assoc($resultat) ) {
+          $buffer .= "<TR><TD>".$row['idService']."</TD><TD>".$row['idPower']."</TD><TD><INPUT TYPE=\"checkbox\" NAME=\"checkPowerService[]\" VALUE=\"".$row['idService']."@".$row['idPower']."\"></INPUT></TD></TR>";
+	   }
+	   
+	}else{
+		$buffer .="<TD>$resultat</TD>";
+	}
+	$buffer .= "<TR><TD id='submit' COLSPAN=3><INPUT TYPE=\"SUBMIT\" VALUE=\"SUPPRIMER\"></INPUT></TD></TR>";
+	$buffer .= "</TABLE></FORM>";
+	return $buffer ;
+}
+
+
+
+function displayResultDelServicePower($servicePower) {
+//check if user can do this command
+	$buffer = "<h1>RÃ©sultat de la commande</h1>";
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "delRight", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	$buffer .= "<TABLE>";
+	
+	foreach ($servicePower as $value) {
+		
+		$Tsplit = split("[@]", $value) ;
+		$idService = $Tsplit[0] ;
+		$idPower = $Tsplit[1];
+		
+		$resultat = ctrlEmpty($idPower, "Nom du droit");
+		if ( $resultat != 1 ){
+			$buffer .="<TR><TD>$resultat</TD></TR>";
+			$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+			return $buffer ;
+		}
+	
+		$resultat = ctrlEmpty($idService, "Nom du service");
+		if ( $resultat != 1 ){
+			$buffer .="<TR><TD>$resultat</TD></TR>";
+			$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+			return $buffer ;
+		}
+	
+		$resultat = delCMDService($idService, $idPower) ;
+		if ($resultat == 1 ) {
+			$buffer .= "<TR><TD>DEL POWER $idPower FOR $idPower: [OK]</TD></TR>";
+		}else{
+			$buffer .= "<TR><TD>$resultat</TD></TR>";
+			$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR>";
+		} 
+		   
+	}
+	
+	$buffer .="</TABLE>";
+	return $buffer;
+}
+
+
+
+
+function displayPowerSwicth($idPower, $idLogin,$idSwitch) {
+	$buffer = "<h1>Liste des droits utilisateurs par switch</h1>";
+	$buffer .= "<TABLE>";
+	$buffer .= "<TR><TD id=title>SWITCH</TD><TD id=title>USER</TD><TD id=title>Power</TD></TR>";
+	$resultat = selectUserCMDSwitch($idPower, $idLogin,$idSwitch);
+    if ( !is_string($resultat) ) {
+		
+	   while ( $row = mysql_fetch_assoc($resultat) ) {
+          $buffer .= "<TR><TD>".$row['idSwitch']."</TD><TD>".$row['idLogin']."</TD><TD>".$row['idPower']."</TD></TR>";
+	   }
+	   
+	}else{
+		$buffer .="<TD>$resultat</TD>";
+	}
+	$buffer .= "</TABLE>";
+	return $buffer ;
+
+}
+
+
+function displayAddPowerService()  {
+	
+	$buffer = "<h1>Ajout de droits ou commande(s) pour un service: </h1>";
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "addRight", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	$buffer .= "<FORM METHOD=\"POST\" ACTION=\"./resultat.php?section=addPowerService\">";
+	$buffer .= "<TABLE>";
+	
+	$resultat = selectService("") ;
+	//TODO display for debugger
+	//echo "type de ressources: " .get_resource_type($resultat);
+	if ( !is_string($resultat) ) {
+		$buffer .= "<TR><TD id=title>Service</TD><TD><SELECT NAME=\"selectService[]\" MULTIPLE SIZE=5>";
+	   while ( $row = mysql_fetch_assoc($resultat) ) {
+         $buffer .= "<OPTION VALUE=\"".$row['idService']."\">".$row['idService']."</OPTION>";
+	   }
+	    $buffer .= "</SELECT></TD>";
+	}else{
+		$buffer .="<TD>$resultat</TD>";
+	}
+	
+	$resultat = selectPower("") ;
+	//TODO echo "type de ressources: " .get_resource_type($resultat);
+	if ( !is_string($resultat) ) {
+		$buffer .= "<TD id=title>Droits</TD><TD><SELECT NAME=\"selectPower[]\" MULTIPLE SIZE=5>";
+	   while ( $row = mysql_fetch_assoc($resultat) ) {
+         $buffer .= "<OPTION VALUE=\"".$row['idPower']."\">".$row['idPower']."</OPTION>";
+	   }
+	    $buffer .= "</SELECT></TD></TR>";
+	}else{
+		$buffer .="<TD>$resultat</TD>";
+	}
+	
+	$buffer .= "</TR>";
+	$buffer .= "<TR><TD id='submit'><INPUT TYPE=\"SUBMIT\" VALUE=\"AJOUTER\"></TD></TR>";
+	$buffer .= "</TABLE></FORM>";
+	
+	return $buffer ;
+	
+}
+
+
+
+function displayResultAddPowerService($power, $service) {
+	
+	$buffer = "<h1>RÃ©sultat de la commande</h1>";
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "addRight", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	
+	$buffer .= "<TABLE>";
+	$resultat = ctrlEmpty($power, "Nom du droit ou de la commande");
+	if ( $resultat != 1 ){
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	$resultat = ctrlEmpty($service, "Service");
+	if ( $resultat != 1 ){
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	foreach ( $service as $idService) {
+		foreach ($power as $idPower) {
+		   $resultat = addCMDService($idService, $idPower);
+		   if ($resultat == 1 ) {
+	   	      $buffer .= "<TR><TD>ADD POWER $idPower FOR $idService: [OK]</TD></TR>";
+	       }else{
+			  $buffer .= "<TR><TD>$resultat</TD></TR>";
+		     // $buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR>";
+	        } 
+		}   
+	}
+	
+	$buffer .="</TABLE>";
+	return $buffer;
+}
+
+
+function displayDelPowerService()  {
+	
+	$buffer = "<h1>Suppression de droits pour un service: </h1>";
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "delRight", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	$buffer .= "<FORM METHOD=\"POST\" ACTION=\"./resultat.php?section=delPowerService\">";
+	$buffer .= "<TABLE>";
+	
+	$resultat = selectService("") ;
+	//TODO display for debugger
+	//echo "type de ressources: " .get_resource_type($resultat);
+	if ( !is_string($resultat) ) {
+		$buffer .= "<TD><SELECT NAME=\"selectService[]\" MULTIPLE SIZE=5>";
+	   while ( $row = mysql_fetch_assoc($resultat) ) {
+         $buffer .= "<OPTION VALUE=\"".$row['idService']."\">".$row['idService']."</OPTION>";
+	   }
+	    $buffer .= "</SELECT></TD>";
+	}else{
+		$buffer .="<TD>$resultat</TD>";
+	}
+	
+	$resultat = selectPower("") ;
+	//TODOdisplay for debugger
+	//echo "type de ressources: " .get_resource_type($resultat);
+	if ( !is_string($resultat) ) {
+		$buffer .= "<TD><SELECT NAME=\"selectPower[]\" MULTIPLE SIZE=5>";
+	   while ( $row = mysql_fetch_assoc($resultat) ) {
+         $buffer .= "<OPTION VALUE=\"".$row['idPower']."\">".$row['idPower']."</OPTION>";
+	   }
+	    $buffer .= "</SELECT></TD>";
+	}else{
+		$buffer .="<TD>$resultat</TD>";
+	}
+	
+	$buffer .= "</TR>";
+	$buffer .= "<TR><TD id='submit'><INPUT TYPE=\"SUBMIT\" VALUE=\"AJOUTER\"></TD></TR>";
+	$buffer .= "</TABLE></FORM>";
+	
+	return $buffer ;
+	
+}
+
+function displayResultDelPowerService($power, $service) {
+	
+	$buffer = "<h1>RÃ©sultat de la commande</h1>";
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "delRight", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR> </TABLE>";
+		return $buffer ;
+	}
+	
+	$buffer .= "<TABLE>";
+	$resultat = ctrlEmpty($power, "Nom du droit ou de la commande");
+	if ($resultat != 1 ){
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR> </TABLE>";
+		return $buffer ;
+	}
+	
+	$resultat = ctrlEmpty($service, "Service");
+	if ( $resultat != 1 ){
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR> </TABLE>";
+		return $buffer ;
+	}
+	
+	foreach ( $service as $idService) {
+		foreach ($power as $idPower) {
+		   $resultat = delCMDService($idService, $idPower);
+		   if ($resultat == 1 ) {
+	   	      $buffer .= "<TR><TD>DEL POWER $idPower FOR $idService: [OK]</TD></TR>";
+	       }else{
+			  $buffer .= "<TR><TD>$resultat</TD></TR>";
+		      $buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR>";
+	        } 
+		}   
+	}
+	
+	$buffer .="</TABLE>";
+	return $buffer;
+}
+
+
+
+function displayAddUserService()  {
+	
+	$buffer = "<h1>Ajout de Service pour un Utilisateur: </h1>";
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "addServiceUser", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR> </TABLE>";
+		return $buffer ;
+	}
+	
+	$buffer .= "<FORM METHOD=\"POST\" ACTION=\"./resultat.php?section=addUserService\">";
+	$buffer .= "<TABLE>";
+	
+	$resultat = selectUser("") ;
+	//TODO display for debugger
+	//echo "type de ressources: " .get_resource_type($resultat);
+	if ( !is_string($resultat) ) {
+		$buffer .= "<TR><TD id=title>Utilisateur</TD><TD><SELECT NAME=\"selectUser[]\" MULTIPLE SIZE=5>";
+	   while ( $row = mysql_fetch_assoc($resultat) ) {
+         $buffer .= "<OPTION VALUE=\"".$row['idUser']."\">".$row['idUser']."</OPTION>";
+	   }
+	    $buffer .= "</SELECT></TD>";
+	}else{
+		$buffer .="<TD>$resultat</TD>";
+	}
+	
+	$resultat = selectService("") ;
+	//TODO display for debugger
+	//echo "type de ressources: " .get_resource_type($resultat);
+	if ( !is_string($resultat) ) {
+		$buffer .= "<TD id=title>Service</TD><TD><SELECT NAME=\"selectService[]\" MULTIPLE SIZE=5>";
+	   while ( $row = mysql_fetch_assoc($resultat) ) {
+         $buffer .= "<OPTION VALUE=\"".$row['idService']."\">".$row['idService']."</OPTION>";
+	   }
+	    $buffer .= "</SELECT></TD>";
+	}else{
+		$buffer .="<TD>$resultat</TD>";
+	}
+	
+	$buffer .= "</TR>";
+	$buffer .= "<TR><TD COLSPAN=4 id='submit'><INPUT TYPE=\"SUBMIT\" VALUE=\"AJOUTER\"></TD></TR>";
+	$buffer .= "</TABLE></FORM>";
+	
+	return $buffer ;
+	
+}
+
+
+function displayResultAddUserService($user, $service) {
+	
+	$buffer = "<h1>RÃ©sultat de la commande</h1>";
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "addServiceUser", "" );
+	if ( $resultat != 1 ){
+		$buffer.= "<TABLE>";
+		$buffer .= "<TR><TD>" . $resultat ."</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	$buffer .= "<TABLE>";
+	$resultat = ctrlEmpty($user, "Utilisateur");
+	if ( $resultat != 1 ){
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	$resultat = ctrlEmpty($service, "Service");
+	if ( $resultat != 1 ){
+		$buffer .= "<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	foreach ( $service as $idService) {
+		foreach ($user as $idLogin) {
+		   $resultat = addUserService($idLogin, $idService);
+		   if ($resultat == 1 ) {
+	   	      $buffer .= "<TR><TD>ADD SERVICE $idService FOR $idLogin: [OK]</TD></TR>";
+	       }else{
+			  $buffer .= "<TR><TD>$resultat</TD></TR>";
+		      $buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR>";
+	        } 
+		}   
+	}
+	
+	$buffer .="</TABLE>";
+	return $buffer;
+}
+
+
+function displayAddSwitchService()  {
+	
+	$buffer = "<h1>Ajout de Service pour un Switch: </h1>";
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "addServiceSwitch", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR> </TABLE>";
+		return $buffer ;
+	}
+	
+	$buffer .= "<FORM METHOD=\"POST\" ACTION=\"./resultat.php?section=addSwitchService\">";
+	$buffer .= "<TABLE>";
+	
+	$resultat = selectSwitch("") ;
+	//TODO display for debugger
+	//echo "type de ressources: " .get_resource_type($resultat);
+	if ( !is_string($resultat) ) {
+		$buffer .= "<TR><TD id=title>Switch</TD><TD><SELECT NAME=\"selectSwitch[]\" MULTIPLE SIZE=5>";
+	   while ( $row = mysql_fetch_assoc($resultat) ) {
+         $buffer .= "<OPTION VALUE=\"".$row['idSwitch']."\">".$row['idSwitch']."</OPTION>";
+	   }
+	    $buffer .= "</SELECT></TD>";
+	}else{
+		$buffer .="<TD>$resultat</TD>";
+	}
+	
+	$resultat = selectService("") ;
+	//TODO display for debugger
+	//echo "type de ressources: " .get_resource_type($resultat);
+	if ( !is_string($resultat) ) {
+		$buffer .= "<TD id=title>Service</TD><TD><SELECT  NAME=\"selectService[]\" MULTIPLE SIZE=5>";
+	   while ( $row = mysql_fetch_assoc($resultat) ) {
+         $buffer .= "<OPTION VALUE=\"".$row['idService']."\">".$row['idService']."</OPTION>";
+	   }
+	    $buffer .= "</SELECT></TD>";
+	}else{
+		$buffer .="<TD>$resultat</TD>";
+	}
+	
+	$buffer .= "</TR>";
+	$buffer .= "<TR><TD id='submit' COLSPAN=4><INPUT TYPE=\"SUBMIT\" VALUE=\"AJOUTER\"></TD></TR>";
+	$buffer .= "</TABLE></FORM>";
+	
+	return $buffer ;
+	
+}
+
+
+function displayResultAddSwitchService($switch, $service) {
+	
+	$buffer = "<h1>RÃ©sultat de la commande</h1>";
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "addServiceSwitch", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .= "<TR><TD>" . $resultat ."</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	$buffer .= "<TABLE>";
+	$resultat = ctrlEmpty($switch, "Switch");
+	if ( $resultat != 1 ){
+		$buffer .= "<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return  $buffer ;
+	}
+	
+	$resultat = ctrlEmpty($service, "Service");
+	if ( $resultat != 1 ){
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	foreach ( $service as $idService) {
+		foreach ($switch as $idSwitch) {
+		   $resultat = addSwitchService($idSwitch, $idService);
+		   if ($resultat == 1 ) {
+	   	      $buffer .= "<TR><TD>ADD SERVICE $idService FOR $idSwitch: [OK]</TD></TR>";
+	       }else{
+			  $buffer .= "<TR><TD>$resultat</TD></TR>";
+		      $buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR>";
+	        } 
+		}   
+	}
+	
+	$buffer .="</TABLE>";
+	return $buffer;
+}
+
+function displayDelUserSwitchService($userService, $switchService) {
+	
+	
+	$buffer = "<TABLE>";
+	
+	if ( !empty($userService) ) {
+		
+		//del service's user
+		foreach ( $userService as $value ) {
+			$Tsplit = split("@", $value);
+			echo "<TR><TD>" . delUserService($Tsplit[0], $Tsplit[1]) ."</TD></TR>";
+		}
+	}
+	
+	if (!empty($switchService) ) {
+		
+		//del service's switch
+		foreach ( $switchService as $valueSwitch ) {
+			$Tsplit = split("@", $valueSwitch) ;
+			echo "<TR><TD>" . delSwitchService($Tsplit[0], $Tsplit[1]) ."</TD></TR>";
+		}
+	}
+	$buffer .= "</TABLE>";
+	
+}
+
+
+
+function displayAddNetwork() {
+	
+	$buffer = "<h1>AJout d'un rÃ©seau</h1>";
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "addNetwork", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR> </TABLE>";
+		return $buffer ;
+	}
+	
+	$buffer .= "<FORM METHOD=\"POST\" ACTION=\"./resultat.php?section=addNetwork\">";
+	$buffer .= "<TABLE>";
+	
+	$buffer .= "<TR><TD id=title>Adresse rÃ©seau (Syntaxe: 192.168.1.0/24): </TD><TD><INPUT TYPE=\"TEXT\" NAME=\"textIdNetwork\"></INPUT></TD></TR>";
+	$buffer .= "<TR><TD id=title>Nom du rÃ©seau: </TD><TD><INPUT TYPE=\"TEXT\" NAME=\"textNameNetwork\"></INPUT></TD></TR>";
+	
+	$buffer .= "<TR><TD id=title>Interface rÃ©seau (Syntaxe: eth0): </TD><TD><INPUT TYPE=\"TEXT\" NAME=\"textInterface\" ></INPUT></TD></TR>";
+	
+	$buffer .= "<TR><TD id=title>Routeur</TD><TD><SELECT NAME=\"selectRouteur\">";
+	
+	$filter = "type='routeur'";
+	$resultat = selectDevice($filter) ;
+	if ( !is_string($resultat) ) {
+		
+	   while ( $row= mysql_fetch_assoc($resultat) ) {
+			
+		//	if ($rowSwitch['type'] == "router") {
+				$buffer .= "<OPTION VALUE=\"" . $row['hostname'] . "\">" . $row['hostname'] . "</OPTION>" ;
+			//}
+		}
+		
+    }
+	
+	$buffer .= "</SELECT></TD></TR>";
+	
+	$buffer .= "<TR><TD id='submit' COLSPAN=2><INPUT TYPE=\"SUBMIT\" NAME=\"AJOUTER\" VALUE=\"VALIDER\"></TD></TR></TABLE></FORM>";
+	
+	return $buffer;
+	
+}
+
+
+function displayResultAddNetwork($addressNetwork, $nameNetwork, $interface,  $routeur) {
+	
+	$buffer = "<h1>RÃ©sultat de la commande </h1>";
+	//TODO: penser Ã  changer la commade par addNetwork
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "addNetwork", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .= "<TR><TD>" . $resultat ."</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	$buffer .= "<TABLE>";
+	
+	//check is addressNetwork is correct
+	$resultat = ctrlAddressNetwork($addressNetwork);
+	if ( $resultat != 1 ){
+		$buffer .= "<TR><TD>" . $resultat ."</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	//check if nameNetwork is not empty
+	$resultat = ctrlEmpty($nameNetwork, "Nom du Reseau");
+	if ( $resultat != 1 ){
+		$buffer .= "<TR><TD>" . $resultat ."</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	//check if interface is not empty
+	$resultat = ctrlEmpty($interface, "Interface");
+	if ( $resultat != 1 ){
+		$buffer .= "<TR><TD>" . $resultat ."</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	$resultat = ctrlEmpty($routeur, "Routeur");
+	if ( $resultat != 1 ){
+		$buffer .= "<TR><TD>" . $resultat ."</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	$resultat = addNetwork($addressNetwork, $nameNetwork, $interface, $routeur) ;
+	if ($resultat == 1 ) {
+	   	$buffer .= "<TR><TD>CREATE NETWORK $addressNetwork $nameNetwork $interface $routeur : [OK]</TD></TR>";
+		
+	}else{
+		$buffer .= "<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR>";
+		return $buffer ."</TABLE>";
+	}
+	
+	$buffer .="</TABLE>";
+	return $buffer;
+}
+
+
+function displayAllNetwork() {
+	
+	$buffer = "<h1>Liste des RÃ©seau</h1>";
+	$buffer .= "<TABLE>";
+	$buffer .= "<TR><TD id=title>Nom du rÃ©seau</TD><TD id=title>RÃ©seau</TD><TD id=title>Interface</TD><TD id=title>Routeur<TD></TR>";
+	$resultat = selectNetwork("") ;
+	if ( !is_string($resultat) ) {
+		
+	   while ( $row = mysql_fetch_assoc($resultat) ) {
+			
+			$buffer .= "<TR><TD>" . $row['nameNetwork'] . "</TD><TD>" . $row['idNetwork'] . "</TD><TD>" . $row['interface'] . "</TD><TD>" . $row['mainRouter'] . "</TD></TR>";
+			
+		}
+		
+    }
+	$buffer .= "</TABLE>";
+	return $buffer ;
+}
+
+
+function displayDelNetwork() {
+	
+	$buffer = "<h1>RÃ©seau(x) Ã  supprimer: </h1>";
+	//TODO Change droit to delNetwork
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "delNetwork", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .= "<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR> </TABLE>";
+		return $buffer ;
+	}
+	
+	$buffer .= "<FORM METHOD=\"POST\" ACTION=\"./resultat.php?section=delNetwork\">";
+	//$buffer = "<FORM METHOD=\"POST\" ACTION=\"./resultat.php?section=delSwitch\">";
+	$buffer .= "<TABLE>";	
+	
+	
+	$resultat = selectNetwork("") ;
+	//display for debugger
+    //echo "type de ressources: " .get_resource_type($resultat);
+	if ( !is_string($resultat) ) {
+		$buffer .= "<TR><TD id=title>RÃ©seau</TD><TD><SELECT NAME=\"selectNetwork[]\" MULTIPLE SIZE=5>";
+	   while ( $row = mysql_fetch_assoc($resultat) ) {
+         $buffer .= "<OPTION VALUE=\"".$row['idNetwork']."\">".$row['idNetwork']."</OPTION>";
+	   }
+	    $buffer .= "</SELECT></TD></TR>";
+		$buffer .= "<TR><TD id='submit' COLSPAN=2><INPUT TYPE=\"SUBMIT\" VALUE=\"SUPPRIMER\"></TD></TR>";
+	}else{
+		$buffer .="<TD>$resultat</TD></TR>";
+	}
+	$buffer .= "</TABLE></FORM>";
+	return $buffer ;
+}
+
+
+function displayResultDelNetwork($network) {
+	
+	$buffer = "<h1>RÃ©sultat de la commande </h1>";
+	//TODO Change droit to delNetwork
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "delNetwork", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .= "<TR><TD>" . $resultat ."</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+   $buffer .= "<TABLE>";
+   $resultat = ctrlEmpty($network, "Nom du rÃ©seau");
+	if ( $resultat != 1 ){
+		$buffer .= "<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+
+   foreach ($network as $idNetwork) {
+       $resultat = delNetwork($idNetwork);
+	   $buffer .= "<TR><TD>$resultat</TD></TR>";  
+   }
+   $buffer .= "</TABLE>";
+   return $buffer;
+}
+
+
+
+function displayAddDevice() {
+	
+	$buffer = "<h1>AJout d'un Device</h1>";
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "addDevice", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR> </TABLE>";
+		return $buffer ;
+	}
+	
+	$buffer .= "<FORM METHOD=\"POST\" ACTION=\"./resultat.php?section=addDevice\">";
+	$buffer .= "<TABLE>";
+	
+	$buffer .= "<TR><TD id=title>Nom du device: </TD><TD><INPUT TYPE=\"TEXT\" NAME=\"textHostname\"></INPUT></TD></TR>";
+	$buffer .= "<TR><TD id=title>Adresse Mac </TD><TD><INPUT TYPE=\"TEXT\" NAME=\"textMac\"></INPUT></TD></TR>";
+	$buffer .= "<TR><TD id=title>Adresse IP </TD><TD><INPUT TYPE=\"TEXT\" NAME=\"textIP\"></INPUT></TD></TR>";
+
+	$buffer .= "<TR><TD id=title>Type</TD>";
+	$buffer .= "<TD><SELECT  NAME=\"selectType\">";
+	$buffer .= "<OPTION VALUE=\"switch\">switch</OPTION>";
+	$buffer .= "<OPTION VALUE=\"routeur\">routeur</OPTION>";
+	$buffer .= "<OPTION VALUE=\"wifi\">borne wifi</OPTION>";
+	$buffer .= "<OPTION VALUE=\"workstation\">poste de travail</OPTION>";
+	$buffer .= "<OPTION VALUE=\"server\">serveur</OPTION></SELECT></TD></TR>";
+	
+	$buffer .= "<TR><TD id='submit' COLSPAN=2><INPUT TYPE=\"SUBMIT\" NAME=\"AJOUTER\" VALUE=\"VALIDER\"></TD></TR></TABLE></FORM>";
+	
+	return $buffer;
+	
+}
+
+
+function displayResultAddDevice($hostname, $mac, $ip,  $type) {
+	
+	$buffer = "<h1>RÃ©sultat de la commande </h1>";
+	//TODO: penser Ã  changer la commade par addDevice
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "addDevice", "" );
+	if ( $resultat != 1 ){
+		$buffer.= "<TABLE>";
+		$buffer .= "<TR><TD>" . $resultat ."</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	$buffer .= "<TABLE>";
+	$resultat = ctrlIP($ip);
+	if ( $resultat != 1 ){
+		$buffer .= "<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	if ( ($type != "switch" and $type != "routeur" and $type != "wifi") or (!empty($mac) ) ) {
+		
+		$resultat = ctrlMac($mac);
+		if ( $resultat != 1 ){
+			$buffer .= "<TR><TD>$resultat</TD></TR>";
+			$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+			return $buffer ;
+		}
+	}
+	
+	$resultat = ctrlEmpty($hostname, "Nom du device");
+	if ( $resultat != 1 ){
+		$buffer .= "<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	//ctrl if exist ip
+	$filter = "hostname = '$hostname' ";
+	$resultat = selectDevice($filter) ;
+	if ( !is_string($resultat) ) {
+		$row = mysql_fetch_assoc($resultat) ;
+		if ($row['hostname'] == $hostname){
+			$buffer .= "<TR><TD>ADD DEVICE WITH $hostname [FAILED]: hostname already exists</TD></TR>";
+			$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+			return $buffer ;
+		}
+    }
+	
+	//ctrl if exist ip
+	$filter = "ip = '$ip' ";
+	$resultat = selectDevice($filter) ;
+	if ( !is_string($resultat) ) {
+		$row = mysql_fetch_assoc($resultat) ;
+		if ($row['ip'] == $ip){
+			$buffer .= "<TR><TD>ADD DEVICE WITH $ip [FAILED]: IP address already exists</TD></TR>";
+			$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+			return $buffer ;
+		}
+    }
+	
+	//ctrl if mac exist
+	if (!empty($mac) and $type != "routeur") {
+		
+		$filter = "mac = '$mac' ";
+		$resultat = selectDevice($filter) ;
+		if ( !is_string($resultat) ) {
+			$row = mysql_fetch_assoc($resultat) ;
+			if ($row['mac'] == $mac){
+				$buffer .= "<TR><TD>ADD DEVICE WITH $mac [FAILED]: Mac address already exists</TD></TR>";
+				$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+				return  $buffer ;
+			}
+		}
+	}
+	
+	$resultat = addDevice($mac, $hostname, $ip, $type) ;
+	if ($resultat == 1 ) {
+		
+	   	$buffer .= "<TR><TD>CREATE DEVICE $hostname $ip $mac $type : [OK]</TD></TR>";
+		
+	}else{
+		$buffer .= "<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR>";
+		return $buffer ."</TABLE>";
+	}
+	
+	$buffer .="</TABLE>";
+	return $buffer;
+}
+
+
+
+function displayAllDevice() {
+	
+	$buffer = "<h1>Liste des Devices</h1>";
+	$buffer .= "<TABLE>";
+	$buffer .= "<TR><TD id=title>Nom</TD><TD id=title>Adresse Mac</TD><TD id=title>Adresse IP</TD><TD id=title>Type<TD></TR>";
+	$resultat = selectDevice("") ;
+	if ( !is_string($resultat) ) {
+		
+	   while ( $row = mysql_fetch_assoc($resultat) ) {
+			
+			$buffer .= "<TR><TD>" . $row['hostname'] . "</TD><TD>" . $row['mac'] . "</TD><TD>" . $row['ip'] . "</TD><TD>" . $row['type'] . "</TD></TR>";
+			
+		}
+		
+    }
+	$buffer .= "</TABLE>";
+	return $buffer ;
+}
+
+
+
+function displayDelDevice() {
+	
+	$buffer = "<h1>Device(s) Ã  supprimer: </h1>";
+	//TODO Change droit to delDevice
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "delDevice", "" );
+	if ( $resultat != 1 ){
+		$buffer = "<TABLE>";
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+	$buffer .= "<FORM METHOD=\"POST\" ACTION=\"./resultat.php?section=delDevice\">";
+	//$buffer = "<FORM METHOD=\"POST\" ACTION=\"./resultat.php?section=delSwitch\">";
+	$buffer .= "<TABLE>";	
+	
+	
+	$resultat = selectDevice("") ;
+	//display for debugger
+    //echo "type de ressources: " .get_resource_type($resultat);
+	if ( !is_string($resultat) ) {
+		$buffer .= "<TR><TD id=title>Devices</TD><TD><SELECT NAME=\"selectDevice[]\" MULTIPLE SIZE=5>";
+	   while ( $row = mysql_fetch_assoc($resultat) ) {
+         $buffer .= "<OPTION VALUE=\"".$row['hostname']."\">".$row['hostname']."</OPTION>";
+	   }
+	    $buffer .= "</SELECT></TD></TR>";
+		$buffer .= "<TR><TD id='submit' COLSPAN=2><INPUT TYPE=\"SUBMIT\" VALUE=\"SUPPRIMER\"></TD></TR>";
+	}else{
+		$buffer .="<TD>$resultat</TD></TR>";
+	}
+	$buffer .= "</TABLE></FORM>";
+	return $buffer ;
+}
+
+
+function displayResultDelDevice($device) {
+	
+	$buffer = "<h1>Resultat de la commande</h1>";
+	//TODO Change droit to delDevice
+	//check if user can do this command
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "delDevice", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+   $buffer .= "<TABLE>";
+   $resultat = ctrlEmpty($device, "Nom du device");
+	if ( $resultat != 1 ){
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+
+   foreach ($device as $hostname) {
+       $resultat = delDevice($hostname);
+	   $buffer .= "<TR><TD>$resultat</TD></TR>";  
+   }
+   $buffer .= "</TABLE>";
+   return $buffer;
+}
+
+
+function displayGenKlaskConf() {
+	//TODO Change droit to delDevice
+	//check if user can do this command
+	$buffer = "<h1>CrÃ©ation du fichier klask.conf</h1>";
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "klaskexportdb", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+   $buffer .= "<TABLE>";
+   $buffer .= "<TR><TD>" . genKlaskConf() ."</TD></TR></TABLE>";
+	return $buffer ;
+	
+}
+
+function displayKlaskExportdb() {
+	$buffer = "<h1>Liste des postes de travail</h1>";
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "klaskexportdb", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+   $buffer .= "<TABLE id=klask>";
+   //$buffer .= "<TR><TD>";
+   //$buffer .= "<TABLE width=10px>";
+   $buffer .= klaskCommand("exportdb")  ."</TABLE>";
+   //$buffer .= "</TD></TR>";
+   $buffer .= "</TABLE>";
+	return $buffer ;
+	
+}
+
+function displayKlaskExportSw() {
+	$buffer = "<h1>Liste des switch et leurs liaisions</h1>";
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "klaskexportsw", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+   $buffer .= "<TABLE>";
+   $buffer .= "<TR><TD>" . klaskCommand("exportsw")  ."</TD></TR></TABLE>";
+	return $buffer ;
+	
+}
+
+function displayKlaskUpdateSw() {
+	$buffer = "<h1>Mise Ã  jour de la base switch</h1>";
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "klaskupdatesw", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+   $buffer .= "<TABLE>";
+   $buffer .= "<TR><TD>" . klaskCommand("updatesw")  ."</TD></TR></TABLE>";
+	return $buffer ;
+	
+}
+
+
+function displayKlaskUpdateDb() {
+	$buffer = "<h1>Mise Ã  jour de la base switch</h1>";
+	$resultat =0;
+	$resultat = ctrlPower($_SESSION['login'],  "klaskupdatedb", "" );
+	if ( $resultat != 1 ){
+		$buffer .= "<TABLE>";
+		$buffer .="<TR><TD>$resultat</TD></TR>";
+		$buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+		return $buffer ;
+	}
+	
+   $buffer .= "<TABLE>";
+   $buffer .= "<TR><TD>" . klaskCommand("updatedb")  ."</TD></TR></TABLE>";
+	return $buffer ;
+	
+}
+
+function displayKlaskGenMap() {
+$buffer = "<h1>Carte du rÃ©seau</h1>";
+$resultat = ctrlPower($_SESSION['login'],  "klaskgenmap", "" );
+        if ( $resultat != 1 ){
+                $buffer .= "<TABLE>";
+                $buffer .="<TR><TD>$resultat</TD></TR>";
+                $buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+                return $buffer ;
+        }
+$buffer .= "<TABLE>";
+$buffer .= "<TR><TD>" . klaskCommand("genmap") ."</TD></TR>";
+$buffer .= "<TR><TD><a href=\"./klask/map.jpg\">Consulter la carte du rÃ©seau ici</a></TD></TR>";
+$buffer .= "</TABLE>";
+return $buffer ;
+}
+
+
+
+function displaySearch() {
+	$buffer = "<h1>Recherche d'une machine</h1>";
+	$buffer .= "<FORM METHOD=\"POST\" ACTION=\"./resultat.php?section=klaskSearch\">";
+	
+	$buffer .= "<TABLE id=\"Add\">";
+	
+	$buffer .= "<TR><TD id=title>Adresse IP de la machine </TD><TD><INPUT TYPE=\"TEXT\" NAME=\"textIP\"></INPUT></TD></TR>";	
+	$buffer .= "<TR><TD COLSPAN=2><INPUT TYPE=SUBMIT NAME=\"RECHERCHER\" VALUE=\"RECHERCHER\"></INPUT></TD></TR>";
+	$buffer .= "</TABLE></FORM>";
+	
+	echo $buffer ;
+	
+}
+
+
+function displayKlaskSearch($ip) {
+$buffer = "<h1>Recherche d'une machine</h1>";
+$resultat = ctrlPower($_SESSION['login'],  "klasksearch", "" );
+        if ( $resultat != 1 ){
+                $buffer .= "<TABLE>";
+                $buffer .="<TR><TD>$resultat</TD></TR>";
+                $buffer .= "<TR><TD><a href=\"javascript:history.back()\">page prÃ©cÃ©dente</a></TD></TR></TABLE>";
+                return $buffer ;
+        }
+$buffer .= "<TABLE>";
+$resultat = klaskSearch($ip);
+if ( !empty($resultat )) {
+	$buffer .= "<TR><TD>" . klaskSearch($ip) ."</TD></TR>";
+}else{
+	$buffer .= "<TR><TD>Aucun RÃ©sultat TrouvÃ©</TD></TR>";
+}
+$buffer .= "</TABLE>";
+return $buffer ;
+}
+
+
+?>
Index: branches/web-klask/libInstall.php
===================================================================
--- branches/web-klask/libInstall.php	(revision 40)
+++ branches/web-klask/libInstall.php	(revision 40)
@@ -0,0 +1,477 @@
+<?
+
+
+function connectDB($hostDB, $userDB, $passwordDB) {
+
+$link = mysql_connect("$hostDB", "$userDB", "$passwordDB")
+    or die("Impossible de se connecter : " . mysql_error());
+
+//mysql_close($link);
+
+
+}
+
+
+
+/************************************************************************************
+*
+*
+* Create Table USER
+* Create Table SERVICE
+* Create Table POWER
+* Create Table SERVICEUSER
+* Create Table CMDUSER
+* Create Table CMDSERVICE
+* Create  Table SWITCH
+* Create Table CMDSWITCH
+* Create Table SERVICESWITCH
+* CREATE Table DEVICE
+*
+*TODO: METTRE LES PRIMARY KEY
+*************************************************************************************/
+
+
+function createDatabase($hostDB, $nameDB, $userCreateDB, $passwdCreateDB, $userDB, $passwdDB, $adminApp, $passwdAdminApp)
+{
+
+//connect DB
+$buffer = "";
+$link = @mysql_connect($hostDB, $userCreateDB, $passwdCreateDB);
+
+
+if (mysql_error()) {
+	
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	
+	return $buffer;
+}
+
+
+
+//Create DB
+$sql = "CREATE DATABASE IF NOT EXISTS  $nameDB";
+if (@mysql_query($sql, $link)) {
+   $buffer = 1 ;
+} else {
+   $buffer = "Create database: [FAILED] :" . mysql_error() ;
+   return $buffer ;   
+}
+
+
+//echo "step create user<br>";
+//CrÃ©ation de l'utilisateur pour l'accÃšs Ã  la base.
+$sql = "GRANT ALL PRIVILEGES ON $nameDB.* TO $userDB@localhost IDENTIFIED BY '$passwdDB' ";
+if (@mysql_query($sql, $link)) {
+   $buffer = 1;
+} else {
+   $buffer = "Create ACCESS DATABASE FROM $userDB [FAILED] :" . mysql_error() ;
+   return $buffer ;   
+}
+
+mysql_close();
+
+$link = @mysql_connect($hostDB, $userDB, $passwdDB);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	return $buffer;
+}else{
+	
+	$db_selected = @mysql_select_db($nameDB, $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sÃ©lectionner la base de donnÃ©es :$nameDB"  . mysql_error();
+    }
+}
+
+
+
+//Create Table USER
+$sql = "CREATE TABLE IF NOT EXISTS USER (
+        idUser VARCHAR(50) NOT NULL,
+		passwdUser VARCHAR(100) NOT NULL,
+        PRIMARY KEY (idUser) );";
+
+ @mysql_query($sql,$link); 
+ if (mysql_error()){ 
+    $buffer = "Create Table USER: [FAILED] : " . mysql_error();
+	return $buffer ;
+ }else{
+    $buffer = 1;
+ }
+ 
+ //Create Table SERVICE
+ $sql = "CREATE TABLE IF NOT EXISTS SERVICE (
+        idService VARCHAR(50) NOT NULL,
+        PRIMARY KEY (idService) );";
+ @mysql_query($sql,$link); 
+ if (mysql_error()){ 
+    $buffer = "Create Table SERVICE: [FAILED] : " . mysql_error();
+ }else{
+    $buffer = 1;
+ }
+ 
+ 
+ //Create Table SERVICEUSER
+$sql = "CREATE TABLE IF NOT EXISTS SERVICEUSER (
+        idUser VARCHAR(50) NOT NULL,
+		idService VARCHAR(50) NOT NULL,
+        PRIMARY KEY (idUser, idService) );";
+
+ @mysql_query($sql,$link); 
+ if (mysql_error()){ 
+    $buffer = "CREATE TABLE SERVICEUSER: [FAILED] : " . mysql_error();
+	return $buffer ;
+ }else{
+    $buffer = 1;
+ }
+ 
+ 
+ 
+ // Create Table POWER
+ /*$sql = "CREATE TABLE IF NOT EXISTS Power (
+        idPower VARCHAR(50) NOT NULL,
+		descPower VARCHAR(50) NOT NULL;)";*/
+$sql = "CREATE TABLE IF NOT EXISTS POWER (
+        idPower VARCHAR(50) NOT NULL,
+		descPower VARCHAR(200),
+		PRIMARY KEY (idPower) );";
+		
+ @mysql_query($sql,$link); 
+ if (mysql_error()){ 
+    $buffer = "Create Table POWER: [FAILED] : " . mysql_error();
+	return $buffer ;
+ }else{
+    $buffer = 1;
+ } 
+ 
+ //Create Table CMDUSER
+ $sql = "CREATE TABLE IF NOT EXISTS CMDUSER (
+        idPower VARCHAR(50) NOT NULL,
+		idUser VARCHAR(50) NOT NULL,
+        PRIMARY KEY (idPower, idUser));";
+  @mysql_query($sql,$link); 
+  if (mysql_error()){ 
+     $buffer = "Create Table CMDUSER: [FAILED] : " . mysql_error();
+  }else{
+     $buffer = 1;
+  }
+ 
+ //Create Table CMDSERVICE
+ $sql = "CREATE TABLE IF NOT EXISTS CMDSERVICE (
+        idPower VARCHAR(50) NOT NULL,
+		idService VARCHAR(50) NOT NULL,
+        PRIMARY KEY (idPower, idService))";
+  @mysql_query($sql,$link); 
+  if (mysql_error()){ 
+     $buffer = "Create Table CMDSERVICE: [FAILED] : " . mysql_error();
+	 return $buffer ; 
+  }else{
+     $buffer = 1;
+  }
+
+ //Create  Table SWITCH
+ $sql = "CREATE TABLE IF NOT EXISTS SWITCH (
+        idSwitch VARCHAR(50) NOT NULL,
+		location VARCHAR(200),
+		level INT(2),
+		portignore VARCHAR(50) ,
+        PRIMARY KEY (idSwitch)
+		);";
+  @mysql_query($sql,$link); 
+  if (mysql_error()){ 
+     $buffer = "Create Table SWITCH: [FAILED] : " . mysql_error();
+	 return $buffer ; 
+  }else{
+     $buffer = 1;
+  }
+
+  //Create Table CMDSWITCH
+  $sql = "CREATE TABLE IF NOT EXISTS CMDSWITCH (
+        idPower VARCHAR(50) NOT NULL,
+		idSwitch VARCHAR(50) NOT NULL,
+		idUser VARCHAR(50) NOT NULL,
+        PRIMARY KEY (idPower, idSwitch, idUser)
+		);";
+  @mysql_query($sql,$link); 
+  if (mysql_error()){ 
+     $buffer = "Create Table CMDSWITCH: [FAILED] : " . mysql_error();
+	  return $buffer; 
+  }else{
+     $buffer = 1;
+  }
+  
+   //Create Table SERVICESWITCH
+  $sql = "CREATE TABLE IF NOT EXISTS SERVICESWITCH (
+        idService VARCHAR(50) NOT NULL,
+		idSwitch VARCHAR(50) NOT NULL,
+        PRIMARY KEY (idService, idSwitch)
+		);";
+  @mysql_query($sql,$link); 
+  if (mysql_error()){ 
+     $buffer = "CREATE TABLE SERVICESWITCH: [FAILED] : " . mysql_error();
+	 return $buffer ; 
+  }else{
+     $buffer = 1;
+  }
+  
+
+	//CREATE Table RESEAU
+	$sql = "CREATE TABLE IF NOT EXISTS NETWORK (
+				idNetwork VARCHAR(50) NOT NULL,
+				nameNetwork VARCHAR(50) NOT NULL,
+				interface VARCHAR(8) NOT NULL,
+				mainRouter VARCHAR(50) NOT NULL,
+				PRIMARY KEY (idNetwork)
+				);";
+	@mysql_query($sql,$link); 
+	if (mysql_error()){ 
+		$buffer = "CREATE TABLE NETWORK: [FAILED] : " . mysql_error();
+		return $buffer ; 
+	}else{
+		$buffer = 1;
+	}
+
+	//CREATE Table DEVICE
+	$sql = "CREATE TABLE IF NOT EXISTS DEVICE (
+				mac VARCHAR(20) NOT NULL,
+				hostname VARCHAR(50) NOT NULL,
+				ip VARCHAR(50) NOT NULL,
+				type VARCHAR(20),
+				PRIMARY KEY (hostname)
+				);";
+	@mysql_query($sql,$link); 
+	if (mysql_error()){ 
+		$buffer = "CREATE TABLE DEVICE: [FAILED] : " . mysql_error();
+		return $buffer ; 
+	}else{
+		$buffer = 1;
+	}
+  
+  //init table POWER
+  
+  $power = array("addUser",
+                 "delUser",
+				 "updateUser",
+				 "addService",
+				 "delService",
+				 "updateService",
+				 "addServiceUser",
+				 "delServiceUser",
+				 "addSwitch",
+				 "delSwitch",
+				 "updateSwitch",
+				 "addServiceSwitch",
+				 "delServiceSwitch", 
+				 "addRight",
+				 "delRight",
+				 "addNetwork",
+				 "delNetwork",
+				 "addDevice",
+				 "delDevice", 
+				 "disablePort",
+				 "enablePort",
+				 "genFileKlaskConf",
+				 "klaskupdatesw",
+				 "klaskupdatedb",
+				 "klaskexportdb",
+				 "klaskgenmap",
+				 "klasksearch" );
+  
+  foreach(  $power as $idPower) {
+	 $sql = "INSERT INTO POWER VALUE('$idPower', '') ";
+	 @mysql_query($sql,$link); 
+     if (mysql_error()){ 
+        $buffer = "INSERT POWER $idPower IN TABLE SERVICESWITCH: [FAILED] : " . mysql_error();
+		return $buffer;
+     }else{
+        $buffer = 1;
+     }
+	
+   }
+
+//init table user, insert adminApp account
+  $passwdAdminApp= md5($passwdAdminApp);
+  $sql= "INSERT INTO USER VALUE('$adminApp', '$passwdAdminApp');";
+  @mysql_query($sql,$link); 
+     if (mysql_error()){ 
+        $buffer .= "INSERT USER ADMIN $adminApp IN TABLE USER: [FAILED] : " . mysql_error();
+		return $buffer;
+     }else{
+        $buffer = 1;
+     }
+
+//init table CMSUSER for adminApp account
+foreach(  $power as $idPower) {
+	 $sql = "INSERT INTO CMDUSER VALUE('$idPower', '$adminApp') ";
+	 @mysql_query($sql,$link); 
+     if (mysql_error()){ 
+        $buffer .= "INSERT CMDUSER $idPower FOR USER $adminApp: [FAILED] : " . mysql_error();
+		return $buffer;
+     }else{
+        $buffer = 1;
+     }
+	
+}
+  
+  return $buffer;
+}
+
+
+function createFileConfig($hostDB, $nameDB, $userDB, $passwdDB, $adminApp) {
+
+
+
+//Create file config.php
+$fileConfig="./conf/config.php";
+
+$content = "<?\n";
+$content .= "\$GLOBALS['hostDB']=\"$hostDB\";\n";
+$content .= "\$GLOBALS['nameDB']=\"$nameDB\";\n";
+$content .= "\$GLOBALS['userDB']=\"$userDB\";\n";
+$content .= "\$GLOBALS['passwdDB']=\"$passwdDB\";\n";
+$content .= "\$GLOBALS['auth']=\"classic\";\n";
+$content .= "\$GLOBALS['adminApp']=\"$adminApp\";\n";
+$content .= "?>";
+
+if (!$handle=fopen($fileConfig, "w+")) {
+    $buffer = "Open file $fileConfig: [FAILED]";
+	return $buffer;
+}
+
+if (!fwrite($handle, $content)) {
+    $buffer = "Write in file $fileConfig: [FAILED]";
+	return $buffer;    
+}
+
+return 1;
+
+}
+
+
+function displaySaisieDB()
+{
+	
+$buffer = "<h1>Installation Etape 1</h1>";
+$buffer .= "<FORM METHOD=\"POST\" ACTION=\"install.php?section=saisieDB\">";
+$buffer .= "<TABLE>";
+$buffer .= "<TR><TD>ParamÃštres pour la crÃ©ation de la base de donnÃ©es</TD></TR>";
+$buffer .= "<TR><TD>Nom de la machine : </TD><TD><INPUT TYPE=\"TEXT\" NAME=\"textHostDB\"></INPUT></TD></TR>";
+$buffer .= "<TR><TD>Nom de la base de donnÃ©es: </TD><TD><INPUT TYPE=\"TEXT\" NAME=\"textNameDB\"></INPUT></TD></TR>";
+$buffer .= "<TR><TD>Utilisateur (autorisÃ© Ã  crÃ©er une base de donnÃ©es, exemple root): </TD><TD><INPUT TYPE=\"TEXT\" NAME=\"textUserCreateDB\"></INPUT></TD></TR>";
+
+$buffer .= "<TR><TD>Mot de passe de l'utilisateur (autorisÃ© Ã  crÃ©er une base de donnÃ©e): </TD><TD><INPUT TYPE=\"TEXT\" NAME=\"textPasswdCreateDB\"</INPUT></TD></TR>";
+
+$buffer .= "<TR><TD>Utilisateur (pour l'accÃšs de l'application Ã  la base): </TD><TD><INPUT TYPE=\"TEXT\" NAME=\"textUserDB\"></INPUT></TD></TR>";
+
+$buffer .= "<TR><TD>Mot de passe de l'utilisateur (pour l'accÃšs Ã  la base): </TD><TD><INPUT TYPE=\"TEXT\" NAME=\"textPasswdDB\"></INPUT></TD></TR>";
+
+$buffer .= "<TR><TD>Compte administrateur de l'application: </TD><TD><INPUT TYPE=\"TEXT\" NAME=\"textAdminApp\"></INPUT></TD></TR>";
+
+$buffer .= "<TR><TD>Mot de passe du compte administrateur de l'application: </TD><TD><INPUT TYPE=\"TEXT\" NAME=\"textPasswdAdminApp\"></INPUT></TD></TR>";
+
+$buffer .= "<TR><TD><INPUT TYPE=\"SUBMIT\" VALUE=\"VALIDER\"></INPUT></TD></TR>";
+$buffer .= "</TABLE></FORM>";
+
+return $buffer;
+
+
+}
+
+
+
+function displayChooseAuth() {
+
+$buffer = "<h1>Installation Etape 2: Choix d'authentification</h1>";
+$buffer .= "<FORM METHOD=\"POST\" ACTION=\"./install.php?section=auth\">";
+$buffer .= "<TABLE>";
+$buffer .= "<TR><TD>Quel mode d'authentification souhaitez-vous ?</TD></TR>";
+$buffer .= "<TR><TD><INPUT TYPE=\"RADIO\" NAME=\"radioAuth\" VALUE=\"classic\" checked>Classique</INPUT></TD>";
+$buffer .= "<TD><INPUT TYPE=\"RADIO\" NAME=\"radioAuth\" VALUE=\"ldap\">LDAP</TD></TR>";
+$buffer .= "<TR><TD><INPUT TYPE=\"SUBMIT\" VALUE=\"VALIDER\"></INPUT></TD></TR>";
+$buffer .= "</TABLE></FORM>";
+
+
+return $buffer ;
+		
+}
+
+
+function displaySaisieLDAP() {
+
+$buffer = "<h1>Installation Etape 3: ParamÃštres LDAP</h1>";
+$buffer .= "<FORM METHOD=\"POST\" ACTION=\"./install.php?section=createFileAuth\">";
+$buffer .= "<TABLE>";
+$buffer .= "<TR><TD>Nom du serveur LDAP</TD><TD><INPUT TYPE=\"TEXT\" NAME=\"textHostLdap\"></INPUT></TD></TR>";
+$buffer .= "<TR><TD>Bind des Utilisateurs (exemple: ou=people, dc=ens, dc=fr) </TD><TD><INPUT TYPE=\"TEXT\" NAME=\"textBindUser\"></INPUT></TD></TR>";
+$buffer .= "<TR><TD>Champs du service d'affectation de l'utilisateur</TD><TD><INPUT TYPE=\"TEXT\" NAME=\"textService\"></TD></TR>";
+$buffer .="<TR><TD><INPUT TYPE=\"SUBMIT\" VALUE=\"VALIDER\"></INPUT></TD></TR>";
+$buffer .= "</TABLE></FORM>";
+
+return $buffer ;
+	
+}
+
+
+
+
+
+
+function createFileLDAP($hostLDAP, $bindUser, $bindService) {
+
+//Create file auth_ldap.php
+$fileAuthLDAP="./ldap/auth_ldap.php";
+
+$content = "<?\n";
+$content .= "\$GLOBALS['hostLDAP']=\"$hostLDAP\";\n";
+$content .= "\$GLOBALS['dnUser']=\"$bindUser\";\n";
+$content .= "\$GLOBALS['dnService']=\"$bindService\";\n";
+$content .= "?>";
+
+if (!$handle=fopen($fileAuthLDAP, "w+")) {
+    $buffer = "Open file $fileAuthLDAP: [FAILED]";
+	return $buffer;
+}
+
+if (!fwrite($handle, $content)) {
+    $buffer = "Write in file $fileAuthLDAP: [FAILED]";
+	return $buffer;    
+}
+
+//READ config.php
+$fileConfig="./conf/config.php";
+$contentToWrite= "";
+$handle = @fopen($fileConfig, "r");
+if ($handle) {
+    while (!feof($handle)) {
+        $contentFile = fgets($handle, 4096);
+				
+		
+	if ( !( ereg ("\?>", $contentFile) )  &&  (!ereg("GLOBALS\['auth'\]", $contentFile) ) ) {
+			$contentToWrite .= $contentFile;
+		}
+    }
+}
+fclose($handle);
+
+$contentToWrite .= "\$GLOBALS['auth']=\"ldap\";\n";
+$contentToWrite .= "?>\n";
+
+//REWRITE config.php
+if (!$handle=fopen($fileConfig, "w+")) {
+    $buffer = "Open file $fileConfig: [FAILED]";
+	return $buffer;
+}
+
+if (!fwrite($handle, $contentToWrite)) {
+    $buffer = "Write in file $fileConfig: [FAILED]";
+	return $buffer;    
+}
+
+
+return 1;
+
+}
+
+
+
+
+?>
Index: branches/web-klask/libKlask.php
===================================================================
--- branches/web-klask/libKlask.php	(revision 40)
+++ branches/web-klask/libKlask.php	(revision 40)
@@ -0,0 +1,211 @@
+<?
+function genSectionEntete() {
+	$content = "default:\n";
+	$content .= "   community: public\n";
+	$content .= "   snmpport: 161\n\n";
+
+        $buffer = "<TR><TD id=title>Section EntÃªte:</TD></TR>";
+	$buffer .= "<TR><TD>default:<BR />";
+	$buffer .= "community: public<BR />";
+	$buffer .= "snmpport: 161</TD></TR>";
+	
+	echo $buffer ;
+	
+	return $content ;
+	
+}
+
+
+function genSectionSwitch() {
+	
+	$content = "switch:\n";
+        $buffer = "<TR><TD id=title>Section switch</TD></TR>";	
+	$resultat = selectSwitch("") ;
+	if ( !is_string($resultat) ) {
+		
+	   while ( $rowSwitch = mysql_fetch_assoc($resultat) ) {
+			$content .= "   - hostname: " . $rowSwitch['idSwitch'] . "\n";
+			$content .= "     location: " . $rowSwitch['location'] . "\n";
+			$content .= "     level: " . $rowSwitch['level'] . "\n";
+			$content .= "     portignore: \n";
+			$content .= "\n\n\n";
+		        $buffer .= "<TR><TD>".$rowSwitch['idSwitch']."<BR />"
+                                             .$rowSwitch['location']."<BR />"
+                                             .$rowSwitch['level']."<BR />"
+					     .$rowSwitch['portignore']."</TD></TR>";
+		}
+		
+    }
+        echo $buffer ;
+	return $content;
+}
+
+function genSectionNetwork() {
+	$content = "network:\n";
+        $buffer = "<TR><TD id=title>Section Netwotk</TD></TR>";	
+	$resultat = selectNetwork("") ;
+	if ( !is_string($resultat) ) {
+		
+		//TODO: attention je n'ai pas pris en compte dans la gÃ©nÃ©ration du fichier plusieurs plage reseau pour un nom reseau
+	   while ( $rowNetwork = mysql_fetch_assoc($resultat) ) {
+			$content .= "   " . $rowNetwork['nameNetwork'] . ":\n";
+			$content .= "     ip-subnet:\n";
+			$content .= "       - add: ".$rowNetwork['idNetwork'] . "\n";
+			$content .= "     interface: " . $rowNetwork['interface'] . "\n";
+			$content .= "     main-router: " . $rowNetwork['mainRouter'] . "\n";
+			$content .= "\n\n\n";
+
+			$buffer .="<TR><TD>".$rowNetwork['nameNetwork']."<BR />"
+			          ."ip-subnet:<BR />"
+				  ."- add: ".$rowNetwork['idNetwork']."<BR />"
+				  ."interface: ".$rowNetwork['interface']."<BR />"
+				  ."main-router: ".$rowNetwork['mainRouter'] ."</TD></TR>";
+		}
+    }
+        echo $buffer ;
+	
+	return $content ;
+}
+
+function genSectionRouter() {
+	
+	$content = "router:\n";
+	
+	$filter = "type = 'routeur'";
+	$resultat = selectDevice($filter) ;
+	if ( !is_string($resultat) ) {
+		
+	   while ( $rowDev = mysql_fetch_assoc($resultat) ) {
+			$content .= "   - hostname: " . $rowDev['hostname'] . "\n";
+			$content .= "     mac-address: " . $rowDev['mac'] . "\n";
+			$buffer .= "<TR><TD> - hostname: ".$rowDev['hostname']."<BR />"
+			          ."mac-address: ".$rowDev['mac']."</TD></TR>";
+		}
+    }
+        echo $buffer ;	
+	$content .="\n\n";
+	
+	return $content ;
+	
+}
+
+
+
+function genKlaskConf() {
+	
+	$fileKlask = "./klask/klask.conf";
+	
+	if (!$handle=fopen($fileKlask, "w+")) {
+    $buffer = "Open file $fileKlask: [FAILED]";
+	return $buffer;
+}
+
+	$content = genSectionEntete() ;
+	$content .= genSectionNetwork() ;
+	$content .= genSectionRouter() ;
+	$content .= genSectionSwitch() ;
+
+if (!fwrite($handle, $content)) {
+    $buffer = "Write in file $fileKlask: [FAILED]";
+	return $buffer;    
+}
+
+}
+
+function klaskCommand($idRight) {
+	$pathKlask = "sudo /usr/sbin/klask" ;
+	
+	$buffet = "";
+	if ($idRight == "exportdb" ) {
+	    $command=exec($pathKlask." ".$idRight , $ret) ;
+
+		$cpt=0;
+		$buffer =  "<TR><TD id=title>Switch</TD><TD id=title>Ports</TD><TD id=title>Hostname</TD><TD id=title>IP</TD><TD id=title>Mac</TD><TD id=title>Date</TD></TR>";
+		foreach ($ret as $line) {
+			$cpt++;
+			if ($cpt > 2) {
+				$buffer2 = str_replace('[ ]+', ' ' , trim($line));
+				$Tsplit =  split('[ ]+', $buffer2);
+				$buffer .=  "<TR><TD id='klask'>".trim($Tsplit[0]) ."</TD><TD id='klask'> ".  trim($Tsplit[1]) . "</TD><TD id='klask'>". trim($Tsplit[3]) . "</TD><TD id='klask'> " . trim($Tsplit[4]) ."</TD><TD id='klask'>" . trim($Tsplit[5]) . "</TD><TD id=klask>" . trim($Tsplit[6]) ." " . $Tsplit[7] ."</TD></TR>";
+			}
+		}
+		return $buffer ;
+		
+	}else{
+		
+		if ($idRight == "updatesw") {
+			
+			$command=exec($pathKlask." ".$idRight , $ret) ;
+			$buffer = "";
+			 foreach ( $ret as $line ) {
+				$buffer .= "$line <BR>";
+			}
+			return $buffer ;
+		}else{
+			if ($idRight == "updatedb") {
+			
+				$command=exec($pathKlask." ".$idRight , $ret) ;
+				$buffer = "";
+				foreach ( $ret as $line ) {
+					$buffer = "$line <BR>";
+				}
+				return $buffer ;
+			}else{
+				if ($idRight == "exportsw") {
+			
+					$command=exec($pathKlask." ".$idRight , $ret) ;
+					$buffer = "";
+					foreach ( $ret as $line ) {
+						if (fnmatch("Switch parent and children port inter-connection", $line)) {
+							$buffer .= "<TR><TD COLSPAN=5>Switch parent and children port inter-connection</TD></TR>";
+						}else{
+							if ( fnmatch("Switch output port and parent port connection", $line)) {
+								$buffer .= "<TR><TD COLSPAN=5>Switch output port and parent port connection</TD></TR>";
+							}else{
+								$buffer2 = str_replace('[ ]+', ' ' , trim($line));
+								$buffer2 = str_replace('[<--+]', ' ' , trim($buffer2));
+								$Tsplit =  split('[ ]+', $buffer2);
+								$buffer .=  "<TR><TD id='klask'>".trim($Tsplit[0]) ."</TD><TD id='klask'> ".  trim($Tsplit[1]) . "</TD><TD id='klask'>". trim($Tsplit[3]) . "</TD><TD id=klask>". trim($Tsplit[4])."</TD></TR>";
+							}
+						}
+					}
+					return $buffer ;
+				}else{
+				   if ( $idRight == "genmap") {
+						$command=exec($pathKlask." exportsw -f dot > ./klask/map.dot" , $ret) ;
+						$command=exec("dot -Tjpg ./klask/map.dot > ./klask/map.jpg", $ret);
+					}
+				}
+		    }
+	} 
+}
+	
+}
+
+
+function KlaskSearch($ip) {
+	$pathKlask = "sudo /usr/sbin/klask" ;
+	$command=exec($pathKlask." search " ."$ip", $ret) ;
+	$buffer = "";
+	$cpt=0;
+	foreach ( $ret as $line ) {
+		$cpt++;
+		if ( $cpt == 2 ) {
+			if ( !empty($line) ) {
+				$buffer2 = str_replace('[ ]+', ' ' , trim($line));
+				$Tsplit =  split('[ ]+', $buffer2);
+				$buffer = "<B>Nom: </B>" . $Tsplit[2] ."<BR />";
+				$buffer .= "<B>IP: </B> " . $Tsplit[3] . "<BR />";
+				$buffer .= "<B>Mac: </B> " . $Tsplit[4] . "<BR />";
+				$buffer .= "<B>ConnectÃ© au Switch: </B>" . $Tsplit[0]. "<BR />";
+				$buffer .= "<B>Port: </B>" . $Tsplit[1];
+				return $buffer ;
+			}else{
+				return "" ;
+			}
+		}
+	}
+}
+
+
+?>
Index: branches/web-klask/libLDAP.php
===================================================================
--- branches/web-klask/libLDAP.php	(revision 40)
+++ branches/web-klask/libLDAP.php	(revision 40)
@@ -0,0 +1,54 @@
+<?
+
+function auth_ldap ($idLogin, $passwd) {
+
+   
+    if ($idLogin != "" && $passwd != "") {
+        $ds=@ldap_connect($GLOBALS['hostLDAP'], "389");
+        $r = @ldap_search( $ds,$GLOBALS['dnUser'], 'uid=' . $idLogin);
+        if ($r) {
+            $result = @ldap_get_entries( $ds, $r);
+			//echo $result[0]['dn'] ;
+            if ($result[0]) {
+                if (@ldap_bind( $ds, $result[0]['dn'], $passwd) ) {
+                    //echo $result[0];
+					return 1;
+                }else{
+					return "AUTHENTIFICATION: [FAILED]" ;
+				}
+            }else{
+					return "AUTHENTIFICATION: [FAILED]";
+			}
+        }else{
+			return "AUTHENTIFICATION: [FAILED]";
+		}
+    }else{
+		return "Les champs Login et mot de passe sont obligatoires";
+	}
+
+	
+}
+
+function getServiceLDAP ($idLogin) {
+
+   
+    if ($idLogin != "" ) {
+
+        $ds=@ldap_connect($GLOBALS['hostLDAP'], "389");
+        $r = @ldap_search( $ds,$GLOBALS['dnUser'], 'uid=' . $idLogin);
+       
+		if ($r) {
+            $result = @ldap_get_entries( $ds, $r);
+			//echo $result[0]['dn'] ;
+            if ($result[0]) {
+				return $result[0][$GLOBALS['dnService']];
+            }
+        }
+    }
+
+	
+}
+
+
+
+?>
Index: branches/web-klask/libNetwork.php
===================================================================
--- branches/web-klask/libNetwork.php	(revision 40)
+++ branches/web-klask/libNetwork.php	(revision 40)
@@ -0,0 +1,101 @@
+<?
+
+function addNetwork($addressNetwork, $nameNetwork, $interface, $routeur) {
+	$link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	return $buffer;
+}
+
+
+$db_selected = @mysql_select_db($GLOBALS['nameDB'], $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sÃ©lectionner la base de donnÃ©es :$nameDB"  . mysql_error();
+    }
+
+
+
+//Add switch
+$sql = "INSERT INTO NETWORK VALUE('$addressNetwork', '$nameNetwork', '$interface', '$routeur');";
+
+if (mysql_query($sql, $link)) {
+   $buffer = 1;
+} else {
+   $buffer = "CREATE NETWORK $addressNetwork $nameNetwork : [FAILED] :" . mysql_error() ;
+}
+
+return $buffer;
+}
+
+
+
+function selectNetwork($filter) {
+//connect DB
+$link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	return $buffer;
+}
+
+
+$db_selected = @mysql_select_db($GLOBALS['nameDB'], $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sÃ©lectionner la base de donnÃ©es :$nameDB"  . mysql_error();
+    }
+
+	
+	if (empty($filter)) {
+		$sql = "SELECT * FROM NETWORK";
+	}else{
+		$sql = "SELECT * FROM NETWORK WHERE $filter ;"  ;
+	}
+
+
+if ($result = mysql_query($sql, $link)) {
+	//test if $return is_array
+    return  $result ;
+
+} else {
+   $buffer = "SELECT NETWORK : [FAILED] :" . mysql_error() ;
+    return $buffer ;   
+}
+
+
+}
+
+
+
+
+function delNetwork($addressNetwork) {
+
+$buffer = "";
+
+//connect DB
+$link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	return $buffer;
+}
+
+
+$db_selected = @mysql_select_db($GLOBALS['nameDB'], $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sÃ©lectionner la base de donnÃ©es :$nameDB"  . mysql_error();
+    }
+
+
+//del switch from SERVICESWITCH
+$sql = "DELETE FROM  NETWORK WHERE idNetwork='$addressNetwork'";
+if (mysql_query($sql, $link)) {
+   $buffer .= "DELETE NETWORK $hostname : [OK]<BR />";
+} else {
+   $buffer = "DELETE NETWORK $hostname : [FAILED] :" . mysql_error() ;
+   return $buffer;
+}
+
+
+return $buffer;
+}
+
+
+?>
Index: branches/web-klask/libRight.php
===================================================================
--- branches/web-klask/libRight.php	(revision 40)
+++ branches/web-klask/libRight.php	(revision 40)
@@ -0,0 +1,281 @@
+<?
+require('./conf/config.php');
+
+/***************************************************************************
+*
+* addPower($idPower, $descPower)
+* selectPower($idPower)
+* delPower($idPower)
+* updatePower($idPowern $descPower)
+* ctrlPower($idLogin, $idService, $idPower, $idSwitch)
+*
+*****************************************************************************/
+
+
+
+function addPower($idPower, $descPower) {
+//connect DB
+$link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	return $buffer;
+}
+
+$db_selected = @mysql_select_db($GLOBALS['nameDB'], $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sÃ©lectionner la base de donnÃ©es :$nameDB"  . mysql_error();
+    }
+
+
+//Add Power
+$sql = "INSERT INTO POWER VALUE('$idPower', '$descPower');";
+
+if (mysql_query($sql, $link)) {
+   $buffer = 1;
+} else {
+   $buffer = "CREATE POWER $idPower, $descPower: [FAILED] :" . mysql_error() ;
+}
+
+return $buffer;
+}
+
+
+
+function selectPower($idPower) {
+//connect DB
+$link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	return $buffer;
+}
+
+$db_selected = @mysql_select_db($GLOBALS['nameDB'], $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sÃ©lectionner la base de donnÃ©es :$nameDB"  . mysql_error();
+    }
+	
+	
+	if (empty($idPower)) {
+		$sql = "SELECT * FROM POWER";
+	}else{
+		$sql = "SELECT * FROM POWER WHERE idPower='$idPower'; ";
+	}
+
+
+if ($result = mysql_query($sql, $link)) {
+	//test if $return is_array
+    return  $result ;
+
+} else {
+   $buffer = "SELECT POWER $idPower: [FAILED] :" . mysql_error() ;
+    return $buffer ;   
+}
+
+
+}
+
+
+
+
+
+
+function delPower($idPower) {
+//connect DB
+$link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	return $buffer;
+}
+
+$db_selected = @mysql_select_db($GLOBALS['nameDB'], $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sÃ©lectionner la base de donnÃ©es :$nameDB"  . mysql_error();
+    }
+
+
+//del Power
+
+
+$sql = "DELETE FROM Power WHERE idPower='$idPower';";
+
+if (mysql_query($sql, $link)) {
+   $buffer = "DELETE POWER $idPower: [OK]";
+} else {
+   $buffer = "DELETE POWER $idPower: [FAILED] :" . mysql_error() ;
+}
+
+return $buffer;
+}
+
+
+function updatePower($idPower, $descPower) {
+//connect DB
+$link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	return $buffer;
+}
+
+
+$db_selected = @mysql_select_db($GLOBALS['nameDB'], $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sÃ©lectionner la base de donnÃ©es :$nameDB"  . mysql_error();
+    }
+
+//update Power
+$sql = "UPDATE POWER SET 
+        idPower='$idPower',
+        descPower='$descPower',
+  		WHERE idPower='$idPower' ;" ;
+
+if (mysql_query($sql, $link)) {
+   $buffer = "UPDATE POWER $idPower, $descPower: [OK]";
+} else {
+   $buffer = "UPDATE POWER $idPower, $descPower: [FAILED] :" . mysql_error() ;
+}
+
+return $buffer;
+}
+
+
+
+
+
+function ctrlPower($idLogin,  $idPower, $idSwitch) {
+
+//connect DB
+$link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	return $buffer;
+}
+
+$db_selected = @mysql_select_db($GLOBALS['nameDB'], $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sÃ©lectionner la base de donnÃ©es :$nameDB"  . mysql_error();
+    }
+
+
+$varCtrl=0;
+
+//Powers for switch are just update, delete, disablePort, enablePort. /!\ No addSwitch is not possible to check Powers for a switch to create /!\
+if (!empty($idSwitch)) {
+   //Verify if service is authorized to execute Power for a switch
+   
+//recupere le ou les services de l'utilisateur loggÃ©
+	$resultat  = selectUserService($idLogin, "");
+	if ( !is_string($resultat) ) {
+		while ( $row = mysql_fetch_assoc($resultat) ) {
+			$idService = $row['idService'];
+			//check if service is authorized to execute command
+		   $sql = "SELECT COUNT(CMDSERVICE.idService) FROM CMDSERVICE, SERVICESWITCH
+                           WHERE CMDSERVICE.idService='$idService'
+                           AND idPower='$idPower'
+	                   AND SERVICESWITCH.idService = CMDSERVICE.idService
+                           AND SERVICESWITCH.idSwitch='$idSwitch';" ;
+			   
+			if ($result = mysql_query($sql, $link)) {
+				$buffer = "VEFICATION SERVICE'S POWER: $idService, $idPower FOR SWITCH $idSwitch : [OK]";
+				while ($rowCount = mysql_fetch_row($result) ) {
+					if ( $rowCount[0] == 1 ) {
+						$varCtrl=1;
+					}
+				}
+			}else {
+				$buffer = "VEFICATION SERVICE'S POWER: $idService, $idPower FOR SWITCH $idSwitch : [FAILED] :" .mysql_error() ;
+				return $buffer;
+			}
+		}
+	}else{
+		
+         return $resultat;
+	}
+
+
+
+   //verify if user is authorized to execute Power for a switch
+
+   $sql = "SELECT COUNT(idPower) FROM CMDSWITCH
+              WHERE idUser='$idLogin'
+              AND idPower='$idPower'
+              AND idSwitch='$idswitch';" ;
+
+   if ($result = mysql_query($sql, $link)) {
+      $buffer = "VEFICATION USER'S POWER : $idLogin, $idPower FOR SWITCH $idSwitch : [OK]";
+      while ($row = mysql_fetch_row($result) ) {
+         if ( $row[0] == 1 ) {
+			$varCtrl=1;
+         }
+	   } 
+   }else {
+      $buffer = "VEFICATION USER'S POWER: $idService, $idPower FOR SWITCH $idSwitch : [FAILED] :" . mysql_error() ;
+      return $buffer;
+   }
+
+}else{
+	
+	
+	//recupere le ou les services de l'utilisateur loggÃ©
+	$resultat  = selectUserService($idLogin,"");
+	if ( !is_string($resultat) ) {
+		while ( $row = mysql_fetch_assoc($resultat) ) {
+			$idService = $row['idService'];
+			//check if service is authorized to execute command
+		   $sql = "SELECT COUNT(idService) FROM CMDSERVICE 
+               WHERE CMDSERVICE.idService='$idService'
+               AND idPower='$idPower' ;";
+	           
+            if ($result = mysql_query($sql, $link)) {
+				$buffer = "VEFICATION SERVICE'S POWER: $idService, $idPower : [OK]";
+				while ($row = mysql_fetch_row($result) ) {
+					if ( $row[0] == 1 ) {
+						$varCtrl=1;
+					}
+				}
+		    }else {
+				$buffer = "VEFICATION SERVICE'S POWER: $idService, $idPower : [FAILED] :" .mysql_error() ;
+				return $buffer;
+			}
+		}
+		
+	}else{
+		
+         return $resultat;
+	}
+
+	
+	
+
+   //check if user is authorized to execute command
+   $sql = "SELECT COUNT(idPower) FROM CMDUSER
+              WHERE idUser='$idLogin'
+              AND idPower='$idPower' " ;
+
+   if ($result = mysql_query($sql, $link)) {
+      $buffer = "VEFICATION USER'S POWER : $idLogin, $idPower : [OK]";
+      while ($row = mysql_fetch_row($result) ) {
+         if ( $row[0] == 1 ) {
+			$varCtrl=1;
+         }
+	   } 
+   }else {
+      $buffer = "VEFICATION USER'S POWER: $idService, $idPower : [FAILED] :" . mysql_error() ;
+      return $buffer;
+   }
+
+
+
+}
+
+if ( $varCtrl == 1 ) {
+	return 1 ;
+}else{
+	return "ACCESS DENIED FOR THIS COMMAND $idPower FOR ". $idLogin ;
+}
+
+}
+
+
+
+
+?>
Index: branches/web-klask/libService.php
===================================================================
--- branches/web-klask/libService.php	(revision 40)
+++ branches/web-klask/libService.php	(revision 40)
@@ -0,0 +1,255 @@
+<?
+
+require('./conf/config.php');
+
+/********************************************************************************
+*
+* addService($idService)
+* selectService($idService) 
+* delService($idService)
+* addCMDService($idService, $command)
+* selectCMDService($idService)
+* delCMDService($idService, $command) 
+*
+*
+*
+********************************************************************************/
+
+
+
+
+function addService($idService) {
+
+//connect DB
+$link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	return $buffer;
+}
+
+$db_selected = @mysql_select_db($GLOBALS['nameDB'], $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sÃ©lectionner la base de donnÃ©es :$nameDB"  . mysql_error();
+    }
+
+
+//Add service
+$sql = "INSERT INTO SERVICE VALUE('$idService');";
+
+if (mysql_query($sql, $link)) {
+   $buffer = 1 ;
+} else {
+   $buffer = "CREATE SERVICE $idService: [FAILED] :" . mysql_error() ;
+}
+
+return $buffer;
+
+
+}
+
+
+
+function selectService($idService) {
+//connect DB
+$link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	return $buffer;
+}
+
+
+$db_selected = mysql_select_db($GLOBALS['nameDB'], $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sÃ©lectionner la base de donnÃ©es :$nameDB"  . mysql_error();
+    }
+	
+	if (empty($idService)) {
+		$sql = "SELECT * FROM SERVICE";
+	}else{
+		$sql = "SELECT * FROM SERVICE WHERE idService='$idService'; ";
+	}
+
+
+if ($result = mysql_query($sql, $link)) {
+	//test if $return is_array
+	
+    return  $result ;
+
+} else {
+   $buffer = "SELECT SERVICE $idService: [FAILED] :" . mysql_error() ;
+    return $buffer ;   
+}
+
+
+}
+
+
+
+
+
+function delService($idService) {
+
+//connect DB
+$link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	return $buffer;
+}
+
+$db_selected = @mysql_select_db($GLOBALS['nameDB'], $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sÃ©lectionner la base de donnÃ©es :$nameDB"  . mysql_error();
+    }
+
+//del service from SERVICEUSER
+$sql = "DELETE FROM SERVICEUSER WHERE idService = '$idService';";
+
+if (mysql_query($sql, $link)) {
+   $buffer .= "DELETE SERVICE $idService FROM TABLE SERVICEUSER: [OK]<BR />";
+} else {
+   $buffer = "DELETE SERVICE $idService FROM TABLE SERVICEUSER: [FAILED] :" . mysql_error() ;
+   return $buffer;
+}
+
+//del service from SERVICESWITCH
+$sql = "DELETE FROM SERVICESWITCH WHERE idService='$idService' ;";
+
+if (mysql_query($sql, $link)) {
+   $buffer = 1 ;
+}else{   
+   $buffer = "DELETE SERVICE $idService FROM TABLE SERVICESWITCH : [FAILED] :" . mysql_error() ;
+return $buffer ;   
+}
+
+
+
+//del service from CMDSERVICE
+$sql = "DELETE FROM CMDSERVICE WHERE idService = '$idService';";
+
+if (mysql_query($sql, $link)) {
+   $buffer .= "DELETE SERVICE $idService FROM TABLE CMDSERVICE: [OK]<BR />";
+} else {
+   $buffer = "DELETE SERVICE $idService FROM TABLE CMDSERVICE: [FAILED] :" . mysql_error() ;
+   return $buffer;
+}
+
+//del service
+$sql = "DELETE FROM SERVICE WHERE idService='$idService';";
+
+if (mysql_query($sql, $link)) {
+   $buffer = "DELETE SERVICE $idService: [OK]<BR />";
+} else {
+   $buffer = "DELETE SERVICE $idService: [FAILED] :" . mysql_error() ;
+}
+
+return $buffer;
+
+}
+
+
+function addCMDService($idService, $command) {
+
+//connect DB
+$link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	return $buffer;
+}
+
+$db_selected = @mysql_select_db($GLOBALS['nameDB'], $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sÃ©lectionner la base de donnÃ©es :$nameDB"  . mysql_error();
+    }
+
+
+
+//Add command (right) for service
+$sql = "INSERT INTO CMDSERVICE VALUE('$command', '$idService');";
+
+if (mysql_query($sql, $link)) {
+   $buffer =1;
+} else {
+   $buffer = "ADD COMMAND $command FOR SERVICE $idService: [FAILED] :" . mysql_error() ;
+}
+
+return $buffer;
+}
+
+
+function selectCMDService($idService, $idPower) {
+
+//connect DB
+$link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	return $buffer;
+}
+
+
+$db_selected = @mysql_select_db($GLOBALS['nameDB'], $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sÃ©lectionner la base de donnÃ©es :$nameDB"  . mysql_error();
+    }
+
+
+	if (empty($idService) && empty($idPower) ) {
+		$sql = "SELECT * FROM CMDSERVICE";
+	}else{
+		if ( !empty($idService) && empty($idPower) ) {
+			
+			$sql = "SELECT * FROM CMDSERVICE WHERE idService='$idService'; ";
+		}else{
+			if ( empty($idService) && !empty($idPower) ) {
+				$sql = "SELECT * FROM CMDSERVICE WHERE idPower='$idPower'; ";
+			}else{
+				$sql = "SELECT * FROM CMDSERVICE WHERE idService='$idService' AND idPower='$idPower'; ";
+			}
+		}
+	}
+
+
+if ($result = mysql_query($sql, $link)) {
+	//test if $return is_array
+    return  $result ;
+
+} else {
+   $buffer = "SELECT SERVICE $idService: [FAILED] :" . mysql_error() ;
+    return $buffer ;   
+}
+
+}
+
+
+
+function delCMDService($idService, $command) {
+
+//connect DB
+$link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	return $buffer;
+}
+
+
+$db_selected = @mysql_select_db($GLOBALS['nameDB'], $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sÃ©lectionner la base de donnÃ©es :$nameDB"  . mysql_error();
+    }
+
+
+//del command (right) for service
+$sql = "DELETE FROM CMDSERVICE WHERE idService='$idService'
+        AND idPower='$command';";
+
+if (mysql_query($sql, $link)) {
+   $buffer = 1;
+} else {
+   $buffer = "DELETE COMMAND $command FOR SERVICE $idService: [FAILED] :" . mysql_error() ;
+}
+
+return $buffer;
+}
+
+
+
+?>
Index: branches/web-klask/libSwitch.php
===================================================================
--- branches/web-klask/libSwitch.php	(revision 40)
+++ branches/web-klask/libSwitch.php	(revision 40)
@@ -0,0 +1,293 @@
+<?
+
+require('./conf/config.php');
+
+/****************************************************************************
+*
+* addSwitch($idSwitch, $ip, $mac, $type, $location, $level, $portIgnore)
+* selectSwitch($idSwitch)
+* delSwitch($idSwicth)
+* upateSwitch($idSwitch, $ip, $mac, $type, $location, $level, $portIgnore)
+* addSwitchService($idSwitch, $idService)
+* selectSwitchService($idSwitch, $idService) 
+* delSwitchService($idSwitch, $idService)
+*
+*****************************************************************************/
+
+
+
+
+
+//TODO: prévoir la syntaxe pour le champs portIgnore
+//TODO: prÃ©voir l'ajout de routeur
+
+function addSwitch($idSwitch, $location, $level, $portIgnore) {
+//connect DB
+$link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	return $buffer;
+}
+
+
+$db_selected = @mysql_select_db($GLOBALS['nameDB'], $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sélectionner la base de données :$nameDB"  . mysql_error();
+    }
+
+
+
+//Add switch
+$sql = "INSERT INTO SWITCH VALUE('$idSwitch', '$location', '$level', '$portIgnore');";
+
+if (mysql_query($sql, $link)) {
+   $buffer = 1;
+} else {
+   $buffer = "CREATE SWITCH $idSwicth: [FAILED] :" . mysql_error() ;
+}
+
+return $buffer;
+}
+
+
+function selectSwitch($idSwitch) {
+//connect DB
+$link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	return $buffer;
+}
+
+
+$db_selected = @mysql_select_db($GLOBALS['nameDB'], $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sélectionner la base de données :$nameDB"  . mysql_error();
+    }
+
+	
+	if (empty($idSwitch)) {
+		$sql = "SELECT * FROM SWITCH, DEVICE WHERE SWITCH.idSwitch = DEVICE.hostname";
+	}else{
+		$sql = "SELECT * FROM SWITCH, DEVICE WHERE SWITCH.idSwitch = DEVICE.hostname AND idSwitch='$idSwitch'; ";
+	}
+
+
+if ($result = mysql_query($sql, $link)) {
+	//test if $return is_array
+    return  $result ;
+
+} else {
+   $buffer = "SELECT SWITCH $idSwitch: [FAILED] :" . mysql_error() ;
+    return $buffer ;   
+}
+
+
+}
+
+
+
+
+
+
+function delSwitch($idSwitch) {
+
+$buffer = "";
+
+//connect DB
+$link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	return $buffer;
+}
+
+
+$db_selected = @mysql_select_db($GLOBALS['nameDB'], $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sélectionner la base de données :$nameDB"  . mysql_error();
+    }
+
+
+//Before  del user of Table USER, del user in all others Table
+//del switch from CMDSWITCH
+$sql="DELETE FROM CMDSWITCH WHERE idSwitch='$idSwitch';";
+if (mysql_query($sql, $link)) {
+   $buffer .= "DELETE SWITCH $idSwitch FROM CMDSWITCH: [OK]<BR />";
+} else {
+   $buffer = "DELETE SWITCH $idSwitch FROM CMDSWITCH: [FAILED] :" . mysql_error() ;
+    return $buffer;
+}
+
+//del switch from SERVICESWITCH
+$sql = "DELETE FROM  SERVICESWITCH WHERE idSwitch='$idSwitch'";
+if (mysql_query($sql, $link)) {
+   $buffer .= "DELETE SWITCH $idSwitch FROM SERVICESWITCH: [OK]<BR />";
+} else {
+   $buffer = "DELETE SWITCH $idSwitch FROM SERVICESWITCH: [FAILED] :" . mysql_error() ;
+   return $buffer;
+}
+
+
+//del switch
+$sql = "DELETE FROM SWITCH WHERE idswitch='$idSwitch';";
+
+if (mysql_query($sql, $link)) {
+   $buffer .= "DELETE SWITCH $idSwitch: [OK]<BR />";
+} else {
+   $buffer = "DELETE SWITCH $idSwitch: [FAILED] :" . mysql_error() ;
+    return $buffer;   
+}
+
+return $buffer;
+}
+
+
+
+
+function updateSwitch($idSwitch, $location, $level, $portIgnore ) {
+
+//connect DB
+$link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	return $buffer;
+}
+
+
+$db_selected = @mysql_select_db($GLOBALS['nameDB'], $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sélectionner la base de données :$nameDB"  . mysql_error();
+    }
+
+
+//update switch
+$sql = "UPDATE SWITCH SET 
+        location='$location',
+        level='$level',
+        portIgnore='$portIgnore'
+		WHERE idSwitch='$idSwitch' ;" ;
+
+if (mysql_query($sql, $link)) {
+   $buffer = 1;
+} else {
+   $buffer = "UPDATE SWITCH $idSwicth: [FAILED] :" . mysql_error() ;
+}
+
+
+return $buffer;
+
+
+}
+
+function addSwitchService($idSwitch, $idService) {
+
+//connect DB
+$link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	return $buffer;
+}
+
+
+$db_selected = @mysql_select_db($GLOBALS['nameDB'], $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sélectionner la base de données :$nameDB"  . mysql_error();
+    }
+
+
+//Add switch for a service
+$sql = "INSERT INTO SERVICESWITCH VALUE('$idService', '$idSwitch');";
+
+if (mysql_query($sql, $link)) {
+   $buffer = 1 ;
+}else{   
+   $buffer = "CREATE SERVICESWITCH $idService: [FAILED] :" . mysql_error() ;
+}
+
+return $buffer;
+
+}
+
+
+function selectSwitchService($idSwitch, $idService) {
+//connect DB
+
+$link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	return $buffer;
+}
+
+
+
+$db_selected = @mysql_select_db($GLOBALS['nameDB'], $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sÃ©lectionner la base de donnÃ©es :$nameDB"  . mysql_error();
+    }
+
+if ( empty($idSwitch) && empty($idService)) {
+	$sql = "SELECT * FROM SERVICESWITCH";
+
+}else{
+	if ( !empty($idSwitch) && !empty($idService) ) {
+	   $sql = "SELECT * FROM SERVICESWITCH
+                    WHERE idSwitch='$idSwitch'
+                     AND idService='$idService';";
+	}else{
+		if ( !empty($idSwitch) && empty($idService) ) {
+			
+		    $sql = "SELECT * FROM SERVICESWITCH
+                        WHERE idSwitch='$idSwitch';";
+		}else{
+			$sql = "SELECT * FROM SERVICESWITCH
+                        WHERE idService='$idService';";
+		}
+    }
+}
+
+if ($result = mysql_query($sql, $link)) {
+   return $result ;
+}else{   
+   $buffer = "SELECT SWITCH $idSwitch for SERVICE $idService : [FAILED] :" . mysql_error() ;
+}
+
+}
+
+
+
+
+
+function delSwitchService($idSwitch, $idService) {
+
+//connect DB
+$link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	return $buffer;
+}
+
+$db_selected = @mysql_select_db($GLOBALS['nameDB'], $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sélectionner la base de données :$nameDB"  . mysql_error();
+    }
+
+
+//del switch for a service
+$sql = "DELETE FROM SERVICESWITCH WHERE idSwitch='$idSwitch' 
+            AND idService='$idService' ;";
+
+
+if (mysql_query($sql, $link)) {
+   $buffer =  "DELETE SWITCH $idSwitch for SERVICE $idService : [OK] ";
+}else{   
+   $buffer = "DELETE SWITCH $idSwitch for SERVICE $idService : [FAILED] :" . mysql_error() ;
+}
+
+return $buffer;
+
+}
+
+
+
+
+
+?>
Index: branches/web-klask/libUser.php
===================================================================
--- branches/web-klask/libUser.php	(revision 40)
+++ branches/web-klask/libUser.php	(revision 40)
@@ -0,0 +1,552 @@
+<?
+require('./conf/config.php'); 
+/*******************************************************************************************
+*
+*
+* addUserDB($idLogin)
+* delUserDB($idLogin)
+* addUserCMD($user, $command)
+* selectUserCMD($idLogin)
+* delUserCMD($user, $command)
+* addUserService($user, $service)
+* selectUserService($idLogin)
+* delUserService($user, $service)
+* addUserCMDSwitch($command, $user, $switch)
+* selectUserCMDSwitch($command, $user,$switch)
+* delUserCMDSwitch($command, $user, $switch)
+*
+*
+********************************************************************************************/
+
+
+
+
+
+function auth_user($idLogin, $passwdUser) {
+
+
+$resultat  = selectUser($idLogin) ;
+
+	if ( !is_string($resultat) ) {
+			
+			while ( $row = mysql_fetch_assoc($resultat) ) {
+				
+				if ( $row['passwdUser'] == md5($passwdUser)  ) {
+					return 1;
+				}else{
+					$buffer = "Authentification FOR USER $idLogin [FAILED]: error password";
+					return $buffer;
+				}
+			}
+	}else{
+			$buffer = "Authentification FOR USER $idLogin [FAILED]: $resultat";
+			return $buffer;
+	}
+
+	return "Authentification Web Klask: [FAILED]";
+}
+
+
+
+
+function addUserDB($idLogin, $passwdUser) {
+//connect DB
+$link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	return $buffer;
+}
+
+
+$db_selected = @mysql_select_db($GLOBALS['nameDB'], $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sÃ©lectionner la base de donnÃ©es :$nameDB"  . mysql_error();
+    }
+
+//Check if user exist
+
+if ( ctrlUnixAccount($idLogin) == 0 ) {
+	
+	$buffer = "L'utilisateur n'existe pas sur dans le fichier /etc/passwd";
+	return $buffer ;
+}
+
+//TODO: to clean
+//md5 du mot de passe; si auth ldap md5 chaine vide
+//echo "LibUser.AddUser " . md5($passwdUser) . " @- md5 saisie ". md5("adm") ." MD5 adm et passwd base ". $row['passwdUser'] ."<BR>"; 
+$passwdUser= md5($passwdUser);
+//$sql= "INSERT INTO USER VALUE('$adminApp', '$passwdAdminApp');";
+
+//Add user
+//echo "libUser.addUser " . $passwdUser ."<BR>";
+$sql = "INSERT INTO USER VALUE('$idLogin', '$passwdUser');";
+
+if (mysql_query($sql, $link)) {
+   $buffer = 1;
+} else {
+   $buffer = "Create USER $idLogin: [FAILED] :" . mysql_error() ;
+}
+
+return $buffer;
+}
+
+
+function selectUser($idLogin) {
+//connect DB
+$link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	return $buffer;
+}
+
+
+$db_selected = @mysql_select_db($GLOBALS['nameDB'], $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sÃ©lectionner la base de donnÃ©es :$nameDB"  . mysql_error();
+    }
+	
+	
+	if (empty($idLogin)) {
+		$sql = "SELECT * FROM USER";
+
+	}else{
+		$sql = "SELECT * FROM USER WHERE idUser='$idLogin'; ";
+	}
+
+
+if ($result = mysql_query($sql, $link)) {
+	//test if $return is_array
+    return  $result ;
+
+} else {
+   $buffer = "SELECT USER $idLogin: [FAILED] :" . mysql_error() ;
+    return $buffer ;   
+}
+
+
+}
+
+
+
+
+
+
+function delUserDB($idLogin) {
+
+//connect DB
+$buffer = "";
+$link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	return $buffer;
+}
+
+
+$db_selected = @mysql_select_db($GLOBALS['nameDB'], $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sÃ©lectionner la base de donnÃ©es :$nameDB"  . mysql_error();
+    }
+
+if ( $idLogin == $GLOBALS['adminApp'] ) {
+	$buffer = "DELETE USER $idLogin : [FAILED] : CAN'T DELETE USER ADMIN APPLICATION";
+	return $buffer ;
+}
+
+//Before  del user of Table USER, del user in all others Table
+//Del user from CMDUSER
+$sql = "DELETE FROM CMDUSER WHERE idUser = '$idLogin';";
+
+if (mysql_query($sql, $link)) {
+   $buffer .= "DELETE USER $idLogin FROM TABLE CMDUSER: [OK]<BR />";
+   
+} else {
+   $buffer = "DELETE USER $idLogin FROM TABLE CMDUSER: [FAILED] :" . mysql_error() ;
+   return $buffer;
+}
+
+
+
+
+//Del user from CMDSWITCH
+$sql = "DELETE FROM CMDSWITCH WHERE idUser = '$idLogin';";
+
+if (mysql_query($sql, $link)) {
+   $buffer .= "DELETE USER $idLogin FROM TABLE CMDSWITCH: [OK]<BR />";
+} else {
+   $buffer = "DELETE USER $idLogin FROM TABLE CMDSWITCH: [FAILED] :" . mysql_error() ;
+   return $buffer;
+}
+
+//del user from SERVICEUSER
+$sql = "DELETE FROM SERVICEUSER WHERE idUser = '$idLogin';";
+
+if (mysql_query($sql, $link)) {
+   $buffer .= "DELETE USER $idLogin FROM TABLE SERVICEUSER: [OK]<BR />";
+} else {
+   $buffer = "DELETE USER $idLogin FROM TABLE SERVICEUSER: [FAILED] :" . mysql_error() ;
+   return $buffer;
+}
+
+
+//Del user
+$sql = "DELETE FROM USER WHERE idUser = '$idLogin';";
+
+if (mysql_query($sql, $link)) {
+   $buffer .= "DELETE USER $idLogin FROM TABLE USER: [OK] <BR />";
+} else {
+   $buffer = "DELETE USER $idLogin FROM TABLE USER: [FAILED] :" . mysql_error() ;
+   return $buffer;
+}
+
+return $buffer;
+}
+
+
+function addUserCMD($user, $command) {
+
+//connect DB
+$link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	return $buffer;
+}
+
+
+$db_selected = @mysql_select_db($GLOBALS['nameDB'], $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sÃ©lectionner la base de donnÃ©es :$nameDB"  . mysql_error();
+    }
+
+
+//add power for user in table cmdUser
+$sql = "INSERT INTO CMDUSER VALUE('$command' , '$user' );";
+
+if (mysql_query($sql, $link)) {
+   $buffer = 1;
+} else {
+   $buffer = "ADD SERVICE $command FOR $user: [FAILED] :" . mysql_error() ;
+   return $buffer;
+}
+
+return $buffer;
+}
+
+
+function selectUserCMD($idLogin, $idPower) {
+
+//connect DB
+$link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	return $buffer;
+}
+
+
+$db_selected = @mysql_select_db($GLOBALS['nameDB'], $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sÃ©lectionner la base de donnÃ©es :$nameDB"  . mysql_error();
+    }
+
+
+
+if (empty($idLogin) && empty($idPower) ) {
+		$sql = "SELECT * FROM CMDUSER";
+	}else{
+		if ( !empty($idLogin) && empty($idPower) ) {
+			$sql = "SELECT * FROM CMDUSER WHERE idUser='$idLogin'; ";
+		}else{
+			if ( empty($idService) && !empty($idPower) ) {
+				$sql = "SELECT * FROM CMDUSER WHERE idPower='$idPower'; ";
+			}else{
+				$sql = "SELECT * FROM CMDUSER WHERE idUser='$idLogin' AND idPower='$idPower'; ";
+			}
+		}
+	}
+	
+if ($result = mysql_query($sql, $link)) {
+	//test if $return is_array
+    return  $result ;
+
+} else {
+   $buffer = "SELECT POWERFOR USER $idLogin: [FAILED] :" . mysql_error() ;
+    return $buffer ;   
+}
+
+}
+
+
+function delUserCMD($user, $command) {
+
+//connect DB
+$link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	return $buffer;
+}
+
+$db_selected = @mysql_select_db($GLOBALS['nameDB'], $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sÃ©lectionner la base de donnÃ©es :$nameDB"  . mysql_error();
+    }
+
+if ( $user == $GLOBALS['adminApp'] ) {
+	$buffer = "DELETE RIGHT FOR $idLogin : [FAILED] : CAN'T DELETE RIGHT FOR USER ADMIN APPLICATION";
+	return $buffer ;
+}
+
+
+//del power for user in table cmdUser
+$sql = "DELETE FROM CMDUSER WHERE idUser='$user'
+        AND idPower='$command' ;";
+
+if (mysql_query($sql, $link)) {
+   $buffer =1;
+} else {
+   $buffer = "DELETE SERVICE $command FOR $user: [FAILED] :" . mysql_error() ;
+   return $buffer;
+}
+
+return $buffer;
+}
+
+function addUserService($user, $service) {
+
+//connect DB
+$link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	return $buffer;
+}
+
+
+$db_selected = @mysql_select_db($GLOBALS['nameDB'], $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sÃ©lectionner la base de donnÃ©es :$nameDB"  . mysql_error();
+    }
+
+
+
+//add service for user
+$sql = "INSERT INTO SERVICEUSER VALUE('$user', '$service');";
+
+if (mysql_query($sql, $link)) {
+   $buffer = 1;
+} else {
+   $buffer = "ADD SERVICE $service FOR $user: [FAILED] :" . mysql_error() ;
+   return $buffer;
+}
+
+return $buffer;
+}
+
+
+function selectUserService($idLogin, $idService) {
+
+//connect DB
+$link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	return $buffer;
+}
+
+
+$db_selected = @mysql_select_db($GLOBALS['nameDB'], $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sÃ©lectionner la base de donnÃ©es :$nameDB"  . mysql_error();
+    }
+
+
+
+	if (empty($idLogin) && empty($idService) ) {
+		$sql = "SELECT * FROM SERVICEUSER";
+	}else{
+		if ( !empty($idLogin) && empty($idService) ) {
+			
+			$sql = "SELECT * FROM SERVICEUSER WHERE idUser='$idLogin'; ";
+		}else{
+			if ( empty($idLogin) && !empty($idService) ) {
+				
+				$sql = "SELECT * FROM SERVICEUSER WHERE idService='$idService'; ";
+			}else{
+				$sql = "SELECT * FROM SERVICEUSER WHERE idService='$idService' AND idUser='$idLogin'; ";
+			}
+		}
+	}
+
+
+if ($result = mysql_query($sql, $link)) {
+	//test if $return is_array
+    return  $result ;
+
+} else {
+   $buffer = "SELECT SERVICE FOR USER $idLogin: [FAILED] :" . mysql_error() ;
+    return $buffer ;   
+}
+
+}
+
+
+
+
+
+
+function delUserService($user, $service) {
+
+//connect DB
+$link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	return $buffer;
+}
+
+$db_selected = @mysql_select_db($GLOBALS['nameDB'], $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sÃ©lectionner la base de donnÃ©es :$nameDB"  . mysql_error();
+    }
+
+
+
+
+//del service for user
+$sql = "DELETE FROM SERVICEUSER WHERE idUser='$user'
+        AND idService='$service';";
+
+if (mysql_query($sql, $link)) {
+  $buffer = "DELETE SERVICE $service FOR $user: [OK] <BR />";
+} else {
+   $buffer = "DELETE SERVICE $service FOR $user: [FAILED] :" . mysql_error() ;
+   return $buffer;
+}
+
+return $buffer;
+}
+
+function addUserCMDSwitch($command, $user, $switch) {
+//connect DB
+$link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	return $buffer;
+}
+
+
+$db_selected = @mysql_select_db($GLOBALS['nameDB'], $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sÃ©lectionner la base de donnÃ©es :$nameDB"  . mysql_error();
+    }
+
+
+
+//add power for user for switch
+$sql = "INSERT INTO CMDSWITCH VALUES('$command', '$switch', '$user');";
+
+if (mysql_query($sql, $link)) {
+   $buffer = "ADD POWER $command FOR $user ON $switch: [OK] <BR />";
+} else {
+   $buffer = "ADD POWER $command FOR $user ON $switch: [FAILED] :" . mysql_error() ;
+   return $buffer;
+}
+
+return $buffer;
+}
+
+
+function selectUserCMDSwitch($idPower, $idLogin,$idSwitch) {
+
+//connect DB
+$link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	return $buffer;
+}
+
+$db_selected = @mysql_select_db($GLOBALS['nameDB'], $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sÃ©lectionner la base de donnÃ©es :$nameDB"  . mysql_error();
+    }
+
+
+if ( empty($idSwitch) && empty($idLogin) && empty($idPower) ) {
+	$sql = "SELECT * FROM CMDSWITCH";
+
+}else{
+	if ( !empty($idSwitch) && !empty($idLogin) && !empty($idPower) ) {
+	   $sql = "SELECT * FROM CMDSWITCH
+                    WHERE idSwitch='$idSwitch'
+                     AND idLogin='$idLogin'
+					 AND idPower='$command';";
+	}else{
+		if ( !empty($idSwitch) && empty($idLogin) && empty($idPower) ) {
+		    $sql = "SELECT * FROM SERVICESWITCH
+                    WHERE idSwitch='$idSwitch';";
+		}else{
+		    if ( !empty($idSwitch) && !empty($idLogin) && empty($idPower) ) {
+			   $sql = "SELECT * FROM SERVICESWITCH
+                       WHERE idSwitch='$idSwitch'
+					   AND idLogin='$idLogin';";
+			}else{
+			   if ( !empty($idSwitch) && empty($idLogin) && !empty($idPower) )  {
+                  $sql = "SELECT * FROM SERVICESWITCH
+                          WHERE idSwitch='$idSwitch'
+					      AND idPower='$idPower';";
+               }else{
+			      if ( !empty($idLogin) && empty($idSwitch) && empty($idPower) ) {
+					$sql = "SELECT * FROM SERVICESWITCH
+                            WHERE idLogin='$idLogin';";
+				  }else{
+				     if ( !empty($idLogin) && empty($idSwitch) && !empty($idPower) ) {
+					   $sql = "SELECT * FROM SERVICESWITCH
+                               WHERE idLogin='$idLogin'
+					           AND idPower='$idPower';";
+					 }else{
+					    if ( !empty($idPower) && empty($idLogin) && empty($idSwitch) ) {
+						   $sql = "SELECT * FROM SERVICESWITCH
+                                   WHERE idPower='$idPower';";
+						}
+					 }
+				  }
+               }			   
+			}
+		}
+    }
+}
+
+if (mysql_query($sql, $link)) {
+   $buffer = 1 ;
+}else{   
+   $buffer = "SELECT SWITCH $idSwitch for SERVICE $idService : [FAILED] :" . mysql_error() ;
+}
+
+}
+
+
+function delUserCMDSwitch($command, $user, $switch) {
+//connect DB
+$link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']);
+if (!$link) {
+    $buffer = "Connexion [FAILED]: " . mysql_error() ;
+	return $buffer;
+}
+
+$db_selected = @mysql_select_db($GLOBALS['nameDB'], $link);
+    if (!$db_selected) {
+       $buffer .= "Impossible de sÃ©lectionner la base de donnÃ©es :$nameDB"  . mysql_error();
+    }
+
+
+
+//del power for user for switch
+$sql = "DELETE FROM CMDSWITCH VALUES('$command', '$switch', '$user');";
+
+if (mysql_query($sql, $link)) {
+   $buffer = "DELETE POWER $command FOR $user ON $switch: [OK]";
+} else {
+   $buffer = "DELETE POWER $command FOR $user ON $switch: [FAILED] :" . mysql_error() ;
+   return $buffer;
+}
+
+return $buffer;
+}
+
+
+?>
Index: branches/web-klask/resultat-inc.php
===================================================================
--- branches/web-klask/resultat-inc.php	(revision 40)
+++ branches/web-klask/resultat-inc.php	(revision 40)
@@ -0,0 +1,116 @@
+<?
+//session_start();
+require('./libInstall.php');
+require('./libDisplay.php');
+require('./ctrl.php');
+
+
+
+if ( $_GET['section'] == "addService" ) {
+	if ( $GLOBALS['auth'] == "classic" ) {
+		echo displayResultAddService($_POST['textIdService']);	
+	}else{
+		echo "<h1>RÃ©sultat de la Commande</h1>";
+		echo "ADD SERVICE [FAILED]: Your authentification use LDAP<BR>"; 
+	}
+	
+	
+}
+
+if ( $_GET['section'] == "addUser" ) {
+	if ( $GLOBALS['auth'] == "classic" ) {
+		echo displayResultAddUser($_POST['textIdLogin'], $_POST['textPasswdUser'], $_POST['selectIdService'] );	
+	}else{
+		echo displayResultAddUser($_POST['textIdLogin'], "", "");
+	}
+}
+
+if ( $_GET['section'] == "addSwitch" ) {
+	echo displayResultAddSwitch($_POST['selectIdSwitch'], $_POST['textLocation'], $_POST['textLevel'], $_POST['textPortIgnore'], $_POST['selectIdService']);	
+	
+}
+
+if ( $_GET['section'] == "addPower" ) {
+	echo displayResultAddPower($_POST['textIdPower'], $_POST['textDescPower']);	
+}
+
+if ( $_GET['section'] == "addPowerUser" ) {
+	echo displayResultAddUserPower($_POST['selectUser'], $_POST['selectPower']);	
+}
+
+if ( $_GET['section'] == "addUserService" ) {
+	
+	if ( $GLOBALS['auth'] == "classic" ) {
+		echo displayResultAddUserService($_POST['selectUser'], $_POST['selectService']);	
+	}else{
+		echo "<h1>RÃ©sultat de la Commande</h1>";
+		echo "ADD SERVICE FOR USER [FAILED]: Your authentification use LDAP<BR>"; 
+	}
+}
+
+if ( $_GET['section'] == "addSwitchService" ) {
+	echo displayResultAddSwitchService($_POST['selectSwitch'], $_POST['selectService']);
+}
+
+if ( $_GET['section'] == "addPowerService" ) {
+	echo displayResultAddPowerService($_POST['selectPower'], $_POST['selectService']);	
+}
+
+if ( $_GET['section'] == "delUser" ) {
+	echo displayResultDelUser($_POST['selectUser']);	
+	
+}
+
+if ( $_GET['section'] == "delService" ) {
+	if ( $GLOBALS['auth'] == "classic" ) {
+		echo displayResultDelService($_POST['selectService']);	
+	}else{
+		echo "<h1>RÃ©sultat de la Commande</h1>";
+		echo "DELETE SERVICE [FAILED]: Your authentification use LDAP<BR>"; 
+	}
+	
+}
+
+if ( $_GET['section'] == "delSwitch" ) {
+	echo displayResultDelSwitch($_POST['selectSwitch']);	
+}
+
+if ( $_GET['section'] == "delUserSwitchService" ) {
+	
+	echo displayDelUserSwitchService($_POST['checkUserService'], $_POST['checkSwitchService']);	
+}
+
+
+if ( $_GET['section'] == "addDevice" ) {
+	echo displayResultAddDevice($_POST['textHostname'], $_POST['textMac'], $_POST['textIP'], $_POST['selectType']);	
+}
+
+if ( $_GET['section'] == "addNetwork" ) {
+	echo displayResultAddNetwork($_POST['textIdNetwork'], $_POST['textNameNetwork'], $_POST['textInterface'], $_POST['selectRouteur']);	
+}
+
+if ( $_GET['section'] == "delDevice" ) {
+	echo displayResultDelDevice($_POST['selectDevice']);	
+}
+
+if ( $_GET['section'] == "delNetwork" ) {
+	echo displayResultDelNetwork($_POST['selectNetwork']);	
+}
+
+if ( $_GET['section'] == "delPowerUserByAllPower" ) {
+	echo displayResultDelUserPowerBydisplayAllPower($_POST['checkPowerUser']);	
+}
+
+if ( $_GET['section'] == "delPowerService" ) {
+	echo displayResultDelServicePower($_POST['checkPowerService']);
+}
+
+if ( $_GET['section'] == "updateSwitch" ) {
+	echo displayResultUpdateSwitch($_POST['textIdSwitch'], $_POST['textIP'], $_POST['textMac'], $_POST['selectType'], $_POST['textLocation'], $_POST['textLevel'], $_POST['textportIgnore'] );
+}
+
+if ( $_GET['section'] == "klaskSearch" ) {
+	echo displayKlaskSearch($_POST['textIP']);
+}
+
+?>
Index: branches/web-klask/resultat.php
===================================================================
--- branches/web-klask/resultat.php	(revision 40)
+++ branches/web-klask/resultat.php	(revision 40)
@@ -0,0 +1,179 @@
+<?
+session_start();
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+    <title>Web Klask</title>
+    
+    <meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
+    
+    <meta name="generator" content="Jonas John" />
+    <meta name="description" content="put a good description in here" />
+    <meta name="keywords" content="good,keywords" />
+    
+    <link rel="stylesheet" type="text/css" href="css/bluesky.css" media="screen, tv, projection" title="Default" />
+    <link rel="alternative stylesheet" type="text/css" href="css/bluesky_large.css" media="screen, projection, tv" title="Larger Fonts" />
+    
+    <link rel="alternative stylesheet" type="text/css" href="css/print.css" media="screen" title="Print Preview" />
+    <link rel="alternative stylesheet" type="text/css" href="css/handheld.css" media="screen" title="Small Layout Preview" />
+    
+    <link rel="stylesheet" type="text/css" href="css/handheld.css" media="handheld" title="Small Layout" />
+    <link rel="stylesheet" type="text/css" href="css/print.css" media="print" />
+
+    <!-- Navigational metadata (an accessibility feature - preview in opera) -->
+    <link rel="top" href="index.html" title="Homepage" />
+    <link rel="up" href="index.html" title="Up" />
+    <link rel="first" href="index.html" title="First page" />
+    <link rel="previous" href="index.html" title="Previous page" />
+    <link rel="next" href="index.html" title="Next page" />
+    <link rel="last" href="index.html" title="Last page" />
+    <link rel="toc" href="index.html" title="Table of contents" />
+    <link rel="index" href="index.html" title="Site map" />
+	
+</head>
+<body>
+
+<div id="page">
+    
+    <div id="header">
+        <a href="index.html">ENS LYON</a>
+    </div>
+    
+    <div id="wrapper"> 
+        
+        <div id="content">
+        
+            <div id="path">
+                A NICE GUI FOR KLASK
+            </div>
+    
+            <div id="main">
+
+                <!-- <h1>Welcome !</h1> -->
+					
+                <p>
+                  <?
+					
+					include('./resultat-inc.php');
+				
+					?>
+                </p>
+                
+            </div>
+
+        </div>
+        
+        <div id="left">
+
+            <div id="nav">
+            
+                <h3>Klask</h3>
+
+                <div class="inner_box">
+
+                    <ul>
+						<li>
+						<?
+							//mettre ici l'include du menu de navigation
+							//session_start();
+							
+
+								if ( ctrlAuth() == 0 ) {
+									echo displayAuthUser();
+								}else{
+										
+									echo navKlask();
+								}
+							
+						?>
+                        </li>
+                    </ul>                
+                </div>
+                
+				<h3>AFFICHER</h3>
+				
+				<div class="inner_box">
+
+                    <ul>
+						<li>
+						<?
+							//mettre ici l'include du menu de navigation
+							//session_start();
+					
+								if ( ctrlAuth() == 0 ) {
+								//echo displayAuthUser();
+								}else{
+									echo navDisplay();
+								}
+							
+						?>
+                        </li>
+                    </ul>                
+                </div>
+				
+				 <h3>AJOUTER</h3>
+				
+				<div class="inner_box">
+
+                    <ul>
+						<li>
+						<?
+							//mettre ici l'include du menu de navigation
+							//session_start();
+							
+								if ( ctrlAuth() == 0 ) {
+									//echo displayAuthUser();
+								}else{
+									echo navAdd();
+								}
+							
+						?>
+                        </li>
+                    </ul>                
+                </div>
+				
+				
+				<h3>Supprimer</h3>
+				
+				<div class="inner_box">
+
+                    <ul>
+						<li>
+						<?
+							//mettre ici l'include du menu de navigation
+							//session_start();
+							
+								if ( ctrlAuth() == 0 ) {
+									//echo displayAuthUser();
+								}else{
+									echo navDel();
+								}
+							
+						?>
+                        </li>
+                    </ul>                
+                </div>
+				
+                <!-- i love clean source code -->
+                
+            </div>
+        </div>
+
+    </div>
+    
+    <div id="footer">
+        <p>
+	    License GPL V2 <a href="index.html">WebKlask</a>.
+            Webdesign disponible sur <a href="http://www.oswd.org">Open Source Web Design</a>  by <a href="http://www.jonasjohn.de/">Jonas John</a>. 
+            
+            <!-- please leave a small credit to the author - thanks :-) ! -->
+            
+        </p>
+    </div>
+
+</div>
+
+</body>
+</html>
