~edb/quam-plures/cronjob_stuff

« back to all changes in this revision

Viewing changes to qp_plugins/basic_antispam_plugin/Net/DNS/RR/SRV.php

  • Committer: EdB
  • Date: 2011-03-08 04:39:47 UTC
  • mfrom: (7592.1.1 quam-plures)
  • Revision ID: 1912webworks@gmail.com-20110308043947-apiklf384cgnwb7s
new stuff in core now here - woohoo!

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
*  Maintainers:
 
8
*  Marco Kaiser <bate@php.net>
 
9
*  Florian Anderiasch <fa@php.net>
 
10
*
 
11
* PHP versions 4 and 5
 
12
*
 
13
* LICENSE: This source file is subject to version 3.01 of the PHP license
 
14
* that is available through the world-wide-web at the following URI:
 
15
* http://www.php.net/license/3_01.txt.  If you did not receive a copy of
 
16
* the PHP License and are unable to obtain it through the web, please
 
17
* send a note to license@php.net so we can mail you a copy immediately.
 
18
*/
 
19
 
 
20
/* Net_DNS_RR_SRV definition {{{ */
 
21
/**
 
22
 * A representation of a resource record of type <b>SRV</b>
 
23
 *
 
24
 * @package Net_DNS
 
25
 */
 
26
class Net_DNS_RR_SRV extends Net_DNS_RR
 
27
{
 
28
    /* class variable definitions {{{ */
 
29
    var $name;
 
30
    var $type;
 
31
    var $class;
 
32
    var $ttl;
 
33
    var $rdlength;
 
34
    var $rdata;
 
35
    var $preference;
 
36
    var $weight;
 
37
    var $port;
 
38
    var $target;
 
39
 
 
40
    /* }}} */
 
41
    /* class constructor - RR(&$rro, $data, $offset = '') {{{ */
 
42
    function Net_DNS_RR_SRV(&$rro, $data, $offset = '')
 
43
    {
 
44
        $this->name = $rro->name;
 
45
        $this->type = $rro->type;
 
46
        $this->class = $rro->class;
 
47
        $this->ttl = $rro->ttl;
 
48
        $this->rdlength = $rro->rdlength;
 
49
        $this->rdata = $rro->rdata;
 
50
 
 
51
        if ($offset) {
 
52
            if ($this->rdlength > 0) {
 
53
                $a = unpack("@$offset/npreference/nweight/nport", $data);
 
54
                $offset += 6;
 
55
                $packet = new Net_DNS_Packet();
 
56
 
 
57
                list($target, $offset) = $packet->dn_expand($data, $offset);
 
58
                $this->preference = $a['preference'];
 
59
                $this->weight = $a['weight'];
 
60
                $this->port = $a['port'];
 
61
                $this->target = $target;
 
62
            }
 
63
        } elseif (is_array($data)) {
 
64
            $this->preference = $data['preference'];
 
65
            $this->weight = $data['weight'];
 
66
            $this->port = $data['port'];
 
67
            $this->target = $data['target'];
 
68
        } else {
 
69
            preg_match("/([0-9]+)[ \t]+([0-9]+)[ \t]+([0-9]+)[ \t]+(.+)[ \t]*$/", $data, $regs);
 
70
            $this->preference = $regs[1];
 
71
            $this->weight = $regs[2];
 
72
            $this->port = $regs[3];
 
73
            $this->target = preg_replace('/(.*)\.$/', '\\1', $regs[4]);
 
74
        }
 
75
    }
 
76
 
 
77
    /* }}} */
 
78
    /* Net_DNS_RR_SRV::rdatastr() {{{ */
 
79
    function rdatastr()
 
80
    {
 
81
        if ($this->port) {
 
82
            return intval($this->preference) . ' ' . intval($this->weight) . ' ' . intval($this->port) . ' ' . $this->target . '.';
 
83
        }
 
84
        return '; no data';
 
85
    }
 
86
 
 
87
    /* }}} */
 
88
    /* Net_DNS_RR_SRV::rr_rdata($packet, $offset) {{{ */
 
89
    function rr_rdata($packet, $offset)
 
90
    {
 
91
        if (isset($this->preference)) {
 
92
            $rdata = pack('nnn', $this->preference, $this->weight, $this->port);
 
93
            $rdata .= $packet->dn_comp($this->target, $offset + strlen($rdata));
 
94
            return $rdata;
 
95
        }
 
96
        return null;
 
97
    }
 
98
 
 
99
    /* }}} */
 
100
}
 
101
/* }}} */
 
102
/* VIM settings {{{
 
103
 * Local variables:
 
104
 * tab-width: 4
 
105
 * c-basic-offset: 4
 
106
 * soft-stop-width: 4
 
107
 * c indent on
 
108
 * End:
 
109
 * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et
 
110
 * vim<600: sw=4 ts=4
 
111
 * }}} */
 
112
?>