Skip to content

armgit / Vvveb

Public Imported from GitHub
0

Powerful and easy to use cms to build websites, blogs or ecommerce stores.

Check if cached page should be directory and save to /index.html

givanz1cb64248a249
diff --git a/system/cache/file.php b/system/cache/file.php
index 2e82d6e..70cda03 100755
--- a/system/cache/file.php
+++ b/system/cache/file.php
@@ -81,11 +81,14 @@ class File {
$file = $this->cacheDir . $namespace . '.' . $this->cachePrefix . basename($key) . '.' . $expire;
$handle = fopen($file, 'w');
- flock($handle, LOCK_EX);
- fwrite($handle, json_encode($value/*, JSON_PRETTY_PRINT*/));
- fflush($handle);
- flock($handle, LOCK_UN);
- fclose($handle);
+
+ if ($handle) {
+ flock($handle, LOCK_EX);
+ fwrite($handle, json_encode($value/*, JSON_PRETTY_PRINT*/));
+ fflush($handle);
+ flock($handle, LOCK_UN);
+ fclose($handle);
+ }
}
public function getMulti($namespace, $keys, $serverKey = false) {
diff --git a/system/page-cache.php b/system/page-cache.php
index 1cd10e6..cba4d21 100755
--- a/system/page-cache.php
+++ b/system/page-cache.php
@@ -70,7 +70,7 @@ class PageCache {
}
if (substr($path, -1) == '/') {
- $path .= 'index.html';
+ $path .= DS . 'index.html';
}
return $file_cache = $this->cacheFolder . $path;
@@ -95,6 +95,10 @@ class PageCache {
function startGenerating() {
$dir = dirname($this->fileName);
+ if (is_dir($this->fileName)) {
+ $this->fileName .= DS . 'index.html';
+ }
+
if (! is_dir($dir)) {
//if page with the same name as folder remove
if (file_exists($dir)) {
@@ -185,7 +189,7 @@ class PageCache {
http_response_code() == 200) {
//create directory structure
if (is_dir($this->fileName)) {
- $this->fileName .= 'index.html';
+ $this->fileName .= DS . 'index.html';
}
$dir = dirname($this->fileName);