function xtc_product_link($pID, $name = '')
{
    #Check for current category link
    $c_path = $_SERVER['QUERY_STRING'];
    if (strpos($c_path, 'cPath') !== false) {
        $category_path = substr($c_path, strpos($c_path, '=') + 1);
        $categorie_previous = end(explode('_', $category_path));
        $cat_children = array();
        $cat_children = xtc_get_categories_children($categorie_previous);
        foreach ($cat_children as $linked_cat) {
            $category_query_check = "select p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = '" . (int) $pID . "' and p.products_status = '1' and p.products_id = p2c.products_id and p2c.categories_id != 0 and p2c.categories_id = '" . $linked_cat . "'";
            $category_query_check = xtDBquery($category_query_check);
            if (xtc_db_num_rows($category_query_check, true)) {
                $cID = xtc_db_fetch_array($category_query_check)['categories_id'];
                break;
            }
        }
    }
    #Take default categorie id
    if (!isset($cID)) {
        $category_query = "select p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = '" . (int) $pID . "' and p.products_status = '1' and p.products_id = p2c.products_id and p2c.categories_id != 0";
        $category_query = xtDBquery($category_query);
        if (xtc_db_num_rows($category_query, true)) {
            $cID = xtc_db_fetch_array($category_query)['categories_id'];
        }
    }
    #Create category path from category ID
    $categories = array();
    xtc_get_parent_categories($categories, $cID);
    $categories = array_reverse($categories);
    $categories[] = $cID;
    $cPath = implode('_', $categories);
    return 'products_id=' . $pID . '&cPath=' . $cPath;
}
function checkAttribute($current_value_id, $current_pid, $current_product_option_id)
{
    global $attr_array, $attr_dl_array;
    //web28 - 2012-07-15 - change global variable list to array
    $query = "SELECT *\n                FROM " . TABLE_PRODUCTS_ATTRIBUTES . "\n               WHERE options_values_id = '" . $current_value_id . "'\n                 AND products_id = ' " . $current_pid . "'\n                 AND options_id = '" . $current_product_option_id . "'";
    $result = xtc_db_query($query);
    $isFound = xtc_db_num_rows($result);
    $attr_array = array();
    $attr_dl_array = array();
    if ($isFound) {
        while ($line = xtc_db_fetch_array($result)) {
            // download function start
            $attr_array = $line;
            $dl_sql = xtc_db_query("SELECT products_attributes_maxdays,\n                                       products_attributes_filename,\n                                       products_attributes_maxcount\n                                 FROM " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . "\n                                 WHERE products_attributes_id = '" . $line['products_attributes_id'] . "'") or die(mysqli_error(xtc_db_connect()));
            $attr_dl_array = xtc_db_fetch_array($dl_sql);
            // download function end
            //price prefixes
            $attr_array['posCheck'] = $line['price_prefix'] == '+' ? ' SELECTED' : '';
            $attr_array['negCheck'] = $line['price_prefix'] == '-' ? ' SELECTED' : '';
            //weight prefixes
            $attr_array['posCheck_weight'] = $line['weight_prefix'] == '+' ? ' SELECTED' : '';
            $attr_array['negCheck_weight'] = $line['weight_prefix'] == '-' ? ' SELECTED' : '';
            //echo print_r($attr_array).'<br>';
        }
        return true;
    } else {
        return false;
    }
}
 function proceed()
 {
     parent::proceed();
     // Nur laden wenn StyleEdit deaktiviert ist.
     if ($_SESSION['style_edit_mode'] != 'edit' && $_SESSION['style_edit_mode'] != 'sos') {
         // Gibt es einen aktiven Slider für die Startseite?
         $_ceck = xtc_db_query("SELECT\n                                        slider_id,\n                                        slider_parameter\n                                    FROM\n                                        multislider\n                                    WHERE\n                                        slider_position = 'startpage'\n                                    AND\n                                        slider_status = 1");
         if (xtc_db_num_rows($_ceck) > 0) {
             // die benötigten Scripte einbinden
             include_once DIR_FS_CATALOG . 'multislider/js/jquery.easing.1.3.min.js';
             include_once DIR_FS_CATALOG . 'multislider/js/jquery.banner-rotator.min.js';
             $_s = xtc_db_fetch_array(xtc_db_query("SELECT slider_parameter FROM multislider WHERE slider_position = 'startpage' AND slider_status = 1"));
             $_d = unserialize(urldecode($_s['slider_parameter']));
             $j = "\$(window).load(function(){ \$('#startpage_slider').bannerRotator({";
             foreach ($_d as $key => $val) {
                 if (is_numeric($val) or $val == 'true' or $val == 'false') {
                     $j .= $key . ":{$val},";
                 } else {
                     $j .= $key . ":'{$val}',";
                 }
             }
             $j .= "borderWidth:0,layerOnHover:false });});";
             echo $j . "\n";
         }
     }
 }
