本文整理匯總了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;
}