function isActive() { global $application; $tables = Configuration::getTables(); $columns = $tables['store_settings']['columns']; $result_rows = array(); $query = new DB_Select(); $query->addSelectField($columns['value'], 'value'); $query->WhereValue($columns['name'], DB_EQ, 'enable_error_document'); $result_rows = $application->db->getDB_Result($query); return $result_rows[0]['value']; }
function getSettings() { global $application; $tables = $this->getTables(); $query = new DB_Select(); $query->addSelectTable('frg_settings'); $query->addSelectField('*'); $res = $application->db->getDB_Result($query); $settings = array(); foreach ($res as $k => $sval) { $settings[$sval['setting_key']] = $sval['setting_value']; } return $settings; }
function getOrderList() { global $application; $tables = modApiFunc('Checkout', 'getTables'); $o = $tables['orders']['columns']; $request =& $application->getInstance('Request'); $order_id_list = $request->getValueByKey('order_id'); $export_all = $request->getValueByKey('export_all'); // id- $query = new DB_Select(); $query->addSelectField($o['id'], 'id'); if ($export_all == null || $export_all == 'false') { $query->WhereField($o['id'], DB_IN, ' (' . implode(',', $order_id_list) . ') '); } $result = $application->db->getDB_Result($query); $plain_list = array(); foreach ($result as $item) { $plain_list[] = $item['id']; } return $plain_list; }
/** * Deletes old records in the news table. * After that <= NEWS_MAX_COUNT records remain. */ function deleteOldNews() { global $application; $tables = $this->getTables(); $columns = $tables['news']['columns']; # select the latest date piece of news among the remain ones in the table... $query = new DB_Select('news'); $query->addSelectField($columns['date'], 'NewsDate'); $query->SelectOrder($columns['date'], 'DESC'); $query->SelectLimit($this->settings[NEWS_MAX_COUNT] - 1, 1); $result = $application->db->getDB_Result($query); if ($result == NULL) { return; } # ...delete all the latest news @ check this line $query = new DB_Delete('news'); $query->WhereValue($columns['date'], DB_LT, $result[0]['NewsDate']); $query->WhereAND(); $query->WhereValue($columns['type'], DB_EQ, 'avactis'); $application->db->getDB_Result($query); }
/** * - . . . sort_order * . * */ function generateCreditCardTypeSortOrder() { global $application; $tables = $this->getTables(); $columns = $tables['credit_card_settings']['columns']; $query = new DB_Select(); $query->addSelectField($query->fMax($columns['sort_order']), 'max'); $result = $application->db->getDB_Result($query); return $result[0]['max'] + 1; }
function __getMaxSortOrderOfProductImages($product_id) { global $application; $tables = $this->getTables(); $imgs_table = $tables['pi_images']['columns']; $query = new DB_Select(); $query->addSelectField($query->fMax($imgs_table['sort_order']), 'max_sort_order'); $query->WhereValue($imgs_table['product_id'], DB_EQ, $product_id); $res = $application->db->getDB_Result($query); return $res[0]['max_sort_order']; }
function __getMaxSortOrderOfManufacturers() { global $application; $tables = $this->getTables(); $mnf_table = $tables['manufacturers']['columns']; $query = new DB_Select(); $query->addSelectField($query->fMax($mnf_table['sort_order']), 'max_sort_order'); $res = $application->db->getDB_Result($query); return $res[0]['max_sort_order']; }
function getCFldValues() { global $application; $values = ""; if ($this->mode == "add") { $values = ""; if (isset($this->field_data['postdata']['customFieldValues'])) { $values = $this->field_data['postdata']['customFieldValues']; } } else { $itid = $this->field_data[0]['input_type_id']; $tables = modAPIFunc("Catalog", "getTables"); $t_input_type_values = $tables['input_type_values']['columns']; $query = new DB_Select(); $query->setMultiLangAlias('_ml_value', 'input_type_values', $t_input_type_values['value'], $t_input_type_values['id'], 'Catalog'); $query->addSelectField($query->getMultiLangAlias('_ml_value'), 'value'); $query->WhereValue($t_input_type_values['it_id'], DB_EQ, $itid); $query->SelectOrder($t_input_type_values['id'], 'ASC'); $result = $application->db->getDB_Result($query); foreach ($result as $r) { $values .= modApiFunc('Catalog', 'getInputTypeActualValue', $r['value']) . "\n"; } } return "<textarea class=\"form-control\"" . $this->HtmlForm->genInputTextAreaField(20, 'customFieldValues', 5) . " id='customFieldValues' disabled=disabled>" . $values . "</textarea>"; }
function initQuery($params) { $key = $params['key']; $otables = Customer_Account::getTables(); $atable = 'ca_person_info_attrs'; $gtable = 'ca_attrs_to_groups'; $dtable = 'ca_person_info_data'; $stables = Subscriptions::getTables(); $stable = 'subscription_temp'; $this->setModifiers(DB_IGNORE); $this->setInsertFields(array($stables[$stable]['columns']['action_key'])); $this->setInsertFields(array($stables[$stable]['columns']['email'])); $squery = new DB_Select($dtable); $squery->addSelectField(DBQuery::quoteValue($key)); $squery->addSelectField(DBQuery::fLower($otables[$dtable]['columns']['data_value'])); $squery->addInnerJoin($gtable, $otables[$dtable]['columns']['ag_id'], DB_EQ, $otables[$gtable]['columns']['ag_id']); $squery->addInnerJoin($atable, $otables[$gtable]['columns']['attr_id'], DB_EQ, $otables[$atable]['columns']['attr_id']); $squery->WhereValue($otables[$atable]['columns']['attr_name'], DB_EQ, 'Email'); $this->setSelectQuery($squery); unset($squery); }
function getPaymentModulesListPrepared() { global $application; if (!empty($this->ModulesList)) { return $this->ModulesList; } $modules = $this->getInstalledModulesListData(); $PaymentModulesGroupsInfo = modApiFunc("Checkout", "getPaymentModulesGroupsInfo"); foreach ($modules as $module) { $name = _ml_strtolower($module->name); // include $table; $uid; include $application->getAppIni("PATH_ASC_ROOT") . $module->directory . "/includes/uid.php"; if (isset($table)) { $query = new DB_Select(); $query->addSelectTable($table); $fields = $application->db->getDB_Result($query); $module_label = ''; foreach ($fields as $row) { $i = 0; $list = array(); foreach ($row as $field) { $list[$i] = $field; $i++; } if ($list[1] == "MODULE_NAME") { $module_label = $list[2]; } } $unserialized_label = @unserialize($module_label); if ($unserialized_label === FALSE) { $unserialized_label = $module_label; } } $payment_group = modApiFunc("Checkout", "getPaymentModuleGroup", $module); if ($payment_group != "") { $this->ModulesList[] = array('uid' => $uid, 'module_class_name' => $module->name, 'module_label_name' => $unserialized_label, 'payment_group' => $payment_group, 'group_short_name' => $PaymentModulesGroupsInfo[$payment_group]['short_name']); } } return $this->ModulesList; }
/** * Checks if options are used during InventoryTracking. * * @param array $oids - index array of option IDs * @return bool; true if at least one option is used, false no option is used */ function __isUsedForIT($oids) { global $application; $tables = $this->getTables(); $options_table = $tables['po_options']['columns']; $query = new DB_Select(); $query->addSelectField($options_table['use_for_it'], 'use_for_it'); $query->addSelectField($query->fCount('*'), 'uit_cnt'); $query->Where($options_table['option_id'], DB_IN, "('" . implode("','", $oids) . "')"); $query->SelectGroup($options_table['use_for_it']); $res = $application->db->getDB_Result($query); for ($i = 0; $i < count($res); $i++) { if ($res[$i]["use_for_it"] == "Y" and $res[$i]["uit_cnt"] > 0) { return true; } } return false; }
function getSettingsRaw() { global $application; $tables = $this->getTables(); $s = $tables['localization_settings']['columns']; $query = new DB_Select(); $query->addSelectField($s["key"], "setting_key"); $query->addSelectField($s["val"], "setting_val"); $result = $application->db->getDB_Result($query); $settings = array(); foreach ($result as $value) { $settings[$value["setting_key"]] = $value["setting_val"]; } return $settings; }
function getTaxFormulaViewFull($tax_rate_id, $specific_rate = "") { if (!$tax_rate_id || $tax_rate_id == 0) { return ""; } global $application; $MessageResources =& $application->getInstance('MessageResources'); $tables = $this->getTables(); $tr = $tables['tax_rates']['columns']; $tn = $tables['tax_names']['columns']; $query = new DB_Select(); $query->addSelectField($tr['rate'], 'Rate'); $query->addSelectField($tr['formula'], 'Formula'); $query->addSelectField($tr['applicable'], 'Applicable'); $query->addLeftJoin('tax_names', $tn['id'], DB_EQ, $tr['tn_id']); $query->setMultiLangAlias('_name', 'tax_names', $tn['name'], $tn['id'], 'Taxes'); $query->addSelectField($query->getMultiLangAlias('_name'), 'TaxName'); $query->WhereValue($tr['id'], DB_EQ, $tax_rate_id); $result = $application->db->getDB_Result($query); if (sizeof($result) == 0) { return ""; } $result = $result[0]; if ($specific_rate != "") { $result['Rate'] = "[{$specific_rate}]"; } if ($result["Applicable"] == "false") { return prepareHTMLDisplay($result['TaxName']) . " = " . $MessageResources->getMessage('TAX_RATE_NOT_APPLICABLE_LABEL'); } $replace = array(); foreach ($this->getTaxNamesList() as $taxNameInfo) { $replace['{t_' . $taxNameInfo['Id'] . '}'] = prepareHTMLDisplay($taxNameInfo['Name']); } foreach ($this->getTaxCostsList() as $cost) { $replace['{p_' . $cost['id'] . '}'] = $MessageResources->getMessage($cost['name']); } preg_match_all("/([0-9]+\\.?[0-9]+)/", $result['Formula'], $numbers); for ($j = 0; $j < sizeof($numbers[0]); $j++) { $replace[$numbers[0][$j]] = modApiFunc("Localization", "num_format", $numbers[0][$j]); } $result['Formula'] = strtr($result['Formula'], $replace); return prepareHTMLDisplay($result['TaxName']) . " = " . $result['Rate'] . "% * (" . $result['Formula'] . ")"; }
function delAllFilesFromProducts($products_ids) { global $application; $tables = $this->getTables(); $files_table = $tables['pf_files']['columns']; $query = new DB_Select(); $query->addSelectField($files_table['file_path']); $query->Where($files_table['product_id'], DB_IN, "('" . implode("','", $products_ids) . "')"); $query->WhereAND(); $query->WhereValue($files_table['is_uploaded'], DB_EQ, 'Y'); $res = $application->db->getDB_Result($query); $this->unlinkFiles($res); $query = new DB_Delete('pf_files'); $query->Where($files_table['product_id'], DB_IN, "('" . implode("','", $products_ids) . "')"); $application->db->PrepareSQL($query); $application->db->DB_Exec(); return; }
/** * * * @param * @return */ function decrypt($name, $encrypted_string) { if (!$name && !$encrypted_string) { return $encrypted_string; } global $application; $session_id = session_id(); $tables = $this->getTables(); $table = 'crypto_keys'; $k = $tables[$table]['columns']; $query = new DB_Select(); $query->addSelectField($k["key"], "crypto_key"); $query->WhereValue($k["id"], DB_EQ, $session_id); $query->WhereAnd(); $query->WhereValue($k["name"], DB_EQ, $name); $result = $application->db->getDB_Result($query); if (isset($result[0]['crypto_key']) && $result[0]['crypto_key']) { $key = $result[0]['crypto_key']; $query = new DB_Delete($table); $query->WhereValue($k["id"], DB_EQ, $session_id); $query->WhereAnd(); $query->WhereValue($k["name"], DB_EQ, $name); $application->db->getDB_Result($query); $blowfish = new Crypt_Blowfish($key); $blowfish->setKey($key); $string = $blowfish->decrypt($encrypted_string); } else { return ""; } return $string; }
/** * * @author Alexandr Girin */ function getTablesAndRecordsCount($count_records = true) { global $application; $avactis_tables = array(); $tables = $this->getTables(); $module_tbl = 'module'; $module_columns = $tables[$module_tbl]['columns']; $module_class_tbl = 'module_class'; $module_class_columns = $tables[$module_class_tbl]['columns']; $db_select = new DB_Select(); $db_select->addSelectField($module_columns['name']); $modules = $application->db->getDB_Result($db_select, QUERY_RESULT_NUM); $total_records = 0; foreach ($modules as $module) { if (method_exists($application->getInstance($module[0]), "getTables")) { $tables = modApiFunc($module[0], "getTables"); if (sizeof($tables)) { foreach ($tables as $tableName => $tableInfo) { if (method_exists($application->getInstance($module[0]), "getIgnoredTablesForBackup")) { $ignoredTables = modApiFunc($module[0], "getIgnoredTablesForBackup"); //print_r($ignoredTables); if (in_array($tableName, $ignoredTables)) { continue; } } if ($count_records) { $query = new DB_Select(); $query->addSelectTable($tableName); $query->addSelectField($query->fCount('*'), 'count'); $result = $application->db->getDB_Result($query); $avactis_tables[] = array('table_name' => $application->getAppIni('DB_TABLE_PREFIX') . $tableName, 'records_count' => $result[0]['count']); $total_records += $result[0]['count']; } else { $avactis_tables[] = $application->getAppIni('DB_TABLE_PREFIX') . $tableName; } } } } } if ($count_records) { $avactis_tables['Total_Records'] = $total_records; } return $avactis_tables; }
function __loadCOPITypesIDs() { global $application; loadClass('Checkout'); $co_tables = Checkout::getTables(); $pa_table = $co_tables['person_info_types']['columns']; $query = new DB_Select(); $query->addSelectTable('person_info_types'); $query->addSelectField($pa_table['id'], 'type_id'); $query->addSelectField($pa_table['tag'], 'type_tag'); $res = $application->db->getDB_Result($query); foreach ($res as $k => $pa_info) { $this->_co_pi_types_ids[_ml_strtolower(str_replace('Info', '', $pa_info['type_tag']))] = $pa_info['type_id']; } }
function __getNotificationNameById($n_id) { global $application; $tables = $this->getTables(); $actions_table = $tables['notifications']['columns']; $query = new DB_Select(); $query->addSelectField($actions_table['name'], 'notification_name'); $query->addSelectTable('notifications'); $query->WhereValue($actions_table['id'], DB_EQ, $n_id); $res = $application->db->getDB_Result($query); return $res[0]['notification_name']; }
/** * * * @author Alexandr Girin * @param * @return */ function DeleteOrders($ordersId) { modApiFunc('EventsManager', 'throwEvent', 'OrdersWillBeDeleted', $ordersId); global $application; $tables = $this->getTables(); $on = $tables['order_notes']['columns']; $opd = $tables['order_person_data']['columns']; $opr = $tables['order_prices']['columns']; $otx = $tables['order_taxes']['columns']; $otdo = $tables['order_tax_display_options']['columns']; $op = $tables['order_product']['columns']; $opca = $tables['order_product_custom_attributes']['columns']; $opta = $tables['order_product_to_attributes']['columns']; $opot = $tables['order_product_options']['columns']; $o = $tables['orders']['columns']; $DB_IN_string = "('" . implode("', '", $ordersId) . "')"; $query = new DB_Select(); $query->addSelectField($op['id'], 'id'); $query->WhereField($op['order_id'], DB_IN, $DB_IN_string); $order_products_id = $application->db->getDB_Result($query); foreach ($order_products_id as $key => $order_product_id) { $order_products_id[$key] = $order_product_id['id']; } $query = new DB_Delete('order_notes'); $query->WhereField($on['order_id'], DB_IN, $DB_IN_string); $application->db->getDB_Result($query); $query = new DB_Delete('order_person_data'); $query->WhereField($opd['order_id'], DB_IN, $DB_IN_string); $application->db->getDB_Result($query); $query = new DB_Delete('order_prices'); $query->WhereField($opr['order_id'], DB_IN, $DB_IN_string); $application->db->getDB_Result($query); $query = new DB_Delete('order_taxes'); $query->WhereField($otx['order_id'], DB_IN, $DB_IN_string); $application->db->getDB_Result($query); $query = new DB_Delete('order_tax_display_options'); $query->WhereField($otdo['order_id'], DB_IN, $DB_IN_string); $application->db->getDB_Result($query); $query = new DB_Delete('order_product'); $query->WhereField($op['order_id'], DB_IN, $DB_IN_string); $application->db->getDB_Result($query); $query = new DB_Delete('order_product_custom_attributes'); $query->WhereField($opca['product_id'], DB_IN, "('" . implode("', '", $order_products_id) . "')"); $application->db->getDB_Result($query); $query = new DB_Delete('order_product_to_attributes'); $query->WhereField($opta['product_id'], DB_IN, "('" . implode("', '", $order_products_id) . "')"); $application->db->getDB_Result($query); $query = new DB_Select(); $query->addSelectField($opot['option_value'], 'option_value'); $query->WhereValue($opot['is_file'], DB_EQ, 'Y'); $query->WhereAND(); $query->Where($opot['order_product_id'], DB_IN, "('" . implode("', '", $order_products_id) . "')"); $__res = $application->db->getDB_Result($query); if (count($__res) > 0) { foreach ($__res as $oinfo) { if ($oinfo['option_value'] != '') { modApiFunc('Shell', 'removeDirectory', dirname($oinfo['option_value'])); } } } $query = new DB_Delete('order_product_options'); $query->WhereField($opot['order_product_id'], DB_IN, "('" . implode("', '", $order_products_id) . "')"); $application->db->getDB_Result($query); modApiFunc("PromoCodes", "DeleteOrders", $ordersId); modApiFunc("TaxExempts", "DeleteOrders", $ordersId); modApiFunc('GiftCertificateApi', 'DeleteOrders', $ordersId); $query = new DB_Delete('orders'); $query->WhereField($o['id'], DB_IN, $DB_IN_string); $application->db->getDB_Result($query); }
function __getMaxFPSortOrderForCategory($category_id) { global $application; $tables = $this->getTables(); $fp_table = $tables['fp_links']['columns']; $query = new DB_Select(); $query->addSelectTable('fp_links'); $query->addSelectField($query->fMax($fp_table['sort_order']), 'max_so'); $query->WhereValue($fp_table['category_id'], DB_EQ, $category_id); $res = $application->db->getDB_Result($query); if (count($res) == 1) { return $res[0]['max_so']; } else { return 0; } }
/** * Gets settings. * * @return array of the settings */ function getSettings() { global $application; if (!isset($this->settings)) { $tables = $this->getTables(); $columns = $tables['scc_settings']['columns']; $query = new DB_Select(); $query->addSelectTable('scc_settings'); $query->addSelectField($columns['key']); $query->addSelectField($columns['value']); $result = $application->db->getDB_Result($query); $settings = array(); foreach ($result as $k => $v) { $settings[$v['scc_settings_key']] = $v['scc_settings_value']; } $this->settings = $settings; } return $this->settings; }
function getOrderGCs($order_id = NULL, $gc_code = NULL) { global $application; $tables = $this->getTables(); $tr = $tables['order_gc']['columns']; $result_array = array(); $query = new DB_Select(); $query->addSelectField($tr["order_id"], "order_id"); $query->addSelectField($tr["gc_id"], "gc_id"); $query->addSelectField($tr["gc_code"], "gc_code"); if ($order_id !== NULL) { #$query->WhereAnd(); $query->WhereValue($tr["order_id"], DB_EQ, $order_id); } if ($gc_code !== NULL) { if ($order_id !== NULL) { $query->WhereAND(); } $query->WhereValue($tr["gc_code"], DB_EQ, $gc_code); } $result_rows = $application->db->getDB_Result($query); return $result_rows; }
function getTopicsEmailsCount($topics_ids, $unique = true) { global $application; if (empty($topics_ids)) { return array(); } $tables = $this->getTables(); $etable = 'subscription_email'; $ecolumns =& $tables[$etable]['columns']; $query = new DB_Select($etable); if ($unique) { $query->addSelectField(DB_Select::fCountDistinct($ecolumns['email_id']), 'email_count'); } else { $query->addSelectField(DB_Select::fCount($ecolumns['email_id']), 'email_count'); } $query->Where($ecolumns['topic_id'], DB_IN, DBQuery::arrayToIn($topics_ids)); $res = $application->db->getDB_Result($query); return $res[0]['email_count']; }
function getOrderCoupons($order_id = NULL, $coupon_id = NULL) { global $application; $tables = $this->getTables(); $tr = $tables['order_promo_codes']['columns']; $result_array = array(); $query = new DB_Select(); $query->addSelectField($tr["order_id"], "order_id"); $query->addSelectField($tr["coupon_id"], "coupon_id"); $query->addSelectField($tr["coupon_promo_code"], "coupon_promo_code"); $query->WhereValue('', '', '1'); if ($order_id !== NULL) { $query->WhereAnd(); $query->WhereValue($tr["order_id"], DB_EQ, $order_id); } if ($coupon_id !== NULL) { $query->WhereAND(); $query->WhereValue($tr["coupon_id"], DB_EQ, $coupon_id); } $result_rows = $application->db->getDB_Result($query); return $result_rows; }
/** * transaction . * * @return unknown */ function getModulesSettings() { global $application; static $ModulesSettings = NULL; $ModulesSettings = array(); $tables = TransactionTracking::getTables(); $ttm = $tables['transaction_tracking_modules_settings']['columns']; $query = new DB_Select(); $query->addSelectField($ttm['id'], 'id'); $query->addSelectField($ttm['module_id'], 'module_id'); $query->addSelectField($ttm['key_name'], 'key_name'); $query->addSelectField($ttm['value'], 'value'); $result = $application->db->getDB_Result($query); if (!empty($result)) { foreach ($result as $entry) { $m_uid = $entry['module_id']; if (!isset($ModulesSettings[$m_uid])) { $ModulesSettings[$m_uid] = array(); } $ModulesSettings[$m_uid][$entry['key_name']] = $entry['value']; } } return $ModulesSettings; }
function getProductAttributeId($view_tag_name, $default_value = null) { global $application; if (!is_object($application)) { return $default_value; } $attr_ids_cache = $application->getAttrIdsCache(); $attr_id = $attr_ids_cache->read($view_tag_name); if ($attr_id == null) { if ($application->db->DB_isTableExists($application->getAppIni('DB_TABLE_PREFIX') . "attributes") != null) { $s = new DB_Select(); $s->addSelectTable("attributes"); $s->addSelectField('attribute_id', 'attribute_id'); $s->WhereValue('attribute_view_tag', DB_EQ, $view_tag_name); $m = new DB_MySQL(); $m->PrepareSQL($s); $result = $m->getDB_Result($s); $attr_id = !empty($result) ? $result[0]['attribute_id'] : $default_value; } else { $attr_id = $default_value; } $attr_ids_cache->write($view_tag_name, $attr_id); } return $attr_id; }
/** * Gets detailed user info. * * @ * @param * @return */ function getUserInfo($uid) { global $application; $tables = $this->getTables(); $a = $tables["admin"]["columns"]; $query = new DB_Select(); $query->addSelectField($a['id'], 'id'); $query->addSelectField($a['firstname'], 'firstname'); $query->addSelectField($a['lastname'], 'lastname'); $query->addSelectField($a['email'], 'email'); $query->addSelectField($a['lognum'], 'lognum'); $query->addSelectField($a['logdate'], 'logdate'); $query->addSelectField($a['created'], 'created'); $query->addSelectField($a['modified'], 'modified'); $query->addSelectField($a['options'], 'options'); $query->WhereValue($a['id'], DB_EQ, $uid); $user_info = $application->db->getDB_Result($query); return @$user_info[0]; }
/** * Gets credit card info by the order. * * @return array - the array of module settings */ function getOrderCCInfoFromDB($order_id) { global $application; $tables = $this->getTables(); $columns = $tables['pm_offline_cc_order_cc_info']['columns']; $query = new DB_Select(); $query->addSelectField($columns["key"], "set_key"); $query->addSelectField($columns["value"], "set_value"); $query->WhereValue($field['order_id'], DB_EQ, $order_id); $result = $application->db->getDB_Result($query); $res = array(); for ($i = 0; $i < sizeof($result); $i++) { $res[$result[$i]['key']] = $result[$i]['value']; } return $res; }
/** * This function calculates hash from checkout form fields array. * @author Andrei V. Zhuravlev * */ function updateCheckoutFormHash() { global $application; $tables = $this->getTables(); $pa = $tables['person_attributes']['columns']; $piva = $tables['person_info_variants_to_attributes']['columns']; $s = new DB_Select(); $s->addSelectTable('person_attributes'); $s->addSelectTable('person_info_variants_to_attributes'); $s->WhereField($piva['attribute_id'], DB_EQ, $pa['id']); $checkout_data = $application->db->getDB_Result($s); //query fields $hash = md5(serialize($checkout_data)); /*$tables = Configuration::getTables(); $ss = $tables['store_settings']['columns']; $u = new DB_Update('store_settings'); $u->addUpdateValue('variable_value',$hash); $u->WhereValue('variable_name', DB_EQ, SYSCONFIG_CHECKOUT_FORM_HASH); $application->db->getDB_Result($u);*/ $cache = CCacheFactory::getCache('hash'); $cache->write(SYSCONFIG_CHECKOUT_FORM_HASH, $hash); return $hash; }
function validateOrder($orderID) { if (ltrim($_GET[WebToPay::PREFIX . 'orderid'], "0") != $orderID) { exit('Order ID mismatch!'); } global $application; $msg =& $application->getInstance('MessageResources', "payment-module-wtp-messages", "AdminZone"); $moduleData = $this->getSettings(); $query = new DB_Select(); $query->addSelectTable('order_prices'); $query->addSelectField('*'); $query->WhereValue('order_id', DB_EQ, $orderID); $Order = $application->db->getDB_Result($query); try { WebToPay::toggleSS2(true); $response = WebToPay::checkResponse($_GET, array('projectid' => $moduleData['MODULE_METHOD_ID'], 'sign_password' => $moduleData['MODULE_METHOD_PASS'])); } catch (Exception $e) { exit(get_class($e) . ': ' . $e->getMessage()); } if (intval(number_format($Order[0]['order_total'], 2, '', '')) > $_GET[WebToPay::PREFIX . 'amount']) { exit('Bad amount!'); } else { if ($Order[0]['currency_code'] != $_GET[WebToPay::PREFIX . 'currency']) { exit('Bad currency!'); } else { modApiFunc("Checkout", "UpdatePaymentStatusInDB", $orderID, 2, 'Payment accepted.'); exit('OK'); } } }