1
0
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:
Mikael Roos
2015-01-29 21:16:32 +01:00
parent bc4e04c3cb
commit 16a7a3dad5
10 changed files with 7906 additions and 38 deletions

View File

@@ -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();
}