Your IP : 216.73.216.170


Current Path : /var/www/iplanru/data/www/i-plan.ru/components/com_pay/models/fields/
Upload File :
Current File : /var/www/iplanru/data/www/i-plan.ru/components/com_pay/models/fields/mycaptcha.php

<?php
 
/**
 * @package     Joomla.Administrator
 * @subpackage  com_content
 *
 * @copyright   Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */
 
defined( 'JPATH_BASE' ) or die;
/**
 * Class JFormFieldMyCaptcha
 */
class JFormFieldMyCaptcha extends JFormFieldText
{
 
    /**
     * @var string
     */
    protected $type = 'MyCaptcha';
 
    /**
     * Метод для создания поля
     * @return string
     */
    public function getInput()
    {
        //Устанавливаем атрибуты сессии
        $size = $this->element['size'] ? ' size="' . (int)$this->element['size'] . '"' : '';
        $maxLength = $this->element['maxlength'] ? ' maxlength="' . (int)$this->element['maxlength'] . '"' : '';
        $class = $this->element['class'] ? ' class="' . (string)$this->element['class'] . '"' : '';
        $readonly = ( (string)$this->element['readonly'] == 'true' ) ? ' readonly="readonly"' : '';
        $disabled = ( (string)$this->element['disabled'] == 'true' ) ? ' disabled="disabled"' : '';
        $onchange = $this->element['onchange'] ? ' onchange="' . (string)$this->element['onchange'] . '"' : '';
        //Генерируем два случайных числа
        $number1 = mt_rand( 1, 9 );
        $number2 = mt_rand( 1, 9 );
        //Получаем сессию
        $session = JFactory::getSession();
        //Устанавливаем в сессию значение суммы наших сгенерированных чисел
        $session->set( 'mycaptcha', $number1 + $number2 );
        //Формируем поле
        $html = 'Пожалуйста подтвердите, что Вы не программа: ' . $number1 . ' + ' . $number2 . ' = ';
        $html .= '<input type="text" name="' . $this->name . '" id="' . $this->id . '"' . ' value="'
            . htmlspecialchars( $this->value, ENT_COMPAT, 'UTF-8' ) . '"' . $class . $size . $disabled . $readonly . $onchange . $maxLength . '/>';
        return $html;
    }
}