7 * Full file system path to cache directory
13 * Full URL to cache directory
19 public function __construct()
21 $this->cacheDir = getcwd() . '/imgcache/';
22 $this->cacheDirUrl = $this->getCurrentUrlDir() . '/imgcache/';
25 public function setupCheck()
27 if (!is_dir($this->cacheDir)) {
28 throw new \Exception('Cache directory does not exist: ' . $this->cacheDir);
30 if (!is_writable($this->cacheDir)) {
31 throw new \Exception('Cache directory is not writable: ' . $this->cacheDir);
35 protected function getCurrentUrl()
37 if (!isset($_SERVER['REQUEST_SCHEME'])) {
38 $_SERVER['REQUEST_SCHEME'] = 'http';
40 return $_SERVER['REQUEST_SCHEME'] . '://'
41 . $_SERVER['HTTP_HOST']
42 . preg_replace('/#.*$/', '', $_SERVER['REQUEST_URI']);
45 protected function getCurrentUrlDir()
47 $url = $this->getCurrentUrl();
48 $url = preg_replace('/\?.*$/', '', $url);
49 if (substr($url, -1) == '/') {
53 return substr($url, 0, -strlen(basename($url)) - 1);