Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mewebstudio committed Apr 19, 2019
1 parent 401b54c commit 8a1de32
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 31 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
composer.lock
vendor
/.idea
/.settings
/.settings
.DS_Store
16 changes: 5 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,13 @@ return [
```php

// [your site path]/Http/routes.php

Route::any('captcha-test', function()
{
if (Request::getMethod() == 'POST')
{
Route::any('captcha-test', function() {
if (request()->getMethod() == 'POST') {
$rules = ['captcha' => 'required|captcha'];
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails())
{
$validator = validator()->make(request()->all(), $rules);
if ($validator->fails()) {
echo '<p style="color: #ff0000;">Incorrect!</p>';
}
else
{
} else {
echo '<p style="color: #00ff30;">Matched :)</p>';
}
}
Expand Down
11 changes: 8 additions & 3 deletions config/captcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@

return [

'characters' => ['2','3','4','6','7','8','9','a','b','c','d','e','f','g','h','j','m','n','p','q','r','t','u','x','y','z','A','B','C','D','E','F','G','H','J','M','N','P','Q','R','T','U','X','Y','Z'],
'characters' => ['2','3','4','6','7','8','9','a','b','c','d','e','f','g','h','j','m','n','p','q','r','t','u','x','y','z','A','B','C','D','E','F','G','H','J','M','N','P','Q','R','T','U','X','Y','Z'],

'default' => [
'length' => 9,
'width' => 120,
'height' => 36,
'quality' => 90,
'math' => false,
],
'math' => [
'length' => 9,
'width' => 120,
'height' => 36,
Expand All @@ -23,13 +30,11 @@
'fontColors'=> ['#2c3e50', '#c0392b', '#16a085', '#c0392b', '#8e44ad', '#303f9f', '#f57c00', '#795548'],
'contrast' => -5,
],

'mini' => [
'length' => 3,
'width' => 60,
'height' => 32,
],

'inverse' => [
'length' => 5,
'width' => 120,
Expand Down
33 changes: 17 additions & 16 deletions src/Captcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,22 +345,23 @@ protected function text()
{
$marginTop = $this->image->height() / $this->length;

$i = 0;
foreach($this->text as $char)
{
$marginLeft = $this->textLeftPadding + ($i * ($this->image->width() - $this->textLeftPadding) / $this->length);

$this->image->text($char, $marginLeft, $marginTop, function($font) {
$font->file($this->font());
$font->size($this->fontSize());
$font->color($this->fontColor());
$font->align('left');
$font->valign('top');
$font->angle($this->angle());
});

$i++;
}
$text = $this->text;
if (is_string($text)) {
$text = str_split($text);
}

foreach($text as $key => $char) {
$marginLeft = $this->textLeftPadding + ($key * ($this->image->width() - $this->textLeftPadding) / $this->length);

$this->image->text($char, $marginLeft, $marginTop, function($font) {
$font->file($this->font());
$font->size($this->fontSize());
$font->color($this->fontColor());
$font->align('left');
$font->valign('top');
$font->angle($this->angle());
});
}
}

/**
Expand Down

0 comments on commit 8a1de32

Please sign in to comment.