Giter Club home page Giter Club logo

fluxbb_addon_verysimpleantibot's People

Contributors

gwron avatar

Stargazers

 avatar

Watchers

 avatar  avatar

fluxbb_addon_verysimpleantibot's Issues

Use variables instead of calling functions

These functions $this->get_chosen_question() and $this->get_chosen_question_hash() don't need to be called, but instead use their respective variables $this->chosen_question and $this->chosen_question_hash due to this if (!$this->do_choose_question()):

        //select a random question and skip showing the captcha form
        //when failing (no questions available)
        if (!$this->do_choose_question())
            return;

        global $lang_addon_vsab, $lang_common;
        ?>
        <div class="inform">
            <fieldset>
                <legend><?php echo $lang_addon_vsab['title'] ?></legend>
                <div class="infldset">
                    <p><?php echo $lang_addon_vsab['info'] ?></p>
                    <label class="required">
                        <strong><?php echo sprintf($lang_addon_vsab['question'], $this->get_chosen_question()) ?></strong>
                        <br />
                        <strong><?php echo $lang_common['Required'] ?></strong>
                        <input name="vsab_question" value="<?php echo   $this->get_chosen_question_hash() ?>" type="hidden" />

Use create_hash in is_valid_hash

This calculation is in both functions.
md5($text . date('dmYH') . $pun_config['vsab_salt'])

Perhaps, use create_hash in is_valid_hash. If yes, create_hash will have to be modified to accommodate the previous hour checking.

Use array_rand

This could be simplified:

//load in the questions of the question=>answer array
$questions = array_keys($addon_vsab_questions);
//choose random question index and generate hash
$this->chosen_question = $questions[ rand(0, count($questions)-1) ];

to:
$this->chosen_question = array_rand($addon_vsab_questions);

Add a comma to the last question/answer entry

'Fill in the missing letters: Are you a human or a c**puter??' => "om"
Just in case this entry is copied and the admin forgets to add a comma before pasting it after this entry.

Check for hidden field username

Related to this mod or added bonus?

        //if the hidden field username contains something, then it was
        //completed by a bot.
        if(!empty($_REQUEST['username']))
        {
            global $lang_register;
            message($lang_register['No new regs']);
        }

Simplify language file loading

In 2 places, simplify this since it does the same test in load_language_and_questions:

        if (!$this->language_file_loaded)
            $this->load_language_and_questions();

to:

            $this->load_language_and_questions();

For example, in verify_question_answer, it checks for language_file_loaded and then again in load_language_and_questions.

Code cleanup

line 239: $questions = array();
Remove since unused in the function.

line 276: <?php if (isset($action) && $action == 'registration') : ?>
$action defaults to empty string in the argument so not necessary to check with isset.

No captcha value in required_fields

    var required_fields = {
        "req_user": "Username",
        "req_password1": "Password",
        "req_password2": "Confirm password",
        "req_email1": "Email",
        "req_email2": "Email 2",
        "captcha": ""
    };

Answers case-senstivity

Answer comparison is case-sensitive. I can see it as an additional layer of defense. However, should it be? I can see a user not realizing this and has Caps Lock on in which case the check will fail. Thoughts?

Delete get_chosen_question_index()

Currently, not being used.

    //return the index of the currently chosen question
    //selects a question if not done yet
    function get_chosen_question_index()
    {
        if ($this->chosen_question_index < 0)
            do_choose_question();
        return $this->chosen_question_index;
    }

Register only applicable hooks?

I am not sure if this is better to do have_to_check_user in register function and only register the applicable hooks. Then you don't need to do this check within the other functions.

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.