Template cache introduced to shortcut expensive compileCode() calls:
authorRoland Häder <roland@mxchange.org>
Wed, 4 Nov 2009 06:07:37 +0000 (06:07 +0000)
committerRoland Häder <roland@mxchange.org>
Wed, 4 Nov 2009 06:07:37 +0000 (06:07 +0000)
- New template caching added which requires you to delete
  inc/cache/templates/foo.tpl.cache if you have edited foo.tpl
- TODOs.txt updated (again some more internal TODOs are closed, some are added)
- getDateTime() call removed from loadTemplate() to speed it up
- Other minor fixes

12 files changed:
.gitattributes
.gitignore
DOCS/TODOs.txt
inc/cache/templates/.htaccess [new file with mode: 0644]
inc/db/lib-mysql3.php
inc/extensions-functions.php
inc/filter-functions.php
inc/filters.php
inc/functions.php
inc/modules/index.php
inc/modules/login.php
modules.php

index 964cd0c..8891988 100644 (file)
@@ -95,6 +95,7 @@ inc/autopurge/purge-mails.php -text
 inc/autopurge/purge-tsks.php -text
 inc/autopurge/purge-unconfirmed.php -text
 inc/cache/.htaccess -text
+inc/cache/templates/.htaccess -text
 inc/classes/.htaccess -text
 inc/classes/cachesystem.class.php -text
 inc/classes/rdf.class.php -text
index 9cdc52a..36fda3f 100644 (file)
@@ -12,3 +12,4 @@ inc/cache/.revision
 inc/cache/config-local.php
 inc/cache/debug.log
 inc/cache/sess_*
