From 78d701dd53b691edb0bcd48fe4abd2c3b054d750 Mon Sep 17 00:00:00 2001 From: Shish Date: Mon, 18 Jun 2012 00:45:32 +0100 Subject: [PATCH] move stuff about to make create_monolith simpler --- core/util.inc.php | 28 ++++++++++++++++++++++++++++ index.php | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/core/util.inc.php b/core/util.inc.php index 8bd37f6a..b0be2d93 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -815,6 +815,34 @@ function transload($url, $mfile) { return false; } + +$_included = array(); +/** + * Get the active contents of a .php file + */ +function manual_include($fname) { + global $_included; + if(in_array($fname, $_included)) return; + $_included[] = $fname; + + print "$fname\n"; + + $text = file_get_contents($fname); + $text = preg_replace('/^<\?php/', '', $text); + $text = preg_replace('/\?>$/', '', $text); + // most requires are built-in, but we want /lib separately + $text = str_replace('require_', '// require_', $text); + $text = str_replace('function _d(', '// function _messed_d(', $text); + $text = str_replace('// require_once "lib', 'require_once "lib', $text); + #if(RECURSE_INCLUDE) { + # text = preg_replace('/require_once "(.*)";/e', "manual_include('$1')", $text); + #} + #$text = preg_replace('/_d\(([^,]*), (.*)\);/', 'if(!defined(\1)) define(\1, \2);', $text); + + return $text; +} + + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ * Logging convenience * \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ diff --git a/index.php b/index.php index fe48a795..e8e6323c 100644 --- a/index.php +++ b/index.php @@ -100,9 +100,9 @@ try { send_event(new CommandEvent($argv)); } - $database->db->commit(); // saving cache data and profiling data to disk can happen later if(function_exists("fastcgi_finish_request")) fastcgi_finish_request(); + $database->db->commit(); ctx_log_endok(); } catch(Exception $e) {