From eb700a58b791eac7ba29ea2f3aa393083a5da7b9 Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Thu, 9 Aug 2007 22:03:28 +0000 Subject: [PATCH] Create a temporary directory called silverstripe-cache in the project folder if access to the tmp folder is restricted git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@39797 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/Core.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/core/Core.php b/core/Core.php index daeb4ce43..02956db90 100755 --- a/core/Core.php +++ b/core/Core.php @@ -15,7 +15,22 @@ function getTempFolder() { } $ssTmp = "$sysTmp/silverstripe-cache"; - if(!file_exists($ssTmp)) mkdir($ssTmp); + if(!file_exists($ssTmp)) { + @$worked = mkdir($ssTmp); + } + if(!$worked) { + $ssTmp = dirname(dirname($_SERVER['SCRIPT_FILENAME'])) . "/silverstripe-cache"; + $worked = true; + if(!file_exists($ssTmp)) { + @$worked = mkdir($ssTmp); + } + } + if(!$worked) { + user_error("Permission problem gaining access to a temp folder. " . + "Please create a folder named silverstripe-cache in the base folder " . + "of the installation and ensure it has the correct permissions", E_USER_ERROR); + } + return $ssTmp; }