+inc/cache/templates/*.cache
index f783ca2..fad06a6 100644 (file)
@@ -1,12 +1,11 @@
 ### WARNING: THIS FILE IS AUTO-GENERATED BY ./DOCS/todo-builder.sh (uid=1000/user=quix0r) ###
 ### DO NOT EDIT THIS FILE. ###
-./beg.php:191:                 // @TODO Opps, what is missing here???
+./beg.php:172:                 // @TODO Opps, what is missing here???
 ./birthday_confirm.php:93:             // @TODO Try to rewrite the following unset()
 ./inc/cache/config-local.php:122:// @TODO Rewrite the following three constants, somehow...
 ./inc/classes/cachesystem.class.php:464:       // @TODO Add support for more types which break in last else-block
 ./inc/config-functions.php:143:        // @TODO Make this all better... :-/
-./inc/config-functions.php:318:                // @TODO Find a way for updating configuration here
-./inc/extensions/ext-html_mail.php:140:                // @TODO Move these arrays into config
+./inc/extensions/ext-html_mail.php:137:                // @TODO Move these arrays into config
 ./inc/extensions/ext-network.php:71:           // @TODO network_type_name is an internal name and needs documentation
 ./inc/extensions/ext-newsletter.php:215:               // @TODO Move these into configuration
 ./inc/extensions/ext-rallye.php:329:           // @TODO Move this code into rallye_functions.php
 ./inc/extensions/ext-sql_patches.php:94:               /* @TODO SQL_ALTER_TABLE() should work now properly
 ./inc/extensions/ext-yoomedia.php:122:         // @TODO Can this be moved into a database table?
 ./inc/extensions/ext-yoomedia.php:55:// @TODO Only deprecated when 'network' is ready! setExtensionDeprecated('Y');
-./inc/extensions-functions.php:373:// @TODO Change from ext_id to ext_name (not just even the variable! ;-) )
-./inc/extensions-functions.php:484:            // @TODO Extension is loaded, what next?
-./inc/functions.php:1350:      // @TODO Remove this if() block if all is working fine
+./inc/extensions-functions.php:376:// @TODO Change from ext_id to ext_name (not just even the variable! ;-) )
+./inc/extensions-functions.php:489:            // @TODO Extension is loaded, what next?
+./inc/functions.php:1308:      // @TODO Remove this if() block if all is working fine
 ./inc/functions.php:222:       // @TODO Remove this sanity-check if all is fine
 ./inc/functions.php:225:       // @TODO Try to rewrite all $DATA to $content
-./inc/functions.php:2370:// @TODO Try to move this to inc/libs/theme_functions.php
-./inc/functions.php:2409:      // @TODO The status should never be empty
-./inc/functions.php:2541:// @TODO Please describe this function
-./inc/functions.php:2559:      searchDirsRecursive($next_dir, $last_changed); // @TODO small change to API to $last_changed = searchDirsRecursive($next_dir, $time);
-./inc/functions.php:264:                               // @TODO Find all templates which are using these direct variables and rewrite them.
-./inc/functions.php:2655:              // @TODO Add a little more infos here
-./inc/functions.php:265:                               // @TODO After this step is done, this else-block is history
-./inc/functions.php:2666:      // @TODO This cannot be rewritten to app_die(), try to find a solution for this.
-./inc/functions.php:2748:                      // @TODO Rewrite this old lost code to a template
-./inc/functions.php:2867:                      // @TODO Are these convertions still required?
-./inc/functions.php:2885:// @TODO Rewrite this function to use readFromFile() and writeToFile()
-./inc/functions.php:580:               // @TODO Extension 'msg' does not exist
-./inc/functions.php:657:// @TODO Rewrite this to an extension 'smtp'
+./inc/functions.php:2328:// @TODO Try to move this to inc/libs/theme_functions.php
+./inc/functions.php:2499:// @TODO Please describe this function
+./inc/functions.php:2517:      searchDirsRecursive($next_dir, $last_changed); // @TODO small change to API to $last_changed = searchDirsRecursive($next_dir, $time);
+./inc/functions.php:2613:              // @TODO Add a little more infos here
+./inc/functions.php:2624:      // @TODO This cannot be rewritten to app_die(), try to find a solution for this.
+./inc/functions.php:2706:                      // @TODO Rewrite this old lost code to a template
+./inc/functions.php:2825:                      // @TODO Are these convertions still required?
+./inc/functions.php:2843:// @TODO Rewrite this function to use readFromFile() and writeToFile()
+./inc/functions.php:546:               // @TODO Extension 'msg' does not exist
+./inc/functions.php:615:// @TODO Rewrite this to an extension 'smtp'
 ./inc/install-functions.php:62:        // @TODO DEACTIVATED: changeDataInFile(getConfig('CACHE_PATH') . 'config-local.php', 'OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestElement('omode'), 0);
 ./inc/language/de.php:1140:// @TODO Rewrite these two constants
 ./inc/language/de.php:1156:// @TODO Rewrite these five constants
@@ -55,9 +51,9 @@
 ./inc/libs/task_functions.php:52:// @TODO Move all extension-dependent queries into filters
 ./inc/libs/theme_functions.php:218:// @TODO Move this code block into a filter and register it with 'init'
 ./inc/libs/user_functions.php:137:     // @TODO These two constants are no longer used, maybe we reactivate this code?
-./inc/libs/user_functions.php:317:                     // @TODO Make this filter working: $ADDON = runFilterChain('post_login_update', $content);
-./inc/libs/user_functions.php:342:                     // @TODO Make this filter working: $URL = runFilterChain('do_login', array('content' => $content, 'addon' => $ADDON));
-./inc/libs/user_functions.php:383:             // @TODO Can this query be merged with above query?
+./inc/libs/user_functions.php:313:                     // @TODO Make this filter working: $ADDON = runFilterChain('post_login_update', $content);
+./inc/libs/user_functions.php:336:                     // @TODO Make this filter working: $URL = runFilterChain('do_login', array('content' => $content, 'addon' => $ADDON));
+./inc/libs/user_functions.php:409:     // @TODO We should try to rewrite this to fetchUserData() somehow
 ./inc/libs/yoomedia_functions.php:64:  $response = YOOMEDIA_QUERY_API('out_textmail.php', true); // @TODO Ask Yoo!Media for test script
 ./inc/load_config.php:76:      // @TODO Rewrite them to avoid this else block
 ./inc/loader/load_cache-extension.php:13: * @TODO Rewrite this whole file to load_cache-extensions.php           *
 ./inc/modules/admin/admin-inc.php:514:// @TODO Try to rewrite this to adminAddMenuSelectionBox()
 ./inc/modules/admin/admin-inc.php:527:         // @TODO Try to rewrite this to $content = SQL_FETCHARRAY(). Please look some lines above for the dynamic query
 ./inc/modules/admin/overview-inc.php:160:                              // @TODO Rewrite this to a filter
-./inc/modules/admin/overview-inc.php:170:                                      // @TODO Can this SQL be encapsulated in a function, so all similar queries can be rewritten?
-./inc/modules/admin/overview-inc.php:281:                              // @TODO Rewrite this to something with include files
-./inc/modules/admin/overview-inc.php:319:                                              // @TODO This may also be rewritten to include files
-./inc/modules/admin/overview-inc.php:321:                                                      default: // @TODO Unknown support mode
-./inc/modules/admin/overview-inc.php:440:                      // @TODO Try to move this in includes
+./inc/modules/admin/overview-inc.php:274:                              // @TODO Rewrite this to something with include files
+./inc/modules/admin/overview-inc.php:312:                                              // @TODO This may also be rewritten to include files
+./inc/modules/admin/overview-inc.php:314:                                                      default: // @TODO Unknown support mode
+./inc/modules/admin/overview-inc.php:433:                      // @TODO Try to move this in includes
 ./inc/modules/admin/overview-inc.php:44:// @TODO This function does also check for uncompleted tasks
 ./inc/modules/admin.php:94:                                    // @TODO Why is this set to 'done'?
 ./inc/modules/admin/what-add_guestnl_cat.php:48:       // @TODO Check if category does already exist
 ./inc/modules/admin/what-list_autopurge.php:84:                // @TODO Rewritings: surname->surname,family->family in templates
 ./inc/modules/admin/what-list_beg.php:85:                      // @TODO Rewrite templates so s/family will be replaced by surname/family
 ./inc/modules/admin/what-list_beg.php:86:                      // @TODO to shorten this block. Please also do so with userid->userid
-./inc/modules/admin/what-list_cats.php:57:             // @TODO No longer needed? define('__CATS_BASE'   , "<a href=\"{?URL?}/modules.php?module=admin&amp;userid=");
-./inc/modules/admin/what-list_links.php:104:                                   // @TODO Rewrite this to includes/filter
-./inc/modules/admin/what-list_links.php:95:                            // @TODO Find a way to rewrite this. See some lines above for different queries
+./inc/modules/admin/what-list_cats.php:55:             // @TODO No longer needed? define('__CATS_BASE'   , "<a href=\"{?URL?}/modules.php?module=admin&amp;userid=");
+./inc/modules/admin/what-list_links.php:56:            // @TODO Try to rewrite this to a filter
+./inc/modules/admin/what-list_links.php:88:                            // @TODO Find a way to rewrite this. See some lines above for different queries
+./inc/modules/admin/what-list_links.php:97:                                    // @TODO Rewrite this to includes/filter
 ./inc/modules/admin/what-list_payouts.php:118:                                         // @TODO Do we need this time-consuming eval() here?
 ./inc/modules/admin/what-list_rallyes.php:250:                 // @TODO Rewritings: userid->userid,opoints->curr_points,old->refs in template
 ./inc/modules/admin/what-list_rallyes.php:303:                 // @TODO Rewritings: admin_id->admin_id in template
 ./inc/modules/admin/what-list_user.php:286:            // @TODO Rewrite this into a  filter
 ./inc/modules/admin/what-list_user.php:340:                    // @TODO Rewrite this into a filter
 ./inc/modules/admin/what-list_user.php:58:// @TODO Rewrite these if-blocks in a filter
-./inc/modules/admin/what-lock_user.php:138:                            // @TODO Rewrite these all constants
 ./inc/modules/admin/what-logs.php:68:                  // @TODO Fix content-type here
 ./inc/modules/admin/what-logs.php:71:                  // @TODO Fix content-type here
 ./inc/modules/admin/what-mem_add.php:125:                              // @TODO This can be somehow rewritten to a function
 ./inc/modules/admin/what-usage.php:87: // @TODO This code is double, see LOAD_TEMPLATE and loadEmailTemplate in functions.php
 ./inc/modules/admin/what-usage.php:98: // @TODO Disabled due to too much trouble
 ./inc/modules/admin/what-usr_online.php:50:    // @TODO Add a filter for sponsor
-./inc/modules/chk_login.php:52:                // @TODO Rewrite this into a filter
 ./inc/modules/guest/what-beg.php:59:// @TODO No more needed? define('__BEG_UID_TIMEOUT', createFancyTime(getConfig('beg_userid_timeout')));
-./inc/modules/guest/what-confirm.php:102:                                      // @TODO Try to rewrite the following unset()
+./inc/modules/guest/what-confirm.php:112:                                      // @TODO Try to rewrite the following unset()
 ./inc/modules/guest/what-login.php:107:        // @TODO Move this HTML code into a template
 ./inc/modules/guest/what-mediadata.php:182:// @TODO Rewrite all these if-blocks to filters
 ./inc/modules/guest/what-mediadata.php:69:     // @TODO Find a better formular than this one
 ./inc/modules/guest/what-rallyes.php:90:       // @TODO Reactivate this: $content['admin'] = "<a href=\"{?URL?}/modules.php?module=index&amp;what=impressum&amp;admin=".$adminId."\">".$login."</a>";
-./inc/modules/guest/what-register.php:198:     // @TODO Rewrite these all to a single filter
-./inc/modules/guest/what-register.php:276:     // @TODO Rewrite this to a filter
-./inc/modules/guest/what-register.php:292:             // @TODO Rewrite this to addPointsDirectly()
+./inc/modules/guest/what-register.php:193:     // @TODO Rewrite these all to a single filter
+./inc/modules/guest/what-register.php:271:     // @TODO Rewrite this to a filter
+./inc/modules/guest/what-register.php:287:             // @TODO Rewrite this to addPointsDirectly()
 ./inc/modules/guest/what-sponsor_infos.php:69:         // @TODO Rewritings: conv->conv_rate,name->conv_name in template
 ./inc/modules/guest/what-sponsor_infos.php:89:                 // @TODO Rewritings: name->pay_name,min->pay_min_count,min->pay_min_count,curr->pay_currency
 ./inc/modules/guest/what-sponsor_reg.php:286:          // @TODO Swap this HTML code to templates
 ./inc/modules/member/what-payout.php:241:                                      // @TODO Rewrite this to a filter
 ./inc/modules/member/what-points.php:54:// @TODO Should we rewrite this to a filter?
 ./inc/modules/member/what-rallyes.php:89:      // @TODO Reactivate this: $content['admin'] = "<a href=\"{?URL?}/modules.php?module=index&amp;what=impressum&amp;admin=".$content['admin_id']."\">".$content['login']."</a>";
-./inc/modules/member/what-reflinks.php:62:// @TODO Move this into a filter
+./inc/modules/member/what-reflinks.php:59:// @TODO Move this into a filter
 ./inc/modules/member/what-stats.php:118:               // @TODO Rewrite in template: clix->clicks
-./inc/modules/member/what-transfer.php:101:                    // @TODO Rewrite this to a filter
-./inc/modules/member/what-transfer.php:143:                            // @TODO Rewrite this to a filter
-./inc/modules/member/what-transfer.php:233:                            // @TODO Try to rewrite his to $content = SQL_FETCHARRAY(), see some lines above for two different queries
-./inc/modules/member/what-transfer.php:318:                    // @TODO This should be somehow rewritten to $row = SQL_FETCHARRAY(), see switch() block above for SQL queries
-./inc/modules/member/what-transfer.php:324:                            // @TODO Rewrite: tid->trans_id,stamp->time_trans
+./inc/modules/member/what-transfer.php:141:                            // @TODO Rewrite this to a filter
+./inc/modules/member/what-transfer.php:231:                            // @TODO Try to rewrite his to $content = SQL_FETCHARRAY(), see some lines above for two different queries
+./inc/modules/member/what-transfer.php:316:                    // @TODO This should be somehow rewritten to $row = SQL_FETCHARRAY(), see switch() block above for SQL queries
+./inc/modules/member/what-transfer.php:322:                            // @TODO Rewrite: tid->trans_id,stamp->time_trans
+./inc/modules/member/what-transfer.php:99:                     // @TODO Rewrite this to a filter
 ./inc/modules/member/what-unconfirmed.php:144: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY()
 ./inc/modules/order.php:75:            // @TODO Unused: 2,4
 ./inc/monthly/monthly_bonus.php:68:    // @TODO Rewrite this to a filter
-./inc/mysql-manager.php:1598:                  // @TODO Try to rewrite this to $content = SQL_FETCHARRAY()
-./inc/mysql-manager.php:1819:                  // @TODO Rewrite this to $content = SQL_FETCHARRAY()
-./inc/mysql-manager.php:2139:          // @TODO This can be somehow rewritten
+./inc/mysql-manager.php:1655:                  // @TODO Try to rewrite this to $content = SQL_FETCHARRAY()
+./inc/mysql-manager.php:1876:                  // @TODO Rewrite this to $content = SQL_FETCHARRAY()
+./inc/mysql-manager.php:2196:          // @TODO This can be somehow rewritten
 ./inc/mysql-manager.php:220:                   // @TODO Nothing helped???
 ./inc/mysql-manager.php:255:                   // @TODO Rewrite this to a filter
 ./inc/mysql-manager.php:576:   // @TODO Try to rewrite this to one or more functions
-./inc/mysql-manager.php:605:                           // @TODO Try to rewrite this to one or more functions
+./inc/mysql-manager.php:891:// @TODO Lame description for this function
 ./inc/mysql-manager.php:93:// @TODO Can we cache this?
 ./inc/reset/reset_birthday.php:92:                     // @TODO 4 is hard-coded here, should we move it out in config?
 ./inc/wrapper-functions.php:127:// @TODO Implement $compress
 ./inc/wrapper-functions.php:134:// @TODO Implement $decompress
 ./inc/wrapper-functions.php:402:// @TODO Do some more sanity check here
-./mailid.php:134:                                      // @TODO Rewrite this to a filter
-./mailid.php:214:      // @TODO Rewrite this to a dynamic include or so
+./mailid.php:131:                                      // @TODO Rewrite this to a filter
+./mailid.php:211:      // @TODO Rewrite this to a dynamic include or so
 ./mailid.php:94:               // @TODO Rewrite this to a filter
-./mailid_top.php:142:                                  // @TODO Rewrite this to a filter
-./mailid_top.php:189:                                                  // @TODO Rewrite this to a filter
-./mailid_top.php:196:                                                                  // @TODO Rewrite this to a filter
-./mailid_top.php:232:                                                                  // @TODO Rewrite these blocks to filter
-./mailid_top.php:267:                                                                          // @TODO Try to rewrite the following unset()
+./mailid_top.php:135:                                  // @TODO Rewrite this to a filter
+./mailid_top.php:182:                                                  // @TODO Rewrite this to a filter
+./mailid_top.php:189:                                                                  // @TODO Rewrite this to a filter
+./mailid_top.php:225:                                                                  // @TODO Rewrite these blocks to filter
+./mailid_top.php:260:                                                                          // @TODO Try to rewrite the following unset()
 ./mailid_top.php:99:           // @TODO Rewrite this to a filter
 ./view.php:72:         // @TODO No banner found, output some default banner
 ### ### DEPRECATION FOLLOWS: ### ###
-./inc/functions.php:249:               // @DEPRECATED Try to rewrite the if() condition
-./inc/functions.php:263:                               // @DEPRECATED
 ./inc/modules/admin/admin-inc.php:515:// @DEPRECATED
+./templates/de/emails/admins_mail_contct_admin.tpl:1:@DEPRECATED
+./templates/de/emails/admins_msg_contct_admin.tpl:1:@DEPRECATED
 ### ### template-warnings.log follows: ### ###
 Warning: DOMDocument::loadHTMLFile(): Unexpected end tag : td in templates/de/html/menu/menu_what_end.tpl, line: 1 in 
 Warning: DOMDocument::loadHTMLFile(): Unexpected end tag : tr in templates/de/html/menu/menu_what_end.tpl, line: 2 in 
@@ -211,6 +205,7 @@ Warning: Not parsing JavaScript templates/de/html/js/js_surfbar_member_edit.tpl.
 Warning: Not parsing JavaScript templates/de/html/js/js_surfbar_stopped.tpl.
 Warning: Not parsing JavaScript templates/de/html/js/js_order_send.tpl.
 Warning: Not parsing JavaScript templates/de/html/js/js_uberwach.tpl.
+Warning: Not parsing JavaScript templates/de/html/js/js_jquery.tpl.
 Warning: Not parsing JavaScript templates/de/html/js/js_surfbar_member_book.tpl.
 Warning: DOMDocument::loadHTMLFile(): Unexpected end tag : table in templates/de/html/admin/admin_overview_footer.tpl, line: 10 in 
 Warning: DOMDocument::loadHTMLFile(): Unexpected end tag : form in templates/de/html/admin/admin_overview_footer.tpl, line: 11 in 
diff --git a/inc/cache/templates/.htaccess b/inc/cache/templates/.htaccess
new file mode 100644 (file)
index 0000000..14249c5
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
\ No newline at end of file
index 61aaa98..625125b 100644 (file)
@@ -78,7 +78,7 @@ function SQL_QUERY ($sqlString, $F, $L) {
        $querytimeBefore = array_sum(explode(' ', microtime()));
 
        // Run SQL command
-       ///* DEBUG: */ print($sqlString . '<br />');
+       //* DEBUG: */ print('F=' . basename($F) . ',L=' . $L . 'sql=' . $sqlString . '<br />');
        $result = mysql_query($sqlString, SQL_GET_LINK())
                or addFatalMessage(__FUNCTION__, __LINE__, $F . ' (' . $L . '):' . mysql_error() . '<br />
 Query string:<br />
@@ -283,9 +283,9 @@ function SQL_QUERY_ESC ($qstring, $data, $F, $L, $run=true, $strip=true, $secure
 
        // Debugging
        //
-       ///* DEBUG: */ $fp = fopen(getConfig('CACHE_PATH') . 'escape_debug.log', 'a') or app_die(__FILE__, __LINE__, "Cannot write debug.log!");
-       ///* DEBUG: */ fwrite($fp, $F.'('.$L."): ".str_replace("\r", '', str_replace("\n", " ", $eval))."\n");
-       ///* DEBUG: */ fclose($fp);
+       //* DEBUG: */ $fp = fopen(getConfig('CACHE_PATH') . 'escape_debug.log', 'a') or app_die(__FILE__, __LINE__, "Cannot write debug.log!");
+       //* DEBUG: */ fwrite($fp, $F.'('.$L."): ".str_replace("\r", '', str_replace("\n", " ", $eval))."\n");
+       //* DEBUG: */ fclose($fp);
 
        if ($run === true) {
                // Run SQL query (default)
@@ -317,7 +317,7 @@ function SQL_ESCAPE ($str, $secureString=true, $strip=true) {
                        $ret = smartAddSlashes($str);
                } elseif (function_exists('mysql_real_escape_string')) {
                        // The new and improved version
-                       ///* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'str='.$str);
+                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'str='.$str);
                        $ret = mysql_real_escape_string($str, SQL_GET_LINK());
                } elseif (function_exists('mysql_escape_string')) {
                        // The obsolete function
index f89233a..f531cb4 100644 (file)
@@ -450,11 +450,10 @@ function isExtensionInstalled ($ext_name) {
                // Extensions are all inactive/not installed during installation
        } else {
                // Look in database
-               $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_name`='%s' LIMIT 1",
-                       array($ext_name), __FILE__, __LINE__);
+               $ext_id = getExtensionId($ext_name);
 
                // Do we have a record?
-               $isInstalled = (SQL_NUMROWS($result) == 1);
+               $isInstalled = ($ext_id > 0);
 
                // Is it installed, then cache the entry
                if ($isInstalled === true) {
@@ -462,9 +461,6 @@ function isExtensionInstalled ($ext_name) {
                        getExtensionId($ext_name, true);
                } // END - if
 
-               // Free result
-               SQL_FREERESULT($result);
-
                // Remember the status
                $GLOBALS['ext_is_installed'][$ext_name] = $isInstalled;
        }
@@ -795,11 +791,9 @@ function getExtensionId ($ext_name, $forceDb = false) {
 
                // Cache it
                $GLOBALS['cache_array']['extension']['ext_id'][$ext_name] = $ret;
-       }
-
-       if ($ret == 0) {
-               // We should fix these all!
-               debug_report_bug(__FUNCTION__ . ': Invalid extension name found. ext_name=' . $ext_name);
+       } else {
+               // Caching enabled but no cache found is bad
+               debug_report_bug(__FUNCTION__ . ': Cache not found but ext-cache is active. ext_name=' . $ext_name);
        } // END - if
 
        // Return value
index 819c891..e83211b 100644 (file)
@@ -158,6 +158,7 @@ ORDER BY
        // Register shutdown filters
        registerFilter('shutdown', 'FLUSH_FILTERS');
        registerFilter('shutdown', 'FLUSH_STATS');
+       registerFilter('shutdown', 'FLUSH_TEMPLATE_CACHE');
        registerFilter('shutdown', 'FLUSH_OUTPUT');
 
        // Compiling code
index 5f6b9ee..fab11f2 100644 (file)
@@ -832,5 +832,17 @@ function FILTER_DISPLAY_PARSING_TIME () {
        } // END - if
 }
 
+// Filter for flushing template cache
+function FILTER_FLUSH_TEMPLATE_CACHE () {
+       // Do we have cached eval() data?
+       if ((isset($GLOBALS['template_eval'])) && (count($GLOBALS['template_eval']) > 0)) {
+               // Now flush all
+               foreach ($GLOBALS['template_eval'] as $template=>$eval) {
+                       // Flush the cache (if not yet found)
+                       flushTemplateCache($template, $eval);
+               } // END - if
+       } // END - if
+}
+
 // [EOF]
 ?>
index 7b691f4..049a7cb 100644 (file)
@@ -226,7 +226,10 @@ function loadTemplate ($template, $return=false, $content=array()) {
        global $DATA;
 
        // Do we have cache?
-       if (!isset($GLOBALS['template_eval'][$template])) {
+       if (isTemplateCached($template)) {
+               // Evaluate the cache
+               eval(readTemplateCache($template));
+       } elseif (!isset($GLOBALS['template_eval'][$template])) {
                // Add more variables which you want to use in your template files
                $username = getUsername();
 
@@ -240,12 +243,6 @@ function loadTemplate ($template, $return=false, $content=array()) {
                $ret = '';
                if (empty($GLOBALS['refid'])) $GLOBALS['refid'] = 0;
 
-               // Generate date/time string
-               $date_time = generateDateTime(time(), 1);
-
-               // Is content an array
-               if (is_array($content)) $content['date_time'] = $date_time;
-
                // Base directory
                $basePath = sprintf("%stemplates/%s/html/", getConfig('PATH'), getLanguage());
                $mode = '';
@@ -3642,6 +3639,51 @@ function determinePageTitle () {
        return $pageTitle;
 }
 
+// Checks wethere there is a cache file there. This function is cached.
+function isTemplateCached ($template) {
+       // Do we have cached this result?
+       if (!isset($GLOBALS['template_cache'][$template])) {
+               // Generate FQFN
+               $FQFN = sprintf("%stemplates/%s.tpl.cache", getConfig('CACHE_PATH'), $template);
+
+               // Is it there?
+               $GLOBALS['template_cache'][$template] = isFileReadable($FQFN);
+       } // END - if
+
+       // Return it
+       return $GLOBALS['template_cache'][$template];
+}
+
+// Flushes non-flushed template cache to disk
+function flushTemplateCache ($template, $eval) {
+       // Is this cache flushed?
+       if (!isTemplateCached($template)) {
+               // Generate FQFN
+               $FQFN = sprintf("%stemplates/%s.tpl.cache", getConfig('CACHE_PATH'), $template);
+
+               // Replace username with a call
+               $eval = str_replace('$username', '".getUsername()."', $eval);
+
+               // And flush it
+               writeToFile($FQFN, $eval, true);
+       } // END - if
+}
+
+// Reads a template cache
+function readTemplateCache ($template) {
+       // Check it again
+       if (isTemplateCached($template)) {
+               // Generate FQFN
+               $FQFN = sprintf("%stemplates/%s.tpl.cache", getConfig('CACHE_PATH'), $template);
+
+               // And read from it
+               $GLOBALS['template_eval'][$template] = readFromFile($FQFN);
+       } // END - if
+
+       // And return it
+       return $GLOBALS['template_eval'][$template];
+}
+
 //////////////////////////////////////////////////
 // AUTOMATICALLY RE-GENERATED MISSING FUNCTIONS //
 //////////////////////////////////////////////////
index ab37b5b..0c3e257 100644 (file)
@@ -42,7 +42,7 @@ if (!defined('__SECURITY')) {
 } // END - if
 
 // Generate a tableset for the menu title and content
-loadTemplate('guest_header');
+loadTemplate('guest_header', false, array('date_time' => generateDateTime(time(), 1)));
 
 // Add code-message here
 handleCodeMessage();
index 9545e43..82ef10b 100644 (file)
@@ -49,7 +49,7 @@ if (!defined('__SECURITY')) {
 enableBlockMode(false);
 
 // Generate a tableset for the menu title and content
-loadTemplate('member_header');
+loadTemplate('member_header', false, array('date_time' => generateDateTime(time(), 1)));
 
 // Add code-message here
 handleCodeMessage();
index 4034fae..de90da0 100644 (file)
@@ -37,7 +37,7 @@
  ************************************************************************/
 
 // XDEBUG call
-//* DEBUG: */ xdebug_start_trace();
+/* DEBUG: */ xdebug_start_trace();
 
 // Load security stuff here
 require('inc/libs/security_functions.php');