Index: /branches/1.3/ChangeLog
===================================================================
--- /branches/1.3/ChangeLog	(revision 624)
+++ /branches/1.3/ChangeLog	(revision 625)
@@ -1,4 +1,5 @@
 1.3.0 2009-??-??
 == ChangeLog ==
+ * PHP 5.3 Supported
  * fixed #138: no segv if cache is not initialized correctly
  * default to 64M for xcache.size in xcache.ini
@@ -6,5 +7,5 @@
  * wrong http auth realm
  * coverager: font-size and newline fix for firefox
- * PHP 5.3 Supported
+ * admin page is now magic quote gpc aware
 
 1.2.2 2007-12-29
Index: /branches/1.3/NEWS
===================================================================
--- /branches/1.3/NEWS	(revision 624)
+++ /branches/1.3/NEWS	(revision 625)
@@ -4,4 +4,5 @@
  * many cacher/coverager bug fixes
  * improved admin pages
+ * admin page is now magic quote gpc aware
  
 1.2.2 2007-12-29
Index: /branches/1.3/admin/common.php
===================================================================
--- /branches/1.3/admin/common.php	(revision 624)
+++ /branches/1.3/admin/common.php	(revision 625)
@@ -92,5 +92,5 @@
 define('REQUEST_TIME', time());
 
