mirror of https://github.com/itflow-org/itflow
When adding a contact, flag duplicate or invalid e-mail addresses
This commit is contained in:
parent
49d3dbad9a
commit
16001f8d4e
|
|
@ -700,6 +700,34 @@ if (isset($_GET['client_duplicate_check'])) {
|
||||||
echo json_encode($response);
|
echo json_encode($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($_GET['contact_email_check'])) {
|
||||||
|
enforceUserPermission('module_client', 2);
|
||||||
|
|
||||||
|
$email = sanitizeInput($_GET['email']);
|
||||||
|
$domain = sanitizeInput(substr($_GET['email'], strpos($_GET['email'], '@') + 1));
|
||||||
|
|
||||||
|
$response['message'] = ""; // default
|
||||||
|
|
||||||
|
if (strlen($email) >= 3) {
|
||||||
|
|
||||||
|
// 1. Duplicate check
|
||||||
|
$sql_contacts = mysqli_query($mysqli, "SELECT contact_email FROM contacts WHERE contact_email = '$email' LIMIT 1");
|
||||||
|
if (mysqli_num_rows($sql_contacts) > 0) {
|
||||||
|
while ($row = mysqli_fetch_array($sql_contacts)) {
|
||||||
|
$response['message'] = "<i class='fas fa-fw fa-copy mr-2'></i> Potential duplicate: <i>" . nullable_htmlentities($row['contact_email']) . "</i> already exists.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. MX record check
|
||||||
|
if (!checkdnsrr($domain, 'MX')) {
|
||||||
|
$response['message'] = "<i class='fas fa-fw fa-exclamation-triangle mr-2'></i> E-mail domain invalid.";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode($response);
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($_GET['ai_reword'])) {
|
if (isset($_GET['ai_reword'])) {
|
||||||
|
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,10 @@ ob_start();
|
||||||
<div class="input-group-prepend">
|
<div class="input-group-prepend">
|
||||||
<span class="input-group-text"><i class="fa fa-fw fa-envelope"></i></span>
|
<span class="input-group-text"><i class="fa fa-fw fa-envelope"></i></span>
|
||||||
</div>
|
</div>
|
||||||
<input type="email" class="form-control" name="email" placeholder="Email Address" maxlength="200">
|
<input type="email" class="form-control" name="email" id="contact_email" placeholder="Email Address" maxlength="200" onfocusout="contact_email_check()">
|
||||||
|
</div>
|
||||||
|
<div class="mt-2">
|
||||||
|
<span class="text-info" id="contact_check_info"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -339,6 +342,23 @@ $(document).ready(function() {
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// Checks contact emails
|
||||||
|
function contact_email_check() {
|
||||||
|
var email = document.getElementById("contact_email").value;
|
||||||
|
//Send a GET request to ajax.php as ajax.php?contact_email_check=true&email=email
|
||||||
|
jQuery.get(
|
||||||
|
"ajax.php",
|
||||||
|
{contact_email_check: 'email', email: email},
|
||||||
|
function(data) {
|
||||||
|
//If we get a response from ajax.php, parse it as JSON
|
||||||
|
const contact_check_data = JSON.parse(data);
|
||||||
|
document.getElementById("contact_check_info").innerHTML = contact_check_data.message;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once '../../../includes/modal_footer.php';
|
require_once '../../../includes/modal_footer.php';
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue