예제 #1
0
 /**
  * Add a captcha with an input field to the form. The captcha could be a picture with a character code
  * or a simple mathematical calculation that must be solved.
  * @param string $id    Id of the captcha field. This will also be the name of the captcha field.
  * @param string $type  The of captcha that should be shown. This can be characters in a image or
  *                      simple mathematical calculation. Possible values are @b pic or @b calc.
  * @param string $class (optional) An additional css classname. The class @b admTextInput
  *                      is set as default and need not set with this parameter.
  */
 public function addCaptcha($id, $type, $class = '')
 {
     global $gL10n, $g_root_path;
     $attributes = array('class' => 'captcha');
     ++$this->countElements;
     // set specific css class for this field
     if ($class !== '') {
         $attributes['class'] .= ' ' . $class;
     }
     // add a row with the captcha puzzle
     $this->openControlStructure('captcha_puzzle', '');
     $captchaLabel = '';
     $captchaDescription = '';
     if ($type === 'pic') {
         $this->addHtml('<img src="' . $g_root_path . '/adm_program/system/show_captcha.php?id=' . time() . '" alt="' . $gL10n->get('SYS_CAPTCHA') . '" />');
         $captchaLabel = $gL10n->get('SYS_CAPTCHA_CONFIRMATION_CODE');
         $captchaDescription = 'SYS_CAPTCHA_DESCRIPTION';
     } elseif ($type === 'calc') {
         $captcha = new Captcha();
         $this->addHtml($captcha->getCaptchaCalc($gL10n->get('SYS_CAPTCHA_CALC_PART1'), $gL10n->get('SYS_CAPTCHA_CALC_PART2'), $gL10n->get('SYS_CAPTCHA_CALC_PART3_THIRD'), $gL10n->get('SYS_CAPTCHA_CALC_PART3_HALF'), $gL10n->get('SYS_CAPTCHA_CALC_PART4')));
         $captchaLabel = $gL10n->get('SYS_CAPTCHA_CALC');
         $captchaDescription = 'SYS_CAPTCHA_CALC_DESCRIPTION';
     }
     $this->closeControlStructure();
     // now add a row with a text field where the user can write the solution for the puzzle
     $this->addInput($id, $captchaLabel, '', array('property' => FIELD_REQUIRED, 'helpTextIdLabel' => $captchaDescription, 'class' => 'form-control-small'));
 }
예제 #2
0
<?php

/**
 ***********************************************************************************************
 * Ausgabe einer Captcha Vorschau
 *
 * @copyright 2004-2015 The Admidio Team
 * @see http://www.admidio.org/
 * @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2.0 only
 ***********************************************************************************************
 */
require_once '../../system/common.php';
echo '
<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
    <h4 class="modal-title">' . $gL10n->get('ORG_CAPTCHA_PREVIEW') . '</h4>
</div>
<div class="modal-body">';
if ($gPreferences['captcha_type'] === 'pic') {
    $height = $gPreferences['captcha_height'] + 25;
    $width = $gPreferences['captcha_width'] + 25;
    echo '<img src="' . $g_root_path . '/adm_program/system/show_captcha.php?id=' . time() . '" alt="' . $gL10n->get('SYS_CAPTCHA') . '" />';
} elseif ($gPreferences['captcha_type'] === 'calc') {
    $captcha = new Captcha();
    echo $captcha->getCaptchaCalc($gL10n->get('SYS_CAPTCHA_CALC_PART1'), $gL10n->get('SYS_CAPTCHA_CALC_PART2'), $gL10n->get('SYS_CAPTCHA_CALC_PART3_THIRD'), $gL10n->get('SYS_CAPTCHA_CALC_PART3_HALF'), $gL10n->get('SYS_CAPTCHA_CALC_PART4'));
    echo '<br><i>(' . $gL10n->get('SYS_CAPTCHA_CALC') . ': ' . $_SESSION['captchacode'] . ')</i>';
}
echo '</div>';