Index: Makefile
===================================================================
--- Makefile	(revision 2999)
+++ Makefile	(revision 3260)
@@ -25,7 +25,8 @@
 	       ./$(DC)/features ./$(DC)/travis ./$(DC)/behat.yml.dist ./$(DC)/composer.*
 
-	## Create cache, db, plugins and public folders
-	mkdir ./$(DC)/cache ./$(DC)/db ./$(DC)/plugins ./$(DC)/public ./$(DC)/themes
+	## Create cache, var, db, plugins, themes and public folders
+	mkdir ./$(DC)/cache ./$(DC)/var ./$(DC)/db ./$(DC)/plugins ./$(DC)/themes ./$(DC)/public
 	cp -p inc/.htaccess ./$(DC)/cache/
+	cp -p inc/.htaccess ./$(DC)/var/
 	cp -p inc/.htaccess ./$(DC)/db/
 	cp -p inc/.htaccess ./$(DC)/plugins/
@@ -73,5 +74,5 @@
 	## Create digest
 	cd $(DC) && ( \
-		md5sum `find . -type f -not -path "./inc/digest" -not -path "./cache/*" -not -path "./db/*" -not -path ./CHANGELOG` \
+		md5sum `find . -type f -not -path "./inc/digest" -not -path "./cache/*" -not -path "./var/*" -not -path "./db/*" -not -path ./CHANGELOG` \
 		> inc/digests \
 	)
Index: admin/index.php
===================================================================
--- admin/index.php	(revision 3238)
+++ admin/index.php	(revision 3260)
@@ -13,4 +13,9 @@
 if (!empty($_GET['pf'])) {
 	require dirname(__FILE__).'/../inc/load_plugin_file.php';
+	exit;
+}
+
+if (!empty($_GET['vf'])) {
+	require dirname(__FILE__).'/../inc/load_var_file.php';
 	exit;
 }
Index: inc/config.php.in
===================================================================
--- inc/config.php.in	(revision 3137)
+++ inc/config.php.in	(revision 3260)
@@ -52,4 +52,7 @@
 define('DC_TPL_CACHE',path::real(dirname(__FILE__).'/..').'/cache');
 
+// Var directory
+define('DC_VAR',path::real(dirname(__FILE__).'/..').'/var');
+
 
 // If you have PATH_INFO issue, uncomment following lines
Index: inc/dbschema/upgrade.php
===================================================================
--- inc/dbschema/upgrade.php	(revision 3237)
+++ inc/dbschema/upgrade.php	(revision 3260)
@@ -544,4 +544,7 @@
 			@unlink(DC_ROOT.'/'.'admin/js/jsUpload/vendor/jquery.ui.widget.js');
 			@rmdir(DC_ROOT.'/'.'admin/js/jsUpload/vendor');
+
+			# Create new var directory
+			@files::makeDir(DC_VAR);
 		}
 
