2020-12-01 15:17:48 +01:00
|
|
|
;********************************
|
|
|
|
;*
|
|
|
|
;* lweb_IP.pbi
|
|
|
|
;*
|
|
|
|
|
|
|
|
|
|
|
|
Procedure IsIPStringValid(Adress.s)
|
|
|
|
Static My_Regex_v4
|
|
|
|
Static My_Regex_v6_nocompress
|
|
|
|
Static My_Regex_v6_compress
|
|
|
|
Static Valid = 0
|
|
|
|
|
|
|
|
My_Regex_v4 = CreateRegularExpression(#PB_Any, "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$")
|
|
|
|
My_Regex_v6_nocompress = CreateRegularExpression(#PB_Any, "^[0-9a-fA-F]{1,4}(:[0-9a-fA-F]{1,4}){7}$")
|
|
|
|
My_Regex_v6_compress = CreateRegularExpression(#PB_Any, "^(([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,5})?)::(([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,5})?)$")
|
|
|
|
|
|
|
|
If MatchRegularExpression(My_Regex_v4, Adress) And Valid = 0
|
2023-03-29 10:44:52 +02:00
|
|
|
lhs_log_ext::OutL(lhs_web::get_config(lhs_web::#conf_Debug_logUUID), lhs_log_ext::#Debugging,"My_Regex_v4")
|
2020-12-01 15:17:48 +01:00
|
|
|
Valid = 1
|
|
|
|
EndIf
|
|
|
|
If MatchRegularExpression(My_Regex_v6_nocompress, Adress) And Valid = 0
|
2023-03-29 10:44:52 +02:00
|
|
|
lhs_log_ext::OutL(lhs_web::get_config(lhs_web::#conf_Debug_logUUID), lhs_log_ext::#Debugging,"My_Regex_v6_nocompress")
|
2020-12-01 15:17:48 +01:00
|
|
|
Valid = 1
|
|
|
|
EndIf
|
|
|
|
If MatchRegularExpression(My_Regex_v6_compress, Adress) And Valid = 0
|
2023-03-29 10:44:52 +02:00
|
|
|
lhs_log_ext::OutL(lhs_web::get_config(lhs_web::#conf_Debug_logUUID), lhs_log_ext::#Debugging,"My_Regex_v6_compress")
|
2020-12-01 15:17:48 +01:00
|
|
|
Valid = 1
|
|
|
|
EndIf
|
|
|
|
|
|
|
|
FreeRegularExpression(My_Regex_v4)
|
|
|
|
FreeRegularExpression(My_Regex_v6_nocompress)
|
|
|
|
FreeRegularExpression(My_Regex_v6_compress)
|
|
|
|
|
|
|
|
If Valid = 1
|
|
|
|
ProcedureReturn #True
|
|
|
|
Else
|
|
|
|
ProcedureReturn #False
|
|
|
|
EndIf
|
|
|
|
|
|
|
|
EndProcedure
|