function xtc_get_tax_description($class_id, $country_id = -1, $zone_id = -1)
{
    if ($country_id == -1 && $zone_id == -1) {
        if (!isset($_SESSION['customer_id'])) {
            $country_id = STORE_COUNTRY;
            $zone_id = STORE_ZONE;
        } else {
            $country_id = $_SESSION['customer_country_id'];
            $zone_id = $_SESSION['customer_zone_id'];
        }
    } else {
        $country_id = $country_id;
        $zone_id = $zone_id;
    }
    $tax_query = xtDBquery("select tax_description from " . TABLE_TAX_RATES . " tr left join " . TABLE_ZONES_TO_GEO_ZONES . " za on (tr.tax_zone_id = za.geo_zone_id) left join " . TABLE_GEO_ZONES . " tz on (tz.geo_zone_id = tr.tax_zone_id) where (za.zone_country_id is null or za.zone_country_id = '0' or za.zone_country_id = '" . xtc_db_input((int) $country_id) . "') and (za.zone_id is null or za.zone_id = '0' or za.zone_id = '" . xtc_db_input((int) $zone_id) . "') and tr.tax_class_id = '" . xtc_db_input((int) $class_id) . "' order by tr.tax_priority");
    if (xtc_db_num_rows($tax_query, true)) {
        $tax_description = '';
        while ($tax = xtc_db_fetch_array($tax_query, true)) {
            $tax_description .= $tax['tax_description'] . ' + ';
        }
        $tax_description = substr($tax_description, 0, -3);
        return $tax_description;
    } else {
        return TEXT_UNKNOWN_TAX_RATE;
    }
}
function xtc_display_banner($action, $identifier)
{
    if ($action == 'dynamic') {
        $banners_query = xtc_db_query("select count(*) as count from " . TABLE_BANNERS . " where status = '1' and banners_group = '" . xtc_db_input($identifier) . "'");
        $banners = xtc_db_fetch_array($banners_query);
        if ($banners['count'] > 0) {
            $banner = xtc_random_select("select banners_id, banners_title, banners_image, banners_html_text from " . TABLE_BANNERS . " where status = '1' and banners_group = '" . xtc_db_input($identifier) . "'");
        } else {
            return '<strong>XTC ERROR! (xtc_display_banner(' . $action . ', ' . $identifier . ') -> No banners with group \'' . $identifier . '\' found!</strong>';
        }
    } elseif ($action == 'static') {
        if (is_array($identifier)) {
            $banner = $identifier;
        } else {
            $banner_query = xtc_db_query("select banners_id, banners_title, banners_image, banners_html_text from " . TABLE_BANNERS . " where status = '1' and banners_id = '" . xtc_db_input($identifier) . "'");
            if (xtc_db_num_rows($banner_query)) {
                $banner = xtc_db_fetch_array($banner_query);
            } else {
                return '<strong>XTC ERROR! (xtc_display_banner(' . $action . ', ' . $identifier . ') -> Banner with ID \'' . $identifier . '\' not found, or status inactive</strong>';
            }
        }
    } else {
        return '<strong>XTC ERROR! (xtc_display_banner(' . $action . ', ' . $identifier . ') -> Unknown $action parameter value - it must be either \'dynamic\' or \'static\'</strong>';
    }
    if (xtc_not_null($banner['banners_html_text'])) {
        $banner_string = $banner['banners_html_text'];
    } else {
        $banner_string = '<a href="' . xtc_href_link(FILENAME_REDIRECT, 'action=banner&goto=' . $banner['banners_id']) . '" onclick="window.open(this.href); return false;">' . xtc_image(DIR_WS_IMAGES . 'banner/' . $banner['banners_image'], $banner['banners_title']) . '</a>';
    }
    xtc_update_banner_display_count($banner['banners_id']);
    return $banner_string;
}
function xtc_get_shop_conf($configuration_key, $result_type = 'ASSOC')
{
    $configuration_values = false;
    if ($result_type == 'ASSOC' || $result_type == 'NUMERIC') {
        if (is_array($configuration_key)) {
            foreach ($configuration_key as $key) {
                $configuration_query = xtc_db_query("\n\t\t\t\t\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\t\t\t\t\tconfiguration_value\n\t\t\t\t\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\t\t\t\t\tshop_configuration\n\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\tconfiguration_key = '" . xtc_db_input($key) . "'\n\t\t\t\t\t\t\t\t\t\t\t\tLIMIT 1\n\t\t\t\t\t\t\t\t\t\t\t");
                if (xtc_db_num_rows($configuration_query) == 1) {
                    if ($configuration_values == false) {
                        $configuration_values = array();
                    }
                    $configuration_row = xtc_db_fetch_array($configuration_query);
                    if ($result_type == 'ASSOC') {
                        $configuration_values[$key] = $configuration_row['configuration_value'];
                    } else {
                        $configuration_values[] = $configuration_row['configuration_value'];
                    }
                }
            }
        } else {
            $configuration_query = xtc_db_query("\n\t\t\t\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\t\t\t\tconfiguration_value\n\t\t\t\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\t\t\t\tshop_configuration\n\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\tconfiguration_key = '" . xtc_db_input($configuration_key) . "'\n\t\t\t\t\t\t\t\t\t\t\tLIMIT 1\n\t\t\t\t\t\t\t\t\t\t");
            if (xtc_db_num_rows($configuration_query) == 1) {
                if ($configuration_values == false) {
                    $configuration_values = '';
                }
                $configuration_row = xtc_db_fetch_array($configuration_query);
                $configuration_values = $configuration_row['configuration_value'];
            }
        }
    }
    return $configuration_values;
}
function xtc_get_tax_rate($class_id, $country_id = -1, $zone_id = -1)
{
    if ($country_id == -1 && $zone_id == -1) {
        if (!isset($_SESSION['customer_id'])) {
            $country_id = STORE_COUNTRY;
            $zone_id = STORE_ZONE;
        } else {
            $country_id = $_SESSION['customer_country_id'];
            $zone_id = $_SESSION['customer_zone_id'];
        }
    } else {
        $country_id = $country_id;
        $zone_id = $zone_id;
    }
    $tax_query = xtDBquery("select sum(tax_rate) as tax_rate from " . TABLE_TAX_RATES . " tr left join " . TABLE_ZONES_TO_GEO_ZONES . " za on (tr.tax_zone_id = za.geo_zone_id) left join " . TABLE_GEO_ZONES . " tz on (tz.geo_zone_id = tr.tax_zone_id) where (za.zone_country_id is null or za.zone_country_id = '0' or za.zone_country_id = '" . xtc_db_input((int) $country_id) . "') and (za.zone_id is null or za.zone_id = '0' or za.zone_id = '" . xtc_db_input((int) $zone_id) . "') and tr.tax_class_id = '" . xtc_db_input((int) $class_id) . "' group by tr.tax_priority");
    if (xtc_db_num_rows($tax_query, true)) {
        $tax_multiplier = 1.0;
        while ($tax = xtc_db_fetch_array($tax_query, true)) {
            $tax_multiplier *= 1.0 + $tax['tax_rate'] / 100;
        }
        return ($tax_multiplier - 1.0) * 100;
    } else {
        return 0;
    }
}
 function check()
 {
     if (!isset($this->_check)) {
         $check_query = xtc_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_MASTERPAYMENT_CONFIG_MERCHANTID'");
         $this->_check = xtc_db_num_rows($check_query);
     }
     return $this->_check;
 }
 function check()
 {
     if (!isset($this->_check)) {
         $check_query = xtc_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_PAYPALINSTALLMENT_FEE_STATUS'");
         $this->_check = xtc_db_num_rows($check_query);
     }
     return $this->_check;
 }
