function table() { global $order; $this->code = 'table'; $this->title = MODULE_SHIPPING_TABLE_TEXT_TITLE; $this->description = MODULE_SHIPPING_TABLE_TEXT_DESCRIPTION; $this->sort_order = MODULE_SHIPPING_TABLE_SORT_ORDER; $this->icon = ''; $this->tax_class = 0; $this->enabled = MODULE_SHIPPING_TABLE_STATUS == 'True' ? true : false; if ($order->content_type == 'virtual') { $this->enabled = false; } $this->order_type = 'common'; // common - без периодики, periodical - периодика, mixed - смешанный if ($this->enabled) { $geozones_check_query = tep_db_query("select count(*) as total from " . TABLE_CITIES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_TABLE_ZONE . "' and city_id = '" . tep_db_input($order->delivery['postcode']) . "'"); $geozones_check = tep_db_fetch_array($geozones_check_query); if ($geozones_check['total'] < 1) { $geozones_check_query = tep_db_query("select count(*) as total from " . TABLE_CITIES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_TABLE_ZONE . "' and city_id like '" . tep_db_input(substr($order->delivery['postcode'], 0, -1)) . "%'"); $geozones_check = tep_db_fetch_array($geozones_check_query); if ($geozones_check['total'] < 1) { $geozones_check_query = tep_db_query("select count(*) as total from " . TABLE_CITIES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_TABLE_ZONE . "' and city_id like '" . tep_db_input(substr($order->delivery['postcode'], 0, -2)) . "%'"); $geozones_check = tep_db_fetch_array($geozones_check_query); } } if ($geozones_check['total'] < 1) { $this->enabled = false; } } }
function tep_update_whos_online() { global $customer_id; if (tep_session_is_registered('customer_id')) { $wo_customer_id = $customer_id; $customer_query = tep_db_query("select customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . (int) $customer_id . "'"); $customer = tep_db_fetch_array($customer_query); $wo_full_name = $customer['customers_firstname'] . ' ' . $customer['customers_lastname']; } else { $wo_customer_id = ''; $wo_full_name = 'Guest'; } $wo_session_id = tep_session_id(); $wo_ip_address = getenv('REMOTE_ADDR'); $wo_last_page_url = getenv('REQUEST_URI'); $current_time = time(); $xx_mins_ago = $current_time - 900; // remove entries that have expired tep_db_query("delete from " . TABLE_WHOS_ONLINE . " where time_last_click < '" . $xx_mins_ago . "'"); $stored_customer_query = tep_db_query("select count(*) as count from " . TABLE_WHOS_ONLINE . " where session_id = '" . tep_db_input($wo_session_id) . "'"); $stored_customer = tep_db_fetch_array($stored_customer_query); if ($stored_customer['count'] > 0) { tep_db_query("update " . TABLE_WHOS_ONLINE . " set customer_id = '" . (int) $wo_customer_id . "', full_name = '" . tep_db_input($wo_full_name) . "', ip_address = '" . tep_db_input($wo_ip_address) . "', time_last_click = '" . tep_db_input($current_time) . "', last_page_url = '" . tep_db_input($wo_last_page_url) . "' where session_id = '" . tep_db_input($wo_session_id) . "'"); } else { tep_db_query("insert into " . TABLE_WHOS_ONLINE . " (customer_id, full_name, session_id, ip_address, time_entry, time_last_click, last_page_url) values ('" . (int) $wo_customer_id . "', '" . tep_db_input($wo_full_name) . "', '" . tep_db_input($wo_session_id) . "', '" . tep_db_input($wo_ip_address) . "', '" . tep_db_input($current_time) . "', '" . tep_db_input($current_time) . "', '" . tep_db_input($wo_last_page_url) . "')"); } }
function query($returns_id) { $returns_query = tep_db_query("SELECT * FROM " . TABLE_RETURNS . " WHERE returns_id = '" . tep_db_input($returns_id) . "'"); $returns = tep_db_fetch_array($returns_query); $refund_payment_query = tep_db_query("SELECT * FROM " . TABLE_RETURN_PAYMENTS . " where returns_id = '" . tep_db_input($returns_id) . "'"); $refund_payment = tep_db_fetch_array($refund_payment_query); $this->returnid = $returns['returns_id']; $this->orderid = $returns['order_id']; $this->info = array('currency' => $returns['currency'], 'currency_value' => $returns['currency_value'], 'payment_method' => $returns['payment_method'], 'rma_value' => $returns['rma_value'], 'order_id' => $returns['order_id'], 'cc_type' => $returns['cc_type'], 'cc_owner' => $returns['cc_owner'], 'cc_number' => $returns['cc_number'], 'cvvnumber' => $returns['cvvnumber'], 'cc_expires' => $returns['cc_expires'], 'comments' => $returns['comments'], 'date_purchased' => $returns['date_purchased'], 'orders_status' => $returns['returns_status'], 'date_finished' => $returns['date_finished'], 'customer_method' => $refund_payment['customer_method'], 'refund_method' => $refund_payment['refund_payment_name'], 'payment_reference' => $refund_payment['refund_payment_reference'], 'refund_amount' => 0, 'refund_date' => $refund_payment['refund_payment_date'], 'refund_gv_id' => $returns['refund_gv_id'], 'last_modified' => $returns['last_modified'], 'return_reason' => $returns['returns_reason']); $this->customer = array('name' => $returns['customers_name'], 'company' => $returns['customers_company'], 'street_address' => $returns['customers_street_address'], 'suburb' => $returns['customers_suburb'], 'city' => $returns['customers_city'], 'postcode' => $returns['customers_postcode'], 'state' => $returns['customers_state'], 'country' => $returns['customers_country'], 'format_id' => $returns['customers_address_format_id'], 'telephone' => $returns['customers_telephone'], 'fax' => $returns['customers_fax'], 'email_address' => $returns['customers_email_address']); $this->delivery = array('name' => $returns['delivery_name'], 'company' => $returns['delivery_company'], 'street_address' => $returns['delivery_street_address'], 'suburb' => $returns['delivery_suburb'], 'city' => $returns['delivery_city'], 'postcode' => $returns['delivery_postcode'], 'state' => $returns['delivery_state'], 'country' => $returns['delivery_country'], 'format_id' => $returns['delivery_address_format_id']); $this->billing = array('name' => $returns['billing_name'], 'company' => $returns['billing_company'], 'street_address' => $returns['billing_street_address'], 'suburb' => $returns['billing_suburb'], 'city' => $returns['billing_city'], 'postcode' => $returns['billing_postcode'], 'state' => $returns['billing_state'], 'country' => $returns['billing_country'], 'format_id' => $returns['billing_address_format_id']); $returns_products_query = tep_db_query("SELECT * FROM " . TABLE_RETURNS_PRODUCTS_DATA . " WHERE returns_id ='" . tep_db_input($returns_id) . "'"); while ($returned_products = tep_db_fetch_array($returns_products_query)) { $this->products = array('qty' => $returned_products['products_quantity'], 'name' => $returned_products['products_name'], 'model' => $returned_products['products_model'], 'tax' => $returned_products['products_tax'], 'price' => $returned_products['products_price'], 'id' => $returned_products['products_id'], 'refund_shipping' => $returned_products['refund_shipping'], 'restock_quantity' => $returned_products['restock_quantity'], 'refund_amount' => $returned_products['refund_amount'], 'exchange_amount' => $returned_products['exchange_amount'], 'refund_shipping_amount' => $returned_products['refund_shipping_amount'], 'final_price' => $returned_products['products_price']); $this->info['refund_amount'] += $returned_products['refund_amount']; } // # END while $this->exchange = array(); $returns_products_query = tep_db_query("SELECT * FROM " . TABLE_ORDERS_PRODUCTS . " \r\n\t\t\t\t\t\t\t\t\t\t\t\t WHERE exchange_returns_id ='" . tep_db_input($returns_id) . "'\r\n\t\t\t\t\t\t\t\t\t\t\t\t"); while ($returned_products = tep_db_fetch_array($returns_products_query)) { $this->exchange[] = array('orders_products_id' => $returned_products['orders_products_id'], 'qty' => $returned_products['products_quantity'], 'name' => $returned_products['products_name'], 'model' => $returned_products['products_model'], 'tax' => $returned_products['products_tax'], 'price' => $returned_products['products_price'], 'final_price' => $returned_products['products_price'], 'id' => $returned_products['products_id'], 'free_shipping' => $returned_products['free_shipping'], 'separate_shipping' => $returned_products['separate_shipping'], 'weight' => $returned_products['products_weight']); $attributes_query = tep_db_query("SELECT * FROM " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " \r\n\t\t\t\t\t\t\t\t\t\t\t WHERE orders_id = '" . $this->orderid . "' \r\n\t\t\t\t\t\t\t\t\t\t\t AND orders_products_id = '" . (int) $returned_products['orders_products_id'] . "'\r\n\t\t\t\t\t\t\t\t\t\t\t"); if (tep_db_num_rows($attributes_query)) { while ($attributes = tep_db_fetch_array($attributes_query)) { $this->exchange[sizeof($this->exchange) - 1]['attributes'][] = array('option' => $attributes['products_options'], 'value' => $attributes['products_options_values'], 'orders_products_attributes_id' => $attributes['orders_products_attributes_id']); } // # END while $attributes } // # END if tep_db_num_rows } // # END $returned_products }
function ot_tax_ma() { global $order, $customer_id; $this->code = 'ot_tax_ma'; $this->title = MODULE_ORDER_TOTAL_TAX_MA_TITLE; $this->description = MODULE_ORDER_TOTAL_TAX_MA_DESCRIPTION; $this->enabled = MODULE_ORDER_TOTAL_TAX_MA_STATUS == 'true' ? true : false; $this->sort_order = MODULE_ORDER_TOTAL_TAX_MA_SORT_ORDER; $this->defined_handling = ''; $this->output = array(); if ($this->enabled) { list($postcode) = explode('-', $order->delivery['postcode']); $geozones_check_query = tep_db_query("select count(*) as total from " . TABLE_CITIES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_ORDER_TOTAL_TAX_MA_ZONE . "' and city_id = '" . tep_db_input($postcode) . "'"); $geozones_check = tep_db_fetch_array($geozones_check_query); if ($geozones_check['total'] > 0) { $company_info_query = tep_db_query("select companies_name, companies_tax_exempt_number from " . TABLE_COMPANIES . " where customers_id = '" . (int) $customer_id . "'"); $company_info = tep_db_fetch_array($company_info_query); if (strpos(strtolower($company_info['companies_name']), 'library') !== false || $company_info['companies_tax_exempt_number'] > 0) { $this->enabled = false; } else { $this->defined_handling = str_replace(',', '.', MODULE_ORDER_TOTAL_TAX_MA_HANDLING); } } else { $this->enabled = false; } } }
function execute() { global $sessiontoken, $login_customer_id, $messageStack, $oscTemplate; $error = false; if (isset($_GET['action']) && $_GET['action'] == 'process' && isset($_POST['formid']) && $_POST['formid'] == $sessiontoken) { $email_address = tep_db_prepare_input($_POST['email_address']); $password = tep_db_prepare_input($_POST['password']); // Check if email exists $customer_query = tep_db_query("select customers_id, customers_password from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($email_address) . "' limit 1"); if (!tep_db_num_rows($customer_query)) { $error = true; } else { $customer = tep_db_fetch_array($customer_query); // Check that password is good if (!tep_validate_password($password, $customer['customers_password'])) { $error = true; } else { // set $login_customer_id globally and perform post login code in catalog/login.php $login_customer_id = (int) $customer['customers_id']; // migrate old hashed password to new phpass password if (tep_password_type($customer['customers_password']) != 'phpass') { tep_db_query("update " . TABLE_CUSTOMERS . " set customers_password = '******' where customers_id = '" . (int) $login_customer_id . "'"); } } } } if ($error == true) { $messageStack->add('login', MODULE_CONTENT_LOGIN_TEXT_LOGIN_ERROR); } ob_start(); include 'includes/modules/content/' . $this->group . '/templates/login_form.php'; $template = ob_get_clean(); $oscTemplate->addContent($template, $this->group); }
/** * Call CONFIRMATION_DELIVER and updates order and item data */ public static function deliverAction() { $post = Globals::getPost(); $orderId = Globals::getPostEntry('order_number'); $order = new order($orderId); $transactionId = Db::getRatepayOrderDataEntry($orderId, 'transaction_id'); $transactionShortId = Db::getRatepayOrderDataEntry($orderId, 'transaction_short_id'); $subType = Data::isFullDeliver(self::getDeliverPostData($post), $orderId) ? 'full-deliver' : 'partial-deliver'; $data = array('HeadInfo' => RequestMapper::getHeadInfoModel($order, $transactionId, $transactionShortId, $orderId, $subType), 'BasketInfo' => RequestMapper::getBasketInfoModel($order, $orderId, self::getDeliverPostData($post))); $payment = Loader::getRatepayPayment($order->info['payment_method']); $requestService = new RequestService($payment->sandbox, $data); $result = $requestService->callConfirmationDeliver(); Db::xmlLog($order, $requestService->getRequest(), $orderId, $requestService->getResponse()); if (!array_key_exists('error', $result)) { Session::setRpSessionEntry('message_css_class', 'messageStackSuccess'); Session::setRpSessionEntry('message', RATEPAY_ORDER_MESSAGE_DELIVER_SUCCESS); Db::shipRpOrder(self::getDeliverPostData($post), $order); Db::setRpHistoryEntrys($post, 'CONFIRMATION_DELIVER', $subType); $flag = true; foreach (Db::getRpItems($orderId) as $item) { if ($item['ordered'] != $item['shipped']) { $flag = false; } } if ($flag) { $sql = "UPDATE orders SET " . "orders_status = " . (int) 3 . " WHERE " . "orders_id = '" . tep_db_input($orderId) . "'"; tep_db_query($sql); } } else { Session::setRpSessionEntry('message_css_class', 'messageStackError'); Session::setRpSessionEntry('message', RATEPAY_ORDER_MESSAGE_DELIVER_ERROR); } tep_redirect(tep_href_link("ratepay_order.php", 'oID=' . $orderId, 'SSL')); }
function quote($method = '') { global $order, $cart, $shipping_weight, $currencies, $currency; $postcode_check_query = tep_db_query("select count(*) as total from " . TABLE_CITIES . " where city_id = '" . tep_db_input(tep_db_prepare_input($order->delivery['postcode'])) . "'"); $postcode_check = tep_db_fetch_array($postcode_check_query); $shipping_cost = 0; // if (empty($order->delivery['postcode'])) { // $this->quotes['error'] = MODULE_SHIPPING_UKRPOSTBN_NO_ZIPCODE_FOUND; // } elseif ($postcode_check['total'] < 1) { // $this->quotes['error'] = MODULE_SHIPPING_UKRPOSTBN_NO_ZIPCODE_EXISTS; // } else { $total_sum = str_replace(',', '.', round($cart->total * $currencies->currencies[$currency]['value'], $currencies->currencies[$currency]['decimal_places'])); $persentage = str_replace(',', '.', MODULE_SHIPPING_UKRPOSTBN_COST); $min_cost = str_replace(',', '.', MODULE_SHIPPING_UKRPOSTBN_MIN_COST); $add_cost = str_replace(',', '.', MODULE_SHIPPING_UKRPOSTBN_ADDITIONAL_COST); if ($persentage > 0) { $shipping_cost = $total_sum * $persentage / 100; } if ($min_cost > 0 && $shipping_cost < $min_cost) { $shipping_cost = $min_cost; } if ($add_cost > 0) { $shipping_cost += $add_cost; } $shipping_method = sprintf(MODULE_SHIPPING_UKRPOSTBN_TEXT_WEIGHT, $shipping_weight); // } if ($shipping_cost > 0) { $shipping_cost = $shipping_cost / $currencies->get_value($currency); } $this->quotes['id'] = $this->code; $this->quotes['module'] = MODULE_SHIPPING_UKRPOSTBN_TEXT_TITLE; $this->quotes['methods'] = array(array('id' => $this->code, 'title' => $shipping_method, 'cost' => $shipping_cost)); return $this->quotes; }
function subtable() { global $order; $this->code = 'subtable'; $this->title = MODULE_SHIPPING_SUBTABLE_TEXT_TITLE; $this->description = MODULE_SHIPPING_SUBTABLE_TEXT_DESCRIPTION; $this->sort_order = MODULE_SHIPPING_SUBTABLE_SORT_ORDER; $this->icon = ''; $this->defined_handling = ''; $this->tax_class = 0; $this->enabled = MODULE_SHIPPING_SUBTABLE_STATUS == 'True' ? true : false; if ($order->content_type == 'virtual') { $this->enabled = false; } if ($this->enabled) { $geozones_check_query = tep_db_query("select count(*) as total from " . TABLE_CITIES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_SUBTABLE_ZONE_1 . "' and city_id = '" . tep_db_input($order->delivery['postcode']) . "'"); $geozones_check = tep_db_fetch_array($geozones_check_query); if ($geozones_check['total'] > 0) { $this->defined_handling = MODULE_SHIPPING_SUBTABLE_HANDLING_1; } else { $geozones_check_query = tep_db_query("select count(*) as total from " . TABLE_CITIES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_SUBTABLE_ZONE_2 . "' and city_id = '" . tep_db_input($order->delivery['postcode']) . "'"); $geozones_check = tep_db_fetch_array($geozones_check_query); if ($geozones_check['total'] > 0) { $this->defined_handling = MODULE_SHIPPING_SUBTABLE_HANDLING_2; } else { $geozones_check_query = tep_db_query("select count(*) as total from " . TABLE_CITIES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_SUBTABLE_ZONE_3 . "' and city_id = '" . tep_db_input($order->delivery['postcode']) . "'"); $geozones_check = tep_db_fetch_array($geozones_check_query); if ($geozones_check['total'] > 0) { $this->defined_handling = MODULE_SHIPPING_SUBTABLE_HANDLING_3; } else { $geozones_check_query = tep_db_query("select count(*) as total from " . TABLE_CITIES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_SUBTABLE_ZONE_4 . "' and city_id = '" . tep_db_input($order->delivery['postcode']) . "'"); $geozones_check = tep_db_fetch_array($geozones_check_query); if ($geozones_check['total'] > 0) { $this->defined_handling = MODULE_SHIPPING_SUBTABLE_HANDLING_4; } else { $geozones_check_query = tep_db_query("select count(*) as total from " . TABLE_CITIES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_SUBTABLE_ZONE_5 . "' and city_id = '" . tep_db_input($order->delivery['postcode']) . "'"); $geozones_check = tep_db_fetch_array($geozones_check_query); if ($geozones_check['total'] > 0) { $this->defined_handling = MODULE_SHIPPING_SUBTABLE_HANDLING_5; } } } } } if (empty($this->defined_handling)) { $this->enabled = false; } } if (is_object($order)) { reset($order->products); while (list(, $order_product) = each($order->products)) { if ($order_product['periodicity'] > 0) { $this->enabled = false; break; } } } }
function canPerform($user_id, $user_name) { $check_query = tep_db_query("select id from " . TABLE_ACTION_RECORDER . " where module = '" . tep_db_input($this->code) . "' and user_name = '" . tep_db_input($user_name) . "' and date_added >= date_sub(now(), interval " . (int) $this->minutes . " minute) and success = 1 order by date_added desc limit " . (int) $this->attempts); if (tep_db_num_rows($check_query) == $this->attempts) { return false; } else { return true; } }
function _sess_destroy($key) { $database = $_SESSION['database']; //$database = new database(); //$database->connect(); $result = $database->query("delete from " . TABLE_SESSIONS . " where sessions_key = '" . tep_db_input($key) . "'"); //$database->close(); return $result; }
function tep_get_zone_id($country_id, $zone_name) { $zone_id_query = tep_db_query("select zone_id from " . TABLE_ZONES . " where zone_country_id = '" . (int) $country_id . "' and zone_name = '" . tep_db_input($zone_name) . "'"); if (tep_db_num_rows($zone_id_query) > 0) { $zone_id_row = tep_db_fetch_array($zone_id_query); return $zone_id_row['zone_id']; } return 0; }
function canPerform($user_id, $user_name) { $check_query = tep_db_query("select date_added from " . TABLE_ACTION_RECORDER . " where module = '" . tep_db_input($this->code) . "' and (" . (!empty($user_id) ? "user_id = '" . (int) $user_id . "' or " : "") . " identifier = '" . tep_db_input($this->identifier) . "') and date_added >= date_sub(now(), interval " . (int) $this->minutes . " minute) and success = 1 order by date_added desc limit 1"); if (tep_db_num_rows($check_query)) { return false; } else { return true; } }
function splitPageResults_rspv($query, $max_rows, $count_key = '*', $page_holder = 'page') { $this->sql_query = strtolower($query); // force the quesry to all lower case $this->page_name = $page_holder; if (isset($_GET[$page_holder])) { $page = $_GET[$page_holder]; } elseif (isset($_POST[$page_holder])) { $page = $_POST[$page_holder]; } else { $page = ''; } if (empty($page) || !is_numeric($page)) { $page = 1; } $this->current_page_number = $page; if ($max_rows <= 0) { $max_rows = '1'; } $this->number_of_rows_per_page = $max_rows; // SQL statements that have a "having" clause must be processed // as the full SQL statment. Otherwise, a shorten version may be used. if (strpos($this->sql_query, ' having') === false) { $pos_to = strlen($this->sql_query); $pos_from = strpos($this->sql_query, ' from', 0); $pos_group_by = strpos($this->sql_query, ' group by', $pos_from); if ($pos_group_by < $pos_to && $pos_group_by != false) { $pos_to = $pos_group_by; } $pos_order_by = strpos($this->sql_query, ' order by', $pos_from); if ($pos_order_by < $pos_to && $pos_order_by != false) { $pos_to = $pos_order_by; } if (strpos($this->sql_query, 'distinct') || strpos($this->sql_query, 'group by')) { $count_string = 'distinct ' . tep_db_input($count_key); } else { $count_string = tep_db_input($count_key); } $count_query = tep_db_query("select count(" . $count_string . ") as total " . substr($this->sql_query, $pos_from, $pos_to - $pos_from)); $count = tep_db_fetch_array($count_query); $this->number_of_rows = $count['total']; } else { $count_query = tep_db_query($this->sql_query); $this->number_of_rows = tep_db_num_rows($count_query); } $this->number_of_pages = ceil($this->number_of_rows / $this->number_of_rows_per_page); if ($this->current_page_number > $this->number_of_pages) { $this->current_page_number = $this->number_of_pages; } $offset = $this->number_of_rows_per_page * ($this->current_page_number - 1); //newer version of mysql can not handle neg number in limit, temp fix if ($offset < '0') { $offset = '1'; } $this->sql_query .= " limit " . $offset . ", " . $this->number_of_rows_per_page; }
function tep_get_author_info($author_id, $language_id = '', $field = 'authors_name') { global $languages_id; if (empty($language_id)) { $language_id = $languages_id; } $author_query = tep_db_query("select " . tep_db_input($field) . " as value from " . TABLE_AUTHORS . " where authors_id = '" . (int) $author_id . "' and language_id = '" . (int) $language_id . "'"); $author = tep_db_fetch_array($author_query); return $author['value']; }
function check() { global $customer_id; $check_query = tep_db_query("select date_added from " . TABLE_ACTION_RECORDER . " where module = 'ar_contact_us' and (" . (tep_session_is_registered('customer_id') ? "customer_id = '" . (int) $customer_id . "' or " : "") . " identifier = '" . tep_db_input($this->_identifier) . "') and date_added >= date_sub(now(), interval " . (int) $this->_min_minutes . " minute) and success = 1 order by date_added desc limit 1"); if (tep_db_num_rows($check_query)) { return false; } else { return true; } }
function tep_get_serie_info($serie_id, $language_id = '', $field = 'series_name') { global $languages_id; if (empty($language_id)) { $language_id = $languages_id; } $serie_query = tep_db_query("select " . tep_db_input($field) . " as value from " . TABLE_SERIES . " where series_id = '" . (int) $serie_id . "' and language_id = '" . (int) $language_id . "'"); $serie = tep_db_fetch_array($serie_query); return $serie['value']; }
function tep_get_manufacturer_info($manufacturer_id, $language_id = '', $field = 'manufacturers_name') { global $languages_id; if (empty($language_id)) { $language_id = $languages_id; } $manufacturer_query = tep_db_query("select " . tep_db_input($field) . " as value from " . TABLE_MANUFACTURERS_INFO . " where manufacturers_id = '" . (int) $manufacturer_id . "' and languages_id = '" . (int) $language_id . "'"); $manufacturer = tep_db_fetch_array($manufacturer_query); return $manufacturer['value']; }
function tep_get_translation_info($pages_translation_id, $language_id, $field = 'pages_translation_description') { global $languages_id; if (!tep_not_null($language_id)) { $language_id = $languages_id; } $pages_translation_query = tep_db_query("select " . tep_db_input($field) . " from " . TABLE_PAGES_TRANSLATION . " where pages_translation_id = '" . (int) $pages_translation_id . "' and language_id = '" . (int) $language_id . "'"); $pages_translation = tep_db_fetch_array($pages_translation_query); return $pages_translation[$field]; }
function tep_has_city_subcities($city_id, $city_name = '') { $child_city_query = tep_db_query("select count(*) as count from " . TABLE_CITIES . " where parent_id = '" . (int) $city_id . "'" . (tep_not_null($city_name) ? " and city_name <> '" . tep_db_input($city_name) . "'" : "")); $child_city = tep_db_fetch_array($child_city_query); if ($child_city['count'] > 0) { return true; } else { return false; } }
function tep_get_news_info($news_id, $language_id = '', $field = 'news_name') { global $languages_id; if (empty($language_id)) { $language_id = $languages_id; } $news_query = tep_db_query("select " . tep_db_input($field) . " as news_field from " . TABLE_NEWS . " where news_id = '" . (int) $news_id . "' and language_id = '" . (int) $language_id . "'"); $news_array = tep_db_fetch_array($news_query); return $news_array['news_field']; }
function tep_get_reviews_type_info($reviews_types_id, $language_id, $field = 'reviews_types_name') { if (tep_db_field_exists(TABLE_REVIEWS_TYPES, $field)) { $type_info_query = tep_db_query("select " . tep_db_input($field) . " as field from " . TABLE_REVIEWS_TYPES . " where reviews_types_id = '" . (int) $reviews_types_id . "' and language_id = '" . (int) $language_id . "'"); $type_info = tep_db_fetch_array($type_info_query); return $type_info['field']; } else { return false; } }
function execute() { global $PHP_SELF, $oscTemplate, $customer_id; if (tep_not_null(MODULE_HEADER_TAGS_GOOGLE_ANALYTICS_ID)) { if (MODULE_HEADER_TAGS_GOOGLE_ANALYTICS_JS_PLACEMENT != 'Header') { $this->group = 'footer_scripts'; } $header = '<script type="text/javascript"> var _gaq = _gaq || []; _gaq.push([\'_setAccount\', \'' . tep_output_string(MODULE_HEADER_TAGS_GOOGLE_ANALYTICS_ID) . '\']); _gaq.push([\'_trackPageview\']);' . "\n"; if (MODULE_HEADER_TAGS_GOOGLE_ANALYTICS_EC_TRACKING == 'True' && basename($PHP_SELF) == FILENAME_CHECKOUT_SUCCESS && tep_session_is_registered('customer_id')) { $order_query = tep_db_query("select orders_id, billing_city, billing_state, billing_country from " . TABLE_ORDERS . " where customers_id = '" . (int) $customer_id . "' order by date_purchased desc limit 1"); if (tep_db_num_rows($order_query) == 1) { $order = tep_db_fetch_array($order_query); $totals = array(); $order_totals_query = tep_db_query("select value, class from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int) $order['orders_id'] . "'"); while ($order_totals = tep_db_fetch_array($order_totals_query)) { $totals[$order_totals['class']] = $order_totals['value']; } $header .= ' _gaq.push([\'_addTrans\', \'' . (int) $order['orders_id'] . '\', // order ID - required \'' . tep_output_string(STORE_NAME) . '\', // store name \'' . (isset($totals['ot_total']) ? $this->format_raw($totals['ot_total'], DEFAULT_CURRENCY) : 0) . '\', // total - required \'' . (isset($totals['ot_tax']) ? $this->format_raw($totals['ot_tax'], DEFAULT_CURRENCY) : 0) . '\', // tax \'' . (isset($totals['ot_shipping']) ? $this->format_raw($totals['ot_shipping'], DEFAULT_CURRENCY) : 0) . '\', // shipping \'' . tep_output_string_protected($order['billing_city']) . '\', // city \'' . tep_output_string_protected($order['billing_state']) . '\', // state or province \'' . tep_output_string_protected($order['billing_country']) . '\' // country ]);' . "\n"; $order_products_query = tep_db_query("select op.products_id, pd.products_name, op.final_price, op.products_quantity from " . TABLE_ORDERS_PRODUCTS . " op, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_LANGUAGES . " l where op.orders_id = '" . (int) $order['orders_id'] . "' and op.products_id = pd.products_id and l.code = '" . tep_db_input(DEFAULT_LANGUAGE) . "' and l.languages_id = pd.language_id"); while ($order_products = tep_db_fetch_array($order_products_query)) { $category_query = tep_db_query("select cd.categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " cd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_LANGUAGES . " l where p2c.products_id = '" . (int) $order_products['products_id'] . "' and p2c.categories_id = cd.categories_id and l.code = '" . tep_db_input(DEFAULT_LANGUAGE) . "' and l.languages_id = cd.language_id limit 1"); $category = tep_db_fetch_array($category_query); $header .= ' _gaq.push([\'_addItem\', \'' . (int) $order['orders_id'] . '\', // order ID - required \'' . (int) $order_products['products_id'] . '\', // SKU/code - required \'' . tep_output_string($order_products['products_name']) . '\', // product name \'' . tep_output_string($category['categories_name']) . '\', // category \'' . $this->format_raw($order_products['final_price']) . '\', // unit price - required \'' . (int) $order_products['products_quantity'] . '\' // quantity - required ]);' . "\n"; } $header .= ' _gaq.push([\'_trackTrans\']); //submits transaction to the Analytics servers' . "\n"; } } $header .= ' (function() { var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true; ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' : \'http://www\') + \'.google-analytics.com/ga.js\'; var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s); })(); </script>' . "\n"; $oscTemplate->addBlock($header, $this->group); } }
function splitPageResults($query, $max_rows, $count_key = '*', $page_holder = 'page', $number_of_rows = '') { global $HTTP_GET_VARS, $HTTP_POST_VARS; $this->sql_query = $query; $this->page_name = $page_holder; if (isset($HTTP_GET_VARS[$page_holder])) { $page = $HTTP_GET_VARS[$page_holder]; } elseif (isset($HTTP_POST_VARS[$page_holder])) { $page = $HTTP_POST_VARS[$page_holder]; } else { $page = ''; } if (empty($page) || (int) $page == 0) { $page = 1; } $this->current_page_number = $page; if (strlen($number_of_rows) > 0) { $this->number_of_rows = $number_of_rows; } else { $pos_to = mb_strlen($this->sql_query, 'CP1251'); $pos_from = mb_strpos($this->sql_query, ' from', 0, 'CP1251'); $pos_group_by = mb_strpos($this->sql_query, ' group by', $pos_from, 'CP1251'); if ($pos_group_by < $pos_to && $pos_group_by != false) { $pos_to = $pos_group_by; } if ($pos_group_by != false) { if (preg_match('/group by ([^\\s|,]+)/i', $this->sql_query, $regs)) { $count_key = trim($regs[1]); } } $pos_having = mb_strpos($this->sql_query, ' having', $pos_from, 'CP1251'); if ($pos_having < $pos_to && $pos_having != false) { $pos_to = $pos_having; } $pos_order_by = mb_strpos($this->sql_query, ' order by', $pos_from, 'CP1251'); if ($pos_order_by < $pos_to && $pos_order_by != false) { $pos_to = $pos_order_by; } if (mb_strpos($this->sql_query, 'distinct', 0, 'CP1251') || mb_strpos($this->sql_query, 'group by', 0, 'CP1251')) { $count_string = 'distinct ' . tep_db_input($count_key); } else { $count_string = tep_db_input($count_key); } $count_query = tep_db_unbuffered_query("select count(" . $count_string . ") as total " . mb_substr($this->sql_query, $pos_from, $pos_to - $pos_from, 'CP1251')); $count = tep_db_fetch_array($count_query); $this->number_of_rows = $count['total']; } $this->number_of_rows_per_page = $max_rows > 0 ? $max_rows : $this->number_of_rows; $this->number_of_pages = ceil($this->number_of_rows / $this->number_of_rows_per_page); if ($this->current_page_number > $this->number_of_pages) { $this->current_page_number = $this->number_of_pages; } $offset = $this->number_of_rows_per_page * ($this->current_page_number - 1); $this->sql_query .= " limit " . $offset . ", " . $this->number_of_rows_per_page; }
function tep_get_languages_directory($code) { global $languages_id; $language_query = tep_db_query("select languages_id, directory from " . TABLE_LANGUAGES . " where code = '" . tep_db_input($code) . "'"); if (tep_db_num_rows($language_query)) { $language = tep_db_fetch_array($language_query); $languages_id = $language['languages_id']; return $language['directory']; } else { return false; } }
function send($newsletter_id) { $mail_query = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_newsletter = '1'"); $mimemessage = new email(array('X-Mailer: osCommerce bulk mailer')); $mimemessage->add_text($this->content); $mimemessage->build_message(); while ($mail = tep_db_fetch_array($mail_query)) { $mimemessage->send($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], $mail['customers_email_address'], '', EMAIL_FROM, $this->title); } $newsletter_id = tep_db_prepare_input($newsletter_id); tep_db_query("update " . TABLE_NEWSLETTERS . " set date_sent = now(), status = '1' where newsletters_id = '" . tep_db_input($newsletter_id) . "'"); }
function send($affiliate_newsletter_id) { $mail_query = tep_db_query("select affiliate_firstname, affiliate_lastname, affiliate_email_address from " . TABLE_AFFILIATE . " where affiliate_newsletter = '1'"); $mimemessage = new email(array('X-Mailer: osCmax Mailer')); $mimemessage->add_text($this->content); $mimemessage->build_message(); while ($mail = tep_db_fetch_array($mail_query)) { $mimemessage->send($mail['affiliate_firstname'] . ' ' . $mail['affiliate_lastname'], $mail['affiliate_email_address'], '', EMAIL_FROM, $this->title); } $affiliate_newsletter_id = tep_db_prepare_input($affiliate_newsletter_id); tep_db_query("update " . TABLE_AFFILIATE_NEWSLETTERS . " set date_sent = now(), status = '1' where affiliate_newsletters_id = '" . tep_db_input($affiliate_newsletter_id) . "'"); }
function install() { tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable OpenSearch Module', 'MODULE_HEADER_TAGS_OPENSEARCH_STATUS', 'True', 'Add shop search functionality to the browser?', '6', '1', 'tep_cfg_select_option(array(\\'True\\', \\'False\\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Short Name', 'MODULE_HEADER_TAGS_OPENSEARCH_SHORT_NAME', '" . tep_db_input(STORE_NAME) . "', 'Short name to describe the search engine.', '6', '0', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Description', 'MODULE_HEADER_TAGS_OPENSEARCH_DESCRIPTION', 'Search " . tep_db_input(STORE_NAME) . "', 'Description of the search engine.', '6', '0', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Contact', 'MODULE_HEADER_TAGS_OPENSEARCH_CONTACT', '" . tep_db_input(STORE_OWNER_EMAIL_ADDRESS) . "', 'E-Mail address of the search engine maintainer. (optional)', '6', '0', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Tags', 'MODULE_HEADER_TAGS_OPENSEARCH_TAGS', '', 'Keywords to identify and categorize the search content, separated by an empty space. (optional)', '6', '0', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Attribution', 'MODULE_HEADER_TAGS_OPENSEARCH_ATTRIBUTION', 'Copyright (c) " . tep_db_input(STORE_NAME) . "', 'Attribution for the search content. (optional)', '6', '0', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Adult Content', 'MODULE_HEADER_TAGS_OPENSEARCH_ADULT_CONTENT', 'False', 'Search content contains material suitable only for adults.', '6', '0', 'tep_cfg_select_option(array(\\'True\\', \\'False\\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('16x16 Icon', 'MODULE_HEADER_TAGS_OPENSEARCH_ICON', '" . HTTP_CATALOG_SERVER . DIR_WS_CATALOG . "favicon.ico', 'A 16x16 sized icon (must be in .ico format, eg http://server/favicon.ico). (optional)', '6', '0', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('64x64 Image', 'MODULE_HEADER_TAGS_OPENSEARCH_IMAGE', '', 'A 64x64 sized image (must be in .png format, eg http://server/images/logo.png). (optional)', '6', '0', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_HEADER_TAGS_OPENSEARCH_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())"); }
function tep_get_products_types_info($products_types_id, $language_id = '', $field = '') { global $languages_id; if (empty($language_id)) { $language_id = $languages_id; } if (empty($field)) { $field = 'products_types_name'; } $type_query = tep_db_query("select " . tep_db_input($field) . " from " . TABLE_PRODUCTS_TYPES . " where products_types_id = '" . (int) $products_types_id . "' and language_id = '" . (int) $language_id . "'"); $type = tep_db_fetch_array($type_query); return $type[$field]; }
public function recordFirstStep($orderId, $paramsSAR, $responseSAR) { $datetime = new DateTime('NOW'); if ($this->_getStep($orderId) == self::FIRST_STEP) { $requestKey = $responseSAR['RequestKey']; $publicRequestKey = $responseSAR['PublicRequestKey']; $query = "UPDATE todopago_transaccion SET first_step = '" . $datetime->format('Y-m-d H:i:s') . "', params_SAR = '" . tep_db_input(tep_db_prepare_input(json_encode($paramsSAR))) . "', response_SAR = '" . tep_db_input(tep_db_prepare_input(json_encode($responseSAR))) . "', request_key = '" . tep_db_input(tep_db_prepare_input($requestKey)) . "', public_request_key = '" . tep_db_input(tep_db_prepare_input($publicRequestKey)) . "' WHERE id_orden = " . $orderId; tep_db_query($query); return $query; } else { return 0; } }
function splitPageResults($query, $max_rows, $count_key = '*', $page_holder = 'page') { global $_GET, $_POST; $this->sql_query = $query; $this->page_name = $page_holder; if (isset($_GET[$page_holder])) { $page = $_GET[$page_holder]; } elseif (isset($_POST[$page_holder])) { $page = $_POST[$page_holder]; } else { $page = ''; } if (empty($page) || !is_numeric($page)) { $page = 1; } $this->current_page_number = $page; $this->number_of_rows_per_page = $max_rows; $pos_to = strlen($this->sql_query); $pos_from = strpos($this->sql_query, ' from', 0); $pos_group_by = strpos($this->sql_query, ' group by', $pos_from); if ($pos_group_by < $pos_to && $pos_group_by != false) { $pos_to = $pos_group_by; } $pos_having = strpos($this->sql_query, ' having', $pos_from); if ($pos_having < $pos_to && $pos_having != false) { $pos_to = $pos_having; } $pos_order_by = strpos($this->sql_query, ' order by', $pos_from); if ($pos_order_by < $pos_to && $pos_order_by != false) { $pos_to = $pos_order_by; } if (strpos($this->sql_query, 'distinct') || strpos($this->sql_query, 'group by')) { $count_string = 'distinct ' . tep_db_input($count_key); } else { $count_string = tep_db_input($count_key); } $count_query = tep_db_query("select count(" . $count_string . ") as total " . substr($this->sql_query, $pos_from, $pos_to - $pos_from)); $count = tep_db_fetch_array($count_query); $this->number_of_rows = $count['total']; $this->number_of_pages = ceil($this->number_of_rows / $this->number_of_rows_per_page); if ($this->current_page_number > $this->number_of_pages) { $this->current_page_number = $this->number_of_pages; } $offset = $this->number_of_rows_per_page * ($this->current_page_number - 1); // LINE ADDED if ($offset < 0) { $offset = 0; } // LINE CHANGED: MS2 update 501112 - Added: max(...) $this->sql_query .= " limit " . max($offset, 0) . ", " . $this->number_of_rows_per_page; }