1 #ifndef PHP_SNUFFLEUPAGUS_H 2 #define PHP_SNUFFLEUPAGUS_H 3 4 #define PHP_SNUFFLEUPAGUS_VERSION "0.7.0" 5 #define PHP_SNUFFLEUPAGUS_EXTNAME "snuffleupagus" 6 #define PHP_SNUFFLEUPAGUS_AUTHOR "NBS System & Julien (jvoisin) Voisin" 7 #define PHP_SNUFFLEUPAGUS_URL "https://github.com/jvoisin/snuffleupagus" 8 #define PHP_SNUFFLEUPAGUS_COPYRIGHT "LGPLv2" 9 10 #ifdef HAVE_CONFIG_H 11 #include "config.h" 12 #endif 13 14 #include <errno.h> 15 #include <fcntl.h> 16 #include <inttypes.h> 17 #include <stdbool.h> 18 #include <stdio.h> 19 #include <stdlib.h> 20 #include <string.h> 21 #include <unistd.h> 22 23 #include <arpa/inet.h> 24 #include <netinet/in.h> 25 #include <sys/socket.h> 26 #include <sys/types.h> 27 #include <sys/wait.h> 28 #include <sys/syslog.h> 29 30 #include "SAPI.h" 31 #include "ext/pcre/php_pcre.h" 32 #include "ext/standard/head.h" 33 #include "ext/standard/info.h" 34 #include "ext/standard/url.h" 35 #include "ext/standard/php_var.h" 36 #include "ext/session/php_session.h" 37 #include "php.h" 38 #include "php_ini.h" 39 #include "rfc1867.h" 40 #include "zend_execute.h" 41 #include "zend_extensions.h" 42 #include "zend_hash.h" 43 #include "zend_string.h" 44 #include "zend_types.h" 45 #include "zend_vm.h" 46 47 /* Compatibility */ 48 #if ( !HAVE_PCRE && !HAVE_BUNDLED_PCRE ) 49 #error Snuffleupagus requires PHP7+ with PCRE support 50 #endif 51 #if PHP_VERSION_ID < 70000 52 #error Snuffleupagus only works with PHP7+. You shouldn't use PHP5 anyway, \ 53 since it's not supported anymore: https://secure.php.net/supported-versions.php 54 #endif 55 #if PHP_VERSION_ID < 70200 56 typedef void (*zif_handler)(INTERNAL_FUNCTION_PARAMETERS); 57 #endif 58 #if PHP_VERSION_ID >= 80000 59 #define TSRMLS_FETCH() 60 #define TSRMLS_C 61 #endif 62 63 #define SP_CONFIG_VALID 1 64 #define SP_CONFIG_INVALID 0 65 #define SP_CONFIG_NONE -1 66 67 #include "sp_pcre_compat.h" 68 #include "sp_list.h" 69 #include "sp_tree.h" 70 #include "sp_var_parser.h" 71 #include "sp_config.h" 72 #include "sp_config_utils.h" 73 #include "sp_config_keywords.h" 74 #include "sp_cookie_encryption.h" 75 #include "sp_disable_xxe.h" 76 #include "sp_disabled_functions.h" 77 #include "sp_execute.h" 78 #include "sp_harden_rand.h" 79 #include "sp_network_utils.h" 80 #include "sp_unserialize.h" 81 #include "sp_upload_validation.h" 82 #include "sp_utils.h" 83 #include "sp_crypt.h" 84 #include "sp_session.h" 85 #include "sp_sloppy.h" 86 #include "sp_wrapper.h" 87 88 extern zend_module_entry snuffleupagus_module_entry; 89 #define phpext_snuffleupagus_ptr &snuffleupagus_module_entry 90 91 #ifdef PHP_WIN32 92 #define PHP_SNUFFLEUPAGUS_API __declspec(dllexport) 93 #elif defined(__GNUC__) && __GNUC__ >= 4 94 #define PHP_SNUFFLEUPAGUS_API __attribute__((visibility("default"))) 95 #else 96 #define PHP_SNUFFLEUPAGUS_API 97 #endif 98 99 #ifdef ZTS 100 #include "TSRM.h" 101 #endif 102 103 ZEND_BEGIN_MODULE_GLOBALS(snuffleupagus) 104 size_t in_eval; 105 sp_config config; 106 int is_config_valid; // 1 = valid, 0 = invalid, -1 = none 107 bool allow_broken_configuration; 108 HashTable *disabled_functions_hook; 109 HashTable *sp_internal_functions_hook; 110 HashTable *sp_eval_blacklist_functions_hook; 111 ZEND_END_MODULE_GLOBALS(snuffleupagus) 112 113 ZEND_EXTERN_MODULE_GLOBALS(snuffleupagus) 114 #define SNUFFLEUPAGUS_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(snuffleupagus, v) 115 116 #if defined(ZTS) && defined(COMPILE_DL_SNUFFLEUPAGUS) 117 ZEND_TSRMLS_CACHE_EXTERN() 118 #endif 119 120 PHP_FUNCTION(check_disabled_function); 121 PHP_FUNCTION(eval_blacklist_callback); 122 123 #endif /* PHP_SNUFFLEUPAGUS_H */ 124