From d0fd598321cf85aeb72925bf7dcf323e378ca933 Mon Sep 17 00:00:00 2001 From: Jefrey Sobreira Santos Date: Sun, 13 Mar 2016 13:31:33 -0300 Subject: [PATCH] bug fixes --- captcha.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/captcha.php b/captcha.php index 8a36134..7cef773 100644 --- a/captcha.php +++ b/captcha.php @@ -1,6 +1,6 @@ * @license GPLv3 @@ -10,8 +10,15 @@ * */ - -session_start(); +// checking if session has been started +if(session_status() == PHP_SESSION_NONE) { + if(headers_sent()) { + trigger_error("Cool PHP Captcha tried to start session but the headers were already sent.", E_USER_ERROR); + exit; + } else { + session_start(); + } +} @@ -437,7 +444,7 @@ protected function WriteText($text, $fontcfg = array()) { } $coords = imagettftext($this->im, $fontsize, $degree, $x, $y, - $this->GdFgColor, $fontfile, $letter); + $this->GdFgColor, dirname(__FILE__).'/'.$fontfile, $letter); $x += ($coords[2]-$x) + ($fontcfg['spacing']*$this->scale); } @@ -476,7 +483,7 @@ protected function WaveImage() { * Reduce the image to the final size */ protected function ReduceImage() { - // Reduzco el tamaño de la imagen + // Reduzco el tamaño de la imagen $imResampled = imagecreatetruecolor($this->width, $this->height); imagecopyresampled($imResampled, $this->im, 0, 0, 0, 0,