code comments/indent
code comments/indent

file:a/LICENSE (deleted)
--- a/LICENSE
+++ /dev/null
@@ -1,340 +1,1 @@
-                    GNU GENERAL PUBLIC LICENSE
-                       Version 2, June 1991
 
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-                            Preamble
-
-  The licenses for most software are designed to take away your
-freedom to share and change it.  By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users.  This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it.  (Some other Free Software Foundation software is covered by
-the GNU Lesser General Public License instead.)  You can apply it to
-your programs, too.
-
-  When we speak of free software, we are referring to freedom, not
-price.  Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
-  To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
-  For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have.  You must make sure that they, too, receive or can get the
-source code.  And you must show them these terms so they know their
-rights.
-
-  We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
-  Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software.  If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
-  Finally, any free program is threatened constantly by software
-patents.  We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary.  To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.
-
-                    GNU GENERAL PUBLIC LICENSE
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
-  0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License.  The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language.  (Hereinafter, translation is included without limitation in
-the term "modification".)  Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope.  The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
-  1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
-  2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
-    a) You must cause the modified files to carry prominent notices
-    stating that you changed the files and the date of any change.
-
-    b) You must cause any work that you distribute or publish, that in
-    whole or in part contains or is derived from the Program or any
-    part thereof, to be licensed as a whole at no charge to all third
-    parties under the terms of this License.
-
-    c) If the modified program normally reads commands interactively
-    when run, you must cause it, when started running for such
-    interactive use in the most ordinary way, to print or display an
-    announcement including an appropriate copyright notice and a
-    notice that there is no warranty (or else, saying that you provide
-    a warranty) and that users may redistribute the program under
-    these conditions, and telling the user how to view a copy of this
-    License.  (Exception: if the Program itself is interactive but
-    does not normally print such an announcement, your work based on
-    the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole.  If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works.  But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
-  3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
-    a) Accompany it with the complete corresponding machine-readable
-    source code, which must be distributed under the terms of Sections
-    1 and 2 above on a medium customarily used for software interchange; or,
-
-    b) Accompany it with a written offer, valid for at least three
-    years, to give any third party, for a charge no more than your
-    cost of physically performing source distribution, a complete
-    machine-readable copy of the corresponding source code, to be
-    distributed under the terms of Sections 1 and 2 above on a medium
-    customarily used for software interchange; or,
-
-    c) Accompany it with the information you received as to the offer
-    to distribute corresponding source code.  (This alternative is
-    allowed only for noncommercial distribution and only if you
-    received the program in object code or executable form with such
-    an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it.  For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable.  However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
-  4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License.  Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
-  5. You are not required to accept this License, since you have not
-signed it.  However, nothing else grants you permission to modify or
-distribute the Program or its derivative works.  These actions are
-prohibited by law if you do not accept this License.  Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
-  6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions.  You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
-  7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all.  For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices.  Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
-  8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded.  In such case, this License incorporates
-the limitation as if written in the body of this License.
-
-  9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time.  Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number.  If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation.  If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
-  10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission.  For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this.  Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
-                            NO WARRANTY
-
-  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
-  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
-                     END OF TERMS AND CONDITIONS
-
-            How to Apply These Terms to Your New Programs
-
-  If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
-  To do so, attach the following notices to the program.  It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-    <one line to give the program's name and a brief idea of what it does.>
-    Copyright (C) <year>  <name of author>
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program 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
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License along
-    with this program; if not, write to the Free Software Foundation, Inc.,
-    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
-    Gnomovision version 69, Copyright (C) year name of author
-    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
-    This is free software, and you are welcome to redistribute it
-    under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License.  Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary.  Here is a sample; alter the names:
-
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
-  `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
-  <signature of Ty Coon>, 1 April 1989
-  Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs.  If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library.  If this is what you want to do, use the GNU Lesser General
-Public License instead of this License.
-

file:b/README.txt (new)
--- /dev/null
+++ b/README.txt
@@ -1,1 +1,128 @@
+VCaching
+--------
 
+CONTENTS OF THIS FILE
+---------------------
+
+ * Introduction
+ * Features
+ * Installation and configuration
+ * Troubleshooting
+ * Credits / Contact
+ * Link references
+
+
+INTRODUCTION
+------------
+
+Complete Drupal Varnish Cache 3.x/4.x integration.
+Ported from my Wordpress plugin https://wordpress.org/plugins/vcaching/
+
+This plugin handles all integration with Varnish Cache. It was designed for high traffic websites.
+
+You can control the following from the Varnish Caching admin panel :
+
+* Enable/Disable caching
+* Homepage cache TTL
+* Cache TTL (for every other page)
+* IPs/Hosts to clear cache to support every type of Varnish Cache implementation
+* Purge key based PURGE
+* Logged in cookie
+* Debugging option
+* console for precise manual purges
+
+This plugin also auto purges Varnish Cache when your site is modified.
+
+Varnish Caching sends a PURGE request to Varnish Cache when a node is modified. This occurs when editing, publishing, commenting or deleting a node.
+Not all pages are purged every time, depending on your Varnish configuration. When a post, page, or custom post type is edited, or a new comment is added, only the following pages will purge:
+
+* The front page
+* The node edited
+
+Varnish Cache is a web application accelerator also known as a caching HTTP reverse proxy. You install it in front of any server that speaks HTTP and configure it to cache the contents. This plugin does not install Varnish for you, nor does it configure Varnish for Drupal. It's expected you already did that on your own using the provided config files.
+
+
+FEATURES
+--------
+
+Main features
+
+ * admin interface, see screenshots
+ * console for manual purges, supports regular expressions so you can purge an entire folder or just a single file
+ * supports every type of Varnish Cache implementation, see screenshots for examples
+ * unlimited number of Varnish Cache servers
+ * use of custom headers when communicating with Varnish Cache does not interfere with other caching plugins, cloudflare, etc
+ * Varnish Cache configuration generator
+ * purge key method so you don't need to setup ACLs
+ * debugging
+ * actively maintained
+
+
+INSTALLATION AND CONFIGURATION
+------------------------------
+
+ * You must install Varnish Cache on your server(s)
+ * Go to the configuration generator. Fill in the backends/ACLs then download the configuration files
+ * Use these configuration files to configure Varnish Cache server(s). Usually the configuration files are in /etc/varnish. In most cases you must put the downloaded configuration files in /etc/varnish and restart Varnish Cache
+
+ * Or use the provided Varnish Cache configuration files located in /wp-content/plugins/vcaching/varnish-conf folder.
+
+ * Configure Varnish Caching settings in Configure » System » Varnish Caching:
+    - Enable/Disable caching
+    - Homepage cache TTL
+    - Cache TTL (for every other page)
+    - IPs/Hosts
+    - Purge key
+
+
+TROUBLESHOOTING
+---------------
+
+ * What version of Varnish is supported?
+
+    - This was built and tested on Varnish 3.x/4.x.
+
+ * Why doesn't every page flush when I make a new post?
+
+    - The only pages that should purge are the post's page, the front page, categories, and tags.
+
+ * How do I manually purge the whole cache?
+
+    - Click the 'Purge cache' menu link on the "Configure/System/Varnish Caching" menu.
+
+ * How do I manually purge cache?
+
+    - Use the console. For example you can purge the whole uploads folder with the URL /uploads/.*
+
+ * Varnish Statistics
+
+    - Statistics need a special setup. More info on the Statistics tab on your Drupal environment.
+
+ * How do I configure my Varnish Cache VCL?
+
+    - Use the Varnish Cache configuration generator. Fill in the backends/ACLs then download your configuration files.
+    - Or use the provided Varnish Cache configuration files located in /wp-content/plugins/vcaching/varnish-conf folder.
+
+ * Can I use this with a proxy service like CloudFlare?
+
+    - Yes.
+
+    * What is logged in cookie?
+
+    - Logged in cookie is a special cookie this plugin sets upon user login. Varnish Cache uses this cookie to bypass caching for logged in users.
+
+    - This is a small step towards securing your site for denial of service attacks. Denial of service attacks can happen if the attacker bypasses Varnish Cache and hits the backend directly.
+    - With the current configuration and the way Drupal works, this can still happen with POST/AJAX requests.
+
+
+CREDITS / CONTACT
+-----------------
+
+Development, documentation and testing by Razvan Stanga.
+
+
+LINK REFERENCES
+---------------
+
+www.varnish-cache.org
+

file:a/readme.txt (deleted)
--- a/readme.txt
+++ /dev/null
@@ -1,128 +1,1 @@
-VCaching
---------
 
-CONTENTS OF THIS FILE
----------------------
-
- * Introduction
- * Features
- * Installation and configuration
- * Troubleshooting
- * Credits / Contact
- * Link references
-
-
-INTRODUCTION
-------------
-
-Complete Drupal Varnish Cache 3.x/4.x integration.
-Ported from my Wordpress plugin https://wordpress.org/plugins/vcaching/
-
-This plugin handles all integration with Varnish Cache. It was designed for high traffic websites.
-
-You can control the following from the Varnish Caching admin panel :
-
-* Enable/Disable caching
-* Homepage cache TTL
-* Cache TTL (for every other page)
-* IPs/Hosts to clear cache to support every type of Varnish Cache implementation
-* Purge key based PURGE
-* Logged in cookie
-* Debugging option
-* console for precise manual purges
-
-This plugin also auto purges Varnish Cache when your site is modified.
-
-Varnish Caching sends a PURGE request to Varnish Cache when a node is modified. This occurs when editing, publishing, commenting or deleting a node.
-Not all pages are purged every time, depending on your Varnish configuration. When a post, page, or custom post type is edited, or a new comment is added, only the following pages will purge:
-
-* The front page
-* The node edited
-
-Varnish Cache is a web application accelerator also known as a caching HTTP reverse proxy. You install it in front of any server that speaks HTTP and configure it to cache the contents. This plugin does not install Varnish for you, nor does it configure Varnish for Drupal. It's expected you already did that on your own using the provided config files.
-
-
-FEATURES
---------
-
-Main features
-
- * admin interface, see screenshots
- * console for manual purges, supports regular expressions so you can purge an entire folder or just a single file
- * supports every type of Varnish Cache implementation, see screenshots for examples
- * unlimited number of Varnish Cache servers
- * use of custom headers when communicating with Varnish Cache does not interfere with other caching plugins, cloudflare, etc
- * Varnish Cache configuration generator
- * purge key method so you don't need to setup ACLs
- * debugging
- * actively maintained
-
-
-INSTALLATION AND CONFIGURATION
-------------------------------
-
- * You must install Varnish Cache on your server(s)
- * Go to the configuration generator. Fill in the backends/ACLs then download the configuration files
- * Use these configuration files to configure Varnish Cache server(s). Usualy the configuration files are in /etc/varnish. In most cases you must put the downloaded configuration files in /etc/varnish and restart Varnish Cache
-
- * Or use the provided Varnish Cache configuration files located in /wp-content/plugins/vcaching/varnish-conf folder.
-
- * Configure Varnish Caching settings in Configure » System » Varnish Caching:
-    - Enable/Disable caching
-    - Homepage cache TTL
-    - Cache TTL (for every other page)
-    - IPs/Hosts
-    - Purge key
-
-
-TROUBLESHOOTING
----------------
-
- * What version of Varnish is supported?
-
-    - This was built and tested on Varnish 3.x/4.x.
-
- * Why doesn't every page flush when I make a new post?
-
-    - The only pages that should purge are the post's page, the front page, categories, and tags.
-
- * How do I manually purge the whole cache?
-
-    - Click the 'Purge cache' menu link on the "Configure/System/Varnish Caching" menu.
-
- * How do I manually purge cache?
-
-    - Use the console. For example you can purge the whole uploads folder with the URL /uploads/.*
-
- * Varnish Statistics
-
-    - Statistics need a special setup. More info on the Statistics tab on your Drupal environment.
-
- * How do I configure my Varnish Cache VCL?
-
-    - Use the Varnish Cache configuration generator. Fill in the backends/ACLs then download your configuration files.
-    - Or use the provided Varnish Cache configuration files located in /wp-content/plugins/vcaching/varnish-conf folder.
-
- * Can I use this with a proxy service like CloudFlare?
-
-    - Yes.
-
-    * What is logged in cookie?
-
-    - Logged in cookie is a special cookie this plugin sets upon user login. Varnish Cache uses this cookie to bypass caching for logged in users.
-
-    - This is a small step towards securing your site for denial of service attacks. Denial of service attacks can happen if the attacker bypasses Varnish Cache and hits the backend directly.
-    - With the current configuration and the way Drupal works, this can still happen with POST/AJAX requests.
-
-
-CREDITS / CONTACT
------------------
-
-Development, documentation and testing by Razvan Stanga.
-
-
-LINK REFERENCES
----------------
-
-www.varnish-cache.org
-

--- a/varnish-conf/v3/default.vcl
+++ b/varnish-conf/v3/default.vcl
@@ -61,7 +61,7 @@
     set req.grace = 2m;
 
     # strip query parameters from all urls (so they cache as a single object)
-    # be carefull using this option
+    # be careful using this option
     #if (req.url ~ "\?.*") {
     #    set req.url = regsub(req.url, "\?.*", "");
     #}

--- a/varnish-conf/v4/default.vcl
+++ b/varnish-conf/v4/default.vcl
@@ -63,7 +63,7 @@
     ### looks like we might actually cache it!
 
     # strip query parameters from all urls (so they cache as a single object)
-    # be carefull using this option
+    # be careful using this option
     #if (req.url ~ "\?.*") {
     #    set req.url = regsub(req.url, "\?.*", "");
     #}

--- a/vcaching.class.php
+++ b/vcaching.class.php
@@ -1,323 +1,374 @@
 <?php
 
-class VCaching
-{
-    protected $prefix = '';
-    protected $purgeUrls = array();
-    protected $varnishIp = null;
-    protected $varnishHost = null;
-    protected $dynamicHost = null;
-    protected $ipsToHosts = array();
-    protected $statsJsons = array();
-    protected $purgeKey = null;
-    protected $getParam = 'purge_varnish_cache';
-    protected $noticeMessage = '';
-    protected $debug = 0;
-
-    public function __construct($prefix)
-    {
-        $this->prefix = $prefix;
-        $this->setupIpsToHosts();
-        $this->purgeKey = ($purgeKey = trim(variable_get($this->prefix . 'purge_key'))) ? $purgeKey : null;
-    }
-
-    protected function setupIpsToHosts()
-    {
-        $this->debug = variable_get($this->prefix . 'debug');
-        $this->varnishIp = variable_get($this->prefix . 'ips');
-        $this->varnishHost = variable_get($this->prefix . 'hosts');
-        $this->dynamicHost = variable_get($this->prefix . 'dynamic_host');
-        $this->statsJsons = variable_get($this->prefix . 'stats_json_file');
-        $varnishIp = explode(',', $this->varnishIp);
-        $varnishHost = explode(',', $this->varnishHost);
-        $statsJsons = explode(',', $this->statsJsons);
-        foreach ($varnishIp as $key => $ip) {
-            if (strpos($ip, ':')) {
-                $_ip = explode(':', $ip);
-                $ip = $_ip[0];
-                $port = $_ip[1];
-            } else {
-                $port = 80;
-            }
-            $this->ipsToHosts[] = array(
-                'ip' => $ip,
-                'port' => $port,
-                'host' => $this->dynamicHost ? $_SERVER['HTTP_HOST'] : $varnishHost[$key],
-                'statsJson' => isset($statsJsons[$key]) ? $statsJsons[$key] : null
-            );
+/**
+ * VCaching Class
+ */
+class VCaching {
+  protected $prefix = '';
+  protected $purgeUrls = array();
+  protected $varnishIp = null;
+  protected $varnishHost = null;
+  protected $dynamicHost = null;
+  protected $ipsToHosts = array();
+  protected $statsJsons = array();
+  protected $purgeKey = null;
+  protected $noticeMessage = '';
+  protected $debug = 0;
+
+  /**
+   * Constructor
+   *
+   * @param string $prefix
+   */
+  public function __construct($prefix)
+  {
+    $this->prefix = $prefix;
+    $this->setupIpsToHosts();
+    $this->purgeKey = ($purgeKey = trim(variable_get($this->prefix . 'purge_key'))) ? $purgeKey : null;
+  }
+
+  /**
+   * Sets up needed vars
+   *
+   * @return void
+   */
+  protected function setupIpsToHosts()
+  {
+    $this->debug = variable_get($this->prefix . 'debug');
+    $this->varnishIp = variable_get($this->prefix . 'ips');
+    $this->varnishHost = variable_get($this->prefix . 'hosts');
+    $this->dynamicHost = variable_get($this->prefix . 'dynamic_host');
+    $this->statsJsons = variable_get($this->prefix . 'stats_json_file');
+    $varnishIp = explode(',', $this->varnishIp);
+    $varnishHost = explode(',', $this->varnishHost);
+    $statsJsons = explode(',', $this->statsJsons);
+    foreach ($varnishIp as $key => $ip) {
+      if (strpos($ip, ':')) {
+        $_ip = explode(':', $ip);
+        $ip = $_ip[0];
+        $port = $_ip[1];
+      } else {
+        $port = 80;
+      }
+      $this->ipsToHosts[] = array(
+        'ip' => $ip,
+        'port' => $port,
+        'host' => $this->dynamicHost ? $_SERVER['HTTP_HOST'] : $varnishHost[$key],
+        'statsJson' => isset($statsJsons[$key]) ? $statsJsons[$key] : null
+        );
+    }
+
+    $this->purgeKey = ($purgeKey = trim(variable_get($this->prefix . 'purge_key'))) ? $purgeKey : null;
+  }
+
+  /**
+   * Purge cache
+   *
+   * @return void
+   */
+  public function purgeCache()
+  {
+    $purgeUrls = array_unique($this->purgeUrls);
+
+    if (!empty($purgeUrls)) {
+      foreach($purgeUrls as $url) {
+        $this->purgeUrl($url);
+      }
+    }
+  }
+
+  /**
+   * Fetches the notice message
+   *
+   * @param  boolean $console
+   * @return string
+   */
+  public function getNoticeMessage($console = false)
+  {
+    return ($console ? str_replace("<br />", "\n", $this->noticeMessage): $this->noticeMessage);
+  }
+
+  /**
+   * Purges the given URL
+   *
+   * @param  string $url relative url
+   * @return void
+   */
+  public function purgeUrl($url)
+  {
+    $p = parse_url($url);
+
+    if (isset($p['path'])) {
+      $path = $p['path'];
+    } else {
+      $path = '';
+    }
+
+    if (isset($p['query']) && ($p['query'] == 'vc-regex')) {
+      $purgemethod = 'regex';
+      $purgeurl = base_path() . '.*';
+    } else {
+      $purgemethod = 'default';
+      $purgeurl = $path;
+    }
+    foreach ($this->ipsToHosts as $ipToHost) {
+      $headers = array('host' => $ipToHost['host'], 'X-VC-Purge-Method' => $purgemethod, 'X-VC-Purge-Host' => $ipToHost['host']);
+      if (!is_null($this->purgeKey)) {
+        $headers['X-VC-Purge-Key'] = $this->purgeKey;
+      }
+      $response = $this->_vcaching_cache_purge($ipToHost['ip'], $ipToHost['port'], $purgeurl, $headers);
+      if ($response['error'] == true) {
+        $this->noticeMessage .= 'Error ' . $response['message'];
+      } else {
+        $this->noticeMessage .= '<br />' . t('Trying to purge URL :') . $purgeurl;
+        preg_match("/<title>(.*)<\/title>/i", $response['message'], $matches);
+        $this->noticeMessage .= ' => <br /> ' . isset($matches[1]) ? ' => ' . $matches[1] : $response['message'];
+        $this->noticeMessage .= '<br />';
+        if ($this->debug) {
+          $this->noticeMessage .= nl2br($response['message'], true) . '<br />';
         }
-
-        $this->purgeKey = ($purgeKey = trim(variable_get($this->prefix . 'purge_key'))) ? $purgeKey : null;
-    }
-
-    public function purgeCache()
-    {
-        $purgeUrls = array_unique($this->purgeUrls);
-
-        if (empty($purgeUrls)) {
-            if (isset($_GET[$this->getParam])) {
-                $this->purgeUrl('/?vc-regex');
-            }
+      }
+    }
+  }
+
+  /**
+   * Stats TAB HTML generator
+   *
+   * @return string
+   */
+  public function stats()
+  {
+    $html = '<fieldset class="form-wrapper" id="edit-general"><legend><span class="fieldset-legend">' . t('Stats') . '</span></legend>' . "\n";
+    $html .= '<div class="fieldset-wrapper">' . "\n";
+    if ($_GET['info'] == 1) {
+      $html .= '<div class="block clearfix block-system">' . "\n";
+      $html .= '<div class="block-content clearfix">' . "\n";
+      $html .= '<h2>' . t('Setup information') .'</h2>' . "\n";
+      $html .= '<br /><p>' . "\n";
+      $html .= t('<strong>Short story</strong><br />You must generate by cronjob the JSON stats file. The generated files must be copied on the backend servers in the Drupal root folder.');
+      $html .= '<br /><br />' . "\n";
+      $html .= sprintf(t('<strong>Long story</strong><br />On every Varnish Cache server setup a cronjob that generates the JSON stats file :<br /> %1$s /path/to/be/set/filename.json # every 3 minutes.'), '*/3 * * * *     root   /usr/bin/varnishstat -1j >');
+      $html .= '<br />' . "\n";
+      $html .= t('The generated files must be copied on the backend servers in the Drupal root folder.');
+      $html .= '<br />' . "\n";
+      $html .= t("Use a different filename for each Varnish Cache server. After this is done, fill in the relative path to the files in Statistics JSONs on the Settings tab.");
+      $html .= '<br /><br />' . "\n";
+      $html .= t('Example 1 <br />If you have a single server, both Varnish Cache and the backend on it, use the following cronjob:');
+      $html .= '<br />' . "\n";
+      $html .= sprintf(t('%1$s /path/to/the/drupal/root/varnishstat.json # every 3 minutes.'), '*/3 * * * *     root   /usr/bin/varnishstat -1j >');
+      $html .= '<br />' . "\n";
+      $html .= t('Then fill in the relative path to the files in Statistics JSONs on the Settings tab :') . "\n";
+      $html .= '<br />' . "\n";
+      $html .= '<input type="text" size="100" value="/varnishstat.json" class="fluid form-text" />' . "\n";
+
+      $html .= '<br /><br />' . "\n";
+      $html .= t("Example 2 <br />You have 2 Varnish Cache Servers, and 3 backend servers. Setup the cronjob :");
+      $html .= '<br />' . "\n";
+      $html .= sprintf(t('VC Server 1 : %1$s # every 3 minutes.'), '*/3 * * * *     root   /usr/bin/varnishstat -1j > /root/varnishstat/server1_3389398cd359cfa443f85ca040da069a.json');
+      $html .= '<br />' . "\n";
+      $html .= sprintf(t('VC Server 2 : %1$s # every 3 minutes.'), '*/3 * * * *     root   /usr/bin/varnishstat -1j > /root/varnishstat/server2_3389398cd359cfa443f85ca040da069a.json');
+      $html .= '<br />' . "\n";
+      $html .= t('Copy the files on the backend servers in /path/to/drupal/root/varnishstat/ folder. Then fill in the relative path to the files in Statistics JSONs on the Settings tab :');
+      $html .= '<br />' . "\n";
+
+      $html .= '<input type="text" class="fluid form-text" size="100" value="/varnishstat/server1_3389398cd359cfa443f85ca040da069a.json,/varnishstat/server2_3389398cd359cfa443f85ca040da069a.json" />' . "\n";
+      $html .= '</p>';
+      $html .= '</div>' . "\n";
+      $html .= '</div>' . "\n";
+    }
+    if(trim($this->statsJsons)){
+      $html .= '<div class="block clearfix block-system">' . "\n";
+      $html .= '<div class="block-content clearfix"><p class="clearfix"><strong>Select server</strong></p>' . "\n";
+      $html .= '<ul class="secondary-tabs links clearfix">' . "\n";
+      foreach ($this->ipsToHosts as $server => $ipToHost) {
+        $html .= '<li class="links ' . (($server == 0) ? 'active' : '') . '"><a class="server nav-tab" href="#" server="' . $server . '">'. sprintf(t('Server %1$s'), $ipToHost['ip']).'</a></li>' . "\n";
+      }
+      $html .= '</ul>';
+      $html .= '</div>' . "\n";
+      $html .= '</div>' . "\n";
+
+      foreach ($this->ipsToHosts as $server => $ipToHost) {
+        $html .= '<div style="display:' . (($server == 0) ? 'block' : 'none') . '" class="servers server_' . $server . '">';
+        $html .= sprintf(t('Fetching stats for server %1$s'), $ipToHost['ip']);
+        $html .= '</div>' . "\n";
+        $html .= '<script type="text/javascript">' . "\n";
+        $html .= 'jQuery.getJSON("' . $ipToHost['statsJson'] . '", function(data) {' . "\n";
+        $html .= 'var server = \'.server_' . $server .'\'' . "\n";
+        $html .= 'jQuery(server).html(\'\');' . "\n";
+        $html .= 'jQuery(server).append(\'<div id="block-system-vcaching-help" class="block block-system"><div class="block-content clearfix"><p>' . sprintf(t('Stats for server %1$s generated on '), $ipToHost['ip']) . '\' + data.timestamp);' . " + '</p></div></div>'\n";
+        $html .= 'jQuery(server).append(\'<table><thead><tr><th><strong>' . t('Description') . '</strong></th><th><strong>' . t('Value') . '</strong></th><th><strong>' . t('Key') .'</strong></th></tr></thead><tbody class="varnishstats_' . $server . '"></tbody></table>\')' . "\n";
+        $html .= 'delete data.timestamp;' . "\n";
+        $html .= 'jQuery.each(data, function(key, val) {' . "\n";
+        $html .= 'jQuery(\'.varnishstats_' . $server . '\').append(\'<tr><td class="views-field views-field-title">\'+val.description+\'</td><td>\'+val.value+\'</td><td>\'+key+\'</td></tr>\');' . "\n";
+        $html .= '});' . "\n";
+        $html .= '});' . "\n";
+        $html .= '</script>' . "\n";
+      }
+      $html .= '<script type="text/javascript">' . "\n";
+      $html .= 'jQuery(\'a.server\').click(function(e){' . "\n";
+      $html .= 'e.preventDefault();' . "\n";
+      $html .= 'jQuery(\'li.links\').removeClass(\'active\');' . "\n";
+      $html .= 'jQuery(this).parent().addClass(\'active\');' . "\n";
+      $html .= 'jQuery(".servers").hide();' . "\n";
+      $html .= 'jQuery(".server_" + jQuery(this).attr(\'server\')).show();' . "\n";
+      $html .= '});' . "\n";
+      $html .= '</script>' . "\n";
+    }
+  $html .= '</div>' . "\n";
+  $html .= '</fieldset>' . "\n";
+  return $html;
+}
+
+  /**
+   * The socket connection to Varnish
+   *
+   * @param  string $server_ip
+   * @param  string $server_port
+   * @param  string $path
+   * @param  array $headers
+   * @return array
+   */
+  protected function _vcaching_cache_purge($server_ip, $server_port, $path = '/.*', $headers)
+  {
+    $fp = fsockopen($server_ip, $server_port, $errno, $errstr, 2);
+    if (!$fp) {
+      return array('error' => true, 'message' => $errstr .'(' . $errno . ')');
+    } else {
+      $out = "PURGE " . $path . " HTTP/1.0\n";
+      foreach ($headers as $key => $value) {
+        $out .= $key . ': '. $value . "\n";
+      }
+      $out .= "Connection: Close\n\n";
+      fwrite($fp, $out);
+      $ret = "";
+      while (!feof($fp)) {
+        $ret .= fgets($fp, 128);
+      }
+      fclose($fp);
+      return array('error' => false, 'message' => $ret);
+    }
+  }
+
+  /**
+   * Creates the configuration zip archive
+   *
+   * @param  int $version
+   * @return void
+   */
+  public function downloadConf($version)
+  {
+    $tmpfile = tempnam("tmp", "zip");
+    $zip = new ZipArchive();
+    $zip->open($tmpfile, ZipArchive::OVERWRITE);
+    $files = array(
+      'default.vcl' => true,
+      'LICENSE' => false,
+      'README.rst' => false,
+      'conf/acl.vcl' => true,
+      'conf/backend.vcl' => true,
+      'lib/bigfiles.vcl' => false,
+      'lib/bigfiles_pipe.vcl' => false,
+      'lib/cloudflare.vcl' => false,
+      'lib/mobile_cache.vcl' => false,
+      'lib/mobile_pass.vcl' => false,
+      'lib/purge.vcl' => true,
+      'lib/static.vcl' => false,
+      'lib/xforward.vcl' => false,
+    );
+    foreach ($files as $file => $parse) {
+      $filepath = __DIR__ . '/varnish-conf/v' . $version . '/' . $file;
+      if ($parse) {
+        $content = $this->_parse_conf_file($version, $file, file_get_contents($filepath));
+      } else {
+        $content = file_get_contents($filepath);
+      }
+      $zip->addFromString($file, $content);
+    }
+    $zip->close();
+    header('Content-Type: application/zip');
+    header('Content-Length: ' . filesize($tmpfile));
+    header('Content-Disposition: attachment; filename="varnish_v' . $version . '_conf.zip"');
+    readfile($tmpfile);
+    unlink($tmpfile);
+    exit();
+  }
+
+  /**
+   * Parses the config files
+   *
+   * @param  int $version
+   * @param  string $file
+   * @param  string $content
+   * @return string
+   */
+  protected function _parse_conf_file($version, $file, $content)
+  {
+    if ($file == 'default.vcl') {
+      $logged_in_cookie = variable_get($this->prefix . 'cookie');
+      $content = str_replace('c005492c65', $logged_in_cookie, $content);
+    } else if ($file == 'conf/backend.vcl') {
+      if ($version == 3) {
+        $content = "";
+      } else if ($version == 4) {
+        $content = "import directors;\n\n";
+      }
+      $backend = array();
+      $ips = variable_get($this->prefix . 'conf_backends');
+      $ips = explode(',', $ips);
+      $id = 1;
+      foreach ($ips as $ip) {
+        if (strstr($ip, ":")) {
+          $_ip = explode(':', $ip);
+          $ip = $_ip[0];
+          $port = $_ip[1];
         } else {
-            foreach($purgeUrls as $url) {
-                $this->purgeUrl($url);
-            }
+          $port = 80;
         }
-    }
-
-    public function getNoticeMessage($console = false)
-    {
-        return ($console ? str_replace("<br />", "\n", $this->noticeMessage): $this->noticeMessage);
-    }
-
-    public function purgeUrl($url)
-    {
-        $p = parse_url($url);
-
-        if (isset($p['path'])) {
-            $path = $p['path'];
-        } else {
-            $path = '';
-        }
-
-        if (isset($p['query']) && ($p['query'] == 'vc-regex')) {
-            $purgemethod = 'regex';
-            $purgeurl = base_path() . '.*';
-        } else {
-            $purgemethod = 'default';
-            $purgeurl = $path;
-        }
-        foreach ($this->ipsToHosts as $ipToHost) {
-            $headers = array('host' => $ipToHost['host'], 'X-VC-Purge-Method' => $purgemethod, 'X-VC-Purge-Host' => $ipToHost['host']);
-            if (!is_null($this->purgeKey)) {
-                $headers['X-VC-Purge-Key'] = $this->purgeKey;
-            }
-            $response = $this->_vcaching_cache_purge($ipToHost['ip'], $ipToHost['port'], $purgeurl, $headers);
-            if ($response['error'] == true) {
-                $this->noticeMessage .= 'Error ' . $response['message'];
-            } else {
-                $this->noticeMessage .= '<br />' . t('Trying to purge URL :') . $purgeurl;
-                preg_match("/<title>(.*)<\/title>/i", $response['message'], $matches);
-                $this->noticeMessage .= ' => <br /> ' . isset($matches[1]) ? ' => ' . $matches[1] : $response['message'];
-                $this->noticeMessage .= '<br />';
-                if ($this->debug) {
-                    $this->noticeMessage .= nl2br($response['message'], true) . '<br />';
-                }
-            }
-        }
-    }
-
-    public function stats()
-    {
-        $html = '<fieldset class="form-wrapper" id="edit-general"><legend><span class="fieldset-legend">' . t('Stats') . '</span></legend>' . "\n";
-        $html .= '<div class="fieldset-wrapper">' . "\n";
-        if ($_GET['info'] == 1) {
-            $html .= '<div class="block clearfix block-system">' . "\n";
-            $html .= '<div class="block-content clearfix">' . "\n";
-            $html .= '<h2>' . t('Setup information') .'</h2>' . "\n";
-            $html .= '<br /><p>' . "\n";
-            $html .= t('<strong>Short story</strong><br />You must generate by cronjob the JSON stats file. The generated files must be copied on the backend servers in the Drupal root folder.');
-            $html .= '<br /><br />' . "\n";
-            $html .= sprintf(t('<strong>Long story</strong><br />On every Varnish Cache server setup a cronjob that generates the JSON stats file :<br /> %1$s /path/to/be/set/filename.json # every 3 minutes.'), '*/3 * * * *     root   /usr/bin/varnishstat -1j >');
-            $html .= '<br />' . "\n";
-            $html .= t('The generated files must be copied on the backend servers in the Drupal root folder.');
-            $html .= '<br />' . "\n";
-            $html .= t("Use a different filename for each Varnish Cache server. After this is done, fill in the relative path to the files in Statistics JSONs on the Settings tab.");
-            $html .= '<br /><br />' . "\n";
-            $html .= t('Example 1 <br />If you have a single server, both Varnish Cache and the backend on it, use the folowing cronjob:');
-            $html .= '<br />' . "\n";
-            $html .= sprintf(t('%1$s /path/to/the/drupal/root/varnishstat.json # every 3 minutes.'), '*/3 * * * *     root   /usr/bin/varnishstat -1j >');
-            $html .= '<br />' . "\n";
-            $html .= t('Then fill in the relative path to the files in Statistics JSONs on the Settings tab :') . "\n";
-            $html .= '<br />' . "\n";
-            $html .= '<input type="text" size="100" value="/varnishstat.json" class="fluid form-text" />' . "\n";
-
-            $html .= '<br /><br />' . "\n";
-            $html .= t("Example 2 <br />You have 2 Varnish Cache Servers, and 3 backend servers. Setup the cronjob :");
-            $html .= '<br />' . "\n";
-            $html .= sprintf(t('VC Server 1 : %1$s # every 3 minutes.'), '*/3 * * * *     root   /usr/bin/varnishstat -1j > /root/varnishstat/server1_3389398cd359cfa443f85ca040da069a.json');
-            $html .= '<br />' . "\n";
-            $html .= sprintf(t('VC Server 2 : %1$s # every 3 minutes.'), '*/3 * * * *     root   /usr/bin/varnishstat -1j > /root/varnishstat/server2_3389398cd359cfa443f85ca040da069a.json');
-            $html .= '<br />' . "\n";
-            $html .= t('Copy the files on the backend servers in /path/to/drupal/root/varnishstat/ folder. Then fill in the relative path to the files in Statistics JSONs on the Settings tab :');
-            $html .= '<br />' . "\n";
-
-            $html .= '<input type="text" class="fluid form-text" size="100" value="/varnishstat/server1_3389398cd359cfa443f85ca040da069a.json,/varnishstat/server2_3389398cd359cfa443f85ca040da069a.json" />' . "\n";
-            $html .= '</p>';
-            $html .= '</div>' . "\n";
-            $html .= '</div>' . "\n";
-        }
-        if(trim($this->statsJsons)){
-            $html .= '<div class="block clearfix block-system">' . "\n";
-            $html .= '<div class="block-content clearfix"><p class="clearfix"><strong>Select server</strong></p>' . "\n";
-            $html .= '<ul class="secondary-tabs links clearfix">' . "\n";
-            foreach ($this->ipsToHosts as $server => $ipToHost) {
-                $html .= '<li class="links ' . (($server == 0) ? 'active' : '') . '"><a class="server nav-tab" href="#" server="' . $server . '">'. sprintf(t('Server %1$s'), $ipToHost['ip']).'</a></li>' . "\n";
-            }
-            $html .= '</ul>';
-            $html .= '</div>' . "\n";
-            $html .= '</div>' . "\n";
-
-            foreach ($this->ipsToHosts as $server => $ipToHost) {
-                $html .= '<div style="display:' . (($server == 0) ? 'block' : 'none') . '" class="servers server_' . $server . '">';
-                $html .= sprintf(t('Fetching stats for server %1$s'), $ipToHost['ip']);
-                $html .= '</div>' . "\n";
-                $html .= '<script type="text/javascript">' . "\n";
-                    $html .= 'jQuery.getJSON("' . $ipToHost['statsJson'] . '", function(data) {' . "\n";
-                        $html .= 'var server = \'.server_' . $server .'\'' . "\n";
-                        $html .= 'jQuery(server).html(\'\');' . "\n";
-                        $html .= 'jQuery(server).append(\'<div id="block-system-vcaching-help" class="block block-system"><div class="block-content clearfix"><p>' . sprintf(t('Stats for server %1$s generated on '), $ipToHost['ip']) . '\' + data.timestamp);' . " + '</p></div></div>'\n";
-                        $html .= 'jQuery(server).append(\'<table><thead><tr><th><strong>' . t('Description') . '</strong></th><th><strong>' . t('Value') . '</strong></th><th><strong>' . t('Key') .'</strong></th></tr></thead><tbody class="varnishstats_' . $server . '"></tbody></table>\')' . "\n";
-                        $html .= 'delete data.timestamp;' . "\n";
-                        $html .= 'jQuery.each(data, function(key, val) {' . "\n";
-                            $html .= 'jQuery(\'.varnishstats_' . $server . '\').append(\'<tr><td class="views-field views-field-title">\'+val.description+\'</td><td>\'+val.value+\'</td><td>\'+key+\'</td></tr>\');' . "\n";
-                        $html .= '});' . "\n";
-                    $html .= '});' . "\n";
-                $html .= '</script>' . "\n";
-            }
-            $html .= '<script type="text/javascript">' . "\n";
-                $html .= 'jQuery(\'a.server\').click(function(e){' . "\n";
-                    $html .= 'e.preventDefault();' . "\n";
-                    $html .= 'jQuery(\'li.links\').removeClass(\'active\');' . "\n";
-                    $html .= 'jQuery(this).parent().addClass(\'active\');' . "\n";
-                    $html .= 'jQuery(".servers").hide();' . "\n";
-                    $html .= 'jQuery(".server_" + jQuery(this).attr(\'server\')).show();' . "\n";
-                $html .= '});' . "\n";
-            $html .= '</script>' . "\n";
-        }
-        $html .= '</div>' . "\n";
-        $html .= '</fieldset>' . "\n";
-        return $html;
-    }
-
-    protected function _vcaching_cache_purge($server_ip, $server_port, $path = '/.*', $headers)
-    {
-        $fp = fsockopen($server_ip, $server_port, $errno, $errstr, 2);
-        if (!$fp) {
-            return array('error' => true, 'message' => $errstr .'(' . $errno . ')');
-        } else {
-            $out = "PURGE " . $path . " HTTP/1.0\n";
-            foreach ($headers as $key => $value) {
-                $out .= $key . ': '. $value . "\n";
-            }
-            $out .= "Connection: Close\n\n";
-            fwrite($fp, $out);
-            $ret = "";
-            while (!feof($fp)) {
-                $ret .= fgets($fp, 128);
-            }
-            fclose($fp);
-            return array('error' => false, 'message' => $ret);
-        }
-    }
-
-    public function downloadConf($version)
-    {
-        $tmpfile = tempnam("tmp", "zip");
-        $zip = new ZipArchive();
-        $zip->open($tmpfile, ZipArchive::OVERWRITE);
-        $files = array(
-            'default.vcl' => true,
-            'LICENSE' => false,
-            'README.rst' => false,
-            'conf/acl.vcl' => true,
-            'conf/backend.vcl' => true,
-            'lib/bigfiles.vcl' => false,
-            'lib/bigfiles_pipe.vcl' => false,
-            'lib/cloudflare.vcl' => false,
-            'lib/mobile_cache.vcl' => false,
-            'lib/mobile_pass.vcl' => false,
-            'lib/purge.vcl' => true,
-            'lib/static.vcl' => false,
-            'lib/xforward.vcl' => false,
-        );
-        $vcaching = new VCaching('vcaching_');
-        foreach ($files as $file => $parse) {
-            $filepath = __DIR__ . '/varnish-conf/v' . $version . '/' . $file;
-            if ($parse) {
-                $content = $vcaching->_parse_conf_file($version, $file, file_get_contents($filepath));
-            } else {
-                $content = file_get_contents($filepath);
-            }
-            $zip->addFromString($file, $content);
-        }
-        $zip->close();
-        header('Content-Type: application/zip');
-        header('Content-Length: ' . filesize($tmpfile));
-        header('Content-Disposition: attachment; filename="varnish_v' . $version . '_conf.zip"');
-        readfile($tmpfile);
-        unlink($tmpfile);
-        exit();
-    }
-
-    public function _parse_conf_file($version, $file, $content)
-    {
-        if ($file == 'default.vcl') {
-            $logged_in_cookie = variable_get($this->prefix . 'cookie');
-            $content = str_replace('c005492c65', $logged_in_cookie, $content);
-        } else if ($file == 'conf/backend.vcl') {
-            if ($version == 3) {
-                $content = "";
-            } else if ($version == 4) {
-                $content = "import directors;\n\n";
-            }
-            $backend = array();
-            $ips = variable_get($this->prefix . 'conf_backends');
-            $ips = explode(',', $ips);
-            $id = 1;
-            foreach ($ips as $ip) {
-                if (strstr($ip, ":")) {
-                    $_ip = explode(':', $ip);
-                    $ip = $_ip[0];
-                    $port = $_ip[1];
-                } else {
-                    $port = 80;
-                }
-                $content .= "backend backend" . $id . " {\n";
-                $content .= "\t.host = \"" . $ip . "\";\n";
-                $content .= "\t.port = \"" . $port . "\";\n";
-                $content .= "}\n";
-                $backend[3] .= "\t{\n";
-                $backend[3] .= "\t\t.backend = backend" . $id . ";\n";
-                $backend[3] .= "\t}\n";
-                $backend[4] .= "\tbackends.add_backend(backend" . $id . ");\n";
-                $id++;
-            }
-            if ($version == 3) {
-                $content .= "\ndirector backends round-robin {\n";
-                $content .= $backend[3];
-                $content .= "}\n";
-                $content .= "\nsub vcl_recv {\n";
-                $content .= "\tset req.backend = backends;\n";
-                $content .= "}\n";
-            } elseif ($version == 4) {
-                $content .= "\nsub vcl_init {\n";
-                $content .= "\tnew backends = directors.round_robin();\n";
-                $content .= $backend[4];
-                $content .= "}\n";
-                $content .= "\nsub vcl_recv {\n";
-                $content .= "\tset req.backend_hint = backends.backend();\n";
-                $content .= "}\n";
-            }
-        } else if ($file == 'conf/acl.vcl') {
-            $acls = variable_get($this->prefix . 'conf_acls');
-            $acls = explode(',', $acls);
-            $content = "acl cloudflare {\n";
-            $content .= "\t# set this ip to your Railgun IP (if applicable)\n";
-            $content .= "\t# \"1.2.3.4\";\n";
-            $content .= "}\n";
-            $content .= "\nacl purge {\n";
-            $content .= "\t\"localhost\";\n";
-            $content .= "\t\"127.0.0.1\";\n";
-            foreach ($acls as $acl) {
-                $content .= "\t\"" . $acl . "\";\n";
-            }
-            $content .= "}\n";
-        } else if ($file == 'lib/purge.vcl') {
-            $purge_key = variable_get($this->prefix . 'purge_key');
-            $content = str_replace('ff93c3cb929cee86901c7eefc8088e9511c005492c6502a930360c02221cf8f4', $purge_key, $content);
-        }
-        return $content;
-    }
+        $content .= "backend backend" . $id . " {\n";
+        $content .= "\t.host = \"" . $ip . "\";\n";
+        $content .= "\t.port = \"" . $port . "\";\n";
+        $content .= "}\n";
+        $backend[3] .= "\t{\n";
+        $backend[3] .= "\t\t.backend = backend" . $id . ";\n";
+        $backend[3] .= "\t}\n";
+        $backend[4] .= "\tbackends.add_backend(backend" . $id . ");\n";
+        $id++;
+      }
+      if ($version == 3) {
+        $content .= "\ndirector backends round-robin {\n";
+        $content .= $backend[3];
+        $content .= "}\n";
+        $content .= "\nsub vcl_recv {\n";
+        $content .= "\tset req.backend = backends;\n";
+        $content .= "}\n";
+      } elseif ($version == 4) {
+        $content .= "\nsub vcl_init {\n";
+        $content .= "\tnew backends = directors.round_robin();\n";
+        $content .= $backend[4];
+        $content .= "}\n";
+        $content .= "\nsub vcl_recv {\n";
+        $content .= "\tset req.backend_hint = backends.backend();\n";
+        $content .= "}\n";
+      }
+    } else if ($file == 'conf/acl.vcl') {
+      $acls = variable_get($this->prefix . 'conf_acls');
+      $acls = explode(',', $acls);
+      $content = "acl cloudflare {\n";
+      $content .= "\t# set this ip to your Railgun IP (if applicable)\n";
+      $content .= "\t# \"1.2.3.4\";\n";
+      $content .= "}\n";
+      $content .= "\nacl purge {\n";
+      $content .= "\t\"localhost\";\n";
+      $content .= "\t\"127.0.0.1\";\n";
+      foreach ($acls as $acl) {
+        $content .= "\t\"" . $acl . "\";\n";
+      }
+      $content .= "}\n";
+    } else if ($file == 'lib/purge.vcl') {
+      $purge_key = variable_get($this->prefix . 'purge_key');
+      $content = str_replace('ff93c3cb929cee86901c7eefc8088e9511c005492c6502a930360c02221cf8f4', $purge_key, $content);
+    }
+    return $content;
+  }
 }
 

--- a/vcaching.drush.inc
+++ b/vcaching.drush.inc
@@ -1,61 +1,74 @@
 <?php
 
 /**
+ * @file
+ * This file contains drush integration for the vcaching module.
+ */
+
+/**
  * Implements hook_drush_command().
+ *
+ * @return array
  */
 function vcaching_drush_command()
 {
-    $items = array();
-    $items['vcaching-purge-all'] = array(
-        'description' => 'Purge all pages in varnish.',
-        'drupal dependencies' => array('vcaching'),
-        'aliases' => array('vpa'),
-        'callback' => 'vcaching_purge_all',
+  $items = array();
+  $items['vcaching-purge-all'] = array(
+    'description' => 'Purge all pages in varnish.',
+    'drupal dependencies' => array('vcaching'),
+    'aliases' => array('vpa'),
+    'callback' => 'vcaching_purge_all',
     );
-    $items['vcaching-purge-urls'] = array(
-        'description' => "Purge a list of URLs in varnish.",
-        'arguments' => array(
-            'paths' => 'A list of paths to purge separated by ;. Regular expressions allowed.',
-        ),
-        'aliases' => array('vpu'),
-        'drupal dependencies' => array('vcaching'),
-        'callback' => 'vcaching_purge_urls',
+  $items['vcaching-purge-urls'] = array(
+    'description' => "Purge a list of URLs in varnish.",
+    'arguments' => array(
+      'paths' => 'A list of paths to purge separated by ;. Regular expressions allowed.',
+      ),
+    'aliases' => array('vpu'),
+    'drupal dependencies' => array('vcaching'),
+    'callback' => 'vcaching_purge_urls',
     );
-    return $items;
+  return $items;
 }
 
 /**
  * Callback for vcaching-purge-all drush command.
+ *
+ * @return void
  */
 function vcaching_purge_all()
 {
-    $vcaching = new VCaching('vcaching_');
-    drush_log(t('Purging all Varnish cache'), 'ok');
-    $vcaching->purgeUrl(base_path() . '?vc-regex');
-    drush_log($vcaching->getNoticeMessage(true), 'ok');
+  $vcaching = new VCaching('vcaching_');
+  drush_log(t('Purging all Varnish cache'), 'ok');
+  $vcaching->purgeUrl(base_path() . '?vc-regex');
+  drush_log($vcaching->getNoticeMessage(true), 'ok');
 }
 
 /**
  * Callback for vcaching-purge-urls drush command.
  *
  * @param string $paths A space separated list of paths.
+ * @return void
  */
 function vcaching_purge_urls($paths)
 {
-    $vcaching = new VCaching('vcaching_');
-    $paths = explode(";", $paths);
-    foreach ($paths as $path) {
-        drush_log("Purging Varnish cache path " . $path);
-        $vcaching->purgeUrl($path);
-    }
-    drush_log($vcaching->getNoticeMessage(true), 'ok');
+  $vcaching = new VCaching('vcaching_');
+  $paths = explode(";", $paths);
+  foreach ($paths as $path) {
+    drush_log("Purging Varnish cache path " . $path);
+    $vcaching->purgeUrl($path);
+  }
+  drush_log($vcaching->getNoticeMessage(true), 'ok');
 }
 
 /**
  * Implements hook_drush_cache_clear().
+ *
+ * @param array $types
+ * @return void
  */
 function vcaching_drush_cache_clear(&$types)
 {
-    $types['vcaching'] = 'vcaching_purge_all';
+  $types['vcaching'] = 'vcaching_purge_all';
 }
 

--- a/vcaching.info
+++ b/vcaching.info
@@ -2,7 +2,6 @@
 description = "Drupal Varnish Cache 3.x/4.x integration"
 package = "Varnish"
 core = 7.x
-version = "7.x-1.0"
 stylesheets[all][] = css/vcaching.css
 configure = admin/config/system/vcaching/settings
 files[] = vcaching.class.php

--- a/vcaching.install
+++ b/vcaching.install
@@ -2,8 +2,11 @@
 
 /**
  * Implements hook_uninstall().
+ *
+ * @return void
  */
-function vcaching_uninstall() {
+function vcaching_uninstall()
+{
     // Delete variables.
     variable_del('vcaching_enable');
     variable_del('vcaching_homepage_ttl');

--- a/vcaching.module
+++ b/vcaching.module
@@ -1,436 +1,470 @@
 <?php
 
+/**
+ * @file
+ * Functions used for the module.
+ */
+
 module_load_include('php', 'vcaching', 'vcaching.class');
 
 /**
- * Implements hook_help()
+ * Implements hook_help().
  */
 function vcaching_help($path, $arg) {
-    switch ($path) {
-        case 'admin/config/system/vcaching':
-            //return '<p>' . t('') . '</p>';
-        case 'admin/config/system/vcaching/console':
-            //return '<p>' . t('') . '</p>';
-        case 'admin/config/system/vcaching/stats':
-            //return '<p>' . t('') . '</p>';
+  switch ($path) {
+    case 'admin/config/system/vcaching':
+    return '';
+    case 'admin/config/system/vcaching/console':
+    return '';
+    case 'admin/config/system/vcaching/stats':
+    return '';
+  }
+}
+
+/**
+ * Implements hook_init().
+ */
+function vcaching_init()
+{
+  $enable = variable_get('vcaching_enable');
+  if ($enable) {
+    drupal_add_http_header('X-VC-Enabled', 'true');
+    if (user_is_logged_in()) {
+      drupal_add_http_header('X-VC-Cacheable', 'NO:User is logged in');
+      $ttl = 0;
+    } else {
+      if (drupal_is_front_page()) {
+        $ttl = variable_get('vcaching_homepage_ttl');
+      } else {
+        $ttl = variable_get('vcaching_ttl');
+      }
     }
-}
-
-/**
- * Implements hook_init()
- */
-function vcaching_init()
-{
-    $enable = variable_get('vcaching_enable');
-    if ($enable) {
-        drupal_add_http_header('X-VC-Enabled', 'true');
-        if (user_is_logged_in()) {
-            drupal_add_http_header('X-VC-Cacheable', 'NO:User is logged in');
-            $ttl = 0;
-        } else {
-            if (drupal_is_front_page()) {
-                $ttl = variable_get('vcaching_homepage_ttl');
-            } else {
-                $ttl = variable_get('vcaching_ttl');
-            }
-        }
-        drupal_add_http_header('X-VC-TTL', $ttl);
-        if (variable_get('vcaching_debug')) {
-            drupal_add_http_header('X-VC-Debug', 'true');
-        }
+    drupal_add_http_header('X-VC-TTL', $ttl);
+    if (variable_get('vcaching_debug')) {
+      drupal_add_http_header('X-VC-Debug', 'true');
+    }
+  } else {
+    drupal_add_http_header('X-VC-Enabled', 'false');
+  }
+}
+
+/**
+ * Implements hook_node_presave().
+ */
+function vcaching_node_presave($node)
+{
+  if (variable_get('vcaching_enable')) {
+    $vcaching = new VCaching('vcaching_');
+    if (variable_get('vcaching_clear_cache_node_save')) {
+      $vcaching->purgeUrl(base_path() . '?vc-regex');
     } else {
-        drupal_add_http_header('X-VC-Enabled', 'false');
+      $vcaching->purgeUrl(base_path() . $node->path['alias']);
     }
-}
-
-/**
- * Implements hook_node_presave()
- */
-function vcaching_node_presave($node)
-{
-    if (variable_get('vcaching_enable')) {
-        $vcaching = new VCaching('vcaching_');
-        if (variable_get('vcaching_clear_cache_node_save')) {
-            $vcaching->purgeUrl(base_path() . '?vc-regex');
-        } else {
-            $vcaching->purgeUrl(base_path() . $node->path['alias']);
-        }
-        drupal_set_message(t('Varnish cache cleared!') . $vcaching->getNoticeMessage());
-    }
-}
-
-/**
- * Purge a node from Varnish on delete.
- */
-function varnish_all_node_delete($node)
-{
-    if (variable_get('vcaching_enable')) {
-        $vcaching = new VCaching('vcaching_');
-        $vcaching->purgeUrl(base_path() . $node->path['alias']);
-        drupal_set_message(t('Varnish cache cleared!') . $vcaching->getNoticeMessage());
-    }
-}
-
-/**
- * Implements hook_menu()
+    drupal_set_message(t('Varnish cache cleared!') . $vcaching->getNoticeMessage());
+  }
+}
+
+/**
+ * Implements hook_node_delete().
+ *
+ * @param  object $node
+ * @return void
+ */
+function varnish_node_delete($node)
+{
+  if (variable_get('vcaching_enable')) {
+    $vcaching = new VCaching('vcaching_');
+    $vcaching->purgeUrl(base_path() . $node->path['alias']);
+    drupal_set_message(t('Varnish cache cleared!') . $vcaching->getNoticeMessage());
+  }
+}
+
+/**
+ * Implements hook_menu().
+ *
+ * @return array
  */
 function vcaching_menu()
 {
-    $items = array();
-
-    $items['admin/config/system/vcaching'] = array(
-        'title' => 'Varnish Caching',
-        'description' => 'Varnish Caching',
-        'page callback' => 'drupal_get_form',
-        'page arguments' => array('vcaching_console_form'),
-        'access arguments' => array('varnish caching console access'),
-        'type' => MENU_NORMAL_ITEM,
-        'weight' => 50,
-        'file' => 'system.admin.inc',
-        'file path' => drupal_get_path('module', 'system')
-    );
-
-    $items['admin/config/system/vcaching/settings'] = array(
-        'title' => 'Settings',
-        'description' => 'Varnish Caching Setings',
-        'page callback' => 'drupal_get_form',
-        'page arguments' => array('vcaching_settings_form'),
-        'access arguments' => array('varnish caching settings access'),
-        'type' => MENU_LOCAL_TASK,
-        'weight' => 10
-    );
-
-    $items['admin/config/system/vcaching/console'] = array(
-        'title' => 'Console',
-        'description' => 'Varnish Caching Console',
-        'page callback' => 'drupal_get_form',
-        'page arguments' => array('vcaching_console_form'),
-        'access arguments' => array('varnish caching console access'),
-        'type' => MENU_DEFAULT_LOCAL_TASK,
-        'weight' => 20
-    );
-
-    $items['admin/config/system/vcaching/stats'] = array(
-        'title' => 'Stats',
-        'description' => 'Varnish Caching Stats',
-        'page callback' => 'vcaching_stats_form',
-        'page arguments' => array(),
-        'access callback' => true,
-        'access arguments' => array('varnish caching stats access'),
-        'type' => MENU_LOCAL_TASK,
-        'weight' => 30
-    );
-
-    $items['admin/config/system/vcaching/conf'] = array(
-        'title' => 'Varnish VCLs',
-        'description' => 'Varnish Cache configuration',
-        'page callback' => 'drupal_get_form',
-        'page arguments' => array('vcaching_conf_form'),
-        'access arguments' => array('varnish caching settings access'),
-        'type' => MENU_LOCAL_TASK,
-        'weight' => 40
-    );
-
-    $items['vcaching_purge_all_cache'] = array(
-        'title' => 'Purge Varnish cache',
-        'description' => 'Clear all cache',
-        'page callback' => 'vcaching_purge_all_cache_callback',
-        'access arguments' => array('varnish caching purge all'),
-        'menu_name' => 'shortcut-set-1',
-        'type' => MENU_NORMAL_ITEM,
-        'weight' => 10
-    );
-
-    return $items;
-}
-
-/**
- * Implements hook_permission()
+  $items = array();
+
+  $items['admin/config/system/vcaching'] = array(
+    'title' => 'Varnish Caching',
+    'description' => 'Varnish Caching',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('vcaching_console_form'),
+    'access arguments' => array('varnish caching console access'),
+    'type' => MENU_NORMAL_ITEM,
+    'weight' => 50,
+    'file' => 'system.admin.inc',
+    'file path' => drupal_get_path('module', 'system')
+    );
+
+  $items['admin/config/system/vcaching/settings'] = array(
+    'title' => 'Settings',
+    'description' => 'Varnish Caching Setings',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('vcaching_settings_form'),
+    'access arguments' => array('varnish caching settings access'),
+    'type' => MENU_LOCAL_TASK,
+    'weight' => 10
+    );
+
+  $items['admin/config/system/vcaching/console'] = array(
+    'title' => 'Console',
+    'description' => 'Varnish Caching Console',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('vcaching_console_form'),
+    'access arguments' => array('varnish caching console access'),
+    'type' => MENU_DEFAULT_LOCAL_TASK,
+    'weight' => 20
+    );
+
+  $items['admin/config/system/vcaching/stats'] = array(
+    'title' => 'Stats',
+    'description' => 'Varnish Caching Stats',
+    'page callback' => 'vcaching_stats_form',
+    'page arguments' => array(),
+    'access callback' => true,
+    'access arguments' => array('varnish caching stats access'),
+    'type' => MENU_LOCAL_TASK,
+    'weight' => 30
+    );
+
+  $items['admin/config/system/vcaching/conf'] = array(
+    'title' => 'Varnish VCLs',
+    'description' => 'Varnish Cache configuration',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('vcaching_conf_form'),
+    'access arguments' => array('varnish caching settings access'),
+    'type' => MENU_LOCAL_TASK,
+    'weight' => 40
+    );
+
+  $items['vcaching_purge_all_cache'] = array(
+    'title' => 'Purge Varnish cache',
+    'description' => 'Clear all cache',
+    'page callback' => 'vcaching_purge_all_cache_callback',
+    'access arguments' => array('varnish caching purge all'),
+    'menu_name' => 'shortcut-set-1',
+    'type' => MENU_NORMAL_ITEM,
+    'weight' => 10
+    );
+
+  return $items;
+}
+
+/**
+ * Implements hook_permission().
+ *
+ * @return array
  */
 function vcaching_permission() {
-    return array(
-        'varnish caching purge all' => array(
-            'title' => t('Purge all Varnish cache from shortcut'),
-        ),
-        'varnish caching settings access' => array(
-            'title' => t('Change settings'),
-        ),
-        'varnish caching console access' => array(
-            'title' => t('Use the console'),
-        ),
-        'varnish caching stats access' => array(
-            'title' => t('View stats'),
-        )
-    );
-}
-
-/**
- * Settings form
+  return array(
+    'varnish caching purge all' => array(
+      'title' => t('Purge all Varnish cache from shortcut'),
+      ),
+    'varnish caching settings access' => array(
+      'title' => t('Change settings'),
+      ),
+    'varnish caching console access' => array(
+      'title' => t('Use the console'),
+      ),
+    'varnish caching stats access' => array(
+      'title' => t('View stats'),
+      )
+    );
+}
+
+/**
+ * Settings form.
+ *
+ * @return array
  */
 function vcaching_settings_form()
 {
-    $form = array();
-    $form['general'] = array(
-        '#type' => 'fieldset',
-        '#title' => t('Settings'),
-        '#weight' => 5,
-        '#collapsible' => false,
-        '#collapsed' => false
-    );
-    $form['general']['vcaching_enable'] = array(
-        '#type' => 'checkbox',
-        '#title' => t('Enable'),
-        '#description' => t('Enable Varnish Caching'),
-        '#default_value' => variable_get('vcaching_enable', '0'),
-        '#title_display' => 'before'
-    );
-    $form['general']['vcaching_homepage_ttl'] = array(
-        '#type' => 'textfield',
-        '#title' => t('Homepage cache TTL'),
-        '#description' => t('Time to live in seconds in Varnish cache for homepage'),
-        '#default_value' => variable_get('vcaching_homepage_ttl', '600'),
-        '#size' => 10,
-        '#maxlength' => 10,
-        '#required' => TRUE,
-    );
-    $form['general']['vcaching_ttl'] = array(
-        '#type' => 'textfield',
-        '#title' => t('Cache TTL'),
-        '#description' => t('Time to live in seconds in Varnish cache'),
-        '#default_value' => variable_get('vcaching_ttl', '600'),
-        '#size' => 10,
-        '#maxlength' => 10,
-        '#required' => TRUE,
-    );
-    $form['general']['vcaching_ips'] = array(
-        '#type' => 'textfield',
-        '#title' => t('IPs'),
-        '#description' => t('Comma separated ip/ip:port. Example : 192.168.0.2,192.168.0.3:8080'),
-        '#default_value' => variable_get('vcaching_ips', '127.0.0.1'),
-        '#size' => 60,
-        '#maxlength' => 500,
-        '#required' => TRUE,
-    );
-    $form['general']['vcaching_dynamic_host'] = array(
-        '#type' => 'checkbox',
-        '#title' => t('Dynamic host'),
-        '#description' => t('Uses the $_SERVER[\'HTTP_HOST\'] as hash for Varnish. This means the purge cache action will work on the domain you\'re on. Use this option if you use only one domain.'),
-        '#default_value' => variable_get('vcaching_dynamic_host', 0)
-    );
-    if (variable_get('vcaching_dynamic_host') == 0) {
-        $form['general']['vcaching_hosts'] = array(
-            '#type' => 'textfield',
-            '#title' => t('Hosts'),
-            '#description' => t('Comma separated hostnames. Varnish uses the hostname to create the cache hash. For each IP, you must set a hostname. Use this option if you use multiple domains.'),
-            '#default_value' => variable_get('vcaching_hosts', 'example.com'),
-            '#size' => 60,
-            '#maxlength' => 500,
-            '#required' => TRUE,
-        );
-    }
-    $form['general']['vcaching_purge_key'] = array(
-        '#type' => 'textfield',
-        '#title' => t('Purge key'),
-        '#suffix' => '<div class="description">' . t('Key used to purge Varnish cache. It is sent to Varnish as X-VC-Purge-Key header. Use a SHA-256 hash. If you can\'t use ACL\'s, use this option. You can set the `purge key` in lib/purge.vcl.<br />Search the default value ff93c3cb929cee86901c7eefc8088e9511c005492c6502a930360c02221cf8f4 to find where to replace it.') . '</div>',
-        '#field_suffix' => '<span class="vcaching-reload" onclick="generateHash(64, 0, \'edit-vcaching-purge-key\'); return false;" title="' . t('Generate') . '"></span>',
-        '#default_value' => variable_get('vcaching_purge_key', 'ff93c3cb929cee86901c7eefc8088e9511c005492c6502a930360c02221cf8f4'),
-        '#size' => 100,
-        '#maxlength' => 64,
-        '#required' => TRUE,
-    );
-    $form['general']['vcaching_cookie'] = array(
-        '#type' => 'textfield',
-        '#title' => t('Logged in cookie'),
-        '#suffix' => '<div class="description">' . t('This module sets a special cookie to tell Varnish that the user is logged in. This should be a random 10 chars string [0-9a-z]. You can set the `logged in cookie` in default.vcl.<br />Search the default value <i>c005492c65</i> to find where to replace it.') . '</div>',
-        '#field_suffix' => '<span class="vcaching-reload" onclick="generateHash(10, 0, \'edit-vcaching-cookie\'); return false;" title="' . t('Generate') . '"></span>',
-        '#default_value' => variable_get('vcaching_cookie', 'c005492c65'),
-        '#size' => 10,
-        '#maxlength' => 10,
-        '#required' => TRUE,
-    );
-    $form['general']['vcaching_stats_json_file'] = array(
-        '#type' => 'textfield',
-        '#title' => t('Statistics JSONs'),
-        '#suffix' => '<div class="description">' . t('Comma separated relative URLs. One for each IP. <a href="vcaching/stats?info=1">Click here</a> for more info on how to set this up.') . '</div>',
-        '#default_value' => variable_get('vcaching_stats_json_file', '/varnishstats.json'),
-        '#size' => 100,
-        '#maxlength' => 128
-    );
-    $form['general']['vcaching_clear_cache_node_save'] = array(
-        '#type' => 'checkbox',
-        '#title' => t('Clear all cache on node save'),
-        '#description' => t('If this option is on, each node save will trigger a full cache purge (/.*). If it\'s off, only the pages associated with the node will be purged.'),
-        '#default_value' => variable_get('vcaching_clear_cache_node_save', 0),
-        '#title_display' => 'before'
-    );
-    $form['general']['vcaching_debug'] = array(
-        '#type' => 'checkbox',
-        '#title' => t('Enable debug'),
-        '#description' => t('Send all debugging headers to the client. Also shows complete response from Varnish on purge all.'),
-        '#default_value' => variable_get('vcaching_debug', 0),
-        '#title_display' => 'before'
-    );
-
-    drupal_add_js('
-        function generateHash(length, bits, id) {
-            bits = bits || 36;
-            var outStr = "", newStr;
-            while (outStr.length < length)
-            {
-                newStr = Math.random().toString(bits).slice(2);
-                outStr += newStr.slice(0, Math.min(newStr.length, (length - outStr.length)));
-            }
-            jQuery("#" + id).val(outStr);
-        };', 'inline');
-
-    return system_settings_form($form);
-}
-
-/**
- * Console form
+  $form = array();
+  $form['general'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Settings'),
+    '#weight' => 5,
+    '#collapsible' => false,
+    '#collapsed' => false
+    );
+  $form['general']['vcaching_enable'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Enable'),
+    '#description' => t('Enable Varnish Caching'),
+    '#default_value' => variable_get('vcaching_enable', '0'),
+    '#title_display' => 'before'
+    );
+  $form['general']['vcaching_homepage_ttl'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Homepage cache TTL'),
+    '#description' => t('Time to live in seconds in Varnish cache for homepage'),
+    '#default_value' => variable_get('vcaching_homepage_ttl', '600'),
+    '#size' => 10,
+    '#maxlength' => 10,
+    '#required' => TRUE,
+    );
+  $form['general']['vcaching_ttl'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Cache TTL'),
+    '#description' => t('Time to live in seconds in Varnish cache'),
+    '#default_value' => variable_get('vcaching_ttl', '600'),
+    '#size' => 10,
+    '#maxlength' => 10,
+    '#required' => TRUE,
+    );
+  $form['general']['vcaching_ips'] = array(
+    '#type' => 'textfield',
+    '#title' => t('IPs'),
+    '#description' => t('Comma separated ip/ip:port. Example : 192.168.0.2,192.168.0.3:8080'),
+    '#default_value' => variable_get('vcaching_ips', '127.0.0.1'),
+    '#size' => 60,
+    '#maxlength' => 500,
+    '#required' => TRUE,
+    );
+  $form['general']['vcaching_dynamic_host'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Dynamic host'),
+    '#description' => t('Uses the $_SERVER[\'HTTP_HOST\'] as hash for Varnish. This means the purge cache action will work on the domain you\'re on. Use this option if you use only one domain.'),
+    '#default_value' => variable_get('vcaching_dynamic_host', 0)
+    );
+  if (variable_get('vcaching_dynamic_host') == 0) {
+    $form['general']['vcaching_hosts'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Hosts'),
+      '#description' => t('Comma separated hostnames. Varnish uses the hostname to create the cache hash. For each IP, you must set a hostname. Use this option if you use multiple domains.'),
+      '#default_value' => variable_get('vcaching_hosts', 'example.com'),
+      '#size' => 60,
+      '#maxlength' => 500,
+      '#required' => TRUE,
+      );
+  }
+  $form['general']['vcaching_purge_key'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Purge key'),
+    '#suffix' => '<div class="description">' . t('Key used to purge Varnish cache. It is sent to Varnish as X-VC-Purge-Key header. Use a SHA-256 hash. If you can\'t use ACL\'s, use this option. You can set the `purge key` in lib/purge.vcl.<br />Search the default value ff93c3cb929cee86901c7eefc8088e9511c005492c6502a930360c02221cf8f4 to find where to replace it.') . '</div>',
+    '#field_suffix' => '<span class="vcaching-reload" onclick="generateHash(64, 0, \'edit-vcaching-purge-key\'); return false;" title="' . t('Generate') . '"></span>',
+    '#default_value' => variable_get('vcaching_purge_key', 'ff93c3cb929cee86901c7eefc8088e9511c005492c6502a930360c02221cf8f4'),
+    '#size' => 100,
+    '#maxlength' => 64,
+    '#required' => TRUE,
+    );
+  $form['general']['vcaching_cookie'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Logged in cookie'),
+    '#suffix' => '<div class="description">' . t('This module sets a special cookie to tell Varnish that the user is logged in. This should be a random 10 chars string [0-9a-z]. You can set the `logged in cookie` in default.vcl.<br />Search the default value <i>c005492c65</i> to find where to replace it.') . '</div>',
+    '#field_suffix' => '<span class="vcaching-reload" onclick="generateHash(10, 0, \'edit-vcaching-cookie\'); return false;" title="' . t('Generate') . '"></span>',
+    '#default_value' => variable_get('vcaching_cookie', 'c005492c65'),
+    '#size' => 10,
+    '#maxlength' => 10,
+    '#required' => TRUE,
+    );
+  $form['general']['vcaching_stats_json_file'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Statistics JSONs'),
+    '#suffix' => '<div class="description">' . t('Comma separated relative URLs. One for each IP. <a href="vcaching/stats?info=1">Click here</a> for more info on how to set this up.') . '</div>',
+    '#default_value' => variable_get('vcaching_stats_json_file', '/varnishstats.json'),
+    '#size' => 100,
+    '#maxlength' => 128
+    );
+  $form['general']['vcaching_clear_cache_node_save'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Clear all cache on node save'),
+    '#description' => t('If this option is on, each node save will trigger a full cache purge (/.*). If it\'s off, only the pages associated with the node will be purged.'),
+    '#default_value' => variable_get('vcaching_clear_cache_node_save', 0),
+    '#title_display' => 'before'
+    );
+  $form['general']['vcaching_debug'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Enable debug'),
+    '#description' => t('Send all debugging headers to the client. Also shows complete response from Varnish on purge all.'),
+    '#default_value' => variable_get('vcaching_debug', 0),
+    '#title_display' => 'before'
+    );
+
+  drupal_add_js('
+    function generateHash(length, bits, id) {
+      bits = bits || 36;
+      var outStr = "", newStr;
+      while (outStr.length < length)
+      {
+        newStr = Math.random().toString(bits).slice(2);
+        outStr += newStr.slice(0, Math.min(newStr.length, (length - outStr.length)));
+      }
+      jQuery("#" + id).val(outStr);
+    };', 'inline');
+
+  return system_settings_form($form);
+}
+
+/**
+ * Console form.
+ *
+ * @return array
  */
 function vcaching_console_form()
 {
-    $form = array();
-    $form['action'] = array(
-        '#type' => 'fieldset',
-        '#title' => t('Console'),
-        '#weight' => 5,
-        '#collapsible' => false,
-        '#collapsed' => false
-    );
-    $form['action']['vcaching_console_url'] = array(
-        '#type' => 'textfield',
-        '#title' => t('Relative URL'),
-        '#description' => t('Relative URL to purge. Example : /uploads/.*'),
-        '#default_value' => variable_get('vcaching_console_url', '/.*'),
-        '#size' => 60,
-        '#maxlength' => 500,
-        '#required' => TRUE,
-    );
-    $form['action']['submit'] = array('#type' => 'submit', '#value' => t('Purge cache'), '#submit' => array('vcaching_console_form_submit'));
-    return system_settings_form($form);
+  $form = array();
+  $form['action'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Console'),
+    '#weight' => 5,
+    '#collapsible' => false,
+    '#collapsed' => false
+    );
+  $form['action']['vcaching_console_url'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Relative URL'),
+    '#description' => t('Relative URL to purge. Example : /uploads/.*'),
+    '#default_value' => variable_get('vcaching_console_url', '/.*'),
+    '#size' => 60,
+    '#maxlength' => 500,
+    '#required' => TRUE,
+    );
+  $form['action']['submit'] = array('#type' => 'submit', '#value' => t('Purge cache'), '#submit' => array('vcaching_console_form_submit'));
+  return system_settings_form($form);
 }
 
 /**
  * Console form submit
+ *
+ * @return void
  */
 function vcaching_console_form_submit($form, &$form_state)
 {
-    if (variable_get('vcaching_enable')) {
-        $vcaching = new VCaching('vcaching_');
-        $vcaching->purgeUrl($_POST['vcaching_console_url']);
-        drupal_set_message(t('Varnish cache cleared!') . $vcaching->getNoticeMessage());
-    }
+  if (variable_get('vcaching_enable')) {
+    $vcaching = new VCaching('vcaching_');
+    $vcaching->purgeUrl($_POST['vcaching_console_url']);
+    drupal_set_message(t('Varnish cache cleared!') . $vcaching->getNoticeMessage());
+  }
 }
 
 /**
  * Stats form
+ *
+ * @return void|string
  */
 function vcaching_stats_form()
 {
-    if (variable_get('vcaching_enable')) {
-        $vcaching = new VCaching('vcaching_');
-        return $vcaching->stats();
-    }
+  if (variable_get('vcaching_enable')) {
+    $vcaching = new VCaching('vcaching_');
+    return $vcaching->stats();
+  }
 }
 
 /**
  * Conf form
+ *
+ * @return array
  */
 function vcaching_conf_form()
 {
-    $form = array();
-    $form['general'] = array(
-        '#type' => 'fieldset',
-        '#title' => t('Varnish Cache configuration'),
-        '#weight' => 5,
-        '#collapsible' => false,
-        '#collapsed' => false
-    );
-    $form['general']['vcaching_conf_backends'] = array(
-        '#type' => 'textfield',
-        '#title' => t('Backends'),
-        '#description' => t('Comma separated ip/ip:port. Example : 192.168.0.2,192.168.0.3:8080'),
-        '#default_value' => variable_get('vcaching_conf_backends'),
-        '#size' => 60,
-        '#required' => true
-    );
-    $form['general']['vcaching_conf_acls'] = array(
-        '#type' => 'textfield',
-        '#title' => t('ACLs'),
-        '#description' => t('Comma separated ip/ip range. Example : 192.168.0.2,192.168.1.1/24'),
-        '#default_value' => variable_get('vcaching_conf_acls'),
-        '#size' => 60,
-        '#required' => true
-    );
-    $form['general']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
-    $form['action'] = array(
-        '#type' => 'fieldset',
-        '#title' => t('Get configuration files'),
-        '#weight' => 5,
-        '#collapsible' => false,
-        '#collapsed' => false
-    );
-    $form['action']['vcaching_conf_version'] = array(
-        '#type' => 'select',
-        '#title' => t('Version'),
-        '#description' => t('Varnish Cache version'),
-        '#options' => array(3 => 3,4 => 4),
-        '#default_value' => 3,
-        '#required' => true
-    );
-    $form['action']['submit'] = array('#type' => 'submit', '#value' => t('Download'), '#submit' => array('vcaching_conf_form_submit'));
-    return system_settings_form($form);
+  $form = array();
+  $form['general'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Varnish Cache configuration'),
+    '#weight' => 5,
+    '#collapsible' => false,
+    '#collapsed' => false
+    );
+  $form['general']['vcaching_conf_backends'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Backends'),
+    '#description' => t('Comma separated ip/ip:port. Example : 192.168.0.2,192.168.0.3:8080'),
+    '#default_value' => variable_get('vcaching_conf_backends'),
+    '#size' => 60,
+    '#required' => true
+    );
+  $form['general']['vcaching_conf_acls'] = array(
+    '#type' => 'textfield',
+    '#title' => t('ACLs'),
+    '#description' => t('Comma separated ip/ip range. Example : 192.168.0.2,192.168.1.1/24'),
+    '#default_value' => variable_get('vcaching_conf_acls'),
+    '#size' => 60,
+    '#required' => true
+    );
+  $form['general']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
+  $form['action'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Get configuration files'),
+    '#weight' => 5,
+    '#collapsible' => false,
+    '#collapsed' => false
+    );
+  $form['action']['vcaching_conf_version'] = array(
+    '#type' => 'select',
+    '#title' => t('Version'),
+    '#description' => t('Varnish Cache version'),
+    '#options' => array(3 => 3,4 => 4),
+    '#default_value' => 3,
+    '#required' => true
+    );
+  $form['action']['submit'] = array('#type' => 'submit', '#value' => t('Download'), '#submit' => array('vcaching_conf_form_submit'));
+  return system_settings_form($form);
 }
 
 /**
  * Implements form_alter()
+ *
+ * @return void
  */
 function vcaching_form_alter(&$form, &$form_state, $form_id)
 {
-    if ($form_id == 'vcaching_conf_form') {
-        unset($form['actions']['submit']);
-    }
+  if ($form_id == 'vcaching_conf_form') {
+    unset($form['actions']['submit']);
+  }
 }
 
 /**
  * Conf form submit
+ *
+ * @return void
  */
 function vcaching_conf_form_submit($form, &$form_state)
 {
-    $version = in_array($_POST['vcaching_conf_version'], array(3,4)) ? $_POST['vcaching_conf_version'] : 3;
-    if (variable_get('vcaching_enable')) {
-        $vcaching = new VCaching('vcaching_');
-        $vcaching->downloadConf($version);
-    }
+  $version = in_array($_POST['vcaching_conf_version'], array(3,4)) ? $_POST['vcaching_conf_version'] : 3;
+  if (variable_get('vcaching_enable')) {
+    $vcaching = new VCaching('vcaching_');
+    $vcaching->downloadConf($version);
+  } else {
+    drupal_goto($_SERVER['HTTP_REFERER']);
+  }
 }
 
 /**
  * Shortcut callback
+ *
+ * @return void
  */
 function vcaching_purge_all_cache_callback()
 {
-    if (variable_get('vcaching_enable')) {
-        $vcaching = new VCaching('vcaching_');
-        $vcaching->purgeUrl(base_path() . '?vc-regex');
-        drupal_set_message(t('Varnish cache cleared!') . $vcaching->getNoticeMessage());
-    }
-    drupal_goto($_SERVER['HTTP_REFERER']);
+  if (variable_get('vcaching_enable')) {
+    $vcaching = new VCaching('vcaching_');
+    $vcaching->purgeUrl(base_path() . '?vc-regex');
+    drupal_set_message(t('Varnish cache cleared!') . $vcaching->getNoticeMessage());
+  }
+  drupal_goto($_SERVER['HTTP_REFERER']);
 }
 
 /**
  * Implements hook_user_login()
+ *
+ * @return void
  */
 function vcaching_user_login(&$edit, $account)
 {
-    user_cookie_save(array(variable_get('vcaching_cookie') => 1));
+  user_cookie_save(array(variable_get('vcaching_cookie') => 1));
 }
 
 /**
  * Implements hook_user_logout()
+ *
+ * @return void
  */
 function vcaching_user_logout($account)
 {
-    user_cookie_delete(variable_get('vcaching_cookie'));
-}
+  user_cookie_delete(variable_get('vcaching_cookie'));
+}

comments