|
From: Culprit <cul...@us...> - 2008-06-22 09:38:07
|
Update of /cvsroot/mxbb/core/includes/shared/phpbb3/includes In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv13554/core/includes/shared/phpbb3/includes Modified Files: functions_module.php functions.php Log Message: massive update for new_acp caching of ported phpBB3 files that are not in shared or sessions folder under includes Index: functions.php =================================================================== RCS file: /cvsroot/mxbb/core/includes/shared/phpbb3/includes/functions.php,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** functions.php 18 Jun 2008 12:14:15 -0000 1.18 --- functions.php 20 Jun 2008 15:55:05 -0000 1.19 *************** *** 1199,1210 **** function tz_select($default = '', $truncate = false) { ! global $user; $tz_select = ''; ! foreach ($user->lang['tz_zones'] as $offset => $zone) { if ($truncate) { ! $zone_trunc = truncate_string($zone, 50, false, '...'); } else --- 1199,1211 ---- function tz_select($default = '', $truncate = false) { ! global $mx_user; $tz_select = ''; ! ! foreach ($mx_user->lang['tz'] as $offset => $zone) { if ($truncate) { ! $zone_trunc = phpbb3::truncate_string($zone, 50, false, '...'); } else Index: functions_module.php =================================================================== RCS file: /cvsroot/mxbb/core/includes/shared/phpbb3/includes/functions_module.php,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** functions_module.php 19 Jun 2008 05:11:50 -0000 1.18 --- functions_module.php 20 Jun 2008 15:55:04 -0000 1.19 *************** *** 48,55 **** var $module_ary = array(); var $FUNCTION_REPLACE_PHPBB3_ARRAY = array( 'request_var', 'add_form_key', 'generate_text_for_display', 'check_form_key', 'gen_sort_selects', 'on_page', 'generate_pagination', 'generate_text_for_edit', 'generate_text_for_storage', 'group_create', ! 'unique_id', 'set_config', 'style_select', 'meta_refresh', 'parse_cfg_file', 'get_formatted_filesize' ); /** --- 48,58 ---- var $module_ary = array(); + var $includes = array(); + var $no_include = '(functions_admin|acp/auth|functions_module|functions_posting|functions)'; var $FUNCTION_REPLACE_PHPBB3_ARRAY = array( 'request_var', 'add_form_key', 'generate_text_for_display', 'check_form_key', 'gen_sort_selects', 'on_page', 'generate_pagination', 'generate_text_for_edit', 'generate_text_for_storage', 'group_create', ! 'unique_id', 'set_config', 'style_select', 'meta_refresh', 'parse_cfg_file', 'get_formatted_filesize', ! 'tz_select', 'decode_message' ); /** *************** *** 406,409 **** --- 409,493 ---- } + + function get_code( $filepathname, $mode = 'INCLUDE') + { + global $phpbb_root_path, $phpEx; + + + $modulecode = file_get_contents( $filepathname); + + $FUNCTION_REPLACE = implode( '|', $this->FUNCTION_REPLACE_PHPBB3_ARRAY); + $preg_array = array( + '#^<\?(php)?|\?>$#si' => '', + '#\$config#si' => '$board_config', + '#\$(cache|user)([,;])#si' => '$mx_\1\2', + '#\$auth([,;])#si' => '$phpbb_auth\1', + '#\$cache-#si' => '$mx_cache-', + '#\$user-#si' => '$mx_user-', + '#\$auth-#si' => '$phpbb_auth-', + '#append_sid\(#si' => 'mx3_append_sid(', + '#add_log\(#si' => 'mx_add_log(', + '#get_username_string\(#si' => 'mx_get_username_string(', + '#\s(global)#si' => '\1 $mx_acp,', + //'#\$template-#si' => '$mx_acp->template-', + '#trigger_error\(([^,)]*)([,\)])#si' => '$mx_acp->mx_message_die_acp( GENERAL_MESSAGE, \1 \2 ', + '#\$mx_acp->template->assign_vars#si' => 'foreach( $mx_user->lang as $key => $value) + { + $mx_acp->template->assign_var( \'L_\' . $key, $value); + } + $mx_acp->template->assign_vars', + '#(' . $FUNCTION_REPLACE . ')\(#si' => 'phpBB3::\1(', + "#'(" . $FUNCTION_REPLACE . ")'#si" => "'phpBB3::\\1'" + ); + + + $modulecode = preg_replace( array_keys( $preg_array), $preg_array, $modulecode); + + $modulecode = str_replace('language_select', 'mx_language_select', $modulecode); + $modulecode = str_replace('$board_config_', '$config_', $modulecode); + $modulecode = str_replace('auth_admin', 'phpbb_auth_admin', $modulecode); + $modulecode = str_replace('include_once($phpbb_root_path . \'includes/acp/auth.\' . $phpEx);', 'mx_page::load_file(\'acp/auth\', \'phpbb3\');', $modulecode); + $modulecode = str_replace('function phpBB3::', 'function phpbb3_', $modulecode); + + $modulecode = preg_replace( '/function ([^(]*)?phpBB3::([^(]*)\(/si', 'function \1\2(', $modulecode); + $modulecode = str_replace('$this->phpBB3::', '$this->', $modulecode); + $includes_cnt = preg_match_all( '#(include|require)(_once)?\(([^)]*)\);#si', $modulecode, $includes_match); + $modulecode = preg_replace( '#(include|require)(_once)?\(([^)]*)\);#si', '// MXP INCLUDE CODE \0', $modulecode); + + + $cache_file_name = str_replace( '.'. $phpEx, '', $filepathname); + $cache_file_name = substr( $cache_file_name, strrpos( $cache_file_name, '/')+1); + $cache_file_name = cache_file( $modulecode, $mode, $cache_file_name); + + for ( $i = 0; $i < $includes_cnt; $i++) + { + eval( '$include = ' . $includes_match[3][$i] . ';'); + if ( in_array( $include, $this->includes)) + { + continue; + } + if ( eregi( "{$this->no_include}\.{$phpEx}", $include)) + { + continue; + } + + $filename = str_replace( '.'. $phpEx, '', $include); + $filename = substr( $filename, strrpos( $filename, '/')+1); + $filename = cache_filename( 'INCLUDE', $filename); + + if ( file_exists( $filename)) + { + $this->includes[$include] = $filename; + } + else + { + $this->includes[$include] = $this->get_code( $include, 'INCLUDE'); + } + + } + + return $cache_file_name; + } + /** * Loads currently active module *************** *** 431,476 **** //include("$module_path/{$this->p_class}_$this->p_name.$phpEx"); - $modulecode = file_get_contents("$module_path/{$this->p_class}_$this->p_name.$phpEx"); - - $FUNCTION_REPLACE = implode( '|', $this->FUNCTION_REPLACE_PHPBB3_ARRAY); - $preg_array = array( - '#^<\?(php)?|\?>$#si' => '', - '#\$config#si' => '$board_config', - '#\$(cache|user)([,;])#si' => '$mx_\1\2', - '#\$auth([,;])#si' => '$phpbb_auth\1', - '#\$cache-#si' => '$mx_cache-', - '#\$user-#si' => '$mx_user-', - '#\$auth-#si' => '$phpbb_auth-', - '#append_sid\(#si' => 'mx3_append_sid(', - '#add_log\(#si' => 'mx_add_log(', - '#get_username_string\(#si' => 'mx_get_username_string(', - '#global#si' => 'global $mx_acp,', - //'#\$template-#si' => '$mx_acp->template-', - '#trigger_error\(([^,)]*)([,\)])#si' => '$mx_acp->mx_message_die_acp( GENERAL_MESSAGE, \1 \2 ', - '#\$mx_acp->template->assign_vars#si' => 'foreach( $mx_user->lang as $key => $value) - { - $mx_acp->template->assign_var( \'L_\' . $key, $value); - } - $mx_acp->template->assign_vars', - '#(' . $FUNCTION_REPLACE . ')\(#si' => 'phpBB3::\1(', - "#'(" . $FUNCTION_REPLACE . ")'#si" => "'phpBB3::\\1'" - ); ! ! $modulecode = preg_replace( array_keys( $preg_array), $preg_array, $modulecode); ! ! $modulecode = str_replace('language_select', 'mx_language_select', $modulecode); ! $modulecode = str_replace('$board_config_', '$config_', $modulecode); ! $modulecode = str_replace('auth_admin', 'phpbb_auth_admin', $modulecode); ! $modulecode = str_replace('include_once($phpbb_root_path . \'includes/acp/auth.\' . $phpEx);', 'mx_page::load_file(\'acp/auth\', \'phpbb3\');', $modulecode); ! ! if ( 0 ) { ! print '<pre style="font:10pt normal;font-family:Courier New">' .preg_replace( array("#\n#esi", "#\t#si"), array("'\n' . sprintf('%4d ', \$i++)", ' '), htmlentities( $modulecode ) ); ! die(); } ! ! // Do eval() ! eval($modulecode); if (!class_exists("{$this->p_class}_$this->p_name")) --- 515,535 ---- //include("$module_path/{$this->p_class}_$this->p_name.$phpEx"); ! $cache_file_name = $this->get_code("$module_path/{$this->p_class}_$this->p_name.$phpEx", 'MODULE'); ! // Do eval() ! //eval($modulecode); ! if ( count( $this->includes) != 0) { ! foreach( $this->includes as $key => $value) ! { ! include_once( $value); ! } } ! ! //print '<pre>'; ! //print_r( $this->includes); ! //die(); ! ! include_once( $cache_file_name); if (!class_exists("{$this->p_class}_$this->p_name")) |