⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mod_php4.c

📁 php-4.4.7学习linux时下载的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
		&& (!PG(safe_mode) || (PG(safe_mode) && !auth_type(r)))		&& !strcasecmp(getword(r->pool, &authorization, ' '), "Basic")) {		tmp = uudecode(r->pool, authorization);		tmp_user = getword_nulls_nc(r->pool, &tmp, ':');		SG(request_info).auth_user = NULL;		if (tmp_user) {			r->connection->user = pstrdup(r->connection->pool, tmp_user);			r->connection->ap_auth_type = "Basic";			SG(request_info).auth_user = estrdup(tmp_user);		}		SG(request_info).auth_password = NULL;		if (tmp) {			SG(request_info).auth_password = estrdup(tmp);		}	} else {		SG(request_info).auth_user = NULL;		SG(request_info).auth_password = NULL;	}}/* }}} *//* {{{ php_apache_alter_ini_entries */static int php_apache_alter_ini_entries(php_per_dir_entry *per_dir_entry TSRMLS_DC){	zend_alter_ini_entry(per_dir_entry->key, per_dir_entry->key_length+1, per_dir_entry->value, per_dir_entry->value_length, per_dir_entry->type, PHP_INI_STAGE_ACTIVATE);	return 0;}/* }}} *//* {{{ php_apache_get_default_mimetype */static char *php_apache_get_default_mimetype(request_rec *r TSRMLS_DC){		char *mimetype;	if (SG(default_mimetype) || SG(default_charset)) {		/* Assume output will be of the default MIME type.  Individual		   scripts may change this later. */		char *tmpmimetype;		tmpmimetype = sapi_get_default_content_type(TSRMLS_C);		mimetype = pstrdup(r->pool, tmpmimetype);		efree(tmpmimetype);	} else {		mimetype = SAPI_DEFAULT_MIMETYPE "; charset=" SAPI_DEFAULT_CHARSET;	}	return mimetype;}/* }}} *//* {{{ send_php */static int send_php(request_rec *r, int display_source_mode, char *filename){	int retval;	HashTable *per_dir_conf;	TSRMLS_FETCH();	if (AP(in_request)) {		zend_file_handle fh = {0};		fh.filename = r->filename;		fh.opened_path = NULL;		fh.free_filename = 0;		fh.type = ZEND_HANDLE_FILENAME;#if defined(ZEND_MULTIBYTE) && defined(HAVE_MBSTRING)		php_mb_set_zend_encoding(TSRMLS_C);#endif /* defined(ZEND_MULTIBYTE) && defined(HAVE_MBSTRING) */		zend_execute_scripts(ZEND_INCLUDE TSRMLS_CC, NULL, 1, &fh);		return OK;	}	zend_first_try {		/* Make sure file exists */		if (filename == NULL && r->finfo.st_mode == 0) {			return DECLINED;		}		per_dir_conf = (HashTable *) get_module_config(r->per_dir_config, &php4_module);		if (per_dir_conf) {			zend_hash_apply((HashTable *) per_dir_conf, (apply_func_t) php_apache_alter_ini_entries TSRMLS_CC);		}				/* If PHP parser engine has been turned off with an "engine off"		 * directive, then decline to handle this request		 */		if (!AP(engine)) {			r->content_type = php_apache_get_default_mimetype(r TSRMLS_CC);			r->allowed |= (1 << METHODS) - 1;			zend_try {				zend_ini_deactivate(TSRMLS_C);			} zend_end_try();			return DECLINED;		}		if (filename == NULL) {			filename = r->filename;		}		/* Apache 1.2 has a more complex mechanism for reading POST data */#if MODULE_MAGIC_NUMBER > 19961007		if ((retval = setup_client_block(r, REQUEST_CHUNKED_ERROR))) {			zend_try {				zend_ini_deactivate(TSRMLS_C);			} zend_end_try();			return retval;		}#endif		if (AP(last_modified)) {#if MODULE_MAGIC_NUMBER < 19970912			if ((retval = set_last_modified(r, r->finfo.st_mtime))) {				zend_try {					zend_ini_deactivate(TSRMLS_C);				} zend_end_try();				return retval;			}#else			update_mtime (r, r->finfo.st_mtime);			set_last_modified(r);			set_etag(r);#endif		}		/* Assume output will be of the default MIME type.  Individual		   scripts may change this later in the request. */		r->content_type = php_apache_get_default_mimetype(r TSRMLS_CC);		/* Init timeout */		hard_timeout("send", r);		SG(server_context) = r;				php_save_umask();		add_common_vars(r);		add_cgi_vars(r);		init_request_info(TSRMLS_C);		apache_php_module_main(r, display_source_mode TSRMLS_CC);		/* Done, restore umask, turn off timeout, close file and return */		php_restore_umask();		kill_timeout(r);	} zend_end_try();	return OK;}/* }}} *//* {{{ send_parsed_php */static int send_parsed_php(request_rec * r){	int result = send_php(r, 0, NULL);#if MEMORY_LIMIT	{		char *mem_usage;		TSRMLS_FETCH(); 		mem_usage = ap_psprintf(r->pool, "%u", AG(allocated_memory_peak));		AG(allocated_memory_peak) = 0;		ap_table_setn(r->notes, "mod_php_memory_usage", mem_usage);	}#endif	return result;}/* }}} *//* {{{ send_parsed_php_source */static int send_parsed_php_source(request_rec * r){	return send_php(r, 1, NULL);}/* }}} *//* {{{ destroy_per_dir_entry */static void destroy_per_dir_entry(php_per_dir_entry *per_dir_entry){	free(per_dir_entry->key);	free(per_dir_entry->value);}/* }}} *//* {{{ copy_per_dir_entry */static void copy_per_dir_entry(php_per_dir_entry *per_dir_entry){	php_per_dir_entry tmp = *per_dir_entry;	per_dir_entry->key = (char *) malloc(tmp.key_length+1);	memcpy(per_dir_entry->key, tmp.key, tmp.key_length);	per_dir_entry->key[per_dir_entry->key_length] = 0;	per_dir_entry->value = (char *) malloc(tmp.value_length+1);	memcpy(per_dir_entry->value, tmp.value, tmp.value_length);	per_dir_entry->value[per_dir_entry->value_length] = 0;}/* }}} *//* {{{ should_overwrite_per_dir_entry */static zend_bool should_overwrite_per_dir_entry(php_per_dir_entry *orig_per_dir_entry, php_per_dir_entry *new_per_dir_entry){	if (new_per_dir_entry->type==PHP_INI_SYSTEM		&& orig_per_dir_entry->type!=PHP_INI_SYSTEM) {		return 1;	} else {		return 0;	}}/* }}} *//* {{{ php_destroy_per_dir_info */static void php_destroy_per_dir_info(HashTable *per_dir_info){	zend_hash_destroy(per_dir_info);	free(per_dir_info);}/* }}} *//* {{{ php_create_dir */static void *php_create_dir(pool *p, char *dummy){	HashTable *per_dir_info;	per_dir_info = (HashTable *) malloc(sizeof(HashTable));	zend_hash_init_ex(per_dir_info, 5, NULL, (void (*)(void *)) destroy_per_dir_entry, 1, 0);	register_cleanup(p, (void *) per_dir_info, (void (*)(void *)) php_destroy_per_dir_info, (void (*)(void *)) zend_hash_destroy);	return per_dir_info;}/* }}} *//* {{{ php_merge_dir */static void *php_merge_dir(pool *p, void *basev, void *addv){	/* This function *must* return addv, and not modify basev */	zend_hash_merge_ex((HashTable *) addv, (HashTable *) basev, (copy_ctor_func_t) copy_per_dir_entry, sizeof(php_per_dir_entry), (zend_bool (*)(void *, void *)) should_overwrite_per_dir_entry);	return addv;}/* }}} *//* {{{ php_apache_value_handler_ex */static CONST_PREFIX char *php_apache_value_handler_ex(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2, int mode){	php_per_dir_entry per_dir_entry;	if (!apache_php_initialized) {		apache_php_initialized = 1;#ifdef ZTS		tsrm_startup(1, 1, 0, NULL);#endif		sapi_startup(&apache_sapi_module);		php_apache_startup(&apache_sapi_module);	}	per_dir_entry.type = mode;	if (strcasecmp(arg2, "none") == 0) {		arg2 = "";	}	per_dir_entry.key_length = strlen(arg1);	per_dir_entry.value_length = strlen(arg2);	per_dir_entry.key = (char *) malloc(per_dir_entry.key_length+1);	memcpy(per_dir_entry.key, arg1, per_dir_entry.key_length);	per_dir_entry.key[per_dir_entry.key_length] = 0;	per_dir_entry.value = (char *) malloc(per_dir_entry.value_length+1);	memcpy(per_dir_entry.value, arg2, per_dir_entry.value_length);	per_dir_entry.value[per_dir_entry.value_length] = 0;	zend_hash_update(conf, per_dir_entry.key, per_dir_entry.key_length, &per_dir_entry, sizeof(php_per_dir_entry), NULL);	return NULL;}/* }}} *//* {{{ php_apache_value_handler */static CONST_PREFIX char *php_apache_value_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2){	return php_apache_value_handler_ex(cmd, conf, arg1, arg2, PHP_INI_PERDIR);}/* }}} *//* {{{ php_apache_admin_value_handler */static CONST_PREFIX char *php_apache_admin_value_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2){	return php_apache_value_handler_ex(cmd, conf, arg1, arg2, PHP_INI_SYSTEM);}/* }}} *//* {{{ php_apache_flag_handler_ex */static CONST_PREFIX char *php_apache_flag_handler_ex(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2, int mode){	char bool_val[2];	if (!strcasecmp(arg2, "On") || (arg2[0] == '1' && arg2[1] == '\0')) {		bool_val[0] = '1';	} else {		bool_val[0] = '0';	}	bool_val[1] = 0;		return php_apache_value_handler_ex(cmd, conf, arg1, bool_val, mode);}/* }}} *//* {{{ php_apache_flag_handler */static CONST_PREFIX char *php_apache_flag_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2){	return php_apache_flag_handler_ex(cmd, conf, arg1, arg2, PHP_INI_PERDIR);}/* }}} *//* {{{ php_apache_admin_flag_handler */static CONST_PREFIX char *php_apache_admin_flag_handler(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2){	return php_apache_flag_handler_ex(cmd, conf, arg1, arg2, PHP_INI_SYSTEM);}/* }}} *//* {{{ int php_xbithack_handler(request_rec * r) */static int php_xbithack_handler(request_rec * r){	HashTable *per_dir_conf;	TSRMLS_FETCH();	if (!(r->finfo.st_mode & S_IXUSR)) {		r->allowed |= (1 << METHODS) - 1;		return DECLINED;	}	per_dir_conf = (HashTable *) get_module_config(r->per_dir_config, &php4_module);	if (per_dir_conf) {		zend_hash_apply((HashTable *) per_dir_conf, (apply_func_t) php_apache_alter_ini_entries TSRMLS_CC);	}	if(!AP(xbithack)) {		r->allowed |= (1 << METHODS) - 1;		zend_try {			zend_ini_deactivate(TSRMLS_C);		} zend_end_try();		return DECLINED;	}	return send_parsed_php(r);}/* }}} *//* {{{ apache_php_module_shutdown_wrapper */static void apache_php_module_shutdown_wrapper(void){	apache_php_initialized = 0;	apache_sapi_module.shutdown(&apache_sapi_module);#if MODULE_MAGIC_NUMBER >= 19970728	/* This function is only called on server exit if the apache API	 * child_exit handler exists, so shutdown globally 	 */	sapi_shutdown();#endif#ifdef ZTS	tsrm_shutdown();#endif}/* }}} */#if MODULE_MAGIC_NUMBER >= 19970728/* {{{ php_child_exit_handler */static void php_child_exit_handler(server_rec *s, pool *p){/*	apache_php_initialized = 0; */	apache_sapi_module.shutdown(&apache_sapi_module);#ifdef ZTS	tsrm_shutdown();#endif}/* }}} */#endif/* {{{ void php_init_handler(server_rec *s, pool *p) */static void php_init_handler(server_rec *s, pool *p){	register_cleanup(p, NULL, (void (*)(void *))apache_php_module_shutdown_wrapper, (void (*)(void *))php_module_shutdown_for_exec);	if (!apache_php_initialized) {		apache_php_initialized = 1;#ifdef ZTS		tsrm_startup(1, 1, 0, NULL);#endif		sapi_startup(&apache_sapi_module);		php_apache_startup(&apache_sapi_module);	}#if MODULE_MAGIC_NUMBER >= 19980527	{		TSRMLS_FETCH();		if (PG(expose_php)) {			ap_add_version_component("PHP/" PHP_VERSION);		}	}#endif}/* }}} *//* {{{ handler_rec php_handlers[] */handler_rec php_handlers[] ={	{"application/x-httpd-php", send_parsed_php},	{"application/x-httpd-php-source", send_parsed_php_source},	{"text/html", php_xbithack_handler},	{NULL}};/* }}} *//* {{{ command_rec php_commands[] */command_rec php_commands[] ={	{"php_value",		php_apache_value_handler, NULL, OR_OPTIONS, TAKE2, "PHP Value Modifier"},	{"php_flag",		php_apache_flag_handler, NULL, OR_OPTIONS, TAKE2, "PHP Flag Modifier"},	{"php_admin_value",	php_apache_admin_value_handler, NULL, ACCESS_CONF|RSRC_CONF, TAKE2, "PHP Value Modifier (Admin)"},	{"php_admin_flag",	php_apache_admin_flag_handler, NULL, ACCESS_CONF|RSRC_CONF, TAKE2, "PHP Flag Modifier (Admin)"},	{NULL}};/* }}} *//* {{{ odule MODULE_VAR_EXPORT php4_module */module MODULE_VAR_EXPORT php4_module ={	STANDARD_MODULE_STUFF,	php_init_handler,			/* initializer */	php_create_dir,				/* per-directory config creator */	php_merge_dir,				/* dir merger */	NULL,						/* per-server config creator */	NULL, 						/* merge server config */	php_commands,				/* command table */	php_handlers,				/* handlers */	NULL,						/* filename translation */	NULL,						/* check_user_id */	NULL,						/* check auth */	NULL,						/* check access */	NULL,						/* type_checker */	NULL,						/* fixups */	NULL						/* logger */#if MODULE_MAGIC_NUMBER >= 19970103	, NULL						/* header parser */#endif#if MODULE_MAGIC_NUMBER >= 19970719	, NULL             			/* child_init */#endif#if MODULE_MAGIC_NUMBER >= 19970728	, php_child_exit_handler		/* child_exit */#endif#if MODULE_MAGIC_NUMBER >= 19970902	, NULL						/* post read-request */#endif};/* }}} *//* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: sw=4 ts=4 fdm=marker * vim<600: sw=4 ts=4 */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -