mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2025-12-30 00:53:50 +00:00
Update email_cron.php
This commit is contained in:
@@ -1,39 +1,54 @@
|
||||
<?php
|
||||
if (PHP_SAPI === 'cli') {
|
||||
$argument1 = $argv[1];
|
||||
} else {
|
||||
die();
|
||||
}
|
||||
|
||||
require_once "root.php";
|
||||
require_once "resources/require.php";
|
||||
|
||||
$sql = "select email from v_emails";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
$result_count = count($result);
|
||||
if ($result_count > 0) {
|
||||
foreach($result as $row) {
|
||||
$msg = $row['email'];
|
||||
|
||||
require_once "secure/v_mailto.php";
|
||||
if ($mailer_error == '') {
|
||||
$_SESSION["message"] = $text['message-message_resent'];
|
||||
if (permission_exists('emails_all') && $_REQUEST['showall'] == 'true') {
|
||||
header("Location: email_delete.php?id=".$email_uuid."&showall=true");
|
||||
} else {
|
||||
header("Location: email_delete.php?id=".$email_uuid);
|
||||
}
|
||||
}
|
||||
|
||||
//restrict to command line only
|
||||
if(defined('STDIN')) {
|
||||
$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');
|
||||
}
|
||||
}
|
||||
unset ($prep_statement, $sql, $result, $result_count);
|
||||
|
||||
//get the failed emails
|
||||
$sql = "select email_uuid, email from v_emails";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$emails = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
|
||||
//process the emails
|
||||
if (is_array($emails)) {
|
||||
foreach($emails as $row) {
|
||||
$email_uuid = $row['email_uuid'];
|
||||
$msg = $row['email'];
|
||||
|
||||
require_once "secure/v_mailto.php";
|
||||
if ($mailer_error == '') {
|
||||
//get the message
|
||||
$_SESSION["message"] = $text['message-message_resent'];
|
||||
|
||||
exit;
|
||||
//delete the email
|
||||
$sql = "delete from v_emails ";
|
||||
$sql .= "where email_uuid = '".$email_uuid."' ";
|
||||
echo $sql;
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
unset($sql, $prep_statement);
|
||||
}
|
||||
unset($mailer_error);
|
||||
break;
|
||||
}
|
||||
}
|
||||
unset ($prep_statement, $sql, $emails);
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user