Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Error message


RojanUK

Recommended Posts

Hi,

 

Can somebody please tell me what this error message means?

 

Warning: htmlspecialchars() expects parameter 1 to be string, array given in c:\program files\easyphp1-7\home\catalog\includes\functions\general.php on line 53

 

By the way, this is line 53 of general.php:

 

      return htmlspecialchars($string);

 

Seems to be in the middle of a whole coding bit, so here's line again, with the closest lines around it:

 

  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);
     }
   }
 }

 

Does anybody have an idea? I get the error when I process an order through checkout on the Order Confirmation page. It should display the delivery address, but instead gives me this error message. On all previous page the billing/delivery address has been displayed properly.

 

Thanks guys.

RojanUK

Link to comment
Share on other sites

  • Replies 78
  • Created
  • Last Reply

Hello roger.

Well i am not a php expert, but if i look at what you wrote, isee that in the error it displays

:

 

given in c:\program files\easyphp1-7\home\catalog\includes\functions\general.php on line 53

 

 

 

Maybe i am going to say something very stupid but i think that you must have done something with a local program [easyphp ?] on a windowws computer, because as far as i know only windows uses a : C:\program files .... etc .

 

It seems to me that you have a hard coded path in your file somewhere, because the oscommerce system doesn't work with C:\ etc paths

 

Hope it clears it up a bit

Link to comment
Share on other sites

i think u have the server on ur comp right

is teh website in this folder

c:\program files\easyphp1-7\

???

Checkout my osc contrib here!

You can also checkout the site im working on by clicking the card button!

Link to comment
Share on other sites

EasyPHP replicates a server (with Apache, PHP and MySql) on a windows computer, allowing you to build your osCommerce on a local workstation, before uploading it to the actual server.

 

Nowhere in the coding is the C:\ path hard coded. For example, an image is coded as "images/pic.gif", but obviouly while testing it on the local computer the rest of the path gets filled in the computer. If I'd uploaded the files as is the path would've been a unix one.

 

Another point is that there are two versions of osCommerce, a windows and a unix version. It will run perfectly well on a windows server as well if that was the case. But like I said, nowhere in the program does the full path (with c:/ etc) get hard coded. It simply adds it to it to give the full path to the files. In my case the files are in the home directory like everybody elses, only the home directory is in the replicator EasyPHP.

 

This is not the problem.

 

Besides, the error is in a line where there is no mention of any path at all. Obviously the error displays the full path of where the file general.php can be found, but that does not mean its hard coded. Its not. The problem is in the general.php file and I've posted that code. Unfortunately I know too little about PHP to understand the error message itself. Its this bit of the error that is important:

 

Warning: htmlspecialchars() expects parameter 1 to be string, array given

and that the error can be found in catalog/includes/functions/general.php.

 

Oh yeah and I do have all the rights on this computer.

 

Anybody else want to have a stab at this one? It seems to be an impressively complicated problem as the are so few reactions. Any help is as always highly appreciated.

RojanUK

Link to comment
Share on other sites

Just a thing we have found out.

 

When trying things locallly for some reason sometimes we also have problems with certain things not working as expected.

 

However we also run our work on a testserver .

The funny thing is that most of the time these same things actually work fine when published to the server ;)

 

Maybe you can try this too ? [or not if you already tried this???]

 

Anyway, now your problem has been bumped again, if my advise didn't help you :P

Link to comment
Share on other sites

I'm unable to do that as I don't have the server yet. That'll be a few weeks yet, I'm afraid. Hence why I'm building it on my computer. However with an EasyPHP server replicator it should work exactly the way it works on the actual server I'd imagine.

 

Also, the stupid thing is that this happens on the very last page of the checkout procedure - before being transported to PayPal using the default PayPal module - but on all the other pages in the checkout procedure the delivery/billing address gets listed perfectly.

 

Also it moans about parameter settings in the line, although I don't see anything wrong with what is there. Maybe somebody can compare the line 53 of general.php to see whether it is in fact the same or whether something has gone wrong? Just an idea.

 

