-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2016-07-23 AC: Merge branch '1.8.9' into stable.
- Loading branch information
Showing
133 changed files
with
19,079 additions
and
2,729 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ matrix: | |
- php: 5.4 | ||
- php: 5.5 | ||
- php: 5.6 | ||
env: | ||
- CS_CHECK=true | ||
- php: 7 | ||
- php: hhvm | ||
allow_failures: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,10 @@ | |
* Text_CAPTCHA - creates a CAPTCHA for Turing tests | ||
* | ||
* Class to create a Turing test for websites by | ||
* creating an image, ASCII art or something else | ||
* with some (obfuscated) characters | ||
* creating an image, ASCII art or something else | ||
* with some (obfuscated) characters | ||
* | ||
* | ||
* | ||
* @package Text_CAPTCHA | ||
* @license BSD License | ||
* @author Christian Wenz <[email protected]> | ||
|
@@ -33,13 +33,13 @@ | |
* Text_CAPTCHA - creates a CAPTCHA for Turing tests | ||
* | ||
* Class to create a Turing test for websites by | ||
* creating an image, ASCII art or something else | ||
* with some (obfuscated) characters | ||
* creating an image, ASCII art or something else | ||
* with some (obfuscated) characters | ||
* | ||
* @package Text_CAPTCHA | ||
*/ | ||
/* | ||
|
||
/* | ||
// This is a simple example script | ||
<?php | ||
|
@@ -52,7 +52,7 @@ public function file_put_contents($filename, $content) { | |
fclose($file); | ||
return $n ? $n : false; | ||
} | ||
} | ||
} | ||
// Start PHP session support | ||
session_start(); | ||
|
@@ -73,16 +73,16 @@ public function file_put_contents($filename, $content) { | |
$msg = 'Please try again!'; | ||
} | ||
unlink(sha1(session_id()) . '.png'); | ||
unlink(sha1(session_id()) . '.png'); | ||
} | ||
print "<p>$msg</p>"; | ||
if (!$ok) { | ||
require_once 'Text/CAPTCHA.php'; | ||
// Set CAPTCHA image options (font must exist!) | ||
$imageOptions = array( | ||
'font_size' => 24, | ||
|
@@ -109,10 +109,10 @@ public function file_put_contents($filename, $content) { | |
$retval->getMessage()); | ||
exit; | ||
} | ||
// Get CAPTCHA secret passphrase | ||
$_SESSION['phrase'] = $c->getPhrase(); | ||
// Get CAPTCHA image (as PNG) | ||
$png = $c->getCAPTCHA(); | ||
if (PEAR::isError($png)) { | ||
|
@@ -121,16 +121,17 @@ public function file_put_contents($filename, $content) { | |
exit; | ||
} | ||
file_put_contents(sha1(session_id()) . '.png', $png); | ||
echo '<form method="post">' . | ||
'<img src="' . sha1(session_id()) . '.png?' . time() . '" />' . | ||
echo '<form method="post">' . | ||
'<img src="' . sha1(session_id()) . '.png?' . time() . '" />' . | ||
'<input type="text" name="phrase" />' . | ||
'<input type="submit" /></form>'; | ||
} | ||
?> | ||
*/ | ||
|
||
class Text_CAPTCHA { | ||
|
||
class Text_CAPTCHA | ||
{ | ||
|
||
/** | ||
* Version number | ||
|
@@ -208,12 +209,12 @@ public function getPhrase() | |
/** | ||
* Sets secret CAPTCHA phrase | ||
* | ||
* This method sets the CAPTCHA phrase | ||
* This method sets the CAPTCHA phrase | ||
* (use null for a random phrase) | ||
* | ||
* @access public | ||
* @param string $phrase the (new) phrase | ||
* @void | ||
* @void | ||
*/ | ||
public function setPhrase($phrase = null) | ||
{ | ||
|
@@ -226,12 +227,13 @@ public function setPhrase($phrase = null) | |
|
||
/** | ||
* Place holder for the real init() method | ||
* used by extended classes to initialize CAPTCHA | ||
* used by extended classes to initialize CAPTCHA | ||
* | ||
* @access private | ||
* @return PEAR_Error | ||
*/ | ||
public function init() { | ||
public function init() | ||
{ | ||
return PEAR::raiseError('CAPTCHA type not selected', true); | ||
} | ||
|
||
|
@@ -242,21 +244,21 @@ public function init() { | |
* @access private | ||
* @return PEAR_Error | ||
*/ | ||
public function _createCAPTCHA() { | ||
public function _createCAPTCHA() | ||
{ | ||
return PEAR::raiseError('CAPTCHA type not selected', true); | ||
} | ||
|
||
/** | ||
* Place holder for the real getCAPTCHA() method | ||
* used by extended classes to return the generated CAPTCHA | ||
* used by extended classes to return the generated CAPTCHA | ||
* (as an image resource, as an ASCII text, ...) | ||
* | ||
* @access private | ||
* @return PEAR_Error | ||
*/ | ||
public function getCAPTCHA() { | ||
public function getCAPTCHA() | ||
{ | ||
return PEAR::raiseError('CAPTCHA type not selected', true); | ||
} | ||
|
||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
|
||
/** | ||
* | ||
* Require Image_Text class for generating the text. | ||
* Require ImageText class for generating the text. | ||
* | ||
*/ | ||
require_once 'CAPTCHA.php'; | ||
|
@@ -12,13 +12,13 @@ | |
/** | ||
* Text_CAPTCHA_Driver_Image - Text_CAPTCHA driver graphical CAPTCHAs | ||
* | ||
* Class to create a graphical Turing test | ||
* Class to create a graphical Turing test | ||
* | ||
* | ||
* | ||
* @license BSD License | ||
* @author Christian Wenz <[email protected]> | ||
* @todo refine the obfuscation algorithm :-) | ||
* @todo consider removing Image_Text dependency | ||
* @todo consider removing ImageText dependency | ||
*/ | ||
|
||
class Text_CAPTCHA_Driver_Image extends Text_CAPTCHA | ||
|
@@ -33,7 +33,7 @@ class Text_CAPTCHA_Driver_Image extends Text_CAPTCHA | |
public $_im; | ||
|
||
/** | ||
* Image_Text object | ||
* ImageText object | ||
* | ||
* @access private | ||
* @public resource | ||
|
@@ -59,7 +59,7 @@ class Text_CAPTCHA_Driver_Image extends Text_CAPTCHA | |
/** | ||
* Phrase length of CAPTCHA | ||
* | ||
* @access public static | ||
* @access public static | ||
* @public int | ||
*/ | ||
public static $_phraseLength; | ||
|
@@ -73,7 +73,7 @@ class Text_CAPTCHA_Driver_Image extends Text_CAPTCHA | |
public $_output; | ||
|
||
/** | ||
* Further options (here: for Image_Text) | ||
* Further options (here: for ImageText) | ||
* | ||
* @access private | ||
* @public array | ||
|
@@ -85,7 +85,7 @@ class Text_CAPTCHA_Driver_Image extends Text_CAPTCHA | |
'text_color' => '#000000', | ||
'lines_color' => '#CACACA', | ||
'background_color' => '#555555'); | ||
|
||
/** | ||
* Whether the immage resource has been created | ||
* | ||
|
@@ -115,17 +115,17 @@ public function init($options = array()) | |
{ | ||
if (!is_array($options)) { | ||
// Compatibility mode ... in future versions, these two | ||
// lines of code will be used: | ||
// lines of code will be used: | ||
// $this->_error = PEAR::raiseError('You need to provide a set of CAPTCHA options!'); | ||
// return $this->_error; | ||
// return $this->_error; | ||
$o = array(); | ||
$args = func_get_args(); | ||
if (isset($args[0])) { | ||
$o['width'] = $args[0]; | ||
} | ||
} | ||
if (isset($args[1])) { | ||
$o['height'] = $args[1]; | ||
} | ||
} | ||
if (isset($args[2]) && $args[2] != null) { | ||
$o['phrase'] = $args[2]; | ||
} | ||
|
@@ -134,16 +134,16 @@ public function init($options = array()) | |
} | ||
$options = $o; | ||
} | ||
if (is_array($options)) { | ||
if (is_array($options)) { | ||
if (isset($options['width']) && is_int($options['width'])) { | ||
$this->_width = $options['width']; | ||
$this->_width = $options['width']; | ||
} else { | ||
$this->_width = 200; | ||
$this->_width = 200; | ||
} | ||
if (isset($options['height']) && is_int($options['height'])) { | ||
$this->_height = $options['height']; | ||
$this->_height = $options['height']; | ||
} else { | ||
$this->_height = 80; | ||
$this->_height = 80; | ||
} | ||
if (!isset($options['phrase']) || empty($options['phrase'])) { | ||
$phraseoptions = (isset($options['phraseOptions']) && is_array($options['phraseOptions'])) ? $options['phraseOptions'] : array(); | ||
|
@@ -155,9 +155,9 @@ public function init($options = array()) | |
$this->_output = 'resource'; | ||
} else { | ||
$this->_output = $options['output']; | ||
} | ||
} | ||
if (isset($options['imageOptions']) && is_array($options['imageOptions']) && count($options['imageOptions']) > 0) { | ||
$this->_imageOptions = array_merge($this->_imageOptions, $options['imageOptions']); | ||
$this->_imageOptions = array_merge($this->_imageOptions, $options['imageOptions']); | ||
} | ||
return true; | ||
} | ||
|
@@ -172,11 +172,11 @@ public function init($options = array()) | |
*/ | ||
public function _createPhrase($options = array()) | ||
{ | ||
if (isset(self::$_phraseLength)) { | ||
$len = intval(min(self::$_phraseLength, $this->_width / 25)); | ||
} else { | ||
$len = intval(min(8, $this->_width / 25)); | ||
} | ||
if (isset(self::$_phraseLength)) { | ||
$len = intval(min(self::$_phraseLength, $this->_width / 25)); | ||
} else { | ||
$len = intval(min(8, $this->_width / 25)); | ||
} | ||
if (!is_array($options) || count($options) === 0) { | ||
$this->_phrase = Text_Password::create($len); | ||
} else { | ||
|
@@ -208,11 +208,11 @@ public function _createCAPTCHA() | |
$options['canvas'] = array( | ||
'width' => $this->_width, | ||
'height' => $this->_height | ||
); | ||
); | ||
$options['width'] = $this->_width - 20; | ||
$options['height'] = $this->_height - 20; | ||
$options['height'] = $this->_height - 20; | ||
$options['cx'] = ceil(($this->_width) / 2 + 10); | ||
$options['cy'] = ceil(($this->_height) / 2 + 10); | ||
$options['cy'] = ceil(($this->_height) / 2 + 10); | ||
$options['angle'] = rand(0, 30) - 15; | ||
$options['font_size'] = $this->_imageOptions['font_size']; | ||
$options['font_path'] = $this->_imageOptions['font_path']; | ||
|
@@ -222,26 +222,29 @@ public function _createCAPTCHA() | |
$options['max_lines'] = 1; | ||
$options['mode'] = 'auto'; | ||
do { | ||
$this->_imt = new Image_Text( | ||
$this->_imt = new ImageText( | ||
$this->_phrase, | ||
$options | ||
); | ||
if (PEAR::isError($e = $this->_imt->init())) { | ||
$this->_error = PEAR::raiseError( | ||
sprintf('Error initializing Image_Text (%s)', | ||
$e->getMessage())); | ||
sprintf( | ||
'Error initializing ImageText (%s)', | ||
$e->getMessage() | ||
) | ||
); | ||
return $this->_error; | ||
} else { | ||
$this->_created = true; | ||
$this->_created = true; | ||
} | ||
$result = $this->_imt->measurize(); | ||
} while ($result === false && --$options['font_size'] > 0); | ||
if ($result === false) { | ||
$this->_error = PEAR::raiseError('The text provided does not fit in the image dimensions'); | ||
return $this->_error; | ||
} | ||
$this->_imt->render(); | ||
$this->_im =& $this->_imt->getImg(); | ||
$this->_imt->render(); | ||
$this->_im =& $this->_imt->getImg(); | ||
$colors = $this->_imt->_convertString2RGB($this->_imageOptions['lines_color']); | ||
$lines_color = imagecolorallocate($this->_im, $colors['r'], $colors['g'], $colors['b']); | ||
//some obfuscation | ||
|
@@ -277,7 +280,7 @@ public function getCAPTCHA() | |
if (PEAR::isError($retval)) { | ||
return PEAR::raiseError($retval->getMessage()); | ||
} | ||
|
||
if ($this->_output == 'gif' && !function_exists('imagegif')) { | ||
$this->_output = 'png'; | ||
} | ||
|
@@ -286,7 +289,7 @@ public function getCAPTCHA() | |
case 'png': | ||
return $this->getCAPTCHAAsPNG(); | ||
break; | ||
case 'jpg': | ||
case 'jpg': | ||
case 'jpeg': | ||
return $this->getCAPTCHAAsJPEG(); | ||
break; | ||
|
@@ -386,5 +389,5 @@ public function getCAPTCHAAsGIF() | |
public function __wakeup() | ||
{ | ||
$this->_created = false; | ||
} | ||
} | ||
} |
Oops, something went wrong.