Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Recommended Posts

Posted

Hi guys i wonder if u can help me ? Ive installed the meta tags controller v 2.36 and now when I try and enter my admin I get the following message

 

Fatal error: Cannot redeclare tep_get_products_head_title_tag() (previously declared in /home/*******/public_html/admin/includes/functions/general.php:514) in /home/******/public_html/admin/includes/functions/general.php on line 538

 

Thanks

Posted

Maybe you should put the code higher up the page, before other HTML has been sent? Just an idea, I am fairly new.

Thanks for any help/comments.

 

Regards,

 

Lewis Hill

Posted

Take a look at your functions/general.php file. When you install HTC, you add code to that file. Sounds like it was added twice. If you don't see anything obvious, post the file here so I can look at it.

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Posted
Take a look at your functions/general.php file.  When you install HTC, you add code to that file. Sounds like it was added twice.  If you don't see anything obvious, post the file here so I can look at it.

 

Jack

I cant find any problems ,here is my includes/functions/general file

 

<?php

/*

$Id: general.php,v 1.231 2003/07/09 01:15:48 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

 

////

// Stop from parsing any further PHP code

function tep_exit() {

tep_session_close();

exit();

}

 

////

// Redirect to another page or site

function tep_redirect($url) {

if ( (ENABLE_SSL == true) && (getenv('HTTPS') == 'on') ) { // We are loading an SSL page

if (substr($url, 0, strlen(HTTP_SERVER)) == HTTP_SERVER) { // NONSSL url

$url = HTTPS_SERVER . substr($url, strlen(HTTP_SERVER)); // Change it to SSL

}

}

 

header('Location: ' . $url);

 

tep_exit();

}

 

////

// Parse the data used in the html tags to ensure the tags will not break

function tep_parse_input_field_data($data, $parse) {

return strtr(trim($data), $parse);

}

 

function tep_output_string($string, $translate = false, $protected = false) {

if ($protected == true) {

return htmlspecialchars($string);

} else {

if ($translate == false) {

return tep_parse_input_field_data($string, array('"' => '"'));

} else {

return tep_parse_input_field_data($string, $translate);

}

}

}

 

function tep_output_string_protected($string) {

return tep_output_string($string, false, true);

}

 

function tep_sanitize_string($string) {

$string = ereg_replace(' +', ' ', trim($string));

 

return preg_replace("/[<>]/", '_', $string);

}

 

////

// Return a random row from a database query

function tep_random_select($query) {

$random_product = '';

$random_query = tep_db_query($query);

$num_rows = tep_db_num_rows($random_query);

if ($num_rows > 0) {

$random_row = tep_rand(0, ($num_rows - 1));

tep_db_data_seek($random_query, $random_row);

$random_product = tep_db_fetch_array($random_query);

}

 

return $random_product;

}

 

////

// Return a product's name

// TABLES: products

function tep_get_products_name($product_id, $language = '') {

global $languages_id;

 

if (empty($language)) $language = $languages_id;

 

$product_query = tep_db_query("select products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language . "'");

$product = tep_db_fetch_array($product_query);

 

return $product['products_name'];

}

 

////

// Return a product's special price (returns nothing if there is no offer)

// TABLES: products

function tep_get_products_special_price($product_id) {

$product_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$product_id . "' and status");

$product = tep_db_fetch_array($product_query);

 

return $product['specials_new_products_price'];

}

 

////

// Return a product's stock

// TABLES: products

function tep_get_products_stock($products_id) {

$products_id = tep_get_prid($products_id);

$stock_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");

$stock_values = tep_db_fetch_array($stock_query);

 

return $stock_values['products_quantity'];

}

 

////

// Check if the required stock is available

// If insufficent stock is available return an out of stock message

function tep_check_stock($products_id, $products_quantity) {

$stock_left = tep_get_products_stock($products_id) - $products_quantity;

$out_of_stock = '';

 

if ($stock_left < 0) {

$out_of_stock = '<span class="markProductOutOfStock">' . STOCK_MARK_PRODUCT_OUT_OF_STOCK . '</span>';

}

 

return $out_of_stock;

}

 

////

// Break a word in a string if it is longer than a specified length ($len)

function tep_break_string($string, $len, $break_char = '-') {

$l = 0;

$output = '';

for ($i=0, $n=strlen($string); $i<$n; $i++) {

$char = substr($string, $i, 1);

if ($char != ' ') {

$l++;

} else {

$l = 0;

}

if ($l > $len) {

$l = 1;

$output .= $break_char;

}

$output .= $char;

}

 

return $output;

}

 

////

// Return all HTTP GET variables, except those passed as a parameter

function tep_get_all_get_params($exclude_array = '') {

global $HTTP_GET_VARS;

 

if (!is_array($exclude_array)) $exclude_array = array();

 

$get_url = '';

if (is_array($HTTP_GET_VARS) && (sizeof($HTTP_GET_VARS) > 0)) {

reset($HTTP_GET_VARS);

while (list($key, $value) = each($HTTP_GET_VARS)) {

if ( (strlen($value) > 0) && ($key != tep_session_name()) && ($key != 'error') && (!in_array($key, $exclude_array)) && ($key != 'x') && ($key != 'y') ) {

$get_url .= $key . '=' . rawurlencode(stripslashes($value)) . '&';

}

}

}

 

return $get_url;

}

 

////

// Returns an array with countries

// TABLES: countries

function tep_get_countries($countries_id = '', $with_iso_codes = false) {

$countries_array = array();

if (tep_not_null($countries_id)) {

if ($with_iso_codes == true) {

$countries = tep_db_query("select countries_name, countries_iso_code_2, countries_iso_code_3 from " . TABLE_COUNTRIES . " where countries_id = '" . (int)$countries_id . "' order by countries_name");

$countries_values = tep_db_fetch_array($countries);

$countries_array = array('countries_name' => $countries_values['countries_name'],

'countries_iso_code_2' => $countries_values['countries_iso_code_2'],

'countries_iso_code_3' => $countries_values['countries_iso_code_3']);

} else {

$countries = tep_db_query("select countries_name from " . TABLE_COUNTRIES . " where countries_id = '" . (int)$countries_id . "'");

$countries_values = tep_db_fetch_array($countries);

$countries_array = array('countries_name' => $countries_values['countries_name']);

}

} else {

$countries = tep_db_query("select countries_id, countries_name from " . TABLE_COUNTRIES . " order by countries_name");

while ($countries_values = tep_db_fetch_array($countries)) {

$countries_array[] = array('countries_id' => $countries_values['countries_id'],

'countries_name' => $countries_values['countries_name']);

}

}

 

return $countries_array;

}

 

////

// Alias function to tep_get_countries, which also returns the countries iso codes

function tep_get_countries_with_iso_codes($countries_id) {

return tep_get_countries($countries_id, true);

}

 

////

// Generate a path to categories

function tep_get_path($current_category_id = '') {

global $cPath_array;

 

if (tep_not_null($current_category_id)) {

$cp_size = sizeof($cPath_array);

if ($cp_size == 0) {

$cPath_new = $current_category_id;

} else {

$cPath_new = '';

$last_category_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$cPath_array[($cp_size-1)] . "'");

$last_category = tep_db_fetch_array($last_category_query);

 

$current_category_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'");

$current_category = tep_db_fetch_array($current_category_query);

 

if ($last_category['parent_id'] == $current_category['parent_id']) {

for ($i=0; $i<($cp_size-1); $i++) {

$cPath_new .= '_' . $cPath_array[$i];

}

} else {

for ($i=0; $i<$cp_size; $i++) {

$cPath_new .= '_' . $cPath_array[$i];

}

}

$cPath_new .= '_' . $current_category_id;

 

if (substr($cPath_new, 0, 1) == '_') {

$cPath_new = substr($cPath_new, 1);

}

}

} else {

$cPath_new = implode('_', $cPath_array);

}

 

return 'cPath=' . $cPath_new;

}

 

////

// Returns the clients browser

function tep_browser_detect($component) {

global $HTTP_USER_AGENT;

 

return stristr($HTTP_USER_AGENT, $component);

}

 

////

// Alias function to tep_get_countries()

function tep_get_country_name($country_id) {

$country_array = tep_get_countries($country_id);

 

return $country_array['countries_name'];

}

 

////

// Returns the zone (State/Province) name

// TABLES: zones

function tep_get_zone_name($country_id, $zone_id, $default_zone) {

$zone_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country_id . "' and zone_id = '" . (int)$zone_id . "'");

if (tep_db_num_rows($zone_query)) {

$zone = tep_db_fetch_array($zone_query);

return $zone['zone_name'];

} else {

return $default_zone;

}

}

 

////

// Returns the zone (State/Province) code

// TABLES: zones

function tep_get_zone_code($country_id, $zone_id, $default_zone) {

$zone_query = tep_db_query("select zone_code from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country_id . "' and zone_id = '" . (int)$zone_id . "'");

if (tep_db_num_rows($zone_query)) {

$zone = tep_db_fetch_array($zone_query);

return $zone['zone_code'];

} else {

return $default_zone;

}

}

 

////

// Wrapper function for round()

function tep_round($number, $precision) {

if (strpos($number, '.') && (strlen(substr($number, strpos($number, '.')+1)) > $precision)) {

$number = substr($number, 0, strpos($number, '.') + 1 + $precision + 1);

 

if (substr($number, -1) >= 5) {

if ($precision > 1) {

$number = substr($number, 0, -1) + ('0.' . str_repeat(0, $precision-1) . '1');

} elseif ($precision == 1) {

$number = substr($number, 0, -1) + 0.1;

} else {

$number = substr($number, 0, -1) + 1;

}

} else {

$number = substr($number, 0, -1);

}

}

 

return $number;

}

 

////

// Returns the tax rate for a zone / class

// TABLES: tax_rates, zones_to_geo_zones

function tep_get_tax_rate($class_id, $country_id = -1, $zone_id = -1) {

global $customer_zone_id, $customer_country_id;

 

if ( ($country_id == -1) && ($zone_id == -1) ) {

if (!tep_session_is_registered('customer_id')) {

$country_id = STORE_COUNTRY;

$zone_id = STORE_ZONE;

} else {

$country_id = $customer_country_id;

$zone_id = $customer_zone_id;

}

}

 

$tax_query = tep_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 = '" . (int)$country_id . "') and (za.zone_id is null or za.zone_id = '0' or za.zone_id = '" . (int)$zone_id . "') and tr.tax_class_id = '" . (int)$class_id . "' group by tr.tax_priority");

if (tep_db_num_rows($tax_query)) {

$tax_multiplier = 1.0;

while ($tax = tep_db_fetch_array($tax_query)) {

$tax_multiplier *= 1.0 + ($tax['tax_rate'] / 100);

}

return ($tax_multiplier - 1.0) * 100;

} else {

return 0;

}

}

 

////

// Return the tax description for a zone / class

// TABLES: tax_rates;

function tep_get_tax_description($class_id, $country_id, $zone_id) {

$tax_query = tep_db_query("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 = '" . (int)$country_id . "') and (za.zone_id is null or za.zone_id = '0' or za.zone_id = '" . (int)$zone_id . "') and tr.tax_class_id = '" . (int)$class_id . "' order by tr.tax_priority");

if (tep_db_num_rows($tax_query)) {

$tax_description = '';

while ($tax = tep_db_fetch_array($tax_query)) {

$tax_description .= $tax['tax_description'] . ' + ';

}

$tax_description = substr($tax_description, 0, -3);

 

return $tax_description;

} else {

return TEXT_UNKNOWN_TAX_RATE;

}

}

 

////

// Add tax to a products price

function tep_add_tax($price, $tax) {

global $currencies;

 

if ( (DISPLAY_PRICE_WITH_TAX == 'true') && ($tax > 0) ) {

return tep_round($price, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']) + tep_calculate_tax($price, $tax);

} else {

return tep_round($price, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);

}

}

 

// Calculates Tax rounding the result

function tep_calculate_tax($price, $tax) {

global $currencies;

 

return tep_round($price * $tax / 100, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);

}

 

////

// Return the number of products in a category

// TABLES: products, products_to_categories, categories

function tep_count_products_in_category($category_id, $include_inactive = false) {

$products_count = 0;

if ($include_inactive == true) {

$products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$category_id . "'");

} else {

$products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p.products_status = '1' and p2c.categories_id = '" . (int)$category_id . "'");

}

$products = tep_db_fetch_array($products_query);

$products_count += $products['total'];

 

$child_categories_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$category_id . "'");

if (tep_db_num_rows($child_categories_query)) {

while ($child_categories = tep_db_fetch_array($child_categories_query)) {

$products_count += tep_count_products_in_category($child_categories['categories_id'], $include_inactive);

}

}

 

return $products_count;

}

 

////

// Return true if the category has subcategories

// TABLES: categories

function tep_has_category_subcategories($category_id) {

$child_category_query = tep_db_query("select count(*) as count from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$category_id . "'");

$child_category = tep_db_fetch_array($child_category_query);

 

if ($child_category['count'] > 0) {

return true;

} else {

return false;

}

}

 

////

// Returns the address_format_id for the given country

// TABLES: countries;

function tep_get_address_format_id($country_id) {

$address_format_query = tep_db_query("select address_format_id as format_id from " . TABLE_COUNTRIES . " where countries_id = '" . (int)$country_id . "'");

if (tep_db_num_rows($address_format_query)) {

$address_format = tep_db_fetch_array($address_format_query);

return $address_format['format_id'];

} else {

return '1';

}

}

 

////

// Return a formatted address

// TABLES: address_format

function tep_address_format($address_format_id, $address, $html, $boln, $eoln) {

$address_format_query = tep_db_query("select address_format as format from " . TABLE_ADDRESS_FORMAT . " where address_format_id = '" . (int)$address_format_id . "'");

$address_format = tep_db_fetch_array($address_format_query);

 

$company = tep_output_string_protected($address['company']);

if (isset($address['firstname']) && tep_not_null($address['firstname'])) {

$firstname = tep_output_string_protected($address['firstname']);

$lastname = tep_output_string_protected($address['lastname']);

} elseif (isset($address['name']) && tep_not_null($address['name'])) {

$firstname = tep_output_string_protected($address['name']);

$lastname = '';

} else {

$firstname = '';

$lastname = '';

}

$street = tep_output_string_protected($address['street_address']);

$suburb = tep_output_string_protected($address['suburb']);

$city = tep_output_string_protected($address['city']);

$state = tep_output_string_protected($address['state']);

if (isset($address['country_id']) && tep_not_null($address['country_id'])) {

$country = tep_get_country_name($address['country_id']);

 

if (isset($address['zone_id']) && tep_not_null($address['zone_id'])) {

$state = tep_get_zone_code($address['country_id'], $address['zone_id'], $state);

}

} elseif (isset($address['country']) && tep_not_null($address['country'])) {

$country = tep_output_string_protected($address['country']);

} else {

$country = '';

}

$postcode = tep_output_string_protected($address['postcode']);

$zip = $postcode;

 

if ($html) {

// HTML Mode

$HR = '<hr>';

$hr = '<hr>';

if ( ($boln == '') && ($eoln == "\n") ) { // Values not specified, use rational defaults

$CR = '<br>';

$cr = '<br>';

$eoln = $cr;

} else { // Use values supplied

$CR = $eoln . $boln;

$cr = $CR;

}

} else {

// Text Mode

$CR = $eoln;

$cr = $CR;

$HR = '----------------------------------------';

$hr = '----------------------------------------';

}

 

$statecomma = '';

$streets = $street;

if ($suburb != '') $streets = $street . $cr . $suburb;

if ($country == '') $country = tep_output_string_protected($address['country']);

if ($state != '') $statecomma = $state . ', ';

 

$fmt = $address_format['format'];

eval("\$address = \"$fmt\";");

 

if ( (ACCOUNT_COMPANY == 'true') && (tep_not_null($company)) ) {

$address = $company . $cr . $address;

}

 

return $address;

}

 

////

// Return a formatted address

// TABLES: customers, address_book

function tep_address_label($customers_id, $address_id = 1, $html = false, $boln = '', $eoln = "\n") {

$address_query = tep_db_query("select entry_firstname as firstname, entry_lastname as lastname, entry_company as company, entry_street_address as street_address, entry_suburb as suburb, entry_city as city, entry_postcode as postcode, entry_state as state, entry_zone_id as zone_id, entry_country_id as country_id from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customers_id . "' and address_book_id = '" . (int)$address_id . "'");

$address = tep_db_fetch_array($address_query);

 

$format_id = tep_get_address_format_id($address['country_id']);

 

return tep_address_format($format_id, $address, $html, $boln, $eoln);

}

 

function tep_row_number_format($number) {

if ( ($number < 10) && (substr($number, 0, 1) != '0') ) $number = '0' . $number;

 

return $number;

}

 

function tep_get_categories($categories_array = '', $parent_id = '0', $indent = '') {

global $languages_id;

 

if (!is_array($categories_array)) $categories_array = array();

 

$categories_query = tep_db_query("select c.categories_id, cd.categories_name from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where parent_id = '" . (int)$parent_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name");

while ($categories = tep_db_fetch_array($categories_query)) {

$categories_array[] = array('id' => $categories['categories_id'],

'text' => $indent . $categories['categories_name']);

 

if ($categories['categories_id'] != $parent_id) {

$categories_array = tep_get_categories($categories_array, $categories['categories_id'], $indent . '  ');

}

}

 

return $categories_array;

}

 

function tep_get_manufacturers($manufacturers_array = '') {

if (!is_array($manufacturers_array)) $manufacturers_array = array();

 

$manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " order by manufacturers_name");

while ($manufacturers = tep_db_fetch_array($manufacturers_query)) {

$manufacturers_array[] = array('id' => $manufacturers['manufacturers_id'], 'text' => $manufacturers['manufacturers_name']);

}

 

return $manufacturers_array;

}

 

////

// Return all subcategory IDs

// TABLES: categories

function tep_get_subcategories(&$subcategories_array, $parent_id = 0) {

$subcategories_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$parent_id . "'");

while ($subcategories = tep_db_fetch_array($subcategories_query)) {

$subcategories_array[sizeof($subcategories_array)] = $subcategories['categories_id'];

if ($subcategories['categories_id'] != $parent_id) {

tep_get_subcategories($subcategories_array, $subcategories['categories_id']);

}

}

}

 

// Output a raw date string in the selected locale date format

// $raw_date needs to be in this format: YYYY-MM-DD HH:MM:SS

function tep_date_long($raw_date) {

if ( ($raw_date == '0000-00-00 00:00:00') || ($raw_date == '') ) return false;

 

$year = (int)substr($raw_date, 0, 4);

$month = (int)substr($raw_date, 5, 2);

$day = (int)substr($raw_date, 8, 2);

$hour = (int)substr($raw_date, 11, 2);

$minute = (int)substr($raw_date, 14, 2);

$second = (int)substr($raw_date, 17, 2);

 

return strftime(DATE_FORMAT_LONG, mktime($hour,$minute,$second,$month,$day,$year));

}

 

////

// Output a raw date string in the selected locale date format

// $raw_date needs to be in this format: YYYY-MM-DD HH:MM:SS

// NOTE: Includes a workaround for dates before 01/01/1970 that fail on windows servers

function tep_date_short($raw_date) {

if ( ($raw_date == '0000-00-00 00:00:00') || empty($raw_date) ) return false;

 

$year = substr($raw_date, 0, 4);

$month = (int)substr($raw_date, 5, 2);

$day = (int)substr($raw_date, 8, 2);

$hour = (int)substr($raw_date, 11, 2);

$minute = (int)substr($raw_date, 14, 2);

$second = (int)substr($raw_date, 17, 2);

 

if (@date('Y', mktime($hour, $minute, $second, $month, $day, $year)) == $year) {

return date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, $year));

} else {

return ereg_replace('2037' . '$', $year, date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, 2037)));

}

}

 

////

// Parse search string into indivual objects

function tep_parse_search_string($search_str = '', &$objects) {

$search_str = trim(strtolower($search_str));

 

// Break up $search_str on whitespace; quoted string will be reconstructed later

$pieces = split('[[:space:]]+', $search_str);

$objects = array();

$tmpstring = '';

$flag = '';

 

for ($k=0; $k<count($pieces); $k++) {

while (substr($pieces[$k], 0, 1) == '(') {

$objects[] = '(';

if (strlen($pieces[$k]) > 1) {

$pieces[$k] = substr($pieces[$k], 1);

} else {

$pieces[$k] = '';

}

}

 

$post_objects = array();

 

while (substr($pieces[$k], -1) == ')') {

$post_objects[] = ')';

if (strlen($pieces[$k]) > 1) {

$pieces[$k] = substr($pieces[$k], 0, -1);

} else {

$pieces[$k] = '';

}

}

 

// Check individual words

 

if ( (substr($pieces[$k], -1) != '"') && (substr($pieces[$k], 0, 1) != '"') ) {

$objects[] = trim($pieces[$k]);

 

for ($j=0; $j<count($post_objects); $j++) {

$objects[] = $post_objects[$j];

}

} else {

/* This means that the $piece is either the beginning or the end of a string.

So, we'll slurp up the $pieces and stick them together until we get to the

end of the string or run out of pieces.

*/

 

