月度存档: 3 月 2020

yii2验证码

yii2自带验证码功能,配置一下就好了,这篇文章以登录页面为例,登录界面加入验证码可以防止暴力破解登录密码。
主要修改三个文件:LoginForm.php,siteController.php,login.php,
三个文件里面都引入下面类
use yii\captcha\CaptchaAction;
use yii\captcha\Captcha;

1.修改模型LoginForm类:

public $verifyCode;//给model增加一个属性 
public function rules()
    {
        return [
            // username and password are both required
            [['username', 'password','verifyCode'], 'required'],
            // rememberMe must be a boolean value
            ['rememberMe', 'boolean'],
            // password is validated by validatePassword()
            ['password', 'validatePassword'],
            ['verifyCode', 'captcha'],
        ];
    }
public function attributeLabels() 
    { 
         return [ 
                   // 'verifyCode' => 'Verification Code', 
                   'username' => '用户名',
                   'password'=>'密码',
                   'verifyCode' => '验证码',
            ]; 
    } 

2.修改SiteController.php

public function behaviors()
    {
        return [
            'access' => [
                'class' => AccessControl::className(),
                'only' => ['logout', 'signup','login'],
                'rules' => [
                    [
                        'actions' => ['signup','login','captcha'],
                        'allow' => true,
                        'roles' => ['?'],
                    ],
                    [
                        'actions' => ['logout'],
                        'allow' => true,
                        'roles' => ['@'],
                    ],
                ],
            ],
            'verbs' => [
                'class' => VerbFilter::className(),
                'actions' => [
                    'logout' => ['post'],
                ],
            ],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function actions()
    {
        return [
            'error' => [
                'class' => 'yii\web\ErrorAction',
            ],
            /*'captcha' => [
                'class' => 'yii\captcha\CaptchaAction',
                'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
            ],*/
            'captcha' => [
                                    'class' => 'yii\captcha\CaptchaAction',
                                    'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
                                    'backColor'=>0x000000,//背景颜色
                                    'maxLength' => 6, //最大显示个数
                                    'minLength' => 5,//最少显示个数
                                    'padding' => 5,//间距
                                    'height'=>40,//高度
                                    'width' => 130,  //宽度  
                                    'foreColor'=>0xffffff,     //字体颜色
                                    'offset'=>4,        //设置字符偏移量 有效果
                                    //'controller'=>'login',        //拥有这个动作的controller
                            ],
        ];
    }

3.修改view里的login.php

use yii\captcha\Captcha;
<?= $form->field($model, 'verifyCode')->widget(Captcha::className()) ?>

搞定!注册页面加入验证码可以防止恶意注册,原理一样,有兴趣的读者可以自行搞定!

yii2-view页面写js

view页面写js

<?php

$js = <<<JS
        url2 = "index.php?r=yourcontroller/index";
        org = new Object();
        org["userid"]=1;
        $("#sendbtn").click(function()
            {
                    alert("ajax");
                    $.ajax(
                                {
                                    url:url2,
                                    type:'post',
                                    //headers:{'X-CSRF-TOKEN':_rsf},
                                    data:org,
                                    success:function(data){alert("sucess2:"+data);},

                                    error: function (jqXHR, textStatus, errorThrown) {
                                            alert(jqXHR.status+textStatus);

                                    }
                                }
                            );


            });
JS;
    $this->registerJs($js);


?>

导引养生功十二法

简介

导引养生功是在汲取传统导引摄生原理基础上编创的系列健身方法。健身气功·导引养生功十二法精选了50余套导引养生功功法中的12式,是一套提高五脏六腑机能、有助于防治疾病的经络导引术。

功能

健身气功·导引养生功十二法不仅具有丰富的文化内涵,而且简练易学,适应于不同人群的健身锻炼。长期习练对心肺功能有积极影响,身体形态、柔韧性、平衡能力、协调能力等改善明显,自主神经系统功能的调节作用有所加强。

健身气功·导引养生功十二法动作要点口诀

预 备 势

夜阑人静万虑抛,意守丹田封七窍;
呼吸徐缓搭鹊桥,身轻如燕飘云霄。

1. 干元启运

旋臂摆掌清气扬,松腰敛臀气息长;
干元启运百会引,气沉丹田精神爽。

2. 双鱼悬阁

丁步切脉按太渊,阴消阳长双鱼悬;
上举下按分清浊,清溪淡流入丹田。

3. 老骥伏枥

手抠劳宫紧握拳,坐腕勾手两商连;
老骥伏枥志千里,老当益壮似当年。

4. 纪昌贯虱

开步推掌沉双肩,凝神贯注拉弓箭;
舒胸畅气降心火,滋阴补肾捻涌泉。

5. 躬身掸靴

转身挥臂任舒展,躬身掸靴去杂念;
伸腰竖脊通督脉,意守命门意绵绵。

6. 犀牛望月

坐腕撑掌展心胸,犀牛望月臂如弓;
五脏六腑十二脉,心有灵犀一点通。

7. 芙蓉出水

弹指分掌莲叶展,精神内守尘不染;
出水芙蓉品高洁,一身正气守清廉。

8. 金鸡报晓

百会上引阳气生,和胃健脾补后天;
金鸡独立三焦畅,升清降浊元气添。

9. 平沙落雁

雁落平沙体态松,宛如仙女回寝宫;
轻起缓落肠胃暖,养精蓄锐度寒冬。

10. 云端白鹤

跷脚收腹揉大包,舒肢展体病自消;
抖腕亮掌云端鹤,翱翔长空体轻飘。

11. 凤凰来仪

侧身展翅意欲飞,凤凰起舞显容仪;
千秋一见国祚昌,太平盛世正当时。

12. 气息归元

春风拂柳精气旺,呼吸吐纳调升降;
天阳地阴任我采,气息归元百脉畅。

收 势

两掌回抱迭关元,赤龙搅海左右旋;
吞津咽液汩有声,练精化气可延年。

ERROR: [Errno 2] No such file or directory: ‘add’ #3708解决方案

服务器版本 ubuntu 18.04 tls
今天执行 yarn add的时候报错
ERROR: [Errno 2] No such file or directory: 'add' #3708
解决方法如下:
sudo apt remove cmdtest
sudo apt remove yarn
1. Configure the repository

$ curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
$ echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
  1. Install Yarn
$ sudo apt-get update && sudo apt-get install --no-install-recommends yarn
  1. Verified Yarn Installtation.
    $ yarn -v
    1.20.1