1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-05-21 10:18:19 +03:00

Оптимизация каптчи и обновление fw

This commit is contained in:
Mzhelskiy Maxim 2014-01-25 20:20:02 +07:00
parent 3c892471fe
commit 2e61c2944f
8 changed files with 52 additions and 20 deletions

View file

@ -88,6 +88,8 @@ class ActionAjax extends Action {
$this->AddEventPreg('/^media$/i','/^save-data-file$/','/^$/','EventMediaSaveDataFile');
$this->AddEventPreg('/^property$/i','/^tags$/','/^autocompleter$/','/^$/','EventPropertyTagsAutocompleter');
$this->AddEventPreg('/^validate$/i','/^captcha$/','/^$/','EventValidateCaptcha');
}
@ -96,6 +98,24 @@ class ActionAjax extends Action {
**********************************************************************************
*/
/**
* Ajax валидация каптчи
*/
protected function EventValidateCaptcha() {
/**
* Устанавливаем формат Ajax ответа
*/
$this->Viewer_SetResponseAjax('json');
$sName=isset($_REQUEST['params']['name']) ? $_REQUEST['params']['name'] : '';
$sValue=isset($_REQUEST['fields'][0]['value']) ? $_REQUEST['fields'][0]['value'] : '';
$sField=isset($_REQUEST['fields'][0]['field']) ? $_REQUEST['fields'][0]['field'] : '';
if (!$this->Validate_Validate('captcha',$sValue,array('name'=>$sName))) {
$aErrors=$this->Validate_GetErrors();
$this->Viewer_AssignAjax('aErrors',array(htmlspecialchars($sField)=>array(reset($aErrors))));
}
}
protected function EventPropertyTagsAutocompleter() {
/**

View file

@ -29,11 +29,11 @@ class ModuleUser_EntityUser extends Entity {
*/
public function __construct($aParam = false) {
if (Config::Get('module.user.captcha_use_registration')) {
$this->aValidateRules[] = array('captcha', 'captcha', 'on' => array('registration'));
$this->aValidateRules[] = array('captcha', 'captcha', 'name'=>'user_signup', 'on' => array('registration'));
}
if (Config::Get('general.login.captcha')){
$this->aValidateRules[] = array('captcha', 'captcha', 'on' => array('signIn'));
$this->aValidateRules[] = array('captcha', 'captcha', 'name'=>'user_auth', 'on' => array('signIn'));
}
parent::__construct($aParam);

View file

@ -133,6 +133,13 @@ $config['module']['user']['userfield_max_identical'] = 2; // Максималь
$config['module']['user']['profile_photo_width'] = 250; // ширина квадрата фотографии в профиле, px
$config['module']['user']['name_max'] = 30; // максимальная длинна имени в профиле пользователя
$config['module']['user']['captcha_use_registration'] = true; // проверять поле капчи при регистрации пользователя
$config['module']['user']['complaint_captcha'] = true; // Использовать или нет каптчу при написании жалобы
$config['module']['user']['complaint_notify_by_mail'] = true; // Уведомлять администратора на емайл о поступлении новой жалобы
$config['module']['user']['complaint_text_required'] = true; // Обязательно указывать текст при жалобе
$config['module']['user']['complaint_text_max'] = 2000; // Максимальный размер текста жалобы
$config['module']['user']['complaint_type'] = array( // Список типов жалоб на пользователя
'spam','obscene','other'
);
// Модуль Comment
$config['module']['comment']['per_page'] = 20; // Число комментариев на одну страницу(это касается только полного списка комментариев прямого эфира)
@ -275,6 +282,7 @@ $config['db']['table']['user_field_value'] = '___db.table.prefix___user_field
$config['db']['table']['subscribe'] = '___db.table.prefix___subscribe';
$config['db']['table']['wall'] = '___db.table.prefix___wall';
$config['db']['table']['user_note'] = '___db.table.prefix___user_note';
$config['db']['table']['user_complaint'] = '___db.table.prefix___user_complaint';
$config['db']['table']['geo_country'] = '___db.table.prefix___geo_country';
$config['db']['table']['geo_region'] = '___db.table.prefix___geo_region';
$config['db']['table']['geo_city'] = '___db.table.prefix___geo_city';
@ -464,6 +472,7 @@ $config['head']['default']['js'] = array(
"___path.framework.frontend.web___/js/ui/autocomplete.js",
"___path.framework.frontend.web___/js/ui/notification.js",
"___path.framework.frontend.web___/js/ui/alert.js",
"___path.framework.frontend.web___/js/ui/captcha.js",
/* LiveStreet */
"___path.application.web___/frontend/common/js/favourite.js",

View file

@ -39,6 +39,11 @@ jQuery(document).ready(function($){
*/
$('[data-type=tab]').tab();
/**
* Captcha
*/
$('[data-type=captcha]').captcha();
/**
* Alerts

View file

@ -7,21 +7,17 @@
{extends file='forms/fields/form.field.base.tpl'}
{block name='field_holder' prepend}
{hookb run="registration_captcha" isPopup=$isModal}
{if ! $isModal}
<img src="{cfg name='path.framework.libs_vendor.web'}/kcaptcha/index.php?{$_sPhpSessionName}={$_sPhpSessionId}&n={rand()}" class="form-auth-captcha js-form-auth-captcha">
{else}
<span style="background-image: url({cfg name='path.framework.libs_vendor.web'}/kcaptcha/index.php?{$_sPhpSessionName}={$_sPhpSessionId}&n={rand()});" class="form-auth-captcha js-form-auth-captcha"></span>
{/if}
<input type="text"
id="{if $sFieldId}{$sFieldId}{else}{$sFieldName}{/if}"
name="{$sFieldName}"
value="{if $sFieldValue}{$sFieldValue}{elseif $_aRequest[$sFieldName]}{$_aRequest[$sFieldName]}{/if}"
class="{if $sFieldClasses}{$sFieldClasses}{else}width-150{/if} js-input-{$sFieldName}"
data-length="3"
data-required="true"
data-remote="{router page='registration'}ajax-validate-fields"
data-remote-method="POST"
{if $bFieldIsDisabled}disabled{/if} />
{/hookb}
{hookb run="captcha"}
<span style="background-image: url({cfg name='path.framework.libs_vendor.web'}/kcaptcha/index.php?{$_sPhpSessionName}={$_sPhpSessionId}&n={rand()}&name={$sCaptchaName});" data-type="captcha" data-captcha-name="{$sCaptchaName}" class="form-auth-captcha"></span>
<input type="text"
id="{if $sFieldId}{$sFieldId}{/if}"
name="{$sFieldName}"
value="{if $sFieldValue}{$sFieldValue}{elseif $_aRequest[$sFieldName]}{$_aRequest[$sFieldName]}{/if}"
class="{if $sFieldClasses}{$sFieldClasses}{else}width-150{/if} js-input-{$sFieldName}"
data-required="true"
data-remote="{router page='ajax/validate/captcha'}"
data-remote-method="POST"
data-remote-param-name="{$sCaptchaName}"
{if $bFieldIsDisabled}disabled{/if} />
{/hookb}
{/block}

View file

@ -26,6 +26,7 @@
{if $oConfig->GetValue('general.login.captcha')}
{include file='forms/fields/form.field.captcha.tpl'
sFieldName = 'captcha'
sCaptchaName = 'user_auth'
sFieldLabel = $aLang.registration_captcha}
{/if}

View file

@ -39,6 +39,7 @@
{* Каптча *}
{include file='forms/fields/form.field.captcha.tpl'
sFieldName = 'captcha'
sCaptchaName = 'user_signup'
sFieldLabel = $aLang.registration_captcha}
{hook run='form_registration_end' isPopup=$isModal}

@ -1 +1 @@
Subproject commit ce32f1e519329a0d0ca2a2cdfe3b4aa5fdb41f18
Subproject commit dead633d0ac6e1738504bb03cce09c1c29fd0101