Severity: Warning
Message: Undefined variable $page
Filename: front/Articles.php
Line Number: 91
Backtrace:
File: /opt/bitnami/projects/celticproductions.net/application/controllers/front/Articles.php
Line: 91
Function: _error_handler
File: /opt/bitnami/projects/celticproductions.net/index.php
Line: 315
Function: require_once
Severity: Warning
Message: Undefined variable $pages
Filename: front/Articles.php
Line Number: 110
Backtrace:
File: /opt/bitnami/projects/celticproductions.net/application/controllers/front/Articles.php
Line: 110
Function: _error_handler
File: /opt/bitnami/projects/celticproductions.net/index.php
Line: 315
Function: require_once
Severity: Warning
Message: Undefined variable $page
Filename: front/Articles.php
Line Number: 111
Backtrace:
File: /opt/bitnami/projects/celticproductions.net/application/controllers/front/Articles.php
Line: 111
Function: _error_handler
File: /opt/bitnami/projects/celticproductions.net/index.php
Line: 315
Function: require_once
Severity: Warning
Message: Undefined variable $category
Filename: front/Articles.php
Line Number: 113
Backtrace:
File: /opt/bitnami/projects/celticproductions.net/application/controllers/front/Articles.php
Line: 113
Function: _error_handler
File: /opt/bitnami/projects/celticproductions.net/index.php
Line: 315
Function: require_once
Severity: Warning
Message: Undefined variable $articles
Filename: front/Articles.php
Line Number: 114
Backtrace:
File: /opt/bitnami/projects/celticproductions.net/application/controllers/front/Articles.php
Line: 114
Function: _error_handler
File: /opt/bitnami/projects/celticproductions.net/index.php
Line: 315
Function: require_once
$content = ... and code that I work on almost always consists of a mixture of the following:
print statements
echo statements
$content = <<<CONTENT statements
<?=$myvar;?> statements
// Should we turn on caching, 1 = Yes, 0 = No
// Caching is good for production scripts but
// you might want to turn it off if you are
// still testing your script
$caching_enabled = 1;
// If caching is enabled, enter the cache block
// I highly recommend having whatever is in the
// if statement the same in both your header
// and footer file. If they are difference, there
// is of course a chance that the output buffer
// will start but not finish (blank pages anyone!)
if($caching_enabled)
{
// We generate the cache filename based on the
// requested URL. Assuming you aren't caching
// session specific pages or POST data, this is
// a great way to quickly tie a unique request
// to a unique cache file. To generate a unique
// fingerprint if you are using session or POST
// data, implode $_REQUEST / $_POST / $_SESSION
// and md5 the result
$filename = "%%-".md5($_SERVER['REQUEST_URI'])."-%%.html";
// Set the $cachefile variable to the full path
// to your cache directory, make sure it's writable!
$cachefile = "/my/cache/directory/".$filename;
// The next few lines are possibly the only lines
// that you will want to change, they determine when
// the cache is invalid. In this example we are using
// a flat 30 minutes but this definitely requires more
// discussion, see below...
$cachetime = 30 * 60;
// If our $cachefile exists and this particular page
// has been cached with the last half an hour, the
// cache is valid and we should use it.
if (file_exists($cachefile) &&
time() - $cachetime < filemtime($cachefile))
{
// Simply include the $cachefile here and kill
// the script. Wow, that page loaded quickly!
include($cachefile);
exit;
}
// This is important; this is effectively an else
// statement here, i.e. if the cache wasn't valid
// we should start the output buffer here to collect
// the 'cacheable' contents of the page
ob_start();
}
?>
if($caching_enabled)
{
// $cachefile has already been set so just
// open a write handle to it and throw out
// the contents of the output buffer into it
$fp = fopen($cachefile, 'w+');
fwrite($fp, ob_get_contents());
// Close up the cache file and flush/echo/print
// the contents of the output buffer to the client
// If you don't flush the contents the generated
// page will be empty!
fclose($fp);
ob_end_flush();
}
include_once("cache_header.php");
?>
Cacheable page content consisting of print statements, echo statements, =$myvar;?> statements and even the much coveted <<include_once("cache_footer.php");
?>
md5_page_identifier and is_dirty. The md5 page identifier could hold the md5'd version of the requested URL while is_dirty is an indication of whether the page potentially needs to be re-cached. You could then set the "is dirty" flag to '1' each time page dependent data is updated (using either database triggers or programmatic triggers in your CMS). You can then display the cached page if is_dirty is set to '0' and re-cache the page if it is set to '1'. Just remember that if you re-cache the page, you should set is_dirty to '0' to ensure that subsequent calls use the cached version of the page.