/** * */ public function renderContent($setting) { $t = array('categorytab' => '', 'categoryBox' => '', 'limit' => 6, 'itemsperpage' => 4, 'columns' => 4, 'order_by' => 'date_add DESC', 'list_mode' => 'grid', 'display_mode' => 'carousel', 'nbr_desktops' => 4, 'nbr_tablets' => 2, 'nbr_mobile' => 1); $setting = array_merge($t, $setting); $porder = preg_split('#\\s+#', $setting['order_by']); if (!isset($porder[1])) { $porder[1] = null; } $output = array(); $context = Context::getContext(); $categories = $setting['categoryBox'] ? explode(',', $setting['categoryBox']) : false; $categorytab = $setting['categorytab'] ? Tools::jsonDecode($setting['categorytab'], true) : array(); if ($categories) { $tg = array(); foreach ($categories as $id_category) { $obj = new Category($id_category, $context->language->id); $tg['category_info'] = isset($categorytab[$id_category]) ? $categorytab[$id_category] : ''; if (is_file(_PAGEBUILDER_IMAGE_DIR_ . $tg['category_info']['icon'])) { $tg['category_info']['icon'] = _PAGEBUILDER_IMAGE_URL_ . $tg['category_info']['icon']; } else { $tg['category_info']['icon'] = ''; } $tg['category_obj'] = $obj; $tg['products'] = $obj->getProducts($context->language->id, 0, $setting['limit'], $porder[0], $porder[1]); $output[] = $tg; } } $setting['list_mode_tpl'] = $this->getProductListStyleFile($setting['list_mode'], $setting['product_style']); $setting['categories_tabs'] = $output; $output = array('type' => 'categoriestabs', 'data' => $setting); return $output; }
/** * @see FrontController::initContent() */ public function initContent() { $this->display_column_left = false; $this->display_column_center = true; $this->display_column_right = false; $valid_payments = array(); if (Configuration::get('PIGMBH_PAYMILL_DEBIT')) { $valid_payments[] = 'debit'; } if (Configuration::get('PIGMBH_PAYMILL_CREDITCARD')) { $valid_payments[] = 'creditcard'; } if (!in_array(Tools::getValue('payment'), $valid_payments)) { Tools::redirectLink($this->context->link->getPageLink('order', true, null, array('step' => '1'))); } $db_data = $this->getPaymillUserData(); $this->updatePaymillClient($db_data); $cart = $this->context->cart; foreach ($this->module->getCurrency((int) $cart->id_currency) as $currency) { if ($currency['id_currency'] == $cart->id_currency) { $iso_currency = $currency['iso_code']; break; } } $brands = array(); foreach (Tools::jsonDecode(Configuration::get('PIGMBH_PAYMILL_ACCEPTED_BRANDS'), true) as $brand_key => $brand_value) { $brands[str_replace('-', '', $brand_key)] = $brand_value; } $data = array('use_backward_compatible_checkout' => _PS_VERSION_ < '1.6', 'nbProducts' => $cart->nbProducts(), 'cust_currency' => $cart->id_currency, 'currencies' => $this->module->getCurrency((int) $cart->id_currency), 'currency_iso' => $iso_currency, 'total' => (int) round($cart->getOrderTotal(true, Cart::BOTH) * 100), 'displayTotal' => $cart->getOrderTotal(true, Cart::BOTH), 'this_path' => $this->module->getPathUri(), 'this_path_ssl' => Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $this->module->name . '/', 'public_key' => Configuration::get('PIGMBH_PAYMILL_PUBLICKEY'), 'payment' => Tools::getValue('payment'), 'paymill_debugging' => (int) Configuration::get('PIGMBH_PAYMILL_DEBUG') == 'on', 'modul_base' => Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/pigmbhpaymill/', 'customer' => $this->context->customer->firstname . ' ' . $this->context->customer->lastname, 'prefilledFormData' => $this->updatePaymillPayment($db_data), 'acceptedBrands' => Configuration::get('PIGMBH_PAYMILL_ACCEPTED_BRANDS'), 'acceptedBrandsDecoded' => $brands); $this->context->smarty->assign($data); parent::initContent(); $this->setTemplate('paymill_checkout.tpl'); }
public function renderContent($setting) { $t = array('categorytab' => '', 'categoryBox' => '', 'show_image' => 1, 'show_cat_title' => 1, 'show_description' => 0, 'limit_description' => 25, 'show_sub_category' => 0, 'limit_subcategory' => 5, 'show_nb_product' => 0, 'show_products' => 0, 'limit' => 6, 'columns' => 4, 'list_mode' => 'grid', 'display_mode' => 'carousel', 'nbr_desktops' => 4, 'nbr_tablets' => 2, 'nbr_mobile' => 1); $setting = array_merge($t, $setting); $context = Context::getContext(); //$categories = $setting['categoryBox'] ? explode(',', $setting['categoryBox']) : false; $categorytab = $setting['categorytab'] ? Tools::jsonDecode($setting['categorytab'], true) : array(); //echo "<pre>".print_r($categorytab,1); die; $categories = $this->getCategories($setting['categoryBox'], $context->language->id); if ($categories) { foreach ($categories as &$category) { $obj = new Category($category['id_category']); $category['nb_products'] = $obj->getProducts($context->language->id, 0, 1, null, null, true); $category['products'] = $obj->getProducts($context->language->id, 0, $setting['limit'], null, null, false); $category['id_image'] = file_exists(_PS_CAT_IMG_DIR_ . (int) $category['id_category'] . '.jpg') ? (int) $category['id_category'] : false; $category['subcategories'] = $this->getSubCategories($category['id_category'], $setting['limit_subcategory'], $context->language->id); $tg = isset($categorytab[$category['id_category']]) ? $categorytab[$category['id_category']] : ''; if (is_file(_PAGEBUILDER_IMAGE_DIR_ . $tg['icon'])) { $category['icon'] = _PAGEBUILDER_IMAGE_URL_ . $tg['icon']; } else { $category['icon'] = ''; } $category['icon_class'] = $tg['icon_class']; } } $setting['list_mode_tpl'] = $this->getProductListStyleFile($setting['list_mode'], $setting['product_style']); $setting['categories_info'] = $categories; $output = array('type' => 'categoriesinfo', 'data' => $setting); return $output; }
protected function getFilterQuery($keys_array = array(), $table) { $sql = ''; foreach ($keys_array as $key) { if ($this->context->cookie->{$table . 'Filter_' . $key} !== '' && $this->context->cookie->{$table . 'Filter_' . $key} !== false) { $value = $this->context->cookie->{$table . 'Filter_' . $key}; if ($key == 'id_manifest') { $sql .= '`id_manifest` ' . ($value ? '!=' : '=') . ' "0" AND '; } elseif (is_array(Tools::jsonDecode($value))) { $date = Tools::jsonDecode($value); $date = array_filter($date); if (!$date) { continue; } if (!empty($date[0])) { $sql .= '`' . bqSQL($key) . '` > "' . pSQL($date[0]) . '" AND '; } if (!empty($date[1])) { $sql .= '`' . bqSQL($key) . '` < "' . pSQL($date[1]) . '" AND '; } } else { $sql .= '`' . bqSQL($key) . '` LIKE "%' . pSQL($value) . '%" AND '; } } } if ($sql) { $sql = ' HAVING ' . Tools::substr($sql, 0, -4); } // remove 'AND ' from the end of query return $sql; }
public static function executeCronTask() { $ts_module = new TrustedShops(); $ts_common = new TSCommon(); $common_count = 0; if (is_array(TSCommon::$available_languages)) { $to_remove = array(); foreach (array_keys(TSCommon::$available_languages) as $iso) { $alerts_infos = RatingAlert::getAlertsInformations($iso); ///print_r($alerts_infos); if ($alerts_infos != false) { $common_count += count($alerts_infos); foreach ($alerts_infos as $infos) { $cert = Configuration::get(TSCommon::PREFIX_TABLE . 'CERTIFICATE_' . Tools::strtoupper($infos['iso'])); $certificate = (array) Tools::jsonDecode(Tools::htmlentitiesDecodeUTF8($cert)); $subject = $ts_module->l('title_part_1') . ' ' . Configuration::get('PS_SHOP_NAME') . $ts_module->l('title_part_2'); $template_vars = array('{ts_id}' => $certificate['tsID'], '{button_url}' => TSCommon::getHttpHost(true, true) . _MODULE_DIR_ . $ts_module->name . '/views/img', '{rating_url}' => $ts_common->getRatingUrlWithBuyerEmail($infos['id_lang'], $infos['id_order'], $infos['email'])); $result = Mail::Send((int) $infos['id_lang'], self::MAIL_TEMPLATE, $subject, $template_vars, $infos['email'], null, Configuration::get('PS_SHOP_EMAIL'), Configuration::get('PS_SHOP_NAME'), null, null, dirname(__FILE__) . '/../mails/'); if ($result) { $to_remove[] = (int) $infos['id_alert']; } } } } if (count($to_remove) > 0) { self::removeAlerts($to_remove); } } return count($to_remove) == $common_count; }
public function hookDisplayHome($params) { !isset($params['tpl']) && ($params['tpl'] = 'hookHome'); $config = Tools::jsonDecode(Configuration::get($this->name), true); $this->smarty->assign($config); return $this->display(__FILE__, $params['tpl'] . '.tpl'); }
/** * @param unknown_type $message * @param Db $db * @return void|boolean */ function processMessage($message, $db) { //$message = Tools::jsonDecode('{"id_event":5,"date_event":"2012-03-14 13:07:18","reference":"274","id_customer":"10687"}', true); //$message = Tools::jsonDecode($response->body->ReceiveMessageResult->Message->Body, true); $message = Tools::jsonDecode($message, true); $id_event = $message['id_event']; if ($id_event == ONLINE_ORDER) { VBRewards::addRewardPoints($message['id_customer'], $id_event, 0, 100, 'Online payment bonus - Order no ' . $message['reference'], $message['reference'], $message['date_event']); return; } if ($id_event == EVENT_REGISTRATION) { VBRewards::addRewardPoints($message['id_customer'], $id_event, 0, 50, 'Registration/Sign-up', $message['reference'], $message['date_event']); return; } if (isset($message['first_order']) && $message['first_order']) { VBRewards::addRewardPoints($message['id_customer'], $id_event, 7, 50, 'First Order Bonus - Order no ' . $message['reference'], $message['reference'], $message['date_event']); return; } if (isset($message['first_review']) && $message['first_review']) { VBRewards::addRewardPoints($message['id_customer'], $id_event, 9, 50, 'Product Review - First review bonus', $message['reference'], $message['date_event']); return; } $res = $db->ExecuteS("select le.id_event, le.name as 'event_name', r.id_rule, r.name as 'rule_name', re.execute_sequence\n\t\t\t\t\t\t\tfrom vb_rules r\n\t\t\t\t\t\t\tinner join vb_loyalty_rule_events re on (r.id_rule = re.id_rule)\n\t\t\t\t\t\t\tinner join vb_loyalty_events le on le.id_event = re.id_event\n\t\t\t\t\t\t\twhere le.id_event = " . $message['id_event'] . " order by le.id_event, re.execute_sequence"); foreach ($res as $rule_row) { if ($rule_row['id_rule'] == 9 || $rule_row['id_rule'] == 7) { continue; } $rewards_rule = RewardRules::getRule($rule_row['rule_name']); $rewards_rule->init($db); $rewards_rule->processEvent($db, $message); echo PHP_EOL; } return false; }
/** * WS call APP * @param type $data : data array * @return array : WS return JSON decoded */ public static function send($url, $data) { // add data for trackers if not empty if (!empty(self::$trackers_data)) { $data['data']['trackers_data'] = self::$trackers_data; } $url = 'http://' . $url . 'ws/'; $enc = self::encodeData($data); $dat = 'k=' . $enc['key'] . '&d=' . $enc['data']; if (function_exists('curl_init')) { // if curl active $c = curl_init($url); curl_setopt($c, CURLOPT_POST, true); curl_setopt($c, CURLOPT_POSTFIELDS, $dat); curl_setopt($c, CURLOPT_RETURNTRANSFER, true); $res = curl_exec($c); curl_close($c); } else { // otherwise : file_get_contents $opts = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $dat)); $context = stream_context_create($opts); $res = Tools::file_get_contents($url, false, $context); } $ret = Tools::jsonDecode($res, true); if ($ret != null) { Configuration::updateValue('checkyourdata_last_errors', implode(', ', $ret['errors'])); } if (!empty($ret['data']['demoEnd'])) { Configuration::updateValue('checkyourdata_demo_end', $ret['data']['demoEnd']); } return $ret; }
public function loadConfiguration() { if ($this->configuration === null) { $data = Configuration::get(self::ADMIN_CONFIGURATION_KEY); $this->configuration = Tools::jsonDecode($data, true); } return $this->configuration; }
/** * query all warehouse addresses * @params $resultFormat string objectList or arrayList * @return array */ public static function queryAll() { $result = Tools::file_get_contents(self::WAREHOUSE_ADDRESS_PATH); if (empty($result)) { return array(); } $array = Tools::jsonDecode($result, true); return $array; }
/** * query all pilibaba supported currency * * @return array */ public static function queryAll() { $result = Tools::file_get_contents(self::PILIPAY_CURRENCY_PATH); if (empty($result)) { return array(); } $array = Tools::jsonDecode($result, true); return $array; }
public function hookDisplayHome($params) { !isset($params['tpl']) && ($params['tpl'] = 'hookHome'); $config = Tools::jsonDecode(Configuration::get($this->name), true); $html = ''; if ($config['show_barcode']) { $html .= '<script type="text/javascript" src="' . $this->_path . 'js/mylabelgenerator.js" ></script>'; } return $html; }
public function ajaxProcessIntegrationModuleCheckForUpdates() { $this->content_only = true; $status = 'error'; if ($json = Tools::getValue('json')) { $request = Tools::jsonDecode($json, true); $status = $this->module->setupInstance()->downloadExtraModule($request['module'], $request['ver']); } $json = array('status' => $status); $this->content = Tools::jsonEncode($json); }
public function postProcess() { $method = Tools::getValue('method'); $path = Tools::getValue('path'); $data = Tools::getValue('data'); $data = Tools::jsonDecode($data); if (!$data) { $data = array(); } $response = $this->aplazame->callToRest($method, $path, $data); die(Tools::jsonEncode($response['payload'])); }
/** * Gets a list of all flash messages from the users cookie by type. * * @param string $type the type of messages (use class constants). * @return array the message array. */ public function getList($type) { $flash_messages = array(); $cookie = Context::getContext()->cookie; $cookie_data = isset($cookie->nostotagging) ? Tools::jsonDecode($cookie->nostotagging, true) : array(); if (isset($cookie_data['flash_messages'][$type])) { $flash_messages = $cookie_data['flash_messages'][$type]; unset($cookie_data['flash_messages'][$type]); $cookie->nostotagging = Tools::jsonEncode($cookie_data); } return $flash_messages; }
public function getErrorMessage() { $message = $this->cookie->{self::DPD_GROUP_ERROR_MESSAGE}; if (Validate::isSerializedArray($message)) { $message = Tools::jsonDecode($message); } unset($this->cookie->{self::DPD_GROUP_ERROR_MESSAGE}); if (is_array($message)) { return array_unique($message); } return $message ? array($message) : ''; }
public static function jsonDecode($json) { if (function_exists('json_decode')) { return json_decode($json); } elseif (method_exists('Tools', 'jsonDecode')) { return Tools::jsonDecode($json); } else { include_once dirname(__FILE__) . '/json.php'; $pearJson = new Services_JSON($assoc ? SERVICES_JSON_LOOSE_TYPE : 0); return $pearJson->decode($json); } }
public function add($autodate = true, $null_values = false) { $order = new Order($this->id_order); $this->shop_address = self::getCurrentFormattedShopAddress($order->id_shop); $invoice_address = new Address((int) $order->id_address_invoice); $invoiceAddressPatternRules = Tools::jsonDecode(Configuration::get('PS_INVCE_INVOICE_ADDR_RULES'), true); $this->invoice_address = AddressFormat::generateAddress($invoice_address, $invoiceAddressPatternRules, '<br />', ' '); $delivery_address = new Address((int) $order->id_address_delivery); $deliveryAddressPatternRules = Tools::jsonDecode(Configuration::get('PS_INVCE_DELIVERY_ADDR_RULES'), true); $this->delivery_address = AddressFormat::generateAddress($delivery_address, $deliveryAddressPatternRules, '<br />', ' '); return parent::add(); }
public function getSlide($slides) { $datas = array(); foreach ($slides as $slide) { if ($slide) { $data = Tools::jsonDecode($slide, true); $data['slide'] = $slide; } $datas[$data['id_slide']] = $data; } return $datas; }
function fireCurl($data, $url) { $domain = Configuration::get('PS_SHOP_DOMAIN'); $auth_token = Configuration::get('PS_AUTH_TOKEN'); Tools::getValue('id_order'); $data_string = Tools::jsonEncode($data); $hash_code = hash_hmac('sha256', $data_string, $auth_token); Logger::addLog('Riskified URL is ' . $url, 1); $ch = curl_init($url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $headers = array('Content-Type: application/json', 'Content-Length: ' . Tools::strlen($data_string), 'X_RISKIFIED_SHOP_DOMAIN:' . $domain, 'X_RISKIFIED_HMAC_SHA256:' . $hash_code); array_push($headers, 'X_RISKIFIED_SUBMIT_NOW:ok'); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_getinfo($ch); $result = curl_exec($ch); $decoded_response = Tools::jsonDecode($result); $order_id = null; $status = null; if (!is_null($decoded_response) && isset($decoded_response->order)) { $order_id = $decoded_response->order->id; $status = $decoded_response->order->status; if ($status != 'captured' && $order_id) { switch ($status) { case 'approved': echo 'Reviewed and approved by Riskified'; break; case 'declined': echo 'Reviewed and declined by Riskified'; break; case 'submitted': echo 'Order under review by Riskified'; break; } } } else { if (!is_null($decoded_response) && isset($decoded_response->error)) { $error_message = $decoded_response->error->message; Logger::addLog('Error occured when submitting an order to Riskified.'); echo 'Error: ' . $error_message; } else { $error_message = print_r($decoded_response, true); echo 'Error occured: ' . $error_message; Logger::addLog('Error occured when submitting an order to Riskified.'); } } die; }
function upgrade_module_2_0($object) { Db::getInstance(_PS_USE_SQL_SLAVE_)->execute("ALTER TABLE `" . _DB_PREFIX_ . "groupcategory_groups` ADD `cat_type` ENUM( 'auto', 'manual' ) NOT NULL DEFAULT 'auto' AFTER `categoryId` ,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tADD `order_by` ENUM( 'seller', 'price', 'discount', 'date_add', 'position', 'review', 'view' ) NOT NULL DEFAULT 'position' AFTER `cat_type` ,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tADD `order_way` ENUM( 'asc', 'desc' ) NOT NULL DEFAULT 'desc' AFTER `order_by` ,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tADD `on_condition` ENUM( 'all', 'new', 'used', 'refurbished' ) NOT NULL DEFAULT 'all' AFTER `order_way` ,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tADD `on_sale` TINYINT( 2 ) UNSIGNED NOT NULL DEFAULT '2' AFTER `on_condition` ,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tADD `on_new` TINYINT( 2 ) UNSIGNED NOT NULL DEFAULT '2' AFTER `on_sale` ,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tADD `on_discount` TINYINT( 2 ) UNSIGNED NOT NULL DEFAULT '2' AFTER `on_new` ,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tADD `max_item` TINYINT( 3 ) UNSIGNED NOT NULL DEFAULT '12' AFTER `on_discount` ,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tADD `params` VARCHAR( 1000 ) NOT NULL AFTER `max_item` ,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tADD `is_cache` TINYINT NOT NULL DEFAULT '1' AFTER `params`"); Db::getInstance(_PS_USE_SQL_SLAVE_)->execute("ALTER TABLE `" . _DB_PREFIX_ . "groupcategory_items` ADD `cat_type` ENUM( 'auto', 'manual' ) NOT NULL DEFAULT 'auto' AFTER `categoryId` ,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tADD `order_by` ENUM( 'seller', 'price', 'discount', 'date_add', 'position', 'review', 'view' ) NOT NULL DEFAULT 'position' AFTER `cat_type` ,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tADD `order_way` ENUM( 'asc', 'desc' ) NOT NULL DEFAULT 'desc' AFTER `order_by` ,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tADD `on_condition` ENUM( 'all', 'new', 'used', 'refurbished' ) NOT NULL DEFAULT 'all' AFTER `order_way` ,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tADD `on_sale` TINYINT( 2 ) UNSIGNED NOT NULL DEFAULT '2' AFTER `on_condition` ,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tADD `on_new` TINYINT( 2 ) UNSIGNED NOT NULL DEFAULT '2' AFTER `on_sale` ,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tADD `on_discount` TINYINT( 2 ) UNSIGNED NOT NULL DEFAULT '2' AFTER `on_new` ,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tADD `max_item` TINYINT( 3 ) UNSIGNED NOT NULL DEFAULT '12' AFTER `on_discount` ,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tADD `params` VARCHAR( 1000 ) NOT NULL AFTER `max_item` ,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tADD `is_cache` TINYINT NOT NULL DEFAULT '1' AFTER `params`"); $items = DB::getInstance()->executeS("Select * From " . _DB_PREFIX_ . "groupcategory_groups"); if ($items) { $params = new stdClass(); foreach ($items as $item) { if ($item['types']) { $types = Tools::jsonDecode($item['types']); if ($types) { foreach ($types as &$type) { if ($type == 'saller') { $type = 'seller'; } } $params->features = $types; } else { $params->features = array(); } } else { $params->features = array(); } if ($item['manufactureConfig']) { $manufactureConfig = Tools::jsonDecode($item['manufactureConfig']); $params->manufacturers = $manufactureConfig->ids; } else { $params->manufacturers = array(); } if ($item['itemConfig']) { $itemConfig = Tools::jsonDecode($item['itemConfig']); $max_item = (int) $itemConfig->countItem; } else { $max_item = 12; } $params->products = array(); Db::getInstance()->update('groupcategory_groups', array('max_item' => $max_item, 'params' => Tools::jsonEncode($params)), "id=" . $item['id']); } } $items = DB::getInstance()->executeS("Select * From " . _DB_PREFIX_ . "groupcategory_items"); if ($items) { $params = new stdClass(); foreach ($items as $item) { $params->products = array(); $max_item = $item['maxItem']; Db::getInstance()->update('groupcategory_items', array('max_item' => $max_item, 'params' => Tools::jsonEncode($params)), "id=" . $item['id']); } } return true; }
function processMessage($response, $db) { echo $response->body->ReceiveMessageResult->Message->Body . PHP_EOL; //$message = Tools::jsonDecode('{"id_event":5,"date_event":"2012-03-14 13:07:18","reference":"274","id_customer":"10687"}', true); $message = Tools::jsonDecode($response->body->ReceiveMessageResult->Message->Body, true); $id_event = $message['id_event']; $res = $db->ExecuteS("select le.id_event, le.name as 'event_name', r.id_rule, r.name as 'rule_name', re.execute_sequence\n\t\t\t\t\t\t\tfrom vb_rules r\n\t\t\t\t\t\t\tinner join vb_loyalty_rule_events re on (r.id_rule = re.id_rule)\n\t\t\t\t\t\t\tinner join vb_loyalty_events le on le.id_event = re.id_event\n\t\t\t\t\t\t\twhere le.id_event = " . $message['id_event'] . " order by le.id_event, re.execute_sequence"); foreach ($res as $rule_row) { $rewards_rule = RewardRules::getRule($rule_row['rule_name']); $rewards_rule->init($db); $rewards_rule->processEvent($db, $message); echo PHP_EOL; } return true; }
public function callToRest($method, $path, array $values = null) { $url = $this->apiBaseUri . $path; $headers = array('Authorization: Bearer ' . $this->accessToken, 'Accept: application/vnd.aplazame.' . ($this->sandbox ? 'sandbox.' : '') . 'v1+json'); $versions = array('PHP/' . PHP_VERSION, 'Prestashop/' . _PS_VERSION_, 'AplazamePrestashop/' . $this->aplazameVersion); $headers[] = 'User-Agent: ' . implode(', ', $versions); if ($values) { $headers[] = 'Content-type: application/json'; $values = Tools::jsonEncode($values); } $result = $this->doCurlRequest($method, $url, $headers, $values); $result['is_error'] = $result['code'] >= 400; $result['payload'] = Tools::jsonDecode($result['payload'], true); return $result; }
private static function getResponseData($data, $url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); if (curl_errno($ch)) { return false; } curl_close($ch); return Tools::jsonDecode($response, true); }
/** * */ public function renderContent($setting) { $t = array('promotions' => '', 'type_display' => '', 'itemsperpage' => 4, 'column' => 4, 'randId' => rand(100, 20000)); $setting = array_merge($t, $setting); if (!empty($setting['promotions'])) { $promotions = Tools::jsonDecode($setting['promotions'], true); foreach ($promotions as &$value) { if ($value['image']) { $value['imageurl'] = _PAGEBUILDER_IMAGE_URL_ . $value['image']; } } $setting['promotions'] = $promotions; } $output = array('type' => 'promotions', 'data' => $setting); return $output; }
/** * Assign summary template */ public function webhook() { $stripe = new StripeJs(); if ($stripe->active) { if (Tools::getIsset('token') && Configuration::get('STRIPE_WEBHOOK_TOKEN') == Tools::getValue('token')) { include $this->module->getLocalPath() . 'lib/Stripe.php'; Stripe::setApiKey(Configuration::get('STRIPE_MODE') ? Configuration::get('STRIPE_PRIVATE_KEY_LIVE') : Configuration::get('STRIPE_PRIVATE_KEY_TEST')); $event_json = Tools::jsonDecode(@Tools::file_get_contents('php://input')); if (isset($event_json->id)) { /* In case there is an issue with the event, Stripe throw an exception, just ignore it. */ try { /* To double-check and for more security, we retrieve the original event directly from Stripe */ $event = Stripe_Event::retrieve($event_json->id); /* We are only handling chargebacks, other events are ignored */ if ($event->type == 'charge.dispute.created') { $id_order = (int) Db::getInstance()->getValue('SELECT id_order FROM ' . _DB_PREFIX_ . 'stripe_transaction WHERE id_stripe_transaction = \'' . pSQL($event->id) . '\' AND `charge_back` = 0'); if ($id_order) { $order = new Order((int) $id_order); if (Validate::isLoadedObject($order)) { if (Configuration::get('STRIPE_CHARGEBACKS_ORDER_STATUS') != -1) { if ($order->getCurrentState() != Configuration::get('STRIPE_CHARGEBACKS_ORDER_STATUS')) { $order->changeIdOrderState((int) Configuration::get('STRIPE_CHARGEBACKS_ORDER_STATUS'), (int) $id_order); Db::getInstance()->getValue('UPDATE `' . _DB_PREFIX_ . 'stipe_transaction` SET `charge_back` = 1 WHERE `id_stripe_transaction` = \'' . pSQL($event->id) . '\' AND `charge_back` = 0'); } } $message = new Message(); $message->message = $stripe->l('A chargeback occured on this order and was reported by Stripe on') . ' ' . date('Y-m-d H:i:s'); $message->id_order = (int) $order->id; $message->id_employee = 1; $message->private = 1; $message->date_add = date('Y-m-d H:i:s'); $message->add(); } } } } catch (Exception $e) { header('HTTP/1.1 200 OK'); exit; } header('HTTP/1.1 200 OK'); exit; } } } header('HTTP/1.1 200 OK'); exit; }
public function __construct($request, $origin) { $this->loadClasses(); parent::__construct($request); // Abstracted out for example $APIKey = new PowaTagAPIKey(); if (!Module::isInstalled('powatag') || !Module::isEnabled('powatag')) { throw new Exception('Module not enable'); } /* if (!array_key_exists('HTTP_HMAC', $_SERVER)) throw new Exception('No API Key provided'); else if (!$APIKey->verifyKey($_SERVER['HTTP_HMAC'], $this->data)) throw new Exception('Invalid API Key'); */ $this->data = Tools::jsonDecode($this->data); }
function ps1607_language_code_update() { if (defined('_PS_VERSION_')) { $langs = Db::getInstance()->executeS('SELECT `id_lang`, `iso_code`, `language_code` FROM `' . _DB_PREFIX_ . 'lang`'); if (is_array($langs) && $langs) { foreach ($langs as $lang) { if (Tools::strlen($lang['language_code']) == 2) { $result = Tools::jsonDecode(Tools::file_get_contents('https://www.prestashop.com/download/lang_packs/get_language_pack.php?version=' . _PS_VERSION_ . '&iso_lang=' . Tools::strtolower($lang['iso_code']))); if ($result && !isset($result->error) && Tools::strlen($result->language_code) > 2) { Db::getInstance()->execute('UPDATE `' . _DB_PREFIX_ . 'lang` SET `language_code` = \'' . pSQL($result->language_code) . '\' WHERE `id_lang` = ' . (int) $lang['id_lang']) . ' LIMIT 1'; } } } } } return true; }
public function postProcess() { parent::postProcess(); $type = Tools::getValue('type'); $func = Tools::getValue('func'); $arr = array($type, $func); $arr = array_merge($arr, $_REQUEST); $dd = serialize($arr); $this->module->logSave('pokupki ' . $dd); $key = Tools::getValue('auth-token'); $sign = Configuration::get('YA_POKUPKI_TOKEN'); if (Tools::strtoupper($sign) != Tools::strtoupper($key)) { header('HTTP/1.1 403 Forbidden'); header('Status: 403 Forbidden'); echo '<h1>Wrong token</h1>'; exit; } else { $json = Tools::file_get_contents("php://input"); $this->module->logSave('pokupki' . $json); if (!$json) { header('HTTP/1.1 403 Forbidden'); header('Status: 403 Forbidden'); echo '<h1>No data posted</h1>'; exit; } else { header('Content-type:application/json; charset=utf-8'); $partner = new Partner(); $data = Tools::jsonDecode($json); if ($type == 'cart') { $partner->requestItems($data); } elseif ($type == 'order') { if ($func == 'accept') { $partner->orderAccept($data); } elseif ($func == 'status') { $partner->alertOrderStatus($data); } } else { header('HTTP/1.0 404 Not Found'); echo '<h1>Wrong controller</h1>'; exit; } } } }
public function renderContent($args, $setting) { # validate module unset($args); // $category = new Category(3, 1 ); // $subCategories = $category->getSubCategories( 1 ); $images = array(); if (isset($setting['category_img']) && $setting['category_img']) { # validate module $images = Tools::jsonDecode($setting['category_img'], true); } $sql_filter = ''; $sql_sort = ''; if (isset($setting['orderby']) && $setting['orderby']) { if ($setting['orderby'] == 'depth') { $sql_sort = ' ORDER BY c.`level_depth` ASC'; } if ($setting['orderby'] == 'position') { $sql_sort = ' ORDER BY c.`level_depth` ASC, category_shop.`position` ASC'; } if ($setting['orderby'] == 'name') { $sql_sort = ' ORDER BY c.`level_depth` ASC, cl.`name` ASC'; } } $catids = isset($setting['categoryBox']) && $setting['categoryBox'] ? $setting['categoryBox'] : array(); $result = array(); $limit = isset($setting['limit']) && $setting['limit'] ? $setting['limit'] : 5; foreach ($catids as $cate_id) { if (isset($setting['cate_depth']) && ($setting['cate_depth'] || $setting['cate_depth'] == '0')) { # validate module $sql_filter = ' AND c.`level_depth` <= ' . (int) $setting['cate_depth'] . ' + (select c.`level_depth` from `' . _DB_PREFIX_ . 'category` c where c.id_category =' . $cate_id . ')'; } if ($limit) { $result_cate = $this->getNestedCategories($images, $cate_id, $setting['id_lang'], false, null, true, $sql_filter, $sql_sort, $limit); } $result[] = $result_cate; } // echo "<pre>";print_r($result);die; $setting['categories'] = $result; $output = array('type' => 'category_image', 'data' => $setting); //echo "<pre>";print_r($setting);die; return $output; }