From 11904944cb32117a6288ef5145fd98c7322c5318 Mon Sep 17 00:00:00 2001
From: Banana <mail@bananas-playground.net>
Date: Sun, 12 Jun 2022 13:36:07 +0200
Subject: [PATCH] email imported update and changelog update

---
 ChangeLog                         |  5 +++--
 documentation/email-importer.txt  |  5 ++++-
 webroot/job/email-import.php      | 11 +++++------
 webroot/lib/simple-imap.class.php |  9 +++++----
 4 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 44f3dd4..80e3240 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,4 @@
-version 2.7 - Sacred Grove ()
+version 2.7 - Sacred Grove (2022-06-12)
 
 	+ Fixed bug #12. Missing translation key
 	+ Adapted some new PHP code formatting
@@ -8,7 +8,8 @@ version 2.7 - Sacred Grove ()
 	+ New syntax in config file. See update.txt for more details
 	+ Fixed #13
 	+ Fixed #15
-	# Fixed #14
+	+ Fixed #14
+	+ Fixed some small email importer notices and warnings
 
 version 2.6 - Hypostyle (2021-03-21)
 
diff --git a/documentation/email-importer.txt b/documentation/email-importer.txt
index 1207e05..af2c93a 100644
--- a/documentation/email-importer.txt
+++ b/documentation/email-importer.txt
@@ -42,6 +42,9 @@ or active the "protection" with a secret given by URL / cli param.
 If you activate EMAIL_JOB_PROTECT you NEED to set an individual string in EMAIL_JOB_PROTECT_SECRET
 AND remove the provided .htaccess file in the job folder.
 
+cli: php email-import.php ----hiddenSouce=EMAIL_JOB_PROTECT_SECRET
+webaccess: email-import.php?hiddenSouce=EMAIL_JOB_PROTECT_SECRET
+
 Use the following settings in the config file:
 define('EMAIL_JOB_PROTECT', false); => Set to true if you want this kind of "protection"
-define('EMAIL_JOB_PROTECT_SECRET', 'YOUR_SOME_SECRET_STRING'); => Change to your liking
\ No newline at end of file
+define('EMAIL_JOB_PROTECT_SECRET', 'YOUR_SOME_SECRET_STRING'); => Change to your liking
diff --git a/webroot/job/email-import.php b/webroot/job/email-import.php
index e786269..64a60d7 100644
--- a/webroot/job/email-import.php
+++ b/webroot/job/email-import.php
@@ -3,7 +3,7 @@
  * Insipid
  * Personal web-bookmark-system
  *
- * Copyright 2016-2020 Johannes Keßler
+ * Copyright 2016-2022 Johannes Keßler
  *
  * Development starting from 2011: Johannes Keßler
  * https://www.bananas-playground.net/projekt/insipid/
@@ -32,7 +32,7 @@ ini_set('error_reporting',-1); // E_ALL & E_STRICT
 # time settings
 date_default_timezone_set('Europe/Berlin');
 
-define('DEBUG',false);
+const DEBUG = false;
 
 ## set the error reporting
 ini_set('log_errors',true);
@@ -146,7 +146,7 @@ if(!empty($emails)) {
     foreach($emails as $emailId=>$emailData) {
         $links = EmailImportHelper::extractEmailLinks($emailData['body']);
 		if(!empty($links)) {
-			if(DEBUG === true) var_dump($links);
+			if(DEBUG === true) var_dump("Links in email:",$links);
 
 			foreach($links as $linkstring) {
 				# defaults
@@ -174,7 +174,7 @@ if(!empty($emails)) {
 
 				if (!filter_var($newdata['link'], FILTER_VALIDATE_URL)) {
 					error_log("ERROR Invalid URL: ".var_export($newdata['link'],true));
-					if(DEBUG === true) var_dump($newdata['link']);
+					if(DEBUG === true) var_dump("Invalid URL:", $newdata['link']);
 					continue;
 				}
 
@@ -198,7 +198,7 @@ if(!empty($emails)) {
 					continue;
 				}
 
-				if(DEBUG === true) var_dump($newdata);
+				if(DEBUG === true) var_dump("New data", $newdata);
 
                 $linkObj = new Link($DB);
                 $linkID = false;
@@ -270,7 +270,6 @@ if(!empty($emails)) {
 				}
 			}
 		}
-
     }
 }
 
diff --git a/webroot/lib/simple-imap.class.php b/webroot/lib/simple-imap.class.php
index 8b09bc1..ff0a5bc 100644
--- a/webroot/lib/simple-imap.class.php
+++ b/webroot/lib/simple-imap.class.php
@@ -3,7 +3,7 @@
  * Insipid
  * Personal web-bookmark-system
  *
- * Copyright 2016-2021 Johannes Keßler
+ * Copyright 2016-2022 Johannes Keßler
  *
  * Development starting from 2011: Johannes Keßler
  * https://www.bananas-playground.net/projekt/insipid/
@@ -50,14 +50,14 @@ class SimpleImap {
 	 */
 	function __construct() {
 	    # create the mailboxstring
-	    $this->_connectionstring = '{'.$this->_server.':'.$this->_port.'/imap/ssl}';
+	    $this->_connectionstring = '{'.$this->_server.':'.$this->_port.'/imap/ssl/novalidate-cert}';
 	}
 
 	/**
 	 *
 	 */
 	function __destruct() {
-	    imap_close($this->_connection);
+	    //imap_close($this->_connection);
 	}
 
 	/**
@@ -270,7 +270,8 @@ class SimpleImap {
             break;
 
             case ENC7BIT: # 0 7BIT
-                $ret = imap_qprint($body);
+				// imap_qprint($body); does throws notices
+                $ret = quoted_printable_decode($body);
             break;
 
             case ENCOTHER: # 5 OTHER
-- 
2.39.5