I really need this to work guys and unfortunately even though I've learned quite a bit over the past weeks I cannot figure this one out on my own.

 

Thanks.

RojanUK

Link to comment
Share on other sites

  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);
     }

This is what I have - looks the same to me. But! Is this really line 53? It looks more like the 40s to me - bear in mind I am very new to all this. And even though you have been up for hours, I'm just waking up!

 

Hope you find the problem

Link to comment
Share on other sites

Well, it seems logical to me as the error message itself quotes 'htmlspecialchars' and according to my PHP editor line 53 is the one who's returning htmlspecialchars. The point I don't get is that the error states that it's expecting parameter 1 to be $string, but as you can see: it is! It's also saying something about array, but I can't see the logic in adding an array to line 53 myself.

 

Another thing that I think I haven't mentioned. When I created the test account I entered a company name as well, even though that is not a mandatory field. So in the address there is a contact name (me) and a company name + the address itself. On all the previous pages they get displayed properly as said, but on the Order Confirmation page - the last one before going to PayPal - I get the error message obviously, however it does display the company name. Nothing else from the delivery/billing address shows, but the company name does. Right underneath the error message.

 

I've made a screenshot. Maybe that will clarify things:

error.jpg

 

Thanks again guys.

RojanUK

Link to comment
Share on other sites

Bump.

Even with the screenshot it's still a mystery to everybody? Well, I can't blame you. It is to me too. But if there's anybody with a hint, I'm willing to give it a go...

 

Thanks.

RojanUK

Link to comment
Share on other sites

have you made any changes to checout_confirmation? The error is not with the general.php or the other one, its with how checkout_confirmation is calling the function, it's got something wrong with it. Try creating an account with out the company name also and see if you get the same error.

 

Ryan

If I was crafty, this would be a funny signature.

Link to comment
Share on other sites

Nope. I've made no changes to that page. At least not recently. A contribution made some changes, which is why with me the line is 53 and with the other 12 people on this forum with the same problem its line 42. But it worked after the contribution installation, so I doubt whether it has anything to do with it. I'll post the entire general.php file here. Sorry if it's a bit long, but it's a major problem and maybe it'll help. If I can't get this fixed all my work on osC has been for nothing and I have to abandon this package. I don't want to do that. I'm almost finished building the site!

 

Tried it with a test account without company name. Same error. But I'm kinda lost here. If it isn't an error in general.php, why does the error message even specifically tell you in which line the error is supposed to be? Maybe a stupid question, but I'm kinda new to PHP.

 

And if you are right, which file is called upon in that part of the general.php file? I don't see it at all... :blink:

 

Thanks.

 

<?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 (c) 2003 osCommerce

?Released under the GNU General Public License
*/

////
// WebMakers.com Added: Find a Categories Name
// TABLES: categories_description
function tep_get_categories_name($who_am_i) {
global $languages_id;
$the_categories_name_query= tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id= '" . $who_am_i . "' and language_id= '" . $languages_id . "'");

$the_categories_name = tep_db_fetch_array($the_categories_name_query);
return $the_categories_name['categories_name'];
}

////
// 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); //THIS IS LINE 53!!!
? ?} 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();

