From 2390c29975a62c94131bd0a422c6c10fb0cda181 Mon Sep 17 00:00:00 2001 From: "Y.P.Y" Date: Mon, 28 May 2012 15:22:41 +0430 Subject: [PATCH 1/3] Update library/GIFEncoder3.0.php --- library/GIFEncoder3.0.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/GIFEncoder3.0.php b/library/GIFEncoder3.0.php index 5c5c27c..9e0c7c8 100644 --- a/library/GIFEncoder3.0.php +++ b/library/GIFEncoder3.0.php @@ -239,11 +239,11 @@ function GIFBlockCompare ( $GlobalBlock, $LocalBlock, $Len ) { $GlobalBlock { 3 * $i + 1 } != $LocalBlock { 3 * $i + 1 } || $GlobalBlock { 3 * $i + 2 } != $LocalBlock { 3 * $i + 2 } ) { - return ( 0 ); + return 0; } } - return ( 1 ); + return 1; } /* ::::::::::::::::::::::::::::::::::::::::::::::::::: @@ -262,6 +262,6 @@ function GIFWord ( $int ) { :: */ function GetAnimation ( ) { - return ( $this->GIF ); + return $this->GIF; } } From ed58f901988804094cefa85b5e52b4e62c4709af Mon Sep 17 00:00:00 2001 From: "Y.P.Y" Date: Mon, 28 May 2012 15:38:28 +0430 Subject: [PATCH 2/3] Update AnimatedCaptcha.php --- AnimatedCaptcha.php | 49 ++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/AnimatedCaptcha.php b/AnimatedCaptcha.php index a3ba3c8..f6b1421 100644 --- a/AnimatedCaptcha.php +++ b/AnimatedCaptcha.php @@ -8,11 +8,10 @@ class AnimatedCaptcha { protected $_options = array( - 'millisecondsBetweenFrames' => 100, - 'pluginName' => 'MovingRectangle', - 'pluginOptions' => array() - ); - + 'millisecondsBetweenFrames' => 100, + 'pluginName' => 'MovingRectangle', + 'pluginOptions' => array() + ); /** * @var string */ @@ -31,8 +30,15 @@ public function __construct(array $options = array()) if (is_array($options)) { $this->setOptions($options); } + + return; } + public function __destruct() + { + return; + } + /** * All given options in the array are given to their setters * @@ -43,7 +49,6 @@ public function setOptions(array $options) { foreach ($options as $key => $value) { $normalized = ucfirst($key); - $method = 'set' . $normalized; if (method_exists($this, $method)) { $this->$method($value); @@ -74,11 +79,8 @@ public function setPluginOptions($pluginOptions) public function render() { $this->_createTempFilePath(); - $this->_getFramesFromPlugin(); - $this->_writeFramesToTargetFile(); - return $this; } @@ -89,15 +91,19 @@ public function render() */ public function outputRenderedImage() { - header('Cache-Control: private, no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); - header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); - header('Last-Modified: '.gmdate('D, d M Y H:i:s',time()-60).' GMT'); - header('Pragma: no-cache'); - header('Content-Length: '.filesize($this->_tempFilePath)); - header('Content-Type: image/gif'); + if(!headers_sent()) { + header('Cache-Control: private, no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); + header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); + header('Last-Modified: '.gmdate('D, d M Y H:i:s',time()-60).' GMT'); + header('Pragma: no-cache'); + header('Content-Length: '.filesize($this->_tempFilePath)); + header('Content-Type: image/gif'); + } + else { + throw new Exception('Can not send header parameters. Thats already sent.'); + } readfile($this->_tempFilePath); - return $this; } @@ -126,12 +132,12 @@ public function getRenderedFilePath() protected function _getFramesFromPlugin() { - require __DIR__ . '/plugins/'.$this->_options['pluginName'].'.php'; + require (__DIR__ . '/plugins/'.$this->_options['pluginName'].'.php'); $pluginClassName = 'AnimatedCaptcha_Plugin_'.$this->_options['pluginName']; $pluginClass = new $pluginClassName($this->_options['pluginOptions']); /** @var $pluginClass AnimatedCaptcha_Plugin */ - $this->_frames = $pluginClass->getFrames(); + return; } /** @@ -140,8 +146,8 @@ protected function _getFramesFromPlugin() protected function _createTempFilePath() { $tempFilePath = tempnam('', '') . '.gif'; - $this->_tempFilePath = $tempFilePath; + return; } /** @@ -150,12 +156,13 @@ protected function _createTempFilePath() protected function _writeFramesToTargetFile() { $delays = array(); + for ($i=0; $i_frames); $i++) { $delays[] = $this->_options['millisecondsBetweenFrames']; } - $gif = new GIFEncoder($this->_frames, $delays, 0, 2, 0, 0, 0, 0, "bin" ); - + $gif = new GIFEncoder($this->_frames, $delays, 0, 2, 0, 0, 0, 0, 'bin' ); file_put_contents($this->_tempFilePath, $gif->GetAnimation()); + return; } } \ No newline at end of file From 9763b4215b4ca11f463731da50c13a4bac4bd803 Mon Sep 17 00:00:00 2001 From: "Y.P.Y" Date: Mon, 28 May 2012 15:57:00 +0430 Subject: [PATCH 3/3] Update AnimatedCaptcha.php --- AnimatedCaptcha.php | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/AnimatedCaptcha.php b/AnimatedCaptcha.php index f6b1421..963d5a1 100644 --- a/AnimatedCaptcha.php +++ b/AnimatedCaptcha.php @@ -31,13 +31,13 @@ public function __construct(array $options = array()) $this->setOptions($options); } - return; + return; } - public function __destruct() - { - return; - } + public function __destruct() + { + return; + } /** * All given options in the array are given to their setters @@ -91,17 +91,17 @@ public function render() */ public function outputRenderedImage() { - if(!headers_sent()) { - header('Cache-Control: private, no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); - header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); - header('Last-Modified: '.gmdate('D, d M Y H:i:s',time()-60).' GMT'); - header('Pragma: no-cache'); - header('Content-Length: '.filesize($this->_tempFilePath)); - header('Content-Type: image/gif'); - } - else { - throw new Exception('Can not send header parameters. Thats already sent.'); - } + if(!headers_sent()) { + header('Cache-Control: private, no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); + header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); + header('Last-Modified: '.gmdate('D, d M Y H:i:s',time()-60).' GMT'); + header('Pragma: no-cache'); + header('Content-Length: '.filesize($this->_tempFilePath)); + header('Content-Type: image/gif'); + } + else { + throw new Exception('Can not send header parameters. Thats already sent.'); + } readfile($this->_tempFilePath); return $this; @@ -137,7 +137,7 @@ protected function _getFramesFromPlugin() $pluginClass = new $pluginClassName($this->_options['pluginOptions']); /** @var $pluginClass AnimatedCaptcha_Plugin */ $this->_frames = $pluginClass->getFrames(); - return; + return; } /** @@ -147,7 +147,7 @@ protected function _createTempFilePath() { $tempFilePath = tempnam('', '') . '.gif'; $this->_tempFilePath = $tempFilePath; - return; + return; } /** @@ -163,6 +163,6 @@ protected function _writeFramesToTargetFile() $gif = new GIFEncoder($this->_frames, $delays, 0, 2, 0, 0, 0, 0, 'bin' ); file_put_contents($this->_tempFilePath, $gif->GetAnimation()); - return; + return; } } \ No newline at end of file