2 +--------------------------------------------------------------------+
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the conditions mentioned |
7 | in the accompanying LICENSE file are met. |
8 +--------------------------------------------------------------------+
9 | Copyright (c) 2015, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
19 #include "ext/standard/info.h"
23 PHP_RINIT_FUNCTION(apfd
)
25 /* populate form data on non-POST requests */
26 if (SG(request_info
).request_method
&& strcasecmp(SG(request_info
).request_method
, "POST") && SG(request_info
).content_type
&& *SG(request_info
).content_type
) {
27 char *ct_str
= zend_str_tolower_dup(SG(request_info
).content_type
, strlen(SG(request_info
).content_type
));
28 size_t ct_end
= strcspn(ct_str
, ";, ");
29 sapi_post_entry
*post_entry
= NULL
;
32 SG(request_info
).content_type_dup
= ct_str
;
34 delim
= ct_str
[ct_end
];
35 ct_str
[ct_end
] = '\0';
37 if (SUCCESS
== zend_hash_find(&SG(known_post_content_types
), ct_str
, ct_end
+1, (void *) &post_entry
)) {
38 zval
*files
= PG(http_globals
)[TRACK_VARS_FILES
];
40 ct_str
[ct_end
] = delim
;
43 SG(request_info
).post_entry
= post_entry
;
45 if (post_entry
->post_reader
) {
46 post_entry
->post_reader(TSRMLS_C
);
50 if (sapi_module
.default_post_reader
) {
51 sapi_module
.default_post_reader(TSRMLS_C
);
54 sapi_handle_post(PG(http_globals
)[TRACK_VARS_POST
] TSRMLS_CC
);
57 * the rfc1867 handler is an awkward buddy
59 if (files
!= PG(http_globals
)[TRACK_VARS_FILES
] && PG(http_globals
)[TRACK_VARS_FILES
]) {
60 Z_ADDREF_P(PG(http_globals
)[TRACK_VARS_FILES
]);
61 zend_hash_update(&EG(symbol_table
), "_FILES", sizeof("_FILES"), &PG(http_globals
)[TRACK_VARS_FILES
], sizeof(zval
*), NULL
);
63 zval_ptr_dtor(&files
);
68 if (SG(request_info
).content_type_dup
) {
69 efree(SG(request_info
).content_type_dup
);
70 SG(request_info
).content_type_dup
= NULL
;
77 PHP_MINFO_FUNCTION(apfd
)
79 php_info_print_table_start();
80 php_info_print_table_header(2, "apfd support", "enabled");
81 php_info_print_table_end();
84 const zend_function_entry apfd_functions
[] = {
88 zend_module_entry apfd_module_entry
= {
89 STANDARD_MODULE_HEADER
,
98 STANDARD_MODULE_PROPERTIES
101 #ifdef COMPILE_DL_APFD
102 ZEND_GET_MODULE(apfd
)
110 * vim600: noet sw=4 ts=4 fdm=marker
111 * vim<600: noet sw=4 ts=4