本文整理汇总了PHP中Net_DNS_Resolver::rawQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP Net_DNS_Resolver::rawQuery方法的具体用法?PHP Net_DNS_Resolver::rawQuery怎么用?PHP Net_DNS_Resolver::rawQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Net_DNS_Resolver
的用法示例。
在下文中一共展示了Net_DNS_Resolver::rawQuery方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* 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;
}