• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Net_DNS_Resolver类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Net_DNS_Resolver的典型用法代码示例。如果您正苦于以下问题:PHP Net_DNS_Resolver类的具体用法?PHP Net_DNS_Resolver怎么用?PHP Net_DNS_Resolver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Net_DNS_Resolver类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: lookup_hosts

 public static function lookup_hosts($service, $location, $domain)
 {
     $servers = array();
     $ttl = false;
     $host = "_{$service}._udp.{$location}.{$domain}";
     echo "Service: {$service}, Location: {$location}, Domain: {$domain}\r\nHost: {$host}\r\n";
     $servers = cache::cache_get($host);
     if ($servers === false) {
         echo "Cache Status: MISS\r\n";
         $resolver = new Net_DNS_Resolver();
         $response = $resolver->query($host, 'SRV');
         if ($response) {
             foreach ($response->answer as $rr) {
                 if ($ttl !== false) {
                     $ttl = $rr->ttl;
                 }
                 //$servers[$rr->preference][$rr->weight][] = $rr->target.":".$rr->port;
                 $servers[$rr->preference][$rr->weight][] = $rr->target;
             }
         }
         cache::cache_put($host, $servers, $ttl);
     } else {
         echo "Cache Status: HIT\r\n";
     }
     return $servers;
 }
开发者ID:johann8384,项目名称:srv3,代码行数:26,代码来源:test_server.php


示例2: getHostForLookup

 /**
  * Get host to lookup. Lookup a host if neccessary and get the
  * complete FQDN to lookup.
  *
  * @param string $host      Host OR IP to use for building the lookup.
  * @param string $blacklist Blacklist to use for building the lookup.
  * @param string $isIP      is IP adress?
  *
  * @return string Ready to use host to lookup
  */
 public static function getHostForLookup($hostname, $blacklist, $isIP = true)
 {
     if ($isIP && filter_var($hostname, FILTER_VALIDATE_IP)) {
         return self::buildLookUpIP($hostname, $blacklist);
     }
     if ($isIP && !filter_var($hostname, FILTER_VALIDATE_IP)) {
         $resolver = new \Net_DNS_Resolver();
         $response = @$resolver->query($hostname);
         $ip = isset($response->answer[0]->address) ? $response->answer[0]->address : null;
         if (!$ip || !filter_var($ip, FILTER_VALIDATE_IP)) {
             return null;
         }
         return self::buildLookUpIP($ip, $blacklist);
     }
     return self::buildLookUpHost($hostname, $blacklist);
 }
开发者ID:webeith,项目名称:dnsbl,代码行数:26,代码来源:Utils.php


示例3: olc_get_ip_info

function olc_get_ip_info(&$smarty)
{
    if (SHOW_IP_LOG == TRUE_STRING_S) {
        $customers_ip_text = 'CUSTOMERS_IP';
        $ip = $_SESSION[$customers_ip_text];
        if (!isset($ip)) {
            $ip = $_SERVER['REMOTE_ADDR'];
            if (strlen($ip) > 0) {
                if (function_exists("gethostbyaddr")) {
                    //Get host-name for IP by built-in PHP-function
                    $host = gethostbyaddr($ip);
                }
                if (strlen($host) == 0) {
                    //"gethostbyaddr" does not work always, so try "Net_DNS" first
                    define('FILENAME_NET_DNS', '"Net/DNS.php');
                    if (file_exists(FILENAME_NET_DNS)) {
                        require_once FILENAME_NET_DNS;
                        $res = new Net_DNS_Resolver();
                        $ans = $res->search($ip, "MX");
                        if ($ans) {
                            $host = $ans->answer[0]->ptrdname;
                        }
                    }
                }
                if (strlen($host) > 0) {
                    if ($host != $ip) {
                        $ip .= LPAREN . $host . RPAREN;
                    }
                }
                $ip .= ' -- Datum: ' . date("d.m.Y H:i:s");
                $_SESSION[$customers_ip_text] = $ip;
            }
        }
        if ($smarty) {
            $smarty->assign('IP_LOG', true);
            $smarty->assign($customers_ip_text, $ip);
        }
    }
}
开发者ID:BackupTheBerlios,项目名称:ol-commerce-svn,代码行数:39,代码来源:145.php


