symfony sfCaptchaGDPlugin 插件的使用方法及注意事项 sf1.4

sfCaptchaGDPlugin 插件用于生成验证码,在最近的使用中发现还是有很多地方要值得注意特作此记录:

一、安装

       1、将插件下载下来解压去掉版本号放进plugins文件夹内

       2、在/config/ProjectConfiguration.class.php 文件里加入$this->enablePlugins('sfCaptchaGDPlugin');

       3、修改 apps/frontend/config/settings.yml

                      添加如下代码:

                              enabled_modules:        [default,  sfCaptchaGD]
                              standard_helpers:       [Partial, Cache, I18N]
                               i18n:                   true

        4、symfony cc

        7、修改plugins/sfDoctrineGuardPlugin/lib/form/doctrine/sfGuardFormSignin.class.php( 其他以此类推)

                       configure函数里添加如下代码:

                                $this->widgetSchema['captcha'] = new sfWidgetCaptchaGD();
                                $this->validatorSchema['captcha'] = new sfCaptchaGDValidator(array ('length' => 4));

        8、修改plugins/sfDoctrineGuardPlugin/modules/sfGuardAuth/_signin_form.php

                      在<table></table里添加

                            <?php echo $form['captcha']->render(array('id'=>'tdck', 'value'=>'请输入验证码'))?>(或其他输出表单字段的形式)

        9、修改apps/frontend/config/app.yml

                      添加如下代码:

                     all:
                         sf_captchagd:
                            image_width:                200 # image width in pixels
                            image_height:               30 # image height in pixels
                            chars:                      "123456789" # possible chars in captcha
                            length:                     4 # length of captcha
                            font_size:                  18 # font size
                            force_new_captcha:          false # if true - captcha regenerated EVERY request, even if user input true value before


                            # possible chars colors
                            font_color:                 ["252525", "8b8787", "550707", "3526E6", "88531E"]


                            # chars fonts
                            fonts:                      ["akbar/akbar.ttf", "brushcut/BRUSHCUT.TTF", "molten/molten.ttf", "planet_benson/Planetbe.ttf", "whoobub/WHOOBUB_.TTF"]
                            background_color:           DDDDDD # image background color
                            border_color:               000000 # image border color

 二、注意

                1、此时我们如果访问我们的登陆页面会发现验证码图片未出现则在plugins/sfCaptchaGDPlugin/modules/sfCaptchaGD/里新建config文件夹并在内新建security.yml

                      文件并添加如下代码:

                              default:
                                   is_secure: false            

                2、如验证码图片还未出现则查看php.ini文件里的extension=php_gd2.dll是否开启,如未开启则去掉其前面的分号(call to undefined function imagecreatetruecolor()                       in也是按此方法解决)



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值