PK

ADDRLIN : /home/anibklip/aelogifts.com/includes/
FLL :
Current File : //home/anibklip/aelogifts.com/includes/form_validation.php

<?php

function validateEmail($email) {
    return filter_var($email, FILTER_VALIDATE_EMAIL);
}

function validateMobile($mobile) {
    // Validate Indian mobile number format (10 digits, starting with 6-9)
    return preg_match("/^[6-9]\d{9}$/", $mobile);
}

function validatePassword($password) {
    // Password must be at least 8 characters long and contain:
    // - At least one uppercase letter
    // - At least one lowercase letter 
    // - At least one number
    // - At least one special character
    return preg_match("/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/", $password);
}

function checkSpamAttempts($conn, $ip_address) {
    // Check for too many registration attempts from same IP
    $time = time() - (15 * 60); // Last 15 minutes
    $query = "SELECT COUNT(*) as attempts FROM registration_attempts WHERE ip_address = '$ip_address' AND timestamp > $time";
    $result = mysqli_query($conn, $query);
    $row = mysqli_fetch_assoc($result);
    return $row['attempts'] >= 3; // Limit to 3 attempts per 15 minutes
}

function logRegistrationAttempt($conn, $ip_address) {
    $timestamp = time();
    mysqli_query($conn, "INSERT INTO registration_attempts (ip_address, timestamp) VALUES ('$ip_address', $timestamp)");
}

?>


PK 99