示例4: connect

	function connect($server_host,$server_port=5222,$connect_timeout=null,$alternate_ip=false) {

		if (is_null($connect_timeout)) $connect_timeout = DEFAULT_CONNECT_TIMEOUT;
		$connector = $this->_connector;

 		if (!$alternate_ip && class_exists('Net_DNS_Resolver')) {
			// Perform SRV record lookups
			$ndr = new Net_DNS_Resolver();
			$answer = $ndr->query("_xmpp-client._tcp.".$server_host,"SRV");
			if ($answer && count($answer->answer) > 0 && !empty($answer->answer[0]->target)) {
				$alternate_ip = $answer->answer[0]->target;
			}
			unset($answer);
			unset($ndr);
 		}

		$this->_connection = &new $connector();
		$this->_server_host = $server_host;
		$this->_server_port = $server_port;
		$this->_server_ip = $alternate_ip ? $alternate_ip : $server_host;
		$this->_connect_timeout = $connect_timeout;

		$this->roster = array();
		$this->services = array();

		$this->_is_win32 = (substr(strtolower(php_uname()),0,3)=="win");
		$this->_sleep_func = $this->_is_win32 ? "win32_sleep" : "posix_sleep";

		return $this->_connect_socket();
	}
开发者ID:nguyennamtien,项目名称:DXMPP,代码行数:30,代码来源:class_Jabber.php


示例5: queryMX

 /**
  * Query DNS server for MX entries
  * @return
  */
 public function queryMX($domain)
 {
     $hosts = array();
     $mxweights = array();
     if (function_exists('getmxrr')) {
         getmxrr($domain, $hosts, $mxweights);
     } else {
         // windows, we need Net_DNS: http://pear.php.net/package/Net_DNS
         require_once 'Net/DNS.php';
         $resolver = new Net_DNS_Resolver();
         $resolver->debug = $this->debug;
         // nameservers to query
         $resolver->nameservers = $this->nameservers;
         $resp = $resolver->query($domain, 'MX');
         if ($resp) {
             foreach ($resp->answer as $answer) {
                 $hosts[] = $answer->exchange;
                 $mxweights[] = $answer->preference;
             }
         }
     }
     $mxs = array_combine($hosts, $mxweights);
     asort($mxs, SORT_NUMERIC);
     return $mxs;
 }
开发者ID:lavoiesl,项目名称:smtp-email-validator,代码行数:29,代码来源:Validator.php


示例6: getHostForLookup

 /** 
  * Get host to lookup. Lookup a host if neccessary and get the
  * complete FQDN to lookup.
  *
  * @param  string Host OR IP to use for building the lookup.
  * @param  string Blacklist to use for building the lookup.
  * @access protected
  * @return string Ready to use host to lookup
  */
 function getHostForLookup($host, $blacklist)
 {
     // Currently only works for v4 addresses.
     if (!Net_CheckIP::check_ip($host)) {
         $resolver = new Net_DNS_Resolver();
         $response = $resolver->query($host);
         $ip = $response->answer[0]->address;
     } else {
         $ip = $host;
     }
     return $this->buildLookUpHost($ip, $blacklist);
 }
开发者ID:ookwudili,项目名称:chisimba,代码行数:21,代码来源:DNSBL.php


示例7: validate_email

function validate_email($email, $checkserver = 'n')
{
    $valid_syntax = eregi("^[_a-z0-9\\+\\.\\-]+@[_a-z0-9\\.\\-]+\\.[a-z]{2,4}\$", $email);
    if (!$valid_syntax) {
        return false;
    } elseif ($checkserver == 'y') {
        include_once 'Net/DNS.php';
        $resolver = new Net_DNS_Resolver();
        $domain = substr(strstr($email, '@'), 1);
        $answer = $resolver->query($domain, 'MX');
        if (!$answer) {
            return false;
        } else {
            foreach ($answer->answer as $server) {
                $mxserver[$server->preference] = $server->exchange;
            }
            krsort($mxserver);
            foreach ($mxserver as $server) {
                $test = fsockopen($server, 25, $errno, $errstr, 15);
                if ($test) {
                    fclose($test);
                    return true;
                }
                fclose($test);
            }
            return false;
        }
    } else {
        return true;
    }
}
开发者ID:Kraiany,项目名称:kraiany_site_docker,代码行数:31,代码来源:tikilib.php


