@@ -72,7 +72,7 @@ noFiles=false
72
72
73
73
# Generate debug file under log
74
74
# DO NOT USE THIS IF YOU DON'T KNOW HOW TO DEBUG FROM OUTPUTTED FILE
75
- debugUnknown=true
75
+ debugUnknown=false
76
76
77
77
# Defaut name for hosts file
78
78
hostsDefault=' hosts'
@@ -749,7 +749,7 @@ getExpirationDate(){
749
749
750
750
# Here's a list of words the ${content} have to match to get the
751
751
# expiration date from the whois record of domain
752
- local toMatch=(' expire:' ' Expiration Date:' ' expire on:' ' Expiry Date:' ' free-date' ' expires:' ' Expiration date:' ' Expiry date:' ' Expire Date:' ' renewal date:' ' Expires:' ' validity:' ' Expiration Date :' ' Expiry :' ' expires at:' ' domain_datebilleduntil:' ' Data de expiração \/ Expiration Date \(dd\/mm\/yyyy\):' ' Fecha de expiración \(Expiration date\):' ' \[Expires on\]' ' Record expires on' ' status: OK-UNTIL' ' renewal:' ' expires............:' ' expire-date:' )
752
+ local toMatch=(' expire:' ' Expiration Date:' ' expire on:' ' Expiry Date:' ' free-date' ' expires:' ' Expiration date:' ' Expiry date:' ' Expire Date:' ' renewal date:' ' Expires:' ' validity:' ' Expiration Date :' ' Expiry :' ' expires at:' ' domain_datebilleduntil:' ' Data de expiração \/ Expiration Date \(dd\/mm\/yyyy\):' ' Fecha de expiración \(Expiration date\):' ' \[Expires on\]' ' Record expires on' ' status: OK-UNTIL' ' renewal:' ' expires............:' ' expire-date:' ' Exp date: ' )
753
753
754
754
for i in ${! toMatch[*]}
755
755
do
@@ -875,46 +875,30 @@ getMonthInEnglish(){
875
875
# @CalledBy formatDate
876
876
# ###############################################################################
877
877
convert1To2digits (){
878
- oneDigit=" ${1} "
878
+ local number=" ${1} "
879
+ local monthOrDay=" ${2} "
879
880
880
- local regex=' (?<!\S)\d(?!\S)'
881
- if [[ ${oneDigit} =~ regex ]]
882
- then
883
- case ${oneDigit} in
884
- 1)
885
- month=' 01'
886
- ;;
887
- 2)
888
- month=' 02'
889
- ;;
890
- 3)
891
- month=' 03'
892
- ;;
893
- 4)
894
- month=' 04'
895
- ;;
896
- 5)
897
- month=' 05'
898
- ;;
899
- 6)
900
- month=' 06'
901
- ;;
902
- 7)
903
- month=' 07'
904
- ;;
905
- 8)
906
- month=' 08'
907
- ;;
908
- 9)
909
- month=' 09'
910
- ;;
911
- * )
912
- month=' 00'
913
- ;;
914
- esac
915
- else
916
- month=${oneDigit}
917
- fi
881
+ local regex=" ^\d"
882
+
883
+ local validNumber=(' 1' ' 2' ' 3' ' 4' ' 5' ' 6' ' 7' ' 8' ' 9' )
884
+ local null=' 0'
885
+
886
+ for i in ${! validNumber[*]}
887
+ do
888
+ if [[ ${number} == ${validNumber[${i}]} ]]
889
+ then
890
+ case " ${monthOrDay} " in
891
+ month)
892
+ month=${null}${number}
893
+ break
894
+ ;;
895
+ day)
896
+ day=${null}${number}
897
+ break
898
+ ;;
899
+ esac
900
+ fi
901
+ done
918
902
}
919
903
920
904
# ############################### Format Date ###################################
@@ -979,6 +963,8 @@ formatDate()
979
963
local regex26=' [0-9]{2}-[A-Z]{1}[a-z]{2}-[0-9]{4}'
980
964
# Date in format: 02.1.2017 // Month: jan
981
965
local regex27=' [0-9]{2}\.[0-9]{1}\.[0-9]{4}'
966
+ # Date in format: 02 Jan 2017
967
+ local regex28=' [0-9]\s[A-Z]{1}[a-z]{2}\s[0-9]{4}'
982
968
983
969
if [[ " ${expirationDate} " =~ ${regex1} || " ${expirationDate} " =~ ${regex11} || " ${expirationDate} " =~ ${regex26} ]]
984
970
then
@@ -1036,14 +1022,46 @@ formatDate()
1036
1022
local year=$( echo " ${expirationDate} " | tr -cd ' [[:digit:]]' | tail -c4)
1037
1023
1038
1024
# We convert the month
1039
- convert1To2digits " ${month} "
1025
+ convert1To2digits " ${month} " " month "
1040
1026
1041
1027
# We convert the month to alpha format
1042
1028
getMonthInEnglish " ${month} "
1043
1029
1044
1030
# We assign the expiration date
1045
1031
expirationDate=${day} ' -' ${month} ' -' ${year}
1046
1032
1033
+ # We convert it to lower case
1034
+ dateToLower
1035
+ elif [[ " ${expirationDate} " =~ ${regex28} ]]
1036
+ then
1037
+ # We split the date
1038
+ local month=$( echo " ${expirationDate} " | tr -cd ' [[:alpha:]]' | head -c3)
1039
+ local year=$( echo " ${expirationDate} " | tr -cd ' [[:digit:]]' | tail -c4)
1040
+ local day=$( echo " ${expirationDate} " | tr -cd ' [[:digit:]]' | head -c4)
1041
+
1042
+ # We get the last 2 digits of the day
1043
+ local dayEnd=$( echo " ${day} " | tr -cd ' [[:digit:]]' | tail -c2)
1044
+
1045
+ # We use 20 to check if it's a 1 or 2 digts day
1046
+ # Case:
1047
+ # 2 Jan 2017
1048
+ # Result: 2201
1049
+ # 02 Jan 2017-01
1050
+ # Result: 0220
1051
+ # So if the last 2 digts are not 20, it's a 1 digit day
1052
+ if [[ ${dayEnd} == ' 20' ]]
1053
+ then
1054
+ local day=$( echo " ${day} " | tr -cd ' [[:digit:]]' | head -c2)
1055
+ else
1056
+ local day=$( echo " ${day} " | tr -cd ' [[:digit:]]' | head -c1)
1057
+
1058
+ # We convert the day
1059
+ convert1To2digits " ${day} " " day"
1060
+ fi
1061
+
1062
+ # We assign the expiration date
1063
+ expirationDate=${day} ' -' ${month} ' -' ${year}
1064
+
1047
1065
# We convert it to lower case
1048
1066
dateToLower
1049
1067
else
0 commit comments