PEEL Shopping
Open source ecommerce : PEEL Shopping
direaunami.php
Go to the documentation of this file.
1 <?php
2 // This file should be in UTF8 without BOM - Accents examples: éèê
3 // +----------------------------------------------------------------------+
4 // | Copyright (c) 2004-2015 Advisto SAS, service PEEL - contact@peel.fr |
5 // +----------------------------------------------------------------------+
6 // | This file is part of PEEL Shopping 8.0.0, which is subject to an |
7 // | opensource GPL license: you are allowed to customize the code |
8 // | for your own needs, but must keep your changes under GPL |
9 // | More information: https://www.peel.fr/lire/licence-gpl-70.html |
10 // +----------------------------------------------------------------------+
11 // | Author: Advisto SAS, RCS 479 205 452, France, https://www.peel.fr/ |
12 // +----------------------------------------------------------------------+
13 // $Id: direaunami.php 47317 2015-10-12 13:33:32Z gboussin $
14 //
15 if (defined('IN_PEEL')) {
16  return;
17 }
18 include("../../configuration.inc.php");
19 
20 if (!check_if_module_active('direaunami')) {
21  // This module is not activated => we redirect to the homepage
22  redirect_and_die(get_url('/'));
23 }
24 
25 if (!empty($_POST)) {
26  $yname = vb($_POST['yname']);//sender
27  $yemail = vb($_POST['yemail']);//sender
28 
29  $items = 5;
30  $fname = array();
31  $femail = array();
32  for ($numitems = 0; $numitems < $items; $numitems++) {
33  if(!empty($_POST['femail'][$numitems])){
34  $fname[$numitems] = vb($_POST['fname'][$numitems]);//receiver
35  $femail[$numitems] = vb($_POST['femail'][$numitems]);//receiver
36  }
37  }
38 
39  $referer = vb($_POST['referer']);//URL
40  $comments = vb($_POST['comments']);//COmments
41 } else {
42  $yname = trim(vb($_SESSION['session_utilisateur']['prenom']).' '.vb($_SESSION['session_utilisateur']['nom_famille']));//sender
43  $yemail = vb($_SESSION['session_utilisateur']['email']);//sender
44 }
45 
46 
47 define('IN_TELL_FRIEND', true);
48 
49 include($GLOBALS['repertoire_modele'] . "/haut.php");
50 
51 switch (vb($_POST['mode'])) {
52  case "send" :
53  if (empty($_SERVER['HTTP_USER_AGENT']) || $_SERVER['REQUEST_METHOD'] != "POST" || empty($_SESSION['session_init_form_direaunami'])) {
54  // Protection du formulaire contre les robots
55  die();
56  }
57  $tpl = $GLOBALS['tplEngine']->createTemplate('modules/direaunami_send.tpl');
58  $tpl->assign('STR_TELL_FRIEND', $GLOBALS['STR_TELL_FRIEND']);
59  $tpl->assign('STR_MODULE_DIREAUNAMI_MSG_ERR_FRIEND', $GLOBALS['STR_MODULE_DIREAUNAMI_MSG_ERR_FRIEND']);
60  $tpl->assign('STR_MODULE_DIREAUNAMI_MSG_FRIEND_SEND', $GLOBALS['STR_MODULE_DIREAUNAMI_MSG_FRIEND_SEND']);
61  $tpl->assign('STR_MODULE_DIREAUNAMI_BACK_REFERER', $GLOBALS['STR_MODULE_DIREAUNAMI_BACK_REFERER']);
62  if (empty($yname) || empty($fname[0]) || empty($femail[0]) || empty($yemail)) {
63  $tpl->assign('is_error', true);
64  } else {
65  $tpl->assign('is_error', false);
66  $items = 5;
67  if (String::strpos($referer, $GLOBALS['wwwroot']) === 0) {
68  $product_link = $referer;
69  } elseif (String::substr($referer, 0 , 1) == '/') {
70  // Referer court ou tentative de hack
71  $product_link = $GLOBALS['wwwroot'] . $referer;
72  } else {
73  // Tentative de hack a priori
74  $product_link = $GLOBALS['wwwroot'];
75  }
76  for ($numitems = 0; $numitems < $items; $numitems++) {
77  if ((!empty($fname[$numitems])) && (!empty($femail[$numitems]))) {
78  $custom_template_tags['PSEUDO'] = $yname;
79  $custom_template_tags['NOM_FAMILLE'] = $fname[$numitems];
80  $custom_template_tags['PRODUCT_LINK'] = $product_link;
81  $custom_template_tags['SUPPORT'] = $GLOBALS['support'];
82  $custom_template_tags['COMMENTS'] = $comments;
83  if (empty($_SESSION['session_form_direaunami_sent'])) {
84  $_SESSION['session_form_direaunami_sent'] = 0;
85  }
86  if ($_SESSION['session_form_direaunami_sent'] < 10) {
87  // Limitation pour éviter spam : Un utilisateur peut envoyer 10 fois un email dire à un ami par session
88  send_email($femail[$numitems], '', '', 'direaunami_sent', $custom_template_tags, null, $GLOBALS['support'], false, false, true, $yemail);
89  $_SESSION['session_form_direaunami_sent']++;
90  }
91  }
92  }
93  $tpl->assign('referer', $referer);
94  }
95  echo $tpl->fetch();
96  break;
97  default :
98  $_SESSION['session_init_form_direaunami']=true;
99  $tpl = $GLOBALS['tplEngine']->createTemplate('modules/direaunami.tpl');
100  $tpl->assign('action', get_current_url(false));
101 
102  if (!empty($_SERVER['HTTP_REFERER']) && String::strpos($_SERVER['HTTP_REFERER'], $GLOBALS['wwwroot']) === 0) {
103  // $_SERVER['HTTP_REFERER'] n'est pas toujours disponible, ça dépend du réglage du navigateur
104  // Pour éviter des hacks, on ne prend $_SERVER['HTTP_REFERER'] que si il contient $GLOBALS['wwwroot']
105  $referer = $_SERVER['HTTP_REFERER'];
106  } elseif (!empty($_SESSION['session_referer'])) {
107  // Variable de session qui peut être initialisée dans produit_details.php et article_details.php
108  // => ATTENTION : si on recharge la page direaunami après avoir été ailleurs, on se trompe de referer
109  // Cette méthode n'est donc pas privilégiée
110  $referer = $_SESSION['session_referer'];
111  } else {
112  // Pas de referer trouvé
113  $referer = $GLOBALS['wwwroot'];
114  }
115  $tpl->assign('yname', vb($yname));
116  $tpl->assign('yemail', vb($yemail));
117  $tpl->assign('referer', $referer);
118  $tpl->assign('STR_TELL_FRIEND', $GLOBALS['STR_TELL_FRIEND']);
119  $tpl->assign('STR_MODULE_DIREAUNAMI_MSG_TELL_FRIEND', $GLOBALS['STR_MODULE_DIREAUNAMI_MSG_TELL_FRIEND']);
120  $tpl->assign('STR_YOUR_NAME', $GLOBALS['STR_YOUR_NAME']);
121  $tpl->assign('STR_YOUR_EMAIL', $GLOBALS['STR_YOUR_EMAIL']);
122  $tpl->assign('STR_BEFORE_TWO_POINTS', $GLOBALS['STR_BEFORE_TWO_POINTS']);
123  $tpl->assign('STR_THEIR_NAMES', $GLOBALS['STR_THEIR_NAMES']);
124  $tpl->assign('STR_THEIR_EMAILS', $GLOBALS['STR_THEIR_EMAILS']);
125  $tpl->assign('STR_COMMENTS', $GLOBALS['STR_COMMENTS']);
126  $tpl->assign('STR_SEND', $GLOBALS['STR_SEND']);
127  $tpl->assign('STR_MANDATORY', $GLOBALS['STR_MANDATORY']);
128  echo $tpl->fetch();
129  break;
130 }
131 
132 include($GLOBALS['repertoire_modele'] . "/bas.php");
133 
static strpos($haystack, $needle, $offset=0)
Returns the numeric position of the first occurrence of needle in the haystack string.
Definition: String.php:54
get_current_url($with_get=true, $get_short_url=false, $take_away_get_args_array=null)
get_current_url()
Definition: fonctions.php:1743
redirect_and_die($url, $permanent_redirection=false, $avoid_loop=false)
Redirige vers l'URL demandée et arrête le programme.
Definition: fonctions.php:1551
if(!empty($_GET['id'])) if(isset($_POST['form_name'], $_POST['form_subject'], $_POST['form_text'], $_POST['form_lang'])&&empty($_GET['id'])) if(empty($_GET['id'])) $tpl
vb(&$var, $default=null)
Variable blanche if $var n'est pas défini, retourne $default, sinon retourne $var.
Definition: format.php:97
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))
Definition: chart-data.php:160
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.
Definition: emails.php:38
$yemail
Definition: direaunami.php:43
$GLOBALS['page_columns_count']
static substr($string, $start, $length=null)
Returns the portion of string specified by the start and length parameters.
Definition: String.php:112
check_if_module_active($module_name, $specific_file_name=null)
Renvoie si un module est présent et activé ou non - Peut être appelé avant ou après le chargement d'u...
if(defined('IN_PEEL_ADMIN')||IN_INSTALLATION) $_SESSION['session_langue']

This documentation for Open ecommerce PEEL Shopping and PEEL.fr has been generated by Doxygen on Thu Oct 15 2015 14:41:28 - Peel ecommerce is a product of Agence web Advisto SAS. All rights reserved.