Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Error message upon checkout


GlobalNet

Recommended Posts

I changed hosting services and installed osCommerce via Fantasico control panel. Uploaded entire sql database other from old hosting provider, everything went great, but now when someone adds a product to their shopping cart and attempts to check out they get this error message.

 

Warning: Cannot modify header information - headers already sent by (output started at /home/global/public_html/catalog/includes/languages/english.php:337) in /home/global/public_html/catalog/includes/functions/general.php on line 29

 

My site is http://www.globalnet-marketing.net

the online catalog is located at http://www.globalnet-marketing.net/catalog

 

Can someone tell me how to fix the problem - PLEASE!

 

Wating for HELP!

Greg :blush:

Link to comment
Share on other sites

I changed hosting services and installed osCommerce via Fantasico control panel. Uploaded entire sql database other from old hosting provider, everything went great, but now when someone adds a product to their shopping cart and attempts to check out they get this error message.

 

Warning: Cannot modify header information - headers already sent by (output started at /home/global/public_html/catalog/includes/languages/english.php:337) in /home/global/public_html/catalog/includes/functions/general.php on line 29

 

My site is http://www.globalnet-marketing.net

the online catalog is located at http://www.globalnet-marketing.net/catalog

 

Can someone tell me how to fix the problem - PLEASE!

 

Wating for HELP!

Greg :blush:

 

Here are the FILES where they say the error message is: ENGLISH .PHP

 

<?php

