Prova questo... ma è da testare.
codice:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled</title> </head> <body> <table summary=""> <tr> <td id="range_count"></td> </tr> </table> <script language="JavaScript" type="text/javascript"> <!-- IP_var1 = 0; IP_var2 = 0; IP_var4 = 0; IP_var3 = 0; IP_Stop1 = 0; IP_Stop2 = 0; IP_Stop4 = 0; IP_Stop3 = 0; ind = 0; function conta_all(str_range){ arr_ip = str_range.split(';'); //------ Primo range ind = 0; conta_single_range(arr_ip[ind]); //------ Conta conta(); } // function conta_all(str_range) function conta_single_range(str_range2){ ar_range = str_range2.split('-'); start_ip = ar_range[0]; stop_ip = ar_range[1]; byt_start = start_ip.split('.'); byt_stop = stop_ip.split('.'); //----------- Parte variabile IP_var1 = byt_start[0]; IP_var2 = byt_start[1]; IP_var3 = byt_start[2]; IP_var4 = byt_start[3]; //----------- Fine del ciclo IP_Stop1 = byt_stop[0]; IP_Stop2 = byt_stop[1]; IP_Stop3 = byt_stop[2]; IP_Stop4 = byt_stop[3]; // ip_str = byt_start[0]+"."+byt_start[1]; } // function conta_single_range(str_range2) function getIP_var() { return IP_var1+'.'+IP_var2+'.'+IP_var3+'.'+IP_var4; } // function getIP_var() function getIP_Stop() { return IP_Stop1+'.'+IP_Stop2+'.'+IP_Stop3+'.'+IP_Stop4; } // function getIP_Stop() function getLongIP_var() { return getSLongIP(IP_var1)+'.'+getSLongIP(IP_var2)+'.'+getSLongIP(IP_var3)+'.'+getSLongIP(IP_var4); } // function getIP_var() function getLongIP_Stop() { return getSLongIP(IP_Stop1)+'.'+getSLongIP(IP_Stop2)+'.'+getSLongIP(IP_Stop3)+'.'+getSLongIP(IP_Stop4); } // function getIP_Stop() function getSLongIP(aValue) { a = new String(); a = aValue.toString(); if (a.length == 1) { ret = "00"+a; return ret; } // if (a.length == 1) if (a.length == 2) { ret = "0"+a; return ret; } // if (a.length == 2) if (a.length == 3) { ret = a; return ret; } // if (a.length == 3) } // function getSLongIP(aValue) function incIP_var() { //----- Incremento 4° IP IP_var4++ ; if (IP_var4 > 255) { IP_var3++; IP_var4 = 0; } // if (IP_var4 > 255) //----- Incremento 3° IP if (IP_var3 > 255) { IP_var2++; IP_var3 = 0; } // if (IP_var3 > 255) //----- Incremento 2° IP if (IP_var2 > 255) { IP_var1++; IP_var2 = 0; } // if (IP_var2 > 255) } // function incIP_var() function conta() { if (getLongIP_var() > getLongIP_Stop()) { if (ind >= arr_ip.length-1) { //------- Se tutti i range sono stati trattati mi fermo return; } else { //------- Passo al range successivo ind++; conta_single_range(arr_ip[ind]); } //if (ind > arr_ip.length-1) } // if (IP_var4 == IP_Stop4) document.getElementById('range_count').innerHTML= "Sfoglia il gruppo" + " "+getIP_var(); incIP_var(); setTimeout("conta()",200); } // function conta() //uso della funzione conta_all("192.168.0.250-192.168.1.20;192.168.3.1-192.168.3.40"); //--> </script> </body> </html>


Rispondi quotando