version 1.1, 2012/02/21 23:48:02
|
version 1.1.1.4, 2014/06/15 20:03:57
|
Line 2
|
Line 2
|
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| PHP Version 5 | |
| PHP Version 5 | |
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| Copyright (c) 1997-2012 The PHP Group | | | Copyright (c) 1997-2014 The PHP Group | |
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| This source file is subject to version 3.01 of the PHP license, | |
| This source file is subject to version 3.01 of the PHP license, | |
| that is bundled with this package in the file LICENSE, and is | |
| that is bundled with this package in the file LICENSE, and is | |
Line 413 PHP_FUNCTION(dns_check_record)
|
Line 413 PHP_FUNCTION(dns_check_record)
|
#if HAVE_FULL_DNS_FUNCS |
#if HAVE_FULL_DNS_FUNCS |
|
|
/* {{{ php_parserr */ |
/* {{{ php_parserr */ |
static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int store, zval **subarray) | static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int store, int raw, zval **subarray) |
{ |
{ |
u_short type, class, dlen; |
u_short type, class, dlen; |
u_long ttl; |
u_long ttl; |
Line 449 static u_char *php_parserr(u_char *cp, querybuf *answe
|
Line 449 static u_char *php_parserr(u_char *cp, querybuf *answe
|
array_init(*subarray); |
array_init(*subarray); |
|
|
add_assoc_string(*subarray, "host", name, 1); |
add_assoc_string(*subarray, "host", name, 1); |
|
add_assoc_string(*subarray, "class", "IN", 1); |
|
add_assoc_long(*subarray, "ttl", ttl); |
|
|
|
if (raw) { |
|
add_assoc_long(*subarray, "type", type); |
|
add_assoc_stringl(*subarray, "data", (char*) cp, (uint) dlen, 1); |
|
cp += dlen; |
|
return cp; |
|
} |
|
|
switch (type) { |
switch (type) { |
case DNS_T_A: |
case DNS_T_A: |
add_assoc_string(*subarray, "type", "A", 1); |
add_assoc_string(*subarray, "type", "A", 1); |
Line 514 static u_char *php_parserr(u_char *cp, querybuf *answe
|
Line 524 static u_char *php_parserr(u_char *cp, querybuf *answe
|
tp[dlen] = '\0'; |
tp[dlen] = '\0'; |
cp += dlen; |
cp += dlen; |
|
|
add_assoc_stringl(*subarray, "txt", tp, dlen - 1, 0); | add_assoc_stringl(*subarray, "txt", tp, (dlen>0)?dlen - 1:0, 0); |
add_assoc_zval(*subarray, "entries", entries); |
add_assoc_zval(*subarray, "entries", entries); |
} |
} |
break; |
break; |
Line 689 static u_char *php_parserr(u_char *cp, querybuf *answe
|
Line 699 static u_char *php_parserr(u_char *cp, querybuf *answe
|
add_assoc_string(*subarray, "replacement", name, 1); |
add_assoc_string(*subarray, "replacement", name, 1); |
break; |
break; |
default: |
default: |
|
zval_ptr_dtor(subarray); |
|
*subarray = NULL; |
cp += dlen; |
cp += dlen; |
|
break; |
} |
} |
|
|
add_assoc_string(*subarray, "class", "IN", 1); |
|
add_assoc_long(*subarray, "ttl", ttl); |
|
|
|
return cp; |
return cp; |
} |
} |
/* }}} */ |
/* }}} */ |
Line 721 PHP_FUNCTION(dns_get_record)
|
Line 731 PHP_FUNCTION(dns_get_record)
|
u_char *cp = NULL, *end = NULL; |
u_char *cp = NULL, *end = NULL; |
int n, qd, an, ns = 0, ar = 0; |
int n, qd, an, ns = 0, ar = 0; |
int type, first_query = 1, store_results = 1; |
int type, first_query = 1, store_results = 1; |
|
zend_bool raw = 0; |
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lzz", &hostname, &hostname_len, &type_param, &authns, &addtl) == FAILURE) { | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lz!z!b", |
| &hostname, &hostname_len, &type_param, &authns, &addtl, &raw) == FAILURE) { |
return; |
return; |
} |
} |
|
|
Line 735 PHP_FUNCTION(dns_get_record)
|
Line 747 PHP_FUNCTION(dns_get_record)
|
array_init(addtl); |
array_init(addtl); |
} |
} |
|
|
if (type_param & ~PHP_DNS_ALL && type_param != PHP_DNS_ANY) { | if (!raw) { |
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Type '%ld' not supported", type_param); | if ((type_param & ~PHP_DNS_ALL) && (type_param != PHP_DNS_ANY)) { |
RETURN_FALSE; | php_error_docref(NULL TSRMLS_CC, E_WARNING, "Type '%ld' not supported", type_param); |
| RETURN_FALSE; |
| } |
| } else { |
| if ((type_param < 1) || (type_param > 0xFFFF)) { |
| php_error_docref(NULL TSRMLS_CC, E_WARNING, |
| "Numeric DNS record type must be between 1 and 65535, '%ld' given", type_param); |
| RETURN_FALSE; |
| } |
} |
} |
|
|
/* Initialize the return array */ |
/* Initialize the return array */ |
Line 748 PHP_FUNCTION(dns_get_record)
|
Line 768 PHP_FUNCTION(dns_get_record)
|
* store_results is used to skip storing the results retrieved in step |
* store_results is used to skip storing the results retrieved in step |
* NUMTYPES+1 when results were already fetched. |
* NUMTYPES+1 when results were already fetched. |
* - In case of PHP_DNS_ANY we use the directly fetch DNS_T_ANY. (step NUMTYPES+1 ) |
* - In case of PHP_DNS_ANY we use the directly fetch DNS_T_ANY. (step NUMTYPES+1 ) |
|
* - In case of raw mode, we query only the requestd type instead of looping type by type |
|
* before going with the additional info stuff. |
*/ |
*/ |
for (type = (type_param == PHP_DNS_ANY ? (PHP_DNS_NUM_TYPES + 1) : 0); | |
| if (raw) { |
| type = -1; |
| } else if (type_param == PHP_DNS_ANY) { |
| type = PHP_DNS_NUM_TYPES + 1; |
| } else { |
| type = 0; |
| } |
| |
| for ( ; |
type < (addtl ? (PHP_DNS_NUM_TYPES + 2) : PHP_DNS_NUM_TYPES) || first_query; |
type < (addtl ? (PHP_DNS_NUM_TYPES + 2) : PHP_DNS_NUM_TYPES) || first_query; |
type++ |
type++ |
) { |
) { |
first_query = 0; |
first_query = 0; |
switch (type) { |
switch (type) { |
|
case -1: /* raw */ |
|
type_to_fetch = type_param; |
|
/* skip over the rest and go directly to additional records */ |
|
type = PHP_DNS_NUM_TYPES - 1; |
|
break; |
case 0: |
case 0: |
type_to_fetch = type_param&PHP_DNS_A ? DNS_T_A : 0; |
type_to_fetch = type_param&PHP_DNS_A ? DNS_T_A : 0; |
break; |
break; |
Line 848 PHP_FUNCTION(dns_get_record)
|
Line 884 PHP_FUNCTION(dns_get_record)
|
while (an-- && cp && cp < end) { |
while (an-- && cp && cp < end) { |
zval *retval; |
zval *retval; |
|
|
cp = php_parserr(cp, &answer, type_to_fetch, store_results, &retval); | cp = php_parserr(cp, &answer, type_to_fetch, store_results, raw, &retval); |
if (retval != NULL && store_results) { |
if (retval != NULL && store_results) { |
add_next_index_zval(return_value, retval); |
add_next_index_zval(return_value, retval); |
} |
} |
Line 861 PHP_FUNCTION(dns_get_record)
|
Line 897 PHP_FUNCTION(dns_get_record)
|
while (ns-- > 0 && cp && cp < end) { |
while (ns-- > 0 && cp && cp < end) { |
zval *retval = NULL; |
zval *retval = NULL; |
|
|
cp = php_parserr(cp, &answer, DNS_T_ANY, authns != NULL, &retval); | cp = php_parserr(cp, &answer, DNS_T_ANY, authns != NULL, raw, &retval); |
if (retval != NULL) { |
if (retval != NULL) { |
add_next_index_zval(authns, retval); |
add_next_index_zval(authns, retval); |
} |
} |
Line 873 PHP_FUNCTION(dns_get_record)
|
Line 909 PHP_FUNCTION(dns_get_record)
|
while (ar-- > 0 && cp && cp < end) { |
while (ar-- > 0 && cp && cp < end) { |
zval *retval = NULL; |
zval *retval = NULL; |
|
|
cp = php_parserr(cp, &answer, DNS_T_ANY, 1, &retval); | cp = php_parserr(cp, &answer, DNS_T_ANY, 1, raw, &retval); |
if (retval != NULL) { |
if (retval != NULL) { |
add_next_index_zval(addtl, retval); |
add_next_index_zval(addtl, retval); |
} |
} |