Contributions > Plugins, tips, and tricks

User input validation for pre-chat survey

<< < (2/2)

yaisel:
to improve the validation of email common.php file and go to the regular expression to replace the line 563 for this.

original (validate client@mibew like correct) line 563

--- Code: ---return preg_match("/^[^@]+@[^\.]+(\.[^\.]+)*$/", $email);

--- End code ---
Replace for this (now validate client@mibew like wrong the correct email is client@mibew.org)

--- Code: ---return preg_match("/^[^0-9][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[@][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[.][a-zA-Z]{2,4}$/", $email);

--- End code ---

yaisel:
to function properly in the verification form entry to chat in version 1.6.11 should add the following code at line 87 of client.php

--- Code: ---                       /*newcode*/
                        $errors = array();
if( !$email ) {
$errors[] = no_field("presurvey.mail");
} else if( !$newname ) {
$errors[] = no_field("presurvey.name");
} else if( !$firstmessage ) {
$errors[] = no_field("presurvey.question");
} else {
if( !is_valid_email($email)) {
$errors[] = wrong_field("presurvey.mail");
}
}
                        /*end this code*/
                        if( count($errors) > 0 ){
$page = array();
setup_logo();
                                setup_survey($visitor['name'], $email, $groupid, $info, $referrer, can_show_captcha());
expand("styles", getchatstyle(), "survey.tpl");
exit;
}
                /*###########*/

--- End code ---

marcellocaetano:

--- Quote from: yaisel on May 21, 2014, 03:54:25 PM ---to function properly in the verification form entry to chat in version 1.6.11 should add the following code at line 87 of client.php

--- Code: ---                       /*newcode*/
                        $errors = array();
if( !$email ) {
$errors[] = no_field("presurvey.mail");
} else if( !$newname ) {
$errors[] = no_field("presurvey.name");
} else if( !$firstmessage ) {
$errors[] = no_field("presurvey.question");
} else {
if( !is_valid_email($email)) {
$errors[] = wrong_field("presurvey.mail");
}
}
                        /*end this code*/
                        if( count($errors) > 0 ){
$page = array();
setup_logo();
                                setup_survey($visitor['name'], $email, $groupid, $info, $referrer, can_show_captcha());
expand("styles", getchatstyle(), "survey.tpl");
exit;
}
                /*###########*/

--- End code ---

--- End quote ---

How can I apply this in Mibew 2?

Navigation

[0] Message Index

[*] Previous page

Go to full version