/*

$Id: english.php,v 1.114 2003/07/09 18:13:39 dgw_ Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

 

// look in your $PATH_LOCALE/locale directory for available locales

// or type locale -a on the server.

// Examples:

// on RedHat try 'en_US'

// on FreeBSD try 'en_US.ISO_8859-1'

// on Windows try 'en', or 'English'

@setlocale(LC_TIME, 'en_US.ISO_8859-1');

 

define('DATE_FORMAT_SHORT', '%m/%d/%Y'); // this is used for strftime()

define('DATE_FORMAT_LONG', '%A %d %B, %Y'); // this is used for strftime()

define('DATE_FORMAT', 'm/d/Y'); // this is used for date()

define('DATE_TIME_FORMAT', DATE_FORMAT_SHORT . ' %H:%M:%S');

 

////

// Return date in raw format

// $date should be in format mm/dd/yyyy

// raw date is in format YYYYMMDD, or DDMMYYYY

function tep_date_raw($date, $reverse = false) {

if ($reverse) {

return substr($date, 3, 2) . substr($date, 0, 2) . substr($date, 6, 4);

} else {

return substr($date, 6, 4) . substr($date, 0, 2) . substr($date, 3, 2);

}

}

 

// if USE_DEFAULT_LANGUAGE_CURRENCY is true, use the following currency, instead of the applications default currency (used when changing language)

define('LANGUAGE_CURRENCY', 'USD');

 

// Global entries for the <html> tag

define('HTML_PARAMS','dir="LTR" lang="en"');

 

// charset for web pages and emails

define('CHARSET', 'iso-8859-1');

 

// page title

define('TITLE', 'GlobalNet Marketing Online Catalog');

 

// header text in includes/header.php

define('HEADER_TITLE_CREATE_ACCOUNT', 'Create an Account');

define('HEADER_TITLE_MY_ACCOUNT', 'My Account');

define('HEADER_TITLE_CART_CONTENTS', 'Cart Contents');

define('HEADER_TITLE_CHECKOUT', 'Checkout');

define('HEADER_TITLE_TOP', 'Top');

define('HEADER_TITLE_CATALOG', 'Catalog');

define('HEADER_TITLE_LOGOFF', 'Log Off');

define('HEADER_TITLE_LOGIN', 'Log In');

 

// footer text in includes/footer.php

define('FOOTER_TEXT_REQUESTS_SINCE', 'requests since');

 

// text for gender

define('MALE', 'Male');

define('FEMALE', 'Female');

define('MALE_ADDRESS', 'Mr.');

define('FEMALE_ADDRESS', 'Ms.');

 

// text for date of birth example

define('DOB_FORMAT_STRING', 'mm/dd/yyyy');

 

// categories box text in includes/boxes/categories.php

define('BOX_HEADING_CATEGORIES', 'Categories');

 

// manufacturers box text in includes/boxes/manufacturers.php

define('BOX_HEADING_MANUFACTURERS', 'Manufacturers');

 

// whats_new box text in includes/boxes/whats_new.php

define('BOX_HEADING_WHATS_NEW', 'What\'s New?');

 

// quick_find box text in includes/boxes/quick_find.php

define('BOX_HEADING_SEARCH', 'Quick Find');

define('BOX_SEARCH_TEXT', 'Use keywords to find the product you are looking for.');

define('BOX_SEARCH_ADVANCED_SEARCH', 'Advanced Search');

 

// specials box text in includes/boxes/specials.php

define('BOX_HEADING_SPECIALS', 'Specials');

 

// reviews box text in includes/boxes/reviews.php

define('BOX_HEADING_REVIEWS', 'Reviews');

define('BOX_REVIEWS_WRITE_REVIEW', 'Write a review on this product!');

define('BOX_REVIEWS_NO_REVIEWS', 'There are currently no product reviews');

define('BOX_REVIEWS_TEXT_OF_5_STARS', '%s of 5 Stars!');

 

// shopping_cart box text in includes/boxes/shopping_cart.php

define('BOX_HEADING_SHOPPING_CART', 'Shopping Cart');

define('BOX_SHOPPING_CART_EMPTY', '0 items');

 

// order_history box text in includes/boxes/order_history.php

define('BOX_HEADING_CUSTOMER_ORDERS', 'Order History');

 

// best_sellers box text in includes/boxes/best_sellers.php

define('BOX_HEADING_BESTSELLERS', 'Bestsellers');

define('BOX_HEADING_BESTSELLERS_IN', 'Bestsellers in<br>  ');

 

// notifications box text in includes/boxes/products_notifications.php

define('BOX_HEADING_NOTIFICATIONS', 'Notifications');

define('BOX_NOTIFICATIONS_NOTIFY', 'Notify me of updates to <b>%s</b>');

define('BOX_NOTIFICATIONS_NOTIFY_REMOVE', 'Do not notify me of updates to <b>%s</b>');

 

// manufacturer box text

define('BOX_HEADING_MANUFACTURER_INFO', 'Manufacturer Info');

define('BOX_MANUFACTURER_INFO_HOMEPAGE', '%s Homepage');

define('BOX_MANUFACTURER_INFO_OTHER_PRODUCTS', 'Other products');

 

// languages box text in includes/boxes/languages.php

define('BOX_HEADING_LANGUAGES', 'Languages');

 

// currencies box text in includes/boxes/currencies.php

define('BOX_HEADING_CURRENCIES', 'Currencies');

 

// information box text in includes/boxes/information.php

define('BOX_HEADING_INFORMATION', 'Information');

define('BOX_INFORMATION_PRIVACY', 'Privacy Notice');

define('BOX_INFORMATION_CONDITIONS', 'Conditions of Use');

define('BOX_INFORMATION_SHIPPING', 'Shipping & Returns');

define('BOX_INFORMATION_CONTACT', 'Contact Us');

 

// tell a friend box text in includes/boxes/tell_a_friend.php

define('BOX_HEADING_TELL_A_FRIEND', 'Tell A Friend');

define('BOX_TELL_A_FRIEND_TEXT', 'Tell someone you know about this product.');

 

// checkout procedure text

define('CHECKOUT_BAR_DELIVERY', 'Delivery Information');

define('CHECKOUT_BAR_PAYMENT', 'Payment Information');

define('CHECKOUT_BAR_CONFIRMATION', 'Confirmation');

define('CHECKOUT_BAR_FINISHED', 'Finished!');

 

// pull down default text

define('PULL_DOWN_DEFAULT', 'Please Select');

define('TYPE_BELOW', 'Type Below');

 

// javascript messages

define('JS_ERROR', 'Errors have occured during the process of your form.\n\nPlease make the following corrections:\n\n');

 

define('JS_REVIEW_TEXT', '* The \'Review Text\' must have at least ' . REVIEW_TEXT_MIN_LENGTH . ' characters.\n');

define('JS_REVIEW_RATING', '* You must rate the product for your review.\n');

 

define('JS_ERROR_NO_PAYMENT_MODULE_SELECTED', '* Please select a payment method for your order.\n');

 

define('JS_ERROR_SUBMITTED', 'This form has already been submitted. Please press Ok and wait for this process to be completed.');

 

define('ERROR_NO_PAYMENT_MODULE_SELECTED', 'Please select a payment method for your order.');

 

define('CATEGORY_COMPANY', 'Company Details');

define('CATEGORY_PERSONAL', 'Your Personal Details');

define('CATEGORY_ADDRESS', 'Your Address');

define('CATEGORY_CONTACT', 'Your Contact Information');

define('CATEGORY_OPTIONS', 'Options');

define('CATEGORY_PASSWORD', 'Your Password');

 

define('ENTRY_COMPANY', 'Company Name:');

define('ENTRY_COMPANY_ERROR', '');

define('ENTRY_COMPANY_TEXT', '');

define('ENTRY_GENDER', 'Gender:');

define('ENTRY_GENDER_ERROR', 'Please select your Gender.');

define('ENTRY_GENDER_TEXT', '*');

define('ENTRY_FIRST_NAME', 'First Name:');

define('ENTRY_FIRST_NAME_ERROR', 'Your First Name must contain a minimum of ' . ENTRY_FIRST_NAME_MIN_LENGTH . ' characters.');

define('ENTRY_FIRST_NAME_TEXT', '*');

define('ENTRY_LAST_NAME', 'Last Name:');

define('ENTRY_LAST_NAME_ERROR', 'Your Last Name must contain a minimum of ' . ENTRY_LAST_NAME_MIN_LENGTH . ' characters.');

define('ENTRY_LAST_NAME_TEXT', '*');

define('ENTRY_DATE_OF_BIRTH', 'Date of Birth:');

define('ENTRY_DATE_OF_BIRTH_ERROR', 'Your Date of Birth must be in this format: MM/DD/YYYY (eg 05/21/1970)');

define('ENTRY_DATE_OF_BIRTH_TEXT', '* (eg. 05/21/1970)');

define('ENTRY_EMAIL_ADDRESS', 'E-Mail Address:');

define('ENTRY_EMAIL_ADDRESS_ERROR', 'Your E-Mail Address must contain a minimum of ' . ENTRY_EMAIL_ADDRESS_MIN_LENGTH . ' characters.');

define('ENTRY_EMAIL_ADDRESS_CHECK_ERROR', 'Your E-Mail Address does not appear to be valid - please make any necessary corrections.');

define('ENTRY_EMAIL_ADDRESS_ERROR_EXISTS', 'Your E-Mail Address already exists in our records - please log in with the e-mail address or create an account with a different address.');

define('ENTRY_EMAIL_ADDRESS_TEXT', '*');

define('ENTRY_STREET_ADDRESS', 'Street Address:');

define('ENTRY_STREET_ADDRESS_ERROR', 'Your Street Address must contain a minimum of ' . ENTRY_STREET_ADDRESS_MIN_LENGTH . ' characters.');

define('ENTRY_STREET_ADDRESS_TEXT', '*');

define('ENTRY_SUBURB', 'Suburb:');

define('ENTRY_SUBURB_ERROR', '');

define('ENTRY_SUBURB_TEXT', '');

define('ENTRY_POST_CODE', 'Post Code:');

define('ENTRY_POST_CODE_ERROR', 'Your Post Code must contain a minimum of ' . ENTRY_POSTCODE_MIN_LENGTH . ' characters.');

define('ENTRY_POST_CODE_TEXT', '*');

define('ENTRY_CITY', 'City:');

define('ENTRY_CITY_ERROR', 'Your City must contain a minimum of ' . ENTRY_CITY_MIN_LENGTH . ' characters.');

define('ENTRY_CITY_TEXT', '*');

define('ENTRY_STATE', 'State/Province:');

define('ENTRY_STATE_ERROR', 'Your State must contain a minimum of ' . ENTRY_STATE_MIN_LENGTH . ' characters.');

define('ENTRY_STATE_ERROR_SELECT', 'Please select a state from the States pull down menu.');

define('ENTRY_STATE_TEXT', '*');

define('ENTRY_COUNTRY', 'Country:');

define('ENTRY_COUNTRY_ERROR', 'You must select a country from the Countries pull down menu.');

define('ENTRY_COUNTRY_TEXT', '*');

define('ENTRY_TELEPHONE_NUMBER', 'Telephone Number:');

define('ENTRY_TELEPHONE_NUMBER_ERROR', 'Your Telephone Number must contain a minimum of ' . ENTRY_TELEPHONE_MIN_LENGTH . ' characters.');

define('ENTRY_TELEPHONE_NUMBER_TEXT', '*');

define('ENTRY_FAX_NUMBER', 'Fax Number:');

define('ENTRY_FAX_NUMBER_ERROR', '');

define('ENTRY_FAX_NUMBER_TEXT', '');

define('ENTRY_NEWSLETTER', 'Newsletter:');

define('ENTRY_NEWSLETTER_TEXT', '');

define('ENTRY_NEWSLETTER_YES', 'Subscribed');

define('ENTRY_NEWSLETTER_NO', 'Unsubscribed');

define('ENTRY_NEWSLETTER_ERROR', '');

define('ENTRY_PASSWORD', 'Password:');

define('ENTRY_PASSWORD_ERROR', 'Your Password must contain a minimum of ' . ENTRY_PASSWORD_MIN_LENGTH . ' characters.');

define('ENTRY_PASSWORD_ERROR_NOT_MATCHING', 'The Password Confirmation must match your Password.');

define('ENTRY_PASSWORD_TEXT', '*');

define('ENTRY_PASSWORD_CONFIRMATION', 'Password Confirmation:');

define('ENTRY_PASSWORD_CONFIRMATION_TEXT', '*');

define('ENTRY_PASSWORD_CURRENT', 'Current Password:');

define('ENTRY_PASSWORD_CURRENT_TEXT', '*');

define('ENTRY_PASSWORD_CURRENT_ERROR', 'Your Password must contain a minimum of ' . ENTRY_PASSWORD_MIN_LENGTH . ' characters.');

define('ENTRY_PASSWORD_NEW', 'New Password:');

define('ENTRY_PASSWORD_NEW_TEXT', '*');

define('ENTRY_PASSWORD_NEW_ERROR', 'Your new Password must contain a minimum of ' . ENTRY_PASSWORD_MIN_LENGTH . ' characters.');

define('ENTRY_PASSWORD_NEW_ERROR_NOT_MATCHING', 'The Password Confirmation must match your new Password.');

define('PASSWORD_HIDDEN', '--HIDDEN--');

 

define('FORM_REQUIRED_INFORMATION', '* Required information');

 

// constants for use in tep_prev_next_display function

define('TEXT_RESULT_PAGE', 'Result Pages:');

define('TEXT_DISPLAY_NUMBER_OF_PRODUCTS', 'Displaying <b>%d</b> to <b>%d</b> (of <b>%d</b> products)');

define('TEXT_DISPLAY_NUMBER_OF_ORDERS', 'Displaying <b>%d</b> to <b>%d</b> (of <b>%d</b> orders)');

define('TEXT_DISPLAY_NUMBER_OF_REVIEWS', 'Displaying <b>%d</b> to <b>%d</b> (of <b>%d</b> reviews)');

define('TEXT_DISPLAY_NUMBER_OF_PRODUCTS_NEW', 'Displaying <b>%d</b> to <b>%d</b> (of <b>%d</b> new products)');

define('TEXT_DISPLAY_NUMBER_OF_SPECIALS', 'Displaying <b>%d</b> to <b>%d</b> (of <b>%d</b> specials)');

 

define('PREVNEXT_TITLE_FIRST_PAGE', 'First Page');

define('PREVNEXT_TITLE_PREVIOUS_PAGE', 'Previous Page');

define('PREVNEXT_TITLE_NEXT_PAGE', 'Next Page');

define('PREVNEXT_TITLE_LAST_PAGE', 'Last Page');

define('PREVNEXT_TITLE_PAGE_NO', 'Page %d');

define('PREVNEXT_TITLE_PREV_SET_OF_NO_PAGE', 'Previous Set of %d Pages');

define('PREVNEXT_TITLE_NEXT_SET_OF_NO_PAGE', 'Next Set of %d Pages');

define('PREVNEXT_BUTTON_FIRST', '<<FIRST');

define('PREVNEXT_BUTTON_PREV', '[<< Prev]');

define('PREVNEXT_BUTTON_NEXT', '[Next >>]');

define('PREVNEXT_BUTTON_LAST', 'LAST>>');

 

define('IMAGE_BUTTON_ADD_ADDRESS', 'Add Address');

define('IMAGE_BUTTON_ADDRESS_BOOK', 'Address Book');

define('IMAGE_BUTTON_BACK', 'Back');

define('IMAGE_BUTTON_BUY_NOW', 'Buy Now');

define('IMAGE_BUTTON_CHANGE_ADDRESS', 'Change Address');

define('IMAGE_BUTTON_CHECKOUT', 'Checkout');

define('IMAGE_BUTTON_CONFIRM_ORDER', 'Confirm Order');

define('IMAGE_BUTTON_CONTINUE', 'Continue');

define('IMAGE_BUTTON_CONTINUE_SHOPPING', 'Continue Shopping');

define('IMAGE_BUTTON_DELETE', 'Delete');

define('IMAGE_BUTTON_EDIT_ACCOUNT', 'Edit Account');

define('IMAGE_BUTTON_HISTORY', 'Order History');

define('IMAGE_BUTTON_LOGIN', 'Sign In');

define('IMAGE_BUTTON_IN_CART', 'Add to Cart');

define('IMAGE_BUTTON_NOTIFICATIONS', 'Notifications');

define('IMAGE_BUTTON_QUICK_FIND', 'Quick Find');

define('IMAGE_BUTTON_REMOVE_NOTIFICATIONS', 'Remove Notifications');

define('IMAGE_BUTTON_REVIEWS', 'Reviews');

define('IMAGE_BUTTON_SEARCH', 'Search');

define('IMAGE_BUTTON_SHIPPING_OPTIONS', 'Shipping Options');

define('IMAGE_BUTTON_TELL_A_FRIEND', 'Tell a Friend');

define('IMAGE_BUTTON_UPDATE', 'Update');

define('IMAGE_BUTTON_UPDATE_CART', 'Update Cart');

define('IMAGE_BUTTON_WRITE_REVIEW', 'Write Review');

 

define('SMALL_IMAGE_BUTTON_DELETE', 'Delete');

define('SMALL_IMAGE_BUTTON_EDIT', 'Edit');

define('SMALL_IMAGE_BUTTON_VIEW', 'View');

 

define('ICON_ARROW_RIGHT', 'more');

define('ICON_CART', 'In Cart');

define('ICON_ERROR', 'Error');

define('ICON_SUCCESS', 'Success');

define('ICON_WARNING', 'Warning');

 

define('TEXT_GREETING_PERSONAL', 'Welcome back <span class="greetUser">%s!</span> Would you like to see which <a href="%s"><u>new products</u></a> are available to purchase?');

define('TEXT_GREETING_PERSONAL_RELOGON', '<small>If you are not %s, please <a href="%s"><u>log yourself in</u></a> with your account information.</small>');

define('TEXT_GREETING_GUEST', 'Welcome <span class="greetUser">Guest!</span> If you have already created and listed your profile with us <a href="%s"><u>log yourself in</u></a> to enhance your shopping experience? Or if you should need to <a href="%s"><u>Add your Profile</u></a> with GlobalNet Marketing; please do so! Creating and listing your profile is free, requires NO credit card or financial information and authorizes you for additional discounts on many of our software products.');

 

define('TEXT_SORT_PRODUCTS', 'Sort products ');

define('TEXT_DESCENDINGLY', 'descendingly');

define('TEXT_ASCENDINGLY', 'ascendingly');

define('TEXT_BY', ' by ');

 

define('TEXT_REVIEW_BY', 'by %s');

define('TEXT_REVIEW_WORD_COUNT', '%s words');

define('TEXT_REVIEW_RATING', 'Rating: %s [%s]');

define('TEXT_REVIEW_DATE_ADDED', 'Date Added: %s');

define('TEXT_NO_REVIEWS', 'There are currently no product reviews.');

 

define('TEXT_NO_NEW_PRODUCTS', 'There are currently no products.');

 

define('TEXT_UNKNOWN_TAX_RATE', 'Unknown tax rate');

 

define('TEXT_REQUIRED', '<span class="errorText">Required</span>');

 

define('ERROR_TEP_MAIL', '<font face="Verdana, Arial" size="2" color="#ff0000"><b><small>TEP ERROR:</small> Cannot send the email through the specified SMTP server. Please check your php.ini setting and correct the SMTP server if necessary.</b></font>');

define('WARNING_INSTALL_DIRECTORY_EXISTS', 'Warning: Installation directory exists at: ' . dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']) . '/install. Please remove this directory for security reasons.');

define('WARNING_CONFIG_FILE_WRITEABLE', 'Warning: I am able to write to the configuration file: ' . dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']) . '/includes/configure.php. This is a potential security risk - please set the right user permissions on this file.');

define('WARNING_SESSION_DIRECTORY_NON_EXISTENT', 'Warning: The sessions directory does not exist: ' . tep_session_save_path() . '. Sessions will not work until this directory is created.');

define('WARNING_SESSION_DIRECTORY_NOT_WRITEABLE', 'Warning: I am not able to write to the sessions directory: ' . tep_session_save_path() . '. Sessions will not work until the right user permissions are set.');

define('WARNING_SESSION_AUTO_START', 'Warning: session.auto_start is enabled - please disable this php feature in php.ini and restart the web server.');

define('WARNING_DOWNLOAD_DIRECTORY_NON_EXISTENT', 'Warning: The downloadable products directory does not exist: ' . DIR_FS_DOWNLOAD . '. Downloadable products will not work until this directory is valid.');

 

define('TEXT_CCVAL_ERROR_INVALID_DATE', 'The expiry date entered for the credit card is invalid.<br>Please check the date and try again.');

define('TEXT_CCVAL_ERROR_INVALID_NUMBER', 'The credit card number entered is invalid.<br>Please check the number and try again.');

define('TEXT_CCVAL_ERROR_UNKNOWN_CARD', 'The first four digits of the number entered are: %s<br>If that number is correct, we do not accept that type of credit card.<br>If it is wrong, please try again.');

 

/*

The following copyright announcement can only be

appropriately modified or removed if the layout of

the site theme has been modified to distinguish

itself from the default osCommerce-copyrighted

theme.

 

For more information please read the following

Frequently Asked Questions entry on the osCommerce

support site:

 

http://www.oscommerce.com/community.php/faq,26/q,50

 

Please leave this comment intact together with the

following copyright announcement.

*/

define('FOOTER_TEXT_BODY', 'Copyright © 2003-2005 <a href="http://www.globalnet-marketing.net" target="_blank">GlobalNet Marketing</a><br>Powered by <a href="http://www.oscommerce.com" target="_blank">osCommerce</a>');

?>

 

 

And here is: GENERAL.PHP

 

<?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[$

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...