Пример #10
0
 function check()
 {
     if (!isset($this->_check)) {
         $check_query = xtc_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_JANOLAW_STATUS'");
         $this->_check = xtc_db_num_rows($check_query);
     }
     return $this->_check;
 }
Пример #11
0
 function check()
 {
     if (!isset($this->_check)) {
         $check_query = xtc_db_query("SELECT configuration_value FROM " . TABLE_CONFIGURATION . " WHERE configuration_key = 'MODULE_PAYMENT_PAYMILL_ELV_STATUS'");
         $this->_check = xtc_db_num_rows($check_query);
     }
     return $this->_check;
 }
 public function checkConfig()
 {
     $check_query = xtc_db_query("SHOW TABLES LIKE 'payone_config'");
     if (xtc_db_num_rows($check_query) > 0) {
         return true;
     }
     return false;
 }
Пример #13
0
 /**
  * Checks received data against database for the order.
  *
  * @param string $state
  * @return boolean
  */
 function checkDatabase($state)
 {
     $query = xtc_db_query("SELECT *\n                                 FROM " . TABLE_ORDERS . "\n                                WHERE orders_id = '" . $this->receivedData['order_id'] . "'\n                                  AND barzahlen_transaction_id = '" . $this->receivedData['transaction_id'] . "'\n                                  AND barzahlen_transaction_state = '" . $state . "'");
     if (xtc_db_num_rows($query) != 1) {
         $this->bzLog('barzahlen/ipn: No ' . $state . ' order found in database - ' . serialize($this->receivedData));
         return false;
     }
     return true;
 }
