[-] MO sendtoafriend: The method used to check all required input fields could lead to errors
This commit is contained in:
1 parent
6449ecfb32
commit
9d94337c9b
2 files changed
+9
-25
No files matched your search
@@ -31,23 +31,17 @@ $('document').ready(function(){
|
|||||||
});
|
});
|
||||||
|
|
||||||
$('#sendEmail').click(function(){
|
$('#sendEmail').click(function(){
|
||||||
var datas = [];
|
|
||||||
$('#send_friend_form_content').find(':input').each(function(index){
|
var name = $('#friend_name').val();
|
||||||
var o = {};
|
var email = $('#friend_email').val();
|
||||||
o.key = $(this).attr('name');
|
var id_product = $('#id_product_comment_send').val();
|
||||||
o.value = $(this).val();
|
if (name && email && !isNaN(id_product))
|
||||||
|
|
||||||
if (o.value != '')
|
|
||||||
datas.push(o);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (datas.length >= 3)
|
|
||||||
{
|
{
|
||||||
$.ajax({
|
$.ajax({
|
||||||
{/literal}url: "{$module_dir}sendtoafriend_ajax.php",{literal}
|
{/literal}url: "{$module_dir}sendtoafriend_ajax.php",{literal}
|
||||||
type: "POST",
|
type: "POST",
|
||||||
headers: {"cache-control": "no-cache"},
|
headers: {"cache-control": "no-cache"},
|
||||||
data: {action: 'sendToMyFriend', secure_key: '{/literal}{$stf_secure_key}{literal}', friend: unescape(JSON.stringify(datas).replace(/\\u/g, '%u'))},{/literal}{literal}
|
data: {action: 'sendToMyFriend', secure_key: '{/literal}{$stf_secure_key}{literal}', name: name, email: email, id_product: id_product},{/literal}{literal}
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function(result) {
|
success: function(result) {
|
||||||
$.fancybox.close();
|
$.fancybox.close();
|
||||||
|
|||||||
@@ -33,19 +33,9 @@ $module = new SendToAFriend();
|
|||||||
|
|
||||||
if (Tools::getValue('action') == 'sendToMyFriend' && Tools::getValue('secure_key') == $module->secure_key)
|
if (Tools::getValue('action') == 'sendToMyFriend' && Tools::getValue('secure_key') == $module->secure_key)
|
||||||
{
|
{
|
||||||
$friend_infos = Tools::jsonDecode(Tools::getValue('friend'));
|
$friendName = Tools::getValue('name');
|
||||||
$friendName = "";
|
$friendMail = Tools::getValue('email');
|
||||||
$friendMail = "";
|
$id_product = Tools::getValue('id_product');
|
||||||
$id_product = null;
|
|
||||||
foreach ($friend_infos as $entry)
|
|
||||||
{
|
|
||||||
if ($entry->key == "friend_name")
|
|
||||||
$friendName = $entry->value;
|
|
||||||
else if ($entry->key == "friend_email")
|
|
||||||
$friendMail = $entry->value;
|
|
||||||
else if ($entry->key == "id_product")
|
|
||||||
$id_product = $entry->value;
|
|
||||||
}
|
|
||||||
if (!$friendName || !$friendMail || !$id_product)
|
if (!$friendName || !$friendMail || !$id_product)
|
||||||
die('0');
|
die('0');
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user