sync
authorAlan Knowles <alan@roojs.com>
Fri, 22 Jun 2018 05:38:28 +0000 (13:38 +0800)
committerAlan Knowles <alan@roojs.com>
Fri, 22 Jun 2018 05:38:28 +0000 (13:38 +0800)
33 files changed:
Fpdf/font/courier.php
Fpdf/font/helvetica.php
Fpdf/font/helveticab.php
Fpdf/font/helveticabi.php
Fpdf/font/helveticai.php
Fpdf/font/symbol.php
Fpdf/font/times.php
Fpdf/font/timesb.php
Fpdf/font/timesbi.php
Fpdf/font/timesi.php
Fpdf/font/unifont/ttfonts.php
Fpdf/font/zapfdingbats.php
Net/DNS.php
Net/DNS/Header.php
Net/DNS/Packet.php
Net/DNS/Question.php
Net/DNS/RR.php
Net/DNS/RR/A.php
Net/DNS/RR/AAAA.php
Net/DNS/RR/CNAME.php
Net/DNS/RR/HINFO.php
Net/DNS/RR/MX.php
Net/DNS/RR/NAPTR.php
Net/DNS/RR/NS.php
Net/DNS/RR/PTR.php
Net/DNS/RR/RP.php
Net/DNS/RR/SOA.php
Net/DNS/RR/SPF.php
Net/DNS/RR/SRV.php
Net/DNS/RR/TSIG.php
Net/DNS/RR/TXT.php
Net/DNS/Resolver.php
XML/Tree/Morph.php

index 4c009f3..913f9a4 100644 (file)
@@ -1,7 +1,7 @@
-<?php
-for($i=0;$i<=255;$i++)
-       $fpdf_charwidths['courier'][chr($i)]=600;
-$fpdf_charwidths['courierB']=$fpdf_charwidths['courier'];
-$fpdf_charwidths['courierI']=$fpdf_charwidths['courier'];
-$fpdf_charwidths['courierBI']=$fpdf_charwidths['courier'];
-?>
+<?php\r
+for($i=0;$i<=255;$i++)\r
+       $fpdf_charwidths['courier'][chr($i)]=600;\r
+$fpdf_charwidths['courierB']=$fpdf_charwidths['courier'];\r
+$fpdf_charwidths['courierI']=$fpdf_charwidths['courier'];\r
+$fpdf_charwidths['courierBI']=$fpdf_charwidths['courier'];\r
+?>\r
index 8fa7683..ca94cdf 100644 (file)
@@ -1,15 +1,15 @@
-<?php
-$fpdf_charwidths['helvetica']=array(
-       chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278,
-       chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>278,'"'=>355,'#'=>556,'$'=>556,'%'=>889,'&'=>667,'\''=>191,'('=>333,')'=>333,'*'=>389,'+'=>584,
-       ','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>278,';'=>278,'<'=>584,'='=>584,'>'=>584,'?'=>556,'@'=>1015,'A'=>667,
-       'B'=>667,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>500,'K'=>667,'L'=>556,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944,
-       'X'=>667,'Y'=>667,'Z'=>611,'['=>278,'\\'=>278,']'=>278,'^'=>469,'_'=>556,'`'=>333,'a'=>556,'b'=>556,'c'=>500,'d'=>556,'e'=>556,'f'=>278,'g'=>556,'h'=>556,'i'=>222,'j'=>222,'k'=>500,'l'=>222,'m'=>833,
-       'n'=>556,'o'=>556,'p'=>556,'q'=>556,'r'=>333,'s'=>500,'t'=>278,'u'=>556,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>500,'{'=>334,'|'=>260,'}'=>334,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>222,chr(131)=>556,
-       chr(132)=>333,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>222,chr(146)=>222,chr(147)=>333,chr(148)=>333,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
-       chr(154)=>500,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>260,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333,
-       chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>556,chr(182)=>537,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>667,chr(193)=>667,chr(194)=>667,chr(195)=>667,chr(196)=>667,chr(197)=>667,
-       chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
-       chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>500,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>556,chr(241)=>556,
-       chr(242)=>556,chr(243)=>556,chr(244)=>556,chr(245)=>556,chr(246)=>556,chr(247)=>584,chr(248)=>611,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>500,chr(254)=>556,chr(255)=>500);
-?>
+<?php\r
+$fpdf_charwidths['helvetica']=array(\r
+       chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278,\r
+       chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>278,'"'=>355,'#'=>556,'$'=>556,'%'=>889,'&'=>667,'\''=>191,'('=>333,')'=>333,'*'=>389,'+'=>584,\r
+       ','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>278,';'=>278,'<'=>584,'='=>584,'>'=>584,'?'=>556,'@'=>1015,'A'=>667,\r
+       'B'=>667,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>500,'K'=>667,'L'=>556,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944,\r
+       'X'=>667,'Y'=>667,'Z'=>611,'['=>278,'\\'=>278,']'=>278,'^'=>469,'_'=>556,'`'=>333,'a'=>556,'b'=>556,'c'=>500,'d'=>556,'e'=>556,'f'=>278,'g'=>556,'h'=>556,'i'=>222,'j'=>222,'k'=>500,'l'=>222,'m'=>833,\r
+       'n'=>556,'o'=>556,'p'=>556,'q'=>556,'r'=>333,'s'=>500,'t'=>278,'u'=>556,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>500,'{'=>334,'|'=>260,'}'=>334,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>222,chr(131)=>556,\r
+       chr(132)=>333,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>222,chr(146)=>222,chr(147)=>333,chr(148)=>333,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,\r
+       chr(154)=>500,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>260,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333,\r
+       chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>556,chr(182)=>537,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>667,chr(193)=>667,chr(194)=>667,chr(195)=>667,chr(196)=>667,chr(197)=>667,\r
+       chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,\r
+       chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>500,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>556,chr(241)=>556,\r
+       chr(242)=>556,chr(243)=>556,chr(244)=>556,chr(245)=>556,chr(246)=>556,chr(247)=>584,chr(248)=>611,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>500,chr(254)=>556,chr(255)=>500);\r
+?>\r
index a8473c9..276cfa8 100644 (file)
@@ -1,15 +1,15 @@
-<?php
-$fpdf_charwidths['helveticaB']=array(
-       chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278,
-       chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>333,'"'=>474,'#'=>556,'$'=>556,'%'=>889,'&'=>722,'\''=>238,'('=>333,')'=>333,'*'=>389,'+'=>584,
-       ','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>333,';'=>333,'<'=>584,'='=>584,'>'=>584,'?'=>611,'@'=>975,'A'=>722,
-       'B'=>722,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>556,'K'=>722,'L'=>611,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944,
-       'X'=>667,'Y'=>667,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>584,'_'=>556,'`'=>333,'a'=>556,'b'=>611,'c'=>556,'d'=>611,'e'=>556,'f'=>333,'g'=>611,'h'=>611,'i'=>278,'j'=>278,'k'=>556,'l'=>278,'m'=>889,
-       'n'=>611,'o'=>611,'p'=>611,'q'=>611,'r'=>389,'s'=>556,'t'=>333,'u'=>611,'v'=>556,'w'=>778,'x'=>556,'y'=>556,'z'=>500,'{'=>389,'|'=>280,'}'=>389,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>278,chr(131)=>556,
-       chr(132)=>500,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>278,chr(146)=>278,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
-       chr(154)=>556,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>280,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333,
-       chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>611,chr(182)=>556,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722,
-       chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
-       chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>556,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>611,chr(241)=>611,
-       chr(242)=>611,chr(243)=>611,chr(244)=>611,chr(245)=>611,chr(246)=>611,chr(247)=>584,chr(248)=>611,chr(249)=>611,chr(250)=>611,chr(251)=>611,chr(252)=>611,chr(253)=>556,chr(254)=>611,chr(255)=>556);
-?>
+<?php\r
+$fpdf_charwidths['helveticaB']=array(\r
+       chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278,\r
+       chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>333,'"'=>474,'#'=>556,'$'=>556,'%'=>889,'&'=>722,'\''=>238,'('=>333,')'=>333,'*'=>389,'+'=>584,\r
+       ','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>333,';'=>333,'<'=>584,'='=>584,'>'=>584,'?'=>611,'@'=>975,'A'=>722,\r
+       'B'=>722,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>556,'K'=>722,'L'=>611,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944,\r
+       'X'=>667,'Y'=>667,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>584,'_'=>556,'`'=>333,'a'=>556,'b'=>611,'c'=>556,'d'=>611,'e'=>556,'f'=>333,'g'=>611,'h'=>611,'i'=>278,'j'=>278,'k'=>556,'l'=>278,'m'=>889,\r
+       'n'=>611,'o'=>611,'p'=>611,'q'=>611,'r'=>389,'s'=>556,'t'=>333,'u'=>611,'v'=>556,'w'=>778,'x'=>556,'y'=>556,'z'=>500,'{'=>389,'|'=>280,'}'=>389,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>278,chr(131)=>556,\r
+       chr(132)=>500,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>278,chr(146)=>278,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,\r
+       chr(154)=>556,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>280,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333,\r
+       chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>611,chr(182)=>556,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722,\r
+       chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,\r
+       chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>556,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>611,chr(241)=>611,\r
+       chr(242)=>611,chr(243)=>611,chr(244)=>611,chr(245)=>611,chr(246)=>611,chr(247)=>584,chr(248)=>611,chr(249)=>611,chr(250)=>611,chr(251)=>611,chr(252)=>611,chr(253)=>556,chr(254)=>611,chr(255)=>556);\r
+?>\r
index 4137953..8d21774 100644 (file)
@@ -1,15 +1,15 @@
-<?php
-$fpdf_charwidths['helveticaBI']=array(
-       chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278,
-       chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>333,'"'=>474,'#'=>556,'$'=>556,'%'=>889,'&'=>722,'\''=>238,'('=>333,')'=>333,'*'=>389,'+'=>584,
-       ','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>333,';'=>333,'<'=>584,'='=>584,'>'=>584,'?'=>611,'@'=>975,'A'=>722,
-       'B'=>722,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>556,'K'=>722,'L'=>611,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944,
-       'X'=>667,'Y'=>667,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>584,'_'=>556,'`'=>333,'a'=>556,'b'=>611,'c'=>556,'d'=>611,'e'=>556,'f'=>333,'g'=>611,'h'=>611,'i'=>278,'j'=>278,'k'=>556,'l'=>278,'m'=>889,
-       'n'=>611,'o'=>611,'p'=>611,'q'=>611,'r'=>389,'s'=>556,'t'=>333,'u'=>611,'v'=>556,'w'=>778,'x'=>556,'y'=>556,'z'=>500,'{'=>389,'|'=>280,'}'=>389,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>278,chr(131)=>556,
-       chr(132)=>500,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>278,chr(146)=>278,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
-       chr(154)=>556,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>280,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333,
-       chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>611,chr(182)=>556,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722,
-       chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
-       chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>556,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>611,chr(241)=>611,
-       chr(242)=>611,chr(243)=>611,chr(244)=>611,chr(245)=>611,chr(246)=>611,chr(247)=>584,chr(248)=>611,chr(249)=>611,chr(250)=>611,chr(251)=>611,chr(252)=>611,chr(253)=>556,chr(254)=>611,chr(255)=>556);
-?>
+<?php\r
+$fpdf_charwidths['helveticaBI']=array(\r
+       chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278,\r
+       chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>333,'"'=>474,'#'=>556,'$'=>556,'%'=>889,'&'=>722,'\''=>238,'('=>333,')'=>333,'*'=>389,'+'=>584,\r
+       ','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>333,';'=>333,'<'=>584,'='=>584,'>'=>584,'?'=>611,'@'=>975,'A'=>722,\r
+       'B'=>722,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>556,'K'=>722,'L'=>611,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944,\r
+       'X'=>667,'Y'=>667,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>584,'_'=>556,'`'=>333,'a'=>556,'b'=>611,'c'=>556,'d'=>611,'e'=>556,'f'=>333,'g'=>611,'h'=>611,'i'=>278,'j'=>278,'k'=>556,'l'=>278,'m'=>889,\r
+       'n'=>611,'o'=>611,'p'=>611,'q'=>611,'r'=>389,'s'=>556,'t'=>333,'u'=>611,'v'=>556,'w'=>778,'x'=>556,'y'=>556,'z'=>500,'{'=>389,'|'=>280,'}'=>389,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>278,chr(131)=>556,\r
+       chr(132)=>500,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>278,chr(146)=>278,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,\r
+       chr(154)=>556,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>280,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333,\r
+       chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>611,chr(182)=>556,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722,\r
+       chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,\r
+       chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>556,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>611,chr(241)=>611,\r
+       chr(242)=>611,chr(243)=>611,chr(244)=>611,chr(245)=>611,chr(246)=>611,chr(247)=>584,chr(248)=>611,chr(249)=>611,chr(250)=>611,chr(251)=>611,chr(252)=>611,chr(253)=>556,chr(254)=>611,chr(255)=>556);\r
+?>\r
index d5bb6e0..88bf437 100644 (file)
@@ -1,15 +1,15 @@
-<?php
-$fpdf_charwidths['helveticaI']=array(
-       chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278,
-       chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>278,'"'=>355,'#'=>556,'$'=>556,'%'=>889,'&'=>667,'\''=>191,'('=>333,')'=>333,'*'=>389,'+'=>584,
-       ','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>278,';'=>278,'<'=>584,'='=>584,'>'=>584,'?'=>556,'@'=>1015,'A'=>667,
-       'B'=>667,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>500,'K'=>667,'L'=>556,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944,
-       'X'=>667,'Y'=>667,'Z'=>611,'['=>278,'\\'=>278,']'=>278,'^'=>469,'_'=>556,'`'=>333,'a'=>556,'b'=>556,'c'=>500,'d'=>556,'e'=>556,'f'=>278,'g'=>556,'h'=>556,'i'=>222,'j'=>222,'k'=>500,'l'=>222,'m'=>833,
-       'n'=>556,'o'=>556,'p'=>556,'q'=>556,'r'=>333,'s'=>500,'t'=>278,'u'=>556,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>500,'{'=>334,'|'=>260,'}'=>334,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>222,chr(131)=>556,
-       chr(132)=>333,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>222,chr(146)=>222,chr(147)=>333,chr(148)=>333,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
-       chr(154)=>500,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>260,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333,
-       chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>556,chr(182)=>537,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>667,chr(193)=>667,chr(194)=>667,chr(195)=>667,chr(196)=>667,chr(197)=>667,
-       chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
-       chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>500,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>556,chr(241)=>556,
-       chr(242)=>556,chr(243)=>556,chr(244)=>556,chr(245)=>556,chr(246)=>556,chr(247)=>584,chr(248)=>611,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>500,chr(254)=>556,chr(255)=>500);
-?>
+<?php\r
+$fpdf_charwidths['helveticaI']=array(\r
+       chr(0)=>278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278,\r
+       chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>278,'"'=>355,'#'=>556,'$'=>556,'%'=>889,'&'=>667,'\''=>191,'('=>333,')'=>333,'*'=>389,'+'=>584,\r
+       ','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>278,';'=>278,'<'=>584,'='=>584,'>'=>584,'?'=>556,'@'=>1015,'A'=>667,\r
+       'B'=>667,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>500,'K'=>667,'L'=>556,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944,\r
+       'X'=>667,'Y'=>667,'Z'=>611,'['=>278,'\\'=>278,']'=>278,'^'=>469,'_'=>556,'`'=>333,'a'=>556,'b'=>556,'c'=>500,'d'=>556,'e'=>556,'f'=>278,'g'=>556,'h'=>556,'i'=>222,'j'=>222,'k'=>500,'l'=>222,'m'=>833,\r
+       'n'=>556,'o'=>556,'p'=>556,'q'=>556,'r'=>333,'s'=>500,'t'=>278,'u'=>556,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>500,'{'=>334,'|'=>260,'}'=>334,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>222,chr(131)=>556,\r
+       chr(132)=>333,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>222,chr(146)=>222,chr(147)=>333,chr(148)=>333,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,\r
+       chr(154)=>500,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>260,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333,\r
+       chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>556,chr(182)=>537,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>667,chr(193)=>667,chr(194)=>667,chr(195)=>667,chr(196)=>667,chr(197)=>667,\r
+       chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,\r
+       chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>500,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>556,chr(241)=>556,\r
+       chr(242)=>556,chr(243)=>556,chr(244)=>556,chr(245)=>556,chr(246)=>556,chr(247)=>584,chr(248)=>611,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>500,chr(254)=>556,chr(255)=>500);\r
+?>\r
index b556ed8..43b50e4 100644 (file)
@@ -1,15 +1,15 @@
-<?php
-$fpdf_charwidths['symbol']=array(
-       chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,
-       chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>713,'#'=>500,'$'=>549,'%'=>833,'&'=>778,'\''=>439,'('=>333,')'=>333,'*'=>500,'+'=>549,
-       ','=>250,'-'=>549,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>278,';'=>278,'<'=>549,'='=>549,'>'=>549,'?'=>444,'@'=>549,'A'=>722,
-       'B'=>667,'C'=>722,'D'=>612,'E'=>611,'F'=>763,'G'=>603,'H'=>722,'I'=>333,'J'=>631,'K'=>722,'L'=>686,'M'=>889,'N'=>722,'O'=>722,'P'=>768,'Q'=>741,'R'=>556,'S'=>592,'T'=>611,'U'=>690,'V'=>439,'W'=>768,
-       'X'=>645,'Y'=>795,'Z'=>611,'['=>333,'\\'=>863,']'=>333,'^'=>658,'_'=>500,'`'=>500,'a'=>631,'b'=>549,'c'=>549,'d'=>494,'e'=>439,'f'=>521,'g'=>411,'h'=>603,'i'=>329,'j'=>603,'k'=>549,'l'=>549,'m'=>576,
-       'n'=>521,'o'=>549,'p'=>549,'q'=>521,'r'=>549,'s'=>603,'t'=>439,'u'=>576,'v'=>713,'w'=>686,'x'=>493,'y'=>686,'z'=>494,'{'=>480,'|'=>200,'}'=>480,'~'=>549,chr(127)=>0,chr(128)=>0,chr(129)=>0,chr(130)=>0,chr(131)=>0,
-       chr(132)=>0,chr(133)=>0,chr(134)=>0,chr(135)=>0,chr(136)=>0,chr(137)=>0,chr(138)=>0,chr(139)=>0,chr(140)=>0,chr(141)=>0,chr(142)=>0,chr(143)=>0,chr(144)=>0,chr(145)=>0,chr(146)=>0,chr(147)=>0,chr(148)=>0,chr(149)=>0,chr(150)=>0,chr(151)=>0,chr(152)=>0,chr(153)=>0,
-       chr(154)=>0,chr(155)=>0,chr(156)=>0,chr(157)=>0,chr(158)=>0,chr(159)=>0,chr(160)=>750,chr(161)=>620,chr(162)=>247,chr(163)=>549,chr(164)=>167,chr(165)=>713,chr(166)=>500,chr(167)=>753,chr(168)=>753,chr(169)=>753,chr(170)=>753,chr(171)=>1042,chr(172)=>987,chr(173)=>603,chr(174)=>987,chr(175)=>603,
-       chr(176)=>400,chr(177)=>549,chr(178)=>411,chr(179)=>549,chr(180)=>549,chr(181)=>713,chr(182)=>494,chr(183)=>460,chr(184)=>549,chr(185)=>549,chr(186)=>549,chr(187)=>549,chr(188)=>1000,chr(189)=>603,chr(190)=>1000,chr(191)=>658,chr(192)=>823,chr(193)=>686,chr(194)=>795,chr(195)=>987,chr(196)=>768,chr(197)=>768,
-       chr(198)=>823,chr(199)=>768,chr(200)=>768,chr(201)=>713,chr(202)=>713,chr(203)=>713,chr(204)=>713,chr(205)=>713,chr(206)=>713,chr(207)=>713,chr(208)=>768,chr(209)=>713,chr(210)=>790,chr(211)=>790,chr(212)=>890,chr(213)=>823,chr(214)=>549,chr(215)=>250,chr(216)=>713,chr(217)=>603,chr(218)=>603,chr(219)=>1042,
-       chr(220)=>987,chr(221)=>603,chr(222)=>987,chr(223)=>603,chr(224)=>494,chr(225)=>329,chr(226)=>790,chr(227)=>790,chr(228)=>786,chr(229)=>713,chr(230)=>384,chr(231)=>384,chr(232)=>384,chr(233)=>384,chr(234)=>384,chr(235)=>384,chr(236)=>494,chr(237)=>494,chr(238)=>494,chr(239)=>494,chr(240)=>0,chr(241)=>329,
-       chr(242)=>274,chr(243)=>686,chr(244)=>686,chr(245)=>686,chr(246)=>384,chr(247)=>384,chr(248)=>384,chr(249)=>384,chr(250)=>384,chr(251)=>384,chr(252)=>494,chr(253)=>494,chr(254)=>494,chr(255)=>0);
-?>
+<?php\r
+$fpdf_charwidths['symbol']=array(\r
+       chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,\r
+       chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>713,'#'=>500,'$'=>549,'%'=>833,'&'=>778,'\''=>439,'('=>333,')'=>333,'*'=>500,'+'=>549,\r
+       ','=>250,'-'=>549,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>278,';'=>278,'<'=>549,'='=>549,'>'=>549,'?'=>444,'@'=>549,'A'=>722,\r
+       'B'=>667,'C'=>722,'D'=>612,'E'=>611,'F'=>763,'G'=>603,'H'=>722,'I'=>333,'J'=>631,'K'=>722,'L'=>686,'M'=>889,'N'=>722,'O'=>722,'P'=>768,'Q'=>741,'R'=>556,'S'=>592,'T'=>611,'U'=>690,'V'=>439,'W'=>768,\r
+       'X'=>645,'Y'=>795,'Z'=>611,'['=>333,'\\'=>863,']'=>333,'^'=>658,'_'=>500,'`'=>500,'a'=>631,'b'=>549,'c'=>549,'d'=>494,'e'=>439,'f'=>521,'g'=>411,'h'=>603,'i'=>329,'j'=>603,'k'=>549,'l'=>549,'m'=>576,\r
+       'n'=>521,'o'=>549,'p'=>549,'q'=>521,'r'=>549,'s'=>603,'t'=>439,'u'=>576,'v'=>713,'w'=>686,'x'=>493,'y'=>686,'z'=>494,'{'=>480,'|'=>200,'}'=>480,'~'=>549,chr(127)=>0,chr(128)=>0,chr(129)=>0,chr(130)=>0,chr(131)=>0,\r
+       chr(132)=>0,chr(133)=>0,chr(134)=>0,chr(135)=>0,chr(136)=>0,chr(137)=>0,chr(138)=>0,chr(139)=>0,chr(140)=>0,chr(141)=>0,chr(142)=>0,chr(143)=>0,chr(144)=>0,chr(145)=>0,chr(146)=>0,chr(147)=>0,chr(148)=>0,chr(149)=>0,chr(150)=>0,chr(151)=>0,chr(152)=>0,chr(153)=>0,\r
+       chr(154)=>0,chr(155)=>0,chr(156)=>0,chr(157)=>0,chr(158)=>0,chr(159)=>0,chr(160)=>750,chr(161)=>620,chr(162)=>247,chr(163)=>549,chr(164)=>167,chr(165)=>713,chr(166)=>500,chr(167)=>753,chr(168)=>753,chr(169)=>753,chr(170)=>753,chr(171)=>1042,chr(172)=>987,chr(173)=>603,chr(174)=>987,chr(175)=>603,\r
+       chr(176)=>400,chr(177)=>549,chr(178)=>411,chr(179)=>549,chr(180)=>549,chr(181)=>713,chr(182)=>494,chr(183)=>460,chr(184)=>549,chr(185)=>549,chr(186)=>549,chr(187)=>549,chr(188)=>1000,chr(189)=>603,chr(190)=>1000,chr(191)=>658,chr(192)=>823,chr(193)=>686,chr(194)=>795,chr(195)=>987,chr(196)=>768,chr(197)=>768,\r
+       chr(198)=>823,chr(199)=>768,chr(200)=>768,chr(201)=>713,chr(202)=>713,chr(203)=>713,chr(204)=>713,chr(205)=>713,chr(206)=>713,chr(207)=>713,chr(208)=>768,chr(209)=>713,chr(210)=>790,chr(211)=>790,chr(212)=>890,chr(213)=>823,chr(214)=>549,chr(215)=>250,chr(216)=>713,chr(217)=>603,chr(218)=>603,chr(219)=>1042,\r
+       chr(220)=>987,chr(221)=>603,chr(222)=>987,chr(223)=>603,chr(224)=>494,chr(225)=>329,chr(226)=>790,chr(227)=>790,chr(228)=>786,chr(229)=>713,chr(230)=>384,chr(231)=>384,chr(232)=>384,chr(233)=>384,chr(234)=>384,chr(235)=>384,chr(236)=>494,chr(237)=>494,chr(238)=>494,chr(239)=>494,chr(240)=>0,chr(241)=>329,\r
+       chr(242)=>274,chr(243)=>686,chr(244)=>686,chr(245)=>686,chr(246)=>384,chr(247)=>384,chr(248)=>384,chr(249)=>384,chr(250)=>384,chr(251)=>384,chr(252)=>494,chr(253)=>494,chr(254)=>494,chr(255)=>0);\r
+?>\r
index b9be1b2..837c706 100644 (file)
@@ -1,15 +1,15 @@
-<?php
-$fpdf_charwidths['times']=array(
-       chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,
-       chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>408,'#'=>500,'$'=>500,'%'=>833,'&'=>778,'\''=>180,'('=>333,')'=>333,'*'=>500,'+'=>564,
-       ','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>278,';'=>278,'<'=>564,'='=>564,'>'=>564,'?'=>444,'@'=>921,'A'=>722,
-       'B'=>667,'C'=>667,'D'=>722,'E'=>611,'F'=>556,'G'=>722,'H'=>722,'I'=>333,'J'=>389,'K'=>722,'L'=>611,'M'=>889,'N'=>722,'O'=>722,'P'=>556,'Q'=>722,'R'=>667,'S'=>556,'T'=>611,'U'=>722,'V'=>722,'W'=>944,
-       'X'=>722,'Y'=>722,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>469,'_'=>500,'`'=>333,'a'=>444,'b'=>500,'c'=>444,'d'=>500,'e'=>444,'f'=>333,'g'=>500,'h'=>500,'i'=>278,'j'=>278,'k'=>500,'l'=>278,'m'=>778,
-       'n'=>500,'o'=>500,'p'=>500,'q'=>500,'r'=>333,'s'=>389,'t'=>278,'u'=>500,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>444,'{'=>480,'|'=>200,'}'=>480,'~'=>541,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500,
-       chr(132)=>444,chr(133)=>1000,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>556,chr(139)=>333,chr(140)=>889,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>444,chr(148)=>444,chr(149)=>350,chr(150)=>500,chr(151)=>1000,chr(152)=>333,chr(153)=>980,
-       chr(154)=>389,chr(155)=>333,chr(156)=>722,chr(157)=>350,chr(158)=>444,chr(159)=>722,chr(160)=>250,chr(161)=>333,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>200,chr(167)=>500,chr(168)=>333,chr(169)=>760,chr(170)=>276,chr(171)=>500,chr(172)=>564,chr(173)=>333,chr(174)=>760,chr(175)=>333,
-       chr(176)=>400,chr(177)=>564,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>500,chr(182)=>453,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>310,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>444,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722,
-       chr(198)=>889,chr(199)=>667,chr(200)=>611,chr(201)=>611,chr(202)=>611,chr(203)=>611,chr(204)=>333,chr(205)=>333,chr(206)=>333,chr(207)=>333,chr(208)=>722,chr(209)=>722,chr(210)=>722,chr(211)=>722,chr(212)=>722,chr(213)=>722,chr(214)=>722,chr(215)=>564,chr(216)=>722,chr(217)=>722,chr(218)=>722,chr(219)=>722,
-       chr(220)=>722,chr(221)=>722,chr(222)=>556,chr(223)=>500,chr(224)=>444,chr(225)=>444,chr(226)=>444,chr(227)=>444,chr(228)=>444,chr(229)=>444,chr(230)=>667,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>500,
-       chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>564,chr(248)=>500,chr(249)=>500,chr(250)=>500,chr(251)=>500,chr(252)=>500,chr(253)=>500,chr(254)=>500,chr(255)=>500);
-?>
+<?php\r
+$fpdf_charwidths['times']=array(\r
+       chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,\r
+       chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>408,'#'=>500,'$'=>500,'%'=>833,'&'=>778,'\''=>180,'('=>333,')'=>333,'*'=>500,'+'=>564,\r
+       ','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>278,';'=>278,'<'=>564,'='=>564,'>'=>564,'?'=>444,'@'=>921,'A'=>722,\r
+       'B'=>667,'C'=>667,'D'=>722,'E'=>611,'F'=>556,'G'=>722,'H'=>722,'I'=>333,'J'=>389,'K'=>722,'L'=>611,'M'=>889,'N'=>722,'O'=>722,'P'=>556,'Q'=>722,'R'=>667,'S'=>556,'T'=>611,'U'=>722,'V'=>722,'W'=>944,\r
+       'X'=>722,'Y'=>722,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>469,'_'=>500,'`'=>333,'a'=>444,'b'=>500,'c'=>444,'d'=>500,'e'=>444,'f'=>333,'g'=>500,'h'=>500,'i'=>278,'j'=>278,'k'=>500,'l'=>278,'m'=>778,\r
+       'n'=>500,'o'=>500,'p'=>500,'q'=>500,'r'=>333,'s'=>389,'t'=>278,'u'=>500,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>444,'{'=>480,'|'=>200,'}'=>480,'~'=>541,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500,\r
+       chr(132)=>444,chr(133)=>1000,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>556,chr(139)=>333,chr(140)=>889,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>444,chr(148)=>444,chr(149)=>350,chr(150)=>500,chr(151)=>1000,chr(152)=>333,chr(153)=>980,\r
+       chr(154)=>389,chr(155)=>333,chr(156)=>722,chr(157)=>350,chr(158)=>444,chr(159)=>722,chr(160)=>250,chr(161)=>333,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>200,chr(167)=>500,chr(168)=>333,chr(169)=>760,chr(170)=>276,chr(171)=>500,chr(172)=>564,chr(173)=>333,chr(174)=>760,chr(175)=>333,\r
+       chr(176)=>400,chr(177)=>564,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>500,chr(182)=>453,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>310,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>444,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722,\r
+       chr(198)=>889,chr(199)=>667,chr(200)=>611,chr(201)=>611,chr(202)=>611,chr(203)=>611,chr(204)=>333,chr(205)=>333,chr(206)=>333,chr(207)=>333,chr(208)=>722,chr(209)=>722,chr(210)=>722,chr(211)=>722,chr(212)=>722,chr(213)=>722,chr(214)=>722,chr(215)=>564,chr(216)=>722,chr(217)=>722,chr(218)=>722,chr(219)=>722,\r
+       chr(220)=>722,chr(221)=>722,chr(222)=>556,chr(223)=>500,chr(224)=>444,chr(225)=>444,chr(226)=>444,chr(227)=>444,chr(228)=>444,chr(229)=>444,chr(230)=>667,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>500,\r
+       chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>564,chr(248)=>500,chr(249)=>500,chr(250)=>500,chr(251)=>500,chr(252)=>500,chr(253)=>500,chr(254)=>500,chr(255)=>500);\r
+?>\r
index c3eb9fa..09cff86 100644 (file)
@@ -1,15 +1,15 @@
-<?php
-$fpdf_charwidths['timesB']=array(
-       chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,
-       chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>555,'#'=>500,'$'=>500,'%'=>1000,'&'=>833,'\''=>278,'('=>333,')'=>333,'*'=>500,'+'=>570,
-       ','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>333,';'=>333,'<'=>570,'='=>570,'>'=>570,'?'=>500,'@'=>930,'A'=>722,
-       'B'=>667,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>778,'I'=>389,'J'=>500,'K'=>778,'L'=>667,'M'=>944,'N'=>722,'O'=>778,'P'=>611,'Q'=>778,'R'=>722,'S'=>556,'T'=>667,'U'=>722,'V'=>722,'W'=>1000,
-       'X'=>722,'Y'=>722,'Z'=>667,'['=>333,'\\'=>278,']'=>333,'^'=>581,'_'=>500,'`'=>333,'a'=>500,'b'=>556,'c'=>444,'d'=>556,'e'=>444,'f'=>333,'g'=>500,'h'=>556,'i'=>278,'j'=>333,'k'=>556,'l'=>278,'m'=>833,
-       'n'=>556,'o'=>500,'p'=>556,'q'=>556,'r'=>444,'s'=>389,'t'=>333,'u'=>556,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>444,'{'=>394,'|'=>220,'}'=>394,'~'=>520,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500,
-       chr(132)=>500,chr(133)=>1000,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>556,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>667,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>500,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
-       chr(154)=>389,chr(155)=>333,chr(156)=>722,chr(157)=>350,chr(158)=>444,chr(159)=>722,chr(160)=>250,chr(161)=>333,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>220,chr(167)=>500,chr(168)=>333,chr(169)=>747,chr(170)=>300,chr(171)=>500,chr(172)=>570,chr(173)=>333,chr(174)=>747,chr(175)=>333,
-       chr(176)=>400,chr(177)=>570,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>556,chr(182)=>540,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>330,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>500,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722,
-       chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>389,chr(205)=>389,chr(206)=>389,chr(207)=>389,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>570,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,
-       chr(220)=>722,chr(221)=>722,chr(222)=>611,chr(223)=>556,chr(224)=>500,chr(225)=>500,chr(226)=>500,chr(227)=>500,chr(228)=>500,chr(229)=>500,chr(230)=>722,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>556,
-       chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>570,chr(248)=>500,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>500,chr(254)=>556,chr(255)=>500);
-?>
+<?php\r
+$fpdf_charwidths['timesB']=array(\r
+       chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,\r
+       chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>555,'#'=>500,'$'=>500,'%'=>1000,'&'=>833,'\''=>278,'('=>333,')'=>333,'*'=>500,'+'=>570,\r
+       ','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>333,';'=>333,'<'=>570,'='=>570,'>'=>570,'?'=>500,'@'=>930,'A'=>722,\r
+       'B'=>667,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>778,'I'=>389,'J'=>500,'K'=>778,'L'=>667,'M'=>944,'N'=>722,'O'=>778,'P'=>611,'Q'=>778,'R'=>722,'S'=>556,'T'=>667,'U'=>722,'V'=>722,'W'=>1000,\r
+       'X'=>722,'Y'=>722,'Z'=>667,'['=>333,'\\'=>278,']'=>333,'^'=>581,'_'=>500,'`'=>333,'a'=>500,'b'=>556,'c'=>444,'d'=>556,'e'=>444,'f'=>333,'g'=>500,'h'=>556,'i'=>278,'j'=>333,'k'=>556,'l'=>278,'m'=>833,\r
+       'n'=>556,'o'=>500,'p'=>556,'q'=>556,'r'=>444,'s'=>389,'t'=>333,'u'=>556,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>444,'{'=>394,'|'=>220,'}'=>394,'~'=>520,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500,\r
+       chr(132)=>500,chr(133)=>1000,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>556,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>667,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>500,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,\r
+       chr(154)=>389,chr(155)=>333,chr(156)=>722,chr(157)=>350,chr(158)=>444,chr(159)=>722,chr(160)=>250,chr(161)=>333,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>220,chr(167)=>500,chr(168)=>333,chr(169)=>747,chr(170)=>300,chr(171)=>500,chr(172)=>570,chr(173)=>333,chr(174)=>747,chr(175)=>333,\r
+       chr(176)=>400,chr(177)=>570,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>556,chr(182)=>540,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>330,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>500,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722,\r
+       chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>389,chr(205)=>389,chr(206)=>389,chr(207)=>389,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>570,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722,\r
+       chr(220)=>722,chr(221)=>722,chr(222)=>611,chr(223)=>556,chr(224)=>500,chr(225)=>500,chr(226)=>500,chr(227)=>500,chr(228)=>500,chr(229)=>500,chr(230)=>722,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>556,\r
+       chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>570,chr(248)=>500,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>500,chr(254)=>556,chr(255)=>500);\r
+?>\r
index 161f630..b4e38d7 100644 (file)
@@ -1,15 +1,15 @@
-<?php
-$fpdf_charwidths['timesBI']=array(
-       chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,
-       chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>389,'"'=>555,'#'=>500,'$'=>500,'%'=>833,'&'=>778,'\''=>278,'('=>333,')'=>333,'*'=>500,'+'=>570,
-       ','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>333,';'=>333,'<'=>570,'='=>570,'>'=>570,'?'=>500,'@'=>832,'A'=>667,
-       'B'=>667,'C'=>667,'D'=>722,'E'=>667,'F'=>667,'G'=>722,'H'=>778,'I'=>389,'J'=>500,'K'=>667,'L'=>611,'M'=>889,'N'=>722,'O'=>722,'P'=>611,'Q'=>722,'R'=>667,'S'=>556,'T'=>611,'U'=>722,'V'=>667,'W'=>889,
-       'X'=>667,'Y'=>611,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>570,'_'=>500,'`'=>333,'a'=>500,'b'=>500,'c'=>444,'d'=>500,'e'=>444,'f'=>333,'g'=>500,'h'=>556,'i'=>278,'j'=>278,'k'=>500,'l'=>278,'m'=>778,
-       'n'=>556,'o'=>500,'p'=>500,'q'=>500,'r'=>389,'s'=>389,'t'=>278,'u'=>556,'v'=>444,'w'=>667,'x'=>500,'y'=>444,'z'=>389,'{'=>348,'|'=>220,'}'=>348,'~'=>570,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500,
-       chr(132)=>500,chr(133)=>1000,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>556,chr(139)=>333,chr(140)=>944,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>500,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,
-       chr(154)=>389,chr(155)=>333,chr(156)=>722,chr(157)=>350,chr(158)=>389,chr(159)=>611,chr(160)=>250,chr(161)=>389,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>220,chr(167)=>500,chr(168)=>333,chr(169)=>747,chr(170)=>266,chr(171)=>500,chr(172)=>606,chr(173)=>333,chr(174)=>747,chr(175)=>333,
-       chr(176)=>400,chr(177)=>570,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>576,chr(182)=>500,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>300,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>500,chr(192)=>667,chr(193)=>667,chr(194)=>667,chr(195)=>667,chr(196)=>667,chr(197)=>667,
-       chr(198)=>944,chr(199)=>667,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>389,chr(205)=>389,chr(206)=>389,chr(207)=>389,chr(208)=>722,chr(209)=>722,chr(210)=>722,chr(211)=>722,chr(212)=>722,chr(213)=>722,chr(214)=>722,chr(215)=>570,chr(216)=>722,chr(217)=>722,chr(218)=>722,chr(219)=>722,
-       chr(220)=>722,chr(221)=>611,chr(222)=>611,chr(223)=>500,chr(224)=>500,chr(225)=>500,chr(226)=>500,chr(227)=>500,chr(228)=>500,chr(229)=>500,chr(230)=>722,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>556,
-       chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>570,chr(248)=>500,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>444,chr(254)=>500,chr(255)=>444);
-?>
+<?php\r
+$fpdf_charwidths['timesBI']=array(\r
+       chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,\r
+       chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>389,'"'=>555,'#'=>500,'$'=>500,'%'=>833,'&'=>778,'\''=>278,'('=>333,')'=>333,'*'=>500,'+'=>570,\r
+       ','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>333,';'=>333,'<'=>570,'='=>570,'>'=>570,'?'=>500,'@'=>832,'A'=>667,\r
+       'B'=>667,'C'=>667,'D'=>722,'E'=>667,'F'=>667,'G'=>722,'H'=>778,'I'=>389,'J'=>500,'K'=>667,'L'=>611,'M'=>889,'N'=>722,'O'=>722,'P'=>611,'Q'=>722,'R'=>667,'S'=>556,'T'=>611,'U'=>722,'V'=>667,'W'=>889,\r
+       'X'=>667,'Y'=>611,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>570,'_'=>500,'`'=>333,'a'=>500,'b'=>500,'c'=>444,'d'=>500,'e'=>444,'f'=>333,'g'=>500,'h'=>556,'i'=>278,'j'=>278,'k'=>500,'l'=>278,'m'=>778,\r
+       'n'=>556,'o'=>500,'p'=>500,'q'=>500,'r'=>389,'s'=>389,'t'=>278,'u'=>556,'v'=>444,'w'=>667,'x'=>500,'y'=>444,'z'=>389,'{'=>348,'|'=>220,'}'=>348,'~'=>570,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500,\r
+       chr(132)=>500,chr(133)=>1000,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>556,chr(139)=>333,chr(140)=>944,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>500,chr(151)=>1000,chr(152)=>333,chr(153)=>1000,\r
+       chr(154)=>389,chr(155)=>333,chr(156)=>722,chr(157)=>350,chr(158)=>389,chr(159)=>611,chr(160)=>250,chr(161)=>389,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>220,chr(167)=>500,chr(168)=>333,chr(169)=>747,chr(170)=>266,chr(171)=>500,chr(172)=>606,chr(173)=>333,chr(174)=>747,chr(175)=>333,\r
+       chr(176)=>400,chr(177)=>570,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>576,chr(182)=>500,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>300,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>500,chr(192)=>667,chr(193)=>667,chr(194)=>667,chr(195)=>667,chr(196)=>667,chr(197)=>667,\r
+       chr(198)=>944,chr(199)=>667,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>389,chr(205)=>389,chr(206)=>389,chr(207)=>389,chr(208)=>722,chr(209)=>722,chr(210)=>722,chr(211)=>722,chr(212)=>722,chr(213)=>722,chr(214)=>722,chr(215)=>570,chr(216)=>722,chr(217)=>722,chr(218)=>722,chr(219)=>722,\r
+       chr(220)=>722,chr(221)=>611,chr(222)=>611,chr(223)=>500,chr(224)=>500,chr(225)=>500,chr(226)=>500,chr(227)=>500,chr(228)=>500,chr(229)=>500,chr(230)=>722,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>556,\r
+       chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>570,chr(248)=>500,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>444,chr(254)=>500,chr(255)=>444);\r
+?>\r
index de171fd..0ba2b77 100644 (file)
@@ -1,15 +1,15 @@
-<?php
-$fpdf_charwidths['timesI']=array(
-       chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,
-       chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>420,'#'=>500,'$'=>500,'%'=>833,'&'=>778,'\''=>214,'('=>333,')'=>333,'*'=>500,'+'=>675,
-       ','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>333,';'=>333,'<'=>675,'='=>675,'>'=>675,'?'=>500,'@'=>920,'A'=>611,
-       'B'=>611,'C'=>667,'D'=>722,'E'=>611,'F'=>611,'G'=>722,'H'=>722,'I'=>333,'J'=>444,'K'=>667,'L'=>556,'M'=>833,'N'=>667,'O'=>722,'P'=>611,'Q'=>722,'R'=>611,'S'=>500,'T'=>556,'U'=>722,'V'=>611,'W'=>833,
-       'X'=>611,'Y'=>556,'Z'=>556,'['=>389,'\\'=>278,']'=>389,'^'=>422,'_'=>500,'`'=>333,'a'=>500,'b'=>500,'c'=>444,'d'=>500,'e'=>444,'f'=>278,'g'=>500,'h'=>500,'i'=>278,'j'=>278,'k'=>444,'l'=>278,'m'=>722,
-       'n'=>500,'o'=>500,'p'=>500,'q'=>500,'r'=>389,'s'=>389,'t'=>278,'u'=>500,'v'=>444,'w'=>667,'x'=>444,'y'=>444,'z'=>389,'{'=>400,'|'=>275,'}'=>400,'~'=>541,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500,
-       chr(132)=>556,chr(133)=>889,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>500,chr(139)=>333,chr(140)=>944,chr(141)=>350,chr(142)=>556,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>556,chr(148)=>556,chr(149)=>350,chr(150)=>500,chr(151)=>889,chr(152)=>333,chr(153)=>980,
-       chr(154)=>389,chr(155)=>333,chr(156)=>667,chr(157)=>350,chr(158)=>389,chr(159)=>556,chr(160)=>250,chr(161)=>389,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>275,chr(167)=>500,chr(168)=>333,chr(169)=>760,chr(170)=>276,chr(171)=>500,chr(172)=>675,chr(173)=>333,chr(174)=>760,chr(175)=>333,
-       chr(176)=>400,chr(177)=>675,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>500,chr(182)=>523,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>310,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>500,chr(192)=>611,chr(193)=>611,chr(194)=>611,chr(195)=>611,chr(196)=>611,chr(197)=>611,
-       chr(198)=>889,chr(199)=>667,chr(200)=>611,chr(201)=>611,chr(202)=>611,chr(203)=>611,chr(204)=>333,chr(205)=>333,chr(206)=>333,chr(207)=>333,chr(208)=>722,chr(209)=>667,chr(210)=>722,chr(211)=>722,chr(212)=>722,chr(213)=>722,chr(214)=>722,chr(215)=>675,chr(216)=>722,chr(217)=>722,chr(218)=>722,chr(219)=>722,
-       chr(220)=>722,chr(221)=>556,chr(222)=>611,chr(223)=>500,chr(224)=>500,chr(225)=>500,chr(226)=>500,chr(227)=>500,chr(228)=>500,chr(229)=>500,chr(230)=>667,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>500,
-       chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>675,chr(248)=>500,chr(249)=>500,chr(250)=>500,chr(251)=>500,chr(252)=>500,chr(253)=>444,chr(254)=>500,chr(255)=>444);
-?>
+<?php\r
+$fpdf_charwidths['timesI']=array(\r
+       chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250,\r
+       chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>420,'#'=>500,'$'=>500,'%'=>833,'&'=>778,'\''=>214,'('=>333,')'=>333,'*'=>500,'+'=>675,\r
+       ','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>333,';'=>333,'<'=>675,'='=>675,'>'=>675,'?'=>500,'@'=>920,'A'=>611,\r
+       'B'=>611,'C'=>667,'D'=>722,'E'=>611,'F'=>611,'G'=>722,'H'=>722,'I'=>333,'J'=>444,'K'=>667,'L'=>556,'M'=>833,'N'=>667,'O'=>722,'P'=>611,'Q'=>722,'R'=>611,'S'=>500,'T'=>556,'U'=>722,'V'=>611,'W'=>833,\r
+       'X'=>611,'Y'=>556,'Z'=>556,'['=>389,'\\'=>278,']'=>389,'^'=>422,'_'=>500,'`'=>333,'a'=>500,'b'=>500,'c'=>444,'d'=>500,'e'=>444,'f'=>278,'g'=>500,'h'=>500,'i'=>278,'j'=>278,'k'=>444,'l'=>278,'m'=>722,\r
+       'n'=>500,'o'=>500,'p'=>500,'q'=>500,'r'=>389,'s'=>389,'t'=>278,'u'=>500,'v'=>444,'w'=>667,'x'=>444,'y'=>444,'z'=>389,'{'=>400,'|'=>275,'}'=>400,'~'=>541,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500,\r
+       chr(132)=>556,chr(133)=>889,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>500,chr(139)=>333,chr(140)=>944,chr(141)=>350,chr(142)=>556,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>556,chr(148)=>556,chr(149)=>350,chr(150)=>500,chr(151)=>889,chr(152)=>333,chr(153)=>980,\r
+       chr(154)=>389,chr(155)=>333,chr(156)=>667,chr(157)=>350,chr(158)=>389,chr(159)=>556,chr(160)=>250,chr(161)=>389,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>275,chr(167)=>500,chr(168)=>333,chr(169)=>760,chr(170)=>276,chr(171)=>500,chr(172)=>675,chr(173)=>333,chr(174)=>760,chr(175)=>333,\r
+       chr(176)=>400,chr(177)=>675,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>500,chr(182)=>523,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>310,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>500,chr(192)=>611,chr(193)=>611,chr(194)=>611,chr(195)=>611,chr(196)=>611,chr(197)=>611,\r
+       chr(198)=>889,chr(199)=>667,chr(200)=>611,chr(201)=>611,chr(202)=>611,chr(203)=>611,chr(204)=>333,chr(205)=>333,chr(206)=>333,chr(207)=>333,chr(208)=>722,chr(209)=>667,chr(210)=>722,chr(211)=>722,chr(212)=>722,chr(213)=>722,chr(214)=>722,chr(215)=>675,chr(216)=>722,chr(217)=>722,chr(218)=>722,chr(219)=>722,\r
+       chr(220)=>722,chr(221)=>556,chr(222)=>611,chr(223)=>500,chr(224)=>500,chr(225)=>500,chr(226)=>500,chr(227)=>500,chr(228)=>500,chr(229)=>500,chr(230)=>667,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>500,\r
+       chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>675,chr(248)=>500,chr(249)=>500,chr(250)=>500,chr(251)=>500,chr(252)=>500,chr(253)=>444,chr(254)=>500,chr(255)=>444);\r
+?>\r
index 4b168f2..2c6fe73 100644 (file)
-<?php
-
-
-/*******************************************************************************
-* TTFontFile class                                                             *
-*                                                                              *
-* This class is based on The ReportLab Open Source PDF library                 *
-* written in Python - http://www.reportlab.com/software/opensource/            *
-* together with ideas from the OpenOffice source code and others.              *
-*                                                                              *
-* Version:  1.02                                                               *
-* Date:     2010-06-07                                                         *
-* Author:   Ian Back <ianb@bpm1.com>                                           *
-* License:  LGPL                                                               *
-* Copyright (c) Ian Back, 2010                                                 *
-* This header must be retained in any redistribution or                        *
-* modification of the file.                                                    *
-*                                                                              *
-*******************************************************************************/
-// TrueType Font Glyph operators
-define("GF_WORDS",(1 << 0));
-define("GF_SCALE",(1 << 3));
-define("GF_MORE",(1 << 5));
-define("GF_XYSCALE",(1 << 6));
-define("GF_TWOBYTWO",(1 << 7));
-
-
-
-class TTFontFile {
-
-var $_pos;
-var $numTables;
-var $searchRange;
-var $entrySelector;
-var $rangeShift;
-var $tables;
-var $otables;
-var $filename;
-var $fh;
-var $hmetrics;
-var $glyphPos;
-var $charToGlyph;
-var $ascent;
-var $descent;
-var $name;
-var $familyName;
-var $styleName;
-var $fullName;
-var $uniqueFontID;
-var $unitsPerEm;
-var $bbox;
-var $capHeight;
-var $stemV;
-var $italicAngle;
-var $flags;
-var $underlinePosition;
-var $underlineThickness;
-var $charWidths;
-var $defaultWidth;
-var $maxStrLenRead;
-
-       function TTFontFile() {
-               $this->maxStrLenRead = 200000;  // Maximum size of glyf table to read in as string (otherwise reads each glyph from file)
-       }
-
-
-       function getMetrics($file, $presubset=0) {
-               $this->filename = $file;
-               $this->fh = fopen($file,'rb') or die('Can\'t open file ' . $file);
-               $this->_pos = 0;
-               $this->charWidths = array();
-               $this->hmetrics = array();
-               $this->glyphPos = array();
-               $this->charToGlyph = array();
-               $this->tables = array();
-               $this->otables = array();
-               $this->ascent = 0;
-               $this->descent = 0;
-               if ($presubset) { $this->skip(4); }
-               else { $this->readHeader(); }
-               $this->readTableDirectory($presubset);
-               $this->extractInfo($presubset); 
-               fclose($this->fh);
-       }
-
-       function readHeader() {
-               // read the sfnt header at the current position
-               $this->version = $version = $this->read_ulong();
-               if ($version==0x4F54544F) 
-                       die("Postscript outlines are not supported");
-               if ($version==0x74746366) 
-                       die("TTC Font collections are not supported");
-               if (!in_array($version, array(0x00010000,0x74727565)))
-                       die("Not a TrueType font: version=".$version);
-               return true;
-       }
-
-       function readTableDirectory($presubset=1) {
-               $this->numTables = $this->read_ushort();
-            $this->searchRange = $this->read_ushort();
-            $this->entrySelector = $this->read_ushort();
-            $this->rangeShift = $this->read_ushort();
-            $this->tables = array();   
-            for ($i=0;$i<$this->numTables;$i++) {      // 1.02
-                $record = array();
-                $record['tag'] = $this->read_tag();
-                $record['checksum'] = array($this->read_ushort(),$this->read_ushort());
-                $record['offset'] = $this->read_ulong();
-                $record['length'] = $this->read_ulong();
-                $this->tables[$record['tag']] = $record;
-               }
-               if (!$presubset) $this->checksumTables();
-       }
-
-       function checksumTables() {
-               // Check the checksums for all tables
-               foreach($this->tables AS $t) {
-                 if ($t['length'] > 0 && $t['length'] < $this->maxStrLenRead) {        // 1.02
-               $table = $this->get_chunk($t['offset'], $t['length']);
-               $checksum = $this->calcChecksum($table);
-               if ($t['tag'] == 'head') {
-                               $up = unpack('n*', substr($table,8,4));
-                               $adjustment[0] = $up[1];
-                               $adjustment[1] = $up[2];
-                       $checksum = $this->sub32($checksum, $adjustment);
-                       }
-               $xchecksum = $t['checksum'];
-               if ($xchecksum != $checksum) 
-                   die(sprintf('TTF file "%s": invalid checksum %s table: %s (expected %s)', $this->filename,dechex($checksum[0]).dechex($checksum[1]),$t['tag'],dechex($xchecksum[0]).dechex($xchecksum[1])));
-                 }
-               }
-       }
-
-       function sub32($x, $y) {
-               $xlo = $x[1];
-               $xhi = $x[0];
-               $ylo = $y[1];
-               $yhi = $y[0];
-               if ($ylo > $xlo) { $xlo += 1 << 16; $yhi += 1; }
-               $reslo = $xlo-$ylo;
-               if ($yhi > $xhi) { $xhi += 1 << 16;  }
-               $reshi = $xhi-$yhi;
-               $reshi = $reshi & 0xFFFF;
-               return array($reshi, $reslo);
-       }
-
-       function calcChecksum($data)  {
-               if (strlen($data) % 4) { $data .= str_repeat("\0",(4-(strlen($data) % 4))); }
-               $hi=0x0000;
-               $lo=0x0000;
-               for($i=0;$i<strlen($data);$i+=4) {
-                       $hi += (ord($data[$i])<<8) + ord($data[$i+1]);
-                       $lo += (ord($data[$i+2])<<8) + ord($data[$i+3]);
-                       $hi += $lo >> 16;
-                       $lo = $lo & 0xFFFF;
-                       $hi = $hi & 0xFFFF;
-               }
-               return array($hi, $lo);
-       }
-
-       function get_table_pos($tag) {
-               $offset = $this->tables[$tag]['offset'];
-               $length = $this->tables[$tag]['length'];
-               return array($offset, $length);
-       }
-
-       function seek($pos) {
-               $this->_pos = $pos;
-               fseek($this->fh,$this->_pos);
-       }
-
-       function skip($delta) {
-               $this->_pos = $this->_pos + $delta;
-               fseek($this->fh,$this->_pos);
-       }
-
-       function seek_table($tag, $offset_in_table = 0) {
-               $tpos = $this->get_table_pos($tag);
-               $this->_pos = $tpos[0] + $offset_in_table;
-               fseek($this->fh, $this->_pos);
-               return $this->_pos;
-       }
-
-       function read_tag() {
-               $this->_pos += 4;
-               return fread($this->fh,4);
-       }
-
-       function read_short() {
-               $this->_pos += 2;
-               $s = fread($this->fh,2);
-               $a = (ord($s[0])<<8) + ord($s[1]);
-               if ($a & (1 << 15) ) { $a = ($a - (1 << 16)) ; }
-               return $a;
-       }
-
-       function read_ushort() {
-               $this->_pos += 2;
-               $s = fread($this->fh,2);
-               return (ord($s[0])<<8) + ord($s[1]);
-       }
-
-       function read_ulong() {
-               $this->_pos += 4;
-               $s = fread($this->fh,4);
-               // if large uInt32 as an integer, PHP converts it to -ve
-               return (ord($s[0])*16777216) + (ord($s[1])<<16) + (ord($s[2])<<8) + ord($s[3]); //      16777216  = 1<<24
-       }
-
-       function get_ushort($pos) {
-               fseek($this->fh,$pos);
-               $s = fread($this->fh,2);
-               return (ord($s[0])<<8) + ord($s[1]);
-       }
-
-       function get_ulong($pos) {
-               fseek($this->fh,$pos);
-               $s = fread($this->fh,4);
-               // iF large uInt32 as an integer, PHP converts it to -ve
-               return (ord($s[0])*16777216) + (ord($s[1])<<16) + (ord($s[2])<<8) + ord($s[3]); //      16777216  = 1<<24
-       }
-
-       function pack_short($val) {
-               if ($val<0) { 
-                       $val = abs($val);
-                       $val = ~$val;
-                       $val += 1;
-               }
-               return pack("n",$val); 
-       }
-
-       function splice($stream, $offset, $value) {
-               return substr($stream,0,$offset) . $value . substr($stream,$offset+strlen($value));
-       }
-
-       function _set_ushort($stream, $offset, $value) {
-               $up = pack("n", $value);
-               return $this->splice($stream, $offset, $up);
-       }
-
-       function get_chunk($pos, $length) {
-               fseek($this->fh,$pos);
-               if ($length <1) { return ''; }  // 1.02
-               return (fread($this->fh,$length));
-       }
-
-       function get_table($tag) {
-               list($pos, $length) = $this->get_table_pos($tag);
-               if ($length == 0) { die('Truetype font ('.$this->filename.'): error reading table: '.$tag); }   // 1.02
-               fseek($this->fh,$pos);
-               return (fread($this->fh,$length));
-       }
-
-       function add($tag, $data) {
-               if ($tag == 'head') {
-                       $data = $this->splice($data, 8, "\0\0\0\0");
-               }
-               $this->otables[$tag] = $data;
-       }
-
-
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-
-       function extractInfo($presubset=0) {
-               // = 0 ; validate; does not need glyphPos or charToGlyph
-               // presubset = 1; no validation; does not need name and other metrics
-               ///////////////////////////////////
-               // name - Naming table
-               ///////////////////////////////////
-               if (!$presubset) { 
-                       $name_offset = $this->seek_table("name");
-                       $format = $this->read_ushort();
-                       if ($format != 0)
-                               die("Unknown name table format ".$format);
-                       $numRecords = $this->read_ushort();
-                       $string_data_offset = $name_offset + $this->read_ushort();
-
-                       $names = array(1=>'',2=>'',3=>'',4=>'',6=>'');
-                       $K = array_keys($names);
-                       $nameCount = count($names);
-                       for ($i=0;$i<$numRecords; $i++) {
-                               $platformId = $this->read_ushort();
-                               $encodingId = $this->read_ushort();
-                               $languageId = $this->read_ushort();
-                               $nameId = $this->read_ushort();
-                               $length = $this->read_ushort();
-                               $offset = $this->read_ushort();
-                               if (!in_array($nameId,$K)) continue;
-                               $N = '';
-                               if ($platformId == 3 && $encodingId == 1 && $languageId == 0x409) { // Microsoft, Unicode, US English, PS Name
-                                       $opos = $this->_pos;
-                                       $this->seek($string_data_offset + $offset);
-                                       if ($length % 2 != 0)
-                                               die("PostScript name is UTF-16BE string of odd length");
-                                       $length /= 2;
-                                       $N = '';
-                                       while ($length > 0) {
-                                               $char = $this->read_ushort();
-                                               $N .= (chr($char));     // 1.02
-                                               $length -= 1;
-                                       }
-                                       $this->_pos = $opos;
-                                       $this->seek($opos);
-                               }
-                               else if ($platformId == 1 && $encodingId == 0 && $languageId == 0) { // Macintosh, Roman, English, PS Name
-                                       $opos = $this->_pos;
-                                       $N = $this->get_chunk($string_data_offset + $offset, $length);
-                                       $this->_pos = $opos;
-                                       $this->seek($opos);
-                               }
-                               if ($N && $names[$nameId]=='') {
-                                       $names[$nameId] = $N;
-                                       $nameCount -= 1;
-                                       if ($nameCount==0) break;
-                               }
-                       }
-                       if ($names[6])
-                               $psName = preg_replace('/ /','-',$names[6]);
-                       else if ($names[4])
-                               $psName = preg_replace('/ /','-',$names[4]);
-                       else if ($names[1])
-                               $psName = preg_replace('/ /','-',$names[1]);
-                       else
-                               $psName = '';
-                       if (!$psName)
-                               die("Could not find PostScript font name");
-                       for ($i=0;$i<strlen($psName);$i++) {
-                               $c = $psName{$i};       // 1.02
-                               $oc = ord($c);
-                               if ($oc>126 || strpos(' [](){}<>/%',$c)!==false)
-                                       die("psName=".$psName." contains invalid character ".$c." ie U+".ord(c));
-                       }
-                       $this->name = $psName;
-                       if ($names[1]) { $this->familyName = $names[1]; } else { $this->familyName = $psName; }
-                       if ($names[2]) { $this->styleName = $names[2]; } else { $this->styleName = 'Regular'; }
-                       if ($names[4]) { $this->fullName = $names[4]; } else { $this->fullName = $psName; }
-                       if ($names[3]) { $this->uniqueFontID = $names[3]; } else { $this->uniqueFontID = $psName; }
-               }
-
-               ///////////////////////////////////
-               // head - Font header table
-               ///////////////////////////////////
-               $this->seek_table("head");
-               if ($presubset) { $this->skip(18); }
-               else {
-                       $ver_maj = $this->read_ushort();
-                       $ver_min = $this->read_ushort();
-                       if ($ver_maj != 1)
-                               die('Unknown head table version '. $ver_maj .'.'. $ver_min);
-                       $this->fontRevision = $this->read_ushort() . $this->read_ushort();
-
-                       $this->skip(4);
-                       $magic = $this->read_ulong();
-                       if ($magic != 0x5F0F3CF5) 
-                               die('Invalid head table magic ' .$magic);
-                       $this->skip(2);
-               }
-               $this->unitsPerEm = $unitsPerEm = $this->read_ushort(); // 1.02
-               $scale = 1000 / $unitsPerEm;    // 1.02
-               if ($presubset) { $this->skip(30); }    // 1.02
-               else { 
-                       $this->skip(16);
-                       $xMin = $this->read_short();
-                       $yMin = $this->read_short();
-                       $xMax = $this->read_short();
-                       $yMax = $this->read_short();
-                       $this->bbox = array(($xMin*$scale), ($yMin*$scale), ($xMax*$scale), ($yMax*$scale));
-                       $this->skip(3*2);
-               }
-               $indexToLocFormat = $this->read_ushort();
-               $glyphDataFormat = $this->read_ushort();
-               if ($glyphDataFormat != 0)
-                       die('Unknown glyph data format '.$glyphDataFormat);
-
-               ///////////////////////////////////
-               // hhea metrics table
-               ///////////////////////////////////
-               // ttf2t1 seems to use this value rather than the one in OS/2 - so put in for compatibility
-               if (isset($this->tables["hhea"])) {
-                       $this->seek_table("hhea");
-                       $this->skip(4);
-                       $hheaAscender = $this->read_short();
-                       $hheaDescender = $this->read_short();
-                       $this->ascent = ($hheaAscender *$scale);
-                       $this->descent = ($hheaDescender *$scale);
-               }
-
-               ///////////////////////////////////
-               // OS/2 - OS/2 and Windows metrics table
-               ///////////////////////////////////
-               if (isset($this->tables["OS/2"])) {
-                       $this->seek_table("OS/2");
-                       $version = $this->read_ushort();
-                       $this->skip(2);
-                       $usWeightClass = $this->read_ushort();
-                       $this->skip(2);
-                       $fsType = $this->read_ushort();
-       //              if ($fsType == 0x0002 || ($fsType & 0x0300) != 0) 
-       //                      die('Font does not allow subsetting/embedding');
-                       $this->skip(58);   //11*2 + 10 + 4*4 + 4 + 3*2
-                       $sTypoAscender = $this->read_short();
-                       $sTypoDescender = $this->read_short();
-                       if (!$this->ascent) $this->ascent = ($sTypoAscender*$scale);
-                       if (!$this->descent) $this->descent = ($sTypoDescender*$scale);
-                       if ($version > 1) {
-                               $this->skip(16);
-                               $sCapHeight = $this->read_short();
-                               $this->capHeight = ($sCapHeight*$scale);
-                       }
-                       else {
-                               $this->capHeight = $this->ascent;
-                       }
-               }
-               else {
-                       $usWeightClass = 500;
-                       if (!$this->ascent) $this->ascent = ($yMax*$scale);
-                       if (!$this->descent) $this->descent = ($yMin*$scale);
-                       $this->capHeight = $this->ascent;
-               }
-               $this->stemV = 50 + intval(pow(($usWeightClass / 65.0),2));
-
-               ///////////////////////////////////
-               // post - PostScript table
-               ///////////////////////////////////
-               $this->seek_table("post");
-               if ($presubset) { $this->skip(4); }
-               else {
-                       $ver_maj = $this->read_ushort();
-                       $ver_min = $this->read_ushort();
-                       if ($ver_maj <1 || $ver_maj >4) 
-                               die('Unknown post table version '.$ver_maj);
-               }
-               $this->italicAngle = $this->read_short() + $this->read_ushort() / 65536.0;
-               $this->underlinePosition = $this->read_short() * $scale;
-               $this->underlineThickness = $this->read_short() * $scale;
-               $isFixedPitch = $this->read_ulong();
-
-               $this->flags = 4;
-
-               if ($this->italicAngle!= 0) 
-                       $this->flags = $this->flags | 64;
-               if ($usWeightClass >= 600)
-                       $this->flags = $this->flags | 262144;
-               if ($isFixedPitch)
-                       $this->flags = $this->flags | 1;
-
-               ///////////////////////////////////
-               // hhea - Horizontal header table
-               ///////////////////////////////////
-               $this->seek_table("hhea");
-               if ($presubset) { $this->skip(32); }
-               else {
-                       $ver_maj = $this->read_ushort();
-                       $ver_min = $this->read_ushort();
-                       if ($ver_maj != 1)
-                               die('Unknown hhea table version '.$ver_maj);
-                       $this->skip(28);
-               }
-               $metricDataFormat = $this->read_ushort();
-               if ($metricDataFormat != 0)
-                       die('Unknown horizontal metric data format '.$metricDataFormat);
-               $numberOfHMetrics = $this->read_ushort();
-               if ($numberOfHMetrics == 0) 
-                       die('Number of horizontal metrics is 0');
-
-               ///////////////////////////////////
-               // maxp - Maximum profile table
-               ///////////////////////////////////
-               $this->seek_table("maxp");
-               if ($presubset) { $this->skip(4); }
-               else {
-                       $ver_maj = $this->read_ushort();
-                       $ver_min = $this->read_ushort();
-                       if ($ver_maj != 1)
-                               die('Unknown maxp table version '.$ver_maj);
-               }
-               $numGlyphs = $this->read_ushort();
-
-               ///////////////////////////////////
-               // cmap - Character to glyph index mapping table
-               ///////////////////////////////////
-               $cmap_offset = $this->seek_table("cmap");
-               $this->skip(2);
-               $cmapTableCount = $this->read_ushort();
-               $unicode_cmap_offset = 0;
-               for ($i=0;$i<$cmapTableCount;$i++) {
-                       $platformID = $this->read_ushort();
-                       $encodingID = $this->read_ushort();
-                       $offset = $this->read_ulong();
-                       $save_pos = $this->_pos;
-                       if ($platformID == 3 && $encodingID == 1) { // Microsoft, Unicode
-                               $format = $this->get_ushort($cmap_offset + $offset);
-                               if ($format == 4) {
-                                       $unicode_cmap_offset = $cmap_offset + $offset;
-                                       break;
-                               }
-                       }
-                       else if ($platformID == 0) { // Unicode -- assume all encodings are compatible
-                               $format = $this->get_ushort($cmap_offset + $offset);
-                               if ($format == 4) {
-                                       $unicode_cmap_offset = $cmap_offset + $offset;
-                                       break;
-                               }
-                       }
-                       $this->seek($save_pos );
-               }
-
-               if (!$unicode_cmap_offset)
-                       die('Font does not have cmap for Unicode (platform 3, encoding 1, format 4, or platform 0, any encoding, format 4)');
-               $this->seek($unicode_cmap_offset + 2);
-               $length = $this->read_ushort();
-               $limit = $unicode_cmap_offset + $length;
-               $this->skip(2);
-
-               $segCount = $this->read_ushort() / 2;
-               $this->skip(6);
-               $endCount = array();
-               for($i=0; $i<$segCount; $i++) { $endCount[] = $this->read_ushort(); }
-               $this->skip(2);
-               $startCount = array();
-               for($i=0; $i<$segCount; $i++) { $startCount[] = $this->read_ushort(); }
-               $idDelta = array();
-               for($i=0; $i<$segCount; $i++) { $idDelta[] = $this->read_short(); }             // ???? was unsigned short
-               $idRangeOffset_start = $this->_pos;
-               $idRangeOffset = array();
-               for($i=0; $i<$segCount; $i++) { $idRangeOffset[] = $this->read_ushort(); }
-
-               $glyphToChar = array();
-               $charToGlyph = array();
-               for ($n=0;$n<$segCount;$n++) {
-                       for ($unichar=$startCount[$n];$unichar<($endCount[$n] + 1);$unichar++) {
-                               if ($idRangeOffset[$n] == 0)
-                                       $glyph = ($unichar + $idDelta[$n]) & 0xFFFF;
-                               else {
-                                       $offset = ($unichar - $startCount[$n]) * 2 + $idRangeOffset[$n];
-                                       $offset = $idRangeOffset_start + 2 * $n + $offset;
-                                       if ($offset >= $limit)
-                                               $glyph = 0;
-                                       else {
-                                               $glyph = $this->get_ushort($offset);
-                                               if ($glyph != 0)
-                                               $glyph = ($glyph + $idDelta[$n]) & 0xFFFF;
-                                       }
-                               }
-                               if ($presubset) $charToGlyph[$unichar] = $glyph;
-                               $glyphToChar[$glyph][] = $unichar;
-                       }
-               }
-               if ($presubset) $this->charToGlyph = $charToGlyph;
-
-               ///////////////////////////////////
-               // hmtx - Horizontal metrics table
-               ///////////////////////////////////
-               $this->seek_table("hmtx");
-               $aw = 0;
-               $this->charWidths = array();
-               $this->hmetrics = array();
-               for( $glyph=0; $glyph<$numberOfHMetrics; $glyph++) {
-                       $aw = $this->read_ushort();
-                       $lsb = $this->read_short();
-                       $this->hmetrics[] = array($aw, $lsb);
-                       $aw = $scale*$aw;
-                       if ($glyph == 0)
-                               $this->defaultWidth = $aw;
-                       if (isset($glyphToChar[$glyph])) {
-                               foreach($glyphToChar[$glyph] AS $char) {
-                                       $this->charWidths[$char] = round($aw);
-                               }
-                       }
-               }
-               for( $glyph=$numberOfHMetrics; $glyph<$numGlyphs; $glyph++) {
-                       $lsb = $this->read_ushort();
-                       $this->hmetrics[] = array($aw, $lsb);
-                       if (isset($glyphToChar[$glyph])) {
-                               foreach($glyphToChar[$glyph] AS $char) {
-                                       $this->charWidths[$char] = round($aw);
-                               }
-                       }
-               }
-
-               ///////////////////////////////////
-               // loca - Index to location
-               ///////////////////////////////////
-               if ($presubset) {
-                       $this->seek_table('loca');
-                       $this->glyphPos = array();
-                       if ($indexToLocFormat == 0) {
-                               for ($n=0; $n<=$numGlyphs; $n++) {      // 1.02
-                                       $this->glyphPos[] = ($this->read_ushort() * 2);
-                               }
-                       }
-                       else if ($indexToLocFormat == 1) {
-                               for ($n=0; $n<=$numGlyphs; $n++) {      // 1.02
-                                       $this->glyphPos[] = ($this->read_ulong());
-                               }
-                       }
-                       else 
-                               die('Unknown location table format '.$indexToLocFormat);
-               }
-       }
-
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-
-       function makeSubset($subset) {
-               $this->fh = fopen($this->filename ,'rb') or die('Can\'t open file ' . $this->filename );
-               $this->otables = array();
-               $glyphMap = array(0=>0); 
-               $glyphSet = array(0=>0);
-               $codeToGlyph = array();
-               foreach($subset AS $code) {
-                       if (isset($this->charToGlyph[$code]))
-                               $originalGlyphIdx = $this->charToGlyph[$code];
-                       else
-                               $originalGlyphIdx = 0;
-                       if (!isset($glyphSet[$originalGlyphIdx])) {
-                               $glyphSet[$originalGlyphIdx] = count($glyphMap);
-                               $glyphMap[] = $originalGlyphIdx;
-                       }
-                       $codeToGlyph[$code] = $glyphSet[$originalGlyphIdx];
-               }
-
-               list($start,$dummy) = $this->get_table_pos('glyf');
-
-               $n = 0;
-               while ($n < count($glyphMap)) {
-                       $originalGlyphIdx = $glyphMap[$n];
-                       $glyphPos = $this->glyphPos[$originalGlyphIdx];
-                       $glyphLen = $this->glyphPos[$originalGlyphIdx + 1] - $glyphPos;
-                       $n += 1;
-                       if (!$glyphLen) continue;
-                       $this->seek($start + $glyphPos);
-                       $numberOfContours = $this->read_short();
-                       if ($numberOfContours < 0) {
-                               $this->skip(8);
-                               $flags = GF_MORE;
-                               while ($flags & GF_MORE) {
-                                       $flags = $this->read_ushort();
-                                       $glyphIdx = $this->read_ushort();
-                                       if (!isset($glyphSet[$glyphIdx])) {
-                                               $glyphSet[$glyphIdx] = count($glyphMap);
-                                               $glyphMap[] = $glyphIdx;
-                                       }
-                                       if ($flags & GF_WORDS)
-                                               $this->skip(4);
-                                       else
-                                               $this->skip(2);
-                                       if ($flags & GF_SCALE)
-                                               $this->skip(2);
-                                       else if ($flags & GF_XYSCALE)
-                                               $this->skip(4);
-                                       else if ($flags & GF_TWOBYTWO)
-                                               $this->skip(8);
-                               }
-                       }
-               }
-
-               $numGlyphs = $n = count($glyphMap);
-               while ($n > 1 && $this->hmetrics[$n][0] == $this->hmetrics[$n - 1][0]) { $n -= 1; }
-               $numberOfHMetrics = $n;
-
-               //tables copied from the original
-               $tags = array ('name', 'OS/2', 'prep');
-               foreach($tags AS $tag) { $this->add($tag, $this->get_table($tag)); }
-               $tags = array ('cvt ', 'fpgm');
-               foreach($tags AS $tag) {        // 1.02
-                       if (isset($this->table['tag'])) { $this->add($tag, $this->get_table($tag)); }
-               }
-
-               // post - PostScript
-               $opost = $this->get_table('post');
-               $post = "\x00\x03\x00\x00" . substr($opost,4,12) . "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
-               $this->add('post', $post);
-
-               // hhea - Horizontal Header
-               $hhea = $this->get_table('hhea');
-               $hhea = $this->_set_ushort($hhea, 34, $numberOfHMetrics);
-               $this->add('hhea', $hhea);
-
-               // maxp - Maximum Profile
-               $maxp = $this->get_table('maxp');
-               $maxp = $this->_set_ushort($maxp, 4, $numGlyphs);
-               $this->add('maxp', $maxp);
-
-               // cmap - Character to glyph mapping - Format 6
-               $entryCount = count($subset);
-               $length = 10 + $entryCount * 2;
-               $cmap = array(0, 1,     // Index : version, number of subtables
-                       1, 0,                   // Subtable : platform, encoding
-                       0, 12,          // offset (hi,lo)
-                       6, $length,     // Format 6 Mapping table: format, length
-                       0, 1,                   // language, First char code
-                       $entryCount);
-
-               foreach($subset AS $code) { $cmap[] = $codeToGlyph[$code]; }
-               $cmapstr = '';
-               foreach($cmap AS $cm) { $cmapstr .= pack("n",$cm); }
-               $this->add('cmap', $cmapstr);
-
-/*
-               // cmap - Character to glyph mapping - Format 4 (MS / )
-               $segCount = 2;
-               $searchRange = 1;
-               $entrySelector = 0;
-               while ($searchRange * 2 <= $segCount ) {
-                       $searchRange = $searchRange * 2;
-                       $entrySelector = $entrySelector + 1;
-               }
-               $searchRange = $searchRange * 16;
-               $rangeShift = $segCount * 16 - $searchRange;
-               $length = 48 + ($numGlyphs-1);
-               $cmap = array(0, 1,     // Index : version, number of subtables
-                       3, 0,                   // Subtable : platform (MS=3), encoding
-                       0, 12,          // Subtable : offset (hi,lo)
-                       4, $length, 0,  // Format 4 Mapping table: format, length, language
-                       $segCount*2,
-                       $searchRange,
-                       $entrySelector,
-                       $rangeShift,
-                       $numGlyphs, 0xFFFF,     // endCode(s)
-                       0,
-                       1, 0xFFFF,                      // startCode(s)
-                       0, 1,                           // idDelta(s) Delta for all character codes in segment
-                       0, 0);                  // idRangeOffset[segCount]      Offset in bytes to glyph indexArray, or 0
-               foreach($subset AS $code) { $cmap[] = $codeToGlyph[$code]; }
-               $cmap[] = 0xFFFF;
-               $cmapstr = '';
-               foreach($cmap AS $cm) { $cmapstr .= pack("n",$cm); }
-               $this->add('cmap', $cmapstr);
-*/
-
-
-               // hmtx - Horizontal Metrics
-               $hmtxstr = '';
-               for($n=0;$n<$numGlyphs;$n++) {
-                       $originalGlyphIdx = $glyphMap[$n];
-                       $aw = $this->hmetrics[$originalGlyphIdx][0];
-                       $lsb = $this->hmetrics[$originalGlyphIdx][1];
-                       if ($n < $numberOfHMetrics) { $hmtxstr .= pack("n",$aw); }
-                       $hmtxstr .= $this->pack_short($lsb);
-               }
-               $this->add('hmtx', $hmtxstr);
-
-               // glyf - Glyph data
-               list($glyfOffset,$glyfLength) = $this->get_table_pos('glyf');
-               if ($glyfLength < $this->maxStrLenRead) {
-                       $glyphData = $this->get_table('glyf');
-               }
-
-               $offsets = array();
-               $glyf = '';
-               $pos = 0;
-
-               for ($n=0;$n<$numGlyphs;$n++) {
-                       $offsets[] = $pos;
-                       $originalGlyphIdx = $glyphMap[$n];
-                       $glyphPos = $this->glyphPos[$originalGlyphIdx];
-                       $glyphLen = $this->glyphPos[$originalGlyphIdx + 1] - $glyphPos;
-                       if ($glyfLength < $this->maxStrLenRead) {
-                               $data = substr($glyphData,$glyphPos,$glyphLen);
-                       }
-                       else {
-                               if ($glyphLen > 0) $data = $this->get_chunk($glyfOffset+$glyphPos,$glyphLen);
-                               else $data = '';
-                       }
-                       if ($glyphLen > 0) $up = unpack("n", substr($data,0,2));
-                       if ($glyphLen > 2 && ($up[1] & (1 << 15)) ) {
-                               $pos_in_glyph = 10;
-                               $flags = GF_MORE;
-                               while ($flags & GF_MORE) {
-                                       $up = unpack("n", substr($data,$pos_in_glyph,2));
-                                       $flags = $up[1];
-                                       $up = unpack("n", substr($data,$pos_in_glyph+2,2));
-                                       $glyphIdx = $up[1];
-                                       $data = $this->_set_ushort($data, $pos_in_glyph + 2, $glyphSet[$glyphIdx]);
-                                       $pos_in_glyph += 4;
-                                       if ($flags & GF_WORDS) { $pos_in_glyph += 4; }
-                                       else { $pos_in_glyph += 2; }
-                                       if ($flags & GF_SCALE) { $pos_in_glyph += 2; }
-                                       else if ($flags & GF_XYSCALE) { $pos_in_glyph += 4; }
-                                       else if ($flags & GF_TWOBYTWO) { $pos_in_glyph += 8; }
-                               }
-                       }
-                       $glyf .= $data;
-                       $pos += $glyphLen;
-                       if ($pos % 4 != 0) {
-                               $padding = 4 - ($pos % 4);
-                               $glyf .= str_repeat("\0",$padding);
-                               $pos += $padding;
-                       }
-               }
-               $offsets[] = $pos;
-               $this->add('glyf', $glyf);
-
-               // loca - Index to location
-               $locastr = '';
-               if ((($pos + 1) >> 1) > 0xFFFF) {
-                       $indexToLocFormat = 1;        // long format
-                       foreach($offsets AS $offset) { $locastr .= pack("N",$offset); }
-               }
-               else {
-                       $indexToLocFormat = 0;        // short format
-                       foreach($offsets AS $offset) { $locastr .= pack("n",($offset/2)); }
-               }
-               $this->add('loca', $locastr);
-
-               // head - Font header
-               $head = $this->get_table('head');
-               $head = $this->_set_ushort($head, 50, $indexToLocFormat);
-               $this->add('head', $head);
-
-               fclose($this->fh);
-
-               // Put the TTF file together
-               $stm = '';
-               $numTables = count($this->otables);
-               $searchRange = 1;
-               $entrySelector = 0;
-               while ($searchRange * 2 <= $numTables) {
-                       $searchRange = $searchRange * 2;
-                       $entrySelector = $entrySelector + 1;
-               }
-               $searchRange = $searchRange * 16;
-               $rangeShift = $numTables * 16 - $searchRange;
-
-               // Header
-               $stm .= (pack("Nnnnn", 0x74727565, $numTables, $searchRange, $entrySelector, $rangeShift));     // 0x74727565 "true" for Mac
-               // 0x00010000 for Windows
-
-               // Table directory
-               $tables = $this->otables;
-               ksort ($tables); 
-               $offset = 12 + $numTables * 16;
-               foreach ($tables AS $tag=>$data) {
-                       if ($tag == 'head') { $head_start = $offset; }
-                       $stm .= $tag;
-                       $checksum = $this->calcChecksum($data);
-                       $stm .= pack("nn", $checksum[0],$checksum[1]);
-                       $stm .= pack("NN", $offset, strlen($data));
-                       $paddedLength = (strlen($data)+3)&~3;
-                       $offset = $offset + $paddedLength;
-               }
-
-               // Table data
-               foreach ($tables AS $tag=>$data) {
-                       $data .= "\0\0\0";
-                       $stm .= substr($data,0,(strlen($data)&~3));
-               }
-
-               $checksum = $this->calcChecksum($stm);
-               $checksum = $this->sub32(array(0xB1B0,0xAFBA), $checksum);
-               $chk = pack("nn", $checksum[0],$checksum[1]);
-               $stm = $this->splice($stm,($head_start + 8),$chk);
-               return $stm ;
-       }
-
-
-}
-
-
+<?php\r
+\r
+\r
+/*******************************************************************************\r
+* TTFontFile class                                                             *\r
+*                                                                              *\r
+* This class is based on The ReportLab Open Source PDF library                 *\r
+* written in Python - http://www.reportlab.com/software/opensource/            *\r
+* together with ideas from the OpenOffice source code and others.              *\r
+*                                                                              *\r
+* Version:  1.02                                                               *\r
+* Date:     2010-06-07                                                         *\r
+* Author:   Ian Back <ianb@bpm1.com>                                           *\r
+* License:  LGPL                                                               *\r
+* Copyright (c) Ian Back, 2010                                                 *\r
+* This header must be retained in any redistribution or                        *\r
+* modification of the file.                                                    *\r
+*                                                                              *\r
+*******************************************************************************/\r
+// TrueType Font Glyph operators\r
+define("GF_WORDS",(1 << 0));\r
+define("GF_SCALE",(1 << 3));\r
+define("GF_MORE",(1 << 5));\r
+define("GF_XYSCALE",(1 << 6));\r
+define("GF_TWOBYTWO",(1 << 7));\r
+\r
+\r
+\r
+class TTFontFile {\r
+\r
+var $_pos;\r
+var $numTables;\r
+var $searchRange;\r
+var $entrySelector;\r
+var $rangeShift;\r
+var $tables;\r
+var $otables;\r
+var $filename;\r
+var $fh;\r
+var $hmetrics;\r
+var $glyphPos;\r
+var $charToGlyph;\r
+var $ascent;\r
+var $descent;\r
+var $name;\r
+var $familyName;\r
+var $styleName;\r
+var $fullName;\r
+var $uniqueFontID;\r
+var $unitsPerEm;\r
+var $bbox;\r
+var $capHeight;\r
+var $stemV;\r
+var $italicAngle;\r
+var $flags;\r
+var $underlinePosition;\r
+var $underlineThickness;\r
+var $charWidths;\r
+var $defaultWidth;\r
+var $maxStrLenRead;\r
+\r
+       function TTFontFile() {\r
+               $this->maxStrLenRead = 200000;  // Maximum size of glyf table to read in as string (otherwise reads each glyph from file)\r
+       }\r
+\r
+\r
+       function getMetrics($file, $presubset=0) {\r
+               $this->filename = $file;\r
+               $this->fh = fopen($file,'rb') or die('Can\'t open file ' . $file);\r
+               $this->_pos = 0;\r
+               $this->charWidths = array();\r
+               $this->hmetrics = array();\r
+               $this->glyphPos = array();\r
+               $this->charToGlyph = array();\r
+               $this->tables = array();\r
+               $this->otables = array();\r
+               $this->ascent = 0;\r
+               $this->descent = 0;\r
+               if ($presubset) { $this->skip(4); }\r
+               else { $this->readHeader(); }\r
+               $this->readTableDirectory($presubset);\r
+               $this->extractInfo($presubset); \r
+               fclose($this->fh);\r
+       }\r
+\r
+       function readHeader() {\r
+               // read the sfnt header at the current position\r
+               $this->version = $version = $this->read_ulong();\r
+               if ($version==0x4F54544F) \r
+                       die("Postscript outlines are not supported");\r
+               if ($version==0x74746366) \r
+                       die("TTC Font collections are not supported");\r
+               if (!in_array($version, array(0x00010000,0x74727565)))\r
+                       die("Not a TrueType font: version=".$version);\r
+               return true;\r
+       }\r
+\r
+       function readTableDirectory($presubset=1) {\r
+               $this->numTables = $this->read_ushort();\r
+            $this->searchRange = $this->read_ushort();\r
+            $this->entrySelector = $this->read_ushort();\r
+            $this->rangeShift = $this->read_ushort();\r
+            $this->tables = array();   \r
+            for ($i=0;$i<$this->numTables;$i++) {      // 1.02\r
+                $record = array();\r
+                $record['tag'] = $this->read_tag();\r
+                $record['checksum'] = array($this->read_ushort(),$this->read_ushort());\r
+                $record['offset'] = $this->read_ulong();\r
+                $record['length'] = $this->read_ulong();\r
+                $this->tables[$record['tag']] = $record;\r
+               }\r
+               if (!$presubset) $this->checksumTables();\r
+       }\r
+\r
+       function checksumTables() {\r
+               // Check the checksums for all tables\r
+               foreach($this->tables AS $t) {\r
+                 if ($t['length'] > 0 && $t['length'] < $this->maxStrLenRead) {        // 1.02\r
+               $table = $this->get_chunk($t['offset'], $t['length']);\r
+               $checksum = $this->calcChecksum($table);\r
+               if ($t['tag'] == 'head') {\r
+                               $up = unpack('n*', substr($table,8,4));\r
+                               $adjustment[0] = $up[1];\r
+                               $adjustment[1] = $up[2];\r
+                       $checksum = $this->sub32($checksum, $adjustment);\r
+                       }\r
+               $xchecksum = $t['checksum'];\r
+               if ($xchecksum != $checksum) \r
+                   die(sprintf('TTF file "%s": invalid checksum %s table: %s (expected %s)', $this->filename,dechex($checksum[0]).dechex($checksum[1]),$t['tag'],dechex($xchecksum[0]).dechex($xchecksum[1])));\r
+                 }\r
+               }\r
+       }\r
+\r
+       function sub32($x, $y) {\r
+               $xlo = $x[1];\r
+               $xhi = $x[0];\r
+               $ylo = $y[1];\r
+               $yhi = $y[0];\r
+               if ($ylo > $xlo) { $xlo += 1 << 16; $yhi += 1; }\r
+               $reslo = $xlo-$ylo;\r
+               if ($yhi > $xhi) { $xhi += 1 << 16;  }\r
+               $reshi = $xhi-$yhi;\r
+               $reshi = $reshi & 0xFFFF;\r
+               return array($reshi, $reslo);\r
+       }\r
+\r
+       function calcChecksum($data)  {\r
+               if (strlen($data) % 4) { $data .= str_repeat("\0",(4-(strlen($data) % 4))); }\r
+               $hi=0x0000;\r
+               $lo=0x0000;\r
+               for($i=0;$i<strlen($data);$i+=4) {\r
+                       $hi += (ord($data[$i])<<8) + ord($data[$i+1]);\r
+                       $lo += (ord($data[$i+2])<<8) + ord($data[$i+3]);\r
+                       $hi += $lo >> 16;\r
+                       $lo = $lo & 0xFFFF;\r
+                       $hi = $hi & 0xFFFF;\r
+               }\r
+               return array($hi, $lo);\r
+       }\r
+\r
+       function get_table_pos($tag) {\r
+               $offset = $this->tables[$tag]['offset'];\r
+               $length = $this->tables[$tag]['length'];\r
+               return array($offset, $length);\r
+       }\r
+\r
+       function seek($pos) {\r
+               $this->_pos = $pos;\r
+               fseek($this->fh,$this->_pos);\r
+       }\r
+\r
+       function skip($delta) {\r
+               $this->_pos = $this->_pos + $delta;\r
+               fseek($this->fh,$this->_pos);\r
+       }\r
+\r
+       function seek_table($tag, $offset_in_table = 0) {\r
+               $tpos = $this->get_table_pos($tag);\r
+               $this->_pos = $tpos[0] + $offset_in_table;\r
+               fseek($this->fh, $this->_pos);\r
+               return $this->_pos;\r
+       }\r
+\r
+       function read_tag() {\r
+               $this->_pos += 4;\r
+               return fread($this->fh,4);\r
+       }\r
+\r
+       function read_short() {\r
+               $this->_pos += 2;\r
+               $s = fread($this->fh,2);\r
+               $a = (ord($s[0])<<8) + ord($s[1]);\r
+               if ($a & (1 << 15) ) { $a = ($a - (1 << 16)) ; }\r
+               return $a;\r
+       }\r
+\r
+       function read_ushort() {\r
+               $this->_pos += 2;\r
+               $s = fread($this->fh,2);\r
+               return (ord($s[0])<<8) + ord($s[1]);\r
+       }\r
+\r
+       function read_ulong() {\r
+               $this->_pos += 4;\r
+               $s = fread($this->fh,4);\r
+               // if large uInt32 as an integer, PHP converts it to -ve\r
+               return (ord($s[0])*16777216) + (ord($s[1])<<16) + (ord($s[2])<<8) + ord($s[3]); //      16777216  = 1<<24\r
+       }\r
+\r
+       function get_ushort($pos) {\r
+               fseek($this->fh,$pos);\r
+               $s = fread($this->fh,2);\r
+               return (ord($s[0])<<8) + ord($s[1]);\r
+       }\r
+\r
+       function get_ulong($pos) {\r
+               fseek($this->fh,$pos);\r
+               $s = fread($this->fh,4);\r
+               // iF large uInt32 as an integer, PHP converts it to -ve\r
+               return (ord($s[0])*16777216) + (ord($s[1])<<16) + (ord($s[2])<<8) + ord($s[3]); //      16777216  = 1<<24\r
+       }\r
+\r
+       function pack_short($val) {\r
+               if ($val<0) { \r
+                       $val = abs($val);\r
+                       $val = ~$val;\r
+                       $val += 1;\r
+               }\r
+               return pack("n",$val); \r
+       }\r
+\r
+       function splice($stream, $offset, $value) {\r
+               return substr($stream,0,$offset) . $value . substr($stream,$offset+strlen($value));\r
+       }\r
+\r
+       function _set_ushort($stream, $offset, $value) {\r
+               $up = pack("n", $value);\r
+               return $this->splice($stream, $offset, $up);\r
+       }\r
+\r
+       function get_chunk($pos, $length) {\r
+               fseek($this->fh,$pos);\r
+               if ($length <1) { return ''; }  // 1.02\r
+               return (fread($this->fh,$length));\r
+       }\r
+\r
+       function get_table($tag) {\r
+               list($pos, $length) = $this->get_table_pos($tag);\r
+               if ($length == 0) { die('Truetype font ('.$this->filename.'): error reading table: '.$tag); }   // 1.02\r
+               fseek($this->fh,$pos);\r
+               return (fread($this->fh,$length));\r
+       }\r
+\r
+       function add($tag, $data) {\r
+               if ($tag == 'head') {\r
+                       $data = $this->splice($data, 8, "\0\0\0\0");\r
+               }\r
+               $this->otables[$tag] = $data;\r
+       }\r
+\r
+\r
+\r
+/////////////////////////////////////////////////////////////////////////////////////////\r
+\r
+\r
+       function extractInfo($presubset=0) {\r
+               // = 0 ; validate; does not need glyphPos or charToGlyph\r
+               // presubset = 1; no validation; does not need name and other metrics\r
+               ///////////////////////////////////\r
+               // name - Naming table\r
+               ///////////////////////////////////\r
+               if (!$presubset) { \r
+                       $name_offset = $this->seek_table("name");\r
+                       $format = $this->read_ushort();\r
+                       if ($format != 0)\r
+                               die("Unknown name table format ".$format);\r
+                       $numRecords = $this->read_ushort();\r
+                       $string_data_offset = $name_offset + $this->read_ushort();\r
+\r
+                       $names = array(1=>'',2=>'',3=>'',4=>'',6=>'');\r
+                       $K = array_keys($names);\r
+                       $nameCount = count($names);\r
+                       for ($i=0;$i<$numRecords; $i++) {\r
+                               $platformId = $this->read_ushort();\r
+                               $encodingId = $this->read_ushort();\r
+                               $languageId = $this->read_ushort();\r
+                               $nameId = $this->read_ushort();\r
+                               $length = $this->read_ushort();\r
+                               $offset = $this->read_ushort();\r
+                               if (!in_array($nameId,$K)) continue;\r
+                               $N = '';\r
+                               if ($platformId == 3 && $encodingId == 1 && $languageId == 0x409) { // Microsoft, Unicode, US English, PS Name\r
+                                       $opos = $this->_pos;\r
+                                       $this->seek($string_data_offset + $offset);\r
+                                       if ($length % 2 != 0)\r
+                                               die("PostScript name is UTF-16BE string of odd length");\r
+                                       $length /= 2;\r
+                                       $N = '';\r
+                                       while ($length > 0) {\r
+                                               $char = $this->read_ushort();\r
+                                               $N .= (chr($char));     // 1.02\r
+                                               $length -= 1;\r
+                                       }\r
+                                       $this->_pos = $opos;\r
+                                       $this->seek($opos);\r
+                               }\r
+                               else if ($platformId == 1 && $encodingId == 0 && $languageId == 0) { // Macintosh, Roman, English, PS Name\r
+                                       $opos = $this->_pos;\r
+                                       $N = $this->get_chunk($string_data_offset + $offset, $length);\r
+                                       $this->_pos = $opos;\r
+                                       $this->seek($opos);\r
+                               }\r
+                               if ($N && $names[$nameId]=='') {\r
+                                       $names[$nameId] = $N;\r
+                                       $nameCount -= 1;\r
+                                       if ($nameCount==0) break;\r
+                               }\r
+                       }\r
+                       if ($names[6])\r
+                               $psName = preg_replace('/ /','-',$names[6]);\r
+                       else if ($names[4])\r
+                               $psName = preg_replace('/ /','-',$names[4]);\r
+                       else if ($names[1])\r
+                               $psName = preg_replace('/ /','-',$names[1]);\r
+                       else\r
+                               $psName = '';\r
+                       if (!$psName)\r
+                               die("Could not find PostScript font name");\r
+                       for ($i=0;$i<strlen($psName);$i++) {\r
+                               $c = $psName{$i};       // 1.02\r
+                               $oc = ord($c);\r
+                               if ($oc>126 || strpos(' [](){}<>/%',$c)!==false)\r
+                                       die("psName=".$psName." contains invalid character ".$c." ie U+".ord(c));\r
+                       }\r
+                       $this->name = $psName;\r
+                       if ($names[1]) { $this->familyName = $names[1]; } else { $this->familyName = $psName; }\r
+                       if ($names[2]) { $this->styleName = $names[2]; } else { $this->styleName = 'Regular'; }\r
+                       if ($names[4]) { $this->fullName = $names[4]; } else { $this->fullName = $psName; }\r
+                       if ($names[3]) { $this->uniqueFontID = $names[3]; } else { $this->uniqueFontID = $psName; }\r
+               }\r
+\r
+               ///////////////////////////////////\r
+               // head - Font header table\r
+               ///////////////////////////////////\r
+               $this->seek_table("head");\r
+               if ($presubset) { $this->skip(18); }\r
+               else {\r
+                       $ver_maj = $this->read_ushort();\r
+                       $ver_min = $this->read_ushort();\r
+                       if ($ver_maj != 1)\r
+                               die('Unknown head table version '. $ver_maj .'.'. $ver_min);\r
+                       $this->fontRevision = $this->read_ushort() . $this->read_ushort();\r
+\r
+                       $this->skip(4);\r
+                       $magic = $this->read_ulong();\r
+                       if ($magic != 0x5F0F3CF5) \r
+                               die('Invalid head table magic ' .$magic);\r
+                       $this->skip(2);\r
+               }\r
+               $this->unitsPerEm = $unitsPerEm = $this->read_ushort(); // 1.02\r
+               $scale = 1000 / $unitsPerEm;    // 1.02\r
+               if ($presubset) { $this->skip(30); }    // 1.02\r
+               else { \r
+                       $this->skip(16);\r
+                       $xMin = $this->read_short();\r
+                       $yMin = $this->read_short();\r
+                       $xMax = $this->read_short();\r
+                       $yMax = $this->read_short();\r
+                       $this->bbox = array(($xMin*$scale), ($yMin*$scale), ($xMax*$scale), ($yMax*$scale));\r
+                       $this->skip(3*2);\r
+               }\r
+               $indexToLocFormat = $this->read_ushort();\r
+               $glyphDataFormat = $this->read_ushort();\r
+               if ($glyphDataFormat != 0)\r
+                       die('Unknown glyph data format '.$glyphDataFormat);\r
+\r
+               ///////////////////////////////////\r
+               // hhea metrics table\r
+               ///////////////////////////////////\r
+               // ttf2t1 seems to use this value rather than the one in OS/2 - so put in for compatibility\r
+               if (isset($this->tables["hhea"])) {\r
+                       $this->seek_table("hhea");\r
+                       $this->skip(4);\r
+                       $hheaAscender = $this->read_short();\r
+                       $hheaDescender = $this->read_short();\r
+                       $this->ascent = ($hheaAscender *$scale);\r
+                       $this->descent = ($hheaDescender *$scale);\r
+               }\r
+\r
+               ///////////////////////////////////\r
+               // OS/2 - OS/2 and Windows metrics table\r
+               ///////////////////////////////////\r
+               if (isset($this->tables["OS/2"])) {\r
+                       $this->seek_table("OS/2");\r
+                       $version = $this->read_ushort();\r
+                       $this->skip(2);\r
+                       $usWeightClass = $this->read_ushort();\r
+                       $this->skip(2);\r
+                       $fsType = $this->read_ushort();\r
+       //              if ($fsType == 0x0002 || ($fsType & 0x0300) != 0) \r
+       //                      die('Font does not allow subsetting/embedding');\r
+                       $this->skip(58);   //11*2 + 10 + 4*4 + 4 + 3*2\r
+                       $sTypoAscender = $this->read_short();\r
+                       $sTypoDescender = $this->read_short();\r
+                       if (!$this->ascent) $this->ascent = ($sTypoAscender*$scale);\r
+                       if (!$this->descent) $this->descent = ($sTypoDescender*$scale);\r
+                       if ($version > 1) {\r
+                               $this->skip(16);\r
+                               $sCapHeight = $this->read_short();\r
+                               $this->capHeight = ($sCapHeight*$scale);\r
+                       }\r
+                       else {\r
+                               $this->capHeight = $this->ascent;\r
+                       }\r
+               }\r
+               else {\r
+                       $usWeightClass = 500;\r
+                       if (!$this->ascent) $this->ascent = ($yMax*$scale);\r
+                       if (!$this->descent) $this->descent = ($yMin*$scale);\r
+                       $this->capHeight = $this->ascent;\r
+               }\r
+               $this->stemV = 50 + intval(pow(($usWeightClass / 65.0),2));\r
+\r
+               ///////////////////////////////////\r
+               // post - PostScript table\r
+               ///////////////////////////////////\r
+               $this->seek_table("post");\r
+               if ($presubset) { $this->skip(4); }\r
+               else {\r
+                       $ver_maj = $this->read_ushort();\r
+                       $ver_min = $this->read_ushort();\r
+                       if ($ver_maj <1 || $ver_maj >4) \r
+                               die('Unknown post table version '.$ver_maj);\r
+               }\r
+               $this->italicAngle = $this->read_short() + $this->read_ushort() / 65536.0;\r
+               $this->underlinePosition = $this->read_short() * $scale;\r
+               $this->underlineThickness = $this->read_short() * $scale;\r
+               $isFixedPitch = $this->read_ulong();\r
+\r
+               $this->flags = 4;\r
+\r
+               if ($this->italicAngle!= 0) \r
+                       $this->flags = $this->flags | 64;\r
+               if ($usWeightClass >= 600)\r
+                       $this->flags = $this->flags | 262144;\r
+               if ($isFixedPitch)\r
+                       $this->flags = $this->flags | 1;\r
+\r
+               ///////////////////////////////////\r
+               // hhea - Horizontal header table\r
+               ///////////////////////////////////\r
+               $this->seek_table("hhea");\r
+               if ($presubset) { $this->skip(32); }\r
+               else {\r
+                       $ver_maj = $this->read_ushort();\r
+                       $ver_min = $this->read_ushort();\r
+                       if ($ver_maj != 1)\r
+                               die('Unknown hhea table version '.$ver_maj);\r
+                       $this->skip(28);\r
+               }\r
+               $metricDataFormat = $this->read_ushort();\r
+               if ($metricDataFormat != 0)\r
+                       die('Unknown horizontal metric data format '.$metricDataFormat);\r
+               $numberOfHMetrics = $this->read_ushort();\r
+               if ($numberOfHMetrics == 0) \r
+                       die('Number of horizontal metrics is 0');\r
+\r
+               ///////////////////////////////////\r
+               // maxp - Maximum profile table\r
+               ///////////////////////////////////\r
+               $this->seek_table("maxp");\r
+               if ($presubset) { $this->skip(4); }\r
+               else {\r
+                       $ver_maj = $this->read_ushort();\r
+                       $ver_min = $this->read_ushort();\r
+                       if ($ver_maj != 1)\r
+                               die('Unknown maxp table version '.$ver_maj);\r
+               }\r
+               $numGlyphs = $this->read_ushort();\r
+\r
+               ///////////////////////////////////\r
+               // cmap - Character to glyph index mapping table\r
+               ///////////////////////////////////\r
+               $cmap_offset = $this->seek_table("cmap");\r
+               $this->skip(2);\r
+               $cmapTableCount = $this->read_ushort();\r
+               $unicode_cmap_offset = 0;\r
+               for ($i=0;$i<$cmapTableCount;$i++) {\r
+                       $platformID = $this->read_ushort();\r
+                       $encodingID = $this->read_ushort();\r
+                       $offset = $this->read_ulong();\r
+                       $save_pos = $this->_pos;\r
+                       if ($platformID == 3 && $encodingID == 1) { // Microsoft, Unicode\r
+                               $format = $this->get_ushort($cmap_offset + $offset);\r
+                               if ($format == 4) {\r
+                                       $unicode_cmap_offset = $cmap_offset + $offset;\r
+                                       break;\r
+                               }\r
+                       }\r
+                       else if ($platformID == 0) { // Unicode -- assume all encodings are compatible\r
+                               $format = $this->get_ushort($cmap_offset + $offset);\r
+                               if ($format == 4) {\r
+                                       $unicode_cmap_offset = $cmap_offset + $offset;\r
+                                       break;\r
+                               }\r
+                       }\r
+                       $this->seek($save_pos );\r
+               }\r
+\r
+               if (!$unicode_cmap_offset)\r
+                       die('Font does not have cmap for Unicode (platform 3, encoding 1, format 4, or platform 0, any encoding, format 4)');\r
+               $this->seek($unicode_cmap_offset + 2);\r
+               $length = $this->read_ushort();\r
+               $limit = $unicode_cmap_offset + $length;\r
+               $this->skip(2);\r
+\r
+               $segCount = $this->read_ushort() / 2;\r
+               $this->skip(6);\r
+               $endCount = array();\r
+               for($i=0; $i<$segCount; $i++) { $endCount[] = $this->read_ushort(); }\r
+               $this->skip(2);\r
+               $startCount = array();\r
+               for($i=0; $i<$segCount; $i++) { $startCount[] = $this->read_ushort(); }\r
+               $idDelta = array();\r
+               for($i=0; $i<$segCount; $i++) { $idDelta[] = $this->read_short(); }             // ???? was unsigned short\r
+               $idRangeOffset_start = $this->_pos;\r
+               $idRangeOffset = array();\r
+               for($i=0; $i<$segCount; $i++) { $idRangeOffset[] = $this->read_ushort(); }\r
+\r
+               $glyphToChar = array();\r
+               $charToGlyph = array();\r
+               for ($n=0;$n<$segCount;$n++) {\r
+                       for ($unichar=$startCount[$n];$unichar<($endCount[$n] + 1);$unichar++) {\r
+                               if ($idRangeOffset[$n] == 0)\r
+                                       $glyph = ($unichar + $idDelta[$n]) & 0xFFFF;\r
+                               else {\r
+                                       $offset = ($unichar - $startCount[$n]) * 2 + $idRangeOffset[$n];\r
+                                       $offset = $idRangeOffset_start + 2 * $n + $offset;\r
+                                       if ($offset >= $limit)\r
+                                               $glyph = 0;\r
+                                       else {\r
+                                               $glyph = $this->get_ushort($offset);\r
+                                               if ($glyph != 0)\r
+                                               $glyph = ($glyph + $idDelta[$n]) & 0xFFFF;\r
+                                       }\r
+                               }\r
+                               if ($presubset) $charToGlyph[$unichar] = $glyph;\r
+                               $glyphToChar[$glyph][] = $unichar;\r
+                       }\r
+               }\r
+               if ($presubset) $this->charToGlyph = $charToGlyph;\r
+\r
+               ///////////////////////////////////\r
+               // hmtx - Horizontal metrics table\r
+               ///////////////////////////////////\r
+               $this->seek_table("hmtx");\r
+               $aw = 0;\r
+               $this->charWidths = array();\r
+               $this->hmetrics = array();\r
+               for( $glyph=0; $glyph<$numberOfHMetrics; $glyph++) {\r
+                       $aw = $this->read_ushort();\r
+                       $lsb = $this->read_short();\r
+                       $this->hmetrics[] = array($aw, $lsb);\r
+                       $aw = $scale*$aw;\r
+                       if ($glyph == 0)\r
+                               $this->defaultWidth = $aw;\r
+                       if (isset($glyphToChar[$glyph])) {\r
+                               foreach($glyphToChar[$glyph] AS $char) {\r
+                                       $this->charWidths[$char] = round($aw);\r
+                               }\r
+                       }\r
+               }\r
+               for( $glyph=$numberOfHMetrics; $glyph<$numGlyphs; $glyph++) {\r
+                       $lsb = $this->read_ushort();\r
+                       $this->hmetrics[] = array($aw, $lsb);\r
+                       if (isset($glyphToChar[$glyph])) {\r
+                               foreach($glyphToChar[$glyph] AS $char) {\r
+                                       $this->charWidths[$char] = round($aw);\r
+                               }\r
+                       }\r
+               }\r
+\r
+               ///////////////////////////////////\r
+               // loca - Index to location\r
+               ///////////////////////////////////\r
+               if ($presubset) {\r
+                       $this->seek_table('loca');\r
+                       $this->glyphPos = array();\r
+                       if ($indexToLocFormat == 0) {\r
+                               for ($n=0; $n<=$numGlyphs; $n++) {      // 1.02\r
+                                       $this->glyphPos[] = ($this->read_ushort() * 2);\r
+                               }\r
+                       }\r
+                       else if ($indexToLocFormat == 1) {\r
+                               for ($n=0; $n<=$numGlyphs; $n++) {      // 1.02\r
+                                       $this->glyphPos[] = ($this->read_ulong());\r
+                               }\r
+                       }\r
+                       else \r
+                               die('Unknown location table format '.$indexToLocFormat);\r
+               }\r
+       }\r
+\r
+\r
+/////////////////////////////////////////////////////////////////////////////////////////\r
+\r
+\r
+       function makeSubset($subset) {\r
+               $this->fh = fopen($this->filename ,'rb') or die('Can\'t open file ' . $this->filename );\r
+               $this->otables = array();\r
+               $glyphMap = array(0=>0); \r
+               $glyphSet = array(0=>0);\r
+               $codeToGlyph = array();\r
+               foreach($subset AS $code) {\r
+                       if (isset($this->charToGlyph[$code]))\r
+                               $originalGlyphIdx = $this->charToGlyph[$code];\r
+                       else\r
+                               $originalGlyphIdx = 0;\r
+                       if (!isset($glyphSet[$originalGlyphIdx])) {\r
+                               $glyphSet[$originalGlyphIdx] = count($glyphMap);\r
+                               $glyphMap[] = $originalGlyphIdx;\r
+                       }\r
+                       $codeToGlyph[$code] = $glyphSet[$originalGlyphIdx];\r
+               }\r
+\r
+               list($start,$dummy) = $this->get_table_pos('glyf');\r
+\r
+               $n = 0;\r
+               while ($n < count($glyphMap)) {\r
+                       $originalGlyphIdx = $glyphMap[$n];\r
+                       $glyphPos = $this->glyphPos[$originalGlyphIdx];\r
+                       $glyphLen = $this->glyphPos[$originalGlyphIdx + 1] - $glyphPos;\r
+                       $n += 1;\r
+                       if (!$glyphLen) continue;\r
+                       $this->seek($start + $glyphPos);\r
+                       $numberOfContours = $this->read_short();\r
+                       if ($numberOfContours < 0) {\r
+                               $this->skip(8);\r
+                               $flags = GF_MORE;\r
+                               while ($flags & GF_MORE) {\r
+                                       $flags = $this->read_ushort();\r
+                                       $glyphIdx = $this->read_ushort();\r
+                                       if (!isset($glyphSet[$glyphIdx])) {\r
+                                               $glyphSet[$glyphIdx] = count($glyphMap);\r
+                                               $glyphMap[] = $glyphIdx;\r
+                                       }\r
+                                       if ($flags & GF_WORDS)\r
+                                               $this->skip(4);\r
+                                       else\r
+                                               $this->skip(2);\r
+                                       if ($flags & GF_SCALE)\r
+                                               $this->skip(2);\r
+                                       else if ($flags & GF_XYSCALE)\r
+                                               $this->skip(4);\r
+                                       else if ($flags & GF_TWOBYTWO)\r
+                                               $this->skip(8);\r
+                               }\r
+                       }\r
+               }\r
+\r
+               $numGlyphs = $n = count($glyphMap);\r
+               while ($n > 1 && $this->hmetrics[$n][0] == $this->hmetrics[$n - 1][0]) { $n -= 1; }\r
+               $numberOfHMetrics = $n;\r
+\r
+               //tables copied from the original\r
+               $tags = array ('name', 'OS/2', 'prep');\r
+               foreach($tags AS $tag) { $this->add($tag, $this->get_table($tag)); }\r
+               $tags = array ('cvt ', 'fpgm');\r
+               foreach($tags AS $tag) {        // 1.02\r
+                       if (isset($this->table['tag'])) { $this->add($tag, $this->get_table($tag)); }\r
+               }\r
+\r
+               // post - PostScript\r
+               $opost = $this->get_table('post');\r
+               $post = "\x00\x03\x00\x00" . substr($opost,4,12) . "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";\r
+               $this->add('post', $post);\r
+\r
+               // hhea - Horizontal Header\r
+               $hhea = $this->get_table('hhea');\r
+               $hhea = $this->_set_ushort($hhea, 34, $numberOfHMetrics);\r
+               $this->add('hhea', $hhea);\r
+\r
+               // maxp - Maximum Profile\r
+               $maxp = $this->get_table('maxp');\r
+               $maxp = $this->_set_ushort($maxp, 4, $numGlyphs);\r
+               $this->add('maxp', $maxp);\r
+\r
+               // cmap - Character to glyph mapping - Format 6\r
+               $entryCount = count($subset);\r
+               $length = 10 + $entryCount * 2;\r
+               $cmap = array(0, 1,     // Index : version, number of subtables\r
+                       1, 0,                   // Subtable : platform, encoding\r
+                       0, 12,          // offset (hi,lo)\r
+                       6, $length,     // Format 6 Mapping table: format, length\r
+                       0, 1,                   // language, First char code\r
+                       $entryCount);\r
+\r
+               foreach($subset AS $code) { $cmap[] = $codeToGlyph[$code]; }\r
+               $cmapstr = '';\r
+               foreach($cmap AS $cm) { $cmapstr .= pack("n",$cm); }\r
+               $this->add('cmap', $cmapstr);\r
+\r
+/*\r
+               // cmap - Character to glyph mapping - Format 4 (MS / )\r
+               $segCount = 2;\r
+               $searchRange = 1;\r
+               $entrySelector = 0;\r
+               while ($searchRange * 2 <= $segCount ) {\r
+                       $searchRange = $searchRange * 2;\r
+                       $entrySelector = $entrySelector + 1;\r
+               }\r
+               $searchRange = $searchRange * 16;\r
+               $rangeShift = $segCount * 16 - $searchRange;\r
+               $length = 48 + ($numGlyphs-1);\r
+               $cmap = array(0, 1,     // Index : version, number of subtables\r
+                       3, 0,                   // Subtable : platform (MS=3), encoding\r
+                       0, 12,          // Subtable : offset (hi,lo)\r
+                       4, $length, 0,  // Format 4 Mapping table: format, length, language\r
+                       $segCount*2,\r
+                       $searchRange,\r
+                       $entrySelector,\r
+                       $rangeShift,\r
+                       $numGlyphs, 0xFFFF,     // endCode(s)\r
+                       0,\r
+                       1, 0xFFFF,                      // startCode(s)\r
+                       0, 1,                           // idDelta(s) Delta for all character codes in segment\r
+                       0, 0);                  // idRangeOffset[segCount]      Offset in bytes to glyph indexArray, or 0\r
+               foreach($subset AS $code) { $cmap[] = $codeToGlyph[$code]; }\r
+               $cmap[] = 0xFFFF;\r
+               $cmapstr = '';\r
+               foreach($cmap AS $cm) { $cmapstr .= pack("n",$cm); }\r
+               $this->add('cmap', $cmapstr);\r
+*/\r
+\r
+\r
+               // hmtx - Horizontal Metrics\r
+               $hmtxstr = '';\r
+               for($n=0;$n<$numGlyphs;$n++) {\r
+                       $originalGlyphIdx = $glyphMap[$n];\r
+                       $aw = $this->hmetrics[$originalGlyphIdx][0];\r
+                       $lsb = $this->hmetrics[$originalGlyphIdx][1];\r
+                       if ($n < $numberOfHMetrics) { $hmtxstr .= pack("n",$aw); }\r
+                       $hmtxstr .= $this->pack_short($lsb);\r
+               }\r
+               $this->add('hmtx', $hmtxstr);\r
+\r
+               // glyf - Glyph data\r
+               list($glyfOffset,$glyfLength) = $this->get_table_pos('glyf');\r
+               if ($glyfLength < $this->maxStrLenRead) {\r
+                       $glyphData = $this->get_table('glyf');\r
+               }\r
+\r
+               $offsets = array();\r
+               $glyf = '';\r
+               $pos = 0;\r
+\r
+               for ($n=0;$n<$numGlyphs;$n++) {\r
+                       $offsets[] = $pos;\r
+                       $originalGlyphIdx = $glyphMap[$n];\r
+                       $glyphPos = $this->glyphPos[$originalGlyphIdx];\r
+                       $glyphLen = $this->glyphPos[$originalGlyphIdx + 1] - $glyphPos;\r
+                       if ($glyfLength < $this->maxStrLenRead) {\r
+                               $data = substr($glyphData,$glyphPos,$glyphLen);\r
+                       }\r
+                       else {\r
+                               if ($glyphLen > 0) $data = $this->get_chunk($glyfOffset+$glyphPos,$glyphLen);\r
+                               else $data = '';\r
+                       }\r
+                       if ($glyphLen > 0) $up = unpack("n", substr($data,0,2));\r
+                       if ($glyphLen > 2 && ($up[1] & (1 << 15)) ) {\r
+                               $pos_in_glyph = 10;\r
+                               $flags = GF_MORE;\r
+                               while ($flags & GF_MORE) {\r
+                                       $up = unpack("n", substr($data,$pos_in_glyph,2));\r
+                                       $flags = $up[1];\r
+                                       $up = unpack("n", substr($data,$pos_in_glyph+2,2));\r
+                                       $glyphIdx = $up[1];\r
+                                       $data = $this->_set_ushort($data, $pos_in_glyph + 2, $glyphSet[$glyphIdx]);\r
+                                       $pos_in_glyph += 4;\r
+                                       if ($flags & GF_WORDS) { $pos_in_glyph += 4; }\r
+                                       else { $pos_in_glyph += 2; }\r
+                                       if ($flags & GF_SCALE) { $pos_in_glyph += 2; }\r
+                                       else if ($flags & GF_XYSCALE) { $pos_in_glyph += 4; }\r
+                                       else if ($flags & GF_TWOBYTWO) { $pos_in_glyph += 8; }\r
+                               }\r
+                       }\r
+                       $glyf .= $data;\r
+                       $pos += $glyphLen;\r
+                       if ($pos % 4 != 0) {\r
+                               $padding = 4 - ($pos % 4);\r
+                               $glyf .= str_repeat("\0",$padding);\r
+                               $pos += $padding;\r
+                       }\r
+               }\r
+               $offsets[] = $pos;\r
+               $this->add('glyf', $glyf);\r
+\r
+               // loca - Index to location\r
+               $locastr = '';\r
+               if ((($pos + 1) >> 1) > 0xFFFF) {\r
+                       $indexToLocFormat = 1;        // long format\r
+                       foreach($offsets AS $offset) { $locastr .= pack("N",$offset); }\r
+               }\r
+               else {\r
+                       $indexToLocFormat = 0;        // short format\r
+                       foreach($offsets AS $offset) { $locastr .= pack("n",($offset/2)); }\r
+               }\r
+               $this->add('loca', $locastr);\r
+\r
+               // head - Font header\r
+               $head = $this->get_table('head');\r
+               $head = $this->_set_ushort($head, 50, $indexToLocFormat);\r
+               $this->add('head', $head);\r
+\r
+               fclose($this->fh);\r
+\r
+               // Put the TTF file together\r
+               $stm = '';\r
+               $numTables = count($this->otables);\r
+               $searchRange = 1;\r
+               $entrySelector = 0;\r
+               while ($searchRange * 2 <= $numTables) {\r
+                       $searchRange = $searchRange * 2;\r
+                       $entrySelector = $entrySelector + 1;\r
+               }\r
+               $searchRange = $searchRange * 16;\r
+               $rangeShift = $numTables * 16 - $searchRange;\r
+\r
+               // Header\r
+               $stm .= (pack("Nnnnn", 0x74727565, $numTables, $searchRange, $entrySelector, $rangeShift));     // 0x74727565 "true" for Mac\r
+               // 0x00010000 for Windows\r
+\r
+               // Table directory\r
+               $tables = $this->otables;\r
+               ksort ($tables); \r
+               $offset = 12 + $numTables * 16;\r
+               foreach ($tables AS $tag=>$data) {\r
+                       if ($tag == 'head') { $head_start = $offset; }\r
+                       $stm .= $tag;\r
+                       $checksum = $this->calcChecksum($data);\r
+                       $stm .= pack("nn", $checksum[0],$checksum[1]);\r
+                       $stm .= pack("NN", $offset, strlen($data));\r
+                       $paddedLength = (strlen($data)+3)&~3;\r
+                       $offset = $offset + $paddedLength;\r
+               }\r
+\r
+               // Table data\r
+               foreach ($tables AS $tag=>$data) {\r
+                       $data .= "\0\0\0";\r
+                       $stm .= substr($data,0,(strlen($data)&~3));\r
+               }\r
+\r
+               $checksum = $this->calcChecksum($stm);\r
+               $checksum = $this->sub32(array(0xB1B0,0xAFBA), $checksum);\r
+               $chk = pack("nn", $checksum[0],$checksum[1]);\r
+               $stm = $this->splice($stm,($head_start + 8),$chk);\r
+               return $stm ;\r
+       }\r
+\r
+\r
+}\r
+\r
+\r
 ?>
\ No newline at end of file
index f2bdfd5..1f926a8 100644 (file)
@@ -1,15 +1,15 @@
-<?php
-$fpdf_charwidths['zapfdingbats']=array(
-       chr(0)=>0,chr(1)=>0,chr(2)=>0,chr(3)=>0,chr(4)=>0,chr(5)=>0,chr(6)=>0,chr(7)=>0,chr(8)=>0,chr(9)=>0,chr(10)=>0,chr(11)=>0,chr(12)=>0,chr(13)=>0,chr(14)=>0,chr(15)=>0,chr(16)=>0,chr(17)=>0,chr(18)=>0,chr(19)=>0,chr(20)=>0,chr(21)=>0,
-       chr(22)=>0,chr(23)=>0,chr(24)=>0,chr(25)=>0,chr(26)=>0,chr(27)=>0,chr(28)=>0,chr(29)=>0,chr(30)=>0,chr(31)=>0,' '=>278,'!'=>974,'"'=>961,'#'=>974,'$'=>980,'%'=>719,'&'=>789,'\''=>790,'('=>791,')'=>690,'*'=>960,'+'=>939,
-       ','=>549,'-'=>855,'.'=>911,'/'=>933,'0'=>911,'1'=>945,'2'=>974,'3'=>755,'4'=>846,'5'=>762,'6'=>761,'7'=>571,'8'=>677,'9'=>763,':'=>760,';'=>759,'<'=>754,'='=>494,'>'=>552,'?'=>537,'@'=>577,'A'=>692,
-       'B'=>786,'C'=>788,'D'=>788,'E'=>790,'F'=>793,'G'=>794,'H'=>816,'I'=>823,'J'=>789,'K'=>841,'L'=>823,'M'=>833,'N'=>816,'O'=>831,'P'=>923,'Q'=>744,'R'=>723,'S'=>749,'T'=>790,'U'=>792,'V'=>695,'W'=>776,
-       'X'=>768,'Y'=>792,'Z'=>759,'['=>707,'\\'=>708,']'=>682,'^'=>701,'_'=>826,'`'=>815,'a'=>789,'b'=>789,'c'=>707,'d'=>687,'e'=>696,'f'=>689,'g'=>786,'h'=>787,'i'=>713,'j'=>791,'k'=>785,'l'=>791,'m'=>873,
-       'n'=>761,'o'=>762,'p'=>762,'q'=>759,'r'=>759,'s'=>892,'t'=>892,'u'=>788,'v'=>784,'w'=>438,'x'=>138,'y'=>277,'z'=>415,'{'=>392,'|'=>392,'}'=>668,'~'=>668,chr(127)=>0,chr(128)=>390,chr(129)=>390,chr(130)=>317,chr(131)=>317,
-       chr(132)=>276,chr(133)=>276,chr(134)=>509,chr(135)=>509,chr(136)=>410,chr(137)=>410,chr(138)=>234,chr(139)=>234,chr(140)=>334,chr(141)=>334,chr(142)=>0,chr(143)=>0,chr(144)=>0,chr(145)=>0,chr(146)=>0,chr(147)=>0,chr(148)=>0,chr(149)=>0,chr(150)=>0,chr(151)=>0,chr(152)=>0,chr(153)=>0,
-       chr(154)=>0,chr(155)=>0,chr(156)=>0,chr(157)=>0,chr(158)=>0,chr(159)=>0,chr(160)=>0,chr(161)=>732,chr(162)=>544,chr(163)=>544,chr(164)=>910,chr(165)=>667,chr(166)=>760,chr(167)=>760,chr(168)=>776,chr(169)=>595,chr(170)=>694,chr(171)=>626,chr(172)=>788,chr(173)=>788,chr(174)=>788,chr(175)=>788,
-       chr(176)=>788,chr(177)=>788,chr(178)=>788,chr(179)=>788,chr(180)=>788,chr(181)=>788,chr(182)=>788,chr(183)=>788,chr(184)=>788,chr(185)=>788,chr(186)=>788,chr(187)=>788,chr(188)=>788,chr(189)=>788,chr(190)=>788,chr(191)=>788,chr(192)=>788,chr(193)=>788,chr(194)=>788,chr(195)=>788,chr(196)=>788,chr(197)=>788,
-       chr(198)=>788,chr(199)=>788,chr(200)=>788,chr(201)=>788,chr(202)=>788,chr(203)=>788,chr(204)=>788,chr(205)=>788,chr(206)=>788,chr(207)=>788,chr(208)=>788,chr(209)=>788,chr(210)=>788,chr(211)=>788,chr(212)=>894,chr(213)=>838,chr(214)=>1016,chr(215)=>458,chr(216)=>748,chr(217)=>924,chr(218)=>748,chr(219)=>918,
-       chr(220)=>927,chr(221)=>928,chr(222)=>928,chr(223)=>834,chr(224)=>873,chr(225)=>828,chr(226)=>924,chr(227)=>924,chr(228)=>917,chr(229)=>930,chr(230)=>931,chr(231)=>463,chr(232)=>883,chr(233)=>836,chr(234)=>836,chr(235)=>867,chr(236)=>867,chr(237)=>696,chr(238)=>696,chr(239)=>874,chr(240)=>0,chr(241)=>874,
-       chr(242)=>760,chr(243)=>946,chr(244)=>771,chr(245)=>865,chr(246)=>771,chr(247)=>888,chr(248)=>967,chr(249)=>888,chr(250)=>831,chr(251)=>873,chr(252)=>927,chr(253)=>970,chr(254)=>918,chr(255)=>0);
-?>
+<?php\r
+$fpdf_charwidths['zapfdingbats']=array(\r
+       chr(0)=>0,chr(1)=>0,chr(2)=>0,chr(3)=>0,chr(4)=>0,chr(5)=>0,chr(6)=>0,chr(7)=>0,chr(8)=>0,chr(9)=>0,chr(10)=>0,chr(11)=>0,chr(12)=>0,chr(13)=>0,chr(14)=>0,chr(15)=>0,chr(16)=>0,chr(17)=>0,chr(18)=>0,chr(19)=>0,chr(20)=>0,chr(21)=>0,\r
+       chr(22)=>0,chr(23)=>0,chr(24)=>0,chr(25)=>0,chr(26)=>0,chr(27)=>0,chr(28)=>0,chr(29)=>0,chr(30)=>0,chr(31)=>0,' '=>278,'!'=>974,'"'=>961,'#'=>974,'$'=>980,'%'=>719,'&'=>789,'\''=>790,'('=>791,')'=>690,'*'=>960,'+'=>939,\r
+       ','=>549,'-'=>855,'.'=>911,'/'=>933,'0'=>911,'1'=>945,'2'=>974,'3'=>755,'4'=>846,'5'=>762,'6'=>761,'7'=>571,'8'=>677,'9'=>763,':'=>760,';'=>759,'<'=>754,'='=>494,'>'=>552,'?'=>537,'@'=>577,'A'=>692,\r
+       'B'=>786,'C'=>788,'D'=>788,'E'=>790,'F'=>793,'G'=>794,'H'=>816,'I'=>823,'J'=>789,'K'=>841,'L'=>823,'M'=>833,'N'=>816,'O'=>831,'P'=>923,'Q'=>744,'R'=>723,'S'=>749,'T'=>790,'U'=>792,'V'=>695,'W'=>776,\r
+       'X'=>768,'Y'=>792,'Z'=>759,'['=>707,'\\'=>708,']'=>682,'^'=>701,'_'=>826,'`'=>815,'a'=>789,'b'=>789,'c'=>707,'d'=>687,'e'=>696,'f'=>689,'g'=>786,'h'=>787,'i'=>713,'j'=>791,'k'=>785,'l'=>791,'m'=>873,\r
+       'n'=>761,'o'=>762,'p'=>762,'q'=>759,'r'=>759,'s'=>892,'t'=>892,'u'=>788,'v'=>784,'w'=>438,'x'=>138,'y'=>277,'z'=>415,'{'=>392,'|'=>392,'}'=>668,'~'=>668,chr(127)=>0,chr(128)=>390,chr(129)=>390,chr(130)=>317,chr(131)=>317,\r
+       chr(132)=>276,chr(133)=>276,chr(134)=>509,chr(135)=>509,chr(136)=>410,chr(137)=>410,chr(138)=>234,chr(139)=>234,chr(140)=>334,chr(141)=>334,chr(142)=>0,chr(143)=>0,chr(144)=>0,chr(145)=>0,chr(146)=>0,chr(147)=>0,chr(148)=>0,chr(149)=>0,chr(150)=>0,chr(151)=>0,chr(152)=>0,chr(153)=>0,\r
+       chr(154)=>0,chr(155)=>0,chr(156)=>0,chr(157)=>0,chr(158)=>0,chr(159)=>0,chr(160)=>0,chr(161)=>732,chr(162)=>544,chr(163)=>544,chr(164)=>910,chr(165)=>667,chr(166)=>760,chr(167)=>760,chr(168)=>776,chr(169)=>595,chr(170)=>694,chr(171)=>626,chr(172)=>788,chr(173)=>788,chr(174)=>788,chr(175)=>788,\r
+       chr(176)=>788,chr(177)=>788,chr(178)=>788,chr(179)=>788,chr(180)=>788,chr(181)=>788,chr(182)=>788,chr(183)=>788,chr(184)=>788,chr(185)=>788,chr(186)=>788,chr(187)=>788,chr(188)=>788,chr(189)=>788,chr(190)=>788,chr(191)=>788,chr(192)=>788,chr(193)=>788,chr(194)=>788,chr(195)=>788,chr(196)=>788,chr(197)=>788,\r
+       chr(198)=>788,chr(199)=>788,chr(200)=>788,chr(201)=>788,chr(202)=>788,chr(203)=>788,chr(204)=>788,chr(205)=>788,chr(206)=>788,chr(207)=>788,chr(208)=>788,chr(209)=>788,chr(210)=>788,chr(211)=>788,chr(212)=>894,chr(213)=>838,chr(214)=>1016,chr(215)=>458,chr(216)=>748,chr(217)=>924,chr(218)=>748,chr(219)=>918,\r
+       chr(220)=>927,chr(221)=>928,chr(222)=>928,chr(223)=>834,chr(224)=>873,chr(225)=>828,chr(226)=>924,chr(227)=>924,chr(228)=>917,chr(229)=>930,chr(230)=>931,chr(231)=>463,chr(232)=>883,chr(233)=>836,chr(234)=>836,chr(235)=>867,chr(236)=>867,chr(237)=>696,chr(238)=>696,chr(239)=>874,chr(240)=>0,chr(241)=>874,\r
+       chr(242)=>760,chr(243)=>946,chr(244)=>771,chr(245)=>865,chr(246)=>771,chr(247)=>888,chr(248)=>967,chr(249)=>888,chr(250)=>831,chr(251)=>873,chr(252)=>927,chr(253)=>970,chr(254)=>918,chr(255)=>0);\r
+?>\r
index 44fc774..a71f5b9 100755 (executable)
-<?php
-/**
-* Class to provide IPv4 calculations
-*
-* Module written/ported by Eric Kilfoil <eric@ypass.net>
-*
-* This is the copyright notice from the PERL Net::DNS module:
-*
-* Copyright (c) 1997-2000 Michael Fuhr.  All rights reserved.  This
-* program is free software; you can redistribute it and/or modify it
-* under the same terms as Perl itself.
-*
-* The majority of this is _NOT_ my code.  I simply ported it from the
-* PERL Net::DNS module.
-*
-* The author of the Net::DNS module is Michael Fuhr <mike@fuhr.org>
-* http://www.fuhr.org/~mfuhr/perldns/
-*
-* Michael Fuhr has nothing to with the porting of this code to PHP.
-* Any questions directly related to this class library should be directed
-* to the maintainer.
-*
-*
-* PHP versions 4 and 5
-*
-* LICENSE: This source file is subject to version 3.01 of the PHP license
-* that is available through the world-wide-web at the following URI:
-* http://www.php.net/license/3_01.txt.  If you did not receive a copy of
-* the PHP License and are unable to obtain it through the web, please
-* send a note to license@php.net so we can mail you a copy immediately.
-*
-* @category   Net
-* @package    Net_IPv4
-* @author     Eric Kilfoil <edk@ypass.net>
-* @author     Marco Kaiser <bate@php.net>
-* @author     Florian Anderiasch <fa@php.net>
-* @copyright  The PHP Group
-* @license    http://www.php.net/license/3_01.txt  PHP License 3.01
-* @version    CVS: $Id: DNS.php 302014 2010-08-09 06:17:29Z bate $
-* @link       http://pear.php.net/package/Net_DNS
-*/
-
-/* Include information {{{ */
-
-    require_once("Net/DNS/Header.php");
-    require_once("Net/DNS/Question.php");
-    require_once("Net/DNS/Packet.php");
-    require_once("Net/DNS/Resolver.php");
-    require_once("Net/DNS/RR.php");
-
-/* }}} */
-/* GLOBAL VARIABLE definitions {{{ */
-
-// Used by the Net_DNS_Resolver object to generate an ID
-
-$GLOBALS['_Net_DNS_packet_id'] = mt_rand(0, 65535);
-
-/* }}} */
-/* Net_DNS object definition (incomplete) {{{ */
-/**
- * Initializes a resolver object
- *
- * Net_DNS allows you to query a nameserver for DNS  lookups.  It bypasses the
- * system resolver library  entirely, which allows you to query any nameserver,
- * set your own values for retries, timeouts, recursion,  etc.
- *
- * @author Eric Kilfoil <eric@ypass.net>
- * @package Net_DNS
- * @version 0.01alpha
- */
-class Net_DNS
-{
-    /* class variable definitions {{{ */
-    /**
-     * A default resolver object created on instantiation
-     *
-     * @var Net_DNS_Resolver object
-     */
-    var $resolver;
-    var $VERSION = '1.00b2'; // This should probably be a define :(
-    var $PACKETSZ = 512;
-    var $HFIXEDSZ = 12;
-    var $QFIXEDSZ = 4;
-    var $RRFIXEDSZ = 10;
-    var $INT32SZ = 4;
-    var $INT16SZ = 2;
-    /* }}} */
-    /* class constructor - Net_DNS() {{{ */
-
-    /**
-     * Initializes a resolver object
-     *
-     * @see Net_DNS_Resolver
-     * @param array $defaults
-     * @return Net_DNS
-     */
-    function Net_DNS($defaults = array())
-    {
-        $this->resolver = new Net_DNS_Resolver($defaults);
-    }
-    /* }}} */
-    /* Net_DNS::opcodesbyname() {{{ */
-    /**
-     * Translates opcode names to integers
-     *
-     * Translates the name of a DNS OPCODE into it's assigned  number
-     * listed in RFC1035, RFC1996, or RFC2136. Valid  OPCODES are:
-     * <ul>
-     *   <li>QUERY
-     *   <li>IQUERY
-     *   <li>STATUS
-     *   <li>NS_NOTIFY_OP
-     *   <li>UPDATE
-     * <ul>
-     *
-     * @param   string  $opcode A DNS Packet OPCODE name
-     * @return  integer The integer value of an OPCODE
-     * @see     Net_DNS::opcodesbyval()
-     */
-    function opcodesbyname($opcode)
-    {
-        $op = array(
-                'QUERY'        => 0,   // RFC 1035
-                'IQUERY'       => 1,   // RFC 1035
-                'STATUS'       => 2,   // RFC 1035
-                'NS_NOTIFY_OP' => 4,   // RFC 1996
-                'UPDATE'       => 5,   // RFC 2136
-                );
-        if (! strlen($op[$opcode])) {
-            $op[$opcode] = null;
-        }
-        return $op[$opcode];
-    }
-
-    /* }}} */
-    /* Net_DNS::opcodesbyval() {{{*/
-    /**
-     * Translates opcode integers into names
-     *
-     * Translates the integer value of an opcode into it's name
-     *
-     * @param   integer $opcodeval  A DNS packet opcode integer
-     * @return  string  The name of the OPCODE
-     * @see     Net_DNS::opcodesbyname()
-     */
-    function opcodesbyval($opcodeval)
-    {
-        $opval = array(
-                0 => 'QUERY',
-                1 => 'IQUERY',
-                2 => 'STATUS',
-                4 => 'NS_NOTIFY_OP',
-                5 => 'UPDATE',
-                );
-        if (! strlen($opval[$opcodeval])) {
-            $opval[$opcodeval] = null;
-        }
-        return $opval[$opcodeval];
-    }
-
-    /*}}}*/
-    /* Net_DNS::rcodesbyname() {{{*/
-    /**
-     * Translates rcode names to integers
-     *
-     * Translates the name of a DNS RCODE (result code) into it's assigned number.
-     * <ul>
-     *   <li>NOERROR
-     *   <li>FORMERR
-     *   <li>SERVFAIL
-     *   <li>NXDOMAIN
-     *   <li>NOTIMP
-     *   <li>REFUSED
-     *   <li>YXDOMAIN
-     *   <li>YXRRSET
-     *   <li>NXRRSET
-     *   <li>NOTAUTH
-     *   <li>NOTZONE
-     * <ul>
-     *
-     * @param   string  $rcode  A DNS Packet RCODE name
-     * @return  integer The integer value of an RCODE
-     * @see     Net_DNS::rcodesbyval()
-     */
-    function rcodesbyname($rcode)
-    {
-        $rc = array(
-                'NOERROR'   => 0,   // RFC 1035
-                'FORMERR'   => 1,   // RFC 1035
-                'SERVFAIL'  => 2,   // RFC 1035
-                'NXDOMAIN'  => 3,   // RFC 1035
-                'NOTIMP'    => 4,   // RFC 1035
-                'REFUSED'   => 5,   // RFC 1035
-                'YXDOMAIN'  => 6,   // RFC 2136
-                'YXRRSET'   => 7,   // RFC 2136
-                'NXRRSET'   => 8,   // RFC 2136
-                'NOTAUTH'   => 9,   // RFC 2136
-                'NOTZONE'   => 10,    // RFC 2136
-                );
-        if (! strlen($rc[$rcode])) {
-            $rc[$rcode] = null;
-        }
-        return $rc[$rcode];
-    }
-
-    /*}}}*/
-    /* Net_DNS::rcodesbyval() {{{*/
-    /**
-     * Translates rcode integers into names
-     *
-     * Translates the integer value of an rcode into it's name
-     *
-     * @param   integer $rcodeval   A DNS packet rcode integer
-     * @return  string  The name of the RCODE
-     * @see     Net_DNS::rcodesbyname()
-     */
-    function rcodesbyval($rcodeval)
-    {
-        $rc = array(
-                0 => 'NOERROR',
-                1 => 'FORMERR',
-                2 => 'SERVFAIL',
-                3 => 'NXDOMAIN',
-                4 => 'NOTIMP',
-                5 => 'REFUSED',
-                6 => 'YXDOMAIN',
-                7 => 'YXRRSET',
-                8 => 'NXRRSET',
-                9 => 'NOTAUTH',
-                10 => 'NOTZONE',
-                );
-        if (! strlen($rc[$rcodeval])) {
-            $rc[$rcodeval] = null;
-        }
-        return $rc[$rcodeval];
-    }
-
-    /*}}}*/
-    /* Net_DNS::typesbyname() {{{*/
-    /**
-     * Translates RR type names into integers
-     *
-     * Translates a Resource Record from it's name to it's  integer value.
-     * Valid resource record types are:
-     *
-     * <ul>
-     *   <li>A
-     *   <li>NS
-     *   <li>MD
-     *   <li>MF
-     *   <li>CNAME
-     *   <li>SOA
-     *   <li>MB
-     *   <li>MG
-     *   <li>MR
-     *   <li>NULL
-     *   <li>WKS
-     *   <li>PTR
-     *   <li>HINFO
-     *   <li>MINFO
-     *   <li>MX
-     *   <li>TXT
-     *   <li>RP
-     *   <li>AFSDB
-     *   <li>X25
-     *   <li>ISDN
-     *   <li>RT
-     *   <li>NSAP
-     *   <li>NSAP_PTR
-     *   <li>SIG
-     *   <li>KEY
-     *   <li>PX
-     *   <li>GPOS
-     *   <li>AAAA
-     *   <li>LOC
-     *   <li>NXT
-     *   <li>EID
-     *   <li>NIMLOC
-     *   <li>SRV
-     *   <li>ATMA
-     *   <li>NAPTR
-     *   <li>TSIG
-     *   <li>SPF
-     *   <li>UINFO
-     *   <li>UID
-     *   <li>GID
-     *   <li>UNSPEC
-     *   <li>IXFR
-     *   <li>AXFR
-     *   <li>MAILB
-     *   <li>MAILA
-     *   <li>ANY
-     * <ul>
-     *
-     * @param   string  $rrtype A DNS packet RR type name
-     * @return  integer The integer value of an RR type
-     * @see     Net_DNS::typesbyval()
-     */
-    function typesbyname($rrtype)
-    {
-        $rc = array(
-                'A'             => 1,
-                'NS'            => 2,
-                'MD'            => 3,
-                'MF'            => 4,
-                'CNAME'         => 5,
-                'SOA'           => 6,
-                'MB'            => 7,
-                'MG'            => 8,
-                'MR'            => 9,
-                'NULL'          => 10,
-                'WKS'           => 11,
-                'PTR'           => 12,
-                'HINFO'         => 13,
-                'MINFO'         => 14,
-                'MX'            => 15,
-                'TXT'           => 16,
-                'RP'            => 17,
-                'AFSDB'         => 18,
-                'X25'           => 19,
-                'ISDN'          => 20,
-                'RT'            => 21,
-                'NSAP'          => 22,
-                'NSAP_PTR'      => 23,
-                'SIG'           => 24,
-                'KEY'           => 25,
-                'PX'            => 26,
-                'GPOS'          => 27,
-                'AAAA'          => 28,
-                'LOC'           => 29,
-                'NXT'           => 30,
-                'EID'           => 31,
-                'NIMLOC'        => 32,
-                'SRV'           => 33,
-                'ATMA'          => 34,
-                'NAPTR'         => 35,
-                'SPF'           => 99,
-                'UINFO'         => 100,
-                'UID'           => 101,
-                'GID'           => 102,
-                'UNSPEC'        => 103,
-                'TSIG'          => 250,
-                'IXFR'          => 251,
-                'AXFR'          => 252,
-                'MAILB'         => 253,
-                'MAILA'         => 254,
-                'ANY'           => 255,
-                );
-        if (empty($rc[$rrtype])) {
-            $rc[$rrtype] = null;
-        }
-        return $rc[$rrtype];
-    }
-
-    /*}}}*/
-    /* Net_DNS::typesbyval() {{{*/
-    /**
-     * Translates RR type integers into names
-     *
-     * Translates the integer value of an RR type into it's name
-     *
-     * @param   integer $rrtypeval  A DNS packet RR type integer
-     * @return  string  The name of the RR type
-     * @see     Net_DNS::typesbyname()
-     */
-    function typesbyval($rrtypeval)
-    {
-        $rc = array(
-                1 => 'A',
-                2 => 'NS',
-                3 => 'MD',
-                4 => 'MF',
-                5 => 'CNAME',
-                6 => 'SOA',
-                7 => 'MB',
-                8 => 'MG',
-                9 => 'MR',
-                10 => 'NULL',
-                11 => 'WKS',
-                12 => 'PTR',
-                13 => 'HINFO',
-                14 => 'MINFO',
-                15 => 'MX',
-                16 => 'TXT',
-                17 => 'RP',
-                18 => 'AFSDB',
-                19 => 'X25',
-                20 => 'ISDN',
-                21 => 'RT',
-                22 => 'NSAP',
-                23 => 'NSAP_PTR',
-                24 => 'SIG',
-                25 => 'KEY',
-                26 => 'PX',
-                27 => 'GPOS',
-                28 => 'AAAA',
-                29 => 'LOC',
-                30 => 'NXT',
-                31 => 'EID',
-                32 => 'NIMLOC',
-                33 => 'SRV',
-                34 => 'ATMA',
-                35 => 'NAPTR',
-                99 => 'SPF',
-                100 => 'UINFO',
-                101 => 'UID',
-                102 => 'GID',
-                103 => 'UNSPEC',
-                250 => 'TSIG',
-                251 => 'IXFR',
-                252 => 'AXFR',
-                253 => 'MAILB',
-                254 => 'MAILA',
-                255 => 'ANY',
-                );
-        $rrtypeval = preg_replace(array('/\s*/',' /^0*/'), '', $rrtypeval);
-        if (empty($rc[$rrtypeval])) {
-            $rc[$rrtypeval] = null;
-        }
-        return $rc[$rrtypeval];
-    }
-
-    /*}}}*/
-    /* Net_DNS::classesbyname() {{{*/
-    /**
-     * translates a DNS class from it's name to it's  integer value. Valid
-     * class names are:
-     * <ul>
-     *   <li>IN
-     *   <li>CH
-     *   <li>HS
-     *   <li>NONE
-     *   <li>ANY
-     * </ul>
-     *
-     * @param   string  $class  A DNS packet class type
-     * @return  integer The integer value of an class type
-     * @see     Net_DNS::classesbyval()
-     */
-    function classesbyname($class)
-    {
-        $rc = array(
-                'IN'   => 1,   // RFC 1035
-                'CH'   => 3,   // RFC 1035
-                'HS'   => 4,   // RFC 1035
-                'NONE' => 254, // RFC 2136
-                'ANY'  => 255  // RFC 1035
-                );
-        if (!isset($rc[$class])) {
-            $rc[$class] = null;
-        }
-        return $rc[$class];
-    }
-
-    /*}}}*/
-    /* Net_DNS::classesbyval() {{{*/
-    /**
-     * Translates RR class integers into names
-     *
-     * Translates the integer value of an RR class into it's name
-     *
-     * @param   integer $classval   A DNS packet RR class integer
-     * @return  string  The name of the RR class
-     * @see     Net_DNS::classesbyname()
-     */
-    function classesbyval($classval)
-    {
-        $rc = array(
-                1 => 'IN',
-                3 => 'CH',
-                4 => 'HS',
-                254 => 'NONE',
-                255 => 'ANY'
-                );
-        $classval = preg_replace(array('/\s*/',' /^0*/'), '', $classval);
-        if (empty($rc[$classval])) {
-            $rc[$classval] = null;
-        }
-        return $rc[$classval];
-    }
-
-    /*}}}*/
-    /* not completed - Net_DNS::mx() {{{*/
-    /*}}}*/
-    /* not completed - Net_DNS::yxrrset() {{{*/
-    /*}}}*/
-    /* not completed - Net_DNS::nxrrset() {{{*/
-    /*}}}*/
-    /* not completed - Net_DNS::yxdomain() {{{*/
-    /*}}}*/
-    /* not completed - Net_DNS::nxdomain() {{{*/
-    /*}}}*/
-    /* not completed - Net_DNS::rr_add() {{{*/
-    /*}}}*/
-    /* not completed - Net_DNS::rr_del() {{{*/
-    /*}}}*/
-}
-/* }}} */
-/* VIM Settings {{{
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * soft-stop-width: 4
- * c indent on
- * End:
- * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et
- * vim<600: sw=4 ts=4
- * }}} */
-?>
+<?php\r
+/**\r
+* Class to provide IPv4 calculations\r
+*\r
+* Module written/ported by Eric Kilfoil <eric@ypass.net>\r
+*\r
+* This is the copyright notice from the PERL Net::DNS module:\r
+*\r
+* Copyright (c) 1997-2000 Michael Fuhr.  All rights reserved.  This\r
+* program is free software; you can redistribute it and/or modify it\r
+* under the same terms as Perl itself.\r
+*\r
+* The majority of this is _NOT_ my code.  I simply ported it from the\r
+* PERL Net::DNS module.\r
+*\r
+* The author of the Net::DNS module is Michael Fuhr <mike@fuhr.org>\r
+* http://www.fuhr.org/~mfuhr/perldns/\r
+*\r
+* Michael Fuhr has nothing to with the porting of this code to PHP.\r
+* Any questions directly related to this class library should be directed\r
+* to the maintainer.\r
+*\r
+*\r
+* PHP versions 4 and 5\r
+*\r
+* LICENSE: This source file is subject to version 3.01 of the PHP license\r
+* that is available through the world-wide-web at the following URI:\r
+* http://www.php.net/license/3_01.txt.  If you did not receive a copy of\r
+* the PHP License and are unable to obtain it through the web, please\r
+* send a note to license@php.net so we can mail you a copy immediately.\r
+*\r
+* @category   Net\r
+* @package    Net_IPv4\r
+* @author     Eric Kilfoil <edk@ypass.net>\r
+* @author     Marco Kaiser <bate@php.net>\r
+* @author     Florian Anderiasch <fa@php.net>\r
+* @copyright  The PHP Group\r
+* @license    http://www.php.net/license/3_01.txt  PHP License 3.01\r
+* @version    CVS: $Id: DNS.php 302014 2010-08-09 06:17:29Z bate $\r
+* @link       http://pear.php.net/package/Net_DNS\r
+*/\r
+\r
+/* Include information {{{ */\r
+\r
+    require_once("Net/DNS/Header.php");\r
+    require_once("Net/DNS/Question.php");\r
+    require_once("Net/DNS/Packet.php");\r
+    require_once("Net/DNS/Resolver.php");\r
+    require_once("Net/DNS/RR.php");\r
+\r
+/* }}} */\r
+/* GLOBAL VARIABLE definitions {{{ */\r
+\r
+// Used by the Net_DNS_Resolver object to generate an ID\r
+\r
+$GLOBALS['_Net_DNS_packet_id'] = mt_rand(0, 65535);\r
+\r
+/* }}} */\r
+/* Net_DNS object definition (incomplete) {{{ */\r
+/**\r
+ * Initializes a resolver object\r
+ *\r
+ * Net_DNS allows you to query a nameserver for DNS  lookups.  It bypasses the\r
+ * system resolver library  entirely, which allows you to query any nameserver,\r
+ * set your own values for retries, timeouts, recursion,  etc.\r
+ *\r
+ * @author Eric Kilfoil <eric@ypass.net>\r
+ * @package Net_DNS\r
+ * @version 0.01alpha\r
+ */\r
+class Net_DNS\r
+{\r
+    /* class variable definitions {{{ */\r
+    /**\r
+     * A default resolver object created on instantiation\r
+     *\r
+     * @var Net_DNS_Resolver object\r
+     */\r
+    var $resolver;\r
+    var $VERSION = '1.00b2'; // This should probably be a define :(\r
+    var $PACKETSZ = 512;\r
+    var $HFIXEDSZ = 12;\r
+    var $QFIXEDSZ = 4;\r
+    var $RRFIXEDSZ = 10;\r
+    var $INT32SZ = 4;\r
+    var $INT16SZ = 2;\r
+    /* }}} */\r
+    /* class constructor - Net_DNS() {{{ */\r
+\r
+    /**\r
+     * Initializes a resolver object\r
+     *\r
+     * @see Net_DNS_Resolver\r
+     * @param array $defaults\r
+     * @return Net_DNS\r
+     */\r
+    function Net_DNS($defaults = array())\r
+    {\r
+        $this->resolver = new Net_DNS_Resolver($defaults);\r
+    }\r
+    /* }}} */\r
+    /* Net_DNS::opcodesbyname() {{{ */\r
+    /**\r
+     * Translates opcode names to integers\r
+     *\r
+     * Translates the name of a DNS OPCODE into it's assigned  number\r
+     * listed in RFC1035, RFC1996, or RFC2136. Valid  OPCODES are:\r
+     * <ul>\r
+     *   <li>QUERY\r
+     *   <li>IQUERY\r
+     *   <li>STATUS\r
+     *   <li>NS_NOTIFY_OP\r
+     *   <li>UPDATE\r
+     * <ul>\r
+     *\r
+     * @param   string  $opcode A DNS Packet OPCODE name\r
+     * @return  integer The integer value of an OPCODE\r
+     * @see     Net_DNS::opcodesbyval()\r
+     */\r
+    function opcodesbyname($opcode)\r
+    {\r
+        $op = array(\r
+                'QUERY'        => 0,   // RFC 1035\r
+                'IQUERY'       => 1,   // RFC 1035\r
+                'STATUS'       => 2,   // RFC 1035\r
+                'NS_NOTIFY_OP' => 4,   // RFC 1996\r
+                'UPDATE'       => 5,   // RFC 2136\r
+                );\r
+        if (! strlen($op[$opcode])) {\r
+            $op[$opcode] = null;\r
+        }\r
+        return $op[$opcode];\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS::opcodesbyval() {{{*/\r
+    /**\r
+     * Translates opcode integers into names\r
+     *\r
+     * Translates the integer value of an opcode into it's name\r
+     *\r
+     * @param   integer $opcodeval  A DNS packet opcode integer\r
+     * @return  string  The name of the OPCODE\r
+     * @see     Net_DNS::opcodesbyname()\r
+     */\r
+    function opcodesbyval($opcodeval)\r
+    {\r
+        $opval = array(\r
+                0 => 'QUERY',\r
+                1 => 'IQUERY',\r
+                2 => 'STATUS',\r
+                4 => 'NS_NOTIFY_OP',\r
+                5 => 'UPDATE',\r
+                );\r
+        if (! strlen($opval[$opcodeval])) {\r
+            $opval[$opcodeval] = null;\r
+        }\r
+        return $opval[$opcodeval];\r
+    }\r
+\r
+    /*}}}*/\r
+    /* Net_DNS::rcodesbyname() {{{*/\r
+    /**\r
+     * Translates rcode names to integers\r
+     *\r
+     * Translates the name of a DNS RCODE (result code) into it's assigned number.\r
+     * <ul>\r
+     *   <li>NOERROR\r
+     *   <li>FORMERR\r
+     *   <li>SERVFAIL\r
+     *   <li>NXDOMAIN\r
+     *   <li>NOTIMP\r
+     *   <li>REFUSED\r
+     *   <li>YXDOMAIN\r
+     *   <li>YXRRSET\r
+     *   <li>NXRRSET\r
+     *   <li>NOTAUTH\r
+     *   <li>NOTZONE\r
+     * <ul>\r
+     *\r
+     * @param   string  $rcode  A DNS Packet RCODE name\r
+     * @return  integer The integer value of an RCODE\r
+     * @see     Net_DNS::rcodesbyval()\r
+     */\r
+    function rcodesbyname($rcode)\r
+    {\r
+        $rc = array(\r
+                'NOERROR'   => 0,   // RFC 1035\r
+                'FORMERR'   => 1,   // RFC 1035\r
+                'SERVFAIL'  => 2,   // RFC 1035\r
+                'NXDOMAIN'  => 3,   // RFC 1035\r
+                'NOTIMP'    => 4,   // RFC 1035\r
+                'REFUSED'   => 5,   // RFC 1035\r
+                'YXDOMAIN'  => 6,   // RFC 2136\r
+                'YXRRSET'   => 7,   // RFC 2136\r
+                'NXRRSET'   => 8,   // RFC 2136\r
+                'NOTAUTH'   => 9,   // RFC 2136\r
+                'NOTZONE'   => 10,    // RFC 2136\r
+                );\r
+        if (! strlen($rc[$rcode])) {\r
+            $rc[$rcode] = null;\r
+        }\r
+        return $rc[$rcode];\r
+    }\r
+\r
+    /*}}}*/\r
+    /* Net_DNS::rcodesbyval() {{{*/\r
+    /**\r
+     * Translates rcode integers into names\r
+     *\r
+     * Translates the integer value of an rcode into it's name\r
+     *\r
+     * @param   integer $rcodeval   A DNS packet rcode integer\r
+     * @return  string  The name of the RCODE\r
+     * @see     Net_DNS::rcodesbyname()\r
+     */\r
+    function rcodesbyval($rcodeval)\r
+    {\r
+        $rc = array(\r
+                0 => 'NOERROR',\r
+                1 => 'FORMERR',\r
+                2 => 'SERVFAIL',\r
+                3 => 'NXDOMAIN',\r
+                4 => 'NOTIMP',\r
+                5 => 'REFUSED',\r
+                6 => 'YXDOMAIN',\r
+                7 => 'YXRRSET',\r
+                8 => 'NXRRSET',\r
+                9 => 'NOTAUTH',\r
+                10 => 'NOTZONE',\r
+                );\r
+        if (! strlen($rc[$rcodeval])) {\r
+            $rc[$rcodeval] = null;\r
+        }\r
+        return $rc[$rcodeval];\r
+    }\r
+\r
+    /*}}}*/\r
+    /* Net_DNS::typesbyname() {{{*/\r
+    /**\r
+     * Translates RR type names into integers\r
+     *\r
+     * Translates a Resource Record from it's name to it's  integer value.\r
+     * Valid resource record types are:\r
+     *\r
+     * <ul>\r
+     *   <li>A\r
+     *   <li>NS\r
+     *   <li>MD\r
+     *   <li>MF\r
+     *   <li>CNAME\r
+     *   <li>SOA\r
+     *   <li>MB\r
+     *   <li>MG\r
+     *   <li>MR\r
+     *   <li>NULL\r
+     *   <li>WKS\r
+     *   <li>PTR\r
+     *   <li>HINFO\r
+     *   <li>MINFO\r
+     *   <li>MX\r
+     *   <li>TXT\r
+     *   <li>RP\r
+     *   <li>AFSDB\r
+     *   <li>X25\r
+     *   <li>ISDN\r
+     *   <li>RT\r
+     *   <li>NSAP\r
+     *   <li>NSAP_PTR\r
+     *   <li>SIG\r
+     *   <li>KEY\r
+     *   <li>PX\r
+     *   <li>GPOS\r
+     *   <li>AAAA\r
+     *   <li>LOC\r
+     *   <li>NXT\r
+     *   <li>EID\r
+     *   <li>NIMLOC\r
+     *   <li>SRV\r
+     *   <li>ATMA\r
+     *   <li>NAPTR\r
+     *   <li>TSIG\r
+     *   <li>SPF\r
+     *   <li>UINFO\r
+     *   <li>UID\r
+     *   <li>GID\r
+     *   <li>UNSPEC\r
+     *   <li>IXFR\r
+     *   <li>AXFR\r
+     *   <li>MAILB\r
+     *   <li>MAILA\r
+     *   <li>ANY\r
+     * <ul>\r
+     *\r
+     * @param   string  $rrtype A DNS packet RR type name\r
+     * @return  integer The integer value of an RR type\r
+     * @see     Net_DNS::typesbyval()\r
+     */\r
+    function typesbyname($rrtype)\r
+    {\r
+        $rc = array(\r
+                'A'             => 1,\r
+                'NS'            => 2,\r
+                'MD'            => 3,\r
+                'MF'            => 4,\r
+                'CNAME'         => 5,\r
+                'SOA'           => 6,\r
+                'MB'            => 7,\r
+                'MG'            => 8,\r
+                'MR'            => 9,\r
+                'NULL'          => 10,\r
+                'WKS'           => 11,\r
+                'PTR'           => 12,\r
+                'HINFO'         => 13,\r
+                'MINFO'         => 14,\r
+                'MX'            => 15,\r
+                'TXT'           => 16,\r
+                'RP'            => 17,\r
+                'AFSDB'         => 18,\r
+                'X25'           => 19,\r
+                'ISDN'          => 20,\r
+                'RT'            => 21,\r
+                'NSAP'          => 22,\r
+                'NSAP_PTR'      => 23,\r
+                'SIG'           => 24,\r
+                'KEY'           => 25,\r
+                'PX'            => 26,\r
+                'GPOS'          => 27,\r
+                'AAAA'          => 28,\r
+                'LOC'           => 29,\r
+                'NXT'           => 30,\r
+                'EID'           => 31,\r
+                'NIMLOC'        => 32,\r
+                'SRV'           => 33,\r
+                'ATMA'          => 34,\r
+                'NAPTR'         => 35,\r
+                'SPF'           => 99,\r
+                'UINFO'         => 100,\r
+                'UID'           => 101,\r
+                'GID'           => 102,\r
+                'UNSPEC'        => 103,\r
+                'TSIG'          => 250,\r
+                'IXFR'          => 251,\r
+                'AXFR'          => 252,\r
+                'MAILB'         => 253,\r
+                'MAILA'         => 254,\r
+                'ANY'           => 255,\r
+                );\r
+        if (empty($rc[$rrtype])) {\r
+            $rc[$rrtype] = null;\r
+        }\r
+        return $rc[$rrtype];\r
+    }\r
+\r
+    /*}}}*/\r
+    /* Net_DNS::typesbyval() {{{*/\r
+    /**\r
+     * Translates RR type integers into names\r
+     *\r
+     * Translates the integer value of an RR type into it's name\r
+     *\r
+     * @param   integer $rrtypeval  A DNS packet RR type integer\r
+     * @return  string  The name of the RR type\r
+     * @see     Net_DNS::typesbyname()\r
+     */\r
+    function typesbyval($rrtypeval)\r
+    {\r
+        $rc = array(\r
+                1 => 'A',\r
+                2 => 'NS',\r
+                3 => 'MD',\r
+                4 => 'MF',\r
+                5 => 'CNAME',\r
+                6 => 'SOA',\r
+                7 => 'MB',\r
+                8 => 'MG',\r
+                9 => 'MR',\r
+                10 => 'NULL',\r
+                11 => 'WKS',\r
+                12 => 'PTR',\r
+                13 => 'HINFO',\r
+                14 => 'MINFO',\r
+                15 => 'MX',\r
+                16 => 'TXT',\r
+                17 => 'RP',\r
+                18 => 'AFSDB',\r
+                19 => 'X25',\r
+                20 => 'ISDN',\r
+                21 => 'RT',\r
+                22 => 'NSAP',\r
+                23 => 'NSAP_PTR',\r
+                24 => 'SIG',\r
+                25 => 'KEY',\r
+                26 => 'PX',\r
+                27 => 'GPOS',\r
+                28 => 'AAAA',\r
+                29 => 'LOC',\r
+                30 => 'NXT',\r
+                31 => 'EID',\r
+                32 => 'NIMLOC',\r
+                33 => 'SRV',\r
+                34 => 'ATMA',\r
+                35 => 'NAPTR',\r
+                99 => 'SPF',\r
+                100 => 'UINFO',\r
+                101 => 'UID',\r
+                102 => 'GID',\r
+                103 => 'UNSPEC',\r
+                250 => 'TSIG',\r
+                251 => 'IXFR',\r
+                252 => 'AXFR',\r
+                253 => 'MAILB',\r
+                254 => 'MAILA',\r
+                255 => 'ANY',\r
+                );\r
+        $rrtypeval = preg_replace(array('/\s*/',' /^0*/'), '', $rrtypeval);\r
+        if (empty($rc[$rrtypeval])) {\r
+            $rc[$rrtypeval] = null;\r
+        }\r
+        return $rc[$rrtypeval];\r
+    }\r
+\r
+    /*}}}*/\r
+    /* Net_DNS::classesbyname() {{{*/\r
+    /**\r
+     * translates a DNS class from it's name to it's  integer value. Valid\r
+     * class names are:\r
+     * <ul>\r
+     *   <li>IN\r
+     *   <li>CH\r
+     *   <li>HS\r
+     *   <li>NONE\r
+     *   <li>ANY\r
+     * </ul>\r
+     *\r
+     * @param   string  $class  A DNS packet class type\r
+     * @return  integer The integer value of an class type\r
+     * @see     Net_DNS::classesbyval()\r
+     */\r
+    function classesbyname($class)\r
+    {\r
+        $rc = array(\r
+                'IN'   => 1,   // RFC 1035\r
+                'CH'   => 3,   // RFC 1035\r
+                'HS'   => 4,   // RFC 1035\r
+                'NONE' => 254, // RFC 2136\r
+                'ANY'  => 255  // RFC 1035\r
+                );\r
+        if (!isset($rc[$class])) {\r
+            $rc[$class] = null;\r
+        }\r
+        return $rc[$class];\r
+    }\r
+\r
+    /*}}}*/\r
+    /* Net_DNS::classesbyval() {{{*/\r
+    /**\r
+     * Translates RR class integers into names\r
+     *\r
+     * Translates the integer value of an RR class into it's name\r
+     *\r
+     * @param   integer $classval   A DNS packet RR class integer\r
+     * @return  string  The name of the RR class\r
+     * @see     Net_DNS::classesbyname()\r
+     */\r
+    function classesbyval($classval)\r
+    {\r
+        $rc = array(\r
+                1 => 'IN',\r
+                3 => 'CH',\r
+                4 => 'HS',\r
+                254 => 'NONE',\r
+                255 => 'ANY'\r
+                );\r
+        $classval = preg_replace(array('/\s*/',' /^0*/'), '', $classval);\r
+        if (empty($rc[$classval])) {\r
+            $rc[$classval] = null;\r
+        }\r
+        return $rc[$classval];\r
+    }\r
+\r
+    /*}}}*/\r
+    /* not completed - Net_DNS::mx() {{{*/\r
+    /*}}}*/\r
+    /* not completed - Net_DNS::yxrrset() {{{*/\r
+    /*}}}*/\r
+    /* not completed - Net_DNS::nxrrset() {{{*/\r
+    /*}}}*/\r
+    /* not completed - Net_DNS::yxdomain() {{{*/\r
+    /*}}}*/\r
+    /* not completed - Net_DNS::nxdomain() {{{*/\r
+    /*}}}*/\r
+    /* not completed - Net_DNS::rr_add() {{{*/\r
+    /*}}}*/\r
+    /* not completed - Net_DNS::rr_del() {{{*/\r
+    /*}}}*/\r
+}\r
+/* }}} */\r
+/* VIM Settings {{{\r
+ * Local variables:\r
+ * tab-width: 4\r
+ * c-basic-offset: 4\r
+ * soft-stop-width: 4\r
+ * c indent on\r
+ * End:\r
+ * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et\r
+ * vim<600: sw=4 ts=4\r
+ * }}} */\r
+?>\r
index 360d941..490f808 100755 (executable)
-<?php
-/**
-*  License Information:
-*
-*  Net_DNS:  A resolver library for PHP
-*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
-*  Maintainers:
-*  Marco Kaiser <bate@php.net>
-*  Florian Anderiasch <fa@php.net>
-*
-* PHP versions 4 and 5
-*
-* LICENSE: This source file is subject to version 3.01 of the PHP license
-* that is available through the world-wide-web at the following URI:
-* http://www.php.net/license/3_01.txt.  If you did not receive a copy of
-* the PHP License and are unable to obtain it through the web, please
-* send a note to license@php.net so we can mail you a copy immediately.
-*/
-
-/*  Net_DNS_Header object definition {{{ */
-/**
- * Object representation of the HEADER section of a DNS packet
- *
- * The Net_DNS::Header class contains the values of a DNS  packet.  It parses
- * the header of a DNS packet or can  generate the binary data
- * representation of the packet.  The format of the header is described in
- * RFC1035.
- *
- * @package Net_DNS
- */
-class Net_DNS_Header
-{
-    /* class variable definitions {{{ */
-    /**
-     * The packet's request id
-     *
-     * The request id of the packet represented as  a 16 bit integer.
-     */
-    var $id;
-    /**
-     * The QR bit in a DNS packet header
-     *
-     * The QR bit as described in RFC1035.  QR is set to 0 for queries, and
-     * 1 for repsones.
-     */
-    var $qr;
-    /**
-     * The OPCODE name of this packet.
-     *
-     * The string value (name) of the opcode for the DNS packet.
-     */
-    var $opcode;
-    /**
-     * The AA (authoritative answer) bit in a DNS packet header
-     *
-     * The AA bit as described in RFC1035.  AA is set to  1 if the answer
-     * is authoritative.  It has no meaning if QR is set to 0.
-     */
-    var $aa;
-    /**
-     * The TC (truncated) bit in a DNS packet header
-     *
-     * This flag is set to 1 if the response was truncated.  This flag has
-     * no meaning in a query packet.
-     */
-    var $tc;
-    /**
-     * The RD (recursion desired) bit in a DNS packet header
-     *
-     * This bit should be set to 1 in a query if recursion  is desired by
-     * the DNS server.
-     */
-    var $rd;
-    /**
-     * The RA (recursion available) bit in a DNS packet header
-     *
-     * This bit is set to 1 by the DNS server if the server is willing to
-     * perform recursion.
-     */
-    var $ra;
-    /**
-     * The RCODE name for this packet.
-     *
-     * The string value (name) of the rcode for the DNS packet.
-     */
-    var $rcode;
-    /**
-     * Number of questions contained within the packet
-     *
-     * 16bit integer representing the number of questions in the question
-     * section of the DNS packet.
-     *
-     * @var integer $qdcount
-     * @see     Net_DNS_Question class
-     */
-    var $qdcount;
-    /**
-     * Number of answer RRs contained within the packet
-     *
-     * 16bit integer representing the number of answer resource records
-     * contained in the answer section of the DNS packet.
-     *
-     * @var integer $ancount
-     * @see     Net_DNS_RR class
-     */
-    var $ancount;
-    /**
-     * Number of authority RRs within the packet
-     *
-     * 16bit integer representing the number of authority (NS) resource
-     * records  contained in the authority section of the DNS packet.
-     *
-     * @var integer $nscount
-     * @see     Net_DNS_RR class
-     */
-    var $nscount;
-    /**
-     * Number of additional RRs within the packet
-     *
-     * 16bit integer representing the number of additional resource records
-     * contained in the additional section of the DNS packet.
-     *
-     * @var integer $arcount
-     * @see     Net_DNS_RR class
-     */
-    var $arcount;
-
-    /* }}} */
-    /* class constructor - Net_DNS_Header($data = "") {{{ */
-    /**
-     * Initializes the default values for the Header object.
-     *
-     * Builds a header object from either default values, or from a DNS
-     * packet passed into the constructor as $data
-     *
-     * @param string $data  A DNS packet of which the header will be parsed.
-     * @return  object  Net_DNS_Header
-     * @access public
-     */
-    function Net_DNS_Header($data = '')
-    {
-        if (empty($data)) {
-            $this->id      = Net_DNS_Resolver::nextid();
-            $this->qr      = 0;
-            $this->opcode  = 0;
-            $this->aa      = 0;
-            $this->tc      = 0;
-            $this->rd      = 1;
-            $this->ra      = 0;
-            $this->rcode   = 0;
-            $this->qdcount = 1;
-            $this->ancount = 0;
-            $this->nscount = 0;
-            $this->arcount = 0;
-        } else {
-            /*
-             * The header MUST be at least 12 bytes.
-             * Passing the full datagram to this constructor
-             * will examine only the header section of the DNS packet
-             */
-            if (strlen($data) < 12) {
-                return false;
-            }
-
-            $a = unpack('nid/C2flags/n4counts', $data);
-            $this->id      = $a['id'];
-            $this->qr      = ($a['flags1'] >> 7) & 0x1;
-            $this->opcode  = ($a['flags1'] >> 3) & 0xf;
-            $this->aa      = ($a['flags1'] >> 2) & 0x1;
-            $this->tc      = ($a['flags1'] >> 1) & 0x1;
-            $this->rd      = $a['flags1'] & 0x1;
-            $this->ra      = ($a['flags2'] >> 7) & 0x1;
-            $this->rcode   = $a['flags2'] & 0xf;
-            $this->qdcount = $a['counts1'];
-            $this->ancount = $a['counts2'];
-            $this->nscount = $a['counts3'];
-            $this->arcount = $a['counts4'];
-        }
-
-
-        $dns = new Net_DNS();
-        if ($dns->opcodesbyval($this->opcode)) {
-            $this->opcode = $dns->opcodesbyval($this->opcode);
-        }
-        if ($dns->rcodesbyval($this->rcode)) {
-            $this->rcode = $dns->rcodesbyval($this->rcode);
-        }
-    }
-
-    /* }}} */
-    /* Net_DNS_Header::display() {{{ */
-    /**
-     * Displays the properties of the header.
-     *
-     * Displays the properties of the header.
-     *
-     * @access public
-     */
-    function display()
-    {
-        echo $this->string();
-    }
-
-    /* }}} */
-    /* Net_DNS_Header::string() {{{ */
-    /**
-     * Returns a formatted string containing the properties of the header.
-     *
-     * @return string   a formatted string containing the properties of the header.
-     * @access public
-     */
-    function string()
-    {
-        $retval = ';; id = ' . $this->id . "\n";
-        if ($this->opcode == 'UPDATE') {
-            $retval .= ';; qr = ' . $this->qr . '    ' .
-                'opcode = ' . $this->opcode . '    '   .
-                'rcode = ' . $this->rcode . "\n";
-            $retval .= ';; zocount = ' . $this->qdcount . '  ' .
-                'prcount = ' . $this->ancount . '  '           .
-                'upcount = ' . $this->nscount . '  '           .
-                'adcount = ' . $this->arcount . "\n";
-        } else {
-            $retval .= ';; qr = ' . $this->qr . '    ' .
-                'opcode = ' . $this->opcode . '    '   .
-                'aa = ' . $this->aa . '    '           .
-                'tc = ' . $this->tc . '    '           .
-                'rd = ' . $this->rd . "\n";
-
-            $retval .= ';; ra = ' . $this->ra . '    ' .
-                'rcode  = ' . $this->rcode . "\n";
-
-            $retval .= ';; qdcount = ' . $this->qdcount . '  ' .
-                'ancount = ' . $this->ancount . '  '    .
-                'nscount = ' . $this->nscount . '  '    .
-                'arcount = ' . $this->arcount . "\n";
-        }
-        return $retval;
-    }
-
-    /* }}} */
-    /* Net_DNS_Header::data() {{{ */
-    /**
-     * Returns the binary data containing the properties of the header
-     *
-     * Packs the properties of the Header object into a binary string
-     * suitable for using as the Header section of a DNS packet.
-     *
-     * @return string   binary representation of the header object
-     * @access public
-     */
-    function data()
-    {
-        $dns = new Net_DNS();
-        $opcode = $dns->opcodesbyname($this->opcode);
-        $rcode  = $dns->rcodesbyname($this->rcode);
-
-        $byte2 = ($this->qr << 7)
-            | ($opcode << 3)
-            | ($this->aa << 2)
-            | ($this->tc << 1)
-            | ($this->rd);
-
-        $byte3 = ($this->ra << 7) | $rcode;
-
-        return pack('nC2n4', $this->id,
-                $byte2,
-                $byte3,
-                $this->qdcount,
-                $this->ancount,
-                $this->nscount,
-                $this->arcount);
-    }
-
-    /* }}} */
-}
-/* }}} */
-/* VIM settings {{{
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * soft-stop-width: 4
- * c indent on
- * expandtab on
- * End:
- * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et
- * vim<600: sw=4 ts=4
- * }}} */
+<?php\r
+/**\r
+*  License Information:\r
+*\r
+*  Net_DNS:  A resolver library for PHP\r
+*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net\r
+*  Maintainers:\r
+*  Marco Kaiser <bate@php.net>\r
+*  Florian Anderiasch <fa@php.net>\r
+*\r
+* PHP versions 4 and 5\r
+*\r
+* LICENSE: This source file is subject to version 3.01 of the PHP license\r
+* that is available through the world-wide-web at the following URI:\r
+* http://www.php.net/license/3_01.txt.  If you did not receive a copy of\r
+* the PHP License and are unable to obtain it through the web, please\r
+* send a note to license@php.net so we can mail you a copy immediately.\r
+*/\r
+\r
+/*  Net_DNS_Header object definition {{{ */\r
+/**\r
+ * Object representation of the HEADER section of a DNS packet\r
+ *\r
+ * The Net_DNS::Header class contains the values of a DNS  packet.  It parses\r
+ * the header of a DNS packet or can  generate the binary data\r
+ * representation of the packet.  The format of the header is described in\r
+ * RFC1035.\r
+ *\r
+ * @package Net_DNS\r
+ */\r
+class Net_DNS_Header\r
+{\r
+    /* class variable definitions {{{ */\r
+    /**\r
+     * The packet's request id\r
+     *\r
+     * The request id of the packet represented as  a 16 bit integer.\r
+     */\r
+    var $id;\r
+    /**\r
+     * The QR bit in a DNS packet header\r
+     *\r
+     * The QR bit as described in RFC1035.  QR is set to 0 for queries, and\r
+     * 1 for repsones.\r
+     */\r
+    var $qr;\r
+    /**\r
+     * The OPCODE name of this packet.\r
+     *\r
+     * The string value (name) of the opcode for the DNS packet.\r
+     */\r
+    var $opcode;\r
+    /**\r
+     * The AA (authoritative answer) bit in a DNS packet header\r
+     *\r
+     * The AA bit as described in RFC1035.  AA is set to  1 if the answer\r
+     * is authoritative.  It has no meaning if QR is set to 0.\r
+     */\r
+    var $aa;\r
+    /**\r
+     * The TC (truncated) bit in a DNS packet header\r
+     *\r
+     * This flag is set to 1 if the response was truncated.  This flag has\r
+     * no meaning in a query packet.\r
+     */\r
+    var $tc;\r
+    /**\r
+     * The RD (recursion desired) bit in a DNS packet header\r
+     *\r
+     * This bit should be set to 1 in a query if recursion  is desired by\r
+     * the DNS server.\r
+     */\r
+    var $rd;\r
+    /**\r
+     * The RA (recursion available) bit in a DNS packet header\r
+     *\r
+     * This bit is set to 1 by the DNS server if the server is willing to\r
+     * perform recursion.\r
+     */\r
+    var $ra;\r
+    /**\r
+     * The RCODE name for this packet.\r
+     *\r
+     * The string value (name) of the rcode for the DNS packet.\r
+     */\r
+    var $rcode;\r
+    /**\r
+     * Number of questions contained within the packet\r
+     *\r
+     * 16bit integer representing the number of questions in the question\r
+     * section of the DNS packet.\r
+     *\r
+     * @var integer $qdcount\r
+     * @see     Net_DNS_Question class\r
+     */\r
+    var $qdcount;\r
+    /**\r
+     * Number of answer RRs contained within the packet\r
+     *\r
+     * 16bit integer representing the number of answer resource records\r
+     * contained in the answer section of the DNS packet.\r
+     *\r
+     * @var integer $ancount\r
+     * @see     Net_DNS_RR class\r
+     */\r
+    var $ancount;\r
+    /**\r
+     * Number of authority RRs within the packet\r
+     *\r
+     * 16bit integer representing the number of authority (NS) resource\r
+     * records  contained in the authority section of the DNS packet.\r
+     *\r
+     * @var integer $nscount\r
+     * @see     Net_DNS_RR class\r
+     */\r
+    var $nscount;\r
+    /**\r
+     * Number of additional RRs within the packet\r
+     *\r
+     * 16bit integer representing the number of additional resource records\r
+     * contained in the additional section of the DNS packet.\r
+     *\r
+     * @var integer $arcount\r
+     * @see     Net_DNS_RR class\r
+     */\r
+    var $arcount;\r
+\r
+    /* }}} */\r
+    /* class constructor - Net_DNS_Header($data = "") {{{ */\r
+    /**\r
+     * Initializes the default values for the Header object.\r
+     *\r
+     * Builds a header object from either default values, or from a DNS\r
+     * packet passed into the constructor as $data\r
+     *\r
+     * @param string $data  A DNS packet of which the header will be parsed.\r
+     * @return  object  Net_DNS_Header\r
+     * @access public\r
+     */\r
+    function Net_DNS_Header($data = '')\r
+    {\r
+        if (empty($data)) {\r
+            $this->id      = Net_DNS_Resolver::nextid();\r
+            $this->qr      = 0;\r
+            $this->opcode  = 0;\r
+            $this->aa      = 0;\r
+            $this->tc      = 0;\r
+            $this->rd      = 1;\r
+            $this->ra      = 0;\r
+            $this->rcode   = 0;\r
+            $this->qdcount = 1;\r
+            $this->ancount = 0;\r
+            $this->nscount = 0;\r
+            $this->arcount = 0;\r
+        } else {\r
+            /*\r
+             * The header MUST be at least 12 bytes.\r
+             * Passing the full datagram to this constructor\r
+             * will examine only the header section of the DNS packet\r
+             */\r
+            if (strlen($data) < 12) {\r
+                return false;\r
+            }\r
+\r
+            $a = unpack('nid/C2flags/n4counts', $data);\r
+            $this->id      = $a['id'];\r
+            $this->qr      = ($a['flags1'] >> 7) & 0x1;\r
+            $this->opcode  = ($a['flags1'] >> 3) & 0xf;\r
+            $this->aa      = ($a['flags1'] >> 2) & 0x1;\r
+            $this->tc      = ($a['flags1'] >> 1) & 0x1;\r
+            $this->rd      = $a['flags1'] & 0x1;\r
+            $this->ra      = ($a['flags2'] >> 7) & 0x1;\r
+            $this->rcode   = $a['flags2'] & 0xf;\r
+            $this->qdcount = $a['counts1'];\r
+            $this->ancount = $a['counts2'];\r
+            $this->nscount = $a['counts3'];\r
+            $this->arcount = $a['counts4'];\r
+        }\r
+\r
+\r
+        $dns = new Net_DNS();\r
+        if ($dns->opcodesbyval($this->opcode)) {\r
+            $this->opcode = $dns->opcodesbyval($this->opcode);\r
+        }\r
+        if ($dns->rcodesbyval($this->rcode)) {\r
+            $this->rcode = $dns->rcodesbyval($this->rcode);\r
+        }\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_Header::display() {{{ */\r
+    /**\r
+     * Displays the properties of the header.\r
+     *\r
+     * Displays the properties of the header.\r
+     *\r
+     * @access public\r
+     */\r
+    function display()\r
+    {\r
+        echo $this->string();\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_Header::string() {{{ */\r
+    /**\r
+     * Returns a formatted string containing the properties of the header.\r
+     *\r
+     * @return string   a formatted string containing the properties of the header.\r
+     * @access public\r
+     */\r
+    function string()\r
+    {\r
+        $retval = ';; id = ' . $this->id . "\n";\r
+        if ($this->opcode == 'UPDATE') {\r
+            $retval .= ';; qr = ' . $this->qr . '    ' .\r
+                'opcode = ' . $this->opcode . '    '   .\r
+                'rcode = ' . $this->rcode . "\n";\r
+            $retval .= ';; zocount = ' . $this->qdcount . '  ' .\r
+                'prcount = ' . $this->ancount . '  '           .\r
+                'upcount = ' . $this->nscount . '  '           .\r
+                'adcount = ' . $this->arcount . "\n";\r
+        } else {\r
+            $retval .= ';; qr = ' . $this->qr . '    ' .\r
+                'opcode = ' . $this->opcode . '    '   .\r
+                'aa = ' . $this->aa . '    '           .\r
+                'tc = ' . $this->tc . '    '           .\r
+                'rd = ' . $this->rd . "\n";\r
+\r
+            $retval .= ';; ra = ' . $this->ra . '    ' .\r
+                'rcode  = ' . $this->rcode . "\n";\r
+\r
+            $retval .= ';; qdcount = ' . $this->qdcount . '  ' .\r
+                'ancount = ' . $this->ancount . '  '    .\r
+                'nscount = ' . $this->nscount . '  '    .\r
+                'arcount = ' . $this->arcount . "\n";\r
+        }\r
+        return $retval;\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_Header::data() {{{ */\r
+    /**\r
+     * Returns the binary data containing the properties of the header\r
+     *\r
+     * Packs the properties of the Header object into a binary string\r
+     * suitable for using as the Header section of a DNS packet.\r
+     *\r
+     * @return string   binary representation of the header object\r
+     * @access public\r
+     */\r
+    function data()\r
+    {\r
+        $dns = new Net_DNS();\r
+        $opcode = $dns->opcodesbyname($this->opcode);\r
+        $rcode  = $dns->rcodesbyname($this->rcode);\r
+\r
+        $byte2 = ($this->qr << 7)\r
+            | ($opcode << 3)\r
+            | ($this->aa << 2)\r
+            | ($this->tc << 1)\r
+            | ($this->rd);\r
+\r
+        $byte3 = ($this->ra << 7) | $rcode;\r
+\r
+        return pack('nC2n4', $this->id,\r
+                $byte2,\r
+                $byte3,\r
+                $this->qdcount,\r
+                $this->ancount,\r
+                $this->nscount,\r
+                $this->arcount);\r
+    }\r
+\r
+    /* }}} */\r
+}\r
+/* }}} */\r
+/* VIM settings {{{\r
+ * Local variables:\r
+ * tab-width: 4\r
+ * c-basic-offset: 4\r
+ * soft-stop-width: 4\r
+ * c indent on\r
+ * expandtab on\r
+ * End:\r
+ * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et\r
+ * vim<600: sw=4 ts=4\r
+ * }}} */\r
 ?>
\ No newline at end of file
index dabca15..8dde529 100755 (executable)
-<?php
-/**
-*  License Information:
-*
-*  Net_DNS:  A resolver library for PHP
-*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
-*  Maintainers:
-*  Marco Kaiser <bate@php.net>
-*  Florian Anderiasch <fa@php.net>
-*
-* PHP versions 4 and 5
-*
-* LICENSE: This source file is subject to version 3.01 of the PHP license
-* that is available through the world-wide-web at the following URI:
-* http://www.php.net/license/3_01.txt.  If you did not receive a copy of
-* the PHP License and are unable to obtain it through the web, please
-* send a note to license@php.net so we can mail you a copy immediately.
-*/
-
-/* Net_DNS_Packet object definition {{{ */
-/**
- * A object represation of a DNS packet (RFC1035)
- *
- * This object is used to manage a DNS packet.  It contains methods for
- * DNS packet compression as defined in RFC1035, as well as parsing  a DNS
- * packet response from a DNS server, or building a DNS packet from  the
- * instance variables contained in the class.
- *
- * @package Net_DNS
- */
-class Net_DNS_Packet
-{
-    /* class variable definitions {{{ */
-    /**
-     * debugging flag
-     *
-     * If set to true (non-zero), debugging code will be displayed as the
-     * packet is parsed.
-     *
-     * @var boolean $debug
-     * @access  public
-     */
-    var $debug;
-    /**
-     * A packet Header object.
-     *
-     * An object of type Net_DNS_Header which contains the header
-     * information  of the packet.
-     *
-     * @var object Net_DNS_Header $header
-     * @access  public
-     */
-    var $header;
-    /**
-     * A hash of compressed labels
-     *
-     * A list of all labels which have been compressed in the DNS packet
-     * and  the location offset of the label within the packet.
-     *
-     * @var array   $compnames
-     */
-    var $compnames;
-    /**
-     * The origin of the packet, if the packet is a server response.
-     *
-     * This contains a string containing the IP address of the name server
-     * from which the answer was given.
-     *
-     * @var string  $answerfrom
-     * @access  public
-     */
-    var $answerfrom;
-    /**
-     * The size of the answer packet, if the packet is a server response.
-     *
-     * This contains a integer containing the size of the DNS packet the
-     * server responded with if this packet was received by a DNS server
-     * using the query() method.
-     *
-     * @var string  $answersize
-     * @access  public
-     */
-    var $answersize;
-    /**
-     * An array of Net_DNS_Question objects
-     *
-     * Contains all of the questions within the packet.  Each question is
-     * stored as an object of type Net_DNS_Question.
-     *
-     * @var array   $question
-     * @access  public
-     */
-    var $question;
-    /**
-     * An array of Net_DNS_RR ANSWER objects
-     *
-     * Contains all of the answer RRs within the packet.  Each answer is
-     * stored as an object of type Net_DNS_RR.
-     *
-     * @var array   $answer
-     * @access  public
-     */
-    var $answer;
-    /**
-     * An array of Net_DNS_RR AUTHORITY objects
-     *
-     * Contains all of the authority RRs within the packet.  Each authority is
-     * stored as an object of type Net_DNS_RR.
-     *
-     * @var array   $authority
-     * @access  public
-     */
-    var $authority;
-    /**
-     * An array of Net_DNS_RR ADDITIONAL objects
-     *
-     * Contains all of the additional RRs within the packet.  Each additional is
-     * stored as an object of type Net_DNS_RR.
-     *
-     * @var array   $additional
-     * @access  public
-     */
-    var $additional;
-
-    const INT32SZ = 4;
-    const INT16SZ = 2;
-       
-    /* }}} */
-    /* class constructor - Net_DNS_Packet($debug = false) {{{ */
-    /*
-     * unfortunately (or fortunately), we can't follow the same
-     * silly method for determining if name is a hostname or a packet
-     * stream in PHP, since there is no ref() function.  So we're going
-     * to define a new method called parse to deal with this
-     * circumstance and another method called buildQuestion to build a question.
-     * I like it better that way anyway.
-     */
-    /**
-     * Initalizes a Net_DNS_Packet object
-     *
-     * @param boolean $debug Turns debugging on or off
-     */
-    function Net_DNS_Packet($debug = false)
-    {
-        $this->debug = $debug;
-        $this->compnames = array();
-    }
-
-    /* }}} */
-    /* Net_DNS_Packet::buildQuestion($name, $type = "A", $class = "IN") {{{ */
-    /**
-     * Adds a DNS question to the DNS packet
-     *
-     * @param   string $name    The name of the record to query
-     * @param   string $type    The type of record to query
-     * @param   string $class   The class of record to query
-     * @see Net_DNS::typesbyname(), Net_DNS::classesbyname()
-     */
-    function buildQuestion($name, $type = 'A', $class = 'IN')
-    {
-        $this->header = new Net_DNS_Header();
-        $this->header->qdcount = 1;
-        $this->question[0] = new Net_DNS_Question($name, $type, $class);
-        $this->answer = null;
-        $this->authority = null;
-        $this->additional = null;
-        /* Do not print question packet
-        if ($this->debug) {
-            $this->display();
-        }
-        */
-    }
-
-    /* }}} */
-    /* Net_DNS_Packet::parse($data) {{{ */
-    /**
-     * Parses a DNS packet returned by a DNS server
-     *
-     * Parses a complete DNS packet and builds an object hierarchy
-     * containing all of the parts of the packet:
-     * <ul>
-     *   <li>HEADER
-     *   <li>QUESTION
-     *   <li>ANSWER || PREREQUISITE
-     *   <li>ADDITIONAL || UPDATE
-     *   <li>AUTHORITY
-     * </ul>
-     *
-     * @param string $data  A binary string containing a DNS packet
-     * @return boolean true on success, null on parser error
-     */
-    function parse($data)
-    {
-        if ($this->debug) {
-            echo ';; HEADER SECTION' . "\n";
-        }
-
-        $this->header = new Net_DNS_Header($data);
-        $header = $this->header;
-
-        if ($this->debug) {
-            $header->display();
-        }
-
-        /*
-         *  Print and parse the QUESTION section of the packet
-         */
-        if ($this->debug) {
-            echo "\n";
-            $section = ($header->opcode  == 'UPDATE') ? 'ZONE' : 'QUESTION';
-            echo ";; $section SECTION (" . $header->qdcount . ' record' .
-                ($header->qdcount == 1 ? '' : 's') . ")\n";
-        }
-
-        $offset = 12;
-
-        $this->question = array();
-        for ($ctr = 0; $ctr < $header->qdcount; $ctr++) {
-            list($qobj, $offset) = $this->parse_question($data, $offset);
-            if (is_null($qobj)) {
-                return null;
-            }
-
-            $this->question[count($this->question)] = $qobj;
-            if ($this->debug) {
-                echo ";;\n;";
-                $qobj->display();
-            }
-        }
-
-        /*
-         *  Print and parse the PREREQUISITE or ANSWER  section of the packet
-         */
-        if ($this->debug) {
-            echo "\n";
-            $section = ($header->opcode == 'UPDATE') ? 'PREREQUISITE' :'ANSWER';
-            echo ";; $section SECTION (" .
-                $header->ancount . ' record' .
-                (($header->ancount == 1) ? '' : 's') .
-                ")\n";
-        }
-
-        $this->answer = array();
-        for ($ctr = 0; $ctr < $header->ancount; $ctr++) {
-            list($rrobj, $offset) = $this->parse_rr($data, $offset);
-
-            if (is_null($rrobj)) {
-                return null;
-            }
-            array_push($this->answer, $rrobj);
-            if ($this->debug) {
-                $rrobj->display();
-            }
-        }
-
-        /*
-         *  Print and parse the UPDATE or AUTHORITY section of the packet
-         */
-        if ($this->debug) {
-            echo "\n";
-            $section = ($header->opcode == 'UPDATE') ? 'UPDATE' : 'AUTHORITY';
-            echo ";; $section SECTION (" .
-                $header->nscount . ' record' .
-                (($header->nscount == 1) ? '' : 's') .
-                ")\n";
-        }
-
-        $this->authority = array();
-        for ($ctr = 0; $ctr < $header->nscount; $ctr++) {
-            list($rrobj, $offset) = $this->parse_rr($data, $offset);
-
-            if (is_null($rrobj)) {
-                $this->header = $header;
-                return null;
-            }
-            array_push($this->authority, $rrobj);
-            if ($this->debug) {
-                $rrobj->display();
-            }
-        }
-
-        /*
-         *  Print and parse the ADDITIONAL section of the packet
-         */
-        if ($this->debug) {
-            echo "\n";
-            echo ';; ADDITIONAL SECTION (' .
-                $header->arcount . ' record' .
-                (($header->arcount == 1) ? '' : 's') .
-                ")\n";
-        }
-
-        $this->additional = array();
-        for ($ctr = 0; $ctr < $header->arcount; $ctr++) {
-            list($rrobj, $offset) = $this->parse_rr($data, $offset);
-
-            if (is_null($rrobj)) {
-                $this->header = $header;
-                return null;
-            }
-            array_push($this->additional, $rrobj);
-            if ($this->debug) {
-                $rrobj->display();
-            }
-        }
-
-        $this->header = $header;
-        return true;
-    }
-
-    /* }}} */
-    /* Net_DNS_Packet::data() {{{*/
-    /**
-     * Build a packet from a Packet object hierarchy
-     *
-     * Builds a valid DNS packet suitable for sending to a DNS server or
-     * resolver client containing all of the data in the packet hierarchy.
-     *
-     * @return string A binary string containing a DNS Packet
-     */
-    function data()
-    {
-        $data = $this->header->data();
-
-        $qdcount = $this->header->qdcount;
-        $ancount = $this->header->ancount;
-        $nscount = $this->header->nscount;
-        $arcount = $this->header->arcount;
-        for ($ctr = 0; $ctr < $qdcount; $ctr++) {
-            $data .= $this->question[$ctr]->data($this, strlen($data));
-        }
-
-        for ($ctr = 0; $ctr < $ancount; $ctr++) {
-            $data .= $this->answer[$ctr]->data($this, strlen($data));
-        }
-
-        for ($ctr = 0; $ctr < $nscount; $ctr++) {
-            $data .= $this->authority[$ctr]->data($this, strlen($data));
-        }
-
-        for ($ctr = 0; $ctr < $arcount; $ctr++) {
-            $data .= $this->additional[$ctr]->data($this, strlen($data));
-        }
-
-        return $data;
-    }
-
-    /*}}}*/
-    /* Net_DNS_Packet::dn_comp($name, $offset) {{{*/
-    /**
-     * DNS packet compression method
-     *
-     * Returns a domain name compressed for a particular packet object, to
-     * be stored beginning at the given offset within the packet data.  The
-     * name will be added to a running list of compressed domain names for
-     * future use.
-     *
-     * @param string    $name       The name of the label to compress
-     * @param integer   $offset     The location offset in the packet to where
-     *                              the label will be stored.
-     * @return string   $compname   A binary string containing the compressed
-     *                              label.
-     * @see Net_DNS_Packet::dn_expand()
-     */
-    function dn_comp($name, $offset)
-    {
-        $names = explode('.', $name);
-        $compname = '';
-        while (count($names)) {
-            $dname = join('.', $names);
-            if (isset($this->compnames[$dname])) {
-                $compname .= pack('n', 0xc000 | $this->compnames[$dname]);
-                break;
-            }
-
-            $this->compnames[$dname] = $offset;
-            $first = array_shift($names);
-            $length = strlen($first);
-            $compname .= pack('Ca*', $length, $first);
-            $offset += $length + 1;
-        }
-        if (!count($names)) {
-            $compname .= pack('C', 0);
-        }
-        return $compname;
-    }
-
-    /*}}}*/
-    /* Net_DNS_Packet::dn_expand($packet, $offset) {{{ */
-    /**
-     * DNS packet decompression method
-     *
-     * Expands the domain name stored at a particular location in a DNS
-     * packet.  The first argument is a variable containing  the packet
-     * data.  The second argument is the offset within the  packet where
-     * the (possibly) compressed domain name is stored.
-     *
-     * @param   string  $packet The packet data
-     * @param   integer $offset The location offset in the packet of the
-     *                          label to decompress.
-     * @return  array   Returns a list of type array($name, $offset) where
-     *                  $name is the name of the label which was decompressed
-     *                  and $offset is the offset of the next field in the
-     *                  packet.  Returns array(null, null) on error
-     */
-    function dn_expand($packet, $offset)
-    {
-        $packetlen = strlen($packet);
-        $name = '';
-        while (1) {
-            if ($packetlen < ($offset + 1)) {
-                return array(null, null);
-            }
-
-            $a = unpack("@$offset/Cchar", $packet);
-            $len = (int)$a['char'];
-
-            if ($len == 0) {
-                $offset++;
-                break;
-            } else if (($len & 0xc0) == 0xc0) {
-                if ($packetlen < ($offset + Net_DNS_Packet::INT16SZ)) {
-                    return array(null, null);
-                }
-                $ptr = unpack("@$offset/ni", $packet);
-                $ptr = $ptr['i'];
-                $ptr = $ptr & 0x3fff;
-                $name2 = Net_DNS_Packet::dn_expand($packet, $ptr);
-
-                if (is_null($name2[0])) {
-                    return array(null, null);
-                }
-                $name .= $name2[0];
-                $offset += Net_DNS_Packet::INT16SZ;
-                break;
-            } else {
-                $offset++;
-
-                if ($packetlen < ($offset + $len)) {
-                    return array(null, null);
-                }
-
-                $elem = substr($packet, $offset, $len);
-                $name .= $elem . '.';
-                $offset += $len;
-            }
-        }
-        $name = preg_replace('/\.$/', '', $name);
-        return array($name, $offset);
-    }
-
-    /*}}}*/
-    /* Net_DNS_Packet::label_extract($packet, $offset) {{{ */
-    /**
-     * DNS packet decompression method
-     *
-     * Extracts the label stored at a particular location in a DNS
-     * packet.  The first argument is a variable containing  the packet
-     * data.  The second argument is the offset within the  packet where
-     * the (possibly) compressed domain name is stored.
-     *
-     * @param   string  $packet The packet data
-     * @param   integer $offset The location offset in the packet of the
-     *                          label to extract.
-     * @return  array   Returns a list of type array($name, $offset) where
-     *                  $name is the name of the label which was decompressed
-     *                  and $offset is the offset of the next field in the
-     *                  packet.  Returns array(null, null) on error
-     */
-    function label_extract($packet, $offset)
-    {
-        $packetlen = strlen($packet);
-        $name = '';
-        if ($packetlen < ($offset + 1)) {
-            return array(null, null);
-        }
-
-        $a = unpack("@$offset/Cchar", $packet);
-        $len = $a['char'];
-        $offset++;
-
-        if ($len + $offset > $packetlen) {
-            $name = substr($packet, $offset);
-            $offset = $packetlen;
-        } else {
-            $name = substr($packet, $offset, $len);
-            $offset += $len;
-        }
-        return array($name, $offset);
-    }
-
-    /*}}}*/
-    /* Net_DNS_Packet::parse_question($data, $offset) {{{ */
-    /**
-     * Parses the question section of a packet
-     *
-     * Examines a DNS packet at the specified offset and parses the data
-     * of the QUESTION section.
-     *
-     * @param   string  $data   The packet data returned from the server
-     * @param   integer $offset The location offset of the start of the
-     *                          question section.
-     * @return  array   An array of type array($q, $offset) where $q
-     *                  is a Net_DNS_Question object and $offset is the
-     *                  location of the next section of the packet which
-     *                  needs to be parsed.
-     */
-    function parse_question($data, $offset)
-    {
-        list($qname, $offset) = $this->dn_expand($data, $offset);
-        if (is_null($qname)) {
-            return array(null, null);
-        }
-
-        if (strlen($data) < ($offset + 4)) {
-            return array(null, null);
-        }
-
-        $q = unpack("@$offset/n2int", $data);
-        $qtype = $q['int1'];
-        $qclass = $q['int2'];
-        $offset += 4;
-
-        $qtype = Net_DNS::typesbyval($qtype);
-        $qclass = Net_DNS::classesbyval($qclass);
-
-        $q = new Net_DNS_Question($qname, $qtype, $qclass);
-        return array($q, $offset);
-    }
-
-    /*}}}*/
-    /* Net_DNS_Packet::parse_rr($data, $offset) {{{ */
-    /**
-     * Parses a resource record section of a packet
-     *
-     * Examines a DNS packet at the specified offset and parses the data
-     * of a section which contains RRs (ANSWER, AUTHORITY, ADDITIONAL).
-     *
-     * @param string    $data   The packet data returned from the server
-     * @param integer   $offset The location offset of the start of the resource
-     *                          record section.
-     * @return  array   An array of type array($rr, $offset) where $rr
-     *                  is a Net_DNS_RR object and $offset is the
-     *                  location of the next section of the packet which
-     *                  needs to be parsed.
-     */
-    function parse_rr($data, $offset)
-    {
-        list($name, $offset) = $this->dn_expand($data, $offset);
-        if ($name === null) {
-            return array(null, null);
-        }
-
-        if (strlen($data) < ($offset + 10)) {
-            return array(null, null);
-        }
-
-        $a = unpack("@$offset/n2tc/Nttl/nrdlength", $data);
-        $type = $a['tc1'];
-        $class = $a['tc2'];
-        $ttl = $a['ttl'];
-        $rdlength = $a['rdlength'];
-
-        $type = Net_DNS::typesbyval($type);
-        $class = Net_DNS::classesbyval($class);
-
-        $offset += 10;
-        if (strlen($data) < ($offset + $rdlength)) {
-            return array(null, null);
-        }
-
-        $rrobj = &Net_DNS_RR::factory(array($name,
-                    $type,
-                    $class,
-                    $ttl,
-                    $rdlength,
-                    $data,
-                    $offset));
-
-        if (is_null($rrobj)) {
-            return array(null, null);
-        }
-
-        $offset += $rdlength;
-
-        return array($rrobj, $offset);
-    }
-
-    /* }}} */
-    /* Net_DNS_Packet::display() {{{ */
-    /**
-     * Prints out the packet in a human readable formatted string
-     */
-    function display()
-    {
-        echo $this->string();
-    }
-
-    /*}}}*/
-    /* Net_DNS_Packet::string() {{{ */
-    /**
-     * Builds a human readable formatted string representing a packet
-     */
-    function string()
-    {
-        $retval = '';
-        if ($this->answerfrom) {
-            $retval .= ';; Answer received from ' . $this->answerfrom . '(' .
-                $this->answersize . " bytes)\n;;\n";
-        }
-
-        $retval .= ";; HEADER SECTION\n";
-        $retval .= $this->header->string();
-        $retval .= "\n";
-
-        $section = ($this->header->opcode == 'UPDATE') ? 'ZONE' : 'QUESTION';
-        $retval .= ";; $section SECTION (" . $this->header->qdcount     .
-            ' record' . ($this->header->qdcount == 1 ? '' : 's') .
-            ")\n";
-
-        foreach ($this->question as $qr) {
-            $retval .= ';; ' . $qr->string() . "\n";
-        }
-
-        $section = ($this->header->opcode == 'UPDATE') ? 'PREREQUISITE' : 'ANSWER';
-        $retval .= "\n;; $section SECTION (" . $this->header->ancount     .
-            ' record' . ($this->header->ancount == 1 ? '' : 's') .
-            ")\n";
-
-        if (is_array($this->answer)) {
-            foreach ($this->answer as $ans) {
-                $retval .= ';; ' . $ans->string() . "\n";
-            }
-        }
-
-        $section = ($this->header->opcode == 'UPDATE') ? 'UPDATE' : 'AUTHORITY';
-        $retval .= "\n;; $section SECTION (" . $this->header->nscount     .
-            ' record' . ($this->header->nscount == 1 ? '' : 's') .
-            ")\n";
-
-        if (is_array($this->authority)) {
-            foreach ($this->authority as $auth) {
-                $retval .= ';; ' . $auth->string() . "\n";
-            }
-        }
-
-        $retval .= "\n;; ADDITIONAL SECTION (" . $this->header->arcount     .
-            ' record' . ($this->header->arcount == 1 ? '' : 's') .
-            ")\n";
-
-        if (is_array($this->additional)) {
-            foreach ($this->additional as $addl) {
-                $retval .= ';; ' . $addl->string() . "\n";
-            }
-        }
-
-        $retval .= "\n\n";
-        return $retval;
-    }
-
-    /*}}}*/
-}
-/* }}} */
-/* VIM settings {{{
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * soft-stop-width: 4
- * c indent on
- * End:
- * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et
- * vim<600: sw=4 ts=4
- * }}} */
-?>
+<?php\r
+/**\r
+*  License Information:\r
+*\r
+*  Net_DNS:  A resolver library for PHP\r
+*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net\r
+*  Maintainers:\r
+*  Marco Kaiser <bate@php.net>\r
+*  Florian Anderiasch <fa@php.net>\r
+*\r
+* PHP versions 4 and 5\r
+*\r
+* LICENSE: This source file is subject to version 3.01 of the PHP license\r
+* that is available through the world-wide-web at the following URI:\r
+* http://www.php.net/license/3_01.txt.  If you did not receive a copy of\r
+* the PHP License and are unable to obtain it through the web, please\r
+* send a note to license@php.net so we can mail you a copy immediately.\r
+*/\r
+\r
+/* Net_DNS_Packet object definition {{{ */\r
+/**\r
+ * A object represation of a DNS packet (RFC1035)\r
+ *\r
+ * This object is used to manage a DNS packet.  It contains methods for\r
+ * DNS packet compression as defined in RFC1035, as well as parsing  a DNS\r
+ * packet response from a DNS server, or building a DNS packet from  the\r
+ * instance variables contained in the class.\r
+ *\r
+ * @package Net_DNS\r
+ */\r
+class Net_DNS_Packet\r
+{\r
+    /* class variable definitions {{{ */\r
+    /**\r
+     * debugging flag\r
+     *\r
+     * If set to true (non-zero), debugging code will be displayed as the\r
+     * packet is parsed.\r
+     *\r
+     * @var boolean $debug\r
+     * @access  public\r
+     */\r
+    var $debug;\r
+    /**\r
+     * A packet Header object.\r
+     *\r
+     * An object of type Net_DNS_Header which contains the header\r
+     * information  of the packet.\r
+     *\r
+     * @var object Net_DNS_Header $header\r
+     * @access  public\r
+     */\r
+    var $header;\r
+    /**\r
+     * A hash of compressed labels\r
+     *\r
+     * A list of all labels which have been compressed in the DNS packet\r
+     * and  the location offset of the label within the packet.\r
+     *\r
+     * @var array   $compnames\r
+     */\r
+    var $compnames;\r
+    /**\r
+     * The origin of the packet, if the packet is a server response.\r
+     *\r
+     * This contains a string containing the IP address of the name server\r
+     * from which the answer was given.\r
+     *\r
+     * @var string  $answerfrom\r
+     * @access  public\r
+     */\r
+    var $answerfrom;\r
+    /**\r
+     * The size of the answer packet, if the packet is a server response.\r
+     *\r
+     * This contains a integer containing the size of the DNS packet the\r
+     * server responded with if this packet was received by a DNS server\r
+     * using the query() method.\r
+     *\r
+     * @var string  $answersize\r
+     * @access  public\r
+     */\r
+    var $answersize;\r
+    /**\r
+     * An array of Net_DNS_Question objects\r
+     *\r
+     * Contains all of the questions within the packet.  Each question is\r
+     * stored as an object of type Net_DNS_Question.\r
+     *\r
+     * @var array   $question\r
+     * @access  public\r
+     */\r
+    var $question;\r
+    /**\r
+     * An array of Net_DNS_RR ANSWER objects\r
+     *\r
+     * Contains all of the answer RRs within the packet.  Each answer is\r
+     * stored as an object of type Net_DNS_RR.\r
+     *\r
+     * @var array   $answer\r
+     * @access  public\r
+     */\r
+    var $answer;\r
+    /**\r
+     * An array of Net_DNS_RR AUTHORITY objects\r
+     *\r
+     * Contains all of the authority RRs within the packet.  Each authority is\r
+     * stored as an object of type Net_DNS_RR.\r
+     *\r
+     * @var array   $authority\r
+     * @access  public\r
+     */\r
+    var $authority;\r
+    /**\r
+     * An array of Net_DNS_RR ADDITIONAL objects\r
+     *\r
+     * Contains all of the additional RRs within the packet.  Each additional is\r
+     * stored as an object of type Net_DNS_RR.\r
+     *\r
+     * @var array   $additional\r
+     * @access  public\r
+     */\r
+    var $additional;\r
+\r
+    const INT32SZ = 4;\r
+    const INT16SZ = 2;\r
+       \r
+    /* }}} */\r
+    /* class constructor - Net_DNS_Packet($debug = false) {{{ */\r
+    /*\r
+     * unfortunately (or fortunately), we can't follow the same\r
+     * silly method for determining if name is a hostname or a packet\r
+     * stream in PHP, since there is no ref() function.  So we're going\r
+     * to define a new method called parse to deal with this\r
+     * circumstance and another method called buildQuestion to build a question.\r
+     * I like it better that way anyway.\r
+     */\r
+    /**\r
+     * Initalizes a Net_DNS_Packet object\r
+     *\r
+     * @param boolean $debug Turns debugging on or off\r
+     */\r
+    function Net_DNS_Packet($debug = false)\r
+    {\r
+        $this->debug = $debug;\r
+        $this->compnames = array();\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_Packet::buildQuestion($name, $type = "A", $class = "IN") {{{ */\r
+    /**\r
+     * Adds a DNS question to the DNS packet\r
+     *\r
+     * @param   string $name    The name of the record to query\r
+     * @param   string $type    The type of record to query\r
+     * @param   string $class   The class of record to query\r
+     * @see Net_DNS::typesbyname(), Net_DNS::classesbyname()\r
+     */\r
+    function buildQuestion($name, $type = 'A', $class = 'IN')\r
+    {\r
+        $this->header = new Net_DNS_Header();\r
+        $this->header->qdcount = 1;\r
+        $this->question[0] = new Net_DNS_Question($name, $type, $class);\r
+        $this->answer = null;\r
+        $this->authority = null;\r
+        $this->additional = null;\r
+        /* Do not print question packet\r
+        if ($this->debug) {\r
+            $this->display();\r
+        }\r
+        */\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_Packet::parse($data) {{{ */\r
+    /**\r
+     * Parses a DNS packet returned by a DNS server\r
+     *\r
+     * Parses a complete DNS packet and builds an object hierarchy\r
+     * containing all of the parts of the packet:\r
+     * <ul>\r
+     *   <li>HEADER\r
+     *   <li>QUESTION\r
+     *   <li>ANSWER || PREREQUISITE\r
+     *   <li>ADDITIONAL || UPDATE\r
+     *   <li>AUTHORITY\r
+     * </ul>\r
+     *\r
+     * @param string $data  A binary string containing a DNS packet\r
+     * @return boolean true on success, null on parser error\r
+     */\r
+    function parse($data)\r
+    {\r
+        if ($this->debug) {\r
+            echo ';; HEADER SECTION' . "\n";\r
+        }\r
+\r
+        $this->header = new Net_DNS_Header($data);\r
+        $header = $this->header;\r
+\r
+        if ($this->debug) {\r
+            $header->display();\r
+        }\r
+\r
+        /*\r
+         *  Print and parse the QUESTION section of the packet\r
+         */\r
+        if ($this->debug) {\r
+            echo "\n";\r
+            $section = ($header->opcode  == 'UPDATE') ? 'ZONE' : 'QUESTION';\r
+            echo ";; $section SECTION (" . $header->qdcount . ' record' .\r
+                ($header->qdcount == 1 ? '' : 's') . ")\n";\r
+        }\r
+\r
+        $offset = 12;\r
+\r
+        $this->question = array();\r
+        for ($ctr = 0; $ctr < $header->qdcount; $ctr++) {\r
+            list($qobj, $offset) = $this->parse_question($data, $offset);\r
+            if (is_null($qobj)) {\r
+                return null;\r
+            }\r
+\r
+            $this->question[count($this->question)] = $qobj;\r
+            if ($this->debug) {\r
+                echo ";;\n;";\r
+                $qobj->display();\r
+            }\r
+        }\r
+\r
+        /*\r
+         *  Print and parse the PREREQUISITE or ANSWER  section of the packet\r
+         */\r
+        if ($this->debug) {\r
+            echo "\n";\r
+            $section = ($header->opcode == 'UPDATE') ? 'PREREQUISITE' :'ANSWER';\r
+            echo ";; $section SECTION (" .\r
+                $header->ancount . ' record' .\r
+                (($header->ancount == 1) ? '' : 's') .\r
+                ")\n";\r
+        }\r
+\r
+        $this->answer = array();\r
+        for ($ctr = 0; $ctr < $header->ancount; $ctr++) {\r
+            list($rrobj, $offset) = $this->parse_rr($data, $offset);\r
+\r
+            if (is_null($rrobj)) {\r
+                return null;\r
+            }\r
+            array_push($this->answer, $rrobj);\r
+            if ($this->debug) {\r
+                $rrobj->display();\r
+            }\r
+        }\r
+\r
+        /*\r
+         *  Print and parse the UPDATE or AUTHORITY section of the packet\r
+         */\r
+        if ($this->debug) {\r
+            echo "\n";\r
+            $section = ($header->opcode == 'UPDATE') ? 'UPDATE' : 'AUTHORITY';\r
+            echo ";; $section SECTION (" .\r
+                $header->nscount . ' record' .\r
+                (($header->nscount == 1) ? '' : 's') .\r
+                ")\n";\r
+        }\r
+\r
+        $this->authority = array();\r
+        for ($ctr = 0; $ctr < $header->nscount; $ctr++) {\r
+            list($rrobj, $offset) = $this->parse_rr($data, $offset);\r
+\r
+            if (is_null($rrobj)) {\r
+                $this->header = $header;\r
+                return null;\r
+            }\r
+            array_push($this->authority, $rrobj);\r
+            if ($this->debug) {\r
+                $rrobj->display();\r
+            }\r
+        }\r
+\r
+        /*\r
+         *  Print and parse the ADDITIONAL section of the packet\r
+         */\r
+        if ($this->debug) {\r
+            echo "\n";\r
+            echo ';; ADDITIONAL SECTION (' .\r
+                $header->arcount . ' record' .\r
+                (($header->arcount == 1) ? '' : 's') .\r
+                ")\n";\r
+        }\r
+\r
+        $this->additional = array();\r
+        for ($ctr = 0; $ctr < $header->arcount; $ctr++) {\r
+            list($rrobj, $offset) = $this->parse_rr($data, $offset);\r
+\r
+            if (is_null($rrobj)) {\r
+                $this->header = $header;\r
+                return null;\r
+            }\r
+            array_push($this->additional, $rrobj);\r
+            if ($this->debug) {\r
+                $rrobj->display();\r
+            }\r
+        }\r
+\r
+        $this->header = $header;\r
+        return true;\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_Packet::data() {{{*/\r
+    /**\r
+     * Build a packet from a Packet object hierarchy\r
+     *\r
+     * Builds a valid DNS packet suitable for sending to a DNS server or\r
+     * resolver client containing all of the data in the packet hierarchy.\r
+     *\r
+     * @return string A binary string containing a DNS Packet\r
+     */\r
+    function data()\r
+    {\r
+        $data = $this->header->data();\r
+\r
+        $qdcount = $this->header->qdcount;\r
+        $ancount = $this->header->ancount;\r
+        $nscount = $this->header->nscount;\r
+        $arcount = $this->header->arcount;\r
+        for ($ctr = 0; $ctr < $qdcount; $ctr++) {\r
+            $data .= $this->question[$ctr]->data($this, strlen($data));\r
+        }\r
+\r
+        for ($ctr = 0; $ctr < $ancount; $ctr++) {\r
+            $data .= $this->answer[$ctr]->data($this, strlen($data));\r
+        }\r
+\r
+        for ($ctr = 0; $ctr < $nscount; $ctr++) {\r
+            $data .= $this->authority[$ctr]->data($this, strlen($data));\r
+        }\r
+\r
+        for ($ctr = 0; $ctr < $arcount; $ctr++) {\r
+            $data .= $this->additional[$ctr]->data($this, strlen($data));\r
+        }\r
+\r
+        return $data;\r
+    }\r
+\r
+    /*}}}*/\r
+    /* Net_DNS_Packet::dn_comp($name, $offset) {{{*/\r
+    /**\r
+     * DNS packet compression method\r
+     *\r
+     * Returns a domain name compressed for a particular packet object, to\r
+     * be stored beginning at the given offset within the packet data.  The\r
+     * name will be added to a running list of compressed domain names for\r
+     * future use.\r
+     *\r
+     * @param string    $name       The name of the label to compress\r
+     * @param integer   $offset     The location offset in the packet to where\r
+     *                              the label will be stored.\r
+     * @return string   $compname   A binary string containing the compressed\r
+     *                              label.\r
+     * @see Net_DNS_Packet::dn_expand()\r
+     */\r
+    function dn_comp($name, $offset)\r
+    {\r
+        $names = explode('.', $name);\r
+        $compname = '';\r
+        while (count($names)) {\r
+            $dname = join('.', $names);\r
+            if (isset($this->compnames[$dname])) {\r
+                $compname .= pack('n', 0xc000 | $this->compnames[$dname]);\r
+                break;\r
+            }\r
+\r
+            $this->compnames[$dname] = $offset;\r
+            $first = array_shift($names);\r
+            $length = strlen($first);\r
+            $compname .= pack('Ca*', $length, $first);\r
+            $offset += $length + 1;\r
+        }\r
+        if (!count($names)) {\r
+            $compname .= pack('C', 0);\r
+        }\r
+        return $compname;\r
+    }\r
+\r
+    /*}}}*/\r
+    /* Net_DNS_Packet::dn_expand($packet, $offset) {{{ */\r
+    /**\r
+     * DNS packet decompression method\r
+     *\r
+     * Expands the domain name stored at a particular location in a DNS\r
+     * packet.  The first argument is a variable containing  the packet\r
+     * data.  The second argument is the offset within the  packet where\r
+     * the (possibly) compressed domain name is stored.\r
+     *\r
+     * @param   string  $packet The packet data\r
+     * @param   integer $offset The location offset in the packet of the\r
+     *                          label to decompress.\r
+     * @return  array   Returns a list of type array($name, $offset) where\r
+     *                  $name is the name of the label which was decompressed\r
+     *                  and $offset is the offset of the next field in the\r
+     *                  packet.  Returns array(null, null) on error\r
+     */\r
+    function dn_expand($packet, $offset)\r
+    {\r
+        $packetlen = strlen($packet);\r
+        $name = '';\r
+        while (1) {\r
+            if ($packetlen < ($offset + 1)) {\r
+                return array(null, null);\r
+            }\r
+\r
+            $a = unpack("@$offset/Cchar", $packet);\r
+            $len = (int)$a['char'];\r
+\r
+            if ($len == 0) {\r
+                $offset++;\r
+                break;\r
+            } else if (($len & 0xc0) == 0xc0) {\r
+                if ($packetlen < ($offset + Net_DNS_Packet::INT16SZ)) {\r
+                    return array(null, null);\r
+                }\r
+                $ptr = unpack("@$offset/ni", $packet);\r
+                $ptr = $ptr['i'];\r
+                $ptr = $ptr & 0x3fff;\r
+                $name2 = Net_DNS_Packet::dn_expand($packet, $ptr);\r
+\r
+                if (is_null($name2[0])) {\r
+                    return array(null, null);\r
+                }\r
+                $name .= $name2[0];\r
+                $offset += Net_DNS_Packet::INT16SZ;\r
+                break;\r
+            } else {\r
+                $offset++;\r
+\r
+                if ($packetlen < ($offset + $len)) {\r
+                    return array(null, null);\r
+                }\r
+\r
+                $elem = substr($packet, $offset, $len);\r
+                $name .= $elem . '.';\r
+                $offset += $len;\r
+            }\r
+        }\r
+        $name = preg_replace('/\.$/', '', $name);\r
+        return array($name, $offset);\r
+    }\r
+\r
+    /*}}}*/\r
+    /* Net_DNS_Packet::label_extract($packet, $offset) {{{ */\r
+    /**\r
+     * DNS packet decompression method\r
+     *\r
+     * Extracts the label stored at a particular location in a DNS\r
+     * packet.  The first argument is a variable containing  the packet\r
+     * data.  The second argument is the offset within the  packet where\r
+     * the (possibly) compressed domain name is stored.\r
+     *\r
+     * @param   string  $packet The packet data\r
+     * @param   integer $offset The location offset in the packet of the\r
+     *                          label to extract.\r
+     * @return  array   Returns a list of type array($name, $offset) where\r
+     *                  $name is the name of the label which was decompressed\r
+     *                  and $offset is the offset of the next field in the\r
+     *                  packet.  Returns array(null, null) on error\r
+     */\r
+    function label_extract($packet, $offset)\r
+    {\r
+        $packetlen = strlen($packet);\r
+        $name = '';\r
+        if ($packetlen < ($offset + 1)) {\r
+            return array(null, null);\r
+        }\r
+\r
+        $a = unpack("@$offset/Cchar", $packet);\r
+        $len = $a['char'];\r
+        $offset++;\r
+\r
+        if ($len + $offset > $packetlen) {\r
+            $name = substr($packet, $offset);\r
+            $offset = $packetlen;\r
+        } else {\r
+            $name = substr($packet, $offset, $len);\r
+            $offset += $len;\r
+        }\r
+        return array($name, $offset);\r
+    }\r
+\r
+    /*}}}*/\r
+    /* Net_DNS_Packet::parse_question($data, $offset) {{{ */\r
+    /**\r
+     * Parses the question section of a packet\r
+     *\r
+     * Examines a DNS packet at the specified offset and parses the data\r
+     * of the QUESTION section.\r
+     *\r
+     * @param   string  $data   The packet data returned from the server\r
+     * @param   integer $offset The location offset of the start of the\r
+     *                          question section.\r
+     * @return  array   An array of type array($q, $offset) where $q\r
+     *                  is a Net_DNS_Question object and $offset is the\r
+     *                  location of the next section of the packet which\r
+     *                  needs to be parsed.\r
+     */\r
+    function parse_question($data, $offset)\r
+    {\r
+        list($qname, $offset) = $this->dn_expand($data, $offset);\r
+        if (is_null($qname)) {\r
+            return array(null, null);\r
+        }\r
+\r
+        if (strlen($data) < ($offset + 4)) {\r
+            return array(null, null);\r
+        }\r
+\r
+        $q = unpack("@$offset/n2int", $data);\r
+        $qtype = $q['int1'];\r
+        $qclass = $q['int2'];\r
+        $offset += 4;\r
+\r
+        $qtype = Net_DNS::typesbyval($qtype);\r
+        $qclass = Net_DNS::classesbyval($qclass);\r
+\r
+        $q = new Net_DNS_Question($qname, $qtype, $qclass);\r
+        return array($q, $offset);\r
+    }\r
+\r
+    /*}}}*/\r
+    /* Net_DNS_Packet::parse_rr($data, $offset) {{{ */\r
+    /**\r
+     * Parses a resource record section of a packet\r
+     *\r
+     * Examines a DNS packet at the specified offset and parses the data\r
+     * of a section which contains RRs (ANSWER, AUTHORITY, ADDITIONAL).\r
+     *\r
+     * @param string    $data   The packet data returned from the server\r
+     * @param integer   $offset The location offset of the start of the resource\r
+     *                          record section.\r
+     * @return  array   An array of type array($rr, $offset) where $rr\r
+     *                  is a Net_DNS_RR object and $offset is the\r
+     *                  location of the next section of the packet which\r
+     *                  needs to be parsed.\r
+     */\r
+    function parse_rr($data, $offset)\r
+    {\r
+        list($name, $offset) = $this->dn_expand($data, $offset);\r
+        if ($name === null) {\r
+            return array(null, null);\r
+        }\r
+\r
+        if (strlen($data) < ($offset + 10)) {\r
+            return array(null, null);\r
+        }\r
+\r
+        $a = unpack("@$offset/n2tc/Nttl/nrdlength", $data);\r
+        $type = $a['tc1'];\r
+        $class = $a['tc2'];\r
+        $ttl = $a['ttl'];\r
+        $rdlength = $a['rdlength'];\r
+\r
+        $type = Net_DNS::typesbyval($type);\r
+        $class = Net_DNS::classesbyval($class);\r
+\r
+        $offset += 10;\r
+        if (strlen($data) < ($offset + $rdlength)) {\r
+            return array(null, null);\r
+        }\r
+\r
+        $rrobj = &Net_DNS_RR::factory(array($name,\r
+                    $type,\r
+                    $class,\r
+                    $ttl,\r
+                    $rdlength,\r
+                    $data,\r
+                    $offset));\r
+\r
+        if (is_null($rrobj)) {\r
+            return array(null, null);\r
+        }\r
+\r
+        $offset += $rdlength;\r
+\r
+        return array($rrobj, $offset);\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_Packet::display() {{{ */\r
+    /**\r
+     * Prints out the packet in a human readable formatted string\r
+     */\r
+    function display()\r
+    {\r
+        echo $this->string();\r
+    }\r
+\r
+    /*}}}*/\r
+    /* Net_DNS_Packet::string() {{{ */\r
+    /**\r
+     * Builds a human readable formatted string representing a packet\r
+     */\r
+    function string()\r
+    {\r
+        $retval = '';\r
+        if ($this->answerfrom) {\r
+            $retval .= ';; Answer received from ' . $this->answerfrom . '(' .\r
+                $this->answersize . " bytes)\n;;\n";\r
+        }\r
+\r
+        $retval .= ";; HEADER SECTION\n";\r
+        $retval .= $this->header->string();\r
+        $retval .= "\n";\r
+\r
+        $section = ($this->header->opcode == 'UPDATE') ? 'ZONE' : 'QUESTION';\r
+        $retval .= ";; $section SECTION (" . $this->header->qdcount     .\r
+            ' record' . ($this->header->qdcount == 1 ? '' : 's') .\r
+            ")\n";\r
+\r
+        foreach ($this->question as $qr) {\r
+            $retval .= ';; ' . $qr->string() . "\n";\r
+        }\r
+\r
+        $section = ($this->header->opcode == 'UPDATE') ? 'PREREQUISITE' : 'ANSWER';\r
+        $retval .= "\n;; $section SECTION (" . $this->header->ancount     .\r
+            ' record' . ($this->header->ancount == 1 ? '' : 's') .\r
+            ")\n";\r
+\r
+        if (is_array($this->answer)) {\r
+            foreach ($this->answer as $ans) {\r
+                $retval .= ';; ' . $ans->string() . "\n";\r
+            }\r
+        }\r
+\r
+        $section = ($this->header->opcode == 'UPDATE') ? 'UPDATE' : 'AUTHORITY';\r
+        $retval .= "\n;; $section SECTION (" . $this->header->nscount     .\r
+            ' record' . ($this->header->nscount == 1 ? '' : 's') .\r
+            ")\n";\r
+\r
+        if (is_array($this->authority)) {\r
+            foreach ($this->authority as $auth) {\r
+                $retval .= ';; ' . $auth->string() . "\n";\r
+            }\r
+        }\r
+\r
+        $retval .= "\n;; ADDITIONAL SECTION (" . $this->header->arcount     .\r
+            ' record' . ($this->header->arcount == 1 ? '' : 's') .\r
+            ")\n";\r
+\r
+        if (is_array($this->additional)) {\r
+            foreach ($this->additional as $addl) {\r
+                $retval .= ';; ' . $addl->string() . "\n";\r
+            }\r
+        }\r
+\r
+        $retval .= "\n\n";\r
+        return $retval;\r
+    }\r
+\r
+    /*}}}*/\r
+}\r
+/* }}} */\r
+/* VIM settings {{{\r
+ * Local variables:\r
+ * tab-width: 4\r
+ * c-basic-offset: 4\r
+ * soft-stop-width: 4\r
+ * c indent on\r
+ * End:\r
+ * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et\r
+ * vim<600: sw=4 ts=4\r
+ * }}} */\r
+?>\r
index ec3f5d2..c150875 100755 (executable)
@@ -1,93 +1,93 @@
-<?php
-/**
-*  License Information:
-*
-*  Net_DNS:  A resolver library for PHP
-*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
-*  Maintainers:
-*  Marco Kaiser <bate@php.net>
-*  Florian Anderiasch <fa@php.net>
-*
-* PHP versions 4 and 5
-*
-* LICENSE: This source file is subject to version 3.01 of the PHP license
-* that is available through the world-wide-web at the following URI:
-* http://www.php.net/license/3_01.txt.  If you did not receive a copy of
-* the PHP License and are unable to obtain it through the web, please
-* send a note to license@php.net so we can mail you a copy immediately.
-*/
-
-/* Net_DNS_Question object definition {{{ */
-/**
- * Builds or parses the QUESTION section of a DNS packet
- *
- * Builds or parses the QUESTION section of a DNS packet
- *
- * @package Net_DNS
- */
-class Net_DNS_Question
-{
-    /* class variable definitions {{{ */
-    var $qname = null;
-    var $qtype = null;
-    var $qclass = null;
-
-    /* }}} */
-    /* class constructor Net_DNS_Question($qname, $qtype, $qclass) {{{ */
-    function Net_DNS_Question($qname, $qtype, $qclass)
-    {
-        $qtype  = !is_null($qtype)  ? strtoupper($qtype)  : 'ANY';
-        $qclass = !is_null($qclass) ? strtoupper($qclass) : 'ANY';
-
-        // Check if the caller has the type and class reversed.
-        // We are not that kind for unknown types.... :-)
-        if ( ( is_null(Net_DNS::typesbyname($qtype)) ||
-               is_null(Net_DNS::classesbyname($qtype)) )
-          && !is_null(Net_DNS::classesbyname($qclass))
-          && !is_null(Net_DNS::typesbyname($qclass)))
-        {
-            list($qtype, $qclass) = array($qclass, $qtype);
-        }
-        $qname = preg_replace(array('/^\.+/', '/\.+$/'), '', $qname);
-        $this->qname = $qname;
-        $this->qtype = $qtype;
-        $this->qclass = $qclass;
-    }
-    /* }}} */
-    /* Net_DNS_Question::display() {{{*/
-    function display()
-    {
-        echo $this->string() . "\n";
-    }
-
-    /*}}}*/
-    /* Net_DNS_Question::string() {{{*/
-    function string()
-    {
-        return $this->qname . ".\t" . $this->qclass . "\t" . $this->qtype;
-    }
-
-    /*}}}*/
-    /* Net_DNS_Question::data(&$packet, $offset) {{{*/
-    function data($packet, $offset)
-    {
-        $data = $packet->dn_comp($this->qname, $offset);
-        $data .= pack('n', Net_DNS::typesbyname(strtoupper($this->qtype)));
-        $data .= pack('n', Net_DNS::classesbyname(strtoupper($this->qclass)));
-        return $data;
-    }
-
-    /*}}}*/
-}
-/* }}} */
-/* VIM settings{{{
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * soft-stop-width: 4
- * c indent on
- * End:
- * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et
- * vim<600: sw=4 ts=4
- * }}} */
+<?php\r
+/**\r
+*  License Information:\r
+*\r
+*  Net_DNS:  A resolver library for PHP\r
+*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net\r
+*  Maintainers:\r
+*  Marco Kaiser <bate@php.net>\r
+*  Florian Anderiasch <fa@php.net>\r
+*\r
+* PHP versions 4 and 5\r
+*\r
+* LICENSE: This source file is subject to version 3.01 of the PHP license\r
+* that is available through the world-wide-web at the following URI:\r
+* http://www.php.net/license/3_01.txt.  If you did not receive a copy of\r
+* the PHP License and are unable to obtain it through the web, please\r
+* send a note to license@php.net so we can mail you a copy immediately.\r
+*/\r
+\r
+/* Net_DNS_Question object definition {{{ */\r
+/**\r
+ * Builds or parses the QUESTION section of a DNS packet\r
+ *\r
+ * Builds or parses the QUESTION section of a DNS packet\r
+ *\r
+ * @package Net_DNS\r
+ */\r
+class Net_DNS_Question\r
+{\r
+    /* class variable definitions {{{ */\r
+    var $qname = null;\r
+    var $qtype = null;\r
+    var $qclass = null;\r
+\r
+    /* }}} */\r
+    /* class constructor Net_DNS_Question($qname, $qtype, $qclass) {{{ */\r
+    function Net_DNS_Question($qname, $qtype, $qclass)\r
+    {\r
+        $qtype  = !is_null($qtype)  ? strtoupper($qtype)  : 'ANY';\r
+        $qclass = !is_null($qclass) ? strtoupper($qclass) : 'ANY';\r
+\r
+        // Check if the caller has the type and class reversed.\r
+        // We are not that kind for unknown types.... :-)\r
+        if ( ( is_null(Net_DNS::typesbyname($qtype)) ||\r
+               is_null(Net_DNS::classesbyname($qtype)) )\r
+          && !is_null(Net_DNS::classesbyname($qclass))\r
+          && !is_null(Net_DNS::typesbyname($qclass)))\r
+        {\r
+            list($qtype, $qclass) = array($qclass, $qtype);\r
+        }\r
+        $qname = preg_replace(array('/^\.+/', '/\.+$/'), '', $qname);\r
+        $this->qname = $qname;\r
+        $this->qtype = $qtype;\r
+        $this->qclass = $qclass;\r
+    }\r
+    /* }}} */\r
+    /* Net_DNS_Question::display() {{{*/\r
+    function display()\r
+    {\r
+        echo $this->string() . "\n";\r
+    }\r
+\r
+    /*}}}*/\r
+    /* Net_DNS_Question::string() {{{*/\r
+    function string()\r
+    {\r
+        return $this->qname . ".\t" . $this->qclass . "\t" . $this->qtype;\r
+    }\r
+\r
+    /*}}}*/\r
+    /* Net_DNS_Question::data(&$packet, $offset) {{{*/\r
+    function data($packet, $offset)\r
+    {\r
+        $data = $packet->dn_comp($this->qname, $offset);\r
+        $data .= pack('n', Net_DNS::typesbyname(strtoupper($this->qtype)));\r
+        $data .= pack('n', Net_DNS::classesbyname(strtoupper($this->qclass)));\r
+        return $data;\r
+    }\r
+\r
+    /*}}}*/\r
+}\r
+/* }}} */\r
+/* VIM settings{{{\r
+ * Local variables:\r
+ * tab-width: 4\r
+ * c-basic-offset: 4\r
+ * soft-stop-width: 4\r
+ * c indent on\r
+ * End:\r
+ * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et\r
+ * vim<600: sw=4 ts=4\r
+ * }}} */\r
 ?>
\ No newline at end of file
index ae0261b..3754218 100755 (executable)
-<?php
-/**
-*  License Information:
-*
-*  Net_DNS:  A resolver library for PHP
-*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
-*  Maintainers:
-*  Marco Kaiser <bate@php.net>
-*  Florian Anderiasch <fa@php.net>
-*
-* PHP versions 4 and 5
-*
-* LICENSE: This source file is subject to version 3.01 of the PHP license
-* that is available through the world-wide-web at the following URI:
-* http://www.php.net/license/3_01.txt.  If you did not receive a copy of
-* the PHP License and are unable to obtain it through the web, please
-* send a note to license@php.net so we can mail you a copy immediately.
-*/
-
-/* Include files {{{ */
-require_once("Net/DNS/RR/A.php");
-require_once("Net/DNS/RR/AAAA.php");
-require_once("Net/DNS/RR/NS.php");
-require_once("Net/DNS/RR/CNAME.php");
-require_once("Net/DNS/RR/PTR.php");
-require_once("Net/DNS/RR/SOA.php");
-require_once("Net/DNS/RR/MX.php");
-require_once("Net/DNS/RR/TSIG.php");
-require_once("Net/DNS/RR/TXT.php");
-require_once("Net/DNS/RR/HINFO.php");
-require_once("Net/DNS/RR/SRV.php");
-require_once("Net/DNS/RR/NAPTR.php");
-require_once("Net/DNS/RR/RP.php");
-require_once("Net/DNS/RR/SPF.php");
-/* }}} */
-/* Net_DNS_RR object definition {{{ */
-/**
- * Resource Record object definition
- *
- * Builds or parses resource record sections of the DNS  packet including
- * the answer, authority, and additional  sections of the packet.
- *
- * @package Net_DNS
- */
-class Net_DNS_RR
-{
-    /* class variable definitions {{{ */
-    var $name;
-    var $type;
-    var $class;
-    var $ttl;
-    var $rdlength;
-    var $rdata;
-    /* }}} */
-
-    /*
-     * Use Net_DNS_RR::factory() instead
-     *
-     * @access private
-     */
-    /* class constructor - Net_DNS_RR($rrdata) {{{ */
-    function Net_DNS_RR($rrdata)
-    {
-        if ($rrdata != 'getRR') { //BC check/warning remove later
-            trigger_error("Please use Net_DNS_RR::factory() instead");
-        }
-    }
-
-    /*
-     * Returns an RR object, use this instead of constructor
-     *
-     * @param mixed $rr_rdata Options as string, array or data
-     * @return object Net_DNS_RR or Net_DNS_RR_<type>
-     * @access public
-     * @see Net_DNS_RR::new_from_array Net_DNS_RR::new_from_data Net_DNS_RR::new_from_string
-     */
-    function &factory($rrdata, $update_type = '')
-    {
-        if (is_string($rrdata)) {
-            $rr = &Net_DNS_RR::new_from_string($rrdata, $update_type);
-        } elseif (count($rrdata) == 7) {
-            list($name, $rrtype, $rrclass, $ttl, $rdlength, $data, $offset) = $rrdata;
-            $rr = &Net_DNS_RR::new_from_data($name, $rrtype, $rrclass, $ttl, $rdlength, $data, $offset);
-        } else {
-            $rr = &Net_DNS_RR::new_from_array($rrdata);
-        }
-        return $rr;
-    }
-
-    /* }}} */
-    /* Net_DNS_RR::new_from_data($name, $ttl, $rrtype, $rrclass, $rdlength, $data, $offset) {{{ */
-    function &new_from_data($name, $rrtype, $rrclass, $ttl, $rdlength, $data, $offset)
-    {
-        $rr = new Net_DNS_RR('getRR');
-        $rr->name = $name;
-        $rr->type = $rrtype;
-        $rr->class = $rrclass;
-        $rr->ttl = $ttl;
-        $rr->rdlength = $rdlength;
-        $rr->rdata = substr($data, $offset, $rdlength);
-        if (class_exists('Net_DNS_RR_' . $rrtype)) {
-            $scn = 'Net_DNS_RR_' . $rrtype;
-            $rr = new $scn($rr, $data, $offset);
-        }
-        return $rr;
-    }
-
-    /* }}} */
-    /* Net_DNS_RR::new_from_string($rrstring, $update_type = '') {{{ */
-    function &new_from_string($rrstring, $update_type = '')
-    {
-        $rr = new Net_DNS_RR('getRR');
-        $ttl = 0;
-        $parts = preg_split('/[\s]+/', $rrstring);
-        while (count($parts) > 0) {
-            $s = array_shift($parts);
-            if (!isset($name)) {
-                $name = preg_replace('/\.+$/', '', $s);
-            } else if (preg_match('/^\d+$/', $s)) {
-                $ttl = $s;
-            } else if (!isset($rrclass) && ! is_null(Net_DNS::classesbyname(strtoupper($s)))) {
-                $rrclass = strtoupper($s);
-                $rdata = join(' ', $parts);
-            } else if (! is_null(Net_DNS::typesbyname(strtoupper($s)))) {
-                $rrtype = strtoupper($s);
-                $rdata = join(' ', $parts);
-                break;
-            } else {
-                break;
-            }
-        }
-
-        /*
-         *  Do we need to do this?
-         */
-        $rdata = trim(chop($rdata));
-
-        if (! strlen($rrtype) && strlen($rrclass) && $rrclass == 'ANY') {
-            $rrtype = $rrclass;
-            $rrclass = 'IN';
-        } else if (! isset($rrclass)) {
-            $rrclass = 'IN';
-        }
-
-        if (! strlen($rrtype)) {
-            $rrtype = 'ANY';
-        }
-
-        if (strlen($update_type)) {
-            $update_type = strtolower($update_type);
-            if ($update_type == 'yxrrset') {
-                $ttl = 0;
-                if (! strlen($rdata)) {
-                    $rrclass = 'ANY';
-                }
-            } else if ($update_type == 'nxrrset') {
-                $ttl = 0;
-                $rrclass = 'NONE';
-                $rdata = '';
-            } else if ($update_type == 'yxdomain') {
-                $ttl = 0;
-                $rrclass = 'ANY';
-                $rrtype = 'ANY';
-                $rdata = '';
-            } else if ($update_type == 'nxdomain') {
-                $ttl = 0;
-                $rrclass = 'NONE';
-                $rrtype = 'ANY';
-                $rdata = '';
-            } else if (preg_match('/^(rr_)?add$/', $update_type)) {
-                $update_type = 'add';
-                if (! $ttl) {
-                    $ttl = 86400;
-                }
-            } else if (preg_match('/^(rr_)?del(ete)?$/', $update_type)) {
-                $update_type = 'del';
-                $ttl = 0;
-                $rrclass = $rdata ? 'NONE' : 'ANY';
-            }
-        }
-
-        if (strlen($rrtype)) {
-            $rr->name = $name;
-            $rr->type = $rrtype;
-            $rr->class = $rrclass;
-            $rr->ttl = $ttl;
-            $rr->rdlength = 0;
-            $rr->rdata = '';
-
-            if (class_exists('Net_DNS_RR_' . $rrtype)) {
-                $scn = 'Net_DNS_RR_' . $rrtype;
-
-                $obj = new $scn($rr, $rdata);
-                return $obj;
-            }
-
-            return $rr;
-
-        }
-
-        return null;
-    }
-
-    /* }}} */
-    /* Net_DNS_RR::new_from_array($rrarray) {{{ */
-    function &new_from_array($rrarray)
-    {
-        $rr = new Net_DNS_RR('getRR');
-        foreach ($rrarray as $k => $v) {
-            $rr->{strtolower($k)} = $v;
-        }
-
-        if (! strlen($rr->name)) {
-            return null;
-        }
-        if (! strlen($rr->type)){
-            return null;
-        }
-        if (! $rr->ttl) {
-            $rr->ttl = 0;
-        }
-        if (! strlen($rr->class)) {
-            $rr->class = 'IN';
-        }
-        if (strlen($rr->rdata)) {
-            $rr->rdlength = strlen($rr->rdata);
-        }
-        if (class_exists('Net_DNS_RR_' . $rr->type)) {
-            $scn = 'Net_DNS_RR_' . $rr->type;
-
-            $obj = new $scn($rr, !empty($rr->rdata) ? $rr->rdata : $rrarray);
-            return $obj;
-        }
-
-        return $rr;
-    }
-
-    /* }}} */
-    /* Net_DNS_RR::display() {{{ */
-    function display()
-    {
-        echo $this->string() . "\n";
-    }
-
-    /* }}} */
-    /* Net_DNS_RR::string() {{{ */
-    function string()
-    {
-        return $this->name . ".\t" . (strlen($this->name) < 16 ? "\t" : '') .
-                $this->ttl  . "\t"  .
-                $this->class. "\t"  .
-                $this->type . "\t"  .
-                $this->rdatastr();
-
-    }
-
-    /* }}} */
-    /* Net_DNS_RR::rdatastr() {{{ */
-    function rdatastr()
-    {
-        if ($this->rdlength) {
-            return '; rdlength = ' . $this->rdlength;
-        }
-        return '; no data';
-    }
-
-    /* }}} */
-    /* Net_DNS_RR::rdata() {{{ */
-    function rdata(&$packetORrdata, $offset = '')
-    {
-        if ($offset) {
-            return $this->rr_rdata($packetORrdata, $offset);
-        } else if (strlen($this->rdata)) {
-            return $this->rdata;
-        } else {
-            return null;
-        }
-    }
-
-    /* }}} */
-    /* Net_DNS_RR::rr_rdata($packet, $offset) {{{ */
-    function rr_rdata(&$packet, $offset)
-    {
-        return (strlen($this->rdata) ? $this->rdata : '');
-    }
-    /* }}} */
-    /* Net_DNS_RR::data() {{{ */
-    function data(&$packet, $offset)
-    {
-        $data = $packet->dn_comp($this->name, $offset);
-        $data .= pack('n', Net_DNS::typesbyname(strtoupper($this->type)));
-        $data .= pack('n', Net_DNS::classesbyname(strtoupper($this->class)));
-        $data .= pack('N', $this->ttl);
-
-        $offset += strlen($data) + 2;  // The 2 extra bytes are for rdlength
-
-        $rdata = $this->rdata($packet, $offset);
-        $data .= pack('n', strlen($rdata));
-        $data .= $rdata;
-
-        return $data;
-    }
-    /* }}} */
-}
-/* }}} */
-/* VIM settings {{{
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * soft-stop-width: 4
- * c indent on
- * End:
- * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et
- * vim<600: sw=4 ts=4
- * }}} */
+<?php\r
+/**\r
+*  License Information:\r
+*\r
+*  Net_DNS:  A resolver library for PHP\r
+*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net\r
+*  Maintainers:\r
+*  Marco Kaiser <bate@php.net>\r
+*  Florian Anderiasch <fa@php.net>\r
+*\r
+* PHP versions 4 and 5\r
+*\r
+* LICENSE: This source file is subject to version 3.01 of the PHP license\r
+* that is available through the world-wide-web at the following URI:\r
+* http://www.php.net/license/3_01.txt.  If you did not receive a copy of\r
+* the PHP License and are unable to obtain it through the web, please\r
+* send a note to license@php.net so we can mail you a copy immediately.\r
+*/\r
+\r
+/* Include files {{{ */\r
+require_once("Net/DNS/RR/A.php");\r
+require_once("Net/DNS/RR/AAAA.php");\r
+require_once("Net/DNS/RR/NS.php");\r
+require_once("Net/DNS/RR/CNAME.php");\r
+require_once("Net/DNS/RR/PTR.php");\r
+require_once("Net/DNS/RR/SOA.php");\r
+require_once("Net/DNS/RR/MX.php");\r
+require_once("Net/DNS/RR/TSIG.php");\r
+require_once("Net/DNS/RR/TXT.php");\r
+require_once("Net/DNS/RR/HINFO.php");\r
+require_once("Net/DNS/RR/SRV.php");\r
+require_once("Net/DNS/RR/NAPTR.php");\r
+require_once("Net/DNS/RR/RP.php");\r
+require_once("Net/DNS/RR/SPF.php");\r
+/* }}} */\r
+/* Net_DNS_RR object definition {{{ */\r
+/**\r
+ * Resource Record object definition\r
+ *\r
+ * Builds or parses resource record sections of the DNS  packet including\r
+ * the answer, authority, and additional  sections of the packet.\r
+ *\r
+ * @package Net_DNS\r
+ */\r
+class Net_DNS_RR\r
+{\r
+    /* class variable definitions {{{ */\r
+    var $name;\r
+    var $type;\r
+    var $class;\r
+    var $ttl;\r
+    var $rdlength;\r
+    var $rdata;\r
+    /* }}} */\r
+\r
+    /*\r
+     * Use Net_DNS_RR::factory() instead\r
+     *\r
+     * @access private\r
+     */\r
+    /* class constructor - Net_DNS_RR($rrdata) {{{ */\r
+    function Net_DNS_RR($rrdata)\r
+    {\r
+        if ($rrdata != 'getRR') { //BC check/warning remove later\r
+            trigger_error("Please use Net_DNS_RR::factory() instead");\r
+        }\r
+    }\r
+\r
+    /*\r
+     * Returns an RR object, use this instead of constructor\r
+     *\r
+     * @param mixed $rr_rdata Options as string, array or data\r
+     * @return object Net_DNS_RR or Net_DNS_RR_<type>\r
+     * @access public\r
+     * @see Net_DNS_RR::new_from_array Net_DNS_RR::new_from_data Net_DNS_RR::new_from_string\r
+     */\r
+    function &factory($rrdata, $update_type = '')\r
+    {\r
+        if (is_string($rrdata)) {\r
+            $rr = &Net_DNS_RR::new_from_string($rrdata, $update_type);\r
+        } elseif (count($rrdata) == 7) {\r
+            list($name, $rrtype, $rrclass, $ttl, $rdlength, $data, $offset) = $rrdata;\r
+            $rr = &Net_DNS_RR::new_from_data($name, $rrtype, $rrclass, $ttl, $rdlength, $data, $offset);\r
+        } else {\r
+            $rr = &Net_DNS_RR::new_from_array($rrdata);\r
+        }\r
+        return $rr;\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_RR::new_from_data($name, $ttl, $rrtype, $rrclass, $rdlength, $data, $offset) {{{ */\r
+    function &new_from_data($name, $rrtype, $rrclass, $ttl, $rdlength, $data, $offset)\r
+    {\r
+        $rr = new Net_DNS_RR('getRR');\r
+        $rr->name = $name;\r
+        $rr->type = $rrtype;\r
+        $rr->class = $rrclass;\r
+        $rr->ttl = $ttl;\r
+        $rr->rdlength = $rdlength;\r
+        $rr->rdata = substr($data, $offset, $rdlength);\r
+        if (class_exists('Net_DNS_RR_' . $rrtype)) {\r
+            $scn = 'Net_DNS_RR_' . $rrtype;\r
+            $rr = new $scn($rr, $data, $offset);\r
+        }\r
+        return $rr;\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_RR::new_from_string($rrstring, $update_type = '') {{{ */\r
+    function &new_from_string($rrstring, $update_type = '')\r
+    {\r
+        $rr = new Net_DNS_RR('getRR');\r
+        $ttl = 0;\r
+        $parts = preg_split('/[\s]+/', $rrstring);\r
+        while (count($parts) > 0) {\r
+            $s = array_shift($parts);\r
+            if (!isset($name)) {\r
+                $name = preg_replace('/\.+$/', '', $s);\r
+            } else if (preg_match('/^\d+$/', $s)) {\r
+                $ttl = $s;\r
+            } else if (!isset($rrclass) && ! is_null(Net_DNS::classesbyname(strtoupper($s)))) {\r
+                $rrclass = strtoupper($s);\r
+                $rdata = join(' ', $parts);\r
+            } else if (! is_null(Net_DNS::typesbyname(strtoupper($s)))) {\r
+                $rrtype = strtoupper($s);\r
+                $rdata = join(' ', $parts);\r
+                break;\r
+            } else {\r
+                break;\r
+            }\r
+        }\r
+\r
+        /*\r
+         *  Do we need to do this?\r
+         */\r
+        $rdata = trim(chop($rdata));\r
+\r
+        if (! strlen($rrtype) && strlen($rrclass) && $rrclass == 'ANY') {\r
+            $rrtype = $rrclass;\r
+            $rrclass = 'IN';\r
+        } else if (! isset($rrclass)) {\r
+            $rrclass = 'IN';\r
+        }\r
+\r
+        if (! strlen($rrtype)) {\r
+            $rrtype = 'ANY';\r
+        }\r
+\r
+        if (strlen($update_type)) {\r
+            $update_type = strtolower($update_type);\r
+            if ($update_type == 'yxrrset') {\r
+                $ttl = 0;\r
+                if (! strlen($rdata)) {\r
+                    $rrclass = 'ANY';\r
+                }\r
+            } else if ($update_type == 'nxrrset') {\r
+                $ttl = 0;\r
+                $rrclass = 'NONE';\r
+                $rdata = '';\r
+            } else if ($update_type == 'yxdomain') {\r
+                $ttl = 0;\r
+                $rrclass = 'ANY';\r
+                $rrtype = 'ANY';\r
+                $rdata = '';\r
+            } else if ($update_type == 'nxdomain') {\r
+                $ttl = 0;\r
+                $rrclass = 'NONE';\r
+                $rrtype = 'ANY';\r
+                $rdata = '';\r
+            } else if (preg_match('/^(rr_)?add$/', $update_type)) {\r
+                $update_type = 'add';\r
+                if (! $ttl) {\r
+                    $ttl = 86400;\r
+                }\r
+            } else if (preg_match('/^(rr_)?del(ete)?$/', $update_type)) {\r
+                $update_type = 'del';\r
+                $ttl = 0;\r
+                $rrclass = $rdata ? 'NONE' : 'ANY';\r
+            }\r
+        }\r
+\r
+        if (strlen($rrtype)) {\r
+            $rr->name = $name;\r
+            $rr->type = $rrtype;\r
+            $rr->class = $rrclass;\r
+            $rr->ttl = $ttl;\r
+            $rr->rdlength = 0;\r
+            $rr->rdata = '';\r
+\r
+            if (class_exists('Net_DNS_RR_' . $rrtype)) {\r
+                $scn = 'Net_DNS_RR_' . $rrtype;\r
+\r
+                $obj = new $scn($rr, $rdata);\r
+                return $obj;\r
+            }\r
+\r
+            return $rr;\r
+\r
+        }\r
+\r
+        return null;\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_RR::new_from_array($rrarray) {{{ */\r
+    function &new_from_array($rrarray)\r
+    {\r
+        $rr = new Net_DNS_RR('getRR');\r
+        foreach ($rrarray as $k => $v) {\r
+            $rr->{strtolower($k)} = $v;\r
+        }\r
+\r
+        if (! strlen($rr->name)) {\r
+            return null;\r
+        }\r
+        if (! strlen($rr->type)){\r
+            return null;\r
+        }\r
+        if (! $rr->ttl) {\r
+            $rr->ttl = 0;\r
+        }\r
+        if (! strlen($rr->class)) {\r
+            $rr->class = 'IN';\r
+        }\r
+        if (strlen($rr->rdata)) {\r
+            $rr->rdlength = strlen($rr->rdata);\r
+        }\r
+        if (class_exists('Net_DNS_RR_' . $rr->type)) {\r
+            $scn = 'Net_DNS_RR_' . $rr->type;\r
+\r
+            $obj = new $scn($rr, !empty($rr->rdata) ? $rr->rdata : $rrarray);\r
+            return $obj;\r
+        }\r
+\r
+        return $rr;\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_RR::display() {{{ */\r
+    function display()\r
+    {\r
+        echo $this->string() . "\n";\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_RR::string() {{{ */\r
+    function string()\r
+    {\r
+        return $this->name . ".\t" . (strlen($this->name) < 16 ? "\t" : '') .\r
+                $this->ttl  . "\t"  .\r
+                $this->class. "\t"  .\r
+                $this->type . "\t"  .\r
+                $this->rdatastr();\r
+\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_RR::rdatastr() {{{ */\r
+    function rdatastr()\r
+    {\r
+        if ($this->rdlength) {\r
+            return '; rdlength = ' . $this->rdlength;\r
+        }\r
+        return '; no data';\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_RR::rdata() {{{ */\r
+    function rdata(&$packetORrdata, $offset = '')\r
+    {\r
+        if ($offset) {\r
+            return $this->rr_rdata($packetORrdata, $offset);\r
+        } else if (strlen($this->rdata)) {\r
+            return $this->rdata;\r
+        } else {\r
+            return null;\r
+        }\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_RR::rr_rdata($packet, $offset) {{{ */\r
+    function rr_rdata(&$packet, $offset)\r
+    {\r
+        return (strlen($this->rdata) ? $this->rdata : '');\r
+    }\r
+    /* }}} */\r
+    /* Net_DNS_RR::data() {{{ */\r
+    function data(&$packet, $offset)\r
+    {\r
+        $data = $packet->dn_comp($this->name, $offset);\r
+        $data .= pack('n', Net_DNS::typesbyname(strtoupper($this->type)));\r
+        $data .= pack('n', Net_DNS::classesbyname(strtoupper($this->class)));\r
+        $data .= pack('N', $this->ttl);\r
+\r
+        $offset += strlen($data) + 2;  // The 2 extra bytes are for rdlength\r
+\r
+        $rdata = $this->rdata($packet, $offset);\r
+        $data .= pack('n', strlen($rdata));\r
+        $data .= $rdata;\r
+\r
+        return $data;\r
+    }\r
+    /* }}} */\r
+}\r
+/* }}} */\r
+/* VIM settings {{{\r
+ * Local variables:\r
+ * tab-width: 4\r
+ * c-basic-offset: 4\r
+ * soft-stop-width: 4\r
+ * c indent on\r
+ * End:\r
+ * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et\r
+ * vim<600: sw=4 ts=4\r
+ * }}} */\r
 ?>
\ No newline at end of file
index 63c91cc..723ea90 100755 (executable)
-<?php
-/**
-*  License Information:
-*
-*  Net_DNS:  A resolver library for PHP
-*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
-*  Maintainers:
-*  Marco Kaiser <bate@php.net>
-*  Florian Anderiasch <fa@php.net>
-*
-* PHP versions 4 and 5
-*
-* LICENSE: This source file is subject to version 3.01 of the PHP license
-* that is available through the world-wide-web at the following URI:
-* http://www.php.net/license/3_01.txt.  If you did not receive a copy of
-* the PHP License and are unable to obtain it through the web, please
-* send a note to license@php.net so we can mail you a copy immediately.
-*/
-
-/* Net_DNS_RR_A object definition {{{ */
-/**
- * A representation of a resource record of type <b>A</b>
- *
- * @package Net_DNS
- */
-class Net_DNS_RR_A extends Net_DNS_RR
-{
-    /* class variable definitions {{{ */
-    var $name;
-    var $type;
-    var $class;
-    var $ttl;
-    var $rdlength;
-    var $rdata;
-    var $address;
-    /* }}} */
-    /* class constructor - Net_DNS_RR_A(&$rro, $data, $offset = '') {{{ */
-    function Net_DNS_RR_A(&$rro, $data, $offset = '')
-    {
-        $this->name = $rro->name;
-        $this->type = $rro->type;
-        $this->class = $rro->class;
-        $this->ttl = $rro->ttl;
-        $this->rdlength = $rro->rdlength;
-        $this->rdata = $rro->rdata;
-
-        if ($offset) {
-            if ($this->rdlength > 0) {
-                /*
-                 *  We don't have inet_ntoa in PHP?
-                 */
-                $aparts = unpack('C4b', $this->rdata);
-                $addr = $aparts['b1'] . '.' .
-                    $aparts['b2'] . '.' .
-                    $aparts['b3'] . '.' .
-                    $aparts['b4'];
-                $this->address = $addr;
-            }
-        } elseif (is_array($data)) {
-            $this->address = $data['address'];
-        } else {
-            if (strlen($data) && preg_match("/([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)[ \t]*$/", $data, $regs)) {
-                if (($regs[1] >= 0 && $regs[1] <= 255) &&
-                        ($regs[2] >= 0 && $regs[2] <= 255) &&
-                        ($regs[3] >= 0 && $regs[3] <= 255) &&
-                        ($regs[4] >= 0 && $regs[4] <= 255)) {
-                    $this->address = $regs[1] . '.' . $regs[2] . '.' . $regs[3] . '.' .$regs[4];
-                }
-            }
-        }
-    }
-
-    /* }}} */
-    /* Net_DNS_RR_A::rdatastr() {{{ */
-    function rdatastr()
-    {
-        if (strlen($this->address)) {
-            return $this->address;
-        }
-        return '; no data';
-    }
-    /* }}} */
-    /* Net_DNS_RR_A::rr_rdata($packet, $offset) {{{ */
-    function rr_rdata($packet, $offset)
-    {
-        $aparts = explode('.', $this->address);
-        if (count($aparts) == 4) {
-            return pack('c4', $aparts[0], $aparts[1], $aparts[2], $aparts[3]);
-        }
-        return null;
-    }
-
-    /* }}} */
-
-}
-/* }}} */
-/* VIM settings {{{
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * soft-stop-width: 4
- * c indent on
- * End:
- * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et
- * vim<600: sw=4 ts=4
- * }}} */
-?>
+<?php\r
+/**\r
+*  License Information:\r
+*\r
+*  Net_DNS:  A resolver library for PHP\r
+*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net\r
+*  Maintainers:\r
+*  Marco Kaiser <bate@php.net>\r
+*  Florian Anderiasch <fa@php.net>\r
+*\r
+* PHP versions 4 and 5\r
+*\r
+* LICENSE: This source file is subject to version 3.01 of the PHP license\r
+* that is available through the world-wide-web at the following URI:\r
+* http://www.php.net/license/3_01.txt.  If you did not receive a copy of\r
+* the PHP License and are unable to obtain it through the web, please\r
+* send a note to license@php.net so we can mail you a copy immediately.\r
+*/\r
+\r
+/* Net_DNS_RR_A object definition {{{ */\r
+/**\r
+ * A representation of a resource record of type <b>A</b>\r
+ *\r
+ * @package Net_DNS\r
+ */\r
+class Net_DNS_RR_A extends Net_DNS_RR\r
+{\r
+    /* class variable definitions {{{ */\r
+    var $name;\r
+    var $type;\r
+    var $class;\r
+    var $ttl;\r
+    var $rdlength;\r
+    var $rdata;\r
+    var $address;\r
+    /* }}} */\r
+    /* class constructor - Net_DNS_RR_A(&$rro, $data, $offset = '') {{{ */\r
+    function Net_DNS_RR_A(&$rro, $data, $offset = '')\r
+    {\r
+        $this->name = $rro->name;\r
+        $this->type = $rro->type;\r
+        $this->class = $rro->class;\r
+        $this->ttl = $rro->ttl;\r
+        $this->rdlength = $rro->rdlength;\r
+        $this->rdata = $rro->rdata;\r
+\r
+        if ($offset) {\r
+            if ($this->rdlength > 0) {\r
+                /*\r
+                 *  We don't have inet_ntoa in PHP?\r
+                 */\r
+                $aparts = unpack('C4b', $this->rdata);\r
+                $addr = $aparts['b1'] . '.' .\r
+                    $aparts['b2'] . '.' .\r
+                    $aparts['b3'] . '.' .\r
+                    $aparts['b4'];\r
+                $this->address = $addr;\r
+            }\r
+        } elseif (is_array($data)) {\r
+            $this->address = $data['address'];\r
+        } else {\r
+            if (strlen($data) && preg_match("/([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)[ \t]*$/", $data, $regs)) {\r
+                if (($regs[1] >= 0 && $regs[1] <= 255) &&\r
+                        ($regs[2] >= 0 && $regs[2] <= 255) &&\r
+                        ($regs[3] >= 0 && $regs[3] <= 255) &&\r
+                        ($regs[4] >= 0 && $regs[4] <= 255)) {\r
+                    $this->address = $regs[1] . '.' . $regs[2] . '.' . $regs[3] . '.' .$regs[4];\r
+                }\r
+            }\r
+        }\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_RR_A::rdatastr() {{{ */\r
+    function rdatastr()\r
+    {\r
+        if (strlen($this->address)) {\r
+            return $this->address;\r
+        }\r
+        return '; no data';\r
+    }\r
+    /* }}} */\r
+    /* Net_DNS_RR_A::rr_rdata($packet, $offset) {{{ */\r
+    function rr_rdata($packet, $offset)\r
+    {\r
+        $aparts = explode('.', $this->address);\r
+        if (count($aparts) == 4) {\r
+            return pack('c4', $aparts[0], $aparts[1], $aparts[2], $aparts[3]);\r
+        }\r
+        return null;\r
+    }\r
+\r
+    /* }}} */\r
+\r
+}\r
+/* }}} */\r
+/* VIM settings {{{\r
+ * Local variables:\r
+ * tab-width: 4\r
+ * c-basic-offset: 4\r
+ * soft-stop-width: 4\r
+ * c indent on\r
+ * End:\r
+ * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et\r
+ * vim<600: sw=4 ts=4\r
+ * }}} */\r
+?>\r
index 54170e5..d3d575e 100755 (executable)
-<?php
-/**
-*  License Information:
-*
-*  Net_DNS:  A resolver library for PHP
-*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
-*  Maintainers:
-*  Marco Kaiser <bate@php.net>
-*  Florian Anderiasch <fa@php.net>
-*
-* PHP versions 4 and 5
-*
-* LICENSE: This source file is subject to version 3.01 of the PHP license
-* that is available through the world-wide-web at the following URI:
-* http://www.php.net/license/3_01.txt.  If you did not receive a copy of
-* the PHP License and are unable to obtain it through the web, please
-* send a note to license@php.net so we can mail you a copy immediately.
-*/
-
-/* Net_DNS_RR_AAAA object definition {{{ */
-/**
- * A representation of a resource record of type <b>AAAA</b>
- *
- * @package Net_DNS
- */
-class Net_DNS_RR_AAAA extends Net_DNS_RR
-{
-    /* class variable definitions {{{ */
-    var $name;
-    var $type;
-    var $class;
-    var $ttl;
-    var $rdlength;
-    var $rdata;
-    var $address;
-
-    /* }}} */
-    /* class constructor - Net_DNS_RR_AAAA(&$rro, $data, $offset = '') {{{ */
-    function Net_DNS_RR_AAAA(&$rro, $data, $offset = '')
-    {
-        $this->name = $rro->name;
-        $this->type = $rro->type;
-        $this->class = $rro->class;
-        $this->ttl = $rro->ttl;
-        $this->rdlength = $rro->rdlength;
-        $this->rdata = $rro->rdata;
-
-        if ($offset) {
-            $this->address = Net_DNS_RR_AAAA::ipv6_decompress(substr($this->rdata, 0, $this->rdlength));
-        } elseif (is_array($data)) {
-            $this->address = $data['address'];
-        } else {
-            if (strlen($data)) {
-                if (count($adata = explode(':', $data, 8)) >= 3) {
-                    foreach($adata as $addr)
-                        if (!preg_match('/^[0-9A-F]{0,4}$/i', $addr)) return;
-                    $this->address = trim($data);
-                }
-            }
-        }
-    }
-
-    /* }}} */
-    /* Net_DNS_RR_AAAA::rdatastr() {{{ */
-    function rdatastr()
-    {
-        if (strlen($this->address)) {
-            return $this->address;
-        }
-        return '; no data';
-    }
-    /* }}} */
-    /* Net_DNS_RR_AAAA::rr_rdata($packet, $offset) {{{ */
-    function rr_rdata($packet, $offset)
-    {
-        return Net_DNS_RR_AAAA::ipv6_compress($this->address);
-    }
-
-    /* }}} */
-    /* Net_DNS_RR_AAAA::ipv6_compress($addr) {{{ */
-    function ipv6_compress($addr)
-    {
-        $numparts = count(explode(':', $addr));
-               if ($numparts < 3 || $numparts > 8 ) {
-            /* Non-sensical IPv6 address */
-            return pack('n8', 0, 0, 0, 0, 0, 0, 0, 0);
-        }
-        if (strpos($addr, '::') !== false) {
-                       if (!preg_match('/^([0-9A-F]{0,4}:){0,7}(:[0-9A-F]{0,4}){0,7}$/i', $addr)) {
-                               return pack('n8', 0, 0, 0, 0, 0, 0, 0, 0);
-                       }
-            /* First we have to normalize the address, turn :: into :0:0:0:0: */
-            $filler = str_repeat(':0', 9 - $numparts) . ':';
-            if (substr($addr, 0, 2) == '::') {
-                $filler = "0$filler";
-            }
-            if (substr($addr, -2, 2) == '::') {
-                $filler .= '0';
-            }
-            $addr = str_replace('::', $filler, $addr);
-        } elseif (!preg_match('/^([0-9A-F]{0,4}:){7}[0-9A-F]{0,4}$/i', $addr)) {
-                       return pack('n8', 0, 0, 0, 0, 0, 0, 0, 0);
-               }
-
-        $aparts = explode(':', $addr);
-        return pack('n8', hexdec($aparts[0]), hexdec($aparts[1]), hexdec($aparts[2]), hexdec($aparts[3]),
-                          hexdec($aparts[4]), hexdec($aparts[5]), hexdec($aparts[6]), hexdec($aparts[7]));
-    }
-    /* }}} */
-
-    /* Net_DNS_RR_AAAA::ipv6_decompress($pack) {{{ */
-    function ipv6_decompress($pack)
-    {
-        if (strlen($pack) != 16) {
-            /* Must be 8 shorts long */
-            return '::';
-        }
-        $a = unpack('n8', $pack);
-        $addr = vsprintf("%x:%x:%x:%x:%x:%x:%x:%x", $a);
-        /* Shorthand the first :0:0: set into a :: */
-        /* TODO: Make this is a single replacement pattern */
-        if (substr($addr, -4) == ':0:0') {
-            return preg_replace('/((:0){2,})$/', '::', $addr);
-        } elseif (substr($addr, 0, 4) == '0:0:') {
-            return '0:0:'. substr($addr, 4);
-        } else {
-            return preg_replace('/(:(0:){2,})/', '::', $addr);
-        }
-    }
-
-    /* }}} */
-}
-/* }}} */
-/* VIM settings {{{
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * soft-stop-width: 4
- * c indent on
- * End:
- * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et
- * vim<600: sw=4 ts=4
- * }}} */
+<?php\r
+/**\r
+*  License Information:\r
+*\r
+*  Net_DNS:  A resolver library for PHP\r
+*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net\r
+*  Maintainers:\r
+*  Marco Kaiser <bate@php.net>\r
+*  Florian Anderiasch <fa@php.net>\r
+*\r
+* PHP versions 4 and 5\r
+*\r
+* LICENSE: This source file is subject to version 3.01 of the PHP license\r
+* that is available through the world-wide-web at the following URI:\r
+* http://www.php.net/license/3_01.txt.  If you did not receive a copy of\r
+* the PHP License and are unable to obtain it through the web, please\r
+* send a note to license@php.net so we can mail you a copy immediately.\r
+*/\r
+\r
+/* Net_DNS_RR_AAAA object definition {{{ */\r
+/**\r
+ * A representation of a resource record of type <b>AAAA</b>\r
+ *\r
+ * @package Net_DNS\r
+ */\r
+class Net_DNS_RR_AAAA extends Net_DNS_RR\r
+{\r
+    /* class variable definitions {{{ */\r
+    var $name;\r
+    var $type;\r
+    var $class;\r
+    var $ttl;\r
+    var $rdlength;\r
+    var $rdata;\r
+    var $address;\r
+\r
+    /* }}} */\r
+    /* class constructor - Net_DNS_RR_AAAA(&$rro, $data, $offset = '') {{{ */\r
+    function Net_DNS_RR_AAAA(&$rro, $data, $offset = '')\r
+    {\r
+        $this->name = $rro->name;\r
+        $this->type = $rro->type;\r
+        $this->class = $rro->class;\r
+        $this->ttl = $rro->ttl;\r
+        $this->rdlength = $rro->rdlength;\r
+        $this->rdata = $rro->rdata;\r
+\r
+        if ($offset) {\r
+            $this->address = Net_DNS_RR_AAAA::ipv6_decompress(substr($this->rdata, 0, $this->rdlength));\r
+        } elseif (is_array($data)) {\r
+            $this->address = $data['address'];\r
+        } else {\r
+            if (strlen($data)) {\r
+                if (count($adata = explode(':', $data, 8)) >= 3) {\r
+                    foreach($adata as $addr)\r
+                        if (!preg_match('/^[0-9A-F]{0,4}$/i', $addr)) return;\r
+                    $this->address = trim($data);\r
+                }\r
+            }\r
+        }\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_RR_AAAA::rdatastr() {{{ */\r
+    function rdatastr()\r
+    {\r
+        if (strlen($this->address)) {\r
+            return $this->address;\r
+        }\r
+        return '; no data';\r
+    }\r
+    /* }}} */\r
+    /* Net_DNS_RR_AAAA::rr_rdata($packet, $offset) {{{ */\r
+    function rr_rdata($packet, $offset)\r
+    {\r
+        return Net_DNS_RR_AAAA::ipv6_compress($this->address);\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_RR_AAAA::ipv6_compress($addr) {{{ */\r
+    function ipv6_compress($addr)\r
+    {\r
+        $numparts = count(explode(':', $addr));\r
+               if ($numparts < 3 || $numparts > 8 ) {\r
+            /* Non-sensical IPv6 address */\r
+            return pack('n8', 0, 0, 0, 0, 0, 0, 0, 0);\r
+        }\r
+        if (strpos($addr, '::') !== false) {\r
+                       if (!preg_match('/^([0-9A-F]{0,4}:){0,7}(:[0-9A-F]{0,4}){0,7}$/i', $addr)) {\r
+                               return pack('n8', 0, 0, 0, 0, 0, 0, 0, 0);\r
+                       }\r
+            /* First we have to normalize the address, turn :: into :0:0:0:0: */\r
+            $filler = str_repeat(':0', 9 - $numparts) . ':';\r
+            if (substr($addr, 0, 2) == '::') {\r
+                $filler = "0$filler";\r
+            }\r
+            if (substr($addr, -2, 2) == '::') {\r
+                $filler .= '0';\r
+            }\r
+            $addr = str_replace('::', $filler, $addr);\r
+        } elseif (!preg_match('/^([0-9A-F]{0,4}:){7}[0-9A-F]{0,4}$/i', $addr)) {\r
+                       return pack('n8', 0, 0, 0, 0, 0, 0, 0, 0);\r
+               }\r
+\r
+        $aparts = explode(':', $addr);\r
+        return pack('n8', hexdec($aparts[0]), hexdec($aparts[1]), hexdec($aparts[2]), hexdec($aparts[3]),\r
+                          hexdec($aparts[4]), hexdec($aparts[5]), hexdec($aparts[6]), hexdec($aparts[7]));\r
+    }\r
+    /* }}} */\r
+\r
+    /* Net_DNS_RR_AAAA::ipv6_decompress($pack) {{{ */\r
+    function ipv6_decompress($pack)\r
+    {\r
+        if (strlen($pack) != 16) {\r
+            /* Must be 8 shorts long */\r
+            return '::';\r
+        }\r
+        $a = unpack('n8', $pack);\r
+        $addr = vsprintf("%x:%x:%x:%x:%x:%x:%x:%x", $a);\r
+        /* Shorthand the first :0:0: set into a :: */\r
+        /* TODO: Make this is a single replacement pattern */\r
+        if (substr($addr, -4) == ':0:0') {\r
+            return preg_replace('/((:0){2,})$/', '::', $addr);\r
+        } elseif (substr($addr, 0, 4) == '0:0:') {\r
+            return '0:0:'. substr($addr, 4);\r
+        } else {\r
+            return preg_replace('/(:(0:){2,})/', '::', $addr);\r
+        }\r
+    }\r
+\r
+    /* }}} */\r
+}\r
+/* }}} */\r
+/* VIM settings {{{\r
+ * Local variables:\r
+ * tab-width: 4\r
+ * c-basic-offset: 4\r
+ * soft-stop-width: 4\r
+ * c indent on\r
+ * End:\r
+ * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et\r
+ * vim<600: sw=4 ts=4\r
+ * }}} */\r
 ?>
\ No newline at end of file
index 44e4530..3e89e44 100755 (executable)
@@ -1,94 +1,94 @@
-<?php
-/**
-*  License Information:
-*
-*  Net_DNS:  A resolver library for PHP
-*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
-*  Maintainers:
-*  Marco Kaiser <bate@php.net>
-*  Florian Anderiasch <fa@php.net>
-*
-* PHP versions 4 and 5
-*
-* LICENSE: This source file is subject to version 3.01 of the PHP license
-* that is available through the world-wide-web at the following URI:
-* http://www.php.net/license/3_01.txt.  If you did not receive a copy of
-* the PHP License and are unable to obtain it through the web, please
-* send a note to license@php.net so we can mail you a copy immediately.
-*/
-
-/* Net_DNS_RR_CNAME definition {{{ */
-/**
- * A representation of a resource record of type <b>CNAME</b>
- *
- * @package Net_DNS
- */
-class Net_DNS_RR_CNAME extends Net_DNS_RR
-{
-    /* class variable definitions {{{ */
-    var $name;
-    var $type;
-    var $class;
-    var $ttl;
-    var $rdlength;
-    var $rdata;
-    var $cname;
-
-    /* }}} */
-    /* class constructor - RR(&$rro, $data, $offset = '') {{{ */
-    function Net_DNS_RR_CNAME(&$rro, $data, $offset = '')
-    {
-        $this->name = $rro->name;
-        $this->type = $rro->type;
-        $this->class = $rro->class;
-        $this->ttl = $rro->ttl;
-        $this->rdlength = $rro->rdlength;
-        $this->rdata = $rro->rdata;
-
-        if ($offset) {
-            if ($this->rdlength > 0) {
-                $packet = new Net_DNS_Packet();
-                list($cname, $offset) = $packet->dn_expand($data, $offset);
-                $this->cname = $cname;
-            }
-        } elseif (is_array($data)) {
-            $this->cname = $data['cname'];
-        } else {
-            $this->cname = preg_replace("/[ \t]+(.+)[\. \t]*$/", '\\1', $data);
-        }
-    }
-
-    /* }}} */
-    /* Net_DNS_RR_CNAME::rdatastr() {{{ */
-    function rdatastr()
-    {
-        if (strlen($this->cname)) {
-            return $this->cname . '.';
-        }
-        return '; no data';
-    }
-
-    /* }}} */
-    /* Net_DNS_RR_CNAME::rr_rdata($packet, $offset) {{{ */
-    function rr_rdata($packet, $offset)
-    {
-        if (strlen($this->cname)) {
-            return $packet->dn_comp($this->cname, $offset);
-        }
-        return null;
-    }
-
-    /* }}} */
-}
-/* }}} */
-/* VIM settings {{{
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * soft-stop-width: 4
- * c indent on
- * End:
- * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et
- * vim<600: sw=4 ts=4
- * }}} */
-?>
+<?php\r
+/**\r
+*  License Information:\r
+*\r
+*  Net_DNS:  A resolver library for PHP\r
+*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net\r
+*  Maintainers:\r
+*  Marco Kaiser <bate@php.net>\r
+*  Florian Anderiasch <fa@php.net>\r
+*\r
+* PHP versions 4 and 5\r
+*\r
+* LICENSE: This source file is subject to version 3.01 of the PHP license\r
+* that is available through the world-wide-web at the following URI:\r
+* http://www.php.net/license/3_01.txt.  If you did not receive a copy of\r
+* the PHP License and are unable to obtain it through the web, please\r
+* send a note to license@php.net so we can mail you a copy immediately.\r
+*/\r
+\r
+/* Net_DNS_RR_CNAME definition {{{ */\r
+/**\r
+ * A representation of a resource record of type <b>CNAME</b>\r
+ *\r
+ * @package Net_DNS\r
+ */\r
+class Net_DNS_RR_CNAME extends Net_DNS_RR\r
+{\r
+    /* class variable definitions {{{ */\r
+    var $name;\r
+    var $type;\r
+    var $class;\r
+    var $ttl;\r
+    var $rdlength;\r
+    var $rdata;\r
+    var $cname;\r
+\r
+    /* }}} */\r
+    /* class constructor - RR(&$rro, $data, $offset = '') {{{ */\r
+    function Net_DNS_RR_CNAME(&$rro, $data, $offset = '')\r
+    {\r
+        $this->name = $rro->name;\r
+        $this->type = $rro->type;\r
+        $this->class = $rro->class;\r
+        $this->ttl = $rro->ttl;\r
+        $this->rdlength = $rro->rdlength;\r
+        $this->rdata = $rro->rdata;\r
+\r
+        if ($offset) {\r
+            if ($this->rdlength > 0) {\r
+                $packet = new Net_DNS_Packet();\r
+                list($cname, $offset) = $packet->dn_expand($data, $offset);\r
+                $this->cname = $cname;\r
+            }\r
+        } elseif (is_array($data)) {\r
+            $this->cname = $data['cname'];\r
+        } else {\r
+            $this->cname = preg_replace("/[ \t]+(.+)[\. \t]*$/", '\\1', $data);\r
+        }\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_RR_CNAME::rdatastr() {{{ */\r
+    function rdatastr()\r
+    {\r
+        if (strlen($this->cname)) {\r
+            return $this->cname . '.';\r
+        }\r
+        return '; no data';\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_RR_CNAME::rr_rdata($packet, $offset) {{{ */\r
+    function rr_rdata($packet, $offset)\r
+    {\r
+        if (strlen($this->cname)) {\r
+            return $packet->dn_comp($this->cname, $offset);\r
+        }\r
+        return null;\r
+    }\r
+\r
+    /* }}} */\r
+}\r
+/* }}} */\r
+/* VIM settings {{{\r
+ * Local variables:\r
+ * tab-width: 4\r
+ * c-basic-offset: 4\r
+ * soft-stop-width: 4\r
+ * c indent on\r
+ * End:\r
+ * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et\r
+ * vim<600: sw=4 ts=4\r
+ * }}} */\r
+?>\r
index a253d03..8802912 100755 (executable)
-<?php
-/**
-*  License Information:
-*
-*  Net_DNS:  A resolver library for PHP
-*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
-*  Maintainers:
-*  Marco Kaiser <bate@php.net>
-*  Florian Anderiasch <fa@php.net>
-*
-* PHP versions 4 and 5
-*
-* LICENSE: This source file is subject to version 3.01 of the PHP license
-* that is available through the world-wide-web at the following URI:
-* http://www.php.net/license/3_01.txt.  If you did not receive a copy of
-* the PHP License and are unable to obtain it through the web, please
-* send a note to license@php.net so we can mail you a copy immediately.
-*/
-
-/* Net_DNS_RR_HINFO definition {{{ */
-/**
- * A representation of a resource record of type <b>HINFO</b>
- *
- * @package Net_DNS
- */
-class Net_DNS_RR_HINFO extends Net_DNS_RR
-{
-    /* class variable definitions {{{ */
-    var $name;
-    var $type;
-    var $class;
-    var $ttl;
-    var $rdlength;
-    var $rdata;
-    var $cpu;
-    var $os;
-
-    /* }}} */
-    /* class constructor - RR(&$rro, $data, $offset = '') {{{ */
-    function Net_DNS_RR_HINFO(&$rro, $data, $offset = '')
-    {
-        $this->name = $rro->name;
-        $this->type = $rro->type;
-        $this->class = $rro->class;
-        $this->ttl = $rro->ttl;
-        $this->rdlength = $rro->rdlength;
-        $this->rdata = $rro->rdata;
-
-        if ($offset) {
-            if ($this->rdlength > 0) {
-                list($cpu, $offset) = Net_DNS_Packet::label_extract($data, $offset);
-                list($os,  $offset) = Net_DNS_Packet::label_extract($data, $offset);
-
-                $this->cpu = $cpu;
-                $this->os  = $os;
-            }
-        } elseif (is_array($data)) {
-            $this->cpu = $data['cpu'];
-            $this->os = $data['os'];
-        } else {
-            $data = str_replace('\\\\', chr(1) . chr(1), $data); /* disguise escaped backslash */
-            $data = str_replace('\\"', chr(2) . chr(2), $data); /* disguise \" */
-
-            preg_match('/("[^"]*"|[^ \t]*)[ \t]+("[^"]*"|[^ \t]*)[ \t]*$/', $data, $regs);
-            foreach($regs as $idx => $value) {
-                $value = str_replace(chr(2) . chr(2), '\\"', $value);
-                $value = str_replace(chr(1) . chr(1), '\\\\', $value);
-                $regs[$idx] = stripslashes($value);
-            }
-
-            $this->cpu = $regs[1];
-            $this->os = $regs[2];
-        }
-    }
-
-    /* }}} */
-    /* Net_DNS_RR_HINFO::rdatastr() {{{ */
-    function rdatastr()
-    {
-        if ($this->text) {
-            return '"' . addslashes($this->cpu) . '" "' . addslashes($this->os) . '"';
-        } else return '; no data';
-    }
-
-    /* }}} */
-    /* Net_DNS_RR_HINFO::rr_rdata($packet, $offset) {{{ */
-    function rr_rdata($packet, $offset)
-    {
-        if ($this->text) {
-            $rdata  = pack('C', strlen($this->cpu)) . $this->cpu;
-            $rdata .= pack('C', strlen($this->os))  . $this->os;
-            return $rdata;
-        }
-        return null;
-    }
-
-    /* }}} */
-}
-/* }}} */
-/* VIM settings {{{
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * soft-stop-width: 4
- * c indent on
- * End:
- * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et
- * vim<600: sw=4 ts=4
- * }}} */
+<?php\r
+/**\r
+*  License Information:\r
+*\r
+*  Net_DNS:  A resolver library for PHP\r
+*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net\r
+*  Maintainers:\r
+*  Marco Kaiser <bate@php.net>\r
+*  Florian Anderiasch <fa@php.net>\r
+*\r
+* PHP versions 4 and 5\r
+*\r
+* LICENSE: This source file is subject to version 3.01 of the PHP license\r
+* that is available through the world-wide-web at the following URI:\r
+* http://www.php.net/license/3_01.txt.  If you did not receive a copy of\r
+* the PHP License and are unable to obtain it through the web, please\r
+* send a note to license@php.net so we can mail you a copy immediately.\r
+*/\r
+\r
+/* Net_DNS_RR_HINFO definition {{{ */\r
+/**\r
+ * A representation of a resource record of type <b>HINFO</b>\r
+ *\r
+ * @package Net_DNS\r
+ */\r
+class Net_DNS_RR_HINFO extends Net_DNS_RR\r
+{\r
+    /* class variable definitions {{{ */\r
+    var $name;\r
+    var $type;\r
+    var $class;\r
+    var $ttl;\r
+    var $rdlength;\r
+    var $rdata;\r
+    var $cpu;\r
+    var $os;\r
+\r
+    /* }}} */\r
+    /* class constructor - RR(&$rro, $data, $offset = '') {{{ */\r
+    function Net_DNS_RR_HINFO(&$rro, $data, $offset = '')\r
+    {\r
+        $this->name = $rro->name;\r
+        $this->type = $rro->type;\r
+        $this->class = $rro->class;\r
+        $this->ttl = $rro->ttl;\r
+        $this->rdlength = $rro->rdlength;\r
+        $this->rdata = $rro->rdata;\r
+\r
+        if ($offset) {\r
+            if ($this->rdlength > 0) {\r
+                list($cpu, $offset) = Net_DNS_Packet::label_extract($data, $offset);\r
+                list($os,  $offset) = Net_DNS_Packet::label_extract($data, $offset);\r
+\r
+                $this->cpu = $cpu;\r
+                $this->os  = $os;\r
+            }\r
+        } elseif (is_array($data)) {\r
+            $this->cpu = $data['cpu'];\r
+            $this->os = $data['os'];\r
+        } else {\r
+            $data = str_replace('\\\\', chr(1) . chr(1), $data); /* disguise escaped backslash */\r
+            $data = str_replace('\\"', chr(2) . chr(2), $data); /* disguise \" */\r
+\r
+            preg_match('/("[^"]*"|[^ \t]*)[ \t]+("[^"]*"|[^ \t]*)[ \t]*$/', $data, $regs);\r
+            foreach($regs as $idx => $value) {\r
+                $value = str_replace(chr(2) . chr(2), '\\"', $value);\r
+                $value = str_replace(chr(1) . chr(1), '\\\\', $value);\r
+                $regs[$idx] = stripslashes($value);\r
+            }\r
+\r
+            $this->cpu = $regs[1];\r
+            $this->os = $regs[2];\r
+        }\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_RR_HINFO::rdatastr() {{{ */\r
+    function rdatastr()\r
+    {\r
+        if ($this->text) {\r
+            return '"' . addslashes($this->cpu) . '" "' . addslashes($this->os) . '"';\r
+        } else return '; no data';\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_RR_HINFO::rr_rdata($packet, $offset) {{{ */\r
+    function rr_rdata($packet, $offset)\r
+    {\r
+        if ($this->text) {\r
+            $rdata  = pack('C', strlen($this->cpu)) . $this->cpu;\r
+            $rdata .= pack('C', strlen($this->os))  . $this->os;\r
+            return $rdata;\r
+        }\r
+        return null;\r
+    }\r
+\r
+    /* }}} */\r
+}\r
+/* }}} */\r
+/* VIM settings {{{\r
+ * Local variables:\r
+ * tab-width: 4\r
+ * c-basic-offset: 4\r
+ * soft-stop-width: 4\r
+ * c indent on\r
+ * End:\r
+ * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et\r
+ * vim<600: sw=4 ts=4\r
+ * }}} */\r
 ?>
\ No newline at end of file
index 96b0b20..3e95c1c 100755 (executable)
-<?php
-/**
-*  License Information:
-*
-*  Net_DNS:  A resolver library for PHP
-*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
-*  Maintainers:
-*  Marco Kaiser <bate@php.net>
-*  Florian Anderiasch <fa@php.net>
-*
-* PHP versions 4 and 5
-*
-* LICENSE: This source file is subject to version 3.01 of the PHP license
-* that is available through the world-wide-web at the following URI:
-* http://www.php.net/license/3_01.txt.  If you did not receive a copy of
-* the PHP License and are unable to obtain it through the web, please
-* send a note to license@php.net so we can mail you a copy immediately.
-*/
-
-/* Net_DNS_RR_MX definition {{{ */
-/**
- * A representation of a resource record of type <b>MX</b>
- *
- * @package Net_DNS
- */
-class Net_DNS_RR_MX extends Net_DNS_RR
-{
-    /* class variable definitions {{{ */
-    var $name;
-    var $type;
-    var $class;
-    var $ttl;
-    var $rdlength;
-    var $rdata;
-    var $preference;
-    var $exchange;
-
-    /* }}} */
-    /* class constructor - RR(&$rro, $data, $offset = '') {{{ */
-    function Net_DNS_RR_MX(&$rro, $data, $offset = '')
-    {
-        $this->name = $rro->name;
-        $this->type = $rro->type;
-        $this->class = $rro->class;
-        $this->ttl = $rro->ttl;
-        $this->rdlength = $rro->rdlength;
-        $this->rdata = $rro->rdata;
-
-        if ($offset) {
-            if ($this->rdlength > 0) {
-                $a = unpack("@$offset/npreference", $data);
-                $offset += 2;
-                $packet = new Net_DNS_Packet();
-                list($exchange, $offset) = $packet->dn_expand($data, $offset);
-                $this->preference = $a['preference'];
-                $this->exchange = $exchange;
-            }
-        } elseif (is_array($data)) {
-            $this->preference = $data['preference'];
-            $this->exchange = $data['exchange'];
-        } else {
-            preg_match("/([0-9]+)[ \t]+(.+)[ \t]*$/", $data, $regs);
-            $this->preference = $regs[1];
-            $this->exchange = preg_replace('/(.*)\.$/', '\\1', $regs[2]);
-        }
-    }
-
-    /* }}} */
-    /* Net_DNS_RR_MX::rdatastr() {{{ */
-    function rdatastr()
-    {
-        if (preg_match('/^[0-9]+$/', $this->preference)) {
-            return $this->preference . ' ' . $this->exchange . '.';
-        }
-        return '; no data';
-    }
-
-    /* }}} */
-    /* Net_DNS_RR_MX::rr_rdata($packet, $offset) {{{ */
-    function rr_rdata($packet, $offset)
-    {
-        if (preg_match('/^[0-9]+$/', $this->preference)) {
-            $rdata = pack('n', $this->preference);
-            $rdata .= $packet->dn_comp($this->exchange, $offset + strlen($rdata));
-            return $rdata;
-        }
-        return null;
-    }
-
-    /* }}} */
-}
-/* }}} */
-/* VIM settings {{{
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * soft-stop-width: 4
- * c indent on
- * End:
- * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et
- * vim<600: sw=4 ts=4
- * }}} */
-?>
+<?php\r
+/**\r
+*  License Information:\r
+*\r
+*  Net_DNS:  A resolver library for PHP\r
+*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net\r
+*  Maintainers:\r
+*  Marco Kaiser <bate@php.net>\r
+*  Florian Anderiasch <fa@php.net>\r
+*\r
+* PHP versions 4 and 5\r
+*\r
+* LICENSE: This source file is subject to version 3.01 of the PHP license\r
+* that is available through the world-wide-web at the following URI:\r
+* http://www.php.net/license/3_01.txt.  If you did not receive a copy of\r
+* the PHP License and are unable to obtain it through the web, please\r
+* send a note to license@php.net so we can mail you a copy immediately.\r
+*/\r
+\r
+/* Net_DNS_RR_MX definition {{{ */\r
+/**\r
+ * A representation of a resource record of type <b>MX</b>\r
+ *\r
+ * @package Net_DNS\r
+ */\r
+class Net_DNS_RR_MX extends Net_DNS_RR\r
+{\r
+    /* class variable definitions {{{ */\r
+    var $name;\r
+    var $type;\r
+    var $class;\r
+    var $ttl;\r
+    var $rdlength;\r
+    var $rdata;\r
+    var $preference;\r
+    var $exchange;\r
+\r
+    /* }}} */\r
+    /* class constructor - RR(&$rro, $data, $offset = '') {{{ */\r
+    function Net_DNS_RR_MX(&$rro, $data, $offset = '')\r
+    {\r
+        $this->name = $rro->name;\r
+        $this->type = $rro->type;\r
+        $this->class = $rro->class;\r
+        $this->ttl = $rro->ttl;\r
+        $this->rdlength = $rro->rdlength;\r
+        $this->rdata = $rro->rdata;\r
+\r
+        if ($offset) {\r
+            if ($this->rdlength > 0) {\r
+                $a = unpack("@$offset/npreference", $data);\r
+                $offset += 2;\r
+                $packet = new Net_DNS_Packet();\r
+                list($exchange, $offset) = $packet->dn_expand($data, $offset);\r
+                $this->preference = $a['preference'];\r
+                $this->exchange = $exchange;\r
+            }\r
+        } elseif (is_array($data)) {\r
+            $this->preference = $data['preference'];\r
+            $this->exchange = $data['exchange'];\r
+        } else {\r
+            preg_match("/([0-9]+)[ \t]+(.+)[ \t]*$/", $data, $regs);\r
+            $this->preference = $regs[1];\r
+            $this->exchange = preg_replace('/(.*)\.$/', '\\1', $regs[2]);\r
+        }\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_RR_MX::rdatastr() {{{ */\r
+    function rdatastr()\r
+    {\r
+        if (preg_match('/^[0-9]+$/', $this->preference)) {\r
+            return $this->preference . ' ' . $this->exchange . '.';\r
+        }\r
+        return '; no data';\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_RR_MX::rr_rdata($packet, $offset) {{{ */\r
+    function rr_rdata($packet, $offset)\r
+    {\r
+        if (preg_match('/^[0-9]+$/', $this->preference)) {\r
+            $rdata = pack('n', $this->preference);\r
+            $rdata .= $packet->dn_comp($this->exchange, $offset + strlen($rdata));\r
+            return $rdata;\r
+        }\r
+        return null;\r
+    }\r
+\r
+    /* }}} */\r
+}\r
+/* }}} */\r
+/* VIM settings {{{\r
+ * Local variables:\r
+ * tab-width: 4\r
+ * c-basic-offset: 4\r
+ * soft-stop-width: 4\r
+ * c indent on\r
+ * End:\r
+ * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et\r
+ * vim<600: sw=4 ts=4\r
+ * }}} */\r
+?>\r
index f7c575c..47d4976 100755 (executable)
-<?php
-/**
-*  License Information:
-*
-*  Net_DNS:  A resolver library for PHP
-*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
-*  Maintainers:
-*  Marco Kaiser <bate@php.net>
-*  Florian Anderiasch <fa@php.net>
-*
-* PHP versions 4 and 5
-*
-* LICENSE: This source file is subject to version 3.01 of the PHP license
-* that is available through the world-wide-web at the following URI:
-* http://www.php.net/license/3_01.txt.  If you did not receive a copy of
-* the PHP License and are unable to obtain it through the web, please
-* send a note to license@php.net so we can mail you a copy immediately.
-*/
-
-/* Net_DNS_RR_NAPTR definition {{{ */
-/**
- * A representation of a resource record of type <b>NAPTR</b>
- *
- * @package Net_DNS
- */
-class Net_DNS_RR_NAPTR extends Net_DNS_RR
-{
-    /* class variable definitions {{{ */
-    var $name;
-    var $type;
-    var $class;
-    var $ttl;
-    var $rdlength;
-    var $rdata;
-    var $order;
-    var $preference;
-    var $flags;
-    var $services;
-    var $regex;
-    var $replacement;
-
-    /* }}} */
-    /* class constructor - RR(&$rro, $data, $offset = '') {{{ */
-    function Net_DNS_RR_NAPTR(&$rro, $data, $offset = '')
-    {
-        $this->name = $rro->name;
-        $this->type = $rro->type;
-        $this->class = $rro->class;
-        $this->ttl = $rro->ttl;
-        $this->rdlength = $rro->rdlength;
-        $this->rdata = $rro->rdata;
-
-        if ($offset) {
-            if ($this->rdlength > 0) {
-                $a = unpack("@$offset/norder/npreference", $data);
-                $offset += 4;
-                $packet = new Net_DNS_Packet();
-
-                list($flags, $offset) = Net_DNS_Packet::label_extract($data, $offset);
-                list($services, $offset) = Net_DNS_Packet::label_extract($data, $offset);
-                list($regex, $offset) = Net_DNS_Packet::label_extract($data, $offset);
-                list($replacement, $offset) = $packet->dn_expand($data, $offset);
-
-                $this->order = $a['order'];
-                $this->preference = $a['preference'];
-                $this->flags = $flags;
-                $this->services = $services;
-                $this->regex = $regex;
-                $this->replacement = $replacement;
-            }
-        } elseif (is_array($data)) {
-            $this->order = $data['order'];
-            $this->preference = $data['preference'];
-            $this->flags = $data['flags'];
-            $this->services = $data['services'];
-            $this->regex = $data['regex'];
-            $this->replacement = $data['replacement'];
-        } else {
-            $data = str_replace('\\\\', chr(1) . chr(1), $data); /* disguise escaped backslash */
-            $data = str_replace('\\"', chr(2) . chr(2), $data); /* disguise \" */
-            preg_match('/([0-9]+)[ \t]+([0-9]+)[ \t]+("[^"]*"|[^ \t]*)[ \t]+("[^"]*"|[^ \t]*)[ \t]+("[^"]*"|[^ \t]*)[ \t]+(.*?)[ \t]*$/', $data, $regs);
-            $this->preference = $regs[1];
-            $this->weight = $regs[2];
-            foreach($regs as $idx => $value) {
-                $value = str_replace(chr(2) . chr(2), '\\"', $value);
-                $value = str_replace(chr(1) . chr(1), '\\\\', $value);
-                $regs[$idx] = stripslashes($value);
-            }
-            $this->flags = $regs[3];
-            $this->services = $regs[4];
-            $this->regex = $regs[5];
-            $this->replacement = $regs[6];
-        }
-    }
-
-    /* }}} */
-    /* Net_DNS_RR_NAPTR::rdatastr() {{{ */
-    function rdatastr()
-    {
-        if ($this->rdata) {
-            return intval($this->order) . ' ' . intval($this->preference) . ' "' . addslashes($this->flags) . '" "' .
-                   addslashes($this->services) . '" "' . addslashes($this->regex) . '" "' . addslashes($this->replacement) . '"';
-        } else return '; no data';
-    }
-
-    /* }}} */
-    /* Net_DNS_RR_NAPTR::rr_rdata($packet, $offset) {{{ */
-    function rr_rdata($packet, $offset)
-    {
-        if ($this->preference) {
-            $rdata  = pack('nn', $this->order, $this->preference);
-            $rdata .= pack('C', strlen($this->flags))    . $this->flags;
-            $rdata .= pack('C', strlen($this->services)) . $this->services;
-            $rdata .= pack('C', strlen($this->regex))    . $this->regex;
-            $rdata .= $packet->dn_comp($this->replacement, $offset + strlen($rdata));
-            return $rdata;
-        }
-        return null;
-    }
-
-    /* }}} */
-}
-/* }}} */
-/* VIM settings {{{
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * soft-stop-width: 4
- * c indent on
- * End:
- * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et
- * vim<600: sw=4 ts=4
- * }}} */
-?>
+<?php\r
+/**\r
+*  License Information:\r
+*\r
+*  Net_DNS:  A resolver library for PHP\r
+*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net\r
+*  Maintainers:\r
+*  Marco Kaiser <bate@php.net>\r
+*  Florian Anderiasch <fa@php.net>\r
+*\r
+* PHP versions 4 and 5\r
+*\r
+* LICENSE: This source file is subject to version 3.01 of the PHP license\r
+* that is available through the world-wide-web at the following URI:\r
+* http://www.php.net/license/3_01.txt.  If you did not receive a copy of\r
+* the PHP License and are unable to obtain it through the web, please\r
+* send a note to license@php.net so we can mail you a copy immediately.\r
+*/\r
+\r
+/* Net_DNS_RR_NAPTR definition {{{ */\r
+/**\r
+ * A representation of a resource record of type <b>NAPTR</b>\r
+ *\r
+ * @package Net_DNS\r
+ */\r
+class Net_DNS_RR_NAPTR extends Net_DNS_RR\r
+{\r
+    /* class variable definitions {{{ */\r
+    var $name;\r
+    var $type;\r
+    var $class;\r
+    var $ttl;\r
+    var $rdlength;\r
+    var $rdata;\r
+    var $order;\r
+    var $preference;\r
+    var $flags;\r
+    var $services;\r
+    var $regex;\r
+    var $replacement;\r
+\r
+    /* }}} */\r
+    /* class constructor - RR(&$rro, $data, $offset = '') {{{ */\r
+    function Net_DNS_RR_NAPTR(&$rro, $data, $offset = '')\r
+    {\r
+        $this->name = $rro->name;\r
+        $this->type = $rro->type;\r
+        $this->class = $rro->class;\r
+        $this->ttl = $rro->ttl;\r
+        $this->rdlength = $rro->rdlength;\r
+        $this->rdata = $rro->rdata;\r
+\r
+        if ($offset) {\r
+            if ($this->rdlength > 0) {\r
+                $a = unpack("@$offset/norder/npreference", $data);\r
+                $offset += 4;\r
+                $packet = new Net_DNS_Packet();\r
+\r
+                list($flags, $offset) = Net_DNS_Packet::label_extract($data, $offset);\r
+                list($services, $offset) = Net_DNS_Packet::label_extract($data, $offset);\r
+                list($regex, $offset) = Net_DNS_Packet::label_extract($data, $offset);\r
+                list($replacement, $offset) = $packet->dn_expand($data, $offset);\r
+\r
+                $this->order = $a['order'];\r
+                $this->preference = $a['preference'];\r
+                $this->flags = $flags;\r
+                $this->services = $services;\r
+                $this->regex = $regex;\r
+                $this->replacement = $replacement;\r
+            }\r
+        } elseif (is_array($data)) {\r
+            $this->order = $data['order'];\r
+            $this->preference = $data['preference'];\r
+            $this->flags = $data['flags'];\r
+            $this->services = $data['services'];\r
+            $this->regex = $data['regex'];\r
+            $this->replacement = $data['replacement'];\r
+        } else {\r
+            $data = str_replace('\\\\', chr(1) . chr(1), $data); /* disguise escaped backslash */\r
+            $data = str_replace('\\"', chr(2) . chr(2), $data); /* disguise \" */\r
+            preg_match('/([0-9]+)[ \t]+([0-9]+)[ \t]+("[^"]*"|[^ \t]*)[ \t]+("[^"]*"|[^ \t]*)[ \t]+("[^"]*"|[^ \t]*)[ \t]+(.*?)[ \t]*$/', $data, $regs);\r
+            $this->preference = $regs[1];\r
+            $this->weight = $regs[2];\r
+            foreach($regs as $idx => $value) {\r
+                $value = str_replace(chr(2) . chr(2), '\\"', $value);\r
+                $value = str_replace(chr(1) . chr(1), '\\\\', $value);\r
+                $regs[$idx] = stripslashes($value);\r
+            }\r
+            $this->flags = $regs[3];\r
+            $this->services = $regs[4];\r
+            $this->regex = $regs[5];\r
+            $this->replacement = $regs[6];\r
+        }\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_RR_NAPTR::rdatastr() {{{ */\r
+    function rdatastr()\r
+    {\r
+        if ($this->rdata) {\r
+            return intval($this->order) . ' ' . intval($this->preference) . ' "' . addslashes($this->flags) . '" "' .\r
+                   addslashes($this->services) . '" "' . addslashes($this->regex) . '" "' . addslashes($this->replacement) . '"';\r
+        } else return '; no data';\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_RR_NAPTR::rr_rdata($packet, $offset) {{{ */\r
+    function rr_rdata($packet, $offset)\r
+    {\r
+        if ($this->preference) {\r
+            $rdata  = pack('nn', $this->order, $this->preference);\r
+            $rdata .= pack('C', strlen($this->flags))    . $this->flags;\r
+            $rdata .= pack('C', strlen($this->services)) . $this->services;\r
+            $rdata .= pack('C', strlen($this->regex))    . $this->regex;\r
+            $rdata .= $packet->dn_comp($this->replacement, $offset + strlen($rdata));\r
+            return $rdata;\r
+        }\r
+        return null;\r
+    }\r
+\r
+    /* }}} */\r
+}\r
+/* }}} */\r
+/* VIM settings {{{\r
+ * Local variables:\r
+ * tab-width: 4\r
+ * c-basic-offset: 4\r
+ * soft-stop-width: 4\r
+ * c indent on\r
+ * End:\r
+ * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et\r
+ * vim<600: sw=4 ts=4\r
+ * }}} */\r
+?>\r
index 735f92f..fc1dc67 100755 (executable)
@@ -1,95 +1,95 @@
-<?php
-/**
-*  License Information:
-*
-*  Net_DNS:  A resolver library for PHP
-*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
-*  Maintainers:
-*  Marco Kaiser <bate@php.net>
-*  Florian Anderiasch <fa@php.net>
-*
-* PHP versions 4 and 5
-*
-* LICENSE: This source file is subject to version 3.01 of the PHP license
-* that is available through the world-wide-web at the following URI:
-* http://www.php.net/license/3_01.txt.  If you did not receive a copy of
-* the PHP License and are unable to obtain it through the web, please
-* send a note to license@php.net so we can mail you a copy immediately.
-*/
-
-/* Net_DNS_RR_NS definition {{{ */
-/**
- * A representation of a resource record of type <b>NS</b>
- *
- * @package Net_DNS
- */
-class Net_DNS_RR_NS extends Net_DNS_RR
-{
-    /* class variable defintiions {{{ */
-    var $name;
-    var $type;
-    var $class;
-    var $ttl;
-    var $rdlength;
-    var $rdata;
-    var $nsdname;
-
-    /* }}} */
-    /* class constructor - RR(&$rro, $data, $offset = '') {{{ */
-    function Net_DNS_RR_NS(&$rro, $data, $offset = '')
-    {
-        $this->name = $rro->name;
-        $this->type = $rro->type;
-        $this->class = $rro->class;
-        $this->ttl = $rro->ttl;
-        $this->rdlength = $rro->rdlength;
-        $this->rdata = $rro->rdata;
-
-
-        if ($offset) {
-            if ($this->rdlength > 0) {
-                $packet = new Net_DNS_Packet();
-                list($nsdname, $offset) = $packet->dn_expand($data, $offset);
-                $this->nsdname = $nsdname;
-            }
-        } elseif (is_array($data)) {
-            $this->nsdname = $data['nsdname'];
-        } else {
-            $this->nsdname = preg_replace("/[ \t]+(.+)[ \t]*$/", '\\1', $data);
-        }
-    }
-
-    /* }}} */
-    /* Net_DNS_RR_NS::rdatastr() {{{ */
-    function rdatastr()
-    {
-        if (strlen($this->nsdname)) {
-            return $this->nsdname . '.';
-        }
-        return '; no data';
-    }
-
-    /* }}} */
-    /* Net_DNS_RR_NS::rr_rdata($packet, $offset) {{{ */
-    function rr_rdata($packet, $offset)
-    {
-        if (strlen($this->nsdname)) {
-            return $packet->dn_comp($this->nsdname, $offset);
-        }
-        return null;
-    }
-
-    /* }}} */
-}
-/* }}} */
-/* VIM settings {{{
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * soft-stop-width: 4
- * c indent on
- * End:
- * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et
- * vim<600: sw=4 ts=4
- * }}} */
-?>
+<?php\r
+/**\r
+*  License Information:\r
+*\r
+*  Net_DNS:  A resolver library for PHP\r
+*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net\r
+*  Maintainers:\r
+*  Marco Kaiser <bate@php.net>\r
+*  Florian Anderiasch <fa@php.net>\r
+*\r
+* PHP versions 4 and 5\r
+*\r
+* LICENSE: This source file is subject to version 3.01 of the PHP license\r
+* that is available through the world-wide-web at the following URI:\r
+* http://www.php.net/license/3_01.txt.  If you did not receive a copy of\r
+* the PHP License and are unable to obtain it through the web, please\r
+* send a note to license@php.net so we can mail you a copy immediately.\r
+*/\r
+\r
+/* Net_DNS_RR_NS definition {{{ */\r
+/**\r
+ * A representation of a resource record of type <b>NS</b>\r
+ *\r
+ * @package Net_DNS\r
+ */\r
+class Net_DNS_RR_NS extends Net_DNS_RR\r
+{\r
+    /* class variable defintiions {{{ */\r
+    var $name;\r
+    var $type;\r
+    var $class;\r
+    var $ttl;\r
+    var $rdlength;\r
+    var $rdata;\r
+    var $nsdname;\r
+\r
+    /* }}} */\r
+    /* class constructor - RR(&$rro, $data, $offset = '') {{{ */\r
+    function Net_DNS_RR_NS(&$rro, $data, $offset = '')\r
+    {\r
+        $this->name = $rro->name;\r
+        $this->type = $rro->type;\r
+        $this->class = $rro->class;\r
+        $this->ttl = $rro->ttl;\r
+        $this->rdlength = $rro->rdlength;\r
+        $this->rdata = $rro->rdata;\r
+\r
+\r
+        if ($offset) {\r
+            if ($this->rdlength > 0) {\r
+                $packet = new Net_DNS_Packet();\r
+                list($nsdname, $offset) = $packet->dn_expand($data, $offset);\r
+                $this->nsdname = $nsdname;\r
+            }\r
+        } elseif (is_array($data)) {\r
+            $this->nsdname = $data['nsdname'];\r
+        } else {\r
+            $this->nsdname = preg_replace("/[ \t]+(.+)[ \t]*$/", '\\1', $data);\r
+        }\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_RR_NS::rdatastr() {{{ */\r
+    function rdatastr()\r
+    {\r
+        if (strlen($this->nsdname)) {\r
+            return $this->nsdname . '.';\r
+        }\r
+        return '; no data';\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_RR_NS::rr_rdata($packet, $offset) {{{ */\r
+    function rr_rdata($packet, $offset)\r
+    {\r
+        if (strlen($this->nsdname)) {\r
+            return $packet->dn_comp($this->nsdname, $offset);\r
+        }\r
+        return null;\r
+    }\r
+\r
+    /* }}} */\r
+}\r
+/* }}} */\r
+/* VIM settings {{{\r
+ * Local variables:\r
+ * tab-width: 4\r
+ * c-basic-offset: 4\r
+ * soft-stop-width: 4\r
+ * c indent on\r
+ * End:\r
+ * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et\r
+ * vim<600: sw=4 ts=4\r
+ * }}} */\r
+?>\r
index 489b5f0..2b9d672 100755 (executable)
@@ -1,96 +1,96 @@
-<?php
-/**
-*  License Information:
-*
-*  Net_DNS:  A resolver library for PHP
-*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
-*  Maintainers:
-*  Marco Kaiser <bate@php.net>
-*  Florian Anderiasch <fa@php.net>
-*
-* PHP versions 4 and 5
-*
-* LICENSE: This source file is subject to version 3.01 of the PHP license
-* that is available through the world-wide-web at the following URI:
-* http://www.php.net/license/3_01.txt.  If you did not receive a copy of
-* the PHP License and are unable to obtain it through the web, please
-* send a note to license@php.net so we can mail you a copy immediately.
-*/
-
-/* Net_DNS_RR_PTR definition {{{ */
-/**
- * A representation of a resource record of type <b>PTR</b>
- *
- * @package Net_DNS
- */
-class Net_DNS_RR_PTR extends Net_DNS_RR
-{
-    /* class variable definitions {{{ */
-    var $name;
-    var $type;
-    var $class;
-    var $ttl;
-    var $rdlength;
-    var $rdata;
-    var $ptrdname;
-
-    /* }}} */
-    /* class constructor - RR(&$rro, $data, $offset = '') {{{ */
-    function Net_DNS_RR_PTR(&$rro, $data, $offset = '')
-    {
-        $this->name = $rro->name;
-        $this->type = $rro->type;
-        $this->class = $rro->class;
-        $this->ttl = $rro->ttl;
-        $this->rdlength = $rro->rdlength;
-        $this->rdata = $rro->rdata;
-
-
-        if ($offset) {
-            if ($this->rdlength > 0) {
-                $packet = new Net_DNS_Packet();
-
-                list($ptrdname, $offset) = $packet->dn_expand($data, $offset);
-                $this->ptrdname = $ptrdname;
-            }
-        } elseif (is_array($data)) {
-            $this->ptrdname = $data['ptrdname'];
-        } else {
-            $this->ptrdname = preg_replace("/[ \t]+(.+)[ \t]*$/", '\\1', $data);
-        }
-    }
-
-    /* }}} */
-    /* Net_DNS_RR_PTR::rdatastr() {{{ */
-    function rdatastr()
-    {
-        if (strlen($this->ptrdname)) {
-            return $this->ptrdname . '.';
-        }
-        return '; no data';
-    }
-
-    /* }}} */
-    /* Net_DNS_RR_PTR::rr_rdata($packet, $offset) {{{ */
-    function rr_rdata($packet, $offset)
-    {
-        if (strlen($this->ptrdname)) {
-            return $packet->dn_comp($this->ptrdname, $offset);
-        }
-        return null;
-    }
-
-    /* }}} */
-}
-/* }}} */
-/* VIM settings {{{
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * soft-stop-width: 4
- * c indent on
- * End:
- * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et
- * vim<600: sw=4 ts=4
- * }}} */
-?>
+<?php\r
+/**\r
+*  License Information:\r
+*\r
+*  Net_DNS:  A resolver library for PHP\r
+*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net\r
+*  Maintainers:\r
+*  Marco Kaiser <bate@php.net>\r
+*  Florian Anderiasch <fa@php.net>\r
+*\r
+* PHP versions 4 and 5\r
+*\r
+* LICENSE: This source file is subject to version 3.01 of the PHP license\r
+* that is available through the world-wide-web at the following URI:\r
+* http://www.php.net/license/3_01.txt.  If you did not receive a copy of\r
+* the PHP License and are unable to obtain it through the web, please\r
+* send a note to license@php.net so we can mail you a copy immediately.\r
+*/\r
+\r
+/* Net_DNS_RR_PTR definition {{{ */\r
+/**\r
+ * A representation of a resource record of type <b>PTR</b>\r
+ *\r
+ * @package Net_DNS\r
+ */\r
+class Net_DNS_RR_PTR extends Net_DNS_RR\r
+{\r
+    /* class variable definitions {{{ */\r
+    var $name;\r
+    var $type;\r
+    var $class;\r
+    var $ttl;\r
+    var $rdlength;\r
+    var $rdata;\r
+    var $ptrdname;\r
+\r
+    /* }}} */\r
+    /* class constructor - RR(&$rro, $data, $offset = '') {{{ */\r
+    function Net_DNS_RR_PTR(&$rro, $data, $offset = '')\r
+    {\r
+        $this->name = $rro->name;\r
+        $this->type = $rro->type;\r
+        $this->class = $rro->class;\r
+        $this->ttl = $rro->ttl;\r
+        $this->rdlength = $rro->rdlength;\r
+        $this->rdata = $rro->rdata;\r
+\r
+\r
+        if ($offset) {\r
+            if ($this->rdlength > 0) {\r
+                $packet = new Net_DNS_Packet();\r
+\r
+                list($ptrdname, $offset) = $packet->dn_expand($data, $offset);\r
+                $this->ptrdname = $ptrdname;\r
+            }\r
+        } elseif (is_array($data)) {\r
+            $this->ptrdname = $data['ptrdname'];\r
+        } else {\r
+            $this->ptrdname = preg_replace("/[ \t]+(.+)[ \t]*$/", '\\1', $data);\r
+        }\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_RR_PTR::rdatastr() {{{ */\r
+    function rdatastr()\r
+    {\r
+        if (strlen($this->ptrdname)) {\r
+            return $this->ptrdname . '.';\r
+        }\r
+        return '; no data';\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_RR_PTR::rr_rdata($packet, $offset) {{{ */\r
+    function rr_rdata($packet, $offset)\r
+    {\r
+        if (strlen($this->ptrdname)) {\r
+            return $packet->dn_comp($this->ptrdname, $offset);\r
+        }\r
+        return null;\r
+    }\r
+\r
+    /* }}} */\r
+}\r
+/* }}} */\r
+/* VIM settings {{{\r
+ * Local variables:\r
+ * tab-width: 4\r
+ * c-basic-offset: 4\r
+ * soft-stop-width: 4\r
+ * c indent on\r
+ * End:\r
+ * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et\r
+ * vim<600: sw=4 ts=4\r
+ * }}} */\r
+?>\r
index 120fa7f..7d453d0 100755 (executable)
-<?php
-/**
-*  License Information:
-*
-*  Net_DNS:  A resolver library for PHP
-*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
-*  Maintainers:
-*  Marco Kaiser <bate@php.net>
-*  Florian Anderiasch <fa@php.net>
-*  Mike Pultz <mike@mrhost.ca>
-*
-* PHP versions 4 and 5
-*
-* LICENSE: This source file is subject to version 3.01 of the PHP license
-* that is available through the world-wide-web at the following URI:
-* http://www.php.net/license/3_01.txt.  If you did not receive a copy of
-* the PHP License and are unable to obtain it through the web, please
-* send a note to license@php.net so we can mail you a copy immediately.
-*/
-
-/* Net_DNS_RR_RP definition {{{ */
-/**
- * A representation of a resource record of type <b>RP</b>
- *
- * @package Net_DNS
- */
-class Net_DNS_RR_RP extends Net_DNS_RR
-{
-    /* class variable definitions {{{ */
-    var $name;
-    var $type;
-    var $class;
-    var $ttl;
-    var $rdlength;
-    var $rdata;
-    var $mboxdname;
-    var $txtdname;
-
-    /* }}} */
-    /* class constructor - RR(&$rro, $data, $offset = '') {{{ */
-    function Net_DNS_RR_RP(&$rro, $data, $offset = '')
-    {
-        $this->name = $rro->name;
-        $this->type = $rro->type;
-        $this->class = $rro->class;
-        $this->ttl = $rro->ttl;
-        $this->rdlength = $rro->rdlength;
-        $this->rdata = $rro->rdata;
-
-        if ($offset) {
-            if ($this->rdlength > 0) {
-                $packet = new Net_DNS_Packet();
-
-                list($this->mboxdname, $offset) = $packet->dn_expand($data, $offset);
-                list($this->txtdname, $offset) = $packet->dn_expand($data, $offset);
-            }
-        } elseif (is_array($data)) {
-
-            $this->mboxdname = $data['mboxdname'];
-            $this->txtdname = $data['txtdname'];
-        } else {
-
-            preg_match("/([^ ]+)\s+([^ ]+)/", $data, $matches);
-
-            $this->mboxdname = preg_replace('/\.$/', '', $matches[1]);
-            $this->txtdname = preg_replace('/\.$/', '', $matches[2]);
-        }
-    }
-
-    /* }}} */
-    /* Net_DNS_RR_RP::rdatastr() {{{ */
-    function rdatastr()
-    {
-        if (strlen($this->mboxdname) > 0) {
-            return $this->mboxdname . '. ' . $this->txtdname . '.';
-        }
-        return '; no data';
-    }
-
-    /* }}} */
-    /* Net_DNS_RR_RP::rr_rdata($packet, $offset) {{{ */
-    function rr_rdata($packet, $offset)
-    {
-        if (strlen($this->mboxdname) > 0) {
-
-            $rdata = $packet->dn_comp($this->mboxdname, $offset);
-            $rdata .= $packet->dn_comp($this->txtdname, $offset + strlen($rdata));
-
-            return $rdata;
-        }
-        return null;
-    }
-
-    /* }}} */
-}
-/* }}} */
-/* VIM settings {{{
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * soft-stop-width: 4
- * c indent on
- * End:
- * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et
- * vim<600: sw=4 ts=4
- * }}} */
-?>
+<?php\r
+/**\r
+*  License Information:\r
+*\r
+*  Net_DNS:  A resolver library for PHP\r
+*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net\r
+*  Maintainers:\r
+*  Marco Kaiser <bate@php.net>\r
+*  Florian Anderiasch <fa@php.net>\r
+*  Mike Pultz <mike@mrhost.ca>\r
+*\r
+* PHP versions 4 and 5\r
+*\r
+* LICENSE: This source file is subject to version 3.01 of the PHP license\r
+* that is available through the world-wide-web at the following URI:\r
+* http://www.php.net/license/3_01.txt.  If you did not receive a copy of\r
+* the PHP License and are unable to obtain it through the web, please\r
+* send a note to license@php.net so we can mail you a copy immediately.\r
+*/\r
+\r
+/* Net_DNS_RR_RP definition {{{ */\r
+/**\r
+ * A representation of a resource record of type <b>RP</b>\r
+ *\r
+ * @package Net_DNS\r
+ */\r
+class Net_DNS_RR_RP extends Net_DNS_RR\r
+{\r
+    /* class variable definitions {{{ */\r
+    var $name;\r
+    var $type;\r
+    var $class;\r
+    var $ttl;\r
+    var $rdlength;\r
+    var $rdata;\r
+    var $mboxdname;\r
+    var $txtdname;\r
+\r
+    /* }}} */\r
+    /* class constructor - RR(&$rro, $data, $offset = '') {{{ */\r
+    function Net_DNS_RR_RP(&$rro, $data, $offset = '')\r
+    {\r
+        $this->name = $rro->name;\r
+        $this->type = $rro->type;\r
+        $this->class = $rro->class;\r
+        $this->ttl = $rro->ttl;\r
+        $this->rdlength = $rro->rdlength;\r
+        $this->rdata = $rro->rdata;\r
+\r
+        if ($offset) {\r
+            if ($this->rdlength > 0) {\r
+                $packet = new Net_DNS_Packet();\r
+\r
+                list($this->mboxdname, $offset) = $packet->dn_expand($data, $offset);\r
+                list($this->txtdname, $offset) = $packet->dn_expand($data, $offset);\r
+            }\r
+        } elseif (is_array($data)) {\r
+\r
+            $this->mboxdname = $data['mboxdname'];\r
+            $this->txtdname = $data['txtdname'];\r
+        } else {\r
+\r
+            preg_match("/([^ ]+)\s+([^ ]+)/", $data, $matches);\r
+\r
+            $this->mboxdname = preg_replace('/\.$/', '', $matches[1]);\r
+            $this->txtdname = preg_replace('/\.$/', '', $matches[2]);\r
+        }\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_RR_RP::rdatastr() {{{ */\r
+    function rdatastr()\r
+    {\r
+        if (strlen($this->mboxdname) > 0) {\r
+            return $this->mboxdname . '. ' . $this->txtdname . '.';\r
+        }\r
+        return '; no data';\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_RR_RP::rr_rdata($packet, $offset) {{{ */\r
+    function rr_rdata($packet, $offset)\r
+    {\r
+        if (strlen($this->mboxdname) > 0) {\r
+\r
+            $rdata = $packet->dn_comp($this->mboxdname, $offset);\r
+            $rdata .= $packet->dn_comp($this->txtdname, $offset + strlen($rdata));\r
+\r
+            return $rdata;\r
+        }\r
+        return null;\r
+    }\r
+\r
+    /* }}} */\r
+}\r
+/* }}} */\r
+/* VIM settings {{{\r
+ * Local variables:\r
+ * tab-width: 4\r
+ * c-basic-offset: 4\r
+ * soft-stop-width: 4\r
+ * c indent on\r
+ * End:\r
+ * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et\r
+ * vim<600: sw=4 ts=4\r
+ * }}} */\r
+?>\r
index f2ef30d..7668cf5 100755 (executable)
-<?php
-/**
-*  License Information:
-*
-*  Net_DNS:  A resolver library for PHP
-*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
-*  Maintainers:
-*  Marco Kaiser <bate@php.net>
-*  Florian Anderiasch <fa@php.net>
-*
-* PHP versions 4 and 5
-*
-* LICENSE: This source file is subject to version 3.01 of the PHP license
-* that is available through the world-wide-web at the following URI:
-* http://www.php.net/license/3_01.txt.  If you did not receive a copy of
-* the PHP License and are unable to obtain it through the web, please
-* send a note to license@php.net so we can mail you a copy immediately.
-*/
-
-/* Net_DNS_RR_SOA definition {{{ */
-/**
- * A representation of a resource record of type <b>SOA</b>
- *
- * @package Net_DNS
- */
-class Net_DNS_RR_SOA extends Net_DNS_RR
-{
-    /* class variable definitions {{{ */
-    var $name;
-    var $type;
-    var $class;
-    var $ttl;
-    var $rdlength;
-    var $rdata;
-    var $mname;
-    var $rname;
-    var $serial;
-    var $refresh;
-    var $retry;
-    var $expire;
-    var $minimum;
-
-    /* }}} */
-    /* class constructor - RR(&$rro, $data, $offset = '') {{{ */
-    function Net_DNS_RR_SOA(&$rro, $data, $offset = '')
-    {
-        $this->name = $rro->name;
-        $this->type = $rro->type;
-        $this->class = $rro->class;
-        $this->ttl = $rro->ttl;
-        $this->rdlength = $rro->rdlength;
-        $this->rdata = $rro->rdata;
-
-        if ($offset) {
-            if ($this->rdlength > 0) {
-                $packet = new Net_DNS_Packet();
-
-                list($mname, $offset) = $packet->dn_expand($data, $offset);
-                list($rname, $offset) = $packet->dn_expand($data, $offset);
-
-                $a = unpack("@$offset/N5soavals", $data);
-                $this->mname = $mname;
-                $this->rname = $rname;
-                $this->serial = $a['soavals1'];
-                $this->refresh = $a['soavals2'];
-                $this->retry = $a['soavals3'];
-                $this->expire = $a['soavals4'];
-                $this->minimum = $a['soavals5'];
-            }
-        } elseif (is_array($data)) {
-            $this->mname = $data['mname'];
-            $this->rname = $data['rname'];
-            $this->serial = $data['serial'];
-            $this->refresh = $data['refresh'];
-            $this->retry = $data['retry'];
-            $this->expire = $data['expire'];
-            $this->minimum = $data['minimum'];
-        } else {
-            if (preg_match("/([^ \t]+)[ \t]+([^ \t]+)[ \t]+([0-9]+)[ \t]+([0-9]+)[ \t]+([0-9]+)[ \t]+([0-9]+)[ \t]+([0-9]+)[ \t]*$/", $data, $regs))
-            {
-                $this->mname = preg_replace('/(.*)\.$/', '\\1', $regs[1]);
-                $this->rname = preg_replace('/(.*)\.$/', '\\1', $regs[2]);
-                $this->serial = $regs[3];
-                $this->refresh = $regs[4];
-                $this->retry = $regs[5];
-                $this->expire = $regs[6];
-                $this->minimum = $regs[7];
-            }
-        }
-    }
-
-    /* }}} */
-    /* Net_DNS_RR_SOA::rdatastr($pretty = 0) {{{ */
-    function rdatastr($pretty = 0)
-    {
-        if (strlen($this->mname)) {
-            if ($pretty) {
-                $rdatastr  = $this->mname . '. ' . $this->rname . ". (\n";
-                $rdatastr .= "\t\t\t\t\t" . $this->serial . "\t; Serial\n";
-                $rdatastr .= "\t\t\t\t\t" . $this->refresh . "\t; Refresh\n";
-                $rdatastr .= "\t\t\t\t\t" . $this->retry . "\t; Retry\n";
-                $rdatastr .= "\t\t\t\t\t" . $this->expire . "\t; Expire\n";
-                $rdatastr .= "\t\t\t\t\t" . $this->minimum . " )\t; Minimum TTL";
-            } else {
-                $rdatastr  = $this->mname . '. ' . $this->rname . '. ' .
-                    $this->serial . ' ' .  $this->refresh . ' ' .  $this->retry . ' ' .
-                    $this->expire . ' ' .  $this->minimum;
-            }
-            return $rdatastr;
-        }
-        return '; no data';
-    }
-
-    /* }}} */
-    /* Net_DNS_RR_SOA::rr_rdata($packet, $offset) {{{ */
-    function rr_rdata($packet, $offset)
-    {
-        if (strlen($this->mname)) {
-            $rdata = $packet->dn_comp($this->mname, $offset);
-            $rdata .= $packet->dn_comp($this->rname, $offset + strlen($rdata));
-            $rdata .= pack('N5', $this->serial,
-                    $this->refresh,
-                    $this->retry,
-                    $this->expire,
-                    $this->minimum);
-            return $rdata;
-        }
-        return null;
-    }
-
-    /* }}} */
-}
-/* }}} */
-/* VIM settings {{{
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * soft-stop-width: 4
- * c indent on
- * End:
- * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et
- * vim<600: sw=4 ts=4
- * }}} */
-?>
+<?php\r
+/**\r
+*  License Information:\r
+*\r
+*  Net_DNS:  A resolver library for PHP\r
+*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net\r
+*  Maintainers:\r
+*  Marco Kaiser <bate@php.net>\r
+*  Florian Anderiasch <fa@php.net>\r
+*\r
+* PHP versions 4 and 5\r
+*\r
+* LICENSE: This source file is subject to version 3.01 of the PHP license\r
+* that is available through the world-wide-web at the following URI:\r
+* http://www.php.net/license/3_01.txt.  If you did not receive a copy of\r
+* the PHP License and are unable to obtain it through the web, please\r
+* send a note to license@php.net so we can mail you a copy immediately.\r
+*/\r
+\r
+/* Net_DNS_RR_SOA definition {{{ */\r
+/**\r
+ * A representation of a resource record of type <b>SOA</b>\r
+ *\r
+ * @package Net_DNS\r
+ */\r
+class Net_DNS_RR_SOA extends Net_DNS_RR\r
+{\r
+    /* class variable definitions {{{ */\r
+    var $name;\r
+    var $type;\r
+    var $class;\r
+    var $ttl;\r
+    var $rdlength;\r
+    var $rdata;\r
+    var $mname;\r
+    var $rname;\r
+    var $serial;\r
+    var $refresh;\r
+    var $retry;\r
+    var $expire;\r
+    var $minimum;\r
+\r
+    /* }}} */\r
+    /* class constructor - RR(&$rro, $data, $offset = '') {{{ */\r
+    function Net_DNS_RR_SOA(&$rro, $data, $offset = '')\r
+    {\r
+        $this->name = $rro->name;\r
+        $this->type = $rro->type;\r
+        $this->class = $rro->class;\r
+        $this->ttl = $rro->ttl;\r
+        $this->rdlength = $rro->rdlength;\r
+        $this->rdata = $rro->rdata;\r
+\r
+        if ($offset) {\r
+            if ($this->rdlength > 0) {\r
+                $packet = new Net_DNS_Packet();\r
+\r
+                list($mname, $offset) = $packet->dn_expand($data, $offset);\r
+                list($rname, $offset) = $packet->dn_expand($data, $offset);\r
+\r
+                $a = unpack("@$offset/N5soavals", $data);\r
+                $this->mname = $mname;\r
+                $this->rname = $rname;\r
+                $this->serial = $a['soavals1'];\r
+                $this->refresh = $a['soavals2'];\r
+                $this->retry = $a['soavals3'];\r
+                $this->expire = $a['soavals4'];\r
+                $this->minimum = $a['soavals5'];\r
+            }\r
+        } elseif (is_array($data)) {\r
+            $this->mname = $data['mname'];\r
+            $this->rname = $data['rname'];\r
+            $this->serial = $data['serial'];\r
+            $this->refresh = $data['refresh'];\r
+            $this->retry = $data['retry'];\r
+            $this->expire = $data['expire'];\r
+            $this->minimum = $data['minimum'];\r
+        } else {\r
+            if (preg_match("/([^ \t]+)[ \t]+([^ \t]+)[ \t]+([0-9]+)[ \t]+([0-9]+)[ \t]+([0-9]+)[ \t]+([0-9]+)[ \t]+([0-9]+)[ \t]*$/", $data, $regs))\r
+            {\r
+                $this->mname = preg_replace('/(.*)\.$/', '\\1', $regs[1]);\r
+                $this->rname = preg_replace('/(.*)\.$/', '\\1', $regs[2]);\r
+                $this->serial = $regs[3];\r
+                $this->refresh = $regs[4];\r
+                $this->retry = $regs[5];\r
+                $this->expire = $regs[6];\r
+                $this->minimum = $regs[7];\r
+            }\r
+        }\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_RR_SOA::rdatastr($pretty = 0) {{{ */\r
+    function rdatastr($pretty = 0)\r
+    {\r
+        if (strlen($this->mname)) {\r
+            if ($pretty) {\r
+                $rdatastr  = $this->mname . '. ' . $this->rname . ". (\n";\r
+                $rdatastr .= "\t\t\t\t\t" . $this->serial . "\t; Serial\n";\r
+                $rdatastr .= "\t\t\t\t\t" . $this->refresh . "\t; Refresh\n";\r
+                $rdatastr .= "\t\t\t\t\t" . $this->retry . "\t; Retry\n";\r
+                $rdatastr .= "\t\t\t\t\t" . $this->expire . "\t; Expire\n";\r
+                $rdatastr .= "\t\t\t\t\t" . $this->minimum . " )\t; Minimum TTL";\r
+            } else {\r
+                $rdatastr  = $this->mname . '. ' . $this->rname . '. ' .\r
+                    $this->serial . ' ' .  $this->refresh . ' ' .  $this->retry . ' ' .\r
+                    $this->expire . ' ' .  $this->minimum;\r
+            }\r
+            return $rdatastr;\r
+        }\r
+        return '; no data';\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_RR_SOA::rr_rdata($packet, $offset) {{{ */\r
+    function rr_rdata($packet, $offset)\r
+    {\r
+        if (strlen($this->mname)) {\r
+            $rdata = $packet->dn_comp($this->mname, $offset);\r
+            $rdata .= $packet->dn_comp($this->rname, $offset + strlen($rdata));\r
+            $rdata .= pack('N5', $this->serial,\r
+                    $this->refresh,\r
+                    $this->retry,\r
+                    $this->expire,\r
+                    $this->minimum);\r
+            return $rdata;\r
+        }\r
+        return null;\r
+    }\r
+\r
+    /* }}} */\r
+}\r
+/* }}} */\r
+/* VIM settings {{{\r
+ * Local variables:\r
+ * tab-width: 4\r
+ * c-basic-offset: 4\r
+ * soft-stop-width: 4\r
+ * c indent on\r
+ * End:\r
+ * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et\r
+ * vim<600: sw=4 ts=4\r
+ * }}} */\r
+?>\r
index a675ef9..9a8ec00 100755 (executable)
@@ -1,47 +1,47 @@
-<?php
-/**
-*  License Information:
-*
-*  Net_DNS:  A resolver library for PHP
-*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
-*  Maintainers:
-*  Marco Kaiser <bate@php.net>
-*  Florian Anderiasch <fa@php.net>
-*  Mike Pultz <mike@mrhost.ca>
-*
-* PHP versions 4 and 5
-*
-* LICENSE: This source file is subject to version 3.01 of the PHP license
-* that is available through the world-wide-web at the following URI:
-* http://www.php.net/license/3_01.txt.  If you did not receive a copy of
-* the PHP License and are unable to obtain it through the web, please
-* send a note to license@php.net so we can mail you a copy immediately.
-*/
-
-/* Net_DNS_RR_SPF definition {{{ */
-/**
- * A representation of a resource record of type <b>SPF</b>
- *
- * @package Net_DNS
- */
-class Net_DNS_RR_SPF extends Net_DNS_RR_TXT
-{
-
-    //
-    // There's no work to be done here, since the SPF RR is identical to the TXT RR- we
-    // just extend the Net_DNS_RR_TXT record class and inherit everything.
-    //
-
-}
-/* }}} */
-/* VIM settings {{{
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * soft-stop-width: 4
- * c indent on
- * End:
- * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et
- * vim<600: sw=4 ts=4
- * }}} */
+<?php\r
+/**\r
+*  License Information:\r
+*\r
+*  Net_DNS:  A resolver library for PHP\r
+*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net\r
+*  Maintainers:\r
+*  Marco Kaiser <bate@php.net>\r
+*  Florian Anderiasch <fa@php.net>\r
+*  Mike Pultz <mike@mrhost.ca>\r
+*\r
+* PHP versions 4 and 5\r
+*\r
+* LICENSE: This source file is subject to version 3.01 of the PHP license\r
+* that is available through the world-wide-web at the following URI:\r
+* http://www.php.net/license/3_01.txt.  If you did not receive a copy of\r
+* the PHP License and are unable to obtain it through the web, please\r
+* send a note to license@php.net so we can mail you a copy immediately.\r
+*/\r
+\r
+/* Net_DNS_RR_SPF definition {{{ */\r
+/**\r
+ * A representation of a resource record of type <b>SPF</b>\r
+ *\r
+ * @package Net_DNS\r
+ */\r
+class Net_DNS_RR_SPF extends Net_DNS_RR_TXT\r
+{\r
+\r
+    //\r
+    // There's no work to be done here, since the SPF RR is identical to the TXT RR- we\r
+    // just extend the Net_DNS_RR_TXT record class and inherit everything.\r
+    //\r
+\r
+}\r
+/* }}} */\r
+/* VIM settings {{{\r
+ * Local variables:\r
+ * tab-width: 4\r
+ * c-basic-offset: 4\r
+ * soft-stop-width: 4\r
+ * c indent on\r
+ * End:\r
+ * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et\r
+ * vim<600: sw=4 ts=4\r
+ * }}} */\r
 ?>
\ No newline at end of file
index 78d1d17..b29fb79 100755 (executable)
-<?php
-/**
-*  License Information:
-*
-*  Net_DNS:  A resolver library for PHP
-*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
-*  Maintainers:
-*  Marco Kaiser <bate@php.net>
-*  Florian Anderiasch <fa@php.net>
-*
-* PHP versions 4 and 5
-*
-* LICENSE: This source file is subject to version 3.01 of the PHP license
-* that is available through the world-wide-web at the following URI:
-* http://www.php.net/license/3_01.txt.  If you did not receive a copy of
-* the PHP License and are unable to obtain it through the web, please
-* send a note to license@php.net so we can mail you a copy immediately.
-*/
-
-/* Net_DNS_RR_SRV definition {{{ */
-/**
- * A representation of a resource record of type <b>SRV</b>
- *
- * @package Net_DNS
- */
-class Net_DNS_RR_SRV extends Net_DNS_RR
-{
-    /* class variable definitions {{{ */
-    var $name;
-    var $type;
-    var $class;
-    var $ttl;
-    var $rdlength;
-    var $rdata;
-    var $preference;
-    var $weight;
-    var $port;
-    var $target;
-
-    /* }}} */
-    /* class constructor - RR(&$rro, $data, $offset = '') {{{ */
-    function Net_DNS_RR_SRV(&$rro, $data, $offset = '')
-    {
-        $this->name = $rro->name;
-        $this->type = $rro->type;
-        $this->class = $rro->class;
-        $this->ttl = $rro->ttl;
-        $this->rdlength = $rro->rdlength;
-        $this->rdata = $rro->rdata;
-
-        if ($offset) {
-            if ($this->rdlength > 0) {
-                $a = unpack("@$offset/npreference/nweight/nport", $data);
-                $offset += 6;
-                $packet = new Net_DNS_Packet();
-
-                list($target, $offset) = $packet->dn_expand($data, $offset);
-                $this->preference = $a['preference'];
-                $this->weight = $a['weight'];
-                $this->port = $a['port'];
-                $this->target = $target;
-            }
-        } elseif (is_array($data)) {
-            $this->preference = $data['preference'];
-            $this->weight = $data['weight'];
-            $this->port = $data['port'];
-            $this->target = $data['target'];
-        } else {
-            preg_match("/([0-9]+)[ \t]+([0-9]+)[ \t]+([0-9]+)[ \t]+(.+)[ \t]*$/", $data, $regs);
-            $this->preference = $regs[1];
-            $this->weight = $regs[2];
-            $this->port = $regs[3];
-            $this->target = preg_replace('/(.*)\.$/', '\\1', $regs[4]);
-        }
-    }
-
-    /* }}} */
-    /* Net_DNS_RR_SRV::rdatastr() {{{ */
-    function rdatastr()
-    {
-        if ($this->port) {
-            return intval($this->preference) . ' ' . intval($this->weight) . ' ' . intval($this->port) . ' ' . $this->target . '.';
-        }
-        return '; no data';
-    }
-
-    /* }}} */
-    /* Net_DNS_RR_SRV::rr_rdata($packet, $offset) {{{ */
-    function rr_rdata($packet, $offset)
-    {
-        if (isset($this->preference)) {
-            $rdata = pack('nnn', $this->preference, $this->weight, $this->port);
-            $rdata .= $packet->dn_comp($this->target, $offset + strlen($rdata));
-            return $rdata;
-        }
-        return null;
-    }
-
-    /* }}} */
-}
-/* }}} */
-/* VIM settings {{{
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * soft-stop-width: 4
- * c indent on
- * End:
- * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et
- * vim<600: sw=4 ts=4
- * }}} */
-?>
+<?php\r
+/**\r
+*  License Information:\r
+*\r
+*  Net_DNS:  A resolver library for PHP\r
+*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net\r
+*  Maintainers:\r
+*  Marco Kaiser <bate@php.net>\r
+*  Florian Anderiasch <fa@php.net>\r
+*\r
+* PHP versions 4 and 5\r
+*\r
+* LICENSE: This source file is subject to version 3.01 of the PHP license\r
+* that is available through the world-wide-web at the following URI:\r
+* http://www.php.net/license/3_01.txt.  If you did not receive a copy of\r
+* the PHP License and are unable to obtain it through the web, please\r
+* send a note to license@php.net so we can mail you a copy immediately.\r
+*/\r
+\r
+/* Net_DNS_RR_SRV definition {{{ */\r
+/**\r
+ * A representation of a resource record of type <b>SRV</b>\r
+ *\r
+ * @package Net_DNS\r
+ */\r
+class Net_DNS_RR_SRV extends Net_DNS_RR\r
+{\r
+    /* class variable definitions {{{ */\r
+    var $name;\r
+    var $type;\r
+    var $class;\r
+    var $ttl;\r
+    var $rdlength;\r
+    var $rdata;\r
+    var $preference;\r
+    var $weight;\r
+    var $port;\r
+    var $target;\r
+\r
+    /* }}} */\r
+    /* class constructor - RR(&$rro, $data, $offset = '') {{{ */\r
+    function Net_DNS_RR_SRV(&$rro, $data, $offset = '')\r
+    {\r
+        $this->name = $rro->name;\r
+        $this->type = $rro->type;\r
+        $this->class = $rro->class;\r
+        $this->ttl = $rro->ttl;\r
+        $this->rdlength = $rro->rdlength;\r
+        $this->rdata = $rro->rdata;\r
+\r
+        if ($offset) {\r
+            if ($this->rdlength > 0) {\r
+                $a = unpack("@$offset/npreference/nweight/nport", $data);\r
+                $offset += 6;\r
+                $packet = new Net_DNS_Packet();\r
+\r
+                list($target, $offset) = $packet->dn_expand($data, $offset);\r
+                $this->preference = $a['preference'];\r
+                $this->weight = $a['weight'];\r
+                $this->port = $a['port'];\r
+                $this->target = $target;\r
+            }\r
+        } elseif (is_array($data)) {\r
+            $this->preference = $data['preference'];\r
+            $this->weight = $data['weight'];\r
+            $this->port = $data['port'];\r
+            $this->target = $data['target'];\r
+        } else {\r
+            preg_match("/([0-9]+)[ \t]+([0-9]+)[ \t]+([0-9]+)[ \t]+(.+)[ \t]*$/", $data, $regs);\r
+            $this->preference = $regs[1];\r
+            $this->weight = $regs[2];\r
+            $this->port = $regs[3];\r
+            $this->target = preg_replace('/(.*)\.$/', '\\1', $regs[4]);\r
+        }\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_RR_SRV::rdatastr() {{{ */\r
+    function rdatastr()\r
+    {\r
+        if ($this->port) {\r
+            return intval($this->preference) . ' ' . intval($this->weight) . ' ' . intval($this->port) . ' ' . $this->target . '.';\r
+        }\r
+        return '; no data';\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_RR_SRV::rr_rdata($packet, $offset) {{{ */\r
+    function rr_rdata($packet, $offset)\r
+    {\r
+        if (isset($this->preference)) {\r
+            $rdata = pack('nnn', $this->preference, $this->weight, $this->port);\r
+            $rdata .= $packet->dn_comp($this->target, $offset + strlen($rdata));\r
+            return $rdata;\r
+        }\r
+        return null;\r
+    }\r
+\r
+    /* }}} */\r
+}\r
+/* }}} */\r
+/* VIM settings {{{\r
+ * Local variables:\r
+ * tab-width: 4\r
+ * c-basic-offset: 4\r
+ * soft-stop-width: 4\r
+ * c indent on\r
+ * End:\r
+ * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et\r
+ * vim<600: sw=4 ts=4\r
+ * }}} */\r
+?>\r
index f08d1d1..258d0be 100755 (executable)
-<?php
-/**
-*  License Information:
-*
-*  Net_DNS:  A resolver library for PHP
-*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
-*  Maintainers:
-*  Marco Kaiser <bate@php.net>
-*  Florian Anderiasch <fa@php.net>
-*
-* PHP versions 4 and 5
-*
-* LICENSE: This source file is subject to version 3.01 of the PHP license
-* that is available through the world-wide-web at the following URI:
-* http://www.php.net/license/3_01.txt.  If you did not receive a copy of
-* the PHP License and are unable to obtain it through the web, please
-* send a note to license@php.net so we can mail you a copy immediately.
-*/
-
-define('NET_DNS_DEFAULT_ALGORITHM', 'hmac-md5.sig-alg.reg.int');
-define('NET_DNS_DEFAULT_FUDGE', 300);
-
-/* Net_DNS_RR_TSIG definition {{{ */
-/**
- * A representation of a resource record of type <b>TSIG</b>
- *
- * @package Net_DNS
- */
-class Net_DNS_RR_TSIG extends Net_DNS_RR
-{
-    /* class variable definitions {{{ */
-    var $name;
-    var $type;
-    var $class;
-    var $ttl;
-    var $rdlength;
-    var $rdata;
-    var $time_signed;
-    var $fudge;
-    var $mac_size;
-    var $mac;
-    var $original_id;
-    var $error;
-    var $other_len;
-    var $other_data;
-    var $key;
-
-    /* }}} */
-    /* class constructor - RR(&$rro, $data, $offset = '') {{{ */
-    function Net_DNS_RR_TSIG(&$rro, $data, $offset = '')
-    {
-        $this->name = $rro->name;
-        $this->type = $rro->type;
-        $this->class = $rro->class;
-        $this->ttl = $rro->ttl;
-        $this->rdlength = $rro->rdlength;
-        $this->rdata = $rro->rdata;
-
-        if ($offset) {
-            if ($this->rdlength > 0) {
-                $packet = new Net_DNS_Packet();
-
-                list($alg, $offset) = $packet->dn_expand($data, $offset);
-                $this->algorithm = $alg;
-
-                $d = unpack("@$offset/nth/Ntl/nfudge/nmac_size", $data);
-                $time_high = $d['th'];
-                $time_low = $d['tl'];
-                $this->time_signed = $time_low;
-                $this->fudge = $d['fudge'];
-                $this->mac_size = $d['mac_size'];
-                $offset += 10;
-
-                $this->mac = substr($data, $offset, $this->mac_size);
-                $offset += $this->mac_size;
-
-                $d = unpack("@$offset/noid/nerror/nolen", $data);
-                $this->original_id = $d['oid'];
-                $this->error = $d['error'];
-                $this->other_len = $d['olen'];
-                $offset += 6;
-
-                if ($this->other_len) {
-                    $odata = substr($data, $offset, $this->other_len);
-                    $d = unpack('nodata_high/Nodata_low', $odata);
-                    $this->other_data = $d['odata_low'];
-                }
-            }
-        } elseif (is_array($data)) {
-            $this->key = $data['key'];
-            $this->algorithm = $data['algorithm'];
-            $this->time_signed = $data['time_signed'];
-            $this->fudge = $data['fudge'];
-            $this->mac = $data['mac'];
-            $this->original_id = $data['original_id'];
-            $this->error = $data['error'];
-            $this->other_len = $data['other_len'];
-            $this->other_data = $data['other_data'];
-        } else {
-            if (strlen($data) && preg_match('/^(.*)$/', $data, $regs)) {
-                $this->key = $regs[1];
-            }
-
-            $this->algorithm   = NET_DNS_DEFAULT_ALGORITHM;
-            $this->time_signed = time();
-
-            $this->fudge       = NET_DNS_DEFAULT_FUDGE;
-            $this->mac_size    = 0;
-            $this->mac         = '';
-            $this->original_id = 0;
-            $this->error       = 0;
-            $this->other_len   = 0;
-            $this->other_data  = '';
-
-            // RFC 2845 Section 2.3
-            $this->class = 'ANY';
-        }
-    }
-
-    /* }}} */
-    /* Net_DNS_RR_TSIG::rdatastr() {{{ */
-    function rdatastr()
-    {
-        $error = $this->error;
-        if (! $error) {
-            $error = 'UNDEFINED';
-        }
-
-        if (strlen($this->algorithm)) {
-            $rdatastr = $this->algorithm . '. ' . $this->time_signed . ' ' .
-                $this->fudge . ' ';
-            if ($this->mac_size && strlen($this->mac)) {
-                $rdatastr .= ' ' . $this->mac_size . ' ' . base64_encode($this->mac);
-            } else {
-                $rdatastr .= ' 0 ';
-            }
-            $rdatastr .= ' ' . $this->original_id . ' ' . $error;
-            if ($this->other_len && strlen($this->other_data)) {
-                $rdatastr .= ' ' . $this->other_data;
-            } else {
-                $rdatastr .= ' 0 ';
-            }
-        } else {
-            $rdatastr = '; no data';
-        }
-
-        return $rdatastr;
-    }
-
-    /* }}} */
-    /* Net_DNS_RR_TSIG::rr_rdata($packet, $offset) {{{ */
-    function rr_rdata($packet, $offset)
-    {
-        $rdata = '';
-        $sigdata = '';
-
-        if (strlen($this->key)) {
-            $key = $this->key;
-            $key = preg_replace('/ /', '', $key);
-            $key = base64_decode($key);
-
-            $newpacket = $packet;
-            $newoffset = $offset;
-            array_pop($newpacket->additional);
-            $newpacket->header->arcount--;
-            $newpacket->compnames = array();
-
-            /*
-             * Add the request MAC if present (used to validate responses).
-             */
-            if (isset($this->request_mac)) {
-                $sigdata .= pack('H*', $this->request_mac);
-            }
-            $sigdata .= $newpacket->data();
-
-            /*
-             * Don't compress the record (key) name.
-             */
-            $tmppacket = new Net_DNS_Packet;
-            $sigdata .= $tmppacket->dn_comp(strtolower($this->name), 0);
-
-            $sigdata .= pack('n', Net_DNS::classesbyname(strtoupper($this->class)));
-            $sigdata .= pack('N', $this->ttl);
-
-            /*
-             * Don't compress the algorithm name.
-             */
-            $tmppacket->compnames = array();
-            $sigdata .= $tmppacket->dn_comp(strtolower($this->algorithm), 0);
-
-            $sigdata .= pack('nN', 0, $this->time_signed);
-            $sigdata .= pack('n', $this->fudge);
-            $sigdata .= pack('nn', $this->error, $this->other_len);
-
-            if (strlen($this->other_data)) {
-                $sigdata .= pack('nN', 0, $this->other_data);
-            }
-
-            $this->mac = $this->hmac_md5($sigdata, $key);
-            $this->mac_size = strlen($this->mac);
-
-            /*
-             * Don't compress the algorithm name.
-             */
-            unset($tmppacket);
-            $tmppacket = new Net_DNS_Packet;
-            $rdata .= $tmppacket->dn_comp(strtolower($this->algorithm), 0);
-
-            $rdata .= pack('nN', 0, $this->time_signed);
-            $rdata .= pack('nn', $this->fudge, $this->mac_size);
-            $rdata .= $this->mac;
-
-            $rdata .= pack('nnn',$packet->header->id,
-                    $this->error,
-                    $this->other_len);
-
-            if ($this->other_data) {
-                $rdata .= pack('nN', 0, $this->other_data);
-            }
-        }
-        return $rdata;
-    }
-    /* }}} */
-    /* Net_DNS_RR_TSIG::error() {{{ */
-    function error()
-    {
-        if ($this->error != 0) {
-            $rcode = Net_DNS::rcodesbyval($error);
-        }
-        return $rcode;
-    }
-    /* }}} */
-
-    /* Net_DNS_RR_TSIG::hmac() {{{ */
-    // Calculate HMAC according to RFC2104
-    // http://www.ietf.org/rfc/rfc2104.txt
-    // posted by mina86 at tlen dot pl on http://php.net/manual/en/function.md5.php
-    /**
-     * @deprecated
-     */
-    function hmac($data, $key, $hash = 'md5', $blocksize = 64) {
-        if ($hash === 'md5') {
-            return $this->hmac_md5($data, $key);
-        }
-
-        return false;
-    }
-
-    /* Net_DNS_RR_TSIG::hmac_md5() {{{ */
-    // Calculate HMAC according to RFC2104
-    // http://www.ietf.org/rfc/rfc2104.txt
-    function hmac_md5($data, $key) {
-        if (strlen($key)>64) {
-            $key = md5($key, true);
-        }
-        $key  = str_pad($key, 64, chr(0));
-        $ipad = str_repeat(chr(0x36), 64);
-        $opad = str_repeat(chr(0x5c), 64);
-        return md5(($key^$opad) . md5(($key^$ipad) . $data, true), true);
-    }
-    /* }}} */
-}
-/* }}} */
-/* VIM settings {{{
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * soft-stop-width: 4
- * c indent on
- * expandtab on
- * End:
- * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et
- * vim<600: sw=4 ts=4
- * }}} */
-?>
+<?php\r
+/**\r
+*  License Information:\r
+*\r
+*  Net_DNS:  A resolver library for PHP\r
+*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net\r
+*  Maintainers:\r
+*  Marco Kaiser <bate@php.net>\r
+*  Florian Anderiasch <fa@php.net>\r
+*\r
+* PHP versions 4 and 5\r
+*\r
+* LICENSE: This source file is subject to version 3.01 of the PHP license\r
+* that is available through the world-wide-web at the following URI:\r
+* http://www.php.net/license/3_01.txt.  If you did not receive a copy of\r
+* the PHP License and are unable to obtain it through the web, please\r
+* send a note to license@php.net so we can mail you a copy immediately.\r
+*/\r
+\r
+define('NET_DNS_DEFAULT_ALGORITHM', 'hmac-md5.sig-alg.reg.int');\r
+define('NET_DNS_DEFAULT_FUDGE', 300);\r
+\r
+/* Net_DNS_RR_TSIG definition {{{ */\r
+/**\r
+ * A representation of a resource record of type <b>TSIG</b>\r
+ *\r
+ * @package Net_DNS\r
+ */\r
+class Net_DNS_RR_TSIG extends Net_DNS_RR\r
+{\r
+    /* class variable definitions {{{ */\r
+    var $name;\r
+    var $type;\r
+    var $class;\r
+    var $ttl;\r
+    var $rdlength;\r
+    var $rdata;\r
+    var $time_signed;\r
+    var $fudge;\r
+    var $mac_size;\r
+    var $mac;\r
+    var $original_id;\r
+    var $error;\r
+    var $other_len;\r
+    var $other_data;\r
+    var $key;\r
+\r
+    /* }}} */\r
+    /* class constructor - RR(&$rro, $data, $offset = '') {{{ */\r
+    function Net_DNS_RR_TSIG(&$rro, $data, $offset = '')\r
+    {\r
+        $this->name = $rro->name;\r
+        $this->type = $rro->type;\r
+        $this->class = $rro->class;\r
+        $this->ttl = $rro->ttl;\r
+        $this->rdlength = $rro->rdlength;\r
+        $this->rdata = $rro->rdata;\r
+\r
+        if ($offset) {\r
+            if ($this->rdlength > 0) {\r
+                $packet = new Net_DNS_Packet();\r
+\r
+                list($alg, $offset) = $packet->dn_expand($data, $offset);\r
+                $this->algorithm = $alg;\r
+\r
+                $d = unpack("@$offset/nth/Ntl/nfudge/nmac_size", $data);\r
+                $time_high = $d['th'];\r
+                $time_low = $d['tl'];\r
+                $this->time_signed = $time_low;\r
+                $this->fudge = $d['fudge'];\r
+                $this->mac_size = $d['mac_size'];\r
+                $offset += 10;\r
+\r
+                $this->mac = substr($data, $offset, $this->mac_size);\r
+                $offset += $this->mac_size;\r
+\r
+                $d = unpack("@$offset/noid/nerror/nolen", $data);\r
+                $this->original_id = $d['oid'];\r
+                $this->error = $d['error'];\r
+                $this->other_len = $d['olen'];\r
+                $offset += 6;\r
+\r
+                if ($this->other_len) {\r
+                    $odata = substr($data, $offset, $this->other_len);\r
+                    $d = unpack('nodata_high/Nodata_low', $odata);\r
+                    $this->other_data = $d['odata_low'];\r
+                }\r
+            }\r
+        } elseif (is_array($data)) {\r
+            $this->key = $data['key'];\r
+            $this->algorithm = $data['algorithm'];\r
+            $this->time_signed = $data['time_signed'];\r
+            $this->fudge = $data['fudge'];\r
+            $this->mac = $data['mac'];\r
+            $this->original_id = $data['original_id'];\r
+            $this->error = $data['error'];\r
+            $this->other_len = $data['other_len'];\r
+            $this->other_data = $data['other_data'];\r
+        } else {\r
+            if (strlen($data) && preg_match('/^(.*)$/', $data, $regs)) {\r
+                $this->key = $regs[1];\r
+            }\r
+\r
+            $this->algorithm   = NET_DNS_DEFAULT_ALGORITHM;\r
+            $this->time_signed = time();\r
+\r
+            $this->fudge       = NET_DNS_DEFAULT_FUDGE;\r
+            $this->mac_size    = 0;\r
+            $this->mac         = '';\r
+            $this->original_id = 0;\r
+            $this->error       = 0;\r
+            $this->other_len   = 0;\r
+            $this->other_data  = '';\r
+\r
+            // RFC 2845 Section 2.3\r
+            $this->class = 'ANY';\r
+        }\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_RR_TSIG::rdatastr() {{{ */\r
+    function rdatastr()\r
+    {\r
+        $error = $this->error;\r
+        if (! $error) {\r
+            $error = 'UNDEFINED';\r
+        }\r
+\r
+        if (strlen($this->algorithm)) {\r
+            $rdatastr = $this->algorithm . '. ' . $this->time_signed . ' ' .\r
+                $this->fudge . ' ';\r
+            if ($this->mac_size && strlen($this->mac)) {\r
+                $rdatastr .= ' ' . $this->mac_size . ' ' . base64_encode($this->mac);\r
+            } else {\r
+                $rdatastr .= ' 0 ';\r
+            }\r
+            $rdatastr .= ' ' . $this->original_id . ' ' . $error;\r
+            if ($this->other_len && strlen($this->other_data)) {\r
+                $rdatastr .= ' ' . $this->other_data;\r
+            } else {\r
+                $rdatastr .= ' 0 ';\r
+            }\r
+        } else {\r
+            $rdatastr = '; no data';\r
+        }\r
+\r
+        return $rdatastr;\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_RR_TSIG::rr_rdata($packet, $offset) {{{ */\r
+    function rr_rdata($packet, $offset)\r
+    {\r
+        $rdata = '';\r
+        $sigdata = '';\r
+\r
+        if (strlen($this->key)) {\r
+            $key = $this->key;\r
+            $key = preg_replace('/ /', '', $key);\r
+            $key = base64_decode($key);\r
+\r
+            $newpacket = $packet;\r
+            $newoffset = $offset;\r
+            array_pop($newpacket->additional);\r
+            $newpacket->header->arcount--;\r
+            $newpacket->compnames = array();\r
+\r
+            /*\r
+             * Add the request MAC if present (used to validate responses).\r
+             */\r
+            if (isset($this->request_mac)) {\r
+                $sigdata .= pack('H*', $this->request_mac);\r
+            }\r
+            $sigdata .= $newpacket->data();\r
+\r
+            /*\r
+             * Don't compress the record (key) name.\r
+             */\r
+            $tmppacket = new Net_DNS_Packet;\r
+            $sigdata .= $tmppacket->dn_comp(strtolower($this->name), 0);\r
+\r
+            $sigdata .= pack('n', Net_DNS::classesbyname(strtoupper($this->class)));\r
+            $sigdata .= pack('N', $this->ttl);\r
+\r
+            /*\r
+             * Don't compress the algorithm name.\r
+             */\r
+            $tmppacket->compnames = array();\r
+            $sigdata .= $tmppacket->dn_comp(strtolower($this->algorithm), 0);\r
+\r
+            $sigdata .= pack('nN', 0, $this->time_signed);\r
+            $sigdata .= pack('n', $this->fudge);\r
+            $sigdata .= pack('nn', $this->error, $this->other_len);\r
+\r
+            if (strlen($this->other_data)) {\r
+                $sigdata .= pack('nN', 0, $this->other_data);\r
+            }\r
+\r
+            $this->mac = $this->hmac_md5($sigdata, $key);\r
+            $this->mac_size = strlen($this->mac);\r
+\r
+            /*\r
+             * Don't compress the algorithm name.\r
+             */\r
+            unset($tmppacket);\r
+            $tmppacket = new Net_DNS_Packet;\r
+            $rdata .= $tmppacket->dn_comp(strtolower($this->algorithm), 0);\r
+\r
+            $rdata .= pack('nN', 0, $this->time_signed);\r
+            $rdata .= pack('nn', $this->fudge, $this->mac_size);\r
+            $rdata .= $this->mac;\r
+\r
+            $rdata .= pack('nnn',$packet->header->id,\r
+                    $this->error,\r
+                    $this->other_len);\r
+\r
+            if ($this->other_data) {\r
+                $rdata .= pack('nN', 0, $this->other_data);\r
+            }\r
+        }\r
+        return $rdata;\r
+    }\r
+    /* }}} */\r
+    /* Net_DNS_RR_TSIG::error() {{{ */\r
+    function error()\r
+    {\r
+        if ($this->error != 0) {\r
+            $rcode = Net_DNS::rcodesbyval($error);\r
+        }\r
+        return $rcode;\r
+    }\r
+    /* }}} */\r
+\r
+    /* Net_DNS_RR_TSIG::hmac() {{{ */\r
+    // Calculate HMAC according to RFC2104\r
+    // http://www.ietf.org/rfc/rfc2104.txt\r
+    // posted by mina86 at tlen dot pl on http://php.net/manual/en/function.md5.php\r
+    /**\r
+     * @deprecated\r
+     */\r
+    function hmac($data, $key, $hash = 'md5', $blocksize = 64) {\r
+        if ($hash === 'md5') {\r
+            return $this->hmac_md5($data, $key);\r
+        }\r
+\r
+        return false;\r
+    }\r
+\r
+    /* Net_DNS_RR_TSIG::hmac_md5() {{{ */\r
+    // Calculate HMAC according to RFC2104\r
+    // http://www.ietf.org/rfc/rfc2104.txt\r
+    function hmac_md5($data, $key) {\r
+        if (strlen($key)>64) {\r
+            $key = md5($key, true);\r
+        }\r
+        $key  = str_pad($key, 64, chr(0));\r
+        $ipad = str_repeat(chr(0x36), 64);\r
+        $opad = str_repeat(chr(0x5c), 64);\r
+        return md5(($key^$opad) . md5(($key^$ipad) . $data, true), true);\r
+    }\r
+    /* }}} */\r
+}\r
+/* }}} */\r
+/* VIM settings {{{\r
+ * Local variables:\r
+ * tab-width: 4\r
+ * c-basic-offset: 4\r
+ * soft-stop-width: 4\r
+ * c indent on\r
+ * expandtab on\r
+ * End:\r
+ * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et\r
+ * vim<600: sw=4 ts=4\r
+ * }}} */\r
+?>\r
index 34721ee..7ce0a71 100755 (executable)
-<?php
-/**
-*  License Information:
-*
-*  Net_DNS:  A resolver library for PHP
-*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
-*  Maintainers:
-*  Marco Kaiser <bate@php.net>
-*  Florian Anderiasch <fa@php.net>
-*
-* PHP versions 4 and 5
-*
-* LICENSE: This source file is subject to version 3.01 of the PHP license
-* that is available through the world-wide-web at the following URI:
-* http://www.php.net/license/3_01.txt.  If you did not receive a copy of
-* the PHP License and are unable to obtain it through the web, please
-* send a note to license@php.net so we can mail you a copy immediately.
-*/
-
-/* Net_DNS_RR_TXT definition {{{ */
-/**
- * A representation of a resource record of type <b>TXT</b>
- *
- * @package Net_DNS
- */
-class Net_DNS_RR_TXT extends Net_DNS_RR
-{
-    /* class variable definitions {{{ */
-    var $name;
-    var $type;
-    var $class;
-    var $ttl;
-    var $rdlength;
-    var $rdata;
-    var $text;
-
-    /* }}} */
-    /* class constructor - RR(&$rro, $data, $offset = '') {{{ */
-    function Net_DNS_RR_TXT(&$rro, $data, $offset = '')
-    {
-        $this->name = $rro->name;
-        $this->type = $rro->type;
-        $this->class = $rro->class;
-        $this->ttl = $rro->ttl;
-        $this->rdlength = $rro->rdlength;
-        $this->rdata = $rro->rdata;
-
-        if ($offset) {
-            if ($this->rdlength > 0) {
-                $maxoffset = $this->rdlength + $offset;
-                while ($maxoffset > $offset) {
-                    list($text, $offset) = Net_DNS_Packet::label_extract($data, $offset);
-                    $this->text[] = $text;
-                }
-            }
-        } elseif (is_array($data)) {
-            $this->text = $data['text'];
-        } else {
-            $data = str_replace('\\\\', chr(1) . chr(1), $data); /* disguise escaped backslash */
-            $data = str_replace('\\"', chr(2) . chr(2), $data); /* disguise \" */
-
-            preg_match('/("[^"]*"|[^ \t]*)[ \t]*$/', $data, $regs);
-            $regs[1] = str_replace(chr(2) . chr(2), '\\"', $regs[1]);
-            $regs[1] = str_replace(chr(1) . chr(1), '\\\\', $regs[1]);
-            $regs[1] = stripslashes($regs[1]);
-
-            $this->text = $regs[1];
-        }
-    }
-
-    /* }}} */
-    /* Net_DNS_RR_TXT::rdatastr() {{{ */
-    function rdatastr()
-    {
-        if ($this->text) {
-             if (is_array($this->text)) {
-                 $tmp = array();
-                 foreach ($this->text as $t) {
-                     $tmp[] = '"'.addslashes($t).'"';
-                 }
-                 return implode(' ',$tmp);
-             } else {
-                 return '"' . addslashes($this->text) . '"';
-             }
-        } else return '; no data';
-    }
-
-    /* }}} */
-    /* Net_DNS_RR_TXT::rr_rdata($packet, $offset) {{{ */
-    function rr_rdata($packet, $offset)
-    {
-        if ($this->text) {
-            $rdata  = pack('C', strlen($this->text)) . $this->text;
-            return $rdata;
-        }
-        return null;
-    }
-
-    /* }}} */
-}
-/* }}} */
-/* VIM settings {{{
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * soft-stop-width: 4
- * c indent on
- * End:
- * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et
- * vim<600: sw=4 ts=4
- * }}} */
-?>
+<?php\r
+/**\r
+*  License Information:\r
+*\r
+*  Net_DNS:  A resolver library for PHP\r
+*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net\r
+*  Maintainers:\r
+*  Marco Kaiser <bate@php.net>\r
+*  Florian Anderiasch <fa@php.net>\r
+*\r
+* PHP versions 4 and 5\r
+*\r
+* LICENSE: This source file is subject to version 3.01 of the PHP license\r
+* that is available through the world-wide-web at the following URI:\r
+* http://www.php.net/license/3_01.txt.  If you did not receive a copy of\r
+* the PHP License and are unable to obtain it through the web, please\r
+* send a note to license@php.net so we can mail you a copy immediately.\r
+*/\r
+\r
+/* Net_DNS_RR_TXT definition {{{ */\r
+/**\r
+ * A representation of a resource record of type <b>TXT</b>\r
+ *\r
+ * @package Net_DNS\r
+ */\r
+class Net_DNS_RR_TXT extends Net_DNS_RR\r
+{\r
+    /* class variable definitions {{{ */\r
+    var $name;\r
+    var $type;\r
+    var $class;\r
+    var $ttl;\r
+    var $rdlength;\r
+    var $rdata;\r
+    var $text;\r
+\r
+    /* }}} */\r
+    /* class constructor - RR(&$rro, $data, $offset = '') {{{ */\r
+    function Net_DNS_RR_TXT(&$rro, $data, $offset = '')\r
+    {\r
+        $this->name = $rro->name;\r
+        $this->type = $rro->type;\r
+        $this->class = $rro->class;\r
+        $this->ttl = $rro->ttl;\r
+        $this->rdlength = $rro->rdlength;\r
+        $this->rdata = $rro->rdata;\r
+\r
+        if ($offset) {\r
+            if ($this->rdlength > 0) {\r
+                $maxoffset = $this->rdlength + $offset;\r
+                while ($maxoffset > $offset) {\r
+                    list($text, $offset) = Net_DNS_Packet::label_extract($data, $offset);\r
+                    $this->text[] = $text;\r
+                }\r
+            }\r
+        } elseif (is_array($data)) {\r
+            $this->text = $data['text'];\r
+        } else {\r
+            $data = str_replace('\\\\', chr(1) . chr(1), $data); /* disguise escaped backslash */\r
+            $data = str_replace('\\"', chr(2) . chr(2), $data); /* disguise \" */\r
+\r
+            preg_match('/("[^"]*"|[^ \t]*)[ \t]*$/', $data, $regs);\r
+            $regs[1] = str_replace(chr(2) . chr(2), '\\"', $regs[1]);\r
+            $regs[1] = str_replace(chr(1) . chr(1), '\\\\', $regs[1]);\r
+            $regs[1] = stripslashes($regs[1]);\r
+\r
+            $this->text = $regs[1];\r
+        }\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_RR_TXT::rdatastr() {{{ */\r
+    function rdatastr()\r
+    {\r
+        if ($this->text) {\r
+             if (is_array($this->text)) {\r
+                 $tmp = array();\r
+                 foreach ($this->text as $t) {\r
+                     $tmp[] = '"'.addslashes($t).'"';\r
+                 }\r
+                 return implode(' ',$tmp);\r
+             } else {\r
+                 return '"' . addslashes($this->text) . '"';\r
+             }\r
+        } else return '; no data';\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_RR_TXT::rr_rdata($packet, $offset) {{{ */\r
+    function rr_rdata($packet, $offset)\r
+    {\r
+        if ($this->text) {\r
+            $rdata  = pack('C', strlen($this->text)) . $this->text;\r
+            return $rdata;\r
+        }\r
+        return null;\r
+    }\r
+\r
+    /* }}} */\r
+}\r
+/* }}} */\r
+/* VIM settings {{{\r
+ * Local variables:\r
+ * tab-width: 4\r
+ * c-basic-offset: 4\r
+ * soft-stop-width: 4\r
+ * c indent on\r
+ * End:\r
+ * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et\r
+ * vim<600: sw=4 ts=4\r
+ * }}} */\r
+?>\r
index a706383..aa50257 100755 (executable)
-<?php
-/**
-*  License Information:
-*
-*  Net_DNS:  A resolver library for PHP
-*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
-*  Maintainers:
-*  Marco Kaiser <bate@php.net>
-*  Florian Anderiasch <fa@php.net>
-*
-* PHP versions 4 and 5
-*
-* LICENSE: This source file is subject to version 3.01 of the PHP license
-* that is available through the world-wide-web at the following URI:
-* http://www.php.net/license/3_01.txt.  If you did not receive a copy of
-* the PHP License and are unable to obtain it through the web, please
-* send a note to license@php.net so we can mail you a copy immediately.
-*/
-
-/* Net_DNS_Resolver object definition {{{ */
-/**
- * A DNS Resolver library
- *
- * Resolver library.  Builds a DNS query packet, sends the packet to the
- * server and parses the reponse.
- *
- * @package Net_DNS
- */
-class Net_DNS_Resolver
-{
-    /* class variable definitions {{{ */
-    /**
-     * An array of all nameservers to query
-     *
-     * @var array $nameservers
-     * @access public
-     */
-    var $nameservers;
-    /**
-     * The UDP port to use for the query (default = 53)
-     *
-     * @var integer $port
-     * @access public
-     */
-    var $port;
-    /**
-     * The domain in which the resolver client host resides.
-     *
-     * @var string $domain
-     * @access public
-     */
-    var $domain;
-    /**
-     * The searchlist to apply to unqualified hosts
-     *
-     * An array of strings containg domains to apply to unqualified hosts
-     * passed to the resolver.
-     *
-     * @var array $searchlist
-     * @access public
-     */
-    var $searchlist;
-    /**
-     * The number of seconds between retransmission of unaswered queries
-     *
-     * @var integer $retrans
-     * @access public
-     */
-    var $retrans;
-    /**
-     * The number of times unanswered requests should be retried
-     *
-     * @var integer $retry
-     * @access public
-     */
-    var $retry;
-    /**
-     * Whether or not to use TCP (Virtual Circuits) instead of UDP
-     *
-     * If set to 0, UDP will be used unless TCP is required.  TCP is
-     * required for questions or responses greater than 512 bytes.
-     *
-     * @var boolean $usevc
-     * @access public
-     */
-    var $usevc;
-    /**
-     * Unknown
-     */
-    var $stayopen;
-    /**
-     * Ignore TC (truncated) bit
-     *
-     * If the server responds with the TC bit set on a response, and $igntc
-     * is set to 0, the resolver will automatically retransmit the request
-     * using virtual circuits (TCP).
-     *
-     * @access public
-     * @var boolean $igntc
-     */
-    var $igntc;
-    /**
-     * Recursion Desired
-     *
-     * Sets the value of the RD (recursion desired) bit in the header. If
-     * the RD bit is set to 0, the server will not perform recursion on the
-     * request.
-     *
-     * @var boolean $recurse
-     * @access public
-     */
-    var $recurse;
-    /**
-     * Unknown
-     */
-    var $defnames;
-    /**
-     * Unknown
-     */
-    var $dnsrch;
-    /**
-     * Contains the value of the last error returned by the resolver.
-     *
-     * @var string $errorstring
-     * @access public
-     */
-    var $errorstring;
-    /**
-     * The origin of the packet.
-     *
-     * This contains a string containing the IP address of the name server
-     * from which the answer was given.
-     *
-     * @var string $answerfrom
-     * @access public
-     */
-    var $answerfrom;
-    /**
-     * The size of the answer packet.
-     *
-     * This contains a integer containing the size of the DNS packet the
-     * server responded with.
-     *
-     * @var string $answersize
-     * @access public
-     */
-    var $answersize;
-    /**
-     * The number of seconds after which a TCP connection should timeout
-     *
-     * @var integer $tcp_timeout
-     * @access public
-     */
-    var $tcp_timeout;
-    /**
-     * The location of the system resolv.conf file.
-     *
-     * @var string $resolv_conf
-     */
-    var $resolv_conf = '/etc/resolv.conf';
-    /**
-     * The name of the user defined resolv.conf
-     *
-     * The resolver will attempt to look in both the current directory as
-     * well as the user's home directory for a user defined resolver
-     * configuration file
-     *
-     * @var string $dotfile
-     * @see Net_DNS_Resolver::$confpath
-     */
-    var $dotfile = '.resolv.conf';
-    /**
-     * A array of directories to search for the user's resolver config
-     *
-     * @var string $confpath
-     * @see Net_DNS_Resolver::$dotfile
-     */
-    var $confpath;
-    /**
-     * debugging flag
-     *
-     * If set to true (non-zero), debugging code will be displayed as the
-     * resolver makes the request.
-     *
-     * @var boolean $debug;
-     * @access public
-     */
-    var $debug;
-    /**
-     * use the (currently) experimental PHP socket library
-     *
-     * If set to true (non-zero), the Resolver will attempt to use the
-     * much more effecient PHP sockets extension (if available).
-     *
-     * @var boolean $useEnhancedSockets;
-     * @access public
-     */
-    var $useEnhancedSockets = true;
-    /**
-     * An array of sockets connected to a name servers
-     *
-     * @var array $sockets
-     * @access private
-     */
-    var $sockets;
-    /**
-     * axfr tcp socket
-     *
-     * Used to store a PHP socket resource for a connection to a server
-     *
-     * @var resource $_axfr_sock;
-     * @access private
-     */
-    var $_axfr_sock;
-    /**
-     * axfr resource record list
-     *
-     * Used to store a resource record list from a zone transfer
-     *
-     * @var resource $_axfr_rr;
-     * @access private
-     */
-    var $_axfr_rr;
-    /**
-     * axfr soa count
-     *
-     * Used to store the number of soa records received from a zone transfer
-     *
-     * @var resource $_axfr_soa_count;
-     * @access private
-     */
-    var $_axfr_soa_count;
-     /**
-     * An array of config files that have been read/parsed already and is used
-     * to ensure the usable config files are searched for only once.
-     *
-     * @var array
-     * @access public
-     * @see Net_DNS_Resolver::read_config()
-     */
-    var $parsedfiles = array();
-    /**
-     * sleep
-     *
-     * Length of time to wait between reading for respose from server.
-     *
-     * @var int
-     * @access private
-     */
-    var $sleep;
-
-    /**
-    /* }}} */
-    /* class constructor - Net_DNS_Resolver() {{{ */
-    /**
-     * Initializes the Resolver Object
-     *
-     * @return Net_DNS_Resolver
-     */
-    function Net_DNS_Resolver($defaults = array())
-    {
-        $mydefaults = array(
-                'nameservers' => array(),
-                'port'        => '53',
-                'domain'      => '',
-                'searchlist'  => array(),
-                'retrans'     => 5,
-                'retry'       => 4,
-                'usevc'       => 0,
-                'stayopen'    => 0,
-                'igntc'       => 0,
-                'recurse'     => 1,
-                'defnames'    => 1,
-                'dnsrch'      => 1,
-                'debug'       => 0,
-                'errorstring' => 'unknown error or no error',
-                'answerfrom'  => '',
-                'answersize'  => 0,
-                'sleep'       => 1000,
-                'tcp_timeout' => 120
-                );
-        foreach ($mydefaults as $k => $v) {
-            $this->{$k} = isset($defaults[$k]) ? $defaults[$k] : $v;
-        }
-        $this->confpath[0] = getenv('HOME');
-        $this->confpath[1] = '.';
-        $this->res_init();
-    }
-
-    /* }}} */
-    /* Net_DNS_Resolver::res_init() {{{ */
-    /**
-     * Initalizes the resolver library
-     *
-     * res_init() searches for resolver library configuration files and
-     * initializes the various properties of the resolver object.
-     *
-     * @see Net_DNS_Resolver::$resolv_conf, Net_DNS_Resolver::$dotfile,
-     *      Net_DNS_Resolver::$confpath, Net_DNS_Resolver::$searchlist,
-     *      Net_DNS_Resolver::$domain, Net_DNS_Resolver::$nameservers
-     * @access public
-     */
-    function res_init()
-    {
-        $err = error_reporting(0);
-        if ($this->parsedfiles == array()) {
-            if (file_exists($this->resolv_conf) && is_readable($this->resolv_conf)) {
-                $this->read_config($this->resolv_conf);
-                array_push($this->parsedfiles, $this->resolv_conf);
-            }
-
-            foreach ($this->confpath as $dir) {
-                $file = $dir.DIRECTORY_SEPARATOR.$this->dotfile;
-                if (file_exists($file) && is_readable($file)) {
-                    $this->read_config($file);
-                    array_push($this->parsedfiles, $file);
-                }
-            }
-        } else {
-            foreach($this->parsedfiles as $file) {
-                $this->read_config($file);
-            }
-        }
-
-        $this->read_env();
-
-        if (!strlen($this->domain) && sizeof($this->searchlist)) {
-            $this->domain = $this->searchlist[0];
-        } else if (! sizeof($this->searchlist) && strlen($this->domain)) {
-            $this->searchlist = array($this->domain);
-        }
-        error_reporting($err);
-    }
-
-    /* }}} */
-    /* Net_DNS_Resolver::read_config {{{ */
-    /**
-     * Reads and parses a resolver configuration file
-     *
-     * @param string $file The name of the file to open and parse
-     */
-    function read_config($file)
-    {
-        if (is_readable($file)) {
-            if (! ($f = fopen($file, 'r'))) {
-                $this->error = "can't open $file";
-            }
-        }
-
-        if (!is_resource($f)) {
-            $this->error = "can't open $file";
-        } else {
-            while (! feof($f)) {
-                $line = chop(fgets($f, 10240));
-                $line = preg_replace('/(.*)[;#].*/', '\\1', $line);
-                if (preg_match("/^[ \t]*$/", $line, $regs)) {
-                    continue;
-                }
-                preg_match("/^[ \t]*([^ \t]+)[ \t]+([^ \t]+)/", $line, $regs);
-                $option = $regs[1];
-                $value = $regs[2];
-
-                switch ($option) {
-                    case 'nameserver':
-                        $nameservers = explode(' ', $regs[2]);
-                        foreach ($nameservers as $ns) {
-                            $this->nameservers[count($this->nameservers)] = $ns;
-                        }
-                        break;
-                    case 'domain':
-                        $this->domain = $regs[2];
-                        break;
-                    case 'search':
-                        $this->searchlist[count($this->searchlist)] = $regs[2];
-                        break;
-                }
-            }
-            fclose($f);
-        }
-    }
-
-    function set_nameservers($nameservers) {
-        if ($nameservers == '') return;
-        $this->nameservers = explode(' ', $nameservers);
-    }
-
-    /* }}} */
-    /* Net_DNS_Resolver::read_env() {{{ */
-    /**
-     * Examines the environment for resolver config information
-     */
-    function read_env()
-    {
-        if (getenv('RES_NAMESERVERS')) {
-            $this->set_nameservers(getenv('RES_NAMESERVERS'));
-        }
-
-        if (getenv('RES_SEARCHLIST')) {
-            $this->searchlist = explode(' ', getenv('RES_SEARCHLIST'));
-        }
-
-        if (getenv('LOCALDOMAIN')) {
-            $this->domain = getenv('LOCALDOMAIN');
-        }
-
-        if (getenv('RES_OPTIONS')) {
-            $env = explode(' ', getenv('RES_OPTIONS'));
-            foreach ($env as $opt) {
-                list($name, $val) = explode(':', $opt);
-                if ($val == '') {
-                    $val = 1;
-                }
-                $this->{$name} = $val;
-            }
-        }
-    }
-
-    /* }}} */
-    /* Net_DNS_Resolver::string() {{{ */
-    /**
-     * Builds a string containing the current state of the resolver
-     *
-     * Builds formatted string containing the state of the resolver library suited
-     * for display.
-     *
-     * @access public
-     */
-    function string()
-    {
-        $state  = ";; Net_DNS_Resolver state:\n";
-        $state .= ';;  domain       = ' . $this->domain . "\n";
-        $state .= ';;  searchlist   = ' . implode(' ', $this->searchlist) . "\n";
-        $state .= ';;  nameservers  = ' . implode(' ', $this->nameservers) . "\n";
-        $state .= ';;  port         = ' . $this->port . "\n";
-        $state .= ';;  tcp_timeout  = ';
-        $state .= ($this->tcp_timeout ? $this->tcp_timeout : 'indefinite') . "\n";
-        $state .= ';;  retrans  = ' . $this->retrans . '  ';
-        $state .= 'retry    = ' . $this->retry . "\n";
-        $state .= ';;  usevc    = ' . $this->usevc . '  ';
-        $state .= 'stayopen = ' . $this->stayopen . '    ';
-        $state .= 'igntc = ' . $this->igntc . "\n";
-        $state .= ';;  defnames = ' . $this->defnames . '  ';
-        $state .= 'dnsrch   = ' . $this->dnsrch . "\n";
-        $state .= ';;  recurse  = ' . $this->recurse . '  ';
-        $state .= 'debug    = ' . $this->debug . "\n";
-        return $state;
-    }
-
-    /* }}} */
-    /* Net_DNS_Resolver::nextid() {{{ */
-    /**
-     * Returns the next request Id to be used for the DNS packet header
-     */
-    function nextid()
-    {
-               if (++$GLOBALS['_Net_DNS_packet_id'] > 65535) {
-            $GLOBALS['_Net_DNS_packet_id']= 1;
-        }
-        return $GLOBALS['_Net_DNS_packet_id'];
-    }
-    /* }}} */
-    /* Net_DNS_Resolver::nameservers() {{{ */
-    /**
-     * Gets or sets the nameservers to be queried.
-     *
-     * Returns the current nameservers if an array of new nameservers is not
-     * given as the argument OR sets the nameservers to the given nameservers.
-     *
-     * Nameservers not specified by ip address must be able to be resolved by
-     * the default settings of a new Net_DNS_Resolver.
-     *
-     * @access public
-     */
-    function nameservers($nsa = array())
-    {
-        $defres = new Net_DNS_Resolver();
-
-        if (is_array($nsa)) {
-            $a = array();
-            foreach ($nsa as $ns) {
-                if (preg_match('/^(\d+(:?\.\d+){0,3})$/', $ns)) {
-                    $a[] = ($ns == 0) ? '0.0.0.0' : $ns;
-                } else {
-                    $names = array();
-                    if (!preg_match('/\./', $ns)) {
-                        if (!empty($defres->searchlist)) {
-                            foreach ($defres->searchlist as $suffix) {
-                                $names[] = $ns .'.' . $suffix;
-                            }
-                        } elseif (!empty($defres->domain)) {
-                            $names[] = $ns .'.'. $defres->domain;
-                        }
-                    } else {
-                        $names[] = $ns;
-                    }
-                    $packet = $defres->search($ns);
-                    if (is_object($packet)) {
-                        $addresses = $this->cname_addr($names, $packet);
-                        foreach ($addresses as $b) {
-                            $a[] = $b;
-                        }
-                        $a = array_unique($a);
-                    }
-                }
-            }
-            if (count($a)) {
-                $this->nameservers = $a;
-            }
-        }
-        return $this->nameservers;
-    }
-
-    /* }}} */
-    /* not tested -- Net_DNS_Resolver::cname_addr() {{{ */
-    function cname_addr($names, $packet)
-    {
-        $addr = array();
-        //my $oct2 = '(?:2[0-4]\d|25[0-5]|[0-1]?\d\d|\d)';
-        foreach ($packet->answer as $rr) {
-            if (in_array($rr->name, $names)) {
-                if ($rr->type == 'CNAME') {
-                    $names[] = $rr->cname;
-                } elseif ($rr->type == 'A') {
-                    // Run a basic taint check.
-                    //next RR unless $rr->address =~ m/^($oct2\.$oct2\.$oct2\.$oct2)$/o;
-
-                    $addr[] = $rr->address;
-                }
-            }
-        }
-        return $addr;
-    }
-
-    /* }}} */
-    /* Net_DNS_Resolver::search() {{{ */
-    /**
-     * Searches nameservers for an answer
-     *
-     * Goes through the search list and attempts to resolve name based on
-     * the information in the search list.
-     *
-     * @param string $name The name (LHS) of a resource record to query.
-     * @param string $type The type of record to query.
-     * @param string $class The class of record to query.
-     * @return mixed    an object of type Net_DNS_Packet on success,
-     *                  or false on failure.
-     * @see Net_DNS::typesbyname(), Net_DNS::classesbyname()
-     * @access public
-     */
-    function search($name, $type = 'A', $class = 'IN')
-    {
-        /*
-         * If the name looks like an IP address then do an appropriate
-         * PTR query.
-         */
-        if (preg_match('/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/', $name, $regs)) {
-            $name = $regs[4].'.'.$regs[3].'.'.$regs[2].'.'.$regs[1].'.in-addr.arpa.';
-            $type = 'PTR';
-        }
-
-        /*
-         * If the name contains at least one dot then try it as is first.
-         */
-        if (strstr($name, '.')) {
-            if ($this->debug) {
-                echo ";; search($name, $type, $class)\n";
-            }
-            $ans = $this->query($name, $type, $class);
-            if (is_object($ans) && ($ans->header->ancount > 0)) {
-                return $ans;
-            }
-        }
-
-        /*
-         * If the name does not end in a dot then apply the search list.
-         */
-        $domain = '';
-        if ((! preg_match('/\.$/', $name)) && $this->dnsrch) {
-            foreach ($this->searchlist as $domain) {
-                $newname = "$name.$domain";
-                if ($this->debug) {
-                    echo ";; search($newname, $type, $class)\n";
-                }
-                $ans = $this->query($newname, $type, $class);
-                if (is_object($ans) && ($ans->header->ancount > 0)) {
-                    return $ans;
-                }
-            }
-        }
-
-        /*
-         * Finally, if the name has no dots then try it as is.
-         */
-        if (strpos($name, '.') === false) {
-            if ($this->debug) {
-                echo ";; search($name, $type, $class)\n";
-            }
-            $ans = $this->query($name.'.', $type, $class);
-            if (is_object($ans) && ($ans->header->ancount > 0)) {
-                return $ans;
-            }
-        }
-
-        /*
-         * No answer was found.
-         */
-        return false;
-    }
-
-    /* }}} */
-    /* Net_DNS_Resolver::rawQuery() {{{ */
-    /**
-     * Queries nameservers for an answer
-     *
-     * Queries the nameservers listed in the resolver configuration for an
-     * answer to a question packet.
-     *
-     * @param string $name The name (LHS) of a resource record to query.
-     * @param string $type The type of record to query.
-     * @param string $class The class of record to query.
-     * @return mixed an object of type Net_DNS_Packet, regardless of whether the packet
-     *               has an answer or not
-     * @see Net_DNS::typesbyname(), Net_DNS::classesbyname()
-     * @access public
-     */
-    function rawQuery($name, $type = 'A', $class = 'IN')
-    {
-        /*
-         * If the name does not contain any dots then append the default domain.
-         */
-        if ((strchr($name, '.') < 0) && $this->defnames) {
-            $name .= '.' . $this->domain;
-        }
-
-        /*
-         * If the name looks like an IP address then do an appropriate
-         * PTR query.
-         */
-        if (preg_match('/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/', $name, $regs)) {
-            $name = $regs[4].'.'.$regs[3].'.'.$regs[2].'.'.$regs[1].'.in-addr.arpa.';
-            $type = 'PTR';
-        }
-
-        if ($this->debug) {
-            echo ";; query($name, $type, $class)\n";
-        }
-        $packet = new Net_DNS_Packet($this->debug);
-        $packet->buildQuestion($name, $type, $class);
-        $packet->header->rd = $this->recurse;
-        $ans = $this->send($packet);
-        return $ans;
-    }
-
-    /* }}} */
-    /* Net_DNS_Resolver::query() {{{ */
-    /**
-     * Queries nameservers for an answer
-     *
-     * Queries the nameservers listed in the resolver configuration for an
-     * answer to a question packet.
-     *
-     * @param string $name The name (LHS) of a resource record to query.
-     * @param string $type The type of record to query.
-     * @param string $class The class of record to query.
-     * @return mixed    an object of type Net_DNS_Packet on success,
-     *                  or false on failure.
-     * @see Net_DNS::typesbyname(), Net_DNS::classesbyname()
-     * @access public
-     */
-    function query($name, $type = 'A', $class = 'IN')
-    {
-        $ans = $this->rawQuery($name, $type, $class);
-        if (is_object($ans) && $ans->header->ancount > 0) {
-            return $ans;
-        }
-        return false;
-    }
-
-    /* }}} */
-    /* Net_DNS_Resolver::send($packetORname, $qtype = '', $qclass = '') {{{ */
-    /**
-     * Sends a packet to a nameserver
-     *
-     * Determines the appropriate communication method (UDP or TCP) and
-     * sends a DNS packet to a nameserver.  Use of the this function
-     * directly  is discouraged. $packetORname should always be a properly
-     * formatted binary DNS packet.  However, it is possible to send a
-     * query here and bypass Net_DNS_Resolver::query()
-     *
-     * @param string $packetORname      A binary DNS packet stream or a
-     *                                  hostname to query
-     * @param string $qtype     This should not be used
-     * @param string $qclass    This should not be used
-     * @return object Net_DNS_Packet    An answer packet object
-     */
-    function send($packetORname, $qtype = '', $qclass = '')
-    {
-        $packet = $this->make_query_packet($packetORname, $qtype, $qclass);
-        $packet_data = $packet->data();
-
-        if (($this->usevc != 0) || (strlen($packet_data) > 512)) {
-            $ans = $this->send_tcp($packet, $packet_data);
-        } else {
-            $ans = $this->send_udp($packet, $packet_data);
-
-            if (($ans) && ($ans->header->tc) && ($this->igntc == 0)) {
-                if ($this->debug) {
-                    echo ";;\n;; packet truncated: retrying using TCP\n";
-                }
-                $ans = $this->send_tcp($packet, $packet_data);
-            }
-        }
-        return $ans;
-    }
-
-    /* }}} */
-    /* Net_DNS_Resolver::printhex($packet_data) {{{ */
-    /**
-     * Prints packet data as hex code.
-     */
-    function printhex($data)
-    {
-        $data = '  ' . $data;
-        $start = 0;
-        while ($start < strlen($data)) {
-            printf(';; %03d: ', $start);
-            for ($ctr = $start; $ctr < $start+16; $ctr++) {
-                if ($ctr < strlen($data)) {
-                    printf('%02x ', ord($data[$ctr]));
-                } else {
-                    echo '   ';
-                }
-            }
-            echo '   ';
-            for ($ctr = $start; $ctr < $start+16; $ctr++) {
-                if (ord($data[$ctr]) < 32 || ord($data[$ctr]) > 127) {
-                    echo '.';
-                } else {
-                    echo $data[$ctr];
-                }
-            }
-            echo "\n";
-            $start += 16;
-        }
-    }
-    /* }}} */
-    /* Net_DNS_Resolver::send_tcp($packet, $packet_data) {{{ */
-    /**
-     * Sends a packet via TCP to the list of name servers.
-     *
-     * @param string $packet    A packet object to send to the NS list
-     * @param string $packet_data   The data in the packet as returned by
-     *                              the Net_DNS_Packet::data() method
-     * @return object Net_DNS_Packet Returns an answer packet object
-     * @see Net_DNS_Resolver::send_udp(), Net_DNS_Resolver::send()
-     */
-    function send_tcp($packet, $packet_data)
-    {
-        if (! count($this->nameservers)) {
-            $this->errorstring = 'no nameservers';
-            if ($this->debug) {
-                echo ";; ERROR: send_tcp: no nameservers\n";
-            }
-            return null;
-        }
-        $timeout = $this->tcp_timeout;
-
-        foreach ($this->nameservers as $ns) {
-            $dstport = $this->port;
-            if ($this->debug) {
-                echo ";; send_tcp($ns:$dstport)\n";
-            }
-            $sock_key = "$ns:$dstport";
-            if (isset($this->sockets[$sock_key]) && is_resource($this->sockets[$sock_key])) {
-                $sock = &$this->sockets[$sock_key];
-            } else {
-                if (! ($sock = @fsockopen($ns, $dstport, $errno,
-                                $errstr, $timeout))) {
-                    $this->errorstring = 'connection failed';
-                    if ($this->debug) {
-                        echo ";; ERROR: send_tcp: connection failed: $errstr\n";
-                    }
-                    continue;
-                }
-                $this->sockets[$sock_key] = $sock;
-                unset($sock);
-                $sock = &$this->sockets[$sock_key];
-            }
-            $lenmsg = pack('n', strlen($packet_data));
-            if ($this->debug) {
-                echo ';; sending ' . strlen($packet_data) . " bytes\n";
-            }
-
-            if (($sent = fwrite($sock, $lenmsg)) == -1) {
-                $this->errorstring = 'length send failed';
-                if ($this->debug) {
-                    echo ";; ERROR: send_tcp: length send failed\n";
-                }
-                continue;
-            }
-
-            if (($sent = fwrite($sock, $packet_data)) == -1) {
-                $this->errorstring = 'packet send failed';
-                if ($this->debug) {
-                    echo ";; ERROR: send_tcp: packet data send failed\n";
-                }
-            }
-
-            socket_set_timeout($sock, $timeout);
-            $buf = fread($sock, 2);
-            $e = socket_get_status($sock);
-            /* If $buf is empty, we want to supress errors
-               long enough to reach the continue; down the line */
-            $len = @unpack('nint', $buf);
-            $len = @$len['int'];
-            if (!$len) {
-                continue;
-            }
-            $buf = '';
-            while (!feof($sock) && (strlen($buf) < $len) ) {
-                $buf .= fread($sock, $len-strlen($buf));
-            }
-            $actual = strlen($buf);
-            $this->answerfrom = $ns;
-            $this->answersize = $len;
-            if ($this->debug) {
-                echo ";; received $actual bytes\n";
-            }
-            if ($actual != $len) {
-                $this->errorstring = "expected $len bytes, received $buf";
-                if ($this->debug) {
-                    echo ';; send_tcp: ' . $this->errorstring;
-                }
-                continue;
-            }
-
-            $ans = new Net_DNS_Packet($this->debug);
-            if (is_null($ans->parse($buf))) {
-                continue;
-            }
-            $this->errorstring = $ans->header->rcode;
-            $ans->answerfrom = $this->answerfrom;
-            $ans->answersize = $this->answersize;
-            return $ans;
-        }
-    }
-
-    /* }}} */
-    /* Net_DNS_Resolver::send_udp_no_sock_lib($packet, $packet_data) {{{ */
-    /**
-     * Sends a packet via UDP to the list of name servers.
-     *
-     * This function sends a packet to a nameserver.  It is called by
-     * send_udp if the sockets PHP extension is not compiled into PHP.
-     *
-     * @param string $packet    A packet object to send to the NS list
-     * @param string $packet_data   The data in the packet as returned by
-     *                              the Net_DNS_Packet::data() method
-     * @return object Net_DNS_Packet Returns an answer packet object
-     * @see Net_DNS_Resolver::send_tcp(), Net_DNS_Resolver::send(),
-     *      Net_DNS_Resolver::send_udp(), Net_DNS_Resolver::send_udp_with_sock_lib()
-     */
-    function send_udp_no_sock_lib($packet, $packet_data)
-    {
-        $retrans = $this->retrans;
-        $timeout = $retrans;
-
-        /*
-         * PHP doesn't have excellent socket support as of this writing.
-         * This needs to be rewritten when PHP POSIX socket support is
-         * complete.
-         * Obviously, this code is MUCH different than the PERL implementation
-         */
-
-        $w = error_reporting(0);
-        $ctr = 0;
-        // Create a socket handle for each nameserver
-        foreach ($this->nameservers as $nameserver) {
-            if ($sock[$ctr++] = fsockopen("udp://$nameserver", $this->port)) {
-                $peerhost[$ctr-1] = $nameserver;
-                $peerport[$ctr-1] = $this->port;
-                stream_set_blocking($sock[$ctr-1], 0);
-            } else {
-                $ctr--;
-            }
-        }
-        error_reporting($w);
-
-        if ($ctr == 0) {
-            $this->errorstring = 'no nameservers';
-            return null;
-        }
-
-        $retry = $this->retry;
-        for ($i = 0; $i < $retry; $i++, $retrans *= 2,
-                $timeout = (int) ($retrans / $ctr)) {
-            if ($timeout < 1) {
-                $timeout = 1;
-            }
-
-            foreach ($sock as $k => $s) {
-                if ($this->debug) {
-                    echo ';; send_udp(' . $peerhost[$k] . ':' . $peerport[$k] . '): sending ' . strlen($packet_data) . " bytes\n";
-                }
-
-                if (! fwrite($s, $packet_data)) {
-                    if ($this->debug) {
-                        echo ";; send error\n";
-                    }
-                }
-
-                /*
-                 *  Here's where it get's really nasty.  We don't have a select()
-                 *  function here, so we have to poll for a response... UGH!
-                 */
-
-                $timetoTO  = time() + (double)microtime() + $timeout;
-
-                /*
-                 * let's sleep for a few hundred microseconds to let the
-                 * data come in from the network...
-                 */
-                $sleep = $this->sleep;
-                if ($sleep) {
-                    usleep($sleep / 2);
-                }
-
-                $buf = '';
-                while (! strlen($buf) && $timetoTO > (time() +
-                            (double)microtime())) {
-                    stream_set_blocking($s, 0);
-                    if ($buf = fread($s, 512)) {
-                        $this->answerfrom = $peerhost[$k];
-                        $this->answersize = strlen($buf);
-                        if ($this->debug) {
-                            echo ';; answer from ' . $peerhost[$k] . ':' .
-                                $peerport[$k] .  ': ' . strlen($buf) . " bytes\n";
-                        }
-                        $ans = new Net_DNS_Packet($this->debug);
-                        if ($ans->parse($buf)) {
-                            if ($ans->header->qr != '1') {
-                                continue;
-                            }
-                            if ($ans->header->id != $packet->header->id) {
-                                continue;
-                            }
-                            $this->errorstring = $ans->header->rcode;
-                            $ans->answerfrom = $this->answerfrom;
-                            $ans->answersize = $this->answersize;
-                            return $ans;
-                        }
-                    }
-                    // Sleep another 1/100th of a second... this sucks...
-                    if ($sleep) {
-                        usleep($sleep / 2);
-                    }
-                }
-
-            }
-
-            $this->errorstring = 'query timed out';
-            return null;
-        }
-    }
-
-    /* }}} */
-    /* Net_DNS_Resolver::send_udp_with_sock_lib($packet, $packet_data) {{{ */
-    /**
-     * Sends a packet via UDP to the list of name servers.
-     *
-     * This function sends a packet to a nameserver.  It is called by
-     * send_udp if the sockets PHP extension is compiled into PHP.
-     *
-     * @param string $packet    A packet object to send to the NS list
-     * @param string $packet_data   The data in the packet as returned by
-     *                              the Net_DNS_Packet::data() method
-     * @return object Net_DNS_Packet Returns an answer packet object
-     * @see Net_DNS_Resolver::send_tcp(), Net_DNS_Resolver::send(),
-     *      Net_DNS_Resolver::send_udp(), Net_DNS_Resolver::send_udp_no_sock_lib()
-     */
-    function send_udp_with_sock_lib($packet, $packet_data)
-    {
-        $retrans = $this->retrans;
-        $timeout = $retrans;
-
-        //$w = error_reporting(0);
-        $ctr = 0;
-        // Create a socket handle for each nameserver
-        foreach ($this->nameservers as $nameserver) {
-            if ((($sock[$ctr++] = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP))) &&
-                  socket_connect($sock[$ctr-1], $nameserver, $this->port))
-            {
-                $peerhost[$ctr-1] = $nameserver;
-                $peerport[$ctr-1] = $this->port;
-                socket_set_nonblock($sock[$ctr-1]);
-            } else {
-                $ctr--;
-            }
-        }
-        //error_reporting($w);
-
-        if ($ctr == 0) {
-            $this->errorstring = 'no nameservers';
-            return null;
-        }
-        // Try each nameserver up to $this->retry times
-        for ($i = 0; $i < $this->retry; $i++) {
-            if ($i !== 0) {
-                // Set the timeout for each retry based on the number of
-                // nameservers there is a connected socket for.
-                $retrans *= 2;
-                $timeout = (int) ($retrans / $ctr);
-            }
-            // Make sure the timeout is at least 1 second
-            if ($timeout < 1) {
-                $timeout = 1;
-            }
-
-            // Try each nameserver
-            foreach ($sock as $k => $s) {
-                if ($this->debug) {
-                    echo "\n;; send_udp(" . $peerhost[$k] . ':' . $peerport[$k] . '): sending ' . strlen($packet_data) . " bytes\n";
-                }
-
-                if (! socket_write($s, $packet_data)) {
-                    if ($this->debug) {
-                        echo ";; send error\n";
-                    }
-                }
-
-                $set = array($s);
-                if ($this->debug) {
-                    echo ";; timeout set to $timeout seconds\n";
-                }
-                $changed = socket_select($set, $w = null, $e = null, $timeout);
-                if ($changed) {
-                    // Test to see if the connection was refused.  Linux servers will send
-                    // an ICMP message which will cause the client's next system call to
-                    // return ECONNREFUSED if the server is not listening on the ip:port queried
-                    if (socket_get_option($s, SOL_SOCKET, SO_ERROR) == SOCKET_ECONNREFUSED) {
-                        // Unix socket connection was refused
-                        if ($this->debug) {
-                            echo ';; connection to ' . $peerhost[$k] . ':' . $peerport[$k] . " was refused\n";
-                        }
-                        // Try the next server.
-                        continue;
-                    }
-
-                    // Read the response
-                    $buf = @socket_read($s, 512);
-                    if ($buf === false) {
-                        // No data could be read from socket
-                        if ($this->debug) {
-                            echo ';; no data could be read from ' . $peerhost[$k] . ':' . $peerport[$k] . "\n";
-                            echo ';; socket_error: ' . socket_strerror(socket_last_error()) . "\n";
-                        }
-                        // Reset the non-specific socket error status
-                        socket_clear_error();
-                        // Try the next server.
-                        continue;
-                    }
-
-                    $this->answerfrom = $peerhost[$k];
-                    $this->answersize = strlen($buf);
-                    if ($this->debug) {
-                        echo ';; answer from ' . $peerhost[$k] . ':' .
-                            $peerport[$k] .  ': ' . strlen($buf) . " bytes\n";
-                    }
-                    $ans = new Net_DNS_Packet($this->debug);
-                    if ($ans->parse($buf)) {
-                        if ($ans->header->qr != '1') {
-                            // Ignore packet if it is not a response
-                            continue;
-                        } elseif ($ans->header->id != $packet->header->id) {
-                            // Ignore packet if the response id does not match the query id
-                            continue;
-                        } else {
-                            // Return the DNS response packet
-                            $this->errorstring = $ans->header->rcode;
-                            $ans->answerfrom = $this->answerfrom;
-                            $ans->answersize = $this->answersize;
-                            return $ans;
-                        }
-                    }
-                } elseif ($this->debug) {
-                    echo ";; query to ". $peerhost[$k] . ':' . $peerport[$k] . " timed out\n";
-                }
-            }
-        }
-        $this->errorstring = 'query timed out';
-        return null;
-    }
-
-    /* }}} */
-    /* Net_DNS_Resolver::send_udp($packet, $packet_data) {{{ */
-    /**
-     * Sends a packet via UDP to the list of name servers.
-     *
-     * This function sends a packet to a nameserver.  send_udp calls
-     * either Net_DNS_Resolver::send_udp_no_sock_lib() or
-     * Net_DNS_Resolver::send_udp_with_sock_lib() depending on whether or
-     * not the sockets extension is compiled into PHP.  Note that using the
-     * sockets extension is MUCH more efficient.
-     *
-     * @param object Net_DNS_Packet $packet A packet object to send to the NS list
-     * @param string $packet_data   The data in the packet as returned by
-     *                              the Net_DNS_Packet::data() method
-     * @return object Net_DNS_Packet Returns an answer packet object
-     * @see Net_DNS_Resolver::send_tcp(), Net_DNS_Resolver::send(),
-     *      Net_DNS_Resolver::send_udp(), Net_DNS_Resolver::send_udp_no_sock_lib()
-     */
-    function send_udp($packet, $packet_data)
-    {
-        if (extension_loaded('sockets') && $this->useEnhancedSockets) {
-            if ($this->debug) {
-                echo "\n;; using extended PHP sockets\n";
-            }
-            return $this->send_udp_with_sock_lib($packet, $packet_data);
-        } else {
-            if ($this->debug) {
-                echo "\n;; using simple sockets\n";
-            }
-            return $this->send_udp_no_sock_lib($packet, $packet_data);
-        }
-    }
-
-    /* }}} */
-    /* Net_DNS_Resolver::make_query_packet($packetORname, $type = '', $class = '') {{{ */
-    /**
-     * Unknown
-     */
-    function make_query_packet($packetORname, $type = '', $class = '')
-    {
-        if (is_object($packetORname) && strcasecmp(get_class($packetORname), 'net_dns_packet') == 0) {
-            $packet = $packetORname;
-        } else {
-            $name = $packetORname;
-            if ($type == '') {
-                $type = 'A';
-            }
-            if ($class == '') {
-                $class = 'IN';
-            }
-
-            /*
-             * If the name looks like an IP address then do an appropriate
-             * PTR query.
-             */
-            if (preg_match('/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/', $name, $regs)) {
-                $name = $regs[4].'.'.$regs[3].'.'.$regs[2].'.'.$regs[1].'.in-addr.arpa.';
-                $type = 'PTR';
-            }
-
-            if ($this->debug) {
-                echo ";; query($name, $type, $class)\n";
-            }
-            $packet = new Net_DNS_Packet($this->debug);
-            $packet->buildQuestion($name, $type, $class);
-        }
-
-        $packet->header->rd = $this->recurse;
-        return $packet;
-    }
-
-    /* }}} */
-    /* Net_DNS_Resolver::axfr_old($dname, $class = 'IN') {{{ */
-    /**
-     * Performs an AXFR query (zone transfer) (OLD BUGGY STYLE)
-     *
-     * This is deprecated and should not be used!
-     *
-     * @param string $dname The domain (zone) to transfer
-     * @param string $class The class in which to look for the zone.
-     * @return object Net_DNS_Packet
-     * @access public
-     */
-    function axfr_old($dname, $class = 'IN')
-    {
-        return $this->axfr($dname, $class, true);
-    }
-    /* }}} */
-    /* Net_DNS_Resolver::axfr($dname, $class = 'IN', $old = false) {{{ */
-    /**
-     * Performs an AXFR query (zone transfer)
-     *
-     * Requests a zone transfer from the nameservers. Note that zone
-     * transfers will ALWAYS use TCP regardless of the setting of the
-     * Net_DNS_Resolver::$usevc flag.  If $old is set to true, Net_DNS requires
-     * a nameserver that supports the many-answers style transfer format.  Large
-     * zone transfers will not function properly.  Setting $old to true is _NOT_
-     * recommended and should only be used for backwards compatibility.
-     *
-     * @param string $dname The domain (zone) to transfer
-     * @param string $class The class in which to look for the zone.
-     * @param boolean $old Requires 'old' style many-answer format to function.
-                           Used for backwards compatibility only.
-     * @return object Net_DNS_Packet
-     * @access public
-     */
-    function axfr($dname, $class = 'IN', $old = false)
-    {
-        if ($old) {
-            if ($this->debug) {
-                echo ";; axfr_start($dname, $class)\n";
-            }
-            if (! count($this->nameservers)) {
-                $this->errorstring = 'no nameservers';
-                if ($this->debug) {
-                    echo ";; ERROR: no nameservers\n";
-                }
-                return null;
-            }
-            $packet = $this->make_query_packet($dname, 'AXFR', $class);
-            $packet_data = $packet->data();
-            $ans = $this->send_tcp($packet, $packet_data);
-            return $ans;
-        } else {
-            if ($this->axfr_start($dname, $class) === null) {
-                return null;
-            }
-            $ret = array();
-            while (($ans = $this->axfr_next()) !== null) {
-                if ($ans === null) {
-                    return null;
-                }
-                array_push($ret, $ans);
-            }
-            return $ret;
-        }
-    }
-
-    /* }}} */
-    /* Net_DNS_Resolver::axfr_start($dname, $class = 'IN') {{{ */
-    /**
-     * Sends a packet via TCP to the list of name servers.
-     *
-     * @param string $packet    A packet object to send to the NS list
-     * @param string $packet_data   The data in the packet as returned by
-     *                              the Net_DNS_Packet::data() method
-     * @return object Net_DNS_Packet Returns an answer packet object
-     * @see Net_DNS_Resolver::send_tcp()
-     */
-    function axfr_start($dname, $class = 'IN')
-    {
-        if ($this->debug) {
-            echo ";; axfr_start($dname, $class)\n";
-        }
-
-        if (! count($this->nameservers)) {
-            $this->errorstring = "no nameservers";
-            if ($this->debug) {
-                echo ";; ERROR: axfr_start: no nameservers\n";
-            }
-            return null;
-        }
-        $packet = $this->make_query_packet($dname, "AXFR", $class);
-        $packet_data = $packet->data();
-
-        $timeout = $this->tcp_timeout;
-
-        foreach ($this->nameservers as $ns) {
-            $dstport = $this->port;
-            if ($this->debug) {
-                echo ";; axfr_start($ns:$dstport)\n";
-            }
-            $sock_key = "$ns:$dstport";
-            if (is_resource($this->sockets[$sock_key])) {
-                $sock = &$this->sockets[$sock_key];
-            } else {
-                if (! ($sock = fsockopen($ns, $dstport, $errno,
-                                $errstr, $timeout))) {
-                    $this->errorstring = "connection failed";
-                    if ($this->debug) {
-                        echo ";; ERROR: axfr_start: connection failed: $errstr\n";
-                    }
-                    continue;
-                }
-                $this->sockets[$sock_key] = $sock;
-                unset($sock);
-                $sock = &$this->sockets[$sock_key];
-            }
-            $lenmsg = pack("n", strlen($packet_data));
-            if ($this->debug) {
-                echo ";; sending " . strlen($packet_data) . " bytes\n";
-            }
-
-            if (($sent = fwrite($sock, $lenmsg)) == -1) {
-                $this->errorstring = "length send failed";
-                if ($this->debug) {
-                    echo ";; ERROR: axfr_start: length send failed\n";
-                }
-                continue;
-            }
-
-            if (($sent = fwrite($sock, $packet_data)) == -1) {
-                $this->errorstring = "packet send failed";
-                if ($this->debug) {
-                    echo ";; ERROR: axfr_start: packet data send failed\n";
-                }
-            }
-
-            socket_set_timeout($sock, $timeout);
-
-            $this->_axfr_sock = $sock;
-            $this->_axfr_rr = array();
-            $this->_axfr_soa_count = 0;
-            return $sock;
-        }
-    }
-
-    /* }}} */
-    /* Net_DNS_Resolver::axfr_next() {{{ */
-    /**
-     * Requests the next RR from a existing transfer started with axfr_start
-     *
-     * @return object Net_DNS_RR Returns a Net_DNS_RR object of the next RR
-     *                           from a zone transfer.
-     * @see Net_DNS_Resolver::send_tcp()
-     */
-    function axfr_next()
-    {
-        if (! count($this->_axfr_rr)) {
-            if (! isset($this->_axfr_sock) || ! is_resource($this->_axfr_sock)) {
-                $this->errorstring = 'no zone transfer in progress';
-                return null;
-            }
-            $timeout = $this->tcp_timeout;
-            $buf = $this->read_tcp($this->_axfr_sock, 2, $this->debug);
-            if (! strlen($buf)) {
-                $this->errorstring = 'truncated zone transfer';
-                return null;
-            }
-            $len = unpack('n1len', $buf);
-            $len = $len['len'];
-            if (! $len) {
-                $this->errorstring = 'truncated zone transfer';
-                return null;
-            }
-            $buf = $this->read_tcp($this->_axfr_sock, $len, $this->debug);
-            if ($this->debug) {
-                echo ';; received ' . strlen($buf) . "bytes\n";
-            }
-            if (strlen($buf) != $len) {
-                $this->errorstring = 'expected ' . $len . ' bytes, received ' . strlen($buf);
-                if ($this->debug) {
-                    echo ';; ' . $err . "\n";
-                }
-                return null;
-            }
-            $ans = new Net_DNS_Packet($this->debug);
-            if (! $ans->parse($buf)) {
-                if (! $this->errorstring) {
-                    $this->errorstring = 'unknown error during packet parsing';
-                }
-                return null;
-            }
-            if ($ans->header->ancount < 1) {
-                $this->errorstring = 'truncated zone transfer';
-                return null;
-            }
-            if ($ans->header->rcode != 'NOERROR') {
-                $this->errorstring = 'errorcode ' . $ans->header->rcode . ' returned';
-                return null;
-            }
-            foreach ($ans->answer as $rr) {
-                if ($rr->type == 'SOA') {
-                    if (++$this->_axfr_soa_count < 2) {
-                        array_push($this->_axfr_rr, $rr);
-                    }
-                } else {
-                    array_push($this->_axfr_rr, $rr);
-                }
-            }
-            if ($this->_axfr_soa_count >= 2) {
-                unset($this->_axfr_sock);
-            }
-        }
-        $rr = array_shift($this->_axfr_rr);
-        return $rr;
-    }
-
-    /* }}} */
-    /* Net_DNS_Resolver::read_tcp() {{{ */
-    /**
-     * Unknown - not ported yet
-     */
-    function read_tcp($sock, $nbytes, $debug = 0)
-    {
-        $buf = '';
-        while (strlen($buf) < $nbytes) {
-            $nread = $nbytes - strlen($buf);
-            $read_buf = '';
-            if ($debug) {
-                echo ";; read_tcp: expecting $nread bytes\n";
-            }
-            $read_buf = fread($sock, $nread);
-            if (! strlen($read_buf)) {
-                if ($debug) {
-                    echo ";; ERROR: read_tcp: fread failed\n";
-                }
-                break;
-            }
-            if ($debug) {
-                echo ';; read_tcp: received ' . strlen($read_buf) . " bytes\n";
-            }
-            if (!strlen($read_buf)) {
-                break;
-            }
-
-            $buf .= $read_buf;
-        }
-        return $buf;
-    }
-    /* }}} */
-}
-/* }}} */
-/* VIM settings {{{
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * soft-stop-width: 4
- * c indent on
- * expandtab on
- * End:
- * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et
- * vim<600: sw=4 ts=4
- * }}} */
-?>
+<?php\r
+/**\r
+*  License Information:\r
+*\r
+*  Net_DNS:  A resolver library for PHP\r
+*  Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net\r
+*  Maintainers:\r
+*  Marco Kaiser <bate@php.net>\r
+*  Florian Anderiasch <fa@php.net>\r
+*\r
+* PHP versions 4 and 5\r
+*\r
+* LICENSE: This source file is subject to version 3.01 of the PHP license\r
+* that is available through the world-wide-web at the following URI:\r
+* http://www.php.net/license/3_01.txt.  If you did not receive a copy of\r
+* the PHP License and are unable to obtain it through the web, please\r
+* send a note to license@php.net so we can mail you a copy immediately.\r
+*/\r
+\r
+/* Net_DNS_Resolver object definition {{{ */\r
+/**\r
+ * A DNS Resolver library\r
+ *\r
+ * Resolver library.  Builds a DNS query packet, sends the packet to the\r
+ * server and parses the reponse.\r
+ *\r
+ * @package Net_DNS\r
+ */\r
+class Net_DNS_Resolver\r
+{\r
+    /* class variable definitions {{{ */\r
+    /**\r
+     * An array of all nameservers to query\r
+     *\r
+     * @var array $nameservers\r
+     * @access public\r
+     */\r
+    var $nameservers;\r
+    /**\r
+     * The UDP port to use for the query (default = 53)\r
+     *\r
+     * @var integer $port\r
+     * @access public\r
+     */\r
+    var $port;\r
+    /**\r
+     * The domain in which the resolver client host resides.\r
+     *\r
+     * @var string $domain\r
+     * @access public\r
+     */\r
+    var $domain;\r
+    /**\r
+     * The searchlist to apply to unqualified hosts\r
+     *\r
+     * An array of strings containg domains to apply to unqualified hosts\r
+     * passed to the resolver.\r
+     *\r
+     * @var array $searchlist\r
+     * @access public\r
+     */\r
+    var $searchlist;\r
+    /**\r
+     * The number of seconds between retransmission of unaswered queries\r
+     *\r
+     * @var integer $retrans\r
+     * @access public\r
+     */\r
+    var $retrans;\r
+    /**\r
+     * The number of times unanswered requests should be retried\r
+     *\r
+     * @var integer $retry\r
+     * @access public\r
+     */\r
+    var $retry;\r
+    /**\r
+     * Whether or not to use TCP (Virtual Circuits) instead of UDP\r
+     *\r
+     * If set to 0, UDP will be used unless TCP is required.  TCP is\r
+     * required for questions or responses greater than 512 bytes.\r
+     *\r
+     * @var boolean $usevc\r
+     * @access public\r
+     */\r
+    var $usevc;\r
+    /**\r
+     * Unknown\r
+     */\r
+    var $stayopen;\r
+    /**\r
+     * Ignore TC (truncated) bit\r
+     *\r
+     * If the server responds with the TC bit set on a response, and $igntc\r
+     * is set to 0, the resolver will automatically retransmit the request\r
+     * using virtual circuits (TCP).\r
+     *\r
+     * @access public\r
+     * @var boolean $igntc\r
+     */\r
+    var $igntc;\r
+    /**\r
+     * Recursion Desired\r
+     *\r
+     * Sets the value of the RD (recursion desired) bit in the header. If\r
+     * the RD bit is set to 0, the server will not perform recursion on the\r
+     * request.\r
+     *\r
+     * @var boolean $recurse\r
+     * @access public\r
+     */\r
+    var $recurse;\r
+    /**\r
+     * Unknown\r
+     */\r
+    var $defnames;\r
+    /**\r
+     * Unknown\r
+     */\r
+    var $dnsrch;\r
+    /**\r
+     * Contains the value of the last error returned by the resolver.\r
+     *\r
+     * @var string $errorstring\r
+     * @access public\r
+     */\r
+    var $errorstring;\r
+    /**\r
+     * The origin of the packet.\r
+     *\r
+     * This contains a string containing the IP address of the name server\r
+     * from which the answer was given.\r
+     *\r
+     * @var string $answerfrom\r
+     * @access public\r
+     */\r
+    var $answerfrom;\r
+    /**\r
+     * The size of the answer packet.\r
+     *\r
+     * This contains a integer containing the size of the DNS packet the\r
+     * server responded with.\r
+     *\r
+     * @var string $answersize\r
+     * @access public\r
+     */\r
+    var $answersize;\r
+    /**\r
+     * The number of seconds after which a TCP connection should timeout\r
+     *\r
+     * @var integer $tcp_timeout\r
+     * @access public\r
+     */\r
+    var $tcp_timeout;\r
+    /**\r
+     * The location of the system resolv.conf file.\r
+     *\r
+     * @var string $resolv_conf\r
+     */\r
+    var $resolv_conf = '/etc/resolv.conf';\r
+    /**\r
+     * The name of the user defined resolv.conf\r
+     *\r
+     * The resolver will attempt to look in both the current directory as\r
+     * well as the user's home directory for a user defined resolver\r
+     * configuration file\r
+     *\r
+     * @var string $dotfile\r
+     * @see Net_DNS_Resolver::$confpath\r
+     */\r
+    var $dotfile = '.resolv.conf';\r
+    /**\r
+     * A array of directories to search for the user's resolver config\r
+     *\r
+     * @var string $confpath\r
+     * @see Net_DNS_Resolver::$dotfile\r
+     */\r
+    var $confpath;\r
+    /**\r
+     * debugging flag\r
+     *\r
+     * If set to true (non-zero), debugging code will be displayed as the\r
+     * resolver makes the request.\r
+     *\r
+     * @var boolean $debug;\r
+     * @access public\r
+     */\r
+    var $debug;\r
+    /**\r
+     * use the (currently) experimental PHP socket library\r
+     *\r
+     * If set to true (non-zero), the Resolver will attempt to use the\r
+     * much more effecient PHP sockets extension (if available).\r
+     *\r
+     * @var boolean $useEnhancedSockets;\r
+     * @access public\r
+     */\r
+    var $useEnhancedSockets = true;\r
+    /**\r
+     * An array of sockets connected to a name servers\r
+     *\r
+     * @var array $sockets\r
+     * @access private\r
+     */\r
+    var $sockets;\r
+    /**\r
+     * axfr tcp socket\r
+     *\r
+     * Used to store a PHP socket resource for a connection to a server\r
+     *\r
+     * @var resource $_axfr_sock;\r
+     * @access private\r
+     */\r
+    var $_axfr_sock;\r
+    /**\r
+     * axfr resource record list\r
+     *\r
+     * Used to store a resource record list from a zone transfer\r
+     *\r
+     * @var resource $_axfr_rr;\r
+     * @access private\r
+     */\r
+    var $_axfr_rr;\r
+    /**\r
+     * axfr soa count\r
+     *\r
+     * Used to store the number of soa records received from a zone transfer\r
+     *\r
+     * @var resource $_axfr_soa_count;\r
+     * @access private\r
+     */\r
+    var $_axfr_soa_count;\r
+     /**\r
+     * An array of config files that have been read/parsed already and is used\r
+     * to ensure the usable config files are searched for only once.\r
+     *\r
+     * @var array\r
+     * @access public\r
+     * @see Net_DNS_Resolver::read_config()\r
+     */\r
+    var $parsedfiles = array();\r
+    /**\r
+     * sleep\r
+     *\r
+     * Length of time to wait between reading for respose from server.\r
+     *\r
+     * @var int\r
+     * @access private\r
+     */\r
+    var $sleep;\r
+\r
+    /**\r
+    /* }}} */\r
+    /* class constructor - Net_DNS_Resolver() {{{ */\r
+    /**\r
+     * Initializes the Resolver Object\r
+     *\r
+     * @return Net_DNS_Resolver\r
+     */\r
+    function Net_DNS_Resolver($defaults = array())\r
+    {\r
+        $mydefaults = array(\r
+                'nameservers' => array(),\r
+                'port'        => '53',\r
+                'domain'      => '',\r
+                'searchlist'  => array(),\r
+                'retrans'     => 5,\r
+                'retry'       => 4,\r
+                'usevc'       => 0,\r
+                'stayopen'    => 0,\r
+                'igntc'       => 0,\r
+                'recurse'     => 1,\r
+                'defnames'    => 1,\r
+                'dnsrch'      => 1,\r
+                'debug'       => 0,\r
+                'errorstring' => 'unknown error or no error',\r
+                'answerfrom'  => '',\r
+                'answersize'  => 0,\r
+                'sleep'       => 1000,\r
+                'tcp_timeout' => 120\r
+                );\r
+        foreach ($mydefaults as $k => $v) {\r
+            $this->{$k} = isset($defaults[$k]) ? $defaults[$k] : $v;\r
+        }\r
+        $this->confpath[0] = getenv('HOME');\r
+        $this->confpath[1] = '.';\r
+        $this->res_init();\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_Resolver::res_init() {{{ */\r
+    /**\r
+     * Initalizes the resolver library\r
+     *\r
+     * res_init() searches for resolver library configuration files and\r
+     * initializes the various properties of the resolver object.\r
+     *\r
+     * @see Net_DNS_Resolver::$resolv_conf, Net_DNS_Resolver::$dotfile,\r
+     *      Net_DNS_Resolver::$confpath, Net_DNS_Resolver::$searchlist,\r
+     *      Net_DNS_Resolver::$domain, Net_DNS_Resolver::$nameservers\r
+     * @access public\r
+     */\r
+    function res_init()\r
+    {\r
+        $err = error_reporting(0);\r
+        if ($this->parsedfiles == array()) {\r
+            if (file_exists($this->resolv_conf) && is_readable($this->resolv_conf)) {\r
+                $this->read_config($this->resolv_conf);\r
+                array_push($this->parsedfiles, $this->resolv_conf);\r
+            }\r
+\r
+            foreach ($this->confpath as $dir) {\r
+                $file = $dir.DIRECTORY_SEPARATOR.$this->dotfile;\r
+                if (file_exists($file) && is_readable($file)) {\r
+                    $this->read_config($file);\r
+                    array_push($this->parsedfiles, $file);\r
+                }\r
+            }\r
+        } else {\r
+            foreach($this->parsedfiles as $file) {\r
+                $this->read_config($file);\r
+            }\r
+        }\r
+\r
+        $this->read_env();\r
+\r
+        if (!strlen($this->domain) && sizeof($this->searchlist)) {\r
+            $this->domain = $this->searchlist[0];\r
+        } else if (! sizeof($this->searchlist) && strlen($this->domain)) {\r
+            $this->searchlist = array($this->domain);\r
+        }\r
+        error_reporting($err);\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_Resolver::read_config {{{ */\r
+    /**\r
+     * Reads and parses a resolver configuration file\r
+     *\r
+     * @param string $file The name of the file to open and parse\r
+     */\r
+    function read_config($file)\r
+    {\r
+        if (is_readable($file)) {\r
+            if (! ($f = fopen($file, 'r'))) {\r
+                $this->error = "can't open $file";\r
+            }\r
+        }\r
+\r
+        if (!is_resource($f)) {\r
+            $this->error = "can't open $file";\r
+        } else {\r
+            while (! feof($f)) {\r
+                $line = chop(fgets($f, 10240));\r
+                $line = preg_replace('/(.*)[;#].*/', '\\1', $line);\r
+                if (preg_match("/^[ \t]*$/", $line, $regs)) {\r
+                    continue;\r
+                }\r
+                preg_match("/^[ \t]*([^ \t]+)[ \t]+([^ \t]+)/", $line, $regs);\r
+                $option = $regs[1];\r
+                $value = $regs[2];\r
+\r
+                switch ($option) {\r
+                    case 'nameserver':\r
+                        $nameservers = explode(' ', $regs[2]);\r
+                        foreach ($nameservers as $ns) {\r
+                            $this->nameservers[count($this->nameservers)] = $ns;\r
+                        }\r
+                        break;\r
+                    case 'domain':\r
+                        $this->domain = $regs[2];\r
+                        break;\r
+                    case 'search':\r
+                        $this->searchlist[count($this->searchlist)] = $regs[2];\r
+                        break;\r
+                }\r
+            }\r
+            fclose($f);\r
+        }\r
+    }\r
+\r
+    function set_nameservers($nameservers) {\r
+        if ($nameservers == '') return;\r
+        $this->nameservers = explode(' ', $nameservers);\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_Resolver::read_env() {{{ */\r
+    /**\r
+     * Examines the environment for resolver config information\r
+     */\r
+    function read_env()\r
+    {\r
+        if (getenv('RES_NAMESERVERS')) {\r
+            $this->set_nameservers(getenv('RES_NAMESERVERS'));\r
+        }\r
+\r
+        if (getenv('RES_SEARCHLIST')) {\r
+            $this->searchlist = explode(' ', getenv('RES_SEARCHLIST'));\r
+        }\r
+\r
+        if (getenv('LOCALDOMAIN')) {\r
+            $this->domain = getenv('LOCALDOMAIN');\r
+        }\r
+\r
+        if (getenv('RES_OPTIONS')) {\r
+            $env = explode(' ', getenv('RES_OPTIONS'));\r
+            foreach ($env as $opt) {\r
+                list($name, $val) = explode(':', $opt);\r
+                if ($val == '') {\r
+                    $val = 1;\r
+                }\r
+                $this->{$name} = $val;\r
+            }\r
+        }\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_Resolver::string() {{{ */\r
+    /**\r
+     * Builds a string containing the current state of the resolver\r
+     *\r
+     * Builds formatted string containing the state of the resolver library suited\r
+     * for display.\r
+     *\r
+     * @access public\r
+     */\r
+    function string()\r
+    {\r
+        $state  = ";; Net_DNS_Resolver state:\n";\r
+        $state .= ';;  domain       = ' . $this->domain . "\n";\r
+        $state .= ';;  searchlist   = ' . implode(' ', $this->searchlist) . "\n";\r
+        $state .= ';;  nameservers  = ' . implode(' ', $this->nameservers) . "\n";\r
+        $state .= ';;  port         = ' . $this->port . "\n";\r
+        $state .= ';;  tcp_timeout  = ';\r
+        $state .= ($this->tcp_timeout ? $this->tcp_timeout : 'indefinite') . "\n";\r
+        $state .= ';;  retrans  = ' . $this->retrans . '  ';\r
+        $state .= 'retry    = ' . $this->retry . "\n";\r
+        $state .= ';;  usevc    = ' . $this->usevc . '  ';\r
+        $state .= 'stayopen = ' . $this->stayopen . '    ';\r
+        $state .= 'igntc = ' . $this->igntc . "\n";\r
+        $state .= ';;  defnames = ' . $this->defnames . '  ';\r
+        $state .= 'dnsrch   = ' . $this->dnsrch . "\n";\r
+        $state .= ';;  recurse  = ' . $this->recurse . '  ';\r
+        $state .= 'debug    = ' . $this->debug . "\n";\r
+        return $state;\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_Resolver::nextid() {{{ */\r
+    /**\r
+     * Returns the next request Id to be used for the DNS packet header\r
+     */\r
+    function nextid()\r
+    {\r
+               if (++$GLOBALS['_Net_DNS_packet_id'] > 65535) {\r
+            $GLOBALS['_Net_DNS_packet_id']= 1;\r
+        }\r
+        return $GLOBALS['_Net_DNS_packet_id'];\r
+    }\r
+    /* }}} */\r
+    /* Net_DNS_Resolver::nameservers() {{{ */\r
+    /**\r
+     * Gets or sets the nameservers to be queried.\r
+     *\r
+     * Returns the current nameservers if an array of new nameservers is not\r
+     * given as the argument OR sets the nameservers to the given nameservers.\r
+     *\r
+     * Nameservers not specified by ip address must be able to be resolved by\r
+     * the default settings of a new Net_DNS_Resolver.\r
+     *\r
+     * @access public\r
+     */\r
+    function nameservers($nsa = array())\r
+    {\r
+        $defres = new Net_DNS_Resolver();\r
+\r
+        if (is_array($nsa)) {\r
+            $a = array();\r
+            foreach ($nsa as $ns) {\r
+                if (preg_match('/^(\d+(:?\.\d+){0,3})$/', $ns)) {\r
+                    $a[] = ($ns == 0) ? '0.0.0.0' : $ns;\r
+                } else {\r
+                    $names = array();\r
+                    if (!preg_match('/\./', $ns)) {\r
+                        if (!empty($defres->searchlist)) {\r
+                            foreach ($defres->searchlist as $suffix) {\r
+                                $names[] = $ns .'.' . $suffix;\r
+                            }\r
+                        } elseif (!empty($defres->domain)) {\r
+                            $names[] = $ns .'.'. $defres->domain;\r
+                        }\r
+                    } else {\r
+                        $names[] = $ns;\r
+                    }\r
+                    $packet = $defres->search($ns);\r
+                    if (is_object($packet)) {\r
+                        $addresses = $this->cname_addr($names, $packet);\r
+                        foreach ($addresses as $b) {\r
+                            $a[] = $b;\r
+                        }\r
+                        $a = array_unique($a);\r
+                    }\r
+                }\r
+            }\r
+            if (count($a)) {\r
+                $this->nameservers = $a;\r
+            }\r
+        }\r
+        return $this->nameservers;\r
+    }\r
+\r
+    /* }}} */\r
+    /* not tested -- Net_DNS_Resolver::cname_addr() {{{ */\r
+    function cname_addr($names, $packet)\r
+    {\r
+        $addr = array();\r
+        //my $oct2 = '(?:2[0-4]\d|25[0-5]|[0-1]?\d\d|\d)';\r
+        foreach ($packet->answer as $rr) {\r
+            if (in_array($rr->name, $names)) {\r
+                if ($rr->type == 'CNAME') {\r
+                    $names[] = $rr->cname;\r
+                } elseif ($rr->type == 'A') {\r
+                    // Run a basic taint check.\r
+                    //next RR unless $rr->address =~ m/^($oct2\.$oct2\.$oct2\.$oct2)$/o;\r
+\r
+                    $addr[] = $rr->address;\r
+                }\r
+            }\r
+        }\r
+        return $addr;\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_Resolver::search() {{{ */\r
+    /**\r
+     * Searches nameservers for an answer\r
+     *\r
+     * Goes through the search list and attempts to resolve name based on\r
+     * the information in the search list.\r
+     *\r
+     * @param string $name The name (LHS) of a resource record to query.\r
+     * @param string $type The type of record to query.\r
+     * @param string $class The class of record to query.\r
+     * @return mixed    an object of type Net_DNS_Packet on success,\r
+     *                  or false on failure.\r
+     * @see Net_DNS::typesbyname(), Net_DNS::classesbyname()\r
+     * @access public\r
+     */\r
+    function search($name, $type = 'A', $class = 'IN')\r
+    {\r
+        /*\r
+         * If the name looks like an IP address then do an appropriate\r
+         * PTR query.\r
+         */\r
+        if (preg_match('/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/', $name, $regs)) {\r
+            $name = $regs[4].'.'.$regs[3].'.'.$regs[2].'.'.$regs[1].'.in-addr.arpa.';\r
+            $type = 'PTR';\r
+        }\r
+\r
+        /*\r
+         * If the name contains at least one dot then try it as is first.\r
+         */\r
+        if (strstr($name, '.')) {\r
+            if ($this->debug) {\r
+                echo ";; search($name, $type, $class)\n";\r
+            }\r
+            $ans = $this->query($name, $type, $class);\r
+            if (is_object($ans) && ($ans->header->ancount > 0)) {\r
+                return $ans;\r
+            }\r
+        }\r
+\r
+        /*\r
+         * If the name does not end in a dot then apply the search list.\r
+         */\r
+        $domain = '';\r
+        if ((! preg_match('/\.$/', $name)) && $this->dnsrch) {\r
+            foreach ($this->searchlist as $domain) {\r
+                $newname = "$name.$domain";\r
+                if ($this->debug) {\r
+                    echo ";; search($newname, $type, $class)\n";\r
+                }\r
+                $ans = $this->query($newname, $type, $class);\r
+                if (is_object($ans) && ($ans->header->ancount > 0)) {\r
+                    return $ans;\r
+                }\r
+            }\r
+        }\r
+\r
+        /*\r
+         * Finally, if the name has no dots then try it as is.\r
+         */\r
+        if (strpos($name, '.') === false) {\r
+            if ($this->debug) {\r
+                echo ";; search($name, $type, $class)\n";\r
+            }\r
+            $ans = $this->query($name.'.', $type, $class);\r
+            if (is_object($ans) && ($ans->header->ancount > 0)) {\r
+                return $ans;\r
+            }\r
+        }\r
+\r
+        /*\r
+         * No answer was found.\r
+         */\r
+        return false;\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_Resolver::rawQuery() {{{ */\r
+    /**\r
+     * Queries nameservers for an answer\r
+     *\r
+     * Queries the nameservers listed in the resolver configuration for an\r
+     * answer to a question packet.\r
+     *\r
+     * @param string $name The name (LHS) of a resource record to query.\r
+     * @param string $type The type of record to query.\r
+     * @param string $class The class of record to query.\r
+     * @return mixed an object of type Net_DNS_Packet, regardless of whether the packet\r
+     *               has an answer or not\r
+     * @see Net_DNS::typesbyname(), Net_DNS::classesbyname()\r
+     * @access public\r
+     */\r
+    function rawQuery($name, $type = 'A', $class = 'IN')\r
+    {\r
+        /*\r
+         * If the name does not contain any dots then append the default domain.\r
+         */\r
+        if ((strchr($name, '.') < 0) && $this->defnames) {\r
+            $name .= '.' . $this->domain;\r
+        }\r
+\r
+        /*\r
+         * If the name looks like an IP address then do an appropriate\r
+         * PTR query.\r
+         */\r
+        if (preg_match('/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/', $name, $regs)) {\r
+            $name = $regs[4].'.'.$regs[3].'.'.$regs[2].'.'.$regs[1].'.in-addr.arpa.';\r
+            $type = 'PTR';\r
+        }\r
+\r
+        if ($this->debug) {\r
+            echo ";; query($name, $type, $class)\n";\r
+        }\r
+        $packet = new Net_DNS_Packet($this->debug);\r
+        $packet->buildQuestion($name, $type, $class);\r
+        $packet->header->rd = $this->recurse;\r
+        $ans = $this->send($packet);\r
+        return $ans;\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_Resolver::query() {{{ */\r
+    /**\r
+     * Queries nameservers for an answer\r
+     *\r
+     * Queries the nameservers listed in the resolver configuration for an\r
+     * answer to a question packet.\r
+     *\r
+     * @param string $name The name (LHS) of a resource record to query.\r
+     * @param string $type The type of record to query.\r
+     * @param string $class The class of record to query.\r
+     * @return mixed    an object of type Net_DNS_Packet on success,\r
+     *                  or false on failure.\r
+     * @see Net_DNS::typesbyname(), Net_DNS::classesbyname()\r
+     * @access public\r
+     */\r
+    function query($name, $type = 'A', $class = 'IN')\r
+    {\r
+        $ans = $this->rawQuery($name, $type, $class);\r
+        if (is_object($ans) && $ans->header->ancount > 0) {\r
+            return $ans;\r
+        }\r
+        return false;\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_Resolver::send($packetORname, $qtype = '', $qclass = '') {{{ */\r
+    /**\r
+     * Sends a packet to a nameserver\r
+     *\r
+     * Determines the appropriate communication method (UDP or TCP) and\r
+     * sends a DNS packet to a nameserver.  Use of the this function\r
+     * directly  is discouraged. $packetORname should always be a properly\r
+     * formatted binary DNS packet.  However, it is possible to send a\r
+     * query here and bypass Net_DNS_Resolver::query()\r
+     *\r
+     * @param string $packetORname      A binary DNS packet stream or a\r
+     *                                  hostname to query\r
+     * @param string $qtype     This should not be used\r
+     * @param string $qclass    This should not be used\r
+     * @return object Net_DNS_Packet    An answer packet object\r
+     */\r
+    function send($packetORname, $qtype = '', $qclass = '')\r
+    {\r
+        $packet = $this->make_query_packet($packetORname, $qtype, $qclass);\r
+        $packet_data = $packet->data();\r
+\r
+        if (($this->usevc != 0) || (strlen($packet_data) > 512)) {\r
+            $ans = $this->send_tcp($packet, $packet_data);\r
+        } else {\r
+            $ans = $this->send_udp($packet, $packet_data);\r
+\r
+            if (($ans) && ($ans->header->tc) && ($this->igntc == 0)) {\r
+                if ($this->debug) {\r
+                    echo ";;\n;; packet truncated: retrying using TCP\n";\r
+                }\r
+                $ans = $this->send_tcp($packet, $packet_data);\r
+            }\r
+        }\r
+        return $ans;\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_Resolver::printhex($packet_data) {{{ */\r
+    /**\r
+     * Prints packet data as hex code.\r
+     */\r
+    function printhex($data)\r
+    {\r
+        $data = '  ' . $data;\r
+        $start = 0;\r
+        while ($start < strlen($data)) {\r
+            printf(';; %03d: ', $start);\r
+            for ($ctr = $start; $ctr < $start+16; $ctr++) {\r
+                if ($ctr < strlen($data)) {\r
+                    printf('%02x ', ord($data[$ctr]));\r
+                } else {\r
+                    echo '   ';\r
+                }\r
+            }\r
+            echo '   ';\r
+            for ($ctr = $start; $ctr < $start+16; $ctr++) {\r
+                if (ord($data[$ctr]) < 32 || ord($data[$ctr]) > 127) {\r
+                    echo '.';\r
+                } else {\r
+                    echo $data[$ctr];\r
+                }\r
+            }\r
+            echo "\n";\r
+            $start += 16;\r
+        }\r
+    }\r
+    /* }}} */\r
+    /* Net_DNS_Resolver::send_tcp($packet, $packet_data) {{{ */\r
+    /**\r
+     * Sends a packet via TCP to the list of name servers.\r
+     *\r
+     * @param string $packet    A packet object to send to the NS list\r
+     * @param string $packet_data   The data in the packet as returned by\r
+     *                              the Net_DNS_Packet::data() method\r
+     * @return object Net_DNS_Packet Returns an answer packet object\r
+     * @see Net_DNS_Resolver::send_udp(), Net_DNS_Resolver::send()\r
+     */\r
+    function send_tcp($packet, $packet_data)\r
+    {\r
+        if (! count($this->nameservers)) {\r
+            $this->errorstring = 'no nameservers';\r
+            if ($this->debug) {\r
+                echo ";; ERROR: send_tcp: no nameservers\n";\r
+            }\r
+            return null;\r
+        }\r
+        $timeout = $this->tcp_timeout;\r
+\r
+        foreach ($this->nameservers as $ns) {\r
+            $dstport = $this->port;\r
+            if ($this->debug) {\r
+                echo ";; send_tcp($ns:$dstport)\n";\r
+            }\r
+            $sock_key = "$ns:$dstport";\r
+            if (isset($this->sockets[$sock_key]) && is_resource($this->sockets[$sock_key])) {\r
+                $sock = &$this->sockets[$sock_key];\r
+            } else {\r
+                if (! ($sock = @fsockopen($ns, $dstport, $errno,\r
+                                $errstr, $timeout))) {\r
+                    $this->errorstring = 'connection failed';\r
+                    if ($this->debug) {\r
+                        echo ";; ERROR: send_tcp: connection failed: $errstr\n";\r
+                    }\r
+                    continue;\r
+                }\r
+                $this->sockets[$sock_key] = $sock;\r
+                unset($sock);\r
+                $sock = &$this->sockets[$sock_key];\r
+            }\r
+            $lenmsg = pack('n', strlen($packet_data));\r
+            if ($this->debug) {\r
+                echo ';; sending ' . strlen($packet_data) . " bytes\n";\r
+            }\r
+\r
+            if (($sent = fwrite($sock, $lenmsg)) == -1) {\r
+                $this->errorstring = 'length send failed';\r
+                if ($this->debug) {\r
+                    echo ";; ERROR: send_tcp: length send failed\n";\r
+                }\r
+                continue;\r
+            }\r
+\r
+            if (($sent = fwrite($sock, $packet_data)) == -1) {\r
+                $this->errorstring = 'packet send failed';\r
+                if ($this->debug) {\r
+                    echo ";; ERROR: send_tcp: packet data send failed\n";\r
+                }\r
+            }\r
+\r
+            socket_set_timeout($sock, $timeout);\r
+            $buf = fread($sock, 2);\r
+            $e = socket_get_status($sock);\r
+            /* If $buf is empty, we want to supress errors\r
+               long enough to reach the continue; down the line */\r
+            $len = @unpack('nint', $buf);\r
+            $len = @$len['int'];\r
+            if (!$len) {\r
+                continue;\r
+            }\r
+            $buf = '';\r
+            while (!feof($sock) && (strlen($buf) < $len) ) {\r
+                $buf .= fread($sock, $len-strlen($buf));\r
+            }\r
+            $actual = strlen($buf);\r
+            $this->answerfrom = $ns;\r
+            $this->answersize = $len;\r
+            if ($this->debug) {\r
+                echo ";; received $actual bytes\n";\r
+            }\r
+            if ($actual != $len) {\r
+                $this->errorstring = "expected $len bytes, received $buf";\r
+                if ($this->debug) {\r
+                    echo ';; send_tcp: ' . $this->errorstring;\r
+                }\r
+                continue;\r
+            }\r
+\r
+            $ans = new Net_DNS_Packet($this->debug);\r
+            if (is_null($ans->parse($buf))) {\r
+                continue;\r
+            }\r
+            $this->errorstring = $ans->header->rcode;\r
+            $ans->answerfrom = $this->answerfrom;\r
+            $ans->answersize = $this->answersize;\r
+            return $ans;\r
+        }\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_Resolver::send_udp_no_sock_lib($packet, $packet_data) {{{ */\r
+    /**\r
+     * Sends a packet via UDP to the list of name servers.\r
+     *\r
+     * This function sends a packet to a nameserver.  It is called by\r
+     * send_udp if the sockets PHP extension is not compiled into PHP.\r
+     *\r
+     * @param string $packet    A packet object to send to the NS list\r
+     * @param string $packet_data   The data in the packet as returned by\r
+     *                              the Net_DNS_Packet::data() method\r
+     * @return object Net_DNS_Packet Returns an answer packet object\r
+     * @see Net_DNS_Resolver::send_tcp(), Net_DNS_Resolver::send(),\r
+     *      Net_DNS_Resolver::send_udp(), Net_DNS_Resolver::send_udp_with_sock_lib()\r
+     */\r
+    function send_udp_no_sock_lib($packet, $packet_data)\r
+    {\r
+        $retrans = $this->retrans;\r
+        $timeout = $retrans;\r
+\r
+        /*\r
+         * PHP doesn't have excellent socket support as of this writing.\r
+         * This needs to be rewritten when PHP POSIX socket support is\r
+         * complete.\r
+         * Obviously, this code is MUCH different than the PERL implementation\r
+         */\r
+\r
+        $w = error_reporting(0);\r
+        $ctr = 0;\r
+        // Create a socket handle for each nameserver\r
+        foreach ($this->nameservers as $nameserver) {\r
+            if ($sock[$ctr++] = fsockopen("udp://$nameserver", $this->port)) {\r
+                $peerhost[$ctr-1] = $nameserver;\r
+                $peerport[$ctr-1] = $this->port;\r
+                stream_set_blocking($sock[$ctr-1], 0);\r
+            } else {\r
+                $ctr--;\r
+            }\r
+        }\r
+        error_reporting($w);\r
+\r
+        if ($ctr == 0) {\r
+            $this->errorstring = 'no nameservers';\r
+            return null;\r
+        }\r
+\r
+        $retry = $this->retry;\r
+        for ($i = 0; $i < $retry; $i++, $retrans *= 2,\r
+                $timeout = (int) ($retrans / $ctr)) {\r
+            if ($timeout < 1) {\r
+                $timeout = 1;\r
+            }\r
+\r
+            foreach ($sock as $k => $s) {\r
+                if ($this->debug) {\r
+                    echo ';; send_udp(' . $peerhost[$k] . ':' . $peerport[$k] . '): sending ' . strlen($packet_data) . " bytes\n";\r
+                }\r
+\r
+                if (! fwrite($s, $packet_data)) {\r
+                    if ($this->debug) {\r
+                        echo ";; send error\n";\r
+                    }\r
+                }\r
+\r
+                /*\r
+                 *  Here's where it get's really nasty.  We don't have a select()\r
+                 *  function here, so we have to poll for a response... UGH!\r
+                 */\r
+\r
+                $timetoTO  = time() + (double)microtime() + $timeout;\r
+\r
+                /*\r
+                 * let's sleep for a few hundred microseconds to let the\r
+                 * data come in from the network...\r
+                 */\r
+                $sleep = $this->sleep;\r
+                if ($sleep) {\r
+                    usleep($sleep / 2);\r
+                }\r
+\r
+                $buf = '';\r
+                while (! strlen($buf) && $timetoTO > (time() +\r
+                            (double)microtime())) {\r
+                    stream_set_blocking($s, 0);\r
+                    if ($buf = fread($s, 512)) {\r
+                        $this->answerfrom = $peerhost[$k];\r
+                        $this->answersize = strlen($buf);\r
+                        if ($this->debug) {\r
+                            echo ';; answer from ' . $peerhost[$k] . ':' .\r
+                                $peerport[$k] .  ': ' . strlen($buf) . " bytes\n";\r
+                        }\r
+                        $ans = new Net_DNS_Packet($this->debug);\r
+                        if ($ans->parse($buf)) {\r
+                            if ($ans->header->qr != '1') {\r
+                                continue;\r
+                            }\r
+                            if ($ans->header->id != $packet->header->id) {\r
+                                continue;\r
+                            }\r
+                            $this->errorstring = $ans->header->rcode;\r
+                            $ans->answerfrom = $this->answerfrom;\r
+                            $ans->answersize = $this->answersize;\r
+                            return $ans;\r
+                        }\r
+                    }\r
+                    // Sleep another 1/100th of a second... this sucks...\r
+                    if ($sleep) {\r
+                        usleep($sleep / 2);\r
+                    }\r
+                }\r
+\r
+            }\r
+\r
+            $this->errorstring = 'query timed out';\r
+            return null;\r
+        }\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_Resolver::send_udp_with_sock_lib($packet, $packet_data) {{{ */\r
+    /**\r
+     * Sends a packet via UDP to the list of name servers.\r
+     *\r
+     * This function sends a packet to a nameserver.  It is called by\r
+     * send_udp if the sockets PHP extension is compiled into PHP.\r
+     *\r
+     * @param string $packet    A packet object to send to the NS list\r
+     * @param string $packet_data   The data in the packet as returned by\r
+     *                              the Net_DNS_Packet::data() method\r
+     * @return object Net_DNS_Packet Returns an answer packet object\r
+     * @see Net_DNS_Resolver::send_tcp(), Net_DNS_Resolver::send(),\r
+     *      Net_DNS_Resolver::send_udp(), Net_DNS_Resolver::send_udp_no_sock_lib()\r
+     */\r
+    function send_udp_with_sock_lib($packet, $packet_data)\r
+    {\r
+        $retrans = $this->retrans;\r
+        $timeout = $retrans;\r
+\r
+        //$w = error_reporting(0);\r
+        $ctr = 0;\r
+        // Create a socket handle for each nameserver\r
+        foreach ($this->nameservers as $nameserver) {\r
+            if ((($sock[$ctr++] = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP))) &&\r
+                  socket_connect($sock[$ctr-1], $nameserver, $this->port))\r
+            {\r
+                $peerhost[$ctr-1] = $nameserver;\r
+                $peerport[$ctr-1] = $this->port;\r
+                socket_set_nonblock($sock[$ctr-1]);\r
+            } else {\r
+                $ctr--;\r
+            }\r
+        }\r
+        //error_reporting($w);\r
+\r
+        if ($ctr == 0) {\r
+            $this->errorstring = 'no nameservers';\r
+            return null;\r
+        }\r
+        // Try each nameserver up to $this->retry times\r
+        for ($i = 0; $i < $this->retry; $i++) {\r
+            if ($i !== 0) {\r
+                // Set the timeout for each retry based on the number of\r
+                // nameservers there is a connected socket for.\r
+                $retrans *= 2;\r
+                $timeout = (int) ($retrans / $ctr);\r
+            }\r
+            // Make sure the timeout is at least 1 second\r
+            if ($timeout < 1) {\r
+                $timeout = 1;\r
+            }\r
+\r
+            // Try each nameserver\r
+            foreach ($sock as $k => $s) {\r
+                if ($this->debug) {\r
+                    echo "\n;; send_udp(" . $peerhost[$k] . ':' . $peerport[$k] . '): sending ' . strlen($packet_data) . " bytes\n";\r
+                }\r
+\r
+                if (! socket_write($s, $packet_data)) {\r
+                    if ($this->debug) {\r
+                        echo ";; send error\n";\r
+                    }\r
+                }\r
+\r
+                $set = array($s);\r
+                if ($this->debug) {\r
+                    echo ";; timeout set to $timeout seconds\n";\r
+                }\r
+                $changed = socket_select($set, $w = null, $e = null, $timeout);\r
+                if ($changed) {\r
+                    // Test to see if the connection was refused.  Linux servers will send\r
+                    // an ICMP message which will cause the client's next system call to\r
+                    // return ECONNREFUSED if the server is not listening on the ip:port queried\r
+                    if (socket_get_option($s, SOL_SOCKET, SO_ERROR) == SOCKET_ECONNREFUSED) {\r
+                        // Unix socket connection was refused\r
+                        if ($this->debug) {\r
+                            echo ';; connection to ' . $peerhost[$k] . ':' . $peerport[$k] . " was refused\n";\r
+                        }\r
+                        // Try the next server.\r
+                        continue;\r
+                    }\r
+\r
+                    // Read the response\r
+                    $buf = @socket_read($s, 512);\r
+                    if ($buf === false) {\r
+                        // No data could be read from socket\r
+                        if ($this->debug) {\r
+                            echo ';; no data could be read from ' . $peerhost[$k] . ':' . $peerport[$k] . "\n";\r
+                            echo ';; socket_error: ' . socket_strerror(socket_last_error()) . "\n";\r
+                        }\r
+                        // Reset the non-specific socket error status\r
+                        socket_clear_error();\r
+                        // Try the next server.\r
+                        continue;\r
+                    }\r
+\r
+                    $this->answerfrom = $peerhost[$k];\r
+                    $this->answersize = strlen($buf);\r
+                    if ($this->debug) {\r
+                        echo ';; answer from ' . $peerhost[$k] . ':' .\r
+                            $peerport[$k] .  ': ' . strlen($buf) . " bytes\n";\r
+                    }\r
+                    $ans = new Net_DNS_Packet($this->debug);\r
+                    if ($ans->parse($buf)) {\r
+                        if ($ans->header->qr != '1') {\r
+                            // Ignore packet if it is not a response\r
+                            continue;\r
+                        } elseif ($ans->header->id != $packet->header->id) {\r
+                            // Ignore packet if the response id does not match the query id\r
+                            continue;\r
+                        } else {\r
+                            // Return the DNS response packet\r
+                            $this->errorstring = $ans->header->rcode;\r
+                            $ans->answerfrom = $this->answerfrom;\r
+                            $ans->answersize = $this->answersize;\r
+                            return $ans;\r
+                        }\r
+                    }\r
+                } elseif ($this->debug) {\r
+                    echo ";; query to ". $peerhost[$k] . ':' . $peerport[$k] . " timed out\n";\r
+                }\r
+            }\r
+        }\r
+        $this->errorstring = 'query timed out';\r
+        return null;\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_Resolver::send_udp($packet, $packet_data) {{{ */\r
+    /**\r
+     * Sends a packet via UDP to the list of name servers.\r
+     *\r
+     * This function sends a packet to a nameserver.  send_udp calls\r
+     * either Net_DNS_Resolver::send_udp_no_sock_lib() or\r
+     * Net_DNS_Resolver::send_udp_with_sock_lib() depending on whether or\r
+     * not the sockets extension is compiled into PHP.  Note that using the\r
+     * sockets extension is MUCH more efficient.\r
+     *\r
+     * @param object Net_DNS_Packet $packet A packet object to send to the NS list\r
+     * @param string $packet_data   The data in the packet as returned by\r
+     *                              the Net_DNS_Packet::data() method\r
+     * @return object Net_DNS_Packet Returns an answer packet object\r
+     * @see Net_DNS_Resolver::send_tcp(), Net_DNS_Resolver::send(),\r
+     *      Net_DNS_Resolver::send_udp(), Net_DNS_Resolver::send_udp_no_sock_lib()\r
+     */\r
+    function send_udp($packet, $packet_data)\r
+    {\r
+        if (extension_loaded('sockets') && $this->useEnhancedSockets) {\r
+            if ($this->debug) {\r
+                echo "\n;; using extended PHP sockets\n";\r
+            }\r
+            return $this->send_udp_with_sock_lib($packet, $packet_data);\r
+        } else {\r
+            if ($this->debug) {\r
+                echo "\n;; using simple sockets\n";\r
+            }\r
+            return $this->send_udp_no_sock_lib($packet, $packet_data);\r
+        }\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_Resolver::make_query_packet($packetORname, $type = '', $class = '') {{{ */\r
+    /**\r
+     * Unknown\r
+     */\r
+    function make_query_packet($packetORname, $type = '', $class = '')\r
+    {\r
+        if (is_object($packetORname) && strcasecmp(get_class($packetORname), 'net_dns_packet') == 0) {\r
+            $packet = $packetORname;\r
+        } else {\r
+            $name = $packetORname;\r
+            if ($type == '') {\r
+                $type = 'A';\r
+            }\r
+            if ($class == '') {\r
+                $class = 'IN';\r
+            }\r
+\r
+            /*\r
+             * If the name looks like an IP address then do an appropriate\r
+             * PTR query.\r
+             */\r
+            if (preg_match('/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/', $name, $regs)) {\r
+                $name = $regs[4].'.'.$regs[3].'.'.$regs[2].'.'.$regs[1].'.in-addr.arpa.';\r
+                $type = 'PTR';\r
+            }\r
+\r
+            if ($this->debug) {\r
+                echo ";; query($name, $type, $class)\n";\r
+            }\r
+            $packet = new Net_DNS_Packet($this->debug);\r
+            $packet->buildQuestion($name, $type, $class);\r
+        }\r
+\r
+        $packet->header->rd = $this->recurse;\r
+        return $packet;\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_Resolver::axfr_old($dname, $class = 'IN') {{{ */\r
+    /**\r
+     * Performs an AXFR query (zone transfer) (OLD BUGGY STYLE)\r
+     *\r
+     * This is deprecated and should not be used!\r
+     *\r
+     * @param string $dname The domain (zone) to transfer\r
+     * @param string $class The class in which to look for the zone.\r
+     * @return object Net_DNS_Packet\r
+     * @access public\r
+     */\r
+    function axfr_old($dname, $class = 'IN')\r
+    {\r
+        return $this->axfr($dname, $class, true);\r
+    }\r
+    /* }}} */\r
+    /* Net_DNS_Resolver::axfr($dname, $class = 'IN', $old = false) {{{ */\r
+    /**\r
+     * Performs an AXFR query (zone transfer)\r
+     *\r
+     * Requests a zone transfer from the nameservers. Note that zone\r
+     * transfers will ALWAYS use TCP regardless of the setting of the\r
+     * Net_DNS_Resolver::$usevc flag.  If $old is set to true, Net_DNS requires\r
+     * a nameserver that supports the many-answers style transfer format.  Large\r
+     * zone transfers will not function properly.  Setting $old to true is _NOT_\r
+     * recommended and should only be used for backwards compatibility.\r
+     *\r
+     * @param string $dname The domain (zone) to transfer\r
+     * @param string $class The class in which to look for the zone.\r
+     * @param boolean $old Requires 'old' style many-answer format to function.\r
+                           Used for backwards compatibility only.\r
+     * @return object Net_DNS_Packet\r
+     * @access public\r
+     */\r
+    function axfr($dname, $class = 'IN', $old = false)\r
+    {\r
+        if ($old) {\r
+            if ($this->debug) {\r
+                echo ";; axfr_start($dname, $class)\n";\r
+            }\r
+            if (! count($this->nameservers)) {\r
+                $this->errorstring = 'no nameservers';\r
+                if ($this->debug) {\r
+                    echo ";; ERROR: no nameservers\n";\r
+                }\r
+                return null;\r
+            }\r
+            $packet = $this->make_query_packet($dname, 'AXFR', $class);\r
+            $packet_data = $packet->data();\r
+            $ans = $this->send_tcp($packet, $packet_data);\r
+            return $ans;\r
+        } else {\r
+            if ($this->axfr_start($dname, $class) === null) {\r
+                return null;\r
+            }\r
+            $ret = array();\r
+            while (($ans = $this->axfr_next()) !== null) {\r
+                if ($ans === null) {\r
+                    return null;\r
+                }\r
+                array_push($ret, $ans);\r
+            }\r
+            return $ret;\r
+        }\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_Resolver::axfr_start($dname, $class = 'IN') {{{ */\r
+    /**\r
+     * Sends a packet via TCP to the list of name servers.\r
+     *\r
+     * @param string $packet    A packet object to send to the NS list\r
+     * @param string $packet_data   The data in the packet as returned by\r
+     *                              the Net_DNS_Packet::data() method\r
+     * @return object Net_DNS_Packet Returns an answer packet object\r
+     * @see Net_DNS_Resolver::send_tcp()\r
+     */\r
+    function axfr_start($dname, $class = 'IN')\r
+    {\r
+        if ($this->debug) {\r
+            echo ";; axfr_start($dname, $class)\n";\r
+        }\r
+\r
+        if (! count($this->nameservers)) {\r
+            $this->errorstring = "no nameservers";\r
+            if ($this->debug) {\r
+                echo ";; ERROR: axfr_start: no nameservers\n";\r
+            }\r
+            return null;\r
+        }\r
+        $packet = $this->make_query_packet($dname, "AXFR", $class);\r
+        $packet_data = $packet->data();\r
+\r
+        $timeout = $this->tcp_timeout;\r
+\r
+        foreach ($this->nameservers as $ns) {\r
+            $dstport = $this->port;\r
+            if ($this->debug) {\r
+                echo ";; axfr_start($ns:$dstport)\n";\r
+            }\r
+            $sock_key = "$ns:$dstport";\r
+            if (is_resource($this->sockets[$sock_key])) {\r
+                $sock = &$this->sockets[$sock_key];\r
+            } else {\r
+                if (! ($sock = fsockopen($ns, $dstport, $errno,\r
+                                $errstr, $timeout))) {\r
+                    $this->errorstring = "connection failed";\r
+                    if ($this->debug) {\r
+                        echo ";; ERROR: axfr_start: connection failed: $errstr\n";\r
+                    }\r
+                    continue;\r
+                }\r
+                $this->sockets[$sock_key] = $sock;\r
+                unset($sock);\r
+                $sock = &$this->sockets[$sock_key];\r
+            }\r
+            $lenmsg = pack("n", strlen($packet_data));\r
+            if ($this->debug) {\r
+                echo ";; sending " . strlen($packet_data) . " bytes\n";\r
+            }\r
+\r
+            if (($sent = fwrite($sock, $lenmsg)) == -1) {\r
+                $this->errorstring = "length send failed";\r
+                if ($this->debug) {\r
+                    echo ";; ERROR: axfr_start: length send failed\n";\r
+                }\r
+                continue;\r
+            }\r
+\r
+            if (($sent = fwrite($sock, $packet_data)) == -1) {\r
+                $this->errorstring = "packet send failed";\r
+                if ($this->debug) {\r
+                    echo ";; ERROR: axfr_start: packet data send failed\n";\r
+                }\r
+            }\r
+\r
+            socket_set_timeout($sock, $timeout);\r
+\r
+            $this->_axfr_sock = $sock;\r
+            $this->_axfr_rr = array();\r
+            $this->_axfr_soa_count = 0;\r
+            return $sock;\r
+        }\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_Resolver::axfr_next() {{{ */\r
+    /**\r
+     * Requests the next RR from a existing transfer started with axfr_start\r
+     *\r
+     * @return object Net_DNS_RR Returns a Net_DNS_RR object of the next RR\r
+     *                           from a zone transfer.\r
+     * @see Net_DNS_Resolver::send_tcp()\r
+     */\r
+    function axfr_next()\r
+    {\r
+        if (! count($this->_axfr_rr)) {\r
+            if (! isset($this->_axfr_sock) || ! is_resource($this->_axfr_sock)) {\r
+                $this->errorstring = 'no zone transfer in progress';\r
+                return null;\r
+            }\r
+            $timeout = $this->tcp_timeout;\r
+            $buf = $this->read_tcp($this->_axfr_sock, 2, $this->debug);\r
+            if (! strlen($buf)) {\r
+                $this->errorstring = 'truncated zone transfer';\r
+                return null;\r
+            }\r
+            $len = unpack('n1len', $buf);\r
+            $len = $len['len'];\r
+            if (! $len) {\r
+                $this->errorstring = 'truncated zone transfer';\r
+                return null;\r
+            }\r
+            $buf = $this->read_tcp($this->_axfr_sock, $len, $this->debug);\r
+            if ($this->debug) {\r
+                echo ';; received ' . strlen($buf) . "bytes\n";\r
+            }\r
+            if (strlen($buf) != $len) {\r
+                $this->errorstring = 'expected ' . $len . ' bytes, received ' . strlen($buf);\r
+                if ($this->debug) {\r
+                    echo ';; ' . $err . "\n";\r
+                }\r
+                return null;\r
+            }\r
+            $ans = new Net_DNS_Packet($this->debug);\r
+            if (! $ans->parse($buf)) {\r
+                if (! $this->errorstring) {\r
+                    $this->errorstring = 'unknown error during packet parsing';\r
+                }\r
+                return null;\r
+            }\r
+            if ($ans->header->ancount < 1) {\r
+                $this->errorstring = 'truncated zone transfer';\r
+                return null;\r
+            }\r
+            if ($ans->header->rcode != 'NOERROR') {\r
+                $this->errorstring = 'errorcode ' . $ans->header->rcode . ' returned';\r
+                return null;\r
+            }\r
+            foreach ($ans->answer as $rr) {\r
+                if ($rr->type == 'SOA') {\r
+                    if (++$this->_axfr_soa_count < 2) {\r
+                        array_push($this->_axfr_rr, $rr);\r
+                    }\r
+                } else {\r
+                    array_push($this->_axfr_rr, $rr);\r
+                }\r
+            }\r
+            if ($this->_axfr_soa_count >= 2) {\r
+                unset($this->_axfr_sock);\r
+            }\r
+        }\r
+        $rr = array_shift($this->_axfr_rr);\r
+        return $rr;\r
+    }\r
+\r
+    /* }}} */\r
+    /* Net_DNS_Resolver::read_tcp() {{{ */\r
+    /**\r
+     * Unknown - not ported yet\r
+     */\r
+    function read_tcp($sock, $nbytes, $debug = 0)\r
+    {\r
+        $buf = '';\r
+        while (strlen($buf) < $nbytes) {\r
+            $nread = $nbytes - strlen($buf);\r
+            $read_buf = '';\r
+            if ($debug) {\r
+                echo ";; read_tcp: expecting $nread bytes\n";\r
+            }\r
+            $read_buf = fread($sock, $nread);\r
+            if (! strlen($read_buf)) {\r
+                if ($debug) {\r
+                    echo ";; ERROR: read_tcp: fread failed\n";\r
+                }\r
+                break;\r
+            }\r
+            if ($debug) {\r
+                echo ';; read_tcp: received ' . strlen($read_buf) . " bytes\n";\r
+            }\r
+            if (!strlen($read_buf)) {\r
+                break;\r
+            }\r
+\r
+            $buf .= $read_buf;\r
+        }\r
+        return $buf;\r
+    }\r
+    /* }}} */\r
+}\r
+/* }}} */\r
+/* VIM settings {{{\r
+ * Local variables:\r
+ * tab-width: 4\r
+ * c-basic-offset: 4\r
+ * soft-stop-width: 4\r
+ * c indent on\r
+ * expandtab on\r
+ * End:\r
+ * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et\r
+ * vim<600: sw=4 ts=4\r
+ * }}} */\r
+?>\r
index 67159fc..c75deee 100644 (file)
@@ -162,7 +162,7 @@ class XML_Tree_Morph extends XML_Tree {
                 
             }
             if (@$this->_morphOptions['debug']) {
-                echo "SKIP: {$node->name}\n";
+                echo "SKIP: {$node->name}\n";\r
             }
             
             $parent->children[] = $node;