示例8: queryMX

 /**
  * Query DNS server for MX entriesg
  * @return 
  */
 function queryMX($domain)
 {
     $hosts = array();
     $mxweights = array();
     if (function_exists('getmxrr')) {
         getmxrr($domain, $hosts, $mxweights);
     } else {
         // windows, we need Net_DNS
         require_once 'Net/DNS.php';
         $resolver = new Net_DNS_Resolver();
         $resolver->debug = $this->debug;
         // nameservers to query
         $resolver->nameservers = $this->nameservers;
         $resp = $resolver->query($domain, 'MX');
         if ($resp) {
             foreach ($resp->answer as $answer) {
                 $hosts[] = $answer->exchange;
                 $mxweights[] = $answer->preference;
             }
         }
     }
     return array($hosts, $mxweights);
 }
开发者ID:dxxd116,项目名称:php-smtp-email-validation,代码行数:27,代码来源:smtp_validateEmail.class.php


示例9: Resolve

 /**
  * @brief Resolve a LSID using the DNS
  *
  * 
  */
 function Resolve($lsid_to_resolve)
 {
     $result = true;
     $this->lsid = new LSID($lsid_to_resolve);
     $ndr = new Net_DNS_Resolver();
     $answer = $ndr->search("_lsid._tcp." . $this->lsid->getAuthority(), "SRV");
     if ($answer == false) {
         $result = false;
     } else {
         if ($this->debug) {
             echo "<pre>";
             print_r($answer->answer);
             echo "</pre>";
         }
     }
     $this->server = $answer->answer[0]->target;
     $this->port = $answer->answer[0]->port;
     if ($this->report) {
         echo "<p>";
         echo "Authority for <strong>{$lsid_to_resolve}</strong> ";
         if ($result) {
             echo "is located at: ", $this->server, ":", $this->port;
         } else {
             echo "not found";
         }
         echo "</p>";
     }
     return $result;
 }
开发者ID:rdmpage,项目名称:bioguid,代码行数:34,代码来源:class_lsid.php


示例10: getHostForLookup

 /** 
  * Get host to lookup. Lookup a host if neccessary and get the
  * complete FQDN to lookup.
  *
  * @param string $host      Host OR IP to use for building the lookup.
  * @param string $blacklist Blacklist to use for building the lookup.
  *
  * @access protected
  * @return string Ready to use host to lookup
  */
 protected function getHostForLookup($host, $blacklist)
 {
     // Currently only works for v4 addresses.
     if (filter_var($host, FILTER_VALIDATE_IP)) {
         $ip = $host;
     } else {
         $resolver = new Net_DNS_Resolver();
         $response = $resolver->query($host);
         $ip = isset($response->answer[0]->address) ? $response->answer[0]->address : null;
     }
     if (!$ip || !filter_var($ip, FILTER_VALIDATE_IP)) {
         return;
     }
     return $this->buildLookUpHost($ip, $blacklist);
 }
开发者ID:jimjag,项目名称:Serendipity,代码行数:25,代码来源:DNSBL.php


示例11: validateEmail

