Giter Site home page Giter Site logo

captcha's People

Contributors

adelbert-silla avatar andreybolonin avatar apirastru avatar bftanase avatar ciarand avatar coolgoose avatar cordoval avatar cryzo avatar didatus avatar gemorroj avatar gondo avatar gregwar avatar jdecool avatar juliardi avatar kaysonwu avatar lackovic10 avatar nvbooster avatar polakjakub avatar sandropons avatar smartynovych avatar thbourlove avatar visavi avatar whyte624 avatar yuriy-svetlov avatar zhuzhichao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

captcha's Issues

Move the "niceize" logic to the this repo

I already removed the "0" and the "O" from the charset because of confusion

We should add the "niceize" logic to the phrasebuilder, which would ignore the case and be nice with characters that look likes (1, l and I, O and 0 etc.)

Problem on Laravel

Hi!

I'm trying to implement this module, but after having downloaded it with composer, when I add 'Gregwar\Captcha\CaptchaBuilder' to providers on any app page I get an error:
Call to undefined method Gregwar\Captcha\CaptchaBuilder::isDeferred
without acutally adding any other code.

Maybe you can help with this?

Is that better to add an accessory function to get captcha's unique id?

Before I submit a pull request, just want to make sure whether it's necessary.

With usage of capture, we also need save the phrase to validate user input. Usually we may use session or a cache component. Well, if we choose to use cache, we also need a cache key for each capture. Thanks to the fingerprint property, we can simply use md5(json_encode($captcha->getFingerprint())) or md5(implode('', $captcha->getFingerprint())) to generate an unique key as the cache key.

As mentioned above, whether it's better to add an accessory function called getToken(), just like this:

    public function getToken()
    {
        if (empty($this->getFingerprint())) {
            throw new \Exception('Captcha token can only be accessed after built');
        }
        
        return md5(implode('', $this->getFingerprint()));
    }

Get 500 error

1.php version 7.3.8 with gd extension active
2.$builder->getPhrase(); can get the captche value
3. $builder->output() get the 500 error , only numbers display,

PhraseBuilder definition errors

Convert all your functions to static if you want the examples to be correct like that one: $phrase = \Gregwar\Captcha\PhraseBuilder::build(5, '0123456789'); or,
define constructor, build object and call member function: $phrase = new \Gregwar\Captcha\PhraseBuilder()->build(5, '0123456789');

I created Yii Extension for this library

Hi, thanks for developing this library.
I want to tell you that I've made an extension for Yii framework based on this library. Here is the repository yii2-captcha. I hope you like it.
If there are any problem please file an issue in that repository.

Thank you.

long generation pictures

I noticed that in some operating systems, for example windose 7, the generation of images takes a long time and even on centos with a version of php 5.6 image is generated 0.4 sec, is it possible to somehow speed this
I did profiling and noticed multiple function call floor and ceil
k-9m8oufnrfzgxbre9qmknvn7pcyiboj3qvoruycdg0

Division by zero

Hello, I have recently begun to see some of that's just such a message in the log

2015/06/08 15:41:56 [error] 23082
0: *8471087 FastCGI sent in stderr: "PHP message: PHP Warning: Division by zero in /var/www/vendor/gregwar/captcha/CaptchaBuilder.php on line 321" 
request: "GET /_gcb/generate-captcha/gcb_captcha?n=1433767309?1589940139 HTTP/1.1", 

VERSION v1.1

Thank you!

How to get the error generated by a wrongly filled Captcha?

Hello.
I have the bundle already working in Symfony2.0 (having installed the 2.0 version of the bundle).
It is apparently working fine, except for a simple question.

When I type a wrong captcha, just to test the behavior and give a proper message, I am finding that the form doesn't gives any error.

When I do

 $process = $formHandler->process($confirmationEnabled);

I get a FALSE, so the form won't succeed. Tat is correct, as I typed wrongly the captcha text.

Nevertheless, after that, when I try to catch the given error

$errors = $form->getErrors();

I am getting an empty array, and so no message is coming and no message is being shown in the visual layer. I don't think that is the normal behavior.

But the weirdest part comes now:

When I inspect the form, I get no errors. That might be expected because $form->getErrors() returned an empty array, as I said before. But when I inspect the form children, I clearly can see how the captcha child HAS the error indeed. Again, this is expected, because the captcha is avoiding the form to be successfully processed. But the question is: How do I get the "internal child" error I got in the captcha child?

Attaching two images. One with the "no errors" father form. And the other with de error captcha child.

form no errors
children errors

Thank you in advance!!

the picture can't display

Hello:
I use this package in two pros,same codes, both are laravel frameworks. But only one can display the picture. I hope you can help me.Thank you in advance for your kind help and I am looking forward to your answer.

Cleaning the code

Variables should be renamed, some comments added and some things like distortion factorized

