Net_DNS
[ class tree: Net_DNS ] [ index: Net_DNS ] [ all elements ]

Source for file NAPTR.php

Documentation is available at NAPTR.php

  1. <?php
  2. /*
  3.  *  License Information:
  4.  *
  5.  *    Net_DNS:  A resolver library for PHP
  6.  *    Copyright (c) 2002-2003 Eric Kilfoil eric@ypass.net
  7.  *
  8.  *    This library is free software; you can redistribute it and/or
  9.  *    modify it under the terms of the GNU Lesser General Public
  10.  *    License as published by the Free Software Foundation; either
  11.  *    version 2.1 of the License, or (at your option) any later version.
  12.  *
  13.  *    This library is distributed in the hope that it will be useful,
  14.  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  *    Lesser General Public License for more details.
  17.  *
  18.  *    You should have received a copy of the GNU Lesser General Public
  19.  *    License along with this library; if not, write to the Free Software
  20.  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  21.  */
  22.  
  23. /* Net_DNS_RR_NAPTR definition {{{ */
  24. /**
  25.  * A representation of a resource record of type <b>NAPTR</b>
  26.  *
  27.  * @package Net_DNS
  28.  */
  29. class Net_DNS_RR_NAPTR extends Net_DNS_RR
  30. {
  31.     /* class variable definitions {{{ */
  32.     var $name;
  33.     var $type;
  34.     var $class;
  35.     var $ttl;
  36.     var $rdlength;
  37.     var $rdata;
  38.     var $order;
  39.     var $preference;
  40.     var $flags;
  41.     var $services;
  42.     var $regex;
  43.     var $replacement;
  44.  
  45.     /* }}} */
  46.     /* class constructor - RR(&$rro, $data, $offset = '') {{{ */
  47.     function Net_DNS_RR_NAPTR(&$rro$data$offset '')
  48.     {
  49.         $this->name = $rro->name;
  50.         $this->type = $rro->type;
  51.         $this->class = $rro->class;
  52.         $this->ttl = $rro->ttl;
  53.         $this->rdlength = $rro->rdlength;
  54.         $this->rdata = $rro->rdata;
  55.  
  56.         if ($offset{
  57.             if ($this->rdlength > 0{
  58.                 $a unpack("@$offset/norder/npreference"$data);
  59.                 $offset += 4;
  60.                 list($flags$offsetNet_DNS_Packet::label_extract($data$offset);
  61.                 list($services$offsetNet_DNS_Packet::label_extract($data$offset);
  62.                 list($regex$offsetNet_DNS_Packet::label_extract($data$offset);
  63.                 list($replacement$offsetNet_DNS_Packet::dn_expand($data$offset);
  64.  
  65.                 $this->order = $a['order'];
  66.                 $this->preference = $a['preference'];
  67.                 $this->flags = $flags;
  68.                 $this->services = $services;
  69.                 $this->regex = $regex;
  70.                 $this->replacement = $replacement;
  71.             }
  72.         else {
  73.             $data str_replace('\\\\'chr(1chr(1)$data)/* disguise escaped backslash */
  74.             $data str_replace('\\"'chr(2chr(2)$data)/* disguise \" */
  75.             ereg('([0-9]+)[ \t]+([0-9]+)[ \t]+("[^"]*"|[^ \t]*)[ \t]+("[^"]*"|[^ \t]*)[ \t]+("[^"]*"|[^ \t]*)[ \t]+(.*?)[ \t]*$'$data$regs);
  76.             $this->preference = $regs[1];
  77.             $this->weight $regs[2];
  78.             foreach($regs as $idx => $value{
  79.                 $value str_replace(chr(2chr(2)'\\"'$value);
  80.                 $value str_replace(chr(1chr(1)'\\\\'$value);
  81.                 $regs[$idxstripslashes($value);
  82.             }
  83.             $this->flags = $regs[3];
  84.             $this->services = $regs[4];
  85.             $this->regex = $regs[5];
  86.             $this->replacement = $regs[6];
  87.         }
  88.     }
  89.  
  90.     /* }}} */
  91.     /* Net_DNS_RR_NAPTR::rdatastr() {{{ */
  92.     function rdatastr()
  93.     {
  94.         if ($this->port{
  95.             return(intval($this->order' ' intval($this->preference' "' addslashes($this->flags'" "' 
  96.                    addslashes($this->services'" "' addslashes($this->regex'" "' addslashes($this->replacement'"');
  97.         else return('; no data');
  98.     }
  99.  
  100.     /* }}} */
  101.     /* Net_DNS_RR_NAPTR::rr_rdata($packet, $offset) {{{ */
  102.     function rr_rdata($packet$offset)
  103.     {
  104.         if ($this->preference{
  105.             $rdata  pack('nn'$this->order$this->preference);
  106.             $rdata .= pack('C'strlen($this->flags))    $this->flags;
  107.             $rdata .= pack('C'strlen($this->services)) $this->services;
  108.             $rdata .= pack('C'strlen($this->regex))    $this->regex;
  109.             $rdata .= $packet->dn_comp($this->replacement$offset strlen($rdata));
  110.             return($rdata);
  111.         }
  112.         return(NULL);
  113.     }
  114.  
  115.     /* }}} */
  116. }
  117. /* }}} */
  118. /* VIM settings {{{
  119.  * Local variables:
  120.  * tab-width: 4
  121.  * c-basic-offset: 4
  122.  * soft-stop-width: 4
  123.  * c indent on
  124.  * End:
  125.  * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et
  126.  * vim<600: sw=4 ts=4
  127.  * }}} */
  128. ?>

Documentation generated on Mon, 11 Mar 2019 14:31:29 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.