cacic.js
6.16 KB
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
var ie4 = (document.all) ? true : false;
var ns4 = (document.layers) ? true : false;
var ns6 = (document.getElementById && !document.all) ? true : false;
function SetaClassDigitacao(obj)
{
obj.style.backgroundColor='#CCCCCC';
}
function SetaClassNormal(obj)
{
obj.style.backgroundColor='#FFFFFF';
}
function preparaEnvio()
{// Percorrerei os forms e encontrarei os campos NOME e SENHA para criptografia... (Anderson Peterle - 04/09/2006)
for (i=0;i<window.document.forms.length;i++)
for (j=0;j<window.document.forms[i].elements.length;j++)
if ((window.document.forms[i].elements[j].name == 'frm_nm_usuario_acesso' ||
window.document.forms[i].elements[j].name == 'frm_te_senha') &&
(window.document.forms[i].elements[j].type == 'text' ||
window.document.forms[i].elements[j].type == 'password') &&
window.document.forms[i].elements[j].value != '')
// Codificação dos campos NOME e SENHA para submissão pelo método POST
window.document.forms[i].elements[j].value = encode64(window.document.forms[i].elements[j].value);
}
function SetaCampo(p_campo)
{
for (i=0;i<window.document.forms.length;i++)
for (j=0;j<window.document.forms[i].elements.length;j++)
if (window.document.forms[i].elements[j].name == p_campo) window.document.forms[i].elements[j].focus();
return true;
}
function Ajuda(p_campo_destino,p_frase)
{
var formulario = window.document.forms[0];
formulario[p_campo_destino].value = p_frase;
return true;
}
function Confirma(p_pergunta)
{
if (confirm(p_pergunta))
return true;
return false;
}
function MostraLayer(strLayerName)
{
if (ie4)
document.all[strLayerName].style.visibility = "visible";
else if (ns4)
document.layers[strLayerName].visibility = "show";
else if (ns6)
document.getElementById([strLayerName]).style.display = "block";
}
function EscondeLayer(strLayerName)
{
if (ie4)
document.all[strLayerName].style.visibility = "hidden";
else if (ns4)
document.layers[strLayerName].visibility = "hide";
else if (ns6)
document.getElementById([strLayerName]).style.display = "none";
}
function EscreveNaLayer(strLayerName,strText)
{
if (ie4)
document.all[strLayerName].innerHTML = strText;
else if (ns4)
{
document[strLayerName].document.write(strText);
document[strLayerName].document.close();
}
else if (ns6)
{
over = document.getElementById([strLayerName]);
range = document.createRange();
range.setStartBefore(over);
domfrag = range.createContextualFragment(strText);
while (over.hasChildNodes())
over.removeChild(over.lastChild);
over.appendChild(domfrag);
}
}
function Trim(Dado)
{
var sDado, Result, i, f;
Result = "";
sDado = Dado.toString();
if (sDado.length > 0)
{
for (i=0; i < sDado.length; i++)
if (sDado.charAt(i) != " ")
break;
if (i < sDado.length)
{
for (f=sDado.length-1; f >= 0; f --)
if (sDado.charAt(f) != " ")
break;
Result = sDado.substring(i, f+1);
}
}
return Result;
}
function VerificaRedeMascara(frmForm)
{
var arrIdIpRede = (frmForm.frm_id_ip_rede.value).split('.');
var arrTeMascaraRede = (frmForm.frm_te_mascara_rede.value).split('.');
var intTesteIdIpRede = TestaIP(arrIdIpRede[0],arrIdIpRede[1],arrIdIpRede[2],arrIdIpRede[3]);
if (intTesteIdIpRede > 0)
{
alert("Endereço de Subrede Inválido!");
frmForm.frm_id_ip_rede.select();
frmForm.frm_id_ip_rede.focus();
return false;
}
var intTesteTeMascaraRede = TestaMascara(arrTeMascaraRede[0],arrTeMascaraRede[1],arrTeMascaraRede[2],arrTeMascaraRede[3]);
if (intTesteTeMascaraRede > 0)
{
alert("Máscara de Subrede Inválida!" );
frmForm.frm_te_mascara_rede.select();
frmForm.frm_te_mascara_rede.focus();
return false;
}
// Cálculo do endereço de rede
var strOctetoRede1 = arrIdIpRede[0] & arrTeMascaraRede[0];
var strOctetoRede2 = arrIdIpRede[1] & arrTeMascaraRede[1];
var strOctetoRede3 = arrIdIpRede[2] & arrTeMascaraRede[2];
var strOctetoRede4 = (arrIdIpRede[3] & arrTeMascaraRede[3])+1;
// Cálculo do endereço de broadcast
var strOctetoMascara1 = arrIdIpRede[0] | (arrTeMascaraRede[0] ^ 255);
var strOctetoMascara2 = arrIdIpRede[1] | (arrTeMascaraRede[1] ^ 255);
var strOctetoMascara3 = arrIdIpRede[2] | (arrTeMascaraRede[2] ^ 255);
var strOctetoMascara4 = (arrIdIpRede[3] | (arrTeMascaraRede[3] ^ 255))-1;
if (Confirma('ATENÇÃO:\n\nCom esta máscara, esta subrede atenderá à faixa "'+strOctetoRede1+'.'+strOctetoRede2+'.'+strOctetoRede3+'.'+strOctetoRede4+'" a "'+strOctetoMascara1+'.'+strOctetoMascara2+'.'+strOctetoMascara3+'.'+strOctetoMascara4+'"\n\n\nConfirma?'))
return true;
else
{
frmForm.frm_te_mascara_rede.select();
frmForm.frm_te_mascara_rede.focus();
return false;
}
}
function TestaIP(IP1, IP2, IP3, IP4)
{
if ((IP1 > 255) || (IP1 < 1))
return 1;
if ((IP2 > 255) || (IP2 < 0))
return 2;
if ((IP3 > 255) || (IP3 < 0))
return 3;
if ((IP4 > 255) || (IP4 < 0))
return 4;
return 0;
}
function TestaMascara(IP1, IP2, IP3, IP4)
{
if ((IP1 > 255) || (IP1 < 0))
return 1;
if ((IP2 > 255) || (IP2 < 0))
return 2;
if ((IP3 > 255) || (IP3 < 0))
return 3;
if ((IP4 > 255) || (IP4 < 0))
return 4;
var IPX =5;
// Determine where IP changes
if (IP1 < 255)
{
if((IP2 > 0) || (IP3 > 0) || (IP4 > 0))
return 5;
IPX = IP1;
}
else
{
if (IP2 < 255)
{
if((IP3 > 0) || (IP4 > 0))
return 6;
IPX = IP2;
}
else
{
if (IP3 < 255)
{
if ((IP4 > 0))
return 7;
IPX = IP3;
}
else
IPX = IP4;
}
}
// Valida o IPX
switch (IPX)
{
case "255":
case "128":
case "192":
case "224":
case "240":
case "248":
case "252":
case "254":
case "0":
return 0;
default:
return 8;
}
return 0;
}