Пример #1
0
         $arr = array('step' => 'send', 'error' => $error, 'begin' => $sn, 'list_id' => $list_id, 'msg_id' => $msg_id, 'sn' => $sn, 'token' => $token, 'pct' => 100, 'TTS' => $tts);
         echo json_encode($arr);
     }
     break;
 default:
     $message = $_SESSION['message'];
     $subject = $_SESSION['subject'];
     $format = $_SESSION['format'];
     $date = date("Y-m-d H:i:s");
     $msg_id = save_message($cnx, $row_config_globale['table_archives'], addslashes($subject), $format, addslashes($message), $date, $list_id);
     $cnx->query("UPDATE " . $row_config_globale['table_upload'] . " SET msg_id={$msg_id} WHERE list_id={$list_id} AND msg_id=0");
     $dontlog = 0;
     if (!($handler = @fopen('logs/list' . $list_id . '-msg' . $msg_id . '.txt', 'a+'))) {
         $dontlog = 1;
     }
     $num = get_newsletter_total_subscribers($cnx, $row_config_globale['table_email'], $list_id);
     $sql = "INSERT into " . $row_config_globale['table_send'] . " (`id_mail`, `id_list`, `cpt`) VALUES ('" . $msg_id . "','" . $list_id . "','0')";
     $cnx->query($sql);
     $sql_suivi = "INSERT into " . $row_config_globale['table_send_suivi'] . " (`list_id`, `msg_id`, `total_to_send`) VALUES ('" . $list_id . "','" . $msg_id . "','" . $num . "')";
     $cnx->query($sql_suivi);
     $errstr = "============================================================\r\n";
     $errstr .= date("d M Y") . "\r\n";
     $errstr .= "Started at " . date("H:i:s") . "\r\n";
     $errstr .= "N° \t Date \t\t Time \t\t Status \t\t Recipient  \r\n";
     $errstr .= "------------------------------------------------------------\r\n";
     if (!$dontlog) {
         fwrite($handler, $errstr, strlen($errstr));
     }
     if (!$dontlog) {
         fclose($handler);
     }
Пример #2
0
$detail_task = $cnx->query('SELECT * FROM ' . $row_config_globale['table_crontab'] . ' WHERE job_id="' . $task_id . '" ORDER BY date DESC')->fetchAll(PDO::FETCH_ASSOC);
if (count($detail_task) == 0) {
    die('No task scheduled for this job');
} else {
    $dat = getrusage();
    /*
    5/ on met l'envoi dans les archives
    // on va mettre le message de la table sauvegarde dans la table archives :
    // cette requête sera faite dans l'envoi
    */
    echo "\n" . ($sql_arch = 'INSERT INTO ' . $row_config_globale['table_archives'] . ' (id,date,type,subject,message,list_id)
                    SELECT "' . $detail_task[0]['msg_id'] . '",CURTIME(),type,mail_subject,mail_body,list_id FROM ' . $row_config_globale['table_crontab'] . '
                        WHERE list_id = "' . $detail_task[0]['list_id'] . '" AND job_id = "' . $task_id . '"');
    $cnx->query($sql_arch);
    // on récupère le nombre total de destinataire :
    $total_suscribers = get_newsletter_total_subscribers($cnx, $row_config_globale['table_email'], $detail_task[0]['list_id']);
    /*                  
    6/ on créée l'entrée dans la table send
    */
    echo "\n" . ($sql = "INSERT into " . $row_config_globale['table_send'] . " (id_mail, id_list, cpt) \n        VALUES ('" . $detail_task[0]['msg_id'] . "','" . $detail_task[0]['list_id'] . "','0')");
    $cnx->query($sql);
    /*
    7/ on crée l'entrée dans la table send_suivi
    */
    echo "\n" . ($sql_suivi = "INSERT into " . $row_config_globale['table_send_suivi'] . " (list_id, msg_id, total_to_send) \n        VALUES ('" . $detail_task[0]['list_id'] . "','" . $detail_task[0]['msg_id'] . "','" . $total_suscribers . "')");
    $cnx->query($sql_suivi);
    $dontlog = 0;
    if (!($handler = @fopen(DOCROOT . '/logs/list' . $detail_task[0]['list_id'] . '-msg' . $detail_task[0]['msg_id'] . '.txt', 'a+'))) {
        $dontlog = 1;
    }
    $errstr = "============================================================\r\n";