软件著作权-源代码范本

更新时间:2024-04-12 12:17:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

天一博胜企业管理软件V1.0 源代码

1

软件著作权-源代码范本

注意事项:常见的源代码包含:C语言,VB,C++,JAVA,.NET等。

提交的代码必须是源代码的开头载入程序,第30页必须断开,第60页是软件的程序结尾,代码中不得出现与申请表内容不符合的日期,著作权人,软件名字等,不能出现开源代码,不能出现任何版权纠纷。

格式要求:一、源代码应提交前、后各连续30页,不足60页的,应当全部提交。

二、源代码页眉应标注软件的名称和版本号,应当与申请表中名称完全一致,页

眉右上应标注页码,源代码每页不少于50行。

范例如下:

#include #include #include

天一博胜企业管理软件V1.0 源代码

2

#include #include #include

#include #include #include #include #include #include #include #include #include #include #include #include #include #define NS_MAIN 1

#include #endif

#ifdef DLZ

#include #endif

static tybs_boolean_t want_stats = TYBS_FALSE; static char program_name[TYBS_DIR_NAMEMAX] = \static char absolute_conffile[TYBS_DIR_PATHMAX]; static char saved_command_line[512]; static char version[512]; static unsigned int maxsocks = 0; void

ns_main_earlywarning(const char *format, ...) { va_list args; va_start(args, format); if (ns_g_lctx != NULL) { tybs_log_vwrite(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_WARNING, format, args); } else { fprintf(stderr, \ vfprintf(stderr, format, args); fprintf(stderr, \ fflush(stderr); } va_end(args); }

Void ns_main_earlyfatal(const char *format, ...) { va_list args; va_start(args, format); if (ns_g_lctx != NULL) { tybs_log_vwrite(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL, format, args); tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,

天一博胜企业管理软件V1.0 源代码

3

NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL, \ } else { fprintf(stderr, \ vfprintf(stderr, format, args); fprintf(stderr, \ fflush(stderr); } va_end(args); exit(1); }

static void

assertion_failed(const char *file, int line, tybs_assertiontype_t type, const char *cond) { if (ns_g_lctx != NULL) { tybs_assertion_setcallback(NULL); tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL, \ tybs_assertion_typetotext(type), cond); tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL, \ } else { fprintf(stderr, \ file, line, tybs_assertion_typetotext(type), cond); fflush(stderr); } if (ns_g_coreok) abort(); exit(1); }

static void

library_fatal_error(const char *file, int line, const char *format, va_list args) TYBS_FORMAT_PRINTF(3, 0); static void

library_fatal_error(const char *file, int line, const char *format, va_list args) { if (ns_g_lctx != NULL) { tybs_error_setfatal(NULL); tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL, \ tybs_log_vwrite(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL, format, args); tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL, \ } else {

天一博胜企业管理软件V1.0 源代码

4

fprintf(stderr, \ vfprintf(stderr, format, args); fprintf(stderr, \ fflush(stderr); } if (ns_g_coreok) abort(); exit(1); }

static void

library_unexpected_error(const char *file, int line, const char *format, va_list args) TYBS_FORMAT_PRINTF(3, 0); static void

library_unexpected_error(const char *file, int line, const char *format, va_list args) { if (ns_g_lctx != NULL) { tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_ERROR, \ tybs_log_vwrite(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_ERROR, format, args); } else { fprintf(stderr, \ vfprintf(stderr, format, args); fprintf(stderr, \ fflush(stderr); } }

static void

lwresd_usage(void) { fprintf(stderr, \ \ \ [-f|-g] [-n number_of_cpus] [-p port] \ \ \ [-t chrootdir] [-u username] [-i pidfile]\\n\ \ [-m {usage|trace|record|size|mctx}]\\n\}

static void usage(void) { if (ns_g_lwresdonly) { lwresd_usage(); return; } fprintf(stderr, \ \ \ [-p port] [-s] [-t chrootdir] [-u username]\\n\ \ [-m {usage|trace|record|size|mctx}]\\n\}

天一博胜企业管理软件V1.0 源代码

5

static void

save_command_line(int argc, char *argv[]) { int i; char *src; char *dst; char *eob; const char truncated[] = \ tybs_boolean_t quoted = TYBS_FALSE; dst = saved_command_line; eob = saved_command_line + sizeof(saved_command_line); for (i = 1; i < argc && dst < eob; i++) { *dst++ = ' '; src = argv[i]; while (*src != '\\0' && dst < eob) { if (quoted || isalnum(*src & 0xff) || *src == '-' || *src == '_' || *src == '.' || *src == '/') { *dst++ = *src++; quoted = TYBS_FALSE; } else { *dst++ = '\\\\'; quoted = TYBS_TRUE; } } } INSIST(sizeof(saved_command_line) >= sizeof(truncated)); if (dst == eob) strcpy(eob - sizeof(truncated), truncated); else *dst = '\\0'; }

static int

parse_int(char *arg, const char *desc) { char *endp; int tmp; long int ltmp; ltmp = strtol(arg, &endp, 10); tmp = (int) ltmp; if (*endp != '\\0') ns_main_earlyfatal(\ if (tmp < 0 || tmp != ltmp) ns_main_earlyfatal(\ return (tmp); }

static struct flag_def { const char *name; unsigned int value; } mem_debug_flags[] = { { \ TYBS_MEM_DEBUGTRACE }, { \ { \ { \

天一博胜企业管理软件V1.0 源代码

6

{ \ { NULL, 0 } };

static void

set_flags(const char *arg, struct flag_def *defs, unsigned int *ret) { for (;;) { const struct flag_def *def; const char *end = strchr(arg, ','); int arglen; if (end == NULL) end = arg + strlen(arg); arglen = end - arg; for (def = defs; def->name != NULL; def++) { if (arglen == (int)strlen(def->name) && memcmp(arg, def->name, arglen) == 0) { *ret |= def->value; goto found; } } ns_main_earlyfatal(\ found: if (*end == '\\0') break; arg = end + 1; } }

static void

parse_command_line(int argc, char *argv[]) { int ch; int port; tybs_boolean_t disable6 = TYBS_FALSE; tybs_boolean_t disable4 = TYBS_FALSE; save_command_line(argc, argv); tybs_commandline_errprint = TYBS_FALSE; while ((ch = tybs_commandline_parse(argc, argv, \ \ switch (ch) { case '4': if (disable4) ns_main_earlyfatal(\ if (tybs_net_probeipv4() != TYBS_R_SUCCESS) ns_main_earlyfatal(\ tybs_net_disableipv6(); disable6 = TYBS_TRUE; break; case '6': if (disable6) ns_main_earlyfatal(\ if (tybs_net_probeipv6() != TYBS_R_SUCCESS) ns_main_earlyfatal(\ tybs_net_disableipv4();

天一博胜企业管理软件V1.0 源代码

7

disable4 = TYBS_TRUE; break; case 'c': ns_g_conffile = tybs_commandline_argument; lwresd_g_conffile = tybs_commandline_argument; if (lwresd_g_useresolvconf) ns_main_earlyfatal(\ ns_g_conffileset = TYBS_TRUE; break; case 'C': lwresd_g_resolvconffile = tybs_commandline_argument; if (ns_g_conffileset) ns_main_earlyfatal(\ lwresd_g_useresolvconf = TYBS_TRUE; break; case 'd': ns_g_debuglevel = parse_int(tybs_commandline_argument, \ break; case 'f': ns_g_foreground = TYBS_TRUE; break; case 'g': ns_g_foreground = TYBS_TRUE; ns_g_logstderr = TYBS_TRUE; break;

/* XXXBEW -i should be removed */ case 'i': lwresd_g_defaultpidfile = tybs_commandline_argument; break; case 'l': ns_g_lwresdonly = TYBS_TRUE; break; case 'm': set_flags(tybs_commandline_argument, mem_debug_flags, &tybs_mem_debugging); break;

case 'N': /* Deprecated. */ case 'n': ns_g_cpus = parse_int(tybs_commandline_argument, \ if (ns_g_cpus == 0) ns_g_cpus = 1; break; case 'p': port = parse_int(tybs_commandline_argument, \ if (port < 1 || port > 65535) ns_main_earlyfatal(\ tybs_commandline_argument); ns_g_port = port; break;

/* XXXBEW Should -P be removed? */

天一博胜企业管理软件V1.0 源代码

8

case 'P': port = parse_int(tybs_commandline_argument, \ if (port < 1 || port > 65535) ns_main_earlyfatal(\ tybs_commandline_argument); lwresd_g_listenport = port; break; case 's': want_stats = TYBS_TRUE; break; case 'S': maxsocks = parse_int(tybs_commandline_argument, \ break; case 't': ns_g_chrootdir = tybs_commandline_argument; break; case 'T': if (strcmp(tybs_commandline_argument, \ ns_g_clienttest = TYBS_TRUE; else fprintf(stderr, \ tybs_commandline_argument); break; case 'u': ns_g_username = tybs_commandline_argument; break; case 'v': printf(\ exit(0); case 'V': printf(\ ns_g_configargs); exit(0); case '?': usage(); if (tybs_commandline_option == '?') exit(0); ns_main_earlyfatal(\ tybs_commandline_option); default: ns_main_earlyfatal(\ } } argc -= tybs_commandline_index; argv += tybs_commandline_index; if (argc > 0) { usage(); ns_main_earlyfatal(\ } }

static tybs_result_t

天一博胜企业管理软件V1.0 源代码

9

create_managers(void) { tybs_result_t result; unsigned int socks;

#ifdef TYBS_PLATFORM_USETHREADS unsigned int cpus_detected; #endif

#ifdef TYBS_PLATFORM_USETHREADS cpus_detected = tybs_os_ncpus(); if (ns_g_cpus == 0) ns_g_cpus = cpus_detected; tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER, TYBS_LOG_INFO, \ cpus_detected, cpus_detected == 1 ? \ ns_g_cpus, ns_g_cpus == 1 ? \#else ns_g_cpus = 1; #endif result = tybs_taskmgr_create(ns_g_mctx, ns_g_cpus, 0, &ns_g_taskmgr); if (result != TYBS_R_SUCCESS) { UNEXPECTED_ERROR(__FILE__, __LINE__, \ tybs_result_totext(result)); return (TYBS_R_UNEXPECTED); } result = tybs_timermgr_create(ns_g_mctx, &ns_g_timermgr); if (result != TYBS_R_SUCCESS) { UNEXPECTED_ERROR(__FILE__, __LINE__, \ tybs_result_totext(result)); return (TYBS_R_UNEXPECTED); } result = tybs_socketmgr_create2(ns_g_mctx, &ns_g_socketmgr, maxsocks); if (result != TYBS_R_SUCCESS) { UNEXPECTED_ERROR(__FILE__, __LINE__, \ tybs_result_totext(result)); return (TYBS_R_UNEXPECTED); } result = tybs_socketmgr_getmaxsockets(ns_g_socketmgr, &socks); if (result == TYBS_R_SUCCESS) { tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER, TYBS_LOG_INFO, \ } result = tybs_entropy_create(ns_g_mctx, &ns_g_entropy); if (result != TYBS_R_SUCCESS) { UNEXPECTED_ERROR(__FILE__, __LINE__, \ tybs_result_totext(result)); return (TYBS_R_UNEXPECTED); } result = tybs_hash_create(ns_g_mctx, ns_g_entropy, DNS_NAME_MAXWIRE);

天一博胜企业管理软件V1.0 源代码

10

if (result != TYBS_R_SUCCESS) { UNEXPECTED_ERROR(__FILE__, __LINE__, \ tybs_result_totext(result)); return (TYBS_R_UNEXPECTED); } return (TYBS_R_SUCCESS); }

static void

destroy_managers(void) { ns_lwresd_shutdown(); tybs_entropy_detach(&ns_g_entropy); if (ns_g_fallbackentropy != NULL) tybs_entropy_detach(&ns_g_fallbackentropy); tybs_taskmgr_destroy(&ns_g_taskmgr); tybs_timermgr_destroy(&ns_g_timermgr); tybs_socketmgr_destroy(&ns_g_socketmgr); tybs_hash_destroy(); }

static void setup(void) { tybs_result_t result; #ifdef HAVE_LIBSCF char *instance = NULL; #endif ns_os_inituserinfo(ns_g_username); ns_os_tzset(); ns_os_opendevnull(); #ifdef HAVE_LIBSCF result = ns_smf_get_instance(&instance, 0, ns_g_mctx); if (result == TYBS_R_SUCCESS) ns_smf_got_instance = 1; else ns_smf_got_instance = 0; if (instance != NULL) tybs_mem_free(ns_g_mctx, instance); #endif /* HAVE_LIBSCF */ #ifdef PATH_RANDOMDEV if (ns_g_chrootdir != NULL) { result = tybs_entropy_create(ns_g_mctx, &ns_g_fallbackentropy); if (result != TYBS_R_SUCCESS) ns_main_earlyfatal(\ tybs_result_totext(result)); result = tybs_entropy_createfilesource(ns_g_fallbackentropy, PATH_RANDOMDEV); if (result != TYBS_R_SUCCESS) { ns_main_earlywarning(\ \ PATH_RANDOMDEV, tybs_result_totext(result)); tybs_entropy_detach(&ns_g_fallbackentropy); }

天一博胜企业管理软件V1.0 源代码

11

} #endif ns_os_chroot(ns_g_chrootdir); ns_os_minprivs(); result = ns_log_init(TYBS_TF(ns_g_username != NULL)); if (result != TYBS_R_SUCCESS) ns_main_earlyfatal(\ tybs_result_totext(result)); if (!ns_g_foreground) ns_os_daemonize(); result = tybs_app_start(); if (result != TYBS_R_SUCCESS) ns_main_earlyfatal(\ tybs_result_totext(result)); tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_NOTICE, \ saved_command_line); tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_NOTICE, \ (void)tybs_resource_getlimit(tybs_resource_stacksize, &ns_g_initstacksize); (void)tybs_resource_getlimit(tybs_resource_datasize, &ns_g_initdatasize); (void)tybs_resource_getlimit(tybs_resource_coresize, &ns_g_initcoresize); (void)tybs_resource_getlimit(tybs_resource_openfiles, &ns_g_initopenfiles); if (! tybs_file_isabsolute(ns_g_conffile)) { result = tybs_file_absolutepath(ns_g_conffile, absolute_conffile, sizeof(absolute_conffile)); if (result != TYBS_R_SUCCESS) ns_main_earlyfatal(\ \ tybs_result_totext(result)); ns_g_conffile = absolute_conffile; } result = tybs_time_now(&ns_g_boottime); if (result != TYBS_R_SUCCESS) ns_main_earlyfatal(\ tybs_result_totext(result)); result = create_managers(); if (result != TYBS_R_SUCCESS) ns_main_earlyfatal(\ tybs_result_totext(result)); ns_builtin_init(); #ifdef DLZ result = dlz_drivers_init(); if (result != TYBS_R_SUCCESS) ns_main_earlyfatal(\ tybs_result_totext(result)); #endif

天一博胜企业管理软件V1.0 源代码

12

ns_server_create(ns_g_mctx, &ns_g_server); }

static void

cleanup(void) { destroy_managers(); ns_server_destroy(&ns_g_server); ns_builtin_deinit(); #ifdef DLZ dlz_drivers_clear(); #endif dns_name_destroy(); tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_NOTICE, \ ns_log_shutdown(); }

static char *memstats = NULL; void

ns_main_setmemstats(const char *filename) { if (memstats != NULL) { free(memstats); memstats = NULL; } if (filename == NULL) return; memstats = malloc(strlen(filename) + 1); if (memstats) strcpy(memstats, filename); }

#ifdef HAVE_LIBSCF tybs_result_t

ns_smf_get_instance(char **ins_name, int debug, tybs_mem_t *mctx) { scf_handle_t *h = NULL; int namelen; char *instance; REQUIRE(ins_name != NULL && *ins_name == NULL); if ((h = scf_handle_create(SCF_VERSION)) == NULL) { if (debug) UNEXPECTED_ERROR(__FILE__, __LINE__, \ scf_strerror(scf_error())); return (TYBS_R_FAILURE); } if (scf_handle_bind(h) == -1) { if (debug) UNEXPECTED_ERROR(__FILE__, __LINE__, \ scf_strerror(scf_error())); scf_handle_destroy(h); return (TYBS_R_FAILURE); } if ((namelen = scf_myname(h, NULL, 0)) == -1) { if (debug)

天一博胜企业管理软件V1.0 源代码

13

UNEXPECTED_ERROR(__FILE__, __LINE__, \ scf_strerror(scf_error())); scf_handle_destroy(h); return (TYBS_R_FAILURE); } if ((instance = tybs_mem_allocate(mctx, namelen + 1)) == NULL) { UNEXPECTED_ERROR(__FILE__, __LINE__, \ \ tybs_result_totext(TYBS_R_NOMEMORY)); scf_handle_destroy(h); return (TYBS_R_FAILURE); } if (scf_myname(h, instance, namelen + 1) == -1) { if (debug) UNEXPECTED_ERROR(__FILE__, __LINE__, \ scf_strerror(scf_error())); scf_handle_destroy(h); tybs_mem_free(mctx, instance); return (TYBS_R_FAILURE); } scf_handle_destroy(h); *ins_name = instance; return (TYBS_R_SUCCESS); }

#endif int

main(int argc, char *argv[]) { tybs_result_t result; #ifdef HAVE_LIBSCF char *instance = NULL; #endif strlcat(version, #ifdef __DATE__ \TE__ \#else \#endif sizeof(version)); result = tybs_file_progname(*argv, program_name, sizeof(program_name)); if (result != TYBS_R_SUCCESS) ns_main_earlyfatal(\ if (strcmp(program_name, \ ns_g_lwresdonly = TYBS_TRUE; tybs_assertion_setcallback(assertion_failed); tybs_error_setfatal(library_fatal_error); tybs_error_setunexpected(library_unexpected_error); ns_os_init(program_name); dns_result_register(); dst_result_register();

天一博胜企业管理软件V1.0 源代码

14

tybscc_result_register(); parse_command_line(argc, argv); if (ns_g_chrootdir != NULL) { int len = strlen(ns_g_chrootdir); if (strncmp(ns_g_chrootdir, ns_g_conffile, len) == 0 && (ns_g_conffile[len] == '/' || ns_g_conffile[len] == '\\\\')) ns_main_earlywarning(\ \ ns_g_conffile, ns_g_chrootdir); } result = tybs_mem_create(0, 0, &ns_g_mctx); if (result != TYBS_R_SUCCESS) ns_main_earlyfatal(\ tybs_result_totext(result)); tybs_mem_setname(ns_g_mctx, \ setup(); do { result = tybs_app_run(); if (result == TYBS_R_RELOAD) { ns_server_reloadwanted(ns_g_server); } else if (result != TYBS_R_SUCCESS) { UNEXPECTED_ERROR(__FILE__, __LINE__, \ tybs_result_totext(result)); result = TYBS_R_SUCCESS; } } while (result != TYBS_R_SUCCESS); #ifdef HAVE_LIBSCF if (ns_smf_want_disable == 1) { result = ns_smf_get_instance(&instance, 1, ns_g_mctx); if (result == TYBS_R_SUCCESS && instance != NULL) { if (smf_disable_instance(instance, 0) != 0) UNEXPECTED_ERROR(__FILE__, __LINE__, \ \ instance, scf_strerror(scf_error())); } if (instance != NULL) tybs_mem_free(ns_g_mctx, instance); }

#endif /* HAVE_LIBSCF */ cleanup(); if (want_stats) { tybs_mem_stats(ns_g_mctx, stdout); tybs_mutex_stats(stdout); } if (ns_g_memstatistics && memstats != NULL) { FILE *fp = NULL; result = tybs_stdio_open(memstats, \ if (result == TYBS_R_SUCCESS) { tybs_mem_stats(ns_g_mctx, fp);

天一博胜企业管理软件V1.0 源代码

15

tybs_mutex_stats(fp); tybs_stdio_close(fp); } } tybs_mem_destroy(&ns_g_mctx); tybs_mem_checkdestroyed(stderr); ns_main_setmemstats(NULL); tybs_app_finish(); ns_os_closedevnull(); ns_os_shutdown(); return (0); }

#define ZEND_INCLUDE_FULL_WINDOWS_HEADERS #include \#include #include #ifdef PHP_WIN32 #include \#include \

#include \#include #elif defined(NETWARE) #include #ifdef USE_WINSOCK #include #endif #endif

#if HAVE_SYS_TIME_H #include #endif

#if HAVE_UNISTD_H #include #endif

#if HAVE_SIGNAL_H #include #endif

#if HAVE_SETLOCALE #include #endif

#include \

#include \#include \#include \#include \

#include \

#include \#include \

#include \#ifdef PHP_WIN32 #include

#include \

#include \

天一博胜企业管理软件V1.0 源代码

16

#endif

#include \

#include \#if PHP_SIGCHILD #include #include #endif

#include \#include \#include \#include \#include \#include \

#include \#include \#include \#include \

#include \#include \#include \/* }}} */ #ifndef ZTS

php_core_globals core_globals; #else

PHPAPI int core_globals_id; #endif

#define SAFE_FILENAME(f) ((f)?(f):\/* {{{ PHP_INI_MH */

static PHP_INI_MH(OnSetPrecision) { int i = atoi(new_value); if (i >= 0) { EG(precision) = i; return SUCCESS; } else { return FAILURE; } }

static PHP_INI_MH(OnChangeMemoryLimit) { if (new_value) { PG(memory_limit) = zend_atoi(new_value, new_value_length); } else { PG(memory_limit) = 1<<30; /* effectively, no limit */ } return zend_set_memory_limit(PG(memory_limit)); }

static void php_disable_functions(TSRMLS_D) { char *s = NULL, *e; if (!*(INI_STR(\

天一博胜企业管理软件V1.0 源代码

17

return; } e = PG(disable_functions) = strdup(INI_STR(\ while (*e) { switch (*e) { case ' ': case ',': if (s) { *e = '\\0'; zend_disable_function(s, e-s TSRMLS_CC); s = NULL; } break; default: if (!s) { s = e; } break; } e++; } if (s) { zend_disable_function(s, e-s TSRMLS_CC); } }

static void php_disable_classes(TSRMLS_D) { char *s = NULL, *e; if (!*(INI_STR(\ return; } e = PG(disable_classes) = strdup(INI_STR(\ while (*e) { switch (*e) { case ' ': case ',': if (s) { *e = '\\0'; zend_disable_class(s, e-s TSRMLS_CC); s = NULL; } break; default: if (!s) { s = e; } break; } e++; } if (s) { zend_disable_class(s, e-s TSRMLS_CC);

天一博胜企业管理软件V1.0 源代码

} }

static PHP_INI_MH(OnUpdateTimeout) { EG(timeout_seconds) = atoi(new_value); if (stage==PHP_INI_STAGE_STARTUP) { /* Don't set a timeout on startup, only per-request */ return SUCCESS; } zend_unset_timeout(TSRMLS_C); zend_set_timeout(EG(timeout_seconds)); return SUCCESS; }

static int php_get_display_errors_mode(char *value, int value_length) { int mode; if (!value) { return PHP_DISPLAY_ERRORS_STDOUT; } if (value_length == 2 && !strcasecmp(\ mode = PHP_DISPLAY_ERRORS_STDOUT; } else if (value_length == 3 && !strcasecmp(\ mode = PHP_DISPLAY_ERRORS_STDOUT; } else if (value_length == 4 && !strcasecmp(\ mode = PHP_DISPLAY_ERRORS_STDOUT; } else if (value_length == 6 && !strcasecmp(value, \ mode = PHP_DISPLAY_ERRORS_STDERR; } else if (value_length == 6 && !strcasecmp(value, \ mode = PHP_DISPLAY_ERRORS_STDOUT; } else { mode = atoi(value); if (mode && mode != PHP_DISPLAY_ERRORS_STDOUT && mode PHP_DISPLAY_ERRORS_STDERR) { mode = PHP_DISPLAY_ERRORS_STDOUT; } } return mode; }

static PHP_INI_MH(OnUpdateDisplayErrors) { PG(display_errors) = (zend_bool) php_get_display_errors_mode(new_value, new_value_length); return SUCCESS; }

static PHP_INI_DISP(display_errors_mode) { int mode, tmp_value_length, cgi_or_cli; char *tmp_value; TSRMLS_FETCH(); if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) { tmp_value = (ini_entry->orig_value ? ini_entry->orig_value : NULL ); tmp_value_length = ini_entry->orig_value_length; } else if (ini_entry->value) {

18

!=

天一博胜企业管理软件V1.0 源代码

19

tmp_value = ini_entry->value; tmp_value_length = ini_entry->value_length; } else { tmp_value = NULL; tmp_value_length = 0; } mode = php_get_display_errors_mode(tmp_value, tmp_value_length); cgi_or_cli = (!strcmp(sapi_module.name, \ switch (mode) { case PHP_DISPLAY_ERRORS_STDERR: if (cgi_or_cli ) { PUTS(\ } else { PUTS(\ } break; case PHP_DISPLAY_ERRORS_STDOUT: if (cgi_or_cli ) { PUTS(\ } else { PUTS(\ } break; default: PUTS(\ break; } }

static PHP_INI_MH(OnUpdateErrorLog) { /* Only do the safemode/open_basedir check at runtime */ if ((stage == PHP_INI_STAGE_RUNTIME || stage == PHP_INI_STAGE_HTACCESS) && strcmp(new_value, \ if (PG(safe_mode) && (!php_checkuid(new_value, NULL, CHECKUID_CHECK_FILE_AND_DIR))) { return FAILURE; } if (PG(open_basedir) && php_check_open_basedir(new_value TSRMLS_CC)) { return FAILURE; } } OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC); return SUCCESS; }

static PHP_INI_MH(OnChangeMailForceExtra) { /* Don't allow changing it in htaccess */ if (stage == PHP_INI_STAGE_HTACCESS) { return FAILURE; } return SUCCESS; }

天一博胜企业管理软件V1.0 源代码

20

#ifndef PHP_SAFE_MODE_EXEC_DIR

# define PHP_SAFE_MODE_EXEC_DIR \#endif

#if defined(PHP_PROG_SENDMAIL) && !defined(NETWARE)

# define DEFAULT_SENDMAIL_PATH PHP_PROG_SENDMAIL \#elif defined(PHP_WIN32)

# define DEFAULT_SENDMAIL_PATH NULL #else

# define DEFAULT_SENDMAIL_PATH \ #endif

PHPAPI void php_log_err(char *log_message TSRMLS_DC) { int fd = -1; char error_time_str[128]; struct tm tmbuf; time_t error_time; /* Try to use the specified logging location. */ if (PG(error_log) != NULL) { #ifdef HAVE_SYSLOG_H if (!strcmp(PG(error_log), \ php_syslog(LOG_NOTICE, \ return; } #endif fd = VCWD_OPEN_MODE(PG(error_log), O_CREAT | O_APPEND | O_WRONLY, 0644); if (fd != -1) { char *tmp; int len; time(&error_time); strftime(error_time_str, sizeof(error_time_str), \%H:%M:%S\php_localtime_r(&error_time, &tmbuf)); len = spprintf(&tmp, 0, \#ifdef PHP_WIN32 php_flock(fd, 2); #endif write(fd, tmp, len); efree(tmp); close(fd); return; } } /* Otherwise fall back to the default logging location, if we have one */ if (sapi_module.log_message) { sapi_module.log_message(log_message); } }

PHPAPI int php_write(void *buf, uint size TSRMLS_DC) { return PHPWRITE(buf, size); }

/* }}} */

/* {{{ php_printf

天一博胜企业管理软件V1.0 源代码

21

*/

PHPAPI int php_printf(const char *format, ...) { va_list args; int ret; char *buffer; int size; TSRMLS_FETCH(); va_start(args, format); size = vspprintf(&buffer, 0, format, args); ret = PHPWRITE(buffer, size); efree(buffer); va_end(args); return ret; }

/* }}} */

/* {{{ php_verror helpers */

/* {{{ php_during_module_startup */

static int php_during_module_startup(void) { return module_startup; }

/* }}} */

/* {{{ php_during_module_shutdown */

static int php_during_module_shutdown(void) { return module_shutdown; }

/* }}} */ /* }}} */

/* {{{ php_verror */

/* php_verror is called from php_error_docref functions.

* Its purpose is to unify error messages and automatically generate clickable * html error messages if correcponding ini setting (html_errors) is activated. * See: CODING_STANDARDS for details. */

PHPAPI void php_verror(const char *docref, const char *params, int type, const char *format, va_list args TSRMLS_DC) { char *buffer = NULL, *docref_buf = NULL, *target = NULL; char *docref_target = \ char *p; int buffer_len = 0; char *space; char *class_name = get_active_class_name(&space TSRMLS_CC); char *function; int origin_len; char *origin; char *message; int is_function = 0; /* get error text into buffer and escape for html if necessary */ buffer_len = vspprintf(&buffer, 0, format, args);

天一博胜企业管理软件V1.0 源代码

22

if (PG(html_errors)) { int len; char *replace = php_escape_html_entities(buffer, buffer_len, &len, 0, ENT_COMPAT, NULL TSRMLS_CC); efree(buffer); buffer = replace; buffer_len = len; } /* which function caused the problem if any at all */ if (php_during_module_startup()) { function = \ } else if (php_during_module_shutdown()) { function = \ } else if (EG(current_execute_data) && EG(current_execute_data)->opline && EG(current_execute_data)->opline->opcode == ZEND_INCLUDE_OR_EVAL ) { switch (EG(current_execute_data)->opline->op2.u.constant.value.lval) { case ZEND_EVAL: function = \ is_function = 1; break; case ZEND_INCLUDE: function = \ is_function = 1; break; case ZEND_INCLUDE_ONCE: function = \ is_function = 1; break; case ZEND_REQUIRE: function = \ is_function = 1; break; case ZEND_REQUIRE_ONCE: function = \ is_function = 1; break; default: function = \ } } else { function = get_active_function_name(TSRMLS_C); if (!function || !strlen(function)) { function = \ } else { is_function = 1; } } if (is_function) { origin_len = spprintf(&origin, 0, \ } else {

天一博胜企业管理软件V1.0 源代码

23

origin_len = spprintf(&origin, 0, \ } if (PG(html_errors)) { int len; char *replace = php_escape_html_entities(origin, origin_len, &len, 0, ENT_COMPAT, NULL TSRMLS_CC); efree(origin); origin = replace; } if (docref && docref[0] == '#') { docref_target = strchr(docref, '#'); docref = NULL; } if (!docref && is_function) { if (space[0] == '\\0') { spprintf(&docref_buf, 0, \ } else { spprintf(&docref_buf, 0, \ } while((p = strchr(docref_buf, '_')) != NULL) { *p = '-'; } docref = docref_buf; } if (docref && is_function && (PG(html_errors) || strlen(PG(docref_root)))) { if (strncmp(docref, \ /* We don't have 'http://' so we use docref_root */ char *ref; /* temp copy for duplicated docref */ docref_root = PG(docref_root); ref = estrdup(docref); if (docref_buf) { efree(docref_buf); } docref_buf = ref; /* strip of the target if any */ p = strrchr(ref, '#'); if (p) { target = estrdup(p); if (target) { docref_target = target; *p = '\\0'; } } /* add the extension if it is set in ini */ if (PG(docref_ext) && strlen(PG(docref_ext))) { spprintf(&docref_buf, 0, \ efree(ref); } docref = docref_buf; } /* display html formatted or only show the additional links */ if (PG(html_errors)) {

天一博胜企业管理软件V1.0 源代码

24

spprintf(&message, 0, \[%s]: %s\origin, docref_root, docref, docref_target, docref, buffer); } else { spprintf(&message, 0, \ } if (target) { efree(target); } } else { spprintf(&message, 0, \ } efree(origin); if (docref_buf) { efree(docref_buf); } if (PG(track_errors) && module_initialized && EG(active_symbol_table) && (!EG(user_error_handler) || !(EG(user_error_handler_error_reporting) & type))) { zval *tmp; ALLOC_INIT_ZVAL(tmp); ZVAL_STRINGL(tmp, buffer, buffer_len, 1); zend_hash_update(EG(active_symbol_table), \sizeof(zval *), NULL); } efree(buffer); php_error(type, \ efree(message); }

/* }}} */

/* {{{ php_error_docref0 */

/* See: CODING_STANDARDS for details. */

PHPAPI void php_error_docref0(const char *docref TSRMLS_DC, int type, const char *format, ...) { va_list args; va_start(args, format); php_verror(docref, \ va_end(args); }

/* }}} */

/* {{{ php_error_docref1 */

/* See: CODING_STANDARDS for details. */

PHPAPI void php_error_docref1(const char *docref TSRMLS_DC, const char *param1, int type, const char *format, ...) { va_list args; va_start(args, format); php_verror(docref, param1, type, format, args TSRMLS_CC); va_end(args); }

/* }}} */

/* {{{ php_error_docref2 */

/* See: CODING_STANDARDS for details. */

PHPAPI void php_error_docref2(const char *docref TSRMLS_DC, const char *param1, const char *param2, int

天一博胜企业管理软件V1.0 源代码

25

type, const char *format, ...) { char *params; va_list args; spprintf(¶ms, 0, \ va_start(args, format); php_verror(docref, params ? params : \ va_end(args); if (params) { efree(params); } }

/* }}} */

/* {{{ php_html_puts */

PHPAPI void php_html_puts(const char *str, uint size TSRMLS_DC) { zend_html_puts(str, size TSRMLS_CC); }

/* }}} */

/* {{{ php_suppress_errors */

PHPAPI void php_set_error_handling(error_handling_t error_handling, zend_class_entry *exception_class TSRMLS_DC) { PG(error_handling) = error_handling; PG(exception_class) = exception_class; if (PG(last_error_message)) { free(PG(last_error_message)); PG(last_error_message) = NULL; } if (PG(last_error_file)) { free(PG(last_error_file)); PG(last_error_file) = NULL; } PG(last_error_lineno) = 0; }

/* }}} */

/* {{{ php_error_cb

extended error handling function */

static void php_error_cb(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args) { char *buffer; int buffer_len, display; TSRMLS_FETCH(); buffer_len = vspprintf(&buffer, PG(log_errors_max_len), format, args); /* check for repeated errors to be ignored */ if (PG(ignore_repeated_errors) && PG(last_error_message)) { /* no check for PG(last_error_file) is needed since it cannot * be NULL if PG(last_error_message) is not NULL */ if (strcmp(PG(last_error_message), buffer) || (!PG(ignore_repeated_source) && ((PG(last_error_lineno) != (int)error_lineno)

天一博胜企业管理软件V1.0 源代码

26

|| strcmp(PG(last_error_file), error_filename)))) { display = 1; } else { display = 0; } } else { display = 1; }

/* store the error if it has changed */ if (display) { if (PG(last_error_message)) { free(PG(last_error_message)); } if (PG(last_error_file)) { free(PG(last_error_file)); } PG(last_error_type) = type; PG(last_error_message) = strdup(buffer); PG(last_error_file) = strdup(error_filename); PG(last_error_lineno) = error_lineno; }

/* according to error handling mode, suppress error, throw exception or show it */ if (PG(error_handling) != EH_NORMAL) { switch (type) { case E_ERROR: case E_CORE_ERROR: case E_COMPILE_ERROR: case E_USER_ERROR: case E_PARSE: /* fatal errors are real errors and cannot be made exceptions */ break; case E_STRICT: /* for the sake of BC to old damaged code */ break; case E_NOTICE: case E_USER_NOTICE: /* notices are no errors and are not treated as such like E_WARNINGS */ break; default: /* throw an exception if we are in EH_THROW mode * but DO NOT overwrite a pending exception */ if (PG(error_handling) == EH_THROW && !EG(exception)) { zend_throw_error_exception(PG(exception_class), buffer, 0, type TSRMLS_CC); } efree(buffer); return; } }

/* display/log the error if necessary */

if (display && (EG(error_reporting) & type || (type & E_CORE)) && (PG(log_errors) || PG(display_errors) || (!module_initialized))) {

天一博胜企业管理软件V1.0 源代码

27

char *error_type_str; switch (type) { case E_ERROR: case E_CORE_ERROR: case E_COMPILE_ERROR: case E_USER_ERROR: error_type_str = \ break; case E_RECOVERABLE_ERROR: error_type_str = \ break; case E_WARNING: case E_CORE_WARNING: case E_COMPILE_WARNING: case E_USER_WARNING: error_type_str = \ break; case E_PARSE: error_type_str = \ break; case E_NOTICE: case E_USER_NOTICE: error_type_str = \ break; case E_STRICT: error_type_str = \ break; default: error_type_str = \ break; } if (!module_initialized || PG(log_errors)) { char *log_buffer; #ifdef PHP_WIN32 if ((type == E_CORE_ERROR || type == E_CORE_WARNING) && PG(display_startup_errors)) { MessageBox(NULL, buffer, error_type_str, MB_OK|ZEND_SERVICE_MB_STYLE); } #endif spprintf(&log_buffer, 0, \ %s in %s on line %d\error_lineno); php_log_err(log_buffer TSRMLS_CC); efree(log_buffer); } if (PG(display_errors) && ((module_initialized && !PG(during_request_startup)) || (PG(display_startup_errors) && (OG(php_body_write)==php_default_output_func || OG(php_body_write)==php_ub_body_write_no_header || OG(php_body_write)==php_ub_body_write) ) ) ) {

天一博胜企业管理软件V1.0 源代码

28

if (PG(xmlrpc_errors)) { php_printf(\

version=\\\%ldfaultString%s:%s in %s on line %d\PG(xmlrpc_error_number), error_type_str, buffer, error_filename, error_lineno); } else { char *prepend_string = INI_STR(\ char *append_string = INI_STR(\ if (PG(html_errors)) { if (type == E_ERROR) { int len; char *buf = php_escape_html_entities(buffer, buffer_len, &len, 0, ENT_COMPAT, NULL TSRMLS_CC); php_printf(\/>\\n%s: %s in %s on line %d
\\n%s\STR_PRINT(prepend_string), error_type_str, buf, error_filename, error_lineno, STR_PRINT(append_string)); efree(buf); } else { php_printf(\/>\\n%s: %s in %s on line %d
\\n%s\STR_PRINT(prepend_string), error_type_str, buffer, error_filename, error_lineno, STR_PRINT(append_string)); } } else { /* Write CLI/CGI errors to stderr if display_errors = \ if ((!strcmp(sapi_module.name, \ PG(display_errors) == PHP_DISPLAY_ERRORS_STDERR ) { fprintf(stderr, \error_lineno); } else { php_printf(\%s in %s on line %d\\n%s\STR_PRINT(prepend_string), error_type_str, buffer, error_filename, error_lineno, STR_PRINT(append_string)); } } } }

#if ZEND_DEBUG if (PG(report_zend_debug)) { zend_bool trigger_break; switch (type) { case E_ERROR: case E_CORE_ERROR: case E_COMPILE_ERROR: case E_USER_ERROR: trigger_break=1; break; default: trigger_break=0; break; } zend_output_debug_string(trigger_break, \: %s - %s\error_filename, error_lineno,

天一博胜企业管理软件V1.0 源代码

29

error_type_str, buffer); } #endif } /* Bail out if we can't recover */ switch (type) { case E_CORE_ERROR: if(!module_initialized) { /* bad error in module startup - no way we can live with this */ exit(-2); } /* no break - intentionally */ case E_ERROR: case E_RECOVERABLE_ERROR: case E_PARSE: case E_COMPILE_ERROR: case E_USER_ERROR: EG(exit_status) = 255; if (module_initialized) { if (!PG(display_errors) && !SG(headers_sent) && SG(sapi_headers).http_response_code == 200 ) { sapi_header_line ctr = {0}; ctr.line = \ ctr.line_len = strlen(ctr.line); sapi_header_op(SAPI_HEADER_REPLACE, &ctr TSRMLS_CC); } /* the parser would return 1 (failure), we can bail out nicely */ if (type != E_PARSE) { /* restore memory limit */ zend_set_memory_limit(PG(memory_limit)); efree(buffer); zend_objects_store_mark_destructed(&EG(objects_store) TSRMLS_CC); zend_bailout(); return; } } break; } /* Log if necessary */ if (!display) { efree(buffer); return; } if (PG(track_errors) && module_initialized && EG(active_symbol_table)) { zval *tmp; ALLOC_INIT_ZVAL(tmp); ZVAL_STRINGL(tmp, buffer, buffer_len, 1); zend_hash_update(EG(active_symbol_table), \sizeof(\(void **) & tmp, sizeof(zval *), NULL); }

天一博胜企业管理软件V1.0 源代码

efree(buffer); }

static PHP_INI_MH(OnUpdateTimeout) { EG(timeout_seconds) = atoi(new_value); if (stage==PHP_INI_STAGE_STARTUP) { /* Don't set a timeout on startup, only per-request */ return SUCCESS; } zend_unset_timeout(TSRMLS_C); zend_set_timeout(EG(timeout_seconds)); return SUCCESS; }

static int php_get_display_errors_mode(char *value, int value_length) { int mode; if (!value) { return PHP_DISPLAY_ERRORS_STDOUT; } if (value_length == 2 && !strcasecmp(\ mode = PHP_DISPLAY_ERRORS_STDOUT; } else if (value_length == 3 && !strcasecmp(\ mode = PHP_DISPLAY_ERRORS_STDOUT; } else if (value_length == 4 && !strcasecmp(\ mode = PHP_DISPLAY_ERRORS_STDOUT; } else if (value_length == 6 && !strcasecmp(value, \ mode = PHP_DISPLAY_ERRORS_STDERR; } else if (value_length == 6 && !strcasecmp(value, \ mode = PHP_DISPLAY_ERRORS_STDOUT; } else { mode = atoi(value); if (mode && mode != PHP_DISPLAY_ERRORS_STDOUT && mode PHP_DISPLAY_ERRORS_STDERR) { mode = PHP_DISPLAY_ERRORS_STDOUT; } } return mode; }

static PHP_INI_MH(OnUpdateDisplayErrors) { PG(display_errors) = (zend_bool) php_get_display_errors_mode(new_value, new_value_length); return SUCCESS; }

static PHP_INI_DISP(display_errors_mode) { int mode, tmp_value_length, cgi_or_cli; char *tmp_value; TSRMLS_FETCH(); if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) { tmp_value = (ini_entry->orig_value ? ini_entry->orig_value : NULL ); tmp_value_length = ini_entry->orig_value_length; } else if (ini_entry->value) {

30

!=

天一博胜企业管理软件V1.0 源代码

31

tmp_value = ini_entry->value; tmp_value_length = ini_entry->value_length; } else { tmp_value = NULL; tmp_value_length = 0; } mode = php_get_display_errors_mode(tmp_value, tmp_value_length); cgi_or_cli = (!strcmp(sapi_module.name, \ switch (mode) { case PHP_DISPLAY_ERRORS_STDERR: if (cgi_or_cli ) { PUTS(\ } else { PUTS(\ } break; case PHP_DISPLAY_ERRORS_STDOUT: if (cgi_or_cli ) { PUTS(\ } else { PUTS(\ } break; default: PUTS(\ break; } }

static PHP_INI_MH(OnUpdateErrorLog) { /* Only do the safemode/open_basedir check at runtime */ if ((stage == PHP_INI_STAGE_RUNTIME || stage == PHP_INI_STAGE_HTACCESS) && strcmp(new_value, \ if (PG(safe_mode) && (!php_checkuid(new_value, NULL, CHECKUID_CHECK_FILE_AND_DIR))) { return FAILURE; } if (PG(open_basedir) && php_check_open_basedir(new_value TSRMLS_CC)) { return FAILURE; } } OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC); return SUCCESS; }

static PHP_INI_MH(OnChangeMailForceExtra) { /* Don't allow changing it in htaccess */ if (stage == PHP_INI_STAGE_HTACCESS) { return FAILURE; } return SUCCESS; }

天一博胜企业管理软件V1.0 源代码

32

#ifndef PHP_SAFE_MODE_EXEC_DIR

# define PHP_SAFE_MODE_EXEC_DIR \#endif

#if defined(PHP_PROG_SENDMAIL) && !defined(NETWARE)

# define DEFAULT_SENDMAIL_PATH PHP_PROG_SENDMAIL \#elif defined(PHP_WIN32)

# define DEFAULT_SENDMAIL_PATH NULL #else

# define DEFAULT_SENDMAIL_PATH \ #endif

PHPAPI void php_log_err(char *log_message TSRMLS_DC) { int fd = -1; char error_time_str[128]; struct tm tmbuf; time_t error_time; /* Try to use the specified logging location. */ if (PG(error_log) != NULL) { #ifdef HAVE_SYSLOG_H if (!strcmp(PG(error_log), \ php_syslog(LOG_NOTICE, \ return; } #endif fd = VCWD_OPEN_MODE(PG(error_log), O_CREAT | O_APPEND | O_WRONLY, 0644); if (fd != -1) { char *tmp; int len; time(&error_time); strftime(error_time_str, sizeof(error_time_str), \%H:%M:%S\php_localtime_r(&error_time, &tmbuf)); len = spprintf(&tmp, 0, \#ifdef PHP_WIN32 php_flock(fd, 2); #endif write(fd, tmp, len); efree(tmp); close(fd); return; } } /* Otherwise fall back to the default logging location, if we have one */ if (sapi_module.log_message) { sapi_module.log_message(log_message); } }

PHPAPI int php_write(void *buf, uint size TSRMLS_DC) { return PHPWRITE(buf, size); }

/* }}} */

/* {{{ php_printf

天一博胜企业管理软件V1.0 源代码

33

*/

PHPAPI int php_printf(const char *format, ...) { va_list args; int ret; char *buffer; int size; TSRMLS_FETCH(); va_start(args, format); size = vspprintf(&buffer, 0, format, args); ret = PHPWRITE(buffer, size); efree(buffer); va_end(args); return ret; }

/* }}} */

/* {{{ php_verror helpers */

/* {{{ php_during_module_startup */

static int php_during_module_startup(void) { return module_startup; }

static int php_during_module_shutdown(void) { return module_shutdown; }

PHPAPI void php_verror(const char *docref, const char *params, int type, const char *format, va_list args TSRMLS_DC) { char *buffer = NULL, *docref_buf = NULL, *target = NULL; char *docref_target = \ char *p; int buffer_len = 0; char *space; char *class_name = get_active_class_name(&space TSRMLS_CC); char *function; int origin_len; char *origin; char *message; int is_function = 0; /* get error text into buffer and escape for html if necessary */ buffer_len = vspprintf(&buffer, 0, format, args); if (PG(html_errors)) { int len; char *replace = php_escape_html_entities(buffer, buffer_len, &len, 0, ENT_COMPAT, NULL TSRMLS_CC); efree(buffer); buffer = replace; buffer_len = len; } /* which function caused the problem if any at all */ if (php_during_module_startup()) {

天一博胜企业管理软件V1.0 源代码

34

function = \ } else if (php_during_module_shutdown()) { function = \ } else if (EG(current_execute_data) && EG(current_execute_data)->opline && EG(current_execute_data)->opline->opcode == ZEND_INCLUDE_OR_EVAL ) { switch (EG(current_execute_data)->opline->op2.u.constant.value.lval) { case ZEND_EVAL: function = \ is_function = 1; break; case ZEND_INCLUDE: function = \ is_function = 1; break; case ZEND_INCLUDE_ONCE: function = \ is_function = 1; break; case ZEND_REQUIRE: function = \ is_function = 1; break; case ZEND_REQUIRE_ONCE: function = \ is_function = 1; break; default: function = \ } } else { function = get_active_function_name(TSRMLS_C); if (!function || !strlen(function)) { function = \ } else { is_function = 1; } } if (is_function) { origin_len = spprintf(&origin, 0, \ } else { origin_len = spprintf(&origin, 0, \ } if (PG(html_errors)) { int len; char *replace = php_escape_html_entities(origin, origin_len, &len, 0, ENT_COMPAT, NULL TSRMLS_CC); efree(origin); origin = replace; } if (docref && docref[0] == '#') {

天一博胜企业管理软件V1.0 源代码

35

docref_target = strchr(docref, '#'); docref = NULL; } if (!docref && is_function) { if (space[0] == '\\0') { spprintf(&docref_buf, 0, \ } else { spprintf(&docref_buf, 0, \ } while((p = strchr(docref_buf, '_')) != NULL) { *p = '-'; } docref = docref_buf; } if (docref && is_function && (PG(html_errors) || strlen(PG(docref_root)))) { if (strncmp(docref, \ /* We don't have 'http://' so we use docref_root */ char *ref; /* temp copy for duplicated docref */ docref_root = PG(docref_root); ref = estrdup(docref); if (docref_buf) { efree(docref_buf); } docref_buf = ref; /* strip of the target if any */ p = strrchr(ref, '#'); if (p) { target = estrdup(p); if (target) { docref_target = target; *p = '\\0'; } } /* add the extension if it is set in ini */ if (PG(docref_ext) && strlen(PG(docref_ext))) { spprintf(&docref_buf, 0, \ efree(ref); } docref = docref_buf; } /* display html formatted or only show the additional links */ if (PG(html_errors)) { spprintf(&message, 0, \[%s]: %s\origin, docref_root, docref, docref_target, docref, buffer); } else { spprintf(&message, 0, \ } if (target) { efree(target); } } else { spprintf(&message, 0, \

天一博胜企业管理软件V1.0 源代码

36

} efree(origin); if (docref_buf) { efree(docref_buf); } if (PG(track_errors) && module_initialized && EG(active_symbol_table) && (!EG(user_error_handler) || !(EG(user_error_handler_error_reporting) & type))) { zval *tmp; ALLOC_INIT_ZVAL(tmp); ZVAL_STRINGL(tmp, buffer, buffer_len, 1); zend_hash_update(EG(active_symbol_table), \sizeof(zval *), NULL); } efree(buffer); php_error(type, \ efree(message); }

/* }}} */

/* {{{ php_error_docref0 */

/* See: CODING_STANDARDS for details. */

PHPAPI void php_error_docref0(const char *docref TSRMLS_DC, int type, const char *format, ...) { va_list args; va_start(args, format); php_verror(docref, \ va_end(args); }

/* }}} */

/* {{{ php_error_docref1 */

/* See: CODING_STANDARDS for details. */

PHPAPI void php_error_docref1(const char *docref TSRMLS_DC, const char *param1, int type, const char *format, ...) { va_list args; va_start(args, format); php_verror(docref, param1, type, format, args TSRMLS_CC); va_end(args); }

/* }}} */

/* {{{ php_error_docref2 */

/* See: CODING_STANDARDS for details. */

PHPAPI void php_error_docref2(const char *docref TSRMLS_DC, const char *param1, const char *param2, int type, const char *format, ...) { char *params; va_list args; spprintf(¶ms, 0, \ va_start(args, format); php_verror(docref, params ? params : \ va_end(args); if (params) { efree(params);

天一博胜企业管理软件V1.0 源代码

37

} }

/* }}} */

/* {{{ php_html_puts */

PHPAPI void php_html_puts(const char *str, uint size TSRMLS_DC) { zend_html_puts(str, size TSRMLS_CC); }

/* }}} */

/* {{{ php_suppress_errors */

PHPAPI void php_set_error_handling(error_handling_t error_handling, zend_class_entry *exception_class TSRMLS_DC) { PG(error_handling) = error_handling; PG(exception_class) = exception_class; if (PG(last_error_message)) { free(PG(last_error_message)); PG(last_error_message) = NULL; } if (PG(last_error_file)) { free(PG(last_error_file)); PG(last_error_file) = NULL; } PG(last_error_lineno) = 0; }

PHP_FUNCTION(set_time_limit) { zval **new_timeout; if (PG(safe_mode)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, \ RETURN_FALSE; } if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &new_timeout) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_string_ex(new_timeout); if (zend_alter_ini_entry(\sizeof(\Z_STRVAL_PP(new_timeout), Z_STRLEN_PP(new_timeout), PHP_INI_USER, PHP_INI_STAGE_RUNTIME) == SUCCESS) { RETURN_TRUE; } else { RETURN_FALSE; } }

static PHP_INI_DISP(display_errors_mode) { int mode, tmp_value_length, cgi_or_cli; char *tmp_value; TSRMLS_FETCH(); if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) { tmp_value = (ini_entry->orig_value ? ini_entry->orig_value : NULL ); tmp_value_length = ini_entry->orig_value_length;

天一博胜企业管理软件V1.0 源代码

38

} else if (ini_entry->value) { tmp_value = ini_entry->value; tmp_value_length = ini_entry->value_length; } else { tmp_value = NULL; tmp_value_length = 0; } mode = php_get_display_errors_mode(tmp_value, tmp_value_length); cgi_or_cli = (!strcmp(sapi_module.name, \ switch (mode) { case PHP_DISPLAY_ERRORS_STDERR: if (cgi_or_cli ) { PUTS(\ } else { PUTS(\ } break; case PHP_DISPLAY_ERRORS_STDOUT: if (cgi_or_cli ) { PUTS(\ } else { PUTS(\ } break; default: PUTS(\ break; } }

static PHP_INI_MH(OnUpdateErrorLog) { /* Only do the safemode/open_basedir check at runtime */ if ((stage == PHP_INI_STAGE_RUNTIME || stage == PHP_INI_STAGE_HTACCESS) && strcmp(new_value, \ if (PG(safe_mode) && (!php_checkuid(new_value, NULL, CHECKUID_CHECK_FILE_AND_DIR))) { return FAILURE; } if (PG(open_basedir) && php_check_open_basedir(new_value TSRMLS_CC)) { return FAILURE; } } OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC); return SUCCESS; }

static FILE *php_fopen_wrapper_for_zend(const char *filename, char **opened_path) { TSRMLS_FETCH(); return php_stream_open_wrapper_as_file((char *)filename, \ENFORCE_SAFE_MODE|USE_PATH|IGNORE_URL_WIN|REPORT_ERRORS|STREAM_OPEN_FOR_INCLUDE, opened_path); }

天一博胜企业管理软件V1.0 源代码

/* }}} */

static void stream_closer_for_zend(void *handle TSRMLS_DC) /* {{{ */ { php_stream_close((php_stream*)handle); }

/* }}} */

static long stream_fteller_for_zend(void *handle TSRMLS_DC) /* {{{ */ { return (long)php_stream_tell((php_stream*)handle); }

/* }}} */

static PHP_INI_MH(OnUpdateTimeout) { EG(timeout_seconds) = atoi(new_value); if (stage==PHP_INI_STAGE_STARTUP) { /* Don't set a timeout on startup, only per-request */ return SUCCESS; } zend_unset_timeout(TSRMLS_C); zend_set_timeout(EG(timeout_seconds)); return SUCCESS; }

/* }}} */

/* {{{ php_get_display_errors_mode() helper function */

static int php_get_display_errors_mode(char *value, int value_length) { int mode; if (!value) { return PHP_DISPLAY_ERRORS_STDOUT; } if (value_length == 2 && !strcasecmp(\ mode = PHP_DISPLAY_ERRORS_STDOUT; } else if (value_length == 3 && !strcasecmp(\ mode = PHP_DISPLAY_ERRORS_STDOUT; } else if (value_length == 4 && !strcasecmp(\ mode = PHP_DISPLAY_ERRORS_STDOUT; } else if (value_length == 6 && !strcasecmp(value, \ mode = PHP_DISPLAY_ERRORS_STDERR; } else if (value_length == 6 && !strcasecmp(value, \ mode = PHP_DISPLAY_ERRORS_STDOUT; } else { mode = atoi(value); if (mode && mode != PHP_DISPLAY_ERRORS_STDOUT PHP_DISPLAY_ERRORS_STDERR) { mode = PHP_DISPLAY_ERRORS_STDOUT; } } return mode; }

/* }}} */

/* {{{ PHP_INI_MH

&& mode 39

!=

天一博胜企业管理软件V1.0 源代码

40

*/

static PHP_INI_MH(OnUpdateDisplayErrors) { PG(display_errors) = (zend_bool) php_get_display_errors_mode(new_value, new_value_length); return SUCCESS; }

/* }}} */

/* {{{ PHP_INI_DISP */

static PHP_INI_DISP(display_errors_mode) { int mode, tmp_value_length, cgi_or_cli; char *tmp_value; TSRMLS_FETCH(); if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) { tmp_value = (ini_entry->orig_value ? ini_entry->orig_value : NULL ); tmp_value_length = ini_entry->orig_value_length; } else if (ini_entry->value) { tmp_value = ini_entry->value; tmp_value_length = ini_entry->value_length; } else { tmp_value = NULL; tmp_value_length = 0; } mode = php_get_display_errors_mode(tmp_value, tmp_value_length); /* Display 'On' for other SAPIs instead of STDOUT or STDERR */ cgi_or_cli = (!strcmp(sapi_module.name, \ switch (mode) { case PHP_DISPLAY_ERRORS_STDERR: if (cgi_or_cli ) { PUTS(\ } else { PUTS(\ } break; case PHP_DISPLAY_ERRORS_STDOUT: if (cgi_or_cli ) { PUTS(\ } else { PUTS(\ } break; default: PUTS(\ break; } }

static PHP_INI_MH(OnUpdateErrorLog) { /* Only do the safemode/open_basedir check at runtime */ if ((stage == PHP_INI_STAGE_RUNTIME || stage == PHP_INI_STAGE_HTACCESS) && strcmp(new_value, \

天一博胜企业管理软件V1.0 源代码

41

if (PG(safe_mode) && (!php_checkuid(new_value, NULL, CHECKUID_CHECK_FILE_AND_DIR))) { return FAILURE; } if (PG(open_basedir) && php_check_open_basedir(new_value TSRMLS_CC)) { return FAILURE; } } OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC); return SUCCESS; }

/* }}} */

/* {{{ PHP_INI_MH */

static PHP_INI_MH(OnChangeMailForceExtra) { /* Don't allow changing it in htaccess */ if (stage == PHP_INI_STAGE_HTACCESS) { return FAILURE; } return SUCCESS; }

static int php_stream_open_for_zend(const char *filename, zend_file_handle *handle TSRMLS_DC) /* {{{ */ { return php_stream_open_for_zend_ex(filename, handle, ENFORCE_SAFE_MODE|USE_PATH|REPORT_ERRORS|STREAM_OPEN_FOR_INCLUDE TSRMLS_CC); }

/* }}} */

PHPAPI int php_stream_open_for_zend_ex(const char *filename, zend_file_handle *handle, int mode TSRMLS_DC) /* {{{ */ { php_stream *stream; stream = php_stream_open_wrapper((char *)filename, \ if (stream) { handle->type = ZEND_HANDLE_STREAM; handle->filename = (char*)filename; handle->free_filename = 0; handle->handle.stream.handle = stream; handle->handle.stream.reader = (zend_stream_reader_t)_php_stream_read; handle->handle.stream.closer = stream_closer_for_zend; handle->handle.stream.fteller = stream_fteller_for_zend; handle->handle.stream.interactive = 0; /* suppress warning if this stream is not explicitly closed */ php_stream_auto_cleanup(stream); return SUCCESS; } return FAILURE; }

/* }}} */

/* {{{ php_get_configuration_directive_for_zend */

static int php_get_configuration_directive_for_zend(char *name, uint name_length, zval *contents)

天一博胜企业管理软件V1.0 源代码

42

{ zval *retval = cfg_get_entry(name, name_length); if (retval) { *contents = *retval; return SUCCESS; } else { return FAILURE; } }

/* }}} */

/* {{{ php_message_handler_for_zend */

static void php_message_handler_for_zend(long message, void *data) { TSRMLS_FETCH(); switch (message) { case ZMSG_FAILED_INCLUDE_FOPEN: php_error_docref(\TSRMLS_CC, E_WARNING, \opening '%s' for inclusion (include_path='%s')\ break; case ZMSG_FAILED_REQUIRE_FOPEN: php_error_docref(\TSRMLS_CC, E_COMPILE_ERROR, \opening required '%s' (include_path='%s')\ break; case ZMSG_FAILED_HIGHLIGHT_FOPEN: php_error_docref(NULL TSRMLS_CC, E_WARNING, \opening '%s' for highlighting\php_strip_url_passwd((char *) data)); break; case ZMSG_MEMORY_LEAK_DETECTED: case ZMSG_MEMORY_LEAK_REPEATED: #if ZEND_DEBUG if (EG(error_reporting) & E_WARNING) { char memory_leak_buf[1024]; if (message==ZMSG_MEMORY_LEAK_DETECTED) { zend_leak_info *t = (zend_leak_info *) data; snprintf(memory_leak_buf, 512, \: Freeing 0x%.8lX (%zu bytes), script=%s\\n\t->filename, t->lineno, (zend_uintptr_t)t->addr, t->size, SAFE_FILENAME(SG(request_info).path_translated)); if (t->orig_filename) { char relay_buf[512]; snprintf(relay_buf, 512, \: Actual location (location was relayed)\\n\t->orig_filename, t->orig_lineno); strlcat(memory_leak_buf, relay_buf, sizeof(memory_leak_buf)); } } else { unsigned long leak_count = (zend_uintptr_t) data; snprintf(memory_leak_buf, 512, \leak repeated %ld time%s\\n\leak_count, (leak_count>1?\ }

# if defined(PHP_WIN32) OutputDebugString(memory_leak_buf); # else

天一博胜企业管理软件V1.0 源代码

43

fprintf(stderr, \# endif } #endif break; case ZMSG_MEMORY_LEAKS_GRAND_TOTAL: #if ZEND_DEBUG if (EG(error_reporting) & E_WARNING) { char memory_leak_buf[512]; snprintf(memory_leak_buf, 512, \*) data));

# if defined(PHP_WIN32) OutputDebugString(memory_leak_buf); # else fprintf(stderr, \# endif } #endif break; case ZMSG_LOG_SCRIPT_NAME: { struct tm *ta, tmbuf; time_t curtime; char *datetime_str, asctimebuf[52]; char memory_leak_buf[4096]; time(&curtime); ta = php_localtime_r(&curtime, &tmbuf); datetime_str = php_asctime_r(ta, asctimebuf); if (datetime_str) { datetime_str[strlen(datetime_str)-1]=0; /* get rid of the trailing newline */ snprintf(memory_leak_buf, sizeof(memory_leak_buf), \ Script: '%s'\\n\datetime_str, SAFE_FILENAME(SG(request_info).path_translated)); } else { snprintf(memory_leak_buf, sizeof(memory_leak_buf), \ Script: '%s'\\n\SAFE_FILENAME(SG(request_info).path_translated)); }

# if defined(PHP_WIN32) OutputDebugString(memory_leak_buf); # else fprintf(stderr, \# endif } break; } }

/* }}} */

PHPAPI void php_error_docref2(const char *docref TSRMLS_DC, const char *param1, const char *param2, int type, const char *format, ...) { char *params; va_list args; spprintf(¶ms, 0, \ va_start(args, format);

天一博胜企业管理软件V1.0 源代码

44

php_verror(docref, params ? params : \ va_end(args); if (params) { efree(params); } }

/* }}} */

/* {{{ php_html_puts */

PHPAPI void php_html_puts(const char *str, uint size TSRMLS_DC) { zend_html_puts(str, size TSRMLS_CC); }

/* }}} */

/* {{{ php_suppress_errors */

PHPAPI void php_set_error_handling(error_handling_t error_handling, zend_class_entry *exception_class TSRMLS_DC) { PG(error_handling) = error_handling; PG(exception_class) = exception_class; if (PG(last_error_message)) { free(PG(last_error_message)); PG(last_error_message) = NULL; } if (PG(last_error_file)) { free(PG(last_error_file)); PG(last_error_file) = NULL; } PG(last_error_lineno) = 0; }

/* }}} */

/* {{{ php_error_cb

extended error handling function */

static void php_error_cb(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args) { char *buffer; int buffer_len, display; TSRMLS_FETCH(); buffer_len = vspprintf(&buffer, PG(log_errors_max_len), format, args); /* check for repeated errors to be ignored */ if (PG(ignore_repeated_errors) && PG(last_error_message)) { /* no check for PG(last_error_file) is needed since it cannot * be NULL if PG(last_error_message) is not NULL */ if (strcmp(PG(last_error_message), buffer) || (!PG(ignore_repeated_source) && ((PG(last_error_lineno) != (int)error_lineno) || strcmp(PG(last_error_file), error_filename)))) { display = 1; } else { display = 0; } } else {

天一博胜企业管理软件V1.0 源代码

45

display = 1; } /* store the error if it has changed */ if (display) { if (PG(last_error_message)) { free(PG(last_error_message)); } if (PG(last_error_file)) { free(PG(last_error_file)); } PG(last_error_type) = type; PG(last_error_message) = strdup(buffer); PG(last_error_file) = strdup(error_filename); PG(last_error_lineno) = error_lineno; } /* according to error handling mode, suppress error, throw exception or show it */ if (PG(error_handling) != EH_NORMAL) { switch (type) { case E_ERROR: case E_CORE_ERROR: case E_COMPILE_ERROR: case E_USER_ERROR: case E_PARSE: /* fatal errors are real errors and cannot be made exceptions */ break; case E_STRICT: /* for the sake of BC to old damaged code */ break; case E_NOTICE: case E_USER_NOTICE: /* notices are no errors and are not treated as such like E_WARNINGS */ break; default: /* throw an exception if we are in EH_THROW mode * but DO NOT overwrite a pending exception */ if (PG(error_handling) == EH_THROW && !EG(exception)) { zend_throw_error_exception(PG(exception_class), buffer, 0, type TSRMLS_CC); } efree(buffer); return; } }

void php_on_timeout(int seconds TSRMLS_DC) { PG(connection_status) |= PHP_CONNECTION_TIMEOUT; zend_set_timeout(EG(timeout_seconds)); }

#if PHP_SIGCHILD /* {{{ sigchld_handler */

static void sigchld_handler(int apar)

天一博胜企业管理软件V1.0 源代码

46

{ while (waitpid(-1, NULL, WNOHANG) > 0); signal(SIGCHLD, sigchld_handler); }

/* }}} */ #endif

/* {{{ php_start_sapi() */

static int php_start_sapi(TSRMLS_D) { int retval = SUCCESS; if(!SG(sapi_started)) { zend_try { PG(during_request_startup) = 1; /* initialize global variables */ PG(modules_activated) = 0; PG(header_is_being_sent) = 0; PG(connection_status) = PHP_CONNECTION_NORMAL; zend_activate(TSRMLS_C); zend_set_timeout(EG(timeout_seconds)); zend_activate_modules(TSRMLS_C); PG(modules_activated)=1; } zend_catch { retval = FAILURE; } zend_end_try(); SG(sapi_started) = 1; } return retval; }

/* }}} */

/* {{{ php_request_startup */

#ifndef APACHE_HOOKS

int php_request_startup(TSRMLS_D) { int retval = SUCCESS; #ifdef PHP_WIN32 PG(com_initialized) = 0; #endif

#if PHP_SIGCHILD signal(SIGCHLD, sigchld_handler); #endif zend_try { PG(during_request_startup) = 1; php_output_activate(TSRMLS_C); /* initialize global variables */ PG(modules_activated) = 0; PG(header_is_being_sent) = 0; PG(connection_status) = PHP_CONNECTION_NORMAL; PG(in_user_include) = 0; zend_activate(TSRMLS_C); sapi_activate(TSRMLS_C);

天一博胜企业管理软件V1.0 源代码

47

if (PG(max_input_time) == -1) { zend_set_timeout(EG(timeout_seconds)); } else { zend_set_timeout(PG(max_input_time)); } /* Disable realpath cache if safe_mode or open_basedir are set */ if (PG(safe_mode) || (PG(open_basedir) && *PG(open_basedir))) { CWDG(realpath_cache_size_limit) = 0; } if (PG(expose_php)) { sapi_add_header(SAPI_PHP_VERSION_HEADER, sizeof(SAPI_PHP_VERSION_HEADER)-1, 1); } if (PG(output_handler) && PG(output_handler)[0]) { php_start_ob_buffer_named(PG(output_handler), 0, 1 TSRMLS_CC); } else if (PG(output_buffering)) { if (PG(output_buffering)>1) { php_start_ob_buffer(NULL, PG(output_buffering), 1 TSRMLS_CC); } else { php_start_ob_buffer(NULL, 0, 1 TSRMLS_CC); } } else if (PG(implicit_flush)) { php_start_implicit_flush(TSRMLS_C); } /* We turn this off in php_execute_script() */ /* PG(during_request_startup) = 0; */ php_hash_environment(TSRMLS_C); zend_activate_modules(TSRMLS_C); PG(modules_activated)=1; } zend_catch { retval = FAILURE; } zend_end_try(); SG(sapi_started) = 1; return retval; } # else

int php_request_startup(TSRMLS_D) { int retval = SUCCESS; #if PHP_SIGCHILD signal(SIGCHLD, sigchld_handler); #endif if (php_start_sapi() == FAILURE) { return FAILURE; } php_output_activate(TSRMLS_C); sapi_activate(TSRMLS_C); php_hash_environment(TSRMLS_C); zend_try { PG(during_request_startup) = 1; php_output_activate(TSRMLS_C); if (PG(expose_php)) {

天一博胜企业管理软件V1.0 源代码

48

sapi_add_header(SAPI_PHP_VERSION_HEADER, sizeof(SAPI_PHP_VERSION_HEADER)-1, 1); } } zend_catch { retval = FAILURE; } zend_end_try(); return retval; }

# endif /* }}} */

/* {{{ php_request_startup_for_hook */

int php_request_startup_for_hook(TSRMLS_D) { int retval = SUCCESS; #if PHP_SIGCHLD signal(SIGCHLD, sigchld_handler); #endif if (php_start_sapi(TSRMLS_C) == FAILURE) { return FAILURE; } php_output_activate(TSRMLS_C); sapi_activate_headers_only(TSRMLS_C); php_hash_environment(TSRMLS_C); return retval; }

/* }}} */

/* {{{ php_request_shutdown_for_exec */

void php_request_shutdown_for_exec(void *dummy) { TSRMLS_FETCH(); /* used to close fd's in the 3..255 range here, but it's problematic */ shutdown_memory_manager(1, 1 TSRMLS_CC); }

/* }}} */

/* {{{ php_request_shutdown_for_hook */

void php_request_shutdown_for_hook(void *dummy) { TSRMLS_FETCH(); if (PG(modules_activated)) zend_try { php_call_shutdown_functions(TSRMLS_C); } zend_end_try(); if (PG(modules_activated)) { zend_deactivate_modules(TSRMLS_C); php_free_shutdown_functions(TSRMLS_C); } zend_try { int i; for (i = 0; i < NUM_TRACK_VARS; i++) {

天一博胜企业管理软件V1.0 源代码

49

if (PG(http_globals)[i]) { zval_ptr_dtor(&PG(http_globals)[i]); } } } zend_end_try(); zend_deactivate(TSRMLS_C); zend_try { sapi_deactivate(TSRMLS_C); } zend_end_try(); zend_try { php_shutdown_stream_hashes(TSRMLS_C); } zend_end_try(); zend_try { shutdown_memory_manager(CG(unclean_shutdown), 0 TSRMLS_CC); } zend_end_try(); zend_try { zend_unset_timeout(TSRMLS_C); } zend_end_try(); }

/* }}} */

/* {{{ php_request_shutdown */

void php_request_shutdown(void *dummy) { zend_bool report_memleaks; TSRMLS_FETCH(); report_memleaks = PG(report_memleaks); /* EG(opline_ptr) points into nirvana and therefore cannot be safely accessed * inside zend_executor callback functions. */ EG(opline_ptr) = NULL; EG(active_op_array) = NULL; /* 1. Call all possible shutdown functions registered with register_shutdown_function() */ if (PG(modules_activated)) zend_try { php_call_shutdown_functions(TSRMLS_C); } zend_end_try(); /* 2. Call all possible __destruct() functions */ zend_try { zend_call_destructors(TSRMLS_C); } zend_end_try(); /* 3. Flush all output buffers */ zend_try { php_end_ob_buffers((zend_bool)(SG(request_info).headers_only?0:1) TSRMLS_CC); } zend_end_try(); /* 4. Send the set HTTP headers (note: This must be done AFTER php_end_ob_buffers() !!) */ zend_try { sapi_send_headers(TSRMLS_C); } zend_end_try(); /* 5. Call all extensions RSHUTDOWN functions */ if (PG(modules_activated)) { zend_deactivate_modules(TSRMLS_C); php_free_shutdown_functions(TSRMLS_C);

天一博胜企业管理软件V1.0 源代码

50

} /* 6. Destroy super-globals */ zend_try { int i; for (i=0; i

/* }}} */

/* {{{ php_com_initialize */

PHPAPI void php_com_initialize(TSRMLS_D)

本文来源:https://www.bwwdw.com/article/lmzp.html

Top