prod to stage
# Conflicts: # includes/filter_header.php # scripts/cron.php # scripts/cron_certificate_refresher.php # scripts/cron_domain_refresher.php # scripts/cron_mail_queue.php # scripts/cron_ticket_email_parser.php
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
chdir(dirname(__FILE__));
|
||||
|
||||
// Ensure we're running from command line
|
||||
if (php_sapi_name() !== 'cli') {
|
||||
if (php_sapi_name() !== 'cli' && $_GET['key'] !== 'GxKo679Jm5xjOtQ81Zo3ywWMVcNB5wgP') {
|
||||
die("This script must be run from the command line.\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
chdir(dirname(__FILE__));
|
||||
|
||||
// Ensure we're running from command line
|
||||
if (php_sapi_name() !== 'cli') {
|
||||
if (php_sapi_name() !== 'cli' && $_GET['key'] !== 'GxKo679Jm5xjOtQ81Zo3ywWMVcNB5wgP') {
|
||||
die("This script must be run from the command line.\n");
|
||||
}
|
||||
|
||||
@@ -406,10 +406,15 @@ if (mysqli_num_rows($sql_recurring_tickets) > 0) {
|
||||
addToMailQueue($data);
|
||||
|
||||
// Set the next run date
|
||||
if ($frequency == "weekly") {
|
||||
// Note: We seemingly have to initialize a new datetime for each loop to avoid stacking the dates
|
||||
if ($frequency == "three days") {
|
||||
$now = new DateTime();
|
||||
$next_run = date_add($now, date_interval_create_from_date_string('3 days'));
|
||||
} elseif ($frequency == "weekly") {
|
||||
$now = new DateTime();
|
||||
$next_run = date_add($now, date_interval_create_from_date_string('1 week'));
|
||||
} elseif ($frequency == "biweekly") {
|
||||
$now = new DateTime();
|
||||
$next_run = date_add($now, date_interval_create_from_date_string('2 weeks'));
|
||||
} elseif ($frequency == "monthly") {
|
||||
$now = new DateTime();
|
||||
$next_run = date_add($now, date_interval_create_from_date_string('1 month'));
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
chdir(dirname(__FILE__));
|
||||
|
||||
// Ensure we're running from command line
|
||||
if (php_sapi_name() !== 'cli') {
|
||||
if (php_sapi_name() !== 'cli' && $_GET['key'] !== 'GxKo679Jm5xjOtQ81Zo3ywWMVcNB5wgP') {
|
||||
die("This script must be run from the command line.\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
chdir(dirname(__FILE__));
|
||||
|
||||
// Ensure we're running from command line
|
||||
if (php_sapi_name() !== 'cli') {
|
||||
if (php_sapi_name() !== 'cli' && $_GET['key'] !== 'GxKo679Jm5xjOtQ81Zo3ywWMVcNB5wgP') {
|
||||
die("This script must be run from the command line.\n");
|
||||
}
|
||||
|
||||
@@ -215,6 +215,7 @@ if (mysqli_num_rows($sql_queue) > 0) {
|
||||
$email_content = $rowq['email_content'];
|
||||
$email_ics_str = $rowq['email_cal_str'];
|
||||
|
||||
// Check sender
|
||||
if (!filter_var($email_from, FILTER_VALIDATE_EMAIL)) {
|
||||
$email_from_logging = sanitizeInput($rowq['email_from']);
|
||||
mysqli_query($mysqli, "UPDATE email_queue SET email_status = 2, email_attempts = 99 WHERE email_id = $email_id");
|
||||
@@ -225,10 +226,14 @@ if (mysqli_num_rows($sql_queue) > 0) {
|
||||
|
||||
mysqli_query($mysqli, "UPDATE email_queue SET email_status = 1 WHERE email_id = $email_id");
|
||||
|
||||
if (!filter_var($email_recipient, FILTER_VALIDATE_EMAIL)) {
|
||||
// Check recipient
|
||||
$domain = sanitizeInput(substr($email_recipient, strpos($email_recipient, '@') + 1));
|
||||
if (!filter_var($email_recipient, FILTER_VALIDATE_EMAIL) || !checkdnsrr($domain, 'MX')) {
|
||||
mysqli_query($mysqli, "UPDATE email_queue SET email_status = 2, email_attempts = 99 WHERE email_id = $email_id");
|
||||
$email_to_logging = sanitizeInput($email_recipient);
|
||||
$email_subject_logging = sanitizeInput($rowq['email_subject']);
|
||||
logApp("Cron-Mail-Queue", "Error", "Failed to send email: $email_id due to invalid recipient address. Email subject was: $email_subject_logging");
|
||||
logApp("Cron-Mail-Queue", "Error", "Failed to send email: $email_id to $email_to_logging due to invalid recipient address. Email subject was: $email_subject_logging");
|
||||
appNotify("Mail", "Failed to send email #$email_id to $email_to_logging due to invalid recipient address: Email subject was: $email_subject_logging");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -273,7 +278,7 @@ if (mysqli_num_rows($sql_queue) > 0) {
|
||||
/** =======================================================================
|
||||
* RETRIES: status = 2 (Failed), attempts < 4, wait 30 min
|
||||
* NOTE: Backoff is `email_failed_at <= NOW() - INTERVAL 30 MINUTE`
|
||||
* ======================================================================= */
|
||||
* =======================================================================*/
|
||||
$sql_failed_queue = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM email_queue
|
||||
|
||||
@@ -11,7 +11,7 @@ $script_start_time = microtime(true);
|
||||
chdir(dirname(__FILE__));
|
||||
|
||||
// Ensure we're running from command line
|
||||
if (php_sapi_name() !== 'cli') {
|
||||
if (php_sapi_name() !== 'cli' && $_GET['key'] !== 'GxKo679Jm5xjOtQ81Zo3ywWMVcNB5wgP') {
|
||||
die("This script must be run from the command line.\n");
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ function addReply($from_email, $date, $subject, $ticket_number, $message, $attac
|
||||
$tech_name = sanitizeInput($tech_row['user_name']);
|
||||
|
||||
$email_subject = "$config_app_name - Ticket updated - [$config_ticket_prefix$ticket_number] $ticket_subject";
|
||||
$email_body = "Hello $tech_name,<br><br>A new reply has been added to the below ticket, check ITFlow for full details.<br><br>Client: $client_name<br>Ticket: $config_ticket_prefix$ticket_number<br>Subject: $ticket_subject<br><br>https://$config_base_url/agent/ticket.php?ticket_id=$ticket_id";
|
||||
$email_body = "Hello $tech_name,<br><br>A new reply has been added to the below ticket.<br><br>Client: $client_name<br>Ticket: $config_ticket_prefix$ticket_number<br>Subject: $ticket_subject<br>Link: https://$config_base_url/agent/ticket.php?ticket_id=$ticket_id<br><br>--------------------------------<br>$message_esc";
|
||||
|
||||
$data = [
|
||||
[
|
||||
@@ -546,17 +546,10 @@ $unprocessed_count = 0;
|
||||
foreach ($messages as $message) {
|
||||
$email_processed = false;
|
||||
|
||||
// Save original RFC822 message as .eml
|
||||
// Save original message as .eml (getRawMessage() doesn't seem to work properly)
|
||||
mkdirMissing('../uploads/tmp/');
|
||||
$original_message_file = "processed-eml-" . randomString(200) . ".eml";
|
||||
|
||||
try {
|
||||
// getRawMessage() available in v3; for v2 use getHeader()->raw or getStructure()? We'll try getRawMessage()
|
||||
$raw_message = $message->getRawMessage();
|
||||
} catch (\Throwable $e) {
|
||||
// Fallback to rebuilding from headers + body if raw not available
|
||||
$raw_message = (string)$message->getHeader()->raw . "\r\n\r\n" . ($message->getRawBody() ?? $message->getHTMLBody() ?? $message->getTextBody());
|
||||
}
|
||||
$raw_message = (string)$message->getHeader()->raw . "\r\n\r\n" . ($message->getRawBody() ?? $message->getHTMLBody() ?? $message->getTextBody());
|
||||
file_put_contents("../uploads/tmp/{$original_message_file}", $raw_message);
|
||||
|
||||
// From
|
||||
|
||||
Reference in New Issue
Block a user