// Add this word to the $tmpstring, starting the $tmpstring

$tmpstring = trim(ereg_replace('"', ' ', $pieces[$k]));

 

// Check for one possible exception to the rule. That there is a single quoted word.

if (substr($pieces[$k], -1 ) == '"') {

// Turn the flag off for future iterations

$flag = 'off';

 

$objects[] = trim($pieces[$k]);

 

for ($j=0; $j<count($post_objects); $j++) {

$objects[] = $post_objects[$j];

}

 

unset($tmpstring);

 

// Stop looking for the end of the string and move onto the next word.

continue;

}

 

// Otherwise, turn on the flag to indicate no quotes have been found attached to this word in the string.

$flag = 'on';

 

// Move on to the next word

$k++;

 

// Keep reading until the end of the string as long as the $flag is on

 

while ( ($flag == 'on') && ($k < count($pieces)) ) {

while (substr($pieces[$k], -1) == ')') {

$post_objects[] = ')';

if (strlen($pieces[$k]) > 1) {

$pieces[$k] = substr($pieces[$k], 0, -1);

} else {

$pieces[$k] = '';

}

}

 

// If the word doesn't end in double quotes, append it to the $tmpstring.

if (substr($pieces[$k], -1) != '"') {

// Tack this word onto the current string entity

$tmpstring .= ' ' . $pieces[$k];

 

// Move on to the next word

$k++;

continue;

} else {

/* If the $piece ends in double quotes, strip the double quotes, tack the

$piece onto the tail of the string, push the $tmpstring onto the $haves,

kill the $tmpstring, turn the $flag "off", and return.

*/

$tmpstring .= ' ' . trim(ereg_replace('"', ' ', $pieces[$k]));

 

// Push the $tmpstring onto the array of stuff to search for

$objects[] = trim($tmpstring);

 

for ($j=0; $j<count($post_objects); $j++) {

$objects[] = $post_objects[$j];

}

 

unset($tmpstring);

 

// Turn off the flag to exit the loop

$flag = 'off';

}

}

}

}

 

// add default logical operators if needed

$temp = array();

for($i=0; $i<(count($objects)-1); $i++) {

$temp[] = $objects[$i];

if ( ($objects[$i] != 'and') &&

($objects[$i] != 'or') &&

($objects[$i] != '(') &&

($objects[$i+1] != 'and') &&

($objects[$i+1] != 'or') &&

($objects[$i+1] != ')') ) {

$temp[] = ADVANCED_SEARCH_DEFAULT_OPERATOR;

}

}

$temp[] = $objects[$i];

$objects = $temp;

 

$keyword_count = 0;

$operator_count = 0;

$balance = 0;

for($i=0; $i<count($objects); $i++) {

if ($objects[$i] == '(') $balance --;

if ($objects[$i] == ')') $balance ++;

if ( ($objects[$i] == 'and') || ($objects[$i] == 'or') ) {

$operator_count ++;

} elseif ( ($objects[$i]) && ($objects[$i] != '(') && ($objects[$i] != ')') ) {

$keyword_count ++;

}

}

 

if ( ($operator_count < $keyword_count) && ($balance == 0) ) {

return true;

} else {

return false;

}

}

 

////

// Check date

function tep_checkdate($date_to_check, $format_string, &$date_array) {

$separator_idx = -1;

 

$separators = array('-', ' ', '/', '.');

$month_abbr = array('jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec');

$no_of_days = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

 

$format_string = strtolower($format_string);

 

if (strlen($date_to_check) != strlen($format_string)) {

return false;

}

 

$size = sizeof($separators);

for ($i=0; $i<$size; $i++) {

$pos_separator = strpos($date_to_check, $separators[$i]);

if ($pos_separator != false) {

$date_separator_idx = $i;

break;

}

}

 

for ($i=0; $i<$size; $i++) {

$pos_separator = strpos($format_string, $separators[$i]);

if ($pos_separator != false) {

$format_separator_idx = $i;

break;

}

}

 

if ($date_separator_idx != $format_separator_idx) {

return false;

}

 

if ($date_separator_idx != -1) {

$format_string_array = explode( $separators[$date_separator_idx], $format_string );

if (sizeof($format_string_array) != 3) {

return false;

}

 

$date_to_check_array = explode( $separators[$date_separator_idx], $date_to_check );

if (sizeof($date_to_check_array) != 3) {

return false;

}

 

$size = sizeof($format_string_array);

for ($i=0; $i<$size; $i++) {

if ($format_string_array[$i] == 'mm' || $format_string_array[$i] == 'mmm') $month = $date_to_check_array[$i];

if ($format_string_array[$i] == 'dd') $day = $date_to_check_array[$i];

if ( ($format_string_array[$i] == 'yyyy') || ($format_string_array[$i] == 'aaaa') ) $year = $date_to_check_array[$i];

}

} else {

if (strlen($format_string) == 8 || strlen($format_string) == 9) {

$pos_month = strpos($format_string, 'mmm');

if ($pos_month != false) {

$month = substr( $date_to_check, $pos_month, 3 );

$size = sizeof($month_abbr);

for ($i=0; $i<$size; $i++) {

if ($month == $month_abbr[$i]) {

$month = $i;

break;

}

}

} else {

$month = substr($date_to_check, strpos($format_string, 'mm'), 2);

}

} else {

return false;

}

 

$day = substr($date_to_check, strpos($format_string, 'dd'), 2);

$year = substr($date_to_check, strpos($format_string, 'yyyy'), 4);

}

 

if (strlen($year) != 4) {

return false;

}

 

if (!settype($year, 'integer') || !settype($month, 'integer') || !settype($day, 'integer')) {

return false;

}

 

if ($month > 12 || $month < 1) {

return false;

}

 

if ($day < 1) {

return false;

}

 

if (tep_is_leap_year($year)) {

$no_of_days[1] = 29;

}

 

if ($day > $no_of_days[$month - 1]) {

return false;

}

 

$date_array = array($year, $month, $day);

 

return true;

}

 

////

// Check if year is a leap year

function tep_is_leap_year($year) {

if ($year % 100 == 0) {

if ($year % 400 == 0) return true;

} else {

if (($year % 4) == 0) return true;

}

 

return false;

}

 

////

// Return table heading with sorting capabilities

function tep_create_sort_heading($sortby, $colnum, $heading) {

global $PHP_SELF;

 

$sort_prefix = '';

$sort_suffix = '';

 

if ($sortby) {

$sort_prefix = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('page', 'info', 'sort')) . 'page=1&sort=' . $colnum . ($sortby == $colnum . 'a' ? 'd' : 'a')) . '" title="' . tep_output_string(TEXT_SORT_PRODUCTS . ($sortby == $colnum . 'd' || substr($sortby, 0, 1) != $colnum ? TEXT_ASCENDINGLY : TEXT_DESCENDINGLY) . TEXT_BY . $heading) . '" class="productListing-heading">' ;

$sort_suffix = (substr($sortby, 0, 1) == $colnum ? (substr($sortby, 1, 1) == 'a' ? '+' : '-') : '') . '</a>';

}

 

return $sort_prefix . $heading . $sort_suffix;

}

 

////

// Recursively go through the categories and retreive all parent categories IDs

// TABLES: categories

function tep_get_parent_categories(&$categories, $categories_id) {

$parent_categories_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$categories_id . "'");

while ($parent_categories = tep_db_fetch_array($parent_categories_query)) {

if ($parent_categories['parent_id'] == 0) return true;

$categories[sizeof($categories)] = $parent_categories['parent_id'];

if ($parent_categories['parent_id'] != $categories_id) {

tep_get_parent_categories($categories, $parent_categories['parent_id']);

}

}

}

 

////

// Construct a category path to the product

// TABLES: products_to_categories

function tep_get_product_path($products_id) {

$cPath = '';

 

$category_query = tep_db_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 limit 1");

if (tep_db_num_rows($category_query)) {

$category = tep_db_fetch_array($category_query);

 

$categories = array();

tep_get_parent_categories($categories, $category['categories_id']);

 

$categories = array_reverse($categories);

 

$cPath = implode('_', $categories);

 

if (tep_not_null($cPath)) $cPath .= '_';

$cPath .= $category['categories_id'];

}

 

return $cPath;

}

 