function xtc_expire_specials()
{
    $specials_query = xtc_db_query("select specials_id from " . TABLE_SPECIALS . " where status = '1' and now() >= expires_date and expires_date > 0");
    if (xtc_db_num_rows($specials_query)) {
        while ($specials = xtc_db_fetch_array($specials_query)) {
            xtc_set_specials_status($specials['specials_id'], '0');
        }
    }
}
function xtc_get_product_path($products_id)
{
    $cPath = '';
    $category_query = "select p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = '" . (int) $products_id . "' and p.products_status = '1' and p.products_id = p2c.products_id and p2c.categories_id != 0";
    $category_query = xtDBquery($category_query);
    if (xtc_db_num_rows($category_query, true)) {
        #Default category( first picked from table)
        $category = xtc_db_fetch_array($category_query);
        $p_path_full = $_SERVER['REQUEST_URI'];
        $p_path = $_SERVER['QUERY_STRING'];
        #If we display product check linked categories
        if (strpos($p_path, 'products_id') !== false) {
            while ($categoryies = xtc_db_fetch_array($category_query)) {
                $cat_name = xtc_get_categories_name($categoryies['categories_id']);
                $cat_name_slug = shopstat_hrefSmallmask($cat_name);
                $p_path_full_array = explode('/', $p_path_full);
                if ($p_path_full_array[count($p_path_full_array) - 2] === $cat_name_slug) {
                    $category = $categoryies;
                    break;
                }
            }
        }
        # Check if current categorie or its children have linked product
        $c_path = $_SERVER['QUERY_STRING'];
        if (strpos($c_path, 'cPath') !== false) {
            $category_path = substr($c_path, strpos($c_path, '=') + 1);
            $categorie_previous = end(explode('_', $category_path));
            $cat_children = array();
            $cat_children = xtc_get_categories_children($categorie_previous);
            foreach ($cat_children as $linked_cat) {
                $category_query_check = "select p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = '" . (int) $products_id . "' and p.products_status = '1' and p.products_id = p2c.products_id and p2c.categories_id != 0 and p2c.categories_id = '" . $linked_cat . "'";
                $category_query_check = xtDBquery($category_query_check);
                if (xtc_db_num_rows($category_query_check, true)) {
                    $category = xtc_db_fetch_array($category_query_check);
                    break;
                }
            }
        }
        $categories = array();
        xtc_get_parent_categories($categories, $category['categories_id']);
        $categories = array_reverse($categories);
        $cPath = implode('_', $categories);
        if (xtc_not_null($cPath)) {
            $cPath .= '_';
        }
        $cPath .= $category['categories_id'];
    }
    //BOF - Dokuman - 2009-10-02 - removed feature, due to wrong links in category on "last viewed"
    /*
      if($_SESSION['lastpath']!=''){
        $cPath = $_SESSION['lastpath'];
      }
    */
    //EOF - Dokuman - 2009-10-02 - removed feature, due to wrong links in category on "last viewed"
    return $cPath;
}
function xtc_get_address_format_id($country_id)
{
    $address_format_query = xtc_db_query("select address_format_id as format_id from " . TABLE_COUNTRIES . " where countries_id = '" . xtc_db_input((int) $country_id) . "'");
    if (xtc_db_num_rows($address_format_query)) {
        $address_format = xtc_db_fetch_array($address_format_query);
        return $address_format['format_id'];
    } else {
        return '1';
    }
}
function xtc_get_zone_name($country_id, $zone_id, $default_zone)
{
    $zone_query = xtc_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . xtc_db_input((int) $country_id) . "' and zone_id = '" . xtc_db_input((int) $zone_id) . "'");
    if (xtc_db_num_rows($zone_query)) {
        $zone = xtc_db_fetch_array($zone_query);
        return $zone['zone_name'];
    } else {
        return $default_zone;
    }
}
function xtc_get_categories_children_calc($cat_id, &$cat_children)
{
    $categories_query = "select categories_id, parent_id from " . TABLE_CATEGORIES . "  where parent_id = '" . $cat_id . "'";
    $categories_query = xtDBquery($categories_query);
    if (xtc_db_num_rows($categories_query, true)) {
        while ($categoryies = xtc_db_fetch_array($categories_query)) {
            $cat_children[] = $categoryies['categories_id'];
            xtc_get_categories_children($categoryies['categories_id'], $cat_children);
        }
    }
}
Пример #19
0
function xtc_get_languages_directory($code)
{
    $language_query = xtc_db_query("select languages_id, directory from " . TABLE_LANGUAGES . " where code = '" . $code . "'");
    if (xtc_db_num_rows($language_query)) {
        $lang = xtc_db_fetch_array($language_query);
        $_SESSION['languages_id'] = $lang['languages_id'];
        return $lang['directory'];
    } else {
        return false;
    }
}
function xtc_activate_banners()
{
    $banners_query = xtc_db_query("select banners_id, date_scheduled from " . TABLE_BANNERS . " where date_scheduled != ''");
    if (xtc_db_num_rows($banners_query)) {
        while ($banners = xtc_db_fetch_array($banners_query)) {
            if (date('Y-m-d H:i:s') >= $banners['date_scheduled']) {
                xtc_set_banner_status($banners['banners_id'], '1');
            }
        }
    }
}
function xtc_random_select($query)
{
    $random_product = '';
    $random_query = xtc_db_query($query);
    $num_rows = xtc_db_num_rows($random_query);
    if ($num_rows > 0) {
        $random_row = xtc_rand(0, $num_rows - 1);
        xtc_db_data_seek($random_query, $random_row);
        $random_product = xtc_db_fetch_array($random_query);
    }
    return $random_product;
}
function xtc_get_affiliate_tax_rate($class_id, $country_id, $zone_id)
{
    $tax_query = xtc_db_query("select SUM(tax_rate) as tax_rate from " . TABLE_TAX_RATES . " tr left join " . TABLE_ZONES_TO_GEO_ZONES . " za ON tr.tax_zone_id = za.geo_zone_id left join " . TABLE_GEO_ZONES . " tz ON tz.geo_zone_id = tr.tax_zone_id WHERE (za.zone_country_id IS NULL OR za.zone_country_id = '0' OR za.zone_country_id = '" . $country_id . "') AND (za.zone_id IS NULL OR za.zone_id = '0' OR za.zone_id = '" . $zone_id . "') AND tr.tax_class_id = '" . $class_id . "' GROUP BY tr.tax_priority");
    if (xtc_db_num_rows($tax_query)) {
        $tax_multiplier = 0;
        while ($tax = xtc_db_fetch_array($tax_query)) {
            $tax_multiplier += $tax['tax_rate'];
        }
        return $tax_multiplier;
    } else {
        return 0;
    }
}
function xtc_findTitle($current_pid, $languageFilter)
{
    $query = "SELECT * FROM " . TABLE_PRODUCTS_DESCRIPTION . "  where language_id = '" . xtc_db_input((int) $_SESSION['languages_id']) . "' AND products_id = '" . xtc_db_input((int) $current_pid) . "'";
    $result = xtc_db_query($query);
    $matches = xtc_db_num_rows($result);
    if ($matches) {
        while ($line = xtc_db_fetch_array($result)) {
            $productName = $line['products_name'];
        }
        return $productName;
    } else {
        return "Something isn't right....";
    }
}
 function _check_TRID()
 {
     // valid trid ?
     $query = "SELECT mb_TRID,mb_ORDERID FROM payment_moneybookers WHERE mb_TRID = '" . $this->data['transaction_id'] . "'";
     $query = xtc_db_query($query);
     if (!xtc_db_num_rows($query)) {
         $this->Error = '1002';
         return false;
     }
     // ok Insert mb transaction ID
     $query = "UPDATE payment_moneybookers SET mb_MBTID ='" . $this->data['mb_transaction_id'] . "'  WHERE mb_TRID = '" . $this->data['transaction_id'] . "'";
     $query = xtc_db_query($query);
     return true;
 }
