From fd5b4c5910cf6639018a3569f458199abfd41334 Mon Sep 17 00:00:00 2001 From: Shish Date: Mon, 18 Jun 2012 01:06:36 +0100 Subject: [PATCH] more re-organisation for create_monolith / hiphop friendliness --- core/userclass.class.php | 4 +--- core/util.inc.php | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/core/userclass.class.php b/core/userclass.class.php index a8a5a66e..c9368d83 100644 --- a/core/userclass.class.php +++ b/core/userclass.class.php @@ -155,7 +155,5 @@ new UserClass("admin", "base", array( "protected" => True, )); -if(file_exists("data/config/user-classes.conf.php")) { - require_once("data/config/user-classes.conf.php"); -} +@include_once "data/config/user-classes.conf.php"; ?> diff --git a/core/util.inc.php b/core/util.inc.php index b0be2d93..813783e1 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -821,6 +821,8 @@ $_included = array(); * Get the active contents of a .php file */ function manual_include($fname) { + if(!file_exists($fname)) return; + global $_included; if(in_array($fname, $_included)) return; $_included[] = $fname; @@ -828,15 +830,20 @@ function manual_include($fname) { print "$fname\n"; $text = file_get_contents($fname); - $text = preg_replace('/^<\?php/', '', $text); - $text = preg_replace('/\?>$/', '', $text); + + // we want one continuous file + $text = str_replace('<'.'?php', '', $text); + $text = str_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); - #} + + // @include_once is used for user-creatable config files + $text = preg_replace('/@include_once "(.*)";/e', "manual_include('$1')", $text); + + // wibble the defines for HipHop's sake + #$text = str_replace('function _d(', '// function _messed_d(', $text); #$text = preg_replace('/_d\(([^,]*), (.*)\);/', 'if(!defined(\1)) define(\1, \2);', $text); return $text;