<commit_before><?php
/**
 * $Id: Captcha.php,v 1.7 2007-01-05 17:38:13 matteo Exp $
 *
 * The phpMyFAQ Captcha class
 *
 * @author      <NAME> <<EMAIL>>
 * @author      <NAME> <<EMAIL>>
 * @author      <NAME> <<EMAIL>>
 * @since       2006-02-04
 * @copyright   (c) 2006 phpMyFAQ Team
 *
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 */

class PMF_Captcha
{
    /**
     * The database handle
     *
     * @var mixed
     */
    var $db;

    /**
     * The phpMyFAQ session id
     *
     * @var string
     */
    var $sids;

    /**
     * Array of fonts
     *
     * @var array
     */
    var $fonts = array();

    /**
     * The captcha code
     *
     * @var string
     */
    var $code;

    /**
     * Array of characters
     *
     * @var array
     */
    var $letters;

    /**
     * Length of the captcha code
     *
     * @var integer
     */
    var $caplength;

    /**
     * Width of the image
     *
     * @var integer
     */
    var $width;

    /**
     * Height of the image
     *
     * @var integer
     */
    var $height;

    /**
     * JPEG quality in percents
     *
     * @var integer
     */
    var $quality;

    /**
     * Random background color RGB components
     *
     * @var array
     */
    var $_backgroundColor;

    /**
     * Generated image
     *
     * @var resource
     */
    var $img;

    /**
     * The user agent language
     *
     * @var string
     */
    var $language;

    /**
     * The user agent string
     *
     * @var string
     */
    var $userAgent;

    /**
     * Timestamp
     *
     * @var integer
     */
    var $timestamp;

    /**
     * Constructor
     *
     * @param   object  $db
     * @param   string  $sids
     * @param   string  $language
     * @param   integer $caplength
     * @return  void
     * @author  <NAME> <<EMAIL>>
     * @author  <NAME> <<EMAIL>>
     */
    function PMF_Captcha($db, $sids, $language, $caplength = 6)
    {
        $this->db           =& $db;
        if ($sids > 0) {
            $this->sids     = $sids;
        } else {
            $this->sids     = '';
        }
        $this->language     = $language;
        $this->userAgent    = $_SERVER['HTTP_USER_AGENT'];
        $this->ip           = $_SERVER['REMOTE_ADDR'];
        $this->caplength    = $caplength;
        $this->letters      = array('1', '2', '3', '4', '5', '6', '7', '8', '9',
                                    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
                                    'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
                                    'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' );
        $this->code          = '';
        $this->quality       = 60;
        $this->fonts         = $this->getFonts();
        $this->width         = 200;
        $this->height         = 40;
        $this->timestamp     = time();
    }

    //
    // public functions
    //

    /**
     * printCaptcha()
     *
     * Gives the HTML output code for the Captcha
     *
     * @param   string  The action parameter
     * @return  string
     * @access  public
     * @since   2006-02-02
     * @author  <NAME> <<EMAIL>>
     * @author  <NAME> <<EMAIL>>
     * @author  <NAME> <<EMAIL>>
     */
    function printCaptcha($action)
    {
        $output = sprintf(
            '<img src="%s?%saction=%s&amp;gen=img&amp;ck=%s" height="%d" width="%d" border="0" alt="Follow the white rabbit." title="Follow the white rabbit." />',
            $_SERVER['PHP_SELF'],
            $this->sids,
            $action,
            time(),
            $this->height,
            $this->width);
        return $output;
    }

    /**
     * showCaptchaImg()
     *
     * Draw the Captcha
     *
     * @return  void<commit_msg>Added new string for missing captchas<commit_after><?php
/**
 * $Id: Captcha.php,v 1.8 2007-02-10 21:59:02 thorstenr Exp $
 *
 * The phpMyFAQ Captcha class
 *
 * @author      <NAME> <<EMAIL>>
 * @author      <NAME> <<EMAIL>>
 * @author      <NAME> <<EMAIL>>
 * @since       2006-02-04
 * @copyright   (c) 2006-2007 phpMyFAQ Team
 *
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 */

class PMF_Captcha
{
    /**
     * The database handle
     *
     * @var mixed
     */
    var $db;

    /**
     * The phpMyFAQ session id
     *
     * @var string
     */
    var $sids;

    /**
     * Array of fonts
     *
     * @var array
     */
    var $fonts = array();

    /**
     * The captcha code
     *
     * @var string
     */
    var $code;

    /**
     * Array of characters
     *
     * @var array
     */
    var $letters;

    /**
     * Length of the captcha code
     *
     * @var integer
     */
    var $caplength;

    /**
     * Width of the image
     *
     * @var integer
     */
    var $width;

    /**
     * Height of the image
     *
     * @var integer
     */
    var $height;

    /**
     * JPEG quality in percents
     *
     * @var integer
     */
    var $quality;

    /**
     * Random background color RGB components
     *
     * @var array
     */
    var $_backgroundColor;

    /**
     * Generated image
     *
     * @var resource
     */
    var $img;

    /**
     * The user agent language
     *
     * @var string
     */
    var $language;

    /**
     * The user agent string
     *
     * @var string
     */
    var $userAgent;

    /**
     * Timestamp
     *
     * @var integer
     */
    var $timestamp;

    /**
     * Constructor
     *
     * @param   object  $db
     * @param   string  $sids
     * @param   string  $language
     * @param   integer $caplength
     * @return  void
     * @author  <NAME> <<EMAIL>>
     * @author  <NAME> <<EMAIL>>
     */
    function PMF_Captcha($db, $sids, $language, $caplength = 6)
    {
        $this->db           =& $db;
        if ($sids > 0) {
            $this->sids     = $sids;
        } else {
            $this->sids     = '';
        }
        $this->language     = $language;
        $this->userAgent    = $_SERVER['HTTP_USER_AGENT'];
        $this->ip           = $_SERVER['REMOTE_ADDR'];
        $this->caplength    = $caplength;
        $this->letters      = array('1', '2', '3', '4', '5', '6', '7', '8', '9',
                                    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
                                    'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
                                    'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' );
        $this->code          = '';
        $this->quality       = 60;
        $this->fonts         = $this->getFonts();
        $this->width         = 200;
        $this->height         = 40;
        $this->timestamp     = time();
    }

    //
    // public functions
    //

    /**
     * printCaptcha()
     *
     * Gives the HTML output code for the Captcha
     *
     * @param   string  The action parameter
     * @return  string
     * @access  public
     * @since   2006-02-02
     * @author  <NAME> <<EMAIL>>
     * @author  <NAME> <<EMAIL>>
     * @author  <NAME> <<EMAIL>>
     */
    function printCaptcha($action)
    {
        $output = sprintf(
            '<img src="%s?%saction=%s&amp;gen=img&amp;ck=%s" height="%d" width="%d" border="0" alt="Chuck Norris has counted to infinity. Twice." title="Chuck Norris has counted to infinity. Twice." />',
            $_SERVER['PHP_SELF'],
            $this->sids,
            $action,
            time(),
            $this->height,
            $this->width);
        return $output;
    }

    /**
     * showCaptchaImg()
     *
     * Draw the Captcha
     *
     * @return  void
{'fraction_non_alphanumeric': 0.15217391304347827, 'fraction_numerical': 0.014017581373247802, 'mean_word_length': 1.471088934546522, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 91, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3592309', 'n_tokens_mistral': 2842, 'n_tokens_neox': 2699, 'n_words': 734}