30if (!defined(
'NOLOGIN')) {
 
   31  define(
'NOLOGIN', 
'1');
 
   33if (!defined(
'NOCSRFCHECK')) {
 
   34  define(
'NOCSRFCHECK', 
'1');
 
   36if (!defined(
'NOBROWSERNOTIF')) {
 
   37  define(
'NOBROWSERNOTIF', 
'1');
 
   39if (!defined(
'NOREQUIREMENU')) {
 
   40  define(
'NOREQUIREMENU', 
'1'); 
 
   42if (!defined(
'NOIPCHECK')) {
 
   43  define(
'NOIPCHECK', 
'1'); 
 
   45if (!defined(
"NOSESSION")) {
 
   46  define(
"NOSESSION", 
'1');
 
   48if (! defined(
'NOREQUIREHTML')) {
 
   49  define(
'NOREQUIREHTML', 
'1');       
 
   51if (! defined(
'NOREQUIREAJAX')) {
 
   52  define(
'NOREQUIREAJAX', 
'1');             
 
   57require 
'../../main.inc.php';
 
   58require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
 
   62global $user, 
$conf, $db, $langs;
 
   64$langs->loadLangs(array(
"main", 
"mails"));
 
   69$unsuscrib = 
GETPOST(
'unsuscrib');
 
   70$securitykey = 
GETPOST(
'securitykey');
 
   77dol_syslog(
"public/emailing/mailing-unsubscribe.php : tag=".$tag.
" securitykey=".$securitykey, LOG_DEBUG);
 
   80  print 
'Bad security key value.';
 
   84if (empty($tag) || ($unsuscrib != 
'1')) {
 
   85  print 
'Bad parameters';
 
   95$replacemainarea = (empty(
$conf->dol_hide_leftmenu) ? 
'<div>' : 
'').
'<div>';
 
   97llxHeader($head, $langs->trans(
"MailUnsubcribe"), 
'', 
'', 0, 0, 
'', 
'', 
'', 
'onlinepaymentbody', $replacemainarea);
 
   99dol_syslog(
"public/emailing/mailing-unsubscribe.php : Launch unsubscribe requests", LOG_DEBUG);
 
  101$sql = 
"SELECT mc.rowid, mc.email, mc.statut, m.entity";
 
  102$sql .= 
" FROM ".MAIN_DB_PREFIX.
"mailing_cibles as mc, ".MAIN_DB_PREFIX.
"mailing as m";
 
  103$sql .= 
" WHERE mc.fk_mailing = m.rowid AND mc.tag = '".$db->escape($tag).
"'";
 
  105$resql = $db->query($sql);
 
  110$obj = $db->fetch_object($resql);
 
  113  print 
'Emailing tag '.$tag.
' not found in database. Operation canceled.';
 
  117if (empty($obj->email)) {
 
  118  print 
'Email for this tag is not valid. Operation canceled.';
 
  123if ($obj->statut == 3) {
 
  124  print 
'Email tag already set to unsubscribe. Operation canceled.';
 
  139$sql = 
"UPDATE ".MAIN_DB_PREFIX.
"mailing_cibles SET statut=".((int) $statut).
" WHERE tag = '".$db->escape($tag).
"'";
 
  141$resql = $db->query($sql);
 
  161$sql = 
"INSERT INTO ".MAIN_DB_PREFIX.
"mailing_unsubscribe (date_creat, entity, email, unsubscribegroup, ip) VALUES ('".$db->idate(
dol_now()).
"', ".((int) $obj->entity).
", '".$db->escape($obj->email).
"', '', '".$db->escape(
getUserRemoteIP()).
"')";
 
  163$resql = $db->query($sql);
 
  167print 
'<table><tr><td style="text_align:center;">';
 
  168print $langs->trans(
"YourMailUnsubcribeOK", $obj->email).
"<br>\n";
 
  169print 
'</td></tr></table>';
 
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
 
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
 
dol_now($mode='auto')
Return date for now.
 
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
 
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
 
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
 
getUserRemoteIP()
Return the IP of remote user.
 
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
 
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
 
dol_hash($chain, $type='0', $nosalt=0)
Returns a hash (non reversible encryption) of a string.