? ?6;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 ($GLOBAL

RojanUK

Link to comment
Share on other sites

And to unwillingly flood this thread completely: you say that it's not the general.php file, but how checkout_confirmation is calling upon it. Well, here it is: checkout_confirmation.php:

 

<?php
/*
 $Id: checkout_confirmation.php,v 1.139 2003/06/11 17:34:53 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');

// if the customer is not logged on, redirect them to the login page
 if (!tep_session_is_registered('customer_id')) {
   $navigation->set_snapshot(array('mode' => 'SSL', 'page' => FILENAME_CHECKOUT_PAYMENT));
   tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
 }

// if there is nothing in the customers cart, redirect them to the shopping cart page
 if ($cart->count_contents() < 1) {
   tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
 }

// avoid hack attempts during the checkout procedure by checking the internal cartID
 if (isset($cart->cartID) && tep_session_is_registered('cartID')) {
   if ($cart->cartID != $cartID) {
     tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
   }
 }

// if no shipping method has been selected, redirect the customer to the shipping method selection page
 if (!tep_session_is_registered('shipping')) {
   tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
 }

 if (!tep_session_is_registered('payment')) tep_session_register('payment');
 if (isset($HTTP_POST_VARS['payment'])) $payment = $HTTP_POST_VARS['payment'];

 if (!tep_session_is_registered('comments')) tep_session_register('comments');
 if (tep_not_null($HTTP_POST_VARS['comments'])) {
   $comments = tep_db_prepare_input($HTTP_POST_VARS['comments']);
 }

// load the selected payment module
 require(DIR_WS_CLASSES . 'payment.php');
 $payment_modules = new payment($payment);

 require(DIR_WS_CLASSES . 'order.php');
 $order = new order;

 $payment_modules->update_status();

 if ( ( is_array($payment_modules->modules) && (sizeof($payment_modules->modules) > 1) && !is_object($$payment) ) || (is_object($$payment) && ($$payment->enabled == false)) ) {
   tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(ERROR_NO_PAYMENT_MODULE_SELECTED), 'SSL'));
 }

 if (is_array($payment_modules->modules)) {
   $payment_modules->pre_confirmation_check();
 }

// load the selected shipping module
 require(DIR_WS_CLASSES . 'shipping.php');
 $shipping_modules = new shipping($shipping);

 require(DIR_WS_CLASSES . 'order_total.php');
 $order_total_modules = new order_total;

// Stock Check
 $any_out_of_stock = false;
 if (STOCK_CHECK == 'true') {
   for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
     if (tep_check_stock($order->products[$i]['id'], $order->products[$i]['qty'])) {
       $any_out_of_stock = true;
     }
   }
   // Out of Stock
   if ( (STOCK_ALLOW_CHECKOUT != 'true') && ($any_out_of_stock == true) ) {
     tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
   }
 }

 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CHECKOUT_CONFIRMATION);

 $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
 $breadcrumb->add(NAVBAR_TITLE_2);
?>
<!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>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="3" cellpadding="3">
 <tr>
   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
   </table></td>
<!-- body_text //-->
   <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
           <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_confirmation.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
       <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
         <tr class="infoBoxContents">
<?php
 if ($sendto != false) {
?>
           <td width="30%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
             <tr>
               <td class="main"><?php echo '<b>' . HEADING_DELIVERY_ADDRESS . '</b> <a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING_ADDRESS, '', 'SSL') . '"><span class="orderEdit">(' . TEXT_EDIT . ')</span></a>'; ?></td>
             </tr>
             <tr>
               <td class="main"><?php echo tep_address_format($order->delivery['format_id'], $order->delivery, 1, ' ', '<br>'); ?></td>
             </tr>
<?php
   if ($order->info['shipping_method']) {
?>
             <tr>
               <td class="main"><?php echo '<b>' . HEADING_SHIPPING_METHOD . '</b> <a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '"><span class="orderEdit">(' . TEXT_EDIT . ')</span></a>'; ?></td>
             </tr>
             <tr>
               <td class="main"><?php echo $order->info['shipping_method']; ?></td>
             </tr>
<?php
   }
?>
           </table></td>
<?php
 }
?>
           <td width="<?php echo (($sendto != false) ? '70%' : '100%'); ?>" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
             <tr>
               <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
<?php
 if (sizeof($order->info['tax_groups']) > 1) {
?>
                 <tr>
                   <td class="main" colspan="2"><?php echo '<b>' . HEADING_PRODUCTS . '</b> <a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '"><span class="orderEdit">(' . TEXT_EDIT . ')</span></a>'; ?></td>
                   <td class="smallText" align="right"><b><?php echo HEADING_TAX; ?></b></td>
                   <td class="smallText" align="right"><b><?php echo HEADING_TOTAL; ?></b></td>
                 </tr>
<?php
 } else {
?>
                 <tr>
                   <td class="main" colspan="3"><?php echo '<b>' . HEADING_PRODUCTS . '</b> <a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '"><span class="orderEdit">(' . TEXT_EDIT . ')</span></a>'; ?></td>
                 </tr>
<?php
 }

 for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
   echo '          <tr>' . "\n" .
        '            <td class="main" align="right" valign="top" width="30">' . $order->products[$i]['qty'] . ' x</td>' . "\n" .
        '            <td class="main" valign="top">' . $order->products[$i]['name'];

   if (STOCK_CHECK == 'true') {
     echo tep_check_stock($order->products[$i]['id'], $order->products[$i]['qty']);
   }

   if ( (isset($order->products[$i]['attributes'])) && (sizeof($order->products[$i]['attributes']) > 0) ) {
     for ($j=0, $n2=sizeof($order->products[$i]['attributes']); $j<$n2; $j++) {
       echo '<br><nobr><small> <i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'] . '</i></small></nobr>';
     }
   }

   echo '</td>' . "\n";

   if (sizeof($order->info['tax_groups']) > 1) echo '            <td class="main" valign="top" align="right">' . tep_display_tax_value($order->products[$i]['tax']) . '%</td>' . "\n";

   echo '            <td class="main" align="right" valign="top">' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . '</td>' . "\n" .
        '          </tr>' . "\n";
 }
?>
               </table></td>
             </tr>
           </table></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
       <td class="main"><b><?php echo HEADING_BILLING_INFORMATION; ?></b></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
       <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
         <tr class="infoBoxContents">
           <td width="30%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
             <tr>
               <td class="main"><?php echo '<b>' . HEADING_BILLING_ADDRESS . '</b> <a href="' . tep_href_link(FILENAME_CHECKOUT_PAYMENT_ADDRESS, '', 'SSL') . '"><span class="orderEdit">(' . TEXT_EDIT . ')</span></a>'; ?></td>
             </tr>
             <tr>
               <td class="main"><?php echo tep_address_format($order->billing['format_id'], $order->billing, 1, ' ', '<br>'); ?></td>
             </tr>
             <tr>
               <td class="main"><?php echo '<b>' . HEADING_PAYMENT_METHOD . '</b> <a href="' . tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL') . '"><span class="orderEdit">(' . TEXT_EDIT . ')</span></a>'; ?></td>
             </tr>
             <tr>
               <td class="main"><?php echo $order->info['payment_method']; ?></td>
             </tr>
           </table></td>
           <td width="70%" valign="top" align="right"><table border="0" cellspacing="0" cellpadding="2">
<?php
 if (MODULE_ORDER_TOTAL_INSTALLED) {
   $order_total_modules->process();
   echo $order_total_modules->output();
 }
?>
           </table></td>
         </tr>
       </table></td>
     </tr>
<?php
 if (is_array($payment_modules->modules)) {
   if ($confirmation = $payment_modules->confirmation()) {
?>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
       <td class="main"><b><?php echo HEADING_PAYMENT_INFORMATION; ?></b></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
       <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
         <tr class="infoBoxContents">
           <td><table border="0" cellspacing="0" cellpadding="2">
             <tr>
               <td class="main" colspan="4"><?php echo $confirmation['title']; ?></td>
             </tr>
<?php
     for ($i=0, $n=sizeof($confirmation['fields']); $i<$n; $i++) {
?>
             <tr>
               <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
               <td class="main"><?php echo $confirmation['fields'][$i]['title']; ?></td>
               <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
               <td class="main"><?php echo $confirmation['fields'][$i]['field']; ?></td>
             </tr>
<?php
     }
?>
           </table></td>
         </tr>
       </table></td>
     </tr>
<?php
   }
 }
?>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
<?php
 if (tep_not_null($order->info['comments'])) {
?>
     <tr>
       <td class="main"><?php echo '<b>' . HEADING_ORDER_COMMENTS . '</b> <a href="' . tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL') . '"><span class="orderEdit">(' . TEXT_EDIT . ')</span></a>'; ?></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
       <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
         <tr class="infoBoxContents">
           <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
             <tr>
               <td class="main"><?php echo nl2br(tep_output_string_protected($order->info['comments'])) . tep_draw_hidden_field('comments', $order->info['comments']); ?></td>
             </tr>
           </table></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
<?php
 }
?>
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td align="right" class="main">
<?php
 if (isset($$payment->form_action_url)) {
   $form_action_url = $$payment->form_action_url;
 } else {
   $form_action_url = tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL');
 }

 echo tep_draw_form('checkout_confirmation', $form_action_url, 'post');

 if (is_array($payment_modules->modules)) {
   echo $payment_modules->process_button();
 }

 echo tep_image_submit('button_confirm_order.gif', IMAGE_BUTTON_CONFIRM_ORDER) . '</form>' . "\n";
?>
           </td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td width="25%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
             <tr>
               <td width="50%" align="right"><?php echo tep_draw_separator('pixel_silver.gif', '1', '5'); ?></td>
               <td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
             </tr>
           </table></td>
           <td width="25%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
           <td width="25%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
             <tr>
               <td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
               <td><?php echo tep_image(DIR_WS_IMAGES . 'checkout_bullet.gif'); ?></td>
               <td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
             </tr>
           </table></td>
           <td width="25%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
             <tr>
               <td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '100%', '1'); ?></td>
               <td width="50%"><?php echo tep_draw_separator('pixel_silver.gif', '1', '5'); ?></td>
             </tr>
           </table></td>
         </tr>
         <tr>
           <td align="center" width="25%" class="checkoutBarFrom"><?php echo '<a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '" class="checkoutBarFrom">' . CHECKOUT_BAR_DELIVERY . '</a>'; ?></td>
           <td align="center" width="25%" class="checkoutBarFrom"><?php echo '<a href="' . tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL') . '" class="checkoutBarFrom">' . CHECKOUT_BAR_PAYMENT . '</a>'; ?></td>
           <td align="center" width="25%" class="checkoutBarCurrent"><?php echo CHECKOUT_BAR_CONFIRMATION; ?></td>
           <td align="center" width="25%" class="checkoutBarTo"><?php echo CHECKOUT_BAR_FINISHED; ?></td>
         </tr>
       </table></td>
     </tr>
   </table></td>
<!-- body_text_eof //-->
   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- right_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
<!-- right_navigation_eof //-->
   </table></td>
 </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

 

I so hope that one of you out can see what I've been missing and/or overlooking for so long.

 

Thanks guys and again, my apologies for flooding this thread, but I hope you can understand why I'm doing this.

RojanUK

Link to comment
Share on other sites

the error is steming from you passing in an invalid error so the error says its in general when in reality the error is you passing in the wrong variable from the page that is calling the function which is checkout_confirmation.php. Did you make any changes to checkout_confirmation.php?

If I was crafty, this would be a funny signature.

Link to comment
Share on other sites

Nope. In fact I had to look it up where it was. I hadn't opened it at all yet. But it's pasted above. You can see whether there is an error in it or not. Personally I can't even see the section that calls on the bit in general.php at all, but then again I don't know PHP enough to recognise it I think.

RojanUK

Link to comment
Share on other sites

Er... if you haven't changed anything, then naked logic would suggest it's EasyPHP. If I had to wager my guess (flicks his penny in the pond) - I would say that if it was replicating a server correctly, then you shouldn't have something that like

c:\programfiles\blahblahblah
being passed about.

 

I use good old Internet Information Server :D on Windows XP and it works by passing http://'s around, or /wwwroot/usr/osc/catalog/.... Maybe this is where you problem lies ?

 

I also have a problem with how osC 'reads' my server it is on (open_basedir anybody), and from extensive combing of the forums looking for my own solutions, I can vouch for the fact that your problem is the first of it's kind i've come across... and so is your use of EasyPHP.

 

Maybe test it using something other than EasyPHP and I will guarantee that your bug will fix itself.

 

If the sky is blue for everyone except you,

Maybe it's time to take off those rose-tinted glasses

- Ancient chinese proverb :P

----------------------------------------

One day I will be a newie no more

Link to comment
Share on other sites

I don't think it's wise to give guarantees where none can be given. More than 12 other threads exist on this forum with the same problem and no solutions have ever been given. Chances are it's not EasyPHP. Besides, everything else on the site works like a dream. Even the other checkout pages, where the same address date is displayed without a problem. If it was EasyPHP it would've stumbled on those pages too. Besides, I doubt whether all of the more than 12 people who started a thread on this issue uses EasyPHP. There must be sommit else. Something blindingly obvious, probably, that I'm completely missing here.

 

Btw: why shouldn't I have that passing about? It tells me which file is acting up and where it's located. It's located on the local server in that directory. I do call the site up in my browser using http://127.0.0.1/home/catalog/, but that stands for c:\program files\easyphp\home\catalog\. And it reads all the files without a hitch. Even the general.php which he's complaining about, otherwise he wouldn't have known that it was line 53 and none of the other pages would've worked either. I appreciate your logic, but my logic states that it must be something else. Just because of all the factors I've mentioned before put together suggests something else than changing the server replicator.

 

Also I don't dare to bring this site live with an error like this. Suppose it did this in a live environment? I would lose so much customers over a bug like that. Luckily I'm still in a test environment. But in it's current state I would not bring my site live on the basis of someone saying that by doing nothing it will automatically go away. That's too big a risk to take I think.

RojanUK

Link to comment
Share on other sites

Check this thread for example. This example is running clearly on a unix server (error states /home/ etc.... ) but still the same error occurs. And still no one has an answer...

 

This is so weird. There must be a reason for an error message and if there's a reason there's a solution. I know, easier said than done and all of that and I most certainly don't know the answer, otherwise I would've given it. But I fear that this error is going to get us beat and loads of people have to be on the lookout for another e-commerce package. My word, I hope not. My site was nearly ready! So, if anybody has an idea - maybe an osC developer who can have a look at the files and see where it goes wrong - then I think an awful lot of people will be eternally grateful for saving their hard work. :)

RojanUK

Link to comment
Share on other sites

Dear RojanUK,

 

My speculation is as follows:

 

In view of the place where this error appears, it looks like it is caused by the function:

tep_address_format. This function is in general.php. In the function, tep_output_string_protected is called. This function on its turn calls tep_output_string through:

 

function tep_output_string_protected($string) {
  return tep_output_string($string, false, true);
}

The last parameter in that string is $protected and if that is "true" (and it is because that is the parameter that is passed in), your line 53 is called:

return htmlspecialchars($string);

 

For some reason something goes wrong with that address, causing it somewhere to have several values (an array) instead of a single row?

 

If this hypothesis is correct, maybe someone smarter than me can figure out what might be wrong with the address/address query?

Link to comment
Share on other sites

That actually is a brilliant hypothisis, JanZ. I've changed

 

return tep_output_string($string, false, true);

 

to

 

return tep_output_string($string, false, false);

 

Just to see what happens. The error message disappears. It's not the solution as still only the company name is shown and not the rest of the address but it has definately something to do with it.

 

If somebody with more PHP knowledge could pick it up from there a lot of people will be helped by this solution.

 

But there is no doubt, JanZ, that you've got us all one step closer to solving this thing. Thanks!

RojanUK

Link to comment
Share on other sites

Cheered a little too soon. On a second trial things went pearshaped. I put the argument back to false, true, as it was before and now I get error messages on every page in the checkout process. This time he's moaning about line 48 in general.php, which is:

 

////
// 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); // THIS IS LINE 48
 }

 

which I find strange for two reasons. 1) I haven't touched that bit of coding, ever and 2) this happened after I put my test changes back to what they were before. Therefore there should not have been a new error popping up.

 

Anyway, the exact error is:

 

Warning: strtr(): The second argument is not an array. in c:\program files\easyphp1-7\home\catalog\includes\functions\general.php on line 48

 

I'm highly confused now... :blink:

RojanUK

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...