1
0
mirror of https://github.com/mosbth/cimage.git synced 2025-07-25 18:51:19 +02:00

code formatting and making log() public

This commit is contained in:
Mikael Roos
2014-05-20 00:55:43 +02:00
parent dedd01bc71
commit b4f51f3438

View File

@@ -1183,7 +1183,7 @@ class CImage
* @param int $height of the new image. * @param int $height of the new image.
* @return image resource. * @return image resource.
*/ */
private function CreateImageKeepTransparency($width, $height) private function createImageKeepTransparency($width, $height)
{ {
$this->log("Creating a new working image width={$width}px, height={$height}px."); $this->log("Creating a new working image width={$width}px, height={$height}px.");
$img = imagecreatetruecolor($width, $height); $img = imagecreatetruecolor($width, $height);
@@ -1347,11 +1347,11 @@ class CImage
$info = list($width, $height, $type, $attr) = getimagesize($file); $info = list($width, $height, $type, $attr) = getimagesize($file);
!empty($info) or $this->raiseError("The file doesn't seem to be an image."); !empty($info) or $this->raiseError("The file doesn't seem to be an image.");
$mime = $info['mime']; $mime = $info['mime'];
$lastModified = filemtime($file); $lastModified = filemtime($file);
$gmdate = gmdate("D, d M Y H:i:s", $lastModified); $gmdate = gmdate("D, d M Y H:i:s", $lastModified);
if (!$this->verbose) { if (!$this->verbose) {
header('Last-Modified: ' . $gmdate . " GMT"); header('Last-Modified: ' . $gmdate . " GMT");
} }
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $lastModified) { if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $lastModified) {
@@ -1364,7 +1364,7 @@ class CImage
header("HTTP/1.0 304 Not Modified"); header("HTTP/1.0 304 Not Modified");
} else { } else {
if ($this->verbose) { if ($this->verbose) {
$this->log("Last modified: " . $gmdate . " GMT"); $this->log("Last modified: " . $gmdate . " GMT");
@@ -1372,7 +1372,7 @@ class CImage
exit; exit;
} }
header('Content-type: ' . $mime); header('Content-type: ' . $mime);
readfile($file); readfile($file);
} }
@@ -1386,13 +1386,15 @@ class CImage
* *
* @param string $message to log. * @param string $message to log.
* *
* @return void * @return this
*/ */
private function log($message) public function log($message)
{ {
if ($this->verbose) { if ($this->verbose) {
$this->log[] = $message; $this->log[] = $message;
} }
return $this;
} }
@@ -1402,7 +1404,7 @@ class CImage
* *
* @return void * @return void
*/ */
private function verboseOutput() private function verboseOutput()
{ {
$log = null; $log = null;
$this->log("Memory peak: " . round(memory_get_peak_usage() /1024/1024) . "M"); $this->log("Memory peak: " . round(memory_get_peak_usage() /1024/1024) . "M");
@@ -1442,8 +1444,8 @@ EOD;
* @return void * @return void
* @throws Exception * @throws Exception
*/ */
private function raiseError($message) private function raiseError($message)
{ {
throw new Exception($message); throw new Exception($message);
} }
} }