From 5329028d6aa219aba1adb3b6c17027a175a55ba7 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 7 Jan 2022 12:17:39 +0100 Subject: [PATCH 001/367] Start feature --- .../install/mysql/migration/15.0.0-16.0.0.sql | 34 ++++++++++++ .../mysql/tables/llx_projet_task_time.sql | 1 + htdocs/projet/class/task.class.php | 6 +++ htdocs/projet/tasks/time.php | 53 ++++++++++++++++++- 4 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 htdocs/install/mysql/migration/15.0.0-16.0.0.sql diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql new file mode 100644 index 00000000000..64df9ca79cb --- /dev/null +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -0,0 +1,34 @@ +-- +-- Be carefull to requests order. +-- This file must be loaded by calling /install/index.php page +-- when current version is 14.0.0 or higher. +-- +-- To restrict request to Mysql version x.y minimum use -- VMYSQLx.y +-- To restrict request to Pgsql version x.y minimum use -- VPGSQLx.y +-- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new; +-- To add a column: ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol; +-- To rename a column: ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60); +-- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname; +-- To change type of field: ALTER TABLE llx_table MODIFY COLUMN name varchar(60); +-- To drop a foreign key: ALTER TABLE llx_table DROP FOREIGN KEY fk_name; +-- To create a unique index ALTER TABLE llx_table ADD UNIQUE INDEX uk_table_field (field); +-- To drop an index: -- VMYSQL4.1 DROP INDEX nomindex on llx_table; +-- To drop an index: -- VPGSQL8.2 DROP INDEX nomindex; +-- To make pk to be auto increment (mysql): -- VMYSQL4.3 ALTER TABLE llx_table CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT; +-- To make pk to be auto increment (postgres): +-- -- VPGSQL8.2 CREATE SEQUENCE llx_table_rowid_seq OWNED BY llx_table.rowid; +-- -- VPGSQL8.2 ALTER TABLE llx_table ADD PRIMARY KEY (rowid); +-- -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN rowid SET DEFAULT nextval('llx_table_rowid_seq'); +-- -- VPGSQL8.2 SELECT setval('llx_table_rowid_seq', MAX(rowid)) FROM llx_table; +-- To set a field as NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NULL; +-- To set a field as NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name DROP NOT NULL; +-- To set a field as NOT NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NOT NULL; +-- To set a field as NOT NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET NOT NULL; +-- To set a field as default NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL; +-- Note: fields with type BLOB/TEXT can't have default value. +-- To rebuild sequence for postgresql after insert by forcing id autoincrement fields: +-- -- VPGSQL8.2 SELECT dol_util_rebuild_sequences(); + + +-- Missing in v14 or lower +ALTER TABLE llx_projet_task_time ADD COLUMN fk_product integer NULL; diff --git a/htdocs/install/mysql/tables/llx_projet_task_time.sql b/htdocs/install/mysql/tables/llx_projet_task_time.sql index 786d8907588..63eadb1177f 100644 --- a/htdocs/install/mysql/tables/llx_projet_task_time.sql +++ b/htdocs/install/mysql/tables/llx_projet_task_time.sql @@ -24,6 +24,7 @@ create table llx_projet_task_time task_datehour datetime, -- day + hour task_date_withhour integer DEFAULT 0, -- 0 by default, 1 if date was entered with start hour task_duration double, + fk_product integer NULL, fk_user integer, thm double(24,8), invoice_id integer DEFAULT NULL, -- If we need to invoice each line of timespent, we can save invoice id here diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index dac2afa4834..5a6a3e1fba0 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -118,6 +118,7 @@ class Task extends CommonObject public $timespent_fk_user; public $timespent_thm; public $timespent_note; + public $timespent_fk_product; public $comments = array(); @@ -1201,6 +1202,7 @@ class Task extends CommonObject $sql .= ", task_date_withhour"; $sql .= ", task_duration"; $sql .= ", fk_user"; + $sql .= ", fk_product"; $sql .= ", note"; $sql .= ") VALUES ("; $sql .= ((int) $this->id); @@ -1209,6 +1211,7 @@ class Task extends CommonObject $sql .= ", ".(empty($this->timespent_withhour) ? 0 : 1); $sql .= ", ".((int) $this->timespent_duration); $sql .= ", ".((int) $this->timespent_fk_user); + $sql .= ", ".((int) $this->timespent_fk_product); $sql .= ", ".(isset($this->timespent_note) ? "'".$this->db->escape($this->timespent_note)."'" : "null"); $sql .= ")"; @@ -1404,6 +1407,7 @@ class Task extends CommonObject $sql .= " t.task_date_withhour,"; $sql .= " t.task_duration,"; $sql .= " t.fk_user,"; + $sql .= " t.fk_product,"; $sql .= " t.thm,"; $sql .= " t.note"; $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; @@ -1422,6 +1426,7 @@ class Task extends CommonObject $this->timespent_withhour = $obj->task_date_withhour; $this->timespent_duration = $obj->task_duration; $this->timespent_fk_user = $obj->fk_user; + $this->timespent_fk_product = $obj->fk_product; $this->timespent_thm = $obj->thm; // hourly rate $this->timespent_note = $obj->note; } @@ -1575,6 +1580,7 @@ class Task extends CommonObject $sql .= " task_date_withhour = ".(empty($this->timespent_withhour) ? 0 : 1).","; $sql .= " task_duration = ".((int) $this->timespent_duration).","; $sql .= " fk_user = ".((int) $this->timespent_fk_user).","; + $sql .= " fk_product = ".((int) $this->timespent_fk_product).","; $sql .= " note = ".(isset($this->timespent_note) ? "'".$this->db->escape($this->timespent_note)."'" : "null"); $sql .= " WHERE rowid = ".((int) $this->timespent_id); diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index f9f3a2aca43..03022cfd1c3 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -73,6 +73,7 @@ $search_task_ref = GETPOST('search_task_ref', 'alpha'); $search_task_label = GETPOST('search_task_label', 'alpha'); $search_user = GETPOST('search_user', 'int'); $search_valuebilled = GETPOST('search_valuebilled', 'int'); +$search_product_ref = GETPOST('search_product_ref', 'alpha'); // Security check $socid = 0; @@ -161,6 +162,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_task_label = ''; $search_user = 0; $search_valuebilled = ''; + $search_product_ref = ''; $toselect = ''; $search_array_options = array(); $action = ''; @@ -215,6 +217,7 @@ if ($action == 'addtimespent' && $user->rights->projet->lire) { $object->timespent_date = dol_mktime(12, 0, 0, GETPOST("timemonth", 'int'), GETPOST("timeday", 'int'), GETPOST("timeyear", 'int')); } $object->timespent_fk_user = GETPOST("userid", 'int'); + $object->timespent_fk_product = GETPOST("fk_product", 'int'); $result = $object->addTimeSpent($user); if ($result >= 0) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); @@ -261,6 +264,7 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us $object->timespent_date = dol_mktime(12, 0, 0, GETPOST("timelinemonth"), GETPOST("timelineday"), GETPOST("timelineyear")); } $object->timespent_fk_user = GETPOST("userid_line", 'int'); + $object->timespent_fk_product = GETPOST("fk_product", 'int'); $result = $object->addTimeSpent($user); if ($result >= 0) { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); @@ -284,6 +288,7 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us $object->timespent_date = dol_mktime(12, 0, 0, GETPOST("timelinemonth", 'int'), GETPOST("timelineday", 'int'), GETPOST("timelineyear", 'int')); } $object->timespent_fk_user = GETPOST("userid_line", 'int'); + $object->timespent_fk_product = GETPOST("fk_product", 'int'); $result = $object->updateTimeSpent($user); if ($result >= 0) { @@ -367,6 +372,7 @@ if ($action == 'confirm_generateinvoice') { $fuser = new User($db); $db->begin(); + //TODO produit du temps passé ou produt id $idprod = GETPOST('productid', 'int'); $generateinvoicemode = GETPOST('generateinvoicemode', 'string'); $invoiceToUse = GETPOST('invoiceid', 'int'); @@ -1029,6 +1035,9 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser } $arrayfields['author'] = array('label'=>$langs->trans("By"), 'checked'=>1); $arrayfields['t.note'] = array('label'=>$langs->trans("Note"), 'checked'=>1); + if ($conf->service->enabled && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) { + $arrayfields['t.fk_product'] = array('label' => $langs->trans("Product"), 'checked' => 1); + } $arrayfields['t.task_duration'] = array('label'=>$langs->trans("Duration"), 'checked'=>1); $arrayfields['value'] = array('label'=>$langs->trans("Value"), 'checked'=>1, 'enabled'=>(empty($conf->salaries->enabled) ? 0 : 1)); $arrayfields['valuebilled'] = array('label'=>$langs->trans("Billed"), 'checked'=>1, 'enabled'=>(((!empty($conf->global->PROJECT_HIDE_TASKS) || empty($conf->global->PROJECT_BILL_TIME_SPENT)) ? 0 : 1) && $projectstatic->usage_bill_time)); @@ -1167,6 +1176,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser $form->select_produits('', 'productid', '1', 0, $projectstatic->thirdparty->price_level, 1, 2, '', 0, array(), $projectstatic->thirdparty->id, 'None', 0, 'maxwidth500'); print ''; print ''; + //TODO : Use product of time affect } print ''; @@ -1238,12 +1248,14 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser $tasks = array(); $sql = "SELECT t.rowid, t.fk_task, t.task_date, t.task_datehour, t.task_date_withhour, t.task_duration, t.fk_user, t.note, t.thm,"; + $sql .= " t.fk_product,"; $sql .= " pt.ref, pt.label, pt.fk_projet,"; $sql .= " u.lastname, u.firstname, u.login, u.photo, u.statut as user_status,"; $sql .= " il.fk_facture as invoice_id, inv.fk_statut"; $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facturedet as il ON il.rowid = t.invoice_line_id"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as inv ON inv.rowid = il.fk_facture,"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as inv ON inv.rowid = il.fk_facture"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as prod ON prod.rowid = t.fk_product,"; $sql .= " ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid"; @@ -1273,6 +1285,9 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if ($search_user > 0) { $sql .= natural_search('t.fk_user', $search_user, 2); } + if (!empty($search_product_ref)) { + $sql .= natural_search('prod.ref', $search_product_ref); + } if ($search_valuebilled == '1') { $sql .= ' AND t.invoice_id > 0'; } @@ -1365,6 +1380,10 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser print ''.$langs->trans("ProgressDeclared").''; if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { print ''; + + if ($conf->service->enabled && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) { + print ''.$langs->trans("Product").''; + } } print ''; print "\n"; @@ -1436,6 +1455,12 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { print ''; print ''; + + if ($conf->service->enabled && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) { + print ''; + print $form->select_produits('', 'fk_product', '1', 0, $projectstatic->thirdparty->price_level, 1, 2, '', 0, array(), $projectstatic->thirdparty->id, 'None', 0, 'maxwidth500'); + print ''; + } } print ''; @@ -1509,6 +1534,10 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if (!empty($arrayfields['t.task_duration']['checked'])) { print ''; } + // Product + if (!empty($arrayfields['t.fk_product']['checked'])) { + print ''; + } // Value in main currency if (!empty($arrayfields['value']['checked'])) { print ''; @@ -1557,6 +1586,10 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if (!empty($arrayfields['t.task_duration']['checked'])) { print_liste_field_titre($arrayfields['t.task_duration']['label'], $_SERVER['PHP_SELF'], 't.task_duration', '', $param, '', $sortfield, $sortorder, 'right '); } + if (!empty($arrayfields['t.fk_product']['checked'])) { + print_liste_field_titre($arrayfields['t.fk_product']['label'], $_SERVER['PHP_SELF'], 't.fk_product', '', $param, '', $sortfield, $sortorder, 'right '); + } + if (!empty($arrayfields['value']['checked'])) { print_liste_field_titre($arrayfields['value']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, 'right '); } @@ -1732,6 +1765,24 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser $totalarray['totalduration'] += $task_time->task_duration; } + //Product + if (!empty($arrayfields['t.fk_product']['checked'])) { + print ''; + if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) { + $form->select_produits($task_time->fk_product, 'fk_product', '1', 0, $projectstatic->thirdparty->price_level, 1, 2, '', 0, array(), $projectstatic->thirdparty->id, 'None', 0, 'maxwidth500'); + } elseif (!empty($task_time->fk_product)) { + $product = new Product($db); + $resultFetch = $product->fetch($task_time->fk_product); + if ($resultFetch < 0) { + setEventMessages($product->error, $product->errors, 'errors'); + } else { + + print $product->getNomUrl(1); + } + } + print ''; + } + // Value spent if (!empty($arrayfields['value']['checked'])) { $langs->load("salaries"); From 09d2204effc7abfe9375d1d77a5565074cf55d69 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 7 Jan 2022 12:19:57 +0100 Subject: [PATCH 002/367] mov dbb change to othger pr --- .../install/mysql/migration/15.0.0-16.0.0.sql | 34 ------------------- .../mysql/tables/llx_projet_task_time.sql | 1 - 2 files changed, 35 deletions(-) delete mode 100644 htdocs/install/mysql/migration/15.0.0-16.0.0.sql diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql deleted file mode 100644 index 64df9ca79cb..00000000000 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ /dev/null @@ -1,34 +0,0 @@ --- --- Be carefull to requests order. --- This file must be loaded by calling /install/index.php page --- when current version is 14.0.0 or higher. --- --- To restrict request to Mysql version x.y minimum use -- VMYSQLx.y --- To restrict request to Pgsql version x.y minimum use -- VPGSQLx.y --- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new; --- To add a column: ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol; --- To rename a column: ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60); --- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname; --- To change type of field: ALTER TABLE llx_table MODIFY COLUMN name varchar(60); --- To drop a foreign key: ALTER TABLE llx_table DROP FOREIGN KEY fk_name; --- To create a unique index ALTER TABLE llx_table ADD UNIQUE INDEX uk_table_field (field); --- To drop an index: -- VMYSQL4.1 DROP INDEX nomindex on llx_table; --- To drop an index: -- VPGSQL8.2 DROP INDEX nomindex; --- To make pk to be auto increment (mysql): -- VMYSQL4.3 ALTER TABLE llx_table CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT; --- To make pk to be auto increment (postgres): --- -- VPGSQL8.2 CREATE SEQUENCE llx_table_rowid_seq OWNED BY llx_table.rowid; --- -- VPGSQL8.2 ALTER TABLE llx_table ADD PRIMARY KEY (rowid); --- -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN rowid SET DEFAULT nextval('llx_table_rowid_seq'); --- -- VPGSQL8.2 SELECT setval('llx_table_rowid_seq', MAX(rowid)) FROM llx_table; --- To set a field as NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NULL; --- To set a field as NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name DROP NOT NULL; --- To set a field as NOT NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NOT NULL; --- To set a field as NOT NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET NOT NULL; --- To set a field as default NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL; --- Note: fields with type BLOB/TEXT can't have default value. --- To rebuild sequence for postgresql after insert by forcing id autoincrement fields: --- -- VPGSQL8.2 SELECT dol_util_rebuild_sequences(); - - --- Missing in v14 or lower -ALTER TABLE llx_projet_task_time ADD COLUMN fk_product integer NULL; diff --git a/htdocs/install/mysql/tables/llx_projet_task_time.sql b/htdocs/install/mysql/tables/llx_projet_task_time.sql index 63eadb1177f..786d8907588 100644 --- a/htdocs/install/mysql/tables/llx_projet_task_time.sql +++ b/htdocs/install/mysql/tables/llx_projet_task_time.sql @@ -24,7 +24,6 @@ create table llx_projet_task_time task_datehour datetime, -- day + hour task_date_withhour integer DEFAULT 0, -- 0 by default, 1 if date was entered with start hour task_duration double, - fk_product integer NULL, fk_user integer, thm double(24,8), invoice_id integer DEFAULT NULL, -- If we need to invoice each line of timespent, we can save invoice id here From 633ad793cdfbf56e9300fff221758f67389f407d Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 7 Jan 2022 11:25:53 +0000 Subject: [PATCH 003/367] Fixing style errors. --- htdocs/projet/tasks/time.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 03022cfd1c3..d38ee8e580a 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -1776,7 +1776,6 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if ($resultFetch < 0) { setEventMessages($product->error, $product->errors, 'errors'); } else { - print $product->getNomUrl(1); } } From 8d3d8fe63b2607b7f875fa96e3c7c1ed7bd24b98 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 24 Jan 2022 23:24:08 +0100 Subject: [PATCH 004/367] merge --- .../EmailValidator/EmailLexer.php | 494 ++--- .../EmailValidator/EmailParser.php | 196 +- .../EmailValidator/EmailValidator.php | 98 +- .../Exception/DomainAcceptsNoMail.php | 6 +- .../Exception/ExpectingQPair.php | 4 +- .../Exception/LocalOrReservedDomain.php | 6 +- .../EmailValidator/Exception/NoDNSRecord.php | 4 +- .../Exception/UnclosedComment.php | 4 +- .../EmailValidator/Parser/DomainPart.php | 811 ++++--- .../EmailValidator/Parser/LocalPart.php | 210 +- .../EmailValidator/Parser/Parser.php | 379 ++-- .../Validation/DNSCheckValidation.php | 246 +- .../Exception/EmptyValidationList.php | 14 +- .../Validation/MultipleErrors.php | 42 +- .../Validation/MultipleValidationWithAnd.php | 196 +- .../Validation/NoRFCWarningsValidation.php | 50 +- .../Validation/RFCValidation.php | 64 +- .../Validation/SpoofCheckValidation.php | 66 +- .../EmailValidator/Warning/QuotedPart.php | 18 +- .../EmailValidator/Warning/QuotedString.php | 18 +- .../EmailValidator/Warning/Warning.php | 68 +- .../Doctrine/Common/Lexer/AbstractLexer.php | 536 ++--- .../swiftmailer/lib/classes/Swift.php | 104 +- .../lib/classes/Swift/AddressEncoder.php | 14 +- .../AddressEncoder/IdnAddressEncoder.php | 40 +- .../AddressEncoder/Utf8AddressEncoder.php | 14 +- .../classes/Swift/AddressEncoderException.php | 20 +- .../lib/classes/Swift/Attachment.php | 68 +- .../AbstractFilterableInputStream.php | 278 +-- .../Swift/ByteStream/ArrayByteStream.php | 288 +-- .../Swift/ByteStream/FileByteStream.php | 342 +-- .../ByteStream/TemporaryFileByteStream.php | 58 +- .../GenericFixedWidthReader.php | 142 +- .../Swift/CharacterReader/UsAsciiReader.php | 122 +- .../Swift/CharacterReader/Utf8Reader.php | 298 +-- .../SimpleCharacterReaderFactory.php | 182 +- .../lib/classes/Swift/CharacterStream.php | 114 +- .../CharacterStream/ArrayCharacterStream.php | 486 ++-- .../CharacterStream/NgCharacterStream.php | 440 ++-- .../lib/classes/Swift/DependencyContainer.php | 644 +++--- .../lib/classes/Swift/EmbeddedFile.php | 66 +- .../classes/Swift/Encoder/Base64Encoder.php | 72 +- .../lib/classes/Swift/Encoder/QpEncoder.php | 504 ++--- .../classes/Swift/Encoder/Rfc2231Encoder.php | 126 +- .../lib/classes/Swift/Events/CommandEvent.php | 84 +- .../classes/Swift/Events/CommandListener.php | 8 +- .../classes/Swift/Events/EventDispatcher.php | 92 +- .../lib/classes/Swift/Events/EventObject.php | 76 +- .../classes/Swift/Events/ResponseEvent.php | 84 +- .../classes/Swift/Events/ResponseListener.php | 8 +- .../lib/classes/Swift/Events/SendEvent.php | 188 +- .../lib/classes/Swift/Events/SendListener.php | 16 +- .../Swift/Events/SimpleEventDispatcher.php | 224 +- .../Swift/Events/TransportChangeListener.php | 32 +- .../Swift/Events/TransportExceptionEvent.php | 46 +- .../Events/TransportExceptionListener.php | 8 +- .../lib/classes/Swift/FailoverTransport.php | 28 +- .../lib/classes/Swift/FileSpool.php | 330 +-- .../lib/classes/Swift/Filterable.php | 24 +- .../lib/classes/Swift/InputByteStream.php | 100 +- .../lib/classes/Swift/IoException.php | 20 +- .../lib/classes/Swift/KeyCache.php | 154 +- .../classes/Swift/KeyCache/ArrayKeyCache.php | 332 +-- .../classes/Swift/KeyCache/DiskKeyCache.php | 508 ++--- .../Swift/KeyCache/KeyCacheInputStream.php | 50 +- .../classes/Swift/KeyCache/NullKeyCache.php | 176 +- .../KeyCache/SimpleKeyCacheInputStream.php | 184 +- .../classes/Swift/LoadBalancedTransport.php | 28 +- .../swiftmailer/lib/classes/Swift/Mailer.php | 142 +- .../Swift/Mailer/ArrayRecipientIterator.php | 64 +- .../lib/classes/Swift/MemorySpool.php | 162 +- .../swiftmailer/lib/classes/Swift/Message.php | 442 ++-- .../lib/classes/Swift/Mime/Attachment.php | 224 +- .../ContentEncoder/Base64ContentEncoder.php | 144 +- .../ContentEncoder/NativeQpContentEncoder.php | 182 +- .../ContentEncoder/NullContentEncoder.php | 110 +- .../ContentEncoder/PlainContentEncoder.php | 252 +-- .../Mime/ContentEncoder/QpContentEncoder.php | 200 +- .../ContentEncoder/QpContentEncoderProxy.php | 134 +- .../Mime/ContentEncoder/RawContentEncoder.php | 80 +- .../lib/classes/Swift/Mime/EmbeddedFile.php | 44 +- .../classes/Swift/Mime/EncodingObserver.php | 8 +- .../lib/classes/Swift/Mime/Header.php | 126 +- .../HeaderEncoder/Base64HeaderEncoder.php | 68 +- .../Mime/HeaderEncoder/QpHeaderEncoder.php | 88 +- .../Swift/Mime/Headers/AbstractHeader.php | 834 +++---- .../classes/Swift/Mime/Headers/DateHeader.php | 174 +- .../Mime/Headers/IdentificationHeader.php | 298 +-- .../Swift/Mime/Headers/MailboxHeader.php | 626 +++--- .../Swift/Mime/Headers/OpenDKIMHeader.php | 208 +- .../Mime/Headers/ParameterizedHeader.php | 426 ++-- .../classes/Swift/Mime/Headers/PathHeader.php | 242 +- .../Swift/Mime/Headers/UnstructuredHeader.php | 166 +- .../lib/classes/Swift/Mime/IdGenerator.php | 68 +- .../lib/classes/Swift/Mime/MimePart.php | 318 +-- .../Swift/Mime/SimpleHeaderFactory.php | 310 +-- .../classes/Swift/Mime/SimpleHeaderSet.php | 674 +++--- .../lib/classes/Swift/Mime/SimpleMessage.php | 1248 +++++------ .../classes/Swift/Mime/SimpleMimeEntity.php | 1616 +++++++------- .../lib/classes/Swift/MimePart.php | 52 +- .../lib/classes/Swift/NullTransport.php | 16 +- .../classes/Swift/Plugins/AntiFloodPlugin.php | 216 +- .../Swift/Plugins/BandwidthMonitorPlugin.php | 244 +- .../classes/Swift/Plugins/DecoratorPlugin.php | 332 +-- .../Swift/Plugins/ImpersonatePlugin.php | 80 +- .../classes/Swift/Plugins/LoggerPlugin.php | 194 +- .../Swift/Plugins/Loggers/ArrayLogger.php | 98 +- .../classes/Swift/Plugins/MessageLogger.php | 92 +- .../Swift/Plugins/PopBeforeSmtpPlugin.php | 376 ++-- .../Swift/Plugins/RedirectingPlugin.php | 314 +-- .../lib/classes/Swift/Plugins/Reporter.php | 22 +- .../classes/Swift/Plugins/ReporterPlugin.php | 72 +- .../Swift/Plugins/Reporters/HitReporter.php | 72 +- .../Swift/Plugins/Reporters/HtmlReporter.php | 40 +- .../classes/Swift/Plugins/ThrottlerPlugin.php | 312 +-- .../lib/classes/Swift/Preferences.php | 142 +- .../lib/classes/Swift/SendmailTransport.php | 28 +- .../swiftmailer/lib/classes/Swift/Signer.php | 2 +- .../lib/classes/Swift/Signers/BodySigner.php | 24 +- .../lib/classes/Swift/Signers/DKIMSigner.php | 1328 +++++------ .../classes/Swift/Signers/DomainKeySigner.php | 860 +++---- .../classes/Swift/Signers/HeaderSigner.php | 76 +- .../classes/Swift/Signers/OpenDKIMSigner.php | 274 +-- .../lib/classes/Swift/Signers/SMimeSigner.php | 1044 ++++----- .../lib/classes/Swift/SmtpTransport.php | 38 +- .../lib/classes/Swift/SpoolTransport.php | 26 +- .../ByteArrayReplacementFilter.php | 268 +-- .../StringReplacementFilterFactory.php | 46 +- .../lib/classes/Swift/SwiftException.php | 20 +- .../lib/classes/Swift/Transport.php | 106 +- .../Swift/Transport/AbstractSmtpTransport.php | 1046 ++++----- .../Esmtp/Auth/CramMd5Authenticator.php | 98 +- .../Esmtp/Auth/LoginAuthenticator.php | 48 +- .../Esmtp/Auth/NTLMAuthenticator.php | 1322 +++++------ .../Esmtp/Auth/PlainAuthenticator.php | 46 +- .../Esmtp/Auth/XOAuth2Authenticator.php | 64 +- .../Swift/Transport/Esmtp/AuthHandler.php | 448 ++-- .../Swift/Transport/Esmtp/Authenticator.php | 34 +- .../Transport/Esmtp/EightBitMimeHandler.php | 156 +- .../Swift/Transport/Esmtp/SmtpUtf8Handler.php | 144 +- .../classes/Swift/Transport/EsmtpHandler.php | 120 +- .../Swift/Transport/EsmtpTransport.php | 768 +++---- .../Swift/Transport/FailoverTransport.php | 146 +- .../lib/classes/Swift/Transport/IoBuffer.php | 82 +- .../Swift/Transport/LoadBalancedTransport.php | 310 +-- .../classes/Swift/Transport/NullTransport.php | 140 +- .../Swift/Transport/SendmailTransport.php | 241 +- .../lib/classes/Swift/Transport/SmtpAgent.php | 34 +- .../Swift/Transport/SpoolTransport.php | 176 +- .../classes/Swift/Transport/StreamBuffer.php | 540 ++--- .../lib/classes/Swift/TransportException.php | 20 +- .../lib/dependency_maps/cache_deps.php | 29 +- .../lib/dependency_maps/mime_deps.php | 207 +- .../lib/dependency_maps/transport_deps.php | 145 +- .../includes/swiftmailer/lib/mime_types.php | 1972 ++++++++--------- .../lib/swiftmailer_generate_mimes_config.php | 304 +-- htdocs/projet/tasks/time.php | 2 - 157 files changed, 17939 insertions(+), 17947 deletions(-) diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailLexer.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailLexer.php index 59dcd5876fd..567002e5e2c 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailLexer.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailLexer.php @@ -6,278 +6,278 @@ use Doctrine\Common\Lexer\AbstractLexer; class EmailLexer extends AbstractLexer { - //ASCII values - const C_DEL = 127; - const C_NUL = 0; - const S_AT = 64; - const S_BACKSLASH = 92; - const S_DOT = 46; - const S_DQUOTE = 34; - const S_SQUOTE = 39; - const S_BACKTICK = 96; - const S_OPENPARENTHESIS = 49; - const S_CLOSEPARENTHESIS = 261; - const S_OPENBRACKET = 262; - const S_CLOSEBRACKET = 263; - const S_HYPHEN = 264; - const S_COLON = 265; - const S_DOUBLECOLON = 266; - const S_SP = 267; - const S_HTAB = 268; - const S_CR = 269; - const S_LF = 270; - const S_IPV6TAG = 271; - const S_LOWERTHAN = 272; - const S_GREATERTHAN = 273; - const S_COMMA = 274; - const S_SEMICOLON = 275; - const S_OPENQBRACKET = 276; - const S_CLOSEQBRACKET = 277; - const S_SLASH = 278; - const S_EMPTY = null; - const GENERIC = 300; - const CRLF = 301; - const INVALID = 302; - const ASCII_INVALID_FROM = 127; - const ASCII_INVALID_TO = 199; + //ASCII values + const C_DEL = 127; + const C_NUL = 0; + const S_AT = 64; + const S_BACKSLASH = 92; + const S_DOT = 46; + const S_DQUOTE = 34; + const S_SQUOTE = 39; + const S_BACKTICK = 96; + const S_OPENPARENTHESIS = 49; + const S_CLOSEPARENTHESIS = 261; + const S_OPENBRACKET = 262; + const S_CLOSEBRACKET = 263; + const S_HYPHEN = 264; + const S_COLON = 265; + const S_DOUBLECOLON = 266; + const S_SP = 267; + const S_HTAB = 268; + const S_CR = 269; + const S_LF = 270; + const S_IPV6TAG = 271; + const S_LOWERTHAN = 272; + const S_GREATERTHAN = 273; + const S_COMMA = 274; + const S_SEMICOLON = 275; + const S_OPENQBRACKET = 276; + const S_CLOSEQBRACKET = 277; + const S_SLASH = 278; + const S_EMPTY = null; + const GENERIC = 300; + const CRLF = 301; + const INVALID = 302; + const ASCII_INVALID_FROM = 127; + const ASCII_INVALID_TO = 199; - /** - * US-ASCII visible characters not valid for atext (@link http://tools.ietf.org/html/rfc5322#section-3.2.3) - * - * @var array - */ - protected $charValue = array( - '(' => self::S_OPENPARENTHESIS, - ')' => self::S_CLOSEPARENTHESIS, - '<' => self::S_LOWERTHAN, - '>' => self::S_GREATERTHAN, - '[' => self::S_OPENBRACKET, - ']' => self::S_CLOSEBRACKET, - ':' => self::S_COLON, - ';' => self::S_SEMICOLON, - '@' => self::S_AT, - '\\' => self::S_BACKSLASH, - '/' => self::S_SLASH, - ',' => self::S_COMMA, - '.' => self::S_DOT, - "'" => self::S_SQUOTE, - "`" => self::S_BACKTICK, - '"' => self::S_DQUOTE, - '-' => self::S_HYPHEN, - '::' => self::S_DOUBLECOLON, - ' ' => self::S_SP, - "\t" => self::S_HTAB, - "\r" => self::S_CR, - "\n" => self::S_LF, - "\r\n" => self::CRLF, - 'IPv6' => self::S_IPV6TAG, - '{' => self::S_OPENQBRACKET, - '}' => self::S_CLOSEQBRACKET, - '' => self::S_EMPTY, - '\0' => self::C_NUL, - ); + /** + * US-ASCII visible characters not valid for atext (@link http://tools.ietf.org/html/rfc5322#section-3.2.3) + * + * @var array + */ + protected $charValue = array( + '(' => self::S_OPENPARENTHESIS, + ')' => self::S_CLOSEPARENTHESIS, + '<' => self::S_LOWERTHAN, + '>' => self::S_GREATERTHAN, + '[' => self::S_OPENBRACKET, + ']' => self::S_CLOSEBRACKET, + ':' => self::S_COLON, + ';' => self::S_SEMICOLON, + '@' => self::S_AT, + '\\' => self::S_BACKSLASH, + '/' => self::S_SLASH, + ',' => self::S_COMMA, + '.' => self::S_DOT, + "'" => self::S_SQUOTE, + "`" => self::S_BACKTICK, + '"' => self::S_DQUOTE, + '-' => self::S_HYPHEN, + '::' => self::S_DOUBLECOLON, + ' ' => self::S_SP, + "\t" => self::S_HTAB, + "\r" => self::S_CR, + "\n" => self::S_LF, + "\r\n" => self::CRLF, + 'IPv6' => self::S_IPV6TAG, + '{' => self::S_OPENQBRACKET, + '}' => self::S_CLOSEQBRACKET, + '' => self::S_EMPTY, + '\0' => self::C_NUL, + ); - /** - * @var bool - */ - protected $hasInvalidTokens = false; + /** + * @var bool + */ + protected $hasInvalidTokens = false; - /** - * @var array - * - * @psalm-var array{value:string, type:null|int, position:int}|array - */ - protected $previous = []; + /** + * @var array + * + * @psalm-var array{value:string, type:null|int, position:int}|array + */ + protected $previous = []; - /** - * The last matched/seen token. - * - * @var array - * - * @psalm-var array{value:string, type:null|int, position:int} - */ - public $token; + /** + * The last matched/seen token. + * + * @var array + * + * @psalm-var array{value:string, type:null|int, position:int} + */ + public $token; - /** - * The next token in the input. - * - * @var array|null - */ - public $lookahead; + /** + * The next token in the input. + * + * @var array|null + */ + public $lookahead; - /** - * @psalm-var array{value:'', type:null, position:0} - */ - private static $nullToken = [ - 'value' => '', - 'type' => null, - 'position' => 0, - ]; + /** + * @psalm-var array{value:'', type:null, position:0} + */ + private static $nullToken = [ + 'value' => '', + 'type' => null, + 'position' => 0, + ]; - public function __construct() - { - $this->previous = $this->token = self::$nullToken; - $this->lookahead = null; - } + public function __construct() + { + $this->previous = $this->token = self::$nullToken; + $this->lookahead = null; + } - /** - * @return void - */ - public function reset() - { - $this->hasInvalidTokens = false; - parent::reset(); - $this->previous = $this->token = self::$nullToken; - } + /** + * @return void + */ + public function reset() + { + $this->hasInvalidTokens = false; + parent::reset(); + $this->previous = $this->token = self::$nullToken; + } - /** - * @return bool - */ - public function hasInvalidTokens() - { - return $this->hasInvalidTokens; - } + /** + * @return bool + */ + public function hasInvalidTokens() + { + return $this->hasInvalidTokens; + } - /** - * @param int $type - * @throws \UnexpectedValueException - * @return boolean - * - * @psalm-suppress InvalidScalarArgument - */ - public function find($type) - { - $search = clone $this; - $search->skipUntil($type); + /** + * @param int $type + * @throws \UnexpectedValueException + * @return boolean + * + * @psalm-suppress InvalidScalarArgument + */ + public function find($type) + { + $search = clone $this; + $search->skipUntil($type); - if (!$search->lookahead) { - throw new \UnexpectedValueException($type . ' not found'); - } - return true; - } + if (!$search->lookahead) { + throw new \UnexpectedValueException($type . ' not found'); + } + return true; + } - /** - * getPrevious - * - * @return array - */ - public function getPrevious() - { - return $this->previous; - } + /** + * getPrevious + * + * @return array + */ + public function getPrevious() + { + return $this->previous; + } - /** - * moveNext - * - * @return boolean - */ - public function moveNext() - { - $this->previous = $this->token; - $hasNext = parent::moveNext(); - $this->token = $this->token ?: self::$nullToken; + /** + * moveNext + * + * @return boolean + */ + public function moveNext() + { + $this->previous = $this->token; + $hasNext = parent::moveNext(); + $this->token = $this->token ?: self::$nullToken; - return $hasNext; - } + return $hasNext; + } - /** - * Lexical catchable patterns. - * - * @return string[] - */ - protected function getCatchablePatterns() - { - return array( - '[a-zA-Z_]+[46]?', //ASCII and domain literal - '[^\x00-\x7F]', //UTF-8 - '[0-9]+', - '\r\n', - '::', - '\s+?', - '.', - ); - } + /** + * Lexical catchable patterns. + * + * @return string[] + */ + protected function getCatchablePatterns() + { + return array( + '[a-zA-Z_]+[46]?', //ASCII and domain literal + '[^\x00-\x7F]', //UTF-8 + '[0-9]+', + '\r\n', + '::', + '\s+?', + '.', + ); + } - /** - * Lexical non-catchable patterns. - * - * @return string[] - */ - protected function getNonCatchablePatterns() - { - return array('[\xA0-\xff]+'); - } + /** + * Lexical non-catchable patterns. + * + * @return string[] + */ + protected function getNonCatchablePatterns() + { + return array('[\xA0-\xff]+'); + } - /** - * Retrieve token type. Also processes the token value if necessary. - * - * @param string $value - * @throws \InvalidArgumentException - * @return integer - */ - protected function getType(&$value) - { - if ($this->isNullType($value)) { - return self::C_NUL; - } + /** + * Retrieve token type. Also processes the token value if necessary. + * + * @param string $value + * @throws \InvalidArgumentException + * @return integer + */ + protected function getType(&$value) + { + if ($this->isNullType($value)) { + return self::C_NUL; + } - if ($this->isValid($value)) { - return $this->charValue[$value]; - } + if ($this->isValid($value)) { + return $this->charValue[$value]; + } - if ($this->isUTF8Invalid($value)) { - $this->hasInvalidTokens = true; - return self::INVALID; - } + if ($this->isUTF8Invalid($value)) { + $this->hasInvalidTokens = true; + return self::INVALID; + } - return self::GENERIC; - } + return self::GENERIC; + } - /** - * @param string $value - * - * @return bool - */ - protected function isValid($value) - { - if (isset($this->charValue[$value])) { - return true; - } + /** + * @param string $value + * + * @return bool + */ + protected function isValid($value) + { + if (isset($this->charValue[$value])) { + return true; + } - return false; - } + return false; + } - /** - * @param string $value - * @return bool - */ - protected function isNullType($value) - { - if ($value === "\0") { - return true; - } + /** + * @param string $value + * @return bool + */ + protected function isNullType($value) + { + if ($value === "\0") { + return true; + } - return false; - } + return false; + } - /** - * @param string $value - * @return bool - */ - protected function isUTF8Invalid($value) - { - if (preg_match('/\p{Cc}+/u', $value)) { - return true; - } + /** + * @param string $value + * @return bool + */ + protected function isUTF8Invalid($value) + { + if (preg_match('/\p{Cc}+/u', $value)) { + return true; + } - return false; - } + return false; + } - /** - * @return string - */ - protected function getModifiers() - { - return 'iu'; - } + /** + * @return string + */ + protected function getModifiers() + { + return 'iu'; + } } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailParser.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailParser.php index 6b7bad66927..cf9e7652339 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailParser.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailParser.php @@ -15,123 +15,123 @@ use Egulias\EmailValidator\Warning\EmailTooLong; */ class EmailParser { - const EMAIL_MAX_LENGTH = 254; + const EMAIL_MAX_LENGTH = 254; - /** - * @var array - */ - protected $warnings = []; + /** + * @var array + */ + protected $warnings = []; - /** - * @var string - */ - protected $domainPart = ''; + /** + * @var string + */ + protected $domainPart = ''; - /** - * @var string - */ - protected $localPart = ''; - /** - * @var EmailLexer - */ - protected $lexer; + /** + * @var string + */ + protected $localPart = ''; + /** + * @var EmailLexer + */ + protected $lexer; - /** - * @var LocalPart - */ - protected $localPartParser; + /** + * @var LocalPart + */ + protected $localPartParser; - /** - * @var DomainPart - */ - protected $domainPartParser; + /** + * @var DomainPart + */ + protected $domainPartParser; - public function __construct(EmailLexer $lexer) - { - $this->lexer = $lexer; - $this->localPartParser = new LocalPart($this->lexer); - $this->domainPartParser = new DomainPart($this->lexer); - } + public function __construct(EmailLexer $lexer) + { + $this->lexer = $lexer; + $this->localPartParser = new LocalPart($this->lexer); + $this->domainPartParser = new DomainPart($this->lexer); + } - /** - * @param string $str - * @return array - */ - public function parse($str) - { - $this->lexer->setInput($str); + /** + * @param string $str + * @return array + */ + public function parse($str) + { + $this->lexer->setInput($str); - if (!$this->hasAtToken()) { - throw new NoLocalPart(); - } + if (!$this->hasAtToken()) { + throw new NoLocalPart(); + } - $this->localPartParser->parse($str); - $this->domainPartParser->parse($str); + $this->localPartParser->parse($str); + $this->domainPartParser->parse($str); - $this->setParts($str); + $this->setParts($str); - if ($this->lexer->hasInvalidTokens()) { - throw new ExpectingATEXT(); - } + if ($this->lexer->hasInvalidTokens()) { + throw new ExpectingATEXT(); + } - return array('local' => $this->localPart, 'domain' => $this->domainPart); - } + return array('local' => $this->localPart, 'domain' => $this->domainPart); + } - /** - * @return Warning\Warning[] - */ - public function getWarnings() - { - $localPartWarnings = $this->localPartParser->getWarnings(); - $domainPartWarnings = $this->domainPartParser->getWarnings(); - $this->warnings = array_merge($localPartWarnings, $domainPartWarnings); + /** + * @return Warning\Warning[] + */ + public function getWarnings() + { + $localPartWarnings = $this->localPartParser->getWarnings(); + $domainPartWarnings = $this->domainPartParser->getWarnings(); + $this->warnings = array_merge($localPartWarnings, $domainPartWarnings); - $this->addLongEmailWarning($this->localPart, $this->domainPart); + $this->addLongEmailWarning($this->localPart, $this->domainPart); - return $this->warnings; - } + return $this->warnings; + } - /** - * @return string - */ - public function getParsedDomainPart() - { - return $this->domainPart; - } + /** + * @return string + */ + public function getParsedDomainPart() + { + return $this->domainPart; + } - /** - * @param string $email - */ - protected function setParts($email) - { - $parts = explode('@', $email); - $this->domainPart = $this->domainPartParser->getDomainPart(); - $this->localPart = $parts[0]; - } + /** + * @param string $email + */ + protected function setParts($email) + { + $parts = explode('@', $email); + $this->domainPart = $this->domainPartParser->getDomainPart(); + $this->localPart = $parts[0]; + } - /** - * @return bool - */ - protected function hasAtToken() - { - $this->lexer->moveNext(); - $this->lexer->moveNext(); - if ($this->lexer->token['type'] === EmailLexer::S_AT) { - return false; - } + /** + * @return bool + */ + protected function hasAtToken() + { + $this->lexer->moveNext(); + $this->lexer->moveNext(); + if ($this->lexer->token['type'] === EmailLexer::S_AT) { + return false; + } - return true; - } + return true; + } - /** - * @param string $localPart - * @param string $parsedDomainPart - */ - protected function addLongEmailWarning($localPart, $parsedDomainPart) - { - if (strlen($localPart . '@' . $parsedDomainPart) > self::EMAIL_MAX_LENGTH) { - $this->warnings[EmailTooLong::CODE] = new EmailTooLong(); - } - } + /** + * @param string $localPart + * @param string $parsedDomainPart + */ + protected function addLongEmailWarning($localPart, $parsedDomainPart) + { + if (strlen($localPart . '@' . $parsedDomainPart) > self::EMAIL_MAX_LENGTH) { + $this->warnings[EmailTooLong::CODE] = new EmailTooLong(); + } + } } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailValidator.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailValidator.php index a30f21dcd30..e0532e618a6 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailValidator.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailValidator.php @@ -7,61 +7,61 @@ use Egulias\EmailValidator\Validation\EmailValidation; class EmailValidator { - /** - * @var EmailLexer - */ - private $lexer; + /** + * @var EmailLexer + */ + private $lexer; - /** - * @var Warning\Warning[] - */ - protected $warnings = []; + /** + * @var Warning\Warning[] + */ + protected $warnings = []; - /** - * @var InvalidEmail|null - */ - protected $error; + /** + * @var InvalidEmail|null + */ + protected $error; - public function __construct() - { - $this->lexer = new EmailLexer(); - } + public function __construct() + { + $this->lexer = new EmailLexer(); + } - /** - * @param string $email - * @param EmailValidation $emailValidation - * @return bool - */ - public function isValid($email, EmailValidation $emailValidation) - { - $isValid = $emailValidation->isValid($email, $this->lexer); - $this->warnings = $emailValidation->getWarnings(); - $this->error = $emailValidation->getError(); + /** + * @param string $email + * @param EmailValidation $emailValidation + * @return bool + */ + public function isValid($email, EmailValidation $emailValidation) + { + $isValid = $emailValidation->isValid($email, $this->lexer); + $this->warnings = $emailValidation->getWarnings(); + $this->error = $emailValidation->getError(); - return $isValid; - } + return $isValid; + } - /** - * @return boolean - */ - public function hasWarnings() - { - return !empty($this->warnings); - } + /** + * @return boolean + */ + public function hasWarnings() + { + return !empty($this->warnings); + } - /** - * @return array - */ - public function getWarnings() - { - return $this->warnings; - } + /** + * @return array + */ + public function getWarnings() + { + return $this->warnings; + } - /** - * @return InvalidEmail|null - */ - public function getError() - { - return $this->error; - } + /** + * @return InvalidEmail|null + */ + public function getError() + { + return $this->error; + } } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/DomainAcceptsNoMail.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/DomainAcceptsNoMail.php index 40a99705ce9..822258f6f07 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/DomainAcceptsNoMail.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/DomainAcceptsNoMail.php @@ -4,6 +4,6 @@ namespace Egulias\EmailValidator\Exception; class DomainAcceptsNoMail extends InvalidEmail { - const CODE = 154; - const REASON = 'Domain accepts no mail (Null MX, RFC7505)'; -} \ No newline at end of file + const CODE = 154; + const REASON = 'Domain accepts no mail (Null MX, RFC7505)'; +} diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/ExpectingQPair.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/ExpectingQPair.php index a738eeb62f0..ea9fc690bfa 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/ExpectingQPair.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/ExpectingQPair.php @@ -4,6 +4,6 @@ namespace Egulias\EmailValidator\Exception; class ExpectingQPair extends InvalidEmail { - const CODE = 136; - const REASON = "Expecting QPAIR"; + const CODE = 136; + const REASON = "Expecting QPAIR"; } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/LocalOrReservedDomain.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/LocalOrReservedDomain.php index 695b05a46d4..964a6406726 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/LocalOrReservedDomain.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/LocalOrReservedDomain.php @@ -4,6 +4,6 @@ namespace Egulias\EmailValidator\Exception; class LocalOrReservedDomain extends InvalidEmail { - const CODE = 153; - const REASON = 'Local, mDNS or reserved domain (RFC2606, RFC6762)'; -} \ No newline at end of file + const CODE = 153; + const REASON = 'Local, mDNS or reserved domain (RFC2606, RFC6762)'; +} diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/NoDNSRecord.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/NoDNSRecord.php index 0aa5fa78902..3e551ea6c11 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/NoDNSRecord.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/NoDNSRecord.php @@ -4,6 +4,6 @@ namespace Egulias\EmailValidator\Exception; class NoDNSRecord extends InvalidEmail { - const CODE = 5; - const REASON = 'No MX or A DSN record was found for this email'; + const CODE = 5; + const REASON = 'No MX or A DSN record was found for this email'; } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/UnclosedComment.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/UnclosedComment.php index 86b2b09622d..40d9ab31fb7 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/UnclosedComment.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/UnclosedComment.php @@ -4,6 +4,6 @@ namespace Egulias\EmailValidator\Exception; class UnclosedComment extends InvalidEmail { - const CODE = 146; - const REASON = "No closing comment token found"; + const CODE = 146; + const REASON = "No closing comment token found"; } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Parser/DomainPart.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Parser/DomainPart.php index 4dadba8af7c..8a0a8fe2674 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Parser/DomainPart.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Parser/DomainPart.php @@ -34,410 +34,409 @@ use Egulias\EmailValidator\Warning\TLD; class DomainPart extends Parser { - const DOMAIN_MAX_LENGTH = 254; - const LABEL_MAX_LENGTH = 63; - - /** - * @var string - */ - protected $domainPart = ''; - - public function parse($domainPart) - { - $this->lexer->moveNext(); - - $this->performDomainStartChecks(); - - $domain = $this->doParseDomainPart(); - - $prev = $this->lexer->getPrevious(); - $length = strlen($domain); - - if ($prev['type'] === EmailLexer::S_DOT) { - throw new DotAtEnd(); - } - if ($prev['type'] === EmailLexer::S_HYPHEN) { - throw new DomainHyphened(); - } - if ($length > self::DOMAIN_MAX_LENGTH) { - $this->warnings[DomainTooLong::CODE] = new DomainTooLong(); - } - if ($prev['type'] === EmailLexer::S_CR) { - throw new CRLFAtTheEnd(); - } - $this->domainPart = $domain; - } - - private function performDomainStartChecks() - { - $this->checkInvalidTokensAfterAT(); - $this->checkEmptyDomain(); - - if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) { - $this->warnings[DeprecatedComment::CODE] = new DeprecatedComment(); - $this->parseDomainComments(); - } - } - - private function checkEmptyDomain() - { - $thereIsNoDomain = $this->lexer->token['type'] === EmailLexer::S_EMPTY || - ($this->lexer->token['type'] === EmailLexer::S_SP && - !$this->lexer->isNextToken(EmailLexer::GENERIC)); - - if ($thereIsNoDomain) { - throw new NoDomainPart(); - } - } - - private function checkInvalidTokensAfterAT() - { - if ($this->lexer->token['type'] === EmailLexer::S_DOT) { - throw new DotAtStart(); - } - if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN) { - throw new DomainHyphened(); - } - } - - /** - * @return string - */ - public function getDomainPart() - { - return $this->domainPart; - } - - /** - * @param string $addressLiteral - * @param int $maxGroups - */ - public function checkIPV6Tag($addressLiteral, $maxGroups = 8) - { - $prev = $this->lexer->getPrevious(); - if ($prev['type'] === EmailLexer::S_COLON) { - $this->warnings[IPV6ColonEnd::CODE] = new IPV6ColonEnd(); - } - - $IPv6 = substr($addressLiteral, 5); - //Daniel Marschall's new IPv6 testing strategy - $matchesIP = explode(':', $IPv6); - $groupCount = count($matchesIP); - $colons = strpos($IPv6, '::'); - - if (count(preg_grep('/^[0-9A-Fa-f]{0,4}$/', $matchesIP, PREG_GREP_INVERT)) !== 0) { - $this->warnings[IPV6BadChar::CODE] = new IPV6BadChar(); - } - - if ($colons === false) { - // We need exactly the right number of groups - if ($groupCount !== $maxGroups) { - $this->warnings[IPV6GroupCount::CODE] = new IPV6GroupCount(); - } - return; - } - - if ($colons !== strrpos($IPv6, '::')) { - $this->warnings[IPV6DoubleColon::CODE] = new IPV6DoubleColon(); - return; - } - - if ($colons === 0 || $colons === (strlen($IPv6) - 2)) { - // RFC 4291 allows :: at the start or end of an address - //with 7 other groups in addition - ++$maxGroups; - } - - if ($groupCount > $maxGroups) { - $this->warnings[IPV6MaxGroups::CODE] = new IPV6MaxGroups(); - } elseif ($groupCount === $maxGroups) { - $this->warnings[IPV6Deprecated::CODE] = new IPV6Deprecated(); - } - } - - /** - * @return string - */ - protected function doParseDomainPart() - { - $domain = ''; - $label = ''; - $openedParenthesis = 0; - do { - $prev = $this->lexer->getPrevious(); - - $this->checkNotAllowedChars($this->lexer->token); - - if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) { - $this->parseComments(); - $openedParenthesis += $this->getOpenedParenthesis(); - $this->lexer->moveNext(); - $tmpPrev = $this->lexer->getPrevious(); - if ($tmpPrev['type'] === EmailLexer::S_CLOSEPARENTHESIS) { - $openedParenthesis--; - } - } - if ($this->lexer->token['type'] === EmailLexer::S_CLOSEPARENTHESIS) { - if ($openedParenthesis === 0) { - throw new UnopenedComment(); - } else { - $openedParenthesis--; - } - } - - $this->checkConsecutiveDots(); - $this->checkDomainPartExceptions($prev); - - if ($this->hasBrackets()) { - $this->parseDomainLiteral(); - } - - if ($this->lexer->token['type'] === EmailLexer::S_DOT) { - $this->checkLabelLength($label); - $label = ''; - } else { - $label .= $this->lexer->token['value']; - } - - if ($this->isFWS()) { - $this->parseFWS(); - } - - $domain .= $this->lexer->token['value']; - $this->lexer->moveNext(); - if ($this->lexer->token['type'] === EmailLexer::S_SP) { - throw new CharNotAllowed(); - } - } while (null !== $this->lexer->token['type']); - - $this->checkLabelLength($label); - - return $domain; - } - - private function checkNotAllowedChars(array $token) - { - $notAllowed = [EmailLexer::S_BACKSLASH => true, EmailLexer::S_SLASH=> true]; - if (isset($notAllowed[$token['type']])) { - throw new CharNotAllowed(); - } - } - - /** - * @return string|false - */ - protected function parseDomainLiteral() - { - if ($this->lexer->isNextToken(EmailLexer::S_COLON)) { - $this->warnings[IPV6ColonStart::CODE] = new IPV6ColonStart(); - } - if ($this->lexer->isNextToken(EmailLexer::S_IPV6TAG)) { - $lexer = clone $this->lexer; - $lexer->moveNext(); - if ($lexer->isNextToken(EmailLexer::S_DOUBLECOLON)) { - $this->warnings[IPV6ColonStart::CODE] = new IPV6ColonStart(); - } - } - - return $this->doParseDomainLiteral(); - } - - /** - * @return string|false - */ - protected function doParseDomainLiteral() - { - $IPv6TAG = false; - $addressLiteral = ''; - do { - if ($this->lexer->token['type'] === EmailLexer::C_NUL) { - throw new ExpectingDTEXT(); - } - - if ($this->lexer->token['type'] === EmailLexer::INVALID || - $this->lexer->token['type'] === EmailLexer::C_DEL || - $this->lexer->token['type'] === EmailLexer::S_LF - ) { - $this->warnings[ObsoleteDTEXT::CODE] = new ObsoleteDTEXT(); - } - - if ($this->lexer->isNextTokenAny(array(EmailLexer::S_OPENQBRACKET, EmailLexer::S_OPENBRACKET))) { - throw new ExpectingDTEXT(); - } - - if ($this->lexer->isNextTokenAny( - array(EmailLexer::S_HTAB, EmailLexer::S_SP, $this->lexer->token['type'] === EmailLexer::CRLF) - )) { - $this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS(); - $this->parseFWS(); - } - - if ($this->lexer->isNextToken(EmailLexer::S_CR)) { - throw new CRNoLF(); - } - - if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH) { - $this->warnings[ObsoleteDTEXT::CODE] = new ObsoleteDTEXT(); - $addressLiteral .= $this->lexer->token['value']; - $this->lexer->moveNext(); - $this->validateQuotedPair(); - } - if ($this->lexer->token['type'] === EmailLexer::S_IPV6TAG) { - $IPv6TAG = true; - } - if ($this->lexer->token['type'] === EmailLexer::S_CLOSEQBRACKET) { - break; - } - - $addressLiteral .= $this->lexer->token['value']; - - } while ($this->lexer->moveNext()); - - $addressLiteral = str_replace('[', '', $addressLiteral); - $addressLiteral = $this->checkIPV4Tag($addressLiteral); - - if (false === $addressLiteral) { - return $addressLiteral; - } - - if (!$IPv6TAG) { - $this->warnings[DomainLiteral::CODE] = new DomainLiteral(); - return $addressLiteral; - } - - $this->warnings[AddressLiteral::CODE] = new AddressLiteral(); - - $this->checkIPV6Tag($addressLiteral); - - return $addressLiteral; - } - - /** - * @param string $addressLiteral - * - * @return string|false - */ - protected function checkIPV4Tag($addressLiteral) - { - $matchesIP = array(); - - // Extract IPv4 part from the end of the address-literal (if there is one) - if (preg_match( - '/\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/', - $addressLiteral, - $matchesIP - ) > 0 - ) { - $index = strrpos($addressLiteral, $matchesIP[0]); - if ($index === 0) { - $this->warnings[AddressLiteral::CODE] = new AddressLiteral(); - return false; - } - // Convert IPv4 part to IPv6 format for further testing - $addressLiteral = substr($addressLiteral, 0, (int) $index) . '0:0'; - } - - return $addressLiteral; - } - - protected function checkDomainPartExceptions(array $prev) - { - $invalidDomainTokens = array( - EmailLexer::S_DQUOTE => true, - EmailLexer::S_SQUOTE => true, - EmailLexer::S_BACKTICK => true, - EmailLexer::S_SEMICOLON => true, - EmailLexer::S_GREATERTHAN => true, - EmailLexer::S_LOWERTHAN => true, - ); - - if (isset($invalidDomainTokens[$this->lexer->token['type']])) { - throw new ExpectingATEXT(); - } - - if ($this->lexer->token['type'] === EmailLexer::S_COMMA) { - throw new CommaInDomain(); - } - - if ($this->lexer->token['type'] === EmailLexer::S_AT) { - throw new ConsecutiveAt(); - } - - if ($this->lexer->token['type'] === EmailLexer::S_OPENQBRACKET && $prev['type'] !== EmailLexer::S_AT) { - throw new ExpectingATEXT(); - } - - if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN && $this->lexer->isNextToken(EmailLexer::S_DOT)) { - throw new DomainHyphened(); - } - - if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH - && $this->lexer->isNextToken(EmailLexer::GENERIC)) { - throw new ExpectingATEXT(); - } - } - - /** - * @return bool - */ - protected function hasBrackets() - { - if ($this->lexer->token['type'] !== EmailLexer::S_OPENBRACKET) { - return false; - } - - try { - $this->lexer->find(EmailLexer::S_CLOSEBRACKET); - } catch (\RuntimeException $e) { - throw new ExpectingDomainLiteralClose(); - } - - return true; - } - - /** - * @param string $label - */ - protected function checkLabelLength($label) - { - if ($this->isLabelTooLong($label)) { - $this->warnings[LabelTooLong::CODE] = new LabelTooLong(); - } - } - - /** - * @param string $label - * @return bool - */ - private function isLabelTooLong($label) - { - if (preg_match('/[^\x00-\x7F]/', $label)) { - idn_to_ascii($label, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46, $idnaInfo); - - return (bool) ($idnaInfo['errors'] & IDNA_ERROR_LABEL_TOO_LONG); - } - - return strlen($label) > self::LABEL_MAX_LENGTH; - } - - protected function parseDomainComments() - { - $this->isUnclosedComment(); - while (!$this->lexer->isNextToken(EmailLexer::S_CLOSEPARENTHESIS)) { - $this->warnEscaping(); - $this->lexer->moveNext(); - } - - $this->lexer->moveNext(); - if ($this->lexer->isNextToken(EmailLexer::S_DOT)) { - throw new ExpectingATEXT(); - } - } - - protected function addTLDWarnings() - { - if ($this->warnings[DomainLiteral::CODE]) { - $this->warnings[TLD::CODE] = new TLD(); - } - } + const DOMAIN_MAX_LENGTH = 254; + const LABEL_MAX_LENGTH = 63; + + /** + * @var string + */ + protected $domainPart = ''; + + public function parse($domainPart) + { + $this->lexer->moveNext(); + + $this->performDomainStartChecks(); + + $domain = $this->doParseDomainPart(); + + $prev = $this->lexer->getPrevious(); + $length = strlen($domain); + + if ($prev['type'] === EmailLexer::S_DOT) { + throw new DotAtEnd(); + } + if ($prev['type'] === EmailLexer::S_HYPHEN) { + throw new DomainHyphened(); + } + if ($length > self::DOMAIN_MAX_LENGTH) { + $this->warnings[DomainTooLong::CODE] = new DomainTooLong(); + } + if ($prev['type'] === EmailLexer::S_CR) { + throw new CRLFAtTheEnd(); + } + $this->domainPart = $domain; + } + + private function performDomainStartChecks() + { + $this->checkInvalidTokensAfterAT(); + $this->checkEmptyDomain(); + + if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) { + $this->warnings[DeprecatedComment::CODE] = new DeprecatedComment(); + $this->parseDomainComments(); + } + } + + private function checkEmptyDomain() + { + $thereIsNoDomain = $this->lexer->token['type'] === EmailLexer::S_EMPTY || + ($this->lexer->token['type'] === EmailLexer::S_SP && + !$this->lexer->isNextToken(EmailLexer::GENERIC)); + + if ($thereIsNoDomain) { + throw new NoDomainPart(); + } + } + + private function checkInvalidTokensAfterAT() + { + if ($this->lexer->token['type'] === EmailLexer::S_DOT) { + throw new DotAtStart(); + } + if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN) { + throw new DomainHyphened(); + } + } + + /** + * @return string + */ + public function getDomainPart() + { + return $this->domainPart; + } + + /** + * @param string $addressLiteral + * @param int $maxGroups + */ + public function checkIPV6Tag($addressLiteral, $maxGroups = 8) + { + $prev = $this->lexer->getPrevious(); + if ($prev['type'] === EmailLexer::S_COLON) { + $this->warnings[IPV6ColonEnd::CODE] = new IPV6ColonEnd(); + } + + $IPv6 = substr($addressLiteral, 5); + //Daniel Marschall's new IPv6 testing strategy + $matchesIP = explode(':', $IPv6); + $groupCount = count($matchesIP); + $colons = strpos($IPv6, '::'); + + if (count(preg_grep('/^[0-9A-Fa-f]{0,4}$/', $matchesIP, PREG_GREP_INVERT)) !== 0) { + $this->warnings[IPV6BadChar::CODE] = new IPV6BadChar(); + } + + if ($colons === false) { + // We need exactly the right number of groups + if ($groupCount !== $maxGroups) { + $this->warnings[IPV6GroupCount::CODE] = new IPV6GroupCount(); + } + return; + } + + if ($colons !== strrpos($IPv6, '::')) { + $this->warnings[IPV6DoubleColon::CODE] = new IPV6DoubleColon(); + return; + } + + if ($colons === 0 || $colons === (strlen($IPv6) - 2)) { + // RFC 4291 allows :: at the start or end of an address + //with 7 other groups in addition + ++$maxGroups; + } + + if ($groupCount > $maxGroups) { + $this->warnings[IPV6MaxGroups::CODE] = new IPV6MaxGroups(); + } elseif ($groupCount === $maxGroups) { + $this->warnings[IPV6Deprecated::CODE] = new IPV6Deprecated(); + } + } + + /** + * @return string + */ + protected function doParseDomainPart() + { + $domain = ''; + $label = ''; + $openedParenthesis = 0; + do { + $prev = $this->lexer->getPrevious(); + + $this->checkNotAllowedChars($this->lexer->token); + + if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) { + $this->parseComments(); + $openedParenthesis += $this->getOpenedParenthesis(); + $this->lexer->moveNext(); + $tmpPrev = $this->lexer->getPrevious(); + if ($tmpPrev['type'] === EmailLexer::S_CLOSEPARENTHESIS) { + $openedParenthesis--; + } + } + if ($this->lexer->token['type'] === EmailLexer::S_CLOSEPARENTHESIS) { + if ($openedParenthesis === 0) { + throw new UnopenedComment(); + } else { + $openedParenthesis--; + } + } + + $this->checkConsecutiveDots(); + $this->checkDomainPartExceptions($prev); + + if ($this->hasBrackets()) { + $this->parseDomainLiteral(); + } + + if ($this->lexer->token['type'] === EmailLexer::S_DOT) { + $this->checkLabelLength($label); + $label = ''; + } else { + $label .= $this->lexer->token['value']; + } + + if ($this->isFWS()) { + $this->parseFWS(); + } + + $domain .= $this->lexer->token['value']; + $this->lexer->moveNext(); + if ($this->lexer->token['type'] === EmailLexer::S_SP) { + throw new CharNotAllowed(); + } + } while (null !== $this->lexer->token['type']); + + $this->checkLabelLength($label); + + return $domain; + } + + private function checkNotAllowedChars(array $token) + { + $notAllowed = [EmailLexer::S_BACKSLASH => true, EmailLexer::S_SLASH=> true]; + if (isset($notAllowed[$token['type']])) { + throw new CharNotAllowed(); + } + } + + /** + * @return string|false + */ + protected function parseDomainLiteral() + { + if ($this->lexer->isNextToken(EmailLexer::S_COLON)) { + $this->warnings[IPV6ColonStart::CODE] = new IPV6ColonStart(); + } + if ($this->lexer->isNextToken(EmailLexer::S_IPV6TAG)) { + $lexer = clone $this->lexer; + $lexer->moveNext(); + if ($lexer->isNextToken(EmailLexer::S_DOUBLECOLON)) { + $this->warnings[IPV6ColonStart::CODE] = new IPV6ColonStart(); + } + } + + return $this->doParseDomainLiteral(); + } + + /** + * @return string|false + */ + protected function doParseDomainLiteral() + { + $IPv6TAG = false; + $addressLiteral = ''; + do { + if ($this->lexer->token['type'] === EmailLexer::C_NUL) { + throw new ExpectingDTEXT(); + } + + if ($this->lexer->token['type'] === EmailLexer::INVALID || + $this->lexer->token['type'] === EmailLexer::C_DEL || + $this->lexer->token['type'] === EmailLexer::S_LF + ) { + $this->warnings[ObsoleteDTEXT::CODE] = new ObsoleteDTEXT(); + } + + if ($this->lexer->isNextTokenAny(array(EmailLexer::S_OPENQBRACKET, EmailLexer::S_OPENBRACKET))) { + throw new ExpectingDTEXT(); + } + + if ($this->lexer->isNextTokenAny( + array(EmailLexer::S_HTAB, EmailLexer::S_SP, $this->lexer->token['type'] === EmailLexer::CRLF) + )) { + $this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS(); + $this->parseFWS(); + } + + if ($this->lexer->isNextToken(EmailLexer::S_CR)) { + throw new CRNoLF(); + } + + if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH) { + $this->warnings[ObsoleteDTEXT::CODE] = new ObsoleteDTEXT(); + $addressLiteral .= $this->lexer->token['value']; + $this->lexer->moveNext(); + $this->validateQuotedPair(); + } + if ($this->lexer->token['type'] === EmailLexer::S_IPV6TAG) { + $IPv6TAG = true; + } + if ($this->lexer->token['type'] === EmailLexer::S_CLOSEQBRACKET) { + break; + } + + $addressLiteral .= $this->lexer->token['value']; + } while ($this->lexer->moveNext()); + + $addressLiteral = str_replace('[', '', $addressLiteral); + $addressLiteral = $this->checkIPV4Tag($addressLiteral); + + if (false === $addressLiteral) { + return $addressLiteral; + } + + if (!$IPv6TAG) { + $this->warnings[DomainLiteral::CODE] = new DomainLiteral(); + return $addressLiteral; + } + + $this->warnings[AddressLiteral::CODE] = new AddressLiteral(); + + $this->checkIPV6Tag($addressLiteral); + + return $addressLiteral; + } + + /** + * @param string $addressLiteral + * + * @return string|false + */ + protected function checkIPV4Tag($addressLiteral) + { + $matchesIP = array(); + + // Extract IPv4 part from the end of the address-literal (if there is one) + if (preg_match( + '/\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/', + $addressLiteral, + $matchesIP + ) > 0 + ) { + $index = strrpos($addressLiteral, $matchesIP[0]); + if ($index === 0) { + $this->warnings[AddressLiteral::CODE] = new AddressLiteral(); + return false; + } + // Convert IPv4 part to IPv6 format for further testing + $addressLiteral = substr($addressLiteral, 0, (int) $index) . '0:0'; + } + + return $addressLiteral; + } + + protected function checkDomainPartExceptions(array $prev) + { + $invalidDomainTokens = array( + EmailLexer::S_DQUOTE => true, + EmailLexer::S_SQUOTE => true, + EmailLexer::S_BACKTICK => true, + EmailLexer::S_SEMICOLON => true, + EmailLexer::S_GREATERTHAN => true, + EmailLexer::S_LOWERTHAN => true, + ); + + if (isset($invalidDomainTokens[$this->lexer->token['type']])) { + throw new ExpectingATEXT(); + } + + if ($this->lexer->token['type'] === EmailLexer::S_COMMA) { + throw new CommaInDomain(); + } + + if ($this->lexer->token['type'] === EmailLexer::S_AT) { + throw new ConsecutiveAt(); + } + + if ($this->lexer->token['type'] === EmailLexer::S_OPENQBRACKET && $prev['type'] !== EmailLexer::S_AT) { + throw new ExpectingATEXT(); + } + + if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN && $this->lexer->isNextToken(EmailLexer::S_DOT)) { + throw new DomainHyphened(); + } + + if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH + && $this->lexer->isNextToken(EmailLexer::GENERIC)) { + throw new ExpectingATEXT(); + } + } + + /** + * @return bool + */ + protected function hasBrackets() + { + if ($this->lexer->token['type'] !== EmailLexer::S_OPENBRACKET) { + return false; + } + + try { + $this->lexer->find(EmailLexer::S_CLOSEBRACKET); + } catch (\RuntimeException $e) { + throw new ExpectingDomainLiteralClose(); + } + + return true; + } + + /** + * @param string $label + */ + protected function checkLabelLength($label) + { + if ($this->isLabelTooLong($label)) { + $this->warnings[LabelTooLong::CODE] = new LabelTooLong(); + } + } + + /** + * @param string $label + * @return bool + */ + private function isLabelTooLong($label) + { + if (preg_match('/[^\x00-\x7F]/', $label)) { + idn_to_ascii($label, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46, $idnaInfo); + + return (bool) ($idnaInfo['errors'] & IDNA_ERROR_LABEL_TOO_LONG); + } + + return strlen($label) > self::LABEL_MAX_LENGTH; + } + + protected function parseDomainComments() + { + $this->isUnclosedComment(); + while (!$this->lexer->isNextToken(EmailLexer::S_CLOSEPARENTHESIS)) { + $this->warnEscaping(); + $this->lexer->moveNext(); + } + + $this->lexer->moveNext(); + if ($this->lexer->isNextToken(EmailLexer::S_DOT)) { + throw new ExpectingATEXT(); + } + } + + protected function addTLDWarnings() + { + if ($this->warnings[DomainLiteral::CODE]) { + $this->warnings[TLD::CODE] = new TLD(); + } + } } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Parser/LocalPart.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Parser/LocalPart.php index 3c21f34ac07..b804b412863 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Parser/LocalPart.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Parser/LocalPart.php @@ -14,132 +14,132 @@ use Egulias\EmailValidator\Warning\LocalTooLong; class LocalPart extends Parser { - public function parse($localPart) - { - $parseDQuote = true; - $closingQuote = false; - $openedParenthesis = 0; - $totalLength = 0; + public function parse($localPart) + { + $parseDQuote = true; + $closingQuote = false; + $openedParenthesis = 0; + $totalLength = 0; - while ($this->lexer->token['type'] !== EmailLexer::S_AT && null !== $this->lexer->token['type']) { - if ($this->lexer->token['type'] === EmailLexer::S_DOT && null === $this->lexer->getPrevious()['type']) { - throw new DotAtStart(); - } + while ($this->lexer->token['type'] !== EmailLexer::S_AT && null !== $this->lexer->token['type']) { + if ($this->lexer->token['type'] === EmailLexer::S_DOT && null === $this->lexer->getPrevious()['type']) { + throw new DotAtStart(); + } - $closingQuote = $this->checkDQUOTE($closingQuote); - if ($closingQuote && $parseDQuote) { - $parseDQuote = $this->parseDoubleQuote(); - } + $closingQuote = $this->checkDQUOTE($closingQuote); + if ($closingQuote && $parseDQuote) { + $parseDQuote = $this->parseDoubleQuote(); + } - if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) { - $this->parseComments(); - $openedParenthesis += $this->getOpenedParenthesis(); - } + if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) { + $this->parseComments(); + $openedParenthesis += $this->getOpenedParenthesis(); + } - if ($this->lexer->token['type'] === EmailLexer::S_CLOSEPARENTHESIS) { - if ($openedParenthesis === 0) { - throw new UnopenedComment(); - } + if ($this->lexer->token['type'] === EmailLexer::S_CLOSEPARENTHESIS) { + if ($openedParenthesis === 0) { + throw new UnopenedComment(); + } - $openedParenthesis--; - } + $openedParenthesis--; + } - $this->checkConsecutiveDots(); + $this->checkConsecutiveDots(); - if ($this->lexer->token['type'] === EmailLexer::S_DOT && - $this->lexer->isNextToken(EmailLexer::S_AT) - ) { - throw new DotAtEnd(); - } + if ($this->lexer->token['type'] === EmailLexer::S_DOT && + $this->lexer->isNextToken(EmailLexer::S_AT) + ) { + throw new DotAtEnd(); + } - $this->warnEscaping(); - $this->isInvalidToken($this->lexer->token, $closingQuote); + $this->warnEscaping(); + $this->isInvalidToken($this->lexer->token, $closingQuote); - if ($this->isFWS()) { - $this->parseFWS(); - } + if ($this->isFWS()) { + $this->parseFWS(); + } - $totalLength += strlen($this->lexer->token['value']); - $this->lexer->moveNext(); - } + $totalLength += strlen($this->lexer->token['value']); + $this->lexer->moveNext(); + } - if ($totalLength > LocalTooLong::LOCAL_PART_LENGTH) { - $this->warnings[LocalTooLong::CODE] = new LocalTooLong(); - } - } + if ($totalLength > LocalTooLong::LOCAL_PART_LENGTH) { + $this->warnings[LocalTooLong::CODE] = new LocalTooLong(); + } + } - /** - * @return bool - */ - protected function parseDoubleQuote() - { - $parseAgain = true; - $special = array( - EmailLexer::S_CR => true, - EmailLexer::S_HTAB => true, - EmailLexer::S_LF => true - ); + /** + * @return bool + */ + protected function parseDoubleQuote() + { + $parseAgain = true; + $special = array( + EmailLexer::S_CR => true, + EmailLexer::S_HTAB => true, + EmailLexer::S_LF => true + ); - $invalid = array( - EmailLexer::C_NUL => true, - EmailLexer::S_HTAB => true, - EmailLexer::S_CR => true, - EmailLexer::S_LF => true - ); - $setSpecialsWarning = true; + $invalid = array( + EmailLexer::C_NUL => true, + EmailLexer::S_HTAB => true, + EmailLexer::S_CR => true, + EmailLexer::S_LF => true + ); + $setSpecialsWarning = true; - $this->lexer->moveNext(); + $this->lexer->moveNext(); - while ($this->lexer->token['type'] !== EmailLexer::S_DQUOTE && null !== $this->lexer->token['type']) { - $parseAgain = false; - if (isset($special[$this->lexer->token['type']]) && $setSpecialsWarning) { - $this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS(); - $setSpecialsWarning = false; - } - if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH && $this->lexer->isNextToken(EmailLexer::S_DQUOTE)) { - $this->lexer->moveNext(); - } + while ($this->lexer->token['type'] !== EmailLexer::S_DQUOTE && null !== $this->lexer->token['type']) { + $parseAgain = false; + if (isset($special[$this->lexer->token['type']]) && $setSpecialsWarning) { + $this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS(); + $setSpecialsWarning = false; + } + if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH && $this->lexer->isNextToken(EmailLexer::S_DQUOTE)) { + $this->lexer->moveNext(); + } - $this->lexer->moveNext(); + $this->lexer->moveNext(); - if (!$this->escaped() && isset($invalid[$this->lexer->token['type']])) { - throw new ExpectingATEXT(); - } - } + if (!$this->escaped() && isset($invalid[$this->lexer->token['type']])) { + throw new ExpectingATEXT(); + } + } - $prev = $this->lexer->getPrevious(); + $prev = $this->lexer->getPrevious(); - if ($prev['type'] === EmailLexer::S_BACKSLASH) { - if (!$this->checkDQUOTE(false)) { - throw new UnclosedQuotedString(); - } - } + if ($prev['type'] === EmailLexer::S_BACKSLASH) { + if (!$this->checkDQUOTE(false)) { + throw new UnclosedQuotedString(); + } + } - if (!$this->lexer->isNextToken(EmailLexer::S_AT) && $prev['type'] !== EmailLexer::S_BACKSLASH) { - throw new ExpectingAT(); - } + if (!$this->lexer->isNextToken(EmailLexer::S_AT) && $prev['type'] !== EmailLexer::S_BACKSLASH) { + throw new ExpectingAT(); + } - return $parseAgain; - } + return $parseAgain; + } - /** - * @param bool $closingQuote - */ - protected function isInvalidToken(array $token, $closingQuote) - { - $forbidden = array( - EmailLexer::S_COMMA, - EmailLexer::S_CLOSEBRACKET, - EmailLexer::S_OPENBRACKET, - EmailLexer::S_GREATERTHAN, - EmailLexer::S_LOWERTHAN, - EmailLexer::S_COLON, - EmailLexer::S_SEMICOLON, - EmailLexer::INVALID - ); + /** + * @param bool $closingQuote + */ + protected function isInvalidToken(array $token, $closingQuote) + { + $forbidden = array( + EmailLexer::S_COMMA, + EmailLexer::S_CLOSEBRACKET, + EmailLexer::S_OPENBRACKET, + EmailLexer::S_GREATERTHAN, + EmailLexer::S_LOWERTHAN, + EmailLexer::S_COLON, + EmailLexer::S_SEMICOLON, + EmailLexer::INVALID + ); - if (in_array($token['type'], $forbidden) && !$closingQuote) { - throw new ExpectingATEXT(); - } - } + if (in_array($token['type'], $forbidden) && !$closingQuote) { + throw new ExpectingATEXT(); + } + } } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Parser/Parser.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Parser/Parser.php index ccdc93889a2..9ebb95ae0a0 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Parser/Parser.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Parser/Parser.php @@ -21,229 +21,228 @@ use Egulias\EmailValidator\Warning\QuotedString; abstract class Parser { - /** - * @var array - */ - protected $warnings = []; + /** + * @var array + */ + protected $warnings = []; - /** - * @var EmailLexer - */ - protected $lexer; + /** + * @var EmailLexer + */ + protected $lexer; - /** - * @var int - */ - protected $openedParenthesis = 0; + /** + * @var int + */ + protected $openedParenthesis = 0; - public function __construct(EmailLexer $lexer) - { - $this->lexer = $lexer; - } + public function __construct(EmailLexer $lexer) + { + $this->lexer = $lexer; + } - /** - * @return \Egulias\EmailValidator\Warning\Warning[] - */ - public function getWarnings() - { - return $this->warnings; - } + /** + * @return \Egulias\EmailValidator\Warning\Warning[] + */ + public function getWarnings() + { + return $this->warnings; + } - /** - * @param string $str - */ - abstract public function parse($str); + /** + * @param string $str + */ + abstract public function parse($str); - /** @return int */ - public function getOpenedParenthesis() - { - return $this->openedParenthesis; - } + /** @return int */ + public function getOpenedParenthesis() + { + return $this->openedParenthesis; + } - /** - * validateQuotedPair - */ - protected function validateQuotedPair() - { - if (!($this->lexer->token['type'] === EmailLexer::INVALID - || $this->lexer->token['type'] === EmailLexer::C_DEL)) { - throw new ExpectingQPair(); - } + /** + * validateQuotedPair + */ + protected function validateQuotedPair() + { + if (!($this->lexer->token['type'] === EmailLexer::INVALID + || $this->lexer->token['type'] === EmailLexer::C_DEL)) { + throw new ExpectingQPair(); + } - $this->warnings[QuotedPart::CODE] = - new QuotedPart($this->lexer->getPrevious()['type'], $this->lexer->token['type']); - } + $this->warnings[QuotedPart::CODE] = + new QuotedPart($this->lexer->getPrevious()['type'], $this->lexer->token['type']); + } - protected function parseComments() - { - $this->openedParenthesis = 1; - $this->isUnclosedComment(); - $this->warnings[Comment::CODE] = new Comment(); - while (!$this->lexer->isNextToken(EmailLexer::S_CLOSEPARENTHESIS)) { - if ($this->lexer->isNextToken(EmailLexer::S_OPENPARENTHESIS)) { - $this->openedParenthesis++; - } - $this->warnEscaping(); - $this->lexer->moveNext(); - } + protected function parseComments() + { + $this->openedParenthesis = 1; + $this->isUnclosedComment(); + $this->warnings[Comment::CODE] = new Comment(); + while (!$this->lexer->isNextToken(EmailLexer::S_CLOSEPARENTHESIS)) { + if ($this->lexer->isNextToken(EmailLexer::S_OPENPARENTHESIS)) { + $this->openedParenthesis++; + } + $this->warnEscaping(); + $this->lexer->moveNext(); + } - $this->lexer->moveNext(); - if ($this->lexer->isNextTokenAny(array(EmailLexer::GENERIC, EmailLexer::S_EMPTY))) { - throw new ExpectingATEXT(); - } + $this->lexer->moveNext(); + if ($this->lexer->isNextTokenAny(array(EmailLexer::GENERIC, EmailLexer::S_EMPTY))) { + throw new ExpectingATEXT(); + } - if ($this->lexer->isNextToken(EmailLexer::S_AT)) { - $this->warnings[CFWSNearAt::CODE] = new CFWSNearAt(); - } - } + if ($this->lexer->isNextToken(EmailLexer::S_AT)) { + $this->warnings[CFWSNearAt::CODE] = new CFWSNearAt(); + } + } - /** - * @return bool - */ - protected function isUnclosedComment() - { - try { - $this->lexer->find(EmailLexer::S_CLOSEPARENTHESIS); - return true; - } catch (\RuntimeException $e) { - throw new UnclosedComment(); - } - } + /** + * @return bool + */ + protected function isUnclosedComment() + { + try { + $this->lexer->find(EmailLexer::S_CLOSEPARENTHESIS); + return true; + } catch (\RuntimeException $e) { + throw new UnclosedComment(); + } + } - protected function parseFWS() - { - $previous = $this->lexer->getPrevious(); + protected function parseFWS() + { + $previous = $this->lexer->getPrevious(); - $this->checkCRLFInFWS(); + $this->checkCRLFInFWS(); - if ($this->lexer->token['type'] === EmailLexer::S_CR) { - throw new CRNoLF(); - } + if ($this->lexer->token['type'] === EmailLexer::S_CR) { + throw new CRNoLF(); + } - if ($this->lexer->isNextToken(EmailLexer::GENERIC) && $previous['type'] !== EmailLexer::S_AT) { - throw new AtextAfterCFWS(); - } + if ($this->lexer->isNextToken(EmailLexer::GENERIC) && $previous['type'] !== EmailLexer::S_AT) { + throw new AtextAfterCFWS(); + } - if ($this->lexer->token['type'] === EmailLexer::S_LF || $this->lexer->token['type'] === EmailLexer::C_NUL) { - throw new ExpectingCTEXT(); - } + if ($this->lexer->token['type'] === EmailLexer::S_LF || $this->lexer->token['type'] === EmailLexer::C_NUL) { + throw new ExpectingCTEXT(); + } - if ($this->lexer->isNextToken(EmailLexer::S_AT) || $previous['type'] === EmailLexer::S_AT) { - $this->warnings[CFWSNearAt::CODE] = new CFWSNearAt(); - } else { - $this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS(); - } - } + if ($this->lexer->isNextToken(EmailLexer::S_AT) || $previous['type'] === EmailLexer::S_AT) { + $this->warnings[CFWSNearAt::CODE] = new CFWSNearAt(); + } else { + $this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS(); + } + } - protected function checkConsecutiveDots() - { - if ($this->lexer->token['type'] === EmailLexer::S_DOT && $this->lexer->isNextToken(EmailLexer::S_DOT)) { - throw new ConsecutiveDot(); - } - } + protected function checkConsecutiveDots() + { + if ($this->lexer->token['type'] === EmailLexer::S_DOT && $this->lexer->isNextToken(EmailLexer::S_DOT)) { + throw new ConsecutiveDot(); + } + } - /** - * @return bool - */ - protected function isFWS() - { - if ($this->escaped()) { - return false; - } + /** + * @return bool + */ + protected function isFWS() + { + if ($this->escaped()) { + return false; + } - if ($this->lexer->token['type'] === EmailLexer::S_SP || - $this->lexer->token['type'] === EmailLexer::S_HTAB || - $this->lexer->token['type'] === EmailLexer::S_CR || - $this->lexer->token['type'] === EmailLexer::S_LF || - $this->lexer->token['type'] === EmailLexer::CRLF - ) { - return true; - } + if ($this->lexer->token['type'] === EmailLexer::S_SP || + $this->lexer->token['type'] === EmailLexer::S_HTAB || + $this->lexer->token['type'] === EmailLexer::S_CR || + $this->lexer->token['type'] === EmailLexer::S_LF || + $this->lexer->token['type'] === EmailLexer::CRLF + ) { + return true; + } - return false; - } + return false; + } - /** - * @return bool - */ - protected function escaped() - { - $previous = $this->lexer->getPrevious(); + /** + * @return bool + */ + protected function escaped() + { + $previous = $this->lexer->getPrevious(); - if ($previous && $previous['type'] === EmailLexer::S_BACKSLASH - && - $this->lexer->token['type'] !== EmailLexer::GENERIC - ) { - return true; - } + if ($previous && $previous['type'] === EmailLexer::S_BACKSLASH + && + $this->lexer->token['type'] !== EmailLexer::GENERIC + ) { + return true; + } - return false; - } + return false; + } - /** - * @return bool - */ - protected function warnEscaping() - { - if ($this->lexer->token['type'] !== EmailLexer::S_BACKSLASH) { - return false; - } + /** + * @return bool + */ + protected function warnEscaping() + { + if ($this->lexer->token['type'] !== EmailLexer::S_BACKSLASH) { + return false; + } - if ($this->lexer->isNextToken(EmailLexer::GENERIC)) { - throw new ExpectingATEXT(); - } + if ($this->lexer->isNextToken(EmailLexer::GENERIC)) { + throw new ExpectingATEXT(); + } - if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB, EmailLexer::C_DEL))) { - return false; - } + if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB, EmailLexer::C_DEL))) { + return false; + } - $this->warnings[QuotedPart::CODE] = - new QuotedPart($this->lexer->getPrevious()['type'], $this->lexer->token['type']); - return true; + $this->warnings[QuotedPart::CODE] = + new QuotedPart($this->lexer->getPrevious()['type'], $this->lexer->token['type']); + return true; + } - } + /** + * @param bool $hasClosingQuote + * + * @return bool + */ + protected function checkDQUOTE($hasClosingQuote) + { + if ($this->lexer->token['type'] !== EmailLexer::S_DQUOTE) { + return $hasClosingQuote; + } + if ($hasClosingQuote) { + return $hasClosingQuote; + } + $previous = $this->lexer->getPrevious(); + if ($this->lexer->isNextToken(EmailLexer::GENERIC) && $previous['type'] === EmailLexer::GENERIC) { + throw new ExpectingATEXT(); + } - /** - * @param bool $hasClosingQuote - * - * @return bool - */ - protected function checkDQUOTE($hasClosingQuote) - { - if ($this->lexer->token['type'] !== EmailLexer::S_DQUOTE) { - return $hasClosingQuote; - } - if ($hasClosingQuote) { - return $hasClosingQuote; - } - $previous = $this->lexer->getPrevious(); - if ($this->lexer->isNextToken(EmailLexer::GENERIC) && $previous['type'] === EmailLexer::GENERIC) { - throw new ExpectingATEXT(); - } + try { + $this->lexer->find(EmailLexer::S_DQUOTE); + $hasClosingQuote = true; + } catch (\Exception $e) { + throw new UnclosedQuotedString(); + } + $this->warnings[QuotedString::CODE] = new QuotedString($previous['value'], $this->lexer->token['value']); - try { - $this->lexer->find(EmailLexer::S_DQUOTE); - $hasClosingQuote = true; - } catch (\Exception $e) { - throw new UnclosedQuotedString(); - } - $this->warnings[QuotedString::CODE] = new QuotedString($previous['value'], $this->lexer->token['value']); + return $hasClosingQuote; + } - return $hasClosingQuote; - } + protected function checkCRLFInFWS() + { + if ($this->lexer->token['type'] !== EmailLexer::CRLF) { + return; + } - protected function checkCRLFInFWS() - { - if ($this->lexer->token['type'] !== EmailLexer::CRLF) { - return; - } + if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB))) { + throw new CRLFX2(); + } - if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB))) { - throw new CRLFX2(); - } - - if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB))) { - throw new CRLFAtTheEnd(); - } - } + if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB))) { + throw new CRLFAtTheEnd(); + } + } } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/DNSCheckValidation.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/DNSCheckValidation.php index 491082a590f..0d02f11a0a6 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/DNSCheckValidation.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/DNSCheckValidation.php @@ -11,156 +11,156 @@ use Egulias\EmailValidator\Exception\NoDNSRecord; class DNSCheckValidation implements EmailValidation { - /** - * @var array - */ - private $warnings = []; + /** + * @var array + */ + private $warnings = []; - /** - * @var InvalidEmail|null - */ - private $error; + /** + * @var InvalidEmail|null + */ + private $error; - /** - * @var array - */ - private $mxRecords = []; + /** + * @var array + */ + private $mxRecords = []; - public function __construct() - { - if (!function_exists('idn_to_ascii')) { - throw new \LogicException(sprintf('The %s class requires the Intl extension.', __CLASS__)); - } - } + public function __construct() + { + if (!function_exists('idn_to_ascii')) { + throw new \LogicException(sprintf('The %s class requires the Intl extension.', __CLASS__)); + } + } - public function isValid($email, EmailLexer $emailLexer) - { - // use the input to check DNS if we cannot extract something similar to a domain - $host = $email; + public function isValid($email, EmailLexer $emailLexer) + { + // use the input to check DNS if we cannot extract something similar to a domain + $host = $email; - // Arguable pattern to extract the domain. Not aiming to validate the domain nor the email - if (false !== $lastAtPos = strrpos($email, '@')) { - $host = substr($email, $lastAtPos + 1); - } + // Arguable pattern to extract the domain. Not aiming to validate the domain nor the email + if (false !== $lastAtPos = strrpos($email, '@')) { + $host = substr($email, $lastAtPos + 1); + } - // Get the domain parts - $hostParts = explode('.', $host); + // Get the domain parts + $hostParts = explode('.', $host); - // Reserved Top Level DNS Names (https://tools.ietf.org/html/rfc2606#section-2), - // mDNS and private DNS Namespaces (https://tools.ietf.org/html/rfc6762#appendix-G) - $reservedTopLevelDnsNames = [ - // Reserved Top Level DNS Names - 'test', - 'example', - 'invalid', - 'localhost', + // Reserved Top Level DNS Names (https://tools.ietf.org/html/rfc2606#section-2), + // mDNS and private DNS Namespaces (https://tools.ietf.org/html/rfc6762#appendix-G) + $reservedTopLevelDnsNames = [ + // Reserved Top Level DNS Names + 'test', + 'example', + 'invalid', + 'localhost', - // mDNS - 'local', + // mDNS + 'local', - // Private DNS Namespaces - 'intranet', - 'internal', - 'private', - 'corp', - 'home', - 'lan', - ]; + // Private DNS Namespaces + 'intranet', + 'internal', + 'private', + 'corp', + 'home', + 'lan', + ]; - $isLocalDomain = count($hostParts) <= 1; - $isReservedTopLevel = in_array($hostParts[(count($hostParts) - 1)], $reservedTopLevelDnsNames, true); + $isLocalDomain = count($hostParts) <= 1; + $isReservedTopLevel = in_array($hostParts[(count($hostParts) - 1)], $reservedTopLevelDnsNames, true); - // Exclude reserved top level DNS names - if ($isLocalDomain || $isReservedTopLevel) { - $this->error = new LocalOrReservedDomain(); - return false; - } + // Exclude reserved top level DNS names + if ($isLocalDomain || $isReservedTopLevel) { + $this->error = new LocalOrReservedDomain(); + return false; + } - return $this->checkDns($host); - } + return $this->checkDns($host); + } - public function getError() - { - return $this->error; - } + public function getError() + { + return $this->error; + } - public function getWarnings() - { - return $this->warnings; - } + public function getWarnings() + { + return $this->warnings; + } - /** - * @param string $host - * - * @return bool - */ - protected function checkDns($host) - { - $variant = INTL_IDNA_VARIANT_UTS46; + /** + * @param string $host + * + * @return bool + */ + protected function checkDns($host) + { + $variant = INTL_IDNA_VARIANT_UTS46; - $host = rtrim(idn_to_ascii($host, IDNA_DEFAULT, $variant), '.') . '.'; + $host = rtrim(idn_to_ascii($host, IDNA_DEFAULT, $variant), '.') . '.'; - return $this->validateDnsRecords($host); - } + return $this->validateDnsRecords($host); + } - /** - * Validate the DNS records for given host. - * - * @param string $host A set of DNS records in the format returned by dns_get_record. - * - * @return bool True on success. - */ - private function validateDnsRecords($host) - { - // Get all MX, A and AAAA DNS records for host - // Using @ as workaround to fix https://bugs.php.net/bug.php?id=73149 - $dnsRecords = @dns_get_record($host, DNS_MX + DNS_A + DNS_AAAA); + /** + * Validate the DNS records for given host. + * + * @param string $host A set of DNS records in the format returned by dns_get_record. + * + * @return bool True on success. + */ + private function validateDnsRecords($host) + { + // Get all MX, A and AAAA DNS records for host + // Using @ as workaround to fix https://bugs.php.net/bug.php?id=73149 + $dnsRecords = @dns_get_record($host, DNS_MX + DNS_A + DNS_AAAA); - // No MX, A or AAAA DNS records - if (empty($dnsRecords)) { - $this->error = new NoDNSRecord(); - return false; - } + // No MX, A or AAAA DNS records + if (empty($dnsRecords)) { + $this->error = new NoDNSRecord(); + return false; + } - // For each DNS record - foreach ($dnsRecords as $dnsRecord) { - if (!$this->validateMXRecord($dnsRecord)) { - return false; - } - } + // For each DNS record + foreach ($dnsRecords as $dnsRecord) { + if (!$this->validateMXRecord($dnsRecord)) { + return false; + } + } - // No MX records (fallback to A or AAAA records) - if (empty($this->mxRecords)) { - $this->warnings[NoDNSMXRecord::CODE] = new NoDNSMXRecord(); - } + // No MX records (fallback to A or AAAA records) + if (empty($this->mxRecords)) { + $this->warnings[NoDNSMXRecord::CODE] = new NoDNSMXRecord(); + } - return true; - } + return true; + } - /** - * Validate an MX record - * - * @param array $dnsRecord Given DNS record. - * - * @return bool True if valid. - */ - private function validateMxRecord($dnsRecord) - { - if ($dnsRecord['type'] !== 'MX') { - return true; - } + /** + * Validate an MX record + * + * @param array $dnsRecord Given DNS record. + * + * @return bool True if valid. + */ + private function validateMxRecord($dnsRecord) + { + if ($dnsRecord['type'] !== 'MX') { + return true; + } - // "Null MX" record indicates the domain accepts no mail (https://tools.ietf.org/html/rfc7505) - if (empty($dnsRecord['target']) || $dnsRecord['target'] === '.') { - $this->error = new DomainAcceptsNoMail(); - return false; - } + // "Null MX" record indicates the domain accepts no mail (https://tools.ietf.org/html/rfc7505) + if (empty($dnsRecord['target']) || $dnsRecord['target'] === '.') { + $this->error = new DomainAcceptsNoMail(); + return false; + } - $this->mxRecords[] = $dnsRecord; + $this->mxRecords[] = $dnsRecord; - return true; - } + return true; + } } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/Exception/EmptyValidationList.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/Exception/EmptyValidationList.php index ee7c41aa033..98d0d12a6d1 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/Exception/EmptyValidationList.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/Exception/EmptyValidationList.php @@ -6,11 +6,11 @@ use Exception; class EmptyValidationList extends \InvalidArgumentException { - /** - * @param int $code - */ - public function __construct($code = 0, Exception $previous = null) - { - parent::__construct("Empty validation list is not allowed", $code, $previous); - } + /** + * @param int $code + */ + public function __construct($code = 0, Exception $previous = null) + { + parent::__construct("Empty validation list is not allowed", $code, $previous); + } } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/MultipleErrors.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/MultipleErrors.php index 3be59732664..cd10ec7aaf8 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/MultipleErrors.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/MultipleErrors.php @@ -6,27 +6,27 @@ use Egulias\EmailValidator\Exception\InvalidEmail; class MultipleErrors extends InvalidEmail { - const CODE = 999; - const REASON = "Accumulated errors for multiple validations"; - /** - * @var InvalidEmail[] - */ - private $errors = []; + const CODE = 999; + const REASON = "Accumulated errors for multiple validations"; + /** + * @var InvalidEmail[] + */ + private $errors = []; - /** - * @param InvalidEmail[] $errors - */ - public function __construct(array $errors) - { - $this->errors = $errors; - parent::__construct(); - } + /** + * @param InvalidEmail[] $errors + */ + public function __construct(array $errors) + { + $this->errors = $errors; + parent::__construct(); + } - /** - * @return InvalidEmail[] - */ - public function getErrors() - { - return $this->errors; - } + /** + * @return InvalidEmail[] + */ + public function getErrors() + { + return $this->errors; + } } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/MultipleValidationWithAnd.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/MultipleValidationWithAnd.php index feb224023da..55aad31459b 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/MultipleValidationWithAnd.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/MultipleValidationWithAnd.php @@ -7,118 +7,118 @@ use Egulias\EmailValidator\Validation\Exception\EmptyValidationList; class MultipleValidationWithAnd implements EmailValidation { - /** - * If one of validations gets failure skips all succeeding validation. - * This means MultipleErrors will only contain a single error which first found. - */ - const STOP_ON_ERROR = 0; + /** + * If one of validations gets failure skips all succeeding validation. + * This means MultipleErrors will only contain a single error which first found. + */ + const STOP_ON_ERROR = 0; - /** - * All of validations will be invoked even if one of them got failure. - * So MultipleErrors will contain all causes. - */ - const ALLOW_ALL_ERRORS = 1; + /** + * All of validations will be invoked even if one of them got failure. + * So MultipleErrors will contain all causes. + */ + const ALLOW_ALL_ERRORS = 1; - /** - * @var EmailValidation[] - */ - private $validations = []; + /** + * @var EmailValidation[] + */ + private $validations = []; - /** - * @var array - */ - private $warnings = []; + /** + * @var array + */ + private $warnings = []; - /** - * @var MultipleErrors|null - */ - private $error; + /** + * @var MultipleErrors|null + */ + private $error; - /** - * @var int - */ - private $mode; + /** + * @var int + */ + private $mode; - /** - * @param EmailValidation[] $validations The validations. - * @param int $mode The validation mode (one of the constants). - */ - public function __construct(array $validations, $mode = self::ALLOW_ALL_ERRORS) - { - if (count($validations) == 0) { - throw new EmptyValidationList(); - } + /** + * @param EmailValidation[] $validations The validations. + * @param int $mode The validation mode (one of the constants). + */ + public function __construct(array $validations, $mode = self::ALLOW_ALL_ERRORS) + { + if (count($validations) == 0) { + throw new EmptyValidationList(); + } - $this->validations = $validations; - $this->mode = $mode; - } + $this->validations = $validations; + $this->mode = $mode; + } - /** - * {@inheritdoc} - */ - public function isValid($email, EmailLexer $emailLexer) - { - $result = true; - $errors = []; - foreach ($this->validations as $validation) { - $emailLexer->reset(); - $validationResult = $validation->isValid($email, $emailLexer); - $result = $result && $validationResult; - $this->warnings = array_merge($this->warnings, $validation->getWarnings()); - $errors = $this->addNewError($validation->getError(), $errors); + /** + * {@inheritdoc} + */ + public function isValid($email, EmailLexer $emailLexer) + { + $result = true; + $errors = []; + foreach ($this->validations as $validation) { + $emailLexer->reset(); + $validationResult = $validation->isValid($email, $emailLexer); + $result = $result && $validationResult; + $this->warnings = array_merge($this->warnings, $validation->getWarnings()); + $errors = $this->addNewError($validation->getError(), $errors); - if ($this->shouldStop($result)) { - break; - } - } + if ($this->shouldStop($result)) { + break; + } + } - if (!empty($errors)) { - $this->error = new MultipleErrors($errors); - } + if (!empty($errors)) { + $this->error = new MultipleErrors($errors); + } - return $result; - } + return $result; + } - /** - * @param \Egulias\EmailValidator\Exception\InvalidEmail|null $possibleError - * @param \Egulias\EmailValidator\Exception\InvalidEmail[] $errors - * - * @return \Egulias\EmailValidator\Exception\InvalidEmail[] - */ - private function addNewError($possibleError, array $errors) - { - if (null !== $possibleError) { - $errors[] = $possibleError; - } + /** + * @param \Egulias\EmailValidator\Exception\InvalidEmail|null $possibleError + * @param \Egulias\EmailValidator\Exception\InvalidEmail[] $errors + * + * @return \Egulias\EmailValidator\Exception\InvalidEmail[] + */ + private function addNewError($possibleError, array $errors) + { + if (null !== $possibleError) { + $errors[] = $possibleError; + } - return $errors; - } + return $errors; + } - /** - * @param bool $result - * - * @return bool - */ - private function shouldStop($result) - { - return !$result && $this->mode === self::STOP_ON_ERROR; - } + /** + * @param bool $result + * + * @return bool + */ + private function shouldStop($result) + { + return !$result && $this->mode === self::STOP_ON_ERROR; + } - /** - * Returns the validation errors. - * - * @return MultipleErrors|null - */ - public function getError() - { - return $this->error; - } + /** + * Returns the validation errors. + * + * @return MultipleErrors|null + */ + public function getError() + { + return $this->error; + } - /** - * {@inheritdoc} - */ - public function getWarnings() - { - return $this->warnings; - } + /** + * {@inheritdoc} + */ + public function getWarnings() + { + return $this->warnings; + } } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/NoRFCWarningsValidation.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/NoRFCWarningsValidation.php index 6b31e5440ec..b7b3bb90910 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/NoRFCWarningsValidation.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/NoRFCWarningsValidation.php @@ -8,34 +8,34 @@ use Egulias\EmailValidator\Validation\Error\RFCWarnings; class NoRFCWarningsValidation extends RFCValidation { - /** - * @var InvalidEmail|null - */ - private $error; + /** + * @var InvalidEmail|null + */ + private $error; - /** - * {@inheritdoc} - */ - public function isValid($email, EmailLexer $emailLexer) - { - if (!parent::isValid($email, $emailLexer)) { - return false; - } + /** + * {@inheritdoc} + */ + public function isValid($email, EmailLexer $emailLexer) + { + if (!parent::isValid($email, $emailLexer)) { + return false; + } - if (empty($this->getWarnings())) { - return true; - } + if (empty($this->getWarnings())) { + return true; + } - $this->error = new RFCWarnings(); + $this->error = new RFCWarnings(); - return false; - } + return false; + } - /** - * {@inheritdoc} - */ - public function getError() - { - return $this->error ?: parent::getError(); - } + /** + * {@inheritdoc} + */ + public function getError() + { + return $this->error ?: parent::getError(); + } } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/RFCValidation.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/RFCValidation.php index 8781e0b62d1..813da231844 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/RFCValidation.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/RFCValidation.php @@ -8,42 +8,42 @@ use Egulias\EmailValidator\Exception\InvalidEmail; class RFCValidation implements EmailValidation { - /** - * @var EmailParser|null - */ - private $parser; + /** + * @var EmailParser|null + */ + private $parser; - /** - * @var array - */ - private $warnings = []; + /** + * @var array + */ + private $warnings = []; - /** - * @var InvalidEmail|null - */ - private $error; + /** + * @var InvalidEmail|null + */ + private $error; - public function isValid($email, EmailLexer $emailLexer) - { - $this->parser = new EmailParser($emailLexer); - try { - $this->parser->parse((string)$email); - } catch (InvalidEmail $invalid) { - $this->error = $invalid; - return false; - } + public function isValid($email, EmailLexer $emailLexer) + { + $this->parser = new EmailParser($emailLexer); + try { + $this->parser->parse((string) $email); + } catch (InvalidEmail $invalid) { + $this->error = $invalid; + return false; + } - $this->warnings = $this->parser->getWarnings(); - return true; - } + $this->warnings = $this->parser->getWarnings(); + return true; + } - public function getError() - { - return $this->error; - } + public function getError() + { + return $this->error; + } - public function getWarnings() - { - return $this->warnings; - } + public function getWarnings() + { + return $this->warnings; + } } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/SpoofCheckValidation.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/SpoofCheckValidation.php index e10bfabd92f..65c017a3ce2 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/SpoofCheckValidation.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/SpoofCheckValidation.php @@ -9,43 +9,43 @@ use \Spoofchecker; class SpoofCheckValidation implements EmailValidation { - /** - * @var InvalidEmail|null - */ - private $error; + /** + * @var InvalidEmail|null + */ + private $error; - public function __construct() - { - if (!extension_loaded('intl')) { - throw new \LogicException(sprintf('The %s class requires the Intl extension.', __CLASS__)); - } - } + public function __construct() + { + if (!extension_loaded('intl')) { + throw new \LogicException(sprintf('The %s class requires the Intl extension.', __CLASS__)); + } + } - /** - * @psalm-suppress InvalidArgument - */ - public function isValid($email, EmailLexer $emailLexer) - { - $checker = new Spoofchecker(); - $checker->setChecks(Spoofchecker::SINGLE_SCRIPT); + /** + * @psalm-suppress InvalidArgument + */ + public function isValid($email, EmailLexer $emailLexer) + { + $checker = new Spoofchecker(); + $checker->setChecks(Spoofchecker::SINGLE_SCRIPT); - if ($checker->isSuspicious($email)) { - $this->error = new SpoofEmail(); - } + if ($checker->isSuspicious($email)) { + $this->error = new SpoofEmail(); + } - return $this->error === null; - } + return $this->error === null; + } - /** - * @return InvalidEmail|null - */ - public function getError() - { - return $this->error; - } + /** + * @return InvalidEmail|null + */ + public function getError() + { + return $this->error; + } - public function getWarnings() - { - return []; - } + public function getWarnings() + { + return []; + } } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/QuotedPart.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/QuotedPart.php index 36a4265a515..dd2cf28d0d8 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/QuotedPart.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/QuotedPart.php @@ -4,14 +4,14 @@ namespace Egulias\EmailValidator\Warning; class QuotedPart extends Warning { - const CODE = 36; + const CODE = 36; - /** - * @param scalar $prevToken - * @param scalar $postToken - */ - public function __construct($prevToken, $postToken) - { - $this->message = "Deprecated Quoted String found between $prevToken and $postToken"; - } + /** + * @param scalar $prevToken + * @param scalar $postToken + */ + public function __construct($prevToken, $postToken) + { + $this->message = "Deprecated Quoted String found between $prevToken and $postToken"; + } } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/QuotedString.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/QuotedString.php index 817e4e84b07..d1f99b905c6 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/QuotedString.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/QuotedString.php @@ -4,14 +4,14 @@ namespace Egulias\EmailValidator\Warning; class QuotedString extends Warning { - const CODE = 11; + const CODE = 11; - /** - * @param scalar $prevToken - * @param scalar $postToken - */ - public function __construct($prevToken, $postToken) - { - $this->message = "Quoted String found between $prevToken and $postToken"; - } + /** + * @param scalar $prevToken + * @param scalar $postToken + */ + public function __construct($prevToken, $postToken) + { + $this->message = "Quoted String found between $prevToken and $postToken"; + } } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/Warning.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/Warning.php index a2ee7b0de1e..0ecd5ab9244 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/Warning.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/Warning.php @@ -4,44 +4,44 @@ namespace Egulias\EmailValidator\Warning; abstract class Warning { - const CODE = 0; + const CODE = 0; - /** - * @var string - */ - protected $message = ''; + /** + * @var string + */ + protected $message = ''; - /** - * @var int - */ - protected $rfcNumber = 0; + /** + * @var int + */ + protected $rfcNumber = 0; - /** - * @return string - */ - public function message() - { - return $this->message; - } + /** + * @return string + */ + public function message() + { + return $this->message; + } - /** - * @return int - */ - public function code() - { - return static::CODE; - } + /** + * @return int + */ + public function code() + { + return static::CODE; + } - /** - * @return int - */ - public function RFCNumber() - { - return $this->rfcNumber; - } + /** + * @return int + */ + public function RFCNumber() + { + return $this->rfcNumber; + } - public function __toString() - { - return $this->message() . " rfc: " . $this->rfcNumber . "interal code: " . static::CODE; - } + public function __toString() + { + return $this->message() . " rfc: " . $this->rfcNumber . "interal code: " . static::CODE; + } } diff --git a/htdocs/includes/swiftmailer/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php b/htdocs/includes/swiftmailer/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php index dd3ea768e3b..a561a6678f9 100644 --- a/htdocs/includes/swiftmailer/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php +++ b/htdocs/includes/swiftmailer/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php @@ -29,304 +29,304 @@ namespace Doctrine\Common\Lexer; */ abstract class AbstractLexer { - /** - * Lexer original input string. - * - * @var string - */ - private $input; + /** + * Lexer original input string. + * + * @var string + */ + private $input; - /** - * Array of scanned tokens. - * - * Each token is an associative array containing three items: - * - 'value' : the string value of the token in the input string - * - 'type' : the type of the token (identifier, numeric, string, input - * parameter, none) - * - 'position' : the position of the token in the input string - * - * @var array - */ - private $tokens = array(); + /** + * Array of scanned tokens. + * + * Each token is an associative array containing three items: + * - 'value' : the string value of the token in the input string + * - 'type' : the type of the token (identifier, numeric, string, input + * parameter, none) + * - 'position' : the position of the token in the input string + * + * @var array + */ + private $tokens = array(); - /** - * Current lexer position in input string. - * - * @var integer - */ - private $position = 0; + /** + * Current lexer position in input string. + * + * @var integer + */ + private $position = 0; - /** - * Current peek of current lexer position. - * - * @var integer - */ - private $peek = 0; + /** + * Current peek of current lexer position. + * + * @var integer + */ + private $peek = 0; - /** - * The next token in the input. - * - * @var array - */ - public $lookahead; + /** + * The next token in the input. + * + * @var array + */ + public $lookahead; - /** - * The last matched/seen token. - * - * @var array - */ - public $token; + /** + * The last matched/seen token. + * + * @var array + */ + public $token; - /** - * Sets the input data to be tokenized. - * - * The Lexer is immediately reset and the new input tokenized. - * Any unprocessed tokens from any previous input are lost. - * - * @param string $input The input to be tokenized. - * - * @return void - */ - public function setInput($input) - { - $this->input = $input; - $this->tokens = array(); + /** + * Sets the input data to be tokenized. + * + * The Lexer is immediately reset and the new input tokenized. + * Any unprocessed tokens from any previous input are lost. + * + * @param string $input The input to be tokenized. + * + * @return void + */ + public function setInput($input) + { + $this->input = $input; + $this->tokens = array(); - $this->reset(); - $this->scan($input); - } + $this->reset(); + $this->scan($input); + } - /** - * Resets the lexer. - * - * @return void - */ - public function reset() - { - $this->lookahead = null; - $this->token = null; - $this->peek = 0; - $this->position = 0; - } + /** + * Resets the lexer. + * + * @return void + */ + public function reset() + { + $this->lookahead = null; + $this->token = null; + $this->peek = 0; + $this->position = 0; + } - /** - * Resets the peek pointer to 0. - * - * @return void - */ - public function resetPeek() - { - $this->peek = 0; - } + /** + * Resets the peek pointer to 0. + * + * @return void + */ + public function resetPeek() + { + $this->peek = 0; + } - /** - * Resets the lexer position on the input to the given position. - * - * @param integer $position Position to place the lexical scanner. - * - * @return void - */ - public function resetPosition($position = 0) - { - $this->position = $position; - } + /** + * Resets the lexer position on the input to the given position. + * + * @param integer $position Position to place the lexical scanner. + * + * @return void + */ + public function resetPosition($position = 0) + { + $this->position = $position; + } - /** - * Retrieve the original lexer's input until a given position. - * - * @param integer $position - * - * @return string - */ - public function getInputUntilPosition($position) - { - return substr($this->input, 0, $position); - } + /** + * Retrieve the original lexer's input until a given position. + * + * @param integer $position + * + * @return string + */ + public function getInputUntilPosition($position) + { + return substr($this->input, 0, $position); + } - /** - * Checks whether a given token matches the current lookahead. - * - * @param integer|string $token - * - * @return boolean - */ - public function isNextToken($token) - { - return null !== $this->lookahead && $this->lookahead['type'] === $token; - } + /** + * Checks whether a given token matches the current lookahead. + * + * @param integer|string $token + * + * @return boolean + */ + public function isNextToken($token) + { + return null !== $this->lookahead && $this->lookahead['type'] === $token; + } - /** - * Checks whether any of the given tokens matches the current lookahead. - * - * @param array $tokens - * - * @return boolean - */ - public function isNextTokenAny(array $tokens) - { - return null !== $this->lookahead && in_array($this->lookahead['type'], $tokens, true); - } + /** + * Checks whether any of the given tokens matches the current lookahead. + * + * @param array $tokens + * + * @return boolean + */ + public function isNextTokenAny(array $tokens) + { + return null !== $this->lookahead && in_array($this->lookahead['type'], $tokens, true); + } - /** - * Moves to the next token in the input string. - * - * @return boolean - */ - public function moveNext() - { - $this->peek = 0; - $this->token = $this->lookahead; - $this->lookahead = (isset($this->tokens[$this->position])) - ? $this->tokens[$this->position++] : null; + /** + * Moves to the next token in the input string. + * + * @return boolean + */ + public function moveNext() + { + $this->peek = 0; + $this->token = $this->lookahead; + $this->lookahead = (isset($this->tokens[$this->position])) + ? $this->tokens[$this->position++] : null; - return $this->lookahead !== null; - } + return $this->lookahead !== null; + } - /** - * Tells the lexer to skip input tokens until it sees a token with the given value. - * - * @param string $type The token type to skip until. - * - * @return void - */ - public function skipUntil($type) - { - while ($this->lookahead !== null && $this->lookahead['type'] !== $type) { - $this->moveNext(); - } - } + /** + * Tells the lexer to skip input tokens until it sees a token with the given value. + * + * @param string $type The token type to skip until. + * + * @return void + */ + public function skipUntil($type) + { + while ($this->lookahead !== null && $this->lookahead['type'] !== $type) { + $this->moveNext(); + } + } - /** - * Checks if given value is identical to the given token. - * - * @param mixed $value - * @param integer $token - * - * @return boolean - */ - public function isA($value, $token) - { - return $this->getType($value) === $token; - } + /** + * Checks if given value is identical to the given token. + * + * @param mixed $value + * @param integer $token + * + * @return boolean + */ + public function isA($value, $token) + { + return $this->getType($value) === $token; + } - /** - * Moves the lookahead token forward. - * - * @return array|null The next token or NULL if there are no more tokens ahead. - */ - public function peek() - { - if (isset($this->tokens[$this->position + $this->peek])) { - return $this->tokens[$this->position + $this->peek++]; - } else { - return null; - } - } + /** + * Moves the lookahead token forward. + * + * @return array|null The next token or NULL if there are no more tokens ahead. + */ + public function peek() + { + if (isset($this->tokens[$this->position + $this->peek])) { + return $this->tokens[$this->position + $this->peek++]; + } else { + return null; + } + } - /** - * Peeks at the next token, returns it and immediately resets the peek. - * - * @return array|null The next token or NULL if there are no more tokens ahead. - */ - public function glimpse() - { - $peek = $this->peek(); - $this->peek = 0; - return $peek; - } + /** + * Peeks at the next token, returns it and immediately resets the peek. + * + * @return array|null The next token or NULL if there are no more tokens ahead. + */ + public function glimpse() + { + $peek = $this->peek(); + $this->peek = 0; + return $peek; + } - /** - * Scans the input string for tokens. - * - * @param string $input A query string. - * - * @return void - */ - protected function scan($input) - { - static $regex; + /** + * Scans the input string for tokens. + * + * @param string $input A query string. + * + * @return void + */ + protected function scan($input) + { + static $regex; - if ( ! isset($regex)) { - $regex = sprintf( - '/(%s)|%s/%s', - implode(')|(', $this->getCatchablePatterns()), - implode('|', $this->getNonCatchablePatterns()), - $this->getModifiers() - ); - } + if ( ! isset($regex)) { + $regex = sprintf( + '/(%s)|%s/%s', + implode(')|(', $this->getCatchablePatterns()), + implode('|', $this->getNonCatchablePatterns()), + $this->getModifiers() + ); + } - $flags = PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE; - $matches = preg_split($regex, $input, -1, $flags); + $flags = PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE; + $matches = preg_split($regex, $input, -1, $flags); - if (false === $matches) { - // Work around https://bugs.php.net/78122 - $matches = array(array($input, 0)); - } + if (false === $matches) { + // Work around https://bugs.php.net/78122 + $matches = array(array($input, 0)); + } - foreach ($matches as $match) { - // Must remain before 'value' assignment since it can change content - $type = $this->getType($match[0]); + foreach ($matches as $match) { + // Must remain before 'value' assignment since it can change content + $type = $this->getType($match[0]); - $this->tokens[] = array( - 'value' => $match[0], - 'type' => $type, - 'position' => $match[1], - ); - } - } + $this->tokens[] = array( + 'value' => $match[0], + 'type' => $type, + 'position' => $match[1], + ); + } + } - /** - * Gets the literal for a given token. - * - * @param integer $token - * - * @return string - */ - public function getLiteral($token) - { - $className = get_class($this); - $reflClass = new \ReflectionClass($className); - $constants = $reflClass->getConstants(); + /** + * Gets the literal for a given token. + * + * @param integer $token + * + * @return string + */ + public function getLiteral($token) + { + $className = get_class($this); + $reflClass = new \ReflectionClass($className); + $constants = $reflClass->getConstants(); - foreach ($constants as $name => $value) { - if ($value === $token) { - return $className . '::' . $name; - } - } + foreach ($constants as $name => $value) { + if ($value === $token) { + return $className . '::' . $name; + } + } - return $token; - } + return $token; + } - /** - * Regex modifiers - * - * @return string - */ - protected function getModifiers() - { - return 'i'; - } + /** + * Regex modifiers + * + * @return string + */ + protected function getModifiers() + { + return 'i'; + } - /** - * Lexical catchable patterns. - * - * @return array - */ - abstract protected function getCatchablePatterns(); + /** + * Lexical catchable patterns. + * + * @return array + */ + abstract protected function getCatchablePatterns(); - /** - * Lexical non-catchable patterns. - * - * @return array - */ - abstract protected function getNonCatchablePatterns(); + /** + * Lexical non-catchable patterns. + * + * @return array + */ + abstract protected function getNonCatchablePatterns(); - /** - * Retrieve token type. Also processes the token value if necessary. - * - * @param string $value - * - * @return integer - */ - abstract protected function getType(&$value); + /** + * Retrieve token type. Also processes the token value if necessary. + * + * @param string $value + * + * @return integer + */ + abstract protected function getType(&$value); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift.php b/htdocs/includes/swiftmailer/lib/classes/Swift.php index 51b19c9cb4e..09cdc4fbefd 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift.php @@ -15,64 +15,64 @@ */ abstract class Swift { - const VERSION = '6.3.0'; + const VERSION = '6.3.0'; - public static $initialized = false; - public static $inits = []; + public static $initialized = false; + public static $inits = []; - /** - * Registers an initializer callable that will be called the first time - * a SwiftMailer class is autoloaded. - * - * This enables you to tweak the default configuration in a lazy way. - * - * @param mixed $callable A valid PHP callable that will be called when autoloading the first Swift class - */ - public static function init($callable) - { - self::$inits[] = $callable; - } + /** + * Registers an initializer callable that will be called the first time + * a SwiftMailer class is autoloaded. + * + * This enables you to tweak the default configuration in a lazy way. + * + * @param mixed $callable A valid PHP callable that will be called when autoloading the first Swift class + */ + public static function init($callable) + { + self::$inits[] = $callable; + } - /** - * Internal autoloader for spl_autoload_register(). - * - * @param string $class - */ - public static function autoload($class) - { - // Don't interfere with other autoloaders - if (0 !== strpos($class, 'Swift_')) { - return; - } + /** + * Internal autoloader for spl_autoload_register(). + * + * @param string $class + */ + public static function autoload($class) + { + // Don't interfere with other autoloaders + if (0 !== strpos($class, 'Swift_')) { + return; + } - $path = __DIR__.'/'.str_replace('_', '/', $class).'.php'; + $path = __DIR__.'/'.str_replace('_', '/', $class).'.php'; - if (!file_exists($path)) { - return; - } + if (!file_exists($path)) { + return; + } - require $path; + require $path; - if (self::$inits && !self::$initialized) { - self::$initialized = true; - foreach (self::$inits as $init) { - \call_user_func($init); - } - } - } + if (self::$inits && !self::$initialized) { + self::$initialized = true; + foreach (self::$inits as $init) { + \call_user_func($init); + } + } + } - /** - * Configure autoloading using Swift Mailer. - * - * This is designed to play nicely with other autoloaders. - * - * @param mixed $callable A valid PHP callable that will be called when autoloading the first Swift class - */ - public static function registerAutoload($callable = null) - { - if (null !== $callable) { - self::$inits[] = $callable; - } - spl_autoload_register(['Swift', 'autoload']); - } + /** + * Configure autoloading using Swift Mailer. + * + * This is designed to play nicely with other autoloaders. + * + * @param mixed $callable A valid PHP callable that will be called when autoloading the first Swift class + */ + public static function registerAutoload($callable = null) + { + if (null !== $callable) { + self::$inits[] = $callable; + } + spl_autoload_register(['Swift', 'autoload']); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoder.php b/htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoder.php index a1704ffb40a..643060e12c1 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoder.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoder.php @@ -15,11 +15,11 @@ */ interface Swift_AddressEncoder { - /** - * Encodes an email address. - * - * @throws Swift_AddressEncoderException if the email cannot be represented in - * the encoding implemented by this class - */ - public function encodeString(string $address): string; + /** + * Encodes an email address. + * + * @throws Swift_AddressEncoderException if the email cannot be represented in + * the encoding implemented by this class + */ + public function encodeString(string $address): string; } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoder/IdnAddressEncoder.php b/htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoder/IdnAddressEncoder.php index a373ef9d546..a00f90efa5e 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoder/IdnAddressEncoder.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoder/IdnAddressEncoder.php @@ -24,27 +24,27 @@ */ class Swift_AddressEncoder_IdnAddressEncoder implements Swift_AddressEncoder { - /** - * Encodes the domain part of an address using IDN. - * - * @throws Swift_AddressEncoderException If local-part contains non-ASCII characters - */ - public function encodeString(string $address): string - { - $i = strrpos($address, '@'); - if (false !== $i) { - $local = substr($address, 0, $i); - $domain = substr($address, $i + 1); + /** + * Encodes the domain part of an address using IDN. + * + * @throws Swift_AddressEncoderException If local-part contains non-ASCII characters + */ + public function encodeString(string $address): string + { + $i = strrpos($address, '@'); + if (false !== $i) { + $local = substr($address, 0, $i); + $domain = substr($address, $i + 1); - if (preg_match('/[^\x00-\x7F]/', $local)) { - throw new Swift_AddressEncoderException('Non-ASCII characters not supported in local-part', $address); - } + if (preg_match('/[^\x00-\x7F]/', $local)) { + throw new Swift_AddressEncoderException('Non-ASCII characters not supported in local-part', $address); + } - if (preg_match('/[^\x00-\x7F]/', $domain)) { - $address = sprintf('%s@%s', $local, idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46)); - } - } + if (preg_match('/[^\x00-\x7F]/', $domain)) { + $address = sprintf('%s@%s', $local, idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46)); + } + } - return $address; - } + return $address; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoder/Utf8AddressEncoder.php b/htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoder/Utf8AddressEncoder.php index 1b454305678..29de0f5cc93 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoder/Utf8AddressEncoder.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoder/Utf8AddressEncoder.php @@ -26,11 +26,11 @@ */ class Swift_AddressEncoder_Utf8AddressEncoder implements Swift_AddressEncoder { - /** - * Returns the address verbatimly. - */ - public function encodeString(string $address): string - { - return $address; - } + /** + * Returns the address verbatimly. + */ + public function encodeString(string $address): string + { + return $address; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoderException.php b/htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoderException.php index 9b405476bcb..7d499f1deaf 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoderException.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoderException.php @@ -16,17 +16,17 @@ */ class Swift_AddressEncoderException extends Swift_RfcComplianceException { - protected $address; + protected $address; - public function __construct(string $message, string $address) - { - parent::__construct($message); + public function __construct(string $message, string $address) + { + parent::__construct($message); - $this->address = $address; - } + $this->address = $address; + } - public function getAddress(): string - { - return $this->address; - } + public function getAddress(): string + { + return $this->address; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Attachment.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Attachment.php index 7a1420f7986..f759001ad4e 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Attachment.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Attachment.php @@ -15,40 +15,40 @@ */ class Swift_Attachment extends Swift_Mime_Attachment { - /** - * Create a new Attachment. - * - * Details may be optionally provided to the constructor. - * - * @param string|Swift_OutputByteStream $data - * @param string $filename - * @param string $contentType - */ - public function __construct($data = null, $filename = null, $contentType = null) - { - \call_user_func_array( - [$this, 'Swift_Mime_Attachment::__construct'], - Swift_DependencyContainer::getInstance() - ->createDependenciesFor('mime.attachment') - ); + /** + * Create a new Attachment. + * + * Details may be optionally provided to the constructor. + * + * @param string|Swift_OutputByteStream $data + * @param string $filename + * @param string $contentType + */ + public function __construct($data = null, $filename = null, $contentType = null) + { + \call_user_func_array( + [$this, 'Swift_Mime_Attachment::__construct'], + Swift_DependencyContainer::getInstance() + ->createDependenciesFor('mime.attachment') + ); - $this->setBody($data, $contentType); - $this->setFilename($filename); - } + $this->setBody($data, $contentType); + $this->setFilename($filename); + } - /** - * Create a new Attachment from a filesystem path. - * - * @param string $path - * @param string $contentType optional - * - * @return self - */ - public static function fromPath($path, $contentType = null) - { - return (new self())->setFile( - new Swift_ByteStream_FileByteStream($path), - $contentType - ); - } + /** + * Create a new Attachment from a filesystem path. + * + * @param string $path + * @param string $contentType optional + * + * @return self + */ + public static function fromPath($path, $contentType = null) + { + return (new self())->setFile( + new Swift_ByteStream_FileByteStream($path), + $contentType + ); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php b/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php index 3a69c15f1c4..0f7833c3a19 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php @@ -15,162 +15,162 @@ */ abstract class Swift_ByteStream_AbstractFilterableInputStream implements Swift_InputByteStream, Swift_Filterable { - /** - * Write sequence. - */ - protected $sequence = 0; + /** + * Write sequence. + */ + protected $sequence = 0; - /** - * StreamFilters. - * - * @var Swift_StreamFilter[] - */ - private $filters = []; + /** + * StreamFilters. + * + * @var Swift_StreamFilter[] + */ + private $filters = []; - /** - * A buffer for writing. - */ - private $writeBuffer = ''; + /** + * A buffer for writing. + */ + private $writeBuffer = ''; - /** - * Bound streams. - * - * @var Swift_InputByteStream[] - */ - private $mirrors = []; + /** + * Bound streams. + * + * @var Swift_InputByteStream[] + */ + private $mirrors = []; - /** - * Commit the given bytes to the storage medium immediately. - * - * @param string $bytes - */ - abstract protected function doCommit($bytes); + /** + * Commit the given bytes to the storage medium immediately. + * + * @param string $bytes + */ + abstract protected function doCommit($bytes); - /** - * Flush any buffers/content with immediate effect. - */ - abstract protected function flush(); + /** + * Flush any buffers/content with immediate effect. + */ + abstract protected function flush(); - /** - * Add a StreamFilter to this InputByteStream. - * - * @param string $key - */ - public function addFilter(Swift_StreamFilter $filter, $key) - { - $this->filters[$key] = $filter; - } + /** + * Add a StreamFilter to this InputByteStream. + * + * @param string $key + */ + public function addFilter(Swift_StreamFilter $filter, $key) + { + $this->filters[$key] = $filter; + } - /** - * Remove an already present StreamFilter based on its $key. - * - * @param string $key - */ - public function removeFilter($key) - { - unset($this->filters[$key]); - } + /** + * Remove an already present StreamFilter based on its $key. + * + * @param string $key + */ + public function removeFilter($key) + { + unset($this->filters[$key]); + } - /** - * Writes $bytes to the end of the stream. - * - * @param string $bytes - * - * @throws Swift_IoException - * - * @return int - */ - public function write($bytes) - { - $this->writeBuffer .= $bytes; - foreach ($this->filters as $filter) { - if ($filter->shouldBuffer($this->writeBuffer)) { - return; - } - } - $this->doWrite($this->writeBuffer); + /** + * Writes $bytes to the end of the stream. + * + * @param string $bytes + * + * @throws Swift_IoException + * + * @return int + */ + public function write($bytes) + { + $this->writeBuffer .= $bytes; + foreach ($this->filters as $filter) { + if ($filter->shouldBuffer($this->writeBuffer)) { + return; + } + } + $this->doWrite($this->writeBuffer); - return ++$this->sequence; - } + return ++$this->sequence; + } - /** - * For any bytes that are currently buffered inside the stream, force them - * off the buffer. - * - * @throws Swift_IoException - */ - public function commit() - { - $this->doWrite($this->writeBuffer); - } + /** + * For any bytes that are currently buffered inside the stream, force them + * off the buffer. + * + * @throws Swift_IoException + */ + public function commit() + { + $this->doWrite($this->writeBuffer); + } - /** - * Attach $is to this stream. - * - * The stream acts as an observer, receiving all data that is written. - * All {@link write()} and {@link flushBuffers()} operations will be mirrored. - */ - public function bind(Swift_InputByteStream $is) - { - $this->mirrors[] = $is; - } + /** + * Attach $is to this stream. + * + * The stream acts as an observer, receiving all data that is written. + * All {@link write()} and {@link flushBuffers()} operations will be mirrored. + */ + public function bind(Swift_InputByteStream $is) + { + $this->mirrors[] = $is; + } - /** - * Remove an already bound stream. - * - * If $is is not bound, no errors will be raised. - * If the stream currently has any buffered data it will be written to $is - * before unbinding occurs. - */ - public function unbind(Swift_InputByteStream $is) - { - foreach ($this->mirrors as $k => $stream) { - if ($is === $stream) { - if ('' !== $this->writeBuffer) { - $stream->write($this->writeBuffer); - } - unset($this->mirrors[$k]); - } - } - } + /** + * Remove an already bound stream. + * + * If $is is not bound, no errors will be raised. + * If the stream currently has any buffered data it will be written to $is + * before unbinding occurs. + */ + public function unbind(Swift_InputByteStream $is) + { + foreach ($this->mirrors as $k => $stream) { + if ($is === $stream) { + if ('' !== $this->writeBuffer) { + $stream->write($this->writeBuffer); + } + unset($this->mirrors[$k]); + } + } + } - /** - * Flush the contents of the stream (empty it) and set the internal pointer - * to the beginning. - * - * @throws Swift_IoException - */ - public function flushBuffers() - { - if ('' !== $this->writeBuffer) { - $this->doWrite($this->writeBuffer); - } - $this->flush(); + /** + * Flush the contents of the stream (empty it) and set the internal pointer + * to the beginning. + * + * @throws Swift_IoException + */ + public function flushBuffers() + { + if ('' !== $this->writeBuffer) { + $this->doWrite($this->writeBuffer); + } + $this->flush(); - foreach ($this->mirrors as $stream) { - $stream->flushBuffers(); - } - } + foreach ($this->mirrors as $stream) { + $stream->flushBuffers(); + } + } - /** Run $bytes through all filters */ - private function filter($bytes) - { - foreach ($this->filters as $filter) { - $bytes = $filter->filter($bytes); - } + /** Run $bytes through all filters */ + private function filter($bytes) + { + foreach ($this->filters as $filter) { + $bytes = $filter->filter($bytes); + } - return $bytes; - } + return $bytes; + } - /** Just write the bytes to the stream */ - private function doWrite($bytes) - { - $this->doCommit($this->filter($bytes)); + /** Just write the bytes to the stream */ + private function doWrite($bytes) + { + $this->doCommit($this->filter($bytes)); - foreach ($this->mirrors as $stream) { - $stream->write($bytes); - } + foreach ($this->mirrors as $stream) { + $stream->write($bytes); + } - $this->writeBuffer = ''; - } + $this->writeBuffer = ''; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/ArrayByteStream.php b/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/ArrayByteStream.php index 4f3dcc37745..53d5cef10a0 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/ArrayByteStream.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/ArrayByteStream.php @@ -15,164 +15,164 @@ */ class Swift_ByteStream_ArrayByteStream implements Swift_InputByteStream, Swift_OutputByteStream { - /** - * The internal stack of bytes. - * - * @var string[] - */ - private $array = []; + /** + * The internal stack of bytes. + * + * @var string[] + */ + private $array = []; - /** - * The size of the stack. - * - * @var int - */ - private $arraySize = 0; + /** + * The size of the stack. + * + * @var int + */ + private $arraySize = 0; - /** - * The internal pointer offset. - * - * @var int - */ - private $offset = 0; + /** + * The internal pointer offset. + * + * @var int + */ + private $offset = 0; - /** - * Bound streams. - * - * @var Swift_InputByteStream[] - */ - private $mirrors = []; + /** + * Bound streams. + * + * @var Swift_InputByteStream[] + */ + private $mirrors = []; - /** - * Create a new ArrayByteStream. - * - * If $stack is given the stream will be populated with the bytes it contains. - * - * @param mixed $stack of bytes in string or array form, optional - */ - public function __construct($stack = null) - { - if (\is_array($stack)) { - $this->array = $stack; - $this->arraySize = \count($stack); - } elseif (\is_string($stack)) { - $this->write($stack); - } else { - $this->array = []; - } - } + /** + * Create a new ArrayByteStream. + * + * If $stack is given the stream will be populated with the bytes it contains. + * + * @param mixed $stack of bytes in string or array form, optional + */ + public function __construct($stack = null) + { + if (\is_array($stack)) { + $this->array = $stack; + $this->arraySize = \count($stack); + } elseif (\is_string($stack)) { + $this->write($stack); + } else { + $this->array = []; + } + } - /** - * Reads $length bytes from the stream into a string and moves the pointer - * through the stream by $length. - * - * If less bytes exist than are requested the - * remaining bytes are given instead. If no bytes are remaining at all, boolean - * false is returned. - * - * @param int $length - * - * @return string - */ - public function read($length) - { - if ($this->offset == $this->arraySize) { - return false; - } + /** + * Reads $length bytes from the stream into a string and moves the pointer + * through the stream by $length. + * + * If less bytes exist than are requested the + * remaining bytes are given instead. If no bytes are remaining at all, boolean + * false is returned. + * + * @param int $length + * + * @return string + */ + public function read($length) + { + if ($this->offset == $this->arraySize) { + return false; + } - // Don't use array slice - $end = $length + $this->offset; - $end = $this->arraySize < $end ? $this->arraySize : $end; - $ret = ''; - for (; $this->offset < $end; ++$this->offset) { - $ret .= $this->array[$this->offset]; - } + // Don't use array slice + $end = $length + $this->offset; + $end = $this->arraySize < $end ? $this->arraySize : $end; + $ret = ''; + for (; $this->offset < $end; ++$this->offset) { + $ret .= $this->array[$this->offset]; + } - return $ret; - } + return $ret; + } - /** - * Writes $bytes to the end of the stream. - * - * @param string $bytes - */ - public function write($bytes) - { - $to_add = str_split($bytes); - foreach ($to_add as $value) { - $this->array[] = $value; - } - $this->arraySize = \count($this->array); + /** + * Writes $bytes to the end of the stream. + * + * @param string $bytes + */ + public function write($bytes) + { + $to_add = str_split($bytes); + foreach ($to_add as $value) { + $this->array[] = $value; + } + $this->arraySize = \count($this->array); - foreach ($this->mirrors as $stream) { - $stream->write($bytes); - } - } + foreach ($this->mirrors as $stream) { + $stream->write($bytes); + } + } - /** - * Not used. - */ - public function commit() - { - } + /** + * Not used. + */ + public function commit() + { + } - /** - * Attach $is to this stream. - * - * The stream acts as an observer, receiving all data that is written. - * All {@link write()} and {@link flushBuffers()} operations will be mirrored. - */ - public function bind(Swift_InputByteStream $is) - { - $this->mirrors[] = $is; - } + /** + * Attach $is to this stream. + * + * The stream acts as an observer, receiving all data that is written. + * All {@link write()} and {@link flushBuffers()} operations will be mirrored. + */ + public function bind(Swift_InputByteStream $is) + { + $this->mirrors[] = $is; + } - /** - * Remove an already bound stream. - * - * If $is is not bound, no errors will be raised. - * If the stream currently has any buffered data it will be written to $is - * before unbinding occurs. - */ - public function unbind(Swift_InputByteStream $is) - { - foreach ($this->mirrors as $k => $stream) { - if ($is === $stream) { - unset($this->mirrors[$k]); - } - } - } + /** + * Remove an already bound stream. + * + * If $is is not bound, no errors will be raised. + * If the stream currently has any buffered data it will be written to $is + * before unbinding occurs. + */ + public function unbind(Swift_InputByteStream $is) + { + foreach ($this->mirrors as $k => $stream) { + if ($is === $stream) { + unset($this->mirrors[$k]); + } + } + } - /** - * Move the internal read pointer to $byteOffset in the stream. - * - * @param int $byteOffset - * - * @return bool - */ - public function setReadPointer($byteOffset) - { - if ($byteOffset > $this->arraySize) { - $byteOffset = $this->arraySize; - } elseif ($byteOffset < 0) { - $byteOffset = 0; - } + /** + * Move the internal read pointer to $byteOffset in the stream. + * + * @param int $byteOffset + * + * @return bool + */ + public function setReadPointer($byteOffset) + { + if ($byteOffset > $this->arraySize) { + $byteOffset = $this->arraySize; + } elseif ($byteOffset < 0) { + $byteOffset = 0; + } - $this->offset = $byteOffset; - } + $this->offset = $byteOffset; + } - /** - * Flush the contents of the stream (empty it) and set the internal pointer - * to the beginning. - */ - public function flushBuffers() - { - $this->offset = 0; - $this->array = []; - $this->arraySize = 0; + /** + * Flush the contents of the stream (empty it) and set the internal pointer + * to the beginning. + */ + public function flushBuffers() + { + $this->offset = 0; + $this->array = []; + $this->arraySize = 0; - foreach ($this->mirrors as $stream) { - $stream->flushBuffers(); - } - } + foreach ($this->mirrors as $stream) { + $stream->flushBuffers(); + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/FileByteStream.php b/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/FileByteStream.php index f6391219e71..b27d96a1760 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/FileByteStream.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/FileByteStream.php @@ -15,200 +15,200 @@ */ class Swift_ByteStream_FileByteStream extends Swift_ByteStream_AbstractFilterableInputStream implements Swift_FileStream { - /** The internal pointer offset */ - private $offset = 0; + /** The internal pointer offset */ + private $offset = 0; - /** The path to the file */ - private $path; + /** The path to the file */ + private $path; - /** The mode this file is opened in for writing */ - private $mode; + /** The mode this file is opened in for writing */ + private $mode; - /** A lazy-loaded resource handle for reading the file */ - private $reader; + /** A lazy-loaded resource handle for reading the file */ + private $reader; - /** A lazy-loaded resource handle for writing the file */ - private $writer; + /** A lazy-loaded resource handle for writing the file */ + private $writer; - /** If stream is seekable true/false, or null if not known */ - private $seekable = null; + /** If stream is seekable true/false, or null if not known */ + private $seekable = null; - /** - * Create a new FileByteStream for $path. - * - * @param string $path - * @param bool $writable if true - */ - public function __construct($path, $writable = false) - { - if (empty($path)) { - throw new Swift_IoException('The path cannot be empty'); - } - $this->path = $path; - $this->mode = $writable ? 'w+b' : 'rb'; - } + /** + * Create a new FileByteStream for $path. + * + * @param string $path + * @param bool $writable if true + */ + public function __construct($path, $writable = false) + { + if (empty($path)) { + throw new Swift_IoException('The path cannot be empty'); + } + $this->path = $path; + $this->mode = $writable ? 'w+b' : 'rb'; + } - /** - * Get the complete path to the file. - * - * @return string - */ - public function getPath() - { - return $this->path; - } + /** + * Get the complete path to the file. + * + * @return string + */ + public function getPath() + { + return $this->path; + } - /** - * Reads $length bytes from the stream into a string and moves the pointer - * through the stream by $length. - * - * If less bytes exist than are requested the - * remaining bytes are given instead. If no bytes are remaining at all, boolean - * false is returned. - * - * @param int $length - * - * @return string|bool - * - * @throws Swift_IoException - */ - public function read($length) - { - $fp = $this->getReadHandle(); - if (!feof($fp)) { - $bytes = fread($fp, $length); - $this->offset = ftell($fp); + /** + * Reads $length bytes from the stream into a string and moves the pointer + * through the stream by $length. + * + * If less bytes exist than are requested the + * remaining bytes are given instead. If no bytes are remaining at all, boolean + * false is returned. + * + * @param int $length + * + * @return string|bool + * + * @throws Swift_IoException + */ + public function read($length) + { + $fp = $this->getReadHandle(); + if (!feof($fp)) { + $bytes = fread($fp, $length); + $this->offset = ftell($fp); - // If we read one byte after reaching the end of the file - // feof() will return false and an empty string is returned - if ((false === $bytes || '' === $bytes) && feof($fp)) { - $this->resetReadHandle(); + // If we read one byte after reaching the end of the file + // feof() will return false and an empty string is returned + if ((false === $bytes || '' === $bytes) && feof($fp)) { + $this->resetReadHandle(); - return false; - } + return false; + } - return $bytes; - } + return $bytes; + } - $this->resetReadHandle(); + $this->resetReadHandle(); - return false; - } + return false; + } - /** - * Move the internal read pointer to $byteOffset in the stream. - * - * @param int $byteOffset - * - * @return bool - */ - public function setReadPointer($byteOffset) - { - if (isset($this->reader)) { - $this->seekReadStreamToPosition($byteOffset); - } - $this->offset = $byteOffset; - } + /** + * Move the internal read pointer to $byteOffset in the stream. + * + * @param int $byteOffset + * + * @return bool + */ + public function setReadPointer($byteOffset) + { + if (isset($this->reader)) { + $this->seekReadStreamToPosition($byteOffset); + } + $this->offset = $byteOffset; + } - /** Just write the bytes to the file */ - protected function doCommit($bytes) - { - fwrite($this->getWriteHandle(), $bytes); - $this->resetReadHandle(); - } + /** Just write the bytes to the file */ + protected function doCommit($bytes) + { + fwrite($this->getWriteHandle(), $bytes); + $this->resetReadHandle(); + } - /** Not used */ - protected function flush() - { - } + /** Not used */ + protected function flush() + { + } - /** Get the resource for reading */ - private function getReadHandle() - { - if (!isset($this->reader)) { - $pointer = @fopen($this->path, 'rb'); - if (!$pointer) { - throw new Swift_IoException('Unable to open file for reading ['.$this->path.']'); - } - $this->reader = $pointer; - if (0 != $this->offset) { - $this->getReadStreamSeekableStatus(); - $this->seekReadStreamToPosition($this->offset); - } - } + /** Get the resource for reading */ + private function getReadHandle() + { + if (!isset($this->reader)) { + $pointer = @fopen($this->path, 'rb'); + if (!$pointer) { + throw new Swift_IoException('Unable to open file for reading ['.$this->path.']'); + } + $this->reader = $pointer; + if (0 != $this->offset) { + $this->getReadStreamSeekableStatus(); + $this->seekReadStreamToPosition($this->offset); + } + } - return $this->reader; - } + return $this->reader; + } - /** Get the resource for writing */ - private function getWriteHandle() - { - if (!isset($this->writer)) { - if (!$this->writer = fopen($this->path, $this->mode)) { - throw new Swift_IoException('Unable to open file for writing ['.$this->path.']'); - } - } + /** Get the resource for writing */ + private function getWriteHandle() + { + if (!isset($this->writer)) { + if (!$this->writer = fopen($this->path, $this->mode)) { + throw new Swift_IoException('Unable to open file for writing ['.$this->path.']'); + } + } - return $this->writer; - } + return $this->writer; + } - /** Force a reload of the resource for reading */ - private function resetReadHandle() - { - if (isset($this->reader)) { - fclose($this->reader); - $this->reader = null; - } - } + /** Force a reload of the resource for reading */ + private function resetReadHandle() + { + if (isset($this->reader)) { + fclose($this->reader); + $this->reader = null; + } + } - /** Check if ReadOnly Stream is seekable */ - private function getReadStreamSeekableStatus() - { - $metas = stream_get_meta_data($this->reader); - $this->seekable = $metas['seekable']; - } + /** Check if ReadOnly Stream is seekable */ + private function getReadStreamSeekableStatus() + { + $metas = stream_get_meta_data($this->reader); + $this->seekable = $metas['seekable']; + } - /** Streams in a readOnly stream ensuring copy if needed */ - private function seekReadStreamToPosition($offset) - { - if (null === $this->seekable) { - $this->getReadStreamSeekableStatus(); - } - if (false === $this->seekable) { - $currentPos = ftell($this->reader); - if ($currentPos < $offset) { - $toDiscard = $offset - $currentPos; - fread($this->reader, $toDiscard); + /** Streams in a readOnly stream ensuring copy if needed */ + private function seekReadStreamToPosition($offset) + { + if (null === $this->seekable) { + $this->getReadStreamSeekableStatus(); + } + if (false === $this->seekable) { + $currentPos = ftell($this->reader); + if ($currentPos < $offset) { + $toDiscard = $offset - $currentPos; + fread($this->reader, $toDiscard); - return; - } - $this->copyReadStream(); - } - fseek($this->reader, $offset, SEEK_SET); - } + return; + } + $this->copyReadStream(); + } + fseek($this->reader, $offset, SEEK_SET); + } - /** Copy a readOnly Stream to ensure seekability */ - private function copyReadStream() - { - if ($tmpFile = fopen('php://temp/maxmemory:4096', 'w+b')) { - /* We have opened a php:// Stream Should work without problem */ - } elseif (\function_exists('sys_get_temp_dir') && is_writable(sys_get_temp_dir()) && ($tmpFile = tmpfile())) { - /* We have opened a tmpfile */ - } else { - throw new Swift_IoException('Unable to copy the file to make it seekable, sys_temp_dir is not writable, php://memory not available'); - } - $currentPos = ftell($this->reader); - fclose($this->reader); - $source = fopen($this->path, 'rb'); - if (!$source) { - throw new Swift_IoException('Unable to open file for copying ['.$this->path.']'); - } - fseek($tmpFile, 0, SEEK_SET); - while (!feof($source)) { - fwrite($tmpFile, fread($source, 4096)); - } - fseek($tmpFile, $currentPos, SEEK_SET); - fclose($source); - $this->reader = $tmpFile; - } + /** Copy a readOnly Stream to ensure seekability */ + private function copyReadStream() + { + if ($tmpFile = fopen('php://temp/maxmemory:4096', 'w+b')) { + /* We have opened a php:// Stream Should work without problem */ + } elseif (\function_exists('sys_get_temp_dir') && is_writable(sys_get_temp_dir()) && ($tmpFile = tmpfile())) { + /* We have opened a tmpfile */ + } else { + throw new Swift_IoException('Unable to copy the file to make it seekable, sys_temp_dir is not writable, php://memory not available'); + } + $currentPos = ftell($this->reader); + fclose($this->reader); + $source = fopen($this->path, 'rb'); + if (!$source) { + throw new Swift_IoException('Unable to open file for copying ['.$this->path.']'); + } + fseek($tmpFile, 0, SEEK_SET); + while (!feof($source)) { + fwrite($tmpFile, fread($source, 4096)); + } + fseek($tmpFile, $currentPos, SEEK_SET); + fclose($source); + $this->reader = $tmpFile; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/TemporaryFileByteStream.php b/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/TemporaryFileByteStream.php index 0dc61909d31..5ea62c5a389 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/TemporaryFileByteStream.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/TemporaryFileByteStream.php @@ -13,40 +13,40 @@ */ class Swift_ByteStream_TemporaryFileByteStream extends Swift_ByteStream_FileByteStream { - public function __construct() - { - $filePath = tempnam(sys_get_temp_dir(), 'FileByteStream'); + public function __construct() + { + $filePath = tempnam(sys_get_temp_dir(), 'FileByteStream'); - if (false === $filePath) { - throw new Swift_IoException('Failed to retrieve temporary file name.'); - } + if (false === $filePath) { + throw new Swift_IoException('Failed to retrieve temporary file name.'); + } - parent::__construct($filePath, true); - } + parent::__construct($filePath, true); + } - public function getContent() - { - if (false === ($content = file_get_contents($this->getPath()))) { - throw new Swift_IoException('Failed to get temporary file content.'); - } + public function getContent() + { + if (false === ($content = file_get_contents($this->getPath()))) { + throw new Swift_IoException('Failed to get temporary file content.'); + } - return $content; - } + return $content; + } - public function __destruct() - { - if (file_exists($this->getPath())) { - @unlink($this->getPath()); - } - } + public function __destruct() + { + if (file_exists($this->getPath())) { + @unlink($this->getPath()); + } + } - public function __sleep() - { - throw new \BadMethodCallException('Cannot serialize '.__CLASS__); - } + public function __sleep() + { + throw new \BadMethodCallException('Cannot serialize '.__CLASS__); + } - public function __wakeup() - { - throw new \BadMethodCallException('Cannot unserialize '.__CLASS__); - } + public function __wakeup() + { + throw new \BadMethodCallException('Cannot unserialize '.__CLASS__); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReader/GenericFixedWidthReader.php b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReader/GenericFixedWidthReader.php index 3e055afd9dc..3e074eaf4e9 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReader/GenericFixedWidthReader.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReader/GenericFixedWidthReader.php @@ -16,82 +16,82 @@ */ class Swift_CharacterReader_GenericFixedWidthReader implements Swift_CharacterReader { - /** - * The number of bytes in a single character. - * - * @var int - */ - private $width; + /** + * The number of bytes in a single character. + * + * @var int + */ + private $width; - /** - * Creates a new GenericFixedWidthReader using $width bytes per character. - * - * @param int $width - */ - public function __construct($width) - { - $this->width = $width; - } + /** + * Creates a new GenericFixedWidthReader using $width bytes per character. + * + * @param int $width + */ + public function __construct($width) + { + $this->width = $width; + } - /** - * Returns the complete character map. - * - * @param string $string - * @param int $startOffset - * @param array $currentMap - * @param mixed $ignoredChars - * - * @return int - */ - public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars) - { - $strlen = \strlen($string); - // % and / are CPU intensive, so, maybe find a better way - $ignored = $strlen % $this->width; - $ignoredChars = $ignored ? substr($string, -$ignored) : ''; - $currentMap = $this->width; + /** + * Returns the complete character map. + * + * @param string $string + * @param int $startOffset + * @param array $currentMap + * @param mixed $ignoredChars + * + * @return int + */ + public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars) + { + $strlen = \strlen($string); + // % and / are CPU intensive, so, maybe find a better way + $ignored = $strlen % $this->width; + $ignoredChars = $ignored ? substr($string, -$ignored) : ''; + $currentMap = $this->width; - return ($strlen - $ignored) / $this->width; - } + return ($strlen - $ignored) / $this->width; + } - /** - * Returns the mapType. - * - * @return int - */ - public function getMapType() - { - return self::MAP_TYPE_FIXED_LEN; - } + /** + * Returns the mapType. + * + * @return int + */ + public function getMapType() + { + return self::MAP_TYPE_FIXED_LEN; + } - /** - * Returns an integer which specifies how many more bytes to read. - * - * A positive integer indicates the number of more bytes to fetch before invoking - * this method again. - * - * A value of zero means this is already a valid character. - * A value of -1 means this cannot possibly be a valid character. - * - * @param string $bytes - * @param int $size - * - * @return int - */ - public function validateByteSequence($bytes, $size) - { - $needed = $this->width - $size; + /** + * Returns an integer which specifies how many more bytes to read. + * + * A positive integer indicates the number of more bytes to fetch before invoking + * this method again. + * + * A value of zero means this is already a valid character. + * A value of -1 means this cannot possibly be a valid character. + * + * @param string $bytes + * @param int $size + * + * @return int + */ + public function validateByteSequence($bytes, $size) + { + $needed = $this->width - $size; - return $needed > -1 ? $needed : -1; - } + return $needed > -1 ? $needed : -1; + } - /** - * Returns the number of bytes which should be read to start each character. - * - * @return int - */ - public function getInitialByteSize() - { - return $this->width; - } + /** + * Returns the number of bytes which should be read to start each character. + * + * @return int + */ + public function getInitialByteSize() + { + return $this->width; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReader/UsAsciiReader.php b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReader/UsAsciiReader.php index ffc05f7166a..7ddc72a6610 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReader/UsAsciiReader.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReader/UsAsciiReader.php @@ -15,70 +15,70 @@ */ class Swift_CharacterReader_UsAsciiReader implements Swift_CharacterReader { - /** - * Returns the complete character map. - * - * @param string $string - * @param int $startOffset - * @param array $currentMap - * @param string $ignoredChars - * - * @return int - */ - public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars) - { - $strlen = \strlen($string); - $ignoredChars = ''; - for ($i = 0; $i < $strlen; ++$i) { - if ($string[$i] > "\x07F") { - // Invalid char - $currentMap[$i + $startOffset] = $string[$i]; - } - } + /** + * Returns the complete character map. + * + * @param string $string + * @param int $startOffset + * @param array $currentMap + * @param string $ignoredChars + * + * @return int + */ + public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars) + { + $strlen = \strlen($string); + $ignoredChars = ''; + for ($i = 0; $i < $strlen; ++$i) { + if ($string[$i] > "\x07F") { + // Invalid char + $currentMap[$i + $startOffset] = $string[$i]; + } + } - return $strlen; - } + return $strlen; + } - /** - * Returns mapType. - * - * @return int mapType - */ - public function getMapType() - { - return self::MAP_TYPE_INVALID; - } + /** + * Returns mapType. + * + * @return int mapType + */ + public function getMapType() + { + return self::MAP_TYPE_INVALID; + } - /** - * Returns an integer which specifies how many more bytes to read. - * - * A positive integer indicates the number of more bytes to fetch before invoking - * this method again. - * A value of zero means this is already a valid character. - * A value of -1 means this cannot possibly be a valid character. - * - * @param string $bytes - * @param int $size - * - * @return int - */ - public function validateByteSequence($bytes, $size) - { - $byte = reset($bytes); - if (1 == \count($bytes) && $byte >= 0x00 && $byte <= 0x7F) { - return 0; - } + /** + * Returns an integer which specifies how many more bytes to read. + * + * A positive integer indicates the number of more bytes to fetch before invoking + * this method again. + * A value of zero means this is already a valid character. + * A value of -1 means this cannot possibly be a valid character. + * + * @param string $bytes + * @param int $size + * + * @return int + */ + public function validateByteSequence($bytes, $size) + { + $byte = reset($bytes); + if (1 == \count($bytes) && $byte >= 0x00 && $byte <= 0x7F) { + return 0; + } - return -1; - } + return -1; + } - /** - * Returns the number of bytes which should be read to start each character. - * - * @return int - */ - public function getInitialByteSize() - { - return 1; - } + /** + * Returns the number of bytes which should be read to start each character. + * + * @return int + */ + public function getInitialByteSize() + { + return 1; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReader/Utf8Reader.php b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReader/Utf8Reader.php index da37e0da9ab..f828f151121 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReader/Utf8Reader.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReader/Utf8Reader.php @@ -16,161 +16,161 @@ */ class Swift_CharacterReader_Utf8Reader implements Swift_CharacterReader { - /** Pre-computed for optimization */ - private static $length_map = [ - // N=0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x0N - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x1N - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x2N - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x3N - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x4N - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x5N - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x6N - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x7N - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x8N - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x9N - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xAN - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xBN - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xCN - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xDN - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 0xEN - 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 0, 0, // 0xFN - ]; + /** Pre-computed for optimization */ + private static $length_map = [ + // N=0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x0N + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x1N + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x2N + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x3N + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x4N + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x5N + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x6N + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x7N + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x8N + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x9N + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xAN + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xBN + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xCN + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xDN + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 0xEN + 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 0, 0, // 0xFN + ]; - private static $s_length_map = [ - "\x00" => 1, "\x01" => 1, "\x02" => 1, "\x03" => 1, "\x04" => 1, "\x05" => 1, "\x06" => 1, "\x07" => 1, - "\x08" => 1, "\x09" => 1, "\x0a" => 1, "\x0b" => 1, "\x0c" => 1, "\x0d" => 1, "\x0e" => 1, "\x0f" => 1, - "\x10" => 1, "\x11" => 1, "\x12" => 1, "\x13" => 1, "\x14" => 1, "\x15" => 1, "\x16" => 1, "\x17" => 1, - "\x18" => 1, "\x19" => 1, "\x1a" => 1, "\x1b" => 1, "\x1c" => 1, "\x1d" => 1, "\x1e" => 1, "\x1f" => 1, - "\x20" => 1, "\x21" => 1, "\x22" => 1, "\x23" => 1, "\x24" => 1, "\x25" => 1, "\x26" => 1, "\x27" => 1, - "\x28" => 1, "\x29" => 1, "\x2a" => 1, "\x2b" => 1, "\x2c" => 1, "\x2d" => 1, "\x2e" => 1, "\x2f" => 1, - "\x30" => 1, "\x31" => 1, "\x32" => 1, "\x33" => 1, "\x34" => 1, "\x35" => 1, "\x36" => 1, "\x37" => 1, - "\x38" => 1, "\x39" => 1, "\x3a" => 1, "\x3b" => 1, "\x3c" => 1, "\x3d" => 1, "\x3e" => 1, "\x3f" => 1, - "\x40" => 1, "\x41" => 1, "\x42" => 1, "\x43" => 1, "\x44" => 1, "\x45" => 1, "\x46" => 1, "\x47" => 1, - "\x48" => 1, "\x49" => 1, "\x4a" => 1, "\x4b" => 1, "\x4c" => 1, "\x4d" => 1, "\x4e" => 1, "\x4f" => 1, - "\x50" => 1, "\x51" => 1, "\x52" => 1, "\x53" => 1, "\x54" => 1, "\x55" => 1, "\x56" => 1, "\x57" => 1, - "\x58" => 1, "\x59" => 1, "\x5a" => 1, "\x5b" => 1, "\x5c" => 1, "\x5d" => 1, "\x5e" => 1, "\x5f" => 1, - "\x60" => 1, "\x61" => 1, "\x62" => 1, "\x63" => 1, "\x64" => 1, "\x65" => 1, "\x66" => 1, "\x67" => 1, - "\x68" => 1, "\x69" => 1, "\x6a" => 1, "\x6b" => 1, "\x6c" => 1, "\x6d" => 1, "\x6e" => 1, "\x6f" => 1, - "\x70" => 1, "\x71" => 1, "\x72" => 1, "\x73" => 1, "\x74" => 1, "\x75" => 1, "\x76" => 1, "\x77" => 1, - "\x78" => 1, "\x79" => 1, "\x7a" => 1, "\x7b" => 1, "\x7c" => 1, "\x7d" => 1, "\x7e" => 1, "\x7f" => 1, - "\x80" => 0, "\x81" => 0, "\x82" => 0, "\x83" => 0, "\x84" => 0, "\x85" => 0, "\x86" => 0, "\x87" => 0, - "\x88" => 0, "\x89" => 0, "\x8a" => 0, "\x8b" => 0, "\x8c" => 0, "\x8d" => 0, "\x8e" => 0, "\x8f" => 0, - "\x90" => 0, "\x91" => 0, "\x92" => 0, "\x93" => 0, "\x94" => 0, "\x95" => 0, "\x96" => 0, "\x97" => 0, - "\x98" => 0, "\x99" => 0, "\x9a" => 0, "\x9b" => 0, "\x9c" => 0, "\x9d" => 0, "\x9e" => 0, "\x9f" => 0, - "\xa0" => 0, "\xa1" => 0, "\xa2" => 0, "\xa3" => 0, "\xa4" => 0, "\xa5" => 0, "\xa6" => 0, "\xa7" => 0, - "\xa8" => 0, "\xa9" => 0, "\xaa" => 0, "\xab" => 0, "\xac" => 0, "\xad" => 0, "\xae" => 0, "\xaf" => 0, - "\xb0" => 0, "\xb1" => 0, "\xb2" => 0, "\xb3" => 0, "\xb4" => 0, "\xb5" => 0, "\xb6" => 0, "\xb7" => 0, - "\xb8" => 0, "\xb9" => 0, "\xba" => 0, "\xbb" => 0, "\xbc" => 0, "\xbd" => 0, "\xbe" => 0, "\xbf" => 0, - "\xc0" => 2, "\xc1" => 2, "\xc2" => 2, "\xc3" => 2, "\xc4" => 2, "\xc5" => 2, "\xc6" => 2, "\xc7" => 2, - "\xc8" => 2, "\xc9" => 2, "\xca" => 2, "\xcb" => 2, "\xcc" => 2, "\xcd" => 2, "\xce" => 2, "\xcf" => 2, - "\xd0" => 2, "\xd1" => 2, "\xd2" => 2, "\xd3" => 2, "\xd4" => 2, "\xd5" => 2, "\xd6" => 2, "\xd7" => 2, - "\xd8" => 2, "\xd9" => 2, "\xda" => 2, "\xdb" => 2, "\xdc" => 2, "\xdd" => 2, "\xde" => 2, "\xdf" => 2, - "\xe0" => 3, "\xe1" => 3, "\xe2" => 3, "\xe3" => 3, "\xe4" => 3, "\xe5" => 3, "\xe6" => 3, "\xe7" => 3, - "\xe8" => 3, "\xe9" => 3, "\xea" => 3, "\xeb" => 3, "\xec" => 3, "\xed" => 3, "\xee" => 3, "\xef" => 3, - "\xf0" => 4, "\xf1" => 4, "\xf2" => 4, "\xf3" => 4, "\xf4" => 4, "\xf5" => 4, "\xf6" => 4, "\xf7" => 4, - "\xf8" => 5, "\xf9" => 5, "\xfa" => 5, "\xfb" => 5, "\xfc" => 6, "\xfd" => 6, "\xfe" => 0, "\xff" => 0, - ]; + private static $s_length_map = [ + "\x00" => 1, "\x01" => 1, "\x02" => 1, "\x03" => 1, "\x04" => 1, "\x05" => 1, "\x06" => 1, "\x07" => 1, + "\x08" => 1, "\x09" => 1, "\x0a" => 1, "\x0b" => 1, "\x0c" => 1, "\x0d" => 1, "\x0e" => 1, "\x0f" => 1, + "\x10" => 1, "\x11" => 1, "\x12" => 1, "\x13" => 1, "\x14" => 1, "\x15" => 1, "\x16" => 1, "\x17" => 1, + "\x18" => 1, "\x19" => 1, "\x1a" => 1, "\x1b" => 1, "\x1c" => 1, "\x1d" => 1, "\x1e" => 1, "\x1f" => 1, + "\x20" => 1, "\x21" => 1, "\x22" => 1, "\x23" => 1, "\x24" => 1, "\x25" => 1, "\x26" => 1, "\x27" => 1, + "\x28" => 1, "\x29" => 1, "\x2a" => 1, "\x2b" => 1, "\x2c" => 1, "\x2d" => 1, "\x2e" => 1, "\x2f" => 1, + "\x30" => 1, "\x31" => 1, "\x32" => 1, "\x33" => 1, "\x34" => 1, "\x35" => 1, "\x36" => 1, "\x37" => 1, + "\x38" => 1, "\x39" => 1, "\x3a" => 1, "\x3b" => 1, "\x3c" => 1, "\x3d" => 1, "\x3e" => 1, "\x3f" => 1, + "\x40" => 1, "\x41" => 1, "\x42" => 1, "\x43" => 1, "\x44" => 1, "\x45" => 1, "\x46" => 1, "\x47" => 1, + "\x48" => 1, "\x49" => 1, "\x4a" => 1, "\x4b" => 1, "\x4c" => 1, "\x4d" => 1, "\x4e" => 1, "\x4f" => 1, + "\x50" => 1, "\x51" => 1, "\x52" => 1, "\x53" => 1, "\x54" => 1, "\x55" => 1, "\x56" => 1, "\x57" => 1, + "\x58" => 1, "\x59" => 1, "\x5a" => 1, "\x5b" => 1, "\x5c" => 1, "\x5d" => 1, "\x5e" => 1, "\x5f" => 1, + "\x60" => 1, "\x61" => 1, "\x62" => 1, "\x63" => 1, "\x64" => 1, "\x65" => 1, "\x66" => 1, "\x67" => 1, + "\x68" => 1, "\x69" => 1, "\x6a" => 1, "\x6b" => 1, "\x6c" => 1, "\x6d" => 1, "\x6e" => 1, "\x6f" => 1, + "\x70" => 1, "\x71" => 1, "\x72" => 1, "\x73" => 1, "\x74" => 1, "\x75" => 1, "\x76" => 1, "\x77" => 1, + "\x78" => 1, "\x79" => 1, "\x7a" => 1, "\x7b" => 1, "\x7c" => 1, "\x7d" => 1, "\x7e" => 1, "\x7f" => 1, + "\x80" => 0, "\x81" => 0, "\x82" => 0, "\x83" => 0, "\x84" => 0, "\x85" => 0, "\x86" => 0, "\x87" => 0, + "\x88" => 0, "\x89" => 0, "\x8a" => 0, "\x8b" => 0, "\x8c" => 0, "\x8d" => 0, "\x8e" => 0, "\x8f" => 0, + "\x90" => 0, "\x91" => 0, "\x92" => 0, "\x93" => 0, "\x94" => 0, "\x95" => 0, "\x96" => 0, "\x97" => 0, + "\x98" => 0, "\x99" => 0, "\x9a" => 0, "\x9b" => 0, "\x9c" => 0, "\x9d" => 0, "\x9e" => 0, "\x9f" => 0, + "\xa0" => 0, "\xa1" => 0, "\xa2" => 0, "\xa3" => 0, "\xa4" => 0, "\xa5" => 0, "\xa6" => 0, "\xa7" => 0, + "\xa8" => 0, "\xa9" => 0, "\xaa" => 0, "\xab" => 0, "\xac" => 0, "\xad" => 0, "\xae" => 0, "\xaf" => 0, + "\xb0" => 0, "\xb1" => 0, "\xb2" => 0, "\xb3" => 0, "\xb4" => 0, "\xb5" => 0, "\xb6" => 0, "\xb7" => 0, + "\xb8" => 0, "\xb9" => 0, "\xba" => 0, "\xbb" => 0, "\xbc" => 0, "\xbd" => 0, "\xbe" => 0, "\xbf" => 0, + "\xc0" => 2, "\xc1" => 2, "\xc2" => 2, "\xc3" => 2, "\xc4" => 2, "\xc5" => 2, "\xc6" => 2, "\xc7" => 2, + "\xc8" => 2, "\xc9" => 2, "\xca" => 2, "\xcb" => 2, "\xcc" => 2, "\xcd" => 2, "\xce" => 2, "\xcf" => 2, + "\xd0" => 2, "\xd1" => 2, "\xd2" => 2, "\xd3" => 2, "\xd4" => 2, "\xd5" => 2, "\xd6" => 2, "\xd7" => 2, + "\xd8" => 2, "\xd9" => 2, "\xda" => 2, "\xdb" => 2, "\xdc" => 2, "\xdd" => 2, "\xde" => 2, "\xdf" => 2, + "\xe0" => 3, "\xe1" => 3, "\xe2" => 3, "\xe3" => 3, "\xe4" => 3, "\xe5" => 3, "\xe6" => 3, "\xe7" => 3, + "\xe8" => 3, "\xe9" => 3, "\xea" => 3, "\xeb" => 3, "\xec" => 3, "\xed" => 3, "\xee" => 3, "\xef" => 3, + "\xf0" => 4, "\xf1" => 4, "\xf2" => 4, "\xf3" => 4, "\xf4" => 4, "\xf5" => 4, "\xf6" => 4, "\xf7" => 4, + "\xf8" => 5, "\xf9" => 5, "\xfa" => 5, "\xfb" => 5, "\xfc" => 6, "\xfd" => 6, "\xfe" => 0, "\xff" => 0, + ]; - /** - * Returns the complete character map. - * - * @param string $string - * @param int $startOffset - * @param array $currentMap - * @param mixed $ignoredChars - * - * @return int - */ - public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars) - { - if (!isset($currentMap['i']) || !isset($currentMap['p'])) { - $currentMap['p'] = $currentMap['i'] = []; - } + /** + * Returns the complete character map. + * + * @param string $string + * @param int $startOffset + * @param array $currentMap + * @param mixed $ignoredChars + * + * @return int + */ + public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars) + { + if (!isset($currentMap['i']) || !isset($currentMap['p'])) { + $currentMap['p'] = $currentMap['i'] = []; + } - $strlen = \strlen($string); - $charPos = \count($currentMap['p']); - $foundChars = 0; - $invalid = false; - for ($i = 0; $i < $strlen; ++$i) { - $char = $string[$i]; - $size = self::$s_length_map[$char]; - if (0 == $size) { - /* char is invalid, we must wait for a resync */ - $invalid = true; - continue; - } else { - if (true === $invalid) { - /* We mark the chars as invalid and start a new char */ - $currentMap['p'][$charPos + $foundChars] = $startOffset + $i; - $currentMap['i'][$charPos + $foundChars] = true; - ++$foundChars; - $invalid = false; - } - if (($i + $size) > $strlen) { - $ignoredChars = substr($string, $i); - break; - } - for ($j = 1; $j < $size; ++$j) { - $char = $string[$i + $j]; - if ($char > "\x7F" && $char < "\xC0") { - // Valid - continue parsing - } else { - /* char is invalid, we must wait for a resync */ - $invalid = true; - continue 2; - } - } - /* Ok we got a complete char here */ - $currentMap['p'][$charPos + $foundChars] = $startOffset + $i + $size; - $i += $j - 1; - ++$foundChars; - } - } + $strlen = \strlen($string); + $charPos = \count($currentMap['p']); + $foundChars = 0; + $invalid = false; + for ($i = 0; $i < $strlen; ++$i) { + $char = $string[$i]; + $size = self::$s_length_map[$char]; + if (0 == $size) { + /* char is invalid, we must wait for a resync */ + $invalid = true; + continue; + } else { + if (true === $invalid) { + /* We mark the chars as invalid and start a new char */ + $currentMap['p'][$charPos + $foundChars] = $startOffset + $i; + $currentMap['i'][$charPos + $foundChars] = true; + ++$foundChars; + $invalid = false; + } + if (($i + $size) > $strlen) { + $ignoredChars = substr($string, $i); + break; + } + for ($j = 1; $j < $size; ++$j) { + $char = $string[$i + $j]; + if ($char > "\x7F" && $char < "\xC0") { + // Valid - continue parsing + } else { + /* char is invalid, we must wait for a resync */ + $invalid = true; + continue 2; + } + } + /* Ok we got a complete char here */ + $currentMap['p'][$charPos + $foundChars] = $startOffset + $i + $size; + $i += $j - 1; + ++$foundChars; + } + } - return $foundChars; - } + return $foundChars; + } - /** - * Returns mapType. - * - * @return int mapType - */ - public function getMapType() - { - return self::MAP_TYPE_POSITIONS; - } + /** + * Returns mapType. + * + * @return int mapType + */ + public function getMapType() + { + return self::MAP_TYPE_POSITIONS; + } - /** - * Returns an integer which specifies how many more bytes to read. - * - * A positive integer indicates the number of more bytes to fetch before invoking - * this method again. - * A value of zero means this is already a valid character. - * A value of -1 means this cannot possibly be a valid character. - * - * @param string $bytes - * @param int $size - * - * @return int - */ - public function validateByteSequence($bytes, $size) - { - if ($size < 1) { - return -1; - } - $needed = self::$length_map[$bytes[0]] - $size; + /** + * Returns an integer which specifies how many more bytes to read. + * + * A positive integer indicates the number of more bytes to fetch before invoking + * this method again. + * A value of zero means this is already a valid character. + * A value of -1 means this cannot possibly be a valid character. + * + * @param string $bytes + * @param int $size + * + * @return int + */ + public function validateByteSequence($bytes, $size) + { + if ($size < 1) { + return -1; + } + $needed = self::$length_map[$bytes[0]] - $size; - return $needed > -1 ? $needed : -1; - } + return $needed > -1 ? $needed : -1; + } - /** - * Returns the number of bytes which should be read to start each character. - * - * @return int - */ - public function getInitialByteSize() - { - return 1; - } + /** + * Returns the number of bytes which should be read to start each character. + * + * @return int + */ + public function getInitialByteSize() + { + return 1; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php index 86900894ab1..97b3b097f3d 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php @@ -15,110 +15,110 @@ */ class Swift_CharacterReaderFactory_SimpleCharacterReaderFactory implements Swift_CharacterReaderFactory { - /** - * A map of charset patterns to their implementation classes. - * - * @var array - */ - private static $map = []; + /** + * A map of charset patterns to their implementation classes. + * + * @var array + */ + private static $map = []; - /** - * Factories which have already been loaded. - * - * @var Swift_CharacterReaderFactory[] - */ - private static $loaded = []; + /** + * Factories which have already been loaded. + * + * @var Swift_CharacterReaderFactory[] + */ + private static $loaded = []; - /** - * Creates a new CharacterReaderFactory. - */ - public function __construct() - { - $this->init(); - } + /** + * Creates a new CharacterReaderFactory. + */ + public function __construct() + { + $this->init(); + } - public function __wakeup() - { - $this->init(); - } + public function __wakeup() + { + $this->init(); + } - public function init() - { - if (\count(self::$map) > 0) { - return; - } + public function init() + { + if (\count(self::$map) > 0) { + return; + } - $prefix = 'Swift_CharacterReader_'; + $prefix = 'Swift_CharacterReader_'; - $singleByte = [ - 'class' => $prefix.'GenericFixedWidthReader', - 'constructor' => [1], - ]; + $singleByte = [ + 'class' => $prefix.'GenericFixedWidthReader', + 'constructor' => [1], + ]; - $doubleByte = [ - 'class' => $prefix.'GenericFixedWidthReader', - 'constructor' => [2], - ]; + $doubleByte = [ + 'class' => $prefix.'GenericFixedWidthReader', + 'constructor' => [2], + ]; - $fourBytes = [ - 'class' => $prefix.'GenericFixedWidthReader', - 'constructor' => [4], - ]; + $fourBytes = [ + 'class' => $prefix.'GenericFixedWidthReader', + 'constructor' => [4], + ]; - // Utf-8 - self::$map['utf-?8'] = [ - 'class' => $prefix.'Utf8Reader', - 'constructor' => [], - ]; + // Utf-8 + self::$map['utf-?8'] = [ + 'class' => $prefix.'Utf8Reader', + 'constructor' => [], + ]; - //7-8 bit charsets - self::$map['(us-)?ascii'] = $singleByte; - self::$map['(iso|iec)-?8859-?[0-9]+'] = $singleByte; - self::$map['windows-?125[0-9]'] = $singleByte; - self::$map['cp-?[0-9]+'] = $singleByte; - self::$map['ansi'] = $singleByte; - self::$map['macintosh'] = $singleByte; - self::$map['koi-?7'] = $singleByte; - self::$map['koi-?8-?.+'] = $singleByte; - self::$map['mik'] = $singleByte; - self::$map['(cork|t1)'] = $singleByte; - self::$map['v?iscii'] = $singleByte; + //7-8 bit charsets + self::$map['(us-)?ascii'] = $singleByte; + self::$map['(iso|iec)-?8859-?[0-9]+'] = $singleByte; + self::$map['windows-?125[0-9]'] = $singleByte; + self::$map['cp-?[0-9]+'] = $singleByte; + self::$map['ansi'] = $singleByte; + self::$map['macintosh'] = $singleByte; + self::$map['koi-?7'] = $singleByte; + self::$map['koi-?8-?.+'] = $singleByte; + self::$map['mik'] = $singleByte; + self::$map['(cork|t1)'] = $singleByte; + self::$map['v?iscii'] = $singleByte; - //16 bits - self::$map['(ucs-?2|utf-?16)'] = $doubleByte; + //16 bits + self::$map['(ucs-?2|utf-?16)'] = $doubleByte; - //32 bits - self::$map['(ucs-?4|utf-?32)'] = $fourBytes; + //32 bits + self::$map['(ucs-?4|utf-?32)'] = $fourBytes; - // Fallback - self::$map['.*'] = $singleByte; - } + // Fallback + self::$map['.*'] = $singleByte; + } - /** - * Returns a CharacterReader suitable for the charset applied. - * - * @param string $charset - * - * @return Swift_CharacterReader - */ - public function getReaderFor($charset) - { - $charset = strtolower(trim($charset ?? '')); - foreach (self::$map as $pattern => $spec) { - $re = '/^'.$pattern.'$/D'; - if (preg_match($re, $charset)) { - if (!\array_key_exists($pattern, self::$loaded)) { - $reflector = new ReflectionClass($spec['class']); - if ($reflector->getConstructor()) { - $reader = $reflector->newInstanceArgs($spec['constructor']); - } else { - $reader = $reflector->newInstance(); - } - self::$loaded[$pattern] = $reader; - } + /** + * Returns a CharacterReader suitable for the charset applied. + * + * @param string $charset + * + * @return Swift_CharacterReader + */ + public function getReaderFor($charset) + { + $charset = strtolower(trim($charset ?? '')); + foreach (self::$map as $pattern => $spec) { + $re = '/^'.$pattern.'$/D'; + if (preg_match($re, $charset)) { + if (!\array_key_exists($pattern, self::$loaded)) { + $reflector = new ReflectionClass($spec['class']); + if ($reflector->getConstructor()) { + $reader = $reflector->newInstanceArgs($spec['constructor']); + } else { + $reader = $reflector->newInstance(); + } + self::$loaded[$pattern] = $reader; + } - return self::$loaded[$pattern]; - } - } - } + return self::$loaded[$pattern]; + } + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterStream.php b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterStream.php index c9d8a078ee0..04e2d433934 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterStream.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterStream.php @@ -19,69 +19,69 @@ */ interface Swift_CharacterStream { - /** - * Set the character set used in this CharacterStream. - * - * @param string $charset - */ - public function setCharacterSet($charset); + /** + * Set the character set used in this CharacterStream. + * + * @param string $charset + */ + public function setCharacterSet($charset); - /** - * Set the CharacterReaderFactory for multi charset support. - */ - public function setCharacterReaderFactory(Swift_CharacterReaderFactory $factory); + /** + * Set the CharacterReaderFactory for multi charset support. + */ + public function setCharacterReaderFactory(Swift_CharacterReaderFactory $factory); - /** - * Overwrite this character stream using the byte sequence in the byte stream. - * - * @param Swift_OutputByteStream $os output stream to read from - */ - public function importByteStream(Swift_OutputByteStream $os); + /** + * Overwrite this character stream using the byte sequence in the byte stream. + * + * @param Swift_OutputByteStream $os output stream to read from + */ + public function importByteStream(Swift_OutputByteStream $os); - /** - * Import a string a bytes into this CharacterStream, overwriting any existing - * data in the stream. - * - * @param string $string - */ - public function importString($string); + /** + * Import a string a bytes into this CharacterStream, overwriting any existing + * data in the stream. + * + * @param string $string + */ + public function importString($string); - /** - * Read $length characters from the stream and move the internal pointer - * $length further into the stream. - * - * @param int $length - * - * @return string - */ - public function read($length); + /** + * Read $length characters from the stream and move the internal pointer + * $length further into the stream. + * + * @param int $length + * + * @return string + */ + public function read($length); - /** - * Read $length characters from the stream and return a 1-dimensional array - * containing there octet values. - * - * @param int $length - * - * @return int[] - */ - public function readBytes($length); + /** + * Read $length characters from the stream and return a 1-dimensional array + * containing there octet values. + * + * @param int $length + * + * @return int[] + */ + public function readBytes($length); - /** - * Write $chars to the end of the stream. - * - * @param string $chars - */ - public function write($chars); + /** + * Write $chars to the end of the stream. + * + * @param string $chars + */ + public function write($chars); - /** - * Move the internal pointer to $charOffset in the stream. - * - * @param int $charOffset - */ - public function setPointer($charOffset); + /** + * Move the internal pointer to $charOffset in the stream. + * + * @param int $charOffset + */ + public function setPointer($charOffset); - /** - * Empty the stream and reset the internal pointer. - */ - public function flushContents(); + /** + * Empty the stream and reset the internal pointer. + */ + public function flushContents(); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterStream/ArrayCharacterStream.php b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterStream/ArrayCharacterStream.php index 5c2869455b8..6f6a22e393e 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterStream/ArrayCharacterStream.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterStream/ArrayCharacterStream.php @@ -15,277 +15,277 @@ */ class Swift_CharacterStream_ArrayCharacterStream implements Swift_CharacterStream { - /** A map of byte values and their respective characters */ - private static $charMap; + /** A map of byte values and their respective characters */ + private static $charMap; - /** A map of characters and their derivative byte values */ - private static $byteMap; + /** A map of characters and their derivative byte values */ + private static $byteMap; - /** The char reader (lazy-loaded) for the current charset */ - private $charReader; + /** The char reader (lazy-loaded) for the current charset */ + private $charReader; - /** A factory for creating CharacterReader instances */ - private $charReaderFactory; + /** A factory for creating CharacterReader instances */ + private $charReaderFactory; - /** The character set this stream is using */ - private $charset; + /** The character set this stream is using */ + private $charset; - /** Array of characters */ - private $array = []; + /** Array of characters */ + private $array = []; - /** Size of the array of character */ - private $array_size = []; + /** Size of the array of character */ + private $array_size = []; - /** The current character offset in the stream */ - private $offset = 0; + /** The current character offset in the stream */ + private $offset = 0; - /** - * Create a new CharacterStream with the given $chars, if set. - * - * @param Swift_CharacterReaderFactory $factory for loading validators - * @param string $charset used in the stream - */ - public function __construct(Swift_CharacterReaderFactory $factory, $charset) - { - self::initializeMaps(); - $this->setCharacterReaderFactory($factory); - $this->setCharacterSet($charset); - } + /** + * Create a new CharacterStream with the given $chars, if set. + * + * @param Swift_CharacterReaderFactory $factory for loading validators + * @param string $charset used in the stream + */ + public function __construct(Swift_CharacterReaderFactory $factory, $charset) + { + self::initializeMaps(); + $this->setCharacterReaderFactory($factory); + $this->setCharacterSet($charset); + } - /** - * Set the character set used in this CharacterStream. - * - * @param string $charset - */ - public function setCharacterSet($charset) - { - $this->charset = $charset; - $this->charReader = null; - } + /** + * Set the character set used in this CharacterStream. + * + * @param string $charset + */ + public function setCharacterSet($charset) + { + $this->charset = $charset; + $this->charReader = null; + } - /** - * Set the CharacterReaderFactory for multi charset support. - */ - public function setCharacterReaderFactory(Swift_CharacterReaderFactory $factory) - { - $this->charReaderFactory = $factory; - } + /** + * Set the CharacterReaderFactory for multi charset support. + */ + public function setCharacterReaderFactory(Swift_CharacterReaderFactory $factory) + { + $this->charReaderFactory = $factory; + } - /** - * Overwrite this character stream using the byte sequence in the byte stream. - * - * @param Swift_OutputByteStream $os output stream to read from - */ - public function importByteStream(Swift_OutputByteStream $os) - { - if (!isset($this->charReader)) { - $this->charReader = $this->charReaderFactory - ->getReaderFor($this->charset); - } + /** + * Overwrite this character stream using the byte sequence in the byte stream. + * + * @param Swift_OutputByteStream $os output stream to read from + */ + public function importByteStream(Swift_OutputByteStream $os) + { + if (!isset($this->charReader)) { + $this->charReader = $this->charReaderFactory + ->getReaderFor($this->charset); + } - $startLength = $this->charReader->getInitialByteSize(); - while (false !== $bytes = $os->read($startLength)) { - $c = []; - for ($i = 0, $len = \strlen($bytes); $i < $len; ++$i) { - $c[] = self::$byteMap[$bytes[$i]]; - } - $size = \count($c); - $need = $this->charReader - ->validateByteSequence($c, $size); - if ($need > 0 && - false !== $bytes = $os->read($need)) { - for ($i = 0, $len = \strlen($bytes); $i < $len; ++$i) { - $c[] = self::$byteMap[$bytes[$i]]; - } - } - $this->array[] = $c; - ++$this->array_size; - } - } + $startLength = $this->charReader->getInitialByteSize(); + while (false !== $bytes = $os->read($startLength)) { + $c = []; + for ($i = 0, $len = \strlen($bytes); $i < $len; ++$i) { + $c[] = self::$byteMap[$bytes[$i]]; + } + $size = \count($c); + $need = $this->charReader + ->validateByteSequence($c, $size); + if ($need > 0 && + false !== $bytes = $os->read($need)) { + for ($i = 0, $len = \strlen($bytes); $i < $len; ++$i) { + $c[] = self::$byteMap[$bytes[$i]]; + } + } + $this->array[] = $c; + ++$this->array_size; + } + } - /** - * Import a string a bytes into this CharacterStream, overwriting any existing - * data in the stream. - * - * @param string $string - */ - public function importString($string) - { - $this->flushContents(); - $this->write($string); - } + /** + * Import a string a bytes into this CharacterStream, overwriting any existing + * data in the stream. + * + * @param string $string + */ + public function importString($string) + { + $this->flushContents(); + $this->write($string); + } - /** - * Read $length characters from the stream and move the internal pointer - * $length further into the stream. - * - * @param int $length - * - * @return string - */ - public function read($length) - { - if ($this->offset == $this->array_size) { - return false; - } + /** + * Read $length characters from the stream and move the internal pointer + * $length further into the stream. + * + * @param int $length + * + * @return string + */ + public function read($length) + { + if ($this->offset == $this->array_size) { + return false; + } - // Don't use array slice - $arrays = []; - $end = $length + $this->offset; - for ($i = $this->offset; $i < $end; ++$i) { - if (!isset($this->array[$i])) { - break; - } - $arrays[] = $this->array[$i]; - } - $this->offset += $i - $this->offset; // Limit function calls - $chars = false; - foreach ($arrays as $array) { - $chars .= implode('', array_map('chr', $array)); - } + // Don't use array slice + $arrays = []; + $end = $length + $this->offset; + for ($i = $this->offset; $i < $end; ++$i) { + if (!isset($this->array[$i])) { + break; + } + $arrays[] = $this->array[$i]; + } + $this->offset += $i - $this->offset; // Limit function calls + $chars = false; + foreach ($arrays as $array) { + $chars .= implode('', array_map('chr', $array)); + } - return $chars; - } + return $chars; + } - /** - * Read $length characters from the stream and return a 1-dimensional array - * containing there octet values. - * - * @param int $length - * - * @return int[] - */ - public function readBytes($length) - { - if ($this->offset == $this->array_size) { - return false; - } - $arrays = []; - $end = $length + $this->offset; - for ($i = $this->offset; $i < $end; ++$i) { - if (!isset($this->array[$i])) { - break; - } - $arrays[] = $this->array[$i]; - } - $this->offset += ($i - $this->offset); // Limit function calls + /** + * Read $length characters from the stream and return a 1-dimensional array + * containing there octet values. + * + * @param int $length + * + * @return int[] + */ + public function readBytes($length) + { + if ($this->offset == $this->array_size) { + return false; + } + $arrays = []; + $end = $length + $this->offset; + for ($i = $this->offset; $i < $end; ++$i) { + if (!isset($this->array[$i])) { + break; + } + $arrays[] = $this->array[$i]; + } + $this->offset += ($i - $this->offset); // Limit function calls - return array_merge(...$arrays); - } + return array_merge(...$arrays); + } - /** - * Write $chars to the end of the stream. - * - * @param string $chars - */ - public function write($chars) - { - if (!isset($this->charReader)) { - $this->charReader = $this->charReaderFactory->getReaderFor( - $this->charset); - } + /** + * Write $chars to the end of the stream. + * + * @param string $chars + */ + public function write($chars) + { + if (!isset($this->charReader)) { + $this->charReader = $this->charReaderFactory->getReaderFor( + $this->charset); + } - $startLength = $this->charReader->getInitialByteSize(); + $startLength = $this->charReader->getInitialByteSize(); - $fp = fopen('php://memory', 'w+b'); - fwrite($fp, $chars); - unset($chars); - fseek($fp, 0, SEEK_SET); + $fp = fopen('php://memory', 'w+b'); + fwrite($fp, $chars); + unset($chars); + fseek($fp, 0, SEEK_SET); - $buffer = [0]; - $buf_pos = 1; - $buf_len = 1; - $has_datas = true; - do { - $bytes = []; - // Buffer Filing - if ($buf_len - $buf_pos < $startLength) { - $buf = array_splice($buffer, $buf_pos); - $new = $this->reloadBuffer($fp, 100); - if ($new) { - $buffer = array_merge($buf, $new); - $buf_len = \count($buffer); - $buf_pos = 0; - } else { - $has_datas = false; - } - } - if ($buf_len - $buf_pos > 0) { - $size = 0; - for ($i = 0; $i < $startLength && isset($buffer[$buf_pos]); ++$i) { - ++$size; - $bytes[] = $buffer[$buf_pos++]; - } - $need = $this->charReader->validateByteSequence( - $bytes, $size); - if ($need > 0) { - if ($buf_len - $buf_pos < $need) { - $new = $this->reloadBuffer($fp, $need); + $buffer = [0]; + $buf_pos = 1; + $buf_len = 1; + $has_datas = true; + do { + $bytes = []; + // Buffer Filing + if ($buf_len - $buf_pos < $startLength) { + $buf = array_splice($buffer, $buf_pos); + $new = $this->reloadBuffer($fp, 100); + if ($new) { + $buffer = array_merge($buf, $new); + $buf_len = \count($buffer); + $buf_pos = 0; + } else { + $has_datas = false; + } + } + if ($buf_len - $buf_pos > 0) { + $size = 0; + for ($i = 0; $i < $startLength && isset($buffer[$buf_pos]); ++$i) { + ++$size; + $bytes[] = $buffer[$buf_pos++]; + } + $need = $this->charReader->validateByteSequence( + $bytes, $size); + if ($need > 0) { + if ($buf_len - $buf_pos < $need) { + $new = $this->reloadBuffer($fp, $need); - if ($new) { - $buffer = array_merge($buffer, $new); - $buf_len = \count($buffer); - } - } - for ($i = 0; $i < $need && isset($buffer[$buf_pos]); ++$i) { - $bytes[] = $buffer[$buf_pos++]; - } - } - $this->array[] = $bytes; - ++$this->array_size; - } - } while ($has_datas); + if ($new) { + $buffer = array_merge($buffer, $new); + $buf_len = \count($buffer); + } + } + for ($i = 0; $i < $need && isset($buffer[$buf_pos]); ++$i) { + $bytes[] = $buffer[$buf_pos++]; + } + } + $this->array[] = $bytes; + ++$this->array_size; + } + } while ($has_datas); - fclose($fp); - } + fclose($fp); + } - /** - * Move the internal pointer to $charOffset in the stream. - * - * @param int $charOffset - */ - public function setPointer($charOffset) - { - if ($charOffset > $this->array_size) { - $charOffset = $this->array_size; - } elseif ($charOffset < 0) { - $charOffset = 0; - } - $this->offset = $charOffset; - } + /** + * Move the internal pointer to $charOffset in the stream. + * + * @param int $charOffset + */ + public function setPointer($charOffset) + { + if ($charOffset > $this->array_size) { + $charOffset = $this->array_size; + } elseif ($charOffset < 0) { + $charOffset = 0; + } + $this->offset = $charOffset; + } - /** - * Empty the stream and reset the internal pointer. - */ - public function flushContents() - { - $this->offset = 0; - $this->array = []; - $this->array_size = 0; - } + /** + * Empty the stream and reset the internal pointer. + */ + public function flushContents() + { + $this->offset = 0; + $this->array = []; + $this->array_size = 0; + } - private function reloadBuffer($fp, $len) - { - if (!feof($fp) && false !== ($bytes = fread($fp, $len))) { - $buf = []; - for ($i = 0, $len = \strlen($bytes); $i < $len; ++$i) { - $buf[] = self::$byteMap[$bytes[$i]]; - } + private function reloadBuffer($fp, $len) + { + if (!feof($fp) && false !== ($bytes = fread($fp, $len))) { + $buf = []; + for ($i = 0, $len = \strlen($bytes); $i < $len; ++$i) { + $buf[] = self::$byteMap[$bytes[$i]]; + } - return $buf; - } + return $buf; + } - return false; - } + return false; + } - private static function initializeMaps() - { - if (!isset(self::$charMap)) { - self::$charMap = []; - for ($byte = 0; $byte < 256; ++$byte) { - self::$charMap[$byte] = \chr($byte); - } - self::$byteMap = array_flip(self::$charMap); - } - } + private static function initializeMaps() + { + if (!isset(self::$charMap)) { + self::$charMap = []; + for ($byte = 0; $byte < 256; ++$byte) { + self::$charMap[$byte] = \chr($byte); + } + self::$byteMap = array_flip(self::$charMap); + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterStream/NgCharacterStream.php b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterStream/NgCharacterStream.php index 7578dda9cac..d7110ff16ef 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterStream/NgCharacterStream.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterStream/NgCharacterStream.php @@ -15,248 +15,248 @@ */ class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream { - /** - * The char reader (lazy-loaded) for the current charset. - * - * @var Swift_CharacterReader - */ - private $charReader; + /** + * The char reader (lazy-loaded) for the current charset. + * + * @var Swift_CharacterReader + */ + private $charReader; - /** - * A factory for creating CharacterReader instances. - * - * @var Swift_CharacterReaderFactory - */ - private $charReaderFactory; + /** + * A factory for creating CharacterReader instances. + * + * @var Swift_CharacterReaderFactory + */ + private $charReaderFactory; - /** - * The character set this stream is using. - * - * @var string - */ - private $charset; + /** + * The character set this stream is using. + * + * @var string + */ + private $charset; - /** - * The data's stored as-is. - * - * @var string - */ - private $datas = ''; + /** + * The data's stored as-is. + * + * @var string + */ + private $datas = ''; - /** - * Number of bytes in the stream. - * - * @var int - */ - private $datasSize = 0; + /** + * Number of bytes in the stream. + * + * @var int + */ + private $datasSize = 0; - /** - * Map. - * - * @var mixed - */ - private $map; + /** + * Map. + * + * @var mixed + */ + private $map; - /** - * Map Type. - * - * @var int - */ - private $mapType = 0; + /** + * Map Type. + * + * @var int + */ + private $mapType = 0; - /** - * Number of characters in the stream. - * - * @var int - */ - private $charCount = 0; + /** + * Number of characters in the stream. + * + * @var int + */ + private $charCount = 0; - /** - * Position in the stream. - * - * @var int - */ - private $currentPos = 0; + /** + * Position in the stream. + * + * @var int + */ + private $currentPos = 0; - /** - * Constructor. - * - * @param string $charset - */ - public function __construct(Swift_CharacterReaderFactory $factory, $charset) - { - $this->setCharacterReaderFactory($factory); - $this->setCharacterSet($charset); - } + /** + * Constructor. + * + * @param string $charset + */ + public function __construct(Swift_CharacterReaderFactory $factory, $charset) + { + $this->setCharacterReaderFactory($factory); + $this->setCharacterSet($charset); + } - /* -- Changing parameters of the stream -- */ + /* -- Changing parameters of the stream -- */ - /** - * Set the character set used in this CharacterStream. - * - * @param string $charset - */ - public function setCharacterSet($charset) - { - $this->charset = $charset; - $this->charReader = null; - $this->mapType = 0; - } + /** + * Set the character set used in this CharacterStream. + * + * @param string $charset + */ + public function setCharacterSet($charset) + { + $this->charset = $charset; + $this->charReader = null; + $this->mapType = 0; + } - /** - * Set the CharacterReaderFactory for multi charset support. - */ - public function setCharacterReaderFactory(Swift_CharacterReaderFactory $factory) - { - $this->charReaderFactory = $factory; - } + /** + * Set the CharacterReaderFactory for multi charset support. + */ + public function setCharacterReaderFactory(Swift_CharacterReaderFactory $factory) + { + $this->charReaderFactory = $factory; + } - /** - * @see Swift_CharacterStream::flushContents() - */ - public function flushContents() - { - $this->datas = null; - $this->map = null; - $this->charCount = 0; - $this->currentPos = 0; - $this->datasSize = 0; - } + /** + * @see Swift_CharacterStream::flushContents() + */ + public function flushContents() + { + $this->datas = null; + $this->map = null; + $this->charCount = 0; + $this->currentPos = 0; + $this->datasSize = 0; + } - /** - * @see Swift_CharacterStream::importByteStream() - */ - public function importByteStream(Swift_OutputByteStream $os) - { - $this->flushContents(); - $blocks = 512; - $os->setReadPointer(0); - while (false !== ($read = $os->read($blocks))) { - $this->write($read); - } - } + /** + * @see Swift_CharacterStream::importByteStream() + */ + public function importByteStream(Swift_OutputByteStream $os) + { + $this->flushContents(); + $blocks = 512; + $os->setReadPointer(0); + while (false !== ($read = $os->read($blocks))) { + $this->write($read); + } + } - /** - * @see Swift_CharacterStream::importString() - * - * @param string $string - */ - public function importString($string) - { - $this->flushContents(); - $this->write($string); - } + /** + * @see Swift_CharacterStream::importString() + * + * @param string $string + */ + public function importString($string) + { + $this->flushContents(); + $this->write($string); + } - /** - * @see Swift_CharacterStream::read() - * - * @param int $length - * - * @return string - */ - public function read($length) - { - if ($this->currentPos >= $this->charCount) { - return false; - } - $ret = false; - $length = ($this->currentPos + $length > $this->charCount) ? $this->charCount - $this->currentPos : $length; - switch ($this->mapType) { - case Swift_CharacterReader::MAP_TYPE_FIXED_LEN: - $len = $length * $this->map; - $ret = substr($this->datas, - $this->currentPos * $this->map, - $len); - $this->currentPos += $length; - break; + /** + * @see Swift_CharacterStream::read() + * + * @param int $length + * + * @return string + */ + public function read($length) + { + if ($this->currentPos >= $this->charCount) { + return false; + } + $ret = false; + $length = ($this->currentPos + $length > $this->charCount) ? $this->charCount - $this->currentPos : $length; + switch ($this->mapType) { + case Swift_CharacterReader::MAP_TYPE_FIXED_LEN: + $len = $length * $this->map; + $ret = substr($this->datas, + $this->currentPos * $this->map, + $len); + $this->currentPos += $length; + break; - case Swift_CharacterReader::MAP_TYPE_INVALID: - $ret = ''; - for (; $this->currentPos < $length; ++$this->currentPos) { - if (isset($this->map[$this->currentPos])) { - $ret .= '?'; - } else { - $ret .= $this->datas[$this->currentPos]; - } - } - break; + case Swift_CharacterReader::MAP_TYPE_INVALID: + $ret = ''; + for (; $this->currentPos < $length; ++$this->currentPos) { + if (isset($this->map[$this->currentPos])) { + $ret .= '?'; + } else { + $ret .= $this->datas[$this->currentPos]; + } + } + break; - case Swift_CharacterReader::MAP_TYPE_POSITIONS: - $end = $this->currentPos + $length; - $end = $end > $this->charCount ? $this->charCount : $end; - $ret = ''; - $start = 0; - if ($this->currentPos > 0) { - $start = $this->map['p'][$this->currentPos - 1]; - } - $to = $start; - for (; $this->currentPos < $end; ++$this->currentPos) { - if (isset($this->map['i'][$this->currentPos])) { - $ret .= substr($this->datas, $start, $to - $start).'?'; - $start = $this->map['p'][$this->currentPos]; - } else { - $to = $this->map['p'][$this->currentPos]; - } - } - $ret .= substr($this->datas, $start, $to - $start); - break; - } + case Swift_CharacterReader::MAP_TYPE_POSITIONS: + $end = $this->currentPos + $length; + $end = $end > $this->charCount ? $this->charCount : $end; + $ret = ''; + $start = 0; + if ($this->currentPos > 0) { + $start = $this->map['p'][$this->currentPos - 1]; + } + $to = $start; + for (; $this->currentPos < $end; ++$this->currentPos) { + if (isset($this->map['i'][$this->currentPos])) { + $ret .= substr($this->datas, $start, $to - $start).'?'; + $start = $this->map['p'][$this->currentPos]; + } else { + $to = $this->map['p'][$this->currentPos]; + } + } + $ret .= substr($this->datas, $start, $to - $start); + break; + } - return $ret; - } + return $ret; + } - /** - * @see Swift_CharacterStream::readBytes() - * - * @param int $length - * - * @return int[] - */ - public function readBytes($length) - { - $read = $this->read($length); - if (false !== $read) { - $ret = array_map('ord', str_split($read, 1)); + /** + * @see Swift_CharacterStream::readBytes() + * + * @param int $length + * + * @return int[] + */ + public function readBytes($length) + { + $read = $this->read($length); + if (false !== $read) { + $ret = array_map('ord', str_split($read, 1)); - return $ret; - } + return $ret; + } - return false; - } + return false; + } - /** - * @see Swift_CharacterStream::setPointer() - * - * @param int $charOffset - */ - public function setPointer($charOffset) - { - if ($this->charCount < $charOffset) { - $charOffset = $this->charCount; - } - $this->currentPos = $charOffset; - } + /** + * @see Swift_CharacterStream::setPointer() + * + * @param int $charOffset + */ + public function setPointer($charOffset) + { + if ($this->charCount < $charOffset) { + $charOffset = $this->charCount; + } + $this->currentPos = $charOffset; + } - /** - * @see Swift_CharacterStream::write() - * - * @param string $chars - */ - public function write($chars) - { - if (!isset($this->charReader)) { - $this->charReader = $this->charReaderFactory->getReaderFor( - $this->charset); - $this->map = []; - $this->mapType = $this->charReader->getMapType(); - } - $ignored = ''; - $this->datas .= $chars; - $this->charCount += $this->charReader->getCharPositions(substr($this->datas, $this->datasSize), $this->datasSize, $this->map, $ignored); - if (false !== $ignored) { - $this->datasSize = \strlen($this->datas) - \strlen($ignored); - } else { - $this->datasSize = \strlen($this->datas); - } - } + /** + * @see Swift_CharacterStream::write() + * + * @param string $chars + */ + public function write($chars) + { + if (!isset($this->charReader)) { + $this->charReader = $this->charReaderFactory->getReaderFor( + $this->charset); + $this->map = []; + $this->mapType = $this->charReader->getMapType(); + } + $ignored = ''; + $this->datas .= $chars; + $this->charCount += $this->charReader->getCharPositions(substr($this->datas, $this->datasSize), $this->datasSize, $this->map, $ignored); + if (false !== $ignored) { + $this->datasSize = \strlen($this->datas) - \strlen($ignored); + } else { + $this->datasSize = \strlen($this->datas); + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/DependencyContainer.php b/htdocs/includes/swiftmailer/lib/classes/Swift/DependencyContainer.php index 3cc885ec03b..c617290d311 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/DependencyContainer.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/DependencyContainer.php @@ -15,373 +15,373 @@ */ class Swift_DependencyContainer { - /** Constant for literal value types */ - const TYPE_VALUE = 0x00001; + /** Constant for literal value types */ + const TYPE_VALUE = 0x00001; - /** Constant for new instance types */ - const TYPE_INSTANCE = 0x00010; + /** Constant for new instance types */ + const TYPE_INSTANCE = 0x00010; - /** Constant for shared instance types */ - const TYPE_SHARED = 0x00100; + /** Constant for shared instance types */ + const TYPE_SHARED = 0x00100; - /** Constant for aliases */ - const TYPE_ALIAS = 0x01000; + /** Constant for aliases */ + const TYPE_ALIAS = 0x01000; - /** Constant for arrays */ - const TYPE_ARRAY = 0x10000; + /** Constant for arrays */ + const TYPE_ARRAY = 0x10000; - /** Singleton instance */ - private static $instance = null; + /** Singleton instance */ + private static $instance = null; - /** The data container */ - private $store = []; + /** The data container */ + private $store = []; - /** The current endpoint in the data container */ - private $endPoint; + /** The current endpoint in the data container */ + private $endPoint; - /** - * Constructor should not be used. - * - * Use {@link getInstance()} instead. - */ - public function __construct() - { - } + /** + * Constructor should not be used. + * + * Use {@link getInstance()} instead. + */ + public function __construct() + { + } - /** - * Returns a singleton of the DependencyContainer. - * - * @return self - */ - public static function getInstance() - { - if (!isset(self::$instance)) { - self::$instance = new self(); - } + /** + * Returns a singleton of the DependencyContainer. + * + * @return self + */ + public static function getInstance() + { + if (!isset(self::$instance)) { + self::$instance = new self(); + } - return self::$instance; - } + return self::$instance; + } - /** - * List the names of all items stored in the Container. - * - * @return array - */ - public function listItems() - { - return array_keys($this->store); - } + /** + * List the names of all items stored in the Container. + * + * @return array + */ + public function listItems() + { + return array_keys($this->store); + } - /** - * Test if an item is registered in this container with the given name. - * - * @see register() - * - * @param string $itemName - * - * @return bool - */ - public function has($itemName) - { - return \array_key_exists($itemName, $this->store) - && isset($this->store[$itemName]['lookupType']); - } + /** + * Test if an item is registered in this container with the given name. + * + * @see register() + * + * @param string $itemName + * + * @return bool + */ + public function has($itemName) + { + return \array_key_exists($itemName, $this->store) + && isset($this->store[$itemName]['lookupType']); + } - /** - * Lookup the item with the given $itemName. - * - * @see register() - * - * @param string $itemName - * - * @return mixed - * - * @throws Swift_DependencyException If the dependency is not found - */ - public function lookup($itemName) - { - if (!$this->has($itemName)) { - throw new Swift_DependencyException('Cannot lookup dependency "'.$itemName.'" since it is not registered.'); - } + /** + * Lookup the item with the given $itemName. + * + * @see register() + * + * @param string $itemName + * + * @return mixed + * + * @throws Swift_DependencyException If the dependency is not found + */ + public function lookup($itemName) + { + if (!$this->has($itemName)) { + throw new Swift_DependencyException('Cannot lookup dependency "'.$itemName.'" since it is not registered.'); + } - switch ($this->store[$itemName]['lookupType']) { - case self::TYPE_ALIAS: - return $this->createAlias($itemName); - case self::TYPE_VALUE: - return $this->getValue($itemName); - case self::TYPE_INSTANCE: - return $this->createNewInstance($itemName); - case self::TYPE_SHARED: - return $this->createSharedInstance($itemName); - case self::TYPE_ARRAY: - return $this->createDependenciesFor($itemName); - } - } + switch ($this->store[$itemName]['lookupType']) { + case self::TYPE_ALIAS: + return $this->createAlias($itemName); + case self::TYPE_VALUE: + return $this->getValue($itemName); + case self::TYPE_INSTANCE: + return $this->createNewInstance($itemName); + case self::TYPE_SHARED: + return $this->createSharedInstance($itemName); + case self::TYPE_ARRAY: + return $this->createDependenciesFor($itemName); + } + } - /** - * Create an array of arguments passed to the constructor of $itemName. - * - * @param string $itemName - * - * @return array - */ - public function createDependenciesFor($itemName) - { - $args = []; - if (isset($this->store[$itemName]['args'])) { - $args = $this->resolveArgs($this->store[$itemName]['args']); - } + /** + * Create an array of arguments passed to the constructor of $itemName. + * + * @param string $itemName + * + * @return array + */ + public function createDependenciesFor($itemName) + { + $args = []; + if (isset($this->store[$itemName]['args'])) { + $args = $this->resolveArgs($this->store[$itemName]['args']); + } - return $args; - } + return $args; + } - /** - * Register a new dependency with $itemName. - * - * This method returns the current DependencyContainer instance because it - * requires the use of the fluid interface to set the specific details for the - * dependency. - * - * @see asNewInstanceOf(), asSharedInstanceOf(), asValue() - * - * @param string $itemName - * - * @return $this - */ - public function register($itemName) - { - $this->store[$itemName] = []; - $this->endPoint = &$this->store[$itemName]; + /** + * Register a new dependency with $itemName. + * + * This method returns the current DependencyContainer instance because it + * requires the use of the fluid interface to set the specific details for the + * dependency. + * + * @see asNewInstanceOf(), asSharedInstanceOf(), asValue() + * + * @param string $itemName + * + * @return $this + */ + public function register($itemName) + { + $this->store[$itemName] = []; + $this->endPoint = &$this->store[$itemName]; - return $this; - } + return $this; + } - /** - * Specify the previously registered item as a literal value. - * - * {@link register()} must be called before this will work. - * - * @param mixed $value - * - * @return $this - */ - public function asValue($value) - { - $endPoint = &$this->getEndPoint(); - $endPoint['lookupType'] = self::TYPE_VALUE; - $endPoint['value'] = $value; + /** + * Specify the previously registered item as a literal value. + * + * {@link register()} must be called before this will work. + * + * @param mixed $value + * + * @return $this + */ + public function asValue($value) + { + $endPoint = &$this->getEndPoint(); + $endPoint['lookupType'] = self::TYPE_VALUE; + $endPoint['value'] = $value; - return $this; - } + return $this; + } - /** - * Specify the previously registered item as an alias of another item. - * - * @param string $lookup - * - * @return $this - */ - public function asAliasOf($lookup) - { - $endPoint = &$this->getEndPoint(); - $endPoint['lookupType'] = self::TYPE_ALIAS; - $endPoint['ref'] = $lookup; + /** + * Specify the previously registered item as an alias of another item. + * + * @param string $lookup + * + * @return $this + */ + public function asAliasOf($lookup) + { + $endPoint = &$this->getEndPoint(); + $endPoint['lookupType'] = self::TYPE_ALIAS; + $endPoint['ref'] = $lookup; - return $this; - } + return $this; + } - /** - * Specify the previously registered item as a new instance of $className. - * - * {@link register()} must be called before this will work. - * Any arguments can be set with {@link withDependencies()}, - * {@link addConstructorValue()} or {@link addConstructorLookup()}. - * - * @see withDependencies(), addConstructorValue(), addConstructorLookup() - * - * @param string $className - * - * @return $this - */ - public function asNewInstanceOf($className) - { - $endPoint = &$this->getEndPoint(); - $endPoint['lookupType'] = self::TYPE_INSTANCE; - $endPoint['className'] = $className; + /** + * Specify the previously registered item as a new instance of $className. + * + * {@link register()} must be called before this will work. + * Any arguments can be set with {@link withDependencies()}, + * {@link addConstructorValue()} or {@link addConstructorLookup()}. + * + * @see withDependencies(), addConstructorValue(), addConstructorLookup() + * + * @param string $className + * + * @return $this + */ + public function asNewInstanceOf($className) + { + $endPoint = &$this->getEndPoint(); + $endPoint['lookupType'] = self::TYPE_INSTANCE; + $endPoint['className'] = $className; - return $this; - } + return $this; + } - /** - * Specify the previously registered item as a shared instance of $className. - * - * {@link register()} must be called before this will work. - * - * @param string $className - * - * @return $this - */ - public function asSharedInstanceOf($className) - { - $endPoint = &$this->getEndPoint(); - $endPoint['lookupType'] = self::TYPE_SHARED; - $endPoint['className'] = $className; + /** + * Specify the previously registered item as a shared instance of $className. + * + * {@link register()} must be called before this will work. + * + * @param string $className + * + * @return $this + */ + public function asSharedInstanceOf($className) + { + $endPoint = &$this->getEndPoint(); + $endPoint['lookupType'] = self::TYPE_SHARED; + $endPoint['className'] = $className; - return $this; - } + return $this; + } - /** - * Specify the previously registered item as array of dependencies. - * - * {@link register()} must be called before this will work. - * - * @return $this - */ - public function asArray() - { - $endPoint = &$this->getEndPoint(); - $endPoint['lookupType'] = self::TYPE_ARRAY; + /** + * Specify the previously registered item as array of dependencies. + * + * {@link register()} must be called before this will work. + * + * @return $this + */ + public function asArray() + { + $endPoint = &$this->getEndPoint(); + $endPoint['lookupType'] = self::TYPE_ARRAY; - return $this; - } + return $this; + } - /** - * Specify a list of injected dependencies for the previously registered item. - * - * This method takes an array of lookup names. - * - * @see addConstructorValue(), addConstructorLookup() - * - * @return $this - */ - public function withDependencies(array $lookups) - { - $endPoint = &$this->getEndPoint(); - $endPoint['args'] = []; - foreach ($lookups as $lookup) { - $this->addConstructorLookup($lookup); - } + /** + * Specify a list of injected dependencies for the previously registered item. + * + * This method takes an array of lookup names. + * + * @see addConstructorValue(), addConstructorLookup() + * + * @return $this + */ + public function withDependencies(array $lookups) + { + $endPoint = &$this->getEndPoint(); + $endPoint['args'] = []; + foreach ($lookups as $lookup) { + $this->addConstructorLookup($lookup); + } - return $this; - } + return $this; + } - /** - * Specify a literal (non looked up) value for the constructor of the - * previously registered item. - * - * @see withDependencies(), addConstructorLookup() - * - * @param mixed $value - * - * @return $this - */ - public function addConstructorValue($value) - { - $endPoint = &$this->getEndPoint(); - if (!isset($endPoint['args'])) { - $endPoint['args'] = []; - } - $endPoint['args'][] = ['type' => 'value', 'item' => $value]; + /** + * Specify a literal (non looked up) value for the constructor of the + * previously registered item. + * + * @see withDependencies(), addConstructorLookup() + * + * @param mixed $value + * + * @return $this + */ + public function addConstructorValue($value) + { + $endPoint = &$this->getEndPoint(); + if (!isset($endPoint['args'])) { + $endPoint['args'] = []; + } + $endPoint['args'][] = ['type' => 'value', 'item' => $value]; - return $this; - } + return $this; + } - /** - * Specify a dependency lookup for the constructor of the previously - * registered item. - * - * @see withDependencies(), addConstructorValue() - * - * @param string $lookup - * - * @return $this - */ - public function addConstructorLookup($lookup) - { - $endPoint = &$this->getEndPoint(); - if (!isset($this->endPoint['args'])) { - $endPoint['args'] = []; - } - $endPoint['args'][] = ['type' => 'lookup', 'item' => $lookup]; + /** + * Specify a dependency lookup for the constructor of the previously + * registered item. + * + * @see withDependencies(), addConstructorValue() + * + * @param string $lookup + * + * @return $this + */ + public function addConstructorLookup($lookup) + { + $endPoint = &$this->getEndPoint(); + if (!isset($this->endPoint['args'])) { + $endPoint['args'] = []; + } + $endPoint['args'][] = ['type' => 'lookup', 'item' => $lookup]; - return $this; - } + return $this; + } - /** Get the literal value with $itemName */ - private function getValue($itemName) - { - return $this->store[$itemName]['value']; - } + /** Get the literal value with $itemName */ + private function getValue($itemName) + { + return $this->store[$itemName]['value']; + } - /** Resolve an alias to another item */ - private function createAlias($itemName) - { - return $this->lookup($this->store[$itemName]['ref']); - } + /** Resolve an alias to another item */ + private function createAlias($itemName) + { + return $this->lookup($this->store[$itemName]['ref']); + } - /** Create a fresh instance of $itemName */ - private function createNewInstance($itemName) - { - $reflector = new ReflectionClass($this->store[$itemName]['className']); - if ($reflector->getConstructor()) { - return $reflector->newInstanceArgs( - $this->createDependenciesFor($itemName) - ); - } + /** Create a fresh instance of $itemName */ + private function createNewInstance($itemName) + { + $reflector = new ReflectionClass($this->store[$itemName]['className']); + if ($reflector->getConstructor()) { + return $reflector->newInstanceArgs( + $this->createDependenciesFor($itemName) + ); + } - return $reflector->newInstance(); - } + return $reflector->newInstance(); + } - /** Create and register a shared instance of $itemName */ - private function createSharedInstance($itemName) - { - if (!isset($this->store[$itemName]['instance'])) { - $this->store[$itemName]['instance'] = $this->createNewInstance($itemName); - } + /** Create and register a shared instance of $itemName */ + private function createSharedInstance($itemName) + { + if (!isset($this->store[$itemName]['instance'])) { + $this->store[$itemName]['instance'] = $this->createNewInstance($itemName); + } - return $this->store[$itemName]['instance']; - } + return $this->store[$itemName]['instance']; + } - /** Get the current endpoint in the store */ - private function &getEndPoint() - { - if (!isset($this->endPoint)) { - throw new BadMethodCallException('Component must first be registered by calling register()'); - } + /** Get the current endpoint in the store */ + private function &getEndPoint() + { + if (!isset($this->endPoint)) { + throw new BadMethodCallException('Component must first be registered by calling register()'); + } - return $this->endPoint; - } + return $this->endPoint; + } - /** Get an argument list with dependencies resolved */ - private function resolveArgs(array $args) - { - $resolved = []; - foreach ($args as $argDefinition) { - switch ($argDefinition['type']) { - case 'lookup': - $resolved[] = $this->lookupRecursive($argDefinition['item']); - break; - case 'value': - $resolved[] = $argDefinition['item']; - break; - } - } + /** Get an argument list with dependencies resolved */ + private function resolveArgs(array $args) + { + $resolved = []; + foreach ($args as $argDefinition) { + switch ($argDefinition['type']) { + case 'lookup': + $resolved[] = $this->lookupRecursive($argDefinition['item']); + break; + case 'value': + $resolved[] = $argDefinition['item']; + break; + } + } - return $resolved; - } + return $resolved; + } - /** Resolve a single dependency with an collections */ - private function lookupRecursive($item) - { - if (\is_array($item)) { - $collection = []; - foreach ($item as $k => $v) { - $collection[$k] = $this->lookupRecursive($v); - } + /** Resolve a single dependency with an collections */ + private function lookupRecursive($item) + { + if (\is_array($item)) { + $collection = []; + foreach ($item as $k => $v) { + $collection[$k] = $this->lookupRecursive($v); + } - return $collection; - } + return $collection; + } - return $this->lookup($item); - } + return $this->lookup($item); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/EmbeddedFile.php b/htdocs/includes/swiftmailer/lib/classes/Swift/EmbeddedFile.php index 30fc68ab03e..0ed8a23d566 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/EmbeddedFile.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/EmbeddedFile.php @@ -15,39 +15,39 @@ */ class Swift_EmbeddedFile extends Swift_Mime_EmbeddedFile { - /** - * Create a new EmbeddedFile. - * - * Details may be optionally provided to the constructor. - * - * @param string|Swift_OutputByteStream $data - * @param string $filename - * @param string $contentType - */ - public function __construct($data = null, $filename = null, $contentType = null) - { - \call_user_func_array( - [$this, 'Swift_Mime_EmbeddedFile::__construct'], - Swift_DependencyContainer::getInstance() - ->createDependenciesFor('mime.embeddedfile') - ); + /** + * Create a new EmbeddedFile. + * + * Details may be optionally provided to the constructor. + * + * @param string|Swift_OutputByteStream $data + * @param string $filename + * @param string $contentType + */ + public function __construct($data = null, $filename = null, $contentType = null) + { + \call_user_func_array( + [$this, 'Swift_Mime_EmbeddedFile::__construct'], + Swift_DependencyContainer::getInstance() + ->createDependenciesFor('mime.embeddedfile') + ); - $this->setBody($data); - $this->setFilename($filename); - if ($contentType) { - $this->setContentType($contentType); - } - } + $this->setBody($data); + $this->setFilename($filename); + if ($contentType) { + $this->setContentType($contentType); + } + } - /** - * Create a new EmbeddedFile from a filesystem path. - * - * @param string $path - * - * @return Swift_Mime_EmbeddedFile - */ - public static function fromPath($path) - { - return (new self())->setFile(new Swift_ByteStream_FileByteStream($path)); - } + /** + * Create a new EmbeddedFile from a filesystem path. + * + * @param string $path + * + * @return Swift_Mime_EmbeddedFile + */ + public static function fromPath($path) + { + return (new self())->setFile(new Swift_ByteStream_FileByteStream($path)); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Encoder/Base64Encoder.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Encoder/Base64Encoder.php index b1eedaa051b..f89e74dc222 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Encoder/Base64Encoder.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Encoder/Base64Encoder.php @@ -15,44 +15,44 @@ */ class Swift_Encoder_Base64Encoder implements Swift_Encoder { - /** - * Takes an unencoded string and produces a Base64 encoded string from it. - * - * Base64 encoded strings have a maximum line length of 76 characters. - * If the first line needs to be shorter, indicate the difference with - * $firstLineOffset. - * - * @param string $string to encode - * @param int $firstLineOffset - * @param int $maxLineLength optional, 0 indicates the default of 76 bytes - * - * @return string - */ - public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) - { - if (0 >= $maxLineLength || 76 < $maxLineLength) { - $maxLineLength = 76; - } + /** + * Takes an unencoded string and produces a Base64 encoded string from it. + * + * Base64 encoded strings have a maximum line length of 76 characters. + * If the first line needs to be shorter, indicate the difference with + * $firstLineOffset. + * + * @param string $string to encode + * @param int $firstLineOffset + * @param int $maxLineLength optional, 0 indicates the default of 76 bytes + * + * @return string + */ + public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) + { + if (0 >= $maxLineLength || 76 < $maxLineLength) { + $maxLineLength = 76; + } - $encodedString = base64_encode($string ?? ''); - $firstLine = ''; + $encodedString = base64_encode($string ?? ''); + $firstLine = ''; - if (0 != $firstLineOffset) { - $firstLine = substr( - $encodedString, 0, $maxLineLength - $firstLineOffset - )."\r\n"; - $encodedString = substr( - $encodedString, $maxLineLength - $firstLineOffset - ); - } + if (0 != $firstLineOffset) { + $firstLine = substr( + $encodedString, 0, $maxLineLength - $firstLineOffset + )."\r\n"; + $encodedString = substr( + $encodedString, $maxLineLength - $firstLineOffset + ); + } - return $firstLine.trim(chunk_split($encodedString, $maxLineLength, "\r\n")); - } + return $firstLine.trim(chunk_split($encodedString, $maxLineLength, "\r\n")); + } - /** - * Does nothing. - */ - public function charsetChanged($charset) - { - } + /** + * Does nothing. + */ + public function charsetChanged($charset) + { + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Encoder/QpEncoder.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Encoder/QpEncoder.php index f078d6d7c38..24ad727f95b 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Encoder/QpEncoder.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Encoder/QpEncoder.php @@ -17,284 +17,284 @@ */ class Swift_Encoder_QpEncoder implements Swift_Encoder { - /** - * The CharacterStream used for reading characters (as opposed to bytes). - * - * @var Swift_CharacterStream - */ - protected $charStream; + /** + * The CharacterStream used for reading characters (as opposed to bytes). + * + * @var Swift_CharacterStream + */ + protected $charStream; - /** - * A filter used if input should be canonicalized. - * - * @var Swift_StreamFilter - */ - protected $filter; + /** + * A filter used if input should be canonicalized. + * + * @var Swift_StreamFilter + */ + protected $filter; - /** - * Pre-computed QP for HUGE optimization. - * - * @var string[] - */ - protected static $qpMap = [ - 0 => '=00', 1 => '=01', 2 => '=02', 3 => '=03', 4 => '=04', - 5 => '=05', 6 => '=06', 7 => '=07', 8 => '=08', 9 => '=09', - 10 => '=0A', 11 => '=0B', 12 => '=0C', 13 => '=0D', 14 => '=0E', - 15 => '=0F', 16 => '=10', 17 => '=11', 18 => '=12', 19 => '=13', - 20 => '=14', 21 => '=15', 22 => '=16', 23 => '=17', 24 => '=18', - 25 => '=19', 26 => '=1A', 27 => '=1B', 28 => '=1C', 29 => '=1D', - 30 => '=1E', 31 => '=1F', 32 => '=20', 33 => '=21', 34 => '=22', - 35 => '=23', 36 => '=24', 37 => '=25', 38 => '=26', 39 => '=27', - 40 => '=28', 41 => '=29', 42 => '=2A', 43 => '=2B', 44 => '=2C', - 45 => '=2D', 46 => '=2E', 47 => '=2F', 48 => '=30', 49 => '=31', - 50 => '=32', 51 => '=33', 52 => '=34', 53 => '=35', 54 => '=36', - 55 => '=37', 56 => '=38', 57 => '=39', 58 => '=3A', 59 => '=3B', - 60 => '=3C', 61 => '=3D', 62 => '=3E', 63 => '=3F', 64 => '=40', - 65 => '=41', 66 => '=42', 67 => '=43', 68 => '=44', 69 => '=45', - 70 => '=46', 71 => '=47', 72 => '=48', 73 => '=49', 74 => '=4A', - 75 => '=4B', 76 => '=4C', 77 => '=4D', 78 => '=4E', 79 => '=4F', - 80 => '=50', 81 => '=51', 82 => '=52', 83 => '=53', 84 => '=54', - 85 => '=55', 86 => '=56', 87 => '=57', 88 => '=58', 89 => '=59', - 90 => '=5A', 91 => '=5B', 92 => '=5C', 93 => '=5D', 94 => '=5E', - 95 => '=5F', 96 => '=60', 97 => '=61', 98 => '=62', 99 => '=63', - 100 => '=64', 101 => '=65', 102 => '=66', 103 => '=67', 104 => '=68', - 105 => '=69', 106 => '=6A', 107 => '=6B', 108 => '=6C', 109 => '=6D', - 110 => '=6E', 111 => '=6F', 112 => '=70', 113 => '=71', 114 => '=72', - 115 => '=73', 116 => '=74', 117 => '=75', 118 => '=76', 119 => '=77', - 120 => '=78', 121 => '=79', 122 => '=7A', 123 => '=7B', 124 => '=7C', - 125 => '=7D', 126 => '=7E', 127 => '=7F', 128 => '=80', 129 => '=81', - 130 => '=82', 131 => '=83', 132 => '=84', 133 => '=85', 134 => '=86', - 135 => '=87', 136 => '=88', 137 => '=89', 138 => '=8A', 139 => '=8B', - 140 => '=8C', 141 => '=8D', 142 => '=8E', 143 => '=8F', 144 => '=90', - 145 => '=91', 146 => '=92', 147 => '=93', 148 => '=94', 149 => '=95', - 150 => '=96', 151 => '=97', 152 => '=98', 153 => '=99', 154 => '=9A', - 155 => '=9B', 156 => '=9C', 157 => '=9D', 158 => '=9E', 159 => '=9F', - 160 => '=A0', 161 => '=A1', 162 => '=A2', 163 => '=A3', 164 => '=A4', - 165 => '=A5', 166 => '=A6', 167 => '=A7', 168 => '=A8', 169 => '=A9', - 170 => '=AA', 171 => '=AB', 172 => '=AC', 173 => '=AD', 174 => '=AE', - 175 => '=AF', 176 => '=B0', 177 => '=B1', 178 => '=B2', 179 => '=B3', - 180 => '=B4', 181 => '=B5', 182 => '=B6', 183 => '=B7', 184 => '=B8', - 185 => '=B9', 186 => '=BA', 187 => '=BB', 188 => '=BC', 189 => '=BD', - 190 => '=BE', 191 => '=BF', 192 => '=C0', 193 => '=C1', 194 => '=C2', - 195 => '=C3', 196 => '=C4', 197 => '=C5', 198 => '=C6', 199 => '=C7', - 200 => '=C8', 201 => '=C9', 202 => '=CA', 203 => '=CB', 204 => '=CC', - 205 => '=CD', 206 => '=CE', 207 => '=CF', 208 => '=D0', 209 => '=D1', - 210 => '=D2', 211 => '=D3', 212 => '=D4', 213 => '=D5', 214 => '=D6', - 215 => '=D7', 216 => '=D8', 217 => '=D9', 218 => '=DA', 219 => '=DB', - 220 => '=DC', 221 => '=DD', 222 => '=DE', 223 => '=DF', 224 => '=E0', - 225 => '=E1', 226 => '=E2', 227 => '=E3', 228 => '=E4', 229 => '=E5', - 230 => '=E6', 231 => '=E7', 232 => '=E8', 233 => '=E9', 234 => '=EA', - 235 => '=EB', 236 => '=EC', 237 => '=ED', 238 => '=EE', 239 => '=EF', - 240 => '=F0', 241 => '=F1', 242 => '=F2', 243 => '=F3', 244 => '=F4', - 245 => '=F5', 246 => '=F6', 247 => '=F7', 248 => '=F8', 249 => '=F9', - 250 => '=FA', 251 => '=FB', 252 => '=FC', 253 => '=FD', 254 => '=FE', - 255 => '=FF', - ]; + /** + * Pre-computed QP for HUGE optimization. + * + * @var string[] + */ + protected static $qpMap = [ + 0 => '=00', 1 => '=01', 2 => '=02', 3 => '=03', 4 => '=04', + 5 => '=05', 6 => '=06', 7 => '=07', 8 => '=08', 9 => '=09', + 10 => '=0A', 11 => '=0B', 12 => '=0C', 13 => '=0D', 14 => '=0E', + 15 => '=0F', 16 => '=10', 17 => '=11', 18 => '=12', 19 => '=13', + 20 => '=14', 21 => '=15', 22 => '=16', 23 => '=17', 24 => '=18', + 25 => '=19', 26 => '=1A', 27 => '=1B', 28 => '=1C', 29 => '=1D', + 30 => '=1E', 31 => '=1F', 32 => '=20', 33 => '=21', 34 => '=22', + 35 => '=23', 36 => '=24', 37 => '=25', 38 => '=26', 39 => '=27', + 40 => '=28', 41 => '=29', 42 => '=2A', 43 => '=2B', 44 => '=2C', + 45 => '=2D', 46 => '=2E', 47 => '=2F', 48 => '=30', 49 => '=31', + 50 => '=32', 51 => '=33', 52 => '=34', 53 => '=35', 54 => '=36', + 55 => '=37', 56 => '=38', 57 => '=39', 58 => '=3A', 59 => '=3B', + 60 => '=3C', 61 => '=3D', 62 => '=3E', 63 => '=3F', 64 => '=40', + 65 => '=41', 66 => '=42', 67 => '=43', 68 => '=44', 69 => '=45', + 70 => '=46', 71 => '=47', 72 => '=48', 73 => '=49', 74 => '=4A', + 75 => '=4B', 76 => '=4C', 77 => '=4D', 78 => '=4E', 79 => '=4F', + 80 => '=50', 81 => '=51', 82 => '=52', 83 => '=53', 84 => '=54', + 85 => '=55', 86 => '=56', 87 => '=57', 88 => '=58', 89 => '=59', + 90 => '=5A', 91 => '=5B', 92 => '=5C', 93 => '=5D', 94 => '=5E', + 95 => '=5F', 96 => '=60', 97 => '=61', 98 => '=62', 99 => '=63', + 100 => '=64', 101 => '=65', 102 => '=66', 103 => '=67', 104 => '=68', + 105 => '=69', 106 => '=6A', 107 => '=6B', 108 => '=6C', 109 => '=6D', + 110 => '=6E', 111 => '=6F', 112 => '=70', 113 => '=71', 114 => '=72', + 115 => '=73', 116 => '=74', 117 => '=75', 118 => '=76', 119 => '=77', + 120 => '=78', 121 => '=79', 122 => '=7A', 123 => '=7B', 124 => '=7C', + 125 => '=7D', 126 => '=7E', 127 => '=7F', 128 => '=80', 129 => '=81', + 130 => '=82', 131 => '=83', 132 => '=84', 133 => '=85', 134 => '=86', + 135 => '=87', 136 => '=88', 137 => '=89', 138 => '=8A', 139 => '=8B', + 140 => '=8C', 141 => '=8D', 142 => '=8E', 143 => '=8F', 144 => '=90', + 145 => '=91', 146 => '=92', 147 => '=93', 148 => '=94', 149 => '=95', + 150 => '=96', 151 => '=97', 152 => '=98', 153 => '=99', 154 => '=9A', + 155 => '=9B', 156 => '=9C', 157 => '=9D', 158 => '=9E', 159 => '=9F', + 160 => '=A0', 161 => '=A1', 162 => '=A2', 163 => '=A3', 164 => '=A4', + 165 => '=A5', 166 => '=A6', 167 => '=A7', 168 => '=A8', 169 => '=A9', + 170 => '=AA', 171 => '=AB', 172 => '=AC', 173 => '=AD', 174 => '=AE', + 175 => '=AF', 176 => '=B0', 177 => '=B1', 178 => '=B2', 179 => '=B3', + 180 => '=B4', 181 => '=B5', 182 => '=B6', 183 => '=B7', 184 => '=B8', + 185 => '=B9', 186 => '=BA', 187 => '=BB', 188 => '=BC', 189 => '=BD', + 190 => '=BE', 191 => '=BF', 192 => '=C0', 193 => '=C1', 194 => '=C2', + 195 => '=C3', 196 => '=C4', 197 => '=C5', 198 => '=C6', 199 => '=C7', + 200 => '=C8', 201 => '=C9', 202 => '=CA', 203 => '=CB', 204 => '=CC', + 205 => '=CD', 206 => '=CE', 207 => '=CF', 208 => '=D0', 209 => '=D1', + 210 => '=D2', 211 => '=D3', 212 => '=D4', 213 => '=D5', 214 => '=D6', + 215 => '=D7', 216 => '=D8', 217 => '=D9', 218 => '=DA', 219 => '=DB', + 220 => '=DC', 221 => '=DD', 222 => '=DE', 223 => '=DF', 224 => '=E0', + 225 => '=E1', 226 => '=E2', 227 => '=E3', 228 => '=E4', 229 => '=E5', + 230 => '=E6', 231 => '=E7', 232 => '=E8', 233 => '=E9', 234 => '=EA', + 235 => '=EB', 236 => '=EC', 237 => '=ED', 238 => '=EE', 239 => '=EF', + 240 => '=F0', 241 => '=F1', 242 => '=F2', 243 => '=F3', 244 => '=F4', + 245 => '=F5', 246 => '=F6', 247 => '=F7', 248 => '=F8', 249 => '=F9', + 250 => '=FA', 251 => '=FB', 252 => '=FC', 253 => '=FD', 254 => '=FE', + 255 => '=FF', + ]; - protected static $safeMapShare = []; + protected static $safeMapShare = []; - /** - * A map of non-encoded ascii characters. - * - * @var string[] - */ - protected $safeMap = []; + /** + * A map of non-encoded ascii characters. + * + * @var string[] + */ + protected $safeMap = []; - /** - * Creates a new QpEncoder for the given CharacterStream. - * - * @param Swift_CharacterStream $charStream to use for reading characters - * @param Swift_StreamFilter $filter if input should be canonicalized - */ - public function __construct(Swift_CharacterStream $charStream, Swift_StreamFilter $filter = null) - { - $this->charStream = $charStream; - if (!isset(self::$safeMapShare[$this->getSafeMapShareId()])) { - $this->initSafeMap(); - self::$safeMapShare[$this->getSafeMapShareId()] = $this->safeMap; - } else { - $this->safeMap = self::$safeMapShare[$this->getSafeMapShareId()]; - } - $this->filter = $filter; - } + /** + * Creates a new QpEncoder for the given CharacterStream. + * + * @param Swift_CharacterStream $charStream to use for reading characters + * @param Swift_StreamFilter $filter if input should be canonicalized + */ + public function __construct(Swift_CharacterStream $charStream, Swift_StreamFilter $filter = null) + { + $this->charStream = $charStream; + if (!isset(self::$safeMapShare[$this->getSafeMapShareId()])) { + $this->initSafeMap(); + self::$safeMapShare[$this->getSafeMapShareId()] = $this->safeMap; + } else { + $this->safeMap = self::$safeMapShare[$this->getSafeMapShareId()]; + } + $this->filter = $filter; + } - public function __sleep() - { - return ['charStream', 'filter']; - } + public function __sleep() + { + return ['charStream', 'filter']; + } - public function __wakeup() - { - if (!isset(self::$safeMapShare[$this->getSafeMapShareId()])) { - $this->initSafeMap(); - self::$safeMapShare[$this->getSafeMapShareId()] = $this->safeMap; - } else { - $this->safeMap = self::$safeMapShare[$this->getSafeMapShareId()]; - } - } + public function __wakeup() + { + if (!isset(self::$safeMapShare[$this->getSafeMapShareId()])) { + $this->initSafeMap(); + self::$safeMapShare[$this->getSafeMapShareId()] = $this->safeMap; + } else { + $this->safeMap = self::$safeMapShare[$this->getSafeMapShareId()]; + } + } - protected function getSafeMapShareId() - { - return static::class; - } + protected function getSafeMapShareId() + { + return static::class; + } - protected function initSafeMap() - { - foreach (array_merge( - [0x09, 0x20], range(0x21, 0x3C), range(0x3E, 0x7E)) as $byte) { - $this->safeMap[$byte] = \chr($byte); - } - } + protected function initSafeMap() + { + foreach (array_merge( + [0x09, 0x20], range(0x21, 0x3C), range(0x3E, 0x7E)) as $byte) { + $this->safeMap[$byte] = \chr($byte); + } + } - /** - * Takes an unencoded string and produces a QP encoded string from it. - * - * QP encoded strings have a maximum line length of 76 characters. - * If the first line needs to be shorter, indicate the difference with - * $firstLineOffset. - * - * @param string $string to encode - * @param int $firstLineOffset optional - * @param int $maxLineLength optional 0 indicates the default of 76 chars - * - * @return string - */ - public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) - { - if ($maxLineLength > 76 || $maxLineLength <= 0) { - $maxLineLength = 76; - } + /** + * Takes an unencoded string and produces a QP encoded string from it. + * + * QP encoded strings have a maximum line length of 76 characters. + * If the first line needs to be shorter, indicate the difference with + * $firstLineOffset. + * + * @param string $string to encode + * @param int $firstLineOffset optional + * @param int $maxLineLength optional 0 indicates the default of 76 chars + * + * @return string + */ + public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) + { + if ($maxLineLength > 76 || $maxLineLength <= 0) { + $maxLineLength = 76; + } - $thisLineLength = $maxLineLength - $firstLineOffset; + $thisLineLength = $maxLineLength - $firstLineOffset; - $lines = []; - $lNo = 0; - $lines[$lNo] = ''; - $currentLine = &$lines[$lNo++]; - $size = $lineLen = 0; + $lines = []; + $lNo = 0; + $lines[$lNo] = ''; + $currentLine = &$lines[$lNo++]; + $size = $lineLen = 0; - $this->charStream->flushContents(); - $this->charStream->importString($string); + $this->charStream->flushContents(); + $this->charStream->importString($string); - // Fetching more than 4 chars at one is slower, as is fetching fewer bytes - // Conveniently 4 chars is the UTF-8 safe number since UTF-8 has up to 6 - // bytes per char and (6 * 4 * 3 = 72 chars per line) * =NN is 3 bytes - while (false !== $bytes = $this->nextSequence()) { - // If we're filtering the input - if (isset($this->filter)) { - // If we can't filter because we need more bytes - while ($this->filter->shouldBuffer($bytes)) { - // Then collect bytes into the buffer - if (false === $moreBytes = $this->nextSequence(1)) { - break; - } + // Fetching more than 4 chars at one is slower, as is fetching fewer bytes + // Conveniently 4 chars is the UTF-8 safe number since UTF-8 has up to 6 + // bytes per char and (6 * 4 * 3 = 72 chars per line) * =NN is 3 bytes + while (false !== $bytes = $this->nextSequence()) { + // If we're filtering the input + if (isset($this->filter)) { + // If we can't filter because we need more bytes + while ($this->filter->shouldBuffer($bytes)) { + // Then collect bytes into the buffer + if (false === $moreBytes = $this->nextSequence(1)) { + break; + } - foreach ($moreBytes as $b) { - $bytes[] = $b; - } - } - // And filter them - $bytes = $this->filter->filter($bytes); - } + foreach ($moreBytes as $b) { + $bytes[] = $b; + } + } + // And filter them + $bytes = $this->filter->filter($bytes); + } - $enc = $this->encodeByteSequence($bytes, $size); + $enc = $this->encodeByteSequence($bytes, $size); - $i = strpos($enc, '=0D=0A'); - $newLineLength = $lineLen + (false === $i ? $size : $i); + $i = strpos($enc, '=0D=0A'); + $newLineLength = $lineLen + (false === $i ? $size : $i); - if ($currentLine && $newLineLength >= $thisLineLength) { - $lines[$lNo] = ''; - $currentLine = &$lines[$lNo++]; - $thisLineLength = $maxLineLength; - $lineLen = 0; - } + if ($currentLine && $newLineLength >= $thisLineLength) { + $lines[$lNo] = ''; + $currentLine = &$lines[$lNo++]; + $thisLineLength = $maxLineLength; + $lineLen = 0; + } - $currentLine .= $enc; + $currentLine .= $enc; - if (false === $i) { - $lineLen += $size; - } else { - // 6 is the length of '=0D=0A'. - $lineLen = $size - strrpos($enc, '=0D=0A') - 6; - } - } + if (false === $i) { + $lineLen += $size; + } else { + // 6 is the length of '=0D=0A'. + $lineLen = $size - strrpos($enc, '=0D=0A') - 6; + } + } - return $this->standardize(implode("=\r\n", $lines)); - } + return $this->standardize(implode("=\r\n", $lines)); + } - /** - * Updates the charset used. - * - * @param string $charset - */ - public function charsetChanged($charset) - { - $this->charStream->setCharacterSet($charset); - } + /** + * Updates the charset used. + * + * @param string $charset + */ + public function charsetChanged($charset) + { + $this->charStream->setCharacterSet($charset); + } - /** - * Encode the given byte array into a verbatim QP form. - * - * @param int[] $bytes - * @param int $size - * - * @return string - */ - protected function encodeByteSequence(array $bytes, &$size) - { - $ret = ''; - $size = 0; - foreach ($bytes as $b) { - if (isset($this->safeMap[$b])) { - $ret .= $this->safeMap[$b]; - ++$size; - } else { - $ret .= self::$qpMap[$b]; - $size += 3; - } - } + /** + * Encode the given byte array into a verbatim QP form. + * + * @param int[] $bytes + * @param int $size + * + * @return string + */ + protected function encodeByteSequence(array $bytes, &$size) + { + $ret = ''; + $size = 0; + foreach ($bytes as $b) { + if (isset($this->safeMap[$b])) { + $ret .= $this->safeMap[$b]; + ++$size; + } else { + $ret .= self::$qpMap[$b]; + $size += 3; + } + } - return $ret; - } + return $ret; + } - /** - * Get the next sequence of bytes to read from the char stream. - * - * @param int $size number of bytes to read - * - * @return int[] - */ - protected function nextSequence($size = 4) - { - return $this->charStream->readBytes($size); - } + /** + * Get the next sequence of bytes to read from the char stream. + * + * @param int $size number of bytes to read + * + * @return int[] + */ + protected function nextSequence($size = 4) + { + return $this->charStream->readBytes($size); + } - /** - * Make sure CRLF is correct and HT/SPACE are in valid places. - * - * @param string $string - * - * @return string - */ - protected function standardize($string) - { - $string = str_replace(["\t=0D=0A", ' =0D=0A', '=0D=0A'], - ["=09\r\n", "=20\r\n", "\r\n"], $string - ); - switch ($end = \ord(substr($string, -1))) { - case 0x09: - case 0x20: - $string = substr_replace($string, self::$qpMap[$end], -1); - } + /** + * Make sure CRLF is correct and HT/SPACE are in valid places. + * + * @param string $string + * + * @return string + */ + protected function standardize($string) + { + $string = str_replace(["\t=0D=0A", ' =0D=0A', '=0D=0A'], + ["=09\r\n", "=20\r\n", "\r\n"], $string + ); + switch ($end = \ord(substr($string, -1))) { + case 0x09: + case 0x20: + $string = substr_replace($string, self::$qpMap[$end], -1); + } - return $string; - } + return $string; + } - /** - * Make a deep copy of object. - */ - public function __clone() - { - $this->charStream = clone $this->charStream; - } + /** + * Make a deep copy of object. + */ + public function __clone() + { + $this->charStream = clone $this->charStream; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Encoder/Rfc2231Encoder.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Encoder/Rfc2231Encoder.php index 7eac36813e0..488fcfd4717 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Encoder/Rfc2231Encoder.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Encoder/Rfc2231Encoder.php @@ -15,76 +15,76 @@ */ class Swift_Encoder_Rfc2231Encoder implements Swift_Encoder { - /** - * A character stream to use when reading a string as characters instead of bytes. - * - * @var Swift_CharacterStream - */ - private $charStream; + /** + * A character stream to use when reading a string as characters instead of bytes. + * + * @var Swift_CharacterStream + */ + private $charStream; - /** - * Creates a new Rfc2231Encoder using the given character stream instance. - */ - public function __construct(Swift_CharacterStream $charStream) - { - $this->charStream = $charStream; - } + /** + * Creates a new Rfc2231Encoder using the given character stream instance. + */ + public function __construct(Swift_CharacterStream $charStream) + { + $this->charStream = $charStream; + } - /** - * Takes an unencoded string and produces a string encoded according to - * RFC 2231 from it. - * - * @param string $string - * @param int $firstLineOffset - * @param int $maxLineLength optional, 0 indicates the default of 75 bytes - * - * @return string - */ - public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) - { - $lines = []; - $lineCount = 0; - $lines[] = ''; - $currentLine = &$lines[$lineCount++]; + /** + * Takes an unencoded string and produces a string encoded according to + * RFC 2231 from it. + * + * @param string $string + * @param int $firstLineOffset + * @param int $maxLineLength optional, 0 indicates the default of 75 bytes + * + * @return string + */ + public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) + { + $lines = []; + $lineCount = 0; + $lines[] = ''; + $currentLine = &$lines[$lineCount++]; - if (0 >= $maxLineLength) { - $maxLineLength = 75; - } + if (0 >= $maxLineLength) { + $maxLineLength = 75; + } - $this->charStream->flushContents(); - $this->charStream->importString($string); + $this->charStream->flushContents(); + $this->charStream->importString($string); - $thisLineLength = $maxLineLength - $firstLineOffset; + $thisLineLength = $maxLineLength - $firstLineOffset; - while (false !== $char = $this->charStream->read(4)) { - $encodedChar = rawurlencode($char); - if (0 != \strlen($currentLine) - && \strlen($currentLine.$encodedChar) > $thisLineLength) { - $lines[] = ''; - $currentLine = &$lines[$lineCount++]; - $thisLineLength = $maxLineLength; - } - $currentLine .= $encodedChar; - } + while (false !== $char = $this->charStream->read(4)) { + $encodedChar = rawurlencode($char); + if (0 != \strlen($currentLine) + && \strlen($currentLine.$encodedChar) > $thisLineLength) { + $lines[] = ''; + $currentLine = &$lines[$lineCount++]; + $thisLineLength = $maxLineLength; + } + $currentLine .= $encodedChar; + } - return implode("\r\n", $lines); - } + return implode("\r\n", $lines); + } - /** - * Updates the charset used. - * - * @param string $charset - */ - public function charsetChanged($charset) - { - $this->charStream->setCharacterSet($charset); - } + /** + * Updates the charset used. + * + * @param string $charset + */ + public function charsetChanged($charset) + { + $this->charStream->setCharacterSet($charset); + } - /** - * Make a deep copy of object. - */ - public function __clone() - { - $this->charStream = clone $this->charStream; - } + /** + * Make a deep copy of object. + */ + public function __clone() + { + $this->charStream = clone $this->charStream; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/CommandEvent.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/CommandEvent.php index 18994c184f3..1524fda752a 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/CommandEvent.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/CommandEvent.php @@ -15,50 +15,50 @@ */ class Swift_Events_CommandEvent extends Swift_Events_EventObject { - /** - * The command sent to the server. - * - * @var string - */ - private $command; + /** + * The command sent to the server. + * + * @var string + */ + private $command; - /** - * An array of codes which a successful response will contain. - * - * @var int[] - */ - private $successCodes = []; + /** + * An array of codes which a successful response will contain. + * + * @var int[] + */ + private $successCodes = []; - /** - * Create a new CommandEvent for $source with $command. - * - * @param string $command - * @param array $successCodes - */ - public function __construct(Swift_Transport $source, $command, $successCodes = []) - { - parent::__construct($source); - $this->command = $command; - $this->successCodes = $successCodes; - } + /** + * Create a new CommandEvent for $source with $command. + * + * @param string $command + * @param array $successCodes + */ + public function __construct(Swift_Transport $source, $command, $successCodes = []) + { + parent::__construct($source); + $this->command = $command; + $this->successCodes = $successCodes; + } - /** - * Get the command which was sent to the server. - * - * @return string - */ - public function getCommand() - { - return $this->command; - } + /** + * Get the command which was sent to the server. + * + * @return string + */ + public function getCommand() + { + return $this->command; + } - /** - * Get the numeric response codes which indicate success for this command. - * - * @return int[] - */ - public function getSuccessCodes() - { - return $this->successCodes; - } + /** + * Get the numeric response codes which indicate success for this command. + * + * @return int[] + */ + public function getSuccessCodes() + { + return $this->successCodes; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/CommandListener.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/CommandListener.php index b158eab462a..7dff32b4ee6 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/CommandListener.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/CommandListener.php @@ -15,8 +15,8 @@ */ interface Swift_Events_CommandListener extends Swift_Events_EventListener { - /** - * Invoked immediately following a command being sent. - */ - public function commandSent(Swift_Events_CommandEvent $evt); + /** + * Invoked immediately following a command being sent. + */ + public function commandSent(Swift_Events_CommandEvent $evt); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/EventDispatcher.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/EventDispatcher.php index df25a124863..1de97381930 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/EventDispatcher.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/EventDispatcher.php @@ -15,56 +15,56 @@ */ interface Swift_Events_EventDispatcher { - /** - * Create a new SendEvent for $source and $message. - * - * @return Swift_Events_SendEvent - */ - public function createSendEvent(Swift_Transport $source, Swift_Mime_SimpleMessage $message); + /** + * Create a new SendEvent for $source and $message. + * + * @return Swift_Events_SendEvent + */ + public function createSendEvent(Swift_Transport $source, Swift_Mime_SimpleMessage $message); - /** - * Create a new CommandEvent for $source and $command. - * - * @param string $command That will be executed - * @param array $successCodes That are needed - * - * @return Swift_Events_CommandEvent - */ - public function createCommandEvent(Swift_Transport $source, $command, $successCodes = []); + /** + * Create a new CommandEvent for $source and $command. + * + * @param string $command That will be executed + * @param array $successCodes That are needed + * + * @return Swift_Events_CommandEvent + */ + public function createCommandEvent(Swift_Transport $source, $command, $successCodes = []); - /** - * Create a new ResponseEvent for $source and $response. - * - * @param string $response - * @param bool $valid If the response is valid - * - * @return Swift_Events_ResponseEvent - */ - public function createResponseEvent(Swift_Transport $source, $response, $valid); + /** + * Create a new ResponseEvent for $source and $response. + * + * @param string $response + * @param bool $valid If the response is valid + * + * @return Swift_Events_ResponseEvent + */ + public function createResponseEvent(Swift_Transport $source, $response, $valid); - /** - * Create a new TransportChangeEvent for $source. - * - * @return Swift_Events_TransportChangeEvent - */ - public function createTransportChangeEvent(Swift_Transport $source); + /** + * Create a new TransportChangeEvent for $source. + * + * @return Swift_Events_TransportChangeEvent + */ + public function createTransportChangeEvent(Swift_Transport $source); - /** - * Create a new TransportExceptionEvent for $source. - * - * @return Swift_Events_TransportExceptionEvent - */ - public function createTransportExceptionEvent(Swift_Transport $source, Swift_TransportException $ex); + /** + * Create a new TransportExceptionEvent for $source. + * + * @return Swift_Events_TransportExceptionEvent + */ + public function createTransportExceptionEvent(Swift_Transport $source, Swift_TransportException $ex); - /** - * Bind an event listener to this dispatcher. - */ - public function bindEventListener(Swift_Events_EventListener $listener); + /** + * Bind an event listener to this dispatcher. + */ + public function bindEventListener(Swift_Events_EventListener $listener); - /** - * Dispatch the given Event to all suitable listeners. - * - * @param string $target method - */ - public function dispatchEvent(Swift_Events_EventObject $evt, $target); + /** + * Dispatch the given Event to all suitable listeners. + * + * @param string $target method + */ + public function dispatchEvent(Swift_Events_EventObject $evt, $target); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/EventObject.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/EventObject.php index 24a11f44e23..8e3f672cdeb 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/EventObject.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/EventObject.php @@ -15,47 +15,47 @@ */ class Swift_Events_EventObject implements Swift_Events_Event { - /** The source of this Event */ - private $source; + /** The source of this Event */ + private $source; - /** The state of this Event (should it bubble up the stack?) */ - private $bubbleCancelled = false; + /** The state of this Event (should it bubble up the stack?) */ + private $bubbleCancelled = false; - /** - * Create a new EventObject originating at $source. - * - * @param object $source - */ - public function __construct($source) - { - $this->source = $source; - } + /** + * Create a new EventObject originating at $source. + * + * @param object $source + */ + public function __construct($source) + { + $this->source = $source; + } - /** - * Get the source object of this event. - * - * @return object - */ - public function getSource() - { - return $this->source; - } + /** + * Get the source object of this event. + * + * @return object + */ + public function getSource() + { + return $this->source; + } - /** - * Prevent this Event from bubbling any further up the stack. - */ - public function cancelBubble($cancel = true) - { - $this->bubbleCancelled = $cancel; - } + /** + * Prevent this Event from bubbling any further up the stack. + */ + public function cancelBubble($cancel = true) + { + $this->bubbleCancelled = $cancel; + } - /** - * Returns true if this Event will not bubble any further up the stack. - * - * @return bool - */ - public function bubbleCancelled() - { - return $this->bubbleCancelled; - } + /** + * Returns true if this Event will not bubble any further up the stack. + * + * @return bool + */ + public function bubbleCancelled() + { + return $this->bubbleCancelled; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/ResponseEvent.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/ResponseEvent.php index ff7c37116ba..ddae7aab9a4 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/ResponseEvent.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/ResponseEvent.php @@ -15,50 +15,50 @@ */ class Swift_Events_ResponseEvent extends Swift_Events_EventObject { - /** - * The overall result. - * - * @var bool - */ - private $valid; + /** + * The overall result. + * + * @var bool + */ + private $valid; - /** - * The response received from the server. - * - * @var string - */ - private $response; + /** + * The response received from the server. + * + * @var string + */ + private $response; - /** - * Create a new ResponseEvent for $source and $response. - * - * @param string $response - * @param bool $valid - */ - public function __construct(Swift_Transport $source, $response, $valid = false) - { - parent::__construct($source); - $this->response = $response; - $this->valid = $valid; - } + /** + * Create a new ResponseEvent for $source and $response. + * + * @param string $response + * @param bool $valid + */ + public function __construct(Swift_Transport $source, $response, $valid = false) + { + parent::__construct($source); + $this->response = $response; + $this->valid = $valid; + } - /** - * Get the response which was received from the server. - * - * @return string - */ - public function getResponse() - { - return $this->response; - } + /** + * Get the response which was received from the server. + * + * @return string + */ + public function getResponse() + { + return $this->response; + } - /** - * Get the success status of this Event. - * - * @return bool - */ - public function isValid() - { - return $this->valid; - } + /** + * Get the success status of this Event. + * + * @return bool + */ + public function isValid() + { + return $this->valid; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/ResponseListener.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/ResponseListener.php index 85115a33811..ba607510426 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/ResponseListener.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/ResponseListener.php @@ -15,8 +15,8 @@ */ interface Swift_Events_ResponseListener extends Swift_Events_EventListener { - /** - * Invoked immediately following a response coming back. - */ - public function responseReceived(Swift_Events_ResponseEvent $evt); + /** + * Invoked immediately following a response coming back. + */ + public function responseReceived(Swift_Events_ResponseEvent $evt); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/SendEvent.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/SendEvent.php index a435691e0b0..c485f29010e 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/SendEvent.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/SendEvent.php @@ -15,112 +15,112 @@ */ class Swift_Events_SendEvent extends Swift_Events_EventObject { - /** Sending has yet to occur */ - const RESULT_PENDING = 0x0001; + /** Sending has yet to occur */ + const RESULT_PENDING = 0x0001; - /** Email is spooled, ready to be sent */ - const RESULT_SPOOLED = 0x0011; + /** Email is spooled, ready to be sent */ + const RESULT_SPOOLED = 0x0011; - /** Sending was successful */ - const RESULT_SUCCESS = 0x0010; + /** Sending was successful */ + const RESULT_SUCCESS = 0x0010; - /** Sending worked, but there were some failures */ - const RESULT_TENTATIVE = 0x0100; + /** Sending worked, but there were some failures */ + const RESULT_TENTATIVE = 0x0100; - /** Sending failed */ - const RESULT_FAILED = 0x1000; + /** Sending failed */ + const RESULT_FAILED = 0x1000; - /** - * The Message being sent. - * - * @var Swift_Mime_SimpleMessage - */ - private $message; + /** + * The Message being sent. + * + * @var Swift_Mime_SimpleMessage + */ + private $message; - /** - * Any recipients which failed after sending. - * - * @var string[] - */ - private $failedRecipients = []; + /** + * Any recipients which failed after sending. + * + * @var string[] + */ + private $failedRecipients = []; - /** - * The overall result as a bitmask from the class constants. - * - * @var int - */ - private $result; + /** + * The overall result as a bitmask from the class constants. + * + * @var int + */ + private $result; - /** - * Create a new SendEvent for $source and $message. - */ - public function __construct(Swift_Transport $source, Swift_Mime_SimpleMessage $message) - { - parent::__construct($source); - $this->message = $message; - $this->result = self::RESULT_PENDING; - } + /** + * Create a new SendEvent for $source and $message. + */ + public function __construct(Swift_Transport $source, Swift_Mime_SimpleMessage $message) + { + parent::__construct($source); + $this->message = $message; + $this->result = self::RESULT_PENDING; + } - /** - * Get the Transport used to send the Message. - * - * @return Swift_Transport - */ - public function getTransport() - { - return $this->getSource(); - } + /** + * Get the Transport used to send the Message. + * + * @return Swift_Transport + */ + public function getTransport() + { + return $this->getSource(); + } - /** - * Get the Message being sent. - * - * @return Swift_Mime_SimpleMessage - */ - public function getMessage() - { - return $this->message; - } + /** + * Get the Message being sent. + * + * @return Swift_Mime_SimpleMessage + */ + public function getMessage() + { + return $this->message; + } - /** - * Set the array of addresses that failed in sending. - * - * @param array $recipients - */ - public function setFailedRecipients($recipients) - { - $this->failedRecipients = $recipients; - } + /** + * Set the array of addresses that failed in sending. + * + * @param array $recipients + */ + public function setFailedRecipients($recipients) + { + $this->failedRecipients = $recipients; + } - /** - * Get an recipient addresses which were not accepted for delivery. - * - * @return string[] - */ - public function getFailedRecipients() - { - return $this->failedRecipients; - } + /** + * Get an recipient addresses which were not accepted for delivery. + * + * @return string[] + */ + public function getFailedRecipients() + { + return $this->failedRecipients; + } - /** - * Set the result of sending. - * - * @param int $result - */ - public function setResult($result) - { - $this->result = $result; - } + /** + * Set the result of sending. + * + * @param int $result + */ + public function setResult($result) + { + $this->result = $result; + } - /** - * Get the result of this Event. - * - * The return value is a bitmask from - * {@see RESULT_PENDING, RESULT_SUCCESS, RESULT_TENTATIVE, RESULT_FAILED} - * - * @return int - */ - public function getResult() - { - return $this->result; - } + /** + * Get the result of this Event. + * + * The return value is a bitmask from + * {@see RESULT_PENDING, RESULT_SUCCESS, RESULT_TENTATIVE, RESULT_FAILED} + * + * @return int + */ + public function getResult() + { + return $this->result; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/SendListener.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/SendListener.php index f7bf55ef56c..33f7f03f870 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/SendListener.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/SendListener.php @@ -15,13 +15,13 @@ */ interface Swift_Events_SendListener extends Swift_Events_EventListener { - /** - * Invoked immediately before the Message is sent. - */ - public function beforeSendPerformed(Swift_Events_SendEvent $evt); + /** + * Invoked immediately before the Message is sent. + */ + public function beforeSendPerformed(Swift_Events_SendEvent $evt); - /** - * Invoked immediately after the Message is sent. - */ - public function sendPerformed(Swift_Events_SendEvent $evt); + /** + * Invoked immediately after the Message is sent. + */ + public function sendPerformed(Swift_Events_SendEvent $evt); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/SimpleEventDispatcher.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/SimpleEventDispatcher.php index 6557103c99a..7531214d824 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/SimpleEventDispatcher.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/SimpleEventDispatcher.php @@ -15,128 +15,128 @@ */ class Swift_Events_SimpleEventDispatcher implements Swift_Events_EventDispatcher { - /** A map of event types to their associated listener types */ - private $eventMap = []; + /** A map of event types to their associated listener types */ + private $eventMap = []; - /** Event listeners bound to this dispatcher */ - private $listeners = []; + /** Event listeners bound to this dispatcher */ + private $listeners = []; - /** - * Create a new EventDispatcher. - */ - public function __construct() - { - $this->eventMap = [ - 'Swift_Events_CommandEvent' => 'Swift_Events_CommandListener', - 'Swift_Events_ResponseEvent' => 'Swift_Events_ResponseListener', - 'Swift_Events_SendEvent' => 'Swift_Events_SendListener', - 'Swift_Events_TransportChangeEvent' => 'Swift_Events_TransportChangeListener', - 'Swift_Events_TransportExceptionEvent' => 'Swift_Events_TransportExceptionListener', - ]; - } + /** + * Create a new EventDispatcher. + */ + public function __construct() + { + $this->eventMap = [ + 'Swift_Events_CommandEvent' => 'Swift_Events_CommandListener', + 'Swift_Events_ResponseEvent' => 'Swift_Events_ResponseListener', + 'Swift_Events_SendEvent' => 'Swift_Events_SendListener', + 'Swift_Events_TransportChangeEvent' => 'Swift_Events_TransportChangeListener', + 'Swift_Events_TransportExceptionEvent' => 'Swift_Events_TransportExceptionListener', + ]; + } - /** - * Create a new SendEvent for $source and $message. - * - * @return Swift_Events_SendEvent - */ - public function createSendEvent(Swift_Transport $source, Swift_Mime_SimpleMessage $message) - { - return new Swift_Events_SendEvent($source, $message); - } + /** + * Create a new SendEvent for $source and $message. + * + * @return Swift_Events_SendEvent + */ + public function createSendEvent(Swift_Transport $source, Swift_Mime_SimpleMessage $message) + { + return new Swift_Events_SendEvent($source, $message); + } - /** - * Create a new CommandEvent for $source and $command. - * - * @param string $command That will be executed - * @param array $successCodes That are needed - * - * @return Swift_Events_CommandEvent - */ - public function createCommandEvent(Swift_Transport $source, $command, $successCodes = []) - { - return new Swift_Events_CommandEvent($source, $command, $successCodes); - } + /** + * Create a new CommandEvent for $source and $command. + * + * @param string $command That will be executed + * @param array $successCodes That are needed + * + * @return Swift_Events_CommandEvent + */ + public function createCommandEvent(Swift_Transport $source, $command, $successCodes = []) + { + return new Swift_Events_CommandEvent($source, $command, $successCodes); + } - /** - * Create a new ResponseEvent for $source and $response. - * - * @param string $response - * @param bool $valid If the response is valid - * - * @return Swift_Events_ResponseEvent - */ - public function createResponseEvent(Swift_Transport $source, $response, $valid) - { - return new Swift_Events_ResponseEvent($source, $response, $valid); - } + /** + * Create a new ResponseEvent for $source and $response. + * + * @param string $response + * @param bool $valid If the response is valid + * + * @return Swift_Events_ResponseEvent + */ + public function createResponseEvent(Swift_Transport $source, $response, $valid) + { + return new Swift_Events_ResponseEvent($source, $response, $valid); + } - /** - * Create a new TransportChangeEvent for $source. - * - * @return Swift_Events_TransportChangeEvent - */ - public function createTransportChangeEvent(Swift_Transport $source) - { - return new Swift_Events_TransportChangeEvent($source); - } + /** + * Create a new TransportChangeEvent for $source. + * + * @return Swift_Events_TransportChangeEvent + */ + public function createTransportChangeEvent(Swift_Transport $source) + { + return new Swift_Events_TransportChangeEvent($source); + } - /** - * Create a new TransportExceptionEvent for $source. - * - * @return Swift_Events_TransportExceptionEvent - */ - public function createTransportExceptionEvent(Swift_Transport $source, Swift_TransportException $ex) - { - return new Swift_Events_TransportExceptionEvent($source, $ex); - } + /** + * Create a new TransportExceptionEvent for $source. + * + * @return Swift_Events_TransportExceptionEvent + */ + public function createTransportExceptionEvent(Swift_Transport $source, Swift_TransportException $ex) + { + return new Swift_Events_TransportExceptionEvent($source, $ex); + } - /** - * Bind an event listener to this dispatcher. - */ - public function bindEventListener(Swift_Events_EventListener $listener) - { - foreach ($this->listeners as $l) { - // Already loaded - if ($l === $listener) { - return; - } - } - $this->listeners[] = $listener; - } + /** + * Bind an event listener to this dispatcher. + */ + public function bindEventListener(Swift_Events_EventListener $listener) + { + foreach ($this->listeners as $l) { + // Already loaded + if ($l === $listener) { + return; + } + } + $this->listeners[] = $listener; + } - /** - * Dispatch the given Event to all suitable listeners. - * - * @param string $target method - */ - public function dispatchEvent(Swift_Events_EventObject $evt, $target) - { - $bubbleQueue = $this->prepareBubbleQueue($evt); - $this->bubble($bubbleQueue, $evt, $target); - } + /** + * Dispatch the given Event to all suitable listeners. + * + * @param string $target method + */ + public function dispatchEvent(Swift_Events_EventObject $evt, $target) + { + $bubbleQueue = $this->prepareBubbleQueue($evt); + $this->bubble($bubbleQueue, $evt, $target); + } - /** Queue listeners on a stack ready for $evt to be bubbled up it */ - private function prepareBubbleQueue(Swift_Events_EventObject $evt) - { - $bubbleQueue = []; - $evtClass = \get_class($evt); - foreach ($this->listeners as $listener) { - if (\array_key_exists($evtClass, $this->eventMap) - && ($listener instanceof $this->eventMap[$evtClass])) { - $bubbleQueue[] = $listener; - } - } + /** Queue listeners on a stack ready for $evt to be bubbled up it */ + private function prepareBubbleQueue(Swift_Events_EventObject $evt) + { + $bubbleQueue = []; + $evtClass = \get_class($evt); + foreach ($this->listeners as $listener) { + if (\array_key_exists($evtClass, $this->eventMap) + && ($listener instanceof $this->eventMap[$evtClass])) { + $bubbleQueue[] = $listener; + } + } - return $bubbleQueue; - } + return $bubbleQueue; + } - /** Bubble $evt up the stack calling $target() on each listener */ - private function bubble(array &$bubbleQueue, Swift_Events_EventObject $evt, $target) - { - if (!$evt->bubbleCancelled() && $listener = array_shift($bubbleQueue)) { - $listener->$target($evt); - $this->bubble($bubbleQueue, $evt, $target); - } - } + /** Bubble $evt up the stack calling $target() on each listener */ + private function bubble(array &$bubbleQueue, Swift_Events_EventObject $evt, $target) + { + if (!$evt->bubbleCancelled() && $listener = array_shift($bubbleQueue)) { + $listener->$target($evt); + $this->bubble($bubbleQueue, $evt, $target); + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/TransportChangeListener.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/TransportChangeListener.php index 4a7492bc551..24d6bde50bd 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/TransportChangeListener.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/TransportChangeListener.php @@ -15,23 +15,23 @@ */ interface Swift_Events_TransportChangeListener extends Swift_Events_EventListener { - /** - * Invoked just before a Transport is started. - */ - public function beforeTransportStarted(Swift_Events_TransportChangeEvent $evt); + /** + * Invoked just before a Transport is started. + */ + public function beforeTransportStarted(Swift_Events_TransportChangeEvent $evt); - /** - * Invoked immediately after the Transport is started. - */ - public function transportStarted(Swift_Events_TransportChangeEvent $evt); + /** + * Invoked immediately after the Transport is started. + */ + public function transportStarted(Swift_Events_TransportChangeEvent $evt); - /** - * Invoked just before a Transport is stopped. - */ - public function beforeTransportStopped(Swift_Events_TransportChangeEvent $evt); + /** + * Invoked just before a Transport is stopped. + */ + public function beforeTransportStopped(Swift_Events_TransportChangeEvent $evt); - /** - * Invoked immediately after the Transport is stopped. - */ - public function transportStopped(Swift_Events_TransportChangeEvent $evt); + /** + * Invoked immediately after the Transport is stopped. + */ + public function transportStopped(Swift_Events_TransportChangeEvent $evt); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/TransportExceptionEvent.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/TransportExceptionEvent.php index df442cc70f6..0301c8dfc11 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/TransportExceptionEvent.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/TransportExceptionEvent.php @@ -15,29 +15,29 @@ */ class Swift_Events_TransportExceptionEvent extends Swift_Events_EventObject { - /** - * The Exception thrown. - * - * @var Swift_TransportException - */ - private $exception; + /** + * The Exception thrown. + * + * @var Swift_TransportException + */ + private $exception; - /** - * Create a new TransportExceptionEvent for $transport. - */ - public function __construct(Swift_Transport $transport, Swift_TransportException $ex) - { - parent::__construct($transport); - $this->exception = $ex; - } + /** + * Create a new TransportExceptionEvent for $transport. + */ + public function __construct(Swift_Transport $transport, Swift_TransportException $ex) + { + parent::__construct($transport); + $this->exception = $ex; + } - /** - * Get the TransportException thrown. - * - * @return Swift_TransportException - */ - public function getException() - { - return $this->exception; - } + /** + * Get the TransportException thrown. + * + * @return Swift_TransportException + */ + public function getException() + { + return $this->exception; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/TransportExceptionListener.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/TransportExceptionListener.php index ad80eb01d0f..1de6e6e59a9 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/TransportExceptionListener.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/TransportExceptionListener.php @@ -15,8 +15,8 @@ */ interface Swift_Events_TransportExceptionListener extends Swift_Events_EventListener { - /** - * Invoked as a TransportException is thrown in the Transport system. - */ - public function exceptionThrown(Swift_Events_TransportExceptionEvent $evt); + /** + * Invoked as a TransportException is thrown in the Transport system. + */ + public function exceptionThrown(Swift_Events_TransportExceptionEvent $evt); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/FailoverTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/FailoverTransport.php index af0be917903..57d343c9ed3 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/FailoverTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/FailoverTransport.php @@ -15,19 +15,19 @@ */ class Swift_FailoverTransport extends Swift_Transport_FailoverTransport { - /** - * Creates a new FailoverTransport with $transports. - * - * @param Swift_Transport[] $transports - */ - public function __construct($transports = []) - { - \call_user_func_array( - [$this, 'Swift_Transport_FailoverTransport::__construct'], - Swift_DependencyContainer::getInstance() - ->createDependenciesFor('transport.failover') - ); + /** + * Creates a new FailoverTransport with $transports. + * + * @param Swift_Transport[] $transports + */ + public function __construct($transports = []) + { + \call_user_func_array( + [$this, 'Swift_Transport_FailoverTransport::__construct'], + Swift_DependencyContainer::getInstance() + ->createDependenciesFor('transport.failover') + ); - $this->setTransports($transports); - } + $this->setTransports($transports); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/FileSpool.php b/htdocs/includes/swiftmailer/lib/classes/Swift/FileSpool.php index 7af8471c9d7..4dd49a65270 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/FileSpool.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/FileSpool.php @@ -16,193 +16,193 @@ */ class Swift_FileSpool extends Swift_ConfigurableSpool { - /** The spool directory */ - private $path; + /** The spool directory */ + private $path; - /** - * File WriteRetry Limit. - * - * @var int - */ - private $retryLimit = 10; + /** + * File WriteRetry Limit. + * + * @var int + */ + private $retryLimit = 10; - /** - * Create a new FileSpool. - * - * @param string $path - * - * @throws Swift_IoException - */ - public function __construct($path) - { - $this->path = $path; + /** + * Create a new FileSpool. + * + * @param string $path + * + * @throws Swift_IoException + */ + public function __construct($path) + { + $this->path = $path; - if (!file_exists($this->path)) { - if (!mkdir($this->path, 0777, true)) { - throw new Swift_IoException(sprintf('Unable to create path "%s".', $this->path)); - } - } - } + if (!file_exists($this->path)) { + if (!mkdir($this->path, 0777, true)) { + throw new Swift_IoException(sprintf('Unable to create path "%s".', $this->path)); + } + } + } - /** - * Tests if this Spool mechanism has started. - * - * @return bool - */ - public function isStarted() - { - return true; - } + /** + * Tests if this Spool mechanism has started. + * + * @return bool + */ + public function isStarted() + { + return true; + } - /** - * Starts this Spool mechanism. - */ - public function start() - { - } + /** + * Starts this Spool mechanism. + */ + public function start() + { + } - /** - * Stops this Spool mechanism. - */ - public function stop() - { - } + /** + * Stops this Spool mechanism. + */ + public function stop() + { + } - /** - * Allow to manage the enqueuing retry limit. - * - * Default, is ten and allows over 64^20 different fileNames - * - * @param int $limit - */ - public function setRetryLimit($limit) - { - $this->retryLimit = $limit; - } + /** + * Allow to manage the enqueuing retry limit. + * + * Default, is ten and allows over 64^20 different fileNames + * + * @param int $limit + */ + public function setRetryLimit($limit) + { + $this->retryLimit = $limit; + } - /** - * Queues a message. - * - * @param Swift_Mime_SimpleMessage $message The message to store - * - * @throws Swift_IoException - * - * @return bool - */ - public function queueMessage(Swift_Mime_SimpleMessage $message) - { - $ser = serialize($message); - $fileName = $this->path.'/'.$this->getRandomString(10); - for ($i = 0; $i < $this->retryLimit; ++$i) { - /* We try an exclusive creation of the file. This is an atomic operation, it avoid locking mechanism */ - $fp = @fopen($fileName.'.message', 'xb'); - if (false !== $fp) { - if (false === fwrite($fp, $ser)) { - return false; - } + /** + * Queues a message. + * + * @param Swift_Mime_SimpleMessage $message The message to store + * + * @throws Swift_IoException + * + * @return bool + */ + public function queueMessage(Swift_Mime_SimpleMessage $message) + { + $ser = serialize($message); + $fileName = $this->path.'/'.$this->getRandomString(10); + for ($i = 0; $i < $this->retryLimit; ++$i) { + /* We try an exclusive creation of the file. This is an atomic operation, it avoid locking mechanism */ + $fp = @fopen($fileName.'.message', 'xb'); + if (false !== $fp) { + if (false === fwrite($fp, $ser)) { + return false; + } - return fclose($fp); - } else { - /* The file already exists, we try a longer fileName */ - $fileName .= $this->getRandomString(1); - } - } + return fclose($fp); + } else { + /* The file already exists, we try a longer fileName */ + $fileName .= $this->getRandomString(1); + } + } - throw new Swift_IoException(sprintf('Unable to create a file for enqueuing Message in "%s".', $this->path)); - } + throw new Swift_IoException(sprintf('Unable to create a file for enqueuing Message in "%s".', $this->path)); + } - /** - * Execute a recovery if for any reason a process is sending for too long. - * - * @param int $timeout in second Defaults is for very slow smtp responses - */ - public function recover($timeout = 900) - { - foreach (new DirectoryIterator($this->path) as $file) { - $file = $file->getRealPath(); + /** + * Execute a recovery if for any reason a process is sending for too long. + * + * @param int $timeout in second Defaults is for very slow smtp responses + */ + public function recover($timeout = 900) + { + foreach (new DirectoryIterator($this->path) as $file) { + $file = $file->getRealPath(); - if ('.message.sending' == substr($file, -16)) { - $lockedtime = filectime($file); - if ((time() - $lockedtime) > $timeout) { - rename($file, substr($file, 0, -8)); - } - } - } - } + if ('.message.sending' == substr($file, -16)) { + $lockedtime = filectime($file); + if ((time() - $lockedtime) > $timeout) { + rename($file, substr($file, 0, -8)); + } + } + } + } - /** - * Sends messages using the given transport instance. - * - * @param Swift_Transport $transport A transport instance - * @param string[] $failedRecipients An array of failures by-reference - * - * @return int The number of sent e-mail's - */ - public function flushQueue(Swift_Transport $transport, &$failedRecipients = null) - { - $directoryIterator = new DirectoryIterator($this->path); + /** + * Sends messages using the given transport instance. + * + * @param Swift_Transport $transport A transport instance + * @param string[] $failedRecipients An array of failures by-reference + * + * @return int The number of sent e-mail's + */ + public function flushQueue(Swift_Transport $transport, &$failedRecipients = null) + { + $directoryIterator = new DirectoryIterator($this->path); - /* Start the transport only if there are queued files to send */ - if (!$transport->isStarted()) { - foreach ($directoryIterator as $file) { - if ('.message' == substr($file->getRealPath(), -8)) { - $transport->start(); - break; - } - } - } + /* Start the transport only if there are queued files to send */ + if (!$transport->isStarted()) { + foreach ($directoryIterator as $file) { + if ('.message' == substr($file->getRealPath(), -8)) { + $transport->start(); + break; + } + } + } - $failedRecipients = (array) $failedRecipients; - $count = 0; - $time = time(); - foreach ($directoryIterator as $file) { - $file = $file->getRealPath(); + $failedRecipients = (array) $failedRecipients; + $count = 0; + $time = time(); + foreach ($directoryIterator as $file) { + $file = $file->getRealPath(); - if ('.message' != substr($file, -8)) { - continue; - } + if ('.message' != substr($file, -8)) { + continue; + } - /* We try a rename, it's an atomic operation, and avoid locking the file */ - if (rename($file, $file.'.sending')) { - $message = unserialize(file_get_contents($file.'.sending')); + /* We try a rename, it's an atomic operation, and avoid locking the file */ + if (rename($file, $file.'.sending')) { + $message = unserialize(file_get_contents($file.'.sending')); - $count += $transport->send($message, $failedRecipients); + $count += $transport->send($message, $failedRecipients); - unlink($file.'.sending'); - } else { - /* This message has just been catched by another process */ - continue; - } + unlink($file.'.sending'); + } else { + /* This message has just been catched by another process */ + continue; + } - if ($this->getMessageLimit() && $count >= $this->getMessageLimit()) { - break; - } + if ($this->getMessageLimit() && $count >= $this->getMessageLimit()) { + break; + } - if ($this->getTimeLimit() && (time() - $time) >= $this->getTimeLimit()) { - break; - } - } + if ($this->getTimeLimit() && (time() - $time) >= $this->getTimeLimit()) { + break; + } + } - return $count; - } + return $count; + } - /** - * Returns a random string needed to generate a fileName for the queue. - * - * @param int $count - * - * @return string - */ - protected function getRandomString($count) - { - // This string MUST stay FS safe, avoid special chars - $base = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-'; - $ret = ''; - $strlen = \strlen($base); - for ($i = 0; $i < $count; ++$i) { - $ret .= $base[random_int(0, $strlen - 1)]; - } + /** + * Returns a random string needed to generate a fileName for the queue. + * + * @param int $count + * + * @return string + */ + protected function getRandomString($count) + { + // This string MUST stay FS safe, avoid special chars + $base = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-'; + $ret = ''; + $strlen = \strlen($base); + for ($i = 0; $i < $count; ++$i) { + $ret .= $base[random_int(0, $strlen - 1)]; + } - return $ret; - } + return $ret; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Filterable.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Filterable.php index efa1b1def5e..9073bf5b663 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Filterable.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Filterable.php @@ -15,17 +15,17 @@ */ interface Swift_Filterable { - /** - * Add a new StreamFilter, referenced by $key. - * - * @param string $key - */ - public function addFilter(Swift_StreamFilter $filter, $key); + /** + * Add a new StreamFilter, referenced by $key. + * + * @param string $key + */ + public function addFilter(Swift_StreamFilter $filter, $key); - /** - * Remove an existing filter using $key. - * - * @param string $key - */ - public function removeFilter($key); + /** + * Remove an existing filter using $key. + * + * @param string $key + */ + public function removeFilter($key); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/InputByteStream.php b/htdocs/includes/swiftmailer/lib/classes/Swift/InputByteStream.php index 379a5a17870..67a12acc6f5 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/InputByteStream.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/InputByteStream.php @@ -18,58 +18,58 @@ */ interface Swift_InputByteStream { - /** - * Writes $bytes to the end of the stream. - * - * Writing may not happen immediately if the stream chooses to buffer. If - * you want to write these bytes with immediate effect, call {@link commit()} - * after calling write(). - * - * This method returns the sequence ID of the write (i.e. 1 for first, 2 for - * second, etc etc). - * - * @param string $bytes - * - * @throws Swift_IoException - * - * @return int - */ - public function write($bytes); + /** + * Writes $bytes to the end of the stream. + * + * Writing may not happen immediately if the stream chooses to buffer. If + * you want to write these bytes with immediate effect, call {@link commit()} + * after calling write(). + * + * This method returns the sequence ID of the write (i.e. 1 for first, 2 for + * second, etc etc). + * + * @param string $bytes + * + * @throws Swift_IoException + * + * @return int + */ + public function write($bytes); - /** - * For any bytes that are currently buffered inside the stream, force them - * off the buffer. - * - * @throws Swift_IoException - */ - public function commit(); + /** + * For any bytes that are currently buffered inside the stream, force them + * off the buffer. + * + * @throws Swift_IoException + */ + public function commit(); - /** - * Attach $is to this stream. - * - * The stream acts as an observer, receiving all data that is written. - * All {@link write()} and {@link flushBuffers()} operations will be mirrored. - * - * @param Swift_InputByteStream $is - */ - public function bind(self $is); + /** + * Attach $is to this stream. + * + * The stream acts as an observer, receiving all data that is written. + * All {@link write()} and {@link flushBuffers()} operations will be mirrored. + * + * @param Swift_InputByteStream $is + */ + public function bind(self $is); - /** - * Remove an already bound stream. - * - * If $is is not bound, no errors will be raised. - * If the stream currently has any buffered data it will be written to $is - * before unbinding occurs. - * - * @param Swift_InputByteStream $is - */ - public function unbind(self $is); + /** + * Remove an already bound stream. + * + * If $is is not bound, no errors will be raised. + * If the stream currently has any buffered data it will be written to $is + * before unbinding occurs. + * + * @param Swift_InputByteStream $is + */ + public function unbind(self $is); - /** - * Flush the contents of the stream (empty it) and set the internal pointer - * to the beginning. - * - * @throws Swift_IoException - */ - public function flushBuffers(); + /** + * Flush the contents of the stream (empty it) and set the internal pointer + * to the beginning. + * + * @throws Swift_IoException + */ + public function flushBuffers(); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/IoException.php b/htdocs/includes/swiftmailer/lib/classes/Swift/IoException.php index 5452bd416a6..8a8b9ff9029 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/IoException.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/IoException.php @@ -15,14 +15,14 @@ */ class Swift_IoException extends Swift_SwiftException { - /** - * Create a new IoException with $message. - * - * @param string $message - * @param int $code - */ - public function __construct($message, $code = 0, Exception $previous = null) - { - parent::__construct($message, $code, $previous); - } + /** + * Create a new IoException with $message. + * + * @param string $message + * @param int $code + */ + public function __construct($message, $code = 0, Exception $previous = null) + { + parent::__construct($message, $code, $previous); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache.php b/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache.php index 87f6a074212..791085d85e7 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache.php @@ -15,90 +15,90 @@ */ interface Swift_KeyCache { - /** Mode for replacing existing cached data */ - const MODE_WRITE = 1; + /** Mode for replacing existing cached data */ + const MODE_WRITE = 1; - /** Mode for appending data to the end of existing cached data */ - const MODE_APPEND = 2; + /** Mode for appending data to the end of existing cached data */ + const MODE_APPEND = 2; - /** - * Set a string into the cache under $itemKey for the namespace $nsKey. - * - * @see MODE_WRITE, MODE_APPEND - * - * @param string $nsKey - * @param string $itemKey - * @param string $string - * @param int $mode - */ - public function setString($nsKey, $itemKey, $string, $mode); + /** + * Set a string into the cache under $itemKey for the namespace $nsKey. + * + * @see MODE_WRITE, MODE_APPEND + * + * @param string $nsKey + * @param string $itemKey + * @param string $string + * @param int $mode + */ + public function setString($nsKey, $itemKey, $string, $mode); - /** - * Set a ByteStream into the cache under $itemKey for the namespace $nsKey. - * - * @see MODE_WRITE, MODE_APPEND - * - * @param string $nsKey - * @param string $itemKey - * @param int $mode - */ - public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $os, $mode); + /** + * Set a ByteStream into the cache under $itemKey for the namespace $nsKey. + * + * @see MODE_WRITE, MODE_APPEND + * + * @param string $nsKey + * @param string $itemKey + * @param int $mode + */ + public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $os, $mode); - /** - * Provides a ByteStream which when written to, writes data to $itemKey. - * - * NOTE: The stream will always write in append mode. - * If the optional third parameter is passed all writes will go through $is. - * - * @param string $nsKey - * @param string $itemKey - * @param Swift_InputByteStream $is optional input stream - * - * @return Swift_InputByteStream - */ - public function getInputByteStream($nsKey, $itemKey, Swift_InputByteStream $is = null); + /** + * Provides a ByteStream which when written to, writes data to $itemKey. + * + * NOTE: The stream will always write in append mode. + * If the optional third parameter is passed all writes will go through $is. + * + * @param string $nsKey + * @param string $itemKey + * @param Swift_InputByteStream $is optional input stream + * + * @return Swift_InputByteStream + */ + public function getInputByteStream($nsKey, $itemKey, Swift_InputByteStream $is = null); - /** - * Get data back out of the cache as a string. - * - * @param string $nsKey - * @param string $itemKey - * - * @return string - */ - public function getString($nsKey, $itemKey); + /** + * Get data back out of the cache as a string. + * + * @param string $nsKey + * @param string $itemKey + * + * @return string + */ + public function getString($nsKey, $itemKey); - /** - * Get data back out of the cache as a ByteStream. - * - * @param string $nsKey - * @param string $itemKey - * @param Swift_InputByteStream $is stream to write the data to - */ - public function exportToByteStream($nsKey, $itemKey, Swift_InputByteStream $is); + /** + * Get data back out of the cache as a ByteStream. + * + * @param string $nsKey + * @param string $itemKey + * @param Swift_InputByteStream $is stream to write the data to + */ + public function exportToByteStream($nsKey, $itemKey, Swift_InputByteStream $is); - /** - * Check if the given $itemKey exists in the namespace $nsKey. - * - * @param string $nsKey - * @param string $itemKey - * - * @return bool - */ - public function hasKey($nsKey, $itemKey); + /** + * Check if the given $itemKey exists in the namespace $nsKey. + * + * @param string $nsKey + * @param string $itemKey + * + * @return bool + */ + public function hasKey($nsKey, $itemKey); - /** - * Clear data for $itemKey in the namespace $nsKey if it exists. - * - * @param string $nsKey - * @param string $itemKey - */ - public function clearKey($nsKey, $itemKey); + /** + * Clear data for $itemKey in the namespace $nsKey if it exists. + * + * @param string $nsKey + * @param string $itemKey + */ + public function clearKey($nsKey, $itemKey); - /** - * Clear all data in the namespace $nsKey if it exists. - * - * @param string $nsKey - */ - public function clearAll($nsKey); + /** + * Clear all data in the namespace $nsKey if it exists. + * + * @param string $nsKey + */ + public function clearAll($nsKey); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/ArrayKeyCache.php b/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/ArrayKeyCache.php index e8fef1c95d4..92a6c2d107e 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/ArrayKeyCache.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/ArrayKeyCache.php @@ -15,183 +15,183 @@ */ class Swift_KeyCache_ArrayKeyCache implements Swift_KeyCache { - /** - * Cache contents. - * - * @var array - */ - private $contents = []; + /** + * Cache contents. + * + * @var array + */ + private $contents = []; - /** - * An InputStream for cloning. - * - * @var Swift_KeyCache_KeyCacheInputStream - */ - private $stream; + /** + * An InputStream for cloning. + * + * @var Swift_KeyCache_KeyCacheInputStream + */ + private $stream; - /** - * Create a new ArrayKeyCache with the given $stream for cloning to make - * InputByteStreams. - */ - public function __construct(Swift_KeyCache_KeyCacheInputStream $stream) - { - $this->stream = $stream; - } + /** + * Create a new ArrayKeyCache with the given $stream for cloning to make + * InputByteStreams. + */ + public function __construct(Swift_KeyCache_KeyCacheInputStream $stream) + { + $this->stream = $stream; + } - /** - * Set a string into the cache under $itemKey for the namespace $nsKey. - * - * @see MODE_WRITE, MODE_APPEND - * - * @param string $nsKey - * @param string $itemKey - * @param string $string - * @param int $mode - */ - public function setString($nsKey, $itemKey, $string, $mode) - { - $this->prepareCache($nsKey); - switch ($mode) { - case self::MODE_WRITE: - $this->contents[$nsKey][$itemKey] = $string; - break; - case self::MODE_APPEND: - if (!$this->hasKey($nsKey, $itemKey)) { - $this->contents[$nsKey][$itemKey] = ''; - } - $this->contents[$nsKey][$itemKey] .= $string; - break; - default: - throw new Swift_SwiftException('Invalid mode ['.$mode.'] used to set nsKey='.$nsKey.', itemKey='.$itemKey); - } - } + /** + * Set a string into the cache under $itemKey for the namespace $nsKey. + * + * @see MODE_WRITE, MODE_APPEND + * + * @param string $nsKey + * @param string $itemKey + * @param string $string + * @param int $mode + */ + public function setString($nsKey, $itemKey, $string, $mode) + { + $this->prepareCache($nsKey); + switch ($mode) { + case self::MODE_WRITE: + $this->contents[$nsKey][$itemKey] = $string; + break; + case self::MODE_APPEND: + if (!$this->hasKey($nsKey, $itemKey)) { + $this->contents[$nsKey][$itemKey] = ''; + } + $this->contents[$nsKey][$itemKey] .= $string; + break; + default: + throw new Swift_SwiftException('Invalid mode ['.$mode.'] used to set nsKey='.$nsKey.', itemKey='.$itemKey); + } + } - /** - * Set a ByteStream into the cache under $itemKey for the namespace $nsKey. - * - * @see MODE_WRITE, MODE_APPEND - * - * @param string $nsKey - * @param string $itemKey - * @param int $mode - */ - public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $os, $mode) - { - $this->prepareCache($nsKey); - switch ($mode) { - case self::MODE_WRITE: - $this->clearKey($nsKey, $itemKey); - // no break - case self::MODE_APPEND: - if (!$this->hasKey($nsKey, $itemKey)) { - $this->contents[$nsKey][$itemKey] = ''; - } - while (false !== $bytes = $os->read(8192)) { - $this->contents[$nsKey][$itemKey] .= $bytes; - } - break; - default: - throw new Swift_SwiftException('Invalid mode ['.$mode.'] used to set nsKey='.$nsKey.', itemKey='.$itemKey); - } - } + /** + * Set a ByteStream into the cache under $itemKey for the namespace $nsKey. + * + * @see MODE_WRITE, MODE_APPEND + * + * @param string $nsKey + * @param string $itemKey + * @param int $mode + */ + public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $os, $mode) + { + $this->prepareCache($nsKey); + switch ($mode) { + case self::MODE_WRITE: + $this->clearKey($nsKey, $itemKey); + // no break + case self::MODE_APPEND: + if (!$this->hasKey($nsKey, $itemKey)) { + $this->contents[$nsKey][$itemKey] = ''; + } + while (false !== $bytes = $os->read(8192)) { + $this->contents[$nsKey][$itemKey] .= $bytes; + } + break; + default: + throw new Swift_SwiftException('Invalid mode ['.$mode.'] used to set nsKey='.$nsKey.', itemKey='.$itemKey); + } + } - /** - * Provides a ByteStream which when written to, writes data to $itemKey. - * - * NOTE: The stream will always write in append mode. - * - * @param string $nsKey - * @param string $itemKey - * - * @return Swift_InputByteStream - */ - public function getInputByteStream($nsKey, $itemKey, Swift_InputByteStream $writeThrough = null) - { - $is = clone $this->stream; - $is->setKeyCache($this); - $is->setNsKey($nsKey); - $is->setItemKey($itemKey); - if (isset($writeThrough)) { - $is->setWriteThroughStream($writeThrough); - } + /** + * Provides a ByteStream which when written to, writes data to $itemKey. + * + * NOTE: The stream will always write in append mode. + * + * @param string $nsKey + * @param string $itemKey + * + * @return Swift_InputByteStream + */ + public function getInputByteStream($nsKey, $itemKey, Swift_InputByteStream $writeThrough = null) + { + $is = clone $this->stream; + $is->setKeyCache($this); + $is->setNsKey($nsKey); + $is->setItemKey($itemKey); + if (isset($writeThrough)) { + $is->setWriteThroughStream($writeThrough); + } - return $is; - } + return $is; + } - /** - * Get data back out of the cache as a string. - * - * @param string $nsKey - * @param string $itemKey - * - * @return string - */ - public function getString($nsKey, $itemKey) - { - $this->prepareCache($nsKey); - if ($this->hasKey($nsKey, $itemKey)) { - return $this->contents[$nsKey][$itemKey]; - } - } + /** + * Get data back out of the cache as a string. + * + * @param string $nsKey + * @param string $itemKey + * + * @return string + */ + public function getString($nsKey, $itemKey) + { + $this->prepareCache($nsKey); + if ($this->hasKey($nsKey, $itemKey)) { + return $this->contents[$nsKey][$itemKey]; + } + } - /** - * Get data back out of the cache as a ByteStream. - * - * @param string $nsKey - * @param string $itemKey - * @param Swift_InputByteStream $is to write the data to - */ - public function exportToByteStream($nsKey, $itemKey, Swift_InputByteStream $is) - { - $this->prepareCache($nsKey); - $is->write($this->getString($nsKey, $itemKey)); - } + /** + * Get data back out of the cache as a ByteStream. + * + * @param string $nsKey + * @param string $itemKey + * @param Swift_InputByteStream $is to write the data to + */ + public function exportToByteStream($nsKey, $itemKey, Swift_InputByteStream $is) + { + $this->prepareCache($nsKey); + $is->write($this->getString($nsKey, $itemKey)); + } - /** - * Check if the given $itemKey exists in the namespace $nsKey. - * - * @param string $nsKey - * @param string $itemKey - * - * @return bool - */ - public function hasKey($nsKey, $itemKey) - { - $this->prepareCache($nsKey); + /** + * Check if the given $itemKey exists in the namespace $nsKey. + * + * @param string $nsKey + * @param string $itemKey + * + * @return bool + */ + public function hasKey($nsKey, $itemKey) + { + $this->prepareCache($nsKey); - return \array_key_exists($itemKey, $this->contents[$nsKey]); - } + return \array_key_exists($itemKey, $this->contents[$nsKey]); + } - /** - * Clear data for $itemKey in the namespace $nsKey if it exists. - * - * @param string $nsKey - * @param string $itemKey - */ - public function clearKey($nsKey, $itemKey) - { - unset($this->contents[$nsKey][$itemKey]); - } + /** + * Clear data for $itemKey in the namespace $nsKey if it exists. + * + * @param string $nsKey + * @param string $itemKey + */ + public function clearKey($nsKey, $itemKey) + { + unset($this->contents[$nsKey][$itemKey]); + } - /** - * Clear all data in the namespace $nsKey if it exists. - * - * @param string $nsKey - */ - public function clearAll($nsKey) - { - unset($this->contents[$nsKey]); - } + /** + * Clear all data in the namespace $nsKey if it exists. + * + * @param string $nsKey + */ + public function clearAll($nsKey) + { + unset($this->contents[$nsKey]); + } - /** - * Initialize the namespace of $nsKey if needed. - * - * @param string $nsKey - */ - private function prepareCache($nsKey) - { - if (!\array_key_exists($nsKey, $this->contents)) { - $this->contents[$nsKey] = []; - } - } + /** + * Initialize the namespace of $nsKey if needed. + * + * @param string $nsKey + */ + private function prepareCache($nsKey) + { + if (!\array_key_exists($nsKey, $this->contents)) { + $this->contents[$nsKey] = []; + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/DiskKeyCache.php b/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/DiskKeyCache.php index 33b6367cb8b..4075b928e13 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/DiskKeyCache.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/DiskKeyCache.php @@ -15,280 +15,280 @@ */ class Swift_KeyCache_DiskKeyCache implements Swift_KeyCache { - /** Signal to place pointer at start of file */ - const POSITION_START = 0; + /** Signal to place pointer at start of file */ + const POSITION_START = 0; - /** Signal to place pointer at end of file */ - const POSITION_END = 1; + /** Signal to place pointer at end of file */ + const POSITION_END = 1; - /** Signal to leave pointer in whatever position it currently is */ - const POSITION_CURRENT = 2; + /** Signal to leave pointer in whatever position it currently is */ + const POSITION_CURRENT = 2; - /** - * An InputStream for cloning. - * - * @var Swift_KeyCache_KeyCacheInputStream - */ - private $stream; + /** + * An InputStream for cloning. + * + * @var Swift_KeyCache_KeyCacheInputStream + */ + private $stream; - /** - * A path to write to. - * - * @var string - */ - private $path; + /** + * A path to write to. + * + * @var string + */ + private $path; - /** - * Stored keys. - * - * @var array - */ - private $keys = []; + /** + * Stored keys. + * + * @var array + */ + private $keys = []; - /** - * Create a new DiskKeyCache with the given $stream for cloning to make - * InputByteStreams, and the given $path to save to. - * - * @param string $path to save to - */ - public function __construct(Swift_KeyCache_KeyCacheInputStream $stream, $path) - { - $this->stream = $stream; - $this->path = $path; - } + /** + * Create a new DiskKeyCache with the given $stream for cloning to make + * InputByteStreams, and the given $path to save to. + * + * @param string $path to save to + */ + public function __construct(Swift_KeyCache_KeyCacheInputStream $stream, $path) + { + $this->stream = $stream; + $this->path = $path; + } - /** - * Set a string into the cache under $itemKey for the namespace $nsKey. - * - * @see MODE_WRITE, MODE_APPEND - * - * @param string $nsKey - * @param string $itemKey - * @param string $string - * @param int $mode - * - * @throws Swift_IoException - */ - public function setString($nsKey, $itemKey, $string, $mode) - { - $this->prepareCache($nsKey); - switch ($mode) { - case self::MODE_WRITE: - $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_START); - break; - case self::MODE_APPEND: - $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_END); - break; - default: - throw new Swift_SwiftException('Invalid mode ['.$mode.'] used to set nsKey='.$nsKey.', itemKey='.$itemKey); - break; - } - fwrite($fp, $string); - $this->freeHandle($nsKey, $itemKey); - } + /** + * Set a string into the cache under $itemKey for the namespace $nsKey. + * + * @see MODE_WRITE, MODE_APPEND + * + * @param string $nsKey + * @param string $itemKey + * @param string $string + * @param int $mode + * + * @throws Swift_IoException + */ + public function setString($nsKey, $itemKey, $string, $mode) + { + $this->prepareCache($nsKey); + switch ($mode) { + case self::MODE_WRITE: + $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_START); + break; + case self::MODE_APPEND: + $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_END); + break; + default: + throw new Swift_SwiftException('Invalid mode ['.$mode.'] used to set nsKey='.$nsKey.', itemKey='.$itemKey); + break; + } + fwrite($fp, $string); + $this->freeHandle($nsKey, $itemKey); + } - /** - * Set a ByteStream into the cache under $itemKey for the namespace $nsKey. - * - * @see MODE_WRITE, MODE_APPEND - * - * @param string $nsKey - * @param string $itemKey - * @param int $mode - * - * @throws Swift_IoException - */ - public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $os, $mode) - { - $this->prepareCache($nsKey); - switch ($mode) { - case self::MODE_WRITE: - $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_START); - break; - case self::MODE_APPEND: - $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_END); - break; - default: - throw new Swift_SwiftException('Invalid mode ['.$mode.'] used to set nsKey='.$nsKey.', itemKey='.$itemKey); - break; - } - while (false !== $bytes = $os->read(8192)) { - fwrite($fp, $bytes); - } - $this->freeHandle($nsKey, $itemKey); - } + /** + * Set a ByteStream into the cache under $itemKey for the namespace $nsKey. + * + * @see MODE_WRITE, MODE_APPEND + * + * @param string $nsKey + * @param string $itemKey + * @param int $mode + * + * @throws Swift_IoException + */ + public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $os, $mode) + { + $this->prepareCache($nsKey); + switch ($mode) { + case self::MODE_WRITE: + $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_START); + break; + case self::MODE_APPEND: + $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_END); + break; + default: + throw new Swift_SwiftException('Invalid mode ['.$mode.'] used to set nsKey='.$nsKey.', itemKey='.$itemKey); + break; + } + while (false !== $bytes = $os->read(8192)) { + fwrite($fp, $bytes); + } + $this->freeHandle($nsKey, $itemKey); + } - /** - * Provides a ByteStream which when written to, writes data to $itemKey. - * - * NOTE: The stream will always write in append mode. - * - * @param string $nsKey - * @param string $itemKey - * - * @return Swift_InputByteStream - */ - public function getInputByteStream($nsKey, $itemKey, Swift_InputByteStream $writeThrough = null) - { - $is = clone $this->stream; - $is->setKeyCache($this); - $is->setNsKey($nsKey); - $is->setItemKey($itemKey); - if (isset($writeThrough)) { - $is->setWriteThroughStream($writeThrough); - } + /** + * Provides a ByteStream which when written to, writes data to $itemKey. + * + * NOTE: The stream will always write in append mode. + * + * @param string $nsKey + * @param string $itemKey + * + * @return Swift_InputByteStream + */ + public function getInputByteStream($nsKey, $itemKey, Swift_InputByteStream $writeThrough = null) + { + $is = clone $this->stream; + $is->setKeyCache($this); + $is->setNsKey($nsKey); + $is->setItemKey($itemKey); + if (isset($writeThrough)) { + $is->setWriteThroughStream($writeThrough); + } - return $is; - } + return $is; + } - /** - * Get data back out of the cache as a string. - * - * @param string $nsKey - * @param string $itemKey - * - * @throws Swift_IoException - * - * @return string - */ - public function getString($nsKey, $itemKey) - { - $this->prepareCache($nsKey); - if ($this->hasKey($nsKey, $itemKey)) { - $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_START); - $str = ''; - while (!feof($fp) && false !== $bytes = fread($fp, 8192)) { - $str .= $bytes; - } - $this->freeHandle($nsKey, $itemKey); + /** + * Get data back out of the cache as a string. + * + * @param string $nsKey + * @param string $itemKey + * + * @throws Swift_IoException + * + * @return string + */ + public function getString($nsKey, $itemKey) + { + $this->prepareCache($nsKey); + if ($this->hasKey($nsKey, $itemKey)) { + $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_START); + $str = ''; + while (!feof($fp) && false !== $bytes = fread($fp, 8192)) { + $str .= $bytes; + } + $this->freeHandle($nsKey, $itemKey); - return $str; - } - } + return $str; + } + } - /** - * Get data back out of the cache as a ByteStream. - * - * @param string $nsKey - * @param string $itemKey - * @param Swift_InputByteStream $is to write the data to - */ - public function exportToByteStream($nsKey, $itemKey, Swift_InputByteStream $is) - { - if ($this->hasKey($nsKey, $itemKey)) { - $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_START); - while (!feof($fp) && false !== $bytes = fread($fp, 8192)) { - $is->write($bytes); - } - $this->freeHandle($nsKey, $itemKey); - } - } + /** + * Get data back out of the cache as a ByteStream. + * + * @param string $nsKey + * @param string $itemKey + * @param Swift_InputByteStream $is to write the data to + */ + public function exportToByteStream($nsKey, $itemKey, Swift_InputByteStream $is) + { + if ($this->hasKey($nsKey, $itemKey)) { + $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_START); + while (!feof($fp) && false !== $bytes = fread($fp, 8192)) { + $is->write($bytes); + } + $this->freeHandle($nsKey, $itemKey); + } + } - /** - * Check if the given $itemKey exists in the namespace $nsKey. - * - * @param string $nsKey - * @param string $itemKey - * - * @return bool - */ - public function hasKey($nsKey, $itemKey) - { - return is_file($this->path.'/'.$nsKey.'/'.$itemKey); - } + /** + * Check if the given $itemKey exists in the namespace $nsKey. + * + * @param string $nsKey + * @param string $itemKey + * + * @return bool + */ + public function hasKey($nsKey, $itemKey) + { + return is_file($this->path.'/'.$nsKey.'/'.$itemKey); + } - /** - * Clear data for $itemKey in the namespace $nsKey if it exists. - * - * @param string $nsKey - * @param string $itemKey - */ - public function clearKey($nsKey, $itemKey) - { - if ($this->hasKey($nsKey, $itemKey)) { - $this->freeHandle($nsKey, $itemKey); - unlink($this->path.'/'.$nsKey.'/'.$itemKey); - } - } + /** + * Clear data for $itemKey in the namespace $nsKey if it exists. + * + * @param string $nsKey + * @param string $itemKey + */ + public function clearKey($nsKey, $itemKey) + { + if ($this->hasKey($nsKey, $itemKey)) { + $this->freeHandle($nsKey, $itemKey); + unlink($this->path.'/'.$nsKey.'/'.$itemKey); + } + } - /** - * Clear all data in the namespace $nsKey if it exists. - * - * @param string $nsKey - */ - public function clearAll($nsKey) - { - if (\array_key_exists($nsKey, $this->keys)) { - foreach ($this->keys[$nsKey] as $itemKey => $null) { - $this->clearKey($nsKey, $itemKey); - } - if (is_dir($this->path.'/'.$nsKey)) { - rmdir($this->path.'/'.$nsKey); - } - unset($this->keys[$nsKey]); - } - } + /** + * Clear all data in the namespace $nsKey if it exists. + * + * @param string $nsKey + */ + public function clearAll($nsKey) + { + if (\array_key_exists($nsKey, $this->keys)) { + foreach ($this->keys[$nsKey] as $itemKey => $null) { + $this->clearKey($nsKey, $itemKey); + } + if (is_dir($this->path.'/'.$nsKey)) { + rmdir($this->path.'/'.$nsKey); + } + unset($this->keys[$nsKey]); + } + } - /** - * Initialize the namespace of $nsKey if needed. - * - * @param string $nsKey - */ - private function prepareCache($nsKey) - { - $cacheDir = $this->path.'/'.$nsKey; - if (!is_dir($cacheDir)) { - if (!mkdir($cacheDir)) { - throw new Swift_IoException('Failed to create cache directory '.$cacheDir); - } - $this->keys[$nsKey] = []; - } - } + /** + * Initialize the namespace of $nsKey if needed. + * + * @param string $nsKey + */ + private function prepareCache($nsKey) + { + $cacheDir = $this->path.'/'.$nsKey; + if (!is_dir($cacheDir)) { + if (!mkdir($cacheDir)) { + throw new Swift_IoException('Failed to create cache directory '.$cacheDir); + } + $this->keys[$nsKey] = []; + } + } - /** - * Get a file handle on the cache item. - * - * @param string $nsKey - * @param string $itemKey - * @param int $position - * - * @return resource - */ - private function getHandle($nsKey, $itemKey, $position) - { - if (!isset($this->keys[$nsKey][$itemKey])) { - $openMode = $this->hasKey($nsKey, $itemKey) ? 'r+b' : 'w+b'; - $fp = fopen($this->path.'/'.$nsKey.'/'.$itemKey, $openMode); - $this->keys[$nsKey][$itemKey] = $fp; - } - if (self::POSITION_START == $position) { - fseek($this->keys[$nsKey][$itemKey], 0, SEEK_SET); - } elseif (self::POSITION_END == $position) { - fseek($this->keys[$nsKey][$itemKey], 0, SEEK_END); - } + /** + * Get a file handle on the cache item. + * + * @param string $nsKey + * @param string $itemKey + * @param int $position + * + * @return resource + */ + private function getHandle($nsKey, $itemKey, $position) + { + if (!isset($this->keys[$nsKey][$itemKey])) { + $openMode = $this->hasKey($nsKey, $itemKey) ? 'r+b' : 'w+b'; + $fp = fopen($this->path.'/'.$nsKey.'/'.$itemKey, $openMode); + $this->keys[$nsKey][$itemKey] = $fp; + } + if (self::POSITION_START == $position) { + fseek($this->keys[$nsKey][$itemKey], 0, SEEK_SET); + } elseif (self::POSITION_END == $position) { + fseek($this->keys[$nsKey][$itemKey], 0, SEEK_END); + } - return $this->keys[$nsKey][$itemKey]; - } + return $this->keys[$nsKey][$itemKey]; + } - private function freeHandle($nsKey, $itemKey) - { - $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_CURRENT); - fclose($fp); - $this->keys[$nsKey][$itemKey] = null; - } + private function freeHandle($nsKey, $itemKey) + { + $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_CURRENT); + fclose($fp); + $this->keys[$nsKey][$itemKey] = null; + } - /** - * Destructor. - */ - public function __destruct() - { - foreach ($this->keys as $nsKey => $null) { - $this->clearAll($nsKey); - } - } + /** + * Destructor. + */ + public function __destruct() + { + foreach ($this->keys as $nsKey => $null) { + $this->clearAll($nsKey); + } + } - public function __wakeup() - { - $this->keys = []; - } + public function __wakeup() + { + $this->keys = []; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/KeyCacheInputStream.php b/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/KeyCacheInputStream.php index be2dbba0c58..159f97643cd 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/KeyCacheInputStream.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/KeyCacheInputStream.php @@ -15,33 +15,33 @@ */ interface Swift_KeyCache_KeyCacheInputStream extends Swift_InputByteStream { - /** - * Set the KeyCache to wrap. - */ - public function setKeyCache(Swift_KeyCache $keyCache); + /** + * Set the KeyCache to wrap. + */ + public function setKeyCache(Swift_KeyCache $keyCache); - /** - * Set the nsKey which will be written to. - * - * @param string $nsKey - */ - public function setNsKey($nsKey); + /** + * Set the nsKey which will be written to. + * + * @param string $nsKey + */ + public function setNsKey($nsKey); - /** - * Set the itemKey which will be written to. - * - * @param string $itemKey - */ - public function setItemKey($itemKey); + /** + * Set the itemKey which will be written to. + * + * @param string $itemKey + */ + public function setItemKey($itemKey); - /** - * Specify a stream to write through for each write(). - */ - public function setWriteThroughStream(Swift_InputByteStream $is); + /** + * Specify a stream to write through for each write(). + */ + public function setWriteThroughStream(Swift_InputByteStream $is); - /** - * Any implementation should be cloneable, allowing the clone to access a - * separate $nsKey and $itemKey. - */ - public function __clone(); + /** + * Any implementation should be cloneable, allowing the clone to access a + * separate $nsKey and $itemKey. + */ + public function __clone(); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/NullKeyCache.php b/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/NullKeyCache.php index 957b1b2a000..2b04d77fe4f 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/NullKeyCache.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/NullKeyCache.php @@ -15,99 +15,99 @@ */ class Swift_KeyCache_NullKeyCache implements Swift_KeyCache { - /** - * Set a string into the cache under $itemKey for the namespace $nsKey. - * - * @see MODE_WRITE, MODE_APPEND - * - * @param string $nsKey - * @param string $itemKey - * @param string $string - * @param int $mode - */ - public function setString($nsKey, $itemKey, $string, $mode) - { - } + /** + * Set a string into the cache under $itemKey for the namespace $nsKey. + * + * @see MODE_WRITE, MODE_APPEND + * + * @param string $nsKey + * @param string $itemKey + * @param string $string + * @param int $mode + */ + public function setString($nsKey, $itemKey, $string, $mode) + { + } - /** - * Set a ByteStream into the cache under $itemKey for the namespace $nsKey. - * - * @see MODE_WRITE, MODE_APPEND - * - * @param string $nsKey - * @param string $itemKey - * @param int $mode - */ - public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $os, $mode) - { - } + /** + * Set a ByteStream into the cache under $itemKey for the namespace $nsKey. + * + * @see MODE_WRITE, MODE_APPEND + * + * @param string $nsKey + * @param string $itemKey + * @param int $mode + */ + public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $os, $mode) + { + } - /** - * Provides a ByteStream which when written to, writes data to $itemKey. - * - * NOTE: The stream will always write in append mode. - * - * @param string $nsKey - * @param string $itemKey - * - * @return Swift_InputByteStream - */ - public function getInputByteStream($nsKey, $itemKey, Swift_InputByteStream $writeThrough = null) - { - } + /** + * Provides a ByteStream which when written to, writes data to $itemKey. + * + * NOTE: The stream will always write in append mode. + * + * @param string $nsKey + * @param string $itemKey + * + * @return Swift_InputByteStream + */ + public function getInputByteStream($nsKey, $itemKey, Swift_InputByteStream $writeThrough = null) + { + } - /** - * Get data back out of the cache as a string. - * - * @param string $nsKey - * @param string $itemKey - * - * @return string - */ - public function getString($nsKey, $itemKey) - { - } + /** + * Get data back out of the cache as a string. + * + * @param string $nsKey + * @param string $itemKey + * + * @return string + */ + public function getString($nsKey, $itemKey) + { + } - /** - * Get data back out of the cache as a ByteStream. - * - * @param string $nsKey - * @param string $itemKey - * @param Swift_InputByteStream $is to write the data to - */ - public function exportToByteStream($nsKey, $itemKey, Swift_InputByteStream $is) - { - } + /** + * Get data back out of the cache as a ByteStream. + * + * @param string $nsKey + * @param string $itemKey + * @param Swift_InputByteStream $is to write the data to + */ + public function exportToByteStream($nsKey, $itemKey, Swift_InputByteStream $is) + { + } - /** - * Check if the given $itemKey exists in the namespace $nsKey. - * - * @param string $nsKey - * @param string $itemKey - * - * @return bool - */ - public function hasKey($nsKey, $itemKey) - { - return false; - } + /** + * Check if the given $itemKey exists in the namespace $nsKey. + * + * @param string $nsKey + * @param string $itemKey + * + * @return bool + */ + public function hasKey($nsKey, $itemKey) + { + return false; + } - /** - * Clear data for $itemKey in the namespace $nsKey if it exists. - * - * @param string $nsKey - * @param string $itemKey - */ - public function clearKey($nsKey, $itemKey) - { - } + /** + * Clear data for $itemKey in the namespace $nsKey if it exists. + * + * @param string $nsKey + * @param string $itemKey + */ + public function clearKey($nsKey, $itemKey) + { + } - /** - * Clear all data in the namespace $nsKey if it exists. - * - * @param string $nsKey - */ - public function clearAll($nsKey) - { - } + /** + * Clear all data in the namespace $nsKey if it exists. + * + * @param string $nsKey + */ + public function clearAll($nsKey) + { + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php b/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php index 03bab481ea3..d9d75e078c7 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php @@ -15,109 +15,109 @@ */ class Swift_KeyCache_SimpleKeyCacheInputStream implements Swift_KeyCache_KeyCacheInputStream { - /** The KeyCache being written to */ - private $keyCache; + /** The KeyCache being written to */ + private $keyCache; - /** The nsKey of the KeyCache being written to */ - private $nsKey; + /** The nsKey of the KeyCache being written to */ + private $nsKey; - /** The itemKey of the KeyCache being written to */ - private $itemKey; + /** The itemKey of the KeyCache being written to */ + private $itemKey; - /** A stream to write through on each write() */ - private $writeThrough = null; + /** A stream to write through on each write() */ + private $writeThrough = null; - /** - * Set the KeyCache to wrap. - */ - public function setKeyCache(Swift_KeyCache $keyCache) - { - $this->keyCache = $keyCache; - } + /** + * Set the KeyCache to wrap. + */ + public function setKeyCache(Swift_KeyCache $keyCache) + { + $this->keyCache = $keyCache; + } - /** - * Specify a stream to write through for each write(). - */ - public function setWriteThroughStream(Swift_InputByteStream $is) - { - $this->writeThrough = $is; - } + /** + * Specify a stream to write through for each write(). + */ + public function setWriteThroughStream(Swift_InputByteStream $is) + { + $this->writeThrough = $is; + } - /** - * Writes $bytes to the end of the stream. - * - * @param string $bytes - * @param Swift_InputByteStream $is optional - */ - public function write($bytes, Swift_InputByteStream $is = null) - { - $this->keyCache->setString( - $this->nsKey, $this->itemKey, $bytes, Swift_KeyCache::MODE_APPEND - ); - if (isset($is)) { - $is->write($bytes); - } - if (isset($this->writeThrough)) { - $this->writeThrough->write($bytes); - } - } + /** + * Writes $bytes to the end of the stream. + * + * @param string $bytes + * @param Swift_InputByteStream $is optional + */ + public function write($bytes, Swift_InputByteStream $is = null) + { + $this->keyCache->setString( + $this->nsKey, $this->itemKey, $bytes, Swift_KeyCache::MODE_APPEND + ); + if (isset($is)) { + $is->write($bytes); + } + if (isset($this->writeThrough)) { + $this->writeThrough->write($bytes); + } + } - /** - * Not used. - */ - public function commit() - { - } + /** + * Not used. + */ + public function commit() + { + } - /** - * Not used. - */ - public function bind(Swift_InputByteStream $is) - { - } + /** + * Not used. + */ + public function bind(Swift_InputByteStream $is) + { + } - /** - * Not used. - */ - public function unbind(Swift_InputByteStream $is) - { - } + /** + * Not used. + */ + public function unbind(Swift_InputByteStream $is) + { + } - /** - * Flush the contents of the stream (empty it) and set the internal pointer - * to the beginning. - */ - public function flushBuffers() - { - $this->keyCache->clearKey($this->nsKey, $this->itemKey); - } + /** + * Flush the contents of the stream (empty it) and set the internal pointer + * to the beginning. + */ + public function flushBuffers() + { + $this->keyCache->clearKey($this->nsKey, $this->itemKey); + } - /** - * Set the nsKey which will be written to. - * - * @param string $nsKey - */ - public function setNsKey($nsKey) - { - $this->nsKey = $nsKey; - } + /** + * Set the nsKey which will be written to. + * + * @param string $nsKey + */ + public function setNsKey($nsKey) + { + $this->nsKey = $nsKey; + } - /** - * Set the itemKey which will be written to. - * - * @param string $itemKey - */ - public function setItemKey($itemKey) - { - $this->itemKey = $itemKey; - } + /** + * Set the itemKey which will be written to. + * + * @param string $itemKey + */ + public function setItemKey($itemKey) + { + $this->itemKey = $itemKey; + } - /** - * Any implementation should be cloneable, allowing the clone to access a - * separate $nsKey and $itemKey. - */ - public function __clone() - { - $this->writeThrough = null; - } + /** + * Any implementation should be cloneable, allowing the clone to access a + * separate $nsKey and $itemKey. + */ + public function __clone() + { + $this->writeThrough = null; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/LoadBalancedTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/LoadBalancedTransport.php index 244b5f60245..3373f67964e 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/LoadBalancedTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/LoadBalancedTransport.php @@ -15,19 +15,19 @@ */ class Swift_LoadBalancedTransport extends Swift_Transport_LoadBalancedTransport { - /** - * Creates a new LoadBalancedTransport with $transports. - * - * @param array $transports - */ - public function __construct($transports = []) - { - \call_user_func_array( - [$this, 'Swift_Transport_LoadBalancedTransport::__construct'], - Swift_DependencyContainer::getInstance() - ->createDependenciesFor('transport.loadbalanced') - ); + /** + * Creates a new LoadBalancedTransport with $transports. + * + * @param array $transports + */ + public function __construct($transports = []) + { + \call_user_func_array( + [$this, 'Swift_Transport_LoadBalancedTransport::__construct'], + Swift_DependencyContainer::getInstance() + ->createDependenciesFor('transport.loadbalanced') + ); - $this->setTransports($transports); - } + $this->setTransports($transports); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mailer.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mailer.php index 57630074cd9..ef9d66365bb 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mailer.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mailer.php @@ -15,84 +15,84 @@ */ class Swift_Mailer { - /** The Transport used to send messages */ - private $transport; + /** The Transport used to send messages */ + private $transport; - /** - * Create a new Mailer using $transport for delivery. - */ - public function __construct(Swift_Transport $transport) - { - $this->transport = $transport; - } + /** + * Create a new Mailer using $transport for delivery. + */ + public function __construct(Swift_Transport $transport) + { + $this->transport = $transport; + } - /** - * Create a new class instance of one of the message services. - * - * For example 'mimepart' would create a 'message.mimepart' instance - * - * @param string $service - * - * @return object - */ - public function createMessage($service = 'message') - { - return Swift_DependencyContainer::getInstance() - ->lookup('message.'.$service); - } + /** + * Create a new class instance of one of the message services. + * + * For example 'mimepart' would create a 'message.mimepart' instance + * + * @param string $service + * + * @return object + */ + public function createMessage($service = 'message') + { + return Swift_DependencyContainer::getInstance() + ->lookup('message.'.$service); + } - /** - * Send the given Message like it would be sent in a mail client. - * - * All recipients (with the exception of Bcc) will be able to see the other - * recipients this message was sent to. - * - * Recipient/sender data will be retrieved from the Message object. - * - * The return value is the number of recipients who were accepted for - * delivery. - * - * @param array $failedRecipients An array of failures by-reference - * - * @return int The number of successful recipients. Can be 0 which indicates failure - */ - public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) - { - $failedRecipients = (array) $failedRecipients; + /** + * Send the given Message like it would be sent in a mail client. + * + * All recipients (with the exception of Bcc) will be able to see the other + * recipients this message was sent to. + * + * Recipient/sender data will be retrieved from the Message object. + * + * The return value is the number of recipients who were accepted for + * delivery. + * + * @param array $failedRecipients An array of failures by-reference + * + * @return int The number of successful recipients. Can be 0 which indicates failure + */ + public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) + { + $failedRecipients = (array) $failedRecipients; - // FIXME: to be removed in 7.0 (as transport must now start itself on send) - if (!$this->transport->isStarted()) { - $this->transport->start(); - } + // FIXME: to be removed in 7.0 (as transport must now start itself on send) + if (!$this->transport->isStarted()) { + $this->transport->start(); + } - $sent = 0; + $sent = 0; - try { - $sent = $this->transport->send($message, $failedRecipients); - } catch (Swift_RfcComplianceException $e) { - foreach ($message->getTo() as $address => $name) { - $failedRecipients[] = $address; - } - } + try { + $sent = $this->transport->send($message, $failedRecipients); + } catch (Swift_RfcComplianceException $e) { + foreach ($message->getTo() as $address => $name) { + $failedRecipients[] = $address; + } + } - return $sent; - } + return $sent; + } - /** - * Register a plugin using a known unique key (e.g. myPlugin). - */ - public function registerPlugin(Swift_Events_EventListener $plugin) - { - $this->transport->registerPlugin($plugin); - } + /** + * Register a plugin using a known unique key (e.g. myPlugin). + */ + public function registerPlugin(Swift_Events_EventListener $plugin) + { + $this->transport->registerPlugin($plugin); + } - /** - * The Transport used to send messages. - * - * @return Swift_Transport - */ - public function getTransport() - { - return $this->transport; - } + /** + * The Transport used to send messages. + * + * @return Swift_Transport + */ + public function getTransport() + { + return $this->transport; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mailer/ArrayRecipientIterator.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mailer/ArrayRecipientIterator.php index 19aa82a9c40..6ee0b1571a4 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mailer/ArrayRecipientIterator.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mailer/ArrayRecipientIterator.php @@ -15,39 +15,39 @@ */ class Swift_Mailer_ArrayRecipientIterator implements Swift_Mailer_RecipientIterator { - /** - * The list of recipients. - * - * @var array - */ - private $recipients = []; + /** + * The list of recipients. + * + * @var array + */ + private $recipients = []; - /** - * Create a new ArrayRecipientIterator from $recipients. - */ - public function __construct(array $recipients) - { - $this->recipients = $recipients; - } + /** + * Create a new ArrayRecipientIterator from $recipients. + */ + public function __construct(array $recipients) + { + $this->recipients = $recipients; + } - /** - * Returns true only if there are more recipients to send to. - * - * @return bool - */ - public function hasNext() - { - return !empty($this->recipients); - } + /** + * Returns true only if there are more recipients to send to. + * + * @return bool + */ + public function hasNext() + { + return !empty($this->recipients); + } - /** - * Returns an array where the keys are the addresses of recipients and the - * values are the names. e.g. ('foo@bar' => 'Foo') or ('foo@bar' => NULL). - * - * @return array - */ - public function nextRecipient() - { - return array_splice($this->recipients, 0, 1); - } + /** + * Returns an array where the keys are the addresses of recipients and the + * values are the names. e.g. ('foo@bar' => 'Foo') or ('foo@bar' => NULL). + * + * @return array + */ + public function nextRecipient() + { + return array_splice($this->recipients, 0, 1); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/MemorySpool.php b/htdocs/includes/swiftmailer/lib/classes/Swift/MemorySpool.php index e3b0894d87a..af430351eba 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/MemorySpool.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/MemorySpool.php @@ -15,96 +15,96 @@ */ class Swift_MemorySpool implements Swift_Spool { - protected $messages = []; - private $flushRetries = 3; + protected $messages = []; + private $flushRetries = 3; - /** - * Tests if this Transport mechanism has started. - * - * @return bool - */ - public function isStarted() - { - return true; - } + /** + * Tests if this Transport mechanism has started. + * + * @return bool + */ + public function isStarted() + { + return true; + } - /** - * Starts this Transport mechanism. - */ - public function start() - { - } + /** + * Starts this Transport mechanism. + */ + public function start() + { + } - /** - * Stops this Transport mechanism. - */ - public function stop() - { - } + /** + * Stops this Transport mechanism. + */ + public function stop() + { + } - /** - * @param int $retries - */ - public function setFlushRetries($retries) - { - $this->flushRetries = $retries; - } + /** + * @param int $retries + */ + public function setFlushRetries($retries) + { + $this->flushRetries = $retries; + } - /** - * Stores a message in the queue. - * - * @param Swift_Mime_SimpleMessage $message The message to store - * - * @return bool Whether the operation has succeeded - */ - public function queueMessage(Swift_Mime_SimpleMessage $message) - { - //clone the message to make sure it is not changed while in the queue - $this->messages[] = clone $message; + /** + * Stores a message in the queue. + * + * @param Swift_Mime_SimpleMessage $message The message to store + * + * @return bool Whether the operation has succeeded + */ + public function queueMessage(Swift_Mime_SimpleMessage $message) + { + //clone the message to make sure it is not changed while in the queue + $this->messages[] = clone $message; - return true; - } + return true; + } - /** - * Sends messages using the given transport instance. - * - * @param Swift_Transport $transport A transport instance - * @param string[] $failedRecipients An array of failures by-reference - * - * @return int The number of sent emails - */ - public function flushQueue(Swift_Transport $transport, &$failedRecipients = null) - { - if (!$this->messages) { - return 0; - } + /** + * Sends messages using the given transport instance. + * + * @param Swift_Transport $transport A transport instance + * @param string[] $failedRecipients An array of failures by-reference + * + * @return int The number of sent emails + */ + public function flushQueue(Swift_Transport $transport, &$failedRecipients = null) + { + if (!$this->messages) { + return 0; + } - if (!$transport->isStarted()) { - $transport->start(); - } + if (!$transport->isStarted()) { + $transport->start(); + } - $count = 0; - $retries = $this->flushRetries; - while ($retries--) { - try { - while ($message = array_pop($this->messages)) { - $count += $transport->send($message, $failedRecipients); - } - } catch (Swift_TransportException $exception) { - if ($retries) { - // re-queue the message at the end of the queue to give a chance - // to the other messages to be sent, in case the failure was due to - // this message and not just the transport failing - array_unshift($this->messages, $message); + $count = 0; + $retries = $this->flushRetries; + while ($retries--) { + try { + while ($message = array_pop($this->messages)) { + $count += $transport->send($message, $failedRecipients); + } + } catch (Swift_TransportException $exception) { + if ($retries) { + // re-queue the message at the end of the queue to give a chance + // to the other messages to be sent, in case the failure was due to + // this message and not just the transport failing + array_unshift($this->messages, $message); - // wait half a second before we try again - usleep(500000); - } else { - throw $exception; - } - } - } + // wait half a second before we try again + usleep(500000); + } else { + throw $exception; + } + } + } - return $count; - } + return $count; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Message.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Message.php index 5c5834e23d8..103563c620c 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Message.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Message.php @@ -15,265 +15,265 @@ */ class Swift_Message extends Swift_Mime_SimpleMessage { - /** - * @var Swift_Signers_HeaderSigner[] - */ - private $headerSigners = []; + /** + * @var Swift_Signers_HeaderSigner[] + */ + private $headerSigners = []; - /** - * @var Swift_Signers_BodySigner[] - */ - private $bodySigners = []; + /** + * @var Swift_Signers_BodySigner[] + */ + private $bodySigners = []; - /** - * @var array - */ - private $savedMessage = []; + /** + * @var array + */ + private $savedMessage = []; - /** - * Create a new Message. - * - * Details may be optionally passed into the constructor. - * - * @param string $subject - * @param string $body - * @param string $contentType - * @param string $charset - */ - public function __construct($subject = null, $body = null, $contentType = null, $charset = null) - { - \call_user_func_array( - [$this, 'Swift_Mime_SimpleMessage::__construct'], - Swift_DependencyContainer::getInstance() - ->createDependenciesFor('mime.message') - ); + /** + * Create a new Message. + * + * Details may be optionally passed into the constructor. + * + * @param string $subject + * @param string $body + * @param string $contentType + * @param string $charset + */ + public function __construct($subject = null, $body = null, $contentType = null, $charset = null) + { + \call_user_func_array( + [$this, 'Swift_Mime_SimpleMessage::__construct'], + Swift_DependencyContainer::getInstance() + ->createDependenciesFor('mime.message') + ); - if (!isset($charset)) { - $charset = Swift_DependencyContainer::getInstance() - ->lookup('properties.charset'); - } - $this->setSubject($subject); - $this->setBody($body); - $this->setCharset($charset); - if ($contentType) { - $this->setContentType($contentType); - } - } + if (!isset($charset)) { + $charset = Swift_DependencyContainer::getInstance() + ->lookup('properties.charset'); + } + $this->setSubject($subject); + $this->setBody($body); + $this->setCharset($charset); + if ($contentType) { + $this->setContentType($contentType); + } + } - /** - * Add a MimePart to this Message. - * - * @param string|Swift_OutputByteStream $body - * @param string $contentType - * @param string $charset - * - * @return $this - */ - public function addPart($body, $contentType = null, $charset = null) - { - return $this->attach((new Swift_MimePart($body, $contentType, $charset))->setEncoder($this->getEncoder())); - } + /** + * Add a MimePart to this Message. + * + * @param string|Swift_OutputByteStream $body + * @param string $contentType + * @param string $charset + * + * @return $this + */ + public function addPart($body, $contentType = null, $charset = null) + { + return $this->attach((new Swift_MimePart($body, $contentType, $charset))->setEncoder($this->getEncoder())); + } - /** - * Attach a new signature handler to the message. - * - * @return $this - */ - public function attachSigner(Swift_Signer $signer) - { - if ($signer instanceof Swift_Signers_HeaderSigner) { - $this->headerSigners[] = $signer; - } elseif ($signer instanceof Swift_Signers_BodySigner) { - $this->bodySigners[] = $signer; - } + /** + * Attach a new signature handler to the message. + * + * @return $this + */ + public function attachSigner(Swift_Signer $signer) + { + if ($signer instanceof Swift_Signers_HeaderSigner) { + $this->headerSigners[] = $signer; + } elseif ($signer instanceof Swift_Signers_BodySigner) { + $this->bodySigners[] = $signer; + } - return $this; - } + return $this; + } - /** - * Detach a signature handler from a message. - * - * @return $this - */ - public function detachSigner(Swift_Signer $signer) - { - if ($signer instanceof Swift_Signers_HeaderSigner) { - foreach ($this->headerSigners as $k => $headerSigner) { - if ($headerSigner === $signer) { - unset($this->headerSigners[$k]); + /** + * Detach a signature handler from a message. + * + * @return $this + */ + public function detachSigner(Swift_Signer $signer) + { + if ($signer instanceof Swift_Signers_HeaderSigner) { + foreach ($this->headerSigners as $k => $headerSigner) { + if ($headerSigner === $signer) { + unset($this->headerSigners[$k]); - return $this; - } - } - } elseif ($signer instanceof Swift_Signers_BodySigner) { - foreach ($this->bodySigners as $k => $bodySigner) { - if ($bodySigner === $signer) { - unset($this->bodySigners[$k]); + return $this; + } + } + } elseif ($signer instanceof Swift_Signers_BodySigner) { + foreach ($this->bodySigners as $k => $bodySigner) { + if ($bodySigner === $signer) { + unset($this->bodySigners[$k]); - return $this; - } - } - } + return $this; + } + } + } - return $this; - } + return $this; + } - /** - * Clear all signature handlers attached to the message. - * - * @return $this - */ - public function clearSigners() - { - $this->headerSigners = []; - $this->bodySigners = []; + /** + * Clear all signature handlers attached to the message. + * + * @return $this + */ + public function clearSigners() + { + $this->headerSigners = []; + $this->bodySigners = []; - return $this; - } + return $this; + } - /** - * Get this message as a complete string. - * - * @return string - */ - public function toString() - { - if (empty($this->headerSigners) && empty($this->bodySigners)) { - return parent::toString(); - } + /** + * Get this message as a complete string. + * + * @return string + */ + public function toString() + { + if (empty($this->headerSigners) && empty($this->bodySigners)) { + return parent::toString(); + } - $this->saveMessage(); + $this->saveMessage(); - $this->doSign(); + $this->doSign(); - $string = parent::toString(); + $string = parent::toString(); - $this->restoreMessage(); + $this->restoreMessage(); - return $string; - } + return $string; + } - /** - * Write this message to a {@link Swift_InputByteStream}. - */ - public function toByteStream(Swift_InputByteStream $is) - { - if (empty($this->headerSigners) && empty($this->bodySigners)) { - parent::toByteStream($is); + /** + * Write this message to a {@link Swift_InputByteStream}. + */ + public function toByteStream(Swift_InputByteStream $is) + { + if (empty($this->headerSigners) && empty($this->bodySigners)) { + parent::toByteStream($is); - return; - } + return; + } - $this->saveMessage(); + $this->saveMessage(); - $this->doSign(); + $this->doSign(); - parent::toByteStream($is); + parent::toByteStream($is); - $this->restoreMessage(); - } + $this->restoreMessage(); + } - public function __wakeup() - { - Swift_DependencyContainer::getInstance()->createDependenciesFor('mime.message'); - } + public function __wakeup() + { + Swift_DependencyContainer::getInstance()->createDependenciesFor('mime.message'); + } - /** - * loops through signers and apply the signatures. - */ - protected function doSign() - { - foreach ($this->bodySigners as $signer) { - $altered = $signer->getAlteredHeaders(); - $this->saveHeaders($altered); - $signer->signMessage($this); - } + /** + * loops through signers and apply the signatures. + */ + protected function doSign() + { + foreach ($this->bodySigners as $signer) { + $altered = $signer->getAlteredHeaders(); + $this->saveHeaders($altered); + $signer->signMessage($this); + } - foreach ($this->headerSigners as $signer) { - $altered = $signer->getAlteredHeaders(); - $this->saveHeaders($altered); - $signer->reset(); + foreach ($this->headerSigners as $signer) { + $altered = $signer->getAlteredHeaders(); + $this->saveHeaders($altered); + $signer->reset(); - $signer->setHeaders($this->getHeaders()); + $signer->setHeaders($this->getHeaders()); - $signer->startBody(); - $this->bodyToByteStream($signer); - $signer->endBody(); + $signer->startBody(); + $this->bodyToByteStream($signer); + $signer->endBody(); - $signer->addSignature($this->getHeaders()); - } - } + $signer->addSignature($this->getHeaders()); + } + } - /** - * save the message before any signature is applied. - */ - protected function saveMessage() - { - $this->savedMessage = ['headers' => []]; - $this->savedMessage['body'] = $this->getBody(); - $this->savedMessage['children'] = $this->getChildren(); - if (\count($this->savedMessage['children']) > 0 && '' != $this->getBody()) { - $this->setChildren(array_merge([$this->becomeMimePart()], $this->savedMessage['children'])); - $this->setBody(''); - } - } + /** + * save the message before any signature is applied. + */ + protected function saveMessage() + { + $this->savedMessage = ['headers' => []]; + $this->savedMessage['body'] = $this->getBody(); + $this->savedMessage['children'] = $this->getChildren(); + if (\count($this->savedMessage['children']) > 0 && '' != $this->getBody()) { + $this->setChildren(array_merge([$this->becomeMimePart()], $this->savedMessage['children'])); + $this->setBody(''); + } + } - /** - * save the original headers. - */ - protected function saveHeaders(array $altered) - { - foreach ($altered as $head) { - $lc = strtolower($head ?? ''); + /** + * save the original headers. + */ + protected function saveHeaders(array $altered) + { + foreach ($altered as $head) { + $lc = strtolower($head ?? ''); - if (!isset($this->savedMessage['headers'][$lc])) { - $this->savedMessage['headers'][$lc] = $this->getHeaders()->getAll($head); - } - } - } + if (!isset($this->savedMessage['headers'][$lc])) { + $this->savedMessage['headers'][$lc] = $this->getHeaders()->getAll($head); + } + } + } - /** - * Remove or restore altered headers. - */ - protected function restoreHeaders() - { - foreach ($this->savedMessage['headers'] as $name => $savedValue) { - $headers = $this->getHeaders()->getAll($name); + /** + * Remove or restore altered headers. + */ + protected function restoreHeaders() + { + foreach ($this->savedMessage['headers'] as $name => $savedValue) { + $headers = $this->getHeaders()->getAll($name); - foreach ($headers as $key => $value) { - if (!isset($savedValue[$key])) { - $this->getHeaders()->remove($name, $key); - } - } - } - } + foreach ($headers as $key => $value) { + if (!isset($savedValue[$key])) { + $this->getHeaders()->remove($name, $key); + } + } + } + } - /** - * Restore message body. - */ - protected function restoreMessage() - { - $this->setBody($this->savedMessage['body']); - $this->setChildren($this->savedMessage['children']); + /** + * Restore message body. + */ + protected function restoreMessage() + { + $this->setBody($this->savedMessage['body']); + $this->setChildren($this->savedMessage['children']); - $this->restoreHeaders(); - $this->savedMessage = []; - } + $this->restoreHeaders(); + $this->savedMessage = []; + } - /** - * Clone Message Signers. - * - * @see Swift_Mime_SimpleMimeEntity::__clone() - */ - public function __clone() - { - parent::__clone(); - foreach ($this->bodySigners as $key => $bodySigner) { - $this->bodySigners[$key] = clone $bodySigner; - } + /** + * Clone Message Signers. + * + * @see Swift_Mime_SimpleMimeEntity::__clone() + */ + public function __clone() + { + parent::__clone(); + foreach ($this->bodySigners as $key => $bodySigner) { + $this->bodySigners[$key] = clone $bodySigner; + } - foreach ($this->headerSigners as $key => $headerSigner) { - $this->headerSigners[$key] = clone $headerSigner; - } - } + foreach ($this->headerSigners as $key => $headerSigner) { + $this->headerSigners[$key] = clone $headerSigner; + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Attachment.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Attachment.php index d994373bd78..ed9b7cbe50c 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Attachment.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Attachment.php @@ -15,130 +15,130 @@ */ class Swift_Mime_Attachment extends Swift_Mime_SimpleMimeEntity { - /** Recognized MIME types */ - private $mimeTypes = []; + /** Recognized MIME types */ + private $mimeTypes = []; - /** - * Create a new Attachment with $headers, $encoder and $cache. - * - * @param array $mimeTypes - */ - public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator, $mimeTypes = []) - { - parent::__construct($headers, $encoder, $cache, $idGenerator); - $this->setDisposition('attachment'); - $this->setContentType('application/octet-stream'); - $this->mimeTypes = $mimeTypes; - } + /** + * Create a new Attachment with $headers, $encoder and $cache. + * + * @param array $mimeTypes + */ + public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator, $mimeTypes = []) + { + parent::__construct($headers, $encoder, $cache, $idGenerator); + $this->setDisposition('attachment'); + $this->setContentType('application/octet-stream'); + $this->mimeTypes = $mimeTypes; + } - /** - * Get the nesting level used for this attachment. - * - * Always returns {@link LEVEL_MIXED}. - * - * @return int - */ - public function getNestingLevel() - { - return self::LEVEL_MIXED; - } + /** + * Get the nesting level used for this attachment. + * + * Always returns {@link LEVEL_MIXED}. + * + * @return int + */ + public function getNestingLevel() + { + return self::LEVEL_MIXED; + } - /** - * Get the Content-Disposition of this attachment. - * - * By default attachments have a disposition of "attachment". - * - * @return string - */ - public function getDisposition() - { - return $this->getHeaderFieldModel('Content-Disposition'); - } + /** + * Get the Content-Disposition of this attachment. + * + * By default attachments have a disposition of "attachment". + * + * @return string + */ + public function getDisposition() + { + return $this->getHeaderFieldModel('Content-Disposition'); + } - /** - * Set the Content-Disposition of this attachment. - * - * @param string $disposition - * - * @return $this - */ - public function setDisposition($disposition) - { - if (!$this->setHeaderFieldModel('Content-Disposition', $disposition)) { - $this->getHeaders()->addParameterizedHeader('Content-Disposition', $disposition); - } + /** + * Set the Content-Disposition of this attachment. + * + * @param string $disposition + * + * @return $this + */ + public function setDisposition($disposition) + { + if (!$this->setHeaderFieldModel('Content-Disposition', $disposition)) { + $this->getHeaders()->addParameterizedHeader('Content-Disposition', $disposition); + } - return $this; - } + return $this; + } - /** - * Get the filename of this attachment when downloaded. - * - * @return string - */ - public function getFilename() - { - return $this->getHeaderParameter('Content-Disposition', 'filename'); - } + /** + * Get the filename of this attachment when downloaded. + * + * @return string + */ + public function getFilename() + { + return $this->getHeaderParameter('Content-Disposition', 'filename'); + } - /** - * Set the filename of this attachment. - * - * @param string $filename - * - * @return $this - */ - public function setFilename($filename) - { - $this->setHeaderParameter('Content-Disposition', 'filename', $filename); - $this->setHeaderParameter('Content-Type', 'name', $filename); + /** + * Set the filename of this attachment. + * + * @param string $filename + * + * @return $this + */ + public function setFilename($filename) + { + $this->setHeaderParameter('Content-Disposition', 'filename', $filename); + $this->setHeaderParameter('Content-Type', 'name', $filename); - return $this; - } + return $this; + } - /** - * Get the file size of this attachment. - * - * @return int - */ - public function getSize() - { - return $this->getHeaderParameter('Content-Disposition', 'size'); - } + /** + * Get the file size of this attachment. + * + * @return int + */ + public function getSize() + { + return $this->getHeaderParameter('Content-Disposition', 'size'); + } - /** - * Set the file size of this attachment. - * - * @param int $size - * - * @return $this - */ - public function setSize($size) - { - $this->setHeaderParameter('Content-Disposition', 'size', $size); + /** + * Set the file size of this attachment. + * + * @param int $size + * + * @return $this + */ + public function setSize($size) + { + $this->setHeaderParameter('Content-Disposition', 'size', $size); - return $this; - } + return $this; + } - /** - * Set the file that this attachment is for. - * - * @param string $contentType optional - * - * @return $this - */ - public function setFile(Swift_FileStream $file, $contentType = null) - { - $this->setFilename(basename($file->getPath())); - $this->setBody($file, $contentType); - if (!isset($contentType)) { - $extension = strtolower(substr($file->getPath(), strrpos($file->getPath(), '.') + 1)); + /** + * Set the file that this attachment is for. + * + * @param string $contentType optional + * + * @return $this + */ + public function setFile(Swift_FileStream $file, $contentType = null) + { + $this->setFilename(basename($file->getPath())); + $this->setBody($file, $contentType); + if (!isset($contentType)) { + $extension = strtolower(substr($file->getPath(), strrpos($file->getPath(), '.') + 1)); - if (\array_key_exists($extension, $this->mimeTypes)) { - $this->setContentType($this->mimeTypes[$extension]); - } - } + if (\array_key_exists($extension, $this->mimeTypes)) { + $this->setContentType($this->mimeTypes[$extension]); + } + } - return $this; - } + return $this; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/Base64ContentEncoder.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/Base64ContentEncoder.php index b7e1e028307..d7ae850d61a 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/Base64ContentEncoder.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/Base64ContentEncoder.php @@ -15,87 +15,87 @@ */ class Swift_Mime_ContentEncoder_Base64ContentEncoder extends Swift_Encoder_Base64Encoder implements Swift_Mime_ContentEncoder { - /** - * Encode stream $in to stream $out. - * - * @param int $firstLineOffset - */ - public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) - { - if (0 >= $maxLineLength || 76 < $maxLineLength) { - $maxLineLength = 76; - } + /** + * Encode stream $in to stream $out. + * + * @param int $firstLineOffset + */ + public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) + { + if (0 >= $maxLineLength || 76 < $maxLineLength) { + $maxLineLength = 76; + } - $remainder = 0; - $base64ReadBufferRemainderBytes = ''; + $remainder = 0; + $base64ReadBufferRemainderBytes = ''; - // To reduce memory usage, the output buffer is streamed to the input buffer like so: - // Output Stream => base64encode => wrap line length => Input Stream - // HOWEVER it's important to note that base64_encode() should only be passed whole triplets of data (except for the final chunk of data) - // otherwise it will assume the input data has *ended* and it will incorrectly pad/terminate the base64 data mid-stream. - // We use $base64ReadBufferRemainderBytes to carry over 1-2 "remainder" bytes from the each chunk from OutputStream and pre-pend those onto the - // chunk of bytes read in the next iteration. - // When the OutputStream is empty, we must flush any remainder bytes. - while (true) { - $readBytes = $os->read(8192); - $atEOF = (false === $readBytes); + // To reduce memory usage, the output buffer is streamed to the input buffer like so: + // Output Stream => base64encode => wrap line length => Input Stream + // HOWEVER it's important to note that base64_encode() should only be passed whole triplets of data (except for the final chunk of data) + // otherwise it will assume the input data has *ended* and it will incorrectly pad/terminate the base64 data mid-stream. + // We use $base64ReadBufferRemainderBytes to carry over 1-2 "remainder" bytes from the each chunk from OutputStream and pre-pend those onto the + // chunk of bytes read in the next iteration. + // When the OutputStream is empty, we must flush any remainder bytes. + while (true) { + $readBytes = $os->read(8192); + $atEOF = (false === $readBytes); - if ($atEOF) { - $streamTheseBytes = $base64ReadBufferRemainderBytes; - } else { - $streamTheseBytes = $base64ReadBufferRemainderBytes.$readBytes; - } - $base64ReadBufferRemainderBytes = ''; - $bytesLength = \strlen($streamTheseBytes); + if ($atEOF) { + $streamTheseBytes = $base64ReadBufferRemainderBytes; + } else { + $streamTheseBytes = $base64ReadBufferRemainderBytes.$readBytes; + } + $base64ReadBufferRemainderBytes = ''; + $bytesLength = \strlen($streamTheseBytes); - if (0 === $bytesLength) { // no data left to encode - break; - } + if (0 === $bytesLength) { // no data left to encode + break; + } - // if we're not on the last block of the ouput stream, make sure $streamTheseBytes ends with a complete triplet of data - // and carry over remainder 1-2 bytes to the next loop iteration - if (!$atEOF) { - $excessBytes = $bytesLength % 3; - if (0 !== $excessBytes) { - $base64ReadBufferRemainderBytes = substr($streamTheseBytes, -$excessBytes); - $streamTheseBytes = substr($streamTheseBytes, 0, $bytesLength - $excessBytes); - } - } + // if we're not on the last block of the ouput stream, make sure $streamTheseBytes ends with a complete triplet of data + // and carry over remainder 1-2 bytes to the next loop iteration + if (!$atEOF) { + $excessBytes = $bytesLength % 3; + if (0 !== $excessBytes) { + $base64ReadBufferRemainderBytes = substr($streamTheseBytes, -$excessBytes); + $streamTheseBytes = substr($streamTheseBytes, 0, $bytesLength - $excessBytes); + } + } - $encoded = base64_encode($streamTheseBytes); - $encodedTransformed = ''; - $thisMaxLineLength = $maxLineLength - $remainder - $firstLineOffset; + $encoded = base64_encode($streamTheseBytes); + $encodedTransformed = ''; + $thisMaxLineLength = $maxLineLength - $remainder - $firstLineOffset; - while ($thisMaxLineLength < \strlen($encoded)) { - $encodedTransformed .= substr($encoded, 0, $thisMaxLineLength)."\r\n"; - $firstLineOffset = 0; - $encoded = substr($encoded, $thisMaxLineLength); - $thisMaxLineLength = $maxLineLength; - $remainder = 0; - } + while ($thisMaxLineLength < \strlen($encoded)) { + $encodedTransformed .= substr($encoded, 0, $thisMaxLineLength)."\r\n"; + $firstLineOffset = 0; + $encoded = substr($encoded, $thisMaxLineLength); + $thisMaxLineLength = $maxLineLength; + $remainder = 0; + } - if (0 < $remainingLength = \strlen($encoded)) { - $remainder += $remainingLength; - $encodedTransformed .= $encoded; - $encoded = null; - } + if (0 < $remainingLength = \strlen($encoded)) { + $remainder += $remainingLength; + $encodedTransformed .= $encoded; + $encoded = null; + } - $is->write($encodedTransformed); + $is->write($encodedTransformed); - if ($atEOF) { - break; - } - } - } + if ($atEOF) { + break; + } + } + } - /** - * Get the name of this encoding scheme. - * Returns the string 'base64'. - * - * @return string - */ - public function getName() - { - return 'base64'; - } + /** + * Get the name of this encoding scheme. + * Returns the string 'base64'. + * + * @return string + */ + public function getName() + { + return 'base64'; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/NativeQpContentEncoder.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/NativeQpContentEncoder.php index 8dfea605fde..a678d67edaf 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/NativeQpContentEncoder.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/NativeQpContentEncoder.php @@ -15,107 +15,107 @@ */ class Swift_Mime_ContentEncoder_NativeQpContentEncoder implements Swift_Mime_ContentEncoder { - /** - * @var string|null - */ - private $charset; + /** + * @var string|null + */ + private $charset; - /** - * @param string|null $charset - */ - public function __construct($charset = null) - { - $this->charset = $charset ?: 'utf-8'; - } + /** + * @param string|null $charset + */ + public function __construct($charset = null) + { + $this->charset = $charset ?: 'utf-8'; + } - /** - * Notify this observer that the entity's charset has changed. - * - * @param string $charset - */ - public function charsetChanged($charset) - { - $this->charset = $charset; - } + /** + * Notify this observer that the entity's charset has changed. + * + * @param string $charset + */ + public function charsetChanged($charset) + { + $this->charset = $charset; + } - /** - * Encode $in to $out. - * - * @param Swift_OutputByteStream $os to read from - * @param Swift_InputByteStream $is to write to - * @param int $firstLineOffset - * @param int $maxLineLength 0 indicates the default length for this encoding - * - * @throws RuntimeException - */ - public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) - { - if ('utf-8' !== $this->charset) { - throw new RuntimeException(sprintf('Charset "%s" not supported. NativeQpContentEncoder only supports "utf-8"', $this->charset)); - } + /** + * Encode $in to $out. + * + * @param Swift_OutputByteStream $os to read from + * @param Swift_InputByteStream $is to write to + * @param int $firstLineOffset + * @param int $maxLineLength 0 indicates the default length for this encoding + * + * @throws RuntimeException + */ + public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) + { + if ('utf-8' !== $this->charset) { + throw new RuntimeException(sprintf('Charset "%s" not supported. NativeQpContentEncoder only supports "utf-8"', $this->charset)); + } - $string = ''; + $string = ''; - while (false !== $bytes = $os->read(8192)) { - $string .= $bytes; - } + while (false !== $bytes = $os->read(8192)) { + $string .= $bytes; + } - $is->write($this->encodeString($string)); - } + $is->write($this->encodeString($string)); + } - /** - * Get the MIME name of this content encoding scheme. - * - * @return string - */ - public function getName() - { - return 'quoted-printable'; - } + /** + * Get the MIME name of this content encoding scheme. + * + * @return string + */ + public function getName() + { + return 'quoted-printable'; + } - /** - * Encode a given string to produce an encoded string. - * - * @param string $string - * @param int $firstLineOffset if first line needs to be shorter - * @param int $maxLineLength 0 indicates the default length for this encoding - * - * @throws RuntimeException - * - * @return string - */ - public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) - { - if ('utf-8' !== $this->charset) { - throw new RuntimeException(sprintf('Charset "%s" not supported. NativeQpContentEncoder only supports "utf-8"', $this->charset)); - } + /** + * Encode a given string to produce an encoded string. + * + * @param string $string + * @param int $firstLineOffset if first line needs to be shorter + * @param int $maxLineLength 0 indicates the default length for this encoding + * + * @throws RuntimeException + * + * @return string + */ + public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) + { + if ('utf-8' !== $this->charset) { + throw new RuntimeException(sprintf('Charset "%s" not supported. NativeQpContentEncoder only supports "utf-8"', $this->charset)); + } - return $this->standardize(quoted_printable_encode($string)); - } + return $this->standardize(quoted_printable_encode($string)); + } - /** - * Make sure CRLF is correct and HT/SPACE are in valid places. - * - * @param string $string - * - * @return string - */ - protected function standardize($string) - { - // transform CR or LF to CRLF - $string = preg_replace('~=0D(?!=0A)|(?name = $name; - } + /** + * Creates a new NullContentEncoder with $name (probably 7bit or 8bit). + * + * @param string $name + */ + public function __construct($name) + { + $this->name = $name; + } - /** - * Encode a given string to produce an encoded string. - * - * @param string $string - * @param int $firstLineOffset ignored - * @param int $maxLineLength ignored - * - * @return string - */ - public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) - { - return $string; - } + /** + * Encode a given string to produce an encoded string. + * + * @param string $string + * @param int $firstLineOffset ignored + * @param int $maxLineLength ignored + * + * @return string + */ + public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) + { + return $string; + } - /** - * Encode stream $in to stream $out. - * - * @param int $firstLineOffset ignored - * @param int $maxLineLength ignored - */ - public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) - { - while (false !== ($bytes = $os->read(8192))) { - $is->write($bytes); - } - } + /** + * Encode stream $in to stream $out. + * + * @param int $firstLineOffset ignored + * @param int $maxLineLength ignored + */ + public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) + { + while (false !== ($bytes = $os->read(8192))) { + $is->write($bytes); + } + } - /** - * Get the name of this encoding scheme. - * - * @return string - */ - public function getName() - { - return $this->name; - } + /** + * Get the name of this encoding scheme. + * + * @return string + */ + public function getName() + { + return $this->name; + } - /** - * Not used. - */ - public function charsetChanged($charset) - { - } + /** + * Not used. + */ + public function charsetChanged($charset) + { + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/PlainContentEncoder.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/PlainContentEncoder.php index 72592fc5894..02546e03d95 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/PlainContentEncoder.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/PlainContentEncoder.php @@ -19,146 +19,146 @@ */ class Swift_Mime_ContentEncoder_PlainContentEncoder implements Swift_Mime_ContentEncoder { - /** - * The name of this encoding scheme (probably 7bit or 8bit). - * - * @var string - */ - private $name; + /** + * The name of this encoding scheme (probably 7bit or 8bit). + * + * @var string + */ + private $name; - /** - * True if canonical transformations should be done. - * - * @var bool - */ - private $canonical; + /** + * True if canonical transformations should be done. + * + * @var bool + */ + private $canonical; - /** - * Creates a new PlainContentEncoder with $name (probably 7bit or 8bit). - * - * @param string $name - * @param bool $canonical if canonicalization transformation should be done - */ - public function __construct($name, $canonical = false) - { - $this->name = $name; - $this->canonical = $canonical; - } + /** + * Creates a new PlainContentEncoder with $name (probably 7bit or 8bit). + * + * @param string $name + * @param bool $canonical if canonicalization transformation should be done + */ + public function __construct($name, $canonical = false) + { + $this->name = $name; + $this->canonical = $canonical; + } - /** - * Encode a given string to produce an encoded string. - * - * @param string $string - * @param int $firstLineOffset ignored - * @param int $maxLineLength - 0 means no wrapping will occur - * - * @return string - */ - public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) - { - if ($this->canonical) { - $string = $this->canonicalize($string); - } + /** + * Encode a given string to produce an encoded string. + * + * @param string $string + * @param int $firstLineOffset ignored + * @param int $maxLineLength - 0 means no wrapping will occur + * + * @return string + */ + public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) + { + if ($this->canonical) { + $string = $this->canonicalize($string); + } - return $this->safeWordwrap($string, $maxLineLength, "\r\n"); - } + return $this->safeWordwrap($string, $maxLineLength, "\r\n"); + } - /** - * Encode stream $in to stream $out. - * - * @param int $firstLineOffset ignored - * @param int $maxLineLength optional, 0 means no wrapping will occur - */ - public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) - { - $leftOver = ''; - while (false !== $bytes = $os->read(8192)) { - $toencode = $leftOver.$bytes; - if ($this->canonical) { - $toencode = $this->canonicalize($toencode); - } - $wrapped = $this->safeWordwrap($toencode, $maxLineLength, "\r\n"); - $lastLinePos = strrpos($wrapped, "\r\n"); - $leftOver = substr($wrapped, $lastLinePos); - $wrapped = substr($wrapped, 0, $lastLinePos); + /** + * Encode stream $in to stream $out. + * + * @param int $firstLineOffset ignored + * @param int $maxLineLength optional, 0 means no wrapping will occur + */ + public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) + { + $leftOver = ''; + while (false !== $bytes = $os->read(8192)) { + $toencode = $leftOver.$bytes; + if ($this->canonical) { + $toencode = $this->canonicalize($toencode); + } + $wrapped = $this->safeWordwrap($toencode, $maxLineLength, "\r\n"); + $lastLinePos = strrpos($wrapped, "\r\n"); + $leftOver = substr($wrapped, $lastLinePos); + $wrapped = substr($wrapped, 0, $lastLinePos); - $is->write($wrapped); - } - if (\strlen($leftOver)) { - $is->write($leftOver); - } - } + $is->write($wrapped); + } + if (\strlen($leftOver)) { + $is->write($leftOver); + } + } - /** - * Get the name of this encoding scheme. - * - * @return string - */ - public function getName() - { - return $this->name; - } + /** + * Get the name of this encoding scheme. + * + * @return string + */ + public function getName() + { + return $this->name; + } - /** - * Not used. - */ - public function charsetChanged($charset) - { - } + /** + * Not used. + */ + public function charsetChanged($charset) + { + } - /** - * A safer (but weaker) wordwrap for unicode. - * - * @param string $string - * @param int $length - * @param string $le - * - * @return string - */ - private function safeWordwrap($string, $length = 75, $le = "\r\n") - { - if (0 >= $length) { - return $string; - } + /** + * A safer (but weaker) wordwrap for unicode. + * + * @param string $string + * @param int $length + * @param string $le + * + * @return string + */ + private function safeWordwrap($string, $length = 75, $le = "\r\n") + { + if (0 >= $length) { + return $string; + } - $originalLines = explode($le, $string); + $originalLines = explode($le, $string); - $lines = []; - $lineCount = 0; + $lines = []; + $lineCount = 0; - foreach ($originalLines as $originalLine) { - $lines[] = ''; - $currentLine = &$lines[$lineCount++]; + foreach ($originalLines as $originalLine) { + $lines[] = ''; + $currentLine = &$lines[$lineCount++]; - //$chunks = preg_split('/(?<=[\ \t,\.!\?\-&\+\/])/', $originalLine); - $chunks = preg_split('/(?<=\s)/', $originalLine); + //$chunks = preg_split('/(?<=[\ \t,\.!\?\-&\+\/])/', $originalLine); + $chunks = preg_split('/(?<=\s)/', $originalLine); - foreach ($chunks as $chunk) { - if (0 != \strlen($currentLine) - && \strlen($currentLine.$chunk) > $length) { - $lines[] = ''; - $currentLine = &$lines[$lineCount++]; - } - $currentLine .= $chunk; - } - } + foreach ($chunks as $chunk) { + if (0 != \strlen($currentLine) + && \strlen($currentLine.$chunk) > $length) { + $lines[] = ''; + $currentLine = &$lines[$lineCount++]; + } + $currentLine .= $chunk; + } + } - return implode("\r\n", $lines); - } + return implode("\r\n", $lines); + } - /** - * Canonicalize string input (fix CRLF). - * - * @param string $string - * - * @return string - */ - private function canonicalize($string) - { - return str_replace( - ["\r\n", "\r", "\n"], - ["\n", "\n", "\r\n"], - $string - ); - } + /** + * Canonicalize string input (fix CRLF). + * + * @param string $string + * + * @return string + */ + private function canonicalize($string) + { + return str_replace( + ["\r\n", "\r", "\n"], + ["\n", "\n", "\r\n"], + $string + ); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php index 465ffd87850..51785234043 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php @@ -15,120 +15,120 @@ */ class Swift_Mime_ContentEncoder_QpContentEncoder extends Swift_Encoder_QpEncoder implements Swift_Mime_ContentEncoder { - protected $dotEscape; + protected $dotEscape; - /** - * Creates a new QpContentEncoder for the given CharacterStream. - * - * @param Swift_CharacterStream $charStream to use for reading characters - * @param Swift_StreamFilter $filter if canonicalization should occur - * @param bool $dotEscape if dot stuffing workaround must be enabled - */ - public function __construct(Swift_CharacterStream $charStream, Swift_StreamFilter $filter = null, $dotEscape = false) - { - $this->dotEscape = $dotEscape; - parent::__construct($charStream, $filter); - } + /** + * Creates a new QpContentEncoder for the given CharacterStream. + * + * @param Swift_CharacterStream $charStream to use for reading characters + * @param Swift_StreamFilter $filter if canonicalization should occur + * @param bool $dotEscape if dot stuffing workaround must be enabled + */ + public function __construct(Swift_CharacterStream $charStream, Swift_StreamFilter $filter = null, $dotEscape = false) + { + $this->dotEscape = $dotEscape; + parent::__construct($charStream, $filter); + } - public function __sleep() - { - return ['charStream', 'filter', 'dotEscape']; - } + public function __sleep() + { + return ['charStream', 'filter', 'dotEscape']; + } - protected function getSafeMapShareId() - { - return static::class.($this->dotEscape ? '.dotEscape' : ''); - } + protected function getSafeMapShareId() + { + return static::class.($this->dotEscape ? '.dotEscape' : ''); + } - protected function initSafeMap() - { - parent::initSafeMap(); - if ($this->dotEscape) { - /* Encode . as =2e for buggy remote servers */ - unset($this->safeMap[0x2e]); - } - } + protected function initSafeMap() + { + parent::initSafeMap(); + if ($this->dotEscape) { + /* Encode . as =2e for buggy remote servers */ + unset($this->safeMap[0x2e]); + } + } - /** - * Encode stream $in to stream $out. - * - * QP encoded strings have a maximum line length of 76 characters. - * If the first line needs to be shorter, indicate the difference with - * $firstLineOffset. - * - * @param Swift_OutputByteStream $os output stream - * @param Swift_InputByteStream $is input stream - * @param int $firstLineOffset - * @param int $maxLineLength - */ - public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) - { - if ($maxLineLength > 76 || $maxLineLength <= 0) { - $maxLineLength = 76; - } + /** + * Encode stream $in to stream $out. + * + * QP encoded strings have a maximum line length of 76 characters. + * If the first line needs to be shorter, indicate the difference with + * $firstLineOffset. + * + * @param Swift_OutputByteStream $os output stream + * @param Swift_InputByteStream $is input stream + * @param int $firstLineOffset + * @param int $maxLineLength + */ + public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) + { + if ($maxLineLength > 76 || $maxLineLength <= 0) { + $maxLineLength = 76; + } - $thisLineLength = $maxLineLength - $firstLineOffset; + $thisLineLength = $maxLineLength - $firstLineOffset; - $this->charStream->flushContents(); - $this->charStream->importByteStream($os); + $this->charStream->flushContents(); + $this->charStream->importByteStream($os); - $currentLine = ''; - $prepend = ''; - $size = $lineLen = 0; + $currentLine = ''; + $prepend = ''; + $size = $lineLen = 0; - while (false !== $bytes = $this->nextSequence()) { - // If we're filtering the input - if (isset($this->filter)) { - // If we can't filter because we need more bytes - while ($this->filter->shouldBuffer($bytes)) { - // Then collect bytes into the buffer - if (false === $moreBytes = $this->nextSequence(1)) { - break; - } + while (false !== $bytes = $this->nextSequence()) { + // If we're filtering the input + if (isset($this->filter)) { + // If we can't filter because we need more bytes + while ($this->filter->shouldBuffer($bytes)) { + // Then collect bytes into the buffer + if (false === $moreBytes = $this->nextSequence(1)) { + break; + } - foreach ($moreBytes as $b) { - $bytes[] = $b; - } - } - // And filter them - $bytes = $this->filter->filter($bytes); - } + foreach ($moreBytes as $b) { + $bytes[] = $b; + } + } + // And filter them + $bytes = $this->filter->filter($bytes); + } - $enc = $this->encodeByteSequence($bytes, $size); + $enc = $this->encodeByteSequence($bytes, $size); - $i = strpos($enc, '=0D=0A'); - $newLineLength = $lineLen + (false === $i ? $size : $i); + $i = strpos($enc, '=0D=0A'); + $newLineLength = $lineLen + (false === $i ? $size : $i); - if ($currentLine && $newLineLength >= $thisLineLength) { - $is->write($prepend.$this->standardize($currentLine)); - $currentLine = ''; - $prepend = "=\r\n"; - $thisLineLength = $maxLineLength; - $lineLen = 0; - } + if ($currentLine && $newLineLength >= $thisLineLength) { + $is->write($prepend.$this->standardize($currentLine)); + $currentLine = ''; + $prepend = "=\r\n"; + $thisLineLength = $maxLineLength; + $lineLen = 0; + } - $currentLine .= $enc; + $currentLine .= $enc; - if (false === $i) { - $lineLen += $size; - } else { - // 6 is the length of '=0D=0A'. - $lineLen = $size - strrpos($enc, '=0D=0A') - 6; - } - } - if (\strlen($currentLine)) { - $is->write($prepend.$this->standardize($currentLine)); - } - } + if (false === $i) { + $lineLen += $size; + } else { + // 6 is the length of '=0D=0A'. + $lineLen = $size - strrpos($enc, '=0D=0A') - 6; + } + } + if (\strlen($currentLine)) { + $is->write($prepend.$this->standardize($currentLine)); + } + } - /** - * Get the name of this encoding scheme. - * Returns the string 'quoted-printable'. - * - * @return string - */ - public function getName() - { - return 'quoted-printable'; - } + /** + * Get the name of this encoding scheme. + * Returns the string 'quoted-printable'. + * + * @return string + */ + public function getName() + { + return 'quoted-printable'; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php index f3ece43aecd..7b9fb138c3a 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php @@ -17,80 +17,80 @@ */ class Swift_Mime_ContentEncoder_QpContentEncoderProxy implements Swift_Mime_ContentEncoder { - /** - * @var Swift_Mime_ContentEncoder_QpContentEncoder - */ - private $safeEncoder; + /** + * @var Swift_Mime_ContentEncoder_QpContentEncoder + */ + private $safeEncoder; - /** - * @var Swift_Mime_ContentEncoder_NativeQpContentEncoder - */ - private $nativeEncoder; + /** + * @var Swift_Mime_ContentEncoder_NativeQpContentEncoder + */ + private $nativeEncoder; - /** - * @var string|null - */ - private $charset; + /** + * @var string|null + */ + private $charset; - /** - * Constructor. - * - * @param string|null $charset - */ - public function __construct(Swift_Mime_ContentEncoder_QpContentEncoder $safeEncoder, Swift_Mime_ContentEncoder_NativeQpContentEncoder $nativeEncoder, $charset) - { - $this->safeEncoder = $safeEncoder; - $this->nativeEncoder = $nativeEncoder; - $this->charset = $charset; - } + /** + * Constructor. + * + * @param string|null $charset + */ + public function __construct(Swift_Mime_ContentEncoder_QpContentEncoder $safeEncoder, Swift_Mime_ContentEncoder_NativeQpContentEncoder $nativeEncoder, $charset) + { + $this->safeEncoder = $safeEncoder; + $this->nativeEncoder = $nativeEncoder; + $this->charset = $charset; + } - /** - * Make a deep copy of object. - */ - public function __clone() - { - $this->safeEncoder = clone $this->safeEncoder; - $this->nativeEncoder = clone $this->nativeEncoder; - } + /** + * Make a deep copy of object. + */ + public function __clone() + { + $this->safeEncoder = clone $this->safeEncoder; + $this->nativeEncoder = clone $this->nativeEncoder; + } - /** - * {@inheritdoc} - */ - public function charsetChanged($charset) - { - $this->charset = $charset; - $this->safeEncoder->charsetChanged($charset); - } + /** + * {@inheritdoc} + */ + public function charsetChanged($charset) + { + $this->charset = $charset; + $this->safeEncoder->charsetChanged($charset); + } - /** - * {@inheritdoc} - */ - public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) - { - $this->getEncoder()->encodeByteStream($os, $is, $firstLineOffset, $maxLineLength); - } + /** + * {@inheritdoc} + */ + public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) + { + $this->getEncoder()->encodeByteStream($os, $is, $firstLineOffset, $maxLineLength); + } - /** - * {@inheritdoc} - */ - public function getName() - { - return 'quoted-printable'; - } + /** + * {@inheritdoc} + */ + public function getName() + { + return 'quoted-printable'; + } - /** - * {@inheritdoc} - */ - public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) - { - return $this->getEncoder()->encodeString($string, $firstLineOffset, $maxLineLength); - } + /** + * {@inheritdoc} + */ + public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) + { + return $this->getEncoder()->encodeString($string, $firstLineOffset, $maxLineLength); + } - /** - * @return Swift_Mime_ContentEncoder - */ - private function getEncoder() - { - return 'utf-8' === $this->charset ? $this->nativeEncoder : $this->safeEncoder; - } + /** + * @return Swift_Mime_ContentEncoder + */ + private function getEncoder() + { + return 'utf-8' === $this->charset ? $this->nativeEncoder : $this->safeEncoder; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/RawContentEncoder.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/RawContentEncoder.php index 870e7f41a93..99d09c56478 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/RawContentEncoder.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/RawContentEncoder.php @@ -19,47 +19,47 @@ */ class Swift_Mime_ContentEncoder_RawContentEncoder implements Swift_Mime_ContentEncoder { - /** - * Encode a given string to produce an encoded string. - * - * @param string $string - * @param int $firstLineOffset ignored - * @param int $maxLineLength ignored - * - * @return string - */ - public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) - { - return $string; - } + /** + * Encode a given string to produce an encoded string. + * + * @param string $string + * @param int $firstLineOffset ignored + * @param int $maxLineLength ignored + * + * @return string + */ + public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) + { + return $string; + } - /** - * Encode stream $in to stream $out. - * - * @param int $firstLineOffset ignored - * @param int $maxLineLength ignored - */ - public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) - { - while (false !== ($bytes = $os->read(8192))) { - $is->write($bytes); - } - } + /** + * Encode stream $in to stream $out. + * + * @param int $firstLineOffset ignored + * @param int $maxLineLength ignored + */ + public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) + { + while (false !== ($bytes = $os->read(8192))) { + $is->write($bytes); + } + } - /** - * Get the name of this encoding scheme. - * - * @return string - */ - public function getName() - { - return 'raw'; - } + /** + * Get the name of this encoding scheme. + * + * @return string + */ + public function getName() + { + return 'raw'; + } - /** - * Not used. - */ - public function charsetChanged($charset) - { - } + /** + * Not used. + */ + public function charsetChanged($charset) + { + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/EmbeddedFile.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/EmbeddedFile.php index 42a51770c76..7b65f781465 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/EmbeddedFile.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/EmbeddedFile.php @@ -15,27 +15,27 @@ */ class Swift_Mime_EmbeddedFile extends Swift_Mime_Attachment { - /** - * Creates a new Attachment with $headers and $encoder. - * - * @param array $mimeTypes optional - */ - public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator, $mimeTypes = []) - { - parent::__construct($headers, $encoder, $cache, $idGenerator, $mimeTypes); - $this->setDisposition('inline'); - $this->setId($this->getId()); - } + /** + * Creates a new Attachment with $headers and $encoder. + * + * @param array $mimeTypes optional + */ + public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator, $mimeTypes = []) + { + parent::__construct($headers, $encoder, $cache, $idGenerator, $mimeTypes); + $this->setDisposition('inline'); + $this->setId($this->getId()); + } - /** - * Get the nesting level of this EmbeddedFile. - * - * Returns {@see LEVEL_RELATED}. - * - * @return int - */ - public function getNestingLevel() - { - return self::LEVEL_RELATED; - } + /** + * Get the nesting level of this EmbeddedFile. + * + * Returns {@see LEVEL_RELATED}. + * + * @return int + */ + public function getNestingLevel() + { + return self::LEVEL_RELATED; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/EncodingObserver.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/EncodingObserver.php index 1a952ece12c..51915764259 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/EncodingObserver.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/EncodingObserver.php @@ -15,8 +15,8 @@ */ interface Swift_Mime_EncodingObserver { - /** - * Notify this observer that the observed entity's ContentEncoder has changed. - */ - public function encoderChanged(Swift_Mime_ContentEncoder $encoder); + /** + * Notify this observer that the observed entity's ContentEncoder has changed. + */ + public function encoderChanged(Swift_Mime_ContentEncoder $encoder); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Header.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Header.php index ca712f35aa0..e2559ffba52 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Header.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Header.php @@ -15,79 +15,79 @@ */ interface Swift_Mime_Header { - /** Text headers */ - const TYPE_TEXT = 2; + /** Text headers */ + const TYPE_TEXT = 2; - /** headers (text + params) */ - const TYPE_PARAMETERIZED = 6; + /** headers (text + params) */ + const TYPE_PARAMETERIZED = 6; - /** Mailbox and address headers */ - const TYPE_MAILBOX = 8; + /** Mailbox and address headers */ + const TYPE_MAILBOX = 8; - /** Date and time headers */ - const TYPE_DATE = 16; + /** Date and time headers */ + const TYPE_DATE = 16; - /** Identification headers */ - const TYPE_ID = 32; + /** Identification headers */ + const TYPE_ID = 32; - /** Address path headers */ - const TYPE_PATH = 64; + /** Address path headers */ + const TYPE_PATH = 64; - /** - * Get the type of Header that this instance represents. - * - * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX - * @see TYPE_DATE, TYPE_ID, TYPE_PATH - * - * @return int - */ - public function getFieldType(); + /** + * Get the type of Header that this instance represents. + * + * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX + * @see TYPE_DATE, TYPE_ID, TYPE_PATH + * + * @return int + */ + public function getFieldType(); - /** - * Set the model for the field body. - * - * The actual types needed will vary depending upon the type of Header. - * - * @param mixed $model - */ - public function setFieldBodyModel($model); + /** + * Set the model for the field body. + * + * The actual types needed will vary depending upon the type of Header. + * + * @param mixed $model + */ + public function setFieldBodyModel($model); - /** - * Set the charset used when rendering the Header. - * - * @param string $charset - */ - public function setCharset($charset); + /** + * Set the charset used when rendering the Header. + * + * @param string $charset + */ + public function setCharset($charset); - /** - * Get the model for the field body. - * - * The return type depends on the specifics of the Header. - * - * @return mixed - */ - public function getFieldBodyModel(); + /** + * Get the model for the field body. + * + * The return type depends on the specifics of the Header. + * + * @return mixed + */ + public function getFieldBodyModel(); - /** - * Get the name of this header (e.g. Subject). - * - * The name is an identifier and as such will be immutable. - * - * @return string - */ - public function getFieldName(); + /** + * Get the name of this header (e.g. Subject). + * + * The name is an identifier and as such will be immutable. + * + * @return string + */ + public function getFieldName(); - /** - * Get the field body, prepared for folding into a final header value. - * - * @return string - */ - public function getFieldBody(); + /** + * Get the field body, prepared for folding into a final header value. + * + * @return string + */ + public function getFieldBody(); - /** - * Get this Header rendered as a compliant string, including trailing CRLF. - * - * @return string - */ - public function toString(); + /** + * Get this Header rendered as a compliant string, including trailing CRLF. + * + * @return string + */ + public function toString(); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/Base64HeaderEncoder.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/Base64HeaderEncoder.php index 21c8aaabfea..6bcb1e4e8f8 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/Base64HeaderEncoder.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/Base64HeaderEncoder.php @@ -15,41 +15,41 @@ */ class Swift_Mime_HeaderEncoder_Base64HeaderEncoder extends Swift_Encoder_Base64Encoder implements Swift_Mime_HeaderEncoder { - /** - * Get the name of this encoding scheme. - * Returns the string 'B'. - * - * @return string - */ - public function getName() - { - return 'B'; - } + /** + * Get the name of this encoding scheme. + * Returns the string 'B'. + * + * @return string + */ + public function getName() + { + return 'B'; + } - /** - * Takes an unencoded string and produces a Base64 encoded string from it. - * - * If the charset is iso-2022-jp, it uses mb_encode_mimeheader instead of - * default encodeString, otherwise pass to the parent method. - * - * @param string $string string to encode - * @param int $firstLineOffset - * @param int $maxLineLength optional, 0 indicates the default of 76 bytes - * @param string $charset - * - * @return string - */ - public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0, $charset = 'utf-8') - { - if ('iso-2022-jp' === strtolower($charset ?? '')) { - $old = mb_internal_encoding(); - mb_internal_encoding('utf-8'); - $newstring = mb_encode_mimeheader($string, $charset, $this->getName(), "\r\n"); - mb_internal_encoding($old); + /** + * Takes an unencoded string and produces a Base64 encoded string from it. + * + * If the charset is iso-2022-jp, it uses mb_encode_mimeheader instead of + * default encodeString, otherwise pass to the parent method. + * + * @param string $string string to encode + * @param int $firstLineOffset + * @param int $maxLineLength optional, 0 indicates the default of 76 bytes + * @param string $charset + * + * @return string + */ + public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0, $charset = 'utf-8') + { + if ('iso-2022-jp' === strtolower($charset ?? '')) { + $old = mb_internal_encoding(); + mb_internal_encoding('utf-8'); + $newstring = mb_encode_mimeheader($string, $charset, $this->getName(), "\r\n"); + mb_internal_encoding($old); - return $newstring; - } + return $newstring; + } - return parent::encodeString($string, $firstLineOffset, $maxLineLength); - } + return parent::encodeString($string, $firstLineOffset, $maxLineLength); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php index 378c4805057..6cfeb3b9285 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php @@ -15,51 +15,51 @@ */ class Swift_Mime_HeaderEncoder_QpHeaderEncoder extends Swift_Encoder_QpEncoder implements Swift_Mime_HeaderEncoder { - /** - * Creates a new QpHeaderEncoder for the given CharacterStream. - * - * @param Swift_CharacterStream $charStream to use for reading characters - */ - public function __construct(Swift_CharacterStream $charStream) - { - parent::__construct($charStream); - } + /** + * Creates a new QpHeaderEncoder for the given CharacterStream. + * + * @param Swift_CharacterStream $charStream to use for reading characters + */ + public function __construct(Swift_CharacterStream $charStream) + { + parent::__construct($charStream); + } - protected function initSafeMap() - { - foreach (array_merge( - range(0x61, 0x7A), range(0x41, 0x5A), - range(0x30, 0x39), [0x20, 0x21, 0x2A, 0x2B, 0x2D, 0x2F] - ) as $byte) { - $this->safeMap[$byte] = \chr($byte); - } - } + protected function initSafeMap() + { + foreach (array_merge( + range(0x61, 0x7A), range(0x41, 0x5A), + range(0x30, 0x39), [0x20, 0x21, 0x2A, 0x2B, 0x2D, 0x2F] + ) as $byte) { + $this->safeMap[$byte] = \chr($byte); + } + } - /** - * Get the name of this encoding scheme. - * - * Returns the string 'Q'. - * - * @return string - */ - public function getName() - { - return 'Q'; - } + /** + * Get the name of this encoding scheme. + * + * Returns the string 'Q'. + * + * @return string + */ + public function getName() + { + return 'Q'; + } - /** - * Takes an unencoded string and produces a QP encoded string from it. - * - * @param string $string string to encode - * @param int $firstLineOffset optional - * @param int $maxLineLength optional, 0 indicates the default of 76 chars - * - * @return string - */ - public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) - { - return str_replace([' ', '=20', "=\r\n"], ['_', '_', "\r\n"], - parent::encodeString($string, $firstLineOffset, $maxLineLength) - ); - } + /** + * Takes an unencoded string and produces a QP encoded string from it. + * + * @param string $string string to encode + * @param int $firstLineOffset optional + * @param int $maxLineLength optional, 0 indicates the default of 76 chars + * + * @return string + */ + public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) + { + return str_replace([' ', '=20', "=\r\n"], ['_', '_', "\r\n"], + parent::encodeString($string, $firstLineOffset, $maxLineLength) + ); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/AbstractHeader.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/AbstractHeader.php index 25740d1155c..344a2b4a7a7 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/AbstractHeader.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/AbstractHeader.php @@ -15,472 +15,472 @@ */ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header { - const PHRASE_PATTERN = '(?:(?:(?:(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))*(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))|(?:(?:[ \t]*(?:\r\n))?[ \t])))?[a-zA-Z0-9!#\$%&\'\*\+\-\/=\?\^_`\{\}\|~]+(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))*(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))|(?:(?:[ \t]*(?:\r\n))?[ \t])))?)|(?:(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))*(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))|(?:(?:[ \t]*(?:\r\n))?[ \t])))?"((?:(?:[ \t]*(?:\r\n))?[ \t])?(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21\x23-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])))*(?:(?:[ \t]*(?:\r\n))?[ \t])?"(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))*(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))|(?:(?:[ \t]*(?:\r\n))?[ \t])))?))+?)'; + const PHRASE_PATTERN = '(?:(?:(?:(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))*(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))|(?:(?:[ \t]*(?:\r\n))?[ \t])))?[a-zA-Z0-9!#\$%&\'\*\+\-\/=\?\^_`\{\}\|~]+(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))*(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))|(?:(?:[ \t]*(?:\r\n))?[ \t])))?)|(?:(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))*(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))|(?:(?:[ \t]*(?:\r\n))?[ \t])))?"((?:(?:[ \t]*(?:\r\n))?[ \t])?(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21\x23-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])))*(?:(?:[ \t]*(?:\r\n))?[ \t])?"(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))*(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))|(?:(?:[ \t]*(?:\r\n))?[ \t])))?))+?)'; - /** - * The name of this Header. - * - * @var string - */ - private $name; + /** + * The name of this Header. + * + * @var string + */ + private $name; - /** - * The Encoder used to encode this Header. - * - * @var Swift_Encoder - */ - private $encoder; + /** + * The Encoder used to encode this Header. + * + * @var Swift_Encoder + */ + private $encoder; - /** - * The maximum length of a line in the header. - * - * @var int - */ - private $lineLength = 78; + /** + * The maximum length of a line in the header. + * + * @var int + */ + private $lineLength = 78; - /** - * The language used in this Header. - * - * @var string - */ - private $lang; + /** + * The language used in this Header. + * + * @var string + */ + private $lang; - /** - * The character set of the text in this Header. - * - * @var string - */ - private $charset = 'utf-8'; + /** + * The character set of the text in this Header. + * + * @var string + */ + private $charset = 'utf-8'; - /** - * The value of this Header, cached. - * - * @var string - */ - private $cachedValue = null; + /** + * The value of this Header, cached. + * + * @var string + */ + private $cachedValue = null; - /** - * Set the character set used in this Header. - * - * @param string $charset - */ - public function setCharset($charset) - { - $this->clearCachedValueIf($charset != $this->charset); - $this->charset = $charset; - if (isset($this->encoder)) { - $this->encoder->charsetChanged($charset); - } - } + /** + * Set the character set used in this Header. + * + * @param string $charset + */ + public function setCharset($charset) + { + $this->clearCachedValueIf($charset != $this->charset); + $this->charset = $charset; + if (isset($this->encoder)) { + $this->encoder->charsetChanged($charset); + } + } - /** - * Get the character set used in this Header. - * - * @return string - */ - public function getCharset() - { - return $this->charset; - } + /** + * Get the character set used in this Header. + * + * @return string + */ + public function getCharset() + { + return $this->charset; + } - /** - * Set the language used in this Header. - * - * For example, for US English, 'en-us'. - * This can be unspecified. - * - * @param string $lang - */ - public function setLanguage($lang) - { - $this->clearCachedValueIf($this->lang != $lang); - $this->lang = $lang; - } + /** + * Set the language used in this Header. + * + * For example, for US English, 'en-us'. + * This can be unspecified. + * + * @param string $lang + */ + public function setLanguage($lang) + { + $this->clearCachedValueIf($this->lang != $lang); + $this->lang = $lang; + } - /** - * Get the language used in this Header. - * - * @return string - */ - public function getLanguage() - { - return $this->lang; - } + /** + * Get the language used in this Header. + * + * @return string + */ + public function getLanguage() + { + return $this->lang; + } - /** - * Set the encoder used for encoding the header. - */ - public function setEncoder(Swift_Mime_HeaderEncoder $encoder) - { - $this->encoder = $encoder; - $this->setCachedValue(null); - } + /** + * Set the encoder used for encoding the header. + */ + public function setEncoder(Swift_Mime_HeaderEncoder $encoder) + { + $this->encoder = $encoder; + $this->setCachedValue(null); + } - /** - * Get the encoder used for encoding this Header. - * - * @return Swift_Mime_HeaderEncoder - */ - public function getEncoder() - { - return $this->encoder; - } + /** + * Get the encoder used for encoding this Header. + * + * @return Swift_Mime_HeaderEncoder + */ + public function getEncoder() + { + return $this->encoder; + } - /** - * Get the name of this header (e.g. charset). - * - * @return string - */ - public function getFieldName() - { - return $this->name; - } + /** + * Get the name of this header (e.g. charset). + * + * @return string + */ + public function getFieldName() + { + return $this->name; + } - /** - * Set the maximum length of lines in the header (excluding EOL). - * - * @param int $lineLength - */ - public function setMaxLineLength($lineLength) - { - $this->clearCachedValueIf($this->lineLength != $lineLength); - $this->lineLength = $lineLength; - } + /** + * Set the maximum length of lines in the header (excluding EOL). + * + * @param int $lineLength + */ + public function setMaxLineLength($lineLength) + { + $this->clearCachedValueIf($this->lineLength != $lineLength); + $this->lineLength = $lineLength; + } - /** - * Get the maximum permitted length of lines in this Header. - * - * @return int - */ - public function getMaxLineLength() - { - return $this->lineLength; - } + /** + * Get the maximum permitted length of lines in this Header. + * + * @return int + */ + public function getMaxLineLength() + { + return $this->lineLength; + } - /** - * Get this Header rendered as a RFC 2822 compliant string. - * - * @return string - * - * @throws Swift_RfcComplianceException - */ - public function toString() - { - return $this->tokensToString($this->toTokens()); - } + /** + * Get this Header rendered as a RFC 2822 compliant string. + * + * @return string + * + * @throws Swift_RfcComplianceException + */ + public function toString() + { + return $this->tokensToString($this->toTokens()); + } - /** - * Returns a string representation of this object. - * - * @return string - * - * @see toString() - */ - public function __toString() - { - return $this->toString(); - } + /** + * Returns a string representation of this object. + * + * @return string + * + * @see toString() + */ + public function __toString() + { + return $this->toString(); + } - /** - * Set the name of this Header field. - * - * @param string $name - */ - protected function setFieldName($name) - { - $this->name = $name; - } + /** + * Set the name of this Header field. + * + * @param string $name + */ + protected function setFieldName($name) + { + $this->name = $name; + } - /** - * Produces a compliant, formatted RFC 2822 'phrase' based on the string given. - * - * @param string $string as displayed - * @param string $charset of the text - * @param bool $shorten the first line to make remove for header name - * - * @return string - */ - protected function createPhrase(Swift_Mime_Header $header, $string, $charset, Swift_Mime_HeaderEncoder $encoder = null, $shorten = false) - { - // Treat token as exactly what was given - $phraseStr = $string; - // If it's not valid + /** + * Produces a compliant, formatted RFC 2822 'phrase' based on the string given. + * + * @param string $string as displayed + * @param string $charset of the text + * @param bool $shorten the first line to make remove for header name + * + * @return string + */ + protected function createPhrase(Swift_Mime_Header $header, $string, $charset, Swift_Mime_HeaderEncoder $encoder = null, $shorten = false) + { + // Treat token as exactly what was given + $phraseStr = $string; + // If it's not valid - if (!preg_match('/^'.self::PHRASE_PATTERN.'$/D', $phraseStr)) { - // .. but it is just ascii text, try escaping some characters - // and make it a quoted-string - if (preg_match('/^[\x00-\x08\x0B\x0C\x0E-\x7F]*$/D', $phraseStr)) { - $phraseStr = $this->escapeSpecials($phraseStr, ['"']); - $phraseStr = '"'.$phraseStr.'"'; - } else { - // ... otherwise it needs encoding - // Determine space remaining on line if first line - if ($shorten) { - $usedLength = \strlen($header->getFieldName().': '); - } else { - $usedLength = 0; - } - $phraseStr = $this->encodeWords($header, $string, $usedLength); - } - } + if (!preg_match('/^'.self::PHRASE_PATTERN.'$/D', $phraseStr)) { + // .. but it is just ascii text, try escaping some characters + // and make it a quoted-string + if (preg_match('/^[\x00-\x08\x0B\x0C\x0E-\x7F]*$/D', $phraseStr)) { + $phraseStr = $this->escapeSpecials($phraseStr, ['"']); + $phraseStr = '"'.$phraseStr.'"'; + } else { + // ... otherwise it needs encoding + // Determine space remaining on line if first line + if ($shorten) { + $usedLength = \strlen($header->getFieldName().': '); + } else { + $usedLength = 0; + } + $phraseStr = $this->encodeWords($header, $string, $usedLength); + } + } - return $phraseStr; - } + return $phraseStr; + } - /** - * Escape special characters in a string (convert to quoted-pairs). - * - * @param string $token - * @param string[] $include additional chars to escape - * - * @return string - */ - private function escapeSpecials($token, $include = []) - { - foreach (array_merge(['\\'], $include) as $char) { - $token = str_replace($char, '\\'.$char, $token); - } + /** + * Escape special characters in a string (convert to quoted-pairs). + * + * @param string $token + * @param string[] $include additional chars to escape + * + * @return string + */ + private function escapeSpecials($token, $include = []) + { + foreach (array_merge(['\\'], $include) as $char) { + $token = str_replace($char, '\\'.$char, $token); + } - return $token; - } + return $token; + } - /** - * Encode needed word tokens within a string of input. - * - * @param string $input - * @param string $usedLength optional - * - * @return string - */ - protected function encodeWords(Swift_Mime_Header $header, $input, $usedLength = -1) - { - $value = ''; + /** + * Encode needed word tokens within a string of input. + * + * @param string $input + * @param string $usedLength optional + * + * @return string + */ + protected function encodeWords(Swift_Mime_Header $header, $input, $usedLength = -1) + { + $value = ''; - $tokens = $this->getEncodableWordTokens($input); + $tokens = $this->getEncodableWordTokens($input); - foreach ($tokens as $token) { - // See RFC 2822, Sect 2.2 (really 2.2 ??) - if ($this->tokenNeedsEncoding($token)) { - // Don't encode starting WSP - $firstChar = substr($token, 0, 1); - switch ($firstChar) { - case ' ': - case "\t": - $value .= $firstChar; - $token = substr($token, 1); - } + foreach ($tokens as $token) { + // See RFC 2822, Sect 2.2 (really 2.2 ??) + if ($this->tokenNeedsEncoding($token)) { + // Don't encode starting WSP + $firstChar = substr($token, 0, 1); + switch ($firstChar) { + case ' ': + case "\t": + $value .= $firstChar; + $token = substr($token, 1); + } - if (-1 == $usedLength) { - $usedLength = \strlen($header->getFieldName().': ') + \strlen($value); - } - $value .= $this->getTokenAsEncodedWord($token, $usedLength); + if (-1 == $usedLength) { + $usedLength = \strlen($header->getFieldName().': ') + \strlen($value); + } + $value .= $this->getTokenAsEncodedWord($token, $usedLength); - $header->setMaxLineLength(76); // Forcefully override - } else { - $value .= $token; - } - } + $header->setMaxLineLength(76); // Forcefully override + } else { + $value .= $token; + } + } - return $value; - } + return $value; + } - /** - * Test if a token needs to be encoded or not. - * - * @param string $token - * - * @return bool - */ - protected function tokenNeedsEncoding($token) - { - return preg_match('~[\x00-\x08\x10-\x19\x7F-\xFF\r\n]~', $token); - } + /** + * Test if a token needs to be encoded or not. + * + * @param string $token + * + * @return bool + */ + protected function tokenNeedsEncoding($token) + { + return preg_match('~[\x00-\x08\x10-\x19\x7F-\xFF\r\n]~', $token); + } - /** - * Splits a string into tokens in blocks of words which can be encoded quickly. - * - * @param string $string - * - * @return string[] - */ - protected function getEncodableWordTokens($string) - { - $tokens = []; + /** + * Splits a string into tokens in blocks of words which can be encoded quickly. + * + * @param string $string + * + * @return string[] + */ + protected function getEncodableWordTokens($string) + { + $tokens = []; - $encodedToken = ''; - // Split at all whitespace boundaries - foreach (preg_split('~(?=[\t ])~', $string ?? '') as $token) { - if ($this->tokenNeedsEncoding($token)) { - $encodedToken .= $token; - } else { - if (\strlen($encodedToken) > 0) { - $tokens[] = $encodedToken; - $encodedToken = ''; - } - $tokens[] = $token; - } - } - if (\strlen($encodedToken)) { - $tokens[] = $encodedToken; - } + $encodedToken = ''; + // Split at all whitespace boundaries + foreach (preg_split('~(?=[\t ])~', $string ?? '') as $token) { + if ($this->tokenNeedsEncoding($token)) { + $encodedToken .= $token; + } else { + if (\strlen($encodedToken) > 0) { + $tokens[] = $encodedToken; + $encodedToken = ''; + } + $tokens[] = $token; + } + } + if (\strlen($encodedToken)) { + $tokens[] = $encodedToken; + } - return $tokens; - } + return $tokens; + } - /** - * Get a token as an encoded word for safe insertion into headers. - * - * @param string $token token to encode - * @param int $firstLineOffset optional - * - * @return string - */ - protected function getTokenAsEncodedWord($token, $firstLineOffset = 0) - { - // Adjust $firstLineOffset to account for space needed for syntax - $charsetDecl = $this->charset; - if (isset($this->lang)) { - $charsetDecl .= '*'.$this->lang; - } - $encodingWrapperLength = \strlen( - '=?'.$charsetDecl.'?'.$this->encoder->getName().'??=' - ); + /** + * Get a token as an encoded word for safe insertion into headers. + * + * @param string $token token to encode + * @param int $firstLineOffset optional + * + * @return string + */ + protected function getTokenAsEncodedWord($token, $firstLineOffset = 0) + { + // Adjust $firstLineOffset to account for space needed for syntax + $charsetDecl = $this->charset; + if (isset($this->lang)) { + $charsetDecl .= '*'.$this->lang; + } + $encodingWrapperLength = \strlen( + '=?'.$charsetDecl.'?'.$this->encoder->getName().'??=' + ); - if ($firstLineOffset >= 75) { - //Does this logic need to be here? - $firstLineOffset = 0; - } + if ($firstLineOffset >= 75) { + //Does this logic need to be here? + $firstLineOffset = 0; + } - $encodedTextLines = explode("\r\n", - $this->encoder->encodeString( - $token, $firstLineOffset, 75 - $encodingWrapperLength, $this->charset - ) ?? '' - ); + $encodedTextLines = explode("\r\n", + $this->encoder->encodeString( + $token, $firstLineOffset, 75 - $encodingWrapperLength, $this->charset + ) ?? '' + ); - if ('iso-2022-jp' !== strtolower($this->charset ?? '')) { - // special encoding for iso-2022-jp using mb_encode_mimeheader - foreach ($encodedTextLines as $lineNum => $line) { - $encodedTextLines[$lineNum] = '=?'.$charsetDecl. - '?'.$this->encoder->getName(). - '?'.$line.'?='; - } - } + if ('iso-2022-jp' !== strtolower($this->charset ?? '')) { + // special encoding for iso-2022-jp using mb_encode_mimeheader + foreach ($encodedTextLines as $lineNum => $line) { + $encodedTextLines[$lineNum] = '=?'.$charsetDecl. + '?'.$this->encoder->getName(). + '?'.$line.'?='; + } + } - return implode("\r\n ", $encodedTextLines); - } + return implode("\r\n ", $encodedTextLines); + } - /** - * Generates tokens from the given string which include CRLF as individual tokens. - * - * @param string $token - * - * @return string[] - */ - protected function generateTokenLines($token) - { - return preg_split('~(\r\n)~', $token ?? '', -1, PREG_SPLIT_DELIM_CAPTURE); - } + /** + * Generates tokens from the given string which include CRLF as individual tokens. + * + * @param string $token + * + * @return string[] + */ + protected function generateTokenLines($token) + { + return preg_split('~(\r\n)~', $token ?? '', -1, PREG_SPLIT_DELIM_CAPTURE); + } - /** - * Set a value into the cache. - * - * @param string $value - */ - protected function setCachedValue($value) - { - $this->cachedValue = $value; - } + /** + * Set a value into the cache. + * + * @param string $value + */ + protected function setCachedValue($value) + { + $this->cachedValue = $value; + } - /** - * Get the value in the cache. - * - * @return string - */ - protected function getCachedValue() - { - return $this->cachedValue; - } + /** + * Get the value in the cache. + * + * @return string + */ + protected function getCachedValue() + { + return $this->cachedValue; + } - /** - * Clear the cached value if $condition is met. - * - * @param bool $condition - */ - protected function clearCachedValueIf($condition) - { - if ($condition) { - $this->setCachedValue(null); - } - } + /** + * Clear the cached value if $condition is met. + * + * @param bool $condition + */ + protected function clearCachedValueIf($condition) + { + if ($condition) { + $this->setCachedValue(null); + } + } - /** - * Generate a list of all tokens in the final header. - * - * @param string $string The string to tokenize - * - * @return array An array of tokens as strings - */ - protected function toTokens($string = null) - { - if (null === $string) { - $string = $this->getFieldBody(); - } + /** + * Generate a list of all tokens in the final header. + * + * @param string $string The string to tokenize + * + * @return array An array of tokens as strings + */ + protected function toTokens($string = null) + { + if (null === $string) { + $string = $this->getFieldBody(); + } - $tokens = []; + $tokens = []; - // Generate atoms; split at all invisible boundaries followed by WSP - foreach (preg_split('~(?=[ \t])~', $string ?? '') as $token) { - $newTokens = $this->generateTokenLines($token); - foreach ($newTokens as $newToken) { - $tokens[] = $newToken; - } - } + // Generate atoms; split at all invisible boundaries followed by WSP + foreach (preg_split('~(?=[ \t])~', $string ?? '') as $token) { + $newTokens = $this->generateTokenLines($token); + foreach ($newTokens as $newToken) { + $tokens[] = $newToken; + } + } - return $tokens; - } + return $tokens; + } - /** - * Takes an array of tokens which appear in the header and turns them into - * an RFC 2822 compliant string, adding FWSP where needed. - * - * @param string[] $tokens - * - * @return string - */ - private function tokensToString(array $tokens) - { - $lineCount = 0; - $headerLines = []; - $headerLines[] = $this->name.': '; - $currentLine = &$headerLines[$lineCount++]; + /** + * Takes an array of tokens which appear in the header and turns them into + * an RFC 2822 compliant string, adding FWSP where needed. + * + * @param string[] $tokens + * + * @return string + */ + private function tokensToString(array $tokens) + { + $lineCount = 0; + $headerLines = []; + $headerLines[] = $this->name.': '; + $currentLine = &$headerLines[$lineCount++]; - // Build all tokens back into compliant header - foreach ($tokens as $i => $token) { - // Line longer than specified maximum or token was just a new line - if (("\r\n" == $token) || - ($i > 0 && \strlen($currentLine.$token) > $this->lineLength) - && 0 < \strlen($currentLine)) { - $headerLines[] = ''; - $currentLine = &$headerLines[$lineCount++]; - } + // Build all tokens back into compliant header + foreach ($tokens as $i => $token) { + // Line longer than specified maximum or token was just a new line + if (("\r\n" == $token) || + ($i > 0 && \strlen($currentLine.$token) > $this->lineLength) + && 0 < \strlen($currentLine)) { + $headerLines[] = ''; + $currentLine = &$headerLines[$lineCount++]; + } - // Append token to the line - if ("\r\n" != $token) { - $currentLine .= $token; - } - } + // Append token to the line + if ("\r\n" != $token) { + $currentLine .= $token; + } + } - // Implode with FWS (RFC 2822, 2.2.3) - return implode("\r\n", $headerLines)."\r\n"; - } + // Implode with FWS (RFC 2822, 2.2.3) + return implode("\r\n", $headerLines)."\r\n"; + } - /** - * Make a deep copy of object. - */ - public function __clone() - { - if ($this->encoder) { - $this->encoder = clone $this->encoder; - } - } + /** + * Make a deep copy of object. + */ + public function __clone() + { + if ($this->encoder) { + $this->encoder = clone $this->encoder; + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/DateHeader.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/DateHeader.php index efe1dad6619..fb83178a8b3 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/DateHeader.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/DateHeader.php @@ -15,99 +15,99 @@ */ class Swift_Mime_Headers_DateHeader extends Swift_Mime_Headers_AbstractHeader { - /** - * Date-time value of this Header. - * - * @var DateTimeImmutable - */ - private $dateTime; + /** + * Date-time value of this Header. + * + * @var DateTimeImmutable + */ + private $dateTime; - /** - * Creates a new DateHeader with $name. - * - * @param string $name of Header - */ - public function __construct($name) - { - $this->setFieldName($name); - } + /** + * Creates a new DateHeader with $name. + * + * @param string $name of Header + */ + public function __construct($name) + { + $this->setFieldName($name); + } - /** - * Get the type of Header that this instance represents. - * - * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX - * @see TYPE_DATE, TYPE_ID, TYPE_PATH - * - * @return int - */ - public function getFieldType() - { - return self::TYPE_DATE; - } + /** + * Get the type of Header that this instance represents. + * + * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX + * @see TYPE_DATE, TYPE_ID, TYPE_PATH + * + * @return int + */ + public function getFieldType() + { + return self::TYPE_DATE; + } - /** - * Set the model for the field body. - * - * @param DateTimeInterface $model - */ - public function setFieldBodyModel($model) - { - $this->setDateTime($model); - } + /** + * Set the model for the field body. + * + * @param DateTimeInterface $model + */ + public function setFieldBodyModel($model) + { + $this->setDateTime($model); + } - /** - * Get the model for the field body. - * - * @return DateTimeImmutable - */ - public function getFieldBodyModel() - { - return $this->getDateTime(); - } + /** + * Get the model for the field body. + * + * @return DateTimeImmutable + */ + public function getFieldBodyModel() + { + return $this->getDateTime(); + } - /** - * Get the date-time representing the Date in this Header. - * - * @return DateTimeImmutable - */ - public function getDateTime() - { - return $this->dateTime; - } + /** + * Get the date-time representing the Date in this Header. + * + * @return DateTimeImmutable + */ + public function getDateTime() + { + return $this->dateTime; + } - /** - * Set the date-time of the Date in this Header. - * - * If a DateTime instance is provided, it is converted to DateTimeImmutable. - */ - public function setDateTime(DateTimeInterface $dateTime) - { - $this->clearCachedValueIf($this->getCachedValue() != $dateTime->format(DateTime::RFC2822)); - if ($dateTime instanceof DateTime) { - $immutable = new DateTimeImmutable('@'.$dateTime->getTimestamp()); - $dateTime = $immutable->setTimezone($dateTime->getTimezone()); - } - $this->dateTime = $dateTime; - } + /** + * Set the date-time of the Date in this Header. + * + * If a DateTime instance is provided, it is converted to DateTimeImmutable. + */ + public function setDateTime(DateTimeInterface $dateTime) + { + $this->clearCachedValueIf($this->getCachedValue() != $dateTime->format(DateTime::RFC2822)); + if ($dateTime instanceof DateTime) { + $immutable = new DateTimeImmutable('@'.$dateTime->getTimestamp()); + $dateTime = $immutable->setTimezone($dateTime->getTimezone()); + } + $this->dateTime = $dateTime; + } - /** - * Get the string value of the body in this Header. - * - * This is not necessarily RFC 2822 compliant since folding white space will - * not be added at this stage (see {@link toString()} for that). - * - * @see toString() - * - * @return string - */ - public function getFieldBody() - { - if (!$this->getCachedValue()) { - if (isset($this->dateTime)) { - $this->setCachedValue($this->dateTime->format(DateTime::RFC2822)); - } - } + /** + * Get the string value of the body in this Header. + * + * This is not necessarily RFC 2822 compliant since folding white space will + * not be added at this stage (see {@link toString()} for that). + * + * @see toString() + * + * @return string + */ + public function getFieldBody() + { + if (!$this->getCachedValue()) { + if (isset($this->dateTime)) { + $this->setCachedValue($this->dateTime->format(DateTime::RFC2822)); + } + } - return $this->getCachedValue(); - } + return $this->getCachedValue(); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/IdentificationHeader.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/IdentificationHeader.php index 4fcdff418a7..cec31c83961 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/IdentificationHeader.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/IdentificationHeader.php @@ -19,171 +19,171 @@ use Egulias\EmailValidator\Validation\RFCValidation; */ class Swift_Mime_Headers_IdentificationHeader extends Swift_Mime_Headers_AbstractHeader { - /** - * The IDs used in the value of this Header. - * - * This may hold multiple IDs or just a single ID. - * - * @var string[] - */ - private $ids = []; + /** + * The IDs used in the value of this Header. + * + * This may hold multiple IDs or just a single ID. + * + * @var string[] + */ + private $ids = []; - /** - * The strict EmailValidator. - * - * @var EmailValidator - */ - private $emailValidator; + /** + * The strict EmailValidator. + * + * @var EmailValidator + */ + private $emailValidator; - private $addressEncoder; + private $addressEncoder; - /** - * Creates a new IdentificationHeader with the given $name and $id. - * - * @param string $name - */ - public function __construct($name, EmailValidator $emailValidator, Swift_AddressEncoder $addressEncoder = null) - { - $this->setFieldName($name); - $this->emailValidator = $emailValidator; - $this->addressEncoder = $addressEncoder ?? new Swift_AddressEncoder_IdnAddressEncoder(); - } + /** + * Creates a new IdentificationHeader with the given $name and $id. + * + * @param string $name + */ + public function __construct($name, EmailValidator $emailValidator, Swift_AddressEncoder $addressEncoder = null) + { + $this->setFieldName($name); + $this->emailValidator = $emailValidator; + $this->addressEncoder = $addressEncoder ?? new Swift_AddressEncoder_IdnAddressEncoder(); + } - /** - * Get the type of Header that this instance represents. - * - * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX - * @see TYPE_DATE, TYPE_ID, TYPE_PATH - * - * @return int - */ - public function getFieldType() - { - return self::TYPE_ID; - } + /** + * Get the type of Header that this instance represents. + * + * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX + * @see TYPE_DATE, TYPE_ID, TYPE_PATH + * + * @return int + */ + public function getFieldType() + { + return self::TYPE_ID; + } - /** - * Set the model for the field body. - * - * This method takes a string ID, or an array of IDs. - * - * @param mixed $model - * - * @throws Swift_RfcComplianceException - */ - public function setFieldBodyModel($model) - { - $this->setId($model); - } + /** + * Set the model for the field body. + * + * This method takes a string ID, or an array of IDs. + * + * @param mixed $model + * + * @throws Swift_RfcComplianceException + */ + public function setFieldBodyModel($model) + { + $this->setId($model); + } - /** - * Get the model for the field body. - * - * This method returns an array of IDs - * - * @return array - */ - public function getFieldBodyModel() - { - return $this->getIds(); - } + /** + * Get the model for the field body. + * + * This method returns an array of IDs + * + * @return array + */ + public function getFieldBodyModel() + { + return $this->getIds(); + } - /** - * Set the ID used in the value of this header. - * - * @param string|array $id - * - * @throws Swift_RfcComplianceException - */ - public function setId($id) - { - $this->setIds(\is_array($id) ? $id : [$id]); - } + /** + * Set the ID used in the value of this header. + * + * @param string|array $id + * + * @throws Swift_RfcComplianceException + */ + public function setId($id) + { + $this->setIds(\is_array($id) ? $id : [$id]); + } - /** - * Get the ID used in the value of this Header. - * - * If multiple IDs are set only the first is returned. - * - * @return string - */ - public function getId() - { - if (\count($this->ids) > 0) { - return $this->ids[0]; - } - } + /** + * Get the ID used in the value of this Header. + * + * If multiple IDs are set only the first is returned. + * + * @return string + */ + public function getId() + { + if (\count($this->ids) > 0) { + return $this->ids[0]; + } + } - /** - * Set a collection of IDs to use in the value of this Header. - * - * @param string[] $ids - * - * @throws Swift_RfcComplianceException - */ - public function setIds(array $ids) - { - $actualIds = []; + /** + * Set a collection of IDs to use in the value of this Header. + * + * @param string[] $ids + * + * @throws Swift_RfcComplianceException + */ + public function setIds(array $ids) + { + $actualIds = []; - foreach ($ids as $id) { - $this->assertValidId($id); - $actualIds[] = $id; - } + foreach ($ids as $id) { + $this->assertValidId($id); + $actualIds[] = $id; + } - $this->clearCachedValueIf($this->ids != $actualIds); - $this->ids = $actualIds; - } + $this->clearCachedValueIf($this->ids != $actualIds); + $this->ids = $actualIds; + } - /** - * Get the list of IDs used in this Header. - * - * @return string[] - */ - public function getIds() - { - return $this->ids; - } + /** + * Get the list of IDs used in this Header. + * + * @return string[] + */ + public function getIds() + { + return $this->ids; + } - /** - * Get the string value of the body in this Header. - * - * This is not necessarily RFC 2822 compliant since folding white space will - * not be added at this stage (see {@see toString()} for that). - * - * @see toString() - * - * @throws Swift_RfcComplianceException - * - * @return string - */ - public function getFieldBody() - { - if (!$this->getCachedValue()) { - $angleAddrs = []; + /** + * Get the string value of the body in this Header. + * + * This is not necessarily RFC 2822 compliant since folding white space will + * not be added at this stage (see {@see toString()} for that). + * + * @see toString() + * + * @throws Swift_RfcComplianceException + * + * @return string + */ + public function getFieldBody() + { + if (!$this->getCachedValue()) { + $angleAddrs = []; - foreach ($this->ids as $id) { - $angleAddrs[] = '<'.$this->addressEncoder->encodeString($id).'>'; - } + foreach ($this->ids as $id) { + $angleAddrs[] = '<'.$this->addressEncoder->encodeString($id).'>'; + } - $this->setCachedValue(implode(' ', $angleAddrs)); - } + $this->setCachedValue(implode(' ', $angleAddrs)); + } - return $this->getCachedValue(); - } + return $this->getCachedValue(); + } - /** - * Throws an Exception if the id passed does not comply with RFC 2822. - * - * @param string $id - * - * @throws Swift_RfcComplianceException - */ - private function assertValidId($id) - { - $emailValidation = class_exists(MessageIDValidation::class) ? new MessageIDValidation() : new RFCValidation(); + /** + * Throws an Exception if the id passed does not comply with RFC 2822. + * + * @param string $id + * + * @throws Swift_RfcComplianceException + */ + private function assertValidId($id) + { + $emailValidation = class_exists(MessageIDValidation::class) ? new MessageIDValidation() : new RFCValidation(); - if (!$this->emailValidator->isValid($id, $emailValidation)) { - throw new Swift_RfcComplianceException('Invalid ID given <'.$id.'>'); - } - } + if (!$this->emailValidator->isValid($id, $emailValidation)) { + throw new Swift_RfcComplianceException('Invalid ID given <'.$id.'>'); + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php index ddd5e8cffb1..febc31332dd 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php @@ -18,341 +18,341 @@ use Egulias\EmailValidator\Validation\RFCValidation; */ class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader { - /** - * The mailboxes used in this Header. - * - * @var string[] - */ - private $mailboxes = []; + /** + * The mailboxes used in this Header. + * + * @var string[] + */ + private $mailboxes = []; - /** - * The strict EmailValidator. - * - * @var EmailValidator - */ - private $emailValidator; + /** + * The strict EmailValidator. + * + * @var EmailValidator + */ + private $emailValidator; - private $addressEncoder; + private $addressEncoder; - /** - * Creates a new MailboxHeader with $name. - * - * @param string $name of Header - */ - public function __construct($name, Swift_Mime_HeaderEncoder $encoder, EmailValidator $emailValidator, Swift_AddressEncoder $addressEncoder = null) - { - $this->setFieldName($name); - $this->setEncoder($encoder); - $this->emailValidator = $emailValidator; - $this->addressEncoder = $addressEncoder ?? new Swift_AddressEncoder_IdnAddressEncoder(); - } + /** + * Creates a new MailboxHeader with $name. + * + * @param string $name of Header + */ + public function __construct($name, Swift_Mime_HeaderEncoder $encoder, EmailValidator $emailValidator, Swift_AddressEncoder $addressEncoder = null) + { + $this->setFieldName($name); + $this->setEncoder($encoder); + $this->emailValidator = $emailValidator; + $this->addressEncoder = $addressEncoder ?? new Swift_AddressEncoder_IdnAddressEncoder(); + } - /** - * Get the type of Header that this instance represents. - * - * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX - * @see TYPE_DATE, TYPE_ID, TYPE_PATH - * - * @return int - */ - public function getFieldType() - { - return self::TYPE_MAILBOX; - } + /** + * Get the type of Header that this instance represents. + * + * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX + * @see TYPE_DATE, TYPE_ID, TYPE_PATH + * + * @return int + */ + public function getFieldType() + { + return self::TYPE_MAILBOX; + } - /** - * Set the model for the field body. - * - * This method takes a string, or an array of addresses. - * - * @param mixed $model - * - * @throws Swift_RfcComplianceException - */ - public function setFieldBodyModel($model) - { - $this->setNameAddresses($model); - } + /** + * Set the model for the field body. + * + * This method takes a string, or an array of addresses. + * + * @param mixed $model + * + * @throws Swift_RfcComplianceException + */ + public function setFieldBodyModel($model) + { + $this->setNameAddresses($model); + } - /** - * Get the model for the field body. - * - * This method returns an associative array like {@link getNameAddresses()} - * - * @throws Swift_RfcComplianceException - * - * @return array - */ - public function getFieldBodyModel() - { - return $this->getNameAddresses(); - } + /** + * Get the model for the field body. + * + * This method returns an associative array like {@link getNameAddresses()} + * + * @throws Swift_RfcComplianceException + * + * @return array + */ + public function getFieldBodyModel() + { + return $this->getNameAddresses(); + } - /** - * Set a list of mailboxes to be shown in this Header. - * - * The mailboxes can be a simple array of addresses, or an array of - * key=>value pairs where (email => personalName). - * Example: - * - * setNameAddresses(array( - * 'chris@swiftmailer.org' => 'Chris Corbyn', - * 'mark@swiftmailer.org' //No associated personal name - * )); - * ?> - * - * - * @see __construct() - * @see setAddresses() - * @see setValue() - * - * @param string|string[] $mailboxes - * - * @throws Swift_RfcComplianceException - */ - public function setNameAddresses($mailboxes) - { - $this->mailboxes = $this->normalizeMailboxes((array) $mailboxes); - $this->setCachedValue(null); //Clear any cached value - } + /** + * Set a list of mailboxes to be shown in this Header. + * + * The mailboxes can be a simple array of addresses, or an array of + * key=>value pairs where (email => personalName). + * Example: + * + * setNameAddresses(array( + * 'chris@swiftmailer.org' => 'Chris Corbyn', + * 'mark@swiftmailer.org' //No associated personal name + * )); + * ?> + * + * + * @see __construct() + * @see setAddresses() + * @see setValue() + * + * @param string|string[] $mailboxes + * + * @throws Swift_RfcComplianceException + */ + public function setNameAddresses($mailboxes) + { + $this->mailboxes = $this->normalizeMailboxes((array) $mailboxes); + $this->setCachedValue(null); //Clear any cached value + } - /** - * Get the full mailbox list of this Header as an array of valid RFC 2822 strings. - * - * Example: - * - * 'Chris Corbyn', - * 'mark@swiftmailer.org' => 'Mark Corbyn') - * ); - * print_r($header->getNameAddressStrings()); - * // array ( - * // 0 => Chris Corbyn , - * // 1 => Mark Corbyn - * // ) - * ?> - * - * - * @see getNameAddresses() - * @see toString() - * - * @throws Swift_RfcComplianceException - * - * @return string[] - */ - public function getNameAddressStrings() - { - return $this->createNameAddressStrings($this->getNameAddresses()); - } + /** + * Get the full mailbox list of this Header as an array of valid RFC 2822 strings. + * + * Example: + * + * 'Chris Corbyn', + * 'mark@swiftmailer.org' => 'Mark Corbyn') + * ); + * print_r($header->getNameAddressStrings()); + * // array ( + * // 0 => Chris Corbyn , + * // 1 => Mark Corbyn + * // ) + * ?> + * + * + * @see getNameAddresses() + * @see toString() + * + * @throws Swift_RfcComplianceException + * + * @return string[] + */ + public function getNameAddressStrings() + { + return $this->createNameAddressStrings($this->getNameAddresses()); + } - /** - * Get all mailboxes in this Header as key=>value pairs. - * - * The key is the address and the value is the name (or null if none set). - * Example: - * - * 'Chris Corbyn', - * 'mark@swiftmailer.org' => 'Mark Corbyn') - * ); - * print_r($header->getNameAddresses()); - * // array ( - * // chris@swiftmailer.org => Chris Corbyn, - * // mark@swiftmailer.org => Mark Corbyn - * // ) - * ?> - * - * - * @see getAddresses() - * @see getNameAddressStrings() - * - * @return string[] - */ - public function getNameAddresses() - { - return $this->mailboxes; - } + /** + * Get all mailboxes in this Header as key=>value pairs. + * + * The key is the address and the value is the name (or null if none set). + * Example: + * + * 'Chris Corbyn', + * 'mark@swiftmailer.org' => 'Mark Corbyn') + * ); + * print_r($header->getNameAddresses()); + * // array ( + * // chris@swiftmailer.org => Chris Corbyn, + * // mark@swiftmailer.org => Mark Corbyn + * // ) + * ?> + * + * + * @see getAddresses() + * @see getNameAddressStrings() + * + * @return string[] + */ + public function getNameAddresses() + { + return $this->mailboxes; + } - /** - * Makes this Header represent a list of plain email addresses with no names. - * - * Example: - * - * setAddresses( - * array('one@domain.tld', 'two@domain.tld', 'three@domain.tld') - * ); - * ?> - * - * - * @see setNameAddresses() - * @see setValue() - * - * @param string[] $addresses - * - * @throws Swift_RfcComplianceException - */ - public function setAddresses($addresses) - { - $this->setNameAddresses(array_values((array) $addresses)); - } + /** + * Makes this Header represent a list of plain email addresses with no names. + * + * Example: + * + * setAddresses( + * array('one@domain.tld', 'two@domain.tld', 'three@domain.tld') + * ); + * ?> + * + * + * @see setNameAddresses() + * @see setValue() + * + * @param string[] $addresses + * + * @throws Swift_RfcComplianceException + */ + public function setAddresses($addresses) + { + $this->setNameAddresses(array_values((array) $addresses)); + } - /** - * Get all email addresses in this Header. - * - * @see getNameAddresses() - * - * @return string[] - */ - public function getAddresses() - { - return array_keys($this->mailboxes); - } + /** + * Get all email addresses in this Header. + * + * @see getNameAddresses() + * + * @return string[] + */ + public function getAddresses() + { + return array_keys($this->mailboxes); + } - /** - * Remove one or more addresses from this Header. - * - * @param string|string[] $addresses - */ - public function removeAddresses($addresses) - { - $this->setCachedValue(null); - foreach ((array) $addresses as $address) { - unset($this->mailboxes[$address]); - } - } + /** + * Remove one or more addresses from this Header. + * + * @param string|string[] $addresses + */ + public function removeAddresses($addresses) + { + $this->setCachedValue(null); + foreach ((array) $addresses as $address) { + unset($this->mailboxes[$address]); + } + } - /** - * Get the string value of the body in this Header. - * - * This is not necessarily RFC 2822 compliant since folding white space will - * not be added at this stage (see {@link toString()} for that). - * - * @see toString() - * - * @throws Swift_RfcComplianceException - * - * @return string - */ - public function getFieldBody() - { - // Compute the string value of the header only if needed - if (null === $this->getCachedValue()) { - $this->setCachedValue($this->createMailboxListString($this->mailboxes)); - } + /** + * Get the string value of the body in this Header. + * + * This is not necessarily RFC 2822 compliant since folding white space will + * not be added at this stage (see {@link toString()} for that). + * + * @see toString() + * + * @throws Swift_RfcComplianceException + * + * @return string + */ + public function getFieldBody() + { + // Compute the string value of the header only if needed + if (null === $this->getCachedValue()) { + $this->setCachedValue($this->createMailboxListString($this->mailboxes)); + } - return $this->getCachedValue(); - } + return $this->getCachedValue(); + } - /** - * Normalizes a user-input list of mailboxes into consistent key=>value pairs. - * - * @param string[] $mailboxes - * - * @return string[] - */ - protected function normalizeMailboxes(array $mailboxes) - { - $actualMailboxes = []; + /** + * Normalizes a user-input list of mailboxes into consistent key=>value pairs. + * + * @param string[] $mailboxes + * + * @return string[] + */ + protected function normalizeMailboxes(array $mailboxes) + { + $actualMailboxes = []; - foreach ($mailboxes as $key => $value) { - if (\is_string($key)) { - //key is email addr - $address = $key; - $name = $value; - } else { - $address = $value; - $name = null; - } - $this->assertValidAddress($address); - $actualMailboxes[$address] = $name; - } + foreach ($mailboxes as $key => $value) { + if (\is_string($key)) { + //key is email addr + $address = $key; + $name = $value; + } else { + $address = $value; + $name = null; + } + $this->assertValidAddress($address); + $actualMailboxes[$address] = $name; + } - return $actualMailboxes; - } + return $actualMailboxes; + } - /** - * Produces a compliant, formatted display-name based on the string given. - * - * @param string $displayName as displayed - * @param bool $shorten the first line to make remove for header name - * - * @return string - */ - protected function createDisplayNameString($displayName, $shorten = false) - { - return $this->createPhrase($this, $displayName, $this->getCharset(), $this->getEncoder(), $shorten); - } + /** + * Produces a compliant, formatted display-name based on the string given. + * + * @param string $displayName as displayed + * @param bool $shorten the first line to make remove for header name + * + * @return string + */ + protected function createDisplayNameString($displayName, $shorten = false) + { + return $this->createPhrase($this, $displayName, $this->getCharset(), $this->getEncoder(), $shorten); + } - /** - * Creates a string form of all the mailboxes in the passed array. - * - * @param string[] $mailboxes - * - * @throws Swift_RfcComplianceException - * - * @return string - */ - protected function createMailboxListString(array $mailboxes) - { - return implode(', ', $this->createNameAddressStrings($mailboxes)); - } + /** + * Creates a string form of all the mailboxes in the passed array. + * + * @param string[] $mailboxes + * + * @throws Swift_RfcComplianceException + * + * @return string + */ + protected function createMailboxListString(array $mailboxes) + { + return implode(', ', $this->createNameAddressStrings($mailboxes)); + } - /** - * Redefine the encoding requirements for mailboxes. - * - * All "specials" must be encoded as the full header value will not be quoted - * - * @see RFC 2822 3.2.1 - * - * @param string $token - * - * @return bool - */ - protected function tokenNeedsEncoding($token) - { - return preg_match('/[()<>\[\]:;@\,."]/', $token) || parent::tokenNeedsEncoding($token); - } + /** + * Redefine the encoding requirements for mailboxes. + * + * All "specials" must be encoded as the full header value will not be quoted + * + * @see RFC 2822 3.2.1 + * + * @param string $token + * + * @return bool + */ + protected function tokenNeedsEncoding($token) + { + return preg_match('/[()<>\[\]:;@\,."]/', $token) || parent::tokenNeedsEncoding($token); + } - /** - * Return an array of strings conforming the the name-addr spec of RFC 2822. - * - * @param string[] $mailboxes - * - * @return string[] - */ - private function createNameAddressStrings(array $mailboxes) - { - $strings = []; + /** + * Return an array of strings conforming the the name-addr spec of RFC 2822. + * + * @param string[] $mailboxes + * + * @return string[] + */ + private function createNameAddressStrings(array $mailboxes) + { + $strings = []; - foreach ($mailboxes as $email => $name) { - $mailboxStr = $this->addressEncoder->encodeString($email); - if (null !== $name) { - $nameStr = $this->createDisplayNameString($name, empty($strings)); - $mailboxStr = $nameStr.' <'.$mailboxStr.'>'; - } - $strings[] = $mailboxStr; - } + foreach ($mailboxes as $email => $name) { + $mailboxStr = $this->addressEncoder->encodeString($email); + if (null !== $name) { + $nameStr = $this->createDisplayNameString($name, empty($strings)); + $mailboxStr = $nameStr.' <'.$mailboxStr.'>'; + } + $strings[] = $mailboxStr; + } - return $strings; - } + return $strings; + } - /** - * Throws an Exception if the address passed does not comply with RFC 2822. - * - * @param string $address - * - * @throws Swift_RfcComplianceException if invalid - */ - private function assertValidAddress($address) - { - if (!$this->emailValidator->isValid($address, new RFCValidation())) { - throw new Swift_RfcComplianceException('Address in mailbox given ['.$address.'] does not comply with RFC 2822, 3.6.2.'); - } - } + /** + * Throws an Exception if the address passed does not comply with RFC 2822. + * + * @param string $address + * + * @throws Swift_RfcComplianceException if invalid + */ + private function assertValidAddress($address) + { + if (!$this->emailValidator->isValid($address, new RFCValidation())) { + throw new Swift_RfcComplianceException('Address in mailbox given ['.$address.'] does not comply with RFC 2822, 3.6.2.'); + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/OpenDKIMHeader.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/OpenDKIMHeader.php index fafb5bae21f..d0cb3504a97 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/OpenDKIMHeader.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/OpenDKIMHeader.php @@ -17,119 +17,119 @@ */ class Swift_Mime_Headers_OpenDKIMHeader implements Swift_Mime_Header { - /** - * The value of this Header. - * - * @var string - */ - private $value; + /** + * The value of this Header. + * + * @var string + */ + private $value; - /** - * The name of this Header. - * - * @var string - */ - private $fieldName; + /** + * The name of this Header. + * + * @var string + */ + private $fieldName; - /** - * @param string $name - */ - public function __construct($name) - { - $this->fieldName = $name; - } + /** + * @param string $name + */ + public function __construct($name) + { + $this->fieldName = $name; + } - /** - * Get the type of Header that this instance represents. - * - * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX - * @see TYPE_DATE, TYPE_ID, TYPE_PATH - * - * @return int - */ - public function getFieldType() - { - return self::TYPE_TEXT; - } + /** + * Get the type of Header that this instance represents. + * + * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX + * @see TYPE_DATE, TYPE_ID, TYPE_PATH + * + * @return int + */ + public function getFieldType() + { + return self::TYPE_TEXT; + } - /** - * Set the model for the field body. - * - * This method takes a string for the field value. - * - * @param string $model - */ - public function setFieldBodyModel($model) - { - $this->setValue($model); - } + /** + * Set the model for the field body. + * + * This method takes a string for the field value. + * + * @param string $model + */ + public function setFieldBodyModel($model) + { + $this->setValue($model); + } - /** - * Get the model for the field body. - * - * This method returns a string. - * - * @return string - */ - public function getFieldBodyModel() - { - return $this->getValue(); - } + /** + * Get the model for the field body. + * + * This method returns a string. + * + * @return string + */ + public function getFieldBodyModel() + { + return $this->getValue(); + } - /** - * Get the (unencoded) value of this header. - * - * @return string - */ - public function getValue() - { - return $this->value; - } + /** + * Get the (unencoded) value of this header. + * + * @return string + */ + public function getValue() + { + return $this->value; + } - /** - * Set the (unencoded) value of this header. - * - * @param string $value - */ - public function setValue($value) - { - $this->value = $value; - } + /** + * Set the (unencoded) value of this header. + * + * @param string $value + */ + public function setValue($value) + { + $this->value = $value; + } - /** - * Get the value of this header prepared for rendering. - * - * @return string - */ - public function getFieldBody() - { - return $this->value; - } + /** + * Get the value of this header prepared for rendering. + * + * @return string + */ + public function getFieldBody() + { + return $this->value; + } - /** - * Get this Header rendered as a RFC 2822 compliant string. - * - * @return string - */ - public function toString() - { - return $this->fieldName.': '.$this->value."\r\n"; - } + /** + * Get this Header rendered as a RFC 2822 compliant string. + * + * @return string + */ + public function toString() + { + return $this->fieldName.': '.$this->value."\r\n"; + } - /** - * Set the Header FieldName. - * - * @see Swift_Mime_Header::getFieldName() - */ - public function getFieldName() - { - return $this->fieldName; - } + /** + * Set the Header FieldName. + * + * @see Swift_Mime_Header::getFieldName() + */ + public function getFieldName() + { + return $this->fieldName; + } - /** - * Ignored. - */ - public function setCharset($charset) - { - } + /** + * Ignored. + */ + public function setCharset($charset) + { + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/ParameterizedHeader.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/ParameterizedHeader.php index 47c15e6c05f..6cd26a26465 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/ParameterizedHeader.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/ParameterizedHeader.php @@ -15,241 +15,241 @@ */ class Swift_Mime_Headers_ParameterizedHeader extends Swift_Mime_Headers_UnstructuredHeader { - /** - * RFC 2231's definition of a token. - * - * @var string - */ - const TOKEN_REGEX = '(?:[\x21\x23-\x27\x2A\x2B\x2D\x2E\x30-\x39\x41-\x5A\x5E-\x7E]+)'; + /** + * RFC 2231's definition of a token. + * + * @var string + */ + const TOKEN_REGEX = '(?:[\x21\x23-\x27\x2A\x2B\x2D\x2E\x30-\x39\x41-\x5A\x5E-\x7E]+)'; - /** - * The Encoder used to encode the parameters. - * - * @var Swift_Encoder - */ - private $paramEncoder; + /** + * The Encoder used to encode the parameters. + * + * @var Swift_Encoder + */ + private $paramEncoder; - /** - * The parameters as an associative array. - * - * @var string[] - */ - private $params = []; + /** + * The parameters as an associative array. + * + * @var string[] + */ + private $params = []; - /** - * Creates a new ParameterizedHeader with $name. - * - * @param string $name - */ - public function __construct($name, Swift_Mime_HeaderEncoder $encoder, Swift_Encoder $paramEncoder = null) - { - parent::__construct($name, $encoder); - $this->paramEncoder = $paramEncoder; - } + /** + * Creates a new ParameterizedHeader with $name. + * + * @param string $name + */ + public function __construct($name, Swift_Mime_HeaderEncoder $encoder, Swift_Encoder $paramEncoder = null) + { + parent::__construct($name, $encoder); + $this->paramEncoder = $paramEncoder; + } - /** - * Get the type of Header that this instance represents. - * - * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX - * @see TYPE_DATE, TYPE_ID, TYPE_PATH - * - * @return int - */ - public function getFieldType() - { - return self::TYPE_PARAMETERIZED; - } + /** + * Get the type of Header that this instance represents. + * + * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX + * @see TYPE_DATE, TYPE_ID, TYPE_PATH + * + * @return int + */ + public function getFieldType() + { + return self::TYPE_PARAMETERIZED; + } - /** - * Set the character set used in this Header. - * - * @param string $charset - */ - public function setCharset($charset) - { - parent::setCharset($charset); - if (isset($this->paramEncoder)) { - $this->paramEncoder->charsetChanged($charset); - } - } + /** + * Set the character set used in this Header. + * + * @param string $charset + */ + public function setCharset($charset) + { + parent::setCharset($charset); + if (isset($this->paramEncoder)) { + $this->paramEncoder->charsetChanged($charset); + } + } - /** - * Set the value of $parameter. - * - * @param string $parameter - * @param string $value - */ - public function setParameter($parameter, $value) - { - $this->setParameters(array_merge($this->getParameters(), [$parameter => $value])); - } + /** + * Set the value of $parameter. + * + * @param string $parameter + * @param string $value + */ + public function setParameter($parameter, $value) + { + $this->setParameters(array_merge($this->getParameters(), [$parameter => $value])); + } - /** - * Get the value of $parameter. - * - * @param string $parameter - * - * @return string - */ - public function getParameter($parameter) - { - $params = $this->getParameters(); + /** + * Get the value of $parameter. + * + * @param string $parameter + * + * @return string + */ + public function getParameter($parameter) + { + $params = $this->getParameters(); - return $params[$parameter] ?? null; - } + return $params[$parameter] ?? null; + } - /** - * Set an associative array of parameter names mapped to values. - * - * @param string[] $parameters - */ - public function setParameters(array $parameters) - { - $this->clearCachedValueIf($this->params != $parameters); - $this->params = $parameters; - } + /** + * Set an associative array of parameter names mapped to values. + * + * @param string[] $parameters + */ + public function setParameters(array $parameters) + { + $this->clearCachedValueIf($this->params != $parameters); + $this->params = $parameters; + } - /** - * Returns an associative array of parameter names mapped to values. - * - * @return string[] - */ - public function getParameters() - { - return $this->params; - } + /** + * Returns an associative array of parameter names mapped to values. + * + * @return string[] + */ + public function getParameters() + { + return $this->params; + } - /** - * Get the value of this header prepared for rendering. - * - * @return string - */ - public function getFieldBody() //TODO: Check caching here - { - $body = parent::getFieldBody(); - foreach ($this->params as $name => $value) { - if (null !== $value) { - // Add the parameter - $body .= '; '.$this->createParameter($name, $value); - } - } + /** + * Get the value of this header prepared for rendering. + * + * @return string + */ + public function getFieldBody() //TODO: Check caching here + { + $body = parent::getFieldBody(); + foreach ($this->params as $name => $value) { + if (null !== $value) { + // Add the parameter + $body .= '; '.$this->createParameter($name, $value); + } + } - return $body; - } + return $body; + } - /** - * Generate a list of all tokens in the final header. - * - * This doesn't need to be overridden in theory, but it is for implementation - * reasons to prevent potential breakage of attributes. - * - * @param string $string The string to tokenize - * - * @return array An array of tokens as strings - */ - protected function toTokens($string = null) - { - $tokens = parent::toTokens(parent::getFieldBody()); + /** + * Generate a list of all tokens in the final header. + * + * This doesn't need to be overridden in theory, but it is for implementation + * reasons to prevent potential breakage of attributes. + * + * @param string $string The string to tokenize + * + * @return array An array of tokens as strings + */ + protected function toTokens($string = null) + { + $tokens = parent::toTokens(parent::getFieldBody()); - // Try creating any parameters - foreach ($this->params as $name => $value) { - if (null !== $value) { - // Add the semi-colon separator - $tokens[\count($tokens) - 1] .= ';'; - $tokens = array_merge($tokens, $this->generateTokenLines( - ' '.$this->createParameter($name, $value) - )); - } - } + // Try creating any parameters + foreach ($this->params as $name => $value) { + if (null !== $value) { + // Add the semi-colon separator + $tokens[\count($tokens) - 1] .= ';'; + $tokens = array_merge($tokens, $this->generateTokenLines( + ' '.$this->createParameter($name, $value) + )); + } + } - return $tokens; - } + return $tokens; + } - /** - * Render a RFC 2047 compliant header parameter from the $name and $value. - * - * @param string $name - * @param string $value - * - * @return string - */ - private function createParameter($name, $value) - { - $origValue = $value; + /** + * Render a RFC 2047 compliant header parameter from the $name and $value. + * + * @param string $name + * @param string $value + * + * @return string + */ + private function createParameter($name, $value) + { + $origValue = $value; - $encoded = false; - // Allow room for parameter name, indices, "=" and DQUOTEs - $maxValueLength = $this->getMaxLineLength() - \strlen($name.'=*N"";') - 1; - $firstLineOffset = 0; + $encoded = false; + // Allow room for parameter name, indices, "=" and DQUOTEs + $maxValueLength = $this->getMaxLineLength() - \strlen($name.'=*N"";') - 1; + $firstLineOffset = 0; - // If it's not already a valid parameter value... - if (!preg_match('/^'.self::TOKEN_REGEX.'$/D', $value)) { - // TODO: text, or something else?? - // ... and it's not ascii - if (!preg_match('/^[\x00-\x08\x0B\x0C\x0E-\x7F]*$/D', $value)) { - $encoded = true; - // Allow space for the indices, charset and language - $maxValueLength = $this->getMaxLineLength() - \strlen($name.'*N*="";') - 1; - $firstLineOffset = \strlen( - $this->getCharset()."'".$this->getLanguage()."'" - ); - } - } + // If it's not already a valid parameter value... + if (!preg_match('/^'.self::TOKEN_REGEX.'$/D', $value)) { + // TODO: text, or something else?? + // ... and it's not ascii + if (!preg_match('/^[\x00-\x08\x0B\x0C\x0E-\x7F]*$/D', $value)) { + $encoded = true; + // Allow space for the indices, charset and language + $maxValueLength = $this->getMaxLineLength() - \strlen($name.'*N*="";') - 1; + $firstLineOffset = \strlen( + $this->getCharset()."'".$this->getLanguage()."'" + ); + } + } - // Encode if we need to - if ($encoded || \strlen($value) > $maxValueLength) { - if (isset($this->paramEncoder)) { - $value = $this->paramEncoder->encodeString( - $origValue, $firstLineOffset, $maxValueLength, $this->getCharset() - ); - } else { - // We have to go against RFC 2183/2231 in some areas for interoperability - $value = $this->getTokenAsEncodedWord($origValue); - $encoded = false; - } - } + // Encode if we need to + if ($encoded || \strlen($value) > $maxValueLength) { + if (isset($this->paramEncoder)) { + $value = $this->paramEncoder->encodeString( + $origValue, $firstLineOffset, $maxValueLength, $this->getCharset() + ); + } else { + // We have to go against RFC 2183/2231 in some areas for interoperability + $value = $this->getTokenAsEncodedWord($origValue); + $encoded = false; + } + } - $valueLines = isset($this->paramEncoder) ? explode("\r\n", $value) : [$value]; + $valueLines = isset($this->paramEncoder) ? explode("\r\n", $value) : [$value]; - // Need to add indices - if (\count($valueLines) > 1) { - $paramLines = []; - foreach ($valueLines as $i => $line) { - $paramLines[] = $name.'*'.$i. - $this->getEndOfParameterValue($line, true, 0 == $i); - } + // Need to add indices + if (\count($valueLines) > 1) { + $paramLines = []; + foreach ($valueLines as $i => $line) { + $paramLines[] = $name.'*'.$i. + $this->getEndOfParameterValue($line, true, 0 == $i); + } - return implode(";\r\n ", $paramLines); - } else { - return $name.$this->getEndOfParameterValue( - $valueLines[0], $encoded, true - ); - } - } + return implode(";\r\n ", $paramLines); + } else { + return $name.$this->getEndOfParameterValue( + $valueLines[0], $encoded, true + ); + } + } - /** - * Returns the parameter value from the "=" and beyond. - * - * @param string $value to append - * @param bool $encoded - * @param bool $firstLine - * - * @return string - */ - private function getEndOfParameterValue($value, $encoded = false, $firstLine = false) - { - if (!preg_match('/^'.self::TOKEN_REGEX.'$/D', $value)) { - $value = '"'.$value.'"'; - } - $prepend = '='; - if ($encoded) { - $prepend = '*='; - if ($firstLine) { - $prepend = '*='.$this->getCharset()."'".$this->getLanguage(). - "'"; - } - } + /** + * Returns the parameter value from the "=" and beyond. + * + * @param string $value to append + * @param bool $encoded + * @param bool $firstLine + * + * @return string + */ + private function getEndOfParameterValue($value, $encoded = false, $firstLine = false) + { + if (!preg_match('/^'.self::TOKEN_REGEX.'$/D', $value)) { + $value = '"'.$value.'"'; + } + $prepend = '='; + if ($encoded) { + $prepend = '*='; + if ($firstLine) { + $prepend = '*='.$this->getCharset()."'".$this->getLanguage(). + "'"; + } + } - return $prepend.$value; - } + return $prepend.$value; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/PathHeader.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/PathHeader.php index 81b421ee7a8..86ab1deaf50 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/PathHeader.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/PathHeader.php @@ -18,136 +18,136 @@ use Egulias\EmailValidator\Validation\RFCValidation; */ class Swift_Mime_Headers_PathHeader extends Swift_Mime_Headers_AbstractHeader { - /** - * The address in this Header (if specified). - * - * @var string - */ - private $address; + /** + * The address in this Header (if specified). + * + * @var string + */ + private $address; - /** - * The strict EmailValidator. - * - * @var EmailValidator - */ - private $emailValidator; + /** + * The strict EmailValidator. + * + * @var EmailValidator + */ + private $emailValidator; - private $addressEncoder; + private $addressEncoder; - /** - * Creates a new PathHeader with the given $name. - * - * @param string $name - */ - public function __construct($name, EmailValidator $emailValidator, Swift_AddressEncoder $addressEncoder = null) - { - $this->setFieldName($name); - $this->emailValidator = $emailValidator; - $this->addressEncoder = $addressEncoder ?? new Swift_AddressEncoder_IdnAddressEncoder(); - } + /** + * Creates a new PathHeader with the given $name. + * + * @param string $name + */ + public function __construct($name, EmailValidator $emailValidator, Swift_AddressEncoder $addressEncoder = null) + { + $this->setFieldName($name); + $this->emailValidator = $emailValidator; + $this->addressEncoder = $addressEncoder ?? new Swift_AddressEncoder_IdnAddressEncoder(); + } - /** - * Get the type of Header that this instance represents. - * - * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX - * @see TYPE_DATE, TYPE_ID, TYPE_PATH - * - * @return int - */ - public function getFieldType() - { - return self::TYPE_PATH; - } + /** + * Get the type of Header that this instance represents. + * + * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX + * @see TYPE_DATE, TYPE_ID, TYPE_PATH + * + * @return int + */ + public function getFieldType() + { + return self::TYPE_PATH; + } - /** - * Set the model for the field body. - * This method takes a string for an address. - * - * @param string $model - * - * @throws Swift_RfcComplianceException - */ - public function setFieldBodyModel($model) - { - $this->setAddress($model); - } + /** + * Set the model for the field body. + * This method takes a string for an address. + * + * @param string $model + * + * @throws Swift_RfcComplianceException + */ + public function setFieldBodyModel($model) + { + $this->setAddress($model); + } - /** - * Get the model for the field body. - * This method returns a string email address. - * - * @return mixed - */ - public function getFieldBodyModel() - { - return $this->getAddress(); - } + /** + * Get the model for the field body. + * This method returns a string email address. + * + * @return mixed + */ + public function getFieldBodyModel() + { + return $this->getAddress(); + } - /** - * Set the Address which should appear in this Header. - * - * @param string $address - * - * @throws Swift_RfcComplianceException - */ - public function setAddress($address) - { - if (null === $address) { - $this->address = null; - } elseif ('' == $address) { - $this->address = ''; - } else { - $this->assertValidAddress($address); - $this->address = $address; - } - $this->setCachedValue(null); - } + /** + * Set the Address which should appear in this Header. + * + * @param string $address + * + * @throws Swift_RfcComplianceException + */ + public function setAddress($address) + { + if (null === $address) { + $this->address = null; + } elseif ('' == $address) { + $this->address = ''; + } else { + $this->assertValidAddress($address); + $this->address = $address; + } + $this->setCachedValue(null); + } - /** - * Get the address which is used in this Header (if any). - * - * Null is returned if no address is set. - * - * @return string - */ - public function getAddress() - { - return $this->address; - } + /** + * Get the address which is used in this Header (if any). + * + * Null is returned if no address is set. + * + * @return string + */ + public function getAddress() + { + return $this->address; + } - /** - * Get the string value of the body in this Header. - * - * This is not necessarily RFC 2822 compliant since folding white space will - * not be added at this stage (see {@link toString()} for that). - * - * @see toString() - * - * @return string - */ - public function getFieldBody() - { - if (!$this->getCachedValue()) { - if (isset($this->address)) { - $address = $this->addressEncoder->encodeString($this->address); - $this->setCachedValue('<'.$address.'>'); - } - } + /** + * Get the string value of the body in this Header. + * + * This is not necessarily RFC 2822 compliant since folding white space will + * not be added at this stage (see {@link toString()} for that). + * + * @see toString() + * + * @return string + */ + public function getFieldBody() + { + if (!$this->getCachedValue()) { + if (isset($this->address)) { + $address = $this->addressEncoder->encodeString($this->address); + $this->setCachedValue('<'.$address.'>'); + } + } - return $this->getCachedValue(); - } + return $this->getCachedValue(); + } - /** - * Throws an Exception if the address passed does not comply with RFC 2822. - * - * @param string $address - * - * @throws Swift_RfcComplianceException If address is invalid - */ - private function assertValidAddress($address) - { - if (!$this->emailValidator->isValid($address, new RFCValidation())) { - throw new Swift_RfcComplianceException('Address set in PathHeader does not comply with addr-spec of RFC 2822.'); - } - } + /** + * Throws an Exception if the address passed does not comply with RFC 2822. + * + * @param string $address + * + * @throws Swift_RfcComplianceException If address is invalid + */ + private function assertValidAddress($address) + { + if (!$this->emailValidator->isValid($address, new RFCValidation())) { + throw new Swift_RfcComplianceException('Address set in PathHeader does not comply with addr-spec of RFC 2822.'); + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/UnstructuredHeader.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/UnstructuredHeader.php index 64f160dec7c..7d51945aabb 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/UnstructuredHeader.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/UnstructuredHeader.php @@ -15,95 +15,95 @@ */ class Swift_Mime_Headers_UnstructuredHeader extends Swift_Mime_Headers_AbstractHeader { - /** - * The value of this Header. - * - * @var string - */ - private $value; + /** + * The value of this Header. + * + * @var string + */ + private $value; - /** - * Creates a new SimpleHeader with $name. - * - * @param string $name - */ - public function __construct($name, Swift_Mime_HeaderEncoder $encoder) - { - $this->setFieldName($name); - $this->setEncoder($encoder); - } + /** + * Creates a new SimpleHeader with $name. + * + * @param string $name + */ + public function __construct($name, Swift_Mime_HeaderEncoder $encoder) + { + $this->setFieldName($name); + $this->setEncoder($encoder); + } - /** - * Get the type of Header that this instance represents. - * - * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX - * @see TYPE_DATE, TYPE_ID, TYPE_PATH - * - * @return int - */ - public function getFieldType() - { - return self::TYPE_TEXT; - } + /** + * Get the type of Header that this instance represents. + * + * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX + * @see TYPE_DATE, TYPE_ID, TYPE_PATH + * + * @return int + */ + public function getFieldType() + { + return self::TYPE_TEXT; + } - /** - * Set the model for the field body. - * - * This method takes a string for the field value. - * - * @param string $model - */ - public function setFieldBodyModel($model) - { - $this->setValue($model); - } + /** + * Set the model for the field body. + * + * This method takes a string for the field value. + * + * @param string $model + */ + public function setFieldBodyModel($model) + { + $this->setValue($model); + } - /** - * Get the model for the field body. - * - * This method returns a string. - * - * @return string - */ - public function getFieldBodyModel() - { - return $this->getValue(); - } + /** + * Get the model for the field body. + * + * This method returns a string. + * + * @return string + */ + public function getFieldBodyModel() + { + return $this->getValue(); + } - /** - * Get the (unencoded) value of this header. - * - * @return string - */ - public function getValue() - { - return $this->value; - } + /** + * Get the (unencoded) value of this header. + * + * @return string + */ + public function getValue() + { + return $this->value; + } - /** - * Set the (unencoded) value of this header. - * - * @param string $value - */ - public function setValue($value) - { - $this->clearCachedValueIf($this->value != $value); - $this->value = $value; - } + /** + * Set the (unencoded) value of this header. + * + * @param string $value + */ + public function setValue($value) + { + $this->clearCachedValueIf($this->value != $value); + $this->value = $value; + } - /** - * Get the value of this header prepared for rendering. - * - * @return string - */ - public function getFieldBody() - { - if (!$this->getCachedValue()) { - $this->setCachedValue( - $this->encodeWords($this, $this->value) - ); - } + /** + * Get the value of this header prepared for rendering. + * + * @return string + */ + public function getFieldBody() + { + if (!$this->getCachedValue()) { + $this->setCachedValue( + $this->encodeWords($this, $this->value) + ); + } - return $this->getCachedValue(); - } + return $this->getCachedValue(); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/IdGenerator.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/IdGenerator.php index 3ce35f27c03..a8fd141a26a 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/IdGenerator.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/IdGenerator.php @@ -13,42 +13,42 @@ */ class Swift_Mime_IdGenerator implements Swift_IdGenerator { - private $idRight; + private $idRight; - /** - * @param string $idRight - */ - public function __construct($idRight) - { - $this->idRight = $idRight; - } + /** + * @param string $idRight + */ + public function __construct($idRight) + { + $this->idRight = $idRight; + } - /** - * Returns the right-hand side of the "@" used in all generated IDs. - * - * @return string - */ - public function getIdRight() - { - return $this->idRight; - } + /** + * Returns the right-hand side of the "@" used in all generated IDs. + * + * @return string + */ + public function getIdRight() + { + return $this->idRight; + } - /** - * Sets the right-hand side of the "@" to use in all generated IDs. - * - * @param string $idRight - */ - public function setIdRight($idRight) - { - $this->idRight = $idRight; - } + /** + * Sets the right-hand side of the "@" to use in all generated IDs. + * + * @param string $idRight + */ + public function setIdRight($idRight) + { + $this->idRight = $idRight; + } - /** - * @return string - */ - public function generateId() - { - // 32 hex values for the left part - return bin2hex(random_bytes(16)).'@'.$this->idRight; - } + /** + * @return string + */ + public function generateId() + { + // 32 hex values for the left part + return bin2hex(random_bytes(16)).'@'.$this->idRight; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/MimePart.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/MimePart.php index d0b2e6586b4..560f5ba64a5 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/MimePart.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/MimePart.php @@ -15,185 +15,185 @@ */ class Swift_Mime_MimePart extends Swift_Mime_SimpleMimeEntity { - /** The format parameter last specified by the user */ - protected $userFormat; + /** The format parameter last specified by the user */ + protected $userFormat; - /** The charset last specified by the user */ - protected $userCharset; + /** The charset last specified by the user */ + protected $userCharset; - /** The delsp parameter last specified by the user */ - protected $userDelSp; + /** The delsp parameter last specified by the user */ + protected $userDelSp; - /** The nesting level of this MimePart */ - private $nestingLevel = self::LEVEL_ALTERNATIVE; + /** The nesting level of this MimePart */ + private $nestingLevel = self::LEVEL_ALTERNATIVE; - /** - * Create a new MimePart with $headers, $encoder and $cache. - * - * @param string $charset - */ - public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator, $charset = null) - { - parent::__construct($headers, $encoder, $cache, $idGenerator); - $this->setContentType('text/plain'); - if (null !== $charset) { - $this->setCharset($charset); - } - } + /** + * Create a new MimePart with $headers, $encoder and $cache. + * + * @param string $charset + */ + public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator, $charset = null) + { + parent::__construct($headers, $encoder, $cache, $idGenerator); + $this->setContentType('text/plain'); + if (null !== $charset) { + $this->setCharset($charset); + } + } - /** - * Set the body of this entity, either as a string, or as an instance of - * {@link Swift_OutputByteStream}. - * - * @param mixed $body - * @param string $contentType optional - * @param string $charset optional - * - * @return $this - */ - public function setBody($body, $contentType = null, $charset = null) - { - if (isset($charset)) { - $this->setCharset($charset); - } - $body = $this->convertString($body); + /** + * Set the body of this entity, either as a string, or as an instance of + * {@link Swift_OutputByteStream}. + * + * @param mixed $body + * @param string $contentType optional + * @param string $charset optional + * + * @return $this + */ + public function setBody($body, $contentType = null, $charset = null) + { + if (isset($charset)) { + $this->setCharset($charset); + } + $body = $this->convertString($body); - parent::setBody($body, $contentType); + parent::setBody($body, $contentType); - return $this; - } + return $this; + } - /** - * Get the character set of this entity. - * - * @return string - */ - public function getCharset() - { - return $this->getHeaderParameter('Content-Type', 'charset'); - } + /** + * Get the character set of this entity. + * + * @return string + */ + public function getCharset() + { + return $this->getHeaderParameter('Content-Type', 'charset'); + } - /** - * Set the character set of this entity. - * - * @param string $charset - * - * @return $this - */ - public function setCharset($charset) - { - $this->setHeaderParameter('Content-Type', 'charset', $charset); - if ($charset !== $this->userCharset) { - $this->clearCache(); - } - $this->userCharset = $charset; - parent::charsetChanged($charset); + /** + * Set the character set of this entity. + * + * @param string $charset + * + * @return $this + */ + public function setCharset($charset) + { + $this->setHeaderParameter('Content-Type', 'charset', $charset); + if ($charset !== $this->userCharset) { + $this->clearCache(); + } + $this->userCharset = $charset; + parent::charsetChanged($charset); - return $this; - } + return $this; + } - /** - * Get the format of this entity (i.e. flowed or fixed). - * - * @return string - */ - public function getFormat() - { - return $this->getHeaderParameter('Content-Type', 'format'); - } + /** + * Get the format of this entity (i.e. flowed or fixed). + * + * @return string + */ + public function getFormat() + { + return $this->getHeaderParameter('Content-Type', 'format'); + } - /** - * Set the format of this entity (flowed or fixed). - * - * @param string $format - * - * @return $this - */ - public function setFormat($format) - { - $this->setHeaderParameter('Content-Type', 'format', $format); - $this->userFormat = $format; + /** + * Set the format of this entity (flowed or fixed). + * + * @param string $format + * + * @return $this + */ + public function setFormat($format) + { + $this->setHeaderParameter('Content-Type', 'format', $format); + $this->userFormat = $format; - return $this; - } + return $this; + } - /** - * Test if delsp is being used for this entity. - * - * @return bool - */ - public function getDelSp() - { - return 'yes' === $this->getHeaderParameter('Content-Type', 'delsp'); - } + /** + * Test if delsp is being used for this entity. + * + * @return bool + */ + public function getDelSp() + { + return 'yes' === $this->getHeaderParameter('Content-Type', 'delsp'); + } - /** - * Turn delsp on or off for this entity. - * - * @param bool $delsp - * - * @return $this - */ - public function setDelSp($delsp = true) - { - $this->setHeaderParameter('Content-Type', 'delsp', $delsp ? 'yes' : null); - $this->userDelSp = $delsp; + /** + * Turn delsp on or off for this entity. + * + * @param bool $delsp + * + * @return $this + */ + public function setDelSp($delsp = true) + { + $this->setHeaderParameter('Content-Type', 'delsp', $delsp ? 'yes' : null); + $this->userDelSp = $delsp; - return $this; - } + return $this; + } - /** - * Get the nesting level of this entity. - * - * @see LEVEL_TOP, LEVEL_ALTERNATIVE, LEVEL_MIXED, LEVEL_RELATED - * - * @return int - */ - public function getNestingLevel() - { - return $this->nestingLevel; - } + /** + * Get the nesting level of this entity. + * + * @see LEVEL_TOP, LEVEL_ALTERNATIVE, LEVEL_MIXED, LEVEL_RELATED + * + * @return int + */ + public function getNestingLevel() + { + return $this->nestingLevel; + } - /** - * Receive notification that the charset has changed on this document, or a - * parent document. - * - * @param string $charset - */ - public function charsetChanged($charset) - { - $this->setCharset($charset); - } + /** + * Receive notification that the charset has changed on this document, or a + * parent document. + * + * @param string $charset + */ + public function charsetChanged($charset) + { + $this->setCharset($charset); + } - /** Fix the content-type and encoding of this entity */ - protected function fixHeaders() - { - parent::fixHeaders(); - if (\count($this->getChildren())) { - $this->setHeaderParameter('Content-Type', 'charset', null); - $this->setHeaderParameter('Content-Type', 'format', null); - $this->setHeaderParameter('Content-Type', 'delsp', null); - } else { - $this->setCharset($this->userCharset); - $this->setFormat($this->userFormat); - $this->setDelSp($this->userDelSp); - } - } + /** Fix the content-type and encoding of this entity */ + protected function fixHeaders() + { + parent::fixHeaders(); + if (\count($this->getChildren())) { + $this->setHeaderParameter('Content-Type', 'charset', null); + $this->setHeaderParameter('Content-Type', 'format', null); + $this->setHeaderParameter('Content-Type', 'delsp', null); + } else { + $this->setCharset($this->userCharset); + $this->setFormat($this->userFormat); + $this->setDelSp($this->userDelSp); + } + } - /** Set the nesting level of this entity */ - protected function setNestingLevel($level) - { - $this->nestingLevel = $level; - } + /** Set the nesting level of this entity */ + protected function setNestingLevel($level) + { + $this->nestingLevel = $level; + } - /** Encode charset when charset is not utf-8 */ - protected function convertString($string) - { - $charset = strtolower($this->getCharset() ?? ''); - if (!\in_array($charset, ['utf-8', 'iso-8859-1', 'iso-8859-15', ''])) { - return mb_convert_encoding($string, $charset, 'utf-8'); - } + /** Encode charset when charset is not utf-8 */ + protected function convertString($string) + { + $charset = strtolower($this->getCharset() ?? ''); + if (!\in_array($charset, ['utf-8', 'iso-8859-1', 'iso-8859-15', ''])) { + return mb_convert_encoding($string, $charset, 'utf-8'); + } - return $string; - } + return $string; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderFactory.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderFactory.php index ab3ce6b1914..347fa74cf66 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderFactory.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderFactory.php @@ -17,179 +17,179 @@ use Egulias\EmailValidator\EmailValidator; */ class Swift_Mime_SimpleHeaderFactory implements Swift_Mime_CharsetObserver { - /** The HeaderEncoder used by these headers */ - private $encoder; + /** The HeaderEncoder used by these headers */ + private $encoder; - /** The Encoder used by parameters */ - private $paramEncoder; + /** The Encoder used by parameters */ + private $paramEncoder; - /** Strict EmailValidator */ - private $emailValidator; + /** Strict EmailValidator */ + private $emailValidator; - /** The charset of created Headers */ - private $charset; + /** The charset of created Headers */ + private $charset; - /** Swift_AddressEncoder */ - private $addressEncoder; + /** Swift_AddressEncoder */ + private $addressEncoder; - /** - * Creates a new SimpleHeaderFactory using $encoder and $paramEncoder. - * - * @param string|null $charset - */ - public function __construct(Swift_Mime_HeaderEncoder $encoder, Swift_Encoder $paramEncoder, EmailValidator $emailValidator, $charset = null, Swift_AddressEncoder $addressEncoder = null) - { - $this->encoder = $encoder; - $this->paramEncoder = $paramEncoder; - $this->emailValidator = $emailValidator; - $this->charset = $charset; - $this->addressEncoder = $addressEncoder ?? new Swift_AddressEncoder_IdnAddressEncoder(); - } + /** + * Creates a new SimpleHeaderFactory using $encoder and $paramEncoder. + * + * @param string|null $charset + */ + public function __construct(Swift_Mime_HeaderEncoder $encoder, Swift_Encoder $paramEncoder, EmailValidator $emailValidator, $charset = null, Swift_AddressEncoder $addressEncoder = null) + { + $this->encoder = $encoder; + $this->paramEncoder = $paramEncoder; + $this->emailValidator = $emailValidator; + $this->charset = $charset; + $this->addressEncoder = $addressEncoder ?? new Swift_AddressEncoder_IdnAddressEncoder(); + } - /** - * Create a new Mailbox Header with a list of $addresses. - * - * @param string $name - * @param array|string|null $addresses - * - * @return Swift_Mime_Header - */ - public function createMailboxHeader($name, $addresses = null) - { - $header = new Swift_Mime_Headers_MailboxHeader($name, $this->encoder, $this->emailValidator, $this->addressEncoder); - if (isset($addresses)) { - $header->setFieldBodyModel($addresses); - } - $this->setHeaderCharset($header); + /** + * Create a new Mailbox Header with a list of $addresses. + * + * @param string $name + * @param array|string|null $addresses + * + * @return Swift_Mime_Header + */ + public function createMailboxHeader($name, $addresses = null) + { + $header = new Swift_Mime_Headers_MailboxHeader($name, $this->encoder, $this->emailValidator, $this->addressEncoder); + if (isset($addresses)) { + $header->setFieldBodyModel($addresses); + } + $this->setHeaderCharset($header); - return $header; - } + return $header; + } - /** - * Create a new Date header using $dateTime. - * - * @param string $name - * - * @return Swift_Mime_Header - */ - public function createDateHeader($name, DateTimeInterface $dateTime = null) - { - $header = new Swift_Mime_Headers_DateHeader($name); - if (isset($dateTime)) { - $header->setFieldBodyModel($dateTime); - } - $this->setHeaderCharset($header); + /** + * Create a new Date header using $dateTime. + * + * @param string $name + * + * @return Swift_Mime_Header + */ + public function createDateHeader($name, DateTimeInterface $dateTime = null) + { + $header = new Swift_Mime_Headers_DateHeader($name); + if (isset($dateTime)) { + $header->setFieldBodyModel($dateTime); + } + $this->setHeaderCharset($header); - return $header; - } + return $header; + } - /** - * Create a new basic text header with $name and $value. - * - * @param string $name - * @param string $value - * - * @return Swift_Mime_Header - */ - public function createTextHeader($name, $value = null) - { - $header = new Swift_Mime_Headers_UnstructuredHeader($name, $this->encoder); - if (isset($value)) { - $header->setFieldBodyModel($value); - } - $this->setHeaderCharset($header); + /** + * Create a new basic text header with $name and $value. + * + * @param string $name + * @param string $value + * + * @return Swift_Mime_Header + */ + public function createTextHeader($name, $value = null) + { + $header = new Swift_Mime_Headers_UnstructuredHeader($name, $this->encoder); + if (isset($value)) { + $header->setFieldBodyModel($value); + } + $this->setHeaderCharset($header); - return $header; - } + return $header; + } - /** - * Create a new ParameterizedHeader with $name, $value and $params. - * - * @param string $name - * @param string $value - * @param array $params - * - * @return Swift_Mime_Headers_ParameterizedHeader - */ - public function createParameterizedHeader($name, $value = null, $params = []) - { - $header = new Swift_Mime_Headers_ParameterizedHeader($name, $this->encoder, ('content-disposition' == strtolower($name ?? '')) ? $this->paramEncoder : null); - if (isset($value)) { - $header->setFieldBodyModel($value); - } - foreach ($params as $k => $v) { - $header->setParameter($k, $v); - } - $this->setHeaderCharset($header); + /** + * Create a new ParameterizedHeader with $name, $value and $params. + * + * @param string $name + * @param string $value + * @param array $params + * + * @return Swift_Mime_Headers_ParameterizedHeader + */ + public function createParameterizedHeader($name, $value = null, $params = []) + { + $header = new Swift_Mime_Headers_ParameterizedHeader($name, $this->encoder, ('content-disposition' == strtolower($name ?? '')) ? $this->paramEncoder : null); + if (isset($value)) { + $header->setFieldBodyModel($value); + } + foreach ($params as $k => $v) { + $header->setParameter($k, $v); + } + $this->setHeaderCharset($header); - return $header; - } + return $header; + } - /** - * Create a new ID header for Message-ID or Content-ID. - * - * @param string $name - * @param string|array $ids - * - * @return Swift_Mime_Header - */ - public function createIdHeader($name, $ids = null) - { - $header = new Swift_Mime_Headers_IdentificationHeader($name, $this->emailValidator); - if (isset($ids)) { - $header->setFieldBodyModel($ids); - } - $this->setHeaderCharset($header); + /** + * Create a new ID header for Message-ID or Content-ID. + * + * @param string $name + * @param string|array $ids + * + * @return Swift_Mime_Header + */ + public function createIdHeader($name, $ids = null) + { + $header = new Swift_Mime_Headers_IdentificationHeader($name, $this->emailValidator); + if (isset($ids)) { + $header->setFieldBodyModel($ids); + } + $this->setHeaderCharset($header); - return $header; - } + return $header; + } - /** - * Create a new Path header with an address (path) in it. - * - * @param string $name - * @param string $path - * - * @return Swift_Mime_Header - */ - public function createPathHeader($name, $path = null) - { - $header = new Swift_Mime_Headers_PathHeader($name, $this->emailValidator); - if (isset($path)) { - $header->setFieldBodyModel($path); - } - $this->setHeaderCharset($header); + /** + * Create a new Path header with an address (path) in it. + * + * @param string $name + * @param string $path + * + * @return Swift_Mime_Header + */ + public function createPathHeader($name, $path = null) + { + $header = new Swift_Mime_Headers_PathHeader($name, $this->emailValidator); + if (isset($path)) { + $header->setFieldBodyModel($path); + } + $this->setHeaderCharset($header); - return $header; - } + return $header; + } - /** - * Notify this observer that the entity's charset has changed. - * - * @param string $charset - */ - public function charsetChanged($charset) - { - $this->charset = $charset; - $this->encoder->charsetChanged($charset); - $this->paramEncoder->charsetChanged($charset); - } + /** + * Notify this observer that the entity's charset has changed. + * + * @param string $charset + */ + public function charsetChanged($charset) + { + $this->charset = $charset; + $this->encoder->charsetChanged($charset); + $this->paramEncoder->charsetChanged($charset); + } - /** - * Make a deep copy of object. - */ - public function __clone() - { - $this->encoder = clone $this->encoder; - $this->paramEncoder = clone $this->paramEncoder; - $this->addressEncoder = clone $this->addressEncoder; - } + /** + * Make a deep copy of object. + */ + public function __clone() + { + $this->encoder = clone $this->encoder; + $this->paramEncoder = clone $this->paramEncoder; + $this->addressEncoder = clone $this->addressEncoder; + } - /** Apply the charset to the Header */ - private function setHeaderCharset(Swift_Mime_Header $header) - { - if (isset($this->charset)) { - $header->setCharset($this->charset); - } - } + /** Apply the charset to the Header */ + private function setHeaderCharset(Swift_Mime_Header $header) + { + if (isset($this->charset)) { + $header->setCharset($this->charset); + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderSet.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderSet.php index 5195bcf48ae..219c46f32ff 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderSet.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderSet.php @@ -15,385 +15,385 @@ */ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_CharsetObserver { - /** HeaderFactory */ - private $factory; + /** HeaderFactory */ + private $factory; - /** Collection of set Headers */ - private $headers = []; + /** Collection of set Headers */ + private $headers = []; - /** Field ordering details */ - private $order = []; + /** Field ordering details */ + private $order = []; - /** List of fields which are required to be displayed */ - private $required = []; + /** List of fields which are required to be displayed */ + private $required = []; - /** The charset used by Headers */ - private $charset; + /** The charset used by Headers */ + private $charset; - /** - * Create a new SimpleHeaderSet with the given $factory. - * - * @param string $charset - */ - public function __construct(Swift_Mime_SimpleHeaderFactory $factory, $charset = null) - { - $this->factory = $factory; - if (isset($charset)) { - $this->setCharset($charset); - } - } + /** + * Create a new SimpleHeaderSet with the given $factory. + * + * @param string $charset + */ + public function __construct(Swift_Mime_SimpleHeaderFactory $factory, $charset = null) + { + $this->factory = $factory; + if (isset($charset)) { + $this->setCharset($charset); + } + } - public function newInstance() - { - return new self($this->factory); - } + public function newInstance() + { + return new self($this->factory); + } - /** - * Set the charset used by these headers. - * - * @param string $charset - */ - public function setCharset($charset) - { - $this->charset = $charset; - $this->factory->charsetChanged($charset); - $this->notifyHeadersOfCharset($charset); - } + /** + * Set the charset used by these headers. + * + * @param string $charset + */ + public function setCharset($charset) + { + $this->charset = $charset; + $this->factory->charsetChanged($charset); + $this->notifyHeadersOfCharset($charset); + } - /** - * Add a new Mailbox Header with a list of $addresses. - * - * @param string $name - * @param array|string $addresses - */ - public function addMailboxHeader($name, $addresses = null) - { - $this->storeHeader($name, $this->factory->createMailboxHeader($name, $addresses)); - } + /** + * Add a new Mailbox Header with a list of $addresses. + * + * @param string $name + * @param array|string $addresses + */ + public function addMailboxHeader($name, $addresses = null) + { + $this->storeHeader($name, $this->factory->createMailboxHeader($name, $addresses)); + } - /** - * Add a new Date header using $dateTime. - * - * @param string $name - */ - public function addDateHeader($name, DateTimeInterface $dateTime = null) - { - $this->storeHeader($name, $this->factory->createDateHeader($name, $dateTime)); - } + /** + * Add a new Date header using $dateTime. + * + * @param string $name + */ + public function addDateHeader($name, DateTimeInterface $dateTime = null) + { + $this->storeHeader($name, $this->factory->createDateHeader($name, $dateTime)); + } - /** - * Add a new basic text header with $name and $value. - * - * @param string $name - * @param string $value - */ - public function addTextHeader($name, $value = null) - { - $this->storeHeader($name, $this->factory->createTextHeader($name, $value)); - } + /** + * Add a new basic text header with $name and $value. + * + * @param string $name + * @param string $value + */ + public function addTextHeader($name, $value = null) + { + $this->storeHeader($name, $this->factory->createTextHeader($name, $value)); + } - /** - * Add a new ParameterizedHeader with $name, $value and $params. - * - * @param string $name - * @param string $value - * @param array $params - */ - public function addParameterizedHeader($name, $value = null, $params = []) - { - $this->storeHeader($name, $this->factory->createParameterizedHeader($name, $value, $params)); - } + /** + * Add a new ParameterizedHeader with $name, $value and $params. + * + * @param string $name + * @param string $value + * @param array $params + */ + public function addParameterizedHeader($name, $value = null, $params = []) + { + $this->storeHeader($name, $this->factory->createParameterizedHeader($name, $value, $params)); + } - /** - * Add a new ID header for Message-ID or Content-ID. - * - * @param string $name - * @param string|array $ids - */ - public function addIdHeader($name, $ids = null) - { - $this->storeHeader($name, $this->factory->createIdHeader($name, $ids)); - } + /** + * Add a new ID header for Message-ID or Content-ID. + * + * @param string $name + * @param string|array $ids + */ + public function addIdHeader($name, $ids = null) + { + $this->storeHeader($name, $this->factory->createIdHeader($name, $ids)); + } - /** - * Add a new Path header with an address (path) in it. - * - * @param string $name - * @param string $path - */ - public function addPathHeader($name, $path = null) - { - $this->storeHeader($name, $this->factory->createPathHeader($name, $path)); - } + /** + * Add a new Path header with an address (path) in it. + * + * @param string $name + * @param string $path + */ + public function addPathHeader($name, $path = null) + { + $this->storeHeader($name, $this->factory->createPathHeader($name, $path)); + } - /** - * Returns true if at least one header with the given $name exists. - * - * If multiple headers match, the actual one may be specified by $index. - * - * @param string $name - * @param int $index - * - * @return bool - */ - public function has($name, $index = 0) - { - $lowerName = strtolower($name ?? ''); + /** + * Returns true if at least one header with the given $name exists. + * + * If multiple headers match, the actual one may be specified by $index. + * + * @param string $name + * @param int $index + * + * @return bool + */ + public function has($name, $index = 0) + { + $lowerName = strtolower($name ?? ''); - if (!\array_key_exists($lowerName, $this->headers)) { - return false; - } + if (!\array_key_exists($lowerName, $this->headers)) { + return false; + } - if (\func_num_args() < 2) { - // index was not specified, so we only need to check that there is at least one header value set - return (bool) \count($this->headers[$lowerName]); - } + if (\func_num_args() < 2) { + // index was not specified, so we only need to check that there is at least one header value set + return (bool) \count($this->headers[$lowerName]); + } - return \array_key_exists($index, $this->headers[$lowerName]); - } + return \array_key_exists($index, $this->headers[$lowerName]); + } - /** - * Set a header in the HeaderSet. - * - * The header may be a previously fetched header via {@link get()} or it may - * be one that has been created separately. - * - * If $index is specified, the header will be inserted into the set at this - * offset. - * - * @param int $index - */ - public function set(Swift_Mime_Header $header, $index = 0) - { - $this->storeHeader($header->getFieldName(), $header, $index); - } + /** + * Set a header in the HeaderSet. + * + * The header may be a previously fetched header via {@link get()} or it may + * be one that has been created separately. + * + * If $index is specified, the header will be inserted into the set at this + * offset. + * + * @param int $index + */ + public function set(Swift_Mime_Header $header, $index = 0) + { + $this->storeHeader($header->getFieldName(), $header, $index); + } - /** - * Get the header with the given $name. - * - * If multiple headers match, the actual one may be specified by $index. - * Returns NULL if none present. - * - * @param string $name - * @param int $index - * - * @return Swift_Mime_Header|null - */ - public function get($name, $index = 0) - { - $name = strtolower($name ?? ''); + /** + * Get the header with the given $name. + * + * If multiple headers match, the actual one may be specified by $index. + * Returns NULL if none present. + * + * @param string $name + * @param int $index + * + * @return Swift_Mime_Header|null + */ + public function get($name, $index = 0) + { + $name = strtolower($name ?? ''); - if (\func_num_args() < 2) { - if ($this->has($name)) { - $values = array_values($this->headers[$name]); + if (\func_num_args() < 2) { + if ($this->has($name)) { + $values = array_values($this->headers[$name]); - return array_shift($values); - } - } else { - if ($this->has($name, $index)) { - return $this->headers[$name][$index]; - } - } - } + return array_shift($values); + } + } else { + if ($this->has($name, $index)) { + return $this->headers[$name][$index]; + } + } + } - /** - * Get all headers with the given $name. - * - * @param string $name - * - * @return array - */ - public function getAll($name = null) - { - if (!isset($name)) { - $headers = []; - foreach ($this->headers as $collection) { - $headers = array_merge($headers, $collection); - } + /** + * Get all headers with the given $name. + * + * @param string $name + * + * @return array + */ + public function getAll($name = null) + { + if (!isset($name)) { + $headers = []; + foreach ($this->headers as $collection) { + $headers = array_merge($headers, $collection); + } - return $headers; - } + return $headers; + } - $lowerName = strtolower($name ?? ''); - if (!\array_key_exists($lowerName, $this->headers)) { - return []; - } + $lowerName = strtolower($name ?? ''); + if (!\array_key_exists($lowerName, $this->headers)) { + return []; + } - return $this->headers[$lowerName]; - } + return $this->headers[$lowerName]; + } - /** - * Return the name of all Headers. - * - * @return array - */ - public function listAll() - { - $headers = $this->headers; - if ($this->canSort()) { - uksort($headers, [$this, 'sortHeaders']); - } + /** + * Return the name of all Headers. + * + * @return array + */ + public function listAll() + { + $headers = $this->headers; + if ($this->canSort()) { + uksort($headers, [$this, 'sortHeaders']); + } - return array_keys($headers); - } + return array_keys($headers); + } - /** - * Remove the header with the given $name if it's set. - * - * If multiple headers match, the actual one may be specified by $index. - * - * @param string $name - * @param int $index - */ - public function remove($name, $index = 0) - { - $lowerName = strtolower($name ?? ''); - unset($this->headers[$lowerName][$index]); - } + /** + * Remove the header with the given $name if it's set. + * + * If multiple headers match, the actual one may be specified by $index. + * + * @param string $name + * @param int $index + */ + public function remove($name, $index = 0) + { + $lowerName = strtolower($name ?? ''); + unset($this->headers[$lowerName][$index]); + } - /** - * Remove all headers with the given $name. - * - * @param string $name - */ - public function removeAll($name) - { - $lowerName = strtolower($name ?? ''); - unset($this->headers[$lowerName]); - } + /** + * Remove all headers with the given $name. + * + * @param string $name + */ + public function removeAll($name) + { + $lowerName = strtolower($name ?? ''); + unset($this->headers[$lowerName]); + } - /** - * Define a list of Header names as an array in the correct order. - * - * These Headers will be output in the given order where present. - */ - public function defineOrdering(array $sequence) - { - $this->order = array_flip(array_map('strtolower', $sequence)); - } + /** + * Define a list of Header names as an array in the correct order. + * + * These Headers will be output in the given order where present. + */ + public function defineOrdering(array $sequence) + { + $this->order = array_flip(array_map('strtolower', $sequence)); + } - /** - * Set a list of header names which must always be displayed when set. - * - * Usually headers without a field value won't be output unless set here. - */ - public function setAlwaysDisplayed(array $names) - { - $this->required = array_flip(array_map('strtolower', $names)); - } + /** + * Set a list of header names which must always be displayed when set. + * + * Usually headers without a field value won't be output unless set here. + */ + public function setAlwaysDisplayed(array $names) + { + $this->required = array_flip(array_map('strtolower', $names)); + } - /** - * Notify this observer that the entity's charset has changed. - * - * @param string $charset - */ - public function charsetChanged($charset) - { - $this->setCharset($charset); - } + /** + * Notify this observer that the entity's charset has changed. + * + * @param string $charset + */ + public function charsetChanged($charset) + { + $this->setCharset($charset); + } - /** - * Returns a string with a representation of all headers. - * - * @return string - */ - public function toString() - { - $string = ''; - $headers = $this->headers; - if ($this->canSort()) { - uksort($headers, [$this, 'sortHeaders']); - } - foreach ($headers as $collection) { - foreach ($collection as $header) { - if ($this->isDisplayed($header) || '' != $header->getFieldBody()) { - $string .= $header->toString(); - } - } - } + /** + * Returns a string with a representation of all headers. + * + * @return string + */ + public function toString() + { + $string = ''; + $headers = $this->headers; + if ($this->canSort()) { + uksort($headers, [$this, 'sortHeaders']); + } + foreach ($headers as $collection) { + foreach ($collection as $header) { + if ($this->isDisplayed($header) || '' != $header->getFieldBody()) { + $string .= $header->toString(); + } + } + } - return $string; - } + return $string; + } - /** - * Returns a string representation of this object. - * - * @return string - * - * @see toString() - */ - public function __toString() - { - return $this->toString(); - } + /** + * Returns a string representation of this object. + * + * @return string + * + * @see toString() + */ + public function __toString() + { + return $this->toString(); + } - /** Save a Header to the internal collection */ - private function storeHeader($name, Swift_Mime_Header $header, $offset = null) - { - if (!isset($this->headers[strtolower($name ?? '')])) { - $this->headers[strtolower($name ?? '')] = []; - } - if (!isset($offset)) { - $this->headers[strtolower($name ?? '')][] = $header; - } else { - $this->headers[strtolower($name ?? '')][$offset] = $header; - } - } + /** Save a Header to the internal collection */ + private function storeHeader($name, Swift_Mime_Header $header, $offset = null) + { + if (!isset($this->headers[strtolower($name ?? '')])) { + $this->headers[strtolower($name ?? '')] = []; + } + if (!isset($offset)) { + $this->headers[strtolower($name ?? '')][] = $header; + } else { + $this->headers[strtolower($name ?? '')][$offset] = $header; + } + } - /** Test if the headers can be sorted */ - private function canSort() - { - return \count($this->order) > 0; - } + /** Test if the headers can be sorted */ + private function canSort() + { + return \count($this->order) > 0; + } - /** uksort() algorithm for Header ordering */ - private function sortHeaders($a, $b) - { - $lowerA = strtolower($a ?? ''); - $lowerB = strtolower($b ?? ''); - $aPos = \array_key_exists($lowerA, $this->order) ? $this->order[$lowerA] : -1; - $bPos = \array_key_exists($lowerB, $this->order) ? $this->order[$lowerB] : -1; + /** uksort() algorithm for Header ordering */ + private function sortHeaders($a, $b) + { + $lowerA = strtolower($a ?? ''); + $lowerB = strtolower($b ?? ''); + $aPos = \array_key_exists($lowerA, $this->order) ? $this->order[$lowerA] : -1; + $bPos = \array_key_exists($lowerB, $this->order) ? $this->order[$lowerB] : -1; - if (-1 === $aPos && -1 === $bPos) { - // just be sure to be determinist here - return $a > $b ? -1 : 1; - } + if (-1 === $aPos && -1 === $bPos) { + // just be sure to be determinist here + return $a > $b ? -1 : 1; + } - if (-1 == $aPos) { - return 1; - } elseif (-1 == $bPos) { - return -1; - } + if (-1 == $aPos) { + return 1; + } elseif (-1 == $bPos) { + return -1; + } - return $aPos < $bPos ? -1 : 1; - } + return $aPos < $bPos ? -1 : 1; + } - /** Test if the given Header is always displayed */ - private function isDisplayed(Swift_Mime_Header $header) - { - return \array_key_exists(strtolower($header->getFieldName() ?? ''), $this->required); - } + /** Test if the given Header is always displayed */ + private function isDisplayed(Swift_Mime_Header $header) + { + return \array_key_exists(strtolower($header->getFieldName() ?? ''), $this->required); + } - /** Notify all Headers of the new charset */ - private function notifyHeadersOfCharset($charset) - { - foreach ($this->headers as $headerGroup) { - foreach ($headerGroup as $header) { - $header->setCharset($charset); - } - } - } + /** Notify all Headers of the new charset */ + private function notifyHeadersOfCharset($charset) + { + foreach ($this->headers as $headerGroup) { + foreach ($headerGroup as $header) { + $header->setCharset($charset); + } + } + } - /** - * Make a deep copy of object. - */ - public function __clone() - { - $this->factory = clone $this->factory; - foreach ($this->headers as $groupKey => $headerGroup) { - foreach ($headerGroup as $key => $header) { - $this->headers[$groupKey][$key] = clone $header; - } - } - } + /** + * Make a deep copy of object. + */ + public function __clone() + { + $this->factory = clone $this->factory; + foreach ($this->headers as $groupKey => $headerGroup) { + foreach ($headerGroup as $key => $header) { + $this->headers[$groupKey][$key] = clone $header; + } + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleMessage.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleMessage.php index 62da1650a7b..1f87ce06452 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleMessage.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleMessage.php @@ -15,628 +15,628 @@ */ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart { - const PRIORITY_HIGHEST = 1; - const PRIORITY_HIGH = 2; - const PRIORITY_NORMAL = 3; - const PRIORITY_LOW = 4; - const PRIORITY_LOWEST = 5; - - /** - * Create a new SimpleMessage with $headers, $encoder and $cache. - * - * @param string $charset - */ - public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator, $charset = null) - { - parent::__construct($headers, $encoder, $cache, $idGenerator, $charset); - $this->getHeaders()->defineOrdering([ - 'Return-Path', - 'Received', - 'DKIM-Signature', - 'DomainKey-Signature', - 'Sender', - 'Message-ID', - 'Date', - 'Subject', - 'From', - 'Reply-To', - 'To', - 'Cc', - 'Bcc', - 'MIME-Version', - 'Content-Type', - 'Content-Transfer-Encoding', - ]); - $this->getHeaders()->setAlwaysDisplayed(['Date', 'Message-ID', 'From']); - $this->getHeaders()->addTextHeader('MIME-Version', '1.0'); - $this->setDate(new DateTimeImmutable()); - $this->setId($this->getId()); - $this->getHeaders()->addMailboxHeader('From'); - } - - /** - * Always returns {@link LEVEL_TOP} for a message instance. - * - * @return int - */ - public function getNestingLevel() - { - return self::LEVEL_TOP; - } - - /** - * Set the subject of this message. - * - * @param string $subject - * - * @return $this - */ - public function setSubject($subject) - { - if (!$this->setHeaderFieldModel('Subject', $subject)) { - $this->getHeaders()->addTextHeader('Subject', $subject); - } - - return $this; - } - - /** - * Get the subject of this message. - * - * @return string - */ - public function getSubject() - { - return $this->getHeaderFieldModel('Subject'); - } - - /** - * Set the date at which this message was created. - * - * @return $this - */ - public function setDate(DateTimeInterface $dateTime) - { - if (!$this->setHeaderFieldModel('Date', $dateTime)) { - $this->getHeaders()->addDateHeader('Date', $dateTime); - } - - return $this; - } - - /** - * Get the date at which this message was created. - * - * @return DateTimeInterface - */ - public function getDate() - { - return $this->getHeaderFieldModel('Date'); - } - - /** - * Set the return-path (the bounce address) of this message. - * - * @param string $address - * - * @return $this - */ - public function setReturnPath($address) - { - if (!$this->setHeaderFieldModel('Return-Path', $address)) { - $this->getHeaders()->addPathHeader('Return-Path', $address); - } - - return $this; - } - - /** - * Get the return-path (bounce address) of this message. - * - * @return string - */ - public function getReturnPath() - { - return $this->getHeaderFieldModel('Return-Path'); - } - - /** - * Set the sender of this message. - * - * This does not override the From field, but it has a higher significance. - * - * @param string $address - * @param string $name optional - * - * @return $this - */ - public function setSender($address, $name = null) - { - if (!\is_array($address) && isset($name)) { - $address = [$address => $name]; - } - - if (!$this->setHeaderFieldModel('Sender', (array) $address)) { - $this->getHeaders()->addMailboxHeader('Sender', (array) $address); - } - - return $this; - } - - /** - * Get the sender of this message. - * - * @return string - */ - public function getSender() - { - return $this->getHeaderFieldModel('Sender'); - } - - /** - * Add a From: address to this message. - * - * If $name is passed this name will be associated with the address. - * - * @param string $address - * @param string $name optional - * - * @return $this - */ - public function addFrom($address, $name = null) - { - $current = $this->getFrom(); - $current[$address] = $name; - - return $this->setFrom($current); - } - - /** - * Set the from address of this message. - * - * You may pass an array of addresses if this message is from multiple people. - * - * If $name is passed and the first parameter is a string, this name will be - * associated with the address. - * - * @param string|array $addresses - * @param string $name optional - * - * @return $this - */ - public function setFrom($addresses, $name = null) - { - if (!\is_array($addresses) && isset($name)) { - $addresses = [$addresses => $name]; - } - - if (!$this->setHeaderFieldModel('From', (array) $addresses)) { - $this->getHeaders()->addMailboxHeader('From', (array) $addresses); - } - - return $this; - } - - /** - * Get the from address of this message. - * - * @return mixed - */ - public function getFrom() - { - return $this->getHeaderFieldModel('From'); - } - - /** - * Add a Reply-To: address to this message. - * - * If $name is passed this name will be associated with the address. - * - * @param string $address - * @param string $name optional - * - * @return $this - */ - public function addReplyTo($address, $name = null) - { - $current = $this->getReplyTo(); - $current[$address] = $name; - - return $this->setReplyTo($current); - } - - /** - * Set the reply-to address of this message. - * - * You may pass an array of addresses if replies will go to multiple people. - * - * If $name is passed and the first parameter is a string, this name will be - * associated with the address. - * - * @param mixed $addresses - * @param string $name optional - * - * @return $this - */ - public function setReplyTo($addresses, $name = null) - { - if (!\is_array($addresses) && isset($name)) { - $addresses = [$addresses => $name]; - } - - if (!$this->setHeaderFieldModel('Reply-To', (array) $addresses)) { - $this->getHeaders()->addMailboxHeader('Reply-To', (array) $addresses); - } - - return $this; - } - - /** - * Get the reply-to address of this message. - * - * @return string - */ - public function getReplyTo() - { - return $this->getHeaderFieldModel('Reply-To'); - } - - /** - * Add a To: address to this message. - * - * If $name is passed this name will be associated with the address. - * - * @param string $address - * @param string $name optional - * - * @return $this - */ - public function addTo($address, $name = null) - { - $current = $this->getTo(); - $current[$address] = $name; - - return $this->setTo($current); - } - - /** - * Set the to addresses of this message. - * - * If multiple recipients will receive the message an array should be used. - * Example: array('receiver@domain.org', 'other@domain.org' => 'A name') - * - * If $name is passed and the first parameter is a string, this name will be - * associated with the address. - * - * @param mixed $addresses - * @param string $name optional - * - * @return $this - */ - public function setTo($addresses, $name = null) - { - if (!\is_array($addresses) && isset($name)) { - $addresses = [$addresses => $name]; - } - - if (!$this->setHeaderFieldModel('To', (array) $addresses)) { - $this->getHeaders()->addMailboxHeader('To', (array) $addresses); - } - - return $this; - } - - /** - * Get the To addresses of this message. - * - * @return array - */ - public function getTo() - { - return $this->getHeaderFieldModel('To'); - } - - /** - * Add a Cc: address to this message. - * - * If $name is passed this name will be associated with the address. - * - * @param string $address - * @param string $name optional - * - * @return $this - */ - public function addCc($address, $name = null) - { - $current = $this->getCc(); - $current[$address] = $name; - - return $this->setCc($current); - } - - /** - * Set the Cc addresses of this message. - * - * If $name is passed and the first parameter is a string, this name will be - * associated with the address. - * - * @param mixed $addresses - * @param string $name optional - * - * @return $this - */ - public function setCc($addresses, $name = null) - { - if (!\is_array($addresses) && isset($name)) { - $addresses = [$addresses => $name]; - } - - if (!$this->setHeaderFieldModel('Cc', (array) $addresses)) { - $this->getHeaders()->addMailboxHeader('Cc', (array) $addresses); - } - - return $this; - } - - /** - * Get the Cc address of this message. - * - * @return array - */ - public function getCc() - { - return $this->getHeaderFieldModel('Cc'); - } - - /** - * Add a Bcc: address to this message. - * - * If $name is passed this name will be associated with the address. - * - * @param string $address - * @param string $name optional - * - * @return $this - */ - public function addBcc($address, $name = null) - { - $current = $this->getBcc(); - $current[$address] = $name; - - return $this->setBcc($current); - } - - /** - * Set the Bcc addresses of this message. - * - * If $name is passed and the first parameter is a string, this name will be - * associated with the address. - * - * @param mixed $addresses - * @param string $name optional - * - * @return $this - */ - public function setBcc($addresses, $name = null) - { - if (!\is_array($addresses) && isset($name)) { - $addresses = [$addresses => $name]; - } - - if (!$this->setHeaderFieldModel('Bcc', (array) $addresses)) { - $this->getHeaders()->addMailboxHeader('Bcc', (array) $addresses); - } - - return $this; - } - - /** - * Get the Bcc addresses of this message. - * - * @return array - */ - public function getBcc() - { - return $this->getHeaderFieldModel('Bcc'); - } - - /** - * Set the priority of this message. - * - * The value is an integer where 1 is the highest priority and 5 is the lowest. - * - * @param int $priority - * - * @return $this - */ - public function setPriority($priority) - { - $priorityMap = [ - self::PRIORITY_HIGHEST => 'Highest', - self::PRIORITY_HIGH => 'High', - self::PRIORITY_NORMAL => 'Normal', - self::PRIORITY_LOW => 'Low', - self::PRIORITY_LOWEST => 'Lowest', - ]; - $pMapKeys = array_keys($priorityMap); - if ($priority > max($pMapKeys)) { - $priority = max($pMapKeys); - } elseif ($priority < min($pMapKeys)) { - $priority = min($pMapKeys); - } - if (!$this->setHeaderFieldModel('X-Priority', - sprintf('%d (%s)', $priority, $priorityMap[$priority]))) { - $this->getHeaders()->addTextHeader('X-Priority', - sprintf('%d (%s)', $priority, $priorityMap[$priority])); - } - - return $this; - } - - /** - * Get the priority of this message. - * - * The returned value is an integer where 1 is the highest priority and 5 - * is the lowest. - * - * @return int - */ - public function getPriority() - { - list($priority) = sscanf($this->getHeaderFieldModel('X-Priority'), - '%[1-5]' - ); - - return $priority ?? 3; - } - - /** - * Ask for a delivery receipt from the recipient to be sent to $addresses. - * - * @param array $addresses - * - * @return $this - */ - public function setReadReceiptTo($addresses) - { - if (!$this->setHeaderFieldModel('Disposition-Notification-To', $addresses)) { - $this->getHeaders() - ->addMailboxHeader('Disposition-Notification-To', $addresses); - } - - return $this; - } - - /** - * Get the addresses to which a read-receipt will be sent. - * - * @return string - */ - public function getReadReceiptTo() - { - return $this->getHeaderFieldModel('Disposition-Notification-To'); - } - - /** - * Attach a {@link Swift_Mime_SimpleMimeEntity} such as an Attachment or MimePart. - * - * @return $this - */ - public function attach(Swift_Mime_SimpleMimeEntity $entity) - { - $this->setChildren(array_merge($this->getChildren(), [$entity])); - - return $this; - } - - /** - * Remove an already attached entity. - * - * @return $this - */ - public function detach(Swift_Mime_SimpleMimeEntity $entity) - { - $newChildren = []; - foreach ($this->getChildren() as $child) { - if ($entity !== $child) { - $newChildren[] = $child; - } - } - $this->setChildren($newChildren); - - return $this; - } - - /** - * Attach a {@link Swift_Mime_SimpleMimeEntity} and return it's CID source. - * - * This method should be used when embedding images or other data in a message. - * - * @return string - */ - public function embed(Swift_Mime_SimpleMimeEntity $entity) - { - $this->attach($entity); - - return 'cid:'.$entity->getId(); - } - - /** - * Get this message as a complete string. - * - * @return string - */ - public function toString() - { - if (\count($children = $this->getChildren()) > 0 && '' != $this->getBody()) { - $this->setChildren(array_merge([$this->becomeMimePart()], $children)); - $string = parent::toString(); - $this->setChildren($children); - } else { - $string = parent::toString(); - } - - return $string; - } - - /** - * Returns a string representation of this object. - * - * @see toString() - * - * @return string - */ - public function __toString() - { - return $this->toString(); - } - - /** - * Write this message to a {@link Swift_InputByteStream}. - */ - public function toByteStream(Swift_InputByteStream $is) - { - if (\count($children = $this->getChildren()) > 0 && '' != $this->getBody()) { - $this->setChildren(array_merge([$this->becomeMimePart()], $children)); - parent::toByteStream($is); - $this->setChildren($children); - } else { - parent::toByteStream($is); - } - } - - /** @see Swift_Mime_SimpleMimeEntity::getIdField() */ - protected function getIdField() - { - return 'Message-ID'; - } - - /** Turn the body of this message into a child of itself if needed */ - protected function becomeMimePart() - { - $part = new parent($this->getHeaders()->newInstance(), $this->getEncoder(), - $this->getCache(), $this->getIdGenerator(), $this->userCharset - ); - $part->setContentType($this->userContentType); - $part->setBody($this->getBody()); - $part->setFormat($this->userFormat); - $part->setDelSp($this->userDelSp); - $part->setNestingLevel($this->getTopNestingLevel()); - - return $part; - } - - /** Get the highest nesting level nested inside this message */ - private function getTopNestingLevel() - { - $highestLevel = $this->getNestingLevel(); - foreach ($this->getChildren() as $child) { - $childLevel = $child->getNestingLevel(); - if ($highestLevel < $childLevel) { - $highestLevel = $childLevel; - } - } - - return $highestLevel; - } + const PRIORITY_HIGHEST = 1; + const PRIORITY_HIGH = 2; + const PRIORITY_NORMAL = 3; + const PRIORITY_LOW = 4; + const PRIORITY_LOWEST = 5; + + /** + * Create a new SimpleMessage with $headers, $encoder and $cache. + * + * @param string $charset + */ + public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator, $charset = null) + { + parent::__construct($headers, $encoder, $cache, $idGenerator, $charset); + $this->getHeaders()->defineOrdering([ + 'Return-Path', + 'Received', + 'DKIM-Signature', + 'DomainKey-Signature', + 'Sender', + 'Message-ID', + 'Date', + 'Subject', + 'From', + 'Reply-To', + 'To', + 'Cc', + 'Bcc', + 'MIME-Version', + 'Content-Type', + 'Content-Transfer-Encoding', + ]); + $this->getHeaders()->setAlwaysDisplayed(['Date', 'Message-ID', 'From']); + $this->getHeaders()->addTextHeader('MIME-Version', '1.0'); + $this->setDate(new DateTimeImmutable()); + $this->setId($this->getId()); + $this->getHeaders()->addMailboxHeader('From'); + } + + /** + * Always returns {@link LEVEL_TOP} for a message instance. + * + * @return int + */ + public function getNestingLevel() + { + return self::LEVEL_TOP; + } + + /** + * Set the subject of this message. + * + * @param string $subject + * + * @return $this + */ + public function setSubject($subject) + { + if (!$this->setHeaderFieldModel('Subject', $subject)) { + $this->getHeaders()->addTextHeader('Subject', $subject); + } + + return $this; + } + + /** + * Get the subject of this message. + * + * @return string + */ + public function getSubject() + { + return $this->getHeaderFieldModel('Subject'); + } + + /** + * Set the date at which this message was created. + * + * @return $this + */ + public function setDate(DateTimeInterface $dateTime) + { + if (!$this->setHeaderFieldModel('Date', $dateTime)) { + $this->getHeaders()->addDateHeader('Date', $dateTime); + } + + return $this; + } + + /** + * Get the date at which this message was created. + * + * @return DateTimeInterface + */ + public function getDate() + { + return $this->getHeaderFieldModel('Date'); + } + + /** + * Set the return-path (the bounce address) of this message. + * + * @param string $address + * + * @return $this + */ + public function setReturnPath($address) + { + if (!$this->setHeaderFieldModel('Return-Path', $address)) { + $this->getHeaders()->addPathHeader('Return-Path', $address); + } + + return $this; + } + + /** + * Get the return-path (bounce address) of this message. + * + * @return string + */ + public function getReturnPath() + { + return $this->getHeaderFieldModel('Return-Path'); + } + + /** + * Set the sender of this message. + * + * This does not override the From field, but it has a higher significance. + * + * @param string $address + * @param string $name optional + * + * @return $this + */ + public function setSender($address, $name = null) + { + if (!\is_array($address) && isset($name)) { + $address = [$address => $name]; + } + + if (!$this->setHeaderFieldModel('Sender', (array) $address)) { + $this->getHeaders()->addMailboxHeader('Sender', (array) $address); + } + + return $this; + } + + /** + * Get the sender of this message. + * + * @return string + */ + public function getSender() + { + return $this->getHeaderFieldModel('Sender'); + } + + /** + * Add a From: address to this message. + * + * If $name is passed this name will be associated with the address. + * + * @param string $address + * @param string $name optional + * + * @return $this + */ + public function addFrom($address, $name = null) + { + $current = $this->getFrom(); + $current[$address] = $name; + + return $this->setFrom($current); + } + + /** + * Set the from address of this message. + * + * You may pass an array of addresses if this message is from multiple people. + * + * If $name is passed and the first parameter is a string, this name will be + * associated with the address. + * + * @param string|array $addresses + * @param string $name optional + * + * @return $this + */ + public function setFrom($addresses, $name = null) + { + if (!\is_array($addresses) && isset($name)) { + $addresses = [$addresses => $name]; + } + + if (!$this->setHeaderFieldModel('From', (array) $addresses)) { + $this->getHeaders()->addMailboxHeader('From', (array) $addresses); + } + + return $this; + } + + /** + * Get the from address of this message. + * + * @return mixed + */ + public function getFrom() + { + return $this->getHeaderFieldModel('From'); + } + + /** + * Add a Reply-To: address to this message. + * + * If $name is passed this name will be associated with the address. + * + * @param string $address + * @param string $name optional + * + * @return $this + */ + public function addReplyTo($address, $name = null) + { + $current = $this->getReplyTo(); + $current[$address] = $name; + + return $this->setReplyTo($current); + } + + /** + * Set the reply-to address of this message. + * + * You may pass an array of addresses if replies will go to multiple people. + * + * If $name is passed and the first parameter is a string, this name will be + * associated with the address. + * + * @param mixed $addresses + * @param string $name optional + * + * @return $this + */ + public function setReplyTo($addresses, $name = null) + { + if (!\is_array($addresses) && isset($name)) { + $addresses = [$addresses => $name]; + } + + if (!$this->setHeaderFieldModel('Reply-To', (array) $addresses)) { + $this->getHeaders()->addMailboxHeader('Reply-To', (array) $addresses); + } + + return $this; + } + + /** + * Get the reply-to address of this message. + * + * @return string + */ + public function getReplyTo() + { + return $this->getHeaderFieldModel('Reply-To'); + } + + /** + * Add a To: address to this message. + * + * If $name is passed this name will be associated with the address. + * + * @param string $address + * @param string $name optional + * + * @return $this + */ + public function addTo($address, $name = null) + { + $current = $this->getTo(); + $current[$address] = $name; + + return $this->setTo($current); + } + + /** + * Set the to addresses of this message. + * + * If multiple recipients will receive the message an array should be used. + * Example: array('receiver@domain.org', 'other@domain.org' => 'A name') + * + * If $name is passed and the first parameter is a string, this name will be + * associated with the address. + * + * @param mixed $addresses + * @param string $name optional + * + * @return $this + */ + public function setTo($addresses, $name = null) + { + if (!\is_array($addresses) && isset($name)) { + $addresses = [$addresses => $name]; + } + + if (!$this->setHeaderFieldModel('To', (array) $addresses)) { + $this->getHeaders()->addMailboxHeader('To', (array) $addresses); + } + + return $this; + } + + /** + * Get the To addresses of this message. + * + * @return array + */ + public function getTo() + { + return $this->getHeaderFieldModel('To'); + } + + /** + * Add a Cc: address to this message. + * + * If $name is passed this name will be associated with the address. + * + * @param string $address + * @param string $name optional + * + * @return $this + */ + public function addCc($address, $name = null) + { + $current = $this->getCc(); + $current[$address] = $name; + + return $this->setCc($current); + } + + /** + * Set the Cc addresses of this message. + * + * If $name is passed and the first parameter is a string, this name will be + * associated with the address. + * + * @param mixed $addresses + * @param string $name optional + * + * @return $this + */ + public function setCc($addresses, $name = null) + { + if (!\is_array($addresses) && isset($name)) { + $addresses = [$addresses => $name]; + } + + if (!$this->setHeaderFieldModel('Cc', (array) $addresses)) { + $this->getHeaders()->addMailboxHeader('Cc', (array) $addresses); + } + + return $this; + } + + /** + * Get the Cc address of this message. + * + * @return array + */ + public function getCc() + { + return $this->getHeaderFieldModel('Cc'); + } + + /** + * Add a Bcc: address to this message. + * + * If $name is passed this name will be associated with the address. + * + * @param string $address + * @param string $name optional + * + * @return $this + */ + public function addBcc($address, $name = null) + { + $current = $this->getBcc(); + $current[$address] = $name; + + return $this->setBcc($current); + } + + /** + * Set the Bcc addresses of this message. + * + * If $name is passed and the first parameter is a string, this name will be + * associated with the address. + * + * @param mixed $addresses + * @param string $name optional + * + * @return $this + */ + public function setBcc($addresses, $name = null) + { + if (!\is_array($addresses) && isset($name)) { + $addresses = [$addresses => $name]; + } + + if (!$this->setHeaderFieldModel('Bcc', (array) $addresses)) { + $this->getHeaders()->addMailboxHeader('Bcc', (array) $addresses); + } + + return $this; + } + + /** + * Get the Bcc addresses of this message. + * + * @return array + */ + public function getBcc() + { + return $this->getHeaderFieldModel('Bcc'); + } + + /** + * Set the priority of this message. + * + * The value is an integer where 1 is the highest priority and 5 is the lowest. + * + * @param int $priority + * + * @return $this + */ + public function setPriority($priority) + { + $priorityMap = [ + self::PRIORITY_HIGHEST => 'Highest', + self::PRIORITY_HIGH => 'High', + self::PRIORITY_NORMAL => 'Normal', + self::PRIORITY_LOW => 'Low', + self::PRIORITY_LOWEST => 'Lowest', + ]; + $pMapKeys = array_keys($priorityMap); + if ($priority > max($pMapKeys)) { + $priority = max($pMapKeys); + } elseif ($priority < min($pMapKeys)) { + $priority = min($pMapKeys); + } + if (!$this->setHeaderFieldModel('X-Priority', + sprintf('%d (%s)', $priority, $priorityMap[$priority]))) { + $this->getHeaders()->addTextHeader('X-Priority', + sprintf('%d (%s)', $priority, $priorityMap[$priority])); + } + + return $this; + } + + /** + * Get the priority of this message. + * + * The returned value is an integer where 1 is the highest priority and 5 + * is the lowest. + * + * @return int + */ + public function getPriority() + { + list($priority) = sscanf($this->getHeaderFieldModel('X-Priority'), + '%[1-5]' + ); + + return $priority ?? 3; + } + + /** + * Ask for a delivery receipt from the recipient to be sent to $addresses. + * + * @param array $addresses + * + * @return $this + */ + public function setReadReceiptTo($addresses) + { + if (!$this->setHeaderFieldModel('Disposition-Notification-To', $addresses)) { + $this->getHeaders() + ->addMailboxHeader('Disposition-Notification-To', $addresses); + } + + return $this; + } + + /** + * Get the addresses to which a read-receipt will be sent. + * + * @return string + */ + public function getReadReceiptTo() + { + return $this->getHeaderFieldModel('Disposition-Notification-To'); + } + + /** + * Attach a {@link Swift_Mime_SimpleMimeEntity} such as an Attachment or MimePart. + * + * @return $this + */ + public function attach(Swift_Mime_SimpleMimeEntity $entity) + { + $this->setChildren(array_merge($this->getChildren(), [$entity])); + + return $this; + } + + /** + * Remove an already attached entity. + * + * @return $this + */ + public function detach(Swift_Mime_SimpleMimeEntity $entity) + { + $newChildren = []; + foreach ($this->getChildren() as $child) { + if ($entity !== $child) { + $newChildren[] = $child; + } + } + $this->setChildren($newChildren); + + return $this; + } + + /** + * Attach a {@link Swift_Mime_SimpleMimeEntity} and return it's CID source. + * + * This method should be used when embedding images or other data in a message. + * + * @return string + */ + public function embed(Swift_Mime_SimpleMimeEntity $entity) + { + $this->attach($entity); + + return 'cid:'.$entity->getId(); + } + + /** + * Get this message as a complete string. + * + * @return string + */ + public function toString() + { + if (\count($children = $this->getChildren()) > 0 && '' != $this->getBody()) { + $this->setChildren(array_merge([$this->becomeMimePart()], $children)); + $string = parent::toString(); + $this->setChildren($children); + } else { + $string = parent::toString(); + } + + return $string; + } + + /** + * Returns a string representation of this object. + * + * @see toString() + * + * @return string + */ + public function __toString() + { + return $this->toString(); + } + + /** + * Write this message to a {@link Swift_InputByteStream}. + */ + public function toByteStream(Swift_InputByteStream $is) + { + if (\count($children = $this->getChildren()) > 0 && '' != $this->getBody()) { + $this->setChildren(array_merge([$this->becomeMimePart()], $children)); + parent::toByteStream($is); + $this->setChildren($children); + } else { + parent::toByteStream($is); + } + } + + /** @see Swift_Mime_SimpleMimeEntity::getIdField() */ + protected function getIdField() + { + return 'Message-ID'; + } + + /** Turn the body of this message into a child of itself if needed */ + protected function becomeMimePart() + { + $part = new parent($this->getHeaders()->newInstance(), $this->getEncoder(), + $this->getCache(), $this->getIdGenerator(), $this->userCharset + ); + $part->setContentType($this->userContentType); + $part->setBody($this->getBody()); + $part->setFormat($this->userFormat); + $part->setDelSp($this->userDelSp); + $part->setNestingLevel($this->getTopNestingLevel()); + + return $part; + } + + /** Get the highest nesting level nested inside this message */ + private function getTopNestingLevel() + { + $highestLevel = $this->getNestingLevel(); + foreach ($this->getChildren() as $child) { + $childLevel = $child->getNestingLevel(); + if ($highestLevel < $childLevel) { + $highestLevel = $childLevel; + } + } + + return $highestLevel; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php index 03eaf472dd5..668d076fb32 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php @@ -15,812 +15,812 @@ */ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_Mime_EncodingObserver { - /** Main message document; there can only be one of these */ - const LEVEL_TOP = 16; - - /** An entity which nests with the same precedence as an attachment */ - const LEVEL_MIXED = 256; - - /** An entity which nests with the same precedence as a mime part */ - const LEVEL_ALTERNATIVE = 4096; - - /** An entity which nests with the same precedence as embedded content */ - const LEVEL_RELATED = 65536; - - /** A collection of Headers for this mime entity */ - private $headers; - - /** The body as a string, or a stream */ - private $body; - - /** The encoder that encodes the body into a streamable format */ - private $encoder; - - /** Message ID generator */ - private $idGenerator; - - /** A mime boundary, if any is used */ - private $boundary; - - /** Mime types to be used based on the nesting level */ - private $compositeRanges = [ - 'multipart/mixed' => [self::LEVEL_TOP, self::LEVEL_MIXED], - 'multipart/alternative' => [self::LEVEL_MIXED, self::LEVEL_ALTERNATIVE], - 'multipart/related' => [self::LEVEL_ALTERNATIVE, self::LEVEL_RELATED], - ]; - - /** A set of filter rules to define what level an entity should be nested at */ - private $compoundLevelFilters = []; - - /** The nesting level of this entity */ - private $nestingLevel = self::LEVEL_ALTERNATIVE; - - /** A KeyCache instance used during encoding and streaming */ - private $cache; - - /** Direct descendants of this entity */ - private $immediateChildren = []; - - /** All descendants of this entity */ - private $children = []; - - /** The maximum line length of the body of this entity */ - private $maxLineLength = 78; - - /** The order in which alternative mime types should appear */ - private $alternativePartOrder = [ - 'text/plain' => 1, - 'text/html' => 2, - 'multipart/related' => 3, - ]; - - /** The CID of this entity */ - private $id; - - /** The key used for accessing the cache */ - private $cacheKey; - - protected $userContentType; - - /** - * Create a new SimpleMimeEntity with $headers, $encoder and $cache. - */ - public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator) - { - $this->cacheKey = bin2hex(random_bytes(16)); // set 32 hex values - $this->cache = $cache; - $this->headers = $headers; - $this->idGenerator = $idGenerator; - $this->setEncoder($encoder); - $this->headers->defineOrdering(['Content-Type', 'Content-Transfer-Encoding']); - - // This array specifies that, when the entire MIME document contains - // $compoundLevel, then for each child within $level, if its Content-Type - // is $contentType then it should be treated as if it's level is - // $neededLevel instead. I tried to write that unambiguously! :-\ - // Data Structure: - // array ( - // $compoundLevel => array( - // $level => array( - // $contentType => $neededLevel - // ) - // ) - // ) - - $this->compoundLevelFilters = [ - (self::LEVEL_ALTERNATIVE + self::LEVEL_RELATED) => [ - self::LEVEL_ALTERNATIVE => [ - 'text/plain' => self::LEVEL_ALTERNATIVE, - 'text/html' => self::LEVEL_RELATED, - ], - ], - ]; - - $this->id = $this->idGenerator->generateId(); - } - - /** - * Generate a new Content-ID or Message-ID for this MIME entity. - * - * @return string - */ - public function generateId() - { - $this->setId($this->idGenerator->generateId()); - - return $this->id; - } - - /** - * Get the {@link Swift_Mime_SimpleHeaderSet} for this entity. - * - * @return Swift_Mime_SimpleHeaderSet - */ - public function getHeaders() - { - return $this->headers; - } - - /** - * Get the nesting level of this entity. - * - * @see LEVEL_TOP, LEVEL_MIXED, LEVEL_RELATED, LEVEL_ALTERNATIVE - * - * @return int - */ - public function getNestingLevel() - { - return $this->nestingLevel; - } - - /** - * Get the Content-type of this entity. - * - * @return string - */ - public function getContentType() - { - return $this->getHeaderFieldModel('Content-Type'); - } - - /** - * Get the Body Content-type of this entity. - * - * @return string - */ - public function getBodyContentType() - { - return $this->userContentType; - } - - /** - * Set the Content-type of this entity. - * - * @param string $type - * - * @return $this - */ - public function setContentType($type) - { - $this->setContentTypeInHeaders($type); - // Keep track of the value so that if the content-type changes automatically - // due to added child entities, it can be restored if they are later removed - $this->userContentType = $type; - - return $this; - } - - /** - * Get the CID of this entity. - * - * The CID will only be present in headers if a Content-ID header is present. - * - * @return string - */ - public function getId() - { - $tmp = (array) $this->getHeaderFieldModel($this->getIdField()); - - return $this->headers->has($this->getIdField()) ? current($tmp) : $this->id; - } - - /** - * Set the CID of this entity. - * - * @param string $id - * - * @return $this - */ - public function setId($id) - { - if (!$this->setHeaderFieldModel($this->getIdField(), $id)) { - $this->headers->addIdHeader($this->getIdField(), $id); - } - $this->id = $id; - - return $this; - } - - /** - * Get the description of this entity. - * - * This value comes from the Content-Description header if set. - * - * @return string - */ - public function getDescription() - { - return $this->getHeaderFieldModel('Content-Description'); - } - - /** - * Set the description of this entity. - * - * This method sets a value in the Content-ID header. - * - * @param string $description - * - * @return $this - */ - public function setDescription($description) - { - if (!$this->setHeaderFieldModel('Content-Description', $description)) { - $this->headers->addTextHeader('Content-Description', $description); - } - - return $this; - } - - /** - * Get the maximum line length of the body of this entity. - * - * @return int - */ - public function getMaxLineLength() - { - return $this->maxLineLength; - } - - /** - * Set the maximum line length of lines in this body. - * - * Though not enforced by the library, lines should not exceed 1000 chars. - * - * @param int $length - * - * @return $this - */ - public function setMaxLineLength($length) - { - $this->maxLineLength = $length; - - return $this; - } - - /** - * Get all children added to this entity. - * - * @return Swift_Mime_SimpleMimeEntity[] - */ - public function getChildren() - { - return $this->children; - } - - /** - * Set all children of this entity. - * - * @param Swift_Mime_SimpleMimeEntity[] $children - * @param int $compoundLevel For internal use only - * - * @return $this - */ - public function setChildren(array $children, $compoundLevel = null) - { - // TODO: Try to refactor this logic - $compoundLevel = $compoundLevel ?? $this->getCompoundLevel($children); - $immediateChildren = []; - $grandchildren = []; - $newContentType = $this->userContentType; - - foreach ($children as $child) { - $level = $this->getNeededChildLevel($child, $compoundLevel); - if (empty($immediateChildren)) { - //first iteration - $immediateChildren = [$child]; - } else { - $nextLevel = $this->getNeededChildLevel($immediateChildren[0], $compoundLevel); - if ($nextLevel == $level) { - $immediateChildren[] = $child; - } elseif ($level < $nextLevel) { - // Re-assign immediateChildren to grandchildren - $grandchildren = array_merge($grandchildren, $immediateChildren); - // Set new children - $immediateChildren = [$child]; - } else { - $grandchildren[] = $child; - } - } - } - - if ($immediateChildren) { - $lowestLevel = $this->getNeededChildLevel($immediateChildren[0], $compoundLevel); - - // Determine which composite media type is needed to accommodate the - // immediate children - foreach ($this->compositeRanges as $mediaType => $range) { - if ($lowestLevel > $range[0] && $lowestLevel <= $range[1]) { - $newContentType = $mediaType; - - break; - } - } - - // Put any grandchildren in a subpart - if (!empty($grandchildren)) { - $subentity = $this->createChild(); - $subentity->setNestingLevel($lowestLevel); - $subentity->setChildren($grandchildren, $compoundLevel); - array_unshift($immediateChildren, $subentity); - } - } - - $this->immediateChildren = $immediateChildren; - $this->children = $children; - $this->setContentTypeInHeaders($newContentType); - $this->fixHeaders(); - $this->sortChildren(); - - return $this; - } - - /** - * Get the body of this entity as a string. - * - * @return string - */ - public function getBody() - { - return $this->body instanceof Swift_OutputByteStream ? $this->readStream($this->body) : $this->body; - } - - /** - * Set the body of this entity, either as a string, or as an instance of - * {@link Swift_OutputByteStream}. - * - * @param mixed $body - * @param string $contentType optional - * - * @return $this - */ - public function setBody($body, $contentType = null) - { - if ($body !== $this->body) { - $this->clearCache(); - } - - $this->body = $body; - if (null !== $contentType) { - $this->setContentType($contentType); - } - - return $this; - } - - /** - * Get the encoder used for the body of this entity. - * - * @return Swift_Mime_ContentEncoder - */ - public function getEncoder() - { - return $this->encoder; - } - - /** - * Set the encoder used for the body of this entity. - * - * @return $this - */ - public function setEncoder(Swift_Mime_ContentEncoder $encoder) - { - if ($encoder !== $this->encoder) { - $this->clearCache(); - } - - $this->encoder = $encoder; - $this->setEncoding($encoder->getName()); - $this->notifyEncoderChanged($encoder); - - return $this; - } - - /** - * Get the boundary used to separate children in this entity. - * - * @return string - */ - public function getBoundary() - { - if (!isset($this->boundary)) { - $this->boundary = '_=_swift_'.time().'_'.bin2hex(random_bytes(16)).'_=_'; - } - - return $this->boundary; - } - - /** - * Set the boundary used to separate children in this entity. - * - * @param string $boundary - * - * @throws Swift_RfcComplianceException - * - * @return $this - */ - public function setBoundary($boundary) - { - $this->assertValidBoundary($boundary); - $this->boundary = $boundary; - - return $this; - } - - /** - * Receive notification that the charset of this entity, or a parent entity - * has changed. - * - * @param string $charset - */ - public function charsetChanged($charset) - { - $this->notifyCharsetChanged($charset); - } - - /** - * Receive notification that the encoder of this entity or a parent entity - * has changed. - */ - public function encoderChanged(Swift_Mime_ContentEncoder $encoder) - { - $this->notifyEncoderChanged($encoder); - } - - /** - * Get this entire entity as a string. - * - * @return string - */ - public function toString() - { - $string = $this->headers->toString(); - $string .= $this->bodyToString(); - - return $string; - } - - /** - * Get this entire entity as a string. - * - * @return string - */ - protected function bodyToString() - { - $string = ''; - - if (isset($this->body) && empty($this->immediateChildren)) { - if ($this->cache->hasKey($this->cacheKey, 'body')) { - $body = $this->cache->getString($this->cacheKey, 'body'); - } else { - $body = "\r\n".$this->encoder->encodeString($this->getBody(), 0, $this->getMaxLineLength()); - $this->cache->setString($this->cacheKey, 'body', $body, Swift_KeyCache::MODE_WRITE); - } - $string .= $body; - } - - if (!empty($this->immediateChildren)) { - foreach ($this->immediateChildren as $child) { - $string .= "\r\n\r\n--".$this->getBoundary()."\r\n"; - $string .= $child->toString(); - } - $string .= "\r\n\r\n--".$this->getBoundary()."--\r\n"; - } - - return $string; - } - - /** - * Returns a string representation of this object. - * - * @see toString() - * - * @return string - */ - public function __toString() - { - return $this->toString(); - } - - /** - * Write this entire entity to a {@see Swift_InputByteStream}. - */ - public function toByteStream(Swift_InputByteStream $is) - { - $is->write($this->headers->toString()); - $is->commit(); - - $this->bodyToByteStream($is); - } - - /** - * Write this entire entity to a {@link Swift_InputByteStream}. - */ - protected function bodyToByteStream(Swift_InputByteStream $is) - { - if (empty($this->immediateChildren)) { - if (isset($this->body)) { - if ($this->cache->hasKey($this->cacheKey, 'body')) { - $this->cache->exportToByteStream($this->cacheKey, 'body', $is); - } else { - $cacheIs = $this->cache->getInputByteStream($this->cacheKey, 'body'); - if ($cacheIs) { - $is->bind($cacheIs); - } - - $is->write("\r\n"); - - if ($this->body instanceof Swift_OutputByteStream) { - $this->body->setReadPointer(0); - - $this->encoder->encodeByteStream($this->body, $is, 0, $this->getMaxLineLength()); - } else { - $is->write($this->encoder->encodeString($this->getBody(), 0, $this->getMaxLineLength())); - } - - if ($cacheIs) { - $is->unbind($cacheIs); - } - } - } - } - - if (!empty($this->immediateChildren)) { - foreach ($this->immediateChildren as $child) { - $is->write("\r\n\r\n--".$this->getBoundary()."\r\n"); - $child->toByteStream($is); - } - $is->write("\r\n\r\n--".$this->getBoundary()."--\r\n"); - } - } - - /** - * Get the name of the header that provides the ID of this entity. - */ - protected function getIdField() - { - return 'Content-ID'; - } - - /** - * Get the model data (usually an array or a string) for $field. - */ - protected function getHeaderFieldModel($field) - { - if ($this->headers->has($field)) { - return $this->headers->get($field)->getFieldBodyModel(); - } - } - - /** - * Set the model data for $field. - */ - protected function setHeaderFieldModel($field, $model) - { - if ($this->headers->has($field)) { - $this->headers->get($field)->setFieldBodyModel($model); - - return true; - } - - return false; - } - - /** - * Get the parameter value of $parameter on $field header. - */ - protected function getHeaderParameter($field, $parameter) - { - if ($this->headers->has($field)) { - return $this->headers->get($field)->getParameter($parameter); - } - } - - /** - * Set the parameter value of $parameter on $field header. - */ - protected function setHeaderParameter($field, $parameter, $value) - { - if ($this->headers->has($field)) { - $this->headers->get($field)->setParameter($parameter, $value); - - return true; - } - - return false; - } - - /** - * Re-evaluate what content type and encoding should be used on this entity. - */ - protected function fixHeaders() - { - if (\count($this->immediateChildren)) { - $this->setHeaderParameter('Content-Type', 'boundary', - $this->getBoundary() - ); - $this->headers->remove('Content-Transfer-Encoding'); - } else { - $this->setHeaderParameter('Content-Type', 'boundary', null); - $this->setEncoding($this->encoder->getName()); - } - } - - /** - * Get the KeyCache used in this entity. - * - * @return Swift_KeyCache - */ - protected function getCache() - { - return $this->cache; - } - - /** - * Get the ID generator. - * - * @return Swift_IdGenerator - */ - protected function getIdGenerator() - { - return $this->idGenerator; - } - - /** - * Empty the KeyCache for this entity. - */ - protected function clearCache() - { - $this->cache->clearKey($this->cacheKey, 'body'); - } - - private function readStream(Swift_OutputByteStream $os) - { - $string = ''; - while (false !== $bytes = $os->read(8192)) { - $string .= $bytes; - } - - $os->setReadPointer(0); - - return $string; - } - - private function setEncoding($encoding) - { - if (!$this->setHeaderFieldModel('Content-Transfer-Encoding', $encoding)) { - $this->headers->addTextHeader('Content-Transfer-Encoding', $encoding); - } - } - - private function assertValidBoundary($boundary) - { - if (!preg_match('/^[a-z0-9\'\(\)\+_\-,\.\/:=\?\ ]{0,69}[a-z0-9\'\(\)\+_\-,\.\/:=\?]$/Di', $boundary)) { - throw new Swift_RfcComplianceException('Mime boundary set is not RFC 2046 compliant.'); - } - } - - private function setContentTypeInHeaders($type) - { - if (!$this->setHeaderFieldModel('Content-Type', $type)) { - $this->headers->addParameterizedHeader('Content-Type', $type); - } - } - - private function setNestingLevel($level) - { - $this->nestingLevel = $level; - } - - private function getCompoundLevel($children) - { - $level = 0; - foreach ($children as $child) { - $level |= $child->getNestingLevel(); - } - - return $level; - } - - private function getNeededChildLevel($child, $compoundLevel) - { - $filter = []; - foreach ($this->compoundLevelFilters as $bitmask => $rules) { - if (($compoundLevel & $bitmask) === $bitmask) { - $filter = $rules + $filter; - } - } - - $realLevel = $child->getNestingLevel(); - $lowercaseType = strtolower($child->getContentType() ?? ''); - - if (isset($filter[$realLevel]) && isset($filter[$realLevel][$lowercaseType])) { - return $filter[$realLevel][$lowercaseType]; - } - - return $realLevel; - } - - private function createChild() - { - return new self($this->headers->newInstance(), $this->encoder, $this->cache, $this->idGenerator); - } - - private function notifyEncoderChanged(Swift_Mime_ContentEncoder $encoder) - { - foreach ($this->immediateChildren as $child) { - $child->encoderChanged($encoder); - } - } - - private function notifyCharsetChanged($charset) - { - $this->encoder->charsetChanged($charset); - $this->headers->charsetChanged($charset); - foreach ($this->immediateChildren as $child) { - $child->charsetChanged($charset); - } - } - - private function sortChildren() - { - $shouldSort = false; - foreach ($this->immediateChildren as $child) { - // NOTE: This include alternative parts moved into a related part - if (self::LEVEL_ALTERNATIVE == $child->getNestingLevel()) { - $shouldSort = true; - break; - } - } - - // Sort in order of preference, if there is one - if ($shouldSort) { - // Group the messages by order of preference - $sorted = []; - foreach ($this->immediateChildren as $child) { - $type = $child->getContentType(); - $level = \array_key_exists($type, $this->alternativePartOrder) ? $this->alternativePartOrder[$type] : max($this->alternativePartOrder) + 1; - - if (empty($sorted[$level])) { - $sorted[$level] = []; - } - - $sorted[$level][] = $child; - } - - ksort($sorted); - - $this->immediateChildren = array_reduce($sorted, 'array_merge', []); - } - } - - /** - * Empties it's own contents from the cache. - */ - public function __destruct() - { - if ($this->cache instanceof Swift_KeyCache) { - $this->cache->clearAll($this->cacheKey); - } - } - - /** - * Make a deep copy of object. - */ - public function __clone() - { - $this->headers = clone $this->headers; - $this->encoder = clone $this->encoder; - $this->cacheKey = bin2hex(random_bytes(16)); // set 32 hex values - $children = []; - foreach ($this->children as $pos => $child) { - $children[$pos] = clone $child; - } - $this->setChildren($children); - } - - public function __wakeup() - { - $this->cacheKey = bin2hex(random_bytes(16)); // set 32 hex values - $this->cache = new Swift_KeyCache_ArrayKeyCache(new Swift_KeyCache_SimpleKeyCacheInputStream()); - } + /** Main message document; there can only be one of these */ + const LEVEL_TOP = 16; + + /** An entity which nests with the same precedence as an attachment */ + const LEVEL_MIXED = 256; + + /** An entity which nests with the same precedence as a mime part */ + const LEVEL_ALTERNATIVE = 4096; + + /** An entity which nests with the same precedence as embedded content */ + const LEVEL_RELATED = 65536; + + /** A collection of Headers for this mime entity */ + private $headers; + + /** The body as a string, or a stream */ + private $body; + + /** The encoder that encodes the body into a streamable format */ + private $encoder; + + /** Message ID generator */ + private $idGenerator; + + /** A mime boundary, if any is used */ + private $boundary; + + /** Mime types to be used based on the nesting level */ + private $compositeRanges = [ + 'multipart/mixed' => [self::LEVEL_TOP, self::LEVEL_MIXED], + 'multipart/alternative' => [self::LEVEL_MIXED, self::LEVEL_ALTERNATIVE], + 'multipart/related' => [self::LEVEL_ALTERNATIVE, self::LEVEL_RELATED], + ]; + + /** A set of filter rules to define what level an entity should be nested at */ + private $compoundLevelFilters = []; + + /** The nesting level of this entity */ + private $nestingLevel = self::LEVEL_ALTERNATIVE; + + /** A KeyCache instance used during encoding and streaming */ + private $cache; + + /** Direct descendants of this entity */ + private $immediateChildren = []; + + /** All descendants of this entity */ + private $children = []; + + /** The maximum line length of the body of this entity */ + private $maxLineLength = 78; + + /** The order in which alternative mime types should appear */ + private $alternativePartOrder = [ + 'text/plain' => 1, + 'text/html' => 2, + 'multipart/related' => 3, + ]; + + /** The CID of this entity */ + private $id; + + /** The key used for accessing the cache */ + private $cacheKey; + + protected $userContentType; + + /** + * Create a new SimpleMimeEntity with $headers, $encoder and $cache. + */ + public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator) + { + $this->cacheKey = bin2hex(random_bytes(16)); // set 32 hex values + $this->cache = $cache; + $this->headers = $headers; + $this->idGenerator = $idGenerator; + $this->setEncoder($encoder); + $this->headers->defineOrdering(['Content-Type', 'Content-Transfer-Encoding']); + + // This array specifies that, when the entire MIME document contains + // $compoundLevel, then for each child within $level, if its Content-Type + // is $contentType then it should be treated as if it's level is + // $neededLevel instead. I tried to write that unambiguously! :-\ + // Data Structure: + // array ( + // $compoundLevel => array( + // $level => array( + // $contentType => $neededLevel + // ) + // ) + // ) + + $this->compoundLevelFilters = [ + (self::LEVEL_ALTERNATIVE + self::LEVEL_RELATED) => [ + self::LEVEL_ALTERNATIVE => [ + 'text/plain' => self::LEVEL_ALTERNATIVE, + 'text/html' => self::LEVEL_RELATED, + ], + ], + ]; + + $this->id = $this->idGenerator->generateId(); + } + + /** + * Generate a new Content-ID or Message-ID for this MIME entity. + * + * @return string + */ + public function generateId() + { + $this->setId($this->idGenerator->generateId()); + + return $this->id; + } + + /** + * Get the {@link Swift_Mime_SimpleHeaderSet} for this entity. + * + * @return Swift_Mime_SimpleHeaderSet + */ + public function getHeaders() + { + return $this->headers; + } + + /** + * Get the nesting level of this entity. + * + * @see LEVEL_TOP, LEVEL_MIXED, LEVEL_RELATED, LEVEL_ALTERNATIVE + * + * @return int + */ + public function getNestingLevel() + { + return $this->nestingLevel; + } + + /** + * Get the Content-type of this entity. + * + * @return string + */ + public function getContentType() + { + return $this->getHeaderFieldModel('Content-Type'); + } + + /** + * Get the Body Content-type of this entity. + * + * @return string + */ + public function getBodyContentType() + { + return $this->userContentType; + } + + /** + * Set the Content-type of this entity. + * + * @param string $type + * + * @return $this + */ + public function setContentType($type) + { + $this->setContentTypeInHeaders($type); + // Keep track of the value so that if the content-type changes automatically + // due to added child entities, it can be restored if they are later removed + $this->userContentType = $type; + + return $this; + } + + /** + * Get the CID of this entity. + * + * The CID will only be present in headers if a Content-ID header is present. + * + * @return string + */ + public function getId() + { + $tmp = (array) $this->getHeaderFieldModel($this->getIdField()); + + return $this->headers->has($this->getIdField()) ? current($tmp) : $this->id; + } + + /** + * Set the CID of this entity. + * + * @param string $id + * + * @return $this + */ + public function setId($id) + { + if (!$this->setHeaderFieldModel($this->getIdField(), $id)) { + $this->headers->addIdHeader($this->getIdField(), $id); + } + $this->id = $id; + + return $this; + } + + /** + * Get the description of this entity. + * + * This value comes from the Content-Description header if set. + * + * @return string + */ + public function getDescription() + { + return $this->getHeaderFieldModel('Content-Description'); + } + + /** + * Set the description of this entity. + * + * This method sets a value in the Content-ID header. + * + * @param string $description + * + * @return $this + */ + public function setDescription($description) + { + if (!$this->setHeaderFieldModel('Content-Description', $description)) { + $this->headers->addTextHeader('Content-Description', $description); + } + + return $this; + } + + /** + * Get the maximum line length of the body of this entity. + * + * @return int + */ + public function getMaxLineLength() + { + return $this->maxLineLength; + } + + /** + * Set the maximum line length of lines in this body. + * + * Though not enforced by the library, lines should not exceed 1000 chars. + * + * @param int $length + * + * @return $this + */ + public function setMaxLineLength($length) + { + $this->maxLineLength = $length; + + return $this; + } + + /** + * Get all children added to this entity. + * + * @return Swift_Mime_SimpleMimeEntity[] + */ + public function getChildren() + { + return $this->children; + } + + /** + * Set all children of this entity. + * + * @param Swift_Mime_SimpleMimeEntity[] $children + * @param int $compoundLevel For internal use only + * + * @return $this + */ + public function setChildren(array $children, $compoundLevel = null) + { + // TODO: Try to refactor this logic + $compoundLevel = $compoundLevel ?? $this->getCompoundLevel($children); + $immediateChildren = []; + $grandchildren = []; + $newContentType = $this->userContentType; + + foreach ($children as $child) { + $level = $this->getNeededChildLevel($child, $compoundLevel); + if (empty($immediateChildren)) { + //first iteration + $immediateChildren = [$child]; + } else { + $nextLevel = $this->getNeededChildLevel($immediateChildren[0], $compoundLevel); + if ($nextLevel == $level) { + $immediateChildren[] = $child; + } elseif ($level < $nextLevel) { + // Re-assign immediateChildren to grandchildren + $grandchildren = array_merge($grandchildren, $immediateChildren); + // Set new children + $immediateChildren = [$child]; + } else { + $grandchildren[] = $child; + } + } + } + + if ($immediateChildren) { + $lowestLevel = $this->getNeededChildLevel($immediateChildren[0], $compoundLevel); + + // Determine which composite media type is needed to accommodate the + // immediate children + foreach ($this->compositeRanges as $mediaType => $range) { + if ($lowestLevel > $range[0] && $lowestLevel <= $range[1]) { + $newContentType = $mediaType; + + break; + } + } + + // Put any grandchildren in a subpart + if (!empty($grandchildren)) { + $subentity = $this->createChild(); + $subentity->setNestingLevel($lowestLevel); + $subentity->setChildren($grandchildren, $compoundLevel); + array_unshift($immediateChildren, $subentity); + } + } + + $this->immediateChildren = $immediateChildren; + $this->children = $children; + $this->setContentTypeInHeaders($newContentType); + $this->fixHeaders(); + $this->sortChildren(); + + return $this; + } + + /** + * Get the body of this entity as a string. + * + * @return string + */ + public function getBody() + { + return $this->body instanceof Swift_OutputByteStream ? $this->readStream($this->body) : $this->body; + } + + /** + * Set the body of this entity, either as a string, or as an instance of + * {@link Swift_OutputByteStream}. + * + * @param mixed $body + * @param string $contentType optional + * + * @return $this + */ + public function setBody($body, $contentType = null) + { + if ($body !== $this->body) { + $this->clearCache(); + } + + $this->body = $body; + if (null !== $contentType) { + $this->setContentType($contentType); + } + + return $this; + } + + /** + * Get the encoder used for the body of this entity. + * + * @return Swift_Mime_ContentEncoder + */ + public function getEncoder() + { + return $this->encoder; + } + + /** + * Set the encoder used for the body of this entity. + * + * @return $this + */ + public function setEncoder(Swift_Mime_ContentEncoder $encoder) + { + if ($encoder !== $this->encoder) { + $this->clearCache(); + } + + $this->encoder = $encoder; + $this->setEncoding($encoder->getName()); + $this->notifyEncoderChanged($encoder); + + return $this; + } + + /** + * Get the boundary used to separate children in this entity. + * + * @return string + */ + public function getBoundary() + { + if (!isset($this->boundary)) { + $this->boundary = '_=_swift_'.time().'_'.bin2hex(random_bytes(16)).'_=_'; + } + + return $this->boundary; + } + + /** + * Set the boundary used to separate children in this entity. + * + * @param string $boundary + * + * @throws Swift_RfcComplianceException + * + * @return $this + */ + public function setBoundary($boundary) + { + $this->assertValidBoundary($boundary); + $this->boundary = $boundary; + + return $this; + } + + /** + * Receive notification that the charset of this entity, or a parent entity + * has changed. + * + * @param string $charset + */ + public function charsetChanged($charset) + { + $this->notifyCharsetChanged($charset); + } + + /** + * Receive notification that the encoder of this entity or a parent entity + * has changed. + */ + public function encoderChanged(Swift_Mime_ContentEncoder $encoder) + { + $this->notifyEncoderChanged($encoder); + } + + /** + * Get this entire entity as a string. + * + * @return string + */ + public function toString() + { + $string = $this->headers->toString(); + $string .= $this->bodyToString(); + + return $string; + } + + /** + * Get this entire entity as a string. + * + * @return string + */ + protected function bodyToString() + { + $string = ''; + + if (isset($this->body) && empty($this->immediateChildren)) { + if ($this->cache->hasKey($this->cacheKey, 'body')) { + $body = $this->cache->getString($this->cacheKey, 'body'); + } else { + $body = "\r\n".$this->encoder->encodeString($this->getBody(), 0, $this->getMaxLineLength()); + $this->cache->setString($this->cacheKey, 'body', $body, Swift_KeyCache::MODE_WRITE); + } + $string .= $body; + } + + if (!empty($this->immediateChildren)) { + foreach ($this->immediateChildren as $child) { + $string .= "\r\n\r\n--".$this->getBoundary()."\r\n"; + $string .= $child->toString(); + } + $string .= "\r\n\r\n--".$this->getBoundary()."--\r\n"; + } + + return $string; + } + + /** + * Returns a string representation of this object. + * + * @see toString() + * + * @return string + */ + public function __toString() + { + return $this->toString(); + } + + /** + * Write this entire entity to a {@see Swift_InputByteStream}. + */ + public function toByteStream(Swift_InputByteStream $is) + { + $is->write($this->headers->toString()); + $is->commit(); + + $this->bodyToByteStream($is); + } + + /** + * Write this entire entity to a {@link Swift_InputByteStream}. + */ + protected function bodyToByteStream(Swift_InputByteStream $is) + { + if (empty($this->immediateChildren)) { + if (isset($this->body)) { + if ($this->cache->hasKey($this->cacheKey, 'body')) { + $this->cache->exportToByteStream($this->cacheKey, 'body', $is); + } else { + $cacheIs = $this->cache->getInputByteStream($this->cacheKey, 'body'); + if ($cacheIs) { + $is->bind($cacheIs); + } + + $is->write("\r\n"); + + if ($this->body instanceof Swift_OutputByteStream) { + $this->body->setReadPointer(0); + + $this->encoder->encodeByteStream($this->body, $is, 0, $this->getMaxLineLength()); + } else { + $is->write($this->encoder->encodeString($this->getBody(), 0, $this->getMaxLineLength())); + } + + if ($cacheIs) { + $is->unbind($cacheIs); + } + } + } + } + + if (!empty($this->immediateChildren)) { + foreach ($this->immediateChildren as $child) { + $is->write("\r\n\r\n--".$this->getBoundary()."\r\n"); + $child->toByteStream($is); + } + $is->write("\r\n\r\n--".$this->getBoundary()."--\r\n"); + } + } + + /** + * Get the name of the header that provides the ID of this entity. + */ + protected function getIdField() + { + return 'Content-ID'; + } + + /** + * Get the model data (usually an array or a string) for $field. + */ + protected function getHeaderFieldModel($field) + { + if ($this->headers->has($field)) { + return $this->headers->get($field)->getFieldBodyModel(); + } + } + + /** + * Set the model data for $field. + */ + protected function setHeaderFieldModel($field, $model) + { + if ($this->headers->has($field)) { + $this->headers->get($field)->setFieldBodyModel($model); + + return true; + } + + return false; + } + + /** + * Get the parameter value of $parameter on $field header. + */ + protected function getHeaderParameter($field, $parameter) + { + if ($this->headers->has($field)) { + return $this->headers->get($field)->getParameter($parameter); + } + } + + /** + * Set the parameter value of $parameter on $field header. + */ + protected function setHeaderParameter($field, $parameter, $value) + { + if ($this->headers->has($field)) { + $this->headers->get($field)->setParameter($parameter, $value); + + return true; + } + + return false; + } + + /** + * Re-evaluate what content type and encoding should be used on this entity. + */ + protected function fixHeaders() + { + if (\count($this->immediateChildren)) { + $this->setHeaderParameter('Content-Type', 'boundary', + $this->getBoundary() + ); + $this->headers->remove('Content-Transfer-Encoding'); + } else { + $this->setHeaderParameter('Content-Type', 'boundary', null); + $this->setEncoding($this->encoder->getName()); + } + } + + /** + * Get the KeyCache used in this entity. + * + * @return Swift_KeyCache + */ + protected function getCache() + { + return $this->cache; + } + + /** + * Get the ID generator. + * + * @return Swift_IdGenerator + */ + protected function getIdGenerator() + { + return $this->idGenerator; + } + + /** + * Empty the KeyCache for this entity. + */ + protected function clearCache() + { + $this->cache->clearKey($this->cacheKey, 'body'); + } + + private function readStream(Swift_OutputByteStream $os) + { + $string = ''; + while (false !== $bytes = $os->read(8192)) { + $string .= $bytes; + } + + $os->setReadPointer(0); + + return $string; + } + + private function setEncoding($encoding) + { + if (!$this->setHeaderFieldModel('Content-Transfer-Encoding', $encoding)) { + $this->headers->addTextHeader('Content-Transfer-Encoding', $encoding); + } + } + + private function assertValidBoundary($boundary) + { + if (!preg_match('/^[a-z0-9\'\(\)\+_\-,\.\/:=\?\ ]{0,69}[a-z0-9\'\(\)\+_\-,\.\/:=\?]$/Di', $boundary)) { + throw new Swift_RfcComplianceException('Mime boundary set is not RFC 2046 compliant.'); + } + } + + private function setContentTypeInHeaders($type) + { + if (!$this->setHeaderFieldModel('Content-Type', $type)) { + $this->headers->addParameterizedHeader('Content-Type', $type); + } + } + + private function setNestingLevel($level) + { + $this->nestingLevel = $level; + } + + private function getCompoundLevel($children) + { + $level = 0; + foreach ($children as $child) { + $level |= $child->getNestingLevel(); + } + + return $level; + } + + private function getNeededChildLevel($child, $compoundLevel) + { + $filter = []; + foreach ($this->compoundLevelFilters as $bitmask => $rules) { + if (($compoundLevel & $bitmask) === $bitmask) { + $filter = $rules + $filter; + } + } + + $realLevel = $child->getNestingLevel(); + $lowercaseType = strtolower($child->getContentType() ?? ''); + + if (isset($filter[$realLevel]) && isset($filter[$realLevel][$lowercaseType])) { + return $filter[$realLevel][$lowercaseType]; + } + + return $realLevel; + } + + private function createChild() + { + return new self($this->headers->newInstance(), $this->encoder, $this->cache, $this->idGenerator); + } + + private function notifyEncoderChanged(Swift_Mime_ContentEncoder $encoder) + { + foreach ($this->immediateChildren as $child) { + $child->encoderChanged($encoder); + } + } + + private function notifyCharsetChanged($charset) + { + $this->encoder->charsetChanged($charset); + $this->headers->charsetChanged($charset); + foreach ($this->immediateChildren as $child) { + $child->charsetChanged($charset); + } + } + + private function sortChildren() + { + $shouldSort = false; + foreach ($this->immediateChildren as $child) { + // NOTE: This include alternative parts moved into a related part + if (self::LEVEL_ALTERNATIVE == $child->getNestingLevel()) { + $shouldSort = true; + break; + } + } + + // Sort in order of preference, if there is one + if ($shouldSort) { + // Group the messages by order of preference + $sorted = []; + foreach ($this->immediateChildren as $child) { + $type = $child->getContentType(); + $level = \array_key_exists($type, $this->alternativePartOrder) ? $this->alternativePartOrder[$type] : max($this->alternativePartOrder) + 1; + + if (empty($sorted[$level])) { + $sorted[$level] = []; + } + + $sorted[$level][] = $child; + } + + ksort($sorted); + + $this->immediateChildren = array_reduce($sorted, 'array_merge', []); + } + } + + /** + * Empties it's own contents from the cache. + */ + public function __destruct() + { + if ($this->cache instanceof Swift_KeyCache) { + $this->cache->clearAll($this->cacheKey); + } + } + + /** + * Make a deep copy of object. + */ + public function __clone() + { + $this->headers = clone $this->headers; + $this->encoder = clone $this->encoder; + $this->cacheKey = bin2hex(random_bytes(16)); // set 32 hex values + $children = []; + foreach ($this->children as $pos => $child) { + $children[$pos] = clone $child; + } + $this->setChildren($children); + } + + public function __wakeup() + { + $this->cacheKey = bin2hex(random_bytes(16)); // set 32 hex values + $this->cache = new Swift_KeyCache_ArrayKeyCache(new Swift_KeyCache_SimpleKeyCacheInputStream()); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/MimePart.php b/htdocs/includes/swiftmailer/lib/classes/Swift/MimePart.php index ea97619ad69..e3440ae0cc3 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/MimePart.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/MimePart.php @@ -15,31 +15,31 @@ */ class Swift_MimePart extends Swift_Mime_MimePart { - /** - * Create a new MimePart. - * - * Details may be optionally passed into the constructor. - * - * @param string $body - * @param string $contentType - * @param string $charset - */ - public function __construct($body = null, $contentType = null, $charset = null) - { - \call_user_func_array( - [$this, 'Swift_Mime_MimePart::__construct'], - Swift_DependencyContainer::getInstance() - ->createDependenciesFor('mime.part') - ); + /** + * Create a new MimePart. + * + * Details may be optionally passed into the constructor. + * + * @param string $body + * @param string $contentType + * @param string $charset + */ + public function __construct($body = null, $contentType = null, $charset = null) + { + \call_user_func_array( + [$this, 'Swift_Mime_MimePart::__construct'], + Swift_DependencyContainer::getInstance() + ->createDependenciesFor('mime.part') + ); - if (!isset($charset)) { - $charset = Swift_DependencyContainer::getInstance() - ->lookup('properties.charset'); - } - $this->setBody($body); - $this->setCharset($charset); - if ($contentType) { - $this->setContentType($contentType); - } - } + if (!isset($charset)) { + $charset = Swift_DependencyContainer::getInstance() + ->lookup('properties.charset'); + } + $this->setBody($body); + $this->setCharset($charset); + if ($contentType) { + $this->setContentType($contentType); + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/NullTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/NullTransport.php index e44b7af982f..5be32bfabac 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/NullTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/NullTransport.php @@ -15,12 +15,12 @@ */ class Swift_NullTransport extends Swift_Transport_NullTransport { - public function __construct() - { - \call_user_func_array( - [$this, 'Swift_Transport_NullTransport::__construct'], - Swift_DependencyContainer::getInstance() - ->createDependenciesFor('transport.null') - ); - } + public function __construct() + { + \call_user_func_array( + [$this, 'Swift_Transport_NullTransport::__construct'], + Swift_DependencyContainer::getInstance() + ->createDependenciesFor('transport.null') + ); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/AntiFloodPlugin.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/AntiFloodPlugin.php index 5b1d7deefff..083ee263ec5 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/AntiFloodPlugin.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/AntiFloodPlugin.php @@ -15,123 +15,123 @@ */ class Swift_Plugins_AntiFloodPlugin implements Swift_Events_SendListener, Swift_Plugins_Sleeper { - /** - * The number of emails to send before restarting Transport. - * - * @var int - */ - private $threshold; + /** + * The number of emails to send before restarting Transport. + * + * @var int + */ + private $threshold; - /** - * The number of seconds to sleep for during a restart. - * - * @var int - */ - private $sleep; + /** + * The number of seconds to sleep for during a restart. + * + * @var int + */ + private $sleep; - /** - * The internal counter. - * - * @var int - */ - private $counter = 0; + /** + * The internal counter. + * + * @var int + */ + private $counter = 0; - /** - * The Sleeper instance for sleeping. - * - * @var Swift_Plugins_Sleeper - */ - private $sleeper; + /** + * The Sleeper instance for sleeping. + * + * @var Swift_Plugins_Sleeper + */ + private $sleeper; - /** - * Create a new AntiFloodPlugin with $threshold and $sleep time. - * - * @param int $threshold - * @param int $sleep time - * @param Swift_Plugins_Sleeper $sleeper (not needed really) - */ - public function __construct($threshold = 99, $sleep = 0, Swift_Plugins_Sleeper $sleeper = null) - { - $this->setThreshold($threshold); - $this->setSleepTime($sleep); - $this->sleeper = $sleeper; - } + /** + * Create a new AntiFloodPlugin with $threshold and $sleep time. + * + * @param int $threshold + * @param int $sleep time + * @param Swift_Plugins_Sleeper $sleeper (not needed really) + */ + public function __construct($threshold = 99, $sleep = 0, Swift_Plugins_Sleeper $sleeper = null) + { + $this->setThreshold($threshold); + $this->setSleepTime($sleep); + $this->sleeper = $sleeper; + } - /** - * Set the number of emails to send before restarting. - * - * @param int $threshold - */ - public function setThreshold($threshold) - { - $this->threshold = $threshold; - } + /** + * Set the number of emails to send before restarting. + * + * @param int $threshold + */ + public function setThreshold($threshold) + { + $this->threshold = $threshold; + } - /** - * Get the number of emails to send before restarting. - * - * @return int - */ - public function getThreshold() - { - return $this->threshold; - } + /** + * Get the number of emails to send before restarting. + * + * @return int + */ + public function getThreshold() + { + return $this->threshold; + } - /** - * Set the number of seconds to sleep for during a restart. - * - * @param int $sleep time - */ - public function setSleepTime($sleep) - { - $this->sleep = $sleep; - } + /** + * Set the number of seconds to sleep for during a restart. + * + * @param int $sleep time + */ + public function setSleepTime($sleep) + { + $this->sleep = $sleep; + } - /** - * Get the number of seconds to sleep for during a restart. - * - * @return int - */ - public function getSleepTime() - { - return $this->sleep; - } + /** + * Get the number of seconds to sleep for during a restart. + * + * @return int + */ + public function getSleepTime() + { + return $this->sleep; + } - /** - * Invoked immediately before the Message is sent. - */ - public function beforeSendPerformed(Swift_Events_SendEvent $evt) - { - } + /** + * Invoked immediately before the Message is sent. + */ + public function beforeSendPerformed(Swift_Events_SendEvent $evt) + { + } - /** - * Invoked immediately after the Message is sent. - */ - public function sendPerformed(Swift_Events_SendEvent $evt) - { - ++$this->counter; - if ($this->counter >= $this->threshold) { - $transport = $evt->getTransport(); - $transport->stop(); - if ($this->sleep) { - $this->sleep($this->sleep); - } - $transport->start(); - $this->counter = 0; - } - } + /** + * Invoked immediately after the Message is sent. + */ + public function sendPerformed(Swift_Events_SendEvent $evt) + { + ++$this->counter; + if ($this->counter >= $this->threshold) { + $transport = $evt->getTransport(); + $transport->stop(); + if ($this->sleep) { + $this->sleep($this->sleep); + } + $transport->start(); + $this->counter = 0; + } + } - /** - * Sleep for $seconds. - * - * @param int $seconds - */ - public function sleep($seconds) - { - if (isset($this->sleeper)) { - $this->sleeper->sleep($seconds); - } else { - sleep($seconds); - } - } + /** + * Sleep for $seconds. + * + * @param int $seconds + */ + public function sleep($seconds) + { + if (isset($this->sleeper)) { + $this->sleeper->sleep($seconds); + } else { + sleep($seconds); + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/BandwidthMonitorPlugin.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/BandwidthMonitorPlugin.php index 36451f44f1f..efffe57c9fb 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/BandwidthMonitorPlugin.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/BandwidthMonitorPlugin.php @@ -15,140 +15,140 @@ */ class Swift_Plugins_BandwidthMonitorPlugin implements Swift_Events_SendListener, Swift_Events_CommandListener, Swift_Events_ResponseListener, Swift_InputByteStream { - /** - * The outgoing traffic counter. - * - * @var int - */ - private $out = 0; + /** + * The outgoing traffic counter. + * + * @var int + */ + private $out = 0; - /** - * The incoming traffic counter. - * - * @var int - */ - private $in = 0; + /** + * The incoming traffic counter. + * + * @var int + */ + private $in = 0; - /** Bound byte streams */ - private $mirrors = []; + /** Bound byte streams */ + private $mirrors = []; - /** - * Not used. - */ - public function beforeSendPerformed(Swift_Events_SendEvent $evt) - { - } + /** + * Not used. + */ + public function beforeSendPerformed(Swift_Events_SendEvent $evt) + { + } - /** - * Invoked immediately after the Message is sent. - */ - public function sendPerformed(Swift_Events_SendEvent $evt) - { - $message = $evt->getMessage(); - $message->toByteStream($this); - } + /** + * Invoked immediately after the Message is sent. + */ + public function sendPerformed(Swift_Events_SendEvent $evt) + { + $message = $evt->getMessage(); + $message->toByteStream($this); + } - /** - * Invoked immediately following a command being sent. - */ - public function commandSent(Swift_Events_CommandEvent $evt) - { - $command = $evt->getCommand(); - $this->out += \strlen($command); - } + /** + * Invoked immediately following a command being sent. + */ + public function commandSent(Swift_Events_CommandEvent $evt) + { + $command = $evt->getCommand(); + $this->out += \strlen($command); + } - /** - * Invoked immediately following a response coming back. - */ - public function responseReceived(Swift_Events_ResponseEvent $evt) - { - $response = $evt->getResponse(); - $this->in += \strlen($response); - } + /** + * Invoked immediately following a response coming back. + */ + public function responseReceived(Swift_Events_ResponseEvent $evt) + { + $response = $evt->getResponse(); + $this->in += \strlen($response); + } - /** - * Called when a message is sent so that the outgoing counter can be increased. - * - * @param string $bytes - */ - public function write($bytes) - { - $this->out += \strlen($bytes); - foreach ($this->mirrors as $stream) { - $stream->write($bytes); - } - } + /** + * Called when a message is sent so that the outgoing counter can be increased. + * + * @param string $bytes + */ + public function write($bytes) + { + $this->out += \strlen($bytes); + foreach ($this->mirrors as $stream) { + $stream->write($bytes); + } + } - /** - * Not used. - */ - public function commit() - { - } + /** + * Not used. + */ + public function commit() + { + } - /** - * Attach $is to this stream. - * - * The stream acts as an observer, receiving all data that is written. - * All {@link write()} and {@link flushBuffers()} operations will be mirrored. - */ - public function bind(Swift_InputByteStream $is) - { - $this->mirrors[] = $is; - } + /** + * Attach $is to this stream. + * + * The stream acts as an observer, receiving all data that is written. + * All {@link write()} and {@link flushBuffers()} operations will be mirrored. + */ + public function bind(Swift_InputByteStream $is) + { + $this->mirrors[] = $is; + } - /** - * Remove an already bound stream. - * - * If $is is not bound, no errors will be raised. - * If the stream currently has any buffered data it will be written to $is - * before unbinding occurs. - */ - public function unbind(Swift_InputByteStream $is) - { - foreach ($this->mirrors as $k => $stream) { - if ($is === $stream) { - unset($this->mirrors[$k]); - } - } - } + /** + * Remove an already bound stream. + * + * If $is is not bound, no errors will be raised. + * If the stream currently has any buffered data it will be written to $is + * before unbinding occurs. + */ + public function unbind(Swift_InputByteStream $is) + { + foreach ($this->mirrors as $k => $stream) { + if ($is === $stream) { + unset($this->mirrors[$k]); + } + } + } - /** - * Not used. - */ - public function flushBuffers() - { - foreach ($this->mirrors as $stream) { - $stream->flushBuffers(); - } - } + /** + * Not used. + */ + public function flushBuffers() + { + foreach ($this->mirrors as $stream) { + $stream->flushBuffers(); + } + } - /** - * Get the total number of bytes sent to the server. - * - * @return int - */ - public function getBytesOut() - { - return $this->out; - } + /** + * Get the total number of bytes sent to the server. + * + * @return int + */ + public function getBytesOut() + { + return $this->out; + } - /** - * Get the total number of bytes received from the server. - * - * @return int - */ - public function getBytesIn() - { - return $this->in; - } + /** + * Get the total number of bytes received from the server. + * + * @return int + */ + public function getBytesIn() + { + return $this->in; + } - /** - * Reset the internal counters to zero. - */ - public function reset() - { - $this->out = 0; - $this->in = 0; - } + /** + * Reset the internal counters to zero. + */ + public function reset() + { + $this->out = 0; + $this->in = 0; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/DecoratorPlugin.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/DecoratorPlugin.php index 93124c9a5f4..796965dca4b 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/DecoratorPlugin.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/DecoratorPlugin.php @@ -16,185 +16,185 @@ */ class Swift_Plugins_DecoratorPlugin implements Swift_Events_SendListener, Swift_Plugins_Decorator_Replacements { - /** The replacement map */ - private $replacements; + /** The replacement map */ + private $replacements; - /** The body as it was before replacements */ - private $originalBody; + /** The body as it was before replacements */ + private $originalBody; - /** The original headers of the message, before replacements */ - private $originalHeaders = []; + /** The original headers of the message, before replacements */ + private $originalHeaders = []; - /** Bodies of children before they are replaced */ - private $originalChildBodies = []; + /** Bodies of children before they are replaced */ + private $originalChildBodies = []; - /** The Message that was last replaced */ - private $lastMessage; + /** The Message that was last replaced */ + private $lastMessage; - /** - * Create a new DecoratorPlugin with $replacements. - * - * The $replacements can either be an associative array, or an implementation - * of {@link Swift_Plugins_Decorator_Replacements}. - * - * When using an array, it should be of the form: - * - * $replacements = array( - * "address1@domain.tld" => array("{a}" => "b", "{c}" => "d"), - * "address2@domain.tld" => array("{a}" => "x", "{c}" => "y") - * ) - * - * - * When using an instance of {@link Swift_Plugins_Decorator_Replacements}, - * the object should return just the array of replacements for the address - * given to {@link Swift_Plugins_Decorator_Replacements::getReplacementsFor()}. - * - * @param mixed $replacements Array or Swift_Plugins_Decorator_Replacements - */ - public function __construct($replacements) - { - $this->setReplacements($replacements); - } + /** + * Create a new DecoratorPlugin with $replacements. + * + * The $replacements can either be an associative array, or an implementation + * of {@link Swift_Plugins_Decorator_Replacements}. + * + * When using an array, it should be of the form: + * + * $replacements = array( + * "address1@domain.tld" => array("{a}" => "b", "{c}" => "d"), + * "address2@domain.tld" => array("{a}" => "x", "{c}" => "y") + * ) + * + * + * When using an instance of {@link Swift_Plugins_Decorator_Replacements}, + * the object should return just the array of replacements for the address + * given to {@link Swift_Plugins_Decorator_Replacements::getReplacementsFor()}. + * + * @param mixed $replacements Array or Swift_Plugins_Decorator_Replacements + */ + public function __construct($replacements) + { + $this->setReplacements($replacements); + } - /** - * Sets replacements. - * - * @param mixed $replacements Array or Swift_Plugins_Decorator_Replacements - * - * @see __construct() - */ - public function setReplacements($replacements) - { - if (!($replacements instanceof Swift_Plugins_Decorator_Replacements)) { - $this->replacements = (array) $replacements; - } else { - $this->replacements = $replacements; - } - } + /** + * Sets replacements. + * + * @param mixed $replacements Array or Swift_Plugins_Decorator_Replacements + * + * @see __construct() + */ + public function setReplacements($replacements) + { + if (!($replacements instanceof Swift_Plugins_Decorator_Replacements)) { + $this->replacements = (array) $replacements; + } else { + $this->replacements = $replacements; + } + } - /** - * Invoked immediately before the Message is sent. - */ - public function beforeSendPerformed(Swift_Events_SendEvent $evt) - { - $message = $evt->getMessage(); - $this->restoreMessage($message); - $to = array_keys($message->getTo()); - $address = array_shift($to); - if ($replacements = $this->getReplacementsFor($address)) { - $body = $message->getBody(); - $search = array_keys($replacements); - $replace = array_values($replacements); - $bodyReplaced = str_replace( - $search, $replace, $body - ); - if ($body != $bodyReplaced) { - $this->originalBody = $body; - $message->setBody($bodyReplaced); - } + /** + * Invoked immediately before the Message is sent. + */ + public function beforeSendPerformed(Swift_Events_SendEvent $evt) + { + $message = $evt->getMessage(); + $this->restoreMessage($message); + $to = array_keys($message->getTo()); + $address = array_shift($to); + if ($replacements = $this->getReplacementsFor($address)) { + $body = $message->getBody(); + $search = array_keys($replacements); + $replace = array_values($replacements); + $bodyReplaced = str_replace( + $search, $replace, $body + ); + if ($body != $bodyReplaced) { + $this->originalBody = $body; + $message->setBody($bodyReplaced); + } - foreach ($message->getHeaders()->getAll() as $header) { - $body = $header->getFieldBodyModel(); - $count = 0; - if (\is_array($body)) { - $bodyReplaced = []; - foreach ($body as $key => $value) { - $count1 = 0; - $count2 = 0; - $key = \is_string($key) ? str_replace($search, $replace, $key, $count1) : $key; - $value = \is_string($value) ? str_replace($search, $replace, $value, $count2) : $value; - $bodyReplaced[$key] = $value; + foreach ($message->getHeaders()->getAll() as $header) { + $body = $header->getFieldBodyModel(); + $count = 0; + if (\is_array($body)) { + $bodyReplaced = []; + foreach ($body as $key => $value) { + $count1 = 0; + $count2 = 0; + $key = \is_string($key) ? str_replace($search, $replace, $key, $count1) : $key; + $value = \is_string($value) ? str_replace($search, $replace, $value, $count2) : $value; + $bodyReplaced[$key] = $value; - if (!$count && ($count1 || $count2)) { - $count = 1; - } - } - } elseif (\is_string($body)) { - $bodyReplaced = str_replace($search, $replace, $body, $count); - } + if (!$count && ($count1 || $count2)) { + $count = 1; + } + } + } elseif (\is_string($body)) { + $bodyReplaced = str_replace($search, $replace, $body, $count); + } - if ($count) { - $this->originalHeaders[$header->getFieldName()] = $body; - $header->setFieldBodyModel($bodyReplaced); - } - } + if ($count) { + $this->originalHeaders[$header->getFieldName()] = $body; + $header->setFieldBodyModel($bodyReplaced); + } + } - $children = (array) $message->getChildren(); - foreach ($children as $child) { - list($type) = sscanf($child->getContentType(), '%[^/]/%s'); - if ('text' == $type) { - $body = $child->getBody(); - $bodyReplaced = str_replace( - $search, $replace, $body - ); - if ($body != $bodyReplaced) { - $child->setBody($bodyReplaced); - $this->originalChildBodies[$child->getId()] = $body; - } - } - } - $this->lastMessage = $message; - } - } + $children = (array) $message->getChildren(); + foreach ($children as $child) { + list($type) = sscanf($child->getContentType(), '%[^/]/%s'); + if ('text' == $type) { + $body = $child->getBody(); + $bodyReplaced = str_replace( + $search, $replace, $body + ); + if ($body != $bodyReplaced) { + $child->setBody($bodyReplaced); + $this->originalChildBodies[$child->getId()] = $body; + } + } + } + $this->lastMessage = $message; + } + } - /** - * Find a map of replacements for the address. - * - * If this plugin was provided with a delegate instance of - * {@link Swift_Plugins_Decorator_Replacements} then the call will be - * delegated to it. Otherwise, it will attempt to find the replacements - * from the array provided in the constructor. - * - * If no replacements can be found, an empty value (NULL) is returned. - * - * @param string $address - * - * @return array - */ - public function getReplacementsFor($address) - { - if ($this->replacements instanceof Swift_Plugins_Decorator_Replacements) { - return $this->replacements->getReplacementsFor($address); - } + /** + * Find a map of replacements for the address. + * + * If this plugin was provided with a delegate instance of + * {@link Swift_Plugins_Decorator_Replacements} then the call will be + * delegated to it. Otherwise, it will attempt to find the replacements + * from the array provided in the constructor. + * + * If no replacements can be found, an empty value (NULL) is returned. + * + * @param string $address + * + * @return array + */ + public function getReplacementsFor($address) + { + if ($this->replacements instanceof Swift_Plugins_Decorator_Replacements) { + return $this->replacements->getReplacementsFor($address); + } - return $this->replacements[$address] ?? null; - } + return $this->replacements[$address] ?? null; + } - /** - * Invoked immediately after the Message is sent. - */ - public function sendPerformed(Swift_Events_SendEvent $evt) - { - $this->restoreMessage($evt->getMessage()); - } + /** + * Invoked immediately after the Message is sent. + */ + public function sendPerformed(Swift_Events_SendEvent $evt) + { + $this->restoreMessage($evt->getMessage()); + } - /** Restore a changed message back to its original state */ - private function restoreMessage(Swift_Mime_SimpleMessage $message) - { - if ($this->lastMessage === $message) { - if (isset($this->originalBody)) { - $message->setBody($this->originalBody); - $this->originalBody = null; - } - if (!empty($this->originalHeaders)) { - foreach ($message->getHeaders()->getAll() as $header) { - if (\array_key_exists($header->getFieldName(), $this->originalHeaders)) { - $header->setFieldBodyModel($this->originalHeaders[$header->getFieldName()]); - } - } - $this->originalHeaders = []; - } - if (!empty($this->originalChildBodies)) { - $children = (array) $message->getChildren(); - foreach ($children as $child) { - $id = $child->getId(); - if (\array_key_exists($id, $this->originalChildBodies)) { - $child->setBody($this->originalChildBodies[$id]); - } - } - $this->originalChildBodies = []; - } - $this->lastMessage = null; - } - } + /** Restore a changed message back to its original state */ + private function restoreMessage(Swift_Mime_SimpleMessage $message) + { + if ($this->lastMessage === $message) { + if (isset($this->originalBody)) { + $message->setBody($this->originalBody); + $this->originalBody = null; + } + if (!empty($this->originalHeaders)) { + foreach ($message->getHeaders()->getAll() as $header) { + if (\array_key_exists($header->getFieldName(), $this->originalHeaders)) { + $header->setFieldBodyModel($this->originalHeaders[$header->getFieldName()]); + } + } + $this->originalHeaders = []; + } + if (!empty($this->originalChildBodies)) { + $children = (array) $message->getChildren(); + foreach ($children as $child) { + $id = $child->getId(); + if (\array_key_exists($id, $this->originalChildBodies)) { + $child->setBody($this->originalChildBodies[$id]); + } + } + $this->originalChildBodies = []; + } + $this->lastMessage = null; + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/ImpersonatePlugin.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/ImpersonatePlugin.php index 3f4dbbfa40f..69d31f0a465 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/ImpersonatePlugin.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/ImpersonatePlugin.php @@ -15,51 +15,51 @@ */ class Swift_Plugins_ImpersonatePlugin implements Swift_Events_SendListener { - /** - * The sender to impersonate. - * - * @var string - */ - private $sender; + /** + * The sender to impersonate. + * + * @var string + */ + private $sender; - /** - * Create a new ImpersonatePlugin to impersonate $sender. - * - * @param string $sender address - */ - public function __construct($sender) - { - $this->sender = $sender; - } + /** + * Create a new ImpersonatePlugin to impersonate $sender. + * + * @param string $sender address + */ + public function __construct($sender) + { + $this->sender = $sender; + } - /** - * Invoked immediately before the Message is sent. - */ - public function beforeSendPerformed(Swift_Events_SendEvent $evt) - { - $message = $evt->getMessage(); - $headers = $message->getHeaders(); + /** + * Invoked immediately before the Message is sent. + */ + public function beforeSendPerformed(Swift_Events_SendEvent $evt) + { + $message = $evt->getMessage(); + $headers = $message->getHeaders(); - // save current recipients - $headers->addPathHeader('X-Swift-Return-Path', $message->getReturnPath()); + // save current recipients + $headers->addPathHeader('X-Swift-Return-Path', $message->getReturnPath()); - // replace them with the one to send to - $message->setReturnPath($this->sender); - } + // replace them with the one to send to + $message->setReturnPath($this->sender); + } - /** - * Invoked immediately after the Message is sent. - */ - public function sendPerformed(Swift_Events_SendEvent $evt) - { - $message = $evt->getMessage(); + /** + * Invoked immediately after the Message is sent. + */ + public function sendPerformed(Swift_Events_SendEvent $evt) + { + $message = $evt->getMessage(); - // restore original headers - $headers = $message->getHeaders(); + // restore original headers + $headers = $message->getHeaders(); - if ($headers->has('X-Swift-Return-Path')) { - $message->setReturnPath($headers->get('X-Swift-Return-Path')->getAddress()); - $headers->removeAll('X-Swift-Return-Path'); - } - } + if ($headers->has('X-Swift-Return-Path')) { + $message->setReturnPath($headers->get('X-Swift-Return-Path')->getAddress()); + $headers->removeAll('X-Swift-Return-Path'); + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/LoggerPlugin.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/LoggerPlugin.php index e183749b7ec..afb0a3df297 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/LoggerPlugin.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/LoggerPlugin.php @@ -15,112 +15,112 @@ */ class Swift_Plugins_LoggerPlugin implements Swift_Events_CommandListener, Swift_Events_ResponseListener, Swift_Events_TransportChangeListener, Swift_Events_TransportExceptionListener, Swift_Plugins_Logger { - /** The logger which is delegated to */ - private $logger; + /** The logger which is delegated to */ + private $logger; - /** - * Create a new LoggerPlugin using $logger. - */ - public function __construct(Swift_Plugins_Logger $logger) - { - $this->logger = $logger; - } + /** + * Create a new LoggerPlugin using $logger. + */ + public function __construct(Swift_Plugins_Logger $logger) + { + $this->logger = $logger; + } - /** - * Add a log entry. - * - * @param string $entry - */ - public function add($entry) - { - $this->logger->add($entry); - } + /** + * Add a log entry. + * + * @param string $entry + */ + public function add($entry) + { + $this->logger->add($entry); + } - /** - * Clear the log contents. - */ - public function clear() - { - $this->logger->clear(); - } + /** + * Clear the log contents. + */ + public function clear() + { + $this->logger->clear(); + } - /** - * Get this log as a string. - * - * @return string - */ - public function dump() - { - return $this->logger->dump(); - } + /** + * Get this log as a string. + * + * @return string + */ + public function dump() + { + return $this->logger->dump(); + } - /** - * Invoked immediately following a command being sent. - */ - public function commandSent(Swift_Events_CommandEvent $evt) - { - $command = $evt->getCommand(); - $this->logger->add(sprintf('>> %s', $command)); - } + /** + * Invoked immediately following a command being sent. + */ + public function commandSent(Swift_Events_CommandEvent $evt) + { + $command = $evt->getCommand(); + $this->logger->add(sprintf('>> %s', $command)); + } - /** - * Invoked immediately following a response coming back. - */ - public function responseReceived(Swift_Events_ResponseEvent $evt) - { - $response = $evt->getResponse(); - $this->logger->add(sprintf('<< %s', $response)); - } + /** + * Invoked immediately following a response coming back. + */ + public function responseReceived(Swift_Events_ResponseEvent $evt) + { + $response = $evt->getResponse(); + $this->logger->add(sprintf('<< %s', $response)); + } - /** - * Invoked just before a Transport is started. - */ - public function beforeTransportStarted(Swift_Events_TransportChangeEvent $evt) - { - $transportName = \get_class($evt->getSource()); - $this->logger->add(sprintf('++ Starting %s', $transportName)); - } + /** + * Invoked just before a Transport is started. + */ + public function beforeTransportStarted(Swift_Events_TransportChangeEvent $evt) + { + $transportName = \get_class($evt->getSource()); + $this->logger->add(sprintf('++ Starting %s', $transportName)); + } - /** - * Invoked immediately after the Transport is started. - */ - public function transportStarted(Swift_Events_TransportChangeEvent $evt) - { - $transportName = \get_class($evt->getSource()); - $this->logger->add(sprintf('++ %s started', $transportName)); - } + /** + * Invoked immediately after the Transport is started. + */ + public function transportStarted(Swift_Events_TransportChangeEvent $evt) + { + $transportName = \get_class($evt->getSource()); + $this->logger->add(sprintf('++ %s started', $transportName)); + } - /** - * Invoked just before a Transport is stopped. - */ - public function beforeTransportStopped(Swift_Events_TransportChangeEvent $evt) - { - $transportName = \get_class($evt->getSource()); - $this->logger->add(sprintf('++ Stopping %s', $transportName)); - } + /** + * Invoked just before a Transport is stopped. + */ + public function beforeTransportStopped(Swift_Events_TransportChangeEvent $evt) + { + $transportName = \get_class($evt->getSource()); + $this->logger->add(sprintf('++ Stopping %s', $transportName)); + } - /** - * Invoked immediately after the Transport is stopped. - */ - public function transportStopped(Swift_Events_TransportChangeEvent $evt) - { - $transportName = \get_class($evt->getSource()); - $this->logger->add(sprintf('++ %s stopped', $transportName)); - } + /** + * Invoked immediately after the Transport is stopped. + */ + public function transportStopped(Swift_Events_TransportChangeEvent $evt) + { + $transportName = \get_class($evt->getSource()); + $this->logger->add(sprintf('++ %s stopped', $transportName)); + } - /** - * Invoked as a TransportException is thrown in the Transport system. - */ - public function exceptionThrown(Swift_Events_TransportExceptionEvent $evt) - { - $e = $evt->getException(); - $message = $e->getMessage(); - $code = $e->getCode(); - $this->logger->add(sprintf('!! %s (code: %s)', $message, $code)); - $message .= PHP_EOL; - $message .= 'Log data:'.PHP_EOL; - $message .= $this->logger->dump(); - $evt->cancelBubble(); - throw new Swift_TransportException($message, $code, $e->getPrevious()); - } + /** + * Invoked as a TransportException is thrown in the Transport system. + */ + public function exceptionThrown(Swift_Events_TransportExceptionEvent $evt) + { + $e = $evt->getException(); + $message = $e->getMessage(); + $code = $e->getCode(); + $this->logger->add(sprintf('!! %s (code: %s)', $message, $code)); + $message .= PHP_EOL; + $message .= 'Log data:'.PHP_EOL; + $message .= $this->logger->dump(); + $evt->cancelBubble(); + throw new Swift_TransportException($message, $code, $e->getPrevious()); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Loggers/ArrayLogger.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Loggers/ArrayLogger.php index 6f595adaa4d..0761b84f83d 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Loggers/ArrayLogger.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Loggers/ArrayLogger.php @@ -15,58 +15,58 @@ */ class Swift_Plugins_Loggers_ArrayLogger implements Swift_Plugins_Logger { - /** - * The log contents. - * - * @var array - */ - private $log = []; + /** + * The log contents. + * + * @var array + */ + private $log = []; - /** - * Max size of the log. - * - * @var int - */ - private $size = 0; + /** + * Max size of the log. + * + * @var int + */ + private $size = 0; - /** - * Create a new ArrayLogger with a maximum of $size entries. - * - * @var int - */ - public function __construct($size = 50) - { - $this->size = $size; - } + /** + * Create a new ArrayLogger with a maximum of $size entries. + * + * @var int + */ + public function __construct($size = 50) + { + $this->size = $size; + } - /** - * Add a log entry. - * - * @param string $entry - */ - public function add($entry) - { - $this->log[] = $entry; - while (\count($this->log) > $this->size) { - array_shift($this->log); - } - } + /** + * Add a log entry. + * + * @param string $entry + */ + public function add($entry) + { + $this->log[] = $entry; + while (\count($this->log) > $this->size) { + array_shift($this->log); + } + } - /** - * Clear the log contents. - */ - public function clear() - { - $this->log = []; - } + /** + * Clear the log contents. + */ + public function clear() + { + $this->log = []; + } - /** - * Get this log as a string. - * - * @return string - */ - public function dump() - { - return implode(PHP_EOL, $this->log); - } + /** + * Get this log as a string. + * + * @return string + */ + public function dump() + { + return implode(PHP_EOL, $this->log); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/MessageLogger.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/MessageLogger.php index 39c48ed18f5..6aaf87599cb 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/MessageLogger.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/MessageLogger.php @@ -15,56 +15,56 @@ */ class Swift_Plugins_MessageLogger implements Swift_Events_SendListener { - /** - * @var Swift_Mime_SimpleMessage[] - */ - private $messages; + /** + * @var Swift_Mime_SimpleMessage[] + */ + private $messages; - public function __construct() - { - $this->messages = []; - } + public function __construct() + { + $this->messages = []; + } - /** - * Get the message list. - * - * @return Swift_Mime_SimpleMessage[] - */ - public function getMessages() - { - return $this->messages; - } + /** + * Get the message list. + * + * @return Swift_Mime_SimpleMessage[] + */ + public function getMessages() + { + return $this->messages; + } - /** - * Get the message count. - * - * @return int count - */ - public function countMessages() - { - return \count($this->messages); - } + /** + * Get the message count. + * + * @return int count + */ + public function countMessages() + { + return \count($this->messages); + } - /** - * Empty the message list. - */ - public function clear() - { - $this->messages = []; - } + /** + * Empty the message list. + */ + public function clear() + { + $this->messages = []; + } - /** - * Invoked immediately before the Message is sent. - */ - public function beforeSendPerformed(Swift_Events_SendEvent $evt) - { - $this->messages[] = clone $evt->getMessage(); - } + /** + * Invoked immediately before the Message is sent. + */ + public function beforeSendPerformed(Swift_Events_SendEvent $evt) + { + $this->messages[] = clone $evt->getMessage(); + } - /** - * Invoked immediately after the Message is sent. - */ - public function sendPerformed(Swift_Events_SendEvent $evt) - { - } + /** + * Invoked immediately after the Message is sent. + */ + public function sendPerformed(Swift_Events_SendEvent $evt) + { + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/PopBeforeSmtpPlugin.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/PopBeforeSmtpPlugin.php index 9448594090b..cf4f2438ec0 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/PopBeforeSmtpPlugin.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/PopBeforeSmtpPlugin.php @@ -15,228 +15,228 @@ */ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeListener, Swift_Plugins_Pop_Pop3Connection { - /** A delegate connection to use (mostly a test hook) */ - private $connection; + /** A delegate connection to use (mostly a test hook) */ + private $connection; - /** Hostname of the POP3 server */ - private $host; + /** Hostname of the POP3 server */ + private $host; - /** Port number to connect on */ - private $port; + /** Port number to connect on */ + private $port; - /** Encryption type to use (if any) */ - private $crypto; + /** Encryption type to use (if any) */ + private $crypto; - /** Username to use (if any) */ - private $username; + /** Username to use (if any) */ + private $username; - /** Password to use (if any) */ - private $password; + /** Password to use (if any) */ + private $password; - /** Established connection via TCP socket */ - private $socket; + /** Established connection via TCP socket */ + private $socket; - /** Connect timeout in seconds */ - private $timeout = 10; + /** Connect timeout in seconds */ + private $timeout = 10; - /** SMTP Transport to bind to */ - private $transport; + /** SMTP Transport to bind to */ + private $transport; - /** - * Create a new PopBeforeSmtpPlugin for $host and $port. - * - * @param string $host Hostname or IP. Literal IPv6 addresses should be - * wrapped in square brackets. - * @param int $port - * @param string $crypto as "tls" or "ssl" - */ - public function __construct($host, $port = 110, $crypto = null) - { - $this->host = $host; - $this->port = $port; - $this->crypto = $crypto; - } + /** + * Create a new PopBeforeSmtpPlugin for $host and $port. + * + * @param string $host Hostname or IP. Literal IPv6 addresses should be + * wrapped in square brackets. + * @param int $port + * @param string $crypto as "tls" or "ssl" + */ + public function __construct($host, $port = 110, $crypto = null) + { + $this->host = $host; + $this->port = $port; + $this->crypto = $crypto; + } - /** - * Set a Pop3Connection to delegate to instead of connecting directly. - * - * @return $this - */ - public function setConnection(Swift_Plugins_Pop_Pop3Connection $connection) - { - $this->connection = $connection; + /** + * Set a Pop3Connection to delegate to instead of connecting directly. + * + * @return $this + */ + public function setConnection(Swift_Plugins_Pop_Pop3Connection $connection) + { + $this->connection = $connection; - return $this; - } + return $this; + } - /** - * Bind this plugin to a specific SMTP transport instance. - */ - public function bindSmtp(Swift_Transport $smtp) - { - $this->transport = $smtp; - } + /** + * Bind this plugin to a specific SMTP transport instance. + */ + public function bindSmtp(Swift_Transport $smtp) + { + $this->transport = $smtp; + } - /** - * Set the connection timeout in seconds (default 10). - * - * @param int $timeout - * - * @return $this - */ - public function setTimeout($timeout) - { - $this->timeout = (int) $timeout; + /** + * Set the connection timeout in seconds (default 10). + * + * @param int $timeout + * + * @return $this + */ + public function setTimeout($timeout) + { + $this->timeout = (int) $timeout; - return $this; - } + return $this; + } - /** - * Set the username to use when connecting (if needed). - * - * @param string $username - * - * @return $this - */ - public function setUsername($username) - { - $this->username = $username; + /** + * Set the username to use when connecting (if needed). + * + * @param string $username + * + * @return $this + */ + public function setUsername($username) + { + $this->username = $username; - return $this; - } + return $this; + } - /** - * Set the password to use when connecting (if needed). - * - * @param string $password - * - * @return $this - */ - public function setPassword($password) - { - $this->password = $password; + /** + * Set the password to use when connecting (if needed). + * + * @param string $password + * + * @return $this + */ + public function setPassword($password) + { + $this->password = $password; - return $this; - } + return $this; + } - /** - * Connect to the POP3 host and authenticate. - * - * @throws Swift_Plugins_Pop_Pop3Exception if connection fails - */ - public function connect() - { - if (isset($this->connection)) { - $this->connection->connect(); - } else { - if (!isset($this->socket)) { - if (!$socket = fsockopen( - $this->getHostString(), $this->port, $errno, $errstr, $this->timeout)) { - throw new Swift_Plugins_Pop_Pop3Exception(sprintf('Failed to connect to POP3 host [%s]: %s', $this->host, $errstr)); - } - $this->socket = $socket; + /** + * Connect to the POP3 host and authenticate. + * + * @throws Swift_Plugins_Pop_Pop3Exception if connection fails + */ + public function connect() + { + if (isset($this->connection)) { + $this->connection->connect(); + } else { + if (!isset($this->socket)) { + if (!$socket = fsockopen( + $this->getHostString(), $this->port, $errno, $errstr, $this->timeout)) { + throw new Swift_Plugins_Pop_Pop3Exception(sprintf('Failed to connect to POP3 host [%s]: %s', $this->host, $errstr)); + } + $this->socket = $socket; - if (false === $greeting = fgets($this->socket)) { - throw new Swift_Plugins_Pop_Pop3Exception(sprintf('Failed to connect to POP3 host [%s]', trim($greeting ?? ''))); - } + if (false === $greeting = fgets($this->socket)) { + throw new Swift_Plugins_Pop_Pop3Exception(sprintf('Failed to connect to POP3 host [%s]', trim($greeting ?? ''))); + } - $this->assertOk($greeting); + $this->assertOk($greeting); - if ($this->username) { - $this->command(sprintf("USER %s\r\n", $this->username)); - $this->command(sprintf("PASS %s\r\n", $this->password)); - } - } - } - } + if ($this->username) { + $this->command(sprintf("USER %s\r\n", $this->username)); + $this->command(sprintf("PASS %s\r\n", $this->password)); + } + } + } + } - /** - * Disconnect from the POP3 host. - */ - public function disconnect() - { - if (isset($this->connection)) { - $this->connection->disconnect(); - } else { - $this->command("QUIT\r\n"); - if (!fclose($this->socket)) { - throw new Swift_Plugins_Pop_Pop3Exception(sprintf('POP3 host [%s] connection could not be stopped', $this->host)); - } - $this->socket = null; - } - } + /** + * Disconnect from the POP3 host. + */ + public function disconnect() + { + if (isset($this->connection)) { + $this->connection->disconnect(); + } else { + $this->command("QUIT\r\n"); + if (!fclose($this->socket)) { + throw new Swift_Plugins_Pop_Pop3Exception(sprintf('POP3 host [%s] connection could not be stopped', $this->host)); + } + $this->socket = null; + } + } - /** - * Invoked just before a Transport is started. - */ - public function beforeTransportStarted(Swift_Events_TransportChangeEvent $evt) - { - if (isset($this->transport)) { - if ($this->transport !== $evt->getTransport()) { - return; - } - } + /** + * Invoked just before a Transport is started. + */ + public function beforeTransportStarted(Swift_Events_TransportChangeEvent $evt) + { + if (isset($this->transport)) { + if ($this->transport !== $evt->getTransport()) { + return; + } + } - $this->connect(); - $this->disconnect(); - } + $this->connect(); + $this->disconnect(); + } - /** - * Not used. - */ - public function transportStarted(Swift_Events_TransportChangeEvent $evt) - { - } + /** + * Not used. + */ + public function transportStarted(Swift_Events_TransportChangeEvent $evt) + { + } - /** - * Not used. - */ - public function beforeTransportStopped(Swift_Events_TransportChangeEvent $evt) - { - } + /** + * Not used. + */ + public function beforeTransportStopped(Swift_Events_TransportChangeEvent $evt) + { + } - /** - * Not used. - */ - public function transportStopped(Swift_Events_TransportChangeEvent $evt) - { - } + /** + * Not used. + */ + public function transportStopped(Swift_Events_TransportChangeEvent $evt) + { + } - private function command($command) - { - if (!fwrite($this->socket, $command)) { - throw new Swift_Plugins_Pop_Pop3Exception(sprintf('Failed to write command [%s] to POP3 host', trim($command ?? ''))); - } + private function command($command) + { + if (!fwrite($this->socket, $command)) { + throw new Swift_Plugins_Pop_Pop3Exception(sprintf('Failed to write command [%s] to POP3 host', trim($command ?? ''))); + } - if (false === $response = fgets($this->socket)) { - throw new Swift_Plugins_Pop_Pop3Exception(sprintf('Failed to read from POP3 host after command [%s]', trim($command ?? ''))); - } + if (false === $response = fgets($this->socket)) { + throw new Swift_Plugins_Pop_Pop3Exception(sprintf('Failed to read from POP3 host after command [%s]', trim($command ?? ''))); + } - $this->assertOk($response); + $this->assertOk($response); - return $response; - } + return $response; + } - private function assertOk($response) - { - if ('+OK' != substr($response, 0, 3)) { - throw new Swift_Plugins_Pop_Pop3Exception(sprintf('POP3 command failed [%s]', trim($response ?? ''))); - } - } + private function assertOk($response) + { + if ('+OK' != substr($response, 0, 3)) { + throw new Swift_Plugins_Pop_Pop3Exception(sprintf('POP3 command failed [%s]', trim($response ?? ''))); + } + } - private function getHostString() - { - $host = $this->host; - switch (strtolower($this->crypto ?? '')) { - case 'ssl': - $host = 'ssl://'.$host; - break; + private function getHostString() + { + $host = $this->host; + switch (strtolower($this->crypto ?? '')) { + case 'ssl': + $host = 'ssl://'.$host; + break; - case 'tls': - $host = 'tls://'.$host; - break; - } + case 'tls': + $host = 'tls://'.$host; + break; + } - return $host; - } + return $host; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/RedirectingPlugin.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/RedirectingPlugin.php index f7373b2424c..756faa89c67 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/RedirectingPlugin.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/RedirectingPlugin.php @@ -15,187 +15,187 @@ */ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener { - /** - * The recipient who will receive all messages. - * - * @var mixed - */ - private $recipient; + /** + * The recipient who will receive all messages. + * + * @var mixed + */ + private $recipient; - /** - * List of regular expression for recipient whitelisting. - * - * @var array - */ - private $whitelist = []; + /** + * List of regular expression for recipient whitelisting. + * + * @var array + */ + private $whitelist = []; - /** - * Create a new RedirectingPlugin. - * - * @param mixed $recipient - */ - public function __construct($recipient, array $whitelist = []) - { - $this->recipient = $recipient; - $this->whitelist = $whitelist; - } + /** + * Create a new RedirectingPlugin. + * + * @param mixed $recipient + */ + public function __construct($recipient, array $whitelist = []) + { + $this->recipient = $recipient; + $this->whitelist = $whitelist; + } - /** - * Set the recipient of all messages. - * - * @param mixed $recipient - */ - public function setRecipient($recipient) - { - $this->recipient = $recipient; - } + /** + * Set the recipient of all messages. + * + * @param mixed $recipient + */ + public function setRecipient($recipient) + { + $this->recipient = $recipient; + } - /** - * Get the recipient of all messages. - * - * @return mixed - */ - public function getRecipient() - { - return $this->recipient; - } + /** + * Get the recipient of all messages. + * + * @return mixed + */ + public function getRecipient() + { + return $this->recipient; + } - /** - * Set a list of regular expressions to whitelist certain recipients. - */ - public function setWhitelist(array $whitelist) - { - $this->whitelist = $whitelist; - } + /** + * Set a list of regular expressions to whitelist certain recipients. + */ + public function setWhitelist(array $whitelist) + { + $this->whitelist = $whitelist; + } - /** - * Get the whitelist. - * - * @return array - */ - public function getWhitelist() - { - return $this->whitelist; - } + /** + * Get the whitelist. + * + * @return array + */ + public function getWhitelist() + { + return $this->whitelist; + } - /** - * Invoked immediately before the Message is sent. - */ - public function beforeSendPerformed(Swift_Events_SendEvent $evt) - { - $message = $evt->getMessage(); - $headers = $message->getHeaders(); + /** + * Invoked immediately before the Message is sent. + */ + public function beforeSendPerformed(Swift_Events_SendEvent $evt) + { + $message = $evt->getMessage(); + $headers = $message->getHeaders(); - // conditionally save current recipients + // conditionally save current recipients - if ($headers->has('to')) { - $headers->addMailboxHeader('X-Swift-To', $message->getTo()); - } + if ($headers->has('to')) { + $headers->addMailboxHeader('X-Swift-To', $message->getTo()); + } - if ($headers->has('cc')) { - $headers->addMailboxHeader('X-Swift-Cc', $message->getCc()); - } + if ($headers->has('cc')) { + $headers->addMailboxHeader('X-Swift-Cc', $message->getCc()); + } - if ($headers->has('bcc')) { - $headers->addMailboxHeader('X-Swift-Bcc', $message->getBcc()); - } + if ($headers->has('bcc')) { + $headers->addMailboxHeader('X-Swift-Bcc', $message->getBcc()); + } - // Filter remaining headers against whitelist - $this->filterHeaderSet($headers, 'To'); - $this->filterHeaderSet($headers, 'Cc'); - $this->filterHeaderSet($headers, 'Bcc'); + // Filter remaining headers against whitelist + $this->filterHeaderSet($headers, 'To'); + $this->filterHeaderSet($headers, 'Cc'); + $this->filterHeaderSet($headers, 'Bcc'); - // Add each hard coded recipient - $to = $message->getTo(); - if (null === $to) { - $to = []; - } + // Add each hard coded recipient + $to = $message->getTo(); + if (null === $to) { + $to = []; + } - foreach ((array) $this->recipient as $recipient) { - if (!\array_key_exists($recipient, $to)) { - $message->addTo($recipient); - } - } - } + foreach ((array) $this->recipient as $recipient) { + if (!\array_key_exists($recipient, $to)) { + $message->addTo($recipient); + } + } + } - /** - * Filter header set against a whitelist of regular expressions. - * - * @param string $type - */ - private function filterHeaderSet(Swift_Mime_SimpleHeaderSet $headerSet, $type) - { - foreach ($headerSet->getAll($type) as $headers) { - $headers->setNameAddresses($this->filterNameAddresses($headers->getNameAddresses())); - } - } + /** + * Filter header set against a whitelist of regular expressions. + * + * @param string $type + */ + private function filterHeaderSet(Swift_Mime_SimpleHeaderSet $headerSet, $type) + { + foreach ($headerSet->getAll($type) as $headers) { + $headers->setNameAddresses($this->filterNameAddresses($headers->getNameAddresses())); + } + } - /** - * Filtered list of addresses => name pairs. - * - * @return array - */ - private function filterNameAddresses(array $recipients) - { - $filtered = []; + /** + * Filtered list of addresses => name pairs. + * + * @return array + */ + private function filterNameAddresses(array $recipients) + { + $filtered = []; - foreach ($recipients as $address => $name) { - if ($this->isWhitelisted($address)) { - $filtered[$address] = $name; - } - } + foreach ($recipients as $address => $name) { + if ($this->isWhitelisted($address)) { + $filtered[$address] = $name; + } + } - return $filtered; - } + return $filtered; + } - /** - * Matches address against whitelist of regular expressions. - * - * @return bool - */ - protected function isWhitelisted($recipient) - { - if (\in_array($recipient, (array) $this->recipient)) { - return true; - } + /** + * Matches address against whitelist of regular expressions. + * + * @return bool + */ + protected function isWhitelisted($recipient) + { + if (\in_array($recipient, (array) $this->recipient)) { + return true; + } - foreach ($this->whitelist as $pattern) { - if (preg_match($pattern, $recipient)) { - return true; - } - } + foreach ($this->whitelist as $pattern) { + if (preg_match($pattern, $recipient)) { + return true; + } + } - return false; - } + return false; + } - /** - * Invoked immediately after the Message is sent. - */ - public function sendPerformed(Swift_Events_SendEvent $evt) - { - $this->restoreMessage($evt->getMessage()); - } + /** + * Invoked immediately after the Message is sent. + */ + public function sendPerformed(Swift_Events_SendEvent $evt) + { + $this->restoreMessage($evt->getMessage()); + } - private function restoreMessage(Swift_Mime_SimpleMessage $message) - { - // restore original headers - $headers = $message->getHeaders(); + private function restoreMessage(Swift_Mime_SimpleMessage $message) + { + // restore original headers + $headers = $message->getHeaders(); - if ($headers->has('X-Swift-To')) { - $message->setTo($headers->get('X-Swift-To')->getNameAddresses()); - $headers->removeAll('X-Swift-To'); - } else { - $message->setTo(null); - } + if ($headers->has('X-Swift-To')) { + $message->setTo($headers->get('X-Swift-To')->getNameAddresses()); + $headers->removeAll('X-Swift-To'); + } else { + $message->setTo(null); + } - if ($headers->has('X-Swift-Cc')) { - $message->setCc($headers->get('X-Swift-Cc')->getNameAddresses()); - $headers->removeAll('X-Swift-Cc'); - } + if ($headers->has('X-Swift-Cc')) { + $message->setCc($headers->get('X-Swift-Cc')->getNameAddresses()); + $headers->removeAll('X-Swift-Cc'); + } - if ($headers->has('X-Swift-Bcc')) { - $message->setBcc($headers->get('X-Swift-Bcc')->getNameAddresses()); - $headers->removeAll('X-Swift-Bcc'); - } - } + if ($headers->has('X-Swift-Bcc')) { + $message->setBcc($headers->get('X-Swift-Bcc')->getNameAddresses()); + $headers->removeAll('X-Swift-Bcc'); + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Reporter.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Reporter.php index b8818339722..384487ba6f8 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Reporter.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Reporter.php @@ -15,17 +15,17 @@ */ interface Swift_Plugins_Reporter { - /** The recipient was accepted for delivery */ - const RESULT_PASS = 0x01; + /** The recipient was accepted for delivery */ + const RESULT_PASS = 0x01; - /** The recipient could not be accepted */ - const RESULT_FAIL = 0x10; + /** The recipient could not be accepted */ + const RESULT_FAIL = 0x10; - /** - * Notifies this ReportNotifier that $address failed or succeeded. - * - * @param string $address - * @param int $result from {@link RESULT_PASS, RESULT_FAIL} - */ - public function notify(Swift_Mime_SimpleMessage $message, $address, $result); + /** + * Notifies this ReportNotifier that $address failed or succeeded. + * + * @param string $address + * @param int $result from {@link RESULT_PASS, RESULT_FAIL} + */ + public function notify(Swift_Mime_SimpleMessage $message, $address, $result); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/ReporterPlugin.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/ReporterPlugin.php index c4a016520f6..2ac77ba2d13 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/ReporterPlugin.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/ReporterPlugin.php @@ -15,43 +15,43 @@ */ class Swift_Plugins_ReporterPlugin implements Swift_Events_SendListener { - /** - * The reporter backend which takes notifications. - * - * @var Swift_Plugins_Reporter - */ - private $reporter; + /** + * The reporter backend which takes notifications. + * + * @var Swift_Plugins_Reporter + */ + private $reporter; - /** - * Create a new ReporterPlugin using $reporter. - */ - public function __construct(Swift_Plugins_Reporter $reporter) - { - $this->reporter = $reporter; - } + /** + * Create a new ReporterPlugin using $reporter. + */ + public function __construct(Swift_Plugins_Reporter $reporter) + { + $this->reporter = $reporter; + } - /** - * Not used. - */ - public function beforeSendPerformed(Swift_Events_SendEvent $evt) - { - } + /** + * Not used. + */ + public function beforeSendPerformed(Swift_Events_SendEvent $evt) + { + } - /** - * Invoked immediately after the Message is sent. - */ - public function sendPerformed(Swift_Events_SendEvent $evt) - { - $message = $evt->getMessage(); - $failures = array_flip($evt->getFailedRecipients()); - foreach ((array) $message->getTo() as $address => $null) { - $this->reporter->notify($message, $address, (\array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS)); - } - foreach ((array) $message->getCc() as $address => $null) { - $this->reporter->notify($message, $address, (\array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS)); - } - foreach ((array) $message->getBcc() as $address => $null) { - $this->reporter->notify($message, $address, (\array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS)); - } - } + /** + * Invoked immediately after the Message is sent. + */ + public function sendPerformed(Swift_Events_SendEvent $evt) + { + $message = $evt->getMessage(); + $failures = array_flip($evt->getFailedRecipients()); + foreach ((array) $message->getTo() as $address => $null) { + $this->reporter->notify($message, $address, (\array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS)); + } + foreach ((array) $message->getCc() as $address => $null) { + $this->reporter->notify($message, $address, (\array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS)); + } + foreach ((array) $message->getBcc() as $address => $null) { + $this->reporter->notify($message, $address, (\array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS)); + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Reporters/HitReporter.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Reporters/HitReporter.php index 249cffbde7b..ef88d47119e 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Reporters/HitReporter.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Reporters/HitReporter.php @@ -15,44 +15,44 @@ */ class Swift_Plugins_Reporters_HitReporter implements Swift_Plugins_Reporter { - /** - * The list of failures. - * - * @var array - */ - private $failures = []; + /** + * The list of failures. + * + * @var array + */ + private $failures = []; - private $failures_cache = []; + private $failures_cache = []; - /** - * Notifies this ReportNotifier that $address failed or succeeded. - * - * @param string $address - * @param int $result from {@link RESULT_PASS, RESULT_FAIL} - */ - public function notify(Swift_Mime_SimpleMessage $message, $address, $result) - { - if (self::RESULT_FAIL == $result && !isset($this->failures_cache[$address])) { - $this->failures[] = $address; - $this->failures_cache[$address] = true; - } - } + /** + * Notifies this ReportNotifier that $address failed or succeeded. + * + * @param string $address + * @param int $result from {@link RESULT_PASS, RESULT_FAIL} + */ + public function notify(Swift_Mime_SimpleMessage $message, $address, $result) + { + if (self::RESULT_FAIL == $result && !isset($this->failures_cache[$address])) { + $this->failures[] = $address; + $this->failures_cache[$address] = true; + } + } - /** - * Get an array of addresses for which delivery failed. - * - * @return array - */ - public function getFailedRecipients() - { - return $this->failures; - } + /** + * Get an array of addresses for which delivery failed. + * + * @return array + */ + public function getFailedRecipients() + { + return $this->failures; + } - /** - * Clear the buffer (empty the list). - */ - public function clear() - { - $this->failures = $this->failures_cache = []; - } + /** + * Clear the buffer (empty the list). + */ + public function clear() + { + $this->failures = $this->failures_cache = []; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Reporters/HtmlReporter.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Reporters/HtmlReporter.php index 1cfc3f974f8..710a0b370dd 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Reporters/HtmlReporter.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Reporters/HtmlReporter.php @@ -15,24 +15,24 @@ */ class Swift_Plugins_Reporters_HtmlReporter implements Swift_Plugins_Reporter { - /** - * Notifies this ReportNotifier that $address failed or succeeded. - * - * @param string $address - * @param int $result from {@see RESULT_PASS, RESULT_FAIL} - */ - public function notify(Swift_Mime_SimpleMessage $message, $address, $result) - { - if (self::RESULT_PASS == $result) { - echo '
'.PHP_EOL; - echo 'PASS '.$address.PHP_EOL; - echo '
'.PHP_EOL; - flush(); - } else { - echo '
'.PHP_EOL; - echo 'FAIL '.$address.PHP_EOL; - echo '
'.PHP_EOL; - flush(); - } - } + /** + * Notifies this ReportNotifier that $address failed or succeeded. + * + * @param string $address + * @param int $result from {@see RESULT_PASS, RESULT_FAIL} + */ + public function notify(Swift_Mime_SimpleMessage $message, $address, $result) + { + if (self::RESULT_PASS == $result) { + echo '
'.PHP_EOL; + echo 'PASS '.$address.PHP_EOL; + echo '
'.PHP_EOL; + flush(); + } else { + echo '
'.PHP_EOL; + echo 'FAIL '.$address.PHP_EOL; + echo '
'.PHP_EOL; + flush(); + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/ThrottlerPlugin.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/ThrottlerPlugin.php index 83d3044927f..82c5d9fb99f 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/ThrottlerPlugin.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/ThrottlerPlugin.php @@ -15,182 +15,182 @@ */ class Swift_Plugins_ThrottlerPlugin extends Swift_Plugins_BandwidthMonitorPlugin implements Swift_Plugins_Sleeper, Swift_Plugins_Timer { - /** Flag for throttling in bytes per minute */ - const BYTES_PER_MINUTE = 0x01; + /** Flag for throttling in bytes per minute */ + const BYTES_PER_MINUTE = 0x01; - /** Flag for throttling in emails per second (Amazon SES) */ - const MESSAGES_PER_SECOND = 0x11; + /** Flag for throttling in emails per second (Amazon SES) */ + const MESSAGES_PER_SECOND = 0x11; - /** Flag for throttling in emails per minute */ - const MESSAGES_PER_MINUTE = 0x10; + /** Flag for throttling in emails per minute */ + const MESSAGES_PER_MINUTE = 0x10; - /** - * The Sleeper instance for sleeping. - * - * @var Swift_Plugins_Sleeper - */ - private $sleeper; + /** + * The Sleeper instance for sleeping. + * + * @var Swift_Plugins_Sleeper + */ + private $sleeper; - /** - * The Timer instance which provides the timestamp. - * - * @var Swift_Plugins_Timer - */ - private $timer; + /** + * The Timer instance which provides the timestamp. + * + * @var Swift_Plugins_Timer + */ + private $timer; - /** - * The time at which the first email was sent. - * - * @var int - */ - private $start; + /** + * The time at which the first email was sent. + * + * @var int + */ + private $start; - /** - * The rate at which messages should be sent. - * - * @var int - */ - private $rate; + /** + * The rate at which messages should be sent. + * + * @var int + */ + private $rate; - /** - * The mode for throttling. - * - * This is {@link BYTES_PER_MINUTE} or {@link MESSAGES_PER_MINUTE} - * - * @var int - */ - private $mode; + /** + * The mode for throttling. + * + * This is {@link BYTES_PER_MINUTE} or {@link MESSAGES_PER_MINUTE} + * + * @var int + */ + private $mode; - /** - * An internal counter of the number of messages sent. - * - * @var int - */ - private $messages = 0; + /** + * An internal counter of the number of messages sent. + * + * @var int + */ + private $messages = 0; - /** - * Create a new ThrottlerPlugin. - * - * @param int $rate - * @param int $mode defaults to {@link BYTES_PER_MINUTE} - * @param Swift_Plugins_Sleeper $sleeper (only needed in testing) - * @param Swift_Plugins_Timer $timer (only needed in testing) - */ - public function __construct($rate, $mode = self::BYTES_PER_MINUTE, Swift_Plugins_Sleeper $sleeper = null, Swift_Plugins_Timer $timer = null) - { - $this->rate = $rate; - $this->mode = $mode; - $this->sleeper = $sleeper; - $this->timer = $timer; - } + /** + * Create a new ThrottlerPlugin. + * + * @param int $rate + * @param int $mode defaults to {@link BYTES_PER_MINUTE} + * @param Swift_Plugins_Sleeper $sleeper (only needed in testing) + * @param Swift_Plugins_Timer $timer (only needed in testing) + */ + public function __construct($rate, $mode = self::BYTES_PER_MINUTE, Swift_Plugins_Sleeper $sleeper = null, Swift_Plugins_Timer $timer = null) + { + $this->rate = $rate; + $this->mode = $mode; + $this->sleeper = $sleeper; + $this->timer = $timer; + } - /** - * Invoked immediately before the Message is sent. - */ - public function beforeSendPerformed(Swift_Events_SendEvent $evt) - { - $time = $this->getTimestamp(); - if (!isset($this->start)) { - $this->start = $time; - } - $duration = $time - $this->start; + /** + * Invoked immediately before the Message is sent. + */ + public function beforeSendPerformed(Swift_Events_SendEvent $evt) + { + $time = $this->getTimestamp(); + if (!isset($this->start)) { + $this->start = $time; + } + $duration = $time - $this->start; - switch ($this->mode) { - case self::BYTES_PER_MINUTE: - $sleep = $this->throttleBytesPerMinute($duration); - break; - case self::MESSAGES_PER_SECOND: - $sleep = $this->throttleMessagesPerSecond($duration); - break; - case self::MESSAGES_PER_MINUTE: - $sleep = $this->throttleMessagesPerMinute($duration); - break; - default: - $sleep = 0; - break; - } + switch ($this->mode) { + case self::BYTES_PER_MINUTE: + $sleep = $this->throttleBytesPerMinute($duration); + break; + case self::MESSAGES_PER_SECOND: + $sleep = $this->throttleMessagesPerSecond($duration); + break; + case self::MESSAGES_PER_MINUTE: + $sleep = $this->throttleMessagesPerMinute($duration); + break; + default: + $sleep = 0; + break; + } - if ($sleep > 0) { - $this->sleep($sleep); - } - } + if ($sleep > 0) { + $this->sleep($sleep); + } + } - /** - * Invoked when a Message is sent. - */ - public function sendPerformed(Swift_Events_SendEvent $evt) - { - parent::sendPerformed($evt); - ++$this->messages; - } + /** + * Invoked when a Message is sent. + */ + public function sendPerformed(Swift_Events_SendEvent $evt) + { + parent::sendPerformed($evt); + ++$this->messages; + } - /** - * Sleep for $seconds. - * - * @param int $seconds - */ - public function sleep($seconds) - { - if (isset($this->sleeper)) { - $this->sleeper->sleep($seconds); - } else { - sleep($seconds); - } - } + /** + * Sleep for $seconds. + * + * @param int $seconds + */ + public function sleep($seconds) + { + if (isset($this->sleeper)) { + $this->sleeper->sleep($seconds); + } else { + sleep($seconds); + } + } - /** - * Get the current UNIX timestamp. - * - * @return int - */ - public function getTimestamp() - { - if (isset($this->timer)) { - return $this->timer->getTimestamp(); - } + /** + * Get the current UNIX timestamp. + * + * @return int + */ + public function getTimestamp() + { + if (isset($this->timer)) { + return $this->timer->getTimestamp(); + } - return time(); - } + return time(); + } - /** - * Get a number of seconds to sleep for. - * - * @param int $timePassed - * - * @return int - */ - private function throttleBytesPerMinute($timePassed) - { - $expectedDuration = $this->getBytesOut() / ($this->rate / 60); + /** + * Get a number of seconds to sleep for. + * + * @param int $timePassed + * + * @return int + */ + private function throttleBytesPerMinute($timePassed) + { + $expectedDuration = $this->getBytesOut() / ($this->rate / 60); - return (int) ceil($expectedDuration - $timePassed); - } + return (int) ceil($expectedDuration - $timePassed); + } - /** - * Get a number of seconds to sleep for. - * - * @param int $timePassed - * - * @return int - */ - private function throttleMessagesPerSecond($timePassed) - { - $expectedDuration = $this->messages / $this->rate; + /** + * Get a number of seconds to sleep for. + * + * @param int $timePassed + * + * @return int + */ + private function throttleMessagesPerSecond($timePassed) + { + $expectedDuration = $this->messages / $this->rate; - return (int) ceil($expectedDuration - $timePassed); - } + return (int) ceil($expectedDuration - $timePassed); + } - /** - * Get a number of seconds to sleep for. - * - * @param int $timePassed - * - * @return int - */ - private function throttleMessagesPerMinute($timePassed) - { - $expectedDuration = $this->messages / ($this->rate / 60); + /** + * Get a number of seconds to sleep for. + * + * @param int $timePassed + * + * @return int + */ + private function throttleMessagesPerMinute($timePassed) + { + $expectedDuration = $this->messages / ($this->rate / 60); - return (int) ceil($expectedDuration - $timePassed); - } + return (int) ceil($expectedDuration - $timePassed); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Preferences.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Preferences.php index 16103e11031..237824ea180 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Preferences.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Preferences.php @@ -15,86 +15,86 @@ */ class Swift_Preferences { - /** Singleton instance */ - private static $instance = null; + /** Singleton instance */ + private static $instance = null; - /** Constructor not to be used */ - private function __construct() - { - } + /** Constructor not to be used */ + private function __construct() + { + } - /** - * Gets the instance of Preferences. - * - * @return self - */ - public static function getInstance() - { - if (!isset(self::$instance)) { - self::$instance = new self(); - } + /** + * Gets the instance of Preferences. + * + * @return self + */ + public static function getInstance() + { + if (!isset(self::$instance)) { + self::$instance = new self(); + } - return self::$instance; - } + return self::$instance; + } - /** - * Set the default charset used. - * - * @param string $charset - * - * @return $this - */ - public function setCharset($charset) - { - Swift_DependencyContainer::getInstance()->register('properties.charset')->asValue($charset); + /** + * Set the default charset used. + * + * @param string $charset + * + * @return $this + */ + public function setCharset($charset) + { + Swift_DependencyContainer::getInstance()->register('properties.charset')->asValue($charset); - return $this; - } + return $this; + } - /** - * Set the directory where temporary files can be saved. - * - * @param string $dir - * - * @return $this - */ - public function setTempDir($dir) - { - Swift_DependencyContainer::getInstance()->register('tempdir')->asValue($dir); + /** + * Set the directory where temporary files can be saved. + * + * @param string $dir + * + * @return $this + */ + public function setTempDir($dir) + { + Swift_DependencyContainer::getInstance()->register('tempdir')->asValue($dir); - return $this; - } + return $this; + } - /** - * Set the type of cache to use (i.e. "disk" or "array"). - * - * @param string $type - * - * @return $this - */ - public function setCacheType($type) - { - Swift_DependencyContainer::getInstance()->register('cache')->asAliasOf(sprintf('cache.%s', $type)); + /** + * Set the type of cache to use (i.e. "disk" or "array"). + * + * @param string $type + * + * @return $this + */ + public function setCacheType($type) + { + Swift_DependencyContainer::getInstance()->register('cache')->asAliasOf(sprintf('cache.%s', $type)); - return $this; - } + return $this; + } - /** - * Set the QuotedPrintable dot escaper preference. - * - * @param bool $dotEscape - * - * @return $this - */ - public function setQPDotEscape($dotEscape) - { - $dotEscape = !empty($dotEscape); - Swift_DependencyContainer::getInstance() - ->register('mime.qpcontentencoder') - ->asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoder') - ->withDependencies(['mime.charstream', 'mime.bytecanonicalizer']) - ->addConstructorValue($dotEscape); + /** + * Set the QuotedPrintable dot escaper preference. + * + * @param bool $dotEscape + * + * @return $this + */ + public function setQPDotEscape($dotEscape) + { + $dotEscape = !empty($dotEscape); + Swift_DependencyContainer::getInstance() + ->register('mime.qpcontentencoder') + ->asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoder') + ->withDependencies(['mime.charstream', 'mime.bytecanonicalizer']) + ->addConstructorValue($dotEscape); - return $this; - } + return $this; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/SendmailTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/SendmailTransport.php index 3c756436cc8..9f159857a51 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/SendmailTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/SendmailTransport.php @@ -15,19 +15,19 @@ */ class Swift_SendmailTransport extends Swift_Transport_SendmailTransport { - /** - * Create a new SendmailTransport, optionally using $command for sending. - * - * @param string $command - */ - public function __construct($command = '/usr/sbin/sendmail -bs') - { - \call_user_func_array( - [$this, 'Swift_Transport_SendmailTransport::__construct'], - Swift_DependencyContainer::getInstance() - ->createDependenciesFor('transport.sendmail') - ); + /** + * Create a new SendmailTransport, optionally using $command for sending. + * + * @param string $command + */ + public function __construct($command = '/usr/sbin/sendmail -bs') + { + \call_user_func_array( + [$this, 'Swift_Transport_SendmailTransport::__construct'], + Swift_DependencyContainer::getInstance() + ->createDependenciesFor('transport.sendmail') + ); - $this->setCommand($command); - } + $this->setCommand($command); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Signer.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Signer.php index 26c5e285c03..4a681f83bfa 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Signer.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Signer.php @@ -15,5 +15,5 @@ */ interface Swift_Signer { - public function reset(); + public function reset(); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/BodySigner.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/BodySigner.php index b25c427af83..a874e1ab2cb 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/BodySigner.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/BodySigner.php @@ -15,17 +15,17 @@ */ interface Swift_Signers_BodySigner extends Swift_Signer { - /** - * Change the Swift_Signed_Message to apply the singing. - * - * @return self - */ - public function signMessage(Swift_Message $message); + /** + * Change the Swift_Signed_Message to apply the singing. + * + * @return self + */ + public function signMessage(Swift_Message $message); - /** - * Return the list of header a signer might tamper. - * - * @return array - */ - public function getAlteredHeaders(); + /** + * Return the list of header a signer might tamper. + * + * @return array + */ + public function getAlteredHeaders(); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/DKIMSigner.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/DKIMSigner.php index ec82dc05663..e7323cb19b9 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/DKIMSigner.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/DKIMSigner.php @@ -15,668 +15,668 @@ */ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner { - /** - * PrivateKey. - * - * @var string - */ - protected $privateKey; - - /** - * DomainName. - * - * @var string - */ - protected $domainName; - - /** - * Selector. - * - * @var string - */ - protected $selector; - - private $passphrase = ''; - - /** - * Hash algorithm used. - * - * @see RFC6376 3.3: Signers MUST implement and SHOULD sign using rsa-sha256. - * - * @var string - */ - protected $hashAlgorithm = 'rsa-sha256'; - - /** - * Body canon method. - * - * @var string - */ - protected $bodyCanon = 'simple'; - - /** - * Header canon method. - * - * @var string - */ - protected $headerCanon = 'simple'; - - /** - * Headers not being signed. - * - * @var array - */ - protected $ignoredHeaders = ['return-path' => true]; - - /** - * Signer identity. - * - * @var string - */ - protected $signerIdentity; - - /** - * BodyLength. - * - * @var int - */ - protected $bodyLen = 0; - - /** - * Maximum signedLen. - * - * @var int - */ - protected $maxLen = PHP_INT_MAX; - - /** - * Embbed bodyLen in signature. - * - * @var bool - */ - protected $showLen = false; - - /** - * When the signature has been applied (true means time()), false means not embedded. - * - * @var mixed - */ - protected $signatureTimestamp = true; - - /** - * When will the signature expires false means not embedded, if sigTimestamp is auto - * Expiration is relative, otherwise it's absolute. - * - * @var int - */ - protected $signatureExpiration = false; - - /** - * Must we embed signed headers? - * - * @var bool - */ - protected $debugHeaders = false; - - // work variables - /** - * Headers used to generate hash. - * - * @var array - */ - protected $signedHeaders = []; - - /** - * If debugHeaders is set store debugData here. - * - * @var string[] - */ - private $debugHeadersData = []; - - /** - * Stores the bodyHash. - * - * @var string - */ - private $bodyHash = ''; - - /** - * Stores the signature header. - * - * @var Swift_Mime_Headers_ParameterizedHeader - */ - protected $dkimHeader; - - private $bodyHashHandler; - - private $headerHash; - - private $headerCanonData = ''; - - private $bodyCanonEmptyCounter = 0; - - private $bodyCanonIgnoreStart = 2; - - private $bodyCanonSpace = false; - - private $bodyCanonLastChar = null; - - private $bodyCanonLine = ''; - - private $bound = []; - - /** - * Constructor. - * - * @param string $privateKey - * @param string $domainName - * @param string $selector - * @param string $passphrase - */ - public function __construct($privateKey, $domainName, $selector, $passphrase = '') - { - $this->privateKey = $privateKey; - $this->domainName = $domainName; - $this->signerIdentity = '@'.$domainName; - $this->selector = $selector; - $this->passphrase = $passphrase; - } - - /** - * Reset the Signer. - * - * @see Swift_Signer::reset() - */ - public function reset() - { - $this->headerHash = null; - $this->signedHeaders = []; - $this->bodyHash = null; - $this->bodyHashHandler = null; - $this->bodyCanonIgnoreStart = 2; - $this->bodyCanonEmptyCounter = 0; - $this->bodyCanonLastChar = null; - $this->bodyCanonSpace = false; - } - - /** - * Writes $bytes to the end of the stream. - * - * Writing may not happen immediately if the stream chooses to buffer. If - * you want to write these bytes with immediate effect, call {@link commit()} - * after calling write(). - * - * This method returns the sequence ID of the write (i.e. 1 for first, 2 for - * second, etc etc). - * - * @param string $bytes - * - * @return int - * - * @throws Swift_IoException - */ - // TODO fix return - public function write($bytes) - { - $this->canonicalizeBody($bytes); - foreach ($this->bound as $is) { - $is->write($bytes); - } - } - - /** - * For any bytes that are currently buffered inside the stream, force them - * off the buffer. - */ - public function commit() - { - // Nothing to do - return; - } - - /** - * Attach $is to this stream. - * - * The stream acts as an observer, receiving all data that is written. - * All {@link write()} and {@link flushBuffers()} operations will be mirrored. - */ - public function bind(Swift_InputByteStream $is) - { - // Don't have to mirror anything - $this->bound[] = $is; - - return; - } - - /** - * Remove an already bound stream. - * - * If $is is not bound, no errors will be raised. - * If the stream currently has any buffered data it will be written to $is - * before unbinding occurs. - */ - public function unbind(Swift_InputByteStream $is) - { - // Don't have to mirror anything - foreach ($this->bound as $k => $stream) { - if ($stream === $is) { - unset($this->bound[$k]); - - return; - } - } - } - - /** - * Flush the contents of the stream (empty it) and set the internal pointer - * to the beginning. - * - * @throws Swift_IoException - */ - public function flushBuffers() - { - $this->reset(); - } - - /** - * Set hash_algorithm, must be one of rsa-sha256 | rsa-sha1. - * - * @param string $hash 'rsa-sha1' or 'rsa-sha256' - * - * @throws Swift_SwiftException - * - * @return $this - */ - public function setHashAlgorithm($hash) - { - switch ($hash) { - case 'rsa-sha1': - $this->hashAlgorithm = 'rsa-sha1'; - break; - case 'rsa-sha256': - $this->hashAlgorithm = 'rsa-sha256'; - if (!\defined('OPENSSL_ALGO_SHA256')) { - throw new Swift_SwiftException('Unable to set sha256 as it is not supported by OpenSSL.'); - } - break; - default: - throw new Swift_SwiftException('Unable to set the hash algorithm, must be one of rsa-sha1 or rsa-sha256 (%s given).', $hash); - } - - return $this; - } - - /** - * Set the body canonicalization algorithm. - * - * @param string $canon - * - * @return $this - */ - public function setBodyCanon($canon) - { - if ('relaxed' == $canon) { - $this->bodyCanon = 'relaxed'; - } else { - $this->bodyCanon = 'simple'; - } - - return $this; - } - - /** - * Set the header canonicalization algorithm. - * - * @param string $canon - * - * @return $this - */ - public function setHeaderCanon($canon) - { - if ('relaxed' == $canon) { - $this->headerCanon = 'relaxed'; - } else { - $this->headerCanon = 'simple'; - } - - return $this; - } - - /** - * Set the signer identity. - * - * @param string $identity - * - * @return $this - */ - public function setSignerIdentity($identity) - { - $this->signerIdentity = $identity; - - return $this; - } - - /** - * Set the length of the body to sign. - * - * @param mixed $len (bool or int) - * - * @return $this - */ - public function setBodySignedLen($len) - { - if (true === $len) { - $this->showLen = true; - $this->maxLen = PHP_INT_MAX; - } elseif (false === $len) { - $this->showLen = false; - $this->maxLen = PHP_INT_MAX; - } else { - $this->showLen = true; - $this->maxLen = (int) $len; - } - - return $this; - } - - /** - * Set the signature timestamp. - * - * @param int $time A timestamp - * - * @return $this - */ - public function setSignatureTimestamp($time) - { - $this->signatureTimestamp = $time; - - return $this; - } - - /** - * Set the signature expiration timestamp. - * - * @param int $time A timestamp - * - * @return $this - */ - public function setSignatureExpiration($time) - { - $this->signatureExpiration = $time; - - return $this; - } - - /** - * Enable / disable the DebugHeaders. - * - * @param bool $debug - * - * @return Swift_Signers_DKIMSigner - */ - public function setDebugHeaders($debug) - { - $this->debugHeaders = (bool) $debug; - - return $this; - } - - /** - * Start Body. - */ - public function startBody() - { - // Init - switch ($this->hashAlgorithm) { - case 'rsa-sha256': - $this->bodyHashHandler = hash_init('sha256'); - break; - case 'rsa-sha1': - $this->bodyHashHandler = hash_init('sha1'); - break; - } - $this->bodyCanonLine = ''; - } - - /** - * End Body. - */ - public function endBody() - { - $this->endOfBody(); - } - - /** - * Returns the list of Headers Tampered by this plugin. - * - * @return array - */ - public function getAlteredHeaders() - { - if ($this->debugHeaders) { - return ['DKIM-Signature', 'X-DebugHash']; - } else { - return ['DKIM-Signature']; - } - } - - /** - * Adds an ignored Header. - * - * @param string $header_name - * - * @return Swift_Signers_DKIMSigner - */ - public function ignoreHeader($header_name) - { - $this->ignoredHeaders[strtolower($header_name ?? '')] = true; - - return $this; - } - - /** - * Set the headers to sign. - * - * @return Swift_Signers_DKIMSigner - */ - public function setHeaders(Swift_Mime_SimpleHeaderSet $headers) - { - $this->headerCanonData = ''; - // Loop through Headers - $listHeaders = $headers->listAll(); - foreach ($listHeaders as $hName) { - // Check if we need to ignore Header - if (!isset($this->ignoredHeaders[strtolower($hName ?? '')])) { - if ($headers->has($hName)) { - $tmp = $headers->getAll($hName); - foreach ($tmp as $header) { - if ('' != $header->getFieldBody()) { - $this->addHeader($header->toString()); - $this->signedHeaders[] = $header->getFieldName(); - } - } - } - } - } - - return $this; - } - - /** - * Add the signature to the given Headers. - * - * @return Swift_Signers_DKIMSigner - */ - public function addSignature(Swift_Mime_SimpleHeaderSet $headers) - { - // Prepare the DKIM-Signature - $params = ['v' => '1', 'a' => $this->hashAlgorithm, 'bh' => base64_encode($this->bodyHash ?? ''), 'd' => $this->domainName, 'h' => implode(': ', $this->signedHeaders), 'i' => $this->signerIdentity, 's' => $this->selector]; - if ('simple' != $this->bodyCanon) { - $params['c'] = $this->headerCanon.'/'.$this->bodyCanon; - } elseif ('simple' != $this->headerCanon) { - $params['c'] = $this->headerCanon; - } - if ($this->showLen) { - $params['l'] = $this->bodyLen; - } - if (true === $this->signatureTimestamp) { - $params['t'] = time(); - if (false !== $this->signatureExpiration) { - $params['x'] = $params['t'] + $this->signatureExpiration; - } - } else { - if (false !== $this->signatureTimestamp) { - $params['t'] = $this->signatureTimestamp; - } - if (false !== $this->signatureExpiration) { - $params['x'] = $this->signatureExpiration; - } - } - if ($this->debugHeaders) { - $params['z'] = implode('|', $this->debugHeadersData); - } - $string = ''; - foreach ($params as $k => $v) { - $string .= $k.'='.$v.'; '; - } - $string = trim($string); - $headers->addTextHeader('DKIM-Signature', $string); - // Add the last DKIM-Signature - $tmp = $headers->getAll('DKIM-Signature'); - $this->dkimHeader = end($tmp); - $this->addHeader(trim($this->dkimHeader->toString() ?? '')."\r\n b=", true); - if ($this->debugHeaders) { - $headers->addTextHeader('X-DebugHash', base64_encode($this->headerHash ?? '')); - } - $this->dkimHeader->setValue($string.' b='.trim(chunk_split(base64_encode($this->getEncryptedHash() ?? ''), 73, ' '))); - - return $this; - } - - /* Private helpers */ - - protected function addHeader($header, $is_sig = false) - { - switch ($this->headerCanon) { - case 'relaxed': - // Prepare Header and cascade - $exploded = explode(':', $header, 2); - $name = strtolower(trim($exploded[0])); - $value = str_replace("\r\n", '', $exploded[1]); - $value = preg_replace("/[ \t][ \t]+/", ' ', $value); - $header = $name.':'.trim($value).($is_sig ? '' : "\r\n"); - // no break - case 'simple': - // Nothing to do - } - $this->addToHeaderHash($header); - } - - protected function canonicalizeBody($string) - { - $len = \strlen($string); - $canon = ''; - $method = ('relaxed' == $this->bodyCanon); - for ($i = 0; $i < $len; ++$i) { - if ($this->bodyCanonIgnoreStart > 0) { - --$this->bodyCanonIgnoreStart; - continue; - } - switch ($string[$i]) { - case "\r": - $this->bodyCanonLastChar = "\r"; - break; - case "\n": - if ("\r" == $this->bodyCanonLastChar) { - if ($method) { - $this->bodyCanonSpace = false; - } - if ('' == $this->bodyCanonLine) { - ++$this->bodyCanonEmptyCounter; - } else { - $this->bodyCanonLine = ''; - $canon .= "\r\n"; - } - } else { - // Wooops Error - // todo handle it but should never happen - } - break; - case ' ': - case "\t": - if ($method) { - $this->bodyCanonSpace = true; - break; - } - // no break - default: - if ($this->bodyCanonEmptyCounter > 0) { - $canon .= str_repeat("\r\n", $this->bodyCanonEmptyCounter); - $this->bodyCanonEmptyCounter = 0; - } - if ($this->bodyCanonSpace) { - $this->bodyCanonLine .= ' '; - $canon .= ' '; - $this->bodyCanonSpace = false; - } - $this->bodyCanonLine .= $string[$i]; - $canon .= $string[$i]; - } - } - $this->addToBodyHash($canon); - } - - protected function endOfBody() - { - // Add trailing Line return if last line is non empty - if (\strlen($this->bodyCanonLine) > 0) { - $this->addToBodyHash("\r\n"); - } - $this->bodyHash = hash_final($this->bodyHashHandler, true); - } - - private function addToBodyHash($string) - { - $len = \strlen($string); - if ($len > ($new_len = ($this->maxLen - $this->bodyLen))) { - $string = substr($string, 0, $new_len); - $len = $new_len; - } - hash_update($this->bodyHashHandler, $string); - $this->bodyLen += $len; - } - - private function addToHeaderHash($header) - { - if ($this->debugHeaders) { - $this->debugHeadersData[] = trim($header ?? ''); - } - $this->headerCanonData .= $header; - } - - /** - * @throws Swift_SwiftException - * - * @return string - */ - private function getEncryptedHash() - { - $signature = ''; - switch ($this->hashAlgorithm) { - case 'rsa-sha1': - $algorithm = OPENSSL_ALGO_SHA1; - break; - case 'rsa-sha256': - $algorithm = OPENSSL_ALGO_SHA256; - break; - } - $pkeyId = openssl_get_privatekey($this->privateKey, $this->passphrase); - if (!$pkeyId) { - throw new Swift_SwiftException('Unable to load DKIM Private Key ['.openssl_error_string().']'); - } - if (openssl_sign($this->headerCanonData, $signature, $pkeyId, $algorithm)) { - return $signature; - } - throw new Swift_SwiftException('Unable to sign DKIM Hash ['.openssl_error_string().']'); - } + /** + * PrivateKey. + * + * @var string + */ + protected $privateKey; + + /** + * DomainName. + * + * @var string + */ + protected $domainName; + + /** + * Selector. + * + * @var string + */ + protected $selector; + + private $passphrase = ''; + + /** + * Hash algorithm used. + * + * @see RFC6376 3.3: Signers MUST implement and SHOULD sign using rsa-sha256. + * + * @var string + */ + protected $hashAlgorithm = 'rsa-sha256'; + + /** + * Body canon method. + * + * @var string + */ + protected $bodyCanon = 'simple'; + + /** + * Header canon method. + * + * @var string + */ + protected $headerCanon = 'simple'; + + /** + * Headers not being signed. + * + * @var array + */ + protected $ignoredHeaders = ['return-path' => true]; + + /** + * Signer identity. + * + * @var string + */ + protected $signerIdentity; + + /** + * BodyLength. + * + * @var int + */ + protected $bodyLen = 0; + + /** + * Maximum signedLen. + * + * @var int + */ + protected $maxLen = PHP_INT_MAX; + + /** + * Embbed bodyLen in signature. + * + * @var bool + */ + protected $showLen = false; + + /** + * When the signature has been applied (true means time()), false means not embedded. + * + * @var mixed + */ + protected $signatureTimestamp = true; + + /** + * When will the signature expires false means not embedded, if sigTimestamp is auto + * Expiration is relative, otherwise it's absolute. + * + * @var int + */ + protected $signatureExpiration = false; + + /** + * Must we embed signed headers? + * + * @var bool + */ + protected $debugHeaders = false; + + // work variables + /** + * Headers used to generate hash. + * + * @var array + */ + protected $signedHeaders = []; + + /** + * If debugHeaders is set store debugData here. + * + * @var string[] + */ + private $debugHeadersData = []; + + /** + * Stores the bodyHash. + * + * @var string + */ + private $bodyHash = ''; + + /** + * Stores the signature header. + * + * @var Swift_Mime_Headers_ParameterizedHeader + */ + protected $dkimHeader; + + private $bodyHashHandler; + + private $headerHash; + + private $headerCanonData = ''; + + private $bodyCanonEmptyCounter = 0; + + private $bodyCanonIgnoreStart = 2; + + private $bodyCanonSpace = false; + + private $bodyCanonLastChar = null; + + private $bodyCanonLine = ''; + + private $bound = []; + + /** + * Constructor. + * + * @param string $privateKey + * @param string $domainName + * @param string $selector + * @param string $passphrase + */ + public function __construct($privateKey, $domainName, $selector, $passphrase = '') + { + $this->privateKey = $privateKey; + $this->domainName = $domainName; + $this->signerIdentity = '@'.$domainName; + $this->selector = $selector; + $this->passphrase = $passphrase; + } + + /** + * Reset the Signer. + * + * @see Swift_Signer::reset() + */ + public function reset() + { + $this->headerHash = null; + $this->signedHeaders = []; + $this->bodyHash = null; + $this->bodyHashHandler = null; + $this->bodyCanonIgnoreStart = 2; + $this->bodyCanonEmptyCounter = 0; + $this->bodyCanonLastChar = null; + $this->bodyCanonSpace = false; + } + + /** + * Writes $bytes to the end of the stream. + * + * Writing may not happen immediately if the stream chooses to buffer. If + * you want to write these bytes with immediate effect, call {@link commit()} + * after calling write(). + * + * This method returns the sequence ID of the write (i.e. 1 for first, 2 for + * second, etc etc). + * + * @param string $bytes + * + * @return int + * + * @throws Swift_IoException + */ + // TODO fix return + public function write($bytes) + { + $this->canonicalizeBody($bytes); + foreach ($this->bound as $is) { + $is->write($bytes); + } + } + + /** + * For any bytes that are currently buffered inside the stream, force them + * off the buffer. + */ + public function commit() + { + // Nothing to do + return; + } + + /** + * Attach $is to this stream. + * + * The stream acts as an observer, receiving all data that is written. + * All {@link write()} and {@link flushBuffers()} operations will be mirrored. + */ + public function bind(Swift_InputByteStream $is) + { + // Don't have to mirror anything + $this->bound[] = $is; + + return; + } + + /** + * Remove an already bound stream. + * + * If $is is not bound, no errors will be raised. + * If the stream currently has any buffered data it will be written to $is + * before unbinding occurs. + */ + public function unbind(Swift_InputByteStream $is) + { + // Don't have to mirror anything + foreach ($this->bound as $k => $stream) { + if ($stream === $is) { + unset($this->bound[$k]); + + return; + } + } + } + + /** + * Flush the contents of the stream (empty it) and set the internal pointer + * to the beginning. + * + * @throws Swift_IoException + */ + public function flushBuffers() + { + $this->reset(); + } + + /** + * Set hash_algorithm, must be one of rsa-sha256 | rsa-sha1. + * + * @param string $hash 'rsa-sha1' or 'rsa-sha256' + * + * @throws Swift_SwiftException + * + * @return $this + */ + public function setHashAlgorithm($hash) + { + switch ($hash) { + case 'rsa-sha1': + $this->hashAlgorithm = 'rsa-sha1'; + break; + case 'rsa-sha256': + $this->hashAlgorithm = 'rsa-sha256'; + if (!\defined('OPENSSL_ALGO_SHA256')) { + throw new Swift_SwiftException('Unable to set sha256 as it is not supported by OpenSSL.'); + } + break; + default: + throw new Swift_SwiftException('Unable to set the hash algorithm, must be one of rsa-sha1 or rsa-sha256 (%s given).', $hash); + } + + return $this; + } + + /** + * Set the body canonicalization algorithm. + * + * @param string $canon + * + * @return $this + */ + public function setBodyCanon($canon) + { + if ('relaxed' == $canon) { + $this->bodyCanon = 'relaxed'; + } else { + $this->bodyCanon = 'simple'; + } + + return $this; + } + + /** + * Set the header canonicalization algorithm. + * + * @param string $canon + * + * @return $this + */ + public function setHeaderCanon($canon) + { + if ('relaxed' == $canon) { + $this->headerCanon = 'relaxed'; + } else { + $this->headerCanon = 'simple'; + } + + return $this; + } + + /** + * Set the signer identity. + * + * @param string $identity + * + * @return $this + */ + public function setSignerIdentity($identity) + { + $this->signerIdentity = $identity; + + return $this; + } + + /** + * Set the length of the body to sign. + * + * @param mixed $len (bool or int) + * + * @return $this + */ + public function setBodySignedLen($len) + { + if (true === $len) { + $this->showLen = true; + $this->maxLen = PHP_INT_MAX; + } elseif (false === $len) { + $this->showLen = false; + $this->maxLen = PHP_INT_MAX; + } else { + $this->showLen = true; + $this->maxLen = (int) $len; + } + + return $this; + } + + /** + * Set the signature timestamp. + * + * @param int $time A timestamp + * + * @return $this + */ + public function setSignatureTimestamp($time) + { + $this->signatureTimestamp = $time; + + return $this; + } + + /** + * Set the signature expiration timestamp. + * + * @param int $time A timestamp + * + * @return $this + */ + public function setSignatureExpiration($time) + { + $this->signatureExpiration = $time; + + return $this; + } + + /** + * Enable / disable the DebugHeaders. + * + * @param bool $debug + * + * @return Swift_Signers_DKIMSigner + */ + public function setDebugHeaders($debug) + { + $this->debugHeaders = (bool) $debug; + + return $this; + } + + /** + * Start Body. + */ + public function startBody() + { + // Init + switch ($this->hashAlgorithm) { + case 'rsa-sha256': + $this->bodyHashHandler = hash_init('sha256'); + break; + case 'rsa-sha1': + $this->bodyHashHandler = hash_init('sha1'); + break; + } + $this->bodyCanonLine = ''; + } + + /** + * End Body. + */ + public function endBody() + { + $this->endOfBody(); + } + + /** + * Returns the list of Headers Tampered by this plugin. + * + * @return array + */ + public function getAlteredHeaders() + { + if ($this->debugHeaders) { + return ['DKIM-Signature', 'X-DebugHash']; + } else { + return ['DKIM-Signature']; + } + } + + /** + * Adds an ignored Header. + * + * @param string $header_name + * + * @return Swift_Signers_DKIMSigner + */ + public function ignoreHeader($header_name) + { + $this->ignoredHeaders[strtolower($header_name ?? '')] = true; + + return $this; + } + + /** + * Set the headers to sign. + * + * @return Swift_Signers_DKIMSigner + */ + public function setHeaders(Swift_Mime_SimpleHeaderSet $headers) + { + $this->headerCanonData = ''; + // Loop through Headers + $listHeaders = $headers->listAll(); + foreach ($listHeaders as $hName) { + // Check if we need to ignore Header + if (!isset($this->ignoredHeaders[strtolower($hName ?? '')])) { + if ($headers->has($hName)) { + $tmp = $headers->getAll($hName); + foreach ($tmp as $header) { + if ('' != $header->getFieldBody()) { + $this->addHeader($header->toString()); + $this->signedHeaders[] = $header->getFieldName(); + } + } + } + } + } + + return $this; + } + + /** + * Add the signature to the given Headers. + * + * @return Swift_Signers_DKIMSigner + */ + public function addSignature(Swift_Mime_SimpleHeaderSet $headers) + { + // Prepare the DKIM-Signature + $params = ['v' => '1', 'a' => $this->hashAlgorithm, 'bh' => base64_encode($this->bodyHash ?? ''), 'd' => $this->domainName, 'h' => implode(': ', $this->signedHeaders), 'i' => $this->signerIdentity, 's' => $this->selector]; + if ('simple' != $this->bodyCanon) { + $params['c'] = $this->headerCanon.'/'.$this->bodyCanon; + } elseif ('simple' != $this->headerCanon) { + $params['c'] = $this->headerCanon; + } + if ($this->showLen) { + $params['l'] = $this->bodyLen; + } + if (true === $this->signatureTimestamp) { + $params['t'] = time(); + if (false !== $this->signatureExpiration) { + $params['x'] = $params['t'] + $this->signatureExpiration; + } + } else { + if (false !== $this->signatureTimestamp) { + $params['t'] = $this->signatureTimestamp; + } + if (false !== $this->signatureExpiration) { + $params['x'] = $this->signatureExpiration; + } + } + if ($this->debugHeaders) { + $params['z'] = implode('|', $this->debugHeadersData); + } + $string = ''; + foreach ($params as $k => $v) { + $string .= $k.'='.$v.'; '; + } + $string = trim($string); + $headers->addTextHeader('DKIM-Signature', $string); + // Add the last DKIM-Signature + $tmp = $headers->getAll('DKIM-Signature'); + $this->dkimHeader = end($tmp); + $this->addHeader(trim($this->dkimHeader->toString() ?? '')."\r\n b=", true); + if ($this->debugHeaders) { + $headers->addTextHeader('X-DebugHash', base64_encode($this->headerHash ?? '')); + } + $this->dkimHeader->setValue($string.' b='.trim(chunk_split(base64_encode($this->getEncryptedHash() ?? ''), 73, ' '))); + + return $this; + } + + /* Private helpers */ + + protected function addHeader($header, $is_sig = false) + { + switch ($this->headerCanon) { + case 'relaxed': + // Prepare Header and cascade + $exploded = explode(':', $header, 2); + $name = strtolower(trim($exploded[0])); + $value = str_replace("\r\n", '', $exploded[1]); + $value = preg_replace("/[ \t][ \t]+/", ' ', $value); + $header = $name.':'.trim($value).($is_sig ? '' : "\r\n"); + // no break + case 'simple': + // Nothing to do + } + $this->addToHeaderHash($header); + } + + protected function canonicalizeBody($string) + { + $len = \strlen($string); + $canon = ''; + $method = ('relaxed' == $this->bodyCanon); + for ($i = 0; $i < $len; ++$i) { + if ($this->bodyCanonIgnoreStart > 0) { + --$this->bodyCanonIgnoreStart; + continue; + } + switch ($string[$i]) { + case "\r": + $this->bodyCanonLastChar = "\r"; + break; + case "\n": + if ("\r" == $this->bodyCanonLastChar) { + if ($method) { + $this->bodyCanonSpace = false; + } + if ('' == $this->bodyCanonLine) { + ++$this->bodyCanonEmptyCounter; + } else { + $this->bodyCanonLine = ''; + $canon .= "\r\n"; + } + } else { + // Wooops Error + // todo handle it but should never happen + } + break; + case ' ': + case "\t": + if ($method) { + $this->bodyCanonSpace = true; + break; + } + // no break + default: + if ($this->bodyCanonEmptyCounter > 0) { + $canon .= str_repeat("\r\n", $this->bodyCanonEmptyCounter); + $this->bodyCanonEmptyCounter = 0; + } + if ($this->bodyCanonSpace) { + $this->bodyCanonLine .= ' '; + $canon .= ' '; + $this->bodyCanonSpace = false; + } + $this->bodyCanonLine .= $string[$i]; + $canon .= $string[$i]; + } + } + $this->addToBodyHash($canon); + } + + protected function endOfBody() + { + // Add trailing Line return if last line is non empty + if (\strlen($this->bodyCanonLine) > 0) { + $this->addToBodyHash("\r\n"); + } + $this->bodyHash = hash_final($this->bodyHashHandler, true); + } + + private function addToBodyHash($string) + { + $len = \strlen($string); + if ($len > ($new_len = ($this->maxLen - $this->bodyLen))) { + $string = substr($string, 0, $new_len); + $len = $new_len; + } + hash_update($this->bodyHashHandler, $string); + $this->bodyLen += $len; + } + + private function addToHeaderHash($header) + { + if ($this->debugHeaders) { + $this->debugHeadersData[] = trim($header ?? ''); + } + $this->headerCanonData .= $header; + } + + /** + * @throws Swift_SwiftException + * + * @return string + */ + private function getEncryptedHash() + { + $signature = ''; + switch ($this->hashAlgorithm) { + case 'rsa-sha1': + $algorithm = OPENSSL_ALGO_SHA1; + break; + case 'rsa-sha256': + $algorithm = OPENSSL_ALGO_SHA256; + break; + } + $pkeyId = openssl_get_privatekey($this->privateKey, $this->passphrase); + if (!$pkeyId) { + throw new Swift_SwiftException('Unable to load DKIM Private Key ['.openssl_error_string().']'); + } + if (openssl_sign($this->headerCanonData, $signature, $pkeyId, $algorithm)) { + return $signature; + } + throw new Swift_SwiftException('Unable to sign DKIM Hash ['.openssl_error_string().']'); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/DomainKeySigner.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/DomainKeySigner.php index 5e2b67b6520..884996b40eb 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/DomainKeySigner.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/DomainKeySigner.php @@ -15,490 +15,490 @@ */ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner { - /** - * PrivateKey. - * - * @var string - */ - protected $privateKey; + /** + * PrivateKey. + * + * @var string + */ + protected $privateKey; - /** - * DomainName. - * - * @var string - */ - protected $domainName; + /** + * DomainName. + * + * @var string + */ + protected $domainName; - /** - * Selector. - * - * @var string - */ - protected $selector; + /** + * Selector. + * + * @var string + */ + protected $selector; - /** - * Hash algorithm used. - * - * @var string - */ - protected $hashAlgorithm = 'rsa-sha1'; + /** + * Hash algorithm used. + * + * @var string + */ + protected $hashAlgorithm = 'rsa-sha1'; - /** - * Canonisation method. - * - * @var string - */ - protected $canon = 'simple'; + /** + * Canonisation method. + * + * @var string + */ + protected $canon = 'simple'; - /** - * Headers not being signed. - * - * @var array - */ - protected $ignoredHeaders = []; + /** + * Headers not being signed. + * + * @var array + */ + protected $ignoredHeaders = []; - /** - * Signer identity. - * - * @var string - */ - protected $signerIdentity; + /** + * Signer identity. + * + * @var string + */ + protected $signerIdentity; - /** - * Must we embed signed headers? - * - * @var bool - */ - protected $debugHeaders = false; + /** + * Must we embed signed headers? + * + * @var bool + */ + protected $debugHeaders = false; - // work variables - /** - * Headers used to generate hash. - * - * @var array - */ - private $signedHeaders = []; + // work variables + /** + * Headers used to generate hash. + * + * @var array + */ + private $signedHeaders = []; - /** - * Stores the signature header. - * - * @var Swift_Mime_Headers_ParameterizedHeader - */ - protected $domainKeyHeader; + /** + * Stores the signature header. + * + * @var Swift_Mime_Headers_ParameterizedHeader + */ + protected $domainKeyHeader; - /** - * Hash Handler. - * - * @var resource|null - */ - private $hashHandler; + /** + * Hash Handler. + * + * @var resource|null + */ + private $hashHandler; - private $canonData = ''; + private $canonData = ''; - private $bodyCanonEmptyCounter = 0; + private $bodyCanonEmptyCounter = 0; - private $bodyCanonIgnoreStart = 2; + private $bodyCanonIgnoreStart = 2; - private $bodyCanonSpace = false; + private $bodyCanonSpace = false; - private $bodyCanonLastChar = null; + private $bodyCanonLastChar = null; - private $bodyCanonLine = ''; + private $bodyCanonLine = ''; - private $bound = []; + private $bound = []; - /** - * Constructor. - * - * @param string $privateKey - * @param string $domainName - * @param string $selector - */ - public function __construct($privateKey, $domainName, $selector) - { - $this->privateKey = $privateKey; - $this->domainName = $domainName; - $this->signerIdentity = '@'.$domainName; - $this->selector = $selector; - } + /** + * Constructor. + * + * @param string $privateKey + * @param string $domainName + * @param string $selector + */ + public function __construct($privateKey, $domainName, $selector) + { + $this->privateKey = $privateKey; + $this->domainName = $domainName; + $this->signerIdentity = '@'.$domainName; + $this->selector = $selector; + } - /** - * Resets internal states. - * - * @return $this - */ - public function reset() - { - $this->hashHandler = null; - $this->bodyCanonIgnoreStart = 2; - $this->bodyCanonEmptyCounter = 0; - $this->bodyCanonLastChar = null; - $this->bodyCanonSpace = false; + /** + * Resets internal states. + * + * @return $this + */ + public function reset() + { + $this->hashHandler = null; + $this->bodyCanonIgnoreStart = 2; + $this->bodyCanonEmptyCounter = 0; + $this->bodyCanonLastChar = null; + $this->bodyCanonSpace = false; - return $this; - } + return $this; + } - /** - * Writes $bytes to the end of the stream. - * - * Writing may not happen immediately if the stream chooses to buffer. If - * you want to write these bytes with immediate effect, call {@link commit()} - * after calling write(). - * - * This method returns the sequence ID of the write (i.e. 1 for first, 2 for - * second, etc etc). - * - * @param string $bytes - * - * @return int - * - * @throws Swift_IoException - * - * @return $this - */ - public function write($bytes) - { - $this->canonicalizeBody($bytes); - foreach ($this->bound as $is) { - $is->write($bytes); - } + /** + * Writes $bytes to the end of the stream. + * + * Writing may not happen immediately if the stream chooses to buffer. If + * you want to write these bytes with immediate effect, call {@link commit()} + * after calling write(). + * + * This method returns the sequence ID of the write (i.e. 1 for first, 2 for + * second, etc etc). + * + * @param string $bytes + * + * @return int + * + * @throws Swift_IoException + * + * @return $this + */ + public function write($bytes) + { + $this->canonicalizeBody($bytes); + foreach ($this->bound as $is) { + $is->write($bytes); + } - return $this; - } + return $this; + } - /** - * For any bytes that are currently buffered inside the stream, force them - * off the buffer. - * - * @throws Swift_IoException - * - * @return $this - */ - public function commit() - { - // Nothing to do - return $this; - } + /** + * For any bytes that are currently buffered inside the stream, force them + * off the buffer. + * + * @throws Swift_IoException + * + * @return $this + */ + public function commit() + { + // Nothing to do + return $this; + } - /** - * Attach $is to this stream. - * - * The stream acts as an observer, receiving all data that is written. - * All {@link write()} and {@link flushBuffers()} operations will be mirrored. - * - * @return $this - */ - public function bind(Swift_InputByteStream $is) - { - // Don't have to mirror anything - $this->bound[] = $is; + /** + * Attach $is to this stream. + * + * The stream acts as an observer, receiving all data that is written. + * All {@link write()} and {@link flushBuffers()} operations will be mirrored. + * + * @return $this + */ + public function bind(Swift_InputByteStream $is) + { + // Don't have to mirror anything + $this->bound[] = $is; - return $this; - } + return $this; + } - /** - * Remove an already bound stream. - * - * If $is is not bound, no errors will be raised. - * If the stream currently has any buffered data it will be written to $is - * before unbinding occurs. - * - * @return $this - */ - public function unbind(Swift_InputByteStream $is) - { - // Don't have to mirror anything - foreach ($this->bound as $k => $stream) { - if ($stream === $is) { - unset($this->bound[$k]); + /** + * Remove an already bound stream. + * + * If $is is not bound, no errors will be raised. + * If the stream currently has any buffered data it will be written to $is + * before unbinding occurs. + * + * @return $this + */ + public function unbind(Swift_InputByteStream $is) + { + // Don't have to mirror anything + foreach ($this->bound as $k => $stream) { + if ($stream === $is) { + unset($this->bound[$k]); - break; - } - } + break; + } + } - return $this; - } + return $this; + } - /** - * Flush the contents of the stream (empty it) and set the internal pointer - * to the beginning. - * - * @throws Swift_IoException - * - * @return $this - */ - public function flushBuffers() - { - $this->reset(); + /** + * Flush the contents of the stream (empty it) and set the internal pointer + * to the beginning. + * + * @throws Swift_IoException + * + * @return $this + */ + public function flushBuffers() + { + $this->reset(); - return $this; - } + return $this; + } - /** - * Set hash_algorithm, must be one of rsa-sha256 | rsa-sha1 defaults to rsa-sha256. - * - * @param string $hash - * - * @return $this - */ - public function setHashAlgorithm($hash) - { - $this->hashAlgorithm = 'rsa-sha1'; + /** + * Set hash_algorithm, must be one of rsa-sha256 | rsa-sha1 defaults to rsa-sha256. + * + * @param string $hash + * + * @return $this + */ + public function setHashAlgorithm($hash) + { + $this->hashAlgorithm = 'rsa-sha1'; - return $this; - } + return $this; + } - /** - * Set the canonicalization algorithm. - * - * @param string $canon simple | nofws defaults to simple - * - * @return $this - */ - public function setCanon($canon) - { - if ('nofws' == $canon) { - $this->canon = 'nofws'; - } else { - $this->canon = 'simple'; - } + /** + * Set the canonicalization algorithm. + * + * @param string $canon simple | nofws defaults to simple + * + * @return $this + */ + public function setCanon($canon) + { + if ('nofws' == $canon) { + $this->canon = 'nofws'; + } else { + $this->canon = 'simple'; + } - return $this; - } + return $this; + } - /** - * Set the signer identity. - * - * @param string $identity - * - * @return $this - */ - public function setSignerIdentity($identity) - { - $this->signerIdentity = $identity; + /** + * Set the signer identity. + * + * @param string $identity + * + * @return $this + */ + public function setSignerIdentity($identity) + { + $this->signerIdentity = $identity; - return $this; - } + return $this; + } - /** - * Enable / disable the DebugHeaders. - * - * @param bool $debug - * - * @return $this - */ - public function setDebugHeaders($debug) - { - $this->debugHeaders = (bool) $debug; + /** + * Enable / disable the DebugHeaders. + * + * @param bool $debug + * + * @return $this + */ + public function setDebugHeaders($debug) + { + $this->debugHeaders = (bool) $debug; - return $this; - } + return $this; + } - /** - * Start Body. - */ - public function startBody() - { - } + /** + * Start Body. + */ + public function startBody() + { + } - /** - * End Body. - */ - public function endBody() - { - $this->endOfBody(); - } + /** + * End Body. + */ + public function endBody() + { + $this->endOfBody(); + } - /** - * Returns the list of Headers Tampered by this plugin. - * - * @return array - */ - public function getAlteredHeaders() - { - if ($this->debugHeaders) { - return ['DomainKey-Signature', 'X-DebugHash']; - } + /** + * Returns the list of Headers Tampered by this plugin. + * + * @return array + */ + public function getAlteredHeaders() + { + if ($this->debugHeaders) { + return ['DomainKey-Signature', 'X-DebugHash']; + } - return ['DomainKey-Signature']; - } + return ['DomainKey-Signature']; + } - /** - * Adds an ignored Header. - * - * @param string $header_name - * - * @return $this - */ - public function ignoreHeader($header_name) - { - $this->ignoredHeaders[strtolower($header_name ?? '')] = true; + /** + * Adds an ignored Header. + * + * @param string $header_name + * + * @return $this + */ + public function ignoreHeader($header_name) + { + $this->ignoredHeaders[strtolower($header_name ?? '')] = true; - return $this; - } + return $this; + } - /** - * Set the headers to sign. - * - * @return $this - */ - public function setHeaders(Swift_Mime_SimpleHeaderSet $headers) - { - $this->startHash(); - $this->canonData = ''; - // Loop through Headers - $listHeaders = $headers->listAll(); - foreach ($listHeaders as $hName) { - // Check if we need to ignore Header - if (!isset($this->ignoredHeaders[strtolower($hName ?? '')])) { - if ($headers->has($hName)) { - $tmp = $headers->getAll($hName); - foreach ($tmp as $header) { - if ('' != $header->getFieldBody()) { - $this->addHeader($header->toString()); - $this->signedHeaders[] = $header->getFieldName(); - } - } - } - } - } - $this->endOfHeaders(); + /** + * Set the headers to sign. + * + * @return $this + */ + public function setHeaders(Swift_Mime_SimpleHeaderSet $headers) + { + $this->startHash(); + $this->canonData = ''; + // Loop through Headers + $listHeaders = $headers->listAll(); + foreach ($listHeaders as $hName) { + // Check if we need to ignore Header + if (!isset($this->ignoredHeaders[strtolower($hName ?? '')])) { + if ($headers->has($hName)) { + $tmp = $headers->getAll($hName); + foreach ($tmp as $header) { + if ('' != $header->getFieldBody()) { + $this->addHeader($header->toString()); + $this->signedHeaders[] = $header->getFieldName(); + } + } + } + } + } + $this->endOfHeaders(); - return $this; - } + return $this; + } - /** - * Add the signature to the given Headers. - * - * @return $this - */ - public function addSignature(Swift_Mime_SimpleHeaderSet $headers) - { - // Prepare the DomainKey-Signature Header - $params = ['a' => $this->hashAlgorithm, 'b' => chunk_split(base64_encode($this->getEncryptedHash() ?? ''), 73, ' '), 'c' => $this->canon, 'd' => $this->domainName, 'h' => implode(': ', $this->signedHeaders), 'q' => 'dns', 's' => $this->selector]; - $string = ''; - foreach ($params as $k => $v) { - $string .= $k.'='.$v.'; '; - } - $string = trim($string); - $headers->addTextHeader('DomainKey-Signature', $string); + /** + * Add the signature to the given Headers. + * + * @return $this + */ + public function addSignature(Swift_Mime_SimpleHeaderSet $headers) + { + // Prepare the DomainKey-Signature Header + $params = ['a' => $this->hashAlgorithm, 'b' => chunk_split(base64_encode($this->getEncryptedHash() ?? ''), 73, ' '), 'c' => $this->canon, 'd' => $this->domainName, 'h' => implode(': ', $this->signedHeaders), 'q' => 'dns', 's' => $this->selector]; + $string = ''; + foreach ($params as $k => $v) { + $string .= $k.'='.$v.'; '; + } + $string = trim($string); + $headers->addTextHeader('DomainKey-Signature', $string); - return $this; - } + return $this; + } - /* Private helpers */ + /* Private helpers */ - protected function addHeader($header) - { - switch ($this->canon) { - case 'nofws': - // Prepare Header and cascade - $exploded = explode(':', $header, 2); - $name = strtolower(trim($exploded[0])); - $value = str_replace("\r\n", '', $exploded[1]); - $value = preg_replace("/[ \t][ \t]+/", ' ', $value); - $header = $name.':'.trim($value)."\r\n"; - // no break - case 'simple': - // Nothing to do - } - $this->addToHash($header); - } + protected function addHeader($header) + { + switch ($this->canon) { + case 'nofws': + // Prepare Header and cascade + $exploded = explode(':', $header, 2); + $name = strtolower(trim($exploded[0])); + $value = str_replace("\r\n", '', $exploded[1]); + $value = preg_replace("/[ \t][ \t]+/", ' ', $value); + $header = $name.':'.trim($value)."\r\n"; + // no break + case 'simple': + // Nothing to do + } + $this->addToHash($header); + } - protected function endOfHeaders() - { - $this->bodyCanonEmptyCounter = 1; - } + protected function endOfHeaders() + { + $this->bodyCanonEmptyCounter = 1; + } - protected function canonicalizeBody($string) - { - $len = \strlen($string); - $canon = ''; - $nofws = ('nofws' == $this->canon); - for ($i = 0; $i < $len; ++$i) { - if ($this->bodyCanonIgnoreStart > 0) { - --$this->bodyCanonIgnoreStart; - continue; - } - switch ($string[$i]) { - case "\r": - $this->bodyCanonLastChar = "\r"; - break; - case "\n": - if ("\r" == $this->bodyCanonLastChar) { - if ($nofws) { - $this->bodyCanonSpace = false; - } - if ('' == $this->bodyCanonLine) { - ++$this->bodyCanonEmptyCounter; - } else { - $this->bodyCanonLine = ''; - $canon .= "\r\n"; - } - } else { - // Wooops Error - throw new Swift_SwiftException('Invalid new line sequence in mail found \n without preceding \r'); - } - break; - case ' ': - case "\t": - case "\x09": //HTAB - if ($nofws) { - $this->bodyCanonSpace = true; - break; - } - // no break - default: - if ($this->bodyCanonEmptyCounter > 0) { - $canon .= str_repeat("\r\n", $this->bodyCanonEmptyCounter); - $this->bodyCanonEmptyCounter = 0; - } - $this->bodyCanonLine .= $string[$i]; - $canon .= $string[$i]; - } - } - $this->addToHash($canon); - } + protected function canonicalizeBody($string) + { + $len = \strlen($string); + $canon = ''; + $nofws = ('nofws' == $this->canon); + for ($i = 0; $i < $len; ++$i) { + if ($this->bodyCanonIgnoreStart > 0) { + --$this->bodyCanonIgnoreStart; + continue; + } + switch ($string[$i]) { + case "\r": + $this->bodyCanonLastChar = "\r"; + break; + case "\n": + if ("\r" == $this->bodyCanonLastChar) { + if ($nofws) { + $this->bodyCanonSpace = false; + } + if ('' == $this->bodyCanonLine) { + ++$this->bodyCanonEmptyCounter; + } else { + $this->bodyCanonLine = ''; + $canon .= "\r\n"; + } + } else { + // Wooops Error + throw new Swift_SwiftException('Invalid new line sequence in mail found \n without preceding \r'); + } + break; + case ' ': + case "\t": + case "\x09": //HTAB + if ($nofws) { + $this->bodyCanonSpace = true; + break; + } + // no break + default: + if ($this->bodyCanonEmptyCounter > 0) { + $canon .= str_repeat("\r\n", $this->bodyCanonEmptyCounter); + $this->bodyCanonEmptyCounter = 0; + } + $this->bodyCanonLine .= $string[$i]; + $canon .= $string[$i]; + } + } + $this->addToHash($canon); + } - protected function endOfBody() - { - if (\strlen($this->bodyCanonLine) > 0) { - $this->addToHash("\r\n"); - } - } + protected function endOfBody() + { + if (\strlen($this->bodyCanonLine) > 0) { + $this->addToHash("\r\n"); + } + } - private function addToHash($string) - { - $this->canonData .= $string; - hash_update($this->hashHandler, $string); - } + private function addToHash($string) + { + $this->canonData .= $string; + hash_update($this->hashHandler, $string); + } - private function startHash() - { - // Init - switch ($this->hashAlgorithm) { - case 'rsa-sha1': - $this->hashHandler = hash_init('sha1'); - break; - } - $this->bodyCanonLine = ''; - } + private function startHash() + { + // Init + switch ($this->hashAlgorithm) { + case 'rsa-sha1': + $this->hashHandler = hash_init('sha1'); + break; + } + $this->bodyCanonLine = ''; + } - /** - * @throws Swift_SwiftException - * - * @return string - */ - private function getEncryptedHash() - { - $signature = ''; - $pkeyId = openssl_get_privatekey($this->privateKey); - if (!$pkeyId) { - throw new Swift_SwiftException('Unable to load DomainKey Private Key ['.openssl_error_string().']'); - } - if (openssl_sign($this->canonData, $signature, $pkeyId, OPENSSL_ALGO_SHA1)) { - return $signature; - } - throw new Swift_SwiftException('Unable to sign DomainKey Hash ['.openssl_error_string().']'); - } + /** + * @throws Swift_SwiftException + * + * @return string + */ + private function getEncryptedHash() + { + $signature = ''; + $pkeyId = openssl_get_privatekey($this->privateKey); + if (!$pkeyId) { + throw new Swift_SwiftException('Unable to load DomainKey Private Key ['.openssl_error_string().']'); + } + if (openssl_sign($this->canonData, $signature, $pkeyId, OPENSSL_ALGO_SHA1)) { + return $signature; + } + throw new Swift_SwiftException('Unable to sign DomainKey Hash ['.openssl_error_string().']'); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/HeaderSigner.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/HeaderSigner.php index 6f5c20923dc..94136b94d85 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/HeaderSigner.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/HeaderSigner.php @@ -15,47 +15,47 @@ */ interface Swift_Signers_HeaderSigner extends Swift_Signer, Swift_InputByteStream { - /** - * Exclude an header from the signed headers. - * - * @param string $header_name - * - * @return self - */ - public function ignoreHeader($header_name); + /** + * Exclude an header from the signed headers. + * + * @param string $header_name + * + * @return self + */ + public function ignoreHeader($header_name); - /** - * Prepare the Signer to get a new Body. - * - * @return self - */ - public function startBody(); + /** + * Prepare the Signer to get a new Body. + * + * @return self + */ + public function startBody(); - /** - * Give the signal that the body has finished streaming. - * - * @return self - */ - public function endBody(); + /** + * Give the signal that the body has finished streaming. + * + * @return self + */ + public function endBody(); - /** - * Give the headers already given. - * - * @return self - */ - public function setHeaders(Swift_Mime_SimpleHeaderSet $headers); + /** + * Give the headers already given. + * + * @return self + */ + public function setHeaders(Swift_Mime_SimpleHeaderSet $headers); - /** - * Add the header(s) to the headerSet. - * - * @return self - */ - public function addSignature(Swift_Mime_SimpleHeaderSet $headers); + /** + * Add the header(s) to the headerSet. + * + * @return self + */ + public function addSignature(Swift_Mime_SimpleHeaderSet $headers); - /** - * Return the list of header a signer might tamper. - * - * @return array - */ - public function getAlteredHeaders(); + /** + * Return the list of header a signer might tamper. + * + * @return array + */ + public function getAlteredHeaders(); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/OpenDKIMSigner.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/OpenDKIMSigner.php index 520bcc15e8b..fb0504dafa7 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/OpenDKIMSigner.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/OpenDKIMSigner.php @@ -18,166 +18,166 @@ */ class Swift_Signers_OpenDKIMSigner extends Swift_Signers_DKIMSigner { - private $peclLoaded = false; + private $peclLoaded = false; - private $dkimHandler = null; + private $dkimHandler = null; - private $dropFirstLF = true; + private $dropFirstLF = true; - const CANON_RELAXED = 1; - const CANON_SIMPLE = 2; - const SIG_RSA_SHA1 = 3; - const SIG_RSA_SHA256 = 4; + const CANON_RELAXED = 1; + const CANON_SIMPLE = 2; + const SIG_RSA_SHA1 = 3; + const SIG_RSA_SHA256 = 4; - public function __construct($privateKey, $domainName, $selector) - { - if (!\extension_loaded('opendkim')) { - throw new Swift_SwiftException('php-opendkim extension not found'); - } + public function __construct($privateKey, $domainName, $selector) + { + if (!\extension_loaded('opendkim')) { + throw new Swift_SwiftException('php-opendkim extension not found'); + } - $this->peclLoaded = true; + $this->peclLoaded = true; - parent::__construct($privateKey, $domainName, $selector); - } + parent::__construct($privateKey, $domainName, $selector); + } - public function addSignature(Swift_Mime_SimpleHeaderSet $headers) - { - $header = new Swift_Mime_Headers_OpenDKIMHeader('DKIM-Signature'); - $headerVal = $this->dkimHandler->getSignatureHeader(); - if (false === $headerVal || \is_int($headerVal)) { - throw new Swift_SwiftException('OpenDKIM Error: '.$this->dkimHandler->getError()); - } - $header->setValue($headerVal); - $headers->set($header); + public function addSignature(Swift_Mime_SimpleHeaderSet $headers) + { + $header = new Swift_Mime_Headers_OpenDKIMHeader('DKIM-Signature'); + $headerVal = $this->dkimHandler->getSignatureHeader(); + if (false === $headerVal || \is_int($headerVal)) { + throw new Swift_SwiftException('OpenDKIM Error: '.$this->dkimHandler->getError()); + } + $header->setValue($headerVal); + $headers->set($header); - return $this; - } + return $this; + } - public function setHeaders(Swift_Mime_SimpleHeaderSet $headers) - { - $hash = 'rsa-sha1' == $this->hashAlgorithm ? OpenDKIMSign::ALG_RSASHA1 : OpenDKIMSign::ALG_RSASHA256; - $bodyCanon = 'simple' == $this->bodyCanon ? OpenDKIMSign::CANON_SIMPLE : OpenDKIMSign::CANON_RELAXED; - $headerCanon = 'simple' == $this->headerCanon ? OpenDKIMSign::CANON_SIMPLE : OpenDKIMSign::CANON_RELAXED; - $this->dkimHandler = new OpenDKIMSign($this->privateKey, $this->selector, $this->domainName, $headerCanon, $bodyCanon, $hash, -1); - // Hardcode signature Margin for now - $this->dkimHandler->setMargin(78); + public function setHeaders(Swift_Mime_SimpleHeaderSet $headers) + { + $hash = 'rsa-sha1' == $this->hashAlgorithm ? OpenDKIMSign::ALG_RSASHA1 : OpenDKIMSign::ALG_RSASHA256; + $bodyCanon = 'simple' == $this->bodyCanon ? OpenDKIMSign::CANON_SIMPLE : OpenDKIMSign::CANON_RELAXED; + $headerCanon = 'simple' == $this->headerCanon ? OpenDKIMSign::CANON_SIMPLE : OpenDKIMSign::CANON_RELAXED; + $this->dkimHandler = new OpenDKIMSign($this->privateKey, $this->selector, $this->domainName, $headerCanon, $bodyCanon, $hash, -1); + // Hardcode signature Margin for now + $this->dkimHandler->setMargin(78); - if (!is_numeric($this->signatureTimestamp)) { - OpenDKIM::setOption(OpenDKIM::OPTS_FIXEDTIME, time()); - } else { - if (!OpenDKIM::setOption(OpenDKIM::OPTS_FIXEDTIME, $this->signatureTimestamp)) { - throw new Swift_SwiftException('Unable to force signature timestamp ['.openssl_error_string().']'); - } - } - if (isset($this->signerIdentity)) { - $this->dkimHandler->setSigner($this->signerIdentity); - } - $listHeaders = $headers->listAll(); - foreach ($listHeaders as $hName) { - // Check if we need to ignore Header - if (!isset($this->ignoredHeaders[strtolower($hName ?? '')])) { - $tmp = $headers->getAll($hName); - if ($headers->has($hName)) { - foreach ($tmp as $header) { - if ('' != $header->getFieldBody()) { - $htosign = $header->toString(); - $this->dkimHandler->header($htosign); - $this->signedHeaders[] = $header->getFieldName(); - } - } - } - } - } + if (!is_numeric($this->signatureTimestamp)) { + OpenDKIM::setOption(OpenDKIM::OPTS_FIXEDTIME, time()); + } else { + if (!OpenDKIM::setOption(OpenDKIM::OPTS_FIXEDTIME, $this->signatureTimestamp)) { + throw new Swift_SwiftException('Unable to force signature timestamp ['.openssl_error_string().']'); + } + } + if (isset($this->signerIdentity)) { + $this->dkimHandler->setSigner($this->signerIdentity); + } + $listHeaders = $headers->listAll(); + foreach ($listHeaders as $hName) { + // Check if we need to ignore Header + if (!isset($this->ignoredHeaders[strtolower($hName ?? '')])) { + $tmp = $headers->getAll($hName); + if ($headers->has($hName)) { + foreach ($tmp as $header) { + if ('' != $header->getFieldBody()) { + $htosign = $header->toString(); + $this->dkimHandler->header($htosign); + $this->signedHeaders[] = $header->getFieldName(); + } + } + } + } + } - return $this; - } + return $this; + } - public function startBody() - { - if (!$this->peclLoaded) { - return parent::startBody(); - } - $this->dropFirstLF = true; - $this->dkimHandler->eoh(); + public function startBody() + { + if (!$this->peclLoaded) { + return parent::startBody(); + } + $this->dropFirstLF = true; + $this->dkimHandler->eoh(); - return $this; - } + return $this; + } - public function endBody() - { - if (!$this->peclLoaded) { - return parent::endBody(); - } - $this->dkimHandler->eom(); + public function endBody() + { + if (!$this->peclLoaded) { + return parent::endBody(); + } + $this->dkimHandler->eom(); - return $this; - } + return $this; + } - public function reset() - { - $this->dkimHandler = null; - parent::reset(); + public function reset() + { + $this->dkimHandler = null; + parent::reset(); - return $this; - } + return $this; + } - /** - * Set the signature timestamp. - * - * @param int $time - * - * @return $this - */ - public function setSignatureTimestamp($time) - { - $this->signatureTimestamp = $time; + /** + * Set the signature timestamp. + * + * @param int $time + * + * @return $this + */ + public function setSignatureTimestamp($time) + { + $this->signatureTimestamp = $time; - return $this; - } + return $this; + } - /** - * Set the signature expiration timestamp. - * - * @param int $time - * - * @return $this - */ - public function setSignatureExpiration($time) - { - $this->signatureExpiration = $time; + /** + * Set the signature expiration timestamp. + * + * @param int $time + * + * @return $this + */ + public function setSignatureExpiration($time) + { + $this->signatureExpiration = $time; - return $this; - } + return $this; + } - /** - * Enable / disable the DebugHeaders. - * - * @param bool $debug - * - * @return $this - */ - public function setDebugHeaders($debug) - { - $this->debugHeaders = (bool) $debug; + /** + * Enable / disable the DebugHeaders. + * + * @param bool $debug + * + * @return $this + */ + public function setDebugHeaders($debug) + { + $this->debugHeaders = (bool) $debug; - return $this; - } + return $this; + } - // Protected + // Protected - protected function canonicalizeBody($string) - { - if (!$this->peclLoaded) { - return parent::canonicalizeBody($string); - } - if (true === $this->dropFirstLF) { - if ("\r" == $string[0] && "\n" == $string[1]) { - $string = substr($string, 2); - } - } - $this->dropFirstLF = false; - if (\strlen($string)) { - $this->dkimHandler->body($string); - } - } + protected function canonicalizeBody($string) + { + if (!$this->peclLoaded) { + return parent::canonicalizeBody($string); + } + if (true === $this->dropFirstLF) { + if ("\r" == $string[0] && "\n" == $string[1]) { + $string = substr($string, 2); + } + } + $this->dropFirstLF = false; + if (\strlen($string)) { + $this->dkimHandler->body($string); + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/SMimeSigner.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/SMimeSigner.php index 3dd3cd05f04..e3a489530af 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/SMimeSigner.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/SMimeSigner.php @@ -17,526 +17,526 @@ */ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner { - protected $signCertificate; - protected $signPrivateKey; - protected $encryptCert; - protected $signThenEncrypt = true; - protected $signLevel; - protected $encryptLevel; - protected $signOptions; - protected $encryptOptions; - protected $encryptCipher; - protected $extraCerts = null; - protected $wrapFullMessage = false; - - /** - * @var Swift_StreamFilters_StringReplacementFilterFactory - */ - protected $replacementFactory; - - /** - * @var Swift_Mime_SimpleHeaderFactory - */ - protected $headerFactory; - - /** - * Constructor. - * - * @param string|null $signCertificate - * @param string|null $signPrivateKey - * @param string|null $encryptCertificate - */ - public function __construct($signCertificate = null, $signPrivateKey = null, $encryptCertificate = null) - { - if (null !== $signPrivateKey) { - $this->setSignCertificate($signCertificate, $signPrivateKey); - } - - if (null !== $encryptCertificate) { - $this->setEncryptCertificate($encryptCertificate); - } - - $this->replacementFactory = Swift_DependencyContainer::getInstance() - ->lookup('transport.replacementfactory'); - - $this->signOptions = PKCS7_DETACHED; - $this->encryptCipher = OPENSSL_CIPHER_AES_128_CBC; - } - - /** - * Set the certificate location to use for signing. - * - * @see https://secure.php.net/manual/en/openssl.pkcs7.flags.php - * - * @param string $certificate - * @param string|array $privateKey If the key needs an passphrase use array('file-location', 'passphrase') instead - * @param int $signOptions Bitwise operator options for openssl_pkcs7_sign() - * @param string $extraCerts A file containing intermediate certificates needed by the signing certificate - * - * @return $this - */ - public function setSignCertificate($certificate, $privateKey = null, $signOptions = PKCS7_DETACHED, $extraCerts = null) - { - $this->signCertificate = 'file://'.str_replace('\\', '/', realpath($certificate)); - - if (null !== $privateKey) { - if (\is_array($privateKey)) { - $this->signPrivateKey = $privateKey; - $this->signPrivateKey[0] = 'file://'.str_replace('\\', '/', realpath($privateKey[0])); - } else { - $this->signPrivateKey = 'file://'.str_replace('\\', '/', realpath($privateKey)); - } - } - - $this->signOptions = $signOptions; - $this->extraCerts = $extraCerts ? realpath($extraCerts) : null; - - return $this; - } - - /** - * Set the certificate location to use for encryption. - * - * @see https://secure.php.net/manual/en/openssl.pkcs7.flags.php - * @see https://secure.php.net/manual/en/openssl.ciphers.php - * - * @param string|array $recipientCerts Either an single X.509 certificate, or an assoc array of X.509 certificates. - * @param int $cipher - * - * @return $this - */ - public function setEncryptCertificate($recipientCerts, $cipher = null) - { - if (\is_array($recipientCerts)) { - $this->encryptCert = []; - - foreach ($recipientCerts as $cert) { - $this->encryptCert[] = 'file://'.str_replace('\\', '/', realpath($cert)); - } - } else { - $this->encryptCert = 'file://'.str_replace('\\', '/', realpath($recipientCerts)); - } - - if (null !== $cipher) { - $this->encryptCipher = $cipher; - } - - return $this; - } - - /** - * @return string - */ - public function getSignCertificate() - { - return $this->signCertificate; - } - - /** - * @return string - */ - public function getSignPrivateKey() - { - return $this->signPrivateKey; - } - - /** - * Set perform signing before encryption. - * - * The default is to first sign the message and then encrypt. - * But some older mail clients, namely Microsoft Outlook 2000 will work when the message first encrypted. - * As this goes against the official specs, its recommended to only use 'encryption -> signing' when specifically targeting these 'broken' clients. - * - * @param bool $signThenEncrypt - * - * @return $this - */ - public function setSignThenEncrypt($signThenEncrypt = true) - { - $this->signThenEncrypt = $signThenEncrypt; - - return $this; - } - - /** - * @return bool - */ - public function isSignThenEncrypt() - { - return $this->signThenEncrypt; - } - - /** - * Resets internal states. - * - * @return $this - */ - public function reset() - { - return $this; - } - - /** - * Specify whether to wrap the entire MIME message in the S/MIME message. - * - * According to RFC5751 section 3.1: - * In order to protect outer, non-content-related message header fields - * (for instance, the "Subject", "To", "From", and "Cc" fields), the - * sending client MAY wrap a full MIME message in a message/rfc822 - * wrapper in order to apply S/MIME security services to these header - * fields. It is up to the receiving client to decide how to present - * this "inner" header along with the unprotected "outer" header. - * - * @param bool $wrap - * - * @return $this - */ - public function setWrapFullMessage($wrap) - { - $this->wrapFullMessage = $wrap; - } - - /** - * Change the Swift_Message to apply the signing. - * - * @return $this - */ - public function signMessage(Swift_Message $message) - { - if (null === $this->signCertificate && null === $this->encryptCert) { - return $this; - } - - if ($this->signThenEncrypt) { - $this->smimeSignMessage($message); - $this->smimeEncryptMessage($message); - } else { - $this->smimeEncryptMessage($message); - $this->smimeSignMessage($message); - } - } - - /** - * Return the list of header a signer might tamper. - * - * @return array - */ - public function getAlteredHeaders() - { - return ['Content-Type', 'Content-Transfer-Encoding', 'Content-Disposition']; - } - - /** - * Sign a Swift message. - */ - protected function smimeSignMessage(Swift_Message $message) - { - // If we don't have a certificate we can't sign the message - if (null === $this->signCertificate) { - return; - } - - // Work on a clone of the original message - $signMessage = clone $message; - $signMessage->clearSigners(); - - if ($this->wrapFullMessage) { - // The original message essentially becomes the body of the new - // wrapped message - $signMessage = $this->wrapMimeMessage($signMessage); - } else { - // Only keep header needed to parse the body correctly - $this->clearAllHeaders($signMessage); - $this->copyHeaders( - $message, - $signMessage, - [ - 'Content-Type', - 'Content-Transfer-Encoding', - 'Content-Disposition', - ] - ); - } - - // Copy the cloned message into a temporary file stream - $messageStream = new Swift_ByteStream_TemporaryFileByteStream(); - $signMessage->toByteStream($messageStream); - $messageStream->commit(); - $signedMessageStream = new Swift_ByteStream_TemporaryFileByteStream(); - - // Sign the message using openssl - if (!openssl_pkcs7_sign( - $messageStream->getPath(), - $signedMessageStream->getPath(), - $this->signCertificate, - $this->signPrivateKey, - [], - $this->signOptions, - $this->extraCerts - ) - ) { - throw new Swift_IoException(sprintf('Failed to sign S/Mime message. Error: "%s".', openssl_error_string())); - } - - // Parse the resulting signed message content back into the Swift message - // preserving the original headers - $this->parseSSLOutput($signedMessageStream, $message); - } - - /** - * Encrypt a Swift message. - */ - protected function smimeEncryptMessage(Swift_Message $message) - { - // If we don't have a certificate we can't encrypt the message - if (null === $this->encryptCert) { - return; - } - - // Work on a clone of the original message - $encryptMessage = clone $message; - $encryptMessage->clearSigners(); - - if ($this->wrapFullMessage) { - // The original message essentially becomes the body of the new - // wrapped message - $encryptMessage = $this->wrapMimeMessage($encryptMessage); - } else { - // Only keep header needed to parse the body correctly - $this->clearAllHeaders($encryptMessage); - $this->copyHeaders( - $message, - $encryptMessage, - [ - 'Content-Type', - 'Content-Transfer-Encoding', - 'Content-Disposition', - ] - ); - } - - // Convert the message content (including headers) to a string - // and place it in a temporary file - $messageStream = new Swift_ByteStream_TemporaryFileByteStream(); - $encryptMessage->toByteStream($messageStream); - $messageStream->commit(); - $encryptedMessageStream = new Swift_ByteStream_TemporaryFileByteStream(); - - // Encrypt the message - if (!openssl_pkcs7_encrypt( - $messageStream->getPath(), - $encryptedMessageStream->getPath(), - $this->encryptCert, - [], - 0, - $this->encryptCipher - ) - ) { - throw new Swift_IoException(sprintf('Failed to encrypt S/Mime message. Error: "%s".', openssl_error_string())); - } - - // Parse the resulting signed message content back into the Swift message - // preserving the original headers - $this->parseSSLOutput($encryptedMessageStream, $message); - } - - /** - * Copy named headers from one Swift message to another. - */ - protected function copyHeaders( - Swift_Message $fromMessage, - Swift_Message $toMessage, - array $headers = [] - ) { - foreach ($headers as $header) { - $this->copyHeader($fromMessage, $toMessage, $header); - } - } - - /** - * Copy a single header from one Swift message to another. - * - * @param string $headerName - */ - protected function copyHeader(Swift_Message $fromMessage, Swift_Message $toMessage, $headerName) - { - $header = $fromMessage->getHeaders()->get($headerName); - if (!$header) { - return; - } - $headers = $toMessage->getHeaders(); - switch ($header->getFieldType()) { - case Swift_Mime_Header::TYPE_TEXT: - $headers->addTextHeader($header->getFieldName(), $header->getValue()); - break; - case Swift_Mime_Header::TYPE_PARAMETERIZED: - $headers->addParameterizedHeader( - $header->getFieldName(), - $header->getValue(), - $header->getParameters() - ); - break; - } - } - - /** - * Remove all headers from a Swift message. - */ - protected function clearAllHeaders(Swift_Message $message) - { - $headers = $message->getHeaders(); - foreach ($headers->listAll() as $header) { - $headers->removeAll($header); - } - } - - /** - * Wraps a Swift_Message in a message/rfc822 MIME part. - * - * @return Swift_MimePart - */ - protected function wrapMimeMessage(Swift_Message $message) - { - // Start by copying the original message into a message stream - $messageStream = new Swift_ByteStream_TemporaryFileByteStream(); - $message->toByteStream($messageStream); - $messageStream->commit(); - - // Create a new MIME part that wraps the original stream - $wrappedMessage = new Swift_MimePart($messageStream, 'message/rfc822'); - $wrappedMessage->setEncoder(new Swift_Mime_ContentEncoder_PlainContentEncoder('7bit')); - - return $wrappedMessage; - } - - protected function parseSSLOutput(Swift_InputByteStream $inputStream, Swift_Message $message) - { - $messageStream = new Swift_ByteStream_TemporaryFileByteStream(); - $this->copyFromOpenSSLOutput($inputStream, $messageStream); - - $this->streamToMime($messageStream, $message); - } - - /** - * Merges an OutputByteStream from OpenSSL to a Swift_Message. - */ - protected function streamToMime(Swift_OutputByteStream $fromStream, Swift_Message $message) - { - // Parse the stream into headers and body - list($headers, $messageStream) = $this->parseStream($fromStream); - - // Get the original message headers - $messageHeaders = $message->getHeaders(); - - // Let the stream determine the headers describing the body content, - // since the body of the original message is overwritten by the body - // coming from the stream. - // These are all content-* headers. - - // Default transfer encoding is 7bit if not set - $encoding = ''; - // Remove all existing transfer encoding headers - $messageHeaders->removeAll('Content-Transfer-Encoding'); - // See whether the stream sets the transfer encoding - if (isset($headers['content-transfer-encoding'])) { - $encoding = $headers['content-transfer-encoding']; - } - - // We use the null content encoder, since the body is already encoded - // according to the transfer encoding specified in the stream - $message->setEncoder(new Swift_Mime_ContentEncoder_NullContentEncoder($encoding)); - - // Set the disposition, if present - if (isset($headers['content-disposition'])) { - $messageHeaders->addTextHeader('Content-Disposition', $headers['content-disposition']); - } - - // Copy over the body from the stream using the content type dictated - // by the stream content - $message->setChildren([]); - $message->setBody($messageStream, $headers['content-type']); - } - - /** - * This message will parse the headers of a MIME email byte stream - * and return an array that contains the headers as an associative - * array and the email body as a string. - * - * @return array - */ - protected function parseStream(Swift_OutputByteStream $emailStream) - { - $bufferLength = 78; - $headerData = ''; - $headerBodySeparator = "\r\n\r\n"; - - $emailStream->setReadPointer(0); - - // Read out the headers section from the stream to a string - while (false !== ($buffer = $emailStream->read($bufferLength))) { - $headerData .= $buffer; - - $headersPosEnd = strpos($headerData, $headerBodySeparator); - - // Stop reading if we found the end of the headers - if (false !== $headersPosEnd) { - break; - } - } - - // Split the header data into lines - $headerData = trim(substr($headerData, 0, $headersPosEnd)); - $headerLines = explode("\r\n", $headerData); - unset($headerData); - - $headers = []; - $currentHeaderName = ''; - - // Transform header lines into an associative array - foreach ($headerLines as $headerLine) { - // Handle headers that span multiple lines - if (false === strpos($headerLine, ':')) { - $headers[$currentHeaderName] .= ' '.trim($headerLine ?? ''); - continue; - } - - $header = explode(':', $headerLine, 2); - $currentHeaderName = strtolower($header[0] ?? ''); - $headers[$currentHeaderName] = trim($header[1] ?? ''); - } - - // Read the entire email body into a byte stream - $bodyStream = new Swift_ByteStream_TemporaryFileByteStream(); - - // Skip the header and separator and point to the body - $emailStream->setReadPointer($headersPosEnd + \strlen($headerBodySeparator)); - - while (false !== ($buffer = $emailStream->read($bufferLength))) { - $bodyStream->write($buffer); - } - - $bodyStream->commit(); - - return [$headers, $bodyStream]; - } - - protected function copyFromOpenSSLOutput(Swift_OutputByteStream $fromStream, Swift_InputByteStream $toStream) - { - $bufferLength = 4096; - $filteredStream = new Swift_ByteStream_TemporaryFileByteStream(); - $filteredStream->addFilter($this->replacementFactory->createFilter("\r\n", "\n"), 'CRLF to LF'); - $filteredStream->addFilter($this->replacementFactory->createFilter("\n", "\r\n"), 'LF to CRLF'); - - while (false !== ($buffer = $fromStream->read($bufferLength))) { - $filteredStream->write($buffer); - } - - $filteredStream->flushBuffers(); - - while (false !== ($buffer = $filteredStream->read($bufferLength))) { - $toStream->write($buffer); - } - - $toStream->commit(); - } + protected $signCertificate; + protected $signPrivateKey; + protected $encryptCert; + protected $signThenEncrypt = true; + protected $signLevel; + protected $encryptLevel; + protected $signOptions; + protected $encryptOptions; + protected $encryptCipher; + protected $extraCerts = null; + protected $wrapFullMessage = false; + + /** + * @var Swift_StreamFilters_StringReplacementFilterFactory + */ + protected $replacementFactory; + + /** + * @var Swift_Mime_SimpleHeaderFactory + */ + protected $headerFactory; + + /** + * Constructor. + * + * @param string|null $signCertificate + * @param string|null $signPrivateKey + * @param string|null $encryptCertificate + */ + public function __construct($signCertificate = null, $signPrivateKey = null, $encryptCertificate = null) + { + if (null !== $signPrivateKey) { + $this->setSignCertificate($signCertificate, $signPrivateKey); + } + + if (null !== $encryptCertificate) { + $this->setEncryptCertificate($encryptCertificate); + } + + $this->replacementFactory = Swift_DependencyContainer::getInstance() + ->lookup('transport.replacementfactory'); + + $this->signOptions = PKCS7_DETACHED; + $this->encryptCipher = OPENSSL_CIPHER_AES_128_CBC; + } + + /** + * Set the certificate location to use for signing. + * + * @see https://secure.php.net/manual/en/openssl.pkcs7.flags.php + * + * @param string $certificate + * @param string|array $privateKey If the key needs an passphrase use array('file-location', 'passphrase') instead + * @param int $signOptions Bitwise operator options for openssl_pkcs7_sign() + * @param string $extraCerts A file containing intermediate certificates needed by the signing certificate + * + * @return $this + */ + public function setSignCertificate($certificate, $privateKey = null, $signOptions = PKCS7_DETACHED, $extraCerts = null) + { + $this->signCertificate = 'file://'.str_replace('\\', '/', realpath($certificate)); + + if (null !== $privateKey) { + if (\is_array($privateKey)) { + $this->signPrivateKey = $privateKey; + $this->signPrivateKey[0] = 'file://'.str_replace('\\', '/', realpath($privateKey[0])); + } else { + $this->signPrivateKey = 'file://'.str_replace('\\', '/', realpath($privateKey)); + } + } + + $this->signOptions = $signOptions; + $this->extraCerts = $extraCerts ? realpath($extraCerts) : null; + + return $this; + } + + /** + * Set the certificate location to use for encryption. + * + * @see https://secure.php.net/manual/en/openssl.pkcs7.flags.php + * @see https://secure.php.net/manual/en/openssl.ciphers.php + * + * @param string|array $recipientCerts Either an single X.509 certificate, or an assoc array of X.509 certificates. + * @param int $cipher + * + * @return $this + */ + public function setEncryptCertificate($recipientCerts, $cipher = null) + { + if (\is_array($recipientCerts)) { + $this->encryptCert = []; + + foreach ($recipientCerts as $cert) { + $this->encryptCert[] = 'file://'.str_replace('\\', '/', realpath($cert)); + } + } else { + $this->encryptCert = 'file://'.str_replace('\\', '/', realpath($recipientCerts)); + } + + if (null !== $cipher) { + $this->encryptCipher = $cipher; + } + + return $this; + } + + /** + * @return string + */ + public function getSignCertificate() + { + return $this->signCertificate; + } + + /** + * @return string + */ + public function getSignPrivateKey() + { + return $this->signPrivateKey; + } + + /** + * Set perform signing before encryption. + * + * The default is to first sign the message and then encrypt. + * But some older mail clients, namely Microsoft Outlook 2000 will work when the message first encrypted. + * As this goes against the official specs, its recommended to only use 'encryption -> signing' when specifically targeting these 'broken' clients. + * + * @param bool $signThenEncrypt + * + * @return $this + */ + public function setSignThenEncrypt($signThenEncrypt = true) + { + $this->signThenEncrypt = $signThenEncrypt; + + return $this; + } + + /** + * @return bool + */ + public function isSignThenEncrypt() + { + return $this->signThenEncrypt; + } + + /** + * Resets internal states. + * + * @return $this + */ + public function reset() + { + return $this; + } + + /** + * Specify whether to wrap the entire MIME message in the S/MIME message. + * + * According to RFC5751 section 3.1: + * In order to protect outer, non-content-related message header fields + * (for instance, the "Subject", "To", "From", and "Cc" fields), the + * sending client MAY wrap a full MIME message in a message/rfc822 + * wrapper in order to apply S/MIME security services to these header + * fields. It is up to the receiving client to decide how to present + * this "inner" header along with the unprotected "outer" header. + * + * @param bool $wrap + * + * @return $this + */ + public function setWrapFullMessage($wrap) + { + $this->wrapFullMessage = $wrap; + } + + /** + * Change the Swift_Message to apply the signing. + * + * @return $this + */ + public function signMessage(Swift_Message $message) + { + if (null === $this->signCertificate && null === $this->encryptCert) { + return $this; + } + + if ($this->signThenEncrypt) { + $this->smimeSignMessage($message); + $this->smimeEncryptMessage($message); + } else { + $this->smimeEncryptMessage($message); + $this->smimeSignMessage($message); + } + } + + /** + * Return the list of header a signer might tamper. + * + * @return array + */ + public function getAlteredHeaders() + { + return ['Content-Type', 'Content-Transfer-Encoding', 'Content-Disposition']; + } + + /** + * Sign a Swift message. + */ + protected function smimeSignMessage(Swift_Message $message) + { + // If we don't have a certificate we can't sign the message + if (null === $this->signCertificate) { + return; + } + + // Work on a clone of the original message + $signMessage = clone $message; + $signMessage->clearSigners(); + + if ($this->wrapFullMessage) { + // The original message essentially becomes the body of the new + // wrapped message + $signMessage = $this->wrapMimeMessage($signMessage); + } else { + // Only keep header needed to parse the body correctly + $this->clearAllHeaders($signMessage); + $this->copyHeaders( + $message, + $signMessage, + [ + 'Content-Type', + 'Content-Transfer-Encoding', + 'Content-Disposition', + ] + ); + } + + // Copy the cloned message into a temporary file stream + $messageStream = new Swift_ByteStream_TemporaryFileByteStream(); + $signMessage->toByteStream($messageStream); + $messageStream->commit(); + $signedMessageStream = new Swift_ByteStream_TemporaryFileByteStream(); + + // Sign the message using openssl + if (!openssl_pkcs7_sign( + $messageStream->getPath(), + $signedMessageStream->getPath(), + $this->signCertificate, + $this->signPrivateKey, + [], + $this->signOptions, + $this->extraCerts + ) + ) { + throw new Swift_IoException(sprintf('Failed to sign S/Mime message. Error: "%s".', openssl_error_string())); + } + + // Parse the resulting signed message content back into the Swift message + // preserving the original headers + $this->parseSSLOutput($signedMessageStream, $message); + } + + /** + * Encrypt a Swift message. + */ + protected function smimeEncryptMessage(Swift_Message $message) + { + // If we don't have a certificate we can't encrypt the message + if (null === $this->encryptCert) { + return; + } + + // Work on a clone of the original message + $encryptMessage = clone $message; + $encryptMessage->clearSigners(); + + if ($this->wrapFullMessage) { + // The original message essentially becomes the body of the new + // wrapped message + $encryptMessage = $this->wrapMimeMessage($encryptMessage); + } else { + // Only keep header needed to parse the body correctly + $this->clearAllHeaders($encryptMessage); + $this->copyHeaders( + $message, + $encryptMessage, + [ + 'Content-Type', + 'Content-Transfer-Encoding', + 'Content-Disposition', + ] + ); + } + + // Convert the message content (including headers) to a string + // and place it in a temporary file + $messageStream = new Swift_ByteStream_TemporaryFileByteStream(); + $encryptMessage->toByteStream($messageStream); + $messageStream->commit(); + $encryptedMessageStream = new Swift_ByteStream_TemporaryFileByteStream(); + + // Encrypt the message + if (!openssl_pkcs7_encrypt( + $messageStream->getPath(), + $encryptedMessageStream->getPath(), + $this->encryptCert, + [], + 0, + $this->encryptCipher + ) + ) { + throw new Swift_IoException(sprintf('Failed to encrypt S/Mime message. Error: "%s".', openssl_error_string())); + } + + // Parse the resulting signed message content back into the Swift message + // preserving the original headers + $this->parseSSLOutput($encryptedMessageStream, $message); + } + + /** + * Copy named headers from one Swift message to another. + */ + protected function copyHeaders( + Swift_Message $fromMessage, + Swift_Message $toMessage, + array $headers = [] + ) { + foreach ($headers as $header) { + $this->copyHeader($fromMessage, $toMessage, $header); + } + } + + /** + * Copy a single header from one Swift message to another. + * + * @param string $headerName + */ + protected function copyHeader(Swift_Message $fromMessage, Swift_Message $toMessage, $headerName) + { + $header = $fromMessage->getHeaders()->get($headerName); + if (!$header) { + return; + } + $headers = $toMessage->getHeaders(); + switch ($header->getFieldType()) { + case Swift_Mime_Header::TYPE_TEXT: + $headers->addTextHeader($header->getFieldName(), $header->getValue()); + break; + case Swift_Mime_Header::TYPE_PARAMETERIZED: + $headers->addParameterizedHeader( + $header->getFieldName(), + $header->getValue(), + $header->getParameters() + ); + break; + } + } + + /** + * Remove all headers from a Swift message. + */ + protected function clearAllHeaders(Swift_Message $message) + { + $headers = $message->getHeaders(); + foreach ($headers->listAll() as $header) { + $headers->removeAll($header); + } + } + + /** + * Wraps a Swift_Message in a message/rfc822 MIME part. + * + * @return Swift_MimePart + */ + protected function wrapMimeMessage(Swift_Message $message) + { + // Start by copying the original message into a message stream + $messageStream = new Swift_ByteStream_TemporaryFileByteStream(); + $message->toByteStream($messageStream); + $messageStream->commit(); + + // Create a new MIME part that wraps the original stream + $wrappedMessage = new Swift_MimePart($messageStream, 'message/rfc822'); + $wrappedMessage->setEncoder(new Swift_Mime_ContentEncoder_PlainContentEncoder('7bit')); + + return $wrappedMessage; + } + + protected function parseSSLOutput(Swift_InputByteStream $inputStream, Swift_Message $message) + { + $messageStream = new Swift_ByteStream_TemporaryFileByteStream(); + $this->copyFromOpenSSLOutput($inputStream, $messageStream); + + $this->streamToMime($messageStream, $message); + } + + /** + * Merges an OutputByteStream from OpenSSL to a Swift_Message. + */ + protected function streamToMime(Swift_OutputByteStream $fromStream, Swift_Message $message) + { + // Parse the stream into headers and body + list($headers, $messageStream) = $this->parseStream($fromStream); + + // Get the original message headers + $messageHeaders = $message->getHeaders(); + + // Let the stream determine the headers describing the body content, + // since the body of the original message is overwritten by the body + // coming from the stream. + // These are all content-* headers. + + // Default transfer encoding is 7bit if not set + $encoding = ''; + // Remove all existing transfer encoding headers + $messageHeaders->removeAll('Content-Transfer-Encoding'); + // See whether the stream sets the transfer encoding + if (isset($headers['content-transfer-encoding'])) { + $encoding = $headers['content-transfer-encoding']; + } + + // We use the null content encoder, since the body is already encoded + // according to the transfer encoding specified in the stream + $message->setEncoder(new Swift_Mime_ContentEncoder_NullContentEncoder($encoding)); + + // Set the disposition, if present + if (isset($headers['content-disposition'])) { + $messageHeaders->addTextHeader('Content-Disposition', $headers['content-disposition']); + } + + // Copy over the body from the stream using the content type dictated + // by the stream content + $message->setChildren([]); + $message->setBody($messageStream, $headers['content-type']); + } + + /** + * This message will parse the headers of a MIME email byte stream + * and return an array that contains the headers as an associative + * array and the email body as a string. + * + * @return array + */ + protected function parseStream(Swift_OutputByteStream $emailStream) + { + $bufferLength = 78; + $headerData = ''; + $headerBodySeparator = "\r\n\r\n"; + + $emailStream->setReadPointer(0); + + // Read out the headers section from the stream to a string + while (false !== ($buffer = $emailStream->read($bufferLength))) { + $headerData .= $buffer; + + $headersPosEnd = strpos($headerData, $headerBodySeparator); + + // Stop reading if we found the end of the headers + if (false !== $headersPosEnd) { + break; + } + } + + // Split the header data into lines + $headerData = trim(substr($headerData, 0, $headersPosEnd)); + $headerLines = explode("\r\n", $headerData); + unset($headerData); + + $headers = []; + $currentHeaderName = ''; + + // Transform header lines into an associative array + foreach ($headerLines as $headerLine) { + // Handle headers that span multiple lines + if (false === strpos($headerLine, ':')) { + $headers[$currentHeaderName] .= ' '.trim($headerLine ?? ''); + continue; + } + + $header = explode(':', $headerLine, 2); + $currentHeaderName = strtolower($header[0] ?? ''); + $headers[$currentHeaderName] = trim($header[1] ?? ''); + } + + // Read the entire email body into a byte stream + $bodyStream = new Swift_ByteStream_TemporaryFileByteStream(); + + // Skip the header and separator and point to the body + $emailStream->setReadPointer($headersPosEnd + \strlen($headerBodySeparator)); + + while (false !== ($buffer = $emailStream->read($bufferLength))) { + $bodyStream->write($buffer); + } + + $bodyStream->commit(); + + return [$headers, $bodyStream]; + } + + protected function copyFromOpenSSLOutput(Swift_OutputByteStream $fromStream, Swift_InputByteStream $toStream) + { + $bufferLength = 4096; + $filteredStream = new Swift_ByteStream_TemporaryFileByteStream(); + $filteredStream->addFilter($this->replacementFactory->createFilter("\r\n", "\n"), 'CRLF to LF'); + $filteredStream->addFilter($this->replacementFactory->createFilter("\n", "\r\n"), 'LF to CRLF'); + + while (false !== ($buffer = $fromStream->read($bufferLength))) { + $filteredStream->write($buffer); + } + + $filteredStream->flushBuffers(); + + while (false !== ($buffer = $filteredStream->read($bufferLength))) { + $toStream->write($buffer); + } + + $toStream->commit(); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/SmtpTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/SmtpTransport.php index 56b62323ad7..625a470e09c 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/SmtpTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/SmtpTransport.php @@ -22,24 +22,24 @@ */ class Swift_SmtpTransport extends Swift_Transport_EsmtpTransport { - /** - * @param string $host - * @param int $port - * @param string|null $encryption SMTP encryption mode: - * - null for plain SMTP (no encryption), - * - 'tls' for SMTP with STARTTLS (best effort encryption), - * - 'ssl' for SMTPS = SMTP over TLS (always encrypted). - */ - public function __construct($host = 'localhost', $port = 25, $encryption = null) - { - \call_user_func_array( - [$this, 'Swift_Transport_EsmtpTransport::__construct'], - Swift_DependencyContainer::getInstance() - ->createDependenciesFor('transport.smtp') - ); + /** + * @param string $host + * @param int $port + * @param string|null $encryption SMTP encryption mode: + * - null for plain SMTP (no encryption), + * - 'tls' for SMTP with STARTTLS (best effort encryption), + * - 'ssl' for SMTPS = SMTP over TLS (always encrypted). + */ + public function __construct($host = 'localhost', $port = 25, $encryption = null) + { + \call_user_func_array( + [$this, 'Swift_Transport_EsmtpTransport::__construct'], + Swift_DependencyContainer::getInstance() + ->createDependenciesFor('transport.smtp') + ); - $this->setHost($host); - $this->setPort($port); - $this->setEncryption($encryption); - } + $this->setHost($host); + $this->setPort($port); + $this->setEncryption($encryption); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/SpoolTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/SpoolTransport.php index c08e0fb17d5..ac30065048a 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/SpoolTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/SpoolTransport.php @@ -15,19 +15,19 @@ */ class Swift_SpoolTransport extends Swift_Transport_SpoolTransport { - /** - * Create a new SpoolTransport. - */ - public function __construct(Swift_Spool $spool) - { - $arguments = Swift_DependencyContainer::getInstance() - ->createDependenciesFor('transport.spool'); + /** + * Create a new SpoolTransport. + */ + public function __construct(Swift_Spool $spool) + { + $arguments = Swift_DependencyContainer::getInstance() + ->createDependenciesFor('transport.spool'); - $arguments[] = $spool; + $arguments[] = $spool; - \call_user_func_array( - [$this, 'Swift_Transport_SpoolTransport::__construct'], - $arguments - ); - } + \call_user_func_array( + [$this, 'Swift_Transport_SpoolTransport::__construct'], + $arguments + ); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/StreamFilters/ByteArrayReplacementFilter.php b/htdocs/includes/swiftmailer/lib/classes/Swift/StreamFilters/ByteArrayReplacementFilter.php index 7e5ddf1b7da..2e68f95e3e7 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/StreamFilters/ByteArrayReplacementFilter.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/StreamFilters/ByteArrayReplacementFilter.php @@ -17,150 +17,150 @@ */ class Swift_StreamFilters_ByteArrayReplacementFilter implements Swift_StreamFilter { - /** The replacement(s) to make */ - private $replace; + /** The replacement(s) to make */ + private $replace; - /** The Index for searching */ - private $index; + /** The Index for searching */ + private $index; - /** The Search Tree */ - private $tree = []; + /** The Search Tree */ + private $tree = []; - /** Gives the size of the largest search */ - private $treeMaxLen = 0; + /** Gives the size of the largest search */ + private $treeMaxLen = 0; - private $repSize; + private $repSize; - /** - * Create a new ByteArrayReplacementFilter with $search and $replace. - * - * @param array $search - * @param array $replace - */ - public function __construct($search, $replace) - { - $this->index = []; - $this->tree = []; - $this->replace = []; - $this->repSize = []; + /** + * Create a new ByteArrayReplacementFilter with $search and $replace. + * + * @param array $search + * @param array $replace + */ + public function __construct($search, $replace) + { + $this->index = []; + $this->tree = []; + $this->replace = []; + $this->repSize = []; - $tree = null; - $i = null; - $last_size = $size = 0; - foreach ($search as $i => $search_element) { - if (null !== $tree) { - $tree[-1] = min(\count($replace) - 1, $i - 1); - $tree[-2] = $last_size; - } - $tree = &$this->tree; - if (\is_array($search_element)) { - foreach ($search_element as $k => $char) { - $this->index[$char] = true; - if (!isset($tree[$char])) { - $tree[$char] = []; - } - $tree = &$tree[$char]; - } - $last_size = $k + 1; - $size = max($size, $last_size); - } else { - $last_size = 1; - if (!isset($tree[$search_element])) { - $tree[$search_element] = []; - } - $tree = &$tree[$search_element]; - $size = max($last_size, $size); - $this->index[$search_element] = true; - } - } - if (null !== $i) { - $tree[-1] = min(\count($replace) - 1, $i); - $tree[-2] = $last_size; - $this->treeMaxLen = $size; - } - foreach ($replace as $rep) { - if (!\is_array($rep)) { - $rep = [$rep]; - } - $this->replace[] = $rep; - } - for ($i = \count($this->replace) - 1; $i >= 0; --$i) { - $this->replace[$i] = $rep = $this->filter($this->replace[$i], $i); - $this->repSize[$i] = \count($rep); - } - } + $tree = null; + $i = null; + $last_size = $size = 0; + foreach ($search as $i => $search_element) { + if (null !== $tree) { + $tree[-1] = min(\count($replace) - 1, $i - 1); + $tree[-2] = $last_size; + } + $tree = &$this->tree; + if (\is_array($search_element)) { + foreach ($search_element as $k => $char) { + $this->index[$char] = true; + if (!isset($tree[$char])) { + $tree[$char] = []; + } + $tree = &$tree[$char]; + } + $last_size = $k + 1; + $size = max($size, $last_size); + } else { + $last_size = 1; + if (!isset($tree[$search_element])) { + $tree[$search_element] = []; + } + $tree = &$tree[$search_element]; + $size = max($last_size, $size); + $this->index[$search_element] = true; + } + } + if (null !== $i) { + $tree[-1] = min(\count($replace) - 1, $i); + $tree[-2] = $last_size; + $this->treeMaxLen = $size; + } + foreach ($replace as $rep) { + if (!\is_array($rep)) { + $rep = [$rep]; + } + $this->replace[] = $rep; + } + for ($i = \count($this->replace) - 1; $i >= 0; --$i) { + $this->replace[$i] = $rep = $this->filter($this->replace[$i], $i); + $this->repSize[$i] = \count($rep); + } + } - /** - * Returns true if based on the buffer passed more bytes should be buffered. - * - * @param array $buffer - * - * @return bool - */ - public function shouldBuffer($buffer) - { - $endOfBuffer = end($buffer); + /** + * Returns true if based on the buffer passed more bytes should be buffered. + * + * @param array $buffer + * + * @return bool + */ + public function shouldBuffer($buffer) + { + $endOfBuffer = end($buffer); - return isset($this->index[$endOfBuffer]); - } + return isset($this->index[$endOfBuffer]); + } - /** - * Perform the actual replacements on $buffer and return the result. - * - * @param array $buffer - * @param int $minReplaces - * - * @return array - */ - public function filter($buffer, $minReplaces = -1) - { - if (0 == $this->treeMaxLen) { - return $buffer; - } + /** + * Perform the actual replacements on $buffer and return the result. + * + * @param array $buffer + * @param int $minReplaces + * + * @return array + */ + public function filter($buffer, $minReplaces = -1) + { + if (0 == $this->treeMaxLen) { + return $buffer; + } - $newBuffer = []; - $buf_size = \count($buffer); - $last_size = 0; - for ($i = 0; $i < $buf_size; ++$i) { - $search_pos = $this->tree; - $last_found = PHP_INT_MAX; - // We try to find if the next byte is part of a search pattern - for ($j = 0; $j <= $this->treeMaxLen; ++$j) { - // We have a new byte for a search pattern - if (isset($buffer[$p = $i + $j]) && isset($search_pos[$buffer[$p]])) { - $search_pos = $search_pos[$buffer[$p]]; - // We have a complete pattern, save, in case we don't find a better match later - if (isset($search_pos[-1]) && $search_pos[-1] < $last_found - && $search_pos[-1] > $minReplaces) { - $last_found = $search_pos[-1]; - $last_size = $search_pos[-2]; - } - } - // We got a complete pattern - elseif (PHP_INT_MAX !== $last_found) { - // Adding replacement datas to output buffer - $rep_size = $this->repSize[$last_found]; - for ($j = 0; $j < $rep_size; ++$j) { - $newBuffer[] = $this->replace[$last_found][$j]; - } - // We Move cursor forward - $i += $last_size - 1; - // Edge Case, last position in buffer - if ($i >= $buf_size) { - $newBuffer[] = $buffer[$i]; - } + $newBuffer = []; + $buf_size = \count($buffer); + $last_size = 0; + for ($i = 0; $i < $buf_size; ++$i) { + $search_pos = $this->tree; + $last_found = PHP_INT_MAX; + // We try to find if the next byte is part of a search pattern + for ($j = 0; $j <= $this->treeMaxLen; ++$j) { + // We have a new byte for a search pattern + if (isset($buffer[$p = $i + $j]) && isset($search_pos[$buffer[$p]])) { + $search_pos = $search_pos[$buffer[$p]]; + // We have a complete pattern, save, in case we don't find a better match later + if (isset($search_pos[-1]) && $search_pos[-1] < $last_found + && $search_pos[-1] > $minReplaces) { + $last_found = $search_pos[-1]; + $last_size = $search_pos[-2]; + } + } + // We got a complete pattern + elseif (PHP_INT_MAX !== $last_found) { + // Adding replacement datas to output buffer + $rep_size = $this->repSize[$last_found]; + for ($j = 0; $j < $rep_size; ++$j) { + $newBuffer[] = $this->replace[$last_found][$j]; + } + // We Move cursor forward + $i += $last_size - 1; + // Edge Case, last position in buffer + if ($i >= $buf_size) { + $newBuffer[] = $buffer[$i]; + } - // We start the next loop - continue 2; - } else { - // this byte is not in a pattern and we haven't found another pattern - break; - } - } - // Normal byte, move it to output buffer - $newBuffer[] = $buffer[$i]; - } + // We start the next loop + continue 2; + } else { + // this byte is not in a pattern and we haven't found another pattern + break; + } + } + // Normal byte, move it to output buffer + $newBuffer[] = $buffer[$i]; + } - return $newBuffer; - } + return $newBuffer; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilterFactory.php b/htdocs/includes/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilterFactory.php index 783b8896dd7..965e9f69cda 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilterFactory.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilterFactory.php @@ -15,31 +15,31 @@ */ class Swift_StreamFilters_StringReplacementFilterFactory implements Swift_ReplacementFilterFactory { - /** Lazy-loaded filters */ - private $filters = []; + /** Lazy-loaded filters */ + private $filters = []; - /** - * Create a new StreamFilter to replace $search with $replace in a string. - * - * @param string $search - * @param string $replace - * - * @return Swift_StreamFilter - */ - public function createFilter($search, $replace) - { - if (!isset($this->filters[$search][$replace])) { - if (!isset($this->filters[$search])) { - $this->filters[$search] = []; - } + /** + * Create a new StreamFilter to replace $search with $replace in a string. + * + * @param string $search + * @param string $replace + * + * @return Swift_StreamFilter + */ + public function createFilter($search, $replace) + { + if (!isset($this->filters[$search][$replace])) { + if (!isset($this->filters[$search])) { + $this->filters[$search] = []; + } - if (!isset($this->filters[$search][$replace])) { - $this->filters[$search][$replace] = []; - } + if (!isset($this->filters[$search][$replace])) { + $this->filters[$search][$replace] = []; + } - $this->filters[$search][$replace] = new Swift_StreamFilters_StringReplacementFilter($search, $replace); - } + $this->filters[$search][$replace] = new Swift_StreamFilters_StringReplacementFilter($search, $replace); + } - return $this->filters[$search][$replace]; - } + return $this->filters[$search][$replace]; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/SwiftException.php b/htdocs/includes/swiftmailer/lib/classes/Swift/SwiftException.php index 15e68b18e79..44cbfc779e5 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/SwiftException.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/SwiftException.php @@ -15,14 +15,14 @@ */ class Swift_SwiftException extends Exception { - /** - * Create a new SwiftException with $message. - * - * @param string $message - * @param int $code - */ - public function __construct($message, $code = 0, Exception $previous = null) - { - parent::__construct($message, $code, $previous); - } + /** + * Create a new SwiftException with $message. + * + * @param string $message + * @param int $code + */ + public function __construct($message, $code = 0, Exception $previous = null) + { + parent::__construct($message, $code, $previous); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport.php index bc324e8685a..f3d4c4fe31e 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport.php @@ -15,62 +15,62 @@ */ interface Swift_Transport { - /** - * Test if this Transport mechanism has started. - * - * @return bool - */ - public function isStarted(); + /** + * Test if this Transport mechanism has started. + * + * @return bool + */ + public function isStarted(); - /** - * Start this Transport mechanism. - */ - public function start(); + /** + * Start this Transport mechanism. + */ + public function start(); - /** - * Stop this Transport mechanism. - */ - public function stop(); + /** + * Stop this Transport mechanism. + */ + public function stop(); - /** - * Check if this Transport mechanism is alive. - * - * If a Transport mechanism session is no longer functional, the method - * returns FALSE. It is the responsibility of the developer to handle this - * case and restart the Transport mechanism manually. - * - * @example - * - * if (!$transport->ping()) { - * $transport->stop(); - * $transport->start(); - * } - * - * The Transport mechanism will be started, if it is not already. - * - * It is undefined if the Transport mechanism attempts to restart as long as - * the return value reflects whether the mechanism is now functional. - * - * @return bool TRUE if the transport is alive - */ - public function ping(); + /** + * Check if this Transport mechanism is alive. + * + * If a Transport mechanism session is no longer functional, the method + * returns FALSE. It is the responsibility of the developer to handle this + * case and restart the Transport mechanism manually. + * + * @example + * + * if (!$transport->ping()) { + * $transport->stop(); + * $transport->start(); + * } + * + * The Transport mechanism will be started, if it is not already. + * + * It is undefined if the Transport mechanism attempts to restart as long as + * the return value reflects whether the mechanism is now functional. + * + * @return bool TRUE if the transport is alive + */ + public function ping(); - /** - * Send the given Message. - * - * Recipient/sender data will be retrieved from the Message API. - * The return value is the number of recipients who were accepted for delivery. - * - * This is the responsibility of the send method to start the transport if needed. - * - * @param string[] $failedRecipients An array of failures by-reference - * - * @return int - */ - public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null); + /** + * Send the given Message. + * + * Recipient/sender data will be retrieved from the Message API. + * The return value is the number of recipients who were accepted for delivery. + * + * This is the responsibility of the send method to start the transport if needed. + * + * @param string[] $failedRecipients An array of failures by-reference + * + * @return int + */ + public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null); - /** - * Register a plugin in the Transport. - */ - public function registerPlugin(Swift_Events_EventListener $plugin); + /** + * Register a plugin in the Transport. + */ + public function registerPlugin(Swift_Events_EventListener $plugin); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php index d2dbd7a66a0..d761677db7e 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php @@ -15,527 +15,527 @@ */ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport { - /** Input-Output buffer for sending/receiving SMTP commands and responses */ - protected $buffer; - - /** Connection status */ - protected $started = false; - - /** The domain name to use in HELO command */ - protected $domain = '[127.0.0.1]'; - - /** The event dispatching layer */ - protected $eventDispatcher; - - protected $addressEncoder; - - /** Whether the PIPELINING SMTP extension is enabled (RFC 2920) */ - protected $pipelining = null; - - /** The pipelined commands waiting for response */ - protected $pipeline = []; - - /** Source Ip */ - protected $sourceIp; - - /** Return an array of params for the Buffer */ - abstract protected function getBufferParams(); - - /** - * Creates a new EsmtpTransport using the given I/O buffer. - * - * @param string $localDomain - */ - public function __construct(Swift_Transport_IoBuffer $buf, Swift_Events_EventDispatcher $dispatcher, $localDomain = '127.0.0.1', Swift_AddressEncoder $addressEncoder = null) - { - $this->buffer = $buf; - $this->eventDispatcher = $dispatcher; - $this->addressEncoder = $addressEncoder ?? new Swift_AddressEncoder_IdnAddressEncoder(); - $this->setLocalDomain($localDomain); - } - - /** - * Set the name of the local domain which Swift will identify itself as. - * - * This should be a fully-qualified domain name and should be truly the domain - * you're using. - * - * If your server does not have a domain name, use the IP address. This will - * automatically be wrapped in square brackets as described in RFC 5321, - * section 4.1.3. - * - * @param string $domain - * - * @return $this - */ - public function setLocalDomain($domain) - { - if ('[' !== substr($domain, 0, 1)) { - if (filter_var($domain, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { - $domain = '['.$domain.']'; - } elseif (filter_var($domain, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { - $domain = '[IPv6:'.$domain.']'; - } - } - - $this->domain = $domain; - - return $this; - } - - /** - * Get the name of the domain Swift will identify as. - * - * If an IP address was specified, this will be returned wrapped in square - * brackets as described in RFC 5321, section 4.1.3. - * - * @return string - */ - public function getLocalDomain() - { - return $this->domain; - } - - /** - * Sets the source IP. - * - * @param string $source - */ - public function setSourceIp($source) - { - $this->sourceIp = $source; - } - - /** - * Returns the IP used to connect to the destination. - * - * @return string - */ - public function getSourceIp() - { - return $this->sourceIp; - } - - public function setAddressEncoder(Swift_AddressEncoder $addressEncoder) - { - $this->addressEncoder = $addressEncoder; - } - - public function getAddressEncoder() - { - return $this->addressEncoder; - } - - /** - * Start the SMTP connection. - */ - public function start() - { - if (!$this->started) { - if ($evt = $this->eventDispatcher->createTransportChangeEvent($this)) { - $this->eventDispatcher->dispatchEvent($evt, 'beforeTransportStarted'); - if ($evt->bubbleCancelled()) { - return; - } - } - - try { - $this->buffer->initialize($this->getBufferParams()); - } catch (Swift_TransportException $e) { - $this->throwException($e); - } - $this->readGreeting(); - $this->doHeloCommand(); - - if ($evt) { - $this->eventDispatcher->dispatchEvent($evt, 'transportStarted'); - } - - $this->started = true; - } - } - - /** - * Test if an SMTP connection has been established. - * - * @return bool - */ - public function isStarted() - { - return $this->started; - } - - /** - * Send the given Message. - * - * Recipient/sender data will be retrieved from the Message API. - * The return value is the number of recipients who were accepted for delivery. - * - * @param string[] $failedRecipients An array of failures by-reference - * - * @return int - */ - public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) - { - if (!$this->isStarted()) { - $this->start(); - } - - $sent = 0; - $failedRecipients = (array) $failedRecipients; - - if ($evt = $this->eventDispatcher->createSendEvent($this, $message)) { - $this->eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); - if ($evt->bubbleCancelled()) { - return 0; - } - } - - if (!$reversePath = $this->getReversePath($message)) { - $this->throwException(new Swift_TransportException('Cannot send message without a sender address')); - } - - $to = (array) $message->getTo(); - $cc = (array) $message->getCc(); - $bcc = (array) $message->getBcc(); - $tos = array_merge($to, $cc, $bcc); - - $message->setBcc([]); - - try { - $sent += $this->sendTo($message, $reversePath, $tos, $failedRecipients); - } finally { - $message->setBcc($bcc); - } - - if ($evt) { - if ($sent == \count($to) + \count($cc) + \count($bcc)) { - $evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS); - } elseif ($sent > 0) { - $evt->setResult(Swift_Events_SendEvent::RESULT_TENTATIVE); - } else { - $evt->setResult(Swift_Events_SendEvent::RESULT_FAILED); - } - $evt->setFailedRecipients($failedRecipients); - $this->eventDispatcher->dispatchEvent($evt, 'sendPerformed'); - } - - $message->generateId(); //Make sure a new Message ID is used - - return $sent; - } - - /** - * Stop the SMTP connection. - */ - public function stop() - { - if ($this->started) { - if ($evt = $this->eventDispatcher->createTransportChangeEvent($this)) { - $this->eventDispatcher->dispatchEvent($evt, 'beforeTransportStopped'); - if ($evt->bubbleCancelled()) { - return; - } - } - - try { - $this->executeCommand("QUIT\r\n", [221]); - } catch (Swift_TransportException $e) { - } - - try { - $this->buffer->terminate(); - - if ($evt) { - $this->eventDispatcher->dispatchEvent($evt, 'transportStopped'); - } - } catch (Swift_TransportException $e) { - $this->throwException($e); - } - } - $this->started = false; - } - - /** - * {@inheritdoc} - */ - public function ping() - { - try { - if (!$this->isStarted()) { - $this->start(); - } - - $this->executeCommand("NOOP\r\n", [250]); - } catch (Swift_TransportException $e) { - try { - $this->stop(); - } catch (Swift_TransportException $e) { - } - - return false; - } - - return true; - } - - /** - * Register a plugin. - */ - public function registerPlugin(Swift_Events_EventListener $plugin) - { - $this->eventDispatcher->bindEventListener($plugin); - } - - /** - * Reset the current mail transaction. - */ - public function reset() - { - $this->executeCommand("RSET\r\n", [250], $failures, true); - } - - /** - * Get the IoBuffer where read/writes are occurring. - * - * @return Swift_Transport_IoBuffer - */ - public function getBuffer() - { - return $this->buffer; - } - - /** - * Run a command against the buffer, expecting the given response codes. - * - * If no response codes are given, the response will not be validated. - * If codes are given, an exception will be thrown on an invalid response. - * If the command is RCPT TO, and the pipeline is non-empty, no exception - * will be thrown; instead the failing address is added to $failures. - * - * @param string $command - * @param int[] $codes - * @param string[] $failures An array of failures by-reference - * @param bool $pipeline Do not wait for response - * @param string $address the address, if command is RCPT TO - * - * @return string|null The server response, or null if pipelining is enabled - */ - public function executeCommand($command, $codes = [], &$failures = null, $pipeline = false, $address = null) - { - $failures = (array) $failures; - $seq = $this->buffer->write($command); - if ($evt = $this->eventDispatcher->createCommandEvent($this, $command, $codes)) { - $this->eventDispatcher->dispatchEvent($evt, 'commandSent'); - } - - $this->pipeline[] = [$command, $seq, $codes, $address]; - - if ($pipeline && $this->pipelining) { - return null; - } - - $response = null; - - while ($this->pipeline) { - list($command, $seq, $codes, $address) = array_shift($this->pipeline); - $response = $this->getFullResponse($seq); - try { - $this->assertResponseCode($response, $codes); - } catch (Swift_TransportException $e) { - if ($this->pipeline && $address) { - $failures[] = $address; - } else { - $this->throwException($e); - } - } - } - - return $response; - } - - /** Read the opening SMTP greeting */ - protected function readGreeting() - { - $this->assertResponseCode($this->getFullResponse(0), [220]); - } - - /** Send the HELO welcome */ - protected function doHeloCommand() - { - $this->executeCommand( - sprintf("HELO %s\r\n", $this->domain), [250] - ); - } - - /** Send the MAIL FROM command */ - protected function doMailFromCommand($address) - { - $address = $this->addressEncoder->encodeString($address); - $this->executeCommand( - sprintf("MAIL FROM:<%s>\r\n", $address), [250], $failures, true - ); - } - - /** Send the RCPT TO command */ - protected function doRcptToCommand($address) - { - $address = $this->addressEncoder->encodeString($address); - $this->executeCommand( - sprintf("RCPT TO:<%s>\r\n", $address), [250, 251, 252], $failures, true, $address - ); - } - - /** Send the DATA command */ - protected function doDataCommand(&$failedRecipients) - { - $this->executeCommand("DATA\r\n", [354], $failedRecipients); - } - - /** Stream the contents of the message over the buffer */ - protected function streamMessage(Swift_Mime_SimpleMessage $message) - { - $this->buffer->setWriteTranslations(["\r\n." => "\r\n.."]); - try { - $message->toByteStream($this->buffer); - $this->buffer->flushBuffers(); - } catch (Swift_TransportException $e) { - $this->throwException($e); - } - $this->buffer->setWriteTranslations([]); - $this->executeCommand("\r\n.\r\n", [250]); - } - - /** Determine the best-use reverse path for this message */ - protected function getReversePath(Swift_Mime_SimpleMessage $message) - { - $return = $message->getReturnPath(); - $sender = $message->getSender(); - $from = $message->getFrom(); - $path = null; - if (!empty($return)) { - $path = $return; - } elseif (!empty($sender)) { - // Don't use array_keys - reset($sender); // Reset Pointer to first pos - $path = key($sender); // Get key - } elseif (!empty($from)) { - reset($from); // Reset Pointer to first pos - $path = key($from); // Get key - } - - return $path; - } - - /** Throw a TransportException, first sending it to any listeners */ - protected function throwException(Swift_TransportException $e) - { - if ($evt = $this->eventDispatcher->createTransportExceptionEvent($this, $e)) { - $this->eventDispatcher->dispatchEvent($evt, 'exceptionThrown'); - if (!$evt->bubbleCancelled()) { - throw $e; - } - } else { - throw $e; - } - } - - /** Throws an Exception if a response code is incorrect */ - protected function assertResponseCode($response, $wanted) - { - if (!$response) { - $this->throwException(new Swift_TransportException('Expected response code '.implode('/', $wanted).' but got an empty response')); - } - - list($code) = sscanf($response, '%3d'); - $valid = (empty($wanted) || \in_array($code, $wanted)); - - if ($evt = $this->eventDispatcher->createResponseEvent($this, $response, - $valid)) { - $this->eventDispatcher->dispatchEvent($evt, 'responseReceived'); - } - - if (!$valid) { - $this->throwException(new Swift_TransportException('Expected response code '.implode('/', $wanted).' but got code "'.$code.'", with message "'.$response.'"', $code)); - } - } - - /** Get an entire multi-line response using its sequence number */ - protected function getFullResponse($seq) - { - $response = ''; - try { - do { - $line = $this->buffer->readLine($seq); - $response .= $line; - } while (null !== $line && false !== $line && ' ' != $line[3]); - } catch (Swift_TransportException $e) { - $this->throwException($e); - } catch (Swift_IoException $e) { - $this->throwException(new Swift_TransportException($e->getMessage(), 0, $e)); - } - - return $response; - } - - /** Send an email to the given recipients from the given reverse path */ - private function doMailTransaction($message, $reversePath, array $recipients, array &$failedRecipients) - { - $sent = 0; - $this->doMailFromCommand($reversePath); - foreach ($recipients as $forwardPath) { - try { - $this->doRcptToCommand($forwardPath); - ++$sent; - } catch (Swift_TransportException $e) { - $failedRecipients[] = $forwardPath; - } catch (Swift_AddressEncoderException $e) { - $failedRecipients[] = $forwardPath; - } - } - - if (0 != $sent) { - $sent += \count($failedRecipients); - $this->doDataCommand($failedRecipients); - $sent -= \count($failedRecipients); - - $this->streamMessage($message); - } else { - $this->reset(); - } - - return $sent; - } - - /** Send a message to the given To: recipients */ - private function sendTo(Swift_Mime_SimpleMessage $message, $reversePath, array $to, array &$failedRecipients) - { - if (empty($to)) { - return 0; - } - - return $this->doMailTransaction($message, $reversePath, array_keys($to), - $failedRecipients); - } - - /** - * Destructor. - */ - public function __destruct() - { - try { - $this->stop(); - } catch (Exception $e) { - } - } - - public function __sleep() - { - throw new \BadMethodCallException('Cannot serialize '.__CLASS__); - } - - public function __wakeup() - { - throw new \BadMethodCallException('Cannot unserialize '.__CLASS__); - } + /** Input-Output buffer for sending/receiving SMTP commands and responses */ + protected $buffer; + + /** Connection status */ + protected $started = false; + + /** The domain name to use in HELO command */ + protected $domain = '[127.0.0.1]'; + + /** The event dispatching layer */ + protected $eventDispatcher; + + protected $addressEncoder; + + /** Whether the PIPELINING SMTP extension is enabled (RFC 2920) */ + protected $pipelining = null; + + /** The pipelined commands waiting for response */ + protected $pipeline = []; + + /** Source Ip */ + protected $sourceIp; + + /** Return an array of params for the Buffer */ + abstract protected function getBufferParams(); + + /** + * Creates a new EsmtpTransport using the given I/O buffer. + * + * @param string $localDomain + */ + public function __construct(Swift_Transport_IoBuffer $buf, Swift_Events_EventDispatcher $dispatcher, $localDomain = '127.0.0.1', Swift_AddressEncoder $addressEncoder = null) + { + $this->buffer = $buf; + $this->eventDispatcher = $dispatcher; + $this->addressEncoder = $addressEncoder ?? new Swift_AddressEncoder_IdnAddressEncoder(); + $this->setLocalDomain($localDomain); + } + + /** + * Set the name of the local domain which Swift will identify itself as. + * + * This should be a fully-qualified domain name and should be truly the domain + * you're using. + * + * If your server does not have a domain name, use the IP address. This will + * automatically be wrapped in square brackets as described in RFC 5321, + * section 4.1.3. + * + * @param string $domain + * + * @return $this + */ + public function setLocalDomain($domain) + { + if ('[' !== substr($domain, 0, 1)) { + if (filter_var($domain, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { + $domain = '['.$domain.']'; + } elseif (filter_var($domain, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { + $domain = '[IPv6:'.$domain.']'; + } + } + + $this->domain = $domain; + + return $this; + } + + /** + * Get the name of the domain Swift will identify as. + * + * If an IP address was specified, this will be returned wrapped in square + * brackets as described in RFC 5321, section 4.1.3. + * + * @return string + */ + public function getLocalDomain() + { + return $this->domain; + } + + /** + * Sets the source IP. + * + * @param string $source + */ + public function setSourceIp($source) + { + $this->sourceIp = $source; + } + + /** + * Returns the IP used to connect to the destination. + * + * @return string + */ + public function getSourceIp() + { + return $this->sourceIp; + } + + public function setAddressEncoder(Swift_AddressEncoder $addressEncoder) + { + $this->addressEncoder = $addressEncoder; + } + + public function getAddressEncoder() + { + return $this->addressEncoder; + } + + /** + * Start the SMTP connection. + */ + public function start() + { + if (!$this->started) { + if ($evt = $this->eventDispatcher->createTransportChangeEvent($this)) { + $this->eventDispatcher->dispatchEvent($evt, 'beforeTransportStarted'); + if ($evt->bubbleCancelled()) { + return; + } + } + + try { + $this->buffer->initialize($this->getBufferParams()); + } catch (Swift_TransportException $e) { + $this->throwException($e); + } + $this->readGreeting(); + $this->doHeloCommand(); + + if ($evt) { + $this->eventDispatcher->dispatchEvent($evt, 'transportStarted'); + } + + $this->started = true; + } + } + + /** + * Test if an SMTP connection has been established. + * + * @return bool + */ + public function isStarted() + { + return $this->started; + } + + /** + * Send the given Message. + * + * Recipient/sender data will be retrieved from the Message API. + * The return value is the number of recipients who were accepted for delivery. + * + * @param string[] $failedRecipients An array of failures by-reference + * + * @return int + */ + public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) + { + if (!$this->isStarted()) { + $this->start(); + } + + $sent = 0; + $failedRecipients = (array) $failedRecipients; + + if ($evt = $this->eventDispatcher->createSendEvent($this, $message)) { + $this->eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); + if ($evt->bubbleCancelled()) { + return 0; + } + } + + if (!$reversePath = $this->getReversePath($message)) { + $this->throwException(new Swift_TransportException('Cannot send message without a sender address')); + } + + $to = (array) $message->getTo(); + $cc = (array) $message->getCc(); + $bcc = (array) $message->getBcc(); + $tos = array_merge($to, $cc, $bcc); + + $message->setBcc([]); + + try { + $sent += $this->sendTo($message, $reversePath, $tos, $failedRecipients); + } finally { + $message->setBcc($bcc); + } + + if ($evt) { + if ($sent == \count($to) + \count($cc) + \count($bcc)) { + $evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS); + } elseif ($sent > 0) { + $evt->setResult(Swift_Events_SendEvent::RESULT_TENTATIVE); + } else { + $evt->setResult(Swift_Events_SendEvent::RESULT_FAILED); + } + $evt->setFailedRecipients($failedRecipients); + $this->eventDispatcher->dispatchEvent($evt, 'sendPerformed'); + } + + $message->generateId(); //Make sure a new Message ID is used + + return $sent; + } + + /** + * Stop the SMTP connection. + */ + public function stop() + { + if ($this->started) { + if ($evt = $this->eventDispatcher->createTransportChangeEvent($this)) { + $this->eventDispatcher->dispatchEvent($evt, 'beforeTransportStopped'); + if ($evt->bubbleCancelled()) { + return; + } + } + + try { + $this->executeCommand("QUIT\r\n", [221]); + } catch (Swift_TransportException $e) { + } + + try { + $this->buffer->terminate(); + + if ($evt) { + $this->eventDispatcher->dispatchEvent($evt, 'transportStopped'); + } + } catch (Swift_TransportException $e) { + $this->throwException($e); + } + } + $this->started = false; + } + + /** + * {@inheritdoc} + */ + public function ping() + { + try { + if (!$this->isStarted()) { + $this->start(); + } + + $this->executeCommand("NOOP\r\n", [250]); + } catch (Swift_TransportException $e) { + try { + $this->stop(); + } catch (Swift_TransportException $e) { + } + + return false; + } + + return true; + } + + /** + * Register a plugin. + */ + public function registerPlugin(Swift_Events_EventListener $plugin) + { + $this->eventDispatcher->bindEventListener($plugin); + } + + /** + * Reset the current mail transaction. + */ + public function reset() + { + $this->executeCommand("RSET\r\n", [250], $failures, true); + } + + /** + * Get the IoBuffer where read/writes are occurring. + * + * @return Swift_Transport_IoBuffer + */ + public function getBuffer() + { + return $this->buffer; + } + + /** + * Run a command against the buffer, expecting the given response codes. + * + * If no response codes are given, the response will not be validated. + * If codes are given, an exception will be thrown on an invalid response. + * If the command is RCPT TO, and the pipeline is non-empty, no exception + * will be thrown; instead the failing address is added to $failures. + * + * @param string $command + * @param int[] $codes + * @param string[] $failures An array of failures by-reference + * @param bool $pipeline Do not wait for response + * @param string $address the address, if command is RCPT TO + * + * @return string|null The server response, or null if pipelining is enabled + */ + public function executeCommand($command, $codes = [], &$failures = null, $pipeline = false, $address = null) + { + $failures = (array) $failures; + $seq = $this->buffer->write($command); + if ($evt = $this->eventDispatcher->createCommandEvent($this, $command, $codes)) { + $this->eventDispatcher->dispatchEvent($evt, 'commandSent'); + } + + $this->pipeline[] = [$command, $seq, $codes, $address]; + + if ($pipeline && $this->pipelining) { + return null; + } + + $response = null; + + while ($this->pipeline) { + list($command, $seq, $codes, $address) = array_shift($this->pipeline); + $response = $this->getFullResponse($seq); + try { + $this->assertResponseCode($response, $codes); + } catch (Swift_TransportException $e) { + if ($this->pipeline && $address) { + $failures[] = $address; + } else { + $this->throwException($e); + } + } + } + + return $response; + } + + /** Read the opening SMTP greeting */ + protected function readGreeting() + { + $this->assertResponseCode($this->getFullResponse(0), [220]); + } + + /** Send the HELO welcome */ + protected function doHeloCommand() + { + $this->executeCommand( + sprintf("HELO %s\r\n", $this->domain), [250] + ); + } + + /** Send the MAIL FROM command */ + protected function doMailFromCommand($address) + { + $address = $this->addressEncoder->encodeString($address); + $this->executeCommand( + sprintf("MAIL FROM:<%s>\r\n", $address), [250], $failures, true + ); + } + + /** Send the RCPT TO command */ + protected function doRcptToCommand($address) + { + $address = $this->addressEncoder->encodeString($address); + $this->executeCommand( + sprintf("RCPT TO:<%s>\r\n", $address), [250, 251, 252], $failures, true, $address + ); + } + + /** Send the DATA command */ + protected function doDataCommand(&$failedRecipients) + { + $this->executeCommand("DATA\r\n", [354], $failedRecipients); + } + + /** Stream the contents of the message over the buffer */ + protected function streamMessage(Swift_Mime_SimpleMessage $message) + { + $this->buffer->setWriteTranslations(["\r\n." => "\r\n.."]); + try { + $message->toByteStream($this->buffer); + $this->buffer->flushBuffers(); + } catch (Swift_TransportException $e) { + $this->throwException($e); + } + $this->buffer->setWriteTranslations([]); + $this->executeCommand("\r\n.\r\n", [250]); + } + + /** Determine the best-use reverse path for this message */ + protected function getReversePath(Swift_Mime_SimpleMessage $message) + { + $return = $message->getReturnPath(); + $sender = $message->getSender(); + $from = $message->getFrom(); + $path = null; + if (!empty($return)) { + $path = $return; + } elseif (!empty($sender)) { + // Don't use array_keys + reset($sender); // Reset Pointer to first pos + $path = key($sender); // Get key + } elseif (!empty($from)) { + reset($from); // Reset Pointer to first pos + $path = key($from); // Get key + } + + return $path; + } + + /** Throw a TransportException, first sending it to any listeners */ + protected function throwException(Swift_TransportException $e) + { + if ($evt = $this->eventDispatcher->createTransportExceptionEvent($this, $e)) { + $this->eventDispatcher->dispatchEvent($evt, 'exceptionThrown'); + if (!$evt->bubbleCancelled()) { + throw $e; + } + } else { + throw $e; + } + } + + /** Throws an Exception if a response code is incorrect */ + protected function assertResponseCode($response, $wanted) + { + if (!$response) { + $this->throwException(new Swift_TransportException('Expected response code '.implode('/', $wanted).' but got an empty response')); + } + + list($code) = sscanf($response, '%3d'); + $valid = (empty($wanted) || \in_array($code, $wanted)); + + if ($evt = $this->eventDispatcher->createResponseEvent($this, $response, + $valid)) { + $this->eventDispatcher->dispatchEvent($evt, 'responseReceived'); + } + + if (!$valid) { + $this->throwException(new Swift_TransportException('Expected response code '.implode('/', $wanted).' but got code "'.$code.'", with message "'.$response.'"', $code)); + } + } + + /** Get an entire multi-line response using its sequence number */ + protected function getFullResponse($seq) + { + $response = ''; + try { + do { + $line = $this->buffer->readLine($seq); + $response .= $line; + } while (null !== $line && false !== $line && ' ' != $line[3]); + } catch (Swift_TransportException $e) { + $this->throwException($e); + } catch (Swift_IoException $e) { + $this->throwException(new Swift_TransportException($e->getMessage(), 0, $e)); + } + + return $response; + } + + /** Send an email to the given recipients from the given reverse path */ + private function doMailTransaction($message, $reversePath, array $recipients, array &$failedRecipients) + { + $sent = 0; + $this->doMailFromCommand($reversePath); + foreach ($recipients as $forwardPath) { + try { + $this->doRcptToCommand($forwardPath); + ++$sent; + } catch (Swift_TransportException $e) { + $failedRecipients[] = $forwardPath; + } catch (Swift_AddressEncoderException $e) { + $failedRecipients[] = $forwardPath; + } + } + + if (0 != $sent) { + $sent += \count($failedRecipients); + $this->doDataCommand($failedRecipients); + $sent -= \count($failedRecipients); + + $this->streamMessage($message); + } else { + $this->reset(); + } + + return $sent; + } + + /** Send a message to the given To: recipients */ + private function sendTo(Swift_Mime_SimpleMessage $message, $reversePath, array $to, array &$failedRecipients) + { + if (empty($to)) { + return 0; + } + + return $this->doMailTransaction($message, $reversePath, array_keys($to), + $failedRecipients); + } + + /** + * Destructor. + */ + public function __destruct() + { + try { + $this->stop(); + } catch (Exception $e) { + } + } + + public function __sleep() + { + throw new \BadMethodCallException('Cannot serialize '.__CLASS__); + } + + public function __wakeup() + { + throw new \BadMethodCallException('Cannot unserialize '.__CLASS__); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php index bb3a1615096..1c577324ced 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php @@ -15,61 +15,61 @@ */ class Swift_Transport_Esmtp_Auth_CramMd5Authenticator implements Swift_Transport_Esmtp_Authenticator { - /** - * Get the name of the AUTH mechanism this Authenticator handles. - * - * @return string - */ - public function getAuthKeyword() - { - return 'CRAM-MD5'; - } + /** + * Get the name of the AUTH mechanism this Authenticator handles. + * + * @return string + */ + public function getAuthKeyword() + { + return 'CRAM-MD5'; + } - /** - * {@inheritdoc} - */ - public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password) - { - try { - $challenge = $agent->executeCommand("AUTH CRAM-MD5\r\n", [334]); - $challenge = base64_decode(substr($challenge, 4)); - $message = base64_encode( - $username.' '.$this->getResponse($password, $challenge) - ); - $agent->executeCommand(sprintf("%s\r\n", $message), [235]); + /** + * {@inheritdoc} + */ + public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password) + { + try { + $challenge = $agent->executeCommand("AUTH CRAM-MD5\r\n", [334]); + $challenge = base64_decode(substr($challenge, 4)); + $message = base64_encode( + $username.' '.$this->getResponse($password, $challenge) + ); + $agent->executeCommand(sprintf("%s\r\n", $message), [235]); - return true; - } catch (Swift_TransportException $e) { - $agent->executeCommand("RSET\r\n", [250]); + return true; + } catch (Swift_TransportException $e) { + $agent->executeCommand("RSET\r\n", [250]); - throw $e; - } - } + throw $e; + } + } - /** - * Generate a CRAM-MD5 response from a server challenge. - * - * @param string $secret - * @param string $challenge - * - * @return string - */ - private function getResponse($secret, $challenge) - { - if (\strlen($secret) > 64) { - $secret = pack('H32', md5($secret)); - } + /** + * Generate a CRAM-MD5 response from a server challenge. + * + * @param string $secret + * @param string $challenge + * + * @return string + */ + private function getResponse($secret, $challenge) + { + if (\strlen($secret) > 64) { + $secret = pack('H32', md5($secret)); + } - if (\strlen($secret) < 64) { - $secret = str_pad($secret, 64, \chr(0)); - } + if (\strlen($secret) < 64) { + $secret = str_pad($secret, 64, \chr(0)); + } - $k_ipad = substr($secret, 0, 64) ^ str_repeat(\chr(0x36), 64); - $k_opad = substr($secret, 0, 64) ^ str_repeat(\chr(0x5C), 64); + $k_ipad = substr($secret, 0, 64) ^ str_repeat(\chr(0x36), 64); + $k_opad = substr($secret, 0, 64) ^ str_repeat(\chr(0x5C), 64); - $inner = pack('H32', md5($k_ipad.$challenge)); - $digest = md5($k_opad.$inner); + $inner = pack('H32', md5($k_ipad.$challenge)); + $digest = md5($k_opad.$inner); - return $digest; - } + return $digest; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php index 0b9d81b8ad6..22e9ac723fd 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php @@ -15,31 +15,31 @@ */ class Swift_Transport_Esmtp_Auth_LoginAuthenticator implements Swift_Transport_Esmtp_Authenticator { - /** - * Get the name of the AUTH mechanism this Authenticator handles. - * - * @return string - */ - public function getAuthKeyword() - { - return 'LOGIN'; - } + /** + * Get the name of the AUTH mechanism this Authenticator handles. + * + * @return string + */ + public function getAuthKeyword() + { + return 'LOGIN'; + } - /** - * {@inheritdoc} - */ - public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password) - { - try { - $agent->executeCommand("AUTH LOGIN\r\n", [334]); - $agent->executeCommand(sprintf("%s\r\n", base64_encode($username ?? '')), [334]); - $agent->executeCommand(sprintf("%s\r\n", base64_encode($password ?? '')), [235]); + /** + * {@inheritdoc} + */ + public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password) + { + try { + $agent->executeCommand("AUTH LOGIN\r\n", [334]); + $agent->executeCommand(sprintf("%s\r\n", base64_encode($username ?? '')), [334]); + $agent->executeCommand(sprintf("%s\r\n", base64_encode($password ?? '')), [235]); - return true; - } catch (Swift_TransportException $e) { - $agent->executeCommand("RSET\r\n", [250]); + return true; + } catch (Swift_TransportException $e) { + $agent->executeCommand("RSET\r\n", [250]); - throw $e; - } - } + throw $e; + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/NTLMAuthenticator.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/NTLMAuthenticator.php index 41931fdd226..dfccdecf200 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/NTLMAuthenticator.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/NTLMAuthenticator.php @@ -17,665 +17,665 @@ */ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Esmtp_Authenticator { - const NTLMSIG = "NTLMSSP\x00"; - const DESCONST = 'KGS!@#$%'; - - /** - * Get the name of the AUTH mechanism this Authenticator handles. - * - * @return string - */ - public function getAuthKeyword() - { - return 'NTLM'; - } - - /** - * {@inheritdoc} - * - * @throws \LogicException - */ - public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password) - { - if (!\function_exists('openssl_encrypt')) { - throw new LogicException('The OpenSSL extension must be enabled to use the NTLM authenticator.'); - } - - if (!\function_exists('bcmul')) { - throw new LogicException('The BCMath functions must be enabled to use the NTLM authenticator.'); - } - - try { - // execute AUTH command and filter out the code at the beginning - // AUTH NTLM xxxx - $response = base64_decode(substr(trim($this->sendMessage1($agent) ?? ''), 4)); - - // extra parameters for our unit cases - $timestamp = \func_num_args() > 3 ? func_get_arg(3) : $this->getCorrectTimestamp(bcmul(microtime(true), '1000')); - $client = \func_num_args() > 4 ? func_get_arg(4) : random_bytes(8); - - // Message 3 response - $this->sendMessage3($response, $username, $password, $timestamp, $client, $agent); - - return true; - } catch (Swift_TransportException $e) { - $agent->executeCommand("RSET\r\n", [250]); - - throw $e; - } - } - - protected function si2bin($si, $bits = 32) - { - $bin = null; - if ($si >= -2 ** ($bits - 1) && ($si <= 2 ** ($bits - 1))) { - // positive or zero - if ($si >= 0) { - $bin = base_convert($si, 10, 2); - // pad to $bits bit - $bin_length = \strlen($bin); - if ($bin_length < $bits) { - $bin = str_repeat('0', $bits - $bin_length).$bin; - } - } else { - // negative - $si = -$si - 2 ** $bits; - $bin = base_convert($si, 10, 2); - $bin_length = \strlen($bin); - if ($bin_length > $bits) { - $bin = str_repeat('1', $bits - $bin_length).$bin; - } - } - } - - return $bin; - } - - /** - * Send our auth message and returns the response. - * - * @return string SMTP Response - */ - protected function sendMessage1(Swift_Transport_SmtpAgent $agent) - { - $message = $this->createMessage1(); - - return $agent->executeCommand(sprintf("AUTH %s %s\r\n", $this->getAuthKeyword(), base64_encode($message)), [334]); - } - - /** - * Fetch all details of our response (message 2). - * - * @param string $response - * - * @return array our response parsed - */ - protected function parseMessage2($response) - { - $responseHex = bin2hex($response); - $length = floor(hexdec(substr($responseHex, 28, 4)) / 256) * 2; - $offset = floor(hexdec(substr($responseHex, 32, 4)) / 256) * 2; - $challenge = hex2bin(substr($responseHex, 48, 16)); - $context = hex2bin(substr($responseHex, 64, 16)); - $targetInfoH = hex2bin(substr($responseHex, 80, 16)); - $targetName = hex2bin(substr($responseHex, $offset, $length)); - $offset = floor(hexdec(substr($responseHex, 88, 4)) / 256) * 2; - $targetInfoBlock = substr($responseHex, $offset); - list($domainName, $serverName, $DNSDomainName, $DNSServerName, $terminatorByte) = $this->readSubBlock($targetInfoBlock); - - return [ - $challenge, - $context, - $targetInfoH, - $targetName, - $domainName, - $serverName, - $DNSDomainName, - $DNSServerName, - hex2bin($targetInfoBlock), - $terminatorByte, - ]; - } - - /** - * Read the blob information in from message2. - * - * @return array - */ - protected function readSubBlock($block) - { - // remove terminatorByte cause it's always the same - $block = substr($block, 0, -8); - - $length = \strlen($block); - $offset = 0; - $data = []; - while ($offset < $length) { - $blockLength = hexdec(substr(substr($block, $offset, 8), -4)) / 256; - $offset += 8; - $data[] = hex2bin(substr($block, $offset, $blockLength * 2)); - $offset += $blockLength * 2; - } - - if (3 == \count($data)) { - $data[] = $data[2]; - $data[2] = ''; - } - - $data[] = $this->createByte('00'); - - return $data; - } - - /** - * Send our final message with all our data. - * - * @param string $response Message 1 response (message 2) - * @param string $username - * @param string $password - * @param string $timestamp - * @param string $client - * @param bool $v2 Use version2 of the protocol - * - * @return string - */ - protected function sendMessage3($response, $username, $password, $timestamp, $client, Swift_Transport_SmtpAgent $agent, $v2 = true) - { - list($domain, $username) = $this->getDomainAndUsername($username); - //$challenge, $context, $targetInfoH, $targetName, $domainName, $workstation, $DNSDomainName, $DNSServerName, $blob, $ter - list($challenge, , , , , $workstation, , , $blob) = $this->parseMessage2($response); - - if (!$v2) { - // LMv1 - $lmResponse = $this->createLMPassword($password, $challenge); - // NTLMv1 - $ntlmResponse = $this->createNTLMPassword($password, $challenge); - } else { - // LMv2 - $lmResponse = $this->createLMv2Password($password, $username, $domain, $challenge, $client); - // NTLMv2 - $ntlmResponse = $this->createNTLMv2Hash($password, $username, $domain, $challenge, $blob, $timestamp, $client); - } - - $message = $this->createMessage3($domain, $username, $workstation, $lmResponse, $ntlmResponse); - - return $agent->executeCommand(sprintf("%s\r\n", base64_encode($message)), [235]); - } - - /** - * Create our message 1. - * - * @return string - */ - protected function createMessage1() - { - return self::NTLMSIG - .$this->createByte('01') // Message 1 -.$this->createByte('0702'); // Flags - } - - /** - * Create our message 3. - * - * @param string $domain - * @param string $username - * @param string $workstation - * @param string $lmResponse - * @param string $ntlmResponse - * - * @return string - */ - protected function createMessage3($domain, $username, $workstation, $lmResponse, $ntlmResponse) - { - // Create security buffers - $domainSec = $this->createSecurityBuffer($domain, 64); - $domainInfo = $this->readSecurityBuffer(bin2hex($domainSec)); - $userSec = $this->createSecurityBuffer($username, ($domainInfo[0] + $domainInfo[1]) / 2); - $userInfo = $this->readSecurityBuffer(bin2hex($userSec)); - $workSec = $this->createSecurityBuffer($workstation, ($userInfo[0] + $userInfo[1]) / 2); - $workInfo = $this->readSecurityBuffer(bin2hex($workSec)); - $lmSec = $this->createSecurityBuffer($lmResponse, ($workInfo[0] + $workInfo[1]) / 2, true); - $lmInfo = $this->readSecurityBuffer(bin2hex($lmSec)); - $ntlmSec = $this->createSecurityBuffer($ntlmResponse, ($lmInfo[0] + $lmInfo[1]) / 2, true); - - return self::NTLMSIG - .$this->createByte('03') // TYPE 3 message -.$lmSec // LM response header -.$ntlmSec // NTLM response header -.$domainSec // Domain header -.$userSec // User header -.$workSec // Workstation header -.$this->createByte('000000009a', 8) // session key header (empty) -.$this->createByte('01020000') // FLAGS -.$this->convertTo16bit($domain) // domain name -.$this->convertTo16bit($username) // username -.$this->convertTo16bit($workstation) // workstation -.$lmResponse - .$ntlmResponse; - } - - /** - * @param string $timestamp Epoch timestamp in microseconds - * @param string $client Random bytes - * @param string $targetInfo - * - * @return string - */ - protected function createBlob($timestamp, $client, $targetInfo) - { - return $this->createByte('0101') - .$this->createByte('00') - .$timestamp - .$client - .$this->createByte('00') - .$targetInfo - .$this->createByte('00'); - } - - /** - * Get domain and username from our username. - * - * @example DOMAIN\username - * - * @param string $name - * - * @return array - */ - protected function getDomainAndUsername($name) - { - if (false !== strpos($name, '\\')) { - return explode('\\', $name); - } - - if (false !== strpos($name, '@')) { - list($user, $domain) = explode('@', $name); - - return [$domain, $user]; - } - - // no domain passed - return ['', $name]; - } - - /** - * Create LMv1 response. - * - * @param string $password - * @param string $challenge - * - * @return string - */ - protected function createLMPassword($password, $challenge) - { - // FIRST PART - $password = $this->createByte(strtoupper($password), 14, false); - list($key1, $key2) = str_split($password, 7); - - $desKey1 = $this->createDesKey($key1); - $desKey2 = $this->createDesKey($key2); - - $constantDecrypt = $this->createByte($this->desEncrypt(self::DESCONST, $desKey1).$this->desEncrypt(self::DESCONST, $desKey2), 21, false); - - // SECOND PART - list($key1, $key2, $key3) = str_split($constantDecrypt, 7); - - $desKey1 = $this->createDesKey($key1); - $desKey2 = $this->createDesKey($key2); - $desKey3 = $this->createDesKey($key3); - - return $this->desEncrypt($challenge, $desKey1).$this->desEncrypt($challenge, $desKey2).$this->desEncrypt($challenge, $desKey3); - } - - /** - * Create NTLMv1 response. - * - * @param string $password - * @param string $challenge - * - * @return string - */ - protected function createNTLMPassword($password, $challenge) - { - // FIRST PART - $ntlmHash = $this->createByte($this->md4Encrypt($password), 21, false); - list($key1, $key2, $key3) = str_split($ntlmHash, 7); - - $desKey1 = $this->createDesKey($key1); - $desKey2 = $this->createDesKey($key2); - $desKey3 = $this->createDesKey($key3); - - return $this->desEncrypt($challenge, $desKey1).$this->desEncrypt($challenge, $desKey2).$this->desEncrypt($challenge, $desKey3); - } - - /** - * Convert a normal timestamp to a tenth of a microtime epoch time. - * - * @param string $time - * - * @return string - */ - protected function getCorrectTimestamp($time) - { - // Get our timestamp (tricky!) - $time = number_format($time, 0, '.', ''); // save microtime to string - $time = bcadd($time, '11644473600000', 0); // add epoch time - $time = bcmul($time, 10000, 0); // tenths of a microsecond. - - $binary = $this->si2bin($time, 64); // create 64 bit binary string - $timestamp = ''; - for ($i = 0; $i < 8; ++$i) { - $timestamp .= \chr(bindec(substr($binary, -(($i + 1) * 8), 8))); - } - - return $timestamp; - } - - /** - * Create LMv2 response. - * - * @param string $password - * @param string $username - * @param string $domain - * @param string $challenge NTLM Challenge - * @param string $client Random string - * - * @return string - */ - protected function createLMv2Password($password, $username, $domain, $challenge, $client) - { - $lmPass = '00'; // by default 00 - // if $password > 15 than we can't use this method - if (\strlen($password) <= 15) { - $ntlmHash = $this->md4Encrypt($password); - $ntml2Hash = $this->md5Encrypt($ntlmHash, $this->convertTo16bit(strtoupper($username).$domain)); - - $lmPass = bin2hex($this->md5Encrypt($ntml2Hash, $challenge.$client).$client); - } - - return $this->createByte($lmPass, 24); - } - - /** - * Create NTLMv2 response. - * - * @param string $password - * @param string $username - * @param string $domain - * @param string $challenge Hex values - * @param string $targetInfo Hex values - * @param string $timestamp - * @param string $client Random bytes - * - * @return string - * - * @see http://davenport.sourceforge.net/ntlm.html#theNtlmResponse - */ - protected function createNTLMv2Hash($password, $username, $domain, $challenge, $targetInfo, $timestamp, $client) - { - $ntlmHash = $this->md4Encrypt($password); - $ntml2Hash = $this->md5Encrypt($ntlmHash, $this->convertTo16bit(strtoupper($username).$domain)); - - // create blob - $blob = $this->createBlob($timestamp, $client, $targetInfo); - - $ntlmv2Response = $this->md5Encrypt($ntml2Hash, $challenge.$blob); - - return $ntlmv2Response.$blob; - } - - protected function createDesKey($key) - { - $material = [bin2hex($key[0])]; - $len = \strlen($key); - for ($i = 1; $i < $len; ++$i) { - list($high, $low) = str_split(bin2hex($key[$i])); - $v = $this->castToByte(\ord($key[$i - 1]) << (7 + 1 - $i) | $this->uRShift(hexdec(dechex(hexdec($high) & 0xf).dechex(hexdec($low) & 0xf)), $i)); - $material[] = str_pad(substr(dechex($v), -2), 2, '0', STR_PAD_LEFT); // cast to byte - } - $material[] = str_pad(substr(dechex($this->castToByte(\ord($key[6]) << 1)), -2), 2, '0'); - - // odd parity - foreach ($material as $k => $v) { - $b = $this->castToByte(hexdec($v)); - $needsParity = 0 == (($this->uRShift($b, 7) ^ $this->uRShift($b, 6) ^ $this->uRShift($b, 5) - ^ $this->uRShift($b, 4) ^ $this->uRShift($b, 3) ^ $this->uRShift($b, 2) - ^ $this->uRShift($b, 1)) & 0x01); - - list($high, $low) = str_split($v); - if ($needsParity) { - $material[$k] = dechex(hexdec($high) | 0x0).dechex(hexdec($low) | 0x1); - } else { - $material[$k] = dechex(hexdec($high) & 0xf).dechex(hexdec($low) & 0xe); - } - } - - return hex2bin(implode('', $material)); - } - - /** HELPER FUNCTIONS */ - - /** - * Create our security buffer depending on length and offset. - * - * @param string $value Value we want to put in - * @param int $offset start of value - * @param bool $is16 Do we 16bit string or not? - * - * @return string - */ - protected function createSecurityBuffer($value, $offset, $is16 = false) - { - $length = \strlen(bin2hex($value)); - $length = $is16 ? $length / 2 : $length; - $length = $this->createByte(str_pad(dechex($length), 2, '0', STR_PAD_LEFT), 2); - - return $length.$length.$this->createByte(dechex($offset), 4); - } - - /** - * Read our security buffer to fetch length and offset of our value. - * - * @param string $value Securitybuffer in hex - * - * @return array array with length and offset - */ - protected function readSecurityBuffer($value) - { - $length = floor(hexdec(substr($value, 0, 4)) / 256) * 2; - $offset = floor(hexdec(substr($value, 8, 4)) / 256) * 2; - - return [$length, $offset]; - } - - /** - * Cast to byte java equivalent to (byte). - * - * @param int $v - * - * @return int - */ - protected function castToByte($v) - { - return (($v + 128) % 256) - 128; - } - - /** - * Java unsigned right bitwise - * $a >>> $b. - * - * @param int $a - * @param int $b - * - * @return int - */ - protected function uRShift($a, $b) - { - if (0 == $b) { - return $a; - } - - return ($a >> $b) & ~(1 << (8 * PHP_INT_SIZE - 1) >> ($b - 1)); - } - - /** - * Right padding with 0 to certain length. - * - * @param string $input - * @param int $bytes Length of bytes - * @param bool $isHex Did we provided hex value - * - * @return string - */ - protected function createByte($input, $bytes = 4, $isHex = true) - { - if ($isHex) { - $byte = hex2bin(str_pad($input, $bytes * 2, '00')); - } else { - $byte = str_pad($input, $bytes, "\x00"); - } - - return $byte; - } - - /** ENCRYPTION ALGORITHMS */ - - /** - * DES Encryption. - * - * @param string $value An 8-byte string - * @param string $key - * - * @return string - */ - protected function desEncrypt($value, $key) - { - return substr(openssl_encrypt($value, 'DES-ECB', $key, \OPENSSL_RAW_DATA), 0, 8); - } - - /** - * MD5 Encryption. - * - * @param string $key Encryption key - * @param string $msg Message to encrypt - * - * @return string - */ - protected function md5Encrypt($key, $msg) - { - $blocksize = 64; - if (\strlen($key) > $blocksize) { - $key = pack('H*', md5($key)); - } - - $key = str_pad($key, $blocksize, "\0"); - $ipadk = $key ^ str_repeat("\x36", $blocksize); - $opadk = $key ^ str_repeat("\x5c", $blocksize); - - return pack('H*', md5($opadk.pack('H*', md5($ipadk.$msg)))); - } - - /** - * MD4 Encryption. - * - * @param string $input - * - * @return string - * - * @see https://secure.php.net/manual/en/ref.hash.php - */ - protected function md4Encrypt($input) - { - $input = $this->convertTo16bit($input); - - return \function_exists('hash') ? hex2bin(hash('md4', $input)) : mhash(MHASH_MD4, $input); - } - - /** - * Convert UTF-8 to UTF-16. - * - * @param string $input - * - * @return string - */ - protected function convertTo16bit($input) - { - return iconv('UTF-8', 'UTF-16LE', $input); - } - - /** - * @param string $message - */ - protected function debug($message) - { - $message = bin2hex($message); - $messageId = substr($message, 16, 8); - echo substr($message, 0, 16)." NTLMSSP Signature
\n"; - echo $messageId." Type Indicator
\n"; - - if ('02000000' == $messageId) { - $map = [ - 'Challenge', - 'Context', - 'Target Information Security Buffer', - 'Target Name Data', - 'NetBIOS Domain Name', - 'NetBIOS Server Name', - 'DNS Domain Name', - 'DNS Server Name', - 'BLOB', - 'Target Information Terminator', - ]; - - $data = $this->parseMessage2(hex2bin($message)); - - foreach ($map as $key => $value) { - echo bin2hex($data[$key]).' - '.$data[$key].' ||| '.$value."
\n"; - } - } elseif ('03000000' == $messageId) { - $i = 0; - $data[$i++] = substr($message, 24, 16); - list($lmLength, $lmOffset) = $this->readSecurityBuffer($data[$i - 1]); - - $data[$i++] = substr($message, 40, 16); - list($ntmlLength, $ntmlOffset) = $this->readSecurityBuffer($data[$i - 1]); - - $data[$i++] = substr($message, 56, 16); - list($targetLength, $targetOffset) = $this->readSecurityBuffer($data[$i - 1]); - - $data[$i++] = substr($message, 72, 16); - list($userLength, $userOffset) = $this->readSecurityBuffer($data[$i - 1]); - - $data[$i++] = substr($message, 88, 16); - list($workLength, $workOffset) = $this->readSecurityBuffer($data[$i - 1]); - - $data[$i++] = substr($message, 104, 16); - $data[$i++] = substr($message, 120, 8); - $data[$i++] = substr($message, $targetOffset, $targetLength); - $data[$i++] = substr($message, $userOffset, $userLength); - $data[$i++] = substr($message, $workOffset, $workLength); - $data[$i++] = substr($message, $lmOffset, $lmLength); - $data[$i] = substr($message, $ntmlOffset, $ntmlLength); - - $map = [ - 'LM Response Security Buffer', - 'NTLM Response Security Buffer', - 'Target Name Security Buffer', - 'User Name Security Buffer', - 'Workstation Name Security Buffer', - 'Session Key Security Buffer', - 'Flags', - 'Target Name Data', - 'User Name Data', - 'Workstation Name Data', - 'LM Response Data', - 'NTLM Response Data', - ]; - - foreach ($map as $key => $value) { - echo $data[$key].' - '.hex2bin($data[$key]).' ||| '.$value."
\n"; - } - } - - echo '

'; - } + const NTLMSIG = "NTLMSSP\x00"; + const DESCONST = 'KGS!@#$%'; + + /** + * Get the name of the AUTH mechanism this Authenticator handles. + * + * @return string + */ + public function getAuthKeyword() + { + return 'NTLM'; + } + + /** + * {@inheritdoc} + * + * @throws \LogicException + */ + public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password) + { + if (!\function_exists('openssl_encrypt')) { + throw new LogicException('The OpenSSL extension must be enabled to use the NTLM authenticator.'); + } + + if (!\function_exists('bcmul')) { + throw new LogicException('The BCMath functions must be enabled to use the NTLM authenticator.'); + } + + try { + // execute AUTH command and filter out the code at the beginning + // AUTH NTLM xxxx + $response = base64_decode(substr(trim($this->sendMessage1($agent) ?? ''), 4)); + + // extra parameters for our unit cases + $timestamp = \func_num_args() > 3 ? func_get_arg(3) : $this->getCorrectTimestamp(bcmul(microtime(true), '1000')); + $client = \func_num_args() > 4 ? func_get_arg(4) : random_bytes(8); + + // Message 3 response + $this->sendMessage3($response, $username, $password, $timestamp, $client, $agent); + + return true; + } catch (Swift_TransportException $e) { + $agent->executeCommand("RSET\r\n", [250]); + + throw $e; + } + } + + protected function si2bin($si, $bits = 32) + { + $bin = null; + if ($si >= -2 ** ($bits - 1) && ($si <= 2 ** ($bits - 1))) { + // positive or zero + if ($si >= 0) { + $bin = base_convert($si, 10, 2); + // pad to $bits bit + $bin_length = \strlen($bin); + if ($bin_length < $bits) { + $bin = str_repeat('0', $bits - $bin_length).$bin; + } + } else { + // negative + $si = -$si - 2 ** $bits; + $bin = base_convert($si, 10, 2); + $bin_length = \strlen($bin); + if ($bin_length > $bits) { + $bin = str_repeat('1', $bits - $bin_length).$bin; + } + } + } + + return $bin; + } + + /** + * Send our auth message and returns the response. + * + * @return string SMTP Response + */ + protected function sendMessage1(Swift_Transport_SmtpAgent $agent) + { + $message = $this->createMessage1(); + + return $agent->executeCommand(sprintf("AUTH %s %s\r\n", $this->getAuthKeyword(), base64_encode($message)), [334]); + } + + /** + * Fetch all details of our response (message 2). + * + * @param string $response + * + * @return array our response parsed + */ + protected function parseMessage2($response) + { + $responseHex = bin2hex($response); + $length = floor(hexdec(substr($responseHex, 28, 4)) / 256) * 2; + $offset = floor(hexdec(substr($responseHex, 32, 4)) / 256) * 2; + $challenge = hex2bin(substr($responseHex, 48, 16)); + $context = hex2bin(substr($responseHex, 64, 16)); + $targetInfoH = hex2bin(substr($responseHex, 80, 16)); + $targetName = hex2bin(substr($responseHex, $offset, $length)); + $offset = floor(hexdec(substr($responseHex, 88, 4)) / 256) * 2; + $targetInfoBlock = substr($responseHex, $offset); + list($domainName, $serverName, $DNSDomainName, $DNSServerName, $terminatorByte) = $this->readSubBlock($targetInfoBlock); + + return [ + $challenge, + $context, + $targetInfoH, + $targetName, + $domainName, + $serverName, + $DNSDomainName, + $DNSServerName, + hex2bin($targetInfoBlock), + $terminatorByte, + ]; + } + + /** + * Read the blob information in from message2. + * + * @return array + */ + protected function readSubBlock($block) + { + // remove terminatorByte cause it's always the same + $block = substr($block, 0, -8); + + $length = \strlen($block); + $offset = 0; + $data = []; + while ($offset < $length) { + $blockLength = hexdec(substr(substr($block, $offset, 8), -4)) / 256; + $offset += 8; + $data[] = hex2bin(substr($block, $offset, $blockLength * 2)); + $offset += $blockLength * 2; + } + + if (3 == \count($data)) { + $data[] = $data[2]; + $data[2] = ''; + } + + $data[] = $this->createByte('00'); + + return $data; + } + + /** + * Send our final message with all our data. + * + * @param string $response Message 1 response (message 2) + * @param string $username + * @param string $password + * @param string $timestamp + * @param string $client + * @param bool $v2 Use version2 of the protocol + * + * @return string + */ + protected function sendMessage3($response, $username, $password, $timestamp, $client, Swift_Transport_SmtpAgent $agent, $v2 = true) + { + list($domain, $username) = $this->getDomainAndUsername($username); + //$challenge, $context, $targetInfoH, $targetName, $domainName, $workstation, $DNSDomainName, $DNSServerName, $blob, $ter + list($challenge, , , , , $workstation, , , $blob) = $this->parseMessage2($response); + + if (!$v2) { + // LMv1 + $lmResponse = $this->createLMPassword($password, $challenge); + // NTLMv1 + $ntlmResponse = $this->createNTLMPassword($password, $challenge); + } else { + // LMv2 + $lmResponse = $this->createLMv2Password($password, $username, $domain, $challenge, $client); + // NTLMv2 + $ntlmResponse = $this->createNTLMv2Hash($password, $username, $domain, $challenge, $blob, $timestamp, $client); + } + + $message = $this->createMessage3($domain, $username, $workstation, $lmResponse, $ntlmResponse); + + return $agent->executeCommand(sprintf("%s\r\n", base64_encode($message)), [235]); + } + + /** + * Create our message 1. + * + * @return string + */ + protected function createMessage1() + { + return self::NTLMSIG + .$this->createByte('01') // Message 1 + .$this->createByte('0702'); // Flags + } + + /** + * Create our message 3. + * + * @param string $domain + * @param string $username + * @param string $workstation + * @param string $lmResponse + * @param string $ntlmResponse + * + * @return string + */ + protected function createMessage3($domain, $username, $workstation, $lmResponse, $ntlmResponse) + { + // Create security buffers + $domainSec = $this->createSecurityBuffer($domain, 64); + $domainInfo = $this->readSecurityBuffer(bin2hex($domainSec)); + $userSec = $this->createSecurityBuffer($username, ($domainInfo[0] + $domainInfo[1]) / 2); + $userInfo = $this->readSecurityBuffer(bin2hex($userSec)); + $workSec = $this->createSecurityBuffer($workstation, ($userInfo[0] + $userInfo[1]) / 2); + $workInfo = $this->readSecurityBuffer(bin2hex($workSec)); + $lmSec = $this->createSecurityBuffer($lmResponse, ($workInfo[0] + $workInfo[1]) / 2, true); + $lmInfo = $this->readSecurityBuffer(bin2hex($lmSec)); + $ntlmSec = $this->createSecurityBuffer($ntlmResponse, ($lmInfo[0] + $lmInfo[1]) / 2, true); + + return self::NTLMSIG + .$this->createByte('03') // TYPE 3 message + .$lmSec // LM response header + .$ntlmSec // NTLM response header + .$domainSec // Domain header + .$userSec // User header + .$workSec // Workstation header + .$this->createByte('000000009a', 8) // session key header (empty) + .$this->createByte('01020000') // FLAGS + .$this->convertTo16bit($domain) // domain name + .$this->convertTo16bit($username) // username + .$this->convertTo16bit($workstation) // workstation + .$lmResponse + .$ntlmResponse; + } + + /** + * @param string $timestamp Epoch timestamp in microseconds + * @param string $client Random bytes + * @param string $targetInfo + * + * @return string + */ + protected function createBlob($timestamp, $client, $targetInfo) + { + return $this->createByte('0101') + .$this->createByte('00') + .$timestamp + .$client + .$this->createByte('00') + .$targetInfo + .$this->createByte('00'); + } + + /** + * Get domain and username from our username. + * + * @example DOMAIN\username + * + * @param string $name + * + * @return array + */ + protected function getDomainAndUsername($name) + { + if (false !== strpos($name, '\\')) { + return explode('\\', $name); + } + + if (false !== strpos($name, '@')) { + list($user, $domain) = explode('@', $name); + + return [$domain, $user]; + } + + // no domain passed + return ['', $name]; + } + + /** + * Create LMv1 response. + * + * @param string $password + * @param string $challenge + * + * @return string + */ + protected function createLMPassword($password, $challenge) + { + // FIRST PART + $password = $this->createByte(strtoupper($password), 14, false); + list($key1, $key2) = str_split($password, 7); + + $desKey1 = $this->createDesKey($key1); + $desKey2 = $this->createDesKey($key2); + + $constantDecrypt = $this->createByte($this->desEncrypt(self::DESCONST, $desKey1).$this->desEncrypt(self::DESCONST, $desKey2), 21, false); + + // SECOND PART + list($key1, $key2, $key3) = str_split($constantDecrypt, 7); + + $desKey1 = $this->createDesKey($key1); + $desKey2 = $this->createDesKey($key2); + $desKey3 = $this->createDesKey($key3); + + return $this->desEncrypt($challenge, $desKey1).$this->desEncrypt($challenge, $desKey2).$this->desEncrypt($challenge, $desKey3); + } + + /** + * Create NTLMv1 response. + * + * @param string $password + * @param string $challenge + * + * @return string + */ + protected function createNTLMPassword($password, $challenge) + { + // FIRST PART + $ntlmHash = $this->createByte($this->md4Encrypt($password), 21, false); + list($key1, $key2, $key3) = str_split($ntlmHash, 7); + + $desKey1 = $this->createDesKey($key1); + $desKey2 = $this->createDesKey($key2); + $desKey3 = $this->createDesKey($key3); + + return $this->desEncrypt($challenge, $desKey1).$this->desEncrypt($challenge, $desKey2).$this->desEncrypt($challenge, $desKey3); + } + + /** + * Convert a normal timestamp to a tenth of a microtime epoch time. + * + * @param string $time + * + * @return string + */ + protected function getCorrectTimestamp($time) + { + // Get our timestamp (tricky!) + $time = number_format($time, 0, '.', ''); // save microtime to string + $time = bcadd($time, '11644473600000', 0); // add epoch time + $time = bcmul($time, 10000, 0); // tenths of a microsecond. + + $binary = $this->si2bin($time, 64); // create 64 bit binary string + $timestamp = ''; + for ($i = 0; $i < 8; ++$i) { + $timestamp .= \chr(bindec(substr($binary, -(($i + 1) * 8), 8))); + } + + return $timestamp; + } + + /** + * Create LMv2 response. + * + * @param string $password + * @param string $username + * @param string $domain + * @param string $challenge NTLM Challenge + * @param string $client Random string + * + * @return string + */ + protected function createLMv2Password($password, $username, $domain, $challenge, $client) + { + $lmPass = '00'; // by default 00 + // if $password > 15 than we can't use this method + if (\strlen($password) <= 15) { + $ntlmHash = $this->md4Encrypt($password); + $ntml2Hash = $this->md5Encrypt($ntlmHash, $this->convertTo16bit(strtoupper($username).$domain)); + + $lmPass = bin2hex($this->md5Encrypt($ntml2Hash, $challenge.$client).$client); + } + + return $this->createByte($lmPass, 24); + } + + /** + * Create NTLMv2 response. + * + * @param string $password + * @param string $username + * @param string $domain + * @param string $challenge Hex values + * @param string $targetInfo Hex values + * @param string $timestamp + * @param string $client Random bytes + * + * @return string + * + * @see http://davenport.sourceforge.net/ntlm.html#theNtlmResponse + */ + protected function createNTLMv2Hash($password, $username, $domain, $challenge, $targetInfo, $timestamp, $client) + { + $ntlmHash = $this->md4Encrypt($password); + $ntml2Hash = $this->md5Encrypt($ntlmHash, $this->convertTo16bit(strtoupper($username).$domain)); + + // create blob + $blob = $this->createBlob($timestamp, $client, $targetInfo); + + $ntlmv2Response = $this->md5Encrypt($ntml2Hash, $challenge.$blob); + + return $ntlmv2Response.$blob; + } + + protected function createDesKey($key) + { + $material = [bin2hex($key[0])]; + $len = \strlen($key); + for ($i = 1; $i < $len; ++$i) { + list($high, $low) = str_split(bin2hex($key[$i])); + $v = $this->castToByte(\ord($key[$i - 1]) << (7 + 1 - $i) | $this->uRShift(hexdec(dechex(hexdec($high) & 0xf).dechex(hexdec($low) & 0xf)), $i)); + $material[] = str_pad(substr(dechex($v), -2), 2, '0', STR_PAD_LEFT); // cast to byte + } + $material[] = str_pad(substr(dechex($this->castToByte(\ord($key[6]) << 1)), -2), 2, '0'); + + // odd parity + foreach ($material as $k => $v) { + $b = $this->castToByte(hexdec($v)); + $needsParity = 0 == (($this->uRShift($b, 7) ^ $this->uRShift($b, 6) ^ $this->uRShift($b, 5) + ^ $this->uRShift($b, 4) ^ $this->uRShift($b, 3) ^ $this->uRShift($b, 2) + ^ $this->uRShift($b, 1)) & 0x01); + + list($high, $low) = str_split($v); + if ($needsParity) { + $material[$k] = dechex(hexdec($high) | 0x0).dechex(hexdec($low) | 0x1); + } else { + $material[$k] = dechex(hexdec($high) & 0xf).dechex(hexdec($low) & 0xe); + } + } + + return hex2bin(implode('', $material)); + } + + /** HELPER FUNCTIONS */ + + /** + * Create our security buffer depending on length and offset. + * + * @param string $value Value we want to put in + * @param int $offset start of value + * @param bool $is16 Do we 16bit string or not? + * + * @return string + */ + protected function createSecurityBuffer($value, $offset, $is16 = false) + { + $length = \strlen(bin2hex($value)); + $length = $is16 ? $length / 2 : $length; + $length = $this->createByte(str_pad(dechex($length), 2, '0', STR_PAD_LEFT), 2); + + return $length.$length.$this->createByte(dechex($offset), 4); + } + + /** + * Read our security buffer to fetch length and offset of our value. + * + * @param string $value Securitybuffer in hex + * + * @return array array with length and offset + */ + protected function readSecurityBuffer($value) + { + $length = floor(hexdec(substr($value, 0, 4)) / 256) * 2; + $offset = floor(hexdec(substr($value, 8, 4)) / 256) * 2; + + return [$length, $offset]; + } + + /** + * Cast to byte java equivalent to (byte). + * + * @param int $v + * + * @return int + */ + protected function castToByte($v) + { + return (($v + 128) % 256) - 128; + } + + /** + * Java unsigned right bitwise + * $a >>> $b. + * + * @param int $a + * @param int $b + * + * @return int + */ + protected function uRShift($a, $b) + { + if (0 == $b) { + return $a; + } + + return ($a >> $b) & ~(1 << (8 * PHP_INT_SIZE - 1) >> ($b - 1)); + } + + /** + * Right padding with 0 to certain length. + * + * @param string $input + * @param int $bytes Length of bytes + * @param bool $isHex Did we provided hex value + * + * @return string + */ + protected function createByte($input, $bytes = 4, $isHex = true) + { + if ($isHex) { + $byte = hex2bin(str_pad($input, $bytes * 2, '00')); + } else { + $byte = str_pad($input, $bytes, "\x00"); + } + + return $byte; + } + + /** ENCRYPTION ALGORITHMS */ + + /** + * DES Encryption. + * + * @param string $value An 8-byte string + * @param string $key + * + * @return string + */ + protected function desEncrypt($value, $key) + { + return substr(openssl_encrypt($value, 'DES-ECB', $key, \OPENSSL_RAW_DATA), 0, 8); + } + + /** + * MD5 Encryption. + * + * @param string $key Encryption key + * @param string $msg Message to encrypt + * + * @return string + */ + protected function md5Encrypt($key, $msg) + { + $blocksize = 64; + if (\strlen($key) > $blocksize) { + $key = pack('H*', md5($key)); + } + + $key = str_pad($key, $blocksize, "\0"); + $ipadk = $key ^ str_repeat("\x36", $blocksize); + $opadk = $key ^ str_repeat("\x5c", $blocksize); + + return pack('H*', md5($opadk.pack('H*', md5($ipadk.$msg)))); + } + + /** + * MD4 Encryption. + * + * @param string $input + * + * @return string + * + * @see https://secure.php.net/manual/en/ref.hash.php + */ + protected function md4Encrypt($input) + { + $input = $this->convertTo16bit($input); + + return \function_exists('hash') ? hex2bin(hash('md4', $input)) : mhash(MHASH_MD4, $input); + } + + /** + * Convert UTF-8 to UTF-16. + * + * @param string $input + * + * @return string + */ + protected function convertTo16bit($input) + { + return iconv('UTF-8', 'UTF-16LE', $input); + } + + /** + * @param string $message + */ + protected function debug($message) + { + $message = bin2hex($message); + $messageId = substr($message, 16, 8); + echo substr($message, 0, 16)." NTLMSSP Signature
\n"; + echo $messageId." Type Indicator
\n"; + + if ('02000000' == $messageId) { + $map = [ + 'Challenge', + 'Context', + 'Target Information Security Buffer', + 'Target Name Data', + 'NetBIOS Domain Name', + 'NetBIOS Server Name', + 'DNS Domain Name', + 'DNS Server Name', + 'BLOB', + 'Target Information Terminator', + ]; + + $data = $this->parseMessage2(hex2bin($message)); + + foreach ($map as $key => $value) { + echo bin2hex($data[$key]).' - '.$data[$key].' ||| '.$value."
\n"; + } + } elseif ('03000000' == $messageId) { + $i = 0; + $data[$i++] = substr($message, 24, 16); + list($lmLength, $lmOffset) = $this->readSecurityBuffer($data[$i - 1]); + + $data[$i++] = substr($message, 40, 16); + list($ntmlLength, $ntmlOffset) = $this->readSecurityBuffer($data[$i - 1]); + + $data[$i++] = substr($message, 56, 16); + list($targetLength, $targetOffset) = $this->readSecurityBuffer($data[$i - 1]); + + $data[$i++] = substr($message, 72, 16); + list($userLength, $userOffset) = $this->readSecurityBuffer($data[$i - 1]); + + $data[$i++] = substr($message, 88, 16); + list($workLength, $workOffset) = $this->readSecurityBuffer($data[$i - 1]); + + $data[$i++] = substr($message, 104, 16); + $data[$i++] = substr($message, 120, 8); + $data[$i++] = substr($message, $targetOffset, $targetLength); + $data[$i++] = substr($message, $userOffset, $userLength); + $data[$i++] = substr($message, $workOffset, $workLength); + $data[$i++] = substr($message, $lmOffset, $lmLength); + $data[$i] = substr($message, $ntmlOffset, $ntmlLength); + + $map = [ + 'LM Response Security Buffer', + 'NTLM Response Security Buffer', + 'Target Name Security Buffer', + 'User Name Security Buffer', + 'Workstation Name Security Buffer', + 'Session Key Security Buffer', + 'Flags', + 'Target Name Data', + 'User Name Data', + 'Workstation Name Data', + 'LM Response Data', + 'NTLM Response Data', + ]; + + foreach ($map as $key => $value) { + echo $data[$key].' - '.hex2bin($data[$key]).' ||| '.$value."
\n"; + } + } + + echo '

'; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php index 41d0a50a82b..cd1a2831e82 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php @@ -15,30 +15,30 @@ */ class Swift_Transport_Esmtp_Auth_PlainAuthenticator implements Swift_Transport_Esmtp_Authenticator { - /** - * Get the name of the AUTH mechanism this Authenticator handles. - * - * @return string - */ - public function getAuthKeyword() - { - return 'PLAIN'; - } + /** + * Get the name of the AUTH mechanism this Authenticator handles. + * + * @return string + */ + public function getAuthKeyword() + { + return 'PLAIN'; + } - /** - * {@inheritdoc} - */ - public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password) - { - try { - $message = base64_encode($username.\chr(0).$username.\chr(0).$password); - $agent->executeCommand(sprintf("AUTH PLAIN %s\r\n", $message), [235]); + /** + * {@inheritdoc} + */ + public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password) + { + try { + $message = base64_encode($username.\chr(0).$username.\chr(0).$password); + $agent->executeCommand(sprintf("AUTH PLAIN %s\r\n", $message), [235]); - return true; - } catch (Swift_TransportException $e) { - $agent->executeCommand("RSET\r\n", [250]); + return true; + } catch (Swift_TransportException $e) { + $agent->executeCommand("RSET\r\n", [250]); - throw $e; - } - } + throw $e; + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php index 859f22f3d5e..c541b0ca952 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php @@ -25,40 +25,40 @@ */ class Swift_Transport_Esmtp_Auth_XOAuth2Authenticator implements Swift_Transport_Esmtp_Authenticator { - /** - * Get the name of the AUTH mechanism this Authenticator handles. - * - * @return string - */ - public function getAuthKeyword() - { - return 'XOAUTH2'; - } + /** + * Get the name of the AUTH mechanism this Authenticator handles. + * + * @return string + */ + public function getAuthKeyword() + { + return 'XOAUTH2'; + } - /** - * {@inheritdoc} - */ - public function authenticate(Swift_Transport_SmtpAgent $agent, $email, $token) - { - try { - $param = $this->constructXOAuth2Params($email, $token); - $agent->executeCommand('AUTH XOAUTH2 '.$param."\r\n", [235]); + /** + * {@inheritdoc} + */ + public function authenticate(Swift_Transport_SmtpAgent $agent, $email, $token) + { + try { + $param = $this->constructXOAuth2Params($email, $token); + $agent->executeCommand('AUTH XOAUTH2 '.$param."\r\n", [235]); - return true; - } catch (Swift_TransportException $e) { - $agent->executeCommand("RSET\r\n", [250]); + return true; + } catch (Swift_TransportException $e) { + $agent->executeCommand("RSET\r\n", [250]); - throw $e; - } - } + throw $e; + } + } - /** - * Construct the auth parameter. - * - * @see https://developers.google.com/google-apps/gmail/xoauth2_protocol#the_sasl_xoauth2_mechanism - */ - protected function constructXOAuth2Params($email, $token) - { - return base64_encode("user=$email\1auth=Bearer $token\1\1"); - } + /** + * Construct the auth parameter. + * + * @see https://developers.google.com/google-apps/gmail/xoauth2_protocol#the_sasl_xoauth2_mechanism + */ + protected function constructXOAuth2Params($email, $token) + { + return base64_encode("user=$email\1auth=Bearer $token\1\1"); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php index 53a90a87383..26ac6086fdf 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php @@ -15,254 +15,254 @@ */ class Swift_Transport_Esmtp_AuthHandler implements Swift_Transport_EsmtpHandler { - /** - * Authenticators available to process the request. - * - * @var Swift_Transport_Esmtp_Authenticator[] - */ - private $authenticators = []; + /** + * Authenticators available to process the request. + * + * @var Swift_Transport_Esmtp_Authenticator[] + */ + private $authenticators = []; - /** - * The username for authentication. - * - * @var string - */ - private $username; + /** + * The username for authentication. + * + * @var string + */ + private $username; - /** - * The password for authentication. - * - * @var string - */ - private $password; + /** + * The password for authentication. + * + * @var string + */ + private $password; - /** - * The auth mode for authentication. - * - * @var string - */ - private $auth_mode; + /** + * The auth mode for authentication. + * + * @var string + */ + private $auth_mode; - /** - * The ESMTP AUTH parameters available. - * - * @var string[] - */ - private $esmtpParams = []; + /** + * The ESMTP AUTH parameters available. + * + * @var string[] + */ + private $esmtpParams = []; - /** - * Create a new AuthHandler with $authenticators for support. - * - * @param Swift_Transport_Esmtp_Authenticator[] $authenticators - */ - public function __construct(array $authenticators) - { - $this->setAuthenticators($authenticators); - } + /** + * Create a new AuthHandler with $authenticators for support. + * + * @param Swift_Transport_Esmtp_Authenticator[] $authenticators + */ + public function __construct(array $authenticators) + { + $this->setAuthenticators($authenticators); + } - /** - * Set the Authenticators which can process a login request. - * - * @param Swift_Transport_Esmtp_Authenticator[] $authenticators - */ - public function setAuthenticators(array $authenticators) - { - $this->authenticators = $authenticators; - } + /** + * Set the Authenticators which can process a login request. + * + * @param Swift_Transport_Esmtp_Authenticator[] $authenticators + */ + public function setAuthenticators(array $authenticators) + { + $this->authenticators = $authenticators; + } - /** - * Get the Authenticators which can process a login request. - * - * @return Swift_Transport_Esmtp_Authenticator[] - */ - public function getAuthenticators() - { - return $this->authenticators; - } + /** + * Get the Authenticators which can process a login request. + * + * @return Swift_Transport_Esmtp_Authenticator[] + */ + public function getAuthenticators() + { + return $this->authenticators; + } - /** - * Set the username to authenticate with. - * - * @param string $username - */ - public function setUsername($username) - { - $this->username = $username; - } + /** + * Set the username to authenticate with. + * + * @param string $username + */ + public function setUsername($username) + { + $this->username = $username; + } - /** - * Get the username to authenticate with. - * - * @return string - */ - public function getUsername() - { - return $this->username; - } + /** + * Get the username to authenticate with. + * + * @return string + */ + public function getUsername() + { + return $this->username; + } - /** - * Set the password to authenticate with. - * - * @param string $password - */ - public function setPassword($password) - { - $this->password = $password; - } + /** + * Set the password to authenticate with. + * + * @param string $password + */ + public function setPassword($password) + { + $this->password = $password; + } - /** - * Get the password to authenticate with. - * - * @return string - */ - public function getPassword() - { - return $this->password; - } + /** + * Get the password to authenticate with. + * + * @return string + */ + public function getPassword() + { + return $this->password; + } - /** - * Set the auth mode to use to authenticate. - * - * @param string $mode - */ - public function setAuthMode($mode) - { - $this->auth_mode = $mode; - } + /** + * Set the auth mode to use to authenticate. + * + * @param string $mode + */ + public function setAuthMode($mode) + { + $this->auth_mode = $mode; + } - /** - * Get the auth mode to use to authenticate. - * - * @return string - */ - public function getAuthMode() - { - return $this->auth_mode; - } + /** + * Get the auth mode to use to authenticate. + * + * @return string + */ + public function getAuthMode() + { + return $this->auth_mode; + } - /** - * Get the name of the ESMTP extension this handles. - * - * @return string - */ - public function getHandledKeyword() - { - return 'AUTH'; - } + /** + * Get the name of the ESMTP extension this handles. + * + * @return string + */ + public function getHandledKeyword() + { + return 'AUTH'; + } - /** - * Set the parameters which the EHLO greeting indicated. - * - * @param string[] $parameters - */ - public function setKeywordParams(array $parameters) - { - $this->esmtpParams = $parameters; - } + /** + * Set the parameters which the EHLO greeting indicated. + * + * @param string[] $parameters + */ + public function setKeywordParams(array $parameters) + { + $this->esmtpParams = $parameters; + } - /** - * Runs immediately after a EHLO has been issued. - * - * @param Swift_Transport_SmtpAgent $agent to read/write - */ - public function afterEhlo(Swift_Transport_SmtpAgent $agent) - { - if ($this->username) { - $count = 0; - $errors = []; - foreach ($this->getAuthenticatorsForAgent() as $authenticator) { - if (\in_array(strtolower($authenticator->getAuthKeyword() ?? ''), array_map('strtolower', $this->esmtpParams))) { - ++$count; - try { - if ($authenticator->authenticate($agent, $this->username, $this->password)) { - return; - } - } catch (Swift_TransportException $e) { - // keep the error message, but tries the other authenticators - $errors[] = [$authenticator->getAuthKeyword(), $e->getMessage()]; - } - } - } + /** + * Runs immediately after a EHLO has been issued. + * + * @param Swift_Transport_SmtpAgent $agent to read/write + */ + public function afterEhlo(Swift_Transport_SmtpAgent $agent) + { + if ($this->username) { + $count = 0; + $errors = []; + foreach ($this->getAuthenticatorsForAgent() as $authenticator) { + if (\in_array(strtolower($authenticator->getAuthKeyword() ?? ''), array_map('strtolower', $this->esmtpParams))) { + ++$count; + try { + if ($authenticator->authenticate($agent, $this->username, $this->password)) { + return; + } + } catch (Swift_TransportException $e) { + // keep the error message, but tries the other authenticators + $errors[] = [$authenticator->getAuthKeyword(), $e->getMessage()]; + } + } + } - $message = 'Failed to authenticate on SMTP server with username "'.$this->username.'" using '.$count.' possible authenticators.'; - foreach ($errors as $error) { - $message .= ' Authenticator '.$error[0].' returned '.$error[1].'.'; - } - throw new Swift_TransportException($message); - } - } + $message = 'Failed to authenticate on SMTP server with username "'.$this->username.'" using '.$count.' possible authenticators.'; + foreach ($errors as $error) { + $message .= ' Authenticator '.$error[0].' returned '.$error[1].'.'; + } + throw new Swift_TransportException($message); + } + } - /** - * Not used. - */ - public function getMailParams() - { - return []; - } + /** + * Not used. + */ + public function getMailParams() + { + return []; + } - /** - * Not used. - */ - public function getRcptParams() - { - return []; - } + /** + * Not used. + */ + public function getRcptParams() + { + return []; + } - /** - * Not used. - */ - public function onCommand(Swift_Transport_SmtpAgent $agent, $command, $codes = [], &$failedRecipients = null, &$stop = false) - { - } + /** + * Not used. + */ + public function onCommand(Swift_Transport_SmtpAgent $agent, $command, $codes = [], &$failedRecipients = null, &$stop = false) + { + } - /** - * Returns +1, -1 or 0 according to the rules for usort(). - * - * This method is called to ensure extensions can be execute in an appropriate order. - * - * @param string $esmtpKeyword to compare with - * - * @return int - */ - public function getPriorityOver($esmtpKeyword) - { - return 0; - } + /** + * Returns +1, -1 or 0 according to the rules for usort(). + * + * This method is called to ensure extensions can be execute in an appropriate order. + * + * @param string $esmtpKeyword to compare with + * + * @return int + */ + public function getPriorityOver($esmtpKeyword) + { + return 0; + } - /** - * Returns an array of method names which are exposed to the Esmtp class. - * - * @return string[] - */ - public function exposeMixinMethods() - { - return ['setUsername', 'getUsername', 'setPassword', 'getPassword', 'setAuthMode', 'getAuthMode']; - } + /** + * Returns an array of method names which are exposed to the Esmtp class. + * + * @return string[] + */ + public function exposeMixinMethods() + { + return ['setUsername', 'getUsername', 'setPassword', 'getPassword', 'setAuthMode', 'getAuthMode']; + } - /** - * Not used. - */ - public function resetState() - { - } + /** + * Not used. + */ + public function resetState() + { + } - /** - * Returns the authenticator list for the given agent. - * - * @return array - */ - protected function getAuthenticatorsForAgent() - { - if (!$mode = strtolower($this->auth_mode ?? '')) { - return $this->authenticators; - } + /** + * Returns the authenticator list for the given agent. + * + * @return array + */ + protected function getAuthenticatorsForAgent() + { + if (!$mode = strtolower($this->auth_mode ?? '')) { + return $this->authenticators; + } - foreach ($this->authenticators as $authenticator) { - if (strtolower($authenticator->getAuthKeyword() ?? '') == $mode) { - return [$authenticator]; - } - } + foreach ($this->authenticators as $authenticator) { + if (strtolower($authenticator->getAuthKeyword() ?? '') == $mode) { + return [$authenticator]; + } + } - throw new Swift_TransportException('Auth mode '.$mode.' is invalid'); - } + throw new Swift_TransportException('Auth mode '.$mode.' is invalid'); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Authenticator.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Authenticator.php index f692a6fe40d..40aeb1a65cc 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Authenticator.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Authenticator.php @@ -15,22 +15,22 @@ */ interface Swift_Transport_Esmtp_Authenticator { - /** - * Get the name of the AUTH mechanism this Authenticator handles. - * - * @return string - */ - public function getAuthKeyword(); + /** + * Get the name of the AUTH mechanism this Authenticator handles. + * + * @return string + */ + public function getAuthKeyword(); - /** - * Try to authenticate the user with $username and $password. - * - * @param string $username - * @param string $password - * - * @return bool true if authentication worked (returning false is deprecated, throw a Swift_TransportException instead) - * - * @throws Swift_TransportException Allows the message to bubble up when authentication was not successful - */ - public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password); + /** + * Try to authenticate the user with $username and $password. + * + * @param string $username + * @param string $password + * + * @return bool true if authentication worked (returning false is deprecated, throw a Swift_TransportException instead) + * + * @throws Swift_TransportException Allows the message to bubble up when authentication was not successful + */ + public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/EightBitMimeHandler.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/EightBitMimeHandler.php index 63f70866939..f2ab8d2e3cc 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/EightBitMimeHandler.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/EightBitMimeHandler.php @@ -22,92 +22,92 @@ */ class Swift_Transport_Esmtp_EightBitMimeHandler implements Swift_Transport_EsmtpHandler { - protected $encoding; + protected $encoding; - /** - * @param string $encoding The parameter so send with the MAIL FROM command; - * either "8BITMIME" or "7BIT" - */ - public function __construct(string $encoding = '8BITMIME') - { - $this->encoding = $encoding; - } + /** + * @param string $encoding The parameter so send with the MAIL FROM command; + * either "8BITMIME" or "7BIT" + */ + public function __construct(string $encoding = '8BITMIME') + { + $this->encoding = $encoding; + } - /** - * Get the name of the ESMTP extension this handles. - * - * @return string - */ - public function getHandledKeyword() - { - return '8BITMIME'; - } + /** + * Get the name of the ESMTP extension this handles. + * + * @return string + */ + public function getHandledKeyword() + { + return '8BITMIME'; + } - /** - * Not used. - */ - public function setKeywordParams(array $parameters) - { - } + /** + * Not used. + */ + public function setKeywordParams(array $parameters) + { + } - /** - * Not used. - */ - public function afterEhlo(Swift_Transport_SmtpAgent $agent) - { - } + /** + * Not used. + */ + public function afterEhlo(Swift_Transport_SmtpAgent $agent) + { + } - /** - * Get params which are appended to MAIL FROM:<>. - * - * @return string[] - */ - public function getMailParams() - { - return ['BODY='.$this->encoding]; - } + /** + * Get params which are appended to MAIL FROM:<>. + * + * @return string[] + */ + public function getMailParams() + { + return ['BODY='.$this->encoding]; + } - /** - * Not used. - */ - public function getRcptParams() - { - return []; - } + /** + * Not used. + */ + public function getRcptParams() + { + return []; + } - /** - * Not used. - */ - public function onCommand(Swift_Transport_SmtpAgent $agent, $command, $codes = [], &$failedRecipients = null, &$stop = false) - { - } + /** + * Not used. + */ + public function onCommand(Swift_Transport_SmtpAgent $agent, $command, $codes = [], &$failedRecipients = null, &$stop = false) + { + } - /** - * Returns +1, -1 or 0 according to the rules for usort(). - * - * This method is called to ensure extensions can be execute in an appropriate order. - * - * @param string $esmtpKeyword to compare with - * - * @return int - */ - public function getPriorityOver($esmtpKeyword) - { - return 0; - } + /** + * Returns +1, -1 or 0 according to the rules for usort(). + * + * This method is called to ensure extensions can be execute in an appropriate order. + * + * @param string $esmtpKeyword to compare with + * + * @return int + */ + public function getPriorityOver($esmtpKeyword) + { + return 0; + } - /** - * Not used. - */ - public function exposeMixinMethods() - { - return []; - } + /** + * Not used. + */ + public function exposeMixinMethods() + { + return []; + } - /** - * Not used. - */ - public function resetState() - { - } + /** + * Not used. + */ + public function resetState() + { + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/SmtpUtf8Handler.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/SmtpUtf8Handler.php index 7d0252a01bf..e9b4b69ea6a 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/SmtpUtf8Handler.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/SmtpUtf8Handler.php @@ -23,85 +23,85 @@ */ class Swift_Transport_Esmtp_SmtpUtf8Handler implements Swift_Transport_EsmtpHandler { - public function __construct() - { - } + public function __construct() + { + } - /** - * Get the name of the ESMTP extension this handles. - * - * @return string - */ - public function getHandledKeyword() - { - return 'SMTPUTF8'; - } + /** + * Get the name of the ESMTP extension this handles. + * + * @return string + */ + public function getHandledKeyword() + { + return 'SMTPUTF8'; + } - /** - * Not used. - */ - public function setKeywordParams(array $parameters) - { - } + /** + * Not used. + */ + public function setKeywordParams(array $parameters) + { + } - /** - * Not used. - */ - public function afterEhlo(Swift_Transport_SmtpAgent $agent) - { - } + /** + * Not used. + */ + public function afterEhlo(Swift_Transport_SmtpAgent $agent) + { + } - /** - * Get params which are appended to MAIL FROM:<>. - * - * @return string[] - */ - public function getMailParams() - { - return ['SMTPUTF8']; - } + /** + * Get params which are appended to MAIL FROM:<>. + * + * @return string[] + */ + public function getMailParams() + { + return ['SMTPUTF8']; + } - /** - * Not used. - */ - public function getRcptParams() - { - return []; - } + /** + * Not used. + */ + public function getRcptParams() + { + return []; + } - /** - * Not used. - */ - public function onCommand(Swift_Transport_SmtpAgent $agent, $command, $codes = [], &$failedRecipients = null, &$stop = false) - { - } + /** + * Not used. + */ + public function onCommand(Swift_Transport_SmtpAgent $agent, $command, $codes = [], &$failedRecipients = null, &$stop = false) + { + } - /** - * Returns +1, -1 or 0 according to the rules for usort(). - * - * This method is called to ensure extensions can be execute in an appropriate order. - * - * @param string $esmtpKeyword to compare with - * - * @return int - */ - public function getPriorityOver($esmtpKeyword) - { - return 0; - } + /** + * Returns +1, -1 or 0 according to the rules for usort(). + * + * This method is called to ensure extensions can be execute in an appropriate order. + * + * @param string $esmtpKeyword to compare with + * + * @return int + */ + public function getPriorityOver($esmtpKeyword) + { + return 0; + } - /** - * Not used. - */ - public function exposeMixinMethods() - { - return []; - } + /** + * Not used. + */ + public function exposeMixinMethods() + { + return []; + } - /** - * Not used. - */ - public function resetState() - { - } + /** + * Not used. + */ + public function resetState() + { + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/EsmtpHandler.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/EsmtpHandler.php index b8ea36e2fa8..7dad692f12a 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/EsmtpHandler.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/EsmtpHandler.php @@ -15,72 +15,72 @@ */ interface Swift_Transport_EsmtpHandler { - /** - * Get the name of the ESMTP extension this handles. - * - * @return string - */ - public function getHandledKeyword(); + /** + * Get the name of the ESMTP extension this handles. + * + * @return string + */ + public function getHandledKeyword(); - /** - * Set the parameters which the EHLO greeting indicated. - * - * @param string[] $parameters - */ - public function setKeywordParams(array $parameters); + /** + * Set the parameters which the EHLO greeting indicated. + * + * @param string[] $parameters + */ + public function setKeywordParams(array $parameters); - /** - * Runs immediately after a EHLO has been issued. - * - * @param Swift_Transport_SmtpAgent $agent to read/write - */ - public function afterEhlo(Swift_Transport_SmtpAgent $agent); + /** + * Runs immediately after a EHLO has been issued. + * + * @param Swift_Transport_SmtpAgent $agent to read/write + */ + public function afterEhlo(Swift_Transport_SmtpAgent $agent); - /** - * Get params which are appended to MAIL FROM:<>. - * - * @return string[] - */ - public function getMailParams(); + /** + * Get params which are appended to MAIL FROM:<>. + * + * @return string[] + */ + public function getMailParams(); - /** - * Get params which are appended to RCPT TO:<>. - * - * @return string[] - */ - public function getRcptParams(); + /** + * Get params which are appended to RCPT TO:<>. + * + * @return string[] + */ + public function getRcptParams(); - /** - * Runs when a command is due to be sent. - * - * @param Swift_Transport_SmtpAgent $agent to read/write - * @param string $command to send - * @param int[] $codes expected in response - * @param string[] $failedRecipients to collect failures - * @param bool $stop to be set true by-reference if the command is now sent - */ - public function onCommand(Swift_Transport_SmtpAgent $agent, $command, $codes = [], &$failedRecipients = null, &$stop = false); + /** + * Runs when a command is due to be sent. + * + * @param Swift_Transport_SmtpAgent $agent to read/write + * @param string $command to send + * @param int[] $codes expected in response + * @param string[] $failedRecipients to collect failures + * @param bool $stop to be set true by-reference if the command is now sent + */ + public function onCommand(Swift_Transport_SmtpAgent $agent, $command, $codes = [], &$failedRecipients = null, &$stop = false); - /** - * Returns +1, -1 or 0 according to the rules for usort(). - * - * This method is called to ensure extensions can be execute in an appropriate order. - * - * @param string $esmtpKeyword to compare with - * - * @return int - */ - public function getPriorityOver($esmtpKeyword); + /** + * Returns +1, -1 or 0 according to the rules for usort(). + * + * This method is called to ensure extensions can be execute in an appropriate order. + * + * @param string $esmtpKeyword to compare with + * + * @return int + */ + public function getPriorityOver($esmtpKeyword); - /** - * Returns an array of method names which are exposed to the Esmtp class. - * - * @return string[] - */ - public function exposeMixinMethods(); + /** + * Returns an array of method names which are exposed to the Esmtp class. + * + * @return string[] + */ + public function exposeMixinMethods(); - /** - * Tells this handler to clear any buffers and reset its state. - */ - public function resetState(); + /** + * Tells this handler to clear any buffers and reset its state. + */ + public function resetState(); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php index 36545f51feb..281337ee855 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php @@ -15,432 +15,432 @@ */ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTransport implements Swift_Transport_SmtpAgent { - /** - * ESMTP extension handlers. - * - * @var Swift_Transport_EsmtpHandler[] - */ - private $handlers = []; + /** + * ESMTP extension handlers. + * + * @var Swift_Transport_EsmtpHandler[] + */ + private $handlers = []; - /** - * ESMTP capabilities. - * - * @var string[] - */ - private $capabilities = []; + /** + * ESMTP capabilities. + * + * @var string[] + */ + private $capabilities = []; - /** - * Connection buffer parameters. - * - * @var array - */ - private $params = [ - 'protocol' => 'tcp', - 'host' => 'localhost', - 'port' => 25, - 'timeout' => 30, - 'blocking' => 1, - 'tls' => false, - 'type' => Swift_Transport_IoBuffer::TYPE_SOCKET, - 'stream_context_options' => [], - ]; + /** + * Connection buffer parameters. + * + * @var array + */ + private $params = [ + 'protocol' => 'tcp', + 'host' => 'localhost', + 'port' => 25, + 'timeout' => 30, + 'blocking' => 1, + 'tls' => false, + 'type' => Swift_Transport_IoBuffer::TYPE_SOCKET, + 'stream_context_options' => [], + ]; - /** - * Creates a new EsmtpTransport using the given I/O buffer. - * - * @param Swift_Transport_EsmtpHandler[] $extensionHandlers - * @param string $localDomain - */ - public function __construct(Swift_Transport_IoBuffer $buf, array $extensionHandlers, Swift_Events_EventDispatcher $dispatcher, $localDomain = '127.0.0.1', Swift_AddressEncoder $addressEncoder = null) - { - parent::__construct($buf, $dispatcher, $localDomain, $addressEncoder); - $this->setExtensionHandlers($extensionHandlers); - } + /** + * Creates a new EsmtpTransport using the given I/O buffer. + * + * @param Swift_Transport_EsmtpHandler[] $extensionHandlers + * @param string $localDomain + */ + public function __construct(Swift_Transport_IoBuffer $buf, array $extensionHandlers, Swift_Events_EventDispatcher $dispatcher, $localDomain = '127.0.0.1', Swift_AddressEncoder $addressEncoder = null) + { + parent::__construct($buf, $dispatcher, $localDomain, $addressEncoder); + $this->setExtensionHandlers($extensionHandlers); + } - /** - * Set the host to connect to. - * - * Literal IPv6 addresses should be wrapped in square brackets. - * - * @param string $host - * - * @return $this - */ - public function setHost($host) - { - $this->params['host'] = $host; + /** + * Set the host to connect to. + * + * Literal IPv6 addresses should be wrapped in square brackets. + * + * @param string $host + * + * @return $this + */ + public function setHost($host) + { + $this->params['host'] = $host; - return $this; - } + return $this; + } - /** - * Get the host to connect to. - * - * @return string - */ - public function getHost() - { - return $this->params['host']; - } + /** + * Get the host to connect to. + * + * @return string + */ + public function getHost() + { + return $this->params['host']; + } - /** - * Set the port to connect to. - * - * @param int $port - * - * @return $this - */ - public function setPort($port) - { - $this->params['port'] = (int) $port; + /** + * Set the port to connect to. + * + * @param int $port + * + * @return $this + */ + public function setPort($port) + { + $this->params['port'] = (int) $port; - return $this; - } + return $this; + } - /** - * Get the port to connect to. - * - * @return int - */ - public function getPort() - { - return $this->params['port']; - } + /** + * Get the port to connect to. + * + * @return int + */ + public function getPort() + { + return $this->params['port']; + } - /** - * Set the connection timeout. - * - * @param int $timeout seconds - * - * @return $this - */ - public function setTimeout($timeout) - { - $this->params['timeout'] = (int) $timeout; - $this->buffer->setParam('timeout', (int) $timeout); + /** + * Set the connection timeout. + * + * @param int $timeout seconds + * + * @return $this + */ + public function setTimeout($timeout) + { + $this->params['timeout'] = (int) $timeout; + $this->buffer->setParam('timeout', (int) $timeout); - return $this; - } + return $this; + } - /** - * Get the connection timeout. - * - * @return int - */ - public function getTimeout() - { - return $this->params['timeout']; - } + /** + * Get the connection timeout. + * + * @return int + */ + public function getTimeout() + { + return $this->params['timeout']; + } - /** - * Set the encryption type (tls or ssl). - * - * @param string $encryption - * - * @return $this - */ - public function setEncryption($encryption) - { - $encryption = strtolower($encryption ?? ''); - if ('tls' == $encryption) { - $this->params['protocol'] = 'tcp'; - $this->params['tls'] = true; - } else { - $this->params['protocol'] = $encryption; - $this->params['tls'] = false; - } + /** + * Set the encryption type (tls or ssl). + * + * @param string $encryption + * + * @return $this + */ + public function setEncryption($encryption) + { + $encryption = strtolower($encryption ?? ''); + if ('tls' == $encryption) { + $this->params['protocol'] = 'tcp'; + $this->params['tls'] = true; + } else { + $this->params['protocol'] = $encryption; + $this->params['tls'] = false; + } - return $this; - } + return $this; + } - /** - * Get the encryption type. - * - * @return string - */ - public function getEncryption() - { - return $this->params['tls'] ? 'tls' : $this->params['protocol']; - } + /** + * Get the encryption type. + * + * @return string + */ + public function getEncryption() + { + return $this->params['tls'] ? 'tls' : $this->params['protocol']; + } - /** - * Sets the stream context options. - * - * @param array $options - * - * @return $this - */ - public function setStreamOptions($options) - { - $this->params['stream_context_options'] = $options; + /** + * Sets the stream context options. + * + * @param array $options + * + * @return $this + */ + public function setStreamOptions($options) + { + $this->params['stream_context_options'] = $options; - return $this; - } + return $this; + } - /** - * Returns the stream context options. - * - * @return array - */ - public function getStreamOptions() - { - return $this->params['stream_context_options']; - } + /** + * Returns the stream context options. + * + * @return array + */ + public function getStreamOptions() + { + return $this->params['stream_context_options']; + } - /** - * Sets the source IP. - * - * IPv6 addresses should be wrapped in square brackets. - * - * @param string $source - * - * @return $this - */ - public function setSourceIp($source) - { - $this->params['sourceIp'] = $source; + /** + * Sets the source IP. + * + * IPv6 addresses should be wrapped in square brackets. + * + * @param string $source + * + * @return $this + */ + public function setSourceIp($source) + { + $this->params['sourceIp'] = $source; - return $this; - } + return $this; + } - /** - * Returns the IP used to connect to the destination. - * - * @return string - */ - public function getSourceIp() - { - return $this->params['sourceIp'] ?? null; - } + /** + * Returns the IP used to connect to the destination. + * + * @return string + */ + public function getSourceIp() + { + return $this->params['sourceIp'] ?? null; + } - /** - * Sets whether SMTP pipelining is enabled. - * - * By default, support is auto-detected using the PIPELINING SMTP extension. - * Use this function to override that in the unlikely event of compatibility - * issues. - * - * @param bool $enabled - * - * @return $this - */ - public function setPipelining($enabled) - { - $this->pipelining = $enabled; + /** + * Sets whether SMTP pipelining is enabled. + * + * By default, support is auto-detected using the PIPELINING SMTP extension. + * Use this function to override that in the unlikely event of compatibility + * issues. + * + * @param bool $enabled + * + * @return $this + */ + public function setPipelining($enabled) + { + $this->pipelining = $enabled; - return $this; - } + return $this; + } - /** - * Returns whether SMTP pipelining is enabled. - * - * @return bool|null a boolean if pipelining is explicitly enabled or disabled, - * or null if support is auto-detected - */ - public function getPipelining() - { - return $this->pipelining; - } + /** + * Returns whether SMTP pipelining is enabled. + * + * @return bool|null a boolean if pipelining is explicitly enabled or disabled, + * or null if support is auto-detected + */ + public function getPipelining() + { + return $this->pipelining; + } - /** - * Set ESMTP extension handlers. - * - * @param Swift_Transport_EsmtpHandler[] $handlers - * - * @return $this - */ - public function setExtensionHandlers(array $handlers) - { - $assoc = []; - foreach ($handlers as $handler) { - $assoc[$handler->getHandledKeyword()] = $handler; - } - uasort($assoc, function ($a, $b) { - return $a->getPriorityOver($b->getHandledKeyword()); - }); - $this->handlers = $assoc; - $this->setHandlerParams(); + /** + * Set ESMTP extension handlers. + * + * @param Swift_Transport_EsmtpHandler[] $handlers + * + * @return $this + */ + public function setExtensionHandlers(array $handlers) + { + $assoc = []; + foreach ($handlers as $handler) { + $assoc[$handler->getHandledKeyword()] = $handler; + } + uasort($assoc, function ($a, $b) { + return $a->getPriorityOver($b->getHandledKeyword()); + }); + $this->handlers = $assoc; + $this->setHandlerParams(); - return $this; - } + return $this; + } - /** - * Get ESMTP extension handlers. - * - * @return Swift_Transport_EsmtpHandler[] - */ - public function getExtensionHandlers() - { - return array_values($this->handlers); - } + /** + * Get ESMTP extension handlers. + * + * @return Swift_Transport_EsmtpHandler[] + */ + public function getExtensionHandlers() + { + return array_values($this->handlers); + } - /** - * Run a command against the buffer, expecting the given response codes. - * - * If no response codes are given, the response will not be validated. - * If codes are given, an exception will be thrown on an invalid response. - * - * @param string $command - * @param int[] $codes - * @param string[] $failures An array of failures by-reference - * @param bool $pipeline Do not wait for response - * @param string $address the address, if command is RCPT TO - * - * @return string|null The server response, or null if pipelining is enabled - */ - public function executeCommand($command, $codes = [], &$failures = null, $pipeline = false, $address = null) - { - $failures = (array) $failures; - $stopSignal = false; - $response = null; - foreach ($this->getActiveHandlers() as $handler) { - $response = $handler->onCommand( - $this, $command, $codes, $failures, $stopSignal - ); - if ($stopSignal) { - return $response; - } - } + /** + * Run a command against the buffer, expecting the given response codes. + * + * If no response codes are given, the response will not be validated. + * If codes are given, an exception will be thrown on an invalid response. + * + * @param string $command + * @param int[] $codes + * @param string[] $failures An array of failures by-reference + * @param bool $pipeline Do not wait for response + * @param string $address the address, if command is RCPT TO + * + * @return string|null The server response, or null if pipelining is enabled + */ + public function executeCommand($command, $codes = [], &$failures = null, $pipeline = false, $address = null) + { + $failures = (array) $failures; + $stopSignal = false; + $response = null; + foreach ($this->getActiveHandlers() as $handler) { + $response = $handler->onCommand( + $this, $command, $codes, $failures, $stopSignal + ); + if ($stopSignal) { + return $response; + } + } - return parent::executeCommand($command, $codes, $failures, $pipeline, $address); - } + return parent::executeCommand($command, $codes, $failures, $pipeline, $address); + } - /** Mixin handling method for ESMTP handlers */ - public function __call($method, $args) - { - foreach ($this->handlers as $handler) { - if (\in_array(strtolower($method), - array_map('strtolower', (array) $handler->exposeMixinMethods()) - )) { - $return = \call_user_func_array([$handler, $method], $args); - // Allow fluid method calls - if (null === $return && 'set' == substr($method, 0, 3)) { - return $this; - } else { - return $return; - } - } - } - trigger_error('Call to undefined method '.$method, E_USER_ERROR); - } + /** Mixin handling method for ESMTP handlers */ + public function __call($method, $args) + { + foreach ($this->handlers as $handler) { + if (\in_array(strtolower($method), + array_map('strtolower', (array) $handler->exposeMixinMethods()) + )) { + $return = \call_user_func_array([$handler, $method], $args); + // Allow fluid method calls + if (null === $return && 'set' == substr($method, 0, 3)) { + return $this; + } else { + return $return; + } + } + } + trigger_error('Call to undefined method '.$method, E_USER_ERROR); + } - /** Get the params to initialize the buffer */ - protected function getBufferParams() - { - return $this->params; - } + /** Get the params to initialize the buffer */ + protected function getBufferParams() + { + return $this->params; + } - /** Overridden to perform EHLO instead */ - protected function doHeloCommand() - { - try { - $response = $this->executeCommand( - sprintf("EHLO %s\r\n", $this->domain), [250] - ); - } catch (Swift_TransportException $e) { - return parent::doHeloCommand(); - } + /** Overridden to perform EHLO instead */ + protected function doHeloCommand() + { + try { + $response = $this->executeCommand( + sprintf("EHLO %s\r\n", $this->domain), [250] + ); + } catch (Swift_TransportException $e) { + return parent::doHeloCommand(); + } - if ($this->params['tls']) { - try { - $this->executeCommand("STARTTLS\r\n", [220]); + if ($this->params['tls']) { + try { + $this->executeCommand("STARTTLS\r\n", [220]); - if (!$this->buffer->startTLS()) { - throw new Swift_TransportException('Unable to connect with TLS encryption'); - } + if (!$this->buffer->startTLS()) { + throw new Swift_TransportException('Unable to connect with TLS encryption'); + } - try { - $response = $this->executeCommand( - sprintf("EHLO %s\r\n", $this->domain), [250] - ); - } catch (Swift_TransportException $e) { - return parent::doHeloCommand(); - } - } catch (Swift_TransportException $e) { - $this->throwException($e); - } - } + try { + $response = $this->executeCommand( + sprintf("EHLO %s\r\n", $this->domain), [250] + ); + } catch (Swift_TransportException $e) { + return parent::doHeloCommand(); + } + } catch (Swift_TransportException $e) { + $this->throwException($e); + } + } - $this->capabilities = $this->getCapabilities($response); - if (!isset($this->pipelining)) { - $this->pipelining = isset($this->capabilities['PIPELINING']); - } + $this->capabilities = $this->getCapabilities($response); + if (!isset($this->pipelining)) { + $this->pipelining = isset($this->capabilities['PIPELINING']); + } - $this->setHandlerParams(); - foreach ($this->getActiveHandlers() as $handler) { - $handler->afterEhlo($this); - } - } + $this->setHandlerParams(); + foreach ($this->getActiveHandlers() as $handler) { + $handler->afterEhlo($this); + } + } - /** Overridden to add Extension support */ - protected function doMailFromCommand($address) - { - $address = $this->addressEncoder->encodeString($address); - $handlers = $this->getActiveHandlers(); - $params = []; - foreach ($handlers as $handler) { - $params = array_merge($params, (array) $handler->getMailParams()); - } - $paramStr = !empty($params) ? ' '.implode(' ', $params) : ''; - $this->executeCommand( - sprintf("MAIL FROM:<%s>%s\r\n", $address, $paramStr), [250], $failures, true - ); - } + /** Overridden to add Extension support */ + protected function doMailFromCommand($address) + { + $address = $this->addressEncoder->encodeString($address); + $handlers = $this->getActiveHandlers(); + $params = []; + foreach ($handlers as $handler) { + $params = array_merge($params, (array) $handler->getMailParams()); + } + $paramStr = !empty($params) ? ' '.implode(' ', $params) : ''; + $this->executeCommand( + sprintf("MAIL FROM:<%s>%s\r\n", $address, $paramStr), [250], $failures, true + ); + } - /** Overridden to add Extension support */ - protected function doRcptToCommand($address) - { - $address = $this->addressEncoder->encodeString($address); - $handlers = $this->getActiveHandlers(); - $params = []; - foreach ($handlers as $handler) { - $params = array_merge($params, (array) $handler->getRcptParams()); - } - $paramStr = !empty($params) ? ' '.implode(' ', $params) : ''; - $this->executeCommand( - sprintf("RCPT TO:<%s>%s\r\n", $address, $paramStr), [250, 251, 252], $failures, true, $address - ); - } + /** Overridden to add Extension support */ + protected function doRcptToCommand($address) + { + $address = $this->addressEncoder->encodeString($address); + $handlers = $this->getActiveHandlers(); + $params = []; + foreach ($handlers as $handler) { + $params = array_merge($params, (array) $handler->getRcptParams()); + } + $paramStr = !empty($params) ? ' '.implode(' ', $params) : ''; + $this->executeCommand( + sprintf("RCPT TO:<%s>%s\r\n", $address, $paramStr), [250, 251, 252], $failures, true, $address + ); + } - /** Determine ESMTP capabilities by function group */ - private function getCapabilities($ehloResponse) - { - $capabilities = []; - $ehloResponse = trim($ehloResponse ?? ''); - $lines = explode("\r\n", $ehloResponse); - array_shift($lines); - foreach ($lines as $line) { - if (preg_match('/^[0-9]{3}[ -]([A-Z0-9-]+)((?:[ =].*)?)$/Di', $line, $matches)) { - $keyword = strtoupper($matches[1]); - $paramStr = strtoupper(ltrim($matches[2], ' =')); - $params = !empty($paramStr) ? explode(' ', $paramStr) : []; - $capabilities[$keyword] = $params; - } - } + /** Determine ESMTP capabilities by function group */ + private function getCapabilities($ehloResponse) + { + $capabilities = []; + $ehloResponse = trim($ehloResponse ?? ''); + $lines = explode("\r\n", $ehloResponse); + array_shift($lines); + foreach ($lines as $line) { + if (preg_match('/^[0-9]{3}[ -]([A-Z0-9-]+)((?:[ =].*)?)$/Di', $line, $matches)) { + $keyword = strtoupper($matches[1]); + $paramStr = strtoupper(ltrim($matches[2], ' =')); + $params = !empty($paramStr) ? explode(' ', $paramStr) : []; + $capabilities[$keyword] = $params; + } + } - return $capabilities; - } + return $capabilities; + } - /** Set parameters which are used by each extension handler */ - private function setHandlerParams() - { - foreach ($this->handlers as $keyword => $handler) { - if (\array_key_exists($keyword, $this->capabilities)) { - $handler->setKeywordParams($this->capabilities[$keyword]); - } - } - } + /** Set parameters which are used by each extension handler */ + private function setHandlerParams() + { + foreach ($this->handlers as $keyword => $handler) { + if (\array_key_exists($keyword, $this->capabilities)) { + $handler->setKeywordParams($this->capabilities[$keyword]); + } + } + } - /** Get ESMTP handlers which are currently ok to use */ - private function getActiveHandlers() - { - $handlers = []; - foreach ($this->handlers as $keyword => $handler) { - if (\array_key_exists($keyword, $this->capabilities)) { - $handlers[] = $handler; - } - } + /** Get ESMTP handlers which are currently ok to use */ + private function getActiveHandlers() + { + $handlers = []; + foreach ($this->handlers as $keyword => $handler) { + if (\array_key_exists($keyword, $this->capabilities)) { + $handlers[] = $handler; + } + } - return $handlers; - } + return $handlers; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/FailoverTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/FailoverTransport.php index 1a4b4754f07..1e007b00201 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/FailoverTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/FailoverTransport.php @@ -15,89 +15,89 @@ */ class Swift_Transport_FailoverTransport extends Swift_Transport_LoadBalancedTransport { - /** - * Registered transport currently used. - * - * @var Swift_Transport - */ - private $currentTransport; + /** + * Registered transport currently used. + * + * @var Swift_Transport + */ + private $currentTransport; - // needed as __construct is called from elsewhere explicitly - public function __construct() - { - parent::__construct(); - } + // needed as __construct is called from elsewhere explicitly + public function __construct() + { + parent::__construct(); + } - /** - * {@inheritdoc} - */ - public function ping() - { - $maxTransports = \count($this->transports); - for ($i = 0; $i < $maxTransports - && $transport = $this->getNextTransport(); ++$i) { - if ($transport->ping()) { - return true; - } else { - $this->killCurrentTransport(); - } - } + /** + * {@inheritdoc} + */ + public function ping() + { + $maxTransports = \count($this->transports); + for ($i = 0; $i < $maxTransports + && $transport = $this->getNextTransport(); ++$i) { + if ($transport->ping()) { + return true; + } else { + $this->killCurrentTransport(); + } + } - return \count($this->transports) > 0; - } + return \count($this->transports) > 0; + } - /** - * Send the given Message. - * - * Recipient/sender data will be retrieved from the Message API. - * The return value is the number of recipients who were accepted for delivery. - * - * @param string[] $failedRecipients An array of failures by-reference - * - * @return int - */ - public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) - { - $maxTransports = \count($this->transports); - $sent = 0; - $this->lastUsedTransport = null; + /** + * Send the given Message. + * + * Recipient/sender data will be retrieved from the Message API. + * The return value is the number of recipients who were accepted for delivery. + * + * @param string[] $failedRecipients An array of failures by-reference + * + * @return int + */ + public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) + { + $maxTransports = \count($this->transports); + $sent = 0; + $this->lastUsedTransport = null; - for ($i = 0; $i < $maxTransports - && $transport = $this->getNextTransport(); ++$i) { - try { - if (!$transport->isStarted()) { - $transport->start(); - } + for ($i = 0; $i < $maxTransports + && $transport = $this->getNextTransport(); ++$i) { + try { + if (!$transport->isStarted()) { + $transport->start(); + } - if ($sent = $transport->send($message, $failedRecipients)) { - $this->lastUsedTransport = $transport; + if ($sent = $transport->send($message, $failedRecipients)) { + $this->lastUsedTransport = $transport; - return $sent; - } - } catch (Swift_TransportException $e) { - $this->killCurrentTransport(); - } - } + return $sent; + } + } catch (Swift_TransportException $e) { + $this->killCurrentTransport(); + } + } - if (0 == \count($this->transports)) { - throw new Swift_TransportException('All Transports in FailoverTransport failed, or no Transports available'); - } + if (0 == \count($this->transports)) { + throw new Swift_TransportException('All Transports in FailoverTransport failed, or no Transports available'); + } - return $sent; - } + return $sent; + } - protected function getNextTransport() - { - if (!isset($this->currentTransport)) { - $this->currentTransport = parent::getNextTransport(); - } + protected function getNextTransport() + { + if (!isset($this->currentTransport)) { + $this->currentTransport = parent::getNextTransport(); + } - return $this->currentTransport; - } + return $this->currentTransport; + } - protected function killCurrentTransport() - { - $this->currentTransport = null; - parent::killCurrentTransport(); - } + protected function killCurrentTransport() + { + $this->currentTransport = null; + parent::killCurrentTransport(); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/IoBuffer.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/IoBuffer.php index 50f1e5e403c..799ad8ae085 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/IoBuffer.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/IoBuffer.php @@ -15,51 +15,51 @@ */ interface Swift_Transport_IoBuffer extends Swift_InputByteStream, Swift_OutputByteStream { - /** A socket buffer over TCP */ - const TYPE_SOCKET = 0x0001; + /** A socket buffer over TCP */ + const TYPE_SOCKET = 0x0001; - /** A process buffer with I/O support */ - const TYPE_PROCESS = 0x0010; + /** A process buffer with I/O support */ + const TYPE_PROCESS = 0x0010; - /** - * Perform any initialization needed, using the given $params. - * - * Parameters will vary depending upon the type of IoBuffer used. - */ - public function initialize(array $params); + /** + * Perform any initialization needed, using the given $params. + * + * Parameters will vary depending upon the type of IoBuffer used. + */ + public function initialize(array $params); - /** - * Set an individual param on the buffer (e.g. switching to SSL). - * - * @param string $param - * @param mixed $value - */ - public function setParam($param, $value); + /** + * Set an individual param on the buffer (e.g. switching to SSL). + * + * @param string $param + * @param mixed $value + */ + public function setParam($param, $value); - /** - * Perform any shutdown logic needed. - */ - public function terminate(); + /** + * Perform any shutdown logic needed. + */ + public function terminate(); - /** - * Set an array of string replacements which should be made on data written - * to the buffer. - * - * This could replace LF with CRLF for example. - * - * @param string[] $replacements - */ - public function setWriteTranslations(array $replacements); + /** + * Set an array of string replacements which should be made on data written + * to the buffer. + * + * This could replace LF with CRLF for example. + * + * @param string[] $replacements + */ + public function setWriteTranslations(array $replacements); - /** - * Get a line of output (including any CRLF). - * - * The $sequence number comes from any writes and may or may not be used - * depending upon the implementation. - * - * @param int $sequence of last write to scan from - * - * @return string - */ - public function readLine($sequence); + /** + * Get a line of output (including any CRLF). + * + * The $sequence number comes from any writes and may or may not be used + * depending upon the implementation. + * + * @param int $sequence of last write to scan from + * + * @return string + */ + public function readLine($sequence); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/LoadBalancedTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/LoadBalancedTransport.php index 0b5ba9d304e..e4262069ffb 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/LoadBalancedTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/LoadBalancedTransport.php @@ -15,178 +15,178 @@ */ class Swift_Transport_LoadBalancedTransport implements Swift_Transport { - /** - * Transports which are deemed useless. - * - * @var Swift_Transport[] - */ - private $deadTransports = []; + /** + * Transports which are deemed useless. + * + * @var Swift_Transport[] + */ + private $deadTransports = []; - /** - * The Transports which are used in rotation. - * - * @var Swift_Transport[] - */ - protected $transports = []; + /** + * The Transports which are used in rotation. + * + * @var Swift_Transport[] + */ + protected $transports = []; - /** - * The Transport used in the last successful send operation. - * - * @var Swift_Transport - */ - protected $lastUsedTransport = null; + /** + * The Transport used in the last successful send operation. + * + * @var Swift_Transport + */ + protected $lastUsedTransport = null; - // needed as __construct is called from elsewhere explicitly - public function __construct() - { - } + // needed as __construct is called from elsewhere explicitly + public function __construct() + { + } - /** - * Set $transports to delegate to. - * - * @param Swift_Transport[] $transports - */ - public function setTransports(array $transports) - { - $this->transports = $transports; - $this->deadTransports = []; - } + /** + * Set $transports to delegate to. + * + * @param Swift_Transport[] $transports + */ + public function setTransports(array $transports) + { + $this->transports = $transports; + $this->deadTransports = []; + } - /** - * Get $transports to delegate to. - * - * @return Swift_Transport[] - */ - public function getTransports() - { - return array_merge($this->transports, $this->deadTransports); - } + /** + * Get $transports to delegate to. + * + * @return Swift_Transport[] + */ + public function getTransports() + { + return array_merge($this->transports, $this->deadTransports); + } - /** - * Get the Transport used in the last successful send operation. - * - * @return Swift_Transport - */ - public function getLastUsedTransport() - { - return $this->lastUsedTransport; - } + /** + * Get the Transport used in the last successful send operation. + * + * @return Swift_Transport + */ + public function getLastUsedTransport() + { + return $this->lastUsedTransport; + } - /** - * Test if this Transport mechanism has started. - * - * @return bool - */ - public function isStarted() - { - return \count($this->transports) > 0; - } + /** + * Test if this Transport mechanism has started. + * + * @return bool + */ + public function isStarted() + { + return \count($this->transports) > 0; + } - /** - * Start this Transport mechanism. - */ - public function start() - { - $this->transports = array_merge($this->transports, $this->deadTransports); - } + /** + * Start this Transport mechanism. + */ + public function start() + { + $this->transports = array_merge($this->transports, $this->deadTransports); + } - /** - * Stop this Transport mechanism. - */ - public function stop() - { - foreach ($this->transports as $transport) { - $transport->stop(); - } - } + /** + * Stop this Transport mechanism. + */ + public function stop() + { + foreach ($this->transports as $transport) { + $transport->stop(); + } + } - /** - * {@inheritdoc} - */ - public function ping() - { - foreach ($this->transports as $transport) { - if (!$transport->ping()) { - $this->killCurrentTransport(); - } - } + /** + * {@inheritdoc} + */ + public function ping() + { + foreach ($this->transports as $transport) { + if (!$transport->ping()) { + $this->killCurrentTransport(); + } + } - return \count($this->transports) > 0; - } + return \count($this->transports) > 0; + } - /** - * Send the given Message. - * - * Recipient/sender data will be retrieved from the Message API. - * The return value is the number of recipients who were accepted for delivery. - * - * @param string[] $failedRecipients An array of failures by-reference - * - * @return int - */ - public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) - { - $maxTransports = \count($this->transports); - $sent = 0; - $this->lastUsedTransport = null; + /** + * Send the given Message. + * + * Recipient/sender data will be retrieved from the Message API. + * The return value is the number of recipients who were accepted for delivery. + * + * @param string[] $failedRecipients An array of failures by-reference + * + * @return int + */ + public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) + { + $maxTransports = \count($this->transports); + $sent = 0; + $this->lastUsedTransport = null; - for ($i = 0; $i < $maxTransports - && $transport = $this->getNextTransport(); ++$i) { - try { - if (!$transport->isStarted()) { - $transport->start(); - } - if ($sent = $transport->send($message, $failedRecipients)) { - $this->lastUsedTransport = $transport; - break; - } - } catch (Swift_TransportException $e) { - $this->killCurrentTransport(); - } - } + for ($i = 0; $i < $maxTransports + && $transport = $this->getNextTransport(); ++$i) { + try { + if (!$transport->isStarted()) { + $transport->start(); + } + if ($sent = $transport->send($message, $failedRecipients)) { + $this->lastUsedTransport = $transport; + break; + } + } catch (Swift_TransportException $e) { + $this->killCurrentTransport(); + } + } - if (0 == \count($this->transports)) { - throw new Swift_TransportException('All Transports in LoadBalancedTransport failed, or no Transports available'); - } + if (0 == \count($this->transports)) { + throw new Swift_TransportException('All Transports in LoadBalancedTransport failed, or no Transports available'); + } - return $sent; - } + return $sent; + } - /** - * Register a plugin. - */ - public function registerPlugin(Swift_Events_EventListener $plugin) - { - foreach ($this->transports as $transport) { - $transport->registerPlugin($plugin); - } - } + /** + * Register a plugin. + */ + public function registerPlugin(Swift_Events_EventListener $plugin) + { + foreach ($this->transports as $transport) { + $transport->registerPlugin($plugin); + } + } - /** - * Rotates the transport list around and returns the first instance. - * - * @return Swift_Transport - */ - protected function getNextTransport() - { - if ($next = array_shift($this->transports)) { - $this->transports[] = $next; - } + /** + * Rotates the transport list around and returns the first instance. + * + * @return Swift_Transport + */ + protected function getNextTransport() + { + if ($next = array_shift($this->transports)) { + $this->transports[] = $next; + } - return $next; - } + return $next; + } - /** - * Tag the currently used (top of stack) transport as dead/useless. - */ - protected function killCurrentTransport() - { - if ($transport = array_pop($this->transports)) { - try { - $transport->stop(); - } catch (Exception $e) { - } - $this->deadTransports[] = $transport; - } - } + /** + * Tag the currently used (top of stack) transport as dead/useless. + */ + protected function killCurrentTransport() + { + if ($transport = array_pop($this->transports)) { + try { + $transport->stop(); + } catch (Exception $e) { + } + $this->deadTransports[] = $transport; + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/NullTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/NullTransport.php index 7d910db5a58..ec82fced23b 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/NullTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/NullTransport.php @@ -15,84 +15,84 @@ */ class Swift_Transport_NullTransport implements Swift_Transport { - /** The event dispatcher from the plugin API */ - private $eventDispatcher; + /** The event dispatcher from the plugin API */ + private $eventDispatcher; - /** - * Constructor. - */ - public function __construct(Swift_Events_EventDispatcher $eventDispatcher) - { - $this->eventDispatcher = $eventDispatcher; - } + /** + * Constructor. + */ + public function __construct(Swift_Events_EventDispatcher $eventDispatcher) + { + $this->eventDispatcher = $eventDispatcher; + } - /** - * Tests if this Transport mechanism has started. - * - * @return bool - */ - public function isStarted() - { - return true; - } + /** + * Tests if this Transport mechanism has started. + * + * @return bool + */ + public function isStarted() + { + return true; + } - /** - * Starts this Transport mechanism. - */ - public function start() - { - } + /** + * Starts this Transport mechanism. + */ + public function start() + { + } - /** - * Stops this Transport mechanism. - */ - public function stop() - { - } + /** + * Stops this Transport mechanism. + */ + public function stop() + { + } - /** - * {@inheritdoc} - */ - public function ping() - { - return true; - } + /** + * {@inheritdoc} + */ + public function ping() + { + return true; + } - /** - * Sends the given message. - * - * @param string[] $failedRecipients An array of failures by-reference - * - * @return int The number of sent emails - */ - public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) - { - if ($evt = $this->eventDispatcher->createSendEvent($this, $message)) { - $this->eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); - if ($evt->bubbleCancelled()) { - return 0; - } - } + /** + * Sends the given message. + * + * @param string[] $failedRecipients An array of failures by-reference + * + * @return int The number of sent emails + */ + public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) + { + if ($evt = $this->eventDispatcher->createSendEvent($this, $message)) { + $this->eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); + if ($evt->bubbleCancelled()) { + return 0; + } + } - if ($evt) { - $evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS); - $this->eventDispatcher->dispatchEvent($evt, 'sendPerformed'); - } + if ($evt) { + $evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS); + $this->eventDispatcher->dispatchEvent($evt, 'sendPerformed'); + } - $count = ( - \count((array) $message->getTo()) - + \count((array) $message->getCc()) - + \count((array) $message->getBcc()) - ); + $count = ( + \count((array) $message->getTo()) + + \count((array) $message->getCc()) + + \count((array) $message->getBcc()) + ); - return $count; - } + return $count; + } - /** - * Register a plugin. - */ - public function registerPlugin(Swift_Events_EventListener $plugin) - { - $this->eventDispatcher->bindEventListener($plugin); - } + /** + * Register a plugin. + */ + public function registerPlugin(Swift_Events_EventListener $plugin) + { + $this->eventDispatcher->bindEventListener($plugin); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php index 65a434d1173..e1723b24f10 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php @@ -19,140 +19,139 @@ */ class Swift_Transport_SendmailTransport extends Swift_Transport_AbstractSmtpTransport { - /** - * Connection buffer parameters. - * - * @var array - */ - private $params = [ - 'timeout' => 30, - 'blocking' => 1, - 'command' => '/usr/sbin/sendmail -bs', - 'type' => Swift_Transport_IoBuffer::TYPE_PROCESS, - ]; + /** + * Connection buffer parameters. + * + * @var array + */ + private $params = [ + 'timeout' => 30, + 'blocking' => 1, + 'command' => '/usr/sbin/sendmail -bs', + 'type' => Swift_Transport_IoBuffer::TYPE_PROCESS, + ]; - /** - * Create a new SendmailTransport with $buf for I/O. - * - * @param string $localDomain - */ - public function __construct(Swift_Transport_IoBuffer $buf, Swift_Events_EventDispatcher $dispatcher, $localDomain = '127.0.0.1', Swift_AddressEncoder $addressEncoder = null) - { - parent::__construct($buf, $dispatcher, $localDomain, $addressEncoder); - } + /** + * Create a new SendmailTransport with $buf for I/O. + * + * @param string $localDomain + */ + public function __construct(Swift_Transport_IoBuffer $buf, Swift_Events_EventDispatcher $dispatcher, $localDomain = '127.0.0.1', Swift_AddressEncoder $addressEncoder = null) + { + parent::__construct($buf, $dispatcher, $localDomain, $addressEncoder); + } - /** - * Start the standalone SMTP session if running in -bs mode. - */ - public function start() - { - if (false !== strpos($this->getCommand(), ' -bs')) { - parent::start(); - } - } + /** + * Start the standalone SMTP session if running in -bs mode. + */ + public function start() + { + if (false !== strpos($this->getCommand(), ' -bs')) { + parent::start(); + } + } - /** - * Set the command to invoke. - * - * If using -t mode you are strongly advised to include -oi or -i in the flags. - * For example: /usr/sbin/sendmail -oi -t - * Swift will append a -f flag if one is not present. - * - * The recommended mode is "-bs" since it is interactive and failure notifications - * are hence possible. - * - * @param string $command - * - * @return $this - */ - public function setCommand($command) - { - $this->params['command'] = $command; + /** + * Set the command to invoke. + * + * If using -t mode you are strongly advised to include -oi or -i in the flags. + * For example: /usr/sbin/sendmail -oi -t + * Swift will append a -f flag if one is not present. + * + * The recommended mode is "-bs" since it is interactive and failure notifications + * are hence possible. + * + * @param string $command + * + * @return $this + */ + public function setCommand($command) + { + $this->params['command'] = $command; - return $this; - } + return $this; + } - /** - * Get the sendmail command which will be invoked. - * - * @return string - */ - public function getCommand() - { - return $this->params['command']; - } + /** + * Get the sendmail command which will be invoked. + * + * @return string + */ + public function getCommand() + { + return $this->params['command']; + } - /** - * Send the given Message. - * - * Recipient/sender data will be retrieved from the Message API. - * - * The return value is the number of recipients who were accepted for delivery. - * NOTE: If using 'sendmail -t' you will not be aware of any failures until - * they bounce (i.e. send() will always return 100% success). - * - * @param string[] $failedRecipients An array of failures by-reference - * - * @return int - */ - public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) - { - $failedRecipients = (array) $failedRecipients; - $command = $this->getCommand(); - $buffer = $this->getBuffer(); - $count = 0; + /** + * Send the given Message. + * + * Recipient/sender data will be retrieved from the Message API. + * + * The return value is the number of recipients who were accepted for delivery. + * NOTE: If using 'sendmail -t' you will not be aware of any failures until + * they bounce (i.e. send() will always return 100% success). + * + * @param string[] $failedRecipients An array of failures by-reference + * + * @return int + */ + public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) + { + $failedRecipients = (array) $failedRecipients; + $command = $this->getCommand(); + $buffer = $this->getBuffer(); + $count = 0; - if (false !== strpos($command, ' -t')) { - if ($evt = $this->eventDispatcher->createSendEvent($this, $message)) { - $this->eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); - if ($evt->bubbleCancelled()) { - return 0; - } - } + if (false !== strpos($command, ' -t')) { + if ($evt = $this->eventDispatcher->createSendEvent($this, $message)) { + $this->eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); + if ($evt->bubbleCancelled()) { + return 0; + } + } - if (false === strpos($command, ' -f')) { - $command .= ' -f'.escapeshellarg($this->getReversePath($message) ?? ''); - } + if (false === strpos($command, ' -f')) { + $command .= ' -f'.escapeshellarg($this->getReversePath($message) ?? ''); + } - $buffer->initialize(array_merge($this->params, ['command' => $command])); + $buffer->initialize(array_merge($this->params, ['command' => $command])); - if (false === strpos($command, ' -i') && false === strpos($command, ' -oi')) { - $buffer->setWriteTranslations(["\r\n" => "\n", "\n." => "\n.."]); - } else { - $buffer->setWriteTranslations(["\r\n" => "\n"]); - } + if (false === strpos($command, ' -i') && false === strpos($command, ' -oi')) { + $buffer->setWriteTranslations(["\r\n" => "\n", "\n." => "\n.."]); + } else { + $buffer->setWriteTranslations(["\r\n" => "\n"]); + } - $count = \count((array) $message->getTo()) - + \count((array) $message->getCc()) - + \count((array) $message->getBcc()) - ; - $message->toByteStream($buffer); - $buffer->flushBuffers(); - $buffer->setWriteTranslations([]); - $buffer->terminate(); + $count = \count((array) $message->getTo()) + + \count((array) $message->getCc()) + + \count((array) $message->getBcc()); + $message->toByteStream($buffer); + $buffer->flushBuffers(); + $buffer->setWriteTranslations([]); + $buffer->terminate(); - if ($evt) { - $evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS); - $evt->setFailedRecipients($failedRecipients); - $this->eventDispatcher->dispatchEvent($evt, 'sendPerformed'); - } + if ($evt) { + $evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS); + $evt->setFailedRecipients($failedRecipients); + $this->eventDispatcher->dispatchEvent($evt, 'sendPerformed'); + } - $message->generateId(); - } elseif (false !== strpos($command, ' -bs')) { - $count = parent::send($message, $failedRecipients); - } else { - $this->throwException(new Swift_TransportException( - 'Unsupported sendmail command flags ['.$command.']. '. - 'Must be one of "-bs" or "-t" but can include additional flags.' - )); - } + $message->generateId(); + } elseif (false !== strpos($command, ' -bs')) { + $count = parent::send($message, $failedRecipients); + } else { + $this->throwException(new Swift_TransportException( + 'Unsupported sendmail command flags ['.$command.']. '. + 'Must be one of "-bs" or "-t" but can include additional flags.' + )); + } - return $count; - } + return $count; + } - /** Get the params to initialize the buffer */ - protected function getBufferParams() - { - return $this->params; - } + /** Get the params to initialize the buffer */ + protected function getBufferParams() + { + return $this->params; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/SmtpAgent.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/SmtpAgent.php index e8ce65c2648..bb761237b1c 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/SmtpAgent.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/SmtpAgent.php @@ -15,22 +15,22 @@ */ interface Swift_Transport_SmtpAgent { - /** - * Get the IoBuffer where read/writes are occurring. - * - * @return Swift_Transport_IoBuffer - */ - public function getBuffer(); + /** + * Get the IoBuffer where read/writes are occurring. + * + * @return Swift_Transport_IoBuffer + */ + public function getBuffer(); - /** - * Run a command against the buffer, expecting the given response codes. - * - * If no response codes are given, the response will not be validated. - * If codes are given, an exception will be thrown on an invalid response. - * - * @param string $command - * @param int[] $codes - * @param string[] $failures An array of failures by-reference - */ - public function executeCommand($command, $codes = [], &$failures = null); + /** + * Run a command against the buffer, expecting the given response codes. + * + * If no response codes are given, the response will not be validated. + * If codes are given, an exception will be thrown on an invalid response. + * + * @param string $command + * @param int[] $codes + * @param string[] $failures An array of failures by-reference + */ + public function executeCommand($command, $codes = [], &$failures = null); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/SpoolTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/SpoolTransport.php index 0cb6a5b80a9..f7c19d05579 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/SpoolTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/SpoolTransport.php @@ -15,106 +15,106 @@ */ class Swift_Transport_SpoolTransport implements Swift_Transport { - /** The spool instance */ - private $spool; + /** The spool instance */ + private $spool; - /** The event dispatcher from the plugin API */ - private $eventDispatcher; + /** The event dispatcher from the plugin API */ + private $eventDispatcher; - /** - * Constructor. - */ - public function __construct(Swift_Events_EventDispatcher $eventDispatcher, Swift_Spool $spool = null) - { - $this->eventDispatcher = $eventDispatcher; - $this->spool = $spool; - } + /** + * Constructor. + */ + public function __construct(Swift_Events_EventDispatcher $eventDispatcher, Swift_Spool $spool = null) + { + $this->eventDispatcher = $eventDispatcher; + $this->spool = $spool; + } - /** - * Sets the spool object. - * - * @return $this - */ - public function setSpool(Swift_Spool $spool) - { - $this->spool = $spool; + /** + * Sets the spool object. + * + * @return $this + */ + public function setSpool(Swift_Spool $spool) + { + $this->spool = $spool; - return $this; - } + return $this; + } - /** - * Get the spool object. - * - * @return Swift_Spool - */ - public function getSpool() - { - return $this->spool; - } + /** + * Get the spool object. + * + * @return Swift_Spool + */ + public function getSpool() + { + return $this->spool; + } - /** - * Tests if this Transport mechanism has started. - * - * @return bool - */ - public function isStarted() - { - return true; - } + /** + * Tests if this Transport mechanism has started. + * + * @return bool + */ + public function isStarted() + { + return true; + } - /** - * Starts this Transport mechanism. - */ - public function start() - { - } + /** + * Starts this Transport mechanism. + */ + public function start() + { + } - /** - * Stops this Transport mechanism. - */ - public function stop() - { - } + /** + * Stops this Transport mechanism. + */ + public function stop() + { + } - /** - * {@inheritdoc} - */ - public function ping() - { - return true; - } + /** + * {@inheritdoc} + */ + public function ping() + { + return true; + } - /** - * Sends the given message. - * - * @param string[] $failedRecipients An array of failures by-reference - * - * @return int The number of sent e-mail's - */ - public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) - { - if ($evt = $this->eventDispatcher->createSendEvent($this, $message)) { - $this->eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); - if ($evt->bubbleCancelled()) { - return 0; - } - } + /** + * Sends the given message. + * + * @param string[] $failedRecipients An array of failures by-reference + * + * @return int The number of sent e-mail's + */ + public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) + { + if ($evt = $this->eventDispatcher->createSendEvent($this, $message)) { + $this->eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); + if ($evt->bubbleCancelled()) { + return 0; + } + } - $success = $this->spool->queueMessage($message); + $success = $this->spool->queueMessage($message); - if ($evt) { - $evt->setResult($success ? Swift_Events_SendEvent::RESULT_SPOOLED : Swift_Events_SendEvent::RESULT_FAILED); - $this->eventDispatcher->dispatchEvent($evt, 'sendPerformed'); - } + if ($evt) { + $evt->setResult($success ? Swift_Events_SendEvent::RESULT_SPOOLED : Swift_Events_SendEvent::RESULT_FAILED); + $this->eventDispatcher->dispatchEvent($evt, 'sendPerformed'); + } - return 1; - } + return 1; + } - /** - * Register a plugin. - */ - public function registerPlugin(Swift_Events_EventListener $plugin) - { - $this->eventDispatcher->bindEventListener($plugin); - } + /** + * Register a plugin. + */ + public function registerPlugin(Swift_Events_EventListener $plugin) + { + $this->eventDispatcher->bindEventListener($plugin); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php index 70782ada044..6a09db7938f 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php @@ -15,305 +15,305 @@ */ class Swift_Transport_StreamBuffer extends Swift_ByteStream_AbstractFilterableInputStream implements Swift_Transport_IoBuffer { - /** A primary socket */ - private $stream; + /** A primary socket */ + private $stream; - /** The input stream */ - private $in; + /** The input stream */ + private $in; - /** The output stream */ - private $out; + /** The output stream */ + private $out; - /** Buffer initialization parameters */ - private $params = []; + /** Buffer initialization parameters */ + private $params = []; - /** The ReplacementFilterFactory */ - private $replacementFactory; + /** The ReplacementFilterFactory */ + private $replacementFactory; - /** Translations performed on data being streamed into the buffer */ - private $translations = []; + /** Translations performed on data being streamed into the buffer */ + private $translations = []; - /** - * Create a new StreamBuffer using $replacementFactory for transformations. - */ - public function __construct(Swift_ReplacementFilterFactory $replacementFactory) - { - $this->replacementFactory = $replacementFactory; - } + /** + * Create a new StreamBuffer using $replacementFactory for transformations. + */ + public function __construct(Swift_ReplacementFilterFactory $replacementFactory) + { + $this->replacementFactory = $replacementFactory; + } - /** - * Perform any initialization needed, using the given $params. - * - * Parameters will vary depending upon the type of IoBuffer used. - */ - public function initialize(array $params) - { - $this->params = $params; - switch ($params['type']) { - case self::TYPE_PROCESS: - $this->establishProcessConnection(); - break; - case self::TYPE_SOCKET: - default: - $this->establishSocketConnection(); - break; - } - } + /** + * Perform any initialization needed, using the given $params. + * + * Parameters will vary depending upon the type of IoBuffer used. + */ + public function initialize(array $params) + { + $this->params = $params; + switch ($params['type']) { + case self::TYPE_PROCESS: + $this->establishProcessConnection(); + break; + case self::TYPE_SOCKET: + default: + $this->establishSocketConnection(); + break; + } + } - /** - * Set an individual param on the buffer (e.g. switching to SSL). - * - * @param string $param - * @param mixed $value - */ - public function setParam($param, $value) - { - if (isset($this->stream)) { - switch ($param) { - case 'timeout': - if ($this->stream) { - stream_set_timeout($this->stream, $value); - } - break; + /** + * Set an individual param on the buffer (e.g. switching to SSL). + * + * @param string $param + * @param mixed $value + */ + public function setParam($param, $value) + { + if (isset($this->stream)) { + switch ($param) { + case 'timeout': + if ($this->stream) { + stream_set_timeout($this->stream, $value); + } + break; - case 'blocking': - if ($this->stream) { - stream_set_blocking($this->stream, 1); - } - } - } - $this->params[$param] = $value; - } + case 'blocking': + if ($this->stream) { + stream_set_blocking($this->stream, 1); + } + } + } + $this->params[$param] = $value; + } - public function startTLS() - { - // STREAM_CRYPTO_METHOD_TLS_CLIENT only allow tls1.0 connections (some php versions) - // To support modern tls we allow explicit tls1.0, tls1.1, tls1.2 - // Ssl3 and older are not allowed because they are vulnerable - // @TODO make tls arguments configurable - return stream_socket_enable_crypto($this->stream, true, STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT); - } + public function startTLS() + { + // STREAM_CRYPTO_METHOD_TLS_CLIENT only allow tls1.0 connections (some php versions) + // To support modern tls we allow explicit tls1.0, tls1.1, tls1.2 + // Ssl3 and older are not allowed because they are vulnerable + // @TODO make tls arguments configurable + return stream_socket_enable_crypto($this->stream, true, STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT); + } - /** - * Perform any shutdown logic needed. - */ - public function terminate() - { - if (isset($this->stream)) { - switch ($this->params['type']) { - case self::TYPE_PROCESS: - fclose($this->in); - fclose($this->out); - proc_close($this->stream); - break; - case self::TYPE_SOCKET: - default: - fclose($this->stream); - break; - } - } - $this->stream = null; - $this->out = null; - $this->in = null; - } + /** + * Perform any shutdown logic needed. + */ + public function terminate() + { + if (isset($this->stream)) { + switch ($this->params['type']) { + case self::TYPE_PROCESS: + fclose($this->in); + fclose($this->out); + proc_close($this->stream); + break; + case self::TYPE_SOCKET: + default: + fclose($this->stream); + break; + } + } + $this->stream = null; + $this->out = null; + $this->in = null; + } - /** - * Set an array of string replacements which should be made on data written - * to the buffer. - * - * This could replace LF with CRLF for example. - * - * @param string[] $replacements - */ - public function setWriteTranslations(array $replacements) - { - foreach ($this->translations as $search => $replace) { - if (!isset($replacements[$search])) { - $this->removeFilter($search); - unset($this->translations[$search]); - } - } + /** + * Set an array of string replacements which should be made on data written + * to the buffer. + * + * This could replace LF with CRLF for example. + * + * @param string[] $replacements + */ + public function setWriteTranslations(array $replacements) + { + foreach ($this->translations as $search => $replace) { + if (!isset($replacements[$search])) { + $this->removeFilter($search); + unset($this->translations[$search]); + } + } - foreach ($replacements as $search => $replace) { - if (!isset($this->translations[$search])) { - $this->addFilter( - $this->replacementFactory->createFilter($search, $replace), $search - ); - $this->translations[$search] = true; - } - } - } + foreach ($replacements as $search => $replace) { + if (!isset($this->translations[$search])) { + $this->addFilter( + $this->replacementFactory->createFilter($search, $replace), $search + ); + $this->translations[$search] = true; + } + } + } - /** - * Get a line of output (including any CRLF). - * - * The $sequence number comes from any writes and may or may not be used - * depending upon the implementation. - * - * @param int $sequence of last write to scan from - * - * @return string - * - * @throws Swift_IoException - */ - public function readLine($sequence) - { - if (isset($this->out) && !feof($this->out)) { - $line = fgets($this->out); - if (0 == \strlen($line)) { - $metas = stream_get_meta_data($this->out); - if ($metas['timed_out']) { - throw new Swift_IoException('Connection to '.$this->getReadConnectionDescription().' Timed Out'); - } - } + /** + * Get a line of output (including any CRLF). + * + * The $sequence number comes from any writes and may or may not be used + * depending upon the implementation. + * + * @param int $sequence of last write to scan from + * + * @return string + * + * @throws Swift_IoException + */ + public function readLine($sequence) + { + if (isset($this->out) && !feof($this->out)) { + $line = fgets($this->out); + if (0 == \strlen($line)) { + $metas = stream_get_meta_data($this->out); + if ($metas['timed_out']) { + throw new Swift_IoException('Connection to '.$this->getReadConnectionDescription().' Timed Out'); + } + } - return $line; - } - } + return $line; + } + } - /** - * Reads $length bytes from the stream into a string and moves the pointer - * through the stream by $length. - * - * If less bytes exist than are requested the remaining bytes are given instead. - * If no bytes are remaining at all, boolean false is returned. - * - * @param int $length - * - * @return string|bool - * - * @throws Swift_IoException - */ - public function read($length) - { - if (isset($this->out) && !feof($this->out)) { - $ret = fread($this->out, $length); - if (0 == \strlen($ret)) { - $metas = stream_get_meta_data($this->out); - if ($metas['timed_out']) { - throw new Swift_IoException('Connection to '.$this->getReadConnectionDescription().' Timed Out'); - } - } + /** + * Reads $length bytes from the stream into a string and moves the pointer + * through the stream by $length. + * + * If less bytes exist than are requested the remaining bytes are given instead. + * If no bytes are remaining at all, boolean false is returned. + * + * @param int $length + * + * @return string|bool + * + * @throws Swift_IoException + */ + public function read($length) + { + if (isset($this->out) && !feof($this->out)) { + $ret = fread($this->out, $length); + if (0 == \strlen($ret)) { + $metas = stream_get_meta_data($this->out); + if ($metas['timed_out']) { + throw new Swift_IoException('Connection to '.$this->getReadConnectionDescription().' Timed Out'); + } + } - return $ret; - } - } + return $ret; + } + } - /** Not implemented */ - public function setReadPointer($byteOffset) - { - } + /** Not implemented */ + public function setReadPointer($byteOffset) + { + } - /** Flush the stream contents */ - protected function flush() - { - if (isset($this->in)) { - fflush($this->in); - } - } + /** Flush the stream contents */ + protected function flush() + { + if (isset($this->in)) { + fflush($this->in); + } + } - /** Write this bytes to the stream */ - protected function doCommit($bytes) - { - if (isset($this->in)) { - $bytesToWrite = \strlen($bytes); - $totalBytesWritten = 0; + /** Write this bytes to the stream */ + protected function doCommit($bytes) + { + if (isset($this->in)) { + $bytesToWrite = \strlen($bytes); + $totalBytesWritten = 0; - while ($totalBytesWritten < $bytesToWrite) { - $bytesWritten = fwrite($this->in, substr($bytes, $totalBytesWritten)); - if (false === $bytesWritten || 0 === $bytesWritten) { - break; - } + while ($totalBytesWritten < $bytesToWrite) { + $bytesWritten = fwrite($this->in, substr($bytes, $totalBytesWritten)); + if (false === $bytesWritten || 0 === $bytesWritten) { + break; + } - $totalBytesWritten += $bytesWritten; - } + $totalBytesWritten += $bytesWritten; + } - if ($totalBytesWritten > 0) { - return ++$this->sequence; - } - } - } + if ($totalBytesWritten > 0) { + return ++$this->sequence; + } + } + } - /** - * Establishes a connection to a remote server. - */ - private function establishSocketConnection() - { - $host = $this->params['host']; - if (!empty($this->params['protocol'])) { - $host = $this->params['protocol'].'://'.$host; - } - $timeout = 15; - if (!empty($this->params['timeout'])) { - $timeout = $this->params['timeout']; - } - $options = []; - if (!empty($this->params['sourceIp'])) { - $options['socket']['bindto'] = $this->params['sourceIp'].':0'; - } + /** + * Establishes a connection to a remote server. + */ + private function establishSocketConnection() + { + $host = $this->params['host']; + if (!empty($this->params['protocol'])) { + $host = $this->params['protocol'].'://'.$host; + } + $timeout = 15; + if (!empty($this->params['timeout'])) { + $timeout = $this->params['timeout']; + } + $options = []; + if (!empty($this->params['sourceIp'])) { + $options['socket']['bindto'] = $this->params['sourceIp'].':0'; + } - if (isset($this->params['stream_context_options'])) { - $options = array_merge($options, $this->params['stream_context_options']); - } - $streamContext = stream_context_create($options); + if (isset($this->params['stream_context_options'])) { + $options = array_merge($options, $this->params['stream_context_options']); + } + $streamContext = stream_context_create($options); - set_error_handler(function ($type, $msg) { - throw new Swift_TransportException('Connection could not be established with host '.$this->params['host'].' :'.$msg); - }); - try { - $this->stream = stream_socket_client($host.':'.$this->params['port'], $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $streamContext); - } finally { - restore_error_handler(); - } + set_error_handler(function ($type, $msg) { + throw new Swift_TransportException('Connection could not be established with host '.$this->params['host'].' :'.$msg); + }); + try { + $this->stream = stream_socket_client($host.':'.$this->params['port'], $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $streamContext); + } finally { + restore_error_handler(); + } - if (!empty($this->params['blocking'])) { - stream_set_blocking($this->stream, 1); - } else { - stream_set_blocking($this->stream, 0); - } - stream_set_timeout($this->stream, $timeout); - $this->in = &$this->stream; - $this->out = &$this->stream; - } + if (!empty($this->params['blocking'])) { + stream_set_blocking($this->stream, 1); + } else { + stream_set_blocking($this->stream, 0); + } + stream_set_timeout($this->stream, $timeout); + $this->in = &$this->stream; + $this->out = &$this->stream; + } - /** - * Opens a process for input/output. - */ - private function establishProcessConnection() - { - $command = $this->params['command']; - $descriptorSpec = [ - 0 => ['pipe', 'r'], - 1 => ['pipe', 'w'], - 2 => ['pipe', 'w'], - ]; - $pipes = []; - $this->stream = proc_open($command, $descriptorSpec, $pipes); - stream_set_blocking($pipes[2], 0); - if ($err = stream_get_contents($pipes[2])) { - throw new Swift_TransportException('Process could not be started ['.$err.']'); - } - $this->in = &$pipes[0]; - $this->out = &$pipes[1]; - } + /** + * Opens a process for input/output. + */ + private function establishProcessConnection() + { + $command = $this->params['command']; + $descriptorSpec = [ + 0 => ['pipe', 'r'], + 1 => ['pipe', 'w'], + 2 => ['pipe', 'w'], + ]; + $pipes = []; + $this->stream = proc_open($command, $descriptorSpec, $pipes); + stream_set_blocking($pipes[2], 0); + if ($err = stream_get_contents($pipes[2])) { + throw new Swift_TransportException('Process could not be started ['.$err.']'); + } + $this->in = &$pipes[0]; + $this->out = &$pipes[1]; + } - private function getReadConnectionDescription() - { - switch ($this->params['type']) { - case self::TYPE_PROCESS: - return 'Process '.$this->params['command']; - break; + private function getReadConnectionDescription() + { + switch ($this->params['type']) { + case self::TYPE_PROCESS: + return 'Process '.$this->params['command']; + break; - case self::TYPE_SOCKET: - default: - $host = $this->params['host']; - if (!empty($this->params['protocol'])) { - $host = $this->params['protocol'].'://'.$host; - } - $host .= ':'.$this->params['port']; + case self::TYPE_SOCKET: + default: + $host = $this->params['host']; + if (!empty($this->params['protocol'])) { + $host = $this->params['protocol'].'://'.$host; + } + $host .= ':'.$this->params['port']; - return $host; - break; - } - } + return $host; + break; + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/TransportException.php b/htdocs/includes/swiftmailer/lib/classes/Swift/TransportException.php index c7417455b3e..763c9fed2ee 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/TransportException.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/TransportException.php @@ -15,14 +15,14 @@ */ class Swift_TransportException extends Swift_IoException { - /** - * Create a new TransportException with $message. - * - * @param string $message - * @param int $code - */ - public function __construct($message, $code = 0, Exception $previous = null) - { - parent::__construct($message, $code, $previous); - } + /** + * Create a new TransportException with $message. + * + * @param string $message + * @param int $code + */ + public function __construct($message, $code = 0, Exception $previous = null) + { + parent::__construct($message, $code, $previous); + } } diff --git a/htdocs/includes/swiftmailer/lib/dependency_maps/cache_deps.php b/htdocs/includes/swiftmailer/lib/dependency_maps/cache_deps.php index 9d94d774014..c2f2df20bc3 100644 --- a/htdocs/includes/swiftmailer/lib/dependency_maps/cache_deps.php +++ b/htdocs/includes/swiftmailer/lib/dependency_maps/cache_deps.php @@ -1,23 +1,22 @@ register('cache') - ->asAliasOf('cache.array') + ->register('cache') + ->asAliasOf('cache.array') - ->register('tempdir') - ->asValue('/tmp') + ->register('tempdir') + ->asValue('/tmp') - ->register('cache.null') - ->asSharedInstanceOf('Swift_KeyCache_NullKeyCache') + ->register('cache.null') + ->asSharedInstanceOf('Swift_KeyCache_NullKeyCache') - ->register('cache.array') - ->asSharedInstanceOf('Swift_KeyCache_ArrayKeyCache') - ->withDependencies(['cache.inputstream']) + ->register('cache.array') + ->asSharedInstanceOf('Swift_KeyCache_ArrayKeyCache') + ->withDependencies(['cache.inputstream']) - ->register('cache.disk') - ->asSharedInstanceOf('Swift_KeyCache_DiskKeyCache') - ->withDependencies(['cache.inputstream', 'tempdir']) + ->register('cache.disk') + ->asSharedInstanceOf('Swift_KeyCache_DiskKeyCache') + ->withDependencies(['cache.inputstream', 'tempdir']) - ->register('cache.inputstream') - ->asNewInstanceOf('Swift_KeyCache_SimpleKeyCacheInputStream') -; + ->register('cache.inputstream') + ->asNewInstanceOf('Swift_KeyCache_SimpleKeyCacheInputStream'); diff --git a/htdocs/includes/swiftmailer/lib/dependency_maps/mime_deps.php b/htdocs/includes/swiftmailer/lib/dependency_maps/mime_deps.php index 307756c89f3..3ee1b762ebe 100644 --- a/htdocs/includes/swiftmailer/lib/dependency_maps/mime_deps.php +++ b/htdocs/includes/swiftmailer/lib/dependency_maps/mime_deps.php @@ -3,132 +3,131 @@ require __DIR__.'/../mime_types.php'; Swift_DependencyContainer::getInstance() - ->register('properties.charset') - ->asValue('utf-8') + ->register('properties.charset') + ->asValue('utf-8') - ->register('email.validator') - ->asSharedInstanceOf('Egulias\EmailValidator\EmailValidator') + ->register('email.validator') + ->asSharedInstanceOf('Egulias\EmailValidator\EmailValidator') - ->register('mime.idgenerator.idright') - // As SERVER_NAME can come from the user in certain configurations, check that - // it does not contain forbidden characters (see RFC 952 and RFC 2181). Use - // preg_replace() instead of preg_match() to prevent DoS attacks with long host names. - ->asValue(!empty($_SERVER['SERVER_NAME']) && '' === preg_replace('/(?:^\[)?[a-zA-Z0-9-:\]_]+\.?/', '', $_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'swift.generated') + ->register('mime.idgenerator.idright') + // As SERVER_NAME can come from the user in certain configurations, check that + // it does not contain forbidden characters (see RFC 952 and RFC 2181). Use + // preg_replace() instead of preg_match() to prevent DoS attacks with long host names. + ->asValue(!empty($_SERVER['SERVER_NAME']) && '' === preg_replace('/(?:^\[)?[a-zA-Z0-9-:\]_]+\.?/', '', $_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'swift.generated') - ->register('mime.idgenerator') - ->asSharedInstanceOf('Swift_Mime_IdGenerator') - ->withDependencies([ - 'mime.idgenerator.idright', - ]) + ->register('mime.idgenerator') + ->asSharedInstanceOf('Swift_Mime_IdGenerator') + ->withDependencies([ + 'mime.idgenerator.idright', + ]) - ->register('mime.message') - ->asNewInstanceOf('Swift_Mime_SimpleMessage') - ->withDependencies([ - 'mime.headerset', - 'mime.textcontentencoder', - 'cache', - 'mime.idgenerator', - 'properties.charset', - ]) + ->register('mime.message') + ->asNewInstanceOf('Swift_Mime_SimpleMessage') + ->withDependencies([ + 'mime.headerset', + 'mime.textcontentencoder', + 'cache', + 'mime.idgenerator', + 'properties.charset', + ]) - ->register('mime.part') - ->asNewInstanceOf('Swift_Mime_MimePart') - ->withDependencies([ - 'mime.headerset', - 'mime.textcontentencoder', - 'cache', - 'mime.idgenerator', - 'properties.charset', - ]) + ->register('mime.part') + ->asNewInstanceOf('Swift_Mime_MimePart') + ->withDependencies([ + 'mime.headerset', + 'mime.textcontentencoder', + 'cache', + 'mime.idgenerator', + 'properties.charset', + ]) - ->register('mime.attachment') - ->asNewInstanceOf('Swift_Mime_Attachment') - ->withDependencies([ - 'mime.headerset', - 'mime.base64contentencoder', - 'cache', - 'mime.idgenerator', - ]) - ->addConstructorValue($swift_mime_types) + ->register('mime.attachment') + ->asNewInstanceOf('Swift_Mime_Attachment') + ->withDependencies([ + 'mime.headerset', + 'mime.base64contentencoder', + 'cache', + 'mime.idgenerator', + ]) + ->addConstructorValue($swift_mime_types) - ->register('mime.embeddedfile') - ->asNewInstanceOf('Swift_Mime_EmbeddedFile') - ->withDependencies([ - 'mime.headerset', - 'mime.base64contentencoder', - 'cache', - 'mime.idgenerator', - ]) - ->addConstructorValue($swift_mime_types) + ->register('mime.embeddedfile') + ->asNewInstanceOf('Swift_Mime_EmbeddedFile') + ->withDependencies([ + 'mime.headerset', + 'mime.base64contentencoder', + 'cache', + 'mime.idgenerator', + ]) + ->addConstructorValue($swift_mime_types) - ->register('mime.headerfactory') - ->asNewInstanceOf('Swift_Mime_SimpleHeaderFactory') - ->withDependencies([ - 'mime.qpheaderencoder', - 'mime.rfc2231encoder', - 'email.validator', - 'properties.charset', - 'address.idnaddressencoder', - ]) + ->register('mime.headerfactory') + ->asNewInstanceOf('Swift_Mime_SimpleHeaderFactory') + ->withDependencies([ + 'mime.qpheaderencoder', + 'mime.rfc2231encoder', + 'email.validator', + 'properties.charset', + 'address.idnaddressencoder', + ]) - ->register('mime.headerset') - ->asNewInstanceOf('Swift_Mime_SimpleHeaderSet') - ->withDependencies(['mime.headerfactory', 'properties.charset']) + ->register('mime.headerset') + ->asNewInstanceOf('Swift_Mime_SimpleHeaderSet') + ->withDependencies(['mime.headerfactory', 'properties.charset']) - ->register('mime.qpheaderencoder') - ->asNewInstanceOf('Swift_Mime_HeaderEncoder_QpHeaderEncoder') - ->withDependencies(['mime.charstream']) + ->register('mime.qpheaderencoder') + ->asNewInstanceOf('Swift_Mime_HeaderEncoder_QpHeaderEncoder') + ->withDependencies(['mime.charstream']) - ->register('mime.base64headerencoder') - ->asNewInstanceOf('Swift_Mime_HeaderEncoder_Base64HeaderEncoder') - ->withDependencies(['mime.charstream']) + ->register('mime.base64headerencoder') + ->asNewInstanceOf('Swift_Mime_HeaderEncoder_Base64HeaderEncoder') + ->withDependencies(['mime.charstream']) - ->register('mime.charstream') - ->asNewInstanceOf('Swift_CharacterStream_NgCharacterStream') - ->withDependencies(['mime.characterreaderfactory', 'properties.charset']) + ->register('mime.charstream') + ->asNewInstanceOf('Swift_CharacterStream_NgCharacterStream') + ->withDependencies(['mime.characterreaderfactory', 'properties.charset']) - ->register('mime.bytecanonicalizer') - ->asSharedInstanceOf('Swift_StreamFilters_ByteArrayReplacementFilter') - ->addConstructorValue([[0x0D, 0x0A], [0x0D], [0x0A]]) - ->addConstructorValue([[0x0A], [0x0A], [0x0D, 0x0A]]) + ->register('mime.bytecanonicalizer') + ->asSharedInstanceOf('Swift_StreamFilters_ByteArrayReplacementFilter') + ->addConstructorValue([[0x0D, 0x0A], [0x0D], [0x0A]]) + ->addConstructorValue([[0x0A], [0x0A], [0x0D, 0x0A]]) - ->register('mime.characterreaderfactory') - ->asSharedInstanceOf('Swift_CharacterReaderFactory_SimpleCharacterReaderFactory') + ->register('mime.characterreaderfactory') + ->asSharedInstanceOf('Swift_CharacterReaderFactory_SimpleCharacterReaderFactory') - ->register('mime.textcontentencoder') - ->asAliasOf('mime.qpcontentencoder') + ->register('mime.textcontentencoder') + ->asAliasOf('mime.qpcontentencoder') - ->register('mime.safeqpcontentencoder') - ->asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoder') - ->withDependencies(['mime.charstream', 'mime.bytecanonicalizer']) + ->register('mime.safeqpcontentencoder') + ->asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoder') + ->withDependencies(['mime.charstream', 'mime.bytecanonicalizer']) - ->register('mime.rawcontentencoder') - ->asNewInstanceOf('Swift_Mime_ContentEncoder_RawContentEncoder') + ->register('mime.rawcontentencoder') + ->asNewInstanceOf('Swift_Mime_ContentEncoder_RawContentEncoder') - ->register('mime.nativeqpcontentencoder') - ->withDependencies(['properties.charset']) - ->asNewInstanceOf('Swift_Mime_ContentEncoder_NativeQpContentEncoder') + ->register('mime.nativeqpcontentencoder') + ->withDependencies(['properties.charset']) + ->asNewInstanceOf('Swift_Mime_ContentEncoder_NativeQpContentEncoder') - ->register('mime.qpcontentencoder') - ->asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoderProxy') - ->withDependencies(['mime.safeqpcontentencoder', 'mime.nativeqpcontentencoder', 'properties.charset']) + ->register('mime.qpcontentencoder') + ->asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoderProxy') + ->withDependencies(['mime.safeqpcontentencoder', 'mime.nativeqpcontentencoder', 'properties.charset']) - ->register('mime.7bitcontentencoder') - ->asNewInstanceOf('Swift_Mime_ContentEncoder_PlainContentEncoder') - ->addConstructorValue('7bit') - ->addConstructorValue(true) + ->register('mime.7bitcontentencoder') + ->asNewInstanceOf('Swift_Mime_ContentEncoder_PlainContentEncoder') + ->addConstructorValue('7bit') + ->addConstructorValue(true) - ->register('mime.8bitcontentencoder') - ->asNewInstanceOf('Swift_Mime_ContentEncoder_PlainContentEncoder') - ->addConstructorValue('8bit') - ->addConstructorValue(true) + ->register('mime.8bitcontentencoder') + ->asNewInstanceOf('Swift_Mime_ContentEncoder_PlainContentEncoder') + ->addConstructorValue('8bit') + ->addConstructorValue(true) - ->register('mime.base64contentencoder') - ->asSharedInstanceOf('Swift_Mime_ContentEncoder_Base64ContentEncoder') + ->register('mime.base64contentencoder') + ->asSharedInstanceOf('Swift_Mime_ContentEncoder_Base64ContentEncoder') - ->register('mime.rfc2231encoder') - ->asNewInstanceOf('Swift_Encoder_Rfc2231Encoder') - ->withDependencies(['mime.charstream']) -; + ->register('mime.rfc2231encoder') + ->asNewInstanceOf('Swift_Encoder_Rfc2231Encoder') + ->withDependencies(['mime.charstream']); unset($swift_mime_types); diff --git a/htdocs/includes/swiftmailer/lib/dependency_maps/transport_deps.php b/htdocs/includes/swiftmailer/lib/dependency_maps/transport_deps.php index 34a63c78e51..40d65b176b9 100644 --- a/htdocs/includes/swiftmailer/lib/dependency_maps/transport_deps.php +++ b/htdocs/includes/swiftmailer/lib/dependency_maps/transport_deps.php @@ -1,97 +1,96 @@ register('transport.localdomain') - // As SERVER_NAME can come from the user in certain configurations, check that - // it does not contain forbidden characters (see RFC 952 and RFC 2181). Use - // preg_replace() instead of preg_match() to prevent DoS attacks with long host names. - ->asValue(!empty($_SERVER['SERVER_NAME']) && '' === preg_replace('/(?:^\[)?[a-zA-Z0-9-:\]_]+\.?/', '', $_SERVER['SERVER_NAME']) ? trim($_SERVER['SERVER_NAME'], '[]') : '127.0.0.1') + ->register('transport.localdomain') + // As SERVER_NAME can come from the user in certain configurations, check that + // it does not contain forbidden characters (see RFC 952 and RFC 2181). Use + // preg_replace() instead of preg_match() to prevent DoS attacks with long host names. + ->asValue(!empty($_SERVER['SERVER_NAME']) && '' === preg_replace('/(?:^\[)?[a-zA-Z0-9-:\]_]+\.?/', '', $_SERVER['SERVER_NAME']) ? trim($_SERVER['SERVER_NAME'], '[]') : '127.0.0.1') - ->register('transport.smtp') - ->asNewInstanceOf('Swift_Transport_EsmtpTransport') - ->withDependencies([ - 'transport.buffer', - 'transport.smtphandlers', - 'transport.eventdispatcher', - 'transport.localdomain', - 'address.idnaddressencoder', - ]) + ->register('transport.smtp') + ->asNewInstanceOf('Swift_Transport_EsmtpTransport') + ->withDependencies([ + 'transport.buffer', + 'transport.smtphandlers', + 'transport.eventdispatcher', + 'transport.localdomain', + 'address.idnaddressencoder', + ]) - ->register('transport.sendmail') - ->asNewInstanceOf('Swift_Transport_SendmailTransport') - ->withDependencies([ - 'transport.buffer', - 'transport.eventdispatcher', - 'transport.localdomain', - ]) + ->register('transport.sendmail') + ->asNewInstanceOf('Swift_Transport_SendmailTransport') + ->withDependencies([ + 'transport.buffer', + 'transport.eventdispatcher', + 'transport.localdomain', + ]) - ->register('transport.loadbalanced') - ->asNewInstanceOf('Swift_Transport_LoadBalancedTransport') + ->register('transport.loadbalanced') + ->asNewInstanceOf('Swift_Transport_LoadBalancedTransport') - ->register('transport.failover') - ->asNewInstanceOf('Swift_Transport_FailoverTransport') + ->register('transport.failover') + ->asNewInstanceOf('Swift_Transport_FailoverTransport') - ->register('transport.spool') - ->asNewInstanceOf('Swift_Transport_SpoolTransport') - ->withDependencies(['transport.eventdispatcher']) + ->register('transport.spool') + ->asNewInstanceOf('Swift_Transport_SpoolTransport') + ->withDependencies(['transport.eventdispatcher']) - ->register('transport.null') - ->asNewInstanceOf('Swift_Transport_NullTransport') - ->withDependencies(['transport.eventdispatcher']) + ->register('transport.null') + ->asNewInstanceOf('Swift_Transport_NullTransport') + ->withDependencies(['transport.eventdispatcher']) - ->register('transport.buffer') - ->asNewInstanceOf('Swift_Transport_StreamBuffer') - ->withDependencies(['transport.replacementfactory']) + ->register('transport.buffer') + ->asNewInstanceOf('Swift_Transport_StreamBuffer') + ->withDependencies(['transport.replacementfactory']) - ->register('transport.smtphandlers') - ->asArray() - ->withDependencies(['transport.authhandler']) + ->register('transport.smtphandlers') + ->asArray() + ->withDependencies(['transport.authhandler']) - ->register('transport.authhandler') - ->asNewInstanceOf('Swift_Transport_Esmtp_AuthHandler') - ->withDependencies(['transport.authhandlers']) + ->register('transport.authhandler') + ->asNewInstanceOf('Swift_Transport_Esmtp_AuthHandler') + ->withDependencies(['transport.authhandlers']) - ->register('transport.authhandlers') - ->asArray() - ->withDependencies([ - 'transport.crammd5auth', - 'transport.loginauth', - 'transport.plainauth', - 'transport.ntlmauth', - 'transport.xoauth2auth', - ]) + ->register('transport.authhandlers') + ->asArray() + ->withDependencies([ + 'transport.crammd5auth', + 'transport.loginauth', + 'transport.plainauth', + 'transport.ntlmauth', + 'transport.xoauth2auth', + ]) - ->register('transport.smtputf8handler') - ->asNewInstanceOf('Swift_Transport_Esmtp_SmtpUtf8Handler') + ->register('transport.smtputf8handler') + ->asNewInstanceOf('Swift_Transport_Esmtp_SmtpUtf8Handler') - ->register('transport.8bitmimehandler') - ->asNewInstanceOf('Swift_Transport_Esmtp_EightBitMimeHandler') - ->addConstructorValue('8BITMIME') + ->register('transport.8bitmimehandler') + ->asNewInstanceOf('Swift_Transport_Esmtp_EightBitMimeHandler') + ->addConstructorValue('8BITMIME') - ->register('transport.crammd5auth') - ->asNewInstanceOf('Swift_Transport_Esmtp_Auth_CramMd5Authenticator') + ->register('transport.crammd5auth') + ->asNewInstanceOf('Swift_Transport_Esmtp_Auth_CramMd5Authenticator') - ->register('transport.loginauth') - ->asNewInstanceOf('Swift_Transport_Esmtp_Auth_LoginAuthenticator') + ->register('transport.loginauth') + ->asNewInstanceOf('Swift_Transport_Esmtp_Auth_LoginAuthenticator') - ->register('transport.plainauth') - ->asNewInstanceOf('Swift_Transport_Esmtp_Auth_PlainAuthenticator') + ->register('transport.plainauth') + ->asNewInstanceOf('Swift_Transport_Esmtp_Auth_PlainAuthenticator') - ->register('transport.xoauth2auth') - ->asNewInstanceOf('Swift_Transport_Esmtp_Auth_XOAuth2Authenticator') + ->register('transport.xoauth2auth') + ->asNewInstanceOf('Swift_Transport_Esmtp_Auth_XOAuth2Authenticator') - ->register('transport.ntlmauth') - ->asNewInstanceOf('Swift_Transport_Esmtp_Auth_NTLMAuthenticator') + ->register('transport.ntlmauth') + ->asNewInstanceOf('Swift_Transport_Esmtp_Auth_NTLMAuthenticator') - ->register('transport.eventdispatcher') - ->asNewInstanceOf('Swift_Events_SimpleEventDispatcher') + ->register('transport.eventdispatcher') + ->asNewInstanceOf('Swift_Events_SimpleEventDispatcher') - ->register('transport.replacementfactory') - ->asSharedInstanceOf('Swift_StreamFilters_StringReplacementFilterFactory') + ->register('transport.replacementfactory') + ->asSharedInstanceOf('Swift_StreamFilters_StringReplacementFilterFactory') - ->register('address.idnaddressencoder') - ->asNewInstanceOf('Swift_AddressEncoder_IdnAddressEncoder') + ->register('address.idnaddressencoder') + ->asNewInstanceOf('Swift_AddressEncoder_IdnAddressEncoder') - ->register('address.utf8addressencoder') - ->asNewInstanceOf('Swift_AddressEncoder_Utf8AddressEncoder') -; + ->register('address.utf8addressencoder') + ->asNewInstanceOf('Swift_AddressEncoder_Utf8AddressEncoder'); diff --git a/htdocs/includes/swiftmailer/lib/mime_types.php b/htdocs/includes/swiftmailer/lib/mime_types.php index 72c6fd2afa6..0cb61d18832 100644 --- a/htdocs/includes/swiftmailer/lib/mime_types.php +++ b/htdocs/includes/swiftmailer/lib/mime_types.php @@ -18,990 +18,990 @@ // You may add or take away what you like (lowercase required) $swift_mime_types = [ - '3dml' => 'text/vnd.in3d.3dml', - '3ds' => 'image/x-3ds', - '3g2' => 'video/3gpp2', - '3gp' => 'video/3gpp', - '7z' => 'application/x-7z-compressed', - 'aab' => 'application/x-authorware-bin', - 'aac' => 'audio/x-aac', - 'aam' => 'application/x-authorware-map', - 'aas' => 'application/x-authorware-seg', - 'abw' => 'application/x-abiword', - 'ac' => 'application/pkix-attr-cert', - 'acc' => 'application/vnd.americandynamics.acc', - 'ace' => 'application/x-ace-compressed', - 'acu' => 'application/vnd.acucobol', - 'acutc' => 'application/vnd.acucorp', - 'adp' => 'audio/adpcm', - 'aep' => 'application/vnd.audiograph', - 'afm' => 'application/x-font-type1', - 'afp' => 'application/vnd.ibm.modcap', - 'ahead' => 'application/vnd.ahead.space', - 'ai' => 'application/postscript', - 'aif' => 'audio/x-aiff', - 'aifc' => 'audio/x-aiff', - 'aiff' => 'audio/x-aiff', - 'air' => 'application/vnd.adobe.air-application-installer-package+zip', - 'ait' => 'application/vnd.dvb.ait', - 'ami' => 'application/vnd.amiga.ami', - 'apk' => 'application/vnd.android.package-archive', - 'appcache' => 'text/cache-manifest', - 'apr' => 'application/vnd.lotus-approach', - 'aps' => 'application/postscript', - 'arc' => 'application/x-freearc', - 'asc' => 'application/pgp-signature', - 'asf' => 'video/x-ms-asf', - 'asm' => 'text/x-asm', - 'aso' => 'application/vnd.accpac.simply.aso', - 'asx' => 'video/x-ms-asf', - 'atc' => 'application/vnd.acucorp', - 'atom' => 'application/atom+xml', - 'atomcat' => 'application/atomcat+xml', - 'atomsvc' => 'application/atomsvc+xml', - 'atx' => 'application/vnd.antix.game-component', - 'au' => 'audio/basic', - 'avi' => 'video/x-msvideo', - 'aw' => 'application/applixware', - 'azf' => 'application/vnd.airzip.filesecure.azf', - 'azs' => 'application/vnd.airzip.filesecure.azs', - 'azw' => 'application/vnd.amazon.ebook', - 'bat' => 'application/x-msdownload', - 'bcpio' => 'application/x-bcpio', - 'bdf' => 'application/x-font-bdf', - 'bdm' => 'application/vnd.syncml.dm+wbxml', - 'bed' => 'application/vnd.realvnc.bed', - 'bh2' => 'application/vnd.fujitsu.oasysprs', - 'bin' => 'application/octet-stream', - 'blb' => 'application/x-blorb', - 'blorb' => 'application/x-blorb', - 'bmi' => 'application/vnd.bmi', - 'bmp' => 'image/bmp', - 'book' => 'application/vnd.framemaker', - 'box' => 'application/vnd.previewsystems.box', - 'boz' => 'application/x-bzip2', - 'bpk' => 'application/octet-stream', - 'btif' => 'image/prs.btif', - 'bz' => 'application/x-bzip', - 'bz2' => 'application/x-bzip2', - 'c' => 'text/x-c', - 'c11amc' => 'application/vnd.cluetrust.cartomobile-config', - 'c11amz' => 'application/vnd.cluetrust.cartomobile-config-pkg', - 'c4d' => 'application/vnd.clonk.c4group', - 'c4f' => 'application/vnd.clonk.c4group', - 'c4g' => 'application/vnd.clonk.c4group', - 'c4p' => 'application/vnd.clonk.c4group', - 'c4u' => 'application/vnd.clonk.c4group', - 'cab' => 'application/vnd.ms-cab-compressed', - 'caf' => 'audio/x-caf', - 'cap' => 'application/vnd.tcpdump.pcap', - 'car' => 'application/vnd.curl.car', - 'cat' => 'application/vnd.ms-pki.seccat', - 'cb7' => 'application/x-cbr', - 'cba' => 'application/x-cbr', - 'cbr' => 'application/x-cbr', - 'cbt' => 'application/x-cbr', - 'cbz' => 'application/x-cbr', - 'cc' => 'text/x-c', - 'cct' => 'application/x-director', - 'ccxml' => 'application/ccxml+xml', - 'cdbcmsg' => 'application/vnd.contact.cmsg', - 'cdf' => 'application/x-netcdf', - 'cdkey' => 'application/vnd.mediastation.cdkey', - 'cdmia' => 'application/cdmi-capability', - 'cdmic' => 'application/cdmi-container', - 'cdmid' => 'application/cdmi-domain', - 'cdmio' => 'application/cdmi-object', - 'cdmiq' => 'application/cdmi-queue', - 'cdx' => 'chemical/x-cdx', - 'cdxml' => 'application/vnd.chemdraw+xml', - 'cdy' => 'application/vnd.cinderella', - 'cer' => 'application/pkix-cert', - 'cfs' => 'application/x-cfs-compressed', - 'cgm' => 'image/cgm', - 'chat' => 'application/x-chat', - 'chm' => 'application/vnd.ms-htmlhelp', - 'chrt' => 'application/vnd.kde.kchart', - 'cif' => 'chemical/x-cif', - 'cii' => 'application/vnd.anser-web-certificate-issue-initiation', - 'cil' => 'application/vnd.ms-artgalry', - 'cla' => 'application/vnd.claymore', - 'class' => 'application/java-vm', - 'clkk' => 'application/vnd.crick.clicker.keyboard', - 'clkp' => 'application/vnd.crick.clicker.palette', - 'clkt' => 'application/vnd.crick.clicker.template', - 'clkw' => 'application/vnd.crick.clicker.wordbank', - 'clkx' => 'application/vnd.crick.clicker', - 'clp' => 'application/x-msclip', - 'cmc' => 'application/vnd.cosmocaller', - 'cmdf' => 'chemical/x-cmdf', - 'cml' => 'chemical/x-cml', - 'cmp' => 'application/vnd.yellowriver-custom-menu', - 'cmx' => 'image/x-cmx', - 'cod' => 'application/vnd.rim.cod', - 'com' => 'application/x-msdownload', - 'conf' => 'text/plain', - 'cpio' => 'application/x-cpio', - 'cpp' => 'text/x-c', - 'cpt' => 'application/mac-compactpro', - 'crd' => 'application/x-mscardfile', - 'crl' => 'application/pkix-crl', - 'crt' => 'application/x-x509-ca-cert', - 'csh' => 'application/x-csh', - 'csml' => 'chemical/x-csml', - 'csp' => 'application/vnd.commonspace', - 'css' => 'text/css', - 'cst' => 'application/x-director', - 'csv' => 'text/csv', - 'cu' => 'application/cu-seeme', - 'curl' => 'text/vnd.curl', - 'cww' => 'application/prs.cww', - 'cxt' => 'application/x-director', - 'cxx' => 'text/x-c', - 'dae' => 'model/vnd.collada+xml', - 'daf' => 'application/vnd.mobius.daf', - 'dart' => 'application/vnd.dart', - 'dataless' => 'application/vnd.fdsn.seed', - 'davmount' => 'application/davmount+xml', - 'dbk' => 'application/docbook+xml', - 'dcr' => 'application/x-director', - 'dcurl' => 'text/vnd.curl.dcurl', - 'dd2' => 'application/vnd.oma.dd2+xml', - 'ddd' => 'application/vnd.fujixerox.ddd', - 'deb' => 'application/x-debian-package', - 'def' => 'text/plain', - 'deploy' => 'application/octet-stream', - 'der' => 'application/x-x509-ca-cert', - 'dfac' => 'application/vnd.dreamfactory', - 'dgc' => 'application/x-dgc-compressed', - 'dic' => 'text/x-c', - 'dir' => 'application/x-director', - 'dis' => 'application/vnd.mobius.dis', - 'dist' => 'application/octet-stream', - 'distz' => 'application/octet-stream', - 'djv' => 'image/vnd.djvu', - 'djvu' => 'image/vnd.djvu', - 'dll' => 'application/x-msdownload', - 'dmg' => 'application/x-apple-diskimage', - 'dmp' => 'application/vnd.tcpdump.pcap', - 'dms' => 'application/octet-stream', - 'dna' => 'application/vnd.dna', - 'doc' => 'application/msword', - 'docm' => 'application/vnd.ms-word.document.macroenabled.12', - 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', - 'dot' => 'application/msword', - 'dotm' => 'application/vnd.ms-word.template.macroenabled.12', - 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', - 'dp' => 'application/vnd.osgi.dp', - 'dpg' => 'application/vnd.dpgraph', - 'dra' => 'audio/vnd.dra', - 'dsc' => 'text/prs.lines.tag', - 'dssc' => 'application/dssc+der', - 'dtb' => 'application/x-dtbook+xml', - 'dtd' => 'application/xml-dtd', - 'dts' => 'audio/vnd.dts', - 'dtshd' => 'audio/vnd.dts.hd', - 'dump' => 'application/octet-stream', - 'dvb' => 'video/vnd.dvb.file', - 'dvi' => 'application/x-dvi', - 'dwf' => 'model/vnd.dwf', - 'dwg' => 'image/vnd.dwg', - 'dxf' => 'image/vnd.dxf', - 'dxp' => 'application/vnd.spotfire.dxp', - 'dxr' => 'application/x-director', - 'ecelp4800' => 'audio/vnd.nuera.ecelp4800', - 'ecelp7470' => 'audio/vnd.nuera.ecelp7470', - 'ecelp9600' => 'audio/vnd.nuera.ecelp9600', - 'ecma' => 'application/ecmascript', - 'edm' => 'application/vnd.novadigm.edm', - 'edx' => 'application/vnd.novadigm.edx', - 'efif' => 'application/vnd.picsel', - 'ei6' => 'application/vnd.pg.osasli', - 'elc' => 'application/octet-stream', - 'emf' => 'application/x-msmetafile', - 'eml' => 'message/rfc822', - 'emma' => 'application/emma+xml', - 'emz' => 'application/x-msmetafile', - 'eol' => 'audio/vnd.digital-winds', - 'eot' => 'application/vnd.ms-fontobject', - 'eps' => 'application/postscript', - 'epub' => 'application/epub+zip', - 'es3' => 'application/vnd.eszigno3+xml', - 'esa' => 'application/vnd.osgi.subsystem', - 'esf' => 'application/vnd.epson.esf', - 'et3' => 'application/vnd.eszigno3+xml', - 'etx' => 'text/x-setext', - 'eva' => 'application/x-eva', - 'evy' => 'application/x-envoy', - 'exe' => 'application/x-msdownload', - 'exi' => 'application/exi', - 'ext' => 'application/vnd.novadigm.ext', - 'ez' => 'application/andrew-inset', - 'ez2' => 'application/vnd.ezpix-album', - 'ez3' => 'application/vnd.ezpix-package', - 'f' => 'text/x-fortran', - 'f4v' => 'video/x-f4v', - 'f77' => 'text/x-fortran', - 'f90' => 'text/x-fortran', - 'fbs' => 'image/vnd.fastbidsheet', - 'fcdt' => 'application/vnd.adobe.formscentral.fcdt', - 'fcs' => 'application/vnd.isac.fcs', - 'fdf' => 'application/vnd.fdf', - 'fe_launch' => 'application/vnd.denovo.fcselayout-link', - 'fg5' => 'application/vnd.fujitsu.oasysgp', - 'fgd' => 'application/x-director', - 'fh' => 'image/x-freehand', - 'fh4' => 'image/x-freehand', - 'fh5' => 'image/x-freehand', - 'fh7' => 'image/x-freehand', - 'fhc' => 'image/x-freehand', - 'fig' => 'application/x-xfig', - 'flac' => 'audio/x-flac', - 'fli' => 'video/x-fli', - 'flo' => 'application/vnd.micrografx.flo', - 'flv' => 'video/x-flv', - 'flw' => 'application/vnd.kde.kivio', - 'flx' => 'text/vnd.fmi.flexstor', - 'fly' => 'text/vnd.fly', - 'fm' => 'application/vnd.framemaker', - 'fnc' => 'application/vnd.frogans.fnc', - 'for' => 'text/x-fortran', - 'fpx' => 'image/vnd.fpx', - 'frame' => 'application/vnd.framemaker', - 'fsc' => 'application/vnd.fsc.weblaunch', - 'fst' => 'image/vnd.fst', - 'ftc' => 'application/vnd.fluxtime.clip', - 'fti' => 'application/vnd.anser-web-funds-transfer-initiation', - 'fvt' => 'video/vnd.fvt', - 'fxp' => 'application/vnd.adobe.fxp', - 'fxpl' => 'application/vnd.adobe.fxp', - 'fzs' => 'application/vnd.fuzzysheet', - 'g2w' => 'application/vnd.geoplan', - 'g3' => 'image/g3fax', - 'g3w' => 'application/vnd.geospace', - 'gac' => 'application/vnd.groove-account', - 'gam' => 'application/x-tads', - 'gbr' => 'application/rpki-ghostbusters', - 'gca' => 'application/x-gca-compressed', - 'gdl' => 'model/vnd.gdl', - 'geo' => 'application/vnd.dynageo', - 'gex' => 'application/vnd.geometry-explorer', - 'ggb' => 'application/vnd.geogebra.file', - 'ggt' => 'application/vnd.geogebra.tool', - 'ghf' => 'application/vnd.groove-help', - 'gif' => 'image/gif', - 'gim' => 'application/vnd.groove-identity-message', - 'gml' => 'application/gml+xml', - 'gmx' => 'application/vnd.gmx', - 'gnumeric' => 'application/x-gnumeric', - 'gph' => 'application/vnd.flographit', - 'gpx' => 'application/gpx+xml', - 'gqf' => 'application/vnd.grafeq', - 'gqs' => 'application/vnd.grafeq', - 'gram' => 'application/srgs', - 'gramps' => 'application/x-gramps-xml', - 'gre' => 'application/vnd.geometry-explorer', - 'grv' => 'application/vnd.groove-injector', - 'grxml' => 'application/srgs+xml', - 'gsf' => 'application/x-font-ghostscript', - 'gtar' => 'application/x-gtar', - 'gtm' => 'application/vnd.groove-tool-message', - 'gtw' => 'model/vnd.gtw', - 'gv' => 'text/vnd.graphviz', - 'gxf' => 'application/gxf', - 'gxt' => 'application/vnd.geonext', - 'gz' => 'application/x-gzip', - 'h' => 'text/x-c', - 'h261' => 'video/h261', - 'h263' => 'video/h263', - 'h264' => 'video/h264', - 'hal' => 'application/vnd.hal+xml', - 'hbci' => 'application/vnd.hbci', - 'hdf' => 'application/x-hdf', - 'hh' => 'text/x-c', - 'hlp' => 'application/winhlp', - 'hpgl' => 'application/vnd.hp-hpgl', - 'hpid' => 'application/vnd.hp-hpid', - 'hps' => 'application/vnd.hp-hps', - 'hqx' => 'application/mac-binhex40', - 'htke' => 'application/vnd.kenameaapp', - 'htm' => 'text/html', - 'html' => 'text/html', - 'hvd' => 'application/vnd.yamaha.hv-dic', - 'hvp' => 'application/vnd.yamaha.hv-voice', - 'hvs' => 'application/vnd.yamaha.hv-script', - 'i2g' => 'application/vnd.intergeo', - 'icc' => 'application/vnd.iccprofile', - 'ice' => 'x-conference/x-cooltalk', - 'icm' => 'application/vnd.iccprofile', - 'ico' => 'image/x-icon', - 'ics' => 'text/calendar', - 'ief' => 'image/ief', - 'ifb' => 'text/calendar', - 'ifm' => 'application/vnd.shana.informed.formdata', - 'iges' => 'model/iges', - 'igl' => 'application/vnd.igloader', - 'igm' => 'application/vnd.insors.igm', - 'igs' => 'model/iges', - 'igx' => 'application/vnd.micrografx.igx', - 'iif' => 'application/vnd.shana.informed.interchange', - 'imp' => 'application/vnd.accpac.simply.imp', - 'ims' => 'application/vnd.ms-ims', - 'in' => 'text/plain', - 'ink' => 'application/inkml+xml', - 'inkml' => 'application/inkml+xml', - 'install' => 'application/x-install-instructions', - 'iota' => 'application/vnd.astraea-software.iota', - 'ipfix' => 'application/ipfix', - 'ipk' => 'application/vnd.shana.informed.package', - 'irm' => 'application/vnd.ibm.rights-management', - 'irp' => 'application/vnd.irepository.package+xml', - 'iso' => 'application/x-iso9660-image', - 'itp' => 'application/vnd.shana.informed.formtemplate', - 'ivp' => 'application/vnd.immervision-ivp', - 'ivu' => 'application/vnd.immervision-ivu', - 'jad' => 'text/vnd.sun.j2me.app-descriptor', - 'jam' => 'application/vnd.jam', - 'jar' => 'application/java-archive', - 'java' => 'text/x-java-source', - 'jisp' => 'application/vnd.jisp', - 'jlt' => 'application/vnd.hp-jlyt', - 'jnlp' => 'application/x-java-jnlp-file', - 'joda' => 'application/vnd.joost.joda-archive', - 'jpe' => 'image/jpeg', - 'jpeg' => 'image/jpeg', - 'jpg' => 'image/jpeg', - 'jpgm' => 'video/jpm', - 'jpgv' => 'video/jpeg', - 'jpm' => 'video/jpm', - 'js' => 'application/javascript', - 'json' => 'application/json', - 'jsonml' => 'application/jsonml+json', - 'kar' => 'audio/midi', - 'karbon' => 'application/vnd.kde.karbon', - 'kfo' => 'application/vnd.kde.kformula', - 'kia' => 'application/vnd.kidspiration', - 'kml' => 'application/vnd.google-earth.kml+xml', - 'kmz' => 'application/vnd.google-earth.kmz', - 'kne' => 'application/vnd.kinar', - 'knp' => 'application/vnd.kinar', - 'kon' => 'application/vnd.kde.kontour', - 'kpr' => 'application/vnd.kde.kpresenter', - 'kpt' => 'application/vnd.kde.kpresenter', - 'kpxx' => 'application/vnd.ds-keypoint', - 'ksp' => 'application/vnd.kde.kspread', - 'ktr' => 'application/vnd.kahootz', - 'ktx' => 'image/ktx', - 'ktz' => 'application/vnd.kahootz', - 'kwd' => 'application/vnd.kde.kword', - 'kwt' => 'application/vnd.kde.kword', - 'lasxml' => 'application/vnd.las.las+xml', - 'latex' => 'application/x-latex', - 'lbd' => 'application/vnd.llamagraphics.life-balance.desktop', - 'lbe' => 'application/vnd.llamagraphics.life-balance.exchange+xml', - 'les' => 'application/vnd.hhe.lesson-player', - 'lha' => 'application/x-lzh-compressed', - 'link66' => 'application/vnd.route66.link66+xml', - 'list' => 'text/plain', - 'list3820' => 'application/vnd.ibm.modcap', - 'listafp' => 'application/vnd.ibm.modcap', - 'lnk' => 'application/x-ms-shortcut', - 'log' => 'text/plain', - 'lostxml' => 'application/lost+xml', - 'lrf' => 'application/octet-stream', - 'lrm' => 'application/vnd.ms-lrm', - 'ltf' => 'application/vnd.frogans.ltf', - 'lvp' => 'audio/vnd.lucent.voice', - 'lwp' => 'application/vnd.lotus-wordpro', - 'lzh' => 'application/x-lzh-compressed', - 'm13' => 'application/x-msmediaview', - 'm14' => 'application/x-msmediaview', - 'm1v' => 'video/mpeg', - 'm21' => 'application/mp21', - 'm2a' => 'audio/mpeg', - 'm2v' => 'video/mpeg', - 'm3a' => 'audio/mpeg', - 'm3u' => 'audio/x-mpegurl', - 'm3u8' => 'application/vnd.apple.mpegurl', - 'm4a' => 'audio/mp4', - 'm4u' => 'video/vnd.mpegurl', - 'm4v' => 'video/x-m4v', - 'ma' => 'application/mathematica', - 'mads' => 'application/mads+xml', - 'mag' => 'application/vnd.ecowin.chart', - 'maker' => 'application/vnd.framemaker', - 'man' => 'text/troff', - 'mar' => 'application/octet-stream', - 'mathml' => 'application/mathml+xml', - 'mb' => 'application/mathematica', - 'mbk' => 'application/vnd.mobius.mbk', - 'mbox' => 'application/mbox', - 'mc1' => 'application/vnd.medcalcdata', - 'mcd' => 'application/vnd.mcd', - 'mcurl' => 'text/vnd.curl.mcurl', - 'mdb' => 'application/x-msaccess', - 'mdi' => 'image/vnd.ms-modi', - 'me' => 'text/troff', - 'mesh' => 'model/mesh', - 'meta4' => 'application/metalink4+xml', - 'metalink' => 'application/metalink+xml', - 'mets' => 'application/mets+xml', - 'mfm' => 'application/vnd.mfmp', - 'mft' => 'application/rpki-manifest', - 'mgp' => 'application/vnd.osgeo.mapguide.package', - 'mgz' => 'application/vnd.proteus.magazine', - 'mid' => 'audio/midi', - 'midi' => 'audio/midi', - 'mie' => 'application/x-mie', - 'mif' => 'application/vnd.mif', - 'mime' => 'message/rfc822', - 'mj2' => 'video/mj2', - 'mjp2' => 'video/mj2', - 'mk3d' => 'video/x-matroska', - 'mka' => 'audio/x-matroska', - 'mks' => 'video/x-matroska', - 'mkv' => 'video/x-matroska', - 'mlp' => 'application/vnd.dolby.mlp', - 'mmd' => 'application/vnd.chipnuts.karaoke-mmd', - 'mmf' => 'application/vnd.smaf', - 'mmr' => 'image/vnd.fujixerox.edmics-mmr', - 'mng' => 'video/x-mng', - 'mny' => 'application/x-msmoney', - 'mobi' => 'application/x-mobipocket-ebook', - 'mods' => 'application/mods+xml', - 'mov' => 'video/quicktime', - 'movie' => 'video/x-sgi-movie', - 'mp2' => 'audio/mpeg', - 'mp21' => 'application/mp21', - 'mp2a' => 'audio/mpeg', - 'mp3' => 'audio/mpeg', - 'mp4' => 'video/mp4', - 'mp4a' => 'audio/mp4', - 'mp4s' => 'application/mp4', - 'mp4v' => 'video/mp4', - 'mpc' => 'application/vnd.mophun.certificate', - 'mpe' => 'video/mpeg', - 'mpeg' => 'video/mpeg', - 'mpg' => 'video/mpeg', - 'mpg4' => 'video/mp4', - 'mpga' => 'audio/mpeg', - 'mpkg' => 'application/vnd.apple.installer+xml', - 'mpm' => 'application/vnd.blueice.multipass', - 'mpn' => 'application/vnd.mophun.application', - 'mpp' => 'application/vnd.ms-project', - 'mpt' => 'application/vnd.ms-project', - 'mpy' => 'application/vnd.ibm.minipay', - 'mqy' => 'application/vnd.mobius.mqy', - 'mrc' => 'application/marc', - 'mrcx' => 'application/marcxml+xml', - 'ms' => 'text/troff', - 'mscml' => 'application/mediaservercontrol+xml', - 'mseed' => 'application/vnd.fdsn.mseed', - 'mseq' => 'application/vnd.mseq', - 'msf' => 'application/vnd.epson.msf', - 'msh' => 'model/mesh', - 'msi' => 'application/x-msdownload', - 'msl' => 'application/vnd.mobius.msl', - 'msty' => 'application/vnd.muvee.style', - 'mts' => 'model/vnd.mts', - 'mus' => 'application/vnd.musician', - 'musicxml' => 'application/vnd.recordare.musicxml+xml', - 'mvb' => 'application/x-msmediaview', - 'mwf' => 'application/vnd.mfer', - 'mxf' => 'application/mxf', - 'mxl' => 'application/vnd.recordare.musicxml', - 'mxml' => 'application/xv+xml', - 'mxs' => 'application/vnd.triscape.mxs', - 'mxu' => 'video/vnd.mpegurl', - 'n-gage' => 'application/vnd.nokia.n-gage.symbian.install', - 'n3' => 'text/n3', - 'nb' => 'application/mathematica', - 'nbp' => 'application/vnd.wolfram.player', - 'nc' => 'application/x-netcdf', - 'ncx' => 'application/x-dtbncx+xml', - 'nfo' => 'text/x-nfo', - 'ngdat' => 'application/vnd.nokia.n-gage.data', - 'nitf' => 'application/vnd.nitf', - 'nlu' => 'application/vnd.neurolanguage.nlu', - 'nml' => 'application/vnd.enliven', - 'nnd' => 'application/vnd.noblenet-directory', - 'nns' => 'application/vnd.noblenet-sealer', - 'nnw' => 'application/vnd.noblenet-web', - 'npx' => 'image/vnd.net-fpx', - 'nsc' => 'application/x-conference', - 'nsf' => 'application/vnd.lotus-notes', - 'ntf' => 'application/vnd.nitf', - 'nzb' => 'application/x-nzb', - 'oa2' => 'application/vnd.fujitsu.oasys2', - 'oa3' => 'application/vnd.fujitsu.oasys3', - 'oas' => 'application/vnd.fujitsu.oasys', - 'obd' => 'application/x-msbinder', - 'obj' => 'application/x-tgif', - 'oda' => 'application/oda', - 'odb' => 'application/vnd.oasis.opendocument.database', - 'odc' => 'application/vnd.oasis.opendocument.chart', - 'odf' => 'application/vnd.oasis.opendocument.formula', - 'odft' => 'application/vnd.oasis.opendocument.formula-template', - 'odg' => 'application/vnd.oasis.opendocument.graphics', - 'odi' => 'application/vnd.oasis.opendocument.image', - 'odm' => 'application/vnd.oasis.opendocument.text-master', - 'odp' => 'application/vnd.oasis.opendocument.presentation', - 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', - 'odt' => 'application/vnd.oasis.opendocument.text', - 'oga' => 'audio/ogg', - 'ogg' => 'audio/ogg', - 'ogv' => 'video/ogg', - 'ogx' => 'application/ogg', - 'omdoc' => 'application/omdoc+xml', - 'onepkg' => 'application/onenote', - 'onetmp' => 'application/onenote', - 'onetoc' => 'application/onenote', - 'onetoc2' => 'application/onenote', - 'opf' => 'application/oebps-package+xml', - 'opml' => 'text/x-opml', - 'oprc' => 'application/vnd.palm', - 'org' => 'application/vnd.lotus-organizer', - 'osf' => 'application/vnd.yamaha.openscoreformat', - 'osfpvg' => 'application/vnd.yamaha.openscoreformat.osfpvg+xml', - 'otc' => 'application/vnd.oasis.opendocument.chart-template', - 'otf' => 'application/x-font-otf', - 'otg' => 'application/vnd.oasis.opendocument.graphics-template', - 'oth' => 'application/vnd.oasis.opendocument.text-web', - 'oti' => 'application/vnd.oasis.opendocument.image-template', - 'otp' => 'application/vnd.oasis.opendocument.presentation-template', - 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template', - 'ott' => 'application/vnd.oasis.opendocument.text-template', - 'oxps' => 'application/oxps', - 'oxt' => 'application/vnd.openofficeorg.extension', - 'p' => 'text/x-pascal', - 'p10' => 'application/pkcs10', - 'p12' => 'application/x-pkcs12', - 'p7b' => 'application/x-pkcs7-certificates', - 'p7c' => 'application/pkcs7-mime', - 'p7m' => 'application/pkcs7-mime', - 'p7r' => 'application/x-pkcs7-certreqresp', - 'p7s' => 'application/pkcs7-signature', - 'p8' => 'application/pkcs8', - 'pas' => 'text/x-pascal', - 'paw' => 'application/vnd.pawaafile', - 'pbd' => 'application/vnd.powerbuilder6', - 'pbm' => 'image/x-portable-bitmap', - 'pcap' => 'application/vnd.tcpdump.pcap', - 'pcf' => 'application/x-font-pcf', - 'pcl' => 'application/vnd.hp-pcl', - 'pclxl' => 'application/vnd.hp-pclxl', - 'pct' => 'image/x-pict', - 'pcurl' => 'application/vnd.curl.pcurl', - 'pcx' => 'image/x-pcx', - 'pdb' => 'application/vnd.palm', - 'pdf' => 'application/pdf', - 'pfa' => 'application/x-font-type1', - 'pfb' => 'application/x-font-type1', - 'pfm' => 'application/x-font-type1', - 'pfr' => 'application/font-tdpfr', - 'pfx' => 'application/x-pkcs12', - 'pgm' => 'image/x-portable-graymap', - 'pgn' => 'application/x-chess-pgn', - 'pgp' => 'application/pgp-encrypted', - 'php' => 'application/x-php', - 'php3' => 'application/x-php', - 'php4' => 'application/x-php', - 'php5' => 'application/x-php', - 'pic' => 'image/x-pict', - 'pkg' => 'application/octet-stream', - 'pki' => 'application/pkixcmp', - 'pkipath' => 'application/pkix-pkipath', - 'plb' => 'application/vnd.3gpp.pic-bw-large', - 'plc' => 'application/vnd.mobius.plc', - 'plf' => 'application/vnd.pocketlearn', - 'pls' => 'application/pls+xml', - 'pml' => 'application/vnd.ctc-posml', - 'png' => 'image/png', - 'pnm' => 'image/x-portable-anymap', - 'portpkg' => 'application/vnd.macports.portpkg', - 'pot' => 'application/vnd.ms-powerpoint', - 'potm' => 'application/vnd.ms-powerpoint.template.macroenabled.12', - 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template', - 'ppam' => 'application/vnd.ms-powerpoint.addin.macroenabled.12', - 'ppd' => 'application/vnd.cups-ppd', - 'ppm' => 'image/x-portable-pixmap', - 'pps' => 'application/vnd.ms-powerpoint', - 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroenabled.12', - 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', - 'ppt' => 'application/vnd.ms-powerpoint', - 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroenabled.12', - 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', - 'pqa' => 'application/vnd.palm', - 'prc' => 'application/x-mobipocket-ebook', - 'pre' => 'application/vnd.lotus-freelance', - 'prf' => 'application/pics-rules', - 'ps' => 'application/postscript', - 'psb' => 'application/vnd.3gpp.pic-bw-small', - 'psd' => 'image/vnd.adobe.photoshop', - 'psf' => 'application/x-font-linux-psf', - 'pskcxml' => 'application/pskc+xml', - 'ptid' => 'application/vnd.pvi.ptid1', - 'pub' => 'application/x-mspublisher', - 'pvb' => 'application/vnd.3gpp.pic-bw-var', - 'pwn' => 'application/vnd.3m.post-it-notes', - 'pya' => 'audio/vnd.ms-playready.media.pya', - 'pyv' => 'video/vnd.ms-playready.media.pyv', - 'qam' => 'application/vnd.epson.quickanime', - 'qbo' => 'application/vnd.intu.qbo', - 'qfx' => 'application/vnd.intu.qfx', - 'qps' => 'application/vnd.publishare-delta-tree', - 'qt' => 'video/quicktime', - 'qwd' => 'application/vnd.quark.quarkxpress', - 'qwt' => 'application/vnd.quark.quarkxpress', - 'qxb' => 'application/vnd.quark.quarkxpress', - 'qxd' => 'application/vnd.quark.quarkxpress', - 'qxl' => 'application/vnd.quark.quarkxpress', - 'qxt' => 'application/vnd.quark.quarkxpress', - 'ra' => 'audio/x-pn-realaudio', - 'ram' => 'audio/x-pn-realaudio', - 'rar' => 'application/x-rar-compressed', - 'ras' => 'image/x-cmu-raster', - 'rcprofile' => 'application/vnd.ipunplugged.rcprofile', - 'rdf' => 'application/rdf+xml', - 'rdz' => 'application/vnd.data-vision.rdz', - 'rep' => 'application/vnd.businessobjects', - 'res' => 'application/x-dtbresource+xml', - 'rgb' => 'image/x-rgb', - 'rif' => 'application/reginfo+xml', - 'rip' => 'audio/vnd.rip', - 'ris' => 'application/x-research-info-systems', - 'rl' => 'application/resource-lists+xml', - 'rlc' => 'image/vnd.fujixerox.edmics-rlc', - 'rld' => 'application/resource-lists-diff+xml', - 'rm' => 'application/vnd.rn-realmedia', - 'rmi' => 'audio/midi', - 'rmp' => 'audio/x-pn-realaudio-plugin', - 'rms' => 'application/vnd.jcp.javame.midlet-rms', - 'rmvb' => 'application/vnd.rn-realmedia-vbr', - 'rnc' => 'application/relax-ng-compact-syntax', - 'roa' => 'application/rpki-roa', - 'roff' => 'text/troff', - 'rp9' => 'application/vnd.cloanto.rp9', - 'rpss' => 'application/vnd.nokia.radio-presets', - 'rpst' => 'application/vnd.nokia.radio-preset', - 'rq' => 'application/sparql-query', - 'rs' => 'application/rls-services+xml', - 'rsd' => 'application/rsd+xml', - 'rss' => 'application/rss+xml', - 'rtf' => 'application/rtf', - 'rtx' => 'text/richtext', - 's' => 'text/x-asm', - 's3m' => 'audio/s3m', - 'saf' => 'application/vnd.yamaha.smaf-audio', - 'sbml' => 'application/sbml+xml', - 'sc' => 'application/vnd.ibm.secure-container', - 'scd' => 'application/x-msschedule', - 'scm' => 'application/vnd.lotus-screencam', - 'scq' => 'application/scvp-cv-request', - 'scs' => 'application/scvp-cv-response', - 'scurl' => 'text/vnd.curl.scurl', - 'sda' => 'application/vnd.stardivision.draw', - 'sdc' => 'application/vnd.stardivision.calc', - 'sdd' => 'application/vnd.stardivision.impress', - 'sdkd' => 'application/vnd.solent.sdkm+xml', - 'sdkm' => 'application/vnd.solent.sdkm+xml', - 'sdp' => 'application/sdp', - 'sdw' => 'application/vnd.stardivision.writer', - 'see' => 'application/vnd.seemail', - 'seed' => 'application/vnd.fdsn.seed', - 'sema' => 'application/vnd.sema', - 'semd' => 'application/vnd.semd', - 'semf' => 'application/vnd.semf', - 'ser' => 'application/java-serialized-object', - 'setpay' => 'application/set-payment-initiation', - 'setreg' => 'application/set-registration-initiation', - 'sfd-hdstx' => 'application/vnd.hydrostatix.sof-data', - 'sfs' => 'application/vnd.spotfire.sfs', - 'sfv' => 'text/x-sfv', - 'sgi' => 'image/sgi', - 'sgl' => 'application/vnd.stardivision.writer-global', - 'sgm' => 'text/sgml', - 'sgml' => 'text/sgml', - 'sh' => 'application/x-sh', - 'shar' => 'application/x-shar', - 'shf' => 'application/shf+xml', - 'sid' => 'image/x-mrsid-image', - 'sig' => 'application/pgp-signature', - 'sil' => 'audio/silk', - 'silo' => 'model/mesh', - 'sis' => 'application/vnd.symbian.install', - 'sisx' => 'application/vnd.symbian.install', - 'sit' => 'application/x-stuffit', - 'sitx' => 'application/x-stuffitx', - 'skd' => 'application/vnd.koan', - 'skm' => 'application/vnd.koan', - 'skp' => 'application/vnd.koan', - 'skt' => 'application/vnd.koan', - 'sldm' => 'application/vnd.ms-powerpoint.slide.macroenabled.12', - 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide', - 'slt' => 'application/vnd.epson.salt', - 'sm' => 'application/vnd.stepmania.stepchart', - 'smf' => 'application/vnd.stardivision.math', - 'smi' => 'application/smil+xml', - 'smil' => 'application/smil+xml', - 'smv' => 'video/x-smv', - 'smzip' => 'application/vnd.stepmania.package', - 'snd' => 'audio/basic', - 'snf' => 'application/x-font-snf', - 'so' => 'application/octet-stream', - 'spc' => 'application/x-pkcs7-certificates', - 'spf' => 'application/vnd.yamaha.smaf-phrase', - 'spl' => 'application/x-futuresplash', - 'spot' => 'text/vnd.in3d.spot', - 'spp' => 'application/scvp-vp-response', - 'spq' => 'application/scvp-vp-request', - 'spx' => 'audio/ogg', - 'sql' => 'application/x-sql', - 'src' => 'application/x-wais-source', - 'srt' => 'application/x-subrip', - 'sru' => 'application/sru+xml', - 'srx' => 'application/sparql-results+xml', - 'ssdl' => 'application/ssdl+xml', - 'sse' => 'application/vnd.kodak-descriptor', - 'ssf' => 'application/vnd.epson.ssf', - 'ssml' => 'application/ssml+xml', - 'st' => 'application/vnd.sailingtracker.track', - 'stc' => 'application/vnd.sun.xml.calc.template', - 'std' => 'application/vnd.sun.xml.draw.template', - 'stf' => 'application/vnd.wt.stf', - 'sti' => 'application/vnd.sun.xml.impress.template', - 'stk' => 'application/hyperstudio', - 'stl' => 'application/vnd.ms-pki.stl', - 'str' => 'application/vnd.pg.format', - 'stw' => 'application/vnd.sun.xml.writer.template', - 'sub' => 'text/vnd.dvb.subtitle', - 'sus' => 'application/vnd.sus-calendar', - 'susp' => 'application/vnd.sus-calendar', - 'sv4cpio' => 'application/x-sv4cpio', - 'sv4crc' => 'application/x-sv4crc', - 'svc' => 'application/vnd.dvb.service', - 'svd' => 'application/vnd.svd', - 'svg' => 'image/svg+xml', - 'svgz' => 'image/svg+xml', - 'swa' => 'application/x-director', - 'swf' => 'application/x-shockwave-flash', - 'swi' => 'application/vnd.aristanetworks.swi', - 'sxc' => 'application/vnd.sun.xml.calc', - 'sxd' => 'application/vnd.sun.xml.draw', - 'sxg' => 'application/vnd.sun.xml.writer.global', - 'sxi' => 'application/vnd.sun.xml.impress', - 'sxm' => 'application/vnd.sun.xml.math', - 'sxw' => 'application/vnd.sun.xml.writer', - 't' => 'text/troff', - 't3' => 'application/x-t3vm-image', - 'taglet' => 'application/vnd.mynfc', - 'tao' => 'application/vnd.tao.intent-module-archive', - 'tar' => 'application/x-tar', - 'tcap' => 'application/vnd.3gpp2.tcap', - 'tcl' => 'application/x-tcl', - 'teacher' => 'application/vnd.smart.teacher', - 'tei' => 'application/tei+xml', - 'teicorpus' => 'application/tei+xml', - 'tex' => 'application/x-tex', - 'texi' => 'application/x-texinfo', - 'texinfo' => 'application/x-texinfo', - 'text' => 'text/plain', - 'tfi' => 'application/thraud+xml', - 'tfm' => 'application/x-tex-tfm', - 'tga' => 'image/x-tga', - 'thmx' => 'application/vnd.ms-officetheme', - 'tif' => 'image/tiff', - 'tiff' => 'image/tiff', - 'tmo' => 'application/vnd.tmobile-livetv', - 'torrent' => 'application/x-bittorrent', - 'tpl' => 'application/vnd.groove-tool-template', - 'tpt' => 'application/vnd.trid.tpt', - 'tr' => 'text/troff', - 'tra' => 'application/vnd.trueapp', - 'trm' => 'application/x-msterminal', - 'tsd' => 'application/timestamped-data', - 'tsv' => 'text/tab-separated-values', - 'ttc' => 'application/x-font-ttf', - 'ttf' => 'application/x-font-ttf', - 'ttl' => 'text/turtle', - 'twd' => 'application/vnd.simtech-mindmapper', - 'twds' => 'application/vnd.simtech-mindmapper', - 'txd' => 'application/vnd.genomatix.tuxedo', - 'txf' => 'application/vnd.mobius.txf', - 'txt' => 'text/plain', - 'u32' => 'application/x-authorware-bin', - 'udeb' => 'application/x-debian-package', - 'ufd' => 'application/vnd.ufdl', - 'ufdl' => 'application/vnd.ufdl', - 'ulx' => 'application/x-glulx', - 'umj' => 'application/vnd.umajin', - 'unityweb' => 'application/vnd.unity', - 'uoml' => 'application/vnd.uoml+xml', - 'uri' => 'text/uri-list', - 'uris' => 'text/uri-list', - 'urls' => 'text/uri-list', - 'ustar' => 'application/x-ustar', - 'utz' => 'application/vnd.uiq.theme', - 'uu' => 'text/x-uuencode', - 'uva' => 'audio/vnd.dece.audio', - 'uvd' => 'application/vnd.dece.data', - 'uvf' => 'application/vnd.dece.data', - 'uvg' => 'image/vnd.dece.graphic', - 'uvh' => 'video/vnd.dece.hd', - 'uvi' => 'image/vnd.dece.graphic', - 'uvm' => 'video/vnd.dece.mobile', - 'uvp' => 'video/vnd.dece.pd', - 'uvs' => 'video/vnd.dece.sd', - 'uvt' => 'application/vnd.dece.ttml+xml', - 'uvu' => 'video/vnd.uvvu.mp4', - 'uvv' => 'video/vnd.dece.video', - 'uvva' => 'audio/vnd.dece.audio', - 'uvvd' => 'application/vnd.dece.data', - 'uvvf' => 'application/vnd.dece.data', - 'uvvg' => 'image/vnd.dece.graphic', - 'uvvh' => 'video/vnd.dece.hd', - 'uvvi' => 'image/vnd.dece.graphic', - 'uvvm' => 'video/vnd.dece.mobile', - 'uvvp' => 'video/vnd.dece.pd', - 'uvvs' => 'video/vnd.dece.sd', - 'uvvt' => 'application/vnd.dece.ttml+xml', - 'uvvu' => 'video/vnd.uvvu.mp4', - 'uvvv' => 'video/vnd.dece.video', - 'uvvx' => 'application/vnd.dece.unspecified', - 'uvvz' => 'application/vnd.dece.zip', - 'uvx' => 'application/vnd.dece.unspecified', - 'uvz' => 'application/vnd.dece.zip', - 'vcard' => 'text/vcard', - 'vcd' => 'application/x-cdlink', - 'vcf' => 'text/x-vcard', - 'vcg' => 'application/vnd.groove-vcard', - 'vcs' => 'text/x-vcalendar', - 'vcx' => 'application/vnd.vcx', - 'vis' => 'application/vnd.visionary', - 'viv' => 'video/vnd.vivo', - 'vob' => 'video/x-ms-vob', - 'vor' => 'application/vnd.stardivision.writer', - 'vox' => 'application/x-authorware-bin', - 'vrml' => 'model/vrml', - 'vsd' => 'application/vnd.visio', - 'vsf' => 'application/vnd.vsf', - 'vss' => 'application/vnd.visio', - 'vst' => 'application/vnd.visio', - 'vsw' => 'application/vnd.visio', - 'vtu' => 'model/vnd.vtu', - 'vxml' => 'application/voicexml+xml', - 'w3d' => 'application/x-director', - 'wad' => 'application/x-doom', - 'wav' => 'audio/x-wav', - 'wax' => 'audio/x-ms-wax', - 'wbmp' => 'image/vnd.wap.wbmp', - 'wbs' => 'application/vnd.criticaltools.wbs+xml', - 'wbxml' => 'application/vnd.wap.wbxml', - 'wcm' => 'application/vnd.ms-works', - 'wdb' => 'application/vnd.ms-works', - 'wdp' => 'image/vnd.ms-photo', - 'weba' => 'audio/webm', - 'webm' => 'video/webm', - 'webp' => 'image/webp', - 'wg' => 'application/vnd.pmi.widget', - 'wgt' => 'application/widget', - 'wks' => 'application/vnd.ms-works', - 'wm' => 'video/x-ms-wm', - 'wma' => 'audio/x-ms-wma', - 'wmd' => 'application/x-ms-wmd', - 'wmf' => 'application/x-msmetafile', - 'wml' => 'text/vnd.wap.wml', - 'wmlc' => 'application/vnd.wap.wmlc', - 'wmls' => 'text/vnd.wap.wmlscript', - 'wmlsc' => 'application/vnd.wap.wmlscriptc', - 'wmv' => 'video/x-ms-wmv', - 'wmx' => 'video/x-ms-wmx', - 'wmz' => 'application/x-msmetafile', - 'woff' => 'application/font-woff', - 'wpd' => 'application/vnd.wordperfect', - 'wpl' => 'application/vnd.ms-wpl', - 'wps' => 'application/vnd.ms-works', - 'wqd' => 'application/vnd.wqd', - 'wri' => 'application/x-mswrite', - 'wrl' => 'model/vrml', - 'wsdl' => 'application/wsdl+xml', - 'wspolicy' => 'application/wspolicy+xml', - 'wtb' => 'application/vnd.webturbo', - 'wvx' => 'video/x-ms-wvx', - 'x32' => 'application/x-authorware-bin', - 'x3d' => 'model/x3d+xml', - 'x3db' => 'model/x3d+binary', - 'x3dbz' => 'model/x3d+binary', - 'x3dv' => 'model/x3d+vrml', - 'x3dvz' => 'model/x3d+vrml', - 'x3dz' => 'model/x3d+xml', - 'xaml' => 'application/xaml+xml', - 'xap' => 'application/x-silverlight-app', - 'xar' => 'application/vnd.xara', - 'xbap' => 'application/x-ms-xbap', - 'xbd' => 'application/vnd.fujixerox.docuworks.binder', - 'xbm' => 'image/x-xbitmap', - 'xdf' => 'application/xcap-diff+xml', - 'xdm' => 'application/vnd.syncml.dm+xml', - 'xdp' => 'application/vnd.adobe.xdp+xml', - 'xdssc' => 'application/dssc+xml', - 'xdw' => 'application/vnd.fujixerox.docuworks', - 'xenc' => 'application/xenc+xml', - 'xer' => 'application/patch-ops-error+xml', - 'xfdf' => 'application/vnd.adobe.xfdf', - 'xfdl' => 'application/vnd.xfdl', - 'xht' => 'application/xhtml+xml', - 'xhtml' => 'application/xhtml+xml', - 'xhvml' => 'application/xv+xml', - 'xif' => 'image/vnd.xiff', - 'xla' => 'application/vnd.ms-excel', - 'xlam' => 'application/vnd.ms-excel.addin.macroenabled.12', - 'xlc' => 'application/vnd.ms-excel', - 'xlf' => 'application/x-xliff+xml', - 'xlm' => 'application/vnd.ms-excel', - 'xls' => 'application/vnd.ms-excel', - 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroenabled.12', - 'xlsm' => 'application/vnd.ms-excel.sheet.macroenabled.12', - 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', - 'xlt' => 'application/vnd.ms-excel', - 'xltm' => 'application/vnd.ms-excel.template.macroenabled.12', - 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', - 'xlw' => 'application/vnd.ms-excel', - 'xm' => 'audio/xm', - 'xml' => 'application/xml', - 'xo' => 'application/vnd.olpc-sugar', - 'xop' => 'application/xop+xml', - 'xpi' => 'application/x-xpinstall', - 'xpl' => 'application/xproc+xml', - 'xpm' => 'image/x-xpixmap', - 'xpr' => 'application/vnd.is-xpr', - 'xps' => 'application/vnd.ms-xpsdocument', - 'xpw' => 'application/vnd.intercon.formnet', - 'xpx' => 'application/vnd.intercon.formnet', - 'xsl' => 'application/xml', - 'xslt' => 'application/xslt+xml', - 'xsm' => 'application/vnd.syncml+xml', - 'xspf' => 'application/xspf+xml', - 'xul' => 'application/vnd.mozilla.xul+xml', - 'xvm' => 'application/xv+xml', - 'xvml' => 'application/xv+xml', - 'xwd' => 'image/x-xwindowdump', - 'xyz' => 'chemical/x-xyz', - 'xz' => 'application/x-xz', - 'yang' => 'application/yang', - 'yin' => 'application/yin+xml', - 'z1' => 'application/x-zmachine', - 'z2' => 'application/x-zmachine', - 'z3' => 'application/x-zmachine', - 'z4' => 'application/x-zmachine', - 'z5' => 'application/x-zmachine', - 'z6' => 'application/x-zmachine', - 'z7' => 'application/x-zmachine', - 'z8' => 'application/x-zmachine', - 'zaz' => 'application/vnd.zzazz.deck+xml', - 'zip' => 'application/zip', - 'zir' => 'application/vnd.zul', - 'zirz' => 'application/vnd.zul', - 'zmm' => 'application/vnd.handheld-entertainment+xml', - '123' => 'application/vnd.lotus-1-2-3', + '3dml' => 'text/vnd.in3d.3dml', + '3ds' => 'image/x-3ds', + '3g2' => 'video/3gpp2', + '3gp' => 'video/3gpp', + '7z' => 'application/x-7z-compressed', + 'aab' => 'application/x-authorware-bin', + 'aac' => 'audio/x-aac', + 'aam' => 'application/x-authorware-map', + 'aas' => 'application/x-authorware-seg', + 'abw' => 'application/x-abiword', + 'ac' => 'application/pkix-attr-cert', + 'acc' => 'application/vnd.americandynamics.acc', + 'ace' => 'application/x-ace-compressed', + 'acu' => 'application/vnd.acucobol', + 'acutc' => 'application/vnd.acucorp', + 'adp' => 'audio/adpcm', + 'aep' => 'application/vnd.audiograph', + 'afm' => 'application/x-font-type1', + 'afp' => 'application/vnd.ibm.modcap', + 'ahead' => 'application/vnd.ahead.space', + 'ai' => 'application/postscript', + 'aif' => 'audio/x-aiff', + 'aifc' => 'audio/x-aiff', + 'aiff' => 'audio/x-aiff', + 'air' => 'application/vnd.adobe.air-application-installer-package+zip', + 'ait' => 'application/vnd.dvb.ait', + 'ami' => 'application/vnd.amiga.ami', + 'apk' => 'application/vnd.android.package-archive', + 'appcache' => 'text/cache-manifest', + 'apr' => 'application/vnd.lotus-approach', + 'aps' => 'application/postscript', + 'arc' => 'application/x-freearc', + 'asc' => 'application/pgp-signature', + 'asf' => 'video/x-ms-asf', + 'asm' => 'text/x-asm', + 'aso' => 'application/vnd.accpac.simply.aso', + 'asx' => 'video/x-ms-asf', + 'atc' => 'application/vnd.acucorp', + 'atom' => 'application/atom+xml', + 'atomcat' => 'application/atomcat+xml', + 'atomsvc' => 'application/atomsvc+xml', + 'atx' => 'application/vnd.antix.game-component', + 'au' => 'audio/basic', + 'avi' => 'video/x-msvideo', + 'aw' => 'application/applixware', + 'azf' => 'application/vnd.airzip.filesecure.azf', + 'azs' => 'application/vnd.airzip.filesecure.azs', + 'azw' => 'application/vnd.amazon.ebook', + 'bat' => 'application/x-msdownload', + 'bcpio' => 'application/x-bcpio', + 'bdf' => 'application/x-font-bdf', + 'bdm' => 'application/vnd.syncml.dm+wbxml', + 'bed' => 'application/vnd.realvnc.bed', + 'bh2' => 'application/vnd.fujitsu.oasysprs', + 'bin' => 'application/octet-stream', + 'blb' => 'application/x-blorb', + 'blorb' => 'application/x-blorb', + 'bmi' => 'application/vnd.bmi', + 'bmp' => 'image/bmp', + 'book' => 'application/vnd.framemaker', + 'box' => 'application/vnd.previewsystems.box', + 'boz' => 'application/x-bzip2', + 'bpk' => 'application/octet-stream', + 'btif' => 'image/prs.btif', + 'bz' => 'application/x-bzip', + 'bz2' => 'application/x-bzip2', + 'c' => 'text/x-c', + 'c11amc' => 'application/vnd.cluetrust.cartomobile-config', + 'c11amz' => 'application/vnd.cluetrust.cartomobile-config-pkg', + 'c4d' => 'application/vnd.clonk.c4group', + 'c4f' => 'application/vnd.clonk.c4group', + 'c4g' => 'application/vnd.clonk.c4group', + 'c4p' => 'application/vnd.clonk.c4group', + 'c4u' => 'application/vnd.clonk.c4group', + 'cab' => 'application/vnd.ms-cab-compressed', + 'caf' => 'audio/x-caf', + 'cap' => 'application/vnd.tcpdump.pcap', + 'car' => 'application/vnd.curl.car', + 'cat' => 'application/vnd.ms-pki.seccat', + 'cb7' => 'application/x-cbr', + 'cba' => 'application/x-cbr', + 'cbr' => 'application/x-cbr', + 'cbt' => 'application/x-cbr', + 'cbz' => 'application/x-cbr', + 'cc' => 'text/x-c', + 'cct' => 'application/x-director', + 'ccxml' => 'application/ccxml+xml', + 'cdbcmsg' => 'application/vnd.contact.cmsg', + 'cdf' => 'application/x-netcdf', + 'cdkey' => 'application/vnd.mediastation.cdkey', + 'cdmia' => 'application/cdmi-capability', + 'cdmic' => 'application/cdmi-container', + 'cdmid' => 'application/cdmi-domain', + 'cdmio' => 'application/cdmi-object', + 'cdmiq' => 'application/cdmi-queue', + 'cdx' => 'chemical/x-cdx', + 'cdxml' => 'application/vnd.chemdraw+xml', + 'cdy' => 'application/vnd.cinderella', + 'cer' => 'application/pkix-cert', + 'cfs' => 'application/x-cfs-compressed', + 'cgm' => 'image/cgm', + 'chat' => 'application/x-chat', + 'chm' => 'application/vnd.ms-htmlhelp', + 'chrt' => 'application/vnd.kde.kchart', + 'cif' => 'chemical/x-cif', + 'cii' => 'application/vnd.anser-web-certificate-issue-initiation', + 'cil' => 'application/vnd.ms-artgalry', + 'cla' => 'application/vnd.claymore', + 'class' => 'application/java-vm', + 'clkk' => 'application/vnd.crick.clicker.keyboard', + 'clkp' => 'application/vnd.crick.clicker.palette', + 'clkt' => 'application/vnd.crick.clicker.template', + 'clkw' => 'application/vnd.crick.clicker.wordbank', + 'clkx' => 'application/vnd.crick.clicker', + 'clp' => 'application/x-msclip', + 'cmc' => 'application/vnd.cosmocaller', + 'cmdf' => 'chemical/x-cmdf', + 'cml' => 'chemical/x-cml', + 'cmp' => 'application/vnd.yellowriver-custom-menu', + 'cmx' => 'image/x-cmx', + 'cod' => 'application/vnd.rim.cod', + 'com' => 'application/x-msdownload', + 'conf' => 'text/plain', + 'cpio' => 'application/x-cpio', + 'cpp' => 'text/x-c', + 'cpt' => 'application/mac-compactpro', + 'crd' => 'application/x-mscardfile', + 'crl' => 'application/pkix-crl', + 'crt' => 'application/x-x509-ca-cert', + 'csh' => 'application/x-csh', + 'csml' => 'chemical/x-csml', + 'csp' => 'application/vnd.commonspace', + 'css' => 'text/css', + 'cst' => 'application/x-director', + 'csv' => 'text/csv', + 'cu' => 'application/cu-seeme', + 'curl' => 'text/vnd.curl', + 'cww' => 'application/prs.cww', + 'cxt' => 'application/x-director', + 'cxx' => 'text/x-c', + 'dae' => 'model/vnd.collada+xml', + 'daf' => 'application/vnd.mobius.daf', + 'dart' => 'application/vnd.dart', + 'dataless' => 'application/vnd.fdsn.seed', + 'davmount' => 'application/davmount+xml', + 'dbk' => 'application/docbook+xml', + 'dcr' => 'application/x-director', + 'dcurl' => 'text/vnd.curl.dcurl', + 'dd2' => 'application/vnd.oma.dd2+xml', + 'ddd' => 'application/vnd.fujixerox.ddd', + 'deb' => 'application/x-debian-package', + 'def' => 'text/plain', + 'deploy' => 'application/octet-stream', + 'der' => 'application/x-x509-ca-cert', + 'dfac' => 'application/vnd.dreamfactory', + 'dgc' => 'application/x-dgc-compressed', + 'dic' => 'text/x-c', + 'dir' => 'application/x-director', + 'dis' => 'application/vnd.mobius.dis', + 'dist' => 'application/octet-stream', + 'distz' => 'application/octet-stream', + 'djv' => 'image/vnd.djvu', + 'djvu' => 'image/vnd.djvu', + 'dll' => 'application/x-msdownload', + 'dmg' => 'application/x-apple-diskimage', + 'dmp' => 'application/vnd.tcpdump.pcap', + 'dms' => 'application/octet-stream', + 'dna' => 'application/vnd.dna', + 'doc' => 'application/msword', + 'docm' => 'application/vnd.ms-word.document.macroenabled.12', + 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'dot' => 'application/msword', + 'dotm' => 'application/vnd.ms-word.template.macroenabled.12', + 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', + 'dp' => 'application/vnd.osgi.dp', + 'dpg' => 'application/vnd.dpgraph', + 'dra' => 'audio/vnd.dra', + 'dsc' => 'text/prs.lines.tag', + 'dssc' => 'application/dssc+der', + 'dtb' => 'application/x-dtbook+xml', + 'dtd' => 'application/xml-dtd', + 'dts' => 'audio/vnd.dts', + 'dtshd' => 'audio/vnd.dts.hd', + 'dump' => 'application/octet-stream', + 'dvb' => 'video/vnd.dvb.file', + 'dvi' => 'application/x-dvi', + 'dwf' => 'model/vnd.dwf', + 'dwg' => 'image/vnd.dwg', + 'dxf' => 'image/vnd.dxf', + 'dxp' => 'application/vnd.spotfire.dxp', + 'dxr' => 'application/x-director', + 'ecelp4800' => 'audio/vnd.nuera.ecelp4800', + 'ecelp7470' => 'audio/vnd.nuera.ecelp7470', + 'ecelp9600' => 'audio/vnd.nuera.ecelp9600', + 'ecma' => 'application/ecmascript', + 'edm' => 'application/vnd.novadigm.edm', + 'edx' => 'application/vnd.novadigm.edx', + 'efif' => 'application/vnd.picsel', + 'ei6' => 'application/vnd.pg.osasli', + 'elc' => 'application/octet-stream', + 'emf' => 'application/x-msmetafile', + 'eml' => 'message/rfc822', + 'emma' => 'application/emma+xml', + 'emz' => 'application/x-msmetafile', + 'eol' => 'audio/vnd.digital-winds', + 'eot' => 'application/vnd.ms-fontobject', + 'eps' => 'application/postscript', + 'epub' => 'application/epub+zip', + 'es3' => 'application/vnd.eszigno3+xml', + 'esa' => 'application/vnd.osgi.subsystem', + 'esf' => 'application/vnd.epson.esf', + 'et3' => 'application/vnd.eszigno3+xml', + 'etx' => 'text/x-setext', + 'eva' => 'application/x-eva', + 'evy' => 'application/x-envoy', + 'exe' => 'application/x-msdownload', + 'exi' => 'application/exi', + 'ext' => 'application/vnd.novadigm.ext', + 'ez' => 'application/andrew-inset', + 'ez2' => 'application/vnd.ezpix-album', + 'ez3' => 'application/vnd.ezpix-package', + 'f' => 'text/x-fortran', + 'f4v' => 'video/x-f4v', + 'f77' => 'text/x-fortran', + 'f90' => 'text/x-fortran', + 'fbs' => 'image/vnd.fastbidsheet', + 'fcdt' => 'application/vnd.adobe.formscentral.fcdt', + 'fcs' => 'application/vnd.isac.fcs', + 'fdf' => 'application/vnd.fdf', + 'fe_launch' => 'application/vnd.denovo.fcselayout-link', + 'fg5' => 'application/vnd.fujitsu.oasysgp', + 'fgd' => 'application/x-director', + 'fh' => 'image/x-freehand', + 'fh4' => 'image/x-freehand', + 'fh5' => 'image/x-freehand', + 'fh7' => 'image/x-freehand', + 'fhc' => 'image/x-freehand', + 'fig' => 'application/x-xfig', + 'flac' => 'audio/x-flac', + 'fli' => 'video/x-fli', + 'flo' => 'application/vnd.micrografx.flo', + 'flv' => 'video/x-flv', + 'flw' => 'application/vnd.kde.kivio', + 'flx' => 'text/vnd.fmi.flexstor', + 'fly' => 'text/vnd.fly', + 'fm' => 'application/vnd.framemaker', + 'fnc' => 'application/vnd.frogans.fnc', + 'for' => 'text/x-fortran', + 'fpx' => 'image/vnd.fpx', + 'frame' => 'application/vnd.framemaker', + 'fsc' => 'application/vnd.fsc.weblaunch', + 'fst' => 'image/vnd.fst', + 'ftc' => 'application/vnd.fluxtime.clip', + 'fti' => 'application/vnd.anser-web-funds-transfer-initiation', + 'fvt' => 'video/vnd.fvt', + 'fxp' => 'application/vnd.adobe.fxp', + 'fxpl' => 'application/vnd.adobe.fxp', + 'fzs' => 'application/vnd.fuzzysheet', + 'g2w' => 'application/vnd.geoplan', + 'g3' => 'image/g3fax', + 'g3w' => 'application/vnd.geospace', + 'gac' => 'application/vnd.groove-account', + 'gam' => 'application/x-tads', + 'gbr' => 'application/rpki-ghostbusters', + 'gca' => 'application/x-gca-compressed', + 'gdl' => 'model/vnd.gdl', + 'geo' => 'application/vnd.dynageo', + 'gex' => 'application/vnd.geometry-explorer', + 'ggb' => 'application/vnd.geogebra.file', + 'ggt' => 'application/vnd.geogebra.tool', + 'ghf' => 'application/vnd.groove-help', + 'gif' => 'image/gif', + 'gim' => 'application/vnd.groove-identity-message', + 'gml' => 'application/gml+xml', + 'gmx' => 'application/vnd.gmx', + 'gnumeric' => 'application/x-gnumeric', + 'gph' => 'application/vnd.flographit', + 'gpx' => 'application/gpx+xml', + 'gqf' => 'application/vnd.grafeq', + 'gqs' => 'application/vnd.grafeq', + 'gram' => 'application/srgs', + 'gramps' => 'application/x-gramps-xml', + 'gre' => 'application/vnd.geometry-explorer', + 'grv' => 'application/vnd.groove-injector', + 'grxml' => 'application/srgs+xml', + 'gsf' => 'application/x-font-ghostscript', + 'gtar' => 'application/x-gtar', + 'gtm' => 'application/vnd.groove-tool-message', + 'gtw' => 'model/vnd.gtw', + 'gv' => 'text/vnd.graphviz', + 'gxf' => 'application/gxf', + 'gxt' => 'application/vnd.geonext', + 'gz' => 'application/x-gzip', + 'h' => 'text/x-c', + 'h261' => 'video/h261', + 'h263' => 'video/h263', + 'h264' => 'video/h264', + 'hal' => 'application/vnd.hal+xml', + 'hbci' => 'application/vnd.hbci', + 'hdf' => 'application/x-hdf', + 'hh' => 'text/x-c', + 'hlp' => 'application/winhlp', + 'hpgl' => 'application/vnd.hp-hpgl', + 'hpid' => 'application/vnd.hp-hpid', + 'hps' => 'application/vnd.hp-hps', + 'hqx' => 'application/mac-binhex40', + 'htke' => 'application/vnd.kenameaapp', + 'htm' => 'text/html', + 'html' => 'text/html', + 'hvd' => 'application/vnd.yamaha.hv-dic', + 'hvp' => 'application/vnd.yamaha.hv-voice', + 'hvs' => 'application/vnd.yamaha.hv-script', + 'i2g' => 'application/vnd.intergeo', + 'icc' => 'application/vnd.iccprofile', + 'ice' => 'x-conference/x-cooltalk', + 'icm' => 'application/vnd.iccprofile', + 'ico' => 'image/x-icon', + 'ics' => 'text/calendar', + 'ief' => 'image/ief', + 'ifb' => 'text/calendar', + 'ifm' => 'application/vnd.shana.informed.formdata', + 'iges' => 'model/iges', + 'igl' => 'application/vnd.igloader', + 'igm' => 'application/vnd.insors.igm', + 'igs' => 'model/iges', + 'igx' => 'application/vnd.micrografx.igx', + 'iif' => 'application/vnd.shana.informed.interchange', + 'imp' => 'application/vnd.accpac.simply.imp', + 'ims' => 'application/vnd.ms-ims', + 'in' => 'text/plain', + 'ink' => 'application/inkml+xml', + 'inkml' => 'application/inkml+xml', + 'install' => 'application/x-install-instructions', + 'iota' => 'application/vnd.astraea-software.iota', + 'ipfix' => 'application/ipfix', + 'ipk' => 'application/vnd.shana.informed.package', + 'irm' => 'application/vnd.ibm.rights-management', + 'irp' => 'application/vnd.irepository.package+xml', + 'iso' => 'application/x-iso9660-image', + 'itp' => 'application/vnd.shana.informed.formtemplate', + 'ivp' => 'application/vnd.immervision-ivp', + 'ivu' => 'application/vnd.immervision-ivu', + 'jad' => 'text/vnd.sun.j2me.app-descriptor', + 'jam' => 'application/vnd.jam', + 'jar' => 'application/java-archive', + 'java' => 'text/x-java-source', + 'jisp' => 'application/vnd.jisp', + 'jlt' => 'application/vnd.hp-jlyt', + 'jnlp' => 'application/x-java-jnlp-file', + 'joda' => 'application/vnd.joost.joda-archive', + 'jpe' => 'image/jpeg', + 'jpeg' => 'image/jpeg', + 'jpg' => 'image/jpeg', + 'jpgm' => 'video/jpm', + 'jpgv' => 'video/jpeg', + 'jpm' => 'video/jpm', + 'js' => 'application/javascript', + 'json' => 'application/json', + 'jsonml' => 'application/jsonml+json', + 'kar' => 'audio/midi', + 'karbon' => 'application/vnd.kde.karbon', + 'kfo' => 'application/vnd.kde.kformula', + 'kia' => 'application/vnd.kidspiration', + 'kml' => 'application/vnd.google-earth.kml+xml', + 'kmz' => 'application/vnd.google-earth.kmz', + 'kne' => 'application/vnd.kinar', + 'knp' => 'application/vnd.kinar', + 'kon' => 'application/vnd.kde.kontour', + 'kpr' => 'application/vnd.kde.kpresenter', + 'kpt' => 'application/vnd.kde.kpresenter', + 'kpxx' => 'application/vnd.ds-keypoint', + 'ksp' => 'application/vnd.kde.kspread', + 'ktr' => 'application/vnd.kahootz', + 'ktx' => 'image/ktx', + 'ktz' => 'application/vnd.kahootz', + 'kwd' => 'application/vnd.kde.kword', + 'kwt' => 'application/vnd.kde.kword', + 'lasxml' => 'application/vnd.las.las+xml', + 'latex' => 'application/x-latex', + 'lbd' => 'application/vnd.llamagraphics.life-balance.desktop', + 'lbe' => 'application/vnd.llamagraphics.life-balance.exchange+xml', + 'les' => 'application/vnd.hhe.lesson-player', + 'lha' => 'application/x-lzh-compressed', + 'link66' => 'application/vnd.route66.link66+xml', + 'list' => 'text/plain', + 'list3820' => 'application/vnd.ibm.modcap', + 'listafp' => 'application/vnd.ibm.modcap', + 'lnk' => 'application/x-ms-shortcut', + 'log' => 'text/plain', + 'lostxml' => 'application/lost+xml', + 'lrf' => 'application/octet-stream', + 'lrm' => 'application/vnd.ms-lrm', + 'ltf' => 'application/vnd.frogans.ltf', + 'lvp' => 'audio/vnd.lucent.voice', + 'lwp' => 'application/vnd.lotus-wordpro', + 'lzh' => 'application/x-lzh-compressed', + 'm13' => 'application/x-msmediaview', + 'm14' => 'application/x-msmediaview', + 'm1v' => 'video/mpeg', + 'm21' => 'application/mp21', + 'm2a' => 'audio/mpeg', + 'm2v' => 'video/mpeg', + 'm3a' => 'audio/mpeg', + 'm3u' => 'audio/x-mpegurl', + 'm3u8' => 'application/vnd.apple.mpegurl', + 'm4a' => 'audio/mp4', + 'm4u' => 'video/vnd.mpegurl', + 'm4v' => 'video/x-m4v', + 'ma' => 'application/mathematica', + 'mads' => 'application/mads+xml', + 'mag' => 'application/vnd.ecowin.chart', + 'maker' => 'application/vnd.framemaker', + 'man' => 'text/troff', + 'mar' => 'application/octet-stream', + 'mathml' => 'application/mathml+xml', + 'mb' => 'application/mathematica', + 'mbk' => 'application/vnd.mobius.mbk', + 'mbox' => 'application/mbox', + 'mc1' => 'application/vnd.medcalcdata', + 'mcd' => 'application/vnd.mcd', + 'mcurl' => 'text/vnd.curl.mcurl', + 'mdb' => 'application/x-msaccess', + 'mdi' => 'image/vnd.ms-modi', + 'me' => 'text/troff', + 'mesh' => 'model/mesh', + 'meta4' => 'application/metalink4+xml', + 'metalink' => 'application/metalink+xml', + 'mets' => 'application/mets+xml', + 'mfm' => 'application/vnd.mfmp', + 'mft' => 'application/rpki-manifest', + 'mgp' => 'application/vnd.osgeo.mapguide.package', + 'mgz' => 'application/vnd.proteus.magazine', + 'mid' => 'audio/midi', + 'midi' => 'audio/midi', + 'mie' => 'application/x-mie', + 'mif' => 'application/vnd.mif', + 'mime' => 'message/rfc822', + 'mj2' => 'video/mj2', + 'mjp2' => 'video/mj2', + 'mk3d' => 'video/x-matroska', + 'mka' => 'audio/x-matroska', + 'mks' => 'video/x-matroska', + 'mkv' => 'video/x-matroska', + 'mlp' => 'application/vnd.dolby.mlp', + 'mmd' => 'application/vnd.chipnuts.karaoke-mmd', + 'mmf' => 'application/vnd.smaf', + 'mmr' => 'image/vnd.fujixerox.edmics-mmr', + 'mng' => 'video/x-mng', + 'mny' => 'application/x-msmoney', + 'mobi' => 'application/x-mobipocket-ebook', + 'mods' => 'application/mods+xml', + 'mov' => 'video/quicktime', + 'movie' => 'video/x-sgi-movie', + 'mp2' => 'audio/mpeg', + 'mp21' => 'application/mp21', + 'mp2a' => 'audio/mpeg', + 'mp3' => 'audio/mpeg', + 'mp4' => 'video/mp4', + 'mp4a' => 'audio/mp4', + 'mp4s' => 'application/mp4', + 'mp4v' => 'video/mp4', + 'mpc' => 'application/vnd.mophun.certificate', + 'mpe' => 'video/mpeg', + 'mpeg' => 'video/mpeg', + 'mpg' => 'video/mpeg', + 'mpg4' => 'video/mp4', + 'mpga' => 'audio/mpeg', + 'mpkg' => 'application/vnd.apple.installer+xml', + 'mpm' => 'application/vnd.blueice.multipass', + 'mpn' => 'application/vnd.mophun.application', + 'mpp' => 'application/vnd.ms-project', + 'mpt' => 'application/vnd.ms-project', + 'mpy' => 'application/vnd.ibm.minipay', + 'mqy' => 'application/vnd.mobius.mqy', + 'mrc' => 'application/marc', + 'mrcx' => 'application/marcxml+xml', + 'ms' => 'text/troff', + 'mscml' => 'application/mediaservercontrol+xml', + 'mseed' => 'application/vnd.fdsn.mseed', + 'mseq' => 'application/vnd.mseq', + 'msf' => 'application/vnd.epson.msf', + 'msh' => 'model/mesh', + 'msi' => 'application/x-msdownload', + 'msl' => 'application/vnd.mobius.msl', + 'msty' => 'application/vnd.muvee.style', + 'mts' => 'model/vnd.mts', + 'mus' => 'application/vnd.musician', + 'musicxml' => 'application/vnd.recordare.musicxml+xml', + 'mvb' => 'application/x-msmediaview', + 'mwf' => 'application/vnd.mfer', + 'mxf' => 'application/mxf', + 'mxl' => 'application/vnd.recordare.musicxml', + 'mxml' => 'application/xv+xml', + 'mxs' => 'application/vnd.triscape.mxs', + 'mxu' => 'video/vnd.mpegurl', + 'n-gage' => 'application/vnd.nokia.n-gage.symbian.install', + 'n3' => 'text/n3', + 'nb' => 'application/mathematica', + 'nbp' => 'application/vnd.wolfram.player', + 'nc' => 'application/x-netcdf', + 'ncx' => 'application/x-dtbncx+xml', + 'nfo' => 'text/x-nfo', + 'ngdat' => 'application/vnd.nokia.n-gage.data', + 'nitf' => 'application/vnd.nitf', + 'nlu' => 'application/vnd.neurolanguage.nlu', + 'nml' => 'application/vnd.enliven', + 'nnd' => 'application/vnd.noblenet-directory', + 'nns' => 'application/vnd.noblenet-sealer', + 'nnw' => 'application/vnd.noblenet-web', + 'npx' => 'image/vnd.net-fpx', + 'nsc' => 'application/x-conference', + 'nsf' => 'application/vnd.lotus-notes', + 'ntf' => 'application/vnd.nitf', + 'nzb' => 'application/x-nzb', + 'oa2' => 'application/vnd.fujitsu.oasys2', + 'oa3' => 'application/vnd.fujitsu.oasys3', + 'oas' => 'application/vnd.fujitsu.oasys', + 'obd' => 'application/x-msbinder', + 'obj' => 'application/x-tgif', + 'oda' => 'application/oda', + 'odb' => 'application/vnd.oasis.opendocument.database', + 'odc' => 'application/vnd.oasis.opendocument.chart', + 'odf' => 'application/vnd.oasis.opendocument.formula', + 'odft' => 'application/vnd.oasis.opendocument.formula-template', + 'odg' => 'application/vnd.oasis.opendocument.graphics', + 'odi' => 'application/vnd.oasis.opendocument.image', + 'odm' => 'application/vnd.oasis.opendocument.text-master', + 'odp' => 'application/vnd.oasis.opendocument.presentation', + 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', + 'odt' => 'application/vnd.oasis.opendocument.text', + 'oga' => 'audio/ogg', + 'ogg' => 'audio/ogg', + 'ogv' => 'video/ogg', + 'ogx' => 'application/ogg', + 'omdoc' => 'application/omdoc+xml', + 'onepkg' => 'application/onenote', + 'onetmp' => 'application/onenote', + 'onetoc' => 'application/onenote', + 'onetoc2' => 'application/onenote', + 'opf' => 'application/oebps-package+xml', + 'opml' => 'text/x-opml', + 'oprc' => 'application/vnd.palm', + 'org' => 'application/vnd.lotus-organizer', + 'osf' => 'application/vnd.yamaha.openscoreformat', + 'osfpvg' => 'application/vnd.yamaha.openscoreformat.osfpvg+xml', + 'otc' => 'application/vnd.oasis.opendocument.chart-template', + 'otf' => 'application/x-font-otf', + 'otg' => 'application/vnd.oasis.opendocument.graphics-template', + 'oth' => 'application/vnd.oasis.opendocument.text-web', + 'oti' => 'application/vnd.oasis.opendocument.image-template', + 'otp' => 'application/vnd.oasis.opendocument.presentation-template', + 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template', + 'ott' => 'application/vnd.oasis.opendocument.text-template', + 'oxps' => 'application/oxps', + 'oxt' => 'application/vnd.openofficeorg.extension', + 'p' => 'text/x-pascal', + 'p10' => 'application/pkcs10', + 'p12' => 'application/x-pkcs12', + 'p7b' => 'application/x-pkcs7-certificates', + 'p7c' => 'application/pkcs7-mime', + 'p7m' => 'application/pkcs7-mime', + 'p7r' => 'application/x-pkcs7-certreqresp', + 'p7s' => 'application/pkcs7-signature', + 'p8' => 'application/pkcs8', + 'pas' => 'text/x-pascal', + 'paw' => 'application/vnd.pawaafile', + 'pbd' => 'application/vnd.powerbuilder6', + 'pbm' => 'image/x-portable-bitmap', + 'pcap' => 'application/vnd.tcpdump.pcap', + 'pcf' => 'application/x-font-pcf', + 'pcl' => 'application/vnd.hp-pcl', + 'pclxl' => 'application/vnd.hp-pclxl', + 'pct' => 'image/x-pict', + 'pcurl' => 'application/vnd.curl.pcurl', + 'pcx' => 'image/x-pcx', + 'pdb' => 'application/vnd.palm', + 'pdf' => 'application/pdf', + 'pfa' => 'application/x-font-type1', + 'pfb' => 'application/x-font-type1', + 'pfm' => 'application/x-font-type1', + 'pfr' => 'application/font-tdpfr', + 'pfx' => 'application/x-pkcs12', + 'pgm' => 'image/x-portable-graymap', + 'pgn' => 'application/x-chess-pgn', + 'pgp' => 'application/pgp-encrypted', + 'php' => 'application/x-php', + 'php3' => 'application/x-php', + 'php4' => 'application/x-php', + 'php5' => 'application/x-php', + 'pic' => 'image/x-pict', + 'pkg' => 'application/octet-stream', + 'pki' => 'application/pkixcmp', + 'pkipath' => 'application/pkix-pkipath', + 'plb' => 'application/vnd.3gpp.pic-bw-large', + 'plc' => 'application/vnd.mobius.plc', + 'plf' => 'application/vnd.pocketlearn', + 'pls' => 'application/pls+xml', + 'pml' => 'application/vnd.ctc-posml', + 'png' => 'image/png', + 'pnm' => 'image/x-portable-anymap', + 'portpkg' => 'application/vnd.macports.portpkg', + 'pot' => 'application/vnd.ms-powerpoint', + 'potm' => 'application/vnd.ms-powerpoint.template.macroenabled.12', + 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template', + 'ppam' => 'application/vnd.ms-powerpoint.addin.macroenabled.12', + 'ppd' => 'application/vnd.cups-ppd', + 'ppm' => 'image/x-portable-pixmap', + 'pps' => 'application/vnd.ms-powerpoint', + 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroenabled.12', + 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', + 'ppt' => 'application/vnd.ms-powerpoint', + 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroenabled.12', + 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'pqa' => 'application/vnd.palm', + 'prc' => 'application/x-mobipocket-ebook', + 'pre' => 'application/vnd.lotus-freelance', + 'prf' => 'application/pics-rules', + 'ps' => 'application/postscript', + 'psb' => 'application/vnd.3gpp.pic-bw-small', + 'psd' => 'image/vnd.adobe.photoshop', + 'psf' => 'application/x-font-linux-psf', + 'pskcxml' => 'application/pskc+xml', + 'ptid' => 'application/vnd.pvi.ptid1', + 'pub' => 'application/x-mspublisher', + 'pvb' => 'application/vnd.3gpp.pic-bw-var', + 'pwn' => 'application/vnd.3m.post-it-notes', + 'pya' => 'audio/vnd.ms-playready.media.pya', + 'pyv' => 'video/vnd.ms-playready.media.pyv', + 'qam' => 'application/vnd.epson.quickanime', + 'qbo' => 'application/vnd.intu.qbo', + 'qfx' => 'application/vnd.intu.qfx', + 'qps' => 'application/vnd.publishare-delta-tree', + 'qt' => 'video/quicktime', + 'qwd' => 'application/vnd.quark.quarkxpress', + 'qwt' => 'application/vnd.quark.quarkxpress', + 'qxb' => 'application/vnd.quark.quarkxpress', + 'qxd' => 'application/vnd.quark.quarkxpress', + 'qxl' => 'application/vnd.quark.quarkxpress', + 'qxt' => 'application/vnd.quark.quarkxpress', + 'ra' => 'audio/x-pn-realaudio', + 'ram' => 'audio/x-pn-realaudio', + 'rar' => 'application/x-rar-compressed', + 'ras' => 'image/x-cmu-raster', + 'rcprofile' => 'application/vnd.ipunplugged.rcprofile', + 'rdf' => 'application/rdf+xml', + 'rdz' => 'application/vnd.data-vision.rdz', + 'rep' => 'application/vnd.businessobjects', + 'res' => 'application/x-dtbresource+xml', + 'rgb' => 'image/x-rgb', + 'rif' => 'application/reginfo+xml', + 'rip' => 'audio/vnd.rip', + 'ris' => 'application/x-research-info-systems', + 'rl' => 'application/resource-lists+xml', + 'rlc' => 'image/vnd.fujixerox.edmics-rlc', + 'rld' => 'application/resource-lists-diff+xml', + 'rm' => 'application/vnd.rn-realmedia', + 'rmi' => 'audio/midi', + 'rmp' => 'audio/x-pn-realaudio-plugin', + 'rms' => 'application/vnd.jcp.javame.midlet-rms', + 'rmvb' => 'application/vnd.rn-realmedia-vbr', + 'rnc' => 'application/relax-ng-compact-syntax', + 'roa' => 'application/rpki-roa', + 'roff' => 'text/troff', + 'rp9' => 'application/vnd.cloanto.rp9', + 'rpss' => 'application/vnd.nokia.radio-presets', + 'rpst' => 'application/vnd.nokia.radio-preset', + 'rq' => 'application/sparql-query', + 'rs' => 'application/rls-services+xml', + 'rsd' => 'application/rsd+xml', + 'rss' => 'application/rss+xml', + 'rtf' => 'application/rtf', + 'rtx' => 'text/richtext', + 's' => 'text/x-asm', + 's3m' => 'audio/s3m', + 'saf' => 'application/vnd.yamaha.smaf-audio', + 'sbml' => 'application/sbml+xml', + 'sc' => 'application/vnd.ibm.secure-container', + 'scd' => 'application/x-msschedule', + 'scm' => 'application/vnd.lotus-screencam', + 'scq' => 'application/scvp-cv-request', + 'scs' => 'application/scvp-cv-response', + 'scurl' => 'text/vnd.curl.scurl', + 'sda' => 'application/vnd.stardivision.draw', + 'sdc' => 'application/vnd.stardivision.calc', + 'sdd' => 'application/vnd.stardivision.impress', + 'sdkd' => 'application/vnd.solent.sdkm+xml', + 'sdkm' => 'application/vnd.solent.sdkm+xml', + 'sdp' => 'application/sdp', + 'sdw' => 'application/vnd.stardivision.writer', + 'see' => 'application/vnd.seemail', + 'seed' => 'application/vnd.fdsn.seed', + 'sema' => 'application/vnd.sema', + 'semd' => 'application/vnd.semd', + 'semf' => 'application/vnd.semf', + 'ser' => 'application/java-serialized-object', + 'setpay' => 'application/set-payment-initiation', + 'setreg' => 'application/set-registration-initiation', + 'sfd-hdstx' => 'application/vnd.hydrostatix.sof-data', + 'sfs' => 'application/vnd.spotfire.sfs', + 'sfv' => 'text/x-sfv', + 'sgi' => 'image/sgi', + 'sgl' => 'application/vnd.stardivision.writer-global', + 'sgm' => 'text/sgml', + 'sgml' => 'text/sgml', + 'sh' => 'application/x-sh', + 'shar' => 'application/x-shar', + 'shf' => 'application/shf+xml', + 'sid' => 'image/x-mrsid-image', + 'sig' => 'application/pgp-signature', + 'sil' => 'audio/silk', + 'silo' => 'model/mesh', + 'sis' => 'application/vnd.symbian.install', + 'sisx' => 'application/vnd.symbian.install', + 'sit' => 'application/x-stuffit', + 'sitx' => 'application/x-stuffitx', + 'skd' => 'application/vnd.koan', + 'skm' => 'application/vnd.koan', + 'skp' => 'application/vnd.koan', + 'skt' => 'application/vnd.koan', + 'sldm' => 'application/vnd.ms-powerpoint.slide.macroenabled.12', + 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide', + 'slt' => 'application/vnd.epson.salt', + 'sm' => 'application/vnd.stepmania.stepchart', + 'smf' => 'application/vnd.stardivision.math', + 'smi' => 'application/smil+xml', + 'smil' => 'application/smil+xml', + 'smv' => 'video/x-smv', + 'smzip' => 'application/vnd.stepmania.package', + 'snd' => 'audio/basic', + 'snf' => 'application/x-font-snf', + 'so' => 'application/octet-stream', + 'spc' => 'application/x-pkcs7-certificates', + 'spf' => 'application/vnd.yamaha.smaf-phrase', + 'spl' => 'application/x-futuresplash', + 'spot' => 'text/vnd.in3d.spot', + 'spp' => 'application/scvp-vp-response', + 'spq' => 'application/scvp-vp-request', + 'spx' => 'audio/ogg', + 'sql' => 'application/x-sql', + 'src' => 'application/x-wais-source', + 'srt' => 'application/x-subrip', + 'sru' => 'application/sru+xml', + 'srx' => 'application/sparql-results+xml', + 'ssdl' => 'application/ssdl+xml', + 'sse' => 'application/vnd.kodak-descriptor', + 'ssf' => 'application/vnd.epson.ssf', + 'ssml' => 'application/ssml+xml', + 'st' => 'application/vnd.sailingtracker.track', + 'stc' => 'application/vnd.sun.xml.calc.template', + 'std' => 'application/vnd.sun.xml.draw.template', + 'stf' => 'application/vnd.wt.stf', + 'sti' => 'application/vnd.sun.xml.impress.template', + 'stk' => 'application/hyperstudio', + 'stl' => 'application/vnd.ms-pki.stl', + 'str' => 'application/vnd.pg.format', + 'stw' => 'application/vnd.sun.xml.writer.template', + 'sub' => 'text/vnd.dvb.subtitle', + 'sus' => 'application/vnd.sus-calendar', + 'susp' => 'application/vnd.sus-calendar', + 'sv4cpio' => 'application/x-sv4cpio', + 'sv4crc' => 'application/x-sv4crc', + 'svc' => 'application/vnd.dvb.service', + 'svd' => 'application/vnd.svd', + 'svg' => 'image/svg+xml', + 'svgz' => 'image/svg+xml', + 'swa' => 'application/x-director', + 'swf' => 'application/x-shockwave-flash', + 'swi' => 'application/vnd.aristanetworks.swi', + 'sxc' => 'application/vnd.sun.xml.calc', + 'sxd' => 'application/vnd.sun.xml.draw', + 'sxg' => 'application/vnd.sun.xml.writer.global', + 'sxi' => 'application/vnd.sun.xml.impress', + 'sxm' => 'application/vnd.sun.xml.math', + 'sxw' => 'application/vnd.sun.xml.writer', + 't' => 'text/troff', + 't3' => 'application/x-t3vm-image', + 'taglet' => 'application/vnd.mynfc', + 'tao' => 'application/vnd.tao.intent-module-archive', + 'tar' => 'application/x-tar', + 'tcap' => 'application/vnd.3gpp2.tcap', + 'tcl' => 'application/x-tcl', + 'teacher' => 'application/vnd.smart.teacher', + 'tei' => 'application/tei+xml', + 'teicorpus' => 'application/tei+xml', + 'tex' => 'application/x-tex', + 'texi' => 'application/x-texinfo', + 'texinfo' => 'application/x-texinfo', + 'text' => 'text/plain', + 'tfi' => 'application/thraud+xml', + 'tfm' => 'application/x-tex-tfm', + 'tga' => 'image/x-tga', + 'thmx' => 'application/vnd.ms-officetheme', + 'tif' => 'image/tiff', + 'tiff' => 'image/tiff', + 'tmo' => 'application/vnd.tmobile-livetv', + 'torrent' => 'application/x-bittorrent', + 'tpl' => 'application/vnd.groove-tool-template', + 'tpt' => 'application/vnd.trid.tpt', + 'tr' => 'text/troff', + 'tra' => 'application/vnd.trueapp', + 'trm' => 'application/x-msterminal', + 'tsd' => 'application/timestamped-data', + 'tsv' => 'text/tab-separated-values', + 'ttc' => 'application/x-font-ttf', + 'ttf' => 'application/x-font-ttf', + 'ttl' => 'text/turtle', + 'twd' => 'application/vnd.simtech-mindmapper', + 'twds' => 'application/vnd.simtech-mindmapper', + 'txd' => 'application/vnd.genomatix.tuxedo', + 'txf' => 'application/vnd.mobius.txf', + 'txt' => 'text/plain', + 'u32' => 'application/x-authorware-bin', + 'udeb' => 'application/x-debian-package', + 'ufd' => 'application/vnd.ufdl', + 'ufdl' => 'application/vnd.ufdl', + 'ulx' => 'application/x-glulx', + 'umj' => 'application/vnd.umajin', + 'unityweb' => 'application/vnd.unity', + 'uoml' => 'application/vnd.uoml+xml', + 'uri' => 'text/uri-list', + 'uris' => 'text/uri-list', + 'urls' => 'text/uri-list', + 'ustar' => 'application/x-ustar', + 'utz' => 'application/vnd.uiq.theme', + 'uu' => 'text/x-uuencode', + 'uva' => 'audio/vnd.dece.audio', + 'uvd' => 'application/vnd.dece.data', + 'uvf' => 'application/vnd.dece.data', + 'uvg' => 'image/vnd.dece.graphic', + 'uvh' => 'video/vnd.dece.hd', + 'uvi' => 'image/vnd.dece.graphic', + 'uvm' => 'video/vnd.dece.mobile', + 'uvp' => 'video/vnd.dece.pd', + 'uvs' => 'video/vnd.dece.sd', + 'uvt' => 'application/vnd.dece.ttml+xml', + 'uvu' => 'video/vnd.uvvu.mp4', + 'uvv' => 'video/vnd.dece.video', + 'uvva' => 'audio/vnd.dece.audio', + 'uvvd' => 'application/vnd.dece.data', + 'uvvf' => 'application/vnd.dece.data', + 'uvvg' => 'image/vnd.dece.graphic', + 'uvvh' => 'video/vnd.dece.hd', + 'uvvi' => 'image/vnd.dece.graphic', + 'uvvm' => 'video/vnd.dece.mobile', + 'uvvp' => 'video/vnd.dece.pd', + 'uvvs' => 'video/vnd.dece.sd', + 'uvvt' => 'application/vnd.dece.ttml+xml', + 'uvvu' => 'video/vnd.uvvu.mp4', + 'uvvv' => 'video/vnd.dece.video', + 'uvvx' => 'application/vnd.dece.unspecified', + 'uvvz' => 'application/vnd.dece.zip', + 'uvx' => 'application/vnd.dece.unspecified', + 'uvz' => 'application/vnd.dece.zip', + 'vcard' => 'text/vcard', + 'vcd' => 'application/x-cdlink', + 'vcf' => 'text/x-vcard', + 'vcg' => 'application/vnd.groove-vcard', + 'vcs' => 'text/x-vcalendar', + 'vcx' => 'application/vnd.vcx', + 'vis' => 'application/vnd.visionary', + 'viv' => 'video/vnd.vivo', + 'vob' => 'video/x-ms-vob', + 'vor' => 'application/vnd.stardivision.writer', + 'vox' => 'application/x-authorware-bin', + 'vrml' => 'model/vrml', + 'vsd' => 'application/vnd.visio', + 'vsf' => 'application/vnd.vsf', + 'vss' => 'application/vnd.visio', + 'vst' => 'application/vnd.visio', + 'vsw' => 'application/vnd.visio', + 'vtu' => 'model/vnd.vtu', + 'vxml' => 'application/voicexml+xml', + 'w3d' => 'application/x-director', + 'wad' => 'application/x-doom', + 'wav' => 'audio/x-wav', + 'wax' => 'audio/x-ms-wax', + 'wbmp' => 'image/vnd.wap.wbmp', + 'wbs' => 'application/vnd.criticaltools.wbs+xml', + 'wbxml' => 'application/vnd.wap.wbxml', + 'wcm' => 'application/vnd.ms-works', + 'wdb' => 'application/vnd.ms-works', + 'wdp' => 'image/vnd.ms-photo', + 'weba' => 'audio/webm', + 'webm' => 'video/webm', + 'webp' => 'image/webp', + 'wg' => 'application/vnd.pmi.widget', + 'wgt' => 'application/widget', + 'wks' => 'application/vnd.ms-works', + 'wm' => 'video/x-ms-wm', + 'wma' => 'audio/x-ms-wma', + 'wmd' => 'application/x-ms-wmd', + 'wmf' => 'application/x-msmetafile', + 'wml' => 'text/vnd.wap.wml', + 'wmlc' => 'application/vnd.wap.wmlc', + 'wmls' => 'text/vnd.wap.wmlscript', + 'wmlsc' => 'application/vnd.wap.wmlscriptc', + 'wmv' => 'video/x-ms-wmv', + 'wmx' => 'video/x-ms-wmx', + 'wmz' => 'application/x-msmetafile', + 'woff' => 'application/font-woff', + 'wpd' => 'application/vnd.wordperfect', + 'wpl' => 'application/vnd.ms-wpl', + 'wps' => 'application/vnd.ms-works', + 'wqd' => 'application/vnd.wqd', + 'wri' => 'application/x-mswrite', + 'wrl' => 'model/vrml', + 'wsdl' => 'application/wsdl+xml', + 'wspolicy' => 'application/wspolicy+xml', + 'wtb' => 'application/vnd.webturbo', + 'wvx' => 'video/x-ms-wvx', + 'x32' => 'application/x-authorware-bin', + 'x3d' => 'model/x3d+xml', + 'x3db' => 'model/x3d+binary', + 'x3dbz' => 'model/x3d+binary', + 'x3dv' => 'model/x3d+vrml', + 'x3dvz' => 'model/x3d+vrml', + 'x3dz' => 'model/x3d+xml', + 'xaml' => 'application/xaml+xml', + 'xap' => 'application/x-silverlight-app', + 'xar' => 'application/vnd.xara', + 'xbap' => 'application/x-ms-xbap', + 'xbd' => 'application/vnd.fujixerox.docuworks.binder', + 'xbm' => 'image/x-xbitmap', + 'xdf' => 'application/xcap-diff+xml', + 'xdm' => 'application/vnd.syncml.dm+xml', + 'xdp' => 'application/vnd.adobe.xdp+xml', + 'xdssc' => 'application/dssc+xml', + 'xdw' => 'application/vnd.fujixerox.docuworks', + 'xenc' => 'application/xenc+xml', + 'xer' => 'application/patch-ops-error+xml', + 'xfdf' => 'application/vnd.adobe.xfdf', + 'xfdl' => 'application/vnd.xfdl', + 'xht' => 'application/xhtml+xml', + 'xhtml' => 'application/xhtml+xml', + 'xhvml' => 'application/xv+xml', + 'xif' => 'image/vnd.xiff', + 'xla' => 'application/vnd.ms-excel', + 'xlam' => 'application/vnd.ms-excel.addin.macroenabled.12', + 'xlc' => 'application/vnd.ms-excel', + 'xlf' => 'application/x-xliff+xml', + 'xlm' => 'application/vnd.ms-excel', + 'xls' => 'application/vnd.ms-excel', + 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroenabled.12', + 'xlsm' => 'application/vnd.ms-excel.sheet.macroenabled.12', + 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'xlt' => 'application/vnd.ms-excel', + 'xltm' => 'application/vnd.ms-excel.template.macroenabled.12', + 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', + 'xlw' => 'application/vnd.ms-excel', + 'xm' => 'audio/xm', + 'xml' => 'application/xml', + 'xo' => 'application/vnd.olpc-sugar', + 'xop' => 'application/xop+xml', + 'xpi' => 'application/x-xpinstall', + 'xpl' => 'application/xproc+xml', + 'xpm' => 'image/x-xpixmap', + 'xpr' => 'application/vnd.is-xpr', + 'xps' => 'application/vnd.ms-xpsdocument', + 'xpw' => 'application/vnd.intercon.formnet', + 'xpx' => 'application/vnd.intercon.formnet', + 'xsl' => 'application/xml', + 'xslt' => 'application/xslt+xml', + 'xsm' => 'application/vnd.syncml+xml', + 'xspf' => 'application/xspf+xml', + 'xul' => 'application/vnd.mozilla.xul+xml', + 'xvm' => 'application/xv+xml', + 'xvml' => 'application/xv+xml', + 'xwd' => 'image/x-xwindowdump', + 'xyz' => 'chemical/x-xyz', + 'xz' => 'application/x-xz', + 'yang' => 'application/yang', + 'yin' => 'application/yin+xml', + 'z1' => 'application/x-zmachine', + 'z2' => 'application/x-zmachine', + 'z3' => 'application/x-zmachine', + 'z4' => 'application/x-zmachine', + 'z5' => 'application/x-zmachine', + 'z6' => 'application/x-zmachine', + 'z7' => 'application/x-zmachine', + 'z8' => 'application/x-zmachine', + 'zaz' => 'application/vnd.zzazz.deck+xml', + 'zip' => 'application/zip', + 'zir' => 'application/vnd.zul', + 'zirz' => 'application/vnd.zul', + 'zmm' => 'application/vnd.handheld-entertainment+xml', + '123' => 'application/vnd.lotus-1-2-3', ]; diff --git a/htdocs/includes/swiftmailer/lib/swiftmailer_generate_mimes_config.php b/htdocs/includes/swiftmailer/lib/swiftmailer_generate_mimes_config.php index ad8fd2aa0d5..b3febce4802 100644 --- a/htdocs/includes/swiftmailer/lib/swiftmailer_generate_mimes_config.php +++ b/htdocs/includes/swiftmailer/lib/swiftmailer_generate_mimes_config.php @@ -6,177 +6,177 @@ function generateUpToDateMimeArray() { - $preamble = " 'application/x-php', - 'php3' => 'application/x-php', - 'php4' => 'application/x-php', - 'php5' => 'application/x-php', - 'zip' => 'application/zip', - 'gif' => 'image/gif', - 'png' => 'image/png', - 'css' => 'text/css', - 'js' => 'text/javascript', - 'txt' => 'text/plain', - 'aif' => 'audio/x-aiff', - 'aiff' => 'audio/x-aiff', - 'avi' => 'video/avi', - 'bmp' => 'image/bmp', - 'bz2' => 'application/x-bz2', - 'csv' => 'text/csv', - 'dmg' => 'application/x-apple-diskimage', - 'doc' => 'application/msword', - 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', - 'eml' => 'message/rfc822', - 'aps' => 'application/postscript', - 'exe' => 'application/x-ms-dos-executable', - 'flv' => 'video/x-flv', - 'gz' => 'application/x-gzip', - 'hqx' => 'application/stuffit', - 'htm' => 'text/html', - 'html' => 'text/html', - 'jar' => 'application/x-java-archive', - 'jpeg' => 'image/jpeg', - 'jpg' => 'image/jpeg', - 'm3u' => 'audio/x-mpegurl', - 'm4a' => 'audio/mp4', - 'mdb' => 'application/x-msaccess', - 'mid' => 'audio/midi', - 'midi' => 'audio/midi', - 'mov' => 'video/quicktime', - 'mp3' => 'audio/mpeg', - 'mp4' => 'video/mp4', - 'mpeg' => 'video/mpeg', - 'mpg' => 'video/mpeg', - 'odg' => 'vnd.oasis.opendocument.graphics', - 'odp' => 'vnd.oasis.opendocument.presentation', - 'odt' => 'vnd.oasis.opendocument.text', - 'ods' => 'vnd.oasis.opendocument.spreadsheet', - 'ogg' => 'audio/ogg', - 'pdf' => 'application/pdf', - 'ppt' => 'application/vnd.ms-powerpoint', - 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', - 'ps' => 'application/postscript', - 'rar' => 'application/x-rar-compressed', - 'rtf' => 'application/rtf', - 'tar' => 'application/x-tar', - 'sit' => 'application/x-stuffit', - 'svg' => 'image/svg+xml', - 'tif' => 'image/tiff', - 'tiff' => 'image/tiff', - 'ttf' => 'application/x-font-truetype', - 'vcf' => 'text/x-vcard', - 'wav' => 'audio/wav', - 'wma' => 'audio/x-ms-wma', - 'wmv' => 'audio/x-ms-wmv', - 'xls' => 'application/vnd.ms-excel', - 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', - 'xml' => 'application/xml', - ]; + // split mime type and extensions eg. "video/x-matroska mkv mk3d mks" + if (false !== preg_match_all('/^#?([a-z0-9\-\+\/\.]+)[\t]+(.*)$/miu', $mime_types, $matches)) { + // collection of predefined mimetypes (bugfix for wrong resolved or missing mime types) + $valid_mime_types_preset = [ + 'php' => 'application/x-php', + 'php3' => 'application/x-php', + 'php4' => 'application/x-php', + 'php5' => 'application/x-php', + 'zip' => 'application/zip', + 'gif' => 'image/gif', + 'png' => 'image/png', + 'css' => 'text/css', + 'js' => 'text/javascript', + 'txt' => 'text/plain', + 'aif' => 'audio/x-aiff', + 'aiff' => 'audio/x-aiff', + 'avi' => 'video/avi', + 'bmp' => 'image/bmp', + 'bz2' => 'application/x-bz2', + 'csv' => 'text/csv', + 'dmg' => 'application/x-apple-diskimage', + 'doc' => 'application/msword', + 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'eml' => 'message/rfc822', + 'aps' => 'application/postscript', + 'exe' => 'application/x-ms-dos-executable', + 'flv' => 'video/x-flv', + 'gz' => 'application/x-gzip', + 'hqx' => 'application/stuffit', + 'htm' => 'text/html', + 'html' => 'text/html', + 'jar' => 'application/x-java-archive', + 'jpeg' => 'image/jpeg', + 'jpg' => 'image/jpeg', + 'm3u' => 'audio/x-mpegurl', + 'm4a' => 'audio/mp4', + 'mdb' => 'application/x-msaccess', + 'mid' => 'audio/midi', + 'midi' => 'audio/midi', + 'mov' => 'video/quicktime', + 'mp3' => 'audio/mpeg', + 'mp4' => 'video/mp4', + 'mpeg' => 'video/mpeg', + 'mpg' => 'video/mpeg', + 'odg' => 'vnd.oasis.opendocument.graphics', + 'odp' => 'vnd.oasis.opendocument.presentation', + 'odt' => 'vnd.oasis.opendocument.text', + 'ods' => 'vnd.oasis.opendocument.spreadsheet', + 'ogg' => 'audio/ogg', + 'pdf' => 'application/pdf', + 'ppt' => 'application/vnd.ms-powerpoint', + 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'ps' => 'application/postscript', + 'rar' => 'application/x-rar-compressed', + 'rtf' => 'application/rtf', + 'tar' => 'application/x-tar', + 'sit' => 'application/x-stuffit', + 'svg' => 'image/svg+xml', + 'tif' => 'image/tiff', + 'tiff' => 'image/tiff', + 'ttf' => 'application/x-font-truetype', + 'vcf' => 'text/x-vcard', + 'wav' => 'audio/wav', + 'wma' => 'audio/x-ms-wma', + 'wmv' => 'audio/x-ms-wmv', + 'xls' => 'application/vnd.ms-excel', + 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'xml' => 'application/xml', + ]; - // wrap array for generating file - foreach ($valid_mime_types_preset as $extension => $mime_type) { - // generate array for mimetype to extension resolver (only first match) - $valid_mime_types[$extension] = "'{$extension}' => '{$mime_type}'"; - } + // wrap array for generating file + foreach ($valid_mime_types_preset as $extension => $mime_type) { + // generate array for mimetype to extension resolver (only first match) + $valid_mime_types[$extension] = "'{$extension}' => '{$mime_type}'"; + } - // all extensions from second match - foreach ($matches[2] as $i => $extensions) { - // explode multiple extensions from string - $extensions = explode(' ', strtolower($extensions ?? '')); + // all extensions from second match + foreach ($matches[2] as $i => $extensions) { + // explode multiple extensions from string + $extensions = explode(' ', strtolower($extensions ?? '')); - // force array for foreach - if (!\is_array($extensions)) { - $extensions = [$extensions]; - } + // force array for foreach + if (!\is_array($extensions)) { + $extensions = [$extensions]; + } - foreach ($extensions as $extension) { - // get mime type - $mime_type = $matches[1][$i]; + foreach ($extensions as $extension) { + // get mime type + $mime_type = $matches[1][$i]; - // check if string length lower than 10 - if (\strlen($extension) < 10) { - if (!isset($valid_mime_types[$mime_type])) { - // generate array for mimetype to extension resolver (only first match) - $valid_mime_types[$extension] = "'{$extension}' => '{$mime_type}'"; - } - } - } - } - } + // check if string length lower than 10 + if (\strlen($extension) < 10) { + if (!isset($valid_mime_types[$mime_type])) { + // generate array for mimetype to extension resolver (only first match) + $valid_mime_types[$extension] = "'{$extension}' => '{$mime_type}'"; + } + } + } + } + } - $xml = simplexml_load_string($mime_xml); + $xml = simplexml_load_string($mime_xml); - foreach ($xml as $node) { - // check if there is no pattern - if (!isset($node->glob['pattern'])) { - continue; - } + foreach ($xml as $node) { + // check if there is no pattern + if (!isset($node->glob['pattern'])) { + continue; + } - // get all matching extensions from match - foreach ((array) $node->glob['pattern'] as $extension) { - // skip none glob extensions - if (false === strpos($extension ?? '', '.')) { - continue; - } + // get all matching extensions from match + foreach ((array) $node->glob['pattern'] as $extension) { + // skip none glob extensions + if (false === strpos($extension ?? '', '.')) { + continue; + } - // remove get only last part - $extension = explode('.', strtolower($extension ?? '')); - $extension = end($extension); - } + // remove get only last part + $extension = explode('.', strtolower($extension ?? '')); + $extension = end($extension); + } - if (isset($node->glob['pattern'][0])) { - // mime type - $mime_type = strtolower((string) $node['type'] ?? ''); + if (isset($node->glob['pattern'][0])) { + // mime type + $mime_type = strtolower((string) $node['type'] ?? ''); - // get first extension - $extension = strtolower(trim($node->glob['ddpattern'][0] ?? '', '*.')); + // get first extension + $extension = strtolower(trim($node->glob['ddpattern'][0] ?? '', '*.')); - // skip none glob extensions and check if string length between 1 and 10 - if (false !== strpos($extension, '.') || \strlen($extension) < 1 || \strlen($extension) > 9) { - continue; - } + // skip none glob extensions and check if string length between 1 and 10 + if (false !== strpos($extension, '.') || \strlen($extension) < 1 || \strlen($extension) > 9) { + continue; + } - // check if string length lower than 10 - if (!isset($valid_mime_types[$mime_type])) { - // generate array for mimetype to extension resolver (only first match) - $valid_mime_types[$extension] = "'{$extension}' => '{$mime_type}'"; - } - } - } + // check if string length lower than 10 + if (!isset($valid_mime_types[$mime_type])) { + // generate array for mimetype to extension resolver (only first match) + $valid_mime_types[$extension] = "'{$extension}' => '{$mime_type}'"; + } + } + } - // full list of valid extensions only - $valid_mime_types = array_unique($valid_mime_types); - ksort($valid_mime_types); + // full list of valid extensions only + $valid_mime_types = array_unique($valid_mime_types); + ksort($valid_mime_types); - // combine mime types and extensions array - $output = "$preamble\$swift_mime_types = array(\n ".implode(",\n ", $valid_mime_types)."\n);"; + // combine mime types and extensions array + $output = "$preamble\$swift_mime_types = array(\n ".implode(",\n ", $valid_mime_types)."\n);"; - // write mime_types.php config file - @file_put_contents('./mime_types.php', $output); + // write mime_types.php config file + @file_put_contents('./mime_types.php', $output); } generateUpToDateMimeArray(); diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index e4ad83e8129..a17e7c2e6be 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -285,7 +285,6 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us } $result = $object->addTimeSpent($user); - } else { $object->fetch($id, $ref); @@ -1794,7 +1793,6 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if ($resultFetch < 0) { setEventMessages($product->error, $product->errors, 'errors'); } else { - print $product->getNomUrl(1); } } From db8d8f0b7d806e5fb510de0e6ca2bd5e5ab71fe9 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 24 Jan 2022 23:27:26 +0100 Subject: [PATCH 005/367] Revert "merge" This reverts commit 8d3d8fe63b2607b7f875fa96e3c7c1ed7bd24b98. --- .../EmailValidator/EmailLexer.php | 494 ++--- .../EmailValidator/EmailParser.php | 196 +- .../EmailValidator/EmailValidator.php | 98 +- .../Exception/DomainAcceptsNoMail.php | 6 +- .../Exception/ExpectingQPair.php | 4 +- .../Exception/LocalOrReservedDomain.php | 6 +- .../EmailValidator/Exception/NoDNSRecord.php | 4 +- .../Exception/UnclosedComment.php | 4 +- .../EmailValidator/Parser/DomainPart.php | 811 +++---- .../EmailValidator/Parser/LocalPart.php | 210 +- .../EmailValidator/Parser/Parser.php | 379 ++-- .../Validation/DNSCheckValidation.php | 246 +- .../Exception/EmptyValidationList.php | 14 +- .../Validation/MultipleErrors.php | 42 +- .../Validation/MultipleValidationWithAnd.php | 196 +- .../Validation/NoRFCWarningsValidation.php | 50 +- .../Validation/RFCValidation.php | 64 +- .../Validation/SpoofCheckValidation.php | 66 +- .../EmailValidator/Warning/QuotedPart.php | 18 +- .../EmailValidator/Warning/QuotedString.php | 18 +- .../EmailValidator/Warning/Warning.php | 68 +- .../Doctrine/Common/Lexer/AbstractLexer.php | 536 ++--- .../swiftmailer/lib/classes/Swift.php | 104 +- .../lib/classes/Swift/AddressEncoder.php | 14 +- .../AddressEncoder/IdnAddressEncoder.php | 40 +- .../AddressEncoder/Utf8AddressEncoder.php | 14 +- .../classes/Swift/AddressEncoderException.php | 20 +- .../lib/classes/Swift/Attachment.php | 68 +- .../AbstractFilterableInputStream.php | 278 +-- .../Swift/ByteStream/ArrayByteStream.php | 288 +-- .../Swift/ByteStream/FileByteStream.php | 342 +-- .../ByteStream/TemporaryFileByteStream.php | 58 +- .../GenericFixedWidthReader.php | 142 +- .../Swift/CharacterReader/UsAsciiReader.php | 122 +- .../Swift/CharacterReader/Utf8Reader.php | 298 +-- .../SimpleCharacterReaderFactory.php | 182 +- .../lib/classes/Swift/CharacterStream.php | 114 +- .../CharacterStream/ArrayCharacterStream.php | 486 ++-- .../CharacterStream/NgCharacterStream.php | 440 ++-- .../lib/classes/Swift/DependencyContainer.php | 644 +++--- .../lib/classes/Swift/EmbeddedFile.php | 66 +- .../classes/Swift/Encoder/Base64Encoder.php | 72 +- .../lib/classes/Swift/Encoder/QpEncoder.php | 504 ++--- .../classes/Swift/Encoder/Rfc2231Encoder.php | 126 +- .../lib/classes/Swift/Events/CommandEvent.php | 84 +- .../classes/Swift/Events/CommandListener.php | 8 +- .../classes/Swift/Events/EventDispatcher.php | 92 +- .../lib/classes/Swift/Events/EventObject.php | 76 +- .../classes/Swift/Events/ResponseEvent.php | 84 +- .../classes/Swift/Events/ResponseListener.php | 8 +- .../lib/classes/Swift/Events/SendEvent.php | 188 +- .../lib/classes/Swift/Events/SendListener.php | 16 +- .../Swift/Events/SimpleEventDispatcher.php | 224 +- .../Swift/Events/TransportChangeListener.php | 32 +- .../Swift/Events/TransportExceptionEvent.php | 46 +- .../Events/TransportExceptionListener.php | 8 +- .../lib/classes/Swift/FailoverTransport.php | 28 +- .../lib/classes/Swift/FileSpool.php | 330 +-- .../lib/classes/Swift/Filterable.php | 24 +- .../lib/classes/Swift/InputByteStream.php | 100 +- .../lib/classes/Swift/IoException.php | 20 +- .../lib/classes/Swift/KeyCache.php | 154 +- .../classes/Swift/KeyCache/ArrayKeyCache.php | 332 +-- .../classes/Swift/KeyCache/DiskKeyCache.php | 508 ++--- .../Swift/KeyCache/KeyCacheInputStream.php | 50 +- .../classes/Swift/KeyCache/NullKeyCache.php | 176 +- .../KeyCache/SimpleKeyCacheInputStream.php | 184 +- .../classes/Swift/LoadBalancedTransport.php | 28 +- .../swiftmailer/lib/classes/Swift/Mailer.php | 142 +- .../Swift/Mailer/ArrayRecipientIterator.php | 64 +- .../lib/classes/Swift/MemorySpool.php | 162 +- .../swiftmailer/lib/classes/Swift/Message.php | 442 ++-- .../lib/classes/Swift/Mime/Attachment.php | 224 +- .../ContentEncoder/Base64ContentEncoder.php | 144 +- .../ContentEncoder/NativeQpContentEncoder.php | 182 +- .../ContentEncoder/NullContentEncoder.php | 110 +- .../ContentEncoder/PlainContentEncoder.php | 252 +-- .../Mime/ContentEncoder/QpContentEncoder.php | 200 +- .../ContentEncoder/QpContentEncoderProxy.php | 134 +- .../Mime/ContentEncoder/RawContentEncoder.php | 80 +- .../lib/classes/Swift/Mime/EmbeddedFile.php | 44 +- .../classes/Swift/Mime/EncodingObserver.php | 8 +- .../lib/classes/Swift/Mime/Header.php | 126 +- .../HeaderEncoder/Base64HeaderEncoder.php | 68 +- .../Mime/HeaderEncoder/QpHeaderEncoder.php | 88 +- .../Swift/Mime/Headers/AbstractHeader.php | 834 +++---- .../classes/Swift/Mime/Headers/DateHeader.php | 174 +- .../Mime/Headers/IdentificationHeader.php | 298 +-- .../Swift/Mime/Headers/MailboxHeader.php | 626 +++--- .../Swift/Mime/Headers/OpenDKIMHeader.php | 208 +- .../Mime/Headers/ParameterizedHeader.php | 426 ++-- .../classes/Swift/Mime/Headers/PathHeader.php | 242 +- .../Swift/Mime/Headers/UnstructuredHeader.php | 166 +- .../lib/classes/Swift/Mime/IdGenerator.php | 68 +- .../lib/classes/Swift/Mime/MimePart.php | 318 +-- .../Swift/Mime/SimpleHeaderFactory.php | 310 +-- .../classes/Swift/Mime/SimpleHeaderSet.php | 674 +++--- .../lib/classes/Swift/Mime/SimpleMessage.php | 1248 +++++------ .../classes/Swift/Mime/SimpleMimeEntity.php | 1616 +++++++------- .../lib/classes/Swift/MimePart.php | 52 +- .../lib/classes/Swift/NullTransport.php | 16 +- .../classes/Swift/Plugins/AntiFloodPlugin.php | 216 +- .../Swift/Plugins/BandwidthMonitorPlugin.php | 244 +- .../classes/Swift/Plugins/DecoratorPlugin.php | 332 +-- .../Swift/Plugins/ImpersonatePlugin.php | 80 +- .../classes/Swift/Plugins/LoggerPlugin.php | 194 +- .../Swift/Plugins/Loggers/ArrayLogger.php | 98 +- .../classes/Swift/Plugins/MessageLogger.php | 92 +- .../Swift/Plugins/PopBeforeSmtpPlugin.php | 376 ++-- .../Swift/Plugins/RedirectingPlugin.php | 314 +-- .../lib/classes/Swift/Plugins/Reporter.php | 22 +- .../classes/Swift/Plugins/ReporterPlugin.php | 72 +- .../Swift/Plugins/Reporters/HitReporter.php | 72 +- .../Swift/Plugins/Reporters/HtmlReporter.php | 40 +- .../classes/Swift/Plugins/ThrottlerPlugin.php | 312 +-- .../lib/classes/Swift/Preferences.php | 142 +- .../lib/classes/Swift/SendmailTransport.php | 28 +- .../swiftmailer/lib/classes/Swift/Signer.php | 2 +- .../lib/classes/Swift/Signers/BodySigner.php | 24 +- .../lib/classes/Swift/Signers/DKIMSigner.php | 1328 +++++------ .../classes/Swift/Signers/DomainKeySigner.php | 860 +++---- .../classes/Swift/Signers/HeaderSigner.php | 76 +- .../classes/Swift/Signers/OpenDKIMSigner.php | 274 +-- .../lib/classes/Swift/Signers/SMimeSigner.php | 1044 ++++----- .../lib/classes/Swift/SmtpTransport.php | 38 +- .../lib/classes/Swift/SpoolTransport.php | 26 +- .../ByteArrayReplacementFilter.php | 268 +-- .../StringReplacementFilterFactory.php | 46 +- .../lib/classes/Swift/SwiftException.php | 20 +- .../lib/classes/Swift/Transport.php | 106 +- .../Swift/Transport/AbstractSmtpTransport.php | 1046 ++++----- .../Esmtp/Auth/CramMd5Authenticator.php | 98 +- .../Esmtp/Auth/LoginAuthenticator.php | 48 +- .../Esmtp/Auth/NTLMAuthenticator.php | 1322 +++++------ .../Esmtp/Auth/PlainAuthenticator.php | 46 +- .../Esmtp/Auth/XOAuth2Authenticator.php | 64 +- .../Swift/Transport/Esmtp/AuthHandler.php | 448 ++-- .../Swift/Transport/Esmtp/Authenticator.php | 34 +- .../Transport/Esmtp/EightBitMimeHandler.php | 156 +- .../Swift/Transport/Esmtp/SmtpUtf8Handler.php | 144 +- .../classes/Swift/Transport/EsmtpHandler.php | 120 +- .../Swift/Transport/EsmtpTransport.php | 768 +++---- .../Swift/Transport/FailoverTransport.php | 146 +- .../lib/classes/Swift/Transport/IoBuffer.php | 82 +- .../Swift/Transport/LoadBalancedTransport.php | 310 +-- .../classes/Swift/Transport/NullTransport.php | 140 +- .../Swift/Transport/SendmailTransport.php | 241 +- .../lib/classes/Swift/Transport/SmtpAgent.php | 34 +- .../Swift/Transport/SpoolTransport.php | 176 +- .../classes/Swift/Transport/StreamBuffer.php | 540 ++--- .../lib/classes/Swift/TransportException.php | 20 +- .../lib/dependency_maps/cache_deps.php | 29 +- .../lib/dependency_maps/mime_deps.php | 207 +- .../lib/dependency_maps/transport_deps.php | 145 +- .../includes/swiftmailer/lib/mime_types.php | 1972 ++++++++--------- .../lib/swiftmailer_generate_mimes_config.php | 304 +-- htdocs/projet/tasks/time.php | 2 + 157 files changed, 17947 insertions(+), 17939 deletions(-) diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailLexer.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailLexer.php index 567002e5e2c..59dcd5876fd 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailLexer.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailLexer.php @@ -6,278 +6,278 @@ use Doctrine\Common\Lexer\AbstractLexer; class EmailLexer extends AbstractLexer { - //ASCII values - const C_DEL = 127; - const C_NUL = 0; - const S_AT = 64; - const S_BACKSLASH = 92; - const S_DOT = 46; - const S_DQUOTE = 34; - const S_SQUOTE = 39; - const S_BACKTICK = 96; - const S_OPENPARENTHESIS = 49; - const S_CLOSEPARENTHESIS = 261; - const S_OPENBRACKET = 262; - const S_CLOSEBRACKET = 263; - const S_HYPHEN = 264; - const S_COLON = 265; - const S_DOUBLECOLON = 266; - const S_SP = 267; - const S_HTAB = 268; - const S_CR = 269; - const S_LF = 270; - const S_IPV6TAG = 271; - const S_LOWERTHAN = 272; - const S_GREATERTHAN = 273; - const S_COMMA = 274; - const S_SEMICOLON = 275; - const S_OPENQBRACKET = 276; - const S_CLOSEQBRACKET = 277; - const S_SLASH = 278; - const S_EMPTY = null; - const GENERIC = 300; - const CRLF = 301; - const INVALID = 302; - const ASCII_INVALID_FROM = 127; - const ASCII_INVALID_TO = 199; + //ASCII values + const C_DEL = 127; + const C_NUL = 0; + const S_AT = 64; + const S_BACKSLASH = 92; + const S_DOT = 46; + const S_DQUOTE = 34; + const S_SQUOTE = 39; + const S_BACKTICK = 96; + const S_OPENPARENTHESIS = 49; + const S_CLOSEPARENTHESIS = 261; + const S_OPENBRACKET = 262; + const S_CLOSEBRACKET = 263; + const S_HYPHEN = 264; + const S_COLON = 265; + const S_DOUBLECOLON = 266; + const S_SP = 267; + const S_HTAB = 268; + const S_CR = 269; + const S_LF = 270; + const S_IPV6TAG = 271; + const S_LOWERTHAN = 272; + const S_GREATERTHAN = 273; + const S_COMMA = 274; + const S_SEMICOLON = 275; + const S_OPENQBRACKET = 276; + const S_CLOSEQBRACKET = 277; + const S_SLASH = 278; + const S_EMPTY = null; + const GENERIC = 300; + const CRLF = 301; + const INVALID = 302; + const ASCII_INVALID_FROM = 127; + const ASCII_INVALID_TO = 199; - /** - * US-ASCII visible characters not valid for atext (@link http://tools.ietf.org/html/rfc5322#section-3.2.3) - * - * @var array - */ - protected $charValue = array( - '(' => self::S_OPENPARENTHESIS, - ')' => self::S_CLOSEPARENTHESIS, - '<' => self::S_LOWERTHAN, - '>' => self::S_GREATERTHAN, - '[' => self::S_OPENBRACKET, - ']' => self::S_CLOSEBRACKET, - ':' => self::S_COLON, - ';' => self::S_SEMICOLON, - '@' => self::S_AT, - '\\' => self::S_BACKSLASH, - '/' => self::S_SLASH, - ',' => self::S_COMMA, - '.' => self::S_DOT, - "'" => self::S_SQUOTE, - "`" => self::S_BACKTICK, - '"' => self::S_DQUOTE, - '-' => self::S_HYPHEN, - '::' => self::S_DOUBLECOLON, - ' ' => self::S_SP, - "\t" => self::S_HTAB, - "\r" => self::S_CR, - "\n" => self::S_LF, - "\r\n" => self::CRLF, - 'IPv6' => self::S_IPV6TAG, - '{' => self::S_OPENQBRACKET, - '}' => self::S_CLOSEQBRACKET, - '' => self::S_EMPTY, - '\0' => self::C_NUL, - ); + /** + * US-ASCII visible characters not valid for atext (@link http://tools.ietf.org/html/rfc5322#section-3.2.3) + * + * @var array + */ + protected $charValue = array( + '(' => self::S_OPENPARENTHESIS, + ')' => self::S_CLOSEPARENTHESIS, + '<' => self::S_LOWERTHAN, + '>' => self::S_GREATERTHAN, + '[' => self::S_OPENBRACKET, + ']' => self::S_CLOSEBRACKET, + ':' => self::S_COLON, + ';' => self::S_SEMICOLON, + '@' => self::S_AT, + '\\' => self::S_BACKSLASH, + '/' => self::S_SLASH, + ',' => self::S_COMMA, + '.' => self::S_DOT, + "'" => self::S_SQUOTE, + "`" => self::S_BACKTICK, + '"' => self::S_DQUOTE, + '-' => self::S_HYPHEN, + '::' => self::S_DOUBLECOLON, + ' ' => self::S_SP, + "\t" => self::S_HTAB, + "\r" => self::S_CR, + "\n" => self::S_LF, + "\r\n" => self::CRLF, + 'IPv6' => self::S_IPV6TAG, + '{' => self::S_OPENQBRACKET, + '}' => self::S_CLOSEQBRACKET, + '' => self::S_EMPTY, + '\0' => self::C_NUL, + ); - /** - * @var bool - */ - protected $hasInvalidTokens = false; + /** + * @var bool + */ + protected $hasInvalidTokens = false; - /** - * @var array - * - * @psalm-var array{value:string, type:null|int, position:int}|array - */ - protected $previous = []; + /** + * @var array + * + * @psalm-var array{value:string, type:null|int, position:int}|array + */ + protected $previous = []; - /** - * The last matched/seen token. - * - * @var array - * - * @psalm-var array{value:string, type:null|int, position:int} - */ - public $token; + /** + * The last matched/seen token. + * + * @var array + * + * @psalm-var array{value:string, type:null|int, position:int} + */ + public $token; - /** - * The next token in the input. - * - * @var array|null - */ - public $lookahead; + /** + * The next token in the input. + * + * @var array|null + */ + public $lookahead; - /** - * @psalm-var array{value:'', type:null, position:0} - */ - private static $nullToken = [ - 'value' => '', - 'type' => null, - 'position' => 0, - ]; + /** + * @psalm-var array{value:'', type:null, position:0} + */ + private static $nullToken = [ + 'value' => '', + 'type' => null, + 'position' => 0, + ]; - public function __construct() - { - $this->previous = $this->token = self::$nullToken; - $this->lookahead = null; - } + public function __construct() + { + $this->previous = $this->token = self::$nullToken; + $this->lookahead = null; + } - /** - * @return void - */ - public function reset() - { - $this->hasInvalidTokens = false; - parent::reset(); - $this->previous = $this->token = self::$nullToken; - } + /** + * @return void + */ + public function reset() + { + $this->hasInvalidTokens = false; + parent::reset(); + $this->previous = $this->token = self::$nullToken; + } - /** - * @return bool - */ - public function hasInvalidTokens() - { - return $this->hasInvalidTokens; - } + /** + * @return bool + */ + public function hasInvalidTokens() + { + return $this->hasInvalidTokens; + } - /** - * @param int $type - * @throws \UnexpectedValueException - * @return boolean - * - * @psalm-suppress InvalidScalarArgument - */ - public function find($type) - { - $search = clone $this; - $search->skipUntil($type); + /** + * @param int $type + * @throws \UnexpectedValueException + * @return boolean + * + * @psalm-suppress InvalidScalarArgument + */ + public function find($type) + { + $search = clone $this; + $search->skipUntil($type); - if (!$search->lookahead) { - throw new \UnexpectedValueException($type . ' not found'); - } - return true; - } + if (!$search->lookahead) { + throw new \UnexpectedValueException($type . ' not found'); + } + return true; + } - /** - * getPrevious - * - * @return array - */ - public function getPrevious() - { - return $this->previous; - } + /** + * getPrevious + * + * @return array + */ + public function getPrevious() + { + return $this->previous; + } - /** - * moveNext - * - * @return boolean - */ - public function moveNext() - { - $this->previous = $this->token; - $hasNext = parent::moveNext(); - $this->token = $this->token ?: self::$nullToken; + /** + * moveNext + * + * @return boolean + */ + public function moveNext() + { + $this->previous = $this->token; + $hasNext = parent::moveNext(); + $this->token = $this->token ?: self::$nullToken; - return $hasNext; - } + return $hasNext; + } - /** - * Lexical catchable patterns. - * - * @return string[] - */ - protected function getCatchablePatterns() - { - return array( - '[a-zA-Z_]+[46]?', //ASCII and domain literal - '[^\x00-\x7F]', //UTF-8 - '[0-9]+', - '\r\n', - '::', - '\s+?', - '.', - ); - } + /** + * Lexical catchable patterns. + * + * @return string[] + */ + protected function getCatchablePatterns() + { + return array( + '[a-zA-Z_]+[46]?', //ASCII and domain literal + '[^\x00-\x7F]', //UTF-8 + '[0-9]+', + '\r\n', + '::', + '\s+?', + '.', + ); + } - /** - * Lexical non-catchable patterns. - * - * @return string[] - */ - protected function getNonCatchablePatterns() - { - return array('[\xA0-\xff]+'); - } + /** + * Lexical non-catchable patterns. + * + * @return string[] + */ + protected function getNonCatchablePatterns() + { + return array('[\xA0-\xff]+'); + } - /** - * Retrieve token type. Also processes the token value if necessary. - * - * @param string $value - * @throws \InvalidArgumentException - * @return integer - */ - protected function getType(&$value) - { - if ($this->isNullType($value)) { - return self::C_NUL; - } + /** + * Retrieve token type. Also processes the token value if necessary. + * + * @param string $value + * @throws \InvalidArgumentException + * @return integer + */ + protected function getType(&$value) + { + if ($this->isNullType($value)) { + return self::C_NUL; + } - if ($this->isValid($value)) { - return $this->charValue[$value]; - } + if ($this->isValid($value)) { + return $this->charValue[$value]; + } - if ($this->isUTF8Invalid($value)) { - $this->hasInvalidTokens = true; - return self::INVALID; - } + if ($this->isUTF8Invalid($value)) { + $this->hasInvalidTokens = true; + return self::INVALID; + } - return self::GENERIC; - } + return self::GENERIC; + } - /** - * @param string $value - * - * @return bool - */ - protected function isValid($value) - { - if (isset($this->charValue[$value])) { - return true; - } + /** + * @param string $value + * + * @return bool + */ + protected function isValid($value) + { + if (isset($this->charValue[$value])) { + return true; + } - return false; - } + return false; + } - /** - * @param string $value - * @return bool - */ - protected function isNullType($value) - { - if ($value === "\0") { - return true; - } + /** + * @param string $value + * @return bool + */ + protected function isNullType($value) + { + if ($value === "\0") { + return true; + } - return false; - } + return false; + } - /** - * @param string $value - * @return bool - */ - protected function isUTF8Invalid($value) - { - if (preg_match('/\p{Cc}+/u', $value)) { - return true; - } + /** + * @param string $value + * @return bool + */ + protected function isUTF8Invalid($value) + { + if (preg_match('/\p{Cc}+/u', $value)) { + return true; + } - return false; - } + return false; + } - /** - * @return string - */ - protected function getModifiers() - { - return 'iu'; - } + /** + * @return string + */ + protected function getModifiers() + { + return 'iu'; + } } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailParser.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailParser.php index cf9e7652339..6b7bad66927 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailParser.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailParser.php @@ -15,123 +15,123 @@ use Egulias\EmailValidator\Warning\EmailTooLong; */ class EmailParser { - const EMAIL_MAX_LENGTH = 254; + const EMAIL_MAX_LENGTH = 254; - /** - * @var array - */ - protected $warnings = []; + /** + * @var array + */ + protected $warnings = []; - /** - * @var string - */ - protected $domainPart = ''; + /** + * @var string + */ + protected $domainPart = ''; - /** - * @var string - */ - protected $localPart = ''; - /** - * @var EmailLexer - */ - protected $lexer; + /** + * @var string + */ + protected $localPart = ''; + /** + * @var EmailLexer + */ + protected $lexer; - /** - * @var LocalPart - */ - protected $localPartParser; + /** + * @var LocalPart + */ + protected $localPartParser; - /** - * @var DomainPart - */ - protected $domainPartParser; + /** + * @var DomainPart + */ + protected $domainPartParser; - public function __construct(EmailLexer $lexer) - { - $this->lexer = $lexer; - $this->localPartParser = new LocalPart($this->lexer); - $this->domainPartParser = new DomainPart($this->lexer); - } + public function __construct(EmailLexer $lexer) + { + $this->lexer = $lexer; + $this->localPartParser = new LocalPart($this->lexer); + $this->domainPartParser = new DomainPart($this->lexer); + } - /** - * @param string $str - * @return array - */ - public function parse($str) - { - $this->lexer->setInput($str); + /** + * @param string $str + * @return array + */ + public function parse($str) + { + $this->lexer->setInput($str); - if (!$this->hasAtToken()) { - throw new NoLocalPart(); - } + if (!$this->hasAtToken()) { + throw new NoLocalPart(); + } - $this->localPartParser->parse($str); - $this->domainPartParser->parse($str); + $this->localPartParser->parse($str); + $this->domainPartParser->parse($str); - $this->setParts($str); + $this->setParts($str); - if ($this->lexer->hasInvalidTokens()) { - throw new ExpectingATEXT(); - } + if ($this->lexer->hasInvalidTokens()) { + throw new ExpectingATEXT(); + } - return array('local' => $this->localPart, 'domain' => $this->domainPart); - } + return array('local' => $this->localPart, 'domain' => $this->domainPart); + } - /** - * @return Warning\Warning[] - */ - public function getWarnings() - { - $localPartWarnings = $this->localPartParser->getWarnings(); - $domainPartWarnings = $this->domainPartParser->getWarnings(); - $this->warnings = array_merge($localPartWarnings, $domainPartWarnings); + /** + * @return Warning\Warning[] + */ + public function getWarnings() + { + $localPartWarnings = $this->localPartParser->getWarnings(); + $domainPartWarnings = $this->domainPartParser->getWarnings(); + $this->warnings = array_merge($localPartWarnings, $domainPartWarnings); - $this->addLongEmailWarning($this->localPart, $this->domainPart); + $this->addLongEmailWarning($this->localPart, $this->domainPart); - return $this->warnings; - } + return $this->warnings; + } - /** - * @return string - */ - public function getParsedDomainPart() - { - return $this->domainPart; - } + /** + * @return string + */ + public function getParsedDomainPart() + { + return $this->domainPart; + } - /** - * @param string $email - */ - protected function setParts($email) - { - $parts = explode('@', $email); - $this->domainPart = $this->domainPartParser->getDomainPart(); - $this->localPart = $parts[0]; - } + /** + * @param string $email + */ + protected function setParts($email) + { + $parts = explode('@', $email); + $this->domainPart = $this->domainPartParser->getDomainPart(); + $this->localPart = $parts[0]; + } - /** - * @return bool - */ - protected function hasAtToken() - { - $this->lexer->moveNext(); - $this->lexer->moveNext(); - if ($this->lexer->token['type'] === EmailLexer::S_AT) { - return false; - } + /** + * @return bool + */ + protected function hasAtToken() + { + $this->lexer->moveNext(); + $this->lexer->moveNext(); + if ($this->lexer->token['type'] === EmailLexer::S_AT) { + return false; + } - return true; - } + return true; + } - /** - * @param string $localPart - * @param string $parsedDomainPart - */ - protected function addLongEmailWarning($localPart, $parsedDomainPart) - { - if (strlen($localPart . '@' . $parsedDomainPart) > self::EMAIL_MAX_LENGTH) { - $this->warnings[EmailTooLong::CODE] = new EmailTooLong(); - } - } + /** + * @param string $localPart + * @param string $parsedDomainPart + */ + protected function addLongEmailWarning($localPart, $parsedDomainPart) + { + if (strlen($localPart . '@' . $parsedDomainPart) > self::EMAIL_MAX_LENGTH) { + $this->warnings[EmailTooLong::CODE] = new EmailTooLong(); + } + } } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailValidator.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailValidator.php index e0532e618a6..a30f21dcd30 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailValidator.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailValidator.php @@ -7,61 +7,61 @@ use Egulias\EmailValidator\Validation\EmailValidation; class EmailValidator { - /** - * @var EmailLexer - */ - private $lexer; + /** + * @var EmailLexer + */ + private $lexer; - /** - * @var Warning\Warning[] - */ - protected $warnings = []; + /** + * @var Warning\Warning[] + */ + protected $warnings = []; - /** - * @var InvalidEmail|null - */ - protected $error; + /** + * @var InvalidEmail|null + */ + protected $error; - public function __construct() - { - $this->lexer = new EmailLexer(); - } + public function __construct() + { + $this->lexer = new EmailLexer(); + } - /** - * @param string $email - * @param EmailValidation $emailValidation - * @return bool - */ - public function isValid($email, EmailValidation $emailValidation) - { - $isValid = $emailValidation->isValid($email, $this->lexer); - $this->warnings = $emailValidation->getWarnings(); - $this->error = $emailValidation->getError(); + /** + * @param string $email + * @param EmailValidation $emailValidation + * @return bool + */ + public function isValid($email, EmailValidation $emailValidation) + { + $isValid = $emailValidation->isValid($email, $this->lexer); + $this->warnings = $emailValidation->getWarnings(); + $this->error = $emailValidation->getError(); - return $isValid; - } + return $isValid; + } - /** - * @return boolean - */ - public function hasWarnings() - { - return !empty($this->warnings); - } + /** + * @return boolean + */ + public function hasWarnings() + { + return !empty($this->warnings); + } - /** - * @return array - */ - public function getWarnings() - { - return $this->warnings; - } + /** + * @return array + */ + public function getWarnings() + { + return $this->warnings; + } - /** - * @return InvalidEmail|null - */ - public function getError() - { - return $this->error; - } + /** + * @return InvalidEmail|null + */ + public function getError() + { + return $this->error; + } } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/DomainAcceptsNoMail.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/DomainAcceptsNoMail.php index 822258f6f07..40a99705ce9 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/DomainAcceptsNoMail.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/DomainAcceptsNoMail.php @@ -4,6 +4,6 @@ namespace Egulias\EmailValidator\Exception; class DomainAcceptsNoMail extends InvalidEmail { - const CODE = 154; - const REASON = 'Domain accepts no mail (Null MX, RFC7505)'; -} + const CODE = 154; + const REASON = 'Domain accepts no mail (Null MX, RFC7505)'; +} \ No newline at end of file diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/ExpectingQPair.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/ExpectingQPair.php index ea9fc690bfa..a738eeb62f0 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/ExpectingQPair.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/ExpectingQPair.php @@ -4,6 +4,6 @@ namespace Egulias\EmailValidator\Exception; class ExpectingQPair extends InvalidEmail { - const CODE = 136; - const REASON = "Expecting QPAIR"; + const CODE = 136; + const REASON = "Expecting QPAIR"; } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/LocalOrReservedDomain.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/LocalOrReservedDomain.php index 964a6406726..695b05a46d4 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/LocalOrReservedDomain.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/LocalOrReservedDomain.php @@ -4,6 +4,6 @@ namespace Egulias\EmailValidator\Exception; class LocalOrReservedDomain extends InvalidEmail { - const CODE = 153; - const REASON = 'Local, mDNS or reserved domain (RFC2606, RFC6762)'; -} + const CODE = 153; + const REASON = 'Local, mDNS or reserved domain (RFC2606, RFC6762)'; +} \ No newline at end of file diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/NoDNSRecord.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/NoDNSRecord.php index 3e551ea6c11..0aa5fa78902 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/NoDNSRecord.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/NoDNSRecord.php @@ -4,6 +4,6 @@ namespace Egulias\EmailValidator\Exception; class NoDNSRecord extends InvalidEmail { - const CODE = 5; - const REASON = 'No MX or A DSN record was found for this email'; + const CODE = 5; + const REASON = 'No MX or A DSN record was found for this email'; } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/UnclosedComment.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/UnclosedComment.php index 40d9ab31fb7..86b2b09622d 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/UnclosedComment.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/UnclosedComment.php @@ -4,6 +4,6 @@ namespace Egulias\EmailValidator\Exception; class UnclosedComment extends InvalidEmail { - const CODE = 146; - const REASON = "No closing comment token found"; + const CODE = 146; + const REASON = "No closing comment token found"; } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Parser/DomainPart.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Parser/DomainPart.php index 8a0a8fe2674..4dadba8af7c 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Parser/DomainPart.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Parser/DomainPart.php @@ -34,409 +34,410 @@ use Egulias\EmailValidator\Warning\TLD; class DomainPart extends Parser { - const DOMAIN_MAX_LENGTH = 254; - const LABEL_MAX_LENGTH = 63; - - /** - * @var string - */ - protected $domainPart = ''; - - public function parse($domainPart) - { - $this->lexer->moveNext(); - - $this->performDomainStartChecks(); - - $domain = $this->doParseDomainPart(); - - $prev = $this->lexer->getPrevious(); - $length = strlen($domain); - - if ($prev['type'] === EmailLexer::S_DOT) { - throw new DotAtEnd(); - } - if ($prev['type'] === EmailLexer::S_HYPHEN) { - throw new DomainHyphened(); - } - if ($length > self::DOMAIN_MAX_LENGTH) { - $this->warnings[DomainTooLong::CODE] = new DomainTooLong(); - } - if ($prev['type'] === EmailLexer::S_CR) { - throw new CRLFAtTheEnd(); - } - $this->domainPart = $domain; - } - - private function performDomainStartChecks() - { - $this->checkInvalidTokensAfterAT(); - $this->checkEmptyDomain(); - - if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) { - $this->warnings[DeprecatedComment::CODE] = new DeprecatedComment(); - $this->parseDomainComments(); - } - } - - private function checkEmptyDomain() - { - $thereIsNoDomain = $this->lexer->token['type'] === EmailLexer::S_EMPTY || - ($this->lexer->token['type'] === EmailLexer::S_SP && - !$this->lexer->isNextToken(EmailLexer::GENERIC)); - - if ($thereIsNoDomain) { - throw new NoDomainPart(); - } - } - - private function checkInvalidTokensAfterAT() - { - if ($this->lexer->token['type'] === EmailLexer::S_DOT) { - throw new DotAtStart(); - } - if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN) { - throw new DomainHyphened(); - } - } - - /** - * @return string - */ - public function getDomainPart() - { - return $this->domainPart; - } - - /** - * @param string $addressLiteral - * @param int $maxGroups - */ - public function checkIPV6Tag($addressLiteral, $maxGroups = 8) - { - $prev = $this->lexer->getPrevious(); - if ($prev['type'] === EmailLexer::S_COLON) { - $this->warnings[IPV6ColonEnd::CODE] = new IPV6ColonEnd(); - } - - $IPv6 = substr($addressLiteral, 5); - //Daniel Marschall's new IPv6 testing strategy - $matchesIP = explode(':', $IPv6); - $groupCount = count($matchesIP); - $colons = strpos($IPv6, '::'); - - if (count(preg_grep('/^[0-9A-Fa-f]{0,4}$/', $matchesIP, PREG_GREP_INVERT)) !== 0) { - $this->warnings[IPV6BadChar::CODE] = new IPV6BadChar(); - } - - if ($colons === false) { - // We need exactly the right number of groups - if ($groupCount !== $maxGroups) { - $this->warnings[IPV6GroupCount::CODE] = new IPV6GroupCount(); - } - return; - } - - if ($colons !== strrpos($IPv6, '::')) { - $this->warnings[IPV6DoubleColon::CODE] = new IPV6DoubleColon(); - return; - } - - if ($colons === 0 || $colons === (strlen($IPv6) - 2)) { - // RFC 4291 allows :: at the start or end of an address - //with 7 other groups in addition - ++$maxGroups; - } - - if ($groupCount > $maxGroups) { - $this->warnings[IPV6MaxGroups::CODE] = new IPV6MaxGroups(); - } elseif ($groupCount === $maxGroups) { - $this->warnings[IPV6Deprecated::CODE] = new IPV6Deprecated(); - } - } - - /** - * @return string - */ - protected function doParseDomainPart() - { - $domain = ''; - $label = ''; - $openedParenthesis = 0; - do { - $prev = $this->lexer->getPrevious(); - - $this->checkNotAllowedChars($this->lexer->token); - - if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) { - $this->parseComments(); - $openedParenthesis += $this->getOpenedParenthesis(); - $this->lexer->moveNext(); - $tmpPrev = $this->lexer->getPrevious(); - if ($tmpPrev['type'] === EmailLexer::S_CLOSEPARENTHESIS) { - $openedParenthesis--; - } - } - if ($this->lexer->token['type'] === EmailLexer::S_CLOSEPARENTHESIS) { - if ($openedParenthesis === 0) { - throw new UnopenedComment(); - } else { - $openedParenthesis--; - } - } - - $this->checkConsecutiveDots(); - $this->checkDomainPartExceptions($prev); - - if ($this->hasBrackets()) { - $this->parseDomainLiteral(); - } - - if ($this->lexer->token['type'] === EmailLexer::S_DOT) { - $this->checkLabelLength($label); - $label = ''; - } else { - $label .= $this->lexer->token['value']; - } - - if ($this->isFWS()) { - $this->parseFWS(); - } - - $domain .= $this->lexer->token['value']; - $this->lexer->moveNext(); - if ($this->lexer->token['type'] === EmailLexer::S_SP) { - throw new CharNotAllowed(); - } - } while (null !== $this->lexer->token['type']); - - $this->checkLabelLength($label); - - return $domain; - } - - private function checkNotAllowedChars(array $token) - { - $notAllowed = [EmailLexer::S_BACKSLASH => true, EmailLexer::S_SLASH=> true]; - if (isset($notAllowed[$token['type']])) { - throw new CharNotAllowed(); - } - } - - /** - * @return string|false - */ - protected function parseDomainLiteral() - { - if ($this->lexer->isNextToken(EmailLexer::S_COLON)) { - $this->warnings[IPV6ColonStart::CODE] = new IPV6ColonStart(); - } - if ($this->lexer->isNextToken(EmailLexer::S_IPV6TAG)) { - $lexer = clone $this->lexer; - $lexer->moveNext(); - if ($lexer->isNextToken(EmailLexer::S_DOUBLECOLON)) { - $this->warnings[IPV6ColonStart::CODE] = new IPV6ColonStart(); - } - } - - return $this->doParseDomainLiteral(); - } - - /** - * @return string|false - */ - protected function doParseDomainLiteral() - { - $IPv6TAG = false; - $addressLiteral = ''; - do { - if ($this->lexer->token['type'] === EmailLexer::C_NUL) { - throw new ExpectingDTEXT(); - } - - if ($this->lexer->token['type'] === EmailLexer::INVALID || - $this->lexer->token['type'] === EmailLexer::C_DEL || - $this->lexer->token['type'] === EmailLexer::S_LF - ) { - $this->warnings[ObsoleteDTEXT::CODE] = new ObsoleteDTEXT(); - } - - if ($this->lexer->isNextTokenAny(array(EmailLexer::S_OPENQBRACKET, EmailLexer::S_OPENBRACKET))) { - throw new ExpectingDTEXT(); - } - - if ($this->lexer->isNextTokenAny( - array(EmailLexer::S_HTAB, EmailLexer::S_SP, $this->lexer->token['type'] === EmailLexer::CRLF) - )) { - $this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS(); - $this->parseFWS(); - } - - if ($this->lexer->isNextToken(EmailLexer::S_CR)) { - throw new CRNoLF(); - } - - if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH) { - $this->warnings[ObsoleteDTEXT::CODE] = new ObsoleteDTEXT(); - $addressLiteral .= $this->lexer->token['value']; - $this->lexer->moveNext(); - $this->validateQuotedPair(); - } - if ($this->lexer->token['type'] === EmailLexer::S_IPV6TAG) { - $IPv6TAG = true; - } - if ($this->lexer->token['type'] === EmailLexer::S_CLOSEQBRACKET) { - break; - } - - $addressLiteral .= $this->lexer->token['value']; - } while ($this->lexer->moveNext()); - - $addressLiteral = str_replace('[', '', $addressLiteral); - $addressLiteral = $this->checkIPV4Tag($addressLiteral); - - if (false === $addressLiteral) { - return $addressLiteral; - } - - if (!$IPv6TAG) { - $this->warnings[DomainLiteral::CODE] = new DomainLiteral(); - return $addressLiteral; - } - - $this->warnings[AddressLiteral::CODE] = new AddressLiteral(); - - $this->checkIPV6Tag($addressLiteral); - - return $addressLiteral; - } - - /** - * @param string $addressLiteral - * - * @return string|false - */ - protected function checkIPV4Tag($addressLiteral) - { - $matchesIP = array(); - - // Extract IPv4 part from the end of the address-literal (if there is one) - if (preg_match( - '/\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/', - $addressLiteral, - $matchesIP - ) > 0 - ) { - $index = strrpos($addressLiteral, $matchesIP[0]); - if ($index === 0) { - $this->warnings[AddressLiteral::CODE] = new AddressLiteral(); - return false; - } - // Convert IPv4 part to IPv6 format for further testing - $addressLiteral = substr($addressLiteral, 0, (int) $index) . '0:0'; - } - - return $addressLiteral; - } - - protected function checkDomainPartExceptions(array $prev) - { - $invalidDomainTokens = array( - EmailLexer::S_DQUOTE => true, - EmailLexer::S_SQUOTE => true, - EmailLexer::S_BACKTICK => true, - EmailLexer::S_SEMICOLON => true, - EmailLexer::S_GREATERTHAN => true, - EmailLexer::S_LOWERTHAN => true, - ); - - if (isset($invalidDomainTokens[$this->lexer->token['type']])) { - throw new ExpectingATEXT(); - } - - if ($this->lexer->token['type'] === EmailLexer::S_COMMA) { - throw new CommaInDomain(); - } - - if ($this->lexer->token['type'] === EmailLexer::S_AT) { - throw new ConsecutiveAt(); - } - - if ($this->lexer->token['type'] === EmailLexer::S_OPENQBRACKET && $prev['type'] !== EmailLexer::S_AT) { - throw new ExpectingATEXT(); - } - - if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN && $this->lexer->isNextToken(EmailLexer::S_DOT)) { - throw new DomainHyphened(); - } - - if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH - && $this->lexer->isNextToken(EmailLexer::GENERIC)) { - throw new ExpectingATEXT(); - } - } - - /** - * @return bool - */ - protected function hasBrackets() - { - if ($this->lexer->token['type'] !== EmailLexer::S_OPENBRACKET) { - return false; - } - - try { - $this->lexer->find(EmailLexer::S_CLOSEBRACKET); - } catch (\RuntimeException $e) { - throw new ExpectingDomainLiteralClose(); - } - - return true; - } - - /** - * @param string $label - */ - protected function checkLabelLength($label) - { - if ($this->isLabelTooLong($label)) { - $this->warnings[LabelTooLong::CODE] = new LabelTooLong(); - } - } - - /** - * @param string $label - * @return bool - */ - private function isLabelTooLong($label) - { - if (preg_match('/[^\x00-\x7F]/', $label)) { - idn_to_ascii($label, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46, $idnaInfo); - - return (bool) ($idnaInfo['errors'] & IDNA_ERROR_LABEL_TOO_LONG); - } - - return strlen($label) > self::LABEL_MAX_LENGTH; - } - - protected function parseDomainComments() - { - $this->isUnclosedComment(); - while (!$this->lexer->isNextToken(EmailLexer::S_CLOSEPARENTHESIS)) { - $this->warnEscaping(); - $this->lexer->moveNext(); - } - - $this->lexer->moveNext(); - if ($this->lexer->isNextToken(EmailLexer::S_DOT)) { - throw new ExpectingATEXT(); - } - } - - protected function addTLDWarnings() - { - if ($this->warnings[DomainLiteral::CODE]) { - $this->warnings[TLD::CODE] = new TLD(); - } - } + const DOMAIN_MAX_LENGTH = 254; + const LABEL_MAX_LENGTH = 63; + + /** + * @var string + */ + protected $domainPart = ''; + + public function parse($domainPart) + { + $this->lexer->moveNext(); + + $this->performDomainStartChecks(); + + $domain = $this->doParseDomainPart(); + + $prev = $this->lexer->getPrevious(); + $length = strlen($domain); + + if ($prev['type'] === EmailLexer::S_DOT) { + throw new DotAtEnd(); + } + if ($prev['type'] === EmailLexer::S_HYPHEN) { + throw new DomainHyphened(); + } + if ($length > self::DOMAIN_MAX_LENGTH) { + $this->warnings[DomainTooLong::CODE] = new DomainTooLong(); + } + if ($prev['type'] === EmailLexer::S_CR) { + throw new CRLFAtTheEnd(); + } + $this->domainPart = $domain; + } + + private function performDomainStartChecks() + { + $this->checkInvalidTokensAfterAT(); + $this->checkEmptyDomain(); + + if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) { + $this->warnings[DeprecatedComment::CODE] = new DeprecatedComment(); + $this->parseDomainComments(); + } + } + + private function checkEmptyDomain() + { + $thereIsNoDomain = $this->lexer->token['type'] === EmailLexer::S_EMPTY || + ($this->lexer->token['type'] === EmailLexer::S_SP && + !$this->lexer->isNextToken(EmailLexer::GENERIC)); + + if ($thereIsNoDomain) { + throw new NoDomainPart(); + } + } + + private function checkInvalidTokensAfterAT() + { + if ($this->lexer->token['type'] === EmailLexer::S_DOT) { + throw new DotAtStart(); + } + if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN) { + throw new DomainHyphened(); + } + } + + /** + * @return string + */ + public function getDomainPart() + { + return $this->domainPart; + } + + /** + * @param string $addressLiteral + * @param int $maxGroups + */ + public function checkIPV6Tag($addressLiteral, $maxGroups = 8) + { + $prev = $this->lexer->getPrevious(); + if ($prev['type'] === EmailLexer::S_COLON) { + $this->warnings[IPV6ColonEnd::CODE] = new IPV6ColonEnd(); + } + + $IPv6 = substr($addressLiteral, 5); + //Daniel Marschall's new IPv6 testing strategy + $matchesIP = explode(':', $IPv6); + $groupCount = count($matchesIP); + $colons = strpos($IPv6, '::'); + + if (count(preg_grep('/^[0-9A-Fa-f]{0,4}$/', $matchesIP, PREG_GREP_INVERT)) !== 0) { + $this->warnings[IPV6BadChar::CODE] = new IPV6BadChar(); + } + + if ($colons === false) { + // We need exactly the right number of groups + if ($groupCount !== $maxGroups) { + $this->warnings[IPV6GroupCount::CODE] = new IPV6GroupCount(); + } + return; + } + + if ($colons !== strrpos($IPv6, '::')) { + $this->warnings[IPV6DoubleColon::CODE] = new IPV6DoubleColon(); + return; + } + + if ($colons === 0 || $colons === (strlen($IPv6) - 2)) { + // RFC 4291 allows :: at the start or end of an address + //with 7 other groups in addition + ++$maxGroups; + } + + if ($groupCount > $maxGroups) { + $this->warnings[IPV6MaxGroups::CODE] = new IPV6MaxGroups(); + } elseif ($groupCount === $maxGroups) { + $this->warnings[IPV6Deprecated::CODE] = new IPV6Deprecated(); + } + } + + /** + * @return string + */ + protected function doParseDomainPart() + { + $domain = ''; + $label = ''; + $openedParenthesis = 0; + do { + $prev = $this->lexer->getPrevious(); + + $this->checkNotAllowedChars($this->lexer->token); + + if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) { + $this->parseComments(); + $openedParenthesis += $this->getOpenedParenthesis(); + $this->lexer->moveNext(); + $tmpPrev = $this->lexer->getPrevious(); + if ($tmpPrev['type'] === EmailLexer::S_CLOSEPARENTHESIS) { + $openedParenthesis--; + } + } + if ($this->lexer->token['type'] === EmailLexer::S_CLOSEPARENTHESIS) { + if ($openedParenthesis === 0) { + throw new UnopenedComment(); + } else { + $openedParenthesis--; + } + } + + $this->checkConsecutiveDots(); + $this->checkDomainPartExceptions($prev); + + if ($this->hasBrackets()) { + $this->parseDomainLiteral(); + } + + if ($this->lexer->token['type'] === EmailLexer::S_DOT) { + $this->checkLabelLength($label); + $label = ''; + } else { + $label .= $this->lexer->token['value']; + } + + if ($this->isFWS()) { + $this->parseFWS(); + } + + $domain .= $this->lexer->token['value']; + $this->lexer->moveNext(); + if ($this->lexer->token['type'] === EmailLexer::S_SP) { + throw new CharNotAllowed(); + } + } while (null !== $this->lexer->token['type']); + + $this->checkLabelLength($label); + + return $domain; + } + + private function checkNotAllowedChars(array $token) + { + $notAllowed = [EmailLexer::S_BACKSLASH => true, EmailLexer::S_SLASH=> true]; + if (isset($notAllowed[$token['type']])) { + throw new CharNotAllowed(); + } + } + + /** + * @return string|false + */ + protected function parseDomainLiteral() + { + if ($this->lexer->isNextToken(EmailLexer::S_COLON)) { + $this->warnings[IPV6ColonStart::CODE] = new IPV6ColonStart(); + } + if ($this->lexer->isNextToken(EmailLexer::S_IPV6TAG)) { + $lexer = clone $this->lexer; + $lexer->moveNext(); + if ($lexer->isNextToken(EmailLexer::S_DOUBLECOLON)) { + $this->warnings[IPV6ColonStart::CODE] = new IPV6ColonStart(); + } + } + + return $this->doParseDomainLiteral(); + } + + /** + * @return string|false + */ + protected function doParseDomainLiteral() + { + $IPv6TAG = false; + $addressLiteral = ''; + do { + if ($this->lexer->token['type'] === EmailLexer::C_NUL) { + throw new ExpectingDTEXT(); + } + + if ($this->lexer->token['type'] === EmailLexer::INVALID || + $this->lexer->token['type'] === EmailLexer::C_DEL || + $this->lexer->token['type'] === EmailLexer::S_LF + ) { + $this->warnings[ObsoleteDTEXT::CODE] = new ObsoleteDTEXT(); + } + + if ($this->lexer->isNextTokenAny(array(EmailLexer::S_OPENQBRACKET, EmailLexer::S_OPENBRACKET))) { + throw new ExpectingDTEXT(); + } + + if ($this->lexer->isNextTokenAny( + array(EmailLexer::S_HTAB, EmailLexer::S_SP, $this->lexer->token['type'] === EmailLexer::CRLF) + )) { + $this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS(); + $this->parseFWS(); + } + + if ($this->lexer->isNextToken(EmailLexer::S_CR)) { + throw new CRNoLF(); + } + + if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH) { + $this->warnings[ObsoleteDTEXT::CODE] = new ObsoleteDTEXT(); + $addressLiteral .= $this->lexer->token['value']; + $this->lexer->moveNext(); + $this->validateQuotedPair(); + } + if ($this->lexer->token['type'] === EmailLexer::S_IPV6TAG) { + $IPv6TAG = true; + } + if ($this->lexer->token['type'] === EmailLexer::S_CLOSEQBRACKET) { + break; + } + + $addressLiteral .= $this->lexer->token['value']; + + } while ($this->lexer->moveNext()); + + $addressLiteral = str_replace('[', '', $addressLiteral); + $addressLiteral = $this->checkIPV4Tag($addressLiteral); + + if (false === $addressLiteral) { + return $addressLiteral; + } + + if (!$IPv6TAG) { + $this->warnings[DomainLiteral::CODE] = new DomainLiteral(); + return $addressLiteral; + } + + $this->warnings[AddressLiteral::CODE] = new AddressLiteral(); + + $this->checkIPV6Tag($addressLiteral); + + return $addressLiteral; + } + + /** + * @param string $addressLiteral + * + * @return string|false + */ + protected function checkIPV4Tag($addressLiteral) + { + $matchesIP = array(); + + // Extract IPv4 part from the end of the address-literal (if there is one) + if (preg_match( + '/\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/', + $addressLiteral, + $matchesIP + ) > 0 + ) { + $index = strrpos($addressLiteral, $matchesIP[0]); + if ($index === 0) { + $this->warnings[AddressLiteral::CODE] = new AddressLiteral(); + return false; + } + // Convert IPv4 part to IPv6 format for further testing + $addressLiteral = substr($addressLiteral, 0, (int) $index) . '0:0'; + } + + return $addressLiteral; + } + + protected function checkDomainPartExceptions(array $prev) + { + $invalidDomainTokens = array( + EmailLexer::S_DQUOTE => true, + EmailLexer::S_SQUOTE => true, + EmailLexer::S_BACKTICK => true, + EmailLexer::S_SEMICOLON => true, + EmailLexer::S_GREATERTHAN => true, + EmailLexer::S_LOWERTHAN => true, + ); + + if (isset($invalidDomainTokens[$this->lexer->token['type']])) { + throw new ExpectingATEXT(); + } + + if ($this->lexer->token['type'] === EmailLexer::S_COMMA) { + throw new CommaInDomain(); + } + + if ($this->lexer->token['type'] === EmailLexer::S_AT) { + throw new ConsecutiveAt(); + } + + if ($this->lexer->token['type'] === EmailLexer::S_OPENQBRACKET && $prev['type'] !== EmailLexer::S_AT) { + throw new ExpectingATEXT(); + } + + if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN && $this->lexer->isNextToken(EmailLexer::S_DOT)) { + throw new DomainHyphened(); + } + + if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH + && $this->lexer->isNextToken(EmailLexer::GENERIC)) { + throw new ExpectingATEXT(); + } + } + + /** + * @return bool + */ + protected function hasBrackets() + { + if ($this->lexer->token['type'] !== EmailLexer::S_OPENBRACKET) { + return false; + } + + try { + $this->lexer->find(EmailLexer::S_CLOSEBRACKET); + } catch (\RuntimeException $e) { + throw new ExpectingDomainLiteralClose(); + } + + return true; + } + + /** + * @param string $label + */ + protected function checkLabelLength($label) + { + if ($this->isLabelTooLong($label)) { + $this->warnings[LabelTooLong::CODE] = new LabelTooLong(); + } + } + + /** + * @param string $label + * @return bool + */ + private function isLabelTooLong($label) + { + if (preg_match('/[^\x00-\x7F]/', $label)) { + idn_to_ascii($label, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46, $idnaInfo); + + return (bool) ($idnaInfo['errors'] & IDNA_ERROR_LABEL_TOO_LONG); + } + + return strlen($label) > self::LABEL_MAX_LENGTH; + } + + protected function parseDomainComments() + { + $this->isUnclosedComment(); + while (!$this->lexer->isNextToken(EmailLexer::S_CLOSEPARENTHESIS)) { + $this->warnEscaping(); + $this->lexer->moveNext(); + } + + $this->lexer->moveNext(); + if ($this->lexer->isNextToken(EmailLexer::S_DOT)) { + throw new ExpectingATEXT(); + } + } + + protected function addTLDWarnings() + { + if ($this->warnings[DomainLiteral::CODE]) { + $this->warnings[TLD::CODE] = new TLD(); + } + } } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Parser/LocalPart.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Parser/LocalPart.php index b804b412863..3c21f34ac07 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Parser/LocalPart.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Parser/LocalPart.php @@ -14,132 +14,132 @@ use Egulias\EmailValidator\Warning\LocalTooLong; class LocalPart extends Parser { - public function parse($localPart) - { - $parseDQuote = true; - $closingQuote = false; - $openedParenthesis = 0; - $totalLength = 0; + public function parse($localPart) + { + $parseDQuote = true; + $closingQuote = false; + $openedParenthesis = 0; + $totalLength = 0; - while ($this->lexer->token['type'] !== EmailLexer::S_AT && null !== $this->lexer->token['type']) { - if ($this->lexer->token['type'] === EmailLexer::S_DOT && null === $this->lexer->getPrevious()['type']) { - throw new DotAtStart(); - } + while ($this->lexer->token['type'] !== EmailLexer::S_AT && null !== $this->lexer->token['type']) { + if ($this->lexer->token['type'] === EmailLexer::S_DOT && null === $this->lexer->getPrevious()['type']) { + throw new DotAtStart(); + } - $closingQuote = $this->checkDQUOTE($closingQuote); - if ($closingQuote && $parseDQuote) { - $parseDQuote = $this->parseDoubleQuote(); - } + $closingQuote = $this->checkDQUOTE($closingQuote); + if ($closingQuote && $parseDQuote) { + $parseDQuote = $this->parseDoubleQuote(); + } - if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) { - $this->parseComments(); - $openedParenthesis += $this->getOpenedParenthesis(); - } + if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) { + $this->parseComments(); + $openedParenthesis += $this->getOpenedParenthesis(); + } - if ($this->lexer->token['type'] === EmailLexer::S_CLOSEPARENTHESIS) { - if ($openedParenthesis === 0) { - throw new UnopenedComment(); - } + if ($this->lexer->token['type'] === EmailLexer::S_CLOSEPARENTHESIS) { + if ($openedParenthesis === 0) { + throw new UnopenedComment(); + } - $openedParenthesis--; - } + $openedParenthesis--; + } - $this->checkConsecutiveDots(); + $this->checkConsecutiveDots(); - if ($this->lexer->token['type'] === EmailLexer::S_DOT && - $this->lexer->isNextToken(EmailLexer::S_AT) - ) { - throw new DotAtEnd(); - } + if ($this->lexer->token['type'] === EmailLexer::S_DOT && + $this->lexer->isNextToken(EmailLexer::S_AT) + ) { + throw new DotAtEnd(); + } - $this->warnEscaping(); - $this->isInvalidToken($this->lexer->token, $closingQuote); + $this->warnEscaping(); + $this->isInvalidToken($this->lexer->token, $closingQuote); - if ($this->isFWS()) { - $this->parseFWS(); - } + if ($this->isFWS()) { + $this->parseFWS(); + } - $totalLength += strlen($this->lexer->token['value']); - $this->lexer->moveNext(); - } + $totalLength += strlen($this->lexer->token['value']); + $this->lexer->moveNext(); + } - if ($totalLength > LocalTooLong::LOCAL_PART_LENGTH) { - $this->warnings[LocalTooLong::CODE] = new LocalTooLong(); - } - } + if ($totalLength > LocalTooLong::LOCAL_PART_LENGTH) { + $this->warnings[LocalTooLong::CODE] = new LocalTooLong(); + } + } - /** - * @return bool - */ - protected function parseDoubleQuote() - { - $parseAgain = true; - $special = array( - EmailLexer::S_CR => true, - EmailLexer::S_HTAB => true, - EmailLexer::S_LF => true - ); + /** + * @return bool + */ + protected function parseDoubleQuote() + { + $parseAgain = true; + $special = array( + EmailLexer::S_CR => true, + EmailLexer::S_HTAB => true, + EmailLexer::S_LF => true + ); - $invalid = array( - EmailLexer::C_NUL => true, - EmailLexer::S_HTAB => true, - EmailLexer::S_CR => true, - EmailLexer::S_LF => true - ); - $setSpecialsWarning = true; + $invalid = array( + EmailLexer::C_NUL => true, + EmailLexer::S_HTAB => true, + EmailLexer::S_CR => true, + EmailLexer::S_LF => true + ); + $setSpecialsWarning = true; - $this->lexer->moveNext(); + $this->lexer->moveNext(); - while ($this->lexer->token['type'] !== EmailLexer::S_DQUOTE && null !== $this->lexer->token['type']) { - $parseAgain = false; - if (isset($special[$this->lexer->token['type']]) && $setSpecialsWarning) { - $this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS(); - $setSpecialsWarning = false; - } - if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH && $this->lexer->isNextToken(EmailLexer::S_DQUOTE)) { - $this->lexer->moveNext(); - } + while ($this->lexer->token['type'] !== EmailLexer::S_DQUOTE && null !== $this->lexer->token['type']) { + $parseAgain = false; + if (isset($special[$this->lexer->token['type']]) && $setSpecialsWarning) { + $this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS(); + $setSpecialsWarning = false; + } + if ($this->lexer->token['type'] === EmailLexer::S_BACKSLASH && $this->lexer->isNextToken(EmailLexer::S_DQUOTE)) { + $this->lexer->moveNext(); + } - $this->lexer->moveNext(); + $this->lexer->moveNext(); - if (!$this->escaped() && isset($invalid[$this->lexer->token['type']])) { - throw new ExpectingATEXT(); - } - } + if (!$this->escaped() && isset($invalid[$this->lexer->token['type']])) { + throw new ExpectingATEXT(); + } + } - $prev = $this->lexer->getPrevious(); + $prev = $this->lexer->getPrevious(); - if ($prev['type'] === EmailLexer::S_BACKSLASH) { - if (!$this->checkDQUOTE(false)) { - throw new UnclosedQuotedString(); - } - } + if ($prev['type'] === EmailLexer::S_BACKSLASH) { + if (!$this->checkDQUOTE(false)) { + throw new UnclosedQuotedString(); + } + } - if (!$this->lexer->isNextToken(EmailLexer::S_AT) && $prev['type'] !== EmailLexer::S_BACKSLASH) { - throw new ExpectingAT(); - } + if (!$this->lexer->isNextToken(EmailLexer::S_AT) && $prev['type'] !== EmailLexer::S_BACKSLASH) { + throw new ExpectingAT(); + } - return $parseAgain; - } + return $parseAgain; + } - /** - * @param bool $closingQuote - */ - protected function isInvalidToken(array $token, $closingQuote) - { - $forbidden = array( - EmailLexer::S_COMMA, - EmailLexer::S_CLOSEBRACKET, - EmailLexer::S_OPENBRACKET, - EmailLexer::S_GREATERTHAN, - EmailLexer::S_LOWERTHAN, - EmailLexer::S_COLON, - EmailLexer::S_SEMICOLON, - EmailLexer::INVALID - ); + /** + * @param bool $closingQuote + */ + protected function isInvalidToken(array $token, $closingQuote) + { + $forbidden = array( + EmailLexer::S_COMMA, + EmailLexer::S_CLOSEBRACKET, + EmailLexer::S_OPENBRACKET, + EmailLexer::S_GREATERTHAN, + EmailLexer::S_LOWERTHAN, + EmailLexer::S_COLON, + EmailLexer::S_SEMICOLON, + EmailLexer::INVALID + ); - if (in_array($token['type'], $forbidden) && !$closingQuote) { - throw new ExpectingATEXT(); - } - } + if (in_array($token['type'], $forbidden) && !$closingQuote) { + throw new ExpectingATEXT(); + } + } } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Parser/Parser.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Parser/Parser.php index 9ebb95ae0a0..ccdc93889a2 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Parser/Parser.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Parser/Parser.php @@ -21,228 +21,229 @@ use Egulias\EmailValidator\Warning\QuotedString; abstract class Parser { - /** - * @var array - */ - protected $warnings = []; + /** + * @var array + */ + protected $warnings = []; - /** - * @var EmailLexer - */ - protected $lexer; + /** + * @var EmailLexer + */ + protected $lexer; - /** - * @var int - */ - protected $openedParenthesis = 0; + /** + * @var int + */ + protected $openedParenthesis = 0; - public function __construct(EmailLexer $lexer) - { - $this->lexer = $lexer; - } + public function __construct(EmailLexer $lexer) + { + $this->lexer = $lexer; + } - /** - * @return \Egulias\EmailValidator\Warning\Warning[] - */ - public function getWarnings() - { - return $this->warnings; - } + /** + * @return \Egulias\EmailValidator\Warning\Warning[] + */ + public function getWarnings() + { + return $this->warnings; + } - /** - * @param string $str - */ - abstract public function parse($str); + /** + * @param string $str + */ + abstract public function parse($str); - /** @return int */ - public function getOpenedParenthesis() - { - return $this->openedParenthesis; - } + /** @return int */ + public function getOpenedParenthesis() + { + return $this->openedParenthesis; + } - /** - * validateQuotedPair - */ - protected function validateQuotedPair() - { - if (!($this->lexer->token['type'] === EmailLexer::INVALID - || $this->lexer->token['type'] === EmailLexer::C_DEL)) { - throw new ExpectingQPair(); - } + /** + * validateQuotedPair + */ + protected function validateQuotedPair() + { + if (!($this->lexer->token['type'] === EmailLexer::INVALID + || $this->lexer->token['type'] === EmailLexer::C_DEL)) { + throw new ExpectingQPair(); + } - $this->warnings[QuotedPart::CODE] = - new QuotedPart($this->lexer->getPrevious()['type'], $this->lexer->token['type']); - } + $this->warnings[QuotedPart::CODE] = + new QuotedPart($this->lexer->getPrevious()['type'], $this->lexer->token['type']); + } - protected function parseComments() - { - $this->openedParenthesis = 1; - $this->isUnclosedComment(); - $this->warnings[Comment::CODE] = new Comment(); - while (!$this->lexer->isNextToken(EmailLexer::S_CLOSEPARENTHESIS)) { - if ($this->lexer->isNextToken(EmailLexer::S_OPENPARENTHESIS)) { - $this->openedParenthesis++; - } - $this->warnEscaping(); - $this->lexer->moveNext(); - } + protected function parseComments() + { + $this->openedParenthesis = 1; + $this->isUnclosedComment(); + $this->warnings[Comment::CODE] = new Comment(); + while (!$this->lexer->isNextToken(EmailLexer::S_CLOSEPARENTHESIS)) { + if ($this->lexer->isNextToken(EmailLexer::S_OPENPARENTHESIS)) { + $this->openedParenthesis++; + } + $this->warnEscaping(); + $this->lexer->moveNext(); + } - $this->lexer->moveNext(); - if ($this->lexer->isNextTokenAny(array(EmailLexer::GENERIC, EmailLexer::S_EMPTY))) { - throw new ExpectingATEXT(); - } + $this->lexer->moveNext(); + if ($this->lexer->isNextTokenAny(array(EmailLexer::GENERIC, EmailLexer::S_EMPTY))) { + throw new ExpectingATEXT(); + } - if ($this->lexer->isNextToken(EmailLexer::S_AT)) { - $this->warnings[CFWSNearAt::CODE] = new CFWSNearAt(); - } - } + if ($this->lexer->isNextToken(EmailLexer::S_AT)) { + $this->warnings[CFWSNearAt::CODE] = new CFWSNearAt(); + } + } - /** - * @return bool - */ - protected function isUnclosedComment() - { - try { - $this->lexer->find(EmailLexer::S_CLOSEPARENTHESIS); - return true; - } catch (\RuntimeException $e) { - throw new UnclosedComment(); - } - } + /** + * @return bool + */ + protected function isUnclosedComment() + { + try { + $this->lexer->find(EmailLexer::S_CLOSEPARENTHESIS); + return true; + } catch (\RuntimeException $e) { + throw new UnclosedComment(); + } + } - protected function parseFWS() - { - $previous = $this->lexer->getPrevious(); + protected function parseFWS() + { + $previous = $this->lexer->getPrevious(); - $this->checkCRLFInFWS(); + $this->checkCRLFInFWS(); - if ($this->lexer->token['type'] === EmailLexer::S_CR) { - throw new CRNoLF(); - } + if ($this->lexer->token['type'] === EmailLexer::S_CR) { + throw new CRNoLF(); + } - if ($this->lexer->isNextToken(EmailLexer::GENERIC) && $previous['type'] !== EmailLexer::S_AT) { - throw new AtextAfterCFWS(); - } + if ($this->lexer->isNextToken(EmailLexer::GENERIC) && $previous['type'] !== EmailLexer::S_AT) { + throw new AtextAfterCFWS(); + } - if ($this->lexer->token['type'] === EmailLexer::S_LF || $this->lexer->token['type'] === EmailLexer::C_NUL) { - throw new ExpectingCTEXT(); - } + if ($this->lexer->token['type'] === EmailLexer::S_LF || $this->lexer->token['type'] === EmailLexer::C_NUL) { + throw new ExpectingCTEXT(); + } - if ($this->lexer->isNextToken(EmailLexer::S_AT) || $previous['type'] === EmailLexer::S_AT) { - $this->warnings[CFWSNearAt::CODE] = new CFWSNearAt(); - } else { - $this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS(); - } - } + if ($this->lexer->isNextToken(EmailLexer::S_AT) || $previous['type'] === EmailLexer::S_AT) { + $this->warnings[CFWSNearAt::CODE] = new CFWSNearAt(); + } else { + $this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS(); + } + } - protected function checkConsecutiveDots() - { - if ($this->lexer->token['type'] === EmailLexer::S_DOT && $this->lexer->isNextToken(EmailLexer::S_DOT)) { - throw new ConsecutiveDot(); - } - } + protected function checkConsecutiveDots() + { + if ($this->lexer->token['type'] === EmailLexer::S_DOT && $this->lexer->isNextToken(EmailLexer::S_DOT)) { + throw new ConsecutiveDot(); + } + } - /** - * @return bool - */ - protected function isFWS() - { - if ($this->escaped()) { - return false; - } + /** + * @return bool + */ + protected function isFWS() + { + if ($this->escaped()) { + return false; + } - if ($this->lexer->token['type'] === EmailLexer::S_SP || - $this->lexer->token['type'] === EmailLexer::S_HTAB || - $this->lexer->token['type'] === EmailLexer::S_CR || - $this->lexer->token['type'] === EmailLexer::S_LF || - $this->lexer->token['type'] === EmailLexer::CRLF - ) { - return true; - } + if ($this->lexer->token['type'] === EmailLexer::S_SP || + $this->lexer->token['type'] === EmailLexer::S_HTAB || + $this->lexer->token['type'] === EmailLexer::S_CR || + $this->lexer->token['type'] === EmailLexer::S_LF || + $this->lexer->token['type'] === EmailLexer::CRLF + ) { + return true; + } - return false; - } + return false; + } - /** - * @return bool - */ - protected function escaped() - { - $previous = $this->lexer->getPrevious(); + /** + * @return bool + */ + protected function escaped() + { + $previous = $this->lexer->getPrevious(); - if ($previous && $previous['type'] === EmailLexer::S_BACKSLASH - && - $this->lexer->token['type'] !== EmailLexer::GENERIC - ) { - return true; - } + if ($previous && $previous['type'] === EmailLexer::S_BACKSLASH + && + $this->lexer->token['type'] !== EmailLexer::GENERIC + ) { + return true; + } - return false; - } + return false; + } - /** - * @return bool - */ - protected function warnEscaping() - { - if ($this->lexer->token['type'] !== EmailLexer::S_BACKSLASH) { - return false; - } + /** + * @return bool + */ + protected function warnEscaping() + { + if ($this->lexer->token['type'] !== EmailLexer::S_BACKSLASH) { + return false; + } - if ($this->lexer->isNextToken(EmailLexer::GENERIC)) { - throw new ExpectingATEXT(); - } + if ($this->lexer->isNextToken(EmailLexer::GENERIC)) { + throw new ExpectingATEXT(); + } - if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB, EmailLexer::C_DEL))) { - return false; - } + if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB, EmailLexer::C_DEL))) { + return false; + } - $this->warnings[QuotedPart::CODE] = - new QuotedPart($this->lexer->getPrevious()['type'], $this->lexer->token['type']); - return true; - } + $this->warnings[QuotedPart::CODE] = + new QuotedPart($this->lexer->getPrevious()['type'], $this->lexer->token['type']); + return true; - /** - * @param bool $hasClosingQuote - * - * @return bool - */ - protected function checkDQUOTE($hasClosingQuote) - { - if ($this->lexer->token['type'] !== EmailLexer::S_DQUOTE) { - return $hasClosingQuote; - } - if ($hasClosingQuote) { - return $hasClosingQuote; - } - $previous = $this->lexer->getPrevious(); - if ($this->lexer->isNextToken(EmailLexer::GENERIC) && $previous['type'] === EmailLexer::GENERIC) { - throw new ExpectingATEXT(); - } + } - try { - $this->lexer->find(EmailLexer::S_DQUOTE); - $hasClosingQuote = true; - } catch (\Exception $e) { - throw new UnclosedQuotedString(); - } - $this->warnings[QuotedString::CODE] = new QuotedString($previous['value'], $this->lexer->token['value']); + /** + * @param bool $hasClosingQuote + * + * @return bool + */ + protected function checkDQUOTE($hasClosingQuote) + { + if ($this->lexer->token['type'] !== EmailLexer::S_DQUOTE) { + return $hasClosingQuote; + } + if ($hasClosingQuote) { + return $hasClosingQuote; + } + $previous = $this->lexer->getPrevious(); + if ($this->lexer->isNextToken(EmailLexer::GENERIC) && $previous['type'] === EmailLexer::GENERIC) { + throw new ExpectingATEXT(); + } - return $hasClosingQuote; - } + try { + $this->lexer->find(EmailLexer::S_DQUOTE); + $hasClosingQuote = true; + } catch (\Exception $e) { + throw new UnclosedQuotedString(); + } + $this->warnings[QuotedString::CODE] = new QuotedString($previous['value'], $this->lexer->token['value']); - protected function checkCRLFInFWS() - { - if ($this->lexer->token['type'] !== EmailLexer::CRLF) { - return; - } + return $hasClosingQuote; + } - if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB))) { - throw new CRLFX2(); - } + protected function checkCRLFInFWS() + { + if ($this->lexer->token['type'] !== EmailLexer::CRLF) { + return; + } - if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB))) { - throw new CRLFAtTheEnd(); - } - } + if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB))) { + throw new CRLFX2(); + } + + if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB))) { + throw new CRLFAtTheEnd(); + } + } } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/DNSCheckValidation.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/DNSCheckValidation.php index 0d02f11a0a6..491082a590f 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/DNSCheckValidation.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/DNSCheckValidation.php @@ -11,156 +11,156 @@ use Egulias\EmailValidator\Exception\NoDNSRecord; class DNSCheckValidation implements EmailValidation { - /** - * @var array - */ - private $warnings = []; + /** + * @var array + */ + private $warnings = []; - /** - * @var InvalidEmail|null - */ - private $error; + /** + * @var InvalidEmail|null + */ + private $error; - /** - * @var array - */ - private $mxRecords = []; + /** + * @var array + */ + private $mxRecords = []; - public function __construct() - { - if (!function_exists('idn_to_ascii')) { - throw new \LogicException(sprintf('The %s class requires the Intl extension.', __CLASS__)); - } - } + public function __construct() + { + if (!function_exists('idn_to_ascii')) { + throw new \LogicException(sprintf('The %s class requires the Intl extension.', __CLASS__)); + } + } - public function isValid($email, EmailLexer $emailLexer) - { - // use the input to check DNS if we cannot extract something similar to a domain - $host = $email; + public function isValid($email, EmailLexer $emailLexer) + { + // use the input to check DNS if we cannot extract something similar to a domain + $host = $email; - // Arguable pattern to extract the domain. Not aiming to validate the domain nor the email - if (false !== $lastAtPos = strrpos($email, '@')) { - $host = substr($email, $lastAtPos + 1); - } + // Arguable pattern to extract the domain. Not aiming to validate the domain nor the email + if (false !== $lastAtPos = strrpos($email, '@')) { + $host = substr($email, $lastAtPos + 1); + } - // Get the domain parts - $hostParts = explode('.', $host); + // Get the domain parts + $hostParts = explode('.', $host); - // Reserved Top Level DNS Names (https://tools.ietf.org/html/rfc2606#section-2), - // mDNS and private DNS Namespaces (https://tools.ietf.org/html/rfc6762#appendix-G) - $reservedTopLevelDnsNames = [ - // Reserved Top Level DNS Names - 'test', - 'example', - 'invalid', - 'localhost', + // Reserved Top Level DNS Names (https://tools.ietf.org/html/rfc2606#section-2), + // mDNS and private DNS Namespaces (https://tools.ietf.org/html/rfc6762#appendix-G) + $reservedTopLevelDnsNames = [ + // Reserved Top Level DNS Names + 'test', + 'example', + 'invalid', + 'localhost', - // mDNS - 'local', + // mDNS + 'local', - // Private DNS Namespaces - 'intranet', - 'internal', - 'private', - 'corp', - 'home', - 'lan', - ]; + // Private DNS Namespaces + 'intranet', + 'internal', + 'private', + 'corp', + 'home', + 'lan', + ]; - $isLocalDomain = count($hostParts) <= 1; - $isReservedTopLevel = in_array($hostParts[(count($hostParts) - 1)], $reservedTopLevelDnsNames, true); + $isLocalDomain = count($hostParts) <= 1; + $isReservedTopLevel = in_array($hostParts[(count($hostParts) - 1)], $reservedTopLevelDnsNames, true); - // Exclude reserved top level DNS names - if ($isLocalDomain || $isReservedTopLevel) { - $this->error = new LocalOrReservedDomain(); - return false; - } + // Exclude reserved top level DNS names + if ($isLocalDomain || $isReservedTopLevel) { + $this->error = new LocalOrReservedDomain(); + return false; + } - return $this->checkDns($host); - } + return $this->checkDns($host); + } - public function getError() - { - return $this->error; - } + public function getError() + { + return $this->error; + } - public function getWarnings() - { - return $this->warnings; - } + public function getWarnings() + { + return $this->warnings; + } - /** - * @param string $host - * - * @return bool - */ - protected function checkDns($host) - { - $variant = INTL_IDNA_VARIANT_UTS46; + /** + * @param string $host + * + * @return bool + */ + protected function checkDns($host) + { + $variant = INTL_IDNA_VARIANT_UTS46; - $host = rtrim(idn_to_ascii($host, IDNA_DEFAULT, $variant), '.') . '.'; + $host = rtrim(idn_to_ascii($host, IDNA_DEFAULT, $variant), '.') . '.'; - return $this->validateDnsRecords($host); - } + return $this->validateDnsRecords($host); + } - /** - * Validate the DNS records for given host. - * - * @param string $host A set of DNS records in the format returned by dns_get_record. - * - * @return bool True on success. - */ - private function validateDnsRecords($host) - { - // Get all MX, A and AAAA DNS records for host - // Using @ as workaround to fix https://bugs.php.net/bug.php?id=73149 - $dnsRecords = @dns_get_record($host, DNS_MX + DNS_A + DNS_AAAA); + /** + * Validate the DNS records for given host. + * + * @param string $host A set of DNS records in the format returned by dns_get_record. + * + * @return bool True on success. + */ + private function validateDnsRecords($host) + { + // Get all MX, A and AAAA DNS records for host + // Using @ as workaround to fix https://bugs.php.net/bug.php?id=73149 + $dnsRecords = @dns_get_record($host, DNS_MX + DNS_A + DNS_AAAA); - // No MX, A or AAAA DNS records - if (empty($dnsRecords)) { - $this->error = new NoDNSRecord(); - return false; - } + // No MX, A or AAAA DNS records + if (empty($dnsRecords)) { + $this->error = new NoDNSRecord(); + return false; + } - // For each DNS record - foreach ($dnsRecords as $dnsRecord) { - if (!$this->validateMXRecord($dnsRecord)) { - return false; - } - } + // For each DNS record + foreach ($dnsRecords as $dnsRecord) { + if (!$this->validateMXRecord($dnsRecord)) { + return false; + } + } - // No MX records (fallback to A or AAAA records) - if (empty($this->mxRecords)) { - $this->warnings[NoDNSMXRecord::CODE] = new NoDNSMXRecord(); - } + // No MX records (fallback to A or AAAA records) + if (empty($this->mxRecords)) { + $this->warnings[NoDNSMXRecord::CODE] = new NoDNSMXRecord(); + } - return true; - } + return true; + } - /** - * Validate an MX record - * - * @param array $dnsRecord Given DNS record. - * - * @return bool True if valid. - */ - private function validateMxRecord($dnsRecord) - { - if ($dnsRecord['type'] !== 'MX') { - return true; - } + /** + * Validate an MX record + * + * @param array $dnsRecord Given DNS record. + * + * @return bool True if valid. + */ + private function validateMxRecord($dnsRecord) + { + if ($dnsRecord['type'] !== 'MX') { + return true; + } - // "Null MX" record indicates the domain accepts no mail (https://tools.ietf.org/html/rfc7505) - if (empty($dnsRecord['target']) || $dnsRecord['target'] === '.') { - $this->error = new DomainAcceptsNoMail(); - return false; - } + // "Null MX" record indicates the domain accepts no mail (https://tools.ietf.org/html/rfc7505) + if (empty($dnsRecord['target']) || $dnsRecord['target'] === '.') { + $this->error = new DomainAcceptsNoMail(); + return false; + } - $this->mxRecords[] = $dnsRecord; + $this->mxRecords[] = $dnsRecord; - return true; - } + return true; + } } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/Exception/EmptyValidationList.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/Exception/EmptyValidationList.php index 98d0d12a6d1..ee7c41aa033 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/Exception/EmptyValidationList.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/Exception/EmptyValidationList.php @@ -6,11 +6,11 @@ use Exception; class EmptyValidationList extends \InvalidArgumentException { - /** - * @param int $code - */ - public function __construct($code = 0, Exception $previous = null) - { - parent::__construct("Empty validation list is not allowed", $code, $previous); - } + /** + * @param int $code + */ + public function __construct($code = 0, Exception $previous = null) + { + parent::__construct("Empty validation list is not allowed", $code, $previous); + } } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/MultipleErrors.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/MultipleErrors.php index cd10ec7aaf8..3be59732664 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/MultipleErrors.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/MultipleErrors.php @@ -6,27 +6,27 @@ use Egulias\EmailValidator\Exception\InvalidEmail; class MultipleErrors extends InvalidEmail { - const CODE = 999; - const REASON = "Accumulated errors for multiple validations"; - /** - * @var InvalidEmail[] - */ - private $errors = []; + const CODE = 999; + const REASON = "Accumulated errors for multiple validations"; + /** + * @var InvalidEmail[] + */ + private $errors = []; - /** - * @param InvalidEmail[] $errors - */ - public function __construct(array $errors) - { - $this->errors = $errors; - parent::__construct(); - } + /** + * @param InvalidEmail[] $errors + */ + public function __construct(array $errors) + { + $this->errors = $errors; + parent::__construct(); + } - /** - * @return InvalidEmail[] - */ - public function getErrors() - { - return $this->errors; - } + /** + * @return InvalidEmail[] + */ + public function getErrors() + { + return $this->errors; + } } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/MultipleValidationWithAnd.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/MultipleValidationWithAnd.php index 55aad31459b..feb224023da 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/MultipleValidationWithAnd.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/MultipleValidationWithAnd.php @@ -7,118 +7,118 @@ use Egulias\EmailValidator\Validation\Exception\EmptyValidationList; class MultipleValidationWithAnd implements EmailValidation { - /** - * If one of validations gets failure skips all succeeding validation. - * This means MultipleErrors will only contain a single error which first found. - */ - const STOP_ON_ERROR = 0; + /** + * If one of validations gets failure skips all succeeding validation. + * This means MultipleErrors will only contain a single error which first found. + */ + const STOP_ON_ERROR = 0; - /** - * All of validations will be invoked even if one of them got failure. - * So MultipleErrors will contain all causes. - */ - const ALLOW_ALL_ERRORS = 1; + /** + * All of validations will be invoked even if one of them got failure. + * So MultipleErrors will contain all causes. + */ + const ALLOW_ALL_ERRORS = 1; - /** - * @var EmailValidation[] - */ - private $validations = []; + /** + * @var EmailValidation[] + */ + private $validations = []; - /** - * @var array - */ - private $warnings = []; + /** + * @var array + */ + private $warnings = []; - /** - * @var MultipleErrors|null - */ - private $error; + /** + * @var MultipleErrors|null + */ + private $error; - /** - * @var int - */ - private $mode; + /** + * @var int + */ + private $mode; - /** - * @param EmailValidation[] $validations The validations. - * @param int $mode The validation mode (one of the constants). - */ - public function __construct(array $validations, $mode = self::ALLOW_ALL_ERRORS) - { - if (count($validations) == 0) { - throw new EmptyValidationList(); - } + /** + * @param EmailValidation[] $validations The validations. + * @param int $mode The validation mode (one of the constants). + */ + public function __construct(array $validations, $mode = self::ALLOW_ALL_ERRORS) + { + if (count($validations) == 0) { + throw new EmptyValidationList(); + } - $this->validations = $validations; - $this->mode = $mode; - } + $this->validations = $validations; + $this->mode = $mode; + } - /** - * {@inheritdoc} - */ - public function isValid($email, EmailLexer $emailLexer) - { - $result = true; - $errors = []; - foreach ($this->validations as $validation) { - $emailLexer->reset(); - $validationResult = $validation->isValid($email, $emailLexer); - $result = $result && $validationResult; - $this->warnings = array_merge($this->warnings, $validation->getWarnings()); - $errors = $this->addNewError($validation->getError(), $errors); + /** + * {@inheritdoc} + */ + public function isValid($email, EmailLexer $emailLexer) + { + $result = true; + $errors = []; + foreach ($this->validations as $validation) { + $emailLexer->reset(); + $validationResult = $validation->isValid($email, $emailLexer); + $result = $result && $validationResult; + $this->warnings = array_merge($this->warnings, $validation->getWarnings()); + $errors = $this->addNewError($validation->getError(), $errors); - if ($this->shouldStop($result)) { - break; - } - } + if ($this->shouldStop($result)) { + break; + } + } - if (!empty($errors)) { - $this->error = new MultipleErrors($errors); - } + if (!empty($errors)) { + $this->error = new MultipleErrors($errors); + } - return $result; - } + return $result; + } - /** - * @param \Egulias\EmailValidator\Exception\InvalidEmail|null $possibleError - * @param \Egulias\EmailValidator\Exception\InvalidEmail[] $errors - * - * @return \Egulias\EmailValidator\Exception\InvalidEmail[] - */ - private function addNewError($possibleError, array $errors) - { - if (null !== $possibleError) { - $errors[] = $possibleError; - } + /** + * @param \Egulias\EmailValidator\Exception\InvalidEmail|null $possibleError + * @param \Egulias\EmailValidator\Exception\InvalidEmail[] $errors + * + * @return \Egulias\EmailValidator\Exception\InvalidEmail[] + */ + private function addNewError($possibleError, array $errors) + { + if (null !== $possibleError) { + $errors[] = $possibleError; + } - return $errors; - } + return $errors; + } - /** - * @param bool $result - * - * @return bool - */ - private function shouldStop($result) - { - return !$result && $this->mode === self::STOP_ON_ERROR; - } + /** + * @param bool $result + * + * @return bool + */ + private function shouldStop($result) + { + return !$result && $this->mode === self::STOP_ON_ERROR; + } - /** - * Returns the validation errors. - * - * @return MultipleErrors|null - */ - public function getError() - { - return $this->error; - } + /** + * Returns the validation errors. + * + * @return MultipleErrors|null + */ + public function getError() + { + return $this->error; + } - /** - * {@inheritdoc} - */ - public function getWarnings() - { - return $this->warnings; - } + /** + * {@inheritdoc} + */ + public function getWarnings() + { + return $this->warnings; + } } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/NoRFCWarningsValidation.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/NoRFCWarningsValidation.php index b7b3bb90910..6b31e5440ec 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/NoRFCWarningsValidation.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/NoRFCWarningsValidation.php @@ -8,34 +8,34 @@ use Egulias\EmailValidator\Validation\Error\RFCWarnings; class NoRFCWarningsValidation extends RFCValidation { - /** - * @var InvalidEmail|null - */ - private $error; + /** + * @var InvalidEmail|null + */ + private $error; - /** - * {@inheritdoc} - */ - public function isValid($email, EmailLexer $emailLexer) - { - if (!parent::isValid($email, $emailLexer)) { - return false; - } + /** + * {@inheritdoc} + */ + public function isValid($email, EmailLexer $emailLexer) + { + if (!parent::isValid($email, $emailLexer)) { + return false; + } - if (empty($this->getWarnings())) { - return true; - } + if (empty($this->getWarnings())) { + return true; + } - $this->error = new RFCWarnings(); + $this->error = new RFCWarnings(); - return false; - } + return false; + } - /** - * {@inheritdoc} - */ - public function getError() - { - return $this->error ?: parent::getError(); - } + /** + * {@inheritdoc} + */ + public function getError() + { + return $this->error ?: parent::getError(); + } } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/RFCValidation.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/RFCValidation.php index 813da231844..8781e0b62d1 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/RFCValidation.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/RFCValidation.php @@ -8,42 +8,42 @@ use Egulias\EmailValidator\Exception\InvalidEmail; class RFCValidation implements EmailValidation { - /** - * @var EmailParser|null - */ - private $parser; + /** + * @var EmailParser|null + */ + private $parser; - /** - * @var array - */ - private $warnings = []; + /** + * @var array + */ + private $warnings = []; - /** - * @var InvalidEmail|null - */ - private $error; + /** + * @var InvalidEmail|null + */ + private $error; - public function isValid($email, EmailLexer $emailLexer) - { - $this->parser = new EmailParser($emailLexer); - try { - $this->parser->parse((string) $email); - } catch (InvalidEmail $invalid) { - $this->error = $invalid; - return false; - } + public function isValid($email, EmailLexer $emailLexer) + { + $this->parser = new EmailParser($emailLexer); + try { + $this->parser->parse((string)$email); + } catch (InvalidEmail $invalid) { + $this->error = $invalid; + return false; + } - $this->warnings = $this->parser->getWarnings(); - return true; - } + $this->warnings = $this->parser->getWarnings(); + return true; + } - public function getError() - { - return $this->error; - } + public function getError() + { + return $this->error; + } - public function getWarnings() - { - return $this->warnings; - } + public function getWarnings() + { + return $this->warnings; + } } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/SpoofCheckValidation.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/SpoofCheckValidation.php index 65c017a3ce2..e10bfabd92f 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/SpoofCheckValidation.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/SpoofCheckValidation.php @@ -9,43 +9,43 @@ use \Spoofchecker; class SpoofCheckValidation implements EmailValidation { - /** - * @var InvalidEmail|null - */ - private $error; + /** + * @var InvalidEmail|null + */ + private $error; - public function __construct() - { - if (!extension_loaded('intl')) { - throw new \LogicException(sprintf('The %s class requires the Intl extension.', __CLASS__)); - } - } + public function __construct() + { + if (!extension_loaded('intl')) { + throw new \LogicException(sprintf('The %s class requires the Intl extension.', __CLASS__)); + } + } - /** - * @psalm-suppress InvalidArgument - */ - public function isValid($email, EmailLexer $emailLexer) - { - $checker = new Spoofchecker(); - $checker->setChecks(Spoofchecker::SINGLE_SCRIPT); + /** + * @psalm-suppress InvalidArgument + */ + public function isValid($email, EmailLexer $emailLexer) + { + $checker = new Spoofchecker(); + $checker->setChecks(Spoofchecker::SINGLE_SCRIPT); - if ($checker->isSuspicious($email)) { - $this->error = new SpoofEmail(); - } + if ($checker->isSuspicious($email)) { + $this->error = new SpoofEmail(); + } - return $this->error === null; - } + return $this->error === null; + } - /** - * @return InvalidEmail|null - */ - public function getError() - { - return $this->error; - } + /** + * @return InvalidEmail|null + */ + public function getError() + { + return $this->error; + } - public function getWarnings() - { - return []; - } + public function getWarnings() + { + return []; + } } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/QuotedPart.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/QuotedPart.php index dd2cf28d0d8..36a4265a515 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/QuotedPart.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/QuotedPart.php @@ -4,14 +4,14 @@ namespace Egulias\EmailValidator\Warning; class QuotedPart extends Warning { - const CODE = 36; + const CODE = 36; - /** - * @param scalar $prevToken - * @param scalar $postToken - */ - public function __construct($prevToken, $postToken) - { - $this->message = "Deprecated Quoted String found between $prevToken and $postToken"; - } + /** + * @param scalar $prevToken + * @param scalar $postToken + */ + public function __construct($prevToken, $postToken) + { + $this->message = "Deprecated Quoted String found between $prevToken and $postToken"; + } } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/QuotedString.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/QuotedString.php index d1f99b905c6..817e4e84b07 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/QuotedString.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/QuotedString.php @@ -4,14 +4,14 @@ namespace Egulias\EmailValidator\Warning; class QuotedString extends Warning { - const CODE = 11; + const CODE = 11; - /** - * @param scalar $prevToken - * @param scalar $postToken - */ - public function __construct($prevToken, $postToken) - { - $this->message = "Quoted String found between $prevToken and $postToken"; - } + /** + * @param scalar $prevToken + * @param scalar $postToken + */ + public function __construct($prevToken, $postToken) + { + $this->message = "Quoted String found between $prevToken and $postToken"; + } } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/Warning.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/Warning.php index 0ecd5ab9244..a2ee7b0de1e 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/Warning.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/Warning.php @@ -4,44 +4,44 @@ namespace Egulias\EmailValidator\Warning; abstract class Warning { - const CODE = 0; + const CODE = 0; - /** - * @var string - */ - protected $message = ''; + /** + * @var string + */ + protected $message = ''; - /** - * @var int - */ - protected $rfcNumber = 0; + /** + * @var int + */ + protected $rfcNumber = 0; - /** - * @return string - */ - public function message() - { - return $this->message; - } + /** + * @return string + */ + public function message() + { + return $this->message; + } - /** - * @return int - */ - public function code() - { - return static::CODE; - } + /** + * @return int + */ + public function code() + { + return static::CODE; + } - /** - * @return int - */ - public function RFCNumber() - { - return $this->rfcNumber; - } + /** + * @return int + */ + public function RFCNumber() + { + return $this->rfcNumber; + } - public function __toString() - { - return $this->message() . " rfc: " . $this->rfcNumber . "interal code: " . static::CODE; - } + public function __toString() + { + return $this->message() . " rfc: " . $this->rfcNumber . "interal code: " . static::CODE; + } } diff --git a/htdocs/includes/swiftmailer/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php b/htdocs/includes/swiftmailer/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php index a561a6678f9..dd3ea768e3b 100644 --- a/htdocs/includes/swiftmailer/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php +++ b/htdocs/includes/swiftmailer/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php @@ -29,304 +29,304 @@ namespace Doctrine\Common\Lexer; */ abstract class AbstractLexer { - /** - * Lexer original input string. - * - * @var string - */ - private $input; + /** + * Lexer original input string. + * + * @var string + */ + private $input; - /** - * Array of scanned tokens. - * - * Each token is an associative array containing three items: - * - 'value' : the string value of the token in the input string - * - 'type' : the type of the token (identifier, numeric, string, input - * parameter, none) - * - 'position' : the position of the token in the input string - * - * @var array - */ - private $tokens = array(); + /** + * Array of scanned tokens. + * + * Each token is an associative array containing three items: + * - 'value' : the string value of the token in the input string + * - 'type' : the type of the token (identifier, numeric, string, input + * parameter, none) + * - 'position' : the position of the token in the input string + * + * @var array + */ + private $tokens = array(); - /** - * Current lexer position in input string. - * - * @var integer - */ - private $position = 0; + /** + * Current lexer position in input string. + * + * @var integer + */ + private $position = 0; - /** - * Current peek of current lexer position. - * - * @var integer - */ - private $peek = 0; + /** + * Current peek of current lexer position. + * + * @var integer + */ + private $peek = 0; - /** - * The next token in the input. - * - * @var array - */ - public $lookahead; + /** + * The next token in the input. + * + * @var array + */ + public $lookahead; - /** - * The last matched/seen token. - * - * @var array - */ - public $token; + /** + * The last matched/seen token. + * + * @var array + */ + public $token; - /** - * Sets the input data to be tokenized. - * - * The Lexer is immediately reset and the new input tokenized. - * Any unprocessed tokens from any previous input are lost. - * - * @param string $input The input to be tokenized. - * - * @return void - */ - public function setInput($input) - { - $this->input = $input; - $this->tokens = array(); + /** + * Sets the input data to be tokenized. + * + * The Lexer is immediately reset and the new input tokenized. + * Any unprocessed tokens from any previous input are lost. + * + * @param string $input The input to be tokenized. + * + * @return void + */ + public function setInput($input) + { + $this->input = $input; + $this->tokens = array(); - $this->reset(); - $this->scan($input); - } + $this->reset(); + $this->scan($input); + } - /** - * Resets the lexer. - * - * @return void - */ - public function reset() - { - $this->lookahead = null; - $this->token = null; - $this->peek = 0; - $this->position = 0; - } + /** + * Resets the lexer. + * + * @return void + */ + public function reset() + { + $this->lookahead = null; + $this->token = null; + $this->peek = 0; + $this->position = 0; + } - /** - * Resets the peek pointer to 0. - * - * @return void - */ - public function resetPeek() - { - $this->peek = 0; - } + /** + * Resets the peek pointer to 0. + * + * @return void + */ + public function resetPeek() + { + $this->peek = 0; + } - /** - * Resets the lexer position on the input to the given position. - * - * @param integer $position Position to place the lexical scanner. - * - * @return void - */ - public function resetPosition($position = 0) - { - $this->position = $position; - } + /** + * Resets the lexer position on the input to the given position. + * + * @param integer $position Position to place the lexical scanner. + * + * @return void + */ + public function resetPosition($position = 0) + { + $this->position = $position; + } - /** - * Retrieve the original lexer's input until a given position. - * - * @param integer $position - * - * @return string - */ - public function getInputUntilPosition($position) - { - return substr($this->input, 0, $position); - } + /** + * Retrieve the original lexer's input until a given position. + * + * @param integer $position + * + * @return string + */ + public function getInputUntilPosition($position) + { + return substr($this->input, 0, $position); + } - /** - * Checks whether a given token matches the current lookahead. - * - * @param integer|string $token - * - * @return boolean - */ - public function isNextToken($token) - { - return null !== $this->lookahead && $this->lookahead['type'] === $token; - } + /** + * Checks whether a given token matches the current lookahead. + * + * @param integer|string $token + * + * @return boolean + */ + public function isNextToken($token) + { + return null !== $this->lookahead && $this->lookahead['type'] === $token; + } - /** - * Checks whether any of the given tokens matches the current lookahead. - * - * @param array $tokens - * - * @return boolean - */ - public function isNextTokenAny(array $tokens) - { - return null !== $this->lookahead && in_array($this->lookahead['type'], $tokens, true); - } + /** + * Checks whether any of the given tokens matches the current lookahead. + * + * @param array $tokens + * + * @return boolean + */ + public function isNextTokenAny(array $tokens) + { + return null !== $this->lookahead && in_array($this->lookahead['type'], $tokens, true); + } - /** - * Moves to the next token in the input string. - * - * @return boolean - */ - public function moveNext() - { - $this->peek = 0; - $this->token = $this->lookahead; - $this->lookahead = (isset($this->tokens[$this->position])) - ? $this->tokens[$this->position++] : null; + /** + * Moves to the next token in the input string. + * + * @return boolean + */ + public function moveNext() + { + $this->peek = 0; + $this->token = $this->lookahead; + $this->lookahead = (isset($this->tokens[$this->position])) + ? $this->tokens[$this->position++] : null; - return $this->lookahead !== null; - } + return $this->lookahead !== null; + } - /** - * Tells the lexer to skip input tokens until it sees a token with the given value. - * - * @param string $type The token type to skip until. - * - * @return void - */ - public function skipUntil($type) - { - while ($this->lookahead !== null && $this->lookahead['type'] !== $type) { - $this->moveNext(); - } - } + /** + * Tells the lexer to skip input tokens until it sees a token with the given value. + * + * @param string $type The token type to skip until. + * + * @return void + */ + public function skipUntil($type) + { + while ($this->lookahead !== null && $this->lookahead['type'] !== $type) { + $this->moveNext(); + } + } - /** - * Checks if given value is identical to the given token. - * - * @param mixed $value - * @param integer $token - * - * @return boolean - */ - public function isA($value, $token) - { - return $this->getType($value) === $token; - } + /** + * Checks if given value is identical to the given token. + * + * @param mixed $value + * @param integer $token + * + * @return boolean + */ + public function isA($value, $token) + { + return $this->getType($value) === $token; + } - /** - * Moves the lookahead token forward. - * - * @return array|null The next token or NULL if there are no more tokens ahead. - */ - public function peek() - { - if (isset($this->tokens[$this->position + $this->peek])) { - return $this->tokens[$this->position + $this->peek++]; - } else { - return null; - } - } + /** + * Moves the lookahead token forward. + * + * @return array|null The next token or NULL if there are no more tokens ahead. + */ + public function peek() + { + if (isset($this->tokens[$this->position + $this->peek])) { + return $this->tokens[$this->position + $this->peek++]; + } else { + return null; + } + } - /** - * Peeks at the next token, returns it and immediately resets the peek. - * - * @return array|null The next token or NULL if there are no more tokens ahead. - */ - public function glimpse() - { - $peek = $this->peek(); - $this->peek = 0; - return $peek; - } + /** + * Peeks at the next token, returns it and immediately resets the peek. + * + * @return array|null The next token or NULL if there are no more tokens ahead. + */ + public function glimpse() + { + $peek = $this->peek(); + $this->peek = 0; + return $peek; + } - /** - * Scans the input string for tokens. - * - * @param string $input A query string. - * - * @return void - */ - protected function scan($input) - { - static $regex; + /** + * Scans the input string for tokens. + * + * @param string $input A query string. + * + * @return void + */ + protected function scan($input) + { + static $regex; - if ( ! isset($regex)) { - $regex = sprintf( - '/(%s)|%s/%s', - implode(')|(', $this->getCatchablePatterns()), - implode('|', $this->getNonCatchablePatterns()), - $this->getModifiers() - ); - } + if ( ! isset($regex)) { + $regex = sprintf( + '/(%s)|%s/%s', + implode(')|(', $this->getCatchablePatterns()), + implode('|', $this->getNonCatchablePatterns()), + $this->getModifiers() + ); + } - $flags = PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE; - $matches = preg_split($regex, $input, -1, $flags); + $flags = PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE; + $matches = preg_split($regex, $input, -1, $flags); - if (false === $matches) { - // Work around https://bugs.php.net/78122 - $matches = array(array($input, 0)); - } + if (false === $matches) { + // Work around https://bugs.php.net/78122 + $matches = array(array($input, 0)); + } - foreach ($matches as $match) { - // Must remain before 'value' assignment since it can change content - $type = $this->getType($match[0]); + foreach ($matches as $match) { + // Must remain before 'value' assignment since it can change content + $type = $this->getType($match[0]); - $this->tokens[] = array( - 'value' => $match[0], - 'type' => $type, - 'position' => $match[1], - ); - } - } + $this->tokens[] = array( + 'value' => $match[0], + 'type' => $type, + 'position' => $match[1], + ); + } + } - /** - * Gets the literal for a given token. - * - * @param integer $token - * - * @return string - */ - public function getLiteral($token) - { - $className = get_class($this); - $reflClass = new \ReflectionClass($className); - $constants = $reflClass->getConstants(); + /** + * Gets the literal for a given token. + * + * @param integer $token + * + * @return string + */ + public function getLiteral($token) + { + $className = get_class($this); + $reflClass = new \ReflectionClass($className); + $constants = $reflClass->getConstants(); - foreach ($constants as $name => $value) { - if ($value === $token) { - return $className . '::' . $name; - } - } + foreach ($constants as $name => $value) { + if ($value === $token) { + return $className . '::' . $name; + } + } - return $token; - } + return $token; + } - /** - * Regex modifiers - * - * @return string - */ - protected function getModifiers() - { - return 'i'; - } + /** + * Regex modifiers + * + * @return string + */ + protected function getModifiers() + { + return 'i'; + } - /** - * Lexical catchable patterns. - * - * @return array - */ - abstract protected function getCatchablePatterns(); + /** + * Lexical catchable patterns. + * + * @return array + */ + abstract protected function getCatchablePatterns(); - /** - * Lexical non-catchable patterns. - * - * @return array - */ - abstract protected function getNonCatchablePatterns(); + /** + * Lexical non-catchable patterns. + * + * @return array + */ + abstract protected function getNonCatchablePatterns(); - /** - * Retrieve token type. Also processes the token value if necessary. - * - * @param string $value - * - * @return integer - */ - abstract protected function getType(&$value); + /** + * Retrieve token type. Also processes the token value if necessary. + * + * @param string $value + * + * @return integer + */ + abstract protected function getType(&$value); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift.php b/htdocs/includes/swiftmailer/lib/classes/Swift.php index 09cdc4fbefd..51b19c9cb4e 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift.php @@ -15,64 +15,64 @@ */ abstract class Swift { - const VERSION = '6.3.0'; + const VERSION = '6.3.0'; - public static $initialized = false; - public static $inits = []; + public static $initialized = false; + public static $inits = []; - /** - * Registers an initializer callable that will be called the first time - * a SwiftMailer class is autoloaded. - * - * This enables you to tweak the default configuration in a lazy way. - * - * @param mixed $callable A valid PHP callable that will be called when autoloading the first Swift class - */ - public static function init($callable) - { - self::$inits[] = $callable; - } + /** + * Registers an initializer callable that will be called the first time + * a SwiftMailer class is autoloaded. + * + * This enables you to tweak the default configuration in a lazy way. + * + * @param mixed $callable A valid PHP callable that will be called when autoloading the first Swift class + */ + public static function init($callable) + { + self::$inits[] = $callable; + } - /** - * Internal autoloader for spl_autoload_register(). - * - * @param string $class - */ - public static function autoload($class) - { - // Don't interfere with other autoloaders - if (0 !== strpos($class, 'Swift_')) { - return; - } + /** + * Internal autoloader for spl_autoload_register(). + * + * @param string $class + */ + public static function autoload($class) + { + // Don't interfere with other autoloaders + if (0 !== strpos($class, 'Swift_')) { + return; + } - $path = __DIR__.'/'.str_replace('_', '/', $class).'.php'; + $path = __DIR__.'/'.str_replace('_', '/', $class).'.php'; - if (!file_exists($path)) { - return; - } + if (!file_exists($path)) { + return; + } - require $path; + require $path; - if (self::$inits && !self::$initialized) { - self::$initialized = true; - foreach (self::$inits as $init) { - \call_user_func($init); - } - } - } + if (self::$inits && !self::$initialized) { + self::$initialized = true; + foreach (self::$inits as $init) { + \call_user_func($init); + } + } + } - /** - * Configure autoloading using Swift Mailer. - * - * This is designed to play nicely with other autoloaders. - * - * @param mixed $callable A valid PHP callable that will be called when autoloading the first Swift class - */ - public static function registerAutoload($callable = null) - { - if (null !== $callable) { - self::$inits[] = $callable; - } - spl_autoload_register(['Swift', 'autoload']); - } + /** + * Configure autoloading using Swift Mailer. + * + * This is designed to play nicely with other autoloaders. + * + * @param mixed $callable A valid PHP callable that will be called when autoloading the first Swift class + */ + public static function registerAutoload($callable = null) + { + if (null !== $callable) { + self::$inits[] = $callable; + } + spl_autoload_register(['Swift', 'autoload']); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoder.php b/htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoder.php index 643060e12c1..a1704ffb40a 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoder.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoder.php @@ -15,11 +15,11 @@ */ interface Swift_AddressEncoder { - /** - * Encodes an email address. - * - * @throws Swift_AddressEncoderException if the email cannot be represented in - * the encoding implemented by this class - */ - public function encodeString(string $address): string; + /** + * Encodes an email address. + * + * @throws Swift_AddressEncoderException if the email cannot be represented in + * the encoding implemented by this class + */ + public function encodeString(string $address): string; } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoder/IdnAddressEncoder.php b/htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoder/IdnAddressEncoder.php index a00f90efa5e..a373ef9d546 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoder/IdnAddressEncoder.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoder/IdnAddressEncoder.php @@ -24,27 +24,27 @@ */ class Swift_AddressEncoder_IdnAddressEncoder implements Swift_AddressEncoder { - /** - * Encodes the domain part of an address using IDN. - * - * @throws Swift_AddressEncoderException If local-part contains non-ASCII characters - */ - public function encodeString(string $address): string - { - $i = strrpos($address, '@'); - if (false !== $i) { - $local = substr($address, 0, $i); - $domain = substr($address, $i + 1); + /** + * Encodes the domain part of an address using IDN. + * + * @throws Swift_AddressEncoderException If local-part contains non-ASCII characters + */ + public function encodeString(string $address): string + { + $i = strrpos($address, '@'); + if (false !== $i) { + $local = substr($address, 0, $i); + $domain = substr($address, $i + 1); - if (preg_match('/[^\x00-\x7F]/', $local)) { - throw new Swift_AddressEncoderException('Non-ASCII characters not supported in local-part', $address); - } + if (preg_match('/[^\x00-\x7F]/', $local)) { + throw new Swift_AddressEncoderException('Non-ASCII characters not supported in local-part', $address); + } - if (preg_match('/[^\x00-\x7F]/', $domain)) { - $address = sprintf('%s@%s', $local, idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46)); - } - } + if (preg_match('/[^\x00-\x7F]/', $domain)) { + $address = sprintf('%s@%s', $local, idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46)); + } + } - return $address; - } + return $address; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoder/Utf8AddressEncoder.php b/htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoder/Utf8AddressEncoder.php index 29de0f5cc93..1b454305678 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoder/Utf8AddressEncoder.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoder/Utf8AddressEncoder.php @@ -26,11 +26,11 @@ */ class Swift_AddressEncoder_Utf8AddressEncoder implements Swift_AddressEncoder { - /** - * Returns the address verbatimly. - */ - public function encodeString(string $address): string - { - return $address; - } + /** + * Returns the address verbatimly. + */ + public function encodeString(string $address): string + { + return $address; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoderException.php b/htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoderException.php index 7d499f1deaf..9b405476bcb 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoderException.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoderException.php @@ -16,17 +16,17 @@ */ class Swift_AddressEncoderException extends Swift_RfcComplianceException { - protected $address; + protected $address; - public function __construct(string $message, string $address) - { - parent::__construct($message); + public function __construct(string $message, string $address) + { + parent::__construct($message); - $this->address = $address; - } + $this->address = $address; + } - public function getAddress(): string - { - return $this->address; - } + public function getAddress(): string + { + return $this->address; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Attachment.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Attachment.php index f759001ad4e..7a1420f7986 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Attachment.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Attachment.php @@ -15,40 +15,40 @@ */ class Swift_Attachment extends Swift_Mime_Attachment { - /** - * Create a new Attachment. - * - * Details may be optionally provided to the constructor. - * - * @param string|Swift_OutputByteStream $data - * @param string $filename - * @param string $contentType - */ - public function __construct($data = null, $filename = null, $contentType = null) - { - \call_user_func_array( - [$this, 'Swift_Mime_Attachment::__construct'], - Swift_DependencyContainer::getInstance() - ->createDependenciesFor('mime.attachment') - ); + /** + * Create a new Attachment. + * + * Details may be optionally provided to the constructor. + * + * @param string|Swift_OutputByteStream $data + * @param string $filename + * @param string $contentType + */ + public function __construct($data = null, $filename = null, $contentType = null) + { + \call_user_func_array( + [$this, 'Swift_Mime_Attachment::__construct'], + Swift_DependencyContainer::getInstance() + ->createDependenciesFor('mime.attachment') + ); - $this->setBody($data, $contentType); - $this->setFilename($filename); - } + $this->setBody($data, $contentType); + $this->setFilename($filename); + } - /** - * Create a new Attachment from a filesystem path. - * - * @param string $path - * @param string $contentType optional - * - * @return self - */ - public static function fromPath($path, $contentType = null) - { - return (new self())->setFile( - new Swift_ByteStream_FileByteStream($path), - $contentType - ); - } + /** + * Create a new Attachment from a filesystem path. + * + * @param string $path + * @param string $contentType optional + * + * @return self + */ + public static function fromPath($path, $contentType = null) + { + return (new self())->setFile( + new Swift_ByteStream_FileByteStream($path), + $contentType + ); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php b/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php index 0f7833c3a19..3a69c15f1c4 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php @@ -15,162 +15,162 @@ */ abstract class Swift_ByteStream_AbstractFilterableInputStream implements Swift_InputByteStream, Swift_Filterable { - /** - * Write sequence. - */ - protected $sequence = 0; + /** + * Write sequence. + */ + protected $sequence = 0; - /** - * StreamFilters. - * - * @var Swift_StreamFilter[] - */ - private $filters = []; + /** + * StreamFilters. + * + * @var Swift_StreamFilter[] + */ + private $filters = []; - /** - * A buffer for writing. - */ - private $writeBuffer = ''; + /** + * A buffer for writing. + */ + private $writeBuffer = ''; - /** - * Bound streams. - * - * @var Swift_InputByteStream[] - */ - private $mirrors = []; + /** + * Bound streams. + * + * @var Swift_InputByteStream[] + */ + private $mirrors = []; - /** - * Commit the given bytes to the storage medium immediately. - * - * @param string $bytes - */ - abstract protected function doCommit($bytes); + /** + * Commit the given bytes to the storage medium immediately. + * + * @param string $bytes + */ + abstract protected function doCommit($bytes); - /** - * Flush any buffers/content with immediate effect. - */ - abstract protected function flush(); + /** + * Flush any buffers/content with immediate effect. + */ + abstract protected function flush(); - /** - * Add a StreamFilter to this InputByteStream. - * - * @param string $key - */ - public function addFilter(Swift_StreamFilter $filter, $key) - { - $this->filters[$key] = $filter; - } + /** + * Add a StreamFilter to this InputByteStream. + * + * @param string $key + */ + public function addFilter(Swift_StreamFilter $filter, $key) + { + $this->filters[$key] = $filter; + } - /** - * Remove an already present StreamFilter based on its $key. - * - * @param string $key - */ - public function removeFilter($key) - { - unset($this->filters[$key]); - } + /** + * Remove an already present StreamFilter based on its $key. + * + * @param string $key + */ + public function removeFilter($key) + { + unset($this->filters[$key]); + } - /** - * Writes $bytes to the end of the stream. - * - * @param string $bytes - * - * @throws Swift_IoException - * - * @return int - */ - public function write($bytes) - { - $this->writeBuffer .= $bytes; - foreach ($this->filters as $filter) { - if ($filter->shouldBuffer($this->writeBuffer)) { - return; - } - } - $this->doWrite($this->writeBuffer); + /** + * Writes $bytes to the end of the stream. + * + * @param string $bytes + * + * @throws Swift_IoException + * + * @return int + */ + public function write($bytes) + { + $this->writeBuffer .= $bytes; + foreach ($this->filters as $filter) { + if ($filter->shouldBuffer($this->writeBuffer)) { + return; + } + } + $this->doWrite($this->writeBuffer); - return ++$this->sequence; - } + return ++$this->sequence; + } - /** - * For any bytes that are currently buffered inside the stream, force them - * off the buffer. - * - * @throws Swift_IoException - */ - public function commit() - { - $this->doWrite($this->writeBuffer); - } + /** + * For any bytes that are currently buffered inside the stream, force them + * off the buffer. + * + * @throws Swift_IoException + */ + public function commit() + { + $this->doWrite($this->writeBuffer); + } - /** - * Attach $is to this stream. - * - * The stream acts as an observer, receiving all data that is written. - * All {@link write()} and {@link flushBuffers()} operations will be mirrored. - */ - public function bind(Swift_InputByteStream $is) - { - $this->mirrors[] = $is; - } + /** + * Attach $is to this stream. + * + * The stream acts as an observer, receiving all data that is written. + * All {@link write()} and {@link flushBuffers()} operations will be mirrored. + */ + public function bind(Swift_InputByteStream $is) + { + $this->mirrors[] = $is; + } - /** - * Remove an already bound stream. - * - * If $is is not bound, no errors will be raised. - * If the stream currently has any buffered data it will be written to $is - * before unbinding occurs. - */ - public function unbind(Swift_InputByteStream $is) - { - foreach ($this->mirrors as $k => $stream) { - if ($is === $stream) { - if ('' !== $this->writeBuffer) { - $stream->write($this->writeBuffer); - } - unset($this->mirrors[$k]); - } - } - } + /** + * Remove an already bound stream. + * + * If $is is not bound, no errors will be raised. + * If the stream currently has any buffered data it will be written to $is + * before unbinding occurs. + */ + public function unbind(Swift_InputByteStream $is) + { + foreach ($this->mirrors as $k => $stream) { + if ($is === $stream) { + if ('' !== $this->writeBuffer) { + $stream->write($this->writeBuffer); + } + unset($this->mirrors[$k]); + } + } + } - /** - * Flush the contents of the stream (empty it) and set the internal pointer - * to the beginning. - * - * @throws Swift_IoException - */ - public function flushBuffers() - { - if ('' !== $this->writeBuffer) { - $this->doWrite($this->writeBuffer); - } - $this->flush(); + /** + * Flush the contents of the stream (empty it) and set the internal pointer + * to the beginning. + * + * @throws Swift_IoException + */ + public function flushBuffers() + { + if ('' !== $this->writeBuffer) { + $this->doWrite($this->writeBuffer); + } + $this->flush(); - foreach ($this->mirrors as $stream) { - $stream->flushBuffers(); - } - } + foreach ($this->mirrors as $stream) { + $stream->flushBuffers(); + } + } - /** Run $bytes through all filters */ - private function filter($bytes) - { - foreach ($this->filters as $filter) { - $bytes = $filter->filter($bytes); - } + /** Run $bytes through all filters */ + private function filter($bytes) + { + foreach ($this->filters as $filter) { + $bytes = $filter->filter($bytes); + } - return $bytes; - } + return $bytes; + } - /** Just write the bytes to the stream */ - private function doWrite($bytes) - { - $this->doCommit($this->filter($bytes)); + /** Just write the bytes to the stream */ + private function doWrite($bytes) + { + $this->doCommit($this->filter($bytes)); - foreach ($this->mirrors as $stream) { - $stream->write($bytes); - } + foreach ($this->mirrors as $stream) { + $stream->write($bytes); + } - $this->writeBuffer = ''; - } + $this->writeBuffer = ''; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/ArrayByteStream.php b/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/ArrayByteStream.php index 53d5cef10a0..4f3dcc37745 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/ArrayByteStream.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/ArrayByteStream.php @@ -15,164 +15,164 @@ */ class Swift_ByteStream_ArrayByteStream implements Swift_InputByteStream, Swift_OutputByteStream { - /** - * The internal stack of bytes. - * - * @var string[] - */ - private $array = []; + /** + * The internal stack of bytes. + * + * @var string[] + */ + private $array = []; - /** - * The size of the stack. - * - * @var int - */ - private $arraySize = 0; + /** + * The size of the stack. + * + * @var int + */ + private $arraySize = 0; - /** - * The internal pointer offset. - * - * @var int - */ - private $offset = 0; + /** + * The internal pointer offset. + * + * @var int + */ + private $offset = 0; - /** - * Bound streams. - * - * @var Swift_InputByteStream[] - */ - private $mirrors = []; + /** + * Bound streams. + * + * @var Swift_InputByteStream[] + */ + private $mirrors = []; - /** - * Create a new ArrayByteStream. - * - * If $stack is given the stream will be populated with the bytes it contains. - * - * @param mixed $stack of bytes in string or array form, optional - */ - public function __construct($stack = null) - { - if (\is_array($stack)) { - $this->array = $stack; - $this->arraySize = \count($stack); - } elseif (\is_string($stack)) { - $this->write($stack); - } else { - $this->array = []; - } - } + /** + * Create a new ArrayByteStream. + * + * If $stack is given the stream will be populated with the bytes it contains. + * + * @param mixed $stack of bytes in string or array form, optional + */ + public function __construct($stack = null) + { + if (\is_array($stack)) { + $this->array = $stack; + $this->arraySize = \count($stack); + } elseif (\is_string($stack)) { + $this->write($stack); + } else { + $this->array = []; + } + } - /** - * Reads $length bytes from the stream into a string and moves the pointer - * through the stream by $length. - * - * If less bytes exist than are requested the - * remaining bytes are given instead. If no bytes are remaining at all, boolean - * false is returned. - * - * @param int $length - * - * @return string - */ - public function read($length) - { - if ($this->offset == $this->arraySize) { - return false; - } + /** + * Reads $length bytes from the stream into a string and moves the pointer + * through the stream by $length. + * + * If less bytes exist than are requested the + * remaining bytes are given instead. If no bytes are remaining at all, boolean + * false is returned. + * + * @param int $length + * + * @return string + */ + public function read($length) + { + if ($this->offset == $this->arraySize) { + return false; + } - // Don't use array slice - $end = $length + $this->offset; - $end = $this->arraySize < $end ? $this->arraySize : $end; - $ret = ''; - for (; $this->offset < $end; ++$this->offset) { - $ret .= $this->array[$this->offset]; - } + // Don't use array slice + $end = $length + $this->offset; + $end = $this->arraySize < $end ? $this->arraySize : $end; + $ret = ''; + for (; $this->offset < $end; ++$this->offset) { + $ret .= $this->array[$this->offset]; + } - return $ret; - } + return $ret; + } - /** - * Writes $bytes to the end of the stream. - * - * @param string $bytes - */ - public function write($bytes) - { - $to_add = str_split($bytes); - foreach ($to_add as $value) { - $this->array[] = $value; - } - $this->arraySize = \count($this->array); + /** + * Writes $bytes to the end of the stream. + * + * @param string $bytes + */ + public function write($bytes) + { + $to_add = str_split($bytes); + foreach ($to_add as $value) { + $this->array[] = $value; + } + $this->arraySize = \count($this->array); - foreach ($this->mirrors as $stream) { - $stream->write($bytes); - } - } + foreach ($this->mirrors as $stream) { + $stream->write($bytes); + } + } - /** - * Not used. - */ - public function commit() - { - } + /** + * Not used. + */ + public function commit() + { + } - /** - * Attach $is to this stream. - * - * The stream acts as an observer, receiving all data that is written. - * All {@link write()} and {@link flushBuffers()} operations will be mirrored. - */ - public function bind(Swift_InputByteStream $is) - { - $this->mirrors[] = $is; - } + /** + * Attach $is to this stream. + * + * The stream acts as an observer, receiving all data that is written. + * All {@link write()} and {@link flushBuffers()} operations will be mirrored. + */ + public function bind(Swift_InputByteStream $is) + { + $this->mirrors[] = $is; + } - /** - * Remove an already bound stream. - * - * If $is is not bound, no errors will be raised. - * If the stream currently has any buffered data it will be written to $is - * before unbinding occurs. - */ - public function unbind(Swift_InputByteStream $is) - { - foreach ($this->mirrors as $k => $stream) { - if ($is === $stream) { - unset($this->mirrors[$k]); - } - } - } + /** + * Remove an already bound stream. + * + * If $is is not bound, no errors will be raised. + * If the stream currently has any buffered data it will be written to $is + * before unbinding occurs. + */ + public function unbind(Swift_InputByteStream $is) + { + foreach ($this->mirrors as $k => $stream) { + if ($is === $stream) { + unset($this->mirrors[$k]); + } + } + } - /** - * Move the internal read pointer to $byteOffset in the stream. - * - * @param int $byteOffset - * - * @return bool - */ - public function setReadPointer($byteOffset) - { - if ($byteOffset > $this->arraySize) { - $byteOffset = $this->arraySize; - } elseif ($byteOffset < 0) { - $byteOffset = 0; - } + /** + * Move the internal read pointer to $byteOffset in the stream. + * + * @param int $byteOffset + * + * @return bool + */ + public function setReadPointer($byteOffset) + { + if ($byteOffset > $this->arraySize) { + $byteOffset = $this->arraySize; + } elseif ($byteOffset < 0) { + $byteOffset = 0; + } - $this->offset = $byteOffset; - } + $this->offset = $byteOffset; + } - /** - * Flush the contents of the stream (empty it) and set the internal pointer - * to the beginning. - */ - public function flushBuffers() - { - $this->offset = 0; - $this->array = []; - $this->arraySize = 0; + /** + * Flush the contents of the stream (empty it) and set the internal pointer + * to the beginning. + */ + public function flushBuffers() + { + $this->offset = 0; + $this->array = []; + $this->arraySize = 0; - foreach ($this->mirrors as $stream) { - $stream->flushBuffers(); - } - } + foreach ($this->mirrors as $stream) { + $stream->flushBuffers(); + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/FileByteStream.php b/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/FileByteStream.php index b27d96a1760..f6391219e71 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/FileByteStream.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/FileByteStream.php @@ -15,200 +15,200 @@ */ class Swift_ByteStream_FileByteStream extends Swift_ByteStream_AbstractFilterableInputStream implements Swift_FileStream { - /** The internal pointer offset */ - private $offset = 0; + /** The internal pointer offset */ + private $offset = 0; - /** The path to the file */ - private $path; + /** The path to the file */ + private $path; - /** The mode this file is opened in for writing */ - private $mode; + /** The mode this file is opened in for writing */ + private $mode; - /** A lazy-loaded resource handle for reading the file */ - private $reader; + /** A lazy-loaded resource handle for reading the file */ + private $reader; - /** A lazy-loaded resource handle for writing the file */ - private $writer; + /** A lazy-loaded resource handle for writing the file */ + private $writer; - /** If stream is seekable true/false, or null if not known */ - private $seekable = null; + /** If stream is seekable true/false, or null if not known */ + private $seekable = null; - /** - * Create a new FileByteStream for $path. - * - * @param string $path - * @param bool $writable if true - */ - public function __construct($path, $writable = false) - { - if (empty($path)) { - throw new Swift_IoException('The path cannot be empty'); - } - $this->path = $path; - $this->mode = $writable ? 'w+b' : 'rb'; - } + /** + * Create a new FileByteStream for $path. + * + * @param string $path + * @param bool $writable if true + */ + public function __construct($path, $writable = false) + { + if (empty($path)) { + throw new Swift_IoException('The path cannot be empty'); + } + $this->path = $path; + $this->mode = $writable ? 'w+b' : 'rb'; + } - /** - * Get the complete path to the file. - * - * @return string - */ - public function getPath() - { - return $this->path; - } + /** + * Get the complete path to the file. + * + * @return string + */ + public function getPath() + { + return $this->path; + } - /** - * Reads $length bytes from the stream into a string and moves the pointer - * through the stream by $length. - * - * If less bytes exist than are requested the - * remaining bytes are given instead. If no bytes are remaining at all, boolean - * false is returned. - * - * @param int $length - * - * @return string|bool - * - * @throws Swift_IoException - */ - public function read($length) - { - $fp = $this->getReadHandle(); - if (!feof($fp)) { - $bytes = fread($fp, $length); - $this->offset = ftell($fp); + /** + * Reads $length bytes from the stream into a string and moves the pointer + * through the stream by $length. + * + * If less bytes exist than are requested the + * remaining bytes are given instead. If no bytes are remaining at all, boolean + * false is returned. + * + * @param int $length + * + * @return string|bool + * + * @throws Swift_IoException + */ + public function read($length) + { + $fp = $this->getReadHandle(); + if (!feof($fp)) { + $bytes = fread($fp, $length); + $this->offset = ftell($fp); - // If we read one byte after reaching the end of the file - // feof() will return false and an empty string is returned - if ((false === $bytes || '' === $bytes) && feof($fp)) { - $this->resetReadHandle(); + // If we read one byte after reaching the end of the file + // feof() will return false and an empty string is returned + if ((false === $bytes || '' === $bytes) && feof($fp)) { + $this->resetReadHandle(); - return false; - } + return false; + } - return $bytes; - } + return $bytes; + } - $this->resetReadHandle(); + $this->resetReadHandle(); - return false; - } + return false; + } - /** - * Move the internal read pointer to $byteOffset in the stream. - * - * @param int $byteOffset - * - * @return bool - */ - public function setReadPointer($byteOffset) - { - if (isset($this->reader)) { - $this->seekReadStreamToPosition($byteOffset); - } - $this->offset = $byteOffset; - } + /** + * Move the internal read pointer to $byteOffset in the stream. + * + * @param int $byteOffset + * + * @return bool + */ + public function setReadPointer($byteOffset) + { + if (isset($this->reader)) { + $this->seekReadStreamToPosition($byteOffset); + } + $this->offset = $byteOffset; + } - /** Just write the bytes to the file */ - protected function doCommit($bytes) - { - fwrite($this->getWriteHandle(), $bytes); - $this->resetReadHandle(); - } + /** Just write the bytes to the file */ + protected function doCommit($bytes) + { + fwrite($this->getWriteHandle(), $bytes); + $this->resetReadHandle(); + } - /** Not used */ - protected function flush() - { - } + /** Not used */ + protected function flush() + { + } - /** Get the resource for reading */ - private function getReadHandle() - { - if (!isset($this->reader)) { - $pointer = @fopen($this->path, 'rb'); - if (!$pointer) { - throw new Swift_IoException('Unable to open file for reading ['.$this->path.']'); - } - $this->reader = $pointer; - if (0 != $this->offset) { - $this->getReadStreamSeekableStatus(); - $this->seekReadStreamToPosition($this->offset); - } - } + /** Get the resource for reading */ + private function getReadHandle() + { + if (!isset($this->reader)) { + $pointer = @fopen($this->path, 'rb'); + if (!$pointer) { + throw new Swift_IoException('Unable to open file for reading ['.$this->path.']'); + } + $this->reader = $pointer; + if (0 != $this->offset) { + $this->getReadStreamSeekableStatus(); + $this->seekReadStreamToPosition($this->offset); + } + } - return $this->reader; - } + return $this->reader; + } - /** Get the resource for writing */ - private function getWriteHandle() - { - if (!isset($this->writer)) { - if (!$this->writer = fopen($this->path, $this->mode)) { - throw new Swift_IoException('Unable to open file for writing ['.$this->path.']'); - } - } + /** Get the resource for writing */ + private function getWriteHandle() + { + if (!isset($this->writer)) { + if (!$this->writer = fopen($this->path, $this->mode)) { + throw new Swift_IoException('Unable to open file for writing ['.$this->path.']'); + } + } - return $this->writer; - } + return $this->writer; + } - /** Force a reload of the resource for reading */ - private function resetReadHandle() - { - if (isset($this->reader)) { - fclose($this->reader); - $this->reader = null; - } - } + /** Force a reload of the resource for reading */ + private function resetReadHandle() + { + if (isset($this->reader)) { + fclose($this->reader); + $this->reader = null; + } + } - /** Check if ReadOnly Stream is seekable */ - private function getReadStreamSeekableStatus() - { - $metas = stream_get_meta_data($this->reader); - $this->seekable = $metas['seekable']; - } + /** Check if ReadOnly Stream is seekable */ + private function getReadStreamSeekableStatus() + { + $metas = stream_get_meta_data($this->reader); + $this->seekable = $metas['seekable']; + } - /** Streams in a readOnly stream ensuring copy if needed */ - private function seekReadStreamToPosition($offset) - { - if (null === $this->seekable) { - $this->getReadStreamSeekableStatus(); - } - if (false === $this->seekable) { - $currentPos = ftell($this->reader); - if ($currentPos < $offset) { - $toDiscard = $offset - $currentPos; - fread($this->reader, $toDiscard); + /** Streams in a readOnly stream ensuring copy if needed */ + private function seekReadStreamToPosition($offset) + { + if (null === $this->seekable) { + $this->getReadStreamSeekableStatus(); + } + if (false === $this->seekable) { + $currentPos = ftell($this->reader); + if ($currentPos < $offset) { + $toDiscard = $offset - $currentPos; + fread($this->reader, $toDiscard); - return; - } - $this->copyReadStream(); - } - fseek($this->reader, $offset, SEEK_SET); - } + return; + } + $this->copyReadStream(); + } + fseek($this->reader, $offset, SEEK_SET); + } - /** Copy a readOnly Stream to ensure seekability */ - private function copyReadStream() - { - if ($tmpFile = fopen('php://temp/maxmemory:4096', 'w+b')) { - /* We have opened a php:// Stream Should work without problem */ - } elseif (\function_exists('sys_get_temp_dir') && is_writable(sys_get_temp_dir()) && ($tmpFile = tmpfile())) { - /* We have opened a tmpfile */ - } else { - throw new Swift_IoException('Unable to copy the file to make it seekable, sys_temp_dir is not writable, php://memory not available'); - } - $currentPos = ftell($this->reader); - fclose($this->reader); - $source = fopen($this->path, 'rb'); - if (!$source) { - throw new Swift_IoException('Unable to open file for copying ['.$this->path.']'); - } - fseek($tmpFile, 0, SEEK_SET); - while (!feof($source)) { - fwrite($tmpFile, fread($source, 4096)); - } - fseek($tmpFile, $currentPos, SEEK_SET); - fclose($source); - $this->reader = $tmpFile; - } + /** Copy a readOnly Stream to ensure seekability */ + private function copyReadStream() + { + if ($tmpFile = fopen('php://temp/maxmemory:4096', 'w+b')) { + /* We have opened a php:// Stream Should work without problem */ + } elseif (\function_exists('sys_get_temp_dir') && is_writable(sys_get_temp_dir()) && ($tmpFile = tmpfile())) { + /* We have opened a tmpfile */ + } else { + throw new Swift_IoException('Unable to copy the file to make it seekable, sys_temp_dir is not writable, php://memory not available'); + } + $currentPos = ftell($this->reader); + fclose($this->reader); + $source = fopen($this->path, 'rb'); + if (!$source) { + throw new Swift_IoException('Unable to open file for copying ['.$this->path.']'); + } + fseek($tmpFile, 0, SEEK_SET); + while (!feof($source)) { + fwrite($tmpFile, fread($source, 4096)); + } + fseek($tmpFile, $currentPos, SEEK_SET); + fclose($source); + $this->reader = $tmpFile; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/TemporaryFileByteStream.php b/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/TemporaryFileByteStream.php index 5ea62c5a389..0dc61909d31 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/TemporaryFileByteStream.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/TemporaryFileByteStream.php @@ -13,40 +13,40 @@ */ class Swift_ByteStream_TemporaryFileByteStream extends Swift_ByteStream_FileByteStream { - public function __construct() - { - $filePath = tempnam(sys_get_temp_dir(), 'FileByteStream'); + public function __construct() + { + $filePath = tempnam(sys_get_temp_dir(), 'FileByteStream'); - if (false === $filePath) { - throw new Swift_IoException('Failed to retrieve temporary file name.'); - } + if (false === $filePath) { + throw new Swift_IoException('Failed to retrieve temporary file name.'); + } - parent::__construct($filePath, true); - } + parent::__construct($filePath, true); + } - public function getContent() - { - if (false === ($content = file_get_contents($this->getPath()))) { - throw new Swift_IoException('Failed to get temporary file content.'); - } + public function getContent() + { + if (false === ($content = file_get_contents($this->getPath()))) { + throw new Swift_IoException('Failed to get temporary file content.'); + } - return $content; - } + return $content; + } - public function __destruct() - { - if (file_exists($this->getPath())) { - @unlink($this->getPath()); - } - } + public function __destruct() + { + if (file_exists($this->getPath())) { + @unlink($this->getPath()); + } + } - public function __sleep() - { - throw new \BadMethodCallException('Cannot serialize '.__CLASS__); - } + public function __sleep() + { + throw new \BadMethodCallException('Cannot serialize '.__CLASS__); + } - public function __wakeup() - { - throw new \BadMethodCallException('Cannot unserialize '.__CLASS__); - } + public function __wakeup() + { + throw new \BadMethodCallException('Cannot unserialize '.__CLASS__); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReader/GenericFixedWidthReader.php b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReader/GenericFixedWidthReader.php index 3e074eaf4e9..3e055afd9dc 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReader/GenericFixedWidthReader.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReader/GenericFixedWidthReader.php @@ -16,82 +16,82 @@ */ class Swift_CharacterReader_GenericFixedWidthReader implements Swift_CharacterReader { - /** - * The number of bytes in a single character. - * - * @var int - */ - private $width; + /** + * The number of bytes in a single character. + * + * @var int + */ + private $width; - /** - * Creates a new GenericFixedWidthReader using $width bytes per character. - * - * @param int $width - */ - public function __construct($width) - { - $this->width = $width; - } + /** + * Creates a new GenericFixedWidthReader using $width bytes per character. + * + * @param int $width + */ + public function __construct($width) + { + $this->width = $width; + } - /** - * Returns the complete character map. - * - * @param string $string - * @param int $startOffset - * @param array $currentMap - * @param mixed $ignoredChars - * - * @return int - */ - public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars) - { - $strlen = \strlen($string); - // % and / are CPU intensive, so, maybe find a better way - $ignored = $strlen % $this->width; - $ignoredChars = $ignored ? substr($string, -$ignored) : ''; - $currentMap = $this->width; + /** + * Returns the complete character map. + * + * @param string $string + * @param int $startOffset + * @param array $currentMap + * @param mixed $ignoredChars + * + * @return int + */ + public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars) + { + $strlen = \strlen($string); + // % and / are CPU intensive, so, maybe find a better way + $ignored = $strlen % $this->width; + $ignoredChars = $ignored ? substr($string, -$ignored) : ''; + $currentMap = $this->width; - return ($strlen - $ignored) / $this->width; - } + return ($strlen - $ignored) / $this->width; + } - /** - * Returns the mapType. - * - * @return int - */ - public function getMapType() - { - return self::MAP_TYPE_FIXED_LEN; - } + /** + * Returns the mapType. + * + * @return int + */ + public function getMapType() + { + return self::MAP_TYPE_FIXED_LEN; + } - /** - * Returns an integer which specifies how many more bytes to read. - * - * A positive integer indicates the number of more bytes to fetch before invoking - * this method again. - * - * A value of zero means this is already a valid character. - * A value of -1 means this cannot possibly be a valid character. - * - * @param string $bytes - * @param int $size - * - * @return int - */ - public function validateByteSequence($bytes, $size) - { - $needed = $this->width - $size; + /** + * Returns an integer which specifies how many more bytes to read. + * + * A positive integer indicates the number of more bytes to fetch before invoking + * this method again. + * + * A value of zero means this is already a valid character. + * A value of -1 means this cannot possibly be a valid character. + * + * @param string $bytes + * @param int $size + * + * @return int + */ + public function validateByteSequence($bytes, $size) + { + $needed = $this->width - $size; - return $needed > -1 ? $needed : -1; - } + return $needed > -1 ? $needed : -1; + } - /** - * Returns the number of bytes which should be read to start each character. - * - * @return int - */ - public function getInitialByteSize() - { - return $this->width; - } + /** + * Returns the number of bytes which should be read to start each character. + * + * @return int + */ + public function getInitialByteSize() + { + return $this->width; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReader/UsAsciiReader.php b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReader/UsAsciiReader.php index 7ddc72a6610..ffc05f7166a 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReader/UsAsciiReader.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReader/UsAsciiReader.php @@ -15,70 +15,70 @@ */ class Swift_CharacterReader_UsAsciiReader implements Swift_CharacterReader { - /** - * Returns the complete character map. - * - * @param string $string - * @param int $startOffset - * @param array $currentMap - * @param string $ignoredChars - * - * @return int - */ - public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars) - { - $strlen = \strlen($string); - $ignoredChars = ''; - for ($i = 0; $i < $strlen; ++$i) { - if ($string[$i] > "\x07F") { - // Invalid char - $currentMap[$i + $startOffset] = $string[$i]; - } - } + /** + * Returns the complete character map. + * + * @param string $string + * @param int $startOffset + * @param array $currentMap + * @param string $ignoredChars + * + * @return int + */ + public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars) + { + $strlen = \strlen($string); + $ignoredChars = ''; + for ($i = 0; $i < $strlen; ++$i) { + if ($string[$i] > "\x07F") { + // Invalid char + $currentMap[$i + $startOffset] = $string[$i]; + } + } - return $strlen; - } + return $strlen; + } - /** - * Returns mapType. - * - * @return int mapType - */ - public function getMapType() - { - return self::MAP_TYPE_INVALID; - } + /** + * Returns mapType. + * + * @return int mapType + */ + public function getMapType() + { + return self::MAP_TYPE_INVALID; + } - /** - * Returns an integer which specifies how many more bytes to read. - * - * A positive integer indicates the number of more bytes to fetch before invoking - * this method again. - * A value of zero means this is already a valid character. - * A value of -1 means this cannot possibly be a valid character. - * - * @param string $bytes - * @param int $size - * - * @return int - */ - public function validateByteSequence($bytes, $size) - { - $byte = reset($bytes); - if (1 == \count($bytes) && $byte >= 0x00 && $byte <= 0x7F) { - return 0; - } + /** + * Returns an integer which specifies how many more bytes to read. + * + * A positive integer indicates the number of more bytes to fetch before invoking + * this method again. + * A value of zero means this is already a valid character. + * A value of -1 means this cannot possibly be a valid character. + * + * @param string $bytes + * @param int $size + * + * @return int + */ + public function validateByteSequence($bytes, $size) + { + $byte = reset($bytes); + if (1 == \count($bytes) && $byte >= 0x00 && $byte <= 0x7F) { + return 0; + } - return -1; - } + return -1; + } - /** - * Returns the number of bytes which should be read to start each character. - * - * @return int - */ - public function getInitialByteSize() - { - return 1; - } + /** + * Returns the number of bytes which should be read to start each character. + * + * @return int + */ + public function getInitialByteSize() + { + return 1; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReader/Utf8Reader.php b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReader/Utf8Reader.php index f828f151121..da37e0da9ab 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReader/Utf8Reader.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReader/Utf8Reader.php @@ -16,161 +16,161 @@ */ class Swift_CharacterReader_Utf8Reader implements Swift_CharacterReader { - /** Pre-computed for optimization */ - private static $length_map = [ - // N=0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x0N - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x1N - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x2N - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x3N - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x4N - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x5N - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x6N - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x7N - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x8N - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x9N - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xAN - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xBN - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xCN - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xDN - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 0xEN - 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 0, 0, // 0xFN - ]; + /** Pre-computed for optimization */ + private static $length_map = [ + // N=0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x0N + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x1N + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x2N + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x3N + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x4N + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x5N + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x6N + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x7N + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x8N + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x9N + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xAN + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xBN + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xCN + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xDN + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 0xEN + 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 0, 0, // 0xFN + ]; - private static $s_length_map = [ - "\x00" => 1, "\x01" => 1, "\x02" => 1, "\x03" => 1, "\x04" => 1, "\x05" => 1, "\x06" => 1, "\x07" => 1, - "\x08" => 1, "\x09" => 1, "\x0a" => 1, "\x0b" => 1, "\x0c" => 1, "\x0d" => 1, "\x0e" => 1, "\x0f" => 1, - "\x10" => 1, "\x11" => 1, "\x12" => 1, "\x13" => 1, "\x14" => 1, "\x15" => 1, "\x16" => 1, "\x17" => 1, - "\x18" => 1, "\x19" => 1, "\x1a" => 1, "\x1b" => 1, "\x1c" => 1, "\x1d" => 1, "\x1e" => 1, "\x1f" => 1, - "\x20" => 1, "\x21" => 1, "\x22" => 1, "\x23" => 1, "\x24" => 1, "\x25" => 1, "\x26" => 1, "\x27" => 1, - "\x28" => 1, "\x29" => 1, "\x2a" => 1, "\x2b" => 1, "\x2c" => 1, "\x2d" => 1, "\x2e" => 1, "\x2f" => 1, - "\x30" => 1, "\x31" => 1, "\x32" => 1, "\x33" => 1, "\x34" => 1, "\x35" => 1, "\x36" => 1, "\x37" => 1, - "\x38" => 1, "\x39" => 1, "\x3a" => 1, "\x3b" => 1, "\x3c" => 1, "\x3d" => 1, "\x3e" => 1, "\x3f" => 1, - "\x40" => 1, "\x41" => 1, "\x42" => 1, "\x43" => 1, "\x44" => 1, "\x45" => 1, "\x46" => 1, "\x47" => 1, - "\x48" => 1, "\x49" => 1, "\x4a" => 1, "\x4b" => 1, "\x4c" => 1, "\x4d" => 1, "\x4e" => 1, "\x4f" => 1, - "\x50" => 1, "\x51" => 1, "\x52" => 1, "\x53" => 1, "\x54" => 1, "\x55" => 1, "\x56" => 1, "\x57" => 1, - "\x58" => 1, "\x59" => 1, "\x5a" => 1, "\x5b" => 1, "\x5c" => 1, "\x5d" => 1, "\x5e" => 1, "\x5f" => 1, - "\x60" => 1, "\x61" => 1, "\x62" => 1, "\x63" => 1, "\x64" => 1, "\x65" => 1, "\x66" => 1, "\x67" => 1, - "\x68" => 1, "\x69" => 1, "\x6a" => 1, "\x6b" => 1, "\x6c" => 1, "\x6d" => 1, "\x6e" => 1, "\x6f" => 1, - "\x70" => 1, "\x71" => 1, "\x72" => 1, "\x73" => 1, "\x74" => 1, "\x75" => 1, "\x76" => 1, "\x77" => 1, - "\x78" => 1, "\x79" => 1, "\x7a" => 1, "\x7b" => 1, "\x7c" => 1, "\x7d" => 1, "\x7e" => 1, "\x7f" => 1, - "\x80" => 0, "\x81" => 0, "\x82" => 0, "\x83" => 0, "\x84" => 0, "\x85" => 0, "\x86" => 0, "\x87" => 0, - "\x88" => 0, "\x89" => 0, "\x8a" => 0, "\x8b" => 0, "\x8c" => 0, "\x8d" => 0, "\x8e" => 0, "\x8f" => 0, - "\x90" => 0, "\x91" => 0, "\x92" => 0, "\x93" => 0, "\x94" => 0, "\x95" => 0, "\x96" => 0, "\x97" => 0, - "\x98" => 0, "\x99" => 0, "\x9a" => 0, "\x9b" => 0, "\x9c" => 0, "\x9d" => 0, "\x9e" => 0, "\x9f" => 0, - "\xa0" => 0, "\xa1" => 0, "\xa2" => 0, "\xa3" => 0, "\xa4" => 0, "\xa5" => 0, "\xa6" => 0, "\xa7" => 0, - "\xa8" => 0, "\xa9" => 0, "\xaa" => 0, "\xab" => 0, "\xac" => 0, "\xad" => 0, "\xae" => 0, "\xaf" => 0, - "\xb0" => 0, "\xb1" => 0, "\xb2" => 0, "\xb3" => 0, "\xb4" => 0, "\xb5" => 0, "\xb6" => 0, "\xb7" => 0, - "\xb8" => 0, "\xb9" => 0, "\xba" => 0, "\xbb" => 0, "\xbc" => 0, "\xbd" => 0, "\xbe" => 0, "\xbf" => 0, - "\xc0" => 2, "\xc1" => 2, "\xc2" => 2, "\xc3" => 2, "\xc4" => 2, "\xc5" => 2, "\xc6" => 2, "\xc7" => 2, - "\xc8" => 2, "\xc9" => 2, "\xca" => 2, "\xcb" => 2, "\xcc" => 2, "\xcd" => 2, "\xce" => 2, "\xcf" => 2, - "\xd0" => 2, "\xd1" => 2, "\xd2" => 2, "\xd3" => 2, "\xd4" => 2, "\xd5" => 2, "\xd6" => 2, "\xd7" => 2, - "\xd8" => 2, "\xd9" => 2, "\xda" => 2, "\xdb" => 2, "\xdc" => 2, "\xdd" => 2, "\xde" => 2, "\xdf" => 2, - "\xe0" => 3, "\xe1" => 3, "\xe2" => 3, "\xe3" => 3, "\xe4" => 3, "\xe5" => 3, "\xe6" => 3, "\xe7" => 3, - "\xe8" => 3, "\xe9" => 3, "\xea" => 3, "\xeb" => 3, "\xec" => 3, "\xed" => 3, "\xee" => 3, "\xef" => 3, - "\xf0" => 4, "\xf1" => 4, "\xf2" => 4, "\xf3" => 4, "\xf4" => 4, "\xf5" => 4, "\xf6" => 4, "\xf7" => 4, - "\xf8" => 5, "\xf9" => 5, "\xfa" => 5, "\xfb" => 5, "\xfc" => 6, "\xfd" => 6, "\xfe" => 0, "\xff" => 0, - ]; + private static $s_length_map = [ + "\x00" => 1, "\x01" => 1, "\x02" => 1, "\x03" => 1, "\x04" => 1, "\x05" => 1, "\x06" => 1, "\x07" => 1, + "\x08" => 1, "\x09" => 1, "\x0a" => 1, "\x0b" => 1, "\x0c" => 1, "\x0d" => 1, "\x0e" => 1, "\x0f" => 1, + "\x10" => 1, "\x11" => 1, "\x12" => 1, "\x13" => 1, "\x14" => 1, "\x15" => 1, "\x16" => 1, "\x17" => 1, + "\x18" => 1, "\x19" => 1, "\x1a" => 1, "\x1b" => 1, "\x1c" => 1, "\x1d" => 1, "\x1e" => 1, "\x1f" => 1, + "\x20" => 1, "\x21" => 1, "\x22" => 1, "\x23" => 1, "\x24" => 1, "\x25" => 1, "\x26" => 1, "\x27" => 1, + "\x28" => 1, "\x29" => 1, "\x2a" => 1, "\x2b" => 1, "\x2c" => 1, "\x2d" => 1, "\x2e" => 1, "\x2f" => 1, + "\x30" => 1, "\x31" => 1, "\x32" => 1, "\x33" => 1, "\x34" => 1, "\x35" => 1, "\x36" => 1, "\x37" => 1, + "\x38" => 1, "\x39" => 1, "\x3a" => 1, "\x3b" => 1, "\x3c" => 1, "\x3d" => 1, "\x3e" => 1, "\x3f" => 1, + "\x40" => 1, "\x41" => 1, "\x42" => 1, "\x43" => 1, "\x44" => 1, "\x45" => 1, "\x46" => 1, "\x47" => 1, + "\x48" => 1, "\x49" => 1, "\x4a" => 1, "\x4b" => 1, "\x4c" => 1, "\x4d" => 1, "\x4e" => 1, "\x4f" => 1, + "\x50" => 1, "\x51" => 1, "\x52" => 1, "\x53" => 1, "\x54" => 1, "\x55" => 1, "\x56" => 1, "\x57" => 1, + "\x58" => 1, "\x59" => 1, "\x5a" => 1, "\x5b" => 1, "\x5c" => 1, "\x5d" => 1, "\x5e" => 1, "\x5f" => 1, + "\x60" => 1, "\x61" => 1, "\x62" => 1, "\x63" => 1, "\x64" => 1, "\x65" => 1, "\x66" => 1, "\x67" => 1, + "\x68" => 1, "\x69" => 1, "\x6a" => 1, "\x6b" => 1, "\x6c" => 1, "\x6d" => 1, "\x6e" => 1, "\x6f" => 1, + "\x70" => 1, "\x71" => 1, "\x72" => 1, "\x73" => 1, "\x74" => 1, "\x75" => 1, "\x76" => 1, "\x77" => 1, + "\x78" => 1, "\x79" => 1, "\x7a" => 1, "\x7b" => 1, "\x7c" => 1, "\x7d" => 1, "\x7e" => 1, "\x7f" => 1, + "\x80" => 0, "\x81" => 0, "\x82" => 0, "\x83" => 0, "\x84" => 0, "\x85" => 0, "\x86" => 0, "\x87" => 0, + "\x88" => 0, "\x89" => 0, "\x8a" => 0, "\x8b" => 0, "\x8c" => 0, "\x8d" => 0, "\x8e" => 0, "\x8f" => 0, + "\x90" => 0, "\x91" => 0, "\x92" => 0, "\x93" => 0, "\x94" => 0, "\x95" => 0, "\x96" => 0, "\x97" => 0, + "\x98" => 0, "\x99" => 0, "\x9a" => 0, "\x9b" => 0, "\x9c" => 0, "\x9d" => 0, "\x9e" => 0, "\x9f" => 0, + "\xa0" => 0, "\xa1" => 0, "\xa2" => 0, "\xa3" => 0, "\xa4" => 0, "\xa5" => 0, "\xa6" => 0, "\xa7" => 0, + "\xa8" => 0, "\xa9" => 0, "\xaa" => 0, "\xab" => 0, "\xac" => 0, "\xad" => 0, "\xae" => 0, "\xaf" => 0, + "\xb0" => 0, "\xb1" => 0, "\xb2" => 0, "\xb3" => 0, "\xb4" => 0, "\xb5" => 0, "\xb6" => 0, "\xb7" => 0, + "\xb8" => 0, "\xb9" => 0, "\xba" => 0, "\xbb" => 0, "\xbc" => 0, "\xbd" => 0, "\xbe" => 0, "\xbf" => 0, + "\xc0" => 2, "\xc1" => 2, "\xc2" => 2, "\xc3" => 2, "\xc4" => 2, "\xc5" => 2, "\xc6" => 2, "\xc7" => 2, + "\xc8" => 2, "\xc9" => 2, "\xca" => 2, "\xcb" => 2, "\xcc" => 2, "\xcd" => 2, "\xce" => 2, "\xcf" => 2, + "\xd0" => 2, "\xd1" => 2, "\xd2" => 2, "\xd3" => 2, "\xd4" => 2, "\xd5" => 2, "\xd6" => 2, "\xd7" => 2, + "\xd8" => 2, "\xd9" => 2, "\xda" => 2, "\xdb" => 2, "\xdc" => 2, "\xdd" => 2, "\xde" => 2, "\xdf" => 2, + "\xe0" => 3, "\xe1" => 3, "\xe2" => 3, "\xe3" => 3, "\xe4" => 3, "\xe5" => 3, "\xe6" => 3, "\xe7" => 3, + "\xe8" => 3, "\xe9" => 3, "\xea" => 3, "\xeb" => 3, "\xec" => 3, "\xed" => 3, "\xee" => 3, "\xef" => 3, + "\xf0" => 4, "\xf1" => 4, "\xf2" => 4, "\xf3" => 4, "\xf4" => 4, "\xf5" => 4, "\xf6" => 4, "\xf7" => 4, + "\xf8" => 5, "\xf9" => 5, "\xfa" => 5, "\xfb" => 5, "\xfc" => 6, "\xfd" => 6, "\xfe" => 0, "\xff" => 0, + ]; - /** - * Returns the complete character map. - * - * @param string $string - * @param int $startOffset - * @param array $currentMap - * @param mixed $ignoredChars - * - * @return int - */ - public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars) - { - if (!isset($currentMap['i']) || !isset($currentMap['p'])) { - $currentMap['p'] = $currentMap['i'] = []; - } + /** + * Returns the complete character map. + * + * @param string $string + * @param int $startOffset + * @param array $currentMap + * @param mixed $ignoredChars + * + * @return int + */ + public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars) + { + if (!isset($currentMap['i']) || !isset($currentMap['p'])) { + $currentMap['p'] = $currentMap['i'] = []; + } - $strlen = \strlen($string); - $charPos = \count($currentMap['p']); - $foundChars = 0; - $invalid = false; - for ($i = 0; $i < $strlen; ++$i) { - $char = $string[$i]; - $size = self::$s_length_map[$char]; - if (0 == $size) { - /* char is invalid, we must wait for a resync */ - $invalid = true; - continue; - } else { - if (true === $invalid) { - /* We mark the chars as invalid and start a new char */ - $currentMap['p'][$charPos + $foundChars] = $startOffset + $i; - $currentMap['i'][$charPos + $foundChars] = true; - ++$foundChars; - $invalid = false; - } - if (($i + $size) > $strlen) { - $ignoredChars = substr($string, $i); - break; - } - for ($j = 1; $j < $size; ++$j) { - $char = $string[$i + $j]; - if ($char > "\x7F" && $char < "\xC0") { - // Valid - continue parsing - } else { - /* char is invalid, we must wait for a resync */ - $invalid = true; - continue 2; - } - } - /* Ok we got a complete char here */ - $currentMap['p'][$charPos + $foundChars] = $startOffset + $i + $size; - $i += $j - 1; - ++$foundChars; - } - } + $strlen = \strlen($string); + $charPos = \count($currentMap['p']); + $foundChars = 0; + $invalid = false; + for ($i = 0; $i < $strlen; ++$i) { + $char = $string[$i]; + $size = self::$s_length_map[$char]; + if (0 == $size) { + /* char is invalid, we must wait for a resync */ + $invalid = true; + continue; + } else { + if (true === $invalid) { + /* We mark the chars as invalid and start a new char */ + $currentMap['p'][$charPos + $foundChars] = $startOffset + $i; + $currentMap['i'][$charPos + $foundChars] = true; + ++$foundChars; + $invalid = false; + } + if (($i + $size) > $strlen) { + $ignoredChars = substr($string, $i); + break; + } + for ($j = 1; $j < $size; ++$j) { + $char = $string[$i + $j]; + if ($char > "\x7F" && $char < "\xC0") { + // Valid - continue parsing + } else { + /* char is invalid, we must wait for a resync */ + $invalid = true; + continue 2; + } + } + /* Ok we got a complete char here */ + $currentMap['p'][$charPos + $foundChars] = $startOffset + $i + $size; + $i += $j - 1; + ++$foundChars; + } + } - return $foundChars; - } + return $foundChars; + } - /** - * Returns mapType. - * - * @return int mapType - */ - public function getMapType() - { - return self::MAP_TYPE_POSITIONS; - } + /** + * Returns mapType. + * + * @return int mapType + */ + public function getMapType() + { + return self::MAP_TYPE_POSITIONS; + } - /** - * Returns an integer which specifies how many more bytes to read. - * - * A positive integer indicates the number of more bytes to fetch before invoking - * this method again. - * A value of zero means this is already a valid character. - * A value of -1 means this cannot possibly be a valid character. - * - * @param string $bytes - * @param int $size - * - * @return int - */ - public function validateByteSequence($bytes, $size) - { - if ($size < 1) { - return -1; - } - $needed = self::$length_map[$bytes[0]] - $size; + /** + * Returns an integer which specifies how many more bytes to read. + * + * A positive integer indicates the number of more bytes to fetch before invoking + * this method again. + * A value of zero means this is already a valid character. + * A value of -1 means this cannot possibly be a valid character. + * + * @param string $bytes + * @param int $size + * + * @return int + */ + public function validateByteSequence($bytes, $size) + { + if ($size < 1) { + return -1; + } + $needed = self::$length_map[$bytes[0]] - $size; - return $needed > -1 ? $needed : -1; - } + return $needed > -1 ? $needed : -1; + } - /** - * Returns the number of bytes which should be read to start each character. - * - * @return int - */ - public function getInitialByteSize() - { - return 1; - } + /** + * Returns the number of bytes which should be read to start each character. + * + * @return int + */ + public function getInitialByteSize() + { + return 1; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php index 97b3b097f3d..86900894ab1 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php @@ -15,110 +15,110 @@ */ class Swift_CharacterReaderFactory_SimpleCharacterReaderFactory implements Swift_CharacterReaderFactory { - /** - * A map of charset patterns to their implementation classes. - * - * @var array - */ - private static $map = []; + /** + * A map of charset patterns to their implementation classes. + * + * @var array + */ + private static $map = []; - /** - * Factories which have already been loaded. - * - * @var Swift_CharacterReaderFactory[] - */ - private static $loaded = []; + /** + * Factories which have already been loaded. + * + * @var Swift_CharacterReaderFactory[] + */ + private static $loaded = []; - /** - * Creates a new CharacterReaderFactory. - */ - public function __construct() - { - $this->init(); - } + /** + * Creates a new CharacterReaderFactory. + */ + public function __construct() + { + $this->init(); + } - public function __wakeup() - { - $this->init(); - } + public function __wakeup() + { + $this->init(); + } - public function init() - { - if (\count(self::$map) > 0) { - return; - } + public function init() + { + if (\count(self::$map) > 0) { + return; + } - $prefix = 'Swift_CharacterReader_'; + $prefix = 'Swift_CharacterReader_'; - $singleByte = [ - 'class' => $prefix.'GenericFixedWidthReader', - 'constructor' => [1], - ]; + $singleByte = [ + 'class' => $prefix.'GenericFixedWidthReader', + 'constructor' => [1], + ]; - $doubleByte = [ - 'class' => $prefix.'GenericFixedWidthReader', - 'constructor' => [2], - ]; + $doubleByte = [ + 'class' => $prefix.'GenericFixedWidthReader', + 'constructor' => [2], + ]; - $fourBytes = [ - 'class' => $prefix.'GenericFixedWidthReader', - 'constructor' => [4], - ]; + $fourBytes = [ + 'class' => $prefix.'GenericFixedWidthReader', + 'constructor' => [4], + ]; - // Utf-8 - self::$map['utf-?8'] = [ - 'class' => $prefix.'Utf8Reader', - 'constructor' => [], - ]; + // Utf-8 + self::$map['utf-?8'] = [ + 'class' => $prefix.'Utf8Reader', + 'constructor' => [], + ]; - //7-8 bit charsets - self::$map['(us-)?ascii'] = $singleByte; - self::$map['(iso|iec)-?8859-?[0-9]+'] = $singleByte; - self::$map['windows-?125[0-9]'] = $singleByte; - self::$map['cp-?[0-9]+'] = $singleByte; - self::$map['ansi'] = $singleByte; - self::$map['macintosh'] = $singleByte; - self::$map['koi-?7'] = $singleByte; - self::$map['koi-?8-?.+'] = $singleByte; - self::$map['mik'] = $singleByte; - self::$map['(cork|t1)'] = $singleByte; - self::$map['v?iscii'] = $singleByte; + //7-8 bit charsets + self::$map['(us-)?ascii'] = $singleByte; + self::$map['(iso|iec)-?8859-?[0-9]+'] = $singleByte; + self::$map['windows-?125[0-9]'] = $singleByte; + self::$map['cp-?[0-9]+'] = $singleByte; + self::$map['ansi'] = $singleByte; + self::$map['macintosh'] = $singleByte; + self::$map['koi-?7'] = $singleByte; + self::$map['koi-?8-?.+'] = $singleByte; + self::$map['mik'] = $singleByte; + self::$map['(cork|t1)'] = $singleByte; + self::$map['v?iscii'] = $singleByte; - //16 bits - self::$map['(ucs-?2|utf-?16)'] = $doubleByte; + //16 bits + self::$map['(ucs-?2|utf-?16)'] = $doubleByte; - //32 bits - self::$map['(ucs-?4|utf-?32)'] = $fourBytes; + //32 bits + self::$map['(ucs-?4|utf-?32)'] = $fourBytes; - // Fallback - self::$map['.*'] = $singleByte; - } + // Fallback + self::$map['.*'] = $singleByte; + } - /** - * Returns a CharacterReader suitable for the charset applied. - * - * @param string $charset - * - * @return Swift_CharacterReader - */ - public function getReaderFor($charset) - { - $charset = strtolower(trim($charset ?? '')); - foreach (self::$map as $pattern => $spec) { - $re = '/^'.$pattern.'$/D'; - if (preg_match($re, $charset)) { - if (!\array_key_exists($pattern, self::$loaded)) { - $reflector = new ReflectionClass($spec['class']); - if ($reflector->getConstructor()) { - $reader = $reflector->newInstanceArgs($spec['constructor']); - } else { - $reader = $reflector->newInstance(); - } - self::$loaded[$pattern] = $reader; - } + /** + * Returns a CharacterReader suitable for the charset applied. + * + * @param string $charset + * + * @return Swift_CharacterReader + */ + public function getReaderFor($charset) + { + $charset = strtolower(trim($charset ?? '')); + foreach (self::$map as $pattern => $spec) { + $re = '/^'.$pattern.'$/D'; + if (preg_match($re, $charset)) { + if (!\array_key_exists($pattern, self::$loaded)) { + $reflector = new ReflectionClass($spec['class']); + if ($reflector->getConstructor()) { + $reader = $reflector->newInstanceArgs($spec['constructor']); + } else { + $reader = $reflector->newInstance(); + } + self::$loaded[$pattern] = $reader; + } - return self::$loaded[$pattern]; - } - } - } + return self::$loaded[$pattern]; + } + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterStream.php b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterStream.php index 04e2d433934..c9d8a078ee0 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterStream.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterStream.php @@ -19,69 +19,69 @@ */ interface Swift_CharacterStream { - /** - * Set the character set used in this CharacterStream. - * - * @param string $charset - */ - public function setCharacterSet($charset); + /** + * Set the character set used in this CharacterStream. + * + * @param string $charset + */ + public function setCharacterSet($charset); - /** - * Set the CharacterReaderFactory for multi charset support. - */ - public function setCharacterReaderFactory(Swift_CharacterReaderFactory $factory); + /** + * Set the CharacterReaderFactory for multi charset support. + */ + public function setCharacterReaderFactory(Swift_CharacterReaderFactory $factory); - /** - * Overwrite this character stream using the byte sequence in the byte stream. - * - * @param Swift_OutputByteStream $os output stream to read from - */ - public function importByteStream(Swift_OutputByteStream $os); + /** + * Overwrite this character stream using the byte sequence in the byte stream. + * + * @param Swift_OutputByteStream $os output stream to read from + */ + public function importByteStream(Swift_OutputByteStream $os); - /** - * Import a string a bytes into this CharacterStream, overwriting any existing - * data in the stream. - * - * @param string $string - */ - public function importString($string); + /** + * Import a string a bytes into this CharacterStream, overwriting any existing + * data in the stream. + * + * @param string $string + */ + public function importString($string); - /** - * Read $length characters from the stream and move the internal pointer - * $length further into the stream. - * - * @param int $length - * - * @return string - */ - public function read($length); + /** + * Read $length characters from the stream and move the internal pointer + * $length further into the stream. + * + * @param int $length + * + * @return string + */ + public function read($length); - /** - * Read $length characters from the stream and return a 1-dimensional array - * containing there octet values. - * - * @param int $length - * - * @return int[] - */ - public function readBytes($length); + /** + * Read $length characters from the stream and return a 1-dimensional array + * containing there octet values. + * + * @param int $length + * + * @return int[] + */ + public function readBytes($length); - /** - * Write $chars to the end of the stream. - * - * @param string $chars - */ - public function write($chars); + /** + * Write $chars to the end of the stream. + * + * @param string $chars + */ + public function write($chars); - /** - * Move the internal pointer to $charOffset in the stream. - * - * @param int $charOffset - */ - public function setPointer($charOffset); + /** + * Move the internal pointer to $charOffset in the stream. + * + * @param int $charOffset + */ + public function setPointer($charOffset); - /** - * Empty the stream and reset the internal pointer. - */ - public function flushContents(); + /** + * Empty the stream and reset the internal pointer. + */ + public function flushContents(); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterStream/ArrayCharacterStream.php b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterStream/ArrayCharacterStream.php index 6f6a22e393e..5c2869455b8 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterStream/ArrayCharacterStream.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterStream/ArrayCharacterStream.php @@ -15,277 +15,277 @@ */ class Swift_CharacterStream_ArrayCharacterStream implements Swift_CharacterStream { - /** A map of byte values and their respective characters */ - private static $charMap; + /** A map of byte values and their respective characters */ + private static $charMap; - /** A map of characters and their derivative byte values */ - private static $byteMap; + /** A map of characters and their derivative byte values */ + private static $byteMap; - /** The char reader (lazy-loaded) for the current charset */ - private $charReader; + /** The char reader (lazy-loaded) for the current charset */ + private $charReader; - /** A factory for creating CharacterReader instances */ - private $charReaderFactory; + /** A factory for creating CharacterReader instances */ + private $charReaderFactory; - /** The character set this stream is using */ - private $charset; + /** The character set this stream is using */ + private $charset; - /** Array of characters */ - private $array = []; + /** Array of characters */ + private $array = []; - /** Size of the array of character */ - private $array_size = []; + /** Size of the array of character */ + private $array_size = []; - /** The current character offset in the stream */ - private $offset = 0; + /** The current character offset in the stream */ + private $offset = 0; - /** - * Create a new CharacterStream with the given $chars, if set. - * - * @param Swift_CharacterReaderFactory $factory for loading validators - * @param string $charset used in the stream - */ - public function __construct(Swift_CharacterReaderFactory $factory, $charset) - { - self::initializeMaps(); - $this->setCharacterReaderFactory($factory); - $this->setCharacterSet($charset); - } + /** + * Create a new CharacterStream with the given $chars, if set. + * + * @param Swift_CharacterReaderFactory $factory for loading validators + * @param string $charset used in the stream + */ + public function __construct(Swift_CharacterReaderFactory $factory, $charset) + { + self::initializeMaps(); + $this->setCharacterReaderFactory($factory); + $this->setCharacterSet($charset); + } - /** - * Set the character set used in this CharacterStream. - * - * @param string $charset - */ - public function setCharacterSet($charset) - { - $this->charset = $charset; - $this->charReader = null; - } + /** + * Set the character set used in this CharacterStream. + * + * @param string $charset + */ + public function setCharacterSet($charset) + { + $this->charset = $charset; + $this->charReader = null; + } - /** - * Set the CharacterReaderFactory for multi charset support. - */ - public function setCharacterReaderFactory(Swift_CharacterReaderFactory $factory) - { - $this->charReaderFactory = $factory; - } + /** + * Set the CharacterReaderFactory for multi charset support. + */ + public function setCharacterReaderFactory(Swift_CharacterReaderFactory $factory) + { + $this->charReaderFactory = $factory; + } - /** - * Overwrite this character stream using the byte sequence in the byte stream. - * - * @param Swift_OutputByteStream $os output stream to read from - */ - public function importByteStream(Swift_OutputByteStream $os) - { - if (!isset($this->charReader)) { - $this->charReader = $this->charReaderFactory - ->getReaderFor($this->charset); - } + /** + * Overwrite this character stream using the byte sequence in the byte stream. + * + * @param Swift_OutputByteStream $os output stream to read from + */ + public function importByteStream(Swift_OutputByteStream $os) + { + if (!isset($this->charReader)) { + $this->charReader = $this->charReaderFactory + ->getReaderFor($this->charset); + } - $startLength = $this->charReader->getInitialByteSize(); - while (false !== $bytes = $os->read($startLength)) { - $c = []; - for ($i = 0, $len = \strlen($bytes); $i < $len; ++$i) { - $c[] = self::$byteMap[$bytes[$i]]; - } - $size = \count($c); - $need = $this->charReader - ->validateByteSequence($c, $size); - if ($need > 0 && - false !== $bytes = $os->read($need)) { - for ($i = 0, $len = \strlen($bytes); $i < $len; ++$i) { - $c[] = self::$byteMap[$bytes[$i]]; - } - } - $this->array[] = $c; - ++$this->array_size; - } - } + $startLength = $this->charReader->getInitialByteSize(); + while (false !== $bytes = $os->read($startLength)) { + $c = []; + for ($i = 0, $len = \strlen($bytes); $i < $len; ++$i) { + $c[] = self::$byteMap[$bytes[$i]]; + } + $size = \count($c); + $need = $this->charReader + ->validateByteSequence($c, $size); + if ($need > 0 && + false !== $bytes = $os->read($need)) { + for ($i = 0, $len = \strlen($bytes); $i < $len; ++$i) { + $c[] = self::$byteMap[$bytes[$i]]; + } + } + $this->array[] = $c; + ++$this->array_size; + } + } - /** - * Import a string a bytes into this CharacterStream, overwriting any existing - * data in the stream. - * - * @param string $string - */ - public function importString($string) - { - $this->flushContents(); - $this->write($string); - } + /** + * Import a string a bytes into this CharacterStream, overwriting any existing + * data in the stream. + * + * @param string $string + */ + public function importString($string) + { + $this->flushContents(); + $this->write($string); + } - /** - * Read $length characters from the stream and move the internal pointer - * $length further into the stream. - * - * @param int $length - * - * @return string - */ - public function read($length) - { - if ($this->offset == $this->array_size) { - return false; - } + /** + * Read $length characters from the stream and move the internal pointer + * $length further into the stream. + * + * @param int $length + * + * @return string + */ + public function read($length) + { + if ($this->offset == $this->array_size) { + return false; + } - // Don't use array slice - $arrays = []; - $end = $length + $this->offset; - for ($i = $this->offset; $i < $end; ++$i) { - if (!isset($this->array[$i])) { - break; - } - $arrays[] = $this->array[$i]; - } - $this->offset += $i - $this->offset; // Limit function calls - $chars = false; - foreach ($arrays as $array) { - $chars .= implode('', array_map('chr', $array)); - } + // Don't use array slice + $arrays = []; + $end = $length + $this->offset; + for ($i = $this->offset; $i < $end; ++$i) { + if (!isset($this->array[$i])) { + break; + } + $arrays[] = $this->array[$i]; + } + $this->offset += $i - $this->offset; // Limit function calls + $chars = false; + foreach ($arrays as $array) { + $chars .= implode('', array_map('chr', $array)); + } - return $chars; - } + return $chars; + } - /** - * Read $length characters from the stream and return a 1-dimensional array - * containing there octet values. - * - * @param int $length - * - * @return int[] - */ - public function readBytes($length) - { - if ($this->offset == $this->array_size) { - return false; - } - $arrays = []; - $end = $length + $this->offset; - for ($i = $this->offset; $i < $end; ++$i) { - if (!isset($this->array[$i])) { - break; - } - $arrays[] = $this->array[$i]; - } - $this->offset += ($i - $this->offset); // Limit function calls + /** + * Read $length characters from the stream and return a 1-dimensional array + * containing there octet values. + * + * @param int $length + * + * @return int[] + */ + public function readBytes($length) + { + if ($this->offset == $this->array_size) { + return false; + } + $arrays = []; + $end = $length + $this->offset; + for ($i = $this->offset; $i < $end; ++$i) { + if (!isset($this->array[$i])) { + break; + } + $arrays[] = $this->array[$i]; + } + $this->offset += ($i - $this->offset); // Limit function calls - return array_merge(...$arrays); - } + return array_merge(...$arrays); + } - /** - * Write $chars to the end of the stream. - * - * @param string $chars - */ - public function write($chars) - { - if (!isset($this->charReader)) { - $this->charReader = $this->charReaderFactory->getReaderFor( - $this->charset); - } + /** + * Write $chars to the end of the stream. + * + * @param string $chars + */ + public function write($chars) + { + if (!isset($this->charReader)) { + $this->charReader = $this->charReaderFactory->getReaderFor( + $this->charset); + } - $startLength = $this->charReader->getInitialByteSize(); + $startLength = $this->charReader->getInitialByteSize(); - $fp = fopen('php://memory', 'w+b'); - fwrite($fp, $chars); - unset($chars); - fseek($fp, 0, SEEK_SET); + $fp = fopen('php://memory', 'w+b'); + fwrite($fp, $chars); + unset($chars); + fseek($fp, 0, SEEK_SET); - $buffer = [0]; - $buf_pos = 1; - $buf_len = 1; - $has_datas = true; - do { - $bytes = []; - // Buffer Filing - if ($buf_len - $buf_pos < $startLength) { - $buf = array_splice($buffer, $buf_pos); - $new = $this->reloadBuffer($fp, 100); - if ($new) { - $buffer = array_merge($buf, $new); - $buf_len = \count($buffer); - $buf_pos = 0; - } else { - $has_datas = false; - } - } - if ($buf_len - $buf_pos > 0) { - $size = 0; - for ($i = 0; $i < $startLength && isset($buffer[$buf_pos]); ++$i) { - ++$size; - $bytes[] = $buffer[$buf_pos++]; - } - $need = $this->charReader->validateByteSequence( - $bytes, $size); - if ($need > 0) { - if ($buf_len - $buf_pos < $need) { - $new = $this->reloadBuffer($fp, $need); + $buffer = [0]; + $buf_pos = 1; + $buf_len = 1; + $has_datas = true; + do { + $bytes = []; + // Buffer Filing + if ($buf_len - $buf_pos < $startLength) { + $buf = array_splice($buffer, $buf_pos); + $new = $this->reloadBuffer($fp, 100); + if ($new) { + $buffer = array_merge($buf, $new); + $buf_len = \count($buffer); + $buf_pos = 0; + } else { + $has_datas = false; + } + } + if ($buf_len - $buf_pos > 0) { + $size = 0; + for ($i = 0; $i < $startLength && isset($buffer[$buf_pos]); ++$i) { + ++$size; + $bytes[] = $buffer[$buf_pos++]; + } + $need = $this->charReader->validateByteSequence( + $bytes, $size); + if ($need > 0) { + if ($buf_len - $buf_pos < $need) { + $new = $this->reloadBuffer($fp, $need); - if ($new) { - $buffer = array_merge($buffer, $new); - $buf_len = \count($buffer); - } - } - for ($i = 0; $i < $need && isset($buffer[$buf_pos]); ++$i) { - $bytes[] = $buffer[$buf_pos++]; - } - } - $this->array[] = $bytes; - ++$this->array_size; - } - } while ($has_datas); + if ($new) { + $buffer = array_merge($buffer, $new); + $buf_len = \count($buffer); + } + } + for ($i = 0; $i < $need && isset($buffer[$buf_pos]); ++$i) { + $bytes[] = $buffer[$buf_pos++]; + } + } + $this->array[] = $bytes; + ++$this->array_size; + } + } while ($has_datas); - fclose($fp); - } + fclose($fp); + } - /** - * Move the internal pointer to $charOffset in the stream. - * - * @param int $charOffset - */ - public function setPointer($charOffset) - { - if ($charOffset > $this->array_size) { - $charOffset = $this->array_size; - } elseif ($charOffset < 0) { - $charOffset = 0; - } - $this->offset = $charOffset; - } + /** + * Move the internal pointer to $charOffset in the stream. + * + * @param int $charOffset + */ + public function setPointer($charOffset) + { + if ($charOffset > $this->array_size) { + $charOffset = $this->array_size; + } elseif ($charOffset < 0) { + $charOffset = 0; + } + $this->offset = $charOffset; + } - /** - * Empty the stream and reset the internal pointer. - */ - public function flushContents() - { - $this->offset = 0; - $this->array = []; - $this->array_size = 0; - } + /** + * Empty the stream and reset the internal pointer. + */ + public function flushContents() + { + $this->offset = 0; + $this->array = []; + $this->array_size = 0; + } - private function reloadBuffer($fp, $len) - { - if (!feof($fp) && false !== ($bytes = fread($fp, $len))) { - $buf = []; - for ($i = 0, $len = \strlen($bytes); $i < $len; ++$i) { - $buf[] = self::$byteMap[$bytes[$i]]; - } + private function reloadBuffer($fp, $len) + { + if (!feof($fp) && false !== ($bytes = fread($fp, $len))) { + $buf = []; + for ($i = 0, $len = \strlen($bytes); $i < $len; ++$i) { + $buf[] = self::$byteMap[$bytes[$i]]; + } - return $buf; - } + return $buf; + } - return false; - } + return false; + } - private static function initializeMaps() - { - if (!isset(self::$charMap)) { - self::$charMap = []; - for ($byte = 0; $byte < 256; ++$byte) { - self::$charMap[$byte] = \chr($byte); - } - self::$byteMap = array_flip(self::$charMap); - } - } + private static function initializeMaps() + { + if (!isset(self::$charMap)) { + self::$charMap = []; + for ($byte = 0; $byte < 256; ++$byte) { + self::$charMap[$byte] = \chr($byte); + } + self::$byteMap = array_flip(self::$charMap); + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterStream/NgCharacterStream.php b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterStream/NgCharacterStream.php index d7110ff16ef..7578dda9cac 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterStream/NgCharacterStream.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterStream/NgCharacterStream.php @@ -15,248 +15,248 @@ */ class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream { - /** - * The char reader (lazy-loaded) for the current charset. - * - * @var Swift_CharacterReader - */ - private $charReader; + /** + * The char reader (lazy-loaded) for the current charset. + * + * @var Swift_CharacterReader + */ + private $charReader; - /** - * A factory for creating CharacterReader instances. - * - * @var Swift_CharacterReaderFactory - */ - private $charReaderFactory; + /** + * A factory for creating CharacterReader instances. + * + * @var Swift_CharacterReaderFactory + */ + private $charReaderFactory; - /** - * The character set this stream is using. - * - * @var string - */ - private $charset; + /** + * The character set this stream is using. + * + * @var string + */ + private $charset; - /** - * The data's stored as-is. - * - * @var string - */ - private $datas = ''; + /** + * The data's stored as-is. + * + * @var string + */ + private $datas = ''; - /** - * Number of bytes in the stream. - * - * @var int - */ - private $datasSize = 0; + /** + * Number of bytes in the stream. + * + * @var int + */ + private $datasSize = 0; - /** - * Map. - * - * @var mixed - */ - private $map; + /** + * Map. + * + * @var mixed + */ + private $map; - /** - * Map Type. - * - * @var int - */ - private $mapType = 0; + /** + * Map Type. + * + * @var int + */ + private $mapType = 0; - /** - * Number of characters in the stream. - * - * @var int - */ - private $charCount = 0; + /** + * Number of characters in the stream. + * + * @var int + */ + private $charCount = 0; - /** - * Position in the stream. - * - * @var int - */ - private $currentPos = 0; + /** + * Position in the stream. + * + * @var int + */ + private $currentPos = 0; - /** - * Constructor. - * - * @param string $charset - */ - public function __construct(Swift_CharacterReaderFactory $factory, $charset) - { - $this->setCharacterReaderFactory($factory); - $this->setCharacterSet($charset); - } + /** + * Constructor. + * + * @param string $charset + */ + public function __construct(Swift_CharacterReaderFactory $factory, $charset) + { + $this->setCharacterReaderFactory($factory); + $this->setCharacterSet($charset); + } - /* -- Changing parameters of the stream -- */ + /* -- Changing parameters of the stream -- */ - /** - * Set the character set used in this CharacterStream. - * - * @param string $charset - */ - public function setCharacterSet($charset) - { - $this->charset = $charset; - $this->charReader = null; - $this->mapType = 0; - } + /** + * Set the character set used in this CharacterStream. + * + * @param string $charset + */ + public function setCharacterSet($charset) + { + $this->charset = $charset; + $this->charReader = null; + $this->mapType = 0; + } - /** - * Set the CharacterReaderFactory for multi charset support. - */ - public function setCharacterReaderFactory(Swift_CharacterReaderFactory $factory) - { - $this->charReaderFactory = $factory; - } + /** + * Set the CharacterReaderFactory for multi charset support. + */ + public function setCharacterReaderFactory(Swift_CharacterReaderFactory $factory) + { + $this->charReaderFactory = $factory; + } - /** - * @see Swift_CharacterStream::flushContents() - */ - public function flushContents() - { - $this->datas = null; - $this->map = null; - $this->charCount = 0; - $this->currentPos = 0; - $this->datasSize = 0; - } + /** + * @see Swift_CharacterStream::flushContents() + */ + public function flushContents() + { + $this->datas = null; + $this->map = null; + $this->charCount = 0; + $this->currentPos = 0; + $this->datasSize = 0; + } - /** - * @see Swift_CharacterStream::importByteStream() - */ - public function importByteStream(Swift_OutputByteStream $os) - { - $this->flushContents(); - $blocks = 512; - $os->setReadPointer(0); - while (false !== ($read = $os->read($blocks))) { - $this->write($read); - } - } + /** + * @see Swift_CharacterStream::importByteStream() + */ + public function importByteStream(Swift_OutputByteStream $os) + { + $this->flushContents(); + $blocks = 512; + $os->setReadPointer(0); + while (false !== ($read = $os->read($blocks))) { + $this->write($read); + } + } - /** - * @see Swift_CharacterStream::importString() - * - * @param string $string - */ - public function importString($string) - { - $this->flushContents(); - $this->write($string); - } + /** + * @see Swift_CharacterStream::importString() + * + * @param string $string + */ + public function importString($string) + { + $this->flushContents(); + $this->write($string); + } - /** - * @see Swift_CharacterStream::read() - * - * @param int $length - * - * @return string - */ - public function read($length) - { - if ($this->currentPos >= $this->charCount) { - return false; - } - $ret = false; - $length = ($this->currentPos + $length > $this->charCount) ? $this->charCount - $this->currentPos : $length; - switch ($this->mapType) { - case Swift_CharacterReader::MAP_TYPE_FIXED_LEN: - $len = $length * $this->map; - $ret = substr($this->datas, - $this->currentPos * $this->map, - $len); - $this->currentPos += $length; - break; + /** + * @see Swift_CharacterStream::read() + * + * @param int $length + * + * @return string + */ + public function read($length) + { + if ($this->currentPos >= $this->charCount) { + return false; + } + $ret = false; + $length = ($this->currentPos + $length > $this->charCount) ? $this->charCount - $this->currentPos : $length; + switch ($this->mapType) { + case Swift_CharacterReader::MAP_TYPE_FIXED_LEN: + $len = $length * $this->map; + $ret = substr($this->datas, + $this->currentPos * $this->map, + $len); + $this->currentPos += $length; + break; - case Swift_CharacterReader::MAP_TYPE_INVALID: - $ret = ''; - for (; $this->currentPos < $length; ++$this->currentPos) { - if (isset($this->map[$this->currentPos])) { - $ret .= '?'; - } else { - $ret .= $this->datas[$this->currentPos]; - } - } - break; + case Swift_CharacterReader::MAP_TYPE_INVALID: + $ret = ''; + for (; $this->currentPos < $length; ++$this->currentPos) { + if (isset($this->map[$this->currentPos])) { + $ret .= '?'; + } else { + $ret .= $this->datas[$this->currentPos]; + } + } + break; - case Swift_CharacterReader::MAP_TYPE_POSITIONS: - $end = $this->currentPos + $length; - $end = $end > $this->charCount ? $this->charCount : $end; - $ret = ''; - $start = 0; - if ($this->currentPos > 0) { - $start = $this->map['p'][$this->currentPos - 1]; - } - $to = $start; - for (; $this->currentPos < $end; ++$this->currentPos) { - if (isset($this->map['i'][$this->currentPos])) { - $ret .= substr($this->datas, $start, $to - $start).'?'; - $start = $this->map['p'][$this->currentPos]; - } else { - $to = $this->map['p'][$this->currentPos]; - } - } - $ret .= substr($this->datas, $start, $to - $start); - break; - } + case Swift_CharacterReader::MAP_TYPE_POSITIONS: + $end = $this->currentPos + $length; + $end = $end > $this->charCount ? $this->charCount : $end; + $ret = ''; + $start = 0; + if ($this->currentPos > 0) { + $start = $this->map['p'][$this->currentPos - 1]; + } + $to = $start; + for (; $this->currentPos < $end; ++$this->currentPos) { + if (isset($this->map['i'][$this->currentPos])) { + $ret .= substr($this->datas, $start, $to - $start).'?'; + $start = $this->map['p'][$this->currentPos]; + } else { + $to = $this->map['p'][$this->currentPos]; + } + } + $ret .= substr($this->datas, $start, $to - $start); + break; + } - return $ret; - } + return $ret; + } - /** - * @see Swift_CharacterStream::readBytes() - * - * @param int $length - * - * @return int[] - */ - public function readBytes($length) - { - $read = $this->read($length); - if (false !== $read) { - $ret = array_map('ord', str_split($read, 1)); + /** + * @see Swift_CharacterStream::readBytes() + * + * @param int $length + * + * @return int[] + */ + public function readBytes($length) + { + $read = $this->read($length); + if (false !== $read) { + $ret = array_map('ord', str_split($read, 1)); - return $ret; - } + return $ret; + } - return false; - } + return false; + } - /** - * @see Swift_CharacterStream::setPointer() - * - * @param int $charOffset - */ - public function setPointer($charOffset) - { - if ($this->charCount < $charOffset) { - $charOffset = $this->charCount; - } - $this->currentPos = $charOffset; - } + /** + * @see Swift_CharacterStream::setPointer() + * + * @param int $charOffset + */ + public function setPointer($charOffset) + { + if ($this->charCount < $charOffset) { + $charOffset = $this->charCount; + } + $this->currentPos = $charOffset; + } - /** - * @see Swift_CharacterStream::write() - * - * @param string $chars - */ - public function write($chars) - { - if (!isset($this->charReader)) { - $this->charReader = $this->charReaderFactory->getReaderFor( - $this->charset); - $this->map = []; - $this->mapType = $this->charReader->getMapType(); - } - $ignored = ''; - $this->datas .= $chars; - $this->charCount += $this->charReader->getCharPositions(substr($this->datas, $this->datasSize), $this->datasSize, $this->map, $ignored); - if (false !== $ignored) { - $this->datasSize = \strlen($this->datas) - \strlen($ignored); - } else { - $this->datasSize = \strlen($this->datas); - } - } + /** + * @see Swift_CharacterStream::write() + * + * @param string $chars + */ + public function write($chars) + { + if (!isset($this->charReader)) { + $this->charReader = $this->charReaderFactory->getReaderFor( + $this->charset); + $this->map = []; + $this->mapType = $this->charReader->getMapType(); + } + $ignored = ''; + $this->datas .= $chars; + $this->charCount += $this->charReader->getCharPositions(substr($this->datas, $this->datasSize), $this->datasSize, $this->map, $ignored); + if (false !== $ignored) { + $this->datasSize = \strlen($this->datas) - \strlen($ignored); + } else { + $this->datasSize = \strlen($this->datas); + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/DependencyContainer.php b/htdocs/includes/swiftmailer/lib/classes/Swift/DependencyContainer.php index c617290d311..3cc885ec03b 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/DependencyContainer.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/DependencyContainer.php @@ -15,373 +15,373 @@ */ class Swift_DependencyContainer { - /** Constant for literal value types */ - const TYPE_VALUE = 0x00001; + /** Constant for literal value types */ + const TYPE_VALUE = 0x00001; - /** Constant for new instance types */ - const TYPE_INSTANCE = 0x00010; + /** Constant for new instance types */ + const TYPE_INSTANCE = 0x00010; - /** Constant for shared instance types */ - const TYPE_SHARED = 0x00100; + /** Constant for shared instance types */ + const TYPE_SHARED = 0x00100; - /** Constant for aliases */ - const TYPE_ALIAS = 0x01000; + /** Constant for aliases */ + const TYPE_ALIAS = 0x01000; - /** Constant for arrays */ - const TYPE_ARRAY = 0x10000; + /** Constant for arrays */ + const TYPE_ARRAY = 0x10000; - /** Singleton instance */ - private static $instance = null; + /** Singleton instance */ + private static $instance = null; - /** The data container */ - private $store = []; + /** The data container */ + private $store = []; - /** The current endpoint in the data container */ - private $endPoint; + /** The current endpoint in the data container */ + private $endPoint; - /** - * Constructor should not be used. - * - * Use {@link getInstance()} instead. - */ - public function __construct() - { - } + /** + * Constructor should not be used. + * + * Use {@link getInstance()} instead. + */ + public function __construct() + { + } - /** - * Returns a singleton of the DependencyContainer. - * - * @return self - */ - public static function getInstance() - { - if (!isset(self::$instance)) { - self::$instance = new self(); - } + /** + * Returns a singleton of the DependencyContainer. + * + * @return self + */ + public static function getInstance() + { + if (!isset(self::$instance)) { + self::$instance = new self(); + } - return self::$instance; - } + return self::$instance; + } - /** - * List the names of all items stored in the Container. - * - * @return array - */ - public function listItems() - { - return array_keys($this->store); - } + /** + * List the names of all items stored in the Container. + * + * @return array + */ + public function listItems() + { + return array_keys($this->store); + } - /** - * Test if an item is registered in this container with the given name. - * - * @see register() - * - * @param string $itemName - * - * @return bool - */ - public function has($itemName) - { - return \array_key_exists($itemName, $this->store) - && isset($this->store[$itemName]['lookupType']); - } + /** + * Test if an item is registered in this container with the given name. + * + * @see register() + * + * @param string $itemName + * + * @return bool + */ + public function has($itemName) + { + return \array_key_exists($itemName, $this->store) + && isset($this->store[$itemName]['lookupType']); + } - /** - * Lookup the item with the given $itemName. - * - * @see register() - * - * @param string $itemName - * - * @return mixed - * - * @throws Swift_DependencyException If the dependency is not found - */ - public function lookup($itemName) - { - if (!$this->has($itemName)) { - throw new Swift_DependencyException('Cannot lookup dependency "'.$itemName.'" since it is not registered.'); - } + /** + * Lookup the item with the given $itemName. + * + * @see register() + * + * @param string $itemName + * + * @return mixed + * + * @throws Swift_DependencyException If the dependency is not found + */ + public function lookup($itemName) + { + if (!$this->has($itemName)) { + throw new Swift_DependencyException('Cannot lookup dependency "'.$itemName.'" since it is not registered.'); + } - switch ($this->store[$itemName]['lookupType']) { - case self::TYPE_ALIAS: - return $this->createAlias($itemName); - case self::TYPE_VALUE: - return $this->getValue($itemName); - case self::TYPE_INSTANCE: - return $this->createNewInstance($itemName); - case self::TYPE_SHARED: - return $this->createSharedInstance($itemName); - case self::TYPE_ARRAY: - return $this->createDependenciesFor($itemName); - } - } + switch ($this->store[$itemName]['lookupType']) { + case self::TYPE_ALIAS: + return $this->createAlias($itemName); + case self::TYPE_VALUE: + return $this->getValue($itemName); + case self::TYPE_INSTANCE: + return $this->createNewInstance($itemName); + case self::TYPE_SHARED: + return $this->createSharedInstance($itemName); + case self::TYPE_ARRAY: + return $this->createDependenciesFor($itemName); + } + } - /** - * Create an array of arguments passed to the constructor of $itemName. - * - * @param string $itemName - * - * @return array - */ - public function createDependenciesFor($itemName) - { - $args = []; - if (isset($this->store[$itemName]['args'])) { - $args = $this->resolveArgs($this->store[$itemName]['args']); - } + /** + * Create an array of arguments passed to the constructor of $itemName. + * + * @param string $itemName + * + * @return array + */ + public function createDependenciesFor($itemName) + { + $args = []; + if (isset($this->store[$itemName]['args'])) { + $args = $this->resolveArgs($this->store[$itemName]['args']); + } - return $args; - } + return $args; + } - /** - * Register a new dependency with $itemName. - * - * This method returns the current DependencyContainer instance because it - * requires the use of the fluid interface to set the specific details for the - * dependency. - * - * @see asNewInstanceOf(), asSharedInstanceOf(), asValue() - * - * @param string $itemName - * - * @return $this - */ - public function register($itemName) - { - $this->store[$itemName] = []; - $this->endPoint = &$this->store[$itemName]; + /** + * Register a new dependency with $itemName. + * + * This method returns the current DependencyContainer instance because it + * requires the use of the fluid interface to set the specific details for the + * dependency. + * + * @see asNewInstanceOf(), asSharedInstanceOf(), asValue() + * + * @param string $itemName + * + * @return $this + */ + public function register($itemName) + { + $this->store[$itemName] = []; + $this->endPoint = &$this->store[$itemName]; - return $this; - } + return $this; + } - /** - * Specify the previously registered item as a literal value. - * - * {@link register()} must be called before this will work. - * - * @param mixed $value - * - * @return $this - */ - public function asValue($value) - { - $endPoint = &$this->getEndPoint(); - $endPoint['lookupType'] = self::TYPE_VALUE; - $endPoint['value'] = $value; + /** + * Specify the previously registered item as a literal value. + * + * {@link register()} must be called before this will work. + * + * @param mixed $value + * + * @return $this + */ + public function asValue($value) + { + $endPoint = &$this->getEndPoint(); + $endPoint['lookupType'] = self::TYPE_VALUE; + $endPoint['value'] = $value; - return $this; - } + return $this; + } - /** - * Specify the previously registered item as an alias of another item. - * - * @param string $lookup - * - * @return $this - */ - public function asAliasOf($lookup) - { - $endPoint = &$this->getEndPoint(); - $endPoint['lookupType'] = self::TYPE_ALIAS; - $endPoint['ref'] = $lookup; + /** + * Specify the previously registered item as an alias of another item. + * + * @param string $lookup + * + * @return $this + */ + public function asAliasOf($lookup) + { + $endPoint = &$this->getEndPoint(); + $endPoint['lookupType'] = self::TYPE_ALIAS; + $endPoint['ref'] = $lookup; - return $this; - } + return $this; + } - /** - * Specify the previously registered item as a new instance of $className. - * - * {@link register()} must be called before this will work. - * Any arguments can be set with {@link withDependencies()}, - * {@link addConstructorValue()} or {@link addConstructorLookup()}. - * - * @see withDependencies(), addConstructorValue(), addConstructorLookup() - * - * @param string $className - * - * @return $this - */ - public function asNewInstanceOf($className) - { - $endPoint = &$this->getEndPoint(); - $endPoint['lookupType'] = self::TYPE_INSTANCE; - $endPoint['className'] = $className; + /** + * Specify the previously registered item as a new instance of $className. + * + * {@link register()} must be called before this will work. + * Any arguments can be set with {@link withDependencies()}, + * {@link addConstructorValue()} or {@link addConstructorLookup()}. + * + * @see withDependencies(), addConstructorValue(), addConstructorLookup() + * + * @param string $className + * + * @return $this + */ + public function asNewInstanceOf($className) + { + $endPoint = &$this->getEndPoint(); + $endPoint['lookupType'] = self::TYPE_INSTANCE; + $endPoint['className'] = $className; - return $this; - } + return $this; + } - /** - * Specify the previously registered item as a shared instance of $className. - * - * {@link register()} must be called before this will work. - * - * @param string $className - * - * @return $this - */ - public function asSharedInstanceOf($className) - { - $endPoint = &$this->getEndPoint(); - $endPoint['lookupType'] = self::TYPE_SHARED; - $endPoint['className'] = $className; + /** + * Specify the previously registered item as a shared instance of $className. + * + * {@link register()} must be called before this will work. + * + * @param string $className + * + * @return $this + */ + public function asSharedInstanceOf($className) + { + $endPoint = &$this->getEndPoint(); + $endPoint['lookupType'] = self::TYPE_SHARED; + $endPoint['className'] = $className; - return $this; - } + return $this; + } - /** - * Specify the previously registered item as array of dependencies. - * - * {@link register()} must be called before this will work. - * - * @return $this - */ - public function asArray() - { - $endPoint = &$this->getEndPoint(); - $endPoint['lookupType'] = self::TYPE_ARRAY; + /** + * Specify the previously registered item as array of dependencies. + * + * {@link register()} must be called before this will work. + * + * @return $this + */ + public function asArray() + { + $endPoint = &$this->getEndPoint(); + $endPoint['lookupType'] = self::TYPE_ARRAY; - return $this; - } + return $this; + } - /** - * Specify a list of injected dependencies for the previously registered item. - * - * This method takes an array of lookup names. - * - * @see addConstructorValue(), addConstructorLookup() - * - * @return $this - */ - public function withDependencies(array $lookups) - { - $endPoint = &$this->getEndPoint(); - $endPoint['args'] = []; - foreach ($lookups as $lookup) { - $this->addConstructorLookup($lookup); - } + /** + * Specify a list of injected dependencies for the previously registered item. + * + * This method takes an array of lookup names. + * + * @see addConstructorValue(), addConstructorLookup() + * + * @return $this + */ + public function withDependencies(array $lookups) + { + $endPoint = &$this->getEndPoint(); + $endPoint['args'] = []; + foreach ($lookups as $lookup) { + $this->addConstructorLookup($lookup); + } - return $this; - } + return $this; + } - /** - * Specify a literal (non looked up) value for the constructor of the - * previously registered item. - * - * @see withDependencies(), addConstructorLookup() - * - * @param mixed $value - * - * @return $this - */ - public function addConstructorValue($value) - { - $endPoint = &$this->getEndPoint(); - if (!isset($endPoint['args'])) { - $endPoint['args'] = []; - } - $endPoint['args'][] = ['type' => 'value', 'item' => $value]; + /** + * Specify a literal (non looked up) value for the constructor of the + * previously registered item. + * + * @see withDependencies(), addConstructorLookup() + * + * @param mixed $value + * + * @return $this + */ + public function addConstructorValue($value) + { + $endPoint = &$this->getEndPoint(); + if (!isset($endPoint['args'])) { + $endPoint['args'] = []; + } + $endPoint['args'][] = ['type' => 'value', 'item' => $value]; - return $this; - } + return $this; + } - /** - * Specify a dependency lookup for the constructor of the previously - * registered item. - * - * @see withDependencies(), addConstructorValue() - * - * @param string $lookup - * - * @return $this - */ - public function addConstructorLookup($lookup) - { - $endPoint = &$this->getEndPoint(); - if (!isset($this->endPoint['args'])) { - $endPoint['args'] = []; - } - $endPoint['args'][] = ['type' => 'lookup', 'item' => $lookup]; + /** + * Specify a dependency lookup for the constructor of the previously + * registered item. + * + * @see withDependencies(), addConstructorValue() + * + * @param string $lookup + * + * @return $this + */ + public function addConstructorLookup($lookup) + { + $endPoint = &$this->getEndPoint(); + if (!isset($this->endPoint['args'])) { + $endPoint['args'] = []; + } + $endPoint['args'][] = ['type' => 'lookup', 'item' => $lookup]; - return $this; - } + return $this; + } - /** Get the literal value with $itemName */ - private function getValue($itemName) - { - return $this->store[$itemName]['value']; - } + /** Get the literal value with $itemName */ + private function getValue($itemName) + { + return $this->store[$itemName]['value']; + } - /** Resolve an alias to another item */ - private function createAlias($itemName) - { - return $this->lookup($this->store[$itemName]['ref']); - } + /** Resolve an alias to another item */ + private function createAlias($itemName) + { + return $this->lookup($this->store[$itemName]['ref']); + } - /** Create a fresh instance of $itemName */ - private function createNewInstance($itemName) - { - $reflector = new ReflectionClass($this->store[$itemName]['className']); - if ($reflector->getConstructor()) { - return $reflector->newInstanceArgs( - $this->createDependenciesFor($itemName) - ); - } + /** Create a fresh instance of $itemName */ + private function createNewInstance($itemName) + { + $reflector = new ReflectionClass($this->store[$itemName]['className']); + if ($reflector->getConstructor()) { + return $reflector->newInstanceArgs( + $this->createDependenciesFor($itemName) + ); + } - return $reflector->newInstance(); - } + return $reflector->newInstance(); + } - /** Create and register a shared instance of $itemName */ - private function createSharedInstance($itemName) - { - if (!isset($this->store[$itemName]['instance'])) { - $this->store[$itemName]['instance'] = $this->createNewInstance($itemName); - } + /** Create and register a shared instance of $itemName */ + private function createSharedInstance($itemName) + { + if (!isset($this->store[$itemName]['instance'])) { + $this->store[$itemName]['instance'] = $this->createNewInstance($itemName); + } - return $this->store[$itemName]['instance']; - } + return $this->store[$itemName]['instance']; + } - /** Get the current endpoint in the store */ - private function &getEndPoint() - { - if (!isset($this->endPoint)) { - throw new BadMethodCallException('Component must first be registered by calling register()'); - } + /** Get the current endpoint in the store */ + private function &getEndPoint() + { + if (!isset($this->endPoint)) { + throw new BadMethodCallException('Component must first be registered by calling register()'); + } - return $this->endPoint; - } + return $this->endPoint; + } - /** Get an argument list with dependencies resolved */ - private function resolveArgs(array $args) - { - $resolved = []; - foreach ($args as $argDefinition) { - switch ($argDefinition['type']) { - case 'lookup': - $resolved[] = $this->lookupRecursive($argDefinition['item']); - break; - case 'value': - $resolved[] = $argDefinition['item']; - break; - } - } + /** Get an argument list with dependencies resolved */ + private function resolveArgs(array $args) + { + $resolved = []; + foreach ($args as $argDefinition) { + switch ($argDefinition['type']) { + case 'lookup': + $resolved[] = $this->lookupRecursive($argDefinition['item']); + break; + case 'value': + $resolved[] = $argDefinition['item']; + break; + } + } - return $resolved; - } + return $resolved; + } - /** Resolve a single dependency with an collections */ - private function lookupRecursive($item) - { - if (\is_array($item)) { - $collection = []; - foreach ($item as $k => $v) { - $collection[$k] = $this->lookupRecursive($v); - } + /** Resolve a single dependency with an collections */ + private function lookupRecursive($item) + { + if (\is_array($item)) { + $collection = []; + foreach ($item as $k => $v) { + $collection[$k] = $this->lookupRecursive($v); + } - return $collection; - } + return $collection; + } - return $this->lookup($item); - } + return $this->lookup($item); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/EmbeddedFile.php b/htdocs/includes/swiftmailer/lib/classes/Swift/EmbeddedFile.php index 0ed8a23d566..30fc68ab03e 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/EmbeddedFile.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/EmbeddedFile.php @@ -15,39 +15,39 @@ */ class Swift_EmbeddedFile extends Swift_Mime_EmbeddedFile { - /** - * Create a new EmbeddedFile. - * - * Details may be optionally provided to the constructor. - * - * @param string|Swift_OutputByteStream $data - * @param string $filename - * @param string $contentType - */ - public function __construct($data = null, $filename = null, $contentType = null) - { - \call_user_func_array( - [$this, 'Swift_Mime_EmbeddedFile::__construct'], - Swift_DependencyContainer::getInstance() - ->createDependenciesFor('mime.embeddedfile') - ); + /** + * Create a new EmbeddedFile. + * + * Details may be optionally provided to the constructor. + * + * @param string|Swift_OutputByteStream $data + * @param string $filename + * @param string $contentType + */ + public function __construct($data = null, $filename = null, $contentType = null) + { + \call_user_func_array( + [$this, 'Swift_Mime_EmbeddedFile::__construct'], + Swift_DependencyContainer::getInstance() + ->createDependenciesFor('mime.embeddedfile') + ); - $this->setBody($data); - $this->setFilename($filename); - if ($contentType) { - $this->setContentType($contentType); - } - } + $this->setBody($data); + $this->setFilename($filename); + if ($contentType) { + $this->setContentType($contentType); + } + } - /** - * Create a new EmbeddedFile from a filesystem path. - * - * @param string $path - * - * @return Swift_Mime_EmbeddedFile - */ - public static function fromPath($path) - { - return (new self())->setFile(new Swift_ByteStream_FileByteStream($path)); - } + /** + * Create a new EmbeddedFile from a filesystem path. + * + * @param string $path + * + * @return Swift_Mime_EmbeddedFile + */ + public static function fromPath($path) + { + return (new self())->setFile(new Swift_ByteStream_FileByteStream($path)); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Encoder/Base64Encoder.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Encoder/Base64Encoder.php index f89e74dc222..b1eedaa051b 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Encoder/Base64Encoder.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Encoder/Base64Encoder.php @@ -15,44 +15,44 @@ */ class Swift_Encoder_Base64Encoder implements Swift_Encoder { - /** - * Takes an unencoded string and produces a Base64 encoded string from it. - * - * Base64 encoded strings have a maximum line length of 76 characters. - * If the first line needs to be shorter, indicate the difference with - * $firstLineOffset. - * - * @param string $string to encode - * @param int $firstLineOffset - * @param int $maxLineLength optional, 0 indicates the default of 76 bytes - * - * @return string - */ - public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) - { - if (0 >= $maxLineLength || 76 < $maxLineLength) { - $maxLineLength = 76; - } + /** + * Takes an unencoded string and produces a Base64 encoded string from it. + * + * Base64 encoded strings have a maximum line length of 76 characters. + * If the first line needs to be shorter, indicate the difference with + * $firstLineOffset. + * + * @param string $string to encode + * @param int $firstLineOffset + * @param int $maxLineLength optional, 0 indicates the default of 76 bytes + * + * @return string + */ + public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) + { + if (0 >= $maxLineLength || 76 < $maxLineLength) { + $maxLineLength = 76; + } - $encodedString = base64_encode($string ?? ''); - $firstLine = ''; + $encodedString = base64_encode($string ?? ''); + $firstLine = ''; - if (0 != $firstLineOffset) { - $firstLine = substr( - $encodedString, 0, $maxLineLength - $firstLineOffset - )."\r\n"; - $encodedString = substr( - $encodedString, $maxLineLength - $firstLineOffset - ); - } + if (0 != $firstLineOffset) { + $firstLine = substr( + $encodedString, 0, $maxLineLength - $firstLineOffset + )."\r\n"; + $encodedString = substr( + $encodedString, $maxLineLength - $firstLineOffset + ); + } - return $firstLine.trim(chunk_split($encodedString, $maxLineLength, "\r\n")); - } + return $firstLine.trim(chunk_split($encodedString, $maxLineLength, "\r\n")); + } - /** - * Does nothing. - */ - public function charsetChanged($charset) - { - } + /** + * Does nothing. + */ + public function charsetChanged($charset) + { + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Encoder/QpEncoder.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Encoder/QpEncoder.php index 24ad727f95b..f078d6d7c38 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Encoder/QpEncoder.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Encoder/QpEncoder.php @@ -17,284 +17,284 @@ */ class Swift_Encoder_QpEncoder implements Swift_Encoder { - /** - * The CharacterStream used for reading characters (as opposed to bytes). - * - * @var Swift_CharacterStream - */ - protected $charStream; + /** + * The CharacterStream used for reading characters (as opposed to bytes). + * + * @var Swift_CharacterStream + */ + protected $charStream; - /** - * A filter used if input should be canonicalized. - * - * @var Swift_StreamFilter - */ - protected $filter; + /** + * A filter used if input should be canonicalized. + * + * @var Swift_StreamFilter + */ + protected $filter; - /** - * Pre-computed QP for HUGE optimization. - * - * @var string[] - */ - protected static $qpMap = [ - 0 => '=00', 1 => '=01', 2 => '=02', 3 => '=03', 4 => '=04', - 5 => '=05', 6 => '=06', 7 => '=07', 8 => '=08', 9 => '=09', - 10 => '=0A', 11 => '=0B', 12 => '=0C', 13 => '=0D', 14 => '=0E', - 15 => '=0F', 16 => '=10', 17 => '=11', 18 => '=12', 19 => '=13', - 20 => '=14', 21 => '=15', 22 => '=16', 23 => '=17', 24 => '=18', - 25 => '=19', 26 => '=1A', 27 => '=1B', 28 => '=1C', 29 => '=1D', - 30 => '=1E', 31 => '=1F', 32 => '=20', 33 => '=21', 34 => '=22', - 35 => '=23', 36 => '=24', 37 => '=25', 38 => '=26', 39 => '=27', - 40 => '=28', 41 => '=29', 42 => '=2A', 43 => '=2B', 44 => '=2C', - 45 => '=2D', 46 => '=2E', 47 => '=2F', 48 => '=30', 49 => '=31', - 50 => '=32', 51 => '=33', 52 => '=34', 53 => '=35', 54 => '=36', - 55 => '=37', 56 => '=38', 57 => '=39', 58 => '=3A', 59 => '=3B', - 60 => '=3C', 61 => '=3D', 62 => '=3E', 63 => '=3F', 64 => '=40', - 65 => '=41', 66 => '=42', 67 => '=43', 68 => '=44', 69 => '=45', - 70 => '=46', 71 => '=47', 72 => '=48', 73 => '=49', 74 => '=4A', - 75 => '=4B', 76 => '=4C', 77 => '=4D', 78 => '=4E', 79 => '=4F', - 80 => '=50', 81 => '=51', 82 => '=52', 83 => '=53', 84 => '=54', - 85 => '=55', 86 => '=56', 87 => '=57', 88 => '=58', 89 => '=59', - 90 => '=5A', 91 => '=5B', 92 => '=5C', 93 => '=5D', 94 => '=5E', - 95 => '=5F', 96 => '=60', 97 => '=61', 98 => '=62', 99 => '=63', - 100 => '=64', 101 => '=65', 102 => '=66', 103 => '=67', 104 => '=68', - 105 => '=69', 106 => '=6A', 107 => '=6B', 108 => '=6C', 109 => '=6D', - 110 => '=6E', 111 => '=6F', 112 => '=70', 113 => '=71', 114 => '=72', - 115 => '=73', 116 => '=74', 117 => '=75', 118 => '=76', 119 => '=77', - 120 => '=78', 121 => '=79', 122 => '=7A', 123 => '=7B', 124 => '=7C', - 125 => '=7D', 126 => '=7E', 127 => '=7F', 128 => '=80', 129 => '=81', - 130 => '=82', 131 => '=83', 132 => '=84', 133 => '=85', 134 => '=86', - 135 => '=87', 136 => '=88', 137 => '=89', 138 => '=8A', 139 => '=8B', - 140 => '=8C', 141 => '=8D', 142 => '=8E', 143 => '=8F', 144 => '=90', - 145 => '=91', 146 => '=92', 147 => '=93', 148 => '=94', 149 => '=95', - 150 => '=96', 151 => '=97', 152 => '=98', 153 => '=99', 154 => '=9A', - 155 => '=9B', 156 => '=9C', 157 => '=9D', 158 => '=9E', 159 => '=9F', - 160 => '=A0', 161 => '=A1', 162 => '=A2', 163 => '=A3', 164 => '=A4', - 165 => '=A5', 166 => '=A6', 167 => '=A7', 168 => '=A8', 169 => '=A9', - 170 => '=AA', 171 => '=AB', 172 => '=AC', 173 => '=AD', 174 => '=AE', - 175 => '=AF', 176 => '=B0', 177 => '=B1', 178 => '=B2', 179 => '=B3', - 180 => '=B4', 181 => '=B5', 182 => '=B6', 183 => '=B7', 184 => '=B8', - 185 => '=B9', 186 => '=BA', 187 => '=BB', 188 => '=BC', 189 => '=BD', - 190 => '=BE', 191 => '=BF', 192 => '=C0', 193 => '=C1', 194 => '=C2', - 195 => '=C3', 196 => '=C4', 197 => '=C5', 198 => '=C6', 199 => '=C7', - 200 => '=C8', 201 => '=C9', 202 => '=CA', 203 => '=CB', 204 => '=CC', - 205 => '=CD', 206 => '=CE', 207 => '=CF', 208 => '=D0', 209 => '=D1', - 210 => '=D2', 211 => '=D3', 212 => '=D4', 213 => '=D5', 214 => '=D6', - 215 => '=D7', 216 => '=D8', 217 => '=D9', 218 => '=DA', 219 => '=DB', - 220 => '=DC', 221 => '=DD', 222 => '=DE', 223 => '=DF', 224 => '=E0', - 225 => '=E1', 226 => '=E2', 227 => '=E3', 228 => '=E4', 229 => '=E5', - 230 => '=E6', 231 => '=E7', 232 => '=E8', 233 => '=E9', 234 => '=EA', - 235 => '=EB', 236 => '=EC', 237 => '=ED', 238 => '=EE', 239 => '=EF', - 240 => '=F0', 241 => '=F1', 242 => '=F2', 243 => '=F3', 244 => '=F4', - 245 => '=F5', 246 => '=F6', 247 => '=F7', 248 => '=F8', 249 => '=F9', - 250 => '=FA', 251 => '=FB', 252 => '=FC', 253 => '=FD', 254 => '=FE', - 255 => '=FF', - ]; + /** + * Pre-computed QP for HUGE optimization. + * + * @var string[] + */ + protected static $qpMap = [ + 0 => '=00', 1 => '=01', 2 => '=02', 3 => '=03', 4 => '=04', + 5 => '=05', 6 => '=06', 7 => '=07', 8 => '=08', 9 => '=09', + 10 => '=0A', 11 => '=0B', 12 => '=0C', 13 => '=0D', 14 => '=0E', + 15 => '=0F', 16 => '=10', 17 => '=11', 18 => '=12', 19 => '=13', + 20 => '=14', 21 => '=15', 22 => '=16', 23 => '=17', 24 => '=18', + 25 => '=19', 26 => '=1A', 27 => '=1B', 28 => '=1C', 29 => '=1D', + 30 => '=1E', 31 => '=1F', 32 => '=20', 33 => '=21', 34 => '=22', + 35 => '=23', 36 => '=24', 37 => '=25', 38 => '=26', 39 => '=27', + 40 => '=28', 41 => '=29', 42 => '=2A', 43 => '=2B', 44 => '=2C', + 45 => '=2D', 46 => '=2E', 47 => '=2F', 48 => '=30', 49 => '=31', + 50 => '=32', 51 => '=33', 52 => '=34', 53 => '=35', 54 => '=36', + 55 => '=37', 56 => '=38', 57 => '=39', 58 => '=3A', 59 => '=3B', + 60 => '=3C', 61 => '=3D', 62 => '=3E', 63 => '=3F', 64 => '=40', + 65 => '=41', 66 => '=42', 67 => '=43', 68 => '=44', 69 => '=45', + 70 => '=46', 71 => '=47', 72 => '=48', 73 => '=49', 74 => '=4A', + 75 => '=4B', 76 => '=4C', 77 => '=4D', 78 => '=4E', 79 => '=4F', + 80 => '=50', 81 => '=51', 82 => '=52', 83 => '=53', 84 => '=54', + 85 => '=55', 86 => '=56', 87 => '=57', 88 => '=58', 89 => '=59', + 90 => '=5A', 91 => '=5B', 92 => '=5C', 93 => '=5D', 94 => '=5E', + 95 => '=5F', 96 => '=60', 97 => '=61', 98 => '=62', 99 => '=63', + 100 => '=64', 101 => '=65', 102 => '=66', 103 => '=67', 104 => '=68', + 105 => '=69', 106 => '=6A', 107 => '=6B', 108 => '=6C', 109 => '=6D', + 110 => '=6E', 111 => '=6F', 112 => '=70', 113 => '=71', 114 => '=72', + 115 => '=73', 116 => '=74', 117 => '=75', 118 => '=76', 119 => '=77', + 120 => '=78', 121 => '=79', 122 => '=7A', 123 => '=7B', 124 => '=7C', + 125 => '=7D', 126 => '=7E', 127 => '=7F', 128 => '=80', 129 => '=81', + 130 => '=82', 131 => '=83', 132 => '=84', 133 => '=85', 134 => '=86', + 135 => '=87', 136 => '=88', 137 => '=89', 138 => '=8A', 139 => '=8B', + 140 => '=8C', 141 => '=8D', 142 => '=8E', 143 => '=8F', 144 => '=90', + 145 => '=91', 146 => '=92', 147 => '=93', 148 => '=94', 149 => '=95', + 150 => '=96', 151 => '=97', 152 => '=98', 153 => '=99', 154 => '=9A', + 155 => '=9B', 156 => '=9C', 157 => '=9D', 158 => '=9E', 159 => '=9F', + 160 => '=A0', 161 => '=A1', 162 => '=A2', 163 => '=A3', 164 => '=A4', + 165 => '=A5', 166 => '=A6', 167 => '=A7', 168 => '=A8', 169 => '=A9', + 170 => '=AA', 171 => '=AB', 172 => '=AC', 173 => '=AD', 174 => '=AE', + 175 => '=AF', 176 => '=B0', 177 => '=B1', 178 => '=B2', 179 => '=B3', + 180 => '=B4', 181 => '=B5', 182 => '=B6', 183 => '=B7', 184 => '=B8', + 185 => '=B9', 186 => '=BA', 187 => '=BB', 188 => '=BC', 189 => '=BD', + 190 => '=BE', 191 => '=BF', 192 => '=C0', 193 => '=C1', 194 => '=C2', + 195 => '=C3', 196 => '=C4', 197 => '=C5', 198 => '=C6', 199 => '=C7', + 200 => '=C8', 201 => '=C9', 202 => '=CA', 203 => '=CB', 204 => '=CC', + 205 => '=CD', 206 => '=CE', 207 => '=CF', 208 => '=D0', 209 => '=D1', + 210 => '=D2', 211 => '=D3', 212 => '=D4', 213 => '=D5', 214 => '=D6', + 215 => '=D7', 216 => '=D8', 217 => '=D9', 218 => '=DA', 219 => '=DB', + 220 => '=DC', 221 => '=DD', 222 => '=DE', 223 => '=DF', 224 => '=E0', + 225 => '=E1', 226 => '=E2', 227 => '=E3', 228 => '=E4', 229 => '=E5', + 230 => '=E6', 231 => '=E7', 232 => '=E8', 233 => '=E9', 234 => '=EA', + 235 => '=EB', 236 => '=EC', 237 => '=ED', 238 => '=EE', 239 => '=EF', + 240 => '=F0', 241 => '=F1', 242 => '=F2', 243 => '=F3', 244 => '=F4', + 245 => '=F5', 246 => '=F6', 247 => '=F7', 248 => '=F8', 249 => '=F9', + 250 => '=FA', 251 => '=FB', 252 => '=FC', 253 => '=FD', 254 => '=FE', + 255 => '=FF', + ]; - protected static $safeMapShare = []; + protected static $safeMapShare = []; - /** - * A map of non-encoded ascii characters. - * - * @var string[] - */ - protected $safeMap = []; + /** + * A map of non-encoded ascii characters. + * + * @var string[] + */ + protected $safeMap = []; - /** - * Creates a new QpEncoder for the given CharacterStream. - * - * @param Swift_CharacterStream $charStream to use for reading characters - * @param Swift_StreamFilter $filter if input should be canonicalized - */ - public function __construct(Swift_CharacterStream $charStream, Swift_StreamFilter $filter = null) - { - $this->charStream = $charStream; - if (!isset(self::$safeMapShare[$this->getSafeMapShareId()])) { - $this->initSafeMap(); - self::$safeMapShare[$this->getSafeMapShareId()] = $this->safeMap; - } else { - $this->safeMap = self::$safeMapShare[$this->getSafeMapShareId()]; - } - $this->filter = $filter; - } + /** + * Creates a new QpEncoder for the given CharacterStream. + * + * @param Swift_CharacterStream $charStream to use for reading characters + * @param Swift_StreamFilter $filter if input should be canonicalized + */ + public function __construct(Swift_CharacterStream $charStream, Swift_StreamFilter $filter = null) + { + $this->charStream = $charStream; + if (!isset(self::$safeMapShare[$this->getSafeMapShareId()])) { + $this->initSafeMap(); + self::$safeMapShare[$this->getSafeMapShareId()] = $this->safeMap; + } else { + $this->safeMap = self::$safeMapShare[$this->getSafeMapShareId()]; + } + $this->filter = $filter; + } - public function __sleep() - { - return ['charStream', 'filter']; - } + public function __sleep() + { + return ['charStream', 'filter']; + } - public function __wakeup() - { - if (!isset(self::$safeMapShare[$this->getSafeMapShareId()])) { - $this->initSafeMap(); - self::$safeMapShare[$this->getSafeMapShareId()] = $this->safeMap; - } else { - $this->safeMap = self::$safeMapShare[$this->getSafeMapShareId()]; - } - } + public function __wakeup() + { + if (!isset(self::$safeMapShare[$this->getSafeMapShareId()])) { + $this->initSafeMap(); + self::$safeMapShare[$this->getSafeMapShareId()] = $this->safeMap; + } else { + $this->safeMap = self::$safeMapShare[$this->getSafeMapShareId()]; + } + } - protected function getSafeMapShareId() - { - return static::class; - } + protected function getSafeMapShareId() + { + return static::class; + } - protected function initSafeMap() - { - foreach (array_merge( - [0x09, 0x20], range(0x21, 0x3C), range(0x3E, 0x7E)) as $byte) { - $this->safeMap[$byte] = \chr($byte); - } - } + protected function initSafeMap() + { + foreach (array_merge( + [0x09, 0x20], range(0x21, 0x3C), range(0x3E, 0x7E)) as $byte) { + $this->safeMap[$byte] = \chr($byte); + } + } - /** - * Takes an unencoded string and produces a QP encoded string from it. - * - * QP encoded strings have a maximum line length of 76 characters. - * If the first line needs to be shorter, indicate the difference with - * $firstLineOffset. - * - * @param string $string to encode - * @param int $firstLineOffset optional - * @param int $maxLineLength optional 0 indicates the default of 76 chars - * - * @return string - */ - public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) - { - if ($maxLineLength > 76 || $maxLineLength <= 0) { - $maxLineLength = 76; - } + /** + * Takes an unencoded string and produces a QP encoded string from it. + * + * QP encoded strings have a maximum line length of 76 characters. + * If the first line needs to be shorter, indicate the difference with + * $firstLineOffset. + * + * @param string $string to encode + * @param int $firstLineOffset optional + * @param int $maxLineLength optional 0 indicates the default of 76 chars + * + * @return string + */ + public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) + { + if ($maxLineLength > 76 || $maxLineLength <= 0) { + $maxLineLength = 76; + } - $thisLineLength = $maxLineLength - $firstLineOffset; + $thisLineLength = $maxLineLength - $firstLineOffset; - $lines = []; - $lNo = 0; - $lines[$lNo] = ''; - $currentLine = &$lines[$lNo++]; - $size = $lineLen = 0; + $lines = []; + $lNo = 0; + $lines[$lNo] = ''; + $currentLine = &$lines[$lNo++]; + $size = $lineLen = 0; - $this->charStream->flushContents(); - $this->charStream->importString($string); + $this->charStream->flushContents(); + $this->charStream->importString($string); - // Fetching more than 4 chars at one is slower, as is fetching fewer bytes - // Conveniently 4 chars is the UTF-8 safe number since UTF-8 has up to 6 - // bytes per char and (6 * 4 * 3 = 72 chars per line) * =NN is 3 bytes - while (false !== $bytes = $this->nextSequence()) { - // If we're filtering the input - if (isset($this->filter)) { - // If we can't filter because we need more bytes - while ($this->filter->shouldBuffer($bytes)) { - // Then collect bytes into the buffer - if (false === $moreBytes = $this->nextSequence(1)) { - break; - } + // Fetching more than 4 chars at one is slower, as is fetching fewer bytes + // Conveniently 4 chars is the UTF-8 safe number since UTF-8 has up to 6 + // bytes per char and (6 * 4 * 3 = 72 chars per line) * =NN is 3 bytes + while (false !== $bytes = $this->nextSequence()) { + // If we're filtering the input + if (isset($this->filter)) { + // If we can't filter because we need more bytes + while ($this->filter->shouldBuffer($bytes)) { + // Then collect bytes into the buffer + if (false === $moreBytes = $this->nextSequence(1)) { + break; + } - foreach ($moreBytes as $b) { - $bytes[] = $b; - } - } - // And filter them - $bytes = $this->filter->filter($bytes); - } + foreach ($moreBytes as $b) { + $bytes[] = $b; + } + } + // And filter them + $bytes = $this->filter->filter($bytes); + } - $enc = $this->encodeByteSequence($bytes, $size); + $enc = $this->encodeByteSequence($bytes, $size); - $i = strpos($enc, '=0D=0A'); - $newLineLength = $lineLen + (false === $i ? $size : $i); + $i = strpos($enc, '=0D=0A'); + $newLineLength = $lineLen + (false === $i ? $size : $i); - if ($currentLine && $newLineLength >= $thisLineLength) { - $lines[$lNo] = ''; - $currentLine = &$lines[$lNo++]; - $thisLineLength = $maxLineLength; - $lineLen = 0; - } + if ($currentLine && $newLineLength >= $thisLineLength) { + $lines[$lNo] = ''; + $currentLine = &$lines[$lNo++]; + $thisLineLength = $maxLineLength; + $lineLen = 0; + } - $currentLine .= $enc; + $currentLine .= $enc; - if (false === $i) { - $lineLen += $size; - } else { - // 6 is the length of '=0D=0A'. - $lineLen = $size - strrpos($enc, '=0D=0A') - 6; - } - } + if (false === $i) { + $lineLen += $size; + } else { + // 6 is the length of '=0D=0A'. + $lineLen = $size - strrpos($enc, '=0D=0A') - 6; + } + } - return $this->standardize(implode("=\r\n", $lines)); - } + return $this->standardize(implode("=\r\n", $lines)); + } - /** - * Updates the charset used. - * - * @param string $charset - */ - public function charsetChanged($charset) - { - $this->charStream->setCharacterSet($charset); - } + /** + * Updates the charset used. + * + * @param string $charset + */ + public function charsetChanged($charset) + { + $this->charStream->setCharacterSet($charset); + } - /** - * Encode the given byte array into a verbatim QP form. - * - * @param int[] $bytes - * @param int $size - * - * @return string - */ - protected function encodeByteSequence(array $bytes, &$size) - { - $ret = ''; - $size = 0; - foreach ($bytes as $b) { - if (isset($this->safeMap[$b])) { - $ret .= $this->safeMap[$b]; - ++$size; - } else { - $ret .= self::$qpMap[$b]; - $size += 3; - } - } + /** + * Encode the given byte array into a verbatim QP form. + * + * @param int[] $bytes + * @param int $size + * + * @return string + */ + protected function encodeByteSequence(array $bytes, &$size) + { + $ret = ''; + $size = 0; + foreach ($bytes as $b) { + if (isset($this->safeMap[$b])) { + $ret .= $this->safeMap[$b]; + ++$size; + } else { + $ret .= self::$qpMap[$b]; + $size += 3; + } + } - return $ret; - } + return $ret; + } - /** - * Get the next sequence of bytes to read from the char stream. - * - * @param int $size number of bytes to read - * - * @return int[] - */ - protected function nextSequence($size = 4) - { - return $this->charStream->readBytes($size); - } + /** + * Get the next sequence of bytes to read from the char stream. + * + * @param int $size number of bytes to read + * + * @return int[] + */ + protected function nextSequence($size = 4) + { + return $this->charStream->readBytes($size); + } - /** - * Make sure CRLF is correct and HT/SPACE are in valid places. - * - * @param string $string - * - * @return string - */ - protected function standardize($string) - { - $string = str_replace(["\t=0D=0A", ' =0D=0A', '=0D=0A'], - ["=09\r\n", "=20\r\n", "\r\n"], $string - ); - switch ($end = \ord(substr($string, -1))) { - case 0x09: - case 0x20: - $string = substr_replace($string, self::$qpMap[$end], -1); - } + /** + * Make sure CRLF is correct and HT/SPACE are in valid places. + * + * @param string $string + * + * @return string + */ + protected function standardize($string) + { + $string = str_replace(["\t=0D=0A", ' =0D=0A', '=0D=0A'], + ["=09\r\n", "=20\r\n", "\r\n"], $string + ); + switch ($end = \ord(substr($string, -1))) { + case 0x09: + case 0x20: + $string = substr_replace($string, self::$qpMap[$end], -1); + } - return $string; - } + return $string; + } - /** - * Make a deep copy of object. - */ - public function __clone() - { - $this->charStream = clone $this->charStream; - } + /** + * Make a deep copy of object. + */ + public function __clone() + { + $this->charStream = clone $this->charStream; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Encoder/Rfc2231Encoder.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Encoder/Rfc2231Encoder.php index 488fcfd4717..7eac36813e0 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Encoder/Rfc2231Encoder.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Encoder/Rfc2231Encoder.php @@ -15,76 +15,76 @@ */ class Swift_Encoder_Rfc2231Encoder implements Swift_Encoder { - /** - * A character stream to use when reading a string as characters instead of bytes. - * - * @var Swift_CharacterStream - */ - private $charStream; + /** + * A character stream to use when reading a string as characters instead of bytes. + * + * @var Swift_CharacterStream + */ + private $charStream; - /** - * Creates a new Rfc2231Encoder using the given character stream instance. - */ - public function __construct(Swift_CharacterStream $charStream) - { - $this->charStream = $charStream; - } + /** + * Creates a new Rfc2231Encoder using the given character stream instance. + */ + public function __construct(Swift_CharacterStream $charStream) + { + $this->charStream = $charStream; + } - /** - * Takes an unencoded string and produces a string encoded according to - * RFC 2231 from it. - * - * @param string $string - * @param int $firstLineOffset - * @param int $maxLineLength optional, 0 indicates the default of 75 bytes - * - * @return string - */ - public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) - { - $lines = []; - $lineCount = 0; - $lines[] = ''; - $currentLine = &$lines[$lineCount++]; + /** + * Takes an unencoded string and produces a string encoded according to + * RFC 2231 from it. + * + * @param string $string + * @param int $firstLineOffset + * @param int $maxLineLength optional, 0 indicates the default of 75 bytes + * + * @return string + */ + public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) + { + $lines = []; + $lineCount = 0; + $lines[] = ''; + $currentLine = &$lines[$lineCount++]; - if (0 >= $maxLineLength) { - $maxLineLength = 75; - } + if (0 >= $maxLineLength) { + $maxLineLength = 75; + } - $this->charStream->flushContents(); - $this->charStream->importString($string); + $this->charStream->flushContents(); + $this->charStream->importString($string); - $thisLineLength = $maxLineLength - $firstLineOffset; + $thisLineLength = $maxLineLength - $firstLineOffset; - while (false !== $char = $this->charStream->read(4)) { - $encodedChar = rawurlencode($char); - if (0 != \strlen($currentLine) - && \strlen($currentLine.$encodedChar) > $thisLineLength) { - $lines[] = ''; - $currentLine = &$lines[$lineCount++]; - $thisLineLength = $maxLineLength; - } - $currentLine .= $encodedChar; - } + while (false !== $char = $this->charStream->read(4)) { + $encodedChar = rawurlencode($char); + if (0 != \strlen($currentLine) + && \strlen($currentLine.$encodedChar) > $thisLineLength) { + $lines[] = ''; + $currentLine = &$lines[$lineCount++]; + $thisLineLength = $maxLineLength; + } + $currentLine .= $encodedChar; + } - return implode("\r\n", $lines); - } + return implode("\r\n", $lines); + } - /** - * Updates the charset used. - * - * @param string $charset - */ - public function charsetChanged($charset) - { - $this->charStream->setCharacterSet($charset); - } + /** + * Updates the charset used. + * + * @param string $charset + */ + public function charsetChanged($charset) + { + $this->charStream->setCharacterSet($charset); + } - /** - * Make a deep copy of object. - */ - public function __clone() - { - $this->charStream = clone $this->charStream; - } + /** + * Make a deep copy of object. + */ + public function __clone() + { + $this->charStream = clone $this->charStream; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/CommandEvent.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/CommandEvent.php index 1524fda752a..18994c184f3 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/CommandEvent.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/CommandEvent.php @@ -15,50 +15,50 @@ */ class Swift_Events_CommandEvent extends Swift_Events_EventObject { - /** - * The command sent to the server. - * - * @var string - */ - private $command; + /** + * The command sent to the server. + * + * @var string + */ + private $command; - /** - * An array of codes which a successful response will contain. - * - * @var int[] - */ - private $successCodes = []; + /** + * An array of codes which a successful response will contain. + * + * @var int[] + */ + private $successCodes = []; - /** - * Create a new CommandEvent for $source with $command. - * - * @param string $command - * @param array $successCodes - */ - public function __construct(Swift_Transport $source, $command, $successCodes = []) - { - parent::__construct($source); - $this->command = $command; - $this->successCodes = $successCodes; - } + /** + * Create a new CommandEvent for $source with $command. + * + * @param string $command + * @param array $successCodes + */ + public function __construct(Swift_Transport $source, $command, $successCodes = []) + { + parent::__construct($source); + $this->command = $command; + $this->successCodes = $successCodes; + } - /** - * Get the command which was sent to the server. - * - * @return string - */ - public function getCommand() - { - return $this->command; - } + /** + * Get the command which was sent to the server. + * + * @return string + */ + public function getCommand() + { + return $this->command; + } - /** - * Get the numeric response codes which indicate success for this command. - * - * @return int[] - */ - public function getSuccessCodes() - { - return $this->successCodes; - } + /** + * Get the numeric response codes which indicate success for this command. + * + * @return int[] + */ + public function getSuccessCodes() + { + return $this->successCodes; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/CommandListener.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/CommandListener.php index 7dff32b4ee6..b158eab462a 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/CommandListener.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/CommandListener.php @@ -15,8 +15,8 @@ */ interface Swift_Events_CommandListener extends Swift_Events_EventListener { - /** - * Invoked immediately following a command being sent. - */ - public function commandSent(Swift_Events_CommandEvent $evt); + /** + * Invoked immediately following a command being sent. + */ + public function commandSent(Swift_Events_CommandEvent $evt); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/EventDispatcher.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/EventDispatcher.php index 1de97381930..df25a124863 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/EventDispatcher.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/EventDispatcher.php @@ -15,56 +15,56 @@ */ interface Swift_Events_EventDispatcher { - /** - * Create a new SendEvent for $source and $message. - * - * @return Swift_Events_SendEvent - */ - public function createSendEvent(Swift_Transport $source, Swift_Mime_SimpleMessage $message); + /** + * Create a new SendEvent for $source and $message. + * + * @return Swift_Events_SendEvent + */ + public function createSendEvent(Swift_Transport $source, Swift_Mime_SimpleMessage $message); - /** - * Create a new CommandEvent for $source and $command. - * - * @param string $command That will be executed - * @param array $successCodes That are needed - * - * @return Swift_Events_CommandEvent - */ - public function createCommandEvent(Swift_Transport $source, $command, $successCodes = []); + /** + * Create a new CommandEvent for $source and $command. + * + * @param string $command That will be executed + * @param array $successCodes That are needed + * + * @return Swift_Events_CommandEvent + */ + public function createCommandEvent(Swift_Transport $source, $command, $successCodes = []); - /** - * Create a new ResponseEvent for $source and $response. - * - * @param string $response - * @param bool $valid If the response is valid - * - * @return Swift_Events_ResponseEvent - */ - public function createResponseEvent(Swift_Transport $source, $response, $valid); + /** + * Create a new ResponseEvent for $source and $response. + * + * @param string $response + * @param bool $valid If the response is valid + * + * @return Swift_Events_ResponseEvent + */ + public function createResponseEvent(Swift_Transport $source, $response, $valid); - /** - * Create a new TransportChangeEvent for $source. - * - * @return Swift_Events_TransportChangeEvent - */ - public function createTransportChangeEvent(Swift_Transport $source); + /** + * Create a new TransportChangeEvent for $source. + * + * @return Swift_Events_TransportChangeEvent + */ + public function createTransportChangeEvent(Swift_Transport $source); - /** - * Create a new TransportExceptionEvent for $source. - * - * @return Swift_Events_TransportExceptionEvent - */ - public function createTransportExceptionEvent(Swift_Transport $source, Swift_TransportException $ex); + /** + * Create a new TransportExceptionEvent for $source. + * + * @return Swift_Events_TransportExceptionEvent + */ + public function createTransportExceptionEvent(Swift_Transport $source, Swift_TransportException $ex); - /** - * Bind an event listener to this dispatcher. - */ - public function bindEventListener(Swift_Events_EventListener $listener); + /** + * Bind an event listener to this dispatcher. + */ + public function bindEventListener(Swift_Events_EventListener $listener); - /** - * Dispatch the given Event to all suitable listeners. - * - * @param string $target method - */ - public function dispatchEvent(Swift_Events_EventObject $evt, $target); + /** + * Dispatch the given Event to all suitable listeners. + * + * @param string $target method + */ + public function dispatchEvent(Swift_Events_EventObject $evt, $target); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/EventObject.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/EventObject.php index 8e3f672cdeb..24a11f44e23 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/EventObject.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/EventObject.php @@ -15,47 +15,47 @@ */ class Swift_Events_EventObject implements Swift_Events_Event { - /** The source of this Event */ - private $source; + /** The source of this Event */ + private $source; - /** The state of this Event (should it bubble up the stack?) */ - private $bubbleCancelled = false; + /** The state of this Event (should it bubble up the stack?) */ + private $bubbleCancelled = false; - /** - * Create a new EventObject originating at $source. - * - * @param object $source - */ - public function __construct($source) - { - $this->source = $source; - } + /** + * Create a new EventObject originating at $source. + * + * @param object $source + */ + public function __construct($source) + { + $this->source = $source; + } - /** - * Get the source object of this event. - * - * @return object - */ - public function getSource() - { - return $this->source; - } + /** + * Get the source object of this event. + * + * @return object + */ + public function getSource() + { + return $this->source; + } - /** - * Prevent this Event from bubbling any further up the stack. - */ - public function cancelBubble($cancel = true) - { - $this->bubbleCancelled = $cancel; - } + /** + * Prevent this Event from bubbling any further up the stack. + */ + public function cancelBubble($cancel = true) + { + $this->bubbleCancelled = $cancel; + } - /** - * Returns true if this Event will not bubble any further up the stack. - * - * @return bool - */ - public function bubbleCancelled() - { - return $this->bubbleCancelled; - } + /** + * Returns true if this Event will not bubble any further up the stack. + * + * @return bool + */ + public function bubbleCancelled() + { + return $this->bubbleCancelled; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/ResponseEvent.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/ResponseEvent.php index ddae7aab9a4..ff7c37116ba 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/ResponseEvent.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/ResponseEvent.php @@ -15,50 +15,50 @@ */ class Swift_Events_ResponseEvent extends Swift_Events_EventObject { - /** - * The overall result. - * - * @var bool - */ - private $valid; + /** + * The overall result. + * + * @var bool + */ + private $valid; - /** - * The response received from the server. - * - * @var string - */ - private $response; + /** + * The response received from the server. + * + * @var string + */ + private $response; - /** - * Create a new ResponseEvent for $source and $response. - * - * @param string $response - * @param bool $valid - */ - public function __construct(Swift_Transport $source, $response, $valid = false) - { - parent::__construct($source); - $this->response = $response; - $this->valid = $valid; - } + /** + * Create a new ResponseEvent for $source and $response. + * + * @param string $response + * @param bool $valid + */ + public function __construct(Swift_Transport $source, $response, $valid = false) + { + parent::__construct($source); + $this->response = $response; + $this->valid = $valid; + } - /** - * Get the response which was received from the server. - * - * @return string - */ - public function getResponse() - { - return $this->response; - } + /** + * Get the response which was received from the server. + * + * @return string + */ + public function getResponse() + { + return $this->response; + } - /** - * Get the success status of this Event. - * - * @return bool - */ - public function isValid() - { - return $this->valid; - } + /** + * Get the success status of this Event. + * + * @return bool + */ + public function isValid() + { + return $this->valid; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/ResponseListener.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/ResponseListener.php index ba607510426..85115a33811 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/ResponseListener.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/ResponseListener.php @@ -15,8 +15,8 @@ */ interface Swift_Events_ResponseListener extends Swift_Events_EventListener { - /** - * Invoked immediately following a response coming back. - */ - public function responseReceived(Swift_Events_ResponseEvent $evt); + /** + * Invoked immediately following a response coming back. + */ + public function responseReceived(Swift_Events_ResponseEvent $evt); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/SendEvent.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/SendEvent.php index c485f29010e..a435691e0b0 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/SendEvent.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/SendEvent.php @@ -15,112 +15,112 @@ */ class Swift_Events_SendEvent extends Swift_Events_EventObject { - /** Sending has yet to occur */ - const RESULT_PENDING = 0x0001; + /** Sending has yet to occur */ + const RESULT_PENDING = 0x0001; - /** Email is spooled, ready to be sent */ - const RESULT_SPOOLED = 0x0011; + /** Email is spooled, ready to be sent */ + const RESULT_SPOOLED = 0x0011; - /** Sending was successful */ - const RESULT_SUCCESS = 0x0010; + /** Sending was successful */ + const RESULT_SUCCESS = 0x0010; - /** Sending worked, but there were some failures */ - const RESULT_TENTATIVE = 0x0100; + /** Sending worked, but there were some failures */ + const RESULT_TENTATIVE = 0x0100; - /** Sending failed */ - const RESULT_FAILED = 0x1000; + /** Sending failed */ + const RESULT_FAILED = 0x1000; - /** - * The Message being sent. - * - * @var Swift_Mime_SimpleMessage - */ - private $message; + /** + * The Message being sent. + * + * @var Swift_Mime_SimpleMessage + */ + private $message; - /** - * Any recipients which failed after sending. - * - * @var string[] - */ - private $failedRecipients = []; + /** + * Any recipients which failed after sending. + * + * @var string[] + */ + private $failedRecipients = []; - /** - * The overall result as a bitmask from the class constants. - * - * @var int - */ - private $result; + /** + * The overall result as a bitmask from the class constants. + * + * @var int + */ + private $result; - /** - * Create a new SendEvent for $source and $message. - */ - public function __construct(Swift_Transport $source, Swift_Mime_SimpleMessage $message) - { - parent::__construct($source); - $this->message = $message; - $this->result = self::RESULT_PENDING; - } + /** + * Create a new SendEvent for $source and $message. + */ + public function __construct(Swift_Transport $source, Swift_Mime_SimpleMessage $message) + { + parent::__construct($source); + $this->message = $message; + $this->result = self::RESULT_PENDING; + } - /** - * Get the Transport used to send the Message. - * - * @return Swift_Transport - */ - public function getTransport() - { - return $this->getSource(); - } + /** + * Get the Transport used to send the Message. + * + * @return Swift_Transport + */ + public function getTransport() + { + return $this->getSource(); + } - /** - * Get the Message being sent. - * - * @return Swift_Mime_SimpleMessage - */ - public function getMessage() - { - return $this->message; - } + /** + * Get the Message being sent. + * + * @return Swift_Mime_SimpleMessage + */ + public function getMessage() + { + return $this->message; + } - /** - * Set the array of addresses that failed in sending. - * - * @param array $recipients - */ - public function setFailedRecipients($recipients) - { - $this->failedRecipients = $recipients; - } + /** + * Set the array of addresses that failed in sending. + * + * @param array $recipients + */ + public function setFailedRecipients($recipients) + { + $this->failedRecipients = $recipients; + } - /** - * Get an recipient addresses which were not accepted for delivery. - * - * @return string[] - */ - public function getFailedRecipients() - { - return $this->failedRecipients; - } + /** + * Get an recipient addresses which were not accepted for delivery. + * + * @return string[] + */ + public function getFailedRecipients() + { + return $this->failedRecipients; + } - /** - * Set the result of sending. - * - * @param int $result - */ - public function setResult($result) - { - $this->result = $result; - } + /** + * Set the result of sending. + * + * @param int $result + */ + public function setResult($result) + { + $this->result = $result; + } - /** - * Get the result of this Event. - * - * The return value is a bitmask from - * {@see RESULT_PENDING, RESULT_SUCCESS, RESULT_TENTATIVE, RESULT_FAILED} - * - * @return int - */ - public function getResult() - { - return $this->result; - } + /** + * Get the result of this Event. + * + * The return value is a bitmask from + * {@see RESULT_PENDING, RESULT_SUCCESS, RESULT_TENTATIVE, RESULT_FAILED} + * + * @return int + */ + public function getResult() + { + return $this->result; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/SendListener.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/SendListener.php index 33f7f03f870..f7bf55ef56c 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/SendListener.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/SendListener.php @@ -15,13 +15,13 @@ */ interface Swift_Events_SendListener extends Swift_Events_EventListener { - /** - * Invoked immediately before the Message is sent. - */ - public function beforeSendPerformed(Swift_Events_SendEvent $evt); + /** + * Invoked immediately before the Message is sent. + */ + public function beforeSendPerformed(Swift_Events_SendEvent $evt); - /** - * Invoked immediately after the Message is sent. - */ - public function sendPerformed(Swift_Events_SendEvent $evt); + /** + * Invoked immediately after the Message is sent. + */ + public function sendPerformed(Swift_Events_SendEvent $evt); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/SimpleEventDispatcher.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/SimpleEventDispatcher.php index 7531214d824..6557103c99a 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/SimpleEventDispatcher.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/SimpleEventDispatcher.php @@ -15,128 +15,128 @@ */ class Swift_Events_SimpleEventDispatcher implements Swift_Events_EventDispatcher { - /** A map of event types to their associated listener types */ - private $eventMap = []; + /** A map of event types to their associated listener types */ + private $eventMap = []; - /** Event listeners bound to this dispatcher */ - private $listeners = []; + /** Event listeners bound to this dispatcher */ + private $listeners = []; - /** - * Create a new EventDispatcher. - */ - public function __construct() - { - $this->eventMap = [ - 'Swift_Events_CommandEvent' => 'Swift_Events_CommandListener', - 'Swift_Events_ResponseEvent' => 'Swift_Events_ResponseListener', - 'Swift_Events_SendEvent' => 'Swift_Events_SendListener', - 'Swift_Events_TransportChangeEvent' => 'Swift_Events_TransportChangeListener', - 'Swift_Events_TransportExceptionEvent' => 'Swift_Events_TransportExceptionListener', - ]; - } + /** + * Create a new EventDispatcher. + */ + public function __construct() + { + $this->eventMap = [ + 'Swift_Events_CommandEvent' => 'Swift_Events_CommandListener', + 'Swift_Events_ResponseEvent' => 'Swift_Events_ResponseListener', + 'Swift_Events_SendEvent' => 'Swift_Events_SendListener', + 'Swift_Events_TransportChangeEvent' => 'Swift_Events_TransportChangeListener', + 'Swift_Events_TransportExceptionEvent' => 'Swift_Events_TransportExceptionListener', + ]; + } - /** - * Create a new SendEvent for $source and $message. - * - * @return Swift_Events_SendEvent - */ - public function createSendEvent(Swift_Transport $source, Swift_Mime_SimpleMessage $message) - { - return new Swift_Events_SendEvent($source, $message); - } + /** + * Create a new SendEvent for $source and $message. + * + * @return Swift_Events_SendEvent + */ + public function createSendEvent(Swift_Transport $source, Swift_Mime_SimpleMessage $message) + { + return new Swift_Events_SendEvent($source, $message); + } - /** - * Create a new CommandEvent for $source and $command. - * - * @param string $command That will be executed - * @param array $successCodes That are needed - * - * @return Swift_Events_CommandEvent - */ - public function createCommandEvent(Swift_Transport $source, $command, $successCodes = []) - { - return new Swift_Events_CommandEvent($source, $command, $successCodes); - } + /** + * Create a new CommandEvent for $source and $command. + * + * @param string $command That will be executed + * @param array $successCodes That are needed + * + * @return Swift_Events_CommandEvent + */ + public function createCommandEvent(Swift_Transport $source, $command, $successCodes = []) + { + return new Swift_Events_CommandEvent($source, $command, $successCodes); + } - /** - * Create a new ResponseEvent for $source and $response. - * - * @param string $response - * @param bool $valid If the response is valid - * - * @return Swift_Events_ResponseEvent - */ - public function createResponseEvent(Swift_Transport $source, $response, $valid) - { - return new Swift_Events_ResponseEvent($source, $response, $valid); - } + /** + * Create a new ResponseEvent for $source and $response. + * + * @param string $response + * @param bool $valid If the response is valid + * + * @return Swift_Events_ResponseEvent + */ + public function createResponseEvent(Swift_Transport $source, $response, $valid) + { + return new Swift_Events_ResponseEvent($source, $response, $valid); + } - /** - * Create a new TransportChangeEvent for $source. - * - * @return Swift_Events_TransportChangeEvent - */ - public function createTransportChangeEvent(Swift_Transport $source) - { - return new Swift_Events_TransportChangeEvent($source); - } + /** + * Create a new TransportChangeEvent for $source. + * + * @return Swift_Events_TransportChangeEvent + */ + public function createTransportChangeEvent(Swift_Transport $source) + { + return new Swift_Events_TransportChangeEvent($source); + } - /** - * Create a new TransportExceptionEvent for $source. - * - * @return Swift_Events_TransportExceptionEvent - */ - public function createTransportExceptionEvent(Swift_Transport $source, Swift_TransportException $ex) - { - return new Swift_Events_TransportExceptionEvent($source, $ex); - } + /** + * Create a new TransportExceptionEvent for $source. + * + * @return Swift_Events_TransportExceptionEvent + */ + public function createTransportExceptionEvent(Swift_Transport $source, Swift_TransportException $ex) + { + return new Swift_Events_TransportExceptionEvent($source, $ex); + } - /** - * Bind an event listener to this dispatcher. - */ - public function bindEventListener(Swift_Events_EventListener $listener) - { - foreach ($this->listeners as $l) { - // Already loaded - if ($l === $listener) { - return; - } - } - $this->listeners[] = $listener; - } + /** + * Bind an event listener to this dispatcher. + */ + public function bindEventListener(Swift_Events_EventListener $listener) + { + foreach ($this->listeners as $l) { + // Already loaded + if ($l === $listener) { + return; + } + } + $this->listeners[] = $listener; + } - /** - * Dispatch the given Event to all suitable listeners. - * - * @param string $target method - */ - public function dispatchEvent(Swift_Events_EventObject $evt, $target) - { - $bubbleQueue = $this->prepareBubbleQueue($evt); - $this->bubble($bubbleQueue, $evt, $target); - } + /** + * Dispatch the given Event to all suitable listeners. + * + * @param string $target method + */ + public function dispatchEvent(Swift_Events_EventObject $evt, $target) + { + $bubbleQueue = $this->prepareBubbleQueue($evt); + $this->bubble($bubbleQueue, $evt, $target); + } - /** Queue listeners on a stack ready for $evt to be bubbled up it */ - private function prepareBubbleQueue(Swift_Events_EventObject $evt) - { - $bubbleQueue = []; - $evtClass = \get_class($evt); - foreach ($this->listeners as $listener) { - if (\array_key_exists($evtClass, $this->eventMap) - && ($listener instanceof $this->eventMap[$evtClass])) { - $bubbleQueue[] = $listener; - } - } + /** Queue listeners on a stack ready for $evt to be bubbled up it */ + private function prepareBubbleQueue(Swift_Events_EventObject $evt) + { + $bubbleQueue = []; + $evtClass = \get_class($evt); + foreach ($this->listeners as $listener) { + if (\array_key_exists($evtClass, $this->eventMap) + && ($listener instanceof $this->eventMap[$evtClass])) { + $bubbleQueue[] = $listener; + } + } - return $bubbleQueue; - } + return $bubbleQueue; + } - /** Bubble $evt up the stack calling $target() on each listener */ - private function bubble(array &$bubbleQueue, Swift_Events_EventObject $evt, $target) - { - if (!$evt->bubbleCancelled() && $listener = array_shift($bubbleQueue)) { - $listener->$target($evt); - $this->bubble($bubbleQueue, $evt, $target); - } - } + /** Bubble $evt up the stack calling $target() on each listener */ + private function bubble(array &$bubbleQueue, Swift_Events_EventObject $evt, $target) + { + if (!$evt->bubbleCancelled() && $listener = array_shift($bubbleQueue)) { + $listener->$target($evt); + $this->bubble($bubbleQueue, $evt, $target); + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/TransportChangeListener.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/TransportChangeListener.php index 24d6bde50bd..4a7492bc551 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/TransportChangeListener.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/TransportChangeListener.php @@ -15,23 +15,23 @@ */ interface Swift_Events_TransportChangeListener extends Swift_Events_EventListener { - /** - * Invoked just before a Transport is started. - */ - public function beforeTransportStarted(Swift_Events_TransportChangeEvent $evt); + /** + * Invoked just before a Transport is started. + */ + public function beforeTransportStarted(Swift_Events_TransportChangeEvent $evt); - /** - * Invoked immediately after the Transport is started. - */ - public function transportStarted(Swift_Events_TransportChangeEvent $evt); + /** + * Invoked immediately after the Transport is started. + */ + public function transportStarted(Swift_Events_TransportChangeEvent $evt); - /** - * Invoked just before a Transport is stopped. - */ - public function beforeTransportStopped(Swift_Events_TransportChangeEvent $evt); + /** + * Invoked just before a Transport is stopped. + */ + public function beforeTransportStopped(Swift_Events_TransportChangeEvent $evt); - /** - * Invoked immediately after the Transport is stopped. - */ - public function transportStopped(Swift_Events_TransportChangeEvent $evt); + /** + * Invoked immediately after the Transport is stopped. + */ + public function transportStopped(Swift_Events_TransportChangeEvent $evt); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/TransportExceptionEvent.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/TransportExceptionEvent.php index 0301c8dfc11..df442cc70f6 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/TransportExceptionEvent.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/TransportExceptionEvent.php @@ -15,29 +15,29 @@ */ class Swift_Events_TransportExceptionEvent extends Swift_Events_EventObject { - /** - * The Exception thrown. - * - * @var Swift_TransportException - */ - private $exception; + /** + * The Exception thrown. + * + * @var Swift_TransportException + */ + private $exception; - /** - * Create a new TransportExceptionEvent for $transport. - */ - public function __construct(Swift_Transport $transport, Swift_TransportException $ex) - { - parent::__construct($transport); - $this->exception = $ex; - } + /** + * Create a new TransportExceptionEvent for $transport. + */ + public function __construct(Swift_Transport $transport, Swift_TransportException $ex) + { + parent::__construct($transport); + $this->exception = $ex; + } - /** - * Get the TransportException thrown. - * - * @return Swift_TransportException - */ - public function getException() - { - return $this->exception; - } + /** + * Get the TransportException thrown. + * + * @return Swift_TransportException + */ + public function getException() + { + return $this->exception; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/TransportExceptionListener.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/TransportExceptionListener.php index 1de6e6e59a9..ad80eb01d0f 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/TransportExceptionListener.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/TransportExceptionListener.php @@ -15,8 +15,8 @@ */ interface Swift_Events_TransportExceptionListener extends Swift_Events_EventListener { - /** - * Invoked as a TransportException is thrown in the Transport system. - */ - public function exceptionThrown(Swift_Events_TransportExceptionEvent $evt); + /** + * Invoked as a TransportException is thrown in the Transport system. + */ + public function exceptionThrown(Swift_Events_TransportExceptionEvent $evt); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/FailoverTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/FailoverTransport.php index 57d343c9ed3..af0be917903 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/FailoverTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/FailoverTransport.php @@ -15,19 +15,19 @@ */ class Swift_FailoverTransport extends Swift_Transport_FailoverTransport { - /** - * Creates a new FailoverTransport with $transports. - * - * @param Swift_Transport[] $transports - */ - public function __construct($transports = []) - { - \call_user_func_array( - [$this, 'Swift_Transport_FailoverTransport::__construct'], - Swift_DependencyContainer::getInstance() - ->createDependenciesFor('transport.failover') - ); + /** + * Creates a new FailoverTransport with $transports. + * + * @param Swift_Transport[] $transports + */ + public function __construct($transports = []) + { + \call_user_func_array( + [$this, 'Swift_Transport_FailoverTransport::__construct'], + Swift_DependencyContainer::getInstance() + ->createDependenciesFor('transport.failover') + ); - $this->setTransports($transports); - } + $this->setTransports($transports); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/FileSpool.php b/htdocs/includes/swiftmailer/lib/classes/Swift/FileSpool.php index 4dd49a65270..7af8471c9d7 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/FileSpool.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/FileSpool.php @@ -16,193 +16,193 @@ */ class Swift_FileSpool extends Swift_ConfigurableSpool { - /** The spool directory */ - private $path; + /** The spool directory */ + private $path; - /** - * File WriteRetry Limit. - * - * @var int - */ - private $retryLimit = 10; + /** + * File WriteRetry Limit. + * + * @var int + */ + private $retryLimit = 10; - /** - * Create a new FileSpool. - * - * @param string $path - * - * @throws Swift_IoException - */ - public function __construct($path) - { - $this->path = $path; + /** + * Create a new FileSpool. + * + * @param string $path + * + * @throws Swift_IoException + */ + public function __construct($path) + { + $this->path = $path; - if (!file_exists($this->path)) { - if (!mkdir($this->path, 0777, true)) { - throw new Swift_IoException(sprintf('Unable to create path "%s".', $this->path)); - } - } - } + if (!file_exists($this->path)) { + if (!mkdir($this->path, 0777, true)) { + throw new Swift_IoException(sprintf('Unable to create path "%s".', $this->path)); + } + } + } - /** - * Tests if this Spool mechanism has started. - * - * @return bool - */ - public function isStarted() - { - return true; - } + /** + * Tests if this Spool mechanism has started. + * + * @return bool + */ + public function isStarted() + { + return true; + } - /** - * Starts this Spool mechanism. - */ - public function start() - { - } + /** + * Starts this Spool mechanism. + */ + public function start() + { + } - /** - * Stops this Spool mechanism. - */ - public function stop() - { - } + /** + * Stops this Spool mechanism. + */ + public function stop() + { + } - /** - * Allow to manage the enqueuing retry limit. - * - * Default, is ten and allows over 64^20 different fileNames - * - * @param int $limit - */ - public function setRetryLimit($limit) - { - $this->retryLimit = $limit; - } + /** + * Allow to manage the enqueuing retry limit. + * + * Default, is ten and allows over 64^20 different fileNames + * + * @param int $limit + */ + public function setRetryLimit($limit) + { + $this->retryLimit = $limit; + } - /** - * Queues a message. - * - * @param Swift_Mime_SimpleMessage $message The message to store - * - * @throws Swift_IoException - * - * @return bool - */ - public function queueMessage(Swift_Mime_SimpleMessage $message) - { - $ser = serialize($message); - $fileName = $this->path.'/'.$this->getRandomString(10); - for ($i = 0; $i < $this->retryLimit; ++$i) { - /* We try an exclusive creation of the file. This is an atomic operation, it avoid locking mechanism */ - $fp = @fopen($fileName.'.message', 'xb'); - if (false !== $fp) { - if (false === fwrite($fp, $ser)) { - return false; - } + /** + * Queues a message. + * + * @param Swift_Mime_SimpleMessage $message The message to store + * + * @throws Swift_IoException + * + * @return bool + */ + public function queueMessage(Swift_Mime_SimpleMessage $message) + { + $ser = serialize($message); + $fileName = $this->path.'/'.$this->getRandomString(10); + for ($i = 0; $i < $this->retryLimit; ++$i) { + /* We try an exclusive creation of the file. This is an atomic operation, it avoid locking mechanism */ + $fp = @fopen($fileName.'.message', 'xb'); + if (false !== $fp) { + if (false === fwrite($fp, $ser)) { + return false; + } - return fclose($fp); - } else { - /* The file already exists, we try a longer fileName */ - $fileName .= $this->getRandomString(1); - } - } + return fclose($fp); + } else { + /* The file already exists, we try a longer fileName */ + $fileName .= $this->getRandomString(1); + } + } - throw new Swift_IoException(sprintf('Unable to create a file for enqueuing Message in "%s".', $this->path)); - } + throw new Swift_IoException(sprintf('Unable to create a file for enqueuing Message in "%s".', $this->path)); + } - /** - * Execute a recovery if for any reason a process is sending for too long. - * - * @param int $timeout in second Defaults is for very slow smtp responses - */ - public function recover($timeout = 900) - { - foreach (new DirectoryIterator($this->path) as $file) { - $file = $file->getRealPath(); + /** + * Execute a recovery if for any reason a process is sending for too long. + * + * @param int $timeout in second Defaults is for very slow smtp responses + */ + public function recover($timeout = 900) + { + foreach (new DirectoryIterator($this->path) as $file) { + $file = $file->getRealPath(); - if ('.message.sending' == substr($file, -16)) { - $lockedtime = filectime($file); - if ((time() - $lockedtime) > $timeout) { - rename($file, substr($file, 0, -8)); - } - } - } - } + if ('.message.sending' == substr($file, -16)) { + $lockedtime = filectime($file); + if ((time() - $lockedtime) > $timeout) { + rename($file, substr($file, 0, -8)); + } + } + } + } - /** - * Sends messages using the given transport instance. - * - * @param Swift_Transport $transport A transport instance - * @param string[] $failedRecipients An array of failures by-reference - * - * @return int The number of sent e-mail's - */ - public function flushQueue(Swift_Transport $transport, &$failedRecipients = null) - { - $directoryIterator = new DirectoryIterator($this->path); + /** + * Sends messages using the given transport instance. + * + * @param Swift_Transport $transport A transport instance + * @param string[] $failedRecipients An array of failures by-reference + * + * @return int The number of sent e-mail's + */ + public function flushQueue(Swift_Transport $transport, &$failedRecipients = null) + { + $directoryIterator = new DirectoryIterator($this->path); - /* Start the transport only if there are queued files to send */ - if (!$transport->isStarted()) { - foreach ($directoryIterator as $file) { - if ('.message' == substr($file->getRealPath(), -8)) { - $transport->start(); - break; - } - } - } + /* Start the transport only if there are queued files to send */ + if (!$transport->isStarted()) { + foreach ($directoryIterator as $file) { + if ('.message' == substr($file->getRealPath(), -8)) { + $transport->start(); + break; + } + } + } - $failedRecipients = (array) $failedRecipients; - $count = 0; - $time = time(); - foreach ($directoryIterator as $file) { - $file = $file->getRealPath(); + $failedRecipients = (array) $failedRecipients; + $count = 0; + $time = time(); + foreach ($directoryIterator as $file) { + $file = $file->getRealPath(); - if ('.message' != substr($file, -8)) { - continue; - } + if ('.message' != substr($file, -8)) { + continue; + } - /* We try a rename, it's an atomic operation, and avoid locking the file */ - if (rename($file, $file.'.sending')) { - $message = unserialize(file_get_contents($file.'.sending')); + /* We try a rename, it's an atomic operation, and avoid locking the file */ + if (rename($file, $file.'.sending')) { + $message = unserialize(file_get_contents($file.'.sending')); - $count += $transport->send($message, $failedRecipients); + $count += $transport->send($message, $failedRecipients); - unlink($file.'.sending'); - } else { - /* This message has just been catched by another process */ - continue; - } + unlink($file.'.sending'); + } else { + /* This message has just been catched by another process */ + continue; + } - if ($this->getMessageLimit() && $count >= $this->getMessageLimit()) { - break; - } + if ($this->getMessageLimit() && $count >= $this->getMessageLimit()) { + break; + } - if ($this->getTimeLimit() && (time() - $time) >= $this->getTimeLimit()) { - break; - } - } + if ($this->getTimeLimit() && (time() - $time) >= $this->getTimeLimit()) { + break; + } + } - return $count; - } + return $count; + } - /** - * Returns a random string needed to generate a fileName for the queue. - * - * @param int $count - * - * @return string - */ - protected function getRandomString($count) - { - // This string MUST stay FS safe, avoid special chars - $base = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-'; - $ret = ''; - $strlen = \strlen($base); - for ($i = 0; $i < $count; ++$i) { - $ret .= $base[random_int(0, $strlen - 1)]; - } + /** + * Returns a random string needed to generate a fileName for the queue. + * + * @param int $count + * + * @return string + */ + protected function getRandomString($count) + { + // This string MUST stay FS safe, avoid special chars + $base = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-'; + $ret = ''; + $strlen = \strlen($base); + for ($i = 0; $i < $count; ++$i) { + $ret .= $base[random_int(0, $strlen - 1)]; + } - return $ret; - } + return $ret; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Filterable.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Filterable.php index 9073bf5b663..efa1b1def5e 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Filterable.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Filterable.php @@ -15,17 +15,17 @@ */ interface Swift_Filterable { - /** - * Add a new StreamFilter, referenced by $key. - * - * @param string $key - */ - public function addFilter(Swift_StreamFilter $filter, $key); + /** + * Add a new StreamFilter, referenced by $key. + * + * @param string $key + */ + public function addFilter(Swift_StreamFilter $filter, $key); - /** - * Remove an existing filter using $key. - * - * @param string $key - */ - public function removeFilter($key); + /** + * Remove an existing filter using $key. + * + * @param string $key + */ + public function removeFilter($key); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/InputByteStream.php b/htdocs/includes/swiftmailer/lib/classes/Swift/InputByteStream.php index 67a12acc6f5..379a5a17870 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/InputByteStream.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/InputByteStream.php @@ -18,58 +18,58 @@ */ interface Swift_InputByteStream { - /** - * Writes $bytes to the end of the stream. - * - * Writing may not happen immediately if the stream chooses to buffer. If - * you want to write these bytes with immediate effect, call {@link commit()} - * after calling write(). - * - * This method returns the sequence ID of the write (i.e. 1 for first, 2 for - * second, etc etc). - * - * @param string $bytes - * - * @throws Swift_IoException - * - * @return int - */ - public function write($bytes); + /** + * Writes $bytes to the end of the stream. + * + * Writing may not happen immediately if the stream chooses to buffer. If + * you want to write these bytes with immediate effect, call {@link commit()} + * after calling write(). + * + * This method returns the sequence ID of the write (i.e. 1 for first, 2 for + * second, etc etc). + * + * @param string $bytes + * + * @throws Swift_IoException + * + * @return int + */ + public function write($bytes); - /** - * For any bytes that are currently buffered inside the stream, force them - * off the buffer. - * - * @throws Swift_IoException - */ - public function commit(); + /** + * For any bytes that are currently buffered inside the stream, force them + * off the buffer. + * + * @throws Swift_IoException + */ + public function commit(); - /** - * Attach $is to this stream. - * - * The stream acts as an observer, receiving all data that is written. - * All {@link write()} and {@link flushBuffers()} operations will be mirrored. - * - * @param Swift_InputByteStream $is - */ - public function bind(self $is); + /** + * Attach $is to this stream. + * + * The stream acts as an observer, receiving all data that is written. + * All {@link write()} and {@link flushBuffers()} operations will be mirrored. + * + * @param Swift_InputByteStream $is + */ + public function bind(self $is); - /** - * Remove an already bound stream. - * - * If $is is not bound, no errors will be raised. - * If the stream currently has any buffered data it will be written to $is - * before unbinding occurs. - * - * @param Swift_InputByteStream $is - */ - public function unbind(self $is); + /** + * Remove an already bound stream. + * + * If $is is not bound, no errors will be raised. + * If the stream currently has any buffered data it will be written to $is + * before unbinding occurs. + * + * @param Swift_InputByteStream $is + */ + public function unbind(self $is); - /** - * Flush the contents of the stream (empty it) and set the internal pointer - * to the beginning. - * - * @throws Swift_IoException - */ - public function flushBuffers(); + /** + * Flush the contents of the stream (empty it) and set the internal pointer + * to the beginning. + * + * @throws Swift_IoException + */ + public function flushBuffers(); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/IoException.php b/htdocs/includes/swiftmailer/lib/classes/Swift/IoException.php index 8a8b9ff9029..5452bd416a6 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/IoException.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/IoException.php @@ -15,14 +15,14 @@ */ class Swift_IoException extends Swift_SwiftException { - /** - * Create a new IoException with $message. - * - * @param string $message - * @param int $code - */ - public function __construct($message, $code = 0, Exception $previous = null) - { - parent::__construct($message, $code, $previous); - } + /** + * Create a new IoException with $message. + * + * @param string $message + * @param int $code + */ + public function __construct($message, $code = 0, Exception $previous = null) + { + parent::__construct($message, $code, $previous); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache.php b/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache.php index 791085d85e7..87f6a074212 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache.php @@ -15,90 +15,90 @@ */ interface Swift_KeyCache { - /** Mode for replacing existing cached data */ - const MODE_WRITE = 1; + /** Mode for replacing existing cached data */ + const MODE_WRITE = 1; - /** Mode for appending data to the end of existing cached data */ - const MODE_APPEND = 2; + /** Mode for appending data to the end of existing cached data */ + const MODE_APPEND = 2; - /** - * Set a string into the cache under $itemKey for the namespace $nsKey. - * - * @see MODE_WRITE, MODE_APPEND - * - * @param string $nsKey - * @param string $itemKey - * @param string $string - * @param int $mode - */ - public function setString($nsKey, $itemKey, $string, $mode); + /** + * Set a string into the cache under $itemKey for the namespace $nsKey. + * + * @see MODE_WRITE, MODE_APPEND + * + * @param string $nsKey + * @param string $itemKey + * @param string $string + * @param int $mode + */ + public function setString($nsKey, $itemKey, $string, $mode); - /** - * Set a ByteStream into the cache under $itemKey for the namespace $nsKey. - * - * @see MODE_WRITE, MODE_APPEND - * - * @param string $nsKey - * @param string $itemKey - * @param int $mode - */ - public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $os, $mode); + /** + * Set a ByteStream into the cache under $itemKey for the namespace $nsKey. + * + * @see MODE_WRITE, MODE_APPEND + * + * @param string $nsKey + * @param string $itemKey + * @param int $mode + */ + public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $os, $mode); - /** - * Provides a ByteStream which when written to, writes data to $itemKey. - * - * NOTE: The stream will always write in append mode. - * If the optional third parameter is passed all writes will go through $is. - * - * @param string $nsKey - * @param string $itemKey - * @param Swift_InputByteStream $is optional input stream - * - * @return Swift_InputByteStream - */ - public function getInputByteStream($nsKey, $itemKey, Swift_InputByteStream $is = null); + /** + * Provides a ByteStream which when written to, writes data to $itemKey. + * + * NOTE: The stream will always write in append mode. + * If the optional third parameter is passed all writes will go through $is. + * + * @param string $nsKey + * @param string $itemKey + * @param Swift_InputByteStream $is optional input stream + * + * @return Swift_InputByteStream + */ + public function getInputByteStream($nsKey, $itemKey, Swift_InputByteStream $is = null); - /** - * Get data back out of the cache as a string. - * - * @param string $nsKey - * @param string $itemKey - * - * @return string - */ - public function getString($nsKey, $itemKey); + /** + * Get data back out of the cache as a string. + * + * @param string $nsKey + * @param string $itemKey + * + * @return string + */ + public function getString($nsKey, $itemKey); - /** - * Get data back out of the cache as a ByteStream. - * - * @param string $nsKey - * @param string $itemKey - * @param Swift_InputByteStream $is stream to write the data to - */ - public function exportToByteStream($nsKey, $itemKey, Swift_InputByteStream $is); + /** + * Get data back out of the cache as a ByteStream. + * + * @param string $nsKey + * @param string $itemKey + * @param Swift_InputByteStream $is stream to write the data to + */ + public function exportToByteStream($nsKey, $itemKey, Swift_InputByteStream $is); - /** - * Check if the given $itemKey exists in the namespace $nsKey. - * - * @param string $nsKey - * @param string $itemKey - * - * @return bool - */ - public function hasKey($nsKey, $itemKey); + /** + * Check if the given $itemKey exists in the namespace $nsKey. + * + * @param string $nsKey + * @param string $itemKey + * + * @return bool + */ + public function hasKey($nsKey, $itemKey); - /** - * Clear data for $itemKey in the namespace $nsKey if it exists. - * - * @param string $nsKey - * @param string $itemKey - */ - public function clearKey($nsKey, $itemKey); + /** + * Clear data for $itemKey in the namespace $nsKey if it exists. + * + * @param string $nsKey + * @param string $itemKey + */ + public function clearKey($nsKey, $itemKey); - /** - * Clear all data in the namespace $nsKey if it exists. - * - * @param string $nsKey - */ - public function clearAll($nsKey); + /** + * Clear all data in the namespace $nsKey if it exists. + * + * @param string $nsKey + */ + public function clearAll($nsKey); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/ArrayKeyCache.php b/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/ArrayKeyCache.php index 92a6c2d107e..e8fef1c95d4 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/ArrayKeyCache.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/ArrayKeyCache.php @@ -15,183 +15,183 @@ */ class Swift_KeyCache_ArrayKeyCache implements Swift_KeyCache { - /** - * Cache contents. - * - * @var array - */ - private $contents = []; + /** + * Cache contents. + * + * @var array + */ + private $contents = []; - /** - * An InputStream for cloning. - * - * @var Swift_KeyCache_KeyCacheInputStream - */ - private $stream; + /** + * An InputStream for cloning. + * + * @var Swift_KeyCache_KeyCacheInputStream + */ + private $stream; - /** - * Create a new ArrayKeyCache with the given $stream for cloning to make - * InputByteStreams. - */ - public function __construct(Swift_KeyCache_KeyCacheInputStream $stream) - { - $this->stream = $stream; - } + /** + * Create a new ArrayKeyCache with the given $stream for cloning to make + * InputByteStreams. + */ + public function __construct(Swift_KeyCache_KeyCacheInputStream $stream) + { + $this->stream = $stream; + } - /** - * Set a string into the cache under $itemKey for the namespace $nsKey. - * - * @see MODE_WRITE, MODE_APPEND - * - * @param string $nsKey - * @param string $itemKey - * @param string $string - * @param int $mode - */ - public function setString($nsKey, $itemKey, $string, $mode) - { - $this->prepareCache($nsKey); - switch ($mode) { - case self::MODE_WRITE: - $this->contents[$nsKey][$itemKey] = $string; - break; - case self::MODE_APPEND: - if (!$this->hasKey($nsKey, $itemKey)) { - $this->contents[$nsKey][$itemKey] = ''; - } - $this->contents[$nsKey][$itemKey] .= $string; - break; - default: - throw new Swift_SwiftException('Invalid mode ['.$mode.'] used to set nsKey='.$nsKey.', itemKey='.$itemKey); - } - } + /** + * Set a string into the cache under $itemKey for the namespace $nsKey. + * + * @see MODE_WRITE, MODE_APPEND + * + * @param string $nsKey + * @param string $itemKey + * @param string $string + * @param int $mode + */ + public function setString($nsKey, $itemKey, $string, $mode) + { + $this->prepareCache($nsKey); + switch ($mode) { + case self::MODE_WRITE: + $this->contents[$nsKey][$itemKey] = $string; + break; + case self::MODE_APPEND: + if (!$this->hasKey($nsKey, $itemKey)) { + $this->contents[$nsKey][$itemKey] = ''; + } + $this->contents[$nsKey][$itemKey] .= $string; + break; + default: + throw new Swift_SwiftException('Invalid mode ['.$mode.'] used to set nsKey='.$nsKey.', itemKey='.$itemKey); + } + } - /** - * Set a ByteStream into the cache under $itemKey for the namespace $nsKey. - * - * @see MODE_WRITE, MODE_APPEND - * - * @param string $nsKey - * @param string $itemKey - * @param int $mode - */ - public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $os, $mode) - { - $this->prepareCache($nsKey); - switch ($mode) { - case self::MODE_WRITE: - $this->clearKey($nsKey, $itemKey); - // no break - case self::MODE_APPEND: - if (!$this->hasKey($nsKey, $itemKey)) { - $this->contents[$nsKey][$itemKey] = ''; - } - while (false !== $bytes = $os->read(8192)) { - $this->contents[$nsKey][$itemKey] .= $bytes; - } - break; - default: - throw new Swift_SwiftException('Invalid mode ['.$mode.'] used to set nsKey='.$nsKey.', itemKey='.$itemKey); - } - } + /** + * Set a ByteStream into the cache under $itemKey for the namespace $nsKey. + * + * @see MODE_WRITE, MODE_APPEND + * + * @param string $nsKey + * @param string $itemKey + * @param int $mode + */ + public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $os, $mode) + { + $this->prepareCache($nsKey); + switch ($mode) { + case self::MODE_WRITE: + $this->clearKey($nsKey, $itemKey); + // no break + case self::MODE_APPEND: + if (!$this->hasKey($nsKey, $itemKey)) { + $this->contents[$nsKey][$itemKey] = ''; + } + while (false !== $bytes = $os->read(8192)) { + $this->contents[$nsKey][$itemKey] .= $bytes; + } + break; + default: + throw new Swift_SwiftException('Invalid mode ['.$mode.'] used to set nsKey='.$nsKey.', itemKey='.$itemKey); + } + } - /** - * Provides a ByteStream which when written to, writes data to $itemKey. - * - * NOTE: The stream will always write in append mode. - * - * @param string $nsKey - * @param string $itemKey - * - * @return Swift_InputByteStream - */ - public function getInputByteStream($nsKey, $itemKey, Swift_InputByteStream $writeThrough = null) - { - $is = clone $this->stream; - $is->setKeyCache($this); - $is->setNsKey($nsKey); - $is->setItemKey($itemKey); - if (isset($writeThrough)) { - $is->setWriteThroughStream($writeThrough); - } + /** + * Provides a ByteStream which when written to, writes data to $itemKey. + * + * NOTE: The stream will always write in append mode. + * + * @param string $nsKey + * @param string $itemKey + * + * @return Swift_InputByteStream + */ + public function getInputByteStream($nsKey, $itemKey, Swift_InputByteStream $writeThrough = null) + { + $is = clone $this->stream; + $is->setKeyCache($this); + $is->setNsKey($nsKey); + $is->setItemKey($itemKey); + if (isset($writeThrough)) { + $is->setWriteThroughStream($writeThrough); + } - return $is; - } + return $is; + } - /** - * Get data back out of the cache as a string. - * - * @param string $nsKey - * @param string $itemKey - * - * @return string - */ - public function getString($nsKey, $itemKey) - { - $this->prepareCache($nsKey); - if ($this->hasKey($nsKey, $itemKey)) { - return $this->contents[$nsKey][$itemKey]; - } - } + /** + * Get data back out of the cache as a string. + * + * @param string $nsKey + * @param string $itemKey + * + * @return string + */ + public function getString($nsKey, $itemKey) + { + $this->prepareCache($nsKey); + if ($this->hasKey($nsKey, $itemKey)) { + return $this->contents[$nsKey][$itemKey]; + } + } - /** - * Get data back out of the cache as a ByteStream. - * - * @param string $nsKey - * @param string $itemKey - * @param Swift_InputByteStream $is to write the data to - */ - public function exportToByteStream($nsKey, $itemKey, Swift_InputByteStream $is) - { - $this->prepareCache($nsKey); - $is->write($this->getString($nsKey, $itemKey)); - } + /** + * Get data back out of the cache as a ByteStream. + * + * @param string $nsKey + * @param string $itemKey + * @param Swift_InputByteStream $is to write the data to + */ + public function exportToByteStream($nsKey, $itemKey, Swift_InputByteStream $is) + { + $this->prepareCache($nsKey); + $is->write($this->getString($nsKey, $itemKey)); + } - /** - * Check if the given $itemKey exists in the namespace $nsKey. - * - * @param string $nsKey - * @param string $itemKey - * - * @return bool - */ - public function hasKey($nsKey, $itemKey) - { - $this->prepareCache($nsKey); + /** + * Check if the given $itemKey exists in the namespace $nsKey. + * + * @param string $nsKey + * @param string $itemKey + * + * @return bool + */ + public function hasKey($nsKey, $itemKey) + { + $this->prepareCache($nsKey); - return \array_key_exists($itemKey, $this->contents[$nsKey]); - } + return \array_key_exists($itemKey, $this->contents[$nsKey]); + } - /** - * Clear data for $itemKey in the namespace $nsKey if it exists. - * - * @param string $nsKey - * @param string $itemKey - */ - public function clearKey($nsKey, $itemKey) - { - unset($this->contents[$nsKey][$itemKey]); - } + /** + * Clear data for $itemKey in the namespace $nsKey if it exists. + * + * @param string $nsKey + * @param string $itemKey + */ + public function clearKey($nsKey, $itemKey) + { + unset($this->contents[$nsKey][$itemKey]); + } - /** - * Clear all data in the namespace $nsKey if it exists. - * - * @param string $nsKey - */ - public function clearAll($nsKey) - { - unset($this->contents[$nsKey]); - } + /** + * Clear all data in the namespace $nsKey if it exists. + * + * @param string $nsKey + */ + public function clearAll($nsKey) + { + unset($this->contents[$nsKey]); + } - /** - * Initialize the namespace of $nsKey if needed. - * - * @param string $nsKey - */ - private function prepareCache($nsKey) - { - if (!\array_key_exists($nsKey, $this->contents)) { - $this->contents[$nsKey] = []; - } - } + /** + * Initialize the namespace of $nsKey if needed. + * + * @param string $nsKey + */ + private function prepareCache($nsKey) + { + if (!\array_key_exists($nsKey, $this->contents)) { + $this->contents[$nsKey] = []; + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/DiskKeyCache.php b/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/DiskKeyCache.php index 4075b928e13..33b6367cb8b 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/DiskKeyCache.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/DiskKeyCache.php @@ -15,280 +15,280 @@ */ class Swift_KeyCache_DiskKeyCache implements Swift_KeyCache { - /** Signal to place pointer at start of file */ - const POSITION_START = 0; + /** Signal to place pointer at start of file */ + const POSITION_START = 0; - /** Signal to place pointer at end of file */ - const POSITION_END = 1; + /** Signal to place pointer at end of file */ + const POSITION_END = 1; - /** Signal to leave pointer in whatever position it currently is */ - const POSITION_CURRENT = 2; + /** Signal to leave pointer in whatever position it currently is */ + const POSITION_CURRENT = 2; - /** - * An InputStream for cloning. - * - * @var Swift_KeyCache_KeyCacheInputStream - */ - private $stream; + /** + * An InputStream for cloning. + * + * @var Swift_KeyCache_KeyCacheInputStream + */ + private $stream; - /** - * A path to write to. - * - * @var string - */ - private $path; + /** + * A path to write to. + * + * @var string + */ + private $path; - /** - * Stored keys. - * - * @var array - */ - private $keys = []; + /** + * Stored keys. + * + * @var array + */ + private $keys = []; - /** - * Create a new DiskKeyCache with the given $stream for cloning to make - * InputByteStreams, and the given $path to save to. - * - * @param string $path to save to - */ - public function __construct(Swift_KeyCache_KeyCacheInputStream $stream, $path) - { - $this->stream = $stream; - $this->path = $path; - } + /** + * Create a new DiskKeyCache with the given $stream for cloning to make + * InputByteStreams, and the given $path to save to. + * + * @param string $path to save to + */ + public function __construct(Swift_KeyCache_KeyCacheInputStream $stream, $path) + { + $this->stream = $stream; + $this->path = $path; + } - /** - * Set a string into the cache under $itemKey for the namespace $nsKey. - * - * @see MODE_WRITE, MODE_APPEND - * - * @param string $nsKey - * @param string $itemKey - * @param string $string - * @param int $mode - * - * @throws Swift_IoException - */ - public function setString($nsKey, $itemKey, $string, $mode) - { - $this->prepareCache($nsKey); - switch ($mode) { - case self::MODE_WRITE: - $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_START); - break; - case self::MODE_APPEND: - $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_END); - break; - default: - throw new Swift_SwiftException('Invalid mode ['.$mode.'] used to set nsKey='.$nsKey.', itemKey='.$itemKey); - break; - } - fwrite($fp, $string); - $this->freeHandle($nsKey, $itemKey); - } + /** + * Set a string into the cache under $itemKey for the namespace $nsKey. + * + * @see MODE_WRITE, MODE_APPEND + * + * @param string $nsKey + * @param string $itemKey + * @param string $string + * @param int $mode + * + * @throws Swift_IoException + */ + public function setString($nsKey, $itemKey, $string, $mode) + { + $this->prepareCache($nsKey); + switch ($mode) { + case self::MODE_WRITE: + $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_START); + break; + case self::MODE_APPEND: + $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_END); + break; + default: + throw new Swift_SwiftException('Invalid mode ['.$mode.'] used to set nsKey='.$nsKey.', itemKey='.$itemKey); + break; + } + fwrite($fp, $string); + $this->freeHandle($nsKey, $itemKey); + } - /** - * Set a ByteStream into the cache under $itemKey for the namespace $nsKey. - * - * @see MODE_WRITE, MODE_APPEND - * - * @param string $nsKey - * @param string $itemKey - * @param int $mode - * - * @throws Swift_IoException - */ - public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $os, $mode) - { - $this->prepareCache($nsKey); - switch ($mode) { - case self::MODE_WRITE: - $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_START); - break; - case self::MODE_APPEND: - $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_END); - break; - default: - throw new Swift_SwiftException('Invalid mode ['.$mode.'] used to set nsKey='.$nsKey.', itemKey='.$itemKey); - break; - } - while (false !== $bytes = $os->read(8192)) { - fwrite($fp, $bytes); - } - $this->freeHandle($nsKey, $itemKey); - } + /** + * Set a ByteStream into the cache under $itemKey for the namespace $nsKey. + * + * @see MODE_WRITE, MODE_APPEND + * + * @param string $nsKey + * @param string $itemKey + * @param int $mode + * + * @throws Swift_IoException + */ + public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $os, $mode) + { + $this->prepareCache($nsKey); + switch ($mode) { + case self::MODE_WRITE: + $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_START); + break; + case self::MODE_APPEND: + $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_END); + break; + default: + throw new Swift_SwiftException('Invalid mode ['.$mode.'] used to set nsKey='.$nsKey.', itemKey='.$itemKey); + break; + } + while (false !== $bytes = $os->read(8192)) { + fwrite($fp, $bytes); + } + $this->freeHandle($nsKey, $itemKey); + } - /** - * Provides a ByteStream which when written to, writes data to $itemKey. - * - * NOTE: The stream will always write in append mode. - * - * @param string $nsKey - * @param string $itemKey - * - * @return Swift_InputByteStream - */ - public function getInputByteStream($nsKey, $itemKey, Swift_InputByteStream $writeThrough = null) - { - $is = clone $this->stream; - $is->setKeyCache($this); - $is->setNsKey($nsKey); - $is->setItemKey($itemKey); - if (isset($writeThrough)) { - $is->setWriteThroughStream($writeThrough); - } + /** + * Provides a ByteStream which when written to, writes data to $itemKey. + * + * NOTE: The stream will always write in append mode. + * + * @param string $nsKey + * @param string $itemKey + * + * @return Swift_InputByteStream + */ + public function getInputByteStream($nsKey, $itemKey, Swift_InputByteStream $writeThrough = null) + { + $is = clone $this->stream; + $is->setKeyCache($this); + $is->setNsKey($nsKey); + $is->setItemKey($itemKey); + if (isset($writeThrough)) { + $is->setWriteThroughStream($writeThrough); + } - return $is; - } + return $is; + } - /** - * Get data back out of the cache as a string. - * - * @param string $nsKey - * @param string $itemKey - * - * @throws Swift_IoException - * - * @return string - */ - public function getString($nsKey, $itemKey) - { - $this->prepareCache($nsKey); - if ($this->hasKey($nsKey, $itemKey)) { - $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_START); - $str = ''; - while (!feof($fp) && false !== $bytes = fread($fp, 8192)) { - $str .= $bytes; - } - $this->freeHandle($nsKey, $itemKey); + /** + * Get data back out of the cache as a string. + * + * @param string $nsKey + * @param string $itemKey + * + * @throws Swift_IoException + * + * @return string + */ + public function getString($nsKey, $itemKey) + { + $this->prepareCache($nsKey); + if ($this->hasKey($nsKey, $itemKey)) { + $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_START); + $str = ''; + while (!feof($fp) && false !== $bytes = fread($fp, 8192)) { + $str .= $bytes; + } + $this->freeHandle($nsKey, $itemKey); - return $str; - } - } + return $str; + } + } - /** - * Get data back out of the cache as a ByteStream. - * - * @param string $nsKey - * @param string $itemKey - * @param Swift_InputByteStream $is to write the data to - */ - public function exportToByteStream($nsKey, $itemKey, Swift_InputByteStream $is) - { - if ($this->hasKey($nsKey, $itemKey)) { - $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_START); - while (!feof($fp) && false !== $bytes = fread($fp, 8192)) { - $is->write($bytes); - } - $this->freeHandle($nsKey, $itemKey); - } - } + /** + * Get data back out of the cache as a ByteStream. + * + * @param string $nsKey + * @param string $itemKey + * @param Swift_InputByteStream $is to write the data to + */ + public function exportToByteStream($nsKey, $itemKey, Swift_InputByteStream $is) + { + if ($this->hasKey($nsKey, $itemKey)) { + $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_START); + while (!feof($fp) && false !== $bytes = fread($fp, 8192)) { + $is->write($bytes); + } + $this->freeHandle($nsKey, $itemKey); + } + } - /** - * Check if the given $itemKey exists in the namespace $nsKey. - * - * @param string $nsKey - * @param string $itemKey - * - * @return bool - */ - public function hasKey($nsKey, $itemKey) - { - return is_file($this->path.'/'.$nsKey.'/'.$itemKey); - } + /** + * Check if the given $itemKey exists in the namespace $nsKey. + * + * @param string $nsKey + * @param string $itemKey + * + * @return bool + */ + public function hasKey($nsKey, $itemKey) + { + return is_file($this->path.'/'.$nsKey.'/'.$itemKey); + } - /** - * Clear data for $itemKey in the namespace $nsKey if it exists. - * - * @param string $nsKey - * @param string $itemKey - */ - public function clearKey($nsKey, $itemKey) - { - if ($this->hasKey($nsKey, $itemKey)) { - $this->freeHandle($nsKey, $itemKey); - unlink($this->path.'/'.$nsKey.'/'.$itemKey); - } - } + /** + * Clear data for $itemKey in the namespace $nsKey if it exists. + * + * @param string $nsKey + * @param string $itemKey + */ + public function clearKey($nsKey, $itemKey) + { + if ($this->hasKey($nsKey, $itemKey)) { + $this->freeHandle($nsKey, $itemKey); + unlink($this->path.'/'.$nsKey.'/'.$itemKey); + } + } - /** - * Clear all data in the namespace $nsKey if it exists. - * - * @param string $nsKey - */ - public function clearAll($nsKey) - { - if (\array_key_exists($nsKey, $this->keys)) { - foreach ($this->keys[$nsKey] as $itemKey => $null) { - $this->clearKey($nsKey, $itemKey); - } - if (is_dir($this->path.'/'.$nsKey)) { - rmdir($this->path.'/'.$nsKey); - } - unset($this->keys[$nsKey]); - } - } + /** + * Clear all data in the namespace $nsKey if it exists. + * + * @param string $nsKey + */ + public function clearAll($nsKey) + { + if (\array_key_exists($nsKey, $this->keys)) { + foreach ($this->keys[$nsKey] as $itemKey => $null) { + $this->clearKey($nsKey, $itemKey); + } + if (is_dir($this->path.'/'.$nsKey)) { + rmdir($this->path.'/'.$nsKey); + } + unset($this->keys[$nsKey]); + } + } - /** - * Initialize the namespace of $nsKey if needed. - * - * @param string $nsKey - */ - private function prepareCache($nsKey) - { - $cacheDir = $this->path.'/'.$nsKey; - if (!is_dir($cacheDir)) { - if (!mkdir($cacheDir)) { - throw new Swift_IoException('Failed to create cache directory '.$cacheDir); - } - $this->keys[$nsKey] = []; - } - } + /** + * Initialize the namespace of $nsKey if needed. + * + * @param string $nsKey + */ + private function prepareCache($nsKey) + { + $cacheDir = $this->path.'/'.$nsKey; + if (!is_dir($cacheDir)) { + if (!mkdir($cacheDir)) { + throw new Swift_IoException('Failed to create cache directory '.$cacheDir); + } + $this->keys[$nsKey] = []; + } + } - /** - * Get a file handle on the cache item. - * - * @param string $nsKey - * @param string $itemKey - * @param int $position - * - * @return resource - */ - private function getHandle($nsKey, $itemKey, $position) - { - if (!isset($this->keys[$nsKey][$itemKey])) { - $openMode = $this->hasKey($nsKey, $itemKey) ? 'r+b' : 'w+b'; - $fp = fopen($this->path.'/'.$nsKey.'/'.$itemKey, $openMode); - $this->keys[$nsKey][$itemKey] = $fp; - } - if (self::POSITION_START == $position) { - fseek($this->keys[$nsKey][$itemKey], 0, SEEK_SET); - } elseif (self::POSITION_END == $position) { - fseek($this->keys[$nsKey][$itemKey], 0, SEEK_END); - } + /** + * Get a file handle on the cache item. + * + * @param string $nsKey + * @param string $itemKey + * @param int $position + * + * @return resource + */ + private function getHandle($nsKey, $itemKey, $position) + { + if (!isset($this->keys[$nsKey][$itemKey])) { + $openMode = $this->hasKey($nsKey, $itemKey) ? 'r+b' : 'w+b'; + $fp = fopen($this->path.'/'.$nsKey.'/'.$itemKey, $openMode); + $this->keys[$nsKey][$itemKey] = $fp; + } + if (self::POSITION_START == $position) { + fseek($this->keys[$nsKey][$itemKey], 0, SEEK_SET); + } elseif (self::POSITION_END == $position) { + fseek($this->keys[$nsKey][$itemKey], 0, SEEK_END); + } - return $this->keys[$nsKey][$itemKey]; - } + return $this->keys[$nsKey][$itemKey]; + } - private function freeHandle($nsKey, $itemKey) - { - $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_CURRENT); - fclose($fp); - $this->keys[$nsKey][$itemKey] = null; - } + private function freeHandle($nsKey, $itemKey) + { + $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_CURRENT); + fclose($fp); + $this->keys[$nsKey][$itemKey] = null; + } - /** - * Destructor. - */ - public function __destruct() - { - foreach ($this->keys as $nsKey => $null) { - $this->clearAll($nsKey); - } - } + /** + * Destructor. + */ + public function __destruct() + { + foreach ($this->keys as $nsKey => $null) { + $this->clearAll($nsKey); + } + } - public function __wakeup() - { - $this->keys = []; - } + public function __wakeup() + { + $this->keys = []; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/KeyCacheInputStream.php b/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/KeyCacheInputStream.php index 159f97643cd..be2dbba0c58 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/KeyCacheInputStream.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/KeyCacheInputStream.php @@ -15,33 +15,33 @@ */ interface Swift_KeyCache_KeyCacheInputStream extends Swift_InputByteStream { - /** - * Set the KeyCache to wrap. - */ - public function setKeyCache(Swift_KeyCache $keyCache); + /** + * Set the KeyCache to wrap. + */ + public function setKeyCache(Swift_KeyCache $keyCache); - /** - * Set the nsKey which will be written to. - * - * @param string $nsKey - */ - public function setNsKey($nsKey); + /** + * Set the nsKey which will be written to. + * + * @param string $nsKey + */ + public function setNsKey($nsKey); - /** - * Set the itemKey which will be written to. - * - * @param string $itemKey - */ - public function setItemKey($itemKey); + /** + * Set the itemKey which will be written to. + * + * @param string $itemKey + */ + public function setItemKey($itemKey); - /** - * Specify a stream to write through for each write(). - */ - public function setWriteThroughStream(Swift_InputByteStream $is); + /** + * Specify a stream to write through for each write(). + */ + public function setWriteThroughStream(Swift_InputByteStream $is); - /** - * Any implementation should be cloneable, allowing the clone to access a - * separate $nsKey and $itemKey. - */ - public function __clone(); + /** + * Any implementation should be cloneable, allowing the clone to access a + * separate $nsKey and $itemKey. + */ + public function __clone(); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/NullKeyCache.php b/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/NullKeyCache.php index 2b04d77fe4f..957b1b2a000 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/NullKeyCache.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/NullKeyCache.php @@ -15,99 +15,99 @@ */ class Swift_KeyCache_NullKeyCache implements Swift_KeyCache { - /** - * Set a string into the cache under $itemKey for the namespace $nsKey. - * - * @see MODE_WRITE, MODE_APPEND - * - * @param string $nsKey - * @param string $itemKey - * @param string $string - * @param int $mode - */ - public function setString($nsKey, $itemKey, $string, $mode) - { - } + /** + * Set a string into the cache under $itemKey for the namespace $nsKey. + * + * @see MODE_WRITE, MODE_APPEND + * + * @param string $nsKey + * @param string $itemKey + * @param string $string + * @param int $mode + */ + public function setString($nsKey, $itemKey, $string, $mode) + { + } - /** - * Set a ByteStream into the cache under $itemKey for the namespace $nsKey. - * - * @see MODE_WRITE, MODE_APPEND - * - * @param string $nsKey - * @param string $itemKey - * @param int $mode - */ - public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $os, $mode) - { - } + /** + * Set a ByteStream into the cache under $itemKey for the namespace $nsKey. + * + * @see MODE_WRITE, MODE_APPEND + * + * @param string $nsKey + * @param string $itemKey + * @param int $mode + */ + public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $os, $mode) + { + } - /** - * Provides a ByteStream which when written to, writes data to $itemKey. - * - * NOTE: The stream will always write in append mode. - * - * @param string $nsKey - * @param string $itemKey - * - * @return Swift_InputByteStream - */ - public function getInputByteStream($nsKey, $itemKey, Swift_InputByteStream $writeThrough = null) - { - } + /** + * Provides a ByteStream which when written to, writes data to $itemKey. + * + * NOTE: The stream will always write in append mode. + * + * @param string $nsKey + * @param string $itemKey + * + * @return Swift_InputByteStream + */ + public function getInputByteStream($nsKey, $itemKey, Swift_InputByteStream $writeThrough = null) + { + } - /** - * Get data back out of the cache as a string. - * - * @param string $nsKey - * @param string $itemKey - * - * @return string - */ - public function getString($nsKey, $itemKey) - { - } + /** + * Get data back out of the cache as a string. + * + * @param string $nsKey + * @param string $itemKey + * + * @return string + */ + public function getString($nsKey, $itemKey) + { + } - /** - * Get data back out of the cache as a ByteStream. - * - * @param string $nsKey - * @param string $itemKey - * @param Swift_InputByteStream $is to write the data to - */ - public function exportToByteStream($nsKey, $itemKey, Swift_InputByteStream $is) - { - } + /** + * Get data back out of the cache as a ByteStream. + * + * @param string $nsKey + * @param string $itemKey + * @param Swift_InputByteStream $is to write the data to + */ + public function exportToByteStream($nsKey, $itemKey, Swift_InputByteStream $is) + { + } - /** - * Check if the given $itemKey exists in the namespace $nsKey. - * - * @param string $nsKey - * @param string $itemKey - * - * @return bool - */ - public function hasKey($nsKey, $itemKey) - { - return false; - } + /** + * Check if the given $itemKey exists in the namespace $nsKey. + * + * @param string $nsKey + * @param string $itemKey + * + * @return bool + */ + public function hasKey($nsKey, $itemKey) + { + return false; + } - /** - * Clear data for $itemKey in the namespace $nsKey if it exists. - * - * @param string $nsKey - * @param string $itemKey - */ - public function clearKey($nsKey, $itemKey) - { - } + /** + * Clear data for $itemKey in the namespace $nsKey if it exists. + * + * @param string $nsKey + * @param string $itemKey + */ + public function clearKey($nsKey, $itemKey) + { + } - /** - * Clear all data in the namespace $nsKey if it exists. - * - * @param string $nsKey - */ - public function clearAll($nsKey) - { - } + /** + * Clear all data in the namespace $nsKey if it exists. + * + * @param string $nsKey + */ + public function clearAll($nsKey) + { + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php b/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php index d9d75e078c7..03bab481ea3 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php @@ -15,109 +15,109 @@ */ class Swift_KeyCache_SimpleKeyCacheInputStream implements Swift_KeyCache_KeyCacheInputStream { - /** The KeyCache being written to */ - private $keyCache; + /** The KeyCache being written to */ + private $keyCache; - /** The nsKey of the KeyCache being written to */ - private $nsKey; + /** The nsKey of the KeyCache being written to */ + private $nsKey; - /** The itemKey of the KeyCache being written to */ - private $itemKey; + /** The itemKey of the KeyCache being written to */ + private $itemKey; - /** A stream to write through on each write() */ - private $writeThrough = null; + /** A stream to write through on each write() */ + private $writeThrough = null; - /** - * Set the KeyCache to wrap. - */ - public function setKeyCache(Swift_KeyCache $keyCache) - { - $this->keyCache = $keyCache; - } + /** + * Set the KeyCache to wrap. + */ + public function setKeyCache(Swift_KeyCache $keyCache) + { + $this->keyCache = $keyCache; + } - /** - * Specify a stream to write through for each write(). - */ - public function setWriteThroughStream(Swift_InputByteStream $is) - { - $this->writeThrough = $is; - } + /** + * Specify a stream to write through for each write(). + */ + public function setWriteThroughStream(Swift_InputByteStream $is) + { + $this->writeThrough = $is; + } - /** - * Writes $bytes to the end of the stream. - * - * @param string $bytes - * @param Swift_InputByteStream $is optional - */ - public function write($bytes, Swift_InputByteStream $is = null) - { - $this->keyCache->setString( - $this->nsKey, $this->itemKey, $bytes, Swift_KeyCache::MODE_APPEND - ); - if (isset($is)) { - $is->write($bytes); - } - if (isset($this->writeThrough)) { - $this->writeThrough->write($bytes); - } - } + /** + * Writes $bytes to the end of the stream. + * + * @param string $bytes + * @param Swift_InputByteStream $is optional + */ + public function write($bytes, Swift_InputByteStream $is = null) + { + $this->keyCache->setString( + $this->nsKey, $this->itemKey, $bytes, Swift_KeyCache::MODE_APPEND + ); + if (isset($is)) { + $is->write($bytes); + } + if (isset($this->writeThrough)) { + $this->writeThrough->write($bytes); + } + } - /** - * Not used. - */ - public function commit() - { - } + /** + * Not used. + */ + public function commit() + { + } - /** - * Not used. - */ - public function bind(Swift_InputByteStream $is) - { - } + /** + * Not used. + */ + public function bind(Swift_InputByteStream $is) + { + } - /** - * Not used. - */ - public function unbind(Swift_InputByteStream $is) - { - } + /** + * Not used. + */ + public function unbind(Swift_InputByteStream $is) + { + } - /** - * Flush the contents of the stream (empty it) and set the internal pointer - * to the beginning. - */ - public function flushBuffers() - { - $this->keyCache->clearKey($this->nsKey, $this->itemKey); - } + /** + * Flush the contents of the stream (empty it) and set the internal pointer + * to the beginning. + */ + public function flushBuffers() + { + $this->keyCache->clearKey($this->nsKey, $this->itemKey); + } - /** - * Set the nsKey which will be written to. - * - * @param string $nsKey - */ - public function setNsKey($nsKey) - { - $this->nsKey = $nsKey; - } + /** + * Set the nsKey which will be written to. + * + * @param string $nsKey + */ + public function setNsKey($nsKey) + { + $this->nsKey = $nsKey; + } - /** - * Set the itemKey which will be written to. - * - * @param string $itemKey - */ - public function setItemKey($itemKey) - { - $this->itemKey = $itemKey; - } + /** + * Set the itemKey which will be written to. + * + * @param string $itemKey + */ + public function setItemKey($itemKey) + { + $this->itemKey = $itemKey; + } - /** - * Any implementation should be cloneable, allowing the clone to access a - * separate $nsKey and $itemKey. - */ - public function __clone() - { - $this->writeThrough = null; - } + /** + * Any implementation should be cloneable, allowing the clone to access a + * separate $nsKey and $itemKey. + */ + public function __clone() + { + $this->writeThrough = null; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/LoadBalancedTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/LoadBalancedTransport.php index 3373f67964e..244b5f60245 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/LoadBalancedTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/LoadBalancedTransport.php @@ -15,19 +15,19 @@ */ class Swift_LoadBalancedTransport extends Swift_Transport_LoadBalancedTransport { - /** - * Creates a new LoadBalancedTransport with $transports. - * - * @param array $transports - */ - public function __construct($transports = []) - { - \call_user_func_array( - [$this, 'Swift_Transport_LoadBalancedTransport::__construct'], - Swift_DependencyContainer::getInstance() - ->createDependenciesFor('transport.loadbalanced') - ); + /** + * Creates a new LoadBalancedTransport with $transports. + * + * @param array $transports + */ + public function __construct($transports = []) + { + \call_user_func_array( + [$this, 'Swift_Transport_LoadBalancedTransport::__construct'], + Swift_DependencyContainer::getInstance() + ->createDependenciesFor('transport.loadbalanced') + ); - $this->setTransports($transports); - } + $this->setTransports($transports); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mailer.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mailer.php index ef9d66365bb..57630074cd9 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mailer.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mailer.php @@ -15,84 +15,84 @@ */ class Swift_Mailer { - /** The Transport used to send messages */ - private $transport; + /** The Transport used to send messages */ + private $transport; - /** - * Create a new Mailer using $transport for delivery. - */ - public function __construct(Swift_Transport $transport) - { - $this->transport = $transport; - } + /** + * Create a new Mailer using $transport for delivery. + */ + public function __construct(Swift_Transport $transport) + { + $this->transport = $transport; + } - /** - * Create a new class instance of one of the message services. - * - * For example 'mimepart' would create a 'message.mimepart' instance - * - * @param string $service - * - * @return object - */ - public function createMessage($service = 'message') - { - return Swift_DependencyContainer::getInstance() - ->lookup('message.'.$service); - } + /** + * Create a new class instance of one of the message services. + * + * For example 'mimepart' would create a 'message.mimepart' instance + * + * @param string $service + * + * @return object + */ + public function createMessage($service = 'message') + { + return Swift_DependencyContainer::getInstance() + ->lookup('message.'.$service); + } - /** - * Send the given Message like it would be sent in a mail client. - * - * All recipients (with the exception of Bcc) will be able to see the other - * recipients this message was sent to. - * - * Recipient/sender data will be retrieved from the Message object. - * - * The return value is the number of recipients who were accepted for - * delivery. - * - * @param array $failedRecipients An array of failures by-reference - * - * @return int The number of successful recipients. Can be 0 which indicates failure - */ - public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) - { - $failedRecipients = (array) $failedRecipients; + /** + * Send the given Message like it would be sent in a mail client. + * + * All recipients (with the exception of Bcc) will be able to see the other + * recipients this message was sent to. + * + * Recipient/sender data will be retrieved from the Message object. + * + * The return value is the number of recipients who were accepted for + * delivery. + * + * @param array $failedRecipients An array of failures by-reference + * + * @return int The number of successful recipients. Can be 0 which indicates failure + */ + public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) + { + $failedRecipients = (array) $failedRecipients; - // FIXME: to be removed in 7.0 (as transport must now start itself on send) - if (!$this->transport->isStarted()) { - $this->transport->start(); - } + // FIXME: to be removed in 7.0 (as transport must now start itself on send) + if (!$this->transport->isStarted()) { + $this->transport->start(); + } - $sent = 0; + $sent = 0; - try { - $sent = $this->transport->send($message, $failedRecipients); - } catch (Swift_RfcComplianceException $e) { - foreach ($message->getTo() as $address => $name) { - $failedRecipients[] = $address; - } - } + try { + $sent = $this->transport->send($message, $failedRecipients); + } catch (Swift_RfcComplianceException $e) { + foreach ($message->getTo() as $address => $name) { + $failedRecipients[] = $address; + } + } - return $sent; - } + return $sent; + } - /** - * Register a plugin using a known unique key (e.g. myPlugin). - */ - public function registerPlugin(Swift_Events_EventListener $plugin) - { - $this->transport->registerPlugin($plugin); - } + /** + * Register a plugin using a known unique key (e.g. myPlugin). + */ + public function registerPlugin(Swift_Events_EventListener $plugin) + { + $this->transport->registerPlugin($plugin); + } - /** - * The Transport used to send messages. - * - * @return Swift_Transport - */ - public function getTransport() - { - return $this->transport; - } + /** + * The Transport used to send messages. + * + * @return Swift_Transport + */ + public function getTransport() + { + return $this->transport; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mailer/ArrayRecipientIterator.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mailer/ArrayRecipientIterator.php index 6ee0b1571a4..19aa82a9c40 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mailer/ArrayRecipientIterator.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mailer/ArrayRecipientIterator.php @@ -15,39 +15,39 @@ */ class Swift_Mailer_ArrayRecipientIterator implements Swift_Mailer_RecipientIterator { - /** - * The list of recipients. - * - * @var array - */ - private $recipients = []; + /** + * The list of recipients. + * + * @var array + */ + private $recipients = []; - /** - * Create a new ArrayRecipientIterator from $recipients. - */ - public function __construct(array $recipients) - { - $this->recipients = $recipients; - } + /** + * Create a new ArrayRecipientIterator from $recipients. + */ + public function __construct(array $recipients) + { + $this->recipients = $recipients; + } - /** - * Returns true only if there are more recipients to send to. - * - * @return bool - */ - public function hasNext() - { - return !empty($this->recipients); - } + /** + * Returns true only if there are more recipients to send to. + * + * @return bool + */ + public function hasNext() + { + return !empty($this->recipients); + } - /** - * Returns an array where the keys are the addresses of recipients and the - * values are the names. e.g. ('foo@bar' => 'Foo') or ('foo@bar' => NULL). - * - * @return array - */ - public function nextRecipient() - { - return array_splice($this->recipients, 0, 1); - } + /** + * Returns an array where the keys are the addresses of recipients and the + * values are the names. e.g. ('foo@bar' => 'Foo') or ('foo@bar' => NULL). + * + * @return array + */ + public function nextRecipient() + { + return array_splice($this->recipients, 0, 1); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/MemorySpool.php b/htdocs/includes/swiftmailer/lib/classes/Swift/MemorySpool.php index af430351eba..e3b0894d87a 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/MemorySpool.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/MemorySpool.php @@ -15,96 +15,96 @@ */ class Swift_MemorySpool implements Swift_Spool { - protected $messages = []; - private $flushRetries = 3; + protected $messages = []; + private $flushRetries = 3; - /** - * Tests if this Transport mechanism has started. - * - * @return bool - */ - public function isStarted() - { - return true; - } + /** + * Tests if this Transport mechanism has started. + * + * @return bool + */ + public function isStarted() + { + return true; + } - /** - * Starts this Transport mechanism. - */ - public function start() - { - } + /** + * Starts this Transport mechanism. + */ + public function start() + { + } - /** - * Stops this Transport mechanism. - */ - public function stop() - { - } + /** + * Stops this Transport mechanism. + */ + public function stop() + { + } - /** - * @param int $retries - */ - public function setFlushRetries($retries) - { - $this->flushRetries = $retries; - } + /** + * @param int $retries + */ + public function setFlushRetries($retries) + { + $this->flushRetries = $retries; + } - /** - * Stores a message in the queue. - * - * @param Swift_Mime_SimpleMessage $message The message to store - * - * @return bool Whether the operation has succeeded - */ - public function queueMessage(Swift_Mime_SimpleMessage $message) - { - //clone the message to make sure it is not changed while in the queue - $this->messages[] = clone $message; + /** + * Stores a message in the queue. + * + * @param Swift_Mime_SimpleMessage $message The message to store + * + * @return bool Whether the operation has succeeded + */ + public function queueMessage(Swift_Mime_SimpleMessage $message) + { + //clone the message to make sure it is not changed while in the queue + $this->messages[] = clone $message; - return true; - } + return true; + } - /** - * Sends messages using the given transport instance. - * - * @param Swift_Transport $transport A transport instance - * @param string[] $failedRecipients An array of failures by-reference - * - * @return int The number of sent emails - */ - public function flushQueue(Swift_Transport $transport, &$failedRecipients = null) - { - if (!$this->messages) { - return 0; - } + /** + * Sends messages using the given transport instance. + * + * @param Swift_Transport $transport A transport instance + * @param string[] $failedRecipients An array of failures by-reference + * + * @return int The number of sent emails + */ + public function flushQueue(Swift_Transport $transport, &$failedRecipients = null) + { + if (!$this->messages) { + return 0; + } - if (!$transport->isStarted()) { - $transport->start(); - } + if (!$transport->isStarted()) { + $transport->start(); + } - $count = 0; - $retries = $this->flushRetries; - while ($retries--) { - try { - while ($message = array_pop($this->messages)) { - $count += $transport->send($message, $failedRecipients); - } - } catch (Swift_TransportException $exception) { - if ($retries) { - // re-queue the message at the end of the queue to give a chance - // to the other messages to be sent, in case the failure was due to - // this message and not just the transport failing - array_unshift($this->messages, $message); + $count = 0; + $retries = $this->flushRetries; + while ($retries--) { + try { + while ($message = array_pop($this->messages)) { + $count += $transport->send($message, $failedRecipients); + } + } catch (Swift_TransportException $exception) { + if ($retries) { + // re-queue the message at the end of the queue to give a chance + // to the other messages to be sent, in case the failure was due to + // this message and not just the transport failing + array_unshift($this->messages, $message); - // wait half a second before we try again - usleep(500000); - } else { - throw $exception; - } - } - } + // wait half a second before we try again + usleep(500000); + } else { + throw $exception; + } + } + } - return $count; - } + return $count; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Message.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Message.php index 103563c620c..5c5834e23d8 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Message.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Message.php @@ -15,265 +15,265 @@ */ class Swift_Message extends Swift_Mime_SimpleMessage { - /** - * @var Swift_Signers_HeaderSigner[] - */ - private $headerSigners = []; + /** + * @var Swift_Signers_HeaderSigner[] + */ + private $headerSigners = []; - /** - * @var Swift_Signers_BodySigner[] - */ - private $bodySigners = []; + /** + * @var Swift_Signers_BodySigner[] + */ + private $bodySigners = []; - /** - * @var array - */ - private $savedMessage = []; + /** + * @var array + */ + private $savedMessage = []; - /** - * Create a new Message. - * - * Details may be optionally passed into the constructor. - * - * @param string $subject - * @param string $body - * @param string $contentType - * @param string $charset - */ - public function __construct($subject = null, $body = null, $contentType = null, $charset = null) - { - \call_user_func_array( - [$this, 'Swift_Mime_SimpleMessage::__construct'], - Swift_DependencyContainer::getInstance() - ->createDependenciesFor('mime.message') - ); + /** + * Create a new Message. + * + * Details may be optionally passed into the constructor. + * + * @param string $subject + * @param string $body + * @param string $contentType + * @param string $charset + */ + public function __construct($subject = null, $body = null, $contentType = null, $charset = null) + { + \call_user_func_array( + [$this, 'Swift_Mime_SimpleMessage::__construct'], + Swift_DependencyContainer::getInstance() + ->createDependenciesFor('mime.message') + ); - if (!isset($charset)) { - $charset = Swift_DependencyContainer::getInstance() - ->lookup('properties.charset'); - } - $this->setSubject($subject); - $this->setBody($body); - $this->setCharset($charset); - if ($contentType) { - $this->setContentType($contentType); - } - } + if (!isset($charset)) { + $charset = Swift_DependencyContainer::getInstance() + ->lookup('properties.charset'); + } + $this->setSubject($subject); + $this->setBody($body); + $this->setCharset($charset); + if ($contentType) { + $this->setContentType($contentType); + } + } - /** - * Add a MimePart to this Message. - * - * @param string|Swift_OutputByteStream $body - * @param string $contentType - * @param string $charset - * - * @return $this - */ - public function addPart($body, $contentType = null, $charset = null) - { - return $this->attach((new Swift_MimePart($body, $contentType, $charset))->setEncoder($this->getEncoder())); - } + /** + * Add a MimePart to this Message. + * + * @param string|Swift_OutputByteStream $body + * @param string $contentType + * @param string $charset + * + * @return $this + */ + public function addPart($body, $contentType = null, $charset = null) + { + return $this->attach((new Swift_MimePart($body, $contentType, $charset))->setEncoder($this->getEncoder())); + } - /** - * Attach a new signature handler to the message. - * - * @return $this - */ - public function attachSigner(Swift_Signer $signer) - { - if ($signer instanceof Swift_Signers_HeaderSigner) { - $this->headerSigners[] = $signer; - } elseif ($signer instanceof Swift_Signers_BodySigner) { - $this->bodySigners[] = $signer; - } + /** + * Attach a new signature handler to the message. + * + * @return $this + */ + public function attachSigner(Swift_Signer $signer) + { + if ($signer instanceof Swift_Signers_HeaderSigner) { + $this->headerSigners[] = $signer; + } elseif ($signer instanceof Swift_Signers_BodySigner) { + $this->bodySigners[] = $signer; + } - return $this; - } + return $this; + } - /** - * Detach a signature handler from a message. - * - * @return $this - */ - public function detachSigner(Swift_Signer $signer) - { - if ($signer instanceof Swift_Signers_HeaderSigner) { - foreach ($this->headerSigners as $k => $headerSigner) { - if ($headerSigner === $signer) { - unset($this->headerSigners[$k]); + /** + * Detach a signature handler from a message. + * + * @return $this + */ + public function detachSigner(Swift_Signer $signer) + { + if ($signer instanceof Swift_Signers_HeaderSigner) { + foreach ($this->headerSigners as $k => $headerSigner) { + if ($headerSigner === $signer) { + unset($this->headerSigners[$k]); - return $this; - } - } - } elseif ($signer instanceof Swift_Signers_BodySigner) { - foreach ($this->bodySigners as $k => $bodySigner) { - if ($bodySigner === $signer) { - unset($this->bodySigners[$k]); + return $this; + } + } + } elseif ($signer instanceof Swift_Signers_BodySigner) { + foreach ($this->bodySigners as $k => $bodySigner) { + if ($bodySigner === $signer) { + unset($this->bodySigners[$k]); - return $this; - } - } - } + return $this; + } + } + } - return $this; - } + return $this; + } - /** - * Clear all signature handlers attached to the message. - * - * @return $this - */ - public function clearSigners() - { - $this->headerSigners = []; - $this->bodySigners = []; + /** + * Clear all signature handlers attached to the message. + * + * @return $this + */ + public function clearSigners() + { + $this->headerSigners = []; + $this->bodySigners = []; - return $this; - } + return $this; + } - /** - * Get this message as a complete string. - * - * @return string - */ - public function toString() - { - if (empty($this->headerSigners) && empty($this->bodySigners)) { - return parent::toString(); - } + /** + * Get this message as a complete string. + * + * @return string + */ + public function toString() + { + if (empty($this->headerSigners) && empty($this->bodySigners)) { + return parent::toString(); + } - $this->saveMessage(); + $this->saveMessage(); - $this->doSign(); + $this->doSign(); - $string = parent::toString(); + $string = parent::toString(); - $this->restoreMessage(); + $this->restoreMessage(); - return $string; - } + return $string; + } - /** - * Write this message to a {@link Swift_InputByteStream}. - */ - public function toByteStream(Swift_InputByteStream $is) - { - if (empty($this->headerSigners) && empty($this->bodySigners)) { - parent::toByteStream($is); + /** + * Write this message to a {@link Swift_InputByteStream}. + */ + public function toByteStream(Swift_InputByteStream $is) + { + if (empty($this->headerSigners) && empty($this->bodySigners)) { + parent::toByteStream($is); - return; - } + return; + } - $this->saveMessage(); + $this->saveMessage(); - $this->doSign(); + $this->doSign(); - parent::toByteStream($is); + parent::toByteStream($is); - $this->restoreMessage(); - } + $this->restoreMessage(); + } - public function __wakeup() - { - Swift_DependencyContainer::getInstance()->createDependenciesFor('mime.message'); - } + public function __wakeup() + { + Swift_DependencyContainer::getInstance()->createDependenciesFor('mime.message'); + } - /** - * loops through signers and apply the signatures. - */ - protected function doSign() - { - foreach ($this->bodySigners as $signer) { - $altered = $signer->getAlteredHeaders(); - $this->saveHeaders($altered); - $signer->signMessage($this); - } + /** + * loops through signers and apply the signatures. + */ + protected function doSign() + { + foreach ($this->bodySigners as $signer) { + $altered = $signer->getAlteredHeaders(); + $this->saveHeaders($altered); + $signer->signMessage($this); + } - foreach ($this->headerSigners as $signer) { - $altered = $signer->getAlteredHeaders(); - $this->saveHeaders($altered); - $signer->reset(); + foreach ($this->headerSigners as $signer) { + $altered = $signer->getAlteredHeaders(); + $this->saveHeaders($altered); + $signer->reset(); - $signer->setHeaders($this->getHeaders()); + $signer->setHeaders($this->getHeaders()); - $signer->startBody(); - $this->bodyToByteStream($signer); - $signer->endBody(); + $signer->startBody(); + $this->bodyToByteStream($signer); + $signer->endBody(); - $signer->addSignature($this->getHeaders()); - } - } + $signer->addSignature($this->getHeaders()); + } + } - /** - * save the message before any signature is applied. - */ - protected function saveMessage() - { - $this->savedMessage = ['headers' => []]; - $this->savedMessage['body'] = $this->getBody(); - $this->savedMessage['children'] = $this->getChildren(); - if (\count($this->savedMessage['children']) > 0 && '' != $this->getBody()) { - $this->setChildren(array_merge([$this->becomeMimePart()], $this->savedMessage['children'])); - $this->setBody(''); - } - } + /** + * save the message before any signature is applied. + */ + protected function saveMessage() + { + $this->savedMessage = ['headers' => []]; + $this->savedMessage['body'] = $this->getBody(); + $this->savedMessage['children'] = $this->getChildren(); + if (\count($this->savedMessage['children']) > 0 && '' != $this->getBody()) { + $this->setChildren(array_merge([$this->becomeMimePart()], $this->savedMessage['children'])); + $this->setBody(''); + } + } - /** - * save the original headers. - */ - protected function saveHeaders(array $altered) - { - foreach ($altered as $head) { - $lc = strtolower($head ?? ''); + /** + * save the original headers. + */ + protected function saveHeaders(array $altered) + { + foreach ($altered as $head) { + $lc = strtolower($head ?? ''); - if (!isset($this->savedMessage['headers'][$lc])) { - $this->savedMessage['headers'][$lc] = $this->getHeaders()->getAll($head); - } - } - } + if (!isset($this->savedMessage['headers'][$lc])) { + $this->savedMessage['headers'][$lc] = $this->getHeaders()->getAll($head); + } + } + } - /** - * Remove or restore altered headers. - */ - protected function restoreHeaders() - { - foreach ($this->savedMessage['headers'] as $name => $savedValue) { - $headers = $this->getHeaders()->getAll($name); + /** + * Remove or restore altered headers. + */ + protected function restoreHeaders() + { + foreach ($this->savedMessage['headers'] as $name => $savedValue) { + $headers = $this->getHeaders()->getAll($name); - foreach ($headers as $key => $value) { - if (!isset($savedValue[$key])) { - $this->getHeaders()->remove($name, $key); - } - } - } - } + foreach ($headers as $key => $value) { + if (!isset($savedValue[$key])) { + $this->getHeaders()->remove($name, $key); + } + } + } + } - /** - * Restore message body. - */ - protected function restoreMessage() - { - $this->setBody($this->savedMessage['body']); - $this->setChildren($this->savedMessage['children']); + /** + * Restore message body. + */ + protected function restoreMessage() + { + $this->setBody($this->savedMessage['body']); + $this->setChildren($this->savedMessage['children']); - $this->restoreHeaders(); - $this->savedMessage = []; - } + $this->restoreHeaders(); + $this->savedMessage = []; + } - /** - * Clone Message Signers. - * - * @see Swift_Mime_SimpleMimeEntity::__clone() - */ - public function __clone() - { - parent::__clone(); - foreach ($this->bodySigners as $key => $bodySigner) { - $this->bodySigners[$key] = clone $bodySigner; - } + /** + * Clone Message Signers. + * + * @see Swift_Mime_SimpleMimeEntity::__clone() + */ + public function __clone() + { + parent::__clone(); + foreach ($this->bodySigners as $key => $bodySigner) { + $this->bodySigners[$key] = clone $bodySigner; + } - foreach ($this->headerSigners as $key => $headerSigner) { - $this->headerSigners[$key] = clone $headerSigner; - } - } + foreach ($this->headerSigners as $key => $headerSigner) { + $this->headerSigners[$key] = clone $headerSigner; + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Attachment.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Attachment.php index ed9b7cbe50c..d994373bd78 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Attachment.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Attachment.php @@ -15,130 +15,130 @@ */ class Swift_Mime_Attachment extends Swift_Mime_SimpleMimeEntity { - /** Recognized MIME types */ - private $mimeTypes = []; + /** Recognized MIME types */ + private $mimeTypes = []; - /** - * Create a new Attachment with $headers, $encoder and $cache. - * - * @param array $mimeTypes - */ - public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator, $mimeTypes = []) - { - parent::__construct($headers, $encoder, $cache, $idGenerator); - $this->setDisposition('attachment'); - $this->setContentType('application/octet-stream'); - $this->mimeTypes = $mimeTypes; - } + /** + * Create a new Attachment with $headers, $encoder and $cache. + * + * @param array $mimeTypes + */ + public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator, $mimeTypes = []) + { + parent::__construct($headers, $encoder, $cache, $idGenerator); + $this->setDisposition('attachment'); + $this->setContentType('application/octet-stream'); + $this->mimeTypes = $mimeTypes; + } - /** - * Get the nesting level used for this attachment. - * - * Always returns {@link LEVEL_MIXED}. - * - * @return int - */ - public function getNestingLevel() - { - return self::LEVEL_MIXED; - } + /** + * Get the nesting level used for this attachment. + * + * Always returns {@link LEVEL_MIXED}. + * + * @return int + */ + public function getNestingLevel() + { + return self::LEVEL_MIXED; + } - /** - * Get the Content-Disposition of this attachment. - * - * By default attachments have a disposition of "attachment". - * - * @return string - */ - public function getDisposition() - { - return $this->getHeaderFieldModel('Content-Disposition'); - } + /** + * Get the Content-Disposition of this attachment. + * + * By default attachments have a disposition of "attachment". + * + * @return string + */ + public function getDisposition() + { + return $this->getHeaderFieldModel('Content-Disposition'); + } - /** - * Set the Content-Disposition of this attachment. - * - * @param string $disposition - * - * @return $this - */ - public function setDisposition($disposition) - { - if (!$this->setHeaderFieldModel('Content-Disposition', $disposition)) { - $this->getHeaders()->addParameterizedHeader('Content-Disposition', $disposition); - } + /** + * Set the Content-Disposition of this attachment. + * + * @param string $disposition + * + * @return $this + */ + public function setDisposition($disposition) + { + if (!$this->setHeaderFieldModel('Content-Disposition', $disposition)) { + $this->getHeaders()->addParameterizedHeader('Content-Disposition', $disposition); + } - return $this; - } + return $this; + } - /** - * Get the filename of this attachment when downloaded. - * - * @return string - */ - public function getFilename() - { - return $this->getHeaderParameter('Content-Disposition', 'filename'); - } + /** + * Get the filename of this attachment when downloaded. + * + * @return string + */ + public function getFilename() + { + return $this->getHeaderParameter('Content-Disposition', 'filename'); + } - /** - * Set the filename of this attachment. - * - * @param string $filename - * - * @return $this - */ - public function setFilename($filename) - { - $this->setHeaderParameter('Content-Disposition', 'filename', $filename); - $this->setHeaderParameter('Content-Type', 'name', $filename); + /** + * Set the filename of this attachment. + * + * @param string $filename + * + * @return $this + */ + public function setFilename($filename) + { + $this->setHeaderParameter('Content-Disposition', 'filename', $filename); + $this->setHeaderParameter('Content-Type', 'name', $filename); - return $this; - } + return $this; + } - /** - * Get the file size of this attachment. - * - * @return int - */ - public function getSize() - { - return $this->getHeaderParameter('Content-Disposition', 'size'); - } + /** + * Get the file size of this attachment. + * + * @return int + */ + public function getSize() + { + return $this->getHeaderParameter('Content-Disposition', 'size'); + } - /** - * Set the file size of this attachment. - * - * @param int $size - * - * @return $this - */ - public function setSize($size) - { - $this->setHeaderParameter('Content-Disposition', 'size', $size); + /** + * Set the file size of this attachment. + * + * @param int $size + * + * @return $this + */ + public function setSize($size) + { + $this->setHeaderParameter('Content-Disposition', 'size', $size); - return $this; - } + return $this; + } - /** - * Set the file that this attachment is for. - * - * @param string $contentType optional - * - * @return $this - */ - public function setFile(Swift_FileStream $file, $contentType = null) - { - $this->setFilename(basename($file->getPath())); - $this->setBody($file, $contentType); - if (!isset($contentType)) { - $extension = strtolower(substr($file->getPath(), strrpos($file->getPath(), '.') + 1)); + /** + * Set the file that this attachment is for. + * + * @param string $contentType optional + * + * @return $this + */ + public function setFile(Swift_FileStream $file, $contentType = null) + { + $this->setFilename(basename($file->getPath())); + $this->setBody($file, $contentType); + if (!isset($contentType)) { + $extension = strtolower(substr($file->getPath(), strrpos($file->getPath(), '.') + 1)); - if (\array_key_exists($extension, $this->mimeTypes)) { - $this->setContentType($this->mimeTypes[$extension]); - } - } + if (\array_key_exists($extension, $this->mimeTypes)) { + $this->setContentType($this->mimeTypes[$extension]); + } + } - return $this; - } + return $this; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/Base64ContentEncoder.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/Base64ContentEncoder.php index d7ae850d61a..b7e1e028307 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/Base64ContentEncoder.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/Base64ContentEncoder.php @@ -15,87 +15,87 @@ */ class Swift_Mime_ContentEncoder_Base64ContentEncoder extends Swift_Encoder_Base64Encoder implements Swift_Mime_ContentEncoder { - /** - * Encode stream $in to stream $out. - * - * @param int $firstLineOffset - */ - public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) - { - if (0 >= $maxLineLength || 76 < $maxLineLength) { - $maxLineLength = 76; - } + /** + * Encode stream $in to stream $out. + * + * @param int $firstLineOffset + */ + public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) + { + if (0 >= $maxLineLength || 76 < $maxLineLength) { + $maxLineLength = 76; + } - $remainder = 0; - $base64ReadBufferRemainderBytes = ''; + $remainder = 0; + $base64ReadBufferRemainderBytes = ''; - // To reduce memory usage, the output buffer is streamed to the input buffer like so: - // Output Stream => base64encode => wrap line length => Input Stream - // HOWEVER it's important to note that base64_encode() should only be passed whole triplets of data (except for the final chunk of data) - // otherwise it will assume the input data has *ended* and it will incorrectly pad/terminate the base64 data mid-stream. - // We use $base64ReadBufferRemainderBytes to carry over 1-2 "remainder" bytes from the each chunk from OutputStream and pre-pend those onto the - // chunk of bytes read in the next iteration. - // When the OutputStream is empty, we must flush any remainder bytes. - while (true) { - $readBytes = $os->read(8192); - $atEOF = (false === $readBytes); + // To reduce memory usage, the output buffer is streamed to the input buffer like so: + // Output Stream => base64encode => wrap line length => Input Stream + // HOWEVER it's important to note that base64_encode() should only be passed whole triplets of data (except for the final chunk of data) + // otherwise it will assume the input data has *ended* and it will incorrectly pad/terminate the base64 data mid-stream. + // We use $base64ReadBufferRemainderBytes to carry over 1-2 "remainder" bytes from the each chunk from OutputStream and pre-pend those onto the + // chunk of bytes read in the next iteration. + // When the OutputStream is empty, we must flush any remainder bytes. + while (true) { + $readBytes = $os->read(8192); + $atEOF = (false === $readBytes); - if ($atEOF) { - $streamTheseBytes = $base64ReadBufferRemainderBytes; - } else { - $streamTheseBytes = $base64ReadBufferRemainderBytes.$readBytes; - } - $base64ReadBufferRemainderBytes = ''; - $bytesLength = \strlen($streamTheseBytes); + if ($atEOF) { + $streamTheseBytes = $base64ReadBufferRemainderBytes; + } else { + $streamTheseBytes = $base64ReadBufferRemainderBytes.$readBytes; + } + $base64ReadBufferRemainderBytes = ''; + $bytesLength = \strlen($streamTheseBytes); - if (0 === $bytesLength) { // no data left to encode - break; - } + if (0 === $bytesLength) { // no data left to encode + break; + } - // if we're not on the last block of the ouput stream, make sure $streamTheseBytes ends with a complete triplet of data - // and carry over remainder 1-2 bytes to the next loop iteration - if (!$atEOF) { - $excessBytes = $bytesLength % 3; - if (0 !== $excessBytes) { - $base64ReadBufferRemainderBytes = substr($streamTheseBytes, -$excessBytes); - $streamTheseBytes = substr($streamTheseBytes, 0, $bytesLength - $excessBytes); - } - } + // if we're not on the last block of the ouput stream, make sure $streamTheseBytes ends with a complete triplet of data + // and carry over remainder 1-2 bytes to the next loop iteration + if (!$atEOF) { + $excessBytes = $bytesLength % 3; + if (0 !== $excessBytes) { + $base64ReadBufferRemainderBytes = substr($streamTheseBytes, -$excessBytes); + $streamTheseBytes = substr($streamTheseBytes, 0, $bytesLength - $excessBytes); + } + } - $encoded = base64_encode($streamTheseBytes); - $encodedTransformed = ''; - $thisMaxLineLength = $maxLineLength - $remainder - $firstLineOffset; + $encoded = base64_encode($streamTheseBytes); + $encodedTransformed = ''; + $thisMaxLineLength = $maxLineLength - $remainder - $firstLineOffset; - while ($thisMaxLineLength < \strlen($encoded)) { - $encodedTransformed .= substr($encoded, 0, $thisMaxLineLength)."\r\n"; - $firstLineOffset = 0; - $encoded = substr($encoded, $thisMaxLineLength); - $thisMaxLineLength = $maxLineLength; - $remainder = 0; - } + while ($thisMaxLineLength < \strlen($encoded)) { + $encodedTransformed .= substr($encoded, 0, $thisMaxLineLength)."\r\n"; + $firstLineOffset = 0; + $encoded = substr($encoded, $thisMaxLineLength); + $thisMaxLineLength = $maxLineLength; + $remainder = 0; + } - if (0 < $remainingLength = \strlen($encoded)) { - $remainder += $remainingLength; - $encodedTransformed .= $encoded; - $encoded = null; - } + if (0 < $remainingLength = \strlen($encoded)) { + $remainder += $remainingLength; + $encodedTransformed .= $encoded; + $encoded = null; + } - $is->write($encodedTransformed); + $is->write($encodedTransformed); - if ($atEOF) { - break; - } - } - } + if ($atEOF) { + break; + } + } + } - /** - * Get the name of this encoding scheme. - * Returns the string 'base64'. - * - * @return string - */ - public function getName() - { - return 'base64'; - } + /** + * Get the name of this encoding scheme. + * Returns the string 'base64'. + * + * @return string + */ + public function getName() + { + return 'base64'; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/NativeQpContentEncoder.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/NativeQpContentEncoder.php index a678d67edaf..8dfea605fde 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/NativeQpContentEncoder.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/NativeQpContentEncoder.php @@ -15,107 +15,107 @@ */ class Swift_Mime_ContentEncoder_NativeQpContentEncoder implements Swift_Mime_ContentEncoder { - /** - * @var string|null - */ - private $charset; + /** + * @var string|null + */ + private $charset; - /** - * @param string|null $charset - */ - public function __construct($charset = null) - { - $this->charset = $charset ?: 'utf-8'; - } + /** + * @param string|null $charset + */ + public function __construct($charset = null) + { + $this->charset = $charset ?: 'utf-8'; + } - /** - * Notify this observer that the entity's charset has changed. - * - * @param string $charset - */ - public function charsetChanged($charset) - { - $this->charset = $charset; - } + /** + * Notify this observer that the entity's charset has changed. + * + * @param string $charset + */ + public function charsetChanged($charset) + { + $this->charset = $charset; + } - /** - * Encode $in to $out. - * - * @param Swift_OutputByteStream $os to read from - * @param Swift_InputByteStream $is to write to - * @param int $firstLineOffset - * @param int $maxLineLength 0 indicates the default length for this encoding - * - * @throws RuntimeException - */ - public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) - { - if ('utf-8' !== $this->charset) { - throw new RuntimeException(sprintf('Charset "%s" not supported. NativeQpContentEncoder only supports "utf-8"', $this->charset)); - } + /** + * Encode $in to $out. + * + * @param Swift_OutputByteStream $os to read from + * @param Swift_InputByteStream $is to write to + * @param int $firstLineOffset + * @param int $maxLineLength 0 indicates the default length for this encoding + * + * @throws RuntimeException + */ + public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) + { + if ('utf-8' !== $this->charset) { + throw new RuntimeException(sprintf('Charset "%s" not supported. NativeQpContentEncoder only supports "utf-8"', $this->charset)); + } - $string = ''; + $string = ''; - while (false !== $bytes = $os->read(8192)) { - $string .= $bytes; - } + while (false !== $bytes = $os->read(8192)) { + $string .= $bytes; + } - $is->write($this->encodeString($string)); - } + $is->write($this->encodeString($string)); + } - /** - * Get the MIME name of this content encoding scheme. - * - * @return string - */ - public function getName() - { - return 'quoted-printable'; - } + /** + * Get the MIME name of this content encoding scheme. + * + * @return string + */ + public function getName() + { + return 'quoted-printable'; + } - /** - * Encode a given string to produce an encoded string. - * - * @param string $string - * @param int $firstLineOffset if first line needs to be shorter - * @param int $maxLineLength 0 indicates the default length for this encoding - * - * @throws RuntimeException - * - * @return string - */ - public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) - { - if ('utf-8' !== $this->charset) { - throw new RuntimeException(sprintf('Charset "%s" not supported. NativeQpContentEncoder only supports "utf-8"', $this->charset)); - } + /** + * Encode a given string to produce an encoded string. + * + * @param string $string + * @param int $firstLineOffset if first line needs to be shorter + * @param int $maxLineLength 0 indicates the default length for this encoding + * + * @throws RuntimeException + * + * @return string + */ + public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) + { + if ('utf-8' !== $this->charset) { + throw new RuntimeException(sprintf('Charset "%s" not supported. NativeQpContentEncoder only supports "utf-8"', $this->charset)); + } - return $this->standardize(quoted_printable_encode($string)); - } + return $this->standardize(quoted_printable_encode($string)); + } - /** - * Make sure CRLF is correct and HT/SPACE are in valid places. - * - * @param string $string - * - * @return string - */ - protected function standardize($string) - { - // transform CR or LF to CRLF - $string = preg_replace('~=0D(?!=0A)|(?name = $name; - } + /** + * Creates a new NullContentEncoder with $name (probably 7bit or 8bit). + * + * @param string $name + */ + public function __construct($name) + { + $this->name = $name; + } - /** - * Encode a given string to produce an encoded string. - * - * @param string $string - * @param int $firstLineOffset ignored - * @param int $maxLineLength ignored - * - * @return string - */ - public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) - { - return $string; - } + /** + * Encode a given string to produce an encoded string. + * + * @param string $string + * @param int $firstLineOffset ignored + * @param int $maxLineLength ignored + * + * @return string + */ + public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) + { + return $string; + } - /** - * Encode stream $in to stream $out. - * - * @param int $firstLineOffset ignored - * @param int $maxLineLength ignored - */ - public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) - { - while (false !== ($bytes = $os->read(8192))) { - $is->write($bytes); - } - } + /** + * Encode stream $in to stream $out. + * + * @param int $firstLineOffset ignored + * @param int $maxLineLength ignored + */ + public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) + { + while (false !== ($bytes = $os->read(8192))) { + $is->write($bytes); + } + } - /** - * Get the name of this encoding scheme. - * - * @return string - */ - public function getName() - { - return $this->name; - } + /** + * Get the name of this encoding scheme. + * + * @return string + */ + public function getName() + { + return $this->name; + } - /** - * Not used. - */ - public function charsetChanged($charset) - { - } + /** + * Not used. + */ + public function charsetChanged($charset) + { + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/PlainContentEncoder.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/PlainContentEncoder.php index 02546e03d95..72592fc5894 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/PlainContentEncoder.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/PlainContentEncoder.php @@ -19,146 +19,146 @@ */ class Swift_Mime_ContentEncoder_PlainContentEncoder implements Swift_Mime_ContentEncoder { - /** - * The name of this encoding scheme (probably 7bit or 8bit). - * - * @var string - */ - private $name; + /** + * The name of this encoding scheme (probably 7bit or 8bit). + * + * @var string + */ + private $name; - /** - * True if canonical transformations should be done. - * - * @var bool - */ - private $canonical; + /** + * True if canonical transformations should be done. + * + * @var bool + */ + private $canonical; - /** - * Creates a new PlainContentEncoder with $name (probably 7bit or 8bit). - * - * @param string $name - * @param bool $canonical if canonicalization transformation should be done - */ - public function __construct($name, $canonical = false) - { - $this->name = $name; - $this->canonical = $canonical; - } + /** + * Creates a new PlainContentEncoder with $name (probably 7bit or 8bit). + * + * @param string $name + * @param bool $canonical if canonicalization transformation should be done + */ + public function __construct($name, $canonical = false) + { + $this->name = $name; + $this->canonical = $canonical; + } - /** - * Encode a given string to produce an encoded string. - * - * @param string $string - * @param int $firstLineOffset ignored - * @param int $maxLineLength - 0 means no wrapping will occur - * - * @return string - */ - public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) - { - if ($this->canonical) { - $string = $this->canonicalize($string); - } + /** + * Encode a given string to produce an encoded string. + * + * @param string $string + * @param int $firstLineOffset ignored + * @param int $maxLineLength - 0 means no wrapping will occur + * + * @return string + */ + public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) + { + if ($this->canonical) { + $string = $this->canonicalize($string); + } - return $this->safeWordwrap($string, $maxLineLength, "\r\n"); - } + return $this->safeWordwrap($string, $maxLineLength, "\r\n"); + } - /** - * Encode stream $in to stream $out. - * - * @param int $firstLineOffset ignored - * @param int $maxLineLength optional, 0 means no wrapping will occur - */ - public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) - { - $leftOver = ''; - while (false !== $bytes = $os->read(8192)) { - $toencode = $leftOver.$bytes; - if ($this->canonical) { - $toencode = $this->canonicalize($toencode); - } - $wrapped = $this->safeWordwrap($toencode, $maxLineLength, "\r\n"); - $lastLinePos = strrpos($wrapped, "\r\n"); - $leftOver = substr($wrapped, $lastLinePos); - $wrapped = substr($wrapped, 0, $lastLinePos); + /** + * Encode stream $in to stream $out. + * + * @param int $firstLineOffset ignored + * @param int $maxLineLength optional, 0 means no wrapping will occur + */ + public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) + { + $leftOver = ''; + while (false !== $bytes = $os->read(8192)) { + $toencode = $leftOver.$bytes; + if ($this->canonical) { + $toencode = $this->canonicalize($toencode); + } + $wrapped = $this->safeWordwrap($toencode, $maxLineLength, "\r\n"); + $lastLinePos = strrpos($wrapped, "\r\n"); + $leftOver = substr($wrapped, $lastLinePos); + $wrapped = substr($wrapped, 0, $lastLinePos); - $is->write($wrapped); - } - if (\strlen($leftOver)) { - $is->write($leftOver); - } - } + $is->write($wrapped); + } + if (\strlen($leftOver)) { + $is->write($leftOver); + } + } - /** - * Get the name of this encoding scheme. - * - * @return string - */ - public function getName() - { - return $this->name; - } + /** + * Get the name of this encoding scheme. + * + * @return string + */ + public function getName() + { + return $this->name; + } - /** - * Not used. - */ - public function charsetChanged($charset) - { - } + /** + * Not used. + */ + public function charsetChanged($charset) + { + } - /** - * A safer (but weaker) wordwrap for unicode. - * - * @param string $string - * @param int $length - * @param string $le - * - * @return string - */ - private function safeWordwrap($string, $length = 75, $le = "\r\n") - { - if (0 >= $length) { - return $string; - } + /** + * A safer (but weaker) wordwrap for unicode. + * + * @param string $string + * @param int $length + * @param string $le + * + * @return string + */ + private function safeWordwrap($string, $length = 75, $le = "\r\n") + { + if (0 >= $length) { + return $string; + } - $originalLines = explode($le, $string); + $originalLines = explode($le, $string); - $lines = []; - $lineCount = 0; + $lines = []; + $lineCount = 0; - foreach ($originalLines as $originalLine) { - $lines[] = ''; - $currentLine = &$lines[$lineCount++]; + foreach ($originalLines as $originalLine) { + $lines[] = ''; + $currentLine = &$lines[$lineCount++]; - //$chunks = preg_split('/(?<=[\ \t,\.!\?\-&\+\/])/', $originalLine); - $chunks = preg_split('/(?<=\s)/', $originalLine); + //$chunks = preg_split('/(?<=[\ \t,\.!\?\-&\+\/])/', $originalLine); + $chunks = preg_split('/(?<=\s)/', $originalLine); - foreach ($chunks as $chunk) { - if (0 != \strlen($currentLine) - && \strlen($currentLine.$chunk) > $length) { - $lines[] = ''; - $currentLine = &$lines[$lineCount++]; - } - $currentLine .= $chunk; - } - } + foreach ($chunks as $chunk) { + if (0 != \strlen($currentLine) + && \strlen($currentLine.$chunk) > $length) { + $lines[] = ''; + $currentLine = &$lines[$lineCount++]; + } + $currentLine .= $chunk; + } + } - return implode("\r\n", $lines); - } + return implode("\r\n", $lines); + } - /** - * Canonicalize string input (fix CRLF). - * - * @param string $string - * - * @return string - */ - private function canonicalize($string) - { - return str_replace( - ["\r\n", "\r", "\n"], - ["\n", "\n", "\r\n"], - $string - ); - } + /** + * Canonicalize string input (fix CRLF). + * + * @param string $string + * + * @return string + */ + private function canonicalize($string) + { + return str_replace( + ["\r\n", "\r", "\n"], + ["\n", "\n", "\r\n"], + $string + ); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php index 51785234043..465ffd87850 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php @@ -15,120 +15,120 @@ */ class Swift_Mime_ContentEncoder_QpContentEncoder extends Swift_Encoder_QpEncoder implements Swift_Mime_ContentEncoder { - protected $dotEscape; + protected $dotEscape; - /** - * Creates a new QpContentEncoder for the given CharacterStream. - * - * @param Swift_CharacterStream $charStream to use for reading characters - * @param Swift_StreamFilter $filter if canonicalization should occur - * @param bool $dotEscape if dot stuffing workaround must be enabled - */ - public function __construct(Swift_CharacterStream $charStream, Swift_StreamFilter $filter = null, $dotEscape = false) - { - $this->dotEscape = $dotEscape; - parent::__construct($charStream, $filter); - } + /** + * Creates a new QpContentEncoder for the given CharacterStream. + * + * @param Swift_CharacterStream $charStream to use for reading characters + * @param Swift_StreamFilter $filter if canonicalization should occur + * @param bool $dotEscape if dot stuffing workaround must be enabled + */ + public function __construct(Swift_CharacterStream $charStream, Swift_StreamFilter $filter = null, $dotEscape = false) + { + $this->dotEscape = $dotEscape; + parent::__construct($charStream, $filter); + } - public function __sleep() - { - return ['charStream', 'filter', 'dotEscape']; - } + public function __sleep() + { + return ['charStream', 'filter', 'dotEscape']; + } - protected function getSafeMapShareId() - { - return static::class.($this->dotEscape ? '.dotEscape' : ''); - } + protected function getSafeMapShareId() + { + return static::class.($this->dotEscape ? '.dotEscape' : ''); + } - protected function initSafeMap() - { - parent::initSafeMap(); - if ($this->dotEscape) { - /* Encode . as =2e for buggy remote servers */ - unset($this->safeMap[0x2e]); - } - } + protected function initSafeMap() + { + parent::initSafeMap(); + if ($this->dotEscape) { + /* Encode . as =2e for buggy remote servers */ + unset($this->safeMap[0x2e]); + } + } - /** - * Encode stream $in to stream $out. - * - * QP encoded strings have a maximum line length of 76 characters. - * If the first line needs to be shorter, indicate the difference with - * $firstLineOffset. - * - * @param Swift_OutputByteStream $os output stream - * @param Swift_InputByteStream $is input stream - * @param int $firstLineOffset - * @param int $maxLineLength - */ - public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) - { - if ($maxLineLength > 76 || $maxLineLength <= 0) { - $maxLineLength = 76; - } + /** + * Encode stream $in to stream $out. + * + * QP encoded strings have a maximum line length of 76 characters. + * If the first line needs to be shorter, indicate the difference with + * $firstLineOffset. + * + * @param Swift_OutputByteStream $os output stream + * @param Swift_InputByteStream $is input stream + * @param int $firstLineOffset + * @param int $maxLineLength + */ + public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) + { + if ($maxLineLength > 76 || $maxLineLength <= 0) { + $maxLineLength = 76; + } - $thisLineLength = $maxLineLength - $firstLineOffset; + $thisLineLength = $maxLineLength - $firstLineOffset; - $this->charStream->flushContents(); - $this->charStream->importByteStream($os); + $this->charStream->flushContents(); + $this->charStream->importByteStream($os); - $currentLine = ''; - $prepend = ''; - $size = $lineLen = 0; + $currentLine = ''; + $prepend = ''; + $size = $lineLen = 0; - while (false !== $bytes = $this->nextSequence()) { - // If we're filtering the input - if (isset($this->filter)) { - // If we can't filter because we need more bytes - while ($this->filter->shouldBuffer($bytes)) { - // Then collect bytes into the buffer - if (false === $moreBytes = $this->nextSequence(1)) { - break; - } + while (false !== $bytes = $this->nextSequence()) { + // If we're filtering the input + if (isset($this->filter)) { + // If we can't filter because we need more bytes + while ($this->filter->shouldBuffer($bytes)) { + // Then collect bytes into the buffer + if (false === $moreBytes = $this->nextSequence(1)) { + break; + } - foreach ($moreBytes as $b) { - $bytes[] = $b; - } - } - // And filter them - $bytes = $this->filter->filter($bytes); - } + foreach ($moreBytes as $b) { + $bytes[] = $b; + } + } + // And filter them + $bytes = $this->filter->filter($bytes); + } - $enc = $this->encodeByteSequence($bytes, $size); + $enc = $this->encodeByteSequence($bytes, $size); - $i = strpos($enc, '=0D=0A'); - $newLineLength = $lineLen + (false === $i ? $size : $i); + $i = strpos($enc, '=0D=0A'); + $newLineLength = $lineLen + (false === $i ? $size : $i); - if ($currentLine && $newLineLength >= $thisLineLength) { - $is->write($prepend.$this->standardize($currentLine)); - $currentLine = ''; - $prepend = "=\r\n"; - $thisLineLength = $maxLineLength; - $lineLen = 0; - } + if ($currentLine && $newLineLength >= $thisLineLength) { + $is->write($prepend.$this->standardize($currentLine)); + $currentLine = ''; + $prepend = "=\r\n"; + $thisLineLength = $maxLineLength; + $lineLen = 0; + } - $currentLine .= $enc; + $currentLine .= $enc; - if (false === $i) { - $lineLen += $size; - } else { - // 6 is the length of '=0D=0A'. - $lineLen = $size - strrpos($enc, '=0D=0A') - 6; - } - } - if (\strlen($currentLine)) { - $is->write($prepend.$this->standardize($currentLine)); - } - } + if (false === $i) { + $lineLen += $size; + } else { + // 6 is the length of '=0D=0A'. + $lineLen = $size - strrpos($enc, '=0D=0A') - 6; + } + } + if (\strlen($currentLine)) { + $is->write($prepend.$this->standardize($currentLine)); + } + } - /** - * Get the name of this encoding scheme. - * Returns the string 'quoted-printable'. - * - * @return string - */ - public function getName() - { - return 'quoted-printable'; - } + /** + * Get the name of this encoding scheme. + * Returns the string 'quoted-printable'. + * + * @return string + */ + public function getName() + { + return 'quoted-printable'; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php index 7b9fb138c3a..f3ece43aecd 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php @@ -17,80 +17,80 @@ */ class Swift_Mime_ContentEncoder_QpContentEncoderProxy implements Swift_Mime_ContentEncoder { - /** - * @var Swift_Mime_ContentEncoder_QpContentEncoder - */ - private $safeEncoder; + /** + * @var Swift_Mime_ContentEncoder_QpContentEncoder + */ + private $safeEncoder; - /** - * @var Swift_Mime_ContentEncoder_NativeQpContentEncoder - */ - private $nativeEncoder; + /** + * @var Swift_Mime_ContentEncoder_NativeQpContentEncoder + */ + private $nativeEncoder; - /** - * @var string|null - */ - private $charset; + /** + * @var string|null + */ + private $charset; - /** - * Constructor. - * - * @param string|null $charset - */ - public function __construct(Swift_Mime_ContentEncoder_QpContentEncoder $safeEncoder, Swift_Mime_ContentEncoder_NativeQpContentEncoder $nativeEncoder, $charset) - { - $this->safeEncoder = $safeEncoder; - $this->nativeEncoder = $nativeEncoder; - $this->charset = $charset; - } + /** + * Constructor. + * + * @param string|null $charset + */ + public function __construct(Swift_Mime_ContentEncoder_QpContentEncoder $safeEncoder, Swift_Mime_ContentEncoder_NativeQpContentEncoder $nativeEncoder, $charset) + { + $this->safeEncoder = $safeEncoder; + $this->nativeEncoder = $nativeEncoder; + $this->charset = $charset; + } - /** - * Make a deep copy of object. - */ - public function __clone() - { - $this->safeEncoder = clone $this->safeEncoder; - $this->nativeEncoder = clone $this->nativeEncoder; - } + /** + * Make a deep copy of object. + */ + public function __clone() + { + $this->safeEncoder = clone $this->safeEncoder; + $this->nativeEncoder = clone $this->nativeEncoder; + } - /** - * {@inheritdoc} - */ - public function charsetChanged($charset) - { - $this->charset = $charset; - $this->safeEncoder->charsetChanged($charset); - } + /** + * {@inheritdoc} + */ + public function charsetChanged($charset) + { + $this->charset = $charset; + $this->safeEncoder->charsetChanged($charset); + } - /** - * {@inheritdoc} - */ - public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) - { - $this->getEncoder()->encodeByteStream($os, $is, $firstLineOffset, $maxLineLength); - } + /** + * {@inheritdoc} + */ + public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) + { + $this->getEncoder()->encodeByteStream($os, $is, $firstLineOffset, $maxLineLength); + } - /** - * {@inheritdoc} - */ - public function getName() - { - return 'quoted-printable'; - } + /** + * {@inheritdoc} + */ + public function getName() + { + return 'quoted-printable'; + } - /** - * {@inheritdoc} - */ - public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) - { - return $this->getEncoder()->encodeString($string, $firstLineOffset, $maxLineLength); - } + /** + * {@inheritdoc} + */ + public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) + { + return $this->getEncoder()->encodeString($string, $firstLineOffset, $maxLineLength); + } - /** - * @return Swift_Mime_ContentEncoder - */ - private function getEncoder() - { - return 'utf-8' === $this->charset ? $this->nativeEncoder : $this->safeEncoder; - } + /** + * @return Swift_Mime_ContentEncoder + */ + private function getEncoder() + { + return 'utf-8' === $this->charset ? $this->nativeEncoder : $this->safeEncoder; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/RawContentEncoder.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/RawContentEncoder.php index 99d09c56478..870e7f41a93 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/RawContentEncoder.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/RawContentEncoder.php @@ -19,47 +19,47 @@ */ class Swift_Mime_ContentEncoder_RawContentEncoder implements Swift_Mime_ContentEncoder { - /** - * Encode a given string to produce an encoded string. - * - * @param string $string - * @param int $firstLineOffset ignored - * @param int $maxLineLength ignored - * - * @return string - */ - public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) - { - return $string; - } + /** + * Encode a given string to produce an encoded string. + * + * @param string $string + * @param int $firstLineOffset ignored + * @param int $maxLineLength ignored + * + * @return string + */ + public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) + { + return $string; + } - /** - * Encode stream $in to stream $out. - * - * @param int $firstLineOffset ignored - * @param int $maxLineLength ignored - */ - public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) - { - while (false !== ($bytes = $os->read(8192))) { - $is->write($bytes); - } - } + /** + * Encode stream $in to stream $out. + * + * @param int $firstLineOffset ignored + * @param int $maxLineLength ignored + */ + public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) + { + while (false !== ($bytes = $os->read(8192))) { + $is->write($bytes); + } + } - /** - * Get the name of this encoding scheme. - * - * @return string - */ - public function getName() - { - return 'raw'; - } + /** + * Get the name of this encoding scheme. + * + * @return string + */ + public function getName() + { + return 'raw'; + } - /** - * Not used. - */ - public function charsetChanged($charset) - { - } + /** + * Not used. + */ + public function charsetChanged($charset) + { + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/EmbeddedFile.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/EmbeddedFile.php index 7b65f781465..42a51770c76 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/EmbeddedFile.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/EmbeddedFile.php @@ -15,27 +15,27 @@ */ class Swift_Mime_EmbeddedFile extends Swift_Mime_Attachment { - /** - * Creates a new Attachment with $headers and $encoder. - * - * @param array $mimeTypes optional - */ - public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator, $mimeTypes = []) - { - parent::__construct($headers, $encoder, $cache, $idGenerator, $mimeTypes); - $this->setDisposition('inline'); - $this->setId($this->getId()); - } + /** + * Creates a new Attachment with $headers and $encoder. + * + * @param array $mimeTypes optional + */ + public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator, $mimeTypes = []) + { + parent::__construct($headers, $encoder, $cache, $idGenerator, $mimeTypes); + $this->setDisposition('inline'); + $this->setId($this->getId()); + } - /** - * Get the nesting level of this EmbeddedFile. - * - * Returns {@see LEVEL_RELATED}. - * - * @return int - */ - public function getNestingLevel() - { - return self::LEVEL_RELATED; - } + /** + * Get the nesting level of this EmbeddedFile. + * + * Returns {@see LEVEL_RELATED}. + * + * @return int + */ + public function getNestingLevel() + { + return self::LEVEL_RELATED; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/EncodingObserver.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/EncodingObserver.php index 51915764259..1a952ece12c 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/EncodingObserver.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/EncodingObserver.php @@ -15,8 +15,8 @@ */ interface Swift_Mime_EncodingObserver { - /** - * Notify this observer that the observed entity's ContentEncoder has changed. - */ - public function encoderChanged(Swift_Mime_ContentEncoder $encoder); + /** + * Notify this observer that the observed entity's ContentEncoder has changed. + */ + public function encoderChanged(Swift_Mime_ContentEncoder $encoder); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Header.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Header.php index e2559ffba52..ca712f35aa0 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Header.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Header.php @@ -15,79 +15,79 @@ */ interface Swift_Mime_Header { - /** Text headers */ - const TYPE_TEXT = 2; + /** Text headers */ + const TYPE_TEXT = 2; - /** headers (text + params) */ - const TYPE_PARAMETERIZED = 6; + /** headers (text + params) */ + const TYPE_PARAMETERIZED = 6; - /** Mailbox and address headers */ - const TYPE_MAILBOX = 8; + /** Mailbox and address headers */ + const TYPE_MAILBOX = 8; - /** Date and time headers */ - const TYPE_DATE = 16; + /** Date and time headers */ + const TYPE_DATE = 16; - /** Identification headers */ - const TYPE_ID = 32; + /** Identification headers */ + const TYPE_ID = 32; - /** Address path headers */ - const TYPE_PATH = 64; + /** Address path headers */ + const TYPE_PATH = 64; - /** - * Get the type of Header that this instance represents. - * - * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX - * @see TYPE_DATE, TYPE_ID, TYPE_PATH - * - * @return int - */ - public function getFieldType(); + /** + * Get the type of Header that this instance represents. + * + * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX + * @see TYPE_DATE, TYPE_ID, TYPE_PATH + * + * @return int + */ + public function getFieldType(); - /** - * Set the model for the field body. - * - * The actual types needed will vary depending upon the type of Header. - * - * @param mixed $model - */ - public function setFieldBodyModel($model); + /** + * Set the model for the field body. + * + * The actual types needed will vary depending upon the type of Header. + * + * @param mixed $model + */ + public function setFieldBodyModel($model); - /** - * Set the charset used when rendering the Header. - * - * @param string $charset - */ - public function setCharset($charset); + /** + * Set the charset used when rendering the Header. + * + * @param string $charset + */ + public function setCharset($charset); - /** - * Get the model for the field body. - * - * The return type depends on the specifics of the Header. - * - * @return mixed - */ - public function getFieldBodyModel(); + /** + * Get the model for the field body. + * + * The return type depends on the specifics of the Header. + * + * @return mixed + */ + public function getFieldBodyModel(); - /** - * Get the name of this header (e.g. Subject). - * - * The name is an identifier and as such will be immutable. - * - * @return string - */ - public function getFieldName(); + /** + * Get the name of this header (e.g. Subject). + * + * The name is an identifier and as such will be immutable. + * + * @return string + */ + public function getFieldName(); - /** - * Get the field body, prepared for folding into a final header value. - * - * @return string - */ - public function getFieldBody(); + /** + * Get the field body, prepared for folding into a final header value. + * + * @return string + */ + public function getFieldBody(); - /** - * Get this Header rendered as a compliant string, including trailing CRLF. - * - * @return string - */ - public function toString(); + /** + * Get this Header rendered as a compliant string, including trailing CRLF. + * + * @return string + */ + public function toString(); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/Base64HeaderEncoder.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/Base64HeaderEncoder.php index 6bcb1e4e8f8..21c8aaabfea 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/Base64HeaderEncoder.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/Base64HeaderEncoder.php @@ -15,41 +15,41 @@ */ class Swift_Mime_HeaderEncoder_Base64HeaderEncoder extends Swift_Encoder_Base64Encoder implements Swift_Mime_HeaderEncoder { - /** - * Get the name of this encoding scheme. - * Returns the string 'B'. - * - * @return string - */ - public function getName() - { - return 'B'; - } + /** + * Get the name of this encoding scheme. + * Returns the string 'B'. + * + * @return string + */ + public function getName() + { + return 'B'; + } - /** - * Takes an unencoded string and produces a Base64 encoded string from it. - * - * If the charset is iso-2022-jp, it uses mb_encode_mimeheader instead of - * default encodeString, otherwise pass to the parent method. - * - * @param string $string string to encode - * @param int $firstLineOffset - * @param int $maxLineLength optional, 0 indicates the default of 76 bytes - * @param string $charset - * - * @return string - */ - public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0, $charset = 'utf-8') - { - if ('iso-2022-jp' === strtolower($charset ?? '')) { - $old = mb_internal_encoding(); - mb_internal_encoding('utf-8'); - $newstring = mb_encode_mimeheader($string, $charset, $this->getName(), "\r\n"); - mb_internal_encoding($old); + /** + * Takes an unencoded string and produces a Base64 encoded string from it. + * + * If the charset is iso-2022-jp, it uses mb_encode_mimeheader instead of + * default encodeString, otherwise pass to the parent method. + * + * @param string $string string to encode + * @param int $firstLineOffset + * @param int $maxLineLength optional, 0 indicates the default of 76 bytes + * @param string $charset + * + * @return string + */ + public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0, $charset = 'utf-8') + { + if ('iso-2022-jp' === strtolower($charset ?? '')) { + $old = mb_internal_encoding(); + mb_internal_encoding('utf-8'); + $newstring = mb_encode_mimeheader($string, $charset, $this->getName(), "\r\n"); + mb_internal_encoding($old); - return $newstring; - } + return $newstring; + } - return parent::encodeString($string, $firstLineOffset, $maxLineLength); - } + return parent::encodeString($string, $firstLineOffset, $maxLineLength); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php index 6cfeb3b9285..378c4805057 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php @@ -15,51 +15,51 @@ */ class Swift_Mime_HeaderEncoder_QpHeaderEncoder extends Swift_Encoder_QpEncoder implements Swift_Mime_HeaderEncoder { - /** - * Creates a new QpHeaderEncoder for the given CharacterStream. - * - * @param Swift_CharacterStream $charStream to use for reading characters - */ - public function __construct(Swift_CharacterStream $charStream) - { - parent::__construct($charStream); - } + /** + * Creates a new QpHeaderEncoder for the given CharacterStream. + * + * @param Swift_CharacterStream $charStream to use for reading characters + */ + public function __construct(Swift_CharacterStream $charStream) + { + parent::__construct($charStream); + } - protected function initSafeMap() - { - foreach (array_merge( - range(0x61, 0x7A), range(0x41, 0x5A), - range(0x30, 0x39), [0x20, 0x21, 0x2A, 0x2B, 0x2D, 0x2F] - ) as $byte) { - $this->safeMap[$byte] = \chr($byte); - } - } + protected function initSafeMap() + { + foreach (array_merge( + range(0x61, 0x7A), range(0x41, 0x5A), + range(0x30, 0x39), [0x20, 0x21, 0x2A, 0x2B, 0x2D, 0x2F] + ) as $byte) { + $this->safeMap[$byte] = \chr($byte); + } + } - /** - * Get the name of this encoding scheme. - * - * Returns the string 'Q'. - * - * @return string - */ - public function getName() - { - return 'Q'; - } + /** + * Get the name of this encoding scheme. + * + * Returns the string 'Q'. + * + * @return string + */ + public function getName() + { + return 'Q'; + } - /** - * Takes an unencoded string and produces a QP encoded string from it. - * - * @param string $string string to encode - * @param int $firstLineOffset optional - * @param int $maxLineLength optional, 0 indicates the default of 76 chars - * - * @return string - */ - public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) - { - return str_replace([' ', '=20', "=\r\n"], ['_', '_', "\r\n"], - parent::encodeString($string, $firstLineOffset, $maxLineLength) - ); - } + /** + * Takes an unencoded string and produces a QP encoded string from it. + * + * @param string $string string to encode + * @param int $firstLineOffset optional + * @param int $maxLineLength optional, 0 indicates the default of 76 chars + * + * @return string + */ + public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) + { + return str_replace([' ', '=20', "=\r\n"], ['_', '_', "\r\n"], + parent::encodeString($string, $firstLineOffset, $maxLineLength) + ); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/AbstractHeader.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/AbstractHeader.php index 344a2b4a7a7..25740d1155c 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/AbstractHeader.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/AbstractHeader.php @@ -15,472 +15,472 @@ */ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header { - const PHRASE_PATTERN = '(?:(?:(?:(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))*(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))|(?:(?:[ \t]*(?:\r\n))?[ \t])))?[a-zA-Z0-9!#\$%&\'\*\+\-\/=\?\^_`\{\}\|~]+(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))*(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))|(?:(?:[ \t]*(?:\r\n))?[ \t])))?)|(?:(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))*(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))|(?:(?:[ \t]*(?:\r\n))?[ \t])))?"((?:(?:[ \t]*(?:\r\n))?[ \t])?(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21\x23-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])))*(?:(?:[ \t]*(?:\r\n))?[ \t])?"(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))*(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))|(?:(?:[ \t]*(?:\r\n))?[ \t])))?))+?)'; + const PHRASE_PATTERN = '(?:(?:(?:(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))*(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))|(?:(?:[ \t]*(?:\r\n))?[ \t])))?[a-zA-Z0-9!#\$%&\'\*\+\-\/=\?\^_`\{\}\|~]+(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))*(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))|(?:(?:[ \t]*(?:\r\n))?[ \t])))?)|(?:(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))*(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))|(?:(?:[ \t]*(?:\r\n))?[ \t])))?"((?:(?:[ \t]*(?:\r\n))?[ \t])?(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21\x23-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])))*(?:(?:[ \t]*(?:\r\n))?[ \t])?"(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))*(?:(?:(?:(?:[ \t]*(?:\r\n))?[ \t])?(\((?:(?:(?:[ \t]*(?:\r\n))?[ \t])|(?:(?:[\x01-\x08\x0B\x0C\x0E-\x19\x7F]|[\x21-\x27\x2A-\x5B\x5D-\x7E])|(?:\\[\x00-\x08\x0B\x0C\x0E-\x7F])|(?1)))*(?:(?:[ \t]*(?:\r\n))?[ \t])?\)))|(?:(?:[ \t]*(?:\r\n))?[ \t])))?))+?)'; - /** - * The name of this Header. - * - * @var string - */ - private $name; + /** + * The name of this Header. + * + * @var string + */ + private $name; - /** - * The Encoder used to encode this Header. - * - * @var Swift_Encoder - */ - private $encoder; + /** + * The Encoder used to encode this Header. + * + * @var Swift_Encoder + */ + private $encoder; - /** - * The maximum length of a line in the header. - * - * @var int - */ - private $lineLength = 78; + /** + * The maximum length of a line in the header. + * + * @var int + */ + private $lineLength = 78; - /** - * The language used in this Header. - * - * @var string - */ - private $lang; + /** + * The language used in this Header. + * + * @var string + */ + private $lang; - /** - * The character set of the text in this Header. - * - * @var string - */ - private $charset = 'utf-8'; + /** + * The character set of the text in this Header. + * + * @var string + */ + private $charset = 'utf-8'; - /** - * The value of this Header, cached. - * - * @var string - */ - private $cachedValue = null; + /** + * The value of this Header, cached. + * + * @var string + */ + private $cachedValue = null; - /** - * Set the character set used in this Header. - * - * @param string $charset - */ - public function setCharset($charset) - { - $this->clearCachedValueIf($charset != $this->charset); - $this->charset = $charset; - if (isset($this->encoder)) { - $this->encoder->charsetChanged($charset); - } - } + /** + * Set the character set used in this Header. + * + * @param string $charset + */ + public function setCharset($charset) + { + $this->clearCachedValueIf($charset != $this->charset); + $this->charset = $charset; + if (isset($this->encoder)) { + $this->encoder->charsetChanged($charset); + } + } - /** - * Get the character set used in this Header. - * - * @return string - */ - public function getCharset() - { - return $this->charset; - } + /** + * Get the character set used in this Header. + * + * @return string + */ + public function getCharset() + { + return $this->charset; + } - /** - * Set the language used in this Header. - * - * For example, for US English, 'en-us'. - * This can be unspecified. - * - * @param string $lang - */ - public function setLanguage($lang) - { - $this->clearCachedValueIf($this->lang != $lang); - $this->lang = $lang; - } + /** + * Set the language used in this Header. + * + * For example, for US English, 'en-us'. + * This can be unspecified. + * + * @param string $lang + */ + public function setLanguage($lang) + { + $this->clearCachedValueIf($this->lang != $lang); + $this->lang = $lang; + } - /** - * Get the language used in this Header. - * - * @return string - */ - public function getLanguage() - { - return $this->lang; - } + /** + * Get the language used in this Header. + * + * @return string + */ + public function getLanguage() + { + return $this->lang; + } - /** - * Set the encoder used for encoding the header. - */ - public function setEncoder(Swift_Mime_HeaderEncoder $encoder) - { - $this->encoder = $encoder; - $this->setCachedValue(null); - } + /** + * Set the encoder used for encoding the header. + */ + public function setEncoder(Swift_Mime_HeaderEncoder $encoder) + { + $this->encoder = $encoder; + $this->setCachedValue(null); + } - /** - * Get the encoder used for encoding this Header. - * - * @return Swift_Mime_HeaderEncoder - */ - public function getEncoder() - { - return $this->encoder; - } + /** + * Get the encoder used for encoding this Header. + * + * @return Swift_Mime_HeaderEncoder + */ + public function getEncoder() + { + return $this->encoder; + } - /** - * Get the name of this header (e.g. charset). - * - * @return string - */ - public function getFieldName() - { - return $this->name; - } + /** + * Get the name of this header (e.g. charset). + * + * @return string + */ + public function getFieldName() + { + return $this->name; + } - /** - * Set the maximum length of lines in the header (excluding EOL). - * - * @param int $lineLength - */ - public function setMaxLineLength($lineLength) - { - $this->clearCachedValueIf($this->lineLength != $lineLength); - $this->lineLength = $lineLength; - } + /** + * Set the maximum length of lines in the header (excluding EOL). + * + * @param int $lineLength + */ + public function setMaxLineLength($lineLength) + { + $this->clearCachedValueIf($this->lineLength != $lineLength); + $this->lineLength = $lineLength; + } - /** - * Get the maximum permitted length of lines in this Header. - * - * @return int - */ - public function getMaxLineLength() - { - return $this->lineLength; - } + /** + * Get the maximum permitted length of lines in this Header. + * + * @return int + */ + public function getMaxLineLength() + { + return $this->lineLength; + } - /** - * Get this Header rendered as a RFC 2822 compliant string. - * - * @return string - * - * @throws Swift_RfcComplianceException - */ - public function toString() - { - return $this->tokensToString($this->toTokens()); - } + /** + * Get this Header rendered as a RFC 2822 compliant string. + * + * @return string + * + * @throws Swift_RfcComplianceException + */ + public function toString() + { + return $this->tokensToString($this->toTokens()); + } - /** - * Returns a string representation of this object. - * - * @return string - * - * @see toString() - */ - public function __toString() - { - return $this->toString(); - } + /** + * Returns a string representation of this object. + * + * @return string + * + * @see toString() + */ + public function __toString() + { + return $this->toString(); + } - /** - * Set the name of this Header field. - * - * @param string $name - */ - protected function setFieldName($name) - { - $this->name = $name; - } + /** + * Set the name of this Header field. + * + * @param string $name + */ + protected function setFieldName($name) + { + $this->name = $name; + } - /** - * Produces a compliant, formatted RFC 2822 'phrase' based on the string given. - * - * @param string $string as displayed - * @param string $charset of the text - * @param bool $shorten the first line to make remove for header name - * - * @return string - */ - protected function createPhrase(Swift_Mime_Header $header, $string, $charset, Swift_Mime_HeaderEncoder $encoder = null, $shorten = false) - { - // Treat token as exactly what was given - $phraseStr = $string; - // If it's not valid + /** + * Produces a compliant, formatted RFC 2822 'phrase' based on the string given. + * + * @param string $string as displayed + * @param string $charset of the text + * @param bool $shorten the first line to make remove for header name + * + * @return string + */ + protected function createPhrase(Swift_Mime_Header $header, $string, $charset, Swift_Mime_HeaderEncoder $encoder = null, $shorten = false) + { + // Treat token as exactly what was given + $phraseStr = $string; + // If it's not valid - if (!preg_match('/^'.self::PHRASE_PATTERN.'$/D', $phraseStr)) { - // .. but it is just ascii text, try escaping some characters - // and make it a quoted-string - if (preg_match('/^[\x00-\x08\x0B\x0C\x0E-\x7F]*$/D', $phraseStr)) { - $phraseStr = $this->escapeSpecials($phraseStr, ['"']); - $phraseStr = '"'.$phraseStr.'"'; - } else { - // ... otherwise it needs encoding - // Determine space remaining on line if first line - if ($shorten) { - $usedLength = \strlen($header->getFieldName().': '); - } else { - $usedLength = 0; - } - $phraseStr = $this->encodeWords($header, $string, $usedLength); - } - } + if (!preg_match('/^'.self::PHRASE_PATTERN.'$/D', $phraseStr)) { + // .. but it is just ascii text, try escaping some characters + // and make it a quoted-string + if (preg_match('/^[\x00-\x08\x0B\x0C\x0E-\x7F]*$/D', $phraseStr)) { + $phraseStr = $this->escapeSpecials($phraseStr, ['"']); + $phraseStr = '"'.$phraseStr.'"'; + } else { + // ... otherwise it needs encoding + // Determine space remaining on line if first line + if ($shorten) { + $usedLength = \strlen($header->getFieldName().': '); + } else { + $usedLength = 0; + } + $phraseStr = $this->encodeWords($header, $string, $usedLength); + } + } - return $phraseStr; - } + return $phraseStr; + } - /** - * Escape special characters in a string (convert to quoted-pairs). - * - * @param string $token - * @param string[] $include additional chars to escape - * - * @return string - */ - private function escapeSpecials($token, $include = []) - { - foreach (array_merge(['\\'], $include) as $char) { - $token = str_replace($char, '\\'.$char, $token); - } + /** + * Escape special characters in a string (convert to quoted-pairs). + * + * @param string $token + * @param string[] $include additional chars to escape + * + * @return string + */ + private function escapeSpecials($token, $include = []) + { + foreach (array_merge(['\\'], $include) as $char) { + $token = str_replace($char, '\\'.$char, $token); + } - return $token; - } + return $token; + } - /** - * Encode needed word tokens within a string of input. - * - * @param string $input - * @param string $usedLength optional - * - * @return string - */ - protected function encodeWords(Swift_Mime_Header $header, $input, $usedLength = -1) - { - $value = ''; + /** + * Encode needed word tokens within a string of input. + * + * @param string $input + * @param string $usedLength optional + * + * @return string + */ + protected function encodeWords(Swift_Mime_Header $header, $input, $usedLength = -1) + { + $value = ''; - $tokens = $this->getEncodableWordTokens($input); + $tokens = $this->getEncodableWordTokens($input); - foreach ($tokens as $token) { - // See RFC 2822, Sect 2.2 (really 2.2 ??) - if ($this->tokenNeedsEncoding($token)) { - // Don't encode starting WSP - $firstChar = substr($token, 0, 1); - switch ($firstChar) { - case ' ': - case "\t": - $value .= $firstChar; - $token = substr($token, 1); - } + foreach ($tokens as $token) { + // See RFC 2822, Sect 2.2 (really 2.2 ??) + if ($this->tokenNeedsEncoding($token)) { + // Don't encode starting WSP + $firstChar = substr($token, 0, 1); + switch ($firstChar) { + case ' ': + case "\t": + $value .= $firstChar; + $token = substr($token, 1); + } - if (-1 == $usedLength) { - $usedLength = \strlen($header->getFieldName().': ') + \strlen($value); - } - $value .= $this->getTokenAsEncodedWord($token, $usedLength); + if (-1 == $usedLength) { + $usedLength = \strlen($header->getFieldName().': ') + \strlen($value); + } + $value .= $this->getTokenAsEncodedWord($token, $usedLength); - $header->setMaxLineLength(76); // Forcefully override - } else { - $value .= $token; - } - } + $header->setMaxLineLength(76); // Forcefully override + } else { + $value .= $token; + } + } - return $value; - } + return $value; + } - /** - * Test if a token needs to be encoded or not. - * - * @param string $token - * - * @return bool - */ - protected function tokenNeedsEncoding($token) - { - return preg_match('~[\x00-\x08\x10-\x19\x7F-\xFF\r\n]~', $token); - } + /** + * Test if a token needs to be encoded or not. + * + * @param string $token + * + * @return bool + */ + protected function tokenNeedsEncoding($token) + { + return preg_match('~[\x00-\x08\x10-\x19\x7F-\xFF\r\n]~', $token); + } - /** - * Splits a string into tokens in blocks of words which can be encoded quickly. - * - * @param string $string - * - * @return string[] - */ - protected function getEncodableWordTokens($string) - { - $tokens = []; + /** + * Splits a string into tokens in blocks of words which can be encoded quickly. + * + * @param string $string + * + * @return string[] + */ + protected function getEncodableWordTokens($string) + { + $tokens = []; - $encodedToken = ''; - // Split at all whitespace boundaries - foreach (preg_split('~(?=[\t ])~', $string ?? '') as $token) { - if ($this->tokenNeedsEncoding($token)) { - $encodedToken .= $token; - } else { - if (\strlen($encodedToken) > 0) { - $tokens[] = $encodedToken; - $encodedToken = ''; - } - $tokens[] = $token; - } - } - if (\strlen($encodedToken)) { - $tokens[] = $encodedToken; - } + $encodedToken = ''; + // Split at all whitespace boundaries + foreach (preg_split('~(?=[\t ])~', $string ?? '') as $token) { + if ($this->tokenNeedsEncoding($token)) { + $encodedToken .= $token; + } else { + if (\strlen($encodedToken) > 0) { + $tokens[] = $encodedToken; + $encodedToken = ''; + } + $tokens[] = $token; + } + } + if (\strlen($encodedToken)) { + $tokens[] = $encodedToken; + } - return $tokens; - } + return $tokens; + } - /** - * Get a token as an encoded word for safe insertion into headers. - * - * @param string $token token to encode - * @param int $firstLineOffset optional - * - * @return string - */ - protected function getTokenAsEncodedWord($token, $firstLineOffset = 0) - { - // Adjust $firstLineOffset to account for space needed for syntax - $charsetDecl = $this->charset; - if (isset($this->lang)) { - $charsetDecl .= '*'.$this->lang; - } - $encodingWrapperLength = \strlen( - '=?'.$charsetDecl.'?'.$this->encoder->getName().'??=' - ); + /** + * Get a token as an encoded word for safe insertion into headers. + * + * @param string $token token to encode + * @param int $firstLineOffset optional + * + * @return string + */ + protected function getTokenAsEncodedWord($token, $firstLineOffset = 0) + { + // Adjust $firstLineOffset to account for space needed for syntax + $charsetDecl = $this->charset; + if (isset($this->lang)) { + $charsetDecl .= '*'.$this->lang; + } + $encodingWrapperLength = \strlen( + '=?'.$charsetDecl.'?'.$this->encoder->getName().'??=' + ); - if ($firstLineOffset >= 75) { - //Does this logic need to be here? - $firstLineOffset = 0; - } + if ($firstLineOffset >= 75) { + //Does this logic need to be here? + $firstLineOffset = 0; + } - $encodedTextLines = explode("\r\n", - $this->encoder->encodeString( - $token, $firstLineOffset, 75 - $encodingWrapperLength, $this->charset - ) ?? '' - ); + $encodedTextLines = explode("\r\n", + $this->encoder->encodeString( + $token, $firstLineOffset, 75 - $encodingWrapperLength, $this->charset + ) ?? '' + ); - if ('iso-2022-jp' !== strtolower($this->charset ?? '')) { - // special encoding for iso-2022-jp using mb_encode_mimeheader - foreach ($encodedTextLines as $lineNum => $line) { - $encodedTextLines[$lineNum] = '=?'.$charsetDecl. - '?'.$this->encoder->getName(). - '?'.$line.'?='; - } - } + if ('iso-2022-jp' !== strtolower($this->charset ?? '')) { + // special encoding for iso-2022-jp using mb_encode_mimeheader + foreach ($encodedTextLines as $lineNum => $line) { + $encodedTextLines[$lineNum] = '=?'.$charsetDecl. + '?'.$this->encoder->getName(). + '?'.$line.'?='; + } + } - return implode("\r\n ", $encodedTextLines); - } + return implode("\r\n ", $encodedTextLines); + } - /** - * Generates tokens from the given string which include CRLF as individual tokens. - * - * @param string $token - * - * @return string[] - */ - protected function generateTokenLines($token) - { - return preg_split('~(\r\n)~', $token ?? '', -1, PREG_SPLIT_DELIM_CAPTURE); - } + /** + * Generates tokens from the given string which include CRLF as individual tokens. + * + * @param string $token + * + * @return string[] + */ + protected function generateTokenLines($token) + { + return preg_split('~(\r\n)~', $token ?? '', -1, PREG_SPLIT_DELIM_CAPTURE); + } - /** - * Set a value into the cache. - * - * @param string $value - */ - protected function setCachedValue($value) - { - $this->cachedValue = $value; - } + /** + * Set a value into the cache. + * + * @param string $value + */ + protected function setCachedValue($value) + { + $this->cachedValue = $value; + } - /** - * Get the value in the cache. - * - * @return string - */ - protected function getCachedValue() - { - return $this->cachedValue; - } + /** + * Get the value in the cache. + * + * @return string + */ + protected function getCachedValue() + { + return $this->cachedValue; + } - /** - * Clear the cached value if $condition is met. - * - * @param bool $condition - */ - protected function clearCachedValueIf($condition) - { - if ($condition) { - $this->setCachedValue(null); - } - } + /** + * Clear the cached value if $condition is met. + * + * @param bool $condition + */ + protected function clearCachedValueIf($condition) + { + if ($condition) { + $this->setCachedValue(null); + } + } - /** - * Generate a list of all tokens in the final header. - * - * @param string $string The string to tokenize - * - * @return array An array of tokens as strings - */ - protected function toTokens($string = null) - { - if (null === $string) { - $string = $this->getFieldBody(); - } + /** + * Generate a list of all tokens in the final header. + * + * @param string $string The string to tokenize + * + * @return array An array of tokens as strings + */ + protected function toTokens($string = null) + { + if (null === $string) { + $string = $this->getFieldBody(); + } - $tokens = []; + $tokens = []; - // Generate atoms; split at all invisible boundaries followed by WSP - foreach (preg_split('~(?=[ \t])~', $string ?? '') as $token) { - $newTokens = $this->generateTokenLines($token); - foreach ($newTokens as $newToken) { - $tokens[] = $newToken; - } - } + // Generate atoms; split at all invisible boundaries followed by WSP + foreach (preg_split('~(?=[ \t])~', $string ?? '') as $token) { + $newTokens = $this->generateTokenLines($token); + foreach ($newTokens as $newToken) { + $tokens[] = $newToken; + } + } - return $tokens; - } + return $tokens; + } - /** - * Takes an array of tokens which appear in the header and turns them into - * an RFC 2822 compliant string, adding FWSP where needed. - * - * @param string[] $tokens - * - * @return string - */ - private function tokensToString(array $tokens) - { - $lineCount = 0; - $headerLines = []; - $headerLines[] = $this->name.': '; - $currentLine = &$headerLines[$lineCount++]; + /** + * Takes an array of tokens which appear in the header and turns them into + * an RFC 2822 compliant string, adding FWSP where needed. + * + * @param string[] $tokens + * + * @return string + */ + private function tokensToString(array $tokens) + { + $lineCount = 0; + $headerLines = []; + $headerLines[] = $this->name.': '; + $currentLine = &$headerLines[$lineCount++]; - // Build all tokens back into compliant header - foreach ($tokens as $i => $token) { - // Line longer than specified maximum or token was just a new line - if (("\r\n" == $token) || - ($i > 0 && \strlen($currentLine.$token) > $this->lineLength) - && 0 < \strlen($currentLine)) { - $headerLines[] = ''; - $currentLine = &$headerLines[$lineCount++]; - } + // Build all tokens back into compliant header + foreach ($tokens as $i => $token) { + // Line longer than specified maximum or token was just a new line + if (("\r\n" == $token) || + ($i > 0 && \strlen($currentLine.$token) > $this->lineLength) + && 0 < \strlen($currentLine)) { + $headerLines[] = ''; + $currentLine = &$headerLines[$lineCount++]; + } - // Append token to the line - if ("\r\n" != $token) { - $currentLine .= $token; - } - } + // Append token to the line + if ("\r\n" != $token) { + $currentLine .= $token; + } + } - // Implode with FWS (RFC 2822, 2.2.3) - return implode("\r\n", $headerLines)."\r\n"; - } + // Implode with FWS (RFC 2822, 2.2.3) + return implode("\r\n", $headerLines)."\r\n"; + } - /** - * Make a deep copy of object. - */ - public function __clone() - { - if ($this->encoder) { - $this->encoder = clone $this->encoder; - } - } + /** + * Make a deep copy of object. + */ + public function __clone() + { + if ($this->encoder) { + $this->encoder = clone $this->encoder; + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/DateHeader.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/DateHeader.php index fb83178a8b3..efe1dad6619 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/DateHeader.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/DateHeader.php @@ -15,99 +15,99 @@ */ class Swift_Mime_Headers_DateHeader extends Swift_Mime_Headers_AbstractHeader { - /** - * Date-time value of this Header. - * - * @var DateTimeImmutable - */ - private $dateTime; + /** + * Date-time value of this Header. + * + * @var DateTimeImmutable + */ + private $dateTime; - /** - * Creates a new DateHeader with $name. - * - * @param string $name of Header - */ - public function __construct($name) - { - $this->setFieldName($name); - } + /** + * Creates a new DateHeader with $name. + * + * @param string $name of Header + */ + public function __construct($name) + { + $this->setFieldName($name); + } - /** - * Get the type of Header that this instance represents. - * - * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX - * @see TYPE_DATE, TYPE_ID, TYPE_PATH - * - * @return int - */ - public function getFieldType() - { - return self::TYPE_DATE; - } + /** + * Get the type of Header that this instance represents. + * + * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX + * @see TYPE_DATE, TYPE_ID, TYPE_PATH + * + * @return int + */ + public function getFieldType() + { + return self::TYPE_DATE; + } - /** - * Set the model for the field body. - * - * @param DateTimeInterface $model - */ - public function setFieldBodyModel($model) - { - $this->setDateTime($model); - } + /** + * Set the model for the field body. + * + * @param DateTimeInterface $model + */ + public function setFieldBodyModel($model) + { + $this->setDateTime($model); + } - /** - * Get the model for the field body. - * - * @return DateTimeImmutable - */ - public function getFieldBodyModel() - { - return $this->getDateTime(); - } + /** + * Get the model for the field body. + * + * @return DateTimeImmutable + */ + public function getFieldBodyModel() + { + return $this->getDateTime(); + } - /** - * Get the date-time representing the Date in this Header. - * - * @return DateTimeImmutable - */ - public function getDateTime() - { - return $this->dateTime; - } + /** + * Get the date-time representing the Date in this Header. + * + * @return DateTimeImmutable + */ + public function getDateTime() + { + return $this->dateTime; + } - /** - * Set the date-time of the Date in this Header. - * - * If a DateTime instance is provided, it is converted to DateTimeImmutable. - */ - public function setDateTime(DateTimeInterface $dateTime) - { - $this->clearCachedValueIf($this->getCachedValue() != $dateTime->format(DateTime::RFC2822)); - if ($dateTime instanceof DateTime) { - $immutable = new DateTimeImmutable('@'.$dateTime->getTimestamp()); - $dateTime = $immutable->setTimezone($dateTime->getTimezone()); - } - $this->dateTime = $dateTime; - } + /** + * Set the date-time of the Date in this Header. + * + * If a DateTime instance is provided, it is converted to DateTimeImmutable. + */ + public function setDateTime(DateTimeInterface $dateTime) + { + $this->clearCachedValueIf($this->getCachedValue() != $dateTime->format(DateTime::RFC2822)); + if ($dateTime instanceof DateTime) { + $immutable = new DateTimeImmutable('@'.$dateTime->getTimestamp()); + $dateTime = $immutable->setTimezone($dateTime->getTimezone()); + } + $this->dateTime = $dateTime; + } - /** - * Get the string value of the body in this Header. - * - * This is not necessarily RFC 2822 compliant since folding white space will - * not be added at this stage (see {@link toString()} for that). - * - * @see toString() - * - * @return string - */ - public function getFieldBody() - { - if (!$this->getCachedValue()) { - if (isset($this->dateTime)) { - $this->setCachedValue($this->dateTime->format(DateTime::RFC2822)); - } - } + /** + * Get the string value of the body in this Header. + * + * This is not necessarily RFC 2822 compliant since folding white space will + * not be added at this stage (see {@link toString()} for that). + * + * @see toString() + * + * @return string + */ + public function getFieldBody() + { + if (!$this->getCachedValue()) { + if (isset($this->dateTime)) { + $this->setCachedValue($this->dateTime->format(DateTime::RFC2822)); + } + } - return $this->getCachedValue(); - } + return $this->getCachedValue(); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/IdentificationHeader.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/IdentificationHeader.php index cec31c83961..4fcdff418a7 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/IdentificationHeader.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/IdentificationHeader.php @@ -19,171 +19,171 @@ use Egulias\EmailValidator\Validation\RFCValidation; */ class Swift_Mime_Headers_IdentificationHeader extends Swift_Mime_Headers_AbstractHeader { - /** - * The IDs used in the value of this Header. - * - * This may hold multiple IDs or just a single ID. - * - * @var string[] - */ - private $ids = []; + /** + * The IDs used in the value of this Header. + * + * This may hold multiple IDs or just a single ID. + * + * @var string[] + */ + private $ids = []; - /** - * The strict EmailValidator. - * - * @var EmailValidator - */ - private $emailValidator; + /** + * The strict EmailValidator. + * + * @var EmailValidator + */ + private $emailValidator; - private $addressEncoder; + private $addressEncoder; - /** - * Creates a new IdentificationHeader with the given $name and $id. - * - * @param string $name - */ - public function __construct($name, EmailValidator $emailValidator, Swift_AddressEncoder $addressEncoder = null) - { - $this->setFieldName($name); - $this->emailValidator = $emailValidator; - $this->addressEncoder = $addressEncoder ?? new Swift_AddressEncoder_IdnAddressEncoder(); - } + /** + * Creates a new IdentificationHeader with the given $name and $id. + * + * @param string $name + */ + public function __construct($name, EmailValidator $emailValidator, Swift_AddressEncoder $addressEncoder = null) + { + $this->setFieldName($name); + $this->emailValidator = $emailValidator; + $this->addressEncoder = $addressEncoder ?? new Swift_AddressEncoder_IdnAddressEncoder(); + } - /** - * Get the type of Header that this instance represents. - * - * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX - * @see TYPE_DATE, TYPE_ID, TYPE_PATH - * - * @return int - */ - public function getFieldType() - { - return self::TYPE_ID; - } + /** + * Get the type of Header that this instance represents. + * + * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX + * @see TYPE_DATE, TYPE_ID, TYPE_PATH + * + * @return int + */ + public function getFieldType() + { + return self::TYPE_ID; + } - /** - * Set the model for the field body. - * - * This method takes a string ID, or an array of IDs. - * - * @param mixed $model - * - * @throws Swift_RfcComplianceException - */ - public function setFieldBodyModel($model) - { - $this->setId($model); - } + /** + * Set the model for the field body. + * + * This method takes a string ID, or an array of IDs. + * + * @param mixed $model + * + * @throws Swift_RfcComplianceException + */ + public function setFieldBodyModel($model) + { + $this->setId($model); + } - /** - * Get the model for the field body. - * - * This method returns an array of IDs - * - * @return array - */ - public function getFieldBodyModel() - { - return $this->getIds(); - } + /** + * Get the model for the field body. + * + * This method returns an array of IDs + * + * @return array + */ + public function getFieldBodyModel() + { + return $this->getIds(); + } - /** - * Set the ID used in the value of this header. - * - * @param string|array $id - * - * @throws Swift_RfcComplianceException - */ - public function setId($id) - { - $this->setIds(\is_array($id) ? $id : [$id]); - } + /** + * Set the ID used in the value of this header. + * + * @param string|array $id + * + * @throws Swift_RfcComplianceException + */ + public function setId($id) + { + $this->setIds(\is_array($id) ? $id : [$id]); + } - /** - * Get the ID used in the value of this Header. - * - * If multiple IDs are set only the first is returned. - * - * @return string - */ - public function getId() - { - if (\count($this->ids) > 0) { - return $this->ids[0]; - } - } + /** + * Get the ID used in the value of this Header. + * + * If multiple IDs are set only the first is returned. + * + * @return string + */ + public function getId() + { + if (\count($this->ids) > 0) { + return $this->ids[0]; + } + } - /** - * Set a collection of IDs to use in the value of this Header. - * - * @param string[] $ids - * - * @throws Swift_RfcComplianceException - */ - public function setIds(array $ids) - { - $actualIds = []; + /** + * Set a collection of IDs to use in the value of this Header. + * + * @param string[] $ids + * + * @throws Swift_RfcComplianceException + */ + public function setIds(array $ids) + { + $actualIds = []; - foreach ($ids as $id) { - $this->assertValidId($id); - $actualIds[] = $id; - } + foreach ($ids as $id) { + $this->assertValidId($id); + $actualIds[] = $id; + } - $this->clearCachedValueIf($this->ids != $actualIds); - $this->ids = $actualIds; - } + $this->clearCachedValueIf($this->ids != $actualIds); + $this->ids = $actualIds; + } - /** - * Get the list of IDs used in this Header. - * - * @return string[] - */ - public function getIds() - { - return $this->ids; - } + /** + * Get the list of IDs used in this Header. + * + * @return string[] + */ + public function getIds() + { + return $this->ids; + } - /** - * Get the string value of the body in this Header. - * - * This is not necessarily RFC 2822 compliant since folding white space will - * not be added at this stage (see {@see toString()} for that). - * - * @see toString() - * - * @throws Swift_RfcComplianceException - * - * @return string - */ - public function getFieldBody() - { - if (!$this->getCachedValue()) { - $angleAddrs = []; + /** + * Get the string value of the body in this Header. + * + * This is not necessarily RFC 2822 compliant since folding white space will + * not be added at this stage (see {@see toString()} for that). + * + * @see toString() + * + * @throws Swift_RfcComplianceException + * + * @return string + */ + public function getFieldBody() + { + if (!$this->getCachedValue()) { + $angleAddrs = []; - foreach ($this->ids as $id) { - $angleAddrs[] = '<'.$this->addressEncoder->encodeString($id).'>'; - } + foreach ($this->ids as $id) { + $angleAddrs[] = '<'.$this->addressEncoder->encodeString($id).'>'; + } - $this->setCachedValue(implode(' ', $angleAddrs)); - } + $this->setCachedValue(implode(' ', $angleAddrs)); + } - return $this->getCachedValue(); - } + return $this->getCachedValue(); + } - /** - * Throws an Exception if the id passed does not comply with RFC 2822. - * - * @param string $id - * - * @throws Swift_RfcComplianceException - */ - private function assertValidId($id) - { - $emailValidation = class_exists(MessageIDValidation::class) ? new MessageIDValidation() : new RFCValidation(); + /** + * Throws an Exception if the id passed does not comply with RFC 2822. + * + * @param string $id + * + * @throws Swift_RfcComplianceException + */ + private function assertValidId($id) + { + $emailValidation = class_exists(MessageIDValidation::class) ? new MessageIDValidation() : new RFCValidation(); - if (!$this->emailValidator->isValid($id, $emailValidation)) { - throw new Swift_RfcComplianceException('Invalid ID given <'.$id.'>'); - } - } + if (!$this->emailValidator->isValid($id, $emailValidation)) { + throw new Swift_RfcComplianceException('Invalid ID given <'.$id.'>'); + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php index febc31332dd..ddd5e8cffb1 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php @@ -18,341 +18,341 @@ use Egulias\EmailValidator\Validation\RFCValidation; */ class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader { - /** - * The mailboxes used in this Header. - * - * @var string[] - */ - private $mailboxes = []; + /** + * The mailboxes used in this Header. + * + * @var string[] + */ + private $mailboxes = []; - /** - * The strict EmailValidator. - * - * @var EmailValidator - */ - private $emailValidator; + /** + * The strict EmailValidator. + * + * @var EmailValidator + */ + private $emailValidator; - private $addressEncoder; + private $addressEncoder; - /** - * Creates a new MailboxHeader with $name. - * - * @param string $name of Header - */ - public function __construct($name, Swift_Mime_HeaderEncoder $encoder, EmailValidator $emailValidator, Swift_AddressEncoder $addressEncoder = null) - { - $this->setFieldName($name); - $this->setEncoder($encoder); - $this->emailValidator = $emailValidator; - $this->addressEncoder = $addressEncoder ?? new Swift_AddressEncoder_IdnAddressEncoder(); - } + /** + * Creates a new MailboxHeader with $name. + * + * @param string $name of Header + */ + public function __construct($name, Swift_Mime_HeaderEncoder $encoder, EmailValidator $emailValidator, Swift_AddressEncoder $addressEncoder = null) + { + $this->setFieldName($name); + $this->setEncoder($encoder); + $this->emailValidator = $emailValidator; + $this->addressEncoder = $addressEncoder ?? new Swift_AddressEncoder_IdnAddressEncoder(); + } - /** - * Get the type of Header that this instance represents. - * - * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX - * @see TYPE_DATE, TYPE_ID, TYPE_PATH - * - * @return int - */ - public function getFieldType() - { - return self::TYPE_MAILBOX; - } + /** + * Get the type of Header that this instance represents. + * + * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX + * @see TYPE_DATE, TYPE_ID, TYPE_PATH + * + * @return int + */ + public function getFieldType() + { + return self::TYPE_MAILBOX; + } - /** - * Set the model for the field body. - * - * This method takes a string, or an array of addresses. - * - * @param mixed $model - * - * @throws Swift_RfcComplianceException - */ - public function setFieldBodyModel($model) - { - $this->setNameAddresses($model); - } + /** + * Set the model for the field body. + * + * This method takes a string, or an array of addresses. + * + * @param mixed $model + * + * @throws Swift_RfcComplianceException + */ + public function setFieldBodyModel($model) + { + $this->setNameAddresses($model); + } - /** - * Get the model for the field body. - * - * This method returns an associative array like {@link getNameAddresses()} - * - * @throws Swift_RfcComplianceException - * - * @return array - */ - public function getFieldBodyModel() - { - return $this->getNameAddresses(); - } + /** + * Get the model for the field body. + * + * This method returns an associative array like {@link getNameAddresses()} + * + * @throws Swift_RfcComplianceException + * + * @return array + */ + public function getFieldBodyModel() + { + return $this->getNameAddresses(); + } - /** - * Set a list of mailboxes to be shown in this Header. - * - * The mailboxes can be a simple array of addresses, or an array of - * key=>value pairs where (email => personalName). - * Example: - * - * setNameAddresses(array( - * 'chris@swiftmailer.org' => 'Chris Corbyn', - * 'mark@swiftmailer.org' //No associated personal name - * )); - * ?> - * - * - * @see __construct() - * @see setAddresses() - * @see setValue() - * - * @param string|string[] $mailboxes - * - * @throws Swift_RfcComplianceException - */ - public function setNameAddresses($mailboxes) - { - $this->mailboxes = $this->normalizeMailboxes((array) $mailboxes); - $this->setCachedValue(null); //Clear any cached value - } + /** + * Set a list of mailboxes to be shown in this Header. + * + * The mailboxes can be a simple array of addresses, or an array of + * key=>value pairs where (email => personalName). + * Example: + * + * setNameAddresses(array( + * 'chris@swiftmailer.org' => 'Chris Corbyn', + * 'mark@swiftmailer.org' //No associated personal name + * )); + * ?> + * + * + * @see __construct() + * @see setAddresses() + * @see setValue() + * + * @param string|string[] $mailboxes + * + * @throws Swift_RfcComplianceException + */ + public function setNameAddresses($mailboxes) + { + $this->mailboxes = $this->normalizeMailboxes((array) $mailboxes); + $this->setCachedValue(null); //Clear any cached value + } - /** - * Get the full mailbox list of this Header as an array of valid RFC 2822 strings. - * - * Example: - * - * 'Chris Corbyn', - * 'mark@swiftmailer.org' => 'Mark Corbyn') - * ); - * print_r($header->getNameAddressStrings()); - * // array ( - * // 0 => Chris Corbyn , - * // 1 => Mark Corbyn - * // ) - * ?> - * - * - * @see getNameAddresses() - * @see toString() - * - * @throws Swift_RfcComplianceException - * - * @return string[] - */ - public function getNameAddressStrings() - { - return $this->createNameAddressStrings($this->getNameAddresses()); - } + /** + * Get the full mailbox list of this Header as an array of valid RFC 2822 strings. + * + * Example: + * + * 'Chris Corbyn', + * 'mark@swiftmailer.org' => 'Mark Corbyn') + * ); + * print_r($header->getNameAddressStrings()); + * // array ( + * // 0 => Chris Corbyn , + * // 1 => Mark Corbyn + * // ) + * ?> + * + * + * @see getNameAddresses() + * @see toString() + * + * @throws Swift_RfcComplianceException + * + * @return string[] + */ + public function getNameAddressStrings() + { + return $this->createNameAddressStrings($this->getNameAddresses()); + } - /** - * Get all mailboxes in this Header as key=>value pairs. - * - * The key is the address and the value is the name (or null if none set). - * Example: - * - * 'Chris Corbyn', - * 'mark@swiftmailer.org' => 'Mark Corbyn') - * ); - * print_r($header->getNameAddresses()); - * // array ( - * // chris@swiftmailer.org => Chris Corbyn, - * // mark@swiftmailer.org => Mark Corbyn - * // ) - * ?> - * - * - * @see getAddresses() - * @see getNameAddressStrings() - * - * @return string[] - */ - public function getNameAddresses() - { - return $this->mailboxes; - } + /** + * Get all mailboxes in this Header as key=>value pairs. + * + * The key is the address and the value is the name (or null if none set). + * Example: + * + * 'Chris Corbyn', + * 'mark@swiftmailer.org' => 'Mark Corbyn') + * ); + * print_r($header->getNameAddresses()); + * // array ( + * // chris@swiftmailer.org => Chris Corbyn, + * // mark@swiftmailer.org => Mark Corbyn + * // ) + * ?> + * + * + * @see getAddresses() + * @see getNameAddressStrings() + * + * @return string[] + */ + public function getNameAddresses() + { + return $this->mailboxes; + } - /** - * Makes this Header represent a list of plain email addresses with no names. - * - * Example: - * - * setAddresses( - * array('one@domain.tld', 'two@domain.tld', 'three@domain.tld') - * ); - * ?> - * - * - * @see setNameAddresses() - * @see setValue() - * - * @param string[] $addresses - * - * @throws Swift_RfcComplianceException - */ - public function setAddresses($addresses) - { - $this->setNameAddresses(array_values((array) $addresses)); - } + /** + * Makes this Header represent a list of plain email addresses with no names. + * + * Example: + * + * setAddresses( + * array('one@domain.tld', 'two@domain.tld', 'three@domain.tld') + * ); + * ?> + * + * + * @see setNameAddresses() + * @see setValue() + * + * @param string[] $addresses + * + * @throws Swift_RfcComplianceException + */ + public function setAddresses($addresses) + { + $this->setNameAddresses(array_values((array) $addresses)); + } - /** - * Get all email addresses in this Header. - * - * @see getNameAddresses() - * - * @return string[] - */ - public function getAddresses() - { - return array_keys($this->mailboxes); - } + /** + * Get all email addresses in this Header. + * + * @see getNameAddresses() + * + * @return string[] + */ + public function getAddresses() + { + return array_keys($this->mailboxes); + } - /** - * Remove one or more addresses from this Header. - * - * @param string|string[] $addresses - */ - public function removeAddresses($addresses) - { - $this->setCachedValue(null); - foreach ((array) $addresses as $address) { - unset($this->mailboxes[$address]); - } - } + /** + * Remove one or more addresses from this Header. + * + * @param string|string[] $addresses + */ + public function removeAddresses($addresses) + { + $this->setCachedValue(null); + foreach ((array) $addresses as $address) { + unset($this->mailboxes[$address]); + } + } - /** - * Get the string value of the body in this Header. - * - * This is not necessarily RFC 2822 compliant since folding white space will - * not be added at this stage (see {@link toString()} for that). - * - * @see toString() - * - * @throws Swift_RfcComplianceException - * - * @return string - */ - public function getFieldBody() - { - // Compute the string value of the header only if needed - if (null === $this->getCachedValue()) { - $this->setCachedValue($this->createMailboxListString($this->mailboxes)); - } + /** + * Get the string value of the body in this Header. + * + * This is not necessarily RFC 2822 compliant since folding white space will + * not be added at this stage (see {@link toString()} for that). + * + * @see toString() + * + * @throws Swift_RfcComplianceException + * + * @return string + */ + public function getFieldBody() + { + // Compute the string value of the header only if needed + if (null === $this->getCachedValue()) { + $this->setCachedValue($this->createMailboxListString($this->mailboxes)); + } - return $this->getCachedValue(); - } + return $this->getCachedValue(); + } - /** - * Normalizes a user-input list of mailboxes into consistent key=>value pairs. - * - * @param string[] $mailboxes - * - * @return string[] - */ - protected function normalizeMailboxes(array $mailboxes) - { - $actualMailboxes = []; + /** + * Normalizes a user-input list of mailboxes into consistent key=>value pairs. + * + * @param string[] $mailboxes + * + * @return string[] + */ + protected function normalizeMailboxes(array $mailboxes) + { + $actualMailboxes = []; - foreach ($mailboxes as $key => $value) { - if (\is_string($key)) { - //key is email addr - $address = $key; - $name = $value; - } else { - $address = $value; - $name = null; - } - $this->assertValidAddress($address); - $actualMailboxes[$address] = $name; - } + foreach ($mailboxes as $key => $value) { + if (\is_string($key)) { + //key is email addr + $address = $key; + $name = $value; + } else { + $address = $value; + $name = null; + } + $this->assertValidAddress($address); + $actualMailboxes[$address] = $name; + } - return $actualMailboxes; - } + return $actualMailboxes; + } - /** - * Produces a compliant, formatted display-name based on the string given. - * - * @param string $displayName as displayed - * @param bool $shorten the first line to make remove for header name - * - * @return string - */ - protected function createDisplayNameString($displayName, $shorten = false) - { - return $this->createPhrase($this, $displayName, $this->getCharset(), $this->getEncoder(), $shorten); - } + /** + * Produces a compliant, formatted display-name based on the string given. + * + * @param string $displayName as displayed + * @param bool $shorten the first line to make remove for header name + * + * @return string + */ + protected function createDisplayNameString($displayName, $shorten = false) + { + return $this->createPhrase($this, $displayName, $this->getCharset(), $this->getEncoder(), $shorten); + } - /** - * Creates a string form of all the mailboxes in the passed array. - * - * @param string[] $mailboxes - * - * @throws Swift_RfcComplianceException - * - * @return string - */ - protected function createMailboxListString(array $mailboxes) - { - return implode(', ', $this->createNameAddressStrings($mailboxes)); - } + /** + * Creates a string form of all the mailboxes in the passed array. + * + * @param string[] $mailboxes + * + * @throws Swift_RfcComplianceException + * + * @return string + */ + protected function createMailboxListString(array $mailboxes) + { + return implode(', ', $this->createNameAddressStrings($mailboxes)); + } - /** - * Redefine the encoding requirements for mailboxes. - * - * All "specials" must be encoded as the full header value will not be quoted - * - * @see RFC 2822 3.2.1 - * - * @param string $token - * - * @return bool - */ - protected function tokenNeedsEncoding($token) - { - return preg_match('/[()<>\[\]:;@\,."]/', $token) || parent::tokenNeedsEncoding($token); - } + /** + * Redefine the encoding requirements for mailboxes. + * + * All "specials" must be encoded as the full header value will not be quoted + * + * @see RFC 2822 3.2.1 + * + * @param string $token + * + * @return bool + */ + protected function tokenNeedsEncoding($token) + { + return preg_match('/[()<>\[\]:;@\,."]/', $token) || parent::tokenNeedsEncoding($token); + } - /** - * Return an array of strings conforming the the name-addr spec of RFC 2822. - * - * @param string[] $mailboxes - * - * @return string[] - */ - private function createNameAddressStrings(array $mailboxes) - { - $strings = []; + /** + * Return an array of strings conforming the the name-addr spec of RFC 2822. + * + * @param string[] $mailboxes + * + * @return string[] + */ + private function createNameAddressStrings(array $mailboxes) + { + $strings = []; - foreach ($mailboxes as $email => $name) { - $mailboxStr = $this->addressEncoder->encodeString($email); - if (null !== $name) { - $nameStr = $this->createDisplayNameString($name, empty($strings)); - $mailboxStr = $nameStr.' <'.$mailboxStr.'>'; - } - $strings[] = $mailboxStr; - } + foreach ($mailboxes as $email => $name) { + $mailboxStr = $this->addressEncoder->encodeString($email); + if (null !== $name) { + $nameStr = $this->createDisplayNameString($name, empty($strings)); + $mailboxStr = $nameStr.' <'.$mailboxStr.'>'; + } + $strings[] = $mailboxStr; + } - return $strings; - } + return $strings; + } - /** - * Throws an Exception if the address passed does not comply with RFC 2822. - * - * @param string $address - * - * @throws Swift_RfcComplianceException if invalid - */ - private function assertValidAddress($address) - { - if (!$this->emailValidator->isValid($address, new RFCValidation())) { - throw new Swift_RfcComplianceException('Address in mailbox given ['.$address.'] does not comply with RFC 2822, 3.6.2.'); - } - } + /** + * Throws an Exception if the address passed does not comply with RFC 2822. + * + * @param string $address + * + * @throws Swift_RfcComplianceException if invalid + */ + private function assertValidAddress($address) + { + if (!$this->emailValidator->isValid($address, new RFCValidation())) { + throw new Swift_RfcComplianceException('Address in mailbox given ['.$address.'] does not comply with RFC 2822, 3.6.2.'); + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/OpenDKIMHeader.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/OpenDKIMHeader.php index d0cb3504a97..fafb5bae21f 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/OpenDKIMHeader.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/OpenDKIMHeader.php @@ -17,119 +17,119 @@ */ class Swift_Mime_Headers_OpenDKIMHeader implements Swift_Mime_Header { - /** - * The value of this Header. - * - * @var string - */ - private $value; + /** + * The value of this Header. + * + * @var string + */ + private $value; - /** - * The name of this Header. - * - * @var string - */ - private $fieldName; + /** + * The name of this Header. + * + * @var string + */ + private $fieldName; - /** - * @param string $name - */ - public function __construct($name) - { - $this->fieldName = $name; - } + /** + * @param string $name + */ + public function __construct($name) + { + $this->fieldName = $name; + } - /** - * Get the type of Header that this instance represents. - * - * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX - * @see TYPE_DATE, TYPE_ID, TYPE_PATH - * - * @return int - */ - public function getFieldType() - { - return self::TYPE_TEXT; - } + /** + * Get the type of Header that this instance represents. + * + * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX + * @see TYPE_DATE, TYPE_ID, TYPE_PATH + * + * @return int + */ + public function getFieldType() + { + return self::TYPE_TEXT; + } - /** - * Set the model for the field body. - * - * This method takes a string for the field value. - * - * @param string $model - */ - public function setFieldBodyModel($model) - { - $this->setValue($model); - } + /** + * Set the model for the field body. + * + * This method takes a string for the field value. + * + * @param string $model + */ + public function setFieldBodyModel($model) + { + $this->setValue($model); + } - /** - * Get the model for the field body. - * - * This method returns a string. - * - * @return string - */ - public function getFieldBodyModel() - { - return $this->getValue(); - } + /** + * Get the model for the field body. + * + * This method returns a string. + * + * @return string + */ + public function getFieldBodyModel() + { + return $this->getValue(); + } - /** - * Get the (unencoded) value of this header. - * - * @return string - */ - public function getValue() - { - return $this->value; - } + /** + * Get the (unencoded) value of this header. + * + * @return string + */ + public function getValue() + { + return $this->value; + } - /** - * Set the (unencoded) value of this header. - * - * @param string $value - */ - public function setValue($value) - { - $this->value = $value; - } + /** + * Set the (unencoded) value of this header. + * + * @param string $value + */ + public function setValue($value) + { + $this->value = $value; + } - /** - * Get the value of this header prepared for rendering. - * - * @return string - */ - public function getFieldBody() - { - return $this->value; - } + /** + * Get the value of this header prepared for rendering. + * + * @return string + */ + public function getFieldBody() + { + return $this->value; + } - /** - * Get this Header rendered as a RFC 2822 compliant string. - * - * @return string - */ - public function toString() - { - return $this->fieldName.': '.$this->value."\r\n"; - } + /** + * Get this Header rendered as a RFC 2822 compliant string. + * + * @return string + */ + public function toString() + { + return $this->fieldName.': '.$this->value."\r\n"; + } - /** - * Set the Header FieldName. - * - * @see Swift_Mime_Header::getFieldName() - */ - public function getFieldName() - { - return $this->fieldName; - } + /** + * Set the Header FieldName. + * + * @see Swift_Mime_Header::getFieldName() + */ + public function getFieldName() + { + return $this->fieldName; + } - /** - * Ignored. - */ - public function setCharset($charset) - { - } + /** + * Ignored. + */ + public function setCharset($charset) + { + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/ParameterizedHeader.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/ParameterizedHeader.php index 6cd26a26465..47c15e6c05f 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/ParameterizedHeader.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/ParameterizedHeader.php @@ -15,241 +15,241 @@ */ class Swift_Mime_Headers_ParameterizedHeader extends Swift_Mime_Headers_UnstructuredHeader { - /** - * RFC 2231's definition of a token. - * - * @var string - */ - const TOKEN_REGEX = '(?:[\x21\x23-\x27\x2A\x2B\x2D\x2E\x30-\x39\x41-\x5A\x5E-\x7E]+)'; + /** + * RFC 2231's definition of a token. + * + * @var string + */ + const TOKEN_REGEX = '(?:[\x21\x23-\x27\x2A\x2B\x2D\x2E\x30-\x39\x41-\x5A\x5E-\x7E]+)'; - /** - * The Encoder used to encode the parameters. - * - * @var Swift_Encoder - */ - private $paramEncoder; + /** + * The Encoder used to encode the parameters. + * + * @var Swift_Encoder + */ + private $paramEncoder; - /** - * The parameters as an associative array. - * - * @var string[] - */ - private $params = []; + /** + * The parameters as an associative array. + * + * @var string[] + */ + private $params = []; - /** - * Creates a new ParameterizedHeader with $name. - * - * @param string $name - */ - public function __construct($name, Swift_Mime_HeaderEncoder $encoder, Swift_Encoder $paramEncoder = null) - { - parent::__construct($name, $encoder); - $this->paramEncoder = $paramEncoder; - } + /** + * Creates a new ParameterizedHeader with $name. + * + * @param string $name + */ + public function __construct($name, Swift_Mime_HeaderEncoder $encoder, Swift_Encoder $paramEncoder = null) + { + parent::__construct($name, $encoder); + $this->paramEncoder = $paramEncoder; + } - /** - * Get the type of Header that this instance represents. - * - * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX - * @see TYPE_DATE, TYPE_ID, TYPE_PATH - * - * @return int - */ - public function getFieldType() - { - return self::TYPE_PARAMETERIZED; - } + /** + * Get the type of Header that this instance represents. + * + * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX + * @see TYPE_DATE, TYPE_ID, TYPE_PATH + * + * @return int + */ + public function getFieldType() + { + return self::TYPE_PARAMETERIZED; + } - /** - * Set the character set used in this Header. - * - * @param string $charset - */ - public function setCharset($charset) - { - parent::setCharset($charset); - if (isset($this->paramEncoder)) { - $this->paramEncoder->charsetChanged($charset); - } - } + /** + * Set the character set used in this Header. + * + * @param string $charset + */ + public function setCharset($charset) + { + parent::setCharset($charset); + if (isset($this->paramEncoder)) { + $this->paramEncoder->charsetChanged($charset); + } + } - /** - * Set the value of $parameter. - * - * @param string $parameter - * @param string $value - */ - public function setParameter($parameter, $value) - { - $this->setParameters(array_merge($this->getParameters(), [$parameter => $value])); - } + /** + * Set the value of $parameter. + * + * @param string $parameter + * @param string $value + */ + public function setParameter($parameter, $value) + { + $this->setParameters(array_merge($this->getParameters(), [$parameter => $value])); + } - /** - * Get the value of $parameter. - * - * @param string $parameter - * - * @return string - */ - public function getParameter($parameter) - { - $params = $this->getParameters(); + /** + * Get the value of $parameter. + * + * @param string $parameter + * + * @return string + */ + public function getParameter($parameter) + { + $params = $this->getParameters(); - return $params[$parameter] ?? null; - } + return $params[$parameter] ?? null; + } - /** - * Set an associative array of parameter names mapped to values. - * - * @param string[] $parameters - */ - public function setParameters(array $parameters) - { - $this->clearCachedValueIf($this->params != $parameters); - $this->params = $parameters; - } + /** + * Set an associative array of parameter names mapped to values. + * + * @param string[] $parameters + */ + public function setParameters(array $parameters) + { + $this->clearCachedValueIf($this->params != $parameters); + $this->params = $parameters; + } - /** - * Returns an associative array of parameter names mapped to values. - * - * @return string[] - */ - public function getParameters() - { - return $this->params; - } + /** + * Returns an associative array of parameter names mapped to values. + * + * @return string[] + */ + public function getParameters() + { + return $this->params; + } - /** - * Get the value of this header prepared for rendering. - * - * @return string - */ - public function getFieldBody() //TODO: Check caching here - { - $body = parent::getFieldBody(); - foreach ($this->params as $name => $value) { - if (null !== $value) { - // Add the parameter - $body .= '; '.$this->createParameter($name, $value); - } - } + /** + * Get the value of this header prepared for rendering. + * + * @return string + */ + public function getFieldBody() //TODO: Check caching here + { + $body = parent::getFieldBody(); + foreach ($this->params as $name => $value) { + if (null !== $value) { + // Add the parameter + $body .= '; '.$this->createParameter($name, $value); + } + } - return $body; - } + return $body; + } - /** - * Generate a list of all tokens in the final header. - * - * This doesn't need to be overridden in theory, but it is for implementation - * reasons to prevent potential breakage of attributes. - * - * @param string $string The string to tokenize - * - * @return array An array of tokens as strings - */ - protected function toTokens($string = null) - { - $tokens = parent::toTokens(parent::getFieldBody()); + /** + * Generate a list of all tokens in the final header. + * + * This doesn't need to be overridden in theory, but it is for implementation + * reasons to prevent potential breakage of attributes. + * + * @param string $string The string to tokenize + * + * @return array An array of tokens as strings + */ + protected function toTokens($string = null) + { + $tokens = parent::toTokens(parent::getFieldBody()); - // Try creating any parameters - foreach ($this->params as $name => $value) { - if (null !== $value) { - // Add the semi-colon separator - $tokens[\count($tokens) - 1] .= ';'; - $tokens = array_merge($tokens, $this->generateTokenLines( - ' '.$this->createParameter($name, $value) - )); - } - } + // Try creating any parameters + foreach ($this->params as $name => $value) { + if (null !== $value) { + // Add the semi-colon separator + $tokens[\count($tokens) - 1] .= ';'; + $tokens = array_merge($tokens, $this->generateTokenLines( + ' '.$this->createParameter($name, $value) + )); + } + } - return $tokens; - } + return $tokens; + } - /** - * Render a RFC 2047 compliant header parameter from the $name and $value. - * - * @param string $name - * @param string $value - * - * @return string - */ - private function createParameter($name, $value) - { - $origValue = $value; + /** + * Render a RFC 2047 compliant header parameter from the $name and $value. + * + * @param string $name + * @param string $value + * + * @return string + */ + private function createParameter($name, $value) + { + $origValue = $value; - $encoded = false; - // Allow room for parameter name, indices, "=" and DQUOTEs - $maxValueLength = $this->getMaxLineLength() - \strlen($name.'=*N"";') - 1; - $firstLineOffset = 0; + $encoded = false; + // Allow room for parameter name, indices, "=" and DQUOTEs + $maxValueLength = $this->getMaxLineLength() - \strlen($name.'=*N"";') - 1; + $firstLineOffset = 0; - // If it's not already a valid parameter value... - if (!preg_match('/^'.self::TOKEN_REGEX.'$/D', $value)) { - // TODO: text, or something else?? - // ... and it's not ascii - if (!preg_match('/^[\x00-\x08\x0B\x0C\x0E-\x7F]*$/D', $value)) { - $encoded = true; - // Allow space for the indices, charset and language - $maxValueLength = $this->getMaxLineLength() - \strlen($name.'*N*="";') - 1; - $firstLineOffset = \strlen( - $this->getCharset()."'".$this->getLanguage()."'" - ); - } - } + // If it's not already a valid parameter value... + if (!preg_match('/^'.self::TOKEN_REGEX.'$/D', $value)) { + // TODO: text, or something else?? + // ... and it's not ascii + if (!preg_match('/^[\x00-\x08\x0B\x0C\x0E-\x7F]*$/D', $value)) { + $encoded = true; + // Allow space for the indices, charset and language + $maxValueLength = $this->getMaxLineLength() - \strlen($name.'*N*="";') - 1; + $firstLineOffset = \strlen( + $this->getCharset()."'".$this->getLanguage()."'" + ); + } + } - // Encode if we need to - if ($encoded || \strlen($value) > $maxValueLength) { - if (isset($this->paramEncoder)) { - $value = $this->paramEncoder->encodeString( - $origValue, $firstLineOffset, $maxValueLength, $this->getCharset() - ); - } else { - // We have to go against RFC 2183/2231 in some areas for interoperability - $value = $this->getTokenAsEncodedWord($origValue); - $encoded = false; - } - } + // Encode if we need to + if ($encoded || \strlen($value) > $maxValueLength) { + if (isset($this->paramEncoder)) { + $value = $this->paramEncoder->encodeString( + $origValue, $firstLineOffset, $maxValueLength, $this->getCharset() + ); + } else { + // We have to go against RFC 2183/2231 in some areas for interoperability + $value = $this->getTokenAsEncodedWord($origValue); + $encoded = false; + } + } - $valueLines = isset($this->paramEncoder) ? explode("\r\n", $value) : [$value]; + $valueLines = isset($this->paramEncoder) ? explode("\r\n", $value) : [$value]; - // Need to add indices - if (\count($valueLines) > 1) { - $paramLines = []; - foreach ($valueLines as $i => $line) { - $paramLines[] = $name.'*'.$i. - $this->getEndOfParameterValue($line, true, 0 == $i); - } + // Need to add indices + if (\count($valueLines) > 1) { + $paramLines = []; + foreach ($valueLines as $i => $line) { + $paramLines[] = $name.'*'.$i. + $this->getEndOfParameterValue($line, true, 0 == $i); + } - return implode(";\r\n ", $paramLines); - } else { - return $name.$this->getEndOfParameterValue( - $valueLines[0], $encoded, true - ); - } - } + return implode(";\r\n ", $paramLines); + } else { + return $name.$this->getEndOfParameterValue( + $valueLines[0], $encoded, true + ); + } + } - /** - * Returns the parameter value from the "=" and beyond. - * - * @param string $value to append - * @param bool $encoded - * @param bool $firstLine - * - * @return string - */ - private function getEndOfParameterValue($value, $encoded = false, $firstLine = false) - { - if (!preg_match('/^'.self::TOKEN_REGEX.'$/D', $value)) { - $value = '"'.$value.'"'; - } - $prepend = '='; - if ($encoded) { - $prepend = '*='; - if ($firstLine) { - $prepend = '*='.$this->getCharset()."'".$this->getLanguage(). - "'"; - } - } + /** + * Returns the parameter value from the "=" and beyond. + * + * @param string $value to append + * @param bool $encoded + * @param bool $firstLine + * + * @return string + */ + private function getEndOfParameterValue($value, $encoded = false, $firstLine = false) + { + if (!preg_match('/^'.self::TOKEN_REGEX.'$/D', $value)) { + $value = '"'.$value.'"'; + } + $prepend = '='; + if ($encoded) { + $prepend = '*='; + if ($firstLine) { + $prepend = '*='.$this->getCharset()."'".$this->getLanguage(). + "'"; + } + } - return $prepend.$value; - } + return $prepend.$value; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/PathHeader.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/PathHeader.php index 86ab1deaf50..81b421ee7a8 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/PathHeader.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/PathHeader.php @@ -18,136 +18,136 @@ use Egulias\EmailValidator\Validation\RFCValidation; */ class Swift_Mime_Headers_PathHeader extends Swift_Mime_Headers_AbstractHeader { - /** - * The address in this Header (if specified). - * - * @var string - */ - private $address; + /** + * The address in this Header (if specified). + * + * @var string + */ + private $address; - /** - * The strict EmailValidator. - * - * @var EmailValidator - */ - private $emailValidator; + /** + * The strict EmailValidator. + * + * @var EmailValidator + */ + private $emailValidator; - private $addressEncoder; + private $addressEncoder; - /** - * Creates a new PathHeader with the given $name. - * - * @param string $name - */ - public function __construct($name, EmailValidator $emailValidator, Swift_AddressEncoder $addressEncoder = null) - { - $this->setFieldName($name); - $this->emailValidator = $emailValidator; - $this->addressEncoder = $addressEncoder ?? new Swift_AddressEncoder_IdnAddressEncoder(); - } + /** + * Creates a new PathHeader with the given $name. + * + * @param string $name + */ + public function __construct($name, EmailValidator $emailValidator, Swift_AddressEncoder $addressEncoder = null) + { + $this->setFieldName($name); + $this->emailValidator = $emailValidator; + $this->addressEncoder = $addressEncoder ?? new Swift_AddressEncoder_IdnAddressEncoder(); + } - /** - * Get the type of Header that this instance represents. - * - * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX - * @see TYPE_DATE, TYPE_ID, TYPE_PATH - * - * @return int - */ - public function getFieldType() - { - return self::TYPE_PATH; - } + /** + * Get the type of Header that this instance represents. + * + * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX + * @see TYPE_DATE, TYPE_ID, TYPE_PATH + * + * @return int + */ + public function getFieldType() + { + return self::TYPE_PATH; + } - /** - * Set the model for the field body. - * This method takes a string for an address. - * - * @param string $model - * - * @throws Swift_RfcComplianceException - */ - public function setFieldBodyModel($model) - { - $this->setAddress($model); - } + /** + * Set the model for the field body. + * This method takes a string for an address. + * + * @param string $model + * + * @throws Swift_RfcComplianceException + */ + public function setFieldBodyModel($model) + { + $this->setAddress($model); + } - /** - * Get the model for the field body. - * This method returns a string email address. - * - * @return mixed - */ - public function getFieldBodyModel() - { - return $this->getAddress(); - } + /** + * Get the model for the field body. + * This method returns a string email address. + * + * @return mixed + */ + public function getFieldBodyModel() + { + return $this->getAddress(); + } - /** - * Set the Address which should appear in this Header. - * - * @param string $address - * - * @throws Swift_RfcComplianceException - */ - public function setAddress($address) - { - if (null === $address) { - $this->address = null; - } elseif ('' == $address) { - $this->address = ''; - } else { - $this->assertValidAddress($address); - $this->address = $address; - } - $this->setCachedValue(null); - } + /** + * Set the Address which should appear in this Header. + * + * @param string $address + * + * @throws Swift_RfcComplianceException + */ + public function setAddress($address) + { + if (null === $address) { + $this->address = null; + } elseif ('' == $address) { + $this->address = ''; + } else { + $this->assertValidAddress($address); + $this->address = $address; + } + $this->setCachedValue(null); + } - /** - * Get the address which is used in this Header (if any). - * - * Null is returned if no address is set. - * - * @return string - */ - public function getAddress() - { - return $this->address; - } + /** + * Get the address which is used in this Header (if any). + * + * Null is returned if no address is set. + * + * @return string + */ + public function getAddress() + { + return $this->address; + } - /** - * Get the string value of the body in this Header. - * - * This is not necessarily RFC 2822 compliant since folding white space will - * not be added at this stage (see {@link toString()} for that). - * - * @see toString() - * - * @return string - */ - public function getFieldBody() - { - if (!$this->getCachedValue()) { - if (isset($this->address)) { - $address = $this->addressEncoder->encodeString($this->address); - $this->setCachedValue('<'.$address.'>'); - } - } + /** + * Get the string value of the body in this Header. + * + * This is not necessarily RFC 2822 compliant since folding white space will + * not be added at this stage (see {@link toString()} for that). + * + * @see toString() + * + * @return string + */ + public function getFieldBody() + { + if (!$this->getCachedValue()) { + if (isset($this->address)) { + $address = $this->addressEncoder->encodeString($this->address); + $this->setCachedValue('<'.$address.'>'); + } + } - return $this->getCachedValue(); - } + return $this->getCachedValue(); + } - /** - * Throws an Exception if the address passed does not comply with RFC 2822. - * - * @param string $address - * - * @throws Swift_RfcComplianceException If address is invalid - */ - private function assertValidAddress($address) - { - if (!$this->emailValidator->isValid($address, new RFCValidation())) { - throw new Swift_RfcComplianceException('Address set in PathHeader does not comply with addr-spec of RFC 2822.'); - } - } + /** + * Throws an Exception if the address passed does not comply with RFC 2822. + * + * @param string $address + * + * @throws Swift_RfcComplianceException If address is invalid + */ + private function assertValidAddress($address) + { + if (!$this->emailValidator->isValid($address, new RFCValidation())) { + throw new Swift_RfcComplianceException('Address set in PathHeader does not comply with addr-spec of RFC 2822.'); + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/UnstructuredHeader.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/UnstructuredHeader.php index 7d51945aabb..64f160dec7c 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/UnstructuredHeader.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/UnstructuredHeader.php @@ -15,95 +15,95 @@ */ class Swift_Mime_Headers_UnstructuredHeader extends Swift_Mime_Headers_AbstractHeader { - /** - * The value of this Header. - * - * @var string - */ - private $value; + /** + * The value of this Header. + * + * @var string + */ + private $value; - /** - * Creates a new SimpleHeader with $name. - * - * @param string $name - */ - public function __construct($name, Swift_Mime_HeaderEncoder $encoder) - { - $this->setFieldName($name); - $this->setEncoder($encoder); - } + /** + * Creates a new SimpleHeader with $name. + * + * @param string $name + */ + public function __construct($name, Swift_Mime_HeaderEncoder $encoder) + { + $this->setFieldName($name); + $this->setEncoder($encoder); + } - /** - * Get the type of Header that this instance represents. - * - * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX - * @see TYPE_DATE, TYPE_ID, TYPE_PATH - * - * @return int - */ - public function getFieldType() - { - return self::TYPE_TEXT; - } + /** + * Get the type of Header that this instance represents. + * + * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX + * @see TYPE_DATE, TYPE_ID, TYPE_PATH + * + * @return int + */ + public function getFieldType() + { + return self::TYPE_TEXT; + } - /** - * Set the model for the field body. - * - * This method takes a string for the field value. - * - * @param string $model - */ - public function setFieldBodyModel($model) - { - $this->setValue($model); - } + /** + * Set the model for the field body. + * + * This method takes a string for the field value. + * + * @param string $model + */ + public function setFieldBodyModel($model) + { + $this->setValue($model); + } - /** - * Get the model for the field body. - * - * This method returns a string. - * - * @return string - */ - public function getFieldBodyModel() - { - return $this->getValue(); - } + /** + * Get the model for the field body. + * + * This method returns a string. + * + * @return string + */ + public function getFieldBodyModel() + { + return $this->getValue(); + } - /** - * Get the (unencoded) value of this header. - * - * @return string - */ - public function getValue() - { - return $this->value; - } + /** + * Get the (unencoded) value of this header. + * + * @return string + */ + public function getValue() + { + return $this->value; + } - /** - * Set the (unencoded) value of this header. - * - * @param string $value - */ - public function setValue($value) - { - $this->clearCachedValueIf($this->value != $value); - $this->value = $value; - } + /** + * Set the (unencoded) value of this header. + * + * @param string $value + */ + public function setValue($value) + { + $this->clearCachedValueIf($this->value != $value); + $this->value = $value; + } - /** - * Get the value of this header prepared for rendering. - * - * @return string - */ - public function getFieldBody() - { - if (!$this->getCachedValue()) { - $this->setCachedValue( - $this->encodeWords($this, $this->value) - ); - } + /** + * Get the value of this header prepared for rendering. + * + * @return string + */ + public function getFieldBody() + { + if (!$this->getCachedValue()) { + $this->setCachedValue( + $this->encodeWords($this, $this->value) + ); + } - return $this->getCachedValue(); - } + return $this->getCachedValue(); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/IdGenerator.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/IdGenerator.php index a8fd141a26a..3ce35f27c03 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/IdGenerator.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/IdGenerator.php @@ -13,42 +13,42 @@ */ class Swift_Mime_IdGenerator implements Swift_IdGenerator { - private $idRight; + private $idRight; - /** - * @param string $idRight - */ - public function __construct($idRight) - { - $this->idRight = $idRight; - } + /** + * @param string $idRight + */ + public function __construct($idRight) + { + $this->idRight = $idRight; + } - /** - * Returns the right-hand side of the "@" used in all generated IDs. - * - * @return string - */ - public function getIdRight() - { - return $this->idRight; - } + /** + * Returns the right-hand side of the "@" used in all generated IDs. + * + * @return string + */ + public function getIdRight() + { + return $this->idRight; + } - /** - * Sets the right-hand side of the "@" to use in all generated IDs. - * - * @param string $idRight - */ - public function setIdRight($idRight) - { - $this->idRight = $idRight; - } + /** + * Sets the right-hand side of the "@" to use in all generated IDs. + * + * @param string $idRight + */ + public function setIdRight($idRight) + { + $this->idRight = $idRight; + } - /** - * @return string - */ - public function generateId() - { - // 32 hex values for the left part - return bin2hex(random_bytes(16)).'@'.$this->idRight; - } + /** + * @return string + */ + public function generateId() + { + // 32 hex values for the left part + return bin2hex(random_bytes(16)).'@'.$this->idRight; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/MimePart.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/MimePart.php index 560f5ba64a5..d0b2e6586b4 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/MimePart.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/MimePart.php @@ -15,185 +15,185 @@ */ class Swift_Mime_MimePart extends Swift_Mime_SimpleMimeEntity { - /** The format parameter last specified by the user */ - protected $userFormat; + /** The format parameter last specified by the user */ + protected $userFormat; - /** The charset last specified by the user */ - protected $userCharset; + /** The charset last specified by the user */ + protected $userCharset; - /** The delsp parameter last specified by the user */ - protected $userDelSp; + /** The delsp parameter last specified by the user */ + protected $userDelSp; - /** The nesting level of this MimePart */ - private $nestingLevel = self::LEVEL_ALTERNATIVE; + /** The nesting level of this MimePart */ + private $nestingLevel = self::LEVEL_ALTERNATIVE; - /** - * Create a new MimePart with $headers, $encoder and $cache. - * - * @param string $charset - */ - public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator, $charset = null) - { - parent::__construct($headers, $encoder, $cache, $idGenerator); - $this->setContentType('text/plain'); - if (null !== $charset) { - $this->setCharset($charset); - } - } + /** + * Create a new MimePart with $headers, $encoder and $cache. + * + * @param string $charset + */ + public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator, $charset = null) + { + parent::__construct($headers, $encoder, $cache, $idGenerator); + $this->setContentType('text/plain'); + if (null !== $charset) { + $this->setCharset($charset); + } + } - /** - * Set the body of this entity, either as a string, or as an instance of - * {@link Swift_OutputByteStream}. - * - * @param mixed $body - * @param string $contentType optional - * @param string $charset optional - * - * @return $this - */ - public function setBody($body, $contentType = null, $charset = null) - { - if (isset($charset)) { - $this->setCharset($charset); - } - $body = $this->convertString($body); + /** + * Set the body of this entity, either as a string, or as an instance of + * {@link Swift_OutputByteStream}. + * + * @param mixed $body + * @param string $contentType optional + * @param string $charset optional + * + * @return $this + */ + public function setBody($body, $contentType = null, $charset = null) + { + if (isset($charset)) { + $this->setCharset($charset); + } + $body = $this->convertString($body); - parent::setBody($body, $contentType); + parent::setBody($body, $contentType); - return $this; - } + return $this; + } - /** - * Get the character set of this entity. - * - * @return string - */ - public function getCharset() - { - return $this->getHeaderParameter('Content-Type', 'charset'); - } + /** + * Get the character set of this entity. + * + * @return string + */ + public function getCharset() + { + return $this->getHeaderParameter('Content-Type', 'charset'); + } - /** - * Set the character set of this entity. - * - * @param string $charset - * - * @return $this - */ - public function setCharset($charset) - { - $this->setHeaderParameter('Content-Type', 'charset', $charset); - if ($charset !== $this->userCharset) { - $this->clearCache(); - } - $this->userCharset = $charset; - parent::charsetChanged($charset); + /** + * Set the character set of this entity. + * + * @param string $charset + * + * @return $this + */ + public function setCharset($charset) + { + $this->setHeaderParameter('Content-Type', 'charset', $charset); + if ($charset !== $this->userCharset) { + $this->clearCache(); + } + $this->userCharset = $charset; + parent::charsetChanged($charset); - return $this; - } + return $this; + } - /** - * Get the format of this entity (i.e. flowed or fixed). - * - * @return string - */ - public function getFormat() - { - return $this->getHeaderParameter('Content-Type', 'format'); - } + /** + * Get the format of this entity (i.e. flowed or fixed). + * + * @return string + */ + public function getFormat() + { + return $this->getHeaderParameter('Content-Type', 'format'); + } - /** - * Set the format of this entity (flowed or fixed). - * - * @param string $format - * - * @return $this - */ - public function setFormat($format) - { - $this->setHeaderParameter('Content-Type', 'format', $format); - $this->userFormat = $format; + /** + * Set the format of this entity (flowed or fixed). + * + * @param string $format + * + * @return $this + */ + public function setFormat($format) + { + $this->setHeaderParameter('Content-Type', 'format', $format); + $this->userFormat = $format; - return $this; - } + return $this; + } - /** - * Test if delsp is being used for this entity. - * - * @return bool - */ - public function getDelSp() - { - return 'yes' === $this->getHeaderParameter('Content-Type', 'delsp'); - } + /** + * Test if delsp is being used for this entity. + * + * @return bool + */ + public function getDelSp() + { + return 'yes' === $this->getHeaderParameter('Content-Type', 'delsp'); + } - /** - * Turn delsp on or off for this entity. - * - * @param bool $delsp - * - * @return $this - */ - public function setDelSp($delsp = true) - { - $this->setHeaderParameter('Content-Type', 'delsp', $delsp ? 'yes' : null); - $this->userDelSp = $delsp; + /** + * Turn delsp on or off for this entity. + * + * @param bool $delsp + * + * @return $this + */ + public function setDelSp($delsp = true) + { + $this->setHeaderParameter('Content-Type', 'delsp', $delsp ? 'yes' : null); + $this->userDelSp = $delsp; - return $this; - } + return $this; + } - /** - * Get the nesting level of this entity. - * - * @see LEVEL_TOP, LEVEL_ALTERNATIVE, LEVEL_MIXED, LEVEL_RELATED - * - * @return int - */ - public function getNestingLevel() - { - return $this->nestingLevel; - } + /** + * Get the nesting level of this entity. + * + * @see LEVEL_TOP, LEVEL_ALTERNATIVE, LEVEL_MIXED, LEVEL_RELATED + * + * @return int + */ + public function getNestingLevel() + { + return $this->nestingLevel; + } - /** - * Receive notification that the charset has changed on this document, or a - * parent document. - * - * @param string $charset - */ - public function charsetChanged($charset) - { - $this->setCharset($charset); - } + /** + * Receive notification that the charset has changed on this document, or a + * parent document. + * + * @param string $charset + */ + public function charsetChanged($charset) + { + $this->setCharset($charset); + } - /** Fix the content-type and encoding of this entity */ - protected function fixHeaders() - { - parent::fixHeaders(); - if (\count($this->getChildren())) { - $this->setHeaderParameter('Content-Type', 'charset', null); - $this->setHeaderParameter('Content-Type', 'format', null); - $this->setHeaderParameter('Content-Type', 'delsp', null); - } else { - $this->setCharset($this->userCharset); - $this->setFormat($this->userFormat); - $this->setDelSp($this->userDelSp); - } - } + /** Fix the content-type and encoding of this entity */ + protected function fixHeaders() + { + parent::fixHeaders(); + if (\count($this->getChildren())) { + $this->setHeaderParameter('Content-Type', 'charset', null); + $this->setHeaderParameter('Content-Type', 'format', null); + $this->setHeaderParameter('Content-Type', 'delsp', null); + } else { + $this->setCharset($this->userCharset); + $this->setFormat($this->userFormat); + $this->setDelSp($this->userDelSp); + } + } - /** Set the nesting level of this entity */ - protected function setNestingLevel($level) - { - $this->nestingLevel = $level; - } + /** Set the nesting level of this entity */ + protected function setNestingLevel($level) + { + $this->nestingLevel = $level; + } - /** Encode charset when charset is not utf-8 */ - protected function convertString($string) - { - $charset = strtolower($this->getCharset() ?? ''); - if (!\in_array($charset, ['utf-8', 'iso-8859-1', 'iso-8859-15', ''])) { - return mb_convert_encoding($string, $charset, 'utf-8'); - } + /** Encode charset when charset is not utf-8 */ + protected function convertString($string) + { + $charset = strtolower($this->getCharset() ?? ''); + if (!\in_array($charset, ['utf-8', 'iso-8859-1', 'iso-8859-15', ''])) { + return mb_convert_encoding($string, $charset, 'utf-8'); + } - return $string; - } + return $string; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderFactory.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderFactory.php index 347fa74cf66..ab3ce6b1914 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderFactory.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderFactory.php @@ -17,179 +17,179 @@ use Egulias\EmailValidator\EmailValidator; */ class Swift_Mime_SimpleHeaderFactory implements Swift_Mime_CharsetObserver { - /** The HeaderEncoder used by these headers */ - private $encoder; + /** The HeaderEncoder used by these headers */ + private $encoder; - /** The Encoder used by parameters */ - private $paramEncoder; + /** The Encoder used by parameters */ + private $paramEncoder; - /** Strict EmailValidator */ - private $emailValidator; + /** Strict EmailValidator */ + private $emailValidator; - /** The charset of created Headers */ - private $charset; + /** The charset of created Headers */ + private $charset; - /** Swift_AddressEncoder */ - private $addressEncoder; + /** Swift_AddressEncoder */ + private $addressEncoder; - /** - * Creates a new SimpleHeaderFactory using $encoder and $paramEncoder. - * - * @param string|null $charset - */ - public function __construct(Swift_Mime_HeaderEncoder $encoder, Swift_Encoder $paramEncoder, EmailValidator $emailValidator, $charset = null, Swift_AddressEncoder $addressEncoder = null) - { - $this->encoder = $encoder; - $this->paramEncoder = $paramEncoder; - $this->emailValidator = $emailValidator; - $this->charset = $charset; - $this->addressEncoder = $addressEncoder ?? new Swift_AddressEncoder_IdnAddressEncoder(); - } + /** + * Creates a new SimpleHeaderFactory using $encoder and $paramEncoder. + * + * @param string|null $charset + */ + public function __construct(Swift_Mime_HeaderEncoder $encoder, Swift_Encoder $paramEncoder, EmailValidator $emailValidator, $charset = null, Swift_AddressEncoder $addressEncoder = null) + { + $this->encoder = $encoder; + $this->paramEncoder = $paramEncoder; + $this->emailValidator = $emailValidator; + $this->charset = $charset; + $this->addressEncoder = $addressEncoder ?? new Swift_AddressEncoder_IdnAddressEncoder(); + } - /** - * Create a new Mailbox Header with a list of $addresses. - * - * @param string $name - * @param array|string|null $addresses - * - * @return Swift_Mime_Header - */ - public function createMailboxHeader($name, $addresses = null) - { - $header = new Swift_Mime_Headers_MailboxHeader($name, $this->encoder, $this->emailValidator, $this->addressEncoder); - if (isset($addresses)) { - $header->setFieldBodyModel($addresses); - } - $this->setHeaderCharset($header); + /** + * Create a new Mailbox Header with a list of $addresses. + * + * @param string $name + * @param array|string|null $addresses + * + * @return Swift_Mime_Header + */ + public function createMailboxHeader($name, $addresses = null) + { + $header = new Swift_Mime_Headers_MailboxHeader($name, $this->encoder, $this->emailValidator, $this->addressEncoder); + if (isset($addresses)) { + $header->setFieldBodyModel($addresses); + } + $this->setHeaderCharset($header); - return $header; - } + return $header; + } - /** - * Create a new Date header using $dateTime. - * - * @param string $name - * - * @return Swift_Mime_Header - */ - public function createDateHeader($name, DateTimeInterface $dateTime = null) - { - $header = new Swift_Mime_Headers_DateHeader($name); - if (isset($dateTime)) { - $header->setFieldBodyModel($dateTime); - } - $this->setHeaderCharset($header); + /** + * Create a new Date header using $dateTime. + * + * @param string $name + * + * @return Swift_Mime_Header + */ + public function createDateHeader($name, DateTimeInterface $dateTime = null) + { + $header = new Swift_Mime_Headers_DateHeader($name); + if (isset($dateTime)) { + $header->setFieldBodyModel($dateTime); + } + $this->setHeaderCharset($header); - return $header; - } + return $header; + } - /** - * Create a new basic text header with $name and $value. - * - * @param string $name - * @param string $value - * - * @return Swift_Mime_Header - */ - public function createTextHeader($name, $value = null) - { - $header = new Swift_Mime_Headers_UnstructuredHeader($name, $this->encoder); - if (isset($value)) { - $header->setFieldBodyModel($value); - } - $this->setHeaderCharset($header); + /** + * Create a new basic text header with $name and $value. + * + * @param string $name + * @param string $value + * + * @return Swift_Mime_Header + */ + public function createTextHeader($name, $value = null) + { + $header = new Swift_Mime_Headers_UnstructuredHeader($name, $this->encoder); + if (isset($value)) { + $header->setFieldBodyModel($value); + } + $this->setHeaderCharset($header); - return $header; - } + return $header; + } - /** - * Create a new ParameterizedHeader with $name, $value and $params. - * - * @param string $name - * @param string $value - * @param array $params - * - * @return Swift_Mime_Headers_ParameterizedHeader - */ - public function createParameterizedHeader($name, $value = null, $params = []) - { - $header = new Swift_Mime_Headers_ParameterizedHeader($name, $this->encoder, ('content-disposition' == strtolower($name ?? '')) ? $this->paramEncoder : null); - if (isset($value)) { - $header->setFieldBodyModel($value); - } - foreach ($params as $k => $v) { - $header->setParameter($k, $v); - } - $this->setHeaderCharset($header); + /** + * Create a new ParameterizedHeader with $name, $value and $params. + * + * @param string $name + * @param string $value + * @param array $params + * + * @return Swift_Mime_Headers_ParameterizedHeader + */ + public function createParameterizedHeader($name, $value = null, $params = []) + { + $header = new Swift_Mime_Headers_ParameterizedHeader($name, $this->encoder, ('content-disposition' == strtolower($name ?? '')) ? $this->paramEncoder : null); + if (isset($value)) { + $header->setFieldBodyModel($value); + } + foreach ($params as $k => $v) { + $header->setParameter($k, $v); + } + $this->setHeaderCharset($header); - return $header; - } + return $header; + } - /** - * Create a new ID header for Message-ID or Content-ID. - * - * @param string $name - * @param string|array $ids - * - * @return Swift_Mime_Header - */ - public function createIdHeader($name, $ids = null) - { - $header = new Swift_Mime_Headers_IdentificationHeader($name, $this->emailValidator); - if (isset($ids)) { - $header->setFieldBodyModel($ids); - } - $this->setHeaderCharset($header); + /** + * Create a new ID header for Message-ID or Content-ID. + * + * @param string $name + * @param string|array $ids + * + * @return Swift_Mime_Header + */ + public function createIdHeader($name, $ids = null) + { + $header = new Swift_Mime_Headers_IdentificationHeader($name, $this->emailValidator); + if (isset($ids)) { + $header->setFieldBodyModel($ids); + } + $this->setHeaderCharset($header); - return $header; - } + return $header; + } - /** - * Create a new Path header with an address (path) in it. - * - * @param string $name - * @param string $path - * - * @return Swift_Mime_Header - */ - public function createPathHeader($name, $path = null) - { - $header = new Swift_Mime_Headers_PathHeader($name, $this->emailValidator); - if (isset($path)) { - $header->setFieldBodyModel($path); - } - $this->setHeaderCharset($header); + /** + * Create a new Path header with an address (path) in it. + * + * @param string $name + * @param string $path + * + * @return Swift_Mime_Header + */ + public function createPathHeader($name, $path = null) + { + $header = new Swift_Mime_Headers_PathHeader($name, $this->emailValidator); + if (isset($path)) { + $header->setFieldBodyModel($path); + } + $this->setHeaderCharset($header); - return $header; - } + return $header; + } - /** - * Notify this observer that the entity's charset has changed. - * - * @param string $charset - */ - public function charsetChanged($charset) - { - $this->charset = $charset; - $this->encoder->charsetChanged($charset); - $this->paramEncoder->charsetChanged($charset); - } + /** + * Notify this observer that the entity's charset has changed. + * + * @param string $charset + */ + public function charsetChanged($charset) + { + $this->charset = $charset; + $this->encoder->charsetChanged($charset); + $this->paramEncoder->charsetChanged($charset); + } - /** - * Make a deep copy of object. - */ - public function __clone() - { - $this->encoder = clone $this->encoder; - $this->paramEncoder = clone $this->paramEncoder; - $this->addressEncoder = clone $this->addressEncoder; - } + /** + * Make a deep copy of object. + */ + public function __clone() + { + $this->encoder = clone $this->encoder; + $this->paramEncoder = clone $this->paramEncoder; + $this->addressEncoder = clone $this->addressEncoder; + } - /** Apply the charset to the Header */ - private function setHeaderCharset(Swift_Mime_Header $header) - { - if (isset($this->charset)) { - $header->setCharset($this->charset); - } - } + /** Apply the charset to the Header */ + private function setHeaderCharset(Swift_Mime_Header $header) + { + if (isset($this->charset)) { + $header->setCharset($this->charset); + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderSet.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderSet.php index 219c46f32ff..5195bcf48ae 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderSet.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderSet.php @@ -15,385 +15,385 @@ */ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_CharsetObserver { - /** HeaderFactory */ - private $factory; + /** HeaderFactory */ + private $factory; - /** Collection of set Headers */ - private $headers = []; + /** Collection of set Headers */ + private $headers = []; - /** Field ordering details */ - private $order = []; + /** Field ordering details */ + private $order = []; - /** List of fields which are required to be displayed */ - private $required = []; + /** List of fields which are required to be displayed */ + private $required = []; - /** The charset used by Headers */ - private $charset; + /** The charset used by Headers */ + private $charset; - /** - * Create a new SimpleHeaderSet with the given $factory. - * - * @param string $charset - */ - public function __construct(Swift_Mime_SimpleHeaderFactory $factory, $charset = null) - { - $this->factory = $factory; - if (isset($charset)) { - $this->setCharset($charset); - } - } + /** + * Create a new SimpleHeaderSet with the given $factory. + * + * @param string $charset + */ + public function __construct(Swift_Mime_SimpleHeaderFactory $factory, $charset = null) + { + $this->factory = $factory; + if (isset($charset)) { + $this->setCharset($charset); + } + } - public function newInstance() - { - return new self($this->factory); - } + public function newInstance() + { + return new self($this->factory); + } - /** - * Set the charset used by these headers. - * - * @param string $charset - */ - public function setCharset($charset) - { - $this->charset = $charset; - $this->factory->charsetChanged($charset); - $this->notifyHeadersOfCharset($charset); - } + /** + * Set the charset used by these headers. + * + * @param string $charset + */ + public function setCharset($charset) + { + $this->charset = $charset; + $this->factory->charsetChanged($charset); + $this->notifyHeadersOfCharset($charset); + } - /** - * Add a new Mailbox Header with a list of $addresses. - * - * @param string $name - * @param array|string $addresses - */ - public function addMailboxHeader($name, $addresses = null) - { - $this->storeHeader($name, $this->factory->createMailboxHeader($name, $addresses)); - } + /** + * Add a new Mailbox Header with a list of $addresses. + * + * @param string $name + * @param array|string $addresses + */ + public function addMailboxHeader($name, $addresses = null) + { + $this->storeHeader($name, $this->factory->createMailboxHeader($name, $addresses)); + } - /** - * Add a new Date header using $dateTime. - * - * @param string $name - */ - public function addDateHeader($name, DateTimeInterface $dateTime = null) - { - $this->storeHeader($name, $this->factory->createDateHeader($name, $dateTime)); - } + /** + * Add a new Date header using $dateTime. + * + * @param string $name + */ + public function addDateHeader($name, DateTimeInterface $dateTime = null) + { + $this->storeHeader($name, $this->factory->createDateHeader($name, $dateTime)); + } - /** - * Add a new basic text header with $name and $value. - * - * @param string $name - * @param string $value - */ - public function addTextHeader($name, $value = null) - { - $this->storeHeader($name, $this->factory->createTextHeader($name, $value)); - } + /** + * Add a new basic text header with $name and $value. + * + * @param string $name + * @param string $value + */ + public function addTextHeader($name, $value = null) + { + $this->storeHeader($name, $this->factory->createTextHeader($name, $value)); + } - /** - * Add a new ParameterizedHeader with $name, $value and $params. - * - * @param string $name - * @param string $value - * @param array $params - */ - public function addParameterizedHeader($name, $value = null, $params = []) - { - $this->storeHeader($name, $this->factory->createParameterizedHeader($name, $value, $params)); - } + /** + * Add a new ParameterizedHeader with $name, $value and $params. + * + * @param string $name + * @param string $value + * @param array $params + */ + public function addParameterizedHeader($name, $value = null, $params = []) + { + $this->storeHeader($name, $this->factory->createParameterizedHeader($name, $value, $params)); + } - /** - * Add a new ID header for Message-ID or Content-ID. - * - * @param string $name - * @param string|array $ids - */ - public function addIdHeader($name, $ids = null) - { - $this->storeHeader($name, $this->factory->createIdHeader($name, $ids)); - } + /** + * Add a new ID header for Message-ID or Content-ID. + * + * @param string $name + * @param string|array $ids + */ + public function addIdHeader($name, $ids = null) + { + $this->storeHeader($name, $this->factory->createIdHeader($name, $ids)); + } - /** - * Add a new Path header with an address (path) in it. - * - * @param string $name - * @param string $path - */ - public function addPathHeader($name, $path = null) - { - $this->storeHeader($name, $this->factory->createPathHeader($name, $path)); - } + /** + * Add a new Path header with an address (path) in it. + * + * @param string $name + * @param string $path + */ + public function addPathHeader($name, $path = null) + { + $this->storeHeader($name, $this->factory->createPathHeader($name, $path)); + } - /** - * Returns true if at least one header with the given $name exists. - * - * If multiple headers match, the actual one may be specified by $index. - * - * @param string $name - * @param int $index - * - * @return bool - */ - public function has($name, $index = 0) - { - $lowerName = strtolower($name ?? ''); + /** + * Returns true if at least one header with the given $name exists. + * + * If multiple headers match, the actual one may be specified by $index. + * + * @param string $name + * @param int $index + * + * @return bool + */ + public function has($name, $index = 0) + { + $lowerName = strtolower($name ?? ''); - if (!\array_key_exists($lowerName, $this->headers)) { - return false; - } + if (!\array_key_exists($lowerName, $this->headers)) { + return false; + } - if (\func_num_args() < 2) { - // index was not specified, so we only need to check that there is at least one header value set - return (bool) \count($this->headers[$lowerName]); - } + if (\func_num_args() < 2) { + // index was not specified, so we only need to check that there is at least one header value set + return (bool) \count($this->headers[$lowerName]); + } - return \array_key_exists($index, $this->headers[$lowerName]); - } + return \array_key_exists($index, $this->headers[$lowerName]); + } - /** - * Set a header in the HeaderSet. - * - * The header may be a previously fetched header via {@link get()} or it may - * be one that has been created separately. - * - * If $index is specified, the header will be inserted into the set at this - * offset. - * - * @param int $index - */ - public function set(Swift_Mime_Header $header, $index = 0) - { - $this->storeHeader($header->getFieldName(), $header, $index); - } + /** + * Set a header in the HeaderSet. + * + * The header may be a previously fetched header via {@link get()} or it may + * be one that has been created separately. + * + * If $index is specified, the header will be inserted into the set at this + * offset. + * + * @param int $index + */ + public function set(Swift_Mime_Header $header, $index = 0) + { + $this->storeHeader($header->getFieldName(), $header, $index); + } - /** - * Get the header with the given $name. - * - * If multiple headers match, the actual one may be specified by $index. - * Returns NULL if none present. - * - * @param string $name - * @param int $index - * - * @return Swift_Mime_Header|null - */ - public function get($name, $index = 0) - { - $name = strtolower($name ?? ''); + /** + * Get the header with the given $name. + * + * If multiple headers match, the actual one may be specified by $index. + * Returns NULL if none present. + * + * @param string $name + * @param int $index + * + * @return Swift_Mime_Header|null + */ + public function get($name, $index = 0) + { + $name = strtolower($name ?? ''); - if (\func_num_args() < 2) { - if ($this->has($name)) { - $values = array_values($this->headers[$name]); + if (\func_num_args() < 2) { + if ($this->has($name)) { + $values = array_values($this->headers[$name]); - return array_shift($values); - } - } else { - if ($this->has($name, $index)) { - return $this->headers[$name][$index]; - } - } - } + return array_shift($values); + } + } else { + if ($this->has($name, $index)) { + return $this->headers[$name][$index]; + } + } + } - /** - * Get all headers with the given $name. - * - * @param string $name - * - * @return array - */ - public function getAll($name = null) - { - if (!isset($name)) { - $headers = []; - foreach ($this->headers as $collection) { - $headers = array_merge($headers, $collection); - } + /** + * Get all headers with the given $name. + * + * @param string $name + * + * @return array + */ + public function getAll($name = null) + { + if (!isset($name)) { + $headers = []; + foreach ($this->headers as $collection) { + $headers = array_merge($headers, $collection); + } - return $headers; - } + return $headers; + } - $lowerName = strtolower($name ?? ''); - if (!\array_key_exists($lowerName, $this->headers)) { - return []; - } + $lowerName = strtolower($name ?? ''); + if (!\array_key_exists($lowerName, $this->headers)) { + return []; + } - return $this->headers[$lowerName]; - } + return $this->headers[$lowerName]; + } - /** - * Return the name of all Headers. - * - * @return array - */ - public function listAll() - { - $headers = $this->headers; - if ($this->canSort()) { - uksort($headers, [$this, 'sortHeaders']); - } + /** + * Return the name of all Headers. + * + * @return array + */ + public function listAll() + { + $headers = $this->headers; + if ($this->canSort()) { + uksort($headers, [$this, 'sortHeaders']); + } - return array_keys($headers); - } + return array_keys($headers); + } - /** - * Remove the header with the given $name if it's set. - * - * If multiple headers match, the actual one may be specified by $index. - * - * @param string $name - * @param int $index - */ - public function remove($name, $index = 0) - { - $lowerName = strtolower($name ?? ''); - unset($this->headers[$lowerName][$index]); - } + /** + * Remove the header with the given $name if it's set. + * + * If multiple headers match, the actual one may be specified by $index. + * + * @param string $name + * @param int $index + */ + public function remove($name, $index = 0) + { + $lowerName = strtolower($name ?? ''); + unset($this->headers[$lowerName][$index]); + } - /** - * Remove all headers with the given $name. - * - * @param string $name - */ - public function removeAll($name) - { - $lowerName = strtolower($name ?? ''); - unset($this->headers[$lowerName]); - } + /** + * Remove all headers with the given $name. + * + * @param string $name + */ + public function removeAll($name) + { + $lowerName = strtolower($name ?? ''); + unset($this->headers[$lowerName]); + } - /** - * Define a list of Header names as an array in the correct order. - * - * These Headers will be output in the given order where present. - */ - public function defineOrdering(array $sequence) - { - $this->order = array_flip(array_map('strtolower', $sequence)); - } + /** + * Define a list of Header names as an array in the correct order. + * + * These Headers will be output in the given order where present. + */ + public function defineOrdering(array $sequence) + { + $this->order = array_flip(array_map('strtolower', $sequence)); + } - /** - * Set a list of header names which must always be displayed when set. - * - * Usually headers without a field value won't be output unless set here. - */ - public function setAlwaysDisplayed(array $names) - { - $this->required = array_flip(array_map('strtolower', $names)); - } + /** + * Set a list of header names which must always be displayed when set. + * + * Usually headers without a field value won't be output unless set here. + */ + public function setAlwaysDisplayed(array $names) + { + $this->required = array_flip(array_map('strtolower', $names)); + } - /** - * Notify this observer that the entity's charset has changed. - * - * @param string $charset - */ - public function charsetChanged($charset) - { - $this->setCharset($charset); - } + /** + * Notify this observer that the entity's charset has changed. + * + * @param string $charset + */ + public function charsetChanged($charset) + { + $this->setCharset($charset); + } - /** - * Returns a string with a representation of all headers. - * - * @return string - */ - public function toString() - { - $string = ''; - $headers = $this->headers; - if ($this->canSort()) { - uksort($headers, [$this, 'sortHeaders']); - } - foreach ($headers as $collection) { - foreach ($collection as $header) { - if ($this->isDisplayed($header) || '' != $header->getFieldBody()) { - $string .= $header->toString(); - } - } - } + /** + * Returns a string with a representation of all headers. + * + * @return string + */ + public function toString() + { + $string = ''; + $headers = $this->headers; + if ($this->canSort()) { + uksort($headers, [$this, 'sortHeaders']); + } + foreach ($headers as $collection) { + foreach ($collection as $header) { + if ($this->isDisplayed($header) || '' != $header->getFieldBody()) { + $string .= $header->toString(); + } + } + } - return $string; - } + return $string; + } - /** - * Returns a string representation of this object. - * - * @return string - * - * @see toString() - */ - public function __toString() - { - return $this->toString(); - } + /** + * Returns a string representation of this object. + * + * @return string + * + * @see toString() + */ + public function __toString() + { + return $this->toString(); + } - /** Save a Header to the internal collection */ - private function storeHeader($name, Swift_Mime_Header $header, $offset = null) - { - if (!isset($this->headers[strtolower($name ?? '')])) { - $this->headers[strtolower($name ?? '')] = []; - } - if (!isset($offset)) { - $this->headers[strtolower($name ?? '')][] = $header; - } else { - $this->headers[strtolower($name ?? '')][$offset] = $header; - } - } + /** Save a Header to the internal collection */ + private function storeHeader($name, Swift_Mime_Header $header, $offset = null) + { + if (!isset($this->headers[strtolower($name ?? '')])) { + $this->headers[strtolower($name ?? '')] = []; + } + if (!isset($offset)) { + $this->headers[strtolower($name ?? '')][] = $header; + } else { + $this->headers[strtolower($name ?? '')][$offset] = $header; + } + } - /** Test if the headers can be sorted */ - private function canSort() - { - return \count($this->order) > 0; - } + /** Test if the headers can be sorted */ + private function canSort() + { + return \count($this->order) > 0; + } - /** uksort() algorithm for Header ordering */ - private function sortHeaders($a, $b) - { - $lowerA = strtolower($a ?? ''); - $lowerB = strtolower($b ?? ''); - $aPos = \array_key_exists($lowerA, $this->order) ? $this->order[$lowerA] : -1; - $bPos = \array_key_exists($lowerB, $this->order) ? $this->order[$lowerB] : -1; + /** uksort() algorithm for Header ordering */ + private function sortHeaders($a, $b) + { + $lowerA = strtolower($a ?? ''); + $lowerB = strtolower($b ?? ''); + $aPos = \array_key_exists($lowerA, $this->order) ? $this->order[$lowerA] : -1; + $bPos = \array_key_exists($lowerB, $this->order) ? $this->order[$lowerB] : -1; - if (-1 === $aPos && -1 === $bPos) { - // just be sure to be determinist here - return $a > $b ? -1 : 1; - } + if (-1 === $aPos && -1 === $bPos) { + // just be sure to be determinist here + return $a > $b ? -1 : 1; + } - if (-1 == $aPos) { - return 1; - } elseif (-1 == $bPos) { - return -1; - } + if (-1 == $aPos) { + return 1; + } elseif (-1 == $bPos) { + return -1; + } - return $aPos < $bPos ? -1 : 1; - } + return $aPos < $bPos ? -1 : 1; + } - /** Test if the given Header is always displayed */ - private function isDisplayed(Swift_Mime_Header $header) - { - return \array_key_exists(strtolower($header->getFieldName() ?? ''), $this->required); - } + /** Test if the given Header is always displayed */ + private function isDisplayed(Swift_Mime_Header $header) + { + return \array_key_exists(strtolower($header->getFieldName() ?? ''), $this->required); + } - /** Notify all Headers of the new charset */ - private function notifyHeadersOfCharset($charset) - { - foreach ($this->headers as $headerGroup) { - foreach ($headerGroup as $header) { - $header->setCharset($charset); - } - } - } + /** Notify all Headers of the new charset */ + private function notifyHeadersOfCharset($charset) + { + foreach ($this->headers as $headerGroup) { + foreach ($headerGroup as $header) { + $header->setCharset($charset); + } + } + } - /** - * Make a deep copy of object. - */ - public function __clone() - { - $this->factory = clone $this->factory; - foreach ($this->headers as $groupKey => $headerGroup) { - foreach ($headerGroup as $key => $header) { - $this->headers[$groupKey][$key] = clone $header; - } - } - } + /** + * Make a deep copy of object. + */ + public function __clone() + { + $this->factory = clone $this->factory; + foreach ($this->headers as $groupKey => $headerGroup) { + foreach ($headerGroup as $key => $header) { + $this->headers[$groupKey][$key] = clone $header; + } + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleMessage.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleMessage.php index 1f87ce06452..62da1650a7b 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleMessage.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleMessage.php @@ -15,628 +15,628 @@ */ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart { - const PRIORITY_HIGHEST = 1; - const PRIORITY_HIGH = 2; - const PRIORITY_NORMAL = 3; - const PRIORITY_LOW = 4; - const PRIORITY_LOWEST = 5; - - /** - * Create a new SimpleMessage with $headers, $encoder and $cache. - * - * @param string $charset - */ - public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator, $charset = null) - { - parent::__construct($headers, $encoder, $cache, $idGenerator, $charset); - $this->getHeaders()->defineOrdering([ - 'Return-Path', - 'Received', - 'DKIM-Signature', - 'DomainKey-Signature', - 'Sender', - 'Message-ID', - 'Date', - 'Subject', - 'From', - 'Reply-To', - 'To', - 'Cc', - 'Bcc', - 'MIME-Version', - 'Content-Type', - 'Content-Transfer-Encoding', - ]); - $this->getHeaders()->setAlwaysDisplayed(['Date', 'Message-ID', 'From']); - $this->getHeaders()->addTextHeader('MIME-Version', '1.0'); - $this->setDate(new DateTimeImmutable()); - $this->setId($this->getId()); - $this->getHeaders()->addMailboxHeader('From'); - } - - /** - * Always returns {@link LEVEL_TOP} for a message instance. - * - * @return int - */ - public function getNestingLevel() - { - return self::LEVEL_TOP; - } - - /** - * Set the subject of this message. - * - * @param string $subject - * - * @return $this - */ - public function setSubject($subject) - { - if (!$this->setHeaderFieldModel('Subject', $subject)) { - $this->getHeaders()->addTextHeader('Subject', $subject); - } - - return $this; - } - - /** - * Get the subject of this message. - * - * @return string - */ - public function getSubject() - { - return $this->getHeaderFieldModel('Subject'); - } - - /** - * Set the date at which this message was created. - * - * @return $this - */ - public function setDate(DateTimeInterface $dateTime) - { - if (!$this->setHeaderFieldModel('Date', $dateTime)) { - $this->getHeaders()->addDateHeader('Date', $dateTime); - } - - return $this; - } - - /** - * Get the date at which this message was created. - * - * @return DateTimeInterface - */ - public function getDate() - { - return $this->getHeaderFieldModel('Date'); - } - - /** - * Set the return-path (the bounce address) of this message. - * - * @param string $address - * - * @return $this - */ - public function setReturnPath($address) - { - if (!$this->setHeaderFieldModel('Return-Path', $address)) { - $this->getHeaders()->addPathHeader('Return-Path', $address); - } - - return $this; - } - - /** - * Get the return-path (bounce address) of this message. - * - * @return string - */ - public function getReturnPath() - { - return $this->getHeaderFieldModel('Return-Path'); - } - - /** - * Set the sender of this message. - * - * This does not override the From field, but it has a higher significance. - * - * @param string $address - * @param string $name optional - * - * @return $this - */ - public function setSender($address, $name = null) - { - if (!\is_array($address) && isset($name)) { - $address = [$address => $name]; - } - - if (!$this->setHeaderFieldModel('Sender', (array) $address)) { - $this->getHeaders()->addMailboxHeader('Sender', (array) $address); - } - - return $this; - } - - /** - * Get the sender of this message. - * - * @return string - */ - public function getSender() - { - return $this->getHeaderFieldModel('Sender'); - } - - /** - * Add a From: address to this message. - * - * If $name is passed this name will be associated with the address. - * - * @param string $address - * @param string $name optional - * - * @return $this - */ - public function addFrom($address, $name = null) - { - $current = $this->getFrom(); - $current[$address] = $name; - - return $this->setFrom($current); - } - - /** - * Set the from address of this message. - * - * You may pass an array of addresses if this message is from multiple people. - * - * If $name is passed and the first parameter is a string, this name will be - * associated with the address. - * - * @param string|array $addresses - * @param string $name optional - * - * @return $this - */ - public function setFrom($addresses, $name = null) - { - if (!\is_array($addresses) && isset($name)) { - $addresses = [$addresses => $name]; - } - - if (!$this->setHeaderFieldModel('From', (array) $addresses)) { - $this->getHeaders()->addMailboxHeader('From', (array) $addresses); - } - - return $this; - } - - /** - * Get the from address of this message. - * - * @return mixed - */ - public function getFrom() - { - return $this->getHeaderFieldModel('From'); - } - - /** - * Add a Reply-To: address to this message. - * - * If $name is passed this name will be associated with the address. - * - * @param string $address - * @param string $name optional - * - * @return $this - */ - public function addReplyTo($address, $name = null) - { - $current = $this->getReplyTo(); - $current[$address] = $name; - - return $this->setReplyTo($current); - } - - /** - * Set the reply-to address of this message. - * - * You may pass an array of addresses if replies will go to multiple people. - * - * If $name is passed and the first parameter is a string, this name will be - * associated with the address. - * - * @param mixed $addresses - * @param string $name optional - * - * @return $this - */ - public function setReplyTo($addresses, $name = null) - { - if (!\is_array($addresses) && isset($name)) { - $addresses = [$addresses => $name]; - } - - if (!$this->setHeaderFieldModel('Reply-To', (array) $addresses)) { - $this->getHeaders()->addMailboxHeader('Reply-To', (array) $addresses); - } - - return $this; - } - - /** - * Get the reply-to address of this message. - * - * @return string - */ - public function getReplyTo() - { - return $this->getHeaderFieldModel('Reply-To'); - } - - /** - * Add a To: address to this message. - * - * If $name is passed this name will be associated with the address. - * - * @param string $address - * @param string $name optional - * - * @return $this - */ - public function addTo($address, $name = null) - { - $current = $this->getTo(); - $current[$address] = $name; - - return $this->setTo($current); - } - - /** - * Set the to addresses of this message. - * - * If multiple recipients will receive the message an array should be used. - * Example: array('receiver@domain.org', 'other@domain.org' => 'A name') - * - * If $name is passed and the first parameter is a string, this name will be - * associated with the address. - * - * @param mixed $addresses - * @param string $name optional - * - * @return $this - */ - public function setTo($addresses, $name = null) - { - if (!\is_array($addresses) && isset($name)) { - $addresses = [$addresses => $name]; - } - - if (!$this->setHeaderFieldModel('To', (array) $addresses)) { - $this->getHeaders()->addMailboxHeader('To', (array) $addresses); - } - - return $this; - } - - /** - * Get the To addresses of this message. - * - * @return array - */ - public function getTo() - { - return $this->getHeaderFieldModel('To'); - } - - /** - * Add a Cc: address to this message. - * - * If $name is passed this name will be associated with the address. - * - * @param string $address - * @param string $name optional - * - * @return $this - */ - public function addCc($address, $name = null) - { - $current = $this->getCc(); - $current[$address] = $name; - - return $this->setCc($current); - } - - /** - * Set the Cc addresses of this message. - * - * If $name is passed and the first parameter is a string, this name will be - * associated with the address. - * - * @param mixed $addresses - * @param string $name optional - * - * @return $this - */ - public function setCc($addresses, $name = null) - { - if (!\is_array($addresses) && isset($name)) { - $addresses = [$addresses => $name]; - } - - if (!$this->setHeaderFieldModel('Cc', (array) $addresses)) { - $this->getHeaders()->addMailboxHeader('Cc', (array) $addresses); - } - - return $this; - } - - /** - * Get the Cc address of this message. - * - * @return array - */ - public function getCc() - { - return $this->getHeaderFieldModel('Cc'); - } - - /** - * Add a Bcc: address to this message. - * - * If $name is passed this name will be associated with the address. - * - * @param string $address - * @param string $name optional - * - * @return $this - */ - public function addBcc($address, $name = null) - { - $current = $this->getBcc(); - $current[$address] = $name; - - return $this->setBcc($current); - } - - /** - * Set the Bcc addresses of this message. - * - * If $name is passed and the first parameter is a string, this name will be - * associated with the address. - * - * @param mixed $addresses - * @param string $name optional - * - * @return $this - */ - public function setBcc($addresses, $name = null) - { - if (!\is_array($addresses) && isset($name)) { - $addresses = [$addresses => $name]; - } - - if (!$this->setHeaderFieldModel('Bcc', (array) $addresses)) { - $this->getHeaders()->addMailboxHeader('Bcc', (array) $addresses); - } - - return $this; - } - - /** - * Get the Bcc addresses of this message. - * - * @return array - */ - public function getBcc() - { - return $this->getHeaderFieldModel('Bcc'); - } - - /** - * Set the priority of this message. - * - * The value is an integer where 1 is the highest priority and 5 is the lowest. - * - * @param int $priority - * - * @return $this - */ - public function setPriority($priority) - { - $priorityMap = [ - self::PRIORITY_HIGHEST => 'Highest', - self::PRIORITY_HIGH => 'High', - self::PRIORITY_NORMAL => 'Normal', - self::PRIORITY_LOW => 'Low', - self::PRIORITY_LOWEST => 'Lowest', - ]; - $pMapKeys = array_keys($priorityMap); - if ($priority > max($pMapKeys)) { - $priority = max($pMapKeys); - } elseif ($priority < min($pMapKeys)) { - $priority = min($pMapKeys); - } - if (!$this->setHeaderFieldModel('X-Priority', - sprintf('%d (%s)', $priority, $priorityMap[$priority]))) { - $this->getHeaders()->addTextHeader('X-Priority', - sprintf('%d (%s)', $priority, $priorityMap[$priority])); - } - - return $this; - } - - /** - * Get the priority of this message. - * - * The returned value is an integer where 1 is the highest priority and 5 - * is the lowest. - * - * @return int - */ - public function getPriority() - { - list($priority) = sscanf($this->getHeaderFieldModel('X-Priority'), - '%[1-5]' - ); - - return $priority ?? 3; - } - - /** - * Ask for a delivery receipt from the recipient to be sent to $addresses. - * - * @param array $addresses - * - * @return $this - */ - public function setReadReceiptTo($addresses) - { - if (!$this->setHeaderFieldModel('Disposition-Notification-To', $addresses)) { - $this->getHeaders() - ->addMailboxHeader('Disposition-Notification-To', $addresses); - } - - return $this; - } - - /** - * Get the addresses to which a read-receipt will be sent. - * - * @return string - */ - public function getReadReceiptTo() - { - return $this->getHeaderFieldModel('Disposition-Notification-To'); - } - - /** - * Attach a {@link Swift_Mime_SimpleMimeEntity} such as an Attachment or MimePart. - * - * @return $this - */ - public function attach(Swift_Mime_SimpleMimeEntity $entity) - { - $this->setChildren(array_merge($this->getChildren(), [$entity])); - - return $this; - } - - /** - * Remove an already attached entity. - * - * @return $this - */ - public function detach(Swift_Mime_SimpleMimeEntity $entity) - { - $newChildren = []; - foreach ($this->getChildren() as $child) { - if ($entity !== $child) { - $newChildren[] = $child; - } - } - $this->setChildren($newChildren); - - return $this; - } - - /** - * Attach a {@link Swift_Mime_SimpleMimeEntity} and return it's CID source. - * - * This method should be used when embedding images or other data in a message. - * - * @return string - */ - public function embed(Swift_Mime_SimpleMimeEntity $entity) - { - $this->attach($entity); - - return 'cid:'.$entity->getId(); - } - - /** - * Get this message as a complete string. - * - * @return string - */ - public function toString() - { - if (\count($children = $this->getChildren()) > 0 && '' != $this->getBody()) { - $this->setChildren(array_merge([$this->becomeMimePart()], $children)); - $string = parent::toString(); - $this->setChildren($children); - } else { - $string = parent::toString(); - } - - return $string; - } - - /** - * Returns a string representation of this object. - * - * @see toString() - * - * @return string - */ - public function __toString() - { - return $this->toString(); - } - - /** - * Write this message to a {@link Swift_InputByteStream}. - */ - public function toByteStream(Swift_InputByteStream $is) - { - if (\count($children = $this->getChildren()) > 0 && '' != $this->getBody()) { - $this->setChildren(array_merge([$this->becomeMimePart()], $children)); - parent::toByteStream($is); - $this->setChildren($children); - } else { - parent::toByteStream($is); - } - } - - /** @see Swift_Mime_SimpleMimeEntity::getIdField() */ - protected function getIdField() - { - return 'Message-ID'; - } - - /** Turn the body of this message into a child of itself if needed */ - protected function becomeMimePart() - { - $part = new parent($this->getHeaders()->newInstance(), $this->getEncoder(), - $this->getCache(), $this->getIdGenerator(), $this->userCharset - ); - $part->setContentType($this->userContentType); - $part->setBody($this->getBody()); - $part->setFormat($this->userFormat); - $part->setDelSp($this->userDelSp); - $part->setNestingLevel($this->getTopNestingLevel()); - - return $part; - } - - /** Get the highest nesting level nested inside this message */ - private function getTopNestingLevel() - { - $highestLevel = $this->getNestingLevel(); - foreach ($this->getChildren() as $child) { - $childLevel = $child->getNestingLevel(); - if ($highestLevel < $childLevel) { - $highestLevel = $childLevel; - } - } - - return $highestLevel; - } + const PRIORITY_HIGHEST = 1; + const PRIORITY_HIGH = 2; + const PRIORITY_NORMAL = 3; + const PRIORITY_LOW = 4; + const PRIORITY_LOWEST = 5; + + /** + * Create a new SimpleMessage with $headers, $encoder and $cache. + * + * @param string $charset + */ + public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator, $charset = null) + { + parent::__construct($headers, $encoder, $cache, $idGenerator, $charset); + $this->getHeaders()->defineOrdering([ + 'Return-Path', + 'Received', + 'DKIM-Signature', + 'DomainKey-Signature', + 'Sender', + 'Message-ID', + 'Date', + 'Subject', + 'From', + 'Reply-To', + 'To', + 'Cc', + 'Bcc', + 'MIME-Version', + 'Content-Type', + 'Content-Transfer-Encoding', + ]); + $this->getHeaders()->setAlwaysDisplayed(['Date', 'Message-ID', 'From']); + $this->getHeaders()->addTextHeader('MIME-Version', '1.0'); + $this->setDate(new DateTimeImmutable()); + $this->setId($this->getId()); + $this->getHeaders()->addMailboxHeader('From'); + } + + /** + * Always returns {@link LEVEL_TOP} for a message instance. + * + * @return int + */ + public function getNestingLevel() + { + return self::LEVEL_TOP; + } + + /** + * Set the subject of this message. + * + * @param string $subject + * + * @return $this + */ + public function setSubject($subject) + { + if (!$this->setHeaderFieldModel('Subject', $subject)) { + $this->getHeaders()->addTextHeader('Subject', $subject); + } + + return $this; + } + + /** + * Get the subject of this message. + * + * @return string + */ + public function getSubject() + { + return $this->getHeaderFieldModel('Subject'); + } + + /** + * Set the date at which this message was created. + * + * @return $this + */ + public function setDate(DateTimeInterface $dateTime) + { + if (!$this->setHeaderFieldModel('Date', $dateTime)) { + $this->getHeaders()->addDateHeader('Date', $dateTime); + } + + return $this; + } + + /** + * Get the date at which this message was created. + * + * @return DateTimeInterface + */ + public function getDate() + { + return $this->getHeaderFieldModel('Date'); + } + + /** + * Set the return-path (the bounce address) of this message. + * + * @param string $address + * + * @return $this + */ + public function setReturnPath($address) + { + if (!$this->setHeaderFieldModel('Return-Path', $address)) { + $this->getHeaders()->addPathHeader('Return-Path', $address); + } + + return $this; + } + + /** + * Get the return-path (bounce address) of this message. + * + * @return string + */ + public function getReturnPath() + { + return $this->getHeaderFieldModel('Return-Path'); + } + + /** + * Set the sender of this message. + * + * This does not override the From field, but it has a higher significance. + * + * @param string $address + * @param string $name optional + * + * @return $this + */ + public function setSender($address, $name = null) + { + if (!\is_array($address) && isset($name)) { + $address = [$address => $name]; + } + + if (!$this->setHeaderFieldModel('Sender', (array) $address)) { + $this->getHeaders()->addMailboxHeader('Sender', (array) $address); + } + + return $this; + } + + /** + * Get the sender of this message. + * + * @return string + */ + public function getSender() + { + return $this->getHeaderFieldModel('Sender'); + } + + /** + * Add a From: address to this message. + * + * If $name is passed this name will be associated with the address. + * + * @param string $address + * @param string $name optional + * + * @return $this + */ + public function addFrom($address, $name = null) + { + $current = $this->getFrom(); + $current[$address] = $name; + + return $this->setFrom($current); + } + + /** + * Set the from address of this message. + * + * You may pass an array of addresses if this message is from multiple people. + * + * If $name is passed and the first parameter is a string, this name will be + * associated with the address. + * + * @param string|array $addresses + * @param string $name optional + * + * @return $this + */ + public function setFrom($addresses, $name = null) + { + if (!\is_array($addresses) && isset($name)) { + $addresses = [$addresses => $name]; + } + + if (!$this->setHeaderFieldModel('From', (array) $addresses)) { + $this->getHeaders()->addMailboxHeader('From', (array) $addresses); + } + + return $this; + } + + /** + * Get the from address of this message. + * + * @return mixed + */ + public function getFrom() + { + return $this->getHeaderFieldModel('From'); + } + + /** + * Add a Reply-To: address to this message. + * + * If $name is passed this name will be associated with the address. + * + * @param string $address + * @param string $name optional + * + * @return $this + */ + public function addReplyTo($address, $name = null) + { + $current = $this->getReplyTo(); + $current[$address] = $name; + + return $this->setReplyTo($current); + } + + /** + * Set the reply-to address of this message. + * + * You may pass an array of addresses if replies will go to multiple people. + * + * If $name is passed and the first parameter is a string, this name will be + * associated with the address. + * + * @param mixed $addresses + * @param string $name optional + * + * @return $this + */ + public function setReplyTo($addresses, $name = null) + { + if (!\is_array($addresses) && isset($name)) { + $addresses = [$addresses => $name]; + } + + if (!$this->setHeaderFieldModel('Reply-To', (array) $addresses)) { + $this->getHeaders()->addMailboxHeader('Reply-To', (array) $addresses); + } + + return $this; + } + + /** + * Get the reply-to address of this message. + * + * @return string + */ + public function getReplyTo() + { + return $this->getHeaderFieldModel('Reply-To'); + } + + /** + * Add a To: address to this message. + * + * If $name is passed this name will be associated with the address. + * + * @param string $address + * @param string $name optional + * + * @return $this + */ + public function addTo($address, $name = null) + { + $current = $this->getTo(); + $current[$address] = $name; + + return $this->setTo($current); + } + + /** + * Set the to addresses of this message. + * + * If multiple recipients will receive the message an array should be used. + * Example: array('receiver@domain.org', 'other@domain.org' => 'A name') + * + * If $name is passed and the first parameter is a string, this name will be + * associated with the address. + * + * @param mixed $addresses + * @param string $name optional + * + * @return $this + */ + public function setTo($addresses, $name = null) + { + if (!\is_array($addresses) && isset($name)) { + $addresses = [$addresses => $name]; + } + + if (!$this->setHeaderFieldModel('To', (array) $addresses)) { + $this->getHeaders()->addMailboxHeader('To', (array) $addresses); + } + + return $this; + } + + /** + * Get the To addresses of this message. + * + * @return array + */ + public function getTo() + { + return $this->getHeaderFieldModel('To'); + } + + /** + * Add a Cc: address to this message. + * + * If $name is passed this name will be associated with the address. + * + * @param string $address + * @param string $name optional + * + * @return $this + */ + public function addCc($address, $name = null) + { + $current = $this->getCc(); + $current[$address] = $name; + + return $this->setCc($current); + } + + /** + * Set the Cc addresses of this message. + * + * If $name is passed and the first parameter is a string, this name will be + * associated with the address. + * + * @param mixed $addresses + * @param string $name optional + * + * @return $this + */ + public function setCc($addresses, $name = null) + { + if (!\is_array($addresses) && isset($name)) { + $addresses = [$addresses => $name]; + } + + if (!$this->setHeaderFieldModel('Cc', (array) $addresses)) { + $this->getHeaders()->addMailboxHeader('Cc', (array) $addresses); + } + + return $this; + } + + /** + * Get the Cc address of this message. + * + * @return array + */ + public function getCc() + { + return $this->getHeaderFieldModel('Cc'); + } + + /** + * Add a Bcc: address to this message. + * + * If $name is passed this name will be associated with the address. + * + * @param string $address + * @param string $name optional + * + * @return $this + */ + public function addBcc($address, $name = null) + { + $current = $this->getBcc(); + $current[$address] = $name; + + return $this->setBcc($current); + } + + /** + * Set the Bcc addresses of this message. + * + * If $name is passed and the first parameter is a string, this name will be + * associated with the address. + * + * @param mixed $addresses + * @param string $name optional + * + * @return $this + */ + public function setBcc($addresses, $name = null) + { + if (!\is_array($addresses) && isset($name)) { + $addresses = [$addresses => $name]; + } + + if (!$this->setHeaderFieldModel('Bcc', (array) $addresses)) { + $this->getHeaders()->addMailboxHeader('Bcc', (array) $addresses); + } + + return $this; + } + + /** + * Get the Bcc addresses of this message. + * + * @return array + */ + public function getBcc() + { + return $this->getHeaderFieldModel('Bcc'); + } + + /** + * Set the priority of this message. + * + * The value is an integer where 1 is the highest priority and 5 is the lowest. + * + * @param int $priority + * + * @return $this + */ + public function setPriority($priority) + { + $priorityMap = [ + self::PRIORITY_HIGHEST => 'Highest', + self::PRIORITY_HIGH => 'High', + self::PRIORITY_NORMAL => 'Normal', + self::PRIORITY_LOW => 'Low', + self::PRIORITY_LOWEST => 'Lowest', + ]; + $pMapKeys = array_keys($priorityMap); + if ($priority > max($pMapKeys)) { + $priority = max($pMapKeys); + } elseif ($priority < min($pMapKeys)) { + $priority = min($pMapKeys); + } + if (!$this->setHeaderFieldModel('X-Priority', + sprintf('%d (%s)', $priority, $priorityMap[$priority]))) { + $this->getHeaders()->addTextHeader('X-Priority', + sprintf('%d (%s)', $priority, $priorityMap[$priority])); + } + + return $this; + } + + /** + * Get the priority of this message. + * + * The returned value is an integer where 1 is the highest priority and 5 + * is the lowest. + * + * @return int + */ + public function getPriority() + { + list($priority) = sscanf($this->getHeaderFieldModel('X-Priority'), + '%[1-5]' + ); + + return $priority ?? 3; + } + + /** + * Ask for a delivery receipt from the recipient to be sent to $addresses. + * + * @param array $addresses + * + * @return $this + */ + public function setReadReceiptTo($addresses) + { + if (!$this->setHeaderFieldModel('Disposition-Notification-To', $addresses)) { + $this->getHeaders() + ->addMailboxHeader('Disposition-Notification-To', $addresses); + } + + return $this; + } + + /** + * Get the addresses to which a read-receipt will be sent. + * + * @return string + */ + public function getReadReceiptTo() + { + return $this->getHeaderFieldModel('Disposition-Notification-To'); + } + + /** + * Attach a {@link Swift_Mime_SimpleMimeEntity} such as an Attachment or MimePart. + * + * @return $this + */ + public function attach(Swift_Mime_SimpleMimeEntity $entity) + { + $this->setChildren(array_merge($this->getChildren(), [$entity])); + + return $this; + } + + /** + * Remove an already attached entity. + * + * @return $this + */ + public function detach(Swift_Mime_SimpleMimeEntity $entity) + { + $newChildren = []; + foreach ($this->getChildren() as $child) { + if ($entity !== $child) { + $newChildren[] = $child; + } + } + $this->setChildren($newChildren); + + return $this; + } + + /** + * Attach a {@link Swift_Mime_SimpleMimeEntity} and return it's CID source. + * + * This method should be used when embedding images or other data in a message. + * + * @return string + */ + public function embed(Swift_Mime_SimpleMimeEntity $entity) + { + $this->attach($entity); + + return 'cid:'.$entity->getId(); + } + + /** + * Get this message as a complete string. + * + * @return string + */ + public function toString() + { + if (\count($children = $this->getChildren()) > 0 && '' != $this->getBody()) { + $this->setChildren(array_merge([$this->becomeMimePart()], $children)); + $string = parent::toString(); + $this->setChildren($children); + } else { + $string = parent::toString(); + } + + return $string; + } + + /** + * Returns a string representation of this object. + * + * @see toString() + * + * @return string + */ + public function __toString() + { + return $this->toString(); + } + + /** + * Write this message to a {@link Swift_InputByteStream}. + */ + public function toByteStream(Swift_InputByteStream $is) + { + if (\count($children = $this->getChildren()) > 0 && '' != $this->getBody()) { + $this->setChildren(array_merge([$this->becomeMimePart()], $children)); + parent::toByteStream($is); + $this->setChildren($children); + } else { + parent::toByteStream($is); + } + } + + /** @see Swift_Mime_SimpleMimeEntity::getIdField() */ + protected function getIdField() + { + return 'Message-ID'; + } + + /** Turn the body of this message into a child of itself if needed */ + protected function becomeMimePart() + { + $part = new parent($this->getHeaders()->newInstance(), $this->getEncoder(), + $this->getCache(), $this->getIdGenerator(), $this->userCharset + ); + $part->setContentType($this->userContentType); + $part->setBody($this->getBody()); + $part->setFormat($this->userFormat); + $part->setDelSp($this->userDelSp); + $part->setNestingLevel($this->getTopNestingLevel()); + + return $part; + } + + /** Get the highest nesting level nested inside this message */ + private function getTopNestingLevel() + { + $highestLevel = $this->getNestingLevel(); + foreach ($this->getChildren() as $child) { + $childLevel = $child->getNestingLevel(); + if ($highestLevel < $childLevel) { + $highestLevel = $childLevel; + } + } + + return $highestLevel; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php index 668d076fb32..03eaf472dd5 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php @@ -15,812 +15,812 @@ */ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_Mime_EncodingObserver { - /** Main message document; there can only be one of these */ - const LEVEL_TOP = 16; - - /** An entity which nests with the same precedence as an attachment */ - const LEVEL_MIXED = 256; - - /** An entity which nests with the same precedence as a mime part */ - const LEVEL_ALTERNATIVE = 4096; - - /** An entity which nests with the same precedence as embedded content */ - const LEVEL_RELATED = 65536; - - /** A collection of Headers for this mime entity */ - private $headers; - - /** The body as a string, or a stream */ - private $body; - - /** The encoder that encodes the body into a streamable format */ - private $encoder; - - /** Message ID generator */ - private $idGenerator; - - /** A mime boundary, if any is used */ - private $boundary; - - /** Mime types to be used based on the nesting level */ - private $compositeRanges = [ - 'multipart/mixed' => [self::LEVEL_TOP, self::LEVEL_MIXED], - 'multipart/alternative' => [self::LEVEL_MIXED, self::LEVEL_ALTERNATIVE], - 'multipart/related' => [self::LEVEL_ALTERNATIVE, self::LEVEL_RELATED], - ]; - - /** A set of filter rules to define what level an entity should be nested at */ - private $compoundLevelFilters = []; - - /** The nesting level of this entity */ - private $nestingLevel = self::LEVEL_ALTERNATIVE; - - /** A KeyCache instance used during encoding and streaming */ - private $cache; - - /** Direct descendants of this entity */ - private $immediateChildren = []; - - /** All descendants of this entity */ - private $children = []; - - /** The maximum line length of the body of this entity */ - private $maxLineLength = 78; - - /** The order in which alternative mime types should appear */ - private $alternativePartOrder = [ - 'text/plain' => 1, - 'text/html' => 2, - 'multipart/related' => 3, - ]; - - /** The CID of this entity */ - private $id; - - /** The key used for accessing the cache */ - private $cacheKey; - - protected $userContentType; - - /** - * Create a new SimpleMimeEntity with $headers, $encoder and $cache. - */ - public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator) - { - $this->cacheKey = bin2hex(random_bytes(16)); // set 32 hex values - $this->cache = $cache; - $this->headers = $headers; - $this->idGenerator = $idGenerator; - $this->setEncoder($encoder); - $this->headers->defineOrdering(['Content-Type', 'Content-Transfer-Encoding']); - - // This array specifies that, when the entire MIME document contains - // $compoundLevel, then for each child within $level, if its Content-Type - // is $contentType then it should be treated as if it's level is - // $neededLevel instead. I tried to write that unambiguously! :-\ - // Data Structure: - // array ( - // $compoundLevel => array( - // $level => array( - // $contentType => $neededLevel - // ) - // ) - // ) - - $this->compoundLevelFilters = [ - (self::LEVEL_ALTERNATIVE + self::LEVEL_RELATED) => [ - self::LEVEL_ALTERNATIVE => [ - 'text/plain' => self::LEVEL_ALTERNATIVE, - 'text/html' => self::LEVEL_RELATED, - ], - ], - ]; - - $this->id = $this->idGenerator->generateId(); - } - - /** - * Generate a new Content-ID or Message-ID for this MIME entity. - * - * @return string - */ - public function generateId() - { - $this->setId($this->idGenerator->generateId()); - - return $this->id; - } - - /** - * Get the {@link Swift_Mime_SimpleHeaderSet} for this entity. - * - * @return Swift_Mime_SimpleHeaderSet - */ - public function getHeaders() - { - return $this->headers; - } - - /** - * Get the nesting level of this entity. - * - * @see LEVEL_TOP, LEVEL_MIXED, LEVEL_RELATED, LEVEL_ALTERNATIVE - * - * @return int - */ - public function getNestingLevel() - { - return $this->nestingLevel; - } - - /** - * Get the Content-type of this entity. - * - * @return string - */ - public function getContentType() - { - return $this->getHeaderFieldModel('Content-Type'); - } - - /** - * Get the Body Content-type of this entity. - * - * @return string - */ - public function getBodyContentType() - { - return $this->userContentType; - } - - /** - * Set the Content-type of this entity. - * - * @param string $type - * - * @return $this - */ - public function setContentType($type) - { - $this->setContentTypeInHeaders($type); - // Keep track of the value so that if the content-type changes automatically - // due to added child entities, it can be restored if they are later removed - $this->userContentType = $type; - - return $this; - } - - /** - * Get the CID of this entity. - * - * The CID will only be present in headers if a Content-ID header is present. - * - * @return string - */ - public function getId() - { - $tmp = (array) $this->getHeaderFieldModel($this->getIdField()); - - return $this->headers->has($this->getIdField()) ? current($tmp) : $this->id; - } - - /** - * Set the CID of this entity. - * - * @param string $id - * - * @return $this - */ - public function setId($id) - { - if (!$this->setHeaderFieldModel($this->getIdField(), $id)) { - $this->headers->addIdHeader($this->getIdField(), $id); - } - $this->id = $id; - - return $this; - } - - /** - * Get the description of this entity. - * - * This value comes from the Content-Description header if set. - * - * @return string - */ - public function getDescription() - { - return $this->getHeaderFieldModel('Content-Description'); - } - - /** - * Set the description of this entity. - * - * This method sets a value in the Content-ID header. - * - * @param string $description - * - * @return $this - */ - public function setDescription($description) - { - if (!$this->setHeaderFieldModel('Content-Description', $description)) { - $this->headers->addTextHeader('Content-Description', $description); - } - - return $this; - } - - /** - * Get the maximum line length of the body of this entity. - * - * @return int - */ - public function getMaxLineLength() - { - return $this->maxLineLength; - } - - /** - * Set the maximum line length of lines in this body. - * - * Though not enforced by the library, lines should not exceed 1000 chars. - * - * @param int $length - * - * @return $this - */ - public function setMaxLineLength($length) - { - $this->maxLineLength = $length; - - return $this; - } - - /** - * Get all children added to this entity. - * - * @return Swift_Mime_SimpleMimeEntity[] - */ - public function getChildren() - { - return $this->children; - } - - /** - * Set all children of this entity. - * - * @param Swift_Mime_SimpleMimeEntity[] $children - * @param int $compoundLevel For internal use only - * - * @return $this - */ - public function setChildren(array $children, $compoundLevel = null) - { - // TODO: Try to refactor this logic - $compoundLevel = $compoundLevel ?? $this->getCompoundLevel($children); - $immediateChildren = []; - $grandchildren = []; - $newContentType = $this->userContentType; - - foreach ($children as $child) { - $level = $this->getNeededChildLevel($child, $compoundLevel); - if (empty($immediateChildren)) { - //first iteration - $immediateChildren = [$child]; - } else { - $nextLevel = $this->getNeededChildLevel($immediateChildren[0], $compoundLevel); - if ($nextLevel == $level) { - $immediateChildren[] = $child; - } elseif ($level < $nextLevel) { - // Re-assign immediateChildren to grandchildren - $grandchildren = array_merge($grandchildren, $immediateChildren); - // Set new children - $immediateChildren = [$child]; - } else { - $grandchildren[] = $child; - } - } - } - - if ($immediateChildren) { - $lowestLevel = $this->getNeededChildLevel($immediateChildren[0], $compoundLevel); - - // Determine which composite media type is needed to accommodate the - // immediate children - foreach ($this->compositeRanges as $mediaType => $range) { - if ($lowestLevel > $range[0] && $lowestLevel <= $range[1]) { - $newContentType = $mediaType; - - break; - } - } - - // Put any grandchildren in a subpart - if (!empty($grandchildren)) { - $subentity = $this->createChild(); - $subentity->setNestingLevel($lowestLevel); - $subentity->setChildren($grandchildren, $compoundLevel); - array_unshift($immediateChildren, $subentity); - } - } - - $this->immediateChildren = $immediateChildren; - $this->children = $children; - $this->setContentTypeInHeaders($newContentType); - $this->fixHeaders(); - $this->sortChildren(); - - return $this; - } - - /** - * Get the body of this entity as a string. - * - * @return string - */ - public function getBody() - { - return $this->body instanceof Swift_OutputByteStream ? $this->readStream($this->body) : $this->body; - } - - /** - * Set the body of this entity, either as a string, or as an instance of - * {@link Swift_OutputByteStream}. - * - * @param mixed $body - * @param string $contentType optional - * - * @return $this - */ - public function setBody($body, $contentType = null) - { - if ($body !== $this->body) { - $this->clearCache(); - } - - $this->body = $body; - if (null !== $contentType) { - $this->setContentType($contentType); - } - - return $this; - } - - /** - * Get the encoder used for the body of this entity. - * - * @return Swift_Mime_ContentEncoder - */ - public function getEncoder() - { - return $this->encoder; - } - - /** - * Set the encoder used for the body of this entity. - * - * @return $this - */ - public function setEncoder(Swift_Mime_ContentEncoder $encoder) - { - if ($encoder !== $this->encoder) { - $this->clearCache(); - } - - $this->encoder = $encoder; - $this->setEncoding($encoder->getName()); - $this->notifyEncoderChanged($encoder); - - return $this; - } - - /** - * Get the boundary used to separate children in this entity. - * - * @return string - */ - public function getBoundary() - { - if (!isset($this->boundary)) { - $this->boundary = '_=_swift_'.time().'_'.bin2hex(random_bytes(16)).'_=_'; - } - - return $this->boundary; - } - - /** - * Set the boundary used to separate children in this entity. - * - * @param string $boundary - * - * @throws Swift_RfcComplianceException - * - * @return $this - */ - public function setBoundary($boundary) - { - $this->assertValidBoundary($boundary); - $this->boundary = $boundary; - - return $this; - } - - /** - * Receive notification that the charset of this entity, or a parent entity - * has changed. - * - * @param string $charset - */ - public function charsetChanged($charset) - { - $this->notifyCharsetChanged($charset); - } - - /** - * Receive notification that the encoder of this entity or a parent entity - * has changed. - */ - public function encoderChanged(Swift_Mime_ContentEncoder $encoder) - { - $this->notifyEncoderChanged($encoder); - } - - /** - * Get this entire entity as a string. - * - * @return string - */ - public function toString() - { - $string = $this->headers->toString(); - $string .= $this->bodyToString(); - - return $string; - } - - /** - * Get this entire entity as a string. - * - * @return string - */ - protected function bodyToString() - { - $string = ''; - - if (isset($this->body) && empty($this->immediateChildren)) { - if ($this->cache->hasKey($this->cacheKey, 'body')) { - $body = $this->cache->getString($this->cacheKey, 'body'); - } else { - $body = "\r\n".$this->encoder->encodeString($this->getBody(), 0, $this->getMaxLineLength()); - $this->cache->setString($this->cacheKey, 'body', $body, Swift_KeyCache::MODE_WRITE); - } - $string .= $body; - } - - if (!empty($this->immediateChildren)) { - foreach ($this->immediateChildren as $child) { - $string .= "\r\n\r\n--".$this->getBoundary()."\r\n"; - $string .= $child->toString(); - } - $string .= "\r\n\r\n--".$this->getBoundary()."--\r\n"; - } - - return $string; - } - - /** - * Returns a string representation of this object. - * - * @see toString() - * - * @return string - */ - public function __toString() - { - return $this->toString(); - } - - /** - * Write this entire entity to a {@see Swift_InputByteStream}. - */ - public function toByteStream(Swift_InputByteStream $is) - { - $is->write($this->headers->toString()); - $is->commit(); - - $this->bodyToByteStream($is); - } - - /** - * Write this entire entity to a {@link Swift_InputByteStream}. - */ - protected function bodyToByteStream(Swift_InputByteStream $is) - { - if (empty($this->immediateChildren)) { - if (isset($this->body)) { - if ($this->cache->hasKey($this->cacheKey, 'body')) { - $this->cache->exportToByteStream($this->cacheKey, 'body', $is); - } else { - $cacheIs = $this->cache->getInputByteStream($this->cacheKey, 'body'); - if ($cacheIs) { - $is->bind($cacheIs); - } - - $is->write("\r\n"); - - if ($this->body instanceof Swift_OutputByteStream) { - $this->body->setReadPointer(0); - - $this->encoder->encodeByteStream($this->body, $is, 0, $this->getMaxLineLength()); - } else { - $is->write($this->encoder->encodeString($this->getBody(), 0, $this->getMaxLineLength())); - } - - if ($cacheIs) { - $is->unbind($cacheIs); - } - } - } - } - - if (!empty($this->immediateChildren)) { - foreach ($this->immediateChildren as $child) { - $is->write("\r\n\r\n--".$this->getBoundary()."\r\n"); - $child->toByteStream($is); - } - $is->write("\r\n\r\n--".$this->getBoundary()."--\r\n"); - } - } - - /** - * Get the name of the header that provides the ID of this entity. - */ - protected function getIdField() - { - return 'Content-ID'; - } - - /** - * Get the model data (usually an array or a string) for $field. - */ - protected function getHeaderFieldModel($field) - { - if ($this->headers->has($field)) { - return $this->headers->get($field)->getFieldBodyModel(); - } - } - - /** - * Set the model data for $field. - */ - protected function setHeaderFieldModel($field, $model) - { - if ($this->headers->has($field)) { - $this->headers->get($field)->setFieldBodyModel($model); - - return true; - } - - return false; - } - - /** - * Get the parameter value of $parameter on $field header. - */ - protected function getHeaderParameter($field, $parameter) - { - if ($this->headers->has($field)) { - return $this->headers->get($field)->getParameter($parameter); - } - } - - /** - * Set the parameter value of $parameter on $field header. - */ - protected function setHeaderParameter($field, $parameter, $value) - { - if ($this->headers->has($field)) { - $this->headers->get($field)->setParameter($parameter, $value); - - return true; - } - - return false; - } - - /** - * Re-evaluate what content type and encoding should be used on this entity. - */ - protected function fixHeaders() - { - if (\count($this->immediateChildren)) { - $this->setHeaderParameter('Content-Type', 'boundary', - $this->getBoundary() - ); - $this->headers->remove('Content-Transfer-Encoding'); - } else { - $this->setHeaderParameter('Content-Type', 'boundary', null); - $this->setEncoding($this->encoder->getName()); - } - } - - /** - * Get the KeyCache used in this entity. - * - * @return Swift_KeyCache - */ - protected function getCache() - { - return $this->cache; - } - - /** - * Get the ID generator. - * - * @return Swift_IdGenerator - */ - protected function getIdGenerator() - { - return $this->idGenerator; - } - - /** - * Empty the KeyCache for this entity. - */ - protected function clearCache() - { - $this->cache->clearKey($this->cacheKey, 'body'); - } - - private function readStream(Swift_OutputByteStream $os) - { - $string = ''; - while (false !== $bytes = $os->read(8192)) { - $string .= $bytes; - } - - $os->setReadPointer(0); - - return $string; - } - - private function setEncoding($encoding) - { - if (!$this->setHeaderFieldModel('Content-Transfer-Encoding', $encoding)) { - $this->headers->addTextHeader('Content-Transfer-Encoding', $encoding); - } - } - - private function assertValidBoundary($boundary) - { - if (!preg_match('/^[a-z0-9\'\(\)\+_\-,\.\/:=\?\ ]{0,69}[a-z0-9\'\(\)\+_\-,\.\/:=\?]$/Di', $boundary)) { - throw new Swift_RfcComplianceException('Mime boundary set is not RFC 2046 compliant.'); - } - } - - private function setContentTypeInHeaders($type) - { - if (!$this->setHeaderFieldModel('Content-Type', $type)) { - $this->headers->addParameterizedHeader('Content-Type', $type); - } - } - - private function setNestingLevel($level) - { - $this->nestingLevel = $level; - } - - private function getCompoundLevel($children) - { - $level = 0; - foreach ($children as $child) { - $level |= $child->getNestingLevel(); - } - - return $level; - } - - private function getNeededChildLevel($child, $compoundLevel) - { - $filter = []; - foreach ($this->compoundLevelFilters as $bitmask => $rules) { - if (($compoundLevel & $bitmask) === $bitmask) { - $filter = $rules + $filter; - } - } - - $realLevel = $child->getNestingLevel(); - $lowercaseType = strtolower($child->getContentType() ?? ''); - - if (isset($filter[$realLevel]) && isset($filter[$realLevel][$lowercaseType])) { - return $filter[$realLevel][$lowercaseType]; - } - - return $realLevel; - } - - private function createChild() - { - return new self($this->headers->newInstance(), $this->encoder, $this->cache, $this->idGenerator); - } - - private function notifyEncoderChanged(Swift_Mime_ContentEncoder $encoder) - { - foreach ($this->immediateChildren as $child) { - $child->encoderChanged($encoder); - } - } - - private function notifyCharsetChanged($charset) - { - $this->encoder->charsetChanged($charset); - $this->headers->charsetChanged($charset); - foreach ($this->immediateChildren as $child) { - $child->charsetChanged($charset); - } - } - - private function sortChildren() - { - $shouldSort = false; - foreach ($this->immediateChildren as $child) { - // NOTE: This include alternative parts moved into a related part - if (self::LEVEL_ALTERNATIVE == $child->getNestingLevel()) { - $shouldSort = true; - break; - } - } - - // Sort in order of preference, if there is one - if ($shouldSort) { - // Group the messages by order of preference - $sorted = []; - foreach ($this->immediateChildren as $child) { - $type = $child->getContentType(); - $level = \array_key_exists($type, $this->alternativePartOrder) ? $this->alternativePartOrder[$type] : max($this->alternativePartOrder) + 1; - - if (empty($sorted[$level])) { - $sorted[$level] = []; - } - - $sorted[$level][] = $child; - } - - ksort($sorted); - - $this->immediateChildren = array_reduce($sorted, 'array_merge', []); - } - } - - /** - * Empties it's own contents from the cache. - */ - public function __destruct() - { - if ($this->cache instanceof Swift_KeyCache) { - $this->cache->clearAll($this->cacheKey); - } - } - - /** - * Make a deep copy of object. - */ - public function __clone() - { - $this->headers = clone $this->headers; - $this->encoder = clone $this->encoder; - $this->cacheKey = bin2hex(random_bytes(16)); // set 32 hex values - $children = []; - foreach ($this->children as $pos => $child) { - $children[$pos] = clone $child; - } - $this->setChildren($children); - } - - public function __wakeup() - { - $this->cacheKey = bin2hex(random_bytes(16)); // set 32 hex values - $this->cache = new Swift_KeyCache_ArrayKeyCache(new Swift_KeyCache_SimpleKeyCacheInputStream()); - } + /** Main message document; there can only be one of these */ + const LEVEL_TOP = 16; + + /** An entity which nests with the same precedence as an attachment */ + const LEVEL_MIXED = 256; + + /** An entity which nests with the same precedence as a mime part */ + const LEVEL_ALTERNATIVE = 4096; + + /** An entity which nests with the same precedence as embedded content */ + const LEVEL_RELATED = 65536; + + /** A collection of Headers for this mime entity */ + private $headers; + + /** The body as a string, or a stream */ + private $body; + + /** The encoder that encodes the body into a streamable format */ + private $encoder; + + /** Message ID generator */ + private $idGenerator; + + /** A mime boundary, if any is used */ + private $boundary; + + /** Mime types to be used based on the nesting level */ + private $compositeRanges = [ + 'multipart/mixed' => [self::LEVEL_TOP, self::LEVEL_MIXED], + 'multipart/alternative' => [self::LEVEL_MIXED, self::LEVEL_ALTERNATIVE], + 'multipart/related' => [self::LEVEL_ALTERNATIVE, self::LEVEL_RELATED], + ]; + + /** A set of filter rules to define what level an entity should be nested at */ + private $compoundLevelFilters = []; + + /** The nesting level of this entity */ + private $nestingLevel = self::LEVEL_ALTERNATIVE; + + /** A KeyCache instance used during encoding and streaming */ + private $cache; + + /** Direct descendants of this entity */ + private $immediateChildren = []; + + /** All descendants of this entity */ + private $children = []; + + /** The maximum line length of the body of this entity */ + private $maxLineLength = 78; + + /** The order in which alternative mime types should appear */ + private $alternativePartOrder = [ + 'text/plain' => 1, + 'text/html' => 2, + 'multipart/related' => 3, + ]; + + /** The CID of this entity */ + private $id; + + /** The key used for accessing the cache */ + private $cacheKey; + + protected $userContentType; + + /** + * Create a new SimpleMimeEntity with $headers, $encoder and $cache. + */ + public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator) + { + $this->cacheKey = bin2hex(random_bytes(16)); // set 32 hex values + $this->cache = $cache; + $this->headers = $headers; + $this->idGenerator = $idGenerator; + $this->setEncoder($encoder); + $this->headers->defineOrdering(['Content-Type', 'Content-Transfer-Encoding']); + + // This array specifies that, when the entire MIME document contains + // $compoundLevel, then for each child within $level, if its Content-Type + // is $contentType then it should be treated as if it's level is + // $neededLevel instead. I tried to write that unambiguously! :-\ + // Data Structure: + // array ( + // $compoundLevel => array( + // $level => array( + // $contentType => $neededLevel + // ) + // ) + // ) + + $this->compoundLevelFilters = [ + (self::LEVEL_ALTERNATIVE + self::LEVEL_RELATED) => [ + self::LEVEL_ALTERNATIVE => [ + 'text/plain' => self::LEVEL_ALTERNATIVE, + 'text/html' => self::LEVEL_RELATED, + ], + ], + ]; + + $this->id = $this->idGenerator->generateId(); + } + + /** + * Generate a new Content-ID or Message-ID for this MIME entity. + * + * @return string + */ + public function generateId() + { + $this->setId($this->idGenerator->generateId()); + + return $this->id; + } + + /** + * Get the {@link Swift_Mime_SimpleHeaderSet} for this entity. + * + * @return Swift_Mime_SimpleHeaderSet + */ + public function getHeaders() + { + return $this->headers; + } + + /** + * Get the nesting level of this entity. + * + * @see LEVEL_TOP, LEVEL_MIXED, LEVEL_RELATED, LEVEL_ALTERNATIVE + * + * @return int + */ + public function getNestingLevel() + { + return $this->nestingLevel; + } + + /** + * Get the Content-type of this entity. + * + * @return string + */ + public function getContentType() + { + return $this->getHeaderFieldModel('Content-Type'); + } + + /** + * Get the Body Content-type of this entity. + * + * @return string + */ + public function getBodyContentType() + { + return $this->userContentType; + } + + /** + * Set the Content-type of this entity. + * + * @param string $type + * + * @return $this + */ + public function setContentType($type) + { + $this->setContentTypeInHeaders($type); + // Keep track of the value so that if the content-type changes automatically + // due to added child entities, it can be restored if they are later removed + $this->userContentType = $type; + + return $this; + } + + /** + * Get the CID of this entity. + * + * The CID will only be present in headers if a Content-ID header is present. + * + * @return string + */ + public function getId() + { + $tmp = (array) $this->getHeaderFieldModel($this->getIdField()); + + return $this->headers->has($this->getIdField()) ? current($tmp) : $this->id; + } + + /** + * Set the CID of this entity. + * + * @param string $id + * + * @return $this + */ + public function setId($id) + { + if (!$this->setHeaderFieldModel($this->getIdField(), $id)) { + $this->headers->addIdHeader($this->getIdField(), $id); + } + $this->id = $id; + + return $this; + } + + /** + * Get the description of this entity. + * + * This value comes from the Content-Description header if set. + * + * @return string + */ + public function getDescription() + { + return $this->getHeaderFieldModel('Content-Description'); + } + + /** + * Set the description of this entity. + * + * This method sets a value in the Content-ID header. + * + * @param string $description + * + * @return $this + */ + public function setDescription($description) + { + if (!$this->setHeaderFieldModel('Content-Description', $description)) { + $this->headers->addTextHeader('Content-Description', $description); + } + + return $this; + } + + /** + * Get the maximum line length of the body of this entity. + * + * @return int + */ + public function getMaxLineLength() + { + return $this->maxLineLength; + } + + /** + * Set the maximum line length of lines in this body. + * + * Though not enforced by the library, lines should not exceed 1000 chars. + * + * @param int $length + * + * @return $this + */ + public function setMaxLineLength($length) + { + $this->maxLineLength = $length; + + return $this; + } + + /** + * Get all children added to this entity. + * + * @return Swift_Mime_SimpleMimeEntity[] + */ + public function getChildren() + { + return $this->children; + } + + /** + * Set all children of this entity. + * + * @param Swift_Mime_SimpleMimeEntity[] $children + * @param int $compoundLevel For internal use only + * + * @return $this + */ + public function setChildren(array $children, $compoundLevel = null) + { + // TODO: Try to refactor this logic + $compoundLevel = $compoundLevel ?? $this->getCompoundLevel($children); + $immediateChildren = []; + $grandchildren = []; + $newContentType = $this->userContentType; + + foreach ($children as $child) { + $level = $this->getNeededChildLevel($child, $compoundLevel); + if (empty($immediateChildren)) { + //first iteration + $immediateChildren = [$child]; + } else { + $nextLevel = $this->getNeededChildLevel($immediateChildren[0], $compoundLevel); + if ($nextLevel == $level) { + $immediateChildren[] = $child; + } elseif ($level < $nextLevel) { + // Re-assign immediateChildren to grandchildren + $grandchildren = array_merge($grandchildren, $immediateChildren); + // Set new children + $immediateChildren = [$child]; + } else { + $grandchildren[] = $child; + } + } + } + + if ($immediateChildren) { + $lowestLevel = $this->getNeededChildLevel($immediateChildren[0], $compoundLevel); + + // Determine which composite media type is needed to accommodate the + // immediate children + foreach ($this->compositeRanges as $mediaType => $range) { + if ($lowestLevel > $range[0] && $lowestLevel <= $range[1]) { + $newContentType = $mediaType; + + break; + } + } + + // Put any grandchildren in a subpart + if (!empty($grandchildren)) { + $subentity = $this->createChild(); + $subentity->setNestingLevel($lowestLevel); + $subentity->setChildren($grandchildren, $compoundLevel); + array_unshift($immediateChildren, $subentity); + } + } + + $this->immediateChildren = $immediateChildren; + $this->children = $children; + $this->setContentTypeInHeaders($newContentType); + $this->fixHeaders(); + $this->sortChildren(); + + return $this; + } + + /** + * Get the body of this entity as a string. + * + * @return string + */ + public function getBody() + { + return $this->body instanceof Swift_OutputByteStream ? $this->readStream($this->body) : $this->body; + } + + /** + * Set the body of this entity, either as a string, or as an instance of + * {@link Swift_OutputByteStream}. + * + * @param mixed $body + * @param string $contentType optional + * + * @return $this + */ + public function setBody($body, $contentType = null) + { + if ($body !== $this->body) { + $this->clearCache(); + } + + $this->body = $body; + if (null !== $contentType) { + $this->setContentType($contentType); + } + + return $this; + } + + /** + * Get the encoder used for the body of this entity. + * + * @return Swift_Mime_ContentEncoder + */ + public function getEncoder() + { + return $this->encoder; + } + + /** + * Set the encoder used for the body of this entity. + * + * @return $this + */ + public function setEncoder(Swift_Mime_ContentEncoder $encoder) + { + if ($encoder !== $this->encoder) { + $this->clearCache(); + } + + $this->encoder = $encoder; + $this->setEncoding($encoder->getName()); + $this->notifyEncoderChanged($encoder); + + return $this; + } + + /** + * Get the boundary used to separate children in this entity. + * + * @return string + */ + public function getBoundary() + { + if (!isset($this->boundary)) { + $this->boundary = '_=_swift_'.time().'_'.bin2hex(random_bytes(16)).'_=_'; + } + + return $this->boundary; + } + + /** + * Set the boundary used to separate children in this entity. + * + * @param string $boundary + * + * @throws Swift_RfcComplianceException + * + * @return $this + */ + public function setBoundary($boundary) + { + $this->assertValidBoundary($boundary); + $this->boundary = $boundary; + + return $this; + } + + /** + * Receive notification that the charset of this entity, or a parent entity + * has changed. + * + * @param string $charset + */ + public function charsetChanged($charset) + { + $this->notifyCharsetChanged($charset); + } + + /** + * Receive notification that the encoder of this entity or a parent entity + * has changed. + */ + public function encoderChanged(Swift_Mime_ContentEncoder $encoder) + { + $this->notifyEncoderChanged($encoder); + } + + /** + * Get this entire entity as a string. + * + * @return string + */ + public function toString() + { + $string = $this->headers->toString(); + $string .= $this->bodyToString(); + + return $string; + } + + /** + * Get this entire entity as a string. + * + * @return string + */ + protected function bodyToString() + { + $string = ''; + + if (isset($this->body) && empty($this->immediateChildren)) { + if ($this->cache->hasKey($this->cacheKey, 'body')) { + $body = $this->cache->getString($this->cacheKey, 'body'); + } else { + $body = "\r\n".$this->encoder->encodeString($this->getBody(), 0, $this->getMaxLineLength()); + $this->cache->setString($this->cacheKey, 'body', $body, Swift_KeyCache::MODE_WRITE); + } + $string .= $body; + } + + if (!empty($this->immediateChildren)) { + foreach ($this->immediateChildren as $child) { + $string .= "\r\n\r\n--".$this->getBoundary()."\r\n"; + $string .= $child->toString(); + } + $string .= "\r\n\r\n--".$this->getBoundary()."--\r\n"; + } + + return $string; + } + + /** + * Returns a string representation of this object. + * + * @see toString() + * + * @return string + */ + public function __toString() + { + return $this->toString(); + } + + /** + * Write this entire entity to a {@see Swift_InputByteStream}. + */ + public function toByteStream(Swift_InputByteStream $is) + { + $is->write($this->headers->toString()); + $is->commit(); + + $this->bodyToByteStream($is); + } + + /** + * Write this entire entity to a {@link Swift_InputByteStream}. + */ + protected function bodyToByteStream(Swift_InputByteStream $is) + { + if (empty($this->immediateChildren)) { + if (isset($this->body)) { + if ($this->cache->hasKey($this->cacheKey, 'body')) { + $this->cache->exportToByteStream($this->cacheKey, 'body', $is); + } else { + $cacheIs = $this->cache->getInputByteStream($this->cacheKey, 'body'); + if ($cacheIs) { + $is->bind($cacheIs); + } + + $is->write("\r\n"); + + if ($this->body instanceof Swift_OutputByteStream) { + $this->body->setReadPointer(0); + + $this->encoder->encodeByteStream($this->body, $is, 0, $this->getMaxLineLength()); + } else { + $is->write($this->encoder->encodeString($this->getBody(), 0, $this->getMaxLineLength())); + } + + if ($cacheIs) { + $is->unbind($cacheIs); + } + } + } + } + + if (!empty($this->immediateChildren)) { + foreach ($this->immediateChildren as $child) { + $is->write("\r\n\r\n--".$this->getBoundary()."\r\n"); + $child->toByteStream($is); + } + $is->write("\r\n\r\n--".$this->getBoundary()."--\r\n"); + } + } + + /** + * Get the name of the header that provides the ID of this entity. + */ + protected function getIdField() + { + return 'Content-ID'; + } + + /** + * Get the model data (usually an array or a string) for $field. + */ + protected function getHeaderFieldModel($field) + { + if ($this->headers->has($field)) { + return $this->headers->get($field)->getFieldBodyModel(); + } + } + + /** + * Set the model data for $field. + */ + protected function setHeaderFieldModel($field, $model) + { + if ($this->headers->has($field)) { + $this->headers->get($field)->setFieldBodyModel($model); + + return true; + } + + return false; + } + + /** + * Get the parameter value of $parameter on $field header. + */ + protected function getHeaderParameter($field, $parameter) + { + if ($this->headers->has($field)) { + return $this->headers->get($field)->getParameter($parameter); + } + } + + /** + * Set the parameter value of $parameter on $field header. + */ + protected function setHeaderParameter($field, $parameter, $value) + { + if ($this->headers->has($field)) { + $this->headers->get($field)->setParameter($parameter, $value); + + return true; + } + + return false; + } + + /** + * Re-evaluate what content type and encoding should be used on this entity. + */ + protected function fixHeaders() + { + if (\count($this->immediateChildren)) { + $this->setHeaderParameter('Content-Type', 'boundary', + $this->getBoundary() + ); + $this->headers->remove('Content-Transfer-Encoding'); + } else { + $this->setHeaderParameter('Content-Type', 'boundary', null); + $this->setEncoding($this->encoder->getName()); + } + } + + /** + * Get the KeyCache used in this entity. + * + * @return Swift_KeyCache + */ + protected function getCache() + { + return $this->cache; + } + + /** + * Get the ID generator. + * + * @return Swift_IdGenerator + */ + protected function getIdGenerator() + { + return $this->idGenerator; + } + + /** + * Empty the KeyCache for this entity. + */ + protected function clearCache() + { + $this->cache->clearKey($this->cacheKey, 'body'); + } + + private function readStream(Swift_OutputByteStream $os) + { + $string = ''; + while (false !== $bytes = $os->read(8192)) { + $string .= $bytes; + } + + $os->setReadPointer(0); + + return $string; + } + + private function setEncoding($encoding) + { + if (!$this->setHeaderFieldModel('Content-Transfer-Encoding', $encoding)) { + $this->headers->addTextHeader('Content-Transfer-Encoding', $encoding); + } + } + + private function assertValidBoundary($boundary) + { + if (!preg_match('/^[a-z0-9\'\(\)\+_\-,\.\/:=\?\ ]{0,69}[a-z0-9\'\(\)\+_\-,\.\/:=\?]$/Di', $boundary)) { + throw new Swift_RfcComplianceException('Mime boundary set is not RFC 2046 compliant.'); + } + } + + private function setContentTypeInHeaders($type) + { + if (!$this->setHeaderFieldModel('Content-Type', $type)) { + $this->headers->addParameterizedHeader('Content-Type', $type); + } + } + + private function setNestingLevel($level) + { + $this->nestingLevel = $level; + } + + private function getCompoundLevel($children) + { + $level = 0; + foreach ($children as $child) { + $level |= $child->getNestingLevel(); + } + + return $level; + } + + private function getNeededChildLevel($child, $compoundLevel) + { + $filter = []; + foreach ($this->compoundLevelFilters as $bitmask => $rules) { + if (($compoundLevel & $bitmask) === $bitmask) { + $filter = $rules + $filter; + } + } + + $realLevel = $child->getNestingLevel(); + $lowercaseType = strtolower($child->getContentType() ?? ''); + + if (isset($filter[$realLevel]) && isset($filter[$realLevel][$lowercaseType])) { + return $filter[$realLevel][$lowercaseType]; + } + + return $realLevel; + } + + private function createChild() + { + return new self($this->headers->newInstance(), $this->encoder, $this->cache, $this->idGenerator); + } + + private function notifyEncoderChanged(Swift_Mime_ContentEncoder $encoder) + { + foreach ($this->immediateChildren as $child) { + $child->encoderChanged($encoder); + } + } + + private function notifyCharsetChanged($charset) + { + $this->encoder->charsetChanged($charset); + $this->headers->charsetChanged($charset); + foreach ($this->immediateChildren as $child) { + $child->charsetChanged($charset); + } + } + + private function sortChildren() + { + $shouldSort = false; + foreach ($this->immediateChildren as $child) { + // NOTE: This include alternative parts moved into a related part + if (self::LEVEL_ALTERNATIVE == $child->getNestingLevel()) { + $shouldSort = true; + break; + } + } + + // Sort in order of preference, if there is one + if ($shouldSort) { + // Group the messages by order of preference + $sorted = []; + foreach ($this->immediateChildren as $child) { + $type = $child->getContentType(); + $level = \array_key_exists($type, $this->alternativePartOrder) ? $this->alternativePartOrder[$type] : max($this->alternativePartOrder) + 1; + + if (empty($sorted[$level])) { + $sorted[$level] = []; + } + + $sorted[$level][] = $child; + } + + ksort($sorted); + + $this->immediateChildren = array_reduce($sorted, 'array_merge', []); + } + } + + /** + * Empties it's own contents from the cache. + */ + public function __destruct() + { + if ($this->cache instanceof Swift_KeyCache) { + $this->cache->clearAll($this->cacheKey); + } + } + + /** + * Make a deep copy of object. + */ + public function __clone() + { + $this->headers = clone $this->headers; + $this->encoder = clone $this->encoder; + $this->cacheKey = bin2hex(random_bytes(16)); // set 32 hex values + $children = []; + foreach ($this->children as $pos => $child) { + $children[$pos] = clone $child; + } + $this->setChildren($children); + } + + public function __wakeup() + { + $this->cacheKey = bin2hex(random_bytes(16)); // set 32 hex values + $this->cache = new Swift_KeyCache_ArrayKeyCache(new Swift_KeyCache_SimpleKeyCacheInputStream()); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/MimePart.php b/htdocs/includes/swiftmailer/lib/classes/Swift/MimePart.php index e3440ae0cc3..ea97619ad69 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/MimePart.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/MimePart.php @@ -15,31 +15,31 @@ */ class Swift_MimePart extends Swift_Mime_MimePart { - /** - * Create a new MimePart. - * - * Details may be optionally passed into the constructor. - * - * @param string $body - * @param string $contentType - * @param string $charset - */ - public function __construct($body = null, $contentType = null, $charset = null) - { - \call_user_func_array( - [$this, 'Swift_Mime_MimePart::__construct'], - Swift_DependencyContainer::getInstance() - ->createDependenciesFor('mime.part') - ); + /** + * Create a new MimePart. + * + * Details may be optionally passed into the constructor. + * + * @param string $body + * @param string $contentType + * @param string $charset + */ + public function __construct($body = null, $contentType = null, $charset = null) + { + \call_user_func_array( + [$this, 'Swift_Mime_MimePart::__construct'], + Swift_DependencyContainer::getInstance() + ->createDependenciesFor('mime.part') + ); - if (!isset($charset)) { - $charset = Swift_DependencyContainer::getInstance() - ->lookup('properties.charset'); - } - $this->setBody($body); - $this->setCharset($charset); - if ($contentType) { - $this->setContentType($contentType); - } - } + if (!isset($charset)) { + $charset = Swift_DependencyContainer::getInstance() + ->lookup('properties.charset'); + } + $this->setBody($body); + $this->setCharset($charset); + if ($contentType) { + $this->setContentType($contentType); + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/NullTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/NullTransport.php index 5be32bfabac..e44b7af982f 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/NullTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/NullTransport.php @@ -15,12 +15,12 @@ */ class Swift_NullTransport extends Swift_Transport_NullTransport { - public function __construct() - { - \call_user_func_array( - [$this, 'Swift_Transport_NullTransport::__construct'], - Swift_DependencyContainer::getInstance() - ->createDependenciesFor('transport.null') - ); - } + public function __construct() + { + \call_user_func_array( + [$this, 'Swift_Transport_NullTransport::__construct'], + Swift_DependencyContainer::getInstance() + ->createDependenciesFor('transport.null') + ); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/AntiFloodPlugin.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/AntiFloodPlugin.php index 083ee263ec5..5b1d7deefff 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/AntiFloodPlugin.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/AntiFloodPlugin.php @@ -15,123 +15,123 @@ */ class Swift_Plugins_AntiFloodPlugin implements Swift_Events_SendListener, Swift_Plugins_Sleeper { - /** - * The number of emails to send before restarting Transport. - * - * @var int - */ - private $threshold; + /** + * The number of emails to send before restarting Transport. + * + * @var int + */ + private $threshold; - /** - * The number of seconds to sleep for during a restart. - * - * @var int - */ - private $sleep; + /** + * The number of seconds to sleep for during a restart. + * + * @var int + */ + private $sleep; - /** - * The internal counter. - * - * @var int - */ - private $counter = 0; + /** + * The internal counter. + * + * @var int + */ + private $counter = 0; - /** - * The Sleeper instance for sleeping. - * - * @var Swift_Plugins_Sleeper - */ - private $sleeper; + /** + * The Sleeper instance for sleeping. + * + * @var Swift_Plugins_Sleeper + */ + private $sleeper; - /** - * Create a new AntiFloodPlugin with $threshold and $sleep time. - * - * @param int $threshold - * @param int $sleep time - * @param Swift_Plugins_Sleeper $sleeper (not needed really) - */ - public function __construct($threshold = 99, $sleep = 0, Swift_Plugins_Sleeper $sleeper = null) - { - $this->setThreshold($threshold); - $this->setSleepTime($sleep); - $this->sleeper = $sleeper; - } + /** + * Create a new AntiFloodPlugin with $threshold and $sleep time. + * + * @param int $threshold + * @param int $sleep time + * @param Swift_Plugins_Sleeper $sleeper (not needed really) + */ + public function __construct($threshold = 99, $sleep = 0, Swift_Plugins_Sleeper $sleeper = null) + { + $this->setThreshold($threshold); + $this->setSleepTime($sleep); + $this->sleeper = $sleeper; + } - /** - * Set the number of emails to send before restarting. - * - * @param int $threshold - */ - public function setThreshold($threshold) - { - $this->threshold = $threshold; - } + /** + * Set the number of emails to send before restarting. + * + * @param int $threshold + */ + public function setThreshold($threshold) + { + $this->threshold = $threshold; + } - /** - * Get the number of emails to send before restarting. - * - * @return int - */ - public function getThreshold() - { - return $this->threshold; - } + /** + * Get the number of emails to send before restarting. + * + * @return int + */ + public function getThreshold() + { + return $this->threshold; + } - /** - * Set the number of seconds to sleep for during a restart. - * - * @param int $sleep time - */ - public function setSleepTime($sleep) - { - $this->sleep = $sleep; - } + /** + * Set the number of seconds to sleep for during a restart. + * + * @param int $sleep time + */ + public function setSleepTime($sleep) + { + $this->sleep = $sleep; + } - /** - * Get the number of seconds to sleep for during a restart. - * - * @return int - */ - public function getSleepTime() - { - return $this->sleep; - } + /** + * Get the number of seconds to sleep for during a restart. + * + * @return int + */ + public function getSleepTime() + { + return $this->sleep; + } - /** - * Invoked immediately before the Message is sent. - */ - public function beforeSendPerformed(Swift_Events_SendEvent $evt) - { - } + /** + * Invoked immediately before the Message is sent. + */ + public function beforeSendPerformed(Swift_Events_SendEvent $evt) + { + } - /** - * Invoked immediately after the Message is sent. - */ - public function sendPerformed(Swift_Events_SendEvent $evt) - { - ++$this->counter; - if ($this->counter >= $this->threshold) { - $transport = $evt->getTransport(); - $transport->stop(); - if ($this->sleep) { - $this->sleep($this->sleep); - } - $transport->start(); - $this->counter = 0; - } - } + /** + * Invoked immediately after the Message is sent. + */ + public function sendPerformed(Swift_Events_SendEvent $evt) + { + ++$this->counter; + if ($this->counter >= $this->threshold) { + $transport = $evt->getTransport(); + $transport->stop(); + if ($this->sleep) { + $this->sleep($this->sleep); + } + $transport->start(); + $this->counter = 0; + } + } - /** - * Sleep for $seconds. - * - * @param int $seconds - */ - public function sleep($seconds) - { - if (isset($this->sleeper)) { - $this->sleeper->sleep($seconds); - } else { - sleep($seconds); - } - } + /** + * Sleep for $seconds. + * + * @param int $seconds + */ + public function sleep($seconds) + { + if (isset($this->sleeper)) { + $this->sleeper->sleep($seconds); + } else { + sleep($seconds); + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/BandwidthMonitorPlugin.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/BandwidthMonitorPlugin.php index efffe57c9fb..36451f44f1f 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/BandwidthMonitorPlugin.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/BandwidthMonitorPlugin.php @@ -15,140 +15,140 @@ */ class Swift_Plugins_BandwidthMonitorPlugin implements Swift_Events_SendListener, Swift_Events_CommandListener, Swift_Events_ResponseListener, Swift_InputByteStream { - /** - * The outgoing traffic counter. - * - * @var int - */ - private $out = 0; + /** + * The outgoing traffic counter. + * + * @var int + */ + private $out = 0; - /** - * The incoming traffic counter. - * - * @var int - */ - private $in = 0; + /** + * The incoming traffic counter. + * + * @var int + */ + private $in = 0; - /** Bound byte streams */ - private $mirrors = []; + /** Bound byte streams */ + private $mirrors = []; - /** - * Not used. - */ - public function beforeSendPerformed(Swift_Events_SendEvent $evt) - { - } + /** + * Not used. + */ + public function beforeSendPerformed(Swift_Events_SendEvent $evt) + { + } - /** - * Invoked immediately after the Message is sent. - */ - public function sendPerformed(Swift_Events_SendEvent $evt) - { - $message = $evt->getMessage(); - $message->toByteStream($this); - } + /** + * Invoked immediately after the Message is sent. + */ + public function sendPerformed(Swift_Events_SendEvent $evt) + { + $message = $evt->getMessage(); + $message->toByteStream($this); + } - /** - * Invoked immediately following a command being sent. - */ - public function commandSent(Swift_Events_CommandEvent $evt) - { - $command = $evt->getCommand(); - $this->out += \strlen($command); - } + /** + * Invoked immediately following a command being sent. + */ + public function commandSent(Swift_Events_CommandEvent $evt) + { + $command = $evt->getCommand(); + $this->out += \strlen($command); + } - /** - * Invoked immediately following a response coming back. - */ - public function responseReceived(Swift_Events_ResponseEvent $evt) - { - $response = $evt->getResponse(); - $this->in += \strlen($response); - } + /** + * Invoked immediately following a response coming back. + */ + public function responseReceived(Swift_Events_ResponseEvent $evt) + { + $response = $evt->getResponse(); + $this->in += \strlen($response); + } - /** - * Called when a message is sent so that the outgoing counter can be increased. - * - * @param string $bytes - */ - public function write($bytes) - { - $this->out += \strlen($bytes); - foreach ($this->mirrors as $stream) { - $stream->write($bytes); - } - } + /** + * Called when a message is sent so that the outgoing counter can be increased. + * + * @param string $bytes + */ + public function write($bytes) + { + $this->out += \strlen($bytes); + foreach ($this->mirrors as $stream) { + $stream->write($bytes); + } + } - /** - * Not used. - */ - public function commit() - { - } + /** + * Not used. + */ + public function commit() + { + } - /** - * Attach $is to this stream. - * - * The stream acts as an observer, receiving all data that is written. - * All {@link write()} and {@link flushBuffers()} operations will be mirrored. - */ - public function bind(Swift_InputByteStream $is) - { - $this->mirrors[] = $is; - } + /** + * Attach $is to this stream. + * + * The stream acts as an observer, receiving all data that is written. + * All {@link write()} and {@link flushBuffers()} operations will be mirrored. + */ + public function bind(Swift_InputByteStream $is) + { + $this->mirrors[] = $is; + } - /** - * Remove an already bound stream. - * - * If $is is not bound, no errors will be raised. - * If the stream currently has any buffered data it will be written to $is - * before unbinding occurs. - */ - public function unbind(Swift_InputByteStream $is) - { - foreach ($this->mirrors as $k => $stream) { - if ($is === $stream) { - unset($this->mirrors[$k]); - } - } - } + /** + * Remove an already bound stream. + * + * If $is is not bound, no errors will be raised. + * If the stream currently has any buffered data it will be written to $is + * before unbinding occurs. + */ + public function unbind(Swift_InputByteStream $is) + { + foreach ($this->mirrors as $k => $stream) { + if ($is === $stream) { + unset($this->mirrors[$k]); + } + } + } - /** - * Not used. - */ - public function flushBuffers() - { - foreach ($this->mirrors as $stream) { - $stream->flushBuffers(); - } - } + /** + * Not used. + */ + public function flushBuffers() + { + foreach ($this->mirrors as $stream) { + $stream->flushBuffers(); + } + } - /** - * Get the total number of bytes sent to the server. - * - * @return int - */ - public function getBytesOut() - { - return $this->out; - } + /** + * Get the total number of bytes sent to the server. + * + * @return int + */ + public function getBytesOut() + { + return $this->out; + } - /** - * Get the total number of bytes received from the server. - * - * @return int - */ - public function getBytesIn() - { - return $this->in; - } + /** + * Get the total number of bytes received from the server. + * + * @return int + */ + public function getBytesIn() + { + return $this->in; + } - /** - * Reset the internal counters to zero. - */ - public function reset() - { - $this->out = 0; - $this->in = 0; - } + /** + * Reset the internal counters to zero. + */ + public function reset() + { + $this->out = 0; + $this->in = 0; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/DecoratorPlugin.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/DecoratorPlugin.php index 796965dca4b..93124c9a5f4 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/DecoratorPlugin.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/DecoratorPlugin.php @@ -16,185 +16,185 @@ */ class Swift_Plugins_DecoratorPlugin implements Swift_Events_SendListener, Swift_Plugins_Decorator_Replacements { - /** The replacement map */ - private $replacements; + /** The replacement map */ + private $replacements; - /** The body as it was before replacements */ - private $originalBody; + /** The body as it was before replacements */ + private $originalBody; - /** The original headers of the message, before replacements */ - private $originalHeaders = []; + /** The original headers of the message, before replacements */ + private $originalHeaders = []; - /** Bodies of children before they are replaced */ - private $originalChildBodies = []; + /** Bodies of children before they are replaced */ + private $originalChildBodies = []; - /** The Message that was last replaced */ - private $lastMessage; + /** The Message that was last replaced */ + private $lastMessage; - /** - * Create a new DecoratorPlugin with $replacements. - * - * The $replacements can either be an associative array, or an implementation - * of {@link Swift_Plugins_Decorator_Replacements}. - * - * When using an array, it should be of the form: - * - * $replacements = array( - * "address1@domain.tld" => array("{a}" => "b", "{c}" => "d"), - * "address2@domain.tld" => array("{a}" => "x", "{c}" => "y") - * ) - * - * - * When using an instance of {@link Swift_Plugins_Decorator_Replacements}, - * the object should return just the array of replacements for the address - * given to {@link Swift_Plugins_Decorator_Replacements::getReplacementsFor()}. - * - * @param mixed $replacements Array or Swift_Plugins_Decorator_Replacements - */ - public function __construct($replacements) - { - $this->setReplacements($replacements); - } + /** + * Create a new DecoratorPlugin with $replacements. + * + * The $replacements can either be an associative array, or an implementation + * of {@link Swift_Plugins_Decorator_Replacements}. + * + * When using an array, it should be of the form: + * + * $replacements = array( + * "address1@domain.tld" => array("{a}" => "b", "{c}" => "d"), + * "address2@domain.tld" => array("{a}" => "x", "{c}" => "y") + * ) + * + * + * When using an instance of {@link Swift_Plugins_Decorator_Replacements}, + * the object should return just the array of replacements for the address + * given to {@link Swift_Plugins_Decorator_Replacements::getReplacementsFor()}. + * + * @param mixed $replacements Array or Swift_Plugins_Decorator_Replacements + */ + public function __construct($replacements) + { + $this->setReplacements($replacements); + } - /** - * Sets replacements. - * - * @param mixed $replacements Array or Swift_Plugins_Decorator_Replacements - * - * @see __construct() - */ - public function setReplacements($replacements) - { - if (!($replacements instanceof Swift_Plugins_Decorator_Replacements)) { - $this->replacements = (array) $replacements; - } else { - $this->replacements = $replacements; - } - } + /** + * Sets replacements. + * + * @param mixed $replacements Array or Swift_Plugins_Decorator_Replacements + * + * @see __construct() + */ + public function setReplacements($replacements) + { + if (!($replacements instanceof Swift_Plugins_Decorator_Replacements)) { + $this->replacements = (array) $replacements; + } else { + $this->replacements = $replacements; + } + } - /** - * Invoked immediately before the Message is sent. - */ - public function beforeSendPerformed(Swift_Events_SendEvent $evt) - { - $message = $evt->getMessage(); - $this->restoreMessage($message); - $to = array_keys($message->getTo()); - $address = array_shift($to); - if ($replacements = $this->getReplacementsFor($address)) { - $body = $message->getBody(); - $search = array_keys($replacements); - $replace = array_values($replacements); - $bodyReplaced = str_replace( - $search, $replace, $body - ); - if ($body != $bodyReplaced) { - $this->originalBody = $body; - $message->setBody($bodyReplaced); - } + /** + * Invoked immediately before the Message is sent. + */ + public function beforeSendPerformed(Swift_Events_SendEvent $evt) + { + $message = $evt->getMessage(); + $this->restoreMessage($message); + $to = array_keys($message->getTo()); + $address = array_shift($to); + if ($replacements = $this->getReplacementsFor($address)) { + $body = $message->getBody(); + $search = array_keys($replacements); + $replace = array_values($replacements); + $bodyReplaced = str_replace( + $search, $replace, $body + ); + if ($body != $bodyReplaced) { + $this->originalBody = $body; + $message->setBody($bodyReplaced); + } - foreach ($message->getHeaders()->getAll() as $header) { - $body = $header->getFieldBodyModel(); - $count = 0; - if (\is_array($body)) { - $bodyReplaced = []; - foreach ($body as $key => $value) { - $count1 = 0; - $count2 = 0; - $key = \is_string($key) ? str_replace($search, $replace, $key, $count1) : $key; - $value = \is_string($value) ? str_replace($search, $replace, $value, $count2) : $value; - $bodyReplaced[$key] = $value; + foreach ($message->getHeaders()->getAll() as $header) { + $body = $header->getFieldBodyModel(); + $count = 0; + if (\is_array($body)) { + $bodyReplaced = []; + foreach ($body as $key => $value) { + $count1 = 0; + $count2 = 0; + $key = \is_string($key) ? str_replace($search, $replace, $key, $count1) : $key; + $value = \is_string($value) ? str_replace($search, $replace, $value, $count2) : $value; + $bodyReplaced[$key] = $value; - if (!$count && ($count1 || $count2)) { - $count = 1; - } - } - } elseif (\is_string($body)) { - $bodyReplaced = str_replace($search, $replace, $body, $count); - } + if (!$count && ($count1 || $count2)) { + $count = 1; + } + } + } elseif (\is_string($body)) { + $bodyReplaced = str_replace($search, $replace, $body, $count); + } - if ($count) { - $this->originalHeaders[$header->getFieldName()] = $body; - $header->setFieldBodyModel($bodyReplaced); - } - } + if ($count) { + $this->originalHeaders[$header->getFieldName()] = $body; + $header->setFieldBodyModel($bodyReplaced); + } + } - $children = (array) $message->getChildren(); - foreach ($children as $child) { - list($type) = sscanf($child->getContentType(), '%[^/]/%s'); - if ('text' == $type) { - $body = $child->getBody(); - $bodyReplaced = str_replace( - $search, $replace, $body - ); - if ($body != $bodyReplaced) { - $child->setBody($bodyReplaced); - $this->originalChildBodies[$child->getId()] = $body; - } - } - } - $this->lastMessage = $message; - } - } + $children = (array) $message->getChildren(); + foreach ($children as $child) { + list($type) = sscanf($child->getContentType(), '%[^/]/%s'); + if ('text' == $type) { + $body = $child->getBody(); + $bodyReplaced = str_replace( + $search, $replace, $body + ); + if ($body != $bodyReplaced) { + $child->setBody($bodyReplaced); + $this->originalChildBodies[$child->getId()] = $body; + } + } + } + $this->lastMessage = $message; + } + } - /** - * Find a map of replacements for the address. - * - * If this plugin was provided with a delegate instance of - * {@link Swift_Plugins_Decorator_Replacements} then the call will be - * delegated to it. Otherwise, it will attempt to find the replacements - * from the array provided in the constructor. - * - * If no replacements can be found, an empty value (NULL) is returned. - * - * @param string $address - * - * @return array - */ - public function getReplacementsFor($address) - { - if ($this->replacements instanceof Swift_Plugins_Decorator_Replacements) { - return $this->replacements->getReplacementsFor($address); - } + /** + * Find a map of replacements for the address. + * + * If this plugin was provided with a delegate instance of + * {@link Swift_Plugins_Decorator_Replacements} then the call will be + * delegated to it. Otherwise, it will attempt to find the replacements + * from the array provided in the constructor. + * + * If no replacements can be found, an empty value (NULL) is returned. + * + * @param string $address + * + * @return array + */ + public function getReplacementsFor($address) + { + if ($this->replacements instanceof Swift_Plugins_Decorator_Replacements) { + return $this->replacements->getReplacementsFor($address); + } - return $this->replacements[$address] ?? null; - } + return $this->replacements[$address] ?? null; + } - /** - * Invoked immediately after the Message is sent. - */ - public function sendPerformed(Swift_Events_SendEvent $evt) - { - $this->restoreMessage($evt->getMessage()); - } + /** + * Invoked immediately after the Message is sent. + */ + public function sendPerformed(Swift_Events_SendEvent $evt) + { + $this->restoreMessage($evt->getMessage()); + } - /** Restore a changed message back to its original state */ - private function restoreMessage(Swift_Mime_SimpleMessage $message) - { - if ($this->lastMessage === $message) { - if (isset($this->originalBody)) { - $message->setBody($this->originalBody); - $this->originalBody = null; - } - if (!empty($this->originalHeaders)) { - foreach ($message->getHeaders()->getAll() as $header) { - if (\array_key_exists($header->getFieldName(), $this->originalHeaders)) { - $header->setFieldBodyModel($this->originalHeaders[$header->getFieldName()]); - } - } - $this->originalHeaders = []; - } - if (!empty($this->originalChildBodies)) { - $children = (array) $message->getChildren(); - foreach ($children as $child) { - $id = $child->getId(); - if (\array_key_exists($id, $this->originalChildBodies)) { - $child->setBody($this->originalChildBodies[$id]); - } - } - $this->originalChildBodies = []; - } - $this->lastMessage = null; - } - } + /** Restore a changed message back to its original state */ + private function restoreMessage(Swift_Mime_SimpleMessage $message) + { + if ($this->lastMessage === $message) { + if (isset($this->originalBody)) { + $message->setBody($this->originalBody); + $this->originalBody = null; + } + if (!empty($this->originalHeaders)) { + foreach ($message->getHeaders()->getAll() as $header) { + if (\array_key_exists($header->getFieldName(), $this->originalHeaders)) { + $header->setFieldBodyModel($this->originalHeaders[$header->getFieldName()]); + } + } + $this->originalHeaders = []; + } + if (!empty($this->originalChildBodies)) { + $children = (array) $message->getChildren(); + foreach ($children as $child) { + $id = $child->getId(); + if (\array_key_exists($id, $this->originalChildBodies)) { + $child->setBody($this->originalChildBodies[$id]); + } + } + $this->originalChildBodies = []; + } + $this->lastMessage = null; + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/ImpersonatePlugin.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/ImpersonatePlugin.php index 69d31f0a465..3f4dbbfa40f 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/ImpersonatePlugin.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/ImpersonatePlugin.php @@ -15,51 +15,51 @@ */ class Swift_Plugins_ImpersonatePlugin implements Swift_Events_SendListener { - /** - * The sender to impersonate. - * - * @var string - */ - private $sender; + /** + * The sender to impersonate. + * + * @var string + */ + private $sender; - /** - * Create a new ImpersonatePlugin to impersonate $sender. - * - * @param string $sender address - */ - public function __construct($sender) - { - $this->sender = $sender; - } + /** + * Create a new ImpersonatePlugin to impersonate $sender. + * + * @param string $sender address + */ + public function __construct($sender) + { + $this->sender = $sender; + } - /** - * Invoked immediately before the Message is sent. - */ - public function beforeSendPerformed(Swift_Events_SendEvent $evt) - { - $message = $evt->getMessage(); - $headers = $message->getHeaders(); + /** + * Invoked immediately before the Message is sent. + */ + public function beforeSendPerformed(Swift_Events_SendEvent $evt) + { + $message = $evt->getMessage(); + $headers = $message->getHeaders(); - // save current recipients - $headers->addPathHeader('X-Swift-Return-Path', $message->getReturnPath()); + // save current recipients + $headers->addPathHeader('X-Swift-Return-Path', $message->getReturnPath()); - // replace them with the one to send to - $message->setReturnPath($this->sender); - } + // replace them with the one to send to + $message->setReturnPath($this->sender); + } - /** - * Invoked immediately after the Message is sent. - */ - public function sendPerformed(Swift_Events_SendEvent $evt) - { - $message = $evt->getMessage(); + /** + * Invoked immediately after the Message is sent. + */ + public function sendPerformed(Swift_Events_SendEvent $evt) + { + $message = $evt->getMessage(); - // restore original headers - $headers = $message->getHeaders(); + // restore original headers + $headers = $message->getHeaders(); - if ($headers->has('X-Swift-Return-Path')) { - $message->setReturnPath($headers->get('X-Swift-Return-Path')->getAddress()); - $headers->removeAll('X-Swift-Return-Path'); - } - } + if ($headers->has('X-Swift-Return-Path')) { + $message->setReturnPath($headers->get('X-Swift-Return-Path')->getAddress()); + $headers->removeAll('X-Swift-Return-Path'); + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/LoggerPlugin.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/LoggerPlugin.php index afb0a3df297..e183749b7ec 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/LoggerPlugin.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/LoggerPlugin.php @@ -15,112 +15,112 @@ */ class Swift_Plugins_LoggerPlugin implements Swift_Events_CommandListener, Swift_Events_ResponseListener, Swift_Events_TransportChangeListener, Swift_Events_TransportExceptionListener, Swift_Plugins_Logger { - /** The logger which is delegated to */ - private $logger; + /** The logger which is delegated to */ + private $logger; - /** - * Create a new LoggerPlugin using $logger. - */ - public function __construct(Swift_Plugins_Logger $logger) - { - $this->logger = $logger; - } + /** + * Create a new LoggerPlugin using $logger. + */ + public function __construct(Swift_Plugins_Logger $logger) + { + $this->logger = $logger; + } - /** - * Add a log entry. - * - * @param string $entry - */ - public function add($entry) - { - $this->logger->add($entry); - } + /** + * Add a log entry. + * + * @param string $entry + */ + public function add($entry) + { + $this->logger->add($entry); + } - /** - * Clear the log contents. - */ - public function clear() - { - $this->logger->clear(); - } + /** + * Clear the log contents. + */ + public function clear() + { + $this->logger->clear(); + } - /** - * Get this log as a string. - * - * @return string - */ - public function dump() - { - return $this->logger->dump(); - } + /** + * Get this log as a string. + * + * @return string + */ + public function dump() + { + return $this->logger->dump(); + } - /** - * Invoked immediately following a command being sent. - */ - public function commandSent(Swift_Events_CommandEvent $evt) - { - $command = $evt->getCommand(); - $this->logger->add(sprintf('>> %s', $command)); - } + /** + * Invoked immediately following a command being sent. + */ + public function commandSent(Swift_Events_CommandEvent $evt) + { + $command = $evt->getCommand(); + $this->logger->add(sprintf('>> %s', $command)); + } - /** - * Invoked immediately following a response coming back. - */ - public function responseReceived(Swift_Events_ResponseEvent $evt) - { - $response = $evt->getResponse(); - $this->logger->add(sprintf('<< %s', $response)); - } + /** + * Invoked immediately following a response coming back. + */ + public function responseReceived(Swift_Events_ResponseEvent $evt) + { + $response = $evt->getResponse(); + $this->logger->add(sprintf('<< %s', $response)); + } - /** - * Invoked just before a Transport is started. - */ - public function beforeTransportStarted(Swift_Events_TransportChangeEvent $evt) - { - $transportName = \get_class($evt->getSource()); - $this->logger->add(sprintf('++ Starting %s', $transportName)); - } + /** + * Invoked just before a Transport is started. + */ + public function beforeTransportStarted(Swift_Events_TransportChangeEvent $evt) + { + $transportName = \get_class($evt->getSource()); + $this->logger->add(sprintf('++ Starting %s', $transportName)); + } - /** - * Invoked immediately after the Transport is started. - */ - public function transportStarted(Swift_Events_TransportChangeEvent $evt) - { - $transportName = \get_class($evt->getSource()); - $this->logger->add(sprintf('++ %s started', $transportName)); - } + /** + * Invoked immediately after the Transport is started. + */ + public function transportStarted(Swift_Events_TransportChangeEvent $evt) + { + $transportName = \get_class($evt->getSource()); + $this->logger->add(sprintf('++ %s started', $transportName)); + } - /** - * Invoked just before a Transport is stopped. - */ - public function beforeTransportStopped(Swift_Events_TransportChangeEvent $evt) - { - $transportName = \get_class($evt->getSource()); - $this->logger->add(sprintf('++ Stopping %s', $transportName)); - } + /** + * Invoked just before a Transport is stopped. + */ + public function beforeTransportStopped(Swift_Events_TransportChangeEvent $evt) + { + $transportName = \get_class($evt->getSource()); + $this->logger->add(sprintf('++ Stopping %s', $transportName)); + } - /** - * Invoked immediately after the Transport is stopped. - */ - public function transportStopped(Swift_Events_TransportChangeEvent $evt) - { - $transportName = \get_class($evt->getSource()); - $this->logger->add(sprintf('++ %s stopped', $transportName)); - } + /** + * Invoked immediately after the Transport is stopped. + */ + public function transportStopped(Swift_Events_TransportChangeEvent $evt) + { + $transportName = \get_class($evt->getSource()); + $this->logger->add(sprintf('++ %s stopped', $transportName)); + } - /** - * Invoked as a TransportException is thrown in the Transport system. - */ - public function exceptionThrown(Swift_Events_TransportExceptionEvent $evt) - { - $e = $evt->getException(); - $message = $e->getMessage(); - $code = $e->getCode(); - $this->logger->add(sprintf('!! %s (code: %s)', $message, $code)); - $message .= PHP_EOL; - $message .= 'Log data:'.PHP_EOL; - $message .= $this->logger->dump(); - $evt->cancelBubble(); - throw new Swift_TransportException($message, $code, $e->getPrevious()); - } + /** + * Invoked as a TransportException is thrown in the Transport system. + */ + public function exceptionThrown(Swift_Events_TransportExceptionEvent $evt) + { + $e = $evt->getException(); + $message = $e->getMessage(); + $code = $e->getCode(); + $this->logger->add(sprintf('!! %s (code: %s)', $message, $code)); + $message .= PHP_EOL; + $message .= 'Log data:'.PHP_EOL; + $message .= $this->logger->dump(); + $evt->cancelBubble(); + throw new Swift_TransportException($message, $code, $e->getPrevious()); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Loggers/ArrayLogger.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Loggers/ArrayLogger.php index 0761b84f83d..6f595adaa4d 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Loggers/ArrayLogger.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Loggers/ArrayLogger.php @@ -15,58 +15,58 @@ */ class Swift_Plugins_Loggers_ArrayLogger implements Swift_Plugins_Logger { - /** - * The log contents. - * - * @var array - */ - private $log = []; + /** + * The log contents. + * + * @var array + */ + private $log = []; - /** - * Max size of the log. - * - * @var int - */ - private $size = 0; + /** + * Max size of the log. + * + * @var int + */ + private $size = 0; - /** - * Create a new ArrayLogger with a maximum of $size entries. - * - * @var int - */ - public function __construct($size = 50) - { - $this->size = $size; - } + /** + * Create a new ArrayLogger with a maximum of $size entries. + * + * @var int + */ + public function __construct($size = 50) + { + $this->size = $size; + } - /** - * Add a log entry. - * - * @param string $entry - */ - public function add($entry) - { - $this->log[] = $entry; - while (\count($this->log) > $this->size) { - array_shift($this->log); - } - } + /** + * Add a log entry. + * + * @param string $entry + */ + public function add($entry) + { + $this->log[] = $entry; + while (\count($this->log) > $this->size) { + array_shift($this->log); + } + } - /** - * Clear the log contents. - */ - public function clear() - { - $this->log = []; - } + /** + * Clear the log contents. + */ + public function clear() + { + $this->log = []; + } - /** - * Get this log as a string. - * - * @return string - */ - public function dump() - { - return implode(PHP_EOL, $this->log); - } + /** + * Get this log as a string. + * + * @return string + */ + public function dump() + { + return implode(PHP_EOL, $this->log); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/MessageLogger.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/MessageLogger.php index 6aaf87599cb..39c48ed18f5 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/MessageLogger.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/MessageLogger.php @@ -15,56 +15,56 @@ */ class Swift_Plugins_MessageLogger implements Swift_Events_SendListener { - /** - * @var Swift_Mime_SimpleMessage[] - */ - private $messages; + /** + * @var Swift_Mime_SimpleMessage[] + */ + private $messages; - public function __construct() - { - $this->messages = []; - } + public function __construct() + { + $this->messages = []; + } - /** - * Get the message list. - * - * @return Swift_Mime_SimpleMessage[] - */ - public function getMessages() - { - return $this->messages; - } + /** + * Get the message list. + * + * @return Swift_Mime_SimpleMessage[] + */ + public function getMessages() + { + return $this->messages; + } - /** - * Get the message count. - * - * @return int count - */ - public function countMessages() - { - return \count($this->messages); - } + /** + * Get the message count. + * + * @return int count + */ + public function countMessages() + { + return \count($this->messages); + } - /** - * Empty the message list. - */ - public function clear() - { - $this->messages = []; - } + /** + * Empty the message list. + */ + public function clear() + { + $this->messages = []; + } - /** - * Invoked immediately before the Message is sent. - */ - public function beforeSendPerformed(Swift_Events_SendEvent $evt) - { - $this->messages[] = clone $evt->getMessage(); - } + /** + * Invoked immediately before the Message is sent. + */ + public function beforeSendPerformed(Swift_Events_SendEvent $evt) + { + $this->messages[] = clone $evt->getMessage(); + } - /** - * Invoked immediately after the Message is sent. - */ - public function sendPerformed(Swift_Events_SendEvent $evt) - { - } + /** + * Invoked immediately after the Message is sent. + */ + public function sendPerformed(Swift_Events_SendEvent $evt) + { + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/PopBeforeSmtpPlugin.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/PopBeforeSmtpPlugin.php index cf4f2438ec0..9448594090b 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/PopBeforeSmtpPlugin.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/PopBeforeSmtpPlugin.php @@ -15,228 +15,228 @@ */ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeListener, Swift_Plugins_Pop_Pop3Connection { - /** A delegate connection to use (mostly a test hook) */ - private $connection; + /** A delegate connection to use (mostly a test hook) */ + private $connection; - /** Hostname of the POP3 server */ - private $host; + /** Hostname of the POP3 server */ + private $host; - /** Port number to connect on */ - private $port; + /** Port number to connect on */ + private $port; - /** Encryption type to use (if any) */ - private $crypto; + /** Encryption type to use (if any) */ + private $crypto; - /** Username to use (if any) */ - private $username; + /** Username to use (if any) */ + private $username; - /** Password to use (if any) */ - private $password; + /** Password to use (if any) */ + private $password; - /** Established connection via TCP socket */ - private $socket; + /** Established connection via TCP socket */ + private $socket; - /** Connect timeout in seconds */ - private $timeout = 10; + /** Connect timeout in seconds */ + private $timeout = 10; - /** SMTP Transport to bind to */ - private $transport; + /** SMTP Transport to bind to */ + private $transport; - /** - * Create a new PopBeforeSmtpPlugin for $host and $port. - * - * @param string $host Hostname or IP. Literal IPv6 addresses should be - * wrapped in square brackets. - * @param int $port - * @param string $crypto as "tls" or "ssl" - */ - public function __construct($host, $port = 110, $crypto = null) - { - $this->host = $host; - $this->port = $port; - $this->crypto = $crypto; - } + /** + * Create a new PopBeforeSmtpPlugin for $host and $port. + * + * @param string $host Hostname or IP. Literal IPv6 addresses should be + * wrapped in square brackets. + * @param int $port + * @param string $crypto as "tls" or "ssl" + */ + public function __construct($host, $port = 110, $crypto = null) + { + $this->host = $host; + $this->port = $port; + $this->crypto = $crypto; + } - /** - * Set a Pop3Connection to delegate to instead of connecting directly. - * - * @return $this - */ - public function setConnection(Swift_Plugins_Pop_Pop3Connection $connection) - { - $this->connection = $connection; + /** + * Set a Pop3Connection to delegate to instead of connecting directly. + * + * @return $this + */ + public function setConnection(Swift_Plugins_Pop_Pop3Connection $connection) + { + $this->connection = $connection; - return $this; - } + return $this; + } - /** - * Bind this plugin to a specific SMTP transport instance. - */ - public function bindSmtp(Swift_Transport $smtp) - { - $this->transport = $smtp; - } + /** + * Bind this plugin to a specific SMTP transport instance. + */ + public function bindSmtp(Swift_Transport $smtp) + { + $this->transport = $smtp; + } - /** - * Set the connection timeout in seconds (default 10). - * - * @param int $timeout - * - * @return $this - */ - public function setTimeout($timeout) - { - $this->timeout = (int) $timeout; + /** + * Set the connection timeout in seconds (default 10). + * + * @param int $timeout + * + * @return $this + */ + public function setTimeout($timeout) + { + $this->timeout = (int) $timeout; - return $this; - } + return $this; + } - /** - * Set the username to use when connecting (if needed). - * - * @param string $username - * - * @return $this - */ - public function setUsername($username) - { - $this->username = $username; + /** + * Set the username to use when connecting (if needed). + * + * @param string $username + * + * @return $this + */ + public function setUsername($username) + { + $this->username = $username; - return $this; - } + return $this; + } - /** - * Set the password to use when connecting (if needed). - * - * @param string $password - * - * @return $this - */ - public function setPassword($password) - { - $this->password = $password; + /** + * Set the password to use when connecting (if needed). + * + * @param string $password + * + * @return $this + */ + public function setPassword($password) + { + $this->password = $password; - return $this; - } + return $this; + } - /** - * Connect to the POP3 host and authenticate. - * - * @throws Swift_Plugins_Pop_Pop3Exception if connection fails - */ - public function connect() - { - if (isset($this->connection)) { - $this->connection->connect(); - } else { - if (!isset($this->socket)) { - if (!$socket = fsockopen( - $this->getHostString(), $this->port, $errno, $errstr, $this->timeout)) { - throw new Swift_Plugins_Pop_Pop3Exception(sprintf('Failed to connect to POP3 host [%s]: %s', $this->host, $errstr)); - } - $this->socket = $socket; + /** + * Connect to the POP3 host and authenticate. + * + * @throws Swift_Plugins_Pop_Pop3Exception if connection fails + */ + public function connect() + { + if (isset($this->connection)) { + $this->connection->connect(); + } else { + if (!isset($this->socket)) { + if (!$socket = fsockopen( + $this->getHostString(), $this->port, $errno, $errstr, $this->timeout)) { + throw new Swift_Plugins_Pop_Pop3Exception(sprintf('Failed to connect to POP3 host [%s]: %s', $this->host, $errstr)); + } + $this->socket = $socket; - if (false === $greeting = fgets($this->socket)) { - throw new Swift_Plugins_Pop_Pop3Exception(sprintf('Failed to connect to POP3 host [%s]', trim($greeting ?? ''))); - } + if (false === $greeting = fgets($this->socket)) { + throw new Swift_Plugins_Pop_Pop3Exception(sprintf('Failed to connect to POP3 host [%s]', trim($greeting ?? ''))); + } - $this->assertOk($greeting); + $this->assertOk($greeting); - if ($this->username) { - $this->command(sprintf("USER %s\r\n", $this->username)); - $this->command(sprintf("PASS %s\r\n", $this->password)); - } - } - } - } + if ($this->username) { + $this->command(sprintf("USER %s\r\n", $this->username)); + $this->command(sprintf("PASS %s\r\n", $this->password)); + } + } + } + } - /** - * Disconnect from the POP3 host. - */ - public function disconnect() - { - if (isset($this->connection)) { - $this->connection->disconnect(); - } else { - $this->command("QUIT\r\n"); - if (!fclose($this->socket)) { - throw new Swift_Plugins_Pop_Pop3Exception(sprintf('POP3 host [%s] connection could not be stopped', $this->host)); - } - $this->socket = null; - } - } + /** + * Disconnect from the POP3 host. + */ + public function disconnect() + { + if (isset($this->connection)) { + $this->connection->disconnect(); + } else { + $this->command("QUIT\r\n"); + if (!fclose($this->socket)) { + throw new Swift_Plugins_Pop_Pop3Exception(sprintf('POP3 host [%s] connection could not be stopped', $this->host)); + } + $this->socket = null; + } + } - /** - * Invoked just before a Transport is started. - */ - public function beforeTransportStarted(Swift_Events_TransportChangeEvent $evt) - { - if (isset($this->transport)) { - if ($this->transport !== $evt->getTransport()) { - return; - } - } + /** + * Invoked just before a Transport is started. + */ + public function beforeTransportStarted(Swift_Events_TransportChangeEvent $evt) + { + if (isset($this->transport)) { + if ($this->transport !== $evt->getTransport()) { + return; + } + } - $this->connect(); - $this->disconnect(); - } + $this->connect(); + $this->disconnect(); + } - /** - * Not used. - */ - public function transportStarted(Swift_Events_TransportChangeEvent $evt) - { - } + /** + * Not used. + */ + public function transportStarted(Swift_Events_TransportChangeEvent $evt) + { + } - /** - * Not used. - */ - public function beforeTransportStopped(Swift_Events_TransportChangeEvent $evt) - { - } + /** + * Not used. + */ + public function beforeTransportStopped(Swift_Events_TransportChangeEvent $evt) + { + } - /** - * Not used. - */ - public function transportStopped(Swift_Events_TransportChangeEvent $evt) - { - } + /** + * Not used. + */ + public function transportStopped(Swift_Events_TransportChangeEvent $evt) + { + } - private function command($command) - { - if (!fwrite($this->socket, $command)) { - throw new Swift_Plugins_Pop_Pop3Exception(sprintf('Failed to write command [%s] to POP3 host', trim($command ?? ''))); - } + private function command($command) + { + if (!fwrite($this->socket, $command)) { + throw new Swift_Plugins_Pop_Pop3Exception(sprintf('Failed to write command [%s] to POP3 host', trim($command ?? ''))); + } - if (false === $response = fgets($this->socket)) { - throw new Swift_Plugins_Pop_Pop3Exception(sprintf('Failed to read from POP3 host after command [%s]', trim($command ?? ''))); - } + if (false === $response = fgets($this->socket)) { + throw new Swift_Plugins_Pop_Pop3Exception(sprintf('Failed to read from POP3 host after command [%s]', trim($command ?? ''))); + } - $this->assertOk($response); + $this->assertOk($response); - return $response; - } + return $response; + } - private function assertOk($response) - { - if ('+OK' != substr($response, 0, 3)) { - throw new Swift_Plugins_Pop_Pop3Exception(sprintf('POP3 command failed [%s]', trim($response ?? ''))); - } - } + private function assertOk($response) + { + if ('+OK' != substr($response, 0, 3)) { + throw new Swift_Plugins_Pop_Pop3Exception(sprintf('POP3 command failed [%s]', trim($response ?? ''))); + } + } - private function getHostString() - { - $host = $this->host; - switch (strtolower($this->crypto ?? '')) { - case 'ssl': - $host = 'ssl://'.$host; - break; + private function getHostString() + { + $host = $this->host; + switch (strtolower($this->crypto ?? '')) { + case 'ssl': + $host = 'ssl://'.$host; + break; - case 'tls': - $host = 'tls://'.$host; - break; - } + case 'tls': + $host = 'tls://'.$host; + break; + } - return $host; - } + return $host; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/RedirectingPlugin.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/RedirectingPlugin.php index 756faa89c67..f7373b2424c 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/RedirectingPlugin.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/RedirectingPlugin.php @@ -15,187 +15,187 @@ */ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener { - /** - * The recipient who will receive all messages. - * - * @var mixed - */ - private $recipient; + /** + * The recipient who will receive all messages. + * + * @var mixed + */ + private $recipient; - /** - * List of regular expression for recipient whitelisting. - * - * @var array - */ - private $whitelist = []; + /** + * List of regular expression for recipient whitelisting. + * + * @var array + */ + private $whitelist = []; - /** - * Create a new RedirectingPlugin. - * - * @param mixed $recipient - */ - public function __construct($recipient, array $whitelist = []) - { - $this->recipient = $recipient; - $this->whitelist = $whitelist; - } + /** + * Create a new RedirectingPlugin. + * + * @param mixed $recipient + */ + public function __construct($recipient, array $whitelist = []) + { + $this->recipient = $recipient; + $this->whitelist = $whitelist; + } - /** - * Set the recipient of all messages. - * - * @param mixed $recipient - */ - public function setRecipient($recipient) - { - $this->recipient = $recipient; - } + /** + * Set the recipient of all messages. + * + * @param mixed $recipient + */ + public function setRecipient($recipient) + { + $this->recipient = $recipient; + } - /** - * Get the recipient of all messages. - * - * @return mixed - */ - public function getRecipient() - { - return $this->recipient; - } + /** + * Get the recipient of all messages. + * + * @return mixed + */ + public function getRecipient() + { + return $this->recipient; + } - /** - * Set a list of regular expressions to whitelist certain recipients. - */ - public function setWhitelist(array $whitelist) - { - $this->whitelist = $whitelist; - } + /** + * Set a list of regular expressions to whitelist certain recipients. + */ + public function setWhitelist(array $whitelist) + { + $this->whitelist = $whitelist; + } - /** - * Get the whitelist. - * - * @return array - */ - public function getWhitelist() - { - return $this->whitelist; - } + /** + * Get the whitelist. + * + * @return array + */ + public function getWhitelist() + { + return $this->whitelist; + } - /** - * Invoked immediately before the Message is sent. - */ - public function beforeSendPerformed(Swift_Events_SendEvent $evt) - { - $message = $evt->getMessage(); - $headers = $message->getHeaders(); + /** + * Invoked immediately before the Message is sent. + */ + public function beforeSendPerformed(Swift_Events_SendEvent $evt) + { + $message = $evt->getMessage(); + $headers = $message->getHeaders(); - // conditionally save current recipients + // conditionally save current recipients - if ($headers->has('to')) { - $headers->addMailboxHeader('X-Swift-To', $message->getTo()); - } + if ($headers->has('to')) { + $headers->addMailboxHeader('X-Swift-To', $message->getTo()); + } - if ($headers->has('cc')) { - $headers->addMailboxHeader('X-Swift-Cc', $message->getCc()); - } + if ($headers->has('cc')) { + $headers->addMailboxHeader('X-Swift-Cc', $message->getCc()); + } - if ($headers->has('bcc')) { - $headers->addMailboxHeader('X-Swift-Bcc', $message->getBcc()); - } + if ($headers->has('bcc')) { + $headers->addMailboxHeader('X-Swift-Bcc', $message->getBcc()); + } - // Filter remaining headers against whitelist - $this->filterHeaderSet($headers, 'To'); - $this->filterHeaderSet($headers, 'Cc'); - $this->filterHeaderSet($headers, 'Bcc'); + // Filter remaining headers against whitelist + $this->filterHeaderSet($headers, 'To'); + $this->filterHeaderSet($headers, 'Cc'); + $this->filterHeaderSet($headers, 'Bcc'); - // Add each hard coded recipient - $to = $message->getTo(); - if (null === $to) { - $to = []; - } + // Add each hard coded recipient + $to = $message->getTo(); + if (null === $to) { + $to = []; + } - foreach ((array) $this->recipient as $recipient) { - if (!\array_key_exists($recipient, $to)) { - $message->addTo($recipient); - } - } - } + foreach ((array) $this->recipient as $recipient) { + if (!\array_key_exists($recipient, $to)) { + $message->addTo($recipient); + } + } + } - /** - * Filter header set against a whitelist of regular expressions. - * - * @param string $type - */ - private function filterHeaderSet(Swift_Mime_SimpleHeaderSet $headerSet, $type) - { - foreach ($headerSet->getAll($type) as $headers) { - $headers->setNameAddresses($this->filterNameAddresses($headers->getNameAddresses())); - } - } + /** + * Filter header set against a whitelist of regular expressions. + * + * @param string $type + */ + private function filterHeaderSet(Swift_Mime_SimpleHeaderSet $headerSet, $type) + { + foreach ($headerSet->getAll($type) as $headers) { + $headers->setNameAddresses($this->filterNameAddresses($headers->getNameAddresses())); + } + } - /** - * Filtered list of addresses => name pairs. - * - * @return array - */ - private function filterNameAddresses(array $recipients) - { - $filtered = []; + /** + * Filtered list of addresses => name pairs. + * + * @return array + */ + private function filterNameAddresses(array $recipients) + { + $filtered = []; - foreach ($recipients as $address => $name) { - if ($this->isWhitelisted($address)) { - $filtered[$address] = $name; - } - } + foreach ($recipients as $address => $name) { + if ($this->isWhitelisted($address)) { + $filtered[$address] = $name; + } + } - return $filtered; - } + return $filtered; + } - /** - * Matches address against whitelist of regular expressions. - * - * @return bool - */ - protected function isWhitelisted($recipient) - { - if (\in_array($recipient, (array) $this->recipient)) { - return true; - } + /** + * Matches address against whitelist of regular expressions. + * + * @return bool + */ + protected function isWhitelisted($recipient) + { + if (\in_array($recipient, (array) $this->recipient)) { + return true; + } - foreach ($this->whitelist as $pattern) { - if (preg_match($pattern, $recipient)) { - return true; - } - } + foreach ($this->whitelist as $pattern) { + if (preg_match($pattern, $recipient)) { + return true; + } + } - return false; - } + return false; + } - /** - * Invoked immediately after the Message is sent. - */ - public function sendPerformed(Swift_Events_SendEvent $evt) - { - $this->restoreMessage($evt->getMessage()); - } + /** + * Invoked immediately after the Message is sent. + */ + public function sendPerformed(Swift_Events_SendEvent $evt) + { + $this->restoreMessage($evt->getMessage()); + } - private function restoreMessage(Swift_Mime_SimpleMessage $message) - { - // restore original headers - $headers = $message->getHeaders(); + private function restoreMessage(Swift_Mime_SimpleMessage $message) + { + // restore original headers + $headers = $message->getHeaders(); - if ($headers->has('X-Swift-To')) { - $message->setTo($headers->get('X-Swift-To')->getNameAddresses()); - $headers->removeAll('X-Swift-To'); - } else { - $message->setTo(null); - } + if ($headers->has('X-Swift-To')) { + $message->setTo($headers->get('X-Swift-To')->getNameAddresses()); + $headers->removeAll('X-Swift-To'); + } else { + $message->setTo(null); + } - if ($headers->has('X-Swift-Cc')) { - $message->setCc($headers->get('X-Swift-Cc')->getNameAddresses()); - $headers->removeAll('X-Swift-Cc'); - } + if ($headers->has('X-Swift-Cc')) { + $message->setCc($headers->get('X-Swift-Cc')->getNameAddresses()); + $headers->removeAll('X-Swift-Cc'); + } - if ($headers->has('X-Swift-Bcc')) { - $message->setBcc($headers->get('X-Swift-Bcc')->getNameAddresses()); - $headers->removeAll('X-Swift-Bcc'); - } - } + if ($headers->has('X-Swift-Bcc')) { + $message->setBcc($headers->get('X-Swift-Bcc')->getNameAddresses()); + $headers->removeAll('X-Swift-Bcc'); + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Reporter.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Reporter.php index 384487ba6f8..b8818339722 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Reporter.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Reporter.php @@ -15,17 +15,17 @@ */ interface Swift_Plugins_Reporter { - /** The recipient was accepted for delivery */ - const RESULT_PASS = 0x01; + /** The recipient was accepted for delivery */ + const RESULT_PASS = 0x01; - /** The recipient could not be accepted */ - const RESULT_FAIL = 0x10; + /** The recipient could not be accepted */ + const RESULT_FAIL = 0x10; - /** - * Notifies this ReportNotifier that $address failed or succeeded. - * - * @param string $address - * @param int $result from {@link RESULT_PASS, RESULT_FAIL} - */ - public function notify(Swift_Mime_SimpleMessage $message, $address, $result); + /** + * Notifies this ReportNotifier that $address failed or succeeded. + * + * @param string $address + * @param int $result from {@link RESULT_PASS, RESULT_FAIL} + */ + public function notify(Swift_Mime_SimpleMessage $message, $address, $result); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/ReporterPlugin.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/ReporterPlugin.php index 2ac77ba2d13..c4a016520f6 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/ReporterPlugin.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/ReporterPlugin.php @@ -15,43 +15,43 @@ */ class Swift_Plugins_ReporterPlugin implements Swift_Events_SendListener { - /** - * The reporter backend which takes notifications. - * - * @var Swift_Plugins_Reporter - */ - private $reporter; + /** + * The reporter backend which takes notifications. + * + * @var Swift_Plugins_Reporter + */ + private $reporter; - /** - * Create a new ReporterPlugin using $reporter. - */ - public function __construct(Swift_Plugins_Reporter $reporter) - { - $this->reporter = $reporter; - } + /** + * Create a new ReporterPlugin using $reporter. + */ + public function __construct(Swift_Plugins_Reporter $reporter) + { + $this->reporter = $reporter; + } - /** - * Not used. - */ - public function beforeSendPerformed(Swift_Events_SendEvent $evt) - { - } + /** + * Not used. + */ + public function beforeSendPerformed(Swift_Events_SendEvent $evt) + { + } - /** - * Invoked immediately after the Message is sent. - */ - public function sendPerformed(Swift_Events_SendEvent $evt) - { - $message = $evt->getMessage(); - $failures = array_flip($evt->getFailedRecipients()); - foreach ((array) $message->getTo() as $address => $null) { - $this->reporter->notify($message, $address, (\array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS)); - } - foreach ((array) $message->getCc() as $address => $null) { - $this->reporter->notify($message, $address, (\array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS)); - } - foreach ((array) $message->getBcc() as $address => $null) { - $this->reporter->notify($message, $address, (\array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS)); - } - } + /** + * Invoked immediately after the Message is sent. + */ + public function sendPerformed(Swift_Events_SendEvent $evt) + { + $message = $evt->getMessage(); + $failures = array_flip($evt->getFailedRecipients()); + foreach ((array) $message->getTo() as $address => $null) { + $this->reporter->notify($message, $address, (\array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS)); + } + foreach ((array) $message->getCc() as $address => $null) { + $this->reporter->notify($message, $address, (\array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS)); + } + foreach ((array) $message->getBcc() as $address => $null) { + $this->reporter->notify($message, $address, (\array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS)); + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Reporters/HitReporter.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Reporters/HitReporter.php index ef88d47119e..249cffbde7b 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Reporters/HitReporter.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Reporters/HitReporter.php @@ -15,44 +15,44 @@ */ class Swift_Plugins_Reporters_HitReporter implements Swift_Plugins_Reporter { - /** - * The list of failures. - * - * @var array - */ - private $failures = []; + /** + * The list of failures. + * + * @var array + */ + private $failures = []; - private $failures_cache = []; + private $failures_cache = []; - /** - * Notifies this ReportNotifier that $address failed or succeeded. - * - * @param string $address - * @param int $result from {@link RESULT_PASS, RESULT_FAIL} - */ - public function notify(Swift_Mime_SimpleMessage $message, $address, $result) - { - if (self::RESULT_FAIL == $result && !isset($this->failures_cache[$address])) { - $this->failures[] = $address; - $this->failures_cache[$address] = true; - } - } + /** + * Notifies this ReportNotifier that $address failed or succeeded. + * + * @param string $address + * @param int $result from {@link RESULT_PASS, RESULT_FAIL} + */ + public function notify(Swift_Mime_SimpleMessage $message, $address, $result) + { + if (self::RESULT_FAIL == $result && !isset($this->failures_cache[$address])) { + $this->failures[] = $address; + $this->failures_cache[$address] = true; + } + } - /** - * Get an array of addresses for which delivery failed. - * - * @return array - */ - public function getFailedRecipients() - { - return $this->failures; - } + /** + * Get an array of addresses for which delivery failed. + * + * @return array + */ + public function getFailedRecipients() + { + return $this->failures; + } - /** - * Clear the buffer (empty the list). - */ - public function clear() - { - $this->failures = $this->failures_cache = []; - } + /** + * Clear the buffer (empty the list). + */ + public function clear() + { + $this->failures = $this->failures_cache = []; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Reporters/HtmlReporter.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Reporters/HtmlReporter.php index 710a0b370dd..1cfc3f974f8 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Reporters/HtmlReporter.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Reporters/HtmlReporter.php @@ -15,24 +15,24 @@ */ class Swift_Plugins_Reporters_HtmlReporter implements Swift_Plugins_Reporter { - /** - * Notifies this ReportNotifier that $address failed or succeeded. - * - * @param string $address - * @param int $result from {@see RESULT_PASS, RESULT_FAIL} - */ - public function notify(Swift_Mime_SimpleMessage $message, $address, $result) - { - if (self::RESULT_PASS == $result) { - echo '
'.PHP_EOL; - echo 'PASS '.$address.PHP_EOL; - echo '
'.PHP_EOL; - flush(); - } else { - echo '
'.PHP_EOL; - echo 'FAIL '.$address.PHP_EOL; - echo '
'.PHP_EOL; - flush(); - } - } + /** + * Notifies this ReportNotifier that $address failed or succeeded. + * + * @param string $address + * @param int $result from {@see RESULT_PASS, RESULT_FAIL} + */ + public function notify(Swift_Mime_SimpleMessage $message, $address, $result) + { + if (self::RESULT_PASS == $result) { + echo '
'.PHP_EOL; + echo 'PASS '.$address.PHP_EOL; + echo '
'.PHP_EOL; + flush(); + } else { + echo '
'.PHP_EOL; + echo 'FAIL '.$address.PHP_EOL; + echo '
'.PHP_EOL; + flush(); + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/ThrottlerPlugin.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/ThrottlerPlugin.php index 82c5d9fb99f..83d3044927f 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/ThrottlerPlugin.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/ThrottlerPlugin.php @@ -15,182 +15,182 @@ */ class Swift_Plugins_ThrottlerPlugin extends Swift_Plugins_BandwidthMonitorPlugin implements Swift_Plugins_Sleeper, Swift_Plugins_Timer { - /** Flag for throttling in bytes per minute */ - const BYTES_PER_MINUTE = 0x01; + /** Flag for throttling in bytes per minute */ + const BYTES_PER_MINUTE = 0x01; - /** Flag for throttling in emails per second (Amazon SES) */ - const MESSAGES_PER_SECOND = 0x11; + /** Flag for throttling in emails per second (Amazon SES) */ + const MESSAGES_PER_SECOND = 0x11; - /** Flag for throttling in emails per minute */ - const MESSAGES_PER_MINUTE = 0x10; + /** Flag for throttling in emails per minute */ + const MESSAGES_PER_MINUTE = 0x10; - /** - * The Sleeper instance for sleeping. - * - * @var Swift_Plugins_Sleeper - */ - private $sleeper; + /** + * The Sleeper instance for sleeping. + * + * @var Swift_Plugins_Sleeper + */ + private $sleeper; - /** - * The Timer instance which provides the timestamp. - * - * @var Swift_Plugins_Timer - */ - private $timer; + /** + * The Timer instance which provides the timestamp. + * + * @var Swift_Plugins_Timer + */ + private $timer; - /** - * The time at which the first email was sent. - * - * @var int - */ - private $start; + /** + * The time at which the first email was sent. + * + * @var int + */ + private $start; - /** - * The rate at which messages should be sent. - * - * @var int - */ - private $rate; + /** + * The rate at which messages should be sent. + * + * @var int + */ + private $rate; - /** - * The mode for throttling. - * - * This is {@link BYTES_PER_MINUTE} or {@link MESSAGES_PER_MINUTE} - * - * @var int - */ - private $mode; + /** + * The mode for throttling. + * + * This is {@link BYTES_PER_MINUTE} or {@link MESSAGES_PER_MINUTE} + * + * @var int + */ + private $mode; - /** - * An internal counter of the number of messages sent. - * - * @var int - */ - private $messages = 0; + /** + * An internal counter of the number of messages sent. + * + * @var int + */ + private $messages = 0; - /** - * Create a new ThrottlerPlugin. - * - * @param int $rate - * @param int $mode defaults to {@link BYTES_PER_MINUTE} - * @param Swift_Plugins_Sleeper $sleeper (only needed in testing) - * @param Swift_Plugins_Timer $timer (only needed in testing) - */ - public function __construct($rate, $mode = self::BYTES_PER_MINUTE, Swift_Plugins_Sleeper $sleeper = null, Swift_Plugins_Timer $timer = null) - { - $this->rate = $rate; - $this->mode = $mode; - $this->sleeper = $sleeper; - $this->timer = $timer; - } + /** + * Create a new ThrottlerPlugin. + * + * @param int $rate + * @param int $mode defaults to {@link BYTES_PER_MINUTE} + * @param Swift_Plugins_Sleeper $sleeper (only needed in testing) + * @param Swift_Plugins_Timer $timer (only needed in testing) + */ + public function __construct($rate, $mode = self::BYTES_PER_MINUTE, Swift_Plugins_Sleeper $sleeper = null, Swift_Plugins_Timer $timer = null) + { + $this->rate = $rate; + $this->mode = $mode; + $this->sleeper = $sleeper; + $this->timer = $timer; + } - /** - * Invoked immediately before the Message is sent. - */ - public function beforeSendPerformed(Swift_Events_SendEvent $evt) - { - $time = $this->getTimestamp(); - if (!isset($this->start)) { - $this->start = $time; - } - $duration = $time - $this->start; + /** + * Invoked immediately before the Message is sent. + */ + public function beforeSendPerformed(Swift_Events_SendEvent $evt) + { + $time = $this->getTimestamp(); + if (!isset($this->start)) { + $this->start = $time; + } + $duration = $time - $this->start; - switch ($this->mode) { - case self::BYTES_PER_MINUTE: - $sleep = $this->throttleBytesPerMinute($duration); - break; - case self::MESSAGES_PER_SECOND: - $sleep = $this->throttleMessagesPerSecond($duration); - break; - case self::MESSAGES_PER_MINUTE: - $sleep = $this->throttleMessagesPerMinute($duration); - break; - default: - $sleep = 0; - break; - } + switch ($this->mode) { + case self::BYTES_PER_MINUTE: + $sleep = $this->throttleBytesPerMinute($duration); + break; + case self::MESSAGES_PER_SECOND: + $sleep = $this->throttleMessagesPerSecond($duration); + break; + case self::MESSAGES_PER_MINUTE: + $sleep = $this->throttleMessagesPerMinute($duration); + break; + default: + $sleep = 0; + break; + } - if ($sleep > 0) { - $this->sleep($sleep); - } - } + if ($sleep > 0) { + $this->sleep($sleep); + } + } - /** - * Invoked when a Message is sent. - */ - public function sendPerformed(Swift_Events_SendEvent $evt) - { - parent::sendPerformed($evt); - ++$this->messages; - } + /** + * Invoked when a Message is sent. + */ + public function sendPerformed(Swift_Events_SendEvent $evt) + { + parent::sendPerformed($evt); + ++$this->messages; + } - /** - * Sleep for $seconds. - * - * @param int $seconds - */ - public function sleep($seconds) - { - if (isset($this->sleeper)) { - $this->sleeper->sleep($seconds); - } else { - sleep($seconds); - } - } + /** + * Sleep for $seconds. + * + * @param int $seconds + */ + public function sleep($seconds) + { + if (isset($this->sleeper)) { + $this->sleeper->sleep($seconds); + } else { + sleep($seconds); + } + } - /** - * Get the current UNIX timestamp. - * - * @return int - */ - public function getTimestamp() - { - if (isset($this->timer)) { - return $this->timer->getTimestamp(); - } + /** + * Get the current UNIX timestamp. + * + * @return int + */ + public function getTimestamp() + { + if (isset($this->timer)) { + return $this->timer->getTimestamp(); + } - return time(); - } + return time(); + } - /** - * Get a number of seconds to sleep for. - * - * @param int $timePassed - * - * @return int - */ - private function throttleBytesPerMinute($timePassed) - { - $expectedDuration = $this->getBytesOut() / ($this->rate / 60); + /** + * Get a number of seconds to sleep for. + * + * @param int $timePassed + * + * @return int + */ + private function throttleBytesPerMinute($timePassed) + { + $expectedDuration = $this->getBytesOut() / ($this->rate / 60); - return (int) ceil($expectedDuration - $timePassed); - } + return (int) ceil($expectedDuration - $timePassed); + } - /** - * Get a number of seconds to sleep for. - * - * @param int $timePassed - * - * @return int - */ - private function throttleMessagesPerSecond($timePassed) - { - $expectedDuration = $this->messages / $this->rate; + /** + * Get a number of seconds to sleep for. + * + * @param int $timePassed + * + * @return int + */ + private function throttleMessagesPerSecond($timePassed) + { + $expectedDuration = $this->messages / $this->rate; - return (int) ceil($expectedDuration - $timePassed); - } + return (int) ceil($expectedDuration - $timePassed); + } - /** - * Get a number of seconds to sleep for. - * - * @param int $timePassed - * - * @return int - */ - private function throttleMessagesPerMinute($timePassed) - { - $expectedDuration = $this->messages / ($this->rate / 60); + /** + * Get a number of seconds to sleep for. + * + * @param int $timePassed + * + * @return int + */ + private function throttleMessagesPerMinute($timePassed) + { + $expectedDuration = $this->messages / ($this->rate / 60); - return (int) ceil($expectedDuration - $timePassed); - } + return (int) ceil($expectedDuration - $timePassed); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Preferences.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Preferences.php index 237824ea180..16103e11031 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Preferences.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Preferences.php @@ -15,86 +15,86 @@ */ class Swift_Preferences { - /** Singleton instance */ - private static $instance = null; + /** Singleton instance */ + private static $instance = null; - /** Constructor not to be used */ - private function __construct() - { - } + /** Constructor not to be used */ + private function __construct() + { + } - /** - * Gets the instance of Preferences. - * - * @return self - */ - public static function getInstance() - { - if (!isset(self::$instance)) { - self::$instance = new self(); - } + /** + * Gets the instance of Preferences. + * + * @return self + */ + public static function getInstance() + { + if (!isset(self::$instance)) { + self::$instance = new self(); + } - return self::$instance; - } + return self::$instance; + } - /** - * Set the default charset used. - * - * @param string $charset - * - * @return $this - */ - public function setCharset($charset) - { - Swift_DependencyContainer::getInstance()->register('properties.charset')->asValue($charset); + /** + * Set the default charset used. + * + * @param string $charset + * + * @return $this + */ + public function setCharset($charset) + { + Swift_DependencyContainer::getInstance()->register('properties.charset')->asValue($charset); - return $this; - } + return $this; + } - /** - * Set the directory where temporary files can be saved. - * - * @param string $dir - * - * @return $this - */ - public function setTempDir($dir) - { - Swift_DependencyContainer::getInstance()->register('tempdir')->asValue($dir); + /** + * Set the directory where temporary files can be saved. + * + * @param string $dir + * + * @return $this + */ + public function setTempDir($dir) + { + Swift_DependencyContainer::getInstance()->register('tempdir')->asValue($dir); - return $this; - } + return $this; + } - /** - * Set the type of cache to use (i.e. "disk" or "array"). - * - * @param string $type - * - * @return $this - */ - public function setCacheType($type) - { - Swift_DependencyContainer::getInstance()->register('cache')->asAliasOf(sprintf('cache.%s', $type)); + /** + * Set the type of cache to use (i.e. "disk" or "array"). + * + * @param string $type + * + * @return $this + */ + public function setCacheType($type) + { + Swift_DependencyContainer::getInstance()->register('cache')->asAliasOf(sprintf('cache.%s', $type)); - return $this; - } + return $this; + } - /** - * Set the QuotedPrintable dot escaper preference. - * - * @param bool $dotEscape - * - * @return $this - */ - public function setQPDotEscape($dotEscape) - { - $dotEscape = !empty($dotEscape); - Swift_DependencyContainer::getInstance() - ->register('mime.qpcontentencoder') - ->asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoder') - ->withDependencies(['mime.charstream', 'mime.bytecanonicalizer']) - ->addConstructorValue($dotEscape); + /** + * Set the QuotedPrintable dot escaper preference. + * + * @param bool $dotEscape + * + * @return $this + */ + public function setQPDotEscape($dotEscape) + { + $dotEscape = !empty($dotEscape); + Swift_DependencyContainer::getInstance() + ->register('mime.qpcontentencoder') + ->asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoder') + ->withDependencies(['mime.charstream', 'mime.bytecanonicalizer']) + ->addConstructorValue($dotEscape); - return $this; - } + return $this; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/SendmailTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/SendmailTransport.php index 9f159857a51..3c756436cc8 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/SendmailTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/SendmailTransport.php @@ -15,19 +15,19 @@ */ class Swift_SendmailTransport extends Swift_Transport_SendmailTransport { - /** - * Create a new SendmailTransport, optionally using $command for sending. - * - * @param string $command - */ - public function __construct($command = '/usr/sbin/sendmail -bs') - { - \call_user_func_array( - [$this, 'Swift_Transport_SendmailTransport::__construct'], - Swift_DependencyContainer::getInstance() - ->createDependenciesFor('transport.sendmail') - ); + /** + * Create a new SendmailTransport, optionally using $command for sending. + * + * @param string $command + */ + public function __construct($command = '/usr/sbin/sendmail -bs') + { + \call_user_func_array( + [$this, 'Swift_Transport_SendmailTransport::__construct'], + Swift_DependencyContainer::getInstance() + ->createDependenciesFor('transport.sendmail') + ); - $this->setCommand($command); - } + $this->setCommand($command); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Signer.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Signer.php index 4a681f83bfa..26c5e285c03 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Signer.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Signer.php @@ -15,5 +15,5 @@ */ interface Swift_Signer { - public function reset(); + public function reset(); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/BodySigner.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/BodySigner.php index a874e1ab2cb..b25c427af83 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/BodySigner.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/BodySigner.php @@ -15,17 +15,17 @@ */ interface Swift_Signers_BodySigner extends Swift_Signer { - /** - * Change the Swift_Signed_Message to apply the singing. - * - * @return self - */ - public function signMessage(Swift_Message $message); + /** + * Change the Swift_Signed_Message to apply the singing. + * + * @return self + */ + public function signMessage(Swift_Message $message); - /** - * Return the list of header a signer might tamper. - * - * @return array - */ - public function getAlteredHeaders(); + /** + * Return the list of header a signer might tamper. + * + * @return array + */ + public function getAlteredHeaders(); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/DKIMSigner.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/DKIMSigner.php index e7323cb19b9..ec82dc05663 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/DKIMSigner.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/DKIMSigner.php @@ -15,668 +15,668 @@ */ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner { - /** - * PrivateKey. - * - * @var string - */ - protected $privateKey; - - /** - * DomainName. - * - * @var string - */ - protected $domainName; - - /** - * Selector. - * - * @var string - */ - protected $selector; - - private $passphrase = ''; - - /** - * Hash algorithm used. - * - * @see RFC6376 3.3: Signers MUST implement and SHOULD sign using rsa-sha256. - * - * @var string - */ - protected $hashAlgorithm = 'rsa-sha256'; - - /** - * Body canon method. - * - * @var string - */ - protected $bodyCanon = 'simple'; - - /** - * Header canon method. - * - * @var string - */ - protected $headerCanon = 'simple'; - - /** - * Headers not being signed. - * - * @var array - */ - protected $ignoredHeaders = ['return-path' => true]; - - /** - * Signer identity. - * - * @var string - */ - protected $signerIdentity; - - /** - * BodyLength. - * - * @var int - */ - protected $bodyLen = 0; - - /** - * Maximum signedLen. - * - * @var int - */ - protected $maxLen = PHP_INT_MAX; - - /** - * Embbed bodyLen in signature. - * - * @var bool - */ - protected $showLen = false; - - /** - * When the signature has been applied (true means time()), false means not embedded. - * - * @var mixed - */ - protected $signatureTimestamp = true; - - /** - * When will the signature expires false means not embedded, if sigTimestamp is auto - * Expiration is relative, otherwise it's absolute. - * - * @var int - */ - protected $signatureExpiration = false; - - /** - * Must we embed signed headers? - * - * @var bool - */ - protected $debugHeaders = false; - - // work variables - /** - * Headers used to generate hash. - * - * @var array - */ - protected $signedHeaders = []; - - /** - * If debugHeaders is set store debugData here. - * - * @var string[] - */ - private $debugHeadersData = []; - - /** - * Stores the bodyHash. - * - * @var string - */ - private $bodyHash = ''; - - /** - * Stores the signature header. - * - * @var Swift_Mime_Headers_ParameterizedHeader - */ - protected $dkimHeader; - - private $bodyHashHandler; - - private $headerHash; - - private $headerCanonData = ''; - - private $bodyCanonEmptyCounter = 0; - - private $bodyCanonIgnoreStart = 2; - - private $bodyCanonSpace = false; - - private $bodyCanonLastChar = null; - - private $bodyCanonLine = ''; - - private $bound = []; - - /** - * Constructor. - * - * @param string $privateKey - * @param string $domainName - * @param string $selector - * @param string $passphrase - */ - public function __construct($privateKey, $domainName, $selector, $passphrase = '') - { - $this->privateKey = $privateKey; - $this->domainName = $domainName; - $this->signerIdentity = '@'.$domainName; - $this->selector = $selector; - $this->passphrase = $passphrase; - } - - /** - * Reset the Signer. - * - * @see Swift_Signer::reset() - */ - public function reset() - { - $this->headerHash = null; - $this->signedHeaders = []; - $this->bodyHash = null; - $this->bodyHashHandler = null; - $this->bodyCanonIgnoreStart = 2; - $this->bodyCanonEmptyCounter = 0; - $this->bodyCanonLastChar = null; - $this->bodyCanonSpace = false; - } - - /** - * Writes $bytes to the end of the stream. - * - * Writing may not happen immediately if the stream chooses to buffer. If - * you want to write these bytes with immediate effect, call {@link commit()} - * after calling write(). - * - * This method returns the sequence ID of the write (i.e. 1 for first, 2 for - * second, etc etc). - * - * @param string $bytes - * - * @return int - * - * @throws Swift_IoException - */ - // TODO fix return - public function write($bytes) - { - $this->canonicalizeBody($bytes); - foreach ($this->bound as $is) { - $is->write($bytes); - } - } - - /** - * For any bytes that are currently buffered inside the stream, force them - * off the buffer. - */ - public function commit() - { - // Nothing to do - return; - } - - /** - * Attach $is to this stream. - * - * The stream acts as an observer, receiving all data that is written. - * All {@link write()} and {@link flushBuffers()} operations will be mirrored. - */ - public function bind(Swift_InputByteStream $is) - { - // Don't have to mirror anything - $this->bound[] = $is; - - return; - } - - /** - * Remove an already bound stream. - * - * If $is is not bound, no errors will be raised. - * If the stream currently has any buffered data it will be written to $is - * before unbinding occurs. - */ - public function unbind(Swift_InputByteStream $is) - { - // Don't have to mirror anything - foreach ($this->bound as $k => $stream) { - if ($stream === $is) { - unset($this->bound[$k]); - - return; - } - } - } - - /** - * Flush the contents of the stream (empty it) and set the internal pointer - * to the beginning. - * - * @throws Swift_IoException - */ - public function flushBuffers() - { - $this->reset(); - } - - /** - * Set hash_algorithm, must be one of rsa-sha256 | rsa-sha1. - * - * @param string $hash 'rsa-sha1' or 'rsa-sha256' - * - * @throws Swift_SwiftException - * - * @return $this - */ - public function setHashAlgorithm($hash) - { - switch ($hash) { - case 'rsa-sha1': - $this->hashAlgorithm = 'rsa-sha1'; - break; - case 'rsa-sha256': - $this->hashAlgorithm = 'rsa-sha256'; - if (!\defined('OPENSSL_ALGO_SHA256')) { - throw new Swift_SwiftException('Unable to set sha256 as it is not supported by OpenSSL.'); - } - break; - default: - throw new Swift_SwiftException('Unable to set the hash algorithm, must be one of rsa-sha1 or rsa-sha256 (%s given).', $hash); - } - - return $this; - } - - /** - * Set the body canonicalization algorithm. - * - * @param string $canon - * - * @return $this - */ - public function setBodyCanon($canon) - { - if ('relaxed' == $canon) { - $this->bodyCanon = 'relaxed'; - } else { - $this->bodyCanon = 'simple'; - } - - return $this; - } - - /** - * Set the header canonicalization algorithm. - * - * @param string $canon - * - * @return $this - */ - public function setHeaderCanon($canon) - { - if ('relaxed' == $canon) { - $this->headerCanon = 'relaxed'; - } else { - $this->headerCanon = 'simple'; - } - - return $this; - } - - /** - * Set the signer identity. - * - * @param string $identity - * - * @return $this - */ - public function setSignerIdentity($identity) - { - $this->signerIdentity = $identity; - - return $this; - } - - /** - * Set the length of the body to sign. - * - * @param mixed $len (bool or int) - * - * @return $this - */ - public function setBodySignedLen($len) - { - if (true === $len) { - $this->showLen = true; - $this->maxLen = PHP_INT_MAX; - } elseif (false === $len) { - $this->showLen = false; - $this->maxLen = PHP_INT_MAX; - } else { - $this->showLen = true; - $this->maxLen = (int) $len; - } - - return $this; - } - - /** - * Set the signature timestamp. - * - * @param int $time A timestamp - * - * @return $this - */ - public function setSignatureTimestamp($time) - { - $this->signatureTimestamp = $time; - - return $this; - } - - /** - * Set the signature expiration timestamp. - * - * @param int $time A timestamp - * - * @return $this - */ - public function setSignatureExpiration($time) - { - $this->signatureExpiration = $time; - - return $this; - } - - /** - * Enable / disable the DebugHeaders. - * - * @param bool $debug - * - * @return Swift_Signers_DKIMSigner - */ - public function setDebugHeaders($debug) - { - $this->debugHeaders = (bool) $debug; - - return $this; - } - - /** - * Start Body. - */ - public function startBody() - { - // Init - switch ($this->hashAlgorithm) { - case 'rsa-sha256': - $this->bodyHashHandler = hash_init('sha256'); - break; - case 'rsa-sha1': - $this->bodyHashHandler = hash_init('sha1'); - break; - } - $this->bodyCanonLine = ''; - } - - /** - * End Body. - */ - public function endBody() - { - $this->endOfBody(); - } - - /** - * Returns the list of Headers Tampered by this plugin. - * - * @return array - */ - public function getAlteredHeaders() - { - if ($this->debugHeaders) { - return ['DKIM-Signature', 'X-DebugHash']; - } else { - return ['DKIM-Signature']; - } - } - - /** - * Adds an ignored Header. - * - * @param string $header_name - * - * @return Swift_Signers_DKIMSigner - */ - public function ignoreHeader($header_name) - { - $this->ignoredHeaders[strtolower($header_name ?? '')] = true; - - return $this; - } - - /** - * Set the headers to sign. - * - * @return Swift_Signers_DKIMSigner - */ - public function setHeaders(Swift_Mime_SimpleHeaderSet $headers) - { - $this->headerCanonData = ''; - // Loop through Headers - $listHeaders = $headers->listAll(); - foreach ($listHeaders as $hName) { - // Check if we need to ignore Header - if (!isset($this->ignoredHeaders[strtolower($hName ?? '')])) { - if ($headers->has($hName)) { - $tmp = $headers->getAll($hName); - foreach ($tmp as $header) { - if ('' != $header->getFieldBody()) { - $this->addHeader($header->toString()); - $this->signedHeaders[] = $header->getFieldName(); - } - } - } - } - } - - return $this; - } - - /** - * Add the signature to the given Headers. - * - * @return Swift_Signers_DKIMSigner - */ - public function addSignature(Swift_Mime_SimpleHeaderSet $headers) - { - // Prepare the DKIM-Signature - $params = ['v' => '1', 'a' => $this->hashAlgorithm, 'bh' => base64_encode($this->bodyHash ?? ''), 'd' => $this->domainName, 'h' => implode(': ', $this->signedHeaders), 'i' => $this->signerIdentity, 's' => $this->selector]; - if ('simple' != $this->bodyCanon) { - $params['c'] = $this->headerCanon.'/'.$this->bodyCanon; - } elseif ('simple' != $this->headerCanon) { - $params['c'] = $this->headerCanon; - } - if ($this->showLen) { - $params['l'] = $this->bodyLen; - } - if (true === $this->signatureTimestamp) { - $params['t'] = time(); - if (false !== $this->signatureExpiration) { - $params['x'] = $params['t'] + $this->signatureExpiration; - } - } else { - if (false !== $this->signatureTimestamp) { - $params['t'] = $this->signatureTimestamp; - } - if (false !== $this->signatureExpiration) { - $params['x'] = $this->signatureExpiration; - } - } - if ($this->debugHeaders) { - $params['z'] = implode('|', $this->debugHeadersData); - } - $string = ''; - foreach ($params as $k => $v) { - $string .= $k.'='.$v.'; '; - } - $string = trim($string); - $headers->addTextHeader('DKIM-Signature', $string); - // Add the last DKIM-Signature - $tmp = $headers->getAll('DKIM-Signature'); - $this->dkimHeader = end($tmp); - $this->addHeader(trim($this->dkimHeader->toString() ?? '')."\r\n b=", true); - if ($this->debugHeaders) { - $headers->addTextHeader('X-DebugHash', base64_encode($this->headerHash ?? '')); - } - $this->dkimHeader->setValue($string.' b='.trim(chunk_split(base64_encode($this->getEncryptedHash() ?? ''), 73, ' '))); - - return $this; - } - - /* Private helpers */ - - protected function addHeader($header, $is_sig = false) - { - switch ($this->headerCanon) { - case 'relaxed': - // Prepare Header and cascade - $exploded = explode(':', $header, 2); - $name = strtolower(trim($exploded[0])); - $value = str_replace("\r\n", '', $exploded[1]); - $value = preg_replace("/[ \t][ \t]+/", ' ', $value); - $header = $name.':'.trim($value).($is_sig ? '' : "\r\n"); - // no break - case 'simple': - // Nothing to do - } - $this->addToHeaderHash($header); - } - - protected function canonicalizeBody($string) - { - $len = \strlen($string); - $canon = ''; - $method = ('relaxed' == $this->bodyCanon); - for ($i = 0; $i < $len; ++$i) { - if ($this->bodyCanonIgnoreStart > 0) { - --$this->bodyCanonIgnoreStart; - continue; - } - switch ($string[$i]) { - case "\r": - $this->bodyCanonLastChar = "\r"; - break; - case "\n": - if ("\r" == $this->bodyCanonLastChar) { - if ($method) { - $this->bodyCanonSpace = false; - } - if ('' == $this->bodyCanonLine) { - ++$this->bodyCanonEmptyCounter; - } else { - $this->bodyCanonLine = ''; - $canon .= "\r\n"; - } - } else { - // Wooops Error - // todo handle it but should never happen - } - break; - case ' ': - case "\t": - if ($method) { - $this->bodyCanonSpace = true; - break; - } - // no break - default: - if ($this->bodyCanonEmptyCounter > 0) { - $canon .= str_repeat("\r\n", $this->bodyCanonEmptyCounter); - $this->bodyCanonEmptyCounter = 0; - } - if ($this->bodyCanonSpace) { - $this->bodyCanonLine .= ' '; - $canon .= ' '; - $this->bodyCanonSpace = false; - } - $this->bodyCanonLine .= $string[$i]; - $canon .= $string[$i]; - } - } - $this->addToBodyHash($canon); - } - - protected function endOfBody() - { - // Add trailing Line return if last line is non empty - if (\strlen($this->bodyCanonLine) > 0) { - $this->addToBodyHash("\r\n"); - } - $this->bodyHash = hash_final($this->bodyHashHandler, true); - } - - private function addToBodyHash($string) - { - $len = \strlen($string); - if ($len > ($new_len = ($this->maxLen - $this->bodyLen))) { - $string = substr($string, 0, $new_len); - $len = $new_len; - } - hash_update($this->bodyHashHandler, $string); - $this->bodyLen += $len; - } - - private function addToHeaderHash($header) - { - if ($this->debugHeaders) { - $this->debugHeadersData[] = trim($header ?? ''); - } - $this->headerCanonData .= $header; - } - - /** - * @throws Swift_SwiftException - * - * @return string - */ - private function getEncryptedHash() - { - $signature = ''; - switch ($this->hashAlgorithm) { - case 'rsa-sha1': - $algorithm = OPENSSL_ALGO_SHA1; - break; - case 'rsa-sha256': - $algorithm = OPENSSL_ALGO_SHA256; - break; - } - $pkeyId = openssl_get_privatekey($this->privateKey, $this->passphrase); - if (!$pkeyId) { - throw new Swift_SwiftException('Unable to load DKIM Private Key ['.openssl_error_string().']'); - } - if (openssl_sign($this->headerCanonData, $signature, $pkeyId, $algorithm)) { - return $signature; - } - throw new Swift_SwiftException('Unable to sign DKIM Hash ['.openssl_error_string().']'); - } + /** + * PrivateKey. + * + * @var string + */ + protected $privateKey; + + /** + * DomainName. + * + * @var string + */ + protected $domainName; + + /** + * Selector. + * + * @var string + */ + protected $selector; + + private $passphrase = ''; + + /** + * Hash algorithm used. + * + * @see RFC6376 3.3: Signers MUST implement and SHOULD sign using rsa-sha256. + * + * @var string + */ + protected $hashAlgorithm = 'rsa-sha256'; + + /** + * Body canon method. + * + * @var string + */ + protected $bodyCanon = 'simple'; + + /** + * Header canon method. + * + * @var string + */ + protected $headerCanon = 'simple'; + + /** + * Headers not being signed. + * + * @var array + */ + protected $ignoredHeaders = ['return-path' => true]; + + /** + * Signer identity. + * + * @var string + */ + protected $signerIdentity; + + /** + * BodyLength. + * + * @var int + */ + protected $bodyLen = 0; + + /** + * Maximum signedLen. + * + * @var int + */ + protected $maxLen = PHP_INT_MAX; + + /** + * Embbed bodyLen in signature. + * + * @var bool + */ + protected $showLen = false; + + /** + * When the signature has been applied (true means time()), false means not embedded. + * + * @var mixed + */ + protected $signatureTimestamp = true; + + /** + * When will the signature expires false means not embedded, if sigTimestamp is auto + * Expiration is relative, otherwise it's absolute. + * + * @var int + */ + protected $signatureExpiration = false; + + /** + * Must we embed signed headers? + * + * @var bool + */ + protected $debugHeaders = false; + + // work variables + /** + * Headers used to generate hash. + * + * @var array + */ + protected $signedHeaders = []; + + /** + * If debugHeaders is set store debugData here. + * + * @var string[] + */ + private $debugHeadersData = []; + + /** + * Stores the bodyHash. + * + * @var string + */ + private $bodyHash = ''; + + /** + * Stores the signature header. + * + * @var Swift_Mime_Headers_ParameterizedHeader + */ + protected $dkimHeader; + + private $bodyHashHandler; + + private $headerHash; + + private $headerCanonData = ''; + + private $bodyCanonEmptyCounter = 0; + + private $bodyCanonIgnoreStart = 2; + + private $bodyCanonSpace = false; + + private $bodyCanonLastChar = null; + + private $bodyCanonLine = ''; + + private $bound = []; + + /** + * Constructor. + * + * @param string $privateKey + * @param string $domainName + * @param string $selector + * @param string $passphrase + */ + public function __construct($privateKey, $domainName, $selector, $passphrase = '') + { + $this->privateKey = $privateKey; + $this->domainName = $domainName; + $this->signerIdentity = '@'.$domainName; + $this->selector = $selector; + $this->passphrase = $passphrase; + } + + /** + * Reset the Signer. + * + * @see Swift_Signer::reset() + */ + public function reset() + { + $this->headerHash = null; + $this->signedHeaders = []; + $this->bodyHash = null; + $this->bodyHashHandler = null; + $this->bodyCanonIgnoreStart = 2; + $this->bodyCanonEmptyCounter = 0; + $this->bodyCanonLastChar = null; + $this->bodyCanonSpace = false; + } + + /** + * Writes $bytes to the end of the stream. + * + * Writing may not happen immediately if the stream chooses to buffer. If + * you want to write these bytes with immediate effect, call {@link commit()} + * after calling write(). + * + * This method returns the sequence ID of the write (i.e. 1 for first, 2 for + * second, etc etc). + * + * @param string $bytes + * + * @return int + * + * @throws Swift_IoException + */ + // TODO fix return + public function write($bytes) + { + $this->canonicalizeBody($bytes); + foreach ($this->bound as $is) { + $is->write($bytes); + } + } + + /** + * For any bytes that are currently buffered inside the stream, force them + * off the buffer. + */ + public function commit() + { + // Nothing to do + return; + } + + /** + * Attach $is to this stream. + * + * The stream acts as an observer, receiving all data that is written. + * All {@link write()} and {@link flushBuffers()} operations will be mirrored. + */ + public function bind(Swift_InputByteStream $is) + { + // Don't have to mirror anything + $this->bound[] = $is; + + return; + } + + /** + * Remove an already bound stream. + * + * If $is is not bound, no errors will be raised. + * If the stream currently has any buffered data it will be written to $is + * before unbinding occurs. + */ + public function unbind(Swift_InputByteStream $is) + { + // Don't have to mirror anything + foreach ($this->bound as $k => $stream) { + if ($stream === $is) { + unset($this->bound[$k]); + + return; + } + } + } + + /** + * Flush the contents of the stream (empty it) and set the internal pointer + * to the beginning. + * + * @throws Swift_IoException + */ + public function flushBuffers() + { + $this->reset(); + } + + /** + * Set hash_algorithm, must be one of rsa-sha256 | rsa-sha1. + * + * @param string $hash 'rsa-sha1' or 'rsa-sha256' + * + * @throws Swift_SwiftException + * + * @return $this + */ + public function setHashAlgorithm($hash) + { + switch ($hash) { + case 'rsa-sha1': + $this->hashAlgorithm = 'rsa-sha1'; + break; + case 'rsa-sha256': + $this->hashAlgorithm = 'rsa-sha256'; + if (!\defined('OPENSSL_ALGO_SHA256')) { + throw new Swift_SwiftException('Unable to set sha256 as it is not supported by OpenSSL.'); + } + break; + default: + throw new Swift_SwiftException('Unable to set the hash algorithm, must be one of rsa-sha1 or rsa-sha256 (%s given).', $hash); + } + + return $this; + } + + /** + * Set the body canonicalization algorithm. + * + * @param string $canon + * + * @return $this + */ + public function setBodyCanon($canon) + { + if ('relaxed' == $canon) { + $this->bodyCanon = 'relaxed'; + } else { + $this->bodyCanon = 'simple'; + } + + return $this; + } + + /** + * Set the header canonicalization algorithm. + * + * @param string $canon + * + * @return $this + */ + public function setHeaderCanon($canon) + { + if ('relaxed' == $canon) { + $this->headerCanon = 'relaxed'; + } else { + $this->headerCanon = 'simple'; + } + + return $this; + } + + /** + * Set the signer identity. + * + * @param string $identity + * + * @return $this + */ + public function setSignerIdentity($identity) + { + $this->signerIdentity = $identity; + + return $this; + } + + /** + * Set the length of the body to sign. + * + * @param mixed $len (bool or int) + * + * @return $this + */ + public function setBodySignedLen($len) + { + if (true === $len) { + $this->showLen = true; + $this->maxLen = PHP_INT_MAX; + } elseif (false === $len) { + $this->showLen = false; + $this->maxLen = PHP_INT_MAX; + } else { + $this->showLen = true; + $this->maxLen = (int) $len; + } + + return $this; + } + + /** + * Set the signature timestamp. + * + * @param int $time A timestamp + * + * @return $this + */ + public function setSignatureTimestamp($time) + { + $this->signatureTimestamp = $time; + + return $this; + } + + /** + * Set the signature expiration timestamp. + * + * @param int $time A timestamp + * + * @return $this + */ + public function setSignatureExpiration($time) + { + $this->signatureExpiration = $time; + + return $this; + } + + /** + * Enable / disable the DebugHeaders. + * + * @param bool $debug + * + * @return Swift_Signers_DKIMSigner + */ + public function setDebugHeaders($debug) + { + $this->debugHeaders = (bool) $debug; + + return $this; + } + + /** + * Start Body. + */ + public function startBody() + { + // Init + switch ($this->hashAlgorithm) { + case 'rsa-sha256': + $this->bodyHashHandler = hash_init('sha256'); + break; + case 'rsa-sha1': + $this->bodyHashHandler = hash_init('sha1'); + break; + } + $this->bodyCanonLine = ''; + } + + /** + * End Body. + */ + public function endBody() + { + $this->endOfBody(); + } + + /** + * Returns the list of Headers Tampered by this plugin. + * + * @return array + */ + public function getAlteredHeaders() + { + if ($this->debugHeaders) { + return ['DKIM-Signature', 'X-DebugHash']; + } else { + return ['DKIM-Signature']; + } + } + + /** + * Adds an ignored Header. + * + * @param string $header_name + * + * @return Swift_Signers_DKIMSigner + */ + public function ignoreHeader($header_name) + { + $this->ignoredHeaders[strtolower($header_name ?? '')] = true; + + return $this; + } + + /** + * Set the headers to sign. + * + * @return Swift_Signers_DKIMSigner + */ + public function setHeaders(Swift_Mime_SimpleHeaderSet $headers) + { + $this->headerCanonData = ''; + // Loop through Headers + $listHeaders = $headers->listAll(); + foreach ($listHeaders as $hName) { + // Check if we need to ignore Header + if (!isset($this->ignoredHeaders[strtolower($hName ?? '')])) { + if ($headers->has($hName)) { + $tmp = $headers->getAll($hName); + foreach ($tmp as $header) { + if ('' != $header->getFieldBody()) { + $this->addHeader($header->toString()); + $this->signedHeaders[] = $header->getFieldName(); + } + } + } + } + } + + return $this; + } + + /** + * Add the signature to the given Headers. + * + * @return Swift_Signers_DKIMSigner + */ + public function addSignature(Swift_Mime_SimpleHeaderSet $headers) + { + // Prepare the DKIM-Signature + $params = ['v' => '1', 'a' => $this->hashAlgorithm, 'bh' => base64_encode($this->bodyHash ?? ''), 'd' => $this->domainName, 'h' => implode(': ', $this->signedHeaders), 'i' => $this->signerIdentity, 's' => $this->selector]; + if ('simple' != $this->bodyCanon) { + $params['c'] = $this->headerCanon.'/'.$this->bodyCanon; + } elseif ('simple' != $this->headerCanon) { + $params['c'] = $this->headerCanon; + } + if ($this->showLen) { + $params['l'] = $this->bodyLen; + } + if (true === $this->signatureTimestamp) { + $params['t'] = time(); + if (false !== $this->signatureExpiration) { + $params['x'] = $params['t'] + $this->signatureExpiration; + } + } else { + if (false !== $this->signatureTimestamp) { + $params['t'] = $this->signatureTimestamp; + } + if (false !== $this->signatureExpiration) { + $params['x'] = $this->signatureExpiration; + } + } + if ($this->debugHeaders) { + $params['z'] = implode('|', $this->debugHeadersData); + } + $string = ''; + foreach ($params as $k => $v) { + $string .= $k.'='.$v.'; '; + } + $string = trim($string); + $headers->addTextHeader('DKIM-Signature', $string); + // Add the last DKIM-Signature + $tmp = $headers->getAll('DKIM-Signature'); + $this->dkimHeader = end($tmp); + $this->addHeader(trim($this->dkimHeader->toString() ?? '')."\r\n b=", true); + if ($this->debugHeaders) { + $headers->addTextHeader('X-DebugHash', base64_encode($this->headerHash ?? '')); + } + $this->dkimHeader->setValue($string.' b='.trim(chunk_split(base64_encode($this->getEncryptedHash() ?? ''), 73, ' '))); + + return $this; + } + + /* Private helpers */ + + protected function addHeader($header, $is_sig = false) + { + switch ($this->headerCanon) { + case 'relaxed': + // Prepare Header and cascade + $exploded = explode(':', $header, 2); + $name = strtolower(trim($exploded[0])); + $value = str_replace("\r\n", '', $exploded[1]); + $value = preg_replace("/[ \t][ \t]+/", ' ', $value); + $header = $name.':'.trim($value).($is_sig ? '' : "\r\n"); + // no break + case 'simple': + // Nothing to do + } + $this->addToHeaderHash($header); + } + + protected function canonicalizeBody($string) + { + $len = \strlen($string); + $canon = ''; + $method = ('relaxed' == $this->bodyCanon); + for ($i = 0; $i < $len; ++$i) { + if ($this->bodyCanonIgnoreStart > 0) { + --$this->bodyCanonIgnoreStart; + continue; + } + switch ($string[$i]) { + case "\r": + $this->bodyCanonLastChar = "\r"; + break; + case "\n": + if ("\r" == $this->bodyCanonLastChar) { + if ($method) { + $this->bodyCanonSpace = false; + } + if ('' == $this->bodyCanonLine) { + ++$this->bodyCanonEmptyCounter; + } else { + $this->bodyCanonLine = ''; + $canon .= "\r\n"; + } + } else { + // Wooops Error + // todo handle it but should never happen + } + break; + case ' ': + case "\t": + if ($method) { + $this->bodyCanonSpace = true; + break; + } + // no break + default: + if ($this->bodyCanonEmptyCounter > 0) { + $canon .= str_repeat("\r\n", $this->bodyCanonEmptyCounter); + $this->bodyCanonEmptyCounter = 0; + } + if ($this->bodyCanonSpace) { + $this->bodyCanonLine .= ' '; + $canon .= ' '; + $this->bodyCanonSpace = false; + } + $this->bodyCanonLine .= $string[$i]; + $canon .= $string[$i]; + } + } + $this->addToBodyHash($canon); + } + + protected function endOfBody() + { + // Add trailing Line return if last line is non empty + if (\strlen($this->bodyCanonLine) > 0) { + $this->addToBodyHash("\r\n"); + } + $this->bodyHash = hash_final($this->bodyHashHandler, true); + } + + private function addToBodyHash($string) + { + $len = \strlen($string); + if ($len > ($new_len = ($this->maxLen - $this->bodyLen))) { + $string = substr($string, 0, $new_len); + $len = $new_len; + } + hash_update($this->bodyHashHandler, $string); + $this->bodyLen += $len; + } + + private function addToHeaderHash($header) + { + if ($this->debugHeaders) { + $this->debugHeadersData[] = trim($header ?? ''); + } + $this->headerCanonData .= $header; + } + + /** + * @throws Swift_SwiftException + * + * @return string + */ + private function getEncryptedHash() + { + $signature = ''; + switch ($this->hashAlgorithm) { + case 'rsa-sha1': + $algorithm = OPENSSL_ALGO_SHA1; + break; + case 'rsa-sha256': + $algorithm = OPENSSL_ALGO_SHA256; + break; + } + $pkeyId = openssl_get_privatekey($this->privateKey, $this->passphrase); + if (!$pkeyId) { + throw new Swift_SwiftException('Unable to load DKIM Private Key ['.openssl_error_string().']'); + } + if (openssl_sign($this->headerCanonData, $signature, $pkeyId, $algorithm)) { + return $signature; + } + throw new Swift_SwiftException('Unable to sign DKIM Hash ['.openssl_error_string().']'); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/DomainKeySigner.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/DomainKeySigner.php index 884996b40eb..5e2b67b6520 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/DomainKeySigner.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/DomainKeySigner.php @@ -15,490 +15,490 @@ */ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner { - /** - * PrivateKey. - * - * @var string - */ - protected $privateKey; + /** + * PrivateKey. + * + * @var string + */ + protected $privateKey; - /** - * DomainName. - * - * @var string - */ - protected $domainName; + /** + * DomainName. + * + * @var string + */ + protected $domainName; - /** - * Selector. - * - * @var string - */ - protected $selector; + /** + * Selector. + * + * @var string + */ + protected $selector; - /** - * Hash algorithm used. - * - * @var string - */ - protected $hashAlgorithm = 'rsa-sha1'; + /** + * Hash algorithm used. + * + * @var string + */ + protected $hashAlgorithm = 'rsa-sha1'; - /** - * Canonisation method. - * - * @var string - */ - protected $canon = 'simple'; + /** + * Canonisation method. + * + * @var string + */ + protected $canon = 'simple'; - /** - * Headers not being signed. - * - * @var array - */ - protected $ignoredHeaders = []; + /** + * Headers not being signed. + * + * @var array + */ + protected $ignoredHeaders = []; - /** - * Signer identity. - * - * @var string - */ - protected $signerIdentity; + /** + * Signer identity. + * + * @var string + */ + protected $signerIdentity; - /** - * Must we embed signed headers? - * - * @var bool - */ - protected $debugHeaders = false; + /** + * Must we embed signed headers? + * + * @var bool + */ + protected $debugHeaders = false; - // work variables - /** - * Headers used to generate hash. - * - * @var array - */ - private $signedHeaders = []; + // work variables + /** + * Headers used to generate hash. + * + * @var array + */ + private $signedHeaders = []; - /** - * Stores the signature header. - * - * @var Swift_Mime_Headers_ParameterizedHeader - */ - protected $domainKeyHeader; + /** + * Stores the signature header. + * + * @var Swift_Mime_Headers_ParameterizedHeader + */ + protected $domainKeyHeader; - /** - * Hash Handler. - * - * @var resource|null - */ - private $hashHandler; + /** + * Hash Handler. + * + * @var resource|null + */ + private $hashHandler; - private $canonData = ''; + private $canonData = ''; - private $bodyCanonEmptyCounter = 0; + private $bodyCanonEmptyCounter = 0; - private $bodyCanonIgnoreStart = 2; + private $bodyCanonIgnoreStart = 2; - private $bodyCanonSpace = false; + private $bodyCanonSpace = false; - private $bodyCanonLastChar = null; + private $bodyCanonLastChar = null; - private $bodyCanonLine = ''; + private $bodyCanonLine = ''; - private $bound = []; + private $bound = []; - /** - * Constructor. - * - * @param string $privateKey - * @param string $domainName - * @param string $selector - */ - public function __construct($privateKey, $domainName, $selector) - { - $this->privateKey = $privateKey; - $this->domainName = $domainName; - $this->signerIdentity = '@'.$domainName; - $this->selector = $selector; - } + /** + * Constructor. + * + * @param string $privateKey + * @param string $domainName + * @param string $selector + */ + public function __construct($privateKey, $domainName, $selector) + { + $this->privateKey = $privateKey; + $this->domainName = $domainName; + $this->signerIdentity = '@'.$domainName; + $this->selector = $selector; + } - /** - * Resets internal states. - * - * @return $this - */ - public function reset() - { - $this->hashHandler = null; - $this->bodyCanonIgnoreStart = 2; - $this->bodyCanonEmptyCounter = 0; - $this->bodyCanonLastChar = null; - $this->bodyCanonSpace = false; + /** + * Resets internal states. + * + * @return $this + */ + public function reset() + { + $this->hashHandler = null; + $this->bodyCanonIgnoreStart = 2; + $this->bodyCanonEmptyCounter = 0; + $this->bodyCanonLastChar = null; + $this->bodyCanonSpace = false; - return $this; - } + return $this; + } - /** - * Writes $bytes to the end of the stream. - * - * Writing may not happen immediately if the stream chooses to buffer. If - * you want to write these bytes with immediate effect, call {@link commit()} - * after calling write(). - * - * This method returns the sequence ID of the write (i.e. 1 for first, 2 for - * second, etc etc). - * - * @param string $bytes - * - * @return int - * - * @throws Swift_IoException - * - * @return $this - */ - public function write($bytes) - { - $this->canonicalizeBody($bytes); - foreach ($this->bound as $is) { - $is->write($bytes); - } + /** + * Writes $bytes to the end of the stream. + * + * Writing may not happen immediately if the stream chooses to buffer. If + * you want to write these bytes with immediate effect, call {@link commit()} + * after calling write(). + * + * This method returns the sequence ID of the write (i.e. 1 for first, 2 for + * second, etc etc). + * + * @param string $bytes + * + * @return int + * + * @throws Swift_IoException + * + * @return $this + */ + public function write($bytes) + { + $this->canonicalizeBody($bytes); + foreach ($this->bound as $is) { + $is->write($bytes); + } - return $this; - } + return $this; + } - /** - * For any bytes that are currently buffered inside the stream, force them - * off the buffer. - * - * @throws Swift_IoException - * - * @return $this - */ - public function commit() - { - // Nothing to do - return $this; - } + /** + * For any bytes that are currently buffered inside the stream, force them + * off the buffer. + * + * @throws Swift_IoException + * + * @return $this + */ + public function commit() + { + // Nothing to do + return $this; + } - /** - * Attach $is to this stream. - * - * The stream acts as an observer, receiving all data that is written. - * All {@link write()} and {@link flushBuffers()} operations will be mirrored. - * - * @return $this - */ - public function bind(Swift_InputByteStream $is) - { - // Don't have to mirror anything - $this->bound[] = $is; + /** + * Attach $is to this stream. + * + * The stream acts as an observer, receiving all data that is written. + * All {@link write()} and {@link flushBuffers()} operations will be mirrored. + * + * @return $this + */ + public function bind(Swift_InputByteStream $is) + { + // Don't have to mirror anything + $this->bound[] = $is; - return $this; - } + return $this; + } - /** - * Remove an already bound stream. - * - * If $is is not bound, no errors will be raised. - * If the stream currently has any buffered data it will be written to $is - * before unbinding occurs. - * - * @return $this - */ - public function unbind(Swift_InputByteStream $is) - { - // Don't have to mirror anything - foreach ($this->bound as $k => $stream) { - if ($stream === $is) { - unset($this->bound[$k]); + /** + * Remove an already bound stream. + * + * If $is is not bound, no errors will be raised. + * If the stream currently has any buffered data it will be written to $is + * before unbinding occurs. + * + * @return $this + */ + public function unbind(Swift_InputByteStream $is) + { + // Don't have to mirror anything + foreach ($this->bound as $k => $stream) { + if ($stream === $is) { + unset($this->bound[$k]); - break; - } - } + break; + } + } - return $this; - } + return $this; + } - /** - * Flush the contents of the stream (empty it) and set the internal pointer - * to the beginning. - * - * @throws Swift_IoException - * - * @return $this - */ - public function flushBuffers() - { - $this->reset(); + /** + * Flush the contents of the stream (empty it) and set the internal pointer + * to the beginning. + * + * @throws Swift_IoException + * + * @return $this + */ + public function flushBuffers() + { + $this->reset(); - return $this; - } + return $this; + } - /** - * Set hash_algorithm, must be one of rsa-sha256 | rsa-sha1 defaults to rsa-sha256. - * - * @param string $hash - * - * @return $this - */ - public function setHashAlgorithm($hash) - { - $this->hashAlgorithm = 'rsa-sha1'; + /** + * Set hash_algorithm, must be one of rsa-sha256 | rsa-sha1 defaults to rsa-sha256. + * + * @param string $hash + * + * @return $this + */ + public function setHashAlgorithm($hash) + { + $this->hashAlgorithm = 'rsa-sha1'; - return $this; - } + return $this; + } - /** - * Set the canonicalization algorithm. - * - * @param string $canon simple | nofws defaults to simple - * - * @return $this - */ - public function setCanon($canon) - { - if ('nofws' == $canon) { - $this->canon = 'nofws'; - } else { - $this->canon = 'simple'; - } + /** + * Set the canonicalization algorithm. + * + * @param string $canon simple | nofws defaults to simple + * + * @return $this + */ + public function setCanon($canon) + { + if ('nofws' == $canon) { + $this->canon = 'nofws'; + } else { + $this->canon = 'simple'; + } - return $this; - } + return $this; + } - /** - * Set the signer identity. - * - * @param string $identity - * - * @return $this - */ - public function setSignerIdentity($identity) - { - $this->signerIdentity = $identity; + /** + * Set the signer identity. + * + * @param string $identity + * + * @return $this + */ + public function setSignerIdentity($identity) + { + $this->signerIdentity = $identity; - return $this; - } + return $this; + } - /** - * Enable / disable the DebugHeaders. - * - * @param bool $debug - * - * @return $this - */ - public function setDebugHeaders($debug) - { - $this->debugHeaders = (bool) $debug; + /** + * Enable / disable the DebugHeaders. + * + * @param bool $debug + * + * @return $this + */ + public function setDebugHeaders($debug) + { + $this->debugHeaders = (bool) $debug; - return $this; - } + return $this; + } - /** - * Start Body. - */ - public function startBody() - { - } + /** + * Start Body. + */ + public function startBody() + { + } - /** - * End Body. - */ - public function endBody() - { - $this->endOfBody(); - } + /** + * End Body. + */ + public function endBody() + { + $this->endOfBody(); + } - /** - * Returns the list of Headers Tampered by this plugin. - * - * @return array - */ - public function getAlteredHeaders() - { - if ($this->debugHeaders) { - return ['DomainKey-Signature', 'X-DebugHash']; - } + /** + * Returns the list of Headers Tampered by this plugin. + * + * @return array + */ + public function getAlteredHeaders() + { + if ($this->debugHeaders) { + return ['DomainKey-Signature', 'X-DebugHash']; + } - return ['DomainKey-Signature']; - } + return ['DomainKey-Signature']; + } - /** - * Adds an ignored Header. - * - * @param string $header_name - * - * @return $this - */ - public function ignoreHeader($header_name) - { - $this->ignoredHeaders[strtolower($header_name ?? '')] = true; + /** + * Adds an ignored Header. + * + * @param string $header_name + * + * @return $this + */ + public function ignoreHeader($header_name) + { + $this->ignoredHeaders[strtolower($header_name ?? '')] = true; - return $this; - } + return $this; + } - /** - * Set the headers to sign. - * - * @return $this - */ - public function setHeaders(Swift_Mime_SimpleHeaderSet $headers) - { - $this->startHash(); - $this->canonData = ''; - // Loop through Headers - $listHeaders = $headers->listAll(); - foreach ($listHeaders as $hName) { - // Check if we need to ignore Header - if (!isset($this->ignoredHeaders[strtolower($hName ?? '')])) { - if ($headers->has($hName)) { - $tmp = $headers->getAll($hName); - foreach ($tmp as $header) { - if ('' != $header->getFieldBody()) { - $this->addHeader($header->toString()); - $this->signedHeaders[] = $header->getFieldName(); - } - } - } - } - } - $this->endOfHeaders(); + /** + * Set the headers to sign. + * + * @return $this + */ + public function setHeaders(Swift_Mime_SimpleHeaderSet $headers) + { + $this->startHash(); + $this->canonData = ''; + // Loop through Headers + $listHeaders = $headers->listAll(); + foreach ($listHeaders as $hName) { + // Check if we need to ignore Header + if (!isset($this->ignoredHeaders[strtolower($hName ?? '')])) { + if ($headers->has($hName)) { + $tmp = $headers->getAll($hName); + foreach ($tmp as $header) { + if ('' != $header->getFieldBody()) { + $this->addHeader($header->toString()); + $this->signedHeaders[] = $header->getFieldName(); + } + } + } + } + } + $this->endOfHeaders(); - return $this; - } + return $this; + } - /** - * Add the signature to the given Headers. - * - * @return $this - */ - public function addSignature(Swift_Mime_SimpleHeaderSet $headers) - { - // Prepare the DomainKey-Signature Header - $params = ['a' => $this->hashAlgorithm, 'b' => chunk_split(base64_encode($this->getEncryptedHash() ?? ''), 73, ' '), 'c' => $this->canon, 'd' => $this->domainName, 'h' => implode(': ', $this->signedHeaders), 'q' => 'dns', 's' => $this->selector]; - $string = ''; - foreach ($params as $k => $v) { - $string .= $k.'='.$v.'; '; - } - $string = trim($string); - $headers->addTextHeader('DomainKey-Signature', $string); + /** + * Add the signature to the given Headers. + * + * @return $this + */ + public function addSignature(Swift_Mime_SimpleHeaderSet $headers) + { + // Prepare the DomainKey-Signature Header + $params = ['a' => $this->hashAlgorithm, 'b' => chunk_split(base64_encode($this->getEncryptedHash() ?? ''), 73, ' '), 'c' => $this->canon, 'd' => $this->domainName, 'h' => implode(': ', $this->signedHeaders), 'q' => 'dns', 's' => $this->selector]; + $string = ''; + foreach ($params as $k => $v) { + $string .= $k.'='.$v.'; '; + } + $string = trim($string); + $headers->addTextHeader('DomainKey-Signature', $string); - return $this; - } + return $this; + } - /* Private helpers */ + /* Private helpers */ - protected function addHeader($header) - { - switch ($this->canon) { - case 'nofws': - // Prepare Header and cascade - $exploded = explode(':', $header, 2); - $name = strtolower(trim($exploded[0])); - $value = str_replace("\r\n", '', $exploded[1]); - $value = preg_replace("/[ \t][ \t]+/", ' ', $value); - $header = $name.':'.trim($value)."\r\n"; - // no break - case 'simple': - // Nothing to do - } - $this->addToHash($header); - } + protected function addHeader($header) + { + switch ($this->canon) { + case 'nofws': + // Prepare Header and cascade + $exploded = explode(':', $header, 2); + $name = strtolower(trim($exploded[0])); + $value = str_replace("\r\n", '', $exploded[1]); + $value = preg_replace("/[ \t][ \t]+/", ' ', $value); + $header = $name.':'.trim($value)."\r\n"; + // no break + case 'simple': + // Nothing to do + } + $this->addToHash($header); + } - protected function endOfHeaders() - { - $this->bodyCanonEmptyCounter = 1; - } + protected function endOfHeaders() + { + $this->bodyCanonEmptyCounter = 1; + } - protected function canonicalizeBody($string) - { - $len = \strlen($string); - $canon = ''; - $nofws = ('nofws' == $this->canon); - for ($i = 0; $i < $len; ++$i) { - if ($this->bodyCanonIgnoreStart > 0) { - --$this->bodyCanonIgnoreStart; - continue; - } - switch ($string[$i]) { - case "\r": - $this->bodyCanonLastChar = "\r"; - break; - case "\n": - if ("\r" == $this->bodyCanonLastChar) { - if ($nofws) { - $this->bodyCanonSpace = false; - } - if ('' == $this->bodyCanonLine) { - ++$this->bodyCanonEmptyCounter; - } else { - $this->bodyCanonLine = ''; - $canon .= "\r\n"; - } - } else { - // Wooops Error - throw new Swift_SwiftException('Invalid new line sequence in mail found \n without preceding \r'); - } - break; - case ' ': - case "\t": - case "\x09": //HTAB - if ($nofws) { - $this->bodyCanonSpace = true; - break; - } - // no break - default: - if ($this->bodyCanonEmptyCounter > 0) { - $canon .= str_repeat("\r\n", $this->bodyCanonEmptyCounter); - $this->bodyCanonEmptyCounter = 0; - } - $this->bodyCanonLine .= $string[$i]; - $canon .= $string[$i]; - } - } - $this->addToHash($canon); - } + protected function canonicalizeBody($string) + { + $len = \strlen($string); + $canon = ''; + $nofws = ('nofws' == $this->canon); + for ($i = 0; $i < $len; ++$i) { + if ($this->bodyCanonIgnoreStart > 0) { + --$this->bodyCanonIgnoreStart; + continue; + } + switch ($string[$i]) { + case "\r": + $this->bodyCanonLastChar = "\r"; + break; + case "\n": + if ("\r" == $this->bodyCanonLastChar) { + if ($nofws) { + $this->bodyCanonSpace = false; + } + if ('' == $this->bodyCanonLine) { + ++$this->bodyCanonEmptyCounter; + } else { + $this->bodyCanonLine = ''; + $canon .= "\r\n"; + } + } else { + // Wooops Error + throw new Swift_SwiftException('Invalid new line sequence in mail found \n without preceding \r'); + } + break; + case ' ': + case "\t": + case "\x09": //HTAB + if ($nofws) { + $this->bodyCanonSpace = true; + break; + } + // no break + default: + if ($this->bodyCanonEmptyCounter > 0) { + $canon .= str_repeat("\r\n", $this->bodyCanonEmptyCounter); + $this->bodyCanonEmptyCounter = 0; + } + $this->bodyCanonLine .= $string[$i]; + $canon .= $string[$i]; + } + } + $this->addToHash($canon); + } - protected function endOfBody() - { - if (\strlen($this->bodyCanonLine) > 0) { - $this->addToHash("\r\n"); - } - } + protected function endOfBody() + { + if (\strlen($this->bodyCanonLine) > 0) { + $this->addToHash("\r\n"); + } + } - private function addToHash($string) - { - $this->canonData .= $string; - hash_update($this->hashHandler, $string); - } + private function addToHash($string) + { + $this->canonData .= $string; + hash_update($this->hashHandler, $string); + } - private function startHash() - { - // Init - switch ($this->hashAlgorithm) { - case 'rsa-sha1': - $this->hashHandler = hash_init('sha1'); - break; - } - $this->bodyCanonLine = ''; - } + private function startHash() + { + // Init + switch ($this->hashAlgorithm) { + case 'rsa-sha1': + $this->hashHandler = hash_init('sha1'); + break; + } + $this->bodyCanonLine = ''; + } - /** - * @throws Swift_SwiftException - * - * @return string - */ - private function getEncryptedHash() - { - $signature = ''; - $pkeyId = openssl_get_privatekey($this->privateKey); - if (!$pkeyId) { - throw new Swift_SwiftException('Unable to load DomainKey Private Key ['.openssl_error_string().']'); - } - if (openssl_sign($this->canonData, $signature, $pkeyId, OPENSSL_ALGO_SHA1)) { - return $signature; - } - throw new Swift_SwiftException('Unable to sign DomainKey Hash ['.openssl_error_string().']'); - } + /** + * @throws Swift_SwiftException + * + * @return string + */ + private function getEncryptedHash() + { + $signature = ''; + $pkeyId = openssl_get_privatekey($this->privateKey); + if (!$pkeyId) { + throw new Swift_SwiftException('Unable to load DomainKey Private Key ['.openssl_error_string().']'); + } + if (openssl_sign($this->canonData, $signature, $pkeyId, OPENSSL_ALGO_SHA1)) { + return $signature; + } + throw new Swift_SwiftException('Unable to sign DomainKey Hash ['.openssl_error_string().']'); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/HeaderSigner.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/HeaderSigner.php index 94136b94d85..6f5c20923dc 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/HeaderSigner.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/HeaderSigner.php @@ -15,47 +15,47 @@ */ interface Swift_Signers_HeaderSigner extends Swift_Signer, Swift_InputByteStream { - /** - * Exclude an header from the signed headers. - * - * @param string $header_name - * - * @return self - */ - public function ignoreHeader($header_name); + /** + * Exclude an header from the signed headers. + * + * @param string $header_name + * + * @return self + */ + public function ignoreHeader($header_name); - /** - * Prepare the Signer to get a new Body. - * - * @return self - */ - public function startBody(); + /** + * Prepare the Signer to get a new Body. + * + * @return self + */ + public function startBody(); - /** - * Give the signal that the body has finished streaming. - * - * @return self - */ - public function endBody(); + /** + * Give the signal that the body has finished streaming. + * + * @return self + */ + public function endBody(); - /** - * Give the headers already given. - * - * @return self - */ - public function setHeaders(Swift_Mime_SimpleHeaderSet $headers); + /** + * Give the headers already given. + * + * @return self + */ + public function setHeaders(Swift_Mime_SimpleHeaderSet $headers); - /** - * Add the header(s) to the headerSet. - * - * @return self - */ - public function addSignature(Swift_Mime_SimpleHeaderSet $headers); + /** + * Add the header(s) to the headerSet. + * + * @return self + */ + public function addSignature(Swift_Mime_SimpleHeaderSet $headers); - /** - * Return the list of header a signer might tamper. - * - * @return array - */ - public function getAlteredHeaders(); + /** + * Return the list of header a signer might tamper. + * + * @return array + */ + public function getAlteredHeaders(); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/OpenDKIMSigner.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/OpenDKIMSigner.php index fb0504dafa7..520bcc15e8b 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/OpenDKIMSigner.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/OpenDKIMSigner.php @@ -18,166 +18,166 @@ */ class Swift_Signers_OpenDKIMSigner extends Swift_Signers_DKIMSigner { - private $peclLoaded = false; + private $peclLoaded = false; - private $dkimHandler = null; + private $dkimHandler = null; - private $dropFirstLF = true; + private $dropFirstLF = true; - const CANON_RELAXED = 1; - const CANON_SIMPLE = 2; - const SIG_RSA_SHA1 = 3; - const SIG_RSA_SHA256 = 4; + const CANON_RELAXED = 1; + const CANON_SIMPLE = 2; + const SIG_RSA_SHA1 = 3; + const SIG_RSA_SHA256 = 4; - public function __construct($privateKey, $domainName, $selector) - { - if (!\extension_loaded('opendkim')) { - throw new Swift_SwiftException('php-opendkim extension not found'); - } + public function __construct($privateKey, $domainName, $selector) + { + if (!\extension_loaded('opendkim')) { + throw new Swift_SwiftException('php-opendkim extension not found'); + } - $this->peclLoaded = true; + $this->peclLoaded = true; - parent::__construct($privateKey, $domainName, $selector); - } + parent::__construct($privateKey, $domainName, $selector); + } - public function addSignature(Swift_Mime_SimpleHeaderSet $headers) - { - $header = new Swift_Mime_Headers_OpenDKIMHeader('DKIM-Signature'); - $headerVal = $this->dkimHandler->getSignatureHeader(); - if (false === $headerVal || \is_int($headerVal)) { - throw new Swift_SwiftException('OpenDKIM Error: '.$this->dkimHandler->getError()); - } - $header->setValue($headerVal); - $headers->set($header); + public function addSignature(Swift_Mime_SimpleHeaderSet $headers) + { + $header = new Swift_Mime_Headers_OpenDKIMHeader('DKIM-Signature'); + $headerVal = $this->dkimHandler->getSignatureHeader(); + if (false === $headerVal || \is_int($headerVal)) { + throw new Swift_SwiftException('OpenDKIM Error: '.$this->dkimHandler->getError()); + } + $header->setValue($headerVal); + $headers->set($header); - return $this; - } + return $this; + } - public function setHeaders(Swift_Mime_SimpleHeaderSet $headers) - { - $hash = 'rsa-sha1' == $this->hashAlgorithm ? OpenDKIMSign::ALG_RSASHA1 : OpenDKIMSign::ALG_RSASHA256; - $bodyCanon = 'simple' == $this->bodyCanon ? OpenDKIMSign::CANON_SIMPLE : OpenDKIMSign::CANON_RELAXED; - $headerCanon = 'simple' == $this->headerCanon ? OpenDKIMSign::CANON_SIMPLE : OpenDKIMSign::CANON_RELAXED; - $this->dkimHandler = new OpenDKIMSign($this->privateKey, $this->selector, $this->domainName, $headerCanon, $bodyCanon, $hash, -1); - // Hardcode signature Margin for now - $this->dkimHandler->setMargin(78); + public function setHeaders(Swift_Mime_SimpleHeaderSet $headers) + { + $hash = 'rsa-sha1' == $this->hashAlgorithm ? OpenDKIMSign::ALG_RSASHA1 : OpenDKIMSign::ALG_RSASHA256; + $bodyCanon = 'simple' == $this->bodyCanon ? OpenDKIMSign::CANON_SIMPLE : OpenDKIMSign::CANON_RELAXED; + $headerCanon = 'simple' == $this->headerCanon ? OpenDKIMSign::CANON_SIMPLE : OpenDKIMSign::CANON_RELAXED; + $this->dkimHandler = new OpenDKIMSign($this->privateKey, $this->selector, $this->domainName, $headerCanon, $bodyCanon, $hash, -1); + // Hardcode signature Margin for now + $this->dkimHandler->setMargin(78); - if (!is_numeric($this->signatureTimestamp)) { - OpenDKIM::setOption(OpenDKIM::OPTS_FIXEDTIME, time()); - } else { - if (!OpenDKIM::setOption(OpenDKIM::OPTS_FIXEDTIME, $this->signatureTimestamp)) { - throw new Swift_SwiftException('Unable to force signature timestamp ['.openssl_error_string().']'); - } - } - if (isset($this->signerIdentity)) { - $this->dkimHandler->setSigner($this->signerIdentity); - } - $listHeaders = $headers->listAll(); - foreach ($listHeaders as $hName) { - // Check if we need to ignore Header - if (!isset($this->ignoredHeaders[strtolower($hName ?? '')])) { - $tmp = $headers->getAll($hName); - if ($headers->has($hName)) { - foreach ($tmp as $header) { - if ('' != $header->getFieldBody()) { - $htosign = $header->toString(); - $this->dkimHandler->header($htosign); - $this->signedHeaders[] = $header->getFieldName(); - } - } - } - } - } + if (!is_numeric($this->signatureTimestamp)) { + OpenDKIM::setOption(OpenDKIM::OPTS_FIXEDTIME, time()); + } else { + if (!OpenDKIM::setOption(OpenDKIM::OPTS_FIXEDTIME, $this->signatureTimestamp)) { + throw new Swift_SwiftException('Unable to force signature timestamp ['.openssl_error_string().']'); + } + } + if (isset($this->signerIdentity)) { + $this->dkimHandler->setSigner($this->signerIdentity); + } + $listHeaders = $headers->listAll(); + foreach ($listHeaders as $hName) { + // Check if we need to ignore Header + if (!isset($this->ignoredHeaders[strtolower($hName ?? '')])) { + $tmp = $headers->getAll($hName); + if ($headers->has($hName)) { + foreach ($tmp as $header) { + if ('' != $header->getFieldBody()) { + $htosign = $header->toString(); + $this->dkimHandler->header($htosign); + $this->signedHeaders[] = $header->getFieldName(); + } + } + } + } + } - return $this; - } + return $this; + } - public function startBody() - { - if (!$this->peclLoaded) { - return parent::startBody(); - } - $this->dropFirstLF = true; - $this->dkimHandler->eoh(); + public function startBody() + { + if (!$this->peclLoaded) { + return parent::startBody(); + } + $this->dropFirstLF = true; + $this->dkimHandler->eoh(); - return $this; - } + return $this; + } - public function endBody() - { - if (!$this->peclLoaded) { - return parent::endBody(); - } - $this->dkimHandler->eom(); + public function endBody() + { + if (!$this->peclLoaded) { + return parent::endBody(); + } + $this->dkimHandler->eom(); - return $this; - } + return $this; + } - public function reset() - { - $this->dkimHandler = null; - parent::reset(); + public function reset() + { + $this->dkimHandler = null; + parent::reset(); - return $this; - } + return $this; + } - /** - * Set the signature timestamp. - * - * @param int $time - * - * @return $this - */ - public function setSignatureTimestamp($time) - { - $this->signatureTimestamp = $time; + /** + * Set the signature timestamp. + * + * @param int $time + * + * @return $this + */ + public function setSignatureTimestamp($time) + { + $this->signatureTimestamp = $time; - return $this; - } + return $this; + } - /** - * Set the signature expiration timestamp. - * - * @param int $time - * - * @return $this - */ - public function setSignatureExpiration($time) - { - $this->signatureExpiration = $time; + /** + * Set the signature expiration timestamp. + * + * @param int $time + * + * @return $this + */ + public function setSignatureExpiration($time) + { + $this->signatureExpiration = $time; - return $this; - } + return $this; + } - /** - * Enable / disable the DebugHeaders. - * - * @param bool $debug - * - * @return $this - */ - public function setDebugHeaders($debug) - { - $this->debugHeaders = (bool) $debug; + /** + * Enable / disable the DebugHeaders. + * + * @param bool $debug + * + * @return $this + */ + public function setDebugHeaders($debug) + { + $this->debugHeaders = (bool) $debug; - return $this; - } + return $this; + } - // Protected + // Protected - protected function canonicalizeBody($string) - { - if (!$this->peclLoaded) { - return parent::canonicalizeBody($string); - } - if (true === $this->dropFirstLF) { - if ("\r" == $string[0] && "\n" == $string[1]) { - $string = substr($string, 2); - } - } - $this->dropFirstLF = false; - if (\strlen($string)) { - $this->dkimHandler->body($string); - } - } + protected function canonicalizeBody($string) + { + if (!$this->peclLoaded) { + return parent::canonicalizeBody($string); + } + if (true === $this->dropFirstLF) { + if ("\r" == $string[0] && "\n" == $string[1]) { + $string = substr($string, 2); + } + } + $this->dropFirstLF = false; + if (\strlen($string)) { + $this->dkimHandler->body($string); + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/SMimeSigner.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/SMimeSigner.php index e3a489530af..3dd3cd05f04 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/SMimeSigner.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/SMimeSigner.php @@ -17,526 +17,526 @@ */ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner { - protected $signCertificate; - protected $signPrivateKey; - protected $encryptCert; - protected $signThenEncrypt = true; - protected $signLevel; - protected $encryptLevel; - protected $signOptions; - protected $encryptOptions; - protected $encryptCipher; - protected $extraCerts = null; - protected $wrapFullMessage = false; - - /** - * @var Swift_StreamFilters_StringReplacementFilterFactory - */ - protected $replacementFactory; - - /** - * @var Swift_Mime_SimpleHeaderFactory - */ - protected $headerFactory; - - /** - * Constructor. - * - * @param string|null $signCertificate - * @param string|null $signPrivateKey - * @param string|null $encryptCertificate - */ - public function __construct($signCertificate = null, $signPrivateKey = null, $encryptCertificate = null) - { - if (null !== $signPrivateKey) { - $this->setSignCertificate($signCertificate, $signPrivateKey); - } - - if (null !== $encryptCertificate) { - $this->setEncryptCertificate($encryptCertificate); - } - - $this->replacementFactory = Swift_DependencyContainer::getInstance() - ->lookup('transport.replacementfactory'); - - $this->signOptions = PKCS7_DETACHED; - $this->encryptCipher = OPENSSL_CIPHER_AES_128_CBC; - } - - /** - * Set the certificate location to use for signing. - * - * @see https://secure.php.net/manual/en/openssl.pkcs7.flags.php - * - * @param string $certificate - * @param string|array $privateKey If the key needs an passphrase use array('file-location', 'passphrase') instead - * @param int $signOptions Bitwise operator options for openssl_pkcs7_sign() - * @param string $extraCerts A file containing intermediate certificates needed by the signing certificate - * - * @return $this - */ - public function setSignCertificate($certificate, $privateKey = null, $signOptions = PKCS7_DETACHED, $extraCerts = null) - { - $this->signCertificate = 'file://'.str_replace('\\', '/', realpath($certificate)); - - if (null !== $privateKey) { - if (\is_array($privateKey)) { - $this->signPrivateKey = $privateKey; - $this->signPrivateKey[0] = 'file://'.str_replace('\\', '/', realpath($privateKey[0])); - } else { - $this->signPrivateKey = 'file://'.str_replace('\\', '/', realpath($privateKey)); - } - } - - $this->signOptions = $signOptions; - $this->extraCerts = $extraCerts ? realpath($extraCerts) : null; - - return $this; - } - - /** - * Set the certificate location to use for encryption. - * - * @see https://secure.php.net/manual/en/openssl.pkcs7.flags.php - * @see https://secure.php.net/manual/en/openssl.ciphers.php - * - * @param string|array $recipientCerts Either an single X.509 certificate, or an assoc array of X.509 certificates. - * @param int $cipher - * - * @return $this - */ - public function setEncryptCertificate($recipientCerts, $cipher = null) - { - if (\is_array($recipientCerts)) { - $this->encryptCert = []; - - foreach ($recipientCerts as $cert) { - $this->encryptCert[] = 'file://'.str_replace('\\', '/', realpath($cert)); - } - } else { - $this->encryptCert = 'file://'.str_replace('\\', '/', realpath($recipientCerts)); - } - - if (null !== $cipher) { - $this->encryptCipher = $cipher; - } - - return $this; - } - - /** - * @return string - */ - public function getSignCertificate() - { - return $this->signCertificate; - } - - /** - * @return string - */ - public function getSignPrivateKey() - { - return $this->signPrivateKey; - } - - /** - * Set perform signing before encryption. - * - * The default is to first sign the message and then encrypt. - * But some older mail clients, namely Microsoft Outlook 2000 will work when the message first encrypted. - * As this goes against the official specs, its recommended to only use 'encryption -> signing' when specifically targeting these 'broken' clients. - * - * @param bool $signThenEncrypt - * - * @return $this - */ - public function setSignThenEncrypt($signThenEncrypt = true) - { - $this->signThenEncrypt = $signThenEncrypt; - - return $this; - } - - /** - * @return bool - */ - public function isSignThenEncrypt() - { - return $this->signThenEncrypt; - } - - /** - * Resets internal states. - * - * @return $this - */ - public function reset() - { - return $this; - } - - /** - * Specify whether to wrap the entire MIME message in the S/MIME message. - * - * According to RFC5751 section 3.1: - * In order to protect outer, non-content-related message header fields - * (for instance, the "Subject", "To", "From", and "Cc" fields), the - * sending client MAY wrap a full MIME message in a message/rfc822 - * wrapper in order to apply S/MIME security services to these header - * fields. It is up to the receiving client to decide how to present - * this "inner" header along with the unprotected "outer" header. - * - * @param bool $wrap - * - * @return $this - */ - public function setWrapFullMessage($wrap) - { - $this->wrapFullMessage = $wrap; - } - - /** - * Change the Swift_Message to apply the signing. - * - * @return $this - */ - public function signMessage(Swift_Message $message) - { - if (null === $this->signCertificate && null === $this->encryptCert) { - return $this; - } - - if ($this->signThenEncrypt) { - $this->smimeSignMessage($message); - $this->smimeEncryptMessage($message); - } else { - $this->smimeEncryptMessage($message); - $this->smimeSignMessage($message); - } - } - - /** - * Return the list of header a signer might tamper. - * - * @return array - */ - public function getAlteredHeaders() - { - return ['Content-Type', 'Content-Transfer-Encoding', 'Content-Disposition']; - } - - /** - * Sign a Swift message. - */ - protected function smimeSignMessage(Swift_Message $message) - { - // If we don't have a certificate we can't sign the message - if (null === $this->signCertificate) { - return; - } - - // Work on a clone of the original message - $signMessage = clone $message; - $signMessage->clearSigners(); - - if ($this->wrapFullMessage) { - // The original message essentially becomes the body of the new - // wrapped message - $signMessage = $this->wrapMimeMessage($signMessage); - } else { - // Only keep header needed to parse the body correctly - $this->clearAllHeaders($signMessage); - $this->copyHeaders( - $message, - $signMessage, - [ - 'Content-Type', - 'Content-Transfer-Encoding', - 'Content-Disposition', - ] - ); - } - - // Copy the cloned message into a temporary file stream - $messageStream = new Swift_ByteStream_TemporaryFileByteStream(); - $signMessage->toByteStream($messageStream); - $messageStream->commit(); - $signedMessageStream = new Swift_ByteStream_TemporaryFileByteStream(); - - // Sign the message using openssl - if (!openssl_pkcs7_sign( - $messageStream->getPath(), - $signedMessageStream->getPath(), - $this->signCertificate, - $this->signPrivateKey, - [], - $this->signOptions, - $this->extraCerts - ) - ) { - throw new Swift_IoException(sprintf('Failed to sign S/Mime message. Error: "%s".', openssl_error_string())); - } - - // Parse the resulting signed message content back into the Swift message - // preserving the original headers - $this->parseSSLOutput($signedMessageStream, $message); - } - - /** - * Encrypt a Swift message. - */ - protected function smimeEncryptMessage(Swift_Message $message) - { - // If we don't have a certificate we can't encrypt the message - if (null === $this->encryptCert) { - return; - } - - // Work on a clone of the original message - $encryptMessage = clone $message; - $encryptMessage->clearSigners(); - - if ($this->wrapFullMessage) { - // The original message essentially becomes the body of the new - // wrapped message - $encryptMessage = $this->wrapMimeMessage($encryptMessage); - } else { - // Only keep header needed to parse the body correctly - $this->clearAllHeaders($encryptMessage); - $this->copyHeaders( - $message, - $encryptMessage, - [ - 'Content-Type', - 'Content-Transfer-Encoding', - 'Content-Disposition', - ] - ); - } - - // Convert the message content (including headers) to a string - // and place it in a temporary file - $messageStream = new Swift_ByteStream_TemporaryFileByteStream(); - $encryptMessage->toByteStream($messageStream); - $messageStream->commit(); - $encryptedMessageStream = new Swift_ByteStream_TemporaryFileByteStream(); - - // Encrypt the message - if (!openssl_pkcs7_encrypt( - $messageStream->getPath(), - $encryptedMessageStream->getPath(), - $this->encryptCert, - [], - 0, - $this->encryptCipher - ) - ) { - throw new Swift_IoException(sprintf('Failed to encrypt S/Mime message. Error: "%s".', openssl_error_string())); - } - - // Parse the resulting signed message content back into the Swift message - // preserving the original headers - $this->parseSSLOutput($encryptedMessageStream, $message); - } - - /** - * Copy named headers from one Swift message to another. - */ - protected function copyHeaders( - Swift_Message $fromMessage, - Swift_Message $toMessage, - array $headers = [] - ) { - foreach ($headers as $header) { - $this->copyHeader($fromMessage, $toMessage, $header); - } - } - - /** - * Copy a single header from one Swift message to another. - * - * @param string $headerName - */ - protected function copyHeader(Swift_Message $fromMessage, Swift_Message $toMessage, $headerName) - { - $header = $fromMessage->getHeaders()->get($headerName); - if (!$header) { - return; - } - $headers = $toMessage->getHeaders(); - switch ($header->getFieldType()) { - case Swift_Mime_Header::TYPE_TEXT: - $headers->addTextHeader($header->getFieldName(), $header->getValue()); - break; - case Swift_Mime_Header::TYPE_PARAMETERIZED: - $headers->addParameterizedHeader( - $header->getFieldName(), - $header->getValue(), - $header->getParameters() - ); - break; - } - } - - /** - * Remove all headers from a Swift message. - */ - protected function clearAllHeaders(Swift_Message $message) - { - $headers = $message->getHeaders(); - foreach ($headers->listAll() as $header) { - $headers->removeAll($header); - } - } - - /** - * Wraps a Swift_Message in a message/rfc822 MIME part. - * - * @return Swift_MimePart - */ - protected function wrapMimeMessage(Swift_Message $message) - { - // Start by copying the original message into a message stream - $messageStream = new Swift_ByteStream_TemporaryFileByteStream(); - $message->toByteStream($messageStream); - $messageStream->commit(); - - // Create a new MIME part that wraps the original stream - $wrappedMessage = new Swift_MimePart($messageStream, 'message/rfc822'); - $wrappedMessage->setEncoder(new Swift_Mime_ContentEncoder_PlainContentEncoder('7bit')); - - return $wrappedMessage; - } - - protected function parseSSLOutput(Swift_InputByteStream $inputStream, Swift_Message $message) - { - $messageStream = new Swift_ByteStream_TemporaryFileByteStream(); - $this->copyFromOpenSSLOutput($inputStream, $messageStream); - - $this->streamToMime($messageStream, $message); - } - - /** - * Merges an OutputByteStream from OpenSSL to a Swift_Message. - */ - protected function streamToMime(Swift_OutputByteStream $fromStream, Swift_Message $message) - { - // Parse the stream into headers and body - list($headers, $messageStream) = $this->parseStream($fromStream); - - // Get the original message headers - $messageHeaders = $message->getHeaders(); - - // Let the stream determine the headers describing the body content, - // since the body of the original message is overwritten by the body - // coming from the stream. - // These are all content-* headers. - - // Default transfer encoding is 7bit if not set - $encoding = ''; - // Remove all existing transfer encoding headers - $messageHeaders->removeAll('Content-Transfer-Encoding'); - // See whether the stream sets the transfer encoding - if (isset($headers['content-transfer-encoding'])) { - $encoding = $headers['content-transfer-encoding']; - } - - // We use the null content encoder, since the body is already encoded - // according to the transfer encoding specified in the stream - $message->setEncoder(new Swift_Mime_ContentEncoder_NullContentEncoder($encoding)); - - // Set the disposition, if present - if (isset($headers['content-disposition'])) { - $messageHeaders->addTextHeader('Content-Disposition', $headers['content-disposition']); - } - - // Copy over the body from the stream using the content type dictated - // by the stream content - $message->setChildren([]); - $message->setBody($messageStream, $headers['content-type']); - } - - /** - * This message will parse the headers of a MIME email byte stream - * and return an array that contains the headers as an associative - * array and the email body as a string. - * - * @return array - */ - protected function parseStream(Swift_OutputByteStream $emailStream) - { - $bufferLength = 78; - $headerData = ''; - $headerBodySeparator = "\r\n\r\n"; - - $emailStream->setReadPointer(0); - - // Read out the headers section from the stream to a string - while (false !== ($buffer = $emailStream->read($bufferLength))) { - $headerData .= $buffer; - - $headersPosEnd = strpos($headerData, $headerBodySeparator); - - // Stop reading if we found the end of the headers - if (false !== $headersPosEnd) { - break; - } - } - - // Split the header data into lines - $headerData = trim(substr($headerData, 0, $headersPosEnd)); - $headerLines = explode("\r\n", $headerData); - unset($headerData); - - $headers = []; - $currentHeaderName = ''; - - // Transform header lines into an associative array - foreach ($headerLines as $headerLine) { - // Handle headers that span multiple lines - if (false === strpos($headerLine, ':')) { - $headers[$currentHeaderName] .= ' '.trim($headerLine ?? ''); - continue; - } - - $header = explode(':', $headerLine, 2); - $currentHeaderName = strtolower($header[0] ?? ''); - $headers[$currentHeaderName] = trim($header[1] ?? ''); - } - - // Read the entire email body into a byte stream - $bodyStream = new Swift_ByteStream_TemporaryFileByteStream(); - - // Skip the header and separator and point to the body - $emailStream->setReadPointer($headersPosEnd + \strlen($headerBodySeparator)); - - while (false !== ($buffer = $emailStream->read($bufferLength))) { - $bodyStream->write($buffer); - } - - $bodyStream->commit(); - - return [$headers, $bodyStream]; - } - - protected function copyFromOpenSSLOutput(Swift_OutputByteStream $fromStream, Swift_InputByteStream $toStream) - { - $bufferLength = 4096; - $filteredStream = new Swift_ByteStream_TemporaryFileByteStream(); - $filteredStream->addFilter($this->replacementFactory->createFilter("\r\n", "\n"), 'CRLF to LF'); - $filteredStream->addFilter($this->replacementFactory->createFilter("\n", "\r\n"), 'LF to CRLF'); - - while (false !== ($buffer = $fromStream->read($bufferLength))) { - $filteredStream->write($buffer); - } - - $filteredStream->flushBuffers(); - - while (false !== ($buffer = $filteredStream->read($bufferLength))) { - $toStream->write($buffer); - } - - $toStream->commit(); - } + protected $signCertificate; + protected $signPrivateKey; + protected $encryptCert; + protected $signThenEncrypt = true; + protected $signLevel; + protected $encryptLevel; + protected $signOptions; + protected $encryptOptions; + protected $encryptCipher; + protected $extraCerts = null; + protected $wrapFullMessage = false; + + /** + * @var Swift_StreamFilters_StringReplacementFilterFactory + */ + protected $replacementFactory; + + /** + * @var Swift_Mime_SimpleHeaderFactory + */ + protected $headerFactory; + + /** + * Constructor. + * + * @param string|null $signCertificate + * @param string|null $signPrivateKey + * @param string|null $encryptCertificate + */ + public function __construct($signCertificate = null, $signPrivateKey = null, $encryptCertificate = null) + { + if (null !== $signPrivateKey) { + $this->setSignCertificate($signCertificate, $signPrivateKey); + } + + if (null !== $encryptCertificate) { + $this->setEncryptCertificate($encryptCertificate); + } + + $this->replacementFactory = Swift_DependencyContainer::getInstance() + ->lookup('transport.replacementfactory'); + + $this->signOptions = PKCS7_DETACHED; + $this->encryptCipher = OPENSSL_CIPHER_AES_128_CBC; + } + + /** + * Set the certificate location to use for signing. + * + * @see https://secure.php.net/manual/en/openssl.pkcs7.flags.php + * + * @param string $certificate + * @param string|array $privateKey If the key needs an passphrase use array('file-location', 'passphrase') instead + * @param int $signOptions Bitwise operator options for openssl_pkcs7_sign() + * @param string $extraCerts A file containing intermediate certificates needed by the signing certificate + * + * @return $this + */ + public function setSignCertificate($certificate, $privateKey = null, $signOptions = PKCS7_DETACHED, $extraCerts = null) + { + $this->signCertificate = 'file://'.str_replace('\\', '/', realpath($certificate)); + + if (null !== $privateKey) { + if (\is_array($privateKey)) { + $this->signPrivateKey = $privateKey; + $this->signPrivateKey[0] = 'file://'.str_replace('\\', '/', realpath($privateKey[0])); + } else { + $this->signPrivateKey = 'file://'.str_replace('\\', '/', realpath($privateKey)); + } + } + + $this->signOptions = $signOptions; + $this->extraCerts = $extraCerts ? realpath($extraCerts) : null; + + return $this; + } + + /** + * Set the certificate location to use for encryption. + * + * @see https://secure.php.net/manual/en/openssl.pkcs7.flags.php + * @see https://secure.php.net/manual/en/openssl.ciphers.php + * + * @param string|array $recipientCerts Either an single X.509 certificate, or an assoc array of X.509 certificates. + * @param int $cipher + * + * @return $this + */ + public function setEncryptCertificate($recipientCerts, $cipher = null) + { + if (\is_array($recipientCerts)) { + $this->encryptCert = []; + + foreach ($recipientCerts as $cert) { + $this->encryptCert[] = 'file://'.str_replace('\\', '/', realpath($cert)); + } + } else { + $this->encryptCert = 'file://'.str_replace('\\', '/', realpath($recipientCerts)); + } + + if (null !== $cipher) { + $this->encryptCipher = $cipher; + } + + return $this; + } + + /** + * @return string + */ + public function getSignCertificate() + { + return $this->signCertificate; + } + + /** + * @return string + */ + public function getSignPrivateKey() + { + return $this->signPrivateKey; + } + + /** + * Set perform signing before encryption. + * + * The default is to first sign the message and then encrypt. + * But some older mail clients, namely Microsoft Outlook 2000 will work when the message first encrypted. + * As this goes against the official specs, its recommended to only use 'encryption -> signing' when specifically targeting these 'broken' clients. + * + * @param bool $signThenEncrypt + * + * @return $this + */ + public function setSignThenEncrypt($signThenEncrypt = true) + { + $this->signThenEncrypt = $signThenEncrypt; + + return $this; + } + + /** + * @return bool + */ + public function isSignThenEncrypt() + { + return $this->signThenEncrypt; + } + + /** + * Resets internal states. + * + * @return $this + */ + public function reset() + { + return $this; + } + + /** + * Specify whether to wrap the entire MIME message in the S/MIME message. + * + * According to RFC5751 section 3.1: + * In order to protect outer, non-content-related message header fields + * (for instance, the "Subject", "To", "From", and "Cc" fields), the + * sending client MAY wrap a full MIME message in a message/rfc822 + * wrapper in order to apply S/MIME security services to these header + * fields. It is up to the receiving client to decide how to present + * this "inner" header along with the unprotected "outer" header. + * + * @param bool $wrap + * + * @return $this + */ + public function setWrapFullMessage($wrap) + { + $this->wrapFullMessage = $wrap; + } + + /** + * Change the Swift_Message to apply the signing. + * + * @return $this + */ + public function signMessage(Swift_Message $message) + { + if (null === $this->signCertificate && null === $this->encryptCert) { + return $this; + } + + if ($this->signThenEncrypt) { + $this->smimeSignMessage($message); + $this->smimeEncryptMessage($message); + } else { + $this->smimeEncryptMessage($message); + $this->smimeSignMessage($message); + } + } + + /** + * Return the list of header a signer might tamper. + * + * @return array + */ + public function getAlteredHeaders() + { + return ['Content-Type', 'Content-Transfer-Encoding', 'Content-Disposition']; + } + + /** + * Sign a Swift message. + */ + protected function smimeSignMessage(Swift_Message $message) + { + // If we don't have a certificate we can't sign the message + if (null === $this->signCertificate) { + return; + } + + // Work on a clone of the original message + $signMessage = clone $message; + $signMessage->clearSigners(); + + if ($this->wrapFullMessage) { + // The original message essentially becomes the body of the new + // wrapped message + $signMessage = $this->wrapMimeMessage($signMessage); + } else { + // Only keep header needed to parse the body correctly + $this->clearAllHeaders($signMessage); + $this->copyHeaders( + $message, + $signMessage, + [ + 'Content-Type', + 'Content-Transfer-Encoding', + 'Content-Disposition', + ] + ); + } + + // Copy the cloned message into a temporary file stream + $messageStream = new Swift_ByteStream_TemporaryFileByteStream(); + $signMessage->toByteStream($messageStream); + $messageStream->commit(); + $signedMessageStream = new Swift_ByteStream_TemporaryFileByteStream(); + + // Sign the message using openssl + if (!openssl_pkcs7_sign( + $messageStream->getPath(), + $signedMessageStream->getPath(), + $this->signCertificate, + $this->signPrivateKey, + [], + $this->signOptions, + $this->extraCerts + ) + ) { + throw new Swift_IoException(sprintf('Failed to sign S/Mime message. Error: "%s".', openssl_error_string())); + } + + // Parse the resulting signed message content back into the Swift message + // preserving the original headers + $this->parseSSLOutput($signedMessageStream, $message); + } + + /** + * Encrypt a Swift message. + */ + protected function smimeEncryptMessage(Swift_Message $message) + { + // If we don't have a certificate we can't encrypt the message + if (null === $this->encryptCert) { + return; + } + + // Work on a clone of the original message + $encryptMessage = clone $message; + $encryptMessage->clearSigners(); + + if ($this->wrapFullMessage) { + // The original message essentially becomes the body of the new + // wrapped message + $encryptMessage = $this->wrapMimeMessage($encryptMessage); + } else { + // Only keep header needed to parse the body correctly + $this->clearAllHeaders($encryptMessage); + $this->copyHeaders( + $message, + $encryptMessage, + [ + 'Content-Type', + 'Content-Transfer-Encoding', + 'Content-Disposition', + ] + ); + } + + // Convert the message content (including headers) to a string + // and place it in a temporary file + $messageStream = new Swift_ByteStream_TemporaryFileByteStream(); + $encryptMessage->toByteStream($messageStream); + $messageStream->commit(); + $encryptedMessageStream = new Swift_ByteStream_TemporaryFileByteStream(); + + // Encrypt the message + if (!openssl_pkcs7_encrypt( + $messageStream->getPath(), + $encryptedMessageStream->getPath(), + $this->encryptCert, + [], + 0, + $this->encryptCipher + ) + ) { + throw new Swift_IoException(sprintf('Failed to encrypt S/Mime message. Error: "%s".', openssl_error_string())); + } + + // Parse the resulting signed message content back into the Swift message + // preserving the original headers + $this->parseSSLOutput($encryptedMessageStream, $message); + } + + /** + * Copy named headers from one Swift message to another. + */ + protected function copyHeaders( + Swift_Message $fromMessage, + Swift_Message $toMessage, + array $headers = [] + ) { + foreach ($headers as $header) { + $this->copyHeader($fromMessage, $toMessage, $header); + } + } + + /** + * Copy a single header from one Swift message to another. + * + * @param string $headerName + */ + protected function copyHeader(Swift_Message $fromMessage, Swift_Message $toMessage, $headerName) + { + $header = $fromMessage->getHeaders()->get($headerName); + if (!$header) { + return; + } + $headers = $toMessage->getHeaders(); + switch ($header->getFieldType()) { + case Swift_Mime_Header::TYPE_TEXT: + $headers->addTextHeader($header->getFieldName(), $header->getValue()); + break; + case Swift_Mime_Header::TYPE_PARAMETERIZED: + $headers->addParameterizedHeader( + $header->getFieldName(), + $header->getValue(), + $header->getParameters() + ); + break; + } + } + + /** + * Remove all headers from a Swift message. + */ + protected function clearAllHeaders(Swift_Message $message) + { + $headers = $message->getHeaders(); + foreach ($headers->listAll() as $header) { + $headers->removeAll($header); + } + } + + /** + * Wraps a Swift_Message in a message/rfc822 MIME part. + * + * @return Swift_MimePart + */ + protected function wrapMimeMessage(Swift_Message $message) + { + // Start by copying the original message into a message stream + $messageStream = new Swift_ByteStream_TemporaryFileByteStream(); + $message->toByteStream($messageStream); + $messageStream->commit(); + + // Create a new MIME part that wraps the original stream + $wrappedMessage = new Swift_MimePart($messageStream, 'message/rfc822'); + $wrappedMessage->setEncoder(new Swift_Mime_ContentEncoder_PlainContentEncoder('7bit')); + + return $wrappedMessage; + } + + protected function parseSSLOutput(Swift_InputByteStream $inputStream, Swift_Message $message) + { + $messageStream = new Swift_ByteStream_TemporaryFileByteStream(); + $this->copyFromOpenSSLOutput($inputStream, $messageStream); + + $this->streamToMime($messageStream, $message); + } + + /** + * Merges an OutputByteStream from OpenSSL to a Swift_Message. + */ + protected function streamToMime(Swift_OutputByteStream $fromStream, Swift_Message $message) + { + // Parse the stream into headers and body + list($headers, $messageStream) = $this->parseStream($fromStream); + + // Get the original message headers + $messageHeaders = $message->getHeaders(); + + // Let the stream determine the headers describing the body content, + // since the body of the original message is overwritten by the body + // coming from the stream. + // These are all content-* headers. + + // Default transfer encoding is 7bit if not set + $encoding = ''; + // Remove all existing transfer encoding headers + $messageHeaders->removeAll('Content-Transfer-Encoding'); + // See whether the stream sets the transfer encoding + if (isset($headers['content-transfer-encoding'])) { + $encoding = $headers['content-transfer-encoding']; + } + + // We use the null content encoder, since the body is already encoded + // according to the transfer encoding specified in the stream + $message->setEncoder(new Swift_Mime_ContentEncoder_NullContentEncoder($encoding)); + + // Set the disposition, if present + if (isset($headers['content-disposition'])) { + $messageHeaders->addTextHeader('Content-Disposition', $headers['content-disposition']); + } + + // Copy over the body from the stream using the content type dictated + // by the stream content + $message->setChildren([]); + $message->setBody($messageStream, $headers['content-type']); + } + + /** + * This message will parse the headers of a MIME email byte stream + * and return an array that contains the headers as an associative + * array and the email body as a string. + * + * @return array + */ + protected function parseStream(Swift_OutputByteStream $emailStream) + { + $bufferLength = 78; + $headerData = ''; + $headerBodySeparator = "\r\n\r\n"; + + $emailStream->setReadPointer(0); + + // Read out the headers section from the stream to a string + while (false !== ($buffer = $emailStream->read($bufferLength))) { + $headerData .= $buffer; + + $headersPosEnd = strpos($headerData, $headerBodySeparator); + + // Stop reading if we found the end of the headers + if (false !== $headersPosEnd) { + break; + } + } + + // Split the header data into lines + $headerData = trim(substr($headerData, 0, $headersPosEnd)); + $headerLines = explode("\r\n", $headerData); + unset($headerData); + + $headers = []; + $currentHeaderName = ''; + + // Transform header lines into an associative array + foreach ($headerLines as $headerLine) { + // Handle headers that span multiple lines + if (false === strpos($headerLine, ':')) { + $headers[$currentHeaderName] .= ' '.trim($headerLine ?? ''); + continue; + } + + $header = explode(':', $headerLine, 2); + $currentHeaderName = strtolower($header[0] ?? ''); + $headers[$currentHeaderName] = trim($header[1] ?? ''); + } + + // Read the entire email body into a byte stream + $bodyStream = new Swift_ByteStream_TemporaryFileByteStream(); + + // Skip the header and separator and point to the body + $emailStream->setReadPointer($headersPosEnd + \strlen($headerBodySeparator)); + + while (false !== ($buffer = $emailStream->read($bufferLength))) { + $bodyStream->write($buffer); + } + + $bodyStream->commit(); + + return [$headers, $bodyStream]; + } + + protected function copyFromOpenSSLOutput(Swift_OutputByteStream $fromStream, Swift_InputByteStream $toStream) + { + $bufferLength = 4096; + $filteredStream = new Swift_ByteStream_TemporaryFileByteStream(); + $filteredStream->addFilter($this->replacementFactory->createFilter("\r\n", "\n"), 'CRLF to LF'); + $filteredStream->addFilter($this->replacementFactory->createFilter("\n", "\r\n"), 'LF to CRLF'); + + while (false !== ($buffer = $fromStream->read($bufferLength))) { + $filteredStream->write($buffer); + } + + $filteredStream->flushBuffers(); + + while (false !== ($buffer = $filteredStream->read($bufferLength))) { + $toStream->write($buffer); + } + + $toStream->commit(); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/SmtpTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/SmtpTransport.php index 625a470e09c..56b62323ad7 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/SmtpTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/SmtpTransport.php @@ -22,24 +22,24 @@ */ class Swift_SmtpTransport extends Swift_Transport_EsmtpTransport { - /** - * @param string $host - * @param int $port - * @param string|null $encryption SMTP encryption mode: - * - null for plain SMTP (no encryption), - * - 'tls' for SMTP with STARTTLS (best effort encryption), - * - 'ssl' for SMTPS = SMTP over TLS (always encrypted). - */ - public function __construct($host = 'localhost', $port = 25, $encryption = null) - { - \call_user_func_array( - [$this, 'Swift_Transport_EsmtpTransport::__construct'], - Swift_DependencyContainer::getInstance() - ->createDependenciesFor('transport.smtp') - ); + /** + * @param string $host + * @param int $port + * @param string|null $encryption SMTP encryption mode: + * - null for plain SMTP (no encryption), + * - 'tls' for SMTP with STARTTLS (best effort encryption), + * - 'ssl' for SMTPS = SMTP over TLS (always encrypted). + */ + public function __construct($host = 'localhost', $port = 25, $encryption = null) + { + \call_user_func_array( + [$this, 'Swift_Transport_EsmtpTransport::__construct'], + Swift_DependencyContainer::getInstance() + ->createDependenciesFor('transport.smtp') + ); - $this->setHost($host); - $this->setPort($port); - $this->setEncryption($encryption); - } + $this->setHost($host); + $this->setPort($port); + $this->setEncryption($encryption); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/SpoolTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/SpoolTransport.php index ac30065048a..c08e0fb17d5 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/SpoolTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/SpoolTransport.php @@ -15,19 +15,19 @@ */ class Swift_SpoolTransport extends Swift_Transport_SpoolTransport { - /** - * Create a new SpoolTransport. - */ - public function __construct(Swift_Spool $spool) - { - $arguments = Swift_DependencyContainer::getInstance() - ->createDependenciesFor('transport.spool'); + /** + * Create a new SpoolTransport. + */ + public function __construct(Swift_Spool $spool) + { + $arguments = Swift_DependencyContainer::getInstance() + ->createDependenciesFor('transport.spool'); - $arguments[] = $spool; + $arguments[] = $spool; - \call_user_func_array( - [$this, 'Swift_Transport_SpoolTransport::__construct'], - $arguments - ); - } + \call_user_func_array( + [$this, 'Swift_Transport_SpoolTransport::__construct'], + $arguments + ); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/StreamFilters/ByteArrayReplacementFilter.php b/htdocs/includes/swiftmailer/lib/classes/Swift/StreamFilters/ByteArrayReplacementFilter.php index 2e68f95e3e7..7e5ddf1b7da 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/StreamFilters/ByteArrayReplacementFilter.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/StreamFilters/ByteArrayReplacementFilter.php @@ -17,150 +17,150 @@ */ class Swift_StreamFilters_ByteArrayReplacementFilter implements Swift_StreamFilter { - /** The replacement(s) to make */ - private $replace; + /** The replacement(s) to make */ + private $replace; - /** The Index for searching */ - private $index; + /** The Index for searching */ + private $index; - /** The Search Tree */ - private $tree = []; + /** The Search Tree */ + private $tree = []; - /** Gives the size of the largest search */ - private $treeMaxLen = 0; + /** Gives the size of the largest search */ + private $treeMaxLen = 0; - private $repSize; + private $repSize; - /** - * Create a new ByteArrayReplacementFilter with $search and $replace. - * - * @param array $search - * @param array $replace - */ - public function __construct($search, $replace) - { - $this->index = []; - $this->tree = []; - $this->replace = []; - $this->repSize = []; + /** + * Create a new ByteArrayReplacementFilter with $search and $replace. + * + * @param array $search + * @param array $replace + */ + public function __construct($search, $replace) + { + $this->index = []; + $this->tree = []; + $this->replace = []; + $this->repSize = []; - $tree = null; - $i = null; - $last_size = $size = 0; - foreach ($search as $i => $search_element) { - if (null !== $tree) { - $tree[-1] = min(\count($replace) - 1, $i - 1); - $tree[-2] = $last_size; - } - $tree = &$this->tree; - if (\is_array($search_element)) { - foreach ($search_element as $k => $char) { - $this->index[$char] = true; - if (!isset($tree[$char])) { - $tree[$char] = []; - } - $tree = &$tree[$char]; - } - $last_size = $k + 1; - $size = max($size, $last_size); - } else { - $last_size = 1; - if (!isset($tree[$search_element])) { - $tree[$search_element] = []; - } - $tree = &$tree[$search_element]; - $size = max($last_size, $size); - $this->index[$search_element] = true; - } - } - if (null !== $i) { - $tree[-1] = min(\count($replace) - 1, $i); - $tree[-2] = $last_size; - $this->treeMaxLen = $size; - } - foreach ($replace as $rep) { - if (!\is_array($rep)) { - $rep = [$rep]; - } - $this->replace[] = $rep; - } - for ($i = \count($this->replace) - 1; $i >= 0; --$i) { - $this->replace[$i] = $rep = $this->filter($this->replace[$i], $i); - $this->repSize[$i] = \count($rep); - } - } + $tree = null; + $i = null; + $last_size = $size = 0; + foreach ($search as $i => $search_element) { + if (null !== $tree) { + $tree[-1] = min(\count($replace) - 1, $i - 1); + $tree[-2] = $last_size; + } + $tree = &$this->tree; + if (\is_array($search_element)) { + foreach ($search_element as $k => $char) { + $this->index[$char] = true; + if (!isset($tree[$char])) { + $tree[$char] = []; + } + $tree = &$tree[$char]; + } + $last_size = $k + 1; + $size = max($size, $last_size); + } else { + $last_size = 1; + if (!isset($tree[$search_element])) { + $tree[$search_element] = []; + } + $tree = &$tree[$search_element]; + $size = max($last_size, $size); + $this->index[$search_element] = true; + } + } + if (null !== $i) { + $tree[-1] = min(\count($replace) - 1, $i); + $tree[-2] = $last_size; + $this->treeMaxLen = $size; + } + foreach ($replace as $rep) { + if (!\is_array($rep)) { + $rep = [$rep]; + } + $this->replace[] = $rep; + } + for ($i = \count($this->replace) - 1; $i >= 0; --$i) { + $this->replace[$i] = $rep = $this->filter($this->replace[$i], $i); + $this->repSize[$i] = \count($rep); + } + } - /** - * Returns true if based on the buffer passed more bytes should be buffered. - * - * @param array $buffer - * - * @return bool - */ - public function shouldBuffer($buffer) - { - $endOfBuffer = end($buffer); + /** + * Returns true if based on the buffer passed more bytes should be buffered. + * + * @param array $buffer + * + * @return bool + */ + public function shouldBuffer($buffer) + { + $endOfBuffer = end($buffer); - return isset($this->index[$endOfBuffer]); - } + return isset($this->index[$endOfBuffer]); + } - /** - * Perform the actual replacements on $buffer and return the result. - * - * @param array $buffer - * @param int $minReplaces - * - * @return array - */ - public function filter($buffer, $minReplaces = -1) - { - if (0 == $this->treeMaxLen) { - return $buffer; - } + /** + * Perform the actual replacements on $buffer and return the result. + * + * @param array $buffer + * @param int $minReplaces + * + * @return array + */ + public function filter($buffer, $minReplaces = -1) + { + if (0 == $this->treeMaxLen) { + return $buffer; + } - $newBuffer = []; - $buf_size = \count($buffer); - $last_size = 0; - for ($i = 0; $i < $buf_size; ++$i) { - $search_pos = $this->tree; - $last_found = PHP_INT_MAX; - // We try to find if the next byte is part of a search pattern - for ($j = 0; $j <= $this->treeMaxLen; ++$j) { - // We have a new byte for a search pattern - if (isset($buffer[$p = $i + $j]) && isset($search_pos[$buffer[$p]])) { - $search_pos = $search_pos[$buffer[$p]]; - // We have a complete pattern, save, in case we don't find a better match later - if (isset($search_pos[-1]) && $search_pos[-1] < $last_found - && $search_pos[-1] > $minReplaces) { - $last_found = $search_pos[-1]; - $last_size = $search_pos[-2]; - } - } - // We got a complete pattern - elseif (PHP_INT_MAX !== $last_found) { - // Adding replacement datas to output buffer - $rep_size = $this->repSize[$last_found]; - for ($j = 0; $j < $rep_size; ++$j) { - $newBuffer[] = $this->replace[$last_found][$j]; - } - // We Move cursor forward - $i += $last_size - 1; - // Edge Case, last position in buffer - if ($i >= $buf_size) { - $newBuffer[] = $buffer[$i]; - } + $newBuffer = []; + $buf_size = \count($buffer); + $last_size = 0; + for ($i = 0; $i < $buf_size; ++$i) { + $search_pos = $this->tree; + $last_found = PHP_INT_MAX; + // We try to find if the next byte is part of a search pattern + for ($j = 0; $j <= $this->treeMaxLen; ++$j) { + // We have a new byte for a search pattern + if (isset($buffer[$p = $i + $j]) && isset($search_pos[$buffer[$p]])) { + $search_pos = $search_pos[$buffer[$p]]; + // We have a complete pattern, save, in case we don't find a better match later + if (isset($search_pos[-1]) && $search_pos[-1] < $last_found + && $search_pos[-1] > $minReplaces) { + $last_found = $search_pos[-1]; + $last_size = $search_pos[-2]; + } + } + // We got a complete pattern + elseif (PHP_INT_MAX !== $last_found) { + // Adding replacement datas to output buffer + $rep_size = $this->repSize[$last_found]; + for ($j = 0; $j < $rep_size; ++$j) { + $newBuffer[] = $this->replace[$last_found][$j]; + } + // We Move cursor forward + $i += $last_size - 1; + // Edge Case, last position in buffer + if ($i >= $buf_size) { + $newBuffer[] = $buffer[$i]; + } - // We start the next loop - continue 2; - } else { - // this byte is not in a pattern and we haven't found another pattern - break; - } - } - // Normal byte, move it to output buffer - $newBuffer[] = $buffer[$i]; - } + // We start the next loop + continue 2; + } else { + // this byte is not in a pattern and we haven't found another pattern + break; + } + } + // Normal byte, move it to output buffer + $newBuffer[] = $buffer[$i]; + } - return $newBuffer; - } + return $newBuffer; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilterFactory.php b/htdocs/includes/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilterFactory.php index 965e9f69cda..783b8896dd7 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilterFactory.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilterFactory.php @@ -15,31 +15,31 @@ */ class Swift_StreamFilters_StringReplacementFilterFactory implements Swift_ReplacementFilterFactory { - /** Lazy-loaded filters */ - private $filters = []; + /** Lazy-loaded filters */ + private $filters = []; - /** - * Create a new StreamFilter to replace $search with $replace in a string. - * - * @param string $search - * @param string $replace - * - * @return Swift_StreamFilter - */ - public function createFilter($search, $replace) - { - if (!isset($this->filters[$search][$replace])) { - if (!isset($this->filters[$search])) { - $this->filters[$search] = []; - } + /** + * Create a new StreamFilter to replace $search with $replace in a string. + * + * @param string $search + * @param string $replace + * + * @return Swift_StreamFilter + */ + public function createFilter($search, $replace) + { + if (!isset($this->filters[$search][$replace])) { + if (!isset($this->filters[$search])) { + $this->filters[$search] = []; + } - if (!isset($this->filters[$search][$replace])) { - $this->filters[$search][$replace] = []; - } + if (!isset($this->filters[$search][$replace])) { + $this->filters[$search][$replace] = []; + } - $this->filters[$search][$replace] = new Swift_StreamFilters_StringReplacementFilter($search, $replace); - } + $this->filters[$search][$replace] = new Swift_StreamFilters_StringReplacementFilter($search, $replace); + } - return $this->filters[$search][$replace]; - } + return $this->filters[$search][$replace]; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/SwiftException.php b/htdocs/includes/swiftmailer/lib/classes/Swift/SwiftException.php index 44cbfc779e5..15e68b18e79 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/SwiftException.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/SwiftException.php @@ -15,14 +15,14 @@ */ class Swift_SwiftException extends Exception { - /** - * Create a new SwiftException with $message. - * - * @param string $message - * @param int $code - */ - public function __construct($message, $code = 0, Exception $previous = null) - { - parent::__construct($message, $code, $previous); - } + /** + * Create a new SwiftException with $message. + * + * @param string $message + * @param int $code + */ + public function __construct($message, $code = 0, Exception $previous = null) + { + parent::__construct($message, $code, $previous); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport.php index f3d4c4fe31e..bc324e8685a 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport.php @@ -15,62 +15,62 @@ */ interface Swift_Transport { - /** - * Test if this Transport mechanism has started. - * - * @return bool - */ - public function isStarted(); + /** + * Test if this Transport mechanism has started. + * + * @return bool + */ + public function isStarted(); - /** - * Start this Transport mechanism. - */ - public function start(); + /** + * Start this Transport mechanism. + */ + public function start(); - /** - * Stop this Transport mechanism. - */ - public function stop(); + /** + * Stop this Transport mechanism. + */ + public function stop(); - /** - * Check if this Transport mechanism is alive. - * - * If a Transport mechanism session is no longer functional, the method - * returns FALSE. It is the responsibility of the developer to handle this - * case and restart the Transport mechanism manually. - * - * @example - * - * if (!$transport->ping()) { - * $transport->stop(); - * $transport->start(); - * } - * - * The Transport mechanism will be started, if it is not already. - * - * It is undefined if the Transport mechanism attempts to restart as long as - * the return value reflects whether the mechanism is now functional. - * - * @return bool TRUE if the transport is alive - */ - public function ping(); + /** + * Check if this Transport mechanism is alive. + * + * If a Transport mechanism session is no longer functional, the method + * returns FALSE. It is the responsibility of the developer to handle this + * case and restart the Transport mechanism manually. + * + * @example + * + * if (!$transport->ping()) { + * $transport->stop(); + * $transport->start(); + * } + * + * The Transport mechanism will be started, if it is not already. + * + * It is undefined if the Transport mechanism attempts to restart as long as + * the return value reflects whether the mechanism is now functional. + * + * @return bool TRUE if the transport is alive + */ + public function ping(); - /** - * Send the given Message. - * - * Recipient/sender data will be retrieved from the Message API. - * The return value is the number of recipients who were accepted for delivery. - * - * This is the responsibility of the send method to start the transport if needed. - * - * @param string[] $failedRecipients An array of failures by-reference - * - * @return int - */ - public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null); + /** + * Send the given Message. + * + * Recipient/sender data will be retrieved from the Message API. + * The return value is the number of recipients who were accepted for delivery. + * + * This is the responsibility of the send method to start the transport if needed. + * + * @param string[] $failedRecipients An array of failures by-reference + * + * @return int + */ + public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null); - /** - * Register a plugin in the Transport. - */ - public function registerPlugin(Swift_Events_EventListener $plugin); + /** + * Register a plugin in the Transport. + */ + public function registerPlugin(Swift_Events_EventListener $plugin); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php index d761677db7e..d2dbd7a66a0 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php @@ -15,527 +15,527 @@ */ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport { - /** Input-Output buffer for sending/receiving SMTP commands and responses */ - protected $buffer; - - /** Connection status */ - protected $started = false; - - /** The domain name to use in HELO command */ - protected $domain = '[127.0.0.1]'; - - /** The event dispatching layer */ - protected $eventDispatcher; - - protected $addressEncoder; - - /** Whether the PIPELINING SMTP extension is enabled (RFC 2920) */ - protected $pipelining = null; - - /** The pipelined commands waiting for response */ - protected $pipeline = []; - - /** Source Ip */ - protected $sourceIp; - - /** Return an array of params for the Buffer */ - abstract protected function getBufferParams(); - - /** - * Creates a new EsmtpTransport using the given I/O buffer. - * - * @param string $localDomain - */ - public function __construct(Swift_Transport_IoBuffer $buf, Swift_Events_EventDispatcher $dispatcher, $localDomain = '127.0.0.1', Swift_AddressEncoder $addressEncoder = null) - { - $this->buffer = $buf; - $this->eventDispatcher = $dispatcher; - $this->addressEncoder = $addressEncoder ?? new Swift_AddressEncoder_IdnAddressEncoder(); - $this->setLocalDomain($localDomain); - } - - /** - * Set the name of the local domain which Swift will identify itself as. - * - * This should be a fully-qualified domain name and should be truly the domain - * you're using. - * - * If your server does not have a domain name, use the IP address. This will - * automatically be wrapped in square brackets as described in RFC 5321, - * section 4.1.3. - * - * @param string $domain - * - * @return $this - */ - public function setLocalDomain($domain) - { - if ('[' !== substr($domain, 0, 1)) { - if (filter_var($domain, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { - $domain = '['.$domain.']'; - } elseif (filter_var($domain, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { - $domain = '[IPv6:'.$domain.']'; - } - } - - $this->domain = $domain; - - return $this; - } - - /** - * Get the name of the domain Swift will identify as. - * - * If an IP address was specified, this will be returned wrapped in square - * brackets as described in RFC 5321, section 4.1.3. - * - * @return string - */ - public function getLocalDomain() - { - return $this->domain; - } - - /** - * Sets the source IP. - * - * @param string $source - */ - public function setSourceIp($source) - { - $this->sourceIp = $source; - } - - /** - * Returns the IP used to connect to the destination. - * - * @return string - */ - public function getSourceIp() - { - return $this->sourceIp; - } - - public function setAddressEncoder(Swift_AddressEncoder $addressEncoder) - { - $this->addressEncoder = $addressEncoder; - } - - public function getAddressEncoder() - { - return $this->addressEncoder; - } - - /** - * Start the SMTP connection. - */ - public function start() - { - if (!$this->started) { - if ($evt = $this->eventDispatcher->createTransportChangeEvent($this)) { - $this->eventDispatcher->dispatchEvent($evt, 'beforeTransportStarted'); - if ($evt->bubbleCancelled()) { - return; - } - } - - try { - $this->buffer->initialize($this->getBufferParams()); - } catch (Swift_TransportException $e) { - $this->throwException($e); - } - $this->readGreeting(); - $this->doHeloCommand(); - - if ($evt) { - $this->eventDispatcher->dispatchEvent($evt, 'transportStarted'); - } - - $this->started = true; - } - } - - /** - * Test if an SMTP connection has been established. - * - * @return bool - */ - public function isStarted() - { - return $this->started; - } - - /** - * Send the given Message. - * - * Recipient/sender data will be retrieved from the Message API. - * The return value is the number of recipients who were accepted for delivery. - * - * @param string[] $failedRecipients An array of failures by-reference - * - * @return int - */ - public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) - { - if (!$this->isStarted()) { - $this->start(); - } - - $sent = 0; - $failedRecipients = (array) $failedRecipients; - - if ($evt = $this->eventDispatcher->createSendEvent($this, $message)) { - $this->eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); - if ($evt->bubbleCancelled()) { - return 0; - } - } - - if (!$reversePath = $this->getReversePath($message)) { - $this->throwException(new Swift_TransportException('Cannot send message without a sender address')); - } - - $to = (array) $message->getTo(); - $cc = (array) $message->getCc(); - $bcc = (array) $message->getBcc(); - $tos = array_merge($to, $cc, $bcc); - - $message->setBcc([]); - - try { - $sent += $this->sendTo($message, $reversePath, $tos, $failedRecipients); - } finally { - $message->setBcc($bcc); - } - - if ($evt) { - if ($sent == \count($to) + \count($cc) + \count($bcc)) { - $evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS); - } elseif ($sent > 0) { - $evt->setResult(Swift_Events_SendEvent::RESULT_TENTATIVE); - } else { - $evt->setResult(Swift_Events_SendEvent::RESULT_FAILED); - } - $evt->setFailedRecipients($failedRecipients); - $this->eventDispatcher->dispatchEvent($evt, 'sendPerformed'); - } - - $message->generateId(); //Make sure a new Message ID is used - - return $sent; - } - - /** - * Stop the SMTP connection. - */ - public function stop() - { - if ($this->started) { - if ($evt = $this->eventDispatcher->createTransportChangeEvent($this)) { - $this->eventDispatcher->dispatchEvent($evt, 'beforeTransportStopped'); - if ($evt->bubbleCancelled()) { - return; - } - } - - try { - $this->executeCommand("QUIT\r\n", [221]); - } catch (Swift_TransportException $e) { - } - - try { - $this->buffer->terminate(); - - if ($evt) { - $this->eventDispatcher->dispatchEvent($evt, 'transportStopped'); - } - } catch (Swift_TransportException $e) { - $this->throwException($e); - } - } - $this->started = false; - } - - /** - * {@inheritdoc} - */ - public function ping() - { - try { - if (!$this->isStarted()) { - $this->start(); - } - - $this->executeCommand("NOOP\r\n", [250]); - } catch (Swift_TransportException $e) { - try { - $this->stop(); - } catch (Swift_TransportException $e) { - } - - return false; - } - - return true; - } - - /** - * Register a plugin. - */ - public function registerPlugin(Swift_Events_EventListener $plugin) - { - $this->eventDispatcher->bindEventListener($plugin); - } - - /** - * Reset the current mail transaction. - */ - public function reset() - { - $this->executeCommand("RSET\r\n", [250], $failures, true); - } - - /** - * Get the IoBuffer where read/writes are occurring. - * - * @return Swift_Transport_IoBuffer - */ - public function getBuffer() - { - return $this->buffer; - } - - /** - * Run a command against the buffer, expecting the given response codes. - * - * If no response codes are given, the response will not be validated. - * If codes are given, an exception will be thrown on an invalid response. - * If the command is RCPT TO, and the pipeline is non-empty, no exception - * will be thrown; instead the failing address is added to $failures. - * - * @param string $command - * @param int[] $codes - * @param string[] $failures An array of failures by-reference - * @param bool $pipeline Do not wait for response - * @param string $address the address, if command is RCPT TO - * - * @return string|null The server response, or null if pipelining is enabled - */ - public function executeCommand($command, $codes = [], &$failures = null, $pipeline = false, $address = null) - { - $failures = (array) $failures; - $seq = $this->buffer->write($command); - if ($evt = $this->eventDispatcher->createCommandEvent($this, $command, $codes)) { - $this->eventDispatcher->dispatchEvent($evt, 'commandSent'); - } - - $this->pipeline[] = [$command, $seq, $codes, $address]; - - if ($pipeline && $this->pipelining) { - return null; - } - - $response = null; - - while ($this->pipeline) { - list($command, $seq, $codes, $address) = array_shift($this->pipeline); - $response = $this->getFullResponse($seq); - try { - $this->assertResponseCode($response, $codes); - } catch (Swift_TransportException $e) { - if ($this->pipeline && $address) { - $failures[] = $address; - } else { - $this->throwException($e); - } - } - } - - return $response; - } - - /** Read the opening SMTP greeting */ - protected function readGreeting() - { - $this->assertResponseCode($this->getFullResponse(0), [220]); - } - - /** Send the HELO welcome */ - protected function doHeloCommand() - { - $this->executeCommand( - sprintf("HELO %s\r\n", $this->domain), [250] - ); - } - - /** Send the MAIL FROM command */ - protected function doMailFromCommand($address) - { - $address = $this->addressEncoder->encodeString($address); - $this->executeCommand( - sprintf("MAIL FROM:<%s>\r\n", $address), [250], $failures, true - ); - } - - /** Send the RCPT TO command */ - protected function doRcptToCommand($address) - { - $address = $this->addressEncoder->encodeString($address); - $this->executeCommand( - sprintf("RCPT TO:<%s>\r\n", $address), [250, 251, 252], $failures, true, $address - ); - } - - /** Send the DATA command */ - protected function doDataCommand(&$failedRecipients) - { - $this->executeCommand("DATA\r\n", [354], $failedRecipients); - } - - /** Stream the contents of the message over the buffer */ - protected function streamMessage(Swift_Mime_SimpleMessage $message) - { - $this->buffer->setWriteTranslations(["\r\n." => "\r\n.."]); - try { - $message->toByteStream($this->buffer); - $this->buffer->flushBuffers(); - } catch (Swift_TransportException $e) { - $this->throwException($e); - } - $this->buffer->setWriteTranslations([]); - $this->executeCommand("\r\n.\r\n", [250]); - } - - /** Determine the best-use reverse path for this message */ - protected function getReversePath(Swift_Mime_SimpleMessage $message) - { - $return = $message->getReturnPath(); - $sender = $message->getSender(); - $from = $message->getFrom(); - $path = null; - if (!empty($return)) { - $path = $return; - } elseif (!empty($sender)) { - // Don't use array_keys - reset($sender); // Reset Pointer to first pos - $path = key($sender); // Get key - } elseif (!empty($from)) { - reset($from); // Reset Pointer to first pos - $path = key($from); // Get key - } - - return $path; - } - - /** Throw a TransportException, first sending it to any listeners */ - protected function throwException(Swift_TransportException $e) - { - if ($evt = $this->eventDispatcher->createTransportExceptionEvent($this, $e)) { - $this->eventDispatcher->dispatchEvent($evt, 'exceptionThrown'); - if (!$evt->bubbleCancelled()) { - throw $e; - } - } else { - throw $e; - } - } - - /** Throws an Exception if a response code is incorrect */ - protected function assertResponseCode($response, $wanted) - { - if (!$response) { - $this->throwException(new Swift_TransportException('Expected response code '.implode('/', $wanted).' but got an empty response')); - } - - list($code) = sscanf($response, '%3d'); - $valid = (empty($wanted) || \in_array($code, $wanted)); - - if ($evt = $this->eventDispatcher->createResponseEvent($this, $response, - $valid)) { - $this->eventDispatcher->dispatchEvent($evt, 'responseReceived'); - } - - if (!$valid) { - $this->throwException(new Swift_TransportException('Expected response code '.implode('/', $wanted).' but got code "'.$code.'", with message "'.$response.'"', $code)); - } - } - - /** Get an entire multi-line response using its sequence number */ - protected function getFullResponse($seq) - { - $response = ''; - try { - do { - $line = $this->buffer->readLine($seq); - $response .= $line; - } while (null !== $line && false !== $line && ' ' != $line[3]); - } catch (Swift_TransportException $e) { - $this->throwException($e); - } catch (Swift_IoException $e) { - $this->throwException(new Swift_TransportException($e->getMessage(), 0, $e)); - } - - return $response; - } - - /** Send an email to the given recipients from the given reverse path */ - private function doMailTransaction($message, $reversePath, array $recipients, array &$failedRecipients) - { - $sent = 0; - $this->doMailFromCommand($reversePath); - foreach ($recipients as $forwardPath) { - try { - $this->doRcptToCommand($forwardPath); - ++$sent; - } catch (Swift_TransportException $e) { - $failedRecipients[] = $forwardPath; - } catch (Swift_AddressEncoderException $e) { - $failedRecipients[] = $forwardPath; - } - } - - if (0 != $sent) { - $sent += \count($failedRecipients); - $this->doDataCommand($failedRecipients); - $sent -= \count($failedRecipients); - - $this->streamMessage($message); - } else { - $this->reset(); - } - - return $sent; - } - - /** Send a message to the given To: recipients */ - private function sendTo(Swift_Mime_SimpleMessage $message, $reversePath, array $to, array &$failedRecipients) - { - if (empty($to)) { - return 0; - } - - return $this->doMailTransaction($message, $reversePath, array_keys($to), - $failedRecipients); - } - - /** - * Destructor. - */ - public function __destruct() - { - try { - $this->stop(); - } catch (Exception $e) { - } - } - - public function __sleep() - { - throw new \BadMethodCallException('Cannot serialize '.__CLASS__); - } - - public function __wakeup() - { - throw new \BadMethodCallException('Cannot unserialize '.__CLASS__); - } + /** Input-Output buffer for sending/receiving SMTP commands and responses */ + protected $buffer; + + /** Connection status */ + protected $started = false; + + /** The domain name to use in HELO command */ + protected $domain = '[127.0.0.1]'; + + /** The event dispatching layer */ + protected $eventDispatcher; + + protected $addressEncoder; + + /** Whether the PIPELINING SMTP extension is enabled (RFC 2920) */ + protected $pipelining = null; + + /** The pipelined commands waiting for response */ + protected $pipeline = []; + + /** Source Ip */ + protected $sourceIp; + + /** Return an array of params for the Buffer */ + abstract protected function getBufferParams(); + + /** + * Creates a new EsmtpTransport using the given I/O buffer. + * + * @param string $localDomain + */ + public function __construct(Swift_Transport_IoBuffer $buf, Swift_Events_EventDispatcher $dispatcher, $localDomain = '127.0.0.1', Swift_AddressEncoder $addressEncoder = null) + { + $this->buffer = $buf; + $this->eventDispatcher = $dispatcher; + $this->addressEncoder = $addressEncoder ?? new Swift_AddressEncoder_IdnAddressEncoder(); + $this->setLocalDomain($localDomain); + } + + /** + * Set the name of the local domain which Swift will identify itself as. + * + * This should be a fully-qualified domain name and should be truly the domain + * you're using. + * + * If your server does not have a domain name, use the IP address. This will + * automatically be wrapped in square brackets as described in RFC 5321, + * section 4.1.3. + * + * @param string $domain + * + * @return $this + */ + public function setLocalDomain($domain) + { + if ('[' !== substr($domain, 0, 1)) { + if (filter_var($domain, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { + $domain = '['.$domain.']'; + } elseif (filter_var($domain, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { + $domain = '[IPv6:'.$domain.']'; + } + } + + $this->domain = $domain; + + return $this; + } + + /** + * Get the name of the domain Swift will identify as. + * + * If an IP address was specified, this will be returned wrapped in square + * brackets as described in RFC 5321, section 4.1.3. + * + * @return string + */ + public function getLocalDomain() + { + return $this->domain; + } + + /** + * Sets the source IP. + * + * @param string $source + */ + public function setSourceIp($source) + { + $this->sourceIp = $source; + } + + /** + * Returns the IP used to connect to the destination. + * + * @return string + */ + public function getSourceIp() + { + return $this->sourceIp; + } + + public function setAddressEncoder(Swift_AddressEncoder $addressEncoder) + { + $this->addressEncoder = $addressEncoder; + } + + public function getAddressEncoder() + { + return $this->addressEncoder; + } + + /** + * Start the SMTP connection. + */ + public function start() + { + if (!$this->started) { + if ($evt = $this->eventDispatcher->createTransportChangeEvent($this)) { + $this->eventDispatcher->dispatchEvent($evt, 'beforeTransportStarted'); + if ($evt->bubbleCancelled()) { + return; + } + } + + try { + $this->buffer->initialize($this->getBufferParams()); + } catch (Swift_TransportException $e) { + $this->throwException($e); + } + $this->readGreeting(); + $this->doHeloCommand(); + + if ($evt) { + $this->eventDispatcher->dispatchEvent($evt, 'transportStarted'); + } + + $this->started = true; + } + } + + /** + * Test if an SMTP connection has been established. + * + * @return bool + */ + public function isStarted() + { + return $this->started; + } + + /** + * Send the given Message. + * + * Recipient/sender data will be retrieved from the Message API. + * The return value is the number of recipients who were accepted for delivery. + * + * @param string[] $failedRecipients An array of failures by-reference + * + * @return int + */ + public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) + { + if (!$this->isStarted()) { + $this->start(); + } + + $sent = 0; + $failedRecipients = (array) $failedRecipients; + + if ($evt = $this->eventDispatcher->createSendEvent($this, $message)) { + $this->eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); + if ($evt->bubbleCancelled()) { + return 0; + } + } + + if (!$reversePath = $this->getReversePath($message)) { + $this->throwException(new Swift_TransportException('Cannot send message without a sender address')); + } + + $to = (array) $message->getTo(); + $cc = (array) $message->getCc(); + $bcc = (array) $message->getBcc(); + $tos = array_merge($to, $cc, $bcc); + + $message->setBcc([]); + + try { + $sent += $this->sendTo($message, $reversePath, $tos, $failedRecipients); + } finally { + $message->setBcc($bcc); + } + + if ($evt) { + if ($sent == \count($to) + \count($cc) + \count($bcc)) { + $evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS); + } elseif ($sent > 0) { + $evt->setResult(Swift_Events_SendEvent::RESULT_TENTATIVE); + } else { + $evt->setResult(Swift_Events_SendEvent::RESULT_FAILED); + } + $evt->setFailedRecipients($failedRecipients); + $this->eventDispatcher->dispatchEvent($evt, 'sendPerformed'); + } + + $message->generateId(); //Make sure a new Message ID is used + + return $sent; + } + + /** + * Stop the SMTP connection. + */ + public function stop() + { + if ($this->started) { + if ($evt = $this->eventDispatcher->createTransportChangeEvent($this)) { + $this->eventDispatcher->dispatchEvent($evt, 'beforeTransportStopped'); + if ($evt->bubbleCancelled()) { + return; + } + } + + try { + $this->executeCommand("QUIT\r\n", [221]); + } catch (Swift_TransportException $e) { + } + + try { + $this->buffer->terminate(); + + if ($evt) { + $this->eventDispatcher->dispatchEvent($evt, 'transportStopped'); + } + } catch (Swift_TransportException $e) { + $this->throwException($e); + } + } + $this->started = false; + } + + /** + * {@inheritdoc} + */ + public function ping() + { + try { + if (!$this->isStarted()) { + $this->start(); + } + + $this->executeCommand("NOOP\r\n", [250]); + } catch (Swift_TransportException $e) { + try { + $this->stop(); + } catch (Swift_TransportException $e) { + } + + return false; + } + + return true; + } + + /** + * Register a plugin. + */ + public function registerPlugin(Swift_Events_EventListener $plugin) + { + $this->eventDispatcher->bindEventListener($plugin); + } + + /** + * Reset the current mail transaction. + */ + public function reset() + { + $this->executeCommand("RSET\r\n", [250], $failures, true); + } + + /** + * Get the IoBuffer where read/writes are occurring. + * + * @return Swift_Transport_IoBuffer + */ + public function getBuffer() + { + return $this->buffer; + } + + /** + * Run a command against the buffer, expecting the given response codes. + * + * If no response codes are given, the response will not be validated. + * If codes are given, an exception will be thrown on an invalid response. + * If the command is RCPT TO, and the pipeline is non-empty, no exception + * will be thrown; instead the failing address is added to $failures. + * + * @param string $command + * @param int[] $codes + * @param string[] $failures An array of failures by-reference + * @param bool $pipeline Do not wait for response + * @param string $address the address, if command is RCPT TO + * + * @return string|null The server response, or null if pipelining is enabled + */ + public function executeCommand($command, $codes = [], &$failures = null, $pipeline = false, $address = null) + { + $failures = (array) $failures; + $seq = $this->buffer->write($command); + if ($evt = $this->eventDispatcher->createCommandEvent($this, $command, $codes)) { + $this->eventDispatcher->dispatchEvent($evt, 'commandSent'); + } + + $this->pipeline[] = [$command, $seq, $codes, $address]; + + if ($pipeline && $this->pipelining) { + return null; + } + + $response = null; + + while ($this->pipeline) { + list($command, $seq, $codes, $address) = array_shift($this->pipeline); + $response = $this->getFullResponse($seq); + try { + $this->assertResponseCode($response, $codes); + } catch (Swift_TransportException $e) { + if ($this->pipeline && $address) { + $failures[] = $address; + } else { + $this->throwException($e); + } + } + } + + return $response; + } + + /** Read the opening SMTP greeting */ + protected function readGreeting() + { + $this->assertResponseCode($this->getFullResponse(0), [220]); + } + + /** Send the HELO welcome */ + protected function doHeloCommand() + { + $this->executeCommand( + sprintf("HELO %s\r\n", $this->domain), [250] + ); + } + + /** Send the MAIL FROM command */ + protected function doMailFromCommand($address) + { + $address = $this->addressEncoder->encodeString($address); + $this->executeCommand( + sprintf("MAIL FROM:<%s>\r\n", $address), [250], $failures, true + ); + } + + /** Send the RCPT TO command */ + protected function doRcptToCommand($address) + { + $address = $this->addressEncoder->encodeString($address); + $this->executeCommand( + sprintf("RCPT TO:<%s>\r\n", $address), [250, 251, 252], $failures, true, $address + ); + } + + /** Send the DATA command */ + protected function doDataCommand(&$failedRecipients) + { + $this->executeCommand("DATA\r\n", [354], $failedRecipients); + } + + /** Stream the contents of the message over the buffer */ + protected function streamMessage(Swift_Mime_SimpleMessage $message) + { + $this->buffer->setWriteTranslations(["\r\n." => "\r\n.."]); + try { + $message->toByteStream($this->buffer); + $this->buffer->flushBuffers(); + } catch (Swift_TransportException $e) { + $this->throwException($e); + } + $this->buffer->setWriteTranslations([]); + $this->executeCommand("\r\n.\r\n", [250]); + } + + /** Determine the best-use reverse path for this message */ + protected function getReversePath(Swift_Mime_SimpleMessage $message) + { + $return = $message->getReturnPath(); + $sender = $message->getSender(); + $from = $message->getFrom(); + $path = null; + if (!empty($return)) { + $path = $return; + } elseif (!empty($sender)) { + // Don't use array_keys + reset($sender); // Reset Pointer to first pos + $path = key($sender); // Get key + } elseif (!empty($from)) { + reset($from); // Reset Pointer to first pos + $path = key($from); // Get key + } + + return $path; + } + + /** Throw a TransportException, first sending it to any listeners */ + protected function throwException(Swift_TransportException $e) + { + if ($evt = $this->eventDispatcher->createTransportExceptionEvent($this, $e)) { + $this->eventDispatcher->dispatchEvent($evt, 'exceptionThrown'); + if (!$evt->bubbleCancelled()) { + throw $e; + } + } else { + throw $e; + } + } + + /** Throws an Exception if a response code is incorrect */ + protected function assertResponseCode($response, $wanted) + { + if (!$response) { + $this->throwException(new Swift_TransportException('Expected response code '.implode('/', $wanted).' but got an empty response')); + } + + list($code) = sscanf($response, '%3d'); + $valid = (empty($wanted) || \in_array($code, $wanted)); + + if ($evt = $this->eventDispatcher->createResponseEvent($this, $response, + $valid)) { + $this->eventDispatcher->dispatchEvent($evt, 'responseReceived'); + } + + if (!$valid) { + $this->throwException(new Swift_TransportException('Expected response code '.implode('/', $wanted).' but got code "'.$code.'", with message "'.$response.'"', $code)); + } + } + + /** Get an entire multi-line response using its sequence number */ + protected function getFullResponse($seq) + { + $response = ''; + try { + do { + $line = $this->buffer->readLine($seq); + $response .= $line; + } while (null !== $line && false !== $line && ' ' != $line[3]); + } catch (Swift_TransportException $e) { + $this->throwException($e); + } catch (Swift_IoException $e) { + $this->throwException(new Swift_TransportException($e->getMessage(), 0, $e)); + } + + return $response; + } + + /** Send an email to the given recipients from the given reverse path */ + private function doMailTransaction($message, $reversePath, array $recipients, array &$failedRecipients) + { + $sent = 0; + $this->doMailFromCommand($reversePath); + foreach ($recipients as $forwardPath) { + try { + $this->doRcptToCommand($forwardPath); + ++$sent; + } catch (Swift_TransportException $e) { + $failedRecipients[] = $forwardPath; + } catch (Swift_AddressEncoderException $e) { + $failedRecipients[] = $forwardPath; + } + } + + if (0 != $sent) { + $sent += \count($failedRecipients); + $this->doDataCommand($failedRecipients); + $sent -= \count($failedRecipients); + + $this->streamMessage($message); + } else { + $this->reset(); + } + + return $sent; + } + + /** Send a message to the given To: recipients */ + private function sendTo(Swift_Mime_SimpleMessage $message, $reversePath, array $to, array &$failedRecipients) + { + if (empty($to)) { + return 0; + } + + return $this->doMailTransaction($message, $reversePath, array_keys($to), + $failedRecipients); + } + + /** + * Destructor. + */ + public function __destruct() + { + try { + $this->stop(); + } catch (Exception $e) { + } + } + + public function __sleep() + { + throw new \BadMethodCallException('Cannot serialize '.__CLASS__); + } + + public function __wakeup() + { + throw new \BadMethodCallException('Cannot unserialize '.__CLASS__); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php index 1c577324ced..bb3a1615096 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php @@ -15,61 +15,61 @@ */ class Swift_Transport_Esmtp_Auth_CramMd5Authenticator implements Swift_Transport_Esmtp_Authenticator { - /** - * Get the name of the AUTH mechanism this Authenticator handles. - * - * @return string - */ - public function getAuthKeyword() - { - return 'CRAM-MD5'; - } + /** + * Get the name of the AUTH mechanism this Authenticator handles. + * + * @return string + */ + public function getAuthKeyword() + { + return 'CRAM-MD5'; + } - /** - * {@inheritdoc} - */ - public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password) - { - try { - $challenge = $agent->executeCommand("AUTH CRAM-MD5\r\n", [334]); - $challenge = base64_decode(substr($challenge, 4)); - $message = base64_encode( - $username.' '.$this->getResponse($password, $challenge) - ); - $agent->executeCommand(sprintf("%s\r\n", $message), [235]); + /** + * {@inheritdoc} + */ + public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password) + { + try { + $challenge = $agent->executeCommand("AUTH CRAM-MD5\r\n", [334]); + $challenge = base64_decode(substr($challenge, 4)); + $message = base64_encode( + $username.' '.$this->getResponse($password, $challenge) + ); + $agent->executeCommand(sprintf("%s\r\n", $message), [235]); - return true; - } catch (Swift_TransportException $e) { - $agent->executeCommand("RSET\r\n", [250]); + return true; + } catch (Swift_TransportException $e) { + $agent->executeCommand("RSET\r\n", [250]); - throw $e; - } - } + throw $e; + } + } - /** - * Generate a CRAM-MD5 response from a server challenge. - * - * @param string $secret - * @param string $challenge - * - * @return string - */ - private function getResponse($secret, $challenge) - { - if (\strlen($secret) > 64) { - $secret = pack('H32', md5($secret)); - } + /** + * Generate a CRAM-MD5 response from a server challenge. + * + * @param string $secret + * @param string $challenge + * + * @return string + */ + private function getResponse($secret, $challenge) + { + if (\strlen($secret) > 64) { + $secret = pack('H32', md5($secret)); + } - if (\strlen($secret) < 64) { - $secret = str_pad($secret, 64, \chr(0)); - } + if (\strlen($secret) < 64) { + $secret = str_pad($secret, 64, \chr(0)); + } - $k_ipad = substr($secret, 0, 64) ^ str_repeat(\chr(0x36), 64); - $k_opad = substr($secret, 0, 64) ^ str_repeat(\chr(0x5C), 64); + $k_ipad = substr($secret, 0, 64) ^ str_repeat(\chr(0x36), 64); + $k_opad = substr($secret, 0, 64) ^ str_repeat(\chr(0x5C), 64); - $inner = pack('H32', md5($k_ipad.$challenge)); - $digest = md5($k_opad.$inner); + $inner = pack('H32', md5($k_ipad.$challenge)); + $digest = md5($k_opad.$inner); - return $digest; - } + return $digest; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php index 22e9ac723fd..0b9d81b8ad6 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php @@ -15,31 +15,31 @@ */ class Swift_Transport_Esmtp_Auth_LoginAuthenticator implements Swift_Transport_Esmtp_Authenticator { - /** - * Get the name of the AUTH mechanism this Authenticator handles. - * - * @return string - */ - public function getAuthKeyword() - { - return 'LOGIN'; - } + /** + * Get the name of the AUTH mechanism this Authenticator handles. + * + * @return string + */ + public function getAuthKeyword() + { + return 'LOGIN'; + } - /** - * {@inheritdoc} - */ - public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password) - { - try { - $agent->executeCommand("AUTH LOGIN\r\n", [334]); - $agent->executeCommand(sprintf("%s\r\n", base64_encode($username ?? '')), [334]); - $agent->executeCommand(sprintf("%s\r\n", base64_encode($password ?? '')), [235]); + /** + * {@inheritdoc} + */ + public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password) + { + try { + $agent->executeCommand("AUTH LOGIN\r\n", [334]); + $agent->executeCommand(sprintf("%s\r\n", base64_encode($username ?? '')), [334]); + $agent->executeCommand(sprintf("%s\r\n", base64_encode($password ?? '')), [235]); - return true; - } catch (Swift_TransportException $e) { - $agent->executeCommand("RSET\r\n", [250]); + return true; + } catch (Swift_TransportException $e) { + $agent->executeCommand("RSET\r\n", [250]); - throw $e; - } - } + throw $e; + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/NTLMAuthenticator.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/NTLMAuthenticator.php index dfccdecf200..41931fdd226 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/NTLMAuthenticator.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/NTLMAuthenticator.php @@ -17,665 +17,665 @@ */ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Esmtp_Authenticator { - const NTLMSIG = "NTLMSSP\x00"; - const DESCONST = 'KGS!@#$%'; - - /** - * Get the name of the AUTH mechanism this Authenticator handles. - * - * @return string - */ - public function getAuthKeyword() - { - return 'NTLM'; - } - - /** - * {@inheritdoc} - * - * @throws \LogicException - */ - public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password) - { - if (!\function_exists('openssl_encrypt')) { - throw new LogicException('The OpenSSL extension must be enabled to use the NTLM authenticator.'); - } - - if (!\function_exists('bcmul')) { - throw new LogicException('The BCMath functions must be enabled to use the NTLM authenticator.'); - } - - try { - // execute AUTH command and filter out the code at the beginning - // AUTH NTLM xxxx - $response = base64_decode(substr(trim($this->sendMessage1($agent) ?? ''), 4)); - - // extra parameters for our unit cases - $timestamp = \func_num_args() > 3 ? func_get_arg(3) : $this->getCorrectTimestamp(bcmul(microtime(true), '1000')); - $client = \func_num_args() > 4 ? func_get_arg(4) : random_bytes(8); - - // Message 3 response - $this->sendMessage3($response, $username, $password, $timestamp, $client, $agent); - - return true; - } catch (Swift_TransportException $e) { - $agent->executeCommand("RSET\r\n", [250]); - - throw $e; - } - } - - protected function si2bin($si, $bits = 32) - { - $bin = null; - if ($si >= -2 ** ($bits - 1) && ($si <= 2 ** ($bits - 1))) { - // positive or zero - if ($si >= 0) { - $bin = base_convert($si, 10, 2); - // pad to $bits bit - $bin_length = \strlen($bin); - if ($bin_length < $bits) { - $bin = str_repeat('0', $bits - $bin_length).$bin; - } - } else { - // negative - $si = -$si - 2 ** $bits; - $bin = base_convert($si, 10, 2); - $bin_length = \strlen($bin); - if ($bin_length > $bits) { - $bin = str_repeat('1', $bits - $bin_length).$bin; - } - } - } - - return $bin; - } - - /** - * Send our auth message and returns the response. - * - * @return string SMTP Response - */ - protected function sendMessage1(Swift_Transport_SmtpAgent $agent) - { - $message = $this->createMessage1(); - - return $agent->executeCommand(sprintf("AUTH %s %s\r\n", $this->getAuthKeyword(), base64_encode($message)), [334]); - } - - /** - * Fetch all details of our response (message 2). - * - * @param string $response - * - * @return array our response parsed - */ - protected function parseMessage2($response) - { - $responseHex = bin2hex($response); - $length = floor(hexdec(substr($responseHex, 28, 4)) / 256) * 2; - $offset = floor(hexdec(substr($responseHex, 32, 4)) / 256) * 2; - $challenge = hex2bin(substr($responseHex, 48, 16)); - $context = hex2bin(substr($responseHex, 64, 16)); - $targetInfoH = hex2bin(substr($responseHex, 80, 16)); - $targetName = hex2bin(substr($responseHex, $offset, $length)); - $offset = floor(hexdec(substr($responseHex, 88, 4)) / 256) * 2; - $targetInfoBlock = substr($responseHex, $offset); - list($domainName, $serverName, $DNSDomainName, $DNSServerName, $terminatorByte) = $this->readSubBlock($targetInfoBlock); - - return [ - $challenge, - $context, - $targetInfoH, - $targetName, - $domainName, - $serverName, - $DNSDomainName, - $DNSServerName, - hex2bin($targetInfoBlock), - $terminatorByte, - ]; - } - - /** - * Read the blob information in from message2. - * - * @return array - */ - protected function readSubBlock($block) - { - // remove terminatorByte cause it's always the same - $block = substr($block, 0, -8); - - $length = \strlen($block); - $offset = 0; - $data = []; - while ($offset < $length) { - $blockLength = hexdec(substr(substr($block, $offset, 8), -4)) / 256; - $offset += 8; - $data[] = hex2bin(substr($block, $offset, $blockLength * 2)); - $offset += $blockLength * 2; - } - - if (3 == \count($data)) { - $data[] = $data[2]; - $data[2] = ''; - } - - $data[] = $this->createByte('00'); - - return $data; - } - - /** - * Send our final message with all our data. - * - * @param string $response Message 1 response (message 2) - * @param string $username - * @param string $password - * @param string $timestamp - * @param string $client - * @param bool $v2 Use version2 of the protocol - * - * @return string - */ - protected function sendMessage3($response, $username, $password, $timestamp, $client, Swift_Transport_SmtpAgent $agent, $v2 = true) - { - list($domain, $username) = $this->getDomainAndUsername($username); - //$challenge, $context, $targetInfoH, $targetName, $domainName, $workstation, $DNSDomainName, $DNSServerName, $blob, $ter - list($challenge, , , , , $workstation, , , $blob) = $this->parseMessage2($response); - - if (!$v2) { - // LMv1 - $lmResponse = $this->createLMPassword($password, $challenge); - // NTLMv1 - $ntlmResponse = $this->createNTLMPassword($password, $challenge); - } else { - // LMv2 - $lmResponse = $this->createLMv2Password($password, $username, $domain, $challenge, $client); - // NTLMv2 - $ntlmResponse = $this->createNTLMv2Hash($password, $username, $domain, $challenge, $blob, $timestamp, $client); - } - - $message = $this->createMessage3($domain, $username, $workstation, $lmResponse, $ntlmResponse); - - return $agent->executeCommand(sprintf("%s\r\n", base64_encode($message)), [235]); - } - - /** - * Create our message 1. - * - * @return string - */ - protected function createMessage1() - { - return self::NTLMSIG - .$this->createByte('01') // Message 1 - .$this->createByte('0702'); // Flags - } - - /** - * Create our message 3. - * - * @param string $domain - * @param string $username - * @param string $workstation - * @param string $lmResponse - * @param string $ntlmResponse - * - * @return string - */ - protected function createMessage3($domain, $username, $workstation, $lmResponse, $ntlmResponse) - { - // Create security buffers - $domainSec = $this->createSecurityBuffer($domain, 64); - $domainInfo = $this->readSecurityBuffer(bin2hex($domainSec)); - $userSec = $this->createSecurityBuffer($username, ($domainInfo[0] + $domainInfo[1]) / 2); - $userInfo = $this->readSecurityBuffer(bin2hex($userSec)); - $workSec = $this->createSecurityBuffer($workstation, ($userInfo[0] + $userInfo[1]) / 2); - $workInfo = $this->readSecurityBuffer(bin2hex($workSec)); - $lmSec = $this->createSecurityBuffer($lmResponse, ($workInfo[0] + $workInfo[1]) / 2, true); - $lmInfo = $this->readSecurityBuffer(bin2hex($lmSec)); - $ntlmSec = $this->createSecurityBuffer($ntlmResponse, ($lmInfo[0] + $lmInfo[1]) / 2, true); - - return self::NTLMSIG - .$this->createByte('03') // TYPE 3 message - .$lmSec // LM response header - .$ntlmSec // NTLM response header - .$domainSec // Domain header - .$userSec // User header - .$workSec // Workstation header - .$this->createByte('000000009a', 8) // session key header (empty) - .$this->createByte('01020000') // FLAGS - .$this->convertTo16bit($domain) // domain name - .$this->convertTo16bit($username) // username - .$this->convertTo16bit($workstation) // workstation - .$lmResponse - .$ntlmResponse; - } - - /** - * @param string $timestamp Epoch timestamp in microseconds - * @param string $client Random bytes - * @param string $targetInfo - * - * @return string - */ - protected function createBlob($timestamp, $client, $targetInfo) - { - return $this->createByte('0101') - .$this->createByte('00') - .$timestamp - .$client - .$this->createByte('00') - .$targetInfo - .$this->createByte('00'); - } - - /** - * Get domain and username from our username. - * - * @example DOMAIN\username - * - * @param string $name - * - * @return array - */ - protected function getDomainAndUsername($name) - { - if (false !== strpos($name, '\\')) { - return explode('\\', $name); - } - - if (false !== strpos($name, '@')) { - list($user, $domain) = explode('@', $name); - - return [$domain, $user]; - } - - // no domain passed - return ['', $name]; - } - - /** - * Create LMv1 response. - * - * @param string $password - * @param string $challenge - * - * @return string - */ - protected function createLMPassword($password, $challenge) - { - // FIRST PART - $password = $this->createByte(strtoupper($password), 14, false); - list($key1, $key2) = str_split($password, 7); - - $desKey1 = $this->createDesKey($key1); - $desKey2 = $this->createDesKey($key2); - - $constantDecrypt = $this->createByte($this->desEncrypt(self::DESCONST, $desKey1).$this->desEncrypt(self::DESCONST, $desKey2), 21, false); - - // SECOND PART - list($key1, $key2, $key3) = str_split($constantDecrypt, 7); - - $desKey1 = $this->createDesKey($key1); - $desKey2 = $this->createDesKey($key2); - $desKey3 = $this->createDesKey($key3); - - return $this->desEncrypt($challenge, $desKey1).$this->desEncrypt($challenge, $desKey2).$this->desEncrypt($challenge, $desKey3); - } - - /** - * Create NTLMv1 response. - * - * @param string $password - * @param string $challenge - * - * @return string - */ - protected function createNTLMPassword($password, $challenge) - { - // FIRST PART - $ntlmHash = $this->createByte($this->md4Encrypt($password), 21, false); - list($key1, $key2, $key3) = str_split($ntlmHash, 7); - - $desKey1 = $this->createDesKey($key1); - $desKey2 = $this->createDesKey($key2); - $desKey3 = $this->createDesKey($key3); - - return $this->desEncrypt($challenge, $desKey1).$this->desEncrypt($challenge, $desKey2).$this->desEncrypt($challenge, $desKey3); - } - - /** - * Convert a normal timestamp to a tenth of a microtime epoch time. - * - * @param string $time - * - * @return string - */ - protected function getCorrectTimestamp($time) - { - // Get our timestamp (tricky!) - $time = number_format($time, 0, '.', ''); // save microtime to string - $time = bcadd($time, '11644473600000', 0); // add epoch time - $time = bcmul($time, 10000, 0); // tenths of a microsecond. - - $binary = $this->si2bin($time, 64); // create 64 bit binary string - $timestamp = ''; - for ($i = 0; $i < 8; ++$i) { - $timestamp .= \chr(bindec(substr($binary, -(($i + 1) * 8), 8))); - } - - return $timestamp; - } - - /** - * Create LMv2 response. - * - * @param string $password - * @param string $username - * @param string $domain - * @param string $challenge NTLM Challenge - * @param string $client Random string - * - * @return string - */ - protected function createLMv2Password($password, $username, $domain, $challenge, $client) - { - $lmPass = '00'; // by default 00 - // if $password > 15 than we can't use this method - if (\strlen($password) <= 15) { - $ntlmHash = $this->md4Encrypt($password); - $ntml2Hash = $this->md5Encrypt($ntlmHash, $this->convertTo16bit(strtoupper($username).$domain)); - - $lmPass = bin2hex($this->md5Encrypt($ntml2Hash, $challenge.$client).$client); - } - - return $this->createByte($lmPass, 24); - } - - /** - * Create NTLMv2 response. - * - * @param string $password - * @param string $username - * @param string $domain - * @param string $challenge Hex values - * @param string $targetInfo Hex values - * @param string $timestamp - * @param string $client Random bytes - * - * @return string - * - * @see http://davenport.sourceforge.net/ntlm.html#theNtlmResponse - */ - protected function createNTLMv2Hash($password, $username, $domain, $challenge, $targetInfo, $timestamp, $client) - { - $ntlmHash = $this->md4Encrypt($password); - $ntml2Hash = $this->md5Encrypt($ntlmHash, $this->convertTo16bit(strtoupper($username).$domain)); - - // create blob - $blob = $this->createBlob($timestamp, $client, $targetInfo); - - $ntlmv2Response = $this->md5Encrypt($ntml2Hash, $challenge.$blob); - - return $ntlmv2Response.$blob; - } - - protected function createDesKey($key) - { - $material = [bin2hex($key[0])]; - $len = \strlen($key); - for ($i = 1; $i < $len; ++$i) { - list($high, $low) = str_split(bin2hex($key[$i])); - $v = $this->castToByte(\ord($key[$i - 1]) << (7 + 1 - $i) | $this->uRShift(hexdec(dechex(hexdec($high) & 0xf).dechex(hexdec($low) & 0xf)), $i)); - $material[] = str_pad(substr(dechex($v), -2), 2, '0', STR_PAD_LEFT); // cast to byte - } - $material[] = str_pad(substr(dechex($this->castToByte(\ord($key[6]) << 1)), -2), 2, '0'); - - // odd parity - foreach ($material as $k => $v) { - $b = $this->castToByte(hexdec($v)); - $needsParity = 0 == (($this->uRShift($b, 7) ^ $this->uRShift($b, 6) ^ $this->uRShift($b, 5) - ^ $this->uRShift($b, 4) ^ $this->uRShift($b, 3) ^ $this->uRShift($b, 2) - ^ $this->uRShift($b, 1)) & 0x01); - - list($high, $low) = str_split($v); - if ($needsParity) { - $material[$k] = dechex(hexdec($high) | 0x0).dechex(hexdec($low) | 0x1); - } else { - $material[$k] = dechex(hexdec($high) & 0xf).dechex(hexdec($low) & 0xe); - } - } - - return hex2bin(implode('', $material)); - } - - /** HELPER FUNCTIONS */ - - /** - * Create our security buffer depending on length and offset. - * - * @param string $value Value we want to put in - * @param int $offset start of value - * @param bool $is16 Do we 16bit string or not? - * - * @return string - */ - protected function createSecurityBuffer($value, $offset, $is16 = false) - { - $length = \strlen(bin2hex($value)); - $length = $is16 ? $length / 2 : $length; - $length = $this->createByte(str_pad(dechex($length), 2, '0', STR_PAD_LEFT), 2); - - return $length.$length.$this->createByte(dechex($offset), 4); - } - - /** - * Read our security buffer to fetch length and offset of our value. - * - * @param string $value Securitybuffer in hex - * - * @return array array with length and offset - */ - protected function readSecurityBuffer($value) - { - $length = floor(hexdec(substr($value, 0, 4)) / 256) * 2; - $offset = floor(hexdec(substr($value, 8, 4)) / 256) * 2; - - return [$length, $offset]; - } - - /** - * Cast to byte java equivalent to (byte). - * - * @param int $v - * - * @return int - */ - protected function castToByte($v) - { - return (($v + 128) % 256) - 128; - } - - /** - * Java unsigned right bitwise - * $a >>> $b. - * - * @param int $a - * @param int $b - * - * @return int - */ - protected function uRShift($a, $b) - { - if (0 == $b) { - return $a; - } - - return ($a >> $b) & ~(1 << (8 * PHP_INT_SIZE - 1) >> ($b - 1)); - } - - /** - * Right padding with 0 to certain length. - * - * @param string $input - * @param int $bytes Length of bytes - * @param bool $isHex Did we provided hex value - * - * @return string - */ - protected function createByte($input, $bytes = 4, $isHex = true) - { - if ($isHex) { - $byte = hex2bin(str_pad($input, $bytes * 2, '00')); - } else { - $byte = str_pad($input, $bytes, "\x00"); - } - - return $byte; - } - - /** ENCRYPTION ALGORITHMS */ - - /** - * DES Encryption. - * - * @param string $value An 8-byte string - * @param string $key - * - * @return string - */ - protected function desEncrypt($value, $key) - { - return substr(openssl_encrypt($value, 'DES-ECB', $key, \OPENSSL_RAW_DATA), 0, 8); - } - - /** - * MD5 Encryption. - * - * @param string $key Encryption key - * @param string $msg Message to encrypt - * - * @return string - */ - protected function md5Encrypt($key, $msg) - { - $blocksize = 64; - if (\strlen($key) > $blocksize) { - $key = pack('H*', md5($key)); - } - - $key = str_pad($key, $blocksize, "\0"); - $ipadk = $key ^ str_repeat("\x36", $blocksize); - $opadk = $key ^ str_repeat("\x5c", $blocksize); - - return pack('H*', md5($opadk.pack('H*', md5($ipadk.$msg)))); - } - - /** - * MD4 Encryption. - * - * @param string $input - * - * @return string - * - * @see https://secure.php.net/manual/en/ref.hash.php - */ - protected function md4Encrypt($input) - { - $input = $this->convertTo16bit($input); - - return \function_exists('hash') ? hex2bin(hash('md4', $input)) : mhash(MHASH_MD4, $input); - } - - /** - * Convert UTF-8 to UTF-16. - * - * @param string $input - * - * @return string - */ - protected function convertTo16bit($input) - { - return iconv('UTF-8', 'UTF-16LE', $input); - } - - /** - * @param string $message - */ - protected function debug($message) - { - $message = bin2hex($message); - $messageId = substr($message, 16, 8); - echo substr($message, 0, 16)." NTLMSSP Signature
\n"; - echo $messageId." Type Indicator
\n"; - - if ('02000000' == $messageId) { - $map = [ - 'Challenge', - 'Context', - 'Target Information Security Buffer', - 'Target Name Data', - 'NetBIOS Domain Name', - 'NetBIOS Server Name', - 'DNS Domain Name', - 'DNS Server Name', - 'BLOB', - 'Target Information Terminator', - ]; - - $data = $this->parseMessage2(hex2bin($message)); - - foreach ($map as $key => $value) { - echo bin2hex($data[$key]).' - '.$data[$key].' ||| '.$value."
\n"; - } - } elseif ('03000000' == $messageId) { - $i = 0; - $data[$i++] = substr($message, 24, 16); - list($lmLength, $lmOffset) = $this->readSecurityBuffer($data[$i - 1]); - - $data[$i++] = substr($message, 40, 16); - list($ntmlLength, $ntmlOffset) = $this->readSecurityBuffer($data[$i - 1]); - - $data[$i++] = substr($message, 56, 16); - list($targetLength, $targetOffset) = $this->readSecurityBuffer($data[$i - 1]); - - $data[$i++] = substr($message, 72, 16); - list($userLength, $userOffset) = $this->readSecurityBuffer($data[$i - 1]); - - $data[$i++] = substr($message, 88, 16); - list($workLength, $workOffset) = $this->readSecurityBuffer($data[$i - 1]); - - $data[$i++] = substr($message, 104, 16); - $data[$i++] = substr($message, 120, 8); - $data[$i++] = substr($message, $targetOffset, $targetLength); - $data[$i++] = substr($message, $userOffset, $userLength); - $data[$i++] = substr($message, $workOffset, $workLength); - $data[$i++] = substr($message, $lmOffset, $lmLength); - $data[$i] = substr($message, $ntmlOffset, $ntmlLength); - - $map = [ - 'LM Response Security Buffer', - 'NTLM Response Security Buffer', - 'Target Name Security Buffer', - 'User Name Security Buffer', - 'Workstation Name Security Buffer', - 'Session Key Security Buffer', - 'Flags', - 'Target Name Data', - 'User Name Data', - 'Workstation Name Data', - 'LM Response Data', - 'NTLM Response Data', - ]; - - foreach ($map as $key => $value) { - echo $data[$key].' - '.hex2bin($data[$key]).' ||| '.$value."
\n"; - } - } - - echo '

'; - } + const NTLMSIG = "NTLMSSP\x00"; + const DESCONST = 'KGS!@#$%'; + + /** + * Get the name of the AUTH mechanism this Authenticator handles. + * + * @return string + */ + public function getAuthKeyword() + { + return 'NTLM'; + } + + /** + * {@inheritdoc} + * + * @throws \LogicException + */ + public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password) + { + if (!\function_exists('openssl_encrypt')) { + throw new LogicException('The OpenSSL extension must be enabled to use the NTLM authenticator.'); + } + + if (!\function_exists('bcmul')) { + throw new LogicException('The BCMath functions must be enabled to use the NTLM authenticator.'); + } + + try { + // execute AUTH command and filter out the code at the beginning + // AUTH NTLM xxxx + $response = base64_decode(substr(trim($this->sendMessage1($agent) ?? ''), 4)); + + // extra parameters for our unit cases + $timestamp = \func_num_args() > 3 ? func_get_arg(3) : $this->getCorrectTimestamp(bcmul(microtime(true), '1000')); + $client = \func_num_args() > 4 ? func_get_arg(4) : random_bytes(8); + + // Message 3 response + $this->sendMessage3($response, $username, $password, $timestamp, $client, $agent); + + return true; + } catch (Swift_TransportException $e) { + $agent->executeCommand("RSET\r\n", [250]); + + throw $e; + } + } + + protected function si2bin($si, $bits = 32) + { + $bin = null; + if ($si >= -2 ** ($bits - 1) && ($si <= 2 ** ($bits - 1))) { + // positive or zero + if ($si >= 0) { + $bin = base_convert($si, 10, 2); + // pad to $bits bit + $bin_length = \strlen($bin); + if ($bin_length < $bits) { + $bin = str_repeat('0', $bits - $bin_length).$bin; + } + } else { + // negative + $si = -$si - 2 ** $bits; + $bin = base_convert($si, 10, 2); + $bin_length = \strlen($bin); + if ($bin_length > $bits) { + $bin = str_repeat('1', $bits - $bin_length).$bin; + } + } + } + + return $bin; + } + + /** + * Send our auth message and returns the response. + * + * @return string SMTP Response + */ + protected function sendMessage1(Swift_Transport_SmtpAgent $agent) + { + $message = $this->createMessage1(); + + return $agent->executeCommand(sprintf("AUTH %s %s\r\n", $this->getAuthKeyword(), base64_encode($message)), [334]); + } + + /** + * Fetch all details of our response (message 2). + * + * @param string $response + * + * @return array our response parsed + */ + protected function parseMessage2($response) + { + $responseHex = bin2hex($response); + $length = floor(hexdec(substr($responseHex, 28, 4)) / 256) * 2; + $offset = floor(hexdec(substr($responseHex, 32, 4)) / 256) * 2; + $challenge = hex2bin(substr($responseHex, 48, 16)); + $context = hex2bin(substr($responseHex, 64, 16)); + $targetInfoH = hex2bin(substr($responseHex, 80, 16)); + $targetName = hex2bin(substr($responseHex, $offset, $length)); + $offset = floor(hexdec(substr($responseHex, 88, 4)) / 256) * 2; + $targetInfoBlock = substr($responseHex, $offset); + list($domainName, $serverName, $DNSDomainName, $DNSServerName, $terminatorByte) = $this->readSubBlock($targetInfoBlock); + + return [ + $challenge, + $context, + $targetInfoH, + $targetName, + $domainName, + $serverName, + $DNSDomainName, + $DNSServerName, + hex2bin($targetInfoBlock), + $terminatorByte, + ]; + } + + /** + * Read the blob information in from message2. + * + * @return array + */ + protected function readSubBlock($block) + { + // remove terminatorByte cause it's always the same + $block = substr($block, 0, -8); + + $length = \strlen($block); + $offset = 0; + $data = []; + while ($offset < $length) { + $blockLength = hexdec(substr(substr($block, $offset, 8), -4)) / 256; + $offset += 8; + $data[] = hex2bin(substr($block, $offset, $blockLength * 2)); + $offset += $blockLength * 2; + } + + if (3 == \count($data)) { + $data[] = $data[2]; + $data[2] = ''; + } + + $data[] = $this->createByte('00'); + + return $data; + } + + /** + * Send our final message with all our data. + * + * @param string $response Message 1 response (message 2) + * @param string $username + * @param string $password + * @param string $timestamp + * @param string $client + * @param bool $v2 Use version2 of the protocol + * + * @return string + */ + protected function sendMessage3($response, $username, $password, $timestamp, $client, Swift_Transport_SmtpAgent $agent, $v2 = true) + { + list($domain, $username) = $this->getDomainAndUsername($username); + //$challenge, $context, $targetInfoH, $targetName, $domainName, $workstation, $DNSDomainName, $DNSServerName, $blob, $ter + list($challenge, , , , , $workstation, , , $blob) = $this->parseMessage2($response); + + if (!$v2) { + // LMv1 + $lmResponse = $this->createLMPassword($password, $challenge); + // NTLMv1 + $ntlmResponse = $this->createNTLMPassword($password, $challenge); + } else { + // LMv2 + $lmResponse = $this->createLMv2Password($password, $username, $domain, $challenge, $client); + // NTLMv2 + $ntlmResponse = $this->createNTLMv2Hash($password, $username, $domain, $challenge, $blob, $timestamp, $client); + } + + $message = $this->createMessage3($domain, $username, $workstation, $lmResponse, $ntlmResponse); + + return $agent->executeCommand(sprintf("%s\r\n", base64_encode($message)), [235]); + } + + /** + * Create our message 1. + * + * @return string + */ + protected function createMessage1() + { + return self::NTLMSIG + .$this->createByte('01') // Message 1 +.$this->createByte('0702'); // Flags + } + + /** + * Create our message 3. + * + * @param string $domain + * @param string $username + * @param string $workstation + * @param string $lmResponse + * @param string $ntlmResponse + * + * @return string + */ + protected function createMessage3($domain, $username, $workstation, $lmResponse, $ntlmResponse) + { + // Create security buffers + $domainSec = $this->createSecurityBuffer($domain, 64); + $domainInfo = $this->readSecurityBuffer(bin2hex($domainSec)); + $userSec = $this->createSecurityBuffer($username, ($domainInfo[0] + $domainInfo[1]) / 2); + $userInfo = $this->readSecurityBuffer(bin2hex($userSec)); + $workSec = $this->createSecurityBuffer($workstation, ($userInfo[0] + $userInfo[1]) / 2); + $workInfo = $this->readSecurityBuffer(bin2hex($workSec)); + $lmSec = $this->createSecurityBuffer($lmResponse, ($workInfo[0] + $workInfo[1]) / 2, true); + $lmInfo = $this->readSecurityBuffer(bin2hex($lmSec)); + $ntlmSec = $this->createSecurityBuffer($ntlmResponse, ($lmInfo[0] + $lmInfo[1]) / 2, true); + + return self::NTLMSIG + .$this->createByte('03') // TYPE 3 message +.$lmSec // LM response header +.$ntlmSec // NTLM response header +.$domainSec // Domain header +.$userSec // User header +.$workSec // Workstation header +.$this->createByte('000000009a', 8) // session key header (empty) +.$this->createByte('01020000') // FLAGS +.$this->convertTo16bit($domain) // domain name +.$this->convertTo16bit($username) // username +.$this->convertTo16bit($workstation) // workstation +.$lmResponse + .$ntlmResponse; + } + + /** + * @param string $timestamp Epoch timestamp in microseconds + * @param string $client Random bytes + * @param string $targetInfo + * + * @return string + */ + protected function createBlob($timestamp, $client, $targetInfo) + { + return $this->createByte('0101') + .$this->createByte('00') + .$timestamp + .$client + .$this->createByte('00') + .$targetInfo + .$this->createByte('00'); + } + + /** + * Get domain and username from our username. + * + * @example DOMAIN\username + * + * @param string $name + * + * @return array + */ + protected function getDomainAndUsername($name) + { + if (false !== strpos($name, '\\')) { + return explode('\\', $name); + } + + if (false !== strpos($name, '@')) { + list($user, $domain) = explode('@', $name); + + return [$domain, $user]; + } + + // no domain passed + return ['', $name]; + } + + /** + * Create LMv1 response. + * + * @param string $password + * @param string $challenge + * + * @return string + */ + protected function createLMPassword($password, $challenge) + { + // FIRST PART + $password = $this->createByte(strtoupper($password), 14, false); + list($key1, $key2) = str_split($password, 7); + + $desKey1 = $this->createDesKey($key1); + $desKey2 = $this->createDesKey($key2); + + $constantDecrypt = $this->createByte($this->desEncrypt(self::DESCONST, $desKey1).$this->desEncrypt(self::DESCONST, $desKey2), 21, false); + + // SECOND PART + list($key1, $key2, $key3) = str_split($constantDecrypt, 7); + + $desKey1 = $this->createDesKey($key1); + $desKey2 = $this->createDesKey($key2); + $desKey3 = $this->createDesKey($key3); + + return $this->desEncrypt($challenge, $desKey1).$this->desEncrypt($challenge, $desKey2).$this->desEncrypt($challenge, $desKey3); + } + + /** + * Create NTLMv1 response. + * + * @param string $password + * @param string $challenge + * + * @return string + */ + protected function createNTLMPassword($password, $challenge) + { + // FIRST PART + $ntlmHash = $this->createByte($this->md4Encrypt($password), 21, false); + list($key1, $key2, $key3) = str_split($ntlmHash, 7); + + $desKey1 = $this->createDesKey($key1); + $desKey2 = $this->createDesKey($key2); + $desKey3 = $this->createDesKey($key3); + + return $this->desEncrypt($challenge, $desKey1).$this->desEncrypt($challenge, $desKey2).$this->desEncrypt($challenge, $desKey3); + } + + /** + * Convert a normal timestamp to a tenth of a microtime epoch time. + * + * @param string $time + * + * @return string + */ + protected function getCorrectTimestamp($time) + { + // Get our timestamp (tricky!) + $time = number_format($time, 0, '.', ''); // save microtime to string + $time = bcadd($time, '11644473600000', 0); // add epoch time + $time = bcmul($time, 10000, 0); // tenths of a microsecond. + + $binary = $this->si2bin($time, 64); // create 64 bit binary string + $timestamp = ''; + for ($i = 0; $i < 8; ++$i) { + $timestamp .= \chr(bindec(substr($binary, -(($i + 1) * 8), 8))); + } + + return $timestamp; + } + + /** + * Create LMv2 response. + * + * @param string $password + * @param string $username + * @param string $domain + * @param string $challenge NTLM Challenge + * @param string $client Random string + * + * @return string + */ + protected function createLMv2Password($password, $username, $domain, $challenge, $client) + { + $lmPass = '00'; // by default 00 + // if $password > 15 than we can't use this method + if (\strlen($password) <= 15) { + $ntlmHash = $this->md4Encrypt($password); + $ntml2Hash = $this->md5Encrypt($ntlmHash, $this->convertTo16bit(strtoupper($username).$domain)); + + $lmPass = bin2hex($this->md5Encrypt($ntml2Hash, $challenge.$client).$client); + } + + return $this->createByte($lmPass, 24); + } + + /** + * Create NTLMv2 response. + * + * @param string $password + * @param string $username + * @param string $domain + * @param string $challenge Hex values + * @param string $targetInfo Hex values + * @param string $timestamp + * @param string $client Random bytes + * + * @return string + * + * @see http://davenport.sourceforge.net/ntlm.html#theNtlmResponse + */ + protected function createNTLMv2Hash($password, $username, $domain, $challenge, $targetInfo, $timestamp, $client) + { + $ntlmHash = $this->md4Encrypt($password); + $ntml2Hash = $this->md5Encrypt($ntlmHash, $this->convertTo16bit(strtoupper($username).$domain)); + + // create blob + $blob = $this->createBlob($timestamp, $client, $targetInfo); + + $ntlmv2Response = $this->md5Encrypt($ntml2Hash, $challenge.$blob); + + return $ntlmv2Response.$blob; + } + + protected function createDesKey($key) + { + $material = [bin2hex($key[0])]; + $len = \strlen($key); + for ($i = 1; $i < $len; ++$i) { + list($high, $low) = str_split(bin2hex($key[$i])); + $v = $this->castToByte(\ord($key[$i - 1]) << (7 + 1 - $i) | $this->uRShift(hexdec(dechex(hexdec($high) & 0xf).dechex(hexdec($low) & 0xf)), $i)); + $material[] = str_pad(substr(dechex($v), -2), 2, '0', STR_PAD_LEFT); // cast to byte + } + $material[] = str_pad(substr(dechex($this->castToByte(\ord($key[6]) << 1)), -2), 2, '0'); + + // odd parity + foreach ($material as $k => $v) { + $b = $this->castToByte(hexdec($v)); + $needsParity = 0 == (($this->uRShift($b, 7) ^ $this->uRShift($b, 6) ^ $this->uRShift($b, 5) + ^ $this->uRShift($b, 4) ^ $this->uRShift($b, 3) ^ $this->uRShift($b, 2) + ^ $this->uRShift($b, 1)) & 0x01); + + list($high, $low) = str_split($v); + if ($needsParity) { + $material[$k] = dechex(hexdec($high) | 0x0).dechex(hexdec($low) | 0x1); + } else { + $material[$k] = dechex(hexdec($high) & 0xf).dechex(hexdec($low) & 0xe); + } + } + + return hex2bin(implode('', $material)); + } + + /** HELPER FUNCTIONS */ + + /** + * Create our security buffer depending on length and offset. + * + * @param string $value Value we want to put in + * @param int $offset start of value + * @param bool $is16 Do we 16bit string or not? + * + * @return string + */ + protected function createSecurityBuffer($value, $offset, $is16 = false) + { + $length = \strlen(bin2hex($value)); + $length = $is16 ? $length / 2 : $length; + $length = $this->createByte(str_pad(dechex($length), 2, '0', STR_PAD_LEFT), 2); + + return $length.$length.$this->createByte(dechex($offset), 4); + } + + /** + * Read our security buffer to fetch length and offset of our value. + * + * @param string $value Securitybuffer in hex + * + * @return array array with length and offset + */ + protected function readSecurityBuffer($value) + { + $length = floor(hexdec(substr($value, 0, 4)) / 256) * 2; + $offset = floor(hexdec(substr($value, 8, 4)) / 256) * 2; + + return [$length, $offset]; + } + + /** + * Cast to byte java equivalent to (byte). + * + * @param int $v + * + * @return int + */ + protected function castToByte($v) + { + return (($v + 128) % 256) - 128; + } + + /** + * Java unsigned right bitwise + * $a >>> $b. + * + * @param int $a + * @param int $b + * + * @return int + */ + protected function uRShift($a, $b) + { + if (0 == $b) { + return $a; + } + + return ($a >> $b) & ~(1 << (8 * PHP_INT_SIZE - 1) >> ($b - 1)); + } + + /** + * Right padding with 0 to certain length. + * + * @param string $input + * @param int $bytes Length of bytes + * @param bool $isHex Did we provided hex value + * + * @return string + */ + protected function createByte($input, $bytes = 4, $isHex = true) + { + if ($isHex) { + $byte = hex2bin(str_pad($input, $bytes * 2, '00')); + } else { + $byte = str_pad($input, $bytes, "\x00"); + } + + return $byte; + } + + /** ENCRYPTION ALGORITHMS */ + + /** + * DES Encryption. + * + * @param string $value An 8-byte string + * @param string $key + * + * @return string + */ + protected function desEncrypt($value, $key) + { + return substr(openssl_encrypt($value, 'DES-ECB', $key, \OPENSSL_RAW_DATA), 0, 8); + } + + /** + * MD5 Encryption. + * + * @param string $key Encryption key + * @param string $msg Message to encrypt + * + * @return string + */ + protected function md5Encrypt($key, $msg) + { + $blocksize = 64; + if (\strlen($key) > $blocksize) { + $key = pack('H*', md5($key)); + } + + $key = str_pad($key, $blocksize, "\0"); + $ipadk = $key ^ str_repeat("\x36", $blocksize); + $opadk = $key ^ str_repeat("\x5c", $blocksize); + + return pack('H*', md5($opadk.pack('H*', md5($ipadk.$msg)))); + } + + /** + * MD4 Encryption. + * + * @param string $input + * + * @return string + * + * @see https://secure.php.net/manual/en/ref.hash.php + */ + protected function md4Encrypt($input) + { + $input = $this->convertTo16bit($input); + + return \function_exists('hash') ? hex2bin(hash('md4', $input)) : mhash(MHASH_MD4, $input); + } + + /** + * Convert UTF-8 to UTF-16. + * + * @param string $input + * + * @return string + */ + protected function convertTo16bit($input) + { + return iconv('UTF-8', 'UTF-16LE', $input); + } + + /** + * @param string $message + */ + protected function debug($message) + { + $message = bin2hex($message); + $messageId = substr($message, 16, 8); + echo substr($message, 0, 16)." NTLMSSP Signature
\n"; + echo $messageId." Type Indicator
\n"; + + if ('02000000' == $messageId) { + $map = [ + 'Challenge', + 'Context', + 'Target Information Security Buffer', + 'Target Name Data', + 'NetBIOS Domain Name', + 'NetBIOS Server Name', + 'DNS Domain Name', + 'DNS Server Name', + 'BLOB', + 'Target Information Terminator', + ]; + + $data = $this->parseMessage2(hex2bin($message)); + + foreach ($map as $key => $value) { + echo bin2hex($data[$key]).' - '.$data[$key].' ||| '.$value."
\n"; + } + } elseif ('03000000' == $messageId) { + $i = 0; + $data[$i++] = substr($message, 24, 16); + list($lmLength, $lmOffset) = $this->readSecurityBuffer($data[$i - 1]); + + $data[$i++] = substr($message, 40, 16); + list($ntmlLength, $ntmlOffset) = $this->readSecurityBuffer($data[$i - 1]); + + $data[$i++] = substr($message, 56, 16); + list($targetLength, $targetOffset) = $this->readSecurityBuffer($data[$i - 1]); + + $data[$i++] = substr($message, 72, 16); + list($userLength, $userOffset) = $this->readSecurityBuffer($data[$i - 1]); + + $data[$i++] = substr($message, 88, 16); + list($workLength, $workOffset) = $this->readSecurityBuffer($data[$i - 1]); + + $data[$i++] = substr($message, 104, 16); + $data[$i++] = substr($message, 120, 8); + $data[$i++] = substr($message, $targetOffset, $targetLength); + $data[$i++] = substr($message, $userOffset, $userLength); + $data[$i++] = substr($message, $workOffset, $workLength); + $data[$i++] = substr($message, $lmOffset, $lmLength); + $data[$i] = substr($message, $ntmlOffset, $ntmlLength); + + $map = [ + 'LM Response Security Buffer', + 'NTLM Response Security Buffer', + 'Target Name Security Buffer', + 'User Name Security Buffer', + 'Workstation Name Security Buffer', + 'Session Key Security Buffer', + 'Flags', + 'Target Name Data', + 'User Name Data', + 'Workstation Name Data', + 'LM Response Data', + 'NTLM Response Data', + ]; + + foreach ($map as $key => $value) { + echo $data[$key].' - '.hex2bin($data[$key]).' ||| '.$value."
\n"; + } + } + + echo '

'; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php index cd1a2831e82..41d0a50a82b 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php @@ -15,30 +15,30 @@ */ class Swift_Transport_Esmtp_Auth_PlainAuthenticator implements Swift_Transport_Esmtp_Authenticator { - /** - * Get the name of the AUTH mechanism this Authenticator handles. - * - * @return string - */ - public function getAuthKeyword() - { - return 'PLAIN'; - } + /** + * Get the name of the AUTH mechanism this Authenticator handles. + * + * @return string + */ + public function getAuthKeyword() + { + return 'PLAIN'; + } - /** - * {@inheritdoc} - */ - public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password) - { - try { - $message = base64_encode($username.\chr(0).$username.\chr(0).$password); - $agent->executeCommand(sprintf("AUTH PLAIN %s\r\n", $message), [235]); + /** + * {@inheritdoc} + */ + public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password) + { + try { + $message = base64_encode($username.\chr(0).$username.\chr(0).$password); + $agent->executeCommand(sprintf("AUTH PLAIN %s\r\n", $message), [235]); - return true; - } catch (Swift_TransportException $e) { - $agent->executeCommand("RSET\r\n", [250]); + return true; + } catch (Swift_TransportException $e) { + $agent->executeCommand("RSET\r\n", [250]); - throw $e; - } - } + throw $e; + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php index c541b0ca952..859f22f3d5e 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php @@ -25,40 +25,40 @@ */ class Swift_Transport_Esmtp_Auth_XOAuth2Authenticator implements Swift_Transport_Esmtp_Authenticator { - /** - * Get the name of the AUTH mechanism this Authenticator handles. - * - * @return string - */ - public function getAuthKeyword() - { - return 'XOAUTH2'; - } + /** + * Get the name of the AUTH mechanism this Authenticator handles. + * + * @return string + */ + public function getAuthKeyword() + { + return 'XOAUTH2'; + } - /** - * {@inheritdoc} - */ - public function authenticate(Swift_Transport_SmtpAgent $agent, $email, $token) - { - try { - $param = $this->constructXOAuth2Params($email, $token); - $agent->executeCommand('AUTH XOAUTH2 '.$param."\r\n", [235]); + /** + * {@inheritdoc} + */ + public function authenticate(Swift_Transport_SmtpAgent $agent, $email, $token) + { + try { + $param = $this->constructXOAuth2Params($email, $token); + $agent->executeCommand('AUTH XOAUTH2 '.$param."\r\n", [235]); - return true; - } catch (Swift_TransportException $e) { - $agent->executeCommand("RSET\r\n", [250]); + return true; + } catch (Swift_TransportException $e) { + $agent->executeCommand("RSET\r\n", [250]); - throw $e; - } - } + throw $e; + } + } - /** - * Construct the auth parameter. - * - * @see https://developers.google.com/google-apps/gmail/xoauth2_protocol#the_sasl_xoauth2_mechanism - */ - protected function constructXOAuth2Params($email, $token) - { - return base64_encode("user=$email\1auth=Bearer $token\1\1"); - } + /** + * Construct the auth parameter. + * + * @see https://developers.google.com/google-apps/gmail/xoauth2_protocol#the_sasl_xoauth2_mechanism + */ + protected function constructXOAuth2Params($email, $token) + { + return base64_encode("user=$email\1auth=Bearer $token\1\1"); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php index 26ac6086fdf..53a90a87383 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php @@ -15,254 +15,254 @@ */ class Swift_Transport_Esmtp_AuthHandler implements Swift_Transport_EsmtpHandler { - /** - * Authenticators available to process the request. - * - * @var Swift_Transport_Esmtp_Authenticator[] - */ - private $authenticators = []; + /** + * Authenticators available to process the request. + * + * @var Swift_Transport_Esmtp_Authenticator[] + */ + private $authenticators = []; - /** - * The username for authentication. - * - * @var string - */ - private $username; + /** + * The username for authentication. + * + * @var string + */ + private $username; - /** - * The password for authentication. - * - * @var string - */ - private $password; + /** + * The password for authentication. + * + * @var string + */ + private $password; - /** - * The auth mode for authentication. - * - * @var string - */ - private $auth_mode; + /** + * The auth mode for authentication. + * + * @var string + */ + private $auth_mode; - /** - * The ESMTP AUTH parameters available. - * - * @var string[] - */ - private $esmtpParams = []; + /** + * The ESMTP AUTH parameters available. + * + * @var string[] + */ + private $esmtpParams = []; - /** - * Create a new AuthHandler with $authenticators for support. - * - * @param Swift_Transport_Esmtp_Authenticator[] $authenticators - */ - public function __construct(array $authenticators) - { - $this->setAuthenticators($authenticators); - } + /** + * Create a new AuthHandler with $authenticators for support. + * + * @param Swift_Transport_Esmtp_Authenticator[] $authenticators + */ + public function __construct(array $authenticators) + { + $this->setAuthenticators($authenticators); + } - /** - * Set the Authenticators which can process a login request. - * - * @param Swift_Transport_Esmtp_Authenticator[] $authenticators - */ - public function setAuthenticators(array $authenticators) - { - $this->authenticators = $authenticators; - } + /** + * Set the Authenticators which can process a login request. + * + * @param Swift_Transport_Esmtp_Authenticator[] $authenticators + */ + public function setAuthenticators(array $authenticators) + { + $this->authenticators = $authenticators; + } - /** - * Get the Authenticators which can process a login request. - * - * @return Swift_Transport_Esmtp_Authenticator[] - */ - public function getAuthenticators() - { - return $this->authenticators; - } + /** + * Get the Authenticators which can process a login request. + * + * @return Swift_Transport_Esmtp_Authenticator[] + */ + public function getAuthenticators() + { + return $this->authenticators; + } - /** - * Set the username to authenticate with. - * - * @param string $username - */ - public function setUsername($username) - { - $this->username = $username; - } + /** + * Set the username to authenticate with. + * + * @param string $username + */ + public function setUsername($username) + { + $this->username = $username; + } - /** - * Get the username to authenticate with. - * - * @return string - */ - public function getUsername() - { - return $this->username; - } + /** + * Get the username to authenticate with. + * + * @return string + */ + public function getUsername() + { + return $this->username; + } - /** - * Set the password to authenticate with. - * - * @param string $password - */ - public function setPassword($password) - { - $this->password = $password; - } + /** + * Set the password to authenticate with. + * + * @param string $password + */ + public function setPassword($password) + { + $this->password = $password; + } - /** - * Get the password to authenticate with. - * - * @return string - */ - public function getPassword() - { - return $this->password; - } + /** + * Get the password to authenticate with. + * + * @return string + */ + public function getPassword() + { + return $this->password; + } - /** - * Set the auth mode to use to authenticate. - * - * @param string $mode - */ - public function setAuthMode($mode) - { - $this->auth_mode = $mode; - } + /** + * Set the auth mode to use to authenticate. + * + * @param string $mode + */ + public function setAuthMode($mode) + { + $this->auth_mode = $mode; + } - /** - * Get the auth mode to use to authenticate. - * - * @return string - */ - public function getAuthMode() - { - return $this->auth_mode; - } + /** + * Get the auth mode to use to authenticate. + * + * @return string + */ + public function getAuthMode() + { + return $this->auth_mode; + } - /** - * Get the name of the ESMTP extension this handles. - * - * @return string - */ - public function getHandledKeyword() - { - return 'AUTH'; - } + /** + * Get the name of the ESMTP extension this handles. + * + * @return string + */ + public function getHandledKeyword() + { + return 'AUTH'; + } - /** - * Set the parameters which the EHLO greeting indicated. - * - * @param string[] $parameters - */ - public function setKeywordParams(array $parameters) - { - $this->esmtpParams = $parameters; - } + /** + * Set the parameters which the EHLO greeting indicated. + * + * @param string[] $parameters + */ + public function setKeywordParams(array $parameters) + { + $this->esmtpParams = $parameters; + } - /** - * Runs immediately after a EHLO has been issued. - * - * @param Swift_Transport_SmtpAgent $agent to read/write - */ - public function afterEhlo(Swift_Transport_SmtpAgent $agent) - { - if ($this->username) { - $count = 0; - $errors = []; - foreach ($this->getAuthenticatorsForAgent() as $authenticator) { - if (\in_array(strtolower($authenticator->getAuthKeyword() ?? ''), array_map('strtolower', $this->esmtpParams))) { - ++$count; - try { - if ($authenticator->authenticate($agent, $this->username, $this->password)) { - return; - } - } catch (Swift_TransportException $e) { - // keep the error message, but tries the other authenticators - $errors[] = [$authenticator->getAuthKeyword(), $e->getMessage()]; - } - } - } + /** + * Runs immediately after a EHLO has been issued. + * + * @param Swift_Transport_SmtpAgent $agent to read/write + */ + public function afterEhlo(Swift_Transport_SmtpAgent $agent) + { + if ($this->username) { + $count = 0; + $errors = []; + foreach ($this->getAuthenticatorsForAgent() as $authenticator) { + if (\in_array(strtolower($authenticator->getAuthKeyword() ?? ''), array_map('strtolower', $this->esmtpParams))) { + ++$count; + try { + if ($authenticator->authenticate($agent, $this->username, $this->password)) { + return; + } + } catch (Swift_TransportException $e) { + // keep the error message, but tries the other authenticators + $errors[] = [$authenticator->getAuthKeyword(), $e->getMessage()]; + } + } + } - $message = 'Failed to authenticate on SMTP server with username "'.$this->username.'" using '.$count.' possible authenticators.'; - foreach ($errors as $error) { - $message .= ' Authenticator '.$error[0].' returned '.$error[1].'.'; - } - throw new Swift_TransportException($message); - } - } + $message = 'Failed to authenticate on SMTP server with username "'.$this->username.'" using '.$count.' possible authenticators.'; + foreach ($errors as $error) { + $message .= ' Authenticator '.$error[0].' returned '.$error[1].'.'; + } + throw new Swift_TransportException($message); + } + } - /** - * Not used. - */ - public function getMailParams() - { - return []; - } + /** + * Not used. + */ + public function getMailParams() + { + return []; + } - /** - * Not used. - */ - public function getRcptParams() - { - return []; - } + /** + * Not used. + */ + public function getRcptParams() + { + return []; + } - /** - * Not used. - */ - public function onCommand(Swift_Transport_SmtpAgent $agent, $command, $codes = [], &$failedRecipients = null, &$stop = false) - { - } + /** + * Not used. + */ + public function onCommand(Swift_Transport_SmtpAgent $agent, $command, $codes = [], &$failedRecipients = null, &$stop = false) + { + } - /** - * Returns +1, -1 or 0 according to the rules for usort(). - * - * This method is called to ensure extensions can be execute in an appropriate order. - * - * @param string $esmtpKeyword to compare with - * - * @return int - */ - public function getPriorityOver($esmtpKeyword) - { - return 0; - } + /** + * Returns +1, -1 or 0 according to the rules for usort(). + * + * This method is called to ensure extensions can be execute in an appropriate order. + * + * @param string $esmtpKeyword to compare with + * + * @return int + */ + public function getPriorityOver($esmtpKeyword) + { + return 0; + } - /** - * Returns an array of method names which are exposed to the Esmtp class. - * - * @return string[] - */ - public function exposeMixinMethods() - { - return ['setUsername', 'getUsername', 'setPassword', 'getPassword', 'setAuthMode', 'getAuthMode']; - } + /** + * Returns an array of method names which are exposed to the Esmtp class. + * + * @return string[] + */ + public function exposeMixinMethods() + { + return ['setUsername', 'getUsername', 'setPassword', 'getPassword', 'setAuthMode', 'getAuthMode']; + } - /** - * Not used. - */ - public function resetState() - { - } + /** + * Not used. + */ + public function resetState() + { + } - /** - * Returns the authenticator list for the given agent. - * - * @return array - */ - protected function getAuthenticatorsForAgent() - { - if (!$mode = strtolower($this->auth_mode ?? '')) { - return $this->authenticators; - } + /** + * Returns the authenticator list for the given agent. + * + * @return array + */ + protected function getAuthenticatorsForAgent() + { + if (!$mode = strtolower($this->auth_mode ?? '')) { + return $this->authenticators; + } - foreach ($this->authenticators as $authenticator) { - if (strtolower($authenticator->getAuthKeyword() ?? '') == $mode) { - return [$authenticator]; - } - } + foreach ($this->authenticators as $authenticator) { + if (strtolower($authenticator->getAuthKeyword() ?? '') == $mode) { + return [$authenticator]; + } + } - throw new Swift_TransportException('Auth mode '.$mode.' is invalid'); - } + throw new Swift_TransportException('Auth mode '.$mode.' is invalid'); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Authenticator.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Authenticator.php index 40aeb1a65cc..f692a6fe40d 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Authenticator.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Authenticator.php @@ -15,22 +15,22 @@ */ interface Swift_Transport_Esmtp_Authenticator { - /** - * Get the name of the AUTH mechanism this Authenticator handles. - * - * @return string - */ - public function getAuthKeyword(); + /** + * Get the name of the AUTH mechanism this Authenticator handles. + * + * @return string + */ + public function getAuthKeyword(); - /** - * Try to authenticate the user with $username and $password. - * - * @param string $username - * @param string $password - * - * @return bool true if authentication worked (returning false is deprecated, throw a Swift_TransportException instead) - * - * @throws Swift_TransportException Allows the message to bubble up when authentication was not successful - */ - public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password); + /** + * Try to authenticate the user with $username and $password. + * + * @param string $username + * @param string $password + * + * @return bool true if authentication worked (returning false is deprecated, throw a Swift_TransportException instead) + * + * @throws Swift_TransportException Allows the message to bubble up when authentication was not successful + */ + public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/EightBitMimeHandler.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/EightBitMimeHandler.php index f2ab8d2e3cc..63f70866939 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/EightBitMimeHandler.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/EightBitMimeHandler.php @@ -22,92 +22,92 @@ */ class Swift_Transport_Esmtp_EightBitMimeHandler implements Swift_Transport_EsmtpHandler { - protected $encoding; + protected $encoding; - /** - * @param string $encoding The parameter so send with the MAIL FROM command; - * either "8BITMIME" or "7BIT" - */ - public function __construct(string $encoding = '8BITMIME') - { - $this->encoding = $encoding; - } + /** + * @param string $encoding The parameter so send with the MAIL FROM command; + * either "8BITMIME" or "7BIT" + */ + public function __construct(string $encoding = '8BITMIME') + { + $this->encoding = $encoding; + } - /** - * Get the name of the ESMTP extension this handles. - * - * @return string - */ - public function getHandledKeyword() - { - return '8BITMIME'; - } + /** + * Get the name of the ESMTP extension this handles. + * + * @return string + */ + public function getHandledKeyword() + { + return '8BITMIME'; + } - /** - * Not used. - */ - public function setKeywordParams(array $parameters) - { - } + /** + * Not used. + */ + public function setKeywordParams(array $parameters) + { + } - /** - * Not used. - */ - public function afterEhlo(Swift_Transport_SmtpAgent $agent) - { - } + /** + * Not used. + */ + public function afterEhlo(Swift_Transport_SmtpAgent $agent) + { + } - /** - * Get params which are appended to MAIL FROM:<>. - * - * @return string[] - */ - public function getMailParams() - { - return ['BODY='.$this->encoding]; - } + /** + * Get params which are appended to MAIL FROM:<>. + * + * @return string[] + */ + public function getMailParams() + { + return ['BODY='.$this->encoding]; + } - /** - * Not used. - */ - public function getRcptParams() - { - return []; - } + /** + * Not used. + */ + public function getRcptParams() + { + return []; + } - /** - * Not used. - */ - public function onCommand(Swift_Transport_SmtpAgent $agent, $command, $codes = [], &$failedRecipients = null, &$stop = false) - { - } + /** + * Not used. + */ + public function onCommand(Swift_Transport_SmtpAgent $agent, $command, $codes = [], &$failedRecipients = null, &$stop = false) + { + } - /** - * Returns +1, -1 or 0 according to the rules for usort(). - * - * This method is called to ensure extensions can be execute in an appropriate order. - * - * @param string $esmtpKeyword to compare with - * - * @return int - */ - public function getPriorityOver($esmtpKeyword) - { - return 0; - } + /** + * Returns +1, -1 or 0 according to the rules for usort(). + * + * This method is called to ensure extensions can be execute in an appropriate order. + * + * @param string $esmtpKeyword to compare with + * + * @return int + */ + public function getPriorityOver($esmtpKeyword) + { + return 0; + } - /** - * Not used. - */ - public function exposeMixinMethods() - { - return []; - } + /** + * Not used. + */ + public function exposeMixinMethods() + { + return []; + } - /** - * Not used. - */ - public function resetState() - { - } + /** + * Not used. + */ + public function resetState() + { + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/SmtpUtf8Handler.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/SmtpUtf8Handler.php index e9b4b69ea6a..7d0252a01bf 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/SmtpUtf8Handler.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/SmtpUtf8Handler.php @@ -23,85 +23,85 @@ */ class Swift_Transport_Esmtp_SmtpUtf8Handler implements Swift_Transport_EsmtpHandler { - public function __construct() - { - } + public function __construct() + { + } - /** - * Get the name of the ESMTP extension this handles. - * - * @return string - */ - public function getHandledKeyword() - { - return 'SMTPUTF8'; - } + /** + * Get the name of the ESMTP extension this handles. + * + * @return string + */ + public function getHandledKeyword() + { + return 'SMTPUTF8'; + } - /** - * Not used. - */ - public function setKeywordParams(array $parameters) - { - } + /** + * Not used. + */ + public function setKeywordParams(array $parameters) + { + } - /** - * Not used. - */ - public function afterEhlo(Swift_Transport_SmtpAgent $agent) - { - } + /** + * Not used. + */ + public function afterEhlo(Swift_Transport_SmtpAgent $agent) + { + } - /** - * Get params which are appended to MAIL FROM:<>. - * - * @return string[] - */ - public function getMailParams() - { - return ['SMTPUTF8']; - } + /** + * Get params which are appended to MAIL FROM:<>. + * + * @return string[] + */ + public function getMailParams() + { + return ['SMTPUTF8']; + } - /** - * Not used. - */ - public function getRcptParams() - { - return []; - } + /** + * Not used. + */ + public function getRcptParams() + { + return []; + } - /** - * Not used. - */ - public function onCommand(Swift_Transport_SmtpAgent $agent, $command, $codes = [], &$failedRecipients = null, &$stop = false) - { - } + /** + * Not used. + */ + public function onCommand(Swift_Transport_SmtpAgent $agent, $command, $codes = [], &$failedRecipients = null, &$stop = false) + { + } - /** - * Returns +1, -1 or 0 according to the rules for usort(). - * - * This method is called to ensure extensions can be execute in an appropriate order. - * - * @param string $esmtpKeyword to compare with - * - * @return int - */ - public function getPriorityOver($esmtpKeyword) - { - return 0; - } + /** + * Returns +1, -1 or 0 according to the rules for usort(). + * + * This method is called to ensure extensions can be execute in an appropriate order. + * + * @param string $esmtpKeyword to compare with + * + * @return int + */ + public function getPriorityOver($esmtpKeyword) + { + return 0; + } - /** - * Not used. - */ - public function exposeMixinMethods() - { - return []; - } + /** + * Not used. + */ + public function exposeMixinMethods() + { + return []; + } - /** - * Not used. - */ - public function resetState() - { - } + /** + * Not used. + */ + public function resetState() + { + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/EsmtpHandler.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/EsmtpHandler.php index 7dad692f12a..b8ea36e2fa8 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/EsmtpHandler.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/EsmtpHandler.php @@ -15,72 +15,72 @@ */ interface Swift_Transport_EsmtpHandler { - /** - * Get the name of the ESMTP extension this handles. - * - * @return string - */ - public function getHandledKeyword(); + /** + * Get the name of the ESMTP extension this handles. + * + * @return string + */ + public function getHandledKeyword(); - /** - * Set the parameters which the EHLO greeting indicated. - * - * @param string[] $parameters - */ - public function setKeywordParams(array $parameters); + /** + * Set the parameters which the EHLO greeting indicated. + * + * @param string[] $parameters + */ + public function setKeywordParams(array $parameters); - /** - * Runs immediately after a EHLO has been issued. - * - * @param Swift_Transport_SmtpAgent $agent to read/write - */ - public function afterEhlo(Swift_Transport_SmtpAgent $agent); + /** + * Runs immediately after a EHLO has been issued. + * + * @param Swift_Transport_SmtpAgent $agent to read/write + */ + public function afterEhlo(Swift_Transport_SmtpAgent $agent); - /** - * Get params which are appended to MAIL FROM:<>. - * - * @return string[] - */ - public function getMailParams(); + /** + * Get params which are appended to MAIL FROM:<>. + * + * @return string[] + */ + public function getMailParams(); - /** - * Get params which are appended to RCPT TO:<>. - * - * @return string[] - */ - public function getRcptParams(); + /** + * Get params which are appended to RCPT TO:<>. + * + * @return string[] + */ + public function getRcptParams(); - /** - * Runs when a command is due to be sent. - * - * @param Swift_Transport_SmtpAgent $agent to read/write - * @param string $command to send - * @param int[] $codes expected in response - * @param string[] $failedRecipients to collect failures - * @param bool $stop to be set true by-reference if the command is now sent - */ - public function onCommand(Swift_Transport_SmtpAgent $agent, $command, $codes = [], &$failedRecipients = null, &$stop = false); + /** + * Runs when a command is due to be sent. + * + * @param Swift_Transport_SmtpAgent $agent to read/write + * @param string $command to send + * @param int[] $codes expected in response + * @param string[] $failedRecipients to collect failures + * @param bool $stop to be set true by-reference if the command is now sent + */ + public function onCommand(Swift_Transport_SmtpAgent $agent, $command, $codes = [], &$failedRecipients = null, &$stop = false); - /** - * Returns +1, -1 or 0 according to the rules for usort(). - * - * This method is called to ensure extensions can be execute in an appropriate order. - * - * @param string $esmtpKeyword to compare with - * - * @return int - */ - public function getPriorityOver($esmtpKeyword); + /** + * Returns +1, -1 or 0 according to the rules for usort(). + * + * This method is called to ensure extensions can be execute in an appropriate order. + * + * @param string $esmtpKeyword to compare with + * + * @return int + */ + public function getPriorityOver($esmtpKeyword); - /** - * Returns an array of method names which are exposed to the Esmtp class. - * - * @return string[] - */ - public function exposeMixinMethods(); + /** + * Returns an array of method names which are exposed to the Esmtp class. + * + * @return string[] + */ + public function exposeMixinMethods(); - /** - * Tells this handler to clear any buffers and reset its state. - */ - public function resetState(); + /** + * Tells this handler to clear any buffers and reset its state. + */ + public function resetState(); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php index 281337ee855..36545f51feb 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php @@ -15,432 +15,432 @@ */ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTransport implements Swift_Transport_SmtpAgent { - /** - * ESMTP extension handlers. - * - * @var Swift_Transport_EsmtpHandler[] - */ - private $handlers = []; + /** + * ESMTP extension handlers. + * + * @var Swift_Transport_EsmtpHandler[] + */ + private $handlers = []; - /** - * ESMTP capabilities. - * - * @var string[] - */ - private $capabilities = []; + /** + * ESMTP capabilities. + * + * @var string[] + */ + private $capabilities = []; - /** - * Connection buffer parameters. - * - * @var array - */ - private $params = [ - 'protocol' => 'tcp', - 'host' => 'localhost', - 'port' => 25, - 'timeout' => 30, - 'blocking' => 1, - 'tls' => false, - 'type' => Swift_Transport_IoBuffer::TYPE_SOCKET, - 'stream_context_options' => [], - ]; + /** + * Connection buffer parameters. + * + * @var array + */ + private $params = [ + 'protocol' => 'tcp', + 'host' => 'localhost', + 'port' => 25, + 'timeout' => 30, + 'blocking' => 1, + 'tls' => false, + 'type' => Swift_Transport_IoBuffer::TYPE_SOCKET, + 'stream_context_options' => [], + ]; - /** - * Creates a new EsmtpTransport using the given I/O buffer. - * - * @param Swift_Transport_EsmtpHandler[] $extensionHandlers - * @param string $localDomain - */ - public function __construct(Swift_Transport_IoBuffer $buf, array $extensionHandlers, Swift_Events_EventDispatcher $dispatcher, $localDomain = '127.0.0.1', Swift_AddressEncoder $addressEncoder = null) - { - parent::__construct($buf, $dispatcher, $localDomain, $addressEncoder); - $this->setExtensionHandlers($extensionHandlers); - } + /** + * Creates a new EsmtpTransport using the given I/O buffer. + * + * @param Swift_Transport_EsmtpHandler[] $extensionHandlers + * @param string $localDomain + */ + public function __construct(Swift_Transport_IoBuffer $buf, array $extensionHandlers, Swift_Events_EventDispatcher $dispatcher, $localDomain = '127.0.0.1', Swift_AddressEncoder $addressEncoder = null) + { + parent::__construct($buf, $dispatcher, $localDomain, $addressEncoder); + $this->setExtensionHandlers($extensionHandlers); + } - /** - * Set the host to connect to. - * - * Literal IPv6 addresses should be wrapped in square brackets. - * - * @param string $host - * - * @return $this - */ - public function setHost($host) - { - $this->params['host'] = $host; + /** + * Set the host to connect to. + * + * Literal IPv6 addresses should be wrapped in square brackets. + * + * @param string $host + * + * @return $this + */ + public function setHost($host) + { + $this->params['host'] = $host; - return $this; - } + return $this; + } - /** - * Get the host to connect to. - * - * @return string - */ - public function getHost() - { - return $this->params['host']; - } + /** + * Get the host to connect to. + * + * @return string + */ + public function getHost() + { + return $this->params['host']; + } - /** - * Set the port to connect to. - * - * @param int $port - * - * @return $this - */ - public function setPort($port) - { - $this->params['port'] = (int) $port; + /** + * Set the port to connect to. + * + * @param int $port + * + * @return $this + */ + public function setPort($port) + { + $this->params['port'] = (int) $port; - return $this; - } + return $this; + } - /** - * Get the port to connect to. - * - * @return int - */ - public function getPort() - { - return $this->params['port']; - } + /** + * Get the port to connect to. + * + * @return int + */ + public function getPort() + { + return $this->params['port']; + } - /** - * Set the connection timeout. - * - * @param int $timeout seconds - * - * @return $this - */ - public function setTimeout($timeout) - { - $this->params['timeout'] = (int) $timeout; - $this->buffer->setParam('timeout', (int) $timeout); + /** + * Set the connection timeout. + * + * @param int $timeout seconds + * + * @return $this + */ + public function setTimeout($timeout) + { + $this->params['timeout'] = (int) $timeout; + $this->buffer->setParam('timeout', (int) $timeout); - return $this; - } + return $this; + } - /** - * Get the connection timeout. - * - * @return int - */ - public function getTimeout() - { - return $this->params['timeout']; - } + /** + * Get the connection timeout. + * + * @return int + */ + public function getTimeout() + { + return $this->params['timeout']; + } - /** - * Set the encryption type (tls or ssl). - * - * @param string $encryption - * - * @return $this - */ - public function setEncryption($encryption) - { - $encryption = strtolower($encryption ?? ''); - if ('tls' == $encryption) { - $this->params['protocol'] = 'tcp'; - $this->params['tls'] = true; - } else { - $this->params['protocol'] = $encryption; - $this->params['tls'] = false; - } + /** + * Set the encryption type (tls or ssl). + * + * @param string $encryption + * + * @return $this + */ + public function setEncryption($encryption) + { + $encryption = strtolower($encryption ?? ''); + if ('tls' == $encryption) { + $this->params['protocol'] = 'tcp'; + $this->params['tls'] = true; + } else { + $this->params['protocol'] = $encryption; + $this->params['tls'] = false; + } - return $this; - } + return $this; + } - /** - * Get the encryption type. - * - * @return string - */ - public function getEncryption() - { - return $this->params['tls'] ? 'tls' : $this->params['protocol']; - } + /** + * Get the encryption type. + * + * @return string + */ + public function getEncryption() + { + return $this->params['tls'] ? 'tls' : $this->params['protocol']; + } - /** - * Sets the stream context options. - * - * @param array $options - * - * @return $this - */ - public function setStreamOptions($options) - { - $this->params['stream_context_options'] = $options; + /** + * Sets the stream context options. + * + * @param array $options + * + * @return $this + */ + public function setStreamOptions($options) + { + $this->params['stream_context_options'] = $options; - return $this; - } + return $this; + } - /** - * Returns the stream context options. - * - * @return array - */ - public function getStreamOptions() - { - return $this->params['stream_context_options']; - } + /** + * Returns the stream context options. + * + * @return array + */ + public function getStreamOptions() + { + return $this->params['stream_context_options']; + } - /** - * Sets the source IP. - * - * IPv6 addresses should be wrapped in square brackets. - * - * @param string $source - * - * @return $this - */ - public function setSourceIp($source) - { - $this->params['sourceIp'] = $source; + /** + * Sets the source IP. + * + * IPv6 addresses should be wrapped in square brackets. + * + * @param string $source + * + * @return $this + */ + public function setSourceIp($source) + { + $this->params['sourceIp'] = $source; - return $this; - } + return $this; + } - /** - * Returns the IP used to connect to the destination. - * - * @return string - */ - public function getSourceIp() - { - return $this->params['sourceIp'] ?? null; - } + /** + * Returns the IP used to connect to the destination. + * + * @return string + */ + public function getSourceIp() + { + return $this->params['sourceIp'] ?? null; + } - /** - * Sets whether SMTP pipelining is enabled. - * - * By default, support is auto-detected using the PIPELINING SMTP extension. - * Use this function to override that in the unlikely event of compatibility - * issues. - * - * @param bool $enabled - * - * @return $this - */ - public function setPipelining($enabled) - { - $this->pipelining = $enabled; + /** + * Sets whether SMTP pipelining is enabled. + * + * By default, support is auto-detected using the PIPELINING SMTP extension. + * Use this function to override that in the unlikely event of compatibility + * issues. + * + * @param bool $enabled + * + * @return $this + */ + public function setPipelining($enabled) + { + $this->pipelining = $enabled; - return $this; - } + return $this; + } - /** - * Returns whether SMTP pipelining is enabled. - * - * @return bool|null a boolean if pipelining is explicitly enabled or disabled, - * or null if support is auto-detected - */ - public function getPipelining() - { - return $this->pipelining; - } + /** + * Returns whether SMTP pipelining is enabled. + * + * @return bool|null a boolean if pipelining is explicitly enabled or disabled, + * or null if support is auto-detected + */ + public function getPipelining() + { + return $this->pipelining; + } - /** - * Set ESMTP extension handlers. - * - * @param Swift_Transport_EsmtpHandler[] $handlers - * - * @return $this - */ - public function setExtensionHandlers(array $handlers) - { - $assoc = []; - foreach ($handlers as $handler) { - $assoc[$handler->getHandledKeyword()] = $handler; - } - uasort($assoc, function ($a, $b) { - return $a->getPriorityOver($b->getHandledKeyword()); - }); - $this->handlers = $assoc; - $this->setHandlerParams(); + /** + * Set ESMTP extension handlers. + * + * @param Swift_Transport_EsmtpHandler[] $handlers + * + * @return $this + */ + public function setExtensionHandlers(array $handlers) + { + $assoc = []; + foreach ($handlers as $handler) { + $assoc[$handler->getHandledKeyword()] = $handler; + } + uasort($assoc, function ($a, $b) { + return $a->getPriorityOver($b->getHandledKeyword()); + }); + $this->handlers = $assoc; + $this->setHandlerParams(); - return $this; - } + return $this; + } - /** - * Get ESMTP extension handlers. - * - * @return Swift_Transport_EsmtpHandler[] - */ - public function getExtensionHandlers() - { - return array_values($this->handlers); - } + /** + * Get ESMTP extension handlers. + * + * @return Swift_Transport_EsmtpHandler[] + */ + public function getExtensionHandlers() + { + return array_values($this->handlers); + } - /** - * Run a command against the buffer, expecting the given response codes. - * - * If no response codes are given, the response will not be validated. - * If codes are given, an exception will be thrown on an invalid response. - * - * @param string $command - * @param int[] $codes - * @param string[] $failures An array of failures by-reference - * @param bool $pipeline Do not wait for response - * @param string $address the address, if command is RCPT TO - * - * @return string|null The server response, or null if pipelining is enabled - */ - public function executeCommand($command, $codes = [], &$failures = null, $pipeline = false, $address = null) - { - $failures = (array) $failures; - $stopSignal = false; - $response = null; - foreach ($this->getActiveHandlers() as $handler) { - $response = $handler->onCommand( - $this, $command, $codes, $failures, $stopSignal - ); - if ($stopSignal) { - return $response; - } - } + /** + * Run a command against the buffer, expecting the given response codes. + * + * If no response codes are given, the response will not be validated. + * If codes are given, an exception will be thrown on an invalid response. + * + * @param string $command + * @param int[] $codes + * @param string[] $failures An array of failures by-reference + * @param bool $pipeline Do not wait for response + * @param string $address the address, if command is RCPT TO + * + * @return string|null The server response, or null if pipelining is enabled + */ + public function executeCommand($command, $codes = [], &$failures = null, $pipeline = false, $address = null) + { + $failures = (array) $failures; + $stopSignal = false; + $response = null; + foreach ($this->getActiveHandlers() as $handler) { + $response = $handler->onCommand( + $this, $command, $codes, $failures, $stopSignal + ); + if ($stopSignal) { + return $response; + } + } - return parent::executeCommand($command, $codes, $failures, $pipeline, $address); - } + return parent::executeCommand($command, $codes, $failures, $pipeline, $address); + } - /** Mixin handling method for ESMTP handlers */ - public function __call($method, $args) - { - foreach ($this->handlers as $handler) { - if (\in_array(strtolower($method), - array_map('strtolower', (array) $handler->exposeMixinMethods()) - )) { - $return = \call_user_func_array([$handler, $method], $args); - // Allow fluid method calls - if (null === $return && 'set' == substr($method, 0, 3)) { - return $this; - } else { - return $return; - } - } - } - trigger_error('Call to undefined method '.$method, E_USER_ERROR); - } + /** Mixin handling method for ESMTP handlers */ + public function __call($method, $args) + { + foreach ($this->handlers as $handler) { + if (\in_array(strtolower($method), + array_map('strtolower', (array) $handler->exposeMixinMethods()) + )) { + $return = \call_user_func_array([$handler, $method], $args); + // Allow fluid method calls + if (null === $return && 'set' == substr($method, 0, 3)) { + return $this; + } else { + return $return; + } + } + } + trigger_error('Call to undefined method '.$method, E_USER_ERROR); + } - /** Get the params to initialize the buffer */ - protected function getBufferParams() - { - return $this->params; - } + /** Get the params to initialize the buffer */ + protected function getBufferParams() + { + return $this->params; + } - /** Overridden to perform EHLO instead */ - protected function doHeloCommand() - { - try { - $response = $this->executeCommand( - sprintf("EHLO %s\r\n", $this->domain), [250] - ); - } catch (Swift_TransportException $e) { - return parent::doHeloCommand(); - } + /** Overridden to perform EHLO instead */ + protected function doHeloCommand() + { + try { + $response = $this->executeCommand( + sprintf("EHLO %s\r\n", $this->domain), [250] + ); + } catch (Swift_TransportException $e) { + return parent::doHeloCommand(); + } - if ($this->params['tls']) { - try { - $this->executeCommand("STARTTLS\r\n", [220]); + if ($this->params['tls']) { + try { + $this->executeCommand("STARTTLS\r\n", [220]); - if (!$this->buffer->startTLS()) { - throw new Swift_TransportException('Unable to connect with TLS encryption'); - } + if (!$this->buffer->startTLS()) { + throw new Swift_TransportException('Unable to connect with TLS encryption'); + } - try { - $response = $this->executeCommand( - sprintf("EHLO %s\r\n", $this->domain), [250] - ); - } catch (Swift_TransportException $e) { - return parent::doHeloCommand(); - } - } catch (Swift_TransportException $e) { - $this->throwException($e); - } - } + try { + $response = $this->executeCommand( + sprintf("EHLO %s\r\n", $this->domain), [250] + ); + } catch (Swift_TransportException $e) { + return parent::doHeloCommand(); + } + } catch (Swift_TransportException $e) { + $this->throwException($e); + } + } - $this->capabilities = $this->getCapabilities($response); - if (!isset($this->pipelining)) { - $this->pipelining = isset($this->capabilities['PIPELINING']); - } + $this->capabilities = $this->getCapabilities($response); + if (!isset($this->pipelining)) { + $this->pipelining = isset($this->capabilities['PIPELINING']); + } - $this->setHandlerParams(); - foreach ($this->getActiveHandlers() as $handler) { - $handler->afterEhlo($this); - } - } + $this->setHandlerParams(); + foreach ($this->getActiveHandlers() as $handler) { + $handler->afterEhlo($this); + } + } - /** Overridden to add Extension support */ - protected function doMailFromCommand($address) - { - $address = $this->addressEncoder->encodeString($address); - $handlers = $this->getActiveHandlers(); - $params = []; - foreach ($handlers as $handler) { - $params = array_merge($params, (array) $handler->getMailParams()); - } - $paramStr = !empty($params) ? ' '.implode(' ', $params) : ''; - $this->executeCommand( - sprintf("MAIL FROM:<%s>%s\r\n", $address, $paramStr), [250], $failures, true - ); - } + /** Overridden to add Extension support */ + protected function doMailFromCommand($address) + { + $address = $this->addressEncoder->encodeString($address); + $handlers = $this->getActiveHandlers(); + $params = []; + foreach ($handlers as $handler) { + $params = array_merge($params, (array) $handler->getMailParams()); + } + $paramStr = !empty($params) ? ' '.implode(' ', $params) : ''; + $this->executeCommand( + sprintf("MAIL FROM:<%s>%s\r\n", $address, $paramStr), [250], $failures, true + ); + } - /** Overridden to add Extension support */ - protected function doRcptToCommand($address) - { - $address = $this->addressEncoder->encodeString($address); - $handlers = $this->getActiveHandlers(); - $params = []; - foreach ($handlers as $handler) { - $params = array_merge($params, (array) $handler->getRcptParams()); - } - $paramStr = !empty($params) ? ' '.implode(' ', $params) : ''; - $this->executeCommand( - sprintf("RCPT TO:<%s>%s\r\n", $address, $paramStr), [250, 251, 252], $failures, true, $address - ); - } + /** Overridden to add Extension support */ + protected function doRcptToCommand($address) + { + $address = $this->addressEncoder->encodeString($address); + $handlers = $this->getActiveHandlers(); + $params = []; + foreach ($handlers as $handler) { + $params = array_merge($params, (array) $handler->getRcptParams()); + } + $paramStr = !empty($params) ? ' '.implode(' ', $params) : ''; + $this->executeCommand( + sprintf("RCPT TO:<%s>%s\r\n", $address, $paramStr), [250, 251, 252], $failures, true, $address + ); + } - /** Determine ESMTP capabilities by function group */ - private function getCapabilities($ehloResponse) - { - $capabilities = []; - $ehloResponse = trim($ehloResponse ?? ''); - $lines = explode("\r\n", $ehloResponse); - array_shift($lines); - foreach ($lines as $line) { - if (preg_match('/^[0-9]{3}[ -]([A-Z0-9-]+)((?:[ =].*)?)$/Di', $line, $matches)) { - $keyword = strtoupper($matches[1]); - $paramStr = strtoupper(ltrim($matches[2], ' =')); - $params = !empty($paramStr) ? explode(' ', $paramStr) : []; - $capabilities[$keyword] = $params; - } - } + /** Determine ESMTP capabilities by function group */ + private function getCapabilities($ehloResponse) + { + $capabilities = []; + $ehloResponse = trim($ehloResponse ?? ''); + $lines = explode("\r\n", $ehloResponse); + array_shift($lines); + foreach ($lines as $line) { + if (preg_match('/^[0-9]{3}[ -]([A-Z0-9-]+)((?:[ =].*)?)$/Di', $line, $matches)) { + $keyword = strtoupper($matches[1]); + $paramStr = strtoupper(ltrim($matches[2], ' =')); + $params = !empty($paramStr) ? explode(' ', $paramStr) : []; + $capabilities[$keyword] = $params; + } + } - return $capabilities; - } + return $capabilities; + } - /** Set parameters which are used by each extension handler */ - private function setHandlerParams() - { - foreach ($this->handlers as $keyword => $handler) { - if (\array_key_exists($keyword, $this->capabilities)) { - $handler->setKeywordParams($this->capabilities[$keyword]); - } - } - } + /** Set parameters which are used by each extension handler */ + private function setHandlerParams() + { + foreach ($this->handlers as $keyword => $handler) { + if (\array_key_exists($keyword, $this->capabilities)) { + $handler->setKeywordParams($this->capabilities[$keyword]); + } + } + } - /** Get ESMTP handlers which are currently ok to use */ - private function getActiveHandlers() - { - $handlers = []; - foreach ($this->handlers as $keyword => $handler) { - if (\array_key_exists($keyword, $this->capabilities)) { - $handlers[] = $handler; - } - } + /** Get ESMTP handlers which are currently ok to use */ + private function getActiveHandlers() + { + $handlers = []; + foreach ($this->handlers as $keyword => $handler) { + if (\array_key_exists($keyword, $this->capabilities)) { + $handlers[] = $handler; + } + } - return $handlers; - } + return $handlers; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/FailoverTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/FailoverTransport.php index 1e007b00201..1a4b4754f07 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/FailoverTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/FailoverTransport.php @@ -15,89 +15,89 @@ */ class Swift_Transport_FailoverTransport extends Swift_Transport_LoadBalancedTransport { - /** - * Registered transport currently used. - * - * @var Swift_Transport - */ - private $currentTransport; + /** + * Registered transport currently used. + * + * @var Swift_Transport + */ + private $currentTransport; - // needed as __construct is called from elsewhere explicitly - public function __construct() - { - parent::__construct(); - } + // needed as __construct is called from elsewhere explicitly + public function __construct() + { + parent::__construct(); + } - /** - * {@inheritdoc} - */ - public function ping() - { - $maxTransports = \count($this->transports); - for ($i = 0; $i < $maxTransports - && $transport = $this->getNextTransport(); ++$i) { - if ($transport->ping()) { - return true; - } else { - $this->killCurrentTransport(); - } - } + /** + * {@inheritdoc} + */ + public function ping() + { + $maxTransports = \count($this->transports); + for ($i = 0; $i < $maxTransports + && $transport = $this->getNextTransport(); ++$i) { + if ($transport->ping()) { + return true; + } else { + $this->killCurrentTransport(); + } + } - return \count($this->transports) > 0; - } + return \count($this->transports) > 0; + } - /** - * Send the given Message. - * - * Recipient/sender data will be retrieved from the Message API. - * The return value is the number of recipients who were accepted for delivery. - * - * @param string[] $failedRecipients An array of failures by-reference - * - * @return int - */ - public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) - { - $maxTransports = \count($this->transports); - $sent = 0; - $this->lastUsedTransport = null; + /** + * Send the given Message. + * + * Recipient/sender data will be retrieved from the Message API. + * The return value is the number of recipients who were accepted for delivery. + * + * @param string[] $failedRecipients An array of failures by-reference + * + * @return int + */ + public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) + { + $maxTransports = \count($this->transports); + $sent = 0; + $this->lastUsedTransport = null; - for ($i = 0; $i < $maxTransports - && $transport = $this->getNextTransport(); ++$i) { - try { - if (!$transport->isStarted()) { - $transport->start(); - } + for ($i = 0; $i < $maxTransports + && $transport = $this->getNextTransport(); ++$i) { + try { + if (!$transport->isStarted()) { + $transport->start(); + } - if ($sent = $transport->send($message, $failedRecipients)) { - $this->lastUsedTransport = $transport; + if ($sent = $transport->send($message, $failedRecipients)) { + $this->lastUsedTransport = $transport; - return $sent; - } - } catch (Swift_TransportException $e) { - $this->killCurrentTransport(); - } - } + return $sent; + } + } catch (Swift_TransportException $e) { + $this->killCurrentTransport(); + } + } - if (0 == \count($this->transports)) { - throw new Swift_TransportException('All Transports in FailoverTransport failed, or no Transports available'); - } + if (0 == \count($this->transports)) { + throw new Swift_TransportException('All Transports in FailoverTransport failed, or no Transports available'); + } - return $sent; - } + return $sent; + } - protected function getNextTransport() - { - if (!isset($this->currentTransport)) { - $this->currentTransport = parent::getNextTransport(); - } + protected function getNextTransport() + { + if (!isset($this->currentTransport)) { + $this->currentTransport = parent::getNextTransport(); + } - return $this->currentTransport; - } + return $this->currentTransport; + } - protected function killCurrentTransport() - { - $this->currentTransport = null; - parent::killCurrentTransport(); - } + protected function killCurrentTransport() + { + $this->currentTransport = null; + parent::killCurrentTransport(); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/IoBuffer.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/IoBuffer.php index 799ad8ae085..50f1e5e403c 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/IoBuffer.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/IoBuffer.php @@ -15,51 +15,51 @@ */ interface Swift_Transport_IoBuffer extends Swift_InputByteStream, Swift_OutputByteStream { - /** A socket buffer over TCP */ - const TYPE_SOCKET = 0x0001; + /** A socket buffer over TCP */ + const TYPE_SOCKET = 0x0001; - /** A process buffer with I/O support */ - const TYPE_PROCESS = 0x0010; + /** A process buffer with I/O support */ + const TYPE_PROCESS = 0x0010; - /** - * Perform any initialization needed, using the given $params. - * - * Parameters will vary depending upon the type of IoBuffer used. - */ - public function initialize(array $params); + /** + * Perform any initialization needed, using the given $params. + * + * Parameters will vary depending upon the type of IoBuffer used. + */ + public function initialize(array $params); - /** - * Set an individual param on the buffer (e.g. switching to SSL). - * - * @param string $param - * @param mixed $value - */ - public function setParam($param, $value); + /** + * Set an individual param on the buffer (e.g. switching to SSL). + * + * @param string $param + * @param mixed $value + */ + public function setParam($param, $value); - /** - * Perform any shutdown logic needed. - */ - public function terminate(); + /** + * Perform any shutdown logic needed. + */ + public function terminate(); - /** - * Set an array of string replacements which should be made on data written - * to the buffer. - * - * This could replace LF with CRLF for example. - * - * @param string[] $replacements - */ - public function setWriteTranslations(array $replacements); + /** + * Set an array of string replacements which should be made on data written + * to the buffer. + * + * This could replace LF with CRLF for example. + * + * @param string[] $replacements + */ + public function setWriteTranslations(array $replacements); - /** - * Get a line of output (including any CRLF). - * - * The $sequence number comes from any writes and may or may not be used - * depending upon the implementation. - * - * @param int $sequence of last write to scan from - * - * @return string - */ - public function readLine($sequence); + /** + * Get a line of output (including any CRLF). + * + * The $sequence number comes from any writes and may or may not be used + * depending upon the implementation. + * + * @param int $sequence of last write to scan from + * + * @return string + */ + public function readLine($sequence); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/LoadBalancedTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/LoadBalancedTransport.php index e4262069ffb..0b5ba9d304e 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/LoadBalancedTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/LoadBalancedTransport.php @@ -15,178 +15,178 @@ */ class Swift_Transport_LoadBalancedTransport implements Swift_Transport { - /** - * Transports which are deemed useless. - * - * @var Swift_Transport[] - */ - private $deadTransports = []; + /** + * Transports which are deemed useless. + * + * @var Swift_Transport[] + */ + private $deadTransports = []; - /** - * The Transports which are used in rotation. - * - * @var Swift_Transport[] - */ - protected $transports = []; + /** + * The Transports which are used in rotation. + * + * @var Swift_Transport[] + */ + protected $transports = []; - /** - * The Transport used in the last successful send operation. - * - * @var Swift_Transport - */ - protected $lastUsedTransport = null; + /** + * The Transport used in the last successful send operation. + * + * @var Swift_Transport + */ + protected $lastUsedTransport = null; - // needed as __construct is called from elsewhere explicitly - public function __construct() - { - } + // needed as __construct is called from elsewhere explicitly + public function __construct() + { + } - /** - * Set $transports to delegate to. - * - * @param Swift_Transport[] $transports - */ - public function setTransports(array $transports) - { - $this->transports = $transports; - $this->deadTransports = []; - } + /** + * Set $transports to delegate to. + * + * @param Swift_Transport[] $transports + */ + public function setTransports(array $transports) + { + $this->transports = $transports; + $this->deadTransports = []; + } - /** - * Get $transports to delegate to. - * - * @return Swift_Transport[] - */ - public function getTransports() - { - return array_merge($this->transports, $this->deadTransports); - } + /** + * Get $transports to delegate to. + * + * @return Swift_Transport[] + */ + public function getTransports() + { + return array_merge($this->transports, $this->deadTransports); + } - /** - * Get the Transport used in the last successful send operation. - * - * @return Swift_Transport - */ - public function getLastUsedTransport() - { - return $this->lastUsedTransport; - } + /** + * Get the Transport used in the last successful send operation. + * + * @return Swift_Transport + */ + public function getLastUsedTransport() + { + return $this->lastUsedTransport; + } - /** - * Test if this Transport mechanism has started. - * - * @return bool - */ - public function isStarted() - { - return \count($this->transports) > 0; - } + /** + * Test if this Transport mechanism has started. + * + * @return bool + */ + public function isStarted() + { + return \count($this->transports) > 0; + } - /** - * Start this Transport mechanism. - */ - public function start() - { - $this->transports = array_merge($this->transports, $this->deadTransports); - } + /** + * Start this Transport mechanism. + */ + public function start() + { + $this->transports = array_merge($this->transports, $this->deadTransports); + } - /** - * Stop this Transport mechanism. - */ - public function stop() - { - foreach ($this->transports as $transport) { - $transport->stop(); - } - } + /** + * Stop this Transport mechanism. + */ + public function stop() + { + foreach ($this->transports as $transport) { + $transport->stop(); + } + } - /** - * {@inheritdoc} - */ - public function ping() - { - foreach ($this->transports as $transport) { - if (!$transport->ping()) { - $this->killCurrentTransport(); - } - } + /** + * {@inheritdoc} + */ + public function ping() + { + foreach ($this->transports as $transport) { + if (!$transport->ping()) { + $this->killCurrentTransport(); + } + } - return \count($this->transports) > 0; - } + return \count($this->transports) > 0; + } - /** - * Send the given Message. - * - * Recipient/sender data will be retrieved from the Message API. - * The return value is the number of recipients who were accepted for delivery. - * - * @param string[] $failedRecipients An array of failures by-reference - * - * @return int - */ - public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) - { - $maxTransports = \count($this->transports); - $sent = 0; - $this->lastUsedTransport = null; + /** + * Send the given Message. + * + * Recipient/sender data will be retrieved from the Message API. + * The return value is the number of recipients who were accepted for delivery. + * + * @param string[] $failedRecipients An array of failures by-reference + * + * @return int + */ + public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) + { + $maxTransports = \count($this->transports); + $sent = 0; + $this->lastUsedTransport = null; - for ($i = 0; $i < $maxTransports - && $transport = $this->getNextTransport(); ++$i) { - try { - if (!$transport->isStarted()) { - $transport->start(); - } - if ($sent = $transport->send($message, $failedRecipients)) { - $this->lastUsedTransport = $transport; - break; - } - } catch (Swift_TransportException $e) { - $this->killCurrentTransport(); - } - } + for ($i = 0; $i < $maxTransports + && $transport = $this->getNextTransport(); ++$i) { + try { + if (!$transport->isStarted()) { + $transport->start(); + } + if ($sent = $transport->send($message, $failedRecipients)) { + $this->lastUsedTransport = $transport; + break; + } + } catch (Swift_TransportException $e) { + $this->killCurrentTransport(); + } + } - if (0 == \count($this->transports)) { - throw new Swift_TransportException('All Transports in LoadBalancedTransport failed, or no Transports available'); - } + if (0 == \count($this->transports)) { + throw new Swift_TransportException('All Transports in LoadBalancedTransport failed, or no Transports available'); + } - return $sent; - } + return $sent; + } - /** - * Register a plugin. - */ - public function registerPlugin(Swift_Events_EventListener $plugin) - { - foreach ($this->transports as $transport) { - $transport->registerPlugin($plugin); - } - } + /** + * Register a plugin. + */ + public function registerPlugin(Swift_Events_EventListener $plugin) + { + foreach ($this->transports as $transport) { + $transport->registerPlugin($plugin); + } + } - /** - * Rotates the transport list around and returns the first instance. - * - * @return Swift_Transport - */ - protected function getNextTransport() - { - if ($next = array_shift($this->transports)) { - $this->transports[] = $next; - } + /** + * Rotates the transport list around and returns the first instance. + * + * @return Swift_Transport + */ + protected function getNextTransport() + { + if ($next = array_shift($this->transports)) { + $this->transports[] = $next; + } - return $next; - } + return $next; + } - /** - * Tag the currently used (top of stack) transport as dead/useless. - */ - protected function killCurrentTransport() - { - if ($transport = array_pop($this->transports)) { - try { - $transport->stop(); - } catch (Exception $e) { - } - $this->deadTransports[] = $transport; - } - } + /** + * Tag the currently used (top of stack) transport as dead/useless. + */ + protected function killCurrentTransport() + { + if ($transport = array_pop($this->transports)) { + try { + $transport->stop(); + } catch (Exception $e) { + } + $this->deadTransports[] = $transport; + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/NullTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/NullTransport.php index ec82fced23b..7d910db5a58 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/NullTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/NullTransport.php @@ -15,84 +15,84 @@ */ class Swift_Transport_NullTransport implements Swift_Transport { - /** The event dispatcher from the plugin API */ - private $eventDispatcher; + /** The event dispatcher from the plugin API */ + private $eventDispatcher; - /** - * Constructor. - */ - public function __construct(Swift_Events_EventDispatcher $eventDispatcher) - { - $this->eventDispatcher = $eventDispatcher; - } + /** + * Constructor. + */ + public function __construct(Swift_Events_EventDispatcher $eventDispatcher) + { + $this->eventDispatcher = $eventDispatcher; + } - /** - * Tests if this Transport mechanism has started. - * - * @return bool - */ - public function isStarted() - { - return true; - } + /** + * Tests if this Transport mechanism has started. + * + * @return bool + */ + public function isStarted() + { + return true; + } - /** - * Starts this Transport mechanism. - */ - public function start() - { - } + /** + * Starts this Transport mechanism. + */ + public function start() + { + } - /** - * Stops this Transport mechanism. - */ - public function stop() - { - } + /** + * Stops this Transport mechanism. + */ + public function stop() + { + } - /** - * {@inheritdoc} - */ - public function ping() - { - return true; - } + /** + * {@inheritdoc} + */ + public function ping() + { + return true; + } - /** - * Sends the given message. - * - * @param string[] $failedRecipients An array of failures by-reference - * - * @return int The number of sent emails - */ - public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) - { - if ($evt = $this->eventDispatcher->createSendEvent($this, $message)) { - $this->eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); - if ($evt->bubbleCancelled()) { - return 0; - } - } + /** + * Sends the given message. + * + * @param string[] $failedRecipients An array of failures by-reference + * + * @return int The number of sent emails + */ + public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) + { + if ($evt = $this->eventDispatcher->createSendEvent($this, $message)) { + $this->eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); + if ($evt->bubbleCancelled()) { + return 0; + } + } - if ($evt) { - $evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS); - $this->eventDispatcher->dispatchEvent($evt, 'sendPerformed'); - } + if ($evt) { + $evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS); + $this->eventDispatcher->dispatchEvent($evt, 'sendPerformed'); + } - $count = ( - \count((array) $message->getTo()) - + \count((array) $message->getCc()) - + \count((array) $message->getBcc()) - ); + $count = ( + \count((array) $message->getTo()) + + \count((array) $message->getCc()) + + \count((array) $message->getBcc()) + ); - return $count; - } + return $count; + } - /** - * Register a plugin. - */ - public function registerPlugin(Swift_Events_EventListener $plugin) - { - $this->eventDispatcher->bindEventListener($plugin); - } + /** + * Register a plugin. + */ + public function registerPlugin(Swift_Events_EventListener $plugin) + { + $this->eventDispatcher->bindEventListener($plugin); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php index e1723b24f10..65a434d1173 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php @@ -19,139 +19,140 @@ */ class Swift_Transport_SendmailTransport extends Swift_Transport_AbstractSmtpTransport { - /** - * Connection buffer parameters. - * - * @var array - */ - private $params = [ - 'timeout' => 30, - 'blocking' => 1, - 'command' => '/usr/sbin/sendmail -bs', - 'type' => Swift_Transport_IoBuffer::TYPE_PROCESS, - ]; + /** + * Connection buffer parameters. + * + * @var array + */ + private $params = [ + 'timeout' => 30, + 'blocking' => 1, + 'command' => '/usr/sbin/sendmail -bs', + 'type' => Swift_Transport_IoBuffer::TYPE_PROCESS, + ]; - /** - * Create a new SendmailTransport with $buf for I/O. - * - * @param string $localDomain - */ - public function __construct(Swift_Transport_IoBuffer $buf, Swift_Events_EventDispatcher $dispatcher, $localDomain = '127.0.0.1', Swift_AddressEncoder $addressEncoder = null) - { - parent::__construct($buf, $dispatcher, $localDomain, $addressEncoder); - } + /** + * Create a new SendmailTransport with $buf for I/O. + * + * @param string $localDomain + */ + public function __construct(Swift_Transport_IoBuffer $buf, Swift_Events_EventDispatcher $dispatcher, $localDomain = '127.0.0.1', Swift_AddressEncoder $addressEncoder = null) + { + parent::__construct($buf, $dispatcher, $localDomain, $addressEncoder); + } - /** - * Start the standalone SMTP session if running in -bs mode. - */ - public function start() - { - if (false !== strpos($this->getCommand(), ' -bs')) { - parent::start(); - } - } + /** + * Start the standalone SMTP session if running in -bs mode. + */ + public function start() + { + if (false !== strpos($this->getCommand(), ' -bs')) { + parent::start(); + } + } - /** - * Set the command to invoke. - * - * If using -t mode you are strongly advised to include -oi or -i in the flags. - * For example: /usr/sbin/sendmail -oi -t - * Swift will append a -f flag if one is not present. - * - * The recommended mode is "-bs" since it is interactive and failure notifications - * are hence possible. - * - * @param string $command - * - * @return $this - */ - public function setCommand($command) - { - $this->params['command'] = $command; + /** + * Set the command to invoke. + * + * If using -t mode you are strongly advised to include -oi or -i in the flags. + * For example: /usr/sbin/sendmail -oi -t + * Swift will append a -f flag if one is not present. + * + * The recommended mode is "-bs" since it is interactive and failure notifications + * are hence possible. + * + * @param string $command + * + * @return $this + */ + public function setCommand($command) + { + $this->params['command'] = $command; - return $this; - } + return $this; + } - /** - * Get the sendmail command which will be invoked. - * - * @return string - */ - public function getCommand() - { - return $this->params['command']; - } + /** + * Get the sendmail command which will be invoked. + * + * @return string + */ + public function getCommand() + { + return $this->params['command']; + } - /** - * Send the given Message. - * - * Recipient/sender data will be retrieved from the Message API. - * - * The return value is the number of recipients who were accepted for delivery. - * NOTE: If using 'sendmail -t' you will not be aware of any failures until - * they bounce (i.e. send() will always return 100% success). - * - * @param string[] $failedRecipients An array of failures by-reference - * - * @return int - */ - public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) - { - $failedRecipients = (array) $failedRecipients; - $command = $this->getCommand(); - $buffer = $this->getBuffer(); - $count = 0; + /** + * Send the given Message. + * + * Recipient/sender data will be retrieved from the Message API. + * + * The return value is the number of recipients who were accepted for delivery. + * NOTE: If using 'sendmail -t' you will not be aware of any failures until + * they bounce (i.e. send() will always return 100% success). + * + * @param string[] $failedRecipients An array of failures by-reference + * + * @return int + */ + public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) + { + $failedRecipients = (array) $failedRecipients; + $command = $this->getCommand(); + $buffer = $this->getBuffer(); + $count = 0; - if (false !== strpos($command, ' -t')) { - if ($evt = $this->eventDispatcher->createSendEvent($this, $message)) { - $this->eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); - if ($evt->bubbleCancelled()) { - return 0; - } - } + if (false !== strpos($command, ' -t')) { + if ($evt = $this->eventDispatcher->createSendEvent($this, $message)) { + $this->eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); + if ($evt->bubbleCancelled()) { + return 0; + } + } - if (false === strpos($command, ' -f')) { - $command .= ' -f'.escapeshellarg($this->getReversePath($message) ?? ''); - } + if (false === strpos($command, ' -f')) { + $command .= ' -f'.escapeshellarg($this->getReversePath($message) ?? ''); + } - $buffer->initialize(array_merge($this->params, ['command' => $command])); + $buffer->initialize(array_merge($this->params, ['command' => $command])); - if (false === strpos($command, ' -i') && false === strpos($command, ' -oi')) { - $buffer->setWriteTranslations(["\r\n" => "\n", "\n." => "\n.."]); - } else { - $buffer->setWriteTranslations(["\r\n" => "\n"]); - } + if (false === strpos($command, ' -i') && false === strpos($command, ' -oi')) { + $buffer->setWriteTranslations(["\r\n" => "\n", "\n." => "\n.."]); + } else { + $buffer->setWriteTranslations(["\r\n" => "\n"]); + } - $count = \count((array) $message->getTo()) - + \count((array) $message->getCc()) - + \count((array) $message->getBcc()); - $message->toByteStream($buffer); - $buffer->flushBuffers(); - $buffer->setWriteTranslations([]); - $buffer->terminate(); + $count = \count((array) $message->getTo()) + + \count((array) $message->getCc()) + + \count((array) $message->getBcc()) + ; + $message->toByteStream($buffer); + $buffer->flushBuffers(); + $buffer->setWriteTranslations([]); + $buffer->terminate(); - if ($evt) { - $evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS); - $evt->setFailedRecipients($failedRecipients); - $this->eventDispatcher->dispatchEvent($evt, 'sendPerformed'); - } + if ($evt) { + $evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS); + $evt->setFailedRecipients($failedRecipients); + $this->eventDispatcher->dispatchEvent($evt, 'sendPerformed'); + } - $message->generateId(); - } elseif (false !== strpos($command, ' -bs')) { - $count = parent::send($message, $failedRecipients); - } else { - $this->throwException(new Swift_TransportException( - 'Unsupported sendmail command flags ['.$command.']. '. - 'Must be one of "-bs" or "-t" but can include additional flags.' - )); - } + $message->generateId(); + } elseif (false !== strpos($command, ' -bs')) { + $count = parent::send($message, $failedRecipients); + } else { + $this->throwException(new Swift_TransportException( + 'Unsupported sendmail command flags ['.$command.']. '. + 'Must be one of "-bs" or "-t" but can include additional flags.' + )); + } - return $count; - } + return $count; + } - /** Get the params to initialize the buffer */ - protected function getBufferParams() - { - return $this->params; - } + /** Get the params to initialize the buffer */ + protected function getBufferParams() + { + return $this->params; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/SmtpAgent.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/SmtpAgent.php index bb761237b1c..e8ce65c2648 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/SmtpAgent.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/SmtpAgent.php @@ -15,22 +15,22 @@ */ interface Swift_Transport_SmtpAgent { - /** - * Get the IoBuffer where read/writes are occurring. - * - * @return Swift_Transport_IoBuffer - */ - public function getBuffer(); + /** + * Get the IoBuffer where read/writes are occurring. + * + * @return Swift_Transport_IoBuffer + */ + public function getBuffer(); - /** - * Run a command against the buffer, expecting the given response codes. - * - * If no response codes are given, the response will not be validated. - * If codes are given, an exception will be thrown on an invalid response. - * - * @param string $command - * @param int[] $codes - * @param string[] $failures An array of failures by-reference - */ - public function executeCommand($command, $codes = [], &$failures = null); + /** + * Run a command against the buffer, expecting the given response codes. + * + * If no response codes are given, the response will not be validated. + * If codes are given, an exception will be thrown on an invalid response. + * + * @param string $command + * @param int[] $codes + * @param string[] $failures An array of failures by-reference + */ + public function executeCommand($command, $codes = [], &$failures = null); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/SpoolTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/SpoolTransport.php index f7c19d05579..0cb6a5b80a9 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/SpoolTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/SpoolTransport.php @@ -15,106 +15,106 @@ */ class Swift_Transport_SpoolTransport implements Swift_Transport { - /** The spool instance */ - private $spool; + /** The spool instance */ + private $spool; - /** The event dispatcher from the plugin API */ - private $eventDispatcher; + /** The event dispatcher from the plugin API */ + private $eventDispatcher; - /** - * Constructor. - */ - public function __construct(Swift_Events_EventDispatcher $eventDispatcher, Swift_Spool $spool = null) - { - $this->eventDispatcher = $eventDispatcher; - $this->spool = $spool; - } + /** + * Constructor. + */ + public function __construct(Swift_Events_EventDispatcher $eventDispatcher, Swift_Spool $spool = null) + { + $this->eventDispatcher = $eventDispatcher; + $this->spool = $spool; + } - /** - * Sets the spool object. - * - * @return $this - */ - public function setSpool(Swift_Spool $spool) - { - $this->spool = $spool; + /** + * Sets the spool object. + * + * @return $this + */ + public function setSpool(Swift_Spool $spool) + { + $this->spool = $spool; - return $this; - } + return $this; + } - /** - * Get the spool object. - * - * @return Swift_Spool - */ - public function getSpool() - { - return $this->spool; - } + /** + * Get the spool object. + * + * @return Swift_Spool + */ + public function getSpool() + { + return $this->spool; + } - /** - * Tests if this Transport mechanism has started. - * - * @return bool - */ - public function isStarted() - { - return true; - } + /** + * Tests if this Transport mechanism has started. + * + * @return bool + */ + public function isStarted() + { + return true; + } - /** - * Starts this Transport mechanism. - */ - public function start() - { - } + /** + * Starts this Transport mechanism. + */ + public function start() + { + } - /** - * Stops this Transport mechanism. - */ - public function stop() - { - } + /** + * Stops this Transport mechanism. + */ + public function stop() + { + } - /** - * {@inheritdoc} - */ - public function ping() - { - return true; - } + /** + * {@inheritdoc} + */ + public function ping() + { + return true; + } - /** - * Sends the given message. - * - * @param string[] $failedRecipients An array of failures by-reference - * - * @return int The number of sent e-mail's - */ - public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) - { - if ($evt = $this->eventDispatcher->createSendEvent($this, $message)) { - $this->eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); - if ($evt->bubbleCancelled()) { - return 0; - } - } + /** + * Sends the given message. + * + * @param string[] $failedRecipients An array of failures by-reference + * + * @return int The number of sent e-mail's + */ + public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) + { + if ($evt = $this->eventDispatcher->createSendEvent($this, $message)) { + $this->eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); + if ($evt->bubbleCancelled()) { + return 0; + } + } - $success = $this->spool->queueMessage($message); + $success = $this->spool->queueMessage($message); - if ($evt) { - $evt->setResult($success ? Swift_Events_SendEvent::RESULT_SPOOLED : Swift_Events_SendEvent::RESULT_FAILED); - $this->eventDispatcher->dispatchEvent($evt, 'sendPerformed'); - } + if ($evt) { + $evt->setResult($success ? Swift_Events_SendEvent::RESULT_SPOOLED : Swift_Events_SendEvent::RESULT_FAILED); + $this->eventDispatcher->dispatchEvent($evt, 'sendPerformed'); + } - return 1; - } + return 1; + } - /** - * Register a plugin. - */ - public function registerPlugin(Swift_Events_EventListener $plugin) - { - $this->eventDispatcher->bindEventListener($plugin); - } + /** + * Register a plugin. + */ + public function registerPlugin(Swift_Events_EventListener $plugin) + { + $this->eventDispatcher->bindEventListener($plugin); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php index 6a09db7938f..70782ada044 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php @@ -15,305 +15,305 @@ */ class Swift_Transport_StreamBuffer extends Swift_ByteStream_AbstractFilterableInputStream implements Swift_Transport_IoBuffer { - /** A primary socket */ - private $stream; + /** A primary socket */ + private $stream; - /** The input stream */ - private $in; + /** The input stream */ + private $in; - /** The output stream */ - private $out; + /** The output stream */ + private $out; - /** Buffer initialization parameters */ - private $params = []; + /** Buffer initialization parameters */ + private $params = []; - /** The ReplacementFilterFactory */ - private $replacementFactory; + /** The ReplacementFilterFactory */ + private $replacementFactory; - /** Translations performed on data being streamed into the buffer */ - private $translations = []; + /** Translations performed on data being streamed into the buffer */ + private $translations = []; - /** - * Create a new StreamBuffer using $replacementFactory for transformations. - */ - public function __construct(Swift_ReplacementFilterFactory $replacementFactory) - { - $this->replacementFactory = $replacementFactory; - } + /** + * Create a new StreamBuffer using $replacementFactory for transformations. + */ + public function __construct(Swift_ReplacementFilterFactory $replacementFactory) + { + $this->replacementFactory = $replacementFactory; + } - /** - * Perform any initialization needed, using the given $params. - * - * Parameters will vary depending upon the type of IoBuffer used. - */ - public function initialize(array $params) - { - $this->params = $params; - switch ($params['type']) { - case self::TYPE_PROCESS: - $this->establishProcessConnection(); - break; - case self::TYPE_SOCKET: - default: - $this->establishSocketConnection(); - break; - } - } + /** + * Perform any initialization needed, using the given $params. + * + * Parameters will vary depending upon the type of IoBuffer used. + */ + public function initialize(array $params) + { + $this->params = $params; + switch ($params['type']) { + case self::TYPE_PROCESS: + $this->establishProcessConnection(); + break; + case self::TYPE_SOCKET: + default: + $this->establishSocketConnection(); + break; + } + } - /** - * Set an individual param on the buffer (e.g. switching to SSL). - * - * @param string $param - * @param mixed $value - */ - public function setParam($param, $value) - { - if (isset($this->stream)) { - switch ($param) { - case 'timeout': - if ($this->stream) { - stream_set_timeout($this->stream, $value); - } - break; + /** + * Set an individual param on the buffer (e.g. switching to SSL). + * + * @param string $param + * @param mixed $value + */ + public function setParam($param, $value) + { + if (isset($this->stream)) { + switch ($param) { + case 'timeout': + if ($this->stream) { + stream_set_timeout($this->stream, $value); + } + break; - case 'blocking': - if ($this->stream) { - stream_set_blocking($this->stream, 1); - } - } - } - $this->params[$param] = $value; - } + case 'blocking': + if ($this->stream) { + stream_set_blocking($this->stream, 1); + } + } + } + $this->params[$param] = $value; + } - public function startTLS() - { - // STREAM_CRYPTO_METHOD_TLS_CLIENT only allow tls1.0 connections (some php versions) - // To support modern tls we allow explicit tls1.0, tls1.1, tls1.2 - // Ssl3 and older are not allowed because they are vulnerable - // @TODO make tls arguments configurable - return stream_socket_enable_crypto($this->stream, true, STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT); - } + public function startTLS() + { + // STREAM_CRYPTO_METHOD_TLS_CLIENT only allow tls1.0 connections (some php versions) + // To support modern tls we allow explicit tls1.0, tls1.1, tls1.2 + // Ssl3 and older are not allowed because they are vulnerable + // @TODO make tls arguments configurable + return stream_socket_enable_crypto($this->stream, true, STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT); + } - /** - * Perform any shutdown logic needed. - */ - public function terminate() - { - if (isset($this->stream)) { - switch ($this->params['type']) { - case self::TYPE_PROCESS: - fclose($this->in); - fclose($this->out); - proc_close($this->stream); - break; - case self::TYPE_SOCKET: - default: - fclose($this->stream); - break; - } - } - $this->stream = null; - $this->out = null; - $this->in = null; - } + /** + * Perform any shutdown logic needed. + */ + public function terminate() + { + if (isset($this->stream)) { + switch ($this->params['type']) { + case self::TYPE_PROCESS: + fclose($this->in); + fclose($this->out); + proc_close($this->stream); + break; + case self::TYPE_SOCKET: + default: + fclose($this->stream); + break; + } + } + $this->stream = null; + $this->out = null; + $this->in = null; + } - /** - * Set an array of string replacements which should be made on data written - * to the buffer. - * - * This could replace LF with CRLF for example. - * - * @param string[] $replacements - */ - public function setWriteTranslations(array $replacements) - { - foreach ($this->translations as $search => $replace) { - if (!isset($replacements[$search])) { - $this->removeFilter($search); - unset($this->translations[$search]); - } - } + /** + * Set an array of string replacements which should be made on data written + * to the buffer. + * + * This could replace LF with CRLF for example. + * + * @param string[] $replacements + */ + public function setWriteTranslations(array $replacements) + { + foreach ($this->translations as $search => $replace) { + if (!isset($replacements[$search])) { + $this->removeFilter($search); + unset($this->translations[$search]); + } + } - foreach ($replacements as $search => $replace) { - if (!isset($this->translations[$search])) { - $this->addFilter( - $this->replacementFactory->createFilter($search, $replace), $search - ); - $this->translations[$search] = true; - } - } - } + foreach ($replacements as $search => $replace) { + if (!isset($this->translations[$search])) { + $this->addFilter( + $this->replacementFactory->createFilter($search, $replace), $search + ); + $this->translations[$search] = true; + } + } + } - /** - * Get a line of output (including any CRLF). - * - * The $sequence number comes from any writes and may or may not be used - * depending upon the implementation. - * - * @param int $sequence of last write to scan from - * - * @return string - * - * @throws Swift_IoException - */ - public function readLine($sequence) - { - if (isset($this->out) && !feof($this->out)) { - $line = fgets($this->out); - if (0 == \strlen($line)) { - $metas = stream_get_meta_data($this->out); - if ($metas['timed_out']) { - throw new Swift_IoException('Connection to '.$this->getReadConnectionDescription().' Timed Out'); - } - } + /** + * Get a line of output (including any CRLF). + * + * The $sequence number comes from any writes and may or may not be used + * depending upon the implementation. + * + * @param int $sequence of last write to scan from + * + * @return string + * + * @throws Swift_IoException + */ + public function readLine($sequence) + { + if (isset($this->out) && !feof($this->out)) { + $line = fgets($this->out); + if (0 == \strlen($line)) { + $metas = stream_get_meta_data($this->out); + if ($metas['timed_out']) { + throw new Swift_IoException('Connection to '.$this->getReadConnectionDescription().' Timed Out'); + } + } - return $line; - } - } + return $line; + } + } - /** - * Reads $length bytes from the stream into a string and moves the pointer - * through the stream by $length. - * - * If less bytes exist than are requested the remaining bytes are given instead. - * If no bytes are remaining at all, boolean false is returned. - * - * @param int $length - * - * @return string|bool - * - * @throws Swift_IoException - */ - public function read($length) - { - if (isset($this->out) && !feof($this->out)) { - $ret = fread($this->out, $length); - if (0 == \strlen($ret)) { - $metas = stream_get_meta_data($this->out); - if ($metas['timed_out']) { - throw new Swift_IoException('Connection to '.$this->getReadConnectionDescription().' Timed Out'); - } - } + /** + * Reads $length bytes from the stream into a string and moves the pointer + * through the stream by $length. + * + * If less bytes exist than are requested the remaining bytes are given instead. + * If no bytes are remaining at all, boolean false is returned. + * + * @param int $length + * + * @return string|bool + * + * @throws Swift_IoException + */ + public function read($length) + { + if (isset($this->out) && !feof($this->out)) { + $ret = fread($this->out, $length); + if (0 == \strlen($ret)) { + $metas = stream_get_meta_data($this->out); + if ($metas['timed_out']) { + throw new Swift_IoException('Connection to '.$this->getReadConnectionDescription().' Timed Out'); + } + } - return $ret; - } - } + return $ret; + } + } - /** Not implemented */ - public function setReadPointer($byteOffset) - { - } + /** Not implemented */ + public function setReadPointer($byteOffset) + { + } - /** Flush the stream contents */ - protected function flush() - { - if (isset($this->in)) { - fflush($this->in); - } - } + /** Flush the stream contents */ + protected function flush() + { + if (isset($this->in)) { + fflush($this->in); + } + } - /** Write this bytes to the stream */ - protected function doCommit($bytes) - { - if (isset($this->in)) { - $bytesToWrite = \strlen($bytes); - $totalBytesWritten = 0; + /** Write this bytes to the stream */ + protected function doCommit($bytes) + { + if (isset($this->in)) { + $bytesToWrite = \strlen($bytes); + $totalBytesWritten = 0; - while ($totalBytesWritten < $bytesToWrite) { - $bytesWritten = fwrite($this->in, substr($bytes, $totalBytesWritten)); - if (false === $bytesWritten || 0 === $bytesWritten) { - break; - } + while ($totalBytesWritten < $bytesToWrite) { + $bytesWritten = fwrite($this->in, substr($bytes, $totalBytesWritten)); + if (false === $bytesWritten || 0 === $bytesWritten) { + break; + } - $totalBytesWritten += $bytesWritten; - } + $totalBytesWritten += $bytesWritten; + } - if ($totalBytesWritten > 0) { - return ++$this->sequence; - } - } - } + if ($totalBytesWritten > 0) { + return ++$this->sequence; + } + } + } - /** - * Establishes a connection to a remote server. - */ - private function establishSocketConnection() - { - $host = $this->params['host']; - if (!empty($this->params['protocol'])) { - $host = $this->params['protocol'].'://'.$host; - } - $timeout = 15; - if (!empty($this->params['timeout'])) { - $timeout = $this->params['timeout']; - } - $options = []; - if (!empty($this->params['sourceIp'])) { - $options['socket']['bindto'] = $this->params['sourceIp'].':0'; - } + /** + * Establishes a connection to a remote server. + */ + private function establishSocketConnection() + { + $host = $this->params['host']; + if (!empty($this->params['protocol'])) { + $host = $this->params['protocol'].'://'.$host; + } + $timeout = 15; + if (!empty($this->params['timeout'])) { + $timeout = $this->params['timeout']; + } + $options = []; + if (!empty($this->params['sourceIp'])) { + $options['socket']['bindto'] = $this->params['sourceIp'].':0'; + } - if (isset($this->params['stream_context_options'])) { - $options = array_merge($options, $this->params['stream_context_options']); - } - $streamContext = stream_context_create($options); + if (isset($this->params['stream_context_options'])) { + $options = array_merge($options, $this->params['stream_context_options']); + } + $streamContext = stream_context_create($options); - set_error_handler(function ($type, $msg) { - throw new Swift_TransportException('Connection could not be established with host '.$this->params['host'].' :'.$msg); - }); - try { - $this->stream = stream_socket_client($host.':'.$this->params['port'], $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $streamContext); - } finally { - restore_error_handler(); - } + set_error_handler(function ($type, $msg) { + throw new Swift_TransportException('Connection could not be established with host '.$this->params['host'].' :'.$msg); + }); + try { + $this->stream = stream_socket_client($host.':'.$this->params['port'], $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $streamContext); + } finally { + restore_error_handler(); + } - if (!empty($this->params['blocking'])) { - stream_set_blocking($this->stream, 1); - } else { - stream_set_blocking($this->stream, 0); - } - stream_set_timeout($this->stream, $timeout); - $this->in = &$this->stream; - $this->out = &$this->stream; - } + if (!empty($this->params['blocking'])) { + stream_set_blocking($this->stream, 1); + } else { + stream_set_blocking($this->stream, 0); + } + stream_set_timeout($this->stream, $timeout); + $this->in = &$this->stream; + $this->out = &$this->stream; + } - /** - * Opens a process for input/output. - */ - private function establishProcessConnection() - { - $command = $this->params['command']; - $descriptorSpec = [ - 0 => ['pipe', 'r'], - 1 => ['pipe', 'w'], - 2 => ['pipe', 'w'], - ]; - $pipes = []; - $this->stream = proc_open($command, $descriptorSpec, $pipes); - stream_set_blocking($pipes[2], 0); - if ($err = stream_get_contents($pipes[2])) { - throw new Swift_TransportException('Process could not be started ['.$err.']'); - } - $this->in = &$pipes[0]; - $this->out = &$pipes[1]; - } + /** + * Opens a process for input/output. + */ + private function establishProcessConnection() + { + $command = $this->params['command']; + $descriptorSpec = [ + 0 => ['pipe', 'r'], + 1 => ['pipe', 'w'], + 2 => ['pipe', 'w'], + ]; + $pipes = []; + $this->stream = proc_open($command, $descriptorSpec, $pipes); + stream_set_blocking($pipes[2], 0); + if ($err = stream_get_contents($pipes[2])) { + throw new Swift_TransportException('Process could not be started ['.$err.']'); + } + $this->in = &$pipes[0]; + $this->out = &$pipes[1]; + } - private function getReadConnectionDescription() - { - switch ($this->params['type']) { - case self::TYPE_PROCESS: - return 'Process '.$this->params['command']; - break; + private function getReadConnectionDescription() + { + switch ($this->params['type']) { + case self::TYPE_PROCESS: + return 'Process '.$this->params['command']; + break; - case self::TYPE_SOCKET: - default: - $host = $this->params['host']; - if (!empty($this->params['protocol'])) { - $host = $this->params['protocol'].'://'.$host; - } - $host .= ':'.$this->params['port']; + case self::TYPE_SOCKET: + default: + $host = $this->params['host']; + if (!empty($this->params['protocol'])) { + $host = $this->params['protocol'].'://'.$host; + } + $host .= ':'.$this->params['port']; - return $host; - break; - } - } + return $host; + break; + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/TransportException.php b/htdocs/includes/swiftmailer/lib/classes/Swift/TransportException.php index 763c9fed2ee..c7417455b3e 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/TransportException.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/TransportException.php @@ -15,14 +15,14 @@ */ class Swift_TransportException extends Swift_IoException { - /** - * Create a new TransportException with $message. - * - * @param string $message - * @param int $code - */ - public function __construct($message, $code = 0, Exception $previous = null) - { - parent::__construct($message, $code, $previous); - } + /** + * Create a new TransportException with $message. + * + * @param string $message + * @param int $code + */ + public function __construct($message, $code = 0, Exception $previous = null) + { + parent::__construct($message, $code, $previous); + } } diff --git a/htdocs/includes/swiftmailer/lib/dependency_maps/cache_deps.php b/htdocs/includes/swiftmailer/lib/dependency_maps/cache_deps.php index c2f2df20bc3..9d94d774014 100644 --- a/htdocs/includes/swiftmailer/lib/dependency_maps/cache_deps.php +++ b/htdocs/includes/swiftmailer/lib/dependency_maps/cache_deps.php @@ -1,22 +1,23 @@ register('cache') - ->asAliasOf('cache.array') + ->register('cache') + ->asAliasOf('cache.array') - ->register('tempdir') - ->asValue('/tmp') + ->register('tempdir') + ->asValue('/tmp') - ->register('cache.null') - ->asSharedInstanceOf('Swift_KeyCache_NullKeyCache') + ->register('cache.null') + ->asSharedInstanceOf('Swift_KeyCache_NullKeyCache') - ->register('cache.array') - ->asSharedInstanceOf('Swift_KeyCache_ArrayKeyCache') - ->withDependencies(['cache.inputstream']) + ->register('cache.array') + ->asSharedInstanceOf('Swift_KeyCache_ArrayKeyCache') + ->withDependencies(['cache.inputstream']) - ->register('cache.disk') - ->asSharedInstanceOf('Swift_KeyCache_DiskKeyCache') - ->withDependencies(['cache.inputstream', 'tempdir']) + ->register('cache.disk') + ->asSharedInstanceOf('Swift_KeyCache_DiskKeyCache') + ->withDependencies(['cache.inputstream', 'tempdir']) - ->register('cache.inputstream') - ->asNewInstanceOf('Swift_KeyCache_SimpleKeyCacheInputStream'); + ->register('cache.inputstream') + ->asNewInstanceOf('Swift_KeyCache_SimpleKeyCacheInputStream') +; diff --git a/htdocs/includes/swiftmailer/lib/dependency_maps/mime_deps.php b/htdocs/includes/swiftmailer/lib/dependency_maps/mime_deps.php index 3ee1b762ebe..307756c89f3 100644 --- a/htdocs/includes/swiftmailer/lib/dependency_maps/mime_deps.php +++ b/htdocs/includes/swiftmailer/lib/dependency_maps/mime_deps.php @@ -3,131 +3,132 @@ require __DIR__.'/../mime_types.php'; Swift_DependencyContainer::getInstance() - ->register('properties.charset') - ->asValue('utf-8') + ->register('properties.charset') + ->asValue('utf-8') - ->register('email.validator') - ->asSharedInstanceOf('Egulias\EmailValidator\EmailValidator') + ->register('email.validator') + ->asSharedInstanceOf('Egulias\EmailValidator\EmailValidator') - ->register('mime.idgenerator.idright') - // As SERVER_NAME can come from the user in certain configurations, check that - // it does not contain forbidden characters (see RFC 952 and RFC 2181). Use - // preg_replace() instead of preg_match() to prevent DoS attacks with long host names. - ->asValue(!empty($_SERVER['SERVER_NAME']) && '' === preg_replace('/(?:^\[)?[a-zA-Z0-9-:\]_]+\.?/', '', $_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'swift.generated') + ->register('mime.idgenerator.idright') + // As SERVER_NAME can come from the user in certain configurations, check that + // it does not contain forbidden characters (see RFC 952 and RFC 2181). Use + // preg_replace() instead of preg_match() to prevent DoS attacks with long host names. + ->asValue(!empty($_SERVER['SERVER_NAME']) && '' === preg_replace('/(?:^\[)?[a-zA-Z0-9-:\]_]+\.?/', '', $_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'swift.generated') - ->register('mime.idgenerator') - ->asSharedInstanceOf('Swift_Mime_IdGenerator') - ->withDependencies([ - 'mime.idgenerator.idright', - ]) + ->register('mime.idgenerator') + ->asSharedInstanceOf('Swift_Mime_IdGenerator') + ->withDependencies([ + 'mime.idgenerator.idright', + ]) - ->register('mime.message') - ->asNewInstanceOf('Swift_Mime_SimpleMessage') - ->withDependencies([ - 'mime.headerset', - 'mime.textcontentencoder', - 'cache', - 'mime.idgenerator', - 'properties.charset', - ]) + ->register('mime.message') + ->asNewInstanceOf('Swift_Mime_SimpleMessage') + ->withDependencies([ + 'mime.headerset', + 'mime.textcontentencoder', + 'cache', + 'mime.idgenerator', + 'properties.charset', + ]) - ->register('mime.part') - ->asNewInstanceOf('Swift_Mime_MimePart') - ->withDependencies([ - 'mime.headerset', - 'mime.textcontentencoder', - 'cache', - 'mime.idgenerator', - 'properties.charset', - ]) + ->register('mime.part') + ->asNewInstanceOf('Swift_Mime_MimePart') + ->withDependencies([ + 'mime.headerset', + 'mime.textcontentencoder', + 'cache', + 'mime.idgenerator', + 'properties.charset', + ]) - ->register('mime.attachment') - ->asNewInstanceOf('Swift_Mime_Attachment') - ->withDependencies([ - 'mime.headerset', - 'mime.base64contentencoder', - 'cache', - 'mime.idgenerator', - ]) - ->addConstructorValue($swift_mime_types) + ->register('mime.attachment') + ->asNewInstanceOf('Swift_Mime_Attachment') + ->withDependencies([ + 'mime.headerset', + 'mime.base64contentencoder', + 'cache', + 'mime.idgenerator', + ]) + ->addConstructorValue($swift_mime_types) - ->register('mime.embeddedfile') - ->asNewInstanceOf('Swift_Mime_EmbeddedFile') - ->withDependencies([ - 'mime.headerset', - 'mime.base64contentencoder', - 'cache', - 'mime.idgenerator', - ]) - ->addConstructorValue($swift_mime_types) + ->register('mime.embeddedfile') + ->asNewInstanceOf('Swift_Mime_EmbeddedFile') + ->withDependencies([ + 'mime.headerset', + 'mime.base64contentencoder', + 'cache', + 'mime.idgenerator', + ]) + ->addConstructorValue($swift_mime_types) - ->register('mime.headerfactory') - ->asNewInstanceOf('Swift_Mime_SimpleHeaderFactory') - ->withDependencies([ - 'mime.qpheaderencoder', - 'mime.rfc2231encoder', - 'email.validator', - 'properties.charset', - 'address.idnaddressencoder', - ]) + ->register('mime.headerfactory') + ->asNewInstanceOf('Swift_Mime_SimpleHeaderFactory') + ->withDependencies([ + 'mime.qpheaderencoder', + 'mime.rfc2231encoder', + 'email.validator', + 'properties.charset', + 'address.idnaddressencoder', + ]) - ->register('mime.headerset') - ->asNewInstanceOf('Swift_Mime_SimpleHeaderSet') - ->withDependencies(['mime.headerfactory', 'properties.charset']) + ->register('mime.headerset') + ->asNewInstanceOf('Swift_Mime_SimpleHeaderSet') + ->withDependencies(['mime.headerfactory', 'properties.charset']) - ->register('mime.qpheaderencoder') - ->asNewInstanceOf('Swift_Mime_HeaderEncoder_QpHeaderEncoder') - ->withDependencies(['mime.charstream']) + ->register('mime.qpheaderencoder') + ->asNewInstanceOf('Swift_Mime_HeaderEncoder_QpHeaderEncoder') + ->withDependencies(['mime.charstream']) - ->register('mime.base64headerencoder') - ->asNewInstanceOf('Swift_Mime_HeaderEncoder_Base64HeaderEncoder') - ->withDependencies(['mime.charstream']) + ->register('mime.base64headerencoder') + ->asNewInstanceOf('Swift_Mime_HeaderEncoder_Base64HeaderEncoder') + ->withDependencies(['mime.charstream']) - ->register('mime.charstream') - ->asNewInstanceOf('Swift_CharacterStream_NgCharacterStream') - ->withDependencies(['mime.characterreaderfactory', 'properties.charset']) + ->register('mime.charstream') + ->asNewInstanceOf('Swift_CharacterStream_NgCharacterStream') + ->withDependencies(['mime.characterreaderfactory', 'properties.charset']) - ->register('mime.bytecanonicalizer') - ->asSharedInstanceOf('Swift_StreamFilters_ByteArrayReplacementFilter') - ->addConstructorValue([[0x0D, 0x0A], [0x0D], [0x0A]]) - ->addConstructorValue([[0x0A], [0x0A], [0x0D, 0x0A]]) + ->register('mime.bytecanonicalizer') + ->asSharedInstanceOf('Swift_StreamFilters_ByteArrayReplacementFilter') + ->addConstructorValue([[0x0D, 0x0A], [0x0D], [0x0A]]) + ->addConstructorValue([[0x0A], [0x0A], [0x0D, 0x0A]]) - ->register('mime.characterreaderfactory') - ->asSharedInstanceOf('Swift_CharacterReaderFactory_SimpleCharacterReaderFactory') + ->register('mime.characterreaderfactory') + ->asSharedInstanceOf('Swift_CharacterReaderFactory_SimpleCharacterReaderFactory') - ->register('mime.textcontentencoder') - ->asAliasOf('mime.qpcontentencoder') + ->register('mime.textcontentencoder') + ->asAliasOf('mime.qpcontentencoder') - ->register('mime.safeqpcontentencoder') - ->asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoder') - ->withDependencies(['mime.charstream', 'mime.bytecanonicalizer']) + ->register('mime.safeqpcontentencoder') + ->asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoder') + ->withDependencies(['mime.charstream', 'mime.bytecanonicalizer']) - ->register('mime.rawcontentencoder') - ->asNewInstanceOf('Swift_Mime_ContentEncoder_RawContentEncoder') + ->register('mime.rawcontentencoder') + ->asNewInstanceOf('Swift_Mime_ContentEncoder_RawContentEncoder') - ->register('mime.nativeqpcontentencoder') - ->withDependencies(['properties.charset']) - ->asNewInstanceOf('Swift_Mime_ContentEncoder_NativeQpContentEncoder') + ->register('mime.nativeqpcontentencoder') + ->withDependencies(['properties.charset']) + ->asNewInstanceOf('Swift_Mime_ContentEncoder_NativeQpContentEncoder') - ->register('mime.qpcontentencoder') - ->asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoderProxy') - ->withDependencies(['mime.safeqpcontentencoder', 'mime.nativeqpcontentencoder', 'properties.charset']) + ->register('mime.qpcontentencoder') + ->asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoderProxy') + ->withDependencies(['mime.safeqpcontentencoder', 'mime.nativeqpcontentencoder', 'properties.charset']) - ->register('mime.7bitcontentencoder') - ->asNewInstanceOf('Swift_Mime_ContentEncoder_PlainContentEncoder') - ->addConstructorValue('7bit') - ->addConstructorValue(true) + ->register('mime.7bitcontentencoder') + ->asNewInstanceOf('Swift_Mime_ContentEncoder_PlainContentEncoder') + ->addConstructorValue('7bit') + ->addConstructorValue(true) - ->register('mime.8bitcontentencoder') - ->asNewInstanceOf('Swift_Mime_ContentEncoder_PlainContentEncoder') - ->addConstructorValue('8bit') - ->addConstructorValue(true) + ->register('mime.8bitcontentencoder') + ->asNewInstanceOf('Swift_Mime_ContentEncoder_PlainContentEncoder') + ->addConstructorValue('8bit') + ->addConstructorValue(true) - ->register('mime.base64contentencoder') - ->asSharedInstanceOf('Swift_Mime_ContentEncoder_Base64ContentEncoder') + ->register('mime.base64contentencoder') + ->asSharedInstanceOf('Swift_Mime_ContentEncoder_Base64ContentEncoder') - ->register('mime.rfc2231encoder') - ->asNewInstanceOf('Swift_Encoder_Rfc2231Encoder') - ->withDependencies(['mime.charstream']); + ->register('mime.rfc2231encoder') + ->asNewInstanceOf('Swift_Encoder_Rfc2231Encoder') + ->withDependencies(['mime.charstream']) +; unset($swift_mime_types); diff --git a/htdocs/includes/swiftmailer/lib/dependency_maps/transport_deps.php b/htdocs/includes/swiftmailer/lib/dependency_maps/transport_deps.php index 40d65b176b9..34a63c78e51 100644 --- a/htdocs/includes/swiftmailer/lib/dependency_maps/transport_deps.php +++ b/htdocs/includes/swiftmailer/lib/dependency_maps/transport_deps.php @@ -1,96 +1,97 @@ register('transport.localdomain') - // As SERVER_NAME can come from the user in certain configurations, check that - // it does not contain forbidden characters (see RFC 952 and RFC 2181). Use - // preg_replace() instead of preg_match() to prevent DoS attacks with long host names. - ->asValue(!empty($_SERVER['SERVER_NAME']) && '' === preg_replace('/(?:^\[)?[a-zA-Z0-9-:\]_]+\.?/', '', $_SERVER['SERVER_NAME']) ? trim($_SERVER['SERVER_NAME'], '[]') : '127.0.0.1') + ->register('transport.localdomain') + // As SERVER_NAME can come from the user in certain configurations, check that + // it does not contain forbidden characters (see RFC 952 and RFC 2181). Use + // preg_replace() instead of preg_match() to prevent DoS attacks with long host names. + ->asValue(!empty($_SERVER['SERVER_NAME']) && '' === preg_replace('/(?:^\[)?[a-zA-Z0-9-:\]_]+\.?/', '', $_SERVER['SERVER_NAME']) ? trim($_SERVER['SERVER_NAME'], '[]') : '127.0.0.1') - ->register('transport.smtp') - ->asNewInstanceOf('Swift_Transport_EsmtpTransport') - ->withDependencies([ - 'transport.buffer', - 'transport.smtphandlers', - 'transport.eventdispatcher', - 'transport.localdomain', - 'address.idnaddressencoder', - ]) + ->register('transport.smtp') + ->asNewInstanceOf('Swift_Transport_EsmtpTransport') + ->withDependencies([ + 'transport.buffer', + 'transport.smtphandlers', + 'transport.eventdispatcher', + 'transport.localdomain', + 'address.idnaddressencoder', + ]) - ->register('transport.sendmail') - ->asNewInstanceOf('Swift_Transport_SendmailTransport') - ->withDependencies([ - 'transport.buffer', - 'transport.eventdispatcher', - 'transport.localdomain', - ]) + ->register('transport.sendmail') + ->asNewInstanceOf('Swift_Transport_SendmailTransport') + ->withDependencies([ + 'transport.buffer', + 'transport.eventdispatcher', + 'transport.localdomain', + ]) - ->register('transport.loadbalanced') - ->asNewInstanceOf('Swift_Transport_LoadBalancedTransport') + ->register('transport.loadbalanced') + ->asNewInstanceOf('Swift_Transport_LoadBalancedTransport') - ->register('transport.failover') - ->asNewInstanceOf('Swift_Transport_FailoverTransport') + ->register('transport.failover') + ->asNewInstanceOf('Swift_Transport_FailoverTransport') - ->register('transport.spool') - ->asNewInstanceOf('Swift_Transport_SpoolTransport') - ->withDependencies(['transport.eventdispatcher']) + ->register('transport.spool') + ->asNewInstanceOf('Swift_Transport_SpoolTransport') + ->withDependencies(['transport.eventdispatcher']) - ->register('transport.null') - ->asNewInstanceOf('Swift_Transport_NullTransport') - ->withDependencies(['transport.eventdispatcher']) + ->register('transport.null') + ->asNewInstanceOf('Swift_Transport_NullTransport') + ->withDependencies(['transport.eventdispatcher']) - ->register('transport.buffer') - ->asNewInstanceOf('Swift_Transport_StreamBuffer') - ->withDependencies(['transport.replacementfactory']) + ->register('transport.buffer') + ->asNewInstanceOf('Swift_Transport_StreamBuffer') + ->withDependencies(['transport.replacementfactory']) - ->register('transport.smtphandlers') - ->asArray() - ->withDependencies(['transport.authhandler']) + ->register('transport.smtphandlers') + ->asArray() + ->withDependencies(['transport.authhandler']) - ->register('transport.authhandler') - ->asNewInstanceOf('Swift_Transport_Esmtp_AuthHandler') - ->withDependencies(['transport.authhandlers']) + ->register('transport.authhandler') + ->asNewInstanceOf('Swift_Transport_Esmtp_AuthHandler') + ->withDependencies(['transport.authhandlers']) - ->register('transport.authhandlers') - ->asArray() - ->withDependencies([ - 'transport.crammd5auth', - 'transport.loginauth', - 'transport.plainauth', - 'transport.ntlmauth', - 'transport.xoauth2auth', - ]) + ->register('transport.authhandlers') + ->asArray() + ->withDependencies([ + 'transport.crammd5auth', + 'transport.loginauth', + 'transport.plainauth', + 'transport.ntlmauth', + 'transport.xoauth2auth', + ]) - ->register('transport.smtputf8handler') - ->asNewInstanceOf('Swift_Transport_Esmtp_SmtpUtf8Handler') + ->register('transport.smtputf8handler') + ->asNewInstanceOf('Swift_Transport_Esmtp_SmtpUtf8Handler') - ->register('transport.8bitmimehandler') - ->asNewInstanceOf('Swift_Transport_Esmtp_EightBitMimeHandler') - ->addConstructorValue('8BITMIME') + ->register('transport.8bitmimehandler') + ->asNewInstanceOf('Swift_Transport_Esmtp_EightBitMimeHandler') + ->addConstructorValue('8BITMIME') - ->register('transport.crammd5auth') - ->asNewInstanceOf('Swift_Transport_Esmtp_Auth_CramMd5Authenticator') + ->register('transport.crammd5auth') + ->asNewInstanceOf('Swift_Transport_Esmtp_Auth_CramMd5Authenticator') - ->register('transport.loginauth') - ->asNewInstanceOf('Swift_Transport_Esmtp_Auth_LoginAuthenticator') + ->register('transport.loginauth') + ->asNewInstanceOf('Swift_Transport_Esmtp_Auth_LoginAuthenticator') - ->register('transport.plainauth') - ->asNewInstanceOf('Swift_Transport_Esmtp_Auth_PlainAuthenticator') + ->register('transport.plainauth') + ->asNewInstanceOf('Swift_Transport_Esmtp_Auth_PlainAuthenticator') - ->register('transport.xoauth2auth') - ->asNewInstanceOf('Swift_Transport_Esmtp_Auth_XOAuth2Authenticator') + ->register('transport.xoauth2auth') + ->asNewInstanceOf('Swift_Transport_Esmtp_Auth_XOAuth2Authenticator') - ->register('transport.ntlmauth') - ->asNewInstanceOf('Swift_Transport_Esmtp_Auth_NTLMAuthenticator') + ->register('transport.ntlmauth') + ->asNewInstanceOf('Swift_Transport_Esmtp_Auth_NTLMAuthenticator') - ->register('transport.eventdispatcher') - ->asNewInstanceOf('Swift_Events_SimpleEventDispatcher') + ->register('transport.eventdispatcher') + ->asNewInstanceOf('Swift_Events_SimpleEventDispatcher') - ->register('transport.replacementfactory') - ->asSharedInstanceOf('Swift_StreamFilters_StringReplacementFilterFactory') + ->register('transport.replacementfactory') + ->asSharedInstanceOf('Swift_StreamFilters_StringReplacementFilterFactory') - ->register('address.idnaddressencoder') - ->asNewInstanceOf('Swift_AddressEncoder_IdnAddressEncoder') + ->register('address.idnaddressencoder') + ->asNewInstanceOf('Swift_AddressEncoder_IdnAddressEncoder') - ->register('address.utf8addressencoder') - ->asNewInstanceOf('Swift_AddressEncoder_Utf8AddressEncoder'); + ->register('address.utf8addressencoder') + ->asNewInstanceOf('Swift_AddressEncoder_Utf8AddressEncoder') +; diff --git a/htdocs/includes/swiftmailer/lib/mime_types.php b/htdocs/includes/swiftmailer/lib/mime_types.php index 0cb61d18832..72c6fd2afa6 100644 --- a/htdocs/includes/swiftmailer/lib/mime_types.php +++ b/htdocs/includes/swiftmailer/lib/mime_types.php @@ -18,990 +18,990 @@ // You may add or take away what you like (lowercase required) $swift_mime_types = [ - '3dml' => 'text/vnd.in3d.3dml', - '3ds' => 'image/x-3ds', - '3g2' => 'video/3gpp2', - '3gp' => 'video/3gpp', - '7z' => 'application/x-7z-compressed', - 'aab' => 'application/x-authorware-bin', - 'aac' => 'audio/x-aac', - 'aam' => 'application/x-authorware-map', - 'aas' => 'application/x-authorware-seg', - 'abw' => 'application/x-abiword', - 'ac' => 'application/pkix-attr-cert', - 'acc' => 'application/vnd.americandynamics.acc', - 'ace' => 'application/x-ace-compressed', - 'acu' => 'application/vnd.acucobol', - 'acutc' => 'application/vnd.acucorp', - 'adp' => 'audio/adpcm', - 'aep' => 'application/vnd.audiograph', - 'afm' => 'application/x-font-type1', - 'afp' => 'application/vnd.ibm.modcap', - 'ahead' => 'application/vnd.ahead.space', - 'ai' => 'application/postscript', - 'aif' => 'audio/x-aiff', - 'aifc' => 'audio/x-aiff', - 'aiff' => 'audio/x-aiff', - 'air' => 'application/vnd.adobe.air-application-installer-package+zip', - 'ait' => 'application/vnd.dvb.ait', - 'ami' => 'application/vnd.amiga.ami', - 'apk' => 'application/vnd.android.package-archive', - 'appcache' => 'text/cache-manifest', - 'apr' => 'application/vnd.lotus-approach', - 'aps' => 'application/postscript', - 'arc' => 'application/x-freearc', - 'asc' => 'application/pgp-signature', - 'asf' => 'video/x-ms-asf', - 'asm' => 'text/x-asm', - 'aso' => 'application/vnd.accpac.simply.aso', - 'asx' => 'video/x-ms-asf', - 'atc' => 'application/vnd.acucorp', - 'atom' => 'application/atom+xml', - 'atomcat' => 'application/atomcat+xml', - 'atomsvc' => 'application/atomsvc+xml', - 'atx' => 'application/vnd.antix.game-component', - 'au' => 'audio/basic', - 'avi' => 'video/x-msvideo', - 'aw' => 'application/applixware', - 'azf' => 'application/vnd.airzip.filesecure.azf', - 'azs' => 'application/vnd.airzip.filesecure.azs', - 'azw' => 'application/vnd.amazon.ebook', - 'bat' => 'application/x-msdownload', - 'bcpio' => 'application/x-bcpio', - 'bdf' => 'application/x-font-bdf', - 'bdm' => 'application/vnd.syncml.dm+wbxml', - 'bed' => 'application/vnd.realvnc.bed', - 'bh2' => 'application/vnd.fujitsu.oasysprs', - 'bin' => 'application/octet-stream', - 'blb' => 'application/x-blorb', - 'blorb' => 'application/x-blorb', - 'bmi' => 'application/vnd.bmi', - 'bmp' => 'image/bmp', - 'book' => 'application/vnd.framemaker', - 'box' => 'application/vnd.previewsystems.box', - 'boz' => 'application/x-bzip2', - 'bpk' => 'application/octet-stream', - 'btif' => 'image/prs.btif', - 'bz' => 'application/x-bzip', - 'bz2' => 'application/x-bzip2', - 'c' => 'text/x-c', - 'c11amc' => 'application/vnd.cluetrust.cartomobile-config', - 'c11amz' => 'application/vnd.cluetrust.cartomobile-config-pkg', - 'c4d' => 'application/vnd.clonk.c4group', - 'c4f' => 'application/vnd.clonk.c4group', - 'c4g' => 'application/vnd.clonk.c4group', - 'c4p' => 'application/vnd.clonk.c4group', - 'c4u' => 'application/vnd.clonk.c4group', - 'cab' => 'application/vnd.ms-cab-compressed', - 'caf' => 'audio/x-caf', - 'cap' => 'application/vnd.tcpdump.pcap', - 'car' => 'application/vnd.curl.car', - 'cat' => 'application/vnd.ms-pki.seccat', - 'cb7' => 'application/x-cbr', - 'cba' => 'application/x-cbr', - 'cbr' => 'application/x-cbr', - 'cbt' => 'application/x-cbr', - 'cbz' => 'application/x-cbr', - 'cc' => 'text/x-c', - 'cct' => 'application/x-director', - 'ccxml' => 'application/ccxml+xml', - 'cdbcmsg' => 'application/vnd.contact.cmsg', - 'cdf' => 'application/x-netcdf', - 'cdkey' => 'application/vnd.mediastation.cdkey', - 'cdmia' => 'application/cdmi-capability', - 'cdmic' => 'application/cdmi-container', - 'cdmid' => 'application/cdmi-domain', - 'cdmio' => 'application/cdmi-object', - 'cdmiq' => 'application/cdmi-queue', - 'cdx' => 'chemical/x-cdx', - 'cdxml' => 'application/vnd.chemdraw+xml', - 'cdy' => 'application/vnd.cinderella', - 'cer' => 'application/pkix-cert', - 'cfs' => 'application/x-cfs-compressed', - 'cgm' => 'image/cgm', - 'chat' => 'application/x-chat', - 'chm' => 'application/vnd.ms-htmlhelp', - 'chrt' => 'application/vnd.kde.kchart', - 'cif' => 'chemical/x-cif', - 'cii' => 'application/vnd.anser-web-certificate-issue-initiation', - 'cil' => 'application/vnd.ms-artgalry', - 'cla' => 'application/vnd.claymore', - 'class' => 'application/java-vm', - 'clkk' => 'application/vnd.crick.clicker.keyboard', - 'clkp' => 'application/vnd.crick.clicker.palette', - 'clkt' => 'application/vnd.crick.clicker.template', - 'clkw' => 'application/vnd.crick.clicker.wordbank', - 'clkx' => 'application/vnd.crick.clicker', - 'clp' => 'application/x-msclip', - 'cmc' => 'application/vnd.cosmocaller', - 'cmdf' => 'chemical/x-cmdf', - 'cml' => 'chemical/x-cml', - 'cmp' => 'application/vnd.yellowriver-custom-menu', - 'cmx' => 'image/x-cmx', - 'cod' => 'application/vnd.rim.cod', - 'com' => 'application/x-msdownload', - 'conf' => 'text/plain', - 'cpio' => 'application/x-cpio', - 'cpp' => 'text/x-c', - 'cpt' => 'application/mac-compactpro', - 'crd' => 'application/x-mscardfile', - 'crl' => 'application/pkix-crl', - 'crt' => 'application/x-x509-ca-cert', - 'csh' => 'application/x-csh', - 'csml' => 'chemical/x-csml', - 'csp' => 'application/vnd.commonspace', - 'css' => 'text/css', - 'cst' => 'application/x-director', - 'csv' => 'text/csv', - 'cu' => 'application/cu-seeme', - 'curl' => 'text/vnd.curl', - 'cww' => 'application/prs.cww', - 'cxt' => 'application/x-director', - 'cxx' => 'text/x-c', - 'dae' => 'model/vnd.collada+xml', - 'daf' => 'application/vnd.mobius.daf', - 'dart' => 'application/vnd.dart', - 'dataless' => 'application/vnd.fdsn.seed', - 'davmount' => 'application/davmount+xml', - 'dbk' => 'application/docbook+xml', - 'dcr' => 'application/x-director', - 'dcurl' => 'text/vnd.curl.dcurl', - 'dd2' => 'application/vnd.oma.dd2+xml', - 'ddd' => 'application/vnd.fujixerox.ddd', - 'deb' => 'application/x-debian-package', - 'def' => 'text/plain', - 'deploy' => 'application/octet-stream', - 'der' => 'application/x-x509-ca-cert', - 'dfac' => 'application/vnd.dreamfactory', - 'dgc' => 'application/x-dgc-compressed', - 'dic' => 'text/x-c', - 'dir' => 'application/x-director', - 'dis' => 'application/vnd.mobius.dis', - 'dist' => 'application/octet-stream', - 'distz' => 'application/octet-stream', - 'djv' => 'image/vnd.djvu', - 'djvu' => 'image/vnd.djvu', - 'dll' => 'application/x-msdownload', - 'dmg' => 'application/x-apple-diskimage', - 'dmp' => 'application/vnd.tcpdump.pcap', - 'dms' => 'application/octet-stream', - 'dna' => 'application/vnd.dna', - 'doc' => 'application/msword', - 'docm' => 'application/vnd.ms-word.document.macroenabled.12', - 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', - 'dot' => 'application/msword', - 'dotm' => 'application/vnd.ms-word.template.macroenabled.12', - 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', - 'dp' => 'application/vnd.osgi.dp', - 'dpg' => 'application/vnd.dpgraph', - 'dra' => 'audio/vnd.dra', - 'dsc' => 'text/prs.lines.tag', - 'dssc' => 'application/dssc+der', - 'dtb' => 'application/x-dtbook+xml', - 'dtd' => 'application/xml-dtd', - 'dts' => 'audio/vnd.dts', - 'dtshd' => 'audio/vnd.dts.hd', - 'dump' => 'application/octet-stream', - 'dvb' => 'video/vnd.dvb.file', - 'dvi' => 'application/x-dvi', - 'dwf' => 'model/vnd.dwf', - 'dwg' => 'image/vnd.dwg', - 'dxf' => 'image/vnd.dxf', - 'dxp' => 'application/vnd.spotfire.dxp', - 'dxr' => 'application/x-director', - 'ecelp4800' => 'audio/vnd.nuera.ecelp4800', - 'ecelp7470' => 'audio/vnd.nuera.ecelp7470', - 'ecelp9600' => 'audio/vnd.nuera.ecelp9600', - 'ecma' => 'application/ecmascript', - 'edm' => 'application/vnd.novadigm.edm', - 'edx' => 'application/vnd.novadigm.edx', - 'efif' => 'application/vnd.picsel', - 'ei6' => 'application/vnd.pg.osasli', - 'elc' => 'application/octet-stream', - 'emf' => 'application/x-msmetafile', - 'eml' => 'message/rfc822', - 'emma' => 'application/emma+xml', - 'emz' => 'application/x-msmetafile', - 'eol' => 'audio/vnd.digital-winds', - 'eot' => 'application/vnd.ms-fontobject', - 'eps' => 'application/postscript', - 'epub' => 'application/epub+zip', - 'es3' => 'application/vnd.eszigno3+xml', - 'esa' => 'application/vnd.osgi.subsystem', - 'esf' => 'application/vnd.epson.esf', - 'et3' => 'application/vnd.eszigno3+xml', - 'etx' => 'text/x-setext', - 'eva' => 'application/x-eva', - 'evy' => 'application/x-envoy', - 'exe' => 'application/x-msdownload', - 'exi' => 'application/exi', - 'ext' => 'application/vnd.novadigm.ext', - 'ez' => 'application/andrew-inset', - 'ez2' => 'application/vnd.ezpix-album', - 'ez3' => 'application/vnd.ezpix-package', - 'f' => 'text/x-fortran', - 'f4v' => 'video/x-f4v', - 'f77' => 'text/x-fortran', - 'f90' => 'text/x-fortran', - 'fbs' => 'image/vnd.fastbidsheet', - 'fcdt' => 'application/vnd.adobe.formscentral.fcdt', - 'fcs' => 'application/vnd.isac.fcs', - 'fdf' => 'application/vnd.fdf', - 'fe_launch' => 'application/vnd.denovo.fcselayout-link', - 'fg5' => 'application/vnd.fujitsu.oasysgp', - 'fgd' => 'application/x-director', - 'fh' => 'image/x-freehand', - 'fh4' => 'image/x-freehand', - 'fh5' => 'image/x-freehand', - 'fh7' => 'image/x-freehand', - 'fhc' => 'image/x-freehand', - 'fig' => 'application/x-xfig', - 'flac' => 'audio/x-flac', - 'fli' => 'video/x-fli', - 'flo' => 'application/vnd.micrografx.flo', - 'flv' => 'video/x-flv', - 'flw' => 'application/vnd.kde.kivio', - 'flx' => 'text/vnd.fmi.flexstor', - 'fly' => 'text/vnd.fly', - 'fm' => 'application/vnd.framemaker', - 'fnc' => 'application/vnd.frogans.fnc', - 'for' => 'text/x-fortran', - 'fpx' => 'image/vnd.fpx', - 'frame' => 'application/vnd.framemaker', - 'fsc' => 'application/vnd.fsc.weblaunch', - 'fst' => 'image/vnd.fst', - 'ftc' => 'application/vnd.fluxtime.clip', - 'fti' => 'application/vnd.anser-web-funds-transfer-initiation', - 'fvt' => 'video/vnd.fvt', - 'fxp' => 'application/vnd.adobe.fxp', - 'fxpl' => 'application/vnd.adobe.fxp', - 'fzs' => 'application/vnd.fuzzysheet', - 'g2w' => 'application/vnd.geoplan', - 'g3' => 'image/g3fax', - 'g3w' => 'application/vnd.geospace', - 'gac' => 'application/vnd.groove-account', - 'gam' => 'application/x-tads', - 'gbr' => 'application/rpki-ghostbusters', - 'gca' => 'application/x-gca-compressed', - 'gdl' => 'model/vnd.gdl', - 'geo' => 'application/vnd.dynageo', - 'gex' => 'application/vnd.geometry-explorer', - 'ggb' => 'application/vnd.geogebra.file', - 'ggt' => 'application/vnd.geogebra.tool', - 'ghf' => 'application/vnd.groove-help', - 'gif' => 'image/gif', - 'gim' => 'application/vnd.groove-identity-message', - 'gml' => 'application/gml+xml', - 'gmx' => 'application/vnd.gmx', - 'gnumeric' => 'application/x-gnumeric', - 'gph' => 'application/vnd.flographit', - 'gpx' => 'application/gpx+xml', - 'gqf' => 'application/vnd.grafeq', - 'gqs' => 'application/vnd.grafeq', - 'gram' => 'application/srgs', - 'gramps' => 'application/x-gramps-xml', - 'gre' => 'application/vnd.geometry-explorer', - 'grv' => 'application/vnd.groove-injector', - 'grxml' => 'application/srgs+xml', - 'gsf' => 'application/x-font-ghostscript', - 'gtar' => 'application/x-gtar', - 'gtm' => 'application/vnd.groove-tool-message', - 'gtw' => 'model/vnd.gtw', - 'gv' => 'text/vnd.graphviz', - 'gxf' => 'application/gxf', - 'gxt' => 'application/vnd.geonext', - 'gz' => 'application/x-gzip', - 'h' => 'text/x-c', - 'h261' => 'video/h261', - 'h263' => 'video/h263', - 'h264' => 'video/h264', - 'hal' => 'application/vnd.hal+xml', - 'hbci' => 'application/vnd.hbci', - 'hdf' => 'application/x-hdf', - 'hh' => 'text/x-c', - 'hlp' => 'application/winhlp', - 'hpgl' => 'application/vnd.hp-hpgl', - 'hpid' => 'application/vnd.hp-hpid', - 'hps' => 'application/vnd.hp-hps', - 'hqx' => 'application/mac-binhex40', - 'htke' => 'application/vnd.kenameaapp', - 'htm' => 'text/html', - 'html' => 'text/html', - 'hvd' => 'application/vnd.yamaha.hv-dic', - 'hvp' => 'application/vnd.yamaha.hv-voice', - 'hvs' => 'application/vnd.yamaha.hv-script', - 'i2g' => 'application/vnd.intergeo', - 'icc' => 'application/vnd.iccprofile', - 'ice' => 'x-conference/x-cooltalk', - 'icm' => 'application/vnd.iccprofile', - 'ico' => 'image/x-icon', - 'ics' => 'text/calendar', - 'ief' => 'image/ief', - 'ifb' => 'text/calendar', - 'ifm' => 'application/vnd.shana.informed.formdata', - 'iges' => 'model/iges', - 'igl' => 'application/vnd.igloader', - 'igm' => 'application/vnd.insors.igm', - 'igs' => 'model/iges', - 'igx' => 'application/vnd.micrografx.igx', - 'iif' => 'application/vnd.shana.informed.interchange', - 'imp' => 'application/vnd.accpac.simply.imp', - 'ims' => 'application/vnd.ms-ims', - 'in' => 'text/plain', - 'ink' => 'application/inkml+xml', - 'inkml' => 'application/inkml+xml', - 'install' => 'application/x-install-instructions', - 'iota' => 'application/vnd.astraea-software.iota', - 'ipfix' => 'application/ipfix', - 'ipk' => 'application/vnd.shana.informed.package', - 'irm' => 'application/vnd.ibm.rights-management', - 'irp' => 'application/vnd.irepository.package+xml', - 'iso' => 'application/x-iso9660-image', - 'itp' => 'application/vnd.shana.informed.formtemplate', - 'ivp' => 'application/vnd.immervision-ivp', - 'ivu' => 'application/vnd.immervision-ivu', - 'jad' => 'text/vnd.sun.j2me.app-descriptor', - 'jam' => 'application/vnd.jam', - 'jar' => 'application/java-archive', - 'java' => 'text/x-java-source', - 'jisp' => 'application/vnd.jisp', - 'jlt' => 'application/vnd.hp-jlyt', - 'jnlp' => 'application/x-java-jnlp-file', - 'joda' => 'application/vnd.joost.joda-archive', - 'jpe' => 'image/jpeg', - 'jpeg' => 'image/jpeg', - 'jpg' => 'image/jpeg', - 'jpgm' => 'video/jpm', - 'jpgv' => 'video/jpeg', - 'jpm' => 'video/jpm', - 'js' => 'application/javascript', - 'json' => 'application/json', - 'jsonml' => 'application/jsonml+json', - 'kar' => 'audio/midi', - 'karbon' => 'application/vnd.kde.karbon', - 'kfo' => 'application/vnd.kde.kformula', - 'kia' => 'application/vnd.kidspiration', - 'kml' => 'application/vnd.google-earth.kml+xml', - 'kmz' => 'application/vnd.google-earth.kmz', - 'kne' => 'application/vnd.kinar', - 'knp' => 'application/vnd.kinar', - 'kon' => 'application/vnd.kde.kontour', - 'kpr' => 'application/vnd.kde.kpresenter', - 'kpt' => 'application/vnd.kde.kpresenter', - 'kpxx' => 'application/vnd.ds-keypoint', - 'ksp' => 'application/vnd.kde.kspread', - 'ktr' => 'application/vnd.kahootz', - 'ktx' => 'image/ktx', - 'ktz' => 'application/vnd.kahootz', - 'kwd' => 'application/vnd.kde.kword', - 'kwt' => 'application/vnd.kde.kword', - 'lasxml' => 'application/vnd.las.las+xml', - 'latex' => 'application/x-latex', - 'lbd' => 'application/vnd.llamagraphics.life-balance.desktop', - 'lbe' => 'application/vnd.llamagraphics.life-balance.exchange+xml', - 'les' => 'application/vnd.hhe.lesson-player', - 'lha' => 'application/x-lzh-compressed', - 'link66' => 'application/vnd.route66.link66+xml', - 'list' => 'text/plain', - 'list3820' => 'application/vnd.ibm.modcap', - 'listafp' => 'application/vnd.ibm.modcap', - 'lnk' => 'application/x-ms-shortcut', - 'log' => 'text/plain', - 'lostxml' => 'application/lost+xml', - 'lrf' => 'application/octet-stream', - 'lrm' => 'application/vnd.ms-lrm', - 'ltf' => 'application/vnd.frogans.ltf', - 'lvp' => 'audio/vnd.lucent.voice', - 'lwp' => 'application/vnd.lotus-wordpro', - 'lzh' => 'application/x-lzh-compressed', - 'm13' => 'application/x-msmediaview', - 'm14' => 'application/x-msmediaview', - 'm1v' => 'video/mpeg', - 'm21' => 'application/mp21', - 'm2a' => 'audio/mpeg', - 'm2v' => 'video/mpeg', - 'm3a' => 'audio/mpeg', - 'm3u' => 'audio/x-mpegurl', - 'm3u8' => 'application/vnd.apple.mpegurl', - 'm4a' => 'audio/mp4', - 'm4u' => 'video/vnd.mpegurl', - 'm4v' => 'video/x-m4v', - 'ma' => 'application/mathematica', - 'mads' => 'application/mads+xml', - 'mag' => 'application/vnd.ecowin.chart', - 'maker' => 'application/vnd.framemaker', - 'man' => 'text/troff', - 'mar' => 'application/octet-stream', - 'mathml' => 'application/mathml+xml', - 'mb' => 'application/mathematica', - 'mbk' => 'application/vnd.mobius.mbk', - 'mbox' => 'application/mbox', - 'mc1' => 'application/vnd.medcalcdata', - 'mcd' => 'application/vnd.mcd', - 'mcurl' => 'text/vnd.curl.mcurl', - 'mdb' => 'application/x-msaccess', - 'mdi' => 'image/vnd.ms-modi', - 'me' => 'text/troff', - 'mesh' => 'model/mesh', - 'meta4' => 'application/metalink4+xml', - 'metalink' => 'application/metalink+xml', - 'mets' => 'application/mets+xml', - 'mfm' => 'application/vnd.mfmp', - 'mft' => 'application/rpki-manifest', - 'mgp' => 'application/vnd.osgeo.mapguide.package', - 'mgz' => 'application/vnd.proteus.magazine', - 'mid' => 'audio/midi', - 'midi' => 'audio/midi', - 'mie' => 'application/x-mie', - 'mif' => 'application/vnd.mif', - 'mime' => 'message/rfc822', - 'mj2' => 'video/mj2', - 'mjp2' => 'video/mj2', - 'mk3d' => 'video/x-matroska', - 'mka' => 'audio/x-matroska', - 'mks' => 'video/x-matroska', - 'mkv' => 'video/x-matroska', - 'mlp' => 'application/vnd.dolby.mlp', - 'mmd' => 'application/vnd.chipnuts.karaoke-mmd', - 'mmf' => 'application/vnd.smaf', - 'mmr' => 'image/vnd.fujixerox.edmics-mmr', - 'mng' => 'video/x-mng', - 'mny' => 'application/x-msmoney', - 'mobi' => 'application/x-mobipocket-ebook', - 'mods' => 'application/mods+xml', - 'mov' => 'video/quicktime', - 'movie' => 'video/x-sgi-movie', - 'mp2' => 'audio/mpeg', - 'mp21' => 'application/mp21', - 'mp2a' => 'audio/mpeg', - 'mp3' => 'audio/mpeg', - 'mp4' => 'video/mp4', - 'mp4a' => 'audio/mp4', - 'mp4s' => 'application/mp4', - 'mp4v' => 'video/mp4', - 'mpc' => 'application/vnd.mophun.certificate', - 'mpe' => 'video/mpeg', - 'mpeg' => 'video/mpeg', - 'mpg' => 'video/mpeg', - 'mpg4' => 'video/mp4', - 'mpga' => 'audio/mpeg', - 'mpkg' => 'application/vnd.apple.installer+xml', - 'mpm' => 'application/vnd.blueice.multipass', - 'mpn' => 'application/vnd.mophun.application', - 'mpp' => 'application/vnd.ms-project', - 'mpt' => 'application/vnd.ms-project', - 'mpy' => 'application/vnd.ibm.minipay', - 'mqy' => 'application/vnd.mobius.mqy', - 'mrc' => 'application/marc', - 'mrcx' => 'application/marcxml+xml', - 'ms' => 'text/troff', - 'mscml' => 'application/mediaservercontrol+xml', - 'mseed' => 'application/vnd.fdsn.mseed', - 'mseq' => 'application/vnd.mseq', - 'msf' => 'application/vnd.epson.msf', - 'msh' => 'model/mesh', - 'msi' => 'application/x-msdownload', - 'msl' => 'application/vnd.mobius.msl', - 'msty' => 'application/vnd.muvee.style', - 'mts' => 'model/vnd.mts', - 'mus' => 'application/vnd.musician', - 'musicxml' => 'application/vnd.recordare.musicxml+xml', - 'mvb' => 'application/x-msmediaview', - 'mwf' => 'application/vnd.mfer', - 'mxf' => 'application/mxf', - 'mxl' => 'application/vnd.recordare.musicxml', - 'mxml' => 'application/xv+xml', - 'mxs' => 'application/vnd.triscape.mxs', - 'mxu' => 'video/vnd.mpegurl', - 'n-gage' => 'application/vnd.nokia.n-gage.symbian.install', - 'n3' => 'text/n3', - 'nb' => 'application/mathematica', - 'nbp' => 'application/vnd.wolfram.player', - 'nc' => 'application/x-netcdf', - 'ncx' => 'application/x-dtbncx+xml', - 'nfo' => 'text/x-nfo', - 'ngdat' => 'application/vnd.nokia.n-gage.data', - 'nitf' => 'application/vnd.nitf', - 'nlu' => 'application/vnd.neurolanguage.nlu', - 'nml' => 'application/vnd.enliven', - 'nnd' => 'application/vnd.noblenet-directory', - 'nns' => 'application/vnd.noblenet-sealer', - 'nnw' => 'application/vnd.noblenet-web', - 'npx' => 'image/vnd.net-fpx', - 'nsc' => 'application/x-conference', - 'nsf' => 'application/vnd.lotus-notes', - 'ntf' => 'application/vnd.nitf', - 'nzb' => 'application/x-nzb', - 'oa2' => 'application/vnd.fujitsu.oasys2', - 'oa3' => 'application/vnd.fujitsu.oasys3', - 'oas' => 'application/vnd.fujitsu.oasys', - 'obd' => 'application/x-msbinder', - 'obj' => 'application/x-tgif', - 'oda' => 'application/oda', - 'odb' => 'application/vnd.oasis.opendocument.database', - 'odc' => 'application/vnd.oasis.opendocument.chart', - 'odf' => 'application/vnd.oasis.opendocument.formula', - 'odft' => 'application/vnd.oasis.opendocument.formula-template', - 'odg' => 'application/vnd.oasis.opendocument.graphics', - 'odi' => 'application/vnd.oasis.opendocument.image', - 'odm' => 'application/vnd.oasis.opendocument.text-master', - 'odp' => 'application/vnd.oasis.opendocument.presentation', - 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', - 'odt' => 'application/vnd.oasis.opendocument.text', - 'oga' => 'audio/ogg', - 'ogg' => 'audio/ogg', - 'ogv' => 'video/ogg', - 'ogx' => 'application/ogg', - 'omdoc' => 'application/omdoc+xml', - 'onepkg' => 'application/onenote', - 'onetmp' => 'application/onenote', - 'onetoc' => 'application/onenote', - 'onetoc2' => 'application/onenote', - 'opf' => 'application/oebps-package+xml', - 'opml' => 'text/x-opml', - 'oprc' => 'application/vnd.palm', - 'org' => 'application/vnd.lotus-organizer', - 'osf' => 'application/vnd.yamaha.openscoreformat', - 'osfpvg' => 'application/vnd.yamaha.openscoreformat.osfpvg+xml', - 'otc' => 'application/vnd.oasis.opendocument.chart-template', - 'otf' => 'application/x-font-otf', - 'otg' => 'application/vnd.oasis.opendocument.graphics-template', - 'oth' => 'application/vnd.oasis.opendocument.text-web', - 'oti' => 'application/vnd.oasis.opendocument.image-template', - 'otp' => 'application/vnd.oasis.opendocument.presentation-template', - 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template', - 'ott' => 'application/vnd.oasis.opendocument.text-template', - 'oxps' => 'application/oxps', - 'oxt' => 'application/vnd.openofficeorg.extension', - 'p' => 'text/x-pascal', - 'p10' => 'application/pkcs10', - 'p12' => 'application/x-pkcs12', - 'p7b' => 'application/x-pkcs7-certificates', - 'p7c' => 'application/pkcs7-mime', - 'p7m' => 'application/pkcs7-mime', - 'p7r' => 'application/x-pkcs7-certreqresp', - 'p7s' => 'application/pkcs7-signature', - 'p8' => 'application/pkcs8', - 'pas' => 'text/x-pascal', - 'paw' => 'application/vnd.pawaafile', - 'pbd' => 'application/vnd.powerbuilder6', - 'pbm' => 'image/x-portable-bitmap', - 'pcap' => 'application/vnd.tcpdump.pcap', - 'pcf' => 'application/x-font-pcf', - 'pcl' => 'application/vnd.hp-pcl', - 'pclxl' => 'application/vnd.hp-pclxl', - 'pct' => 'image/x-pict', - 'pcurl' => 'application/vnd.curl.pcurl', - 'pcx' => 'image/x-pcx', - 'pdb' => 'application/vnd.palm', - 'pdf' => 'application/pdf', - 'pfa' => 'application/x-font-type1', - 'pfb' => 'application/x-font-type1', - 'pfm' => 'application/x-font-type1', - 'pfr' => 'application/font-tdpfr', - 'pfx' => 'application/x-pkcs12', - 'pgm' => 'image/x-portable-graymap', - 'pgn' => 'application/x-chess-pgn', - 'pgp' => 'application/pgp-encrypted', - 'php' => 'application/x-php', - 'php3' => 'application/x-php', - 'php4' => 'application/x-php', - 'php5' => 'application/x-php', - 'pic' => 'image/x-pict', - 'pkg' => 'application/octet-stream', - 'pki' => 'application/pkixcmp', - 'pkipath' => 'application/pkix-pkipath', - 'plb' => 'application/vnd.3gpp.pic-bw-large', - 'plc' => 'application/vnd.mobius.plc', - 'plf' => 'application/vnd.pocketlearn', - 'pls' => 'application/pls+xml', - 'pml' => 'application/vnd.ctc-posml', - 'png' => 'image/png', - 'pnm' => 'image/x-portable-anymap', - 'portpkg' => 'application/vnd.macports.portpkg', - 'pot' => 'application/vnd.ms-powerpoint', - 'potm' => 'application/vnd.ms-powerpoint.template.macroenabled.12', - 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template', - 'ppam' => 'application/vnd.ms-powerpoint.addin.macroenabled.12', - 'ppd' => 'application/vnd.cups-ppd', - 'ppm' => 'image/x-portable-pixmap', - 'pps' => 'application/vnd.ms-powerpoint', - 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroenabled.12', - 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', - 'ppt' => 'application/vnd.ms-powerpoint', - 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroenabled.12', - 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', - 'pqa' => 'application/vnd.palm', - 'prc' => 'application/x-mobipocket-ebook', - 'pre' => 'application/vnd.lotus-freelance', - 'prf' => 'application/pics-rules', - 'ps' => 'application/postscript', - 'psb' => 'application/vnd.3gpp.pic-bw-small', - 'psd' => 'image/vnd.adobe.photoshop', - 'psf' => 'application/x-font-linux-psf', - 'pskcxml' => 'application/pskc+xml', - 'ptid' => 'application/vnd.pvi.ptid1', - 'pub' => 'application/x-mspublisher', - 'pvb' => 'application/vnd.3gpp.pic-bw-var', - 'pwn' => 'application/vnd.3m.post-it-notes', - 'pya' => 'audio/vnd.ms-playready.media.pya', - 'pyv' => 'video/vnd.ms-playready.media.pyv', - 'qam' => 'application/vnd.epson.quickanime', - 'qbo' => 'application/vnd.intu.qbo', - 'qfx' => 'application/vnd.intu.qfx', - 'qps' => 'application/vnd.publishare-delta-tree', - 'qt' => 'video/quicktime', - 'qwd' => 'application/vnd.quark.quarkxpress', - 'qwt' => 'application/vnd.quark.quarkxpress', - 'qxb' => 'application/vnd.quark.quarkxpress', - 'qxd' => 'application/vnd.quark.quarkxpress', - 'qxl' => 'application/vnd.quark.quarkxpress', - 'qxt' => 'application/vnd.quark.quarkxpress', - 'ra' => 'audio/x-pn-realaudio', - 'ram' => 'audio/x-pn-realaudio', - 'rar' => 'application/x-rar-compressed', - 'ras' => 'image/x-cmu-raster', - 'rcprofile' => 'application/vnd.ipunplugged.rcprofile', - 'rdf' => 'application/rdf+xml', - 'rdz' => 'application/vnd.data-vision.rdz', - 'rep' => 'application/vnd.businessobjects', - 'res' => 'application/x-dtbresource+xml', - 'rgb' => 'image/x-rgb', - 'rif' => 'application/reginfo+xml', - 'rip' => 'audio/vnd.rip', - 'ris' => 'application/x-research-info-systems', - 'rl' => 'application/resource-lists+xml', - 'rlc' => 'image/vnd.fujixerox.edmics-rlc', - 'rld' => 'application/resource-lists-diff+xml', - 'rm' => 'application/vnd.rn-realmedia', - 'rmi' => 'audio/midi', - 'rmp' => 'audio/x-pn-realaudio-plugin', - 'rms' => 'application/vnd.jcp.javame.midlet-rms', - 'rmvb' => 'application/vnd.rn-realmedia-vbr', - 'rnc' => 'application/relax-ng-compact-syntax', - 'roa' => 'application/rpki-roa', - 'roff' => 'text/troff', - 'rp9' => 'application/vnd.cloanto.rp9', - 'rpss' => 'application/vnd.nokia.radio-presets', - 'rpst' => 'application/vnd.nokia.radio-preset', - 'rq' => 'application/sparql-query', - 'rs' => 'application/rls-services+xml', - 'rsd' => 'application/rsd+xml', - 'rss' => 'application/rss+xml', - 'rtf' => 'application/rtf', - 'rtx' => 'text/richtext', - 's' => 'text/x-asm', - 's3m' => 'audio/s3m', - 'saf' => 'application/vnd.yamaha.smaf-audio', - 'sbml' => 'application/sbml+xml', - 'sc' => 'application/vnd.ibm.secure-container', - 'scd' => 'application/x-msschedule', - 'scm' => 'application/vnd.lotus-screencam', - 'scq' => 'application/scvp-cv-request', - 'scs' => 'application/scvp-cv-response', - 'scurl' => 'text/vnd.curl.scurl', - 'sda' => 'application/vnd.stardivision.draw', - 'sdc' => 'application/vnd.stardivision.calc', - 'sdd' => 'application/vnd.stardivision.impress', - 'sdkd' => 'application/vnd.solent.sdkm+xml', - 'sdkm' => 'application/vnd.solent.sdkm+xml', - 'sdp' => 'application/sdp', - 'sdw' => 'application/vnd.stardivision.writer', - 'see' => 'application/vnd.seemail', - 'seed' => 'application/vnd.fdsn.seed', - 'sema' => 'application/vnd.sema', - 'semd' => 'application/vnd.semd', - 'semf' => 'application/vnd.semf', - 'ser' => 'application/java-serialized-object', - 'setpay' => 'application/set-payment-initiation', - 'setreg' => 'application/set-registration-initiation', - 'sfd-hdstx' => 'application/vnd.hydrostatix.sof-data', - 'sfs' => 'application/vnd.spotfire.sfs', - 'sfv' => 'text/x-sfv', - 'sgi' => 'image/sgi', - 'sgl' => 'application/vnd.stardivision.writer-global', - 'sgm' => 'text/sgml', - 'sgml' => 'text/sgml', - 'sh' => 'application/x-sh', - 'shar' => 'application/x-shar', - 'shf' => 'application/shf+xml', - 'sid' => 'image/x-mrsid-image', - 'sig' => 'application/pgp-signature', - 'sil' => 'audio/silk', - 'silo' => 'model/mesh', - 'sis' => 'application/vnd.symbian.install', - 'sisx' => 'application/vnd.symbian.install', - 'sit' => 'application/x-stuffit', - 'sitx' => 'application/x-stuffitx', - 'skd' => 'application/vnd.koan', - 'skm' => 'application/vnd.koan', - 'skp' => 'application/vnd.koan', - 'skt' => 'application/vnd.koan', - 'sldm' => 'application/vnd.ms-powerpoint.slide.macroenabled.12', - 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide', - 'slt' => 'application/vnd.epson.salt', - 'sm' => 'application/vnd.stepmania.stepchart', - 'smf' => 'application/vnd.stardivision.math', - 'smi' => 'application/smil+xml', - 'smil' => 'application/smil+xml', - 'smv' => 'video/x-smv', - 'smzip' => 'application/vnd.stepmania.package', - 'snd' => 'audio/basic', - 'snf' => 'application/x-font-snf', - 'so' => 'application/octet-stream', - 'spc' => 'application/x-pkcs7-certificates', - 'spf' => 'application/vnd.yamaha.smaf-phrase', - 'spl' => 'application/x-futuresplash', - 'spot' => 'text/vnd.in3d.spot', - 'spp' => 'application/scvp-vp-response', - 'spq' => 'application/scvp-vp-request', - 'spx' => 'audio/ogg', - 'sql' => 'application/x-sql', - 'src' => 'application/x-wais-source', - 'srt' => 'application/x-subrip', - 'sru' => 'application/sru+xml', - 'srx' => 'application/sparql-results+xml', - 'ssdl' => 'application/ssdl+xml', - 'sse' => 'application/vnd.kodak-descriptor', - 'ssf' => 'application/vnd.epson.ssf', - 'ssml' => 'application/ssml+xml', - 'st' => 'application/vnd.sailingtracker.track', - 'stc' => 'application/vnd.sun.xml.calc.template', - 'std' => 'application/vnd.sun.xml.draw.template', - 'stf' => 'application/vnd.wt.stf', - 'sti' => 'application/vnd.sun.xml.impress.template', - 'stk' => 'application/hyperstudio', - 'stl' => 'application/vnd.ms-pki.stl', - 'str' => 'application/vnd.pg.format', - 'stw' => 'application/vnd.sun.xml.writer.template', - 'sub' => 'text/vnd.dvb.subtitle', - 'sus' => 'application/vnd.sus-calendar', - 'susp' => 'application/vnd.sus-calendar', - 'sv4cpio' => 'application/x-sv4cpio', - 'sv4crc' => 'application/x-sv4crc', - 'svc' => 'application/vnd.dvb.service', - 'svd' => 'application/vnd.svd', - 'svg' => 'image/svg+xml', - 'svgz' => 'image/svg+xml', - 'swa' => 'application/x-director', - 'swf' => 'application/x-shockwave-flash', - 'swi' => 'application/vnd.aristanetworks.swi', - 'sxc' => 'application/vnd.sun.xml.calc', - 'sxd' => 'application/vnd.sun.xml.draw', - 'sxg' => 'application/vnd.sun.xml.writer.global', - 'sxi' => 'application/vnd.sun.xml.impress', - 'sxm' => 'application/vnd.sun.xml.math', - 'sxw' => 'application/vnd.sun.xml.writer', - 't' => 'text/troff', - 't3' => 'application/x-t3vm-image', - 'taglet' => 'application/vnd.mynfc', - 'tao' => 'application/vnd.tao.intent-module-archive', - 'tar' => 'application/x-tar', - 'tcap' => 'application/vnd.3gpp2.tcap', - 'tcl' => 'application/x-tcl', - 'teacher' => 'application/vnd.smart.teacher', - 'tei' => 'application/tei+xml', - 'teicorpus' => 'application/tei+xml', - 'tex' => 'application/x-tex', - 'texi' => 'application/x-texinfo', - 'texinfo' => 'application/x-texinfo', - 'text' => 'text/plain', - 'tfi' => 'application/thraud+xml', - 'tfm' => 'application/x-tex-tfm', - 'tga' => 'image/x-tga', - 'thmx' => 'application/vnd.ms-officetheme', - 'tif' => 'image/tiff', - 'tiff' => 'image/tiff', - 'tmo' => 'application/vnd.tmobile-livetv', - 'torrent' => 'application/x-bittorrent', - 'tpl' => 'application/vnd.groove-tool-template', - 'tpt' => 'application/vnd.trid.tpt', - 'tr' => 'text/troff', - 'tra' => 'application/vnd.trueapp', - 'trm' => 'application/x-msterminal', - 'tsd' => 'application/timestamped-data', - 'tsv' => 'text/tab-separated-values', - 'ttc' => 'application/x-font-ttf', - 'ttf' => 'application/x-font-ttf', - 'ttl' => 'text/turtle', - 'twd' => 'application/vnd.simtech-mindmapper', - 'twds' => 'application/vnd.simtech-mindmapper', - 'txd' => 'application/vnd.genomatix.tuxedo', - 'txf' => 'application/vnd.mobius.txf', - 'txt' => 'text/plain', - 'u32' => 'application/x-authorware-bin', - 'udeb' => 'application/x-debian-package', - 'ufd' => 'application/vnd.ufdl', - 'ufdl' => 'application/vnd.ufdl', - 'ulx' => 'application/x-glulx', - 'umj' => 'application/vnd.umajin', - 'unityweb' => 'application/vnd.unity', - 'uoml' => 'application/vnd.uoml+xml', - 'uri' => 'text/uri-list', - 'uris' => 'text/uri-list', - 'urls' => 'text/uri-list', - 'ustar' => 'application/x-ustar', - 'utz' => 'application/vnd.uiq.theme', - 'uu' => 'text/x-uuencode', - 'uva' => 'audio/vnd.dece.audio', - 'uvd' => 'application/vnd.dece.data', - 'uvf' => 'application/vnd.dece.data', - 'uvg' => 'image/vnd.dece.graphic', - 'uvh' => 'video/vnd.dece.hd', - 'uvi' => 'image/vnd.dece.graphic', - 'uvm' => 'video/vnd.dece.mobile', - 'uvp' => 'video/vnd.dece.pd', - 'uvs' => 'video/vnd.dece.sd', - 'uvt' => 'application/vnd.dece.ttml+xml', - 'uvu' => 'video/vnd.uvvu.mp4', - 'uvv' => 'video/vnd.dece.video', - 'uvva' => 'audio/vnd.dece.audio', - 'uvvd' => 'application/vnd.dece.data', - 'uvvf' => 'application/vnd.dece.data', - 'uvvg' => 'image/vnd.dece.graphic', - 'uvvh' => 'video/vnd.dece.hd', - 'uvvi' => 'image/vnd.dece.graphic', - 'uvvm' => 'video/vnd.dece.mobile', - 'uvvp' => 'video/vnd.dece.pd', - 'uvvs' => 'video/vnd.dece.sd', - 'uvvt' => 'application/vnd.dece.ttml+xml', - 'uvvu' => 'video/vnd.uvvu.mp4', - 'uvvv' => 'video/vnd.dece.video', - 'uvvx' => 'application/vnd.dece.unspecified', - 'uvvz' => 'application/vnd.dece.zip', - 'uvx' => 'application/vnd.dece.unspecified', - 'uvz' => 'application/vnd.dece.zip', - 'vcard' => 'text/vcard', - 'vcd' => 'application/x-cdlink', - 'vcf' => 'text/x-vcard', - 'vcg' => 'application/vnd.groove-vcard', - 'vcs' => 'text/x-vcalendar', - 'vcx' => 'application/vnd.vcx', - 'vis' => 'application/vnd.visionary', - 'viv' => 'video/vnd.vivo', - 'vob' => 'video/x-ms-vob', - 'vor' => 'application/vnd.stardivision.writer', - 'vox' => 'application/x-authorware-bin', - 'vrml' => 'model/vrml', - 'vsd' => 'application/vnd.visio', - 'vsf' => 'application/vnd.vsf', - 'vss' => 'application/vnd.visio', - 'vst' => 'application/vnd.visio', - 'vsw' => 'application/vnd.visio', - 'vtu' => 'model/vnd.vtu', - 'vxml' => 'application/voicexml+xml', - 'w3d' => 'application/x-director', - 'wad' => 'application/x-doom', - 'wav' => 'audio/x-wav', - 'wax' => 'audio/x-ms-wax', - 'wbmp' => 'image/vnd.wap.wbmp', - 'wbs' => 'application/vnd.criticaltools.wbs+xml', - 'wbxml' => 'application/vnd.wap.wbxml', - 'wcm' => 'application/vnd.ms-works', - 'wdb' => 'application/vnd.ms-works', - 'wdp' => 'image/vnd.ms-photo', - 'weba' => 'audio/webm', - 'webm' => 'video/webm', - 'webp' => 'image/webp', - 'wg' => 'application/vnd.pmi.widget', - 'wgt' => 'application/widget', - 'wks' => 'application/vnd.ms-works', - 'wm' => 'video/x-ms-wm', - 'wma' => 'audio/x-ms-wma', - 'wmd' => 'application/x-ms-wmd', - 'wmf' => 'application/x-msmetafile', - 'wml' => 'text/vnd.wap.wml', - 'wmlc' => 'application/vnd.wap.wmlc', - 'wmls' => 'text/vnd.wap.wmlscript', - 'wmlsc' => 'application/vnd.wap.wmlscriptc', - 'wmv' => 'video/x-ms-wmv', - 'wmx' => 'video/x-ms-wmx', - 'wmz' => 'application/x-msmetafile', - 'woff' => 'application/font-woff', - 'wpd' => 'application/vnd.wordperfect', - 'wpl' => 'application/vnd.ms-wpl', - 'wps' => 'application/vnd.ms-works', - 'wqd' => 'application/vnd.wqd', - 'wri' => 'application/x-mswrite', - 'wrl' => 'model/vrml', - 'wsdl' => 'application/wsdl+xml', - 'wspolicy' => 'application/wspolicy+xml', - 'wtb' => 'application/vnd.webturbo', - 'wvx' => 'video/x-ms-wvx', - 'x32' => 'application/x-authorware-bin', - 'x3d' => 'model/x3d+xml', - 'x3db' => 'model/x3d+binary', - 'x3dbz' => 'model/x3d+binary', - 'x3dv' => 'model/x3d+vrml', - 'x3dvz' => 'model/x3d+vrml', - 'x3dz' => 'model/x3d+xml', - 'xaml' => 'application/xaml+xml', - 'xap' => 'application/x-silverlight-app', - 'xar' => 'application/vnd.xara', - 'xbap' => 'application/x-ms-xbap', - 'xbd' => 'application/vnd.fujixerox.docuworks.binder', - 'xbm' => 'image/x-xbitmap', - 'xdf' => 'application/xcap-diff+xml', - 'xdm' => 'application/vnd.syncml.dm+xml', - 'xdp' => 'application/vnd.adobe.xdp+xml', - 'xdssc' => 'application/dssc+xml', - 'xdw' => 'application/vnd.fujixerox.docuworks', - 'xenc' => 'application/xenc+xml', - 'xer' => 'application/patch-ops-error+xml', - 'xfdf' => 'application/vnd.adobe.xfdf', - 'xfdl' => 'application/vnd.xfdl', - 'xht' => 'application/xhtml+xml', - 'xhtml' => 'application/xhtml+xml', - 'xhvml' => 'application/xv+xml', - 'xif' => 'image/vnd.xiff', - 'xla' => 'application/vnd.ms-excel', - 'xlam' => 'application/vnd.ms-excel.addin.macroenabled.12', - 'xlc' => 'application/vnd.ms-excel', - 'xlf' => 'application/x-xliff+xml', - 'xlm' => 'application/vnd.ms-excel', - 'xls' => 'application/vnd.ms-excel', - 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroenabled.12', - 'xlsm' => 'application/vnd.ms-excel.sheet.macroenabled.12', - 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', - 'xlt' => 'application/vnd.ms-excel', - 'xltm' => 'application/vnd.ms-excel.template.macroenabled.12', - 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', - 'xlw' => 'application/vnd.ms-excel', - 'xm' => 'audio/xm', - 'xml' => 'application/xml', - 'xo' => 'application/vnd.olpc-sugar', - 'xop' => 'application/xop+xml', - 'xpi' => 'application/x-xpinstall', - 'xpl' => 'application/xproc+xml', - 'xpm' => 'image/x-xpixmap', - 'xpr' => 'application/vnd.is-xpr', - 'xps' => 'application/vnd.ms-xpsdocument', - 'xpw' => 'application/vnd.intercon.formnet', - 'xpx' => 'application/vnd.intercon.formnet', - 'xsl' => 'application/xml', - 'xslt' => 'application/xslt+xml', - 'xsm' => 'application/vnd.syncml+xml', - 'xspf' => 'application/xspf+xml', - 'xul' => 'application/vnd.mozilla.xul+xml', - 'xvm' => 'application/xv+xml', - 'xvml' => 'application/xv+xml', - 'xwd' => 'image/x-xwindowdump', - 'xyz' => 'chemical/x-xyz', - 'xz' => 'application/x-xz', - 'yang' => 'application/yang', - 'yin' => 'application/yin+xml', - 'z1' => 'application/x-zmachine', - 'z2' => 'application/x-zmachine', - 'z3' => 'application/x-zmachine', - 'z4' => 'application/x-zmachine', - 'z5' => 'application/x-zmachine', - 'z6' => 'application/x-zmachine', - 'z7' => 'application/x-zmachine', - 'z8' => 'application/x-zmachine', - 'zaz' => 'application/vnd.zzazz.deck+xml', - 'zip' => 'application/zip', - 'zir' => 'application/vnd.zul', - 'zirz' => 'application/vnd.zul', - 'zmm' => 'application/vnd.handheld-entertainment+xml', - '123' => 'application/vnd.lotus-1-2-3', + '3dml' => 'text/vnd.in3d.3dml', + '3ds' => 'image/x-3ds', + '3g2' => 'video/3gpp2', + '3gp' => 'video/3gpp', + '7z' => 'application/x-7z-compressed', + 'aab' => 'application/x-authorware-bin', + 'aac' => 'audio/x-aac', + 'aam' => 'application/x-authorware-map', + 'aas' => 'application/x-authorware-seg', + 'abw' => 'application/x-abiword', + 'ac' => 'application/pkix-attr-cert', + 'acc' => 'application/vnd.americandynamics.acc', + 'ace' => 'application/x-ace-compressed', + 'acu' => 'application/vnd.acucobol', + 'acutc' => 'application/vnd.acucorp', + 'adp' => 'audio/adpcm', + 'aep' => 'application/vnd.audiograph', + 'afm' => 'application/x-font-type1', + 'afp' => 'application/vnd.ibm.modcap', + 'ahead' => 'application/vnd.ahead.space', + 'ai' => 'application/postscript', + 'aif' => 'audio/x-aiff', + 'aifc' => 'audio/x-aiff', + 'aiff' => 'audio/x-aiff', + 'air' => 'application/vnd.adobe.air-application-installer-package+zip', + 'ait' => 'application/vnd.dvb.ait', + 'ami' => 'application/vnd.amiga.ami', + 'apk' => 'application/vnd.android.package-archive', + 'appcache' => 'text/cache-manifest', + 'apr' => 'application/vnd.lotus-approach', + 'aps' => 'application/postscript', + 'arc' => 'application/x-freearc', + 'asc' => 'application/pgp-signature', + 'asf' => 'video/x-ms-asf', + 'asm' => 'text/x-asm', + 'aso' => 'application/vnd.accpac.simply.aso', + 'asx' => 'video/x-ms-asf', + 'atc' => 'application/vnd.acucorp', + 'atom' => 'application/atom+xml', + 'atomcat' => 'application/atomcat+xml', + 'atomsvc' => 'application/atomsvc+xml', + 'atx' => 'application/vnd.antix.game-component', + 'au' => 'audio/basic', + 'avi' => 'video/x-msvideo', + 'aw' => 'application/applixware', + 'azf' => 'application/vnd.airzip.filesecure.azf', + 'azs' => 'application/vnd.airzip.filesecure.azs', + 'azw' => 'application/vnd.amazon.ebook', + 'bat' => 'application/x-msdownload', + 'bcpio' => 'application/x-bcpio', + 'bdf' => 'application/x-font-bdf', + 'bdm' => 'application/vnd.syncml.dm+wbxml', + 'bed' => 'application/vnd.realvnc.bed', + 'bh2' => 'application/vnd.fujitsu.oasysprs', + 'bin' => 'application/octet-stream', + 'blb' => 'application/x-blorb', + 'blorb' => 'application/x-blorb', + 'bmi' => 'application/vnd.bmi', + 'bmp' => 'image/bmp', + 'book' => 'application/vnd.framemaker', + 'box' => 'application/vnd.previewsystems.box', + 'boz' => 'application/x-bzip2', + 'bpk' => 'application/octet-stream', + 'btif' => 'image/prs.btif', + 'bz' => 'application/x-bzip', + 'bz2' => 'application/x-bzip2', + 'c' => 'text/x-c', + 'c11amc' => 'application/vnd.cluetrust.cartomobile-config', + 'c11amz' => 'application/vnd.cluetrust.cartomobile-config-pkg', + 'c4d' => 'application/vnd.clonk.c4group', + 'c4f' => 'application/vnd.clonk.c4group', + 'c4g' => 'application/vnd.clonk.c4group', + 'c4p' => 'application/vnd.clonk.c4group', + 'c4u' => 'application/vnd.clonk.c4group', + 'cab' => 'application/vnd.ms-cab-compressed', + 'caf' => 'audio/x-caf', + 'cap' => 'application/vnd.tcpdump.pcap', + 'car' => 'application/vnd.curl.car', + 'cat' => 'application/vnd.ms-pki.seccat', + 'cb7' => 'application/x-cbr', + 'cba' => 'application/x-cbr', + 'cbr' => 'application/x-cbr', + 'cbt' => 'application/x-cbr', + 'cbz' => 'application/x-cbr', + 'cc' => 'text/x-c', + 'cct' => 'application/x-director', + 'ccxml' => 'application/ccxml+xml', + 'cdbcmsg' => 'application/vnd.contact.cmsg', + 'cdf' => 'application/x-netcdf', + 'cdkey' => 'application/vnd.mediastation.cdkey', + 'cdmia' => 'application/cdmi-capability', + 'cdmic' => 'application/cdmi-container', + 'cdmid' => 'application/cdmi-domain', + 'cdmio' => 'application/cdmi-object', + 'cdmiq' => 'application/cdmi-queue', + 'cdx' => 'chemical/x-cdx', + 'cdxml' => 'application/vnd.chemdraw+xml', + 'cdy' => 'application/vnd.cinderella', + 'cer' => 'application/pkix-cert', + 'cfs' => 'application/x-cfs-compressed', + 'cgm' => 'image/cgm', + 'chat' => 'application/x-chat', + 'chm' => 'application/vnd.ms-htmlhelp', + 'chrt' => 'application/vnd.kde.kchart', + 'cif' => 'chemical/x-cif', + 'cii' => 'application/vnd.anser-web-certificate-issue-initiation', + 'cil' => 'application/vnd.ms-artgalry', + 'cla' => 'application/vnd.claymore', + 'class' => 'application/java-vm', + 'clkk' => 'application/vnd.crick.clicker.keyboard', + 'clkp' => 'application/vnd.crick.clicker.palette', + 'clkt' => 'application/vnd.crick.clicker.template', + 'clkw' => 'application/vnd.crick.clicker.wordbank', + 'clkx' => 'application/vnd.crick.clicker', + 'clp' => 'application/x-msclip', + 'cmc' => 'application/vnd.cosmocaller', + 'cmdf' => 'chemical/x-cmdf', + 'cml' => 'chemical/x-cml', + 'cmp' => 'application/vnd.yellowriver-custom-menu', + 'cmx' => 'image/x-cmx', + 'cod' => 'application/vnd.rim.cod', + 'com' => 'application/x-msdownload', + 'conf' => 'text/plain', + 'cpio' => 'application/x-cpio', + 'cpp' => 'text/x-c', + 'cpt' => 'application/mac-compactpro', + 'crd' => 'application/x-mscardfile', + 'crl' => 'application/pkix-crl', + 'crt' => 'application/x-x509-ca-cert', + 'csh' => 'application/x-csh', + 'csml' => 'chemical/x-csml', + 'csp' => 'application/vnd.commonspace', + 'css' => 'text/css', + 'cst' => 'application/x-director', + 'csv' => 'text/csv', + 'cu' => 'application/cu-seeme', + 'curl' => 'text/vnd.curl', + 'cww' => 'application/prs.cww', + 'cxt' => 'application/x-director', + 'cxx' => 'text/x-c', + 'dae' => 'model/vnd.collada+xml', + 'daf' => 'application/vnd.mobius.daf', + 'dart' => 'application/vnd.dart', + 'dataless' => 'application/vnd.fdsn.seed', + 'davmount' => 'application/davmount+xml', + 'dbk' => 'application/docbook+xml', + 'dcr' => 'application/x-director', + 'dcurl' => 'text/vnd.curl.dcurl', + 'dd2' => 'application/vnd.oma.dd2+xml', + 'ddd' => 'application/vnd.fujixerox.ddd', + 'deb' => 'application/x-debian-package', + 'def' => 'text/plain', + 'deploy' => 'application/octet-stream', + 'der' => 'application/x-x509-ca-cert', + 'dfac' => 'application/vnd.dreamfactory', + 'dgc' => 'application/x-dgc-compressed', + 'dic' => 'text/x-c', + 'dir' => 'application/x-director', + 'dis' => 'application/vnd.mobius.dis', + 'dist' => 'application/octet-stream', + 'distz' => 'application/octet-stream', + 'djv' => 'image/vnd.djvu', + 'djvu' => 'image/vnd.djvu', + 'dll' => 'application/x-msdownload', + 'dmg' => 'application/x-apple-diskimage', + 'dmp' => 'application/vnd.tcpdump.pcap', + 'dms' => 'application/octet-stream', + 'dna' => 'application/vnd.dna', + 'doc' => 'application/msword', + 'docm' => 'application/vnd.ms-word.document.macroenabled.12', + 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'dot' => 'application/msword', + 'dotm' => 'application/vnd.ms-word.template.macroenabled.12', + 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', + 'dp' => 'application/vnd.osgi.dp', + 'dpg' => 'application/vnd.dpgraph', + 'dra' => 'audio/vnd.dra', + 'dsc' => 'text/prs.lines.tag', + 'dssc' => 'application/dssc+der', + 'dtb' => 'application/x-dtbook+xml', + 'dtd' => 'application/xml-dtd', + 'dts' => 'audio/vnd.dts', + 'dtshd' => 'audio/vnd.dts.hd', + 'dump' => 'application/octet-stream', + 'dvb' => 'video/vnd.dvb.file', + 'dvi' => 'application/x-dvi', + 'dwf' => 'model/vnd.dwf', + 'dwg' => 'image/vnd.dwg', + 'dxf' => 'image/vnd.dxf', + 'dxp' => 'application/vnd.spotfire.dxp', + 'dxr' => 'application/x-director', + 'ecelp4800' => 'audio/vnd.nuera.ecelp4800', + 'ecelp7470' => 'audio/vnd.nuera.ecelp7470', + 'ecelp9600' => 'audio/vnd.nuera.ecelp9600', + 'ecma' => 'application/ecmascript', + 'edm' => 'application/vnd.novadigm.edm', + 'edx' => 'application/vnd.novadigm.edx', + 'efif' => 'application/vnd.picsel', + 'ei6' => 'application/vnd.pg.osasli', + 'elc' => 'application/octet-stream', + 'emf' => 'application/x-msmetafile', + 'eml' => 'message/rfc822', + 'emma' => 'application/emma+xml', + 'emz' => 'application/x-msmetafile', + 'eol' => 'audio/vnd.digital-winds', + 'eot' => 'application/vnd.ms-fontobject', + 'eps' => 'application/postscript', + 'epub' => 'application/epub+zip', + 'es3' => 'application/vnd.eszigno3+xml', + 'esa' => 'application/vnd.osgi.subsystem', + 'esf' => 'application/vnd.epson.esf', + 'et3' => 'application/vnd.eszigno3+xml', + 'etx' => 'text/x-setext', + 'eva' => 'application/x-eva', + 'evy' => 'application/x-envoy', + 'exe' => 'application/x-msdownload', + 'exi' => 'application/exi', + 'ext' => 'application/vnd.novadigm.ext', + 'ez' => 'application/andrew-inset', + 'ez2' => 'application/vnd.ezpix-album', + 'ez3' => 'application/vnd.ezpix-package', + 'f' => 'text/x-fortran', + 'f4v' => 'video/x-f4v', + 'f77' => 'text/x-fortran', + 'f90' => 'text/x-fortran', + 'fbs' => 'image/vnd.fastbidsheet', + 'fcdt' => 'application/vnd.adobe.formscentral.fcdt', + 'fcs' => 'application/vnd.isac.fcs', + 'fdf' => 'application/vnd.fdf', + 'fe_launch' => 'application/vnd.denovo.fcselayout-link', + 'fg5' => 'application/vnd.fujitsu.oasysgp', + 'fgd' => 'application/x-director', + 'fh' => 'image/x-freehand', + 'fh4' => 'image/x-freehand', + 'fh5' => 'image/x-freehand', + 'fh7' => 'image/x-freehand', + 'fhc' => 'image/x-freehand', + 'fig' => 'application/x-xfig', + 'flac' => 'audio/x-flac', + 'fli' => 'video/x-fli', + 'flo' => 'application/vnd.micrografx.flo', + 'flv' => 'video/x-flv', + 'flw' => 'application/vnd.kde.kivio', + 'flx' => 'text/vnd.fmi.flexstor', + 'fly' => 'text/vnd.fly', + 'fm' => 'application/vnd.framemaker', + 'fnc' => 'application/vnd.frogans.fnc', + 'for' => 'text/x-fortran', + 'fpx' => 'image/vnd.fpx', + 'frame' => 'application/vnd.framemaker', + 'fsc' => 'application/vnd.fsc.weblaunch', + 'fst' => 'image/vnd.fst', + 'ftc' => 'application/vnd.fluxtime.clip', + 'fti' => 'application/vnd.anser-web-funds-transfer-initiation', + 'fvt' => 'video/vnd.fvt', + 'fxp' => 'application/vnd.adobe.fxp', + 'fxpl' => 'application/vnd.adobe.fxp', + 'fzs' => 'application/vnd.fuzzysheet', + 'g2w' => 'application/vnd.geoplan', + 'g3' => 'image/g3fax', + 'g3w' => 'application/vnd.geospace', + 'gac' => 'application/vnd.groove-account', + 'gam' => 'application/x-tads', + 'gbr' => 'application/rpki-ghostbusters', + 'gca' => 'application/x-gca-compressed', + 'gdl' => 'model/vnd.gdl', + 'geo' => 'application/vnd.dynageo', + 'gex' => 'application/vnd.geometry-explorer', + 'ggb' => 'application/vnd.geogebra.file', + 'ggt' => 'application/vnd.geogebra.tool', + 'ghf' => 'application/vnd.groove-help', + 'gif' => 'image/gif', + 'gim' => 'application/vnd.groove-identity-message', + 'gml' => 'application/gml+xml', + 'gmx' => 'application/vnd.gmx', + 'gnumeric' => 'application/x-gnumeric', + 'gph' => 'application/vnd.flographit', + 'gpx' => 'application/gpx+xml', + 'gqf' => 'application/vnd.grafeq', + 'gqs' => 'application/vnd.grafeq', + 'gram' => 'application/srgs', + 'gramps' => 'application/x-gramps-xml', + 'gre' => 'application/vnd.geometry-explorer', + 'grv' => 'application/vnd.groove-injector', + 'grxml' => 'application/srgs+xml', + 'gsf' => 'application/x-font-ghostscript', + 'gtar' => 'application/x-gtar', + 'gtm' => 'application/vnd.groove-tool-message', + 'gtw' => 'model/vnd.gtw', + 'gv' => 'text/vnd.graphviz', + 'gxf' => 'application/gxf', + 'gxt' => 'application/vnd.geonext', + 'gz' => 'application/x-gzip', + 'h' => 'text/x-c', + 'h261' => 'video/h261', + 'h263' => 'video/h263', + 'h264' => 'video/h264', + 'hal' => 'application/vnd.hal+xml', + 'hbci' => 'application/vnd.hbci', + 'hdf' => 'application/x-hdf', + 'hh' => 'text/x-c', + 'hlp' => 'application/winhlp', + 'hpgl' => 'application/vnd.hp-hpgl', + 'hpid' => 'application/vnd.hp-hpid', + 'hps' => 'application/vnd.hp-hps', + 'hqx' => 'application/mac-binhex40', + 'htke' => 'application/vnd.kenameaapp', + 'htm' => 'text/html', + 'html' => 'text/html', + 'hvd' => 'application/vnd.yamaha.hv-dic', + 'hvp' => 'application/vnd.yamaha.hv-voice', + 'hvs' => 'application/vnd.yamaha.hv-script', + 'i2g' => 'application/vnd.intergeo', + 'icc' => 'application/vnd.iccprofile', + 'ice' => 'x-conference/x-cooltalk', + 'icm' => 'application/vnd.iccprofile', + 'ico' => 'image/x-icon', + 'ics' => 'text/calendar', + 'ief' => 'image/ief', + 'ifb' => 'text/calendar', + 'ifm' => 'application/vnd.shana.informed.formdata', + 'iges' => 'model/iges', + 'igl' => 'application/vnd.igloader', + 'igm' => 'application/vnd.insors.igm', + 'igs' => 'model/iges', + 'igx' => 'application/vnd.micrografx.igx', + 'iif' => 'application/vnd.shana.informed.interchange', + 'imp' => 'application/vnd.accpac.simply.imp', + 'ims' => 'application/vnd.ms-ims', + 'in' => 'text/plain', + 'ink' => 'application/inkml+xml', + 'inkml' => 'application/inkml+xml', + 'install' => 'application/x-install-instructions', + 'iota' => 'application/vnd.astraea-software.iota', + 'ipfix' => 'application/ipfix', + 'ipk' => 'application/vnd.shana.informed.package', + 'irm' => 'application/vnd.ibm.rights-management', + 'irp' => 'application/vnd.irepository.package+xml', + 'iso' => 'application/x-iso9660-image', + 'itp' => 'application/vnd.shana.informed.formtemplate', + 'ivp' => 'application/vnd.immervision-ivp', + 'ivu' => 'application/vnd.immervision-ivu', + 'jad' => 'text/vnd.sun.j2me.app-descriptor', + 'jam' => 'application/vnd.jam', + 'jar' => 'application/java-archive', + 'java' => 'text/x-java-source', + 'jisp' => 'application/vnd.jisp', + 'jlt' => 'application/vnd.hp-jlyt', + 'jnlp' => 'application/x-java-jnlp-file', + 'joda' => 'application/vnd.joost.joda-archive', + 'jpe' => 'image/jpeg', + 'jpeg' => 'image/jpeg', + 'jpg' => 'image/jpeg', + 'jpgm' => 'video/jpm', + 'jpgv' => 'video/jpeg', + 'jpm' => 'video/jpm', + 'js' => 'application/javascript', + 'json' => 'application/json', + 'jsonml' => 'application/jsonml+json', + 'kar' => 'audio/midi', + 'karbon' => 'application/vnd.kde.karbon', + 'kfo' => 'application/vnd.kde.kformula', + 'kia' => 'application/vnd.kidspiration', + 'kml' => 'application/vnd.google-earth.kml+xml', + 'kmz' => 'application/vnd.google-earth.kmz', + 'kne' => 'application/vnd.kinar', + 'knp' => 'application/vnd.kinar', + 'kon' => 'application/vnd.kde.kontour', + 'kpr' => 'application/vnd.kde.kpresenter', + 'kpt' => 'application/vnd.kde.kpresenter', + 'kpxx' => 'application/vnd.ds-keypoint', + 'ksp' => 'application/vnd.kde.kspread', + 'ktr' => 'application/vnd.kahootz', + 'ktx' => 'image/ktx', + 'ktz' => 'application/vnd.kahootz', + 'kwd' => 'application/vnd.kde.kword', + 'kwt' => 'application/vnd.kde.kword', + 'lasxml' => 'application/vnd.las.las+xml', + 'latex' => 'application/x-latex', + 'lbd' => 'application/vnd.llamagraphics.life-balance.desktop', + 'lbe' => 'application/vnd.llamagraphics.life-balance.exchange+xml', + 'les' => 'application/vnd.hhe.lesson-player', + 'lha' => 'application/x-lzh-compressed', + 'link66' => 'application/vnd.route66.link66+xml', + 'list' => 'text/plain', + 'list3820' => 'application/vnd.ibm.modcap', + 'listafp' => 'application/vnd.ibm.modcap', + 'lnk' => 'application/x-ms-shortcut', + 'log' => 'text/plain', + 'lostxml' => 'application/lost+xml', + 'lrf' => 'application/octet-stream', + 'lrm' => 'application/vnd.ms-lrm', + 'ltf' => 'application/vnd.frogans.ltf', + 'lvp' => 'audio/vnd.lucent.voice', + 'lwp' => 'application/vnd.lotus-wordpro', + 'lzh' => 'application/x-lzh-compressed', + 'm13' => 'application/x-msmediaview', + 'm14' => 'application/x-msmediaview', + 'm1v' => 'video/mpeg', + 'm21' => 'application/mp21', + 'm2a' => 'audio/mpeg', + 'm2v' => 'video/mpeg', + 'm3a' => 'audio/mpeg', + 'm3u' => 'audio/x-mpegurl', + 'm3u8' => 'application/vnd.apple.mpegurl', + 'm4a' => 'audio/mp4', + 'm4u' => 'video/vnd.mpegurl', + 'm4v' => 'video/x-m4v', + 'ma' => 'application/mathematica', + 'mads' => 'application/mads+xml', + 'mag' => 'application/vnd.ecowin.chart', + 'maker' => 'application/vnd.framemaker', + 'man' => 'text/troff', + 'mar' => 'application/octet-stream', + 'mathml' => 'application/mathml+xml', + 'mb' => 'application/mathematica', + 'mbk' => 'application/vnd.mobius.mbk', + 'mbox' => 'application/mbox', + 'mc1' => 'application/vnd.medcalcdata', + 'mcd' => 'application/vnd.mcd', + 'mcurl' => 'text/vnd.curl.mcurl', + 'mdb' => 'application/x-msaccess', + 'mdi' => 'image/vnd.ms-modi', + 'me' => 'text/troff', + 'mesh' => 'model/mesh', + 'meta4' => 'application/metalink4+xml', + 'metalink' => 'application/metalink+xml', + 'mets' => 'application/mets+xml', + 'mfm' => 'application/vnd.mfmp', + 'mft' => 'application/rpki-manifest', + 'mgp' => 'application/vnd.osgeo.mapguide.package', + 'mgz' => 'application/vnd.proteus.magazine', + 'mid' => 'audio/midi', + 'midi' => 'audio/midi', + 'mie' => 'application/x-mie', + 'mif' => 'application/vnd.mif', + 'mime' => 'message/rfc822', + 'mj2' => 'video/mj2', + 'mjp2' => 'video/mj2', + 'mk3d' => 'video/x-matroska', + 'mka' => 'audio/x-matroska', + 'mks' => 'video/x-matroska', + 'mkv' => 'video/x-matroska', + 'mlp' => 'application/vnd.dolby.mlp', + 'mmd' => 'application/vnd.chipnuts.karaoke-mmd', + 'mmf' => 'application/vnd.smaf', + 'mmr' => 'image/vnd.fujixerox.edmics-mmr', + 'mng' => 'video/x-mng', + 'mny' => 'application/x-msmoney', + 'mobi' => 'application/x-mobipocket-ebook', + 'mods' => 'application/mods+xml', + 'mov' => 'video/quicktime', + 'movie' => 'video/x-sgi-movie', + 'mp2' => 'audio/mpeg', + 'mp21' => 'application/mp21', + 'mp2a' => 'audio/mpeg', + 'mp3' => 'audio/mpeg', + 'mp4' => 'video/mp4', + 'mp4a' => 'audio/mp4', + 'mp4s' => 'application/mp4', + 'mp4v' => 'video/mp4', + 'mpc' => 'application/vnd.mophun.certificate', + 'mpe' => 'video/mpeg', + 'mpeg' => 'video/mpeg', + 'mpg' => 'video/mpeg', + 'mpg4' => 'video/mp4', + 'mpga' => 'audio/mpeg', + 'mpkg' => 'application/vnd.apple.installer+xml', + 'mpm' => 'application/vnd.blueice.multipass', + 'mpn' => 'application/vnd.mophun.application', + 'mpp' => 'application/vnd.ms-project', + 'mpt' => 'application/vnd.ms-project', + 'mpy' => 'application/vnd.ibm.minipay', + 'mqy' => 'application/vnd.mobius.mqy', + 'mrc' => 'application/marc', + 'mrcx' => 'application/marcxml+xml', + 'ms' => 'text/troff', + 'mscml' => 'application/mediaservercontrol+xml', + 'mseed' => 'application/vnd.fdsn.mseed', + 'mseq' => 'application/vnd.mseq', + 'msf' => 'application/vnd.epson.msf', + 'msh' => 'model/mesh', + 'msi' => 'application/x-msdownload', + 'msl' => 'application/vnd.mobius.msl', + 'msty' => 'application/vnd.muvee.style', + 'mts' => 'model/vnd.mts', + 'mus' => 'application/vnd.musician', + 'musicxml' => 'application/vnd.recordare.musicxml+xml', + 'mvb' => 'application/x-msmediaview', + 'mwf' => 'application/vnd.mfer', + 'mxf' => 'application/mxf', + 'mxl' => 'application/vnd.recordare.musicxml', + 'mxml' => 'application/xv+xml', + 'mxs' => 'application/vnd.triscape.mxs', + 'mxu' => 'video/vnd.mpegurl', + 'n-gage' => 'application/vnd.nokia.n-gage.symbian.install', + 'n3' => 'text/n3', + 'nb' => 'application/mathematica', + 'nbp' => 'application/vnd.wolfram.player', + 'nc' => 'application/x-netcdf', + 'ncx' => 'application/x-dtbncx+xml', + 'nfo' => 'text/x-nfo', + 'ngdat' => 'application/vnd.nokia.n-gage.data', + 'nitf' => 'application/vnd.nitf', + 'nlu' => 'application/vnd.neurolanguage.nlu', + 'nml' => 'application/vnd.enliven', + 'nnd' => 'application/vnd.noblenet-directory', + 'nns' => 'application/vnd.noblenet-sealer', + 'nnw' => 'application/vnd.noblenet-web', + 'npx' => 'image/vnd.net-fpx', + 'nsc' => 'application/x-conference', + 'nsf' => 'application/vnd.lotus-notes', + 'ntf' => 'application/vnd.nitf', + 'nzb' => 'application/x-nzb', + 'oa2' => 'application/vnd.fujitsu.oasys2', + 'oa3' => 'application/vnd.fujitsu.oasys3', + 'oas' => 'application/vnd.fujitsu.oasys', + 'obd' => 'application/x-msbinder', + 'obj' => 'application/x-tgif', + 'oda' => 'application/oda', + 'odb' => 'application/vnd.oasis.opendocument.database', + 'odc' => 'application/vnd.oasis.opendocument.chart', + 'odf' => 'application/vnd.oasis.opendocument.formula', + 'odft' => 'application/vnd.oasis.opendocument.formula-template', + 'odg' => 'application/vnd.oasis.opendocument.graphics', + 'odi' => 'application/vnd.oasis.opendocument.image', + 'odm' => 'application/vnd.oasis.opendocument.text-master', + 'odp' => 'application/vnd.oasis.opendocument.presentation', + 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', + 'odt' => 'application/vnd.oasis.opendocument.text', + 'oga' => 'audio/ogg', + 'ogg' => 'audio/ogg', + 'ogv' => 'video/ogg', + 'ogx' => 'application/ogg', + 'omdoc' => 'application/omdoc+xml', + 'onepkg' => 'application/onenote', + 'onetmp' => 'application/onenote', + 'onetoc' => 'application/onenote', + 'onetoc2' => 'application/onenote', + 'opf' => 'application/oebps-package+xml', + 'opml' => 'text/x-opml', + 'oprc' => 'application/vnd.palm', + 'org' => 'application/vnd.lotus-organizer', + 'osf' => 'application/vnd.yamaha.openscoreformat', + 'osfpvg' => 'application/vnd.yamaha.openscoreformat.osfpvg+xml', + 'otc' => 'application/vnd.oasis.opendocument.chart-template', + 'otf' => 'application/x-font-otf', + 'otg' => 'application/vnd.oasis.opendocument.graphics-template', + 'oth' => 'application/vnd.oasis.opendocument.text-web', + 'oti' => 'application/vnd.oasis.opendocument.image-template', + 'otp' => 'application/vnd.oasis.opendocument.presentation-template', + 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template', + 'ott' => 'application/vnd.oasis.opendocument.text-template', + 'oxps' => 'application/oxps', + 'oxt' => 'application/vnd.openofficeorg.extension', + 'p' => 'text/x-pascal', + 'p10' => 'application/pkcs10', + 'p12' => 'application/x-pkcs12', + 'p7b' => 'application/x-pkcs7-certificates', + 'p7c' => 'application/pkcs7-mime', + 'p7m' => 'application/pkcs7-mime', + 'p7r' => 'application/x-pkcs7-certreqresp', + 'p7s' => 'application/pkcs7-signature', + 'p8' => 'application/pkcs8', + 'pas' => 'text/x-pascal', + 'paw' => 'application/vnd.pawaafile', + 'pbd' => 'application/vnd.powerbuilder6', + 'pbm' => 'image/x-portable-bitmap', + 'pcap' => 'application/vnd.tcpdump.pcap', + 'pcf' => 'application/x-font-pcf', + 'pcl' => 'application/vnd.hp-pcl', + 'pclxl' => 'application/vnd.hp-pclxl', + 'pct' => 'image/x-pict', + 'pcurl' => 'application/vnd.curl.pcurl', + 'pcx' => 'image/x-pcx', + 'pdb' => 'application/vnd.palm', + 'pdf' => 'application/pdf', + 'pfa' => 'application/x-font-type1', + 'pfb' => 'application/x-font-type1', + 'pfm' => 'application/x-font-type1', + 'pfr' => 'application/font-tdpfr', + 'pfx' => 'application/x-pkcs12', + 'pgm' => 'image/x-portable-graymap', + 'pgn' => 'application/x-chess-pgn', + 'pgp' => 'application/pgp-encrypted', + 'php' => 'application/x-php', + 'php3' => 'application/x-php', + 'php4' => 'application/x-php', + 'php5' => 'application/x-php', + 'pic' => 'image/x-pict', + 'pkg' => 'application/octet-stream', + 'pki' => 'application/pkixcmp', + 'pkipath' => 'application/pkix-pkipath', + 'plb' => 'application/vnd.3gpp.pic-bw-large', + 'plc' => 'application/vnd.mobius.plc', + 'plf' => 'application/vnd.pocketlearn', + 'pls' => 'application/pls+xml', + 'pml' => 'application/vnd.ctc-posml', + 'png' => 'image/png', + 'pnm' => 'image/x-portable-anymap', + 'portpkg' => 'application/vnd.macports.portpkg', + 'pot' => 'application/vnd.ms-powerpoint', + 'potm' => 'application/vnd.ms-powerpoint.template.macroenabled.12', + 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template', + 'ppam' => 'application/vnd.ms-powerpoint.addin.macroenabled.12', + 'ppd' => 'application/vnd.cups-ppd', + 'ppm' => 'image/x-portable-pixmap', + 'pps' => 'application/vnd.ms-powerpoint', + 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroenabled.12', + 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', + 'ppt' => 'application/vnd.ms-powerpoint', + 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroenabled.12', + 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'pqa' => 'application/vnd.palm', + 'prc' => 'application/x-mobipocket-ebook', + 'pre' => 'application/vnd.lotus-freelance', + 'prf' => 'application/pics-rules', + 'ps' => 'application/postscript', + 'psb' => 'application/vnd.3gpp.pic-bw-small', + 'psd' => 'image/vnd.adobe.photoshop', + 'psf' => 'application/x-font-linux-psf', + 'pskcxml' => 'application/pskc+xml', + 'ptid' => 'application/vnd.pvi.ptid1', + 'pub' => 'application/x-mspublisher', + 'pvb' => 'application/vnd.3gpp.pic-bw-var', + 'pwn' => 'application/vnd.3m.post-it-notes', + 'pya' => 'audio/vnd.ms-playready.media.pya', + 'pyv' => 'video/vnd.ms-playready.media.pyv', + 'qam' => 'application/vnd.epson.quickanime', + 'qbo' => 'application/vnd.intu.qbo', + 'qfx' => 'application/vnd.intu.qfx', + 'qps' => 'application/vnd.publishare-delta-tree', + 'qt' => 'video/quicktime', + 'qwd' => 'application/vnd.quark.quarkxpress', + 'qwt' => 'application/vnd.quark.quarkxpress', + 'qxb' => 'application/vnd.quark.quarkxpress', + 'qxd' => 'application/vnd.quark.quarkxpress', + 'qxl' => 'application/vnd.quark.quarkxpress', + 'qxt' => 'application/vnd.quark.quarkxpress', + 'ra' => 'audio/x-pn-realaudio', + 'ram' => 'audio/x-pn-realaudio', + 'rar' => 'application/x-rar-compressed', + 'ras' => 'image/x-cmu-raster', + 'rcprofile' => 'application/vnd.ipunplugged.rcprofile', + 'rdf' => 'application/rdf+xml', + 'rdz' => 'application/vnd.data-vision.rdz', + 'rep' => 'application/vnd.businessobjects', + 'res' => 'application/x-dtbresource+xml', + 'rgb' => 'image/x-rgb', + 'rif' => 'application/reginfo+xml', + 'rip' => 'audio/vnd.rip', + 'ris' => 'application/x-research-info-systems', + 'rl' => 'application/resource-lists+xml', + 'rlc' => 'image/vnd.fujixerox.edmics-rlc', + 'rld' => 'application/resource-lists-diff+xml', + 'rm' => 'application/vnd.rn-realmedia', + 'rmi' => 'audio/midi', + 'rmp' => 'audio/x-pn-realaudio-plugin', + 'rms' => 'application/vnd.jcp.javame.midlet-rms', + 'rmvb' => 'application/vnd.rn-realmedia-vbr', + 'rnc' => 'application/relax-ng-compact-syntax', + 'roa' => 'application/rpki-roa', + 'roff' => 'text/troff', + 'rp9' => 'application/vnd.cloanto.rp9', + 'rpss' => 'application/vnd.nokia.radio-presets', + 'rpst' => 'application/vnd.nokia.radio-preset', + 'rq' => 'application/sparql-query', + 'rs' => 'application/rls-services+xml', + 'rsd' => 'application/rsd+xml', + 'rss' => 'application/rss+xml', + 'rtf' => 'application/rtf', + 'rtx' => 'text/richtext', + 's' => 'text/x-asm', + 's3m' => 'audio/s3m', + 'saf' => 'application/vnd.yamaha.smaf-audio', + 'sbml' => 'application/sbml+xml', + 'sc' => 'application/vnd.ibm.secure-container', + 'scd' => 'application/x-msschedule', + 'scm' => 'application/vnd.lotus-screencam', + 'scq' => 'application/scvp-cv-request', + 'scs' => 'application/scvp-cv-response', + 'scurl' => 'text/vnd.curl.scurl', + 'sda' => 'application/vnd.stardivision.draw', + 'sdc' => 'application/vnd.stardivision.calc', + 'sdd' => 'application/vnd.stardivision.impress', + 'sdkd' => 'application/vnd.solent.sdkm+xml', + 'sdkm' => 'application/vnd.solent.sdkm+xml', + 'sdp' => 'application/sdp', + 'sdw' => 'application/vnd.stardivision.writer', + 'see' => 'application/vnd.seemail', + 'seed' => 'application/vnd.fdsn.seed', + 'sema' => 'application/vnd.sema', + 'semd' => 'application/vnd.semd', + 'semf' => 'application/vnd.semf', + 'ser' => 'application/java-serialized-object', + 'setpay' => 'application/set-payment-initiation', + 'setreg' => 'application/set-registration-initiation', + 'sfd-hdstx' => 'application/vnd.hydrostatix.sof-data', + 'sfs' => 'application/vnd.spotfire.sfs', + 'sfv' => 'text/x-sfv', + 'sgi' => 'image/sgi', + 'sgl' => 'application/vnd.stardivision.writer-global', + 'sgm' => 'text/sgml', + 'sgml' => 'text/sgml', + 'sh' => 'application/x-sh', + 'shar' => 'application/x-shar', + 'shf' => 'application/shf+xml', + 'sid' => 'image/x-mrsid-image', + 'sig' => 'application/pgp-signature', + 'sil' => 'audio/silk', + 'silo' => 'model/mesh', + 'sis' => 'application/vnd.symbian.install', + 'sisx' => 'application/vnd.symbian.install', + 'sit' => 'application/x-stuffit', + 'sitx' => 'application/x-stuffitx', + 'skd' => 'application/vnd.koan', + 'skm' => 'application/vnd.koan', + 'skp' => 'application/vnd.koan', + 'skt' => 'application/vnd.koan', + 'sldm' => 'application/vnd.ms-powerpoint.slide.macroenabled.12', + 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide', + 'slt' => 'application/vnd.epson.salt', + 'sm' => 'application/vnd.stepmania.stepchart', + 'smf' => 'application/vnd.stardivision.math', + 'smi' => 'application/smil+xml', + 'smil' => 'application/smil+xml', + 'smv' => 'video/x-smv', + 'smzip' => 'application/vnd.stepmania.package', + 'snd' => 'audio/basic', + 'snf' => 'application/x-font-snf', + 'so' => 'application/octet-stream', + 'spc' => 'application/x-pkcs7-certificates', + 'spf' => 'application/vnd.yamaha.smaf-phrase', + 'spl' => 'application/x-futuresplash', + 'spot' => 'text/vnd.in3d.spot', + 'spp' => 'application/scvp-vp-response', + 'spq' => 'application/scvp-vp-request', + 'spx' => 'audio/ogg', + 'sql' => 'application/x-sql', + 'src' => 'application/x-wais-source', + 'srt' => 'application/x-subrip', + 'sru' => 'application/sru+xml', + 'srx' => 'application/sparql-results+xml', + 'ssdl' => 'application/ssdl+xml', + 'sse' => 'application/vnd.kodak-descriptor', + 'ssf' => 'application/vnd.epson.ssf', + 'ssml' => 'application/ssml+xml', + 'st' => 'application/vnd.sailingtracker.track', + 'stc' => 'application/vnd.sun.xml.calc.template', + 'std' => 'application/vnd.sun.xml.draw.template', + 'stf' => 'application/vnd.wt.stf', + 'sti' => 'application/vnd.sun.xml.impress.template', + 'stk' => 'application/hyperstudio', + 'stl' => 'application/vnd.ms-pki.stl', + 'str' => 'application/vnd.pg.format', + 'stw' => 'application/vnd.sun.xml.writer.template', + 'sub' => 'text/vnd.dvb.subtitle', + 'sus' => 'application/vnd.sus-calendar', + 'susp' => 'application/vnd.sus-calendar', + 'sv4cpio' => 'application/x-sv4cpio', + 'sv4crc' => 'application/x-sv4crc', + 'svc' => 'application/vnd.dvb.service', + 'svd' => 'application/vnd.svd', + 'svg' => 'image/svg+xml', + 'svgz' => 'image/svg+xml', + 'swa' => 'application/x-director', + 'swf' => 'application/x-shockwave-flash', + 'swi' => 'application/vnd.aristanetworks.swi', + 'sxc' => 'application/vnd.sun.xml.calc', + 'sxd' => 'application/vnd.sun.xml.draw', + 'sxg' => 'application/vnd.sun.xml.writer.global', + 'sxi' => 'application/vnd.sun.xml.impress', + 'sxm' => 'application/vnd.sun.xml.math', + 'sxw' => 'application/vnd.sun.xml.writer', + 't' => 'text/troff', + 't3' => 'application/x-t3vm-image', + 'taglet' => 'application/vnd.mynfc', + 'tao' => 'application/vnd.tao.intent-module-archive', + 'tar' => 'application/x-tar', + 'tcap' => 'application/vnd.3gpp2.tcap', + 'tcl' => 'application/x-tcl', + 'teacher' => 'application/vnd.smart.teacher', + 'tei' => 'application/tei+xml', + 'teicorpus' => 'application/tei+xml', + 'tex' => 'application/x-tex', + 'texi' => 'application/x-texinfo', + 'texinfo' => 'application/x-texinfo', + 'text' => 'text/plain', + 'tfi' => 'application/thraud+xml', + 'tfm' => 'application/x-tex-tfm', + 'tga' => 'image/x-tga', + 'thmx' => 'application/vnd.ms-officetheme', + 'tif' => 'image/tiff', + 'tiff' => 'image/tiff', + 'tmo' => 'application/vnd.tmobile-livetv', + 'torrent' => 'application/x-bittorrent', + 'tpl' => 'application/vnd.groove-tool-template', + 'tpt' => 'application/vnd.trid.tpt', + 'tr' => 'text/troff', + 'tra' => 'application/vnd.trueapp', + 'trm' => 'application/x-msterminal', + 'tsd' => 'application/timestamped-data', + 'tsv' => 'text/tab-separated-values', + 'ttc' => 'application/x-font-ttf', + 'ttf' => 'application/x-font-ttf', + 'ttl' => 'text/turtle', + 'twd' => 'application/vnd.simtech-mindmapper', + 'twds' => 'application/vnd.simtech-mindmapper', + 'txd' => 'application/vnd.genomatix.tuxedo', + 'txf' => 'application/vnd.mobius.txf', + 'txt' => 'text/plain', + 'u32' => 'application/x-authorware-bin', + 'udeb' => 'application/x-debian-package', + 'ufd' => 'application/vnd.ufdl', + 'ufdl' => 'application/vnd.ufdl', + 'ulx' => 'application/x-glulx', + 'umj' => 'application/vnd.umajin', + 'unityweb' => 'application/vnd.unity', + 'uoml' => 'application/vnd.uoml+xml', + 'uri' => 'text/uri-list', + 'uris' => 'text/uri-list', + 'urls' => 'text/uri-list', + 'ustar' => 'application/x-ustar', + 'utz' => 'application/vnd.uiq.theme', + 'uu' => 'text/x-uuencode', + 'uva' => 'audio/vnd.dece.audio', + 'uvd' => 'application/vnd.dece.data', + 'uvf' => 'application/vnd.dece.data', + 'uvg' => 'image/vnd.dece.graphic', + 'uvh' => 'video/vnd.dece.hd', + 'uvi' => 'image/vnd.dece.graphic', + 'uvm' => 'video/vnd.dece.mobile', + 'uvp' => 'video/vnd.dece.pd', + 'uvs' => 'video/vnd.dece.sd', + 'uvt' => 'application/vnd.dece.ttml+xml', + 'uvu' => 'video/vnd.uvvu.mp4', + 'uvv' => 'video/vnd.dece.video', + 'uvva' => 'audio/vnd.dece.audio', + 'uvvd' => 'application/vnd.dece.data', + 'uvvf' => 'application/vnd.dece.data', + 'uvvg' => 'image/vnd.dece.graphic', + 'uvvh' => 'video/vnd.dece.hd', + 'uvvi' => 'image/vnd.dece.graphic', + 'uvvm' => 'video/vnd.dece.mobile', + 'uvvp' => 'video/vnd.dece.pd', + 'uvvs' => 'video/vnd.dece.sd', + 'uvvt' => 'application/vnd.dece.ttml+xml', + 'uvvu' => 'video/vnd.uvvu.mp4', + 'uvvv' => 'video/vnd.dece.video', + 'uvvx' => 'application/vnd.dece.unspecified', + 'uvvz' => 'application/vnd.dece.zip', + 'uvx' => 'application/vnd.dece.unspecified', + 'uvz' => 'application/vnd.dece.zip', + 'vcard' => 'text/vcard', + 'vcd' => 'application/x-cdlink', + 'vcf' => 'text/x-vcard', + 'vcg' => 'application/vnd.groove-vcard', + 'vcs' => 'text/x-vcalendar', + 'vcx' => 'application/vnd.vcx', + 'vis' => 'application/vnd.visionary', + 'viv' => 'video/vnd.vivo', + 'vob' => 'video/x-ms-vob', + 'vor' => 'application/vnd.stardivision.writer', + 'vox' => 'application/x-authorware-bin', + 'vrml' => 'model/vrml', + 'vsd' => 'application/vnd.visio', + 'vsf' => 'application/vnd.vsf', + 'vss' => 'application/vnd.visio', + 'vst' => 'application/vnd.visio', + 'vsw' => 'application/vnd.visio', + 'vtu' => 'model/vnd.vtu', + 'vxml' => 'application/voicexml+xml', + 'w3d' => 'application/x-director', + 'wad' => 'application/x-doom', + 'wav' => 'audio/x-wav', + 'wax' => 'audio/x-ms-wax', + 'wbmp' => 'image/vnd.wap.wbmp', + 'wbs' => 'application/vnd.criticaltools.wbs+xml', + 'wbxml' => 'application/vnd.wap.wbxml', + 'wcm' => 'application/vnd.ms-works', + 'wdb' => 'application/vnd.ms-works', + 'wdp' => 'image/vnd.ms-photo', + 'weba' => 'audio/webm', + 'webm' => 'video/webm', + 'webp' => 'image/webp', + 'wg' => 'application/vnd.pmi.widget', + 'wgt' => 'application/widget', + 'wks' => 'application/vnd.ms-works', + 'wm' => 'video/x-ms-wm', + 'wma' => 'audio/x-ms-wma', + 'wmd' => 'application/x-ms-wmd', + 'wmf' => 'application/x-msmetafile', + 'wml' => 'text/vnd.wap.wml', + 'wmlc' => 'application/vnd.wap.wmlc', + 'wmls' => 'text/vnd.wap.wmlscript', + 'wmlsc' => 'application/vnd.wap.wmlscriptc', + 'wmv' => 'video/x-ms-wmv', + 'wmx' => 'video/x-ms-wmx', + 'wmz' => 'application/x-msmetafile', + 'woff' => 'application/font-woff', + 'wpd' => 'application/vnd.wordperfect', + 'wpl' => 'application/vnd.ms-wpl', + 'wps' => 'application/vnd.ms-works', + 'wqd' => 'application/vnd.wqd', + 'wri' => 'application/x-mswrite', + 'wrl' => 'model/vrml', + 'wsdl' => 'application/wsdl+xml', + 'wspolicy' => 'application/wspolicy+xml', + 'wtb' => 'application/vnd.webturbo', + 'wvx' => 'video/x-ms-wvx', + 'x32' => 'application/x-authorware-bin', + 'x3d' => 'model/x3d+xml', + 'x3db' => 'model/x3d+binary', + 'x3dbz' => 'model/x3d+binary', + 'x3dv' => 'model/x3d+vrml', + 'x3dvz' => 'model/x3d+vrml', + 'x3dz' => 'model/x3d+xml', + 'xaml' => 'application/xaml+xml', + 'xap' => 'application/x-silverlight-app', + 'xar' => 'application/vnd.xara', + 'xbap' => 'application/x-ms-xbap', + 'xbd' => 'application/vnd.fujixerox.docuworks.binder', + 'xbm' => 'image/x-xbitmap', + 'xdf' => 'application/xcap-diff+xml', + 'xdm' => 'application/vnd.syncml.dm+xml', + 'xdp' => 'application/vnd.adobe.xdp+xml', + 'xdssc' => 'application/dssc+xml', + 'xdw' => 'application/vnd.fujixerox.docuworks', + 'xenc' => 'application/xenc+xml', + 'xer' => 'application/patch-ops-error+xml', + 'xfdf' => 'application/vnd.adobe.xfdf', + 'xfdl' => 'application/vnd.xfdl', + 'xht' => 'application/xhtml+xml', + 'xhtml' => 'application/xhtml+xml', + 'xhvml' => 'application/xv+xml', + 'xif' => 'image/vnd.xiff', + 'xla' => 'application/vnd.ms-excel', + 'xlam' => 'application/vnd.ms-excel.addin.macroenabled.12', + 'xlc' => 'application/vnd.ms-excel', + 'xlf' => 'application/x-xliff+xml', + 'xlm' => 'application/vnd.ms-excel', + 'xls' => 'application/vnd.ms-excel', + 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroenabled.12', + 'xlsm' => 'application/vnd.ms-excel.sheet.macroenabled.12', + 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'xlt' => 'application/vnd.ms-excel', + 'xltm' => 'application/vnd.ms-excel.template.macroenabled.12', + 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', + 'xlw' => 'application/vnd.ms-excel', + 'xm' => 'audio/xm', + 'xml' => 'application/xml', + 'xo' => 'application/vnd.olpc-sugar', + 'xop' => 'application/xop+xml', + 'xpi' => 'application/x-xpinstall', + 'xpl' => 'application/xproc+xml', + 'xpm' => 'image/x-xpixmap', + 'xpr' => 'application/vnd.is-xpr', + 'xps' => 'application/vnd.ms-xpsdocument', + 'xpw' => 'application/vnd.intercon.formnet', + 'xpx' => 'application/vnd.intercon.formnet', + 'xsl' => 'application/xml', + 'xslt' => 'application/xslt+xml', + 'xsm' => 'application/vnd.syncml+xml', + 'xspf' => 'application/xspf+xml', + 'xul' => 'application/vnd.mozilla.xul+xml', + 'xvm' => 'application/xv+xml', + 'xvml' => 'application/xv+xml', + 'xwd' => 'image/x-xwindowdump', + 'xyz' => 'chemical/x-xyz', + 'xz' => 'application/x-xz', + 'yang' => 'application/yang', + 'yin' => 'application/yin+xml', + 'z1' => 'application/x-zmachine', + 'z2' => 'application/x-zmachine', + 'z3' => 'application/x-zmachine', + 'z4' => 'application/x-zmachine', + 'z5' => 'application/x-zmachine', + 'z6' => 'application/x-zmachine', + 'z7' => 'application/x-zmachine', + 'z8' => 'application/x-zmachine', + 'zaz' => 'application/vnd.zzazz.deck+xml', + 'zip' => 'application/zip', + 'zir' => 'application/vnd.zul', + 'zirz' => 'application/vnd.zul', + 'zmm' => 'application/vnd.handheld-entertainment+xml', + '123' => 'application/vnd.lotus-1-2-3', ]; diff --git a/htdocs/includes/swiftmailer/lib/swiftmailer_generate_mimes_config.php b/htdocs/includes/swiftmailer/lib/swiftmailer_generate_mimes_config.php index b3febce4802..ad8fd2aa0d5 100644 --- a/htdocs/includes/swiftmailer/lib/swiftmailer_generate_mimes_config.php +++ b/htdocs/includes/swiftmailer/lib/swiftmailer_generate_mimes_config.php @@ -6,177 +6,177 @@ function generateUpToDateMimeArray() { - $preamble = " 'application/x-php', - 'php3' => 'application/x-php', - 'php4' => 'application/x-php', - 'php5' => 'application/x-php', - 'zip' => 'application/zip', - 'gif' => 'image/gif', - 'png' => 'image/png', - 'css' => 'text/css', - 'js' => 'text/javascript', - 'txt' => 'text/plain', - 'aif' => 'audio/x-aiff', - 'aiff' => 'audio/x-aiff', - 'avi' => 'video/avi', - 'bmp' => 'image/bmp', - 'bz2' => 'application/x-bz2', - 'csv' => 'text/csv', - 'dmg' => 'application/x-apple-diskimage', - 'doc' => 'application/msword', - 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', - 'eml' => 'message/rfc822', - 'aps' => 'application/postscript', - 'exe' => 'application/x-ms-dos-executable', - 'flv' => 'video/x-flv', - 'gz' => 'application/x-gzip', - 'hqx' => 'application/stuffit', - 'htm' => 'text/html', - 'html' => 'text/html', - 'jar' => 'application/x-java-archive', - 'jpeg' => 'image/jpeg', - 'jpg' => 'image/jpeg', - 'm3u' => 'audio/x-mpegurl', - 'm4a' => 'audio/mp4', - 'mdb' => 'application/x-msaccess', - 'mid' => 'audio/midi', - 'midi' => 'audio/midi', - 'mov' => 'video/quicktime', - 'mp3' => 'audio/mpeg', - 'mp4' => 'video/mp4', - 'mpeg' => 'video/mpeg', - 'mpg' => 'video/mpeg', - 'odg' => 'vnd.oasis.opendocument.graphics', - 'odp' => 'vnd.oasis.opendocument.presentation', - 'odt' => 'vnd.oasis.opendocument.text', - 'ods' => 'vnd.oasis.opendocument.spreadsheet', - 'ogg' => 'audio/ogg', - 'pdf' => 'application/pdf', - 'ppt' => 'application/vnd.ms-powerpoint', - 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', - 'ps' => 'application/postscript', - 'rar' => 'application/x-rar-compressed', - 'rtf' => 'application/rtf', - 'tar' => 'application/x-tar', - 'sit' => 'application/x-stuffit', - 'svg' => 'image/svg+xml', - 'tif' => 'image/tiff', - 'tiff' => 'image/tiff', - 'ttf' => 'application/x-font-truetype', - 'vcf' => 'text/x-vcard', - 'wav' => 'audio/wav', - 'wma' => 'audio/x-ms-wma', - 'wmv' => 'audio/x-ms-wmv', - 'xls' => 'application/vnd.ms-excel', - 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', - 'xml' => 'application/xml', - ]; + // split mime type and extensions eg. "video/x-matroska mkv mk3d mks" + if (false !== preg_match_all('/^#?([a-z0-9\-\+\/\.]+)[\t]+(.*)$/miu', $mime_types, $matches)) { + // collection of predefined mimetypes (bugfix for wrong resolved or missing mime types) + $valid_mime_types_preset = [ + 'php' => 'application/x-php', + 'php3' => 'application/x-php', + 'php4' => 'application/x-php', + 'php5' => 'application/x-php', + 'zip' => 'application/zip', + 'gif' => 'image/gif', + 'png' => 'image/png', + 'css' => 'text/css', + 'js' => 'text/javascript', + 'txt' => 'text/plain', + 'aif' => 'audio/x-aiff', + 'aiff' => 'audio/x-aiff', + 'avi' => 'video/avi', + 'bmp' => 'image/bmp', + 'bz2' => 'application/x-bz2', + 'csv' => 'text/csv', + 'dmg' => 'application/x-apple-diskimage', + 'doc' => 'application/msword', + 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'eml' => 'message/rfc822', + 'aps' => 'application/postscript', + 'exe' => 'application/x-ms-dos-executable', + 'flv' => 'video/x-flv', + 'gz' => 'application/x-gzip', + 'hqx' => 'application/stuffit', + 'htm' => 'text/html', + 'html' => 'text/html', + 'jar' => 'application/x-java-archive', + 'jpeg' => 'image/jpeg', + 'jpg' => 'image/jpeg', + 'm3u' => 'audio/x-mpegurl', + 'm4a' => 'audio/mp4', + 'mdb' => 'application/x-msaccess', + 'mid' => 'audio/midi', + 'midi' => 'audio/midi', + 'mov' => 'video/quicktime', + 'mp3' => 'audio/mpeg', + 'mp4' => 'video/mp4', + 'mpeg' => 'video/mpeg', + 'mpg' => 'video/mpeg', + 'odg' => 'vnd.oasis.opendocument.graphics', + 'odp' => 'vnd.oasis.opendocument.presentation', + 'odt' => 'vnd.oasis.opendocument.text', + 'ods' => 'vnd.oasis.opendocument.spreadsheet', + 'ogg' => 'audio/ogg', + 'pdf' => 'application/pdf', + 'ppt' => 'application/vnd.ms-powerpoint', + 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'ps' => 'application/postscript', + 'rar' => 'application/x-rar-compressed', + 'rtf' => 'application/rtf', + 'tar' => 'application/x-tar', + 'sit' => 'application/x-stuffit', + 'svg' => 'image/svg+xml', + 'tif' => 'image/tiff', + 'tiff' => 'image/tiff', + 'ttf' => 'application/x-font-truetype', + 'vcf' => 'text/x-vcard', + 'wav' => 'audio/wav', + 'wma' => 'audio/x-ms-wma', + 'wmv' => 'audio/x-ms-wmv', + 'xls' => 'application/vnd.ms-excel', + 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'xml' => 'application/xml', + ]; - // wrap array for generating file - foreach ($valid_mime_types_preset as $extension => $mime_type) { - // generate array for mimetype to extension resolver (only first match) - $valid_mime_types[$extension] = "'{$extension}' => '{$mime_type}'"; - } + // wrap array for generating file + foreach ($valid_mime_types_preset as $extension => $mime_type) { + // generate array for mimetype to extension resolver (only first match) + $valid_mime_types[$extension] = "'{$extension}' => '{$mime_type}'"; + } - // all extensions from second match - foreach ($matches[2] as $i => $extensions) { - // explode multiple extensions from string - $extensions = explode(' ', strtolower($extensions ?? '')); + // all extensions from second match + foreach ($matches[2] as $i => $extensions) { + // explode multiple extensions from string + $extensions = explode(' ', strtolower($extensions ?? '')); - // force array for foreach - if (!\is_array($extensions)) { - $extensions = [$extensions]; - } + // force array for foreach + if (!\is_array($extensions)) { + $extensions = [$extensions]; + } - foreach ($extensions as $extension) { - // get mime type - $mime_type = $matches[1][$i]; + foreach ($extensions as $extension) { + // get mime type + $mime_type = $matches[1][$i]; - // check if string length lower than 10 - if (\strlen($extension) < 10) { - if (!isset($valid_mime_types[$mime_type])) { - // generate array for mimetype to extension resolver (only first match) - $valid_mime_types[$extension] = "'{$extension}' => '{$mime_type}'"; - } - } - } - } - } + // check if string length lower than 10 + if (\strlen($extension) < 10) { + if (!isset($valid_mime_types[$mime_type])) { + // generate array for mimetype to extension resolver (only first match) + $valid_mime_types[$extension] = "'{$extension}' => '{$mime_type}'"; + } + } + } + } + } - $xml = simplexml_load_string($mime_xml); + $xml = simplexml_load_string($mime_xml); - foreach ($xml as $node) { - // check if there is no pattern - if (!isset($node->glob['pattern'])) { - continue; - } + foreach ($xml as $node) { + // check if there is no pattern + if (!isset($node->glob['pattern'])) { + continue; + } - // get all matching extensions from match - foreach ((array) $node->glob['pattern'] as $extension) { - // skip none glob extensions - if (false === strpos($extension ?? '', '.')) { - continue; - } + // get all matching extensions from match + foreach ((array) $node->glob['pattern'] as $extension) { + // skip none glob extensions + if (false === strpos($extension ?? '', '.')) { + continue; + } - // remove get only last part - $extension = explode('.', strtolower($extension ?? '')); - $extension = end($extension); - } + // remove get only last part + $extension = explode('.', strtolower($extension ?? '')); + $extension = end($extension); + } - if (isset($node->glob['pattern'][0])) { - // mime type - $mime_type = strtolower((string) $node['type'] ?? ''); + if (isset($node->glob['pattern'][0])) { + // mime type + $mime_type = strtolower((string) $node['type'] ?? ''); - // get first extension - $extension = strtolower(trim($node->glob['ddpattern'][0] ?? '', '*.')); + // get first extension + $extension = strtolower(trim($node->glob['ddpattern'][0] ?? '', '*.')); - // skip none glob extensions and check if string length between 1 and 10 - if (false !== strpos($extension, '.') || \strlen($extension) < 1 || \strlen($extension) > 9) { - continue; - } + // skip none glob extensions and check if string length between 1 and 10 + if (false !== strpos($extension, '.') || \strlen($extension) < 1 || \strlen($extension) > 9) { + continue; + } - // check if string length lower than 10 - if (!isset($valid_mime_types[$mime_type])) { - // generate array for mimetype to extension resolver (only first match) - $valid_mime_types[$extension] = "'{$extension}' => '{$mime_type}'"; - } - } - } + // check if string length lower than 10 + if (!isset($valid_mime_types[$mime_type])) { + // generate array for mimetype to extension resolver (only first match) + $valid_mime_types[$extension] = "'{$extension}' => '{$mime_type}'"; + } + } + } - // full list of valid extensions only - $valid_mime_types = array_unique($valid_mime_types); - ksort($valid_mime_types); + // full list of valid extensions only + $valid_mime_types = array_unique($valid_mime_types); + ksort($valid_mime_types); - // combine mime types and extensions array - $output = "$preamble\$swift_mime_types = array(\n ".implode(",\n ", $valid_mime_types)."\n);"; + // combine mime types and extensions array + $output = "$preamble\$swift_mime_types = array(\n ".implode(",\n ", $valid_mime_types)."\n);"; - // write mime_types.php config file - @file_put_contents('./mime_types.php', $output); + // write mime_types.php config file + @file_put_contents('./mime_types.php', $output); } generateUpToDateMimeArray(); diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index a17e7c2e6be..e4ad83e8129 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -285,6 +285,7 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us } $result = $object->addTimeSpent($user); + } else { $object->fetch($id, $ref); @@ -1793,6 +1794,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if ($resultFetch < 0) { setEventMessages($product->error, $product->errors, 'errors'); } else { + print $product->getNomUrl(1); } } From ebda8d52f016c2d8db259d8e89dbcdd5d805d92b Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 24 Jan 2022 22:30:25 +0000 Subject: [PATCH 006/367] Fixing style errors. --- htdocs/projet/tasks/time.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index e4ad83e8129..a17e7c2e6be 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -285,7 +285,6 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us } $result = $object->addTimeSpent($user); - } else { $object->fetch($id, $ref); @@ -1794,7 +1793,6 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if ($resultFetch < 0) { setEventMessages($product->error, $product->errors, 'errors'); } else { - print $product->getNomUrl(1); } } From bb5f5bc18c361637ce037bb66aec892414d27d91 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 24 Jan 2022 23:30:41 +0100 Subject: [PATCH 007/367] merge --- htdocs/projet/tasks/time.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index e4ad83e8129..d82f0d6ac66 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -285,7 +285,6 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us } $result = $object->addTimeSpent($user); - } else { $object->fetch($id, $ref); @@ -391,7 +390,6 @@ if ($action == 'confirm_generateinvoice') { $fuser = new User($db); $db->begin(); - //TODO produit du temps passé ou produt id $idprod = GETPOST('productid', 'int'); $generateinvoicemode = GETPOST('generateinvoicemode', 'string'); $invoiceToUse = GETPOST('invoiceid', 'int'); @@ -1196,7 +1194,6 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser $form->select_produits('', 'productid', '1', 0, $projectstatic->thirdparty->price_level, 1, 2, '', 0, array(), $projectstatic->thirdparty->id, 'None', 0, 'maxwidth500'); print ''; print ''; - //TODO : Use product of time affect } print ''; @@ -1794,7 +1791,6 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if ($resultFetch < 0) { setEventMessages($product->error, $product->errors, 'errors'); } else { - print $product->getNomUrl(1); } } From 7880d8f0400fd56fadc917ddc971c93f2b7d4785 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 4 Mar 2022 10:04:41 +0100 Subject: [PATCH 008/367] fix double call --- htdocs/projet/tasks/time.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index b0ba6b1f24f..153683442e9 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -283,8 +283,6 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us $error++; } } - - $result = $object->addTimeSpent($user); } else { $object->fetch($id, $ref); From 6c3ea310dca2d935e87e3bd3c0da974abc07e23f Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 18 Mar 2022 09:12:34 +0100 Subject: [PATCH 009/367] align css --- htdocs/projet/tasks/time.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 153683442e9..de1c1455002 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -1603,7 +1603,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser print_liste_field_titre($arrayfields['t.task_duration']['label'], $_SERVER['PHP_SELF'], 't.task_duration', '', $param, '', $sortfield, $sortorder, 'right '); } if (!empty($arrayfields['t.fk_product']['checked'])) { - print_liste_field_titre($arrayfields['t.fk_product']['label'], $_SERVER['PHP_SELF'], 't.fk_product', '', $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre($arrayfields['t.fk_product']['label'], $_SERVER['PHP_SELF'], 't.fk_product', '', $param, '', $sortfield, $sortorder); } if (!empty($arrayfields['value']['checked'])) { From 8152a728a866c568baf769db56ff09ef36b8a9e3 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Tue, 22 Mar 2022 11:42:15 +0100 Subject: [PATCH 010/367] Fix : filemanagement in ecm and medias --- htdocs/core/class/html.formfile.class.php | 8 ++++---- htdocs/core/tpl/filemanager.tpl.php | 18 ++++++++++++++++-- htdocs/ecm/class/htmlecm.form.class.php | 4 ++-- htdocs/ecm/dir_add_card.php | 2 +- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 6c4ff6e30f1..7117b2b8a2a 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1328,7 +1328,7 @@ class FormFile if ($file['name'] != '.' && $file['name'] != '..' && !preg_match('/\.meta$/i', $file['name'])) { - if ($filearray[$key]['rowid'] > 0) { + if (!empty($filearray[$key]['rowid']) && $filearray[$key]['rowid'] > 0) { $lastrowid = $filearray[$key]['rowid']; } $filepath = $relativepath.$file['name']; @@ -1337,8 +1337,8 @@ class FormFile $nboflines++; print ''."\n"; // Do we have entry into database ? - print ''."\n"; - print ''; + print ''."\n"; + print ''; // File name print ''; @@ -1481,7 +1481,7 @@ class FormFile if ($permtoeditline) { // Link to resize $moreparaminurl = ''; - if ($object->id > 0) { + if (!empty($object->id) && $object->id > 0) { $moreparaminurl = '&id='.$object->id; } elseif (GETPOST('website', 'alpha')) { $moreparaminurl = '&website='.GETPOST('website', 'alpha'); diff --git a/htdocs/core/tpl/filemanager.tpl.php b/htdocs/core/tpl/filemanager.tpl.php index e776388ac53..5c40e56ff10 100644 --- a/htdocs/core/tpl/filemanager.tpl.php +++ b/htdocs/core/tpl/filemanager.tpl.php @@ -51,7 +51,7 @@ if ($module == 'medias') { $permtoupload = ($user->rights->mailing->creer || $user->rights->website->write); $showroot = 1; } - +$section = 0; // Confirm remove file (for non javascript users) @@ -102,12 +102,26 @@ $('#acreatedir').on('click', function() { try{ section_dir = $('.directory.expanded')[$('.directory.expanded').length-1].children[0].rel; section = $('.directory.expanded')[$('.directory.expanded').length-1].children[0].id.split('_')[2]; + catParent = "; +if ($module == 'ecm') { + print "section;"; +} else { + print "section_dir.substring(0, section_dir.length - 1);"; +} +print " } catch{ section_dir = '/'; section = 0; + catParent = "; +if ($module == 'ecm') { + print "section;"; +} else { + print "section_dir;"; +} +print " } console.log('We click to create a new directory, we set current section_dir='+section_dir+' into href url of button acreatedir'); - $('#acreatedir').attr('href', $('#acreatedir').attr('href')+'§ion_dir='+encodeURI(section_dir)+'§ion='+encodeURI(section)); + $('#acreatedir').attr('href', $('#acreatedir').attr('href')+'%26section_dir%3D'+encodeURI(section_dir)+'%26section%3D'+encodeURI(section)+'§ion_dir='+encodeURI(section_dir)+'§ion='+encodeURI(section)+'&catParent='+encodeURI(catParent)); console.log($('#acreatedir').attr('href')); }); $('#agenerateimgwebp').on('click', function() { diff --git a/htdocs/ecm/class/htmlecm.form.class.php b/htdocs/ecm/class/htmlecm.form.class.php index 623d626935d..b93d3d563fb 100644 --- a/htdocs/ecm/class/htmlecm.form.class.php +++ b/htdocs/ecm/class/htmlecm.form.class.php @@ -80,7 +80,7 @@ class FormEcm $cate_arbo = dol_dir_list($path, 'directories', 1, '', array('(\.meta|_preview.*\.png)$', '^\.'), 'relativename', SORT_ASC); } - $output = ''; if (is_array($cate_arbo)) { if (!count($cate_arbo)) { $output .= ''; @@ -100,7 +100,7 @@ class FormEcm } } $output .= ''; - $output .= ajax_combobox($select_name); + //$output .= ajax_combobox($select_name); $output .= "\n"; return $output; } diff --git a/htdocs/ecm/dir_add_card.php b/htdocs/ecm/dir_add_card.php index d7de6acc727..a6c980e5908 100644 --- a/htdocs/ecm/dir_add_card.php +++ b/htdocs/ecm/dir_add_card.php @@ -230,7 +230,7 @@ if ($action == 'create') { print ''; // Label - print ''."\n"; + print ''."\n"; print ''; print ''; - //auto APPROVAL ON CREATE + //auto validation ON CREATE print ''."\n"; From bf10e8f68771f9e125b76d09a248bd6a6244b98f Mon Sep 17 00:00:00 2001 From: jpb Date: Wed, 8 Jun 2022 17:08:05 +0200 Subject: [PATCH 032/367] add js behaviour on auvalidation and automail remove todo --- htdocs/holiday/card_group.php | 95 +++++++++++++++++++++-------------- 1 file changed, 58 insertions(+), 37 deletions(-) diff --git a/htdocs/holiday/card_group.php b/htdocs/holiday/card_group.php index 8ffe0f3e1fc..898d9f53be8 100644 --- a/htdocs/holiday/card_group.php +++ b/htdocs/holiday/card_group.php @@ -318,8 +318,8 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); $error++; } else { - // AUTO APPROUVAL /VALIDATED - //@TODO changer le nom si approuved / validated + + //@TODO changer le nom si validated if ($autoValidation) { $htemp = new Holiday($db); $htemp->fetch($result); @@ -332,10 +332,11 @@ if (empty($reshook)) { $error++; } // we can auto send mail if we are in auto validation behavior - //@todo jquery disable if checkbox autovalidation unchecked + if ($AutoSendMail && !$error) { // send a mail to the user - sendMail($result, $cancreate, $now, $autoValidation); + $returnSendMail = sendMail($result, $cancreate, $now, $autoValidation); + if (!empty($returnSendMail->msg)) setEventMessage($returnSendMail->msg,$returnSendMail->style); } } } @@ -413,6 +414,13 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { print ''."\n"; @@ -448,12 +465,8 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { print ''."\n"; print ''."\n"; - - print dol_get_fiche_head(); - //print ''.$langs->trans('DelayToRequestCP',$object->getConfCP('delayForRequest')).'

'; - print '
'.$langs->trans("Label").'
'.$langs->trans("Label").'
'.$langs->trans("AddIn").''; print $formecm->selectAllSections((GETPOST("catParent", 'alpha') ? GETPOST("catParent", 'alpha') : $ecmdir->fk_parent), 'catParent', $module); From b18eac6c75708e6d1e2869cd3c99936440225932 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Tue, 22 Mar 2022 14:44:11 +0100 Subject: [PATCH 011/367] remove tests lines --- htdocs/ecm/class/htmlecm.form.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/ecm/class/htmlecm.form.class.php b/htdocs/ecm/class/htmlecm.form.class.php index b93d3d563fb..623d626935d 100644 --- a/htdocs/ecm/class/htmlecm.form.class.php +++ b/htdocs/ecm/class/htmlecm.form.class.php @@ -80,7 +80,7 @@ class FormEcm $cate_arbo = dol_dir_list($path, 'directories', 1, '', array('(\.meta|_preview.*\.png)$', '^\.'), 'relativename', SORT_ASC); } - $output = ''; if (is_array($cate_arbo)) { if (!count($cate_arbo)) { $output .= ''; @@ -100,7 +100,7 @@ class FormEcm } } $output .= ''; - //$output .= ajax_combobox($select_name); + $output .= ajax_combobox($select_name); $output .= "\n"; return $output; } From e6a989e51a2670c0eaaa49e969f46c302a7ac8a5 Mon Sep 17 00:00:00 2001 From: kamel Date: Fri, 25 Mar 2022 17:00:23 +0100 Subject: [PATCH 012/367] FIX - Case of invoice situation at 100% with a credit note Set situation_final to 0 if is a credit note and the invoice source is a invoice situation (case when invoice situation is at 100%) when the credit note is validated So we can continue to create new invoice situation --- htdocs/compta/facture/class/facture.class.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 4feeb3d60b6..4caa9a8bca6 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2848,6 +2848,25 @@ class Facture extends CommonInvoice } } + /* + * Set situation_final to 0 if is a credit note and the invoice source is a invoice situation (case when invoice situation is at 100%) + * So we can continue to create new invoice situation + */ + if (!$error && $this->type == self::TYPE_CREDIT_NOTE && $this->fk_facture_source > 0) { + $invoice_situation = new Facture($this->db); + $result = $invoice_situation->fetch($this->fk_facture_source); + if ($result > 0) { + $invoice_situation->situation_final = 0; + // Disable triggers because module can force situation_final to 1 by triggers (ex: SubTotal) + $result = $invoice_situation->setFinal($user, 1); + } + if ($result < 0) { + $this->error = $invoice_situation->error; + $this->errors = $invoice_situation->errors; + $error++; + } + } + // Trigger calls if (!$error && !$notrigger) { // Call trigger From 2ca5c38f0acfe4b988c55ff98033afb1d47ca3bd Mon Sep 17 00:00:00 2001 From: kamel Date: Mon, 4 Apr 2022 10:40:10 +0200 Subject: [PATCH 013/367] Add test for checking if parent invoice is of type 'situation' --- htdocs/compta/facture/class/facture.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 939db98330c..29101108d00 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2902,7 +2902,7 @@ class Facture extends CommonInvoice if (!$error && $this->type == self::TYPE_CREDIT_NOTE && $this->fk_facture_source > 0) { $invoice_situation = new Facture($this->db); $result = $invoice_situation->fetch($this->fk_facture_source); - if ($result > 0) { + if ($result > 0 && $invoice_situation->type == self::TYPE_SITUATION && $invoice_situation->situation_final == 1) { $invoice_situation->situation_final = 0; // Disable triggers because module can force situation_final to 1 by triggers (ex: SubTotal) $result = $invoice_situation->setFinal($user, 1); From f17d09743ff2e9d5d88492671f091f56e49b515e Mon Sep 17 00:00:00 2001 From: lvessiller Date: Tue, 12 Apr 2022 16:40:59 +0200 Subject: [PATCH 014/367] NEW product categories filter on inventory list --- htdocs/product/inventory/list.php | 69 +++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index c4548b3aa66..a2b9fdfa194 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -27,6 +27,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php'; +if (!empty($conf->categorie->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +} // Load translation files required by the page $langs->loadLangs(array("stocks", "other")); @@ -88,6 +91,13 @@ foreach ($object->fields as $key => $val) { $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int')); } } +$searchCategoryProductOperator = 0; +if (GETPOSTISSET('formfilteraction')) { + $searchCategoryProductOperator = GETPOST('search_category_product_operator', 'int'); +} elseif (!empty($conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT)) { + $searchCategoryProductOperator = $conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT; +} +$searchCategoryProductList = GETPOST('search_category_product_list', 'array'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); @@ -166,6 +176,7 @@ if (empty($reshook)) { $search[$key.'_dtend'] = ''; } } + $searchCategoryProductList = array(); $toselect = array(); $search_array_options = array(); } @@ -259,6 +270,50 @@ foreach ($search as $key => $val) { if ($search_all) { $sql .= natural_search(array_keys($fieldstosearchall), $search_all); } +$searchCategoryProductSqlList = array(); +if ($searchCategoryProductOperator == 1) { + $existsCategoryProductList = array(); + foreach ($searchCategoryProductList as $searchCategoryProduct) { + if (intval($searchCategoryProduct) == -2) { + $sqlCategoryProductNotExists = " NOT EXISTS ("; + $sqlCategoryProductNotExists .= " SELECT cp.fk_product"; + $sqlCategoryProductNotExists .= " FROM ".$db->prefix()."categorie_product AS cp"; + $sqlCategoryProductNotExists .= " WHERE cp.fk_product = t.fk_product"; + $sqlCategoryProductNotExists .= " )"; + $searchCategoryProductSqlList[] = $sqlCategoryProductNotExists; + } elseif (intval($searchCategoryProduct) > 0) { + $existsCategoryProductList[] = $db->escape($searchCategoryProduct); + } + } + if (!empty($existsCategoryProductList)) { + $sqlCategoryProductExists = " EXISTS ("; + $sqlCategoryProductExists .= " SELECT cp.fk_product"; + $sqlCategoryProductExists .= " FROM ".$db->prefix()."categorie_product AS cp"; + $sqlCategoryProductExists .= " WHERE cp.fk_product = t.fk_product"; + $sqlCategoryProductExists .= " AND cp.fk_categorie IN (".implode(",", $existsCategoryProductList).")"; + $sqlCategoryProductExists .= " )"; + $searchCategoryProductSqlList[] = $sqlCategoryProductExists; + } + if (!empty($searchCategoryProductSqlList)) { + $sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")"; + } +} else { + foreach ($searchCategoryProductList as $searchCategoryProduct) { + if (intval($searchCategoryProduct) == -2) { + $sqlCategoryProductNotExists = " NOT EXISTS ("; + $sqlCategoryProductNotExists .= " SELECT cp.fk_product"; + $sqlCategoryProductNotExists .= " FROM ".$db->prefix()."categorie_product AS cp"; + $sqlCategoryProductNotExists .= " WHERE cp.fk_product = t.fk_product"; + $sqlCategoryProductNotExists .= " )"; + $searchCategoryProductSqlList[] = $sqlCategoryProductNotExists; + } elseif (intval($searchCategoryProduct) > 0) { + $searchCategoryProductSqlList[] = "t.fk_product IN (SELECT fk_product FROM ".$db->prefix()."categorie_product WHERE fk_categorie = ".((int) $searchCategoryProduct).")"; + } + } + if (!empty($searchCategoryProductSqlList)) { + $sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")"; + } +} //$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; @@ -348,6 +403,9 @@ foreach ($search as $key => $val) { if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); } +foreach ($searchCategoryProductList as $searchCategoryProduct) { + $param .= "&search_category_product_list[]=".urlencode($searchCategoryProduct); +} // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // Add $param from hooks @@ -405,6 +463,17 @@ $moreforfilter = ''; $moreforfilter.= $langs->trans('MyFilter') . ': '; $moreforfilter.= '';*/ +// Filter on categories +if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { + $moreforfilter .= '
'; + $moreforfilter .= img_picto($langs->trans('Categories'), 'category', 'class="pictofixedwidth"'); + $categoriesProductArr = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', '', 64, 0, 1); + $categoriesProductArr[-2] = '- '.$langs->trans('NotCategorized').' -'; + $moreforfilter .= Form::multiselectarray('search_category_product_list', $categoriesProductArr, $searchCategoryProductList, 0, 0, 'minwidth300'); + $moreforfilter .= ' '; + $moreforfilter .= '
'; +} + $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook if (empty($reshook)) { From 4510af67478628bd7b36ac69a5a91ac785944596 Mon Sep 17 00:00:00 2001 From: lvessiller Date: Tue, 12 Apr 2022 16:59:46 +0200 Subject: [PATCH 015/367] FIX travis SQL syntax --- htdocs/product/inventory/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index a2b9fdfa194..7e795d821bf 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -290,7 +290,7 @@ if ($searchCategoryProductOperator == 1) { $sqlCategoryProductExists .= " SELECT cp.fk_product"; $sqlCategoryProductExists .= " FROM ".$db->prefix()."categorie_product AS cp"; $sqlCategoryProductExists .= " WHERE cp.fk_product = t.fk_product"; - $sqlCategoryProductExists .= " AND cp.fk_categorie IN (".implode(",", $existsCategoryProductList).")"; + $sqlCategoryProductExists .= " AND cp.fk_categorie IN (".$db->sanitize(implode(',', $existsCategoryProductList)).")"; $sqlCategoryProductExists .= " )"; $searchCategoryProductSqlList[] = $sqlCategoryProductExists; } From 1435e2666e8d698b9b7f1cbabc75306e2b62bea8 Mon Sep 17 00:00:00 2001 From: lvessiller Date: Tue, 12 Apr 2022 17:18:39 +0200 Subject: [PATCH 016/367] FIX reload travis From 902301659b47c827b76da586d9de48f9d14684da Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 13 Apr 2022 09:31:30 +0200 Subject: [PATCH 017/367] finish invoice per product per line --- htdocs/compta/facture/class/facture.class.php | 1 + htdocs/langs/en_US/projects.lang | 3 +- htdocs/product/class/product.class.php | 37 ++++++++ htdocs/projet/tasks/time.php | 87 +++++++++++++------ 4 files changed, 99 insertions(+), 29 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 7ad0a8ed4bc..d0089e6f1e7 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3500,6 +3500,7 @@ class Facture extends CommonInvoice return -2; } } else { + $this->errors[]='status of invoice must be Draft to allow use of ->addline()'; dol_syslog(get_class($this)."::addline status of invoice must be Draft to allow use of ->addline()", LOG_ERR); return -3; } diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 1e0ed42d3e3..645171e8ac7 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -259,7 +259,7 @@ TimeSpentInvoiced=Time spent billed TimeSpentForIntervention=Time spent TimeSpentForInvoice=Time spent OneLinePerUser=One line per user -ServiceToUseOnLines=Service to use on lines +ServiceToUseOnLines=Service to use on lines by default InvoiceGeneratedFromTimeSpent=Invoice %s has been generated from time spent on project InterventionGeneratedFromTimeSpent=Intervention %s has been generated from time spent on project ProjectBillTimeDescription=Check if you enter timesheet on tasks of project AND you plan to generate invoice(s) from the timesheet to bill the customer of the project (do not check if you plan to create invoice that is not based on entered timesheets). Note: To generate invoice, go on tab 'Time spent' of the project and select lines to include. @@ -276,6 +276,7 @@ NewInter=New intervention OneLinePerTask=One line per task OneLinePerPeriod=One line per period OneLinePerTimeSpentLine=One line for each time spent declaration +OneLinePerTimeSpentLineProduct=One line for each time spent declaration with product defined AddDetailDateAndDuration=With date and duration into line description RefTaskParent=Ref. Parent Task ProfitIsCalculatedWith=Profit is calculated using diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 365b5e90916..fb42b6887f2 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -6058,6 +6058,43 @@ class Product extends CommonObject dol_print_error($this->db); } } + + + /** + * Return the duration in Hours of a service base on duration fields + * @return int -1 KO, >= 0 is the duration in hours + */ + public function getProductDurationHours() + { + global $langs; + + if (empty($this->duration_value)) { + $this->errors[]='ErrorDurationForServiceNotDefinedCantCalculateHourlyPrice'; + return -1; + } + + if ($this->duration_unit == 'i') { + $prodDurationHours = 1. / 60; + } + if ($this->duration_unit == 'h') { + $prodDurationHours = 1.; + } + if ($this->duration_unit == 'd') { + $prodDurationHours = 24.; + } + if ($this->duration_unit == 'w') { + $prodDurationHours = 24. * 7; + } + if ($this->duration_unit == 'm') { + $prodDurationHours = 24. * 30; + } + if ($this->duration_unit == 'y') { + $prodDurationHours = 24. * 365; + } + $prodDurationHours *= $this->duration_value; + + return $prodDurationHours; + } } diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 34333b91632..b201feef622 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -392,36 +392,21 @@ if ($action == 'confirm_generateinvoice') { $generateinvoicemode = GETPOST('generateinvoicemode', 'string'); $invoiceToUse = GETPOST('invoiceid', 'int'); - $prodDurationHours = 1.0; + $prodDurationHoursBase = 1.0; if ($idprod > 0) { $tmpproduct->fetch($idprod); + if ($result<0) { + $error++; + setEventMessages($tmpproduct->error, $tmpproduct->errors, 'errors'); + } - if (empty($tmpproduct->duration_value)) { + $prodDurationHoursBase=$tmpproduct->getProductDurationHours(); + if ($prodDurationHoursBase<0) { $error++; $langs->load("errors"); - setEventMessages($langs->trans("ErrorDurationForServiceNotDefinedCantCalculateHourlyPrice"), null, 'errors'); + setEventMessages(null, $tmpproduct->errors, 'errors'); } - if ($tmpproduct->duration_unit == 'i') { - $prodDurationHours = 1. / 60; - } - if ($tmpproduct->duration_unit == 'h') { - $prodDurationHours = 1.; - } - if ($tmpproduct->duration_unit == 'd') { - $prodDurationHours = 24.; - } - if ($tmpproduct->duration_unit == 'w') { - $prodDurationHours = 24. * 7; - } - if ($tmpproduct->duration_unit == 'm') { - $prodDurationHours = 24. * 30; - } - if ($tmpproduct->duration_unit == 'y') { - $prodDurationHours = 24. * 365; - } - $prodDurationHours *= $tmpproduct->duration_value; - $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0); $pu_ht = empty($dataforprice['pu_ht']) ? 0 : $dataforprice['pu_ht']; @@ -429,7 +414,7 @@ if ($action == 'confirm_generateinvoice') { $localtax1 = $dataforprice['localtax1']; $localtax2 = $dataforprice['localtax2']; } else { - $prodDurationHours = 1; + $prodDurationHoursBase = 1; $pu_ht = 0; $txtva = get_default_tva($mysoc, $projectstatic->thirdparty); @@ -476,7 +461,7 @@ if ($action == 'confirm_generateinvoice') { } // Add lines - $lineid = $tmpinvoice->addline($langs->trans("TimeSpentForInvoice", $username).' : '.$qtyhourtext, $pu_ht, round($qtyhour / $prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); + $lineid = $tmpinvoice->addline($langs->trans("TimeSpentForInvoice", $username).' : '.$qtyhourtext, $pu_ht, round($qtyhour / $prodDurationHoursBase, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); // Update lineid into line of timespent $sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time SET invoice_line_id = '.((int) $lineid).', invoice_id = '.((int) $tmpinvoice->id); @@ -488,8 +473,9 @@ if ($action == 'confirm_generateinvoice') { break; } } - } elseif ($generateinvoicemode == 'onelineperperiod') { // One line for each time spent line + } elseif ($generateinvoicemode == 'onelineperperiod' || $generateinvoicemode == 'onelineperperiodproduct') { // One line for each time spent line $arrayoftasks = array(); + $product_data_cache = array(); $withdetail=GETPOST('detail_time_duration', 'alpha'); foreach ($toselect as $key => $value) { // Get userid, timepent @@ -519,6 +505,7 @@ if ($action == 'confirm_generateinvoice') { $arrayoftasks[$object->timespent_id]['note'] .= ' - '.$langs->trans("Duration").': '.convertSecondToTime($object->timespent_duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); } $arrayoftasks[$object->timespent_id]['user'] = $object->timespent_fk_user; + $arrayoftasks[$object->timespent_id]['fk_product'] = $object->timespent_fk_product; } foreach ($arrayoftasks as $timespent_id => $value) { @@ -534,7 +521,50 @@ if ($action == 'confirm_generateinvoice') { } // Add lines - $lineid = $tmpinvoice->addline($value['note'], $pu_ht, round($qtyhour / $prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0)); + $prodDurationHours = $prodDurationHoursBase; + $idprodline=$idprod; + $pu_htline = $pu_ht; + $txtvaline = $txtva; + $localtax1line = $localtax1; + $localtax2line = $localtax2; + + + if ($generateinvoicemode == 'onelineperperiodproduct' && !empty($value['fk_product']) && $value['fk_product']!==$idprod) { + if (!array_key_exists($value['fk_product'], $product_data_cache)) { + $result = $tmpproduct->fetch($value['fk_product']); + if ($result < 0) { + $error++; + setEventMessages($tmpproduct->error, $tmpproduct->errors, 'errors'); + } + $prodDurationHours = $tmpproduct->getProductDurationHours(); + if ($prodDurationHours < 0) { + $error++; + $langs->load("errors"); + setEventMessages(null, $tmpproduct->errors, 'errors'); + } + + $dataforprice = $tmpproduct->getSellPrice($mysoc, $projectstatic->thirdparty, 0); + + $pu_htline = empty($dataforprice['pu_ht']) ? 0 : $dataforprice['pu_ht']; + $txtvaline = $dataforprice['tva_tx']; + $localtax1line = $dataforprice['localtax1']; + $localtax2line = $dataforprice['localtax2']; + + $product_data_cache[$value['fk_product']] = array('duration'=>$prodDurationHours,'dataforprice'=>$dataforprice); + } else { + $prodDurationHours = $product_data_cache[$value['fk_product']]['duration']; + $pu_htline = empty($product_data_cache[$value['fk_product']]['dataforprice']['pu_ht']) ? 0 : $product_data_cache[$value['fk_product']]['dataforprice']['pu_ht']; + $txtvaline = $product_data_cache[$value['fk_product']]['dataforprice']['tva_tx']; + $localtax1line = $product_data_cache[$value['fk_product']]['dataforprice']['localtax1']; + $localtax2line = $product_data_cache[$value['fk_product']]['dataforprice']['localtax2']; + } + $idprodline=$value['fk_product']; + } + $lineid = $tmpinvoice->addline($value['note'], $pu_htline, round($qtyhour / $prodDurationHours, 2), $txtvaline, $localtax1line, $localtax2line, ($idprodline > 0 ? $idprodline : 0)); + if ($lineid<0) { + $error++; + setEventMessages(null, $tmpinvoice->errors, 'errors'); + } //var_dump($lineid);exit; // Update lineid into line of timespent @@ -1178,6 +1208,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser 'onelineperuser'=>'OneLinePerUser', 'onelinepertask'=>'OneLinePerTask', 'onelineperperiod'=>'OneLinePerTimeSpentLine', + 'onelineperperiodproduct'=>'OneLinePerTimeSpentLineProduct', ); print $form->selectarray('generateinvoicemode', $tmparray, 'onelineperuser', 0, 0, 0, '', 1); print "\n".''."\n"; + + + // Formulaire de demande + print '
'."\n"; + print ''."\n"; + print ''."\n"; + + + + print dol_get_fiche_head(); + + //print ''.$langs->trans('DelayToRequestCP',$object->getConfCP('delayForRequest')).'

'; + + print ''; + print ''; + + // groupe + print ''; + print ''; + + print ''; + + // users + print ''; + print ''; + print ''; + + + + // Type + print ''; + print ''; + print ''; + print ''; + + // Date start + print ''; + print ''; + print ''; + print ''; + + // Date end + print ''; + print ''; + print ''; + print ''; + + // Approver + print ''; + print ''; + print ''; + print ''; + + //auto APPROVAL ON CREATE + print ''."\n"; + + + //no auto SEND MAIL + print ''."\n"; + + // Description + print ''; + print ''; + print ''; + + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; + + print ''; + print '
'.$langs->trans("groups"); + + print ''; + //@todo ajouter entity ! + $sql =' SELECT rowid, nom from '.MAIN_DB_PREFIX.'usergroup '; + + $resql = $db->query($sql); + $Tgroup = array(); + while ($obj = $db->fetch_object($resql)){ + $Tgroup[$obj->rowid] = $obj->nom; + } + print $form->multiselectarray('groups', $Tgroup, GETPOST('groups', 'array'), '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); + + print '
'.$langs->trans("users").''; + + $sql = ' SELECT DISTINCT u.rowid,u.lastname,u.firstname from '.MAIN_DB_PREFIX.'user as u'; + $sql .= ' WHERE 1=1 '; + $sql .= !empty($morefilter) ? $morefilter : ''; + + + if ($cancreate && !$cancreateall) { + + }else{ + //$sql .= ' AND u.fk_user = '.$user->id; + //$sql .= ' OR u.rowid ='.$user->id; + } + + $resql = $db->query($sql); + if ($resql){ + while ($obj = $db->fetch_object($resql)){ + $userlist[$obj->rowid] = $obj->firstname . ' '. $obj->lastname; + } + } + + print img_picto('', 'users') . $form->multiselectarray('users', $userlist, GETPOST('users', 'array'), '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); + print '
'.$langs->trans("Type").''; + $typeleaves = $object->getTypes(1, -1); + $arraytypeleaves = array(); + foreach ($typeleaves as $key => $val) { + $labeltoshow = ($langs->trans($val['code']) != $val['code'] ? $langs->trans($val['code']) : $val['label']); + $labeltoshow .= ($val['delay'] > 0 ? ' ('.$langs->trans("NoticePeriod").': '.$val['delay'].' '.$langs->trans("days").')' : ''); + $arraytypeleaves[$val['rowid']] = $labeltoshow; + } + print $form->selectarray('type', $arraytypeleaves, (GETPOST('type', 'alpha') ?GETPOST('type', 'alpha') : ''), 1, 0, 0, '', 0, 0, 0, '', '', true); + if ($user->admin) { + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + } + print '
'; + print $form->textwithpicto($langs->trans("DateDebCP"), $langs->trans("FirstDayOfHoliday")); + print ''; + // Si la demande ne vient pas de l'agenda + if (!GETPOST('date_debut_')) { + print $form->selectDate(-1, 'date_debut_', 0, 0, 0, '', 1, 1); + } else { + $tmpdate = dol_mktime(0, 0, 0, GETPOST('date_debut_month', 'int'), GETPOST('date_debut_day', 'int'), GETPOST('date_debut_year', 'int')); + print $form->selectDate($tmpdate, 'date_debut_', 0, 0, 0, '', 1, 1); + } + print '     '; + print $form->selectarray('starthalfday', $listhalfday, (GETPOST('starthalfday', 'alpha') ?GETPOST('starthalfday', 'alpha') : 'morning')); + print '
'; + print $form->textwithpicto($langs->trans("DateFinCP"), $langs->trans("LastDayOfHoliday")); + print ''; + if (!GETPOST('date_fin_')) { + print $form->selectDate(-1, 'date_fin_', 0, 0, 0, '', 1, 1); + } else { + $tmpdate = dol_mktime(0, 0, 0, GETPOST('date_fin_month', 'int'), GETPOST('date_fin_day', 'int'), GETPOST('date_fin_year', 'int')); + print $form->selectDate($tmpdate, 'date_fin_', 0, 0, 0, '', 1, 1); + } + print '     '; + print $form->selectarray('endhalfday', $listhalfday, (GETPOST('endhalfday', 'alpha') ?GETPOST('endhalfday', 'alpha') : 'afternoon')); + print '
'.$langs->trans("ReviewedByCP").''; + + $object = new Holiday($db); + $include_users = $object->fetch_users_approver_holiday(); + if (empty($include_users)) { + print img_warning().' '.$langs->trans("NobodyHasPermissionToValidateHolidays"); + } else { + // Defined default approver (the forced approved of user or the supervisor if no forced value defined) + // Note: This use will be set only if the deinfed approvr has permission to approve so is inside include_users + $defaultselectuser = (empty($user->fk_user_holiday_validator) ? $user->fk_user : $user->fk_user_holiday_validator); + if (!empty($conf->global->HOLIDAY_DEFAULT_VALIDATOR)) { + $defaultselectuser = $conf->global->HOLIDAY_DEFAULT_VALIDATOR; // Can force default approver + } + if (GETPOST('valideur', 'int') > 0) { + $defaultselectuser = GETPOST('valideur', 'int'); + } + $s = $form->select_dolusers($defaultselectuser, "valideur", 1, '', 0, $include_users, '', '0,'.$conf->entity, 0, 0, '', 0, '', 'minwidth200 maxwidth500'); + print img_picto('', 'user').$form->textwithpicto($s, $langs->trans("AnyOtherInThisListCanValidate")); + } + + + print '
'.$langs->trans("AutoApprovalOnCreate").''; + print ''; + print '
'.$langs->trans("AutoSendMail").''; + print ''; + print '
'.$langs->trans("DescCP").''; + $doleditor = new DolEditor('description', GETPOST('description', 'restricthtml'), '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->fckeditor->enabled) ? false : $conf->fckeditor->enabled, ROWS_3, '90%'); + print $doleditor->Create(1); + print '
'; + + print dol_get_fiche_end(); + + print $form->buttonsSaveCancel("SendRequestCollectiveCP"); + + print ''."\n"; + } +} else { + if ($error) { + print '
'; + print $error; + print '

'; + print '
'; + } +} + +// End of page +llxFooter(); + +if (is_object($db)) { + $db->close(); +} + +// automatic send mail +function sendMail ($id, $cancreate, $now){ + + global $db, $user, $conf, $langs; + + $object = new Holiday($db); + + $result = $object->fetch($id); + + if ($result){ + // If draft and owner of leave + if ($object->statut == Holiday::STATUS_DRAFT && $cancreate) { + $object->oldcopy = dol_clone($object); + + $object->statut = Holiday::STATUS_VALIDATED; + + $verif = $object->validate($user); + + // If no SQL error, we redirect to the request form + if ($verif > 0) { + // To + $destinataire = new User($db); + $destinataire->fetch($object->fk_validator); + $emailTo = $destinataire->email; + + if (!$emailTo) { + dol_syslog("Expected validator has no email, so we redirect directly to finished page without sending email"); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; + } + + // From + $expediteur = new User($db); + $expediteur->fetch($object->fk_user); + //$emailFrom = $expediteur->email; Email of user can be an email into another company. Sending will fails, we must use the generic email. + $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM; + + // Subject + $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM; + if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { + $societeName = $conf->global->MAIN_APPLICATION_TITLE; + } + + $subject = $societeName." - ".$langs->transnoentitiesnoconv("HolidaysToValidate"); + + // Content + $message = "

".$langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",

\n"; + + $message .= "

".$langs->transnoentities("HolidaysToValidateBody")."

\n"; + + + // option to warn the validator in case of too short delay + if (empty($conf->global->HOLIDAY_HIDE_APPROVER_ABOUT_TOO_LOW_DELAY)) { + $delayForRequest = 0; // TODO Set delay depending of holiday leave type + if ($delayForRequest) { + $nowplusdelay = dol_time_plus_duree($now, $delayForRequest, 'd'); + + if ($object->date_debut < $nowplusdelay) { + $message = "

".$langs->transnoentities("HolidaysToValidateDelay", $delayForRequest)."

\n"; + } + } + } + + // option to notify the validator if the balance is less than the request + if (empty($conf->global->HOLIDAY_HIDE_APPROVER_ABOUT_NEGATIVE_BALANCE)) { + $nbopenedday = num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday); + + if ($nbopenedday > $object->getCPforUser($object->fk_user, $object->fk_type)) { + $message .= "

".$langs->transnoentities("HolidaysToValidateAlertSolde")."

\n"; + } + } + + $link = dol_buildpath("/holiday/card.php", 3) . '?id='.$object->id; + + $message .= "
    "; + $message .= "
  • ".$langs->transnoentitiesnoconv("Name")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."
  • \n"; + $message .= "
  • ".$langs->transnoentitiesnoconv("Period")." : ".dol_print_date($object->date_debut, 'day')." ".$langs->transnoentitiesnoconv("To")." ".dol_print_date($object->date_fin, 'day')."
  • \n"; + $message .= "
  • ".$langs->transnoentitiesnoconv("Link").' : '.$link."
  • \n"; + $message .= "
\n"; + + $trackid = 'leav'.$object->id; + + $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 1, '', '', $trackid); + + // Sending the email + $result = $mail->sendfile(); + + if (!$result) { + setEventMessages($mail->error, $mail->errors, 'warnings'); + $action = ''; + } else { + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; + } + } else { + setEventMessages($object->error, $object->errors, 'errors'); + $action = ''; + } + } + }else{ + setEventMessage($langs->trans('ErrorloadUserOnSendingMail'),'warning'); + } + + +} diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index bef89f4462e..1f6dbb6b44d 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1111,11 +1111,11 @@ class Holiday extends CommonObject $this->fetchByUser($fk_user, '', ''); foreach ($this->holiday as $infos_CP) { - if ($infos_CP['statut'] == 4) { + if ($infos_CP['statut'] == Holiday::STATUS_CANCELED) { continue; // ignore not validated holidays } - if ($infos_CP['statut'] == 5) { - continue; // ignore not validated holidays + if ($infos_CP['statut'] == Holiday::STATUS_REFUSED) { + continue; // ignore refused holidays } //var_dump("--"); //var_dump("old: ".dol_print_date($infos_CP['date_debut'],'dayhour').' '.dol_print_date($infos_CP['date_fin'],'dayhour').' '.$infos_CP['halfday']); diff --git a/htdocs/langs/en_US/holiday.lang b/htdocs/langs/en_US/holiday.lang index 3d0ae64be0f..944b0b54db8 100644 --- a/htdocs/langs/en_US/holiday.lang +++ b/htdocs/langs/en_US/holiday.lang @@ -4,6 +4,7 @@ Holidays=Leave CPTitreMenu=Leave MenuReportMonth=Monthly statement MenuAddCP=New leave request +MenuCollectiveAddCP=New collective leave request NotActiveModCP=You must enable the module Leave to view this page. AddCP=Make a leave request DateDebCP=Start date @@ -86,6 +87,13 @@ UserUpdateCP=Updated for PrevSoldeCP=Previous Balance NewSoldeCP=New Balance alreadyCPexist=A leave request has already been done on this period. +UseralreadyCPexist=A leave request has already been done on this period for %s. +groups=Groups +users=Users +AutoSendMail=Automatic mailing +NewHolidayForGroup=Collective leaves +SendRequestCollectiveCP=Send collective leave request +AutoApprovalOnCreate=Automatic approval FirstDayOfHoliday=Beginning day of leave request LastDayOfHoliday=Ending day of leave request BoxTitleLastLeaveRequests=Latest %s modified leave requests From 02a4e10fd3e6ba1edc0d2daa5c1861ef11986296 Mon Sep 17 00:00:00 2001 From: jpb Date: Tue, 7 Jun 2022 19:12:40 +0200 Subject: [PATCH 027/367] add todo for some jquery --- htdocs/holiday/card_group.php | 35 ++++++++++++++++++++------------- htdocs/langs/en_US/holiday.lang | 2 +- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/htdocs/holiday/card_group.php b/htdocs/holiday/card_group.php index 05694934589..5d96bbbbc21 100644 --- a/htdocs/holiday/card_group.php +++ b/htdocs/holiday/card_group.php @@ -51,7 +51,7 @@ $fuserid = (GETPOST('fuserid', 'int') ?GETPOST('fuserid', 'int') : $user->id); $users = (GETPOST('users', 'array') ?GETPOST('users', 'array') : array($user->id)); $groups = GETPOST('groups', 'array') ; $socid = GETPOST('socid', 'int'); -$autoApproval = GETPOST('autoApproval','int'); +$autoValidation = GETPOST('autoValidation','int'); $AutoSendMail = GETPOST('AutoSendMail','int'); // Load translation files required by the page $langs->loadLangs(array("other", "holiday", "mails", "trips")); @@ -323,26 +323,26 @@ if (empty($reshook)) { }else{ // AUTO APPROUVAL /VALIDATED //@TODO changer le nom si approuved / validated - if ($autoApproval){ + if ($autoValidation){ $htemp = new Holiday($db); $htemp->fetch ($result); - // must set the status before approve call ... - $htemp->statut = Holiday::STATUS_VALIDATED; - // $resultApproved = $htemp->approve($approverid); - //@todo à voir avec nico validated ou approuved ? + $htemp->statut = Holiday::STATUS_VALIDATED; $resultValidated = $htemp->update($approverid); if ($resultValidated < 0 ){ setEventMessages($object->error, $object->errors, 'errors'); $error++; } + // we can auto send mail if we are in auto validation behavior + //@todo jquery disable if checkbox autovalidation unchecked + if ($AutoSendMail && !$error){ + // send a mail to the user + sendMail($result, $cancreate, $now, $autoValidation); + } } - if ($AutoSendMail && !$error){ - // send a mail to the user - sendMail($result, $cancreate, $now); - } + } } @@ -985,9 +985,16 @@ llxFooter(); if (is_object($db)) { $db->close(); } - -// automatic send mail -function sendMail ($id, $cancreate, $now){ +/** + * we send email to validator for current leave request (id) + * @param $id + * @param $cancreate + * @param $now + * @param $autoValidation + * @return void + * @throws Exception + */ +function sendMail ($id, $cancreate, $now, $autoValidation){ global $db, $user, $conf, $langs; @@ -1000,7 +1007,7 @@ function sendMail ($id, $cancreate, $now){ if ($object->statut == Holiday::STATUS_DRAFT && $cancreate) { $object->oldcopy = dol_clone($object); - $object->statut = Holiday::STATUS_VALIDATED; + if ($autoValidation) $object->statut = Holiday::STATUS_VALIDATED; $verif = $object->validate($user); diff --git a/htdocs/langs/en_US/holiday.lang b/htdocs/langs/en_US/holiday.lang index 944b0b54db8..2005d7e613c 100644 --- a/htdocs/langs/en_US/holiday.lang +++ b/htdocs/langs/en_US/holiday.lang @@ -93,7 +93,7 @@ users=Users AutoSendMail=Automatic mailing NewHolidayForGroup=Collective leaves SendRequestCollectiveCP=Send collective leave request -AutoApprovalOnCreate=Automatic approval +AutoValidationOnCreate=Automatic validation FirstDayOfHoliday=Beginning day of leave request LastDayOfHoliday=Ending day of leave request BoxTitleLastLeaveRequests=Latest %s modified leave requests From bf0650900d339c8b11459f0bfc9574648e4d18df Mon Sep 17 00:00:00 2001 From: jpb Date: Tue, 7 Jun 2022 19:16:57 +0200 Subject: [PATCH 028/367] remove useless code --- htdocs/holiday/card_group.php | 348 ---------------------------------- 1 file changed, 348 deletions(-) diff --git a/htdocs/holiday/card_group.php b/htdocs/holiday/card_group.php index 5d96bbbbc21..06157ee3e94 100644 --- a/htdocs/holiday/card_group.php +++ b/htdocs/holiday/card_group.php @@ -358,354 +358,6 @@ if (empty($reshook)) { } } } - - - if ($action == 'update_extras') { - $object->oldcopy = dol_clone($object); - - // Fill array 'array_options' with data from update form - $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); - if ($ret < 0) { - $error++; - } - - if (!$error) { - // Actions on extra fields - $result = $object->insertExtraFields('HOLIDAY_MODIFY'); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - $error++; - } - } - - if ($error) { - $action = 'edit_extras'; - } - } - - // Approve leave request - if ($action == 'confirm_valid') { - $object->fetch($id); - - // If status is waiting approval and approver is also user - if ($object->statut == Holiday::STATUS_VALIDATED && $user->id == $object->fk_validator) { - $object->oldcopy = dol_clone($object); - - $object->date_valid = dol_now(); - $object->fk_user_valid = $user->id; - $object->statut = Holiday::STATUS_APPROVED; - - $db->begin(); - - $verif = $object->approve($user); - if ($verif <= 0) { - setEventMessages($object->error, $object->errors, 'errors'); - $error++; - } - - // If no SQL error, we redirect to the request form - if (!$error) { - // Calculcate number of days consummed - $nbopenedday = num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday); - $soldeActuel = $object->getCpforUser($object->fk_user, $object->fk_type); - $newSolde = ($soldeActuel - $nbopenedday); - $label = $langs->transnoentitiesnoconv("Holidays").' - '.$object->ref; - - // The modification is added to the LOG - $result = $object->addLogCP($user->id, $object->fk_user, $label, $newSolde, $object->fk_type); - if ($result < 0) { - $error++; - setEventMessages(null, $object->errors, 'errors'); - } - - // Update balance - $result = $object->updateSoldeCP($object->fk_user, $newSolde, $object->fk_type); - if ($result < 0) { - $error++; - setEventMessages(null, $object->errors, 'errors'); - } - } - - if (!$error) { - // To - $destinataire = new User($db); - $destinataire->fetch($object->fk_user); - $emailTo = $destinataire->email; - - if (!$emailTo) { - dol_syslog("User that request leave has no email, so we redirect directly to finished page without sending email"); - } else { - // From - $expediteur = new User($db); - $expediteur->fetch($object->fk_validator); - //$emailFrom = $expediteur->email; Email of user can be an email into another company. Sending will fails, we must use the generic email. - $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM; - - // Subject - $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM; - if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { - $societeName = $conf->global->MAIN_APPLICATION_TITLE; - } - - $subject = $societeName." - ".$langs->transnoentitiesnoconv("HolidaysValidated"); - - // Content - $message = "

".$langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",

\n"; - - $message .= "

".$langs->transnoentities("HolidaysValidatedBody", dol_print_date($object->date_debut, 'day'), dol_print_date($object->date_fin, 'day'))."

\n"; - - $link = dol_buildpath('/holiday/card.php', 3).'?id='.$object->id; - - $message .= "
    \n"; - $message .= "
  • ".$langs->transnoentitiesnoconv("ValidatedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."
  • \n"; - $message .= "
  • ".$langs->transnoentitiesnoconv("Link").' : '.$link."
  • \n"; - $message .= "
\n"; - - $trackid = 'leav'.$object->id; - - $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 1, '', '', $trackid); - - // Sending email - $result = $mail->sendfile(); - - if (!$result) { - setEventMessages($mail->error, $mail->errors, 'warnings'); // Show error, but do no make rollback, so $error is not set to 1 - $action = ''; - } - } - } - - if (!$error) { - $db->commit(); - - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; - } else { - $db->rollback(); - $action = ''; - } - } - } - - if ($action == 'confirm_refuse' && GETPOST('confirm', 'alpha') == 'yes') { - if (GETPOST('detail_refuse')) { - $object->fetch($id); - - // If status pending validation and validator = user - if ($object->statut == Holiday::STATUS_VALIDATED && $user->id == $object->fk_validator) { - $object->date_refuse = dol_print_date('dayhour', dol_now()); - $object->fk_user_refuse = $user->id; - $object->statut = Holiday::STATUS_REFUSED; - $object->detail_refuse = GETPOST('detail_refuse', 'alphanohtml'); - - $db->begin(); - - $verif = $object->update($user); - if ($verif <= 0) { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); - } - - // If no SQL error, we redirect to the request form - if (!$error) { - // To - $destinataire = new User($db); - $destinataire->fetch($object->fk_user); - $emailTo = $destinataire->email; - - if (!$emailTo) { - dol_syslog("User that request leave has no email, so we redirect directly to finished page without sending email"); - } else { - // From - $expediteur = new User($db); - $expediteur->fetch($object->fk_validator); - //$emailFrom = $expediteur->email; Email of user can be an email into another company. Sending will fails, we must use the generic email. - $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM; - - // Subject - $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM; - if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { - $societeName = $conf->global->MAIN_APPLICATION_TITLE; - } - - $subject = $societeName." - ".$langs->transnoentitiesnoconv("HolidaysRefused"); - - // Content - $message = "

".$langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",

\n"; - - $message .= "

".$langs->transnoentities("HolidaysRefusedBody", dol_print_date($object->date_debut, 'day'), dol_print_date($object->date_fin, 'day'))."

\n"; - $message .= "

".GETPOST('detail_refuse', 'alpha')."

"; - - $link = dol_buildpath('/holiday/card.php', 3).'?id='.$object->id; - - $message .= "
    \n"; - $message .= "
  • ".$langs->transnoentitiesnoconv("ModifiedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."
  • \n"; - $message .= "
  • ".$langs->transnoentitiesnoconv("Link").' : '.$link."
  • \n"; - $message .= "
"; - - $trackid = 'leav'.$object->id; - - $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 1, '', '', $trackid); - - // sending email - $result = $mail->sendfile(); - - if (!$result) { - setEventMessages($mail->error, $mail->errors, 'warnings'); // Show error, but do no make rollback, so $error is not set to 1 - $action = ''; - } - } - } else { - $action = ''; - } - - if (!$error) { - $db->commit(); - - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; - } else { - $db->rollback(); - $action = ''; - } - } - } else { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DetailRefusCP")), null, 'errors'); - $action = 'refuse'; - } - } - - - // If the request is validated - if ($action == 'confirm_draft' && GETPOST('confirm') == 'yes') { - $error = 0; - - $object->fetch($id); - - $oldstatus = $object->statut; - $object->statut = Holiday::STATUS_DRAFT; - - $result = $object->update($user); - if ($result < 0) { - $error++; - setEventMessages($langs->trans('ErrorBackToDraft').' '.$object->error, $object->errors, 'errors'); - } - - if (!$error) { - $db->commit(); - - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; - } else { - $db->rollback(); - } - } - - // If confirmation of cancellation - if ($action == 'confirm_cancel' && GETPOST('confirm') == 'yes') { - $error = 0; - - $object->fetch($id); - - // If status pending validation and validator = validator or user, or rights to do for others - if (($object->statut == Holiday::STATUS_VALIDATED || $object->statut == Holiday::STATUS_APPROVED) && - (!empty($user->admin) || $user->id == $object->fk_validator || $cancreate || $cancreateall)) { - $db->begin(); - - $oldstatus = $object->statut; - $object->date_cancel = dol_now(); - $object->fk_user_cancel = $user->id; - $object->statut = Holiday::STATUS_CANCELED; - - $result = $object->update($user); - - if ($result >= 0 && $oldstatus == Holiday::STATUS_APPROVED) { // holiday was already validated, status 3, so we must increase back the balance - // Call trigger - $result = $object->call_trigger('HOLIDAY_CANCEL', $user); - if ($result < 0) { - $error++; - } - - // Calculcate number of days consummed - $nbopenedday = num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday); - - $soldeActuel = $object->getCpforUser($object->fk_user, $object->fk_type); - $newSolde = ($soldeActuel + $nbopenedday); - - // The modification is added to the LOG - $result1 = $object->addLogCP($user->id, $object->fk_user, $langs->transnoentitiesnoconv("HolidaysCancelation"), $newSolde, $object->fk_type); - - // Update of the balance - $result2 = $object->updateSoldeCP($object->fk_user, $newSolde, $object->fk_type); - - if ($result1 < 0 || $result2 < 0) { - $error++; - setEventMessages($langs->trans('ErrorCantDeleteCP').' '.$object->error, $object->errors, 'errors'); - } - } - - if (!$error) { - $db->commit(); - } else { - $db->rollback(); - } - - // If no SQL error, we redirect to the request form - if (!$error && $result > 0) { - // To - $destinataire = new User($db); - $destinataire->fetch($object->fk_user); - $emailTo = $destinataire->email; - - if (!$emailTo) { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; - } - - // From - $expediteur = new User($db); - $expediteur->fetch($object->fk_user_cancel); - //$emailFrom = $expediteur->email; Email of user can be an email into another company. Sending will fails, we must use the generic email. - $emailFrom = $conf->global->MAIN_MAIL_EMAIL_FROM; - - // Subject - $societeName = $conf->global->MAIN_INFO_SOCIETE_NOM; - if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { - $societeName = $conf->global->MAIN_APPLICATION_TITLE; - } - - $subject = $societeName." - ".$langs->transnoentitiesnoconv("HolidaysCanceled"); - - // Content - $message = "

".$langs->transnoentitiesnoconv("Hello")." ".$destinataire->firstname.",

\n"; - - $message .= "

".$langs->transnoentities("HolidaysCanceledBody", dol_print_date($object->date_debut, 'day'), dol_print_date($object->date_fin, 'day'))."

\n"; - - $link = dol_buildpath('/holiday/card.php', 3).'?id='.$object->id; - - $message .= "
    \n"; - $message .= "
  • ".$langs->transnoentitiesnoconv("ModifiedBy")." : ".dolGetFirstLastname($expediteur->firstname, $expediteur->lastname)."
  • \n"; - $message .= "
  • ".$langs->transnoentitiesnoconv("Link").' : '.$link."
  • \n"; - $message .= "
\n"; - - $trackid = 'leav'.$object->id; - - $mail = new CMailFile($subject, $emailTo, $emailFrom, $message, array(), array(), array(), '', '', 0, 1, '', '', $trackid); - - // sending email - $result = $mail->sendfile(); - - if (!$result) { - setEventMessages($mail->error, $mail->errors, 'warnings'); - $action = ''; - } else { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; - } - } - } - } - } From 8c607b8101a580736259420a50694ecbeca4e5e6 Mon Sep 17 00:00:00 2001 From: jpb Date: Tue, 7 Jun 2022 19:20:53 +0200 Subject: [PATCH 029/367] add todo --- htdocs/holiday/card_group.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/htdocs/holiday/card_group.php b/htdocs/holiday/card_group.php index 06157ee3e94..a51f9c6ab20 100644 --- a/htdocs/holiday/card_group.php +++ b/htdocs/holiday/card_group.php @@ -638,12 +638,12 @@ if (is_object($db)) { $db->close(); } /** - * we send email to validator for current leave request (id) + * send email to validator for current leave represented by (id) * @param $id * @param $cancreate * @param $now * @param $autoValidation - * @return void + * @return string|void * @throws Exception */ function sendMail ($id, $cancreate, $now, $autoValidation){ @@ -670,6 +670,8 @@ function sendMail ($id, $cancreate, $now, $autoValidation){ $destinataire->fetch($object->fk_validator); $emailTo = $destinataire->email; + //@todo make object return errors + //@todo remove redisrection here ! if (!$emailTo) { dol_syslog("Expected validator has no email, so we redirect directly to finished page without sending email"); header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); @@ -736,17 +738,23 @@ function sendMail ($id, $cancreate, $now, $autoValidation){ setEventMessages($mail->error, $mail->errors, 'warnings'); $action = ''; } else { + //@todo make object return errors + //@todo remove redisrection here ! header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } } else { + //@todo make object return errors + //@todo remove redisrection here ! setEventMessages($object->error, $object->errors, 'errors'); $action = ''; } } }else{ + //@todo make object return errors + //@todo remove redisrection here ! setEventMessage($langs->trans('ErrorloadUserOnSendingMail'),'warning'); } - + return 'objerrors'; } From c87c6ad042b2881018a59fabed7f5a9a43da13a9 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 8 Jun 2022 07:26:00 +0000 Subject: [PATCH 030/367] Fixing style errors. --- htdocs/core/menus/standard/eldy.lib.php | 3 +- htdocs/holiday/card_group.php | 54 +++++++++++-------------- 2 files changed, 25 insertions(+), 32 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 6427c0b07d7..3e0ac2d371d 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -2270,7 +2270,7 @@ function get_left_menu_hrm($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = $newmenu->add("/holiday/list.php?mainmenu=hrm&leftmenu=holiday", $langs->trans("CPTitreMenu"), 0, $user->rights->holiday->read, '', $mainmenu, 'holiday', 0, '', '', '', img_picto('', 'holiday', 'class="pictofixedwidth"')); $newmenu->add("/holiday/card.php?mainmenu=hrm&leftmenu=holiday&action=create", $langs->trans("New"), 1, $user->rights->holiday->write, '', $mainmenu); - $newmenu->add("/holiday/card_group.php?mainmenu=hrm&leftmenu=holiday&action=request", $langs->trans("NewHolidayForGroup"), 1, ($user->rights->holiday->writeall && $user->rights->holiday->readall) , '', $mainmenu, 'holiday_sm'); + $newmenu->add("/holiday/card_group.php?mainmenu=hrm&leftmenu=holiday&action=request", $langs->trans("NewHolidayForGroup"), 1, ($user->rights->holiday->writeall && $user->rights->holiday->readall), '', $mainmenu, 'holiday_sm'); $newmenu->add("/holiday/list.php?mainmenu=hrm&leftmenu=holiday", $langs->trans("List"), 1, $user->rights->holiday->read, '', $mainmenu); if ($usemenuhider || empty($leftmenu) || $leftmenu == "holiday") { $newmenu->add("/holiday/list.php?search_status=1&mainmenu=hrm&leftmenu=holiday", $langs->trans("DraftCP"), 2, $user->rights->holiday->read, '', $mainmenu, 'holiday_sm'); @@ -2282,7 +2282,6 @@ function get_left_menu_hrm($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = $newmenu->add("/holiday/define_holiday.php?mainmenu=hrm&action=request", $langs->trans("MenuConfCP"), 1, $user->rights->holiday->read, '', $mainmenu, 'holiday_sm'); $newmenu->add("/holiday/month_report.php?mainmenu=hrm&leftmenu=holiday", $langs->trans("MenuReportMonth"), 1, $user->rights->holiday->readall, '', $mainmenu, 'holiday_sm'); $newmenu->add("/holiday/view_log.php?mainmenu=hrm&leftmenu=holiday&action=request", $langs->trans("MenuLogCP"), 1, $user->rights->holiday->define_holiday, '', $mainmenu, 'holiday_sm'); - } // Trips and expenses (old module) diff --git a/htdocs/holiday/card_group.php b/htdocs/holiday/card_group.php index a51f9c6ab20..a786191acd1 100644 --- a/htdocs/holiday/card_group.php +++ b/htdocs/holiday/card_group.php @@ -49,10 +49,10 @@ $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); $fuserid = (GETPOST('fuserid', 'int') ?GETPOST('fuserid', 'int') : $user->id); $users = (GETPOST('users', 'array') ?GETPOST('users', 'array') : array($user->id)); -$groups = GETPOST('groups', 'array') ; +$groups = GETPOST('groups', 'array'); $socid = GETPOST('socid', 'int'); -$autoValidation = GETPOST('autoValidation','int'); -$AutoSendMail = GETPOST('AutoSendMail','int'); +$autoValidation = GETPOST('autoValidation', 'int'); +$AutoSendMail = GETPOST('AutoSendMail', 'int'); // Load translation files required by the page $langs->loadLangs(array("other", "holiday", "mails", "trips")); @@ -162,9 +162,8 @@ if (empty($reshook)) { } if (!$error) { - $users = GETPOST('users', 'array'); - $groups = GETPOST('groups', 'array') ; + $groups = GETPOST('groups', 'array'); $date_debut = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year')); $date_fin = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year')); @@ -209,7 +208,7 @@ if (empty($reshook)) { } } // If no groups and no users - if (empty($groups) && empty($users)){ + if (empty($groups) && empty($users)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("User")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Group")), null, 'errors'); $error++; @@ -259,7 +258,6 @@ if (empty($reshook)) { if (!$error) { - $TusersToProcess = array(); /** GROUPS */ @@ -290,10 +288,10 @@ if (empty($reshook)) { $userError = new User($db); $result = $userError->fetch($u); - if ($result){ - setEventMessages($langs->trans("UseralreadyCPexist",$userError->firstname . ' '. $userError->lastname), null, 'errors'); - }else{ - setEventMessages($langs->trans("ErrorUserFetch",$u), null, 'errors'); + if ($result) { + setEventMessages($langs->trans("UseralreadyCPexist", $userError->firstname . ' '. $userError->lastname), null, 'errors'); + } else { + setEventMessages($langs->trans("ErrorUserFetch", $u), null, 'errors'); } $error++; @@ -305,7 +303,6 @@ if (empty($reshook)) { $db->begin(); // non errors we can insert all foreach ($TusersToProcess as $u) { - $object = new Holiday($db); $object->fk_user = $u; $object->description = $description; @@ -320,30 +317,27 @@ if (empty($reshook)) { if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; - }else{ + } else { // AUTO APPROUVAL /VALIDATED //@TODO changer le nom si approuved / validated - if ($autoValidation){ + if ($autoValidation) { $htemp = new Holiday($db); - $htemp->fetch ($result); + $htemp->fetch($result); $htemp->statut = Holiday::STATUS_VALIDATED; $resultValidated = $htemp->update($approverid); - if ($resultValidated < 0 ){ + if ($resultValidated < 0 ) { setEventMessages($object->error, $object->errors, 'errors'); $error++; } // we can auto send mail if we are in auto validation behavior //@todo jquery disable if checkbox autovalidation unchecked - if ($AutoSendMail && !$error){ + if ($AutoSendMail && !$error) { // send a mail to the user sendMail($result, $cancreate, $now, $autoValidation); } } - - - } } } @@ -475,7 +469,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { $resql = $db->query($sql); $Tgroup = array(); - while ($obj = $db->fetch_object($resql)){ + while ($obj = $db->fetch_object($resql)) { $Tgroup[$obj->rowid] = $obj->nom; } print $form->multiselectarray('groups', $Tgroup, GETPOST('groups', 'array'), '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); @@ -493,15 +487,14 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { if ($cancreate && !$cancreateall) { - - }else{ + } else { //$sql .= ' AND u.fk_user = '.$user->id; //$sql .= ' OR u.rowid ='.$user->id; } $resql = $db->query($sql); - if ($resql){ - while ($obj = $db->fetch_object($resql)){ + if ($resql) { + while ($obj = $db->fetch_object($resql)) { $userlist[$obj->rowid] = $obj->firstname . ' '. $obj->lastname; } } @@ -646,7 +639,8 @@ if (is_object($db)) { * @return string|void * @throws Exception */ -function sendMail ($id, $cancreate, $now, $autoValidation){ +function sendMail($id, $cancreate, $now, $autoValidation) +{ global $db, $user, $conf, $langs; @@ -654,7 +648,7 @@ function sendMail ($id, $cancreate, $now, $autoValidation){ $result = $object->fetch($id); - if ($result){ + if ($result) { // If draft and owner of leave if ($object->statut == Holiday::STATUS_DRAFT && $cancreate) { $object->oldcopy = dol_clone($object); @@ -750,11 +744,11 @@ function sendMail ($id, $cancreate, $now, $autoValidation){ $action = ''; } } - }else{ + } else { //@todo make object return errors //@todo remove redisrection here ! - setEventMessage($langs->trans('ErrorloadUserOnSendingMail'),'warning'); + setEventMessage($langs->trans('ErrorloadUserOnSendingMail'), 'warning'); } - return 'objerrors'; + return 'objerrors'; } From 7df97d1f3dad1ec19fa5b0dcd3b7220af1fe04c0 Mon Sep 17 00:00:00 2001 From: jpb Date: Wed, 8 Jun 2022 10:09:30 +0200 Subject: [PATCH 031/367] rename autovalidation --- htdocs/holiday/card_group.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/holiday/card_group.php b/htdocs/holiday/card_group.php index a51f9c6ab20..49605a69511 100644 --- a/htdocs/holiday/card_group.php +++ b/htdocs/holiday/card_group.php @@ -591,9 +591,9 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { print '
'.$langs->trans("AutoApprovalOnCreate").''; - print ''; + print ''; print '
'; print ''; @@ -485,13 +498,6 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { $sql .= ' WHERE 1=1 '; $sql .= !empty($morefilter) ? $morefilter : ''; - - if ($cancreate && !$cancreateall) { - } else { - //$sql .= ' AND u.fk_user = '.$user->id; - //$sql .= ' OR u.rowid ='.$user->id; - } - $resql = $db->query($sql); if ($resql) { while ($obj = $db->fetch_object($resql)) { @@ -586,13 +592,13 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { //auto validation ON CREATE print ''."\n"; //no auto SEND MAIL print ''."\n"; // Description @@ -641,6 +647,11 @@ if (is_object($db)) { */ function sendMail($id, $cancreate, $now, $autoValidation) { + $objStd = new stdClass(); + $objStd->msg = ''; + $objStd->status = 'success'; + $objStd->error = 0; + $objStd->style = ''; global $db, $user, $conf, $langs; @@ -657,19 +668,21 @@ function sendMail($id, $cancreate, $now, $autoValidation) $verif = $object->validate($user); - // If no SQL error, we redirect to the request form if ($verif > 0) { // To $destinataire = new User($db); $destinataire->fetch($object->fk_validator); $emailTo = $destinataire->email; - //@todo make object return errors - //@todo remove redisrection here ! + if (!$emailTo) { dol_syslog("Expected validator has no email, so we redirect directly to finished page without sending email"); - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; + + $objStd->error++; + $objStd->msg = $langs->trans('ErroremailTo'); + $objStd->status = 'error'; + $objStd->style="warnings"; + return $objStd; } // From @@ -729,26 +742,34 @@ function sendMail($id, $cancreate, $now, $autoValidation) $result = $mail->sendfile(); if (!$result) { - setEventMessages($mail->error, $mail->errors, 'warnings'); - $action = ''; + + $objStd->error++; + $objStd->msg = $langs->trans('ErroreSendmail'); + $objStd->style="warnings"; + $objStd->status = 'error'; } else { - //@todo make object return errors - //@todo remove redisrection here ! - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; + + $objStd->msg = $langs->trans('mailSended'); } + + return $objStd; } else { - //@todo make object return errors - //@todo remove redisrection here ! - setEventMessages($object->error, $object->errors, 'errors'); - $action = ''; + + $objStd->error++; + $objStd->msg = $langs->trans('ErroreVerif'); + $objStd->status = 'error'; + $objStd->style="errors"; + return $objStd; } } } else { - //@todo make object return errors - //@todo remove redisrection here ! - setEventMessage($langs->trans('ErrorloadUserOnSendingMail'), 'warning'); + + $objStd->error++; + $objStd->msg = $langs->trans('ErrorloadUserOnSendingMail'); + $objStd->status = 'error'; + $objStd->style="warnings"; + return $objStd; } - return 'objerrors'; + return $objStd; } From 189d918181f906e0caf7083d287481079f9b8e94 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 8 Jun 2022 15:14:18 +0000 Subject: [PATCH 033/367] Fixing style errors. --- htdocs/holiday/card_group.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/htdocs/holiday/card_group.php b/htdocs/holiday/card_group.php index 898d9f53be8..19f5e1a5fd8 100644 --- a/htdocs/holiday/card_group.php +++ b/htdocs/holiday/card_group.php @@ -318,7 +318,6 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); $error++; } else { - //@TODO changer le nom si validated if ($autoValidation) { $htemp = new Holiday($db); @@ -336,7 +335,7 @@ if (empty($reshook)) { if ($AutoSendMail && !$error) { // send a mail to the user $returnSendMail = sendMail($result, $cancreate, $now, $autoValidation); - if (!empty($returnSendMail->msg)) setEventMessage($returnSendMail->msg,$returnSendMail->style); + if (!empty($returnSendMail->msg)) setEventMessage($returnSendMail->msg, $returnSendMail->style); } } } @@ -742,19 +741,16 @@ function sendMail($id, $cancreate, $now, $autoValidation) $result = $mail->sendfile(); if (!$result) { - $objStd->error++; $objStd->msg = $langs->trans('ErroreSendmail'); $objStd->style="warnings"; $objStd->status = 'error'; } else { - $objStd->msg = $langs->trans('mailSended'); } return $objStd; } else { - $objStd->error++; $objStd->msg = $langs->trans('ErroreVerif'); $objStd->status = 'error'; @@ -763,7 +759,6 @@ function sendMail($id, $cancreate, $now, $autoValidation) } } } else { - $objStd->error++; $objStd->msg = $langs->trans('ErrorloadUserOnSendingMail'); $objStd->status = 'error'; From 9ad5553c47b064fa4e3b30fe6824d101a52f38c7 Mon Sep 17 00:00:00 2001 From: melina Date: Wed, 8 Jun 2022 17:56:11 +0200 Subject: [PATCH 034/367] Add setup parameters --- htdocs/langs/en_US/cashdesk.lang | 8 +++++- htdocs/langs/fr_FR/cashdesk.lang | 6 ++++ htdocs/takepos/admin/appearance.php | 43 +++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index b53eb235c29..07b91316771 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -136,4 +136,10 @@ PrintWithoutDetails=Print without details YearNotDefined=Year is not defined TakeposBarcodeRuleToInsertProduct=Barcode rule to insert product TakeposBarcodeRuleToInsertProductDesc=Rule to extract the product reference + a quantity from a scanned barcode.
If empty (default value), application will use the full barcode scanned to find the product.

If defined, syntax must be:
ref:NB+qu:NB+qd:NB+other:NB
where NB is the number of characters to use to extract data from the scanned barcode with:
  • ref : product reference
  • qu : quantity to set when inserting item (units)
  • qd : quantity to set when inserting item (decimals)
  • other : others characters
-AlreadyPrinted=Already printed \ No newline at end of file +AlreadyPrinted=Already printed +HideCategories=Hide categories +HideStockOnLine=Hide stock on line +ShowOnlyProductInStock=Show the products in stock +ShowCategoryDescription=Show category description +ShowProductReference=Show reference of products +UsePriceHT=Use price excl. taxes and not price incl. taxes \ No newline at end of file diff --git a/htdocs/langs/fr_FR/cashdesk.lang b/htdocs/langs/fr_FR/cashdesk.lang index 24d35d56a06..5ce6fb98a5d 100644 --- a/htdocs/langs/fr_FR/cashdesk.lang +++ b/htdocs/langs/fr_FR/cashdesk.lang @@ -136,3 +136,9 @@ PrintWithoutDetails=Générer sans les détails YearNotDefined=L'année n'est pas définie TakeposBarcodeRuleToInsertProduct=Règle de lecture du code barre des produits TakeposBarcodeRuleToInsertProductDesc=Règle pour extraire la référence produit + une quantité d'un code barre scanné.
Si vide (valeur par défaut), l'application utilisera le code-barres complet scanné pour trouver le produit.

Si elle est définie, la syntaxe doit être:
ref: NB + Qu: NB + QD: NB + autres: NB
où NB est le nombre de caractères à utiliser pour extraire les données du code à barres scannés avec:
  • ref : référence produit
  • qu : quantité de jeu lors de l'insertion article (unités)
  • qd: quantité de jeu lors de l'insertion article (décimaux)
  • autre : autres caractères
+HideCategories=Masquer les catégories +HideStockOnLine=Masquer le stock en ligne +ShowOnlyProductInStock=Affficher les produits en stock +ShowCategoryDescription=Afficher la description des catégories +ShowProductReference=Afficher la référence des produits +UsePriceHT= Utiliser le prix HT et non en TTC \ No newline at end of file diff --git a/htdocs/takepos/admin/appearance.php b/htdocs/takepos/admin/appearance.php index 135a3b2a9e7..060c955728d 100644 --- a/htdocs/takepos/admin/appearance.php +++ b/htdocs/takepos/admin/appearance.php @@ -117,6 +117,49 @@ $array = array(1=>"1", 2=>"2", 3=>"3", 4=>"4", 5=>"5", 6=>"6"); print $form->selectarray('TAKEPOS_LINES_TO_SHOW', $array, (empty($conf->global->TAKEPOS_LINES_TO_SHOW) ? '2' : $conf->global->TAKEPOS_LINES_TO_SHOW), 0); print "\n"; +// D'ont display category +print '
\n"; + +// Hide stock on line +print '\n"; + +// Only the products in stock +print '\n"; + +// View description of the categories +print '\n"; + +// View reference of products +print '\n"; + +// Use price excl. taxes (HT) and not price incl. taxes (TTC) +print '\n"; + + print '
'.$langs->trans("AutoApprovalOnCreate").''; - print ''; + print ''; print '
'.$langs->trans("AutoSendMail").''; - print ''; + print ''; print '
'; +print $langs->trans('HideCategories'); +print ''; +print ajax_constantonoff("TAKEPOS_HIDE_CATEGORIES", array(), $conf->entity, 0, 0, 1, 0); +print "
'; +print $langs->trans('HideStockOnLine'); +print ''; +print ajax_constantonoff("TAKEPOS_HIDE_STOCK_ON_LINE", array(), $conf->entity, 0, 0, 1, 0); +print "
'; +print $langs->trans('ShowOnlyProductInStock'); +print ''; +print ajax_constantonoff("TAKEPOS_PRODUCT_IN_STOCK", array(), $conf->entity, 0, 0, 1, 0); +print "
'; +print $langs->trans('ShowCategoryDescription'); +print ''; +print ajax_constantonoff("TAKEPOS_SHOW_CATEGORY_DESCRIPTION", array(), $conf->entity, 0, 0, 1, 0); +print "
'; +print $langs->trans('ShowProductReference'); +print ''; +print ajax_constantonoff("TAKEPOS_SHOW_PRODUCT_REFERENCE", array(), $conf->entity, 0, 0, 1, 0); +print "
'; +print $langs->trans('UsePriceHT'); +print ''; +print ajax_constantonoff("TAKEPOS_CHANGE_PRICE_HT", array(), $conf->entity, 0, 0, 1, 0); +print "
'; print $form->buttonsSaveCancel("Save", ''); From fb3f2698ae6c58b4340b4061626f55176f60aaec Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 9 Jun 2022 08:46:46 +0000 Subject: [PATCH 035/367] Fixing style errors. --- htdocs/takepos/admin/appearance.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/admin/appearance.php b/htdocs/takepos/admin/appearance.php index 060c955728d..9198b03bb63 100644 --- a/htdocs/takepos/admin/appearance.php +++ b/htdocs/takepos/admin/appearance.php @@ -124,7 +124,7 @@ print ''; print ajax_constantonoff("TAKEPOS_HIDE_CATEGORIES", array(), $conf->entity, 0, 0, 1, 0); print "\n"; -// Hide stock on line +// Hide stock on line print ''; print $langs->trans('HideStockOnLine'); print ''; From 50ae1b1f7693f53cc687c681a4cd716bb8822db0 Mon Sep 17 00:00:00 2001 From: kamel Date: Fri, 10 Jun 2022 10:19:56 +0200 Subject: [PATCH 036/367] NEW: Add new hook for show virtual stock details on product stock card --- htdocs/product/stock/product.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index b9fc1a201e5..e8622781a3f 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -734,6 +734,15 @@ if ($id > 0 || $ref) { $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) ? '- '.$langs->trans("ReStockOnValidateOrder").'
' : ''); $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) ? '- '.$langs->trans("ReStockOnDispatchOrder").'
' : ''); $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE) ? '- '.$langs->trans("StockOnReception").'
' : ''); + $parameters = array(); + $reshook = $hookmanager->executeHooks('physicalStockTextStockOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook > 0) { + $text_stock_options = $hookmanager->resPrint; + } elseif ($reshook == 0) { + $text_stock_options .= $hookmanager->resPrint; + } else { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } print ''; print $form->textwithpicto($langs->trans("PhysicalStock"), $text_stock_options, 1); @@ -820,6 +829,15 @@ if ($id > 0 || $ref) { $helpondiff .= $langs->trans("ProductQtyToConsumeByMO").': '.$object->stats_mrptoconsume['qty'].'
'; $helpondiff .= $langs->trans("ProductQtyToProduceByMO").': '.$object->stats_mrptoproduce['qty']; } + $parameters = array('found' => &$found, 'id' => $object->id, 'includedraftpoforvirtual' => null); + $reshook = $hookmanager->executeHooks('virtualStockHelpOnDiff', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook > 0) { + $helpondiff = $hookmanager->resPrint; + } elseif ($reshook == 0) { + $helpondiff .= $hookmanager->resPrint; + } else { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } // Calculating a theorical value From 19cb81e3ea3247ded71b35c58bbab6e4e35d1070 Mon Sep 17 00:00:00 2001 From: jpb Date: Sat, 11 Jun 2022 10:16:04 +0200 Subject: [PATCH 037/367] change filter array method on users selection from groups --- htdocs/holiday/card_group.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/htdocs/holiday/card_group.php b/htdocs/holiday/card_group.php index 898d9f53be8..07beaeeb678 100644 --- a/htdocs/holiday/card_group.php +++ b/htdocs/holiday/card_group.php @@ -259,7 +259,7 @@ if (empty($reshook)) { if (!$error) { $TusersToProcess = array(); - + // usergroup select /** GROUPS */ $sql = ' SELECT DISTINCT u.rowid,u.lastname,u.firstname from ' . MAIN_DB_PREFIX . 'user as u'; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'usergroup_user as ug on ug.fk_user = u.rowid '; @@ -268,15 +268,13 @@ if (empty($reshook)) { if ($resql) { while ($obj = $db->fetch_object($resql)) { - if (!array_key_exists($obj->rowid, $TusersToProcess)) - $TusersToProcess[] = $obj->rowid; + $TusersToProcess[$obj->rowid] = $obj->rowid; } } /** USERS */ if (is_array($users) && count($users) > 0) { foreach ($users as $u) { - if (!array_key_exists($u, $TusersToProcess)) - $TusersToProcess[] = $u; + $TusersToProcess[$u] = $u; } } foreach ($TusersToProcess as $u) { From 1af3b6ccbddd6ba5fdc3c12ba36babb281ebcc94 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sat, 11 Jun 2022 08:23:08 +0000 Subject: [PATCH 038/367] Fixing style errors. --- htdocs/holiday/card_group.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/holiday/card_group.php b/htdocs/holiday/card_group.php index 93560b9bb7c..c52ea39681d 100644 --- a/htdocs/holiday/card_group.php +++ b/htdocs/holiday/card_group.php @@ -259,7 +259,7 @@ if (empty($reshook)) { if (!$error) { $TusersToProcess = array(); - // usergroup select + // usergroup select /** GROUPS */ $sql = ' SELECT DISTINCT u.rowid,u.lastname,u.firstname from ' . MAIN_DB_PREFIX . 'user as u'; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'usergroup_user as ug on ug.fk_user = u.rowid '; From 74d23cccd8c6e84efb87d4be862c82bd8e8b91ec Mon Sep 17 00:00:00 2001 From: jpb Date: Sat, 11 Jun 2022 14:01:54 +0200 Subject: [PATCH 039/367] remove seteventMessage * precheck automail on selected auto validation --- htdocs/holiday/card_group.php | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/htdocs/holiday/card_group.php b/htdocs/holiday/card_group.php index 93560b9bb7c..57fe16ea23e 100644 --- a/htdocs/holiday/card_group.php +++ b/htdocs/holiday/card_group.php @@ -281,7 +281,7 @@ if (empty($reshook)) { // Check if there is already holiday for this period pour chaque user $verifCP = $object->verifDateHolidayCP($u, $date_debut, $date_fin, $halfday); if (!$verifCP) { - setEventMessages($langs->trans("alreadyCPexist"), null, 'errors'); + //setEventMessages($langs->trans("alreadyCPexist"), null, 'errors'); $userError = new User($db); $result = $userError->fetch($u); @@ -342,7 +342,7 @@ if (empty($reshook)) { // If no SQL error we redirect to the request card if (!$error) { $db->commit(); - header('Location: '.DOL_URL_ROOT.'/holiday/list.php?restore_lastsearch_values=1'); + header('Location: '.DOL_URL_ROOT.'/holiday/list.php'); exit; } else { $db->rollback(); @@ -414,10 +414,27 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { if( $("input[name=autoValidation]").is(":checked") ){ $("#AutoSendMail").prop("disabled", false); + $("#AutoSendMail").prop("checked", true); + } else { $("#AutoSendMail").prop("disabled", true); + $("#AutoSendMail").prop("checked", false); } + $("input[name=autoValidation]").click( function(e) { + console.log("chang") + + if( $("input[name=autoValidation]").is(":checked") ){ + $("#AutoSendMail").prop("disabled", false); + $("#AutoSendMail").prop("checked", true); + } else { + $("#AutoSendMail").prop("disabled", true); + $("#AutoSendMail").prop("checked", false); + } + }); + + + $("input.button-save").click("submit", function(e) { console.log("Call valider()"); if (document.demandeCP.date_debut_.value != "") @@ -588,7 +605,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { print ''; //auto validation ON CREATE - print ''.$langs->trans("AutoApprovalOnCreate").''; + print ''.$langs->trans("AutoValidationOnCreate").''; print ''; print ''."\n"; @@ -658,10 +675,10 @@ function sendMail($id, $cancreate, $now, $autoValidation) if ($result) { // If draft and owner of leave - if ($object->statut == Holiday::STATUS_DRAFT && $cancreate) { + if ($object->statut == Holiday::STATUS_VALIDATED && $cancreate) { $object->oldcopy = dol_clone($object); - if ($autoValidation) $object->statut = Holiday::STATUS_VALIDATED; + //if ($autoValidation) $object->statut = Holiday::STATUS_VALIDATED; $verif = $object->validate($user); From 348fb8e9f23e1001cfa7afda0543b144827f9128 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sun, 12 Jun 2022 21:34:35 +0200 Subject: [PATCH 040/367] Stripe Terminal --- htdocs/stripe/admin/stripe.php | 54 +++++++ htdocs/stripe/ajax/ajax.php | 124 +++++++++++++++ htdocs/stripe/class/stripe.class.php | 41 ++++- htdocs/takepos/admin/terminal.php | 43 +++++ htdocs/takepos/pay.php | 229 ++++++++++++++++++++++++++- 5 files changed, 486 insertions(+), 5 deletions(-) create mode 100644 htdocs/stripe/ajax/ajax.php diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 77c8d9a03b2..8240b21ff75 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -104,6 +104,10 @@ if ($action == 'setvalue' && $user->admin) { if (!$result > 0) { $error++; } + $result = dolibarr_set_const($db, "STRIPE_LOCATION", GETPOST('STRIPE_LOCATION', 'alpha'), 'chaine', 0, '', $conf->entity); + if (!$result > 0) { + $error++; + } $result = dolibarr_set_const($db, "ONLINE_PAYMENT_CSS_URL", GETPOST('ONLINE_PAYMENT_CSS_URL', 'alpha'), 'chaine', 0, '', $conf->entity); if (!$result > 0) { $error++; @@ -364,6 +368,56 @@ if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { // What is this for ? print ''; } +// Card Present for Stripe Terminal +if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code + print ''; + print $langs->trans("STRIPE_CARD_PRESENT").''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STRIPE_CARD_PRESENT'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STRIPE_CARD_PRESENT", $arrval, $conf->global->STRIPE_CARD_PRESENT); + } + print ''; +} + +// Locations for Stripe Terminal +if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code + print ''; + print $langs->trans("STRIPE_LOCATION").''; + $service = 'StripeTest'; + $servicestatus = 0; + if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha')) { + $service = 'StripeLive'; + $servicestatus = 1; + } + global $stripearrayofkeysbyenv; + $site_account = $stripearrayofkeysbyenv[$servicestatus]['secret_key']; + \Stripe\Stripe::setApiKey($site_account); + if (!empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) { + $service = 'StripeTest'; + $servicestatus = '0'; + dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning'); + } else { + $service = 'StripeLive'; + $servicestatus = '1'; + } + $stripe = new Stripe($db); + $stripeacc = $stripe->getStripeAccount($service); + if ($stripeacc) { + $locations = \Stripe\Terminal\Location::all('', array("stripe_account" => $stripeacc)); + } else { + $locations = \Stripe\Terminal\Location::all(); + } + $location = array(); + $location[""] = $langs->trans("EmptyLocation"); + foreach ($locations as $locations) { + $location[$locations->id] = $locations->display_name; + } + print $form->selectarray("STRIPE_LOCATION", $location, $conf->global->STRIPE_LOCATION); + print ''; +} + // Activate Payment Request API if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code print ''; diff --git a/htdocs/stripe/ajax/ajax.php b/htdocs/stripe/ajax/ajax.php new file mode 100644 index 00000000000..e50b426ee87 --- /dev/null +++ b/htdocs/stripe/ajax/ajax.php @@ -0,0 +1,124 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/stripe/ajax/ajax.php + * \brief Ajax action for Stipe ie: Terminal + */ + +if (!defined('NOCSRFCHECK')) { + define('NOCSRFCHECK', '1'); +} +if (!defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', '1'); +} +if (!defined('NOREQUIREMENU')) { + define('NOREQUIREMENU', '1'); +} +if (!defined('NOREQUIREHTML')) { + define('NOREQUIREHTML', '1'); +} +if (!defined('NOREQUIREAJAX')) { + define('NOREQUIREAJAX', '1'); +} +if (!defined('NOBROWSERNOTIF')) { + define('NOBROWSERNOTIF', '1'); +} + +require '../../main.inc.php'; // Load $user and permissions +require_once DOL_DOCUMENT_ROOT.'/includes/stripe/stripe-php/init.php'; +require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + +$action = GETPOST('action', 'aZ09'); +$location = GETPOST('location', 'alphanohtml'); +$stripeacc = GETPOST('stripeacc', 'alphanohtml'); +$servicestatus = GETPOST('servicestatus', 'int'); +$amount = GETPOST('amount', 'int'); + +if (empty($user->rights->takepos->run)) { + accessforbidden(); +} + + +/* + * View + */ + +if ($action == 'getConnexionToken') { + try { + // Be sure to authenticate the endpoint for creating connection tokens. + // Force to use the correct API key + global $stripearrayofkeysbyenv; + \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus]['secret_key']); + // The ConnectionToken's secret lets you connect to any Stripe Terminal reader + // and take payments with your Stripe account. + $array = array(); + if (isset($location) && !empty($location)) $array['location'] = $location; + if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage + $connectionToken = \Stripe\Terminal\ConnectionToken::create($array); + } else { + $connectionToken = \Stripe\Terminal\ConnectionToken::create($array, array("stripe_account" => $stripeacc)); + } + echo json_encode(array('secret' => $connectionToken->secret)); + } catch (Error $e) { + http_response_code(500); + echo json_encode(['error' => $e->getMessage()]); + } +} elseif ($action == 'createPaymentIntent') { + try { + $json_str = file_get_contents('php://input'); + $json_obj = json_decode($json_str); + + // For Terminal payments, the 'payment_method_types' parameter must include + // 'card_present' and the 'capture_method' must be set to 'manual' + $object = new Facture($db); + $object->fetch($json_obj->invoiceid); + $object->fetch_thirdparty(); + + $fulltag='INV='.$object->id.'.CUS='.$object->thirdparty->id; + $tag=null; + $fulltag=dol_string_unaccent($fulltag); + + $stripe = new Stripe($db); + $customer = $stripe->customerStripe($object->thirdparty, $stripeacc, $servicestatus, 1); + + $intent = $stripe->getPaymentIntent($json_obj->amount, $object->multicurrency_code, null, 'Stripe payment: '.$fulltag.(is_object($object)?' ref='.$object->ref:''), $object, $customer, $stripeacc, $servicestatus, 1, 'terminal', false, null, 0, 1); + + echo json_encode(array('client_secret' => $intent->client_secret)); + } catch (Error $e) { + http_response_code(500); + echo json_encode(['error' => $e->getMessage()]); + } +} elseif ($action == 'capturePaymentIntent') { + try { + // retrieve JSON from POST body + $json_str = file_get_contents('php://input'); + $json_obj = json_decode($json_str); + if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage + $intent = \Stripe\PaymentIntent::retrieve($json_obj->id); + } else { + $intent = \Stripe\PaymentIntent::retrieve($json_obj->id, array("stripe_account" => $stripeacc)); + } + $intent = $intent->capture(); + + echo json_encode($intent); + } catch (Error $e) { + http_response_code(500); + echo json_encode(['error' => $e->getMessage()]); + } +} diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 36e67d2827c..b14ed0e8ca6 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -290,6 +290,34 @@ class Stripe extends CommonObject return $stripepaymentmethod; } + /** + * Get the Stripe reader Object from its ID + * + * @param string $reader Reader ID + * @param string $key ''=Use common API. If not '', it is the Stripe connect account 'acc_....' to use Stripe connect + * @param int $status Status (0=test, 1=live) + * @return \Stripe\Terminal\Reader|null Stripe Reader or null if not found + */ + public function getSelectedReader($reader, $key = '', $status = 0) + { + $selectedreader = null; + + try { + // Force to use the correct API key + global $stripearrayofkeysbyenv; + \Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$status]['secret_key']); + if (empty($key)) { // If the Stripe connect account not set, we use common API usage + $selectedreader = \Stripe\Terminal\Reader::retrieve(''.$reader.''); + } else { + $stripepaymentmethod = \Stripe\Terminal\Reader::retrieve(''.$reader.'', array("stripe_account" => $key)); + } + } catch (Exception $e) { + $this->error = $e->getMessage(); + } + + return $selectedreader; + } + /** * Get the Stripe payment intent. Create it with confirmnow=false * Warning. If a payment was tried and failed, a payment intent was created. @@ -350,7 +378,7 @@ class Stripe extends CommonObject $paymentintent = null; - if (is_object($object) && !empty($conf->global->STRIPE_REUSE_EXISTING_INTENT_IF_FOUND)) { + if (is_object($object) && !empty($conf->global->STRIPE_REUSE_EXISTING_INTENT_IF_FOUND) && empty($conf->global->STRIPE_CARD_PRESENT)) { // Warning. If a payment was tried and failed, a payment intent was created. // But if we change something on object to pay (amount or other that does not change the idempotency key), reusing same payment intent is not allowed by Stripe. // Recommended solution is to recreate a new payment intent each time we need one (old one will be automatically closed by Stripe after a delay), Stripe will @@ -424,6 +452,9 @@ class Stripe extends CommonObject if (!empty($conf->global->STRIPE_SOFORT)) { $paymentmethodtypes[] = "sofort"; } + if (!empty($conf->global->STRIPE_CARD_PRESENT) && $mode == 'terminal') { + $paymentmethodtypes = array("card_present"); + } $dataforintent = array( "confirm" => $confirmnow, // Do not confirm immediatly during creation of intent @@ -456,6 +487,11 @@ class Stripe extends CommonObject if (!empty($conf->global->STRIPE_KLARNA)) { unset($dataforintent['setup_future_usage']); } + if (!empty($conf->global->STRIPE_CARD_PRESENT) && $mode == 'terminal') { + unset($dataforintent['setup_future_usage']); + $dataforintent["capture_method"] = "manual"; + $dataforintent["confirmation_method"] = "manual"; + } if (!is_null($payment_method)) { $dataforintent["payment_method"] = $payment_method; $description .= ' - '.$payment_method; @@ -607,6 +643,9 @@ class Stripe extends CommonObject if (!empty($conf->global->STRIPE_BANCONTACT)) { $paymentmethodtypes[] = "bancontact"; } + if (!empty($conf->global->STRIPE_KLARNA)) { + $paymentmethodtypes[] = "klarna"; + } if (!empty($conf->global->STRIPE_IDEAL)) { $paymentmethodtypes[] = "ideal"; } diff --git a/htdocs/takepos/admin/terminal.php b/htdocs/takepos/admin/terminal.php index f6562d81693..64ce74b6022 100644 --- a/htdocs/takepos/admin/terminal.php +++ b/htdocs/takepos/admin/terminal.php @@ -1,6 +1,7 @@ * Copyright (C) 2011-2017 Juanjo Menent + * Copyright (C) 2021 Thibault FOUCART * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,6 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT."/core/lib/takepos.lib.php"; +require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; $terminal = GETPOST('terminal', 'int'); // If socid provided by ajax company selector @@ -73,6 +75,9 @@ if (GETPOST('action', 'alpha') == 'set') { $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CASH".$terminaltouse, (GETPOST('CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CHEQUE".$terminaltouse, (GETPOST('CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CB".$terminaltouse, (GETPOST('CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity); + if (!empty($conf->stripe->enabled) && !empty($conf->global->STRIPE_CARD_PRESENT)) { + $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL".$terminaltouse, GETPOST('CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity); + } if (!empty($conf->global->TAKEPOS_ENABLE_SUMUP)) { $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_SUMUP".$terminaltouse, (GETPOST('CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity); } @@ -174,6 +179,44 @@ if (!empty($conf->banque->enabled)) { $atleastonefound++; } print ''; + + if (!empty($conf->stripe->enabled) && !empty($conf->global->STRIPE_CARD_PRESENT)) { + print ''.$langs->trans("CashDeskBankAccountForStripeTerminal").''; // Force Stripe Terminal + print ''; + $service = 'StripeTest'; + $servicestatus = 0; + if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha')) { + $service = 'StripeLive'; + $servicestatus = 1; + } + global $stripearrayofkeysbyenv; + $site_account = $stripearrayofkeysbyenv[$servicestatus]['secret_key']; + \Stripe\Stripe::setApiKey($site_account); + if (!empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) { + $service = 'StripeTest'; + $servicestatus = '0'; + dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning'); + } else { + $service = 'StripeLive'; + $servicestatus = '1'; + } + $stripe = new Stripe($db); + $stripeacc = $stripe->getStripeAccount($service); + if ($stripeacc) { + $readers = \Stripe\Terminal\Reader::all('', array("location" => $conf->global->STRIPE_LOCATION, "stripe_account" => $stripeacc)); + } else { + $readers = \Stripe\Terminal\Reader::all('', array("location" => $conf->global->STRIPE_LOCATION)); + } + + $reader = array(); + $reader[""] = $langs->trans("NoReader"); + foreach ($readers as $readers) { + $reader[$reader->id] = $readers->label.' ('.$readers->status.')'; + } + print $form->selectarray('CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL'.$terminaltouse, $reader, $conf->global->{'CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL'.$terminaltouse}); + print ''; + } + if ($conf->global->TAKEPOS_ENABLE_SUMUP) { print ''.$langs->trans("CashDeskBankAccountForSumup").''; print ''; diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php index 40d873654c6..cc1d335272d 100644 --- a/htdocs/takepos/pay.php +++ b/htdocs/takepos/pay.php @@ -1,5 +1,6 @@ + * Copyright (C) 2021 Thibault FOUCART * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -40,6 +41,7 @@ if (!defined('NOREQUIREHTML')) { require '../main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; $langs->loadLangs(array("main", "bills", "cashdesk", "banks")); @@ -51,11 +53,60 @@ if (empty($user->rights->takepos->run)) { accessforbidden(); } +if (!empty($conf->stripe->enabled)) { + $service = 'StripeTest'; + $servicestatus = 0; + if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha')) { + $service = 'StripeLive'; + $servicestatus = 1; + } + + // Force to use the correct API key + global $stripearrayofkeysbyenv; + $site_account = $stripearrayofkeysbyenv[$servicestatus]['publishable_key']; + + $stripe = new Stripe($db); + $stripeacc = $stripe->getStripeAccount($service); // Get Stripe OAuth connect account (no remote access to Stripe here) + $stripecu = $stripe->getStripeCustomerAccount($object->id, $servicestatus, $site_account); // Get remote Stripe customer 'cus_...' (no remote access to Stripe here) + $keyforstripeterminalbank = "CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL".$_SESSION["takeposterminal"]; + ?> + + +stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) { + dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning', 1); +} + $invoice = new Facture($db); if ($invoiceid > 0) { $invoice->fetch($invoiceid); @@ -73,6 +124,57 @@ if ($invoiceid > 0) { } } +?> + +global->TAKEPOS_NUMPAD == 0) { }); } + function fetchPaymentIntentClientSecret(amount, invoiceid) { + const bodyContent = JSON.stringify({ amount : amount, invoiceid : invoiceid }); + + return fetch('', { + method: "POST", + headers: { + 'Content-Type': 'application/json' + }, + body: bodyContent + }) + .then(function(response) { + return response.json(); + }) + .then(function(data) { + return data.client_secret; + }); + } + + + function capturePaymentIntent(paymentIntentId) { + const bodyContent = JSON.stringify({"id": paymentIntentId}) + + return fetch('', { + method: "POST", + headers: { + 'Content-Type': 'application/json' + }, + body: bodyContent + }) + .then(function(response) { + return response.json(); + }) + .then(function(data) { + return data.client_secret; + }); + } + + + function ValidateStripeTerminal() { + console.log("Launch ValidateStripeTerminal"); + var invoiceid = 0 ? $invoiceid : 0); ?>; + var accountid = $("#selectaccountid").val(); + var amountpayed = $("#change1").val(); + var excess = $("#change2").val(); + if (amountpayed > getRemainToPay(); ?>) { + amountpayed = getRemainToPay(); ?>; + } + if (amountpayed == 0) { + amountpayed = getRemainToPay(); ?>; + } + + console.log("Pay with terminal ", amountpayed); + + fetchPaymentIntentClientSecret(amountpayed, invoiceid).then(function(client_secret) { + global->STRIPE_TERMINAL_SIMULATED)) { ?> + terminal.setSimulatorConfiguration({testCardNumber: 'global->STRIPE_TERMINAL_SIMULATED; ?>'}); + + document.getElementById("card-present-alert").innerHTML = '
trans('PaymentSendToStripeTerminal'); ?>
'; + terminal.collectPaymentMethod(client_secret).then(function(result) { + if (result.error) { + // Placeholder for handling result.error + document.getElementById("card-present-alert").innerHTML = '
'+result.error.message+'
'; + } else { + document.getElementById("card-present-alert").innerHTML = '
trans('PaymentBeingProcessed'); ?>
'; + console.log('terminal.collectPaymentMethod', result.paymentIntent); + terminal.processPayment(result.paymentIntent).then(function(result) { + if (result.error) { + document.getElementById("card-present-alert").innerHTML = '
'+result.error.message+'
'; + console.log(result.error) + } else if (result.paymentIntent) { + paymentIntentId = result.paymentIntent.id; + console.log('terminal.processPayment', result.paymentIntent); + capturePaymentIntent(paymentIntentId).then(function(client_secret) { + if (result.error) { + // Placeholder for handling result.error + document.getElementById("card-present-alert").innerHTML = '
'+result.error.message+'
'; + console.log("error when capturing paymentIntent", result.error); + } else { + document.getElementById("card-present-alert").innerHTML = '
trans('PaymentValidated'); ?>
'; + console.log("Capture paymentIntent successfull "+paymentIntentId); + parent.$("#poslines").load("invoice.php?place=&action=valid&pay=CB&amount="+amountpayed+"&excess="+excess+"&invoiceid="+invoiceid+"&accountid="+accountid, function() { + if (amountpayed > || amountpayed == || amountpayed==0 ) { + console.log("Close popup"); + parent.$.colorbox.close(); + } + else { + console.log("Amount is not comple, so we do NOT close popup and reload it."); + location.reload(); + } + }); + + } + }); + } + }); + } + }); + }); + } + function ValidateSumup() { console.log("Launch ValidateSumup"); @@ -271,7 +479,7 @@ if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) { ?> -
+
trans('TotalTTC'); ?>: total_ttc, 1, '', 1, -1, -1, $invoice->multicurrency_code); ?>
@@ -299,7 +507,6 @@ if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) { } ?>
-
global->TAKEPOS_NUMPAD; - +if (!empty($conf->stripe->enabled) && !empty($conf->global->STRIPE_CARD_PRESENT)) { + print ''; + dol_htmloutput_mesg($langs->trans('ConnectingToStripeTerminal', 'Stripe'), '', 'warning', 1); + print ''; +} print ''; print ''; print ''; @@ -424,8 +635,18 @@ while ($i < count($arrayOfValidPaymentModes)) { $i = $i + 1; } -$keyforsumupbank = "CASHDESK_ID_BANKACCOUNT_SUMUP".$_SESSION["takeposterminal"]; +if (!empty($conf->stripe->enabled) && !empty($conf->global->STRIPE_CARD_PRESENT)) { + $keyforstripeterminalbank = "CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL".$_SESSION["takeposterminal"]; + print ''; + if (!empty($conf->global->$keyforstripeterminalbank)) { + } else { + $langs->loadLangs(array("errors", "admin")); + //print ''; + } +} + if ($conf->global->TAKEPOS_ENABLE_SUMUP) { + $keyforsumupbank = "CASHDESK_ID_BANKACCOUNT_SUMUP".$_SESSION["takeposterminal"]; if (!empty($conf->global->$keyforsumupbank)) { print ''; } else { From 627f3469336d636ea1f1a9d52c2a3231117c8463 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sun, 12 Jun 2022 21:40:21 +0200 Subject: [PATCH 041/367] Update pay.php --- htdocs/takepos/pay.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php index cc1d335272d..f4c1a0416b1 100644 --- a/htdocs/takepos/pay.php +++ b/htdocs/takepos/pay.php @@ -103,7 +103,7 @@ function fetchConnectionToken() { * View */ -if (!empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) { +if (!empty($conf->stripe->enabled) && isset($keyforstripeterminalbank) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) { dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning', 1); } @@ -524,7 +524,7 @@ $action_buttons = array( ), ); $numpad = $conf->global->TAKEPOS_NUMPAD; -if (!empty($conf->stripe->enabled) && !empty($conf->global->STRIPE_CARD_PRESENT)) { +if (!empty($conf->stripe->enabled) && isset($keyforstripeterminalbank) && !empty($conf->global->STRIPE_CARD_PRESENT)) { print ''; dol_htmloutput_mesg($langs->trans('ConnectingToStripeTerminal', 'Stripe'), '', 'warning', 1); print ''; From 87f98b5bcbeea3778a45450dfe62293bef93f042 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sun, 12 Jun 2022 21:44:17 +0200 Subject: [PATCH 042/367] Update pay.php --- htdocs/takepos/pay.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php index f4c1a0416b1..f487862e895 100644 --- a/htdocs/takepos/pay.php +++ b/htdocs/takepos/pay.php @@ -635,7 +635,7 @@ while ($i < count($arrayOfValidPaymentModes)) { $i = $i + 1; } -if (!empty($conf->stripe->enabled) && !empty($conf->global->STRIPE_CARD_PRESENT)) { +if (!empty($conf->stripe->enabled) && isset($keyforstripeterminalbank) && !empty($conf->global->STRIPE_CARD_PRESENT)) { $keyforstripeterminalbank = "CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL".$_SESSION["takeposterminal"]; print ''; if (!empty($conf->global->$keyforstripeterminalbank)) { From 616e6f5a8f833a27c46f5667c85f2c989fa2ed60 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 12 Jun 2022 19:46:22 +0000 Subject: [PATCH 043/367] Fixing style errors. --- htdocs/stripe/ajax/ajax.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/stripe/ajax/ajax.php b/htdocs/stripe/ajax/ajax.php index e50b426ee87..cf6ec53d580 100644 --- a/htdocs/stripe/ajax/ajax.php +++ b/htdocs/stripe/ajax/ajax.php @@ -92,13 +92,13 @@ if ($action == 'getConnexionToken') { $fulltag='INV='.$object->id.'.CUS='.$object->thirdparty->id; $tag=null; - $fulltag=dol_string_unaccent($fulltag); + $fulltag=dol_string_unaccent($fulltag); $stripe = new Stripe($db); $customer = $stripe->customerStripe($object->thirdparty, $stripeacc, $servicestatus, 1); $intent = $stripe->getPaymentIntent($json_obj->amount, $object->multicurrency_code, null, 'Stripe payment: '.$fulltag.(is_object($object)?' ref='.$object->ref:''), $object, $customer, $stripeacc, $servicestatus, 1, 'terminal', false, null, 0, 1); - + echo json_encode(array('client_secret' => $intent->client_secret)); } catch (Error $e) { http_response_code(500); From 0e72085be681eaf485080490fddea2cc76973007 Mon Sep 17 00:00:00 2001 From: jpb Date: Mon, 13 Jun 2022 08:36:17 +0200 Subject: [PATCH 044/367] add trads on form fields --- htdocs/holiday/card_group.php | 11 +++++++---- htdocs/langs/en_US/holiday.lang | 2 ++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/htdocs/holiday/card_group.php b/htdocs/holiday/card_group.php index 9655bb24320..5dee6e54f6c 100644 --- a/htdocs/holiday/card_group.php +++ b/htdocs/holiday/card_group.php @@ -209,8 +209,9 @@ if (empty($reshook)) { } // If no groups and no users if (empty($groups) && empty($users)) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("User")), null, 'errors'); - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Group")), null, 'errors'); + setEventMessages($langs->trans("ErrorFieldRequiredUserOrGroup"), null, 'errors'); + //setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UserOrGroup")), null, 'errors'); + //setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Group")), null, 'errors'); $error++; $action = 'create'; } @@ -486,7 +487,8 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { // groupe print ''; - print ''.$langs->trans("groups"); + print ''; + print $form->textwithpicto($langs->trans("groups"), $langs->trans("fusionGroupsUsers")); print ''; @@ -505,7 +507,8 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { // users print ''; - print ''.$langs->trans("users").''; + print ''; + print $form->textwithpicto($langs->trans("users"), $langs->trans("fusionGroupsUsers")); print ''; $sql = ' SELECT DISTINCT u.rowid,u.lastname,u.firstname from '.MAIN_DB_PREFIX.'user as u'; diff --git a/htdocs/langs/en_US/holiday.lang b/htdocs/langs/en_US/holiday.lang index 2005d7e613c..36f1e839e67 100644 --- a/htdocs/langs/en_US/holiday.lang +++ b/htdocs/langs/en_US/holiday.lang @@ -80,6 +80,8 @@ MotifCP=Reason UserCP=User ErrorAddEventToUserCP=An error occurred while adding the exceptional leave. AddEventToUserOkCP=The addition of the exceptional leave has been completed. +ErrorFieldRequiredUserOrGroup=The "group" field or the "user" field must be filled in +fusionGroupsUsers=The groups field and the user field will be merged MenuLogCP=View change logs LogCP=Log of all updates made to "Balance of Leave" ActionByCP=Updated by From 2209d31b2c6666cdd7917c48cedf80f5cf7e5819 Mon Sep 17 00:00:00 2001 From: jpb Date: Mon, 13 Jun 2022 08:51:49 +0200 Subject: [PATCH 045/367] add comment on function --- htdocs/holiday/card_group.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/holiday/card_group.php b/htdocs/holiday/card_group.php index 5dee6e54f6c..f244c6374e5 100644 --- a/htdocs/holiday/card_group.php +++ b/htdocs/holiday/card_group.php @@ -655,11 +655,11 @@ if (is_object($db)) { } /** * send email to validator for current leave represented by (id) - * @param $id - * @param $cancreate - * @param $now - * @param $autoValidation - * @return string|void + * @param $id validator for current leave represented by (id) + * @param $cancreate flag for user right + * @param $now date + * @param $autoValidation boolean flag on autovalidation + * @return stdClass * @throws Exception */ function sendMail($id, $cancreate, $now, $autoValidation) From af0846e2f7b22e129628ee699b9dcb1ab6e00ccc Mon Sep 17 00:00:00 2001 From: jpb Date: Mon, 13 Jun 2022 09:09:19 +0200 Subject: [PATCH 046/367] add sanitize to sql --- htdocs/holiday/card_group.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/holiday/card_group.php b/htdocs/holiday/card_group.php index f244c6374e5..8de636da6c8 100644 --- a/htdocs/holiday/card_group.php +++ b/htdocs/holiday/card_group.php @@ -264,7 +264,7 @@ if (empty($reshook)) { /** GROUPS */ $sql = ' SELECT DISTINCT u.rowid,u.lastname,u.firstname from ' . MAIN_DB_PREFIX . 'user as u'; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'usergroup_user as ug on ug.fk_user = u.rowid '; - $sql .= ' WHERE fk_usergroup in (' . implode(',', $groups) . ')'; + $sql .= ' WHERE fk_usergroup in (' .$this->db->sanitize(implode(',', $groups)) . ')'; $resql = $db->query($sql); if ($resql) { @@ -423,7 +423,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { } $("input[name=autoValidation]").click( function(e) { - console.log("chang") + if( $("input[name=autoValidation]").is(":checked") ){ $("#AutoSendMail").prop("disabled", false); From d7ca52f4ef996b9711a321823da0e19c11730d0d Mon Sep 17 00:00:00 2001 From: jpb Date: Mon, 13 Jun 2022 09:17:19 +0200 Subject: [PATCH 047/367] remove $this on sanitize --- htdocs/holiday/card_group.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/holiday/card_group.php b/htdocs/holiday/card_group.php index 8de636da6c8..b63a3ae657b 100644 --- a/htdocs/holiday/card_group.php +++ b/htdocs/holiday/card_group.php @@ -264,7 +264,7 @@ if (empty($reshook)) { /** GROUPS */ $sql = ' SELECT DISTINCT u.rowid,u.lastname,u.firstname from ' . MAIN_DB_PREFIX . 'user as u'; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'usergroup_user as ug on ug.fk_user = u.rowid '; - $sql .= ' WHERE fk_usergroup in (' .$this->db->sanitize(implode(',', $groups)) . ')'; + $sql .= ' WHERE fk_usergroup in (' .$db->sanitize(implode(',', $groups)) . ')'; $resql = $db->query($sql); if ($resql) { From 09c5b8be79204817c5fc359df27b7690a6de7f19 Mon Sep 17 00:00:00 2001 From: jpb Date: Mon, 13 Jun 2022 10:38:49 +0200 Subject: [PATCH 048/367] add comment --- htdocs/holiday/card_group.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/holiday/card_group.php b/htdocs/holiday/card_group.php index b63a3ae657b..5e571f077c8 100644 --- a/htdocs/holiday/card_group.php +++ b/htdocs/holiday/card_group.php @@ -261,6 +261,7 @@ if (empty($reshook)) { if (!$error) { $TusersToProcess = array(); // usergroup select + // better perf on single sql /** GROUPS */ $sql = ' SELECT DISTINCT u.rowid,u.lastname,u.firstname from ' . MAIN_DB_PREFIX . 'user as u'; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'usergroup_user as ug on ug.fk_user = u.rowid '; From dddd4186a864b53574b61d65d850c28ccf5c2fb0 Mon Sep 17 00:00:00 2001 From: lvessiller Date: Mon, 13 Jun 2022 15:37:43 +0200 Subject: [PATCH 049/367] NEW show product label on inventory --- htdocs/core/class/commonobject.class.php | 11 ++++++++- .../fourn/class/fournisseur.product.class.php | 20 ++++++++++++---- htdocs/product/class/product.class.php | 24 ++++++++++++------- .../inventory/class/inventory.class.php | 2 +- 4 files changed, 41 insertions(+), 16 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 1f64741385f..1f258fa2ba4 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7556,11 +7556,20 @@ abstract class CommonObject if ($classname && class_exists($classname)) { $object = new $classname($this->db); if ($object->element === 'product') { // Special cas for product because default valut of fetch are wrong + $getnomurlparam3 = (!isset($InfoFieldList[5]) ? 0 : $InfoFieldList[5]); + $getnomurlparam4 = (!isset($InfoFieldList[6]) ? -1 : $InfoFieldList[6]); + $getnomurlparam5 = (!isset($InfoFieldList[7]) ? 0 : $InfoFieldList[7]); + $getnomurlparam6 = (!isset($InfoFieldList[8]) ? 0 : $InfoFieldList[8]); + + /** + * @var Product $object + */ $object->fetch($value, '', '', '', 0, 1, 1); + $value = $object->getNomUrl($getnomurlparam, $getnomurlparam2, $getnomurlparam3, $getnomurlparam4, $getnomurlparam5, $getnomurlparam6); } else { $object->fetch($value); + $value = $object->getNomUrl($getnomurlparam, $getnomurlparam2); } - $value = $object->getNomUrl($getnomurlparam, $getnomurlparam2); } } else { dol_syslog('Error bad setup of extrafield', LOG_WARNING); diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index d113eadd8a7..774dd192659 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -1091,12 +1091,15 @@ class ProductFournisseur extends Product * * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) * @param string $option On what the link point to ('nolink', ...) - * @param int $notooltip 1=Disable tooltip - * @param string $morecss Add more css on link + * @param int $maxlength Maxlength of ref * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param int $notooltip No tooltip + * @param int $add_label 0=Default, 1=Add label into string, >1=Add first chars into string + * @param string $sep ' - '=Separator between ref and label if option 'add_label' is set + * @param string $morecss ''=Add more css on link * @return string String with URL */ - public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $maxlength = 0, $save_lastsearch_value = -1, $notooltip = 0, $add_label = 0, $sep = ' - ', $morecss = '') { global $db, $conf, $langs, $hookmanager; @@ -1107,6 +1110,11 @@ class ProductFournisseur extends Product $result = ''; $label = ''; + $newref = $this->ref; + if ($maxlength) { + $newref = dol_trunc($newref, $maxlength, 'middle'); + } + if (!empty($this->entity)) { $tmpphoto = $this->show_photos('product', $conf->product->multidir_output[$this->entity], 1, 1, 0, 0, 0, 80); if ($this->nbphoto > 0) { @@ -1228,10 +1236,12 @@ class ProductFournisseur extends Product $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); } if ($withpicto != 2) { - $result .= $this->ref.($this->ref_supplier ? ' ('.$this->ref_supplier.')' : ''); + $result .= $newref.($this->ref_supplier ? ' ('.$this->ref_supplier.')' : ''); } $result .= $linkend; - //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + if ($withpicto != 2) { + $result .= (($add_label && $this->label) ? $sep.dol_trunc($this->label, ($add_label > 1 ? $add_label : 0)) : ''); + } global $action; $hookmanager->initHooks(array($this->element . 'dao')); diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 5a7990cd0a7..c5eb211de2c 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4882,14 +4882,17 @@ class Product extends CommonObject /** * Return clicable link of object (with eventually picto) * - * @param int $withpicto Add picto into link - * @param string $option Where point the link ('stock', 'composition', 'category', 'supplier', '') - * @param int $maxlength Maxlength of ref - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @param int $notooltip No tooltip - * @return string String with URL + * @param int $withpicto Add picto into link + * @param string $option Where point the link ('stock', 'composition', 'category', 'supplier', '') + * @param int $maxlength Maxlength of ref + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param int $notooltip No tooltip + * @param int $add_label 0=Default, 1=Add label into string, >1=Add first chars into string + * @param string $sep ' - '=Separator between ref and label if option 'add_label' is set + * @param string $morecss ''=Add more css on link + * @return string String with URL */ - public function getNomUrl($withpicto = 0, $option = '', $maxlength = 0, $save_lastsearch_value = -1, $notooltip = 0) + public function getNomUrl($withpicto = 0, $option = '', $maxlength = 0, $save_lastsearch_value = -1, $notooltip = 0, $add_label = 0, $sep = ' - ', $morecss = '') { global $conf, $langs, $hookmanager; include_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; @@ -4997,9 +5000,9 @@ class Product extends CommonObject } $linkclose .= ' title="'.dol_escape_htmltag($label, 1, 1).'"'; - $linkclose .= ' class="nowraponall classfortooltip"'; + $linkclose .= ' class="nowraponall classfortooltip'.($morecss ? ' '.$morecss : '').'"'; } else { - $linkclose = ' class="nowraponall"'; + $linkclose = ' class="nowraponall'.($morecss ? ' '.$morecss : '').'"'; } if ($option == 'supplier' || $option == 'category') { @@ -5038,6 +5041,9 @@ class Product extends CommonObject } $result .= $newref; $result .= $linkend; + if ($withpicto != 2) { + $result .= (($add_label && $this->label) ? $sep.dol_trunc($this->label, ($add_label > 1 ? $add_label : 0)) : ''); + } global $action; $hookmanager->initHooks(array('productdao')); diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index 80823c7ba5a..c755b92b3e4 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -101,7 +101,7 @@ class Inventory extends CommonObject 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), 'title' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>25, 'css'=>'minwidth300', 'csslist'=>'tdoverflowmax200'), 'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Warehouse', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'index'=>1, 'help'=>'InventoryForASpecificWarehouse', 'picto'=>'stock', 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'csslist'=>'tdoverflowmax200'), - 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'visible'=>1, 'enabled'=>1, 'position'=>32, 'index'=>1, 'help'=>'InventoryForASpecificProduct', 'picto'=>'product', 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'csslist'=>'tdoverflowmax200'), + 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php::::0:-1:0:1', 'label'=>'Product', 'visible'=>1, 'enabled'=>1, 'position'=>32, 'index'=>1, 'help'=>'InventoryForASpecificProduct', 'picto'=>'product', 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'csslist'=>'tdoverflowmax200'), 'date_inventory' => array('type'=>'date', 'label'=>'DateValue', 'visible'=>1, 'enabled'=>'$conf->global->STOCK_INVENTORY_ADD_A_VALUE_DATE', 'position'=>35), // This date is not used so disabled by default. 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), From 65d20bdc61e512f924a6cc6ad3eea9cd30e0f4ae Mon Sep 17 00:00:00 2001 From: lvessiller Date: Thu, 16 Jun 2022 12:06:06 +0200 Subject: [PATCH 050/367] NEW add attached file in presend email form of thirdparty card --- htdocs/core/tpl/card_presend.tpl.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index 7b47c4676a6..9a99faef526 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -41,14 +41,16 @@ if ($action == 'presend') { $object->fetch_projet(); - if (!in_array($object->element, array('societe', 'user', 'member'))) { + $ref = dol_sanitizeFileName($object->ref); + if (!in_array($object->element, array('user', 'member'))) { // TODO get also the main_lastdoc field of $object. If not found, try to guess with following code - $ref = dol_sanitizeFileName($object->ref); include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; // Special case if ($object->element == 'invoice_supplier') { $fileparams = dol_most_recent_file($diroutput.'/'.get_exdir($object->id, 2, 0, 0, $object, $object->element).$ref, preg_quote($ref, '/').'([^\-])+'); + } elseif ($object->element == 'societe') { + $fileparams = dol_most_recent_file($diroutput.'/'.$ref); } else { $fileparams = dol_most_recent_file($diroutput.'/'.$ref, preg_quote($ref, '/').'[^\-]+'); } @@ -82,12 +84,15 @@ if ($action == 'presend') { // Build document if it not exists $forcebuilddoc = true; - if (in_array($object->element, array('societe', 'user', 'member'))) { + if (in_array($object->element, array('user', 'member'))) { $forcebuilddoc = false; } if ($object->element == 'invoice_supplier' && empty($conf->global->INVOICE_SUPPLIER_ADDON_PDF)) { $forcebuilddoc = false; } + if ($object->element == 'societe' && empty($conf->global->COMPANY_ADDON_PDF)) { + $forcebuilddoc = false; + } if ($forcebuilddoc) { // If there is no default value for supplier invoice, we do not generate file, even if modelpdf was set by a manual generation if ((!$file || !is_readable($file)) && method_exists($object, 'generateDocument')) { $result = $object->generateDocument(GETPOST('model') ? GETPOST('model') : $object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -97,6 +102,8 @@ if ($action == 'presend') { } if ($object->element == 'invoice_supplier') { $fileparams = dol_most_recent_file($diroutput.'/'.get_exdir($object->id, 2, 0, 0, $object, $object->element).$ref, preg_quote($ref, '/').'([^\-])+'); + } elseif ($object->element == 'societe') { + $fileparams = dol_most_recent_file($diroutput.'/'.$ref); } else { $fileparams = dol_most_recent_file($diroutput.'/'.$ref, preg_quote($ref, '/').'[^\-]+'); } From 61a9521e3c7f48ac29e4df7bec471c586eecb0e3 Mon Sep 17 00:00:00 2001 From: lvessiller Date: Fri, 17 Jun 2022 17:32:22 +0200 Subject: [PATCH 051/367] NEW Changelog and reorder getNomUrl parameters --- ChangeLog | 7 +++++++ htdocs/core/class/commonobject.class.php | 5 +++-- htdocs/fourn/class/fournisseur.product.class.php | 4 ++-- htdocs/product/class/product.class.php | 4 ++-- htdocs/product/inventory/class/inventory.class.php | 2 +- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 37957f61c1d..5813c185885 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,13 @@ English Dolibarr ChangeLog -------------------------------------------------------------- +***** ChangeLog for 17.0.0 compared to 16.0.0 ***** + +For developers or integrators: +------------------------------ + +Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: +* The signature of method getNomUrl() of class ProductFournisseur has been modified to match the signature of method Product ***** ChangeLog for 16.0.0 compared to 15.0.0 ***** diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 10b6fd5e690..a9b7edf6078 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7565,12 +7565,13 @@ abstract class CommonObject $getnomurlparam3 = (!isset($InfoFieldList[5]) ? 0 : $InfoFieldList[5]); $getnomurlparam4 = (!isset($InfoFieldList[6]) ? -1 : $InfoFieldList[6]); $getnomurlparam5 = (!isset($InfoFieldList[7]) ? 0 : $InfoFieldList[7]); - $getnomurlparam6 = (!isset($InfoFieldList[8]) ? 0 : $InfoFieldList[8]); + $getnomurlparam6 = (!isset($InfoFieldList[8]) ? '' : $InfoFieldList[8]); + $getnomurlparam7 = (!isset($InfoFieldList[9]) ? 0 : $InfoFieldList[9]); /** * @var Product $object */ - $value = $object->getNomUrl($getnomurlparam, $getnomurlparam2, $getnomurlparam3, $getnomurlparam4, $getnomurlparam5, $getnomurlparam6); + $value = $object->getNomUrl($getnomurlparam, $getnomurlparam2, $getnomurlparam3, $getnomurlparam4, $getnomurlparam5, $getnomurlparam6, $getnomurlparam7); } else { $value = $object->getNomUrl($getnomurlparam, $getnomurlparam2); } diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 774dd192659..349a317b1d2 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -1094,12 +1094,12 @@ class ProductFournisseur extends Product * @param int $maxlength Maxlength of ref * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @param int $notooltip No tooltip + * @param string $morecss ''=Add more css on link * @param int $add_label 0=Default, 1=Add label into string, >1=Add first chars into string * @param string $sep ' - '=Separator between ref and label if option 'add_label' is set - * @param string $morecss ''=Add more css on link * @return string String with URL */ - public function getNomUrl($withpicto = 0, $option = '', $maxlength = 0, $save_lastsearch_value = -1, $notooltip = 0, $add_label = 0, $sep = ' - ', $morecss = '') + public function getNomUrl($withpicto = 0, $option = '', $maxlength = 0, $save_lastsearch_value = -1, $notooltip = 0, $morecss = '', $add_label = 0, $sep = ' - ') { global $db, $conf, $langs, $hookmanager; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index c5eb211de2c..c268929d59c 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4887,12 +4887,12 @@ class Product extends CommonObject * @param int $maxlength Maxlength of ref * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @param int $notooltip No tooltip + * @param string $morecss ''=Add more css on link * @param int $add_label 0=Default, 1=Add label into string, >1=Add first chars into string * @param string $sep ' - '=Separator between ref and label if option 'add_label' is set - * @param string $morecss ''=Add more css on link * @return string String with URL */ - public function getNomUrl($withpicto = 0, $option = '', $maxlength = 0, $save_lastsearch_value = -1, $notooltip = 0, $add_label = 0, $sep = ' - ', $morecss = '') + public function getNomUrl($withpicto = 0, $option = '', $maxlength = 0, $save_lastsearch_value = -1, $notooltip = 0, $morecss = '', $add_label = 0, $sep = ' - ') { global $conf, $langs, $hookmanager; include_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index c755b92b3e4..ddf7d582fba 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -101,7 +101,7 @@ class Inventory extends CommonObject 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), 'title' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>25, 'css'=>'minwidth300', 'csslist'=>'tdoverflowmax200'), 'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Warehouse', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'index'=>1, 'help'=>'InventoryForASpecificWarehouse', 'picto'=>'stock', 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'csslist'=>'tdoverflowmax200'), - 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php::::0:-1:0:1', 'label'=>'Product', 'visible'=>1, 'enabled'=>1, 'position'=>32, 'index'=>1, 'help'=>'InventoryForASpecificProduct', 'picto'=>'product', 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'csslist'=>'tdoverflowmax200'), + 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php::::0:-1:0::1', 'label'=>'Product', 'visible'=>1, 'enabled'=>1, 'position'=>32, 'index'=>1, 'help'=>'InventoryForASpecificProduct', 'picto'=>'product', 'css'=>'minwidth300 maxwidth500 widthcentpercentminusx', 'csslist'=>'tdoverflowmax200'), 'date_inventory' => array('type'=>'date', 'label'=>'DateValue', 'visible'=>1, 'enabled'=>'$conf->global->STOCK_INVENTORY_ADD_A_VALUE_DATE', 'position'=>35), // This date is not used so disabled by default. 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), From 82cfca1a80d04e883fbcc6658246042c67aeeafa Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Sun, 19 Jun 2022 00:48:06 +0200 Subject: [PATCH 052/367] Filter accounting reports by projects --- htdocs/compta/accounting-files.php | 44 ++++++++++++++++++++++++++--- htdocs/langs/en_US/accountancy.lang | 3 +- htdocs/langs/en_US/projects.lang | 3 +- htdocs/projet/card.php | 11 ++++++++ 4 files changed, 55 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index 996ad22fbce..88dd1c317f2 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -47,6 +47,11 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/loan/class/paymentloan.class.php'; +if (!empty($conf->project->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +} + // Constant to define payment sens const PAY_DEBIT = 0; const PAY_CREDIT = 1; @@ -64,6 +69,7 @@ $date_stopMonth = GETPOST('date_stopmonth', 'int'); $date_stopYear = GETPOST('date_stopyear', 'int'); $date_stop = dol_mktime(23, 59, 59, $date_stopMonth, $date_stopDay, $date_stopYear, 'tzuserrel'); $action = GETPOST('action', 'aZ09'); +$projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : 0); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('comptafileslist', 'globallist')); @@ -175,6 +181,7 @@ if (($action == 'searchfiles' || $action == 'dl')) { $sql .= " WHERE datef between ".$wheretail; $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')'; $sql .= " AND t.fk_statut <> ".Facture::STATUS_DRAFT; + if(!empty($projectid)) $sql .= " AND fk_projet = ".$db->sanitize($projectid); } // Vendor invoices if (GETPOST('selectsupplierinvoices') && !empty($listofchoices['selectsupplierinvoices']['perms'])) { @@ -186,9 +193,10 @@ if (($action == 'searchfiles' || $action == 'dl')) { $sql .= " WHERE datef between ".$wheretail; $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')'; $sql .= " AND t.fk_statut <> ".FactureFournisseur::STATUS_DRAFT; + if(!empty($projectid)) $sql .= " AND fk_projet = ".$db->sanitize($projectid); } // Expense reports - if (GETPOST('selectexpensereports') && !empty($listofchoices['selectexpensereports']['perms'])) { + if (GETPOST('selectexpensereports') && !empty($listofchoices['selectexpensereports']['perms']) and empty($projectid)) { if (!empty($sql)) { $sql .= " UNION ALL"; } @@ -208,6 +216,7 @@ if (($action == 'searchfiles' || $action == 'dl')) { $sql .= " WHERE datedon between ".$wheretail; $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')'; $sql .= " AND t.fk_statut <> ".Don::STATUS_DRAFT; + if(!empty($projectid)) $sql .= " AND fk_projet = ".$db->sanitize($projectid); } // Payments of salaries if (GETPOST('selectpaymentsofsalaries') && !empty($listofchoices['selectpaymentsofsalaries']['perms'])) { @@ -219,6 +228,7 @@ if (($action == 'searchfiles' || $action == 'dl')) { $sql .= " WHERE datep between ".$wheretail; $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')'; //$sql.=" AND fk_statut <> ".PaymentSalary::STATUS_DRAFT; + if(!empty($projectid)) $sql .= " AND fk_projet = ".$db->sanitize($projectid); } // Social contributions if (GETPOST('selectsocialcontributions') && !empty($listofchoices['selectsocialcontributions']['perms'])) { @@ -230,6 +240,7 @@ if (($action == 'searchfiles' || $action == 'dl')) { $sql .= " WHERE t.date_ech between ".$wheretail; $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')'; //$sql.=" AND fk_statut <> ".ChargeSociales::STATUS_DRAFT; + if(!empty($projectid)) $sql .= " AND fk_projet = ".$db->sanitize($projectid); } // Various payments if (GETPOST('selectvariouspayment') && !empty($listofchoices['selectvariouspayment']['perms'])) { @@ -240,9 +251,10 @@ if (($action == 'searchfiles' || $action == 'dl')) { $sql .= " FROM ".MAIN_DB_PREFIX."payment_various as t"; $sql .= " WHERE datep between ".$wheretail; $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')'; + if(!empty($projectid)) $sql .= " AND fk_projet = ".$db->sanitize($projectid); } // Loan payments - if (GETPOST('selectloanspayment') && !empty($listofchoices['selectloanspayment']['perms'])) { + if (GETPOST('selectloanspayment') && !empty($listofchoices['selectloanspayment']['perms']) and empty($projectid)) { if (!empty($sql)) { $sql .= " UNION ALL"; } @@ -460,7 +472,19 @@ if ($result && $action == "dl" && !$error) { $log .= ','.$langs->transnoentitiesnoconv("Country"); $log .= ','.$langs->transnoentitiesnoconv("VATIntra"); $log .= ','.$langs->transnoentitiesnoconv("Sens")."\n"; - $zipname = $dirfortmpfile.'/'.dol_print_date($date_start, 'dayrfc', 'tzuserrel')."-".dol_print_date($date_stop, 'dayrfc', 'tzuserrel').'_export.zip'; + $zipname = $dirfortmpfile.'/'.dol_print_date($date_start, 'dayrfc', 'tzuserrel')."-".dol_print_date($date_stop, 'dayrfc', 'tzuserrel'); + if(!empty($projectid)) { + $sql = 'SELECT t.ref FROM '.MAIN_DB_PREFIX.'projet as t'; + $sql .= ' WHERE t.rowid = '.((int) $db->sanitize($projectid)); + $resql = $db->query($sql); + if ($resql) { + $obj = $db->fetch_object($resql); + $zipname .= '_'.$obj->ref; + } else { + dol_print_error($db); + } + } + $zipname .='_export.zip'; dol_delete_file($zipname); @@ -561,11 +585,13 @@ print $form->selectDate($date_stop, 'date_stop', 0, 0, 0, "", 1, 1, 0, '', '', ' print "\n"; // Export is for current company only +$socid = 0; if (!empty($conf->multicompany->enabled) && is_object($mc)) { $mc->getInfo($conf->entity); print '('.$langs->trans("Entity").' : '; print ""; if (!empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES)) { + $socid = $mc->id; print $mc->select_entities(GETPOSTISSET('search_entity') ? GETPOST('search_entity', 'int') : $mc->id, 'search_entity', '', false, false, false, false, true); } else { print $mc->label; @@ -576,6 +602,16 @@ if (!empty($conf->multicompany->enabled) && is_object($mc)) { print '
'; +// Project filter +if (!empty($conf->projet->enabled)) { + $formproject = new FormProjets($db); + $langs->load('projects'); + print ''.$langs->trans('Project').":"; + print img_picto('', 'project').$formproject->select_projects(($socid > 0 ? $socid : -1), $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 1, 0, ''); + print ''; + print '
'; +} + foreach ($listofchoices as $choice => $val) { if (empty($val['enabled'])) { continue; // list not qualified @@ -614,7 +650,7 @@ if (!empty($date_start) && !empty($date_stop)) { echo dol_print_date($date_start, 'day', 'tzuserrel')." - ".dol_print_date($date_stop, 'day', 'tzuserrel'); - print 'The exported ZIP file will contain the lists of requested items in CSV, as well as their attached files in their original format (PDF, ODT, DOCX...). ExportAccountingSourceDocHelp2=To export your journals, use the menu entry %s - %s. +ExportAccountingProjectHelp=Specify a project if you need an accounting report only for a specific project. Expense reports and loan payments are not included in project reports. VueByAccountAccounting=View by accounting account VueBySubAccountAccounting=View by accounting subaccount diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index e0fa85dd273..b4bd6f75d9a 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -293,4 +293,5 @@ LeadPublicFormDesc=You can enable here a public page to allow your prospects to EnablePublicLeadForm=Enable the public form for contact NewLeadbyWeb=Your message or request has been recorded. We will answer or contact your soon. NewLeadForm=New contact form -LeadFromPublicForm=Online lead from public form \ No newline at end of file +LeadFromPublicForm=Online lead from public form +ExportAccountingReportButtonLabel=Get report \ No newline at end of file diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 0cfe126d69b..f3b60e8593c 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -1280,6 +1280,17 @@ if ($action == 'create' && $user->rights->projet->creer) { } } + // Accounting Report + $accouting_module_activated = !empty($conf->comptabilite->enabled) || !empty($conf->accounting->enabled); + if ($accouting_module_activated && $object->statut != Project::STATUS_DRAFT) { + $start = dol_getdate((int)$object->date_start); + $end = dol_getdate((int)$object->date_end); + $url = DOL_URL_ROOT.'/compta/accounting-files.php?projectid='.$object->id; + if(!empty($object->date_start)) $url .= '&date_startday='.$start['mday'].'&date_startmonth='.$start['mon'].'&date_startyear='.$start['year']; + if(!empty($object->date_end)) $url .= '&date_stopday='.$end['mday'].'&date_stopmonth='.$end['mon'].'&date_stopyear='.$end['year']; + print dolGetButtonAction('', $langs->trans('ExportAccountingReportButtonLabel'), 'default', $url, ''); + } + // Modify if ($object->statut != Project::STATUS_CLOSED && $user->rights->projet->creer) { if ($userWrite > 0) { From eb4c42e98758abd117f88afc54e60ba59e1a1405 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Sun, 19 Jun 2022 19:21:51 +0200 Subject: [PATCH 053/367] Fixed AND operator to standardize code --- htdocs/compta/accounting-files.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index 88dd1c317f2..327298a033d 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -254,7 +254,7 @@ if (($action == 'searchfiles' || $action == 'dl')) { if(!empty($projectid)) $sql .= " AND fk_projet = ".$db->sanitize($projectid); } // Loan payments - if (GETPOST('selectloanspayment') && !empty($listofchoices['selectloanspayment']['perms']) and empty($projectid)) { + if (GETPOST('selectloanspayment') && !empty($listofchoices['selectloanspayment']['perms']) && empty($projectid)) { if (!empty($sql)) { $sql .= " UNION ALL"; } From 13511d983eeb1487530951b5aa232303a3cecf71 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 19 Jun 2022 17:27:15 +0000 Subject: [PATCH 054/367] Fixing style errors. --- htdocs/compta/accounting-files.php | 14 +++++++------- htdocs/projet/card.php | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index 327298a033d..571d17bea08 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -181,7 +181,7 @@ if (($action == 'searchfiles' || $action == 'dl')) { $sql .= " WHERE datef between ".$wheretail; $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')'; $sql .= " AND t.fk_statut <> ".Facture::STATUS_DRAFT; - if(!empty($projectid)) $sql .= " AND fk_projet = ".$db->sanitize($projectid); + if (!empty($projectid)) $sql .= " AND fk_projet = ".$db->sanitize($projectid); } // Vendor invoices if (GETPOST('selectsupplierinvoices') && !empty($listofchoices['selectsupplierinvoices']['perms'])) { @@ -193,7 +193,7 @@ if (($action == 'searchfiles' || $action == 'dl')) { $sql .= " WHERE datef between ".$wheretail; $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')'; $sql .= " AND t.fk_statut <> ".FactureFournisseur::STATUS_DRAFT; - if(!empty($projectid)) $sql .= " AND fk_projet = ".$db->sanitize($projectid); + if (!empty($projectid)) $sql .= " AND fk_projet = ".$db->sanitize($projectid); } // Expense reports if (GETPOST('selectexpensereports') && !empty($listofchoices['selectexpensereports']['perms']) and empty($projectid)) { @@ -216,7 +216,7 @@ if (($action == 'searchfiles' || $action == 'dl')) { $sql .= " WHERE datedon between ".$wheretail; $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')'; $sql .= " AND t.fk_statut <> ".Don::STATUS_DRAFT; - if(!empty($projectid)) $sql .= " AND fk_projet = ".$db->sanitize($projectid); + if (!empty($projectid)) $sql .= " AND fk_projet = ".$db->sanitize($projectid); } // Payments of salaries if (GETPOST('selectpaymentsofsalaries') && !empty($listofchoices['selectpaymentsofsalaries']['perms'])) { @@ -228,7 +228,7 @@ if (($action == 'searchfiles' || $action == 'dl')) { $sql .= " WHERE datep between ".$wheretail; $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')'; //$sql.=" AND fk_statut <> ".PaymentSalary::STATUS_DRAFT; - if(!empty($projectid)) $sql .= " AND fk_projet = ".$db->sanitize($projectid); + if (!empty($projectid)) $sql .= " AND fk_projet = ".$db->sanitize($projectid); } // Social contributions if (GETPOST('selectsocialcontributions') && !empty($listofchoices['selectsocialcontributions']['perms'])) { @@ -240,7 +240,7 @@ if (($action == 'searchfiles' || $action == 'dl')) { $sql .= " WHERE t.date_ech between ".$wheretail; $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')'; //$sql.=" AND fk_statut <> ".ChargeSociales::STATUS_DRAFT; - if(!empty($projectid)) $sql .= " AND fk_projet = ".$db->sanitize($projectid); + if (!empty($projectid)) $sql .= " AND fk_projet = ".$db->sanitize($projectid); } // Various payments if (GETPOST('selectvariouspayment') && !empty($listofchoices['selectvariouspayment']['perms'])) { @@ -251,7 +251,7 @@ if (($action == 'searchfiles' || $action == 'dl')) { $sql .= " FROM ".MAIN_DB_PREFIX."payment_various as t"; $sql .= " WHERE datep between ".$wheretail; $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')'; - if(!empty($projectid)) $sql .= " AND fk_projet = ".$db->sanitize($projectid); + if (!empty($projectid)) $sql .= " AND fk_projet = ".$db->sanitize($projectid); } // Loan payments if (GETPOST('selectloanspayment') && !empty($listofchoices['selectloanspayment']['perms']) && empty($projectid)) { @@ -473,7 +473,7 @@ if ($result && $action == "dl" && !$error) { $log .= ','.$langs->transnoentitiesnoconv("VATIntra"); $log .= ','.$langs->transnoentitiesnoconv("Sens")."\n"; $zipname = $dirfortmpfile.'/'.dol_print_date($date_start, 'dayrfc', 'tzuserrel')."-".dol_print_date($date_stop, 'dayrfc', 'tzuserrel'); - if(!empty($projectid)) { + if (!empty($projectid)) { $sql = 'SELECT t.ref FROM '.MAIN_DB_PREFIX.'projet as t'; $sql .= ' WHERE t.rowid = '.((int) $db->sanitize($projectid)); $resql = $db->query($sql); diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index f3b60e8593c..7a3690fb39f 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -1283,11 +1283,11 @@ if ($action == 'create' && $user->rights->projet->creer) { // Accounting Report $accouting_module_activated = !empty($conf->comptabilite->enabled) || !empty($conf->accounting->enabled); if ($accouting_module_activated && $object->statut != Project::STATUS_DRAFT) { - $start = dol_getdate((int)$object->date_start); - $end = dol_getdate((int)$object->date_end); + $start = dol_getdate((int) $object->date_start); + $end = dol_getdate((int) $object->date_end); $url = DOL_URL_ROOT.'/compta/accounting-files.php?projectid='.$object->id; - if(!empty($object->date_start)) $url .= '&date_startday='.$start['mday'].'&date_startmonth='.$start['mon'].'&date_startyear='.$start['year']; - if(!empty($object->date_end)) $url .= '&date_stopday='.$end['mday'].'&date_stopmonth='.$end['mon'].'&date_stopyear='.$end['year']; + if (!empty($object->date_start)) $url .= '&date_startday='.$start['mday'].'&date_startmonth='.$start['mon'].'&date_startyear='.$start['year']; + if (!empty($object->date_end)) $url .= '&date_stopday='.$end['mday'].'&date_stopmonth='.$end['mon'].'&date_stopyear='.$end['year']; print dolGetButtonAction('', $langs->trans('ExportAccountingReportButtonLabel'), 'default', $url, ''); } From 623917291085f3ee8293b0187eb9ea08c8bd8577 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Sun, 19 Jun 2022 19:30:10 +0200 Subject: [PATCH 055/367] Fixed sanitization of int --- htdocs/compta/accounting-files.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index 571d17bea08..a0a592c72e1 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -181,7 +181,7 @@ if (($action == 'searchfiles' || $action == 'dl')) { $sql .= " WHERE datef between ".$wheretail; $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')'; $sql .= " AND t.fk_statut <> ".Facture::STATUS_DRAFT; - if (!empty($projectid)) $sql .= " AND fk_projet = ".$db->sanitize($projectid); + if(!empty($projectid)) $sql .= " AND fk_projet = ".((int) $projectid); } // Vendor invoices if (GETPOST('selectsupplierinvoices') && !empty($listofchoices['selectsupplierinvoices']['perms'])) { @@ -193,7 +193,7 @@ if (($action == 'searchfiles' || $action == 'dl')) { $sql .= " WHERE datef between ".$wheretail; $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')'; $sql .= " AND t.fk_statut <> ".FactureFournisseur::STATUS_DRAFT; - if (!empty($projectid)) $sql .= " AND fk_projet = ".$db->sanitize($projectid); + if(!empty($projectid)) $sql .= " AND fk_projet = ".((int) $projectid); } // Expense reports if (GETPOST('selectexpensereports') && !empty($listofchoices['selectexpensereports']['perms']) and empty($projectid)) { @@ -216,7 +216,7 @@ if (($action == 'searchfiles' || $action == 'dl')) { $sql .= " WHERE datedon between ".$wheretail; $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')'; $sql .= " AND t.fk_statut <> ".Don::STATUS_DRAFT; - if (!empty($projectid)) $sql .= " AND fk_projet = ".$db->sanitize($projectid); + if(!empty($projectid)) $sql .= " AND fk_projet = ".((int) $projectid); } // Payments of salaries if (GETPOST('selectpaymentsofsalaries') && !empty($listofchoices['selectpaymentsofsalaries']['perms'])) { @@ -228,7 +228,7 @@ if (($action == 'searchfiles' || $action == 'dl')) { $sql .= " WHERE datep between ".$wheretail; $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')'; //$sql.=" AND fk_statut <> ".PaymentSalary::STATUS_DRAFT; - if (!empty($projectid)) $sql .= " AND fk_projet = ".$db->sanitize($projectid); + if(!empty($projectid)) $sql .= " AND fk_projet = ".((int) $projectid); } // Social contributions if (GETPOST('selectsocialcontributions') && !empty($listofchoices['selectsocialcontributions']['perms'])) { @@ -240,7 +240,7 @@ if (($action == 'searchfiles' || $action == 'dl')) { $sql .= " WHERE t.date_ech between ".$wheretail; $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')'; //$sql.=" AND fk_statut <> ".ChargeSociales::STATUS_DRAFT; - if (!empty($projectid)) $sql .= " AND fk_projet = ".$db->sanitize($projectid); + if(!empty($projectid)) $sql .= " AND fk_projet = ".((int) $projectid); } // Various payments if (GETPOST('selectvariouspayment') && !empty($listofchoices['selectvariouspayment']['perms'])) { @@ -251,7 +251,7 @@ if (($action == 'searchfiles' || $action == 'dl')) { $sql .= " FROM ".MAIN_DB_PREFIX."payment_various as t"; $sql .= " WHERE datep between ".$wheretail; $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')'; - if (!empty($projectid)) $sql .= " AND fk_projet = ".$db->sanitize($projectid); + if(!empty($projectid)) $sql .= " AND fk_projet = ".((int) $projectid); } // Loan payments if (GETPOST('selectloanspayment') && !empty($listofchoices['selectloanspayment']['perms']) && empty($projectid)) { From 4e2bacb039af2b48a6e219c77f090533af44adea Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 19 Jun 2022 18:26:33 +0000 Subject: [PATCH 056/367] Fixing style errors. --- htdocs/compta/accounting-files.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index a0a592c72e1..e754af8c60e 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -181,7 +181,7 @@ if (($action == 'searchfiles' || $action == 'dl')) { $sql .= " WHERE datef between ".$wheretail; $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')'; $sql .= " AND t.fk_statut <> ".Facture::STATUS_DRAFT; - if(!empty($projectid)) $sql .= " AND fk_projet = ".((int) $projectid); + if (!empty($projectid)) $sql .= " AND fk_projet = ".((int) $projectid); } // Vendor invoices if (GETPOST('selectsupplierinvoices') && !empty($listofchoices['selectsupplierinvoices']['perms'])) { @@ -193,7 +193,7 @@ if (($action == 'searchfiles' || $action == 'dl')) { $sql .= " WHERE datef between ".$wheretail; $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')'; $sql .= " AND t.fk_statut <> ".FactureFournisseur::STATUS_DRAFT; - if(!empty($projectid)) $sql .= " AND fk_projet = ".((int) $projectid); + if (!empty($projectid)) $sql .= " AND fk_projet = ".((int) $projectid); } // Expense reports if (GETPOST('selectexpensereports') && !empty($listofchoices['selectexpensereports']['perms']) and empty($projectid)) { @@ -216,7 +216,7 @@ if (($action == 'searchfiles' || $action == 'dl')) { $sql .= " WHERE datedon between ".$wheretail; $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')'; $sql .= " AND t.fk_statut <> ".Don::STATUS_DRAFT; - if(!empty($projectid)) $sql .= " AND fk_projet = ".((int) $projectid); + if (!empty($projectid)) $sql .= " AND fk_projet = ".((int) $projectid); } // Payments of salaries if (GETPOST('selectpaymentsofsalaries') && !empty($listofchoices['selectpaymentsofsalaries']['perms'])) { @@ -228,7 +228,7 @@ if (($action == 'searchfiles' || $action == 'dl')) { $sql .= " WHERE datep between ".$wheretail; $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')'; //$sql.=" AND fk_statut <> ".PaymentSalary::STATUS_DRAFT; - if(!empty($projectid)) $sql .= " AND fk_projet = ".((int) $projectid); + if (!empty($projectid)) $sql .= " AND fk_projet = ".((int) $projectid); } // Social contributions if (GETPOST('selectsocialcontributions') && !empty($listofchoices['selectsocialcontributions']['perms'])) { @@ -240,7 +240,7 @@ if (($action == 'searchfiles' || $action == 'dl')) { $sql .= " WHERE t.date_ech between ".$wheretail; $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')'; //$sql.=" AND fk_statut <> ".ChargeSociales::STATUS_DRAFT; - if(!empty($projectid)) $sql .= " AND fk_projet = ".((int) $projectid); + if (!empty($projectid)) $sql .= " AND fk_projet = ".((int) $projectid); } // Various payments if (GETPOST('selectvariouspayment') && !empty($listofchoices['selectvariouspayment']['perms'])) { @@ -251,7 +251,7 @@ if (($action == 'searchfiles' || $action == 'dl')) { $sql .= " FROM ".MAIN_DB_PREFIX."payment_various as t"; $sql .= " WHERE datep between ".$wheretail; $sql .= " AND t.entity IN (".$db->sanitize($entity == 1 ? '0,1' : $entity).')'; - if(!empty($projectid)) $sql .= " AND fk_projet = ".((int) $projectid); + if (!empty($projectid)) $sql .= " AND fk_projet = ".((int) $projectid); } // Loan payments if (GETPOST('selectloanspayment') && !empty($listofchoices['selectloanspayment']['perms']) && empty($projectid)) { From 950c0c2183963a32eba08f0ecd3094648fbbd57a Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Mon, 20 Jun 2022 09:15:19 +0200 Subject: [PATCH 057/367] Create llx_element_categorie.sql The goal of table llx_element_categorie is to replace all tables llx_categories_xxx (with one table). the llx_element_tag table initially intended for this does not have the correct nomenclature to express its real use (and was used for other things before) more informations here : https://github.com/Dolibarr/dolibarr/pull/21192 --- .../mysql/tables/llx_element_categorie.sql | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 htdocs/install/mysql/tables/llx_element_categorie.sql diff --git a/htdocs/install/mysql/tables/llx_element_categorie.sql b/htdocs/install/mysql/tables/llx_element_categorie.sql new file mode 100644 index 00000000000..a1c7fddb0eb --- /dev/null +++ b/htdocs/install/mysql/tables/llx_element_categorie.sql @@ -0,0 +1,25 @@ +-- ============================================================================ +-- Copyright (C) 2022 charlene Benke +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ============================================================================ + +create table llx_element_categorie +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_categorie integer NOT NULL, + fk_element integer NOT NULL, + import_key varchar(14) +)ENGINE=innodb; From aebdb0eaa1075cf277d349de6c7b39c5d923f23b Mon Sep 17 00:00:00 2001 From: Quatadah Nasdami Date: Tue, 21 Jun 2022 13:22:59 +0200 Subject: [PATCH 058/367] adding clone button --- htdocs/projet/tasks/task.php | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 3df3cf8928e..a1aae4eadf4 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -128,6 +128,29 @@ if ($action == 'update' && !GETPOST("cancel") && $user->rights->projet->creer) { } } +if ($action == 'confirm_clone' && $confirm == 'yes') { + //$clone_contacts = GETPOST('clone_contacts') ? 1 : 0; + $clone_prog = GETPOST('clone_prog') ? 1 : 0; + $clone_time = GETPOST('clone_time') ? 1 : 0; + $clone_affectation = GETPOST('clone_affectation') ? 1 : 0; + $clone_change_dt = GETPOST('clone_change_dt') ? 1 : 0; + $clone_notes = GETPOST('clone_notes') ? 1 : 0; + $clone_file = GETPOST('clone_file') ? 1 : 0; + $result = $object->createFromClone($user, $object->id, $object->fk_project, $object->fk_task_parent, $clone_change_dt, $clone_affectation, $clone_time, $clone_file, $clone_notes, $clone_prog); + if ($result <= 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } else { + // Load new object + $newobject = new Task($db); + $newobject->fetch($result); + $newobject->fetch_optionals(); + $newobject->fetch_thirdparty(); // Load new object + $object = $newobject; + $action = 'edit'; + $comefromclone = true; + } +} + if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->projet->supprimer) { $result = $projectstatic->fetch($object->fk_project); $projectstatic->fetch_thirdparty(); @@ -199,6 +222,7 @@ $form = new Form($db); $formother = new FormOther($db); $formfile = new FormFile($db); + if ($id > 0 || !empty($ref)) { $res = $object->fetch_optionals(); if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) { @@ -379,6 +403,22 @@ if ($id > 0 || !empty($ref)) { //$userAccess = $projectstatic->restrictedProjectArea($user); // We allow task affected to user even if a not allowed project //$arrayofuseridoftask=$object->getListContactId('internal'); + if ($action == 'clone') { + $formquestion = array( + 'text' => $langs->trans("ConfirmClone"), + //array('type' => 'checkbox', 'name' => 'clone_contacts', 'label' => $langs->trans("CloneContacts"), 'value' => true), + array('type' => 'checkbox', 'name' => 'clone_change_dt', 'label' => $langs->trans("CloneChanges"), 'value' => true), + array('type' => 'checkbox', 'name' => 'clone_affectation', 'label' => $langs->trans("CloneAffectation"), 'value' => true), + array('type' => 'checkbox', 'name' => 'clone_prog', 'label' => $langs->trans("CloneProgression"), 'value' => true), + array('type' => 'checkbox', 'name' => 'clone_time', 'label' => $langs->trans("CloneTimes"), 'value' => true), + array('type' => 'checkbox', 'name' => 'clone_file', 'label' => $langs->trans("CloneFile"), 'value' => true), + + ); + + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ToClone"), $langs->trans("ConfirmCloneTask"), "confirm_clone", $formquestion, '', 1, 300, 590); + } + + $head = task_prepare_head($object); if ($action == 'edit' && $user->rights->projet->creer) { @@ -622,6 +662,7 @@ if ($id > 0 || !empty($ref)) { // Modify if ($user->rights->projet->creer) { print ''.$langs->trans('Modify').''; + print ''.$langs->trans('Clone').''; } else { print ''.$langs->trans('Modify').''; } From 629ece047378fba6f443768dabf4e4217796ff37 Mon Sep 17 00:00:00 2001 From: Quatadah Nasdami Date: Tue, 21 Jun 2022 13:33:55 +0200 Subject: [PATCH 059/367] adding clone button on task 2 --- htdocs/projet/tasks/task.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index a1aae4eadf4..4ca35cf46d3 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -45,6 +45,7 @@ $confirm = GETPOST('confirm', 'alpha'); $withproject = GETPOST('withproject', 'int'); $project_ref = GETPOST('project_ref', 'alpha'); $planned_workload = ((GETPOST('planned_workloadhour', 'int') != '' || GETPOST('planned_workloadmin', 'int') != '') ? (GETPOST('planned_workloadhour', 'int') > 0 ?GETPOST('planned_workloadhour', 'int') * 3600 : 0) + (GETPOST('planned_workloadmin', 'int') > 0 ?GETPOST('planned_workloadmin', 'int') * 60 : 0) : ''); +$comefromclone = GETPOST("comefromclone", "alpha"); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('projecttaskcard', 'globalcard')); @@ -659,6 +660,20 @@ if ($id > 0 || !empty($ref)) { $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook if (empty($reshook)) { + // Cancel + if ($cancel) { + if (GETPOST("comefromclone") == 1) { + $result = $object->delete($user); + if ($result > 0) { + header("Location: index.php"); + exit; + } else { + dol_syslog($object->error, LOG_DEBUG); + setEventMessages($langs->trans("CantRemoveProject", $langs->transnoentitiesnoconv("ProjectOverview")), null, 'errors'); + } + } + } + // Modify if ($user->rights->projet->creer) { print ''.$langs->trans('Modify').''; From 8c0b1efce4e32715fa4b415acef39fa056644eab Mon Sep 17 00:00:00 2001 From: GregM Date: Tue, 21 Jun 2022 15:21:45 +0200 Subject: [PATCH 060/367] NEW add objectLink expedition --- htdocs/core/class/html.form.class.php | 3 ++- htdocs/expedition/card.php | 4 ++-- htdocs/expedition/tpl/linkedobjectblock.tpl.php | 3 +-- htdocs/langs/en_US/main.lang | 1 + htdocs/langs/fr_FR/main.lang | 1 + 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 8f112b9aa98..072383f7ae9 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -8414,7 +8414,7 @@ class Form if (empty($conf->supplier_proposal->enabled)) { continue; // Do not show if module disabled } - } elseif ($objecttype == 'shipping' || $objecttype == 'shipment') { + } elseif ($objecttype == 'shipping' || $objecttype == 'shipment' || $objecttype == 'expedition') { $tplpath = 'expedition'; if (empty($conf->expedition->enabled)) { continue; // Do not show if module disabled @@ -8533,6 +8533,7 @@ class Form $possiblelinks = array( 'propal'=>array('enabled'=>$conf->propal->enabled, 'perms'=>1, 'label'=>'LinkToProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."propal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('propal').')'), + 'shipping'=>array('enabled'=>$conf->expedition->enabled, 'perms'=>1, 'label'=>'LinkToExpedition', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."expedition as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('shipping').')'), 'order'=>array('enabled'=>$conf->commande->enabled, 'perms'=>1, 'label'=>'LinkToOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."commande as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('commande').')'), 'invoice'=>array('enabled'=>$conf->facture->enabled, 'perms'=>1, 'label'=>'LinkToInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."facture as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('invoice').')'), 'invoice_template'=>array('enabled'=>$conf->facture->enabled, 'perms'=>1, 'label'=>'LinkToTemplateInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.titre as ref, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."facture_rec as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('invoice').')'), diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index f835e293f5f..09f28d456e6 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -2551,8 +2551,8 @@ if ($action == 'create') { // Show links to link elements - //$linktoelem = $form->showLinkToObjectBlock($object, null, array('order')); - $somethingshown = $form->showLinkedObjectBlock($object, ''); + $linktoelem = $form->showLinkToObjectBlock($object, null, array('shipping')); + $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); print '
'; diff --git a/htdocs/expedition/tpl/linkedobjectblock.tpl.php b/htdocs/expedition/tpl/linkedobjectblock.tpl.php index 26e4ebbb47d..e26f60486e5 100644 --- a/htdocs/expedition/tpl/linkedobjectblock.tpl.php +++ b/htdocs/expedition/tpl/linkedobjectblock.tpl.php @@ -60,8 +60,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) { // For now, shipments must stay linked to order, so link is not deletable if ($object->element != 'commande') { ?> - ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> - id.'&token='.newToken().'&action=dellink&dellinkid='.$key; ?>">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 2867c7b853b..503587aa8f0 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -799,6 +799,7 @@ URLPhoto=URL of photo/logo SetLinkToAnotherThirdParty=Link to another third party LinkTo=Link to LinkToProposal=Link to proposal +LinkToExpedition= Link to expedition LinkToOrder=Link to order LinkToInvoice=Link to invoice LinkToTemplateInvoice=Link to template invoice diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index 12778f337dd..2c0a6cee908 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -799,6 +799,7 @@ URLPhoto=URL de la photo/logo SetLinkToAnotherThirdParty=Lier vers un autre tiers LinkTo=Lier à LinkToProposal=Lier à une proposition commerciale +LinkToExpedition=Lier à une expédition LinkToOrder=Lier à une commande LinkToInvoice=Lier à une facture LinkToTemplateInvoice=Lien vers le modèle de facture From dd9e77e764f09632147330b499b153441e47cea7 Mon Sep 17 00:00:00 2001 From: Faustin Date: Tue, 21 Jun 2022 17:57:00 +0200 Subject: [PATCH 061/367] NEW 21000 Added columns 'alias_name' on poject list --- htdocs/projet/list.php | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index eaf9c5022a3..eab0d8cd8be 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -91,6 +91,7 @@ $search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alph $search_ref = GETPOST("search_ref", 'alpha'); $search_label = GETPOST("search_label", 'alpha'); $search_societe = GETPOST("search_societe", 'alpha'); +$search_societe_alias = GETPOST("search_societe_alias", 'alpha'); $search_status = GETPOST("search_status", 'int'); $search_opp_status = GETPOST("search_opp_status", 'alpha'); $search_opp_percent = GETPOST("search_opp_percent", 'alpha'); @@ -198,6 +199,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; // Add non object fields to fields for list $arrayfields['s.nom'] = array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'position'=>21, 'enabled'=>(empty($conf->societe->enabled) ? 0 : 1)); +$arrayfields['s.name_alias'] = array('label'=>"AliasNameShort", 'checked'=>1, 'position'=>22); $arrayfields['commercial'] = array('label'=>$langs->trans("SaleRepresentativesOfThirdParty"), 'checked'=>0, 'position'=>23); $arrayfields['c.assigned'] = array('label'=>$langs->trans("AssignedTo"), 'checked'=>-1, 'position'=>120); $arrayfields['opp_weighted_amount'] = array('label'=>$langs->trans('OpportunityWeightedAmountShort'), 'checked'=>0, 'position'=> 116, 'enabled'=>(empty($conf->global->PROJECT_USE_OPPORTUNITIES) ? 0 : 1), 'position'=>106); @@ -246,6 +248,7 @@ if (empty($reshook)) { $search_ref = ""; $search_label = ""; $search_societe = ""; + $search_societe_alias = ''; $search_status = -1; $search_opp_status = -1; $search_opp_amount = ''; @@ -447,6 +450,9 @@ if ($search_label) { if ($search_societe) { $sql .= natural_search('s.nom', $search_societe); } +if ($search_societe_alias) { + $sql .= natural_search('s.name_alias', $search_societe_alias); +} if ($search_opp_amount) { $sql .= natural_search('p.opp_amount', $search_opp_amount, 1); } @@ -687,6 +693,9 @@ if ($search_label != '') { if ($search_societe != '') { $param .= '&search_societe='.urlencode($search_societe); } +if ($search_societe_alias != '') { + $param .= '&search_societe_alias='.urlencode($search_societe_alias); +} if ($search_status >= 0) { $param .= '&search_status='.urlencode($search_status); } @@ -887,6 +896,18 @@ if (!empty($arrayfields['s.nom']['checked'])) { print ''; print ''; } + +// Alias +if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; + if ($socid > 0) { + $tmpthirdparty = new Societe($db); + $tmpthirdparty->fetch($socid); + $search_societe_alias = $tmpthirdparty->name_alias; + } + print ''; + print ''; +} // Sale representative if (!empty($arrayfields['commercial']['checked'])) { print ' '; @@ -1050,6 +1071,9 @@ if (!empty($arrayfields['p.title']['checked'])) { if (!empty($arrayfields['s.nom']['checked'])) { print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder); } +if (!empty($arrayfields['s.name_alias']['checked'])) { + print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], "s.name_alias", "", $param, "", $sortfield, $sortorder); +} if (!empty($arrayfields['commercial']['checked'])) { print_liste_field_titre($arrayfields['commercial']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder, 'tdoverflowmax100imp '); } @@ -1185,7 +1209,20 @@ while ($i < min($num, $limit)) { if (!empty($arrayfields['s.nom']['checked'])) { print ''; if ($obj->socid) { - print $companystatic->getNomUrl(1); + print $companystatic->getNomUrl(1, '', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); + } else { + print ' '; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Alias + if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; + if ($obj->socid) { + print $companystatic->name_alias; } else { print ' '; } From e76b49c360ae4db85eef85453d65e9f92f0151ef Mon Sep 17 00:00:00 2001 From: Faustin Date: Tue, 21 Jun 2022 18:06:58 +0200 Subject: [PATCH 062/367] NEW 21000 Added columns 'alias_name' on poject list --- htdocs/projet/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index eab0d8cd8be..1ec8245b868 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -199,7 +199,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; // Add non object fields to fields for list $arrayfields['s.nom'] = array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'position'=>21, 'enabled'=>(empty($conf->societe->enabled) ? 0 : 1)); -$arrayfields['s.name_alias'] = array('label'=>"AliasNameShort", 'checked'=>1, 'position'=>22); +$arrayfields['s.name_alias'] = array('label'=>"AliasNameShort", 'checked'=>0, 'position'=>22); $arrayfields['commercial'] = array('label'=>$langs->trans("SaleRepresentativesOfThirdParty"), 'checked'=>0, 'position'=>23); $arrayfields['c.assigned'] = array('label'=>$langs->trans("AssignedTo"), 'checked'=>-1, 'position'=>120); $arrayfields['opp_weighted_amount'] = array('label'=>$langs->trans('OpportunityWeightedAmountShort'), 'checked'=>0, 'position'=> 116, 'enabled'=>(empty($conf->global->PROJECT_USE_OPPORTUNITIES) ? 0 : 1), 'position'=>106); From 57d2a0352e5200a0733843689240f17a3b254565 Mon Sep 17 00:00:00 2001 From: Faustin Date: Tue, 21 Jun 2022 18:30:23 +0200 Subject: [PATCH 063/367] NEW 21000 Added columns 'alias_name' on tasks list --- htdocs/projet/tasks/list.php | 37 ++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index bfda3ad31be..f6da556e8d7 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -154,6 +154,7 @@ $arrayfields = array( 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>1), 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0), 's.nom'=>array('label'=>"ThirdParty", 'checked'=>0), + 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>1), 'p.fk_statut'=>array('label'=>"ProjectStatus", 'checked'=>1), 't.planned_workload'=>array('label'=>"PlannedWorkload", 'checked'=>1, 'position'=>102), 't.duration_effective'=>array('label'=>"TimeSpent", 'checked'=>1, 'position'=>103), @@ -326,7 +327,7 @@ if (count($listoftaskcontacttype) == 0) { $distinct = 'DISTINCT'; // We add distinct until we are added a protection to be sure a contact of a project and task is assigned only once. $sql = "SELECT ".$distinct." p.rowid as projectid, p.ref as projectref, p.title as projecttitle, p.fk_statut as projectstatus, p.datee as projectdatee, p.fk_opp_status, p.public, p.fk_user_creat as projectusercreate, p.usage_bill_time,"; -$sql .= " s.nom as name, s.rowid as socid,"; +$sql .= " s.nom as name, s.name_alias as alias, s.rowid as socid,"; $sql .= " t.datec as date_creation, t.dateo as date_start, t.datee as date_end, t.tms as date_update,"; $sql .= " t.rowid as id, t.ref, t.label, t.planned_workload, t.duration_effective, t.progress, t.fk_statut, "; $sql .= " t.description, t.fk_task_parent"; @@ -413,6 +414,9 @@ if ($search_task_budget_amount) { if ($search_societe) { $sql .= natural_search('s.nom', $search_societe); } +if ($search_societe_alias) { + $sql .= natural_search('s.name_alias', $search_societe_alias); +} if ($search_date_start) { $sql .= " AND t.dateo >= '".$db->idate($search_date_start)."'"; } @@ -768,6 +772,11 @@ if (!empty($arrayfields['s.nom']['checked'])) { print ''; print ''; } +if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; + print ''; + print ''; +} if (!empty($arrayfields['p.fk_statut']['checked'])) { print ''; $arrayofstatus = array(); @@ -890,6 +899,10 @@ if (!empty($arrayfields['s.nom']['checked'])) { print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder); $totalarray['nbfield']++; } +if (!empty($arrayfields['s.name_alias']['checked'])) { + print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], "s.name_alias", "", $param, "", $sortfield, $sortorder); + $totalarray['nbfield']++; +} if (!empty($arrayfields['p.fk_statut']['checked'])) { print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, '', $sortfield, $sortorder, 'center '); $totalarray['nbfield']++; @@ -992,6 +1005,11 @@ while ($i < $imaxinloop) { $projectstatic->statut = $obj->projectstatus; $projectstatic->datee = $db->jdate($obj->projectdatee); + if ($obj->socid) { + $socstatic->id = $obj->socid; + $socstatic->name = $obj->name; + $socstatic->name_alias = $obj->alias; + } if ($mode == 'kanban') { if ($i == 0) { print ''; @@ -1101,9 +1119,20 @@ while ($i < $imaxinloop) { if (!empty($arrayfields['s.nom']['checked'])) { print ''; if ($obj->socid) { - $socstatic->id = $obj->socid; - $socstatic->name = $obj->name; - print $socstatic->getNomUrl(1); + print $socstatic->getNomUrl(1, '', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); + } else { + print ' '; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Alias + if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; + if ($obj->socid) { + print $socstatic->name_alias; } else { print ' '; } From 0adc7116a6a8a562da02ba1fad5c2feafe9877f3 Mon Sep 17 00:00:00 2001 From: Faustin Date: Tue, 21 Jun 2022 19:21:50 +0200 Subject: [PATCH 064/367] NEW 21000 Added columns 'alias_name' on supplier order list --- htdocs/fourn/commande/list.php | 36 ++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 22c4921b5b1..6f2669ac877 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -93,6 +93,7 @@ $search_product_category = GETPOST('search_product_category', 'int'); $search_ref = GETPOST('search_ref', 'alpha'); $search_refsupp = GETPOST('search_refsupp', 'alpha'); $search_company = GETPOST('search_company', 'alpha'); +$search_company_alias = GETPOST('search_company_alias', 'alpha'); $search_town = GETPOST('search_town', 'alpha'); $search_zip = GETPOST('search_zip', 'alpha'); $search_state = GETPOST("search_state", 'alpha'); @@ -181,6 +182,7 @@ $checkedtypetiers = 0; // Definition of array of fields for columns $arrayfields = array( + 's.name_alias'=>array('label'=>"AliasNameShort", 'position'=>47, 'checked'=>0), 's.town'=>array('label'=>"Town", 'enabled'=>1, 'position'=>47, 'checked'=>1), 's.zip'=>array('label'=>"Zip", 'enabled'=>1, 'position'=>47, 'checked'=>1), 'state.nom'=>array('label'=>"StateShort", 'enabled'=>1, 'position'=>48), @@ -246,6 +248,7 @@ if (empty($reshook)) { $search_ref = ''; $search_refsupp = ''; $search_company = ''; + $search_company_alias = ''; $search_town = ''; $search_zip = ""; $search_state = ""; @@ -657,6 +660,9 @@ if (empty($reshook)) { if ($search_company) { $param .= '&search_company='.urlencode($search_company); } + if ($search_company_alias) { + $param .= '&search_company_alias='.urlencode($search_company_alias); + } //if ($search_ref_customer) $param .= '&search_ref_customer='.urlencode($search_ref_customer); if ($search_user > 0) { $param .= '&search_user='.urlencode($search_user); @@ -741,7 +747,7 @@ $sql = 'SELECT'; if ($sall || $search_product_category > 0) { $sql = 'SELECT DISTINCT'; } -$sql .= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, s.email,'; +$sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.town, s.zip, s.fk_pays, s.client, s.code_client, s.email,'; $sql .= " typent.code as typent_code,"; $sql .= " state.code_departement as state_code, state.nom as state_name,"; $sql .= " cf.rowid, cf.ref, cf.ref_supplier, cf.fk_statut, cf.billed, cf.total_ht, cf.total_tva, cf.total_ttc, cf.fk_user_author, cf.date_commande as date_commande, cf.date_livraison as date_livraison,cf.date_valid, cf.date_approve,"; @@ -803,6 +809,9 @@ if ($sall) { if ($search_company) { $sql .= natural_search('s.nom', $search_company); } +if ($search_company_alias) { + $sql .= natural_search('s.name_alias', $search_company_alias); +} if ($search_request_author) { $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_request_author); } @@ -861,6 +870,9 @@ if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) { if ($search_company) { $sql .= natural_search('s.nom', $search_company); } +if ($search_company_alias) { + $sql .= natural_search('s.name_alias', $search_company_alias); +} if ($search_sale > 0) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale); } @@ -1032,6 +1044,9 @@ if ($resql) { if ($search_company) { $param .= '&search_company='.urlencode($search_company); } + if ($search_company_alias) { + $param .= '&search_company_alias='.urlencode($search_company_alias); + } if ($search_user > 0) { $param .= '&search_user='.urlencode($search_user); } @@ -1275,6 +1290,10 @@ if ($resql) { if (!empty($arrayfields['cf.fk_soc']['checked'])) { print ''; } + // Alias + if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; + } // Town if (!empty($arrayfields['s.town']['checked'])) { print ''; @@ -1447,6 +1466,9 @@ if ($resql) { if (!empty($arrayfields['cf.fk_soc']['checked'])) { print_liste_field_titre($arrayfields['cf.fk_soc']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder); } + if (!empty($arrayfields['s.name_alias']['checked'])) { + print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], "s.name_alias", "", $param, '', $sortfield, $sortorder); + } if (!empty($arrayfields['s.town']['checked'])) { print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); } @@ -1623,7 +1645,17 @@ if ($resql) { $thirdpartytmp->id = $obj->socid; $thirdpartytmp->name = $obj->name; $thirdpartytmp->email = $obj->email; - print $thirdpartytmp->getNomUrl(1, 'supplier'); + $thirdpartytmp->name_alias = $obj->alias; + print $thirdpartytmp->getNomUrl(1, 'supplier', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); + print ''."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + //alias + if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; + print $obj->alias; print ''."\n"; if (!$i) { $totalarray['nbfield']++; From 08ba39f70444d2e3b1992dc26039aac1606d2e6e Mon Sep 17 00:00:00 2001 From: Faustin Date: Tue, 21 Jun 2022 19:25:38 +0200 Subject: [PATCH 065/367] NEW 21000 Added columns 'alias_name' on supplier order list --- htdocs/projet/tasks/list.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index f6da556e8d7..183a53783fb 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -68,6 +68,7 @@ $search_task_user = GETPOST('search_task_user', 'int'); $search_task_progress = GETPOST('search_task_progress'); $search_task_budget_amount = GETPOST('search_task_budget_amount'); $search_societe = GETPOST('search_societe'); +$search_societe_alias = GETPOST('search_societe_alias'); $search_opp_status = GETPOST("search_opp_status", 'alpha'); $mine = GETPOST('mode', 'alpha') == 'mine' ? 1 : 0; @@ -206,6 +207,8 @@ if (empty($reshook)) { $search_categ = ""; $search_projectstatus = -1; $search_project_ref = ""; + $search_societe = ""; + $search_societe_alias = ""; $search_project_title = ""; $search_task_ref = ""; $search_task_label = ""; @@ -583,6 +586,9 @@ if ($search_task_progress != '') { if ($search_societe != '') { $param .= '&search_societe='.urlencode($search_societe); } +if ($search_societe != '') { + $param .= '&search_societe_alias='.urlencode($search_societe_alias); +} if ($search_projectstatus != '') { $param .= '&search_projectstatus='.urlencode($search_projectstatus); } @@ -774,7 +780,7 @@ if (!empty($arrayfields['s.nom']['checked'])) { } if (!empty($arrayfields['s.name_alias']['checked'])) { print ''; - print ''; + print ''; print ''; } if (!empty($arrayfields['p.fk_statut']['checked'])) { From df8580dd4cdba7ed69ec658fd57b88bc2a72c161 Mon Sep 17 00:00:00 2001 From: Faustin Date: Tue, 21 Jun 2022 19:50:05 +0200 Subject: [PATCH 066/367] NEW 21000 Added columns 'alias_name' on supplier invoice list --- htdocs/fourn/facture/list.php | 36 ++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 70a7334196a..4df04f30f70 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -77,6 +77,7 @@ $search_refsupplier = GETPOST('search_refsupplier', 'alpha'); $search_type = GETPOST('search_type', 'int'); $search_project = GETPOST('search_project', 'alpha'); $search_company = GETPOST('search_company', 'alpha'); +$search_company_alias = GETPOST('search_company_alias', 'alpha'); $search_montant_ht = GETPOST('search_montant_ht', 'alpha'); $search_montant_vat = GETPOST('search_montant_vat', 'alpha'); $search_montant_localtax1 = GETPOST('search_montant_localtax1', 'alpha'); @@ -178,6 +179,7 @@ $arrayfields = array( 'f.date_lim_reglement'=>array('label'=>"DateDue", 'checked'=>1), 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>0), 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1), + 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>0), 's.town'=>array('label'=>"Town", 'checked'=>-1), 's.zip'=>array('label'=>"Zip", 'checked'=>1), 'state.nom'=>array('label'=>"StateShort", 'checked'=>0), @@ -252,6 +254,7 @@ if (empty($reshook)) { $search_label = ""; $search_project = ''; $search_company = ""; + $search_company_alias = ""; $search_amount_no_tax = ""; $search_amount_all_tax = ""; $search_montant_ht = ''; @@ -413,7 +416,7 @@ $sql .= " f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,"; $sql .= ' f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva as multicurrency_total_vat, f.multicurrency_total_ttc,'; $sql .= " f.note_public, f.note_private,"; $sql .= " f.fk_user_author,"; -$sql .= " s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,"; +$sql .= " s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,"; $sql .= " typent.code as typent_code,"; $sql .= " state.code_departement as state_code, state.nom as state_name,"; $sql .= " country.code as country_code,"; @@ -518,6 +521,9 @@ if ($search_project) { if ($search_company) { $sql .= natural_search('s.nom', $search_company); } +if ($search_company_alias) { + $sql .= natural_search('s.name_alias', $search_company_alias); +} if ($search_town) { $sql .= natural_search('s.town', $search_town); } @@ -693,6 +699,7 @@ if ($resql) { $soc->fetch($socid); if (empty($search_company)) { $search_company = $soc->name; + $search_company_alias = $soc->name_alias; } } @@ -757,6 +764,9 @@ if ($resql) { if ($search_company) { $param .= '&search_company='.urlencode($search_company); } + if ($search_company_alias) { + $param .= '&search_company_alias='.urlencode($search_company_alias); + } if ($search_login) { $param .= '&search_login='.urlencode($search_login); } @@ -1004,6 +1014,10 @@ if ($resql) { if (!empty($arrayfields['s.nom']['checked'])) { print ''; } + // Alias + if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; + } // Town if (!empty($arrayfields['s.town']['checked'])) { print ''; @@ -1181,6 +1195,9 @@ if ($resql) { if (!empty($arrayfields['s.nom']['checked'])) { print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], 's.nom', '', $param, '', $sortfield, $sortorder); } + if (!empty($arrayfields['s.name_alias']['checked'])) { + print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER['PHP_SELF'], 's.name_alias', '', $param, '', $sortfield, $sortorder); + } if (!empty($arrayfields['s.town']['checked'])) { print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); } @@ -1188,7 +1205,10 @@ if ($resql) { print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder, 'center '); } if (!empty($arrayfields['state.nom']['checked'])) { - print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.name_alias", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['state.name_alias']['checked'])) { + print_liste_field_titre($arrayfields['state.name_alias']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); } if (!empty($arrayfields['country.code_iso']['checked'])) { print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); @@ -1293,6 +1313,7 @@ if ($resql) { $thirdparty->id = $obj->socid; $thirdparty->name = $obj->name; + $thirdparty->name_alias = $obj->alias; $thirdparty->client = $obj->client; $thirdparty->fournisseur = $obj->fournisseur; $thirdparty->code_client = $obj->code_client; @@ -1417,7 +1438,16 @@ if ($resql) { // Third party if (!empty($arrayfields['s.nom']['checked'])) { print ''; - print $thirdparty->getNomUrl(1, 'supplier'); + print $thirdparty->getNomUrl(1, 'supplier', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Alias + if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; + print $thirdparty->name_alias; print ''; if (!$i) { $totalarray['nbfield']++; From 15abd76ef4a5e5f21d3efb7465036491b2c483e2 Mon Sep 17 00:00:00 2001 From: Faustin Date: Tue, 21 Jun 2022 20:04:35 +0200 Subject: [PATCH 067/367] NEW 21000 Added columns 'alias_name' on supplier propals list --- htdocs/supplier_proposal/list.php | 32 +++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 96f8a2b2cca..894c16cacf7 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -61,6 +61,7 @@ $search_user = GETPOST('search_user', 'int'); $search_sale = GETPOST('search_sale', 'int'); $search_ref = GETPOST('sf_ref') ?GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha'); $search_societe = GETPOST('search_societe', 'alpha'); +$search_societe_alias = GETPOST('search_societe_alias', 'alpha'); $search_login = GETPOST('search_login', 'alpha'); $search_town = GETPOST('search_town', 'alpha'); $search_zip = GETPOST('search_zip', 'alpha'); @@ -168,6 +169,7 @@ $checkedtypetiers = 0; $arrayfields = array( 'sp.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), 's.nom'=>array('label'=>$langs->trans("Supplier"), 'checked'=>1), + 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>0), 's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1), 's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>1), 'state.nom'=>array('label'=>$langs->trans("StateShort"), 'checked'=>0), @@ -224,6 +226,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_sale = ''; $search_ref = ''; $search_societe = ''; + $search_societe_alias = ''; $search_montant_ht = ''; $search_montant_vat = ''; $search_montant_ttc = ''; @@ -292,7 +295,7 @@ $sql = 'SELECT'; if ($sall || $search_product_category > 0 || $search_user > 0) { $sql = 'SELECT DISTINCT'; } -$sql .= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; +$sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; $sql .= " typent.code as typent_code,"; $sql .= " state.code_departement as state_code, state.nom as state_name,"; $sql .= ' sp.rowid, sp.note_public, sp.note_private, sp.total_ht, sp.total_tva, sp.total_ttc, sp.localtax1, sp.localtax2, sp.ref, sp.fk_statut as status, sp.fk_user_author, sp.date_valid, sp.date_livraison as dp,'; @@ -363,6 +366,9 @@ if ($search_ref) { if ($search_societe) { $sql .= natural_search('s.nom', $search_societe); } +if ($search_societe_alias) { + $sql .= natural_search('s.name_alias', $search_societe_alias); +} if ($search_login) { $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_login); } @@ -521,6 +527,9 @@ if ($resql) { if ($search_societe) { $param .= '&search_societe='.urlencode($search_societe); } + if ($search_societe_alias) { + $param .= '&search_societe_alias='.urlencode($search_societe_alias); + } if ($search_user > 0) { $param .= '&search_user='.urlencode($search_user); } @@ -677,6 +686,11 @@ if ($resql) { print ''; print ''; } + if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; + print ''; + print ''; + } if (!empty($arrayfields['s.town']['checked'])) { print ''; } @@ -816,6 +830,9 @@ if ($resql) { if (!empty($arrayfields['s.nom']['checked'])) { print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder); } + if (!empty($arrayfields['s.name_alias']['checked'])) { + print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], 's.name_alias', '', $param, '', $sortfield, $sortorder); + } if (!empty($arrayfields['s.town']['checked'])) { print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); } @@ -904,6 +921,7 @@ if ($resql) { // Company $companystatic->id = $obj->socid; $companystatic->name = $obj->name; + $companystatic->name_alias = $obj->alias; $companystatic->client = $obj->client; $companystatic->code_client = $obj->code_client; @@ -942,7 +960,17 @@ if ($resql) { // Thirdparty if (!empty($arrayfields['s.nom']['checked'])) { print ''; - print $companystatic->getNomUrl(1, 'supplier'); + print $companystatic->getNomUrl(1, 'supplier', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Alias + if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; + print $companystatic->name_alias; print ''; if (!$i) { $totalarray['nbfield']++; From 3eff91a6dc7cb259906cfd18d6dc59d6e5b1431f Mon Sep 17 00:00:00 2001 From: atm-steve Date: Wed, 22 Jun 2022 10:50:54 +0200 Subject: [PATCH 068/367] wip: popin with new fileds --- htdocs/contrat/card.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 87d6b98475b..df74c8dbf25 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1261,7 +1261,24 @@ if ($action == 'create') { // Confirmation de la fermeture $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("CloseAContract"), $langs->trans("ConfirmCloseContract"), "confirm_close", '', 0, 1); } elseif ($action == 'activate') { - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("ActivateAllOnContract"), $langs->trans("ConfirmActivateAllOnContract"), "confirm_activate", '', 0, 1); + //$sql = "SELECT date_ouverture, date_cloture, commentaire FROM " . MAIN_DB_PREFIX ."contratdet WHERE fk_contrat = " . $object->id; + ////$sql.= ""; +// + //$result = $db->query($sql); + //if ($result) { + // $objp = $db->fetch_object($result); + //} +// + //// Definie date debut et fin par defaut + //$dateactstart = $objp->date_ouverture; + //$dateactend = $objp->date_cloture; + //$comment = $objp->commentaire; + $formquestion = array( + array('type' => 'other', 'name' => 'active', 'label' => $langs->trans("DateServiceActivate"), 'value' => $form->selectDate('', '', $usehm, $usehm, '', "active", 1, 0), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)'), + array('type' => 'other', 'name' => 'active', 'label' => $langs->trans("DateEndPlanned"), 'value' => $form->selectDate('', "end", $usehm, $usehm, '', "active", 1, 0), '', ''), + array('type' => 'text', 'comment' => 'active', 'label' => $langs->trans("Comment"), 'value' => '', '', '', 'class' => 'minwidth300') + ); + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("ActivateAllOnContract"), $langs->trans("ConfirmActivateAllOnContract"), "confirm_activate", $formquestion, 'yes', 1, 280); } elseif ($action == 'clone') { // Clone confirmation $formquestion = array(array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)'))); From 3d7904c404f970a5523ee96d53d25d923ae18e62 Mon Sep 17 00:00:00 2001 From: atm-steve Date: Wed, 22 Jun 2022 12:05:39 +0200 Subject: [PATCH 069/367] feat: activate all services on contrat --- htdocs/contrat/card.php | 24 +++++++----------------- htdocs/contrat/class/contrat.class.php | 4 ++-- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index df74c8dbf25..0254efdbe95 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -785,8 +785,10 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); } } elseif ($action == 'confirm_activate' && $confirm == 'yes' && $user->rights->contrat->creer) { - // Close all lines - $result = $object->activateAll($user); + $date_start = dol_mktime(12, 0, 0, GETPOST('d_startmonth'), GETPOST('d_startday'), GETPOST('d_startyear')); + $date_end = dol_mktime(12, 0, 0, GETPOST('d_endmonth'), GETPOST('d_endday'), GETPOST('d_endyear')); + $comment = GETPOST('comment', 'alpha'); + $result = $object->activateAll($user, $date_start, 0, $comment, $date_end); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } @@ -1261,22 +1263,10 @@ if ($action == 'create') { // Confirmation de la fermeture $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("CloseAContract"), $langs->trans("ConfirmCloseContract"), "confirm_close", '', 0, 1); } elseif ($action == 'activate') { - //$sql = "SELECT date_ouverture, date_cloture, commentaire FROM " . MAIN_DB_PREFIX ."contratdet WHERE fk_contrat = " . $object->id; - ////$sql.= ""; -// - //$result = $db->query($sql); - //if ($result) { - // $objp = $db->fetch_object($result); - //} -// - //// Definie date debut et fin par defaut - //$dateactstart = $objp->date_ouverture; - //$dateactend = $objp->date_cloture; - //$comment = $objp->commentaire; $formquestion = array( - array('type' => 'other', 'name' => 'active', 'label' => $langs->trans("DateServiceActivate"), 'value' => $form->selectDate('', '', $usehm, $usehm, '', "active", 1, 0), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)'), - array('type' => 'other', 'name' => 'active', 'label' => $langs->trans("DateEndPlanned"), 'value' => $form->selectDate('', "end", $usehm, $usehm, '', "active", 1, 0), '', ''), - array('type' => 'text', 'comment' => 'active', 'label' => $langs->trans("Comment"), 'value' => '', '', '', 'class' => 'minwidth300') + array('type' => 'date', 'name' => 'd_start', 'label' => $langs->trans("DateServiceActivate"), /*'value' => $form->selectDate('', '', $usehm, $usehm, '', "active", 1, 0),*/ /*'socid', '(s.client=1 OR s.client=2 OR s.client=3)'*/), + array('type' => 'date', 'name' => 'd_end', 'label' => $langs->trans("DateEndPlanned"), /*'value' => $form->selectDate('', "end", $usehm, $usehm, '', "active", 1, 0),*/ '', ''), + array('type' => 'text', 'name' => 'comment', 'label' => $langs->trans("Comment"), 'value' => '', '', '', 'class' => 'minwidth300') ); $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("ActivateAllOnContract"), $langs->trans("ConfirmActivateAllOnContract"), "confirm_activate", $formquestion, 'yes', 1, 280); } elseif ($action == 'clone') { diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 4e4437c1b2c..87f728b18a4 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -369,7 +369,7 @@ class Contrat extends CommonObject * @return int <0 if KO, >0 if OK * @see () */ - public function activateAll($user, $date_start = '', $notrigger = 0, $comment = '') + public function activateAll($user, $date_start = '', $notrigger = 0, $comment = '', $date_end = '') { if (empty($date_start)) { $date_start = dol_now(); @@ -387,7 +387,7 @@ class Contrat extends CommonObject if ($contratline->statut != ContratLigne::STATUS_OPEN) { $contratline->context = $this->context; - $result = $contratline->active_line($user, $date_start, -1, $comment); // This call trigger LINECONTRACT_ACTIVATE + $result = $contratline->active_line($user, $date_start, !empty($date_end) ? $date_end : -1, $comment); // This call trigger LINECONTRACT_ACTIVATE if ($result < 0) { $error++; $this->error = $contratline->error; From 63cca2c7cfe0cfc664299a2b9948107e1dc46250 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 22 Jun 2022 10:16:27 +0000 Subject: [PATCH 070/367] Fixing style errors. --- htdocs/core/class/html.formfile.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 0b87823c38d..69c349616f5 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1282,7 +1282,6 @@ class FormFile if ($file['name'] != '.' && $file['name'] != '..' && !preg_match('/\.meta$/i', $file['name'])) { - if (array_key_exists('rowid', $filearray[$key]) && $filearray[$key]['rowid'] > 0) { $lastrowid = $filearray[$key]['rowid']; } From fd0bbf8ebc94c27ba44f213e5c88ae8c6e5447af Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Wed, 22 Jun 2022 12:25:59 +0200 Subject: [PATCH 071/367] fix coments --- htdocs/core/tpl/filemanager.tpl.php | 4 +++- htdocs/ecm/dir_add_card.php | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/tpl/filemanager.tpl.php b/htdocs/core/tpl/filemanager.tpl.php index 2290e9093d8..2c4b2f5dea8 100644 --- a/htdocs/core/tpl/filemanager.tpl.php +++ b/htdocs/core/tpl/filemanager.tpl.php @@ -53,8 +53,10 @@ if ($module == 'medias') { $permtoupload = ($user->rights->mailing->creer || $user->rights->website->write); $showroot = 1; } -$section = 0; +if (!isset($section)) { + $section = 0; +} // Confirm remove file (for non javascript users) if (($action == 'delete' || $action == 'file_manager_delete') && empty($conf->use_javascript_ajax)) { diff --git a/htdocs/ecm/dir_add_card.php b/htdocs/ecm/dir_add_card.php index a6c980e5908..e5df264e377 100644 --- a/htdocs/ecm/dir_add_card.php +++ b/htdocs/ecm/dir_add_card.php @@ -230,7 +230,7 @@ if ($action == 'create') { print ''; // Label - print ''."\n"; + print ''."\n"; print ''; + + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + // Action column + print ''; + } + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { print ''; @@ -1528,13 +1537,20 @@ if ($resql) { print ''; } // Action column - print ''; + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } print "\n"; print ''; + + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); + } + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder); } @@ -1685,7 +1701,10 @@ if ($resql) { if (!empty($arrayfields['f.fk_statut']['checked'])) { print_liste_field_titre($arrayfields['f.fk_statut']['label'], $_SERVER["PHP_SELF"], "f.fk_statut,f.paye,f.type", "", $param, 'class="right"', $sortfield, $sortorder); } - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); + } + print "\n"; $projectstatic = new Project($db); @@ -1818,6 +1837,20 @@ if ($resql) { } print '>'; + + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } + // No if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { print ''; @@ -2392,19 +2425,21 @@ if ($resql) { } // Action column (Show the massaction button only when this page is not opend from the Extended POS) - print ''; } - print ''; if (!$i) { $totalarray['nbfield']++; } - print "\n"; $i++; From d3807286d4af5cc60461c4219a52e04bb0c78193 Mon Sep 17 00:00:00 2001 From: bagtaib Date: Fri, 24 Jun 2022 13:41:21 +0200 Subject: [PATCH 084/367] fix spaces --- ...terface_20_modWorkflow_WorkflowManager.class.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index b04be51379d..cc6a1168c32 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -73,18 +73,17 @@ class InterfaceWorkflowManager extends DolibarrTriggers dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); if (!empty($conf->commande->enabled) && !empty($conf->global->WORKFLOW_PROPAL_AUTOCREATE_ORDER)) { $object->fetchObjectLinked(); - if (!empty($object->linkedObjectsIds['commande'])){ + if (!empty($object->linkedObjectsIds['commande'])) { setEventMessages($langs->trans("OrderExists"), null, 'warnings'); return $ret; - } - else { + } else { include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; $newobject = new Commande($this->db); - + $newobject->context['createfrompropal'] = 'createfrompropal'; $newobject->context['origin'] = $object->element; $newobject->context['origin_id'] = $object->id; - + $ret = $newobject->createFromProposal($object, $user); if ($ret < 0) { $this->error = $newobject->error; @@ -92,8 +91,8 @@ class InterfaceWorkflowManager extends DolibarrTriggers } return $ret; } - } - } + } + } // Order to invoice if ($action == 'ORDER_CLOSE') { From 10a9ab5ed179a3c02f21d8d9d17544bc04481a74 Mon Sep 17 00:00:00 2001 From: Faustin Date: Fri, 24 Jun 2022 13:56:24 +0200 Subject: [PATCH 085/367] NEW #20650 enabled checkcolumn on left for commande list --- htdocs/commande/list.php | 55 ++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 350674370e9..aa13e9607e6 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -1374,7 +1374,7 @@ if ($resql) { } $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; - $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); if (GETPOST('autoselectall', 'int')) { @@ -1391,6 +1391,14 @@ if ($resql) { print '
'.$langs->trans("Label").'
'.$langs->trans("Label").'label).'" autofocus>
'.$langs->trans("AddIn").''; print $formecm->selectAllSections((GETPOST("catParent", 'alpha') ? GETPOST("catParent", 'alpha') : $ecmdir->fk_parent), 'catParent', $module); From ce7db0004bdf68664cc32f03a45f504189c32ee6 Mon Sep 17 00:00:00 2001 From: Quatadah Nasdami Date: Wed, 22 Jun 2022 14:41:46 +0200 Subject: [PATCH 072/367] two changes to feature request --- htdocs/core/class/commonobject.class.php | 3 +++ htdocs/core/lib/files.lib.php | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 4a95bb7d345..ff240501d1e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5516,6 +5516,9 @@ abstract class CommonObject if ($this->element == 'bank_account' && !empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) { $setsharekey = true; } + if ($this->element == 'product' && !empty($conf->global->PRODUCT_ALLOW_EXTERNAL_DOWNLOAD)) { + $setsharekey = true; + } if ($this->element == 'contrat' && !empty($conf->global->CONTRACT_ALLOW_EXTERNAL_DOWNLOAD)) { $setsharekey = true; } diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 482831191d6..e8134c6f0dd 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1727,6 +1727,13 @@ function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesess } } + // Update table of files + if ($donotupdatesession == 1) { + $sharefile = 0; + if ($TFile['type'][$i] == 'application/pdf' && strpos($_SERVER["REQUEST_URI"], 'product') !== false && !empty($conf->global->PRODUCT_ALLOW_EXTERNAL_DOWNLOAD)) $sharefile = 1; + $result = addFileIntoDatabaseIndex($upload_dir, basename($destfile), $TFile['name'][$i], 'uploaded', $sharefile); + } + $nbok++; } else { $langs->load("errors"); From a14b7009002dd65071adebd5c386838e17101eba Mon Sep 17 00:00:00 2001 From: bagtaib Date: Wed, 22 Jun 2022 15:09:23 +0200 Subject: [PATCH 073/367] New #19511 --- htdocs/core/lib/functions.lib.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 13d44e1ec8a..c86cd4bd77b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3310,6 +3310,17 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli //ex: +61_A_BCDE_FGHI $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 1).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 4); } + } elseif (strtoupper($countrycode) == "LU") { + // Luxembourg + if (dol_strlen($phone) == 10) {// fixe 6 chiffres +352_AA_BB_CC + $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2); + } elseif (dol_strlen($phone) == 11) {// fixe 7 chiffres +352_AA_BB_CC_D + $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 1); + } elseif (dol_strlen($phone) == 12) {// fixe 8 chiffres +352_AA_BB_CC_DD + $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2); + } elseif (dol_strlen($phone) == 13) {// mobile +352_AAA_BB_CC_DD + $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2).$separ.substr($newphone, 11, 2); + } } if (!empty($addlink)) { // Link on phone number (+ link to add action if conf->global->AGENDA_ADDACTIONFORPHONE set) if ($conf->browser->layout == 'phone' || (!empty($conf->clicktodial->enabled) && !empty($conf->global->CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS))) { // If phone or option for, we use link of phone From 03de8707510de11d19c3844aec8890d68a7c1223 Mon Sep 17 00:00:00 2001 From: bagtaib Date: Wed, 22 Jun 2022 16:29:15 +0200 Subject: [PATCH 074/367] NEW #21204 --- htdocs/admin/workflow.php | 6 ++++++ .../interface_20_modWorkflow_WorkflowManager.class.php | 6 ++++++ htdocs/langs/en_US/workflow.lang | 1 + 3 files changed, 13 insertions(+) diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index 47e6e87a244..4c7339f8520 100644 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -65,6 +65,12 @@ $workflowcodes = array( 'enabled'=>(!empty($conf->propal->enabled) && !empty($conf->commande->enabled)), 'picto'=>'order' ), + 'WORKFLOW_PROPAL_NOTCREATE_ORDER_IFEXISTS'=>array( + 'family'=>'create', + 'position'=>15, + 'enabled'=>(!empty($conf->propal->enabled) && !empty($conf->commande->enabled)), + 'picto'=>'order' + ), 'WORKFLOW_ORDER_AUTOCREATE_INVOICE'=>array( 'family'=>'create', 'position'=>20, diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index 8bd1e0d647d..5dc95a0679e 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -86,8 +86,14 @@ class InterfaceWorkflowManager extends DolibarrTriggers } return $ret; } + if (!empty($conf->global->WORKFLOW_PROPAL_NOTCREATE_ORDER_IFEXISTS)) { + $object->fetchObjectLinked(); + if (!empty($object->linkedObjectsIds['commande'])) + return $ret; + } } + // Order to invoice if ($action == 'ORDER_CLOSE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); diff --git a/htdocs/langs/en_US/workflow.lang b/htdocs/langs/en_US/workflow.lang index 803a31c9646..15c8b75d3ed 100644 --- a/htdocs/langs/en_US/workflow.lang +++ b/htdocs/langs/en_US/workflow.lang @@ -3,6 +3,7 @@ WorkflowSetup=Workflow module setup WorkflowDesc=This module provides some automatic actions. By default, the workflow is open (you can do things in the order you want) but here you can activate some automatic actions. ThereIsNoWorkflowToModify=There is no workflow modifications available with the activated modules. # Autocreate +descWORKFLOW_PROPAL_NOTCREATE_ORDER_IFEXISTS=Do not Automatically create a sales order after a commercial proposal is signed if it already exists descWORKFLOW_PROPAL_AUTOCREATE_ORDER=Automatically create a sales order after a commercial proposal is signed (the new order will have same amount as the proposal) descWORKFLOW_PROPAL_AUTOCREATE_INVOICE=Automatically create a customer invoice after a commercial proposal is signed (the new invoice will have same amount as the proposal) descWORKFLOW_CONTRACT_AUTOCREATE_INVOICE=Automatically create a customer invoice after a contract is validated From cc0be635dc38a722931dde3a2f4c5757cecb06af Mon Sep 17 00:00:00 2001 From: bagtaib Date: Thu, 23 Jun 2022 15:37:37 +0200 Subject: [PATCH 075/367] removed the new option and enhanced the old one --- htdocs/admin/workflow.php | 6 --- ...e_20_modWorkflow_WorkflowManager.class.php | 39 ++++++++++--------- htdocs/langs/en_US/orders.lang | 1 + htdocs/langs/en_US/workflow.lang | 1 - 4 files changed, 21 insertions(+), 26 deletions(-) diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index 4c7339f8520..47e6e87a244 100644 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -65,12 +65,6 @@ $workflowcodes = array( 'enabled'=>(!empty($conf->propal->enabled) && !empty($conf->commande->enabled)), 'picto'=>'order' ), - 'WORKFLOW_PROPAL_NOTCREATE_ORDER_IFEXISTS'=>array( - 'family'=>'create', - 'position'=>15, - 'enabled'=>(!empty($conf->propal->enabled) && !empty($conf->commande->enabled)), - 'picto'=>'order' - ), 'WORKFLOW_ORDER_AUTOCREATE_INVOICE'=>array( 'family'=>'create', 'position'=>20, diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index 5dc95a0679e..b04be51379d 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -72,27 +72,28 @@ class InterfaceWorkflowManager extends DolibarrTriggers if ($action == 'PROPAL_CLOSE_SIGNED') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); if (!empty($conf->commande->enabled) && !empty($conf->global->WORKFLOW_PROPAL_AUTOCREATE_ORDER)) { - include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - $newobject = new Commande($this->db); - - $newobject->context['createfrompropal'] = 'createfrompropal'; - $newobject->context['origin'] = $object->element; - $newobject->context['origin_id'] = $object->id; - - $ret = $newobject->createFromProposal($object, $user); - if ($ret < 0) { - $this->error = $newobject->error; - $this->errors[] = $newobject->error; - } - return $ret; - } - if (!empty($conf->global->WORKFLOW_PROPAL_NOTCREATE_ORDER_IFEXISTS)) { $object->fetchObjectLinked(); - if (!empty($object->linkedObjectsIds['commande'])) + if (!empty($object->linkedObjectsIds['commande'])){ + setEventMessages($langs->trans("OrderExists"), null, 'warnings'); return $ret; - } - } - + } + else { + include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + $newobject = new Commande($this->db); + + $newobject->context['createfrompropal'] = 'createfrompropal'; + $newobject->context['origin'] = $object->element; + $newobject->context['origin_id'] = $object->id; + + $ret = $newobject->createFromProposal($object, $user); + if ($ret < 0) { + $this->error = $newobject->error; + $this->errors[] = $newobject->error; + } + return $ret; + } + } + } // Order to invoice if ($action == 'ORDER_CLOSE') { diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang index a4261f8e62c..aa7dd934ede 100644 --- a/htdocs/langs/en_US/orders.lang +++ b/htdocs/langs/en_US/orders.lang @@ -1,4 +1,5 @@ # Dolibarr language file - Source file is en_US - orders +OrderExists=An order was already open linked to this proposal, so no other order was created automatically OrdersArea=Customers orders area SuppliersOrdersArea=Purchase orders area OrderCard=Order card diff --git a/htdocs/langs/en_US/workflow.lang b/htdocs/langs/en_US/workflow.lang index 15c8b75d3ed..803a31c9646 100644 --- a/htdocs/langs/en_US/workflow.lang +++ b/htdocs/langs/en_US/workflow.lang @@ -3,7 +3,6 @@ WorkflowSetup=Workflow module setup WorkflowDesc=This module provides some automatic actions. By default, the workflow is open (you can do things in the order you want) but here you can activate some automatic actions. ThereIsNoWorkflowToModify=There is no workflow modifications available with the activated modules. # Autocreate -descWORKFLOW_PROPAL_NOTCREATE_ORDER_IFEXISTS=Do not Automatically create a sales order after a commercial proposal is signed if it already exists descWORKFLOW_PROPAL_AUTOCREATE_ORDER=Automatically create a sales order after a commercial proposal is signed (the new order will have same amount as the proposal) descWORKFLOW_PROPAL_AUTOCREATE_INVOICE=Automatically create a customer invoice after a commercial proposal is signed (the new invoice will have same amount as the proposal) descWORKFLOW_CONTRACT_AUTOCREATE_INVOICE=Automatically create a customer invoice after a contract is validated From 2f1eff28815183ddd43b535e516a5fd465a1ee2a Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 23 Jun 2022 13:42:37 +0000 Subject: [PATCH 076/367] Fixing style errors. --- ...terface_20_modWorkflow_WorkflowManager.class.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index b04be51379d..cc6a1168c32 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -73,18 +73,17 @@ class InterfaceWorkflowManager extends DolibarrTriggers dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); if (!empty($conf->commande->enabled) && !empty($conf->global->WORKFLOW_PROPAL_AUTOCREATE_ORDER)) { $object->fetchObjectLinked(); - if (!empty($object->linkedObjectsIds['commande'])){ + if (!empty($object->linkedObjectsIds['commande'])) { setEventMessages($langs->trans("OrderExists"), null, 'warnings'); return $ret; - } - else { + } else { include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; $newobject = new Commande($this->db); - + $newobject->context['createfrompropal'] = 'createfrompropal'; $newobject->context['origin'] = $object->element; $newobject->context['origin_id'] = $object->id; - + $ret = $newobject->createFromProposal($object, $user); if ($ret < 0) { $this->error = $newobject->error; @@ -92,8 +91,8 @@ class InterfaceWorkflowManager extends DolibarrTriggers } return $ret; } - } - } + } + } // Order to invoice if ($action == 'ORDER_CLOSE') { From e7858a97bf7c71cb3102b22c74de40a0535f4fc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?This=20Charl=C3=A8ne?= <1179011+defrance@users.noreply.github.com> Date: Thu, 23 Jun 2022 17:46:32 +0200 Subject: [PATCH 077/367] Delete llx_element_tag.sql --- .../install/mysql/tables/llx_element_tag.sql | 25 ------------------- 1 file changed, 25 deletions(-) delete mode 100644 htdocs/install/mysql/tables/llx_element_tag.sql diff --git a/htdocs/install/mysql/tables/llx_element_tag.sql b/htdocs/install/mysql/tables/llx_element_tag.sql deleted file mode 100644 index d43ced98130..00000000000 --- a/htdocs/install/mysql/tables/llx_element_tag.sql +++ /dev/null @@ -1,25 +0,0 @@ --- ============================================================================ --- Copyright (C) 2021 Maxime Kohlhaas --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program. If not, see . --- --- ============================================================================ - -create table llx_element_tag -( - rowid integer AUTO_INCREMENT PRIMARY KEY, - fk_categorie integer NOT NULL, - fk_element integer NOT NULL, - import_key varchar(14) -)ENGINE=innodb; From 7594c142360b82a4b483fe381653001bc54a3c5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?This=20Charl=C3=A8ne?= <1179011+defrance@users.noreply.github.com> Date: Thu, 23 Jun 2022 17:46:57 +0200 Subject: [PATCH 078/367] Delete llx_element_tag.key.sql --- .../mysql/tables/llx_element_tag.key.sql | 21 ------------------- 1 file changed, 21 deletions(-) delete mode 100644 htdocs/install/mysql/tables/llx_element_tag.key.sql diff --git a/htdocs/install/mysql/tables/llx_element_tag.key.sql b/htdocs/install/mysql/tables/llx_element_tag.key.sql deleted file mode 100644 index d3a0b38afa9..00000000000 --- a/htdocs/install/mysql/tables/llx_element_tag.key.sql +++ /dev/null @@ -1,21 +0,0 @@ --- ============================================================================ --- Copyright (C) 2021 Maxime Kohlhaas --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program. If not, see . --- --- ============================================================================ - -ALTER TABLE llx_element_tag ADD UNIQUE INDEX idx_element_tag_uk (fk_categorie, fk_element); - -ALTER TABLE llx_element_tag ADD CONSTRAINT fk_element_tag_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid); From 205022b4c852d421e6b33bb5640303bbe158f47f Mon Sep 17 00:00:00 2001 From: Quatadah Nasdami Date: Thu, 23 Jun 2022 18:09:00 +0200 Subject: [PATCH 079/367] removing useless block --- htdocs/core/lib/files.lib.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index e8134c6f0dd..beb25a3d5fe 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1717,7 +1717,9 @@ function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesess // Update index table of files (llx_ecm_files) if ($donotupdatesession == 1) { - $result = addFileIntoDatabaseIndex($upload_dir, basename($destfile).($resupload == 2 ? '.noexe' : ''), $TFile['name'][$i], 'uploaded', 0, $object); + $sharefile = 0; + if ($TFile['type'][$i] == 'application/pdf' && strpos($_SERVER["REQUEST_URI"], 'product') !== false && !empty($conf->global->PRODUCT_ALLOW_EXTERNAL_DOWNLOAD)) $sharefile = 1; + $result = addFileIntoDatabaseIndex($upload_dir, basename($destfile).($resupload == 2 ? '.noexe' : ''), $TFile['name'][$i], 'uploaded', $sharefile, $object); if ($result < 0) { if ($allowoverwrite) { // Do not show error message. We can have an error due to DB_ERROR_RECORD_ALREADY_EXISTS @@ -1727,13 +1729,6 @@ function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesess } } - // Update table of files - if ($donotupdatesession == 1) { - $sharefile = 0; - if ($TFile['type'][$i] == 'application/pdf' && strpos($_SERVER["REQUEST_URI"], 'product') !== false && !empty($conf->global->PRODUCT_ALLOW_EXTERNAL_DOWNLOAD)) $sharefile = 1; - $result = addFileIntoDatabaseIndex($upload_dir, basename($destfile), $TFile['name'][$i], 'uploaded', $sharefile); - } - $nbok++; } else { $langs->load("errors"); From d6330fd3f73137c493ed9bad5935889f348e7195 Mon Sep 17 00:00:00 2001 From: Quatadah Nasdami Date: Thu, 23 Jun 2022 19:15:05 +0200 Subject: [PATCH 080/367] initialising the smiley function --- htdocs/core/lib/website.lib.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index e9de957e4a8..d9602379977 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -213,6 +213,18 @@ function dolWebsiteReplacementOfLinks($website, $content, $removephppart = 0, $c return $content; } +/** + * Converts smiley string into the utf8 sequence. + * @param string $content Content to replace + * @return string Replacement of all smiley strings with their utf8 code + * @see dolWebsiteOutput() + */ +function dolReplaceSmileyCodeWithUTF8($content) +{ + return $content; +} + + /** * Render a string of an HTML content and output it. * Used to ouput the page when viewed from a server (Dolibarr or Apache). @@ -369,6 +381,8 @@ function dolWebsiteOutput($content, $contenttype = 'html', $containerid = '') $content = str_replace(' Date: Thu, 23 Jun 2022 22:50:23 +0200 Subject: [PATCH 081/367] NEW #20650 thirdparty list : making the dropdown select appears on screen when checked boxes appears on left --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 88f7f7aaa9a..31d54797489 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -8366,7 +8366,7 @@ class Form
'; + $searchpicto = $form->showFilterButtons('left'); + print $searchpicto; + print ''; print ''; - $searchpicto = $form->showFilterButtons(); - print $searchpicto; - print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print '
'; + if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->id, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print ''.(($offset * $limit) + $i).''; - if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->id, $arrayofselected)) { - $selected = 1; + + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->id, $arrayofselected)) { + $selected = 1; + } + print ''; } - print ''; + print '
'."\n"; print ''; + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } + // Ref if (!empty($arrayfields['c.ref']['checked'])) { print ''; } // Action column - print ''; - + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } print "\n"; // Fields title print ''; + + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center '); + } if (!empty($arrayfields['c.ref']['checked'])) { print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], 'c.ref', '', $param, '', $sortfield, $sortorder); } @@ -1794,7 +1807,9 @@ if ($resql) { if (!empty($arrayfields['c.fk_statut']['checked'])) { print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, '', $sortfield, $sortorder, 'center '); } - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center '); + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center '); + } print ''."\n"; $total = 0; @@ -1875,6 +1890,18 @@ if ($resql) { print ''; + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; if (!$i) { From 6118cb69e6e7eb1bfa340b438b7854bfc97ca2fc Mon Sep 17 00:00:00 2001 From: Faustin Date: Fri, 24 Jun 2022 15:01:32 +0200 Subject: [PATCH 086/367] NEW #20650 enabled checkcolumn on left for propal list --- htdocs/comm/propal/list.php | 58 ++++++++++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 14 deletions(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index e490a5ca7ac..722fbbd09e5 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -1096,13 +1096,22 @@ if ($resql) { } $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; - $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; print '
'; + $searchpicto = $form->showFilterButtons('left'); + print $searchpicto; + print ''; @@ -1643,15 +1651,20 @@ if ($resql) { print ''; - $searchpicto = $form->showFilterButtons(); - print $searchpicto; - print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print '
'; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + } + // Ref if (!empty($arrayfields['c.ref']['checked'])) { print ''; @@ -2435,13 +2462,15 @@ if ($resql) { } // Action column - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; } - print ''; } print '
'."\n"; print ''; + + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } + if (!empty($arrayfields['p.ref']['checked'])) { print ''; } // Action column - print ''; - + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } print "\n"; // Fields title print ''; + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); + } if (!empty($arrayfields['p.ref']['checked'])) { print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder); } @@ -1527,7 +1540,9 @@ if ($resql) { if (!empty($arrayfields['p.fk_statut']['checked'])) { print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, 'class="right"', $sortfield, $sortorder); } - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); + } print ''."\n"; $now = dol_now(); @@ -1608,6 +1623,19 @@ if ($resql) { print ''; + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } + if (!empty($arrayfields['p.ref']['checked'])) { print ''; } - print ''; if (!$i) { $totalarray['nbfield']++; } From 1cc9eda9a6a4168ecdcd2ac60dd66292da30cb0d Mon Sep 17 00:00:00 2001 From: Faustin Date: Fri, 24 Jun 2022 16:43:28 +0200 Subject: [PATCH 087/367] NEW #20650 completing checkcolumn on left for propal list --- htdocs/adherents/list.php | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 8bf7f7af6a6..3075225abb9 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -675,7 +675,7 @@ if (!empty($moreforfilter)) { } $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields if ($massactionbutton) { $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); } @@ -685,7 +685,13 @@ print '
'; + $searchpicto = $form->showFilterButtons('left'); + print $searchpicto; + print ''; print ''; @@ -1365,16 +1374,20 @@ if ($resql) { print ''; - $searchpicto = $form->showFilterButtons(); - print $searchpicto; - print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print '
'; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print ''; @@ -2120,15 +2148,17 @@ if ($resql) { } } // Action column - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; } - print ''; + print '
'; - +// Action column +if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; +} // Line numbering if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) { print ''; @@ -962,6 +968,19 @@ while ($i < min($num, $limit)) { print ''; + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } + if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) { print ''; if (!$i) { From 1db386c6956792e82bde64c298f90d3a83ee1255 Mon Sep 17 00:00:00 2001 From: Faustin Date: Fri, 24 Jun 2022 17:00:32 +0200 Subject: [PATCH 088/367] NEW #20650 completing checkcolumn on left for contact list --- htdocs/contact/list.php | 55 ++++++++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 14 deletions(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index e68274ecff2..ca948f8d1ab 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -772,7 +772,7 @@ print $hookmanager->resPrint; print ''; $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields if ($massactionbutton) { $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); } @@ -782,6 +782,13 @@ print '
'; + $searchpicto = $form->showFilterButtons('left'); + print $searchpicto; + print ' 
'; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print ''.$obj->rowid.'
'; +// Action column +if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; +} if (!empty($arrayfields['p.rowid']['checked'])) { print ''; } // Action column -print ''; - +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; +} print ''; // Ligne des titres print ''; +if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); +} if (!empty($arrayfields['p.rowid']['checked'])) { print_liste_field_titre($arrayfields['p.rowid']['label'], $_SERVER["PHP_SELF"], "p.rowid", "", $param, "", $sortfield, $sortorder); } @@ -1032,7 +1043,9 @@ if (!empty($arrayfields['p.statut']['checked'])) { if (!empty($arrayfields['p.import_key']['checked'])) { print_liste_field_titre($arrayfields['p.import_key']['label'], $_SERVER["PHP_SELF"], "p.import_key", "", $param, '', $sortfield, $sortorder, 'center '); } -print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); +} print "\n"; @@ -1064,6 +1077,18 @@ while ($i < min($num, $limit)) { print ''; + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } // ID if (!empty($arrayfields['p.rowid']['checked'])) { print ''; } - print ''; if (!$i) { $totalarray['nbfield']++; } From 4b704e40e7a1fabfddd62cd49f8852d13c197255 Mon Sep 17 00:00:00 2001 From: Faustin Date: Fri, 24 Jun 2022 17:12:03 +0200 Subject: [PATCH 089/367] NEW #20650 completing checkcolumn on left for product list --- htdocs/product/list.php | 56 ++++++++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 770c819ac3c..ff75416b13c 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -852,7 +852,7 @@ if ($resql) { $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; - $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields if ($massactionbutton) { $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); } @@ -862,6 +862,12 @@ if ($resql) { // Lines with input filters print ''; + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } if (!empty($arrayfields['p.rowid']['checked'])) { print ''; } - print ''; - + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } print ''; print ''; + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); + } if (!empty($arrayfields['p.rowid']['checked'])) { print_liste_field_titre($arrayfields['p.rowid']['label'], $_SERVER["PHP_SELF"], "p.rowid", "", $param, "", $sortfield, $sortorder); } @@ -1275,7 +1285,9 @@ if ($resql) { if (!empty($arrayfields['p.tobuy']['checked'])) { print_liste_field_titre($arrayfields['p.tobuy']['label'], $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center '); } - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); + } print "\n"; @@ -1352,6 +1364,18 @@ if ($resql) { print ''; + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } // Ref if (!empty($arrayfields['p.rowid']['checked'])) { print ''; } - print ''; if (!$i) { $totalarray['nbfield']++; } From 1b81b5be5a114caaa5d0d6002907e3299e7d0623 Mon Sep 17 00:00:00 2001 From: Faustin Date: Fri, 24 Jun 2022 17:23:58 +0200 Subject: [PATCH 090/367] NEW #20650 completing checkcolumn on left for stock list --- htdocs/product/stock/list.php | 56 ++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index 4271ac5d8c2..cc94ae303ec 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -443,7 +443,7 @@ if (!empty($moreforfilter)) { } $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; @@ -452,7 +452,13 @@ print '
'; + $searchpicto = $form->showFilterButtons('left'); + print $searchpicto; + print ''; print ''; @@ -934,15 +941,19 @@ if (!empty($arrayfields['p.import_key']['checked'])) { print ''; -$searchpicto = $form->showFilterAndCheckAddButtons(0); -print $searchpicto; -print ''; + $searchpicto = $form->showFilterAndCheckAddButtons(0); + print $searchpicto; + print '
'; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print ''; @@ -1292,15 +1317,17 @@ while ($i < min($num, $limit)) { } // Action column - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; } - print ''; + print '
'; + $searchpicto = $form->showFilterButtons('left'); + print $searchpicto; + print ''; print ''; @@ -1115,14 +1121,18 @@ if ($resql) { print $form->selectarray('search_tobuy', array('0'=>$langs->trans('ProductStatusNotOnBuyShort'), '1'=>$langs->trans('ProductStatusOnBuyShort')), $search_tobuy, 1); print ''; - $searchpicto = $form->showFilterButtons(); - print $searchpicto; - print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print '
'; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print ''; @@ -1895,16 +1919,18 @@ if ($resql) { } } - // Action - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; + // Action column + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; } - print ''; + print '
'; - +// Action column +if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; +} foreach ($object->fields as $key => $val) { if ($key == 'statut') { continue; @@ -508,16 +514,22 @@ if (!empty($arrayfields['t.statut']['checked'])) { } // Action column -print ''; +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; +} print ''."\n"; // Fields title label // -------------------------------------------------------------------- print ''; +// Action column +if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +} foreach ($object->fields as $key => $val) { if ($key == 'statut') { continue; @@ -562,7 +574,9 @@ if (!empty($arrayfields['t.statut']['checked'])) { } // Action column -print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +} print ''."\n"; // Loop on record @@ -585,6 +599,18 @@ while ($i < min($num, $limit)) { // Show here line of result print ''; + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } foreach ($warehouse->fields as $key => $val) { if ($key == 'statut') { continue; @@ -704,15 +730,17 @@ while ($i < min($num, $limit)) { } // Action column - print ''; } - print ''; if (!$i) { $totalarray['nbfield']++; } From 9ede77c0e773243eec4ce46e50eda4c9b4f86c3c Mon Sep 17 00:00:00 2001 From: Faustin Date: Fri, 24 Jun 2022 17:32:28 +0200 Subject: [PATCH 091/367] NEW #20650 completing checkcolumn on left for expedition list --- htdocs/expedition/list.php | 54 +++++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 6b67f419da5..adc80e27b64 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -611,7 +611,7 @@ if (!empty($moreforfilter)) { } $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); if ($massactionbutton) { $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); // This also change content of $arrayfields } @@ -621,6 +621,13 @@ print '
'; + $searchpicto = $form->showFilterButtons('left'); + print $searchpicto; + print ''; -$searchpicto = $form->showFilterButtons(); -print $searchpicto; -print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print '
'; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; } - print ''; + print '
'; +// Action column +if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; +} // Ref if (!empty($arrayfields['e.ref']['checked'])) { print ''; } // Action column -print ''; +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; +} print "\n"; print ''; +if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); +} if (!empty($arrayfields['e.ref']['checked'])) { print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, '', $sortfield, $sortorder); } @@ -809,7 +821,9 @@ if (!empty($arrayfields['e.fk_statut']['checked'])) { if (!empty($arrayfields['e.billed']['checked'])) { print_liste_field_titre($arrayfields['e.billed']['label'], $_SERVER["PHP_SELF"], "e.billed", "", $param, '', $sortfield, $sortorder, 'center '); } -print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); +} print "\n"; $typenArray = $formcompany->typent_array(1); @@ -832,6 +846,18 @@ while ($i < min($num, $limit)) { print ''; + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } // Ref if (!empty($arrayfields['e.ref']['checked'])) { print ''; } - print ''; if (!$i) { $totalarray['nbfield']++; } From d2e7ff3bfbe6b0877b63d699adf7fdfd8ea0f2db Mon Sep 17 00:00:00 2001 From: Faustin Date: Fri, 24 Jun 2022 17:38:58 +0200 Subject: [PATCH 092/367] NEW #20650 completing checkcolumn on left for reception list --- htdocs/reception/list.php | 57 +++++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 14 deletions(-) diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php index 5cdbb201d87..88c86168678 100644 --- a/htdocs/reception/list.php +++ b/htdocs/reception/list.php @@ -751,7 +751,7 @@ if (!empty($moreforfilter)) { } $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); @@ -761,6 +761,13 @@ print '
'; + $searchpicto = $form->showFilterButtons('left'); + print $searchpicto; + print ''; @@ -742,13 +749,18 @@ if (!empty($arrayfields['e.billed']['checked'])) { print ''; -$searchpicto = $form->showFilterAndCheckAddButtons(0); -print $searchpicto; -print ''; + $searchpicto = $form->showFilterAndCheckAddButtons(0); + print $searchpicto; + print '
'; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print ''; @@ -1008,15 +1034,17 @@ while ($i < min($num, $limit)) { } // Action column - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; } - print ''; + print '
'; +// Action column +if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; +} // Ref if (!empty($arrayfields['e.ref']['checked'])) { print ''; } // Action column -print ''; +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; +} print "\n"; print ''; +if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); +} if (!empty($arrayfields['e.ref']['checked'])) { print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, '', $sortfield, $sortorder); } @@ -907,7 +919,9 @@ if (!empty($arrayfields['e.fk_statut']['checked'])) { if (!empty($arrayfields['e.billed']['checked'])) { print_liste_field_titre($arrayfields['e.billed']['label'], $_SERVER["PHP_SELF"], "e.billed", "", $param, '', $sortfield, $sortorder, 'center '); } -print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); +} print "\n"; $i = 0; @@ -926,6 +940,19 @@ while ($i < min($num, $limit)) { print ''; + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } // Ref if (!empty($arrayfields['e.ref']['checked'])) { print ''; } - print ''; if (!$i) { $totalarray['nbfield']++; } From 6b421823f55de7b9f4466e47164da54a037826dc Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Sat, 25 Jun 2022 00:11:40 +0200 Subject: [PATCH 093/367] Use class instance instead of SQL req --- htdocs/compta/accounting-files.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index e754af8c60e..24d0c191d33 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -474,14 +474,10 @@ if ($result && $action == "dl" && !$error) { $log .= ','.$langs->transnoentitiesnoconv("Sens")."\n"; $zipname = $dirfortmpfile.'/'.dol_print_date($date_start, 'dayrfc', 'tzuserrel')."-".dol_print_date($date_stop, 'dayrfc', 'tzuserrel'); if (!empty($projectid)) { - $sql = 'SELECT t.ref FROM '.MAIN_DB_PREFIX.'projet as t'; - $sql .= ' WHERE t.rowid = '.((int) $db->sanitize($projectid)); - $resql = $db->query($sql); - if ($resql) { - $obj = $db->fetch_object($resql); - $zipname .= '_'.$obj->ref; - } else { - dol_print_error($db); + $project = new Project($db); + $project->fetch($projectid); + if ($project->ref) { + $zipname .= '_'.$project->ref; } } $zipname .='_export.zip'; From acddc2a332bc57736dd1538e99194c1f3f6b9f90 Mon Sep 17 00:00:00 2001 From: Faustin Date: Sat, 25 Jun 2022 18:51:19 +0200 Subject: [PATCH 094/367] NEW #20650 completing checkcolumn on left for project list --- htdocs/projet/list.php | 55 +++++++++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 14 deletions(-) diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index eaf9c5022a3..a24ee1fce65 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -854,7 +854,7 @@ if (!empty($moreforfilter)) { } $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); @@ -864,6 +864,13 @@ print '
'; + $searchpicto = $form->showFilterButtons('left'); + print $searchpicto; + print ''; @@ -849,13 +856,18 @@ if (!empty($arrayfields['e.billed']['checked'])) { print ''; -$searchpicto = $form->showFilterAndCheckAddButtons(0); -print $searchpicto; -print ''; + $searchpicto = $form->showFilterAndCheckAddButtons(0); + print $searchpicto; + print '
'; + if ($massactionbutton || $massaction) { + // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print ''; @@ -1085,16 +1112,18 @@ while ($i < min($num, $limit)) { } // Action column - print ''; - if ($massactionbutton || $massaction) { - // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + if ($massactionbutton || $massaction) { + // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; } - print ''; + print '
'; +// Action column +if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; +} // Project ref if (!empty($arrayfields['p.ref']['checked'])) { print ''; } // Action column -print ''; - +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; +} print ''."\n"; print ''; +if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); +} if (!empty($arrayfields['p.ref']['checked'])) { print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, "", $sortfield, $sortorder); } @@ -1122,7 +1133,9 @@ if (!empty($arrayfields['p.email_msgid']['checked'])) { if (!empty($arrayfields['p.fk_statut']['checked'])) { print_liste_field_titre($arrayfields['p.fk_statut']['label'], $_SERVER["PHP_SELF"], "p.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); } -print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); +} print "\n"; $i = 0; @@ -1160,6 +1173,18 @@ while ($i < min($num, $limit)) { print ''; + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } // Project url if (!empty($arrayfields['p.ref']['checked'])) { print ''; } - print ''; if (!$i) { $totalarray['nbfield']++; } From c387f1d57a167422d7d60dfa789043fe7a6504a5 Mon Sep 17 00:00:00 2001 From: Faustin Date: Sat, 25 Jun 2022 19:01:52 +0200 Subject: [PATCH 095/367] NEW #20650 completing checkcolumn on left for task list --- htdocs/projet/tasks/list.php | 54 +++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index bfda3ad31be..25b9452518f 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -274,7 +274,7 @@ if ($search_task_user > 0) { $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields $title = $langs->trans("Activities"); @@ -708,6 +708,13 @@ print '
'; + $searchpicto = $form->showFilterButtons('left'); + print $searchpicto; + print ''; @@ -1033,14 +1040,18 @@ if (!empty($arrayfields['p.fk_statut']['checked'])) { print ''; -$searchpicto = $form->showFilterButtons(); -print $searchpicto; -print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print '
'; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->id, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print ''; @@ -1512,15 +1537,17 @@ while ($i < min($num, $limit)) { } } // Action column - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->id, $arrayofselected)) { - $selected = 1; + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->id, $arrayofselected)) { + $selected = 1; + } + print ''; } - print ''; + print '
'; +// Action column +if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; +} if (!empty($arrayfields['t.fk_task_parent']['checked'])) { print ''; } // Action column -print ''; +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; +} print ''."\n"; $totalarray = array( @@ -854,6 +863,9 @@ $totalarray = array( // Fields title label // -------------------------------------------------------------------- print ''; +if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); +} if (!empty($arrayfields['t.fk_task_parent']['checked'])) { print_liste_field_titre($arrayfields['t.fk_task_parent']['label'], $_SERVER["PHP_SELF"], "t.fk_task_parent", "", $param, "", $sortfield, $sortorder); $totalarray['nbfield']++; @@ -946,7 +958,9 @@ if (!empty($arrayfields['t.tms']['checked'])) { print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER["PHP_SELF"], "t.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); $totalarray['nbfield']++; } -print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); +} $totalarray['nbfield']++; print ''."\n"; @@ -1008,6 +1022,18 @@ while ($i < $imaxinloop) { if ($userAccess >= 0) { print ''; + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } // Ref Parent if (!empty($arrayfields['t.fk_task_parent']['checked'])) { print ''; }*/ // Action column - print ''; } - print ''; if (!$i) { $totalarray['nbfield']++; } From 3d00c065aec07bfc437100160263e52aeef75aef Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Sun, 26 Jun 2022 23:51:10 +0200 Subject: [PATCH 096/367] Missing label for excluded members --- .../interface_50_modAgenda_ActionsAuto.class.php | 12 ++++++++++++ htdocs/langs/en_US/agenda.lang | 1 + 2 files changed, 13 insertions(+) diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 0e018514353..4e926050f24 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -798,6 +798,18 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type; + $object->sendtoid = 0; + } elseif ($action == 'MEMBER_EXCLUDE') { + // Load translation files required by the page + $langs->loadLangs(array("agenda", "other", "members")); + + if (empty($object->actionmsg2)) { + $object->actionmsg2 = $langs->transnoentities("MemberExcludedInDolibarr", $object->getFullName($langs)); + } + $object->actionmsg = $langs->transnoentities("MemberExcludedInDolibarr", $object->getFullName($langs)); + $object->actionmsg .= "\n".$langs->transnoentities("Member").': '.$object->getFullName($langs); + $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type; + $object->sendtoid = 0; } elseif ($action == 'PROJECT_CREATE') { // Projects diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index 272ec22df5c..b8f9ffa857b 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -57,6 +57,7 @@ MemberValidatedInDolibarr=Member %s validated MemberModifiedInDolibarr=Member %s modified MemberResiliatedInDolibarr=Member %s terminated MemberDeletedInDolibarr=Member %s deleted +MemberExcludedInDolibarr=Member %s excluded MemberSubscriptionAddedInDolibarr=Subscription %s for member %s added MemberSubscriptionModifiedInDolibarr=Subscription %s for member %s modified MemberSubscriptionDeletedInDolibarr=Subscription %s for member %s deleted From 6053f3e5f8228ebb557c90bfa05c0f95bdf30977 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Mon, 27 Jun 2022 00:27:00 +0200 Subject: [PATCH 097/367] Internationalize invoice lines for new memberships --- htdocs/langs/en_US/paypal.lang | 1 + htdocs/public/payment/paymentok.php | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/langs/en_US/paypal.lang b/htdocs/langs/en_US/paypal.lang index beaf9a5ea3f..a935cd38434 100644 --- a/htdocs/langs/en_US/paypal.lang +++ b/htdocs/langs/en_US/paypal.lang @@ -34,3 +34,4 @@ ARollbackWasPerformedOnPostActions=A rollback was performed on all Post actions. ValidationOfPaymentFailed=Validation of payment has failed CardOwner=Card holder PayPalBalance=Paypal credit +OnlineSubscriptionPaymentLine=Online subscription recorded on %s
Paid via %s
Originating IP address: %s
Transaction ID: %s diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index c0b88736ce3..992e7ab403d 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -504,9 +504,13 @@ if ($ispaymentok) { $datesubend = dol_time_plus_duree($datesubend, -1, 'd'); } + // Set output language + $outputlangs = new Translate('', $conf); + $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); $paymentdate = $now; $amount = $FinalPaymentAmt; - $label = 'Online subscription '.dol_print_date($now, 'standard').' using '.$paymentmethod.' from '.$ipaddress.' - Transaction ID = '.$TRANSACTIONID; + $formatteddate = dol_print_date($paymentdate, 'dayhour', 'auto', $outputlangs); + $label = $langs->trans("OnlineSubscriptionPaymentLine", $formatteddate, $paymentmethod, $ipaddress, $TRANSACTIONID); // Payment informations $accountid = 0; @@ -693,9 +697,6 @@ if ($ispaymentok) { // Send subscription email include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); - // Set output language - $outputlangs = new Translate('', $conf); - $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); // Load traductions files required by page $outputlangs->loadLangs(array("main", "members")); // Get email content from template From 10aa31a376fada47228daf78021b3c3d43a00d30 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Mon, 27 Jun 2022 00:31:59 +0200 Subject: [PATCH 098/367] Let users know that the PDF invoice is enclosed --- htdocs/langs/en_US/members.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index 22060706a36..fafa1a60400 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -135,7 +135,7 @@ CardContent=Content of your member card # Text of email templates ThisIsContentOfYourMembershipRequestWasReceived=We want to let you know that your membership request was received.

ThisIsContentOfYourMembershipWasValidated=We want to let you know that your membership was validated with the following information:

-ThisIsContentOfYourSubscriptionWasRecorded=We want to let you know that your new subscription was recorded.

+ThisIsContentOfYourSubscriptionWasRecorded=We want to let you know that your new subscription was recorded. Please find your invoice here enclosed.

ThisIsContentOfSubscriptionReminderEmail=We want to let you know that your subscription is about to expire or has already expired (__MEMBER_LAST_SUBSCRIPTION_DATE_END__). We hope you will renew it.

ThisIsContentOfYourCard=This is a summary of the information we have about you. Please contact us if anything is incorrect.

DescADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT=Subject of the notification email received in case of auto-inscription of a guest From 89d1389e2d2c7c79bfd517df05a96b10b2d3b9b2 Mon Sep 17 00:00:00 2001 From: Christian Foellmann Date: Mon, 27 Jun 2022 12:46:39 +0200 Subject: [PATCH 099/367] fix page titles --- htdocs/comm/propal/card.php | 6 +++++- htdocs/comm/propal/contact.php | 3 ++- htdocs/comm/propal/document.php | 2 +- htdocs/comm/propal/info.php | 2 +- htdocs/comm/propal/list.php | 5 +++-- htdocs/comm/propal/note.php | 3 ++- htdocs/commande/card.php | 6 +++++- htdocs/commande/contact.php | 8 ++++---- htdocs/commande/document.php | 2 +- htdocs/commande/note.php | 2 +- htdocs/compta/bank/annuel.php | 9 ++++----- htdocs/compta/bank/bankentries_list.php | 2 +- htdocs/compta/bank/card.php | 11 ++++++----- htdocs/compta/bank/document.php | 3 +-- htdocs/compta/bank/graph.php | 9 ++++----- htdocs/compta/bank/releve.php | 9 ++++----- htdocs/compta/bank/treso.php | 8 +++----- htdocs/compta/bank/various_payment/card.php | 10 +++++++--- htdocs/compta/bank/various_payment/list.php | 2 +- htdocs/compta/facture/card.php | 6 ++++-- htdocs/compta/facture/contact.php | 2 +- htdocs/compta/facture/document.php | 3 +-- htdocs/compta/facture/info.php | 2 +- htdocs/compta/facture/note.php | 2 +- htdocs/contact/list.php | 14 ++++++-------- htdocs/core/lib/usergroups.lib.php | 2 +- htdocs/expedition/card.php | 6 +++++- htdocs/expedition/shipment.php | 2 +- htdocs/fourn/commande/card.php | 5 ++++- htdocs/fourn/commande/contact.php | 8 ++++---- htdocs/fourn/commande/dispatch.php | 3 ++- htdocs/fourn/commande/document.php | 2 +- htdocs/fourn/commande/info.php | 2 +- htdocs/fourn/commande/note.php | 2 +- htdocs/fourn/facture/card.php | 7 +++++-- htdocs/fourn/facture/contact.php | 9 ++++----- htdocs/fourn/facture/document.php | 2 +- htdocs/fourn/facture/info.php | 11 ++++------- htdocs/fourn/facture/note.php | 2 +- htdocs/langs/en_US/suppliers.lang | 1 + htdocs/product/card.php | 17 +++++++++++++---- htdocs/product/list.php | 10 ++++------ htdocs/product/stock/card.php | 7 ++++++- htdocs/product/stock/movement_list.php | 17 +++++++++++------ htdocs/projet/card.php | 1 + htdocs/projet/document.php | 2 +- htdocs/projet/info.php | 4 ++-- htdocs/projet/note.php | 2 +- htdocs/projet/tasks.php | 5 ++++- htdocs/projet/tasks/contact.php | 13 +++++++++---- htdocs/projet/tasks/document.php | 9 +++++++-- htdocs/projet/tasks/note.php | 11 ++++++++--- htdocs/projet/tasks/task.php | 14 ++++++++++---- htdocs/projet/tasks/time.php | 15 ++++++++++----- htdocs/societe/card.php | 4 +++- htdocs/societe/list.php | 2 +- htdocs/societe/paymentmodes.php | 2 +- htdocs/supplier_proposal/card.php | 7 +++++-- htdocs/supplier_proposal/contact.php | 8 ++++---- htdocs/supplier_proposal/document.php | 2 +- htdocs/supplier_proposal/info.php | 11 ++++------- htdocs/supplier_proposal/list.php | 6 ++++-- htdocs/supplier_proposal/note.php | 8 ++++---- htdocs/user/agenda_extsites.php | 6 +++++- htdocs/user/bank.php | 5 ++++- htdocs/user/card.php | 10 +++++++++- htdocs/user/clicktodial.php | 8 ++++---- htdocs/user/document.php | 6 +++++- htdocs/user/group/card.php | 7 ++++++- htdocs/user/group/ldap.php | 4 +++- htdocs/user/group/list.php | 4 ++-- htdocs/user/group/perms.php | 4 +++- htdocs/user/home.php | 5 +++-- htdocs/user/info.php | 5 ++++- htdocs/user/ldap.php | 5 ++++- htdocs/user/list.php | 4 ++-- htdocs/user/note.php | 8 +++++--- htdocs/user/param_ihm.php | 5 ++++- htdocs/user/perms.php | 5 ++++- 79 files changed, 287 insertions(+), 176 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index c56f1840ab7..5ea0636cc16 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1463,8 +1463,12 @@ if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } -$title = $langs->trans('Proposal')." - ".$langs->trans('Card'); +$title = $object->ref." - ".$langs->trans('Card'); +if ($action == 'create') { + $title = $langs->trans("NewPropal"); +} $help_url = 'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos|DE:Modul_Angebote'; + llxHeader('', $title, $help_url); $now = dol_now(); diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index fedf6a6233d..ceb25175596 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -118,8 +118,9 @@ elseif ($action == 'setaddress' && $user->rights->propale->creer) /* * View */ -$title = $langs->trans('Proposal')." - ".$langs->trans('ContactsAddresses'); +$title = $object->ref." - ".$langs->trans('ContactsAddresses'); $help_url = "EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos"; + llxHeader('', $title, $help_url); $form = new Form($db); diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index 804fedd623b..b6fbb97cdf7 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -104,7 +104,7 @@ if ($object->id > 0) { /* * View */ -$title = $langs->trans('Proposal')." - ".$langs->trans('Documents'); +$title = $object->ref." - ".$langs->trans('Documents'); $help_url = 'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'; llxHeader('', $title, $help_url); diff --git a/htdocs/comm/propal/info.php b/htdocs/comm/propal/info.php index dc43af9ceff..1782e39e2d2 100644 --- a/htdocs/comm/propal/info.php +++ b/htdocs/comm/propal/info.php @@ -59,7 +59,7 @@ restrictedArea($user, 'propal', $object->id); $form = new Form($db); -$title = $langs->trans('Proposal')." - ".$langs->trans('Info'); +$title = $object->ref." - ".$langs->trans('Info'); $help_url = 'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'; llxHeader('', $title, $help_url); diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index e0eb8a23e3e..38ad80d964f 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -491,8 +491,9 @@ $companystatic = new Societe($db); $projectstatic = new Project($db); $formcompany = new FormCompany($db); +$title = $langs->trans('ListOfProposals'); $help_url = 'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'; -//llxHeader('',$langs->trans('Proposal'),$help_url); +llxHeader('', $title, $help_url); $sql = 'SELECT'; if ($sall || $search_product_category > 0 || $search_user > 0) { @@ -750,7 +751,7 @@ if ($resql) { exit; } - llxHeader('', $langs->trans('Proposal'), $help_url); +// llxHeader('', $langs->trans('Proposal'), $help_url); $param = '&search_status='.urlencode($search_status); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php index 13fa42edb29..6aba2973975 100644 --- a/htdocs/comm/propal/note.php +++ b/htdocs/comm/propal/note.php @@ -81,8 +81,9 @@ if (empty($reshook)) { $form = new Form($db); -$title = $langs->trans('Proposal')." - ".$langs->trans('Notes'); +$title = $object->ref." - ".$langs->trans('Notes'); $help_url = 'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'; + llxHeader('', $title, $help_url); if ($object->id > 0) { diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 20bc5462d5e..401622957c7 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1428,8 +1428,12 @@ if (empty($reshook)) { * View */ -$title = $langs->trans('Order')." - ".$langs->trans('Card'); +$title = $object->ref." - ".$langs->trans('Card'); +if ($action == 'create') { + $title = $langs->trans("NewOrder"); +} $help_url = 'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes|DE:Modul_Kundenaufträge'; + llxHeader('', $title, $help_url); $form = new Form($db); diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php index a4d857a47fd..b3b1319fa76 100644 --- a/htdocs/commande/contact.php +++ b/htdocs/commande/contact.php @@ -103,10 +103,6 @@ elseif ($action == 'setaddress' && $user->rights->commande->creer) /* * View */ -$title = $langs->trans('Order')." - ".$langs->trans('ContactsAddresses'); -$help_url = 'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes|DE:Modul_Kundenaufträge'; -llxHeader('', $title, $help_url); - $form = new Form($db); $formcompany = new FormCompany($db); $formother = new FormOther($db); @@ -124,6 +120,10 @@ if ($id > 0 || !empty($ref)) { if ($object->fetch($id, $ref) > 0) { $object->fetch_thirdparty(); + $title = $object->ref." - ".$langs->trans('ContactsAddresses'); + $help_url = 'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes|DE:Modul_Kundenaufträge'; + llxHeader('', $title, $help_url); + $head = commande_prepare_head($object); print dol_get_fiche_head($head, 'contact', $langs->trans("CustomerOrder"), -1, 'order'); diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php index 684d8e61334..0e96c21db97 100644 --- a/htdocs/commande/document.php +++ b/htdocs/commande/document.php @@ -96,7 +96,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; /* * View */ -$title = $langs->trans('Order')." - ".$langs->trans('Documents'); +$title = $object->ref." - ".$langs->trans('Documents'); $help_url = 'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes|DE:Modul_Kundenaufträge'; llxHeader('', $title, $help_url); diff --git a/htdocs/commande/note.php b/htdocs/commande/note.php index 55140c30ae2..961aec01fa4 100644 --- a/htdocs/commande/note.php +++ b/htdocs/commande/note.php @@ -77,7 +77,7 @@ if (empty($reshook)) { /* * View */ -$title = $langs->trans('Order')." - ".$langs->trans('Notes'); +$title = $object->ref." - ".$langs->trans('Notes'); $help_url = 'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes|DE:Modul_Kundenaufträge'; llxHeader('', $title, $help_url); diff --git a/htdocs/compta/bank/annuel.php b/htdocs/compta/bank/annuel.php index 36a9d17315a..e1d0f7b8382 100644 --- a/htdocs/compta/bank/annuel.php +++ b/htdocs/compta/bank/annuel.php @@ -60,11 +60,6 @@ if (!$year_start) { /* * View */ - -$title = $langs->trans("FinancialAccount").' - '.$langs->trans("IOMonthlyReporting"); -$helpurl = ""; -llxHeader('', $title, $helpurl); - $form = new Form($db); // Get account informations @@ -78,6 +73,10 @@ if (!empty($ref)) { $id = $object->id; } +$title = $object->ref.' - '.$langs->trans("IOMonthlyReporting"); +$helpurl = ""; +llxHeader('', $title, $helpurl); + // Ce rapport de tresorerie est base sur llx_bank (car doit inclure les transactions sans facture) // plutot que sur llx_paiement + llx_paiementfourn diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 421080951f2..5c4d7824a82 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -506,7 +506,7 @@ $buttonreconcile = ''; $morehtmlref = ''; if ($id > 0 || !empty($ref)) { - $title = $langs->trans("FinancialAccount").' - '.$langs->trans("Transactions"); + $title = $object->ref.' - '.$langs->trans("Transactions"); $helpurl = ""; llxHeader('', $title, $helpurl); diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 5c91a9f504d..cbf7b75a3b3 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -329,18 +329,16 @@ if (!empty($conf->accounting->enabled)) { $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; -$title = $langs->trans("FinancialAccount")." - ".$langs->trans("Card"); - $help_url = 'EN:Module_Banks_and_Cash|FR:Module_Banques_et_Caisses|ES:Módulo_Bancos_y_Cajas|DE:Modul_Banken_und_Barbestände'; -llxHeader("", $title, $help_url); - - // Creation if ($action == 'create') { $object = new Account($db); + $title = $langs->trans("NewFinancialAccount"); + llxHeader("", $title, $help_url); + print load_fiche_titre($langs->trans("NewFinancialAccount"), '', 'bank_account'); if ($conf->use_javascript_ajax) { @@ -605,6 +603,9 @@ if ($action == 'create') { $_GET["id"] = $object->id; } + $title = $object->ref." - ".$langs->trans("Card"); + llxHeader("", $title, $help_url); + // Show tabs $head = bank_prepare_head($object); print dol_get_fiche_head($head, 'bankname', $langs->trans("FinancialAccount"), -1, 'account'); diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php index 78d45beadf3..91f514948a6 100644 --- a/htdocs/compta/bank/document.php +++ b/htdocs/compta/bank/document.php @@ -93,8 +93,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; * View */ -$title = $langs->trans("FinancialAccount").' - '.$langs->trans("Documents"); - +$title = $object->ref.' - '.$langs->trans("Documents"); $help_url = "EN:Module_Banks_and_Cash|FR:Module_Banques_et_Caisses"; llxHeader("", $title, $help_url); diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php index 4c0efec57d2..119266b7901 100644 --- a/htdocs/compta/bank/graph.php +++ b/htdocs/compta/bank/graph.php @@ -55,11 +55,6 @@ $error = 0; /* * View */ - -$title = $langs->trans("FinancialAccount").' - '.$langs->trans("Graph"); -$helpurl = ""; -llxHeader('', $title, $helpurl); - $form = new Form($db); $datetime = dol_now(); @@ -83,6 +78,10 @@ if (GETPOST("ref")) { $account = $object->id; } +$title = $object->ref.' - '.$langs->trans("Graph"); +$helpurl = ""; +llxHeader('', $title, $helpurl); + $result = dol_mkdir($conf->bank->dir_temp); if ($result < 0) { $langs->load("errors"); diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 2385f2210a5..624830dfb1d 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -194,11 +194,6 @@ if ($action == 'confirm_editbankreceipt' && !empty($oldbankreceipt) && !empty($n /* * View */ - -$title = $langs->trans("FinancialAccount").' - '.$langs->trans("AccountStatements"); -$helpurl = ""; -llxHeader('', $title, $helpurl); - $form = new Form($db); $societestatic = new Societe($db); $chargestatic = new ChargeSociales($db); @@ -250,6 +245,10 @@ if (empty($numref)) { $numrows = $db->num_rows($result); $i = 0; + $title = $object->ref.' - '.$langs->trans("AccountStatements"); + $helpurl = ""; + llxHeader('', $title, $helpurl); + // Onglets $head = bank_prepare_head($object); print dol_get_fiche_head($head, 'statement', $langs->trans("FinancialAccount"), 0, 'account'); diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index 98a51947c0e..94711d1cfe9 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -57,11 +57,6 @@ $hookmanager->initHooks(array('banktreso', 'globalcard')); /* * View */ - -$title = $langs->trans("FinancialAccount").' - '.$langs->trans("PlannedTransactions"); -$helpurl = ""; -llxHeader('', $title, $helpurl); - $societestatic = new Societe($db); $facturestatic = new Facture($db); $facturefournstatic = new FactureFournisseur($db); @@ -85,6 +80,9 @@ if (GETPOST("account") || GETPOST("ref")) { $_GET["account"] = $object->id; } + $title = $object->ref.' - '.$langs->trans("PlannedTransactions"); + $helpurl = ""; + llxHeader('', $title, $helpurl); // Onglets $head = bank_prepare_head($object); diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index ab4b24e3889..254507db375 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -304,9 +304,6 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->banque->m /* * View */ - -llxHeader("", $langs->trans("VariousPayment")); - $form = new Form($db); if (!empty($conf->accounting->enabled)) { $formaccounting = new FormAccounting($db); @@ -324,6 +321,13 @@ if ($id) { } } +$title = $object->ref." - ".$langs->trans('Card'); +if ($action == 'create') { + $title = $langs->trans("NewVariousPayment"); +} +$help_url = 'EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores|DE:Modul_Lieferantenrechnungen'; +llxHeader('', $title, $help_url); + $options = array(); // Load bank groups diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index bbec4f23fc6..7831a1b7ba0 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -290,7 +290,7 @@ if ($result) { } // must be place behind the last "header(...)" call - llxHeader(); + llxHeader('', $langs->trans("VariousPayments")); $i = 0; $total = 0; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index b31d65fdcaf..8e68945739c 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2840,8 +2840,10 @@ if (!empty($conf->projet->enabled)) { $now = dol_now(); -$title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('Card'); - +$title = $object->ref." - ".$langs->trans('Card'); +if ($action == 'create') { + $title = $langs->trans("NewBill"); +} $help_url = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; llxHeader('', $title, $help_url); diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index 43897172779..35e49518231 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -100,7 +100,7 @@ if ($action == 'addcontact' && $user->rights->facture->creer) { * View */ -$title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('ContactsAddresses'); +$title = $object->ref." - ".$langs->trans('ContactsAddresses'); $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; llxHeader('', $title, $helpurl); diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index 6eb05a16922..aa781610a70 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -100,8 +100,7 @@ if (empty($object->id)) { exit; } -$title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('Documents'); - +$title = $object->ref." - ".$langs->trans('Documents'); $help_url = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; llxHeader('', $title, $help_url); diff --git a/htdocs/compta/facture/info.php b/htdocs/compta/facture/info.php index 60efaf36e3d..1c462d60ef2 100644 --- a/htdocs/compta/facture/info.php +++ b/htdocs/compta/facture/info.php @@ -65,7 +65,7 @@ $result = restrictedArea($user, 'facture', $object->id, '', '', 'fk_soc', $field $form = new Form($db); -$title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('Info'); +$title = $object->ref." - ".$langs->trans('Info'); $help_url = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; llxHeader('', $title, $help_url); diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php index 6f699774d32..199ffce653d 100644 --- a/htdocs/compta/facture/note.php +++ b/htdocs/compta/facture/note.php @@ -85,7 +85,7 @@ if (empty($object->id)) { exit; } -$title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('Notes'); +$title = $object->ref." - ".$langs->trans('Notes'); $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; llxHeader('', $title, $helpurl); diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 66561730829..95c298f7244 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -132,31 +132,31 @@ if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('b } $offset = $limit * $page; -$titre = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ListOfContacts") : $langs->trans("ListOfContactsAddresses")); +$title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ListOfContacts") : $langs->trans("ListOfContactsAddresses")); if ($type == "p") { if (empty($contextpage) || $contextpage == 'contactlist') { $contextpage = 'contactprospectlist'; } - $titre .= ' ('.$langs->trans("ThirdPartyProspects").')'; + $title .= ' ('.$langs->trans("ThirdPartyProspects").')'; $urlfiche = "card.php"; } if ($type == "c") { if (empty($contextpage) || $contextpage == 'contactlist') { $contextpage = 'contactcustomerlist'; } - $titre .= ' ('.$langs->trans("ThirdPartyCustomers").')'; + $title .= ' ('.$langs->trans("ThirdPartyCustomers").')'; $urlfiche = "card.php"; } elseif ($type == "f") { if (empty($contextpage) || $contextpage == 'contactlist') { $contextpage = 'contactsupplierlist'; } - $titre .= ' ('.$langs->trans("ThirdPartySuppliers").')'; + $title .= ' ('.$langs->trans("ThirdPartySuppliers").')'; $urlfiche = "card.php"; } elseif ($type == "o") { if (empty($contextpage) || $contextpage == 'contactlist') { $contextpage = 'contactotherlist'; } - $titre .= ' ('.$langs->trans("OthersNotLinkedToThirdParty").')'; + $title .= ' ('.$langs->trans("OthersNotLinkedToThirdParty").')'; $urlfiche = ""; } @@ -345,8 +345,6 @@ if (!empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES) $contactstatic->loadCacheOfProspStatus(); } -$title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); - // Select every potentiels, and note each potentiels which fit in search parameters $tab_level = array(); $sql = "SELECT code, label, sortorder"; @@ -709,7 +707,7 @@ print ''; print ''; print ''; -print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'address', 0, $newcardbutton, '', $limit, 0, 0, 1); +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'address', 0, $newcardbutton, '', $limit, 0, 0, 1); $topicmail = "Information"; $modelmail = "contact"; diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index accbd84ba8c..b4cac4a82a0 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -211,7 +211,7 @@ function group_prepare_head($object) $head = array(); $head[$h][0] = DOL_URL_ROOT.'/user/group/card.php?id='.$object->id; - $head[$h][1] = $langs->trans("GroupCard"); + $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'group'; $h++; diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 03595b022a5..89678ad95dc 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -803,9 +803,13 @@ if (empty($reshook)) { * View */ +$title = $langs->trans("Shipment"); +if ($action == 'create2') { + $title = $langs->trans("CreateShipment"); +} $help_url = 'EN:Module_Shipments|FR:Module_Expéditions|ES:Módulo_Expediciones|DE:Modul_Lieferungen'; -llxHeader('', $langs->trans('Shipment'), 'Expedition', $help_url); +llxHeader('', $title, 'Expedition', $help_url); if (empty($action)) { $action = 'view'; diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index bfa48e9aa0f..cea7c59fdc6 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -232,7 +232,7 @@ if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } -$title = $langs->trans('Order')." - ".$langs->trans('Shipments'); +$title = $object->ref." - ".$langs->trans('Shipments'); $help_url = 'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes|DE:Modul_Kundenaufträge'; llxHeader('', $title, $help_url); diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 35e5257fce0..f1e02f203e7 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1529,7 +1529,10 @@ if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } -$title = $langs->trans('SupplierOrder')." - ".$langs->trans('Card'); +$title = $object->ref." - ".$langs->trans('Card'); +if ($action == 'create') { + $title = $langs->trans("NewOrderSupplier"); +} $help_url = 'EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores'; llxHeader('', $title, $help_url); diff --git a/htdocs/fourn/commande/contact.php b/htdocs/fourn/commande/contact.php index e521caf1080..d3477503e4e 100644 --- a/htdocs/fourn/commande/contact.php +++ b/htdocs/fourn/commande/contact.php @@ -99,10 +99,6 @@ if ($action == 'addcontact' && ($user->rights->fournisseur->commande->creer || $ /* * View */ -$title = $langs->trans('SupplierOrder')." - ".$langs->trans('ContactsAddresses'); -$help_url = 'EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores'; -llxHeader('', $title, $help_url); - $form = new Form($db); $formcompany = new FormCompany($db); $contactstatic = new Contact($db); @@ -121,6 +117,10 @@ if ($id > 0 || !empty($ref)) { if ($object->fetch($id, $ref) > 0) { $object->fetch_thirdparty(); + $title = $object->ref." - ".$langs->trans('ContactsAddresses'); + $help_url = 'EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores'; + llxHeader('', $title, $help_url); + $head = ordersupplier_prepare_head($object); print dol_get_fiche_head($head, 'contact', $langs->trans("SupplierOrder"), -1, 'order'); diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index a1ddef959a0..52f4c37d8a1 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -505,10 +505,11 @@ $formproduct = new FormProduct($db); $warehouse_static = new Entrepot($db); $supplierorderdispatch = new CommandeFournisseurDispatch($db); +$title = $object->ref." - ".$langs->trans('OrderDispatch'); $help_url = 'EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores'; $morejs = array('/fourn/js/lib_dispatch.js.php'); -llxHeader('', $langs->trans("OrderDispatch"), $help_url, '', 0, 0, $morejs); +llxHeader('', $title, $help_url, '', 0, 0, $morejs); if ($id > 0 || !empty($ref)) { $soc = new Societe($db); diff --git a/htdocs/fourn/commande/document.php b/htdocs/fourn/commande/document.php index d54d5553efb..64e4d1c8b24 100644 --- a/htdocs/fourn/commande/document.php +++ b/htdocs/fourn/commande/document.php @@ -98,7 +98,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; $form = new Form($db); -$title = $langs->trans('SupplierOrder')." - ".$langs->trans('Documents'); +$title = $object->ref." - ".$langs->trans('Documents'); $help_url = 'EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores'; llxHeader('', $title, $help_url); diff --git a/htdocs/fourn/commande/info.php b/htdocs/fourn/commande/info.php index 6c64672ee84..dfa5d10a2f6 100644 --- a/htdocs/fourn/commande/info.php +++ b/htdocs/fourn/commande/info.php @@ -113,7 +113,7 @@ if ($id > 0 || !empty($ref)) { $object->info($object->id); } -$title = $langs->trans("SupplierOrder").' - '.$langs->trans('Info').' - '.$object->ref.' '.$object->name; +$title = $object->ref.' - '.$langs->trans('Info').' - '.$object->ref.' '.$object->name; if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { $title = $object->ref.' '.$object->name.' - '.$langs->trans("Info"); } diff --git a/htdocs/fourn/commande/note.php b/htdocs/fourn/commande/note.php index 1c67c03d727..d32ee8e0641 100644 --- a/htdocs/fourn/commande/note.php +++ b/htdocs/fourn/commande/note.php @@ -69,7 +69,7 @@ if (empty($reshook)) { /* * View */ -$title = $langs->trans('SupplierOrder')." - ".$langs->trans('Notes'); +$title = $object->ref." - ".$langs->trans('Notes'); $help_url = 'EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores'; llxHeader('', $title, $help_url); diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 71c7a4beaf5..654fcce3f60 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1831,7 +1831,10 @@ if (!empty($conf->projet->enabled)) { $now = dol_now(); -$title = $langs->trans('SupplierInvoice')." - ".$langs->trans('Card'); +$title = $object->ref." - ".$langs->trans('Card'); +if ($action == 'create') { + $title = $langs->trans("NewSupplierInvoice"); +} $help_url = 'EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores|DE:Modul_Lieferantenrechnungen'; llxHeader('', $title, $help_url); @@ -1839,7 +1842,7 @@ llxHeader('', $title, $help_url); if ($action == 'create') { $facturestatic = new FactureFournisseur($db); - print load_fiche_titre($langs->trans('NewBill'), '', 'supplier_invoice'); + print load_fiche_titre($langs->trans('NewSupplierInvoice'), '', 'supplier_invoice'); dol_htmloutput_events(); diff --git a/htdocs/fourn/facture/contact.php b/htdocs/fourn/facture/contact.php index 927cc5f36b9..a3b4fba9502 100644 --- a/htdocs/fourn/facture/contact.php +++ b/htdocs/fourn/facture/contact.php @@ -98,11 +98,6 @@ if ($action == 'addcontact' && ($user->rights->fournisseur->facture->creer || $u /* * View */ - -$title = $langs->trans('SupplierInvoice')." - ".$langs->trans('ContactsAddresses'); -$helpurl = "EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores"; -llxHeader('', $title, $helpurl); - $form = new Form($db); $formcompany = new FormCompany($db); $contactstatic = new Contact($db); @@ -121,6 +116,10 @@ if ($id > 0 || !empty($ref)) { $alreadypaid = $object->getSommePaiement(); + $title = $object->ref." - ".$langs->trans('ContactsAddresses'); + $helpurl = "EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores"; + llxHeader('', $title, $helpurl); + $head = facturefourn_prepare_head($object); print dol_get_fiche_head($head, 'contact', $langs->trans('SupplierInvoice'), -1, 'supplier_invoice'); diff --git a/htdocs/fourn/facture/document.php b/htdocs/fourn/facture/document.php index 34255541c01..959a1d4020c 100644 --- a/htdocs/fourn/facture/document.php +++ b/htdocs/fourn/facture/document.php @@ -93,7 +93,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; $form = new Form($db); -$title = $langs->trans('SupplierInvoice')." - ".$langs->trans('Documents'); +$title = $object->ref." - ".$langs->trans('Documents'); $helpurl = "EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores"; llxHeader('', $title, $helpurl); diff --git a/htdocs/fourn/facture/info.php b/htdocs/fourn/facture/info.php index f17d3c3e127..e9c4d2ea0fa 100644 --- a/htdocs/fourn/facture/info.php +++ b/htdocs/fourn/facture/info.php @@ -53,18 +53,15 @@ $object = new FactureFournisseur($db); */ $form = new Form($db); - -$title = $langs->trans('SupplierInvoice')." - ".$langs->trans('Info'); -$helpurl = "EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores"; -llxHeader('', $title, $helpurl); - $object->fetch($id, $ref); $object->fetch_thirdparty(); - $object->info($object->id); - $alreadypaid = $object->getSommePaiement(); +$title = $object->ref." - ".$langs->trans('Info'); +$helpurl = "EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores"; +llxHeader('', $title, $helpurl); + $head = facturefourn_prepare_head($object); $titre = $langs->trans('SupplierInvoice'); print dol_get_fiche_head($head, 'info', $langs->trans('SupplierInvoice'), -1, 'supplier_invoice'); diff --git a/htdocs/fourn/facture/note.php b/htdocs/fourn/facture/note.php index d59aefe7831..97f4d4562b3 100644 --- a/htdocs/fourn/facture/note.php +++ b/htdocs/fourn/facture/note.php @@ -83,7 +83,7 @@ if ($action == 'setlabel' && ($user->rights->fournisseur->facture->creer || $use $form = new Form($db); -$title = $langs->trans('SupplierInvoice')." - ".$langs->trans('Notes'); +$title = $object->ref." - ".$langs->trans('Notes'); $helpurl = "EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores"; llxHeader('', $title, $helpurl); diff --git a/htdocs/langs/en_US/suppliers.lang b/htdocs/langs/en_US/suppliers.lang index ca9ee174d29..cd75cfba57e 100644 --- a/htdocs/langs/en_US/suppliers.lang +++ b/htdocs/langs/en_US/suppliers.lang @@ -4,6 +4,7 @@ SuppliersInvoice=Vendor invoice SupplierInvoices=Vendor invoices ShowSupplierInvoice=Show Vendor Invoice NewSupplier=New vendor +NewSupplierInvoice = New vendor invoice History=History ListOfSuppliers=List of vendors ShowSupplier=Show vendor diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 49c70b05641..292d1a59abe 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1022,15 +1022,24 @@ if (!empty($conf->accounting->enabled)) { $title = $langs->trans('ProductServiceCard'); + $help_url = ''; $shortlabel = dol_trunc($object->label, 16); if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { - $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Card'); - $help_url = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos|DE:Modul_Produkte'; + if ($action == 'create') { + $title = $langs->trans("NewProduct"); + } else { + $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Card'); + $help_url = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos|DE:Modul_Produkte'; + } } if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { - $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Card'); - $help_url = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios|DE:Modul_Leistungen'; + if ($action == 'create') { + $title = $langs->trans("NewService"); + } else { + $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Card'); + $help_url = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios|DE:Modul_Leistungen'; + } } llxHeader('', $title, $help_url); diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 942a76585cc..0315922ca28 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -381,16 +381,14 @@ if (empty($reshook)) { * View */ -$title = $langs->trans("ProductsAndServices"); +$title = $langs->trans("ListOfProductsAndServices"); if ($search_type != '' && $search_type != '-1') { if ($search_type == 1) { - $texte = $langs->trans("Services"); + $title = $langs->trans("ListOfServices"); } else { - $texte = $langs->trans("Products"); + $title = $langs->trans("ListOfProducts"); } -} else { - $texte = $langs->trans("ProductsAndServices"); } $sql = 'SELECT DISTINCT p.rowid, p.ref, p.label, p.fk_product_type, p.barcode, p.price, p.tva_tx, p.price_ttc, p.price_base_type, p.entity,'; @@ -783,7 +781,7 @@ if ($resql) { $picto = 'service'; } - print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $picto, 0, $newcardbutton, '', $limit, 0, 0, 1); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $picto, 0, $newcardbutton, '', $limit, 0, 0, 1); $topicmail = "Information"; $modelmail = "product"; diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 8389d63e843..de58f033737 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -279,8 +279,13 @@ if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } +$title = $langs->trans("WarehouseCard"); +if ($action == 'create') { + $title = $langs->trans("NewWarehouse"); +} + $help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; -llxHeader("", $langs->trans("WarehouseCard"), $help_url); +llxHeader("", $title, $help_url); if ($action == 'create') { diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index f5d74c47c8e..6462115182d 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -630,14 +630,19 @@ $arrayofselected = is_array($toselect) ? $toselect : array(); $i = 0; $help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; if ($msid) { - $texte = $langs->trans('StockMovementForId', $msid); + $title = $langs->trans('StockMovementForId', $msid); } else { - $texte = $langs->trans("ListOfStockMovements"); + $title = $langs->trans("ListOfStockMovements"); if ($id) { - $texte .= ' ('.$langs->trans("ForThisWarehouse").')'; + if (!empty($object->ref)) { + $title .= ' ('.$object->ref.')'; + } else { + $title .= ' ('.$langs->trans("ForThisWarehouse").')'; + } + } } -llxHeader("", $texte, $help_url); +llxHeader("", $title, $help_url); /* * Show tab only if we ask a particular warehouse @@ -897,9 +902,9 @@ if ($id > 0) { } if ($id > 0) { - print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'movement', 0, '', '', $limit, 0, 0, 1); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'movement', 0, '', '', $limit, 0, 0, 1); } else { - print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'movement', 0, '', '', $limit, 0, 0, 1); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'movement', 0, '', '', $limit, 0, 0, 1); } // Add code for pre mass action (confirmation or email presend form) diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index da45abb6168..0e8b5fd4380 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -477,6 +477,7 @@ $title = $langs->trans("Project").' - '.$object->ref.(!empty($object->thirdparty if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE)) { $title = $object->ref.(!empty($object->thirdparty->name) ? ' - '.$object->thirdparty->name : '').(!empty($object->title) ? ' - '.$object->title : ''); } + $help_url = "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos|DE:Modul_Projekte"; llxHeader("", $title, $help_url); diff --git a/htdocs/projet/document.php b/htdocs/projet/document.php index 9e8d3a6ce8e..2b5f38dbf02 100644 --- a/htdocs/projet/document.php +++ b/htdocs/projet/document.php @@ -96,7 +96,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; * View */ -$title = $langs->trans('Project').' - '.$langs->trans('Document').' - '.$object->ref.' '.$object->name; +$title = $langs->trans('Documents').' - '.$object->ref.' '.$object->name; if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { $title = $object->ref.' '.$object->name.' - '.$langs->trans('Document'); } diff --git a/htdocs/projet/info.php b/htdocs/projet/info.php index c0afe5d1370..7b8d9528cc3 100644 --- a/htdocs/projet/info.php +++ b/htdocs/projet/info.php @@ -107,8 +107,8 @@ if ($id > 0 || !empty($ref)) { } $object->info($object->id); } - -$title = $langs->trans("Project").' - '.$object->ref.' '.$object->name; +$agenda = (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) ? '/'.$langs->trans("Agenda") : ''; +$title = $langs->trans('Events').$agenda.' - '.$object->ref.' '.$object->name; if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { $title = $object->ref.' '.$object->name.' - '.$langs->trans("Info"); } diff --git a/htdocs/projet/note.php b/htdocs/projet/note.php index 2ee52d3a247..3eed5e14c60 100644 --- a/htdocs/projet/note.php +++ b/htdocs/projet/note.php @@ -69,7 +69,7 @@ if (empty($reshook)) { * View */ -$title = $langs->trans("Project").' - '.$langs->trans("Note").' - '.$object->ref.' '.$object->name; +$title = $langs->trans("Notes").' - '.$object->ref.' '.$object->name; if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { $title = $object->ref.' '.$object->name.' - '.$langs->trans("Note"); } diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 64d134a7254..49943b79434 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -404,10 +404,13 @@ $projectstatic = new Project($db); $taskstatic = new Task($db); $userstatic = new User($db); -$title = $langs->trans("Project").' - '.$langs->trans("Tasks").' - '.$object->ref.' '.$object->name; +$title = $langs->trans("Tasks").' - '.$object->ref.' '.$object->name; if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { $title = $object->ref.' '.$object->name.' - '.$langs->trans("Tasks"); } +if ($action == 'create') { + $title = $langs->trans("NewTask"); +} $help_url = "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; llxHeader("", $title, $help_url); diff --git a/htdocs/projet/tasks/contact.php b/htdocs/projet/tasks/contact.php index 0b26161c28c..962c9853360 100644 --- a/htdocs/projet/tasks/contact.php +++ b/htdocs/projet/tasks/contact.php @@ -140,13 +140,19 @@ if (!empty($project_ref) && !empty($withproject)) { /* * View */ - -llxHeader('', $langs->trans("Task")); - $form = new Form($db); $formcompany = new FormCompany($db); $contactstatic = new Contact($db); $userstatic = new User($db); +$result = $projectstatic->fetch($object->fk_project); + +$title = $object->ref . ' - ' . $langs->trans("Contacts"); +if (!empty($withproject)) { + $title .= ' | ' . $langs->trans("Project") . (!empty($projectstatic->ref) ? ': '.$projectstatic->ref : '') ; +} +$help_url = ''; + +llxHeader('', $title, $help_url); /* *************************************************************************** */ @@ -162,7 +168,6 @@ if ($id > 0 || !empty($ref)) { } $id = $object->id; // So when doing a search from ref, id is also set correctly. - $result = $projectstatic->fetch($object->fk_project); if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) { $projectstatic->fetchComments(); } diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php index c57610d0130..77d52fd547f 100644 --- a/htdocs/projet/tasks/document.php +++ b/htdocs/projet/tasks/document.php @@ -119,10 +119,15 @@ include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; /* * View */ - $form = new Form($db); -llxHeader('', $langs->trans('Task')); +$title = $object->ref . ' - ' . $langs->trans("Documents"); +if (!empty($withproject)) { + $title .= ' | ' . $langs->trans("Project") . (!empty($projectstatic->ref) ? ': '.$projectstatic->ref : '') ; +} +$help_url = ''; + +llxHeader('', $title, $help_url); if ($object->id > 0) { $projectstatic->fetch_thirdparty(); diff --git a/htdocs/projet/tasks/note.php b/htdocs/projet/tasks/note.php index 3d1ec610b48..ad6a7c6d03c 100644 --- a/htdocs/projet/tasks/note.php +++ b/htdocs/projet/tasks/note.php @@ -110,14 +110,19 @@ if (empty($reshook)) { /* * View */ - -llxHeader('', $langs->trans("Task")); - $form = new Form($db); $userstatic = new User($db); $now = dol_now(); +$title = $object->ref . ' - ' . $langs->trans("Notes"); +if (!empty($withproject)) { + $title .= ' | ' . $langs->trans("Project") . (!empty($projectstatic->ref) ? ': '.$projectstatic->ref : '') ; +} +$help_url = ''; + +llxHeader('', $title, $help_url); + if ($object->id > 0) { $userWrite = $projectstatic->restrictedProjectArea($user, 'write'); diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index f163af75cae..20cb27eb002 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -191,12 +191,18 @@ if ($action == 'remove_file' && $user->rights->projet->creer) { /* * View */ - -llxHeader('', $langs->trans("Task")); - $form = new Form($db); $formother = new FormOther($db); $formfile = new FormFile($db); +$result = $projectstatic->fetch($object->fk_project); + +$title = $object->ref; +if (!empty($withproject)) { + $title .= ' | ' . $langs->trans("Project") . (!empty($projectstatic->ref) ? ': '.$projectstatic->ref : '') ; +} +$help_url = ''; + +llxHeader('', $title, $help_url); if ($id > 0 || !empty($ref)) { $res = $object->fetch_optionals(); @@ -204,7 +210,7 @@ if ($id > 0 || !empty($ref)) { $object->fetchComments(); } - $result = $projectstatic->fetch($object->fk_project); + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) { $projectstatic->fetchComments(); } diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index ef8ac6aa9df..ef7f98107db 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -699,15 +699,20 @@ if ($action == 'confirm_generateinter') { /* * View */ - -$arrayofselected = is_array($toselect) ? $toselect : array(); - -llxHeader("", $langs->trans("Task")); - $form = new Form($db); $formother = new FormOther($db); $formproject = new FormProjets($db); $userstatic = new User($db); +//$result = $projectstatic->fetch($object->fk_project); +$arrayofselected = is_array($toselect) ? $toselect : array(); + +$title = $object->ref . ' - ' . $langs->trans("TimeSpent"); +if (!empty($withproject)) { + $title .= ' | ' . $langs->trans("Project") . (!empty($projectstatic->ref) ? ': '.$projectstatic->ref : '') ; +} +$help_url = ''; + +llxHeader('', $title, $help_url); if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser > 0) { /* diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 3ef501aeac6..8edf9567c79 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -943,10 +943,12 @@ if ($socid > 0 && empty($object->id)) { } $title = $langs->trans("ThirdParty"); +if ($action == 'create') { + $title = $langs->trans("NewThirdParty"); +} if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { $title = $object->name." - ".$langs->trans('Card'); } - $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas|DE:Modul_Geschäftspartner'; llxHeader('', $title, $help_url); diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 80b0142a572..a7e6d836218 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -721,7 +721,7 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ( } $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; -llxHeader('', $langs->trans("ThirdParty"), $help_url); +llxHeader('', $title, $help_url); $param = ''; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index dedb1ad445d..2d2e9c16ac7 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -681,7 +681,7 @@ if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $title = $object->name." - ".$langs->trans('PaymentInformation'); } -llxHeader(); +llxHeader('', $title, $help_url); $head = societe_prepare_head($object); diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 56eef9fb632..9a54edadcd0 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1063,7 +1063,10 @@ if (empty($reshook)) { /* * View */ -$title = $langs->trans('CommRequest')." - ".$langs->trans('Card'); +$title = $object->ref." - ".$langs->trans('Card'); +if ($action == 'create') { + $title = $langs->trans("SupplierProposalNew"); +} $help_url = 'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur'; llxHeader('', $title, $help_url); @@ -1082,7 +1085,7 @@ $now = dol_now(); if ($action == 'create') { $currency_code = $conf->currency; - print load_fiche_titre($langs->trans("NewAskPrice"), '', 'supplier_proposal'); + print load_fiche_titre($langs->trans("SupplierProposalNew"), '', 'supplier_proposal'); $soc = new Societe($db); if ($socid > 0) { diff --git a/htdocs/supplier_proposal/contact.php b/htdocs/supplier_proposal/contact.php index f1756f17814..b6a11e9ba17 100644 --- a/htdocs/supplier_proposal/contact.php +++ b/htdocs/supplier_proposal/contact.php @@ -98,10 +98,6 @@ if ($action == 'addcontact' && $permissiontoedit) { /* * View */ -$title = $langs->trans('CommRequest')." - ".$langs->trans('ContactsAddresses'); -$help_url = 'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur'; -llxHeader('', $title, $help_url); - $form = new Form($db); $formcompany = new FormCompany($db); $contactstatic = new Contact($db); @@ -120,6 +116,10 @@ if ($id > 0 || !empty($ref)) { if ($object->fetch($id, $ref) > 0) { $object->fetch_thirdparty(); + $title = $object->ref." - ".$langs->trans('ContactsAddresses'); + $help_url = 'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur'; + llxHeader('', $title, $help_url); + $head = supplier_proposal_prepare_head($object); print dol_get_fiche_head($head, 'contact', $langs->trans("CommRequest"), -1, 'supplier_proposal'); diff --git a/htdocs/supplier_proposal/document.php b/htdocs/supplier_proposal/document.php index fa73ec22fa8..ad4050a6eb4 100644 --- a/htdocs/supplier_proposal/document.php +++ b/htdocs/supplier_proposal/document.php @@ -90,7 +90,7 @@ if ($object->id > 0) { * View */ -$title = $langs->trans('CommRequest')." - ".$langs->trans('Documents'); +$title = $object->ref." - ".$langs->trans('Documents'); $help_url = 'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur'; llxHeader('', $title, $help_url); diff --git a/htdocs/supplier_proposal/info.php b/htdocs/supplier_proposal/info.php index 0b796937d2e..bda854cba23 100644 --- a/htdocs/supplier_proposal/info.php +++ b/htdocs/supplier_proposal/info.php @@ -48,19 +48,16 @@ $result = restrictedArea($user, 'supplier_proposal', $id); /* * View */ - $form = new Form($db); - -$title = $langs->trans('CommRequest')." - ".$langs->trans('Info'); -$help_url = 'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur'; -llxHeader('', $title, $help_url); - $object = new SupplierProposal($db); $object->fetch($id); $object->fetch_thirdparty(); - $object->info($object->id); +$title = $object->ref." - ".$langs->trans('Info'); +$help_url = 'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur'; +llxHeader('', $title, $help_url); + $head = supplier_proposal_prepare_head($object); print dol_get_fiche_head($head, 'info', $langs->trans('CommRequest'), -1, 'supplier_proposal'); diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index ad35c8f9914..a07272b13df 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -285,8 +285,10 @@ $formpropal = new FormPropal($db); $companystatic = new Societe($db); $formcompany = new FormCompany($db); +$title = $langs->trans('ListOfSupplierProposals'); $help_url = 'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur'; -//llxHeader('',$langs->trans('CommRequest'),$help_url); + +llxHeader('', $title, $help_url); $sql = 'SELECT'; if ($sall || $search_product_category > 0 || $search_user > 0) { @@ -467,7 +469,7 @@ if ($resql) { exit; } - llxHeader('', $langs->trans('CommRequest'), $help_url); +// llxHeader('', $langs->trans('CommRequest'), $help_url); $param = ''; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { diff --git a/htdocs/supplier_proposal/note.php b/htdocs/supplier_proposal/note.php index 5a19a94b402..dface2f68c5 100644 --- a/htdocs/supplier_proposal/note.php +++ b/htdocs/supplier_proposal/note.php @@ -72,10 +72,6 @@ if (empty($reshook)) { /* * View */ -$title = $langs->trans('CommRequest')." - ".$langs->trans('Notes'); -$help_url = 'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur'; -llxHeader('', $title, $help_url); - $form = new Form($db); if ($id > 0 || !empty($ref)) { @@ -88,6 +84,10 @@ if ($id > 0 || !empty($ref)) { if ($object->fetch($id, $ref)) { $object->fetch_thirdparty(); + $title = $object->ref." - ".$langs->trans('Notes'); + $help_url = 'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur'; + llxHeader('', $title, $help_url); + $societe = new Societe($db); if ($societe->fetch($object->socid)) { $head = supplier_proposal_prepare_head($object); diff --git a/htdocs/user/agenda_extsites.php b/htdocs/user/agenda_extsites.php index 5921f7d84cd..09b31e54cd0 100644 --- a/htdocs/user/agenda_extsites.php +++ b/htdocs/user/agenda_extsites.php @@ -148,7 +148,11 @@ $formother = new FormOther($db); $arrayofjs = array(); $arrayofcss = array(); -llxHeader('', $langs->trans("UserSetup"), '', '', 0, 0, $arrayofjs, $arrayofcss); +$person_name = !empty($object->firstname) ? $object->lastname.", ".$object->firstname : $object->lastname; +$title = $person_name." - ".$langs->trans('ExtSites'); +$help_url = ''; + +llxHeader('', $title, $help_url, '', 0, 0, $arrayofjs, $arrayofcss); print ''; diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index 59f593f5b74..eb17903c597 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -259,7 +259,10 @@ $form = new Form($db); $childids = $user->getAllChildIds(1); -llxHeader(null, $langs->trans("BankAccounts")); +$person_name = !empty($object->firstname) ? $object->lastname.", ".$object->firstname : $object->lastname; +$title = $person_name." - ".$langs->trans('BankAccounts'); +$help_url = ''; +llxHeader('', $title, $help_url); $head = user_prepare_head($object); diff --git a/htdocs/user/card.php b/htdocs/user/card.php index f789023b8d4..b050fb70df7 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -716,9 +716,13 @@ if (!empty($conf->stock->enabled)) { $formproduct = new FormProduct($db); } -llxHeader('', $langs->trans("UserCard")); +$help_url = ''; if ($action == 'create' || $action == 'adduserldap') { + + $title = $langs->trans("NewUser"); + llxHeader('', $title, $help_url); + print load_fiche_titre($langs->trans("NewUser"), '', 'user'); print ''.$langs->trans("CreateInternalUserDesc")."
\n"; @@ -1336,6 +1340,10 @@ if ($action == 'create' || $action == 'adduserldap') { } } + $person_name = !empty($object->firstname) ? $object->lastname.", ".$object->firstname : $object->lastname; + $title = $person_name." - ".$langs->trans('Card'); + llxHeader('', $title, $help_url); + // Show tabs if ($mode == 'employee') { // For HRM module development $title = $langs->trans("Employee"); diff --git a/htdocs/user/clicktodial.php b/htdocs/user/clicktodial.php index 2207e3358ae..9e203db4904 100644 --- a/htdocs/user/clicktodial.php +++ b/htdocs/user/clicktodial.php @@ -74,18 +74,18 @@ if (empty($reshook)) { /* * View */ - $form = new Form($db); -llxHeader("", "ClickToDial"); - - if ($id > 0) { $object = new User($db); $object->fetch($id, '', '', 1); $object->getrights(); $object->fetch_clicktodial(); + $person_name = !empty($object->firstname) ? $object->lastname.", ".$object->firstname : $object->lastname; + $title = $person_name." - ".$langs->trans('ClickToDial'); + $help_url = ''; + llxHeader('', $title, $help_url); $head = user_prepare_head($object); diff --git a/htdocs/user/document.php b/htdocs/user/document.php index 142c44d85fe..d33175af8c5 100644 --- a/htdocs/user/document.php +++ b/htdocs/user/document.php @@ -129,7 +129,11 @@ if (empty($reshook)) { $form = new Form($db); -llxHeader('', $langs->trans("UserCard").' - '.$langs->trans("Files")); + +$person_name = !empty($object->firstname) ? $object->lastname.", ".$object->firstname : $object->lastname; +$title = $person_name." - ".$langs->trans('Documents'); +$help_url = ''; +llxHeader('', $title, $help_url); if ($object->id) { /* diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index f698d1b5a07..7e61fc150b2 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -246,8 +246,13 @@ if (empty($reshook)) { /* * View */ +$title = $object->name.' - '.$langs->trans("Card"); +if ($action == 'create') { + $title = $langs->trans("NewGroup"); +} + +llxHeader('', $title, $help_url); -llxHeader('', $langs->trans("GroupCard")); $form = new Form($db); $fuserstatic = new User($db); diff --git a/htdocs/user/group/ldap.php b/htdocs/user/group/ldap.php index af28b979225..0c73b07807e 100644 --- a/htdocs/user/group/ldap.php +++ b/htdocs/user/group/ldap.php @@ -92,7 +92,9 @@ if ($action == 'dolibarr2ldap') { $form = new Form($db); -llxHeader(); +$title = $object->name." - ".$langs->trans('LDAP'); +$help_url = ''; +llxHeader('', $title, $help_url); $head = group_prepare_head($object); diff --git a/htdocs/user/group/list.php b/htdocs/user/group/list.php index 04fa0035418..58d009a7c26 100644 --- a/htdocs/user/group/list.php +++ b/htdocs/user/group/list.php @@ -120,8 +120,8 @@ if (empty($reshook)) { /* * View */ - -llxHeader(); +$title = $langs->trans("ListOfGroups"); +llxHeader('', $title, $help_url); $sql = "SELECT g.rowid, g.nom as name, g.note, g.entity, g.datec, g.tms as datem, COUNT(DISTINCT ugu.fk_user) as nb, COUNT(DISTINCT ugr.fk_id) as nbpermissions"; $sql .= " FROM ".MAIN_DB_PREFIX."usergroup as g"; diff --git a/htdocs/user/group/perms.php b/htdocs/user/group/perms.php index 478e345f2e3..b959c124a5f 100644 --- a/htdocs/user/group/perms.php +++ b/htdocs/user/group/perms.php @@ -128,7 +128,9 @@ if (empty($reshook)) { $form = new Form($db); -llxHeader('', $langs->trans("Permissions")); +$title = $object->name." - ".$langs->trans('Permissions'); +$help_url = ''; +llxHeader('', $title, $help_url); if ($object->id > 0) { $head = group_prepare_head($object); diff --git a/htdocs/user/home.php b/htdocs/user/home.php index c8dbdf2c1b8..b79476e7d5c 100644 --- a/htdocs/user/home.php +++ b/htdocs/user/home.php @@ -75,8 +75,9 @@ if (GETPOST('addbox')) { /* * View */ - -llxHeader(); +$title = $langs->trans("MenuUsersAndGroups"); +$help_url = ''; +llxHeader('', $title, $help_url); print load_fiche_titre($langs->trans("MenuUsersAndGroups"), $resultboxes['selectboxlist'], 'user'); diff --git a/htdocs/user/info.php b/htdocs/user/info.php index f6a0c731e14..6104df6f996 100644 --- a/htdocs/user/info.php +++ b/htdocs/user/info.php @@ -62,7 +62,10 @@ if (($object->id != $user->id) && (!$user->rights->user->user->lire)) { $form = new Form($db); -llxHeader(); +$person_name = !empty($object->firstname) ? $object->lastname.", ".$object->firstname : $object->lastname; +$title = $person_name." - ".$langs->trans('Info'); +$help_url = ''; +llxHeader('', $title, $help_url); $head = user_prepare_head($object); diff --git a/htdocs/user/ldap.php b/htdocs/user/ldap.php index 5e6cf57bfd4..8a8ca28092e 100644 --- a/htdocs/user/ldap.php +++ b/htdocs/user/ldap.php @@ -89,7 +89,10 @@ if (empty($reshook)) { $form = new Form($db); -llxHeader(); +$person_name = !empty($object->firstname) ? $object->lastname.", ".$object->firstname : $object->lastname; +$title = $person_name." - ".$langs->trans('LDAP'); +$help_url = ''; +llxHeader('', $title, $help_url); $head = user_prepare_head($object); diff --git a/htdocs/user/list.php b/htdocs/user/list.php index cd87e286225..a01394604de 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -473,8 +473,8 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $ // Output page // -------------------------------------------------------------------- - -llxHeader('', $langs->trans("ListOfUsers"), $help_url); +$title = $langs->trans("ListOfUsers"); +llxHeader('', $title, $help_url); $param = ''; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { diff --git a/htdocs/user/note.php b/htdocs/user/note.php index 1cf1f112df4..a8e01536408 100644 --- a/htdocs/user/note.php +++ b/htdocs/user/note.php @@ -84,11 +84,13 @@ if (empty($reshook)) { /* * View */ - -llxHeader(); - $form = new Form($db); +$person_name = !empty($object->firstname) ? $object->lastname.", ".$object->firstname : $object->lastname; +$title = $person_name." - ".$langs->trans('Notes'); +$help_url = ''; +llxHeader('', $title, $help_url); + if ($id) { $head = user_prepare_head($object); diff --git a/htdocs/user/param_ihm.php b/htdocs/user/param_ihm.php index bb1320ecd0b..3bed57c38bc 100644 --- a/htdocs/user/param_ihm.php +++ b/htdocs/user/param_ihm.php @@ -178,8 +178,11 @@ if (empty($reshook)) { /* * View */ +$person_name = !empty($object->firstname) ? $object->lastname.", ".$object->firstname : $object->lastname; +$title = $person_name." - ".$langs->trans('Card'); +$help_url = ''; -llxHeader(); +llxHeader('', $title, $help_url); // List of possible landing pages $tmparray = array('index.php'=>'Dashboard'); diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index 6e28a77b5bc..0fd3ee23ebb 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -143,7 +143,10 @@ if (empty($reshook)) { $form = new Form($db); -llxHeader('', $langs->trans("Permissions")); +$person_name = !empty($object->firstname) ? $object->lastname.", ".$object->firstname : $object->lastname; +$title = $person_name." - ".$langs->trans('Permissions'); +$help_url = ''; +llxHeader('', $title, $help_url); $head = user_prepare_head($object); From 23d948cec4a6a91a556118ba98a3c4357ee86ea4 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 27 Jun 2022 10:56:08 +0000 Subject: [PATCH 100/367] Fixing style errors. --- htdocs/comm/propal/list.php | 2 +- htdocs/product/stock/movement_list.php | 1 - htdocs/supplier_proposal/list.php | 2 +- htdocs/user/card.php | 1 - 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 38ad80d964f..d6dcd0e4576 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -751,7 +751,7 @@ if ($resql) { exit; } -// llxHeader('', $langs->trans('Proposal'), $help_url); + // llxHeader('', $langs->trans('Proposal'), $help_url); $param = '&search_status='.urlencode($search_status); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index 6462115182d..416843aca50 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -639,7 +639,6 @@ if ($msid) { } else { $title .= ' ('.$langs->trans("ForThisWarehouse").')'; } - } } llxHeader("", $title, $help_url); diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index a07272b13df..36706610a2d 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -469,7 +469,7 @@ if ($resql) { exit; } -// llxHeader('', $langs->trans('CommRequest'), $help_url); + // llxHeader('', $langs->trans('CommRequest'), $help_url); $param = ''; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { diff --git a/htdocs/user/card.php b/htdocs/user/card.php index b050fb70df7..a1cb7b5c996 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -719,7 +719,6 @@ if (!empty($conf->stock->enabled)) { $help_url = ''; if ($action == 'create' || $action == 'adduserldap') { - $title = $langs->trans("NewUser"); llxHeader('', $title, $help_url); From 4335e6724917b9b5fee4b15a0ba9da07ac1a4f52 Mon Sep 17 00:00:00 2001 From: Christian Foellmann Date: Mon, 27 Jun 2022 12:59:06 +0200 Subject: [PATCH 101/367] remove old commented code --- htdocs/comm/propal/list.php | 2 -- htdocs/supplier_proposal/list.php | 2 -- 2 files changed, 4 deletions(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index d6dcd0e4576..fb135aa0205 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -751,8 +751,6 @@ if ($resql) { exit; } - // llxHeader('', $langs->trans('Proposal'), $help_url); - $param = '&search_status='.urlencode($search_status); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 36706610a2d..b13a63ed661 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -469,8 +469,6 @@ if ($resql) { exit; } - // llxHeader('', $langs->trans('CommRequest'), $help_url); - $param = ''; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); From d7d02fee9a9eaf7b41c494041d18724cc6119114 Mon Sep 17 00:00:00 2001 From: Faustin Date: Mon, 27 Jun 2022 16:08:06 +0200 Subject: [PATCH 102/367] NEW #21395 : Added option for dark theme mode in display - color and theme --- htdocs/admin/ihm.php | 10 ++++++++++ htdocs/core/lib/usergroups.lib.php | 21 +++++++++++++++++++++ htdocs/langs/en_US/admin.lang | 9 +++++++-- htdocs/langs/fr_FR/admin.lang | 20 ++++++++++++-------- 4 files changed, 50 insertions(+), 10 deletions(-) diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index 959d881041d..5ad497205ab 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -104,6 +104,16 @@ if ($action == 'update') { dolibarr_set_const($db, "MAIN_THEME", GETPOST("main_theme", 'aZ09'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", getDolGlobalInt('MAIN_IHM_PARAMS_REV') + 1, 'chaine', 0, '', $conf->entity); + if (GETPOSTISSET('THEME_DARKMODEENABLED')) { + $val = GETPOST('THEME_DARKMODEENABLED'); + if (!$val) { + dolibarr_del_const($db, "THEME_DARKMODEENABLED", $conf->entity); + } + if ($val) { + dolibarr_set_const($db, "THEME_DARKMODEENABLED", $val, 'chaine', 0, '', $conf->entity); + } + } + if (GETPOSTISSET('THEME_TOPMENU_DISABLE_IMAGE')) { $val=GETPOST('THEME_TOPMENU_DISABLE_IMAGE'); if (!$val) { diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 538fc299564..eed9043afa6 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -455,6 +455,27 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; } + //Dark mode + if ($foruserprofile) { + //Nothing + } else { + $listofdarkmodes = array( + '0' => $langs->trans("AlwaysDisabled"), + '1' => $langs->trans("AccordingToBrowser"), + '2' => $langs->trans("AlwaysEnabled") + ); + print '
'; + print ''; + print ''; + } + + // TopMenuDisableImages if ($foruserprofile) { /* diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 95ed076f347..4c3d8c32799 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -897,7 +897,7 @@ Permission701=Read donations Permission702=Create/modify donations Permission703=Delete donations Permission771=Read expense reports (yours and your subordinates) -Permission772=Create/modify expense reports (for you and your subordinates) +Permission772=Create/modify expense reports (for you and your subordinates) Permission773=Delete expense reports Permission775=Approve expense reports Permission776=Pay expense reports @@ -2169,7 +2169,7 @@ EMailsWillHaveMessageID=Emails will have a tag 'References' matching this syntax PDF_SHOW_PROJECT=Show project on document ShowProjectLabel=Project Label PDF_INCLUDE_ALIAS_IN_THIRDPARTY_NAME=Include alias in thirdparty name -THIRDPARTY_ALIAS=Name thirdparty - Alias thirdparty +THIRDPARTY_ALIAS=Name thirdparty - Alias thirdparty ALIAS_THIRDPARTY=Alias thirdparty - Name thirdparty PDF_USE_ALSO_LANGUAGE_CODE=If you want to have some texts in your PDF duplicated in 2 different languages in the same generated PDF, you must set here this second language so generated PDF will contains 2 different languages in same page, the one chosen when generating PDF and this one (only few PDF templates support this). Keep empty for 1 language per PDF. PDF_USE_A=Gererate PDF documents with format PDF/A instead of defaut format PDF @@ -2277,3 +2277,8 @@ INVOICE_ADD_ZATCA_QR_CODEMore=Some Arabic countries need this QR Code on their i INVOICE_ADD_SWISS_QR_CODE=Show the swiss QR-Bill code on invoices UrlSocialNetworksDesc=Url link of social network. Use {socialid} for the variable part that contains the social network ID. IfThisCategoryIsChildOfAnother=If this category is a child of another one + +DarkThemeMode=Dark theme mode +AlwaysDisabled=Always disabled +AccordingToBrowser=According to browser +AlwaysEnabled=Always Enabled \ No newline at end of file diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 7ac18213e1e..68aa93b7b5d 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -190,7 +190,7 @@ Compression=Compression CommandsToDisableForeignKeysForImport=Commande pour désactiver les clés étrangères à l'importation CommandsToDisableForeignKeysForImportWarning=Requis si vous voulez être en mesure de restaurer votre « dump » SQL plus tard ExportCompatibility=Compatibilité du fichier d'exportation généré -ExportUseMySQLQuickParameter=Utiliser le paramètre --quick +ExportUseMySQLQuickParameter=Utiliser le paramètre --quick ExportUseMySQLQuickParameterHelp=Le paramètre '--quick' aide à réduire la consommation de RAM pour les longues listes MySqlExportParameters=Paramètres de l'exportation MySQL PostgreSqlExportParameters= Paramètres de l'exportation PostgreSQL @@ -338,7 +338,7 @@ MenuHandlers=Gestionnaires de menu MenuAdmin=Édition menu DoNotUseInProduction=Ne pas utiliser en production ThisIsProcessToFollow=Procédure de mise à jour: -ThisIsAlternativeProcessToFollow=Voici une procédure de configuration alternative +ThisIsAlternativeProcessToFollow=Voici une procédure de configuration alternative StepNb=Étape %s FindPackageFromWebSite=Rechercher le paquet qui répond à votre besoin (par exemple sur le site web %s). DownloadPackageFromWebSite=Télécharger le package (par exemple depuis le site web officiel %s) @@ -1377,7 +1377,7 @@ NumberingModules=Modèles de numérotation DocumentModules=Modèles de documents ##### Module password generation PasswordGenerationStandard=Renvoie un mot de passe généré selon l'algorythme interne de Dolibarr :%s caractères contenant chiffres et minuscules -PasswordGenerationNone=Ne pas suggérer un mot de passe généré. Le mot de passe doit être entré manuellement. +PasswordGenerationNone=Ne pas suggérer un mot de passe généré. Le mot de passe doit être entré manuellement. PasswordGenerationPerso=Renvoie un mot de passe en fonction d'une configuration personnalisée. SetupPerso=Selon votre configuration PasswordPatternDesc=Description du masque du mot de passe @@ -1455,7 +1455,7 @@ OrdersNumberingModules=Modèles de numérotation des commandes OrdersModelModule=Modèles de document des commandes FreeLegalTextOnOrders=Mention complémentaire sur les commandes WatermarkOnDraftOrders=Filigrane sur les brouillons de commandes (aucun si vide) -ShippableOrderIconInList=Ajouter une icône dans la liste des commandes qui indique si la commande est expédiable. +ShippableOrderIconInList=Ajouter une icône dans la liste des commandes qui indique si la commande est expédiable. BANK_ASK_PAYMENT_BANK_DURING_ORDER=Demander le compte bancaire cible durant la commande ##### Interventions ##### InterventionsSetup=Configuration du module Interventions @@ -1645,7 +1645,7 @@ TestNotPossibleWithCurrentBrowsers=Une détection automatique n'est pas possible DefaultValuesDesc=Vous pouvez définir/forcer ici la valeur par défaut que vous voulez obtenir lorsque vous créez un nouvel enregistrement, et/ou les filtres par défaut ou ordre de tri des listes. DefaultCreateForm=Valeurs par défaut (sur les formulaires de création) DefaultSearchFilters=Filtres de recherche par défaut -DefaultSortOrder=Ordre de tri par défaut +DefaultSortOrder=Ordre de tri par défaut DefaultFocus=Champs par défaut ayant le focus DefaultMandatory=Champs de formulaire obligatoires ##### Products ##### @@ -1864,7 +1864,7 @@ ChequeReceiptsNumberingModule=Module de numérotation des bordereaux de remises MultiCompanySetup=Configuration du module Multi-société ##### Suppliers ##### SuppliersSetup=Configuration du module Fournisseurs -SuppliersCommandModel=Modèle de commande fournisseur complet +SuppliersCommandModel=Modèle de commande fournisseur complet SuppliersCommandModelMuscadet=Modèle de commande fournisseur complet (ancienne implémentation du modèle Cornas) SuppliersInvoiceModel=Modèle de facture fournisseur complet SuppliersInvoiceNumberingModel=Modèles de numérotation des factures fournisseur @@ -1899,7 +1899,7 @@ NbMajMin=Nombre minimal de caractères majuscules NbNumMin=Nombre minimal de caractères numériques NbSpeMin=Nombre minimal de caractères spéciaux NbIteConsecutive=Nombre maximal de répétition des mêmes caractères -NoAmbiCaracAutoGeneration=Ne pas utiliser des caractères ambigus ("1","l","i","|","0","O") pour la génération automatique +NoAmbiCaracAutoGeneration=Ne pas utiliser des caractères ambigus ("1","l","i","|","0","O") pour la génération automatique SalariesSetup=Configuration du module salaires SortOrder=Ordre de tri Format=Format @@ -1920,7 +1920,7 @@ GoOntoContactCardToAddMore=Rendez-vous sur l'onglet "Notifications" d'un tiers p Threshold=Seuil BackupDumpWizard=Assistant pour créer le fichier dump de la base de données BackupZipWizard=Assistant pour générer l'archive du répertoire documents -SomethingMakeInstallFromWebNotPossible=L'installation de module externe est impossible depuis l'interface web pour la raison suivante : +SomethingMakeInstallFromWebNotPossible=L'installation de module externe est impossible depuis l'interface web pour la raison suivante : SomethingMakeInstallFromWebNotPossible2=Pour cette raison, le processus de mise à jour décrit ici est une processus manuel que seul un utilisateur ayant des droits privilégiés peut réaliser. InstallModuleFromWebHasBeenDisabledByFile=L'installation de module externe depuis l'application a été désactivé par l'administrator. Vous devez lui demander de supprimer le fichier %s pour permettre cette fonctionnalité. ConfFileMustContainCustom=Installer ou créer un module externe à partir de l'application nécessite de sauvegarder les fichiers du module dans le répertoire %s. Pour que ce répertoire soit reconnu par Dolibarr, vous devez paramétrer le fichier de configuration conf/conf.php en ajoutant les 2 lignes suivantes :
$dolibarr_main_url_root_alt='/custom'
$dolibarr_main_document_root_alt='%s/custom'; @@ -2263,3 +2263,7 @@ IconOnly=Icon only - Text on tooltip only INVOICE_ADD_ZATCA_QR_CODE=Show the ZATCA QR code on invoices INVOICE_ADD_ZATCA_QR_CODEMore=Some Arabic countries need this QR Code on their invoices UrlSocialNetworksDesc=Url link of social network. Use {socialid} for the variable part that contains the social network ID. +DarkThemeMode=Mode thème sombre +AlwaysDisabled=Toujours désactivé +AccordingToBrowser=Selon le navigateur +AlwaysEnabled=Toujours activé \ No newline at end of file From 3e66ca1636dd80c64a79d2d033b3866ae88bf18a Mon Sep 17 00:00:00 2001 From: Faustin Date: Mon, 27 Jun 2022 16:18:54 +0200 Subject: [PATCH 103/367] NEW #21395 : Added picto text to inform that option does not work with all themes --- htdocs/core/lib/usergroups.lib.php | 1 + htdocs/langs/en_US/admin.lang | 3 ++- htdocs/langs/fr_FR/admin.lang | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index eed9043afa6..4aa2942884d 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -472,6 +472,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } else { print $listofdarkmodes[isset($conf->global->THEME_DARKMODEENABLED) ? $conf->global->THEME_DARKMODEENABLED : 0]; } + print $form->textwithpicto('', $langs->trans("DoesNotWorkWithAllThemes")); print ''; } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 4c3d8c32799..bec98616b11 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2281,4 +2281,5 @@ IfThisCategoryIsChildOfAnother=If this category is a child of another one DarkThemeMode=Dark theme mode AlwaysDisabled=Always disabled AccordingToBrowser=According to browser -AlwaysEnabled=Always Enabled \ No newline at end of file +AlwaysEnabled=Always Enabled +DoesNotWorkWithAllThemes=Will not work with all themes \ No newline at end of file diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 68aa93b7b5d..3c653717801 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -2266,4 +2266,5 @@ UrlSocialNetworksDesc=Url link of social network. Use {socialid} for the variabl DarkThemeMode=Mode thème sombre AlwaysDisabled=Toujours désactivé AccordingToBrowser=Selon le navigateur -AlwaysEnabled=Toujours activé \ No newline at end of file +AlwaysEnabled=Toujours activé +DoesNotWorkWithAllThemes=Ne fonctionne pas avec tous les thèmes \ No newline at end of file From 0fca79529a782cacdd47387131d527e98aaf60d8 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Tue, 28 Jun 2022 01:51:14 +0200 Subject: [PATCH 104/367] Missing lib import --- htdocs/public/members/new.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 31f1fa9f952..654fce78ccc 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -64,6 +64,7 @@ if (is_numeric($entity)) { require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; From 5998999f18741ec3a7c9f439231054e59ef0aa8c Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Tue, 28 Jun 2022 02:33:17 +0200 Subject: [PATCH 105/367] NEW: Add free membership amounts at the membership type level --- .../adherents/class/adherent_type.class.php | 10 +++++- htdocs/adherents/type.php | 10 +++++- htdocs/core/lib/payments.lib.php | 4 ++- .../install/mysql/migration/15.0.0-16.0.0.sql | 3 +- htdocs/langs/en_US/members.lang | 3 ++ htdocs/langs/fr_FR/members.lang | 3 ++ htdocs/public/members/new.php | 31 ++++++++++++++----- 7 files changed, 52 insertions(+), 12 deletions(-) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 3f857ce827b..38641c8664b 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -94,6 +94,11 @@ class AdherentType extends CommonObject */ public $amount; + /** + * @var int Amount can be choosen by the visitor during subscription (0 or 1) + */ + public $caneditamount; + /** * @var string Public note * @deprecated @@ -380,6 +385,7 @@ class AdherentType extends CommonObject $sql .= "morphy = '".$this->db->escape($this->morphy)."',"; $sql .= "subscription = '".$this->db->escape($this->subscription)."',"; $sql .= "amount = ".((empty($this->amount) && $this->amount == '') ? 'null' : ((float) $this->amount)).","; + $sql .= "caneditamount = '".$this->db->escape($this->caneditamount)."',"; $sql .= "duration = '".$this->db->escape($this->duration_value.$this->duration_unit)."',"; $sql .= "note = '".$this->db->escape($this->note_public)."',"; $sql .= "vote = ".(integer) $this->db->escape($this->vote).","; @@ -474,7 +480,7 @@ class AdherentType extends CommonObject { global $langs, $conf; - $sql = "SELECT d.rowid, d.libelle as label, d.morphy, d.statut as status, d.duration, d.subscription, d.amount, d.mail_valid, d.note as note_public, d.vote"; + $sql = "SELECT d.rowid, d.libelle as label, d.morphy, d.statut as status, d.duration, d.subscription, d.amount, d.caneditamount, d.mail_valid, d.note as note_public, d.vote"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; $sql .= " WHERE d.rowid = ".(int) $rowid; @@ -495,6 +501,7 @@ class AdherentType extends CommonObject $this->duration_unit = substr($obj->duration, -1); $this->subscription = $obj->subscription; $this->amount = $obj->amount; + $this->caneditamount = $obj->caneditamount; $this->mail_valid = $obj->mail_valid; $this->note = $obj->note_public; // deprecated $this->note_public = $obj->note_public; @@ -850,6 +857,7 @@ class AdherentType extends CommonObject $this->note_public = 'This is a public note'; $this->mail_valid = 'This is welcome email'; $this->subscription = 1; + $this->caneditamount = 0; $this->vote = 0; $this->status = 1; diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index bcd6c99afbf..0b54132b5d0 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -122,6 +122,7 @@ if ($action == 'add' && $user->rights->adherent->configurer) { $object->status = (int) $status; $object->subscription = (int) $subscription; $object->amount = ($amount == '' ? '' : price2num($amount, 'MT')); + $object->caneditamount = (int) GETPOST("caneditamount", 'int'); $object->duration_value = $duration_value; $object->duration_unit = $duration_unit; $object->note = trim($comment); @@ -229,7 +230,7 @@ llxHeader('', $langs->trans("MembersTypeSetup"), $help_url); if (!$rowid && $action != 'create' && $action != 'edit') { //print dol_get_fiche_head(''); - $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.amount, d.vote, d.statut as status, d.morphy"; + $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.amount, d.caneditamount, d.vote, d.statut as status, d.morphy"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; $sql .= " WHERE d.entity IN (".getEntity('member_type').")"; @@ -276,6 +277,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') { print ''; print ''; print ''; + print ''; print ''; print ''; print ''; @@ -292,6 +294,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') { $membertype->status = $objp->status; $membertype->subscription = $objp->subscription; $membertype->amount = $objp->amount; + $membertype->caneditamount = $objp->caneditamount; print ''; print ''; print ''; print ''; + print ''; print ''; print ''; if ($user->rights->adherent->configurer) { @@ -380,6 +384,10 @@ if ($action == 'create') { print ''; print ''; + print ''; + print ''; diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index 2911564adef..c006c4b9c9f 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -318,7 +318,9 @@ function getOnlinePaymentUrl($mode, $type, $ref = '', $amount = '9.99', $freetag } } elseif ($type == 'member' || $type == 'membersubscription') { $newtype = 'member'; - $out = $urltouse.'/public/payment/newpayment.php?source=member&ref='.($mode ? '' : ''); + $out = $urltouse.'/public/payment/newpayment.php?source=member'; + $out .= '&amount='.$amount; + $out .= '&ref='.($mode ? '' : ''); if ($mode == 1) { $out .= 'member_ref'; } diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index b57cab5b4eb..c465151f9c2 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -648,4 +648,5 @@ ALTER TABLE llx_paiement MODIFY COLUMN ext_payment_id varchar(255); ALTER TABLE llx_payment_donation MODIFY COLUMN ext_payment_id varchar(255); ALTER TABLE llx_prelevement_facture_demande MODIFY COLUMN ext_payment_id varchar(255); - +-- Allow users to make subscriptions of any amount during membership subscription +ALTER TABLE llx_adherent_type ADD COLUMN caneditamount varchar(3) DEFAULT 0 AFTER amount; diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index fafa1a60400..e552755f705 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -71,6 +71,9 @@ MemberTypeCanNotBeDeleted=Member type can not be deleted NewSubscription=New contribution NewSubscriptionDesc=This form allows you to record your subscription as a new member of the foundation. If you want to renew your subscription (if already a member), please contact foundation board instead by email %s. Subscription=Contribution +AnyAmountWithAdvisedAmount=Any amount with a recommended amount of %s %s +AnyAmountWithoutAdvisedAmount=Any amount +CanEditAmountShort=Any amount Subscriptions=Contributions SubscriptionLate=Late SubscriptionNotReceived=Contribution never received diff --git a/htdocs/langs/fr_FR/members.lang b/htdocs/langs/fr_FR/members.lang index a6f805daca6..5f67cc681ab 100644 --- a/htdocs/langs/fr_FR/members.lang +++ b/htdocs/langs/fr_FR/members.lang @@ -199,6 +199,9 @@ AmountOfSubscriptions=Montant des cotisations TurnoverOrBudget=Chiffre affaire (pour société) ou Budget (asso ou collectivité) DefaultAmount=Montant par défaut de la cotisation CanEditAmount=Le visiteur peut modifier / choisir le montant de sa cotisation +AnyAmountWithAdvisedAmount=Montant libre avec un montant recommandé de %s %s +AnyAmountWithoutAdvisedAmount=Montant libre +CanEditAmountShort=Montant libre MEMBER_NEWFORM_PAYONLINE=Rediriger sur la page intégrée de paiement en ligne ByProperties=Par nature MembersStatisticsByProperties=Statistiques des adhérents par nature diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 654fce78ccc..f6957502284 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -692,16 +692,31 @@ if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { // Clean the amount $amount = price2num($amount); - + $adht = new AdherentType($db); + $adht->fetch($typeid); + $caneditamount = $adht->caneditamount; + $showedamount = $amount>0? $amount: 0; // $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal', 'paybox' or 'stripe' - print ''; } From 1ea8d47c844b6f422709ec84e7d978243560ee0e Mon Sep 17 00:00:00 2001 From: lvessiller Date: Tue, 28 Jun 2022 10:42:13 +0200 Subject: [PATCH 106/367] NEW join only the main document --- htdocs/core/tpl/card_presend.tpl.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index 9a99faef526..9e0a38bee39 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -49,8 +49,6 @@ if ($action == 'presend') { // Special case if ($object->element == 'invoice_supplier') { $fileparams = dol_most_recent_file($diroutput.'/'.get_exdir($object->id, 2, 0, 0, $object, $object->element).$ref, preg_quote($ref, '/').'([^\-])+'); - } elseif ($object->element == 'societe') { - $fileparams = dol_most_recent_file($diroutput.'/'.$ref); } else { $fileparams = dol_most_recent_file($diroutput.'/'.$ref, preg_quote($ref, '/').'[^\-]+'); } @@ -102,8 +100,6 @@ if ($action == 'presend') { } if ($object->element == 'invoice_supplier') { $fileparams = dol_most_recent_file($diroutput.'/'.get_exdir($object->id, 2, 0, 0, $object, $object->element).$ref, preg_quote($ref, '/').'([^\-])+'); - } elseif ($object->element == 'societe') { - $fileparams = dol_most_recent_file($diroutput.'/'.$ref); } else { $fileparams = dol_most_recent_file($diroutput.'/'.$ref, preg_quote($ref, '/').'[^\-]+'); } From 739d24e1aeb5ab56f7431c2c634ef89cfa6709e0 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 28 Jun 2022 11:22:01 +0200 Subject: [PATCH 107/367] fix: replannish view lost filter and sort on pagination and sorting --- htdocs/product/stock/replenish.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index a4ce5577361..66ad0889b31 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -137,7 +137,7 @@ if ($reshook < 0) { * Actions */ -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('valid')) { // Both test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // Both test are required to be compatible with all browsers $search_ref = ''; $search_label = ''; $sall = ''; @@ -669,6 +669,8 @@ if ($search_ref || $search_label || $sall || $salert || $draftorder || GETPOST(' if ($limit > 0 && $limit != $conf->liste_limit) { $filters .= '&limit='.urlencode($limit); } +if (!empty($includeproductswithoutdesiredqty)) $filters .= '&includeproductswithoutdesiredqty='.urlencode($includeproductswithoutdesiredqty); +if (!empty($salert)) $filters .= '&salert='.urlencode($salert); $param = (isset($type) ? '&type='.urlencode($type) : ''); $param .= '&fourn_id='.urlencode($fourn_id).'&search_label='.urlencode($search_label).'&includeproductswithoutdesiredqty='.urlencode($includeproductswithoutdesiredqty).'&salert='.urlencode($salert).'&draftorder='.urlencode($draftorder); @@ -676,6 +678,8 @@ $param .= '&search_ref='.urlencode($search_ref); $param .= '&mode='.urlencode($mode); $param .= '&fk_supplier='.urlencode($fk_supplier); $param .= '&fk_entrepot='.urlencode($fk_entrepot); +if (!empty($includeproductswithoutdesiredqty)) $param .= '&includeproductswithoutdesiredqty='.urlencode($includeproductswithoutdesiredqty); +if (!empty($salert)) $param .= '&salert='.urlencode($salert); $stocklabel = $langs->trans('Stock'); $stocklabelbis = $langs->trans('Stock'); From 2981b268aedca56124a633115eeeca89b0509058 Mon Sep 17 00:00:00 2001 From: Christian Foellmann Date: Tue, 28 Jun 2022 13:28:31 +0200 Subject: [PATCH 108/367] add hook "changeHelpURL" to modify target of the help button --- htdocs/main.inc.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 1d09b9f9887..03bc6bfa504 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1309,7 +1309,7 @@ if (!function_exists("llxHeader")) { */ function llxHeader($head = '', $title = '', $help_url = '', $target = '', $disablejs = 0, $disablehead = 0, $arrayofjs = '', $arrayofcss = '', $morequerystring = '', $morecssonbody = '', $replacemainareaby = '', $disablenofollow = 0) { - global $conf; + global $conf, $hookmanager; // html header top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss, 0, $disablenofollow); @@ -1329,6 +1329,12 @@ if (!function_exists("llxHeader")) { print ''."\n"; + $parameters = array('help_url' => $help_url); + $reshook = $hookmanager->executeHooks('changeHelpURL', $parameters); + if ($reshook > 0) { + $help_url = $hookmanager->resPrint; + } + // top menu and left menu area if (empty($conf->dol_hide_topmenu) || GETPOST('dol_invisible_topmenu', 'int')) { top_menu($head, $title, $target, $disablejs, $disablehead, $arrayofjs, $arrayofcss, $morequerystring, $help_url); From 3c4183f7838efef3142d83f6dd98c6f4ff404aa0 Mon Sep 17 00:00:00 2001 From: Quatadah Nasdami Date: Tue, 28 Jun 2022 15:51:38 +0200 Subject: [PATCH 109/367] success --- htdocs/core/lib/website.lib.php | 35 +++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index d9602379977..18bd7226400 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -221,6 +221,41 @@ function dolWebsiteReplacementOfLinks($website, $content, $removephppart = 0, $c */ function dolReplaceSmileyCodeWithUTF8($content) { + $map = array( + ":face_with_tears_of_joy:" => "\xF0\x9F\x98\x82", + ":grinning_face_with_smiling_eyes:" => "\xF0\x9F\x98\x81", + ":smiling_face_with_open_mouth:" => "\xF0\x9F\x98\x83", + ":smiling_face_with_open_mouth_and_cold_sweat:" => "\xF0\x9F\x98\x85", + ":smiling_face_with_open_mouth_and_tightly_closed_eyes:" => "\xF0\x9F\x98\x86", + ":winking_face:" => "\xF0\x9F\x98\x89", + ":smiling_face_with_smiling_eyes:" => "\xF0\x9F\x98\x8A", + ":face_savouring_delicious_food:" => "\xF0\x9F\x98\x8B", + ":relieved_face:" => "\xF0\x9F\x98\x8C", + ":smiling_face_with_heart_shaped_eyes:" => "\xF0\x9F\x98\x8D", + ":smiling_face_with_sunglasses:" => "\xF0\x9F\x98\x8E", + ":smirking_face:" => "\xF0\x9F\x98\x8F", + ":neutral_face:" => "\xF0\x9F\x98\x90", + ":expressionless_face:" => "\xF0\x9F\x98\x91", + ":unamused_face:" => "\xF0\x9F\x98\x92", + ":face_with_cold_sweat:" => "\xF0\x9F\x98\x93", + ":pensive_face:" => "\xF0\x9F\x98\x94", + ":confused_face:" => "\xF0\x9F\x98\x95", + ":confounded_face:" => "\xF0\x9F\x98\x96", + ":kissing_face:" => "\xF0\x9F\x98\x97", + ":face_throwing_a_kiss:" => "\xF0\x9F\x98\x98", + ":kissing_face_with_smiling_eyes:" => "\xF0\x9F\x98\x99", + ":kissing_face_with_closed_eyes:" => "\xF0\x9F\x98\x9A", + ":face_with_stuck_out_tongue:" => "\xF0\x9F\x98\x9B", + ":face_with_stuck_out_tongue_and_winking_eye:" => "\xF0\x9F\x98\x9C", + ":face_with_stuck_out_tongue_and_tightly_closed_eyes:" => "\xF0\x9F\x98\x9D", + ":disappointed_face:" => "\xF0\x9F\x98\x9E", + ":worried_face:" => "\xF0\x9F\x98\x9F", + ":angry_face:" => "\xF0\x9F\x98\xA0", + ":face_with_symbols_on_mouth:" => "\xF0\x9F\x98\xA1", + ); + foreach ($map as $key => $value) { + $content = str_replace($key, $value, $content); + } return $content; } From 831ff35c4d9f2de2b5946097ec393d3dc66b50c3 Mon Sep 17 00:00:00 2001 From: Quatadah Nasdami Date: Tue, 28 Jun 2022 16:10:10 +0200 Subject: [PATCH 110/367] API for module reception --- .../reception/class/api_receptions.class.php | 721 ++++++++++++++++++ 1 file changed, 721 insertions(+) create mode 100644 htdocs/reception/class/api_receptions.class.php diff --git a/htdocs/reception/class/api_receptions.class.php b/htdocs/reception/class/api_receptions.class.php new file mode 100644 index 00000000000..c8ab7626a3e --- /dev/null +++ b/htdocs/reception/class/api_receptions.class.php @@ -0,0 +1,721 @@ + + * Copyright (C) 2022 Laurent Destailleur + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + use Luracast\Restler\RestException; + + require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php'; + +/** + * API class for receptions + * + * @access protected + * @class DolibarrApiAccess {@requires user,external} + */ +class Receptions extends DolibarrApi +{ + + /** + * @var array $FIELDS Mandatory fields, checked when create and update object + */ + public static $FIELDS = array( + 'socid', + 'origin_id', + 'origin_type', + ); + + /** + * @var Reception $reception {@type Reception} + */ + public $reception; + + /** + * Constructor + */ + public function __construct() + { + global $db, $conf; + $this->db = $db; + $this->reception = new Reception($this->db); + } + + /** + * Get properties of a reception object + * + * Return an array with reception informations + * + * @param int $id ID of reception + * @return array|mixed data without useless information + * + * @throws RestException + */ + public function get($id) + { + if (!DolibarrApiAccess::$user->rights->reception->lire) { + throw new RestException(401); + } + + $result = $this->reception->fetch($id); + if (!$result) { + throw new RestException(404, 'Shipment not found'); + } + + if (!DolibarrApi::_checkAccessToResource('reception', $this->reception->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $this->reception->fetchObjectLinked(); + return $this->_cleanObjectDatas($this->reception); + } + + + + /** + * List receptions + * + * Get a list of receptions + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $thirdparty_ids Thirdparty ids to filter receptions of (example '1' or '1,2,3') {@pattern /^[0-9,]*$/i} + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" + * @return array Array of reception objects + * + * @throws RestException + */ + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') + { + global $db, $conf; + + if (!DolibarrApiAccess::$user->rights->reception->lire) { + throw new RestException(401); + } + + $obj_ret = array(); + + // case of external user, $thirdparty_ids param is ignored and replaced by user's socid + $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; + + // If the internal user must only see his customers, force searching by him + $search_sale = 0; + if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) { + $search_sale = DolibarrApiAccess::$user->id; + } + + $sql = "SELECT t.rowid"; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) { + $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) + } + $sql .= " FROM ".MAIN_DB_PREFIX."reception as t"; + + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + } + + $sql .= ' WHERE t.entity IN ('.getEntity('reception').')'; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) { + $sql .= " AND t.fk_soc = sc.fk_soc"; + } + if ($socids) { + $sql .= " AND t.fk_soc IN (".$this->db->sanitize($socids).")"; + } + if ($search_sale > 0) { + $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale + } + // Insert sale filter + if ($search_sale > 0) { + $sql .= " AND sc.fk_user = ".((int) $search_sale); + } + // Add sql filters + if ($sqlfilters) { + $errormessage = ''; + if (!DolibarrApi::_checkFilters($sqlfilters, $errormessage)) { + throw new RestException(503, 'Error when validating parameter sqlfilters -> '.$errormessage); + } + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + + $sql .= $this->db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; + + $sql .= $this->db->plimit($limit + 1, $offset); + } + + dol_syslog("API Rest request"); + $result = $this->db->query($sql); + + if ($result) { + $num = $this->db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + $i = 0; + while ($i < $min) { + $obj = $this->db->fetch_object($result); + $reception_static = new Reception($this->db); + if ($reception_static->fetch($obj->rowid)) { + $obj_ret[] = $this->_cleanObjectDatas($reception_static); + } + $i++; + } + } else { + throw new RestException(503, 'Error when retrieve commande list : '.$this->db->lasterror()); + } + if (!count($obj_ret)) { + throw new RestException(404, 'No reception found'); + } + return $obj_ret; + } + + /** + * Create reception object + * + * @param array $request_data Request data + * @return int ID of reception + */ + public function post($request_data = null) + { + if (!DolibarrApiAccess::$user->rights->reception->creer) { + throw new RestException(401, "Insuffisant rights"); + } + // Check mandatory fields + $result = $this->_validate($request_data); + + foreach ($request_data as $field => $value) { + $this->reception->$field = $value; + } + if (isset($request_data["lines"])) { + $lines = array(); + foreach ($request_data["lines"] as $line) { + array_push($lines, (object) $line); + } + $this->reception->lines = $lines; + } + + if ($this->reception->create(DolibarrApiAccess::$user) < 0) { + throw new RestException(500, "Error creating reception", array_merge(array($this->reception->error), $this->reception->errors)); + } + + return $this->reception->id; + } + + // /** + // * Get lines of an reception + // * + // * @param int $id Id of reception + // * + // * @url GET {id}/lines + // * + // * @return int + // */ + /* + public function getLines($id) + { + if(! DolibarrApiAccess::$user->rights->reception->lire) { + throw new RestException(401); + } + + $result = $this->reception->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Shipment not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('reception',$this->reception->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $this->reception->getLinesArray(); + $result = array(); + foreach ($this->reception->lines as $line) { + array_push($result,$this->_cleanObjectDatas($line)); + } + return $result; + } + */ + + // /** + // * Add a line to given reception + // * + // * @param int $id Id of reception to update + // * @param array $request_data ShipmentLine data + // * + // * @url POST {id}/lines + // * + // * @return int + // */ + /* + public function postLine($id, $request_data = null) + { + if(! DolibarrApiAccess::$user->rights->reception->creer) { + throw new RestException(401); + } + + $result = $this->reception->fetch($id); + if ( ! $result ) { + throw new RestException(404, 'Shipment not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('reception',$this->reception->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $request_data = (object) $request_data; + + $request_data->desc = sanitizeVal($request_data->desc, 'restricthtml'); + $request_data->label = sanitizeVal($request_data->label); + + $updateRes = $this->reception->addline( + $request_data->desc, + $request_data->subprice, + $request_data->qty, + $request_data->tva_tx, + $request_data->localtax1_tx, + $request_data->localtax2_tx, + $request_data->fk_product, + $request_data->remise_percent, + $request_data->info_bits, + $request_data->fk_remise_except, + 'HT', + 0, + $request_data->date_start, + $request_data->date_end, + $request_data->product_type, + $request_data->rang, + $request_data->special_code, + $fk_parent_line, + $request_data->fk_fournprice, + $request_data->pa_ht, + $request_data->label, + $request_data->array_options, + $request_data->fk_unit, + $request_data->origin, + $request_data->origin_id, + $request_data->multicurrency_subprice + ); + + if ($updateRes > 0) { + return $updateRes; + + } + return false; + }*/ + + // /** + // * Update a line to given reception + // * + // * @param int $id Id of reception to update + // * @param int $lineid Id of line to update + // * @param array $request_data ShipmentLine data + // * + // * @url PUT {id}/lines/{lineid} + // * + // * @return object + // */ + /* + public function putLine($id, $lineid, $request_data = null) + { + if (! DolibarrApiAccess::$user->rights->reception->creer) { + throw new RestException(401); + } + + $result = $this->reception->fetch($id); + if ( ! $result ) { + throw new RestException(404, 'Shipment not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('reception',$this->reception->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $request_data = (object) $request_data; + + $request_data->desc = sanitizeVal($request_data->desc, 'restricthtml'); + $request_data->label = sanitizeVal($request_data->label); + + $updateRes = $this->reception->updateline( + $lineid, + $request_data->desc, + $request_data->subprice, + $request_data->qty, + $request_data->remise_percent, + $request_data->tva_tx, + $request_data->localtax1_tx, + $request_data->localtax2_tx, + 'HT', + $request_data->info_bits, + $request_data->date_start, + $request_data->date_end, + $request_data->product_type, + $request_data->fk_parent_line, + 0, + $request_data->fk_fournprice, + $request_data->pa_ht, + $request_data->label, + $request_data->special_code, + $request_data->array_options, + $request_data->fk_unit, + $request_data->multicurrency_subprice + ); + + if ($updateRes > 0) { + $result = $this->get($id); + unset($result->line); + return $this->_cleanObjectDatas($result); + } + return false; + }*/ + + /** + * Delete a line to given reception + * + * + * @param int $id Id of reception to update + * @param int $lineid Id of line to delete + * + * @url DELETE {id}/lines/{lineid} + * + * @return int + * + * @throws RestException 401 + * @throws RestException 404 + */ + public function deleteLine($id, $lineid) + { + if (!DolibarrApiAccess::$user->rights->reception->creer) { + throw new RestException(401); + } + + $result = $this->reception->fetch($id); + if (!$result) { + throw new RestException(404, 'Shipment not found'); + } + + if (!DolibarrApi::_checkAccessToResource('reception', $this->reception->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + // TODO Check the lineid $lineid is a line of ojbect + + $updateRes = $this->reception->deleteline(DolibarrApiAccess::$user, $lineid); + if ($updateRes > 0) { + return $this->get($id); + } else { + throw new RestException(405, $this->reception->error); + } + } + + /** + * Update reception general fields (won't touch lines of reception) + * + * @param int $id Id of reception to update + * @param array $request_data Datas + * + * @return int + */ + public function put($id, $request_data = null) + { + if (!DolibarrApiAccess::$user->rights->reception->creer) { + throw new RestException(401); + } + + $result = $this->reception->fetch($id); + if (!$result) { + throw new RestException(404, 'Shipment not found'); + } + + if (!DolibarrApi::_checkAccessToResource('reception', $this->reception->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + foreach ($request_data as $field => $value) { + if ($field == 'id') { + continue; + } + $this->reception->$field = $value; + } + + if ($this->reception->update(DolibarrApiAccess::$user) > 0) { + return $this->get($id); + } else { + throw new RestException(500, $this->reception->error); + } + } + + /** + * Delete reception + * + * @param int $id Shipment ID + * + * @return array + */ + public function delete($id) + { + if (!DolibarrApiAccess::$user->rights->reception->supprimer) { + throw new RestException(401); + } + $result = $this->reception->fetch($id); + if (!$result) { + throw new RestException(404, 'Shipment not found'); + } + + if (!DolibarrApi::_checkAccessToResource('reception', $this->reception->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + if (!$this->reception->delete(DolibarrApiAccess::$user)) { + throw new RestException(500, 'Error when deleting reception : '.$this->reception->error); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Shipment deleted' + ) + ); + } + + /** + * Validate a reception + * + * This may record stock movements if module stock is enabled and option to + * decrease stock on reception is on. + * + * @param int $id Shipment ID + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * + * @url POST {id}/validate + * + * @return array + * \todo An error 403 is returned if the request has an empty body. + * Error message: "Forbidden: Content type `text/plain` is not supported." + * Workaround: send this in the body + * { + * "notrigger": 0 + * } + */ + public function validate($id, $notrigger = 0) + { + if (!DolibarrApiAccess::$user->rights->reception->creer) { + throw new RestException(401); + } + $result = $this->reception->fetch($id); + if (!$result) { + throw new RestException(404, 'Shipment not found'); + } + + if (!DolibarrApi::_checkAccessToResource('reception', $this->reception->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $result = $this->reception->valid(DolibarrApiAccess::$user, $notrigger); + if ($result == 0) { + throw new RestException(304, 'Error nothing done. May be object is already validated'); + } + if ($result < 0) { + throw new RestException(500, 'Error when validating Shipment: '.$this->reception->error); + } + + // Reload reception + $result = $this->reception->fetch($id); + + $this->reception->fetchObjectLinked(); + return $this->_cleanObjectDatas($this->reception); + } + + + // /** + // * Classify the reception as invoiced + // * + // * @param int $id Id of the reception + // * + // * @url POST {id}/setinvoiced + // * + // * @return int + // * + // * @throws RestException 400 + // * @throws RestException 401 + // * @throws RestException 404 + // * @throws RestException 405 + // */ + /* + public function setinvoiced($id) + { + + if(! DolibarrApiAccess::$user->rights->reception->creer) { + throw new RestException(401); + } + if(empty($id)) { + throw new RestException(400, 'Shipment ID is mandatory'); + } + $result = $this->reception->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Shipment not found'); + } + + $result = $this->reception->classifyBilled(DolibarrApiAccess::$user); + if( $result < 0) { + throw new RestException(400, $this->reception->error); + } + return $result; + } + */ + + + // /** + // * Create a reception using an existing order. + // * + // * @param int $orderid Id of the order + // * + // * @url POST /createfromorder/{orderid} + // * + // * @return int + // * @throws RestException 400 + // * @throws RestException 401 + // * @throws RestException 404 + // * @throws RestException 405 + // */ + /* + public function createShipmentFromOrder($orderid) + { + + require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; + + if(! DolibarrApiAccess::$user->rights->reception->lire) { + throw new RestException(401); + } + if(! DolibarrApiAccess::$user->rights->reception->creer) { + throw new RestException(401); + } + if(empty($proposalid)) { + throw new RestException(400, 'Order ID is mandatory'); + } + + $order = new Commande($this->db); + $result = $order->fetch($proposalid); + if( ! $result ) { + throw new RestException(404, 'Order not found'); + } + + $result = $this->reception->createFromOrder($order, DolibarrApiAccess::$user); + if( $result < 0) { + throw new RestException(405, $this->reception->error); + } + $this->reception->fetchObjectLinked(); + return $this->_cleanObjectDatas($this->reception); + } + */ + + /** + * Close a reception (Classify it as "Delivered") + * + * @param int $id Reception ID + * @param int $notrigger Disabled triggers + * + * @url POST {id}/close + * + * @return int + */ + public function close($id, $notrigger = 0) + { + if (!DolibarrApiAccess::$user->rights->reception->creer) { + throw new RestException(401); + } + + $result = $this->reception->fetch($id); + if (!$result) { + throw new RestException(404, 'Shipment not found'); + } + + if (!DolibarrApi::_checkAccessToResource('reception', $this->commande->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $result = $this->reception->setClosed(); + if ($result == 0) { + throw new RestException(304, 'Error nothing done. May be object is already closed'); + } + if ($result < 0) { + throw new RestException(500, 'Error when closing Order: '.$this->commande->error); + } + + // Reload reception + $result = $this->reception->fetch($id); + + $this->reception->fetchObjectLinked(); + + return $this->_cleanObjectDatas($this->reception); + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Clean sensible object datas + * + * @param Object $object Object to clean + * @return Object Object with cleaned properties + */ + protected function _cleanObjectDatas($object) + { + // phpcs:enable + $object = parent::_cleanObjectDatas($object); + + unset($object->thirdparty); // id already returned + + unset($object->note); + unset($object->address); + unset($object->barcode_type); + unset($object->barcode_type_code); + unset($object->barcode_type_label); + unset($object->barcode_type_coder); + + if (!empty($object->lines) && is_array($object->lines)) { + foreach ($object->lines as $line) { + unset($line->tva_tx); + unset($line->vat_src_code); + unset($line->total_ht); + unset($line->total_ttc); + unset($line->total_tva); + unset($line->total_localtax1); + unset($line->total_localtax2); + unset($line->remise_percent); + } + } + + return $object; + } + + /** + * Validate fields before create or update object + * + * @param array $data Array with data to verify + * @return array + * @throws RestException + */ + private function _validate($data) + { + $reception = array(); + foreach (Shipments::$FIELDS as $field) { + if (!isset($data[$field])) { + throw new RestException(400, "$field field missing"); + } + $reception[$field] = $data[$field]; + } + return $reception; + } +} From 811b11cab255c4bd45b73a53766ab66d800a8d03 Mon Sep 17 00:00:00 2001 From: Faustin Date: Tue, 28 Jun 2022 16:33:00 +0200 Subject: [PATCH 111/367] NEW #21397 : added option to auto define barcode numbers for third-parties in barcode module setup --- htdocs/admin/barcode.php | 81 +++- .../mod_barcode_thirdparty_standard.php | 354 ++++++++++++++++++ 2 files changed, 434 insertions(+), 1 deletion(-) create mode 100644 htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php index ee0fcd5d130..d03d227470a 100644 --- a/htdocs/admin/barcode.php +++ b/htdocs/admin/barcode.php @@ -55,6 +55,16 @@ if ($action == 'setbarcodeproducton') { $res = dolibarr_del_const($db, "BARCODE_PRODUCT_ADDON_NUM", $conf->entity); } +if ($action == 'setbarcodethirdpartyon') { + $barcodenumberingmodule = GETPOST('value', 'alpha'); + $res = dolibarr_set_const($db, "BARCODE_THIRDPARTY_ADDON_NUM", $barcodenumberingmodule, 'chaine', 0, '', $conf->entity); + if ($barcodenumberingmodule == 'mod_barcode_thirdparty_standard' && empty($conf->global->BARCODE_STANDARD_THIRDPARTY_MASK)) { + $res = dolibarr_set_const($db, "BARCODE_STANDARD_THIRDPARTY_MASK", '020{000000000}', 'chaine', 0, '', $conf->entity); + } +} elseif ($action == 'setbarcodethirdpartyoff') { + $res = dolibarr_del_const($db, "BARCODE_THIRDPARTY_ADDON_NUM", $conf->entity); +} + if ($action == 'setcoder') { $coder = GETPOST('coder', 'alpha'); $code_id = GETPOST('code_id', 'int'); @@ -241,6 +251,66 @@ if ($conf->product->enabled) { print ''; } +// Select barcode numbering module +if ($conf->societe->enabled) { + print load_fiche_titre($langs->trans("BarCodeNumberManager")." (".$langs->trans("ThirdParty").")", '', ''); + + print '
'; + print '
'; + $searchpicto = $form->showFilterButtons('left'); + print $searchpicto; + print ''; print ''; @@ -826,10 +833,12 @@ if (!empty($arrayfields['t.tms']['checked'])) { print ''; -$searchpicto = $form->showFilterButtons(); -print $searchpicto; -print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print '
'; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($object->id, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print ''; @@ -1318,15 +1344,17 @@ while ($i < $imaxinloop) { print ''.$projectstatic->getLibStatut(5).''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($object->id, $arrayofselected)) { - $selected = 1; + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($object->id, $arrayofselected)) { + $selected = 1; + } + print ''; } - print ''; + print '
'.$langs->trans("DarkThemeMode").''; + if ($edit) { + print $form->selectarray('THEME_DARKMODEENABLED', $listofdarkmodes, isset($conf->global->THEME_DARKMODEENABLED) ? $conf->global->THEME_DARKMODEENABLED : 0); + } else { + print $listofdarkmodes[isset($conf->global->THEME_DARKMODEENABLED) ? $conf->global->THEME_DARKMODEENABLED : 0]; + } + print '
'.$langs->trans("MembersNature").''.$langs->trans("SubscriptionRequired").''.$langs->trans("Amount").''.$langs->trans("CanEditAmountShort").''.$langs->trans("VoteAllowed").''.$langs->trans("Status").' 
'; @@ -310,6 +313,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') { print ''.yn($objp->subscription).''.(is_null($objp->amount) || $objp->amount === '' ? '' : price($objp->amount)).''.yn($objp->caneditamount).''.yn($objp->vote).''.$membertype->getLibStatut(5).'
'.$langs->trans("CanEditAmountShort").''; + print $form->selectyesno("caneditamount", 0, 1); + print '
'.$langs->trans("VoteAllowed").''; print $form->selectyesno("vote", GETPOSTISSET("vote") ? GETPOST('vote', 'aZ09') : 1, 1); print '
'.$langs->trans("Subscription").''; - if (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { - print ''; - } else { - print ''; - print ''; + print '
'.$langs->trans("Subscription"); + if (!empty($conf->global->MEMBER_EXT_URL_SUBSCRIPTION_INFO)) { + print ' - '.$langs->trans("SeeHere").''; + } + print ''; + + if (empty($amount) && !empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { + $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; + } + + if (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT) || $caneditamount) { + print ''; + print ' '.$langs->trans("Currency".$conf->currency).' – '; + print $amount>0? $langs->trans("AnyAmountWithAdvisedAmount", $amount, $langs->trans("Currency".$conf->currency)): $langs->trans("AnyAmountWithoutAdvisedAmount"); + print ''; + } else { + print ''; + print ''; + print ' '.$langs->trans("Currency".$conf->currency); } - print ' '.$langs->trans("Currency".$conf->currency); print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + $dirbarcodenum = array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']); + + foreach ($dirbarcodenum as $dirroot) { + $dir = dol_buildpath($dirroot, 0); + + $handle = @opendir($dir); + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if (preg_match('/^mod_barcode_thirdparty_.*php$/', $file)) { + $file = substr($file, 0, dol_strlen($file) - 4); + + try { + dol_include_once($dirroot.$file.'.php'); + } catch (Exception $e) { + dol_syslog($e->getMessage(), LOG_ERR); + } + + $modBarCode = new $file(); + print ''; + print ''; + print '\n"; + + if (!empty($conf->global->BARCODE_THIRDPARTY_ADDON_NUM) && $conf->global->BARCODE_THIRDPARTY_ADDON_NUM == "$file") { + print ''; + } else { + print ''; + } + print ''; + print "\n"; + } + } + closedir($handle); + } + } + print "
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Status").''.$langs->trans("ShortInfo").'
'.(isset($modBarCode->name) ? $modBarCode->name : $modBarCode->nom)."\n"; + print $modBarCode->info($langs); + print ''.$modBarCode->getExample($langs)."'; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; + $s = $modBarCode->getToolTip($langs, null, -1); + print $form->textwithpicto('', $s, 1); + print '
\n"; + print '
'; +} /* * CHOIX ENCODAGE @@ -251,7 +321,16 @@ print load_fiche_titre($langs->trans("BarcodeEncodeModule"), '', ''); if (empty($conf->use_javascript_ajax)) { print ''; - print ''; + print '';if ($module->encodingIsSupported($obj->encoding)) { + // Build barcode on disk (not used, this is done to make debug easier) + $result = $module->writeBarCode($obj->example, $obj->encoding, 'Y'); + // Generate on the fly and output barcode with generator + $url = DOL_URL_ROOT.'/viewimage.php?modulepart=barcode&generator='.urlencode($obj->coder).'&code='.urlencode($obj->example).'&encoding='.urlencode($obj->encoding); + //print $url; + print ''; + } else { + print $langs->trans("FormatNotSupportedByGenerator"); + } print ''; } diff --git a/htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php b/htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php new file mode 100644 index 00000000000..42f8d9c3b50 --- /dev/null +++ b/htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php @@ -0,0 +1,354 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see https://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/barcode/mod_barcode_thirdparty_standard.php + * \ingroup barcode + * \brief File of class to manage barcode numbering with standard rule + */ + +require_once DOL_DOCUMENT_ROOT.'/core/modules/barcode/modules_barcode.class.php'; + + +/** + * Class to manage barcode with standard rule + */ +class mod_barcode_thirdparty_standard extends ModeleNumRefBarCode +{ + public $name = 'Standard'; // Model Name + + public $code_modifiable; // Editable code + + public $code_modifiable_invalide; // Modified code if it is invalid + + public $code_modifiable_null; // Modified code if it is null + + public $code_null; // Optional code + + /** + * Dolibarr version of the loaded document + * @var string + */ + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + + /** + * @var int Automatic numbering + */ + public $code_auto; + + public $searchcode; // Search string + + public $numbitcounter; // Number of digits the counter + + public $prefixIsRequired; // The prefix field of third party must be filled when using {pre} + + + /** + * Constructor + */ + public function __construct() + { + $this->code_null = 0; + $this->code_modifiable = 1; + $this->code_modifiable_invalide = 1; + $this->code_modifiable_null = 1; + $this->code_auto = 1; + $this->prefixIsRequired = 0; + } + + + /** Return description of module + * + * @param Translate $langs Object langs + * @return string Description of module + */ + public function info($langs) + { + global $conf, $mc; + global $form; + + $langs->load("thirdparties"); + + $disabled = ((!empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : ''); + + $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("BarCode"), $langs->transnoentities("BarCode")); + $tooltip .= $langs->trans("GenericMaskCodes3EAN"); + $tooltip .= ''.$langs->trans("Example").':
'; + $tooltip .= '020{000000000}? (for internal use)
'; + $tooltip .= '9771234{00000}? (example of ISSN code with prefix 1234)
'; + $tooltip .= '9791234{00000}? (example of ISMN code with prefix 1234)
'; + //$tooltip.=$langs->trans("GenericMaskCodes5"); + + // Mask parameter + //$texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + + $texte .= '
'.$langs->trans("Mask").' ('.$langs->trans("BarCodeModel").'):
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).' 
'; + $texte .= ''; + + return $texte; + } + + + /** + * Return an example of result returned by getNextValue + * + * @param Translate $langs Object langs + * @param Societe $objthirdparty Object third-party + * @return string Return string example + */ + public function getExample($langs, $objthirdparty = 0) + { + $examplebarcode = $this->getNextValue($objthirdparty, ''); + if (!$examplebarcode) { + $examplebarcode = $langs->trans('NotConfigured'); + } + if ($examplebarcode == "ErrorBadMask") { + $langs->load("errors"); + $examplebarcode = $langs->trans($examplebarcode); + } + + return $examplebarcode; + } + /** + * Return literal barcode type code from numerical rowid type of barcode + * + * @param Database $db Database + * @param int $type Type of barcode (EAN, ISBN, ...) as rowid + * @return string + */ + public function literalBarcodeType($db, $type = '') + { + global $conf; + $out = ''; + + $sql = "SELECT rowid, code, libelle as label"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_barcode_type"; + $sql .= " WHERE rowid = '".$db->escape($type)."'"; + $sql .= " AND entity = ".((int) $conf->entity); + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + + if ($num > 0) { + $obj = $db->fetch_object($result); + $out .= $obj->label; //take the label corresponding to the type rowid in the database + } + } else { + dol_print_error($db); + } + + return $out; + } + /** + * Return next value + * + * @param Societe $objthirdparty Object third-party + * @param string $type Type of barcode (EAN, ISBN, ...) + * @return string Value if OK, '' if module not configured, <0 if KO + */ + public function getNextValue($objthirdparty, $type = '') + { + global $db, $conf; + + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/barcode.lib.php'; // to be able to call function barcode_gen_ean_sum($ean) + + if (empty($type)) { + $type = $conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY; + } //get barcode type configuration for companies if $type not set + + // TODO + + // Get Mask value + $mask = ''; + if (!empty($conf->global->BARCODE_STANDARD_THIRDPARTY_MASK)) { + $mask = $conf->global->BARCODE_STANDARD_THIRDPARTY_MASK; + } + + if (empty($mask)) { + $this->error = 'NotConfigured'; + return ''; + } + + $field = 'barcode'; + $where = ''; + + $now = dol_now(); + + $numFinal = get_next_value($db, $mask, 'societe', $field, $where, '', $now); + //Begin barcode with key: for barcode with key (EAN13...) calculate and substitute the last character (* or ?) used in the mask by the key + if ((substr($numFinal, -1)=='*') or (substr($numFinal, -1)=='?')) { // if last mask character is * or ? a joker, probably we have to calculate a key as last character (EAN13...) + $literaltype = ''; + $literaltype = $this->literalBarcodeType($db, $type);//get literal_Barcode_Type + switch ($literaltype) { + case 'EAN13': //EAN13 rowid = 2 + if (strlen($numFinal)==13) {// be sure that the mask length is correct for EAN13 + $ean = substr($numFinal, 0, 12); //take first 12 digits + $eansum = barcode_gen_ean_sum($ean); + $ean .= $eansum; //substitute the las character by the key + $numFinal = $ean; + } + break; + // Other barcode cases with key could be written here + default: + break; + } + } + //End barcode with key + return $numFinal; + } + + + /** + * Check validity of code according to its rules + * + * @param DoliDB $db Database handler + * @param string $code Code to check/correct + * @param Societe $thirdparty Object third-party + * @param int $thirdparty_type 0 = customer/prospect , 1 = supplier + * @param string $type type of barcode (EAN, ISBN, ...) + * @return int 0 if OK + * -1 ErrorBadCustomerCodeSyntax + * -2 ErrorCustomerCodeRequired + * -3 ErrorCustomerCodeAlreadyUsed + * -4 ErrorPrefixRequired + */ + public function verif($db, &$code, $thirdparty, $thirdparty_type, $type) + { + global $conf; + + //var_dump($code.' '.$thirdparty->ref.' '.$thirdparty_type);exit; + + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + + $result = 0; + $code = strtoupper(trim($code)); + + if (empty($code) && $this->code_null && empty($conf->global->BARCODE_STANDARD_THIRDPARTY_MASK)) { + $result = 0; + } elseif (empty($code) && (!$this->code_null || !empty($conf->global->BARCODE_STANDARD_THIRDPARTY_MASK))) { + $result = -2; + } else { + if ($this->verif_syntax($code, $type) >= 0) { + $is_dispo = $this->verif_dispo($db, $code, $thirdparty); + if ($is_dispo <> 0) { + $result = -3; + } else { + $result = 0; + } + } else { + if (dol_strlen($code) == 0) { + $result = -2; + } else { + $result = -1; + } + } + } + + dol_syslog(get_class($this)."::verif type=".$thirdparty_type." result=".$result); + return $result; + } + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return if a code is used (by other element) + * + * @param DoliDB $db Handler acces base + * @param string $code Code to check + * @param Societe $thirdparty Objet third-party + * @return int 0 if available, <0 if KO + */ + public function verif_dispo($db, $code, $thirdparty) + { + // phpcs:enable + $sql = "SELECT barcode FROM ".MAIN_DB_PREFIX."societe"; + $sql .= " WHERE barcode = '".$db->escape($code)."'"; + if ($thirdparty->id > 0) { + $sql .= " AND rowid <> ".$thirdparty->id; + } + + $resql = $db->query($sql); + if ($resql) { + if ($db->num_rows($resql) == 0) { + return 0; + } else { + return -1; + } + } else { + return -2; + } + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return if a barcode value match syntax + * + * @param string $codefortest Code to check syntax + * @param string $typefortest Type of barcode (ISBN, EAN, ...) + * @return int 0 if OK, <0 if KO + */ + public function verif_syntax($codefortest, $typefortest) + { + // phpcs:enable + global $conf; + + $result = 0; + + // Get Mask value + $mask = empty($conf->global->BARCODE_STANDARD_THIRDPARTY_MASK) ? '' : $conf->global->BARCODE_STANDARD_THIRDPARTY_MASK; + if (!$mask) { + $this->error = 'NotConfigured'; + return -1; + } + + dol_syslog(get_class($this).'::verif_syntax codefortest='.$codefortest." typefortest=".$typefortest); + + $newcodefortest = $codefortest; + + // Special case, if mask is on 12 digits instead of 13, we remove last char into code to test + if (in_array($typefortest, array('EAN13', 'ISBN'))) { // We remove the CRC char not included into mask + if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i', $mask, $reg)) { + if (strlen($reg[1]) == 12) { + $newcodefortest = substr($newcodefortest, 0, 12); + } + dol_syslog(get_class($this).'::verif_syntax newcodefortest='.$newcodefortest); + } + } + + $result = check_value($mask, $newcodefortest); + if (is_string($result)) { + $this->error = $result; + return -1; + } + + return $result; + } +} From 3f7fe8d68894d371939be286b15cb00e69e79012 Mon Sep 17 00:00:00 2001 From: Faustin Date: Tue, 28 Jun 2022 16:39:34 +0200 Subject: [PATCH 112/367] NEW #21397 : small fix --- htdocs/admin/barcode.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php index d03d227470a..ce394f24d76 100644 --- a/htdocs/admin/barcode.php +++ b/htdocs/admin/barcode.php @@ -321,7 +321,8 @@ print load_fiche_titre($langs->trans("BarcodeEncodeModule"), '', ''); if (empty($conf->use_javascript_ajax)) { print '
'; - print '';if ($module->encodingIsSupported($obj->encoding)) { + print ''; + if ($module->encodingIsSupported($obj->encoding)) { // Build barcode on disk (not used, this is done to make debug easier) $result = $module->writeBarCode($obj->example, $obj->encoding, 'Y'); // Generate on the fly and output barcode with generator From 23cbb5212d1eed8e8fe067a8f0e6829a9304354c Mon Sep 17 00:00:00 2001 From: Faustin Date: Tue, 28 Jun 2022 16:40:59 +0200 Subject: [PATCH 113/367] NEW #21397 : code intrusion --- htdocs/admin/barcode.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php index ce394f24d76..57c32d79318 100644 --- a/htdocs/admin/barcode.php +++ b/htdocs/admin/barcode.php @@ -322,16 +322,6 @@ print load_fiche_titre($langs->trans("BarcodeEncodeModule"), '', ''); if (empty($conf->use_javascript_ajax)) { print ''; print ''; - if ($module->encodingIsSupported($obj->encoding)) { - // Build barcode on disk (not used, this is done to make debug easier) - $result = $module->writeBarCode($obj->example, $obj->encoding, 'Y'); - // Generate on the fly and output barcode with generator - $url = DOL_URL_ROOT.'/viewimage.php?modulepart=barcode&generator='.urlencode($obj->coder).'&code='.urlencode($obj->example).'&encoding='.urlencode($obj->encoding); - //print $url; - print ''; - } else { - print $langs->trans("FormatNotSupportedByGenerator"); - } print ''; } From bc66c37a083b6b185d834078329a25b5443a78b5 Mon Sep 17 00:00:00 2001 From: Faustin Date: Tue, 28 Jun 2022 18:52:20 +0200 Subject: [PATCH 114/367] hook fix --- htdocs/barcode/codeinit.php | 177 +++++++++++++++--- .../mod_barcode_thirdparty_standard.php | 6 +- 2 files changed, 159 insertions(+), 24 deletions(-) diff --git a/htdocs/barcode/codeinit.php b/htdocs/barcode/codeinit.php index b4e365fe018..65ca10a8794 100644 --- a/htdocs/barcode/codeinit.php +++ b/htdocs/barcode/codeinit.php @@ -35,7 +35,8 @@ $month = dol_print_date($now, '%m'); $day = dol_print_date($now, '%d'); $forbarcode = GETPOST('forbarcode'); $fk_barcode_type = GETPOST('fk_barcode_type'); -$eraseallbarcode = GETPOST('eraseallbarcode'); +$eraseallproductbarcode = GETPOST('eraseallproductbarcode'); +$eraseallthirdpartybarcode = GETPOST('eraseallthirdpartybarcode'); $action = GETPOST('action', 'aZ09'); @@ -43,6 +44,7 @@ $producttmp = new Product($db); $thirdpartytmp = new Societe($db); $modBarCodeProduct = ''; +$modBarCodeThirdparty = ''; $maxperinit = 1000; @@ -51,6 +53,106 @@ $maxperinit = 1000; * Actions */ +// Define barcode template for third-party +if (!empty($conf->global->BARCODE_THIRDPARTY_ADDON_NUM)) { + $dirbarcodenum = array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']); + + foreach ($dirbarcodenum as $dirroot) { + $dir = dol_buildpath($dirroot, 0); + + $handle = @opendir($dir); + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if (preg_match('/^mod_barcode_thirdparty_.*php$/', $file)) { + $file = substr($file, 0, dol_strlen($file) - 4); + + try { + dol_include_once($dirroot.$file.'.php'); + } catch (Exception $e) { + dol_syslog($e->getMessage(), LOG_ERR); + } + + $modBarCodeThirdparty = new $file(); + break; + } + } + closedir($handle); + } + } +} + +if ($action == 'initbarcodethirdparties') { + if (!is_object($modBarCodeThirdparty)) { + $error++; + setEventMessages($langs->trans("NoBarcodeNumberingTemplateDefined"), null, 'errors'); + } + + if (!$error) { + $thirdpartystatic = new Societe($db); + + $db->begin(); + + $nbok = 0; + if (!empty($eraseallthirdpartybarcode)) { + $sql = "UPDATE ".MAIN_DB_PREFIX."societe"; + $sql .= " SET barcode = NULL"; + $resql = $db->query($sql); + if ($resql) { + setEventMessages($langs->trans("AllBarcodeReset"), null, 'mesgs'); + } else { + $error++; + dol_print_error($db); + } + } else { + $sql = "SELECT rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe"; + $sql .= " WHERE barcode IS NULL or barcode = ''"; + $sql .= $db->order("datec", "ASC"); + $sql .= $db->plimit($maxperinit); + + dol_syslog("codeinit", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + + $i = 0; $nbok = $nbtry = 0; + while ($i < min($num, $maxperinit)) { + $obj = $db->fetch_object($resql); + if ($obj) { + $thirdpartystatic->id = $obj->rowid; + $nextvalue = $modBarCodeThirdparty->getNextValue($thirdpartystatic, ''); + + $result = $thirdpartystatic->setValueFrom('barcode', $nextvalue, '', '', 'text', '', $user, 'THIRDPARTY_MODIFY'); + + $nbtry++; + if ($result > 0) { + $nbok++; + } + } + + $i++; + } + } else { + $error++; + dol_print_error($db); + } + + if (!$error) { + setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + } + } + + if (!$error) { + //$db->rollback(); + $db->commit(); + } else { + $db->rollback(); + } + } + + $action = ''; +} + // Define barcode template for products if (!empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) { $dirbarcodenum = array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']); @@ -91,7 +193,7 @@ if ($action == 'initbarcodeproducts') { $db->begin(); $nbok = 0; - if (!empty($eraseallbarcode)) { + if (!empty($eraseallproductbarcode)) { $sql = "UPDATE ".MAIN_DB_PREFIX."product"; $sql .= " SET barcode = NULL"; $resql = $db->query($sql); @@ -155,7 +257,6 @@ if ($action == 'initbarcodeproducts') { } - /* * View */ @@ -189,7 +290,11 @@ print '
'; // For thirdparty if (isModEnabled('societe')) { - $nbno = $nbtotal = 0; + print ''; + print ''; + print ''; + print ''; + $nbthirdpartyno = $nbthirdpartytotal = 0; print load_fiche_titre($langs->trans("BarcodeInitForThirdparties"), '', 'company'); @@ -198,7 +303,7 @@ if (isModEnabled('societe')) { $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); - $nbno = $obj->nb; + $nbthirdpartyno = $obj->nb; } else { dol_print_error($db); } @@ -207,22 +312,46 @@ if (isModEnabled('societe')) { $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); - $nbtotal = $obj->nb; + $nbthirdpartytotal = $obj->nb; } else { dol_print_error($db); } - print $langs->trans("CurrentlyNWithoutBarCode", $nbno, $nbtotal, $langs->transnoentitiesnoconv("ThirdParties")).'
'."\n"; + print $langs->trans("CurrentlyNWithoutBarCode", $nbthirdpartyno, $nbthirdpartytotal, $langs->transnoentitiesnoconv("ThirdParties")).'
'."\n"; - print '
'; + $disabledthirdparty = $disabledthirdparty1 = 0; + + if (is_object($modBarCodeThirdparty)) { + print $langs->trans("BarCodeNumberManager").": "; + $objthirdparty = new Societe($db); + print ''.(isset($modBarCodeThirdparty->name) ? $modBarCodeThirdparty->name : $modBarCodeThirdparty->nom).' - '.$langs->trans("NextValue").': '.$modBarCodeThirdparty->getNextValue($objthirdparty).'
'; + $disabledthirdparty = 0; + } else { + $disabledthirdparty = 1; + $titleno = $langs->trans("NoBarcodeNumberingTemplateDefined"); + print ''.$langs->trans("NoBarcodeNumberingTemplateDefined").' ('.$langs->trans("ToGenerateCodeDefineAutomaticRuleFirst").')
'; + } + if (empty($nbthirdpartyno)) { + $disabledthirdparty1 = 1; + } + + $moretagsthirdparty1 = (($disabledthirdparty || $disabledthirdparty1) ? ' disabled title="'.dol_escape_htmltag($titleno).'"' : ''); + print '
'; + $moretagsthirdparty2 = (($nbthirdpartyno == $nbthirdpartytotal) ? ' disabled' : ''); + print '   '; + print ''; print '



'; + print ''; } // For products if ($conf->product->enabled || $conf->product->service) { + print '
'; + print ''; + print ''; + print ''; + // Example 1 : Adding jquery code print ''; - $nbno = $nbtotal = 0; + $nbproductno = $nbproducttotal = 0; print load_fiche_titre($langs->trans("BarcodeInitForProductsOrServices"), '', 'product'); print '
'."\n"; @@ -247,7 +376,7 @@ if ($conf->product->enabled || $conf->product->service) { $i = 0; while ($i < $num) { $obj = $db->fetch_object($resql); - $nbno += $obj->nb; + $nbproductno += $obj->nb; $i++; } @@ -259,35 +388,38 @@ if ($conf->product->enabled || $conf->product->service) { $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); - $nbtotal = $obj->nb; + $nbproducttotal = $obj->nb; } else { dol_print_error($db); } - print $langs->trans("CurrentlyNWithoutBarCode", $nbno, $nbtotal, $langs->transnoentitiesnoconv("ProductsOrServices")).'
'."\n"; + print $langs->trans("CurrentlyNWithoutBarCode", $nbproductno, $nbproducttotal, $langs->transnoentitiesnoconv("ProductsOrServices")).'
'."\n"; + + $disabledproduct = $disabledproduct1 = 0; if (is_object($modBarCodeProduct)) { print $langs->trans("BarCodeNumberManager").": "; $objproduct = new Product($db); print ''.(isset($modBarCodeProduct->name) ? $modBarCodeProduct->name : $modBarCodeProduct->nom).' - '.$langs->trans("NextValue").': '.$modBarCodeProduct->getNextValue($objproduct).'
'; - $disabled = 0; + $disabledproduct = 0; } else { - $disabled = 1; + $disabledproduct = 1; $titleno = $langs->trans("NoBarcodeNumberingTemplateDefined"); print ''.$langs->trans("NoBarcodeNumberingTemplateDefined").' ('.$langs->trans("ToGenerateCodeDefineAutomaticRuleFirst").')
'; } - if (empty($nbno)) { - $disabled1 = 1; + if (empty($nbproductno)) { + $disabledproduct1 = 1; } print '
'; //print ' '.$langs->trans("ResetBarcodeForAllRecords").'
'; - $moretags1 = (($disabled || $disabled1) ? ' disabled title="'.dol_escape_htmltag($titleno).'"' : ''); - print ''; - $moretags2 = (($nbno == $nbtotal) ? ' disabled' : ''); + $moretagsproduct1 = (($disabledproduct || $disabledproduct1) ? ' disabled title="'.dol_escape_htmltag($titleno).'"' : ''); + print ''; + $moretagsproduct2 = (($nbproductno == $nbproducttotal) ? ' disabled' : ''); print '   '; - print ''; + print ''; print '



'; + print '
'; } @@ -297,7 +429,6 @@ print $langs->trans("ClickHereToGoTo").' : '; //print '
'; -print '
'; -print ''; -print ''; -print ''; - print '
'; + + +// Example 1 : Adding jquery code +print ''; + + // For thirdparty if (isModEnabled('societe')) { print ''; @@ -352,13 +357,6 @@ if ($conf->product->enabled || $conf->product->service) { print ''; print ''; - // Example 1 : Adding jquery code - print ''; - $nbproductno = $nbproducttotal = 0; print load_fiche_titre($langs->trans("BarcodeInitForProductsOrServices"), '', 'product'); From ea0c710104d7b6cc7f0d31d30c14d939234989e6 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Wed, 29 Jun 2022 00:23:27 +0200 Subject: [PATCH 116/367] dopayment string fix --- htdocs/public/payment/newpayment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index b61a2e22a06..ff53ccf0e09 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -1596,7 +1596,7 @@ if ($source == 'member' || $source == 'membersubscription') { print ''; print $form->selectarray("typeid", $adht->liste_array(1), $member->typeid, 0, 0, 0, 'onchange="window.location.replace(\''.$urlwithroot.'/public/payment/newpayment.php?source='.urlencode($source).'&ref='.urlencode($ref).'&amount='.urlencode($amount).'&typeid=\' + this.value + \'&securekey='.urlencode($SECUREKEY).'\');"', 0, 0, 0, '', '', 1); print "\n"; - } elseif ($action == dopayment) { + } elseif ($action == 'dopayment') { print ''.$langs->trans("NewMemberType"); print ''.dol_escape_htmltag($member->type); print ''; From 759900bccee95b31e7684b2d69d93370d0e176ed Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Wed, 29 Jun 2022 00:27:18 +0200 Subject: [PATCH 117/367] No longer allow to edit amount in the payment step If amount is editable, edition has been done in the previous screen in public/members/new.php It also allows the possibility to prevent the visitor from doing a >0 payment if this is not wanted. --- htdocs/langs/en_US/members.lang | 1 + htdocs/langs/fr_FR/members.lang | 1 + htdocs/public/payment/newpayment.php | 61 ++++++---------------------- 3 files changed, 15 insertions(+), 48 deletions(-) diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index e552755f705..d9af9c9c350 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -202,6 +202,7 @@ AmountOfSubscriptions=Amount collected from contributions TurnoverOrBudget=Turnover (for a company) or Budget (for a foundation) DefaultAmount=Default amount of contribution CanEditAmount=Visitor can choose/edit amount of its contribution +AmountIsLowerToMinimumNotice=sur un dû total de %s MEMBER_NEWFORM_PAYONLINE=Jump on integrated online payment page ByProperties=By nature MembersStatisticsByProperties=Members statistics by nature diff --git a/htdocs/langs/fr_FR/members.lang b/htdocs/langs/fr_FR/members.lang index 5f67cc681ab..9cf2f25a2b0 100644 --- a/htdocs/langs/fr_FR/members.lang +++ b/htdocs/langs/fr_FR/members.lang @@ -199,6 +199,7 @@ AmountOfSubscriptions=Montant des cotisations TurnoverOrBudget=Chiffre affaire (pour société) ou Budget (asso ou collectivité) DefaultAmount=Montant par défaut de la cotisation CanEditAmount=Le visiteur peut modifier / choisir le montant de sa cotisation +AmountIsLowerToMinimumNotice=sur un dû total de %s AnyAmountWithAdvisedAmount=Montant libre avec un montant recommandé de %s %s AnyAmountWithoutAdvisedAmount=Montant libre CanEditAmountShort=Montant libre diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index ff53ccf0e09..1c3c0202b23 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -1500,7 +1500,7 @@ if ($source == 'member' || $source == 'membersubscription') { $amount = $adht->amount; } - $amount = price2num($amount, 'MT'); + $amount = max(0, price2num($amount, 'MT')); } if (GETPOST('fulltag', 'alpha')) { @@ -1611,57 +1611,22 @@ if ($source == 'member' || $source == 'membersubscription') { // Amount print ''.$langs->trans("Amount"); - if (empty($amount)) { - if (empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { - print ' ('.$langs->trans("ToComplete"); - } - if (!empty($conf->global->MEMBER_EXT_URL_SUBSCRIPTION_INFO)) { - print ' -
'.$langs->trans("SeeHere").''; - } - if (empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { - print ')'; - } + // This place no longer allows amount edition + if (!empty($conf->global->MEMBER_EXT_URL_SUBSCRIPTION_INFO)) { + print ' - '.$langs->trans("SeeHere").''; } print ''; - $valtoshow = ''; - if (empty($amount) || !is_numeric($amount)) { - $valtoshow = price2num(GETPOST("newamount", 'alpha'), 'MT'); - // force default subscription amount to value defined into constant... - if (empty($valtoshow)) { - if (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { - if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { - $valtoshow = $conf->global->MEMBER_NEWFORM_AMOUNT; - } - } else { - if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { - $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; - } - } - } + if (!empty($conf->global->MEMBER_MIN_AMOUNT) && $amount) { + $amount = max(0, $conf->global->MEMBER_MIN_AMOUNT, $amount); } - if (empty($amount) || !is_numeric($amount)) { - //$valtoshow=price2num(GETPOST("newamount",'alpha'),'MT'); - if (!empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) { - $valtoshow = max($conf->global->MEMBER_MIN_AMOUNT, $valtoshow); - } - print ''; - if (empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { - print ''; - print ''; - } else { - print ''; - } - print ' '.$langs->trans("Currency".$currency).''; - } else { - $valtoshow = $amount; - if (!empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) { - $valtoshow = max($conf->global->MEMBER_MIN_AMOUNT, $valtoshow); - $amount = $valtoshow; - } - print ''.price($valtoshow, 1, $langs, 1, -1, -1, $currency).''; // Price with currency - print ''; - print ''; + print ''.price($amount, 1, $langs, 1, -1, -1, $currency).''; // Price with currency + $caneditamount = !empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT) || $adht->caneditamount; + $minimumamount = empty($conf->global->MEMBER_MIN_AMOUNT)? $adht->amount : max($conf->global->MEMBER_MIN_AMOUNT, $adht->amount > $amount); + if(!$caneditamount && $minimumamount > $amount) { + print ' '. $langs->trans("AmountIsLowerToMinimumNotice", price($adht->amount, 1, $langs, 1, -1, -1, $currency)); } + + print ''; print ''; print ''."\n"; From f8af181cee81767fd2f0f68cbd30c59f438951d5 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Wed, 29 Jun 2022 00:28:33 +0200 Subject: [PATCH 118/367] Label clarification following the new per-type setting "CanEditAmount" --- htdocs/langs/en_US/members.lang | 2 +- htdocs/langs/fr_FR/members.lang | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index d9af9c9c350..70b207c2b88 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -201,7 +201,7 @@ NbOfSubscriptions=Number of contributions AmountOfSubscriptions=Amount collected from contributions TurnoverOrBudget=Turnover (for a company) or Budget (for a foundation) DefaultAmount=Default amount of contribution -CanEditAmount=Visitor can choose/edit amount of its contribution +CanEditAmount=Visitor can choose/edit amount of its contribution regardless of the member type AmountIsLowerToMinimumNotice=sur un dû total de %s MEMBER_NEWFORM_PAYONLINE=Jump on integrated online payment page ByProperties=By nature diff --git a/htdocs/langs/fr_FR/members.lang b/htdocs/langs/fr_FR/members.lang index 9cf2f25a2b0..9c3c51d52c6 100644 --- a/htdocs/langs/fr_FR/members.lang +++ b/htdocs/langs/fr_FR/members.lang @@ -198,7 +198,7 @@ NbOfSubscriptions=Nombre de cotisations AmountOfSubscriptions=Montant des cotisations TurnoverOrBudget=Chiffre affaire (pour société) ou Budget (asso ou collectivité) DefaultAmount=Montant par défaut de la cotisation -CanEditAmount=Le visiteur peut modifier / choisir le montant de sa cotisation +CanEditAmount=Le visiteur peut modifier / choisir le montant de sa cotisation quel que soit le type d'adhésion AmountIsLowerToMinimumNotice=sur un dû total de %s AnyAmountWithAdvisedAmount=Montant libre avec un montant recommandé de %s %s AnyAmountWithoutAdvisedAmount=Montant libre From e7058c253e6b5014bec7e77b44a3e80301048038 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Wed, 29 Jun 2022 03:25:33 +0200 Subject: [PATCH 119/367] NEW: Table of membership types --- htdocs/langs/en_US/members.lang | 3 + htdocs/langs/fr_FR/members.lang | 3 + htdocs/public/members/new.php | 580 ++++++++++++++++++-------------- 3 files changed, 339 insertions(+), 247 deletions(-) diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index 70b207c2b88..972be559eec 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -74,6 +74,9 @@ Subscription=Contribution AnyAmountWithAdvisedAmount=Any amount with a recommended amount of %s %s AnyAmountWithoutAdvisedAmount=Any amount CanEditAmountShort=Any amount +CanEditAmountShortForValues=recommended, any amount +MembershipDuration=Duration +GetMembershipButtonLabel=Get membership Subscriptions=Contributions SubscriptionLate=Late SubscriptionNotReceived=Contribution never received diff --git a/htdocs/langs/fr_FR/members.lang b/htdocs/langs/fr_FR/members.lang index 9c3c51d52c6..a5a76c9be55 100644 --- a/htdocs/langs/fr_FR/members.lang +++ b/htdocs/langs/fr_FR/members.lang @@ -202,6 +202,9 @@ CanEditAmount=Le visiteur peut modifier / choisir le montant de sa cotisation qu AmountIsLowerToMinimumNotice=sur un dû total de %s AnyAmountWithAdvisedAmount=Montant libre avec un montant recommandé de %s %s AnyAmountWithoutAdvisedAmount=Montant libre +CanEditAmountShortForValues=conseillé, montant libre +MembershipDuration=Durée +GetMembershipButtonLabel=Adhérer CanEditAmountShort=Montant libre MEMBER_NEWFORM_PAYONLINE=Rediriger sur la page intégrée de paiement en ligne ByProperties=Par nature diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index f6957502284..6f490ca5b66 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -69,6 +69,7 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php'; // Init vars $errmsg = ''; @@ -474,268 +475,353 @@ dol_htmloutput_errors($errmsg); print ''."\n"; print ''; print ''; -print ''; -print ''; -print '
'; +if (!empty($conf->global->MEMBER_NEWFORM_FORCETYPE) || $action == 'create') { + print ''; + print '
'; + print '
'.$langs->trans("FieldsWithAreMandatory", '*').'
'; + //print $langs->trans("FieldsWithIsForPublic",'**').'
'; -print '
'.$langs->trans("FieldsWithAreMandatory", '*').'
'; -//print $langs->trans("FieldsWithIsForPublic",'**').'
'; - -print dol_get_fiche_head(''); - -print ''; - - -print ''."\n"; - -// Type -if (empty($conf->global->MEMBER_NEWFORM_FORCETYPE)) { - $listoftype = $adht->liste_array(); - $tmp = array_keys($listoftype); - $defaulttype = ''; - $isempty = 1; - if (count($listoftype) == 1) { - $defaulttype = $tmp[0]; - $isempty = 0; - } - print ''."\n"; -} else { - $adht->fetch($conf->global->MEMBER_NEWFORM_FORCETYPE); - print ''; -} - -// Moral/Physic attribute -$morphys["phy"] = $langs->trans("Physical"); -$morphys["mor"] = $langs->trans("Moral"); -if (empty($conf->global->MEMBER_NEWFORM_FORCEMORPHY)) { - print ''."\n"; -} else { - print $morphys[$conf->global->MEMBER_NEWFORM_FORCEMORPHY]; - print ''; -} - -// Company -print ''."\n"; -// Title -print ''."\n"; -// Lastname -print ''."\n"; -// Firstname -print ''."\n"; -// EMail -print ''."\n"; -// Login -if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print ''."\n"; - print ''."\n"; - print ''."\n"; -} -// Gender -print ''; -print ''; -// Address -print ''."\n"; -// Zip / Town -print ''; -// Country -print ''; -// State -if (empty($conf->global->SOCIETE_DISABLE_STATE)) { - print ''; -} -// Birthday -print ''."\n"; -// Photo -print ''."\n"; -// Public -print ''."\n"; -// Other attributes -$tpl_context = 'public'; // define template context to public -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; -// Comments -print ''; -print ''; -print ''; -print ''."\n"; - -// Add specific fields used by Dolibarr foundation for example -// TODO Move this into generic feature. -if (!empty($conf->global->MEMBER_NEWFORM_DOLIBARRTURNOVER)) { - $arraybudget = array('50'=>'<= 100 000', '100'=>'<= 200 000', '200'=>'<= 500 000', '300'=>'<= 1 500 000', '600'=>'<= 3 000 000', '1000'=>'<= 5 000 000', '2000'=>'5 000 000+'); - print ''."\n"; -} + jQuery(document).ready(function () { + jQuery(document).ready(function () { + function initmorphy() + { + console.log("Call initmorphy"); + if (jQuery("#morphy").val() == \'phy\') { + jQuery("#trcompany").hide(); + } + if (jQuery("#morphy").val() == \'mor\') { + jQuery("#trcompany").show(); + } + }; + initmorphy(); + jQuery("#morphy").change(function() { + initmorphy(); + }); + jQuery("#selectcountry_id").change(function() { + document.newmember.action.value="create"; + document.newmember.submit(); + }); + jQuery("#typeid").change(function() { + document.newmember.action.value="create"; + document.newmember.submit(); + }); + }); + }); + '; -if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { - $amount = 0; - $typeid = $conf->global->MEMBER_NEWFORM_FORCETYPE ? $conf->global->MEMBER_NEWFORM_FORCETYPE : GETPOST('typeid', 'int'); - // Set amount for the subscription: - // - First check the amount of the member type. - $amountbytype = $adht->amountByType(1); // Load the array of amount per type - $amount = empty($amountbytype[$typeid]) ? (isset($amount) ? $amount : 0) : $amountbytype[$typeid]; - // - If not found, take the default amount - if (empty($amount) && !empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { - $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; - } - // - If not set, we accept ot have amount defined as parameter (for backward compatibility). - if (empty($amount)) { - $amount = (GETPOST('amount') ? price2num(GETPOST('amount', 'alpha'), 'MT', 2) : ''); - } + print '
'.$langs->trans("Type").' *'; - print $form->selectarray("typeid", $adht->liste_array(1), GETPOST('typeid') ? GETPOST('typeid') : $defaulttype, $isempty); - print '
'.$langs->trans('MemberNature').' *'."\n"; - print $form->selectarray("morphy", $morphys, GETPOST('morphy'), 1); - print '
'.$langs->trans("Company").''; -print img_picto('', 'company', 'class="pictofixedwidth"'); -print '
'.$langs->trans('UserTitle').''; -print $formcompany->select_civility(GETPOST('civility_id'), 'civility_id').'
'.$langs->trans("Lastname").' *
'.$langs->trans("Firstname").' *
'.$langs->trans("Email").($conf->global->ADHERENT_MAIL_REQUIRED ? ' *' : '').''; -//print img_picto('', 'email', 'class="pictofixedwidth"'); -print '
'.$langs->trans("Login").' *
'.$langs->trans("Password").' *
'.$langs->trans("PasswordAgain").' *
'.$langs->trans("Gender").''; -$arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman")); -print $form->selectarray('gender', $arraygender, GETPOST('gender') ?GETPOST('gender') : $object->gender, 1); -print '
'.$langs->trans("Address").''."\n"; -print '
'.$langs->trans('Zip').' / '.$langs->trans('Town').''; -print $formcompany->select_ziptown(GETPOST('zipcode'), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 0, 1, '', 'width75'); -print ' / '; -print $formcompany->select_ziptown(GETPOST('town'), 'town', array('zipcode', 'selectcountry_id', 'state_id'), 0, 1); -print '
'.$langs->trans('Country').''; -print img_picto('', 'country', 'class="pictofixedwidth"'); -$country_id = GETPOST('country_id', 'int'); -if (!$country_id && !empty($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE)) { - $country_id = getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs); -} -if (!$country_id && !empty($conf->geoipmaxmind->enabled)) { - $country_code = dol_user_country(); - //print $country_code; - if ($country_code) { - $new_country_id = getCountry($country_code, 3, $db, $langs); - //print 'xxx'.$country_code.' - '.$new_country_id; - if ($new_country_id) { - $country_id = $new_country_id; - } - } -} -$country_code = getCountry($country_id, 2, $db, $langs); -print $form->select_country($country_id, 'country_id'); -print '
'.$langs->trans('State').''; - if ($country_code) { - print $formcompany->select_state(GETPOST("state_id"), $country_code); - } - print '
'.$langs->trans("DateOfBirth").''; -print $form->selectDate($birthday, 'birth', 0, 0, 1, "newmember", 1, 0); -print '
'.$langs->trans("URLPhoto").'
'.$langs->trans("Public").'
'.$langs->trans("Comments").'
'.$langs->trans("TurnoverOrBudget").' *'; - print $form->selectarray('budget', $arraybudget, GETPOST('budget'), 1); - print ' € or $'; + print dol_get_fiche_head(''); print ''; - print '
'."\n"; - // Clean the amount - $amount = price2num($amount); - $adht = new AdherentType($db); - $adht->fetch($typeid); - $caneditamount = $adht->caneditamount; - $showedamount = $amount>0? $amount: 0; - // $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal', 'paybox' or 'stripe' - print ''."\n"; } else { - print ''; - print ''; - print ' '.$langs->trans("Currency".$conf->currency); + $adht->fetch($conf->global->MEMBER_NEWFORM_FORCETYPE); + print ''; } + + // Moral/Physic attribute + $morphys["phy"] = $langs->trans("Physical"); + $morphys["mor"] = $langs->trans("Moral"); + if (empty($conf->global->MEMBER_NEWFORM_FORCEMORPHY)) { + print ''."\n"; + } else { + print $morphys[$conf->global->MEMBER_NEWFORM_FORCEMORPHY]; + print ''; + } + + // Company + print ''."\n"; + // Title + print ''."\n"; + // Lastname + print ''."\n"; + // Firstname + print ''."\n"; + // EMail + print ''."\n"; + // Login + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { + print ''."\n"; + print ''."\n"; + print ''."\n"; + } + // Gender + print ''; + print ''; + // Address + print ''."\n"; + // Zip / Town + print ''; + // Country + print ''; + // State + if (empty($conf->global->SOCIETE_DISABLE_STATE)) { + print ''; + } + // Birthday + print ''."\n"; + // Photo + print ''."\n"; + // Public + print ''."\n"; + // Other attributes + $tpl_context = 'public'; // define template context to public + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; + // Comments + print ''; + print ''; + print ''; + print ''."\n"; + + // Add specific fields used by Dolibarr foundation for example + // TODO Move this into generic feature. + if (!empty($conf->global->MEMBER_NEWFORM_DOLIBARRTURNOVER)) { + $arraybudget = array('50'=>'<= 100 000', '100'=>'<= 200 000', '200'=>'<= 500 000', '300'=>'<= 1 500 000', '600'=>'<= 3 000 000', '1000'=>'<= 5 000 000', '2000'=>'5 000 000+'); + print ''."\n"; + } + + if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { + $amount = 0; + $typeid = $conf->global->MEMBER_NEWFORM_FORCETYPE ? $conf->global->MEMBER_NEWFORM_FORCETYPE : GETPOST('typeid', 'int'); + + // Set amount for the subscription: + // - First check the amount of the member type. + $amountbytype = $adht->amountByType(1); // Load the array of amount per type + $amount = empty($amountbytype[$typeid]) ? (isset($amount) ? $amount : 0) : $amountbytype[$typeid]; + // - If not found, take the default amount + if (empty($amount) && !empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { + $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; + } + // - If not set, we accept ot have amount defined as parameter (for backward compatibility). + if (empty($amount)) { + $amount = (GETPOST('amount') ? price2num(GETPOST('amount', 'alpha'), 'MT', 2) : ''); + } + + // Clean the amount + $amount = price2num($amount); + $adht = new AdherentType($db); + $adht->fetch($typeid); + $caneditamount = $adht->caneditamount; + $showedamount = $amount>0? $amount: 0; + // $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal', 'paybox' or 'stripe' + print ''; + } + + print "
'.$langs->trans("Subscription"); - if (!empty($conf->global->MEMBER_EXT_URL_SUBSCRIPTION_INFO)) { - print ' - '.$langs->trans("SeeHere").''; - } - print ''; - - if (empty($amount) && !empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { - $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; - } - - if (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT) || $caneditamount) { - print ''; - print ' '.$langs->trans("Currency".$conf->currency).' – '; - print $amount>0? $langs->trans("AnyAmountWithAdvisedAmount", $amount, $langs->trans("Currency".$conf->currency)): $langs->trans("AnyAmountWithoutAdvisedAmount"); - print ''; + // Type + if (empty($conf->global->MEMBER_NEWFORM_FORCETYPE)) { + $listoftype = $adht->liste_array(); + $tmp = array_keys($listoftype); + $defaulttype = ''; + $isempty = 1; + if (count($listoftype) == 1) { + $defaulttype = $tmp[0]; + $isempty = 0; + } + print '
'.$langs->trans("Type").' *'; + print $form->selectarray("typeid", $adht->liste_array(1), GETPOST('typeid') ? GETPOST('typeid') : $defaulttype, $isempty); + print '
'.$langs->trans('MemberNature').' *'."\n"; + print $form->selectarray("morphy", $morphys, GETPOST('morphy'), 1); + print '
'.$langs->trans("Company").''; + print img_picto('', 'company', 'class="pictofixedwidth"'); + print '
'.$langs->trans('UserTitle').''; + print $formcompany->select_civility(GETPOST('civility_id'), 'civility_id').'
'.$langs->trans("Lastname").' *
'.$langs->trans("Firstname").' *
'.$langs->trans("Email").($conf->global->ADHERENT_MAIL_REQUIRED ? ' *' : '').''; + //print img_picto('', 'email', 'class="pictofixedwidth"'); + print '
'.$langs->trans("Login").' *
'.$langs->trans("Password").' *
'.$langs->trans("PasswordAgain").' *
'.$langs->trans("Gender").''; + $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman")); + print $form->selectarray('gender', $arraygender, GETPOST('gender') ?GETPOST('gender') : $object->gender, 1); print '
'.$langs->trans("Address").''."\n"; + print '
'.$langs->trans('Zip').' / '.$langs->trans('Town').''; + print $formcompany->select_ziptown(GETPOST('zipcode'), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 0, 1, '', 'width75'); + print ' / '; + print $formcompany->select_ziptown(GETPOST('town'), 'town', array('zipcode', 'selectcountry_id', 'state_id'), 0, 1); + print '
'.$langs->trans('Country').''; + print img_picto('', 'country', 'class="pictofixedwidth"'); + $country_id = GETPOST('country_id', 'int'); + if (!$country_id && !empty($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE)) { + $country_id = getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs); + } + if (!$country_id && !empty($conf->geoipmaxmind->enabled)) { + $country_code = dol_user_country(); + //print $country_code; + if ($country_code) { + $new_country_id = getCountry($country_code, 3, $db, $langs); + //print 'xxx'.$country_code.' - '.$new_country_id; + if ($new_country_id) { + $country_id = $new_country_id; + } + } + } + $country_code = getCountry($country_id, 2, $db, $langs); + print $form->select_country($country_id, 'country_id'); + print '
'.$langs->trans('State').''; + if ($country_code) { + print $formcompany->select_state(GETPOST("state_id"), $country_code); + } + print '
'.$langs->trans("DateOfBirth").''; + print $form->selectDate($birthday, 'birth', 0, 0, 1, "newmember", 1, 0); + print '
'.$langs->trans("URLPhoto").'
'.$langs->trans("Public").'
'.$langs->trans("Comments").'
'.$langs->trans("TurnoverOrBudget").' *'; + print $form->selectarray('budget', $arraybudget, GETPOST('budget'), 1); + print ' € or $'; + + print ''; + print '
'.$langs->trans("Subscription"); + if (!empty($conf->global->MEMBER_EXT_URL_SUBSCRIPTION_INFO)) { + print ' - '.$langs->trans("SeeHere").''; + } + print ''; + + if (empty($amount) && !empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { + $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; + } + + if (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT) || $caneditamount) { + print ''; + print ' '.$langs->trans("Currency".$conf->currency).' – '; + print $amount>0? $langs->trans("AnyAmountWithAdvisedAmount", $amount, $langs->trans("Currency".$conf->currency)): $langs->trans("AnyAmountWithoutAdvisedAmount"); + print ''; + } else { + print ''; + print ''; + print ' '.$langs->trans("Currency".$conf->currency); + } + print '
\n"; + + print dol_get_fiche_end(); + + // Save + print '
'; + print ''; + if (!empty($backtopage)) { + print '     '; + } + print '
'; + + + print "\n"; + print "
"; + print '
'; } +else { // Show the table of membership types + // Get units + $measuringUnits = new CUnits($db); + $result = $measuringUnits->fetchAll('', '', 0, 0, array('t.active' => 1)); + $units = array(); + foreach ($measuringUnits->records as $lines) + $units[$lines->short_label] = $langs->trans(ucfirst($lines->label)); -print "\n"; + $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.amount, d.caneditamount, d.vote, d.note, d.duration, d.statut as status, d.morphy"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; + $sql .= " WHERE d.entity IN (".getEntity('member_type').")"; + $sql .= " AND d.statut=1"; -print dol_get_fiche_end(); + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + + print '
'; + print ''."\n"; + print ''; -// Save -print '
'; -print ''; -if (!empty($backtopage)) { - print '     '; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + $i = 0; + while ($i < $num) { + $objp = $db->fetch_object($result); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ""; + $i++; + } + + // If no record found + if ($num == 0) { + $colspan = 8; + print ''; + } + + print "
'.$langs->trans("Label").''.$langs->trans("MembershipDuration").''.$langs->trans("Amount").''.$langs->trans("MembersNature").''.$langs->trans("VoteAllowed").''.$langs->trans("NewSubscription").'
'.dol_escape_htmltag($objp->label).''; + $unit = preg_replace("/[^a-zA-Z]+/", "", $objp->duration); + print max(1, intval($objp->duration)).' '.$units[$unit]; + print ''; + $displayedamount = max(intval($objp->amount), intval($conf->global->MEMBER_MIN_AMOUNT)); + $caneditamount = !empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT) || $objp->caneditamount; + if($objp->subscription) { + print $displayedamount.' '.strtoupper($conf->currency); + if ($caneditamount && $displayedamount>0) { + print $form->textwithpicto('', $langs->transnoentities("CanEditAmountShortForValues"), 1, 'help', '', 0, 3); + } + elseif ($caneditamount) { + print $langs->transnoentities("CanEditAmountShort"); + } + } + else { + print "–"; // No subscription required + } + print ''; + if ($objp->morphy == 'phy') { + print $langs->trans("Physical"); + } elseif ($objp->morphy == 'mor') { + print $langs->trans("Moral"); + } else { + print $langs->trans("MorAndPhy"); + } + print ''.yn($objp->vote).'
'.$langs->trans("NoRecordFound").'
"; + print '
'; + + print ''; + } else { + dol_print_error($db); + } } -print ''; - - -print "\n"; -print "
"; -print ''; llxFooterVierge(); From f4d5962254504ae5df37bfc031537ef0969a6e16 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Wed, 29 Jun 2022 03:27:48 +0200 Subject: [PATCH 120/367] Allow to skip membership table for retrocompatibility --- htdocs/public/members/new.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 6f490ca5b66..04ae3cdd7bd 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -476,7 +476,7 @@ print '
'. print ''; print ''; -if (!empty($conf->global->MEMBER_NEWFORM_FORCETYPE) || $action == 'create') { +if (!empty($conf->global->MEMBER_SKIP_TABLE) || !empty($conf->global->MEMBER_NEWFORM_FORCETYPE) || $action == 'create') { print ''; print '
'; print '
'.$langs->trans("FieldsWithAreMandatory", '*').'
'; From 253799eb1edbbec1ae65a90da9c0e52e3dcf70a3 Mon Sep 17 00:00:00 2001 From: bagtaib Date: Wed, 29 Jun 2022 05:07:32 +0200 Subject: [PATCH 121/367] NEW #21399 --- htdocs/core/lib/xcal.lib.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/xcal.lib.php b/htdocs/core/lib/xcal.lib.php index 97ada3e3d4f..cd300546e46 100644 --- a/htdocs/core/lib/xcal.lib.php +++ b/htdocs/core/lib/xcal.lib.php @@ -301,7 +301,7 @@ function build_calfile($format, $title, $desc, $events_array, $outputfile) * @param string $format "rss" * @param string $title Title of export * @param string $desc Description of export - * @param array $events_array Array of events ("uid","startdate","summary","url","desc","author","category") or Array of WebsitePage + * @param array $events_array Array of events ("uid","startdate","summary","url","desc","author","category","image") or Array of WebsitePage * @param string $outputfile Output file * @param string $filter (optional) Filter * @param string $url Url (If empty, forge URL for agenda RSS export) @@ -377,6 +377,7 @@ function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filt $tmpevent['author'] = $event->author_alias ? $event->author_alias : 'unknown'; //$tmpevent['category'] = ''; $tmpevent['desc'] = $event->description; + $tmpevent['image'] = $event->image; $event = $tmpevent; } @@ -387,7 +388,9 @@ function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filt $url = $event["url"]; $author = $event["author"]; $category = $event["category"]; - + if (!empty($event["image"])) { + $image = $event["image"]; + } /* No place inside a RSS $priority = $event["priority"]; $fulldayevent = $event["fulldayevent"]; @@ -404,6 +407,10 @@ function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filt fwrite($fichier, "\n"); fwrite($fichier, "

'); + } + if ($description) { fwrite($fichier, $description); } From f840af384a8aedda4ccfd4cfc28ad09017164ea0 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 29 Jun 2022 07:32:16 +0200 Subject: [PATCH 122/367] PHP8 Warning --- htdocs/expensereport/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index a877b659141..47eefb01be9 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -138,7 +138,7 @@ $candelete = 0; if (!empty($user->rights->expensereport->supprimer)) { $candelete = 1; } -if ($object->statut == ExpenseReport::STATUS_DRAFT && !empty($user->rights->expensereport->write) && in_array($object->fk_user_author, $childids)) { +if ($object->statut == ExpenseReport::STATUS_DRAFT && $user->hasRight('expensereport', 'write') && in_array($object->fk_user_author, $childids)) { $candelete = 1; } From df85137772e4140690a7fbed115b60726edc8ffe Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 29 Jun 2022 07:32:25 +0200 Subject: [PATCH 123/367] PHP8 Warning --- htdocs/admin/mails_templates.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index e01c3142cc0..6d461b525bc 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -54,10 +54,12 @@ if (!empty($conf->eventorganization->enabled)) { $langs->loadLangs($langsArray); +$toselect = GETPOST('toselect', 'array'); $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; $massaction = GETPOST('massaction', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation $mode = GETPOST('mode', 'aZ09'); +$optioncss = GETPOST('optioncss', 'alpha'); $id = GETPOST('id', 'int'); $rowid = GETPOST('rowid', 'alpha'); @@ -77,6 +79,7 @@ $actl[1] = img_picto($langs->trans("Activated"), 'switch_on', 'class="size15x"') $listoffset = GETPOST('listoffset', 'alpha'); $listlimit = GETPOST('listlimit', 'alpha') > 0 ?GETPOST('listlimit', 'alpha') : 1000; +$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); From 0867c96f616046e7f095d41fe4fbb398442c82ae Mon Sep 17 00:00:00 2001 From: Artem Chernitsov Date: Wed, 29 Jun 2022 11:48:06 +0300 Subject: [PATCH 124/367] fix of recruitment module - checking file permissions --- htdocs/core/lib/files.lib.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 482831191d6..b8a40461bbc 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -2977,7 +2977,13 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, // Wrapping for import module $accessallowed = $user->rights->import->run; $original_file = $conf->import->dir_temp.'/'.$original_file; - } elseif ($modulepart == 'editor' && !empty($conf->fckeditor->dir_output)) { + } + elseif ($modulepart == 'recruitment' && !empty($conf->recruitment->dir_temp)){ + // Wrapping for recruitment module + $accessallowed = $user->rights->$modulepart->recruitmentjobposition->read; + $original_file = $conf->recruitment->dir_output .'/'. $original_file; + } + elseif ($modulepart == 'editor' && !empty($conf->fckeditor->dir_output)) { // Wrapping for wysiwyg editor $accessallowed = 1; $original_file = $conf->fckeditor->dir_output.'/'.$original_file; From 1d515705b5ab763ea31b7ba0be1ff8d476e60717 Mon Sep 17 00:00:00 2001 From: Artem Chernitsov Date: Wed, 29 Jun 2022 11:51:58 +0300 Subject: [PATCH 125/367] add check file permission recruitment module --- htdocs/core/lib/files.lib.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index b8a40461bbc..ff7fd8df598 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -2977,13 +2977,11 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, // Wrapping for import module $accessallowed = $user->rights->import->run; $original_file = $conf->import->dir_temp.'/'.$original_file; - } - elseif ($modulepart == 'recruitment' && !empty($conf->recruitment->dir_temp)){ + } elseif ($modulepart == 'recruitment' && !empty($conf->recruitment->dir_temp)){ // Wrapping for recruitment module $accessallowed = $user->rights->$modulepart->recruitmentjobposition->read; $original_file = $conf->recruitment->dir_output .'/'. $original_file; - } - elseif ($modulepart == 'editor' && !empty($conf->fckeditor->dir_output)) { + } elseif ($modulepart == 'editor' && !empty($conf->fckeditor->dir_output)) { // Wrapping for wysiwyg editor $accessallowed = 1; $original_file = $conf->fckeditor->dir_output.'/'.$original_file; From cc1ebbc49900ea6cd9f2ebd0e771a5e160d56449 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 29 Jun 2022 08:53:55 +0000 Subject: [PATCH 126/367] Fixing style errors. --- htdocs/core/lib/files.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index ff7fd8df598..223095609d3 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -2977,7 +2977,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, // Wrapping for import module $accessallowed = $user->rights->import->run; $original_file = $conf->import->dir_temp.'/'.$original_file; - } elseif ($modulepart == 'recruitment' && !empty($conf->recruitment->dir_temp)){ + } elseif ($modulepart == 'recruitment' && !empty($conf->recruitment->dir_temp)) { // Wrapping for recruitment module $accessallowed = $user->rights->$modulepart->recruitmentjobposition->read; $original_file = $conf->recruitment->dir_output .'/'. $original_file; From 08bffca31b04d66ad516b831f38cda52d3467f20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?This=20Charl=C3=A8ne?= <1179011+defrance@users.noreply.github.com> Date: Wed, 29 Jun 2022 14:41:50 +0200 Subject: [PATCH 127/367] introduce barcode on warehouse place --- htdocs/install/mysql/tables/llx_entrepot.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/install/mysql/tables/llx_entrepot.sql b/htdocs/install/mysql/tables/llx_entrepot.sql index b2e814c15c6..4b93106e0d4 100644 --- a/htdocs/install/mysql/tables/llx_entrepot.sql +++ b/htdocs/install/mysql/tables/llx_entrepot.sql @@ -35,6 +35,8 @@ create table llx_entrepot fk_pays integer DEFAULT 0, phone varchar(20), -- phone number fax varchar(20), -- fax number + barcode varchar(180) DEFAULT NULL, -- barcode + fk_barcode_type integer DEFAULT NULL, -- barcode type warehouse_usage integer DEFAULT 1, -- 1=internal, 2=external (virtual warehouse or stock out of company) statut tinyint DEFAULT 1, -- 1 open, 0 close fk_user_author integer, From f6b1c91f218524da60ecb142f302b2a3e33fc0da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?This=20Charl=C3=A8ne?= <1179011+defrance@users.noreply.github.com> Date: Wed, 29 Jun 2022 14:44:17 +0200 Subject: [PATCH 128/367] Update 15.0.0-16.0.0.sql --- htdocs/install/mysql/migration/15.0.0-16.0.0.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index 35bf589b2f0..6ba0a0b8dce 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -51,7 +51,8 @@ -- VPGSQL8.2 ALTER TABLE llx_c_payment_term ALTER COLUMN rowid SET DEFAULT nextval('llx_c_payment_term_rowid_seq'); -- VPGSQL8.2 SELECT setval('llx_c_payment_term_rowid_seq', MAX(rowid)) FROM llx_c_payment_term; - +ALTER TABLE llx_entrepot ADD COLUMN barcode varchar(180) DEFAULT NULL; +ALTER TABLE llx_entrepot ADD COLUMN fk_barcode_type integer DEFAULT NULL; ALTER TABLE llx_c_transport_mode ADD UNIQUE INDEX uk_c_transport_mode (code, entity); From f4c7c03dc10fea94957c40f1bde99d305ca8996f Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 29 Jun 2022 14:38:43 +0000 Subject: [PATCH 129/367] Fixing style errors. --- htdocs/public/members/new.php | 14 ++++++-------- htdocs/public/payment/newpayment.php | 4 ++-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 04ae3cdd7bd..7f3687cc006 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -702,7 +702,7 @@ if (!empty($conf->global->MEMBER_SKIP_TABLE) || !empty($conf->global->MEMBER_NEW print ' - '.$langs->trans("SeeHere").''; } print ''; - + if (empty($amount) && !empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; } @@ -753,7 +753,7 @@ else { // Show the table of membership types $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); - + print '
'; print ''."\n"; print ''; @@ -766,7 +766,7 @@ else { // Show the table of membership types print ''; print ''; print "\n"; - + $i = 0; while ($i < $num) { $objp = $db->fetch_object($result); @@ -780,16 +780,14 @@ else { // Show the table of membership types print ''; diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 1c3c0202b23..a6b190bfc66 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -1622,10 +1622,10 @@ if ($source == 'member' || $source == 'membersubscription') { print ''.price($amount, 1, $langs, 1, -1, -1, $currency).''; // Price with currency $caneditamount = !empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT) || $adht->caneditamount; $minimumamount = empty($conf->global->MEMBER_MIN_AMOUNT)? $adht->amount : max($conf->global->MEMBER_MIN_AMOUNT, $adht->amount > $amount); - if(!$caneditamount && $minimumamount > $amount) { + if (!$caneditamount && $minimumamount > $amount) { print ' '. $langs->trans("AmountIsLowerToMinimumNotice", price($adht->amount, 1, $langs, 1, -1, -1, $currency)); } - + print ''; print ''; print ''."\n"; From 371b4ac94e284943bb95e269b18da123eb3a7757 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9=20GDSOFT?= Date: Wed, 29 Jun 2022 16:56:07 +0200 Subject: [PATCH 130/367] invoice export : add accounting affectation --- htdocs/core/modules/modFacture.class.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index 2cdc8229e51..498ff55da74 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -517,7 +517,8 @@ class modFacture extends DolibarrModules 'fd.subprice'=>"LineUnitPrice", 'fd.tva_tx'=>"LineVATRate", 'fd.qty'=>"LineQty", 'fd.total_ht'=>"LineTotalHT", 'fd.total_tva'=>"LineTotalVAT", 'fd.total_ttc'=>"LineTotalTTC", 'fd.date_start'=>"DateStart", 'fd.date_end'=>"DateEnd", 'fd.special_code'=>'SpecialCode', 'fd.product_type'=>"TypeOfLineServiceOrProduct", 'fd.fk_product'=>'ProductId', 'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel', - $alias_product_perentity . '.accountancy_code_sell'=>'ProductAccountancySellCode' + $alias_product_perentity . '.accountancy_code_sell'=>'ProductAccountancySellCode', + 'aa.account_number' => 'AccountingAffectation' ); if (!empty($conf->multicurrency->enabled)) { $this->export_fields_array[$r]['f.multicurrency_code'] = 'Currency'; @@ -549,6 +550,7 @@ class modFacture extends DolibarrModules 'fd.special_code'=>'Numeric', 'fd.product_type'=>"Numeric", 'fd.fk_product'=>'List:product:label', 'p.ref'=>'Text', 'p.label'=>'Text', $alias_product_perentity . '.accountancy_code_sell'=>'Text', 'f.entity'=>'List:entity:label:rowid', + 'aa.account_number' => 'Text' ); if (!empty($conf->cashdesk->enabled) || !empty($conf->takepos->enabled) || !empty($conf->global->INVOICE_SHOW_POS)) { $this->export_TypeFields_array[$r]['f.module_source'] = 'Text'; @@ -561,7 +563,8 @@ class modFacture extends DolibarrModules 'fd.subprice'=>"invoice_line", 'fd.total_ht'=>"invoice_line", 'fd.total_tva'=>"invoice_line", 'fd.total_ttc'=>"invoice_line", 'fd.tva_tx'=>"invoice_line", 'fd.qty'=>"invoice_line", 'fd.date_start'=>"invoice_line", 'fd.date_end'=>"invoice_line", 'fd.special_code'=>'invoice_line', 'fd.product_type'=>'invoice_line', 'fd.fk_product'=>'product', 'p.ref'=>'product', 'p.label'=>'product', $alias_product_perentity . '.accountancy_code_sell'=>'product', - 'f.fk_user_author'=>'user', 'uc.login'=>'user', 'f.fk_user_valid'=>'user', 'uv.login'=>'user' + 'f.fk_user_author'=>'user', 'uc.login'=>'user', 'f.fk_user_valid'=>'user', 'uv.login'=>'user', + 'aa.account_number' => "invoice_line", ); $this->export_special_array[$r] = array('none.rest'=>'getRemainToPay'); $this->export_dependencies_array[$r] = array('invoice_line'=>'fd.rowid', 'product'=>'fd.rowid', 'none.rest'=>array('f.rowid', 'f.total_ttc', 'f.close_code')); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them @@ -602,6 +605,7 @@ class modFacture extends DolibarrModules $this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); } $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'accounting_account as aa on fd.fk_code_ventilation = aa.rowid'; $this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture'; $this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('invoice').')'; if (empty($user->rights->societe->client->voir)) { From 7fcbe97b9c90a50b2f39eff211ccf8039e98456e Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 29 Jun 2022 17:32:50 +0200 Subject: [PATCH 131/367] NEW Project - Add author on list --- htdocs/projet/list.php | 53 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index eaf9c5022a3..2c111a30c2c 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -108,6 +108,7 @@ $search_accept_conference_suggestions = GETPOST('search_accept_conference_sugges $search_accept_booth_suggestions = GETPOST('search_accept_booth_suggestions', 'int'); $search_price_registration = GETPOST("search_price_registration", 'alpha'); $search_price_booth = GETPOST("search_price_booth", 'alpha'); +$search_login = GETPOST('search_login', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); $mine = ((GETPOST('mode') == 'mine') ? 1 : 0); @@ -201,6 +202,7 @@ $arrayfields['s.nom'] = array('label'=>$langs->trans("ThirdParty"), 'checked'=>1 $arrayfields['commercial'] = array('label'=>$langs->trans("SaleRepresentativesOfThirdParty"), 'checked'=>0, 'position'=>23); $arrayfields['c.assigned'] = array('label'=>$langs->trans("AssignedTo"), 'checked'=>-1, 'position'=>120); $arrayfields['opp_weighted_amount'] = array('label'=>$langs->trans('OpportunityWeightedAmountShort'), 'checked'=>0, 'position'=> 116, 'enabled'=>(empty($conf->global->PROJECT_USE_OPPORTUNITIES) ? 0 : 1), 'position'=>106); +$arrayfields['u.login'] = array('label'=>"Author", 'checked'=>1, 'position'=>165); // Force some fields according to search_usage filter... if (GETPOST('search_usage_opportunity')) { //$arrayfields['p.usage_opportunity']['visible'] = 1; // Not require, filter on search_opp_status is enough @@ -285,6 +287,7 @@ if (empty($reshook)) { $search_accept_booth_suggestions = ''; $search_price_registration = ''; $search_price_booth = ''; + $search_login = ''; $toselect = array(); $search_array_options = array(); $search_category_array = array(); @@ -390,10 +393,11 @@ $sql = "SELECT ".$distinct." p.rowid as id, p.ref, p.title, p.fk_statut as statu $sql .= " p.datec as date_creation, p.dateo as date_start, p.datee as date_end, p.opp_amount, p.opp_percent, (p.opp_amount*p.opp_percent/100) as opp_weighted_amount, p.tms as date_update, p.budget_amount,"; $sql .= " p.usage_opportunity, p.usage_task, p.usage_bill_time, p.usage_organize_event,"; $sql .= " p.email_msgid,"; -$sql .= " accept_conference_suggestions, accept_booth_suggestions, price_registration, price_booth,"; +$sql .= " p.accept_conference_suggestions, p.accept_booth_suggestions, p.price_registration, p.price_booth,"; $sql .= " s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.email, s.phone, s.fax, s.address, s.town, s.zip, s.fk_pays, s.client, s.code_client,"; $sql .= " country.code as country_code,"; -$sql .= " cls.code as opp_status_code"; +$sql .= " cls.code as opp_status_code,"; +$sql .= ' u.login, u.lastname, u.firstname, u.email as user_email, u.statut as user_statut, u.entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender'; // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { @@ -415,6 +419,7 @@ if (!empty($extrafields->attributes[$object->table_element]['label']) &&is_array $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status as cls on p.fk_opp_status = cls.rowid"; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user AS u ON p.fk_user_creat = u.rowid'; // We'll need this table joined to the select in order to filter by sale // No check is done on company permission because readability is managed by public status of project and assignement. //if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; @@ -544,6 +549,9 @@ if ($search_price_registration != '') { if ($search_price_booth != '') { $sql .= natural_search('p.price_booth', $search_price_booth, 1); } +if ($search_login) { + $sql .= natural_search(array('u.login', 'u.firstname', 'u.lastname'), $search_login); +} // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks @@ -735,6 +743,9 @@ if ($search_price_registration != '') { if ($search_price_booth != '') { $param .= '&search_price_booth='.urlencode($search_price_booth); } +if ($search_login) { + $param .= '&search_login='.urlencode($search_login); +} if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); } @@ -999,6 +1010,12 @@ if (!empty($arrayfields['p.price_booth']['checked'])) { print ''; print ''; } +if (!empty($arrayfields['u.login']['checked'])) { + // Author + print ''; +} // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; @@ -1104,6 +1121,9 @@ if (!empty($arrayfields['p.price_registration']['checked'])) { if (!empty($arrayfields['p.price_booth']['checked'])) { print_liste_field_titre($arrayfields['p.price_booth']['label'], $_SERVER["PHP_SELF"], 'p.price_booth', "", $param, '', $sortfield, $sortorder, 'right '); } +if (!empty($arrayfields['u.login']['checked'])) { + print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder); +} // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields @@ -1125,6 +1145,8 @@ if (!empty($arrayfields['p.fk_statut']['checked'])) { print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; +$userstatic = new User($db); + $i = 0; $totalarray = array( 'nbfield' => 0, @@ -1473,6 +1495,33 @@ while ($i < min($num, $limit)) { $totalarray['pos'][$totalarray['nbfield']] = 'p.price_booth'; } } + // Author + $userstatic->id = $obj->fk_user_creat; + $userstatic->login = $obj->login; + $userstatic->lastname = $obj->lastname; + $userstatic->firstname = $obj->firstname; + $userstatic->email = $obj->user_email; + $userstatic->statut = $obj->user_statut; + $userstatic->entity = $obj->entity; + $userstatic->photo = $obj->photo; + $userstatic->office_phone = $obj->office_phone; + $userstatic->office_fax = $obj->office_fax; + $userstatic->user_mobile = $obj->user_mobile; + $userstatic->job = $obj->job; + $userstatic->gender = $obj->gender; + + if (!empty($arrayfields['u.login']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook From 6a8882b60ddd36072345bb19154865e7adc7f3d4 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Thu, 30 Jun 2022 00:39:13 +0200 Subject: [PATCH 132/367] Bugfix: regression, keep newamount equal to amount for the payment Follows 759900bccee95b31e7684b2d69d93370d0e176ed --- htdocs/public/payment/newpayment.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index a6b190bfc66..faf3cafc59a 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -1627,6 +1627,7 @@ if ($source == 'member' || $source == 'membersubscription') { } print ''; + print ''; print ''; print ''."\n"; From 364960a8fccba5829b9d54be022ef2024d4d4898 Mon Sep 17 00:00:00 2001 From: BB2A Anthony Berton Date: Thu, 30 Jun 2022 09:56:37 +0200 Subject: [PATCH 133/367] FIX - php V8 soc list --- htdocs/societe/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index a57b498490b..255152744f7 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -1583,7 +1583,7 @@ while ($i < min($num, $limit)) { } } if (!empty($arrayfields['s.email']['checked'])) { - print '\n"; + print '\n"; if (!$i) { $totalarray['nbfield']++; } From bf98c77d73c97f2a42a803b6d904589d76b415d0 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Thu, 30 Jun 2022 10:24:47 +0200 Subject: [PATCH 134/367] FIX : french traductions for payment methods --- htdocs/langs/fr_FR/bills.lang | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/langs/fr_FR/bills.lang b/htdocs/langs/fr_FR/bills.lang index d1a0dbbbe92..a250e2f383e 100644 --- a/htdocs/langs/fr_FR/bills.lang +++ b/htdocs/langs/fr_FR/bills.lang @@ -81,14 +81,14 @@ PaymentsReports=Rapports de règlements PaymentsAlreadyDone=Versements déjà effectués PaymentsBackAlreadyDone=Remboursements déjà effectués PaymentRule=Mode de paiement -PaymentMode=Payment method -PaymentModes=Payment methods -DefaultPaymentMode=Default Payment method +PaymentMode=Mode de règlement +PaymentModes=Modes de règlement +DefaultPaymentMode=Mode de règlement par défaut DefaultBankAccount=Compte bancaire par défaut -IdPaymentMode=Payment method (id) -CodePaymentMode=Payment method (code) -LabelPaymentMode=Payment method (label) -PaymentModeShort=Payment method +IdPaymentMode=Mode de règlement (id) +CodePaymentMode=Mode de règlement (code) +LabelPaymentMode=Mode de règlement (label) +PaymentModeShort=Mode règlement PaymentTerm=Condition de règlement PaymentConditions=Conditions de règlement PaymentConditionsShort=Conditions de règlement From 8594bd952805138248bc3e4ddfc6d2575565c01f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 30 Jun 2022 13:46:07 +0200 Subject: [PATCH 135/367] Debug v16 --- htdocs/modulebuilder/template/myobject_card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 7702aa6699b..ec818206705 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -92,7 +92,7 @@ $lineid = GETPOST('lineid', 'int'); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); $cancel = GETPOST('cancel', 'aZ09'); -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'myobjectcard'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', __FILE__); // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); $dol_openinpopup = GETPOST('dol_openinpopup', 'aZ09'); From ad9c91fc251e6b9cf2f4a0c14958ee0f040854f4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 30 Jun 2022 14:40:03 +0200 Subject: [PATCH 136/367] Debug v16 --- htdocs/modulebuilder/template/class/myobject.class.php | 2 +- htdocs/modulebuilder/template/myobject_list.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index d0e6acf70e3..eedb4de0b13 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -240,7 +240,7 @@ class MyObject extends CommonObject $this->db = $db; - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) { + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid']) && !empty($this->fields['ref'])) { $this->fields['rowid']['visible'] = 0; } if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) { diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index c71d7abc4be..aaf93d1e229 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -570,7 +570,7 @@ foreach ($object->fields as $key => $val) { $cssforfield .= ($cssforfield ? ' ' : '').'center'; } elseif (in_array($val['type'], array('timestamp'))) { $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'rowid' && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } if (!empty($arrayfields['t.'.$key]['checked'])) { @@ -632,7 +632,7 @@ foreach ($object->fields as $key => $val) { $cssforfield .= ($cssforfield ? ' ' : '').'center'; } elseif (in_array($val['type'], array('timestamp'))) { $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'rowid' && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label From f0848d9f9fe7b7540834c50eb63380059013bebf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 30 Jun 2022 15:58:59 +0200 Subject: [PATCH 137/367] Debug v16 --- htdocs/core/class/commonobject.class.php | 6 +- .../partnership/class/partnership.class.php | 2 +- htdocs/partnership/partnership_list.php | 335 +++++++++++------- 3 files changed, 211 insertions(+), 132 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 2a5ddcf5a34..42442f47fd0 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7399,8 +7399,10 @@ abstract class CommonObject } // Format output value differently according to properties of field - if ($key == 'ref' && method_exists($this, 'getNomUrl')) { - $value = $this->getNomUrl(1, '', 0, '', 1); + if (in_array($key, array('rowid', 'ref')) && method_exists($this, 'getNomUrl')) { + if ($key != 'rowid' || empty($this->fields['ref'])) { // If we want ref field or if we want ID and there is no ref field, we show the link. + $value = $this->getNomUrl(1, '', 0, '', 1); + } } elseif ($key == 'status' && method_exists($this, 'getLibStatut')) { $value = $this->getLibStatut(3); } elseif ($type == 'date') { diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index 28fcc2fd68e..85787075f28 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -205,7 +205,7 @@ class Partnership extends CommonObject $this->fields['fk_soc'] = array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'picto'=>'company', 'css'=>'maxwidth500', 'csslist'=>'tdoverflowmax150'); } - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) { + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid']) && !empty($this->fields['ref'])) { $this->fields['rowid']['visible'] = 0; } // if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) { diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php index 014d576f5d6..a237a359b25 100644 --- a/htdocs/partnership/partnership_list.php +++ b/htdocs/partnership/partnership_list.php @@ -43,9 +43,10 @@ $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'partnershiplist'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', __FILE__); // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page -$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$mode = GETPOST('mode', 'aZ'); $id = GETPOST('id', 'int'); @@ -55,8 +56,9 @@ $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + // If $page is not defined, or '' or -1 or if we click on clear filters $page = 0; -} // If $page is not defined, or '' or -1 or if we click on clear filters +} $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -88,7 +90,7 @@ if (!$sortorder) { } // Initialize array of search criterias -$search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'); +$search_all = GETPOST('search_all', 'alphanohtml'); $search = array(); foreach ($object->fields as $key => $val) { if (GETPOST('search_'.$key, 'alpha') !== '') { @@ -118,11 +120,11 @@ $arrayfields = array(); foreach ($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field if (!empty($val['visible'])) { - $visible = (int) dol_eval($val['visible'], 1, 1, '1'); + $visible = (int) dol_eval($val['visible'], 1); $arrayfields['t.'.$key] = array( 'label'=>$val['label'], 'checked'=>(($visible < 0) ? 0 : 1), - 'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')), + 'enabled'=>(abs($visible) != 3 && dol_eval($val['enabled'], 1)), 'position'=>$val['position'], 'help'=> isset($val['help']) ? $val['help'] : '' ); @@ -150,14 +152,13 @@ if ($user->socid > 0) { // Protection if external user //$result = restrictedArea($user, 'partnership'); //if (!$permissiontoread) accessforbidden(); +$error = 0; /* * Actions */ -$error = 0; - if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; @@ -187,7 +188,6 @@ if (empty($reshook)) { } $toselect = array(); $search_array_options = array(); - $search_filter = ""; } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { @@ -285,7 +285,7 @@ $now = dol_now(); //$help_url="EN:Module_Partnership|FR:Module_Partnership_FR|ES:Módulo_Partnership"; $help_url = ''; -$title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("Partnerships")); +$title = $langs->trans("Partnerships"); $morejs = array(); $morecss = array(); @@ -341,17 +341,17 @@ foreach ($search as $key => $val) { $mode_search = 2; } if ($search[$key] != '') { - $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); + $sql .= natural_search("t.".$db->escape($key), $search[$key], (($key == 'status') ? 2 : $mode_search)); } } else { if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') { $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key); if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) { if (preg_match('/_dtstart$/', $key)) { - $sql .= " AND t.".$columnName." >= '".$db->idate($search[$key])."'"; + $sql .= " AND t.".$db->escape($columnName)." >= '".$db->idate($search[$key])."'"; } if (preg_match('/_dtend$/', $key)) { - $sql .= " AND t.".$columnName." <= '".$db->idate($search[$key])."'"; + $sql .= " AND t.".$db->escape($columnName)." <= '".$db->idate($search[$key])."'"; } } } @@ -382,11 +382,13 @@ $sql .= $hookmanager->resPrint; /* If a group by is required $sql.= " GROUP BY "; foreach($object->fields as $key => $val) { - $sql .= "t.".$key.", "; + $sql .= "t.".$db->escape($key).", "; } // Add fields from extrafields if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); + } } // Add where from hooks $parameters=array(); @@ -395,35 +397,41 @@ $sql.=$hookmanager->resPrint; $sql=preg_replace('/,\s*$/','', $sql); */ -$sql .= $db->order($sortfield, $sortorder); - // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $resql = $db->query($sql); - $nbtotalofrecords = $db->num_rows($resql); + /* The fast and low memory method to get and count full list converts the sql into a sql count */ + $sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); + $resql = $db->query($sqlforcount); + if ($resql) { + $objforcount = $db->fetch_object($resql); + $nbtotalofrecords = $objforcount->nbtotalofrecords; + } else { + dol_print_error($db); + } + if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 $page = 0; $offset = 0; } + $db->free($resql); } -// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. -if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) { - $num = $nbtotalofrecords; -} else { - if ($limit) { - $sql .= $db->plimit($limit + 1, $offset); - } - $resql = $db->query($sql); - if (!$resql) { - dol_print_error($db); - exit; - } - - $num = $db->num_rows($resql); +// Complete request and execute it with limit +$sql .= $db->order($sortfield, $sortorder); +if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); } +$resql = $db->query($sql); +if (!$resql) { + dol_print_error($db); + exit; +} + +$num = $db->num_rows($resql); + + // Direct jump if only one record found if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) { $obj = $db->fetch_object($resql); @@ -451,9 +459,11 @@ if ($limit > 0 && $limit != $conf->liste_limit) { foreach ($search as $key => $val) { if (is_array($search[$key]) && count($search[$key])) { foreach ($search[$key] as $skey) { - $param .= '&search_'.$key.'[]='.urlencode($skey); + if ($skey != '') { + $param .= '&search_'.$key.'[]='.urlencode($skey); + } } - } else { + } elseif ($search[$key] != '') { $param .= '&search_'.$key.'='.urlencode($search[$key]); } } @@ -496,9 +506,12 @@ print ''; print ''; print ''; +print ''; print ''; +print ''; -$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/partnership/partnership_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); +$newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/partnership/partnership_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -510,10 +523,13 @@ $trackid = 'pship'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($search_all) { + $setupstring = ''; foreach ($fieldstosearchall as $key => $val) { $fieldstosearchall[$key] = $langs->trans($val); + $setupstring .= $key."=".$val.";"; } - print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'; + print ''."\n"; + print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'."\n"; } $moreforfilter = ''; @@ -536,7 +552,7 @@ if (!empty($moreforfilter)) { } $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table @@ -551,25 +567,31 @@ if ($managedfor == 'member') { // Fields title search // -------------------------------------------------------------------- print '
'; +// Action column +if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; +} foreach ($object->fields as $key => $val) { - $cssforfield = (empty($val['css']) ? '' : $val['css']); + $searchkey = empty($search[$key]) ? '' : $search[$key]; + $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); if ($key == 'status') { $cssforfield .= ($cssforfield ? ' ' : '').'center'; } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { $cssforfield .= ($cssforfield ? ' ' : '').'center'; } elseif (in_array($val['type'], array('timestamp'))) { $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'rowid' && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; } @@ -596,16 +624,23 @@ $parameters = array('arrayfields'=>$arrayfields); $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column -print ''; +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; +} print ''."\n"; +$totalarray = array(); +$totalarray['nbfield'] = 0; // Fields title label // -------------------------------------------------------------------- print ''; +if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +} foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); if ($key == 'status') { @@ -614,11 +649,13 @@ foreach ($object->fields as $key => $val) { $cssforfield .= ($cssforfield ? ' ' : '').'center'; } elseif (in_array($val['type'], array('timestamp'))) { $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'rowid' && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } + $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label if (!empty($arrayfields['t.'.$key]['checked'])) { print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; + $totalarray['nbfield']++; } } // End of subscription date @@ -630,11 +667,14 @@ if ($managedfor == 'member') { // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column -print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +} +$totalarray['nbfield']++; print ''."\n"; @@ -652,8 +692,11 @@ if (isset($extrafields->attributes[$object->table_element]['computed']) && is_ar // Loop on record // -------------------------------------------------------------------- $i = 0; +$savnbfield = $totalarray['nbfield']; $totalarray = array(); -while ($i < ($limit ? min($num, $limit) : $num)) { +$totalarray['nbfield'] = 0; +$imaxinloop = ($limit ? min($num, $limit) : $num); +while ($i < $imaxinloop) { $obj = $db->fetch_object($resql); if (empty($obj)) { break; // Should not happen @@ -662,98 +705,132 @@ while ($i < ($limit ? min($num, $limit) : $num)) { // Store properties in $object $object->setVarsFromFetchObj($obj); - // Show here line of result - print ''; - foreach ($object->fields as $key => $val) { - $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif ($key == 'status') { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; + if ($mode == 'kanban') { + if ($i == 0) { + print ''; } - - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'right'; - } - //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; - - if (!empty($arrayfields['t.'.$key]['checked'])) { - print ''; - if ($key == 'status') { - print $object->getLibStatut(5); - } else { - print $object->showOutputField($val, $key, $object->$key, ''); + } else { + // Show here line of result + $j = 0; + print ''; + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; - if (!$i) { - $totalarray['nbfield']++; + } + foreach ($object->fields as $key => $val) { + $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; } - if (!empty($val['isameasure']) && $val['isameasure'] == 1) { + + if (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif ($key == 'ref') { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } + + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } + //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; + + if (!empty($arrayfields['t.'.$key]['checked'])) { + print ''; + if ($key == 'status') { + print $object->getLibStatut(5); + } elseif ($key == 'rowid') { + print $object->showOutputField($val, $key, $object->id, ''); + } else { + print $object->showOutputField($val, $key, $object->$key, ''); + } + print ''; if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + $totalarray['nbfield']++; } - if (!isset($totalarray['val'])) { - $totalarray['val'] = array(); + if (!empty($val['isameasure']) && $val['isameasure'] == 1) { + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + } + if (!isset($totalarray['val'])) { + $totalarray['val'] = array(); + } + if (!isset($totalarray['val']['t.'.$key])) { + $totalarray['val']['t.'.$key] = 0; + } + $totalarray['val']['t.'.$key] += $object->$key; } - if (!isset($totalarray['val']['t.'.$key])) { - $totalarray['val']['t.'.$key] = 0; - } - $totalarray['val']['t.'.$key] += $object->$key; } } - } - // End of subscription date - if ($managedfor == 'member') { - print ''; } - print ''; - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Action column - print ''; + } + if (!$i) { + $totalarray['nbfield']++; } - print ''; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - print ''."\n"; + print ''."\n"; + } $i++; } @@ -771,14 +848,14 @@ if ($num == 0) { } } if ($managedfor != 'member') $colspan++; // End of subscription date - print ''; + print ''; } $db->free($resql); $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'.$langs->trans("VoteAllowed").''.$langs->trans("NewSubscription").'
'; $displayedamount = max(intval($objp->amount), intval($conf->global->MEMBER_MIN_AMOUNT)); $caneditamount = !empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT) || $objp->caneditamount; - if($objp->subscription) { + if ($objp->subscription) { print $displayedamount.' '.strtoupper($conf->currency); if ($caneditamount && $displayedamount>0) { print $form->textwithpicto('', $langs->transnoentities("CanEditAmountShortForValues"), 1, 'help', '', 0, 3); - } - elseif ($caneditamount) { + } elseif ($caneditamount) { print $langs->transnoentities("CanEditAmountShort"); } - } - else { + } else { print "–"; // No subscription required } print '
'; + print ''; + print '
'; + if ($userstatic->id) { + print $userstatic->getNomUrl(-1); + } else { + print ' '; + } + print "
'.dol_print_email($obj->email, $obj->rowid, $obj->socid, 'AC_EMAIL', 0, 0, 1)."'.dol_print_email($obj->email, $obj->rowid, $obj->rowid, 'AC_EMAIL', 0, 0, 1)."
'; + $searchpicto = $form->showFilterButtons('left'); + print $searchpicto; + print ''; if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { - print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) { - print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth125', 1); - } elseif (!preg_match('/^(date|timestamp|datetime)/', $val['type'])) { - print ''; + print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth250', 1); } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { print '
'; print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); @@ -577,6 +599,12 @@ foreach ($object->fields as $key => $val) { print '
'; print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); print '
'; + } elseif ($key == 'lang') { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; + $formadmin = new FormAdmin($db); + print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth150 maxwidth200', 2); + } else { + print ''; } print '
'; -$searchpicto = $form->showFilterButtons(); -print $searchpicto; -print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print '
'; + print '
'; } - - if (in_array($val['type'], array('timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif ($key == 'ref') { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + // Output Kanban + print $object->getKanbanView(''); + if ($i == ($imaxinloop - 1)) { + print '
'; + print '
'; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($object->id, $arrayofselected)) { + $selected = 1; + } + print ''; } print ''; - $result = $adherent->fetch($object->fk_member); - if ($result) { - $datefin = $adherent->datefin; - if ($datefin) { - print dol_print_date($datefin, 'day'); - if ($adherent->hasDelay()) { - $textlate .= ' ('.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($conf->adherent->subscription->warning_delay / 60 / 60 / 24) >= 0 ? '+' : '').ceil($conf->adherent->subscription->warning_delay / 60 / 60 / 24).' '.$langs->trans("days").')'; - print " ".img_warning($langs->trans("SubscriptionLate").$textlate); - } - } else { - if ($adherent->subscription == 'yes') { - print $langs->trans("SubscriptionNotReceived"); - if ($adherent->statut > 0) { - print " ".img_warning(); + // End of subscription date + if ($managedfor == 'member') { + print ''; + $result = $adherent->fetch($object->fk_member); + if ($result) { + $datefin = $adherent->datefin; + if ($datefin) { + print dol_print_date($datefin, 'day'); + if ($adherent->hasDelay()) { + $textlate .= ' ('.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($conf->adherent->subscription->warning_delay / 60 / 60 / 24) >= 0 ? '+' : '').ceil($conf->adherent->subscription->warning_delay / 60 / 60 / 24).' '.$langs->trans("days").')'; + print " ".img_warning($langs->trans("SubscriptionLate").$textlate); } } else { - print ' '; + if ($adherent->subscription == 'yes') { + print $langs->trans("SubscriptionNotReceived"); + if ($adherent->statut > 0) { + print " ".img_warning(); + } + } else { + print ' '; + } } } + print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($object->id, $arrayofselected)) { - $selected = 1; + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Action column + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($object->id, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print '
'.$langs->trans("NoRecordFound").'
'.$langs->trans("NoRecordFound").'
'."\n"; From 80ce80f7cc2d9c5d2adaace03f2fe45914132c7a Mon Sep 17 00:00:00 2001 From: BB2A Anthony Berton Date: Thu, 30 Jun 2022 17:29:02 +0200 Subject: [PATCH 138/367] FIX - php V8 admin translation --- htdocs/admin/translation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index 4968e75989a..78d399a2f48 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -554,7 +554,7 @@ if ($mode == 'searchkey') { break; } print ''.$langcode.''.$key.''; - $titleforvalue = $langs->trans("Translation").' en_US for key '.$key.':
'.($langsenfileonly->tab_translate[$key] ? $langsenfileonly->trans($key) : ''.$langs->trans("None").''); + $titleforvalue = $langs->trans("Translation").' en_US for key '.$key.':
'.(isset($langsenfileonly->tab_translate[$key]) ? $langsenfileonly->trans($key) : ''.$langs->trans("None").''); print ''; print dol_escape_htmltag($val); print ''; From 6e153b9b75e0e9e0d85b8259f2e2b8880a8c0612 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 30 Jun 2022 22:52:08 +0200 Subject: [PATCH 139/367] Debug import FIX #yogosha11618 --- .../modules/import/import_csv.modules.php | 21 ++- .../modules/import/import_xlsx.modules.php | 9 + htdocs/core/modules/modAdherent.class.php | 14 +- htdocs/imports/import.php | 163 +++++++++--------- htdocs/langs/en_US/companies.lang | 3 +- htdocs/langs/en_US/errors.lang | 1 + htdocs/langs/en_US/members.lang | 3 +- htdocs/main.inc.php | 2 +- 8 files changed, 121 insertions(+), 95 deletions(-) diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 8c3e5bfeab9..32284a2cbd1 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -470,9 +470,9 @@ class ImportCsv extends ModeleImports $newval = $classinstance->id; } else { if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) { - $this->errors[$error]['lib'] = $langs->trans('ErrorFieldValueNotIn', $key, $newval, 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); + $this->errors[$error]['lib'] = $langs->trans('ErrorFieldValueNotIn', num2Alpha($key - 1), $newval, 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); } elseif (!empty($objimport->array_import_convertvalue[0][$val]['element'])) { - $this->errors[$error]['lib'] = $langs->trans('ErrorFieldRefNotIn', $key, $newval, $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['element'])); + $this->errors[$error]['lib'] = $langs->trans('ErrorFieldRefNotIn', num2Alpha($key - 1), $newval, $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['element'])); } else { $this->errors[$error]['lib'] = 'ErrorBadDefinitionOfImportProfile'; } @@ -512,7 +512,7 @@ class ImportCsv extends ModeleImports $newval = $classinstance->id; } else { if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) { - $this->errors[$error]['lib'] = $langs->trans('ErrorFieldValueNotIn', $key, $newval, 'scale', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); + $this->errors[$error]['lib'] = $langs->trans('ErrorFieldValueNotIn', num2Alpha($key - 1), $newval, 'scale', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); } else { $this->errors[$error]['lib'] = 'ErrorFieldValueNotIn'; } @@ -549,7 +549,7 @@ class ImportCsv extends ModeleImports $newval = $scaleorid ? $scaleorid : 0; } else { if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) { - $this->errors[$error]['lib'] = $langs->trans('ErrorFieldValueNotIn', $key, $newval, 'scale', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); + $this->errors[$error]['lib'] = $langs->trans('ErrorFieldValueNotIn', num2Alpha($key - 1), $newval, 'scale', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); } else { $this->errors[$error]['lib'] = 'ErrorFieldValueNotIn'; } @@ -697,7 +697,7 @@ class ImportCsv extends ModeleImports if (!empty($filter)) { $tableforerror .= ':'.$filter; } - $this->errors[$error]['lib'] = $langs->transnoentitiesnoconv('ErrorFieldValueNotIn', $key, $newval, $field, $tableforerror); + $this->errors[$error]['lib'] = $langs->transnoentitiesnoconv('ErrorFieldValueNotIn', num2Alpha($key - 1), $newval, $field, $tableforerror); $this->errors[$error]['type'] = 'FOREIGNKEY'; $errorforthistable++; $error++; @@ -705,13 +705,22 @@ class ImportCsv extends ModeleImports } elseif (!preg_match('/'.$objimport->array_import_regex[0][$val].'/i', $newval)) { // If test is just a static regex //if ($key == 19) print "xxx".$newval."zzz".$objimport->array_import_regex[0][$val]."
"; - $this->errors[$error]['lib'] = $langs->transnoentitiesnoconv('ErrorWrongValueForField', $key, $newval, $objimport->array_import_regex[0][$val]); + $this->errors[$error]['lib'] = $langs->transnoentitiesnoconv('ErrorWrongValueForField', num2Alpha($key - 1), $newval, $objimport->array_import_regex[0][$val]); $this->errors[$error]['type'] = 'REGEX'; $errorforthistable++; $error++; } } + // Check HTML injection + $inj = testSqlAndScriptInject($newval, 0); + if ($inj) { + $this->errors[$error]['lib'] = $langs->transnoentitiesnoconv('ErrorHtmlInjectionForField', num2Alpha($key - 1), dol_trunc($newval, 100)); + $this->errors[$error]['type'] = 'HTMLINJECTION'; + $errorforthistable++; + $error++; + } + // Other tests // ... } diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 4740f7d3390..d8a9d77a98e 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -756,6 +756,15 @@ class ImportXlsx extends ModeleImports } } + // Check HTML injection + $inj = testSqlAndScriptInject($newval, 0); + if ($inj) { + $this->errors[$error]['lib'] = $langs->transnoentitiesnoconv('ErrorHtmlInjectionForField', $key, dol_trunc($newval, 100)); + $this->errors[$error]['type'] = 'HTMLINJECTION'; + $errorforthistable++; + $error++; + } + // Other tests // ... } diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index 0d4a85e00ae..215e7dd3c64 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -286,8 +286,8 @@ class modAdherent extends DolibarrModules $this->export_label[$r] = 'MembersAndSubscriptions'; $this->export_permission[$r] = array(array("adherent", "export")); $this->export_fields_array[$r] = array( - 'a.rowid'=>'Id', 'a.civility'=>"UserTitle", 'a.lastname'=>"Lastname", 'a.firstname'=>"Firstname", 'a.login'=>"Login", 'a.gender'=>"Gender", 'a.morphy'=>'MemberNature', - 'a.societe'=>'Company', 'a.address'=>"Address", 'a.zip'=>"Zip", 'a.town'=>"Town", 'd.nom'=>"State", 'co.code'=>"CountryCode", 'co.label'=>"Country", + 'a.rowid'=>'MemberId', 'a.ref'=>'MemberRef', 'a.civility'=>"UserTitle", 'a.lastname'=>"Lastname", 'a.firstname'=>"Firstname", 'a.login'=>"Login", 'a.gender'=>"Gender", 'a.morphy'=>'MemberNature', + 'a.societe'=>'Company', 'a.address'=>"Address", 'a.zip'=>"Zip", 'a.town'=>"Town", 'd.code_departement'=>'StateCode', 'd.nom'=>"State", 'co.code'=>"CountryCode", 'co.label'=>"Country", 'a.phone'=>"PhonePro", 'a.phone_perso'=>"PhonePerso", 'a.phone_mobile'=>"PhoneMobile", 'a.email'=>"Email", 'a.birth'=>"Birthday", 'a.statut'=>"Status", 'a.photo'=>"Photo", 'a.note_public'=>"NotePublic", 'a.note_private'=>"NotePrivate", 'a.datec'=>'DateCreation', 'a.datevalid'=>'DateValidation', 'a.tms'=>'DateLastModification', 'a.datefin'=>'DateEndSubscription', 'ta.rowid'=>'MemberTypeId', 'ta.libelle'=>'MemberTypeLabel', @@ -301,7 +301,7 @@ class modAdherent extends DolibarrModules 'c.rowid'=>'Numeric', 'c.dateadh'=>'Date', 'c.datef'=>'Date', 'c.subscription'=>'Numeric' ); $this->export_entities_array[$r] = array( - 'a.rowid'=>'member', 'a.civility'=>"member", 'a.lastname'=>"member", 'a.firstname'=>"member", 'a.login'=>"member", 'a.gender'=>'member', 'a.morphy'=>'member', + 'a.rowid'=>'member', 'a.ref'=>'member', 'a.civility'=>"member", 'a.lastname'=>"member", 'a.firstname'=>"member", 'a.login'=>"member", 'a.gender'=>'member', 'a.morphy'=>'member', 'a.societe'=>'member', 'a.address'=>"member", 'a.zip'=>"member", 'a.town'=>"member", 'd.nom'=>"member", 'co.code'=>"member", 'co.label'=>"member", 'a.phone'=>"member", 'a.phone_perso'=>"member", 'a.phone_mobile'=>"member", 'a.email'=>"member", 'a.birth'=>"member", 'a.statut'=>"member", 'a.photo'=>"member", 'a.note_public'=>"member", 'a.note_private'=>"member", 'a.datec'=>'member', 'a.datevalid'=>'member', 'a.tms'=>'member', @@ -338,10 +338,10 @@ class modAdherent extends DolibarrModules $this->import_tables_array[$r] = array('a'=>MAIN_DB_PREFIX.'adherent', 'extra'=>MAIN_DB_PREFIX.'adherent_extrafields'); $this->import_tables_creator_array[$r] = array('a'=>'fk_user_author'); // Fields to store import user id $this->import_fields_array[$r] = array( - 'a.ref' => 'Member Ref*', + 'a.ref' => 'MemberRef*', 'a.civility'=>"UserTitle", 'a.lastname'=>"Lastname*", 'a.firstname'=>"Firstname", 'a.gender'=>"Gender", 'a.login'=>"Login*", "a.pass"=>"Password", - "a.fk_adherent_type"=>"MemberType*", 'a.morphy'=>'MemberNature*', 'a.societe'=>'Company', 'a.address'=>"Address", 'a.zip'=>"Zip", 'a.town'=>"Town", - 'a.state_id'=>'StateId', 'a.country'=>"CountryId", 'a.phone'=>"PhonePro", 'a.phone_perso'=>"PhonePerso", 'a.phone_mobile'=>"PhoneMobile", + "a.fk_adherent_type"=>"MemberTypeId*", 'a.morphy'=>'MemberNature*', 'a.societe'=>'Company', 'a.address'=>"Address", 'a.zip'=>"Zip", 'a.town'=>"Town", + 'a.state_id'=>'StateId|StateCode', 'a.country'=>"CountryId|CountryCode", 'a.phone'=>"PhonePro", 'a.phone_perso'=>"PhonePerso", 'a.phone_mobile'=>"PhoneMobile", 'a.email'=>"Email", 'a.birth'=>"Birthday", 'a.statut'=>"Status*", 'a.photo'=>"Photo", 'a.note_public'=>"NotePublic", 'a.note_private'=>"NotePrivate", 'a.datec'=>'DateCreation', 'a.datefin'=>'DateEndSubscription' ); @@ -397,7 +397,7 @@ class modAdherent extends DolibarrModules if (!empty($conf->societe->enabled)) { $this->import_examplevalues_array[$r]['a.fk_soc'] = "rowid or name"; } - $this->import_updatekeys_array[$r] = array('a.ref'=>'Member Ref', 'a.login'=>'Login'); + $this->import_updatekeys_array[$r] = array('a.ref'=>'MemberRef', 'a.login'=>'Login'); // Cronjobs $arraydate = dol_getdate(dol_now()); diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 38a540ca042..51a50c6376c 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -876,9 +876,9 @@ if ($step == 4 && $datatoimport) { $isrequired = preg_match('/\*$/', $label); if (!empty($isrequired)) { $newlabel = substr($label, 0, -1); - $fieldstarget_tmp[$key] = array("label"=>$newlabel,"required"=>true); + $fieldstarget_tmp[$key] = array("label"=>$newlabel, "required"=>true); } else { - $fieldstarget_tmp[$key] = array("label"=>$label,"required"=>false); + $fieldstarget_tmp[$key] = array("label"=>$label, "required"=>false); } if (!empty($array_match_database_to_file[$key])) { $fieldstarget_tmp[$key]["imported"] = true; @@ -1089,9 +1089,14 @@ if ($step == 4 && $datatoimport) { $optionsall = array(); foreach ($fieldstarget as $code => $line) { //var_dump($line); - $labeltoshow = $langs->transnoentities($line["label"]); - $optionsall[$code] = array('labelkey'=>$line['label'], 'label'=>$labeltoshow, 'required'=>(empty($line["required"]) ? 0 : 1), 'position'=>!empty($line['position']) ? $line['position'] : 0); - // TODO Get type from an new array into module descriptor. + + $tmparray = explode('|', $line["label"]); // If label of field is several translation keys separated with | + $labeltoshow = ''; + foreach ($tmparray as $tmpkey => $tmpval) { + $labeltoshow .= ($labeltoshow ? ' '.$langs->trans('or').' ' : '').$langs->transnoentities($tmpval); + } + $optionsall[$code] = array('labelkey'=>$line['label'], 'labelkeyarray'=>$tmparray, 'label'=>$labeltoshow, 'required'=>(empty($line["required"]) ? 0 : 1), 'position'=>!empty($line['position']) ? $line['position'] : 0); + // TODO Get type from a new array into module descriptor. //$picto = 'email'; $picto = ''; if ($picto) { @@ -1129,9 +1134,6 @@ if ($step == 4 && $datatoimport) { print ''; $entity = (!empty($objimport->array_import_entities[0][$code]) ? $objimport->array_import_entities[0][$code] : $objimport->array_import_icon[0]); - $tablealias = preg_replace('/(\..*)$/i', '', $code); - $tablename = !empty($objimport->array_import_tables[0][$tablealias]) ? $objimport->array_import_tables[0][$tablealias] : ""; - $entityicon = !empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity; // $entityicon must string name of picto of the field like 'project', 'company', 'contact', 'modulename', ... $entitylang = $entitytolang[$entity] ? $entitytolang[$entity] : $objimport->array_import_label[0]; // $entitylang must be a translation key to describe object the field is related to, like 'Company', 'Contact', 'MyModyle', ... @@ -1161,6 +1163,48 @@ if ($step == 4 && $datatoimport) { $label .= $tmpval['label']; $label .= $tmpval['required'] ? '*' : ''; + $tablealias = preg_replace('/(\..*)$/i', '', $tmpcode); + $tablename = !empty($objimport->array_import_tables[0][$tablealias]) ? $objimport->array_import_tables[0][$tablealias] : ""; + + $htmltext = ''; + + $filecolumn = ($i + 1); + // Source field info + if (empty($objimport->array_import_convertvalue[0][$tmpcode])) { // If source file does not need convertion + $filecolumntoshow = num2Alpha($i); + } else { + if ($objimport->array_import_convertvalue[0][$tmpcode]['rule'] == 'fetchidfromref') { + $htmltext .= $langs->trans("DataComeFromIdFoundFromRef", $filecolumn, $langs->transnoentitiesnoconv($entitylang)).'
'; + } + if ($objimport->array_import_convertvalue[0][$tmpcode]['rule'] == 'fetchidfromcodeid') { + $htmltext .= $langs->trans("DataComeFromIdFoundFromCodeId", $filecolumn, $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$code]['dict'])).'
'; + } + } + // Source required + $example = !empty($objimport->array_import_examplevalues[0][$tmpcode])?$objimport->array_import_examplevalues[0][$tmpcode]:""; + // Example + if (empty($objimport->array_import_convertvalue[0][$tmpcode])) { // If source file does not need convertion + if ($example) { + $htmltext .= $langs->trans("SourceExample").': '.str_replace('"', '', $example).'
'; + } + } else { + if ($objimport->array_import_convertvalue[0][$tmpcode]['rule'] == 'fetchidfromref') { + $htmltext .= $langs->trans("SourceExample").': '.$langs->transnoentitiesnoconv("ExampleAnyRefFoundIntoElement", $entitylang).($example ? ' ('.$langs->transnoentitiesnoconv("Example").': '.$example.')' : '').'
'; + } elseif ($objimport->array_import_convertvalue[0][$tmpcode]['rule'] == 'fetchidfromcodeid') { + $htmltext .= $langs->trans("SourceExample").': '.$langs->trans("ExampleAnyCodeOrIdFoundIntoDictionary", $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$code]['dict'])).($example ? ' ('.$langs->transnoentitiesnoconv("Example").': '.$example.')' : '').'
'; + } elseif ($example) { + $htmltext .= $langs->trans("SourceExample").': '.str_replace('"', '', $example).'
'; + } + } + // Format control rule + if (!empty($objimport->array_import_regex[0][$tmpcode])) { + $htmltext .= $langs->trans("FormatControlRule").': '.str_replace('"', '', $objimport->array_import_regex[0][$tmpcode]).'
'; + } + + $htmltext .= $langs->trans("Table")."->".$langs->trans("Field").':   '.$tablename."->".preg_replace('/^.*\./', '', $tmpcode).""; + + $labelhtml = $label.' '.$form->textwithpicto('', $htmltext, 1, 'help', '', 1); + $selectforline .= '
"; print ''; From 71045cbe8337634804955fa4486429576139e9e9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Jul 2022 14:00:19 +0200 Subject: [PATCH 331/367] Fix popup message --- htdocs/admin/mails_emailing.php | 8 ++++++-- htdocs/admin/mails_ticket.php | 8 ++++++-- htdocs/comm/mailing/card.php | 8 +++++++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/htdocs/admin/mails_emailing.php b/htdocs/admin/mails_emailing.php index 40af4c4ae2a..79ddda792e0 100644 --- a/htdocs/admin/mails_emailing.php +++ b/htdocs/admin/mails_emailing.php @@ -427,11 +427,15 @@ if ($action == 'edit') { // Method print ''.$langs->trans("MAIN_MAIL_SENDMODE").''; - $text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE_EMAILING]; + $text = $listofmethods[getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING')]; if (empty($text)) { $text = $langs->trans("Undefined").img_warning(); } - print $text; + if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') == 'default') { + print ''.$text.''; + } else { + print $text; + } print ''; if (!empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'default') { diff --git a/htdocs/admin/mails_ticket.php b/htdocs/admin/mails_ticket.php index 481fcad212c..a439bdabcf0 100644 --- a/htdocs/admin/mails_ticket.php +++ b/htdocs/admin/mails_ticket.php @@ -394,11 +394,15 @@ if ($action == 'edit') { // Method print ''.$langs->trans("MAIN_MAIL_SENDMODE").''; - $text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE_TICKET]; + $text = $listofmethods[getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET')]; if (empty($text)) { $text = $langs->trans("Undefined").img_warning(); } - print $text; + if (getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') == 'default') { + print ''.$text.''; + } else { + print $text; + } print ''; if (!empty($conf->global->MAIN_MAIL_SENDMODE_TICKET) && $conf->global->MAIN_MAIL_SENDMODE_TICKET != 'default') { diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 290a29c02ee..748c5fabf10 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -808,7 +808,13 @@ if ($action == 'create') { $linktoadminemailbefore = ''; $linktoadminemailend = ''; setEventMessages($langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]), null, 'warnings'); - setEventMessages($langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']), null, 'warnings'); + $messagetoshow = $langs->trans("MailSendSetupIs2", '{s1}', '{s2}', '{s3}', '{s4}'); + $messagetoshow = str_replace('{s1}', $linktoadminemailbefore, $messagetoshow); + $messagetoshow = str_replace('{s2}', $linktoadminemailend, $messagetoshow); + $messagetoshow = str_replace('{s3}', $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $messagetoshow); + $messagetoshow = str_replace('{s4}', $listofmethods['smtps'], $messagetoshow); + setEventMessages($messagetoshow, null, 'warnings'); + if (!empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS)) { setEventMessages($langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS), null, 'warnings'); } From 5a7652fd75c75b74a02f50acbc4327528f8eaa64 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Jul 2022 10:15:03 +0200 Subject: [PATCH 332/367] Add test to fetch lines --- htdocs/contrat/class/contrat.class.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 322f3f4652e..1e8da8a9a81 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -668,7 +668,7 @@ class Contrat extends CommonObject if (!$id) { $sql .= " WHERE entity IN (".getEntity('contract').")"; } else { - $sql .= " WHERE rowid=".(int) $id; + $sql .= " WHERE rowid = ".(int) $id; } if ($ref_customer) { $sql .= " AND ref_customer = '".$this->db->escape($ref_customer)."'"; @@ -677,7 +677,7 @@ class Contrat extends CommonObject $sql .= " AND ref_supplier = '".$this->db->escape($ref_supplier)."'"; } if ($ref) { - $sql .= " AND ref='".$this->db->escape($ref)."'"; + $sql .= " AND ref = '".$this->db->escape($ref)."'"; } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); @@ -724,10 +724,13 @@ class Contrat extends CommonObject // Retrieve all extrafields // fetch optionals attributes and labels - $this->fetch_optionals(); + $result = $this->fetch_optionals(); // Lines - $result = $this->fetch_lines(); + if ($result >= 0 && !empty($this->table_element_line)) { + $result = $this->fetch_lines(); + } + if ($result < 0) { $this->error = $this->db->lasterror(); return -3; From 75693ce34a23f6c732402e4020b0b39c126c87df Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Jul 2022 10:56:55 +0200 Subject: [PATCH 333/367] FIX php8 --- htdocs/core/class/extrafields.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index f2463804e32..c12cfc480fc 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -908,7 +908,7 @@ class ExtraFields $this->attributes[$tab->elementtype]['param'][$tab->name] = ($tab->param ? jsonOrUnserialize($tab->param) : ''); $this->attributes[$tab->elementtype]['pos'][$tab->name] = $tab->pos; $this->attributes[$tab->elementtype]['alwayseditable'][$tab->name] = $tab->alwayseditable; - $this->attributes[$tab->elementtype]['perms'][$tab->name] = (strlen($tab->perms) == 0 ? 1 : $tab->perms); + $this->attributes[$tab->elementtype]['perms'][$tab->name] = ((is_null($tab->perms) || strlen($tab->perms) == 0) ? 1 : $tab->perms); $this->attributes[$tab->elementtype]['langfile'][$tab->name] = $tab->langs; $this->attributes[$tab->elementtype]['list'][$tab->name] = $tab->list; $this->attributes[$tab->elementtype]['printable'][$tab->name] = $tab->printable; From 3e6e4cc42826aebaebfeda46415fdd40a0de3cd5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Jul 2022 10:56:55 +0200 Subject: [PATCH 334/367] FIX php8 --- htdocs/core/class/extrafields.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 7a9da4e34a5..0c48cefa281 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -864,7 +864,7 @@ class ExtraFields $this->attributes[$tab->elementtype]['param'][$tab->name] = ($tab->param ? jsonOrUnserialize($tab->param) : ''); $this->attributes[$tab->elementtype]['pos'][$tab->name] = $tab->pos; $this->attributes[$tab->elementtype]['alwayseditable'][$tab->name] = $tab->alwayseditable; - $this->attributes[$tab->elementtype]['perms'][$tab->name] = (strlen($tab->perms) == 0 ? 1 : $tab->perms); + $this->attributes[$tab->elementtype]['perms'][$tab->name] = ((is_null($tab->perms) || strlen($tab->perms) == 0) ? 1 : $tab->perms); $this->attributes[$tab->elementtype]['langfile'][$tab->name] = $tab->langs; $this->attributes[$tab->elementtype]['list'][$tab->name] = $tab->list; $this->attributes[$tab->elementtype]['printable'][$tab->name] = $tab->printable; From d4acad4a7a5e0f7d648237f38d9fa768ef699977 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Jul 2022 11:51:38 +0200 Subject: [PATCH 335/367] FIX #yogosha11774 --- htdocs/install/default.css | 6 +++- htdocs/support/inc.php | 1 + htdocs/support/index.php | 60 +++++++++++++++++++++++++------------- 3 files changed, 45 insertions(+), 22 deletions(-) diff --git a/htdocs/install/default.css b/htdocs/install/default.css index e7bbe6c7771..79f6d3eb9c1 100644 --- a/htdocs/install/default.css +++ b/htdocs/install/default.css @@ -129,6 +129,10 @@ a.button.runupgrade { padding: 10px; } +tr.title.tablesupport-title { + height: 100px; +} + /* Force values for small screen 570 */ @media only screen and (max-width: 570px) { @@ -464,7 +468,7 @@ table.login.tablesupport .title { } table.tablesupport { - min-height: 250px; + min-height: 300px; border: 1px solid #E0E0E0; background: #FFF; } diff --git a/htdocs/support/inc.php b/htdocs/support/inc.php index d5c92cade7b..e6f2afd504d 100644 --- a/htdocs/support/inc.php +++ b/htdocs/support/inc.php @@ -236,6 +236,7 @@ function pHeader($soutitre, $next, $action = 'none') // On force contenu dans format sortie header("Content-type: text/html; charset=".$conf->file->character_set_client); header("X-Content-Type-Options: nosniff"); + header("X-Frame-Options: SAMEORIGIN"); // Frames allowed only if on same domain (stop some XSS attacks) print ''."\n"; print ''."\n"; diff --git a/htdocs/support/index.php b/htdocs/support/index.php index 7330c034aa7..e61fef41f23 100644 --- a/htdocs/support/index.php +++ b/htdocs/support/index.php @@ -77,17 +77,22 @@ print '
'; -print ''; +print ''; +print ''; print ''; print ''; @@ -141,17 +148,22 @@ print "\n"; print '
'; // EMail support -print '
'; -print ''; +print ''; +print ''; print '