Добрый день!
На сайте ранее была сделана капча и работала без проблем.
Нужно было продублировать ее на другие страницы. Делал по аналогии с рабочим кодом. В итоге на одной странице поставилась и работает без проблем, а на другой (которая оформлена во всплывающем окне) не отображается картирка.
На обычных страницах пишет такой путь к картинке - src="/a/socialReview/default/captcha?v=54e19be1434ac"
На всплывающей - src="/site/default/captcha/v/54e19be1434ac" - это битая картинка
Проверял кодировку модели, контроллера, файла отображения, индексного файла и файла конфига. Все в utf8 без bom
Подскажите, в чем может быть дело?
Не отображается капча
Re: Не отображается капча
Правило URL какое-то для контроллера site срабатывает.
Re: Не отображается капча
есть запись
'/call_me'=>'site/callMe',
стоит почти в самом начале (call_me - всплывающая страница, на которой не отображается капча)
еще есть
'/cron/<key:\d+>' => 'site/cron',
'/contacts' => 'site/contacts',
'/errors' => 'site/manualError',
'/errors/<id:\d+>' => 'site/manualError',
больше записей с site нет
'/call_me'=>'site/callMe',
стоит почти в самом начале (call_me - всплывающая страница, на которой не отображается капча)
еще есть
'/cron/<key:\d+>' => 'site/cron',
'/contacts' => 'site/contacts',
'/errors' => 'site/manualError',
'/errors/<id:\d+>' => 'site/manualError',
больше записей с site нет
Re: Не отображается капча
так могут и записи без site влиять. Давай полный код urlManager, метода actions контроллера и код отображения капчи. Только без "я убрал то что не надо". А то как правило убирают то что надо
Re: Не отображается капча
метода actions контроллера
Код: Выделить всё
public function actions()
{
return array(
'captcha'=>array(
'class'=>'CCaptchaAction',
'maxLength'=> 4,
'minLength'=> 4,
),
);
}
Код: Выделить всё
<?php
Yii::import('shopShipping.models.*');
class SiteController extends Controller
{
public $breadcrumbs=array();
public function actionIndex()
{
$this->render('index');
}
/**
* Обратная связь
*/
public function actionContacts()
{
$model = new ContactForm;
if (isset($_POST['ContactForm'])){
$model->attributes = $_POST['ContactForm'];
if ($model->send()){
Yii::app()->user->setFlash('contact', 'Thank you for your request!');
$this->refresh();
}
}
if(Yii::app()->request->isAjaxRequest)
$this->renderPartial('_feedback', compact('model'));
else
$this->render('contacts', array('model' => $model, 'content' => $this->page['content']));
}
/**
* This is the action to handle external exceptions.
*/
public function actionError($error=array('code'=>404, 'message'=>'Данной страницы не существует.'))
{
$this->layout = false;
$this->pageTitle = 'Ошибка '.$error['code'];
$this->breadcrumbs = array('Ошибка ' . $error['code']);
if(Yii::app()->errorHandler->error)
$error = Yii::app()->errorHandler->error;
$this->render('error', $error);
}
/**
* This is the action to handle external exceptions.
*/
public function actionManualError($id = 404, $text = false)
{
throw new CHttpException($id, $text);
}
public function actionCallMe()
{
if (!Yii::app()->user->isGuest) {
$user = User::model()->findByPk(Yii::app()->user->id);
$name = $user->name;
$phone = $user->phone;
} else {
$name = '';
$phone = '';
}
$model = new CallMe();
if (isset($_POST['CallMe'])){
$model->attributes = $_POST['CallMe'];
if ($model->send() && $model->save()){
Yii::app()->user->setFlash('call', '<div class="thanks_block">Thank you for request. Our manager will contact with you at the time you prefer</div>');
$this->refresh();
}
}
if(Yii::app()->request->isAjaxRequest){
$this->renderPartial('call_me', array('model'=>$model, 'name'=>$name, 'phone'=>$phone));
} else {
$this->render('call_me', array('model'=>$model, 'name'=>$name, 'phone'=>$phone));
}
}
public function actionCron($key)
{
if($key != 789123)
throw new CHttpException(404);
//import currencies from cbr site
Yii::import('shopCurrency.models.ShopCurrencyItem');
ShopCurrencyItem::parseCbr();
//change orders statuses by periods
Yii::import('shopOrder.models.ShopOrder');
ShopOrder::changeAllStatusesByPeriod();
//update is_new fields for catalog items
Yii::import('productCatalog.models.ProductCatalogItem');
ProductCatalogItem::updateItemsNew();
}
public function actions()
{
return array(
'captcha'=>array(
'class'=>'CCaptchaAction',
'maxLength'=> 4,
'minLength'=> 4,
),
);
}
}
код отображения капчи
Код: Выделить всё
<?php if(CCaptcha::checkRequirements() && Yii::app()->user->isGuest):?>
<?php echo CHtml::activeLabelEx($model, 'verifyCode');?>
<?php echo CHtml::activeTextField($model,
'verifyCode',array("style"=>"width:100px;"))?>
<?php $this->widget('CCaptcha', array('clickableImage'=>true, 'showRefreshButton'=>false,
'imageOptions'=>array('title'=>'Get a new image', 'style'=>'cursor:pointer'))); ?>
<?php endif?>
полный код urlManager
Код: Выделить всё
<?php
// Конфигурация URL менеджера
return array(
'urlFormat' => 'path',
'showScriptName' => false,
'useStrictParsing' => true,
'rules' => array(
/* ADMIN */
'/admin' => 'textPage/category/index',
'/order_add_item'=>'/shopOrder/item/addItem',
'/delete/detail_photo'=>'/productCatalog/item/deleteDetailPhoto',
'/actNews/index'=>'actNews/item/index',
'/actEvent/index'=>'actEvent/item/index',
'/change_delivery_admin'=>'shopOrder/item/changeDelivery',
'/call_me'=>'site/callMe',
'/save_countries_and_shippings'=>'/shopShipping/item/saveCountriesAndShippings',
'/admin/<_m>/<_a>' => '<_m>/admin/<_a>',
/* SITE */
'/cron/<key:\d+>' => 'site/cron',
'/contacts' => 'site/contacts',
'/errors' => 'site/manualError',
'/errors/<id:\d+>' => 'site/manualError',
/* USERS */
'/login' => 'users/default/login',
'/logout' => 'users/default/logout',
'/profile' => 'users/profile/view',
'/profile/<_a>/*' => 'users/profile/<_a>',
'/users/<_a>' => 'users/default/<_a>',
/* CATALOG */
'/catalog'=>'/productCatalog/default/index',
'/catalog/view/<url:\w+>'=>'/productCatalog/default/view',
'/catalog/viewTab/*'=>'/productCatalog/default/viewTab',
'/catalog/measuresPrice/*'=>'/productCatalog/default/measuresPrice',
'/catalog/<category_url:\S+>'=>'/productCatalog/default/index',
/* SHOP ORDER */
'/leotards/Designleotards' => 'shopOrder/default/design_leotard',
'/wishlist' => 'shopOrder/default/pending',
'/change_delivery'=>'shopOrder/default/changeDelivery',
'/cart' => 'shopOrder/default/cart',
'/cart/design_leotard' => 'site/manualError',
'/cart/<_a>/*' => 'shopOrder/default/<_a>',
/* SEARCH */
//'/search'=>'search/default/index',
'/search'=>'metaSearch/default/index',
/* ACT NEWS */
'/news' => 'actNews/default/index',
'/news/<id:\d+>' => 'actNews/default/view',
'/news/<_c>/<_a>/*' => 'actNews/<_c>/<_a>',
/* ACT events */
'/events' => 'actEvent/default/index',
'/events/<id:\d+>' => 'actEvent/default/view',
'/events/<_c>/<_a>/*' => 'actEvent/<_c>/<_a>',
/* text articles */
'/tips' => 'textArticle/default/index',
'/tips/category/<cid:\d+>' => 'textArticle/default/category',
'/tips/<id:\d+>' => 'textArticle/default/view',
//'/tips/<url:\w+>' => 'textArticle/default/view',
'/tips/<url:[a-z0-9-\_]+>' => 'textArticle/default/view',
/* text advices */
'/advices' => 'textAdvice/default/index',
'/advices/category/<cid:\d+>' => 'textAdvice/default/category',
'/advices/<id:\d+>' => 'textAdvice/default/view',
/* text quotation */
'/quotation' => 'textQuotation/default/index',
/* text blog */
'/blog' => 'textBlog/default/index',
'/blog/<id:\d+>' => 'textBlog/default/view',
/* text translation */
'/translate/<_a>/*' => 'textTranslator/default/<_a>',
/* SOCIAL Review - testimonials */
'/testimonials' => 'socialReview/default/index',
/* shop Currency */
'/currency/<_a>/*' => 'shopCurrency/default/<_a>',
/* SOCIAL FAQ */
'/help/askyourquestion' => 'socialFaq/default/index',
/* SOCIAL FORUM */
'/forum1' => 'socialForum/defaultCategory/index',
'/forum1/<pid:\d+>' => 'socialForum/defaultCategory/index',
'/forum1/<pid:\d+>/<_a>' => 'socialForum/defaultCategory/<_a>',
'/forum1/post/<id:\d+>/<_a>' => 'socialForum/defaultItem/<_a>',
/* MEDIA gallery */
'/media' => 'mediaGallery/default/index',
'/media/tags' => 'mediaGallery/default/tags',
'/media/allTags' => 'mediaGallery/default/allTags',
'/media/<url:\w+>' => 'mediaGallery/default/view',
/* SOCIAL VOTE */
'/voting_result'=>'socialVote/default/votingResult',
/* ALL */
'/a/<_m>/<_c>/<_a>'=>'<_m>/<_c>/<_a>',
/* PAGES */
//'/<route:\S+>' => 'textPage/defaultPage/view',
'/<route:\S+>' => 'productCatalog/default/index',
'/' => 'textPage/defaultPage/view',
),
);
Re: Не отображается капча
Ну и откуда взялся default в URL /site/default/captcha/v/54e19be1434ac ?
Re: Не отображается капча
А где можно исключить default из урл?
Re: Не отображается капча
Не знаю. Попробуй открыть URL /site/default/captcha/v/* который выдаст тебе страница только без default. Если работает, попробуй закомментировать все правила. Посмотри поменяется ли урл. Если это тоже сработает, раскомментирывай по одному, найдешь какое не работает.tai писал(а):А где можно исключить default из урл?