Agregado soporte para reemplazar variables en el código.
[reseter.git] / bas / Global.bas
blob1539b402e4e973ae781b6f69e7f33f5033b07a06
1 Attribute VB_Name = "Global"
2 Option Explicit
3 ' Este archivo es parte del programa "reseter", el cúal es pertenece a SVCommunity.org y a Todosv.com
4 ' Mantenedores principales:
5 ' *Vlad
6 ' *Kikeuntercio
7 ' Para soporte, dudas, consultas, inquitudes y demás:
8 ' http://www.svcommunity.org/forum/index.php?topic=25095.0
9 ' http://www.todosv.com/index.php?showtopic=331
10 Private TiempoMax As Double
11 'Tipo
12 Enum e_Acceso
13 web
14 telnet
15 auro
16 End Enum
17 Enum e_AccionEX
18 ed_clic
19 ed_java
20 ed_llenar
21 ed_navegar
22 End Enum
23 Type t_Datos
24 Direccion As String 'Dirección a navegar
25 usuario As String 'Usuario del router
26 clave As String 'Clave del usuario del router
27 base As String 'Dirección de la puerta de enlace
28 puerto As Long 'Puerto de acceso
29 nForm As Integer
30 nCont As Integer
31 accionTipo As e_AccionEX
32 accionEX As String
33 accionEX2 As String
34 codigo As String 'Lista de codigos a ejecutarse
35 tipoAcceso As e_Acceso 'Tipo de acceso [Telnet | Web]
36 renovar As Boolean 'Ejecutar renovación de IP
37 asumirDes As Boolean 'Asumir desconexion o probar?
38 End Type
39 Public m_Datos As t_Datos
40 Public flag_Navegar As Boolean
41 Public IE As Object
42 Public TelnetComandos() As String
43 Public nComando As Integer
44 Public NetError As Boolean
45 Private Intentos_Realizados As Byte
46 Public pSocket As AuroNet
47 Public ppSocket As AuroNet
48 Public Tiempo As cTimer 'Uso general
49 Public TiempoEx As cTimer 'Uso secundario
50 Public TiempoEx2 As New cTimer 'Uso terciario
51 Public dXMR As String
52 Public dXMR_ok As Boolean
54 Public Sub Main()
55 'Activar_Temas_XP
56 'Rutas de archivos
57 '------------------------
58 '<EhHeader>
59 On Error GoTo main_Err
60 '</EhHeader>
61 100 Set Tiempo = New cTimer
62 101 Set TiempoEx = New cTimer
63 'Empezamos a medir el tiempo que tarda en iniciar el programa
64 102 Tiempo.StartTimer
65 '------------------------
66 'Iniciamos los Sockets
67 103 Set pSocket = New AuroNet
68 104 Set ppSocket = New AuroNet
69 105 pSocket.Direccion = PaginaIP
70 106 ppSocket.Direccion = "www.google.com"
71 '------------------------
72 107 EthInfo
73 '------------------------
74 'Fichero INI con las opciones del programa
75 108 rINI_OPCIONES = App.Path & "\Reseter.ini"
76 'Fichero INI con los códigos de reseteo para los routers
77 109 rINI_ROUTERS = App.Path & "\Routers.ini"
78 '------------------------
79 110 Quieto = LeerINI("Opciones", "Quieto", False)
80 'Será que es mejor no iniciar el Objeto IE?
81 'Esto es util cuando se ha desinstalado el Explorer o en Wine
82 111 NoIE = LeerINI("Opciones", "NoIE", False)
83 11 ModoLinux = LeerINI("Opciones", "Linux:Compatibilidad", False)
84 '------------------------
85 112 frmPrincipal.Show
87 113 DoEvents
88 '------------------------
89 114 Registrar "Iniciando Reseter: " & App.Major & "." & App.Minor & "." & App.Revision & " " & EstadoVer
90 115 Registrar "Propiedad de svcommunity.org, todosv.com y untercio.net"
91 116 Registrar "www.svcommunity.org/forum/index.php?topic=25095.0"
92 117 Registrar "www.todosv.com/index.php?showtopic=331"
93 118 Registrar "Información del programa en:"
94 119 Registrar "IP pública por " & ObtenerDominio(PaginaIP)
96 '------------------------
97 'Objeto IE
98 120 If NoIE Then
99 121 Registrar "+-Se omitió la creacion del Objeto IE; NoIE=-1"
100 Else
101 122 Crear_Objeto_IE
102 End If
104 123 Registrar "+IP Local: " & pSocket.IpLocal
105 124 Registrar "+IP Gateway: " & EthGateWay
106 125 Cambio_IP
107 126 Registrar "Cargando lista de dispositivos soportados"
108 127 Obtener_Lista_Externa
109 128 frmPrincipal.ComReset.Text = Predefinido
110 'Comprobando XMR
111 '------------------------
112 129 Registrar "Comprobando si existe XMR..."
113 130 dXMR = App.Path & "\XMR.exe"
115 131 If Dir$(dXMR) = vbNullString Then
116 132 Registrar "=>XMR no pudo ser encontrado"
117 133 dXMR_ok = False
118 Else
119 134 Registrar "=>XMR encontrado y listo!"
120 135 dXMR_ok = True
121 End If
123 '------------------------
124 'Interfaz
125 '------------------------
126 136 Registrar "Reestableciendo interfaz"
127 137 frmPrincipal.chkAvanzado.Value = LeerINI("Interfaz", "MAvanzado", Unchecked)
128 138 frmPrincipal.chkTerminal.Value = LeerINI("Interfaz", "MTerminal", Unchecked)
129 139 frmPrincipal.txtNumero.Text = LeerINI("Opciones", "Telefono", vbNullString)
130 'variables
131 140 Umbral_Desconexion = 30000
133 '------------------------
134 'Verificar si hay router predefinido y proceder
135 '------------------------
136 141 If HayPredefinido = True Then
137 142 Registrar "Router predefinido, 10segs. para reseteo o cancelar"
138 143 frmPrincipal.cmdPredefinir.Caption = "Cancelar"
139 144 frmPrincipal.cmdReset.Enabled = False
140 145 frmPrincipal.ComReset.Enabled = False
141 146 TiempoEx.StartTimer
142 147 TiempoEx2.StartTimer
144 'Esperamos los 10segs ó que la persona presione cancelar
145 148 Do Until TiempoEx.Elapsed > 10000 Or NetError = True
146 149 Esperar 0.1
147 150 frmPrincipal.lblTW.Caption = Fix((10000 - TiempoEx.Elapsed) / 1000)
149 151 If TiempoEx2.Elapsed > 1000 Then
150 152 Beep
151 153 TiempoEx2.StartTimer
152 End If
154 Loop
156 154 TiempoEx2.EndTimer
158 'Si no presionó cancelar
159 155 If Not NetError Then
160 Registrar "{[PRE]:Iniciando reseteo predefinido}"
161 156 Procesar_Codigo
162 Registrar "{[PRE]:Terminando programa}"
163 157 GuardarRegistro
164 158 Terminar
165 Else
166 'Si presionó cancelar
167 159 Registrar "Se ha cancelado el reseteo automatico"
168 160 NetError = False
169 End If
170 End If
172 161 TiempoEx.EndTimer
173 162 frmPrincipal.cmdReset.Enabled = True
174 163 frmPrincipal.ComReset.Enabled = True
175 164 Tiempo.EndTimer
176 '------------------------
177 165 Registrar "Reseter tardó " & Round(Tiempo.Elapsed / 1000, 2) & "segs. en cargar"
178 '<EhFooter>
179 Exit Sub
180 main_Err:
181 Controlar_Error Erl, Err.Description, "Reseter.Global.main.Ref 12/2/2008 : 09:38:35"
182 Resume Next
183 '</EhFooter>
184 End Sub
186 Public Sub Reiniciar()
187 '<EhHeader>
188 On Error GoTo Reiniciar_Err
189 '</EhHeader>
190 Dim bIP As IP
191 Dim Detectado As Boolean
192 'Reseteamos las variables.
193 100 NetError = False
195 'Verificamos si existe el objeto IE y verificamos si debe o no
196 'de existir.
197 101 If IE Is Nothing And m_Datos.tipoAcceso = web Then
198 102 If NoIE Then
199 103 Registrar "!!!No hay objeto IE porque se especificó NoIE=-1"
200 Else
201 104 Registrar "!!!Por alguna causa el objeto IE no esta!"
202 End If
203 End If
205 'Verificamos el tipo de operación [Web | Telnet | AuroNet]
206 'y la ejecutamos
207 105 Select Case m_Datos.tipoAcceso
209 Case Is = e_Acceso.web
210 106 Registrar "+-Será un reseteo via WEB"
211 107 res_Web
213 108 Case Is = e_Acceso.telnet
214 109 Registrar "+-Será un reseteo via Telnet"
215 110 res_Telnet
217 111 Case Is = e_Acceso.auro
218 112 Registrar "+-Será un reseteo via WEB/AuroNet"
219 113 res_auro
220 End Select
222 'Si ocurrió algún error en el reinicio
223 114 If NetError = True Then
224 115 Registrar "!!! Ha ocurrido un error critico y el reseteo no continuará"
225 Exit Sub
226 End If
228 'Esperamos la reconexión
229 116 If m_Datos.asumirDes Or ModoLinux Then
230 117 Registrar "+--Esperando " & Fix((Umbral_Desconexion / 1000)) & "Segs. para asumir des/conexión de router"
231 118 Tiempo.StartTimer
234 119 Esperar 0.5
235 120 frmPrincipal.lblTW.Caption = Fix((Umbral_Desconexion - Tiempo.Elapsed) / 1000)
236 121 Loop Until Tiempo.Elapsed > Umbral_Desconexion Or NetError Or GetNetConnectString = False
238 122 Tiempo.EndTimer
240 123 If NetError Then Exit Sub
241 Else
242 124 Registrar "+--Esperando " & Fix(Umbral_Desconexion / 1000) & " segundos para desconexión de router"
243 125 Tiempo.StartTimer
246 126 Esperar 0.5
247 127 frmPrincipal.lblTW.Caption = Fix((Umbral_Desconexion - Tiempo.Elapsed) / 1000)
248 128 Loop Until Tiempo.Elapsed > Umbral_Desconexion Or NetError Or GetNetConnectString = False
250 129 Tiempo.EndTimer
252 130 If NetError Or Tiempo.Elapsed > Umbral_Desconexion Then
253 131 Registrar "+---El router nunca se desconectó o ocurrió otro error"
254 132 Error_Cel
255 133 NetError = True
256 Exit Sub
257 End If
259 134 Registrar "+--Esperando " & Fix(Umbral_Desconexion / 1000) & "segundos para reconexión de router"
260 135 Tiempo.StartTimer
263 136 Esperar 0.5
264 137 frmPrincipal.lblTW.Caption = Fix((Umbral_Desconexion - Tiempo.Elapsed) / 1000)
265 138 Loop Until Tiempo.Elapsed > Umbral_Desconexion Or NetError Or GetNetConnectString = True
267 139 Tiempo.EndTimer
269 140 If NetError Or Tiempo.Elapsed > Umbral_Desconexion Then
270 141 Registrar "+---El router nunca se conectó o ocurrió otro error"
271 142 Error_Cel
272 143 NetError = True
273 Exit Sub
274 End If
275 End If
277 'Esperar 5 minutos a que se recupere el internet
278 144 Registrar "+--Esperando recuperación de internet (máximo " & (Umbral_EsperarInternetMax / 60000) & "minutos)"
279 145 Tiempo.StartTimer
280 146 TiempoEx.StartTimer
281 Dim dTemporizador As Long
282 147 dTemporizador = SetTimer(0, 0, 1000, AddressOf lpActualizar)
283 148 Detectado = HayInternet
285 149 If Not Detectado Then
287 150 Do Until (Tiempo.Elapsed > Umbral_EsperarInternetMax) Or NetError
288 151 Esperar 0.5
290 'Chequear si ya hay internet
291 152 If TiempoEx.Elapsed > Umbral_ChequeoInternet Then
292 153 Detectado = HayInternet
294 154 If Detectado Then Exit Do
295 End If
297 Loop
299 End If
301 155 KillTimer 0, dTemporizador
302 156 Tiempo.EndTimer
303 157 TiempoEx.EndTimer
305 158 If Detectado And NetError = False Then
306 'Si hay internet entonces verificamos si la IP cambió
307 '1: Si no cambió entonces reseteamos el router de nuevo
308 '2: siempre y cuando no supere cierto limite de reintentos.
309 159 bIP = Cambio_IP
311 160 If bIP.Cambio = True Then
312 161 Registrar "++La IP no cambió, reintentando reseteo en " & (Umbral_Reintento / 1000) & "Segs."
313 162 Intentos_Realizados = Intentos_Realizados + 1
315 'Como no cambió reintentamos el reseteo
316 163 If Intentos_Realizados > Intentos_Maximos Then
317 'Si ya no nos quedan intentos...
318 164 Registrar "++-Se han hecho " & Intentos_Realizados & " intentos sin exito, deteniendo"
319 165 Registrar "+Se han cancelado los reintentos aútomaticos"
320 Exit Sub
321 Else
322 'Si aún nos quedan intentos...
323 166 Tiempo.StartTimer
324 'Esperar 30segs. para reintentar reseteo
325 167 Registrar "+Esperando " & Fix(Umbral_Reintento / 1000) & " segundos para intento #" & Intentos_Realizados + 1
328 168 Esperar 0.5
329 169 frmPrincipal.lblTW.Caption = Fix((Umbral_Desconexion - Tiempo.Elapsed) / 1000)
330 170 Loop Until Tiempo.Elapsed > Umbral_Reintento Or NetError
332 171 If Not NetError Then
333 172 Procesar_Codigo
334 Exit Sub
335 End If
336 End If
338 Else
339 173 Registrar "+El cambió fue satisfactorio"
341 174 If dXMR_ok And frmPrincipal.txtNumero.Text <> vbNullString Then
342 175 Registrar "Enviando mensaje de exito a usuario"
343 176 XMR_Enviar frmPrincipal.txtNumero.Text, "El reseteo fue exitoso, a las " & Now & " | nueva IP: " & bIP.IP_Actual
344 Else
345 177 Registrar "No habia numero para notificacion de usuario"
346 End If
348 178 frmPrincipal.lblTW.Caption = "Exito"
349 End If
351 Else
352 'Si no se detectó para nada el internet
353 179 Registrar "+El tiempo de espera se agotó y no se detecto conexión."
354 180 Registrar "++El servidor " & PaginaIP & " puede estar caido."
355 181 Registrar "+Se han cancelado los reintentos aútomaticos"
356 182 Error_Cel
357 183 frmPrincipal.lblTW.Caption = "Error"
358 End If
360 ' Reseteamos algunas variables
361 184 Umbral_Desconexion = 30000
362 '<EhFooter>
363 Exit Sub
364 Reiniciar_Err:
365 Controlar_Error Erl, Err.Description, "Reseter.Global.Reiniciar.Ref 12/2/2008 : 09:38:34"
366 Resume Next
367 '</EhFooter>
368 End Sub
370 Public Function GuardarRegistro() As String
371 '<EhHeader>
372 On Error GoTo GuardarRegistro_Err
373 '</EhHeader>
374 Dim i As Byte
375 Dim Buffer As String
376 Static ocupado As Boolean
378 100 If ocupado Then Exit Function
379 101 ocupado = True
380 102 i = FreeFile
381 103 Buffer = frmPrincipal.txtSalida.Text
382 104 Open App.Path & "\" & Day(Now) & "-" & Month(Now) & ".txt" For Append Access Write As #i
383 105 Print #i, CStr(Now)
384 106 Print #i, CStr(Buffer)
385 107 Close #i
386 108 GuardarRegistro = (App.Path & "\" & Day(Now) & "-" & Month(Now) & ".txt")
387 109 ocupado = False
388 '<EhFooter>
389 Exit Function
390 GuardarRegistro_Err:
391 Controlar_Error Erl, Err.Description, "Reseter.Global.GuardarRegistro.Ref 12/2/2008 : 09:38:34"
392 Resume Next
393 '</EhFooter>
394 End Function
396 'CSEH: Skip
397 Public Sub Controlar_Error(linea As Long, _
398 descripcion As String, _
399 lugar As String)
400 100 Registrar "¦¦¦""" & descripcion & """, erl #" & linea & " - """ & lugar & """"
402 102 If Quieto Then
403 104 GuardarRegistro
404 Else
406 106 If MsgBox("Ocurrió el error """ & descripcion & """, en linea #" & linea & " de """ & lugar & """" & vbNewLine & "Por favor notifica de este error al tema especifico de reseter en svcommunity.org ó todosv.com" & vbNewLine & "Se ha guardado un registro de error en """ & GuardarRegistro & """ por favor envielo a los creadores" & vbNewLine & "¿Desea terminar la aplicación?", vbCritical + vbYesNo) = vbYes Then End
407 End If
409 End Sub
411 Public Sub Predefinir(Valor As Boolean)
412 '<EhHeader>
413 On Error GoTo Predefinir_Err
414 '</EhHeader>
415 100 EscribirINI "Opciones", "BPredefinido", CStr(CInt(Valor))
416 101 EscribirINI "Opciones", "Predefinido", frmPrincipal.ComReset.Text
417 '<EhFooter>
418 Exit Sub
419 Predefinir_Err:
420 Controlar_Error Erl, Err.Description, "Reseter.Global.Predefinir.Ref 12/2/2008 : 09:38:34"
421 Resume Next
422 '</EhFooter>
423 End Sub
425 Public Function Predefinido() As String
426 '<EhHeader>
427 On Error GoTo Predefinido_Err
428 '</EhHeader>
429 100 Predefinido = LeerINI("Opciones", "Predefinido", "Escoja su router/modem")
430 '<EhFooter>
431 Exit Function
432 Predefinido_Err:
433 Controlar_Error Erl, Err.Description, "Reseter.Global.Predefinido.Ref 12/2/2008 : 09:38:34"
434 Resume Next
435 '</EhFooter>
436 End Function
438 Public Function ObtenerDominio(URL As String) As String
439 '<EhHeader>
440 On Error GoTo ObtenerDominio_Err
441 '</EhHeader>
442 Dim Buffer As Long
443 100 Buffer = InStr(8, URL, "/")
445 101 If Buffer > 0 Then ObtenerDominio = Replace$(Mid$(URL, 1, Buffer - 1), "http://", vbNullString) Else ObtenerDominio = URL
446 '<EhFooter>
447 Exit Function
448 ObtenerDominio_Err:
449 Controlar_Error Erl, Err.Description, "Reseter.Global.ObtenerDominio.Ref 12/2/2008 : 09:38:34"
450 Resume Next
451 '</EhFooter>
452 End Function
454 Public Function HayPredefinido() As Boolean
455 '<EhHeader>
456 On Error GoTo HayPredefinido_Err
457 '</EhHeader>
458 100 HayPredefinido = LeerINI("Opciones", "BPredefinido", False)
459 '<EhFooter>
460 Exit Function
461 HayPredefinido_Err:
462 Controlar_Error Erl, Err.Description, "Reseter.Global.HayPredefinido.Ref 12/2/2008 : 09:38:34"
463 Resume Next
464 '</EhFooter>
465 End Function
467 Public Sub XMR_Enviar(Numero As String, _
468 Mensaje As String)
469 'Gracias a Olatin por la idea de enviar mensaje con notificaciones!.
470 '<EhHeader>
471 On Error GoTo XMR_Enviar_Err
472 '</EhHeader>
473 100 ShellExecute frmPrincipal.hWnd, "", dXMR & " /x n=" & Numero & "|m=" & Mensaje & "|f=Reseter 4.0", "", "", 0
474 '<EhFooter>
475 Exit Sub
476 XMR_Enviar_Err:
477 Controlar_Error Erl, Err.Description, "Reseter.Global.XMR_Enviar.Ref 12/2/2008 : 09:38:34"
478 Resume Next
479 '</EhFooter>
480 End Sub
482 Public Sub Error_Cel()
483 '<EhHeader>
484 On Error GoTo Error_Cel_Err
486 '</EhHeader>
487 100 If dXMR_ok And frmPrincipal.txtNumero.Text <> vbNullString Then
488 101 Registrar "Enviando mensaje de error a usuario"
489 102 XMR_Enviar frmPrincipal.txtNumero.Text, "El reseteo NO fue exitoso, fallo ocurrido en " & Now
490 End If
492 '<EhFooter>
493 Exit Sub
494 Error_Cel_Err:
495 Controlar_Error Erl, Err.Description, "Reseter.Global.Error_Cel.Ref 12/2/2008 : 09:38:34"
496 Resume Next
497 '</EhFooter>
498 End Sub
500 Public Sub Procesar_Codigo()
501 'Primero quebramos el codigo en un array, donde cada elemento contendrá una linea de codigo básico.
502 '<EhHeader>
503 On Error GoTo Procesar_Codigo_Err
504 '</EhHeader>
505 Dim A_Codigo() As String
506 Dim i As Long
507 Dim cTimeEspera As New cTimer
508 100 A_Codigo = Split(m_Datos.codigo, Chr(254))
510 101 For i = 0 To UBound(A_Codigo)
511 'Saltar los comentarios
512 If Left(A_Codigo(i), 2) = "//" Then Registrar "PreProcesador: Comentario: '" & Mid$(A_Codigo(i), 3) & "'"
513 'Reemplazar variables
514 A_Codigo(i) = Replace$(A_Codigo(i), "$$GATEWAY$$", EthGateWay)
515 '#########################################################################################
516 ' Ejecutores
517 '#########################################################################################
518 'El codigo dice que tenemos que reiniciar?, bien, "tratemos"
519 102 If A_Codigo(i) = "objetivo.reiniciar" Then
520 103 Registrar "PreProcesador: 'objetivo.reiniciar' ejecutando 'Reiniciar'"
521 104 Reiniciar
522 105 Registrar "PreProcesador: 'objetivo.reiniciar' ejecutado."
523 End If
525 'El codigo dice que tenemos que ejecutemos el procesador Res_web?
526 106 If A_Codigo(i) = "web.procesar" Then
527 107 Registrar "PreProcesador: 'web.procesar' ejecutando 'Res_Web'"
528 108 res_Web
529 109 Registrar "PreProcesador: 'web.procesar' ejecutado."
530 End If
532 'El codigo diceque tenemos que esperar X segundos antes de seguir?
533 110 If InStr(1, A_Codigo(i), "mi.esperar=") Then
534 111 TiempoMax = CDbl(Mid$(A_Codigo(i), InStr(1, A_Codigo(i), "=") + 1)) * 1000
535 112 Registrar "PreProcesador: 'mi.esperar' iniciada [" & TiempoMax & "]"
536 113 cTimeEspera.StartTimer
539 114 Esperar 0.5
540 115 Loop Until cTimeEspera.Elapsed > TiempoMax
542 116 Registrar "PreProcesador: comando 'mi.esperar' concluido"
543 End If
545 '#########################################################################################
546 '#########################################################################################
547 '#########################################################################################
548 ' Banderas
549 '#########################################################################################
550 'El codigo dice que tenemos que hacer clic en la direccion indicada?
551 117 If A_Codigo(i) = "web.accion.clic" Then
552 118 m_Datos.accionTipo = ed_clic
553 119 Registrar "PreProcesador: 'web.accion.clic' traducido a 'm_Datos.accionTipo=ed_clic'"
554 End If
556 'El codigo dice que solo tenemos que navegar la direccion indicada? (codigo JAVA)
557 120 If A_Codigo(i) = "web.accion.java" Then
558 121 m_Datos.accionTipo = ed_java
559 122 Registrar "PreProcesador: 'web.accion.java' traducido a 'm_Datos.accionTipo=ed_java'"
560 End If
562 'El codigo dice que solo tenemos que navegar la direccion indicada?
563 123 If A_Codigo(i) = "web.accion.navegar" Then
564 124 m_Datos.accionTipo = ed_navegar
565 125 Registrar "PreProcesador: 'web.accion.navegar' traducido a 'm_Datos.accionTipo=ed_navegar'"
566 End If
568 'El codigo dice que tenemos que llenar información en la direccion y posición indicada?
569 126 If InStr(1, A_Codigo(i), "web.accion.llenar") Then
570 127 m_Datos.accionTipo = ed_llenar
571 128 Registrar "PreProcesador: 'web.accion.llenar' traducido a 'm_Datos.accionTipo=ed_llenar'"
572 End If
574 'Debemos asumir que el router se desconectará internamente?.
575 129 If InStr(1, A_Codigo(i), "objetivo.asumir.desconexion=") Then
576 130 m_Datos.asumirDes = CBool(Mid$(A_Codigo(i), InStr(1, A_Codigo(i), "=") + 1))
577 131 Registrar "PreProcesador: 'objetivo.asumir.desconexion' traducido a 'm_Datos.asumirDes=" & m_Datos.asumirDes & "'"
578 End If
580 'El codigo dice que tenemos que renovar despues de la operación?
581 132 If InStr(1, A_Codigo(i), "red.renovar=") Then
582 133 m_Datos.renovar = CBool(Mid$(A_Codigo(i), InStr(1, A_Codigo(i), "=") + 1))
583 134 Registrar "PreProcesador: 'red.renovar' traducido a 'm_Datos.renovar=" & m_Datos.renovar & "'"
584 End If
586 'El codigo dice que no tenemos que navegar en reiniciar.res_web y en web.procesar?
587 135 If InStr(1, A_Codigo(i), "web.navegar=") Then
588 136 flag_Navegar = CBool(Mid$(A_Codigo(i), InStr(1, A_Codigo(i), "=") + 1))
589 137 Registrar "PreProcesador: 'web.navegar' traducido a 'flag_Navegar=" & flag_Navegar & "'"
590 End If
592 'El codigo dice que tenemos que cambiar el limite para asumir desconexion -temporal-?
593 'mi.umbral.desconexion=<TIEMPO EN SEGUNDOS>
594 138 If InStr(1, A_Codigo(i), "mi.umbral.desconexion=") Then
595 139 Umbral_Desconexion = Mid$(A_Codigo(i), InStr(1, A_Codigo(i), "=") + 1) * 1000
596 140 Registrar "PreProcesador: 'mi.umbral.desconexion' traducido a 'Umbral_Desconexion=" & Umbral_Desconexion & "'"
597 End If
599 '#########################################################################################
600 '#########################################################################################
601 '#########################################################################################
602 ' Ajustes de parametros
603 '#########################################################################################
604 'El codigo dice que tenemos que ajustar las opciones para procesar telnet?
605 'telnet=<COMANDOS SEPARADOS POR ";">
606 141 If InStr(1, A_Codigo(i), "telnet.comando=") Then
607 142 m_Datos.tipoAcceso = telnet
608 143 m_Datos.accionEX = Mid$(A_Codigo(i), InStr(1, A_Codigo(i), "=") + 1)
609 144 Registrar "PreProcesador: 'telnet' traducido a 'm_Datos.accionEX=" & m_Datos.accionEX & "'"
610 End If
612 'El codigo dice que tenemos que ajustar las opciones para procesar web?
613 145 If InStr(1, A_Codigo(i), "web.url=") Then
614 146 m_Datos.accionEX = Mid$(A_Codigo(i), InStr(1, A_Codigo(i), "=") + 1)
615 147 m_Datos.tipoAcceso = web
616 148 Registrar "PreProcesador: 'web.url' traducido a 'm_Datos.accionEX=" & m_Datos.accionEX & "'"
617 End If
619 'El codigo nos da datos para EX2
620 149 If InStr(1, A_Codigo(i), "web.datos=") Then
621 150 m_Datos.accionEX2 = Mid$(A_Codigo(i), InStr(1, A_Codigo(i), "=") + 1)
622 151 Registrar "PreProcesador: 'web.datos' traducido a 'm_Datos.accionEX2=" & m_Datos.accionEX2 & "'"
623 End If
625 'El codigo especifica el puerto a usar?
626 152 If InStr(1, A_Codigo(i), "puerto=") Then
627 153 m_Datos.puerto = Mid$(A_Codigo(i), InStr(1, A_Codigo(i), "=") + 1)
628 154 Registrar "PreProcesador: 'puerto' traducido a 'm_Datos.puerto=" & m_Datos.puerto & "'"
629 End If
631 'El codigo especifica el control a usar?
632 155 If InStr(1, A_Codigo(i), "web.control=") Then
633 156 m_Datos.nCont = Mid$(A_Codigo(i), InStr(1, A_Codigo(i), "=") + 1)
634 157 Registrar "PreProcesador: 'web.control' traducido a 'm_Datos.nCont=" & m_Datos.nCont & "'"
635 End If
637 'El codigo especifica el formulario a usar?
638 158 If InStr(1, A_Codigo(i), "web.formulario=") Then
639 159 m_Datos.nForm = Mid$(A_Codigo(i), InStr(1, A_Codigo(i), "=") + 1)
640 160 Registrar "PreProcesador: 'web.formulario' traducido a 'm_Datos.nForm=" & m_Datos.nForm & "'"
641 End If
643 'El codigo especifica el usuario a usar?
644 161 If InStr(1, A_Codigo(i), "web.usuario=") Then
645 162 m_Datos.usuario = Mid$(A_Codigo(i), InStr(1, A_Codigo(i), "=") + 1)
646 163 Registrar "PreProcesador: 'web.usuario' traducido a 'm_Datos.usuario=" & m_Datos.usuario & "'"
647 End If
649 'El codigo especifica la clave a usar?
650 164 If InStr(1, A_Codigo(i), "web.clave=") Then
651 165 m_Datos.clave = Mid$(A_Codigo(i), InStr(1, A_Codigo(i), "=") + 1)
652 166 Registrar "PreProcesador: 'clave' traducido a 'm_Datos.clave=" & m_Datos.clave & "'"
653 End If
655 'El codigo especifica la dirección base a usar?
656 167 If InStr(1, A_Codigo(i), "objetivo.ip=") Then
657 168 m_Datos.base = Mid$(A_Codigo(i), InStr(1, A_Codigo(i), "=") + 1)
658 169 Registrar "PreProcesador: 'base' traducido a 'm_Datos.base=" & m_Datos.base & "'"
659 End If
661 '#########################################################################################
662 '#########################################################################################
663 Next
665 '<EhFooter>
666 Exit Sub
667 Procesar_Codigo_Err:
668 Controlar_Error Erl, Err.Description, "Reseter.Global.Procesar_Codigo.Ref 12/2/2008 : 09:38:34"
669 Resume Next
670 '</EhFooter>
671 End Sub
673 Public Function HayInternet() As Boolean
674 '<EhHeader>
675 On Error GoTo HayInternet_Err
677 '</EhHeader>
678 100 If m_Datos.renovar = True Then RenovarLAN
679 101 Registrar "+---Chequeando conexión a internet... espere"
680 102 Esperar 0.5
682 103 If ppSocket.HTML_CONSULTAR Then
683 104 Registrar "+----Chequeo -> Se detectó internet"
684 105 HayInternet = True
685 Else
686 106 Registrar "+----Chequeo -> Aún no hay internet"
687 107 TiempoEx.StartTimer
688 End If
690 '<EhFooter>
691 Exit Function
692 HayInternet_Err:
693 Controlar_Error Erl, Err.Description, "Reseter.Global.HayInternet.Ref 12/2/2008 : 09:38:34"
694 Resume Next
695 '</EhFooter>
696 End Function
698 Public Sub Restablecer_Todo()
699 '<EhHeader>
700 On Error GoTo Restablecer_Todo_Err
701 '</EhHeader>
702 100 flag_Navegar = True
703 101 TelnetComandos = Split("")
704 102 nComando = 0
705 103 NetError = False
706 104 Intentos_Realizados = 0
708 105 With m_Datos
709 106 .accionEX = ""
710 107 .accionEX2 = ""
711 108 .accionTipo = ed_clic
712 109 .asumirDes = False
713 110 .base = ""
714 111 .clave = ""
715 112 .codigo = ""
716 113 .Direccion = ""
717 114 .nCont = -1
718 115 .nForm = -1
719 116 .puerto = 0
720 117 .renovar = True
721 118 .tipoAcceso = web
722 119 .usuario = ""
723 End With
725 '<EhFooter>
726 Exit Sub
727 Restablecer_Todo_Err:
728 Controlar_Error Erl, Err.Description, "Reseter.Global.Restablecer_Todo.Ref 12/2/2008 : 09:38:34"
729 Resume Next
730 '</EhFooter>
731 End Sub
733 Public Sub Terminar()
734 '<EhHeader>
735 On Error GoTo Terminar_Err
736 '</EhHeader>
737 100 Destruir_Conexion
738 101 EscribirINI "Opciones", "Quieto", CStr(CInt(Quieto))
739 102 EscribirINI "Opciones", "NoIE", CStr(CInt(NoIE))
740 103 EscribirINI "Opciones", "Telefono", CStr(frmPrincipal.txtNumero.Text)
741 10 EscribirINI "Opciones", "Linux:Compatibilidad", CStr(CInt(ModoLinux))
742 104 Set pSocket = Nothing
743 105 Set ppSocket = Nothing
744 Dim f As Form
746 106 For Each f In Forms
747 107 Unload f
748 Next
750 108 End
751 '<EhFooter>
752 Exit Sub
753 Terminar_Err:
754 Controlar_Error Erl, Err.Description, "Reseter.Global.Terminar.Ref 12/2/2008 : 09:38:34"
755 Resume Next
756 '</EhFooter>
757 End Sub