Skip to content

Commit 15daac2

Browse files
committed
CSS cache remover
Clearing css cache fixed
1 parent 82ccd2e commit 15daac2

File tree

3 files changed

+91
-77
lines changed

3 files changed

+91
-77
lines changed

app/classes/ez_sql_core.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,8 +549,9 @@ function clean_cache($full=false) {
549549
}
550550
}
551551
/* Remove css cache */
552-
$csslist = glob($css_dir."{[^\.]}", GLOB_BRACE);
552+
$csslist = glob($css_dir."{*.css*}", GLOB_BRACE);
553553
if($csslist) {
554+
var_dump($csslist);
554555
foreach ($csslist as $filename) {
555556
if($filename){
556557
if(!is_dir($filename) && (( strpos($filename,'index.html') == false) || ( strpos($filename,'htaccess') == false) )) {

app/functions/functions.global.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ function percent($first, $num_total, $precision = 0)
362362
//limit a string
363363
function _cut($str, $nb = 10)
364364
{
365-
if(not_empty($str)){
365+
if (not_empty($str)) {
366366
if (strlen($str) > $nb) {
367367
if (extension_loaded('mbstring')) {
368368
mb_internal_encoding("UTF-8");
@@ -613,30 +613,32 @@ function site_copy()
613613
return apply_filters('tsitecopy', get_option('site-copyright'));
614614
}
615615

616-
function video_time($sec, $padHours = false) {
616+
function video_time($sec, $padHours = false)
617+
{
617618
$hms = "";
618619
// there are 3600 seconds in an hour, so if we
619620
// divide total seconds by 3600 and throw away
620621
// the remainder, we've got the number of hours
621622
$hours = intval(intval($sec) / 3600);
622623
if ($hours > 0):
623624
// add to $hms, with a leading 0 if asked for
624-
$hms .= ($padHours)? str_pad($hours, 2, "0", STR_PAD_LEFT). ':' : $hours. ':';
625+
$hms .= ($padHours) ? str_pad($hours, 2, "0", STR_PAD_LEFT) . ':' : $hours . ':';
625626
endif;
626627
// dividing the total seconds by 60 will give us
627628
// the number of minutes, but we're interested in
628629
// minutes past the hour: to get that, we need to
629630
// divide by 60 again and keep the remainder
630631
$minutes = intval(intval($sec / 60) % 60);
631632
// then add to $hms (with a leading 0 if needed)
632-
$hms .= str_pad($minutes, 2, "0", STR_PAD_LEFT). ':';
633+
$hms .= str_pad($minutes, 2, "0", STR_PAD_LEFT) . ':';
633634
// seconds are simple - just divide the total
634635
// seconds by 60 and keep the remainder
635636
$seconds = intval($sec % 60);
636637
// add to $hms, again with a leading 0 if needed
637638
$hms .= str_pad($seconds, 2, "0", STR_PAD_LEFT);
638639
return $hms;
639640
}
641+
640642
function sef_url()
641643
{
642644
$url = site_url();
@@ -714,10 +716,10 @@ function _count($table, $field = null, $sum = false)
714716
} else {
715717
$c = $db->get_row("SELECT count(*) as nr FROM " . DB_PREFIX . $table);
716718
}
717-
if($c && not_empty($c->nr)) {
718-
return number_format($c->nr, 0);
719+
if ($c && not_empty($c->nr)) {
720+
return number_format($c->nr, 0);
719721
} else {
720-
return 0;
722+
return 0;
721723
}
722724
}
723725

@@ -1085,7 +1087,7 @@ function remove_file($filename)
10851087
echo '<div class="msg-info">' . $filename . ' removed.</div>';
10861088
} else {
10871089
echo '<div class="msg-warning">' . $filename . ' was not removed. Check server permisions for "unlink" function.</div>';
1088-
};
1090+
}
10891091
}
10901092
}
10911093

@@ -1533,6 +1535,7 @@ function removeCommonWords($input)
15331535
}
15341536
return false;
15351537
}
1538+
15361539
function the_embed()
15371540
{
15381541
global $embedvideo;
@@ -1917,7 +1920,7 @@ function get_activity($done)
19171920
case 6:
19181921
$video = $cachedb->get_row("SELECT title,id from " . DB_PREFIX . "videos where id='" . intval($done->object) . "'");
19191922
if ($video) {
1920-
$did["what"] = _lang("commented on the video") . ' <a class="text-primary" href="' . video_url($video->id, $video->title) . '" title="' . _html($video->title) . '">' . _html(_cut($video->title, 268)) . '</a>';;
1923+
$did["what"] = _lang("commented on the video") . ' <a class="text-primary" href="' . video_url($video->id, $video->title) . '" title="' . _html($video->title) . '">' . _html(_cut($video->title, 268)) . '</a>';
19211924
}
19221925
break;
19231926
case 7:
@@ -1926,7 +1929,7 @@ function get_activity($done)
19261929
$vid = intval(str_replace('video_', '', $com->object_id));
19271930
$video = $db->get_row("SELECT title,id from " . DB_PREFIX . "videos where id='" . $vid . "'");
19281931
if ($video) {
1929-
$did["what"] = _lang("liked a comment on") . ' <a class="text-primary" href="' . video_url($video->id, $video->title) . '" title="' . _html($video->title) . '">' . _html(_cut($video->title, 268)) . '</a>';;
1932+
$did["what"] = _lang("liked a comment on") . ' <a class="text-primary" href="' . video_url($video->id, $video->title) . '" title="' . _html($video->title) . '">' . _html(_cut($video->title, 268)) . '</a>';
19301933
$did["content"] = '<div class="content-filled">' . $com->comment_text . '</div>';
19311934
}
19321935
}

moderator/clean-cache.php

Lines changed: 76 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,85 @@
11
<script>
2-
function minijJS() {
3-
$.ajax({
4-
url: '<?php echo admin_url(); ?>minijs.php',
5-
beforeSend: function( xhr ) {
6-
$('a#vv').text('Started in background...this may take a while');
7-
}
8-
})
9-
.done(function( data ) {
10-
//alert(data);
11-
if ( data == 'done' ) {
12-
$('a#vv').text('Done.');
13-
$('code#secod').remove();
14-
} else {
15-
$('a#vv').text('Failed! Try again.');
16-
$('a#vv').removeClass('btn-default').addClass('btn-outline btn-danger');
17-
$('code#secod').text(data).addClass('btn-outline btn-danger active');
18-
}
19-
});
20-
}
2+
function minijJS() {
3+
$.ajax({
4+
url: '<?php echo admin_url(); ?>minijs.php',
5+
beforeSend: function (xhr) {
6+
$('a#vv').text('Started in background...this may take a while');
7+
}
8+
})
9+
.done(function (data) {
10+
//alert(data);
11+
if (data == 'done') {
12+
$('a#vv').text('Done.');
13+
$('code#secod').remove();
14+
} else {
15+
$('a#vv').text('Failed! Try again.');
16+
$('a#vv').removeClass('btn-default').addClass('btn-outline btn-danger');
17+
$('code#secod').text(data).addClass('btn-outline btn-danger active');
18+
}
19+
});
20+
}
2121
</script>
2222
<div class="row">
23-
<div class="panel">
24-
<div class="panel-heading">
25-
<h3 class="panel-title">Clear static cache</h3>
26-
</div>
27-
<div class="panel-body">
28-
<p>This cleans cache and puts live some changes. Empties full cache, js + css cache and ezsql's cache.</p>
29-
<div>
30-
<a class="btn btn-raised btn-primary pull-right" href="<?php echo admin_url('clean-cache'); ?>&clearit=1">Clean cache</a>
31-
</div>
32-
<p><code>It's a good practice to clean cache from time to time!</code></p>
33-
</div>
34-
</div>
23+
<div class="panel">
24+
<div class="panel-heading">
25+
<h3 class="panel-title">Clear static cache</h3>
26+
</div>
27+
<div class="panel-body">
28+
<p>This cleans cache and puts live some changes. Empties full cache, js + css cache and ezsql's cache.</p>
29+
<div>
30+
<a class="btn btn-raised btn-primary pull-right"
31+
href="<?php echo admin_url('clean-cache'); ?>&clearit=1">Clean cache</a>
32+
</div>
33+
<p><code>It's a good practice to clean cache from time to time!</code></p>
34+
</div>
35+
</div>
3536
</div>
3637
<div class="row" style="padding:30px 0;">
37-
<div class="panel">
38-
<div class="panel-heading">
39-
<h3 class="panel-title">JS combined file</h3>
40-
</div>
41-
<div class="panel-body">
42-
<p>Once cache is cleared so is the file cache for minified javascripts.</p>
43-
<div>
44-
<a class="btn btn-raised btn-primary pull-right" id="vv" href="javascript:minijJS()">Rebuild Minified javascript</a>
45-
</div>
46-
<p><code id="secod">This process takes time and is server heavy but reduces by up to 20% the js file size.</code></p>
47-
<p><a class="btn btn-raised btn-default" href="<?php echo tpl();?>styles/minjs.php" target="_blank">SEE FILE</a> (Opens in a new tab) Use ctrl/command + shift + r to clear the browser's file cache</p>
48-
</div>
49-
</div>
38+
<div class="panel">
39+
<div class="panel-heading">
40+
<h3 class="panel-title">JS combined file</h3>
41+
</div>
42+
<div class="panel-body">
43+
<p>Once cache is cleared so is the file cache for minified javascripts.</p>
44+
<div>
45+
<a class="btn btn-raised btn-primary pull-right" id="vv" href="javascript:minijJS()">Rebuild Minified
46+
javascript</a>
47+
</div>
48+
<p><code id="secod">This process takes time and is server heavy but reduces by up to 20% the js file
49+
size.</code></p>
50+
<p><a class="btn btn-raised btn-default" href="<?php echo tpl(); ?>styles/minjs.php" target="_blank">SEE
51+
FILE</a> (Opens in a new tab) Use ctrl/command + shift + r to clear the browser's file cache</p>
52+
</div>
53+
</div>
5054
</div>
5155
<?php
52-
if(_get('clearit')) {
53-
$cInc = ABSPATH;
54-
if( !defined( 'vSTATIC_FOLD' ) )
55-
define('vSTATIC_FOLD', '/cache/html/');
56-
require_once( CNC.'/fullcache.php' );
57-
$debug1 =FullCache::ClearAll();
58-
foreach ($debug1 as $d1) {
59-
echo str_replace($cInc,'', $d1);
60-
}
61-
$debug = $db->clean_cache();
62-
foreach ($debug as $d) {
63-
echo str_replace($cInc,'', $d);
64-
}
65-
$debug2 = $db->clean_cache(true);
66-
foreach ($debug2 as $d2) {
67-
echo str_replace($cInc,'', $d2);;
68-
}
69-
$jdebug = jc_purge();
70-
foreach ($jdebug as $dj) {
71-
echo str_replace($cInc,'', $dj);
56+
if (_get('clearit')) {
57+
$cInc = ABSPATH;
58+
if (!defined('vSTATIC_FOLD'))
59+
define('vSTATIC_FOLD', '/cache/html/');
60+
require_once(CNC . '/fullcache.php');
61+
$debug1 = FullCache::ClearAll();
62+
foreach ($debug1 as $d1) {
63+
echo str_replace($cInc, '', $d1);
64+
}
65+
$debug = $db->clean_cache();
66+
foreach ($debug as $d) {
67+
if (not_empty($d)) {
68+
echo str_replace($cInc, '', $d);
69+
}
70+
}
71+
$debug2 = $db->clean_cache(true);
72+
foreach ($debug2 as $d2) {
73+
if (not_empty($d2)) {
74+
echo str_replace($cInc, '', $d2);
75+
}
76+
}
77+
$jdebug = jc_purge();
78+
foreach ($jdebug as $dj) {
79+
if (not_empty($dj)) {
80+
echo str_replace($cInc, '', $dj);
81+
}
82+
}
83+
echo '<div class="msg-win">Cache cleared</div>';
7284
}
73-
echo '<div class="msg-win">Cache cleared</div>';
74-
}
7585
?>

0 commit comments

Comments
 (0)