Jump to content

driven22

Members
  • Content count

    59
  • Joined

  • Last visited

Profile Information

  • Real Name
    Grzesiek

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. driven22

    NIF (VAT NUMBER) in customer email confirmation

    Unfortunately, it's hard to get any help there :( I have had all versions of oscommerce for over a dozen years and it was always possible to solve some problems together on the forum. Now that has changed a little
  2. How to pull invoice information from the database that is in (table-orders-YOUR_NEW_BOX) to customer e-mail confirmation in Phoenix version? Data saved in the field Orders - YOUR_NEW_BOX are displayed without any problems in the admin side, they are remembered when typing in checkout_payment but are invisible in the e-mail. file tpl_n_checkout.php: <?php /* $Id$ CE Phoenix, E-Commerce made Easy https://phoenixcart.org Copyright (c) 2021 Phoenix Cart Released under the GNU General Public License */ // let's start with the email confirmation echo STORE_NAME . "\n" . MODULE_NOTIFICATIONS_CHECKOUT_SEPARATOR . "\n" . MODULE_NOTIFICATIONS_CHECKOUT_TEXT_ORDER_NUMBER . ' ' . $order->get_id() . "\n" . MODULE_NOTIFICATIONS_CHECKOUT_TEXT_INVOICE_URL . ' ' . tep_href_link('account_history_info.php', 'order_id=' . $order->get_id(), 'SSL', false) . "\n" . MODULE_NOTIFICATIONS_CHECKOUT_TEXT_DATE_ORDERED . ' ' . strftime(DATE_FORMAT_LONG) . "\n\n" . EMAIL_TEXT_CUSTOMER_NAME . ' ' . $order->customer['firstname'] . ' ' . $order->customer['lastname'] . "\n" . EMAIL_TEXT_CUSTOMER_EMAIL_ADDRESS .' '. $order->customer['email_address'] . "\n" . MODULE_CUSTOMER_DATA_TELEPHONE . ' '.$order->customer['telephone']. "\n\n"; if (!empty($order->info['comments'])) { echo tep_db_output($order->info['comments']) . "\n"; } //not working //if (!empty($order->info['YOUR_NEW_BOX'])) { //echo tep_db_output($order->info['YOUR_NEW_BOX']) . "\n"; //} echo MODULE_NOTIFICATIONS_CHECKOUT_TEXT_PRODUCTS . "\n" . MODULE_NOTIFICATIONS_CHECKOUT_SEPARATOR . "\n"; foreach ($order->products as $product) { echo "\n" . $product['qty'] . ' x ' . $product['name'] . (empty($product['model']) ? '' : ' (' . $product['model'] . ')') . ' = ' . $GLOBALS['currencies']->display_price($product['final_price'], $product['tax'], $product['qty']); //------insert customer chosen option to order-------- foreach (($product['attributes'] ?? []) as $attribute) { echo "\n\t" . $attribute['option'] . ' ' . $attribute['value']; } //------insert customer chosen option eof ---- } echo "\n" . MODULE_NOTIFICATIONS_CHECKOUT_SEPARATOR . "\n"; foreach ($order->totals as $order_total) { echo strip_tags($order_total['title']) . ' ' . strip_tags($order_total['text']) . "\n"; } if ($order->content_type != 'virtual') { echo "\n" . MODULE_NOTIFICATIONS_CHECKOUT_TEXT_DELIVERY_ADDRESS . "\n" . MODULE_NOTIFICATIONS_CHECKOUT_SEPARATOR . "\n" . $customer->make_address_label($order->delivery, 0, '', "\n") . "\n"; } echo "\n" . MODULE_NOTIFICATIONS_CHECKOUT_TEXT_BILLING_ADDRESS . "\n" . MODULE_NOTIFICATIONS_CHECKOUT_SEPARATOR . "\n" . $customer->make_address_label($order->billing, 0, '', "\n") . "\n\n"; $payment = $GLOBALS[$_SESSION['payment']]; if (is_object($payment)) { echo MODULE_NOTIFICATIONS_CHECKOUT_TEXT_PAYMENT_METHOD . "\n" . MODULE_NOTIFICATIONS_CHECKOUT_SEPARATOR . "\n"; echo $order->info['payment_method'] . "\n\n"; if (isset($payment->email_footer)) { echo $payment->email_footer . "\n\n"; } } ?>
  3. driven22

    ship2pay for 2.3.x

    Hi, i have same problem with shi2pay. Can you help mi (last version Phoenix) ? if ($_GET['action']) { switch ($_GET['action']) { switch ($_GET['action']) { if (is_object($trInfo)) { I have a lot problems with ship2pay. In Phoenix version removed class/payment.php .
  4. driven22

    osCommerce v4 demo

    2.3.4.1 is obsolete and does not work with CDN, so I asked when will the V4 version be released?
  5. driven22

    osCommerce v4 demo

    When will the official version be released? My oscommerce 2.3.4.1 CE does not work with CDN servers and the latest PHP :(
  6. This code makes the page blank
  7. This is all code: <?php /* $Id$ Designed for: osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Surfalot CMS Copyright (c) 2017 Todd Holforty - mtholforty (at) surfalot (at) com Released under the GNU General Public License */ /* surfcms_page abstract class */ require_once DIR_FS_CATALOG . 'includes/apps/surfcms/core/surfcms_page.abstract.php'; /* surfcms_app_setup singleton class */ require_once DIR_FS_CATALOG . 'includes/apps/surfcms/core/surfcms_app_setup.class.php'; // ///////////////////////////////////////////////////// // SurfCMS Main Class // class surfcms extends surfcms_page { protected $_code = 'surfcms'; protected $_title = 'Surfalot CMS App'; protected $_config_id; protected $_admins; protected $_restricted_admins; protected $_restricted_utilities; protected $_restricted_lists; // ///////////////////////////////////////////////////// // Construct / Destruct // public function __construct($group_name = null, $page_id = null, $languages_id = null, $defs = null) { $this->setLanguage(); $this->loadLanguageFile('surfcms.class.php'); $this->getVersion(); $this->checkVersion(); if ( isset($group_name) ) { $this->getPageGroup($group_name, $languages_id, $defs); } elseif ( isset($page_id) ) { $this->getPageGroup($this->getGroupName($page_id), $languages_id, $defs); } $this->_title .= ' v' . $this->getVersion() . ' ' . $this->getDef('text_content_app_subver'); } public function __destruct() {} // ///////////////////////////////////////////////////// // no serialize // private function __clone() {} private function __sleep() {} private function __wakeup() {} // ///////////////////////////////////////////////////// // Gets // public function getGroupName($id) { $return = false; if ( isset($id) ) { $item_query = tep_db_query("select surfcms_content_group from surfcms_content where surfcms_content_id = '" . (int)$id . "' limit 1"); if ( $item_row = tep_db_fetch_array($item_query) ) { $return = $item_row['surfcms_content_group']; } } return $return; } public function getItemType($id) { $return = false; if ( isset($id) ) { $item_query = tep_db_query("select oc.surfcms_content_type from surfcms_content oc, surfcms_content_description ocd where oc.surfcms_content_id = ocd.surfcms_content_id and oc.surfcms_content_id = '" . (int)$id . "' limit 1"); if ( $item_row = tep_db_fetch_array($item_query) ) { $return = $item_row['surfcms_content_type']; } } return $return; } public function getItemTitle($id) { $return = false; if ( isset($id) ) { $item_query = tep_db_query("select ocd.surfcms_content_menu_text from surfcms_content oc, surfcms_content_description ocd where oc.surfcms_content_id = ocd.surfcms_content_id and oc.surfcms_content_id = '" . (int)$id . "' limit 1"); if ( $item_row = tep_db_fetch_array($item_query) ) { $return = $item_row['surfcms_content_menu_text']; } } return $return; } public function itemExists($item_name, $types = null) { $return = false; if (tep_not_null($item_name)) { if ( is_array($item_name) ) { $where_group = " (surfcms_content_group like '" . implode("' or surfcms_content_group like '", tep_db_prepare_input($item_name)) . "')"; } else { $where_group = " surfcms_content_group like '" . tep_db_prepare_input($item_name) . "'"; } $where_type = ''; if ( is_array($types) ) { $where_types = " and surfcms_content_type in ('" . implode("','", tep_db_prepare_input($types)) . "')"; } elseif ( tep_not_null($types) ) { $where_types = " and surfcms_content_type = '" . (int)$types . "'"; } $item_query = tep_db_query("select count(surfcms_content_id) as count from surfcms_content where" . $where_group . $where_types); if ($item = tep_db_fetch_array($item_query)) { $return = $item['count']; } } return $return; } public function getBlockItems($items = null, $languages_id = null) { return $this->getItems($items, '2', $languages_id); } public function getContentItems($items = null, $languages_id = null) { return $this->getItems($items, '1', $languages_id); } public function getItems($items = null, $types = null, $languages_id = null) { $return = false; if ( !isset($languages_id) ) { $languages_id = $this->languages_id; } $where_group = (is_array($items) ? " and oc.surfcms_content_group in ('" . implode("','",$items) . "')" : (tep_not_null($items) ? " and oc.surfcms_content_group like '" . $items . "'" : '')); $where_type = (is_array($types) ? " and oc.surfcms_content_type in ('" . implode("','",$types) . "')" : (tep_not_null($types) ? " and oc.surfcms_content_type = '" . $types . "'" : '')); $item_query = tep_db_query("select oc.surfcms_content_id, oc.surfcms_content_group, oc.surfcms_content_type, oc.surfcms_content_width, oc.surfcms_content_sort_order, oc.surfcms_content_administrators, ocd.surfcms_content_menu_text, ocd.surfcms_content_body from surfcms_content oc, surfcms_content_description ocd where oc.surfcms_content_id = ocd.surfcms_content_id" . $where_group . " and oc.surfcms_content_status = '1'" . $where_type . " and ocd.language_id = '" . (int)$languages_id . "' order by oc.surfcms_content_sort_order"); if ( tep_db_num_rows($item_query) ) { $return = array(); while ( $item_row = tep_db_fetch_array($item_query) ) { $return[] = array( 'id' => $item_row['surfcms_content_id'], 'group' => $item_row['surfcms_content_group'], 'type' => $item_row['surfcms_content_type'], 'width' => $item_row['surfcms_content_width'], 'sort_order' => $item_row['surfcms_content_sort_order'], 'admins' => $item_row['surfcms_content_administrators'], 'menu_text' => $item_row['surfcms_content_menu_text'], 'body' => $item_row['surfcms_content_body']); } } return $return; } public function getNavigation($nav = 'navbar', $languages_id = null) { $return = false; $navigation = array(); if ( !isset($languages_id) ) { $languages_id = $this->languages_id; } $where = ($nav == 'navbar' ? " and oc.surfcms_content_show_in_nav != '0'" : " and oc.surfcms_content_show_in_box = '1'"); $order = ($nav == 'navbar' ? " order by oc.surfcms_content_show_in_nav, oc.surfcms_content_sort_order" : " order by oc.surfcms_content_sort_order"); $item_query = tep_db_query("select oc.surfcms_content_id as id, oc.surfcms_content_group as `group`, oc.surfcms_content_type as type, oc.surfcms_content_show_in_nav as nav, oc.surfcms_content_url as url, oc.surfcms_content_menu_parent as parent, oc.surfcms_content_menu_icon as icon, oc.surfcms_content_sort_order as sort_order, oc.surfcms_content_administrators as admins, ocd.surfcms_content_menu_text as menu_text, ocd.surfcms_content_meta_title as meta_title, ocd.surfcms_content_body as body from surfcms_content oc, surfcms_content_description ocd where oc.surfcms_content_id = ocd.surfcms_content_id and oc.surfcms_content_status = '1'" . $where . " and ocd.language_id = '" . (int)$languages_id . "'" . $order); // assemble nodes per ID while ( $item_row = tep_db_fetch_array($item_query) ) { $item_row['link'] = $this->getLink($item_row['id'], $item_row['type'], $item_row['group'], $item_row['url']); // compile sets with sub-menu items below parents with IDs as keys if ( (int)$item_row['parent'] == 0 || $nav == 'box' ) { if ( isset($navigation[$item_row['id']]) && is_array( $navigation[$item_row['id']]['sub'] ) ) { $item_row['sub'] = $navigation[$item_row['id']]['sub']; } // add existing [sub] to $item_row $navigation[$item_row['id']] = $item_row; } else { $navigation[$item_row['parent']]['sub'][$item_row['id']] = $item_row; } } // rearrange with sort_order as keys if ( count($navigation) ) { $return = array(); if ($nav == 'navbar') { // separate and sort nav items foreach ( $navigation as $data ) { if ( isset($data['type']) ) { // skip disabled top menu items for ($i=0; isset($return[$data['nav']][((int)$data['sort_order']+$i)]); $i++) {} $return[$data['nav']][((int)$data['sort_order']+$i)] = $data; } } // sort left and right nav groups. home should only contain one if (count($return['2'])) ksort($return['2']); if (count($return['3'])) ksort($return['3']); } elseif ($nav == 'box') { foreach ( $navigation as $data ) { for ($i=0; isset($return[((int)$data['sort_order']+$i)]); $i++) {} $return[((int)$data['sort_order']+$i)] = $data; } if (count($return)) ksort($return); } } return $return; } // ///////////////////////////////////////////////////// // Get Link // public function getLink($id, $type = null, $group = null, $url = null) { $return = false; if (function_exists('tep_catalog_href_link')) { $funct = 'tep_catalog_href_link'; } else { $funct = 'tep_href_link'; } if ( !isset($type) || !isset($group) ) { $item_query = tep_db_query("select oc.surfcms_content_group, oc.surfcms_content_type, oc.surfcms_content_url from surfcms_content oc where oc.surfcms_content_id = '" . $id . "' limit 1"); if ( $item_row = tep_db_fetch_array($item_query) ) { $group = $item_row['surfcms_content_group']; $type = $item_row['surfcms_content_type']; $url = $item_row['surfcms_content_url']; } } if ( tep_not_null($type) && $type == '4' ) { $return = $url; } elseif ( tep_not_null($type) && $type == '3' ) { $return = '#'; } elseif (tep_not_null($group) && file_exists(DIR_FS_CATALOG . $group . '.php')) { $return = $funct($group . '.php', (tep_not_null($url) ? ltrim($url,'?') : '')); } else { $return = $funct('surfcms.php', 'pg=' . $id); } return $return; } // ///////////////////////////////////////////////////// // Type Conversion // public function navGroup($enum) { switch ($enum) { case '1': $return = 'navbar_modules_home'; break; case '2': $return = 'navbar_modules_left'; break; case '3': $return = 'navbar_modules_right'; break; } return $return; } public function typeValue($type) { switch ($type) { case $this->getDef('text_content_type_page'): $return = '0'; break; case $this->getDef('text_content_type_content'): $return = '1'; break; case $this->getDef('text_content_type_block'): $return = '2'; break; case $this->getDef('text_content_type_sub_menu'): $return = '3'; break; case $this->getDef('text_content_type_menu_link'): $return = '4'; break; } return $return; } public function typeName($type) { switch ((string)$type) { case '0': $return = $this->getDef('text_content_type_page'); break; case '1': $return = $this->getDef('text_content_type_content'); break; case '2': $return = $this->getDef('text_content_type_block'); break; case '3': $return = $this->getDef('text_content_type_sub_menu'); break; case '4': $return = $this->getDef('text_content_type_menu_link'); break; } return $return; } // ///////////////////////////////////////////////////// // Nav Templates // public function navNode($node) { ob_start(); include(DIR_FS_CATALOG . 'includes/apps/surfcms/core/templates/nav_node.php'); $data = ob_get_clean(); return $data; } public function navSubmenuNode($node) { ob_start(); include(DIR_FS_CATALOG . 'includes/apps/surfcms/core/templates/nav_sub_menu_node.php'); $data = ob_get_clean(); return $data; } // ///////////////////////////////////////////////////// // Admin Access Restrictions // // returns array of restricted admins public function access_installed() { return file_exists(DIR_FS_CATALOG . 'includes/apps/surfcms/admin/utilities_modules/access_administrator.php'); } // returns array of restricted admins public function restricted_admins() { if ( !isset($this->_restricted_admins) ) { if ( $this->access_installed() ) { $admins_config = tep_db_fetch_array(tep_db_query("SELECT configuration_value as users FROM configuration WHERE configuration_key LIKE 'SURFCMS_MODULE_CONTENT_ADMIN_GROUP'")); if ( !empty($admins_config['users']) ) $this->_restricted_admins = explode(',', $admins_config['users']); } if ( !isset($this->_restricted_admins) ) $this->_restricted_admins = array(); } return $this->_restricted_admins; } // returns array of restricted utilities public function restricted_utilities() { if ( !isset($this->_restricted_utilities) ) { if ( $this->access_installed() ) { $utilities_config = tep_db_fetch_array(tep_db_query("SELECT configuration_value as utilities FROM configuration WHERE configuration_key LIKE 'SURFCMS_MODULE_CONTENT_UTILITY_GROUP'")); if ( !empty($utilities_config['utilities']) ) $this->_restricted_utilities = explode(',', $utilities_config['utilities']); } if ( !isset($this->_restricted_utilities) ) $this->_restricted_utilities = array(); } return $this->_restricted_utilities; } // returns array of restricted list boxes public function restricted_lists() { if ( !isset($this->_restricted_lists) ) { if ( $this->access_installed() ) { $lists_config = tep_db_fetch_array(tep_db_query("SELECT configuration_value as lists FROM configuration WHERE configuration_key LIKE 'SURFCMS_MODULE_CONTENT_LIST_GROUP'")); if ( !empty($lists_config['lists']) ) $this->_restricted_lists = explode(',', $lists_config['lists']); } if ( !isset($this->_restricted_lists) ) $this->_restricted_lists = array(); } return $this->_restricted_lists; } // returns array of all admins // if $id is passed, method returns associated name // if $id is array, return array of admin names public function admins($id = null) { if ( !isset($this->_admins) ) { if ( $this->access_installed() ) { $this->_admins = array(); $admin_query = tep_db_query("SELECT id, user_name FROM administrators"); while ( $item_row = tep_db_fetch_array($admin_query) ) { $this->_admins[$item_row['id']] = $item_row['user_name']; } } else { $this->_admins = array(); } } if ($id != null && is_array($id)) return array_uintersect_uassoc($this->_admins, $id, function($a, $b) { return 0; }, function($a, $b) { if ($a == $b) return 0; else return -1; } ); elseif ($id != null) return $this->_admins[$id]; else return $this->_admins; } // Returns true if $admin is in restricted list AND $item is NULL // Returns true if $admin is in restricted list AND $item is in its restricted list public function isRestricted($admin_id = null, $item = null) { return ( in_array($admin_id, $this->restricted_admins()) && ( (($item == null) || (($item != null) && in_array($item, $this->restricted_utilities()))) || (($item == null) || (($item != null) && in_array($item, $this->restricted_lists()))) ) ); } // ///////////////////////////////////////////////////// // Configuration Group ID // public function getConfigID() { if (!isset($this->_config_id)) { $config = tep_db_fetch_array(tep_db_query("SELECT `configuration_value` as id FROM `configuration` WHERE `configuration_key` LIKE 'SURFCMS_CONFIGURATION_GROUP' LIMIT 1")); $this->_config_id = $config['id']; } return $this->_config_id; } // ///////////////////////////////////////////////////// // Version Control // public function checkVersion() { if ( isset($this->_version) ) { // get Data version $surfcms_config_query = tep_db_query("SELECT `configuration_value` as vers FROM `configuration` WHERE `configuration_key` = 'SURFCMS_VERSION_INSTALLED'"); if ($surfcms_config = tep_db_fetch_array($surfcms_config_query)) { $db_version = $surfcms_config['vers']; } else { trigger_error($this->getAppTitle() . $this->getDef('db_version_error')); } // check for install/update if ( isset($db_version) ) { if ( $this->_version != $db_version ) { trigger_error($this->getAppTitle() . sprintf($this->getDef('db_update_warning'),$db_version,$this->_version)); $this->updateApp(); } } else { trigger_error($this->getAppTitle() . sprintf($this->getDef('db_installation_warning'),$this->_version)); $this->installApp(); } } return $this->_version; } public function installApp() { surfcms_app_setup::i()->installDatabase($this->getVersion()); return true; } public function updateApp() { surfcms_app_setup::i()->updateDatabase($this->getVersion()); return true; } } // class surfcms ?>
  8. when I change to if (count(array($return['2']))) than it displays two warnings: Warning: ksort() expects parameter 1 to be array, null given in /home/mystore/ftp/sklep4/includes/apps/surfcms/surfcms.class.php on line 210 Warning: Invalid argument supplied for foreach() in /home/mystore/ftp/sklep4/includes/modules/content/navigation/cm_surfcms_navbar.php on line 63
  9. Demitry, Bonbec you guys are amazing . I have looked at this file so many times and i have not seen a duplicate classes. One warning left: Warning: count(): Parameter must be an array or an object that implements Countable in /home/mystore/ftp/sklep4/includes/apps/surfcms/surfcms.class.php on line 208 and the various bugs he mentioned Dimitry. Thanks for help
  10. <?php define('HTTP_SERVER', 'https://www.mystore.com.pl'); define('HTTPS_SERVER', 'https://www.mystore.com.pl'); define('ENABLE_SSL', true); define('HTTP_COOKIE_DOMAIN', ''); define('HTTPS_COOKIE_DOMAIN', ''); define('HTTP_COOKIE_PATH', '/'); define('HTTPS_COOKIE_PATH', '/'); define('DIR_WS_HTTP_CATALOG', '/'); define('DIR_WS_HTTPS_CATALOG', '/'); define('DIR_WS_CLASSES', DIR_WS_INCLUDES . 'classes/'); define('DIR_FS_CATALOG', '/home/mystore/ftp/sklep4/'); define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG . 'download/'); define('DIR_FS_DOWNLOAD_PUBLIC', DIR_FS_CATALOG . 'pub/'); define('DIR_WS_IMAGES', 'images/'); define('DIR_WS_ICONS', DIR_WS_IMAGES . 'icons/'); # define('DIR_WS_INCLUDES', 'includes/'); define('DIR_WS_INCLUDES', '/home/mystore/ftp/sklep4/includes/'); define('DIR_WS_FUNCTIONS', DIR_WS_INCLUDES . 'functions/'); define('DIR_WS_CLASSES', DIR_WS_INCLUDES . 'classes/'); define('DIR_WS_MODULES', DIR_WS_INCLUDES . 'modules/'); define('DIR_WS_LANGUAGES', DIR_WS_INCLUDES . 'languages/') Line 11: define('DIR_WS_CLASSES', DIR_WS_INCLUDES . 'classes/'); In Admin settings: -Use Cache -false Session Directory /home/mystore/ftp/sklep4/includes/work/ Force Cookie Use False Check SSL Session ID False Check User Agent False Check IP Address False Prevent Spider Sessions True Recreate Session True
  11. I want to find fromabove errors you can see - just don't understand where is the error (ex Use of undefined constant DIR_WS_INCLUDES - assumed 'DIR_WS_INCLUDES' ) in configure.php everything is ok. How to find out which file is sowing error?
  12. This version of the store has been around for about 3 years. I have an entry in configure: define ('DIR_WS_INCLUDES', 'includes /') ;, I also changed to define ('DIR_WS_INCLUDES', '/ home /mystore / ftp / sklep4 / includes /'); but it didn't do anything. For a long time, I have had a problem with cookies, which means that every few days the store stops (customers when trying to log in or go from the cart further receive a warning in the form of cookie_usage.php). Only clearing the server cache improves performance for 3-4 days and the problem returns. The PHP version is 7.2 and I can't go any further and I have the impression that the problem appeared when the version was changed from 7.1 to 7.2 and additionally only CDN servers were introduced. I have put hundreds of hours into this shop and I can't save it :( .. I don't know anyone but you who would be able to help me.
  13. My shop generates few errors, please help me solve them (version 2.3.4.1 CE): Can I pass the page safely or is it better to leave "mysite" ? Warning: Use of undefined constant DIR_WS_INCLUDES - assumed 'DIR_WS_INCLUDES' (this will throw an Error in a future version of PHP) in /home/mysite/ftp/sklep4/includes/configure.php on line 11 Warning: session_set_save_handler(): Cannot change save handler when headers already sent in /home/mysite/ftp/sklep4/includes/functions/sessions.php on line 62 Warning: session_name(): Cannot change session name when headers already sent in /home/mysite/ftp/sklep4/includes/functions/sessions.php on line 148 Warning: session_save_path(): Cannot change save path when headers already sent in /home/mysite/ftp/sklep4/includes/functions/sessions.php on line 175 Warning: session_set_cookie_params(): Cannot change session cookie parameters when headers already sent in /home/mysite/ftp/sklep4/includes/application_top.php on line 155 Warning: session_start(): Cannot start session when headers already sent in /home/mysite/ftp/sklep4/includes/functions/sessions.php on line 101 Warning: extract() expects parameter 1 to be array, null given in /home/mysite/ftp/sklep4/includes/application_top.php on line 210 Warning: Cannot modify header information - headers already sent by (output started at /home/mysite/ftp/sklep4/includes/configure.php:11) in /home/mysite/ftp/sklep4/includes/functions/general.php on line 49
  14. general.php <?php /* $Id$ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2014 osCommerce Released under the GNU General Public License */ //// // Get the installed version number function tep_get_version() { static $v; if (!isset($v)) { $v = trim(implode('', file(DIR_FS_CATALOG . 'includes/version.php'))); } return $v; } //// // Stop from parsing any further PHP code // v2.3.3.1 now closes the session through a registered shutdown function function tep_exit() { exit; } //// // Redirect to another page or site function tep_redirect($url) { if ( (strstr($url, "\n") != false) || (strstr($url, "\r") != false) ) { tep_redirect(tep_href_link('index.php', '', 'NONSSL', false)); } if ( (ENABLE_SSL == true) && (getenv('HTTPS') == 'on') ) { // We are loading an SSL page if (substr($url, 0, strlen(HTTP_SERVER . DIR_WS_HTTP_CATALOG)) == HTTP_SERVER . DIR_WS_HTTP_CATALOG) { // NONSSL url $url = HTTPS_SERVER . DIR_WS_HTTPS_CATALOG . substr($url, strlen(HTTP_SERVER . DIR_WS_HTTP_CATALOG)); // Change it to SSL } } if ( strpos($url, '&amp;') !== false ) { $url = str_replace('&amp;', '&', $url); } 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('"' => '&quot;')); } 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) { $patterns = array ('/ +/','/[<>]/'); $replace = array (' ', '_'); return preg_replace($patterns, $replace, trim($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 = 1"); $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="text-danger"><b>' . STOCK_MARK_PRODUCT_OUT_OF_STOCK . '</b></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 = '') { if (!is_array($exclude_array)) $exclude_array = array(); $get_url = ''; if (is_array($_GET) && (sizeof($_GET) > 0)) { foreach($_GET as $key => $value) { if ( is_string($value) && (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) { return stristr($_SERVER['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; static $tax_rates = array(); 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; } } if (!isset($tax_rates[$class_id][$country_id][$zone_id]['rate'])) { $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); } $tax_rates[$class_id][$country_id][$zone_id]['rate'] = ($tax_multiplier - 1.0) * 100; } else { $tax_rates[$class_id][$country_id][$zone_id]['rate'] = 0; } } return $tax_rates[$class_id][$country_id][$zone_id]['rate']; } //// // Return the tax description for a zone / class // TABLES: tax_rates; function tep_get_tax_description($class_id, $country_id, $zone_id) { static $tax_rates = array(); if (!isset($tax_rates[$class_id][$country_id][$zone_id]['description'])) { $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); $tax_rates[$class_id][$country_id][$zone_id]['description'] = $tax_description; } else { $tax_rates[$class_id][$country_id][$zone_id]['description'] = TEXT_UNKNOWN_TAX_RATE; } } return $tax_rates[$class_id][$country_id][$zone_id]['description']; } //// // Add tax to a products price function tep_add_tax($price, $tax) { if ( (DISPLAY_PRICE_WITH_TAX == 'true') && ($tax > 0) ) { return $price + tep_calculate_tax($price, $tax); } else { return $price; } } // Calculates Tax rounding the result function tep_calculate_tax($price, $tax) { return $price * $tax / 100; } //// // 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']['title']); } 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 ($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") { if (is_array($address_id) && !empty($address_id)) { return tep_address_format($address_id['address_format_id'], $address_id, $html, $boln, $eoln); } $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 . '&nbsp;&nbsp;'); } } 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 preg_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)); //wyniki wyszukiwania z polskimi literami function tep_parse_search_string($search_str = '', &$objects) { $search_str = trim($search_str); $search_str = mb_convert_case($search_str, MB_CASE_LOWER, "utf-8"); // Break up $search_str on whitespace; quoted string will be reconstructed later $pieces = preg_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(preg_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(preg_replace('/"/', ' ', $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(preg_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($PHP_SELF, tep_get_all_get_params(array('info', 'sort', 'page')) . '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) { if (is_numeric($prid)) { $uprid = (int)$prid; if (is_array($params) && (sizeof($params) > 0)) { $attributes_check = true; $attributes_ids = ''; foreach($params as $option => $value) { if (is_numeric($option) && is_numeric($value)) { $attributes_ids .= '{' . (int)$option . '}' . (int)$value; } else { $attributes_check = false; break; } } if ($attributes_check == true) { $uprid .= $attributes_ids; } } } else { $uprid = tep_get_prid($prid); if (is_numeric($uprid)) { if (strpos($prid, '{') !== false) { $attributes_check = true; $attributes_ids = ''; // strpos()+1 to remove up to and including the first { which would create an empty array element in explode() $attributes = explode('{', substr($prid, strpos($prid, '{')+1)); for ($i=0, $n=sizeof($attributes); $i<$n; $i++) { $pair = explode('}', $attributes[$i]); if (is_numeric($pair[0]) && is_numeric($pair[1])) { $attributes_ids .= '{' . (int)$pair[0] . '}' . (int)$pair[1]; } else { $attributes_check = false; break; } } if ($attributes_check == true) { $uprid .= $attributes_ids; } } } else { return false; } } return $uprid; } //// // Return a product ID from a product ID with attributes function tep_get_prid($uprid) { $pieces = explode('{', $uprid); if (is_numeric($pieces[0])) { return (int)$pieces[0]; } else { return false; } } //// //! 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. jan.wildeboer@gmx.de // $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. info@mytepshop.com 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(); // 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 = preg_split('/' . $needle . '/', $string); return sizeof($temp_array); } function tep_count_modules($modules = '') { $count = 0; if (empty($modules)) return $count; $modules_array = explode(';', $modules); for ($i=0, $n=sizeof($modules_array); $i<$n; $i++) { $class = substr($modules_array[$i], 0, strrpos($modules_array[$i], '.')); if (isset($GLOBALS[$class]) && is_object($GLOBALS[$class])) { if ($GLOBALS[$class]->enabled) { $count++; } } } return $count; } function tep_count_payment_modules() { return tep_count_modules(MODULE_PAYMENT_INSTALLED); } function tep_count_shipping_modules() { return tep_count_modules(MODULE_SHIPPING_INSTALLED); } function tep_create_random_value($length, $type = 'mixed') { if ( ($type != 'mixed') && ($type != 'chars') && ($type != 'digits')) $type = 'mixed'; $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $digits = '0123456789'; $base = ''; if ( ($type == 'mixed') || ($type == 'chars') ) { $base .= $chars; } if ( ($type == 'mixed') || ($type == 'digits') ) { $base .= $digits; } $value = ''; if (!class_exists('PasswordHash')) { include('includes/classes/passwordhash.php'); } $hasher = new PasswordHash(10, true); do { $random = base64_encode($hasher->get_random_bytes($length)); for ($i = 0, $n = strlen($random); $i < $n; $i++) { $char = substr($random, $i, 1); if ( strpos($base, $char) !== false ) { $value .= $char; } } } while ( strlen($value) < $length ); if ( strlen($value) > $length ) { $value = substr($value, 0, $length); } return $value; } function tep_array_to_string($array, $exclude = '', $equals = '=', $separator = '&') { if (!is_array($exclude)) $exclude = array(); $get_string = ''; if (sizeof($array) > 0) { foreach($array as $key => $value) { if ( (!in_array($key, $exclude)) && ($key != 'x') && ($key != 'y') ) { $get_string .= $key . $equals . $value . $separator; } } $remove_chars = strlen($separator); $get_string = substr($get_string, 0, -$remove_chars); } return $get_string; } function tep_not_null($value) { if (is_array($value)) { if (sizeof($value) > 0) { return true; } else { return false; } } else { if (($value != '') && (strtolower($value) != 'null') && (strlen(trim($value)) > 0)) { return true; } else { return false; } } } //// // Output the tax percentage with optional padded decimals function tep_display_tax_value($value, $padding = TAX_DECIMAL_PLACES) { if (strpos($value, '.')) { $loop = true; while ($loop) { if (substr($value, -1) == '0') { $value = substr($value, 0, -1); } else { $loop = false; if (substr($value, -1) == '.') { $value = substr($value, 0, -1); } } } } if ($padding > 0) { if ($decimal_pos = strpos($value, '.')) { $decimals = strlen(substr($value, ($decimal_pos+1))); for ($i=$decimals; $i<$padding; $i++) { $value .= '0'; } } else { $value .= '.'; for ($i=0; $i<$padding; $i++) { $value .= '0'; } } } return $value; } //// // Checks to see if the currency code exists as a currency // TABLES: currencies function tep_currency_exists($code) { $code = tep_db_prepare_input($code); $currency_query = tep_db_query("select code from " . TABLE_CURRENCIES . " where code = '" . tep_db_input($code) . "' limit 1"); if (tep_db_num_rows($currency_query)) { $currency = tep_db_fetch_array($currency_query); return $currency['code']; } else { return false; } } function tep_string_to_int($string) { return (int)$string; } //// // Parse and secure the cPath parameter values function tep_parse_category_path($cPath) { // make sure the category IDs are integers $cPath_array = array_map('tep_string_to_int', explode('_', $cPath)); // make sure no duplicate category IDs exist which could lock the server in a loop $tmp_array = array(); $n = sizeof($cPath_array); for ($i=0; $i<$n; $i++) { if (!in_array($cPath_array[$i], $tmp_array)) { $tmp_array[] = $cPath_array[$i]; } } return $tmp_array; } //// // Return a random value function tep_rand($min = null, $max = null) { static $seeded; if (!isset($seeded)) { $seeded = true; if ( (PHP_VERSION < '4.2.0') ) { mt_srand((double)microtime()*1000000); } } if (isset($min) && isset($max)) { if ($min >= $max) { return $min; } else { return mt_rand($min, $max); } } else { return mt_rand(); } } function tep_setcookie($name, $value = '', $expire = 0, $path = '/', $domain = '', $secure = 0) { setcookie($name, $value, $expire, $path, (tep_not_null($domain) ? $domain : ''), $secure); } function tep_validate_ip_address($ip_address) { if (function_exists('filter_var') && defined('FILTER_VALIDATE_IP')) { return filter_var($ip_address, FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV4)); } if (preg_match('/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/', $ip_address)) { $parts = explode('.', $ip_address); foreach ($parts as $ip_parts) { if ( ((int)($ip_parts) > 255) || ((int)($ip_parts) < 0) ) { return false; // number is not within 0-255 } } return true; } return false; } function tep_get_ip_address() { global $_SERVER; $ip_address = null; $ip_addresses = array(); if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && !empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { foreach ( array_reverse(explode(',', $_SERVER['HTTP_X_FORWARDED_FOR'])) as $x_ip ) { $x_ip = trim($x_ip); if (tep_validate_ip_address($x_ip)) { $ip_addresses[] = $x_ip; } } } if (isset($_SERVER['HTTP_CLIENT_IP']) && !empty($_SERVER['HTTP_CLIENT_IP'])) { $ip_addresses[] = $_SERVER['HTTP_CLIENT_IP']; } if (isset($_SERVER['HTTP_X_CLUSTER_CLIENT_IP']) && !empty($_SERVER['HTTP_X_CLUSTER_CLIENT_IP'])) { $ip_addresses[] = $_SERVER['HTTP_X_CLUSTER_CLIENT_IP']; } if (isset($_SERVER['HTTP_PROXY_USER']) && !empty($_SERVER['HTTP_PROXY_USER'])) { $ip_addresses[] = $_SERVER['HTTP_PROXY_USER']; } $ip_addresses[] = $_SERVER['REMOTE_ADDR']; foreach ( $ip_addresses as $ip ) { if (!empty($ip) && tep_validate_ip_address($ip)) { $ip_address = $ip; break; } } return $ip_address; } function tep_count_customer_orders($id = '', $check_session = true) { global $customer_id, $languages_id; if (is_numeric($id) == false) { if (tep_session_is_registered('customer_id')) { $id = $customer_id; } else { return 0; } } if ($check_session == true) { if ( (tep_session_is_registered('customer_id') == false) || ($id != $customer_id) ) { return 0; } } $orders_check_query = tep_db_query("select count(*) as total from " . TABLE_ORDERS . " o, " . TABLE_ORDERS_STATUS . " s where o.customers_id = '" . (int)$id . "' and o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and s.public_flag = '1'"); $orders_check = tep_db_fetch_array($orders_check_query); return $orders_check['total']; } function tep_count_customer_address_book_entries($id = '', $check_session = true) { global $customer_id; if (is_numeric($id) == false) { if (tep_session_is_registered('customer_id')) { $id = $customer_id; } else { return 0; } } if ($check_session == true) { if ( (tep_session_is_registered('customer_id') == false) || ($id != $customer_id) ) { return 0; } } $addresses_query = tep_db_query("select count(*) as total from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$id . "'"); $addresses = tep_db_fetch_array($addresses_query); return $addresses['total']; } // nl2br() prior PHP 4.2.0 did not convert linefeeds on all OSs (it only converted \n) function tep_convert_linefeeds($from, $to, $string) { if ((PHP_VERSION < "4.0.5") && is_array($from)) { return preg_replace('/(' . implode('|', $from) . ')/', $to, $string); } else { return str_replace($from, $to, $string); } }
  15. Warning in application top: // set the session cookie parameters if (function_exists('session_set_cookie_params')) { session_set_cookie_params(0, $cookie_path, $cookie_domain); } elseif (function_exists('ini_set')) { ini_set('session.cookie_lifetime', '0'); ini_set('session.cookie_path', $cookie_path); ini_set('session.cookie_domain', $cookie_domain); } next warning in application_top: if ( ($session_started == true) && (PHP_VERSION >= 4.3) && function_exists('ini_get') && (ini_get('register_globals') == false) ) { extract($_SESSION, EXTR_OVERWRITE+EXTR_REFS); }
×