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';
60global $user, $conf, $langs;
62$langs->loadLangs(array(
"main",
"mails"));
67$unsuscrib =
GETPOST(
'unsuscrib');
68$securitykey =
GETPOST(
'securitykey');
75dol_syslog(
"public/emailing/mailing-unsubscribe.php : tag=".$tag.
" securitykey=".$securitykey, LOG_DEBUG);
78 print
'Bad security key value.';
82if (empty($tag) || ($unsuscrib !=
'1')) {
83 print
'Bad parameters';
93$replacemainarea = (empty($conf->dol_hide_leftmenu) ?
'<div>' :
'').
'<div>';
95llxHeader($head, $langs->trans(
"MailUnsubcribe"),
'',
'', 0, 0,
'',
'',
'',
'onlinepaymentbody', $replacemainarea);
97dol_syslog(
"public/emailing/mailing-unsubscribe.php : Launch unsubscribe requests", LOG_DEBUG);
99$sql =
"SELECT mc.rowid, mc.email, mc.statut, m.entity";
100$sql .=
" FROM ".MAIN_DB_PREFIX.
"mailing_cibles as mc, ".MAIN_DB_PREFIX.
"mailing as m";
101$sql .=
" WHERE mc.fk_mailing = m.rowid AND mc.tag = '".$db->escape($tag).
"'";
103$resql = $db->query($sql);
108$obj = $db->fetch_object($resql);
111 print
'Emailing tag '.$tag.
' not found in database. Operation canceled.';
115if (empty($obj->email)) {
116 print
'Email for this tag is not valid. Operation canceled.';
121if ($obj->statut == 3) {
122 print
'Email tag already set to unsubscribe. Operation canceled.';
137$sql =
"UPDATE ".MAIN_DB_PREFIX.
"mailing_cibles SET statut=".((int) $statut).
" WHERE tag = '".$db->escape($tag).
"'";
139$resql = $db->query($sql);
159$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()).
"')";
161$resql = $db->query($sql);
165print
'<table><tr><td style="text_align:center;">';
166print $langs->trans(
"YourMailUnsubcribeOK", $obj->email).
"<br>\n";
167print
'</td></tr></table>';
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
getDolGlobalString($key, $default='')
Return 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.
dol_hash($chain, $type='0', $nosalt=0)
Returns a hash (non reversible encryption) of a string.