public function sendMetrikaData() { $m = new Metrika(); $response = $m->run(); $data = array('YA_METRIKA_CART' => array('name' => 'YA_METRIKA_CART', 'flag' => 'basket', 'type' => 'action', 'class' => 1, 'depth' => 0, 'conditions' => array(array('url' => 'metrikaCart', 'type' => 'exact'))), 'YA_METRIKA_ORDER' => array('name' => 'YA_METRIKA_ORDER', 'flag' => 'order', 'type' => 'action', 'class' => 1, 'depth' => 0, 'conditions' => array(array('url' => 'metrikaOrder', 'type' => 'exact'))), 'YA_METRIKA_WISHLIST' => array('name' => 'YA_METRIKA_WISHLIST', 'flag' => '', 'type' => 'action', 'class' => 1, 'depth' => 0, 'conditions' => array(array('url' => 'metrikaWishlist', 'type' => 'exact')))); $ret = array(); $error = ''; if (Configuration::get('YA_METRIKA_TOKEN') != '') { if ($response) { $counter = $m->getCounter(); if (!empty($counter->counter->code)) { Configuration::UpdateValue('YA_METRIKA_CODE', $counter->counter->code, true); } $otvet = $m->editCounter(); if ($otvet->counter->id != Configuration::get('YA_METRIKA_NUMBER')) { $error .= $this->displayError($this->l('Saving the settings the meter is not the meter number is incorrect.')); } else { $tmp_goals = $m->getCounterGoals(); $goals = array(); foreach ($tmp_goals->goals as $goal) { $goals[$goal->name] = $goal; } $types = array('YA_METRIKA_ORDER', 'YA_METRIKA_WISHLIST', 'YA_METRIKA_CART'); foreach ($types as $type) { $conf = explode('_', $type); $conf = $conf[0] . '_' . $conf[1] . '_CELI_' . $conf[2]; if (Configuration::get($conf) == 0 && isset($goals[$type])) { $ret['delete_' . $type] = $m->deleteCounterGoal($goals[$type]->id); } elseif (Configuration::get($conf) == 1 && !isset($goals[$type])) { $params = $data[$type]; $ret['add_' . $type] = $m->addCounterGoal(array('goal' => $params)); } } } } elseif (!empty($m->errors)) { $error .= $this->displayError($m->errors); } } else { $error .= $this->displayError($this->l('The token for authorization is missing! Get the token and repeat!')); } if ($error == '') { $this->metrika_status .= $this->displayConfirmation($this->l('Data was successfully sent and saved! Code metrici updated pages automatically.')); } else { $this->metrika_status .= $error; } }
<?php /** * Module is prohibited to sales! Violation of this condition leads to the deprivation of the license! * * @category Front Office Features * @package Yandex Payment Solution * @author Yandex.Money <*****@*****.**> * @copyright © 2015 NBCO Yandex.Money LLC * @license https://money.yandex.ru/doc.xml?id=527052 */ require_once dirname(__FILE__) . '/../../config/config.inc.php'; require_once dirname(__FILE__) . '/../../init.php'; require_once dirname(__FILE__) . '/yamodule.php'; require_once dirname(__FILE__) . '/classes/callback.php'; $yamodule = new yamodule(); $m = new Metrika(); $code = Tools::getValue('code'); $error = Tools::getValue('error'); $state = base64_decode(Tools::getValue('state')); $response = $m->run(); if ($error == '') { $state = explode('_', $yamodule->cryptor->decrypt($state)); $type = $state[2]; $m->code = $code; $m->getToken($type); Tools::redirect(_PS_BASE_URL_ . __PS_BASE_URI__ . $state[0] . '/' . Context::getContext()->link->getAdminLink('AdminModules', false) . ($m->errors ? '&error=' . $yamodule->cryptor->encrypt($m->errors) : '') . '&configure=yamodule&tab_module=payments_gateways&module_name=yamodule&token=' . Tools::getAdminToken('AdminModules' . (int) Tab::getIdFromClassName('AdminModules') . (int) $state[1])); } else { die('error #' . $error . ' error description: ' . Tools::getValue('error_description')); }
public function sendMetrikaData() { $m = new Metrika(); $response = $m->run(); $data = array('YA_METRIKA_CART' => array('name' => 'YA_METRIKA_CART', 'flag' => 'basket', 'type' => 'action', 'class' => 1, 'depth' => 0, 'conditions' => array(array('url' => 'metrikaCart', 'type' => 'exact'))), 'YA_METRIKA_ORDER' => array('name' => 'YA_METRIKA_ORDER', 'flag' => 'order', 'type' => 'action', 'class' => 1, 'depth' => 0, 'conditions' => array(array('url' => 'metrikaOrder', 'type' => 'exact'))), 'YA_METRIKA_WISHLIST' => array('name' => 'YA_METRIKA_WISHLIST', 'flag' => '', 'type' => 'action', 'class' => 1, 'depth' => 0, 'conditions' => array(array('url' => 'metrikaWishlist', 'type' => 'exact')))); $ret = array(); $error = ''; if (Configuration::get('YA_METRIKA_TOKEN') != '') { if ($response) { $counter = $m->getCounter(); if (!empty($counter->counter->code)) { Configuration::UpdateValue('YA_METRIKA_CODE', $counter->counter->code, true); } $otvet = $m->editCounter(); if ($otvet->counter->id != Configuration::get('YA_METRIKA_NUMBER')) { $error .= $this->displayError($this->l('Сохранение настроек счётчика не выполнено или номер счётчика неверен.')); } else { $tmp_goals = $m->getCounterGoals(); foreach ($tmp_goals->goals as $goal) { $goals[$goal->name] = $goal; } $types = array('YA_METRIKA_ORDER', 'YA_METRIKA_WISHLIST', 'YA_METRIKA_CART'); foreach ($types as $type) { $conf = explode('_', $type); $conf = $conf[0] . '_' . $conf[1] . '_CELI_' . $conf[2]; if (Configuration::get($conf) == 0 && isset($goals[$type])) { $ret['delete_' . $type] = $m->deleteCounterGoal($goals[$type]->id); } elseif (Configuration::get($conf) == 1 && !isset($goals[$type])) { $params = $data[$type]; $ret['add_' . $type] = $m->addCounterGoal(array('goal' => $params)); } } } } elseif (!empty($m->errors)) { $error .= $this->displayError($m->errors); } } else { $error .= $this->displayError($this->l('Токен для авторизации отсутствует! Получите токен и повторите!')); } if ($error == '') { $this->metrika_status .= $this->displayConfirmation($this->l('Данные успешно отправлены и сохранены! Код метрники обновится на страницах автоматически.')); } else { $this->metrika_status .= $error; } }