mirror of
https://github.com/mosbth/cimage.git
synced 2025-08-07 00:26:33 +02:00
* Now returns statuscode 500 when something fails #55.
* Three different modes: strict, production, development #44. * Three files for all-in-one `imgs.php`, `imgp.php`, `imgd.php` #73.
This commit is contained in:
@@ -124,6 +124,23 @@ class CRemoteImage
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Check if cache is writable or throw exception.
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @throws Exception if cahce folder is not writable.
|
||||
*/
|
||||
public function isCacheWritable()
|
||||
{
|
||||
if (!is_writable($this->saveFolder)) {
|
||||
throw new Exception("Cache folder is not writable for downloaded files.");
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Decide if the cache should be used or not before trying to download
|
||||
* a remote file.
|
||||
@@ -277,8 +294,10 @@ class CRemoteImage
|
||||
|
||||
$this->status = $this->http->getStatus();
|
||||
if ($this->status === 200) {
|
||||
$this->isCacheWritable();
|
||||
return $this->save();
|
||||
} else if ($this->status === 304) {
|
||||
$this->isCacheWritable();
|
||||
return $this->updateCacheDetails();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user