Example #1
0
 /**
  * Actually track a visitor.
  */
 function TrackVisitor()
 {
     $today_stamp = mktime(0, 0, 0, isc_date("m"), isc_date("d"), isc_date("Y"));
     if (!isset($_COOKIE['STORE_VISITOR'])) {
         // We have a new visitor, let's track that.
         $query = sprintf("SELECT COUNT(uniqueid) AS num FROM [|PREFIX|]unique_visitors WHERE datestamp='%d'", $GLOBALS['ISC_CLASS_DB']->Quote($today_stamp));
         $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
         $row = $GLOBALS['ISC_CLASS_DB']->Fetch($result);
         if ($row['num'] == 0) {
             // This person is the first to visit the site today, so track it
             $new_visitor = array("datestamp" => $today_stamp, "numuniques" => 1);
             $GLOBALS['ISC_CLASS_DB']->InsertQuery("unique_visitors", $new_visitor);
         } else {
             // At least one person has visited the site today, just update the record
             $query = sprintf("UPDATE [|PREFIX|]unique_visitors SET numuniques=numuniques+1 WHERE datestamp='%d'", $today_stamp);
             // Run the query to update the number of unique visitors
             $GLOBALS['ISC_CLASS_DB']->Query($query);
         }
         // Set the tracking cookie for another 24 hours
         ISC_SetCookie("STORE_VISITOR", true, time() + 86400);
     }
     header("Content-type: image/gif");
     echo base64_decode('R0lGODlhAQABALMAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A/wD//wBiZCH5BAEAAA8ALAAAAAABAAEAAAQC8EUAOw==');
     exit;
 }
Example #2
0
 public function CreateSession()
 {
     $this->_token = session_id();
     $newSession = array("sessionhash" => $this->_token, "sessdata" => "", "sesslastupdated" => time());
     $this->_id = $GLOBALS['ISC_CLASS_DB']->InsertQuery("sessions", $newSession);
     $this->_new_session = true;
     $this->_data = array();
     ISC_SetCookie("SHOP_SESSION_TOKEN", $this->_token, time() + (int) @ini_get('session.gc_maxlifetime'));
 }
Example #3
0
		protected function editOrderSaveAction()
		{
			if (empty($_POST['quoteSession'])) {
				exit;
			}

			$quoteSession = $_POST['quoteSession'];

			/** @var ISC_QUOTE */
			$quote = getClass('ISC_ADMIN_ORDERS')->getQuoteSession($quoteSession);
			if(!$quote) {
				$this->sendEditOrderNoQuoteResponse('saveError');
			}

			try {
				$quote->setCustomerMessage(Interspire_Request::post('customerMessage'));
				$quote->setStaffNotes(Interspire_Request::post('staffNotes'));

				$entity = new ISC_ENTITY_ORDER;

				$currency = GetDefaultCurrency();
				$order = array(
					'ordcurrencyid' => $currency['currencyid'],
					'ordcurrencyexchangerate' => $currency['currencyexchangerate'],
					'ordipaddress' => getIp(),
					'extraInfo' => array(),
					'quote' => $quote,
				);

				$createAccount = false;

				// process customer details to see if an account should be made
				if (Interspire_Request::post('orderFor') == 'new') {
					// this really needs to be split off into another method because it's done both at the front end checkout, in save billing, and in here! -ge
					$password = '';
					$confirmedPassword = '';
					$email = '';
					$accountFormFields = $GLOBALS['ISC_CLASS_FORM']->getFormFields(FORMFIELDS_FORM_ACCOUNT, true);
					$accountCustomFields = array();
					foreach($accountFormFields as $formFieldId => $formField) {
						$formFieldPrivateId = $formField->record['formfieldprivateid'];

						if (!$formFieldPrivateId) {
							$accountCustomFields[$formFieldId] = $formField->getValue();
						} else if($formFieldPrivateId == 'EmailAddress') {
							$email = $formField->getValue();
						} else if($formFieldPrivateId == 'Password') {
							$password = $formField->getValue();
						} else if($formFieldPrivateId == 'ConfirmPassword') {
							$confirmedPassword = $formField->getValue();
						}
					}

					// shouldn't reach this point with a valid email without all the details already being validated after step 1 > next, so go ahead and assign it to the order
					if ($email) {
						$createAccount = array(
							'addresses' => array(),
							'password' => $password,
							'customFormFields' => $accountCustomFields,
						);

						foreach ($quote->getAllAddresses() as /** @var ISC_QUOTE_ADDRESS */$address) {
							if (!$address->getSaveAddress()) {
								continue;
							}

							$customerAddress = $address->getAsArray();
							$customFields = $address->getCustomFields();
							if (!empty($customFields)) {
								$customerAddress['customFormFields'] = $customFields;

								// Shipping fields need to be mapped back to billing so they can be stored
								if ($address->getType() == ISC_QUOTE_ADDRESS::TYPE_SHIPPING) {
									$newCustomFields = array();
									$map = $GLOBALS['ISC_CLASS_FORM']->mapAddressFieldList(FORMFIELDS_FORM_SHIPPING, array_keys($customFields));
									foreach($map as $oldId => $newId) {
										$newCustomFields[$newId] = $customFields[$oldId];
									}
									$customerAddress['customFormFields'] = $newCustomFields;
								}
							}

							$createAccount['addresses'][] = $customerAddress;
						}
					}
				}

				if ($quote->getOrderId()) {
					$editing = true;
					$adding = false;

					$orderId = $quote->getOrderId();

					$existingOrder = $entity->get($orderId);
					if ($existingOrder['deleted']) {
						// don't allow saving changes for a deleted order
						$errors[] = GetLang('EditDeletedOrderError');
					} else {
						$order['orderid'] = $orderId;
						if (!$entity->edit($order)) {
							$errors[] = $entity->getError();
						}
					}
				} else {
					$editing = false;
					$adding = true;

					$order['orderpaymentmodule'] = '';

					$orderId = $entity->add($order);

					if ($orderId) {
						$quote->setOrderId($orderId);
					} else {
						$errors[] = $entity->getError();
					}
				}

				if (!empty($errors)) {
					$this->sendEditOrderResponse(array(
						'errors' => $errors,
						'stateTransition' => 'saveError',
					));
				}

				// retrieve the created/edited order record
				$order = GetOrder($orderId);

				if ($createAccount) {
					// this function doesn't return anything for error testing
					createOrderCustomerAccount($order, $createAccount);
				}

				// Process a payment
				$paymentMethod = Interspire_Request::post('paymentMethod');

				$providerSuccess = false;

				// Retrieve the payment method details
				$paymentFields = Interspire_Request::post('paymentField');
				if (!empty($paymentFields[$paymentMethod])) {
					$paymentFields = $paymentFields[$paymentMethod];
				}
				else {
					$paymentFields = array();
				}

				if ($quote->getGrandTotalWithStoreCredit() > 0 && ($adding || empty($order['ordpaymentstatus']) || empty($order['orderpaymentmodule'])) && !empty($paymentMethod)) {
					$gatewayAmount = $quote->getGrandTotalWithStoreCredit();

					$provider = null;

					// was a custom payment specified?
					if ($paymentMethod == 'custom') {
						$paymentMethodName = $paymentFields['custom_name'];
						$providerSuccess = true;
					}
					// actual payment module
					else {
						GetModuleById('checkout', $provider, $paymentMethod);
						if(is_object($provider)) {
							$paymentMethodName = $provider->GetDisplayName();

							if (method_exists($provider, 'ProcessManualPayment')) {
								// set the order token as required by various payment methods
								ISC_SetCookie('SHOP_ORDER_TOKEN', $order['ordtoken'], time() + (3600*24), true);
								// make the token immediately available
								$_COOKIE['SHOP_ORDER_TOKEN'] = $order['ordtoken'];

								// process the payment
								$result = $provider->ProcessManualPayment($order, $paymentFields);
								if ($result['result']) {
									$providerSuccess = true;
									$gatewayAmount = $result['amount'];

									FlashMessage(GetLang('OrderPaymentSuccess', array('amount' => FormatPrice($gatewayAmount), 'orderId' => $orderId, 'provider' => $paymentMethodName)), MSG_SUCCESS);
								}
								else {
									$errors[] = GetLang('OrderPaymentFail', array('orderId' => $orderId, 'provider' => $paymentMethodName, 'reason' => $result['message']));
								}
							}
							else {
								// all manual/offline methods will always be successfull
								$providerSuccess = true;
							}
						}
						else {
							// failed to get a payment module
						}
					}
				// if the grand total after minus the coupon,etc is 0 and it's adding order also the payment method is custom.
				} else if ($quote->getGrandTotalWithStoreCredit() == 0 && ($adding || empty($order['ordpaymentstatus']) || empty($order['orderpaymentmodule'])) && $paymentMethod == 'custom') {
					$paymentMethodName = $paymentFields['custom_name'];
					$providerSuccess = true;
				}

				// was payment successfull?
				if ($providerSuccess) {
					// record payment info for the order
					$updatedOrder = array(
						'orderpaymentmethod' 	=> $paymentMethodName,
						'orderpaymentmodule'	=> $paymentMethod,
					);

					$this->db->UpdateQuery("orders", $updatedOrder, "orderid = " . $orderId);

					// set appropriate status for the order
					if ($quote->isDigital()) {
						$newStatus = ORDER_STATUS_COMPLETED;
					}
					else {
						$newStatus = ORDER_STATUS_AWAITING_FULFILLMENT;
					}
					UpdateOrderStatus($orderId, $newStatus, false);

					// email invoice
					if (Interspire_Request::post('emailInvoiceToCustomer')) {
						EmailInvoiceToCustomer($orderId);
					}
				}

				if (!empty($errors)) {
					$response = array(
						'errors' => $errors,
						'stateTransition' => 'saveError',
					);
				}
				else {
					if ($editing) {
						FlashMessage(GetLang('OrderUpdated', array('orderId' => $orderId)), MSG_SUCCESS);
					} else {
						FlashMessage(GetLang('OrderCreated', array('orderId' => $orderId)), MSG_SUCCESS);
					}

					$response = array(
						'stateTransition' => 'saveOk',
					);

					// remove quote object from session after successful save and successful payment
					getClass('ISC_ADMIN_ORDERS')->deleteQuoteSession($quoteSession);
				}

				if ($adding) {
					$response['updateOrderId'] = $orderId;
				}

				$this->sendEditOrderResponse($response);
			} catch (ISC_QUOTE_EXCEPTION $exception) {
				$this->sendEditOrderResponse(array(
					'stateTransition' => 'saveError',
					'errors' => array(
						$exception->getMessage(),
					),
				));
			}
		}
Example #4
0
 public function SetPanelSettings()
 {
     //$GLOBALS['ISC_CLASS_SEARCH'] = GetClass('ISC_SEARCH');
     //$GLOBALS['ISC_CLASS_NEWSEARCH'] = GetClass('ISC_NEWSEARCH');
     $count = 0;
     $output = "";
     $params = $GLOBALS['ISC_CLASS_NEWSEARCH']->_searchterms;
     $GLOBALS['DynamicDisplay'] = 'block';
     $GLOBALS['YMMTableDisplay'] = 'block';
     if (!empty($_COOKIE['last_search_selection']['year'])) {
         $params['year'] = $_COOKIE['last_search_selection']['year'];
     }
     if (!empty($_COOKIE['last_search_selection']['make'])) {
         $params['make'] = $_COOKIE['last_search_selection']['make'];
     }
     if (!empty($_COOKIE['last_search_selection']['model'])) {
         $params['model'] = $_COOKIE['last_search_selection']['model'];
     }
     $this->searchterms = $params;
     /* Checking the search string. If it is used in any search, will be retained. else it will not be retained - starts */
     if (isset($this->searchterms['search'])) {
         $search_str = trim(str_ireplace($this->searchterms['search_string'], "", $this->searchterms['search']));
         if ($search_str == '') {
             unset($this->searchterms['search'], $params['search']);
         } else {
             $this->searchterms['search'] = $params['search'] = $search_str;
         }
     }
     $path = GetConfig('ShopPath');
     /* the below mmy links are passed to the breadcrumbs */
     $mmy_links = "";
     /*---------- This below section is for generating search phrase----------*/
     $GLOBALS['Category'] = "";
     $GLOBALS['MMY'] = "";
     $GLOBALS['PQ'] = "";
     $GLOBALS['VQ'] = "";
     $GLOBALS['SearchPhrase'] = "";
     $ext_links = "";
     // this variable is passed to the product detail page
     $seo_delim = "&";
     if ($GLOBALS['EnableSEOUrls'] == 1) {
         $seo_delim = "/";
     }
     if (isset($GLOBALS['ISC_SRCH_CATG_NAME'])) {
         $GLOBALS['Category'] .= $GLOBALS['ISC_SRCH_CATG_NAME'];
     }
     if (isset($params['year'])) {
         $GLOBALS['MMY'] .= $params['year'] . "<br>";
         $ext_links .= $seo_delim . "year=" . $params['year'];
     }
     if (isset($params['make'])) {
         $GLOBALS['MMY'] .= strtoupper($params['make']) . "<br>";
         $ext_links .= $seo_delim . "make=" . MakeURLSafe($params['make']);
     }
     if (isset($params['model']) && (!isset($params['model_flag']) || $params['model_flag'] == 1)) {
         $GLOBALS['MMY'] .= strtoupper($params['model']) . "<br>";
         $ext_links .= $seo_delim . "model=" . MakeURLSafe($params['model']);
     }
     /*else if(isset($params['model']))
     	 $ext_links .= $seo_delim."model=".$params['model'];*/
     /* this condition has been added seperately here to show submodel at last */
     if (isset($params['submodel'])) {
         $GLOBALS['MMY'] .= MakeURLSafe($params['submodel']) . "<br>";
     }
     /*if(isset($params['year'])) {
     	 $ext_links .= $seo_delim."year=".$params['year'];
     	 }*/
     if (isset($params['dynfilters']) && !empty($params['dynfilters'])) {
         foreach ($params['dynfilters'] as $key => $value) {
             if (eregi('vq', $key)) {
                 $key = str_ireplace('vq', '', $key);
                 $GLOBALS['VQ'] .= ucfirst($key) . ": {$value}<br>";
             } else {
                 if (eregi('pq', $key)) {
                     $key = str_ireplace('pq', '', $key);
                     $GLOBALS['PQ'] .= ucfirst($key) . ": {$value}<br>";
                 }
             }
         }
     }
     $filter_var = array('vq', 'pq');
     $catg_desc_arr = array();
     $isDynamicPage = true;
     /* this below patch is used for getting description of the category. Here currently the selected category id will be last one in the $params['srch_category'] array. if input['category'] is used then it will be the first one */
     if (!empty($params['srch_category'])) {
         if (isset($params['category'])) {
             $selected_catg = $params['srch_category'][0];
         }
         //else
         //$selected_catg = end($params['srch_category']);
         $selected_catg = $params['srch_category'];
         //wirror_20100806: add selected files like pagecontenttype and customcontentid;
         //$catg_desc_qry = "select pagecontenttype, customcontentid, catdesc , categoryfooter  from [|PREFIX|]categories where categoryid = ".$selected_catg;
         $catg_desc_qry = "select categoryid, pagecontenttype, customcontentid, catdesc , categoryfooter  from [|PREFIX|]categories where categoryid in(" . implode(',', $selected_catg) . ")";
         $catg_desc_res = $GLOBALS['ISC_CLASS_DB']->Query($catg_desc_qry);
         if ($GLOBALS['ISC_CLASS_DB']->CountResult($catg_desc_res) > 0) {
             while ($rs = $GLOBALS['ISC_CLASS_DB']->Fetch($catg_desc_res)) {
                 $catg_desc_arr[$rs['categoryid']] = $rs;
                 //zcs=add "$rs['categoryid']" as indexs
             }
             //$catg_desc_arr = $GLOBALS['ISC_CLASS_DB']->Fetch($catg_desc_res);
         }
         //zcs=>Compat for "Custom Landing page"
         //filter out the category parents that have products
         $hasProductParents = $this->_filterParents($selected_catg);
         if (count($hasProductParents) == 1) {
             $catg_desc_arr = $catg_desc_arr[$hasProductParents[0]];
         }
         //<=zcs
         $isDynamicPage = $catg_desc_arr['pagecontenttype'] == 0 ? true : false;
         //wirror_20100806: get the custom prudocts list;
         $catg_custom_arr = array();
         /*$catg_custom_qry = "SELECT cp.productids, cp.categoryid, cp.subcategoryid, cp.brandid, cp.seriesid, cp.description
           		  FROM [|PREFIX|]custom_products cp 
           		  INNER JOIN [|PREFIX|]custom_contents cc on cc.contentid=cp.contentid
           		  WHERE cc.contentid
                     IN (
                          SELECT customcontentid
                          FROM [|PREFIX|]categories
                          WHERE categoryid = '$selected_catg'
                     )
                     AND cp.enabled=1 ";
           */
         $catg_custom_qry = "SELECT cp.productids, cp.categoryid, cp.subcategoryid, cp.brandid, cp.seriesid, cp.description\n            \t\t  FROM [|PREFIX|]custom_products cp \n            \t\t  INNER JOIN [|PREFIX|]custom_contents cc on cc.contentid=cp.contentid\n            \t\t  WHERE cc.contentid\n                      IN (\n                           SELECT customcontentid\n                           FROM [|PREFIX|]categories\n                           WHERE categoryid in(" . implode(',', $selected_catg) . ")\n                      )\n                      AND cp.enabled=1 ";
         if (isset($params['brand']) && $params['brand'] != "") {
             $brand_query = "select brandid from [|PREFIX|]brands WHERE brandname='" . $params['brand'] . "'";
             $brand_result = $GLOBALS['ISC_CLASS_DB']->Query($brand_query);
             $brandId = $GLOBALS['ISC_CLASS_DB']->FetchOne($brand_result);
             if ((int) $brandId > 0) {
                 $catg_custom_qry .= " AND cp.brandid={$brandId} ";
             }
         }
         $catg_custom_qry .= " ORDER BY cp.displayorder ASC ";
         $catg_custom_res = $GLOBALS['ISC_CLASS_DB']->Query($catg_custom_qry);
         while ($rows = $GLOBALS['ISC_CLASS_DB']->Fetch($catg_custom_res)) {
             $catg_custom_arr[] = $rows;
         }
         $catCustomFlag = false;
         /* this below patch is used to show the display name for the qualifiers from the qualifier association table */
         $map_names = array();
         $display_names = array();
         $filter_names = "select qid , column_name , display_names from [|PREFIX|]qualifier_names where column_name regexp '^(pq|vq)'";
         $filter_result = $GLOBALS['ISC_CLASS_DB']->Query($filter_names);
         while ($filter_row = $GLOBALS['ISC_CLASS_DB']->Fetch($filter_result)) {
             $map_names[$filter_row['qid']] = $filter_row['column_name'];
             $display_names[$filter_row['qid']] = $filter_row['display_names'];
         }
         $this->GetAssocDetails($selected_catg, $OwnAssoc, $ParentAssoc, $OwnValue, $ParentValue);
     }
     if (isset($params['brand'])) {
         $brand_desc_arr = array();
         $brand_desc_qry = "select branddescription , brandfooter from [|PREFIX|]brands where brandname = '" . $params['brand'] . "'";
         $brand_desc_res = $GLOBALS['ISC_CLASS_DB']->Query($brand_desc_qry);
         if ($GLOBALS['ISC_CLASS_DB']->CountResult($brand_desc_res) > 0) {
             $brand_desc_arr = $GLOBALS['ISC_CLASS_DB']->Fetch($brand_desc_res);
         }
     }
     // for breadcrumbs
     $this->_BuildBreadCrumbs();
     /* the below line has been commented as client told to remove it */
     //$GLOBALS['SearchPhrase'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SearchPhrase");
     if ($GLOBALS['ISC_CLASS_NEWSEARCH']->GetNumResults() > 30) {
         $msg_qry = "select value from [|PREFIX|]display where messageid = 1";
         $msg_res = $GLOBALS['ISC_CLASS_DB']->Query($msg_qry);
         $msg_row = $GLOBALS['ISC_CLASS_DB']->FetchOne($msg_res);
         $GLOBALS['SearchPhrase'] = $msg_row;
         //$GLOBALS['SearchPhrase'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SearchPhrase");
     }
     /*if(!empty($params['dynfilters']))
     	 $GLOBALS['SearchPhrase'] .= " ".implode(" ",$params['dynfilters']);
     	 /*---------- Ending section for generating search phrase----------*/
     $vq_column_title = "";
     $GLOBALS['SearchResultList'] = "";
     $brand_rating = 0;
     if ($GLOBALS['ISC_CLASS_NEWSEARCH']->GetNumResults() > 0) {
         $category_rating = 0;
         if ($GLOBALS['results_page_flag'] == 1) {
             $brand_rating_qry = "select avg(revrating) as rating from [|PREFIX|]reviews r left join [|PREFIX|]products p on r.revproductid = p.productid left join [|PREFIX|]brands b on p.prodbrandid = b.brandid  where r.revstatus = 1 and b.brandname = '" . $params['brand'] . "'";
             $brand_rating_res = $GLOBALS['ISC_CLASS_DB']->Query($brand_rating_qry);
             $brand_rating_arr = $GLOBALS['ISC_CLASS_DB']->FetchOne($brand_rating_res);
             if (isset($brand_rating_arr['rating'])) {
                 $brand_rating = (int) $brand_rating_arr['rating'];
             }
         } else {
             if ($GLOBALS['results_page_flag'] == 0 && isset($selected_catg)) {
                 // 3rdAug2010: added the condition "isset($selected_catg)" as no need to show rating when only YMM is selected
                 // lguan_20100612: Category page mode, calculate the rating
                 //$catquery = $GLOBALS['ISC_CLASS_DB']->Query("SELECT categoryid FROM [|PREFIX|]categories where catparentid = $selected_catg");
                 $catquery = $GLOBALS['ISC_CLASS_DB']->Query("SELECT categoryid FROM [|PREFIX|]categories where catparentid in(" . implode(',', $selected_catg) . ")");
                 $catlistid = array();
                 while ($catrow = $GLOBALS['ISC_CLASS_DB']->Fetch($catquery)) {
                     $catlistid[] = $catrow['categoryid'];
                 }
                 $catcountlist = implode(",", $catlistid);
                 //lguan_20100612: Changed following codes to get product rating for categories
                 if (count($catlistid) > 0) {
                     $catcountlist = $selected_catg . "," . $catcountlist;
                 }
                 $cat_rating_res = $GLOBALS['ISC_CLASS_DB']->Query("SELECT floor(SUM(p.prodratingtotal)/SUM(p.prodnumratings))AS prodavgrating FROM [|PREFIX|]categoryassociations c INNER JOIN [|PREFIX|]products p on c.productid=p.productid where c.categoryid IN ({$catcountlist})");
                 $cat_rating_arr = $GLOBALS['ISC_CLASS_DB']->FetchOne($cat_rating_res);
                 if (isset($cat_rating_arr['prodavgrating'])) {
                     $category_rating = (int) $cat_rating_arr['prodavgrating'];
                 }
             }
         }
         /* displaying the dropdowns for YMM */
         if (!isset($params['make']) || !isset($params['year']) || !isset($params['model']) || isset($params['model_flag']) && $params['model_flag'] == 0) {
             $this->YMMSelectors($params);
         }
         // We have at least one result, let's show it to the world!
         $GLOBALS['HideNoResults'] = "none";
         // Only show the "compare" option if there are 2 or more products on this page
         if (GetConfig('EnableProductComparisons') == 0 || $GLOBALS['ISC_CLASS_DB']->CountResult($GLOBALS['SearchResults']) < 2) {
             $GLOBALS['HideCompareItems'] = "none";
         }
         if (GetConfig('EnableProductReviews') == 0) {
             $GLOBALS['HideProductRating'] = "display: none";
         }
         $mmy_links = $this->GetYMMLinks($params);
         $mmy_links .= $this->GetOtherLinks($params);
         $subcatId = array();
         if (isset($params['partnumber']) || $params['flag_srch_category'] == 1 || isset($params['flag_srch_category']) && isset($GLOBALS['BRAND_SERIES_FLAG']) && $GLOBALS['BRAND_SERIES_FLAG'] == 1) {
             $this->ShowProductList($mmy_links, $params, $catg_desc_arr, $ext_links, $vq_column_title);
         } else {
             if ($GLOBALS['results_page_flag'] == 0) {
                 //alandy mark.
                 //class.newsearch.php  $this->DoSearch($start, $GLOBALS['SearchResults'], $this->_numresults);
                 $this->ShowSubCategoies($mmy_links, $params, $catg_desc_arr, $subcatId, $catCustomFlag);
             } else {
                 $this->ShowSeriesPage($mmy_links, $params, $brand_rating);
             }
         }
         if (!$isDynamicPage) {
             $catCustomFlag = true;
         }
         ///wirror_code_mark_end
         $get_variables = $_GET;
         $sort_qry = "{$path}/search.php?search_query=" . urlencode($params['search_query']);
         unset($get_variables['orderby'], $get_variables['sort'], $get_variables['search_query'], $get_variables['sortby']);
         $i = 0;
         foreach ($get_variables as $key => $value) {
             $sort_qry .= "&{$key}={$value}";
         }
         if (isset($_REQUEST['sortby']) && $_REQUEST['sortby'] == 'desc') {
             $sort = "asc ";
             $img = "&nbsp;<img src='{$path}/templates/default/images/ArrowDown.gif' border=0>";
         } else {
             $sort = "desc ";
             $img = "&nbsp;<img src='{$path}/templates/default/images/ArrowUp.gif' border=0>";
         }
         //wirror_code_mark_begin
         //$GLOBALS['SearchResults'] = $GLOBALS['SearchResultList']; // commented by vikas
         if (isset($params['partnumber']) || $params['flag_srch_category'] == 1 || isset($params['flag_srch_category']) && isset($GLOBALS['BRAND_SERIES_FLAG']) && $GLOBALS['BRAND_SERIES_FLAG'] == 1) {
             if ($GLOBALS['EnableSEOUrls'] == 1) {
                 $GLOBALS['ProductBrand'] = "<a href='{$path}{$mmy_links}/orderby/brandname/sortby/{$sort}'>Brand / Series</a>";
                 $GLOBALS['ProductPartNumber'] = "<a href='{$path}{$mmy_links}/orderby/prodcode/sortby/{$sort}'>Image / Part#</a>";
                 $GLOBALS['ProductDetails'] = "<a href='{$path}{$mmy_links}/orderby/prodfinalprice/sortby/{$sort}'>Price</a>";
             } else {
                 $GLOBALS['ProductBrand'] = "<a href='{$path}/search.php?search_query={$mmy_links}&orderby=brandname&sortby={$sort}'>Brand / Series</a>";
                 $GLOBALS['ProductPartNumber'] = "<a href='{$path}/search.php?search_query={$mmy_links}&orderby=prodcode&sortby={$sort}'>Image / Part#</a>";
                 $GLOBALS['ProductDetails'] = "<a href='{$path}/search.php?search_query={$mmy_links}&orderby=prodfinalprice&sortby={$sort}'>Price</a>";
             }
             if (isset($_REQUEST['orderby']) && $_REQUEST['orderby'] == 'brandname') {
                 $GLOBALS['ProductBrand'] .= $img;
             }
             $GLOBALS['ProductVQ'] = $vq_column_title;
             /*if(isset($_GET['orderby']) && $_GET['orderby'] == 'brandname')
             	 $GLOBALS['Product_VQ'] .= $img;*/
             if (isset($_REQUEST['orderby']) && $_REQUEST['orderby'] == 'prodcode') {
                 $GLOBALS['ProductPartNumber'] .= $img;
             }
             $GLOBALS['ProductPQ'] = "Product Options";
             /*if(isset($_GET['orderby']) && $_GET['orderby'] == 'productoption')
             	 $GLOBALS['SearchResults'] .= $img;*/
             if (isset($_REQUEST['orderby']) && $_REQUEST['orderby'] == 'prodcalculatedprice') {
                 $GLOBALS['ProductPrice'] .= $img;
             }
             if (isset($_REQUEST['orderby']) && $_REQUEST['orderby'] == 'prodfinalprice') {
                 $GLOBALS['ProductDetails'] .= $img;
             }
             //wirror_20110324: replace the empyt ymm selector with the given picture
             if (!isset($GLOBALS['YMMTable']) || !$GLOBALS['YMMTable']) {
                 $GLOBALS['YMMTable'] = "<img src='/images/mmy-middle-6.jpg'/>";
             }
             $GLOBALS['SearchResults'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCategoryProductsItemHeader");
         } else {
             if ($catCustomFlag) {
                 //wirror_20100809: show the custom filter items
                 if ($isDynamicPage) {
                     $GLOBALS['DynamicDisplay'] = 'block';
                     $GLOBALS['YMMTableDisplay'] = 'block';
                 } else {
                     $GLOBALS['DynamicDisplay'] = 'none';
                     $GLOBALS['YMMTableDisplay'] = 'none';
                 }
                 //wirror_20100809: record the searched productids
                 $searchedProductIds = array();
                 $subcatIds = implode("','", $subcatId);
                 $querySubcatProdsStr = "\n\t\t\t\t\t\t    \tSELECT DISTINCT(p.productid)\n                \t\t\t\tFROM [|PREFIX|]products p\n                \t\t\t    LEFT JOIN [|PREFIX|]categoryassociations ca on ca.productid = p.productid\n                \t\t\t    %s\n                \t\t\t\tWHERE 1=1 \n                \t\t\t\tAND p.prodvisible='1'\n                \t\t\t\tAND ca.categoryid in ('{$subcatIds}')\n\t\t\t\t\t\t    ";
                 $hasYMM = false;
                 if (isset($params['year']) && !empty($params['year'])) {
                     $hasYMM = true;
                     $year = $params['year'];
                     $querySubcatProdsStr .= " AND ({$year} between v.prodstartyear and v.prodendyear OR v.prodstartyear = 'ALL')";
                 }
                 if (isset($params['make']) && !empty($params['make'])) {
                     $hasYMM = true;
                     $make = $params['make'];
                     $querySubcatProdsStr .= " AND (v.prodmake='{$make}' or v.prodmake='NON-SPEC VEHICLE')";
                 }
                 if (isset($params['model']) && !empty($params['model'])) {
                     $hasYMM = true;
                     $model = $params['model'];
                     $querySubcatProdsStr .= " AND (v.prodmodel='{$model}' or v.prodmodel='ALL')";
                 }
                 if ($hasYMM) {
                     $querySubcatProds = sprintf($querySubcatProdsStr, ' LEFT JOIN [|PREFIX|]import_variations v on v.productid = p.productid ');
                 } else {
                     $querySubcatProds = sprintf($querySubcatProdsStr, '');
                 }
                 $resultSubcatProds = $GLOBALS['ISC_CLASS_DB']->Query($querySubcatProds);
                 while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($resultSubcatProds)) {
                     $searchedProductIds[] = $row['productid'];
                 }
                 if (isset($_GET['debug']) && $_GET['debug'] == 1) {
                     //                			    echo $GLOBALS['DoSearchQuery'].'<br/>';
                     //                			    echo $querySubcatProds;echo '<br/>';
                     //                			    var_dump($searchedProductIds);
                     //                			    echo '<br/>';
                 }
                 $hasProds = false;
                 $GLOBALS['CatgDescandBrandImage'] = isset($catg_desc_arr['catdesc']) ? $catg_desc_arr['catdesc'] : '';
                 // description will be added here to show it at the top of subcatg page.
                 $GLOBALS['CustomPage'] = '';
                 foreach ($catg_custom_arr as $subArr) {
                     $pIds = explode(',', $subArr['productids']);
                     if (count($pIds) == 1 && in_array('0', $pIds)) {
                         $condArr = array('category' => $subArr['categoryid'], 'subscategory' => $subArr['subcategoryid'], 'brand' => $subArr['brandid'], 'series' => $subArr['seriesid']);
                         $pIdArr = GetClass('ISC_ADMIN_CUSTOMCONTENTS')->GetProductIds($condArr);
                     } else {
                         $pIdArr = $pIds;
                     }
                     //print_r($pIdArr);
                     if (!empty($searchedProductIds) && $this->is_subarray($pIdArr, $searchedProductIds)) {
                         $hasProds = true;
                         $GLOBALS['CustomPage'] .= $subArr['description'];
                     }
                 }
                 if ($hasProds) {
                     $GLOBALS['YMMTableDisplay'] = 'block';
                 } else {
                     //if there is no static items, show the dynamic page
                     if (!empty($searchedProductIds)) {
                         $GLOBALS['DynamicDisplay'] = 'block';
                     }
                     $GLOBALS['YMMTableDisplay'] = 'block';
                 }
             }
             //lguan_20100612: Show overal product rating at category landing page
             if ($category_rating != 0) {
                 //$GLOBALS['CatgDescandBrandImage'] .= "<br><h2>Rating : <img width='64' height='12' src='".$GLOBALS['TPL_PATH']."/images/IcoRating$category_rating.gif' alt='' /></h2>";
             }
             //		                $GLOBALS['SearchResults'] = "<div>".$GLOBALS['SearchResultList']."</div>";
             //wirror_20110324: replace the empyt ymm selector with the given picture
             if (!isset($GLOBALS['YMMTable']) || !$GLOBALS['YMMTable']) {
                 $GLOBALS['YMMTable'] = "<img src='/images/mmy-middle-6.jpg'/>";
             }
             $GLOBALS['SearchResults'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCategoryListingMain");
             /*
             //alandy_2012-1-19 modify.
             if(isset($GLOBALS['showDialog']) && !empty($GLOBALS['showDialog'])){
             	$showDialog = true;
             
             }
             */
             if ($GLOBALS['results_page_flag'] == 0 && !isset($params['srch_category'])) {
                 $GLOBALS['SearchLink'] = "";
                 if (isset($params['searchtext'])) {
                     $GLOBALS['SearchLink'] .= "/searchtext/" . MakeURLSafe(strtolower($params['searchtext']));
                 }
                 if (isset($params['search'])) {
                     $GLOBALS['SearchLink'] .= "/searchtext/" . MakeURLSafe(strtolower($params['search']));
                 }
                 if (isset($params['model']) && !isset($params['make'])) {
                     $GLOBALS['SearchLink'] .= "/model/" . MakeURLSafe(strtolower($params['model']));
                 }
                 if (isset($params['model_flag']) && $params['model_flag'] == 0 && !isset($params['make'])) {
                     $GLOBALS['SearchLink'] .= "/model_flag/" . MakeURLSafe(strtolower($params['model_flag']));
                 }
                 $GLOBALS['SearchResults'] = "";
                 if (isset($GLOBALS['YMMTable']) && $GLOBALS['YMMTable'] !== "<img src='/images/mmy-middle-6.jpg'/>") {
                     $GLOBALS['SearchResults'] .= "<div>" . $GLOBALS['YMMTable'] . "</div>";
                 }
                 if ($_REQUEST['is_smart_search']) {
                     $GLOBALS['SearchResults'] .= '<p class="ErrorMessage">' . GetLang('SearchYourSearch') . ' <strong>"' . htmlspecialchars($GLOBALS['OriginalSearchQuery']) . '"</strong> ' . GetLang('SearchDidNotMatch') . '</p>';
                     if ($GLOBALS['OriginalSearchQuery'] == '') {
                         $GLOBALS['SearchTitle'] = '';
                     } else {
                         $GLOBALS['SearchTitle'] = " " . sprintf(GetLang('SearchResultsFor'), $GLOBALS['OriginalSearchQuery']);
                         //$GLOBALS['SearchTitle'] = GetLang('SearchResultsFor');
                     }
                 }
                 //$GLOBALS['SearchResults'] .= "<div style='width:100%'><p class='InfoMessage'>Please choose a category or brand</p></div>";
                 $GLOBALS['CategoryBrandList'] = "%%Panel.StaticFeaturedCategories%%\n\t\t\t\t\t\t\t%%Panel.StaticFeaturedBrands%%";
                 $GLOBALS['HidePanels'][] = 'SearchPagingTop';
             }
         }
         $GLOBALS['SearchResults'] .= "<script type=\"text/javascript\"> \$('.focushiddendiv').css({'position':'absolute', 'margin-top':'-200px', 'display':'block'}); </script>";
         if ($GLOBALS['EnableSEOUrls'] == 1) {
             $back2url = $_SESSION['back2url'] = preg_replace("/^\\//", "", $_SERVER['REQUEST_URI']);
         } else {
             $back2url = $_SESSION['back2url'] = "search.php?" . $_SERVER['QUERY_STRING'];
         }
         ISC_SetCookie("back2search", $back2url, 0, "/");
         // Showing the syndication option?
         if (GetConfig('RSSNewProducts') != 0 && GetConfig('RSSCategories') != 0 && GetConfig('RSSSyndicationIcons') != 0) {
             $GLOBALS['RSSURL'] = SearchLink($GLOBALS['ISC_CLASS_NEWSEARCH']->GetQuery(), 0, false);
             $GLOBALS['SNIPPETS']['SearchResultsFeed'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SearchResultsFeed");
         }
         /*
         //alandy_2012-1-16 add logic.
         if(isset($showDialog) && $showDialog){
         	
         	$GLOBALS['Displaydialog'] = 5;
         }
         */
     } else {
         if (isset($GLOBALS['showDialog']) && !empty($GLOBALS['showDialog'])) {
             $GLOBALS['Displaydialog'] = 5;
             unset($GLOBALS['showDialog']);
         }
         $this->YMMSelectors($params);
         //alandy_2012-2-6 hidde middle ymm selector.
         //$GLOBALS['SearchResults'] = "<div>".$GLOBALS['YMMTable']."</div>";
         $GLOBALS['SearchResults'] = '';
         $GLOBALS['CategoryBrandList'] = "\n\t\t\t\n\t\t\t                                %%Panel.StaticFeaturedCategories%%\n\t\t\t\t                            %%Panel.StaticFeaturedBrands%%\n\t\t\t\t                           ";
         // No search results were found
         // commented below code as need to show the favorite categories and brands as in homepage
         // $GLOBALS['HideSearchResults'] = "none";
         //$GLOBALS['HidePanels'][] = 'SearchPageProducts';
     }
     //var_dump($GLOBALS['SearchResults']);exit;
 }
 public function SetPanelSettings()
 {
     $params = $GLOBALS['ISC_CLASS_ABTESTING']->_searchterms;
     $this->searchterms = $params;
     if ($GLOBALS['pagetype'] == 1) {
         return;
     }
     if ($GLOBALS['pagetype'] == 2 && isset($GLOBALS['pagecontent']) && $GLOBALS['pagecontent'] == 1) {
         $this->YMMSelectors($params);
         $GLOBALS['SearchResults'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("AbSubCategoryListingMain");
         return;
     }
     if ($GLOBALS['ISC_CLASS_ABTESTING']->GetNumResults() == 0) {
         $this->YMMSelectors($params);
         $GLOBALS['SearchResults'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("AbSubCategoryListingMain");
         return;
     }
     $count = 0;
     $output = "";
     /* Checking the search string. If it is used in any search, will be retained. else it will not be retained - starts */
     if (isset($this->searchterms['search'])) {
         $search_str = trim(str_ireplace($this->searchterms['search_string'], "", $this->searchterms['search']));
         if ($search_str == '') {
             unset($this->searchterms['search'], $params['search']);
         } else {
             $this->searchterms['search'] = $params['search'] = $search_str;
         }
     }
     $path = GetConfig('ShopPath');
     /* the below mmy links are passed to the breadcrumbs */
     $mmy_links = "";
     /*---------- This below section is for generating search phrase----------*/
     $GLOBALS['Category'] = "";
     $GLOBALS['MMY'] = "";
     $GLOBALS['PQ'] = "";
     $GLOBALS['VQ'] = "";
     $GLOBALS['SearchPhrase'] = "";
     $ext_links = "";
     // this variable is passed to the product detail page
     $seo_delim = "&";
     if ($GLOBALS['EnableSEOUrls'] == 1) {
         $seo_delim = "/";
     }
     if (isset($GLOBALS['ISC_SRCH_CATG_NAME'])) {
         $GLOBALS['Category'] .= $GLOBALS['ISC_SRCH_CATG_NAME'];
     }
     if (isset($params['year'])) {
         $GLOBALS['MMY'] .= $params['year'] . "<br>";
         $ext_links .= $seo_delim . "year=" . $params['year'];
     }
     if (isset($params['make'])) {
         $GLOBALS['MMY'] .= strtoupper($params['make']) . "<br>";
         $ext_links .= $seo_delim . "make=" . MakeURLSafe($params['make']);
     }
     if (isset($params['model']) && (!isset($params['model_flag']) || $params['model_flag'] == 1)) {
         $GLOBALS['MMY'] .= strtoupper($params['model']) . "<br>";
         $ext_links .= $seo_delim . "model=" . MakeURLSafe($params['model']);
     }
     /*else if(isset($params['model']))
       $ext_links .= $seo_delim."model=".$params['model'];*/
     /* this condition has been added seperately here to show submodel at last */
     if (isset($params['submodel'])) {
         $GLOBALS['MMY'] .= MakeURLSafe($params['submodel']) . "<br>";
     }
     /*if(isset($params['year'])) {
       $ext_links .= $seo_delim."year=".$params['year'];                
       }*/
     if (isset($params['dynfilters']) && !empty($params['dynfilters'])) {
         foreach ($params['dynfilters'] as $key => $value) {
             if (eregi('vq', $key)) {
                 $key = str_ireplace('vq', '', $key);
                 $GLOBALS['VQ'] .= ucfirst($key) . ": {$value}<br>";
             } else {
                 if (eregi('pq', $key)) {
                     $key = str_ireplace('pq', '', $key);
                     $GLOBALS['PQ'] .= ucfirst($key) . ": {$value}<br>";
                 }
             }
         }
     }
     $filter_var = array('vq', 'pq');
     /* this below patch is used for getting description of the category. Here currently the selected category id will be last one in the $params['srch_category'] array. if input['category'] is used then it will be the first one */
     if (!empty($params['srch_category'])) {
         if (isset($params['category'])) {
             $selected_catg = $params['srch_category'][0];
         } else {
             $selected_catg = end($params['srch_category']);
         }
         //wirror_20100806: add selected files like pagecontenttype and customcontentid;
         $catg_desc_qry = "select pagecontenttype, customcontentid, catdesc , categoryfooter  from [|PREFIX|]categories where categoryid = " . $selected_catg;
         $catg_desc_res = $GLOBALS['ISC_CLASS_DB']->Query($catg_desc_qry);
         if ($GLOBALS['ISC_CLASS_DB']->CountResult($catg_desc_res) > 0) {
             $catg_desc_arr = $GLOBALS['ISC_CLASS_DB']->Fetch($catg_desc_res);
         }
         /* this below patch is used to show the display name for the qualifiers from the qualifier association table */
         $map_names = array();
         $display_names = array();
         $filter_names = "select qid , column_name , display_names from [|PREFIX|]qualifier_names where column_name regexp '^(pq|vq)'";
         $filter_result = $GLOBALS['ISC_CLASS_DB']->Query($filter_names);
         while ($filter_row = $GLOBALS['ISC_CLASS_DB']->Fetch($filter_result)) {
             $map_names[$filter_row['qid']] = $filter_row['column_name'];
             $display_names[$filter_row['qid']] = $filter_row['display_names'];
         }
         $this->GetAssocDetails($selected_catg, $OwnAssoc, $ParentAssoc, $OwnValue, $ParentValue);
     }
     if (isset($params['brand'])) {
         $brand_desc_arr = array();
         $brand_desc_qry = "select branddescription , brandfooter from [|PREFIX|]brands where brandname = '" . $params['brand'] . "'";
         $brand_desc_res = $GLOBALS['ISC_CLASS_DB']->Query($brand_desc_qry);
         if ($GLOBALS['ISC_CLASS_DB']->CountResult($brand_desc_res) > 0) {
             $brand_desc_arr = $GLOBALS['ISC_CLASS_DB']->Fetch($brand_desc_res);
         }
     }
     // for breadcrumbs
     $this->_BuildBreadCrumbs();
     /* the below line has been commented as client told to remove it */
     //$GLOBALS['SearchPhrase'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SearchPhrase");
     if ($GLOBALS['ISC_CLASS_ABTESTING']->GetNumResults() > 30) {
         $msg_qry = "select value from [|PREFIX|]display where messageid = 1";
         $msg_res = $GLOBALS['ISC_CLASS_DB']->Query($msg_qry);
         $msg_row = $GLOBALS['ISC_CLASS_DB']->FetchOne($msg_res);
         $GLOBALS['SearchPhrase'] = $msg_row;
         //$GLOBALS['SearchPhrase'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SearchPhrase");
     }
     /*if(!empty($params['dynfilters']))
       $GLOBALS['SearchPhrase'] .= " ".implode(" ",$params['dynfilters']);
       /*---------- Ending section for generating search phrase----------*/
     $vq_column_title = "";
     $GLOBALS['SearchResultList'] = "";
     if ($GLOBALS['ISC_CLASS_ABTESTING']->GetNumResults() > 0) {
         $brand_rating = 0;
         $category_rating = 0;
         if ($GLOBALS['results_page_flag'] == 1) {
             $brand_rating_qry = "select avg(revrating) as rating from [|PREFIX|]reviews r left join [|PREFIX|]products p on r.revproductid = p.productid left join [|PREFIX|]brands b on p.prodbrandid = b.brandid  where r.revstatus = 1 and b.brandname = '" . $params['brand'] . "'";
             $brand_rating_res = $GLOBALS['ISC_CLASS_DB']->Query($brand_rating_qry);
             $brand_rating_arr = $GLOBALS['ISC_CLASS_DB']->FetchOne($brand_rating_res);
             if (isset($brand_rating_arr['rating'])) {
                 $brand_rating = (int) $brand_rating_arr['rating'];
             }
         } else {
             if ($GLOBALS['results_page_flag'] == 0 && isset($selected_catg)) {
                 // 3rdAug2010: added the condition "isset($selected_catg)" as no need to show rating when only YMM is selected
                 // lguan_20100612: Category page mode, calculate the rating
                 $catquery = $GLOBALS['ISC_CLASS_DB']->Query("SELECT categoryid FROM [|PREFIX|]categories where catparentid = {$selected_catg}");
                 $catlistid = array();
                 while ($catrow = $GLOBALS['ISC_CLASS_DB']->Fetch($catquery)) {
                     $catlistid[] = $catrow['categoryid'];
                 }
                 $catcountlist = implode(",", $catlistid);
                 //lguan_20100612: Changed following codes to get product rating for categories
                 if (count($catlistid) > 0) {
                     $catcountlist = $selected_catg . "," . $catcountlist;
                 }
                 $cat_rating_res = $GLOBALS['ISC_CLASS_DB']->Query("SELECT floor(SUM(p.prodratingtotal)/SUM(p.prodnumratings))AS prodavgrating FROM [|PREFIX|]categoryassociations c INNER JOIN [|PREFIX|]products p on c.productid=p.productid where c.categoryid IN ({$catcountlist})");
                 $cat_rating_arr = $GLOBALS['ISC_CLASS_DB']->FetchOne($cat_rating_res);
                 if (isset($cat_rating_arr['prodavgrating'])) {
                     $category_rating = (int) $cat_rating_arr['prodavgrating'];
                 }
             }
         }
         /* displaying the dropdowns for YMM */
         if (!isset($params['make']) || !isset($params['year']) || !isset($params['model']) || isset($params['model_flag']) && $params['model_flag'] == 0) {
             $this->YMMSelectors($params);
         }
         // We have at least one result, let's show it to the world!
         $GLOBALS['HideNoResults'] = "none";
         // Only show the "compare" option if there are 2 or more products on this page
         if (GetConfig('EnableProductComparisons') == 0 || $GLOBALS['ISC_CLASS_DB']->CountResult($GLOBALS['SearchResults']) < 2) {
             $GLOBALS['HideCompareItems'] = "none";
         }
         if (GetConfig('EnableProductReviews') == 0) {
             $GLOBALS['HideProductRating'] = "display: none";
         }
         $GLOBALS['AlternateClass'] = '';
         $counter = 1;
         $CurCatId = 0;
         $mmy_links = $this->GetYMMLinks($params);
         $mmy_links .= $this->GetOtherLinks($params);
         //wirror_code_mark_begin
         //wirror_20100809: record the searched productids
         $searchedProductIds = array();
         while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($GLOBALS['SearchResults'])) {
             /* Added by Simha to check inf prodcucts comes from different categories*/
             if (empty($params['srch_category']) || !isset($params['srch_category'])) {
                 if ($CurCatId != $row['categoryid']) {
                     $CurCatId = $row['categoryid'];
                     $map_names = array();
                     $display_names = array();
                     $filter_names = "SELECT DISTINCT qn.qid, qn.column_name, qn.display_names from \n                                                [|PREFIX|]qualifier_names qn\n                                                LEFT JOIN [|PREFIX|]qualifier_associations qa ON qa.qualifierid = qn.qid\n                                                WHERE (qa.categoryid = '{$CurCatId}') \n                                                AND qn.column_name regexp '^(pq|vq)'";
                     // || qa.categoryid IN (SELECT catparentid FROM isc_categories WHERE categoryid = '$CurCatId')
                     $filter_result = $GLOBALS['ISC_CLASS_DB']->Query($filter_names);
                     while ($filter_row = $GLOBALS['ISC_CLASS_DB']->Fetch($filter_result)) {
                         $map_names[$filter_row['qid']] = $filter_row['column_name'];
                         $display_names[$filter_row['qid']] = $filter_row['display_names'];
                     }
                     $this->GetAssocDetails($CurCatId, $OwnAssoc, $ParentAssoc, $OwnValue, $ParentValue);
                 }
             }
             /* Added by Simha Ends */
             $GLOBALS['SearchTrackClass'] = "TrackLink";
             $imagefile = "";
             if ($GLOBALS['AlternateClass'] == 'Odd') {
                 $GLOBALS['AlternateClass'] = 'Even';
             } else {
                 $GLOBALS['AlternateClass'] = 'Odd';
             }
             $qry_string = $_SERVER['QUERY_STRING'];
             if (isset($_GET['page'])) {
                 $page = "&page=" . $_GET['page'];
                 $qry_string = str_ireplace($page, '', $qry_string);
             }
             if ($GLOBALS['EnableSEOUrls'] == 1) {
                 if (isset($_GET['search_key'])) {
                     $qry_string = str_ireplace('&search_key=' . $_GET['search_key'], '', $qry_string);
                 }
                 if (isset($params['search_query']) && !strstr($qry_string, 'search_query=')) {
                     $qry_string .= "search_query=" . MakeURLSafe($params['search_query']);
                 }
                 if (isset($params['make']) && !strstr($qry_string, 'make=')) {
                     $qry_string .= "&make=" . MakeURLSafe($params['make']);
                 }
                 if (isset($params['model']) && !strstr($qry_string, 'model=')) {
                     $qry_string .= "&model=" . MakeURLSafe($params['model']);
                 }
                 if (isset($params['year']) && !strstr($qry_string, 'year=')) {
                     $qry_string .= "&year=" . MakeURLSafe($params['year']);
                 }
                 if (isset($params['make']) && !strstr($qry_string, 'make=')) {
                     $qry_string .= "&make=" . MakeURLSafe($params['make']);
                 }
                 if (isset($params['model_flag']) && !strstr($qry_string, 'model_flag=')) {
                     $qry_string .= "&model_flag=" . MakeURLSafe($params['model_flag']);
                 }
                 if (isset($params['submodel']) && !strstr($qry_string, 'submodel=')) {
                     $qry_string .= "&submodel=" . MakeURLSafe($params['submodel']);
                 }
             }
             if ($GLOBALS['results_page_flag'] == 0 && !isset($params['srch_category'])) {
                 break;
             }
             if ($GLOBALS['pagetype'] == 3) {
                 //wirror_mark_condition1
                 /*if( isset($params['srch_category']) )  {
                 			$GLOBALS['CatgDescandBrandImage'] = isset($catg_desc_arr['catdesc']) ? $catg_desc_arr['catdesc'] : ''; // description will be added here to show it at the top of product listing page.
                 		}*/
                 /*if(isset($params['category']) || ( !isset($params['subcategory']) && isset($params['series']) ))
                 							{
                 								$GLOBALS['CatgDescandBrandImage'] = $row['seriesdescription'];
                 								//$GLOBALS['CatgBrandSeriesFooter'] = $row['seriesfooter'];
                 								$GLOBALS['CatgBrandSeriesFooter'] = "";
                 
                 								if( ( isset($params['category']) || isset($params['subcategory']) ) && $GLOBALS['CatgDescandBrandImage'] == "" )
                 								{
                 									$GLOBALS['CatgDescandBrandImage'] = isset($catg_desc_arr['catdesc']) ? $catg_desc_arr['catdesc'] : '';
                 									//$GLOBALS['CatgBrandSeriesFooter'] = isset($catg_desc_arr['categoryfooter']) ? $catg_desc_arr['categoryfooter'] : '';
                 									$GLOBALS['CatgBrandSeriesFooter'] = "";
                 								}
                 
                 							}
                 							else if(isset($params['srch_category']))
                 							{
                 								$GLOBALS['CatgDescandBrandImage'] = isset($catg_desc_arr['catdesc']) ? $catg_desc_arr['catdesc'] : '';	
                 								$GLOBALS['CatgBrandSeriesFooter'] = isset($catg_desc_arr['categoryfooter']) ? $catg_desc_arr['categoryfooter'] : '';
                 								if( isset($params['series']) && $row['seriesdescription'] != "" )
                 								{
                 									$GLOBALS['CatgDescandBrandImage'] = $row['seriesdescription'];
                 									//$GLOBALS['CatgBrandSeriesFooter'] = $row['seriesfooter'];
                 									$GLOBALS['CatgBrandSeriesFooter'] = "";
                 								}
                 
                 								if($GLOBALS['CatgDescandBrandImage'] == '' && $GLOBALS['CatgBrandSeriesFooter'] == '' && isset($params['brand']))
                 								{
                 									$GLOBALS['CatgDescandBrandImage'] = isset($brand_desc_arr['branddescription']) ? $brand_desc_arr['branddescription'] : '';
                 									//$GLOBALS['CatgBrandSeriesFooter'] = isset($brand_desc_arr['brandfooter']) ? $brand_desc_arr['brandfooter'] : '';
                 									$GLOBALS['CatgBrandSeriesFooter'] = "";
                 								}
                 
                 							}
                 							else if(isset($params['brand']))
                 							{
                 								$GLOBALS['CatgDescandBrandImage'] = isset($brand_desc_arr['branddescription']) ? $brand_desc_arr['branddescription'] : '';
                 								$GLOBALS['CatgBrandSeriesFooter'] = isset($brand_desc_arr['brandfooter']) ? $brand_desc_arr['brandfooter'] : '';
                 							}*/
                 /* No need to show footer description when YMM are selected */
                 /*if( isset($params['make']) || isset($params['model']) || isset($params['year']) )
                 		{
                 			$GLOBALS['CatgBrandSeriesFooter'] = "";
                 		}*/
                 $GLOBALS['ProductCartQuantity'] = '';
                 if (isset($GLOBALS['CartQuantity' . $row['productid']])) {
                     $GLOBALS['ProductCartQuantity'] = (int) $GLOBALS['CartQuantity' . $row['productid']];
                 }
                 if ($counter % 2 == 0) {
                     $GLOBALS['RowColor'] = 'grayrow';
                 } else {
                     $GLOBALS['RowColor'] = 'whiterow';
                 }
                 $counter++;
                 $GLOBALS['ProductId'] = (int) $row['productid'];
                 $GLOBALS['ProductName'] = isc_html_escape($row['prodname']);
                 $GLOBALS['ProductLink'] = ProdLink($row['prodname']);
                 $GLOBALS['ProductRating'] = (int) $row['prodavgrating'];
                 //$GLOBALS['BrandName'] = $row['brandname'];
                 /* -- The below code is added to display the brand and series logo -- */
                 $GLOBALS['BrandName'] = "";
                 $brandlogo = realpath(ISC_BASE_PATH . '/product_images/' . $row['brandimagefile']);
                 if ($row['brandimagefile'] != '' && file_exists($brandlogo)) {
                     $GLOBALS['BrandName'] .= "<img src=\"" . $GLOBALS['ShopPath'] . "/product_images/" . $row['brandimagefile'] . "\" class=\"BrandSeriesLogo\" />";
                 } else {
                     $GLOBALS['BrandName'] .= $row['brandname'];
                 }
                 $serieslogo = realpath(ISC_BASE_PATH . '/series_images/' . $row['serieslogoimage']);
                 if ($row['serieslogoimage'] != '' && file_exists($serieslogo)) {
                     $GLOBALS['BrandName'] .= "<br><img src=\"" . $GLOBALS['ShopPath'] . "/series_images/" . $row['serieslogoimage'] . "\" />";
                 } else {
                     $GLOBALS['BrandName'] .= "<br>" . $row['seriesname'];
                 }
                 /* --- ends --- */
                 $GLOBALS['ProdCode'] = $row['prodcode'];
                 //$GLOBALS['ProdDesc'] = $this->strip_html_tags($row['proddesc']);
                 //$GLOBALS['ProdOptions'] = $row['productoption'];
                 $GLOBALS['VehicleOptions'] = "";
                 $GLOBALS['ProdOptions'] = "";
                 foreach ($row as $key => $val) {
                     if ($val != "" && $val != "~") {
                         if (($qualifier_id = array_search($key, $map_names)) !== false) {
                             if (eregi('^vq', $key)) {
                                 $val = trim($val, "~");
                                 $val = preg_split('/[~;]+/', $val);
                                 $val = array_unique($val);
                                 $val = array_values($val);
                                 $val = implode(",", $val);
                                 /* -- Setting display name for qualifier name -- */
                                 if (isset($OwnAssoc[$qualifier_id]) && $OwnAssoc[$qualifier_id][0]['qname'] != '') {
                                     $key = $OwnAssoc[$qualifier_id][0]['qname'];
                                 } else {
                                     if (isset($ParentAssoc[$qualifier_id]) && $ParentAssoc[$qualifier_id][0]['qname'] != '') {
                                         $key = $ParentAssoc[$qualifier_id][0]['qname'];
                                     } else {
                                         if (isset($display_names[$qualifier_id]) && !empty($display_names[$qualifier_id])) {
                                             $key = $display_names[$qualifier_id];
                                         } else {
                                             $key = ucfirst(str_ireplace($filter_var, "", $key));
                                         }
                                     }
                                 }
                                 /* -- Setting display name for qualifier name ends -- */
                                 /* -- Setting display name for qualifier value -- */
                                 if (isset($OwnValue[$qualifier_id]) && ($m = array_search(strtolower($val), $OwnValue[$qualifier_id])) !== false && $OwnAssoc[$qualifier_id][$m]['vname'] != "") {
                                     $val = $OwnAssoc[$qualifier_id][$m]['vname'];
                                 } else {
                                     if (isset($ParentValue[$qualifier_id]) && ($m = array_search(strtolower($val), $ParentValue[$qualifier_id])) !== false && $ParentAssoc[$qualifier_id][$m]['vname'] != "") {
                                         $val = $ParentAssoc[$qualifier_id][$m]['vname'];
                                     }
                                 }
                                 /* -- Setting display name for qualifier value ends-- */
                                 //$GLOBALS['VehicleOptions'] .= "<b>".$key."</b> : ".$val."<br>";
                                 $GLOBALS['VehicleOptions'] .= "<div class='qualifierwrap'><div class='qualifiertitle'>" . $key . " :</div> " . $val . "</div>";
                             }
                             if (eregi('^pq', $key)) {
                                 $val = trim($val, "~");
                                 $val = preg_split('/[~;]+/', $val);
                                 $val = array_unique($val);
                                 $val = array_values($val);
                                 $val = implode(",", $val);
                                 /* -- Setting display name for qualifier name -- */
                                 if (isset($OwnAssoc[$qualifier_id]) && $OwnAssoc[$qualifier_id][0]['qname'] != '') {
                                     $key = $OwnAssoc[$qualifier_id][0]['qname'];
                                 } else {
                                     if (isset($ParentAssoc[$qualifier_id]) && $ParentAssoc[$qualifier_id][0]['qname'] != '') {
                                         $key = $ParentAssoc[$qualifier_id][0]['qname'];
                                     } else {
                                         if (isset($display_names[$qualifier_id]) && !empty($display_names[$qualifier_id])) {
                                             $key = $display_names[$qualifier_id];
                                         } else {
                                             $key = ucfirst(str_ireplace($filter_var, "", $key));
                                         }
                                     }
                                 }
                                 /* -- Setting display name for qualifier name ends -- */
                                 /* -- Setting display name for qualifier value -- */
                                 if (isset($OwnValue[$qualifier_id]) && ($m = array_search(strtolower($val), $OwnValue[$qualifier_id])) !== false && $OwnAssoc[$qualifier_id][$m]['vname'] != '') {
                                     $val = $OwnAssoc[$qualifier_id][$m]['vname'];
                                 } else {
                                     if (isset($ParentValue[$qualifier_id]) && ($m = array_search(strtolower($val), $ParentValue[$qualifier_id])) !== false && $ParentValue[$qualifier_id][$m]['vname'] != '') {
                                         $val = $ParentAssoc[$qualifier_id][$m]['vname'];
                                     }
                                 }
                                 /* -- Setting display name for qualifier value ends-- */
                                 //$GLOBALS['ProdOptions'] .= "<b>".$key."</b> : ".$val."<br>";
                                 $GLOBALS['ProdOptions'] .= "<div class='qualifierwrap'><div class='qualifiertitle'>" . $key . " :</div> " . $val . "</div>";
                             }
                         }
                     }
                 }
                 if (isset($row['vehicleoption'])) {
                     $GLOBALS['VehicleOptions'] = $row['vehicleoption'];
                 }
                 if (isset($row['productoption'])) {
                     $GLOBALS['ProdOptions'] = $row['productoption'];
                 }
                 if (isset($row['catuniversal']) && $row['catuniversal'] == 1) {
                     $GLOBALS['VehicleOptions'] = $GLOBALS['ProductName'];
                     if ($vq_column_title == "") {
                         $vq_column_title = "Product Name";
                     } else {
                         if ($vq_column_title != "Product Name") {
                             $vq_column_title = "Product Name / Vehicle";
                         }
                     }
                 } else {
                     if ($vq_column_title == "") {
                         $vq_column_title = "Vehicle Options";
                     } else {
                         if ($vq_column_title != "Vehicle Options") {
                             $vq_column_title = "Product Name / Vehicle";
                         }
                     }
                 }
                 if (empty($GLOBALS['ProdOptions']) && empty($GLOBALS['VehicleOptions'])) {
                     $GLOBALS['ProdOptions'] = "&nbsp;";
                 }
                 if (empty($GLOBALS['VehicleOptions'])) {
                     $GLOBALS['VehicleOptions'] = "&nbsp;";
                 }
                 /*--- the below lines are added for back 2 search link in the product detail page. Also modified line no 56 & 60 --- */
                 if ($GLOBALS['EnableSEOUrls'] == 1) {
                     $GLOBALS['ProductLink'] .= "/refer=true" . $ext_links;
                     if (isset($GLOBALS['SearchId'])) {
                         $GLOBALS['ProductLink'] .= '/SearchLogId/' . $GLOBALS['SearchId'];
                     }
                 } else {
                     $GLOBALS['ProductLink'] .= "&refer=true" . $ext_links;
                     if (isset($GLOBALS['SearchId'])) {
                         $GLOBALS['ProductLink'] .= '&SearchLogId=' . $GLOBALS['SearchId'];
                     }
                 }
                 ### Added by Simha for onsale addition
                 // Determine the price of this product
                 //$GLOBALS['ProductPrice'] = CalculateProductPrice_retail($row);
                 $GLOBALS['ProductPrice'] = CalculateProductPriceRetail($row);
                 $FinalPrice = $GLOBALS['ProductPrice'];
                 $SalePrice = $row['prodsaleprice'];
                 //$DiscountAmount = $FinalPrice;
                 $discounttype = 0;
                 $discountname = '';
                 if ((double) $SalePrice > 0 && $SalePrice < $FinalPrice) {
                     $DiscountPrice = $SalePrice;
                 } else {
                     $DiscountPrice = $FinalPrice;
                     $DiscountPrice = CalculateDiscountPrice($FinalPrice, $DiscountPrice, $row['categoryid'], $row['brandseriesid'], $discounttype, $discountname);
                     /*if($discounttype == 0)    {
                           $DiscountPrice = $FinalPrice;
                       }*/
                 }
                 /*
                 							foreach($DiscountInfo as $DiscountInfoSub)   {  
                     if(isset($DiscountInfoSub['catids']))    {
                 								    $catids = explode(",", $DiscountInfoSub['catids']); 
                 								    foreach($catids as $catid) {
                 									    if($catid == $row['categoryid']) {
                 										    $DiscountAmount = $FinalPrice * ((int)$DiscountInfoSub['amount']/100); 
                 										    if ($DiscountAmount < 0) {
                 											    $DiscountAmount = 0;
                 										    }                                                                         
                 										    $DiscountPrice  = $FinalPrice - $DiscountAmount;  
                 									    } 
                 								    }  
                     }
                 							}       
                 */
                 if (isset($DiscountPrice) && $DiscountPrice < $FinalPrice && $discounttype == 0) {
                     //&& GetConfig('ShowOnSale')
                     $GLOBALS['ProductPrice'] = '<strike>' . CurrencyConvertFormatPrice($FinalPrice) . '</strike>';
                     $GLOBALS['ProductPrice'] .= '<br><div class="finalprice">' . CurrencyConvertFormatPrice($DiscountPrice) . '</div> ';
                     if (strtolower($discountname) == "clearance") {
                         $GLOBALS['ShowOnSaleImage'] = '<img id="OnSale" src="' . GetConfig('ShopPath') . '/templates/default/images/clearance.gif" alt="">';
                     } else {
                         $GLOBALS['ShowOnSaleImage'] = '<img id="OnSale" src="' . GetConfig('ShopPath') . '/templates/default/images/onsale.gif" alt="">';
                     }
                     if (GetConfig('ShowOnSale')) {
                         $GLOBALS['ProductPrice'] .= '' . $GLOBALS['ShowOnSaleImage'] . '';
                     }
                 } else {
                     $GLOBALS['ProductPrice'] = '<div class="finalprice">' . CurrencyConvertFormatPrice($FinalPrice) . '</div>';
                 }
                 ### Added by Simha Ends
                 // commented the below line by vikas
                 //$GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], ProdLink($row['prodname']));
                 $GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], $GLOBALS['ProductLink']);
                 if (isId($row['prodvariationid']) || trim($row['prodconfigfields']) != '' || $row['prodeventdaterequired'] == 1) {
                     //$GLOBALS['ProductURL'] = ProdLink($row['prodname']); // commented by vikas
                     $GLOBALS['ProductURL'] = $GLOBALS['ProductLink'];
                     $GLOBALS['ProductAddText'] = GetLang('ProductChooseOptionLink');
                 } else {
                     //$GLOBALS['ProductURL'] = CartLink($row['productid']);
                     //$GLOBALS['ProductURL'] = ProdLink($row['prodname']); // commented by vikas
                     $GLOBALS['ProductURL'] = $GLOBALS['ProductLink'];
                     //blessen
                     if (intval($row['prodretailprice']) <= 0) {
                         //$GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink'); // commented by vikas on 15-7-09
                         $GLOBALS['ProductAddText'] = "<img src='{$path}/templates/default/images/view.gif' border=0>";
                     } else {
                         //$GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink1'); // commented by vikas on 15-7-09
                         $GLOBALS['ProductAddText'] = "<img src='{$path}/templates/default/images/view.gif' border=0>";
                     }
                     //blessen
                     // original $GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink');
                 }
                 if (CanAddToCart($row) && GetConfig('ShowAddToCartLink')) {
                     $GLOBALS['HideActionAdd'] = '';
                 } else {
                     $GLOBALS['HideActionAdd'] = 'none';
                 }
                 $GLOBALS['HideProductVendorName'] = 'display: none';
                 $GLOBALS['ProductVendor'] = '';
                 if (GetConfig('ShowProductVendorNames') && $row['prodvendorid'] > 0) {
                     $vendorCache = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('Vendors');
                     if (isset($vendorCache[$row['prodvendorid']])) {
                         $GLOBALS['ProductVendor'] = '<a href="' . VendorLink($vendorCache[$row['prodvendorid']]) . '">' . isc_html_escape($vendorCache[$row['prodvendorid']]['vendorname']) . '</a>';
                         $GLOBALS['HideProductVendorName'] = '';
                     }
                 }
                 $GLOBALS['CartURL'] = CartLink($row['productid']);
                 if (isset($GLOBALS['SearchId'])) {
                     $GLOBALS['CartURL'] .= '&SearchLogId=' . $GLOBALS['SearchId'];
                 }
                 $offer = $this->IsProductMakeanOffer($row['brandseriesid'], $row['brandname'], $row['categoryid']);
                 if ($offer == 'yes') {
                     $GLOBALS['HideOfferButton'] = 'block';
                 } else {
                     $GLOBALS['HideOfferButton'] = 'none';
                 }
                 $GLOBALS['SearchResultList'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCategoryProductsItem");
             } else {
                 if ($GLOBALS['pagetype'] == 2) {
                     //wirror_mark_condition2
                     $isDynamicPage = $catg_desc_arr['pagecontenttype'] == 0 ? true : false;
                     $mmy_links_modified = $mmy_links;
                     if (!isset($GLOBALS['ISC_SRCH_CATG_ID'])) {
                         $parentid = $GLOBALS['categories_all'][$row['categoryid']]['catparentid'];
                         if ($parentid != 0) {
                             if (isset($GLOBALS['categories_all'][$parentid])) {
                                 // if parent catg is not visible
                                 $mmy_links_modified = $mmy_links;
                             } else {
                                 $mmy_links_modified = $mmy_links;
                             }
                         } else {
                             $mmy_links_modified = $mmy_links;
                         }
                     }
                     $subcatg_link = $this->LeftCatLink($mmy_links_modified, 'subcategory', $row['catname']);
                     $link = "<a href='" . $subcatg_link . "'>";
                     $tiplink = "<a class='thickbox1' href='" . $GLOBALS['ShopPath'] . "/catgbrand.php?categoryid=" . $row['categoryid'] . "&url=" . urlencode($subcatg_link) . "'  title=''><img src='{$path}/templates/default/images/fastlook_red.gif' border=0></a>";
                     $imagelink = "<a class='thickbox' href='" . $GLOBALS['ShopPath'] . "/catgbrand.php?categoryid=" . $row['categoryid'] . "&url=" . urlencode($subcatg_link) . "' title='' onmouseover='createtip(" . $row['categoryid'] . ")' onmouseout='UnTip()'>";
                     //$imagelink = "<a href='".$GLOBALS['ShopPath']."/catgbrand.php?categoryid=".$row['categoryid']."&url=$subcatg_link' class='thickbox' title=''>";
                     if (isset($row['imagefile']) && !empty($row['imagefile'])) {
                         $images = explode("~", $row['imagefile']);
                         for ($j = 0; $j < count($images); $j++) {
                             if (!empty($images[$j])) {
                                 $imagefile = "{$imagelink}<img src='{$path}/category_images/" . $images[$j] . "' alt='" . $row['catimagealt'] . "' title='" . $row['catimagealt'] . "'></a>";
                                 $imagefile .= "<span id='span" . $row['categoryid'] . "' style='display:none'>" . $tiplink . "</span>";
                                 break;
                             }
                         }
                     } else {
                         if (empty($row['imagefile']) || empty($imagefile)) {
                             $imagefile = "{$imagelink}<img src='{$path}/templates/default/images/ProductDefault.gif' border=0></a>";
                             $imagefile .= "<span id='span" . $row['categoryid'] . "' style='display:none'>" . $tiplink . "</span>";
                         }
                     }
                     $GLOBALS['LeftImage'] = $imagefile;
                     $GLOBALS['ProductsCount'] = "(" . $row['totalproducts'] . ") Products Available";
                     $row['brandname'] = str_replace('~', ' , ', $row['brandname']);
                     //$GLOBALS['RelatedBrands'] = $row['brandname'];
                     if (!empty($row['seriesname'])) {
                         $row['brandname'] .= "<br>" . $row['seriesname'];
                     }
                     $GLOBALS['CatgSeriesList'] = "";
                     if ($row['seriesids'] != "") {
                         $seriesids = str_ireplace("~", ",", $row['seriesids']);
                         $seriesids_qry = "select seriesid , brandname , seriesname from isc_brand_series bs left join isc_brands b on bs.brandid = b.brandid where seriesid in (" . $seriesids . ")";
                         $seriesids_res = $GLOBALS['ISC_CLASS_DB']->Query($seriesids_qry);
                         if ($GLOBALS['ISC_CLASS_DB']->CountResult($seriesids_res) > 0) {
                             while ($seriesids_arr = $GLOBALS['ISC_CLASS_DB']->Fetch($seriesids_res)) {
                                 if ($GLOBALS['CatgSeriesList'] == "") {
                                     $GLOBALS['CatgSeriesList'] .= "<br><a href='javascript:' onclick=\"checkanimate('" . $row['categoryid'] . "')\">View Brands ></a><div id='" . $row['categoryid'] . "' style='display:block'>";
                                 } else {
                                     $GLOBALS['CatgSeriesList'] .= "<br>";
                                 }
                                 $tooltipscript = "onmouseover='createtip(" . $row['categoryid'] . $seriesids_arr['seriesid'] . ")' onmouseout='UnTip()'";
                                 if (!isset($params['brand'])) {
                                     if ($GLOBALS['EnableSEOUrls'] == 1) {
                                         $series_link = $subcatg_link . "/brand/" . MakeURLSafe(Strtolower($seriesids_arr['brandname'])) . "/series/" . MakeURLSafe(Strtolower($seriesids_arr['seriesname']));
                                         $GLOBALS['CatgSeriesList'] .= "<a href='" . $subcatg_link . "/brand/" . MakeURLSafe(Strtolower($seriesids_arr['brandname'])) . "/series/" . MakeURLSafe(Strtolower($seriesids_arr['seriesname'])) . "' {$tooltipscript}>" . $seriesids_arr['brandname'] . " " . $seriesids_arr['seriesname'] . "</a>";
                                     } else {
                                         $series_link = $subcatg_link . "&brand=" . MakeURLSafe(Strtolower($seriesids_arr['brandname'])) . "&series=" . MakeURLSafe(Strtolower($seriesids_arr['seriesname']));
                                         $GLOBALS['CatgSeriesList'] .= "<a href='" . $subcatg_link . "&brand=" . MakeURLSafe(Strtolower($seriesids_arr['brandname'])) . "&series=" . MakeURLSafe(Strtolower($seriesids_arr['seriesname'])) . "' {$tooltipscript}>" . $seriesids_arr['brandname'] . " " . $seriesids_arr['seriesname'] . "</a>";
                                     }
                                 } else {
                                     if ($GLOBALS['EnableSEOUrls'] == 1) {
                                         $series_link = $subcatg_link . "/series/" . MakeURLSafe(Strtolower($seriesids_arr['seriesname']));
                                         $GLOBALS['CatgSeriesList'] .= "<a href='" . $subcatg_link . "/series/" . MakeURLSafe(Strtolower($seriesids_arr['seriesname'])) . "' {$tooltipscript}>" . $seriesids_arr['brandname'] . " " . $seriesids_arr['seriesname'] . "</a>";
                                     } else {
                                         $series_link = $subcatg_link . "&series=" . MakeURLSafe(Strtolower($seriesids_arr['seriesname']));
                                         $GLOBALS['CatgSeriesList'] .= "<a href='" . $subcatg_link . "&series=" . MakeURLSafe(Strtolower($seriesids_arr['seriesname'])) . "' {$tooltipscript}>" . $seriesids_arr['brandname'] . " " . $seriesids_arr['seriesname'] . "</a>";
                                     }
                                 }
                                 //wirror20100728: keep the catname consistent with the displayname
                                 $GLOBALS['CatgSeriesList'] .= "<span id='span" . $row['categoryid'] . $seriesids_arr['seriesid'] . "' style='display:none'><a class='thickbox1'  href='" . $GLOBALS['ShopPath'] . "/catgbrand.php?seriesid=" . $seriesids_arr['seriesid'] . "&catname=" . rawurlencode($row['catname']) . "&url=" . urlencode($series_link) . "' class='' ><img src='{$path}/templates/default/images/fastlook_red.gif' border=0></a></span>";
                             }
                             $GLOBALS['CatgSeriesList'] .= "</br></div>";
                         }
                     }
                     $content = $row['brandname'] . "<br>";
                     if (!isset($params['category']) && (isset($params['srch_category']) || !isset($GLOBALS['BRAND_SERIES_FLAG']))) {
                         /*$GLOBALS['CatgBrandSeriesFooter'] = isset($catg_desc_arr['categoryfooter']) ? $catg_desc_arr['categoryfooter'] : '';
                         		if( isset($params['make']) || isset($params['model']) || isset($params['year']) || isset($params['brand']) )
                         		{
                         			$GLOBALS['CatgBrandSeriesFooter'] = "";
                         		}*/
                         $content .= "<h3><a href='" . $path . "/search.php?{$qry_string}&subcategory=" . MakeURLSafe($row['catname']) . "'>" . $row['catname'] . "</a></h3>>";
                         $GLOBALS['TitleLink'] = "<h2><a href='" . $subcatg_link . "' onmouseover='createtip(" . $row['categoryid'] . ")' onmouseout='UnTip()'>" . $row['catname'] . "</a></h2>";
                     }
                     /*	copy the code to outer		
                     			//lguan_20100612: Show overal product rating at category landing page
                     			if($category_rating != 0)
                     			{
                     				$GLOBALS['CatgDescandBrandImage'] .= "<br><h2>Rating : <img width='64' height='12' src='".$GLOBALS['TPL_PATH']."/images/IcoRating$category_rating.gif' alt='' /></h2>";
                     			}
                     			*/
                     /*$ProdStartPrice = GetStartingPrice($row['categoryid'], $row['prodcalculatedprice']);
                                            
                     		$content .= "Price starting from $".number_format($ProdStartPrice, 2, '.', '')."<br>".$imagefile;*/
                     $GLOBALS['leftsidecontent'] = $content;
                     if (number_format($row['prodminprice'], 2, '.', '') < number_format($row['prodmaxprice'], 2, '.', '')) {
                         $GLOBALS['PriceRange'] = "Price range from \$" . number_format($row['prodminprice'], 2, '.', '') . " to \$" . number_format($row['prodmaxprice'], 2, '.', '');
                     } else {
                         $GLOBALS['PriceRange'] = "Available at \$" . number_format($row['prodminprice'], 2, '.', '');
                     }
                     //lguan_20100612: Show product ratings in categories/sub-categories page
                     $GLOBALS['Rating'] = isset($row['prodavgrating']) ? $row['prodavgrating'] : 0;
                     $GLOBALS['RatingVisible'] = $GLOBALS['Rating'] == 0 ? 'display:none' : '';
                     $content = "<img src='{$path}/templates/default/images/free-shipping2.gif'><br>" . strip_tags($row['proddesc']) . "<br>" . $row['prodwarranty'];
                     $GLOBALS['rightsidecontent'] = $content;
                     $GLOBALS['ShippingImage'] = "<img src='{$path}/templates/default/images/free-shipping2.gif'>";
                     $GLOBALS['ProductWarranty'] = "<h3>" . $row['prodwarranty'] . "</h3>";
                     $GLOBALS['ViewDetailsImage'] = "<a href='{$path}/catgbrand.php?categoryid=" . $row['categoryid'] . "&url=" . urlencode($subcatg_link) . "' class='thickbox'><img src='{$path}/templates/default/images/fastlook_red.gif'></a> ";
                     $content = "{$link}<img src='{$path}/templates/default/images/viewproducts.gif'></a>";
                     $GLOBALS['ViewDetailsImage'] .= $content;
                     $discountname = '';
                     if (IsDiscountAvailable('category', $row['categoryid'], $discountname)) {
                         if (strtolower($discountname) == "clearance") {
                             $GLOBALS['ViewDetailsImage'] .= '<img id="OnSale" src="' . GetConfig('ShopPath') . '/templates/default/images/clearance.gif" alt="">';
                         } else {
                             $GLOBALS['ViewDetailsImage'] .= '<img id="OnSale" src="' . GetConfig('ShopPath') . '/templates/default/images/onsale.gif" alt="">';
                         }
                     }
                     if ($this->IsMakeAnOffer('category', $row['categoryid']) == 'yes') {
                         $GLOBALS['ViewDetailsImage'] .= "<h3>Qualifies for Make an Offer!</h3>";
                     }
                     $GLOBALS['RelatedBrands'] = $row['featurepoints'];
                     $GLOBALS['lowersidecontent'] = $content;
                     $GLOBALS['SearchResultList'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCategoryListing");
                 }
             }
         }
         ///wirror_code_mark_end
         $get_variables = $_GET;
         $sort_qry = "{$path}/search.php?search_query=" . urlencode($params['search_query']);
         unset($get_variables['orderby'], $get_variables['sort'], $get_variables['search_query'], $get_variables['sortby']);
         $i = 0;
         foreach ($get_variables as $key => $value) {
             $sort_qry .= "&{$key}={$value}";
         }
         if (isset($_REQUEST['sortby']) && $_REQUEST['sortby'] == 'desc') {
             $sort = "asc ";
             $img = "&nbsp;<img src='{$path}/templates/default/images/ArrowDown.gif' border=0>";
         } else {
             $sort = "desc ";
             $img = "&nbsp;<img src='{$path}/templates/default/images/ArrowUp.gif' border=0>";
         }
         //wirror_code_mark_begin
         //$GLOBALS['SearchResults'] = $GLOBALS['SearchResultList']; // commented by vikas
         if (isset($params['partnumber']) || $params['flag_srch_category'] == 1 || isset($params['flag_srch_category']) && isset($GLOBALS['BRAND_SERIES_FLAG']) && $GLOBALS['BRAND_SERIES_FLAG'] == 1) {
             $path = $path . "/a-b-testing";
             if ($GLOBALS['EnableSEOUrls'] == 1) {
                 $GLOBALS['ProductBrand'] = "<a href='{$path}{$mmy_links}/orderby/brandname/sortby/{$sort}'>Brand / Series</a>";
                 $GLOBALS['ProductPartNumber'] = "<a href='{$path}{$mmy_links}/orderby/prodcode/sortby/{$sort}'>Image / Part#</a>";
                 $GLOBALS['ProductDetails'] = "<a href='{$path}{$mmy_links}/orderby/prodfinalprice/sortby/{$sort}'>Price</a>";
             } else {
                 $GLOBALS['ProductBrand'] = "<a href='{$path}/search.php?search_query={$mmy_links}&orderby=brandname&sortby={$sort}'>Brand / Series</a>";
                 $GLOBALS['ProductPartNumber'] = "<a href='{$path}/search.php?search_query={$mmy_links}&orderby=prodcode&sortby={$sort}'>Image / Part#</a>";
                 $GLOBALS['ProductDetails'] = "<a href='{$path}/search.php?search_query={$mmy_links}&orderby=prodfinalprice&sortby={$sort}'>Price</a>";
             }
             if (isset($_REQUEST['orderby']) && $_REQUEST['orderby'] == 'brandname') {
                 $GLOBALS['ProductBrand'] .= $img;
             }
             $GLOBALS['ProductVQ'] = $vq_column_title;
             /*if(isset($_GET['orderby']) && $_GET['orderby'] == 'brandname')
             		$GLOBALS['Product_VQ'] .= $img;*/
             if (isset($_REQUEST['orderby']) && $_REQUEST['orderby'] == 'prodcode') {
                 $GLOBALS['ProductPartNumber'] .= $img;
             }
             $GLOBALS['ProductPQ'] = "Product Options";
             /*if(isset($_GET['orderby']) && $_GET['orderby'] == 'productoption')
             		$GLOBALS['SearchResults'] .= $img;*/
             if (isset($_REQUEST['orderby']) && $_REQUEST['orderby'] == 'prodcalculatedprice') {
                 $GLOBALS['ProductPrice'] .= $img;
             }
             if (isset($_REQUEST['orderby']) && $_REQUEST['orderby'] == 'prodfinalprice') {
                 $GLOBALS['ProductDetails'] .= $img;
             }
             $GLOBALS['SearchResults'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("AbSubCategoryProductsItemHeader");
         } else {
             //lguan_20100612: Show overal product rating at category landing page
             /*if($category_rating != 0)
             		{
             			$GLOBALS['CatgDescandBrandImage'] .= "<br><h2>Rating : <img width='64' height='12' src='".$GLOBALS['TPL_PATH']."/images/IcoRating$category_rating.gif' alt='' /></h2>";
             		}*/
             //		                $GLOBALS['SearchResults'] = "<div>".$GLOBALS['SearchResultList']."</div>";
             $GLOBALS['SearchResults'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("AbSubCategoryListingMain");
             if ($GLOBALS['results_page_flag'] == 0 && !isset($params['srch_category'])) {
                 $GLOBALS['SearchLink'] = "";
                 if (isset($params['searchtext'])) {
                     $GLOBALS['SearchLink'] .= "/searchtext/" . MakeURLSafe(strtolower($params['searchtext']));
                 }
                 if (isset($params['search'])) {
                     $GLOBALS['SearchLink'] .= "/searchtext/" . MakeURLSafe(strtolower($params['search']));
                 }
                 if (isset($params['model']) && !isset($params['make'])) {
                     $GLOBALS['SearchLink'] .= "/model/" . MakeURLSafe(strtolower($params['model']));
                 }
                 if (isset($params['model_flag']) && $params['model_flag'] == 0 && !isset($params['make'])) {
                     $GLOBALS['SearchLink'] .= "/model_flag/" . MakeURLSafe(strtolower($params['model_flag']));
                 }
                 $GLOBALS['SearchResults'] = "";
                 if (isset($GLOBALS['YMMTable'])) {
                     $GLOBALS['SearchResults'] .= "<div>" . $GLOBALS['YMMTable'] . "</div>";
                 }
                 if ($_REQUEST['is_smart_search']) {
                     $GLOBALS['SearchResults'] .= '<p class="ErrorMessage">' . GetLang('SearchYourSearch') . ' <strong>"' . htmlspecialchars($GLOBALS['OriginalSearchQuery']) . '"</strong> ' . GetLang('SearchDidNotMatch') . '</p>';
                     if ($GLOBALS['OriginalSearchQuery'] == '') {
                         $GLOBALS['SearchTitle'] = '';
                     } else {
                         $GLOBALS['SearchTitle'] = " " . sprintf(GetLang('SearchResultsFor'), $GLOBALS['OriginalSearchQuery']);
                     }
                 }
                 //$GLOBALS['SearchResults'] .= "<div style='width:100%'><p class='InfoMessage'>Please choose a category or brand</p></div>";
                 $GLOBALS['CategoryBrandList'] = "%%Panel.StaticFeaturedCategories%%\n\t\t\t\t\t\t\t%%Panel.StaticFeaturedBrands%%";
                 $GLOBALS['HidePanels'][] = 'SearchPagingTop';
             }
         }
         $GLOBALS['SearchResults'] .= "<script type=\"text/javascript\"> \$('.focushiddendiv').css({'position':'absolute', 'margin-top':'-200px', 'display':'block'}); </script>";
         if ($GLOBALS['EnableSEOUrls'] == 1) {
             $back2url = $_SESSION['back2url'] = preg_replace("/^\\//", "", $_SERVER['REQUEST_URI']);
         } else {
             $back2url = $_SESSION['back2url'] = "search.php?" . $_SERVER['QUERY_STRING'];
         }
         ISC_SetCookie("back2search", $back2url, 0, "/");
     } else {
         $this->YMMSelectors($params);
         $GLOBALS['SearchResults'] = "<div>" . $GLOBALS['YMMTable'] . "</div>";
         $GLOBALS['CategoryBrandList'] = "%%Panel.StaticFeaturedCategories%%\n\t\t\t\t%%Panel.StaticFeaturedBrands%%";
         // No search results were found
         // commented below code as need to show the favorite categories and brands as in homepage
         /*$GLOBALS['HideSearchResults'] = "none";
         		$GLOBALS['HidePanels'][] = 'SearchPageProducts';*/
     }
 }
Example #6
0
 public function _AddToRecentlyViewedProducts()
 {
     /*
     	Store this product's ID in a persistent cookie
     	that will be used to remember the last 5 products
     	that this person has viewed
     */
     $viewed_products = array();
     if (isset($_COOKIE['RECENTLY_VIEWED_PRODUCTS'])) {
         $viewed_products = explode(",", $_COOKIE['RECENTLY_VIEWED_PRODUCTS']);
     }
     if (in_array($this->GetProductId(), $viewed_products)) {
         // Remove it from the array
         foreach ($viewed_products as $k => $v) {
             if ($v == $this->GetProductId()) {
                 unset($viewed_products[$k]);
             }
         }
     }
     // Add it to the list
     $viewed_products[] = $this->GetProductId();
     // Only store the 5 most recent product Id's
     if (count($viewed_products) > 5) {
         $reverse_viewed_products = array_reverse($viewed_products);
         $viewed_products = array();
         for ($i = 0; $i < 5; $i++) {
             $viewed_products[] = $reverse_viewed_products[$i];
         }
         // Reverse the array so the oldest products show first
         $viewed_products = array_reverse($viewed_products);
     }
     $new_viewed_products = implode(",", $viewed_products);
     // Persist the cookie for 30 days
     ISC_SetCookie("RECENTLY_VIEWED_PRODUCTS", $new_viewed_products, time() + 3600 * 24 * 30);
     // Persist the cookie session-wide for use on the cart page
     $_SESSION['RECENTLY_VIEWED_PRODUCTS'] = $new_viewed_products;
 }
Example #7
0
    public function ProcessLogin()
    {
        //zcs=>authenticate captcha when it is not a QA user
        if (GetConfig('UserQA') != $_POST['username']) {
            $GLOBALS['ISC_CLASS_CAPTCHA'] = GetClass('ISC_CAPTCHA');
            $captcha = trim($_REQUEST['captcha']);
            if (isc_strtolower($captcha) != isc_strtolower($GLOBALS['ISC_CLASS_CAPTCHA']->LoadSecret())) {
                // Captcha validation failed
                $GLOBALS['ISC_CLASS_ADMIN_AUTH']->DoLogin(false, false, GetLang('InvalidCaptcha'));
                die;
            }
        }
        //<=zcs
        $loginName = '';
        $loginPass = '';
        if ((!isset($_POST['username']) || !isset($_POST['password'])) && !isset($_COOKIE['RememberToken'])) {
            $GLOBALS['ISC_CLASS_ADMIN_AUTH']->DoLogin(true);
            return;
        }
        // Is this an automatic login from "Remember Me" being ticked?
        if (isset($_POST['username'])) {
            $loginName = @$_POST['username'];
            $loginPass = @$_POST['password'];
            //zcs= add "fails" "userstatus" & remove " and userstatus='1'"
            $query = sprintf("SELECT pk_userid, username, userpass, token, userimportpass, fails, userstatus FROM [|PREFIX|]users WHERE username='******'", $GLOBALS['ISC_CLASS_DB']->Quote($loginName));
        } else {
            if (isset($_COOKIE['RememberToken']) && trim($_COOKIE['RememberToken']) != '') {
                $md5 = $_COOKIE['RememberToken'];
                //zcs= add "fails" "userstatus" & remove " userstatus='1' AND"
                $query = sprintf("SELECT pk_userid, username, userpass, token, userimportpass, fails, userstatus FROM [|PREFIX|]users WHERE md5(concat(username, token))='%s'", $GLOBALS['ISC_CLASS_DB']->Quote($md5));
            } else {
                // Otherwise, we have a bad username/password
                $GLOBALS['ISC_CLASS_LOG']->LogAdminAction("invalid", $loginName);
                $GLOBALS['ISC_CLASS_ADMIN_AUTH']->DoLogin(true);
                die;
            }
        }
        if (isset($_POST['remember']) || isset($_COOKIE['RememberToken'])) {
            $remember = true;
        } else {
            $remember = false;
        }
        ob_start();
        // Try and find a user with the same credentials
        $userResult = $GLOBALS["ISC_CLASS_DB"]->Query($query);
        if ($userRow = $GLOBALS["ISC_CLASS_DB"]->Fetch($userResult)) {
            //zcs=>if already locked user, change message & get out
            if ($userRow['userstatus'] == 0) {
                $GLOBALS['ISC_CLASS_LOG']->LogAdminAction("has been locked", $loginName);
                $GLOBALS['ISC_CLASS_ADMIN_AUTH']->DoLogin(false, false, GetLang('LockedUser'));
                die;
            }
            //<=zcs
            if (!$remember) {
                ISC_SetCookie("RememberToken", "", time() - 3600 * 24 * 365, true);
            }
            // Was this an improted password?
            if ($userRow['userimportpass'] != '' && $userRow['userpass'] != md5($loginPass)) {
                if (ValidateImportPassword($loginPass, $userRow['userimportpass'])) {
                    // Valid login from an import password. We now store the Interspire Shopping Cart version of the password
                    $updatedUser = array("userpass" => md5($loginPass), "userimportpass" => "", 'fails' => 0);
                    $GLOBALS['ISC_CLASS_DB']->UpdateQuery("users", $updatedUser, "pk_userid='" . $GLOBALS['ISC_CLASS_DB']->Quote($userRow['pk_userid']) . "'");
                } else {
                    $this->doLoginFailed($userRow['pk_userid'], $userRow['fails']);
                    //zcs=if failed
                    unset($userRow['pk_userid']);
                }
            } else {
                // Is this a "Remember Me" auto login or a form login?
                if (isset($_POST['username'])) {
                    if ($userRow['userpass'] != md5($loginPass)) {
                        $this->doLoginFailed($userRow['pk_userid'], $userRow['fails']);
                        //zcs=if failed
                        unset($userRow['pk_userid']);
                    } else {
                        //zcs=>clear last fails
                        if ($userRow['fails'] > 0) {
                            $this->clearFails($userRow['pk_userid']);
                        }
                        //<=zcs
                    }
                } else {
                    // If they get here then "Remember Me" was set and valid so we don't have to do anything
                }
            }
            if (isset($userRow['pk_userid'])) {
                // Set the auth session variable to true
                $_COOKIE['STORESUITE_CP_TOKEN'] = $userRow['token'];
                ISC_SetCookie("STORESUITE_CP_TOKEN", $userRow['token'], 0, true);
                if ($remember) {
                    ISC_SetCookie("RememberToken", md5($userRow['username'] . $userRow['token']), time() + 3600 * 24 * 365, true);
                }
                // Log the successful login to the administrators log
                $GLOBALS['ISC_CLASS_LOG']->LogAdminAction("valid");
                // Everything was OK and the user has been logged in successfully
                ?>
						<script type="text/javascript">
							document.location.href='index.php?ToDo=';
						</script>
					<?php 
                die;
            }
        }
        // Otherwise, we have a bad username/password
        $GLOBALS['ISC_CLASS_LOG']->LogAdminAction("invalid", $loginName);
        $GLOBALS['ISC_CLASS_ADMIN_AUTH']->DoLogin(true);
        die;
    }
Example #8
0
/**
 * Saves a users sort order in a cookie for when they return to the page later (preserve their sort order)
 *
 * @param string Unique identifier for the page we're saving this preference for.
 * @param string The field we're sorting by.
 * @param string The order we're sorting in.
 */
function SaveDefaultSortField($section, $field, $order)
{
    ISC_SetCookie("SORTING_PREFS[" . $section . "]", serialize(array($field, $order)));
}
 /**
  * Create the pending order in the database with the customers selected payment details, etc.
  *
  * @return array An array containing information about what needs to be done next.
  */
 public function SavePendingOrder()
 {
     $provider = null;
     $verifyPaymentProvider = true;
     $redirectToFinishOrder = false;
     $providerId = '';
     $pendingOrderResult = array();
     if (!isset($_SESSION['CHECKOUT']['PENDING_DATA'])) {
         return false;
     }
     // Did they agree to signup to any mailing lists?
     if (isset($_POST['join_mailing_list'])) {
         ISC_SetCookie("JOIN_MAILING_LIST", 1, time() + 3600 * 24 * 7);
     }
     if (isset($_POST['join_order_list'])) {
         ISC_SetCookie("JOIN_ORDER_LIST", 1, time() + 3600 * 24 * 7);
     }
     $orderTotal = $_SESSION['CHECKOUT']['PENDING_DATA']['ORDER_TOTAL'];
     $giftCertificateAmount = $_SESSION['CHECKOUT']['PENDING_DATA']['GIFTCERTIFICATE_AMOUNT'];
     $gatewayAmount = $_SESSION['CHECKOUT']['PENDING_DATA']['GATEWAY_AMOUNT'];
     $creditUsed = 0;
     $giftCertificates = array();
     // Find out what currency we are using. We'll need this later to display their previous orders in the currency that they have selected
     $selectedCurrency = GetCurrencyById($GLOBALS['CurrentCurrency']);
     if (isset($_SESSION['OFFERCART']['GIFTCERTIFICATES']) && is_array($_SESSION['OFFERCART']['GIFTCERTIFICATES'])) {
         $giftCertificates = $_SESSION['OFFERCART']['GIFTCERTIFICATES'];
         // Now we check that the gift certificates can actually be applied to the order
         $GLOBALS['ISC_CLASS_GIFT_CERTIFICATES'] = GetClass('ISC_GIFTCERTIFICATES');
         $badCertificates = array();
         $remainingBalance = 0;
         $GLOBALS['ISC_CLASS_GIFT_CERTIFICATES']->GiftCertificatesApplicableToOrder($orderTotal, $giftCertificates, $remainingBalance, $badCertificates);
         // One or more gift certificates were invalid so this order is now invalid
         if (count($badCertificates) > 0) {
             $badCertificatesList = '<strong>' . GetLang('BadGiftCertificates') . '</strong><ul>';
             foreach ($badCertificates as $code => $reason) {
                 if (is_array($reason) && $reason[0] == "expired") {
                     $reason = sprintf(GetLang('BadGiftCertificateExpired'), CDate($reason[1]));
                 } else {
                     $reason = GetLang('BadGiftCertificate' . ucfirst($reason));
                 }
                 $badCertificatesList .= sprintf("<li>%s - %s", isc_html_escape($code), $reason);
             }
             $badCertificatesList .= "</ul>";
             $pendingOrderResult = array('error' => GetLang('OrderContainedInvalidGiftCertificates'), 'errorDetails' => $badCertificatesList);
             return $pendingOrderResult;
         } else {
             if ($orderTotal == $giftCertificateAmount && $remainingBalance > 0) {
                 $pendingOrderResult = array('error' => GetLang('OrderTotalStillRemainingCertificates'));
                 return $pendingOrderResult;
             } else {
                 if ($orderTotal == $giftCertificateAmount) {
                     $providerId = 'giftcertificate';
                     $verifyPaymentProvider = false;
                     $redirectToFinishOrder = true;
                 }
             }
         }
     }
     // If the order total is 0, then we just forward the user on to the "Thank You" page and set the payment provider to ''
     if ($orderTotal == 0) {
         $providerId = '';
         $verifyPaymentProvider = false;
         $redirectToFinishOrder = true;
     }
     if ($verifyPaymentProvider) {
         if (isset($_POST['credit_checkout_provider']) && $_POST['credit_checkout_provider'] != "") {
             $_POST['checkout_provider'] = $_POST['credit_checkout_provider'];
         }
         $selected_provider = "";
         $providers = GetCheckoutModulesThatCustomerHasAccessTo(true);
         // If there's more than one, use the value they've chosen
         if (count($providers) > 1 && isset($_POST['checkout_provider']) || isset($_SESSION['CHECKOUT']['ProviderListHTML'])) {
             $selected_provider = $_POST['checkout_provider'];
         } else {
             if (count($providers) == 1) {
                 $selected_provider = $providers[0]['object']->GetId();
                 $_POST['checkout_provider'] = $selected_provider;
             } else {
                 $selected_provider = '';
             }
         }
         if (!isset($_POST['checkout_provider'])) {
             $_POST['checkout_provider'] = '';
         }
         // Are we using our store credit?
         $GLOBALS['ISC_CLASS_CUSTOMER'] = GetClass('ISC_CUSTOMER');
         $customer = $GLOBALS['ISC_CLASS_CUSTOMER']->GetCustomerDataByToken();
         if (isset($_POST['store_credit']) && $_POST['store_credit'] == 1 && $customer['custstorecredit'] > 0) {
             // User has not chosen a payment provider and can't afford this order using only store credit, throw back as error
             if (!$_POST['checkout_provider'] && $customer['custstorecredit'] < $orderTotal) {
                 return false;
             } else {
                 $onlyCredit = false;
                 $updateExtra = '';
                 // If we're only using store credit
                 $creditToUse = $orderTotal - $giftCertificateAmount;
                 if ($customer['custstorecredit'] >= $creditToUse) {
                     // Set the checkout provider
                     $providerId = 'storecredit';
                     $verifyPaymentProvider = false;
                     $redirectToFinishOrder = true;
                     $creditUsed = $creditToUse;
                     $onlyCredit = true;
                 } else {
                     // Using all of our store credit to pay for this order and we owe more.
                     $creditUsed = $customer['custstorecredit'];
                     $gatewayAmount -= $creditUsed;
                 }
             }
         }
     }
     // Now with round 2, do we still need to verify the payment provider?
     if ($verifyPaymentProvider) {
         // If there's more than one provider and one wasn't selected on the order confirmation screen then there's a problem
         if ((count($providers) == 0 || count($providers) > 1 && !isset($_POST['checkout_provider'])) && !isset($_SESSION['CHECKOUT']['ProviderListHTML'])) {
             return false;
         }
         // Is the payment provider selected actually valid?
         if (!GetModuleById('checkout', $provider, $selected_provider)) {
             return false;
         }
         $providerId = $provider->GetId();
     }
     // Load up all of the data for the items in the cart
     $GLOBALS['ISC_CLASS_MAKEAOFFER'] = GetClass('ISC_MAKEAOFFER');
     $cartItems = $GLOBALS['ISC_CLASS_MAKEAOFFER']->api->GetProductsInCart();
     // OK, we're successful down to here - do they want to create an account?
     if (isset($_SESSION['CHECKOUT']['CREATE_ACCOUNT'])) {
         $accountDetails = $_SESSION['CHECKOUT']['ACCOUNT_DETAILS'];
         $token = GenerateCustomerToken();
         $customerData = array('email' => trim($accountDetails['email']), 'password' => $accountDetails['password'], 'firstname' => $accountDetails['firstname'], 'lastname' => $accountDetails['lastname'], 'company' => $accountDetails['company'], 'phone' => $accountDetails['phone'], 'token' => $token);
         //alandy modify.2011-5-20.
         /*$sql="select customerid from [|PREFIX|]customers where custconemail='".$accountDetails['email']."'";
         		$query=$GLOBALS['ISC_CLASS_DB']->Query($sql);
         		while($rs=$GLOBALS['ISC_CLASS_DB']->Fetch($query)){
         		    $GLOBALS['Hasemailflag']="yes";
         		      return array(
         				    'error' => GetLang('AccountInternalError')
         			    );
         			    
         	        }*/
         $cusquery = "SELECT customerid\n\t\t\t\tFROM [|PREFIX|]customers\n\t\t\t\tWHERE isguest = 1 AND LOWER(custconemail)='" . $GLOBALS['ISC_CLASS_DB']->Quote(isc_strtolower($customerData['email'])) . "'";
         $cusresult = $GLOBALS['ISC_CLASS_DB']->Query($cusquery);
         $cusrow = $GLOBALS['ISC_CLASS_DB']->Fetch($cusresult);
         $custId = $cusrow['customerid'];
         if ($custId == '') {
             // 20110613 johnny add ---- add flag for guest user email don't exist
             if ($_SESSION['CHECKOUT']['PENDING_DATA']['GUEST_CHECKOUT']) {
                 $customerData['isguest'] = 1;
             }
             $customerId = $GLOBALS['ISC_CLASS_CUSTOMER']->CreateCustomerAccount($customerData, false, $accountDetails['autoAccount']);
         } else {
             if (!$_SESSION['CHECKOUT']['PENDING_DATA']['GUEST_CHECKOUT']) {
                 $customerId = $GLOBALS['ISC_CLASS_CUSTOMER']->CreateCustomerAccount($customerData, true, $accountDetails['autoAccount']);
                 /* delet already exist guest account
                 			$entity = new ISC_ENTITY_CUSTOMER();
                 			$entity->delete($custId);
                 			*/
             } else {
                 $customerId = $custId;
                 // update guest account in customer table for guest user email exist
                 $GLOBALS['ISC_CLASS_DB']->Query("UPDATE [|PREFIX|]customers SET custconfirstname = '" . $customerData['firstname'] . "', custconlastname = '" . $customerData['lastname'] . "' WHERE customerid = {$customerId}");
             }
         }
         if (!$customerId) {
             return array('error' => GetLang('AccountInternalError'));
         }
         if (!$_SESSION['CHECKOUT']['PENDING_DATA']['GUEST_CHECKOUT']) {
             $GLOBALS['ISC_CLASS_CUSTOMER']->LoginCustomerById($customerId, true);
         }
         unset($_SESSION['CHECKOUT']['CREATE_ACCOUNT']);
         unset($_SESSION['CHECKOUT']['ACCOUNT_DETAILS']);
         // Log the customer in
         @ob_end_clean();
     }
     if (isset($_COOKIE['SHOP_TOKEN'])) {
         $customerToken = $_COOKIE['SHOP_TOKEN'];
     } else {
         $customerToken = '';
     }
     $orderComments = '';
     if (isset($_REQUEST['ordercomments'])) {
         $orderComments = $_REQUEST['ordercomments'];
     }
     $checkoutSession = $_SESSION['CHECKOUT'];
     $pendingData = $checkoutSession['PENDING_DATA'];
     // Get a list of the vendors for all of the items in the cart, and loop through them
     // to build all of the pending orders
     $cartContent = $this->BreakdownCartByAddressVendorforshipping();
     //Changed to merging function by Simha
     $vendorOrderInfo = array();
     foreach ($cartContent as $vendorId => $addresses) {
         foreach ($addresses as $addressId => $products) {
             $allDigital = 1;
             $productArray = array();
             foreach ($products as $cartItemId => $product) {
                 // A physical product, mark as so
                 if ($product['data']['prodtype'] == PT_PHYSICAL) {
                     $allDigital = 0;
                 }
                 // Mark the quantity of this item
                 $productArray[$cartItemId] = $product['quantity'];
             }
             $vendorInfo = $pendingData['VENDORS'][$vendorId . '_' . $addressId];
             $vendorData = array('itemtotal' => $vendorInfo['ITEM_TOTAL'], 'taxcost' => $vendorInfo['TAX_COST'], 'taxname' => $vendorInfo['TAX_NAME'], 'taxrate' => $vendorInfo['TAX_RATE'], 'totalcost' => $vendorInfo['ORDER_TOTAL'], 'shippingcost' => @$_SESSION['CHECKOUT']['SHIPPING'][$vendorId][$addressId]['COST'], 'handlingcost' => @$_SESSION['CHECKOUT']['SHIPPING'][$vendorId][$addressId]['HANDLING'], 'shippingprovider' => @$_SESSION['CHECKOUT']['SHIPPING'][$vendorId][$addressId]['PROVIDER'], 'shippingmodule' => @$_SESSION['CHECKOUT']['SHIPPING'][$vendorId][$addressId]['MODULE'], 'isdigitalorder' => $allDigital, 'products' => $productArray);
             if ($addressId == 0) {
                 $addresses = $this->GetOrderShippingAddresses();
                 $vendorData['shippingaddress'] = $addresses[$addressId];
             } else {
                 $vendorData['shippingaddressid'] = $addressId;
             }
             // Shipping zones can be configured per vendor, so we need to be sure
             // to pass this along correctly too
             if (isset($vendorInfo['SHIPPING_ZONE'])) {
                 $shippingZone = GetShippingZoneById($vendorInfo['SHIPPING_ZONE']);
                 if (is_array($shippingZone)) {
                     $vendorData['ordshippingzoneid'] = $shippingZone['zoneid'];
                     $vendorData['ordshippingzone'] = $shippingZone['zonename'];
                 }
             }
             $vendorOrderInfo[$vendorId . '_' . $addressId] = $vendorData;
         }
     }
     // Set some defaults about the rest of the order
     $pendingOrder = array("customertoken" => $customerToken, 'paymentmethod' => $providerId, "storecreditamount" => $creditUsed, "giftcertificateamount" => $giftCertificateAmount, "giftcertificates" => $giftCertificates, "gatewayamount" => $gatewayAmount, 'totalincludestax' => $pendingData['TAX_INCLUDED'], "currencyid" => $selectedCurrency['currencyid'], "currencyexchangerate" => $selectedCurrency['currencyexchangerate'], 'ordercomments' => $orderComments, 'ipaddress' => GetIP(), 'vendorinfo' => $vendorOrderInfo);
     if (isset($customerId)) {
         $pendingOrder['customerid'] = $customerId;
     }
     // Determine the address ID we're using for billing
     if (is_array($_SESSION['CHECKOUT']['BILLING_ADDRESS'])) {
         $pendingOrder['billingaddress'] = $_SESSION['CHECKOUT']['BILLING_ADDRESS'];
     } else {
         $pendingOrder['billingaddressid'] = (int) $_SESSION['CHECKOUT']['BILLING_ADDRESS'];
     }
     if (isset($_POST['ordermessage'])) {
         $pendingOrder['ordermessage'] = $_POST['ordermessage'];
     } else {
         $pendingOrder['ordermessage'] = '';
     }
     /**
      * Save our custom fields. If we are creating a new account then split this up so the
      * account fields will go in the customers table and the rest will go in the orders table
      */
     if (isset($_SESSION['CHECKOUT']['CUSTOM_FIELDS']['customer']) && isset($customerId) && isId($customerId)) {
         $formSessionId = $GLOBALS['ISC_CLASS_FORM']->saveFormSessionManual($_SESSION['CHECKOUT']['CUSTOM_FIELDS']['customer']);
         if (isId($formSessionId)) {
             $updateData = array('customerid' => $customerId, 'email' => $customerData['email'], 'firstname' => $customerData['firstname'], 'lastname' => $customerData['lastname'], 'company' => $customerData['company'], 'phone' => $customerData['phone'], 'custformsessionid' => $formSessionId);
             $entity = new ISC_ENTITY_CUSTOMER();
             $entity->edit($updateData);
         }
     }
     /**
      * OK, now to store the custom address fields. Check here to see if we are not split
      * shipping (single order)
      */
     if (!isset($_SESSION['CHECKOUT']['IS_SPLIT_SHIPPING']) || !$_SESSION['CHECKOUT']['IS_SPLIT_SHIPPING']) {
         $pendingOrder['ordformsessionid'] = '';
         if (isset($_SESSION['CHECKOUT']['CUSTOM_FIELDS']) && is_array($_SESSION['CHECKOUT']['CUSTOM_FIELDS'])) {
             /**
              * Save the billing
              */
             if (isset($_SESSION['CHECKOUT']['CUSTOM_FIELDS']['billing']) && isset($pendingOrder['billingaddress']['saveAddress']) && $pendingOrder['billingaddress']['saveAddress']) {
                 $pendingOrder['billingaddress']['shipformsessionid'] = $GLOBALS['ISC_CLASS_FORM']->saveFormSessionManual($_SESSION['CHECKOUT']['CUSTOM_FIELDS']['billing']);
             }
             /**
              * Now for the shipping. Only save this once for all the shipping addresses
              */
             if (isset($_SESSION['CHECKOUT']['CUSTOM_FIELDS']['shipping'])) {
                 $shippSessId = $GLOBALS['ISC_CLASS_FORM']->saveFormSessionManual($_SESSION['CHECKOUT']['CUSTOM_FIELDS']['shipping']);
                 foreach ($pendingOrder['vendorinfo'] as $vendorId => $vendorData) {
                     if (isset($vendorData['shippingaddress']['saveAddress']) && $vendorData['shippingaddress']['saveAddress']) {
                         $pendingOrder['vendorinfo'][$vendorId]['shippingaddress']['shipformsessionid'] = $shippSessId;
                     }
                 }
             }
             /**
              * Now the orders. This part is tricky because the billing and shipping information
              * have the same keys (same fields used in the frontend). We need to split them up
              * into separate billing and shipping information and then save it
              */
             if (isset($_SESSION['CHECKOUT']['CUSTOM_FIELDS']['billing']) && is_array($_SESSION['CHECKOUT']['CUSTOM_FIELDS']['billing'])) {
                 /**
                  * We create a map first so we can map the shipping information to its proper field
                  * ID
                  */
                 $billingKeys = array_keys($_SESSION['CHECKOUT']['CUSTOM_FIELDS']['billing']);
                 $fieldAddressMap = $GLOBALS['ISC_CLASS_FORM']->mapAddressFieldList(FORMFIELDS_FORM_BILLING, $billingKeys);
                 /**
                  * OK, we have the map, now to split up the custom fields
                  */
                 $orderSessData = array();
                 foreach ($fieldAddressMap as $fieldId => $newShippingFieldId) {
                     $orderSessData[$fieldId] = $_SESSION['CHECKOUT']['CUSTOM_FIELDS']['billing'][$fieldId];
                     if (isset($_SESSION['CHECKOUT']['CUSTOM_FIELDS']['shipping'][$fieldId])) {
                         $orderSessData[$newShippingFieldId] = $_SESSION['CHECKOUT']['CUSTOM_FIELDS']['shipping'][$fieldId];
                     }
                 }
                 $pendingOrder['ordformsessionid'] = $GLOBALS['ISC_CLASS_FORM']->saveFormSessionManual($orderSessData);
             }
         }
         /**
          * This is for split shipping. Loop through each address to get their default custom
          * field data, combine it with the billing custom field data, create the form session
          * record and then save that ID for each address
          */
     } else {
         $shippingAddresses = $this->GetOrderShippingAddresses();
         $origFormSessionData = array();
         if (isset($_SESSION['CHECKOUT']['CUSTOM_FIELDS']['billing']) && is_array($_SESSION['CHECKOUT']['CUSTOM_FIELDS']['billing'])) {
             $origFormSessionData = $_SESSION['CHECKOUT']['CUSTOM_FIELDS']['billing'];
         }
         foreach ($pendingOrder['vendorinfo'] as $vendorId => $vendorData) {
             $address = null;
             $orderSessData = array();
             if (array_key_exists($vendorData['shippingaddressid'], $shippingAddresses)) {
                 $address = $shippingAddresses[$vendorData['shippingaddressid']];
             }
             if (isset($address['shipformsessionid']) && isId($address['shipformsessionid'])) {
                 $shippingSessionData = $GLOBALS['ISC_CLASS_FORM']->getSavedSessionData($address['shipformsessionid']);
                 if (is_array($shippingSessionData)) {
                     /**
                      * Same deal with this save session data because the billing and shipping data
                      * use the same fields and therefore have the same keys
                      */
                     $billingKeys = array_keys($origFormSessionData);
                     $fieldAddressMap = $GLOBALS['ISC_CLASS_FORM']->mapAddressFieldList(FORMFIELDS_FORM_BILLING, $billingKeys);
                     /**
                      * OK, we have the map, now to split up the custom fields
                      */
                     $orderSessData = array();
                     foreach ($fieldAddressMap as $fieldId => $newShippingFieldId) {
                         $orderSessData[$fieldId] = $origFormSessionData[$fieldId];
                         $orderSessData[$newShippingFieldId] = $shippingSessionData[$fieldId];
                     }
                 }
             }
             $newFormSessionId = $GLOBALS['ISC_CLASS_FORM']->saveFormSessionManual($orderSessData);
             if (isId($newFormSessionId)) {
                 $pendingOrder['vendorinfo'][$vendorId]['ordformsessionid'] = $newFormSessionId;
             }
         }
     }
     $pendingToken = CreateOrder($pendingOrder, $cartItems);
     // Try to add the record and if we can't then take them back to the shopping cart
     if (!$pendingToken) {
         return false;
     }
     // Persist the pending order token as a cookie for 24 hours
     ISC_SetCookie("SHOP_ORDER_TOKEN", $pendingToken, time() + 3600 * 24, true);
     $_COOKIE['SHOP_ORDER_TOKEN'] = $pendingToken;
     // Redirecting to finish order page?
     if ($redirectToFinishOrder) {
         return array('redirectToFinishOrder' => true);
     }
     $orderData = LoadPendingOrdersByToken($pendingToken);
     // Otherwise, the gateway want's to do something
     $provider->SetOrderData($orderData);
     // Is this an online payment provider? It would like to do something
     if ($provider->GetPaymentType() == PAYMENT_PROVIDER_ONLINE || method_exists($provider, "ShowPaymentForm")) {
         // Call the checkout process for the selected provider
         if (method_exists($provider, "ShowPaymentForm")) {
             return array('provider' => $provider, 'showPaymentForm' => true);
         } else {
             return array('provider' => $provider);
         }
     } else {
         return array('provider' => $provider);
     }
 }
Example #10
0
	/**
	 * Saves a users per page setting in a cookie for when they return to the page later
	 *
	 * @param string Unique identifier for the page we're saving this preference for.
	 * @param int The per page setting to save
	 */
	function SaveDefaultPerPage($section, $perPage = 20)
	{
		ISC_SetCookie("PERPAGE_PREFS[".$section."]", (int)$perPage);
	}
Example #11
0
		public function ProcessLogin($todo='')
		{
			$loginName='';
			$loginPass='';
			if((!isset($_POST['username']) || !isset($_POST['password'])) && !isset($_COOKIE['RememberToken'])) {
				$GLOBALS['ISC_CLASS_ADMIN_AUTH']->displayLoginForm(true);
				return;
			}

			// Is this an automatic login from "Remember Me" being ticked?
			$userManager = getClass('ISC_ADMIN_USER');
			$userRow = null;
			$autoLogin = false;
			if(isset($_POST['username'])) {
				$loginName = @$_POST['username'];
				$loginPass = @$_POST['password'];
				$userRow = $userManager->getUserByField('username', $loginName, '*');
			}
			else if(isset($_COOKIE['RememberToken']) && trim($_COOKIE['RememberToken']) != '') {
				$userRow = $userManager->getUserByField('md5(concat(username, token))', $_COOKIE['RememberToken'], '*');
				$autoLogin = true;
			}

			$remember = false;
			if(isset($_POST['remember']) || isset($_COOKIE['RememberToken'])) {
				$remember = true;
			}

			ob_start();

			// Try and find a user with the same credentials
			if($userRow != null && $userRow['userstatus'] == 1) {
				$uid = $userRow['pk_userid'];

				// check 1: lockout
				$lockout = (int) $userRow['attempt_lockout'];
				if ($lockout != 0 && $lockout > time()) {
					// user is currently being locked out due to too
					// many failed login attempts in a row
					$msg = GetLang('LockedOutError', array(
						'lockoutTime' => GetConfig('PCILoginLockoutTimeMin'),
						'unblockLink' => 'index.php?ToDo=unblock&step=sendEmail&t='.$uid,
					));
					$this->template->assign('AdminLogo', GetConfig('AdminLogo'));
					$this->template->assign('Message', $msg);
					$this->template->display('plain.tpl');
					die;
				}

				// check 2: expired password
				$expiry = $userManager->getPasswordExpiry($uid);
				if ($expiry != 0 && $expiry != 1 && time() > $expiry) {
					// if expiry is zero, user password is pre 6.0
					// if expiry is one, password expiry feature is disabled
					// otherwise, password has expired
					// send email and force user to change password
					$userManager->sendResetPasswordEmail($userRow['username'], true);
					$expireDays = (int) GetConfig('PCIPasswordExpiryTimeDay');
					FlashMessage(GetLang('PasswordExpired', array(
						'expireDays' => $expireDays,
					)), MSG_INFO);
					$GLOBALS['ISC_CLASS_ADMIN_AUTH']->displayLoginForm();
					return;
				}

				if (!$remember) {
					ISC_SetCookie("RememberToken", "", time() - 3600*24*365, true);
				}

				if ($autoLogin || $userManager->verifyPassword($uid, $loginPass) == true) {
					// Set the auth session variable to true
					$_COOKIE['STORESUITE_CP_TOKEN'] = $userRow['token'];
					ISC_SetCookie("STORESUITE_CP_TOKEN", $userRow['token'], 0, true);

					if($remember) {
						ISC_SetCookie("RememberToken", md5($userRow['username'] . $userRow['token']), time() + 3600*24*365, true);
					}

					// Log the successful login to the administrators log
					$GLOBALS['ISC_CLASS_LOG']->LogAdminAction("valid");
					$userManager->resetFailedLoginAttempt($uid);
					$userManager->updateLoginTimestamp($uid);

					// Everything was OK and the user has been logged in successfully
					header('Location: index.php?ToDo=' . $todo);
					die();
				} else {
					// record this failed attempt
					$userManager->addFailedLoginAttempt($uid);
				}
			}

			// Otherwise, we have a bad username/password
			$GLOBALS['ISC_CLASS_LOG']->LogAdminAction("invalid", $loginName);
			$GLOBALS['ISC_CLASS_ADMIN_AUTH']->displayLoginForm(true);
			die();
		}
Example #12
0
		/**
		 * Private function used for loggin in a customer
		 *
		 * @param mixed Either the customer's ID or record array.
		 * @param boolean Set to true to not show any error messages but return true or false depending on if the login was successful or not.
		 * @return boolean True if the login was successful.
		 */
		private function LoginCustomer($ClientRecord, $silent=false)
		{
			if (isId($ClientRecord)) {
				$ClientRecord = $GLOBALS['ISC_CLASS_DB']->Fetch($GLOBALS['ISC_CLASS_DB']->Query("SELECT * FROM [|PREFIX|]customers WHERE customerid=" . (int)$ClientRecord));
			}

			if (!is_array($ClientRecord)) {
				return false;
			}

			@ob_end_clean();

			if(!trim($ClientRecord['customertoken'])) {
				$custToken = GenerateCustomerToken();
				$updated_customer_token = array(
					"customertoken" => $custToken
				);
				$GLOBALS['ISC_CLASS_DB']->UpdateQuery("customers", $updated_customer_token, "customerid='".$GLOBALS['ISC_CLASS_DB']->Quote($ClientRecord['customerid'])."'");
				$ClientRecord['customertoken'] = $custToken;
			}


			ISC_SetCookie("SHOP_TOKEN", $ClientRecord['customertoken'], time()+(3600*24*7), true);

			// Make the cookie accessible via PHP as well
			$_COOKIE['SHOP_TOKEN'] = $ClientRecord['customertoken'];

			// Also store it in the session as well when we're transferring the session between domains
			$_SESSION['SHOP_TOKEN'] = $ClientRecord['customertoken'];

			if($silent == true) {
				return true;
			}

			if (isset($_SESSION['LOGIN_REDIR']) && $_SESSION['LOGIN_REDIR'] != '') {
				// Take them to the page they wanted
				$page = $_SESSION['LOGIN_REDIR'];
				unset($_SESSION['LOGIN_REDIR']);
				header(sprintf("Location: %s", $page));
			}
			else {
				// Take them to the "My Account" page
				header(sprintf("Location: %s/account.php", $GLOBALS['ShopPathNormal']));
			}

			die();
		}
Example #13
0
// Disable product comparisons if the template does not support them
if($GLOBALS['TPL_CFG']['MaxComparisonProducts'] == 0) {
	$GLOBALS['ISC_CFG']['EnableProductComparisons'] = false;
}

// check if the store is down for maintenance
if(GetConfig('DownForMaintenance')) {
	// we have token coming through
	if (!empty($_GET['ctk'])) {
		$token = $_GET['ctk'];
		// check if the token is valid for a user
		$query = "SELECT pk_userid FROM [|PREFIX|]users where token = '" . $GLOBALS['ISC_CLASS_DB']->Quote($token) . "'";
		$res = $GLOBALS['ISC_CLASS_DB']->Query($query);
		if ($GLOBALS['ISC_CLASS_DB']->CountResult($res)) {
			// set the cookie so the admin auth class will function
			ISC_SetCookie('STORESUITE_CP_TOKEN', $token, 0, true);
			$_COOKIE['STORESUITE_CP_TOKEN'] = $token;
		}
	}
	$GLOBALS['ISC_CLASS_ADMIN_AUTH'] = GetClass('ISC_ADMIN_AUTH');
	if(!$GLOBALS['ISC_CLASS_ADMIN_AUTH']->IsLoggedIn() || !$GLOBALS['ISC_CLASS_ADMIN_AUTH']->HasPermission(AUTH_See_Store_During_Maintenance)) {
		define('MAINTENANCE_IS_ADMIN', false);
		Store_DownForMaintenance::showDownForMaintenance();
		die();
	}

	define('MAINTENANCE_IS_ADMIN', true);

	if(isset($_GET['showStore']) && $_GET['showStore'] == 'yes') {
		$_SESSION['AdminShowStore'] = true;
	} elseif (isset($_GET['showStore']) && $_GET['showStore'] == 'no') {
 public function SetPanelSettings()
 {
     $count = 0;
     $output = "";
     $params = $GLOBALS['ISC_CLASS_SEARCH']->_searchterms;
     $this->searchterms = $params;
     $path = GetConfig('ShopPath');
     /* the below mmy links are passed to the breadcrumbs */
     $mmy_links = "";
     /*---------- This below section is for generating search phrase----------*/
     $GLOBALS['Category'] = "";
     $GLOBALS['MMY'] = "";
     $GLOBALS['PQ'] = "";
     $GLOBALS['VQ'] = "";
     $GLOBALS['SearchPhrase'] = "";
     $ext_links = "";
     // this variable is passed to the product detail page
     $seo_delim = "&";
     if ($GLOBALS['EnableSEOUrls'] == 1) {
         $seo_delim = "/";
     }
     if (isset($GLOBALS['ISC_SRCH_CATG_NAME'])) {
         $GLOBALS['Category'] .= $GLOBALS['ISC_SRCH_CATG_NAME'];
     }
     if (isset($params['year'])) {
         $GLOBALS['MMY'] .= $params['year'] . "<br>";
         $ext_links .= $seo_delim . "year=" . $params['year'];
     }
     if (isset($params['make'])) {
         $GLOBALS['MMY'] .= strtoupper($params['make']) . "<br>";
         $ext_links .= $seo_delim . "make=" . $params['make'];
     }
     if (isset($_REQUEST['model']) && !empty($_REQUEST['model']) && (!isset($params['model_flag']) || $params['model_flag'] != 0)) {
         $GLOBALS['MMY'] .= strtoupper($_REQUEST['model']) . "<br>";
         $ext_links .= $seo_delim . "model=" . strtoupper($params['model']);
     } else {
         if (isset($params['model'])) {
             $ext_links .= $seo_delim . "model=" . $params['model'];
         }
     }
     /* this condition has been added seperately here to show submodel at last */
     if (isset($params['submodel'])) {
         $GLOBALS['MMY'] .= strtoupper($params['submodel']) . "<br>";
     }
     /*if(isset($params['year'])) {
       $ext_links .= $seo_delim."year=".$params['year'];                
       }*/
     if (isset($params['dynfilters']) && !empty($params['dynfilters'])) {
         foreach ($params['dynfilters'] as $key => $value) {
             if (eregi('vq', $key)) {
                 $key = str_ireplace('vq', '', $key);
                 $GLOBALS['VQ'] .= ucfirst($key) . ": {$value}<br>";
             } else {
                 if (eregi('pq', $key)) {
                     $key = str_ireplace('pq', '', $key);
                     $GLOBALS['PQ'] .= ucfirst($key) . ": {$value}<br>";
                 }
             }
         }
     }
     $filter_var = array('vq', 'pq');
     /* this below patch is used for getting description of the category. Here currently the selected category id will be last one in the $params['srch_category'] array. if input['category'] is used then it will be the first one */
     if (!empty($params['srch_category'])) {
         if (isset($params['category'])) {
             $selected_catg = $params['srch_category'][0];
         } else {
             $selected_catg = end($params['srch_category']);
         }
         $catg_desc_qry = "select catdesc from [|PREFIX|]categories where categoryid = " . $selected_catg;
         $catg_desc_res = $GLOBALS['ISC_CLASS_DB']->Query($catg_desc_qry);
         if ($GLOBALS['ISC_CLASS_DB']->CountResult($catg_desc_res) > 0) {
             $catg_desc_arr = $GLOBALS['ISC_CLASS_DB']->Fetch($catg_desc_res);
         }
         /* this below patch is used to show the display name for the qualifiers from the qualifier association table */
         $map_names = array();
         $display_names = array();
         $filter_names = "select qid , column_name , display_names from [|PREFIX|]qualifier_names where column_name regexp '^(pq|vq)'";
         $filter_result = $GLOBALS['ISC_CLASS_DB']->Query($filter_names);
         while ($filter_row = $GLOBALS['ISC_CLASS_DB']->Fetch($filter_result)) {
             $map_names[$filter_row['qid']] = $filter_row['column_name'];
             $display_names[$filter_row['qid']] = $filter_row['display_names'];
         }
         $this->GetAssocDetails($selected_catg, $OwnAssoc, $ParentAssoc, $OwnValue, $ParentValue);
     }
     // for breadcrumbs
     $this->_BuildBreadCrumbs();
     /* the below line has been commented as client told to remove it */
     //$GLOBALS['SearchPhrase'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SearchPhrase");
     if ($GLOBALS['ISC_CLASS_SEARCH']->GetNumResults() > 30) {
         $msg_qry = "select value from [|PREFIX|]display where messageid = 1";
         $msg_res = $GLOBALS['ISC_CLASS_DB']->Query($msg_qry);
         $msg_row = $GLOBALS['ISC_CLASS_DB']->FetchOne($msg_res);
         $GLOBALS['SearchPhrase'] = $msg_row;
         //$GLOBALS['SearchPhrase'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SearchPhrase");
     }
     /*if(!empty($params['dynfilters']))
       $GLOBALS['SearchPhrase'] .= " ".implode(" ",$params['dynfilters']);
       /*---------- Ending section for generating search phrase----------*/
     $vq_column_title = "";
     $GLOBALS['SearchResultList'] = "";
     if ($GLOBALS['ISC_CLASS_SEARCH']->GetNumResults() > 0) {
         // We have at least one result, let's show it to the world!
         $GLOBALS['HideNoResults'] = "none";
         // Only show the "compare" option if there are 2 or more products on this page
         if (GetConfig('EnableProductComparisons') == 0 || $GLOBALS['ISC_CLASS_DB']->CountResult($GLOBALS['SearchResults']) < 2) {
             $GLOBALS['HideCompareItems'] = "none";
         }
         if (GetConfig('EnableProductReviews') == 0) {
             $GLOBALS['HideProductRating'] = "display: none";
         }
         $GLOBALS['AlternateClass'] = '';
         $counter = 1;
         $CurCatId = 0;
         $mmy_links = $this->GetYMMLinks($params);
         $mmy_links .= $this->GetOtherLinks($params);
         while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($GLOBALS['SearchResults'])) {
             /* Added by Simha to check inf prodcucts comes from different categories*/
             if (empty($params['srch_category']) || !isset($params['srch_category'])) {
                 if ($CurCatId != $row['categoryid']) {
                     $CurCatId = $row['categoryid'];
                     $map_names = array();
                     $display_names = array();
                     $filter_names = "SELECT DISTINCT qn.qid, qn.column_name, qn.display_names from \n                                                [|PREFIX|]qualifier_names qn\n                                                LEFT JOIN [|PREFIX|]qualifier_associations qa ON qa.qualifierid = qn.qid\n                                                WHERE (qa.categoryid = '{$CurCatId}') \n                                                AND qn.column_name regexp '^(pq|vq)'";
                     // || qa.categoryid IN (SELECT catparentid FROM isc_categories WHERE categoryid = '$CurCatId')
                     $filter_result = $GLOBALS['ISC_CLASS_DB']->Query($filter_names);
                     while ($filter_row = $GLOBALS['ISC_CLASS_DB']->Fetch($filter_result)) {
                         $map_names[$filter_row['qid']] = $filter_row['column_name'];
                         $display_names[$filter_row['qid']] = $filter_row['display_names'];
                     }
                     $this->GetAssocDetails($CurCatId, $OwnAssoc, $ParentAssoc, $OwnValue, $ParentValue);
                 }
             }
             /* Added by Simha Ends */
             $GLOBALS['SearchTrackClass'] = "TrackLink";
             $imagefile = "";
             if ($GLOBALS['AlternateClass'] == 'Odd') {
                 $GLOBALS['AlternateClass'] = 'Even';
             } else {
                 $GLOBALS['AlternateClass'] = 'Odd';
             }
             $qry_string = $_SERVER['QUERY_STRING'];
             if (isset($_GET['page'])) {
                 $page = "&page=" . $_GET['page'];
                 $qry_string = str_ireplace($page, '', $qry_string);
             }
             if ($GLOBALS['EnableSEOUrls'] == 1) {
                 if (isset($_GET['search_key'])) {
                     $qry_string = str_ireplace('&search_key=' . $_GET['search_key'], '', $qry_string);
                 }
                 if (isset($params['search_query']) && !strstr($qry_string, 'search_query=')) {
                     $qry_string .= "search_query=" . MakeURLSafe($params['search_query']);
                 }
                 if (isset($params['make']) && !strstr($qry_string, 'make=')) {
                     $qry_string .= "&make=" . MakeURLSafe($params['make']);
                 }
                 if (isset($params['model']) && !strstr($qry_string, 'model=')) {
                     $qry_string .= "&model=" . MakeURLSafe($params['model']);
                 }
                 if (isset($params['year']) && !strstr($qry_string, 'year=')) {
                     $qry_string .= "&year=" . MakeURLSafe($params['year']);
                 }
                 if (isset($params['make']) && !strstr($qry_string, 'make=')) {
                     $qry_string .= "&make=" . MakeURLSafe($params['make']);
                 }
                 if (isset($params['model_flag']) && !strstr($qry_string, 'model_flag=')) {
                     $qry_string .= "&model_flag=" . MakeURLSafe($params['model_flag']);
                 }
                 if (isset($params['submodel']) && !strstr($qry_string, 'submodel=')) {
                     $qry_string .= "&submodel=" . MakeURLSafe($params['submodel']);
                 }
             }
             if (isset($params['partnumber']) || $params['flag_srch_category'] == 1 || isset($params['flag_srch_category']) && isset($GLOBALS['BRAND_SERIES_FLAG']) && $GLOBALS['BRAND_SERIES_FLAG'] == 1) {
                 if (isset($params['srch_category'])) {
                     $GLOBALS['CatgDescandBrandImage'] = isset($catg_desc_arr['catdesc']) ? $catg_desc_arr['catdesc'] : '';
                     // description will be added here to show it at the top of product listing page.
                 }
                 $GLOBALS['ProductCartQuantity'] = '';
                 if (isset($GLOBALS['CartQuantity' . $row['productid']])) {
                     $GLOBALS['ProductCartQuantity'] = (int) $GLOBALS['CartQuantity' . $row['productid']];
                 }
                 if ($counter % 2 == 0) {
                     $GLOBALS['RowColor'] = 'grayrow';
                 } else {
                     $GLOBALS['RowColor'] = 'whiterow';
                 }
                 $counter++;
                 $GLOBALS['ProductId'] = (int) $row['productid'];
                 $GLOBALS['ProductName'] = isc_html_escape($row['prodname']);
                 $GLOBALS['ProductLink'] = ProdLink($row['prodname']);
                 $GLOBALS['ProductRating'] = (int) $row['prodavgrating'];
                 $GLOBALS['BrandName'] = $row['brandname'];
                 $GLOBALS['ProdCode'] = $row['prodcode'];
                 //$GLOBALS['ProdDesc'] = $this->strip_html_tags($row['proddesc']);
                 //$GLOBALS['ProdOptions'] = $row['productoption'];
                 $GLOBALS['VehicleOptions'] = "";
                 $GLOBALS['ProdOptions'] = "";
                 foreach ($row as $key => $val) {
                     if ($val != "" && $val != "~") {
                         if (($qualifier_id = array_search($key, $map_names)) !== false) {
                             if (eregi('^vq', $key)) {
                                 $val = trim($val, "~");
                                 $val = preg_split('/[~;]+/', $val);
                                 $val = array_unique($val);
                                 $val = array_values($val);
                                 $val = implode(",", $val);
                                 /* -- Setting display name for qualifier name -- */
                                 if (isset($OwnAssoc[$qualifier_id]) && $OwnAssoc[$qualifier_id][0]['qname'] != '') {
                                     $key = $OwnAssoc[$qualifier_id][0]['qname'];
                                 } else {
                                     if (isset($ParentAssoc[$qualifier_id]) && $ParentAssoc[$qualifier_id][0]['qname'] != '') {
                                         $key = $ParentAssoc[$qualifier_id][0]['qname'];
                                     } else {
                                         if (isset($display_names[$qualifier_id]) && !empty($display_names[$qualifier_id])) {
                                             $key = $display_names[$qualifier_id];
                                         } else {
                                             $key = ucfirst(str_ireplace($filter_var, "", $key));
                                         }
                                     }
                                 }
                                 /* -- Setting display name for qualifier name ends -- */
                                 /* -- Setting display name for qualifier value -- */
                                 if (($m = array_search(strtolower($val), $OwnValue[$qualifier_id])) !== false && $OwnAssoc[$qualifier_id][$m]['vname'] != "") {
                                     $val = $OwnAssoc[$qualifier_id][$m]['vname'];
                                 } else {
                                     if (isset($ParentValue[$qualifier_id]) && ($m = array_search(strtolower($val), $ParentValue[$qualifier_id])) !== false && $ParentAssoc[$qualifier_id][$m]['vname'] != "") {
                                         $val = $ParentAssoc[$qualifier_id][$m]['vname'];
                                     }
                                 }
                                 /* -- Setting display name for qualifier value ends-- */
                                 $GLOBALS['VehicleOptions'] .= $key . " : " . $val . "<br>";
                             }
                             if (eregi('^pq', $key)) {
                                 $val = trim($val, "~");
                                 $val = preg_split('/[~;]+/', $val);
                                 $val = array_unique($val);
                                 $val = array_values($val);
                                 $val = implode(",", $val);
                                 /* -- Setting display name for qualifier name -- */
                                 if (isset($OwnAssoc[$qualifier_id]) && $OwnAssoc[$qualifier_id][0]['qname'] != '') {
                                     $key = $OwnAssoc[$qualifier_id][0]['qname'];
                                 } else {
                                     if (isset($ParentAssoc[$qualifier_id]) && $ParentAssoc[$qualifier_id][0]['qname'] != '') {
                                         $key = $ParentAssoc[$qualifier_id][0]['qname'];
                                     } else {
                                         if (isset($display_names[$qualifier_id]) && !empty($display_names[$qualifier_id])) {
                                             $key = $display_names[$qualifier_id];
                                         } else {
                                             $key = ucfirst(str_ireplace($filter_var, "", $key));
                                         }
                                     }
                                 }
                                 /* -- Setting display name for qualifier name ends -- */
                                 /* -- Setting display name for qualifier value -- */
                                 if (isset($OwnValue[$qualifier_id]) && ($m = array_search(strtolower($val), $OwnValue[$qualifier_id])) !== false && $OwnAssoc[$qualifier_id][$m]['vname'] != '') {
                                     $val = $OwnAssoc[$qualifier_id][$m]['vname'];
                                 } else {
                                     if (isset($ParentValue[$qualifier_id]) && ($m = array_search(strtolower($val), $ParentValue[$qualifier_id])) !== false && $ParentValue[$qualifier_id][$m]['vname'] != '') {
                                         $val = $ParentAssoc[$qualifier_id][$m]['vname'];
                                     }
                                 }
                                 /* -- Setting display name for qualifier value ends-- */
                                 $GLOBALS['ProdOptions'] .= $key . " : " . $val . "<br>";
                             }
                         }
                     }
                 }
                 if (isset($row['vehicleoption'])) {
                     $GLOBALS['VehicleOptions'] = $row['vehicleoption'];
                 }
                 if (isset($row['productoption'])) {
                     $GLOBALS['ProdOptions'] = $row['productoption'];
                 }
                 if (isset($row['catuniversal']) && $row['catuniversal'] == 1) {
                     $GLOBALS['VehicleOptions'] = $GLOBALS['ProductName'];
                     if ($vq_column_title == "") {
                         $vq_column_title = "Product Name";
                     } else {
                         if ($vq_column_title != "Product Name") {
                             $vq_column_title = "Product Name / Vehicle Options";
                         }
                     }
                 } else {
                     if ($vq_column_title == "") {
                         $vq_column_title = "Vehicle Options";
                     } else {
                         if ($vq_column_title != "Vehicle Options") {
                             $vq_column_title = "Product Name / Vehicle Options";
                         }
                     }
                 }
                 if (empty($GLOBALS['VehicleOptions'])) {
                     $GLOBALS['VehicleOptions'] = "&nbsp;";
                 }
                 if (empty($GLOBALS['ProdOptions'])) {
                     $GLOBALS['ProdOptions'] = "&nbsp;";
                 }
                 /*--- the below lines are added for back 2 search link in the product detail page. Also modified line no 56 & 60 --- */
                 if ($GLOBALS['EnableSEOUrls'] == 1) {
                     $GLOBALS['ProductLink'] .= "/refer=true" . $ext_links;
                 } else {
                     $GLOBALS['ProductLink'] .= "&refer=true" . $ext_links;
                 }
                 ### Added by Simha for onsale addition
                 // Determine the price of this product
                 //$GLOBALS['ProductPrice'] = CalculateProductPrice_retail($row);
                 $GLOBALS['ProductPrice'] = CalculateProductPriceRetail($row);
                 $FinalPrice = $GLOBALS['ProductPrice'];
                 $SalePrice = $row['prodsaleprice'];
                 //$DiscountAmount = $FinalPrice;
                 if ((double) $SalePrice > 0 && $SalePrice < $FinalPrice) {
                     $DiscountPrice = $SalePrice;
                 } else {
                     $DiscountPrice = $FinalPrice;
                     $DiscountPrice = CalculateDiscountPrice($FinalPrice, $DiscountPrice, $row['categoryid'], $row['brandseriesid']);
                 }
                 /*
                 							foreach($DiscountInfo as $DiscountInfoSub)   {  
                     if(isset($DiscountInfoSub['catids']))    {
                 								    $catids = explode(",", $DiscountInfoSub['catids']); 
                 								    foreach($catids as $catid) {
                 									    if($catid == $row['categoryid']) {
                 										    $DiscountAmount = $FinalPrice * ((int)$DiscountInfoSub['amount']/100); 
                 										    if ($DiscountAmount < 0) {
                 											    $DiscountAmount = 0;
                 										    }                                                                         
                 										    $DiscountPrice  = $FinalPrice - $DiscountAmount;  
                 									    } 
                 								    }  
                     }
                 							}       
                 */
                 if (isset($DiscountPrice) && $DiscountPrice < $FinalPrice) {
                     //&& GetConfig('ShowOnSale')
                     $GLOBALS['ProductPrice'] = '<strike>' . CurrencyConvertFormatPrice($FinalPrice) . '</strike>';
                     $GLOBALS['ProductPrice'] .= '<br>' . CurrencyConvertFormatPrice($DiscountPrice) . '';
                     $GLOBALS['ShowOnSaleImage'] = '<img id="OnSale" src="' . GetConfig('ShopPath') . '/templates/default/images/onsale.gif" alt="">';
                     if (GetConfig('ShowOnSale')) {
                         $GLOBALS['ProductPrice'] .= '<br>' . $GLOBALS['ShowOnSaleImage'] . '';
                     }
                 } else {
                     $GLOBALS['ProductPrice'] = '' . CurrencyConvertFormatPrice($FinalPrice) . '';
                 }
                 ### Added by Simha Ends
                 // commented the below line by vikas
                 //$GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], ProdLink($row['prodname']));
                 $GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], $GLOBALS['ProductLink']);
                 if (isId($row['prodvariationid']) || trim($row['prodconfigfields']) != '' || $row['prodeventdaterequired'] == 1) {
                     //$GLOBALS['ProductURL'] = ProdLink($row['prodname']); // commented by vikas
                     $GLOBALS['ProductURL'] = $GLOBALS['ProductLink'];
                     $GLOBALS['ProductAddText'] = GetLang('ProductChooseOptionLink');
                 } else {
                     //$GLOBALS['ProductURL'] = CartLink($row['productid']);
                     //$GLOBALS['ProductURL'] = ProdLink($row['prodname']); // commented by vikas
                     $GLOBALS['ProductURL'] = $GLOBALS['ProductLink'];
                     //blessen
                     if (intval($row['prodretailprice']) <= 0) {
                         //$GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink'); // commented by vikas on 15-7-09
                         $GLOBALS['ProductAddText'] = "<img src='{$path}/templates/default/images/view.gif' border=0>";
                     } else {
                         //$GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink1'); // commented by vikas on 15-7-09
                         $GLOBALS['ProductAddText'] = "<img src='{$path}/templates/default/images/view.gif' border=0>";
                     }
                     //blessen
                     // original $GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink');
                 }
                 if (CanAddToCart($row) && GetConfig('ShowAddToCartLink')) {
                     $GLOBALS['HideActionAdd'] = '';
                 } else {
                     $GLOBALS['HideActionAdd'] = 'none';
                 }
                 $GLOBALS['HideProductVendorName'] = 'display: none';
                 $GLOBALS['ProductVendor'] = '';
                 if (GetConfig('ShowProductVendorNames') && $row['prodvendorid'] > 0) {
                     $vendorCache = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('Vendors');
                     if (isset($vendorCache[$row['prodvendorid']])) {
                         $GLOBALS['ProductVendor'] = '<a href="' . VendorLink($vendorCache[$row['prodvendorid']]) . '">' . isc_html_escape($vendorCache[$row['prodvendorid']]['vendorname']) . '</a>';
                         $GLOBALS['HideProductVendorName'] = '';
                     }
                 }
                 $GLOBALS['CartURL'] = CartLink($row['productid']);
                 $offer = $this->IsProductMakeanOffer($row['brandseriesid'], $row['brandname'], $row['categoryid']);
                 if ($offer == 'yes') {
                     $GLOBALS['HideOfferButton'] = 'block';
                 } else {
                     $GLOBALS['HideOfferButton'] = 'none';
                 }
                 $GLOBALS['SearchResultList'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCategoryProductsItem");
             } else {
                 if ($GLOBALS['results_page_flag'] == 0) {
                     $subcatg_link = $this->LeftCatLink($mmy_links, 'subcategory', $row['catname']);
                     $link = "<a href='" . $subcatg_link . "'>";
                     if (isset($row['imagefile']) && !empty($row['imagefile'])) {
                         $images = explode("~", $row['imagefile']);
                         for ($j = 0; $j < count($images); $j++) {
                             if (!empty($images[$j])) {
                                 $imagefile = "{$link}<img src='{$path}/category_images/" . $images[$j] . "'></a>";
                                 break;
                             }
                         }
                     } else {
                         if (empty($row['imagefile']) || empty($imagefile)) {
                             $imagefile = "{$link}<img src='{$path}/templates/default/images/ProductDefault.gif' border=0></a>";
                         }
                     }
                     $GLOBALS['LeftImage'] = $imagefile;
                     $GLOBALS['ProductsCount'] = "(" . $row['totalproducts'] . ") Products Available";
                     $row['brandname'] = str_replace('~', ' , ', $row['brandname']);
                     //$GLOBALS['RelatedBrands'] = $row['brandname'];
                     if (!empty($row['seriesname'])) {
                         $row['brandname'] .= "<br>" . $row['seriesname'];
                     }
                     if ($row['seriesids'] != "") {
                         $seriesids = str_ireplace("~", ",", $row['seriesids']);
                         $seriesids_qry = "select brandname , seriesname from isc_brand_series bs left join isc_brands b on bs.brandid = b.brandid where seriesid in (" . $seriesids . ")";
                         $seriesids_res = $GLOBALS['ISC_CLASS_DB']->Query($seriesids_qry);
                         if ($GLOBALS['ISC_CLASS_DB']->CountResult($seriesids_res) > 0) {
                             while ($seriesids_arr = $GLOBALS['ISC_CLASS_DB']->Fetch($seriesids_res)) {
                                 if (!isset($params['brand'])) {
                                     if ($GLOBALS['EnableSEOUrls'] == 1) {
                                         $GLOBALS['ProductsCount'] .= "<br><a href='" . $subcatg_link . "/brand/" . MakeURLSafe(Strtolower($seriesids_arr['brandname'])) . "/series/" . MakeURLSafe(Strtolower($seriesids_arr['seriesname'])) . "'>" . $seriesids_arr['brandname'] . " " . $seriesids_arr['seriesname'] . "</a>";
                                     } else {
                                         $GLOBALS['ProductsCount'] .= "<br><a href='" . $subcatg_link . "&brand=" . MakeURLSafe(Strtolower($seriesids_arr['brandname'])) . "&series=" . MakeURLSafe(Strtolower($seriesids_arr['seriesname'])) . "'>" . $seriesids_arr['brandname'] . " " . $seriesids_arr['seriesname'] . "</a>";
                                     }
                                 } else {
                                     if ($GLOBALS['EnableSEOUrls'] == 1) {
                                         $GLOBALS['ProductsCount'] .= "<br><a href='" . $subcatg_link . "/series/" . MakeURLSafe(Strtolower($seriesids_arr['seriesname'])) . "'>" . $seriesids_arr['brandname'] . " " . $seriesids_arr['seriesname'] . "</a>";
                                     } else {
                                         $GLOBALS['ProductsCount'] .= "<br><a href='" . $subcatg_link . "&series=" . MakeURLSafe(Strtolower($seriesids_arr['seriesname'])) . "'>" . $seriesids_arr['brandname'] . " " . $seriesids_arr['seriesname'] . "</a>";
                                     }
                                 }
                             }
                         }
                     }
                     $content = $row['brandname'] . "<br>";
                     if (!isset($params['category']) && (isset($params['srch_category']) || !isset($GLOBALS['BRAND_SERIES_FLAG']))) {
                         $GLOBALS['CatgDescandBrandImage'] = isset($catg_desc_arr['catdesc']) ? $catg_desc_arr['catdesc'] : '';
                         // description will be added here to show it at the top of subcatg page.
                         $content .= "<h3><a href='" . $path . "/search.php?{$qry_string}&subcategory=" . MakeURLSafe($row['catname']) . "'>" . $row['catname'] . "</a></h3>>";
                         $GLOBALS['TitleLink'] = "<h2><a href='" . $subcatg_link . "'>" . $row['catname'] . "</a></h2>";
                     }
                     $content .= "Price starting from \$" . number_format($row['prodcalculatedprice'], 2, '.', '') . "<br>" . $imagefile;
                     $GLOBALS['leftsidecontent'] = $content;
                     $GLOBALS['PriceRange'] = "Price starting from \$" . number_format($row['prodcalculatedprice'], 2, '.', '');
                     $content = "<img src='{$path}/templates/default/images/free-shipping2.gif'><br>" . strip_tags($row['proddesc']) . "<br>" . $row['prodwarranty'];
                     $GLOBALS['rightsidecontent'] = $content;
                     $GLOBALS['ShippingImage'] = "<img src='{$path}/templates/default/images/free-shipping2.gif'>";
                     $GLOBALS['ProductWarranty'] = "<h3>" . $row['prodwarranty'] . "</h3>";
                     $content = "{$link}<img src='{$path}/templates/default/images/view.gif'></a>";
                     $GLOBALS['ViewDetailsImage'] = $content;
                     if (IsDiscountAvailable('category', $row['categoryid'])) {
                         $GLOBALS['ViewDetailsImage'] .= '<img id="OnSale" src="' . GetConfig('ShopPath') . '/templates/default/images/onsale.gif" alt="">';
                     }
                     if ($this->IsMakeAnOffer('category', $row['categoryid']) == 'yes') {
                         $GLOBALS['ViewDetailsImage'] .= "<h3>Qualifies for Make an Offer!</h3>";
                     }
                     $GLOBALS['lowersidecontent'] = $content;
                     $GLOBALS['SearchResultList'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCategoryListing");
                 } else {
                     $series_link = $this->LeftCatLink($mmy_links, 'series', $row['seriesname']);
                     $link = "<a href='" . $series_link . "'>";
                     if (isset($row['imagefile']) && !empty($row['imagefile'])) {
                         $images = explode("~", $row['imagefile']);
                         for ($j = 0; $j < count($images); $j++) {
                             if (!empty($images[$j])) {
                                 $imagefile = "{$link}<img src='{$path}/category_images/" . $images[$j] . "'></a>";
                                 break;
                             }
                         }
                     } else {
                         if (empty($row['imagefile']) || empty($imagefile)) {
                             $imagefile = "{$link}<img src='{$path}/templates/default/images/ProductDefault.gif' border=0></a>";
                         }
                     }
                     $GLOBALS['LeftImage'] = $imagefile;
                     $row['brandname'] = str_replace('~', ' , ', $row['brandname']);
                     $GLOBALS['RelatedBrands'] = $row['brandname'];
                     if (isset($row['seriesname']) && !empty($row['seriesname']) && (!isset($params['srch_category']) || isset($params['category'])) && isset($GLOBALS['BRAND_SERIES_FLAG'])) {
                         if (empty($row['imagefile']) || empty($imagefile)) {
                             $GLOBALS['LeftImage'] = "{$link}<img src='{$path}/templates/default/images/ProductDefault.gif'></a>";
                         } else {
                             $GLOBALS['LeftImage'] = "{$link}<img src='{$path}/series_images/" . $row['imagefile'] . "' width='140px'></a>";
                         }
                         $GLOBALS['TitleLink'] = "<h2><a href='" . $series_link . "'>" . $row['brandname'] . " " . $row['seriesname'] . " " . $row['parentcatname'] . "</a></h2>";
                         //"<h3>".$row['catname']."</h3>
                         $GLOBALS['ProductsCount'] = "(" . $row['totalproducts'] . ") Products Available";
                         $GLOBALS['RelatedBrands'] = "<ul class='featurepoints'>";
                         if (!empty($row['feature_points1'])) {
                             $GLOBALS['RelatedBrands'] .= "<li>" . $row['feature_points1'] . "</li>";
                         }
                         if (!empty($row['feature_points2'])) {
                             $GLOBALS['RelatedBrands'] .= "<li>" . $row['feature_points2'] . "</li>";
                         }
                         if (!empty($row['feature_points3'])) {
                             $GLOBALS['RelatedBrands'] .= "<li>" . $row['feature_points3'] . "</li>";
                         }
                         if (!empty($row['feature_points4'])) {
                             $GLOBALS['RelatedBrands'] .= "<li>" . $row['feature_points4'] . "</li>";
                         }
                         $GLOBALS['RelatedBrands'] .= "</ul>";
                         /*if(isset($row['brandlargefile']) && !empty($row['brandlargefile'])) {
                         			$brand_image_path = "product_images/".$row['brandlargefile'];
                         			if(file_exists($brand_image_path)) {
                         				$GLOBALS['CatgDescandBrandImage'] = "<img src='$path/product_images/".$row['brandlargefile']."'>";
                         			} else if(isset($row['brandimagefile']) && !empty($row['brandimagefile'])) {
                         				$brand_image_path = "product_images/".$row['brandimagefile'];
                         				if(file_exists($brand_image_path))
                         					$GLOBALS['CatgDescandBrandImage'] = "<img src='$path/product_images/".$row['brandimagefile']."'>";
                         			}
                         		} else if(isset($row['brandimagefile']) && !empty($row['brandimagefile'])) {
                         				$brand_image_path = "product_images/".$row['brandimagefile'];
                         				if(file_exists($brand_image_path))
                         					$GLOBALS['CatgDescandBrandImage'] = "<img src='$path/product_images/".$row['brandimagefile']."'>";
                         		}*/
                     }
                     $GLOBALS['CatgDescandBrandImage'] = $row['branddescription'];
                     if ($row['subcatgids'] != "") {
                         $subcatgids = str_ireplace("~", ",", $row['subcatgids']);
                         $subcatgids_qry = "select catname from [|PREFIX|]categories where categoryid in (" . $subcatgids . ")";
                         $subcatgids_res = $GLOBALS['ISC_CLASS_DB']->Query($subcatgids_qry);
                         if ($GLOBALS['ISC_CLASS_DB']->CountResult($subcatgids_res) > 0) {
                             while ($subcatgids_arr = $GLOBALS['ISC_CLASS_DB']->Fetch($subcatgids_res)) {
                                 if ($GLOBALS['EnableSEOUrls'] == 1) {
                                     $GLOBALS['ProductsCount'] .= "<br><a href='" . $series_link . "/subcategory/" . MakeURLSafe(Strtolower($subcatgids_arr['catname'])) . "'>" . $subcatgids_arr['catname'] . "</a>";
                                 } else {
                                     $GLOBALS['ProductsCount'] .= "<br><a href='" . $series_link . "&subcategory=" . MakeURLSafe(Strtolower($subcatgids_arr['catname'])) . "'>" . $subcatgids_arr['catname'] . "</a>";
                                 }
                             }
                         }
                     }
                     $content = $row['brandname'] . "<br>";
                     $content .= $row['catname'] . "<br>";
                     $content .= "Price starting from \$" . number_format($row['prodcalculatedprice'], 2, '.', '');
                     $GLOBALS['leftsidecontent'] = $content;
                     $GLOBALS['PriceRange'] = "Price starting from \$" . number_format($row['prodcalculatedprice'], 2, '.', '');
                     $content = "<img src='{$path}/templates/default/images/free-shipping2.gif'><br>" . strip_tags($row['proddesc']) . "<br>" . $row['prodwarranty'];
                     $GLOBALS['rightsidecontent'] = $content;
                     $GLOBALS['ShippingImage'] = "<img src='{$path}/templates/default/images/free-shipping2.gif'>";
                     $GLOBALS['ProductWarranty'] = "<h3>" . $row['prodwarranty'] . "</h3>";
                     $content = "{$link}<img src='{$path}/templates/default/images/view.gif'></a>";
                     $GLOBALS['ViewDetailsImage'] = $content;
                     if (IsDiscountAvailable('series', $row['brandseriesid'])) {
                         $GLOBALS['ViewDetailsImage'] .= '<img id="OnSale" src="' . GetConfig('ShopPath') . '/templates/default/images/onsale.gif" alt="">';
                     }
                     if ($this->IsMakeAnOffer('series', $row['brandseriesid']) == 'yes') {
                         $GLOBALS['ViewDetailsImage'] .= "<h3>Qualifies for Make an Offer!</h3>";
                     }
                     $GLOBALS['lowersidecontent'] = $content;
                     $GLOBALS['SearchResultList'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCategoryListing");
                     $GLOBALS['HideCompareItems'] = "none";
                 }
             }
         }
         $get_variables = $_GET;
         $sort_qry = "{$path}/search.php?search_query=" . urlencode($params['search_query']);
         unset($get_variables['orderby'], $get_variables['sort'], $get_variables['search_query'], $get_variables['sortby']);
         $i = 0;
         foreach ($get_variables as $key => $value) {
             $sort_qry .= "&{$key}={$value}";
         }
         if (isset($_REQUEST['sortby']) && $_REQUEST['sortby'] == 'desc') {
             $sort = "asc ";
             $img = "&nbsp;<img src='{$path}/templates/default/images/ArrowDown.gif' border=0>";
         } else {
             $sort = "desc ";
             $img = "&nbsp;<img src='{$path}/templates/default/images/ArrowUp.gif' border=0>";
         }
         //$GLOBALS['SearchResults'] = $GLOBALS['SearchResultList']; // commented by vikas
         if (isset($params['partnumber']) || $params['flag_srch_category'] == 1 || isset($params['flag_srch_category']) && isset($GLOBALS['BRAND_SERIES_FLAG']) && $GLOBALS['BRAND_SERIES_FLAG'] == 1) {
             if ($GLOBALS['EnableSEOUrls'] == 1) {
                 $GLOBALS['ProductBrand'] = "<a href='{$path}{$mmy_links}/orderby/brandname/sortby/{$sort}'>Brand</a>";
                 $GLOBALS['ProductPartNumber'] = "<a href='{$path}{$mmy_links}/orderby/prodcode/sortby/{$sort}'>Part Number</a>";
                 $GLOBALS['ProductPrice'] = "<a href='{$path}{$mmy_links}/orderby/prodcalculatedprice/sortby/{$sort}'>Price</a>";
             } else {
                 $GLOBALS['ProductBrand'] = "<a href='{$path}/search.php?search_query={$mmy_links}&orderby=brandname&sortby={$sort}'>Brand</a>";
                 $GLOBALS['ProductPartNumber'] = "<a href='{$path}/search.php?search_query={$mmy_links}&orderby=prodcode&sortby={$sort}'>Part Number</a>";
                 $GLOBALS['ProductPrice'] = "<a href='{$path}/search.php?search_query={$mmy_links}&orderby=prodcalculatedprice&sortby={$sort}'>Price</a>";
             }
             if (isset($_REQUEST['orderby']) && $_REQUEST['orderby'] == 'brandname') {
                 $GLOBALS['ProductBrand'] .= $img;
             }
             $GLOBALS['ProductVQ'] = $vq_column_title;
             /*if(isset($_GET['orderby']) && $_GET['orderby'] == 'brandname')
             		$GLOBALS['Product_VQ'] .= $img;*/
             if (isset($_REQUEST['orderby']) && $_REQUEST['orderby'] == 'prodcode') {
                 $GLOBALS['ProductPartNumber'] .= $img;
             }
             $GLOBALS['ProductPQ'] = "Product Options";
             /*if(isset($_GET['orderby']) && $_GET['orderby'] == 'productoption')
             		$GLOBALS['SearchResults'] .= $img;*/
             if (isset($_REQUEST['orderby']) && $_REQUEST['orderby'] == 'prodcalculatedprice') {
                 $GLOBALS['ProductPrice'] .= $img;
             }
             $GLOBALS['ProductDetails'] = "Details";
             $GLOBALS['SearchResults'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCategoryProductsItemHeader");
         } else {
             //		                $GLOBALS['SearchResults'] = "<div>".$GLOBALS['SearchResultList']."</div>";
             $GLOBALS['SearchResults'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCategoryListingMain");
         }
         if ($GLOBALS['EnableSEOUrls'] == 1) {
             $back2url = $_SESSION['back2url'] = preg_replace("/^\\//", "", $_SERVER['REQUEST_URI']);
         } else {
             $back2url = $_SESSION['back2url'] = "search.php?" . $_SERVER['QUERY_STRING'];
         }
         ISC_SetCookie("back2search", $back2url, 0, "/");
         // Showing the syndication option?
         if (GetConfig('RSSNewProducts') != 0 && GetConfig('RSSCategories') != 0 && GetConfig('RSSSyndicationIcons') != 0) {
             $GLOBALS['RSSURL'] = SearchLink($GLOBALS['ISC_CLASS_SEARCH']->GetQuery(), 0, false);
             $GLOBALS['SNIPPETS']['SearchResultsFeed'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SearchResultsFeed");
         }
     } else {
         // No search results were found
         $GLOBALS['HideSearchResults'] = "none";
         $GLOBALS['HidePanels'][] = 'SearchPageProducts';
     }
 }
Example #15
0
	parseLangFile(ISC_BASE_PATH.'/language/'.getConfig('Language').'/module_language.ini');

	$templatePath = ISC_BASE_PATH.'/admin/templates';

	// Control panel mobile interface is supported on the following devices:
	// iPhone, iPod Touch, Palm Pre and Android based devices
	$mobileDevice = getPortableDeviceType();
	$supportedDevices = array(
		'iphone',
		'ipod',
		'pre',
		'android'
	);
	if(is_array($mobileDevice) && in_array($mobileDevice['device'], $supportedDevices) && empty($_COOKIE['fullControlPanel'])) {
		if(!empty($_REQUEST['fullControlPanel'])) {
			ISC_SetCookie('fullControlPanel', 1);
		}
		define('IS_PHONE', true);
		$templatePath .= '/iphone/';
	}

	initBuildTemplateInstance($templatePath);

	if(GetConfig('isSetup')) {
		// Ensure database tables exist
		$GLOBALS['ProductEdition'] = GetLang('Edition') . mysql_dump();
		if(!gzte11(ISC_LARGEPRINT)) {
			$GLOBALS['ProductEditionUpgrade'] = 1;
		}

		$GLOBALS['ISC_CLASS_ADMIN_ENGINE'] = GetClass('ISC_ADMIN_ENGINE');
Example #16
0
 /**
  * Private function used for loggin in a customer
  *
  * @param mixed Either the customer's ID or record array.
  * @param boolean Set to true to not show any error messages but return true or false depending on if the login was successful or not.
  * @return boolean True if the login was successful.
  */
 private function LoginCustomer($ClientRecord, $silent = false)
 {
     if (isId($ClientRecord)) {
         $ClientRecord = $GLOBALS['ISC_CLASS_DB']->Fetch($GLOBALS['ISC_CLASS_DB']->Query("SELECT * FROM [|PREFIX|]customers WHERE customerid=" . (int) $ClientRecord));
     }
     if (!is_array($ClientRecord)) {
         return false;
     }
     @ob_end_clean();
     if (!trim($ClientRecord['customertoken'])) {
         $custToken = GenerateCustomerToken();
         $updated_customer_token = array("customertoken" => $custToken);
         $GLOBALS['ISC_CLASS_DB']->UpdateQuery("customers", $updated_customer_token, "customerid='" . $GLOBALS['ISC_CLASS_DB']->Quote($ClientRecord['customerid']) . "'");
         $ClientRecord['customertoken'] = $custToken;
     }
     /* Added to know the browser Baskaran */
     $agent = $_SERVER['HTTP_USER_AGENT'];
     $ub = '';
     if (preg_match('/MSIE/i', $agent)) {
         $ub = "ie";
     } elseif (preg_match('/Firefox/i', $agent)) {
         $ub = "firefox";
     } else {
         if (preg_match('/Chrome/i', $agent)) {
             $ub = "chrome";
         } else {
             $ub = "ie";
         }
     }
     # To set the expire date for a cookie depending upon the browser -- Baskaran
     $expiredate = '';
     if ($ub == 'ie') {
         $expiredate = 0;
     } else {
         if ($ub == "chrome") {
             $expiredate = 0;
         } else {
             $expiredate = "";
         }
     }
     /* Ends here */
     //			ISC_SetCookie("SHOP_TOKEN", $ClientRecord['customertoken'], time()+(3600*24*7), true);
     ISC_SetCookie("SHOP_TOKEN", $ClientRecord['customertoken'], 0, true);
     // Make the cookie accessible via PHP as well
     $_COOKIE['SHOP_TOKEN'] = $ClientRecord['customertoken'];
     if ($silent == true) {
         return true;
     }
     if (isset($_SESSION['LOGIN_REDIR']) && $_SESSION['LOGIN_REDIR'] != '') {
         // Take them to the page they wanted
         $page = $_SESSION['LOGIN_REDIR'];
         unset($_SESSION['LOGIN_REDIR']);
         header(sprintf("Location: %s", $page));
     } else {
         // Take them to the "My Account" page
         header(sprintf("Location: %s/account.php", $GLOBALS['ShopPathNormal']));
     }
     die;
 }
Example #17
0
	/**
	 * Create the pending order in the database with the customers selected payment details, etc.
	 *
	 * @return array An array containing information about what needs to be done next.
	 */
	public function SavePendingOrder()
	{
		$provider = null;
		$verifyPaymentProvider = true;
		$redirectToFinishOrder = false;
		$providerId = '';

		$pendingOrderResult = array();
		$creditUsed = 0;
		$giftCertificates = array();

		$orderTotal = $this->getQuote()->getGrandTotal();

		// store the discounted subtotal in the session for affiliate tracking
		$incTax = (getConfig('taxDefaultTaxDisplayOrders') == TAX_PRICES_DISPLAY_INCLUSIVE);
		$_SESSION['LAST_ORDER_DISCOUNTED_SUBTOTAL'] = $this->getQuote()->getDiscountedSubTotal($incTax);

		// Find out what currency we are using. We'll need this later to display their previous orders in the currency that they have selected
		$selectedCurrency = GetCurrencyById($GLOBALS['CurrentCurrency']);

		$giftCertificates = $this->getQuote()->getAppliedGiftCertificates();
		if(!empty($giftCertificates)) {
			$badCertificates = array();
			$remainingBalance = 0;
			$totalWithoutCertificates =
				$this->getQuote()->getGrandTotalWithoutGiftCertificates();
			$giftCertificateAmount =
				$this->getQuote()->getGiftCertificateTotal();
			getClass('ISC_GIFTCERTIFICATES')
				->giftCertificatesApplicableToOrder(
					$totalWithoutCertificates,
					$giftCertificates,
					$remainingBalance,
					$badCertificates);

			// One or more gift certificates were invalid so this order is now invalid
			if(!empty($badCertificates)) {
				$badCertificatesList = '<strong>'.GetLang('BadGiftCertificates').'</strong><ul>';
				foreach($badCertificates as $code => $reason) {
					if(is_array($reason) && $reason[0] == "expired") {
						$reason = sprintf(GetLang('BadGiftCertificateExpired'), CDate($reason[1]));
					}
					else {
						$reason = GetLang('BadGiftCertificate'.ucfirst($reason));
					}
					$badCertificatesList .= sprintf("<li>%s - %s", isc_html_escape($code), $reason);
				}
				$badCertificatesList .= "</ul>";
				$pendingOrderResult = array(
					'error' => GetLang('OrderContainedInvalidGiftCertificates'),
					'errorDetails' => $badCertificatesList
				);
				return $pendingOrderResult;
			}
			// This order was entirely paid for using gift certificates but the totals don't add up
			else if($totalWithoutCertificates == $giftCertificateAmount && $remainingBalance > 0) {
				$pendingOrderResult = array(
					'error' => GetLang('OrderTotalStillRemainingCertificates')
				);
				return $pendingOrderResult;
			}
			// Order was entirely paid for using gift certificates
			else if($totalWithoutCertificates == $giftCertificateAmount) {
				$providerId = 'giftcertificate';
				$verifyPaymentProvider = false;
				$redirectToFinishOrder = true;
			}
		}

		// If the order total is 0, then we just forward the user on to the "Thank You" page and set the payment provider to ''
		if($orderTotal == 0) {
			$providerId = '';
			$verifyPaymentProvider = false;
			$redirectToFinishOrder = true;
		}

		$selected_provider = '';
		if($verifyPaymentProvider) {
			$candidate = '';
			if (isset($_POST['checkout_provider']) && $_POST['checkout_provider'] != '') {
				$candidate = $_POST['checkout_provider'];
			} else if (isset($_POST['credit_checkout_provider']) && $_POST['credit_checkout_provider'] != '') {
				// used by paypal
				$candidate = $_POST['credit_checkout_provider'];
			}

			// Check if the chosen checkout method is valid
			$providers = GetCheckoutModulesThatCustomerHasAccessTo(true);
			foreach ($providers as $p) {
				if ($p['id'] == $candidate) {
					$selected_provider = $candidate;
				}
			}

			// If there's only one payment provider, then they're paying via that
			if($selected_provider == '' && count($providers) == 1) {
				$selected_provider = $providers[0]['object']->GetId();
			}

			// Are we using our store credit?
			$customer = getClass('ISC_CUSTOMER')->getCustomerDataByToken();
			if (isset($_POST['store_credit']) && $_POST['store_credit'] == 1
				&& $customer['custstorecredit'] > 0) {
					// User has not chosen a payment provider and can't afford this order using only store credit, throw back as error
					if ($selected_provider == '' && $customer['custstorecredit'] < $orderTotal) {
						return false;
					}
					// Otherwise we can use the store credit.
					// Subtract store credit from users account and send them to the finished page
					else {
						$onlyCredit = false;
						$updateExtra = '';
						// If we're only using store credit
						$creditToUse = $orderTotal;
						if ($customer['custstorecredit'] >= $creditToUse) {
							// Set the checkout provider
							$providerId = 'storecredit';
							$verifyPaymentProvider = false;
							$redirectToFinishOrder = true;
							$creditUsed = $creditToUse;
							$onlyCredit = true;
						}
						else {
							// Using all of our store credit to pay for this order and we owe more.
							$creditUsed = $customer['custstorecredit'];
						}
					}
			}
		}

		$orderStatus = ORDER_STATUS_INCOMPLETE;

		// Now with round 2, do we still need to verify the payment provider?
		if($verifyPaymentProvider) {
			// If there's more than one provider and one wasn't selected on the order confirmation screen then there's a problem
			if ((count($providers) == 0 ||
				(count($providers) > 1 && $selected_provider == '')) &&
					!isset($_SESSION['CHECKOUT']['ProviderListHTML'])) {
					return false;
			}

			// Is the payment provider selected actually valid?
			if (!GetModuleById('checkout', $provider, $selected_provider)) {
				return false;
			}
			$providerId = $provider->GetId();
		}

		if(isset($_COOKIE['SHOP_TOKEN'])) {
			$customerToken = $_COOKIE['SHOP_TOKEN'];
		}
		else {
			$customerToken = '';
		}

		$orderComments = '';
		if(isset($_REQUEST['ordercomments'])) {
			$orderComments = $_POST['ordercomments'];
		}

		// Set up the order to be created
		$this->getQuote()
			->setAppliedStoreCredit($creditUsed)
			->setCustomerMessage($orderComments);
			;

		$newOrder = array(
			'orderpaymentmodule' => $providerId,
			'ordcurrencyid' => $selectedCurrency['currencyid'],
			'ordcurrencyexchangerate' => $selectedCurrency['currencyexchangerate'],
			'ordipaddress' => getIp(),
			'ordstatus' => $orderStatus,
			'extraInfo' => array(),

			'quote' => $this->getQuote(),
		);


		// OK, we're successful down to here - do they want to create an account? If so then assign it to
		// a session so we can create the actual record on a successful order
		if(!empty($_SESSION['CHECKOUT']['CREATE_ACCOUNT']) ||
			!customerIsSignedIn() && getConfig('GuestCheckoutCreateAccounts')) {
				$createAccount = array(
					'addresses' => array()
				);
				if(!empty($_SESSION['CHECKOUT']['CREATE_ACCOUNT'])) {
					$createAccount['password'] = $_SESSION['CHECKOUT']['CREATE_ACCOUNT']['password'];
					$createAccount['customFormFields'] = $_SESSION['CHECKOUT']['CREATE_ACCOUNT']['customFields'];
				}
				else {
					$createAccount['autoCreated'] = 1;
				}

				// Handle saving of addresses for new customers
				foreach($this->getQuote()->getAllAddresses() as $address) {
					if($address->getSaveAddress()) {
						$customerAddress = $address->getAsArray();
						$customFields = $address->getCustomFields();
						if(!empty($customFields)) {
							$customerAddress['customFormFields'] = $customFields;

							// Shipping fields need to be mapped back to billing so they can be stored
							if($address->getType() == ISC_QUOTE_ADDRESS::TYPE_SHIPPING) {
								$newCustomFields = array();
								$map = $GLOBALS['ISC_CLASS_FORM']->mapAddressFieldList(FORMFIELDS_FORM_SHIPPING, array_keys($customFields));
								foreach($map as $oldId => $newId) {
									$newCustomFields[$newId] = $customFields[$oldId];
								}
								$customerAddress['customFormFields'] = $newCustomFields;
							}
						}

						$createAccount['addresses'][] = $customerAddress;
					}
				}

				$newOrder['extraInfo']['createAccount'] = $createAccount;
		}

		// Did they agree to signup to any mailing lists?
		if (isset($_POST['join_mailing_list'])) {
			$newOrder['extraInfo']['join_mailing_list'] = true;
		}

		if (isset($_POST['join_order_list'])) {
			$newOrder['extraInfo']['join_order_list'] = true;
		}

		if (isset($_POST['join_mailing_list']) || isset($_POST['join_order_list'])) {
			if (isset($_POST['mail_format_preference'])) {
				$newOrder['extraInfo']['mail_format_preference'] = (int)$_POST['mail_format_preference'];
			} else {
				$newOrder['extraInfo']['mail_format_preference'] = Interspire_EmailIntegration_Subscription::FORMAT_PREF_NONE;
			}
			$newOrder['extraInfo']['join_order_list'] = true;
		}


		if(isset($_POST['ordermessage'])) {
			$newOrder['ordermessage'] = $_POST['ordermessage'];
		} else {
			$newOrder['ordermessage'] = '';
		}

		$entity = new ISC_ENTITY_ORDER();
		$orderId = $entity->add($newOrder);

		// Failed to create the order
		if(!$orderId) {
			return false;
		}

		$order = getOrder($orderId);

		// Persist the pending order token as a cookie for 24 hours
		ISC_SetCookie("SHOP_ORDER_TOKEN", $order['ordtoken'], time() + (3600*24), true);
		$_COOKIE['SHOP_ORDER_TOKEN'] = $order['ordtoken'];

		// Redirecting to finish order page?
		if($redirectToFinishOrder) {
			return array(
				'redirectToFinishOrder' => true
			);
		}

		// Otherwise, the gateway want's to do something
		$orderData = LoadPendingOrdersByToken($order['ordtoken']);
		$provider->SetOrderData($orderData);

		// Is this an online payment provider? It would like to do something
		if($provider->GetPaymentType() == PAYMENT_PROVIDER_ONLINE || method_exists($provider, "ShowPaymentForm")) {
			// Call the checkout process for the selected provider
			if(method_exists($provider, "ShowPaymentForm")) {
				return array(
					'provider' => $provider,
					'showPaymentForm' => true
				);
			}
			else {
				return array(
					'provider' => $provider
				);
			}
		}
		// If an offline method, we throw them to the "Thank you for your order" page
		else {
			return array(
				'provider' => $provider
			);
		}
	}
    public function ProcessLogin()
    {
        $loginName = '';
        $loginPass = '';
        if ((!isset($_POST['username']) || !isset($_POST['password'])) && !isset($_COOKIE['RememberToken'])) {
            $GLOBALS['ISC_CLASS_ADMIN_AUTH']->DoLogin(true);
            return;
        }
        // Is this an automatic login from "Remember Me" being ticked?
        if (isset($_POST['username'])) {
            $loginName = @$_POST['username'];
            $loginPass = @$_POST['password'];
            $query = sprintf("SELECT pk_userid, username, userpass, token, userimportpass FROM [|PREFIX|]users WHERE username='******' and userstatus='1'", $GLOBALS['ISC_CLASS_DB']->Quote($loginName));
        } else {
            if (isset($_COOKIE['RememberToken']) && trim($_COOKIE['RememberToken']) != '') {
                $md5 = $_COOKIE['RememberToken'];
                $query = sprintf("SELECT pk_userid, username, userpass, token, userimportpass FROM [|PREFIX|]users WHERE userstatus='1' AND md5(concat(username, token))='%s'", $GLOBALS['ISC_CLASS_DB']->Quote($md5));
            } else {
                // Otherwise, we have a bad username/password
                $GLOBALS['ISC_CLASS_LOG']->LogAdminAction("invalid", $loginName);
                $GLOBALS['ISC_CLASS_ADMIN_AUTH']->DoLogin(true);
                die;
            }
        }
        if (isset($_POST['remember']) || isset($_COOKIE['RememberToken'])) {
            $remember = true;
        } else {
            $remember = false;
        }
        ob_start();
        // Try and find a user with the same credentials
        $userResult = $GLOBALS["ISC_CLASS_DB"]->Query($query);
        if ($userRow = $GLOBALS["ISC_CLASS_DB"]->Fetch($userResult)) {
            if (!$remember) {
                ISC_SetCookie("RememberToken", "", time() - 3600 * 24 * 365, true);
            }
            // Was this an improted password?
            if ($userRow['userimportpass'] != '' && $userRow['userpass'] != md5($loginPass)) {
                if (ValidateImportPassword($loginPass, $userRow['userimportpass'])) {
                    // Valid login from an import password. We now store the Interspire Shopping Cart version of the password
                    $updatedUser = array("userpass" => md5($loginPass), "userimportpass" => "");
                    $GLOBALS['ISC_CLASS_DB']->UpdateQuery("users", $updatedUser, "pk_userid='" . $GLOBALS['ISC_CLASS_DB']->Quote($userRow['pk_userid']) . "'");
                } else {
                    unset($userRow['pk_userid']);
                }
            } else {
                // Is this a "Remember Me" auto login or a form login?
                if (isset($_POST['username'])) {
                    if ($userRow['userpass'] != md5($loginPass)) {
                        unset($userRow['pk_userid']);
                    }
                } else {
                    // If they get here then "Remember Me" was set and valid so we don't have to do anything
                }
            }
            if (isset($userRow['pk_userid'])) {
                // Set the auth session variable to true
                $_COOKIE['STORESUITE_CP_TOKEN'] = $userRow['token'];
                ISC_SetCookie("STORESUITE_CP_TOKEN", $userRow['token'], 0, true);
                if ($remember) {
                    ISC_SetCookie("RememberToken", md5($userRow['username'] . $userRow['token']), time() + 3600 * 24 * 365, true);
                }
                // Log the successful login to the administrators log
                $GLOBALS['ISC_CLASS_LOG']->LogAdminAction("valid");
                // Everything was OK and the user has been logged in successfully
                ?>
						<script type="text/javascript">
							document.location.href='index.php?ToDo=';
						</script>
					<?php 
                die;
            }
        }
        // Otherwise, we have a bad username/password
        $GLOBALS['ISC_CLASS_LOG']->LogAdminAction("invalid", $loginName);
        $GLOBALS['ISC_CLASS_ADMIN_AUTH']->DoLogin(true);
        die;
    }
Example #19
0
 public function SetPanelSettings()
 {
     $count = 0;
     $output = "";
     $params = $GLOBALS['ISC_CLASS_SEARCH']->_searchterms;
     $this->searchterms = $params;
     $path = GetConfig('ShopPath');
     /* the below mmy links are passed to the breadcrumbs */
     $mmy_links = "";
     /*---------- This below section is for generating search phrase----------*/
     $GLOBALS['Category'] = "";
     $GLOBALS['MMY'] = "";
     $GLOBALS['PQ'] = "";
     $GLOBALS['VQ'] = "";
     $GLOBALS['SearchPhrase'] = "";
     $ext_links = "";
     // this variable is passed to the product detail page
     $seo_delim = "&";
     if ($GLOBALS['EnableSEOUrls'] == 1) {
         $seo_delim = "/";
     }
     if (isset($GLOBALS['ISC_SRCH_CATG_NAME'])) {
         $GLOBALS['Category'] .= $GLOBALS['ISC_SRCH_CATG_NAME'];
     }
     if (isset($params['year'])) {
         $GLOBALS['MMY'] .= $params['year'] . "<br>";
         $ext_links .= $seo_delim . "year=" . $params['year'];
     }
     if (isset($params['make'])) {
         $GLOBALS['MMY'] .= strtoupper($params['make']) . "<br>";
         $ext_links .= $seo_delim . "make=" . MakeURLSafe($params['make']);
     }
     if (isset($params['model']) && (!isset($params['model_flag']) || $params['model_flag'] == 1)) {
         $GLOBALS['MMY'] .= strtoupper($params['model']) . "<br>";
         $ext_links .= $seo_delim . "model=" . MakeURLSafe($params['model']);
     }
     /*else if(isset($params['model']))
       $ext_links .= $seo_delim."model=".$params['model'];*/
     /* this condition has been added seperately here to show submodel at last */
     if (isset($params['submodel'])) {
         $GLOBALS['MMY'] .= MakeURLSafe($params['submodel']) . "<br>";
     }
     /*if(isset($params['year'])) {
       $ext_links .= $seo_delim."year=".$params['year'];                
       }*/
     if (isset($params['dynfilters']) && !empty($params['dynfilters'])) {
         foreach ($params['dynfilters'] as $key => $value) {
             if (eregi('vq', $key)) {
                 $key = str_ireplace('vq', '', $key);
                 $GLOBALS['VQ'] .= ucfirst($key) . ": {$value}<br>";
             } else {
                 if (eregi('pq', $key)) {
                     $key = str_ireplace('pq', '', $key);
                     $GLOBALS['PQ'] .= ucfirst($key) . ": {$value}<br>";
                 }
             }
         }
     }
     $filter_var = array('vq', 'pq');
     /* this below patch is used for getting description of the category. Here currently the selected category id will be last one in the $params['srch_category'] array. if input['category'] is used then it will be the first one */
     if (!empty($params['srch_category'])) {
         if (isset($params['category'])) {
             $selected_catg = $params['srch_category'][0];
         } else {
             $selected_catg = end($params['srch_category']);
         }
         $catg_desc_qry = "select catdesc , categoryfooter from [|PREFIX|]categories where categoryid = " . $selected_catg;
         $catg_desc_res = $GLOBALS['ISC_CLASS_DB']->Query($catg_desc_qry);
         if ($GLOBALS['ISC_CLASS_DB']->CountResult($catg_desc_res) > 0) {
             $catg_desc_arr = $GLOBALS['ISC_CLASS_DB']->Fetch($catg_desc_res);
         }
         /* this below patch is used to show the display name for the qualifiers from the qualifier association table */
         $map_names = array();
         $display_names = array();
         $filter_names = "select qid , column_name , display_names from [|PREFIX|]qualifier_names where column_name regexp '^(pq|vq)'";
         $filter_result = $GLOBALS['ISC_CLASS_DB']->Query($filter_names);
         while ($filter_row = $GLOBALS['ISC_CLASS_DB']->Fetch($filter_result)) {
             $map_names[$filter_row['qid']] = $filter_row['column_name'];
             $display_names[$filter_row['qid']] = $filter_row['display_names'];
         }
         $this->GetAssocDetails($selected_catg, $OwnAssoc, $ParentAssoc, $OwnValue, $ParentValue);
     }
     if (isset($params['brand'])) {
         $brand_desc_arr = array();
         $brand_desc_qry = "select branddescription , brandfooter from [|PREFIX|]brands where brandname = '" . $params['brand'] . "'";
         $brand_desc_res = $GLOBALS['ISC_CLASS_DB']->Query($brand_desc_qry);
         if ($GLOBALS['ISC_CLASS_DB']->CountResult($brand_desc_res) > 0) {
             $brand_desc_arr = $GLOBALS['ISC_CLASS_DB']->Fetch($brand_desc_res);
         }
     }
     // for breadcrumbs
     $this->_BuildBreadCrumbs();
     /* the below line has been commented as client told to remove it */
     //$GLOBALS['SearchPhrase'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SearchPhrase");
     if ($GLOBALS['ISC_CLASS_SEARCH']->GetNumResults() > 30) {
         $msg_qry = "select value from [|PREFIX|]display where messageid = 1";
         $msg_res = $GLOBALS['ISC_CLASS_DB']->Query($msg_qry);
         $msg_row = $GLOBALS['ISC_CLASS_DB']->FetchOne($msg_res);
         $GLOBALS['SearchPhrase'] = $msg_row;
         //$GLOBALS['SearchPhrase'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SearchPhrase");
     }
     /*if(!empty($params['dynfilters']))
       $GLOBALS['SearchPhrase'] .= " ".implode(" ",$params['dynfilters']);
       /*---------- Ending section for generating search phrase----------*/
     $vq_column_title = "";
     $GLOBALS['SearchResultList'] = "";
     if ($GLOBALS['ISC_CLASS_SEARCH']->GetNumResults() > 0) {
         $brand_rating = 0;
         if ($GLOBALS['results_page_flag'] == 1) {
             $brand_rating_qry = "select avg(revrating) as rating from [|PREFIX|]reviews r left join [|PREFIX|]products p on r.revproductid = p.productid left join [|PREFIX|]brands b on p.prodbrandid = b.brandid  where r.revstatus = 1 and b.brandname = '" . $params['brand'] . "'";
             $brand_rating_res = $GLOBALS['ISC_CLASS_DB']->Query($brand_rating_qry);
             $brand_rating_arr = $GLOBALS['ISC_CLASS_DB']->FetchOne($brand_rating_res);
             if (isset($brand_rating_arr['rating'])) {
                 $brand_rating = (int) $brand_rating_arr['rating'];
             }
         }
         /* displaying the dropdowns for YMM */
         if (!isset($params['make']) || !isset($params['year']) || !isset($params['model']) || isset($params['model_flag']) && $params['model_flag'] == 0) {
             $this->YMMSelectors($params);
         }
         // We have at least one result, let's show it to the world!
         $GLOBALS['HideNoResults'] = "none";
         // Only show the "compare" option if there are 2 or more products on this page
         if (GetConfig('EnableProductComparisons') == 0 || $GLOBALS['ISC_CLASS_DB']->CountResult($GLOBALS['SearchResults']) < 2) {
             $GLOBALS['HideCompareItems'] = "none";
         }
         if (GetConfig('EnableProductReviews') == 0) {
             $GLOBALS['HideProductRating'] = "display: none";
         }
         $GLOBALS['AlternateClass'] = '';
         $counter = 1;
         $CurCatId = 0;
         $mmy_links = $this->GetYMMLinks($params);
         $mmy_links .= $this->GetOtherLinks($params);
         while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($GLOBALS['SearchResults'])) {
             /* Added by Simha to check inf prodcucts comes from different categories*/
             if (empty($params['srch_category']) || !isset($params['srch_category'])) {
                 if ($CurCatId != $row['categoryid']) {
                     $CurCatId = $row['categoryid'];
                     $map_names = array();
                     $display_names = array();
                     $filter_names = "SELECT DISTINCT qn.qid, qn.column_name, qn.display_names from \n                                                [|PREFIX|]qualifier_names qn\n                                                LEFT JOIN [|PREFIX|]qualifier_associations qa ON qa.qualifierid = qn.qid\n                                                WHERE (qa.categoryid = '{$CurCatId}') \n                                                AND qn.column_name regexp '^(pq|vq)'";
                     // || qa.categoryid IN (SELECT catparentid FROM isc_categories WHERE categoryid = '$CurCatId')
                     $filter_result = $GLOBALS['ISC_CLASS_DB']->Query($filter_names);
                     while ($filter_row = $GLOBALS['ISC_CLASS_DB']->Fetch($filter_result)) {
                         $map_names[$filter_row['qid']] = $filter_row['column_name'];
                         $display_names[$filter_row['qid']] = $filter_row['display_names'];
                     }
                     $this->GetAssocDetails($CurCatId, $OwnAssoc, $ParentAssoc, $OwnValue, $ParentValue);
                 }
             }
             /* Added by Simha Ends */
             $GLOBALS['SearchTrackClass'] = "TrackLink";
             $imagefile = "";
             if ($GLOBALS['AlternateClass'] == 'Odd') {
                 $GLOBALS['AlternateClass'] = 'Even';
             } else {
                 $GLOBALS['AlternateClass'] = 'Odd';
             }
             $qry_string = $_SERVER['QUERY_STRING'];
             if (isset($_GET['page'])) {
                 $page = "&page=" . $_GET['page'];
                 $qry_string = str_ireplace($page, '', $qry_string);
             }
             if ($GLOBALS['EnableSEOUrls'] == 1) {
                 if (isset($_GET['search_key'])) {
                     $qry_string = str_ireplace('&search_key=' . $_GET['search_key'], '', $qry_string);
                 }
                 if (isset($params['search_query']) && !strstr($qry_string, 'search_query=')) {
                     $qry_string .= "search_query=" . MakeURLSafe($params['search_query']);
                 }
                 if (isset($params['make']) && !strstr($qry_string, 'make=')) {
                     $qry_string .= "&make=" . MakeURLSafe($params['make']);
                 }
                 if (isset($params['model']) && !strstr($qry_string, 'model=')) {
                     $qry_string .= "&model=" . MakeURLSafe($params['model']);
                 }
                 if (isset($params['year']) && !strstr($qry_string, 'year=')) {
                     $qry_string .= "&year=" . MakeURLSafe($params['year']);
                 }
                 if (isset($params['make']) && !strstr($qry_string, 'make=')) {
                     $qry_string .= "&make=" . MakeURLSafe($params['make']);
                 }
                 if (isset($params['model_flag']) && !strstr($qry_string, 'model_flag=')) {
                     $qry_string .= "&model_flag=" . MakeURLSafe($params['model_flag']);
                 }
                 if (isset($params['submodel']) && !strstr($qry_string, 'submodel=')) {
                     $qry_string .= "&submodel=" . MakeURLSafe($params['submodel']);
                 }
             }
             if (isset($params['partnumber']) || $params['flag_srch_category'] == 1 || isset($params['flag_srch_category']) && isset($GLOBALS['BRAND_SERIES_FLAG']) && $GLOBALS['BRAND_SERIES_FLAG'] == 1) {
                 /*if( isset($params['srch_category']) )  {
                 			$GLOBALS['CatgDescandBrandImage'] = isset($catg_desc_arr['catdesc']) ? $catg_desc_arr['catdesc'] : ''; // description will be added here to show it at the top of product listing page.
                 		}*/
                 if (isset($params['category']) || !isset($params['subcategory']) && isset($params['series'])) {
                     $GLOBALS['CatgDescandBrandImage'] = $row['seriesdescription'];
                     $GLOBALS['CatgBrandSeriesFooter'] = $row['seriesfooter'];
                     if ((isset($params['category']) || isset($params['subcategory'])) && $GLOBALS['CatgDescandBrandImage'] == "") {
                         $GLOBALS['CatgDescandBrandImage'] = isset($catg_desc_arr['catdesc']) ? $catg_desc_arr['catdesc'] : '';
                         $GLOBALS['CatgBrandSeriesFooter'] = isset($catg_desc_arr['categoryfooter']) ? $catg_desc_arr['categoryfooter'] : '';
                     }
                 } else {
                     if (isset($params['srch_category'])) {
                         $GLOBALS['CatgDescandBrandImage'] = isset($catg_desc_arr['catdesc']) ? $catg_desc_arr['catdesc'] : '';
                         $GLOBALS['CatgBrandSeriesFooter'] = isset($catg_desc_arr['categoryfooter']) ? $catg_desc_arr['categoryfooter'] : '';
                         if (isset($params['series']) && $row['seriesdescription'] != "") {
                             $GLOBALS['CatgDescandBrandImage'] = $row['seriesdescription'];
                             $GLOBALS['CatgBrandSeriesFooter'] = $row['seriesfooter'];
                         }
                         if ($GLOBALS['CatgDescandBrandImage'] == '' && $GLOBALS['CatgBrandSeriesFooter'] == '' && isset($params['brand'])) {
                             $GLOBALS['CatgDescandBrandImage'] = isset($brand_desc_arr['branddescription']) ? $brand_desc_arr['branddescription'] : '';
                             $GLOBALS['CatgBrandSeriesFooter'] = isset($brand_desc_arr['brandfooter']) ? $brand_desc_arr['brandfooter'] : '';
                         }
                     } else {
                         if (isset($params['brand'])) {
                             $GLOBALS['CatgDescandBrandImage'] = isset($brand_desc_arr['branddescription']) ? $brand_desc_arr['branddescription'] : '';
                             $GLOBALS['CatgBrandSeriesFooter'] = isset($brand_desc_arr['brandfooter']) ? $brand_desc_arr['brandfooter'] : '';
                         }
                     }
                 }
                 $GLOBALS['ProductCartQuantity'] = '';
                 if (isset($GLOBALS['CartQuantity' . $row['productid']])) {
                     $GLOBALS['ProductCartQuantity'] = (int) $GLOBALS['CartQuantity' . $row['productid']];
                 }
                 if ($counter % 2 == 0) {
                     $GLOBALS['RowColor'] = 'grayrow';
                 } else {
                     $GLOBALS['RowColor'] = 'whiterow';
                 }
                 $counter++;
                 $GLOBALS['ProductId'] = (int) $row['productid'];
                 $GLOBALS['ProductName'] = isc_html_escape($row['prodname']);
                 $GLOBALS['ProductLink'] = ProdLink($row['prodname']);
                 $GLOBALS['ProductRating'] = (int) $row['prodavgrating'];
                 $GLOBALS['BrandName'] = $row['brandname'];
                 $GLOBALS['ProdCode'] = $row['prodcode'];
                 //$GLOBALS['ProdDesc'] = $this->strip_html_tags($row['proddesc']);
                 //$GLOBALS['ProdOptions'] = $row['productoption'];
                 $GLOBALS['VehicleOptions'] = "";
                 $GLOBALS['ProdOptions'] = "";
                 foreach ($row as $key => $val) {
                     if ($val != "" && $val != "~") {
                         if (($qualifier_id = array_search($key, $map_names)) !== false) {
                             if (eregi('^vq', $key)) {
                                 $val = trim($val, "~");
                                 $val = preg_split('/[~;]+/', $val);
                                 $val = array_unique($val);
                                 $val = array_values($val);
                                 $val = implode(",", $val);
                                 /* -- Setting display name for qualifier name -- */
                                 if (isset($OwnAssoc[$qualifier_id]) && $OwnAssoc[$qualifier_id][0]['qname'] != '') {
                                     $key = $OwnAssoc[$qualifier_id][0]['qname'];
                                 } else {
                                     if (isset($ParentAssoc[$qualifier_id]) && $ParentAssoc[$qualifier_id][0]['qname'] != '') {
                                         $key = $ParentAssoc[$qualifier_id][0]['qname'];
                                     } else {
                                         if (isset($display_names[$qualifier_id]) && !empty($display_names[$qualifier_id])) {
                                             $key = $display_names[$qualifier_id];
                                         } else {
                                             $key = ucfirst(str_ireplace($filter_var, "", $key));
                                         }
                                     }
                                 }
                                 /* -- Setting display name for qualifier name ends -- */
                                 /* -- Setting display name for qualifier value -- */
                                 if (($m = array_search(strtolower($val), $OwnValue[$qualifier_id])) !== false && $OwnAssoc[$qualifier_id][$m]['vname'] != "") {
                                     $val = $OwnAssoc[$qualifier_id][$m]['vname'];
                                 } else {
                                     if (isset($ParentValue[$qualifier_id]) && ($m = array_search(strtolower($val), $ParentValue[$qualifier_id])) !== false && $ParentAssoc[$qualifier_id][$m]['vname'] != "") {
                                         $val = $ParentAssoc[$qualifier_id][$m]['vname'];
                                     }
                                 }
                                 /* -- Setting display name for qualifier value ends-- */
                                 $GLOBALS['VehicleOptions'] .= $key . " : " . $val . "<br>";
                             }
                             if (eregi('^pq', $key)) {
                                 $val = trim($val, "~");
                                 $val = preg_split('/[~;]+/', $val);
                                 $val = array_unique($val);
                                 $val = array_values($val);
                                 $val = implode(",", $val);
                                 /* -- Setting display name for qualifier name -- */
                                 if (isset($OwnAssoc[$qualifier_id]) && $OwnAssoc[$qualifier_id][0]['qname'] != '') {
                                     $key = $OwnAssoc[$qualifier_id][0]['qname'];
                                 } else {
                                     if (isset($ParentAssoc[$qualifier_id]) && $ParentAssoc[$qualifier_id][0]['qname'] != '') {
                                         $key = $ParentAssoc[$qualifier_id][0]['qname'];
                                     } else {
                                         if (isset($display_names[$qualifier_id]) && !empty($display_names[$qualifier_id])) {
                                             $key = $display_names[$qualifier_id];
                                         } else {
                                             $key = ucfirst(str_ireplace($filter_var, "", $key));
                                         }
                                     }
                                 }
                                 /* -- Setting display name for qualifier name ends -- */
                                 /* -- Setting display name for qualifier value -- */
                                 if (isset($OwnValue[$qualifier_id]) && ($m = array_search(strtolower($val), $OwnValue[$qualifier_id])) !== false && $OwnAssoc[$qualifier_id][$m]['vname'] != '') {
                                     $val = $OwnAssoc[$qualifier_id][$m]['vname'];
                                 } else {
                                     if (isset($ParentValue[$qualifier_id]) && ($m = array_search(strtolower($val), $ParentValue[$qualifier_id])) !== false && $ParentValue[$qualifier_id][$m]['vname'] != '') {
                                         $val = $ParentAssoc[$qualifier_id][$m]['vname'];
                                     }
                                 }
                                 /* -- Setting display name for qualifier value ends-- */
                                 $GLOBALS['ProdOptions'] .= $key . " : " . $val . "<br>";
                             }
                         }
                     }
                 }
                 if (isset($row['vehicleoption'])) {
                     $GLOBALS['VehicleOptions'] = $row['vehicleoption'];
                 }
                 if (isset($row['productoption'])) {
                     $GLOBALS['ProdOptions'] = $row['productoption'];
                 }
                 if (isset($row['catuniversal']) && $row['catuniversal'] == 1) {
                     $GLOBALS['VehicleOptions'] = $GLOBALS['ProductName'];
                     if ($vq_column_title == "") {
                         $vq_column_title = "Product Name";
                     } else {
                         if ($vq_column_title != "Product Name") {
                             $vq_column_title = "Product Name / Vehicle Options";
                         }
                     }
                 } else {
                     if ($vq_column_title == "") {
                         $vq_column_title = "Vehicle Options";
                     } else {
                         if ($vq_column_title != "Vehicle Options") {
                             $vq_column_title = "Product Name / Vehicle Options";
                         }
                     }
                 }
                 if (empty($GLOBALS['VehicleOptions'])) {
                     $GLOBALS['VehicleOptions'] = "&nbsp;";
                 }
                 if (empty($GLOBALS['ProdOptions'])) {
                     $GLOBALS['ProdOptions'] = "&nbsp;";
                 }
                 /*--- the below lines are added for back 2 search link in the product detail page. Also modified line no 56 & 60 --- */
                 if ($GLOBALS['EnableSEOUrls'] == 1) {
                     $GLOBALS['ProductLink'] .= "/refer=true" . $ext_links;
                 } else {
                     $GLOBALS['ProductLink'] .= "&refer=true" . $ext_links;
                 }
                 ### Added by Simha for onsale addition
                 // Determine the price of this product
                 //$GLOBALS['ProductPrice'] = CalculateProductPrice_retail($row);
                 $GLOBALS['ProductPrice'] = CalculateProductPriceRetail($row);
                 $FinalPrice = $GLOBALS['ProductPrice'];
                 $SalePrice = $row['prodsaleprice'];
                 //$DiscountAmount = $FinalPrice;
                 $discounttype = 0;
                 if ((double) $SalePrice > 0 && $SalePrice < $FinalPrice) {
                     $DiscountPrice = $SalePrice;
                 } else {
                     $DiscountPrice = $FinalPrice;
                     $DiscountPrice = CalculateDiscountPrice($FinalPrice, $DiscountPrice, $row['categoryid'], $row['brandseriesid'], $discounttype);
                     /*if($discounttype == 0)    {
                           $DiscountPrice = $FinalPrice;
                       }*/
                 }
                 /*
                 							foreach($DiscountInfo as $DiscountInfoSub)   {  
                     if(isset($DiscountInfoSub['catids']))    {
                 								    $catids = explode(",", $DiscountInfoSub['catids']); 
                 								    foreach($catids as $catid) {
                 									    if($catid == $row['categoryid']) {
                 										    $DiscountAmount = $FinalPrice * ((int)$DiscountInfoSub['amount']/100); 
                 										    if ($DiscountAmount < 0) {
                 											    $DiscountAmount = 0;
                 										    }                                                                         
                 										    $DiscountPrice  = $FinalPrice - $DiscountAmount;  
                 									    } 
                 								    }  
                     }
                 							}       
                 */
                 if (isset($DiscountPrice) && $DiscountPrice < $FinalPrice && $discounttype == 0) {
                     //&& GetConfig('ShowOnSale')
                     $GLOBALS['ProductPrice'] = '<strike>' . CurrencyConvertFormatPrice($FinalPrice) . '</strike>';
                     $GLOBALS['ProductPrice'] .= '<br>' . CurrencyConvertFormatPrice($DiscountPrice) . '';
                     $GLOBALS['ShowOnSaleImage'] = '<img id="OnSale" src="' . GetConfig('ShopPath') . '/templates/default/images/onsale.gif" alt="">';
                     if (GetConfig('ShowOnSale')) {
                         $GLOBALS['ProductPrice'] .= '<br>' . $GLOBALS['ShowOnSaleImage'] . '';
                     }
                 } else {
                     $GLOBALS['ProductPrice'] = '' . CurrencyConvertFormatPrice($FinalPrice) . '';
                 }
                 ### Added by Simha Ends
                 // commented the below line by vikas
                 //$GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], ProdLink($row['prodname']));
                 $GLOBALS['ProductThumb'] = ImageThumb($row['imagefile'], $GLOBALS['ProductLink']);
                 if (isId($row['prodvariationid']) || trim($row['prodconfigfields']) != '' || $row['prodeventdaterequired'] == 1) {
                     //$GLOBALS['ProductURL'] = ProdLink($row['prodname']); // commented by vikas
                     $GLOBALS['ProductURL'] = $GLOBALS['ProductLink'];
                     $GLOBALS['ProductAddText'] = GetLang('ProductChooseOptionLink');
                 } else {
                     //$GLOBALS['ProductURL'] = CartLink($row['productid']);
                     //$GLOBALS['ProductURL'] = ProdLink($row['prodname']); // commented by vikas
                     $GLOBALS['ProductURL'] = $GLOBALS['ProductLink'];
                     //blessen
                     if (intval($row['prodretailprice']) <= 0) {
                         //$GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink'); // commented by vikas on 15-7-09
                         $GLOBALS['ProductAddText'] = "<img src='{$path}/templates/default/images/view.gif' border=0>";
                     } else {
                         //$GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink1'); // commented by vikas on 15-7-09
                         $GLOBALS['ProductAddText'] = "<img src='{$path}/templates/default/images/view.gif' border=0>";
                     }
                     //blessen
                     // original $GLOBALS['ProductAddText'] = GetLang('ProductAddToCartLink');
                 }
                 if (CanAddToCart($row) && GetConfig('ShowAddToCartLink')) {
                     $GLOBALS['HideActionAdd'] = '';
                 } else {
                     $GLOBALS['HideActionAdd'] = 'none';
                 }
                 $GLOBALS['HideProductVendorName'] = 'display: none';
                 $GLOBALS['ProductVendor'] = '';
                 if (GetConfig('ShowProductVendorNames') && $row['prodvendorid'] > 0) {
                     $vendorCache = $GLOBALS['ISC_CLASS_DATA_STORE']->Read('Vendors');
                     if (isset($vendorCache[$row['prodvendorid']])) {
                         $GLOBALS['ProductVendor'] = '<a href="' . VendorLink($vendorCache[$row['prodvendorid']]) . '">' . isc_html_escape($vendorCache[$row['prodvendorid']]['vendorname']) . '</a>';
                         $GLOBALS['HideProductVendorName'] = '';
                     }
                 }
                 $GLOBALS['CartURL'] = CartLink($row['productid']);
                 $offer = $this->IsProductMakeanOffer($row['brandseriesid'], $row['brandname'], $row['categoryid']);
                 if ($offer == 'yes') {
                     $GLOBALS['HideOfferButton'] = 'block';
                 } else {
                     $GLOBALS['HideOfferButton'] = 'none';
                 }
                 $GLOBALS['SearchResultList'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCategoryProductsItem");
             } else {
                 if ($GLOBALS['results_page_flag'] == 0) {
                     $mmy_links_modified = $mmy_links;
                     if (!isset($GLOBALS['ISC_SRCH_CATG_ID'])) {
                         $parentid = $GLOBALS['categories_all'][$row['categoryid']]['catparentid'];
                         if ($parentid != 0) {
                             if (isset($GLOBALS['categories_all'][$parentid])) {
                                 // if parent catg is not visible
                                 $mmy_links_modified = "/" . MakeURLSafe(strtolower($GLOBALS['categories_all'][$parentid]['catname'])) . $mmy_links;
                             } else {
                                 $mmy_links_modified = "/" . MakeURLSafe(strtolower($GLOBALS['categories_all'][$row['categoryid']]['catname'])) . $mmy_links;
                             }
                         } else {
                             $mmy_links_modified = "/" . MakeURLSafe(strtolower($GLOBALS['categories_all'][$row['categoryid']]['catname'])) . $mmy_links;
                         }
                     }
                     $subcatg_link = $this->LeftCatLink($mmy_links_modified, 'subcategory', $row['catname']);
                     $link = "<a href='" . $subcatg_link . "'>";
                     $tiplink = "<a class='thickbox1' href='" . $GLOBALS['ShopPath'] . "/catgbrand.php?categoryid=" . $row['categoryid'] . "&url=" . urlencode($subcatg_link) . "'  title=''><img src='{$path}/templates/default/images/fastlook_red.gif' border=0></a>";
                     $imagelink = "<a class='thickbox' href='" . $GLOBALS['ShopPath'] . "/catgbrand.php?categoryid=" . $row['categoryid'] . "&url=" . urlencode($subcatg_link) . "' title='' onmouseover='createtip(" . $row['categoryid'] . ")' onmouseout='UnTip()'>";
                     //$imagelink = "<a href='".$GLOBALS['ShopPath']."/catgbrand.php?categoryid=".$row['categoryid']."&url=$subcatg_link' class='thickbox' title=''>";
                     if (isset($row['imagefile']) && !empty($row['imagefile'])) {
                         $images = explode("~", $row['imagefile']);
                         for ($j = 0; $j < count($images); $j++) {
                             if (!empty($images[$j])) {
                                 $imagefile = "{$imagelink}<img src='{$path}/category_images/" . $images[$j] . "' alt='" . isc_html_escape($row['catimagealt']) . "' title='" . isc_html_escape($row['catimagealt']) . "' class='subcat-image'></a>";
                                 $imagefile .= "<span id='span" . $row['categoryid'] . "' style='display:none'>" . $tiplink . "</span>";
                                 break;
                             }
                         }
                     } else {
                         if (empty($row['imagefile']) || empty($imagefile)) {
                             $imagefile = "{$imagelink}<img src='{$path}/templates/default/images/ProductDefault.gif' border=0 class='subcat-image'></a>";
                             $imagefile .= "<span id='span" . $row['categoryid'] . "' style='display:none'>" . $tiplink . "</span>";
                         }
                     }
                     $GLOBALS['LeftImage'] = $imagefile;
                     $GLOBALS['ProductsCount'] = "(" . $row['totalproducts'] . ") Products Available";
                     $row['brandname'] = str_replace('~', ' , ', $row['brandname']);
                     //$GLOBALS['RelatedBrands'] = $row['brandname'];
                     if (!empty($row['seriesname'])) {
                         $row['brandname'] .= "<br>" . $row['seriesname'];
                     }
                     $GLOBALS['CatgSeriesList'] = "";
                     if ($row['seriesids'] != "") {
                         $seriesids = str_ireplace("~", ",", $row['seriesids']);
                         $seriesids_qry = "select seriesid , brandname , seriesname from isc_brand_series bs left join isc_brands b on bs.brandid = b.brandid where seriesid in (" . $seriesids . ")";
                         $seriesids_res = $GLOBALS['ISC_CLASS_DB']->Query($seriesids_qry);
                         if ($GLOBALS['ISC_CLASS_DB']->CountResult($seriesids_res) > 0) {
                             while ($seriesids_arr = $GLOBALS['ISC_CLASS_DB']->Fetch($seriesids_res)) {
                                 if ($GLOBALS['CatgSeriesList'] == "") {
                                     $GLOBALS['CatgSeriesList'] .= "<br><a href='javascript:' onclick=\"checkanimate('" . $row['categoryid'] . "')\">View Brands ></a><div id='" . $row['categoryid'] . "' style='display:block'>";
                                 } else {
                                     $GLOBALS['CatgSeriesList'] .= "<br>";
                                 }
                                 $tooltipscript = "onmouseover='createtip(" . $row['categoryid'] . $seriesids_arr['seriesid'] . ")' onmouseout='UnTip()'";
                                 if (!isset($params['brand'])) {
                                     if ($GLOBALS['EnableSEOUrls'] == 1) {
                                         $series_link = $subcatg_link . "/brand/" . MakeURLSafe(Strtolower($seriesids_arr['brandname'])) . "/series/" . MakeURLSafe(Strtolower($seriesids_arr['seriesname']));
                                         $GLOBALS['CatgSeriesList'] .= "<a href='" . $subcatg_link . "/brand/" . MakeURLSafe(Strtolower($seriesids_arr['brandname'])) . "/series/" . MakeURLSafe(Strtolower($seriesids_arr['seriesname'])) . "' {$tooltipscript}>" . $seriesids_arr['brandname'] . " " . $seriesids_arr['seriesname'] . "</a>";
                                     } else {
                                         $series_link = $subcatg_link . "&brand=" . MakeURLSafe(Strtolower($seriesids_arr['brandname'])) . "&series=" . MakeURLSafe(Strtolower($seriesids_arr['seriesname']));
                                         $GLOBALS['CatgSeriesList'] .= "<a href='" . $subcatg_link . "&brand=" . MakeURLSafe(Strtolower($seriesids_arr['brandname'])) . "&series=" . MakeURLSafe(Strtolower($seriesids_arr['seriesname'])) . "' {$tooltipscript}>" . $seriesids_arr['brandname'] . " " . $seriesids_arr['seriesname'] . "</a>";
                                     }
                                 } else {
                                     if ($GLOBALS['EnableSEOUrls'] == 1) {
                                         $series_link = $subcatg_link . "/series/" . MakeURLSafe(Strtolower($seriesids_arr['seriesname']));
                                         $GLOBALS['CatgSeriesList'] .= "<a href='" . $subcatg_link . "/series/" . MakeURLSafe(Strtolower($seriesids_arr['seriesname'])) . "' {$tooltipscript}>" . $seriesids_arr['brandname'] . " " . $seriesids_arr['seriesname'] . "</a>";
                                     } else {
                                         $series_link = $subcatg_link . "&series=" . MakeURLSafe(Strtolower($seriesids_arr['seriesname']));
                                         $GLOBALS['CatgSeriesList'] .= "<a href='" . $subcatg_link . "&series=" . MakeURLSafe(Strtolower($seriesids_arr['seriesname'])) . "' {$tooltipscript}>" . $seriesids_arr['brandname'] . " " . $seriesids_arr['seriesname'] . "</a>";
                                     }
                                 }
                                 $GLOBALS['CatgSeriesList'] .= "<span id='span" . $row['categoryid'] . $seriesids_arr['seriesid'] . "' style='display:none'><a class='thickbox1'  href='" . $GLOBALS['ShopPath'] . "/catgbrand.php?seriesid=" . $seriesids_arr['seriesid'] . "&catname=" . MakeURLSafe($row['catname']) . "&url=" . urlencode($series_link) . "' class='' ><img src='{$path}/templates/default/images/fastlook_red.gif' border=0></a></span>";
                             }
                             $GLOBALS['CatgSeriesList'] .= "</br></div>";
                         }
                     }
                     $content = $row['brandname'] . "<br>";
                     if (!isset($params['category']) && (isset($params['srch_category']) || !isset($GLOBALS['BRAND_SERIES_FLAG']))) {
                         $GLOBALS['CatgDescandBrandImage'] = isset($catg_desc_arr['catdesc']) ? $catg_desc_arr['catdesc'] : '';
                         // description will be added here to show it at the top of subcatg page.
                         $GLOBALS['CatgBrandSeriesFooter'] = isset($catg_desc_arr['categoryfooter']) ? $catg_desc_arr['categoryfooter'] : '';
                         $content .= "<h3><a href='" . $path . "/search.php?{$qry_string}&subcategory=" . MakeURLSafe($row['catname']) . "'>" . $row['catname'] . "</a></h3>>";
                         $GLOBALS['TitleLink'] = "<h2><a href='" . $subcatg_link . "' onmouseover='createtip(" . $row['categoryid'] . ")' onmouseout='UnTip()'>" . $row['catname'] . "</a></h2>";
                     }
                     /*$ProdStartPrice = GetStartingPrice($row['categoryid'], $row['prodcalculatedprice']);
                                            
                     		$content .= "Price starting from $".number_format($ProdStartPrice, 2, '.', '')."<br>".$imagefile;*/
                     $GLOBALS['leftsidecontent'] = $content;
                     if (number_format($row['prodminprice'], 2) < number_format($row['prodmaxprice'], 2)) {
                         $GLOBALS['PriceRange'] = "Price range from \$" . number_format($row['prodminprice'], 2, '.', '') . " to \$" . number_format($row['prodmaxprice'], 2, '.', '');
                     } else {
                         $GLOBALS['PriceRange'] = "Available at \$" . number_format($row['prodminprice'], 2, '.', '');
                     }
                     $content = "<img src='{$path}/templates/default/images/free-shipping2.gif'><br>" . strip_tags($row['proddesc']) . "<br>" . $row['prodwarranty'];
                     $GLOBALS['rightsidecontent'] = $content;
                     $GLOBALS['ShippingImage'] = "<img src='{$path}/templates/default/images/free-shipping2.gif'>";
                     $GLOBALS['ProductWarranty'] = "<h3>" . $row['prodwarranty'] . "</h3>";
                     $GLOBALS['ViewDetailsImage'] = "<a href='{$path}/catgbrand.php?categoryid=" . $row['categoryid'] . "&url=" . urlencode($subcatg_link) . "' class='thickbox'><img src='{$path}/templates/default/images/fastlook_red.gif'></a> ";
                     $content = "{$link}<img src='{$path}/templates/default/images/viewproducts.gif'></a>";
                     $GLOBALS['ViewDetailsImage'] .= $content;
                     if (IsDiscountAvailable('category', $row['categoryid'])) {
                         $GLOBALS['ViewDetailsImage'] .= '<img id="OnSale" src="' . GetConfig('ShopPath') . '/templates/default/images/onsale.gif" alt="">';
                     }
                     if ($this->IsMakeAnOffer('category', $row['categoryid']) == 'yes') {
                         $GLOBALS['ViewDetailsImage'] .= "<h3>Qualifies for Make an Offer!</h3>";
                     }
                     $GLOBALS['RelatedBrands'] = $row['featurepoints'];
                     $GLOBALS['lowersidecontent'] = $content;
                     /* This below conditions is added to have different templates for tonneau covers page */
                     if (isset($params['srch_category']) && !empty($params['srch_category']) && $selected_catg == 4 && $GLOBALS['results_page_flag'] == 0) {
                         $GLOBALS['rightsidecontent'] = $row['featurepoints'];
                         $GLOBALS['warranty'] = "";
                         /*if( trim($row['prodwarranty']) != '' )
                         		{
                         			$GLOBALS['warranty'] = "<img alt='Warranty' src='".$GLOBALS['ShopPath']."/images/warranty-icon.gif' style='margin-right: 7px;'/><strong>".$row['prodwarranty']."</strong>";
                         		}*/
                         if ($GLOBALS['SearchResultList'] != "") {
                             $GLOBALS['SearchResultList'] .= '<hr style="clear: left;"/>';
                         }
                         $GLOBALS['SearchResultList'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("NewSubCategoryListing");
                     } else {
                         $GLOBALS['SearchResultList'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCategoryListing");
                     }
                 } else {
                     $series_link = $this->LeftCatLink($mmy_links, 'series', $row['seriesname']);
                     $link = "<a href='" . $series_link . "'>";
                     //$imagelink = "<a href='".$path."/catgbrand.php?seriesid=".$row['brandseriesid']."&catname=".MakeURLSafe($row['parentcatname'])."&url=$series_link' class='thickbox' title=''>";
                     $main_catg_link = "";
                     $catg_count = array();
                     $GLOBALS['CatgSeriesList'] = "";
                     if ($row['subcatgids'] != "") {
                         $subcatgids = str_ireplace("~", ",", $row['subcatgids']);
                         $subcatgids_qry = "select c.categoryid , c.catname as childcatname , p.categoryid as parentid , p.catname as parentcatname from [|PREFIX|]categories c left join [|PREFIX|]categories p on c.catparentid = p.categoryid where c.categoryid in (" . $subcatgids . ")";
                         $subcatgids_res = $GLOBALS['ISC_CLASS_DB']->Query($subcatgids_qry);
                         //$catg_count = $GLOBALS['ISC_CLASS_DB']->CountResult($subcatgids_res);
                         if ($GLOBALS['ISC_CLASS_DB']->CountResult($subcatgids_res) > 0) {
                             while ($subcatgids_arr = $GLOBALS['ISC_CLASS_DB']->Fetch($subcatgids_res)) {
                                 if ($subcatgids_arr['parentid'] != 0) {
                                     $main_catg_link = $series_link . "/category/" . MakeURLSafe(Strtolower($subcatgids_arr['parentcatname']));
                                     $catg_count[$subcatgids_arr['parentid']] = $subcatgids_arr['parentcatname'];
                                 } else {
                                     $catg_count[$subcatgids_arr['categoryid']] = $subcatgids_arr['childcatname'];
                                 }
                                 if ($GLOBALS['CatgSeriesList'] == "") {
                                     $GLOBALS['CatgSeriesList'] .= "<br><a href='javascript:' onclick=\"checkanimate('" . $row['brandseriesid'] . "')\">View Category ></a><div id='" . $row['brandseriesid'] . "' style='display:none'>";
                                 } else {
                                     $GLOBALS['CatgSeriesList'] .= "<br>";
                                 }
                                 $tooltipscript = "onmouseover='createtip(" . $subcatgids_arr['categoryid'] . $row['brandseriesid'] . ")' onmouseout='UnTip()'";
                                 if ($GLOBALS['EnableSEOUrls'] == 1) {
                                     if ($subcatgids_arr['parentcatname'] == "") {
                                         $catgs_link = $series_link . "/category/" . MakeURLSafe(Strtolower($subcatgids_arr['childcatname']));
                                     } else {
                                         $catgs_link = $series_link . "/category/" . MakeURLSafe(Strtolower($subcatgids_arr['parentcatname'])) . "/subcategory/" . MakeURLSafe(Strtolower($subcatgids_arr['childcatname']));
                                     }
                                     $GLOBALS['CatgSeriesList'] .= "<a href='" . $catgs_link . "' {$tooltipscript}>" . $subcatgids_arr['childcatname'] . "</a>";
                                 } else {
                                     if ($subcatgids_arr['parentcatname'] == "") {
                                         $catgs_link = $series_link . "&category=" . MakeURLSafe(Strtolower($subcatgids_arr['childcatname']));
                                     } else {
                                         $catgs_link = $series_link . "&category=" . MakeURLSafe(Strtolower($subcatgids_arr['parentcatname'])) . "&subcategory=" . MakeURLSafe(Strtolower($subcatgids_arr['childcatname']));
                                     }
                                     $GLOBALS['CatgSeriesList'] .= "<a href='" . $catgs_link . "' {$tooltipscript}>" . $subcatgids_arr['childcatname'] . "</a>";
                                 }
                                 $GLOBALS['CatgSeriesList'] .= "<span id='span" . $subcatgids_arr['categoryid'] . $row['brandseriesid'] . "' style='display:none'><a class='thickbox1'  href='" . $GLOBALS['ShopPath'] . "/catgbrand.php?categoryid=" . $subcatgids_arr['categoryid'] . "&url=" . urlencode($catgs_link) . "' class='' ><img src='{$path}/templates/default/images/fastlook_red.gif' border=0></a></span>";
                             }
                             $GLOBALS['CatgSeriesList'] .= "</br></div>";
                         }
                     }
                     $GLOBALS['TitleLink'] = "<h2><a href='" . $series_link . "' onmouseover='createtip(" . $row['brandseriesid'] . ")' onmouseout='UnTip()'>" . $row['brandname'] . " " . $row['seriesname'] . " " . $row['parentcatname'] . "</a></h2>";
                     if (count($catg_count) == 1) {
                         $GLOBALS['TitleLink'] = "<h2><a href='" . $main_catg_link . "' onmouseover='createtip(" . $row['brandseriesid'] . ")' onmouseout='UnTip()'>" . $row['brandname'] . " " . $row['seriesname'] . " " . $row['parentcatname'] . "</a></h2>";
                     } else {
                         if (count($catg_count) > 1) {
                             $GLOBALS['TitleLink'] = "<h2><a href='" . $series_link . "' onmouseover='createtip(" . $row['brandseriesid'] . ")' onmouseout='UnTip()' onclick='return checkcategoryselection()'>" . $row['brandname'] . " " . $row['seriesname'] . " " . $row['parentcatname'] . "</a></h2>";
                         }
                     }
                     $tiplink = "<a class='thickbox1' href='" . $GLOBALS['ShopPath'] . "/catgbrand.php?seriesid=" . $row['brandseriesid'] . "&catname=" . MakeURLSafe($row['parentcatname']) . "&url=";
                     if (count($catg_count) == 1) {
                         $tiplink .= urlencode($main_catg_link) . "'";
                     } else {
                         if (count($catg_count) > 1) {
                             $tiplink .= "#' ";
                         } else {
                             $tiplink .= urlencode($series_link) . "'";
                         }
                     }
                     $tiplink .= " title=''><img src='{$path}/templates/default/images/fastlook_red.gif' border=0></a>";
                     $imagelink = "<a class='thickbox' href='" . $GLOBALS['ShopPath'] . "/catgbrand.php?seriesid=" . $row['brandseriesid'] . "&catname=" . MakeURLSafe($row['parentcatname']) . "&url=";
                     if (count($catg_count) == 1) {
                         $imagelink .= urlencode($main_catg_link) . "'";
                     } else {
                         if (count($catg_count) > 1) {
                             $imagelink .= "#' ";
                         } else {
                             $imagelink .= urlencode($series_link) . "'";
                         }
                     }
                     $imagelink .= " title='' onmouseover='createtip(" . $row['brandseriesid'] . ")' onmouseout='UnTip()'>";
                     if (isset($row['imagefile']) && !empty($row['imagefile'])) {
                         $images = explode("~", $row['imagefile']);
                         for ($j = 0; $j < count($images); $j++) {
                             if (!empty($images[$j])) {
                                 $imagefile = "{$imagelink}<img src='{$path}/category_images/" . $images[$j] . "'></a>";
                                 break;
                             }
                         }
                     } else {
                         if (empty($row['imagefile']) || empty($imagefile)) {
                             $imagefile = "{$imagelink}<img src='{$path}/templates/default/images/ProductDefault.gif' border=0></a>";
                         }
                     }
                     $GLOBALS['LeftImage'] = $imagefile;
                     $row['brandname'] = str_replace('~', ' , ', $row['brandname']);
                     $GLOBALS['RelatedBrands'] = $row['brandname'];
                     if (isset($row['seriesname']) && !empty($row['seriesname']) && (!isset($params['srch_category']) || isset($params['category'])) && isset($GLOBALS['BRAND_SERIES_FLAG'])) {
                         if (empty($row['imagefile']) || empty($imagefile)) {
                             $GLOBALS['LeftImage'] = "{$imagelink}<img src='{$path}/templates/default/images/ProductDefault.gif'  alt='" . isc_html_escape($row['seriesimagealt']) . "' title='" . isc_html_escape($row['seriesimagealt']) . "'></a>";
                             $GLOBALS['LeftImage'] .= "<span id='span" . $row['brandseriesid'] . "' style='display:none'>" . $tiplink . "</span>";
                         } else {
                             $GLOBALS['LeftImage'] = "{$imagelink}<img src='{$path}/series_images/" . $row['imagefile'] . "' width='140px'  alt='" . isc_html_escape($row['seriesimagealt']) . "' title='" . isc_html_escape($row['seriesimagealt']) . "'></a>";
                             $GLOBALS['LeftImage'] .= "<span id='span" . $row['brandseriesid'] . "' style='display:none'>" . $tiplink . "</span>";
                         }
                         //"<h3>".$row['catname']."</h3>
                         $GLOBALS['ProductsCount'] = "(" . $row['totalproducts'] . ") Products Available";
                         $GLOBALS['RelatedBrands'] = "<ul class='featurepoints'>";
                         if (!empty($row['feature_points1'])) {
                             $GLOBALS['RelatedBrands'] .= "<li>" . $row['feature_points1'] . "</li>";
                         }
                         if (!empty($row['feature_points2'])) {
                             $GLOBALS['RelatedBrands'] .= "<li>" . $row['feature_points2'] . "</li>";
                         }
                         if (!empty($row['feature_points3'])) {
                             $GLOBALS['RelatedBrands'] .= "<li>" . $row['feature_points3'] . "</li>";
                         }
                         if (!empty($row['feature_points4'])) {
                             $GLOBALS['RelatedBrands'] .= "<li>" . $row['feature_points4'] . "</li>";
                         }
                         $GLOBALS['RelatedBrands'] .= "</ul>";
                         /*if(isset($row['brandlargefile']) && !empty($row['brandlargefile'])) {
                         			$brand_image_path = "product_images/".$row['brandlargefile'];
                         			if(file_exists($brand_image_path)) {
                         				$GLOBALS['CatgDescandBrandImage'] = "<img src='$path/product_images/".$row['brandlargefile']."'>";
                         			} else if(isset($row['brandimagefile']) && !empty($row['brandimagefile'])) {
                         				$brand_image_path = "product_images/".$row['brandimagefile'];
                         				if(file_exists($brand_image_path))
                         					$GLOBALS['CatgDescandBrandImage'] = "<img src='$path/product_images/".$row['brandimagefile']."'>";
                         			}
                         		} else if(isset($row['brandimagefile']) && !empty($row['brandimagefile'])) {
                         				$brand_image_path = "product_images/".$row['brandimagefile'];
                         				if(file_exists($brand_image_path))
                         					$GLOBALS['CatgDescandBrandImage'] = "<img src='$path/product_images/".$row['brandimagefile']."'>";
                         		}*/
                     }
                     $GLOBALS['RelatedBrands'] = $row['feature_points'];
                     $GLOBALS['CatgDescandBrandImage'] = $row['branddescription'];
                     $GLOBALS['CatgBrandSeriesFooter'] = $row['brandfooter'];
                     if ($brand_rating != 0) {
                         $GLOBALS['CatgDescandBrandImage'] .= "<br><h2>Rating : <img width='64' height='12' src='" . $GLOBALS['TPL_PATH'] . "/images/IcoRating{$brand_rating}.gif' alt='' /></h2>";
                     }
                     $content = $row['brandname'] . "<br>";
                     $content .= $row['catname'] . "<br>";
                     /*$ProdStartPriceSeries = GetStartingPriceForSeries($row['brandseriesid'], $row['prodcalculatedprice']);
                       
                       $content .= "Price starting from $".number_format($ProdStartPriceSeries, 2, '.', '');*/
                     $GLOBALS['leftsidecontent'] = $content;
                     //$GLOBALS['PriceRange'] = "Price range from $".number_format($row['prodminprice'], 2, '.', '')." to $".number_format($row['prodmaxprice'], 2, '.', '');
                     if (number_format($row['prodminprice'], 2) < number_format($row['prodmaxprice'], 2)) {
                         $GLOBALS['PriceRange'] = "Price range from \$" . number_format($row['prodminprice'], 2, '.', '') . " to \$" . number_format($row['prodmaxprice'], 2, '.', '');
                     } else {
                         $GLOBALS['PriceRange'] = "Available at \$" . number_format($row['prodminprice'], 2, '.', '');
                     }
                     $content = "<img src='{$path}/templates/default/images/free-shipping2.gif'><br>" . strip_tags($row['proddesc']) . "<br>" . $row['prodwarranty'];
                     $GLOBALS['rightsidecontent'] = $content;
                     $GLOBALS['ShippingImage'] = "<img src='{$path}/templates/default/images/free-shipping2.gif'>";
                     $GLOBALS['ProductWarranty'] = "<h3>" . $row['prodwarranty'] . "</h3>";
                     $GLOBALS['ViewDetailsImage'] = "<a class='thickbox' href='" . $GLOBALS['ShopPath'] . "/catgbrand.php?seriesid=" . $row['brandseriesid'] . "&catname=" . MakeURLSafe($row['parentcatname']) . "&url=";
                     if (count($catg_count) > 1) {
                         $GLOBALS['ViewDetailsImage'] .= "#'";
                     } else {
                         if (count($catg_count) == 1) {
                             $GLOBALS['ViewDetailsImage'] .= urlencode($main_catg_link) . "'";
                         } else {
                             $GLOBALS['ViewDetailsImage'] .= urlencode($series_link) . "'";
                         }
                     }
                     $GLOBALS['ViewDetailsImage'] .= "><img src='{$path}/templates/default/images/fastlook_red.gif'></a> ";
                     $content = "{$link}";
                     if (count($catg_count) == 1) {
                         $content = "<a href='" . $main_catg_link . "'>";
                     } else {
                         if (count($catg_count) > 1) {
                             $content = "<a href='" . $series_link . "' onclick='return checkcategoryselection()'>";
                         }
                     }
                     $content .= "<img src='{$path}/templates/default/images/viewproducts.gif'></a>";
                     $GLOBALS['ViewDetailsImage'] .= $content;
                     if (IsDiscountAvailable('series', $row['brandseriesid'])) {
                         $GLOBALS['ViewDetailsImage'] .= '<img id="OnSale" src="' . GetConfig('ShopPath') . '/templates/default/images/onsale.gif" alt="">';
                     }
                     if ($this->IsMakeAnOffer('series', $row['brandseriesid']) == 'yes') {
                         $GLOBALS['ViewDetailsImage'] .= "<h3>Qualifies for Make an Offer!</h3>";
                     }
                     $GLOBALS['lowersidecontent'] = $content;
                     $GLOBALS['SearchResultList'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCategoryListing");
                     $GLOBALS['HideCompareItems'] = "none";
                 }
             }
         }
         $get_variables = $_GET;
         $sort_qry = "{$path}/search.php?search_query=" . urlencode($params['search_query']);
         unset($get_variables['orderby'], $get_variables['sort'], $get_variables['search_query'], $get_variables['sortby']);
         $i = 0;
         foreach ($get_variables as $key => $value) {
             $sort_qry .= "&{$key}={$value}";
         }
         if (isset($_REQUEST['sortby']) && $_REQUEST['sortby'] == 'desc') {
             $sort = "asc ";
             $img = "&nbsp;<img src='{$path}/templates/default/images/ArrowDown.gif' border=0>";
         } else {
             $sort = "desc ";
             $img = "&nbsp;<img src='{$path}/templates/default/images/ArrowUp.gif' border=0>";
         }
         //$GLOBALS['SearchResults'] = $GLOBALS['SearchResultList']; // commented by vikas
         if (isset($params['partnumber']) || $params['flag_srch_category'] == 1 || isset($params['flag_srch_category']) && isset($GLOBALS['BRAND_SERIES_FLAG']) && $GLOBALS['BRAND_SERIES_FLAG'] == 1) {
             if ($GLOBALS['EnableSEOUrls'] == 1) {
                 $GLOBALS['ProductBrand'] = "<a href='{$path}{$mmy_links}/orderby/brandname/sortby/{$sort}'>Brand</a>";
                 $GLOBALS['ProductPartNumber'] = "<a href='{$path}{$mmy_links}/orderby/prodcode/sortby/{$sort}'>Part Number</a>";
                 $GLOBALS['ProductPrice'] = "<a href='{$path}{$mmy_links}/orderby/prodcalculatedprice/sortby/{$sort}'>Price</a>";
             } else {
                 $GLOBALS['ProductBrand'] = "<a href='{$path}/search.php?search_query={$mmy_links}&orderby=brandname&sortby={$sort}'>Brand</a>";
                 $GLOBALS['ProductPartNumber'] = "<a href='{$path}/search.php?search_query={$mmy_links}&orderby=prodcode&sortby={$sort}'>Part Number</a>";
                 $GLOBALS['ProductPrice'] = "<a href='{$path}/search.php?search_query={$mmy_links}&orderby=prodcalculatedprice&sortby={$sort}'>Price</a>";
             }
             if (isset($_REQUEST['orderby']) && $_REQUEST['orderby'] == 'brandname') {
                 $GLOBALS['ProductBrand'] .= $img;
             }
             $GLOBALS['ProductVQ'] = $vq_column_title;
             /*if(isset($_GET['orderby']) && $_GET['orderby'] == 'brandname')
             		$GLOBALS['Product_VQ'] .= $img;*/
             if (isset($_REQUEST['orderby']) && $_REQUEST['orderby'] == 'prodcode') {
                 $GLOBALS['ProductPartNumber'] .= $img;
             }
             $GLOBALS['ProductPQ'] = "Product Options";
             /*if(isset($_GET['orderby']) && $_GET['orderby'] == 'productoption')
             		$GLOBALS['SearchResults'] .= $img;*/
             if (isset($_REQUEST['orderby']) && $_REQUEST['orderby'] == 'prodcalculatedprice') {
                 $GLOBALS['ProductPrice'] .= $img;
             }
             $GLOBALS['ProductDetails'] = "Details";
             $GLOBALS['SearchResults'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCategoryProductsItemHeader");
         } else {
             //		                $GLOBALS['SearchResults'] = "<div>".$GLOBALS['SearchResultList']."</div>";
             if (isset($params['srch_category']) && !empty($params['srch_category']) && $GLOBALS['results_page_flag'] == 0 && $selected_catg == 4) {
                 $GLOBALS['FilterTitle'] = "Narrow by Category";
                 $GLOBALS['ResultTitle'] = "Category Details";
                 if (count($GLOBALS['SearchBrands']) > 0) {
                     $GLOBALS['BrandsList'] = "";
                     $brandlistingqry = " select brandname , brandimagefile, brandlargefile, brandaltkeyword from [|PREFIX|]brands where brandid in (" . implode($GLOBALS['SearchBrands'], ",") . ")";
                     $brandlistingresult = $GLOBALS['ISC_CLASS_DB']->Query($brandlistingqry);
                     while ($brandlisting_row = $GLOBALS['ISC_CLASS_DB']->Fetch($brandlistingresult)) {
                         if (isset($params['brand'])) {
                             $file = realpath(ISC_BASE_PATH . '/' . GetConfig('ImageDirectory') . '/' . $brandlisting_row['brandlargefile']);
                             if (file_exists($file)) {
                                 $attribs = @getimagesize($file);
                                 $width = $attribs[0];
                                 $height = $attribs[1];
                                 if ($width > 240) {
                                     $width = "240";
                                 }
                                 /*if( $height > 240 )
                                 		$height = "240";*/
                                 $GLOBALS['BrandsList'] .= "<img alt='" . $brandlisting_row['brandaltkeyword'] . "' src='" . $GLOBALS['ShopPath'] . "/product_images/" . $brandlisting_row['brandlargefile'] . "' width='" . $width . "' /> ";
                                 $brandparams = $params;
                                 unset($brandparams['brand'], $brandparams['series']);
                                 $mmylinks = $this->GetYMMLinks($brandparams);
                                 $GLOBALS['BrandsList'] .= "<br><a href='" . $path . $mmylinks . "'>View All Brands</a>";
                             }
                         } else {
                             if (isset($params['srch_category'])) {
                                 $GLOBALS['BrandsList'] .= "<a href='" . $path . $mmy_links . "/brand/" . MakeURLSafe(strtolower($brandlisting_row['brandname'])) . "'>";
                             } else {
                                 $GLOBALS['BrandsList'] .= "<a  href='" . $path . "/" . MakeURLSafe(strtolower($brandlisting_row['brandname'])) . $mmy_links . "'>";
                             }
                             $GLOBALS['BrandsList'] .= "<img alt='" . $brandlisting_row['brandname'] . "'  src='" . $GLOBALS['ShopPath'] . "/product_images/" . $brandlisting_row['brandimagefile'] . "'/></a>";
                         }
                     }
                 } else {
                     $GLOBALS['BrandListStyle'] = "display:none";
                 }
                 $GLOBALS['ResultCategories'] = "";
                 foreach ($GLOBALS['SearchCategories'] as $key => $catid) {
                     $parentid = $GLOBALS['categories_all'][$catid]['catparentid'];
                     if ($parentid != 0) {
                         if (isset($params['srch_category'])) {
                             $mmy_links_modified = $mmy_links;
                         } else {
                             if (isset($GLOBALS['categories_all'][$parentid])) {
                                 // if parent catg is not visible
                                 $mmy_links_modified = "/" . MakeURLSafe(strtolower($GLOBALS['categories_all'][$parentid]['catname'])) . $mmy_links;
                             } else {
                                 $mmy_links_modified = "/" . MakeURLSafe(strtolower($GLOBALS['categories_all'][$catid]['catname'])) . $mmy_links;
                             }
                         }
                     } else {
                         $mmy_links_modified = "/" . MakeURLSafe(strtolower($GLOBALS['categories_all'][$catid]['catname'])) . $mmy_links;
                     }
                     /*echo "<br>".$mmy_links;
                     		exit;*/
                     $subcatg_link = $this->LeftCatLink($mmy_links_modified, 'subcategory', $GLOBALS['categories_all'][$catid]['catname']);
                     $GLOBALS['ResultCategories'] .= "<div class='button'><a href='" . $subcatg_link . "'>" . $GLOBALS['categories_all'][$catid]['catname'] . "</a></div>";
                 }
                 $GLOBALS['SearchResults'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("NewSubCategoryListingMain");
             } else {
                 $GLOBALS['SearchResults'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SubCategoryListingMain");
             }
         }
         $GLOBALS['SearchResults'] .= "<script type=\"text/javascript\"> \$('.focushiddendiv').css({'position':'absolute', 'margin-top':'-200px', 'display':'block'}); </script>";
         if ($GLOBALS['EnableSEOUrls'] == 1) {
             $back2url = $_SESSION['back2url'] = preg_replace("/^\\//", "", $_SERVER['REQUEST_URI']);
         } else {
             $back2url = $_SESSION['back2url'] = "search.php?" . $_SERVER['QUERY_STRING'];
         }
         ISC_SetCookie("back2search", $back2url, 0, "/");
         // Showing the syndication option?
         if (GetConfig('RSSNewProducts') != 0 && GetConfig('RSSCategories') != 0 && GetConfig('RSSSyndicationIcons') != 0) {
             $GLOBALS['RSSURL'] = SearchLink($GLOBALS['ISC_CLASS_SEARCH']->GetQuery(), 0, false);
             $GLOBALS['SNIPPETS']['SearchResultsFeed'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SearchResultsFeed");
         }
     } else {
         $this->YMMSelectors($params);
         $GLOBALS['SearchResults'] = "<div style='float:left'>" . $GLOBALS['YMMTable'] . "</div>";
         $GLOBALS['CategoryBrandList'] = "%%Panel.StaticFeaturedCategories%%\n\t\t\t\t%%Panel.StaticFeaturedBrands%%";
         // No search results were found
         // commented below code as need to show the favorite categories and brands as in homepage
         /*$GLOBALS['HideSearchResults'] = "none";
         		$GLOBALS['HidePanels'][] = 'SearchPageProducts';*/
     }
 }