SHARE
TWEET

Semple initialization

a guest Feb 10th, 2020 12 in 219 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void destructor() {
  2.     if(TmpPHPInit.SessionInit2) {
  3.         sapi_deactivate();
  4.         zend_ini_deactivate();
  5.     }
  6.     php_request_shutdown((void *) 0);
  7.  
  8.     if(TmpPHPInit.SessionInit) php_module_shutdown();
  9.  
  10.     sapi_shutdown();
  11.     tsrm_shutdown();
  12. }
  13.  
  14.  
  15. SAPI_API PHPOptions *PHPInit(char * name, char * pretty_name) {
  16.     memset(&TmpPHPInit, 0, sizeof(PHPOptions));
  17.     memset(&TmpPHPInit.sapi_module, 0, sizeof(sapi_module_struct));
  18.    
  19.    
  20.     TmpPHPInit.SizeZval = sizeof(zval);
  21.     TmpPHPInit.destructor = destructor;
  22.     TmpPHPInit.evalCode= evalCode;
  23.  
  24.     TmpPHPInit.sapi_module.name = strdup(name);
  25.     TmpPHPInit.sapi_module.pretty_name = strdup(pretty_name);
  26.     TmpPHPInit.sapi_module.startup = php_cli_startup;
  27.     TmpPHPInit.sapi_module.shutdown = php_module_shutdown_wrapper;
  28.     TmpPHPInit.sapi_module.deactivate = sapi_cli_deactivate;
  29.     TmpPHPInit.sapi_module.ub_write = Engineub_write;
  30.     TmpPHPInit.sapi_module.flush = sapi_cli_flush;
  31.     TmpPHPInit.sapi_module.sapi_error = php_error;
  32.     TmpPHPInit.sapi_module.header_handler = sapi_cli_header_handler;
  33.     TmpPHPInit.sapi_module.send_headers = sapi_cli_send_headers;
  34.     TmpPHPInit.sapi_module.send_header = sapi_cli_send_header;
  35.     TmpPHPInit.sapi_module.read_cookies = sapi_cli_read_cookies;
  36.     TmpPHPInit.sapi_module.register_server_variables = sapi_cli_register_variables;
  37.     TmpPHPInit.sapi_module.log_message = sapi_cli_log_message;
  38.    
  39.    
  40.     // В будущем используйте zend_register_functions с пометкой CG(function_table)
  41.     TmpPHPInit.sapi_module.additional_functions = additional_functions;
  42.     TmpPHPInit.sapi_module.php_ini_path_override = strdup("php.ini");
  43.    
  44.    
  45.     php_tsrm_startup();
  46.     ZEND_TSRMLS_CACHE_UPDATE();
  47.     zend_signal_startup();
  48.    
  49.    
  50.     TmpPHPInit.sapi_module.ini_defaults = Engineini_defaults;
  51.     TmpPHPInit.sapi_module.phpinfo_as_text = 1;
  52.     TmpPHPInit.sapi_module.php_ini_ignore_cwd = 1;
  53.    
  54.     sapi_startup(&TmpPHPInit.sapi_module);
  55.    
  56.     if (TmpPHPInit.sapi_module.startup(&TmpPHPInit.sapi_module) != FAILURE) {
  57.         TmpPHPInit.SessionInit = 1;
  58.         TmpPHPInit.SessionInit2 = php_request_startup()!=FAILURE;
  59.     }
  60.    
  61.     return &TmpPHPInit;
  62. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top