[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 /** 2 3 * Page qui teste les differents services 4 * @Version $Id: tests.js 3002 2008-05-30 12:58:43Z keyser $ 5 * @Projet LCS / SambaEdu 6 * @auteurs Philippe Chadefaux MrT 7 * @Licence Distribue selon les termes de la licence GPL 8 * @note 9 * Modifications proposées par Sébastien Tack (MrT) 10 * Optimisation du lancement des scripts bash par la technologie asynchrone Ajax. 11 * Modification du système d'infos bulles.(Nouvelle version de wz-tooltip Fonctions Tip('msg') TagToTip() UnTip() ) Ancienne version incompatible avec ajax 12 * Externalisation des messages contenus dans les infos-bulles. 13 * Nouvelle organisation de l'arborescence. 14 15 16 */ 17 18 /** 19 20 * @Repertoire: /tests/js/ 21 * file: tests.js 22 */ 23 24 var can_connect_internet=false; 25 var ntpserver; 26 27 function trim (myString) { 28 return myString.replace(/^\s+/g,'').replace(/\s+$/g,'') 29 } 30 31 function init() { 32 //alert('Ajax works fine'); 33 //lancer a partir d'ici les divers process de test 34 ntpserver=$('ntp_server').innerHTML; 35 36 init_default_msg(); 37 38 //test ligne internet 39 var url2 = './tests/test_internet.php'; 40 var params2 = ''; 41 var method2 = 'post'; 42 43 var url = './tests/test_gateway.php'; 44 var method = 'post'; 45 var params=''; 46 $('check_gateway').src = '../elements/images/spinner.gif'; 47 var ajax2 = new Ajax.Request(url,{ method: method, parameters: params, onSuccess: function(requester){ 48 if( requester.responseText == '1') { 49 $('check_gateway').src = '../elements/images/recovery.png'; 50 $('check_dns_se3').src = '../elements/images/spinner.gif'; 51 //DNS_SE3 52 var url4 = './tests/test_dns_se3.php'; 53 var params4 = ''; 54 var method4 = 'post'; 55 var ajax32 = new Ajax.Request(url4,{ method: method4, parameters: params4, onSuccess: function(requester){ 56 var reponse4 = requester.responseText; 57 if(reponse4 == '1') 58 $('check_dns_se3').src = '../elements/images/recovery.png'; 59 else 60 $('check_dns_se3').src = '../elements/images/critical.png'; 61 }}); 62 63 64 } 65 else 66 $('check_gateway').src = '../elements/images/critical.png'; 67 }}); 68 69 //test cles 70 $('check_keys').src = '../elements/images/spinner.gif'; 71 var url9 = './tests/test_keys.php'; 72 var params9 = ''; 73 var method9 = 'post'; 74 var ajax39 = new Ajax.Request(url9,{ method: method9, parameters: params9, onSuccess: function(requester){ 75 var reponse9 = requester.responseText; 76 if(reponse9 == '1') { 77 $('check_keys').src = '../elements/images/recovery.png'; 78 $('check_keys').onmouseover= function(){ return false; }; 79 80 } else { 81 $('check_keys').src = '../elements/images/critical.png'; 82 $('check_keys').onmouseover= function() { 83 UnTip(); 84 Tip(msg_keys_ko,WIDTH,250,SHADOW,true,DURATION,duration); 85 this.onmouseout=function() { UnTip(); } 86 } 87 $('link_keys').href = link_keys_ko; 88 } 89 90 91 }}); 92 93 //test VBS 94 $('check_vbs').src = '../elements/images/spinner.gif'; 95 var url10 = './tests/test_vbs.php'; 96 var params10 = ''; 97 var method10 = 'post'; 98 var ajax310 = new Ajax.Request(url10,{ method: method10, parameters: params10, onSuccess: function(requester){ 99 var reponse10 = requester.responseText; 100 if(reponse10 == '1') { 101 $('check_vbs').src = '../elements/images/recovery.png'; 102 $('check_vbs').onmouseover= function(){ return false; }; 103 104 } 105 else { 106 $('check_vbs').src = '../elements/images/critical.png'; 107 $('check_vbs').onmouseover= function() { 108 UnTip(); 109 Tip(msg_vbs_ko,WIDTH,250,SHADOW,true,DURATION,duration); 110 this.onmouseout=function() { UnTip(); } 111 } 112 113 $('link_vbs').href = link_vbs_ko; 114 115 } 116 }}); 117 //test clonage 118 $('check_clonage').src = '../elements/images/spinner.gif'; 119 var url13 = './tests/test_clonage.php'; 120 var params13 = ''; 121 var method13 = 'post'; 122 var ajax313 = new Ajax.Request(url13,{ method: method13, parameters: params13, onSuccess: function(requester){ 123 var reponse13 = requester.responseText; 124 125 // if (reponse13 != '-1') { 126 127 // Element.show('ligne_clonage'); 128 129 130 if(reponse13 == '1') { 131 $('check_clonage').src = '../elements/images/recovery.png'; 132 $('check_clonage').onmouseover= function(){ return false; }; 133 134 } 135 else { 136 $('check_clonage').src = '../elements/images/critical.png'; 137 $('check_clonage').onmouseover= function() { 138 UnTip(); 139 Tip(msg_clonage_ko,WIDTH,250,SHADOW,true,DURATION,duration); 140 this.onmouseout=function() { UnTip(); } 141 } 142 143 $('link_clonage').href = link_clonage_ko; 144 145 } 146 147 //} else { 148 // Element.hide('ligne_clonage'); 149 //} 150 }}); 151 152 //test client 153 $('check_client').src = '../elements/images/spinner.gif'; 154 var url101 = './tests/test_client.php'; 155 var params101 = ''; 156 var method101 = 'post'; 157 var ajax3101 = new Ajax.Request(url101,{ method: method101, parameters: params101, onSuccess: function(requester){ 158 var reponse101 = requester.responseText; 159 if(reponse101 == '1') { 160 $('check_client').src = '../elements/images/recovery.png'; 161 162 163 } 164 else { 165 $('check_client').src = '../elements/images/critical.png'; 166 $('check_client').onmouseover= function() { 167 UnTip(); 168 Tip(msg_client_ko,STICKY,true,WIDTH,250,SHADOW,true,DURATION,duration); 169 this.onmouseout=function() { UnTip(); } 170 } 171 $('link_client').href = link_client_ko; 172 173 } 174 }}); 175 176 177 //test services 178 $('check_mail').src = '../elements/images/spinner.gif'; 179 $('check_smb').src = '../elements/images/spinner.gif'; 180 $('check_sid').src = '../elements/images/spinner.gif'; 181 $('check_mysql').src = '../elements/images/spinner.gif'; 182 183 184 $('check_ondul').src = '../elements/images/spinner.gif'; 185 186 187 var url11 = './tests/test_services.php'; 188 var params11 = ''; 189 var method11 = 'post'; 190 var ajax311 = new Ajax.Request(url11,{ method: method11, parameters: params11, onSuccess: function(requester){ 191 var reponse11 = eval(requester.responseText); 192 eval(requester.responseText); 193 if(arr_services[0] == '1') 194 $('check_mail').src = '../elements/images/recovery.png'; 195 else 196 $('check_mail').src = '../elements/images/critical.png'; 197 if(arr_services[1] == '1') 198 $('check_smb').src = '../elements/images/recovery.png'; 199 else { 200 $('check_smb').src = '../elements/images/critical.png'; 201 $('check_smb').onmouseover= function(){ 202 UnTip(); 203 Tip(msg_samba_ko); 204 this.onmouseout=function() { UnTip(); } 205 } 206 $('link_samba').href = link_samba_ko; 207 208 } 209 if(arr_services[2] == '1') 210 $('check_sid').src = '../elements/images/recovery.png'; 211 else { 212 $('check_sid').src = '../elements/images/critical.png'; 213 $('check_sid').onmouseover= function(){ 214 UnTip(); 215 Tip(msg_sid_ko); 216 this.onmouseout=function() { UnTip(); } 217 } 218 219 } 220 if(arr_services[3] == '1') 221 $('check_mysql').src = '../elements/images/recovery.png'; 222 else 223 $('check_mysql').src = '../elements/images/critical.png'; 224 225 if (arr_services[4] != '-1') { 226 227 Element.show('ligne_dhcp'); 228 if(arr_services[4] == '1') { 229 $('check_dhcp').src = '../elements/images/recovery.png'; 230 $('check_dhcp').onmouseover= function(){ 231 UnTip(); 232 Tip(msg_dhcp_ok); 233 this.onmouseout=function() { UnTip(); } 234 } 235 236 } 237 else { 238 $('check_dhcp').src = '../elements/images/critical.png'; 239 $('check_dhcp').onmouseover= function(){ 240 UnTip(); 241 Tip(msg_dhcp_ko); 242 this.onmouseout=function() { UnTip(); } 243 } 244 245 } 246 247 } else { 248 Element.hide('ligne_dhcp'); 249 } 250 251 if(arr_services[5] == '1') { 252 $('check_ondul').src = '../elements/images/recovery.png'; 253 $('check_ondul').onmouseover= function(){ 254 UnTip(); 255 Tip(msg_ondul_ok); 256 this.onmouseout=function() { UnTip(); } 257 } 258 $('link_ondul').href = link_ondul_ok; 259 $('help_ondul_se3').onmouseover= function(){ 260 UnTip(); 261 Tip(msg_ondul_ok); 262 this.onmouseout=function() { UnTip(); } 263 } 264 265 } 266 else 267 { 268 $('check_ondul').src = '../elements/images/warning.png'; 269 $('check_ondul').onmouseover= function(){ 270 UnTip(); 271 Tip(msg_ondul_ko); 272 this.onmouseout=function() { UnTip(); } 273 } 274 $('link_ondul').href = link_ondul_ko; 275 $('help_ondul_se3').onmouseover= function(){ 276 UnTip(); 277 Tip(msg_ondul_ko_info); 278 this.onmouseout=function() { UnTip(); } 279 } 280 281 282 } 283 284 285 286 }}); 287 288 //test services 289 $('check_disk1').src = '../elements/images/spinner.gif'; 290 $('check_disk2').src = '../elements/images/spinner.gif'; 291 $('check_disk3').src = '../elements/images/spinner.gif'; 292 $('check_disk4').src = '../elements/images/spinner.gif'; 293 294 295 296 var url12 = './tests/test_disks.php'; 297 var params12 = ''; 298 var method12 = 'post'; 299 var ajax312 = new Ajax.Request(url12,{ method: method12, parameters: params12, onSuccess: function(requester){ 300 var reponse12 = eval(requester.responseText); 301 302 $('space_disk1').innerHTML = '<I>- Espace occupé: ( '+arr_space_disks1[0]+' % )</I>'; 303 $('space_disk2').innerHTML = '<I>- Espace occupé: ( '+arr_space_disks2[0]+' % )</I>'; 304 $('space_disk3').innerHTML = '<I>- Espace occupé: ( '+arr_space_disks3[0]+' % )</I>'; 305 $('space_disk4').innerHTML = '<I>- Espace occupé: ( '+arr_space_disks4[0]+' % )</I>'; 306 307 308 if(arr_space_disks1[0] < 96) 309 $('check_disk1').src = '../elements/images/recovery.png'; 310 else 311 $('check_disk1').src = '../elements/images/critical.png'; 312 if(arr_space_disks2[0] < 96) 313 $('check_disk2').src = '../elements/images/recovery.png'; 314 else 315 $('check_disk2').src = '../elements/images/critical.png'; 316 if(arr_space_disks3[0] < 96) 317 $('check_disk3').src = '../elements/images/recovery.png'; 318 else 319 $('check_disk3').src = '../elements/images/critical.png'; 320 if(arr_space_disks4[0] < 96) 321 $('check_disk4').src = '../elements/images/recovery.png'; 322 else 323 $('check_disk4').src = '../elements/images/critical.png'; 324 325 326 327 $('help_disk1').onmouseover= function() { 328 Tip('Partition root /<br>Espace total: <b>'+arr_space_disks1[1]+' Go</b><br>Espace occupé: <b>' 329 +arr_space_disks1[2]+' Go</b><br>Espace disponible: <b>'+arr_space_disks1[3]+' Go</b>'); 330 this.onmouseout = function() { UnTip(); } 331 } 332 333 $('help_disk2').onmouseover= function() { 334 Tip('Partition /var/se3<br>Espace total: <b>'+arr_space_disks2[1]+' Go</b><br>Espace occupé: <b>' 335 +arr_space_disks2[2]+' Go</b><br>Espace disponible: <b>'+arr_space_disks2[3]+' Go</b>'); 336 this.onmouseout = function() { UnTip(); } 337 } 338 $('help_disk3').onmouseover= function() { 339 Tip('Partition /home<br>Espace total: <b>'+arr_space_disks3[1]+' Go</b><br>Espace occupé: <b>' 340 +arr_space_disks3[2]+' Go</b><br>Espace disponible: <b>'+arr_space_disks3[3]+' Go</b>'); 341 this.onmouseout = function() { UnTip(); } 342 } 343 $('help_disk4').onmouseover= function() { 344 Tip('Partition /var<br>Espace total: <b>'+arr_space_disks4[1]+' Go</b><br>Espace occupé: <b>' 345 +arr_space_disks4[2]+' Go</b><br>Espace disponible: <b>'+arr_space_disks4[3]+' Go</b>'); 346 this.onmouseout = function() { UnTip(); } 347 } 348 349 350 }}); 351 352 353 $('check_internet').src = '../elements/images/spinner.gif'; 354 var ajax3 = new Ajax.Request(url2,{ method: method2, parameters: params2, onSuccess: function(requester){ 355 can_connect_internet = (requester.responseText == '0%'); 356 if(can_connect_internet) { 357 358 var ajax311 = new Ajax.Request('tests/popup_alert.php',{ onSuccess: function(requester){ 359 eval(requester.responseText); 360 }}); 361 362 $('check_internet').src = '../elements/images/recovery.png'; 363 //DNS 364 var url3 = './tests/test_dns.php'; 365 var params3 = ''; 366 var method3 = 'post'; 367 368 $('check_dns').src = '../elements/images/spinner.gif'; 369 var ajax31 = new Ajax.Request(url3,{ method: method3, parameters: params3, onSuccess: function(requester){ 370 var reponse3 = requester.responseText; 371 if(reponse3 == '1') { 372 $('check_dns').src = '../elements/images/recovery.png'; 373 $('check_dns').onmouseover= function(){ return false; }; 374 375 } 376 else 377 $('check_dns').src = '../elements/images/critical.png'; 378 }}); 379 380 381 //MAJ 382 var url8 = './tests/test_maj.php'; 383 var params8 = ''; 384 var method8 = 'post'; 385 386 $('check_maj').src = '../elements/images/spinner.gif'; 387 var ajax38 = new Ajax.Request(url8,{ method: method8, parameters: params8, onSuccess: function(requester){ 388 var reponse8 = parseInt(requester.responseText,10); 389 390 if (-1 == reponse8) { 391 $('check_maj').src = '../elements/images/info.png'; 392 $('link_maj').href='#'; 393 $('check_maj').onmouseover= function() { 394 UnTip(); 395 Tip(msg_maj_nocx,WIDTH,250,SHADOW,true,DURATION,duration); 396 this.onmouseout=function() { UnTip(); } 397 } 398 } 399 400 if (1 == reponse8) { 401 $('check_maj').src = '../elements/images/recovery.png'; 402 $('check_maj').onmouseover= function() { 403 UnTip(); 404 Tip(msg_maj_ok,WIDTH,250,SHADOW,true,DURATION,duration); 405 this.onmouseout=function() { UnTip(); } 406 } 407 } 408 409 if (0 == reponse8) { 410 $('check_maj').src = '../elements/images/critical.png'; 411 $('check_maj').onmouseover= function() { 412 UnTip(); 413 Tip(msg_maj_ko,STICKY,true,WIDTH,250,SHADOW,true,DURATION,duration); 414 this.onmouseout=function() { UnTip(); } 415 } 416 $('link_maj').href = link_maj_ko; 417 418 } 419 }}); 420 421 //SECU 422 var url81 = './tests/test_secu.php'; 423 var params81 = ''; 424 var method81 = 'post'; 425 426 $('check_secu').src = '../elements/images/spinner.gif'; 427 var ajax381 = new Ajax.Request(url81,{ method: method81, parameters: params81, onSuccess: function(requester){ 428 var reponse81 = requester.responseText; 429 if(reponse81 == '1') { 430 $('check_secu').src = '../elements/images/recovery.png'; 431 $('check_secu').onmouseover= function(){ return false; }; 432 433 } 434 else { 435 $('check_secu').src = '../elements/images/warning.png'; 436 $('check_secu').onmouseover= function() { 437 UnTip(); 438 Tip(msg_secu_ko,STICKY,true,WIDTH,250,SHADOW,true,DURATION,duration); 439 this.onmouseout=function() { UnTip(); } 440 } 441 $('link_secu').href = link_secu_ko; 442 443 } 444 }}); 445 446 447 $('check_ftp').src = '../elements/images/spinner.gif'; 448 //FTP 449 var url5 = './tests/test_ftp.php'; 450 var params5 = ''; 451 var method5 = 'post'; 452 var ajax33 = new Ajax.Request(url5,{ method: method5, parameters: params5, onSuccess: function(requester){ 453 var reponse5 = requester.responseText; 454 if(reponse5 == '1') { 455 $('check_ftp').src = '../elements/images/recovery.png'; 456 $('check_ftp').onmouseover= function(){ return false; }; 457 458 } 459 else 460 $('check_ftp').src = '../elements/images/critical.png'; 461 }}); 462 463 464 //WEB 465 $('check_web').src = '../elements/images/spinner.gif'; 466 var url6 = './tests/test_web.php'; 467 var params6 = ''; 468 var method6 = 'post'; 469 var ajax34 = new Ajax.Request(url6,{ method: method6, parameters: params6, onSuccess: function(requester){ 470 var reponse6 = requester.responseText; 471 if(reponse6 == '1') { 472 $('check_web').src = '../elements/images/recovery.png'; 473 $('check_web').onmouseover= function(){ return false; }; 474 475 } 476 else 477 $('check_web').src = '../elements/images/critical.png'; 478 }}); 479 480 //NTP 481 $('check_ntp').src = '../elements/images/spinner.gif'; 482 var url7 = './tests/test_ntp.php'; 483 var params7 = ''; 484 var method7 = 'post'; 485 var ajax35 = new Ajax.Request(url7,{ method: method7, parameters: params7, onSuccess: function(requester){ 486 var reponse7 = requester.responseText; 487 488 if(reponse7 == '1') { 489 $('check_ntp').src = '../elements/images/recovery.png'; 490 $('check_ntp').onmouseover= function(){ 491 UnTip(); 492 this.onmouseout=function() { UnTip(); } 493 494 } 495 496 Element.show('ligne_date'); 497 $('check_time').src = '../elements/images/spinner.gif'; 498 499 var ajax35 = new Ajax.Request('tests/test_time.php',{ onSuccess: function(requester){ 500 var reponse735 = requester.responseText; 501 502 if(reponse735 == '1') 503 $('check_time').src = '../elements/images/recovery.png'; 504 else { 505 506 $('check_time').src = '../elements/images/critical.png'; 507 $('check_time').onmouseover= function(){ 508 UnTip(); 509 Tip(msg_time_ko); 510 this.onmouseout=function() { UnTip(); } 511 } 512 513 $('link_time').href = link_time_ko; 514 } 515 516 }}); 517 518 } else { 519 $('check_ntp').src = '../elements/images/critical.png'; 520 Element.hide('ligne_date'); 521 $('check_ntp').onmouseover= function(){ 522 523 if (can_connect_internet) 524 Tip(msg_ntp_ko,WIDTH,250,SHADOW,true,DURATION,duration); 525 else 526 Tip(msg_ntp_nocx,WIDTH,250,SHADOW,true,DURATION,duration); 527 } 528 } 529 }}); 530 531 532 533 534 535 } 536 else 537 $('check_internet').src = '../elements/images/critical.png'; 538 539 }}); 540 541 542 543 544 } 545 546 Event.observe(window,'load',init,false); 547
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Mar 17 22:47:18 2015 | Cross-referenced by PHPXref 0.7.1 |