////

// Return a product ID with attributes

function tep_get_uprid($prid, $params) {

$uprid = $prid;

if ( (is_array($params)) && (!strstr($prid, '{')) ) {

while (list($option, $value) = each($params)) {

$uprid = $uprid . '{' . $option . '}' . $value;

}

}

 

return $uprid;

}

 

////

// Return a product ID from a product ID with attributes

function tep_get_prid($uprid) {

$pieces = explode('{', $uprid);

 

return $pieces[0];

}

 

////

// Return a customer greeting

function tep_customer_greeting() {

global $customer_id, $customer_first_name;

 

if (tep_session_is_registered('customer_first_name') && tep_session_is_registered('customer_id')) {

$greeting_string = sprintf(TEXT_GREETING_PERSONAL, tep_output_string_protected($customer_first_name), tep_href_link(FILENAME_PRODUCTS_NEW));

} else {

$greeting_string = sprintf(TEXT_GREETING_GUEST, tep_href_link(FILENAME_LOGIN, '', 'SSL'), tep_href_link(FILENAME_CREATE_ACCOUNT, '', 'SSL'));

}

 

return $greeting_string;

}

 

////

//! Send email (text/html) using MIME

// This is the central mail function. The SMTP Server should be configured

// correct in php.ini

// Parameters:

// $to_name The name of the recipient, e.g. "Jan Wildeboer"

// $to_email_address The eMail address of the recipient,

// e.g. [email protected]

// $email_subject The subject of the eMail

// $email_text The text of the eMail, may contain HTML entities

// $from_email_name The name of the sender, e.g. Shop Administration

// $from_email_adress The eMail address of the sender,

// e.g. [email protected]

 

function tep_mail($to_name, $to_email_address, $email_subject, $email_text, $from_email_name, $from_email_address) {

if (SEND_EMAILS != 'true') return false;

 

// Instantiate a new mail object

$message = new email(array('X-Mailer: osCommerce Mailer'));

 

// Build the text version

$text = strip_tags($email_text);

if (EMAIL_USE_HTML == 'true') {

$message->add_html($email_text, $text);

} else {

$message->add_text($text);

}

 

// Send message

$message->build_message();

$message->send($to_name, $to_email_address, $from_email_name, $from_email_address, $email_subject);

}

 

////

// Check if product has attributes

function tep_has_product_attributes($products_id) {

$attributes_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "'");

$attributes = tep_db_fetch_array($attributes_query);

 

if ($attributes['count'] > 0) {

return true;

} else {

return false;

}

}

 

////

// Get the number of times a word/character is present in a string

function tep_word_count($string, $needle) {

$temp_array = split($needle, $string);

 

return sizeof($temp_array);

}

 

function tep_count_modules($modules = '') {

$count = 0;

 

if (empty($modules)) return $count;

 

$modules_array = split(';', $modules);

 

for ($i=0, $n=sizeof($modules_array); $i<$n; $i++) {

$class = substr($modules_array[$i], 0, strrpos($modules_array[$i], '.'));

 

if (is_object($GLOBALS[$class])) {

if ($GLOBALS[$class]->enabled) {

$count++;

}

}

}

 

return $count;

}

 

function tep_count_payment_modules() {

return tep_count_modules(MODULE_PAYMENT_INSTALLED);

}

 

function tep_count_shipping_modules() {

return tep_count_modules(MODULE_SHIPPING_INSTALLED);

}

 

function tep_create_random_value($length, $type = 'mixed') {

if ( ($type != 'mixed') && ($type != 'chars') && ($type != 'digits')) return false;

 

$rand_value = '';

while (strlen($rand_value) < $length) {

if ($type == 'digits') {

$char = tep_rand(0,9);

} else {

$char = chr(tep_rand(0,255));

}

if ($type == 'mixed') {

if (eregi('^[a-z0-9]$', $char)) $rand_value .= $char;

} elseif ($type == 'chars') {

if (eregi('^[a-z]$', $char)) $rand_value .= $char;

} elseif ($type == 'digits') {

if (ereg('^[0-9]$', $char)) $rand_value .= $char;

}

}

 

return $rand_value;

}

 

function tep_array_to_string($array, $exclude = '', $equals = '=', $separator = '&') {

if (!is_array($exclude)) $exclude = array();

 

$get_string = '';

if (sizeof($array) > 0) {

while (list($key, $value) = each($array)) {

if ( (!in_array($key, $exclude)) && ($key != 'x') && ($key != 'y') ) {

$get_string .= $key . $equals . $value . $separator;

}

}

$remove_chars = strlen($separator);

$get_string = substr($get_string, 0, -$remove_chars);

}

 

return $get_string;

}

 

function tep_not_null($value) {

if (is_array($value)) {

if (sizeof($value) > 0) {

return true;

} else {

return false;

}

} else {

if (($value != '') && (strtolower($value) != 'null') && (strlen(trim($value)) > 0)) {

return true;

} else {

return false;

}

}

}

 

////

// Output the tax percentage with optional padded decimals

function tep_display_tax_value($value, $padding = TAX_DECIMAL_PLACES) {

if (strpos($value, '.')) {

$loop = true;

while ($loop) {

if (substr($value, -1) == '0') {

$value = substr($value, 0, -1);

} else {

$loop = false;

if (substr($value, -1) == '.') {

$value = substr($value, 0, -1);

}

}

}

}

 

if ($padding > 0) {

if ($decimal_pos = strpos($value, '.')) {

$decimals = strlen(substr($value, ($decimal_pos+1)));

for ($i=$decimals; $i<$padding; $i++) {

$value .= '0';

}

} else {

$value .= '.';

for ($i=0; $i<$padding; $i++) {

$value .= '0';

}

}

}

 

return $value;

}

 

////

// Checks to see if the currency code exists as a currency

// TABLES: currencies

function tep_currency_exists($code) {

$code = tep_db_prepare_input($code);

 

$currency_code = tep_db_query("select currencies_id from " . TABLE_CURRENCIES . " where code = '" . tep_db_input($code) . "'");

if (tep_db_num_rows($currency_code)) {

return $code;

} else {

return false;

}

}

 

function tep_string_to_int($string) {

return (int)$string;

}

 

////

// Parse and secure the cPath parameter values

function tep_parse_category_path($cPath) {

// make sure the category IDs are integers

$cPath_array = array_map('tep_string_to_int', explode('_', $cPath));

 

// make sure no duplicate category IDs exist which could lock the server in a loop

$tmp_array = array();

$n = sizeof($cPath_array);

for ($i=0; $i<$n; $i++) {

if (!in_array($cPath_array[$i], $tmp_array)) {

$tmp_array[] = $cPath_array[$i];

}

}

 

return $tmp_array;

}

 

////

// Return a random value

function tep_rand($min = null, $max = null) {

static $seeded;

 

if (!isset($seeded)) {

mt_srand((double)microtime()*1000000);

$seeded = true;

}

 

if (isset($min) && isset($max)) {

if ($min >= $max) {

return $min;

} else {

return mt_rand($min, $max);

}

} else {

return mt_rand();

}

}

 

function tep_setcookie($name, $value = '', $expire = 0, $path = '/', $domain = '', $secure = 0) {

setcookie($name, $value, $expire, $path, (tep_not_null($domain) ? $domain : ''), $secure);

}

 

function tep_get_ip_address() {

if (isset($_SERVER)) {

if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {

$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];

} elseif (isset($_SERVER['HTTP_CLIENT_IP'])) {

$ip = $_SERVER['HTTP_CLIENT_IP'];

} else {

$ip = $_SERVER['REMOTE_ADDR'];

}

} else {

if (getenv('HTTP_X_FORWARDED_FOR')) {

$ip = getenv('HTTP_X_FORWARDED_FOR');

} elseif (getenv('HTTP_CLIENT_IP')) {

$ip = getenv('HTTP_CLIENT_IP');

} else {

$ip = getenv('REMOTE_ADDR');

}

}

 

return $ip;

}

 

function tep_count_customer_orders($id = '', $check_session = true) {

global $customer_id;

 

if (is_numeric($id) == false) {

if (tep_session_is_registered('customer_id')) {

$id = $customer_id;

} else {

return 0;

}

}

 

if ($check_session == true) {

if ( (tep_session_is_registered('customer_id') == false) || ($id != $customer_id) ) {

return 0;

}

}

 

$orders_check_query = tep_db_query("select count(*) as total from " . TABLE_ORDERS . " where customers_id = '" . (int)$id . "'");

$orders_check = tep_db_fetch_array($orders_check_query);

 

return $orders_check['total'];

}

 

