diff --git a/asy_jpcache.plugin.php b/asy_jpcache.plugin.php
new file mode 100644
index 0000000..6aa3412
--- /dev/null
+++ b/asy_jpcache.plugin.php
@@ -0,0 +1,219 @@
+";
+ printf("Deleted %s files. Cache is clean.",''.asy_flushdir(true));
+ echo "";
+ }
+ } else {
+ pagetop("JPCache Cleaner");
+ }
+ echo "
";
+ echo form(
+ tag("JPCache-Cleaner", "h3").
+ graf("Usually you don't need to do that. Cache is automatically cleared
1)
+ after a certain amount of time
2) when a comment is posted, edited or moderated
+
3) after a page-template or form-tag is is modified.
".
+ fInput("hidden", "asy_token", md5($lastmod)).
+ fInput("submit", "clean_cache", "Clean all cached Files", "smallerbox").
+ eInput("asy_jpcache").sInput("clean")
+ ," style=\"text-align:center\"")
+ );
+ echo tag("Cache Statistics","h3");
+ global $path_to_site;$count = array('size'=>0, 'num'=>0);
+ $asy_cache_dir = $path_to_site .'/jpcache/cache';
+ if (!empty($asy_cache_dir) and $fp = opendir($asy_cache_dir)) {
+ while (false !== ($file = readdir($fp))) {
+ if ($file{0} != ".") {
+ $count['size'] += filesize("$asy_cache_dir/$file");
+ ++$count['num'];
+ }
+ }
+ closedir($fp);
+ printf("There are %d cache files with a total size of %d kb.", $count['num'], floor($count['size']/1000));
+ } else { echo "Cache is empty.";}
+ include $path_to_site .'/jpcache/jpcache-config.php';
+/* if (@$JPCACHE_TXPLOG_DO == 1 && $prefs['logging']=='all'){
+ echo tag("Read-Write-Ratio1","h3");;
+ $cachehits = safe_field('COUNT( id ) as hit', 'txp_log', "page LIKE '%#cachehit'");
+ $totalhits = getThing("SELECT MIN(time) FROM ".PFX."txp_log WHERE page LIKE '%#cachehit'");
+ $totalhits = getThing("SELECT COUNT(id) FROM ".PFX."txp_log WHERE time > '". $totalhits."'");
+ printf("There were %d cache-reads recorded and %d possible cache-writes.
Average number of reads per write: %01.2f",$cachehits, $totalhits-$cachehits, (($totalhits-$cachehits) > 0) ? ($cachehits/($totalhits-$cachehits)) : '0');
+ echo "
1This is a (low) Approximation. Initially wait a week before numbers become meaningful.";
+ }
+*/ echo "
";
+ }
+
+ // This function clears the Cache directory. Make sure jpcache is installed in the right directory.
+ function asy_flushdir($force_clean = false) {
+ global $path_to_site, $lastmod;
+
+ $count = 0;
+ $asy_cache_dir = $path_to_site .'/jpcache/cache';
+
+ if (!empty($asy_cache_dir) and $fp = opendir($asy_cache_dir)) {
+ $last = strtotime($lastmod);
+ while (false !== ($file = readdir($fp))) {
+ if ($file{0} != "." AND
+ ((filemtime("$asy_cache_dir/$file") < $last) OR $force_clean)){
+ @unlink("$asy_cache_dir/$file");
+ ++$count;
+ }
+ }
+
+ closedir($fp);
+ }
+
+ return $count;
+ }
+
+
+# --- END PLUGIN CODE ---
+if (0) {
+?>
+
+