Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

si_captcha_mathmatic and getCaptchaHtml() not working #55

Open
skibulk opened this issue Apr 11, 2016 · 3 comments
Open

si_captcha_mathmatic and getCaptchaHtml() not working #55

skibulk opened this issue Apr 11, 2016 · 3 comments

Comments

@skibulk
Copy link

skibulk commented Apr 11, 2016

I would expect the following code to generate a math captcha, but it keeps generating an alphanumeric captcha.

    <?php
    require_once('./inc/securimage/securimage.php');
    $securimage = new Securimage([
        'captcha_type'=>Securimage::SI_CAPTCHA_MATHEMATIC,
    ]);
    echo $securimage->getCaptchaHtml();
    ?>
@dapphp
Copy link
Owner

dapphp commented Apr 11, 2016

getCaptchaHtml has the ability to control some aspects of the captcha, but nothing that affects the properties of the image itself. The reason for this is because there is no facility to pass customization options through the URL to affect the appearance of the captcha image (malicious users could then customize the appearance of your image to make it easier to solve).

If you want to use a math captcha, you can either change the properties in securimage_show.php, or edit config.inc.php in the securimage directory and set the appearance options there.

Acceptable options to getCaptchaHtml() can be seen here.

@skibulk
Copy link
Author

skibulk commented Apr 11, 2016

That makes sense, thanks. It might be helpful to list the bad properties under getCaptchaHtml in the docs, with your explanation. I did a page search for "captcha_type", but didn't find this information.

@dapphp
Copy link
Owner

dapphp commented May 21, 2016

I agree, they need to be documented somewhere better, other than the code.

Currently they are:

/**
 * Returns HTML code for displaying the captcha image, audio button, and form text input.
 *
 * Options can be specified to modify the output of the HTML.  Accepted options:
 *
 *     'securimage_path':
 *         Optional: The URI to where securimage is installed (e.g. /securimage)
 *     'show_image_url':
 *         Path to the securimage_show.php script (useful when integrating with a framework or moving outside the securimage directory)
 *         This will be passed as a urlencoded string to the <img> tag for outputting the captcha image
 *     'audio_play_url':
 *         Same as show_image_url, except this indicates the URL of the audio playback script
 *     'image_id':
 *          A string that sets the "id" attribute of the captcha image (default: captcha_image)
 *     'image_alt_text':
 *         The alt text of the captcha image (default: CAPTCHA Image)
 *     'show_audio_button':
 *         true/false  Whether or not to show the audio button (default: true)
 *     'disable_flash_fallback':)
 *         Allow only HTML5 audio and disable Flash fallback
 *     'show_refresh_button':
 *         true/false  Whether or not to show a button to refresh the image (default: true)
 *     'audio_icon_url':
 *         URL to the image used for showing the HTML5 audio icon
 *     'icon_size':
 *         Size (for both height & width) in pixels of the audio and refresh buttons
 *     'show_text_input':
 *         true/false  Whether or not to show the text input for the captcha (default: true)
 *     'refresh_alt_text':
 *         Alt text for the refresh image (default: Refresh Image)
 *     'refresh_title_text':
 *         Title text for the refresh image link (default: Refresh Image)
 *     'input_id':
 *         A string that sets the "id" attribute of the captcha text input (default: captcha_code)
 *     'input_name':
 *         A string that sets the "name" attribute of the captcha text input (default: same as input_id)
 *     'input_text':
 *         A string that sets the text of the label for the captcha text input (default: Type the text:)
 *     'input_attributes':
 *         An array of additional HTML tag attributes to pass to the text input tag (default: empty)
 *     'image_attributes':
 *         An array of additional HTML tag attributes to pass to the captcha image tag (default: empty)
 *     'error_html':
 *         Optional HTML markup to be shown above the text input field
 *     'namespace':
 *         The optional captcha namespace to use for showing the image and playing back the audio. Namespaces are for using multiple captchas on the same page.
 *
 * @param array $options Array of options for modifying the HTML code.
 * @param int   $parts Securiage::HTML_* constant controlling what component of the captcha HTML to display
 *
 * @return string  The generated HTML code for displaying the captcha
 */
public static function getCaptchaHtml($options = array(), $parts = Securimage::HTML_ALL)

For reference, they are in securimage.php at function getCaptchaHtml(). I'll leave this open for a while longer for any feedback and easier accessibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants