function validateFormInputs()
{
    if (validateName()) {
        if (validateEmail()) {
            if (validatePhone()) {
                if (validateMessage()) {
                    return true;
                }
            }
        }
    }
    return false;
}
function insertPhoneInput()
{
    if (isset($_POST['odeslat'])) {
        if (validatePhone()) {
            insertInputWithValue("tel", "telefon", "telefon", "Telefonní číslo (nepovinné)", 20, trim($_POST['telefon']));
            insertOKSpan();
        } else {
            insertInputWithValue("tel", "telefon", "telefon", "Telefonní číslo (nepovinné)", 20, trim($_POST['telefon']));
            insertWrongSpan();
        }
    } else {
        insertInput("tel", "telefon", "telefon", "Telefonní číslo (nepovinné)", 20);
        // 		insertOKSpan();
    }
}
function validate()
{
    if (!validateAlpha($_POST['fname'])) {
        echo '<script type="text/javascript">alert("Not a valid firstname!")</script>';
        return false;
    }
    if (!validateAlpha($_POST['lname'])) {
        echo '<script type="text/javascript">alert("Not a valid lastname!")</script>';
        return false;
    }
    if (!validateAlphaNumeric($_POST['address'])) {
        echo '<script type="text/javascript">alert("Not a valid address!")</script>';
        return false;
    }
    if (!validatePhone($_POST['phone'])) {
        echo '<script type="text/javascript">alert("Not a valid phone number, use ###-###-####!")</script>';
        return false;
    }
    if (!validateEmail($_POST['email'])) {
        echo '<script type="text/javascript">alert("Not a valid email!")</script>';
        return false;
    }
    return true;
}
Exemple #4
0
}
?>
 />
		            				<span class="formcheck" id="spanZip" ></span><br />
	
	            <label>Phone:</label>
	            	<input type="text" name="PHONE" size="17" id="phone" class="validates" placeholder="###-###-####" 
	            		onkeyup="phoneValid()" 
	            			value="<?php 
if (isset($_POST['PHONE'])) {
    echo $phone;
}
?>
" 
	            				<?php 
if (!validatePhone($phone)) {
    echo $styleInvalid;
}
?>
 />
									<span class="formcheck" id="spanPhoneNum"> </span><br />
	
	            <label>Birthday:</label>
	            	<input type="date" name="DOB" size="30" placeholder="mm/dm/yyyy" 
	            		value="<?php 
if (isset($_POST['DOB'])) {
    echo $dob;
}
?>
" id="dob" 
	            			<?php 