function xtc_gv_account_update($customer_id, $gv_id)
{
    $customer_gv_query = xtc_db_query("select amount from " . TABLE_COUPON_GV_CUSTOMER . " where customer_id = '" . xtc_db_input((int) $customer_id) . "'");
    $coupon_gv_query = xtc_db_query("select coupon_amount from " . TABLE_COUPONS . " where coupon_id = '" . xtc_db_input((int) $gv_id) . "'");
    $coupon_gv = xtc_db_fetch_array($coupon_gv_query);
    if (xtc_db_num_rows($customer_gv_query) > 0) {
        $customer_gv = xtc_db_fetch_array($customer_gv_query);
        $new_gv_amount = $customer_gv['amount'] + $coupon_gv['coupon_amount'];
        //prepare for DB insert
        $new_gv_amount = str_replace(",", ".", $new_gv_amount);
        $gv_query = xtc_db_query("update " . TABLE_COUPON_GV_CUSTOMER . " set amount = '" . xtc_db_input($new_gv_amount) . "' where customer_id = '" . xtc_db_input((int) $customer_id) . "'");
    } else {
        $gv_query = xtc_db_query("insert into " . TABLE_COUPON_GV_CUSTOMER . " (customer_id, amount) values ('" . xtc_db_input((int) $customer_id) . "', '" . xtc_db_input($coupon_gv['coupon_amount']) . "')");
    }
}
function xtc_currency_exists($code)
{
    $param = '/[^a-zA-Z]/';
    $code = preg_replace($param, '', $code);
    $currency_code = xtc_db_query("SELECT code, currencies_id from " . TABLE_CURRENCIES . " WHERE code = '" . xtc_db_input($code) . "' LIMIT 1");
    if (xtc_db_num_rows($currency_code)) {
        $curr = xtc_db_fetch_array($currency_code);
        if ($curr['code'] == $code) {
            return $code;
        } else {
            return false;
        }
    } else {
        return false;
    }
}
function xtc_expire_banners()
{
    $banners_query = xtc_db_query("select b.banners_id, b.expires_date, b.expires_impressions, sum(bh.banners_shown) as banners_shown from " . TABLE_BANNERS . " b, " . TABLE_BANNERS_HISTORY . " bh where b.status = '1' and b.banners_id = bh.banners_id group by b.banners_id");
    if (xtc_db_num_rows($banners_query)) {
        while ($banners = xtc_db_fetch_array($banners_query)) {
            if (xtc_not_null($banners['expires_date'])) {
                if (date('Y-m-d H:i:s') >= $banners['expires_date']) {
                    xtc_set_banner_status($banners['banners_id'], '0');
                }
            } elseif (xtc_not_null($banners['expires_impressions'])) {
                if ($banners['banners_shown'] >= $banners['expires_impressions']) {
                    xtc_set_banner_status($banners['banners_id'], '0');
                }
            }
        }
    }
}
 function xtc_cfg_save_max_display_results($cfg_key)
 {
     if (isset($_POST[$cfg_key])) {
         $configuration_value = preg_replace('/[^0-9-]/', '', $_POST[$cfg_key]);
         $configuration_value = xtc_db_prepare_input($configuration_value);
         $configuration_query = xtc_db_query("SELECT configuration_key,\n                                                  configuration_value\n                                             FROM " . TABLE_CONFIGURATION . "\n                                            WHERE configuration_key = '" . xtc_db_input($cfg_key) . "'\n                                         ");
         if (xtc_db_num_rows($configuration_query) > 0) {
             //update
             xtc_db_query("UPDATE " . TABLE_CONFIGURATION . "\n                         SET configuration_value ='" . xtc_db_input($configuration_value) . "',\n                             last_modified = NOW()\n                       WHERE configuration_key='" . xtc_db_input($cfg_key) . "'");
         } else {
             //new entry
             $sql_data_array = array('configuration_key' => $cfg_key, 'configuration_value' => $configuration_value, 'configuration_group_id' => '1000', 'sort_order' => '-1', 'last_modified' => 'now()', 'date_added' => 'now()');
             xtc_db_perform(TABLE_CONFIGURATION, $sql_data_array);
         }
         return $configuration_value;
     }
     return defined($cfg_key) && (int) constant($cfg_key) > 0 ? constant($cfg_key) : 20;
 }