Index: inc/load_var_file.php
===================================================================
--- inc/load_var_file.php	(revision 3260)
+++ inc/load_var_file.php	(revision 3260)
@@ -0,0 +1,86 @@
+<?php
+# -- BEGIN LICENSE BLOCK ---------------------------------------
+#
+# This file is part of Dotclear 2.
+#
+# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear
+# Licensed under the GPL version 2.0 license.
+# See LICENSE file or
+# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+#
+# -- END LICENSE BLOCK -----------------------------------------
+
+#  ClearBricks and DotClear classes auto-loader
+if (@is_dir('/usr/lib/clearbricks')) {
+	define('CLEARBRICKS_PATH','/usr/lib/clearbricks');
+} elseif (is_dir(dirname(__FILE__).'/libs/clearbricks')) {
+	define('CLEARBRICKS_PATH',dirname(__FILE__).'/libs/clearbricks');
+} elseif (isset($_SERVER['CLEARBRICKS_PATH']) && is_dir($_SERVER['CLEARBRICKS_PATH'])) {
+	define('CLEARBRICKS_PATH',$_SERVER['CLEARBRICKS_PATH']);
+}
+
+if (!defined('CLEARBRICKS_PATH') || !is_dir(CLEARBRICKS_PATH)) {
+	exit('No clearbricks path defined');
+}
+
+require CLEARBRICKS_PATH.'/_common.php';
+
+if (isset($_SERVER['DC_RC_PATH'])) {
+	define('DC_RC_PATH',$_SERVER['DC_RC_PATH']);
+} elseif (isset($_SERVER['REDIRECT_DC_RC_PATH'])) {
+	define('DC_RC_PATH',$_SERVER['REDIRECT_DC_RC_PATH']);
+} else {
+	define('DC_RC_PATH',dirname(__FILE__).'/config.php');
+}
+
+if (!is_file(DC_RC_PATH)) {
+	trigger_error('Unable to open config file',E_USER_ERROR);
+	exit;
+}
+
+require DC_RC_PATH;
+
+if (empty($_GET['vf'])) {
+	header('Content-Type: text/plain');
+	http::head(404,'Not Found');
+	exit;
+}
+
+// $_GET['v'] : version in url to bypass cache in case of dotclear upgrade or in dev mode
+// but don't care of value
+if (isset($_GET['v']))
+{
+    unset($_GET['v']);
+}
+
+// Only $_GET['vf'] is allowed in URL
+if (count($_GET) > 1)
+{
+    header('Content-Type: text/plain');
+    http::head(403,'Forbidden');
+    exit;
+}
+
+$allow_types = array('png','jpg','jpeg','gif','css','js','swf','svg','html');
+
+$vf = path::clean($_GET['vf']);
+$VF = path::real(DC_VAR.'/'.$vf);
+
+if ($VF === false || !is_file($VF) || !is_readable($VF)) {
+	header('Content-Type: text/plain');
+	http::head(404,'Not Found');
+	exit;
+}
+
+if (!in_array(files::getExtension($VF),$allow_types)) {
+	header('Content-Type: text/plain');
+	http::head(404,'Not Found');
+	exit;
+}
+
+http::$cache_max_age = 7 * 24 * 60 * 60;	// One week cache for var files served by ?vf=…
+http::cache(array_merge(array($VF),get_included_files()));
+
+header('Content-Type: '.files::getMimeType($VF));
+readfile($VF);
+exit;
Index: inc/prepend.php
===================================================================
--- inc/prepend.php	(revision 3255)
+++ inc/prepend.php	(revision 3260)
@@ -197,8 +197,27 @@
 	if (strlen(crypt::hmac(DC_MASTER_KEY,DC_VENDOR_NAME,DC_CRYPT_ALGO)) < 40) {
 		if (!defined('DC_CONTEXT_ADMIN')) {
-			exit('Site temporarily unavailable');
+			__error('Server error','Site temporarily unavailable');
 		} else {
-			exit(DC_CRYPT_ALGO.' cryptographic algorithm configured is not strong enough, please change it.');
-		}
+			__error('Dotclear error',DC_CRYPT_ALGO.' cryptographic algorithm configured is not strong enough, please change it.');
+		}
+		exit;
+	}
+}
+
+if (!defined('DC_VAR')) {
+	define('DC_VAR',path::real(dirname(__FILE__).'/..').'/var');
+}
+// Check existence of var directory
+if (!is_dir(DC_VAR)) {
+	// Try to create it
+	@files::makeDir(DC_VAR);
+	if (!is_dir(DC_VAR)) {
+		// Admin must create it
+		if (!defined('DC_CONTEXT_ADMIN')) {
+			__error('Server error','Site temporarily unavailable');
+		} else {
+			__error('Dotclear error',DC_VAR.' directory does not exist. Please create it.');
+		}
+		exit;
 	}
 }
Index: inc/public/prepend.php
===================================================================
--- inc/public/prepend.php	(revision 3059)
+++ inc/public/prepend.php	(revision 3260)
@@ -13,4 +13,9 @@
 if (!empty($_GET['pf'])) {
 	require dirname(__FILE__).'/../load_plugin_file.php';
+	exit;
+}
+
+if (!empty($_GET['vf'])) {
+	require dirname(__FILE__).'/../load_var_file.php';
 	exit;
 }