function tep_count_customer_address_book_entries($id = '', $check_session = true) {

global $customer_id;

 

if (is_numeric($id) == false) {

if (tep_session_is_registered('customer_id')) {

$id = $customer_id;

} else {

return 0;

}

}

 

if ($check_session == true) {

if ( (tep_session_is_registered('customer_id') == false) || ($id != $customer_id) ) {

return 0;

}

}

 

$addresses_query = tep_db_query("select count(*) as total from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$id . "'");

$addresses = tep_db_fetch_array($addresses_query);

 

return $addresses['total'];

}

 

// nl2br() prior PHP 4.2.0 did not convert linefeeds on all OSs (it only converted \n)

function tep_convert_linefeeds($from, $to, $string) {

if ((PHP_VERSION < "4.0.5") && is_array($from)) {

return ereg_replace('(' . implode('|', $from) . ')', $to, $string);

} else {

return str_replace($from, $to, $string);

}

}

?>

Posted

Sorry, should have been more specific. The error you are getting indicates the admin/includes/functions/general.php file. You posted the catalog/includes/functions/general.php file.

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Posted
Sorry, should have been more specific.  The error you are getting indicates the admin/includes/functions/general.php file.  You posted the catalog/includes/functions/general.php file.

 

Jack

sorry is this any better ?

 

<?php

/*

$Id: general.php,v 1.160 2003/07/12 08:32:47 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

 

////

// Redirect to another page or site

function tep_redirect($url) {

global $logger;

 

header('Location: ' . $url);

 

if (STORE_PAGE_PARSE_TIME == 'true') {

if (!is_object($logger)) $logger = new logger;

$logger->timer_stop();

}

 

exit;

}

 

////

// Parse the data used in the html tags to ensure the tags will not break

function tep_parse_input_field_data($data, $parse) {

return strtr(trim($data), $parse);

}

 

function tep_output_string($string, $translate = false, $protected = false) {

if ($protected == true) {

return htmlspecialchars($string);

} else {

if ($translate == false) {

return tep_parse_input_field_data($string, array('"' => '"'));

} else {

return tep_parse_input_field_data($string, $translate);

}

}

}

 

function tep_output_string_protected($string) {

return tep_output_string($string, false, true);

}

 

function tep_sanitize_string($string) {

$string = ereg_replace(' +', ' ', $string);

 

return preg_replace("/[<>]/", '_', $string);

}

 

function tep_customers_name($customers_id) {

$customers = tep_db_query("select customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customers_id . "'");

$customers_values = tep_db_fetch_array($customers);

 

return $customers_values['customers_firstname'] . ' ' . $customers_values['customers_lastname'];

}

 

function tep_get_path($current_category_id = '') {

global $cPath_array;

 

if ($current_category_id == '') {

$cPath_new = implode('_', $cPath_array);

} else {

if (sizeof($cPath_array) == 0) {

$cPath_new = $current_category_id;

} else {

$cPath_new = '';

$last_category_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$cPath_array[(sizeof($cPath_array)-1)] . "'");

$last_category = tep_db_fetch_array($last_category_query);

 

$current_category_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'");

$current_category = tep_db_fetch_array($current_category_query);

 

if ($last_category['parent_id'] == $current_category['parent_id']) {

for ($i = 0, $n = sizeof($cPath_array) - 1; $i < $n; $i++) {

$cPath_new .= '_' . $cPath_array[$i];

}

} else {

for ($i = 0, $n = sizeof($cPath_array); $i < $n; $i++) {

$cPath_new .= '_' . $cPath_array[$i];

}

}

 

$cPath_new .= '_' . $current_category_id;

 

if (substr($cPath_new, 0, 1) == '_') {

$cPath_new = substr($cPath_new, 1);

}

}

}

 

return 'cPath=' . $cPath_new;

}

 

function tep_get_all_get_params($exclude_array = '') {

global $HTTP_GET_VARS;

 

if ($exclude_array == '') $exclude_array = array();

 

$get_url = '';

 

reset($HTTP_GET_VARS);

while (list($key, $value) = each($HTTP_GET_VARS)) {

if (($key != tep_session_name()) && ($key != 'error') && (!in_array($key, $exclude_array))) $get_url .= $key . '=' . $value . '&';

}

 

return $get_url;

}

 

function tep_date_long($raw_date) {

if ( ($raw_date == '0000-00-00 00:00:00') || ($raw_date == '') ) return false;

 

$year = (int)substr($raw_date, 0, 4);

$month = (int)substr($raw_date, 5, 2);

$day = (int)substr($raw_date, 8, 2);

$hour = (int)substr($raw_date, 11, 2);

$minute = (int)substr($raw_date, 14, 2);

$second = (int)substr($raw_date, 17, 2);

 

return strftime(DATE_FORMAT_LONG, mktime($hour, $minute, $second, $month, $day, $year));

}

 

////

// Output a raw date string in the selected locale date format

// $raw_date needs to be in this format: YYYY-MM-DD HH:MM:SS

// NOTE: Includes a workaround for dates before 01/01/1970 that fail on windows servers

function tep_date_short($raw_date) {

if ( ($raw_date == '0000-00-00 00:00:00') || ($raw_date == '') ) return false;

 

$year = substr($raw_date, 0, 4);

$month = (int)substr($raw_date, 5, 2);

$day = (int)substr($raw_date, 8, 2);

$hour = (int)substr($raw_date, 11, 2);

$minute = (int)substr($raw_date, 14, 2);

$second = (int)substr($raw_date, 17, 2);

 

if (@date('Y', mktime($hour, $minute, $second, $month, $day, $year)) == $year) {

return date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, $year));

} else {

return ereg_replace('2037' . '$', $year, date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, 2037)));

}

 

}

 

function tep_datetime_short($raw_datetime) {

if ( ($raw_datetime == '0000-00-00 00:00:00') || ($raw_datetime == '') ) return false;

 

$year = (int)substr($raw_datetime, 0, 4);

$month = (int)substr($raw_datetime, 5, 2);

$day = (int)substr($raw_datetime, 8, 2);

$hour = (int)substr($raw_datetime, 11, 2);

$minute = (int)substr($raw_datetime, 14, 2);

$second = (int)substr($raw_datetime, 17, 2);

 

return strftime(DATE_TIME_FORMAT, mktime($hour, $minute, $second, $month, $day, $year));

}

 

function tep_get_category_tree($parent_id = '0', $spacing = '', $exclude = '', $category_tree_array = '', $include_itself = false) {

global $languages_id;

 

if (!is_array($category_tree_array)) $category_tree_array = array();

if ( (sizeof($category_tree_array) < 1) && ($exclude != '0') ) $category_tree_array[] = array('id' => '0', 'text' => TEXT_TOP);

 

if ($include_itself) {

$category_query = tep_db_query("select cd.categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " cd where cd.language_id = '" . (int)$languages_id . "' and cd.categories_id = '" . (int)$parent_id . "'");

$category = tep_db_fetch_array($category_query);

$category_tree_array[] = array('id' => $parent_id, 'text' => $category['categories_name']);

}

 

$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and c.parent_id = '" . (int)$parent_id . "' order by c.sort_order, cd.categories_name");

while ($categories = tep_db_fetch_array($categories_query)) {

if ($exclude != $categories['categories_id']) $category_tree_array[] = array('id' => $categories['categories_id'], 'text' => $spacing . $categories['categories_name']);

$category_tree_array = tep_get_category_tree($categories['categories_id'], $spacing . '   ', $exclude, $category_tree_array);

}

 

return $category_tree_array;

}

 

function tep_draw_products_pull_down($name, $parameters = '', $exclude = '') {

global $currencies, $languages_id;

 

if ($exclude == '') {

$exclude = array();

}

 

$select_string = '<select name="' . $name . '"';

 

if ($parameters) {

$select_string .= ' ' . $parameters;

}

 

$select_string .= '>';

 

$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by products_name");

while ($products = tep_db_fetch_array($products_query)) {

if (!in_array($products['products_id'], $exclude)) {

$select_string .= '<option value="' . $products['products_id'] . '">' . $products['products_name'] . ' (' . $currencies->format($products['products_price']) . ')</option>';

}

}

 

$select_string .= '</select>';

 

return $select_string;

}

 

function tep_options_name($options_id) {

global $languages_id;

 

$options = tep_db_query("select products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$options_id . "' and language_id = '" . (int)$languages_id . "'");

$options_values = tep_db_fetch_array($options);

 

return $options_values['products_options_name'];

}

 

function tep_values_name($values_id) {

global $languages_id;

 

$values = tep_db_query("select products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . (int)$values_id . "' and language_id = '" . (int)$languages_id . "'");

$values_values = tep_db_fetch_array($values);

 

return $values_values['products_options_values_name'];

}

 

function tep_info_image($image, $alt, $width = '', $height = '') {

if (tep_not_null($image) && (file_exists(DIR_FS_CATALOG_IMAGES . $image)) ) {

$image = tep_image(DIR_WS_CATALOG_IMAGES . $image, $alt, $width, $height);

} else {

$image = TEXT_IMAGE_NONEXISTENT;

}

 

return $image;

}

 

function tep_break_string($string, $len, $break_char = '-') {

$l = 0;

$output = '';

for ($i=0, $n=strlen($string); $i<$n; $i++) {

$char = substr($string, $i, 1);

if ($char != ' ') {

$l++;

} else {

$l = 0;

}

if ($l > $len) {

$l = 1;

$output .= $break_char;

}

$output .= $char;

}

 

return $output;

}

 

function tep_get_country_name($country_id) {

$country_query = tep_db_query("select countries_name from " . TABLE_COUNTRIES . " where countries_id = '" . (int)$country_id . "'");

 

if (!tep_db_num_rows($country_query)) {

return $country_id;

} else {

$country = tep_db_fetch_array($country_query);

return $country['countries_name'];

}

}

 

function tep_get_zone_name($country_id, $zone_id, $default_zone) {

$zone_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country_id . "' and zone_id = '" . (int)$zone_id . "'");

if (tep_db_num_rows($zone_query)) {

$zone = tep_db_fetch_array($zone_query);

return $zone['zone_name'];

} else {

return $default_zone;

}

}

 

function tep_not_null($value) {

if (is_array($value)) {

if (sizeof($value) > 0) {

return true;

} else {

return false;

}

} else {

if ( (is_string($value) || is_int($value)) && ($value != '') && ($value != 'NULL') && (strlen(trim($value)) > 0)) {

return true;

} else {

return false;

}

}

}

 

function tep_browser_detect($component) {

global $HTTP_USER_AGENT;

 

return stristr($HTTP_USER_AGENT, $component);

}

 

function tep_tax_classes_pull_down($parameters, $selected = '') {

$select_string = '<select ' . $parameters . '>';

$classes_query = tep_db_query("select tax_class_id, tax_class_title from " . TABLE_TAX_CLASS . " order by tax_class_title");

while ($classes = tep_db_fetch_array($classes_query)) {

$select_string .= '<option value="' . $classes['tax_class_id'] . '"';

if ($selected == $classes['tax_class_id']) $select_string .= ' SELECTED';

$select_string .= '>' . $classes['tax_class_title'] . '</option>';

}

$select_string .= '</select>';

 

return $select_string;

}

 

function tep_geo_zones_pull_down($parameters, $selected = '') {

$select_string = '<select ' . $parameters . '>';

$zones_query = tep_db_query("select geo_zone_id, geo_zone_name from " . TABLE_GEO_ZONES . " order by geo_zone_name");

while ($zones = tep_db_fetch_array($zones_query)) {

$select_string .= '<option value="' . $zones['geo_zone_id'] . '"';

if ($selected == $zones['geo_zone_id']) $select_string .= ' SELECTED';

$select_string .= '>' . $zones['geo_zone_name'] . '</option>';

}

$select_string .= '</select>';

 

return $select_string;

}

 

function tep_get_geo_zone_name($geo_zone_id) {

$zones_query = tep_db_query("select geo_zone_name from " . TABLE_GEO_ZONES . " where geo_zone_id = '" . (int)$geo_zone_id . "'");

 

if (!tep_db_num_rows($zones_query)) {

$geo_zone_name = $geo_zone_id;

} else {

$zones = tep_db_fetch_array($zones_query);

$geo_zone_name = $zones['geo_zone_name'];

}

 

return $geo_zone_name;

}

 

function tep_address_format($address_format_id, $address, $html, $boln, $eoln) {

$address_format_query = tep_db_query("select address_format as format from " . TABLE_ADDRESS_FORMAT . " where address_format_id = '" . (int)$address_format_id . "'");

$address_format = tep_db_fetch_array($address_format_query);

 

$company = tep_output_string_protected($address['company']);

if (isset($address['firstname']) && tep_not_null($address['firstname'])) {

$firstname = tep_output_string_protected($address['firstname']);

$lastname = tep_output_string_protected($address['lastname']);

} elseif (isset($address['name']) && tep_not_null($address['name'])) {

$firstname = tep_output_string_protected($address['name']);

$lastname = '';

} else {

$firstname = '';

$lastname = '';

}

$street = tep_output_string_protected($address['street_address']);

$suburb = tep_output_string_protected($address['suburb']);

$city = tep_output_string_protected($address['city']);

$state = tep_output_string_protected($address['state']);

if (isset($address['country_id']) && tep_not_null($address['country_id'])) {

$country = tep_get_country_name($address['country_id']);

 

if (isset($address['zone_id']) && tep_not_null($address['zone_id'])) {

$state = tep_get_zone_code($address['country_id'], $address['zone_id'], $state);

}

} elseif (isset($address['country']) && tep_not_null($address['country'])) {

$country = tep_output_string_protected($address['country']);

} else {

$country = '';

}

$postcode = tep_output_string_protected($address['postcode']);

$zip = $postcode;

 

if ($html) {

// HTML Mode

$HR = '<hr>';

$hr = '<hr>';

if ( ($boln == '') && ($eoln == "\n") ) { // Values not specified, use rational defaults

$CR = '<br>';

$cr = '<br>';

$eoln = $cr;

} else { // Use values supplied

$CR = $eoln . $boln;

$cr = $CR;

}

} else {

// Text Mode

$CR = $eoln;

$cr = $CR;

$HR = '----------------------------------------';

$hr = '----------------------------------------';

}

 

$statecomma = '';

$streets = $street;

if ($suburb != '') $streets = $street . $cr . $suburb;

if ($country == '') $country = tep_output_string_protected($address['country']);

if ($state != '') $statecomma = $state . ', ';

 

$fmt = $address_format['format'];

eval("\$address = \"$fmt\";");

 

if ( (ACCOUNT_COMPANY == 'true') && (tep_not_null($company)) ) {

$address = $company . $cr . $address;

}

 

return $address;

}

 

////////////////////////////////////////////////////////////////////////////////////////////////

//

// Function : tep_get_zone_code

//

// Arguments : country country code string

// zone state/province zone_id

// def_state default string if zone==0

//

// Return : state_prov_code state/province code

//

// Description : Function to retrieve the state/province code (as in FL for Florida etc)

//

////////////////////////////////////////////////////////////////////////////////////////////////

function tep_get_zone_code($country, $zone, $def_state) {

 

$state_prov_query = tep_db_query("select zone_code from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' and zone_id = '" . (int)$zone . "'");

 

if (!tep_db_num_rows($state_prov_query)) {

$state_prov_code = $def_state;

}

else {

$state_prov_values = tep_db_fetch_array($state_prov_query);

$state_prov_code = $state_prov_values['zone_code'];

}

 

return $state_prov_code;

}

 

function tep_get_uprid($prid, $params) {

$uprid = $prid;

if ( (is_array($params)) && (!strstr($prid, '{')) ) {

while (list($option, $value) = each($params)) {

$uprid = $uprid . '{' . $option . '}' . $value;

}

}

 

return $uprid;

}

 

function tep_get_prid($uprid) {

$pieces = explode('{', $uprid);

 

return $pieces[0];

}

 

function tep_get_languages() {

$languages_query = tep_db_query("select languages_id, name, code, image, directory from " . TABLE_LANGUAGES . " order by sort_order");

while ($languages = tep_db_fetch_array($languages_query)) {

$languages_array[] = array('id' => $languages['languages_id'],

'name' => $languages['name'],

'code' => $languages['code'],

'image' => $languages['image'],

'directory' => $languages['directory']);

}

 

return $languages_array;

}

 

function tep_get_category_name($category_id, $language_id) {

$category_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$category_id . "' and language_id = '" . (int)$language_id . "'");

$category = tep_db_fetch_array($category_query);

 

return $category['categories_name'];

}

 

function tep_get_orders_status_name($orders_status_id, $language_id = '') {

global $languages_id;

 

if (!$language_id) $language_id = $languages_id;

$orders_status_query = tep_db_query("select orders_status_name from " . TABLE_ORDERS_STATUS . " where orders_status_id = '" . (int)$orders_status_id . "' and language_id = '" . (int)$language_id . "'");

$orders_status = tep_db_fetch_array($orders_status_query);

 

return $orders_status['orders_status_name'];

}

 

function tep_get_orders_status() {

global $languages_id;

 

$orders_status_array = array();

$orders_status_query = tep_db_query("select orders_status_id, orders_status_name from " . TABLE_ORDERS_STATUS . " where language_id = '" . (int)$languages_id . "' order by orders_status_id");

while ($orders_status = tep_db_fetch_array($orders_status_query)) {

$orders_status_array[] = array('id' => $orders_status['orders_status_id'],

'text' => $orders_status['orders_status_name']);

}

 

return $orders_status_array;

}

 

function tep_get_products_name($product_id, $language_id = 0) {

global $languages_id;

 

if ($language_id == 0) $language_id = $languages_id;

$product_query = tep_db_query("select products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'");

$product = tep_db_fetch_array($product_query);

 

return $product['products_name'];

}

 

function tep_get_products_description($product_id, $language_id) {

$product_query = tep_db_query("select products_description from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'");

$product = tep_db_fetch_array($product_query);

 

return $product['products_description'];

}

function tep_get_products_head_title_tag($product_id, $language_id) {

$product_query = tep_db_query("select products_head_title_tag from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'");

$product = tep_db_fetch_array($product_query);

 

return $product['products_head_title_tag'];

}

 

function tep_get_products_head_desc_tag($product_id, $language_id) {

$product_query = tep_db_query("select products_head_desc_tag from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'");

$product = tep_db_fetch_array($product_query);

 

return $product['products_head_desc_tag'];

}

 

function tep_get_products_head_keywords_tag($product_id, $language_id) {

$product_query = tep_db_query("select products_head_keywords_tag from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'");

$product = tep_db_fetch_array($product_query);

 

return $product['products_head_keywords_tag'];

}

 

 

 

// BoF Header Tag Controller

function tep_get_products_head_title_tag($product_id, $language_id) {

$product_query = tep_db_query("select products_head_title_tag from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'");

$product = tep_db_fetch_array($product_query);

 

return $product['products_head_title_tag'];

}

 

function tep_get_products_head_desc_tag($product_id, $language_id) {

$product_query = tep_db_query("select products_head_desc_tag from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'");

$product = tep_db_fetch_array($product_query);

 

return $product['products_head_desc_tag'];

}

 

function tep_get_products_head_keywords_tag($product_id, $language_id) {

$product_query = tep_db_query("select products_head_keywords_tag from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'");

$product = tep_db_fetch_array($product_query);

 

return $product['products_head_keywords_tag'];

}

// EoF Header Tag Controller

 

 

function tep_get_products_url($product_id, $language_id) {

$product_query = tep_db_query("select products_url from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'");

$product = tep_db_fetch_array($product_query);

 

return $product['products_url'];

}

 

////

// Return the manufacturers URL in the needed language

// TABLES: manufacturers_info

function tep_get_manufacturer_url($manufacturer_id, $language_id) {

$manufacturer_query = tep_db_query("select manufacturers_url 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['manufacturers_url'];

}

 

////

// Wrapper for class_exists() function

// This function is not available in all PHP versions so we test it before using it.

function tep_class_exists($class_name) {

if (function_exists('class_exists')) {

return class_exists($class_name);

} else {

return true;

}

}

 

////

// Count how many products exist in a category

// TABLES: products, products_to_categories, categories

function tep_products_in_category_count($categories_id, $include_deactivated = false) {

$products_count = 0;

 

if ($include_deactivated) {

$products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$categories_id . "'");

} else {

$products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p.products_status = '1' and p2c.categories_id = '" . (int)$categories_id . "'");

}

 

$products = tep_db_fetch_array($products_query);

 

$products_count += $products['total'];

 

$childs_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$categories_id . "'");

if (tep_db_num_rows($childs_query)) {

while ($childs = tep_db_fetch_array($childs_query)) {

$products_count += tep_products_in_category_count($childs['categories_id'], $include_deactivated);

}

}

 

return $products_count;

}

 

////

// Count how many subcategories exist in a category

// TABLES: categories

function tep_childs_in_category_count($categories_id) {

$categories_count = 0;

 

$categories_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$categories_id . "'");

while ($categories = tep_db_fetch_array($categories_query)) {

$categories_count++;

$categories_count += tep_childs_in_category_count($categories['categories_id']);

}

 

return $categories_count;

}

 

////

// Returns an array with countries

// TABLES: countries

function tep_get_countries($default = '') {

$countries_array = array();

if ($default) {

$countries_array[] = array('id' => '',

'text' => $default);

}

$countries_query = tep_db_query("select countries_id, countries_name from " . TABLE_COUNTRIES . " order by countries_name");

while ($countries = tep_db_fetch_array($countries_query)) {

$countries_array[] = array('id' => $countries['countries_id'],

'text' => $countries['countries_name']);

}

 

return $countries_array;

}

 

////

// return an array with country zones

function tep_get_country_zones($country_id) {

$zones_array = array();

$zones_query = tep_db_query("select zone_id, zone_name from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country_id . "' order by zone_name");

while ($zones = tep_db_fetch_array($zones_query)) {

$zones_array[] = array('id' => $zones['zone_id'],

'text' => $zones['zone_name']);

}

 

return $zones_array;

}

 

function tep_prepare_country_zones_pull_down($country_id = '') {

// preset the width of the drop-down for Netscape

$pre = '';

if ( (!tep_browser_detect('MSIE')) && (tep_browser_detect('Mozilla/4')) ) {

for ($i=0; $i<45; $i++) $pre .= ' ';

}

 

$zones = tep_get_country_zones($country_id);

 

if (sizeof($zones) > 0) {

$zones_select = array(array('id' => '', 'text' => PLEASE_SELECT));

$zones = array_merge($zones_select, $zones);

} else {

$zones = array(array('id' => '', 'text' => TYPE_BELOW));

// create dummy options for Netscape to preset the height of the drop-down

if ( (!tep_browser_detect('MSIE')) && (tep_browser_detect('Mozilla/4')) ) {

for ($i=0; $i<9; $i++) {

$zones[] = array('id' => '', 'text' => $pre);

}

}

}

 

return $zones;

}

 

////

// Get list of address_format_id's

function tep_get_address_formats() {

$address_format_query = tep_db_query("select address_format_id from " . TABLE_ADDRESS_FORMAT . " order by address_format_id");

$address_format_array = array();

while ($address_format_values = tep_db_fetch_array($address_format_query)) {

$address_format_array[] = array('id' => $address_format_values['address_format_id'],

'text' => $address_format_values['address_format_id']);

}

return $address_format_array;

}

 

////

// Alias function for Store configuration values in the Administration Tool

function tep_cfg_pull_down_country_list($country_id) {

return tep_draw_pull_down_menu('configuration_value', tep_get_countries(), $country_id);

}

 

function tep_cfg_pull_down_zone_list($zone_id) {

return tep_draw_pull_down_menu('configuration_value', tep_get_country_zones(STORE_COUNTRY), $zone_id);

}

 

function tep_cfg_pull_down_tax_classes($tax_class_id, $key = '') {

$name = (($key) ? 'configuration[' . $key . ']' : 'configuration_value');

 

$tax_class_array = array(array('id' => '0', 'text' => TEXT_NONE));

$tax_class_query = tep_db_query("select tax_class_id, tax_class_title from " . TABLE_TAX_CLASS . " order by tax_class_title");

while ($tax_class = tep_db_fetch_array($tax_class_query)) {

$tax_class_array[] = array('id' => $tax_class['tax_class_id'],

'text' => $tax_class['tax_class_title']);

}

 

return tep_draw_pull_down_menu($name, $tax_class_array, $tax_class_id);

}

 

////

// Function to read in text area in admin

function tep_cfg_textarea($text) {

return tep_draw_textarea_field('configuration_value', false, 35, 5, $text);

}

 

function tep_cfg_get_zone_name($zone_id) {

$zone_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_id = '" . (int)$zone_id . "'");

 

if (!tep_db_num_rows($zone_query)) {

return $zone_id;

} else {

$zone = tep_db_fetch_array($zone_query);

return $zone['zone_name'];

}

}

 

////

// Sets the status of a banner

function tep_set_banner_status($banners_id, $status) {

if ($status == '1') {

return tep_db_query("update " . TABLE_BANNERS . " set status = '1', expires_impressions = NULL, expires_date = NULL, date_status_change = NULL where banners_id = '" . $banners_id . "'");

} elseif ($status == '0') {

return tep_db_query("update " . TABLE_BANNERS . " set status = '0', date_status_change = now() where banners_id = '" . $banners_id . "'");

} else {

return -1;

}

}

 

////

// Sets the status of a product

function tep_set_product_status($products_id, $status) {

if ($status == '1') {

return tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '1', products_last_modified = now() where products_id = '" . (int)$products_id . "'");

} elseif ($status == '0') {

return tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0', products_last_modified = now() where products_id = '" . (int)$products_id . "'");

} else {

return -1;

}

}

 

////

// Sets the status of a product on special

function tep_set_specials_status($specials_id, $status) {

if ($status == '1') {

return tep_db_query("update " . TABLE_SPECIALS . " set status = '1', expires_date = NULL, date_status_change = NULL where specials_id = '" . (int)$specials_id . "'");

} elseif ($status == '0') {

return tep_db_query("update " . TABLE_SPECIALS . " set status = '0', date_status_change = now() where specials_id = '" . (int)$specials_id . "'");

} else {

return -1;

}

}

 

////

// Sets timeout for the current script.

// Cant be used in safe mode.

function tep_set_time_limit($limit) {

if (!get_cfg_var('safe_mode')) {

set_time_limit($limit);

}

}

 

////

// Alias function for Store configuration values in the Administration Tool

function tep_cfg_select_option($select_array, $key_value, $key = '') {

$string = '';

 

for ($i=0, $n=sizeof($select_array); $i<$n; $i++) {

$name = ((tep_not_null($key)) ? 'configuration[' . $key . ']' : 'configuration_value');

 

$string .= '<br><input type="radio" name="' . $name . '" value="' . $select_array[$i] . '"';

 

if ($key_value == $select_array[$i]) $string .= ' CHECKED';

 

$string .= '> ' . $select_array[$i];

}

 

return $string;

}

 

////

// Alias function for module configuration keys

function tep_mod_select_option($select_array, $key_name, $key_value) {

reset($select_array);

while (list($key, $value) = each($select_array)) {

if (is_int($key)) $key = $value;

$string .= '<br><input type="radio" name="configuration[' . $key_name . ']" value="' . $key . '"';

if ($key_value == $key) $string .= ' CHECKED';

$string .= '> ' . $value;

}

 

return $string;

}

 

////

// Retreive server information

function tep_get_system_information() {

global $HTTP_SERVER_VARS;

 

$db_query = tep_db_query("select now() as datetime");

$db = tep_db_fetch_array($db_query);

 

list($system, $host, $kernel) = preg_split('/[\s,]+/', @exec('uname -a'), 5);

 

return array('date' => tep_datetime_short(date('Y-m-d H:i:s')),

'system' => $system,

'kernel' => $kernel,

'host' => $host,

'ip' => gethostbyname($host),

'uptime' => @exec('uptime'),

'http_server' => $HTTP_SERVER_VARS['SERVER_SOFTWARE'],

'php' => PHP_VERSION,

'zend' => (function_exists('zend_version') ? zend_version() : ''),

'db_server' => DB_SERVER,

'db_ip' => gethostbyname(DB_SERVER),

'db_version' => 'MySQL ' . (function_exists('mysql_get_server_info') ? mysql_get_server_info() : ''),

'db_date' => tep_datetime_short($db['datetime']));

}

 

function tep_generate_category_path($id, $from = 'category', $categories_array = '', $index = 0) {

global $languages_id;

 

if (!is_array($categories_array)) $categories_array = array();

 

if ($from == 'product') {

$categories_query = tep_db_query("select categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$id . "'");

while ($categories = tep_db_fetch_array($categories_query)) {

if ($categories['categories_id'] == '0') {

$categories_array[$index][] = array('id' => '0', 'text' => TEXT_TOP);

} else {

$category_query = tep_db_query("select cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$categories['categories_id'] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "'");

$category = tep_db_fetch_array($category_query);

$categories_array[$index][] = array('id' => $categories['categories_id'], 'text' => $category['categories_name']);

if ( (tep_not_null($category['parent_id'])) && ($category['parent_id'] != '0') ) $categories_array = tep_generate_category_path($category['parent_id'], 'category', $categories_array, $index);

$categories_array[$index] = array_reverse($categories_array[$index]);

}

$index++;

}

} elseif ($from == 'category') {

$category_query = tep_db_query("select cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "'");

$category = tep_db_fetch_array($category_query);

$categories_array[$index][] = array('id' => $id, 'text' => $category['categories_name']);

if ( (tep_not_null($category['parent_id'])) && ($category['parent_id'] != '0') ) $categories_array = tep_generate_category_path($category['parent_id'], 'category', $categories_array, $index);

}

 

return $categories_array;

}

 

function tep_output_generated_category_path($id, $from = 'category') {

$calculated_category_path_string = '';

$calculated_category_path = tep_generate_category_path($id, $from);

for ($i=0, $n=sizeof($calculated_category_path); $i<$n; $i++) {

for ($j=0, $k=sizeof($calculated_category_path[$i]); $j<$k; $j++) {

$calculated_category_path_string .= $calculated_category_path[$i][$j]['text'] . ' > ';

}

$calculated_category_path_string = substr($calculated_category_path_string, 0, -16) . '<br>';

}

$calculated_category_path_string = substr($calculated_category_path_string, 0, -4);

 

if (strlen($calculated_category_path_string) < 1) $calculated_category_path_string = TEXT_TOP;

 

return $calculated_category_path_string;

}

 

function tep_get_generated_category_path_ids($id, $from = 'category') {

$calculated_category_path_string = '';

$calculated_category_path = tep_generate_category_path($id, $from);

for ($i=0, $n=sizeof($calculated_category_path); $i<$n; $i++) {

for ($j=0, $k=sizeof($calculated_category_path[$i]); $j<$k; $j++) {

$calculated_category_path_string .= $calculated_category_path[$i][$j]['id'] . '_';

}

$calculated_category_path_string = substr($calculated_category_path_string, 0, -1) . '<br>';

}

$calculated_category_path_string = substr($calculated_category_path_string, 0, -4);

 

if (strlen($calculated_category_path_string) < 1) $calculated_category_path_string = TEXT_TOP;

 

return $calculated_category_path_string;

}

 

function tep_remove_category($category_id) {

$category_image_query = tep_db_query("select categories_image from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$category_id . "'");

$category_image = tep_db_fetch_array($category_image_query);

 

$duplicate_image_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " where categories_image = '" . tep_db_input($category_image['categories_image']) . "'");

$duplicate_image = tep_db_fetch_array($duplicate_image_query);

 

if ($duplicate_image['total'] < 2) {

if (file_exists(DIR_FS_CATALOG_IMAGES . $category_image['categories_image'])) {

@unlink(DIR_FS_CATALOG_IMAGES . $category_image['categories_image']);

}

}

 

tep_db_query("delete from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$category_id . "'");

tep_db_query("delete from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$category_id . "'");

tep_db_query("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int)$category_id . "'");

 

if (USE_CACHE == 'true') {

tep_reset_cache_block('categories');

tep_reset_cache_block('also_purchased');

}

}

 

function tep_remove_product($product_id) {

$product_image_query = tep_db_query("select products_image from " . TABLE_PRODUCTS . " where products_id = '" . (int)$product_id . "'");

$product_image = tep_db_fetch_array($product_image_query);

 

$duplicate_image_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " where products_image = '" . tep_db_input($product_image['products_image']) . "'");

$duplicate_image = tep_db_fetch_array($duplicate_image_query);

 

if ($duplicate_image['total'] < 2) {

if (file_exists(DIR_FS_CATALOG_IMAGES . $product_image['products_image'])) {

@unlink(DIR_FS_CATALOG_IMAGES . $product_image['products_image']);

}

}

 

tep_db_query("delete from " . TABLE_SPECIALS . " where products_id = '" . (int)$product_id . "'");

tep_db_query("delete from " . TABLE_PRODUCTS . " where products_id = '" . (int)$product_id . "'");

tep_db_query("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$product_id . "'");

tep_db_query("delete from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "'");

tep_db_query("delete from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$product_id . "'");

tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where products_id = '" . (int)$product_id . "'");

tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where products_id = '" . (int)$product_id . "'");

 

$product_reviews_query = tep_db_query("select reviews_id from " . TABLE_REVIEWS . " where products_id = '" . (int)$product_id . "'");

while ($product_reviews = tep_db_fetch_array($product_reviews_query)) {

tep_db_query("delete from " . TABLE_REVIEWS_DESCRIPTION . " where reviews_id = '" . (int)$product_reviews['reviews_id'] . "'");

}

tep_db_query("delete from " . TABLE_REVIEWS . " where products_id = '" . (int)$product_id . "'");

 

if (USE_CACHE == 'true') {

tep_reset_cache_block('categories');

tep_reset_cache_block('also_purchased');

}

}

 

function tep_remove_order($order_id, $restock = false) {

if ($restock == 'on') {

$order_query = tep_db_query("select products_id, products_quantity from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "'");

while ($order = tep_db_fetch_array($order_query)) {

tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = products_quantity + " . $order['products_quantity'] . ", products_ordered = products_ordered - " . $order['products_quantity'] . " where products_id = '" . (int)$order['products_id'] . "'");

}

}

 

tep_db_query("delete from " . TABLE_ORDERS . " where orders_id = '" . (int)$order_id . "'");

tep_db_query("delete from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "'");

tep_db_query("delete from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$order_id . "'");

tep_db_query("delete from " . TABLE_ORDERS_STATUS_HISTORY . " where orders_id = '" . (int)$order_id . "'");

tep_db_query("delete from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "'");

}

 

function tep_reset_cache_block($cache_block) {

global $cache_blocks;

 

for ($i=0, $n=sizeof($cache_blocks); $i<$n; $i++) {

if ($cache_blocks[$i]['code'] == $cache_block) {

if ($cache_blocks[$i]['multiple']) {

if ($dir = @opendir(DIR_FS_CACHE)) {

while ($cache_file = readdir($dir)) {

$cached_file = $cache_blocks[$i]['file'];

$languages = tep_get_languages();

for ($j=0, $k=sizeof($languages); $j<$k; $j++) {

$cached_file_unlink = ereg_replace('-language', '-' . $languages[$j]['directory'], $cached_file);

if (ereg('^' . $cached_file_unlink, $cache_file)) {

@unlink(DIR_FS_CACHE . $cache_file);

}

}

}

closedir($dir);

}

} else {

$cached_file = $cache_blocks[$i]['file'];

$languages = tep_get_languages();

for ($i=0, $n=sizeof($languages); $i<$n; $i++) {

$cached_file = ereg_replace('-language', '-' . $languages[$i]['directory'], $cached_file);

@unlink(DIR_FS_CACHE . $cached_file);

}

}

break;

}

}

}

 

function tep_get_file_permissions($mode) {

// determine type

if ( ($mode & 0xC000) == 0xC000) { // unix domain socket

$type = 's';

} elseif ( ($mode & 0x4000) == 0x4000) { // directory

$type = 'd';

} elseif ( ($mode & 0xA000) == 0xA000) { // symbolic link

$type = 'l';

} elseif ( ($mode & 0x8000) == 0x8000) { // regular file

$type = '-';

} elseif ( ($mode & 0x6000) == 0x6000) { //bBlock special file

$type = 'b';

} elseif ( ($mode & 0x2000) == 0x2000) { // character special file

$type = 'c';

} elseif ( ($mode & 0x1000) == 0x1000) { // named pipe

$type = 'p';

} else { // unknown

$type = '?';

}

 

// determine permissions

$owner['read'] = ($mode & 00400) ? 'r' : '-';

$owner['write'] = ($mode & 00200) ? 'w' : '-';

$owner['execute'] = ($mode & 00100) ? 'x' : '-';

$group['read'] = ($mode & 00040) ? 'r' : '-';

$group['write'] = ($mode & 00020) ? 'w' : '-';

$group['execute'] = ($mode & 00010) ? 'x' : '-';

$world['read'] = ($mode & 00004) ? 'r' : '-';

$world['write'] = ($mode & 00002) ? 'w' : '-';

$world['execute'] = ($mode & 00001) ? 'x' : '-';

 

// adjust for SUID, SGID and sticky bit

if ($mode & 0x800 ) $owner['execute'] = ($owner['execute'] == 'x') ? 's' : 'S';

if ($mode & 0x400 ) $group['execute'] = ($group['execute'] == 'x') ? 's' : 'S';

if ($mode & 0x200 ) $world['execute'] = ($world['execute'] == 'x') ? 't' : 'T';

 

return $type .

$owner['read'] . $owner['write'] . $owner['execute'] .

$group['read'] . $group['write'] . $group['execute'] .

$world['read'] . $world['write'] . $world['execute'];

}

 

function tep_remove($source) {

global $messageStack, $tep_remove_error;

 

if (isset($tep_remove_error)) $tep_remove_error = false;

 

if (is_dir($source)) {

$dir = dir($source);

while ($file = $dir->read()) {

if ( ($file != '.') && ($file != '..') ) {

if (is_writeable($source . '/' . $file)) {

tep_remove($source . '/' . $file);

} else {

$messageStack->add(sprintf(ERROR_FILE_NOT_REMOVEABLE, $source . '/' . $file), 'error');

$tep_remove_error = true;

}

}

}

$dir->close();

 

if (is_writeable($source)) {

rmdir($source);

} else {

$messageStack->add(sprintf(ERROR_DIRECTORY_NOT_REMOVEABLE, $source), 'error');

$tep_remove_error = true;

}

} else {

if (is_writeable($source)) {

unlink($source);

} else {

$messageStack->add(sprintf(ERROR_FILE_NOT_REMOVEABLE, $source), 'error');

$tep_remove_error = true;

}

}

}

 

////

// Output the tax percentage with optional padded decimals

function tep_display_tax_value($value, $padding = TAX_DECIMAL_PLACES) {

if (strpos($value, '.')) {

$loop = true;

while ($loop) {

if (substr($value, -1) == '0') {

$value = substr($value, 0, -1);

} else {

$loop = false;

if (substr($value, -1) == '.') {

$value = substr($value, 0, -1);

}

}

}

}

 

if ($padding > 0) {

if ($decimal_pos = strpos($value, '.')) {

$decimals = strlen(substr($value, ($decimal_pos+1)));

for ($i=$decimals; $i<$padding; $i++) {

$value .= '0';

}

} else {

$value .= '.';

for ($i=0; $i<$padding; $i++) {

$value .= '0';

}

}

}

 

return $value;

}

 

function tep_mail($to_name, $to_email_address, $email_subject, $email_text, $from_email_name, $from_email_address) {

if (SEND_EMAILS != 'true') return false;

 

// Instantiate a new mail object

$message = new email(array('X-Mailer: osCommerce'));

 

// Build the text version

$text = strip_tags($email_text);

if (EMAIL_USE_HTML == 'true') {

$message->add_html($email_text, $text);

} else {

$message->add_text($text);

}

 

// Send message

$message->build_message();

$message->send($to_name, $to_email_address, $from_email_name, $from_email_address, $email_subject);

}

 

function tep_get_tax_class_title($tax_class_id) {

if ($tax_class_id == '0') {

return TEXT_NONE;

} else {

$classes_query = tep_db_query("selec

Posted

At line 514, you have:

  function tep_get_products_head_title_tag($product_id, $language_id) {

    $product_query = tep_db_query("select products_head_title_tag from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'");

    $product = tep_db_fetch_array($product_query);

 

    return $product['products_head_title_tag'];

  }

And at line 538 you have:

function tep_get_products_head_title_tag($product_id, $language_id) {

    $product_query = tep_db_query("select products_head_title_tag from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'");

    $product = tep_db_fetch_array($product_query);

 

    return $product['products_head_title_tag'];

  }

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Posted
At line 514, you have:

 

And at line 538 you have:

 

Jack

thankyou jack ,Ive deleted the duplicated lines ,my admin works now but when I click on CONTENTS I get the following error

 

Parse error: parse error, unexpected T_DOUBLE_ARROW in /home/madgad00/public_html/admin/categories.php on line 257

 

Heres a snippet of the code starting at line 257

 

 

'products_head_title_tag' => tep_db_prepare_input($HTTP_POST_VARS['products_head_title_tag'][$language_id]), 'products_head_desc_tag' => tep_db_prepare_input($HTTP_POST_VARS['products_head_desc_tag'][$language_id]), 'products_head_keywords_tag' => tep_db_prepare_input($HTTP_POST_VARS['products_head_keywords_tag'][$language_id]));

// EoF Header Tag Controller

 

if ($action == 'insert_product') {

$insert_sql_data = array('products_id' => $products_id,

'language_id' => $language_id);

 

$sql_data_array = array_merge($sql_data_array, $insert_sql_data);

 

tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array);

 

thankyou for your valuable help

Posted

I would suspect that the line before it ends in ])); but I can't tell without seeing the code. You obviousy have a lot of problems in your code. I wouldn't trust it at this point. You would be better advised to start over or you may end up with some strange problem you can't isolate at some point.

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Posted
I would suspect that the line before it ends in ])); but I can't tell without seeing the code.  You obviousy have a lot of problems in your code.  I wouldn't trust it at this point.  You would be better advised to start over or you may end up with some strange problem you can't isolate at some point.

 

Jack

 

Thanks ,This is the 3rd time ive tried to install it ,I just keep getting problems lol,

heres the full code

 

<?php

/*

$Id: categories.php,v 1.146 2003/07/11 14:40:27 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

 

require('includes/application_top.php');

 

require(DIR_WS_CLASSES . 'currencies.php');

$currencies = new currencies();

 

$action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');

 

if (tep_not_null($action)) {

switch ($action) {

case 'setflag':

if ( ($HTTP_GET_VARS['flag'] == '0') || ($HTTP_GET_VARS['flag'] == '1') ) {

if (isset($HTTP_GET_VARS['pID'])) {

tep_set_product_status($HTTP_GET_VARS['pID'], $HTTP_GET_VARS['flag']);

}

 

if (USE_CACHE == 'true') {

tep_reset_cache_block('categories');

tep_reset_cache_block('also_purchased');

}

}

 

tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $HTTP_GET_VARS['cPath'] . '&pID=' . $HTTP_GET_VARS['pID']));

break;

case 'insert_category':

case 'update_category':

if (isset($HTTP_POST_VARS['categories_id'])) $categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']);

$sort_order = tep_db_prepare_input($HTTP_POST_VARS['sort_order']);

 

$sql_data_array = array('sort_order' => $sort_order);

 

if ($action == 'insert_category') {

$insert_sql_data = array('parent_id' => $current_category_id,

'date_added' => 'now()');

 

$sql_data_array = array_merge($sql_data_array, $insert_sql_data);

 

tep_db_perform(TABLE_CATEGORIES, $sql_data_array);

 

$categories_id = tep_db_insert_id();

} elseif ($action == 'update_category') {

$update_sql_data = array('last_modified' => 'now()');

 

$sql_data_array = array_merge($sql_data_array, $update_sql_data);

 

tep_db_perform(TABLE_CATEGORIES, $sql_data_array, 'update', "categories_id = '" . (int)$categories_id . "'");

}

 

$languages = tep_get_languages();

for ($i=0, $n=sizeof($languages); $i<$n; $i++) {

$categories_name_array = $HTTP_POST_VARS['categories_name'];

 

$language_id = $languages[$i]['id'];

 

$sql_data_array = array('categories_name' => tep_db_prepare_input($categories_name_array[$language_id]));

 

if ($action == 'insert_category') {

$insert_sql_data = array('categories_id' => $categories_id,

'language_id' => $languages[$i]['id']);

 

$sql_data_array = array_merge($sql_data_array, $insert_sql_data);

 

tep_db_perform(TABLE_CATEGORIES_DESCRIPTION, $sql_data_array);

} elseif ($action == 'update_category') {

tep_db_perform(TABLE_CATEGORIES_DESCRIPTION, $sql_data_array, 'update', "categories_id = '" . (int)$categories_id . "' and language_id = '" . (int)$languages[$i]['id'] . "'");

}

}

 

if ($categories_image = new upload('categories_image', DIR_FS_CATALOG_IMAGES)) {

tep_db_query("update " . TABLE_CATEGORIES . " set categories_image = '" . tep_db_input($categories_image->filename) . "' where categories_id = '" . (int)$categories_id . "'");

}

 

if (USE_CACHE == 'true') {

tep_reset_cache_block('categories');

tep_reset_cache_block('also_purchased');

}

 

tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $categories_id));

break;

case 'delete_category_confirm':

if (isset($HTTP_POST_VARS['categories_id'])) {

$categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']);

 

$categories = tep_get_category_tree($categories_id, '', '0', '', true);

$products = array();

$products_delete = array();

 

for ($i=0, $n=sizeof($categories); $i<$n; $i++) {

$product_ids_query = tep_db_query("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int)$categories[$i]['id'] . "'");

 

while ($product_ids = tep_db_fetch_array($product_ids_query)) {

$products[$product_ids['products_id']]['categories'][] = $categories[$i]['id'];

}

}

 

reset($products);

while (list($key, $value) = each($products)) {

$category_ids = '';

 

for ($i=0, $n=sizeof($value['categories']); $i<$n; $i++) {

$category_ids .= "'" . (int)$value['categories'][$i] . "', ";

}

$category_ids = substr($category_ids, 0, -2);

 

$check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$key . "' and categories_id not in (" . $category_ids . ")");

$check = tep_db_fetch_array($check_query);

if ($check['total'] < '1') {

$products_delete[$key] = $key;

}

}

 

// removing categories can be a lengthy process

tep_set_time_limit(0);

for ($i=0, $n=sizeof($categories); $i<$n; $i++) {

tep_remove_category($categories[$i]['id']);

}

 

reset($products_delete);

while (list($key) = each($products_delete)) {

tep_remove_product($key);

}

}

 

if (USE_CACHE == 'true') {

tep_reset_cache_block('categories');

tep_reset_cache_block('also_purchased');

}

 

tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath));

break;

case 'delete_product_confirm':

if (isset($HTTP_POST_VARS['products_id']) && isset($HTTP_POST_VARS['product_categories']) && is_array($HTTP_POST_VARS['product_categories'])) {

$product_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']);

$product_categories = $HTTP_POST_VARS['product_categories'];

 

for ($i=0, $n=sizeof($product_categories); $i<$n; $i++) {

tep_db_query("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$product_id . "' and categories_id = '" . (int)$product_categories[$i] . "'");

}

 

$product_categories_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$product_id . "'");

$product_categories = tep_db_fetch_array($product_categories_query);

 

if ($product_categories['total'] == '0') {

tep_remove_product($product_id);

}

}

 

if (USE_CACHE == 'true') {

tep_reset_cache_block('categories');

tep_reset_cache_block('also_purchased');

}

 

tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath));

break;

case 'move_category_confirm':

if (isset($HTTP_POST_VARS['categories_id']) && ($HTTP_POST_VARS['categories_id'] != $HTTP_POST_VARS['move_to_category_id'])) {

$categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']);

$new_parent_id = tep_db_prepare_input($HTTP_POST_VARS['move_to_category_id']);

 

$path = explode('_', tep_get_generated_category_path_ids($new_parent_id));

 

if (in_array($categories_id, $path)) {

$messageStack->add_session(ERROR_CANNOT_MOVE_CATEGORY_TO_PARENT, 'error');

 

tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $categories_id));

} else {

tep_db_query("update " . TABLE_CATEGORIES . " set parent_id = '" . (int)$new_parent_id . "', last_modified = now() where categories_id = '" . (int)$categories_id . "'");

 

if (USE_CACHE == 'true') {

tep_reset_cache_block('categories');

tep_reset_cache_block('also_purchased');

}

 

tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $new_parent_id . '&cID=' . $categories_id));

}

}

 

break;

case 'move_product_confirm':

$products_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']);

$new_parent_id = tep_db_prepare_input($HTTP_POST_VARS['move_to_category_id']);

 

$duplicate_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$products_id . "' and categories_id = '" . (int)$new_parent_id . "'");

$duplicate_check = tep_db_fetch_array($duplicate_check_query);

if ($duplicate_check['total'] < 1) tep_db_query("update " . TABLE_PRODUCTS_TO_CATEGORIES . " set categories_id = '" . (int)$new_parent_id . "' where products_id = '" . (int)$products_id . "' and categories_id = '" . (int)$current_category_id . "'");

 

if (USE_CACHE == 'true') {

tep_reset_cache_block('categories');

tep_reset_cache_block('also_purchased');

}

 

tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $new_parent_id . '&pID=' . $products_id));

break;

case 'insert_product':

case 'update_product':

if (isset($HTTP_POST_VARS['edit_x']) || isset($HTTP_POST_VARS['edit_y'])) {

$action = 'new_product';

} else {

if (isset($HTTP_GET_VARS['pID'])) $products_id = tep_db_prepare_input($HTTP_GET_VARS['pID']);

$products_date_available = tep_db_prepare_input($HTTP_POST_VARS['products_date_available']);

 

$products_date_available = (date('Y-m-d') < $products_date_available) ? $products_date_available : 'null';

 

$sql_data_array = array('products_quantity' => tep_db_prepare_input($HTTP_POST_VARS['products_quantity']),

'products_model' => tep_db_prepare_input($HTTP_POST_VARS['products_model']),

'products_price' => tep_db_prepare_input($HTTP_POST_VARS['products_price']),

'products_date_available' => $products_date_available,

'products_weight' => tep_db_prepare_input($HTTP_POST_VARS['products_weight']),

'products_status' => tep_db_prepare_input($HTTP_POST_VARS['products_status']),

'products_tax_class_id' => tep_db_prepare_input($HTTP_POST_VARS['products_tax_class_id']),

'manufacturers_id' => tep_db_prepare_input($HTTP_POST_VARS['manufacturers_id']));

 

if (isset($HTTP_POST_VARS['products_image']) && tep_not_null($HTTP_POST_VARS['products_image']) && ($HTTP_POST_VARS['products_image'] != 'none')) {

$sql_data_array['products_image'] = tep_db_prepare_input($HTTP_POST_VARS['products_image']);

}

 

if ($action == 'insert_product') {

$insert_sql_data = array('products_date_added' => 'now()');

 

$sql_data_array = array_merge($sql_data_array, $insert_sql_data);

 

tep_db_perform(TABLE_PRODUCTS, $sql_data_array);

$products_id = tep_db_insert_id();

 

tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$products_id . "', '" . (int)$current_category_id . "')");

} elseif ($action == 'update_product') {

$update_sql_data = array('products_last_modified' => 'now()');

 

$sql_data_array = array_merge($sql_data_array, $update_sql_data);

 

tep_db_perform(TABLE_PRODUCTS, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "'");

}

 

$languages = tep_get_languages();

for ($i=0, $n=sizeof($languages); $i<$n; $i++) {

$language_id = $languages[$i]['id'];

 

$sql_data_array = array('products_name' => tep_db_prepare_input($HTTP_POST_VARS['products_name'][$language_id]),

'products_description' => tep_db_prepare_input($HTTP_POST_VARS['products_description'][$language_id]),

'products_url' => tep_db_prepare_input($HTTP_POST_VARS['products_url'][$language_id]),

'products_head_title_tag' => tep_db_prepare_input($HTTP_POST_VARS['products_head_title_tag'][$language_id]),

'products_head_desc_tag' => tep_db_prepare_input($HTTP_POST_VARS['products_head_desc_tag'][$language_id]),

'products_head_keywords_tag' => tep_db_prepare_input($HTTP_POST_VARS['products_head_keywords_tag'][$language_id]));

 

 

'products_head_title_tag' => tep_db_prepare_input($HTTP_POST_VARS['products_head_title_tag'][$language_id]), 'products_head_desc_tag' => tep_db_prepare_input($HTTP_POST_VARS['products_head_desc_tag'][$language_id]), 'products_head_keywords_tag' => tep_db_prepare_input($HTTP_POST_VARS['products_head_keywords_tag'][$language_id]));

// EoF Header Tag Controller

 

if ($action == 'insert_product') {

$insert_sql_data = array('products_id' => $products_id,

'language_id' => $language_id);

 

$sql_data_array = array_merge($sql_data_array, $insert_sql_data);

 

tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array);

} elseif ($action == 'update_product') {

tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "' and language_id = '" . (int)$language_id . "'");

}

}

 

if (USE_CACHE == 'true') {

tep_reset_cache_block('categories');

tep_reset_cache_block('also_purchased');

}

 

tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products_id));

}

break;

case 'copy_to_confirm':

if (isset($HTTP_POST_VARS['products_id']) && isset($HTTP_POST_VARS['categories_id'])) {

$products_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']);

$categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']);

 

if ($HTTP_POST_VARS['copy_as'] == 'link') {

if ($categories_id != $current_category_id) {

$check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$products_id . "' and categories_id = '" . (int)$categories_id . "'");

$check = tep_db_fetch_array($check_query);

if ($check['total'] < '1') {

tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$products_id . "', '" . (int)$categories_id . "')");

}

} else {

$messageStack->add_session(ERROR_CANNOT_LINK_TO_SAME_CATEGORY, 'error');

}

} elseif ($HTTP_POST_VARS['copy_as'] == 'duplicate') {

$product_query = tep_db_query("select products_quantity, products_model, products_image, products_price, products_date_available, products_weight, products_tax_class_id, manufacturers_id from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");

$product = tep_db_fetch_array($product_query);

 

tep_db_query("insert into " . TABLE_PRODUCTS . " (products_quantity, products_model,products_image, products_price, products_date_added, products_date_available, products_weight, products_status, products_tax_class_id, manufacturers_id) values ('" . tep_db_input($product['products_quantity']) . "', '" . tep_db_input($product['products_model']) . "', '" . tep_db_input($product['products_image']) . "', '" . tep_db_input($product['products_price']) . "', now(), '" . tep_db_input($product['products_date_available']) . "', '" . tep_db_input($product['products_weight']) . "', '0', '" . (int)$product['products_tax_class_id'] . "', '" . (int)$product['manufacturers_id'] . "')");

$dup_products_id = tep_db_insert_id();

 

// BoF Header Tag Controller

$description_query = tep_db_query("select language_id, products_name, products_description, products_head_title_tag, products_head_desc_tag, products_head_keywords_tag, products_url from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$products_id . "'");

while ($description = tep_db_fetch_array($description_query)) {

tep_db_query("insert into " . TABLE_PRODUCTS_DESCRIPTION . " (products_id, language_id, products_name, products_description, products_head_title_tag, products_head_desc_tag, products_head_keywords_tag, products_url, products_viewed) values ('" . (int)$dup_products_id . "', '" . (int)$description['language_id'] . "', '" . tep_db_input($description['products_name']) . "', '" . tep_db_input($description['products_description']) . "', '" . tep_db_input($description['products_head_title_tag']) . "', '" . tep_db_input($description['products_head_desc_tag']) . "', '" . tep_db_input($description['products_head_keywords_tag']) . "', '" . tep_db_input($description['products_url']) . "', '0')");

}

 

tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$dup_products_id . "', '" . (int)$categories_id . "')");

$products_id = $dup_products_id;

}

 

if (USE_CACHE == 'true') {

tep_reset_cache_block('categories');

tep_reset_cache_block('also_purchased');

}

}

 

tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $categories_id . '&pID=' . $products_id));

break;

case 'new_product_preview':

// copy image only if modified

$products_image = new upload('products_image');

$products_image->set_destination(DIR_FS_CATALOG_IMAGES);

if ($products_image->parse() && $products_image->save()) {

$products_image_name = $products_image->filename;

} else {

$products_image_name = (isset($HTTP_POST_VARS['products_previous_image']) ? $HTTP_POST_VARS['products_previous_image'] : '');

}

break;

}

}

 

// check if the catalog image directory exists

if (is_dir(DIR_FS_CATALOG_IMAGES)) {

if (!is_writeable(DIR_FS_CATALOG_IMAGES)) $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_NOT_WRITEABLE, 'error');

} else {

$messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_DOES_NOT_EXIST, 'error');

}

?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">

<html <?php echo HTML_PARAMS; ?>>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">

<title><?php echo TITLE; ?></title>

 

<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">

<script language="javascript" src="includes/general.js"></script>

</head>

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">

<div id="spiffycalendar" class="text"></div>

<!-- header //-->

<?php require(DIR_WS_INCLUDES . 'header.php'); ?>

<!-- header_eof //-->

 

<!-- body //-->

<table border="0" width="100%" cellspacing="2" cellpadding="2">

<tr>

<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">

<!-- left_navigation //-->

<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>

<!-- left_navigation_eof //-->

</table></td>

<!-- body_text //-->

<td width="100%" valign="top">

<?php

if ($action == 'new_product') {

$parameters = array('products_name' => '',

'products_description' => '',

'products_url' => '',

'products_id' => '',

'products_quantity' => '',

'products_model' => '',

'products_image' => '',

'products_price' => '',

'products_weight' => '',

'products_date_added' => '',

'products_last_modified' => '',

'products_date_available' => '',

'products_status' => '',

'products_tax_class_id' => '',

'manufacturers_id' => '');

 

$pInfo = new objectInfo($parameters);

 

if (isset ($HTTP_GET_VARS['pID']) && (!$HTTP_POST_VARS) ) {

$product_query = tep_db_query("select pd.products_name, pd.products_description, pd.products_head_title_tag, pd.products_head_desc_tag, pd.products_head_keywords_tag, pd.products_url, p.products_id, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, date_format(p.products_date_available, '%Y-%m-%d') as products_date_available, p.products_status, p.products_tax_class_id, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'");

$product = tep_db_fetch_array($product_query);

 

 

$pInfo->objectInfo($product);

} elseif (tep_not_null($HTTP_POST_VARS)) {

$pInfo->objectInfo($HTTP_POST_VARS);

$products_name = $HTTP_POST_VARS['products_name'];

$products_description = $HTTP_POST_VARS['products_description'];

$products_url = $HTTP_POST_VARS['products_url'];

}

 

$manufacturers_array = array(array('id' => '', 'text' => TEXT_NONE));

$manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " order by manufacturers_name");

while ($manufacturers = tep_db_fetch_array($manufacturers_query)) {

$manufacturers_array[] = array('id' => $manufacturers['manufacturers_id'],

'text' => $manufacturers['manufacturers_name']);

}

 

$tax_class_array = array(array('id' => '0', 'text' => TEXT_NONE));

$tax_class_query = tep_db_query("select tax_class_id, tax_class_title from " . TABLE_TAX_CLASS . " order by tax_class_title");

while ($tax_class = tep_db_fetch_array($tax_class_query)) {

$tax_class_array[] = array('id' => $tax_class['tax_class_id'],

'text' => $tax_class['tax_class_title']);

}

 

$languages = tep_get_languages();

 

if (!isset($pInfo->products_status)) $pInfo->products_status = '1';

switch ($pInfo->products_status) {

case '0': $in_status = false; $out_status = true; break;

case '1':

default: $in_status = true; $out_status = false;

}

?>

<link rel="stylesheet" type="text/css" href="includes/javascript/spiffyCal/spiffyCal_v2_1.css">

<script language="JavaScript" src="includes/javascript/spiffyCal/spiffyCal_v2_1.js"></script>

<script language="javascript"><!--

var dateAvailable = new ctlSpiffyCalendarBox("dateAvailable", "new_product", "products_date_available","btnDate1","<?php echo $pInfo->products_date_available; ?>",scBTNMODE_CUSTOMBLUE);

//--></script>

<script language="javascript"><!--

var tax_rates = new Array();

<?php

for ($i=0, $n=sizeof($tax_class_array); $i<$n; $i++) {

if ($tax_class_array[$i]['id'] > 0) {

echo 'tax_rates["' . $tax_class_array[$i]['id'] . '"] = ' . tep_get_tax_rate_value($tax_class_array[$i]['id']) . ';' . "\n";

}

}

?>

 

function doRound(x, places) {

return Math.round(x * Math.pow(10, places)) / Math.pow(10, places);

}

 

function getTaxRate() {

var selected_value = document.forms["new_product"].products_tax_class_id.selectedIndex;

var parameterVal = document.forms["new_product"].products_tax_class_id[selected_value].value;

 

if ( (parameterVal > 0) && (tax_rates[parameterVal] > 0) ) {

return tax_rates[parameterVal];

} else {

return 0;

}

}

 

function updateGross() {

var taxRate = getTaxRate();

var grossValue = document.forms["new_product"].products_price.value;

 

if (taxRate > 0) {

grossValue = grossValue * ((taxRate / 100) + 1);

}

 

document.forms["new_product"].products_price_gross.value = doRound(grossValue, 4);

}

 

function updateNet() {

var taxRate = getTaxRate();

var netValue = document.forms["new_product"].products_price_gross.value;

 

if (taxRate > 0) {

netValue = netValue / ((taxRate / 100) + 1);

}

 

document.forms["new_product"].products_price.value = doRound(netValue, 4);

}

//--></script>

<?php echo tep_draw_form('new_product', FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($HTTP_GET_VARS['pID']) ? '&pID=' . $HTTP_GET_VARS['pID'] : '') . '&action=new_product_preview', 'post', 'enctype="multipart/form-data"'); ?>

<table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr>

<td><table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

<td class="pageHeading"><?php echo sprintf(TEXT_NEW_PRODUCT, tep_output_generated_category_path($current_category_id)); ?></td>

<td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>

</tr>

</table></td>

</tr>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<tr>

<td><table border="0" cellspacing="0" cellpadding="2">

<tr>

<td class="main"><?php echo TEXT_PRODUCTS_STATUS; ?></td>

<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_radio_field('products_status', '1', $in_status) . ' ' . TEXT_PRODUCT_AVAILABLE . ' ' . tep_draw_radio_field('products_status', '0', $out_status) . ' ' . TEXT_PRODUCT_NOT_AVAILABLE; ?></td>

</tr>

<tr>

<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<tr>

<td class="main"><?php echo TEXT_PRODUCTS_DATE_AVAILABLE; ?><br><small>(YYYY-MM-DD)</small></td>

<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' '; ?><script language="javascript">dateAvailable.writeControl(); dateAvailable.dateFormat="yyyy-MM-dd";</script></td>

</tr>

<tr>

<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<tr>

<td class="main"><?php echo TEXT_PRODUCTS_MANUFACTURER; ?></td>

<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_pull_down_menu('manufacturers_id', $manufacturers_array, $pInfo->manufacturers_id); ?></td>

</tr>

<tr>

<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<?php

for ($i=0, $n=sizeof($languages); $i<$n; $i++) {

?>

<tr>

<td class="main"><?php if ($i == 0) echo TEXT_PRODUCTS_NAME; ?></td>

<td class="main"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . tep_draw_input_field('products_name[' . $languages[$i]['id'] . ']', (isset($products_name[$languages[$i]['id']]) ? $products_name[$languages[$i]['id']] : tep_get_products_name($pInfo->products_id, $languages[$i]['id']))); ?></td>

</tr>

<?php

}

?>

<tr>

<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<tr bgcolor="#ebebff">

<td class="main"><?php echo TEXT_PRODUCTS_TAX_CLASS; ?></td>

<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_pull_down_menu('products_tax_class_id', $tax_class_array, $pInfo->products_tax_class_id, 'onchange="updateGross()"'); ?></td>

</tr>

<tr bgcolor="#ebebff">

<td class="main"><?php echo TEXT_PRODUCTS_PRICE_NET; ?></td>

<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_price', $pInfo->products_price, 'onKeyUp="updateGross()"'); ?></td>

</tr>

<tr bgcolor="#ebebff">

<td class="main"><?php echo TEXT_PRODUCTS_PRICE_GROSS; ?></td>

<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_price_gross', $pInfo->products_price, 'OnKeyUp="updateNet()"'); ?></td>

</tr>

<tr>

<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<script language="javascript"><!--

updateGross();

//--></script>

<?php

for ($i=0, $n=sizeof($languages); $i<$n; $i++) {

?>

<tr>

<td class="main" valign="top"><?php if ($i == 0) echo TEXT_PRODUCTS_DESCRIPTION; ?></td>

<td><table border="0" cellspacing="0" cellpadding="0">

<tr>

<td class="main" valign="top"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?> </td>

<td class="main"><?php echo tep_draw_textarea_field('products_description[' . $languages[$i]['id'] . ']', 'soft', '70', '15', (isset($products_description[$languages[$i]['id']]) ? $products_description[$languages[$i]['id']] : tep_get_products_description($pInfo->products_id, $languages[$i]['id']))); ?></td>

</tr>

</table></td>

</tr>

<?php

}

// BoF Header Tag Controller

?>

<tr>

<td colspan="2" class="main"><hr><?php echo TEXT_PRODUCT_METTA_INFO; ?></td>

</tr>

<?php

for ($i=0, $n=sizeof($languages); $i<$n; $i++) {

?>

<tr>

<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<tr>

<td class="main" valign="top"><?php if ($i == 0) echo TEXT_PRODUCTS_PAGE_TITLE; ?></td>

<td><table border="0" cellspacing="0" cellpadding="0">

<tr>

<td class="main" valign="top"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?> </td>

<td class="main"><?php echo tep_draw_textarea_field('products_head_title_tag[' . $languages[$i]['id'] . ']', 'soft', '70', '5', (isset($products_head_title_tag[$languages[$i]['id']]) ? $products_head_title_tag[$languages[$i]['id']] : tep_get_products_head_title_tag($pInfo->products_id, $languages[$i]['id']))); ?></td>

</tr>

</table></td>

</tr>

<?php

}

for ($i=0, $n=sizeof($languages); $i<$n; $i++) {

?>

<tr>

<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<tr>

<td class="main" valign="top"><?php if ($i == 0) echo TEXT_PRODUCTS_HEADER_DESCRIPTION; ?></td>

<td><table border="0" cellspacing="0" cellpadding="0">

<tr>

<td class="main" valign="top"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?> </td>

<td class="main"><?php echo tep_draw_textarea_field('products_head_desc_tag[' . $languages[$i]['id'] . ']', 'soft', '70', '5', (isset($products_head_desc_tag[$languages[$i]['id']]) ? $products_head_desc_tag[$languages[$i]['id']] : tep_get_products_head_desc_tag($pInfo->products_id, $languages[$i]['id']))); ?></td>

</tr>

</table></td>

</tr>

<?php

}

for ($i=0, $n=sizeof($languages); $i<$n; $i++) {

?>

<tr>

<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<tr>

<td class="main" valign="top"><?php if ($i == 0) echo TEXT_PRODUCTS_KEYWORDS; ?></td>

<td><table border="0" cellspacing="0" cellpadding="0">

<tr>

<td class="main" valign="top"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?> </td>

<td class="main"><?php echo tep_draw_textarea_field('products_head_keywords_tag[' . $languages[$i]['id'] . ']', 'soft', '70', '5', (isset($products_head_keywords_tag[$languages[$i]['id']]) ? $products_head_keywords_tag[$languages[$i]['id']] : tep_get_products_head_keywords_tag($pInfo->products_id, $languages[$i]['id']))); ?></td>

</tr>

</table></td>

</tr>

<?php

// EoF Header Tag Controller

}

?>

<tr>

<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<tr>

<?php // BoF Header Tag Controller ?>

<td colspan="2" class="main"><hr></td>

</tr>

<tr>

<?php // EoF Header Tag Controller ?>

<td class="main"><?php echo TEXT_PRODUCTS_QUANTITY; ?></td>

<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_quantity', $pInfo->products_quantity); ?></td>

</tr>

<tr>

<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<tr>

<td class="main"><?php echo TEXT_PRODUCTS_MODEL; ?></td>

<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_model', $pInfo->products_model); ?></td>

</tr>

<tr>

<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<tr>

<td class="main"><?php echo TEXT_PRODUCTS_IMAGE; ?></td>

<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_file_field('products_image') . '<br>' . tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . $pInfo->products_image . tep_draw_hidden_field('products_previous_image', $pInfo->products_image); ?></td>

</tr>

<tr>

<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<?php

for ($i=0, $n=sizeof($languages); $i<$n; $i++) {

?>

<tr>

<td class="main" valign="top"><?php if ($i == 0) echo TEXT_PRODUCTS_DESCRIPTION; ?></td>

<td><table border="0" cellspacing="0" cellpadding="0">

<tr>

<td class="main" valign="top"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?> </td>

<td class="main"><?php echo tep_draw_textarea_field('products_description[' . $languages[$i]['id'] . ']', 'soft', '70', '15', (isset($products_description[$languages[$i]['id']]) ? $products_description[$languages[$i]['id']] : tep_get_products_description($pInfo->products_id, $languages[$i]['id']))); ?></td>

 

</tr>

</table></td>

</tr>

<tr>

<td colspan="2" class="main"><hr><?php echo TEXT_PRODUCT_METTA_INFO; ?></td>

</tr>

<?php

}

for ($i=0, $n=sizeof($languages); $i<$n; $i++) {

?>

<tr>

<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<tr>

<td class="main" valign="top"><?php if ($i == 0) echo TEXT_PRODUCTS_PAGE_TITLE; ?></td>

<td><table border="0" cellspacing="0" cellpadding="0">

<tr>

<td class="main" valign="top"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?> </td>

<td class="main"><?php echo tep_draw_textarea_field('products_head_title_tag[' . $languages[$i]['id'] . ']', 'soft', '70', '5', (isset($products_head_title_tag[$languages[$i]['id']]) ? $products_head_title_tag[$languages[$i]['id']] : tep_get_products_head_title_tag($pInfo->products_id, $languages[$i]['id']))); ?></td>

</tr>

</table></td>

</tr>

<?php

}

for ($i=0, $n=sizeof($languages); $i<$n; $i++) {

?>

<tr>

<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<tr>

<td class="main" valign="top"><?php if ($i == 0) echo TEXT_PRODUCTS_HEADER_DESCRIPTION; ?></td>

<td><table border="0" cellspacing="0" cellpadding="0">

<tr>

<td class="main" valign="top"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?> </td>

<td class="main"><?php echo tep_draw_textarea_field('products_head_desc_tag[' . $languages[$i]['id'] . ']', 'soft', '70', '5', (isset($products_head_desc_tag[$languages[$i]['id']]) ? $products_head_desc_tag[$languages[$i]['id']] : tep_get_products_head_desc_tag($pInfo->products_id, $languages[$i]['id']))); ?></td>

</tr>

</table></td>

</tr>

<?php

}

for ($i=0, $n=sizeof($languages); $i<$n; $i++) {

?>

<tr>

<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<tr>

<td class="main" valign="top"><?php if ($i == 0) echo TEXT_PRODUCTS_KEYWORDS; ?></td>

<td><table border="0" cellspacing="0" cellpadding="0">

<tr>

<td class="main" valign="top"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?> </td>

<td class="main"><?php echo tep_draw_textarea_field('products_head_keywords_tag[' . $languages[$i]['id'] . ']', 'soft', '70', '5', (isset($products_head_keywords_tag[$languages[$i]['id']]) ? $products_head_keywords_tag[$languages[$i]['id']] : tep_get_products_head_keywords_tag($pInfo->products_id, $languages[$i]['id']))); ?></td>

</tr>

</table></td>

</tr>

<?php

}

?>

<tr>

<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<tr>

<td colspan="2" class="main"><hr></td>

</tr>

 

 

 

<tr>

<td class="main" align="right"><?php echo tep_draw_hidden_field('products_date_added', (tep_not_null($pInfo->products_date_added) ? $pInfo->products_date_added : date('Y-m-d'))) . tep_image_submit('button_preview.gif', IMAGE_PREVIEW) . '  <a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($HTTP_GET_VARS['pID']) ? '&pID=' . $HTTP_GET_VARS['pID'] : '')) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>

</tr>

</table></form>

<?php

} elseif ($action == 'new_product_preview') {

if (tep_not_null($HTTP_POST_VARS)) {

$pInfo = new objectInfo($HTTP_POST_VARS);

$products_name = $HTTP_POST_VARS['products_name'];

$products_description = $HTTP_POST_VARS['products_description'];

$products_head_title_tag = $HTTP_POST_VARS['products_head_title_tag'];

$products_head_desc_tag = $HTTP_POST_VARS['products_head_desc_tag'];

$products_head_keywords_tag = $HTTP_POST_VARS['products_head_keywords_tag'];

$products_url = $HTTP_POST_VARS['products_url'];

} else {

$product_query = tep_db_query("select p.products_id, pd.language_id, pd.products_name, pd.products_description, pd.products_head_title_tag, pd.products_head_desc_tag, pd.products_head_keywords_tag, pd.products_url, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "'");

$product = tep_db_fetch_array($product_query);

 

 

 

$form_action = (isset($HTTP_GET_VARS['pID'])) ? 'update_product' : 'insert_product';

 

echo tep_draw_form($form_action, FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($HTTP_GET_VARS['pID']) ? '&pID=' . $HTTP_GET_VARS['pID'] : '') . '&action=' . $form_action, 'post', 'enctype="multipart/form-data"');

 

$languages = tep_get_languages();

for ($i=0, $n=sizeof($languages); $i<$n; $i++) {

if (isset($HTTP_GET_VARS['read']) && ($HTTP_GET_VARS['read'] == 'only')) {

$pInfo->products_name = tep_get_products_name($pInfo->products_id, $languages[$i]['id']);

$pInfo->products_description = tep_get_products_description($pInfo->products_id, $languages[$i]['id']);

$pInfo->products_head_title_tag = tep_db_prepare_input($products_head_title_tag[$languages[$i]['id']]);

$pInfo->products_head_desc_tag = tep_db_prepare_input($products_head_desc_tag[$languages[$i]['id']]);

$pInfo->products_head_keywords_tag = tep_db_prepare_input($products_head_keywords_tag[$languages[$i]['id']]);

$pInfo->products_url = tep_get_products_url($pInfo->products_id, $languages[$i]['id']);

} else {

$pInfo->products_name = tep_db_prepare_input($products_name[$languages[$i]['id']]);

$pInfo->products_description = tep_db_prepare_input($products_description[$languages[$i]['id']]);

$pInfo->products_head_title_tag = tep_db_prepare_input($products_head_title_tag[$languages[$i]['id']]);

$pInfo->products_head_desc_tag = tep_db_prepare_input($products_head_desc_tag[$languages[$i]['id']]);

$pInfo->products_head_keywords_tag = tep_db_prepare_input($products_head_keywords_tag[$languages[$i]['id']]);

$pInfo->products_url = tep_db_prepare_input($products_url[$languages[$i]['id']]);

}

 

?>

<table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr>

<td><table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

<td class="pageHeading"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . $pInfo->products_name; ?></td>

<td class="pageHeading" align="right"><?php echo $currencies->format($pInfo->products_price); ?></td>

</tr>

</table></td>

</tr>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<tr>

<td class="main"><?php echo tep_image(DIR_WS_CATALOG_IMAGES . $products_image_name, $pInfo->products_name, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'align="right" hspace="5" vspace="5"') . $pInfo->products_description; ?></td>

</tr>

<?php

if ($pInfo->products_url) {

?>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<tr>

<td class="main"><?php echo sprintf(TEXT_PRODUCT_MORE_INFORMATION, $pInfo->products_url); ?></td>

</tr>

<?php

}

?>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<?php

if ($pInfo->products_date_available > date('Y-m-d')) {

?>

<tr>

<td align="center" class="smallText"><?php echo sprintf(TEXT_PRODUCT_DATE_AVAILABLE, tep_date_long($pInfo->products_date_available)); ?></td>

</tr>

<?php

} else {

?>

<tr>

<td align="center" class="smallText"><?php echo sprintf(TEXT_PRODUCT_DATE_ADDED, tep_date_long($pInfo->products_date_added)); ?></td>

</tr>

<?php

}

?>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>

</tr>

<?php

}

 

if (isset($HTTP_GET_VARS['read']) && ($HTTP_GET_VARS['read'] == 'only')) {

if (isset($HTTP_GET_VARS['origin'])) {

$pos_params = strpos($HTTP_GET_VARS['origin'], '?', 0);

if ($pos_params != false) {

$back_url = substr($HTTP_GET_VARS['origin'], 0, $pos_params);

$back_url_params = substr($HTTP_GET_VARS['origin'], $pos_params + 1);

} else {

$back_url = $HTTP_GET_VARS['origin'];

$back_url_params = '';

}

} else {

$back_url = FILENAME_CATEGORIES;

$back_url_params = 'cPath=' . $cPath . '&pID=' . $pInfo->products_id;

}

?>

<tr>

<td align="right"><?php echo '<a href="' . tep_href_link($back_url, $back_url_params, 'NONSSL') . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a>'; ?></td>

</tr>

<?php

} else {

?&g

Posted

Same problem - duplicate code.

'products_head_title_tag' => tep_db_prepare_input($HTTP_POST_VARS['products_head_title_tag'][$language_id]),
'products_head_desc_tag' => tep_db_prepare_input($HTTP_POST_VARS['products_head_desc_tag'][$language_id]),
'products_head_keywords_tag' => tep_db_prepare_input($HTTP_POST_VARS['products_head_keywords_tag'][$language_id]));


'products_head_title_tag' => tep_db_prepare_input($HTTP_POST_VARS['products_head_title_tag'][$language_id]), 'products_head_desc_tag' => tep_db_prepare_input($HTTP_POST_VARS['products_head_desc_tag'][$language_id]), 'products_head_keywords_tag' => tep_db_prepare_input($HTTP_POST_VARS['products_head_keywords_tag'][$language_id]));
// EoF Header Tag Controller

Installing contributions is a fact of life with OSC. Again, I urge you strongly, start over and install it so it is working correctly without these errors. Otherwise, you will be back in six months saying my shop fails every once in a while and I don't know why. No one will be able to help you at that point I'm afraid.

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...