fusionpbx/app/email_logs/email_log_cron.php

61 lines
1.6 KiB
PHP
Raw Normal View History

2016-03-11 22:03:01 +01:00
<?php
2017-01-17 02:26:23 +01:00
//restrict to command line only
2019-08-06 05:22:26 +02:00
if (defined('STDIN')) {
2017-01-17 02:26:23 +01:00
$document_root = str_replace("\\", "/", $_SERVER["PHP_SELF"]);
preg_match("/^(.*)\/app\/.*$/", $document_root, $matches);
$document_root = $matches[1];
set_include_path($document_root);
include "root.php";
require_once "resources/require.php";
require_once "resources/classes/text.php";
$_SERVER["DOCUMENT_ROOT"] = $document_root;
$format = 'text'; //html, text
//add multi-lingual support
$language = new text;
$text = $language->get();
}
else {
die('access denied');
}
2016-03-11 22:03:01 +01:00
2017-01-17 02:26:23 +01:00
//get the failed emails
$sql = "select email_log_uuid, email from v_email_logs limit 100";
2019-08-06 05:22:26 +02:00
$database = new database;
$emails = $database->select($sql, null, 'all');
2017-01-17 02:26:23 +01:00
//process the emails
2019-08-06 05:22:26 +02:00
if (is_array($emails) && @sizeof($emails) != 0) {
2019-08-29 05:02:08 +02:00
foreach($emails as $x => $row) {
$email_log_uuid = $row['email_log_uuid'];
2017-01-17 02:26:23 +01:00
$msg = $row['email'];
require_once "secure/v_mailto.php";
if ($mailer_error == '') {
2019-08-29 05:02:08 +02:00
//set the message
message::add($text['message-message_resent']);
2017-01-17 02:26:23 +01:00
2019-08-29 05:02:08 +02:00
//build delete array
$array['email_logs'][$x]['email_log_uuid'] = $email_log_uuid;
2016-03-11 22:03:01 +01:00
}
2017-01-17 02:26:23 +01:00
unset($mailer_error);
2016-03-11 22:03:01 +01:00
}
2019-08-06 05:22:26 +02:00
if (is_array($array) && @sizeof($array) != 0) {
2019-08-29 05:02:08 +02:00
//grant temporary permissions
$p = new permissions;
$p->add('email_log_delete', 'temp');
//execute delete
$database = new database;
$database->app_name = 'email_logs';
$database->app_uuid = 'bd64f590-9a24-468d-951f-6639ac728694';
$database->delete($array);
unset($array);
//revoke temporary permissions
$p->delete('email_log_delete', 'temp');
2019-08-06 05:22:26 +02:00
}
2016-03-11 22:03:01 +01:00
}
2019-08-29 05:02:08 +02:00
unset($sql, $emails, $x, $row);
2016-03-11 22:03:01 +01:00
2017-01-17 02:26:23 +01:00
?>