IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VBScript Discussion :

Trier un tableau dans une HTA avec javascript


Sujet :

VBScript

  1. #1
    Membre habitué
    Homme Profil pro
    Ingénieur systèmes et réseaux
    Inscrit en
    Juillet 2012
    Messages
    284
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur systèmes et réseaux
    Secteur : Finance

    Informations forums :
    Inscription : Juillet 2012
    Messages : 284
    Points : 132
    Points
    132
    Par défaut Trier un tableau dans une HTA avec javascript
    Bonjour,

    J'ai un JS qui permet de trier les colonnes de mon tableau (ASC,DESC).

    Ca fonctionne si je fais du html classique, je peux trier mes colonnes générées statiquement.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     
    <html>
    <script type="text/javascript" src="sort_table.js"></script>
     
    <table class = 'sortable'><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th><tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td> </tr><tr><td>11</td><td>12</td><td>13</td><td>14</td><td>15</td></tr></table>
     
    <body>
    <span id = "oDivDisplayArea"></span></br>
    </body>
    </html>
    Cependant si maintenant, je veux trier mon tableau généré en vbs ca ne fonctionne plus Mon tableau s'affiche mais deviens statique, je ne peux plus utiliser les flèches qui permettent de trier mes colonnes.

    Si vous avez une idée, je suis preneur.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
     
    <html>
    <script type="text/javascript" src="sort_table.js"></script>
     
    <script language="VBScript">
    Sub window_Onload
    	oDivDisplayArea.innerHTML = "<table class = 'sortable'><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th><tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td> </tr><tr><td>11</td><td>12</td><td>13</td><td>14</td><td>15</td></tr></table>"
    End sub	
    </script>
     
    <body>
    <span id = "oDivDisplayArea"></span></br>
    </body>
    </html>
    Merci d'avance ...

  2. #2
    Expert éminent
    Avatar de hackoofr
    Homme Profil pro
    Enseignant
    Inscrit en
    Juin 2009
    Messages
    3 840
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Juin 2009
    Messages : 3 840
    Points : 9 225
    Points
    9 225
    Par défaut

    Pouvez-vous poster le code de sort_table.js

  3. #3
    Membre habitué
    Homme Profil pro
    Ingénieur systèmes et réseaux
    Inscrit en
    Juillet 2012
    Messages
    284
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur systèmes et réseaux
    Secteur : Finance

    Informations forums :
    Inscription : Juillet 2012
    Messages : 284
    Points : 132
    Points
    132
    Par défaut
    hello hackfoor

    C'est un script que j'ai récupéré ici, il fonctionne pas de pb.

    http://www.kryogenix.org/code/browse...e/sorttable.js

    Pour moi ce n'est pas le JS, mais merci à toi

  4. #4
    Expert éminent
    Avatar de hackoofr
    Homme Profil pro
    Enseignant
    Inscrit en
    Juin 2009
    Messages
    3 840
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Juin 2009
    Messages : 3 840
    Points : 9 225
    Points
    9 225
    Par défaut

    Voila un JS un peu modifié et qui fait l'affaire inspiré par ici qui est lui même basé sur le même JS que vous avez posté, j'ai juste modifié les liens des images des flèches qui sont morts
    sort_table.js
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    /*
    Table sorting script  by Joost de Valk, check it out at http://www.joostdevalk.nl/code/sortable-table/.
    Based on a script from http://www.kryogenix.org/code/browser/sorttable/.
    Distributed under the MIT license: http://www.kryogenix.org/code/browser/licence.html .
     
    Copyright (c) 1997-2007 Stuart Langridge, Joost de Valk.
     
    Version 1.5.7
    */
     
    /* You can change these values */
    //var image_path = "http://upload.wikimedia.org/wikipedia/en/7/73/";
    var image_up = "http://twiki.org/p/pub/TWiki/TWikiDocGraphics/arrowup.gif";
    var image_down = "http://upload.wikimedia.org/wikipedia/en/7/73/Arrow-down.gif";
    var image_none = "http://targethut.s3.amazonaws.com/img/arrow-none.gif";
    var europeandate = true;
    var alternate_row_colors = true;
     
    /* Don't change anything below this unless you know what you're doing */
    addEvent(window, "load", sortables_init);
     
    var SORT_COLUMN_INDEX;
    var thead = false;
     
    function sortables_init() {
        // Find all tables with class sortable and make them sortable
        if (!document.getElementsByTagName) return;
        tbls = document.getElementsByTagName("table");
        for (ti=0;ti<tbls.length;ti++) {
            thisTbl = tbls[ti];
            if (((' '+thisTbl.className+' ').indexOf("sortable") != -1) && (thisTbl.id)) {
                ts_makeSortable(thisTbl);
            }
        }
    }
     
    function ts_makeSortable(t) {
        if (t.rows && t.rows.length > 0) {
            if (t.tHead && t.tHead.rows.length > 0) {
                var firstRow = t.tHead.rows[t.tHead.rows.length-1];
                thead = true;
            } else {
                var firstRow = t.rows[0];
            }
        }
        if (!firstRow) return;
     
        // We have a first row: assume it's the header, and make its contents clickable links
        for (var i=0;i<firstRow.cells.length;i++) {
            var cell = firstRow.cells[i];
            var txt = ts_getInnerText(cell);
            if (cell.className != "unsortable" && cell.className.indexOf("unsortable") == -1) {
                cell.innerHTML = '<a href="#" class="sortheader" onclick="ts_resortTable(this, '+i+');return false;">'+txt+'<span class="sortarrow">&nbsp;&nbsp;<img src="' + image_none + '" alt="&darr;"/></span></a>';
            }
        }
        if (alternate_row_colors) {
            alternate(t);
        }
    }
     
    function ts_getInnerText(el) {
        if (typeof el == "string") return el;
        if (typeof el == "undefined") { return el };
        if (el.innerText) return el.innerText;    //Not needed but it is faster
        var str = "";
     
        var cs = el.childNodes;
        var l = cs.length;
        for (var i = 0; i < l; i++) {
            switch (cs[i].nodeType) {
                case 1: //ELEMENT_NODE
                    str += ts_getInnerText(cs[i]);
                    break;
                case 3:    //TEXT_NODE
                    str += cs[i].nodeValue;
                    break;
            }
        }
        return str;
    }
     
    function ts_resortTable(lnk, clid) {
        var span;
        for (var ci=0;ci<lnk.childNodes.length;ci++) {
            if (lnk.childNodes[ci].tagName && lnk.childNodes[ci].tagName.toLowerCase() == 'span') span = lnk.childNodes[ci];
        }
        var spantext = ts_getInnerText(span);
        var td = lnk.parentNode;
        var column = clid || td.cellIndex;
        var t = getParent(td,'TABLE');
        // Work out a type for the column
        if (t.rows.length <= 1) return;
        var itm = "";
        var i = 0;
        while (itm == "" && i < t.tBodies[0].rows.length) {
            var itm = ts_getInnerText(t.tBodies[0].rows[i].cells[column]);
            itm = trim(itm);
            if (itm.substr(0,4) == "<!--" || itm.length == 0) {
                itm = "";
            }
            i++;
        }
        if (itm == "") return; 
        sortfn = ts_sort_caseinsensitive;
        if (itm.match(/^\d\d[\/\.-][a-zA-z][a-zA-Z][a-zA-Z][\/\.-]\d\d\d\d$/)) sortfn = ts_sort_date;
        if (itm.match(/^\d\d[\/\.-]\d\d[\/\.-]\d\d\d{2}?$/)) sortfn = ts_sort_date;
        if (itm.match(/^-?[�$�ۢ�]\d/)) sortfn = ts_sort_numeric;
        if (itm.match(/^-?(\d+[,\.]?)+(E[-+][\d]+)?%?$/)) sortfn = ts_sort_numeric;
        SORT_COLUMN_INDEX = column;
        var firstRow = new Array();
        var newRows = new Array();
        for (k=0;k<t.tBodies.length;k++) {
            for (i=0;i<t.tBodies[k].rows[0].length;i++) { 
                firstRow[i] = t.tBodies[k].rows[0][i]; 
            }
        }
        for (k=0;k<t.tBodies.length;k++) {
            if (!thead) {
                // Skip the first row
                for (j=1;j<t.tBodies[k].rows.length;j++) { 
                    newRows[j-1] = t.tBodies[k].rows[j];
                }
            } else {
                // Do NOT skip the first row
                for (j=0;j<t.tBodies[k].rows.length;j++) { 
                    newRows[j] = t.tBodies[k].rows[j];
                }
            }
        }
        newRows.sort(sortfn);
        if (span.getAttribute("sortdir") == 'down') {
                ARROW = '&nbsp;&nbsp;<img src="'+ image_down + '" alt="&darr;"/>';
                newRows.reverse();
                span.setAttribute('sortdir','up');
        } else {
                ARROW = '&nbsp;&nbsp;<img src="'+ image_up + '" alt="&uarr;"/>';
                span.setAttribute('sortdir','down');
        } 
        // We appendChild rows that already exist to the tbody, so it moves them rather than creating new ones
        // don't do sortbottom rows
        for (i=0; i<newRows.length; i++) { 
            if (!newRows[i].className || (newRows[i].className && (newRows[i].className.indexOf('sortbottom') == -1))) {
                t.tBodies[0].appendChild(newRows[i]);
            }
        }
        // do sortbottom rows only
        for (i=0; i<newRows.length; i++) {
            if (newRows[i].className && (newRows[i].className.indexOf('sortbottom') != -1)) 
                t.tBodies[0].appendChild(newRows[i]);
        }
        // Delete any other arrows there may be showing
        var allspans = document.getElementsByTagName("span");
        for (var ci=0;ci<allspans.length;ci++) {
            if (allspans[ci].className == 'sortarrow') {
                if (getParent(allspans[ci],"table") == getParent(lnk,"table")) { // in the same table as us?
                    allspans[ci].innerHTML = '&nbsp;&nbsp;<img src="'+ image_none + '" alt="&darr;"/>';
                }
            }
        }        
        span.innerHTML = ARROW;
        alternate(t);
    }
     
    function getParent(el, pTagName) {
        if (el == null) {
            return null;
        } else if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase()) {
            return el;
        } else {
            return getParent(el.parentNode, pTagName);
        }
    }
     
    function sort_date(date) {    
        // y2k notes: two digit years less than 50 are treated as 20XX, greater than 50 are treated as 19XX
        dt = "00000000";
        if (date.length == 11) {
            mtstr = date.substr(3,3);
            mtstr = mtstr.toLowerCase();
            switch(mtstr) {
                case "jan": var mt = "01"; break;
                case "feb": var mt = "02"; break;
                case "mar": var mt = "03"; break;
                case "apr": var mt = "04"; break;
                case "may": var mt = "05"; break;
                case "jun": var mt = "06"; break;
                case "jul": var mt = "07"; break;
                case "aug": var mt = "08"; break;
                case "sep": var mt = "09"; break;
                case "oct": var mt = "10"; break;
                case "nov": var mt = "11"; break;
                case "dec": var mt = "12"; break;
                // default: var mt = "00";
            }
            dt = date.substr(7,4)+mt+date.substr(0,2);
            return dt;
        } else if (date.length == 10) {
            if (europeandate == false) {
                dt = date.substr(6,4)+date.substr(0,2)+date.substr(3,2);
                return dt;
            } else {
                dt = date.substr(6,4)+date.substr(3,2)+date.substr(0,2);
                return dt;
            }
        } else if (date.length == 8) {
            yr = date.substr(6,2);
            if (parseInt(yr) < 50) { 
                yr = '20'+yr; 
            } else { 
                yr = '19'+yr; 
            }
            if (europeandate == true) {
                dt = yr+date.substr(3,2)+date.substr(0,2);
                return dt;
            } else {
                dt = yr+date.substr(0,2)+date.substr(3,2);
                return dt;
            }
        }
        return dt;
    }
     
    function ts_sort_date(a,b) {
        dt1 = sort_date(ts_getInnerText(a.cells[SORT_COLUMN_INDEX]));
        dt2 = sort_date(ts_getInnerText(b.cells[SORT_COLUMN_INDEX]));
     
        if (dt1==dt2) {
            return 0;
        }
        if (dt1<dt2) { 
            return -1;
        }
        return 1;
    }
    function ts_sort_numeric(a,b) {
        var aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]);
        aa = clean_num(aa);
        var bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]);
        bb = clean_num(bb);
        return compare_numeric(aa,bb);
    }
    function compare_numeric(a,b) {
        var a = parseFloat(a);
        a = (isNaN(a) ? 0 : a);
        var b = parseFloat(b);
        b = (isNaN(b) ? 0 : b);
        return a - b;
    }
    function ts_sort_caseinsensitive(a,b) {
        aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]).toLowerCase();
        bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]).toLowerCase();
        if (aa==bb) {
            return 0;
        }
        if (aa<bb) {
            return -1;
        }
        return 1;
    }
    function ts_sort_default(a,b) {
        aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]);
        bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]);
        if (aa==bb) {
            return 0;
        }
        if (aa<bb) {
            return -1;
        }
        return 1;
    }
    function addEvent(elm, evType, fn, useCapture)
    // addEvent and removeEvent
    // cross-browser event handling for IE5+,    NS6 and Mozilla
    // By Scott Andrew
    {
        if (elm.addEventListener){
            elm.addEventListener(evType, fn, useCapture);
            return true;
        } else if (elm.attachEvent){
            var r = elm.attachEvent("on"+evType, fn);
            return r;
        } else {
            alert("Handler could not be removed");
        }
    }
    function clean_num(str) {
        str = str.replace(new RegExp(/[^-?0-9.]/g),"");
        return str;
    }
    function trim(s) {
        return s.replace(/^\s+|\s+$/g, "");
    }
    function alternate(table) {
        // Take object table and get all it's tbodies.
        var tableBodies = table.getElementsByTagName("tbody");
        // Loop through these tbodies
        for (var i = 0; i < tableBodies.length; i++) {
            // Take the tbody, and get all it's rows
            var tableRows = tableBodies[i].getElementsByTagName("tr");
            // Loop through these rows
            // Start at 1 because we want to leave the heading row untouched
            for (var j = 0; j < tableRows.length; j++) {
                // Check if j is even, and apply classes for both possible results
                if ( (j % 2) == 0  ) {
                    if ( !(tableRows[j].className.indexOf('odd') == -1) ) {
                        tableRows[j].className = tableRows[j].className.replace('odd', 'even');
                    } else {
                        if ( tableRows[j].className.indexOf('even') == -1 ) {
                            tableRows[j].className += " even";
                        }
                    }
                } else {
                    if ( !(tableRows[j].className.indexOf('even') == -1) ) {
                        tableRows[j].className = tableRows[j].className.replace('even', 'odd');
                    } else {
                        if ( tableRows[j].className.indexOf('odd') == -1 ) {
                            tableRows[j].className += " odd";
                        }
                    }
                } 
            }
        }
    }
    et le HTA à tester :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    <html>
    <head>
    <link rel='stylesheet' id='yoast-theme-css'  href='http://cdn.yoast.com//wp-content/themes/yoast-theme/style.php?lastmod=1385414581' type='text/css' media='all' />
    <style type="text/css">
    .odd {
    background-color: #ddd;
    }
    .even {
    background-color: #fff;
    }
    </style>
    <script type="text/javascript" src="sort_table.js"></script>
    </head>
    <table class="sortable" id="anyid" cellpadding="0" cellspacing="0">
    <tr>
    <th>Numbers</th>
    <th>Alphabet</th>
    <th class="startsort">Dates</th>
    <th>Currency</th>
    <th class="unsortable">Unsortable</th>
    </tr>
    <tr>
    <td>1</td>
    <td>Z</td>
    <td>02-02-2004</td>
    <td>&euro;5.00</td>
    <td>This</td>
    </tr>
    <tr>
    <td>2</td>
    <td>y</td>
    <td>13-apr-2005</td>
    <td></td>
    <td>Row</td>
    </tr>
    <tr>
    <td>3</td>
    <td>X</td>
    <td>17.aug.2006</td>
    <td>&euro;6.50</td>
    <td>Is</td>
    </tr>
    <tr>
    <td>4</td>
    <td>w</td>
    <td>01.Jan.2005</td>
    <td>&euro;4.20</td>
    <td>Unsortable</td>
    </tr>
    <tr>
    <td>5</td>
    <td>V</td>
    <td>05/12/2006</td>
    <td>&euro;7.15</td>
    <td>See?</td>
    </tr>
    <tr class="sortbottom">
    <td>15</td>
    <td></td>
    <td></td>
    <td>&euro;29.55</td>
    <td></td>
    </tr>
    </table><hr>
    <table class = 'sortable' id="sortabletable"><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th><th class="unsortable">Unsortable</th><tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td></tr><tr><td>11</td><td>12</td><td>13</td><td>14</td><td>15</td><td>20</td></tr><tr class="sortbottom"><td>Hackoo</td><td>Crackoo</td><td>vous</td><td>salut</td><td>Monsieur</td><td>snorky94</td></tr></table>
    <body>
    <hr><span id = "oDivDisplayArea">By Javascript</span></br><hr>
    <script language="VBScript">
    Sub window_Onload()
    	Dim StrHTML
    	StrHTML = "<table class = 'sortable' id='sortabletable'><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th><th class='unsortable'>Unsortable</th><tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td></tr><tr><td>11</td><td>12</td><td>13</td><td>14</td><td>15</td><td>20</td></tr><tr class='sortbottom'><td>Hackoo</td><td>Crackoo</td><td>vous</td><td>salut</td><td>Monsieur</td><td>snorky94</td></tr></table>"
    	StrHTML = StrHTML & "<hr> Generated by the Vbscript<hr>"
    	VBS_DisplayArea.innerHTML = StrHTML
    End sub
    </script>
    <br><span id = "VBS_DisplayArea"></span>
    </body>
    </html>

  5. #5
    Membre habitué
    Homme Profil pro
    Ingénieur systèmes et réseaux
    Inscrit en
    Juillet 2012
    Messages
    284
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur systèmes et réseaux
    Secteur : Finance

    Informations forums :
    Inscription : Juillet 2012
    Messages : 284
    Points : 132
    Points
    132
    Par défaut
    Merci au grand monsieur hackoofr qui est toujours la quand il y a un pb

    Alors j'ai fait plusieurs tests.

    Dans la procédure Onload ca s'affiche sans problème, je peux trier mes colonnes c'est top

    Cependant, dès que je le met dans une autre procédure View_Scopes(), mon tableau s'affiche correctement, mais le tableau ne peux pas etre trié

    Une idée ???

    Merci encore pour ton aide précieuse

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
     
    <html>
     
    <head>
     
    <script type="text/javascript" src="sort_table.js"></script>
     
    </head>
    <script language="VBScript">
     
    Sub window_Onload()
    	Dim StrHTML
    	StrHTML = "<table class = 'sortable' id='sortabletable'><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th><th class='unsortable'>Unsortable</th><tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td></tr><tr><td>11</td><td>12</td><td>13</td><td>14</td><td>15</td><td>20</td></tr><tr class='sortbottom'><td>Hackoo</td><td>Crackoo</td><td>vous</td><td>salut</td><td>Monsieur</td><td>snorky94</td></tr></table>"
    	VBS_DisplayArea1.innerHTML = StrHTML
    End sub
     
    Sub View_Scopes()
    	Dim StrHTML
    	StrHTML = "<table class = 'sortable' id='sortabletable'><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th><th class='unsortable'>Unsortable</th><tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td></tr><tr><td>11</td><td>12</td><td>13</td><td>14</td><td>15</td><td>20</td></tr><tr class='sortbottom'><td>Hackoo</td><td>Crackoo</td><td>vous</td><td>salut</td><td>Monsieur</td><td>snorky94</td></tr></table>"
    	VBS_DisplayArea2.InnerHtml = StrHTML
    End Sub
     
    </script>
     
     
    </head>
     
    <body>
     
    <p>
    <input type="submit" Value="View Scopes" onClick="View_Scopes();" class="button">
    </p>
     
    <p>
    <span id = "VBS_DisplayArea1"></span>
    </p>
     
    <p>
    <span id = "VBS_DisplayArea2"></span>
    </p>
     
    </body>
    </html>

  6. #6
    Expert éminent sénior
    Avatar de ProgElecT
    Homme Profil pro
    Retraité
    Inscrit en
    Décembre 2004
    Messages
    6 107
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 68
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Retraité
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Décembre 2004
    Messages : 6 107
    Points : 16 633
    Points
    16 633
    Par défaut
    Salut
    Pas sûr mais il me semble que ligne 30 le onClick =
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <input type="submit" Value="View Scopes" onClick="View_Scopes" class="button">

  7. #7
    Expert éminent
    Avatar de hackoofr
    Homme Profil pro
    Enseignant
    Inscrit en
    Juin 2009
    Messages
    3 840
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Juin 2009
    Messages : 3 840
    Points : 9 225
    Points
    9 225
    Par défaut

    A tester et si par hasard ce code marche n'oubliez pas mes +1
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    <html>
    <head>
    <script type="text/javascript" src="sort_table.js"></script>
    <script language="VBScript">
     Sub window_Onload()
    	Dim StrHTML
    	Call View_Scopes()
    	StrHTML = "<table class = 'sortable' id='sortabletable'><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th><th class='unsortable'>Unsortable</th><tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td></tr><tr><td>11</td><td>12</td><td>13</td><td>14</td><td>15</td><td>20</td></tr><tr class='sortbottom'><td>Hackoo</td><td>Crackoo</td><td>vous</td><td>salue</td><td>Monsieur</td><td>snorky94</td></tr></table>"
    	VBS_DisplayArea1.innerHTML = StrHTML
    	MonBouton.Value = "View Scopes"
    	VBS_DisplayArea2.style.visibility="hidden"
    End sub
     
    Sub View_Scopes()
    	Dim StrHTML
    	StrHTML = "<table class = 'sortable' id='sortabletable'><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th><th class='unsortable'>Unsortable</th><tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td></tr><tr><td>11</td><td>12</td><td>13</td><td>14</td><td>15</td><td>20</td></tr><tr class='sortbottom'><td>Hackoo</td><td>Crackoo</td><td>vous</td><td>salue</td><td>Monsieur</td><td>snorky94</td></tr></table>"
    	VBS_DisplayArea2.InnerHtml = StrHTML
    End Sub
     
    Sub ToggleButton()
    	If VBS_DisplayArea2.style.visibility="hidden" Then
    		VBS_DisplayArea2.style.visibility="visible"
    		MonBouton.Value = "Hide Scopes"
    	Else
    		VBS_DisplayArea2.style.visibility="hidden"
    		MonBouton.Value = "View Scopes"
    	End If
    End Sub
    </script>
    </head>
    <body>
     <p>
    <input type="button" Id="MonBouton" onClick="ToggleButton()">
    </p>
     <p>
    <span id = "VBS_DisplayArea1"></span>
    </p>
     <p>
    <span id = "VBS_DisplayArea2"></span>
    </p>
     
    </body>
    </html>

  8. #8
    Membre habitué
    Homme Profil pro
    Ingénieur systèmes et réseaux
    Inscrit en
    Juillet 2012
    Messages
    284
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur systèmes et réseaux
    Secteur : Finance

    Informations forums :
    Inscription : Juillet 2012
    Messages : 284
    Points : 132
    Points
    132
    Par défaut
    Je n'arrive pas à l'intégrer dans mon code, trop compliqué

    Est ce que je peux t'envoyer mon code en MP ou par mail ?

    Bien sur que tu auras des +1 apres.

    Tu me sauves la vie la

    Merci.

  9. #9
    Expert éminent
    Avatar de hackoofr
    Homme Profil pro
    Enseignant
    Inscrit en
    Juin 2009
    Messages
    3 840
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Juin 2009
    Messages : 3 840
    Points : 9 225
    Points
    9 225
    Par défaut

    Voila avec le code de sort-table.js intégré dans le HTA directement
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    <html>
    <head>
    <script type="text/javascript">
    /*
    Table sorting script  by Joost de Valk, check it out at http://www.joostdevalk.nl/code/sortable-table/.
    Based on a script from http://www.kryogenix.org/code/browser/sorttable/.
    Distributed under the MIT license: http://www.kryogenix.org/code/browser/licence.html .
     
    Copyright (c) 1997-2007 Stuart Langridge, Joost de Valk.
     
    Version 1.5.7
    */
     
    /* You can change these values */
    //var image_path = "http://upload.wikimedia.org/wikipedia/en/7/73/";
    var image_up = "http://twiki.org/p/pub/TWiki/TWikiDocGraphics/arrowup.gif";
    var image_down = "http://upload.wikimedia.org/wikipedia/en/7/73/Arrow-down.gif";
    var image_none = "http://targethut.s3.amazonaws.com/img/arrow-none.gif";
    var europeandate = true;
    var alternate_row_colors = true;
     
    /* Don't change anything below this unless you know what you're doing */
    addEvent(window, "load", sortables_init);
     
    var SORT_COLUMN_INDEX;
    var thead = false;
     
    function sortables_init() {
        // Find all tables with class sortable and make them sortable
        if (!document.getElementsByTagName) return;
        tbls = document.getElementsByTagName("table");
        for (ti=0;ti<tbls.length;ti++) {
            thisTbl = tbls[ti];
            if (((' '+thisTbl.className+' ').indexOf("sortable") != -1) && (thisTbl.id)) {
                ts_makeSortable(thisTbl);
            }
        }
    }
     
    function ts_makeSortable(t) {
        if (t.rows && t.rows.length > 0) {
            if (t.tHead && t.tHead.rows.length > 0) {
                var firstRow = t.tHead.rows[t.tHead.rows.length-1];
                thead = true;
            } else {
                var firstRow = t.rows[0];
            }
        }
        if (!firstRow) return;
     
        // We have a first row: assume it's the header, and make its contents clickable links
        for (var i=0;i<firstRow.cells.length;i++) {
            var cell = firstRow.cells[i];
            var txt = ts_getInnerText(cell);
            if (cell.className != "unsortable" && cell.className.indexOf("unsortable") == -1) {
                cell.innerHTML = '<a href="#" class="sortheader" onclick="ts_resortTable(this, '+i+');return false;">'+txt+'<span class="sortarrow">&nbsp;&nbsp;<img src="' + image_none + '" alt="&darr;"/></span></a>';
            }
        }
        if (alternate_row_colors) {
            alternate(t);
        }
    }
     
    function ts_getInnerText(el) {
        if (typeof el == "string") return el;
        if (typeof el == "undefined") { return el };
        if (el.innerText) return el.innerText;    //Not needed but it is faster
        var str = "";
     
        var cs = el.childNodes;
        var l = cs.length;
        for (var i = 0; i < l; i++) {
            switch (cs[i].nodeType) {
                case 1: //ELEMENT_NODE
                    str += ts_getInnerText(cs[i]);
                    break;
                case 3:    //TEXT_NODE
                    str += cs[i].nodeValue;
                    break;
            }
        }
        return str;
    }
     
    function ts_resortTable(lnk, clid) {
        var span;
        for (var ci=0;ci<lnk.childNodes.length;ci++) {
            if (lnk.childNodes[ci].tagName && lnk.childNodes[ci].tagName.toLowerCase() == 'span') span = lnk.childNodes[ci];
        }
        var spantext = ts_getInnerText(span);
        var td = lnk.parentNode;
        var column = clid || td.cellIndex;
        var t = getParent(td,'TABLE');
        // Work out a type for the column
        if (t.rows.length <= 1) return;
        var itm = "";
        var i = 0;
        while (itm == "" && i < t.tBodies[0].rows.length) {
            var itm = ts_getInnerText(t.tBodies[0].rows[i].cells[column]);
            itm = trim(itm);
            if (itm.substr(0,4) == "<!--" || itm.length == 0) {
                itm = "";
            }
            i++;
        }
        if (itm == "") return; 
        sortfn = ts_sort_caseinsensitive;
        if (itm.match(/^\d\d[\/\.-][a-zA-z][a-zA-Z][a-zA-Z][\/\.-]\d\d\d\d$/)) sortfn = ts_sort_date;
        if (itm.match(/^\d\d[\/\.-]\d\d[\/\.-]\d\d\d{2}?$/)) sortfn = ts_sort_date;
        if (itm.match(/^-?[�$�ۢ�]\d/)) sortfn = ts_sort_numeric;
        if (itm.match(/^-?(\d+[,\.]?)+(E[-+][\d]+)?%?$/)) sortfn = ts_sort_numeric;
        SORT_COLUMN_INDEX = column;
        var firstRow = new Array();
        var newRows = new Array();
        for (k=0;k<t.tBodies.length;k++) {
            for (i=0;i<t.tBodies[k].rows[0].length;i++) { 
                firstRow[i] = t.tBodies[k].rows[0][i]; 
            }
        }
        for (k=0;k<t.tBodies.length;k++) {
            if (!thead) {
                // Skip the first row
                for (j=1;j<t.tBodies[k].rows.length;j++) { 
                    newRows[j-1] = t.tBodies[k].rows[j];
                }
            } else {
                // Do NOT skip the first row
                for (j=0;j<t.tBodies[k].rows.length;j++) { 
                    newRows[j] = t.tBodies[k].rows[j];
                }
            }
        }
        newRows.sort(sortfn);
        if (span.getAttribute("sortdir") == 'down') {
                ARROW = '&nbsp;&nbsp;<img src="'+ image_down + '" alt="&darr;"/>';
                newRows.reverse();
                span.setAttribute('sortdir','up');
        } else {
                ARROW = '&nbsp;&nbsp;<img src="'+ image_up + '" alt="&uarr;"/>';
                span.setAttribute('sortdir','down');
        } 
        // We appendChild rows that already exist to the tbody, so it moves them rather than creating new ones
        // don't do sortbottom rows
        for (i=0; i<newRows.length; i++) { 
            if (!newRows[i].className || (newRows[i].className && (newRows[i].className.indexOf('sortbottom') == -1))) {
                t.tBodies[0].appendChild(newRows[i]);
            }
        }
        // do sortbottom rows only
        for (i=0; i<newRows.length; i++) {
            if (newRows[i].className && (newRows[i].className.indexOf('sortbottom') != -1)) 
                t.tBodies[0].appendChild(newRows[i]);
        }
        // Delete any other arrows there may be showing
        var allspans = document.getElementsByTagName("span");
        for (var ci=0;ci<allspans.length;ci++) {
            if (allspans[ci].className == 'sortarrow') {
                if (getParent(allspans[ci],"table") == getParent(lnk,"table")) { // in the same table as us?
                    allspans[ci].innerHTML = '&nbsp;&nbsp;<img src="'+ image_none + '" alt="&darr;"/>';
                }
            }
        }        
        span.innerHTML = ARROW;
        alternate(t);
    }
     
    function getParent(el, pTagName) {
        if (el == null) {
            return null;
        } else if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase()) {
            return el;
        } else {
            return getParent(el.parentNode, pTagName);
        }
    }
     
    function sort_date(date) {    
        // y2k notes: two digit years less than 50 are treated as 20XX, greater than 50 are treated as 19XX
        dt = "00000000";
        if (date.length == 11) {
            mtstr = date.substr(3,3);
            mtstr = mtstr.toLowerCase();
            switch(mtstr) {
                case "jan": var mt = "01"; break;
                case "feb": var mt = "02"; break;
                case "mar": var mt = "03"; break;
                case "apr": var mt = "04"; break;
                case "may": var mt = "05"; break;
                case "jun": var mt = "06"; break;
                case "jul": var mt = "07"; break;
                case "aug": var mt = "08"; break;
                case "sep": var mt = "09"; break;
                case "oct": var mt = "10"; break;
                case "nov": var mt = "11"; break;
                case "dec": var mt = "12"; break;
                // default: var mt = "00";
            }
            dt = date.substr(7,4)+mt+date.substr(0,2);
            return dt;
        } else if (date.length == 10) {
            if (europeandate == false) {
                dt = date.substr(6,4)+date.substr(0,2)+date.substr(3,2);
                return dt;
            } else {
                dt = date.substr(6,4)+date.substr(3,2)+date.substr(0,2);
                return dt;
            }
        } else if (date.length == 8) {
            yr = date.substr(6,2);
            if (parseInt(yr) < 50) { 
                yr = '20'+yr; 
            } else { 
                yr = '19'+yr; 
            }
            if (europeandate == true) {
                dt = yr+date.substr(3,2)+date.substr(0,2);
                return dt;
            } else {
                dt = yr+date.substr(0,2)+date.substr(3,2);
                return dt;
            }
        }
        return dt;
    }
     
    function ts_sort_date(a,b) {
        dt1 = sort_date(ts_getInnerText(a.cells[SORT_COLUMN_INDEX]));
        dt2 = sort_date(ts_getInnerText(b.cells[SORT_COLUMN_INDEX]));
     
        if (dt1==dt2) {
            return 0;
        }
        if (dt1<dt2) { 
            return -1;
        }
        return 1;
    }
    function ts_sort_numeric(a,b) {
        var aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]);
        aa = clean_num(aa);
        var bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]);
        bb = clean_num(bb);
        return compare_numeric(aa,bb);
    }
    function compare_numeric(a,b) {
        var a = parseFloat(a);
        a = (isNaN(a) ? 0 : a);
        var b = parseFloat(b);
        b = (isNaN(b) ? 0 : b);
        return a - b;
    }
    function ts_sort_caseinsensitive(a,b) {
        aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]).toLowerCase();
        bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]).toLowerCase();
        if (aa==bb) {
            return 0;
        }
        if (aa<bb) {
            return -1;
        }
        return 1;
    }
    function ts_sort_default(a,b) {
        aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]);
        bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]);
        if (aa==bb) {
            return 0;
        }
        if (aa<bb) {
            return -1;
        }
        return 1;
    }
    function addEvent(elm, evType, fn, useCapture)
    // addEvent and removeEvent
    // cross-browser event handling for IE5+,    NS6 and Mozilla
    // By Scott Andrew
    {
        if (elm.addEventListener){
            elm.addEventListener(evType, fn, useCapture);
            return true;
        } else if (elm.attachEvent){
            var r = elm.attachEvent("on"+evType, fn);
            return r;
        } else {
            alert("Handler could not be removed");
        }
    }
    function clean_num(str) {
        str = str.replace(new RegExp(/[^-?0-9.]/g),"");
        return str;
    }
    function trim(s) {
        return s.replace(/^\s+|\s+$/g, "");
    }
    function alternate(table) {
        // Take object table and get all it's tbodies.
        var tableBodies = table.getElementsByTagName("tbody");
        // Loop through these tbodies
        for (var i = 0; i < tableBodies.length; i++) {
            // Take the tbody, and get all it's rows
            var tableRows = tableBodies[i].getElementsByTagName("tr");
            // Loop through these rows
            // Start at 1 because we want to leave the heading row untouched
            for (var j = 0; j < tableRows.length; j++) {
                // Check if j is even, and apply classes for both possible results
                if ( (j % 2) == 0  ) {
                    if ( !(tableRows[j].className.indexOf('odd') == -1) ) {
                        tableRows[j].className = tableRows[j].className.replace('odd', 'even');
                    } else {
                        if ( tableRows[j].className.indexOf('even') == -1 ) {
                            tableRows[j].className += " even";
                        }
                    }
                } else {
                    if ( !(tableRows[j].className.indexOf('even') == -1) ) {
                        tableRows[j].className = tableRows[j].className.replace('even', 'odd');
                    } else {
                        if ( tableRows[j].className.indexOf('odd') == -1 ) {
                            tableRows[j].className += " odd";
                        }
                    }
                } 
            }
        }
    }
    </script>
    <script language="VBScript">
     Sub window_Onload()
    	Dim StrHTML
    	Call View_Scopes()
    	StrHTML = "<table class = 'sortable' id='sortabletable'><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th><th class='unsortable'>Unsortable</th><tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td></tr><tr><td>11</td><td>12</td><td>13</td><td>14</td><td>15</td><td>20</td></tr><tr class='sortbottom'><td>Hackoo</td><td>Crackoo</td><td>vous</td><td>salue</td><td>Monsieur</td><td>snorky94</td></tr></table>"
    	VBS_DisplayArea1.innerHTML = StrHTML
    	MonBouton.Value = "View Scopes"
    	VBS_DisplayArea2.style.visibility="hidden"
    End sub
     
    Sub View_Scopes()
    	Dim StrHTML
    	StrHTML = "<table class = 'sortable' id='sortabletable'><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th><th class='unsortable'>Unsortable</th><tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td></tr><tr><td>11</td><td>12</td><td>13</td><td>14</td><td>15</td><td>20</td></tr><tr class='sortbottom'><td>Hackoo</td><td>Crackoo</td><td>vous</td><td>salue</td><td>Monsieur</td><td>snorky94</td></tr></table>"
    	VBS_DisplayArea2.InnerHtml = StrHTML
    End Sub
     
    Sub ToggleButton()
    	If VBS_DisplayArea2.style.visibility="hidden" Then
    		VBS_DisplayArea2.style.visibility="visible"
    		MonBouton.Value = "Hide Scopes"
    	Else
    		VBS_DisplayArea2.style.visibility="hidden"
    		MonBouton.Value = "View Scopes"
    	End If
    End Sub
    </script>
    </head>
    <body>
     <p>
    <input type="button" Id="MonBouton" onClick="ToggleButton()">
    </p>
     <p>
    <span id = "VBS_DisplayArea1"></span>
    </p>
     <p>
    <span id = "VBS_DisplayArea2"></span>
    </p>
    </body>
    </html>

  10. #10
    Membre habitué
    Homme Profil pro
    Ingénieur systèmes et réseaux
    Inscrit en
    Juillet 2012
    Messages
    284
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur systèmes et réseaux
    Secteur : Finance

    Informations forums :
    Inscription : Juillet 2012
    Messages : 284
    Points : 132
    Points
    132
    Par défaut
    merci

    Ce n'est pas l'intégration du js dans le hta qui pose pb, mais l'adaptation de mon code

  11. #11
    Expert éminent
    Avatar de hackoofr
    Homme Profil pro
    Enseignant
    Inscrit en
    Juin 2009
    Messages
    3 840
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Juin 2009
    Messages : 3 840
    Points : 9 225
    Points
    9 225
    Par défaut

    et ceci avec un peu de CSS
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    <html>
    <head>
    <link rel='stylesheet' id='yoast-theme-css'  href='http://cdn.yoast.com//wp-content/themes/yoast-theme/style.php?lastmod=1385414581' type='text/css' media='all' />
    <style type="text/css">
    .odd {
    background-color: #ddd;
    }
    .even {
    background-color: #fff;
    }
    </style>
    <script type="text/javascript">
    /*
    Table sorting script  by Joost de Valk, check it out at http://www.joostdevalk.nl/code/sortable-table/.
    Based on a script from http://www.kryogenix.org/code/browser/sorttable/.
    Distributed under the MIT license: http://www.kryogenix.org/code/browser/licence.html .
     
    Copyright (c) 1997-2007 Stuart Langridge, Joost de Valk.
     
    Version 1.5.7
    */
     
    /* You can change these values */
    //var image_path = "http://upload.wikimedia.org/wikipedia/en/7/73/";
    var image_up = "http://twiki.org/p/pub/TWiki/TWikiDocGraphics/arrowup.gif";
    var image_down = "http://upload.wikimedia.org/wikipedia/en/7/73/Arrow-down.gif";
    var image_none = "http://targethut.s3.amazonaws.com/img/arrow-none.gif";
    var europeandate = true;
    var alternate_row_colors = true;
     
    /* Don't change anything below this unless you know what you're doing */
    addEvent(window, "load", sortables_init);
     
    var SORT_COLUMN_INDEX;
    var thead = false;
     
    function sortables_init() {
        // Find all tables with class sortable and make them sortable
        if (!document.getElementsByTagName) return;
        tbls = document.getElementsByTagName("table");
        for (ti=0;ti<tbls.length;ti++) {
            thisTbl = tbls[ti];
            if (((' '+thisTbl.className+' ').indexOf("sortable") != -1) && (thisTbl.id)) {
                ts_makeSortable(thisTbl);
            }
        }
    }
     
    function ts_makeSortable(t) {
        if (t.rows && t.rows.length > 0) {
            if (t.tHead && t.tHead.rows.length > 0) {
                var firstRow = t.tHead.rows[t.tHead.rows.length-1];
                thead = true;
            } else {
                var firstRow = t.rows[0];
            }
        }
        if (!firstRow) return;
     
        // We have a first row: assume it's the header, and make its contents clickable links
        for (var i=0;i<firstRow.cells.length;i++) {
            var cell = firstRow.cells[i];
            var txt = ts_getInnerText(cell);
            if (cell.className != "unsortable" && cell.className.indexOf("unsortable") == -1) {
                cell.innerHTML = '<a href="#" class="sortheader" onclick="ts_resortTable(this, '+i+');return false;">'+txt+'<span class="sortarrow">&nbsp;&nbsp;<img src="' + image_none + '" alt="&darr;"/></span></a>';
            }
        }
        if (alternate_row_colors) {
            alternate(t);
        }
    }
     
    function ts_getInnerText(el) {
        if (typeof el == "string") return el;
        if (typeof el == "undefined") { return el };
        if (el.innerText) return el.innerText;    //Not needed but it is faster
        var str = "";
     
        var cs = el.childNodes;
        var l = cs.length;
        for (var i = 0; i < l; i++) {
            switch (cs[i].nodeType) {
                case 1: //ELEMENT_NODE
                    str += ts_getInnerText(cs[i]);
                    break;
                case 3:    //TEXT_NODE
                    str += cs[i].nodeValue;
                    break;
            }
        }
        return str;
    }
     
    function ts_resortTable(lnk, clid) {
        var span;
        for (var ci=0;ci<lnk.childNodes.length;ci++) {
            if (lnk.childNodes[ci].tagName && lnk.childNodes[ci].tagName.toLowerCase() == 'span') span = lnk.childNodes[ci];
        }
        var spantext = ts_getInnerText(span);
        var td = lnk.parentNode;
        var column = clid || td.cellIndex;
        var t = getParent(td,'TABLE');
        // Work out a type for the column
        if (t.rows.length <= 1) return;
        var itm = "";
        var i = 0;
        while (itm == "" && i < t.tBodies[0].rows.length) {
            var itm = ts_getInnerText(t.tBodies[0].rows[i].cells[column]);
            itm = trim(itm);
            if (itm.substr(0,4) == "<!--" || itm.length == 0) {
                itm = "";
            }
            i++;
        }
        if (itm == "") return; 
        sortfn = ts_sort_caseinsensitive;
        if (itm.match(/^\d\d[\/\.-][a-zA-z][a-zA-Z][a-zA-Z][\/\.-]\d\d\d\d$/)) sortfn = ts_sort_date;
        if (itm.match(/^\d\d[\/\.-]\d\d[\/\.-]\d\d\d{2}?$/)) sortfn = ts_sort_date;
        if (itm.match(/^-?[�$�ۢ�]\d/)) sortfn = ts_sort_numeric;
        if (itm.match(/^-?(\d+[,\.]?)+(E[-+][\d]+)?%?$/)) sortfn = ts_sort_numeric;
        SORT_COLUMN_INDEX = column;
        var firstRow = new Array();
        var newRows = new Array();
        for (k=0;k<t.tBodies.length;k++) {
            for (i=0;i<t.tBodies[k].rows[0].length;i++) { 
                firstRow[i] = t.tBodies[k].rows[0][i]; 
            }
        }
        for (k=0;k<t.tBodies.length;k++) {
            if (!thead) {
                // Skip the first row
                for (j=1;j<t.tBodies[k].rows.length;j++) { 
                    newRows[j-1] = t.tBodies[k].rows[j];
                }
            } else {
                // Do NOT skip the first row
                for (j=0;j<t.tBodies[k].rows.length;j++) { 
                    newRows[j] = t.tBodies[k].rows[j];
                }
            }
        }
        newRows.sort(sortfn);
        if (span.getAttribute("sortdir") == 'down') {
                ARROW = '&nbsp;&nbsp;<img src="'+ image_down + '" alt="&darr;"/>';
                newRows.reverse();
                span.setAttribute('sortdir','up');
        } else {
                ARROW = '&nbsp;&nbsp;<img src="'+ image_up + '" alt="&uarr;"/>';
                span.setAttribute('sortdir','down');
        } 
        // We appendChild rows that already exist to the tbody, so it moves them rather than creating new ones
        // don't do sortbottom rows
        for (i=0; i<newRows.length; i++) { 
            if (!newRows[i].className || (newRows[i].className && (newRows[i].className.indexOf('sortbottom') == -1))) {
                t.tBodies[0].appendChild(newRows[i]);
            }
        }
        // do sortbottom rows only
        for (i=0; i<newRows.length; i++) {
            if (newRows[i].className && (newRows[i].className.indexOf('sortbottom') != -1)) 
                t.tBodies[0].appendChild(newRows[i]);
        }
        // Delete any other arrows there may be showing
        var allspans = document.getElementsByTagName("span");
        for (var ci=0;ci<allspans.length;ci++) {
            if (allspans[ci].className == 'sortarrow') {
                if (getParent(allspans[ci],"table") == getParent(lnk,"table")) { // in the same table as us?
                    allspans[ci].innerHTML = '&nbsp;&nbsp;<img src="'+ image_none + '" alt="&darr;"/>';
                }
            }
        }        
        span.innerHTML = ARROW;
        alternate(t);
    }
     
    function getParent(el, pTagName) {
        if (el == null) {
            return null;
        } else if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase()) {
            return el;
        } else {
            return getParent(el.parentNode, pTagName);
        }
    }
     
    function sort_date(date) {    
        // y2k notes: two digit years less than 50 are treated as 20XX, greater than 50 are treated as 19XX
        dt = "00000000";
        if (date.length == 11) {
            mtstr = date.substr(3,3);
            mtstr = mtstr.toLowerCase();
            switch(mtstr) {
                case "jan": var mt = "01"; break;
                case "feb": var mt = "02"; break;
                case "mar": var mt = "03"; break;
                case "apr": var mt = "04"; break;
                case "may": var mt = "05"; break;
                case "jun": var mt = "06"; break;
                case "jul": var mt = "07"; break;
                case "aug": var mt = "08"; break;
                case "sep": var mt = "09"; break;
                case "oct": var mt = "10"; break;
                case "nov": var mt = "11"; break;
                case "dec": var mt = "12"; break;
                // default: var mt = "00";
            }
            dt = date.substr(7,4)+mt+date.substr(0,2);
            return dt;
        } else if (date.length == 10) {
            if (europeandate == false) {
                dt = date.substr(6,4)+date.substr(0,2)+date.substr(3,2);
                return dt;
            } else {
                dt = date.substr(6,4)+date.substr(3,2)+date.substr(0,2);
                return dt;
            }
        } else if (date.length == 8) {
            yr = date.substr(6,2);
            if (parseInt(yr) < 50) { 
                yr = '20'+yr; 
            } else { 
                yr = '19'+yr; 
            }
            if (europeandate == true) {
                dt = yr+date.substr(3,2)+date.substr(0,2);
                return dt;
            } else {
                dt = yr+date.substr(0,2)+date.substr(3,2);
                return dt;
            }
        }
        return dt;
    }
     
    function ts_sort_date(a,b) {
        dt1 = sort_date(ts_getInnerText(a.cells[SORT_COLUMN_INDEX]));
        dt2 = sort_date(ts_getInnerText(b.cells[SORT_COLUMN_INDEX]));
     
        if (dt1==dt2) {
            return 0;
        }
        if (dt1<dt2) { 
            return -1;
        }
        return 1;
    }
    function ts_sort_numeric(a,b) {
        var aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]);
        aa = clean_num(aa);
        var bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]);
        bb = clean_num(bb);
        return compare_numeric(aa,bb);
    }
    function compare_numeric(a,b) {
        var a = parseFloat(a);
        a = (isNaN(a) ? 0 : a);
        var b = parseFloat(b);
        b = (isNaN(b) ? 0 : b);
        return a - b;
    }
    function ts_sort_caseinsensitive(a,b) {
        aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]).toLowerCase();
        bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]).toLowerCase();
        if (aa==bb) {
            return 0;
        }
        if (aa<bb) {
            return -1;
        }
        return 1;
    }
    function ts_sort_default(a,b) {
        aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]);
        bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]);
        if (aa==bb) {
            return 0;
        }
        if (aa<bb) {
            return -1;
        }
        return 1;
    }
    function addEvent(elm, evType, fn, useCapture)
    // addEvent and removeEvent
    // cross-browser event handling for IE5+,    NS6 and Mozilla
    // By Scott Andrew
    {
        if (elm.addEventListener){
            elm.addEventListener(evType, fn, useCapture);
            return true;
        } else if (elm.attachEvent){
            var r = elm.attachEvent("on"+evType, fn);
            return r;
        } else {
            alert("Handler could not be removed");
        }
    }
    function clean_num(str) {
        str = str.replace(new RegExp(/[^-?0-9.]/g),"");
        return str;
    }
    function trim(s) {
        return s.replace(/^\s+|\s+$/g, "");
    }
    function alternate(table) {
        // Take object table and get all it's tbodies.
        var tableBodies = table.getElementsByTagName("tbody");
        // Loop through these tbodies
        for (var i = 0; i < tableBodies.length; i++) {
            // Take the tbody, and get all it's rows
            var tableRows = tableBodies[i].getElementsByTagName("tr");
            // Loop through these rows
            // Start at 1 because we want to leave the heading row untouched
            for (var j = 0; j < tableRows.length; j++) {
                // Check if j is even, and apply classes for both possible results
                if ( (j % 2) == 0  ) {
                    if ( !(tableRows[j].className.indexOf('odd') == -1) ) {
                        tableRows[j].className = tableRows[j].className.replace('odd', 'even');
                    } else {
                        if ( tableRows[j].className.indexOf('even') == -1 ) {
                            tableRows[j].className += " even";
                        }
                    }
                } else {
                    if ( !(tableRows[j].className.indexOf('even') == -1) ) {
                        tableRows[j].className = tableRows[j].className.replace('even', 'odd');
                    } else {
                        if ( tableRows[j].className.indexOf('odd') == -1 ) {
                            tableRows[j].className += " odd";
                        }
                    }
                } 
            }
        }
    }
    </script>
    <script language="VBScript">
     Sub window_Onload()
    	Dim StrHTML
    	Call View_Scopes()
    	StrHTML = "<table class = 'sortable' id='sortabletable'><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th><th class='unsortable'>Unsortable</th><tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td></tr><tr><td>11</td><td>12</td><td>13</td><td>14</td><td>15</td><td>20</td></tr><tr class='sortbottom'><td>Hackoo</td><td>Crackoo</td><td>vous</td><td>salue</td><td>Monsieur</td><td>snorky94</td></tr></table>"
    	VBS_DisplayArea1.innerHTML = StrHTML
    	MonBouton.Value = "View Scopes"
    	VBS_DisplayArea2.style.visibility="hidden"
    End sub
     
    Sub View_Scopes()
    	Dim StrHTML
    	StrHTML = "<table class = 'sortable' id='sortabletable'><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th><th class='unsortable'>Unsortable</th><tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td></tr><tr><td>11</td><td>12</td><td>13</td><td>14</td><td>15</td><td>20</td></tr><tr class='sortbottom'><td>Hackoo</td><td>Crackoo</td><td>vous</td><td>salue</td><td>Monsieur</td><td>snorky94</td></tr></table>"
    	VBS_DisplayArea2.InnerHtml = StrHTML
    End Sub
     
    Sub ToggleButton()
    	If VBS_DisplayArea2.style.visibility="hidden" Then
    		VBS_DisplayArea2.style.visibility="visible"
    		MonBouton.Value = "Hide Scopes"
    	Else
    		VBS_DisplayArea2.style.visibility="hidden"
    		MonBouton.Value = "View Scopes"
    	End If
    End Sub
    </script>
    </head>
    <body>
     <p>
    <input type="button" Id="MonBouton" onClick="ToggleButton()">
    </p>
     <p>
    <span id = "VBS_DisplayArea1"></span>
    </p>
     <p>
    <span id = "VBS_DisplayArea2"></span>
    </p>
    </body>
    </html>

  12. #12
    Membre habitué
    Homme Profil pro
    Ingénieur systèmes et réseaux
    Inscrit en
    Juillet 2012
    Messages
    284
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur systèmes et réseaux
    Secteur : Finance

    Informations forums :
    Inscription : Juillet 2012
    Messages : 284
    Points : 132
    Points
    132
    Par défaut
    Ce n'est pas ca le pb

    Je verrais un peu plus tard

    Merci.

  13. #13
    Expert éminent
    Avatar de hackoofr
    Homme Profil pro
    Enseignant
    Inscrit en
    Juin 2009
    Messages
    3 840
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Juin 2009
    Messages : 3 840
    Points : 9 225
    Points
    9 225
    Par défaut

    Si votre code ne comporte pas des données personnelles et confidentielles, alors,vous pouvez, le poster en totalité pour voir comment vous voulez l'adapter
    @+

  14. #14
    Membre habitué
    Homme Profil pro
    Ingénieur systèmes et réseaux
    Inscrit en
    Juillet 2012
    Messages
    284
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur systèmes et réseaux
    Secteur : Finance

    Informations forums :
    Inscription : Juillet 2012
    Messages : 284
    Points : 132
    Points
    132
    Par défaut
    Bonjour,

    Ci-dessous le code en question.

    Il permet d'extraire les données d'un serveur DHCP et d'afficher l'état d'occupation des scopes, ip libre, etc ...

    Avant d'executer le script, il faut juste copier les 2 fichiers joints (zip):

    dhcp_dump_10.232.69.58.txt
    dhcp_mibs_10.232.69.58.txt

    Dans la variable %temp% de la machine.

    Ensuite il faut juste cliquer sur View Scopes
    et la un tableau s'affiche avec le taux d'utilisation etc.

    C'est les colones de ce tableau en résulat que je souhaiterais pour trier, ce serait parfait.

    Ci-dessous le code :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    723
    724
    725
    726
    727
    728
    729
    730
    731
    732
    733
    734
    735
    736
    737
    738
    739
    740
    741
    742
    743
    744
    745
    746
    747
    748
    749
    750
    751
    752
    753
    754
    755
    756
    757
    758
    759
    760
    761
    762
    763
    764
    765
    766
    767
    768
    769
    770
    771
    772
    773
    774
    775
    776
    777
    778
    779
    780
    781
    782
    783
    784
    785
    786
    787
    788
    789
    790
    791
    792
    793
    794
    795
    796
    797
    798
    799
    800
    801
    802
    803
    804
    805
    806
    807
    808
    809
    810
    811
    812
    813
    814
    815
    816
    817
    818
    819
    820
    821
    822
    823
    824
    825
    826
    827
    828
    829
    830
    831
    832
    833
    834
    835
    836
    837
    838
    839
    840
    841
    842
    843
    844
    845
    846
    847
    848
    849
    850
    851
    852
    853
    854
    855
    856
    857
    858
    859
    860
    861
    862
    863
    864
    865
    866
    867
    868
    869
    870
    871
    872
    873
    874
    875
    876
    877
    878
    879
    880
    881
    882
    883
    884
    885
    886
    887
    888
    889
    890
    891
    892
    893
    894
    895
    896
    897
    898
    899
    900
    901
    902
    903
    904
    905
    906
    907
    908
    909
    910
    911
    912
    913
    914
    915
    916
    917
    918
    919
    920
    921
    922
    923
    924
    925
    926
    927
    928
    929
    930
    931
    932
    933
    934
    935
    936
    937
    938
    939
    940
    941
    942
    943
    944
    945
    946
    947
    948
    949
    950
    951
    952
    953
    954
    955
    956
    957
    958
    959
    960
    961
    962
    963
    964
    965
    966
    967
    968
    969
    970
    971
    972
    973
    974
    975
    976
    977
    978
    979
    980
    981
    982
    983
    984
    985
    986
    987
    988
    989
    990
    991
    992
    993
    994
    995
    996
    997
    998
    999
    1000
    1001
    1002
    1003
    1004
    1005
    1006
    1007
    1008
    1009
    1010
    1011
    1012
    1013
    1014
    1015
    1016
    1017
    1018
    1019
    1020
    1021
    1022
    1023
    1024
    1025
    1026
    1027
    1028
    1029
    1030
    1031
    1032
    1033
    1034
    1035
    1036
    1037
    1038
    1039
    1040
    1041
    1042
    1043
    1044
    1045
    1046
    1047
    1048
    1049
    1050
    1051
    1052
    1053
    1054
    1055
    1056
    1057
    1058
    1059
    1060
    1061
    1062
    1063
    1064
    1065
    1066
    1067
    1068
    1069
    1070
    1071
    1072
    1073
    1074
    1075
    1076
    1077
    1078
    1079
    1080
    1081
    1082
    1083
    1084
    1085
    1086
    1087
    1088
    1089
    1090
    1091
    1092
    1093
    1094
    1095
    1096
    1097
    1098
    1099
    1100
    1101
    1102
    1103
    1104
    1105
    1106
    1107
    1108
    1109
    1110
    1111
    1112
    1113
    1114
    1115
     
    <html>
     
    <head>
    	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    	<title>DHCP Manager</title>
    	<hta:application
    	ID="DHCP_Manager"
    	applicationname="DHCP_Manager"
    	Icon="%SystemRoot%\System32\magnify.exe"	
    	BORDERSTYLE="normal"
    	INNERBORDER="yes"
    	NAVIGABLE="yes"
    	SELECTION="yes"
    	SHOWINTASKBAR="yes"
    	scroll="auto"
    	WINDOWSTATE="maximize">	
     
    <!-- ======================================= DEBUT CSS ======================================= -->	
     
    <style type="text/css">
     
    body{font-size: 12px;font-family: arial;color:#000000; background-color:#306EFF;}
     
    h1 {text-align : center; font-size : 14px; font-weight : bold;}
     
    #title{background: #56A5EC;border-top: 1px solid #444444;border-bottom: 1px solid #444444;border-right: 1px solid #444444;border-left: 1px solid #444444;font: bold 14px Verdana, sans-serif;}
     
    #infoframe{border: 1px dashed black;color: black;font-weight: bold;padding: 5px 5px 5px 5px;background-color:#82CAFA;}
    #warningframe{border: 1px dashed black;color: black;font-weight: bold;padding: 5px 5px 5px 5px;background-color:#FF0000;}
    #okframe{border: 1px dashed black;color: black;font-weight: bold;padding: 5px 5px 5px 5px;background-color:#00CC33;}
     
    h4 {text-align : right; font-size : 11px;font-weight : bold;}
     
    table {width:100%;font: 12px;}
     
    table, th{border:1px solid #222222;border:1px solid #444444;border-collapse: collapse;}
     
    caption{color:white; background-color:#555555;font-weight : bold;}
     
    th{background-color:#56A5EC;}
     
    td {border:1px solid #222222;border:1px solid #444444;border-collapse: collapse;background-color:#82CAFA;}
     
    td, th {white-space: nowrap;}
     
    .graph {width:104px;height:10px;padding:1px;border:1px solid white;background:#2C3539;}
     
    .legend {width:30px;height:10px;padding:1px;border:1px solid black;}
     
    .bar {width:0px;height:10px;text-align : right;}
     
    /*
    .PB {width:700px;height:10px;padding:1px;border:1px solid white;background:#000000}
     
    .button {padding:1px;border:1px solid #000000;background: #82CAFA;width:130px;margin:auto;}
     
    .more {padding:0px;border:1px solid #000000;background: #6666FF;margin:auto;}
    */
     
    </style>
    <!-- ======================================= FIN CSS ======================================= -->	
     
     
    </head>
    <!-- ======================================= DEBUT VBS ======================================= -->	
    <script language="VBScript">
     
    '********************************************************************************
    ' LOAD
    '********************************************************************************
    Sub window_Onload
    	GetCurrentUsername()
    	FilterSelection.ServerName.Focus
    	Actions.InnerHTML = "<div id=infoframe>Use with Care. </br> </br>" _
    	& "The loading time at the first exectution of the script may be long (~1 min 30), so please wait. </br> </br>" _
    	& "Type the Ip address of the DHCP server you want to manage. </br> </br>" _
    	& "For best performances run the script locally.</div>"
    End sub
    '********************************************************************************
     
    '********************************************************************************
    ' GET CURRENT USER
    '********************************************************************************
    Function getCurrentUsername()
    	Set WshNetwork = CreateObject("WScript.Network")
    	GetCurrentUsername = WshNetwork.UserDomain & "\" & WshNetwork.UserName
    	UserName.InnerHTML = "Current Username : " & GetCurrentUsername
    End Function
    '********************************************************************************
     
    '################################################################################
    ' VIEW SCOPES 
    '################################################################################
    Sub View_Scopes()
     
    	ScopesList.InnerHTML = ""
    	Actions.InnerHTML = ""
    	DaysOld = 20
    	MinutesOld = 200
     
     
    	' Affichage d'un statut et récupération des valeurs fournies par l'utilisateur
    	strDHCPServer = FilterSelection.ServerName.Value
    	strFilter = FilterSelection.Filter.Value
     
    	' Variables
    	Set objShell = CreateObject("WScript.Shell")	
    	Set fso = CreateObject("Scripting.FileSystemObject")
     
    	If len(strDHCPServer) <= 0 Then
    		Actions.InnerHTML = "<div id=warningframe>Type server name !</div>"
    		FilterSelection.ServerName.Focus
    		Exit Sub
    	Else
    		Call Verif_IPV4(strDHCPServer,ValidIP)
    		If ValidIP = False Then
    			Actions.InnerHTML = "<div id=warningframe>Type a valid IP Address !</div>"
    			FilterSelection.ServerName.Focus
    			Exit Sub
    		End If
    	End If
     
    	' Dump Files Path	
    	DHCP_Dump_File = objShell.ExpandEnvironmentStrings("%temp%") & "\dhcp_dump_" & strDHCPServer & ".txt"
     
    	DHCP_Mibs_File = objShell.ExpandEnvironmentStrings("%temp%") & "\dhcp_mibs_" & strDHCPServer & ".txt"
     
    	Local_DHCP_Dump_File = objShell.ExpandEnvironmentStrings("%temp%") & "\dhcp_dump_" & strDHCPServer & ".txt"
    	Remote_DHCP_Dump_File = objShell.ExpandEnvironmentStrings("%SystemDrive%") & "\dhcp_dump_" & strDHCPServer & ".txt"
     
    	' Netsh Commands
    	DHCPDumpCmd = "netsh dhcp server \\" & strDHCPServer & " dump"
    	DHCPMibsCmd = "netsh dhcp server \\" & strDHCPServer & " show all"
     
    	If not (fso.FileExists(DHCP_Mibs_File)) Then
    		Call NetshCommand(DHCPMibsCmd,DHCP_Mibs_File,strDHCPServer,ResFile1,ResFile2,MibsStatus)	
    		'If ResFile1 = True AND ResFile2 = True Then
    		If (fso.FileExists(DHCP_Mibs_File)) AND (fso.FileExists(DHCP_Dump_File)) Then
    			Call Traitement_Scopes(DHCP_Dump_File,DHCP_Mibs_File)
    		End If
    	End If	
     
    	If MibsStatus = True Then Exit Sub
     
    	If not (fso.FileExists(DHCP_Dump_File)) Then
    		'Call NetshCommand(DHCPDumpCmd,DHCP_Dump_File,strDHCPServer,ResFile1,ResFile2)
    		Call LaunchProcess(strDHCPServer,Remote_DHCP_Dump_File,Local_DHCP_Dump_File)
     
     
    		'If ResFile1 = True AND ResFile2 = True Then
    		If (fso.FileExists(DHCP_Dump_File)) AND (fso.FileExists(DHCP_Mibs_File)) Then
    			Call Traitement_Scopes(DHCP_Dump_File,DHCP_Mibs_File)
    		End If
    	End If	
     
     
    	If (fso.FileExists(DHCP_Dump_File)) AND (fso.FileExists(DHCP_Mibs_File)) Then
    		set FDump = fso.GetFile(DHCP_Dump_File)
    		set FMibs = fso.GetFile(DHCP_Mibs_File)
     
    		If DateDiff("d", FMibs.DateLastModified, Now()) >= MinutesOld Then	
    			fso.DeleteFile(DHCP_Mibs_File)
    			Call NetshCommand(DHCPMibsCmd,DHCP_Mibs_File,strDHCPServer,ResFile1,ResFile2,MibsStatus)
    			'If ResFile1 = True AND ResFile2 = True Then
    			If (fso.FileExists(DHCP_Dump_File)) AND (fso.FileExists(DHCP_Mibs_File)) Then
    				Call Traitement_Scopes(DHCP_Dump_File,DHCP_Mibs_File)
    			End If	
    		ElseIf DateDiff("d", FDump.DateLastModified, Now()) >= DaysOld Then
    			fso.DeleteFile(DHCP_Dump_File)
    			'Call NetshCommand(DHCPDumpCmd,DHCP_Dump_File,strDHCPServer,ResFile1,ResFile2)
    			Call LaunchProcess(strDHCPServer,Remote_DHCP_Dump_File,Local_DHCP_Dump_File)
     
    			'If ResFile1 = True AND ResFile2 = True Then
    			If (fso.FileExists(DHCP_Dump_File)) AND (fso.FileExists(DHCP_Mibs_File)) Then
    				Call Traitement_Scopes(DHCP_Dump_File,DHCP_Mibs_File)
     
    			End If
    		End If
     
    		'If ResFile1 = True AND ResFile2 = True Then
    		If (fso.FileExists(DHCP_Dump_File)) AND (fso.FileExists(DHCP_Mibs_File)) Then
    			Call Traitement_Scopes(DHCP_Dump_File,DHCP_Mibs_File)	
    		End If
    	End If	
     
     
    End Sub
    '################################################################################
     
    '********************************************************************************
    ' GET VALID IPV4
    '********************************************************************************
    Function Verif_IPV4(IP,ValidIP)
     
    	ValidIP = False
    	Set RegExIP = New RegExp
     
    	With RegExIP
    		.Pattern    = "(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})"
    		.IgnoreCase = True
    		.Global     = False
    	End With
     
    	Set ResultRegExIP = RegExIP.Execute(IP)
    	If ResultRegExIP.count > 0 Then
    		ValidIP = True
    		Exit Function
    	End If
     
    End Function
    '********************************************************************************
     
    '********************************************************************************
    ' NETSH COMMAND
    '********************************************************************************
    Function NetshCommand(Command,File,DHCPServer,Result1,Result2,MibsHS)
     
    	Result1 = False
    	Result2 = False
    	MibsHS = False
    	Ftype = ""
    	Dim objConsole
    	Dim objFSO, objLog
    	set objConsole = new CliWrapper
    	Const ForWriting = 2
    	Const TristateFalse = 0
    	Const CreateIfNecessary = True
     
    	Set objFSO = CreateObject("Scripting.FileSystemObject")
     
    	Actions.InnerHTML = "<div id=infoframe>Dumping " & DHCPServer & " configuration in progress, please wait (~1 min 30) ...</div>"
    	strConsoleOut= objConsole.exec(Command)	
    	AllLigne = strConsoleOut
     
    	'Debug
    	'msgbox AllLigne
     
    	If Instr(File,"mibs") > 0 Then
    		Ftype = "mibs"
    	End If
     
    	If Instr(File,"dump") > 0 Then
    		Ftype = "dump"
    	End If
     
    	Select Case Ftype
    		Case "mibs"
     
    		If InStr(AllLigne,"Le serveur ne fonctionne ") > 0 Then
    				Actions.InnerHTML = "<div id=warningframe>Unable to connect to this server or Netsh component is unavailable. </br> </br> Have you registered netsh component with this command : cmd /c NETSH ADD HELPER DHCPMON.DLL ?</div>"
    				MibsHS = True
    				Exit Function
    			End If
     
    			If InStr(AllLigne,"La commande suivante n'a pas ") > 0 Then
    				Actions.InnerHTML = "<div id=warningframe>Unable to connect to this server or Netsh component is unavailable. </br> </br> Have you registered netsh component with this command : cmd /c NETSH ADD HELPER DHCPMON.DLL ?</div>"
    				MibsHS = True
    				Exit Function
    			End If
     
    			If InStr(AllLigne,"chec de la commande") > 0 Then
    				Actions.InnerHTML = "<div id=warningframe>Access denied. </br> </br> Please execute the script with an authorized account.</div>"
    				MibsHS = True
    				Exit Function
    			End If	
     
    			Result2 = True
    			Set objLog = objFSO.OpenTextFile(File, ForWriting, CreateIfNecessary, TristateFalse)
    			objLog.writeline AllLigne		
     
     
    		Case "dump"
     
    			If Not InStr(AllLigne,"add scope ") > 0 Then
    				Actions.InnerHTML = "<div id=warningframe>Access denied. </br> </br> Please execute the script with an authorized account.</div>"
    				Exit Function
    			End If
     
    			Result1 = True
    			Set objLog = objFSO.OpenTextFile(File, ForWriting, CreateIfNecessary, TristateFalse)
    			objLog.writeline AllLigne			
     
    	End Select
     
    End Function
    '********************************************************************************
     
    '********************************************************************************
    ' LAUCH DUMP PROCESS
    '********************************************************************************
    Function LaunchProcess(DHCPServer,RFile,Lfile)
     
    	On Error Resume Next
    	Set objWMIService = GetObject("winmgmts:"& "{impersonationLevel=impersonate}!\\" & DHCPServer & "\root\cimv2")
     
    	Select Case Err.Number
    	  Case 0
    		Const FEN = 0
     
    		Actions.InnerHTML = "<div id=infoframe>Dumping " & DHCPServer & " configuration in progress, please wait (~1 min 30) ...</div>"			
    		strCommand = "cmd /c netsh dhcp server " & DHCPServer & " dump > " & RFile 
     
    		Set objStartup = objWMIService.Get("Win32_ProcessStartup")
    		Set objConfig = objStartup.SpawnInstance_
    		objConfig.ShowWindow = FEN
     
    		Set objProcess = objWMIService.Get("Win32_Process")
    		intReturn = objProcess.Create(strCommand, Null, objConfig, intProcessID)
    		'wscript.echo intReturn
    		'wscript.echo intProcessID
     
    		ProcessRunning = TRUE
    		Do Until Not ProcessRunning
    			'Set colProcessList = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = 'netsh.exe'")
    			Set colProcessList = objWMIService.ExecQuery ("Select * from Win32_Process Where ProcessId = '" & intProcessID & "'")
    			If colProcessList.Count = 0 then
    				ProcessRunning = False	
    			End If
    		Loop
     
    		If intReturn = 0 and  ProcessRunning = False Then
    			Set objShell = CreateObject("WScript.Shell")	
    			strPath = objShell.ExpandEnvironmentStrings("%SystemDrive%")
    			RFile = Replace(RFile,":","$")
    			strPath = Replace(strPath,":","$")
    			strPath = "\\" & DHCPServer & "\" & strPath
     
    			'Net use Windows
    			strCommandMap = "cmd /c net use " & strPath 
    			ReturnCodeMap = objShell.Run(strCommandMap, 0, True)
     
    			'Copy
    			RFile = Replace(RFile,"C$\","")
    			strCommandCopy = "cmd /c copy " & strPath & "\" & RFile & " " & LFile & " /Y"
    			ReturnCodeCopy = objShell.Run(strCommandCopy, 0, True)
     
    			'Net use Windows
    			strCommandUNMap = "cmd /c net use " & strPath & " /d /Y"
    			ReturnCodeUNMap = objShell.Run(strCommandUNMap, 0, True)
    		End IF
     
    	  Case 70
    		' Run-time error '70': Permission denied
    		Actions.InnerHTML = "<div id=warningframe>Access denied. </br> </br> Please execute the script with an authorized account.</div>"
    	  Case 462
    		' The remote server machine does not exist or is unavailable
    		Actions.InnerHTML = "<div id=warningframe>Access denied. </br> </br> Please execute the script with an authorized account.</div>"
    	  Case -2147217375
    		' Unknown/undocumented runtime error (till this time)
    		Actions.InnerHTML = "<div id=warningframe>Access denied. </br> </br> Please execute the script with an authorized account.</div>"
    	  Case Else
    		' Unhandled Run-time error (till this time)
    		Actions.InnerHTML = "<div id=warningframe>Access denied. </br> </br> Please execute the script with an authorized account.</div>"
    	End Select
    	Err.Clear
    	On Error GoTo 0
     
     
    End Function
    '********************************************************************************
     
    '********************************************************************************
    ' Déclaration de la classe CliWrapper, qui permet d'exécuter une commande externe sans pop up
    '********************************************************************************
    Class CliWrapper
     
    	public stdout, stderr, command
    	private sh, fso, syncmode, outfile, errfile
    	private ForReading, TristateUseDefault, DoNotCreateFile
     
    	public function Exec(sCmd)
    		' clean out old stdout and stderr
    		stdout = vbNullString: stderr = vbNullString
    		command = sh.ExpandEnvironmentStrings(sCmd)
    		sh.Run "%COMSPEC% /c " & sCmd & " 2>" & errfile _
    		& " 1>" & outfile, 0, syncmode
    		stderr = ProcessFile(errfile)
    		stdout = ProcessFile(outfile)
    		Exec = stdout
    	end function
     
    	private sub class_initialize
    		' for speed of use over time
    		Set sh = createobject("WScript.Shell")
    		Set fso = createobject("Scripting.FileSystemObject")
    		ForReading = 1: TristateUseDefault = -2
    		DoNotCreateFile = false
    		outfile = sh.ExpandEnvironmentStrings("%temp%") & "\" & fso.GetTempName
    		errfile = sh.ExpandEnvironmentStrings("%temp%") & "\" & fso.GetTempName
    		syncmode = true
    	end sub
     
    	private function ProcessFile(filepath)
    	  ' given the path to a file, will return entire contents
    	  if fso.FileExists(filepath) then
    		with fso.OpenTextFile(filepath, ForReading, _
    		false, TristateUseDefault)
    		if .AtEndOfStream <> true then
    			ProcessFile = .ReadAll
    		end if
    		.Close
    		fso.DeleteFile(filepath)
    	   end with
    	  else
    		'msgbox "Erreur avec les fichiers temporaires...",vbExclamation,"Erreur !"
    	  end if 
    	end function
     
    end class
    '********************************************************************************
     
    '********************************************************************************
    ' TRAITEMENT SCOPES
    '********************************************************************************
    Sub Traitement_Scopes(DHCP_Dump_File,DHCP_Mibs_File)
     
    	StartTime = Timer()
    	strFilter = FilterSelection.Filter.Value
    	strDHCPServer = FilterSelection.ServerName.Value
     
    	Const ForReading = 1
    	Const ForWriting = 2
    	Const ModeAscii = 0
     
    	Dim objFSO, objFile
    	Set objFSO = CreateObject("Scripting.FileSystemObject")
     
    	' Dictionaries
    	Set DicoAddValidScope = CreateObject("Scripting.Dictionary")
    	Set DicoAddScopeStatus = CreateObject("Scripting.Dictionary")
    	Set DicoAddScopeLease = CreateObject("Scripting.Dictionary")
    	Set DicoAddMibs = CreateObject("Scripting.Dictionary")
    	Set DicoAddExcludeRange = CreateObject("Scripting.Dictionary")
     
    	DicoAddValidScope.CompareMode = vbTextCompare
    	DicoAddScopeStatus.CompareMode = vbTextCompare
    	DicoAddScopeLease.CompareMode = vbTextCompare
    	DicoAddMibs.CompareMode = vbTextCompare
    	DicoAddExcludeRange.CompareMode = vbTextCompare
     
    	'Read File 1
    	AllLigne = ""
    	Ligne = ""
     
    	Set Fichier_Parcourir1 = objFSO.OpenTextFile(DHCP_Dump_File,ForReading)
    	Do While Fichier_Parcourir1.AtEndOfStream <> True  
    		AllLigne = Fichier_Parcourir1.ReadAll
     
    		'Debug
    		'Actions.InnerHTML = AllLigne
     
    		Tableau = Split(AllLigne,vbnewline)
    		For i = lbound(Tableau) to ubound(Tableau)
    			Ligne = Tableau(i)
     
    			' Find Scope and and to dico
    			If InStr(Ligne,"add scope ") > 0 Then
    				Call GetScopeInfos(Ligne,mScope,SMask,SName,Sdesc)
    				Infos = mScope & "#" & SMask & "#" & SName & "#" & Sdesc
    				If Not DicoAddValidScope.Exists(mScope) Then
    					DicoAddValidScope.add mScope, Infos
    				End If
    			End If
     
    			' Find Scope State  and and to dico
    			If InStr(Ligne,"set state ") > 0 Then
    				Call GetScopeState(Ligne,mScope,State)
    				If Not DicoAddScopeStatus.Exists(mScope) Then
    					DicoAddScopeStatus.add mScope, State
    				End If
    			End If
     
    			' Find Lease and and to dico
    			If InStr(Ligne,"optionvalue 51 DWORD ") > 0 Then
    				Call GetScopeLease(Ligne,mScope,gLease)
    				If Not DicoAddScopeLease.Exists(mScope) Then
    					DicoAddScopeLease.add mScope, gLease
    				End If
    			End If
     
    			' Find Exclude Scope
    			If InStr(Ligne,"excluderange ") > 0 Then
    				Call GetExcludeRange(Ligne,mScope,StartIP,EndIP)
    				ExCludeRange = "S:" & StartIP & "E:" & EndIP	
    				If Not DicoAddExcludeRange.Exists(mScope) Then
    					DicoAddExcludeRange.add mScope, ExCludeRange
    				Else
    					ExistValue = DicoAddExcludeRange.item(mScope)
    					If Not Instr(ExistValue,ExCludeRange ) > 0  Then
    						DicoAddExcludeRange.remove(mScope)
    						DicoAddExcludeRange.add mScope, ExistValue & "," & ExCludeRange
    					End If
    				End If
    			End If
    		Next	
    	Loop
    	'------
     
    	'Read File 2
    	AllLigne = ""
    	Ligne = ""
    	Set Fichier_Parcourir2 = objFSO.OpenTextFile(DHCP_Mibs_File,ForReading)
    	Do While Fichier_Parcourir2.AtEndOfStream <> True  
    		AllLigne = Fichier_Parcourir2.ReadAll
     
    		'Debug
    		'Actions.InnerHTML = AllLigne
     
    		If InStr(AllLigne, "Nombre de MIBÿ:") > 0 Then 
    			Language = "FR"
    			Lang.InnerHtml = "Language : " & Language
    			Search_Mibs = "Nombre de MIBÿ:"
    			Search_Scope = "Sous"
    			lenght = 15
    		ElseIf InStr(AllLigne, "MIBCounts:") > 0 Then 
    			Language = "EN"
    			Lang.InnerHtml = "Language : " & Language
    			Search_Mibs = "MIBCounts:"
    			Search_Scope = "Subnet = "
    			lenght = 10
    		End If
     
     
    		If InStr(AllLigne, Search_Mibs) > 0 Then
    			Tableau = Split(AllLigne,vbCrLf)
    			For i = 0 To UBound(Tableau)
    				Ligne = Tableau(i)
    				If Instr(Ligne, Search_Scope) > 0 Then
    					On error resume next
    					'Determine Scope name
    					tScope = Right(Tableau(i), Len(Tableau(i)) - lenght)
    					tScope = Left(tScope, Len(tScope) - 1)
    					'Determine number of addresses in use
    					UsedArray = Split(Tableau(i + 1), "=")
    					tUsed = CLng(Left(UsedArray(1), Len(UsedArray(1)) - 1))
    					'Determine number of addresses free
    					FreeArray = Split(Tableau(i + 2), "=")
    					tFree = CLng(Left(FreeArray(1), Len(FreeArray(1)) - 1))
    					'Determine percentage of addresses free
    					tSumTotal = CLng(tFree + tUsed)
    					If tSumTotal = 0 Then 
    						'Cannot divide by zero
    					Else
    						tPercentFree = (tFree / tSumTotal) * 100
    						tPercentFree = FormatNumber(tPercentFree, 0)
    						tPercentUsed = (tUsed / tSumTotal) * 100
    						tPercentUsed = FormatNumber(tPercentUsed, 0)
    						Datas = tUsed & "#" & tFree & "#" & tSumTotal & "#"  & tPercentFree & "#"  & tPercentUsed
    					End If
    					DicoAddMibs.add tScope, Datas
    					On error goto 0	
    					End If	
    			Next	
    		End If
    	Loop		
    	'------
     
    	'msgbox DicoAddValidScope.count
    	'msgbox DicoAddScopeStatus.count
    	'msgbox DicoAddScopeLease.count
    	'msgbox DicoAddExcludeRange.count
     
    	'----------------------------------------------------------
    	' Table Header
    	strScopeListHeader = "<table>" _
    	& "<caption>Scopes Informations</caption>" _
    	& "<tr>" _
    	& "<th>Count</th>" _
    	& "<th>Infos</th>" _
    	& "<th>Scope</th>" _
    	& "<th>Name</th>" _
    	& "<th>Lease</th>" _
    	& "<th>% Usage</th>" _
    	& "</tr>" 
    	'----------------------------------------------------------
     
    	'----------------------------------------------------------
    	' Legend	
    	ScopeListLegend = "<table>" _
    	& "<caption>Legend</caption>" _
    	& "<tr>" _
    	& "<td>" _
    	& "Disabled Scope : <span class='legend' style='background-color:#C0C0C0'></span>" _
    	& "&nbsp; Usage >= 80 % : <span class='legend' style='background-color:#FF0000'></span>" _
    	& "&nbsp; Usage >= 50 % : <span class='legend' style='background-color:#FF9933'></span>" _
    	& "&nbsp; Usage < 50 % : <span class='legend' style='background-color:#82CAFA'></span>" _
    	& "</td>" _
    	& "</tr>" _
    	& "</table></br>"
    	'---------------------------------------------------------
     
    	'----------------------------------------------------------
    	' Export Header
    	strToExportScopesBodyHeader = "Count" & ";" _
    	& "Scope" & ";" _
    	& "Mask" & ";" _
    	& "Name" & ";" _
    	& "Description" & ";" _
    	& "CIDR" & ";" _
    	& "BROADCAST" & ";" _
    	& "Total Host" & ";" _
    	& "IP Range" & ";" _
    	& "Status" & ";" _
    	& "Lease" & ";" _
    	& "Used IP" & ";" _
    	& "Free IP" & ";" _
    	& "Total" & ";" _
    	& "% Free" & ";" _
    	& "%Used" & ";" _
    	& "Excluded Range" & ";" _
    	& vbNewLine
    	'----------------------------------------------------------
     
    	CptScope = 0
    	IndexKeys = DicoAddValidScope.Keys
     
    	Dim strTableBody()
    	Redim strTableBody(DicoAddValidScope.count)
     
    	For key=0 To ubound(IndexKeys)
    		DicoAddValidScopeValue = DicoAddValidScope.item(IndexKeys(key))
    		DicoAddScopeStatusValue = DicoAddScopeStatus.item(IndexKeys(key))
    		DicoAddScopeLeaseValue = DicoAddScopeLease.item(IndexKeys(key))
    		DicoAddMibsValue = DicoAddMibs.item(IndexKeys(key))
    		DicoAddExcludeRangeValue = DicoAddExcludeRange.item(IndexKeys(key))	
    		Call Filter_Exist(DicoAddValidScopeValue,strFilter,Exist)
     
    		If Exist = True Then
    			CptScope = CptScope + 1
    			If Len(DicoAddValidScopeValue) > 0 Then 
    				Tab1 = Split(DicoAddValidScopeValue,"#")
    				tScope = Tab1(0)
    				tMask = Tab1(1)
    				tName = Tab1(2)
    				tDesc = Tab1(3)
    			Else
    				Exit Sub
    			End If
     
    			tCIDR = MaskLength(tMask)
    			tBROADCAST = CalcBroadcastAddress(tScope,tMask)				
    			tTOTAL_HOST = GetNumberOfAvailableHostAddresses(tCIDR)
    			tIP_RANGE = Range(tScope,tBROADCAST)
     
    			tExclude = "-"
    			tStatus = "-"
    			tLease = "-"
    			tMibs = "-"
     
    			If DicoAddExcludeRange.Exists(IndexKeys(key)) Then
    				tExclude = DicoAddExcludeRangeValue
    			End If
     
    			If DicoAddScopeStatus.Exists(IndexKeys(key)) Then
    				tStatus = DicoAddScopeStatusValue
    				HorizontalBar = ""
     
    				Select Case tStatus
    					Case 0 
    					Color = "#C0C0C0" 'Grey
    					'tUsed = ""
    					'tFree = ""
    					'tSumTotal = ""
    					'tPercentFree = ""
    					'tPercentUsed = ""
    					tStatus = "Disabled"
     
    					If Len(DicoAddMibsValue) > 0 Then 
    						Tab2 = Split(DicoAddMibsValue,"#")
    						tUsed = Tab2(0)
    						tFree = Tab2(1)
    						tSumTotal = Tab2(2)
    						tPercentFree = Tab2(3) 
    						tPercentUsed = Tab2(4) & " %"
    					End If
     
    					HorizontalBar =  "<div class=" & Chr(34) & "graph" & Chr(34) & "><div class=" & Chr(34) & "bar"  & Chr(34) & "style=" & Chr(34) & "background-color:"& color & "; width:" & tPercentUsed & chr(34) & ">" & tPercentUsed &"</div></div>"
     
    					Case 1 
    					If Len(DicoAddMibsValue) > 0 Then 
    						Tab2 = Split(DicoAddMibsValue,"#")
    						tUsed = Tab2(0)
    						tFree = Tab2(1)
    						tSumTotal = Tab2(2)
    						tPercentFree = Tab2(3) 
    						tPercentUsed = Tab2(4)
    					End If
    						tStatus = "Enabled"
     
    						If tPercentUsed >= 80 Then
    							Color = "#FF0000" 'Red
    							tPercentUsed = tPercentUsed & " %"
    						ElseIf tPercentUsed >= 50 Then						
    							color = "#FF9933" 'Orange
    							tPercentUsed = tPercentUsed & " %"
    						Else
    							Color = "#82CAFA" 'Blue
    							tPercentUsed = tPercentUsed & " %"
    						End If
     
    						HorizontalBar =  "<div class=" & Chr(34) & "graph" & Chr(34) & "><div class=" & Chr(34) & "bar"  & Chr(34) & "style=" & Chr(34) & "background-color:"& color & "; width:" & tPercentUsed & chr(34) & ">" & tPercentUsed &"</div></div>"
     
    				End Select
     
    			End If
     
    			If DicoAddScopeLease.Exists(IndexKeys(key)) Then
    				tLease = DicoAddScopeLeaseValue
    			End If	
     
    			If DicoAddMibs.Exists(IndexKeys(key)) Then
    				tMibs = DicoAddMibsValue
    			End If
     
    			'& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">" & tDesc & "</td>" _ 
    			'& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">" & tPercentUsed & "</td>" _
    			'& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">" & tMask & "</td>" _			
    			'& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">" & tBROADCAST & "</td>" _
    			'& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">" & tIP_RANGE & "</td>" _	
    			'& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">" & tStatus & "</td>" _
    			'& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">" & tPercentFree & "</td>" _
    			'& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">" & tExclude & "</td>" _
    			'& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">" & tUsed & "</td>" _
    			'& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">" & tSumTotal & "</td>" _
    			'& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">" & tTOTAL_HOST & "</td>" _
    			'& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">/" & tCIDR & "</td>" _
    			'& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">" & tFree & "</td>" _
    			'& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">" & tTOTAL_HOST & "</td>" _
     
    			' Table Body	
    			aHTML = "<tr><Form method='POST'>" _
    			& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">" & CptScope & "</td>" _
    			& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & "><input type='button' Value='Infos' onclick='Call Scope_Infos(tscope.value,tmask.value,tname.value,tdesc.value,tstatus.value,tlease.value,tcidr.value,tbroadcast.value,ttotal_host.value,tip_range.value,tused.value,tfree.value,tsumtotal.value,tpercentfree.value,tpercentused.value,texclude.value)' class='more'></td>" _
    			& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">" & tScope & "</td>" _
    			& "<input type='hidden'  name='tscope'  value='" & tScope & "'>" _
    			& "<input type='hidden'  name='tmask'  value='" & tMask & "'>" _
    			& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">" & tName & "</td>" _
    			& "<input type='hidden'  name='tname'  value='" & tName & "'>" _
    			& "<input type='hidden'  name='tdesc'  value='" & tDesc & "'>" _ 
    			& "<input type='hidden'  name='tcidr'  value='" & tCIDR & "'>" _
    			& "<input type='hidden'  name='tbroadcast'  value='" & tBROADCAST & "'>" _
    			& "<input type='hidden'  name='ttotal_host'  value='" & tTOTAL_HOST & "'>" _
    			& "<input type='hidden'  name='tip_range'  value='" & tIP_RANGE & "'>" _
    			& "<input type='hidden'  name='tstatus'  value='" & tStatus & "'>" _
    			& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">" & tLease & "</td>"	 _
    			& "<input type='hidden'  name='tlease'  value='" & tLease & "'>" _
    			& "<input type='hidden'  name='tused'  value='" & tUsed & "'>" _
    			& "<input type='hidden'  name='tfree'  value='" & tFree & "'>" _
    			& "<input type='hidden'  name='tsumtotal'  value='" & tSumTotal & "'>" _
    			& "<input type='hidden'  name='tpercentfree'  value='" & tPercentFree & "'>" _
    			& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">" & HorizontalBar & "</td>" _
    			& "<input type='hidden'  name='tpercentused'  value='" & tPercentUsed & "'>" _
    			& "<input type='hidden'  name='texclude'  value='" & tExclude & "'>" _
    			& "</tr></Form>"
     
    			strTableBody(key) =  aHTML	
     
    			strToExportScopesBody = strToExportScopesBody _
    			& CptScope & ";" _
    			& tScope & ";" _
    			& tMask & ";" _
    			& tName & ";" _
    			& tDesc & ";" _
    			& tCIDR & ";" _
    			& tBROADCAST & ";" _
    			& tTOTAL_HOST & ";" _
    			& tIP_RANGE & ";" _
    			& tStatus & ";" _
    			& tLease & ";" _
    			& tUsed & ";" _
    			& tFree & ";" _
    			& tSumTotal & ";" _
    			& tPercentFree & ";" _
    			& tPercentUsed & ";" _
    			& tExclude & ";" _
    			& vbNewLine
     
    			strToExportScopesBody = Replace(strToExportScopesBody,"'","")			
     
    		End If
     
    	Next
     
    	Dim To_Export
    	Dim Scopes_CSVFile
     
    	To_Export =  strToExportScopesBodyHeader & strToExportScopesBody
    	Scopes_CSVFile = Replace(strFilter," ","_") & "_" & Replace(strDHCPServer,".",".") & "_scopes.csv"
     
    	ExportButton = "<input type='hidden'  name='Scopes_CSVFile'  value='" & Scopes_CSVFile & "'>" _
    	& "<input type='hidden'  name='To_Export'  value='" & To_Export & "'>" _
    	& "<input type='button' value='Export to CSV' onclick='Call ExportToCSV(Scopes_CSVFile.value,To_Export.value)'></br></br>"
     
     
    	strHTML = caca & ScopeListLegend & ExportButton  & strScopeListHeader & Join(strTableBody,"") & "</table>"	
     
    	' Result
    	If CptScope >= 1 Then
    		Actions.InnerHTML = "<div id=infoframe>Result with filter : <b>" & strFilter & "</b></br>Execution Time : <b>" & FormatNumber(Timer() - StartTime, 2) & " seconds </b></div>"
    		ScopesList.InnerHTML = strHTML
    		FilterSelection.Filter.Focus
    		Exit Sub
    	Else
    		If Len(strFilter) > 0 Then
    			Actions.InnerHTML = "<div id=warningframe>" & strFilter & " Not Found !</div>"
    		Else
    			Actions.InnerHTML = "<div id=warningframe>No data !</div>"
    		End If
    		FilterSelection.Filter.Focus
    		Exit Sub
    	End If	
     
    End Sub
    '********************************************************************************
     
    '********************************************************************************
    ' GET SCOPE INFOS
    '********************************************************************************
    Function GetScopeInfos(FstrScopeLine,FScope,FMask,FName,FDesc)
    	If len(FstrScopeLine) > 0 Then
    		Tab1 = Split(FstrScopeLine," ")
    		FScope = Tab1(5)
    		FMask = Tab1(6)
    		Tab1 = Split(FstrScopeLine,"""")
    		FName = Tab1(1)
    		FDesc = Tab1(3)
    	Else
    		Exit Function
    	End If
    End Function 
    '********************************************************************************
     
    '********************************************************************************
    ' GET SCOPE STATE
    '********************************************************************************
    Function GetScopeState(strScopeLine,Scope,State)
    	If len(strScopeLine) > 0 Then
    		Tab1 = Split(strScopeLine," ")
    		Scope = Tab1(4)
    		State = Tab1(7)
    	Else
    		Exit Function
    	End If
    End Function 
    '********************************************************************************
     
    '********************************************************************************
    ' GET SCOPE LEASE
    '********************************************************************************
    Function GetScopeLease(strScopeLine,Scope,gLease)
    	If len(strScopeLine) > 0 Then
    		on error resume next 'a regarder
    		Tab1 = Split(strScopeLine," ")
    		Scope = Tab1(4)
    		gLease = Tab1(9)
    		gLease = Replace(gLease,"""","")	
     
    		If Len(gLease) > 0 Then
    			If gLease <= 0 Then
    				gLease = "NO LEASE"
    				Exit Function
    			Else
    				LEASE_H = FormatNumber((gLease/3600),1)
    				LEASE_D = (LEASE_H/24)
    				If LEASE_D <= 0 Then
    					LEASE_D = 0
    				Else
    					LEASE_D = FormatNumber((LEASE_H/24),0)
    				End If
    				gLease = LEASE_H & " (H) " & LEASE_D  & " (D) "
    			End If
    		End If
    		On error goto 0
    	Else
    		Exit Function
    	End If
    End Function 
    '********************************************************************************
     
    '********************************************************************************
    ' GET EXCLUDE RANGE
    '********************************************************************************
    Function GetExcludeRange(strScopeLine,Scope,StartIP,EndIP)
    	If len(strScopeLine) > 0 Then
    		Tab1 = Split(strScopeLine," ")
    		Scope = Tab1(4)
    		StartIP = Tab1(7)
    		EndIP = Tab1(8)
    		'ExCludeRange = "S:" & StartIP & "E:" & EndIP
    	Else
    		Exit Function
    	End If		
     
    End Function 
    '********************************************************************************
     
    '********************************************************************************
    ' GET FILTER 
    '********************************************************************************
    Function Filter_Exist(strToFind,strFilter,Exist)
     
    	Exist = False
     
    	Set RegExFilter = New RegExp
     
    	With RegExFilter
    		.Pattern    = strFilter
    		.IgnoreCase = True
    		.Global     = False
    	End With
     
    	Set ResultRegExFilter = RegExFilter.Execute(strToFind)
    	If ResultRegExFilter.count > 0 Then
    		Exist = True
    		Exit Function
    	End If
     
    End Function
    '********************************************************************************
     
    '********************************************************************************
    'EXPORT TO CSV
    '********************************************************************************
    Function ExportToCSV(strFile,strData)
     
    	If len(strData) > 0 Then
    		 Const ForWriting = 2
    		 Const TristateFalse = 0
    		 Const CreateIfNecessary = True
     
    		 Dim objFSO, objTextFile 
    		 Set objFSO = CreateObject("Scripting.FileSystemObject")
     
    		curDir = objFSO.GetAbsolutePathName(".")
     
    		 Set objTextFile  = objFSO.OpenTextFile(strFile, ForWriting, CreateIfNecessary, TristateFalse)
    		 objTextFile.Write (strData)
    		 If err.number <> 0 Then
    			Actions.InnerHTML = "<div id=warningframe>Error ...</div>"
    			Exit Function
    		Else
    			Actions.InnerHTML = "<div id=okframe>File successfully saved in : " & curDir & "\" & strFile & "</div>"
    		End If
    	Else
    		Exit Function
    	End If	
     
    End Function
    '********************************************************************************
     
     
    '==========================================================================
    ' Fonction Convertir Mask en CIDR
    '--------------------------------------------------------------------------
    Function MaskLength(MASK_SCOPE) 
    	Dim arrOctets : arrOctets = Split(MASK_SCOPE, ".") 
    	Dim i 
    	For i = 0 to UBound(arrOctets) 
    		Dim intOctet : intOctet = CInt(arrOctets(i)) 
    		Dim j, intMaskLength 
    		For j = 0 To 7 
    			If intOctet And (2^(7 -j)) Then
    				intMaskLength = intMaskLength + 1 
    			End If
    		Next
    	Next
    	MaskLength = intMaskLength 
    End Function	 
    '==========================================================================
     
    '==========================================================================
    ' Fonction Calcul Adresse Broadcast
    '--------------------------------------------------------------------------
    Function CalcBroadcastAddress(SCOPE,MASK_SCOPE) 
    	Dim strBinIP : strBinIP = ConvertIPToBinary(SCOPE) 
    	Dim strBinMask : strBinMask = ConvertIPToBinary(MASK_SCOPE) 
    	' Set each unmasked bit to 1 
    	Dim i, strBinBroadcast 
    	For i = 1 to Len(strBinIP) 
    		Dim strIPBit : strIPBit = Mid(strBinIP, i, 1) 
    		Dim strMaskBit : strMaskBit = Mid(strBinMask, i, 1) 
    		If strIPBit = "1" Or strMaskBit = "0" Then
    			strBinBroadcast = strBinBroadcast & "1"
    		ElseIf strIPBit = "." Then
    			strBinBroadcast = strBinBroadcast & strIPBit 
    		Else
    			strBinBroadcast = strBinBroadcast & "0"
    		End If
    	Next
    	CalcBroadcastAddress = ConvertBinIPToDecimal(strBinBroadcast) 
    End Function	 
    '==========================================================================
     
    '==========================================================================
    ' Fonction Convertir IP en Binaire
    '--------------------------------------------------------------------------
    Function ConvertIPToBinary(SCOPE) 
    	Dim arrOctets : arrOctets = Split(SCOPE, ".") 
    	Dim i 
    	For i = 0 to UBound(arrOctets) 
    		Dim intOctet : intOctet = CInt(arrOctets(i)) 
    		Dim strBinOctet : strBinOctet = ""
    		Dim j 
    		For j = 0 To 7 
    			If intOctet And (2^(7 - j)) Then
    				strBinOctet = strBinOctet & "1"
    			Else
    				strBinOctet = strBinOctet & "0"
    			End If
    		Next
    		arrOctets(i) = strBinOctet 
    	Next
    	ConvertIPToBinary = Join(arrOctets, ".") 
    End Function	 
    '==========================================================================
     
    '==========================================================================
    ' Fonction Convertir Binaire en Decimal
    '--------------------------------------------------------------------------
    Function ConvertBinIPToDecimal(strBinIP) 
    	Dim arrOctets : arrOctets = Split(strBinIP, ".") 
    	Dim i 
    	For i = 0 to UBound(arrOctets) 
    		Dim intOctet : intOctet = 0 
    		Dim j 
    		For j = 0 to 7 
    			Dim intBit : intBit = CInt(Mid(arrOctets(i), j + 1, 1)) 
    			If intBit = 1 Then
    				intOctet = intOctet + 2^(7 - j) 
    			End If
    		Next
    		arrOctets(i) = CStr(intOctet) 
    	Next
    	ConvertBinIPToDecimal = Join(arrOctets, ".") 
    End Function	 
    '==========================================================================
     
    '==========================================================================
    ' Fonction Calcul Total hotes pour un réseau
    '--------------------------------------------------------------------------
    Function GetNumberOfAvailableHostAddresses(CIDR) 
    	Dim nHosts, nAvailableBits 
    	nHosts = -1 
    	nAvailableBits = 32 - CIDR
    	'wscript.echo nAvailableBits 
    	'Number of Addresses Available for Hosts in Subnet = 2(32 - Number of Masked Bits) - 2 
    	nHosts = (2 ^ nAvailableBits) - 2 
    	GetNumberOfAvailableHostAddresses = nHosts 
    End Function
    '==========================================================================
     
    '==========================================================================
    ' Fonction Get IP Range 
    '--------------------------------------------------------------------------
    Function Range(FScope,FBROADCAST)
    	If Len(FScope) > 0 Then
    		IP_START = Split(FScope, ".")
    		IP_START_RES = IP_START(0) & "." & IP_START(1) & "." & IP_START(2) & "." & IP_START(3)+1
    		IP_END = Split(FBROADCAST, ".")
    		IP_END_RES = IP_END(0) & "." & IP_END(1) & "." & IP_END(2) & "." & IP_END(3)-1
    		Range = (IP_START_RES & " - " & IP_END_RES)	
    	End If
    End Function
    '==========================================================================
     
     
    </script>
     
     
    </head>
     
    <body>
     
    <br><span id = "VBS_DisplayArea"></span>
     
    <div id="title"><h1>DHCP Manager V1.0</h1></div>
     
    <p>
    	<span>
    		<form name="FilterSelection" id="FilterSelection">
    			<table>
    				<caption>Select DHCP Server to manage</caption>
    				<tr>
    					<td>DHCP Server  (Ip Address) : </td>
    					<td><input name="ServerName" value="10.232.69.58"></td>
    				</tr>
     
    				<tr>
    					<td>Scope Filter (Blank = No Filter) : </td>
    					<td><input name="Filter" value=""></td>
    				</tr>
     
    			</table>
    		</form>
    	</span>	
    </p>
     
    <p>
    <input type="submit" Value="View Scopes" onClick="View_Scopes()" class="button">
    </p>
     
    <span id = "Actions"></span>
     
    <p>
    <span id = "ScopesList"></span>
    </p>
     
    <h4>Copyright Distributed Windows 2013</br> 
    <span id = "UserName"></span></br> 
    <span id = "Lang"></span>
    </h4>
     
    </body>
    </html>
    Merci encore pour ton aide
    Fichiers attachés Fichiers attachés

  15. #15
    Expert éminent
    Avatar de hackoofr
    Homme Profil pro
    Enseignant
    Inscrit en
    Juin 2009
    Messages
    3 840
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Juin 2009
    Messages : 3 840
    Points : 9 225
    Points
    9 225
    Par défaut

    Oui j'avoue que c'est trop compliqué et casse-tête pour intégrer un grand JS dans un grand HTA comme celui-là
    Le problème maintenant c'est qu'il faut connaître et localiser l'erreur si elle vient du HTA ou bien du JS
    Donc, après intégration, on a toujours un petit bug au chargement du JS, mais en ignorant cette dernière on peut trier après le tableau.
    Testez-le
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    723
    724
    725
    726
    727
    728
    729
    730
    731
    732
    733
    734
    735
    736
    737
    738
    739
    740
    741
    742
    743
    744
    745
    746
    747
    748
    749
    750
    751
    752
    753
    754
    755
    756
    757
    758
    759
    760
    761
    762
    763
    764
    765
    766
    767
    768
    769
    770
    771
    772
    773
    774
    775
    776
    777
    778
    779
    780
    781
    782
    783
    784
    785
    786
    787
    788
    789
    790
    791
    792
    793
    794
    795
    796
    797
    798
    799
    800
    801
    802
    803
    804
    805
    806
    807
    808
    809
    810
    811
    812
    813
    814
    815
    816
    817
    818
    819
    820
    821
    822
    823
    824
    825
    826
    827
    828
    829
    830
    831
    832
    833
    834
    835
    836
    837
    838
    839
    840
    841
    842
    843
    844
    845
    846
    847
    848
    849
    850
    851
    852
    853
    854
    855
    856
    857
    858
    859
    860
    861
    862
    863
    864
    865
    866
    867
    868
    869
    870
    871
    872
    873
    874
    875
    876
    877
    878
    879
    880
    881
    882
    883
    884
    885
    886
    887
    888
    889
    890
    891
    892
    893
    894
    895
    896
    897
    898
    899
    900
    901
    902
    903
    904
    905
    906
    907
    908
    909
    910
    911
    912
    913
    914
    915
    916
    917
    918
    919
    920
    921
    922
    923
    924
    925
    926
    927
    928
    929
    930
    931
    932
    933
    934
    935
    936
    937
    938
    939
    940
    941
    942
    943
    944
    945
    946
    947
    948
    949
    950
    951
    952
    953
    954
    955
    956
    957
    958
    959
    960
    961
    962
    963
    964
    965
    966
    967
    968
    969
    970
    971
    972
    973
    974
    975
    976
    977
    978
    979
    980
    981
    982
    983
    984
    985
    986
    987
    988
    989
    990
    991
    992
    993
    994
    995
    996
    997
    998
    999
    1000
    1001
    1002
    1003
    1004
    1005
    1006
    1007
    1008
    1009
    1010
    1011
    1012
    1013
    1014
    1015
    1016
    1017
    1018
    1019
    1020
    1021
    1022
    1023
    1024
    1025
    1026
    1027
    1028
    1029
    1030
    1031
    1032
    1033
    1034
    1035
    1036
    1037
    1038
    1039
    1040
    1041
    1042
    1043
    1044
    1045
    1046
    1047
    1048
    1049
    1050
    1051
    1052
    1053
    1054
    1055
    1056
    1057
    1058
    1059
    1060
    1061
    1062
    1063
    1064
    1065
    1066
    1067
    1068
    1069
    1070
    1071
    1072
    1073
    1074
    1075
    1076
    1077
    1078
    1079
    1080
    1081
    1082
    1083
    1084
    1085
    1086
    1087
    1088
    1089
    1090
    1091
    1092
    1093
    1094
    1095
    1096
    1097
    1098
    1099
    1100
    1101
    1102
    1103
    1104
    1105
    1106
    1107
    1108
    1109
    1110
    1111
    1112
    1113
    1114
    1115
    1116
    1117
    1118
    1119
    1120
    1121
    1122
    1123
    <html>
    <head>
    	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    	<title>DHCP Manager</title>
    	<hta:application
    	ID="DHCP_Manager"
    	applicationname="DHCP_Manager"
    	Icon="%SystemRoot%\System32\magnify.exe"	
    	BORDERSTYLE="normal"
    	INNERBORDER="yes"
    	NAVIGABLE="yes"
    	SELECTION="yes"
    	SHOWINTASKBAR="yes"
    	scroll="auto"
    	WINDOWSTATE="maximize">	
      <script type="text/javascript" src="sort_table.js"></script>
    <!-- ======================================= DEBUT CSS ======================================= -->	
     
    <style type="text/css">
     
    body{font-size: 12px;font-family: arial;color:#000000; background-color:#306EFF;}
     
    h1 {text-align : center; font-size : 14px; font-weight : bold;}
     
    #title{background: #56A5EC;border-top: 1px solid #444444;border-bottom: 1px solid #444444;border-right: 1px solid #444444;border-left: 1px solid #444444;font: bold 14px Verdana, sans-serif;}
     
    #infoframe{border: 1px dashed black;color: black;font-weight: bold;padding: 5px 5px 5px 5px;background-color:#82CAFA;}
    #warningframe{border: 1px dashed black;color: black;font-weight: bold;padding: 5px 5px 5px 5px;background-color:#FF0000;}
    #okframe{border: 1px dashed black;color: black;font-weight: bold;padding: 5px 5px 5px 5px;background-color:#00CC33;}
     
    h4 {text-align : right; font-size : 11px;font-weight : bold;}
     
    table {width:100%;font: 12px;}
     
    table, th{border:1px solid #222222;border:1px solid #444444;border-collapse: collapse;}
     
    caption{color:white; background-color:#555555;font-weight : bold;}
     
    th{background-color:#56A5EC;}
     
    td {border:1px solid #222222;border:1px solid #444444;border-collapse: collapse;background-color:#82CAFA;}
     
    td, th {white-space: nowrap;}
     
    .graph {width:104px;height:10px;padding:1px;border:1px solid white;background:#2C3539;}
     
    .legend {width:30px;height:10px;padding:1px;border:1px solid black;}
     
    .bar {width:0px;height:10px;text-align : right;}
     
    /*
    .PB {width:700px;height:10px;padding:1px;border:1px solid white;background:#000000}
     
    .button {padding:1px;border:1px solid #000000;background: #82CAFA;width:130px;margin:auto;}
     
    .more {padding:0px;border:1px solid #000000;background: #6666FF;margin:auto;}
    */
     
    </style>
    <!-- ======================================= FIN CSS ======================================= -->	
     
    </head>
    <!-- ======================================= DEBUT VBS ======================================= -->	
    <script language="VBScript">
     
    '********************************************************************************
    ' LOAD
    '********************************************************************************
    Sub ToggleButton()
    	If ScopesList.style.visibility="hidden" Then
    		ScopesList.style.visibility="visible"
    		MonBouton.Value = "Hide Scopes"
    	Else
    		ScopesList.style.visibility="hidden"
    		MonBouton.Value = "View Scopes"
    	End If
    End Sub
     
    Sub window_Onload
    	ScopesList.style.visibility="hidden"
    	MonBouton.Value = "View Scopes"
    	GetCurrentUsername()
    	FilterSelection.ServerName.Focus
    	Actions.InnerHTML = "<div id=infoframe>Use with Care. </br> </br>" _
    	& "The loading time at the first exectution of the script may be long (~1 min 30), so please wait. </br> </br>" _
    	& "Type the Ip address of the DHCP server you want to manage. </br> </br>" _
    	& "For best performances run the script locally.</div>"
    	View_Scopes()
    End sub
    '********************************************************************************
     
    '********************************************************************************
    ' GET CURRENT USER
    '********************************************************************************
    Function getCurrentUsername()
    	Set WshNetwork = CreateObject("WScript.Network")
    	GetCurrentUsername = WshNetwork.UserDomain & "\" & WshNetwork.UserName
    	UserName.InnerHTML = "Current Username : " & GetCurrentUsername
    End Function
    '********************************************************************************
     
    '################################################################################
    ' VIEW SCOPES 
    '################################################################################
    Sub View_Scopes()
     
    	ScopesList.InnerHTML = ""
    	Actions.InnerHTML = ""
    	DaysOld = 20
    	MinutesOld = 200
     
     
    	' Affichage d'un statut et récupération des valeurs fournies par l'utilisateur
    	strDHCPServer = FilterSelection.ServerName.Value
    	strFilter = FilterSelection.Filter.Value
     
    	' Variables
    	Set objShell = CreateObject("WScript.Shell")	
    	Set fso = CreateObject("Scripting.FileSystemObject")
     
    	If len(strDHCPServer) <= 0 Then
    		Actions.InnerHTML = "<div id=warningframe>Type server name !</div>"
    		FilterSelection.ServerName.Focus
    		Exit Sub
    	Else
    		Call Verif_IPV4(strDHCPServer,ValidIP)
    		If ValidIP = False Then
    			Actions.InnerHTML = "<div id=warningframe>Type a valid IP Address !</div>"
    			FilterSelection.ServerName.Focus
    			Exit Sub
    		End If
    	End If
     
    	' Dump Files Path	
    	DHCP_Dump_File = objShell.ExpandEnvironmentStrings("%temp%") & "\dhcp_dump_" & strDHCPServer & ".txt"
     
    	DHCP_Mibs_File = objShell.ExpandEnvironmentStrings("%temp%") & "\dhcp_mibs_" & strDHCPServer & ".txt"
     
    	Local_DHCP_Dump_File = objShell.ExpandEnvironmentStrings("%temp%") & "\dhcp_dump_" & strDHCPServer & ".txt"
    	Remote_DHCP_Dump_File = objShell.ExpandEnvironmentStrings("%SystemDrive%") & "\dhcp_dump_" & strDHCPServer & ".txt"
     
    	' Netsh Commands
    	DHCPDumpCmd = "netsh dhcp server \\" & strDHCPServer & " dump"
    	DHCPMibsCmd = "netsh dhcp server \\" & strDHCPServer & " show all"
     
    	If not (fso.FileExists(DHCP_Mibs_File)) Then
    		Call NetshCommand(DHCPMibsCmd,DHCP_Mibs_File,strDHCPServer,ResFile1,ResFile2,MibsStatus)	
    		'If ResFile1 = True AND ResFile2 = True Then
    		If (fso.FileExists(DHCP_Mibs_File)) AND (fso.FileExists(DHCP_Dump_File)) Then
    			Call Traitement_Scopes(DHCP_Dump_File,DHCP_Mibs_File)
    		End If
    	End If	
     
    	If MibsStatus = True Then Exit Sub
     
    	If not (fso.FileExists(DHCP_Dump_File)) Then
    		'Call NetshCommand(DHCPDumpCmd,DHCP_Dump_File,strDHCPServer,ResFile1,ResFile2)
    		Call LaunchProcess(strDHCPServer,Remote_DHCP_Dump_File,Local_DHCP_Dump_File)
     
     
    		'If ResFile1 = True AND ResFile2 = True Then
    		If (fso.FileExists(DHCP_Dump_File)) AND (fso.FileExists(DHCP_Mibs_File)) Then
    			Call Traitement_Scopes(DHCP_Dump_File,DHCP_Mibs_File)
    		End If
    	End If	
     
     
    	If (fso.FileExists(DHCP_Dump_File)) AND (fso.FileExists(DHCP_Mibs_File)) Then
    		set FDump = fso.GetFile(DHCP_Dump_File)
    		set FMibs = fso.GetFile(DHCP_Mibs_File)
     
    		If DateDiff("d", FMibs.DateLastModified, Now()) >= MinutesOld Then	
    			fso.DeleteFile(DHCP_Mibs_File)
    			Call NetshCommand(DHCPMibsCmd,DHCP_Mibs_File,strDHCPServer,ResFile1,ResFile2,MibsStatus)
    			'If ResFile1 = True AND ResFile2 = True Then
    			If (fso.FileExists(DHCP_Dump_File)) AND (fso.FileExists(DHCP_Mibs_File)) Then
    				Call Traitement_Scopes(DHCP_Dump_File,DHCP_Mibs_File)
    			End If	
    		ElseIf DateDiff("d", FDump.DateLastModified, Now()) >= DaysOld Then
    			fso.DeleteFile(DHCP_Dump_File)
    			'Call NetshCommand(DHCPDumpCmd,DHCP_Dump_File,strDHCPServer,ResFile1,ResFile2)
    			Call LaunchProcess(strDHCPServer,Remote_DHCP_Dump_File,Local_DHCP_Dump_File)
     
    			'If ResFile1 = True AND ResFile2 = True Then
    			If (fso.FileExists(DHCP_Dump_File)) AND (fso.FileExists(DHCP_Mibs_File)) Then
    				Call Traitement_Scopes(DHCP_Dump_File,DHCP_Mibs_File)
     
    			End If
    		End If
     
    		'If ResFile1 = True AND ResFile2 = True Then
    		If (fso.FileExists(DHCP_Dump_File)) AND (fso.FileExists(DHCP_Mibs_File)) Then
    			Call Traitement_Scopes(DHCP_Dump_File,DHCP_Mibs_File)	
    		End If
    	End If	
     
     
    End Sub
    '################################################################################
     
    '********************************************************************************
    ' GET VALID IPV4
    '********************************************************************************
    Function Verif_IPV4(IP,ValidIP)
     
    	ValidIP = False
    	Set RegExIP = New RegExp
     
    	With RegExIP
    		.Pattern    = "(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})"
    		.IgnoreCase = True
    		.Global     = False
    	End With
     
    	Set ResultRegExIP = RegExIP.Execute(IP)
    	If ResultRegExIP.count > 0 Then
    		ValidIP = True
    		Exit Function
    	End If
     
    End Function
    '********************************************************************************
     
    '********************************************************************************
    ' NETSH COMMAND
    '********************************************************************************
    Function NetshCommand(Command,File,DHCPServer,Result1,Result2,MibsHS)
     
    	Result1 = False
    	Result2 = False
    	MibsHS = False
    	Ftype = ""
    	Dim objConsole
    	Dim objFSO, objLog
    	set objConsole = new CliWrapper
    	Const ForWriting = 2
    	Const TristateFalse = 0
    	Const CreateIfNecessary = True
     
    	Set objFSO = CreateObject("Scripting.FileSystemObject")
     
    	Actions.InnerHTML = "<div id=infoframe>Dumping " & DHCPServer & " configuration in progress, please wait (~1 min 30) ...</div>"
    	strConsoleOut= objConsole.exec(Command)	
    	AllLigne = strConsoleOut
     
    	'Debug
    	'msgbox AllLigne
     
    	If Instr(File,"mibs") > 0 Then
    		Ftype = "mibs"
    	End If
     
    	If Instr(File,"dump") > 0 Then
    		Ftype = "dump"
    	End If
     
    	Select Case Ftype
    		Case "mibs"
     
    		If InStr(AllLigne,"Le serveur ne fonctionne ") > 0 Then
    				Actions.InnerHTML = "<div id=warningframe>Unable to connect to this server or Netsh component is unavailable. </br> </br> Have you registered netsh component with this command : cmd /c NETSH ADD HELPER DHCPMON.DLL ?</div>"
    				MibsHS = True
    				Exit Function
    			End If
     
    			If InStr(AllLigne,"La commande suivante n'a pas ") > 0 Then
    				Actions.InnerHTML = "<div id=warningframe>Unable to connect to this server or Netsh component is unavailable. </br> </br> Have you registered netsh component with this command : cmd /c NETSH ADD HELPER DHCPMON.DLL ?</div>"
    				MibsHS = True
    				Exit Function
    			End If
     
    			If InStr(AllLigne,"chec de la commande") > 0 Then
    				Actions.InnerHTML = "<div id=warningframe>Access denied. </br> </br> Please execute the script with an authorized account.</div>"
    				MibsHS = True
    				Exit Function
    			End If	
     
    			Result2 = True
    			Set objLog = objFSO.OpenTextFile(File, ForWriting, CreateIfNecessary, TristateFalse)
    			objLog.writeline AllLigne		
     
     
    		Case "dump"
     
    			If Not InStr(AllLigne,"add scope ") > 0 Then
    				Actions.InnerHTML = "<div id=warningframe>Access denied. </br> </br> Please execute the script with an authorized account.</div>"
    				Exit Function
    			End If
     
    			Result1 = True
    			Set objLog = objFSO.OpenTextFile(File, ForWriting, CreateIfNecessary, TristateFalse)
    			objLog.writeline AllLigne			
     
    	End Select
     
    End Function
    '********************************************************************************
     
    '********************************************************************************
    ' LAUCH DUMP PROCESS
    '********************************************************************************
    Function LaunchProcess(DHCPServer,RFile,Lfile)
     
    	On Error Resume Next
    	Set objWMIService = GetObject("winmgmts:"& "{impersonationLevel=impersonate}!\\" & DHCPServer & "\root\cimv2")
     
    	Select Case Err.Number
    	  Case 0
    		Const FEN = 0
     
    		Actions.InnerHTML = "<div id=infoframe>Dumping " & DHCPServer & " configuration in progress, please wait (~1 min 30) ...</div>"			
    		strCommand = "cmd /c netsh dhcp server " & DHCPServer & " dump > " & RFile 
     
    		Set objStartup = objWMIService.Get("Win32_ProcessStartup")
    		Set objConfig = objStartup.SpawnInstance_
    		objConfig.ShowWindow = FEN
     
    		Set objProcess = objWMIService.Get("Win32_Process")
    		intReturn = objProcess.Create(strCommand, Null, objConfig, intProcessID)
    		'wscript.echo intReturn
    		'wscript.echo intProcessID
     
    		ProcessRunning = TRUE
    		Do Until Not ProcessRunning
    			'Set colProcessList = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = 'netsh.exe'")
    			Set colProcessList = objWMIService.ExecQuery ("Select * from Win32_Process Where ProcessId = '" & intProcessID & "'")
    			If colProcessList.Count = 0 then
    				ProcessRunning = False	
    			End If
    		Loop
     
    		If intReturn = 0 and  ProcessRunning = False Then
    			Set objShell = CreateObject("WScript.Shell")	
    			strPath = objShell.ExpandEnvironmentStrings("%SystemDrive%")
    			RFile = Replace(RFile,":","$")
    			strPath = Replace(strPath,":","$")
    			strPath = "\\" & DHCPServer & "\" & strPath
     
    			'Net use Windows
    			strCommandMap = "cmd /c net use " & strPath 
    			ReturnCodeMap = objShell.Run(strCommandMap, 0, True)
     
    			'Copy
    			RFile = Replace(RFile,"C$\","")
    			strCommandCopy = "cmd /c copy " & strPath & "\" & RFile & " " & LFile & " /Y"
    			ReturnCodeCopy = objShell.Run(strCommandCopy, 0, True)
     
    			'Net use Windows
    			strCommandUNMap = "cmd /c net use " & strPath & " /d /Y"
    			ReturnCodeUNMap = objShell.Run(strCommandUNMap, 0, True)
    		End IF
     
    	  Case 70
    		' Run-time error '70': Permission denied
    		Actions.InnerHTML = "<div id=warningframe>Access denied. </br> </br> Please execute the script with an authorized account.</div>"
    	  Case 462
    		' The remote server machine does not exist or is unavailable
    		Actions.InnerHTML = "<div id=warningframe>Access denied. </br> </br> Please execute the script with an authorized account.</div>"
    	  Case -2147217375
    		' Unknown/undocumented runtime error (till this time)
    		Actions.InnerHTML = "<div id=warningframe>Access denied. </br> </br> Please execute the script with an authorized account.</div>"
    	  Case Else
    		' Unhandled Run-time error (till this time)
    		Actions.InnerHTML = "<div id=warningframe>Access denied. </br> </br> Please execute the script with an authorized account.</div>"
    	End Select
    	Err.Clear
    	On Error GoTo 0
     
     
    End Function
    '********************************************************************************
     
    '********************************************************************************
    ' Déclaration de la classe CliWrapper, qui permet d'exécuter une commande externe sans pop up
    '********************************************************************************
    Class CliWrapper
     
    	public stdout, stderr, command
    	private sh, fso, syncmode, outfile, errfile
    	private ForReading, TristateUseDefault, DoNotCreateFile
     
    	public function Exec(sCmd)
    		' clean out old stdout and stderr
    		stdout = vbNullString: stderr = vbNullString
    		command = sh.ExpandEnvironmentStrings(sCmd)
    		sh.Run "%COMSPEC% /c " & sCmd & " 2>" & errfile _
    		& " 1>" & outfile, 0, syncmode
    		stderr = ProcessFile(errfile)
    		stdout = ProcessFile(outfile)
    		Exec = stdout
    	end function
     
    	private sub class_initialize
    		' for speed of use over time
    		Set sh = createobject("WScript.Shell")
    		Set fso = createobject("Scripting.FileSystemObject")
    		ForReading = 1: TristateUseDefault = -2
    		DoNotCreateFile = false
    		outfile = sh.ExpandEnvironmentStrings("%temp%") & "\" & fso.GetTempName
    		errfile = sh.ExpandEnvironmentStrings("%temp%") & "\" & fso.GetTempName
    		syncmode = true
    	end sub
     
    	private function ProcessFile(filepath)
    	  ' given the path to a file, will return entire contents
    	  if fso.FileExists(filepath) then
    		with fso.OpenTextFile(filepath, ForReading, _
    		false, TristateUseDefault)
    		if .AtEndOfStream <> true then
    			ProcessFile = .ReadAll
    		end if
    		.Close
    		fso.DeleteFile(filepath)
    	   end with
    	  else
    		'msgbox "Erreur avec les fichiers temporaires...",vbExclamation,"Erreur !"
    	  end if 
    	end function
     
    end class
    '********************************************************************************
     
    '********************************************************************************
    ' TRAITEMENT SCOPES
    '********************************************************************************
    Sub Traitement_Scopes(DHCP_Dump_File,DHCP_Mibs_File)
     
    	StartTime = Timer()
    	strFilter = FilterSelection.Filter.Value
    	strDHCPServer = FilterSelection.ServerName.Value
     
    	Const ForReading = 1
    	Const ForWriting = 2
    	Const ModeAscii = 0
     
    	Dim objFSO, objFile
    	Set objFSO = CreateObject("Scripting.FileSystemObject")
     
    	' Dictionaries
    	Set DicoAddValidScope = CreateObject("Scripting.Dictionary")
    	Set DicoAddScopeStatus = CreateObject("Scripting.Dictionary")
    	Set DicoAddScopeLease = CreateObject("Scripting.Dictionary")
    	Set DicoAddMibs = CreateObject("Scripting.Dictionary")
    	Set DicoAddExcludeRange = CreateObject("Scripting.Dictionary")
     
    	DicoAddValidScope.CompareMode = vbTextCompare
    	DicoAddScopeStatus.CompareMode = vbTextCompare
    	DicoAddScopeLease.CompareMode = vbTextCompare
    	DicoAddMibs.CompareMode = vbTextCompare
    	DicoAddExcludeRange.CompareMode = vbTextCompare
     
    	'Read File 1
    	AllLigne = ""
    	Ligne = ""
     
    	Set Fichier_Parcourir1 = objFSO.OpenTextFile(DHCP_Dump_File,ForReading)
    	Do While Fichier_Parcourir1.AtEndOfStream <> True  
    		AllLigne = Fichier_Parcourir1.ReadAll
     
    		'Debug
    		'Actions.InnerHTML = AllLigne
     
    		Tableau = Split(AllLigne,vbnewline)
    		For i = lbound(Tableau) to ubound(Tableau)
    			Ligne = Tableau(i)
     
    			' Find Scope and and to dico
    			If InStr(Ligne,"add scope ") > 0 Then
    				Call GetScopeInfos(Ligne,mScope,SMask,SName,Sdesc)
    				Infos = mScope & "#" & SMask & "#" & SName & "#" & Sdesc
    				If Not DicoAddValidScope.Exists(mScope) Then
    					DicoAddValidScope.add mScope, Infos
    				End If
    			End If
     
    			' Find Scope State  and and to dico
    			If InStr(Ligne,"set state ") > 0 Then
    				Call GetScopeState(Ligne,mScope,State)
    				If Not DicoAddScopeStatus.Exists(mScope) Then
    					DicoAddScopeStatus.add mScope, State
    				End If
    			End If
     
    			' Find Lease and and to dico
    			If InStr(Ligne,"optionvalue 51 DWORD ") > 0 Then
    				Call GetScopeLease(Ligne,mScope,gLease)
    				If Not DicoAddScopeLease.Exists(mScope) Then
    					DicoAddScopeLease.add mScope, gLease
    				End If
    			End If
     
    			' Find Exclude Scope
    			If InStr(Ligne,"excluderange ") > 0 Then
    				Call GetExcludeRange(Ligne,mScope,StartIP,EndIP)
    				ExCludeRange = "S:" & StartIP & "E:" & EndIP	
    				If Not DicoAddExcludeRange.Exists(mScope) Then
    					DicoAddExcludeRange.add mScope, ExCludeRange
    				Else
    					ExistValue = DicoAddExcludeRange.item(mScope)
    					If Not Instr(ExistValue,ExCludeRange ) > 0  Then
    						DicoAddExcludeRange.remove(mScope)
    						DicoAddExcludeRange.add mScope, ExistValue & "," & ExCludeRange
    					End If
    				End If
    			End If
    		Next	
    	Loop
    	'------
     
    	'Read File 2
    	AllLigne = ""
    	Ligne = ""
    	Set Fichier_Parcourir2 = objFSO.OpenTextFile(DHCP_Mibs_File,ForReading)
    	Do While Fichier_Parcourir2.AtEndOfStream <> True  
    		AllLigne = Fichier_Parcourir2.ReadAll
     
    		'Debug
    		'Actions.InnerHTML = AllLigne
     
    		If InStr(AllLigne, "Nombre de MIBÿ:") > 0 Then 
    			Language = "FR"
    			Lang.InnerHtml = "Language : " & Language
    			Search_Mibs = "Nombre de MIBÿ:"
    			Search_Scope = "Sous"
    			lenght = 15
    		ElseIf InStr(AllLigne, "MIBCounts:") > 0 Then 
    			Language = "EN"
    			Lang.InnerHtml = "Language : " & Language
    			Search_Mibs = "MIBCounts:"
    			Search_Scope = "Subnet = "
    			lenght = 10
    		End If
     
     
    		If InStr(AllLigne, Search_Mibs) > 0 Then
    			Tableau = Split(AllLigne,vbCrLf)
    			For i = 0 To UBound(Tableau)
    				Ligne = Tableau(i)
    				If Instr(Ligne, Search_Scope) > 0 Then
    					On error resume next
    					'Determine Scope name
    					tScope = Right(Tableau(i), Len(Tableau(i)) - lenght)
    					tScope = Left(tScope, Len(tScope) - 1)
    					'Determine number of addresses in use
    					UsedArray = Split(Tableau(i + 1), "=")
    					tUsed = CLng(Left(UsedArray(1), Len(UsedArray(1)) - 1))
    					'Determine number of addresses free
    					FreeArray = Split(Tableau(i + 2), "=")
    					tFree = CLng(Left(FreeArray(1), Len(FreeArray(1)) - 1))
    					'Determine percentage of addresses free
    					tSumTotal = CLng(tFree + tUsed)
    					If tSumTotal = 0 Then 
    						'Cannot divide by zero
    					Else
    						tPercentFree = (tFree / tSumTotal) * 100
    						tPercentFree = FormatNumber(tPercentFree, 0)
    						tPercentUsed = (tUsed / tSumTotal) * 100
    						tPercentUsed = FormatNumber(tPercentUsed, 0)
    						Datas = tUsed & "#" & tFree & "#" & tSumTotal & "#"  & tPercentFree & "#"  & tPercentUsed
    					End If
    					DicoAddMibs.add tScope, Datas
    					On error goto 0	
    					End If	
    			Next	
    		End If
    	Loop		
    	'------
     
    	'msgbox DicoAddValidScope.count
    	'msgbox DicoAddScopeStatus.count
    	'msgbox DicoAddScopeLease.count
    	'msgbox DicoAddExcludeRange.count
     
    	'----------------------------------------------------------
    	' Table Header
    	strScopeListHeader = "<table class = 'sortable' id='sortabletable'>" _
    	& "<caption>Scopes Informations</caption>" _
    	& "<tr>" _
    	& "<th>Count</th>" _
    	& "<th>Infos</th>" _
    	& "<th>Scope</th>" _
    	& "<th>Name</th>" _
    	& "<th>Lease</th>" _
    	& "<th>% Usage</th>" _
    	& "</tr>" 
    	'----------------------------------------------------------
     
    	'----------------------------------------------------------
    	' Legend	
    	ScopeListLegend = "<table>" _
    	& "<caption>Legend</caption>" _
    	& "<tr>" _
    	& "<td>" _
    	& "Disabled Scope : <span class='legend' style='background-color:#C0C0C0'></span>" _
    	& "&nbsp; Usage >= 80 % : <span class='legend' style='background-color:#FF0000'></span>" _
    	& "&nbsp; Usage >= 50 % : <span class='legend' style='background-color:#FF9933'></span>" _
    	& "&nbsp; Usage < 50 % : <span class='legend' style='background-color:#82CAFA'></span>" _
    	& "</td>" _
    	& "</tr>" _
    	& "</table></br>"
    	'---------------------------------------------------------
     
    	'----------------------------------------------------------
    	' Export Header
    	strToExportScopesBodyHeader = "Count" & ";" _
    	& "Scope" & ";" _
    	& "Mask" & ";" _
    	& "Name" & ";" _
    	& "Description" & ";" _
    	& "CIDR" & ";" _
    	& "BROADCAST" & ";" _
    	& "Total Host" & ";" _
    	& "IP Range" & ";" _
    	& "Status" & ";" _
    	& "Lease" & ";" _
    	& "Used IP" & ";" _
    	& "Free IP" & ";" _
    	& "Total" & ";" _
    	& "% Free" & ";" _
    	& "%Used" & ";" _
    	& "Excluded Range" & ";" _
    	& vbNewLine
    	'----------------------------------------------------------
     
    	CptScope = 0
    	IndexKeys = DicoAddValidScope.Keys
     
    	Dim strTableBody()
    	Redim strTableBody(DicoAddValidScope.count)
     
    	For key=0 To ubound(IndexKeys)
    		DicoAddValidScopeValue = DicoAddValidScope.item(IndexKeys(key))
    		DicoAddScopeStatusValue = DicoAddScopeStatus.item(IndexKeys(key))
    		DicoAddScopeLeaseValue = DicoAddScopeLease.item(IndexKeys(key))
    		DicoAddMibsValue = DicoAddMibs.item(IndexKeys(key))
    		DicoAddExcludeRangeValue = DicoAddExcludeRange.item(IndexKeys(key))	
    		Call Filter_Exist(DicoAddValidScopeValue,strFilter,Exist)
     
    		If Exist = True Then
    			CptScope = CptScope + 1
    			If Len(DicoAddValidScopeValue) > 0 Then 
    				Tab1 = Split(DicoAddValidScopeValue,"#")
    				tScope = Tab1(0)
    				tMask = Tab1(1)
    				tName = Tab1(2)
    				tDesc = Tab1(3)
    			Else
    				Exit Sub
    			End If
     
    			tCIDR = MaskLength(tMask)
    			tBROADCAST = CalcBroadcastAddress(tScope,tMask)				
    			tTOTAL_HOST = GetNumberOfAvailableHostAddresses(tCIDR)
    			tIP_RANGE = Range(tScope,tBROADCAST)
     
    			tExclude = "-"
    			tStatus = "-"
    			tLease = "-"
    			tMibs = "-"
     
    			If DicoAddExcludeRange.Exists(IndexKeys(key)) Then
    				tExclude = DicoAddExcludeRangeValue
    			End If
     
    			If DicoAddScopeStatus.Exists(IndexKeys(key)) Then
    				tStatus = DicoAddScopeStatusValue
    				HorizontalBar = ""
     
    				Select Case tStatus
    					Case 0 
    					Color = "#C0C0C0" 'Grey
    					'tUsed = ""
    					'tFree = ""
    					'tSumTotal = ""
    					'tPercentFree = ""
    					'tPercentUsed = ""
    					tStatus = "Disabled"
     
    					If Len(DicoAddMibsValue) > 0 Then 
    						Tab2 = Split(DicoAddMibsValue,"#")
    						tUsed = Tab2(0)
    						tFree = Tab2(1)
    						tSumTotal = Tab2(2)
    						tPercentFree = Tab2(3) 
    						tPercentUsed = Tab2(4) & " %"
    					End If
     
    					HorizontalBar =  "<div class=" & Chr(34) & "graph" & Chr(34) & "><div class=" & Chr(34) & "bar"  & Chr(34) & "style=" & Chr(34) & "background-color:"& color & "; width:" & tPercentUsed & chr(34) & ">" & tPercentUsed &"</div></div>"
     
    					Case 1 
    					If Len(DicoAddMibsValue) > 0 Then 
    						Tab2 = Split(DicoAddMibsValue,"#")
    						tUsed = Tab2(0)
    						tFree = Tab2(1)
    						tSumTotal = Tab2(2)
    						tPercentFree = Tab2(3) 
    						tPercentUsed = Tab2(4)
    					End If
    						tStatus = "Enabled"
     
    						If tPercentUsed >= 80 Then
    							Color = "#FF0000" 'Red
    							tPercentUsed = tPercentUsed & " %"
    						ElseIf tPercentUsed >= 50 Then						
    							color = "#FF9933" 'Orange
    							tPercentUsed = tPercentUsed & " %"
    						Else
    							Color = "#82CAFA" 'Blue
    							tPercentUsed = tPercentUsed & " %"
    						End If
     
    						HorizontalBar =  "<div class=" & Chr(34) & "graph" & Chr(34) & "><div class=" & Chr(34) & "bar"  & Chr(34) & "style=" & Chr(34) & "background-color:"& color & "; width:" & tPercentUsed & chr(34) & ">" & tPercentUsed &"</div></div>"
     
    				End Select
     
    			End If
     
    			If DicoAddScopeLease.Exists(IndexKeys(key)) Then
    				tLease = DicoAddScopeLeaseValue
    			End If	
     
    			If DicoAddMibs.Exists(IndexKeys(key)) Then
    				tMibs = DicoAddMibsValue
    			End If
     
    			'& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">" & tDesc & "</td>" _ 
    			'& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">" & tPercentUsed & "</td>" _
    			'& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">" & tMask & "</td>" _			
    			'& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">" & tBROADCAST & "</td>" _
    			'& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">" & tIP_RANGE & "</td>" _	
    			'& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">" & tStatus & "</td>" _
    			'& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">" & tPercentFree & "</td>" _
    			'& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">" & tExclude & "</td>" _
    			'& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">" & tUsed & "</td>" _
    			'& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">" & tSumTotal & "</td>" _
    			'& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">" & tTOTAL_HOST & "</td>" _
    			'& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">/" & tCIDR & "</td>" _
    			'& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">" & tFree & "</td>" _
    			'& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">" & tTOTAL_HOST & "</td>" _
     
    			' Table Body	
    			aHTML = "<tr><Form method='POST'>" _
    			& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">" & CptScope & "</td>" _
    			& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & "><input type='button' Value='Infos' onclick='Call Scope_Infos(tscope.value,tmask.value,tname.value,tdesc.value,tstatus.value,tlease.value,tcidr.value,tbroadcast.value,ttotal_host.value,tip_range.value,tused.value,tfree.value,tsumtotal.value,tpercentfree.value,tpercentused.value,texclude.value)' class='more'></td>" _
    			& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">" & tScope & "</td>" _
    			& "<input type='hidden'  name='tscope'  value='" & tScope & "'>" _
    			& "<input type='hidden'  name='tmask'  value='" & tMask & "'>" _
    			& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">" & tName & "</td>" _
    			& "<input type='hidden'  name='tname'  value='" & tName & "'>" _
    			& "<input type='hidden'  name='tdesc'  value='" & tDesc & "'>" _ 
    			& "<input type='hidden'  name='tcidr'  value='" & tCIDR & "'>" _
    			& "<input type='hidden'  name='tbroadcast'  value='" & tBROADCAST & "'>" _
    			& "<input type='hidden'  name='ttotal_host'  value='" & tTOTAL_HOST & "'>" _
    			& "<input type='hidden'  name='tip_range'  value='" & tIP_RANGE & "'>" _
    			& "<input type='hidden'  name='tstatus'  value='" & tStatus & "'>" _
    			& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">" & tLease & "</td>"	 _
    			& "<input type='hidden'  name='tlease'  value='" & tLease & "'>" _
    			& "<input type='hidden'  name='tused'  value='" & tUsed & "'>" _
    			& "<input type='hidden'  name='tfree'  value='" & tFree & "'>" _
    			& "<input type='hidden'  name='tsumtotal'  value='" & tSumTotal & "'>" _
    			& "<input type='hidden'  name='tpercentfree'  value='" & tPercentFree & "'>" _
    			& "<td style=" & chr(34) & "background-color:" & Color & "" & chr(34) & ">" & HorizontalBar & "</td>" _
    			& "<input type='hidden'  name='tpercentused'  value='" & tPercentUsed & "'>" _
    			& "<input type='hidden'  name='texclude'  value='" & tExclude & "'>" _
    			& "</tr></Form>"
     
    			strTableBody(key) =  aHTML	
     
    			strToExportScopesBody = strToExportScopesBody _
    			& CptScope & ";" _
    			& tScope & ";" _
    			& tMask & ";" _
    			& tName & ";" _
    			& tDesc & ";" _
    			& tCIDR & ";" _
    			& tBROADCAST & ";" _
    			& tTOTAL_HOST & ";" _
    			& tIP_RANGE & ";" _
    			& tStatus & ";" _
    			& tLease & ";" _
    			& tUsed & ";" _
    			& tFree & ";" _
    			& tSumTotal & ";" _
    			& tPercentFree & ";" _
    			& tPercentUsed & ";" _
    			& tExclude & ";" _
    			& vbNewLine
     
    			strToExportScopesBody = Replace(strToExportScopesBody,"'","")			
     
    		End If
     
    	Next
     
    	Dim To_Export
    	Dim Scopes_CSVFile
     
    	To_Export =  strToExportScopesBodyHeader & strToExportScopesBody
    	Scopes_CSVFile = Replace(strFilter," ","_") & "_" & Replace(strDHCPServer,".",".") & "_scopes.csv"
     
    	ExportButton = "<input type='hidden'  name='Scopes_CSVFile'  value='" & Scopes_CSVFile & "'>" _
    	& "<input type='hidden'  name='To_Export'  value='" & To_Export & "'>" _
    	& "<input type='button' value='Export to CSV' onclick='Call ExportToCSV(Scopes_CSVFile.value,To_Export.value)'></br></br>"
     
     
    	strHTML = caca & ScopeListLegend & ExportButton  & strScopeListHeader & Join(strTableBody,"") & "</table>"	
     
    	' Result
    	If CptScope >= 1 Then
    		Actions.InnerHTML = "<div id=infoframe>Result with filter : <b>" & strFilter & "</b></br>Execution Time : <b>" & FormatNumber(Timer() - StartTime, 2) & " seconds </b></div>"
    		ScopesList.InnerHTML = strHTML
    		FilterSelection.Filter.Focus
    		Exit Sub
    	Else
    		If Len(strFilter) > 0 Then
    			Actions.InnerHTML = "<div id=warningframe>" & strFilter & " Not Found !</div>"
    		Else
    			Actions.InnerHTML = "<div id=warningframe>No data !</div>"
    		End If
    		FilterSelection.Filter.Focus
    		Exit Sub
    	End If	
     
    End Sub
    '********************************************************************************
     
    '********************************************************************************
    ' GET SCOPE INFOS
    '********************************************************************************
    Function GetScopeInfos(FstrScopeLine,FScope,FMask,FName,FDesc)
    	If len(FstrScopeLine) > 0 Then
    		Tab1 = Split(FstrScopeLine," ")
    		FScope = Tab1(5)
    		FMask = Tab1(6)
    		Tab1 = Split(FstrScopeLine,"""")
    		FName = Tab1(1)
    		FDesc = Tab1(3)
    	Else
    		Exit Function
    	End If
    End Function 
    '********************************************************************************
     
    '********************************************************************************
    ' GET SCOPE STATE
    '********************************************************************************
    Function GetScopeState(strScopeLine,Scope,State)
    	If len(strScopeLine) > 0 Then
    		Tab1 = Split(strScopeLine," ")
    		Scope = Tab1(4)
    		State = Tab1(7)
    	Else
    		Exit Function
    	End If
    End Function 
    '********************************************************************************
     
    '********************************************************************************
    ' GET SCOPE LEASE
    '********************************************************************************
    Function GetScopeLease(strScopeLine,Scope,gLease)
    	If len(strScopeLine) > 0 Then
    		on error resume next 'a regarder
    		Tab1 = Split(strScopeLine," ")
    		Scope = Tab1(4)
    		gLease = Tab1(9)
    		gLease = Replace(gLease,"""","")	
     
    		If Len(gLease) > 0 Then
    			If gLease <= 0 Then
    				gLease = "NO LEASE"
    				Exit Function
    			Else
    				LEASE_H = FormatNumber((gLease/3600),1)
    				LEASE_D = (LEASE_H/24)
    				If LEASE_D <= 0 Then
    					LEASE_D = 0
    				Else
    					LEASE_D = FormatNumber((LEASE_H/24),0)
    				End If
    				gLease = LEASE_H & " (H) " & LEASE_D  & " (D) "
    			End If
    		End If
    		On error goto 0
    	Else
    		Exit Function
    	End If
    End Function 
    '********************************************************************************
     
    '********************************************************************************
    ' GET EXCLUDE RANGE
    '********************************************************************************
    Function GetExcludeRange(strScopeLine,Scope,StartIP,EndIP)
    	If len(strScopeLine) > 0 Then
    		Tab1 = Split(strScopeLine," ")
    		Scope = Tab1(4)
    		StartIP = Tab1(7)
    		EndIP = Tab1(8)
    		'ExCludeRange = "S:" & StartIP & "E:" & EndIP
    	Else
    		Exit Function
    	End If		
     
    End Function 
    '********************************************************************************
     
    '********************************************************************************
    ' GET FILTER 
    '********************************************************************************
    Function Filter_Exist(strToFind,strFilter,Exist)
     
    	Exist = False
     
    	Set RegExFilter = New RegExp
     
    	With RegExFilter
    		.Pattern    = strFilter
    		.IgnoreCase = True
    		.Global     = False
    	End With
     
    	Set ResultRegExFilter = RegExFilter.Execute(strToFind)
    	If ResultRegExFilter.count > 0 Then
    		Exist = True
    		Exit Function
    	End If
     
    End Function
    '********************************************************************************
     
    '********************************************************************************
    'EXPORT TO CSV
    '********************************************************************************
    Function ExportToCSV(strFile,strData)
     
    	If len(strData) > 0 Then
    		 Const ForWriting = 2
    		 Const TristateFalse = 0
    		 Const CreateIfNecessary = True
     
    		 Dim objFSO, objTextFile 
    		 Set objFSO = CreateObject("Scripting.FileSystemObject")
     
    		curDir = objFSO.GetAbsolutePathName(".")
     
    		 Set objTextFile  = objFSO.OpenTextFile(strFile, ForWriting, CreateIfNecessary, TristateFalse)
    		 objTextFile.Write (strData)
    		 If err.number <> 0 Then
    			Actions.InnerHTML = "<div id=warningframe>Error ...</div>"
    			Exit Function
    		Else
    			Actions.InnerHTML = "<div id=okframe>File successfully saved in : " & curDir & "\" & strFile & "</div>"
    		End If
    	Else
    		Exit Function
    	End If	
     
    End Function
    '********************************************************************************
     
     
    '==========================================================================
    ' Fonction Convertir Mask en CIDR
    '--------------------------------------------------------------------------
    Function MaskLength(MASK_SCOPE) 
    	Dim arrOctets : arrOctets = Split(MASK_SCOPE, ".") 
    	Dim i 
    	For i = 0 to UBound(arrOctets) 
    		Dim intOctet : intOctet = CInt(arrOctets(i)) 
    		Dim j, intMaskLength 
    		For j = 0 To 7 
    			If intOctet And (2^(7 -j)) Then
    				intMaskLength = intMaskLength + 1 
    			End If
    		Next
    	Next
    	MaskLength = intMaskLength 
    End Function	 
    '==========================================================================
     
    '==========================================================================
    ' Fonction Calcul Adresse Broadcast
    '--------------------------------------------------------------------------
    Function CalcBroadcastAddress(SCOPE,MASK_SCOPE) 
    	Dim strBinIP : strBinIP = ConvertIPToBinary(SCOPE) 
    	Dim strBinMask : strBinMask = ConvertIPToBinary(MASK_SCOPE) 
    	' Set each unmasked bit to 1 
    	Dim i, strBinBroadcast 
    	For i = 1 to Len(strBinIP) 
    		Dim strIPBit : strIPBit = Mid(strBinIP, i, 1) 
    		Dim strMaskBit : strMaskBit = Mid(strBinMask, i, 1) 
    		If strIPBit = "1" Or strMaskBit = "0" Then
    			strBinBroadcast = strBinBroadcast & "1"
    		ElseIf strIPBit = "." Then
    			strBinBroadcast = strBinBroadcast & strIPBit 
    		Else
    			strBinBroadcast = strBinBroadcast & "0"
    		End If
    	Next
    	CalcBroadcastAddress = ConvertBinIPToDecimal(strBinBroadcast) 
    End Function	 
    '==========================================================================
     
    '==========================================================================
    ' Fonction Convertir IP en Binaire
    '--------------------------------------------------------------------------
    Function ConvertIPToBinary(SCOPE) 
    	Dim arrOctets : arrOctets = Split(SCOPE, ".") 
    	Dim i 
    	For i = 0 to UBound(arrOctets) 
    		Dim intOctet : intOctet = CInt(arrOctets(i)) 
    		Dim strBinOctet : strBinOctet = ""
    		Dim j 
    		For j = 0 To 7 
    			If intOctet And (2^(7 - j)) Then
    				strBinOctet = strBinOctet & "1"
    			Else
    				strBinOctet = strBinOctet & "0"
    			End If
    		Next
    		arrOctets(i) = strBinOctet 
    	Next
    	ConvertIPToBinary = Join(arrOctets, ".") 
    End Function	 
    '==========================================================================
     
    '==========================================================================
    ' Fonction Convertir Binaire en Decimal
    '--------------------------------------------------------------------------
    Function ConvertBinIPToDecimal(strBinIP) 
    	Dim arrOctets : arrOctets = Split(strBinIP, ".") 
    	Dim i 
    	For i = 0 to UBound(arrOctets) 
    		Dim intOctet : intOctet = 0 
    		Dim j 
    		For j = 0 to 7 
    			Dim intBit : intBit = CInt(Mid(arrOctets(i), j + 1, 1)) 
    			If intBit = 1 Then
    				intOctet = intOctet + 2^(7 - j) 
    			End If
    		Next
    		arrOctets(i) = CStr(intOctet) 
    	Next
    	ConvertBinIPToDecimal = Join(arrOctets, ".") 
    End Function	 
    '==========================================================================
     
    '==========================================================================
    ' Fonction Calcul Total hotes pour un réseau
    '--------------------------------------------------------------------------
    Function GetNumberOfAvailableHostAddresses(CIDR) 
    	Dim nHosts, nAvailableBits 
    	nHosts = -1 
    	nAvailableBits = 32 - CIDR
    	'wscript.echo nAvailableBits 
    	'Number of Addresses Available for Hosts in Subnet = 2(32 - Number of Masked Bits) - 2 
    	nHosts = (2 ^ nAvailableBits) - 2 
    	GetNumberOfAvailableHostAddresses = nHosts 
    End Function
    '==========================================================================
     
    '==========================================================================
    ' Fonction Get IP Range 
    '--------------------------------------------------------------------------
    Function Range(FScope,FBROADCAST)
    	If Len(FScope) > 0 Then
    		IP_START = Split(FScope, ".")
    		IP_START_RES = IP_START(0) & "." & IP_START(1) & "." & IP_START(2) & "." & IP_START(3)+1
    		IP_END = Split(FBROADCAST, ".")
    		IP_END_RES = IP_END(0) & "." & IP_END(1) & "." & IP_END(2) & "." & IP_END(3)-1
    		Range = (IP_START_RES & " - " & IP_END_RES)	
    	End If
    End Function
    '==========================================================================
     
     
    </script>
     
     
    </head>
     
    <body>
     
    <div id="title"><h1>DHCP Manager V1.0</h1></div>
     
    <p>
    	<span>
    		<form name="FilterSelection" id="FilterSelection">
    			<table>
    				<caption>Select DHCP Server to manage</caption>
    				<tr>
    					<td>DHCP Server  (Ip Address) : </td>
    					<td><input name="ServerName" value="10.232.69.58"></td>
    				</tr>
     
    				<tr>
    					<td>Scope Filter (Blank = No Filter) : </td>
    					<td><input name="Filter" value=""></td>
    				</tr>
     
    			</table>
    		</form>
    	</span>	
    </p>
     
    <p>
    <!--<input type="submit" Value="View Scopes" onClick="View_Scopes()" class="button">-->
    <input type="button" Id="MonBouton" onClick="ToggleButton()">
    </p>
     
    <span id = "Actions"></span>
     
    <p>
    <span id = "ScopesList"></span>
    </p>
     
    <h4>Copyright Distributed Windows 2013</br> 
    <span id = "UserName"></span></br> 
    <span id = "Lang"></span>
    </h4>
    </body>
    </html>

  16. #16
    Membre habitué
    Homme Profil pro
    Ingénieur systèmes et réseaux
    Inscrit en
    Juillet 2012
    Messages
    284
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur systèmes et réseaux
    Secteur : Finance

    Informations forums :
    Inscription : Juillet 2012
    Messages : 284
    Points : 132
    Points
    132
    Par défaut
    Humm, merci encore pour votre aide sur le sujet

    Lorsque je lance la hta au chargement j'ai une erreur (cf image en PJ), mais je ne peux pas l'ignorer.

    Pourtant j'ai bien repris le code fourni, ainsi que le sort_table.js.

    Une idée ?

    Merci.
    Images attachées Images attachées  

  17. #17
    Expert éminent
    Avatar de hackoofr
    Homme Profil pro
    Enseignant
    Inscrit en
    Juin 2009
    Messages
    3 840
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Juin 2009
    Messages : 3 840
    Points : 9 225
    Points
    9 225
    Par défaut

    c'est l'erreur qui me casse la tête moi aussi celle-là que je viens de vous signaler, je ne sais pas pour le moment, comment la "déboguer" ou bien l'éviter j'espère, qu'un autre intervenant expert en Javascript nous apporte un petit coup de pousse

  18. #18
    Membre habitué
    Homme Profil pro
    Ingénieur systèmes et réseaux
    Inscrit en
    Juillet 2012
    Messages
    284
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur systèmes et réseaux
    Secteur : Finance

    Informations forums :
    Inscription : Juillet 2012
    Messages : 284
    Points : 132
    Points
    132
    Par défaut
    ha ok

    Merci, je vais chercher un peu de mon coté aussi

  19. #19
    Expert éminent
    Avatar de hackoofr
    Homme Profil pro
    Enseignant
    Inscrit en
    Juin 2009
    Messages
    3 840
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Juin 2009
    Messages : 3 840
    Points : 9 225
    Points
    9 225
    Par défaut

    Alors vous êtes ou dans votre projet ?
    Vous pouvez jeter un coup d’œil ici Rendre les tables HTML triables

Discussions similaires

  1. Injecter une page asp dans une autre avec javascript
    Par hwoarang dans le forum ASP.NET
    Réponses: 3
    Dernier message: 14/02/2011, 14h01
  2. Réponses: 2
    Dernier message: 21/10/2010, 17h23
  3. marge inutile autours d'un tableau dans une cellule avec IE
    Par pythéas dans le forum Balisage (X)HTML et validation W3C
    Réponses: 4
    Dernier message: 19/12/2008, 11h55
  4. Réponses: 3
    Dernier message: 20/09/2006, 16h07
  5. navigation dans une jsp avec javascript
    Par petitelulu dans le forum Général JavaScript
    Réponses: 3
    Dernier message: 15/11/2004, 18h55

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo