9namespace Bitrix\Main\Mail;
12use Bitrix\Main\Application;
13use Bitrix\Main\Config;
14use Bitrix\Main\EventResult;
15use Bitrix\Main\Security\Sign\BadSignatureException;
16use Bitrix\Main\Security\Sign\Signer;
17use Bitrix\Main\SystemException;
27 const onRead =
'OnMailEventMailRead';
55 $data = explode(
".", $tag);
74 return $signer->
sign($tag, static::SIGN_SALT_ACTION);
90 $unsignedTag = $signer->
unsign($signedTag, static::SIGN_SALT_ACTION);
91 return static::parseTag($unsignedTag);
97 $signer->setKey(self::getSignKey());
98 $unsignedTag = $signer->unsign($signedTag, static::SIGN_SALT_ACTION);
99 return static::parseTag($unsignedTag);
113 return static::getTaggedLink(
131 return static::getTaggedLink(
150 return static::getTaggedLink(
169 $uri .=
"/tools/track_mail_$opCode.php";
173 $uri .=
'tag=' . urlencode($tag);
187 static $cached =
array();
188 foreach ($cached as $cache)
190 if ($cache[0] == $value)
197 $sign = $signer->getSignature($value, static::SIGN_SALT_ACTION);
200 if (
count($cached) > 10)
202 array_shift($cached);
220 $result = $signer->validate($value, $signature, static::SIGN_SALT_ACTION);
229 return self::validateSignWithStoredKey($value, $signature);
235 private static function validateSignWithStoredKey($value, $signature)
240 $key = self::getSignKey();
244 $signer->setKey(
$key);
247 return $signer->validate($value, $signature, static::SIGN_SALT_ACTION);
249 catch (BadSignatureException $exception)
255 private static function getSignKey()
257 $key = Config\Option::get(
'sender', self::CUSTOM_SIGNER_KEY,
null);
260 $key = Config\Option::get(
'main',
'signer_default_key',
null);
263 Config\Option::set(
'sender', self::CUSTOM_SIGNER_KEY,
$key);
278 $subscription =
array();
280 if(array_key_exists(
'MODULE_ID',
$data))
285 if(!is_array(
$data[
'FIELDS']))
return false;
289 foreach (
$event->getResults() as $eventResult)
291 if ($eventResult->getType() == EventResult::ERROR)
296 $subscriptionList = $eventResult->getParameters();
297 if($subscriptionList && is_array($subscriptionList[
'LIST']))
299 $subscription = array_merge(
301 array($eventResult->getModuleId() => $subscriptionList[
'LIST'])
306 if (empty(
$data[
'MODULE_ID']) ||
$data[
'MODULE_ID'] ===
'main')
308 if (empty($subscription[
'main']))
310 $subscription[
'main'] = [];
312 $subscription[
'main'] = array_merge(
313 $subscription[
'main'],
318 if(array_key_exists(
'MODULE_ID',
$data))
319 $subscription = $subscription[
$data[
'MODULE_ID']];
321 return $subscription;
332 if(!is_array(
$data[
'FIELDS']))
return false;
336 foreach (
$event->getResults() as $eventResult)
338 if ($eventResult->getType() == EventResult::ERROR)
355 if(!is_array(
$data[
'FIELDS']))
return false;
359 foreach (
$event->getResults() as $eventResult)
361 if ($eventResult->getType() == EventResult::ERROR)
367 if (!empty(
$data[
'MODULE_ID']) &&
$data[
'MODULE_ID'] ===
'main')
383 if (
Main\
Config\Option::get(
'main',
'track_outgoing_emails_click',
'Y') !=
'Y')
388 if(array_key_exists(
'MODULE_ID',
$data))
395 foreach (
$event->getResults() as $eventResult)
397 if ($eventResult->getType() == EventResult::ERROR)
413 $request = Main\Context::getCurrent()->getRequest();
422 $tag = static::parseTag($tag);
423 $tag[
'FIELDS'][
'IP'] =
$request->getRemoteAddress();
424 $tag[
'FIELDS'][
'URL'] =
$url;
433 $isValidate = static::validateSign(
$url,
$sign);
434 $skipSecCheck = (
$sign &&
$url && $isValidate);
442 ShowError(
'Failed to verify the security of the url address');
453 $request = Main\Context::getCurrent()->getRequest();
462 $data = static::parseTag($tag);
464 return static::read(
$data);
480 if (
Main\
Config\Option::get(
'main',
'track_outgoing_emails_read',
'Y') !=
'Y')
485 if(array_key_exists(
'MODULE_ID',
$data))
492 foreach (
$event->getResults() as $eventResult)
494 if ($eventResult->getType() == EventResult::ERROR)
511 if($callbackResult->getModuleId())
513 $filter = [$callbackResult->getModuleId()];
522 foreach (
$event->getResults() as $eventResult)
524 if ($eventResult->getType() == EventResult::ERROR)
if(!Loader::includeModule('catalog')) if(!AccessController::getCurrent() ->check(ActionDictionary::ACTION_PRICE_EDIT)) if(!check_bitrix_sessid()) $request
static onMailEventSubscriptionList(array $data)
static onMailEventSubscriptionDisable(array $data)
static changeStatus(Callback\Result $callbackResult)
static getTag($moduleId, $fields)
static getLinkClick($moduleId, $fields, $urlPage=null)
static getLinkUnsub($moduleId, $fields, $urlPage=null)
static click(array $data)
static clickFromRequest()
static getSignedTag($moduleId, $fields)
static unsubscribe($data)
static getLinkRead($moduleId, $fields, $urlPage=null)
static parseSignedTag($signedTag)
static getTaggedLink($tag, $opCode, $uri=null)
static getSubscriptionList($data)
static validateSign($value, $signature)
unsign($signedValue, $salt=null)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(file_exists($_SERVER['DOCUMENT_ROOT'] . "/urlrewrite.php")) $uri
ShowError($strError, $cls="errortext")
LocalRedirect($url, $skip_security_check=false, $status="302 Found")
if(empty($signedUserToken)) $key
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"