function xtc_get_product_original_path($products_id)
{
    $cPath = '';
    $category_query = "select p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = '" . (int) $products_id . "' and p.products_status = '1' and p.products_id = p2c.products_id and p2c.categories_id != 0 limit 1";
    $category_query = xtDBquery($category_query);
    if (xtc_db_num_rows($category_query, true)) {
        $category = xtc_db_fetch_array($category_query);
        $categories = array();
        xtc_get_parent_categories($categories, $category['categories_id']);
        $categories = array_reverse($categories);
        $cPath = implode('_', $categories);
        if (xtc_not_null($cPath)) {
            $cPath .= '_';
        }
        $cPath .= $category['categories_id'];
    }
    return $cPath;
}
function xtc_get_tax_rate_export($class_id, $country_id = -1, $zone_id = -1)
{
    global $currency;
    // calculate currencies
    if ($country_id == -1 && $zone_id == -1) {
        $country_id = STORE_COUNTRY;
        $zone_id = STORE_ZONE;
    }
    $tax_query = xtc_db_query("select sum(tax_rate) as tax_rate from " . TABLE_TAX_RATES . " tr left join " . TABLE_ZONES_TO_GEO_ZONES . " za on (tr.tax_zone_id = za.geo_zone_id) left join " . TABLE_GEO_ZONES . " tz on (tz.geo_zone_id = tr.tax_zone_id) where (za.zone_country_id is null or za.zone_country_id = '0' or za.zone_country_id = '" . $country_id . "') and (za.zone_id is null or za.zone_id = '0' or za.zone_id = '" . $zone_id . "') and tr.tax_class_id = '" . $class_id . "' group by tr.tax_priority");
    if (xtc_db_num_rows($tax_query)) {
        $tax_multiplier = 1.0;
        while ($tax = xtc_db_fetch_array($tax_query)) {
            $tax_multiplier *= 1.0 + $tax['tax_rate'] / 100;
        }
        return ($tax_multiplier - 1.0) * 100;
    } else {
        return 0;
    }
}