From 458d1fbfeba4011202b7bc2e372f62197a910055 Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Wed, 24 Aug 2016 20:35:19 +0200 Subject: [PATCH] [Bridge] Rename to --- lib/Bridge.php | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/lib/Bridge.php b/lib/Bridge.php index 0dfe8f9..bd23006 100644 --- a/lib/Bridge.php +++ b/lib/Bridge.php @@ -172,20 +172,20 @@ abstract class HttpCachingBridgeAbstract extends BridgeAbstract { // TODO build this from the variable given to Cache $pageCacheDir = __DIR__ . '/../cache/pages/'; - $filename = $pageCacheDir . $simplified_url; + $filepath = $pageCacheDir . $simplified_url; - if(substr($filename, -1) == '/'){ - $filename = $filename . 'index.html'; + if(substr($filepath, -1) == '/'){ + $filepath .= 'index.html'; } - if(file_exists($filename)){ - $this->debugMessage('loading cached file from ' . $filename . ' for page at url ' . $url); + if(file_exists($filepath)){ + $this->debugMessage('loading cached file from ' . $filepath . ' for page at url ' . $url); // TODO touch file and its parent, and try to do neighbour deletion - $this->refresh_in_cache($pageCacheDir, $filename); - $content = file_get_contents($filename); + $this->refresh_in_cache($pageCacheDir, $filepath); + $content = file_get_contents($filepath); } else { - $this->debugMessage('we have no local copy of ' . $url . ' Downloading to ' . $filename); - $dir = substr($filename, 0, strrpos($filename, '/')); + $this->debugMessage('we have no local copy of ' . $url . ' Downloading to ' . $filepath); + $dir = substr($filepath, 0, strrpos($filepath, '/')); if(!is_dir($dir)){ $this->debugMessage('creating directories for ' . $dir); @@ -193,8 +193,8 @@ abstract class HttpCachingBridgeAbstract extends BridgeAbstract { } $content = $this->getContents($url); - if($content!==false){ - file_put_contents($filename,$content); + if($content !== false){ + file_put_contents($filepath, $content); } } @@ -206,21 +206,21 @@ abstract class HttpCachingBridgeAbstract extends BridgeAbstract { // TODO build this from the variable given to Cache $pageCacheDir = __DIR__ . '/../cache/pages/'; - $filename = $pageCacheDir . $simplified_url; + $filepath = $pageCacheDir . $simplified_url; - if(substr($filename, -1) == '/'){ - $filename = $filename . 'index.html'; + if(substr($filepath, -1) == '/'){ + $filepath .= 'index.html'; } - if(!file_exists($filename)){ + if(!file_exists($filepath)){ $this->get_cached($url); } - return filectime($filename); + return filectime($filepath); } - private function refresh_in_cache($pageCacheDir, $filename){ - $currentPath = $filename; + private function refresh_in_cache($pageCacheDir, $filepath){ + $currentPath = $filepath; while(!$pageCacheDir == $currentPath){ touch($currentPath); $currentPath = dirname($currentPath); @@ -232,9 +232,9 @@ abstract class HttpCachingBridgeAbstract extends BridgeAbstract { // TODO build this from the variable given to Cache $pageCacheDir = __DIR__ . '/../cache/pages/'; - $filename = realpath($pageCacheDir . $simplified_url); - $this->debugMessage('removing from cache \'' . $filename . '\' WELL, NOT REALLY'); - // unlink($filename); + $filepath = realpath($pageCacheDir . $simplified_url); + $this->debugMessage('removing from cache \'' . $filepath . '\' WELL, NOT REALLY'); + // unlink($filepath); } }