@@ -71,6 +71,7 @@ zend_module_entry appserver_module_entry = {
7171};
7272
7373PHP_INI_BEGIN ()
74+ PHP_INI_ENTRY ("appserver.php_sapi" , "" , PHP_INI_ALL , NULL )
7475PHP_INI_ENTRY ("appserver.remove_functions" , "" , PHP_INI_ALL , NULL )
7576PHP_INI_ENTRY ("appserver.remove_constants" , "" , PHP_INI_ALL , NULL )
7677PHP_INI_END ()
@@ -207,23 +208,25 @@ PHP_RINIT_FUNCTION(appserver)
207208 char * ptr , * str , * sapiconst = APPSERVER_CONSTANT_PHP_SAPI ;
208209 zend_constant * defined ;
209210 zval * new_phpsapi ;
210- char * new_phpsapi_name = APPSERVER_SAPI_NAME ;
211-
212- /* create zval for new sapi string */
213- MAKE_STD_ZVAL (new_phpsapi );
214- ZVAL_STRING (new_phpsapi , new_phpsapi_name , 1 );
215-
216- /* check if PHP_SAPI const can be found to overwrite cli sapi name to appserver */
217- if (zend_hash_find (EG (zend_constants ), sapiconst , strlen (sapiconst )+ 1 , (void * * ) & defined ) == SUCCESS ) {
218- /* create new constant with new php sapi name */
219- zend_constant c ;
220- c .value = * new_phpsapi ;
221- c .flags = PHP_USER_CONSTANT ;
222- c .name = zend_strndup (& sapiconst , strlen (sapiconst ));
223- c .name_len = strlen (sapiconst ) + 1 ;
224- c .module_number = 0 ;
225- /* update PHP_SAPI constant in hash table */
226- zend_hash_update (EG (zend_constants ), sapiconst , strlen (sapiconst )+ 1 , (void * )& c , sizeof (zend_constant ), (void * * )& c );
211+ char * new_phpsapi_name ;
212+
213+ if (INI_STR ("appserver.php_sapi" ) != "" ) {
214+ new_phpsapi_name = INI_STR ("appserver.php_sapi" );
215+ /* check if PHP_SAPI const can be found to overwrite cli sapi name to appserver */
216+ if (zend_hash_find (EG (zend_constants ), sapiconst , strlen (sapiconst )+ 1 , (void * * ) & defined ) == SUCCESS ) {
217+ /* create zval for new sapi string */
218+ MAKE_STD_ZVAL (new_phpsapi );
219+ ZVAL_STRING (new_phpsapi , new_phpsapi_name , 1 );
220+ /* create new constant with new php sapi name */
221+ zend_constant c ;
222+ c .value = * new_phpsapi ;
223+ c .flags = PHP_USER_CONSTANT ;
224+ c .name = zend_strndup (& sapiconst , strlen (sapiconst ));
225+ c .name_len = strlen (sapiconst ) + 1 ;
226+ c .module_number = 0 ;
227+ /* update PHP_SAPI constant in hash table */
228+ zend_hash_update (EG (zend_constants ), sapiconst , strlen (sapiconst )+ 1 , (void * )& c , sizeof (zend_constant ), (void * * )& c );
229+ }
227230 }
228231
229232 /* remove functions given in ini setting */
0 commit comments