sffullpagecache - Version 1.0.0

Version Notes

It will make sure the extension work ok , you must read the document ,beafore you use the extension .

Download this release

Release Info

Developer evan wang
Extension sffullpagecache
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/SF/Fullpagecache/Block/form.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div>
2
+ <p style="text-align:center;"><b>clean cache page</b></p>
3
+ <div style="border:1px dashed #000 ; padding:10px; ">
4
+ <form id="form1" name="form1" method="post" action="<?php echo $url_this ?>">
5
+ <p><label>user <input type="text" name="fpcuser" id="user" /></label></p>
6
+ <p>
7
+ <label>all
8
+ <input type="radio" name="fpcclean" id="all" value="all" />
9
+ </label>
10
+ <label>batch
11
+ <input type="radio" name="fpcclean" id="one" value="batch" />
12
+ </label>
13
+ </p>
14
+ <p>
15
+ <p>urls</p>
16
+ <label>
17
+ <textarea name="fpcurls" id="urls" cols="45" rows="5"></textarea>
18
+ </label>
19
+ </p>
20
+ <input name="" type="submit" /><input name="" type="reset" />
21
+ </form>
22
+ </div>
23
+ <p></p>
24
+ <div style="border:1px dashed #000 ; padding:10px; color:red ">
25
+ Notice:
26
+ <p>document:<a href="http://business.345soft.com/archives/2922.html"> how to clean the cache </a> </p>
27
+ <p>check new version : <a href="http://business.345soft.com/archives/2922.html"> check new version</a></p>
28
+ </div>
29
+ </div>
app/code/community/SF/Fullpagecache/controllers/Fuallpagecache.php ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once ('app/code/community/SF/Fullpagecache/etc/ini.php');
3
+ $http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://';
4
+ $url_this=$http_type.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
5
+ $cachename=md5($url_this);
6
+ $cacheurl=getcwd().'/html/';
7
+ if(!$fpc_config['is_allow_fpc']){
8
+ Mage::run($mageRunCode, $mageRunType);
9
+ }else{
10
+ if(isset($_REQUEST['fpcclean'])&&isset($_REQUEST['fpcuser'])){
11
+ if($_REQUEST['fpcuser']==$fpc_config['user']){
12
+ $cleancache=$_REQUEST['fpcclean'];
13
+ if($cleancache=='all'){
14
+ delDirAndFile($cacheurl);
15
+ goback();
16
+ }elseif($cleancache=='batch'){
17
+ $cleancache=$_REQUEST['fpcurls'];
18
+ if($cleancache){
19
+ $urls=explode(PHP_EOL,$cleancache);
20
+ foreach($urls as $value){
21
+ if($value){
22
+ $cachename=md5($value);
23
+ if(file_exists($cacheurl.$cachename)){
24
+ if(unlink($cacheurl.$cachename)){
25
+ echo "file delete ok $value<br />\n";
26
+ }
27
+ }else{
28
+ echo '<b>'.$value."not find the file!".'</b><br />\n';
29
+ }
30
+ }
31
+ }
32
+ goback();
33
+ }else{
34
+ echo "the urls empty!";
35
+ goback();
36
+
37
+ }
38
+ }
39
+ }else{
40
+ echo "no the user!";
41
+ goback();
42
+ }
43
+
44
+ }elseif(isset($_REQUEST['fpcform'])){
45
+ if($_REQUEST['fpcform']==1){
46
+ require_once ('app/code/community/SF/Fullpagecache/Block/form.php');
47
+ }
48
+ }else{
49
+ $flag=true;
50
+ foreach($not_cache_url as $value){
51
+ if(strpos($url_this,$value)){
52
+ $flag=false;break;
53
+ }
54
+ }
55
+ if($flag){
56
+ if(file_exists($cacheurl.$cachename)){
57
+ $html=file_get_contents($cacheurl.$cachename);
58
+ }else{
59
+ if(isset($_REQUEST['needcache'])){
60
+ if($_REQUEST['needcache']=='cache'){
61
+ Mage::run($mageRunCode, $mageRunType);
62
+ return;
63
+ }
64
+ }else{
65
+ if(strpos($url_this,'?')){
66
+ $newurl=$url_this.'&needcache=cache';
67
+ }else{
68
+ $newurl=$url_this.'?needcache=cache';
69
+ }
70
+ /*
71
+ sorry this method no work in linux , beacuse there are the ob funtion in magento
72
+ ob_start();
73
+ Mage::run($mageRunCode, $mageRunType);
74
+ $html='<!--'.$url_this.'--!>'.ob_get_contents();
75
+ ob_end_clean();
76
+ */
77
+ $ctx = stream_context_create(array('http' => array('timeout' => 60)));
78
+ $html=file_get_contents($newurl,false,$ctx).'<!--'.$url_this.'--!>';
79
+ if(!is_dir($cacheurl)) {
80
+ mkdir($cacheurl,0777);
81
+ }
82
+ file_put_contents($cacheurl.$cachename,$html);
83
+ }
84
+ }
85
+ echo $html;
86
+ }else{
87
+ Mage::run($mageRunCode, $mageRunType);
88
+ }
89
+ }
90
+ }
91
+ function delDirAndFile( $dirName )
92
+ {
93
+ if(!is_dir($dirName)){
94
+ echo "there are no the dir!";
95
+ goback();
96
+ }
97
+ if ($handle = opendir("$dirName")) {
98
+ while (false!==($item= readdir($handle))) {
99
+ if ($item!= "."&&$item != "..") {
100
+ if (is_dir("$dirName/$item")) {
101
+ delDirAndFile("$dirName/$item");
102
+ }else {
103
+ if(unlink( "$dirName/$item")){
104
+ echo "file delete ok $dirName/$item<br />\n";
105
+ }
106
+ }
107
+ }
108
+ }
109
+ closedir($handle);
110
+ if(rmdir($dirName))echo "dir delete ok $dirName<br />\n";
111
+ }
112
+ }
113
+ function goback(){
114
+ global $url_this;
115
+ header("refresh:10;url=".$url_this);
116
+ print("<p> wait 10 seconds go back or you can click <a href=$url_this >here</a> go back </p>");
117
+ exit;
118
+ }
119
+ ?>
app/code/community/SF/Fullpagecache/etc/config.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <SF_Fullpagecache>
5
+ <version>0.1.0</version>
6
+ </SF_Fullpagecache>
7
+ </modules>
8
+ </config>
app/code/community/SF/Fullpagecache/etc/ini.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $fpc_config=array(
3
+ 'is_allow_fpc'=>true,
4
+ 'user'=>'root'
5
+ );
6
+ $not_cache_url=array(
7
+ '1'=>'admin',
8
+ '2'=>'checkout',
9
+ '3'=>'customer',
10
+ '4'=>'catalog',
11
+ '5'=>'product_compare',
12
+ '6'=>'wishlist',
13
+ '7'=>'downloader',
14
+ '8'=>'catalogsearch',
15
+ '9'=>'install',
16
+ '10'=>'review',
17
+ '11'=>'varnish'
18
+ );
19
+ ?>
app/code/community/SF/Fullpagecache/readme.txt ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ It will make sure the extension work ok , you must read the document ,beafore you use the extension .
2
+
3
+ beacuse , the extension need to be configuration . the document url : http://business.345soft.com/archives/2922.html
4
+
5
+ feature :
6
+
7
+ this extension can make you website fly .
8
+
9
+ how it wok , when custmoer first visit the you website , the extension will create the full page cache according the url .
10
+
11
+ after that , the extesion will get the cache return back to customer directly , when customers visit the you website .
12
+
13
+ It allow you to clean the all cache , or parts of cahce .
14
+
15
+
16
+
17
+
18
+
19
+
app/etc/modules/SF_Fullpagecache.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <modules>
3
+ <SF_Fullpagecache>
4
+ <active>true</active>
5
+ <codePool>community</codePool>
6
+ </SF_Fullpagecache>
7
+ </modules>
8
+ </config>
package.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>sffullpagecache</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">osl-3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>this extension can make you website fly</summary>
10
+ <description>the extension will create the full page cache according the url .&#xD;
11
+ &#xD;
12
+ after that , the extesion will get the cache return back to customer directly , when customers visit the you website .&#xD;
13
+ &#xD;
14
+ It allow you to clean the all cache , or parts of cahce .&#xD;
15
+ </description>
16
+ <notes>It will make sure the extension work ok , you must read the document ,beafore you use the extension .</notes>
17
+ <authors><author><name>evan wang</name><user>evanwang</user><email>lanqiaowangxin@gmail.com</email></author></authors>
18
+ <date>2013-04-25</date>
19
+ <time>05:30:24</time>
20
+ <contents><target name="magecommunity"><dir name="SF"><dir name="Fullpagecache"><dir name="Block"><file name="form.php" hash="f3c7034adfaf842a3c0cf96c61aaadf2"/></dir><dir name="controllers"><file name="Fuallpagecache.php" hash="71bed43e6f820e00f2b542757e68b925"/></dir><dir name="etc"><file name="config.xml" hash="0ae3c5df62c17f89b25388f037a61475"/><file name="ini.php" hash="c5d0940f35815993353380f3d8d09403"/></dir><file name="readme.txt" hash="1de05cf578f0eae10ff2b40907e78a46"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="SF_Fullpagecache.xml" hash="0fb3e06d447ba9e4fc1be7c2eab8d386"/></dir></target></contents>
21
+ <compatible/>
22
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
23
+ </package>