Index: branches/unlabeled/unlabeled-1.14.2/core/kernel/parser/template.php =================================================================== diff -u -r5741 -r5843 --- branches/unlabeled/unlabeled-1.14.2/core/kernel/parser/template.php (.../template.php) (revision 5741) +++ branches/unlabeled/unlabeled-1.14.2/core/kernel/parser/template.php (.../template.php) (revision 5843) @@ -199,19 +199,31 @@ if (file_exists($fname) && file_exists($tname) && filemtime($fname) > filemtime($tname)) { return array('active' => 1, 'fname' => $fname, 'tname' => $tname, 'mode' => 'file'); } - if (!file_exists($fname)) $this->CheckDir(dirname($fname)); //make sure to create directory if pre-parsed file does not exist + if (!file_exists($fname)) { + // make sure to create directory if pre-parsed file does not exist + $this->CheckDir(dirname($fname), FULL_PATH.'/kernel/cache'); + } } return array('active' => 0, 'fname' => $fname, 'tname' => $tname); } - function CheckDir($dir) + /** + * Recursive mkdir + * + * @param string $dir + * @param string $base_path base path to directory where folders should be created in + */ + function CheckDir($dir, $base_path = '') { if (file_exists($dir)) { return; } else { + // remove $base_path from beggining because it is already created during install + $dir = preg_replace('/^'.preg_quote($base_path.'/', '/').'/', '', $dir, 1); $segments = explode('/', $dir); - $cur_path = ''; + $cur_path = $base_path; + foreach ($segments as $segment) { // do not add leading / for windows paths (c:\...) $cur_path .= preg_match('/^[a-zA-Z]{1}:/', $segment) ? $segment : '/'.$segment; Index: branches/unlabeled/unlabeled-1.24.2/core/kernel/parser/template_parser.php =================================================================== diff -u -r5745 -r5843 --- branches/unlabeled/unlabeled-1.24.2/core/kernel/parser/template_parser.php (.../template_parser.php) (revision 5745) +++ branches/unlabeled/unlabeled-1.24.2/core/kernel/parser/template_parser.php (.../template_parser.php) (revision 5843) @@ -333,14 +333,23 @@ } } - function CheckDir($dir) + /** + * Recursive mkdir + * + * @param string $dir + * @param string $base_path base path to directory where folders should be created in + */ + function CheckDir($dir, $base_path = '') { if (file_exists($dir)) { return; } else { + // remove $base_path from beggining because it is already created during install + $dir = preg_replace('/^'.preg_quote($base_path.'/', '/').'/', '', $dir, 1); $segments = explode('/', $dir); - $cur_path = ''; + $cur_path = $base_path; + foreach ($segments as $segment) { // do not add leading / for windows paths (c:\...) $cur_path .= preg_match('/^[a-zA-Z]{1}:/', $segment) ? $segment : '/'.$segment; @@ -460,7 +469,7 @@ $fname = str_replace(FULL_PATH, FULL_PATH.'/kernel/cache', $fname); if (!defined('SAFE_MODE') || !SAFE_MODE) { - $this->CheckDir(dirname($fname)); + $this->CheckDir(dirname($fname), FULL_PATH.'/kernel/cache'); } $tname = $this->Application->TemplatesCache->GetRealFilename($this->TemplateName).'.tpl';