Index: /branches/1.3/xcache.c
===================================================================
--- /branches/1.3/xcache.c	(revision 626)
+++ /branches/1.3/xcache.c	(revision 627)
@@ -1594,4 +1594,12 @@
 }
 /* }}} */
+static void xc_copy_zend_constant(zend_constant *c) /* {{{ */
+{
+	c->name = zend_strndup(c->name, c->name_len - 1);
+	if (!(c->flags & CONST_PERSISTENT)) {
+		zval_copy_ctor(&c->value);
+	}
+}
+/* }}} */
 static void xc_request_init(TSRMLS_D) /* {{{ */
 {
@@ -1599,13 +1607,25 @@
 
 	if (!XG(internal_table_copied)) {
+#ifdef HAVE_XCACHE_CONSTANT
+		zend_constant tmp_const;
+#endif
 		zend_function tmp_func;
 		xc_cest_t tmp_cest;
 
+#ifdef HAVE_XCACHE_CONSTANT
+		zend_hash_destroy(&XG(internal_constant_table));
+#endif
 		zend_hash_destroy(&XG(internal_function_table));
 		zend_hash_destroy(&XG(internal_class_table));
 
+#ifdef HAVE_XCACHE_CONSTANT
+		zend_hash_init_ex(&XG(internal_constant_table), 20,  NULL, NULL, 1, 0);
+#endif
 		zend_hash_init_ex(&XG(internal_function_table), 100, NULL, NULL, 1, 0);
 		zend_hash_init_ex(&XG(internal_class_table),    10,  NULL, NULL, 1, 0);
 
+#ifdef HAVE_XCACHE_CONSTANT
+		zend_hash_copy(&XG(internal_constant_table), EG(zend_constants), (copy_ctor_func_t) xc_copy_zend_constant, &tmp_const, sizeof(tmp_const));
+#endif
 		zend_hash_copy(&XG(internal_function_table), CG(function_table), NULL, &tmp_func, sizeof(tmp_func));
 		zend_hash_copy(&XG(internal_class_table), CG(class_table), NULL, &tmp_cest, sizeof(tmp_cest));
@@ -1666,4 +1686,7 @@
 	memset(xcache_globals, 0, sizeof(zend_xcache_globals));
 
+#ifdef HAVE_XCACHE_CONSTANT
+	zend_hash_init_ex(&xcache_globals->internal_constant_table, 1, NULL, NULL, 1, 0);
+#endif
 	zend_hash_init_ex(&xcache_globals->internal_function_table, 1, NULL, NULL, 1, 0);
 	zend_hash_init_ex(&xcache_globals->internal_class_table,    1, NULL, NULL, 1, 0);
@@ -1697,4 +1720,7 @@
 
 	if (xcache_globals->internal_table_copied) {
+#ifdef HAVE_XCACHE_CONSTANT
+		zend_hash_destroy(&xcache_globals->internal_constant_table);
+#endif
 		zend_hash_destroy(&xcache_globals->internal_function_table);
 		zend_hash_destroy(&xcache_globals->internal_class_table);
Index: /branches/1.3/xcache-test.ini
===================================================================
--- /branches/1.3/xcache-test.ini	(revision 623)
+++ /branches/1.3/xcache-test.ini	(revision 627)
@@ -8,5 +8,5 @@
 xcache.cacher = On
 xcache.test=1
-xcache.size = 1M
+xcache.size = 16M
 xcache.count = 1
 xcache.var_size = 1M
Index: /branches/1.3/admin/edit.tpl.php
===================================================================
--- /branches/1.3/admin/edit.tpl.php	(revision 604)
+++ /branches/1.3/admin/edit.tpl.php	(revision 627)
@@ -7,5 +7,5 @@
 	<fieldset>
 		<legend><?php echo sprintf(_T("Editing Variable %s"), $h_name); ?></legend>
-		<textarea name="value" style="width: 100%; height: 200px; overflow-y: auto"><?php echo $h_value; ?></textarea><br>
+		<textarea name="value" style="width: 100%; height: 200px; overflow-y: auto" <?php echo $editable ? "" : "disabled=disabled"; ?>><?php echo $h_value; ?></textarea><br>
 		<input type="submit">
 	</fieldset>
Index: /branches/1.3/admin/edit.php
===================================================================
--- /branches/1.3/admin/edit.php	(revision 607)
+++ /branches/1.3/admin/edit.php	(revision 627)
@@ -12,10 +12,28 @@
 
 if ($_SERVER['REQUEST_METHOD'] == 'POST') {
-	eval('$value = ' . $_POST['value']);
+	if ($enable_eval) {
+		eval('$value = ' . $_POST['value']);
+	}
+	else {
+		$value = $_POST['value'];
+	}
 	xcache_set($name, $value);
 	header("Location: xcache.php?type=" . XC_TYPE_VAR);
 	exit;
 }
-$value = var_export(xcache_get($name), true);
+$value = xcache_get($name);
+if ($enable_eval) {
+	$value = var_export($value, true);
+	$editable = true;
+}
+else {
+	if (is_string($value)) {
+		$editable = true;
+	}
+	else {
+		$editable = false;
+		$value = var_export($value, true);
+	}
+}
 
 $xcache_version = XCACHE_VERSION;
Index: /branches/1.3/admin/config.php.example
===================================================================
--- /branches/1.3/admin/config.php.example	(revision 623)
+++ /branches/1.3/admin/config.php.example	(revision 627)
@@ -16,4 +16,8 @@
 // do not define both with
 // $free_graph_width = 120;
+
+// only enable if you have password protection for admin page
+// enabling this option will cause user to eval() whatever code they want
+$enable_eval = false;
 
 // this function is detected by xcache.tpl.php, and enabled if function_exists
Index: /branches/1.3/run-xcachetest
===================================================================
--- /branches/1.3/run-xcachetest	(revision 623)
+++ /branches/1.3/run-xcachetest	(revision 627)
@@ -1,7 +1,11 @@
 #!/bin/sh
+
+getAbsolutePath() {
+	which readlink >/dev/null 2>&1 && readlink -f "$@" || echo "$@"
+}
 
 # use symlink first
 if test -x ./php-cli ; then
-	php_cli=./php-cli
+	php_cli=`getAbsolutePath ./php-cli`
 elif test ! -z "$TEST_PHP_EXECUTABLE" && test -x "$TEST_PHP_EXECUTABLE"; then
 	php_cli="$TEST_PHP_EXECUTABLE"
@@ -11,30 +15,22 @@
 
 if test -x ./php-cgi ; then
-	php_cgi=./php-cgi
+	php_cgi=`getAbsolutePath ./php-cgi`
 else
 	php_cgi="`which php-cgi`"
 fi
 
-test -z "$PHP_SRC" && PHP_SRC=./php-src
-if test -z "$TEST_PHP_USER" ; then
-	TEST_PHP_USER="$PHP_SRC/tests"
-	for i in Zend ZendEngine2 ext/standard/tests ext/reflection/tests ext/spl/tests; do
-		if test -d "$PHP_SRC/$i" ; then
-			TEST_PHP_USER="$TEST_PHP_USER,$PHP_SRC/$i"
-		fi
-	done
-fi
+test -z "$PHP_SRC" && PHP_SRC=`getAbsolutePath ./php-src`
 
 TEST_PHP_EXECUTABLE="$php_cli"
 TEST_PHP_CGI_EXECUTABLE="$php_cgi"
+TEST_PHP_SRCDIR="$PHP_SRC"
 
+export TEST_PHP_EXECUTABLE
 export TEST_PHP_CGI_EXECUTABLE
-export TEST_PHP_EXECUTABLE
-export TEST_PHP_USER
+export TEST_PHP_SRCDIR
 
 echo "XCache test running with:"
 echo "TEST_PHP_CGI_EXECUTABLE: $TEST_PHP_CGI_EXECUTABLE"
 echo "TEST_PHP_EXECUTABLE:     $TEST_PHP_EXECUTABLE"
-echo "TEST_PHP_USER:           $TEST_PHP_USER"
 
 exec "$php_cli" "$@"
Index: /branches/1.3/utils.c
===================================================================
--- /branches/1.3/utils.c	(revision 625)
+++ /branches/1.3/utils.c	(revision 627)
@@ -598,4 +598,12 @@
 #endif
 
+static void xc_copy_zend_constant(zend_constant *c) /* {{{ */
+{
+	c->name = zend_strndup(c->name, c->name_len - 1);
+	if (!(c->flags & CONST_PERSISTENT)) {
+		zval_copy_ctor(&c->value);
+	}
+}
+/* }}} */
 xc_sandbox_t *xc_sandbox_init(xc_sandbox_t *sandbox, char *filename TSRMLS_DC) /* {{{ */
 {
@@ -635,4 +643,8 @@
 	h = OG(zend_constants);
 	zend_hash_init_ex(&TG(zend_constants),  20, NULL, h->pDestructor, h->persistent, h->bApplyProtection);
+	{
+		zend_constant tmp_const;
+		zend_hash_copy(&TG(zend_constants), &XG(internal_constant_table), (copy_ctor_func_t) xc_copy_zend_constant, (void *) &tmp_const, sizeof(tmp_const));
+	}
 #endif
 	h = OG(function_table);
@@ -677,5 +689,5 @@
 	/* 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;
+	CG(compiler_options) |= ZEND_COMPILE_IGNORE_INTERNAL_CLASSES | ZEND_COMPILE_NO_CONSTANT_SUBSTITUTION | ZEND_COMPILE_DELAYED_BINDING;
 #endif
 
@@ -696,5 +708,5 @@
 
 #ifdef HAVE_XCACHE_CONSTANT
-	b = TG(zend_constants).pListHead;
+	b = /*TG(internal_constant_tail) ? TG(internal_constant_tail)->pListNext :*/ TG(zend_constants).pListHead;
 	/* install constants */
 	while (b != NULL) {
Index: /branches/1.3/xcache_globals.h
===================================================================
--- /branches/1.3/xcache_globals.h	(revision 622)
+++ /branches/1.3/xcache_globals.h	(revision 627)
@@ -22,4 +22,7 @@
 #endif
 
+#ifdef HAVE_XCACHE_CONSTANT
+	HashTable internal_constant_table;
+#endif
 	HashTable internal_function_table;
 	HashTable internal_class_table;
Index: /branches/1.3/utils.h
===================================================================
--- /branches/1.3/utils.h	(revision 625)
+++ /branches/1.3/utils.h	(revision 627)
@@ -95,4 +95,7 @@
 	HashTable tmp_class_table;
 	HashTable tmp_auto_globals;
+#ifdef HAVE_XCACHE_CONSTANT
+	Bucket    *tmp_internal_constant_tail;
+#endif
 	Bucket    *tmp_internal_function_tail;
 	Bucket    *tmp_internal_class_tail;
Index: /branches/1.3/Makefile.frag
===================================================================
--- /branches/1.3/Makefile.frag	(revision 620)
+++ /branches/1.3/Makefile.frag	(revision 627)
@@ -15,5 +15,5 @@
 
 $(XCACHE_PROC_OUT): $(XCACHE_PROC_SRC) $(XCACHE_STRUCTINFO_OUT) $(XCACHE_PROC_SOURCES)
-	$(M4) -D srcdir="$(srcdir)" -D builddir="$(builddir)" $(XCACHE_ENABLE_TEST) $(XCACHE_PROC_SRC) > $(XCACHE_PROC_OUT).tmp
+	$(M4) -D srcdir='`'"$(srcdir)'" -D builddir='`'"$(builddir)'" $(XCACHE_ENABLE_TEST) $(XCACHE_PROC_SRC) > $(XCACHE_PROC_OUT).tmp
 	mv -f $(XCACHE_PROC_OUT).tmp $(XCACHE_PROC_OUT)
 
@@ -39,5 +39,6 @@
 
 xcachetest:
+	$(SED) "s#\\./modules/#$(top_builddir)/modules/#" < $(srcdir)/xcache-test.ini > $(top_builddir)/tmp-php.ini
 	TEST_PHP_SRCDIR=$(top_srcdir) \
 	CC="$(CC)" \
-		$(srcdir)/run-xcachetest -d 'open_basedir=' -d 'safe_mode=0' -d 'output_buffering=0' -d 'memory_limit=-1' $(top_srcdir)/run-tests.php $(TESTS) $(TEST_ARGS) -c $(srcdir)/xcache-test.ini
+		$(srcdir)/run-xcachetest -d 'open_basedir=' -d 'safe_mode=0' -d 'output_buffering=0' -d 'memory_limit=-1' $(top_srcdir)/run-tests.php $(TESTS) $(TEST_ARGS) -c $(top_builddir)/tmp-php.ini
