31 if (empty($get_vars[
'request'])) {
47 if (!$this->config->simplecache_enabled) {
59 if (isset($server_vars[
'HTTP_IF_NONE_MATCH']) && trim($server_vars[
'HTTP_IF_NONE_MATCH']) === $etag) {
60 header(
"HTTP/1.1 304 Not Modified");
64 $filename = $this->config->dataroot .
'views_simplecache/' . md5(
"$viewtype|$view");
80 if ($cache_timestamp ==
$ts) {
85 $dir_name = $this->config->dataroot .
'views_simplecache/';
86 if (!is_dir($dir_name)) {
87 mkdir($dir_name, 0700);
108 if (
false !== strpos($request_var,
'..')) {
112 if (preg_match(
'#[^a-zA-Z0-9/\.\-_]#', $request_var)) {
119 if (!preg_match(
'#^/?([0-9]+)/([^/]+)/(.+)$#', $request_var, $matches)) {
125 'viewtype' => $matches[2],
126 'view' => $matches[3],
136 if (!empty($this->config->dataroot) && isset($this->config->simplecache_enabled)) {
140 $dblink = mysql_connect($this->config->dbhost, $this->config->dbuser, $this->config->dbpass,
true);
142 $this->
send403(
'Cache error: unable to connect to database server');
145 if (!mysql_select_db($this->config->dbname, $dblink)) {
146 $this->
send403(
'Cache error: unable to connect to Elgg database');
149 $query =
"SELECT `name`, `value` FROM {$this->config->dbprefix}datalists 150 WHERE `name` IN ('dataroot', 'simplecache_enabled')";
152 $result = mysql_query($query, $dblink);
155 $this->config->{
$row->name} =
$row->value;
159 mysql_close($dblink);
161 if (!
$result || !isset($this->config->dataroot)) {
162 $this->
send403(
'Cache error: unable to get the data root');
173 header(
'Expires: ' . gmdate(
'D, d M Y H:i:s \G\M\T', strtotime(
"+6 months")),
true);
174 header(
"Pragma: public",
true);
175 header(
"Cache-Control: public",
true);
186 $segments = explode(
'/',
$view, 2);
187 switch ($segments[0]) {
189 header(
"Content-Type: text/css",
true);
192 header(
'Content-Type: text/javascript',
true);
209 $hook_params = array(
251 require_once dirname(dirname(dirname(__FILE__))) .
"/start.php";
260 protected function send403($msg =
'Cache error: bad request') {
261 header(
'HTTP/1.1 403 Forbidden');
elgg_get_config($name, $site_guid=0)
Get an Elgg configuration value.
loadEngine()
Load the complete Elgg engine.
send403($msg= 'Cache error:bad request')
Send an error message to requestor.
renderView($view, $viewtype)
Render a view for caching.
elgg_view_exists($view, $viewtype= '', $recurse=true)
Returns whether the specified view exists.
setupSimplecache()
Do a minimal engine load.
_elgg_get_view_filetype($view)
Returns the type of output expected from the view.
parseRequestVar($request_var)
Parse a request.
getProcessedView($view, $viewtype)
Get the contents of a view for caching.
elgg_set_viewtype($viewtype="")
Manually set the viewtype.
sendCacheHeaders($etag)
Send cache headers.
elgg_set_config($name, $value)
Set an Elgg configuration value.
_elgg_is_view_cacheable($view)
Check whether a view is registered as cacheable.
elgg echo
Translates a string.
elgg_trigger_plugin_hook($hook, $type, $params=null, $returnvalue=null)
Trigger a Plugin Hook and run all handler callbacks registered to that hook:type. ...
elgg_view($view, $vars=array(), $bypass=false, $ignored=false, $viewtype= '')
Return a parsed view.
handleRequest($get_vars, $server_vars)
Handle a request for a cached view.
$content
Set robots.txt action.
sendContentType($view)
Send content type.
clearfix elgg elgg elgg elgg page header
__construct($config)
Constructor.