Blank image

Hello guys

Autoload installed via composer... all is well. I also created a temp directory, writable in the same directory where the files of captcha are.

The result is a blank image :-(

The code is

	$builder = new CaptchaBuilder;
	$builder->build();
	echo "<pre>"; print_r($builder); echo "</pre>"; exit;
	header('Content-type: image/jpeg');
	$builder->output();
	exit;

When i uncomment the line starting with "echo", i get a blank image and the result of the print_r (the echo line) is as follows:

What am I doing wrong?

Gregwar\Captcha\CaptchaBuilder Object
(
    [fingerprint:protected] => Array
        (
            [0] => 0
            [1] => 207
            [2] => 221
            [3] => 228
            [4] => 2
            [5] => 253
            [6] => 155
            [7] => 239
            [8] => 0
            [9] => 26
            [10] => 20
            [11] => 97
            [12] => 32
            [13] => 3
            [14] => 240
            [15] => 154
            [16] => 163
            [17] => 1
            [18] => 14
            [19] => 39
            [20] => 145
            [21] => 9
            [22] => 2
            [23] => 1
            [24] => 61
            [25] => 56
            [26] => 69
            [27] => 8
            [28] => 5
            [29] => -3
            [30] => 2
            [31] => 0
            [32] => 0
            [33] => 4
            [34] => 2
            [35] => -6
            [36] => -4
            [37] => 3
            [38] => 0
            [39] => 4
            [40] => 1
            [41] => 77
            [42] => 37
            [43] => 3
            [44] => 0
            [45] => 107
            [46] => 14
            [47] => 45
            [48] => 29
            [49] => 3
            [50] => 1
            [51] => 65
            [52] => 19
            [53] => 79
            [54] => 13
            [55] => 1
            [56] => 121
            [57] => 28
            [58] => 7
            [59] => 46
            [60] => 0
            [61] => 0
            [62] => -6
            [63] => 3
        )

    [useFingerprint:protected] => 
    [textColor:protected] => Array
        (
        )

    [backgroundColor:protected] => 
    [backgroundImages:protected] => Array
        (
        )

    [contents:protected] => Resource id #3
    [phrase:protected] => 3jfj9
    [builder:protected] => Gregwar\Captcha\PhraseBuilder Object
        (
            [length] => 5
            [charset] => abcdefghijklmnpqrstuvwxyz123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ
        )

    [distortion:protected] => 1
    [maxFrontLines:protected] => 
    [maxBehindLines:protected] => 
    [maxAngle:protected] => 8
    [maxOffset:protected] => 5
    [interpolation:protected] => 1
    [ignoreAllEffects:protected] => 
    [allowedBackgroundImageTypes:protected] => Array
        (
            [0] => image/png
            [1] => image/jpeg
            [2] => image/gif
        )

    [tempDir] => temp/
    [background] => 13622756
)

in php 7.2 . count(null) get a warning 7.2中的count(null) 时报警告

hi man, php 7.2 version ,CaptchBuilder 333 line, count(null) has warning ,i know error_reporting setting ,but wish you fix this bug.

你好,我在php 7.2 版本使用这个组件,但是出现了错误警告,导致不能生成验证码,我知道可以定义 error_report 错误级别忽略,但是本着严谨的态度来说,希望可以修正这个错误。

$captcha->setBackgroundImages() $bg undefined index

like the title

if (empty($this->backgroundImages)) {
            // if background images list is not set, use a color fill as a background
            $image   = imagecreatetruecolor($width, $height);
            if ($this->backgroundColor == null) {
                $bg = imagecolorallocate($image, $this->rand(200, 255), $this->rand(200, 255), $this->rand(200, 255));
            } else {
                $color = $this->backgroundColor;
                $bg = imagecolorallocate($image, $color[0], $color[1], $color[2]);
            }
            $this->background = $bg;
            imagefill($image, 0, 0, $bg);
 } else {
            // use a random background image
            $randomBackgroundImage = $this->backgroundImages[rand(0, count($this->backgroundImages)-1)];

            $imageType = $this->validateBackgroundImage($randomBackgroundImage);

            $image = $this->createBackgroundImageFromType($randomBackgroundImage, $imageType);
        }

code in this part,if set background imaes,variable $bg will not be defined!

Sometimes, the results of getPhrase and inline are partly inconsistent

Why sometimes the characters of getPhrase () and the characters in inline () are inconsistent, not all are wrong, but the case of one of the letters is inconsistent.

E.g:
The image base64 from inline () is processed in the browser, and the result displayed is YF7B
But the result of getPhrase () is Yf7B

why? Is it a browser issue or a code design issue?

setBackgroundColor(r,g,b) 不生效

    $builder = new CaptchaBuilder();
    $builder->build(215,80);

    $builder->setBackgroundColor(0,0,0);

    $builder->setIgnoreAllEffects(false);
    $code=$builder->getPhrase();
    header("Cache-Control: no-cache, must-revalidate");
    header('Content-Type: image/jpeg');
    $builder->output();

from 1.1.5 update to 1.1.6。Problem appear:Can't show pictures。

Method:$builder->save('out.jpg'); or <img src="<?php echo $builder->inline(); ?>" /> no problem
The problem is that:

header('Content-type: image/jpeg');
$builder->output();

After output,inline it directly in the HTML page。
Directly nested this page in the IMG label:
<img name="randomImage" id="randomImage" src="http://test.com/login/captcha/1" title="Refresh" size="10">

The following is the code:

$phrase= new PhraseBuilder;
$code= $phrase->build(4);
$builder = new CaptchaBuilder($code, $phrase);;
$builder->setBackgroundColor(255, 255, 255);
$builder->build($width = 80, $height = 38, $font = null);
$phrase = $builder->getPhrase();
Session::flash('logincaptcha', `$phrase);`
header("Cache-Control: no-cache, must-revalidate");
header('Content-Type: image/jpeg');
$builder->output();

Why Finder 3.0 ?

Is there anything that prevents it from working with Finder 2.8?

I am using this package through gregwar/captcha-bundle, which will work with Symfony 2.8. However, gregwar/captcha requires Finder 3.0 or above. As the result, I get gregwar/captcha v1.1.3 which is not compatible with PHP 7, while Symfony 2.8 is.

Bug - Image shown is different than $expectedCode

I have no idea what exactly causes this, but some times when testing, I notice that when I fill in the image correctly, I have an error saying that it's invalid.

The $expectedCode isn't equal to $form->getData() and mostly happens after testing the same form a couple of times. I can only fix this with a hard page reload or a manual press on "renew". The return is not null, it's an actual different code than show in the image.

My configuration:

gregwar_captcha:
    quality:          100
    distortion:       false
    height:           65
    width:            270
    reload:           true
    as_url:           true
    interpolation:    true
    background_color: [255, 255, 255]

What am i doing wrong?

I installed via composer

build(); header('Content-type: image/jpeg'); $builder->output(); On IE , in the console, i see DOM7009: Unable to decode image at URL: '<>' with MIME: 'image/jpeg'. In firefox, in the main browser window, i see "the image <<>> cannot be displayed as it contains errors If i remove the header line, i do see a lot of junk chars and a jpeg header being sent out. So it does look like i have the relevant libraries for PHP installed $my_dir is outside my web directory, but i don't think that should matter, right? Thanks in advance for any help!!!!

text_color works only in global config.yml ?

Hi
I'm tring to put the text_color parameter in the form definition as the follow exemple:
$builder->
add(...)
...
->add('captcha', 'captcha', array('text_color' => array(255,0,0) ))
...

But seems that it takes only the global config in the config.yml :
....
gregwar_captcha:
width: 100
height: 50
quality: 20
background_color: [255, 255, 255]
text_color: [255, 0, 0]
...

Can you check please ?
Thanx
Andrea

Captcha render text I to J

Hello,

I'm using Captcha, and I have noticed that sometimes the code i.e ABIDE will be built as ABJDE in image.

Do you have any idea why is that mistake happened by Captcha builder->build()?

How can I reload the captcha with AJAX?

I have a form, on submit button click, with AJAX I am calling the php that sends the mail and once the email is sent the form refreshes, how can I generate a new captcha once the form is sent?

$builder->testPhrase always returns false

I tried captcha as explained in readme file but it doesn't work

<?php

require_once 'vendor/autoload.php';

session_start();

use Gregwar\Captcha\CaptchaBuilder;
$builder = new CaptchaBuilder;
$builder->buildAgainstOCR(); // Also tried with build() method

if (!empty($_POST['submit'])) {
    $user_input = $_POST['captcha'];
    if ($builder->testPhrase($user_input)) {
        echo "OK!";
    } else {
        echo "Wrong answer";
    }
}
?>

<!doctype html>
<html lang="tr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <img src="<?= $builder->inline(); ?>" alt="">
    <form action="captcha-test.php" method="post">
        <label for="captcha">Enter Text: </label>
        <input name="captcha" id="captcha">
        <input type="submit" name="submit" value="OK">
    </form>
</body>
</html>

ErrorException: count()

ErrorException: count(): Parameter must be an array or an object that implements Countable in C:\OpenServer\domains\site.dev\vendor\gregwar\captcha\CaptchaBuilder.php:333

I'm using PHP 7.2 RC2

both upper & lower case in v1.1.8

In v1.1.7, getPhrase() will only return string in lower-case,
while in v1.1.8, getPhrase() will return upper&lower characters.
if there is a notice in README, it'll be better to prevent someone get confused after doing composer update

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.