]> 91.132.146.200 Git - insipid.git/commitdiff
updated e-mail importer
authorBanana <mail@bananas-playground.net>
Mon, 11 Sep 2023 11:23:34 +0000 (13:23 +0200)
committerBanana <mail@bananas-playground.net>
Mon, 11 Sep 2023 11:23:34 +0000 (13:23 +0200)
webroot/index.php
webroot/job/email-import.php
webroot/lib/snapshot.class.php
webroot/lib/summoner.class.php

index eee0f58b57932c44f5d681edeca5832c4f7eb630..1ce564e2f944baa395d5861aaf5af3d6ed6e16c6 100644 (file)
@@ -45,7 +45,6 @@ if(!empty($_urlToParse)) {
 
 ## set the error reporting
 ini_set('log_errors',true);
-ini_set('error_log','error.log');
 if(DEBUG === true) {
     ini_set('display_errors',true);
 }
index 8819577b8f1a04b5d93ff1e3fd8d34fd07ad64b0..69ee442e35f2981785f7ccadbcd0f47259591213 100644 (file)
 
 mb_http_output('UTF-8');
 mb_internal_encoding('UTF-8');
-ini_set('error_reporting',-1); // E_ALL & E_STRICT
+error_reporting(-1); // E_ALL & E_STRICT
 # time settings
 date_default_timezone_set('Europe/Berlin');
 
 require('../config.php');
 
 ## set the error reporting
-ini_set('log_errors',true);
-ini_set('error_log','import.log');
+ini_set('log_errors',true);;
 if(DEBUG === true) {
     ini_set('display_errors',true);
 }
@@ -123,7 +122,7 @@ try {
     if(DEBUG === true) $EmailReader->mailboxStatus();
 }
 catch (Exception $e) {
-    error_log('ERROR Email server connection failed: '.var_export($e->getMessage(),true));
+    Summoner::sysLog('[ERROR] Email server connection failed: '.var_export($e->getMessage(),true));
     exit();
 }
 
@@ -133,7 +132,7 @@ try {
     $emails = $EmailReader->messageWithValidSubject(EMAIL_MARKER);
 }
 catch (Exception $e) {
-    error_log('ERROR Can not process email messages: '.var_export($e->getMessage(),true));
+    Summoner::sysLog('[ERROR] Can not process email messages: '.var_export($e->getMessage(),true));
     exit();
 }
 
@@ -208,7 +207,7 @@ if(!empty($emails)) {
 
                 if(!empty($existing) && isset($existing['id'])) {
                     $linkID = $existing['id'];
-                    error_log('INFO Updating existing link with tag or category '.$newdata['link']);
+                    Summoner::sysLog('[INFO] Updating existing link with tag or category '.$newdata['link']);
                 }
                 else {
                     $linkObj = new Link($DB);
@@ -225,7 +224,7 @@ if(!empty($emails)) {
                         ), true);
                     } catch (Exception $e) {
                         $_m = "WARN Can not create new link into DB." . $e->getMessage();
-                        error_log($_m);
+                        Summoner::sysLog($_m);
                         $emailData['importmessage'] = $_m;
                         array_push($invalidProcessedEmails, $emailData);
                         if (DEBUG === true) var_dump($_m);
@@ -257,12 +256,12 @@ if(!empty($emails)) {
 
                                        $DB->commit();
 
-                                       error_log("INFO Link successfully added/updated: ".$newdata['link']);
+                    Summoner::sysLog("[INFO] Link successfully added/updated: ".$newdata['link']);
                                        array_push($validProcessedEmails,$emailData);
                                }
                                else {
                                        $DB->rollback();
-                                       error_log("ERROR Link could not be added. SQL problem? ".$newdata['link']);
+                    Summoner::sysLog("[ERROR] Link could not be added. SQL problem? ".$newdata['link']);
                                        $emailData['importmessage'] = "Link could not be added";
                                        array_push($invalidProcessedEmails,$emailData);
                                }
@@ -274,7 +273,7 @@ if(!empty($emails)) {
 # if we have invalid import mails, ignore them, just log em
 # if EMAIL_REPORT_BACK is true then report back with errors if EMAIL_REPLY_BACK_VALID
 if(!empty($invalidProcessedEmails)) {
-       error_log("INFO We have invalid import messages.");
+    Summoner::sysLog("[INFO] We have invalid import messages.");
        foreach ($invalidProcessedEmails as $invalidMail) {
                if(EmailImportHelper::canSendReplyTo($invalidMail['header_rfc822']->reply_toaddress)
                        && !EmailImportHelper::isAutoReplyMessage($invalidMail['header_array'])) {
@@ -283,20 +282,20 @@ if(!empty($invalidProcessedEmails)) {
                        $phpmailer->Body .= $invalidMail['body'];
                        $phpmailer->addAddress($_address[0]['address']);
                        $phpmailer->send();
-                       error_log("INFO Report back email to: ".$_address[0]['address']);
+            Summoner::sysLog("[INFO] Report back email to: ".$_address[0]['address']);
                }
                else {
-                       error_log("WARN Invalid message: ".$invalidMail['header_rfc822']->subject);
+            Summoner::sysLog("[WARN] Invalid message: ".$invalidMail['header_rfc822']->subject);
                }
        }
 }
 
 # move them to the processed / archive folder
 if(!empty($validProcessedEmails)) {
-       error_log("INFO We have valid import messages.");
+    Summoner::sysLog("[INFO] We have valid import messages.");
        foreach ($validProcessedEmails as $validMail) {
            $EmailReader->moveMessage($validMail['uid']);
-        error_log("INFO Mail moved to archive ".$validMail['header_rfc822']->subject);
+        Summoner::sysLog("[INFO] Mail moved to archive ".$validMail['header_rfc822']->subject);
        }
 }
 
index 13ebce88c30da5bf2437032887c6b3b426c84e4c..2e720ad639ae6621bdcef62e1fed6b157d2b5719 100644 (file)
@@ -111,7 +111,7 @@ class Snapshot {
             if ($command->execute()) {
                 $ret = $command->getOutput();
             } else {
-                error_log($command->getError());
+                Summoner::sysLog($command->getError());
                 $ret = $command->getExitCode();
             }
         }
index bb6a693e2bac31e8b7185e9caebcfb83b656df5d..0673fba14c67c1f0554a64b673275b3c654681fc 100644 (file)
@@ -162,7 +162,7 @@ class Summoner {
             $ret = $do;
         }
         else {
-            error_log('ERROR '.var_export(curl_error($ch),true));
+            self::sysLog('ERROR '.var_export(curl_error($ch),true));
         }
 
         curl_close($ch);