+#if PHP_VERSION_ID >= 70000
+
+struct apfd {
+ zval post;
+ zval files;
+};
+
+#define APFD_SG(t) &PG(http_globals)[t]
+static inline sapi_post_entry *apfd_get_post_entry(const char *ct_str, size_t ct_len)
+{
+ return zend_hash_str_find_ptr(&SG(known_post_content_types), ct_str, ct_len);
+}
+
+static inline void apfd_backup(struct apfd *apfd)
+{
+ if (SG(rfc1867_uploaded_files)) {
+ destroy_uploaded_files_hash();
+ }
+
+ zval_ptr_dtor(APFD_SG(TRACK_VARS_POST));
+ array_init(&apfd->post);
+ ZVAL_COPY_VALUE(APFD_SG(TRACK_VARS_POST), &apfd->post);
+
+ zval_ptr_dtor(APFD_SG(TRACK_VARS_FILES));
+ array_init(&apfd->files);
+ ZVAL_COPY_VALUE(APFD_SG(TRACK_VARS_FILES), &apfd->files);
+}
+
+static inline void apfd_update(struct apfd *apfd)
+{
+ zend_hash_str_update(&EG(symbol_table), "_POST", sizeof("_POST")-1, APFD_SG(TRACK_VARS_POST));
+ Z_TRY_ADDREF_P(APFD_SG(TRACK_VARS_POST));
+
+ zend_hash_str_update(&EG(symbol_table), "_FILES", sizeof("_FILES")-1, APFD_SG(TRACK_VARS_FILES));
+ Z_TRY_ADDREF_P(APFD_SG(TRACK_VARS_FILES));
+}
+
+#else
+
+struct apfd {
+ zval *post;
+ zval *files;
+};
+
+#define APFD_SG(t) PG(http_globals)[t]
+static inline sapi_post_entry *apfd_get_post_entry(const char *ct_str, size_t ct_len TSRMLS_DC)
+{
+ sapi_post_entry *post_entry;
+
+ if (SUCCESS == zend_hash_find(&SG(known_post_content_types), ct_str, ct_len+1, (void *) &post_entry)) {
+ return post_entry;
+ }
+ return NULL;
+}
+
+static inline void apfd_backup(struct apfd *apfd TSRMLS_DC)
+{
+ apfd->post = APFD_SG(TRACK_VARS_POST);
+ apfd->files = APFD_SG(TRACK_VARS_FILES);
+}
+
+static inline void apfd_update(struct apfd *apfd TSRMLS_DC)
+{
+ if (apfd->files != APFD_SG(TRACK_VARS_FILES) && APFD_SG(TRACK_VARS_FILES)) {
+ Z_ADDREF_P(APFD_SG(TRACK_VARS_FILES));
+ zend_hash_update(&EG(symbol_table), "_FILES", sizeof("_FILES"), &APFD_SG(TRACK_VARS_FILES), sizeof(zval *), NULL);
+ if (apfd->files) {
+ zval_ptr_dtor(&apfd->files);
+ }
+ }
+}
+#endif
+