-if (get_magic_quotes_gpc()) {
+if (function_exists('get_magic_quotes_gpc') && @get_magic_quotes_gpc()) {
 	$mqs = (bool) ini_get('magic_quotes_sybase');
 	$_GET = stripaddslashes_array($_GET, $mqs);
Index: /branches/1.3/admin/mkpassword.php
===================================================================
--- /branches/1.3/admin/mkpassword.php	(revision 625)
+++ /branches/1.3/admin/mkpassword.php	(revision 625)
@@ -0,0 +1,24 @@
+<html>
+	<head>
+		<title>Simple MD5 password generator</title>
+	</head>
+	<body>
+		<h1>Simple MD5 password generator</h1>
+		<form method="post">
+			<fieldset>
+				md5: <input type="password" name="password"> <input type="submit"><br>
+				<div>
+				<?php
+				if ($_SERVER['REQUEST_METHOD'] == 'POST') {
+					$md5 = md5(@ $_POST['password']);
+					$offs = mt_rand(0 + 1, 31 - 1);
+					$md5_1 = substr($md5, 0, $offs);
+					$md5_2 = substr($md5, $offs);
+					echo "Result: <span>$md5_1</span><span>$md5_2</span>";
+				}
+				?>
+				</div>
+			</fieldset>
+		</form>
+	</body>
+</html>
Index: /branches/1.3/admin/xcache.php
===================================================================
--- /branches/1.3/admin/xcache.php	(revision 624)
+++ /branches/1.3/admin/xcache.php	(revision 625)
@@ -130,6 +130,6 @@
 		else {
 			switch ($k) {
-			case 'his_by_hour':
-			case 'his_by_second':
+			case 'hits_by_hour':
+			case 'hits_by_second':
 				foreach ($data[$k] as $kk => $vv) {
 					$total[$k][$kk] += $vv;
Index: /branches/1.3/coverager.c
===================================================================
--- /branches/1.3/coverager.c	(revision 624)
+++ /branches/1.3/coverager.c	(revision 625)
@@ -1,2 +1,6 @@
+#if 0
+#define XCACHE_DEBUG
+#endif
+
 #include <stdio.h>
 #include "xcache.h"
@@ -18,8 +22,4 @@
 static char *xc_coveragedump_dir = NULL;
 static zend_compile_file_t *old_compile_file = NULL;
-
-#if 0
-#define DEBUG
-#endif
 
 /* dumper */
@@ -246,5 +246,9 @@
 	if (XG(coverager)) {
 		xc_coverager_enable(TSRMLS_C);
+#ifdef ZEND_COMPILE_EXTENDED_INFO
+		CG(compiler_options) |= ZEND_COMPILE_EXTENDED_INFO;
+#else
 		CG(extended_info) = 1;
+#endif
 	}
 	else {
@@ -470,6 +474,7 @@
 
 	if (cfg_get_string("xcache.coveragedump_directory", &xc_coveragedump_dir) == SUCCESS && xc_coveragedump_dir) {
+		int len;
 		xc_coveragedump_dir = pestrdup(xc_coveragedump_dir, 1);
-		int len = strlen(xc_coveragedump_dir);
+		len = strlen(xc_coveragedump_dir);
 		if (len) {
 			if (xc_coveragedump_dir[len - 1] == '/') {
Index: /branches/1.3/mem.c
===================================================================
--- /branches/1.3/mem.c	(revision 624)
+++ /branches/1.3/mem.c	(revision 625)
@@ -2,7 +2,13 @@
 #include <limits.h>
 #include <stdio.h>
+#	define XCACHE_DEBUG
 #else
 #include <php.h>
 #endif
+
+#ifdef XCACHE_DEBUG
+#	define ALLOC_DEBUG_BLOCK_CHECK
+#endif
+
 
 #include <assert.h>
@@ -14,11 +20,4 @@
 #include "align.h"
 #include "utils.h"
-
-#ifdef TEST
-#	define DEBUG
-#endif
-#ifdef DEBUG
-#	define ALLOC_DEBUG_BLOCK_CHECK
-#endif
 
 #if 0
Index: /branches/1.3/mmap.c
===================================================================
--- /branches/1.3/mmap.c	(revision 624)
+++ /branches/1.3/mmap.c	(revision 625)
@@ -199,5 +199,5 @@
 	if (shm->ptr == XCACHE_MAP_FAILED) {
 		perror(shm->name);
-		errstr = "Failed creating file mappping";
+		errstr = "Failed creating file mapping";
 		shm->ptr = NULL;
 		goto err;
Index: /branches/1.3/processor/processor.m4
===================================================================
--- /branches/1.3/processor/processor.m4	(revision 624)
+++ /branches/1.3/processor/processor.m4	(revision 625)
@@ -506,5 +506,10 @@
 	dnl main op_array && have early binding
 	zend_uint ii;
-	if (!processor->readonly_protection && !(src == processor->xce_src->data.php->op_array && processor->xce_src->data.php->have_early_binding)) {
+#ifdef ZEND_COMPILE_DELAYED_BINDING
+	zend_bool need_early_binding = 0;
+#else
+	zend_bool need_early_binding = processor->xce_src->data.php->have_early_binding;
+#endif
+	if (!processor->readonly_protection && !(src == processor->xce_src->data.php->op_array && need_early_binding)) {
 		/* really fast shallow copy */
 		memcpy(dst, src, sizeof(src[0]));
@@ -633,4 +638,7 @@
 	PROC_ZSTRING_L(, doc_comment, doc_comment_len)
 #endif
+#ifdef ZEND_COMPILE_DELAYED_BINDING
+	DISPATCH(zend_uint, early_binding);
+#endif
 
 	/* reserved */
@@ -730,5 +738,7 @@
 	STRUCT(zend_class_entry, cest)
 #endif
+#ifndef ZEND_COMPILE_DELAYED_BINDING
 	DISPATCH(int, oplineno)
+#endif
 ')
 dnl }}}
@@ -783,5 +793,8 @@
 	')
 #endif
+#ifndef ZEND_COMPILE_DELAYED_BINDING
 	DISPATCH(zend_bool, have_early_binding)
+#endif
+	DISPATCH(zend_bool, have_references)
 ')
 dnl }}}
Index: /branches/1.3/utils.c
===================================================================
--- /branches/1.3/utils.c	(revision 624)
+++ /branches/1.3/utils.c	(revision 625)
@@ -500,7 +500,9 @@
 					ZESW(&stored_ce_ptr, NULL)
 					);
+#ifndef ZEND_COMPILE_DELAYED_BINDING
 		if (oplineno != -1) {
 			xc_do_early_binding(CG(active_op_array), CG(class_table), oplineno TSRMLS_CC);
 		}
+#endif
 	}
 	else if (zend_u_hash_quick_add(CG(class_table), type, key, len, h,
@@ -526,4 +528,50 @@
 #define OG(x) (sandbox->orig_##x)
 /* }}} */
+<<<<<<< .working
+=======
+#ifdef E_STRICT
+static void xc_sandbox_error_cb(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args) /* {{{ */
+{
+	xc_compilererror_t *compilererror;
+	xc_sandbox_t *sandbox;
+	TSRMLS_FETCH();
+
+	sandbox = (xc_sandbox_t *) XG(sandbox);
+	assert(sandbox != NULL);
+	if (type != E_STRICT) {
+		/* give up, and user handler is not supported in this case */
+		zend_uint i;
+		zend_uint orig_lineno = CG(zend_lineno);
+		zend_error_cb = sandbox->orig_zend_error_cb;
+
+		for (i = 0; i < sandbox->compilererror_cnt; i ++) {
+			compilererror = &sandbox->compilererrors[i];
+			CG(zend_lineno) = compilererror->lineno;
+			zend_error(E_STRICT, "%s", compilererror->error);
+		}
+		CG(zend_lineno) = orig_lineno;
+		sandbox->compilererror_cnt = 0;
+
+		sandbox->orig_zend_error_cb(type, error_filename, error_lineno, format, args);
+		return;
+	}
+
+	if (sandbox->compilererror_cnt <= sandbox->compilererror_size) {
+		if (sandbox->compilererror_size) {
+			sandbox->compilererror_size += 16;
+			sandbox->compilererrors = erealloc(sandbox->compilererrors, sandbox->compilererror_size * sizeof(sandbox->compilererrors));
+		}
+		else {
+			sandbox->compilererror_size = 16;
+			sandbox->compilererrors = emalloc(sandbox->compilererror_size * sizeof(sandbox->compilererrors));
+		}
+	}
+	compilererror = &sandbox->compilererrors[sandbox->compilererror_cnt++];
+	compilererror->lineno = error_lineno;
+	compilererror->error_len = vspprintf(&compilererror->error, 0, format, args);
+}
+/* }}} */
+#endif
+>>>>>>> .merge-right.r559
 #ifdef ZEND_ENGINE_2_1
 static zend_bool xc_auto_global_callback(char *name, uint name_len TSRMLS_DC) /* {{{ */
@@ -625,4 +673,12 @@
 #endif
 
+#ifdef ZEND_COMPILE_IGNORE_INTERNAL_CLASSES
+	sandbox->orig_compiler_options = CG(compiler_options);
+	/* Using ZEND_COMPILE_IGNORE_INTERNAL_CLASSES for ZEND_FETCH_CLASS_RT_NS_CHECK
+	 */
+	CG(compiler_options) |= ZEND_COMPILE_IGNORE_INTERNAL_CLASSES | ZEND_COMPILE_DELAYED_BINDING;
+#endif
+
+	XG(sandbox) = (void *) sandbox;
 	return sandbox;
 }
@@ -636,5 +692,5 @@
 static void xc_sandbox_install(xc_sandbox_t *sandbox, xc_install_action_t install TSRMLS_DC) /* {{{ */
 {
-	int i;
+	zend_uint i;
 	Bucket *b;
 
@@ -679,7 +735,11 @@
 
 	if (install != XC_InstallNoBinding) {
+#ifdef ZEND_COMPILE_DELAYED_BINDING
+		zend_do_delayed_early_binding(CG(active_op_array) TSRMLS_CC);
+#else
 		xc_undo_pass_two(CG(active_op_array) TSRMLS_CC);
 		xc_foreach_early_binding_class(CG(active_op_array), xc_early_binding_cb, (void *) sandbox TSRMLS_CC);
 		xc_redo_pass_two(CG(active_op_array) TSRMLS_CC);
+#endif
 	}
 
@@ -735,4 +795,8 @@
 #endif
 
+#ifdef ZEND_COMPILE_IGNORE_INTERNAL_CLASSES
+	CG(compiler_options) = sandbox->orig_compiler_options;
+#endif
+
 	if (sandbox->alloc) {
 		efree(sandbox);
Index: /branches/1.3/utils.h
===================================================================
--- /branches/1.3/utils.h	(revision 624)
+++ /branches/1.3/utils.h	(revision 625)
@@ -2,5 +2,5 @@
 #include "xcache.h"
 
-#ifdef DEBUG
+#ifdef XCACHE_DEBUG
 #	define IFDEBUG(x) (x)
 int xc_vtrace(const char *fmt, va_list args);
@@ -25,5 +25,5 @@
 #   undef inline
 #   define inline
-#else /* DEBUG */
+#else /* XCACHE_DEBUG */
 
 #	ifdef ZEND_WIN32
@@ -41,5 +41,5 @@
 #       define NDEBUG
 #   endif
-#endif /* DEBUG */
+#endif /* XCACHE_DEBUG */
 #include <assert.h>
 
@@ -101,4 +101,8 @@
 	int orig_user_error_handler_error_reporting;
 #endif
+
+#ifdef ZEND_COMPILE_IGNORE_INTERNAL_CLASSES
+	zend_uint orig_compiler_options;
+#endif
 } xc_sandbox_t;
 
Index: /branches/1.3/xcache.c
===================================================================
--- /branches/1.3/xcache.c	(revision 624)
+++ /branches/1.3/xcache.c	(revision 625)
@@ -1,5 +1,5 @@
 
 #if 0
-#define DEBUG
+#define XCACHE_DEBUG
 #endif
 
@@ -23,4 +23,7 @@
 
 #include "xcache.h"
+#ifdef ZEND_ENGINE_2_1
+#include "ext/date/php_date.h"
+#endif
 #include "optimizer.h"
 #include "coverager.h"
@@ -652,6 +655,11 @@
 		new_cest_ptrs[i] =
 #endif
+#ifdef ZEND_COMPILE_DELAYED_BINDING
+		xc_install_class(xce->name.str.val, &ci->cest, -1,
+				UNISW(0, ci->type), ci->key, ci->key_size, ci->h TSRMLS_CC);
+#else
 		xc_install_class(xce->name.str.val, &ci->cest, ci->oplineno,
 				UNISW(0, ci->type), ci->key, ci->key_size, ci->h TSRMLS_CC);
+#endif
 	}
 
@@ -750,5 +758,5 @@
 
 #define HASH(i) (i)
-#define HASH_USTR_L(t, s, l) HASH(zend_u_inline_hash_func(t, s, (l + 1) * sizeof(UChar)))
+#define HASH_ZSTR_L(t, s, l) HASH(zend_u_inline_hash_func(t, s, (l + 1) * sizeof(UChar)))
 #define HASH_STR_L(s, l) HASH(zend_inline_hash_func(s, l + 1))
 #define HASH_STR(s) HASH_STR_L(s, strlen(s) + 1)
@@ -766,5 +774,5 @@
 static inline xc_hash_value_t xc_entry_hash_name(xc_entry_t *xce TSRMLS_DC) /* {{{ */
 {
-	return UNISW(NOTHING, UG(unicode) ? HASH_USTR_L(xce->name_type, xce->name.uni.val, xce->name.uni.len) :)
+	return UNISW(NOTHING, UG(unicode) ? HASH_ZSTR_L(xce->name_type, xce->name.uni.val, xce->name.uni.len) :)
 		HASH_STR_L(xce->name.str.val, xce->name.str.len);
 }
@@ -893,4 +901,5 @@
 }
 /* }}} */
+#ifndef ZEND_COMPILE_DELAYED_BINDING
 static void xc_cache_early_binding_class_cb(zend_op *opline, int oplineno, void *data TSRMLS_DC) /* {{{ */
 {
@@ -920,4 +929,5 @@
 }
 /* }}} */
+#endif
 static zend_op_array *xc_check_initial_compile_file(zend_file_handle *h, int type TSRMLS_DC) /* {{{ */
 {
@@ -938,5 +948,4 @@
 	char opened_path_buffer[MAXPATHLEN];
 	int old_constinfo_cnt, old_funcinfo_cnt, old_classinfo_cnt;
-	int i;
 
 	if (!xc_initized) {
@@ -1180,8 +1189,12 @@
 	}
 	/* }}} */
+#ifndef ZEND_COMPILE_DELAYED_BINDING
 	/* {{{ find inherited classes that should be early-binding */
 	php.have_early_binding = 0;
-	for (i = 0; i < php.classinfo_cnt; i ++) {
-		php.classinfos[i].oplineno = -1;
+	{
+		int i;
+		for (i = 0; i < php.classinfo_cnt; i ++) {
+			php.classinfos[i].oplineno = -1;
+		}
 	}
 
@@ -1190,4 +1203,6 @@
 	xc_redo_pass_two(php.op_array TSRMLS_CC);
 	/* }}} */
+#endif
+
 #ifdef SHOW_DPRINT
 	xc_dprint(&xce, 0 TSRMLS_CC);
@@ -1711,9 +1726,11 @@
 
 	if (admin_user == NULL || admin_pass == NULL) {
-		php_error_docref(NULL TSRMLS_CC, E_ERROR, "xcache.admin.user and xcache.admin.pass is required");
+		php_error_docref(XCACHE_WIKI_URL "/InstallAdministration" TSRMLS_CC, E_ERROR,
+				"xcache.admin.user and/or xcache.admin.pass settings is not configured."
+				" Make sure you've modified the correct php ini file for your php used in webserver.");
 		zend_bailout();
 	}
 	if (strlen(admin_pass) != 32) {
-		php_error_docref(NULL TSRMLS_CC, E_ERROR, "unexpect %lu bytes of xcache.admin.pass, expected 32 bytes, the password after md5()", (unsigned long) strlen(admin_pass));
+		php_error_docref(NULL TSRMLS_CC, E_ERROR, "xcache.admin.pass is %lu chars unexpectedly, it is supposed to be the password after md5() which should be 32 chars", (unsigned long) strlen(admin_pass));
 		zend_bailout();
 	}
@@ -1764,5 +1781,20 @@
 	sapi_add_header_ex(STR, sizeof(STR) - 1, 1, 1 TSRMLS_CC);
 #undef STR
-	ZEND_PUTS("XCache Auth Failed. User and Password is case sense\n");
+#define STR "Content-type: text/html; charset=UTF-8"
+	sapi_add_header_ex(STR, sizeof(STR) - 1, 1, 1 TSRMLS_CC);
+#undef STR
+	ZEND_PUTS("<html>\n");
+	ZEND_PUTS("<head><title>XCache Authentication Failed</title></head>\n");
+	ZEND_PUTS("<body>\n");
+	ZEND_PUTS("<h1>XCache Authentication Failed</h1>\n");
+	ZEND_PUTS("<p>You're not authorized to access this page due to wrong username and/or password you typed.<br />The following check points is suggested:</p>\n");
+	ZEND_PUTS("<ul>\n");
+	ZEND_PUTS("<li>Be aware that `Username' and `Password' is case sense. Check capslock status led on your keyboard, and punch left/right Shift keys once for each</li>\n");
+	ZEND_PUTS("<li>Make sure the md5 password is generated correctly. You may use <a href=\"mkpassword.php\">mkpassword.php</a></li>\n");
+	ZEND_PUTS("<li>Reload browser cache by pressing F5 and/or Ctrl+F5, or simply clear browser cache after you've updated username/password in php ini.</li>\n");
+	ZEND_PUTS("</ul>\n");
+	ZEND_PUTS("Check <a href=\"" XCACHE_WIKI_URL "/InstallAdministration\">XCache wiki page</a> for more information.\n");
+	ZEND_PUTS("</body>\n");
+	ZEND_PUTS("</html>\n");
 
 	zend_bailout();
@@ -2560,7 +2592,12 @@
 	php_info_print_table_row(2, "Modules Built", XCACHE_MODULES);
 	php_info_print_table_row(2, "Readonly Protection", xc_readonly_protection ? "enabled" : "N/A");
+#ifdef ZEND_ENGINE_2_1
 	ptr = php_format_date("Y-m-d H:i:s", sizeof("Y-m-d H:i:s") - 1, xc_init_time, 1 TSRMLS_CC);
 	php_info_print_table_row(2, "Cache Init Time", ptr);
 	efree(ptr);
+#else
+	snprintf(buf, sizeof(buf), "%lu", (long unsigned) xc_init_time);
+	php_info_print_table_row(2, "Cache Init Time", buf);
+#endif
 
 #ifdef ZTS
@@ -2805,5 +2842,9 @@
 		xc_initized = 1;
 		xc_init_time = time(NULL);
+#ifdef PHP_WIN32
+		xc_init_instance_id = GetCurrentProcessId();
+#else
 		xc_init_instance_id = getpid();
+#endif
 #ifdef ZTS
 		xc_init_instance_subid = tsrm_thread_id();
@@ -2979,5 +3020,5 @@
 
 		ext = (zend_extension *) zend_llist_get_last_ex(&zend_extensions, &lpos);
-		assert(ext && ext != xc_llist_zend_extension);
+		assert(ext && ext != (zend_extension *) xc_llist_zend_extension->data);
 		xc_last_ext_startup = ext->startup;
 		ext->startup = xc_zend_startup_last;
Index: /branches/1.3/xcache.h
===================================================================
--- /branches/1.3/xcache.h	(revision 624)
+++ /branches/1.3/xcache.h	(revision 625)
@@ -6,4 +6,5 @@
 #define XCACHE_COPYRIGHT  "Copyright (c) 2005-2009"
 #define XCACHE_URL        "http://xcache.lighttpd.net"
+#define XCACHE_WIKI_URL   XCACHE_URL "/wiki"
 
 #include <php.h>
@@ -39,5 +40,8 @@
 #endif
 
-#ifdef ALLOCA_FLAG
+#ifdef do_alloca_with_limit
+#	define my_do_alloca(size, use_heap) do_alloca_with_limit(size, use_heap)
+#	define my_free_alloca(size, use_heap) free_alloca_with_limit(size, use_heap)
+#elif defined(ALLOCA_FLAG)
 #	define my_do_alloca(size, use_heap) do_alloca(size, use_heap)
 #	define my_free_alloca(size, use_heap) free_alloca(size, use_heap)
@@ -238,5 +242,7 @@
 	ulong     h;
 	xc_cest_t cest;
+#ifndef ZEND_COMPILE_DELAYED_BINDING
 	int       oplineno;
+#endif
 } xc_classinfo_t;
 /* }}} */
@@ -299,5 +305,7 @@
 	zend_uint classinfo_cnt;
 	xc_classinfo_t *classinfos;
+#ifndef ZEND_COMPILE_DELAYED_BINDING
 	zend_bool have_early_binding;
+#endif
 
 #ifdef ZEND_ENGINE_2_1
