Skip to content

Commit

Permalink
V1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
boiteasite committed Oct 7, 2020
1 parent 7d2d126 commit 15b2a6f
Show file tree
Hide file tree
Showing 9 changed files with 185 additions and 71 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ This contactMailTemplate.php should create the HTML email content : $msgH. It wi

### Versions ###

* 1.5 - xx/03/2020 : Master mode
* 1.6 - 07/10/2020 : Admin can reply to email field if exists. User reply to Admin (no change).
* 1.5 - 24/03/2020 : Master mode
* 1.4 - 08/01/2020 : Fix PHPMailer issue - Custom template - Copy to sender - Custom subject
* 1.3 - 27/12/2017 : W3.css compatibility
* 1.2.2 - 15/03/2017 : Fix issue when unknow lang
Expand Down
4 changes: 4 additions & 0 deletions contact.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ function f_contact_load(){
jQuery.post('uno/plugins/contact/contact.php',{'action':'load','unox':Unox},function(r){
r=JSON.parse(r);
if(r.mail)document.getElementById('contactAdmin').value=r.mail;
if(r.name)document.getElementById('contactName').value=r.name;
if(r.send)document.getElementById('contactSend').value=r.send;
if(r.happy)document.getElementById('contactHappy').value=r.happy;
if(r.subject)document.getElementById('contactSubject').value=r.subject;
if(r.captcha==1)document.getElementById('contactCaptcha').checked=true;else document.getElementById('contactCaptcha').checked=false;
if(r.copy==1)document.getElementById('contactCopy').checked=true;else document.getElementById('contactCopy').checked=false;
if(r.master==1)document.getElementById('contactMaster').checked=true;else document.getElementById('contactMaster').checked=false;
if(r.reply==1)document.getElementById('contactReply').checked=true;else document.getElementById('contactReply').checked=false;
jQuery("#contactResult").empty();
jQuery.each(r.frm,function(k,v){f_contact_add(v.l,v.t);});
});
Expand All @@ -24,12 +26,14 @@ function f_contact_save(){
h.push({name:'action',value:'save'});
h.push({name:'unox',value:Unox});
h.push({name:'contactAdmin',value:document.getElementById('contactAdmin').value});
h.push({name:'contactName',value:document.getElementById('contactName').value});
h.push({name:'contactSend',value:document.getElementById('contactSend').value});
h.push({name:'contactHappy',value:document.getElementById('contactHappy').value});
h.push({name:'contactSubject',value:document.getElementById('contactSubject').value});
h.push({name:'contactCaptcha',value:document.getElementById('contactCaptcha').checked});
h.push({name:'contactCopy',value:document.getElementById('contactCopy').checked});
h.push({name:'contactMaster',value:document.getElementById('contactMaster').checked});
h.push({name:'contactReply',value:document.getElementById('contactReply').checked});
jQuery.post('uno/plugins/contact/contact.php',h,function(r){f_alert(r);});
});
}
Expand Down
21 changes: 17 additions & 4 deletions contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
<td><input type="text" class="input" name="contactAdmin" id="contactAdmin" /></td>
<td><em><?php echo T_("E-mail address of destination : Your email address or the contact site.");?></em></td>
</tr>
<tr>
<td><label><?php echo T_("Name");?></label></td>
<td><input type="text" class="input" name="contactName" id="contactName" /></td>
<td><em><?php echo T_("The name for your email address.");?></em></td>
</tr>
<tr>
<td><label><?php echo T_("Send button");?></label></td>
<td><input type="text" class="input" name="contactSend" id="contactSend" /></td>
Expand All @@ -53,19 +58,24 @@
</tr>
<tr>
<td><label><?php echo T_("Enable Captcha");?></label></td>
<td><input type="checkbox" class="input" name="contactCaptcha" id="contactCaptcha" /></td>
<td><input type="checkbox" class="input" name="contactCaptcha" id="contactCaptcha" /></td>
<td><em><?php echo T_("Code image to enter to block the automatic sending of email by robots.");?></em></td>
</tr>
<tr>
<td><label><?php echo T_("Mail to author");?></label></td>
<td><input type="checkbox" class="input" name="contactCopy" id="contactCopy" /></td>
<td><input type="checkbox" class="input" name="contactCopy" id="contactCopy" /></td>
<td><em><?php echo T_("Send a copy to the emails of the form.").' ('.T_("Text email").')';?></em></td>
</tr>
<tr>
<td><label><?php echo T_("Master mode");?></label></td>
<td><input type="checkbox" class="input" name="contactMaster" id="contactMaster" /></td>
<td><input type="checkbox" class="input" name="contactMaster" id="contactMaster" /></td>
<td><em><?php echo T_("In multipage site, the configuration will be centralized on the master page.");?></em></td>
</tr>
<tr>
<td><label><?php echo T_("Reply to the email");?></label></td>
<td><input type="checkbox" class="input" name="contactReply" id="contactReply" /></td>
<td><em><?php echo T_("Reply to the first email field if exists. Default is admin email.");?></em></td>
</tr>
</table>
<h3><?php echo T_("Add a field :");?></h3>
<table class="hForm">
Expand Down Expand Up @@ -105,14 +115,17 @@
}
else $a['mail'] = $_POST['contactAdmin'];
$a['send'] = (stripslashes($_POST['contactSend'])?stripslashes($_POST['contactSend']):'OK');
$a['name'] = (!empty($_POST['contactName'])?stripslashes($_POST['contactName']):'No Reply');
$a['happy'] = stripslashes($_POST['contactHappy']);
$a['subject'] = stripslashes($_POST['contactSubject']);
if($_POST['contactMaster']=="true" && !file_exists('../../data/contactMaster.txt')) file_put_contents('../../data/contactMaster.txt', '1');
else if($_POST['contactMaster']!="true" && file_exists('../../data/contactMaster.txt')) unlink('../../data/contactMaster.txt');
if($_POST['contactCaptcha']=="true") $a['captcha']=1; else $a['captcha']=0;
if($_POST['contactCopy']=="true") $a['copy']=1; else $a['copy']=0;
if($_POST['contactReply']=="true") $a['reply']=1; else $a['reply']=0;
$b = array('action','unox','contactAdmin','contactName','contactSend','contactHappy','contactCaptcha','contactSubject','contactCopy','contactMaster','contactReply');
foreach($_POST as $k=>$v) {
if($k!='action' && $k!='unox' && $k!='contactAdmin' && $k!='contactSend' && $k!='contactHappy' && $k!='contactCaptcha' && $k!='contactSubject' && $k!='contactCopy' && $k!='contactMaster') {
if(!in_array($k,$b)) {
$a['frm'][$c]['t'] = substr($k,0,2);
$a['frm'][$c]['l'] = stripslashes(substr($k,2));
}
Expand Down
32 changes: 27 additions & 5 deletions contactCall.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,26 @@
$mailadm = (!empty($c['mail'])?$c['mail']:$a['mel']);
if(!filter_var($mailadm, FILTER_VALIDATE_EMAIL)) die;
$happy = (!empty($c['happy'])?$c['happy']:'');
$name = (!empty($c['name'])?$c['name']:'No Reply');
$copy = array();
$l = 0;
$reply = (!empty($c['reply'])?'':false);
foreach($_POST as $k=>$v) {
if($k!='action') {
$v = strip_tags($v);
$kk = $k;
if(substr($k,0,5)=='mail0' && filter_var($v,FILTER_VALIDATE_EMAIL)) $copy[] = $v;
if(substr($k,0,5)=='mail0' && filter_var($v,FILTER_VALIDATE_EMAIL)) {
$copy[] = $v;
if($reply==='') $reply = $v;
}
if(substr($k,0,5)=='text0' || substr($k,0,5)=='area0' || substr($k,0,5)=='mail0') $kk = substr($k,5);
$msgT .= $kk.' : '.$v."\r\n";
$msgH .= '<tr><td>'.$kk.'</td><td> : '.$v.'</td></tr>';
$l += strlen($v);
}
}
$name2 = (!empty($reply)?'User':$name);
if(empty($reply)) $reply = $mailadm;
$msgH .= "</table>" . $bottom;
if(file_exists('../../template/'.$b['tem'].'/contactMailTemplate.php')) include('../../template/'.$b['tem'].'/contactMailTemplate.php'); // custom template with custom methods - $msgH
if(empty($a['subject'])) $sujet = $b['tit'] . " - Contact";
Expand All @@ -55,7 +62,7 @@
$phm = new PHPMailer();
$phm->CharSet = "UTF-8";
$phm->Encoding = "base64";
$phm->setFrom($mailadm, 'No Reply');
$phm->setFrom($reply, $name2);
$phm->addAddress($mailadm);
$phm->isHTML(true);
$phm->Subject = stripslashes($sujet);
Expand All @@ -69,7 +76,7 @@
$phm->ClearAllRecipients();
$phm->CharSet = "UTF-8";
$phm->Encoding = "base64";
$phm->setFrom($mail, 'No Reply');
$phm->setFrom($mailadm, $name);
foreach($copy as $r) {
if(filter_var($r, FILTER_VALIDATE_EMAIL)) $phm->addAddress($r);
++$ncopy;
Expand All @@ -85,9 +92,9 @@
}
else {
$boundary = "-----=".md5(rand());
if(!preg_match("#^[a-z0-9._-]+@(hotmail|live|msn).[a-z]{2,4}$#", $mailadm)) $rn = "\r\n";
if(!preg_match("#^[a-z0-9._-]+@(hotmail|live|msn).[a-z]{2,4}$#", $reply)) $rn = "\r\n";
else $rn = "\n";
$header = "From: \"No reply\"<".$mailadm.">".$rn;
$header = "From: \"".$name2."\"<".$reply.">".$rn;
$header.= "MIME-Version: 1.0".$rn;
$header.= "Content-Type: multipart/alternative;".$rn." boundary=\"$boundary\"".$rn;
$msg= $rn."--".$boundary.$rn;
Expand All @@ -104,6 +111,21 @@
if(!$happy) echo T_('OK');
else echo " ".$happy;
if(!empty($c['copy']) && !empty($copy)) {
if(!preg_match("#^[a-z0-9._-]+@(hotmail|live|msn).[a-z]{2,4}$#", $mailadm)) $rn = "\r\n";
else $rn = "\n";
$header = "From: \"".$name."\"<".$mailadm.">".$rn;
$header.= "MIME-Version: 1.0".$rn;
$header.= "Content-Type: multipart/alternative;".$rn." boundary=\"$boundary\"".$rn;
$msg= $rn."--".$boundary.$rn;
$msg.= "Content-Type: text/plain; charset=\"utf-8\"".$rn;
$msg.= "Content-Transfer-Encoding: 8bit".$rn;
$msg.= $rn.$msgT.$rn;
$msg.= $rn."--".$boundary.$rn;
$msg.= "Content-Type: text/html; charset=\"utf-8\"".$rn;
$msg.= "Content-Transfer-Encoding: 8bit".$rn;
$msg.= $rn.$msgH.$rn;
$msg.= $rn."--".$boundary."--".$rn;
$msg.= $rn."--".$boundary."--".$rn;
foreach($copy as $r) if(filter_var($r, FILTER_VALIDATE_EMAIL)) mail($r, stripslashes($sujet), stripslashes($msg), $header);
}
}
Expand Down
Binary file modified lang/es_ES.utf8/LC_MESSAGES/contact.mo
Binary file not shown.
97 changes: 67 additions & 30 deletions lang/es_ES.utf8/LC_MESSAGES/contact.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ msgid ""
msgstr ""
"Project-Id-Version: CmsUno\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-01-08 11:50+0100\n"
"PO-Revision-Date: 2020-01-08 11:51+0100\n"
"POT-Creation-Date: 2020-10-07 19:24+0200\n"
"PO-Revision-Date: 2020-10-07 19:27+0200\n"
"Last-Translator: malgrange <[email protected]>\n"
"Language-Team: Jacques Malgrange <[email protected]>\n"
"Language: es_ES\n"
Expand All @@ -18,135 +18,172 @@ msgstr ""
"X-Generator: Poedit 1.8.7.1\n"
"X-Poedit-SearchPath-0: ../../..\n"

#: ../../../contact.php:19
#: ../../../contact.php:22
msgid ""
"This plugin allows you to create a contact form that can be installed at any "
"location of the site."
msgstr ""
"Este plugin te permite crear un formulario de contacto que se puede instalar "
"en cualquier ubicación del sitio."

#: ../../../contact.php:20
#: ../../../contact.php:23
msgid "Just insert the code"
msgstr "Sólo tiene que insertar el código"

#: ../../../contact.php:20
#: ../../../contact.php:23
msgid ""
"in the text of your page or directly into the template. This code will be "
"replaced by the form."
msgstr ""
"en el texto de su página o directamente en la plantilla. Este código será "
"reemplazado por el formulario."

#: ../../../contact.php:23
#: ../../../contact.php:26
msgid "Master mode activated."
msgstr "Modo maestro activado."

#: ../../../contact.php:28
msgid "Config the plugin in the master page : "
msgstr "Configure el plugin en la página maestra :"

#: ../../../contact.php:35
msgid "Admin email"
msgstr "Admin email"

#: ../../../contact.php:25
#: ../../../contact.php:37
msgid "E-mail address of destination : Your email address or the contact site."
msgstr ""
"E-mail de destino : Tu dirección de correo electrónico o en el sitio de "
"contacto."

#: ../../../contact.php:28
#: ../../../contact.php:40
msgid "Name"
msgstr "Nombre"

#: ../../../contact.php:42
msgid "The name for your email address."
msgstr "El nombre de su dirección de email."

#: ../../../contact.php:45
msgid "Send button"
msgstr "Enviar botón"

#: ../../../contact.php:30
#: ../../../contact.php:47
msgid "The word that should appear on the 'Send' button."
msgstr "La palabra que debe aparecer en el botón 'Enviar'."

#: ../../../contact.php:33
#: ../../../contact.php:50
msgid "Thank you"
msgstr "Gracias"

#: ../../../contact.php:35
#: ../../../contact.php:52
msgid ""
"The sentence of thanks that will be displayed on the screen after sending "
"the message."
msgstr ""
"La frase de agradecimiento que se mostrará en la pantalla después de enviar "
"el mensaje."

#: ../../../contact.php:38
#: ../../../contact.php:55
msgid "Subject"
msgstr "Tema"

#: ../../../contact.php:40
#: ../../../contact.php:57
msgid "The title of the email for sending. Empty => Site title - Contact"
msgstr "El título del email para enviar. Vacío => Título del sitio - Contacto"

#: ../../../contact.php:43
#: ../../../contact.php:60
msgid "Enable Captcha"
msgstr "Habilitar Captcha"

#: ../../../contact.php:45
#: ../../../contact.php:62
msgid "Code image to enter to block the automatic sending of email by robots."
msgstr ""
"La imagen del código para entrar en bloquear el envío de la automática de "
"correo electrónico por robots."

#: ../../../contact.php:48
#: ../../../contact.php:65
msgid "Mail to author"
msgstr "Enviar al autor"

#: ../../../contact.php:50
#: ../../../contact.php:67
msgid "Send a copy to the emails of the form."
msgstr "Envíe una copia a los email del formulario"

#: ../../../contact.php:50 ../../../contact.php:61
#: ../../../contact.php:67 ../../../contact.php:88
msgid "Text email"
msgstr "Text email"

#: ../../../contact.php:53
#: ../../../contact.php:70
msgid "Master mode"
msgstr "Modo maestro"

#: ../../../contact.php:72
msgid ""
"In multipage site, the configuration will be centralized on the master page."
msgstr ""
"En un sitio de varias páginas, la configuración se centralizará en la página "
"maestra."

#: ../../../contact.php:75
msgid "Reply to the email"
msgstr "Responder al email"

#: ../../../contact.php:77
msgid "Reply to the first email field if exists. Default is admin email."
msgstr ""
"Responda al primer campo de email si existe. El valor predeterminado es el "
"email de admin."

#: ../../../contact.php:80
msgid "Add a field :"
msgstr "Añadir un campo :"

#: ../../../contact.php:56
#: ../../../contact.php:83
msgid "Label"
msgstr "Label"

#: ../../../contact.php:60
#: ../../../contact.php:87
msgid "Text"
msgstr "Texto"

#: ../../../contact.php:62
#: ../../../contact.php:89
msgid "Textarea"
msgstr "Textarea"

#: ../../../contact.php:65 ../../../contact.php:72
#: ../../../contact.php:92 ../../../contact.php:99
msgid "Save settings"
msgstr "Guardar ajustes"

#: ../../../contact.php:65
#: ../../../contact.php:92
msgid "Add"
msgstr "Añadir"

#: ../../../contact.php:68
#: ../../../contact.php:95
msgid "Result :"
msgstr "Resultado :"

#: ../../../contact.php:72
#: ../../../contact.php:99
msgid "Save"
msgstr "Guardar"

#: ../../../contact.php:106
#: ../../../contact.php:135
msgid "Backup performed"
msgstr "Copia de seguridad realizada"

#: ../../../contact.php:107
#: ../../../contact.php:136
msgid "Impossible backup"
msgstr "Copia de seguridad Imposible"

#: ../../../contactCall.php:20
msgid "Captcha error"
msgstr "Error de CAPTCHA"

#: ../../../contactCall.php:66 ../../../contactCall.php:104
#: ../../../contactCall.php:72 ../../../contactCall.php:111
msgid "OK"
msgstr "OK"

#: ../../../contactCall.php:82 ../../../contactCall.php:111
#: ../../../contactCall.php:91 ../../../contactCall.php:132
msgid "Failed to send"
msgstr "Fallo al enviar"

Expand Down
Binary file modified lang/fr_FR.utf8/LC_MESSAGES/contact.mo
Binary file not shown.
Loading

0 comments on commit 15b2a6f

Please sign in to comment.