14 if (!defined(
'IN_PEEL')) {
38 function send_email($to, $mail_subject =
'', $mail_content =
'', $template_technical_code = null, $template_tags = null, $format = null, $sender = null, $html_add_structure =
true, $html_correct_conformity =
false, $html_convert_url_to_links =
true, $reply_to = null, $attached_files_infos_array = null,
$lang = null, $additional_infos_array = array(), $attachment_not_sent_by_email =
false)
48 $format =
vb(
$GLOBALS[
'site_parameters'][
'email_sending_format_default'],
'html');
50 if (defined(
'IN_PEEL_ADMIN') &&
a_priv(
'demo')) {
51 echo
$GLOBALS[
'tplEngine']->createTemplate(
'global_error.tpl', array(
'message' =>
$GLOBALS[
'STR_ADMIN_DEMO_EMAILS_DEACTIVATED']))->fetch();
54 if(is_array($sender)) {
55 $from = $sender[
'email'];
59 if (empty($from) && !empty(
$GLOBALS[
'support'])) {
62 $used_template_technical_code = null;
63 if (!empty($template_technical_code)) {
64 if(!is_array($template_technical_code)) {
65 $template_technical_code = array($template_technical_code);
67 foreach($template_technical_code as $this_template_technical_code) {
69 if (!empty($template_infos)) {
72 if (empty($mail_subject)) {
73 $mail_subject = $template_infos[
'subject'];
75 if (empty($mail_content)) {
76 $mail_content = $template_infos[
'text'];
78 if (!empty($mail_content)) {
79 if (!empty($template_infos[
"default_signature_code"])) {
81 $signature = $template_infos[
"default_signature_code"];
83 $signature =
'signature';
86 if (!empty($signature_infos)) {
87 $mail_content .= $signature_infos[
'text'];
90 $used_template_technical_code = $this_template_technical_code;
95 if (empty($mail_subject) && empty($mail_content)) {
98 $mail_header =
"Content-Transfer-Encoding: 8bit" . $eol;
99 $mail_header .=
"MIME-Version: 1.0" . $eol;
102 if ($from ==
$GLOBALS[
'support'] && !empty(
$GLOBALS[
'site_parameters'][
'nom_expediteur'])) {
103 $email_name_rules = array(
"\r" =>
'',
"\n" =>
'',
"\t" =>
'',
'"' =>
"'",
',' =>
'',
'<' =>
'[',
'>' =>
']');
104 $nom_expediteur = strtr(
$GLOBALS[
'site_parameters'][
'nom_expediteur'], $email_name_rules);
106 $nom_expediteur =
'';
108 $temp = explode(
',', str_replace(
';',
',', $from));
109 $from = trim($temp[0]);
111 if (!empty($nom_expediteur)) {
112 $mail_header .=
'From: "' . $nom_expediteur .
'" <' . $from .
'>' . $eol;
114 $mail_header .=
'From: ' . $from . $eol;
116 if (!empty($reply_to)) {
118 $reply_to_array = explode(
',', str_replace(
';',
',', $reply_to));
119 $reply_to = trim($reply_to_array[0]);
120 $mail_header .=
"Reply-To: " . $reply_to .
"" . $eol;
122 $mail_header .=
"Reply-To: " . $from .
"" . $eol;
124 $mail_header .=
"Return-Path:" . $from .
"" . $eol;
126 if ($format !=
"text") {
128 if (strip_tags($mail_content) != $mail_content) {
135 $mail_content = str_replace(array(
"\n"),
"<br />\n", str_replace(array(
"\r\n",
"\r"), array(
"\n",
"\n"), $mail_content));
142 if ($format ==
"text") {
145 if (empty($attached_files_infos_array)) {
147 $mail_header .=
"Content-Type: text/plain; charset=" . GENERAL_ENCODING .
"" . $eol;
149 $mail_body = $mail_content;
154 $mail_content =
String::htmlentities($mail_content, null, GENERAL_ENCODING,
false,
true,
false);
155 if ($html_correct_conformity) {
159 if (empty($attached_files_infos_array)) {
161 $mail_header .=
"Content-Type: text/html; charset=" . GENERAL_ENCODING .
"" . $eol;
165 if ($html_convert_url_to_links) {
167 $mail_content =
url2Link($mail_content);
170 $mail_body =
'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
173 <meta http-equiv="Content-Type" content="text/html; charset=' . GENERAL_ENCODING .
'">
174 <title>' . $mail_subject .
'</title>
177 ' . $mail_content .
'
181 $mail_body = $mail_content;
185 if (!empty($attached_files_infos_array) && !$attachment_not_sent_by_email) {
186 $main_document_attached = $attached_files_infos_array[
'path_file_attachment'][0] . $attached_files_infos_array[
'name'][0];
187 $mime_boundary_main = md5(uniqid() .
'iéhf|ao5225izah%0g'.mt_rand(1,1000000));
188 $mime_boundary_html_or_plain = md5(mt_rand(1,1000000).
'iéhf|ao5225izah%0g' . uniqid());
190 $mail_header .=
"Content-Type: multipart/mixed; boundary=\"" . $mime_boundary_main .
"\"" .
"" . $eol;
192 $msg =
"--" . $mime_boundary_main .
"" . $eol;
193 $msg .=
"Content-Type: multipart/alternative; boundary=\"" . $mime_boundary_html_or_plain .
"\"" . $eol . $eol;
195 $msg .=
"--" . $mime_boundary_html_or_plain .
"" . $eol;
196 $msg .=
"Content-Type: text/plain; charset=" . GENERAL_ENCODING .
"" . $eol;
197 $msg .=
"Content-Transfer-Encoding: 8bit" .
"" . $eol . $eol;
199 if ($format ==
"html") {
201 $msg .=
"--" . $mime_boundary_html_or_plain .
"" . $eol;
202 $msg .=
"Content-Type: text/html; charset=" . GENERAL_ENCODING .
"" . $eol;
203 $msg .=
"Content-Transfer-Encoding: 8bit" . $eol . $eol;
204 $msg .= $mail_body . $eol;
206 $msg .=
"--".$mime_boundary_html_or_plain.
"--" .
"" . $eol . $eol;
207 for($j = 0;$j < count($attached_files_infos_array[
'name']); $j++) {
208 if(!empty($attached_files_infos_array[
'content'][$j])) {
209 $fichier = $attached_files_infos_array[
'content'][$j];
211 $fichier = file_get_contents($attached_files_infos_array[
'path_file_attachment'][$j] . $attached_files_infos_array[
'name'][$j]);
213 $msg .=
"--" . $mime_boundary_main .
"" . $eol;
214 $msg .=
"Content-Type: " . $attached_files_infos_array[
'type-mime'][$j] .
"; name=\"" . $attached_files_infos_array[
'name'][$j] .
"\"" .
"" . $eol;
215 $msg .=
"Content-Transfer-Encoding: base64" .
"" . $eol;
216 $msg .=
"Content-Disposition: attachment; filename=\"" . $attached_files_infos_array[
'name'][$j] .
"\"" .
"" . $eol . $eol;
217 $msg .= chunk_split(base64_encode($fichier)) .
"" . $eol . $eol;
219 $msg .=
"--" . $mime_boundary_main .
"--" .
"" . $eol . $eol;
222 $recipient_array = explode(
',', str_replace(
';',
',', $to));
225 foreach($recipient_array as $this_email) {
226 $this_email = trim($this_email);
227 if(empty($used_template_technical_code) || !in_array($used_template_technical_code,
vb(
$GLOBALS[
'site_parameters'][
'send_email_technical_codes_no_email'], array()))) {
228 if (empty($this_email) ||
$i > 10) {
232 if (((strpos(
$GLOBALS[
'wwwroot'],
'://localhost')===
false && strpos(
$GLOBALS[
'wwwroot'],
'://127.0.0.1')===
false) || !empty(
$GLOBALS[
'site_parameters'][
'localhost_send_email_active'])) && !empty(
$GLOBALS[
'site_parameters'][
'send_email_active'])) {
235 $result = mail($this_email,
'=?' .
String::strtoupper(GENERAL_ENCODING) .
'?B?' . base64_encode($mail_subject) .
'?=', $mail_body, $mail_header);
237 $result = mail($this_email, $mail_subject, $mail_body, $mail_header);
239 if(!empty(
$GLOBALS[
'site_parameters'][
'trigger_user_notice_email_sent']) && empty(
$GLOBALS[
'display_errors'])) {
240 trigger_error(
'Email sent to ' . $this_email .
' : ' . $mail_subject, E_USER_NOTICE);
243 trigger_error(
'Email invalide : ' . $this_email, E_USER_NOTICE);
248 echo
$GLOBALS[
'tplEngine']->createTemplate(
'global_success.tpl', array(
'message' => sprintf(
$GLOBALS[
'STR_EMAIL_SENDING_DEACTIVATED'], $mail_subject)))->fetch();
252 if(is_array($sender)) {
257 $params = array_merge($params, array(
'recipient_array' => array($this_email),
'from' => $from,
'mail_subject' => $mail_subject,
'mail_content' => $mail_content,
'technical_code' => $used_template_technical_code,
'document' =>
vb($main_document_attached)), $additional_infos_array);
258 if(empty($params[
'id_expediteur']) && !empty($from)) {
259 if(!empty($params[
'id_utilisateur'])) {
260 $params[
'id_expediteur'] = $params[
'id_utilisateur'];
263 FROM peel_utilisateurs
266 $params[
'id_expediteur'] =
$result[
'id_utilisateur'];
285 return(preg_match(
'/^[[:alnum:]]*((\.|_|-)[[:alnum:]]+)*@[[:alnum:]]*((\.|-)[[:alnum:]]+)*(\.[[:alpha:]]{2,})/i', $email));
297 if (!empty($user_id)) {
298 $sql_additional_fields =
'';
299 $q =
'SELECT *' . $sql_additional_fields .
'
301 WHERE id_utilisateur="' . intval($user_id) .
'"';
304 foreach($row_account as $key => $value) {
305 if ($key !=
'mot_passe') {
311 if (!empty($order_id)) {
312 $q =
'SELECT o.code_facture
313 FROM peel_commandes o
317 $template_tags[
'ORDER'] =
'';
318 $template_tags[
'ORDER_LINK'] =
'[link="' .
$GLOBALS[
'wwwroot'] .
'/factures/commande_pdf.php?code_facture=' . urlencode($row_orders[
'code_facture']) .
'&mode=facture"]Facture n°' . urlencode($_POST[
'form_order']) .
'[/link]';
320 return $template_tags;
335 FROM peel_email_template
337 if(!empty($template_technical_id)) {
338 $sql .=
' AND id="' . intval($template_technical_id) .
'"';
344 if ($this_template =
fetch_assoc($query_template)) {
345 if(!empty($this_template[
'lang'])) {
346 $this_lang = $this_template[
'lang'];
347 }
elseif(!empty($template_lang)) {
348 $this_lang = $template_lang;
350 $this_lang =
$_SESSION[
'session_langue'];
352 if ($this_template[
'technical_code'] !=
'layout') {
354 if(!empty($generic_layout_infos[
'text'])) {
359 if (
String::strpos($this_template[
'text'],
'[NEWSLETTER]') !==
false) {
362 if(!empty($news_infos[
'sujet_' . $this_lang])) {
363 $this_template[
'subject'] = $news_infos[
'sujet_' . $this_lang];
367 return $this_template;
382 $sql_cond_array[] =
"id='".intval(
$id).
"'";
386 $sql_cond_array[] =
"(sujet_".$lang.
"!='' OR message_".
$lang.
"!='')";
388 if(empty($sql_cond_array)) {
389 $sql_cond_array[] = 1;
391 $sql =
"SELECT id, date, format, template_technical_code, statut, sujet_".$lang.
", message_".
$lang.
"
static strtoupper($string)
Returns string with all alphabetic characters converted to uppercase.
static strip_tags($string, $allowed_tags=null)
String::strip_tags()
static htmlentities($string, $flags=ENT_COMPAT, $charset=GENERAL_ENCODING, $suppr_endline=false, $encode_only_isolated_amperstands=false, $decode_html_entities_first=false)
Convert all applicable characters to HTML entities Cette fonction sert si on veut afficher du contenu...
static strpos($haystack, $needle, $offset=0)
Returns the numeric position of the first occurrence of needle in the haystack string.
static getCleanHTML($text, $max_width=null, $allow_form=false, $allow_object=false, $allow_class=false, $additional_config=null, $safe=true, $additional_elements=null, $max_caracters_length=50000, $max_octets_length=59000, $max_word_and_url_length=100)
Fonction qui nettoie le HTML.
word_real_escape_string($value)
Applique real_escape_string dans le cas où on n'insère qu'un seul mot, de moins de 30 caractères...
get_last_newsletter($id=null, $lang=null)
Récupère les informations de la newsletter de l'id demandée, ou de la dernière newsletter dans une la...
static strtolower($string)
Returns string with all alphabetic characters converted to lowercase.
nohtml_real_escape_string($value, $allowed_tags=null)
Protège les données pour insertion dans MySQL ET supprime les tags HTML pour protéger de toute sorte ...
real_escape_string($value)
real_escape_string()
get_filter_site_cond($table_technical_code, $table_alias=null, $use_strict_rights_if_in_admin=false, $specific_site_id=null, $exclude_public_items=false, $admin_force_multisite_if_allowed=false)
Retourne la condition SQL permettant de filtrer les données pour une table.
query($query, $die_if_error=false, $database_object=null, $silent_if_error=false, $security_sql_filter=true)
The query() function is meant to be called anywhere you want to make a query.
if(strlen($date2)== '10') if($type== 'users-by-age'&&a_priv('admin_users', true)) elseif($type== 'forums-count'&&a_priv('admin_content', true)) elseif($type== 'forums-categories'&&a_priv('admin_content', true)) elseif($type== 'users-count'&&a_priv('admin_users', true)) elseif($type== 'product-categories'&&a_priv('admin_products', true)) elseif($type== 'users-by-sex'&&a_priv('admin_users', true)) elseif($type== 'users-by-country'&&a_priv('admin_users', true)) elseif($type== 'sales'&&a_priv('admin_sales', true))
EmailOK($email)
Vérification du format d'adresse email trouvée sur http://www.phpinfo.net/?p=trucs&rub=astuces.
if(!defined('IN_PEEL')) send_email($to, $mail_subject= '', $mail_content= '', $template_technical_code=null, $template_tags=null, $format=null, $sender=null, $html_add_structure=true, $html_correct_conformity=false, $html_convert_url_to_links=true, $reply_to=null, $attached_files_infos_array=null, $lang=null, $additional_infos_array=array(), $attachment_not_sent_by_email=false)
Envoi d'un email à un utilisateur.
fetch_assoc($query_result)
fetch_assoc()
call_module_hook($hook, $params, $mode= 'boolean')
Appelle la fonction correspondant au $hook pour chaque module installé La fonction doit s'appeler : [...
$GLOBALS['page_columns_count']
getTextAndTitleFromEmailTemplateLang($template_technical_code, $template_lang, $template_technical_id=null)
getTextAndTitleFromEmailTemplateLang()
a_priv($requested_priv, $demo_allowed=false, $site_configuration_modification=false, $user_id=null)
Renvoie true si l'utilisateur de la session a le privilège $requested_priv ou un droit supérieur Des ...
static html_entity_decode($string, $quote_style=ENT_COMPAT, $charset=GENERAL_ENCODING)
String::html_entity_decode()
prepare_email_tags($user_id, $order_id)
Création d'un tableau contenant la correspondance entre nom des tags et valeur à utiliser.
static nl2br_if_needed($string)
Fonction de compatibilité avec de vieilles versions de PEEL ou du contenu qui vient d'ailleurs...
if(defined('IN_PEEL_ADMIN')||IN_INSTALLATION) $_SESSION['session_langue']