Linux ip-172-26-2-223 5.4.0-1018-aws #18-Ubuntu SMP Wed Jun 24 01:15:00 UTC 2020 x86_64
Apache
: 172.26.2.223 | : 18.190.152.109
Cant Read [ /etc/named.conf ]
8.1.13
www
www.github.com/MadExploits
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
CPANEL RESET
CREATE WP USER
BLACK DEFEND!
README
+ Create Folder
+ Create File
/
www /
server /
php /
80 /
src /
ext /
standard /
[ HOME SHELL ]
Name
Size
Permission
Action
html_tables
[ DIR ]
drwxr-xr-x
tests
[ DIR ]
drwxr-xr-x
Makefile.frag
518
B
-rw-r--r--
Makefile.frag.w32
484
B
-rw-r--r--
array.c
173.39
KB
-rw-r--r--
assert.c
8.25
KB
-rw-r--r--
base64.c
30.63
KB
-rw-r--r--
base64.h
3.59
KB
-rw-r--r--
basic_functions.c
67.72
KB
-rw-r--r--
basic_functions.h
5.03
KB
-rw-r--r--
basic_functions.stub.php
41.8
KB
-rw-r--r--
basic_functions_arginfo.h
123.78
KB
-rw-r--r--
browscap.c
20.65
KB
-rw-r--r--
config.m4
11.12
KB
-rw-r--r--
config.w32
1.79
KB
-rw-r--r--
crc32.c
3.11
KB
-rw-r--r--
crc32.h
4.5
KB
-rw-r--r--
crc32_x86.c
11.99
KB
-rw-r--r--
crc32_x86.h
1.82
KB
-rw-r--r--
credits.c
5.71
KB
-rw-r--r--
credits.h
1.53
KB
-rw-r--r--
credits_ext.h
5.24
KB
-rw-r--r--
credits_sapi.h
835
B
-rw-r--r--
crypt.c
6.73
KB
-rw-r--r--
crypt_blowfish.c
30.75
KB
-rw-r--r--
crypt_blowfish.h
790
B
-rw-r--r--
crypt_freesec.c
21.52
KB
-rw-r--r--
crypt_freesec.h
662
B
-rw-r--r--
crypt_sha256.c
21.6
KB
-rw-r--r--
crypt_sha512.c
26.25
KB
-rw-r--r--
css.c
2.24
KB
-rw-r--r--
css.h
1.04
KB
-rw-r--r--
datetime.c
3.28
KB
-rw-r--r--
datetime.h
1.14
KB
-rw-r--r--
dir.c
13.95
KB
-rw-r--r--
dir.stub.php
387
B
-rw-r--r--
dir_arginfo.h
746
B
-rw-r--r--
dl.c
8.21
KB
-rw-r--r--
dl.h
1.46
KB
-rw-r--r--
dl.stub.php
56
B
-rw-r--r--
dl_arginfo.h
269
B
-rw-r--r--
dns.c
28.31
KB
-rw-r--r--
dns_win32.c
14.9
KB
-rw-r--r--
exec.c
12.78
KB
-rw-r--r--
exec.h
1.27
KB
-rw-r--r--
file.c
64.34
KB
-rw-r--r--
file.h
3.91
KB
-rw-r--r--
filestat.c
26.73
KB
-rw-r--r--
filters.c
50.04
KB
-rw-r--r--
flock_compat.c
6.44
KB
-rw-r--r--
flock_compat.h
2.06
KB
-rw-r--r--
formatted_print.c
23.37
KB
-rw-r--r--
fsock.c
3.67
KB
-rw-r--r--
fsock.h
1.22
KB
-rw-r--r--
ftok.c
1.84
KB
-rw-r--r--
ftp_fopen_wrapper.c
31.59
KB
-rw-r--r--
head.c
10.66
KB
-rw-r--r--
head.h
1.53
KB
-rw-r--r--
hrtime.c
4.86
KB
-rw-r--r--
hrtime.h
2.31
KB
-rw-r--r--
html.c
44.87
KB
-rw-r--r--
html.h
2.35
KB
-rw-r--r--
html_tables.h
472.26
KB
-rw-r--r--
http.c
6.99
KB
-rw-r--r--
http_fopen_wrapper.c
32.39
KB
-rw-r--r--
image.c
41.83
KB
-rw-r--r--
incomplete_class.c
5.16
KB
-rw-r--r--
info.c
39.87
KB
-rw-r--r--
info.h
22.94
KB
-rw-r--r--
iptc.c
9.18
KB
-rw-r--r--
lcg.c
2.8
KB
-rw-r--r--
levenshtein.c
2.57
KB
-rw-r--r--
link.c
5.45
KB
-rw-r--r--
mail.c
16.25
KB
-rw-r--r--
math.c
27.2
KB
-rw-r--r--
md5.c
10.62
KB
-rw-r--r--
md5.h
1.92
KB
-rw-r--r--
metaphone.c
11.53
KB
-rw-r--r--
microtime.c
4.01
KB
-rw-r--r--
mt_rand.c
10.53
KB
-rw-r--r--
net.c
8.97
KB
-rw-r--r--
pack.c
31.01
KB
-rw-r--r--
pack.h
1.05
KB
-rw-r--r--
pageinfo.c
3.23
KB
-rw-r--r--
pageinfo.h
1.15
KB
-rw-r--r--
password.c
19.21
KB
-rw-r--r--
php_array.h
2.25
KB
-rw-r--r--
php_assert.h
1.18
KB
-rw-r--r--
php_browscap.h
1.11
KB
-rw-r--r--
php_crypt.h
1.37
KB
-rw-r--r--
php_crypt_r.c
5.74
KB
-rw-r--r--
php_crypt_r.h
1.63
KB
-rw-r--r--
php_dir.h
1.28
KB
-rw-r--r--
php_dns.h
2.58
KB
-rw-r--r--
php_ext_syslog.h
1.25
KB
-rw-r--r--
php_filestat.h
2.11
KB
-rw-r--r--
php_fopen_wrapper.c
11.47
KB
-rw-r--r--
php_fopen_wrappers.h
1.79
KB
-rw-r--r--
php_http.h
1.44
KB
-rw-r--r--
php_image.h
2.1
KB
-rw-r--r--
php_incomplete_class.h
2.15
KB
-rw-r--r--
php_lcg.h
1.31
KB
-rw-r--r--
php_mail.h
2.16
KB
-rw-r--r--
php_math.h
3.55
KB
-rw-r--r--
php_mt_rand.h
1.81
KB
-rw-r--r--
php_net.h
1.14
KB
-rw-r--r--
php_password.h
2.77
KB
-rw-r--r--
php_rand.h
3
KB
-rw-r--r--
php_random.h
1.87
KB
-rw-r--r--
php_smart_string.h
1.13
KB
-rw-r--r--
php_smart_string_public.h
1.14
KB
-rw-r--r--
php_standard.h
1.91
KB
-rw-r--r--
php_string.h
3.96
KB
-rw-r--r--
php_uuencode.h
1.18
KB
-rw-r--r--
php_var.h
3.41
KB
-rw-r--r--
php_versioning.h
1.18
KB
-rw-r--r--
proc_open.c
35.27
KB
-rw-r--r--
proc_open.h
1.66
KB
-rw-r--r--
quot_print.c
7.05
KB
-rw-r--r--
quot_print.h
1.23
KB
-rw-r--r--
rand.c
2.22
KB
-rw-r--r--
random.c
7.22
KB
-rw-r--r--
scanf.c
28.23
KB
-rw-r--r--
scanf.h
1.95
KB
-rw-r--r--
sha1.c
11.18
KB
-rw-r--r--
sha1.h
1.53
KB
-rw-r--r--
soundex.c
2.94
KB
-rw-r--r--
streamsfuncs.c
43.24
KB
-rw-r--r--
streamsfuncs.h
1.11
KB
-rw-r--r--
string.c
142.27
KB
-rw-r--r--
strnatcmp.c
4.34
KB
-rw-r--r--
syslog.c
6.05
KB
-rw-r--r--
type.c
10.49
KB
-rw-r--r--
uniqid.c
2.43
KB
-rw-r--r--
url.c
18.11
KB
-rw-r--r--
url.h
2.09
KB
-rw-r--r--
url_scanner_ex.c
38.41
KB
-rw-r--r--
url_scanner_ex.h
2.32
KB
-rw-r--r--
url_scanner_ex.re
27.63
KB
-rw-r--r--
user_filters.c
16.53
KB
-rw-r--r--
user_filters.stub.php
371
B
-rw-r--r--
user_filters_arginfo.h
987
B
-rw-r--r--
uuencode.c
6.35
KB
-rw-r--r--
var.c
37.2
KB
-rw-r--r--
var_unserializer.c
37.95
KB
-rw-r--r--
var_unserializer.re
30.26
KB
-rw-r--r--
versioning.c
5.61
KB
-rw-r--r--
winver.h
6.23
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : url.c
/* +----------------------------------------------------------------------+ | Copyright (c) The PHP Group | +----------------------------------------------------------------------+ | 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 | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Jim Winstead <jimw@php.net> | +----------------------------------------------------------------------+ */ #include <stdlib.h> #include <string.h> #include <ctype.h> #include <sys/types.h> #ifdef __SSE2__ #include <emmintrin.h> #endif #include "php.h" #include "url.h" #include "file.h" /* {{{ free_url */ PHPAPI void php_url_free(php_url *theurl) { if (theurl->scheme) zend_string_release_ex(theurl->scheme, 0); if (theurl->user) zend_string_release_ex(theurl->user, 0); if (theurl->pass) zend_string_release_ex(theurl->pass, 0); if (theurl->host) zend_string_release_ex(theurl->host, 0); if (theurl->path) zend_string_release_ex(theurl->path, 0); if (theurl->query) zend_string_release_ex(theurl->query, 0); if (theurl->fragment) zend_string_release_ex(theurl->fragment, 0); efree(theurl); } /* }}} */ /* {{{ php_replace_controlchars_ex */ PHPAPI char *php_replace_controlchars_ex(char *str, size_t len) { unsigned char *s = (unsigned char *)str; unsigned char *e = (unsigned char *)str + len; if (!str) { return (NULL); } while (s < e) { if (iscntrl(*s)) { *s='_'; } s++; } return (str); } /* }}} */ PHPAPI char *php_replace_controlchars(char *str) { return php_replace_controlchars_ex(str, strlen(str)); } PHPAPI php_url *php_url_parse(char const *str) { return php_url_parse_ex(str, strlen(str)); } static const char *binary_strcspn(const char *s, const char *e, const char *chars) { while (*chars) { const char *p = memchr(s, *chars, e - s); if (p) { e = p; } chars++; } return e; } /* {{{ php_url_parse */ PHPAPI php_url *php_url_parse_ex(char const *str, size_t length) { zend_bool has_port; return php_url_parse_ex2(str, length, &has_port); } /* {{{ php_url_parse_ex2 */ PHPAPI php_url *php_url_parse_ex2(char const *str, size_t length, zend_bool *has_port) { char port_buf[6]; php_url *ret = ecalloc(1, sizeof(php_url)); char const *s, *e, *p, *pp, *ue; *has_port = 0; s = str; ue = s + length; /* parse scheme */ if ((e = memchr(s, ':', length)) && e != s) { /* validate scheme */ p = s; while (p < e) { /* scheme = 1*[ lowalpha | digit | "+" | "-" | "." ] */ if (!isalpha(*p) && !isdigit(*p) && *p != '+' && *p != '.' && *p != '-') { if (e + 1 < ue && e < binary_strcspn(s, ue, "?#")) { goto parse_port; } else if (s + 1 < ue && *s == '/' && *(s + 1) == '/') { /* relative-scheme URL */ s += 2; e = 0; goto parse_host; } else { goto just_path; } } p++; } if (e + 1 == ue) { /* only scheme is available */ ret->scheme = zend_string_init(s, (e - s), 0); php_replace_controlchars_ex(ZSTR_VAL(ret->scheme), ZSTR_LEN(ret->scheme)); return ret; } /* * certain schemas like mailto: and zlib: may not have any / after them * this check ensures we support those. */ if (*(e+1) != '/') { /* check if the data we get is a port this allows us to * correctly parse things like a.com:80 */ p = e + 1; while (p < ue && isdigit(*p)) { p++; } if ((p == ue || *p == '/') && (p - e) < 7) { goto parse_port; } ret->scheme = zend_string_init(s, (e-s), 0); php_replace_controlchars_ex(ZSTR_VAL(ret->scheme), ZSTR_LEN(ret->scheme)); s = e + 1; goto just_path; } else { ret->scheme = zend_string_init(s, (e-s), 0); php_replace_controlchars_ex(ZSTR_VAL(ret->scheme), ZSTR_LEN(ret->scheme)); if (e + 2 < ue && *(e + 2) == '/') { s = e + 3; if (zend_string_equals_literal_ci(ret->scheme, "file")) { if (e + 3 < ue && *(e + 3) == '/') { /* support windows drive letters as in: file:///c:/somedir/file.txt */ if (e + 5 < ue && *(e + 5) == ':') { s = e + 4; } goto just_path; } } } else { s = e + 1; goto just_path; } } } else if (e) { /* no scheme; starts with colon: look for port */ parse_port: p = e + 1; pp = p; while (pp < ue && pp - p < 6 && isdigit(*pp)) { pp++; } if (pp - p > 0 && pp - p < 6 && (pp == ue || *pp == '/')) { zend_long port; char *end; memcpy(port_buf, p, (pp - p)); port_buf[pp - p] = '\0'; port = ZEND_STRTOL(port_buf, &end, 10); if (port >= 0 && port <= 65535 && end != port_buf) { *has_port = 1; ret->port = (unsigned short) port; if (s + 1 < ue && *s == '/' && *(s + 1) == '/') { /* relative-scheme URL */ s += 2; } } else { php_url_free(ret); return NULL; } } else if (p == pp && pp == ue) { php_url_free(ret); return NULL; } else if (s + 1 < ue && *s == '/' && *(s + 1) == '/') { /* relative-scheme URL */ s += 2; } else { goto just_path; } } else if (s + 1 < ue && *s == '/' && *(s + 1) == '/') { /* relative-scheme URL */ s += 2; } else { goto just_path; } parse_host: e = binary_strcspn(s, ue, "/?#"); /* check for login and password */ if ((p = zend_memrchr(s, '@', (e-s)))) { if ((pp = memchr(s, ':', (p-s)))) { ret->user = zend_string_init(s, (pp-s), 0); php_replace_controlchars_ex(ZSTR_VAL(ret->user), ZSTR_LEN(ret->user)); pp++; ret->pass = zend_string_init(pp, (p-pp), 0); php_replace_controlchars_ex(ZSTR_VAL(ret->pass), ZSTR_LEN(ret->pass)); } else { ret->user = zend_string_init(s, (p-s), 0); php_replace_controlchars_ex(ZSTR_VAL(ret->user), ZSTR_LEN(ret->user)); } s = p + 1; } /* check for port */ if (s < ue && *s == '[' && *(e-1) == ']') { /* Short circuit portscan, we're dealing with an IPv6 embedded address */ p = NULL; } else { p = zend_memrchr(s, ':', (e-s)); } if (p) { if (!ret->port) { p++; if (e-p > 5) { /* port cannot be longer then 5 characters */ php_url_free(ret); return NULL; } else if (e - p > 0) { zend_long port; char *end; memcpy(port_buf, p, (e - p)); port_buf[e - p] = '\0'; port = ZEND_STRTOL(port_buf, &end, 10); if (port >= 0 && port <= 65535 && end != port_buf) { *has_port = 1; ret->port = (unsigned short)port; } else { php_url_free(ret); return NULL; } } p--; } } else { p = e; } /* check if we have a valid host, if we don't reject the string as url */ if ((p-s) < 1) { php_url_free(ret); return NULL; } ret->host = zend_string_init(s, (p-s), 0); php_replace_controlchars_ex(ZSTR_VAL(ret->host), ZSTR_LEN(ret->host)); if (e == ue) { return ret; } s = e; just_path: e = ue; p = memchr(s, '#', (e - s)); if (p) { p++; if (p < e) { ret->fragment = zend_string_init(p, (e - p), 0); php_replace_controlchars_ex(ZSTR_VAL(ret->fragment), ZSTR_LEN(ret->fragment)); } else { ret->fragment = ZSTR_EMPTY_ALLOC(); } e = p-1; } p = memchr(s, '?', (e - s)); if (p) { p++; if (p < e) { ret->query = zend_string_init(p, (e - p), 0); php_replace_controlchars_ex(ZSTR_VAL(ret->query), ZSTR_LEN(ret->query)); } else { ret->query = ZSTR_EMPTY_ALLOC(); } e = p-1; } if (s < e || s == ue) { ret->path = zend_string_init(s, (e - s), 0); php_replace_controlchars_ex(ZSTR_VAL(ret->path), ZSTR_LEN(ret->path)); } return ret; } /* }}} */ /* {{{ Parse a URL and return its components */ PHP_FUNCTION(parse_url) { char *str; size_t str_len; php_url *resource; zend_long key = -1; zval tmp; zend_bool has_port; ZEND_PARSE_PARAMETERS_START(1, 2) Z_PARAM_STRING(str, str_len) Z_PARAM_OPTIONAL Z_PARAM_LONG(key) ZEND_PARSE_PARAMETERS_END(); resource = php_url_parse_ex2(str, str_len, &has_port); if (resource == NULL) { /* @todo Find a method to determine why php_url_parse_ex() failed */ RETURN_FALSE; } if (key > -1) { switch (key) { case PHP_URL_SCHEME: if (resource->scheme != NULL) RETVAL_STR_COPY(resource->scheme); break; case PHP_URL_HOST: if (resource->host != NULL) RETVAL_STR_COPY(resource->host); break; case PHP_URL_PORT: if (has_port) RETVAL_LONG(resource->port); break; case PHP_URL_USER: if (resource->user != NULL) RETVAL_STR_COPY(resource->user); break; case PHP_URL_PASS: if (resource->pass != NULL) RETVAL_STR_COPY(resource->pass); break; case PHP_URL_PATH: if (resource->path != NULL) RETVAL_STR_COPY(resource->path); break; case PHP_URL_QUERY: if (resource->query != NULL) RETVAL_STR_COPY(resource->query); break; case PHP_URL_FRAGMENT: if (resource->fragment != NULL) RETVAL_STR_COPY(resource->fragment); break; default: zend_argument_value_error(2, "must be a valid URL component identifier, " ZEND_LONG_FMT " given", key); break; } goto done; } /* allocate an array for return */ array_init(return_value); /* add the various elements to the array */ if (resource->scheme != NULL) { ZVAL_STR_COPY(&tmp, resource->scheme); zend_hash_add_new(Z_ARRVAL_P(return_value), ZSTR_KNOWN(ZEND_STR_SCHEME), &tmp); } if (resource->host != NULL) { ZVAL_STR_COPY(&tmp, resource->host); zend_hash_add_new(Z_ARRVAL_P(return_value), ZSTR_KNOWN(ZEND_STR_HOST), &tmp); } if (has_port) { ZVAL_LONG(&tmp, resource->port); zend_hash_add_new(Z_ARRVAL_P(return_value), ZSTR_KNOWN(ZEND_STR_PORT), &tmp); } if (resource->user != NULL) { ZVAL_STR_COPY(&tmp, resource->user); zend_hash_add_new(Z_ARRVAL_P(return_value), ZSTR_KNOWN(ZEND_STR_USER), &tmp); } if (resource->pass != NULL) { ZVAL_STR_COPY(&tmp, resource->pass); zend_hash_add_new(Z_ARRVAL_P(return_value), ZSTR_KNOWN(ZEND_STR_PASS), &tmp); } if (resource->path != NULL) { ZVAL_STR_COPY(&tmp, resource->path); zend_hash_add_new(Z_ARRVAL_P(return_value), ZSTR_KNOWN(ZEND_STR_PATH), &tmp); } if (resource->query != NULL) { ZVAL_STR_COPY(&tmp, resource->query); zend_hash_add_new(Z_ARRVAL_P(return_value), ZSTR_KNOWN(ZEND_STR_QUERY), &tmp); } if (resource->fragment != NULL) { ZVAL_STR_COPY(&tmp, resource->fragment); zend_hash_add_new(Z_ARRVAL_P(return_value), ZSTR_KNOWN(ZEND_STR_FRAGMENT), &tmp); } done: php_url_free(resource); } /* }}} */ /* {{{ php_htoi */ static int php_htoi(char *s) { int value; int c; c = ((unsigned char *)s)[0]; if (isupper(c)) c = tolower(c); value = (c >= '0' && c <= '9' ? c - '0' : c - 'a' + 10) * 16; c = ((unsigned char *)s)[1]; if (isupper(c)) c = tolower(c); value += c >= '0' && c <= '9' ? c - '0' : c - 'a' + 10; return (value); } /* }}} */ /* rfc1738: ...The characters ";", "/", "?", ":", "@", "=" and "&" are the characters which may be reserved for special meaning within a scheme... ...Thus, only alphanumerics, the special characters "$-_.+!*'(),", and reserved characters used for their reserved purposes may be used unencoded within a URL... For added safety, we only leave -_. unencoded. */ static const unsigned char hexchars[] = "0123456789ABCDEF"; static zend_always_inline zend_string *php_url_encode_impl(const char *s, size_t len, zend_bool raw) /* {{{ */ { register unsigned char c; unsigned char *to; unsigned char const *from, *end; zend_string *start; from = (unsigned char *)s; end = (unsigned char *)s + len; start = zend_string_safe_alloc(3, len, 0, 0); to = (unsigned char*)ZSTR_VAL(start); #ifdef __SSE2__ while (from + 16 < end) { __m128i mask; uint32_t bits; const __m128i _A = _mm_set1_epi8('A' - 1); const __m128i Z_ = _mm_set1_epi8('Z' + 1); const __m128i _a = _mm_set1_epi8('a' - 1); const __m128i z_ = _mm_set1_epi8('z' + 1); const __m128i _zero = _mm_set1_epi8('0' - 1); const __m128i nine_ = _mm_set1_epi8('9' + 1); const __m128i dot = _mm_set1_epi8('.'); const __m128i minus = _mm_set1_epi8('-'); const __m128i under = _mm_set1_epi8('_'); __m128i in = _mm_loadu_si128((__m128i *)from); __m128i gt = _mm_cmpgt_epi8(in, _A); __m128i lt = _mm_cmplt_epi8(in, Z_); mask = _mm_and_si128(lt, gt); /* upper */ gt = _mm_cmpgt_epi8(in, _a); lt = _mm_cmplt_epi8(in, z_); mask = _mm_or_si128(mask, _mm_and_si128(lt, gt)); /* lower */ gt = _mm_cmpgt_epi8(in, _zero); lt = _mm_cmplt_epi8(in, nine_); mask = _mm_or_si128(mask, _mm_and_si128(lt, gt)); /* number */ mask = _mm_or_si128(mask, _mm_cmpeq_epi8(in, dot)); mask = _mm_or_si128(mask, _mm_cmpeq_epi8(in, minus)); mask = _mm_or_si128(mask, _mm_cmpeq_epi8(in, under)); if (!raw) { const __m128i blank = _mm_set1_epi8(' '); __m128i eq = _mm_cmpeq_epi8(in, blank); if (_mm_movemask_epi8(eq)) { in = _mm_add_epi8(in, _mm_and_si128(eq, _mm_set1_epi8('+' - ' '))); mask = _mm_or_si128(mask, eq); } } if (raw) { const __m128i wavy = _mm_set1_epi8('~'); mask = _mm_or_si128(mask, _mm_cmpeq_epi8(in, wavy)); } if (((bits = _mm_movemask_epi8(mask)) & 0xffff) == 0xffff) { _mm_storeu_si128((__m128i*)to, in); to += 16; } else { int i; unsigned char xmm[16]; _mm_storeu_si128((__m128i*)xmm, in); for (i = 0; i < sizeof(xmm); i++) { if ((bits & (0x1 << i))) { *to++ = xmm[i]; } else { *to++ = '%'; *to++ = hexchars[xmm[i] >> 4]; *to++ = hexchars[xmm[i] & 0xf]; } } } from += 16; } #endif while (from < end) { c = *from++; if (!raw && c == ' ') { *to++ = '+'; } else if ((c < '0' && c != '-' && c != '.') || (c < 'A' && c > '9') || (c > 'Z' && c < 'a' && c != '_') || (c > 'z' && (!raw || c != '~'))) { to[0] = '%'; to[1] = hexchars[c >> 4]; to[2] = hexchars[c & 15]; to += 3; } else { *to++ = c; } } *to = '\0'; start = zend_string_truncate(start, to - (unsigned char*)ZSTR_VAL(start), 0); return start; } /* }}} */ /* {{{ php_url_encode */ PHPAPI zend_string *php_url_encode(char const *s, size_t len) { return php_url_encode_impl(s, len, 0); } /* }}} */ /* {{{ URL-encodes string */ PHP_FUNCTION(urlencode) { zend_string *in_str; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_STR(in_str) ZEND_PARSE_PARAMETERS_END(); RETURN_STR(php_url_encode(ZSTR_VAL(in_str), ZSTR_LEN(in_str))); } /* }}} */ /* {{{ Decodes URL-encoded string */ PHP_FUNCTION(urldecode) { zend_string *in_str, *out_str; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_STR(in_str) ZEND_PARSE_PARAMETERS_END(); out_str = zend_string_init(ZSTR_VAL(in_str), ZSTR_LEN(in_str), 0); ZSTR_LEN(out_str) = php_url_decode(ZSTR_VAL(out_str), ZSTR_LEN(out_str)); RETURN_NEW_STR(out_str); } /* }}} */ /* {{{ php_url_decode */ PHPAPI size_t php_url_decode(char *str, size_t len) { char *dest = str; char *data = str; while (len--) { if (*data == '+') { *dest = ' '; } else if (*data == '%' && len >= 2 && isxdigit((int) *(data + 1)) && isxdigit((int) *(data + 2))) { *dest = (char) php_htoi(data + 1); data += 2; len -= 2; } else { *dest = *data; } data++; dest++; } *dest = '\0'; return dest - str; } /* }}} */ /* {{{ php_raw_url_encode */ PHPAPI zend_string *php_raw_url_encode(char const *s, size_t len) { return php_url_encode_impl(s, len, 1); } /* }}} */ /* {{{ URL-encodes string */ PHP_FUNCTION(rawurlencode) { zend_string *in_str; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_STR(in_str) ZEND_PARSE_PARAMETERS_END(); RETURN_STR(php_raw_url_encode(ZSTR_VAL(in_str), ZSTR_LEN(in_str))); } /* }}} */ /* {{{ Decodes URL-encodes string */ PHP_FUNCTION(rawurldecode) { zend_string *in_str, *out_str; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_STR(in_str) ZEND_PARSE_PARAMETERS_END(); out_str = zend_string_init(ZSTR_VAL(in_str), ZSTR_LEN(in_str), 0); ZSTR_LEN(out_str) = php_raw_url_decode(ZSTR_VAL(out_str), ZSTR_LEN(out_str)); RETURN_NEW_STR(out_str); } /* }}} */ /* {{{ php_raw_url_decode */ PHPAPI size_t php_raw_url_decode(char *str, size_t len) { char *dest = str; char *data = str; while (len--) { if (*data == '%' && len >= 2 && isxdigit((int) *(data + 1)) && isxdigit((int) *(data + 2))) { *dest = (char) php_htoi(data + 1); data += 2; len -= 2; } else { *dest = *data; } data++; dest++; } *dest = '\0'; return dest - str; } /* }}} */ /* {{{ fetches all the headers sent by the server in response to a HTTP request */ PHP_FUNCTION(get_headers) { char *url; size_t url_len; php_stream *stream; zval *prev_val, *hdr = NULL; zend_bool format = 0; zval *zcontext = NULL; php_stream_context *context; ZEND_PARSE_PARAMETERS_START(1, 3) Z_PARAM_PATH(url, url_len) Z_PARAM_OPTIONAL Z_PARAM_BOOL(format) Z_PARAM_RESOURCE_OR_NULL(zcontext) ZEND_PARSE_PARAMETERS_END(); context = php_stream_context_from_zval(zcontext, 0); if (!(stream = php_stream_open_wrapper_ex(url, "r", REPORT_ERRORS | STREAM_USE_URL | STREAM_ONLY_GET_HEADERS, NULL, context))) { RETURN_FALSE; } if (Z_TYPE(stream->wrapperdata) != IS_ARRAY) { php_stream_close(stream); RETURN_FALSE; } array_init(return_value); ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&stream->wrapperdata), hdr) { if (Z_TYPE_P(hdr) != IS_STRING) { continue; } if (!format) { no_name_header: add_next_index_str(return_value, zend_string_copy(Z_STR_P(hdr))); } else { char c; char *s, *p; if ((p = strchr(Z_STRVAL_P(hdr), ':'))) { c = *p; *p = '\0'; s = p + 1; while (isspace((int)*(unsigned char *)s)) { s++; } if ((prev_val = zend_hash_str_find(Z_ARRVAL_P(return_value), Z_STRVAL_P(hdr), (p - Z_STRVAL_P(hdr)))) == NULL) { add_assoc_stringl_ex(return_value, Z_STRVAL_P(hdr), (p - Z_STRVAL_P(hdr)), s, (Z_STRLEN_P(hdr) - (s - Z_STRVAL_P(hdr)))); } else { /* some headers may occur more than once, therefor we need to remake the string into an array */ convert_to_array(prev_val); add_next_index_stringl(prev_val, s, (Z_STRLEN_P(hdr) - (s - Z_STRVAL_P(hdr)))); } *p = c; } else { goto no_name_header; } } } ZEND_HASH_FOREACH_END(); php_stream_close(stream); } /* }}} */
Close