本文整理汇总了PHP中yii\captcha\Captcha类的典型用法代码示例。如果您正苦于以下问题:PHP Captcha类的具体用法?PHP Captcha怎么用?PHP Captcha使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Captcha类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
<?php
$form = ActiveForm::begin(['id' => 'contact-form', 'action' => '/contact']);
?>
<?php
echo $form->field($model, 'email')->textInput(['placeholder' => 'email'])->label(false);
?>
<div class="clear" style="height:20px"></div>
<?php
echo $form->field($model, 'subject')->textInput(['placeholder' => 'тема'])->label(false);
?>
<div class="clear" style="height:20px"></div>
<?php
echo $form->field($model, 'body')->textArea(['rows' => 6])->label(false);
?>
<div class="clear" style="height:20px"></div>
<?php
echo $form->field($model, 'verifyCode')->widget(Captcha::className(), ['template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>', 'options' => ['placeholder' => 'введите код']])->label(false);
?>
<div class="clear" style="height:20px"></div>
<div class="form-group">
<?php
echo Html::submitButton('Отправить', ['class' => 'btn btn-primary', 'name' => 'contact-button']);
?>
</div>
<div class="clear" style="height:16px"></div>
<span class="form_hint">Чтобы закрыть форму нажмите ESC</span>
<?php
ActiveForm::end();
?>
</div>
示例2: run
/**
* @inheritdoc
*
* Takes the decision of rendering the widget or not depending on the number
* of requests made from the client IP.
*/
public function run()
{
$captchaControl = new CaptchaControl(['model' => $this->model]);
if ($captchaControl->hasReachedRequestNumber()) {
parent::run();
}
}
示例3: init
/**
* @inheritdoc
*/
public function init()
{
/**
* @var Module $m
*/
$m = Yii::$app->getModule('user');
if (!$m->getRegistrationSetting('randomUsernames', $this->userType)) {
$this->attributes['username'] = ['type' => Form::INPUT_TEXT, 'options' => ['autocomplete' => 'new-username']];
}
if (!$m->getRegistrationSetting('randomPasswords', $this->userType)) {
$password = ['type' => Form::INPUT_PASSWORD];
if (in_array(Module::SCN_REGISTER, $m->passwordSettings['strengthMeter'])) {
$password = ['type' => Form::INPUT_WIDGET, 'widgetClass' => PasswordInput::classname(), 'options' => ['options' => ['placeholder' => Yii::t('user', 'Password'), 'autocomplete' => 'off']]];
}
$this->attributes['password'] = $password;
}
$this->attributes['email'] = ['type' => Form::INPUT_TEXT];
$captcha = ArrayHelper::getValue($m->registrationSettings, 'captcha', false);
if ($captcha !== false && is_array($captcha)) {
$this->attributes['captcha'] = ['type' => Form::INPUT_WIDGET, 'widgetClass' => Captcha::classname(), 'options' => $captcha['widget']];
}
parent::init();
unset($this->attributes['rememberMe']);
$this->leftFooter = $m->button(Module::BTN_HOME) . $m->button(Module::BTN_ALREADY_REGISTERED);
$this->rightFooter = $m->button(Module::BTN_RESET_FORM) . ' ' . $m->button(Module::BTN_REGISTER);
}
示例4: renderForm
public function renderForm()
{
if (isset($this->form) && $this->form->active) {
$model = $this->model;
$activeForm = $this->activeForm;
$fieldsHtml = FormUtil::getFieldsHtml($activeForm, $this->model, ['label' => $this->showLabel]);
echo $fieldsHtml;
if ($this->form->captcha) {
if ($this->showLabel) {
$captchaHtml = $activeForm->field($model, 'captcha')->widget(Captcha::classname(), ['options' => ['placeholder' => 'Captcha*']]);
} else {
$captchaHtml = $activeForm->field($model, 'captcha')->label(false)->widget(Captcha::classname(), ['options' => ['placeholder' => 'Captcha*']]);
}
echo $captchaHtml;
}
if (!isset($this->formActions)) {
echo "<div class='frm-actions'><input type='submit' value='Submit' /></div>";
} else {
echo $this->formActions;
}
} else {
echo "<div class='warning'>Form submission is disabled by site admin.</div>";
}
}
示例5:
<div class="login text-center">
<div class="login-form col-lg-5">
<div class="panel panel-default text-left">
<div class="panel-heading"><strong>登录</strong></div>
<div class="panel-body">
<?php
$form = ActiveForm::begin(['id' => 'login', 'options' => ['class' => 'form-horizontal'], 'fieldConfig' => ['labelOptions' => ['class' => 'col-lg-2 control-label'], 'template' => "{label}<div class='col-lg-8'>{input}\n{error}</div>"]]);
?>
<?php
echo $form->field($model, 'username');
?>
<?php
echo $form->field($model, 'password')->passwordInput();
?>
<?php
echo $form->field($model, 'captcha')->widget(Captcha::className(), ['imageOptions' => ['class' => 'captcha'], 'template' => "<div class='row'><div class='col-lg-4'>{image}</div><div class='col-lg-8'>{input}</div></div>"]);
?>
<div class="form-group">
<div class="col-lg-2"></div>
<div class="col-lg-7">
<?php
echo Html::submitButton('登 录', ['class' => 'btn btn-primary', 'name' => 'login-button']);
?>
</div>
</div>
<?php
ActiveForm::end();
?>
</div>
</div>
</div>
示例6:
<div id="slide-content2" class="row" style="margin: 0; padding: 0;">
<div class="mail" style="">
<?php
echo $form->field($model, 'username', ['inputTemplate' => '{input}', 'inputOptions' => ['id' => 'input-username-check', 'style' => 'margin-bottom: -10px;', 'class' => 'form-control pva-border', 'placeholder' => 'Username']])->label(false);
?>
<?php
echo $form->field($model, 'email', ['inputTemplate' => '{input}', 'inputOptions' => ['id' => 'input-mail-check', 'style' => 'margin-bottom: -10px;', 'class' => 'form-control pva-border', 'placeholder' => 'Email']])->label(false);
?>
<?php
echo $form->field($model, 'password', ['inputTemplate' => '{input}', 'inputOptions' => ['id' => 'input-password-check', 'style' => 'margin-bottom: -10px;', 'class' => 'form-control pva-border', 'placeholder' => 'Password']])->passwordInput()->label(false);
?>
</div>
<div class="vfy" style="">
<?php
echo $form->field($model, 'verifyCode')->label(false)->widget(Captcha::className(), ['template' => '<div class="display: inline;"><label class="pull-left" style="color: white;">Captcha Code: </label><div class="text-right">{image}</div><div style="margin-top: 25px; margin-bottom: 25px; color: white;">* * Click image to generate new captcha code</div></div><p></p>{input}']);
?>
</div>
</div>
</div>
</div>
<div class="slide-btn">
<button type="button" id="btn-info-check" class="btn btn-primary btn-block pva-border" style="height: 46px; background: #337AB7; border: 0;" data-toggle="modal" data-target="#verify">NEXT</button>
</div>
</div>
<p id="msg-info-check" style="color: white; font-size: 16px; margin-top: 20px;"></p>
</div>
</div>
</div>
</div>
</div>
示例7: array
<div class="form-group">
<?php
//echo $form->labelEx($model, 'email');
?>
<?php
echo $form->textField($model, 'email', array('class' => 'form-control', 'id' => 'email_txt', 'placeholder' => Yii::t('UserModule.views_auth_recoverPassword', 'your email')));
?>
<?php
echo $form->error($model, 'email');
?>
</div>
<div class="form-group">
<?php
echo \yii\captcha\Captcha::widget(['model' => $model, 'attribute' => 'verifyCode', 'captchaAction' => '/user/auth/captcha', 'options' => array('class' => 'form-control', 'placeholder' => Yii::t('UserModule.views_auth_recoverPassword', 'enter security code above'))]);
?>
<?php
echo $form->error($model, 'verifyCode');
?>
</div>
<hr>
<?php
echo \humhub\widgets\AjaxButton::widget(['label' => Yii::t('UserModule.views_auth_recoverPassword', 'Reset password'), 'ajaxOptions' => ['type' => 'POST', 'beforeSend' => new yii\web\JsExpression('function(){ setModalLoader(); }'), 'success' => 'function(html){ $("#globalModal").html(html); }', 'url' => Url::to(['/user/password-recovery'])], 'htmlOptions' => ['class' => 'btn btn-primary', 'id' => 'recoverPasswordBtn']]);
echo \humhub\widgets\AjaxButton::widget(['label' => Yii::t('UserModule.views_auth_recoverPassword', 'Back'), 'ajaxOptions' => ['type' => 'POST', 'beforeSend' => new yii\web\JsExpression('function(){ setModalLoader(); }'), 'success' => 'function(html){ $("#globalModal").html(html); }', 'url' => Url::to(['/user/auth/login'])], 'htmlOptions' => ['class' => 'btn btn-primary', 'id' => 'backBtn']]);
?>
<?php
CActiveForm::end();
?>
</div>
示例8:
<?php
echo $form->field($model, 'username');
?>
<?php
if ($module->enableGeneratingPassword == false) {
?>
<?php
echo $form->field($model, 'password')->passwordInput();
?>
<?php
}
?>
<?php
echo $form->field($model, 'captcha')->widget(\yii\captcha\Captcha::className(), ['captchaAction' => ['/site/captcha']]);
?>
<?php
echo Html::submitButton(Yii::t('user', 'Sign up'), ['class' => 'btn btn-success btn-block']);
?>
<?php
ActiveForm::end();
?>
</div>
</div>
<p class="text-center">
<?php
echo Html::a(Yii::t('user', 'Already registered? Sign in!'), ['/user/security/login']);
?>
示例9:
<div class="row">
<div class="col-lg-9">
<?php
$form = ActiveForm::begin(['id' => 'form-signup', 'layout' => 'horizontal', 'fieldConfig' => ['template' => "{label}\n{beginWrapper}\n{input}\n{hint}\n{error}\n{endWrapper}", 'horizontalCssClasses' => ['label' => 'col-sm-4', 'offset' => 'col-sm-offset-4', 'wrapper' => 'col-sm-8', 'error' => '', 'hint' => '']]]);
?>
<?php
echo $form->field($model, 'username')->textInput(['maxlength' => 255]);
?>
<?php
echo $form->field($model, 'email')->textInput(['maxlength' => 255]);
?>
<?php
echo $form->field($model, 'password')->passwordInput(['maxlength' => 255]);
?>
<?php
echo $form->field($model, 'verifyCode')->widget(Captcha::className(), ['captchaAction' => '/account/captcha', 'imageOptions' => ['alt' => '点击换图', 'title' => '点击换图', 'style' => 'cursor:pointer'], 'template' => '<div class="row"><div class="col-lg-8">{input}</div><div class="col-lg-4">{image}</div></div>']);
?>
<div class="form-group">
<div class="col-sm-offset-4 col-sm-9">
<?php
echo Html::submitButton('注册', ['class' => 'btn btn-primary', 'name' => 'signup-button']);
?>
</div>
</div>
<?php
ActiveForm::end();
?>
</div>
</div>
</article>
示例10:
$field = $form->field($model, "data[note]");
$field->template = "{input}";
echo $field->textArea(["class" => "form-control required", "placeholder" => Yii::t("app", "Notes for us / special request")]);
$model->data = $data;
?>
</div>
<?php
if ($model->captchaRequired) {
?>
<div class="well">
<div class="row">
<?php
echo $form->field($model, "captcha")->widget(Captcha::classname(), ['captchaAction' => ['/yes/order/captcha'], 'imageOptions' => ['class' => 'col-sm-4 col-xs-6', 'style' => 'margin:20px -5px 20px -5px;max-height:80px;cursor:pointer;'], 'options' => ['class' => 'col-sm-8 col-xs-6']]);
?>
</div>
</div>
<?php
}
?>
<hr>
<a onclick="$('#ordertab a[href=\'#summary\']').tab('show')" class="btn btn-warning btn-tab pull-left" ><?php
echo Yii::t("app", "Previous");
?>
</a>
<div class="form-group">
示例11:
?>
<div class="alert alert-warning" role="alert"><?php
echo $session->getFlash('resignup');
?>
</div>
<?php
}
?>
<?php
echo $form->field($model, 'mobile');
?>
<?php
echo $form->field($model, 'password')->passwordInput();
?>
<?php
echo $form->field($model, 'captcha')->widget(Captcha::className(), ['template' => "<div class=\"row\">\n<div class=\"col-xs-6\">\n{input}\n</div>\n<div class=\"col-xs-4\">\n{image}\n</div>\n</div>"])->hint('点击验证码换一个。');
?>
<div class="form-group">
<?php
echo Html::submitButton('下一步 <i class="fa fa-angle-double-right"></i>', ['class' => 'btn btn-primary btn-fill']);
?>
</div>
<div class="form-group text-right">
<?php
echo Html::a('已有帐号?去登录<i class="fa fa-long-arrow-right"></i>', ['/site/login']);
?>
</div>
<?php
ActiveForm::end();
?>
<?php
示例12:
?>
<?php
echo $form->field($model, 'name')->textInput(['size' => 60]);
?>
<?php
echo $form->field($model, 'email')->textInput(['size' => 60]);
?>
<?php
echo $form->field($model, 'subject')->textInput(['size' => 60]);
?>
<?php
echo $form->field($model, 'text')->textarea(['rows' => 10, 'cols' => 80]);
?>
<?php
echo $form->field($model, 'captcha')->widget(Captcha::className(), ['model' => $model, 'attribute' => 'captcha', 'captchaAction' => '/app/captcha', 'template' => '<div class="cols">{image}</div> <div class="cols">{input}</div>']);
?>
<div class="wrap-box-row-submit">
<div class="wrap-box-value">
<?php
echo Html::submitButton('Відправити', ['class' => 'buttonOrange', 'name' => 'contact-button']);
?>
</div>
</div>
<?php
ActiveForm::end();
?>
<?php
示例13:
echo Html::activeInput("password", $model, "password", ['placeholder' => "請輸入密碼", "required" => true]);
?>
<span>輸入6-12位元英數密碼(不分大小寫)</span>
</div>
<div class="psw">
<?php
echo Html::activeInput("password", $model, "chkpassword", ['placeholder' => "請確認密碼", "required" => true]);
?>
<span>確認您的密碼</span>
</div>
<div class="reload">
<div class="image">
<?php
echo $form->field($model, 'captcha')->widget(\yii\captcha\Captcha::className(), ['template' => '<div class="pic">{image}</div>', "imageOptions" => ["style" => "width:60px;height:40px;"]])->label(false)->error(false);
?>
</div>
<div class="code">
<?php
echo Html::activeInput("text", $model, "captcha", ['placeholder' => "請輸入圖形驗證碼", "required" => true, "style" => "padding-left: 70px; padding-right: 0px;"]);
?>
</div>
<span>請輸入圖形驗證碼</span>
</div>
<p>如果繼續,即表示同意接受會員條款</p>
<button type="submit">註冊</button>
<?php
ActiveForm::end();
?>
</div>
示例14:
$form = ActiveForm::begin(['id' => 'contact-form']);
?>
<?php
echo $form->field($model, 'name')->label('Ваше имя');
?>
<?php
echo $form->field($model, 'email')->label('Email');
?>
<?php
echo $form->field($model, 'subject')->label('Тема');
?>
<?php
echo $form->field($model, 'body')->textArea(['rows' => 6])->label('Сообщение');
?>
<?php
echo $form->field($model, 'verifyCode')->hint('Введите код указанный на картинке')->widget(Captcha::className(), ['template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>']);
?>
<div class="form-group">
<?php
echo Html::submitButton('Отправить', ['class' => 'btn btn-primary', 'name' => 'contact-button']);
?>
</div>
<?php
ActiveForm::end();
?>
</div>
</div>
<?php
}
?>
示例15:
<!--账号-->
<?php
echo $form->field($model, 'username', ['inputOptions' => ['placeholder' => '请输入用户名', 'class' => 'input-text size-L'], 'template' => '<div class="row cl"><label class="form-label col-3"><i class="Hui-iconfont"></i></label><div class="formControls col-8">{input}{error}</div></div>'])->textInput();
?>
<!--密码-->
<?php
echo $form->field($model, 'password', ['inputOptions' => ['placeholder' => '请输入密码', 'class' => 'input-text size-L'], 'template' => '<div class="row cl"><label class="form-label col-3"><i class="Hui-iconfont"></i></label><div class="formControls col-8">{input}{error}</div></div>'])->passwordInput();
?>
<!--验证码-->
<?php
echo $form->field($model, 'verifyCode')->widget(Captcha::className(), ['template' => '<div class="row cl"><div class="formControls col-8 col-offset-3" id="verify-div">{image}<span id="imgcode">{input}</span></div></div>', 'imageOptions' => ['alt' => '验证码'], 'captchaAction' => 'login/captcha', 'options' => ['placeholder' => '请输入验证码', 'class' => 'input-text size-L', 'id' => 'verify']]);
?>
<!--登陆-->
<div class="row">
<div class="formControls col-8 col-offset-3">
<?php
echo Html::submitButton('登陆', ['class' => 'btn btn-success radius size-L']);
?>
<?php
echo Html::resetButton('重置', ['class' => 'btn btn-default radius size-L']);
?>
</div>
</div>