otherwise, only allow 1 (enabled), and error on disabling */
ZEND_INI_MH(phar_ini_modify_handler) /* {{{ */
{
- zend_bool *p, test;
-#ifndef ZTS
- char *base = (char *) mh_arg2;
-#else
- char *base;
-
- base = (char *) ts_resource(*((int *) mh_arg2));
-#endif
+ zend_bool old, ini;
- p = (zend_bool *) (base+(size_t) mh_arg1);
+ if (entry->name_length == 14) {
+ old = PHAR_G(readonly_orig);
+ } else {
+ old = PHAR_G(require_hash_orig);
+ }
- if (new_value_length==2 && strcasecmp("on", new_value)==0) {
- *p = (zend_bool) 1;
+ if (new_value_length == 2 && !strcasecmp("on", new_value)) {
+ ini = (zend_bool) 1;
}
- else if (new_value_length==3 && strcasecmp("yes", new_value)==0) {
- *p = (zend_bool) 1;
+ else if (new_value_length == 3 && !strcasecmp("yes", new_value)) {
+ ini = (zend_bool) 1;
}
- else if (new_value_length==4 && strcasecmp("true", new_value)==0) {
- *p = (zend_bool) 1;
+ else if (new_value_length == 4 && !strcasecmp("true", new_value)) {
+ ini = (zend_bool) 1;
}
else {
- *p = (zend_bool) atoi(new_value);
- }
- if (stage == ZEND_INI_STAGE_STARTUP && !entry->modified) {
- /* this is more efficient than processing orig_value every time */
- if (entry->name_length == 14) { /* phar.readonly */
- PHAR_G(readonly_orig) = *p;
- } else { /* phar.require_hash */
- PHAR_G(require_hash_orig) = *p;
- }
+ ini = (zend_bool) atoi(new_value);
}
- if (stage != ZEND_INI_STAGE_STARTUP) {
- if (entry->name_length == 14) { /* phar.readonly */
- test = PHAR_G(readonly_orig);
- } else { /* phar.require_hash */
- test = PHAR_G(require_hash_orig);
+
+ /* do not allow unsetting in runtime */
+ if (stage == ZEND_INI_STAGE_STARTUP) {
+ if (entry->name_length == 14) {
+ PHAR_G(readonly_orig) = ini;
+ } else {
+ PHAR_G(require_hash_orig) = ini;
}
- if (test && !*p) {
- /* do not allow unsetting in runtime */
- *p = (zend_bool) 1;
- return FAILURE;
- }
+ } else if (old && !ini) {
+ return FAILURE;
}
+
+ if (entry->name_length == 14) {
+ PHAR_G(readonly) = ini;
+ } else {
+ PHAR_G(require_hash) = ini;
+ }
return SUCCESS;
}
/* }}}*/