diff --git a/cron.php b/cron.php index a4977274..6306aaf7 100644 --- a/cron.php +++ b/cron.php @@ -147,7 +147,6 @@ if ($config_whitelabel_enabled && !validateWhitelabelKey($config_whitelabel_key) appNotify("Settings", "White-labelling was disabled due to expired/invalid key", "settings_modules.php"); - mysqli_query($mysqli, "INSERT INTO notifications SET notification_type = 'Settings', notification = 'White-labelling was disabled due to expired/invalid key', notification_action = 'settings_modules.php'"); } diff --git a/cron_mail_queue.php b/cron_mail_queue.php index ba0e12f6..19e499e0 100644 --- a/cron_mail_queue.php +++ b/cron_mail_queue.php @@ -118,7 +118,8 @@ if (mysqli_num_rows($sql_queue) > 0) { // Update Message - Failure mysqli_query($mysqli, "UPDATE email_queue SET email_status = 2, email_failed_at = NOW(), email_attempts = 1 WHERE email_id = $email_id"); - mysqli_query($mysqli, "INSERT INTO notifications SET notification_type = 'Cron-Mail-Queue', notification = 'Failed to send email #$email_id to $email_recipient_logging'"); + appNotify("Cron-Mail-Queue", "Failed to send email #$email_id to $email_recipient_logging"); + mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Cron-Mail-Queue', log_action = 'Error', log_description = 'Failed to send email #$email_id to $email_recipient_logging regarding $email_subject_logging. $mail'"); } else { // Update Message - Success @@ -136,7 +137,9 @@ if (mysqli_num_rows($sql_queue) > 0) { $email_from_logging = sanitizeInput($row['email_from']); mysqli_query($mysqli, "UPDATE email_queue SET email_status = 2, email_attempts = 99 WHERE email_id = $email_id"); mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Cron-Mail-Queue', log_action = 'Error', log_description = 'Failed to send email #$email_id due to invalid sender address: $email_from_logging - check configuration in settings.'"); - mysqli_query($mysqli, "INSERT INTO notifications SET notification_type = 'Mail', notification = 'Failed to send email #$email_id due to invalid sender address'"); + + appNotify("Mail", "Failed to send email #$email_id due to invalid sender address"); + } } diff --git a/cron_ticket_email_parser.php b/cron_ticket_email_parser.php index e580dc5b..cb2ea734 100644 --- a/cron_ticket_email_parser.php +++ b/cron_ticket_email_parser.php @@ -100,15 +100,15 @@ function addTicket($contact_id, $contact_name, $contact_email, $client_id, $date $ticket_prefix_esc = mysqli_real_escape_string($mysqli, $config_ticket_prefix); $message_esc = mysqli_real_escape_string($mysqli, $message); $contact_email_esc = mysqli_real_escape_string($mysqli, $contact_email); - $client_id_esc = intval($client_id); + $client_id = intval($client_id); //Generate a unique URL key for clients to access $url_key = randomString(156); - mysqli_query($mysqli, "INSERT INTO tickets SET ticket_prefix = '$ticket_prefix_esc', ticket_number = $ticket_number, ticket_subject = '$subject', ticket_details = '$message_esc', ticket_priority = 'Low', ticket_status = 1, ticket_created_by = 0, ticket_contact_id = $contact_id, ticket_url_key = '$url_key', ticket_client_id = $client_id_esc"); + mysqli_query($mysqli, "INSERT INTO tickets SET ticket_prefix = '$ticket_prefix_esc', ticket_number = $ticket_number, ticket_subject = '$subject', ticket_details = '$message_esc', ticket_priority = 'Low', ticket_status = 1, ticket_created_by = 0, ticket_contact_id = $contact_id, ticket_url_key = '$url_key', ticket_client_id = $client_id"); $id = mysqli_insert_id($mysqli); - mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket', log_action = 'Create', log_description = 'Email parser: Client contact $contact_email_esc created ticket $ticket_prefix_esc$ticket_number ($subject) ($id)', log_client_id = $client_id_esc"); + mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket', log_action = 'Create', log_description = 'Email parser: Client contact $contact_email_esc created ticket $ticket_prefix_esc$ticket_number ($subject) ($id)', log_client_id = $client_id"); mkdirMissing('uploads/tickets/'); $att_dir = "uploads/tickets/" . $id . "/"; @@ -136,7 +136,7 @@ function addTicket($contact_id, $contact_name, $contact_email, $client_id, $date mysqli_query($mysqli, "INSERT INTO ticket_attachments SET ticket_attachment_name = '$ticket_attachment_name_esc', ticket_attachment_reference_name = '$ticket_attachment_reference_name_esc', ticket_attachment_ticket_id = $id"); } else { $ticket_attachment_name_esc = mysqli_real_escape_string($mysqli, $att_name); - mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket', log_action = 'Update', log_description = 'Email parser: Blocked attachment $ticket_attachment_name_esc from Client contact $contact_email_esc for ticket $ticket_prefix_esc$ticket_number', log_client_id = $client_id_esc"); + mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket', log_action = 'Update', log_description = 'Email parser: Blocked attachment $ticket_attachment_name_esc from Client contact $contact_email_esc for ticket $ticket_prefix_esc$ticket_number', log_client_id = $client_id"); } } @@ -220,10 +220,8 @@ function addReply($from_email, $date, $subject, $ticket_number, $message, $attac if ($ticket_status == 5) { $config_ticket_prefix_esc = mysqli_real_escape_string($mysqli, $config_ticket_prefix); $ticket_number_esc = mysqli_real_escape_string($mysqli, $ticket_number); - $ticket_id_esc = intval($ticket_id); - $client_id_esc = intval($client_id); - mysqli_query($mysqli, "INSERT INTO notifications SET notification_type = 'Ticket', notification = 'Email parser: $from_email attempted to re-open ticket $config_ticket_prefix_esc$ticket_number_esc (ID $ticket_id_esc) - check inbox manually to see email', notification_action = 'ticket.php?ticket_id=$ticket_id_esc', notification_client_id = $client_id_esc"); + appNotify("Ticket", "Email parser: $from_email attempted to re-open ticket $config_ticket_prefix_esc$ticket_number_esc (ID $ticket_id) - check inbox manually to see email", "ticket.php?ticket_id=$ticket_id", $client_id); $email_subject = "Action required: This ticket is already closed"; $email_body = "Hi there,

You've tried to reply to a ticket that is closed - we won't see your response.

Please raise a new ticket by sending a new e-mail to our support address below.

--
$company_name - Support
$config_ticket_from_email
$company_phone";