function validateEmail($email, $domainCheck = false, $verify = false, $probe_address='', $helo_address='', $return_errors=false) {
	global $debug;
	$server_timeout = 180; # timeout in seconds. Some servers deliberately wait a while (tarpitting)
	if($debug) {echo "<pre>";}
	# Check email syntax with regex
	if (preg_match('/^([a-zA-Z0-9\._\+-]+)\@((\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,7}|[0-9]{1,3})(\]?))$/', $email, $matches)) {
		$user = $matches[1];
		$domain = $matches[2];
		# Check availability of  MX/A records
		if ($domainCheck) {
			if(function_exists('checkdnsrr')) {
				# Construct array of available mailservers
				if(getmxrr($domain, $mxhosts, $mxweight)) {
					for($i=0;$i<count($mxhosts);$i++){
						$mxs[$mxhosts[$i]] = $mxweight[$i];
					}
					asort($mxs);
					$mailers = array_keys($mxs);
				} elseif(checkdnsrr($domain, 'A')) {
					$mailers[0] = gethostbyname($domain);
				} else {
					$mailers=array();
				}
			} else {
			# DNS functions do not exist - we are probably on Win32.
			# This means we have to resort to other means, like the Net_DNS PEAR class.
			# For more info see http://pear.php.net
			# For this you also need to enable the mhash module (lib_mhash.dll).
			# Another way of doing this is by using a wrapper for Win32 dns functions like
			# the one descrieb at http://px.sklar.com/code.html/id=1304
				require_once 'Net/DNS.php';
				$resolver = new Net_DNS_Resolver();
				# Workaround for bug in Net_DNS, you have to explicitly tell the name servers
				#
				# ***********  CHANGE THIS TO YOUR OWN NAME SERVERS **************
				$resolver->nameservers = array ('217.149.196.6', '217.149.192.6');
				
				$mx_response = $resolver->query($domain, 'MX');
				$a_response  = $resolver->query($domain, 'A');
				if ($mx_response) {
					foreach ($mx_response->answer as $rr) {
							$mxs[$rr->exchange] = $rr->preference;
					}
					asort($mxs);
					$mailers = array_keys($mxs);
				} elseif($a_response) {
					$mailers[0] = gethostbyname($domain);
				} else {
					$mailers = array();
				}
				
			}
			
			$total = count($mailers);
			# Query each mailserver
			if($total > 0 && $verify) {
				# Check if mailers accept mail
				for($n=0; $n < $total; $n++) {
					# Check if socket can be opened
					if($debug) { echo "Checking server $mailers[$n]...\n";}
					$connect_timeout = $server_timeout;
					$errno = 0;
					$errstr = 0;
					# Try to open up socket
					if($sock = @fsockopen($mailers[$n], 25, $errno , $errstr, $connect_timeout)) {
						$response = fgets($sock);
						if($debug) {echo "Opening up socket to $mailers[$n]... Succes!\n";}
						stream_set_timeout($sock, 30);
						$meta = stream_get_meta_data($sock);
						if($debug) { echo "$mailers[$n] replied: $response\n";}
						$cmds = array(
							"HELO $helo_address",
							"MAIL FROM: <$probe_address>",
							"RCPT TO: <$email>",
							"QUIT",
						);
						# Hard error on connect -> break out
						# Error means 'any reply that does not start with 2xx '
						if(!$meta['timed_out'] && !preg_match('/^2\d\d[ -]/', $response)) {
							$error = "Error: $mailers[$n] said: $response\n";
							break;
						}
						foreach($cmds as $cmd) {
							$before = microtime(true);
							fputs($sock, "$cmd\r\n");
							$response = fgets($sock, 4096);
							$t = 1000*(microtime(true)-$before);
							if($debug) {echo htmlentities("$cmd\n$response") . "(" . sprintf('%.2f', $t) . " ms)\n";}
							if(!$meta['timed_out'] && preg_match('/^5\d\d[ -]/', $response)) {
								$error = "Unverified address: $mailers[$n] said: $response";
								break 2;
							}
						}
						fclose($sock);
						if($debug) { echo "Succesful communication with $mailers[$n], no hard errors, assuming OK";}
						break;
					} elseif($n == $total-1) {
						$error = "None of the mailservers listed for $domain could be contacted";
					}
				}
//.........这里部分代码省略.........
开发者ID:Naddiseo,项目名称:WW2Game,代码行数:101,代码来源:Email.php


示例12: dns_get_ns

 function dns_get_ns($hostname, &$ns_array)
 {
     // 答えを返すところをクリアしておく
     if (!empty($ns_array)) {
         while (array_pop($ns_array)) {
         }
     }
     // まだキャッシュがなければ以前に得た結果のキャッシュファイルを読み込む
     if (empty($this->dns_get_ns_cache)) {
         $fp = fopen(DATA_HOME . SPAM_FILTER_DNSGETNS_CACHE_FILE, "a+") or die_message('Cannot read dns_get_ns cache file: ' . SPAM_FILTER_DNSGETNS_CACHE_FILE . "\n");
         flock($fp, LOCK_SH);
         while ($csv = fgetcsv($fp, 1000, ",")) {
             $host = array_shift($csv);
             $time = $csv[0];
             if ($time + SPAM_FILTER_DNSGETNS_CACHE_DAY * 24 * 60 * 60 < time()) {
                 continue;
             }
             // 古すぎる情報は捨てる
             $this->dns_get_ns_cache["{$host}"] = $csv;
         }
         flock($fp, LOCK_UN);
         fclose($fp);
     }
     // キャッシュの結果に入ってるならそこから結果を引いて返す
     $cache = $this->dns_get_ns_cache["{$hostname}"];
     if (!empty($cache)) {
         $time = array_shift($cache);
         foreach ($cache as $ns) {
             $ns_array[] = $ns;
         }
         return TRUE;
     }
     // ホスト名を上から一つづつ減らしてNSが得られるまで試す
     // 例: www.subdomain.example.com→subdomain.example.com→example.com
     $domain_array = explode(".", $hostname);
     $ns_found = FALSE;
     do {
         $domain = implode(".", $domain_array);
         // 環境で使える手段に合わせてドメインのNSを得る
         if (function_exists('dns_get_record')) {
             // 内部関数 dns_get_record 使える場合
             $lookup = dns_get_record($domain, DNS_NS);
             if (!empty($lookup)) {
                 foreach ($lookup as $record) {
                     $ns_array[] = $record['target'];
                 }
                 $ns_found = TRUE;
             }
         } else {
             if (include_once 'Net/DNS.php') {
                 // PEARのDNSクラスが使える場合
                 $resolver = new Net_DNS_Resolver();
                 if (SPAM_FILTER_IS_WINDOWS) {
                     $resolver->nameservers[0] = $this->getDNSServer();
                 }
                 $response = $resolver->query($domain, 'NS');
                 if ($response) {
                     foreach ($response->answer as $rr) {
                         if ($rr->type == "NS") {
                             $ns_array[] = $rr->nsdname;
                         } else {
                             if ($rr->type == "CNAME") {
                                 // CNAMEされてるときは、そっちを再帰で引く
                                 $this->dns_get_ns($rr->rdatastr(), $ns_array);
                             }
                         }
                     }
                     $ns_found = TRUE;
                 }
             } else {
                 // PEARも使えない場合、外部コマンドnslookupによりNSを取得
                 is_executable(SPAM_FILTER_NSLOOKUP_PATH) or die_message("Cannot execute nslookup. see NSLOOKUP_PATH setting.\n");
                 @exec(SPAM_FILTER_NSLOOKUP_PATH . " -type=ns " . $domain, $lookup);
                 foreach ($lookup as $line) {
                     if (preg_match('/\\s*nameserver\\s*=\\s*(\\S+)$/', $line, $ns) || preg_match('/\\s*origin\\s*=\\s*(\\S+)$/', $line, $ns) || preg_match('/\\s*primary name server\\s*=\\s*(\\S+)$/', $line, $ns)) {
                         $ns_array[] = $ns[1];
                         $ns_found = TRUE;
                     }
                 }
             }
         }
     } while (!$ns_found && array_shift($domain_array) != NULL);
     // NSが引けていたら、結果をキャッシュに入れて保存
     if ($ns_found) {
         // 結果をキャッシュに登録
         $cache = $ns_array;
         array_unshift($cache, time());
         // 引いた時間も保持
         $this->dns_get_ns_cache["{$hostname}"] = $cache;
         // キャッシュをファイルに保存
         $fp = fopen(DATA_HOME . SPAM_FILTER_DNSGETNS_CACHE_FILE, "w") or die_message("Cannot write dns_get_ns cache file: " . SPAM_FILTER_DNSGETNS_CACHE_FILE . "\n");
         flock($fp, LOCK_EX);
         foreach ($this->dns_get_ns_cache as $host => $cachedata) {
             $csv = $host;
             foreach ($cachedata as $data) {
                 $csv .= "," . $data;
             }
             $csv .= "\n";
             fputs($fp, $csv);
         }
//.........这里部分代码省略.........
开发者ID:stealthinu,项目名称:pukiwiki_spam_filter,代码行数:101,代码来源:spam_filter.php


示例13: validateEmail


//.........这里部分代码省略.........
                            return false;
                        } else {
                            return true;
                        }
                    }
                }
            }
        }
        # Check availability of  MX/A records
        if ($domainCheck) {
            if (function_exists('checkdnsrr')) {
                # Construct array of available mailservers
                getmxrr($domain, $mxhosts, $mxweight);
                if (count($mxhosts) > 0) {
                    for ($i = 0; $i < count($mxhosts); $i++) {
                        $mxs[$mxhosts[$i]] = $mxweight[$i];
                    }
                    asort($mxs);
                    $mailers = array_keys($mxs);
                    # No MX found, use A
                } elseif (checkdnsrr($domain, 'A')) {
                    $mailers[0] = gethostbyname($domain);
                } else {
                    $mailers = array();
                }
            } else {
                # DNS functions do not exist - we are probably on Win32.
                # This means we have to resort to other means, like the Net_DNS PEAR class.
                # For more info see http://pear.php.net
                # For this you also need to enable the mhash module (lib_mhash.dll).
                # Another way of doing this is by using a wrapper for Win32 dns functions like
                # the one descrieb at http://px.sklar.com/code.html/id=1304
                require_once 'Net/DNS.php';
                $resolver = new Net_DNS_Resolver();
                # Workaround for bug in Net_DNS, you have to explicitly tell the name servers
                #
                # ***********  CHANGE THIS TO YOUR OWN NAME SERVERS **************
                $resolver->nameservers = array('217.149.196.6', '217.149.192.6');
                $mx_response = $resolver->query($domain, 'MX');
                $a_response = $resolver->query($domain, 'A');
                if ($mx_response) {
                    foreach ($mx_response->answer as $rr) {
                        $mxs[$rr->exchange] = $rr->preference;
                    }
                    asort($mxs);
                    $mailers = array_keys($mxs);
                } elseif ($a_response) {
                    $mailers[0] = gethostbyname($domain);
                } else {
                    $mailers = array();
                }
            }
            $total = count($mailers);
            # Query each mailserver
            if ($total > 0 && $verify) {
                # Check if mailers accept mail
                for ($n = 0; $n < $total; $n++) {
                    # Check if socket can be opened
                    if ($debug) {
                        echo "Checking server {$mailers[$n]}...\n";
                    }
                    $errno = 0;
                    $errstr = 0;
                    # Try to open up TCP socket
                    if ($sock = @fsockopen($mailers[$n], 25, $errno, $errstr, $tcp_connect_timeout)) {
                        $response = fread($sock, 8192);
开发者ID:bogiesoft,项目名称:hotelmis-ota,代码行数:67,代码来源:validate_email.php


示例14: getdnsattributes_VMWO

function getdnsattributes_VMWO($l, $ip)
{
    $r = new Net_DNS_Resolver();
    $r->nameservers = array("ws1.maxmind.com");
    $p = $r->search($l . "." . $ip . ".s.maxmind.com", "TXT", "IN");
    $str = is_object($p->answer[0]) ? $p->answer[0]->string() : '';
    //ereg("\"(.*)\"",$str,$regs); // mike challis PHP5.3 fix
    preg_match("/\"(.*)\"/", $str, $regs);
    $str = isset($regs[1]) ? $regs[1] : '';
    return $str;
}
开发者ID:sdgdsffdsfff,项目名称:html-sensor,代码行数:11,代码来源:geoipcity.inc.php


示例15: ZoneAXFR

 function ZoneAXFR($domain, $server)
 {
     require_once "Net/DNS.php";
     $res = new Net_DNS_Resolver();
     //$res->debug = 1;
     $res->persistent_tcp = 1;
     $res->nameservers = array($server);
     $answer = $res->axfr($domain);
     /*
     echo "<pre>"; 
     var_dump($answer); 
     //var_dump($res); 
     //var_dump($answer[0]->header->rcode); 
     echo "</pre>";
     exit;
     */
     // check for errors
     /*
     if ($res->errorstring != "NOERROR") {
         $this->err=70;
         $this->errstr .= sprintf(my_("Zone transfer for domain %s failed with message %s"), $this->domain, $res->errorstring)."\n";
         return "";
     }
     */
     if ($answer) {
         $this->hname = array();
         $i = 1;
         // kill form information
         foreach ($answer as $rr) {
             if ($rr->type == "SOA") {
                 //var_dump($rr);
                 $this->ttl = $rr->ttl;
                 $this->refresh = $rr->refresh;
                 $this->retry = $rr->retry;
                 $this->expire = $rr->expire;
                 $this->minimum = $rr->minimum;
                 $this->responsiblemail = $rr->rname;
             }
             if ($rr->type == "NS" and $rr->name == $this->domain) {
                 $this->hname[$i++] = $this->strip_domain($rr->nsdname, $this->domain);
             }
         }
         $this->err = 0;
         return $answer;
     } else {
         $this->errstr .= sprintf(my_("Zone transfer for domain %s failed - using defaults: %s"), $this->domain, $res->errorstring) . "\n";
         // could not do transfer, so use defaults from now on!
         $this->err = -1;
         return "";
     }
 }
开发者ID:hetznerZA,项目名称:ipplan,代码行数:51,代码来源:class.dnslib.php


示例16: 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;
 }
开发者ID:geo4web-testbed,项目名称:topic2,代码行数:48,代码来源:Resolver.php


示例17: Net_DNS_Header

 /**
  * 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 ($data != '') {
         /*
          * 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'];
     } else {
         $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;
     }
     if (Net_DNS::opcodesbyval($this->opcode)) {
         $this->opcode = Net_DNS::opcodesbyval($this->opcode);
     }
     if (Net_DNS::rcodesbyval($this->rcode)) {
         $this->rcode = Net_DNS::rcodesbyval($this->rcode);
     }
 }
开发者ID:railfuture,项目名称:tiki-website,代码行数:55,代码来源:Header.php


示例18: getdnsattributes

 public function getdnsattributes($l, $ip)
 {
     $r = new Net_DNS_Resolver();
     $r->nameservers = array("ws1.maxmind.com");
     $p = $r->search($l . "." . $ip . ".s.maxmind.com", "TXT", "IN");
     $str = is_object($p->answer[0]) ? $p->answer[0]->string() : '';
     $str = substr($str, 1, -1);
     return $str;
 }
开发者ID:nathanlon,项目名称:Maxmind-GeoIp,代码行数:9,代码来源:GeoIp.php


示例19: validate_form

 /**
  *  validate html form 
  *
  *  @param array $errors    array with error messages
  *  @return bool            TRUE if given values of form are OK, FALSE otherwise
  */
 function validate_form(&$errors)
 {
     global $lang_str, $config, $data;
     if (false === parent::validate_form($errors)) {
         return false;
     }
     /* Check if the domain name is not prohibited */
     if (!empty($_POST['domainname']) and in_array($_POST['domainname'], $this->opt['prohibited_domain_names'])) {
         $errors[] = $lang_str['prohibited_domain_name'];
         return false;
     }
     /* Check if domain name does not already exists */
     $o = array('check_deleted_flag' => false, 'filter' => array('name' => $_POST['domainname']));
     $data->add_method('get_domain');
     if (false === ($domains = $data->get_domain($o))) {
         return false;
     }
     if (count($domains)) {
         $errors[] = $lang_str['err_domain_already_hosted'];
         return false;
     }
     // create DNS resolver object
     $ndr = new Net_DNS_Resolver();
     // query for SRV record
     $dns_lookup = "_sip._udp." . $_POST['domainname'];
     $dns_answer = $ndr->rawQuery($dns_lookup, "SRV");
     if (!$dns_answer) {
         ErrorHandler::log_errors(PEAR::raiseError($lang_str['err_dns_lookup'], null, null, null, $ndr->errorstring));
         return false;
     }
     if (!$dns_answer->answer) {
         $errors[] = str_replace("<hostname>", $dns_lookup, $lang_str['err_no_srv_record']);
         return false;
     }
     $srv_ok = false;
     $srv_false_rec = array();
     foreach ($dns_answer->answer as $v) {
         if ($v->port == $config->srv_sip_proxy_port and $v->target == $config->srv_sip_proxy_hostname) {
             $srv_ok = true;
             break;
         }
         $srv_false_rec[] = array("host" => $v->target, "port" => $v->port);
     }
     if ($srv_ok) {
         return true;
     }
     $err = $lang_str['err_wrong_srv_record'] . "\n";
     foreach ($srv_false_rec as $v) {
         $err .= "host: " . $v['host'] . ", port: " . $v['port'] . "\n";
     }
     $errors[] = $err;
     return false;
 }
开发者ID:BackupTheBerlios,项目名称:serweb,代码行数:59,代码来源:apu_domain_dns_validator.php


示例20: getdnsattributes

function getdnsattributes($l, $ip)
{
    $r = new Net_DNS_Resolver();
    $r->nameservers = array("ws1.maxmind.com");
    $p = $r->search($l . "." . $ip . ".s.maxmind.com", "TXT", "IN");
    $str = is_object($p->answer[0]) ? $p->answer[0]->string() : '';
    ereg("\"(.*)\"", $str, $regs);
    $str = $regs[1];
    return $str;
}
开发者ID:heshuai64,项目名称:gamestore,代码行数:10,代码来源:geoip.php



注:本文中的Net_DNS_Resolver类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Net_IDNA2类代码示例发布时间:2022-05-23
下一篇:
PHP Net_DNS2_Packet类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap