| [ Index ] |
PHP Cross Reference of osCMax 2.0.4 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 $Id: application_top.php 3 2006-05-27 04:59:07Z user $ 4 5 osCMax Power E-Commerce 6 http://oscdox.com 7 8 Copyright 2006 osCMax 9 10 Released under the GNU General Public License 11 */ 12 13 // start the timer for the page parse time log 14 define('PAGE_PARSE_START_TIME', microtime()); 15 //LINE ADDED 16 $debug = array(); 17 18 // set the level of error reporting 19 error_reporting(E_ALL & ~E_NOTICE); 20 21 // check support for register_globals 22 if (function_exists('ini_get') && (ini_get('register_globals') == false) && (PHP_VERSION < 4.3) ) { 23 exit('Server Requirement Error: register_globals is disabled in your PHP configuration. This can be enabled in your php.ini configuration file or in the .htaccess file in your catalog directory. Please use PHP 4.3+ if register_globals cannot be enabled on the server.'); 24 } 25 // LINE ADDED: added to support PHP 5.0.x by TJ 26 $HTTP_GET_VARS = $_GET; $HTTP_POST_VARS = $_POST; 27 28 // Set the local configuration parameters - mainly for developers 29 if (file_exists('includes/local/configure.php')) include('includes/local/configure.php'); 30 31 // include server parameters 32 require ('includes/configure.php'); 33 34 if (strlen(DB_SERVER) < 1) { 35 if (is_dir('install')) { 36 header('Location: install/index.php'); 37 } 38 } 39 40 // define the project version 41 define('PROJECT_VERSION', 'osCMax v2.0.4'); 42 43 // some code to solve compatibility issues 44 require (DIR_WS_FUNCTIONS . 'compatibility.php'); 45 46 // set the type of request (secure or not) 47 $request_type = (getenv('HTTPS') == 'on') ? 'SSL' : 'NONSSL'; 48 49 // set php_self in the local scope 50 if (!isset($PHP_SELF)) $PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF']; 51 52 if ($request_type == 'NONSSL') { 53 define('DIR_WS_CATALOG', DIR_WS_HTTP_CATALOG); 54 } else { 55 define('DIR_WS_CATALOG', DIR_WS_HTTPS_CATALOG); 56 } 57 58 // include the list of project filenames 59 require (DIR_WS_INCLUDES . 'filenames.php'); 60 61 // include the list of project database tables 62 require (DIR_WS_INCLUDES . 'database_tables.php'); 63 64 // customization for the design layout 65 define('BOX_WIDTH', 125); // how wide the boxes should be in pixels (default: 125) 66 67 // include the database functions 68 require (DIR_WS_FUNCTIONS . 'database.php'); 69 70 // make a connection to the database... now 71 tep_db_connect() or die('Unable to connect to database server!'); 72 73 // set the application parameters 74 $configuration_query = tep_db_query('select configuration_key as cfgKey, configuration_value as cfgValue from ' . TABLE_CONFIGURATION); 75 while ($configuration = tep_db_fetch_array($configuration_query)) { 76 define($configuration['cfgKey'], $configuration['cfgValue']); 77 } 78 79 // if gzip_compression is enabled, start to buffer the output 80 if ( (GZIP_COMPRESSION == 'true') && ($ext_zlib_loaded = extension_loaded('zlib')) && (PHP_VERSION >= '4') ) { 81 if (($ini_zlib_output_compression = (int)ini_get('zlib.output_compression')) < 1) { 82 if (PHP_VERSION >= '4.0.4') { 83 ob_start('ob_gzhandler'); 84 } else { 85 include (DIR_WS_FUNCTIONS . 'gzip_compression.php'); 86 ob_start(); 87 ob_implicit_flush(); 88 } 89 } else { 90 ini_set('zlib.output_compression_level', GZIP_LEVEL); 91 } 92 } 93 94 // set the HTTP GET parameters manually if search_engine_friendly_urls is enabled 95 if (SEARCH_ENGINE_FRIENDLY_URLS == 'true') { 96 if (strlen(getenv('PATH_INFO')) > 1) { 97 $GET_array = array(); 98 $PHP_SELF = str_replace(getenv('PATH_INFO'), '', $PHP_SELF); 99 $vars = explode('/', substr(getenv('PATH_INFO'), 1)); 100 for ($i=0, $n=sizeof($vars); $i<$n; $i++) { 101 if (strpos($vars[$i], '[]')) { 102 $GET_array[substr($vars[$i], 0, -2)][] = $vars[$i+1]; 103 } else { 104 $HTTP_GET_VARS[$vars[$i]] = $vars[$i+1]; 105 } 106 $i++; 107 } 108 109 if (sizeof($GET_array) > 0) { 110 while (list($key, $value) = each($GET_array)) { 111 $HTTP_GET_VARS[$key] = $value; 112 } 113 } 114 } 115 } 116 117 // define general functions used application-wide 118 require (DIR_WS_FUNCTIONS . 'general.php'); 119 require (DIR_WS_FUNCTIONS . 'html_output.php'); 120 121 // set the cookie domain 122 $cookie_domain = (($request_type == 'NONSSL') ? HTTP_COOKIE_DOMAIN : HTTPS_COOKIE_DOMAIN); 123 $cookie_path = (($request_type == 'NONSSL') ? HTTP_COOKIE_PATH : HTTPS_COOKIE_PATH); 124 125 // include cache functions if enabled 126 if (USE_CACHE == 'true') include (DIR_WS_FUNCTIONS . 'cache.php'); 127 128 // BOF: MOD - Wishlist 3.5 129 // include wishlist class 130 require (DIR_WS_CLASSES . 'wishlist.php'); 131 // EOF: MOD - Wishlist 3.5 132 133 // include shopping cart class 134 require (DIR_WS_CLASSES . 'shopping_cart.php'); 135 136 // include navigation history class 137 require (DIR_WS_CLASSES . 'navigation_history.php'); 138 139 // check if sessions are supported, otherwise use the php3 compatible session class 140 if (!function_exists('session_start')) { 141 define('PHP_SESSION_NAME', 'osCsid'); 142 define('PHP_SESSION_PATH', $cookie_path); 143 define('PHP_SESSION_DOMAIN', $cookie_domain); 144 define('PHP_SESSION_SAVE_PATH', SESSION_WRITE_DIRECTORY); 145 146 include (DIR_WS_CLASSES . 'sessions.php'); 147 } 148 149 // define how the session functions will be used 150 require (DIR_WS_FUNCTIONS . 'sessions.php'); 151 152 // set the session name and save path 153 tep_session_name('osCsid'); 154 tep_session_save_path(SESSION_WRITE_DIRECTORY); 155 156 // set the session cookie parameters 157 if (function_exists('session_set_cookie_params')) { 158 session_set_cookie_params(0, $cookie_path, $cookie_domain); 159 } elseif (function_exists('ini_set')) { 160 ini_set('session.cookie_lifetime', '0'); 161 ini_set('session.cookie_path', $cookie_path); 162 ini_set('session.cookie_domain', $cookie_domain); 163 } 164 165 // set the session ID if it exists 166 if (isset($HTTP_POST_VARS[tep_session_name()])) { 167 tep_session_id($HTTP_POST_VARS[tep_session_name()]); 168 } elseif ( ($request_type == 'SSL') && isset($HTTP_GET_VARS[tep_session_name()]) ) { 169 tep_session_id($HTTP_GET_VARS[tep_session_name()]); 170 } 171 172 // start the session 173 $session_started = false; 174 if (SESSION_FORCE_COOKIE_USE == 'True') { 175 tep_setcookie('cookie_test', 'please_accept_for_session', time()+60*60*24*30, $cookie_path, $cookie_domain); 176 177 if (isset($HTTP_COOKIE_VARS['cookie_test'])) { 178 tep_session_start(); 179 $session_started = true; 180 } 181 } elseif (SESSION_BLOCK_SPIDERS == 'True') { 182 $user_agent = strtolower(getenv('HTTP_USER_AGENT')); 183 $spider_flag = false; 184 185 if (tep_not_null($user_agent)) { 186 $spiders = file(DIR_WS_INCLUDES . 'spiders.txt'); 187 188 for ($i=0, $n=sizeof($spiders); $i<$n; $i++) { 189 if (tep_not_null($spiders[$i])) { 190 if (is_integer(strpos($user_agent, trim($spiders[$i])))) { 191 $spider_flag = true; 192 break; 193 } 194 } 195 } 196 } 197 198 if ($spider_flag == false) { 199 tep_session_start(); 200 $session_started = true; 201 } 202 } else { 203 tep_session_start(); 204 $session_started = true; 205 } 206 207 if ( ($session_started == true) && (PHP_VERSION >= 4.3) && function_exists('ini_get') && (ini_get('register_globals') == false) ) { 208 extract($_SESSION, EXTR_OVERWRITE+EXTR_REFS); 209 } 210 211 // set SID once, even if empty 212 $SID = (defined('SID') ? SID : ''); 213 214 // verify the ssl_session_id if the feature is enabled 215 if ( ($request_type == 'SSL') && (SESSION_CHECK_SSL_SESSION_ID == 'True') && (ENABLE_SSL == true) && ($session_started == true) ) { 216 $ssl_session_id = getenv('SSL_SESSION_ID'); 217 if (!tep_session_is_registered('SSL_SESSION_ID')) { 218 $SESSION_SSL_ID = $ssl_session_id; 219 tep_session_register('SESSION_SSL_ID'); 220 } 221 222 if ($SESSION_SSL_ID != $ssl_session_id) { 223 tep_session_destroy(); 224 tep_redirect(tep_href_link(FILENAME_SSL_CHECK)); 225 } 226 } 227 228 // verify the browser user agent if the feature is enabled 229 if (SESSION_CHECK_USER_AGENT == 'True') { 230 $http_user_agent = getenv('HTTP_USER_AGENT'); 231 if (!tep_session_is_registered('SESSION_USER_AGENT')) { 232 $SESSION_USER_AGENT = $http_user_agent; 233 tep_session_register('SESSION_USER_AGENT'); 234 } 235 236 if ($SESSION_USER_AGENT != $http_user_agent) { 237 tep_session_destroy(); 238 tep_redirect(tep_href_link(FILENAME_LOGIN)); 239 } 240 } 241 242 // verify the IP address if the feature is enabled 243 if (SESSION_CHECK_IP_ADDRESS == 'True') { 244 $ip_address = tep_get_ip_address(); 245 if (!tep_session_is_registered('SESSION_IP_ADDRESS')) { 246 $SESSION_IP_ADDRESS = $ip_address; 247 tep_session_register('SESSION_IP_ADDRESS'); 248 } 249 250 if ($SESSION_IP_ADDRESS != $ip_address) { 251 tep_session_destroy(); 252 tep_redirect(tep_href_link(FILENAME_LOGIN)); 253 } 254 } 255 256 // create the shopping cart & fix the cart if necesary 257 if (tep_session_is_registered('cart') && is_object($cart)) { 258 if (PHP_VERSION < 4) { 259 $broken_cart = $cart; 260 $cart = new shoppingCart; 261 $cart->unserialize($broken_cart); 262 } 263 } else { 264 tep_session_register('cart'); 265 $cart = new shoppingCart; 266 } 267 268 // include currencies class and create an instance 269 require (DIR_WS_CLASSES . 'currencies.php'); 270 $currencies = new currencies(); 271 272 // include the mail classes 273 require (DIR_WS_CLASSES . 'mime.php'); 274 require (DIR_WS_CLASSES . 'email.php'); 275 276 // set the language 277 if (!tep_session_is_registered('language') || isset($HTTP_GET_VARS['language'])) { 278 if (!tep_session_is_registered('language')) { 279 tep_session_register('language'); 280 tep_session_register('languages_id'); 281 } 282 283 include (DIR_WS_CLASSES . 'language.php'); 284 $lng = new language(); 285 286 if (isset($HTTP_GET_VARS['language']) && tep_not_null($HTTP_GET_VARS['language'])) { 287 $lng->set_language($HTTP_GET_VARS['language']); 288 } else { 289 $lng->get_browser_language(); 290 } 291 292 $language = $lng->language['directory']; 293 $languages_id = $lng->language['id']; 294 } 295 296 // include the language translations 297 require(DIR_WS_LANGUAGES . $language . '.php'); 298 299 // BOF: MOD 300 # include the cache class 301 include ('includes/classes/cache.class.php'); 302 $cache = new cache($languages_id); 303 // Ultimate SEO URLs v2.1 304 include_once (DIR_WS_CLASSES . 'seo.class.php'); 305 if ( !is_object($seo_urls) ){ 306 $seo_urls = new SEO_URL($languages_id); 307 } 308 // Validate SEO URL 309 if ( is_object($seo_urls) && (strpos($_SERVER['REQUEST_URI'], '.html') !== false) && (defined('FWR_VALIDATION_ON') && FWR_VALIDATION_ON === 'true') ) { // SEO URLS is active and there is .html in the querystring 310 tep_validate_seo_urls(); 311 } 312 313 # Get the cache - no parameters will get all GLOBAL cache entries for this language 314 $cache->get_cache('GLOBAL'); 315 316 317 if ( isset($HTTP_GET_VARS['cName']) && defined(urldecode($HTTP_GET_VARS['cName'])) ) { 318 $cPath = str_replace( 'cPath=', '', constant(urldecode($HTTP_GET_VARS['cName'])) ); 319 $HTTP_GET_VARS['cPath'] = $cPath; 320 } 321 if (isset($HTTP_GET_VARS['pName']) && defined(urldecode($HTTP_GET_VARS['pName'])) ) { 322 $pid = str_replace('products_id=', '', constant(urldecode($HTTP_GET_VARS['pName']))); 323 $HTTP_GET_VARS['products_id'] = (int)$pid; 324 } 325 // EOF: MOD 326 327 // currency 328 if (!tep_session_is_registered('currency') || isset($HTTP_GET_VARS['currency']) || ( (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') && (LANGUAGE_CURRENCY != $currency) ) ) { 329 if (!tep_session_is_registered('currency')) tep_session_register('currency'); 330 331 if (isset($HTTP_GET_VARS['currency']) && $currencies->is_set($HTTP_GET_VARS['currency'])) { 332 $currency = $HTTP_GET_VARS['currency']; 333 } else { 334 $currency = (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') ? LANGUAGE_CURRENCY : DEFAULT_CURRENCY; 335 } 336 } 337 338 // navigation history 339 if (tep_session_is_registered('navigation')) { 340 if (PHP_VERSION < 4) { 341 $broken_navigation = $navigation; 342 $navigation = new navigationHistory; 343 $navigation->unserialize($broken_navigation); 344 } 345 } else { 346 tep_session_register('navigation'); 347 $navigation = new navigationHistory; 348 } 349 $navigation->add_current_page(); 350 351 // BOF: MOD - Down for Maintenance except for admin ip 352 if (EXCLUDE_ADMIN_IP_FOR_MAINTENANCE != getenv('REMOTE_ADDR')){ 353 if (DOWN_FOR_MAINTENANCE=='true' and !strstr($PHP_SELF,DOWN_FOR_MAINTENANCE_FILENAME)) { tep_redirect(tep_href_link(DOWN_FOR_MAINTENANCE_FILENAME)); } 354 } 355 // do not let people get to down for maintenance page if not turned on 356 if (DOWN_FOR_MAINTENANCE=='false' and strstr($PHP_SELF,DOWN_FOR_MAINTENANCE_FILENAME)) { 357 tep_redirect(tep_href_link(FILENAME_DEFAULT)); 358 } 359 // EOF: MOD - Down for Maintenance 360 361 // BOF: MOD - Wishlist 3.5 362 // wishlist data 363 if(!tep_session_is_registered('wishList')) { 364 tep_session_register('wishList'); 365 $wishList = new wishlist; 366 } 367 368 //Wishlist actions (must be before shopping cart actions) 369 if(isset($HTTP_POST_VARS['wishlist_x'])) { 370 if(isset($HTTP_POST_VARS['products_id'])) { 371 if(isset($HTTP_POST_VARS['id'])) { 372 $attributes_id = $HTTP_POST_VARS['id']; 373 tep_session_register('attributes_id'); 374 } 375 $wishlist_id = $HTTP_POST_VARS['products_id']; 376 tep_session_register('wishlist_id'); 377 } 378 tep_redirect(tep_href_link(FILENAME_WISHLIST)); 379 } 380 // EOF: MOD - Wishlist 3.5 381 382 // Shopping cart actions 383 if (isset($HTTP_GET_VARS['action'])) { 384 // redirect the customer to a friendly cookie-must-be-enabled page if cookies are disabled 385 if ($session_started == false) { 386 tep_redirect(tep_href_link(FILENAME_COOKIE_USAGE)); 387 } 388 389 if (DISPLAY_CART == 'true') { 390 $goto = FILENAME_SHOPPING_CART; 391 // LINE MOD: Ultimate SEO URLs v2.1 removed 'cName', 'pName' 392 $parameters = array('action', 'cPath', 'products_id', 'pid'); 393 } else { 394 $goto = basename($PHP_SELF); 395 if ($HTTP_GET_VARS['action'] == 'buy_now') { 396 // LINE MOD: Ultimate SEO URLs v2.1 removed 'pName' 397 $parameters = array('action', 'pid', 'products_id'); 398 } else { 399 $parameters = array('action', 'pid'); 400 } 401 } 402 switch ($HTTP_GET_VARS['action']) { 403 // customer wants to update the product quantity in their shopping cart 404 case 'update_product' : for ($i=0, $n=sizeof($HTTP_POST_VARS['products_id']); $i<$n; $i++) { 405 if (in_array($HTTP_POST_VARS['products_id'][$i], (is_array($HTTP_POST_VARS['cart_delete']) ? $HTTP_POST_VARS['cart_delete'] : array()))) { 406 $cart->remove($HTTP_POST_VARS['products_id'][$i]); 407 } else { 408 if (PHP_VERSION < 4) { 409 // if PHP3, make correction for lack of multidimensional array. 410 reset($HTTP_POST_VARS); 411 while (list($key, $value) = each($HTTP_POST_VARS)) { 412 if (is_array($value)) { 413 while (list($key2, $value2) = each($value)) { 414 if (ereg ("(.*)\]\[(.*)", $key2, $var)) { 415 $id2[$var[1]][$var[2]] = $value2; 416 } 417 } 418 } 419 } 420 $attributes = ($id2[$HTTP_POST_VARS['products_id'][$i]]) ? $id2[$HTTP_POST_VARS['products_id'][$i]] : ''; 421 } else { 422 $attributes = ($HTTP_POST_VARS['id'][$HTTP_POST_VARS['products_id'][$i]]) ? $HTTP_POST_VARS['id'][$HTTP_POST_VARS['products_id'][$i]] : ''; 423 } 424 $cart->add_cart($HTTP_POST_VARS['products_id'][$i], $HTTP_POST_VARS['cart_quantity'][$i], $attributes, false); 425 } 426 } 427 tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); 428 break; 429 // customer adds a product from the products page 430 // BOF: MOD - QT Pro 431 // case 'add_product' : if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) { 432 // $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+1, $HTTP_POST_VARS['id']); 433 case 'add_product' : if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id']) && ($HTTP_POST_VARS['products_id']==(int)$HTTP_POST_VARS['products_id'])) { 434 $attributes=array(); 435 if (isset($HTTP_POST_VARS['attrcomb']) && (preg_match("/^\d{1,10}-\d{1,10}(,\d{1,10}-\d{1,10})*$/",$HTTP_POST_VARS['attrcomb']))) { 436 $attrlist=explode(',',$HTTP_POST_VARS['attrcomb']); 437 foreach ($attrlist as $attr) { 438 list($oid, $oval)=explode('-',$attr); 439 if (is_numeric($oid) && $oid==(int)$oid && is_numeric($oval) && $oval==(int)$oval) 440 $attributes[$oid]=$oval; 441 } 442 } 443 if (isset($HTTP_POST_VARS['id']) && is_array($HTTP_POST_VARS['id'])) { 444 foreach ($HTTP_POST_VARS['id'] as $key=>$val) { 445 if (is_numeric($key) && $key==(int)$key && is_numeric($val) && $val==(int)$val) 446 $attributes=$attributes + $HTTP_POST_VARS['id']; 447 } 448 } 449 $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $attributes))+1, $attributes); 450 // EOF: MOD - QT Pro 451 } 452 tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); 453 break; 454 // performed by the 'buy now' button in product listings and review page 455 case 'buy_now' : if (isset($HTTP_GET_VARS['products_id'])) { 456 457 if (tep_has_product_attributes($HTTP_GET_VARS['products_id'])) { 458 tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id'])); 459 } else { 460 $cart->add_cart($HTTP_GET_VARS['products_id'], $cart->get_quantity($HTTP_GET_VARS['products_id'])+1); 461 } 462 } 463 // BOF: MOD - Ultimate SEO URLs 464 // tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); 465 // break; 466 if ( (defined('SEO_URLS') && SEO_URLS == 'true') && (defined('SEO_URLS_TYPE') && SEO_URLS_TYPE == 'Rewrite') ){ 467 $cPath = tep_get_product_path($HTTP_GET_VARS['products_id']); 468 $cPath_array = tep_parse_category_path($cPath); 469 $cPath = implode('_', $cPath_array); 470 tep_redirect(tep_href_link($goto, 'cPath=' . $cPath . '&' . tep_get_all_get_params($parameters))); 471 } else { 472 tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); 473 } 474 break; 475 // EOF: MOD - Ultimate SEO URLs 476 case 'notify' : if (tep_session_is_registered('customer_id')) { 477 if (isset($HTTP_GET_VARS['products_id'])) { 478 $notify = $HTTP_GET_VARS['products_id']; 479 } elseif (isset($HTTP_GET_VARS['notify'])) { 480 $notify = $HTTP_GET_VARS['notify']; 481 } elseif (isset($HTTP_POST_VARS['notify'])) { 482 $notify = $HTTP_POST_VARS['notify']; 483 } else { 484 tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'notify')))); 485 } 486 if (!is_array($notify)) $notify = array($notify); 487 for ($i=0, $n=sizeof($notify); $i<$n; $i++) { 488 $check_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $notify[$i] . "' and customers_id = '" . $customer_id . "'"); 489 $check = tep_db_fetch_array($check_query); 490 if ($check['count'] < 1) { 491 tep_db_query("insert into " . TABLE_PRODUCTS_NOTIFICATIONS . " (products_id, customers_id, date_added) values ('" . $notify[$i] . "', '" . $customer_id . "', now())"); 492 } 493 } 494 tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'notify')))); 495 } else { 496 $navigation->set_snapshot(); 497 tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); 498 } 499 break; 500 case 'notify_remove' : if (tep_session_is_registered('customer_id') && isset($HTTP_GET_VARS['products_id'])) { 501 $check_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $HTTP_GET_VARS['products_id'] . "' and customers_id = '" . $customer_id . "'"); 502 $check = tep_db_fetch_array($check_query); 503 if ($check['count'] > 0) { 504 tep_db_query("delete from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $HTTP_GET_VARS['products_id'] . "' and customers_id = '" . $customer_id . "'"); 505 } 506 tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')))); 507 } else { 508 $navigation->set_snapshot(); 509 tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); 510 } 511 break; 512 case 'cust_order' : if (tep_session_is_registered('customer_id') && isset($HTTP_GET_VARS['pid'])) { 513 if (tep_has_product_attributes($HTTP_GET_VARS['pid'])) { 514 tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['pid'])); 515 } else { 516 $cart->add_cart($HTTP_GET_VARS['pid'], $cart->get_quantity($HTTP_GET_VARS['pid'])+1); 517 } 518 } 519 tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); 520 break; 521 522 } // end switch $HTTP_GET_VARS['action'] 523 } // end if is set $HTTP_GET_VARS['action'] 524 525 526 // include the who's online functions 527 require (DIR_WS_FUNCTIONS . 'whos_online.php'); 528 tep_update_whos_online(); 529 530 // include the password crypto functions 531 require (DIR_WS_FUNCTIONS . 'password_funcs.php'); 532 533 // include validation functions (right now only email address) 534 require (DIR_WS_FUNCTIONS . 'validations.php'); 535 536 // split-page-results 537 require (DIR_WS_CLASSES . 'split_page_results.php'); 538 539 // infobox 540 require (DIR_WS_CLASSES . 'boxes.php'); 541 542 // auto activate and expire banners 543 require (DIR_WS_FUNCTIONS . 'banner.php'); 544 tep_activate_banners(); 545 tep_expire_banners(); 546 547 // auto expire special products 548 require (DIR_WS_FUNCTIONS . 'specials.php'); 549 tep_expire_specials(); 550 551 // calculate category path 552 if (isset($HTTP_GET_VARS['cPath'])) { 553 $cPath = $HTTP_GET_VARS['cPath']; 554 } elseif (isset($HTTP_GET_VARS['products_id']) && !isset($HTTP_GET_VARS['manufacturers_id'])) { 555 $cPath = tep_get_product_path($HTTP_GET_VARS['products_id']); 556 } else { 557 $cPath = ''; 558 } 559 560 if (tep_not_null($cPath)) { 561 $cPath_array = tep_parse_category_path($cPath); 562 $cPath = implode('_', $cPath_array); 563 $current_category_id = $cPath_array[(sizeof($cPath_array)-1)]; 564 } else { 565 $current_category_id = 0; 566 } 567 568 // include the breadcrumb class and start the breadcrumb trail 569 require (DIR_WS_CLASSES . 'breadcrumb.php'); 570 $breadcrumb = new breadcrumb; 571 572 $breadcrumb->add(HEADER_TITLE_TOP, HTTP_SERVER); 573 $breadcrumb->add(HEADER_TITLE_CATALOG, tep_href_link(FILENAME_DEFAULT)); 574 575 // add category names or the manufacturer name to the breadcrumb trail 576 if (isset($cPath_array)) { 577 for ($i=0, $n=sizeof($cPath_array); $i<$n; $i++) { 578 $categories_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$cPath_array[$i] . "' and language_id = '" . (int)$languages_id . "'"); 579 if (tep_db_num_rows($categories_query) > 0) { 580 $categories = tep_db_fetch_array($categories_query); 581 $breadcrumb->add($categories['categories_name'], tep_href_link(FILENAME_DEFAULT, 'cPath=' . implode('_', array_slice($cPath_array, 0, ($i+1))))); 582 } else { 583 break; 584 } 585 } 586 } elseif (isset($HTTP_GET_VARS['manufacturers_id'])) { 587 $manufacturers_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'"); 588 if (tep_db_num_rows($manufacturers_query)) { 589 $manufacturers = tep_db_fetch_array($manufacturers_query); 590 $breadcrumb->add($manufacturers['manufacturers_name'], tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'])); 591 } 592 } 593 594 // add the products model to the breadcrumb trail 595 if (isset($HTTP_GET_VARS['products_id'])) { 596 $model_query = tep_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'"); 597 if (tep_db_num_rows($model_query)) { 598 $model = tep_db_fetch_array($model_query); 599 $breadcrumb->add($model['products_model'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $HTTP_GET_VARS['products_id'])); 600 } 601 } 602 603 // BOF: MOD - articles functions 604 require (DIR_WS_FUNCTIONS . 'articles.php'); 605 require (DIR_WS_FUNCTIONS . 'article_header_tags.php'); 606 607 // calculate topic path 608 if (isset($HTTP_GET_VARS['tPath'])) { 609 $tPath = $HTTP_GET_VARS['tPath']; 610 } elseif (isset($HTTP_GET_VARS['articles_id']) && !isset($HTTP_GET_VARS['authors_id'])) { 611 $tPath = tep_get_article_path($HTTP_GET_VARS['articles_id']); 612 } else { 613 $tPath = ''; 614 } 615 616 if (tep_not_null($tPath)) { 617 $tPath_array = tep_parse_topic_path($tPath); 618 $tPath = implode('_', $tPath_array); 619 $current_topic_id = $tPath_array[(sizeof($tPath_array)-1)]; 620 } else { 621 $current_topic_id = 0; 622 } 623 624 // add topic names or the author name to the breadcrumb trail 625 if (isset($tPath_array)) { 626 for ($i=0, $n=sizeof($tPath_array); $i<$n; $i++) { 627 $topics_query = tep_db_query("select topics_name from " . TABLE_TOPICS_DESCRIPTION . " where topics_id = '" . (int)$tPath_array[$i] . "' and language_id = '" . (int)$languages_id . "'"); 628 if (tep_db_num_rows($topics_query) > 0) { 629 $topics = tep_db_fetch_array($topics_query); 630 $breadcrumb->add($topics['topics_name'], tep_href_link(FILENAME_ARTICLES, 'tPath=' . implode('_', array_slice($tPath_array, 0, ($i+1))))); 631 } else { 632 break; 633 } 634 } 635 } elseif (isset($HTTP_GET_VARS['authors_id'])) { 636 $authors_query = tep_db_query("select authors_name from " . TABLE_AUTHORS . " where authors_id = '" . (int)$HTTP_GET_VARS['authors_id'] . "'"); 637 if (tep_db_num_rows($authors_query)) { 638 $authors = tep_db_fetch_array($authors_query); 639 $breadcrumb->add('Articles by ' . $authors['authors_name'], tep_href_link(FILENAME_ARTICLES, 'authors_id=' . $HTTP_GET_VARS['authors_id'])); 640 } 641 } 642 643 // add the articles name to the breadcrumb trail 644 if (isset($HTTP_GET_VARS['articles_id'])) { 645 $article_query = tep_db_query("select articles_name from " . TABLE_ARTICLES_DESCRIPTION . " where articles_id = '" . (int)$HTTP_GET_VARS['articles_id'] . "'"); 646 if (tep_db_num_rows($article_query)) { 647 $article = tep_db_fetch_array($article_query); 648 if (isset($HTTP_GET_VARS['authors_id'])) { 649 $breadcrumb->add($article['articles_name'], tep_href_link(FILENAME_ARTICLE_INFO, 'authors_id=' . $HTTP_GET_VARS['authors_id'] . '&articles_id=' . $HTTP_GET_VARS['articles_id'])); 650 } else { 651 $breadcrumb->add($article['articles_name'], tep_href_link(FILENAME_ARTICLE_INFO, 'tPath=' . $tPath . '&articles_id=' . $HTTP_GET_VARS['articles_id'])); 652 } 653 } 654 } 655 656 // add only if Header Tags not already installed 657 require (DIR_WS_FUNCTIONS . 'clean_html_comments.php'); 658 // EOF: MOD - articles functions 659 660 // initialize the message stack for output messages 661 require (DIR_WS_CLASSES . 'message_stack.php'); 662 $messageStack = new messageStack; 663 664 // set which precautions should be checked 665 define('WARN_INSTALL_EXISTENCE', 'true'); 666 define('WARN_CONFIG_WRITEABLE', 'true'); 667 define('WARN_SESSION_DIRECTORY_NOT_WRITEABLE', 'true'); 668 define('WARN_SESSION_AUTO_START', 'true'); 669 define('WARN_DOWNLOAD_DIRECTORY_NOT_READABLE', 'true'); 670 // LINE ADDED: MOD - OSC-AFFILIATE 671 require (DIR_WS_INCLUDES . 'affiliate_application_top.php'); 672 // LINE ADDED: MOD - GC Credit Class 673 REQUIRE (DIR_WS_INCLUDES . 'add_ccgvdc_application_top.php'); 674 675 // LINE ADDED: MOD - BTS 676 require (DIR_WS_INCLUDES . 'configure_bts.php'); 677 // BOF: MOD - NEW OSC tax class 678 require ('includes/classes/tax.php'); 679 $osC_Tax = new osC_Tax; 680 // EOF: MOD - NEW OSC tax class 681 682 // BOF: MOD - Page cache contribution - by Chemo 683 // Define the pages to be cached in the $cache_pages array 684 $cache_pages = array('index.php', 'product_info.php'); 685 if (!tep_session_is_registered('customer_id') && ENABLE_PAGE_CACHE == 'true') { 686 // Start the output buffer for the shopping cart 687 ob_start(); 688 require (DIR_WS_BOXES . 'shopping_cart.php'); 689 $cart_cache = ob_get_clean(); 690 // End the output buffer for cart and save as $cart_cache string 691 692 // Loop through the $cache_pages array and start caching if found 693 foreach ($cache_pages as $index => $page){ 694 if ( strpos($_SERVER['PHP_SELF'], $page) ){ 695 include_once (DIR_WS_CLASSES . 'page_cache.php'); 696 $page_cache = new page_cache($cart_cache); 697 // The cache timelife is set globally 698 // in the admin control panel settings 699 // Example below overrides the setting to 60 minutes 700 // Leave blank to use default setting 701 // $page_cache->cache_this_page(60); 702 $page_cache->cache_this_page(); 703 } 704 } 705 } 706 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Fri Jan 1 13:43:16 2010 | Cross-referenced by PHPXref 0.7 |