Share a detailed question about the DEDECMS verification code. I have a question. The SESSION Post was last edited by default7 from 2012-12-0115:54:51: submit the question again. After the form is successfully submitted, right-click the page and return to the previous page. the browser prompts "this page is unavailable". press F5 to refresh the page and the result is submitted successfully. As a result, if the refresh is not stopped, the submission is successful! Share a detailed question about the DEDECMS verification code. For more information about SESSION
This post was last edited by default7 at 15:54:51, January 1 ,.
Problem:Submit questions again. After the form is successfully submitted, right-click the page and return to the previous page. the browser prompts "this page is unavailable". press F5 to refresh the page and the result is submitted successfully. Cause
If you keep refreshing, you can submit the job continuously!Verification code.
Code:
If ($ dopost = 'ADD '){
$ Svali = GetCkVdValue ();
If (strtolower ($ vdcode )! = $ Svali | $ svali = '')
{
ResetVdValue ();
ShowMsg ('verification code error! ','-1 ');
Exit ();
}
}
Solution:At first, we thought it was ResetVdValue (); this function was a problem, and finally we found it was a problem of execution sequence. We put ResetVdValue (); it can be placed before determining whether the "submitted verification code is correct.
If ($ dopost = 'ADD '){
$ Svali = GetCkVdValue ();
ResetVdValue (); // Before location shift
If (strtolower ($ vdcode )! = $ Svali | $ svali = '')
{
ShowMsg ('verification code error! ','-1 ');
Exit ();
}
}
Later I looked at the functions for obtaining and destroying verification codes. I have a question:
1. files before modification:/include/common. func. php, functions GetCkVdValue () and ResetVdValue ()
/**
* Obtain the session value of the verification code.
*
* @ Return string
*/
Function GetCkVdValue ()
{
@ Session_id ($ _ COOKIE ['phpsessid']);
@ Session_start ();
Return isset ($ _ SESSION ['securimage _ code_value '])? $ _ SESSION ['securimage _ code_value ']: '';
}
/**
* Some PHP versions have bugs. you cannot read the session in the same scope and cancel it. Therefore, you need to execute this function after calling it.
*
* @ Return void
*/
Function ResetVdValue ()
{
@ Session_start ();
$ _ SESSION ['securimage _ code_value '] = '';
}
2. the verification code generation program before modification: write at the beginning of/include/vdimgck. php
$ SessSavePath = DEDEDATA. "/sessions /";
// Session save path
If (is_writeable ($ sessSavePath) & is_readable ($ sessSavePath) {session_save_path ($ sessSavePath );}
If (! Empty ($ pai_domain_cookie) session_set_cookie_params (0, '/', $ pai_domain_cookie );
Session_start ();
Modify the code as follows: File/include/common. func. php
/**
* Obtain the session value of the verification code.
*
* @ Return string
*/
Function GetCkVdValue ()
{
$ SessSavePath = DEDEDATA. "/sessions /";
If (is_writeable ($ sessSavePath) & is_readable ($ sessSavePath) {session_save_path ($ sessSavePath );}
If (! Empty ($ GLOBALS ['cfg _ domain_cookie ']) session_set_cookie_params (0,'/', $ GLOBALS ['cfg _ domain_cookie']);
@ Session_id ($ _ COOKIE ['phpsessid']);
@ Session_start ();
Return isset ($ _ SESSION ['securimage _ code_value '])? $ _ SESSION ['securimage _ code_value ']: '';
}
/**
* Some PHP versions have bugs. you cannot read the session in the same scope and cancel it. Therefore, you need to execute this function after calling it.
*
* @ Return void
*/
Function ResetVdValue ()
{
$ SessSavePath = DEDEDATA. "/sessions /";
If (is_writeable ($ sessSavePath) & is_readable ($ sessSavePath) {session_save_path ($ sessSavePath );}