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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
|
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* @see Zend_Validate_Abstract
*/
/**
* @see Zend_Validate_Ip
*/
/**
* Please note there are two standalone test scripts for testing IDN characters due to problems
* with file encoding.
*
* The first is tests/Zend/Validate/HostnameTestStandalone.php which is designed to be run on
* the command line.
*
* The second is tests/Zend/Validate/HostnameTestForm.php which is designed to be run via HTML
* to allow users to test entering UTF-8 characters in a form.
*
* @category Zend
* @package Zend_Validate
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Validate_Hostname extends Zend_Validate_Abstract
{
const CANNOT_DECODE_PUNYCODE = 'hostnameCannotDecodePunycode';
const INVALID = 'hostnameInvalid';
const INVALID_DASH = 'hostnameDashCharacter';
const INVALID_HOSTNAME = 'hostnameInvalidHostname';
const INVALID_HOSTNAME_SCHEMA = 'hostnameInvalidHostnameSchema';
const INVALID_LOCAL_NAME = 'hostnameInvalidLocalName';
const INVALID_URI = 'hostnameInvalidUri';
const IP_ADDRESS_NOT_ALLOWED = 'hostnameIpAddressNotAllowed';
const LOCAL_NAME_NOT_ALLOWED = 'hostnameLocalNameNotAllowed';
const UNDECIPHERABLE_TLD = 'hostnameUndecipherableTld';
const UNKNOWN_TLD = 'hostnameUnknownTld';
/**
* @var array
*/
protected $_messageTemplates = array(
self::CANNOT_DECODE_PUNYCODE => "'%value%' appears to be a DNS hostname but the given punycode notation cannot be decoded",
self::INVALID => "Invalid type given. String expected",
self::INVALID_DASH => "'%value%' appears to be a DNS hostname but contains a dash in an invalid position",
self::INVALID_HOSTNAME => "'%value%' does not match the expected structure for a DNS hostname",
self::INVALID_HOSTNAME_SCHEMA => "'%value%' appears to be a DNS hostname but cannot match against hostname schema for TLD '%tld%'",
self::INVALID_LOCAL_NAME => "'%value%' does not appear to be a valid local network name",
self::INVALID_URI => "'%value%' does not appear to be a valid URI hostname",
self::IP_ADDRESS_NOT_ALLOWED => "'%value%' appears to be an IP address, but IP addresses are not allowed",
self::LOCAL_NAME_NOT_ALLOWED => "'%value%' appears to be a local network name but local network names are not allowed",
self::UNDECIPHERABLE_TLD => "'%value%' appears to be a DNS hostname but cannot extract TLD part",
self::UNKNOWN_TLD => "'%value%' appears to be a DNS hostname but cannot match TLD against known list",
);
/**
* @var array
*/
protected $_messageVariables = array(
'tld' => '_tld'
);
/**
* Allows Internet domain names (e.g., example.com)
*/
const ALLOW_DNS = 1;
/**
* Allows IP addresses
*/
const ALLOW_IP = 2;
/**
* Allows local network names (e.g., localhost, www.localdomain)
*/
const ALLOW_LOCAL = 4;
/**
* Allows all types of hostnames
*/
const ALLOW_URI = 8;
/**
* Allows all types of hostnames
*/
const ALLOW_ALL = 15;
/**
* Array of valid top-level-domains
*
* Version 2015091800, Last Updated Fri Sep 18 07:07:01 2015 UTC
*
* @see http://data.iana.org/TLD/tlds-alpha-by-domain.txt List of all TLDs by domain
* @see http://www.iana.org/domains/root/db/ Official list of supported TLDs
* @var array
*/
protected $_validTlds = array(
'aaa',
'abb',
'abbott',
'abogado',
'ac',
'academy',
'accenture',
'accountant',
'accountants',
'aco',
'active',
'actor',
'ad',
'ads',
'adult',
'ae',
'aeg',
'aero',
'af',
'afl',
'ag',
'agency',
'ai',
'aig',
'airforce',
'airtel',
'al',
'allfinanz',
'alsace',
'am',
'amica',
'amsterdam',
'android',
'ao',
'apartments',
'app',
'aq',
'aquarelle',
'ar',
'aramco',
'archi',
'army',
'arpa',
'arte',
'as',
'asia',
'associates',
'at',
'attorney',
'au',
'auction',
'audio',
'auto',
'autos',
'aw',
'ax',
'axa',
'az',
'azure',
'ba',
'band',
'bank',
'bar',
'barcelona',
'barclaycard',
'barclays',
'bargains',
'bauhaus',
'bayern',
'bb',
'bbc',
'bbva',
'bcn',
'bd',
'be',
'beer',
'bentley',
'berlin',
'best',
'bet',
'bf',
'bg',
'bh',
'bharti',
'bi',
'bible',
'bid',
'bike',
'bing',
'bingo',
'bio',
'biz',
'bj',
'black',
'blackfriday',
'bloomberg',
'blue',
'bm',
'bms',
'bmw',
'bn',
'bnl',
'bnpparibas',
'bo',
'boats',
'bom',
'bond',
'boo',
'boots',
'boutique',
'br',
'bradesco',
'bridgestone',
'broker',
'brother',
'brussels',
'bs',
'bt',
'budapest',
'build',
'builders',
'business',
'buzz',
'bv',
'bw',
'by',
'bz',
'bzh',
'ca',
'cab',
'cafe',
'cal',
'camera',
'camp',
'cancerresearch',
'canon',
'capetown',
'capital',
'car',
'caravan',
'cards',
'care',
'career',
'careers',
'cars',
'cartier',
'casa',
'cash',
'casino',
'cat',
'catering',
'cba',
'cbn',
'cc',
'cd',
'ceb',
'center',
'ceo',
'cern',
'cf',
'cfa',
'cfd',
'cg',
'ch',
'chanel',
'channel',
'chat',
'cheap',
'chloe',
'christmas',
'chrome',
'church',
'ci',
'cipriani',
'cisco',
'citic',
'city',
'ck',
'cl',
'claims',
'cleaning',
'click',
'clinic',
'clothing',
'cloud',
'club',
'clubmed',
'cm',
'cn',
'co',
'coach',
'codes',
'coffee',
'college',
'cologne',
'com',
'commbank',
'community',
'company',
'computer',
'condos',
'construction',
'consulting',
'contractors',
'cooking',
'cool',
'coop',
'corsica',
'country',
'coupons',
'courses',
'cr',
'credit',
'creditcard',
'cricket',
'crown',
'crs',
'cruises',
'csc',
'cu',
'cuisinella',
'cv',
'cw',
'cx',
'cy',
'cymru',
'cyou',
'cz',
'dabur',
'dad',
'dance',
'date',
'dating',
'datsun',
'day',
'dclk',
'de',
'deals',
'degree',
'delivery',
'dell',
'delta',
'democrat',
'dental',
'dentist',
'desi',
'design',
'dev',
'diamonds',
'diet',
'digital',
'direct',
'directory',
'discount',
'dj',
'dk',
'dm',
'dnp',
'do',
'docs',
'dog',
'doha',
'domains',
'doosan',
'download',
'drive',
'durban',
'dvag',
'dz',
'earth',
'eat',
'ec',
'edu',
'education',
'ee',
'eg',
'email',
'emerck',
'energy',
'engineer',
'engineering',
'enterprises',
'epson',
'equipment',
'er',
'erni',
'es',
'esq',
'estate',
'et',
'eu',
'eurovision',
'eus',
'events',
'everbank',
'exchange',
'expert',
'exposed',
'express',
'fage',
'fail',
'faith',
'family',
'fan',
'fans',
'farm',
'fashion',
'feedback',
'fi',
'film',
'final',
'finance',
'financial',
'firmdale',
'fish',
'fishing',
'fit',
'fitness',
'fj',
'fk',
'flights',
'florist',
'flowers',
'flsmidth',
'fly',
'fm',
'fo',
'foo',
'football',
'forex',
'forsale',
'forum',
'foundation',
'fr',
'frl',
'frogans',
'fund',
'furniture',
'futbol',
'fyi',
'ga',
'gal',
'gallery',
'game',
'garden',
'gb',
'gbiz',
'gd',
'gdn',
'ge',
'gea',
'gent',
'genting',
'gf',
'gg',
'ggee',
'gh',
'gi',
'gift',
'gifts',
'gives',
'giving',
'gl',
'glass',
'gle',
'global',
'globo',
'gm',
'gmail',
'gmo',
'gmx',
'gn',
'gold',
'goldpoint',
'golf',
'goo',
'goog',
'google',
'gop',
'gov',
'gp',
'gq',
'gr',
'graphics',
'gratis',
'green',
'gripe',
'group',
'gs',
'gt',
'gu',
'gucci',
'guge',
'guide',
'guitars',
'guru',
'gw',
'gy',
'hamburg',
'hangout',
'haus',
'healthcare',
'help',
'here',
'hermes',
'hiphop',
'hitachi',
'hiv',
'hk',
'hm',
'hn',
'hockey',
'holdings',
'holiday',
'homedepot',
'homes',
'honda',
'horse',
'host',
'hosting',
'hoteles',
'hotmail',
'house',
'how',
'hr',
'hsbc',
'ht',
'hu',
'hyundai',
'ibm',
'icbc',
'ice',
'icu',
'id',
'ie',
'ifm',
'iinet',
'il',
'im',
'immo',
'immobilien',
'in',
'industries',
'infiniti',
'info',
'ing',
'ink',
'institute',
'insure',
'int',
'international',
'investments',
'io',
'ipiranga',
'iq',
'ir',
'irish',
'is',
'ist',
'istanbul',
'it',
'itau',
'iwc',
'jaguar',
'java',
'jcb',
'je',
'jetzt',
'jewelry',
'jlc',
'jll',
'jm',
'jo',
'jobs',
'joburg',
'jp',
'jprs',
'juegos',
'kaufen',
'kddi',
'ke',
'kg',
'kh',
'ki',
'kia',
'kim',
'kinder',
'kitchen',
'kiwi',
'km',
'kn',
'koeln',
'komatsu',
'kp',
'kr',
'krd',
'kred',
'kw',
'ky',
'kyoto',
'kz',
'la',
'lacaixa',
'lancaster',
'land',
'landrover',
'lasalle',
'lat',
'latrobe',
'law',
'lawyer',
'lb',
'lc',
'lds',
'lease',
'leclerc',
'legal',
'lexus',
'lgbt',
'li',
'liaison',
'lidl',
'life',
'lighting',
'limited',
'limo',
'linde',
'link',
'live',
'lixil',
'lk',
'loan',
'loans',
'lol',
'london',
'lotte',
'lotto',
'love',
'lr',
'ls',
'lt',
'ltd',
'ltda',
'lu',
'lupin',
'luxe',
'luxury',
'lv',
'ly',
'ma',
'madrid',
'maif',
'maison',
'man',
'management',
'mango',
'market',
'marketing',
'markets',
'marriott',
'mba',
'mc',
'md',
'me',
'media',
'meet',
'melbourne',
'meme',
'memorial',
'men',
'menu',
'mg',
'mh',
'miami',
'microsoft',
'mil',
'mini',
'mk',
'ml',
'mm',
'mma',
'mn',
'mo',
'mobi',
'moda',
'moe',
'moi',
'mom',
'monash',
'money',
'montblanc',
'mormon',
'mortgage',
'moscow',
'motorcycles',
'mov',
'movie',
'movistar',
'mp',
'mq',
'mr',
'ms',
'mt',
'mtn',
'mtpc',
'mtr',
'mu',
'museum',
'mutuelle',
'mv',
'mw',
'mx',
'my',
'mz',
'na',
'nadex',
'nagoya',
'name',
'navy',
'nc',
'ne',
'nec',
'net',
'netbank',
'network',
'neustar',
'new',
'news',
'nexus',
'nf',
'ng',
'ngo',
'nhk',
'ni',
'nico',
'ninja',
'nissan',
'nl',
'no',
'nokia',
'np',
'nr',
'nra',
'nrw',
'ntt',
'nu',
'nyc',
'nz',
'obi',
'office',
'okinawa',
'om',
'omega',
'one',
'ong',
'onl',
'online',
'ooo',
'oracle',
'orange',
'org',
'organic',
'osaka',
'otsuka',
'ovh',
'pa',
'page',
'panerai',
'paris',
'partners',
'parts',
'party',
'pe',
'pet',
'pf',
'pg',
'ph',
'pharmacy',
'philips',
'photo',
'photography',
'photos',
'physio',
'piaget',
'pics',
'pictet',
'pictures',
'pink',
'pizza',
'pk',
'pl',
'place',
'play',
'plumbing',
'plus',
'pm',
'pn',
'pohl',
'poker',
'porn',
'post',
'pr',
'praxi',
'press',
'pro',
'prod',
'productions',
'prof',
'properties',
'property',
'protection',
'ps',
'pt',
'pub',
'pw',
'py',
'qa',
'qpon',
'quebec',
'racing',
're',
'realtor',
'realty',
'recipes',
'red',
'redstone',
'rehab',
'reise',
'reisen',
'reit',
'ren',
'rent',
'rentals',
'repair',
'report',
'republican',
'rest',
'restaurant',
'review',
'reviews',
'rich',
'ricoh',
'rio',
'rip',
'ro',
'rocks',
'rodeo',
'rs',
'rsvp',
'ru',
'ruhr',
'run',
'rw',
'rwe',
'ryukyu',
'sa',
'saarland',
'sakura',
'sale',
'samsung',
'sandvik',
'sandvikcoromant',
'sanofi',
'sap',
'sarl',
'saxo',
'sb',
'sc',
'sca',
'scb',
'schmidt',
'scholarships',
'school',
'schule',
'schwarz',
'science',
'scor',
'scot',
'sd',
'se',
'seat',
'security',
'seek',
'sener',
'services',
'seven',
'sew',
'sex',
'sexy',
'sg',
'sh',
'shiksha',
'shoes',
'show',
'shriram',
'si',
'singles',
'site',
'sj',
'sk',
'ski',
'sky',
'skype',
'sl',
'sm',
'sn',
'sncf',
'so',
'soccer',
'social',
'software',
'sohu',
'solar',
'solutions',
'sony',
'soy',
'space',
'spiegel',
'spreadbetting',
'sr',
'srl',
'st',
'stada',
'starhub',
'statoil',
'stc',
'stcgroup',
'stockholm',
'studio',
'study',
'style',
'su',
'sucks',
'supplies',
'supply',
'support',
'surf',
'surgery',
'suzuki',
'sv',
'swatch',
'swiss',
'sx',
'sy',
'sydney',
'systems',
'sz',
'taipei',
'tatamotors',
'tatar',
'tattoo',
'tax',
'taxi',
'tc',
'td',
'team',
'tech',
'technology',
'tel',
'telefonica',
'temasek',
'tennis',
'tf',
'tg',
'th',
'thd',
'theater',
'theatre',
'tickets',
'tienda',
'tips',
'tires',
'tirol',
'tj',
'tk',
'tl',
'tm',
'tn',
'to',
'today',
'tokyo',
'tools',
'top',
'toray',
'toshiba',
'tours',
'town',
'toyota',
'toys',
'tr',
'trade',
'trading',
'training',
'travel',
'trust',
'tt',
'tui',
'tv',
'tw',
'tz',
'ua',
'ubs',
'ug',
'uk',
'university',
'uno',
'uol',
'us',
'uy',
'uz',
'va',
'vacations',
'vc',
've',
'vegas',
'ventures',
'versicherung',
'vet',
'vg',
'vi',
'viajes',
'video',
'villas',
'vin',
'virgin',
'vision',
'vista',
'vistaprint',
'viva',
'vlaanderen',
'vn',
'vodka',
'vote',
'voting',
'voto',
'voyage',
'vu',
'wales',
'walter',
'wang',
'watch',
'webcam',
'website',
'wed',
'wedding',
'weir',
'wf',
'whoswho',
'wien',
'wiki',
'williamhill',
'win',
'windows',
'wine',
'wme',
'work',
'works',
'world',
'ws',
'wtc',
'wtf',
'xbox',
'xerox',
'xin',
'xn--11b4c3d',
'xn--1qqw23a',
'xn--30rr7y',
'xn--3bst00m',
'xn--3ds443g',
'xn--3e0b707e',
'xn--3pxu8k',
'xn--42c2d9a',
'xn--45brj9c',
'xn--45q11c',
'xn--4gbrim',
'xn--55qw42g',
'xn--55qx5d',
'xn--6frz82g',
'xn--6qq986b3xl',
'xn--80adxhks',
'xn--80ao21a',
'xn--80asehdb',
'xn--80aswg',
'xn--90a3ac',
'xn--90ais',
'xn--9dbq2a',
'xn--9et52u',
'xn--b4w605ferd',
'xn--c1avg',
'xn--c2br7g',
'xn--cg4bki',
'xn--clchc0ea0b2g2a9gcd',
'xn--czr694b',
'xn--czrs0t',
'xn--czru2d',
'xn--d1acj3b',
'xn--d1alf',
'xn--efvy88h',
'xn--estv75g',
'xn--fhbei',
'xn--fiq228c5hs',
'xn--fiq64b',
'xn--fiqs8s',
'xn--fiqz9s',
'xn--fjq720a',
'xn--flw351e',
'xn--fpcrj9c3d',
'xn--fzc2c9e2c',
'xn--gecrj9c',
'xn--h2brj9c',
'xn--hxt814e',
'xn--i1b6b1a6a2e',
'xn--imr513n',
'xn--io0a7i',
'xn--j1aef',
'xn--j1amh',
'xn--j6w193g',
'xn--kcrx77d1x4a',
'xn--kprw13d',
'xn--kpry57d',
'xn--kput3i',
'xn--l1acc',
'xn--lgbbat1ad8j',
'xn--mgb9awbf',
'xn--mgba3a3ejt',
'xn--mgba3a4f16a',
'xn--mgbaam7a8h',
'xn--mgbab2bd',
'xn--mgbayh7gpa',
'xn--mgbbh1a71e',
'xn--mgbc0a9azcg',
'xn--mgberp4a5d4ar',
'xn--mgbpl2fh',
'xn--mgbx4cd0ab',
'xn--mk1bu44c',
'xn--mxtq1m',
'xn--ngbc5azd',
'xn--node',
'xn--nqv7f',
'xn--nqv7fs00ema',
'xn--nyqy26a',
'xn--o3cw4h',
'xn--ogbpf8fl',
'xn--p1acf',
'xn--p1ai',
'xn--pgbs0dh',
'xn--pssy2u',
'xn--q9jyb4c',
'xn--qcka1pmc',
'xn--rhqv96g',
'xn--s9brj9c',
'xn--ses554g',
'xn--t60b56a',
'xn--tckwe',
'xn--unup4y',
'xn--vermgensberater-ctb',
'xn--vermgensberatung-pwb',
'xn--vhquv',
'xn--vuq861b',
'xn--wgbh1c',
'xn--wgbl6a',
'xn--xhq521b',
'xn--xkc2al3hye2a',
'xn--xkc2dl3a5ee0h',
'xn--y9a3aq',
'xn--yfro4i67o',
'xn--ygbi2ammx',
'xn--zfr164b',
'xperia',
'xxx',
'xyz',
'yachts',
'yamaxun',
'yandex',
'ye',
'yodobashi',
'yoga',
'yokohama',
'youtube',
'yt',
'za',
'zara',
'zip',
'zm',
'zone',
'zuerich',
'zw',
'测试',
'परीक्षा',
'佛山',
'集团',
'在线',
'한국',
'ভারত',
'八卦',
'موقع',
'বাংলা',
'公益',
'公司',
'移动',
'我爱你',
'москва',
'испытание',
'қаз',
'онлайн',
'сайт',
'срб',
'бел',
'테스트',
'орг',
'삼성',
'சிங்கப்பூர்',
'商标',
'商城',
'дети',
'мкд',
'טעסט',
'中文网',
'中信',
'中国',
'中國',
'谷歌',
'భారత్',
'ලංකා',
'測試',
'ભારત',
'भारत',
'آزمایشی',
'பரிட்சை',
'संगठन',
'网络',
'укр',
'香港',
'δοκιμή',
'إختبار',
'台湾',
'台灣',
'手机',
'мон',
'الجزائر',
'عمان',
'ایران',
'امارات',
'بازار',
'پاکستان',
'الاردن',
'بھارت',
'المغرب',
'السعودية',
'سودان',
'عراق',
'مليسيا',
'شبكة',
'გე',
'机构',
'组织机构',
'ไทย',
'سورية',
'рус',
'рф',
'تونس',
'みんな',
'グーグル',
'世界',
'ਭਾਰਤ',
'网址',
'游戏',
'vermögensberater',
'vermögensberatung',
'企业',
'مصر',
'قطر',
'广东',
'இலங்கை',
'இந்தியா',
'հայ',
'新加坡',
'فلسطين',
'テスト',
'政务',
);
/**
* @var string
*/
protected $_tld;
/**
* Array for valid Idns
* @see http://www.iana.org/domains/idn-tables/ Official list of supported IDN Chars
* (.AC) Ascension Island http://www.nic.ac/pdf/AC-IDN-Policy.pdf
* (.AR) Argentinia http://www.nic.ar/faqidn.html
* (.AS) American Samoa http://www.nic.as/idn/chars.cfm
* (.AT) Austria http://www.nic.at/en/service/technical_information/idn/charset_converter/
* (.BIZ) International http://www.iana.org/domains/idn-tables/
* (.BR) Brazil http://registro.br/faq/faq6.html
* (.BV) Bouvett Island http://www.norid.no/domeneregistrering/idn/idn_nyetegn.en.html
* (.CA) Canada http://www.iana.org/domains/idn-tables/tables/ca_fr_1.0.html
* (.CAT) Catalan http://www.iana.org/domains/idn-tables/tables/cat_ca_1.0.html
* (.CH) Switzerland https://nic.switch.ch/reg/ocView.action?res=EF6GW2JBPVTG67DLNIQXU234MN6SC33JNQQGI7L6#anhang1
* (.CL) Chile http://www.iana.org/domains/idn-tables/tables/cl_latn_1.0.html
* (.COM) International http://www.verisign.com/information-services/naming-services/internationalized-domain-names/index.html
* (.DE) Germany http://www.denic.de/en/domains/idns/liste.html
* (.DK) Danmark http://www.dk-hostmaster.dk/index.php?id=151
* (.ES) Spain https://www.nic.es/media/2008-05/1210147705287.pdf
* (.FI) Finland http://www.ficora.fi/en/index/palvelut/fiverkkotunnukset/aakkostenkaytto.html
* (.GR) Greece https://grweb.ics.forth.gr/CharacterTable1_en.jsp
* (.HU) Hungary http://www.domain.hu/domain/English/szabalyzat/szabalyzat.html
* (.INFO) International http://www.nic.info/info/idn
* (.IO) British Indian Ocean Territory http://www.nic.io/IO-IDN-Policy.pdf
* (.IR) Iran http://www.nic.ir/Allowable_Characters_dot-iran
* (.IS) Iceland http://www.isnic.is/domain/rules.php
* (.KR) Korea http://www.iana.org/domains/idn-tables/tables/kr_ko-kr_1.0.html
* (.LI) Liechtenstein https://nic.switch.ch/reg/ocView.action?res=EF6GW2JBPVTG67DLNIQXU234MN6SC33JNQQGI7L6#anhang1
* (.LT) Lithuania http://www.domreg.lt/static/doc/public/idn_symbols-en.pdf
* (.MD) Moldova http://www.register.md/
* (.MUSEUM) International http://www.iana.org/domains/idn-tables/tables/museum_latn_1.0.html
* (.NET) International http://www.verisign.com/information-services/naming-services/internationalized-domain-names/index.html
* (.NO) Norway http://www.norid.no/domeneregistrering/idn/idn_nyetegn.en.html
* (.NU) Niue http://www.worldnames.net/
* (.ORG) International http://www.pir.org/index.php?db=content/FAQs&tbl=FAQs_Registrant&id=2
* (.PE) Peru https://www.nic.pe/nuevas_politicas_faq_2.php
* (.PL) Poland http://www.dns.pl/IDN/allowed_character_sets.pdf
* (.PR) Puerto Rico http://www.nic.pr/idn_rules.asp
* (.PT) Portugal https://online.dns.pt/dns_2008/do?com=DS;8216320233;111;+PAGE(4000058)+K-CAT-CODIGO(C.125)+RCNT(100);
* (.RU) Russia http://www.iana.org/domains/idn-tables/tables/ru_ru-ru_1.0.html
* (.RS) Serbia http://www.iana.org/domains/idn-tables/tables/rs_sr-rs_1.0.pdf
* (.SA) Saudi Arabia http://www.iana.org/domains/idn-tables/tables/sa_ar_1.0.html
* (.SE) Sweden http://www.iis.se/english/IDN_campaignsite.shtml?lang=en
* (.SH) Saint Helena http://www.nic.sh/SH-IDN-Policy.pdf
* (.SJ) Svalbard and Jan Mayen http://www.norid.no/domeneregistrering/idn/idn_nyetegn.en.html
* (.TH) Thailand http://www.iana.org/domains/idn-tables/tables/th_th-th_1.0.html
* (.TM) Turkmenistan http://www.nic.tm/TM-IDN-Policy.pdf
* (.TR) Turkey https://www.nic.tr/index.php
* (.UA) Ukraine http://www.iana.org/domains/idn-tables/tables/ua_cyrl_1.2.html
* (.VE) Venice http://www.iana.org/domains/idn-tables/tables/ve_es_1.0.html
* (.VN) Vietnam http://www.vnnic.vn/english/5-6-300-2-2-04-20071115.htm#1.%20Introduction
*
* @var array
*/
protected $_validIdns = array(
'AC' => array(1 => '/^[\x{002d}0-9a-zà-öø-ÿāăąćĉċčďđēėęěĝġģĥħīįĵķĺļľŀłńņňŋőœŕŗřśŝşšţťŧūŭůűųŵŷźżž]{1,63}$/iu'),
'AR' => array(1 => '/^[\x{002d}0-9a-zà-ãç-êìíñ-õü]{1,63}$/iu'),
'AS' => array(1 => '/^[\x{002d}0-9a-zà-öø-ÿāăąćĉċčďđēĕėęěĝğġģĥħĩīĭįıĵķĸĺļľłńņňŋōŏőœŕŗřśŝşšţťŧũūŭůűųŵŷźż]{1,63}$/iu'),
'AT' => array(1 => '/^[\x{002d}0-9a-zà-öø-ÿœšž]{1,63}$/iu'),
'BIZ' => 'Hostname/Biz.php',
'BR' => array(1 => '/^[\x{002d}0-9a-zà-ãçéíó-õúü]{1,63}$/iu'),
'BV' => array(1 => '/^[\x{002d}0-9a-zàáä-éêñ-ôöøüčđńŋšŧž]{1,63}$/iu'),
'CA' => array(1 => '/^[\x{002d}0-9a-zàâæçéèêëîïôœùûüÿ\x{00E0}\x{00E2}\x{00E7}\x{00E8}\x{00E9}\x{00EA}\x{00EB}\x{00EE}\x{00EF}\x{00F4}\x{00F9}\x{00FB}\x{00FC}\x{00E6}\x{0153}\x{00FF}]{1,63}$/iu'),
'CAT' => array(1 => '/^[\x{002d}0-9a-z·àç-éíïòóúü]{1,63}$/iu'),
'CH' => array(1 => '/^[\x{002d}0-9a-zà-öø-ÿœ]{1,63}$/iu'),
'CL' => array(1 => '/^[\x{002d}0-9a-záéíñóúü]{1,63}$/iu'),
'CN' => 'Hostname/Cn.php',
'COM' => 'Hostname/Com.php',
'DE' => array(1 => '/^[\x{002d}0-9a-zà-öø-ÿăąāćĉčċďđĕěėęēğĝġģĥħĭĩįīıĵķĺľļłńňņŋŏőōœĸŕřŗśŝšşťßţŧŭůűũųūŵŷźžż]{1,63}$/iu'),
'DK' => array(1 => '/^[\x{002d}0-9a-zäéöüæøå]{1,63}$/iu'),
'ES' => array(1 => '/^[\x{002d}0-9a-zàáçèéíïñòóúü·]{1,63}$/iu'),
'EU' => array(1 => '/^[\x{002d}0-9a-zà-öø-ÿ]{1,63}$/iu',
2 => '/^[\x{002d}0-9a-zāăąćĉċčďđēĕėęěĝğġģĥħĩīĭįıĵķĺļľŀłńņňʼnŋōŏőœŕŗřśŝšťŧũūŭůűųŵŷźżž]{1,63}$/iu',
3 => '/^[\x{002d}0-9a-zșț]{1,63}$/iu',
4 => '/^[\x{002d}0-9a-zΐάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύώ]{1,63}$/iu',
5 => '/^[\x{002d}0-9a-zабвгдежзийклмнопрстуфхцчшщъыьэюя]{1,63}$/iu',
6 => '/^[\x{002d}0-9a-zἀ-ἇἐ-ἕἠ-ἧἰ-ἷὀ-ὅὐ-ὗὠ-ὧὰ-ὼώᾀ-ᾇᾐ-ᾗᾠ-ᾧᾰ-ᾴᾶᾷῂῃῄῆῇῐ-ῒΐῖῗῠ-ῧῲῳῴῶῷ]{1,63}$/iu'),
'FI' => array(1 => '/^[\x{002d}0-9a-zäåö]{1,63}$/iu'),
'GR' => array(1 => '/^[\x{002d}0-9a-zΆΈΉΊΌΎ-ΡΣ-ώἀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼῂῃῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲῳῴῶ-ῼ]{1,63}$/iu'),
'HK' => 'Hostname/Cn.php',
'HU' => array(1 => '/^[\x{002d}0-9a-záéíóöúüőű]{1,63}$/iu'),
'IL' => array(1 => '/^[\x{002d}0-9\x{05D0}-\x{05EA}]{1,63}$/iu',
2 => '/^[\x{002d}0-9a-z]{1,63}$/i'),
'INFO'=> array(1 => '/^[\x{002d}0-9a-zäåæéöøü]{1,63}$/iu',
2 => '/^[\x{002d}0-9a-záéíóöúüőű]{1,63}$/iu',
3 => '/^[\x{002d}0-9a-záæéíðóöúýþ]{1,63}$/iu',
4 => '/^[\x{AC00}-\x{D7A3}]{1,17}$/iu',
5 => '/^[\x{002d}0-9a-zāčēģīķļņōŗšūž]{1,63}$/iu',
6 => '/^[\x{002d}0-9a-ząčėęįšūųž]{1,63}$/iu',
7 => '/^[\x{002d}0-9a-zóąćęłńśźż]{1,63}$/iu',
8 => '/^[\x{002d}0-9a-záéíñóúü]{1,63}$/iu'),
'IO' => array(1 => '/^[\x{002d}0-9a-zà-öø-ÿăąāćĉčċďđĕěėęēğĝġģĥħĭĩįīıĵķĺľļłńňņŋŏőōœĸŕřŗśŝšşťţŧŭůűũųūŵŷźžż]{1,63}$/iu'),
'IS' => array(1 => '/^[\x{002d}0-9a-záéýúíóþæöð]{1,63}$/iu'),
'IT' => array(1 => '/^[\x{002d}0-9a-zàâäèéêëìîïòôöùûüæœçÿß-]{1,63}$/iu'),
'JP' => 'Hostname/Jp.php',
'KR' => array(1 => '/^[\x{AC00}-\x{D7A3}]{1,17}$/iu'),
'LI' => array(1 => '/^[\x{002d}0-9a-zà-öø-ÿœ]{1,63}$/iu'),
'LT' => array(1 => '/^[\x{002d}0-9ąčęėįšųūž]{1,63}$/iu'),
'MD' => array(1 => '/^[\x{002d}0-9ăâîşţ]{1,63}$/iu'),
'MUSEUM' => array(1 => '/^[\x{002d}0-9a-zà-öø-ÿāăąćċčďđēėęěğġģħīįıķĺļľłńņňŋōőœŕŗřśşšţťŧūůűųŵŷźżžǎǐǒǔ\x{01E5}\x{01E7}\x{01E9}\x{01EF}ə\x{0292}ẁẃẅỳ]{1,63}$/iu'),
'NET' => 'Hostname/Com.php',
'NO' => array(1 => '/^[\x{002d}0-9a-zàáä-éêñ-ôöøüčđńŋšŧž]{1,63}$/iu'),
'NU' => 'Hostname/Com.php',
'ORG' => array(1 => '/^[\x{002d}0-9a-záéíñóúü]{1,63}$/iu',
2 => '/^[\x{002d}0-9a-zóąćęłńśźż]{1,63}$/iu',
3 => '/^[\x{002d}0-9a-záäåæéëíðóöøúüýþ]{1,63}$/iu',
4 => '/^[\x{002d}0-9a-záéíóöúüőű]{1,63}$/iu',
5 => '/^[\x{002d}0-9a-ząčėęįšūųž]{1,63}$/iu',
6 => '/^[\x{AC00}-\x{D7A3}]{1,17}$/iu',
7 => '/^[\x{002d}0-9a-zāčēģīķļņōŗšūž]{1,63}$/iu'),
'PE' => array(1 => '/^[\x{002d}0-9a-zñáéíóúü]{1,63}$/iu'),
'PL' => array(1 => '/^[\x{002d}0-9a-zāčēģīķļņōŗšūž]{1,63}$/iu',
2 => '/^[\x{002d}а-ик-ш\x{0450}ѓѕјљњќџ]{1,63}$/iu',
3 => '/^[\x{002d}0-9a-zâîăşţ]{1,63}$/iu',
4 => '/^[\x{002d}0-9а-яё\x{04C2}]{1,63}$/iu',
5 => '/^[\x{002d}0-9a-zàáâèéêìíîòóôùúûċġħż]{1,63}$/iu',
6 => '/^[\x{002d}0-9a-zàäåæéêòóôöøü]{1,63}$/iu',
7 => '/^[\x{002d}0-9a-zóąćęłńśźż]{1,63}$/iu',
8 => '/^[\x{002d}0-9a-zàáâãçéêíòóôõúü]{1,63}$/iu',
9 => '/^[\x{002d}0-9a-zâîăşţ]{1,63}$/iu',
10=> '/^[\x{002d}0-9a-záäéíóôúýčďĺľňŕšťž]{1,63}$/iu',
11=> '/^[\x{002d}0-9a-zçë]{1,63}$/iu',
12=> '/^[\x{002d}0-9а-ик-шђјљњћџ]{1,63}$/iu',
13=> '/^[\x{002d}0-9a-zćčđšž]{1,63}$/iu',
14=> '/^[\x{002d}0-9a-zâçöûüğış]{1,63}$/iu',
15=> '/^[\x{002d}0-9a-záéíñóúü]{1,63}$/iu',
16=> '/^[\x{002d}0-9a-zäõöüšž]{1,63}$/iu',
17=> '/^[\x{002d}0-9a-zĉĝĥĵŝŭ]{1,63}$/iu',
18=> '/^[\x{002d}0-9a-zâäéëîô]{1,63}$/iu',
19=> '/^[\x{002d}0-9a-zàáâäåæçèéêëìíîïðñòôöøùúûüýćčłńřśš]{1,63}$/iu',
20=> '/^[\x{002d}0-9a-zäåæõöøüšž]{1,63}$/iu',
21=> '/^[\x{002d}0-9a-zàáçèéìíòóùú]{1,63}$/iu',
22=> '/^[\x{002d}0-9a-zàáéíóöúüőű]{1,63}$/iu',
23=> '/^[\x{002d}0-9ΐά-ώ]{1,63}$/iu',
24=> '/^[\x{002d}0-9a-zàáâåæçèéêëðóôöøüþœ]{1,63}$/iu',
25=> '/^[\x{002d}0-9a-záäéíóöúüýčďěňřšťůž]{1,63}$/iu',
26=> '/^[\x{002d}0-9a-z·àçèéíïòóúü]{1,63}$/iu',
27=> '/^[\x{002d}0-9а-ъьюя\x{0450}\x{045D}]{1,63}$/iu',
28=> '/^[\x{002d}0-9а-яёіў]{1,63}$/iu',
29=> '/^[\x{002d}0-9a-ząčėęįšūųž]{1,63}$/iu',
30=> '/^[\x{002d}0-9a-záäåæéëíðóöøúüýþ]{1,63}$/iu',
31=> '/^[\x{002d}0-9a-zàâæçèéêëîïñôùûüÿœ]{1,63}$/iu',
32=> '/^[\x{002d}0-9а-щъыьэюяёєіїґ]{1,63}$/iu',
33=> '/^[\x{002d}0-9א-ת]{1,63}$/iu'),
'PR' => array(1 => '/^[\x{002d}0-9a-záéíóúñäëïüöâêîôûàèùæçœãõ]{1,63}$/iu'),
'PT' => array(1 => '/^[\x{002d}0-9a-záàâãçéêíóôõú]{1,63}$/iu'),
'RS' => array(1 => '/^[\x{002D}\x{0030}-\x{0039}\x{0061}-\x{007A}\x{0107}\x{010D}\x{0111}\x{0161}\x{017E}]{1,63}$/iu)'),
'RU' => array(1 => '/^[\x{002d}0-9а-яё]{1,63}$/iu'),
'SA' => array(1 => '/^[\x{002d}.0-9\x{0621}-\x{063A}\x{0641}-\x{064A}\x{0660}-\x{0669}]{1,63}$/iu'),
'SE' => array(1 => '/^[\x{002d}0-9a-zäåéöü]{1,63}$/iu'),
'SH' => array(1 => '/^[\x{002d}0-9a-zà-öø-ÿăąāćĉčċďđĕěėęēğĝġģĥħĭĩįīıĵķĺľļłńňņŋŏőōœĸŕřŗśŝšşťţŧŭůűũųūŵŷźžż]{1,63}$/iu'),
'SI' => array(
1 => '/^[\x{002d}0-9a-zà-öø-ÿ]{1,63}$/iu',
2 => '/^[\x{002d}0-9a-zāăąćĉċčďđēĕėęěĝğġģĥħĩīĭįıĵķĺļľŀłńņňʼnŋōŏőœŕŗřśŝšťŧũūŭůűųŵŷźżž]{1,63}$/iu',
3 => '/^[\x{002d}0-9a-zșț]{1,63}$/iu'),
'SJ' => array(1 => '/^[\x{002d}0-9a-zàáä-éêñ-ôöøüčđńŋšŧž]{1,63}$/iu'),
'TH' => array(1 => '/^[\x{002d}0-9a-z\x{0E01}-\x{0E3A}\x{0E40}-\x{0E4D}\x{0E50}-\x{0E59}]{1,63}$/iu'),
'TM' => array(1 => '/^[\x{002d}0-9a-zà-öø-ÿāăąćĉċčďđēėęěĝġģĥħīįĵķĺļľŀłńņňŋőœŕŗřśŝşšţťŧūŭůűųŵŷźżž]{1,63}$/iu'),
'TW' => 'Hostname/Cn.php',
'TR' => array(1 => '/^[\x{002d}0-9a-zğıüşöç]{1,63}$/iu'),
'UA' => array(1 => '/^[\x{002d}0-9a-zабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓєѕіїјљњћќѝўџґӂʼ]{1,63}$/iu'),
'VE' => array(1 => '/^[\x{002d}0-9a-záéíóúüñ]{1,63}$/iu'),
'VN' => array(1 => '/^[ÀÁÂÃÈÉÊÌÍÒÓÔÕÙÚÝàáâãèéêìíòóôõùúýĂăĐđĨĩŨũƠơƯư\x{1EA0}-\x{1EF9}]{1,63}$/iu'),
'мон' => array(1 => '/^[\x{002d}0-9\x{0430}-\x{044F}]{1,63}$/iu'),
'срб' => array(1 => '/^[\x{002d}0-9а-ик-шђјљњћџ]{1,63}$/iu'),
'сайт' => array(1 => '/^[\x{002d}0-9а-яёіїѝйўґг]{1,63}$/iu'),
'онлайн' => array(1 => '/^[\x{002d}0-9а-яёіїѝйўґг]{1,63}$/iu'),
'中国' => 'Hostname/Cn.php',
'中國' => 'Hostname/Cn.php',
'ලංකා' => array(1 => '/^[\x{0d80}-\x{0dff}]{1,63}$/iu'),
'香港' => 'Hostname/Cn.php',
'台湾' => 'Hostname/Cn.php',
'台灣' => 'Hostname/Cn.php',
'امارات' => array(1 => '/^[\x{0621}-\x{0624}\x{0626}-\x{063A}\x{0641}\x{0642}\x{0644}-\x{0648}\x{067E}\x{0686}\x{0698}\x{06A9}\x{06AF}\x{06CC}\x{06F0}-\x{06F9}]{1,30}$/iu'),
'الاردن' => array(1 => '/^[\x{0621}-\x{0624}\x{0626}-\x{063A}\x{0641}\x{0642}\x{0644}-\x{0648}\x{067E}\x{0686}\x{0698}\x{06A9}\x{06AF}\x{06CC}\x{06F0}-\x{06F9}]{1,30}$/iu'),
'السعودية' => array(1 => '/^[\x{0621}-\x{0624}\x{0626}-\x{063A}\x{0641}\x{0642}\x{0644}-\x{0648}\x{067E}\x{0686}\x{0698}\x{06A9}\x{06AF}\x{06CC}\x{06F0}-\x{06F9}]{1,30}$/iu'),
'ไทย' => array(1 => '/^[\x{002d}0-9a-z\x{0E01}-\x{0E3A}\x{0E40}-\x{0E4D}\x{0E50}-\x{0E59}]{1,63}$/iu'),
'рф' => array(1 => '/^[\x{002d}0-9а-яё]{1,63}$/iu'),
'تونس' => array(1 => '/^[\x{0621}-\x{0624}\x{0626}-\x{063A}\x{0641}\x{0642}\x{0644}-\x{0648}\x{067E}\x{0686}\x{0698}\x{06A9}\x{06AF}\x{06CC}\x{06F0}-\x{06F9}]{1,30}$/iu'),
'مصر' => array(1 => '/^[\x{0621}-\x{0624}\x{0626}-\x{063A}\x{0641}\x{0642}\x{0644}-\x{0648}\x{067E}\x{0686}\x{0698}\x{06A9}\x{06AF}\x{06CC}\x{06F0}-\x{06F9}]{1,30}$/iu'),
'இலங்கை' => array(1 => '/^[\x{0b80}-\x{0bff}]{1,63}$/iu'),
'فلسطين' => array(1 => '/^[\x{0621}-\x{0624}\x{0626}-\x{063A}\x{0641}\x{0642}\x{0644}-\x{0648}\x{067E}\x{0686}\x{0698}\x{06A9}\x{06AF}\x{06CC}\x{06F0}-\x{06F9}]{1,30}$/iu'),
'شبكة' => array(1 => '/^[\x{0621}-\x{0624}\x{0626}-\x{063A}\x{0641}\x{0642}\x{0644}-\x{0648}\x{067E}\x{0686}\x{0698}\x{06A9}\x{06AF}\x{06CC}\x{06F0}-\x{06F9}]{1,30}$/iu'),
);
protected $_idnLength = array(
'BIZ' => array(5 => 17, 11 => 15, 12 => 20),
'CN' => array(1 => 20),
'COM' => array(3 => 17, 5 => 20),
'HK' => array(1 => 15),
'INFO'=> array(4 => 17),
'KR' => array(1 => 17),
'NET' => array(3 => 17, 5 => 20),
'ORG' => array(6 => 17),
'TW' => array(1 => 20),
'ایران' => array(1 => 30),
'中国' => array(1 => 20),
'公司' => array(1 => 20),
'网络' => array(1 => 20),
);
protected $_options = array(
'allow' => self::ALLOW_DNS,
'idn' => true,
'tld' => true,
'ip' => null
);
/**
* Sets validator options
*
* @see http://www.iana.org/cctld/specifications-policies-cctlds-01apr02.htm Technical Specifications for ccTLDs
* @param array $options Validator options
*/
public function __construct($options = array())
{
if ($options instanceof Zend_Config) {
$options = $options->toArray();
} else if (!is_array($options)) {
$options = func_get_args();
$temp['allow'] = array_shift($options);
if (!empty($options)) {
$temp['idn'] = array_shift($options);
}
if (!empty($options)) {
$temp['tld'] = array_shift($options);
}
if (!empty($options)) {
$temp['ip'] = array_shift($options);
}
$options = $temp;
}
$options += $this->_options;
$this->setOptions($options);
}
/**
* Returns all set options
*
* @return array
*/
public function getOptions()
{
return $this->_options;
}
/**
* Sets the options for this validator
*
* @param array $options
* @return Zend_Validate_Hostname
*/
public function setOptions($options)
{
if (array_key_exists('allow', $options)) {
$this->setAllow($options['allow']);
}
if (array_key_exists('idn', $options)) {
$this->setValidateIdn($options['idn']);
}
if (array_key_exists('tld', $options)) {
$this->setValidateTld($options['tld']);
}
if (array_key_exists('ip', $options)) {
$this->setIpValidator($options['ip']);
}
return $this;
}
/**
* Returns the set ip validator
*
* @return Zend_Validate_Ip
*/
public function getIpValidator()
{
return $this->_options['ip'];
}
/**
* @param Zend_Validate_Ip $ipValidator OPTIONAL
* @return Zend_Validate_Hostname
*/
public function setIpValidator(Zend_Validate_Ip $ipValidator = null)
{
if ($ipValidator === null) {
$ipValidator = new Zend_Validate_Ip();
}
$this->_options['ip'] = $ipValidator;
return $this;
}
/**
* Returns the allow option
*
* @return integer
*/
public function getAllow()
{
return $this->_options['allow'];
}
/**
* Sets the allow option
*
* @param integer $allow
* @return Zend_Validate_Hostname Provides a fluent interface
*/
public function setAllow($allow)
{
$this->_options['allow'] = $allow;
return $this;
}
/**
* Returns the set idn option
*
* @return boolean
*/
public function getValidateIdn()
{
return $this->_options['idn'];
}
/**
* Set whether IDN domains are validated
*
* This only applies when DNS hostnames are validated
*
* @param boolean $allowed Set allowed to true to validate IDNs, and false to not validate them
* @return $this
*/
public function setValidateIdn ($allowed)
{
$this->_options['idn'] = (bool) $allowed;
return $this;
}
/**
* Returns the set tld option
*
* @return boolean
*/
public function getValidateTld()
{
return $this->_options['tld'];
}
/**
* Set whether the TLD element of a hostname is validated
*
* This only applies when DNS hostnames are validated
*
* @param boolean $allowed Set allowed to true to validate TLDs, and false to not validate them
* @return $this
*/
public function setValidateTld ($allowed)
{
$this->_options['tld'] = (bool) $allowed;
return $this;
}
/**
* Defined by Zend_Validate_Interface
*
* Returns true if and only if the $value is a valid hostname with respect to the current allow option
*
* @param string $value
* @throws Zend_Validate_Exception if a fatal error occurs for validation process
* @return boolean
*/
public function isValid($value)
{
if (!is_string($value)) {
$this->_error(self::INVALID);
return false;
}
$this->_setValue($value);
// Check input against IP address schema
if (preg_match('/^[0-9a-f:.]*$/i', $value) &&
$this->_options['ip']->setTranslator($this->getTranslator())->isValid($value)) {
if (!($this->_options['allow'] & self::ALLOW_IP)) {
$this->_error(self::IP_ADDRESS_NOT_ALLOWED);
return false;
} else {
return true;
}
}
// RFC3986 3.2.2 states:
//
// The rightmost domain label of a fully qualified domain name
// in DNS may be followed by a single "." and should be if it is
// necessary to distinguish between the complete domain name and
// some local domain.
//
// (see ZF-6363)
// Local hostnames are allowed to be partitial (ending '.')
if ($this->_options['allow'] & self::ALLOW_LOCAL) {
if (substr($value, -1) === '.') {
$value = substr($value, 0, -1);
if (substr($value, -1) === '.') {
// Empty hostnames (ending '..') are not allowed
$this->_error(self::INVALID_LOCAL_NAME);
return false;
}
}
}
$domainParts = explode('.', $value);
// Prevent partitial IP V4 adresses (ending '.')
if ((count($domainParts) == 4) && preg_match('/^[0-9.a-e:.]*$/i', $value) &&
$this->_options['ip']->setTranslator($this->getTranslator())->isValid($value)) {
$this->_error(self::INVALID_LOCAL_NAME);
}
// Check input against DNS hostname schema
if ((count($domainParts) > 1) && (strlen($value) >= 4) && (strlen($value) <= 254)) {
$status = false;
$origenc = PHP_VERSION_ID < 50600
? iconv_get_encoding('internal_encoding')
: ini_get('default_charset');
if (PHP_VERSION_ID < 50600) {
iconv_set_encoding('internal_encoding', 'UTF-8');
} else {
ini_set('default_charset', 'UTF-8');
}
do {
// First check TLD
$matches = array();
if (preg_match('/([^.]{2,63})$/iu', end($domainParts), $matches)
|| (array_key_exists(end($domainParts), $this->_validIdns))) {
reset($domainParts);
// Hostname characters are: *(label dot)(label dot label); max 254 chars
// label: id-prefix [*ldh{61} id-prefix]; max 63 chars
// id-prefix: alpha / digit
// ldh: alpha / digit / dash
// Match TLD against known list
$this->_tld = $matches[1];
if ($this->_options['tld']) {
if (!in_array(strtolower($this->_tld), $this->_validTlds)
&& !in_array($this->_tld, $this->_validTlds)) {
$this->_error(self::UNKNOWN_TLD);
$status = false;
break;
}
// We have already validated that the TLD is fine. We don't want it to go through the below
// checks as new UTF-8 TLDs will incorrectly fail if there is no IDN regex for it.
array_pop($domainParts);
}
/**
* Match against IDN hostnames
* Note: Keep label regex short to avoid issues with long patterns when matching IDN hostnames
* @see Zend_Validate_Hostname_Interface
*/
$regexChars = array(0 => '/^[a-z0-9\x2d]{1,63}$/i');
if ($this->_options['idn'] && isset($this->_validIdns[strtoupper($this->_tld)])) {
if (is_string($this->_validIdns[strtoupper($this->_tld)])) {
$regexChars += include($this->_validIdns[strtoupper($this->_tld)]);
} else {
$regexChars += $this->_validIdns[strtoupper($this->_tld)];
}
}
// Check each hostname part
$check = 0;
foreach ($domainParts as $domainPart) {
// If some domain part is empty (i.e. zend..com), it's invalid
if (empty($domainPart) && $domainPart !== '0') {
$this->_error(self::INVALID_HOSTNAME);
return false;
}
// Decode Punycode domainnames to IDN
if (strpos($domainPart, 'xn--') === 0) {
$domainPart = $this->decodePunycode(substr($domainPart, 4));
if ($domainPart === false) {
return false;
}
}
// Check dash (-) does not start, end or appear in 3rd and 4th positions
if ((strpos($domainPart, '-') === 0)
|| ((strlen($domainPart) > 2) && (strpos($domainPart, '-', 2) == 2) && (strpos($domainPart, '-', 3) == 3))
|| (strpos($domainPart, '-') === (strlen($domainPart) - 1))) {
$this->_error(self::INVALID_DASH);
$status = false;
break 2;
}
// Check each domain part
$checked = false;
foreach($regexChars as $regexKey => $regexChar) {
$status = preg_match($regexChar, $domainPart);
if ($status > 0) {
$length = 63;
if (array_key_exists(strtoupper($this->_tld), $this->_idnLength)
&& (array_key_exists($regexKey, $this->_idnLength[strtoupper($this->_tld)]))) {
$length = $this->_idnLength[strtoupper($this->_tld)];
}
if (iconv_strlen($domainPart, 'UTF-8') > $length) {
$this->_error(self::INVALID_HOSTNAME);
} else {
$checked = true;
break;
}
}
}
if ($checked) {
++$check;
}
}
// If one of the labels doesn't match, the hostname is invalid
if ($check !== count($domainParts)) {
$this->_error(self::INVALID_HOSTNAME_SCHEMA);
$status = false;
}
} else {
// Hostname not long enough
$this->_error(self::UNDECIPHERABLE_TLD);
$status = false;
}
} while (false);
if (PHP_VERSION_ID < 50600) {
iconv_set_encoding('internal_encoding', $origenc);
} else {
ini_set('default_charset', $origenc);
}
// If the input passes as an Internet domain name, and domain names are allowed, then the hostname
// passes validation
if ($status && ($this->_options['allow'] & self::ALLOW_DNS)) {
return true;
}
} else if ($this->_options['allow'] & self::ALLOW_DNS) {
$this->_error(self::INVALID_HOSTNAME);
}
// Check for URI Syntax (RFC3986)
if ($this->_options['allow'] & self::ALLOW_URI) {
if (preg_match("/^([a-zA-Z0-9-._~!$&\'()*+,;=]|%[[:xdigit:]]{2}){1,254}$/i", $value)) {
return true;
} else {
$this->_error(self::INVALID_URI);
}
}
// Check input against local network name schema; last chance to pass validation
$regexLocal = '/^(([a-zA-Z0-9\x2d]{1,63}\x2e)*[a-zA-Z0-9\x2d]{1,63}[\x2e]{0,1}){1,254}$/';
$status = @preg_match($regexLocal, $value);
// If the input passes as a local network name, and local network names are allowed, then the
// hostname passes validation
$allowLocal = $this->_options['allow'] & self::ALLOW_LOCAL;
if ($status && $allowLocal) {
return true;
}
// If the input does not pass as a local network name, add a message
if (!$status) {
$this->_error(self::INVALID_LOCAL_NAME);
}
// If local network names are not allowed, add a message
if ($status && !$allowLocal) {
$this->_error(self::LOCAL_NAME_NOT_ALLOWED);
}
return false;
}
/**
* Decodes a punycode encoded string to it's original utf8 string
* In case of a decoding failure the original string is returned
*
* @param string $encoded Punycode encoded string to decode
* @return string
*/
protected function decodePunycode($encoded)
{
if (!preg_match('/^[a-z0-9-]+$/i', $encoded)) {
// no punycode encoded string
$this->_error(self::CANNOT_DECODE_PUNYCODE);
return false;
}
$decoded = array();
$separator = strrpos($encoded, '-');
if ($separator > 0) {
for ($x = 0; $x < $separator; ++$x) {
// prepare decoding matrix
$decoded[] = ord($encoded[$x]);
}
}
$lengthd = count($decoded);
$lengthe = strlen($encoded);
// decoding
$init = true;
$base = 72;
$index = 0;
$char = 0x80;
for ($indexe = ($separator) ? ($separator + 1) : 0; $indexe < $lengthe; ++$lengthd) {
for ($old_index = $index, $pos = 1, $key = 36; 1 ; $key += 36) {
$hex = ord($encoded[$indexe++]);
$digit = ($hex - 48 < 10) ? $hex - 22
: (($hex - 65 < 26) ? $hex - 65
: (($hex - 97 < 26) ? $hex - 97
: 36));
$index += $digit * $pos;
$tag = ($key <= $base) ? 1 : (($key >= $base + 26) ? 26 : ($key - $base));
if ($digit < $tag) {
break;
}
$pos = (int) ($pos * (36 - $tag));
}
$delta = intval($init ? (($index - $old_index) / 700) : (($index - $old_index) / 2));
$delta += intval($delta / ($lengthd + 1));
for ($key = 0; $delta > 910 / 2; $key += 36) {
$delta = intval($delta / 35);
}
$base = intval($key + 36 * $delta / ($delta + 38));
$init = false;
$char += (int) ($index / ($lengthd + 1));
$index %= ($lengthd + 1);
if ($lengthd > 0) {
for ($i = $lengthd; $i > $index; $i--) {
$decoded[$i] = $decoded[($i - 1)];
}
}
$decoded[$index++] = $char;
}
// convert decoded ucs4 to utf8 string
foreach ($decoded as $key => $value) {
if ($value < 128) {
$decoded[$key] = chr($value);
} elseif ($value < (1 << 11)) {
$decoded[$key] = chr(192 + ($value >> 6));
$decoded[$key] .= chr(128 + ($value & 63));
} elseif ($value < (1 << 16)) {
$decoded[$key] = chr(224 + ($value >> 12));
$decoded[$key] .= chr(128 + (($value >> 6) & 63));
$decoded[$key] .= chr(128 + ($value & 63));
} elseif ($value < (1 << 21)) {
$decoded[$key] = chr(240 + ($value >> 18));
$decoded[$key] .= chr(128 + (($value >> 12) & 63));
$decoded[$key] .= chr(128 + (($value >> 6) & 63));
$decoded[$key] .= chr(128 + ($value & 63));
} else {
$this->_error(self::CANNOT_DECODE_PUNYCODE);
return false;
}
}
return implode($decoded);
}
}
|