Skip to content

Commit

Permalink
Cache Control 1.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
Colinax committed Jul 3, 2021
1 parent 2d8b970 commit cf4c03f
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 20 deletions.
35 changes: 22 additions & 13 deletions wbce/modules/outputfilter_dashboard/plugins/cachecontrol/filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,44 @@
opf cache control is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with opf cache control. If not, see <http://www.gnu.org/licenses/>.
*/

if(!defined('WB_PATH')) die(header('Location: ../../index.php'));
if (!defined('WB_PATH')) {
die(header('Location: ../../index.php'));
}

function opff_cachecontrol(&$content, $page_id, $section_id, $module, $wb) {
function opff_cachecontrol(&$content, $page_id, $section_id, $module, $wb)
{
global $opf_HEADER, $opf_BODY; // PRIVATE - do not do this

$head = $body = '';
foreach($opf_HEADER as $str) $head .= $str;
foreach($opf_BODY as $str) $body .= $str;
foreach ($opf_HEADER as $str) {
$head .= $str;
}
foreach ($opf_BODY as $str) {
$body .= $str;
}

$regex = '(href|src)="([^"]+\.(css|js))"';
$extracts = opf_cut_extract($content, $regex, 2, 'i', '~');
$extracts = opf_cut_extract($head, $regex, 2, 'i', '~', $extracts);
$extracts = opf_cut_extract($body, $regex, 2, 'i', '~', $extracts);
foreach($extracts as $k=>$str) {
if(strpos($str, WB_PATH)===0)
$extracts = opf_cut_extract($head, $regex, 2, 'i', '~', $extracts);
$extracts = opf_cut_extract($body, $regex, 2, 'i', '~', $extracts);
foreach ($extracts as $k=>$str) {
if (strpos($str, WB_PATH)===0) {
$file = $str;
else
} else {
$file = str_replace(WB_URL, WB_PATH, $str);
if(strpos($file, WB_PATH)===0) {
if(is_numeric($t = @filemtime($file)))
}
if (strpos($file, WB_PATH)===0) {
if (file_exists($file) && is_numeric($t = @filemtime($file))) {
$extracts[$k] = $str.'?'.$t;
}
}
}
opf_glue_extract($body, $extracts);
Expand All @@ -52,5 +61,5 @@ function opff_cachecontrol(&$content, $page_id, $section_id, $module, $wb) {
$opf_HEADER = array($head);
$opf_BODY = array($body);

return(TRUE);
return(true);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php

@header('HTTP/1.1 301 Moved Permanently',TRUE,301);
exit(header('Location: ../index.php'));
@header('HTTP/1.1 301 Moved Permanently', true, 301);
exit(header('Location: ../index.php'));
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,16 @@
*/

if(!defined('WB_PATH')) die(header('Location: ../../index.php'));
if (!defined('WB_PATH')) {
die(header('Location: ../../index.php'));
}

/*
Header: Version-History
1.0.7 %(mrbaseman; 1 Jul, 2021)%
- check for file existence, first
1.0.6 %(mrbaseman; 15 Jul, 2019)%
- use by default in search results, too
- bugfix: correct the previous change
Expand All @@ -52,10 +57,9 @@

$plugin_directory = 'cachecontrol';
$plugin_name = 'Cache Control';
$plugin_version = '1.0.6';
$plugin_version = '1.0.7';
$plugin_status = 'beta';
$plugin_platform = '2.8';
$plugin_author = 'thorn, mrbaseman';
$plugin_license = 'GNU General Public License, Version 3 or later';
$plugin_description = 'Filter to automatically prevent browsers from delivering outdated files (css,js) from cache';

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
*/

if(!defined('WB_PATH')) die(header('Location: ../../index.php'));
if (!defined('WB_PATH')) {
die(header('Location: ../../index.php'));
}

opf_register_filter(array(
'name' => 'Cache Control',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
*/

if(!defined('WB_PATH')) die(header('Location: ../../index.php'));
if (!defined('WB_PATH')) {
die(header('Location: ../../index.php'));
}

// nothing to do, yet.

0 comments on commit cf4c03f

Please sign in to comment.