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

Source for file Question.php

Documentation is available at Question.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_Question object definition {{{ */
  24. /**
  25.  * Builds or parses the QUESTION section of a DNS packet
  26.  *
  27.  * Builds or parses the QUESTION section of a DNS packet
  28.  *
  29.  * @package Net_DNS
  30.  */
  31. {
  32.     /* class variable definitions {{{ */
  33.     var $qname = null;
  34.     var $qtype = null;
  35.     var $qclass = null;
  36.  
  37.     /* }}} */
  38.     /* class constructor Net_DNS_Question($qname, $qtype, $qclass) {{{ */
  39.     function Net_DNS_Question($qname$qtype$qclass)
  40.     {
  41.         $qtype  !is_null($qtype)  strtoupper($qtype)  'ANY';
  42.         $qclass !is_null($qclassstrtoupper($qclass'ANY';
  43.  
  44.         // Check if the caller has the type and class reversed.
  45.         // We are not that kind for unknown types.... :-)
  46.         if ( ( is_null(Net_DNS::typesbyname($qtype)) ||
  47.                is_null(Net_DNS::classesbyname($qtype)) )
  48.           && !is_null(Net_DNS::classesbyname($qclass))
  49.           && !is_null(Net_DNS::typesbyname($qclass)))
  50.         {
  51.             list($qtype$qclass= array($qclass$qtype);
  52.         }
  53.         $qname preg_replace(array('/^\.+/''/\.+$/')''$qname);
  54.         $this->qname = $qname;
  55.         $this->qtype = $qtype;
  56.         $this->qclass = $qclass;
  57.     }
  58.     /* }}} */
  59.     /* Net_DNS_Question::display() {{{*/
  60.     function display()
  61.     {
  62.         echo $this->string("\n";
  63.     }
  64.  
  65.     /*}}}*/
  66.     /* Net_DNS_Question::string() {{{*/
  67.     function string()
  68.     {
  69.         return $this->qname . ".\t" $this->qclass . "\t" $this->qtype;
  70.     }
  71.  
  72.     /*}}}*/
  73.     /* Net_DNS_Question::data(&$packet, $offset) {{{*/
  74.     function data($packet$offset)
  75.     {
  76.         $data $packet->dn_comp($this->qname$offset);
  77.         $data .= pack('n'Net_DNS::typesbyname(strtoupper($this->qtype)));
  78.         $data .= pack('n'Net_DNS::classesbyname(strtoupper($this->qclass)));
  79.         return $data;
  80.     }
  81.  
  82.     /*}}}*/
  83. }
  84. /* }}} */
  85. /* VIM settings{{{
  86.  * Local variables:
  87.  * tab-width: 4
  88.  * c-basic-offset: 4
  89.  * soft-stop-width: 4
  90.  * c indent on
  91.  * End:
  92.  * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et
  93.  * vim<600: sw=4 ts=4
  94.  * }}} */
  95. ?>

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