function ProcessItem($formid, $fvalue, $params, $output_type)
{
    global $TOOL_SHORT;
    $PASS_VALUE = "ok";
    $FAIL_VALUE = "error";
    global $VALIDATE_TEXT;
    $failed = false;
    $VALIDATE_TEXT = "";
    // clear before doing the validation
    if (!validateRequired($fvalue) && !array_key_exists("required", $params)) {
        // blank and not required
        return "";
    }
    // do the validation
    foreach ($params as $value) {
        if ($failed) {
            break;
        }
        $type = $value;
        if (strpos($value, ";") !== false) {
            // get the special rule type
            $type = substr($value, 0, strpos($value, ";"));
        }
        writeLog($TOOL_SHORT, "ajax", "validate:" . $type . ":" . $fvalue);
        if ($type == "required" || $type == "notblank") {
            if (!validateRequired($fvalue)) {
                $failed = true;
            }
        } else {
            if ($type == "email") {
                if (!validateEmail($fvalue)) {
                    $failed = true;
                }
            } else {
                if ($type == "phone") {
                    if (!validatePhone($fvalue)) {
                        $failed = true;
                    }
                } else {
                    if ($type == "date") {
                        if (!validateDate($fvalue)) {
                            $failed = true;
                        }
                    } else {
                        if ($type == "time") {
                            if (!validateTime($fvalue)) {
                                $failed = true;
                            }
                        } else {
                            if ($type == "zip" || $type == "zipcode") {
                                if (!validateZip($fvalue)) {
                                    $failed = true;
                                }
                            } else {
                                if ($type == "nospaces" || $type == "password") {
                                    if (!validateNoSpaces($fvalue)) {
                                        $failed = true;
                                    }
                                } else {
                                    if ($type == "alpha") {
                                        if (!validateAlpha($fvalue)) {
                                            $failed = true;
                                        }
                                    } else {
                                        if ($type == "alphanum") {
                                            if (!validateAlphaNumeric($fvalue)) {
                                                $failed = true;
                                            }
                                        } else {
                                            if ($type == "number") {
                                                if (!validateNumeric($fvalue)) {
                                                    $failed = true;
                                                }
                                            } else {
                                                if ($type == "name") {
                                                    if (!validateAlphaName($fvalue)) {
                                                        $failed = true;
                                                    }
                                                } else {
                                                    if ($type == "namespaces") {
                                                        if (!validateAlphaNameSpaces($fvalue)) {
                                                            $failed = true;
                                                        }
                                                    } else {
                                                        if ($type == "uniquesql") {
                                                            // should be uniquesql;(columnname);(tablename);(tableid);(userid)
                                                            $parts = split(';', $value);
                                                            if (!validateUniqueSQL($parts[1], $parts[2], $fvalue, $parts[3], $parts[4])) {
                                                                $VALIDATE_TEXT = $formid . " already used";
                                                                $failed = true;
                                                            }
                                                        } else {
                                                            if ($type == "uniqueinstp") {
                                                                // should be uniqueinstp;(value);($field);(idval)
                                                                $parts = split(';', $value);
                                                                if (!validateUniqueInst($fvalue, $parts[1], $parts[2])) {
                                                                    $VALIDATE_TEXT = $formid . " already used";
                                                                    $failed = true;
                                                                }
                                                            } else {
                                                                if ($type == "uniqueuserp") {
                                                                    // should be uniqueuserp;(value);($field);(idval)
                                                                    $parts = split(';', $value);
                                                                    if (!validateUniqueUser($fvalue, $parts[1], $parts[2])) {
                                                                        $VALIDATE_TEXT = $formid . " already used";
                                                                        $failed = true;
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    if ($output_type == "ajax") {
        $status = $PASS_VALUE;
        if ($failed) {
            $status = $FAIL_VALUE;
        }
        $ajaxReturn = "{$status}|{$formid}|{$VALIDATE_TEXT}";
        echo $ajaxReturn;
        writeLog($TOOL_SHORT, "ajax", "return={$ajaxReturn}");
    } else {
        if ($output_type == "print") {
            if ($failed) {
                print $VALIDATE_TEXT . "<br>";
            }
        } else {
            if ($output_type == "array") {
                if ($failed) {
                    return $VALIDATE_TEXT;
                }
            }
        }
    }
    // defaults to "return"
    if ($failed) {
        return $VALIDATE_TEXT . "<br>";
    }
    return "";
}
Exemple #6
0
function validateNewBuyerProfile($form)
{
    if (checkEmpty($form['firstname'])) {
        $msg = str_replace('field', _LBL_FIRST_NAME, _ALRT_REQUIRED_FIELD);
        return $msg;
    }
    if (!checkEmpty($form['firstname']) && !checkLength($form['firstname'], 255)) {
        $msg = str_replace('%field%', _LBL_FIRST_NAME, _ALRT_CHECK_LENGTH);
        return $msg;
    }
    if (checkEmpty($form['lastname'])) {
        $msg = str_replace('field', _LBL_LAST_NAME, _ALRT_REQUIRED_FIELD);
        return $msg;
    }
    if (!checkEmpty($form['lastname']) && !checkLength($form['lastname'], 255)) {
        $msg = str_replace('%field%', _LBL_LAST_NAME, _ALRT_CHECK_LENGTH);
        return $msg;
    }
    /*if(checkEmpty($form['companyname']))
    	{
    		$msg = str_replace('field',_LBL_COMPANY_NAME,_ALRT_REQUIRED_FIELD);
    		return $msg;
    	}*/
    if (!checkEmpty($form['companyname']) && !checkLength($form['companyname'], 100)) {
        $msg = str_replace('%field%', _LBL_COMPANY_NAME, _ALRT_CHECK_LENGTH);
        return $msg;
    }
    if (checkEmpty($form['type_entertainment'])) {
        $msg = str_replace('field', _LBL_TYPE_OF_ENT, _ALRT_REQUIRED_FIELD);
        return $msg;
    }
    /*if(checkEmpty($form['contactname']))
    	{
    		$msg = str_replace('field',_LBL_CON_PERSON,_ALRT_REQUIRED_FIELD);
    		return $msg;
    	}*/
    if (!checkEmpty($form['phone']) && !checkLength($form['phone'], 20)) {
        $msg = str_replace('%field%', _LBL_PH_NO, _ALRT_CHECK_LENGTH);
        return $msg;
    }
    if (!checkEmpty($form['phone']) && !validatePhone($form['phone'])) {
        $msg = str_replace('%field%', _LBL_PH_NO, _ALRT_CHECK_PHONE);
        return $msg;
    }
    if (!checkEmpty($form['jobtitle']) && !checkLength($form['jobtitle'], 100)) {
        $msg = str_replace('%field%', _LBL_JOB_TITLE, _ALRT_CHECK_LENGTH);
        return $msg;
    }
    /*if(checkEmpty($form['yearfound']))
    	{
    		$msg = str_replace('field',_LBL_YR_FOUNDED,_ALRT_REQUIRED_FIELD);
    		return $msg;
    	}*/
    if (!checkEmpty($form['yearfound']) && !checkLength($form['yearfound'], 4)) {
        $msg = str_replace('%field%', 'Year Started', _ALRT_CHECK_LENGTH);
        return $msg;
    }
    if (!checkEmpty($form['yearfound']) && !checkValidYear($form['yearfound'])) {
        $msg = str_replace('field', 'Year Started', _ALRT_VALID_FIELD);
        return $msg;
    }
    if (!checkEmpty($form['fax']) && !checkLength($form['fax'], 20)) {
        $msg = str_replace('%field%', _LBL_FAX_NO, _ALRT_CHECK_LENGTH);
        return $msg;
    }
    if (!checkEmpty($form['fax']) && !validateFax($form['fax'])) {
        $msg = str_replace('%field%', _LBL_FAX_NO, _ALRT_CHECK_VALID);
        return $msg;
    }
    if (!checkEmpty($form['web']) && !checkLength($form['web'], 200)) {
        $msg = str_replace('%field%', _LBL_COMP_URL, _ALRT_CHECK_LENGTH);
        return $msg;
    }
    if (!checkEmpty($form['web']) && !validateURL($form['web'])) {
        $msg = str_replace('%field%', _LBL_COMP_URL, _ALRT_CHECK_URL);
        $show_tab_type = 'COMPANY_INFO';
        return $msg;
    }
    if (checkEmpty($form['city'])) {
        $msg = str_replace('field', _CITY, _ALRT_REQUIRED_FIELD);
        return $msg;
    }
    if (!checkEmpty($form['city']) && !checkLength($form['city'], 80)) {
        $msg = str_replace('%field%', _CITY, _ALRT_CHECK_LENGTH);
        return $msg;
    }
    if (checkEmpty($form['state'])) {
        $msg = str_replace('field', _LBL_STATE, _ALRT_REQUIRED_FIELD);
        $show_tab_type = 'CONTACT_INFO';
        return $msg;
    }
    if (!checkEmpty($form['state']) && !checkLength($form['state'], 80)) {
        $msg = str_replace('%field%', _LBL_STATE, _ALRT_CHECK_LENGTH);
        return $msg;
    }
    if (checkEmpty($form['zip'])) {
        $msg = str_replace('field', _LBL_ZIP_POSTALCODE, _ALRT_REQUIRED_FIELD);
        return $msg;
    }
    if (!checkEmpty($form['zip']) && !checkLength($form['zip'], 15)) {
        $msg = str_replace('%field%', _LBL_ZIP_POSTALCODE, _ALRT_CHECK_LENGTH);
        return $msg;
    }
    if (!checkEmpty($form['zip']) && !validateZip($form['zip'])) {
        $msg = str_replace('%field%', _LBL_ZIP_POSTALCODE, _ALRT_CHECK_ZIP);
        return $msg;
    }
    return true;
}
Exemple #7
0
    $templet = !empty($templet) ? $templet : MEMBERTEMPLET . 'reg.htm';
    $pv->Fields['stoken'] = $token;
    $pv->SetTemplet(MEMBERTEMPLET . 'reg.htm');
    $pv->Display();
    exit;
}
//用户注册
if ($dopost == 'doreg') {
    @session_start();
    $pwd = md5($password);
    $jointime = time();
    $joinip = GetIP();
    $jifen = empty($cfg_reg_jifen) ? 0 : $cfg_reg_jifen;
    //网上注册赠送积分
    $nickname = substr($mobile, 0, 5) . '***';
    $validateResult = validatePhone();
    $_SESSION['mobilecode_' . $mobile] = '';
    if ($validateResult !== true) {
        Helper_Archive::showMsg('注册失败!' . $validateResult, 'reg.php?dopost=reg', 0);
        return;
    }
    $sql = "insert into #@__member(mobile,pwd,jointime,joinip,jifen,nickname) values('{$mobile}','{$pwd}','{$jointime}','{$joinip}','{$jifen}','{$nickname}')";
    if (defined('UC_API') && @(include_once SLINEROOT . '/uc_client/client.php')) {
        $email = time() . "@163.com";
        $uid = uc_user_register($mobile, $password, $email);
        if ($uid <= 0) {
        } else {
            $ucsynlogin = uc_user_synlogin($uid);
        }
    }
    if ($dsql->ExecuteNoneQuery($sql)) {
Exemple #8
0
    $err[] = 'The email field is too short or empty';
}
if (!validateMaxLength($_POST['email'], 254)) {
    $err[] = 'The email field must be less than 254 characters';
}
if (validateMinLength($_POST['email'], 2) && validateMaxLength($_POST['email'], 254) && !validateEmail($_POST['email'])) {
    $err[] = 'That email address appears to be invalid';
}
//11 = Minimum Number, 23 = Maximum Number
if (!validateMinLength($_POST['phone'], 11)) {
    $err[] = 'The phone number field must be at least 11 numbers';
}
if (!validateMaxLength($_POST['phone'], 23)) {
    $err[] = 'The phone number field must be less than 22 numbers';
}
if (validateMaxLength($_POST['phone'], 23) && validateMinLength($_POST['phone'], 11) && !validatePhone($_POST['phone'])) {
    $err[] = 'The phone number is not valid. Numbers and Hyphens (-) only';
}
//1 = Minimum Number
if (!validateMinLength($_POST['message'], 1)) {
    $err[] = 'The message field is too short or empty';
}
//5 = Minimum Number, 5 = Maximum Number
if (!validateMinLength($_POST['verify'], 5)) {
    $err[] = 'The security captcha field is too short or empty';
}
if (!validateMaxLength($_POST['verify'], 5)) {
    $err[] = 'The security captcha field is too long';
}
if (validateMinLength($_POST['verify'], 5) && validateMaxLength($_POST['verify'], 5) && md5($_POST['verify']) != $_SESSION['verify']) {
    $err[] = 'The captcha field appears to be incorrect';
Exemple #9
0
 $_SESSION['s_two_fa'] = "";
 $_SESSION['s_two_fa'] = "{$two_fa}";
 // Validate SMS gateway
 // SMS gateways must have a valid MX record.
 // The user's SMS gateway is stored encrypted in the DB.
 if ($sms_gateway != "no_mobile") {
     if (!getmxrr($sms_gateway, $mxhosts)) {
         die("Invalid SMS Gateway.");
     }
 }
 // Ensure 10 digit numbers have the "1" prepended to it.
 if (strlen($phone) == "10") {
     $phone = "1" . $phone;
 }
 // Phone validation.  The phone number is stored encrypted in the DB.
 $new_phone = validatePhone($phone, "<b>Phone number should be less than 15 digits.</b>");
 // Needed to send code via SMS.  This is appended to the phone number, if the user is using an sms gateway.
 if ($sms_gateway != "no_mobile") {
     $_SESSION['s_reg_gateway'] = "{$new_phone}" . "@" . "{$sms_gateway}";
 }
 // These session variables will be passed to the Verify Code script below and passed to the
 // gen_cert() function, if the proper code is entered.
 $_SESSION['s_reg_password'] = $password;
 $_SESSION['s_phone'] = "";
 $_SESSION['s_phone'] = $new_phone;
 $_SESSION['s_sms_gateway'] = $sms_gateway;
 // Send the respective verification code to complete the registration.
 if ($two_fa == "s") {
     // Send sms auth code.
     sms_random_code_auth();
 } else {