PHPWind9.0 manually blocks the verification code to solve the problem of disabling the verification code in the background but still displaying it. phpwind9.0 Verification Code

Source: Internet
Author: User

PHPWind9.0 manually blocks the verification code to solve the problem of disabling the verification code in the background but still displaying it. phpwind9.0 Verification Code

Recently, a product was designed and requires POST login to PHPWind. However, PHPWind9 (pw9) has its own security policy. For details, you can go to the phpwind official forum. The existence of a security policy will result in a verification code displayed even if the webmaster closes the verification code policy during login (provided that the user retries too many times ).

If you want to POST a log on without a verification code, you have to handle this problem. However, the official website does not provide a solution and you can only handle it on your own.

First of all, we need to understand that phpwind is not like many simple php programs, but simply put the Page code in the corresponding file. Every access will call wekit. php, and then wekit calls plug-ins, applications, and services. After the analysis, we can solve the problem.

Login, the logon part, in the path. under \ src \ applications \ u \ controller, it is not difficult to recognize the file name, LoginController. php is used for login (this part is actually available in English names)
At this time, we will post a piece of code (I will note some content later)

Public function run () {$ this-> setOutput ($ this-> _ showVerify (), 'verify '); // display the verification code $ this-> setOutput ('user login', 'title '); // set the page title $ this-> setOutput ($ this-> _ filterUrl (false), 'url'); $ this-> setOutput (PwUserHelper: getLoginMessage (), 'loginway'); $ this-> setOutput ($ this-> getInput ('input'), 'input'); $ this-> setTemplate ('login'); Wind:: import ('srv: seo. bo. pwSeoBo '); $ seoBo = PwSeoBo: getInstance (); $ lang = Wind: getComponent ('i18n '); $ seoBo-> setCustomSeo ($ lang-> getMessage ('seo: u. login. run. title '), '',''); Wekit: setV ('seo', $ seoBo );}

Obviously, first we need to block the display part of the verification code.

Set

$ This-> setOutput ($ this-> _ showVerify (), 'verify '); // display the verification code

Modify

// $ This-> setOutput ($ this-> _ showVerify (), 'verify '); // display the verification code

At this point, we have hidden the Verification Code. However, if you log on to this step, you will find that the verification code is incorrect, so we need to modify it further to make it more like no verification code, yes! We need to return the verification code in any case.

The verification code is part of the Service Section (For details, refer to the official documentation. in \ src \ service \ verify \ srv, PwVerifyService can also be distinguished by file name. php is the main file that provides the verification code service.

At this time, I posted a piece of code (the opportunity part of the remarks)

Public function checkVerify ($ verifyType, $ code = '') {return true; if ($ code ='') return false; // if the verification code is empty, return verification code error $ types = $ this-> getVerifyType (); if (! Array_key_exists ($ verifyType, $ types) return false; $ verify = $ types [$ verifyType]; if (! Isset ($ verify ['components'] ['path']) return false; $ obj = Wekit :: load ($ verify ['components'] ['path']); if ($ obj-> checkVerify ($ code) === true) return true; return false ;}

Here I will give you a simple and rough one. I don't want to talk about other methods. I just want to study it myself.

Public function checkVerify ($ verifyType, $ code = '') {return true; // return true directly, return the correct Verification code // if ($ code ='') return false; $ types = $ this-> getVerifyType (); if (! Array_key_exists ($ verifyType, $ types) return false; $ verify = $ types [$ verifyType]; if (! Isset ($ verify ['components'] ['path']) return false; $ obj = Wekit :: load ($ verify ['components'] ['path']); if ($ obj-> checkVerify ($ code) === true) return true; return false ;}

So far, the problem has been solved.

The above is the PHPWind9.0 manual blocking Verification Code introduced by the small Editor to solve the problem that the verification code is disabled in the background but still displayed. I hope it will help you. If you have any questions, please leave a message, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.