home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / MX.php < prev    next >
Encoding:
PHP Script  |  2004-03-24  |  2.9 KB  |  103 lines

  1. <?php
  2. /*
  3.  *  License Information:
  4.  *
  5.  *    Net_DNS:  A resolver library for PHP
  6.  *    Copyright (C) 2002 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_MX definition {{{ */
  24. /**
  25.  * A representation of a resource record of type <b>MX</b>
  26.  *
  27.  * @package Net_DNS
  28.  */
  29. class Net_DNS_RR_MX 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 $preference;
  39.     var $exchange;
  40.  
  41.     /* }}} */
  42.     /* class constructor - RR(&$rro, $data, $offset = "") {{{ */
  43.     function Net_DNS_RR_MX(&$rro, $data, $offset = "")
  44.     {
  45.         $this->name = $rro->name;
  46.         $this->type = $rro->type;
  47.         $this->class = $rro->class;
  48.         $this->ttl = $rro->ttl;
  49.         $this->rdlength = $rro->rdlength;
  50.         $this->rdata = $rro->rdata;
  51.  
  52.         if ($offset) {
  53.             if ($this->rdlength > 0) {
  54.                 $a = unpack("@$offset/npreference", $data);
  55.                 $offset += 2;
  56.                 list($exchange, $offset) = Net_DNS_Packet::dn_expand($data, $offset);
  57.                 $this->preference = $a["preference"];
  58.                 $this->exchange = $exchange;
  59.             }
  60.         } else {
  61.             ereg("([0-9]+)[ \t]+(.+)[ \t]*$", $data, $regs);
  62.             $this->preference = $regs[1];
  63.             $this->exchange = ereg_replace("(.*)\.$", "\\1", $regs[2]);
  64.         }
  65.     }
  66.  
  67.     /* }}} */
  68.     /* Net_DNS_RR_MX::rdatastr() {{{ */
  69.     function rdatastr()
  70.     {
  71.         if ($this->preference) {
  72.             return($this->preference . " " . $this->exchange . ".");
  73.         }
  74.         return("; no data");
  75.     }
  76.  
  77.     /* }}} */
  78.     /* Net_DNS_RR_MX::rr_rdata($packet, $offset) {{{ */
  79.     function rr_rdata($packet, $offset)
  80.     {
  81.         if ($this->preference) {
  82.             $rdata = pack("n", $this->preference);
  83.             $rdata .= $packet->dn_comp($this->exchange, $offset + strlen($rdata));
  84.             return($rdata);
  85.         }
  86.         return(NULL);
  87.     }
  88.  
  89.     /* }}} */
  90. }
  91. /* }}} */
  92. /* VIM settings {{{
  93.  * Local variables:
  94.  * tab-width: 4
  95.  * c-basic-offset: 4
  96.  * soft-stop-width: 4
  97.  * c indent on
  98.  * End:
  99.  * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et
  100.  * vim<600: sw=4 ts=4
  101.  * }}} */
  102. ?>
  103.