' ;}
if (strpos(strtolower($_SERVER['QUERY_STRING']),strtolower($value_word)) !== false ) { $run_sql = false ;}
}
}
if ( $detect->isMobile() || $detect->isTablet() ) { $alfa = 2; $beta = 1; } else { $alfa = 4; $beta = 3; }
//$warehouse_sql_text = "warehouse = '" . $warehouse_global . "' and store_id = " . $store_id . " and ";
//$warehouse_global = 'ae';
//we have us client with us web site to show him only us warehouse item
$warehouse_sql_text = '';
if (isset($warehouse_global)) {
//$warehouse_sql_text = " warehouse = '" . $warehouse_global . "' and store_id = " . $store_id . " and ";
$warehouse_sql_text = " from_bg.warehouse in (" . $warehouse_global . ") and ";
}
// check if we have different store id then zero then we will only show sub set of items for that store....
$store_id_sql_text = '' ;
if (isset($store_id)) {
$store_id_sql_text = " from_bg.store_id = " . $store_id . " and ";
}
//$sales_rank_sql_text = " from_bg.sales_rank > 0 and from_bg.sales_rank < 50000 and ";
$sales_rank_sql_text = " from_bg.sales_rank is not null and ";
$sales_rank_sql_text = " ";
$sort = ' from_bg.sales_rank asc '; // $sort = 'from_bg.product_name'; $sort = 'RAND()'; // $sort = 'from_bg.1cd_price desc'; //$sort = 'from_bg.views';
$sort = 1;
$sort = ' line_id desc ';
// if ($max_price < 200 )
// { $some_price = rand(5,190); }
// else
// { $some_price = rand(50,3000); }
$some_price = rand(5,$max_price);
// $min_price_rand = $some_price - 5 ;
// $max_price_rand = $some_price + 5;
$min_price_rand = $some_price - $some_price*0.2;
$max_price_rand = $some_price + $some_price*0.2;
// for ai items we do not issues with # of items for now ...
if ( $use_ai_product_name == true ) {$min_price_rand = 5; $max_price_rand = 500;}
// for for any other store with $show_all_items_in_home_page == true
if ($show_all_items_in_home_page == true) {$min_price_rand = 5; $max_price_rand = 500;}
$min_price = 1;
//$max_price = 3000;
if (isset($_GET['sort']))
{ if ($_GET['sort'] == '1') {$sort = '1cd_price asc';}
else if ($_GET['sort'] == '-1') {$sort = '1cd_price desc';} }
$email_q2_err='';
if (isset($_POST['email_q2']))
{
if(!filter_var($_POST['email_q2'], FILTER_VALIDATE_EMAIL))
{ $email_q2_err=' Not a valid email address '; }
if ($_POST['captcha_q'] != "10")
{ $email_q2_err.=' Not a valid answer '; }
if ($email_q2_err=='') {
$to = 'info@' . $business_name . '.com';
$subject = 'Question from product page: ' . time().'-'.mt_rand() ;
$headers = "From: " . $_POST['email_q2'];
$headers .= "Reply-To: " . $_POST['email_q2'] . "\r\n";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$message = "From: " . $_POST['email_q2']. "
ITEM URL: " . $url . "
QUESTION: " . $_POST['text_q2'];
mail($to, $subject, $message, $headers,"-f" . $_POST['email_q2']);
$email_q2_err=' Thank you! We Will Respond Soon';
}
}
$text_text ='';
$search_str = "";
$sql_text = '';
$sql_text_images = '';
$num_records = 0 ;
$ribbon_text = '';
$search_param = '';
$prime_sql_text ='';
$sql_select_string = "product_name,product_sku,sub_category,brand,last_node,image_url0,local_image_url0,qty,cat_text,binding,product_type,product_group,sales_rank,department";
//show special promotions for USA hollydays
/*****************************/
$halloween_date = date("31-10-2017");
$currentdate = date("d-m-Y");
//echo $currentdate;
$days_to_halloween = (strtotime($halloween_date) - strtotime($currentdate)) / (60 * 60 * 24);
//echo $days;
/*****************************/
if (isset($show_prime_items_only)) {
if ($show_prime_items_only==1) {
$prime_sql_text = "from_bg.availability = 'Usually ships in 24 hours' and is_eligible_for_super_saver_shipping=1 and ";
}
}
//check if we have watch list to display :
if (isset($_GET['watch_list']) && isset($_SESSION['customer_id'])) {
$sort = 'watch_list.date_added';
//check if we have brand in url as well so we will filter both
$sql_text = "SELECT ".$sql_select_string.", from_bg.product_price*".$discount_amount."+".$flat_fee." as 1cd_price FROM from_bg inner join watch_list on from_bg.product_sku = watch_list.product_sku where watch_list.email_address= '".$_SESSION['email_address']."' ORDER BY ".$sort." LIMIT 24;";
//echo $sql_text;
$text_text = 'Products in your watch list ';
}
//check if we search by last_node :
else if (isset($_GET['last_node'])) {
//check if we have brand in url as well so we will filter both
$search_param = mysqli_real_escape_string($con,htmlentities($_GET['last_node']));
//$search_param = htmlentities($search_param, ENT_QUOTES | ENT_HTML5, 'UTF-8');
$added_cond = '';
if (isset($_GET['brand'])) {
$added_text = ' > ' . htmlentities($_GET['brand']) . ' ';
$added_cond = ' and (brand = "' . mysqli_real_escape_string($con,$_GET['brand']) . '" ) '; }
if (isset($_GET['filter'])) {
$added_text = $added_text . ' > ' . htmlentities($_GET['filter']) . ' ';
$added_cond = $added_cond . ' and (department = "' . mysqli_real_escape_string($con,$_GET['filter']) . '" ) '; }
$sql_text = "SELECT ".$sql_select_string.", product_price*".$discount_amount."+".$flat_fee." as 1cd_price FROM from_bg where " . $prime_sql_text . $warehouse_sql_text . $store_id_sql_text . $sales_rank_sql_text . $binding_sql_text . $forbidden_items_sql_text . " (product_price*".$discount_amount."+".$flat_fee." > ".$min_price." and product_price*".$discount_amount."+".$flat_fee." < ".$max_price.") and (last_node = '" . $search_param . "' ) " . $added_cond . " and qty > 0 " .$show_in_store . " ORDER BY ".$sort." LIMIT ".$num_results.";";
$text_text = ' '. $search_param . ' ' . $added_text;
}
//check if we search by brand name :
else if (isset($_GET['brand'])) {
$search_param = mysqli_real_escape_string($con,htmlentities($_GET['brand']));
//$search_param = htmlentities($search_param, ENT_QUOTES | ENT_HTML5, 'UTF-8');
$added_cond = '';
if (isset($_GET['last_node'])) {
$added_text = ' >' . htmlentities($_GET['last_node']) . ' ';
$added_cond = ' and (last_node = "' . mysqli_real_escape_string($con,$_GET['last_node']) . '" ) '; }
if (isset($_GET['filter'])) {
$added_text = $added_text . ' > ' . htmlentities($_GET['filter']) . ' ';
$added_cond = $added_cond . ' and (department = "' . mysqli_real_escape_string($con,$_GET['filter']) . '" ) '; }
$sql_text = "SELECT ".$sql_select_string.", product_price*".$discount_amount."+".$flat_fee." as 1cd_price FROM from_bg where " . $prime_sql_text . $warehouse_sql_text . $store_id_sql_text . $sales_rank_sql_text . $binding_sql_text . $forbidden_items_sql_text . " (product_price*".$discount_amount."+".$flat_fee." > ".$min_price." and product_price*".$discount_amount."+".$flat_fee." < ".$max_price.") and (brand = '" . $search_param . "' ) " . $added_cond . " and qty > 0 " .$show_in_store . " ORDER BY ".$sort." LIMIT ".$num_results.";";
$text_text = ''. $search_param . '' . $added_text ;
}
//check if we search by binding :
else if (isset($_GET['cat_text'])) {
//check if we have brand in url as well so we will filter both
$search_param = mysqli_real_escape_string($con,$_GET['cat_text']);
//$search_param = htmlentities($search_param, ENT_QUOTES | ENT_HTML5, 'UTF-8');
$sql_text = "SELECT ".$sql_select_string.", product_price*".$discount_amount."+".$flat_fee." as 1cd_price FROM from_bg where " . $prime_sql_text . $warehouse_sql_text . $store_id_sql_text . $sales_rank_sql_text . $binding_sql_text . $forbidden_items_sql_text . " (product_price*".$discount_amount."+".$flat_fee." > ".$min_price." and product_price*".$discount_amount."+".$flat_fee." < ".$max_price.") and (cat_text = '" . $search_param . "' ) and qty > 0 " .$show_in_store . " ORDER BY ".$sort." LIMIT ".$num_results.";";
$cat_text = $_GET['cat_text'];
//$cat_text = htmlentities($_GET['cat_text']);
$cat_text_array = explode(">", $cat_text);
if ($_GET['test1']) { echo 'cat_text_array : ' . $cat_text_array[0] . $cat_text_array[1] . $cat_text_array[2]. $cat_text_array[3]. $cat_text_array[4]. $cat_text_array[5].'
' ; }
if ($cat_text_array[0] !== '') {$cat_text_0 = $cat_text_array[0] . ' > ' ;}
if ($cat_text_array[1] !== '') {$cat_text_1 = $cat_text_array[1] . ' > ' ;}
if ($cat_text_array[2] !== '') {$cat_text_2 = $cat_text_array[2] . ' > ' ;}
if ($cat_text_array[3] !== '') {$cat_text_3 = $cat_text_array[3] . ' > ' ;}
if ($cat_text_array[4] !== '') {$cat_text_4 = $cat_text_array[4] . ' > ' ;}
if ($cat_text_array[5] !== '') {$cat_text_5 = $cat_text_array[5] ;}
$cat_text_show = $cat_text_0 . $cat_text_1 . $cat_text_2 . $cat_text_3 . $cat_text_4 . $cat_text_5 ;
$cat_text_show =str_replace("Categories >","",$cat_text_show);
$cat_text_show =str_replace("Departments >","",$cat_text_show);
$cat_text_show =str_replace("Products >","",$cat_text_show);
if ($_GET['test1']) { echo "new show " . $cat_text_show.'
'; }
// if (trim($cat_text_array[5]) !== '') { $text_text = ' '. $cat_text_array[5] ; }
// else { $text_text = ' '. $cat_text_show ; }
// fix - show the last element only
// instead of this
$text_text = ' '. $cat_text_show ;
// do this
$cat_text_show_array1 = explode('>', $cat_text_show);
$text_text = end($cat_text_show_array1) ;
}
//check if we search by binding :
else if (isset($_GET['binding'])) {
//check if we have brand in url as well so we will filter both
$search_param = mysqli_real_escape_string($con,$_GET['binding']);
$search_param = htmlentities($search_param, ENT_QUOTES | ENT_HTML5, 'UTF-8');
$sql_text = "SELECT ".$sql_select_string.", product_price*".$discount_amount."+".$flat_fee." as 1cd_price FROM from_bg where " . $prime_sql_text . $warehouse_sql_text . $store_id_sql_text . $sales_rank_sql_text . $binding_sql_text . $forbidden_items_sql_text . " (product_price*".$discount_amount."+".$flat_fee." > ".$min_price." and product_price*".$discount_amount."+".$flat_fee." < ".$max_price.") and (binding = '" . $search_param . "' ) and qty > 0 " .$show_in_store . " ORDER BY ".$sort." LIMIT ".$num_results.";";
$text_text = ' '. $search_param . ' ' . $added_text;
}
//check if we search by product_type :
else if (isset($_GET['product_group'])) {
//check if we have brand in url as well so we will filter both
$search_param = mysqli_real_escape_string($con,$_GET['product_group']);
$search_param = htmlentities($search_param, ENT_QUOTES | ENT_HTML5, 'UTF-8');
$sql_text = "SELECT ".$sql_select_string.", product_price*".$discount_amount."+".$flat_fee." as 1cd_price FROM from_bg where " . $prime_sql_text . $warehouse_sql_text . $store_id_sql_text . $sales_rank_sql_text . $binding_sql_text . $forbidden_items_sql_text . " (product_price*".$discount_amount."+".$flat_fee." > ".$min_price." and product_price*".$discount_amount."+".$flat_fee." < ".$max_price.") and (product_group = '" . $search_param . "' ) and qty > 0 " .$show_in_store . " ORDER BY ".$sort." LIMIT ".$num_results.";";
$text_text = ' '. $search_param . ' ' . $added_text;
}
//check if we search by product_type :
else if (isset($_GET['product_type'])) {
//check if we have brand in url as well so we will filter both
$search_param = mysqli_real_escape_string($con,$_GET['product_type']);
$search_param = htmlentities($search_param, ENT_QUOTES | ENT_HTML5, 'UTF-8');
$sql_text = "SELECT ".$sql_select_string.", product_price*".$discount_amount."+".$flat_fee." as 1cd_price FROM from_bg where " . $prime_sql_text . $warehouse_sql_text . $store_id_sql_text . $sales_rank_sql_text . $binding_sql_text . $forbidden_items_sql_text . " (product_price*".$discount_amount."+".$flat_fee." > ".$min_price." and product_price*".$discount_amount."+".$flat_fee." < ".$max_price.") and (product_type = '" . $search_param . "' ) and qty > 0 " .$show_in_store . " ORDER BY ".$sort." LIMIT ".$num_results.";";
$text_text = ' '. $search_param . ' ' . $added_text;
}
// if we come from search box or doing search via GET
else if (isset($_POST['search_param']) || (isset($_GET['search_box']) && empty($_GET['search_box'])==false)) {
if (isset($_POST['search_param'])) {
if (strlen($_POST['search_param']) > 2 )
{ $search_param = mysqli_real_escape_string($con,$_POST['search_param']);
$search_param = htmlentities($search_param, ENT_QUOTES | ENT_HTML5, 'UTF-8');
$search_param_row = $search_param;
} else { $search_param = 'SORRY ... NOTHING TO SHOW HERE'; exit; }
// fix to output text without XSS attack risk ...
$text_text = html_entity_decode($search_param);
$user_input = explode(' ',$search_param);
$search_param = join(' +',$user_input);
// $text_text = $_POST['search_param'];
}
else if (isset($_GET['search_box']) && empty($_GET['search_box'])==false) {
// echo $_GET['search_box'];
if (strlen($_GET['search_box']) > 2 )
{ $search_param = mysqli_real_escape_string($con,urldecode($_GET['search_box']));
$search_param = htmlentities($search_param, ENT_QUOTES | ENT_HTML5, 'UTF-8');
}
else { exit; $text_text = 'SORRY ... NOTHING TO SHOW HERE'; }
//echo $search_param;
$user_input = explode(' ',$search_param);
$search_param = join(' +',$user_input);
$text_text = $_GET['search_box'];
}
//search last_node then item
//check for last node
// disable for now as it is slow ...
/*
$sql_text = "SELECT ".$sql_select_string.", product_price*".$discount_amount."+".$flat_fee." as 1cd_price, MATCH(last_node) AGAINST ('+" . $search_param . "' IN BOOLEAN MODE) as relevance FROM from_bg where " . $prime_sql_text . $warehouse_sql_text . $store_id_sql_text . " (product_price*".$discount_amount."+".$flat_fee." > 0 and product_price*".$discount_amount."+".$flat_fee." < ".$max_price.") and MATCH(last_node) AGAINST ('" . $search_param . "' IN BOOLEAN MODE) and qty > 0 " .$show_in_store . " ORDER BY relevance DESC, ".$sort." LIMIT ".$num_results."";
$result_last_node = mysqli_query($con, $sql_text);
if (mysqli_num_rows($result_last_node) == 0) {
$sql_text = "SELECT ".$sql_select_string.", product_price*".$discount_amount."+".$flat_fee." as 1cd_price, MATCH(product_name) AGAINST ('+" . $search_param . "' IN BOOLEAN MODE) as relevance FROM from_bg where " . $prime_sql_text . $warehouse_sql_text . $store_id_sql_text . " (product_price*".$discount_amount."+".$flat_fee." > 0 and product_price*".$discount_amount."+".$flat_fee." < ".$max_price.") and MATCH(product_name) AGAINST ('" . $search_param . "' IN BOOLEAN MODE) and qty > 0 " .$show_in_store . " ORDER BY relevance DESC, ".$sort." LIMIT ".$num_results."";
}
*/
// re write SQL for faster serch
//$search_param = mysqli_real_escape_string($con,$_POST['search_param']);
// loop to prevent forbidden keywords
$run_sql = true ;
if ($forbidden_keywords) {
foreach ($forbidden_keywords as $value_word) {
if (strpos(strtolower($search_param),strtolower($value_word)) !== false ) { $run_sql = false ;}
}
}
if ($run_sql == true) {
$sql_text = "SELECT ".$sql_select_string.", product_price*".$discount_amount."+".$flat_fee." as 1cd_price, MATCH(product_name) AGAINST ('+" . $search_param . "' IN BOOLEAN MODE) as relevance FROM from_bg where " . $prime_sql_text . $warehouse_sql_text . $store_id_sql_text . $sales_rank_sql_text . $binding_sql_text . $forbidden_items_sql_text . " (product_price*".$discount_amount."+".$flat_fee." > ".$min_price." and product_price*".$discount_amount."+".$flat_fee." < ".$max_price.") and MATCH(product_name) AGAINST ('" . $search_param . "' IN BOOLEAN MODE) and qty > 0 " .$show_in_store . " LIMIT ".$num_results."";
//echo $search_param ;
// special code to handle the case where search_param is model or brand - we will look for special symbol 'model:' or 'brand:' if we found this then we will run the search based on model / brand only without like - this done via the autosuggest.php code where we add model / brand to the search string ...
if (strpos(strtolower($search_param_row) , 'model-') !== false) {
$search_param_row = str_replace('model-', '', $search_param_row);
$sql_text = "SELECT ".$sql_select_string.", product_price*".$discount_amount."+".$flat_fee." as 1cd_price FROM from_bg where " . $prime_sql_text . $warehouse_sql_text . $store_id_sql_text . $sales_rank_sql_text . $binding_sql_text . $forbidden_items_sql_text . " (product_price*".$discount_amount."+".$flat_fee." > ".$min_price." and product_price*".$discount_amount."+".$flat_fee." < ".$max_price.") and model = '".$search_param_row."' and qty > 0 " .$show_in_store . " LIMIT ".$num_results."";
//echo $sql_text;
}
if (strpos(strtolower($search_param_row) , 'brand-') !== false) {
$search_param_row = str_replace('brand-', '', $search_param_row);
$sql_text = "SELECT ".$sql_select_string.", product_price*".$discount_amount."+".$flat_fee." as 1cd_price FROM from_bg where " . $prime_sql_text . $warehouse_sql_text . $store_id_sql_text . $sales_rank_sql_text . $binding_sql_text . $forbidden_items_sql_text . " (product_price*".$discount_amount."+".$flat_fee." > ".$min_price." and product_price*".$discount_amount."+".$flat_fee." < ".$max_price.") and brand = '".$search_param_row."' and qty > 0 " .$show_in_store . " LIMIT ".$num_results."";
//echo $sql_text;
}
}
else { $sql_text = '';}
//$sql_text = "SELECT ".$sql_select_string.", product_price*".$discount_amount."+".$flat_fee." as 1cd_price FROM from_bg where " . $prime_sql_text . $warehouse_sql_text . $store_id_sql_text . $sales_rank_sql_text . $binding_sql_text . " (product_price*".$discount_amount."+".$flat_fee." > ".$min_price." and product_price*".$discount_amount."+".$flat_fee." < ".$max_price.") and product_name LIKE '%" .$text_text . "%' and qty > 0 " .$show_in_store . " LIMIT ".$num_results."";
//if (($user_ip == '37.142.221.8' || $user_ip == '31.168.230.226') && 1 == 1) {
//echo 'showing only to local ip :
' ;
// echo $sql_text . '
' ; }
//echo $sql_text;
}
// special case for refurbished items for dealz17.com
else if ($_GET['search_param'] == "HOMEPAGE" && $domain_1 == "www.dealz17.com" && 1 == 0)
{
$sql_text = "SELECT ".$sql_select_string.", product_price*".$discount_amount."+".$flat_fee." as 1cd_price
FROM from_bg
where " . $prime_sql_text . $warehouse_sql_text . $store_id_sql_text . $sales_rank_sql_text . $binding_sql_text . " (product_price*".$discount_amount."+".$flat_fee." > ".$min_price." and product_price*".$discount_amount."+".$flat_fee." < ".$max_price.") and MATCH(product_name) AGAINST ('refurbished' IN BOOLEAN MODE) and qty > 0 " .$show_in_store . " ORDER BY RAND() LIMIT ".$num_results."";
$reload_more = ' ' . 'Load More... ' . '';
$text_text = 'Special DEALZ on well known brands ' . $reload_more ;
}
// if we come through parameter in URL
else if (isset($_GET['search_param']) && empty($_GET['search_param'])==false)
{
$array_categ = array('Animals & Pet Supplies','Apparel & Accessories','Arts & Entertainment','Baby & Toddler','Business & Industrial','Cameras & Optics','Electronics','Food, Beverages & Tobacco','Hardware','Health & Beauty','Home & Garden','Luggage & Bags','Office Supplies','Software','Sporting Goods','Toys & Games','Vehicles & Parts');
if (strlen($_GET['search_param']) > 2 ) { $search_param = htmlentities($_GET['search_param']); } else { $search_param = 'SORRY ... NOTHING TO SHOW HERE'; }
if ($_GET['search_param'] == "STARTSEARCH"){ $search_param = 'Please fill in 3 character or more keyword(s)'; }
else if ($_GET['search_param'] == "HOMEPAGE" && ( $domain_1 == "www.haitaok.com" || $domain_1 == "www.ca.2daydeliver.com" || $domain_1 == "www.ru.bta-mall.com" || $domain_1 == "www.ru.alumigogo.com" || $domain_1 == "www.uk.bta-mall.com") )
{
//show special promotions for USA hollydays
/*****************************/
/*
if ($days_to_halloween> 0 && $days_to_halloween<30 && 1==0) {
$array_categ = array('Halloween Costumes','Halloween Masks','Halloween Wigs','Halloween Costume Capes');
$rand_num = rand(0,2);
$search_param = $array_categ[$rand_num];
//$search_param = 'halloween costumes';
$sql_text = "SELECT ".$sql_select_string.", product_price*".$discount_amount."+".$flat_fee." as 1cd_price, MATCH(product_name) AGAINST ('+" . $search_param . "' IN BOOLEAN MODE) as relevance FROM from_bg where " . $prime_sql_text . $warehouse_sql_text . $store_id_sql_text . $sales_rank_sql_text . $binding_sql_text . $forbidden_items_sql_text . " (product_price*".$discount_amount."+".$flat_fee." > 0 and product_price*".$discount_amount."+".$flat_fee." < ".$max_price.") and MATCH(product_name) AGAINST ('" . $search_param . "' IN BOOLEAN MODE) and qty > 0 " .$show_in_store . " ORDER BY relevance DESC, ".$sort." LIMIT ".$num_results."";
$text_text = ' Halloween Shopping Ideas ' ;
}
*/
/***************************************/
//$rand_num = 11;
if ($sql_text == '') {
/*
$array_categ = array('Toys','Vehicles','Health','Beauty','Apparel','Electronics','Home & Garden','Sport','Animals');
$rand_num = rand(0,8);
$main_categ = $array_categ[$rand_num];
if ( $domain_1 == "www.fashion-shop.club" ) {$main_categ='shoes';}
if ( $domain_1 == "www.solikomall.com" ) {$main_categ='swimwear';}
*/
//if ( $store_id == 7 ) {$rand_num = 7;}
//$sql_text = "SELECT *, product_price*".$discount_amount."+".$flat_fee." as 1cd_price FROM from_bg where " . $prime_sql_text . $warehouse_sql_text . $store_id_sql_text . " (product_price*".$discount_amount."+".$flat_fee." > 0 and product_price*".$discount_amount."+".$flat_fee." < ".$max_price.") and category = '".$main_categ."' and qty > 0 " .$show_in_store . " ORDER BY ".$sort." LIMIT ".$num_results.";" ;
//$sql_text = "SELECT ".$sql_select_string.", product_price*".$discount_amount."+".$flat_fee." as 1cd_price, MATCH(product_name) AGAINST ('+" . $main_categ . "' ) as relevance FROM from_bg where " . $prime_sql_text . $warehouse_sql_text . $store_id_sql_text . $sales_rank_sql_text . $binding_sql_text . $forbidden_items_sql_text . " (product_price*".$discount_amount."+".$flat_fee." > 0 and product_price*".$discount_amount."+".$flat_fee." < ".$max_price.") and MATCH(product_name) AGAINST ('" . $main_categ . "' ) and qty > 0 " .$show_in_store . " ORDER BY relevance DESC, ".$sort." LIMIT ".$num_results."";
$limit_from = rand(1,200) ;
$limit_to = $limit_from + $num_results ;
//$max_price = rand(1,2000) ;
$sql_text = "SELECT ".$sql_select_string.", product_price*".$discount_amount."+".$flat_fee." as 1cd_price FROM from_bg where " . $prime_sql_text . $warehouse_sql_text . $binding_sql_text . $store_id_sql_text . " (product_price*".$discount_amount."+".$flat_fee." > ".$min_price_rand." and product_price*".$discount_amount."+".$flat_fee." < ".$max_price_rand.") and qty > 0 " .$show_in_store . " LIMIT ". $limit_from . ", " .$limit_to."";
//if (($user_ip == '37.142.221.8' || $user_ip == '31.168.230.226') && 1 == 1) { echo $sql_text; };
//echo $sql_text;
//$text_text = $main_categ ;
$text_text = 'Random Hot Items ...' ;
}
}
//////////////
else if ($_GET['search_param'] == "HOMEPAGE" && ($domain_1 == "www.global.bta-mall.com" || $domain_1 == "au.alumigogo.com" || $domain_1 == "au.bta-mall.com" || $domain_1 == "ca.alumigogo.com" || $domain_1 == "ca.bta-mall.com" || $domain_1 == "uk.alumigogo.com" || $domain_1 == "uk.bta-mall.com" || $domain_1 == "www.shop.dealz17.com") && 1 == 1 )
{
//exit;
if ($sql_text == '') {
//$array_categ = array('Toys','Vehicles','Health','Beauty','Apparel','Electronics','Home & Garden','Sport','Animals');
//$rand_num = rand(0,8);
//$main_categ = $array_categ[$rand_num];
//$sql_text = "SELECT *, product_price*".$discount_amount."+".$flat_fee." as 1cd_price FROM from_bg where " . $prime_sql_text . $warehouse_sql_text . $store_id_sql_text . " (product_price*".$discount_amount."+".$flat_fee." > 0 and product_price*".$discount_amount."+".$flat_fee." < ".$max_price.") and category = '".$main_categ."' and qty > 0 " .$show_in_store . " ORDER BY ".$sort." LIMIT ".$num_results.";" ;
//$sql_text = "SELECT ".$sql_select_string.", product_price*".$discount_amount."+".$flat_fee." as 1cd_price, MATCH(product_name) AGAINST ('+" . $main_categ . "' ) as relevance FROM from_bg where " . $prime_sql_text . $warehouse_sql_text . $store_id_sql_text . $sales_rank_sql_text . $binding_sql_text . $forbidden_items_sql_text . " (product_price*".$discount_amount."+".$flat_fee." > 0 and product_price*".$discount_amount."+".$flat_fee." < ".$max_price.") and MATCH(product_name) AGAINST ('" . $main_categ . "' ) and qty > 0 " .$show_in_store . " ORDER BY relevance DESC, ".$sort." LIMIT ".$num_results."";
//$sql_text = "SELECT ".$sql_select_string.", product_price*".$discount_amount."+".$flat_fee." as 1cd_price, MATCH(last_node) AGAINST ('+" . $main_categ . "' IN BOOLEAN MODE) as relevance FROM from_bg where " . $prime_sql_text . $warehouse_sql_text . $store_id_sql_text . " (product_price*".$discount_amount."+".$flat_fee." > 0 and product_price*".$discount_amount."+".$flat_fee." < ".$max_price.") and MATCH(last_node) AGAINST ('" . $main_categ . "' IN BOOLEAN MODE) and qty > 0 " .$show_in_store . " ORDER BY relevance DESC, ".$sort." LIMIT ".$num_results."";
$sql_text = "SELECT ".$sql_select_string.", product_price*".$discount_amount."+".$flat_fee." as 1cd_price FROM from_bg where " . $prime_sql_text . $warehouse_sql_text . $binding_sql_text . $store_id_sql_text . " (product_price*".$discount_amount."+".$flat_fee." > ".$min_price_rand." and product_price*".$discount_amount."+".$flat_fee." < ".$max_price_rand.") and qty > 0 " .$show_in_store . " LIMIT ".$num_results."";
//ORDER BY rand()
// if (($user_ip == '37.142.221.8' || $user_ip == '31.168.230.226') && 1 == 1) { echo $sql_text; }
$text_text = 'Random Hot Items ...' ;
if ($_GET['test1']) { echo "sql_text show 4" . $sql_text.'
'; }
if ($_GET['test1']) { echo "domain 1" . $domain_1.'
'; }
}
}
////////////
else if ($_GET['search_param'] == "HOMEPAGE" || in_array($_GET['search_param'], $array_categ)) // we will show Daily Deals per main category
{
/* disable $main_categ for now ...
if (in_array($_GET['search_param'], $array_categ)) {$main_categ = $_GET['search_param'];}
else { shuffle($array_categ); $main_categ = $array_categ[0]; } //randomize categ array
$sql_text = "SELECT from_bg.product_name, from_bg.product_sku, from_bg.sub_category, from_bg.brand, from_bg.last_node, from_bg.cat_text, from_bg.image_url0,
from_bg.local_image_url0, from_bg.qty, from_bg.product_price*".$discount_amount."+".$flat_fee." as 1cd_price , daily_deals.deal_discount_off
FROM from_bg inner join daily_deals on from_bg.product_sku = daily_deals.product_sku
where " . $prime_sql_text . $warehouse_sql_text . $store_id_sql_text . " (from_bg.product_price*".$discount_amount."+".$flat_fee." > 0 and from_bg.product_price*".$discount_amount."+".$flat_fee." < ".$max_price.") and from_bg.qty > 0 and from_bg.deleted=0 and category = '" . $main_categ . "' ORDER BY deal_discount_off desc LIMIT ". 1*$num_results. "";
$text_text = $main_categ . ' Daily Deals';
*/
// just do a random search on all daily deals ...
if ($binding_sql_text == '' ) { //
$sql_text = "SELECT from_bg.department, from_bg.product_name, from_bg.product_sku, from_bg.sub_category, from_bg.brand, from_bg.last_node, from_bg.cat_text, from_bg.image_url0,
from_bg.local_image_url0, from_bg.qty, from_bg.product_price*".$discount_amount."+".$flat_fee." as 1cd_price , daily_deals.deal_discount_off
FROM from_bg inner join daily_deals on from_bg.product_sku = daily_deals.product_sku
where " . $prime_sql_text . $warehouse_sql_text . $store_id_sql_text . $sales_rank_sql_text . $binding_sql_text . $forbidden_items_sql_text . " (from_bg.product_price*".$discount_amount."+".$flat_fee." > ".$min_price." and from_bg.product_price*".$discount_amount."+".$flat_fee." < ".$max_price.") and from_bg.qty > 0 and from_bg.deleted=0 ORDER BY RAND() LIMIT ". 1*$num_results. "";
//items with video only
$sql_text = "SELECT from_bg.department, from_bg.product_name, from_bg.product_sku, from_bg.sub_category, from_bg.brand, from_bg.last_node, from_bg.cat_text, from_bg.image_url0,
from_bg.local_image_url0, from_bg.qty, from_bg.product_price*".$discount_amount."+".$flat_fee." as 1cd_price, from_bg_videos.mp4_url
FROM from_bg inner join from_bg_videos on from_bg.product_sku = from_bg_videos.product_sku
where " . $prime_sql_text . $warehouse_sql_text . $store_id_sql_text . $sales_rank_sql_text . $binding_sql_text . $forbidden_items_sql_text . " (from_bg.product_price*".$discount_amount."+".$flat_fee." > ".$min_price_rand." and from_bg.product_price*".$discount_amount."+".$flat_fee." < ".$max_price_rand.") and from_bg.qty > 0 and from_bg.deleted=0 and from_bg_videos.disable = 0 and from_bg_videos.mp4_url <> '' ORDER BY ".$sort." LIMIT ". 1*$num_results. "";
// ORDER BY RAND()
//items with video only
$sql_text = "SELECT from_bg.department, from_bg.product_name, from_bg.product_sku, from_bg.sub_category, from_bg.brand, from_bg.last_node, from_bg.cat_text, from_bg.image_url0,
from_bg.local_image_url0, from_bg.qty, from_bg.product_price*".$discount_amount."+".$flat_fee." as 1cd_price, from_bg_videos.mp4_url
FROM from_bg inner join from_bg_videos on from_bg.product_sku = from_bg_videos.product_sku
where " . $prime_sql_text . $warehouse_sql_text . $store_id_sql_text . $sales_rank_sql_text . $binding_sql_text . $forbidden_items_sql_text . " (from_bg.product_price*".$discount_amount."+".$flat_fee." > ".$min_price_rand." and from_bg.product_price*".$discount_amount."+".$flat_fee." < ".$max_price_rand.") and from_bg.qty > 0 and from_bg.deleted=0 and from_bg_videos.disable = 0 and from_bg_videos.mp4_url <> '' LIMIT ". 1*$num_results. "";
// ORDER BY RAND()
//items with video only and larger savings
$sql_text = "SELECT from_bg.department, from_bg.product_name, from_bg.product_sku, from_bg.sub_category, from_bg.brand, from_bg.last_node, from_bg.cat_text, from_bg.image_url0,
from_bg.local_image_url0, from_bg.qty, from_bg.product_price*".$discount_amount."+".$flat_fee." as 1cd_price, from_bg_videos.mp4_url ,
from_bg_price_used.savingspercent
FROM from_bg inner join from_bg_videos on from_bg.product_sku = from_bg_videos.product_sku
inner join from_bg_price_used on from_bg.product_sku = from_bg_price_used.product_sku
where " . $prime_sql_text . $warehouse_sql_text . $store_id_sql_text . $sales_rank_sql_text . $binding_sql_text . $forbidden_items_sql_text . " (from_bg.product_price*".$discount_amount."+".$flat_fee." > ".$min_price_rand." and from_bg.product_price*".$discount_amount."+".$flat_fee." < ".$max_price_rand.") and from_bg.qty > 0 and from_bg.deleted=0 and from_bg_videos.disable = 0 and from_bg_videos.mp4_url <> '' and from_bg_price_used.savingspercent > 2 order by from_bg_price_used.date_added desc LIMIT ". 1*$num_results. "";
// ORDER BY RAND()
// //items with video only sorted by rating
// $sql_text = "SELECT from_bg.department, from_bg.product_name, from_bg.product_sku, from_bg.sub_category, from_bg.brand, from_bg.last_node, from_bg.cat_text, from_bg.image_url0,
// from_bg.local_image_url0, from_bg.qty, from_bg.product_price*".$discount_amount."+".$flat_fee." as 1cd_price, from_bg_videos.mp4_url
// FROM from_bg inner join from_bg_videos on from_bg.product_sku = from_bg_videos.product_sku inner join customer_reviews_total on from_bg.product_sku = customer_reviews_total.product_sku
// where " . $prime_sql_text . $warehouse_sql_text . $store_id_sql_text . $sales_rank_sql_text . $binding_sql_text . $forbidden_items_sql_text . " (from_bg.product_price*".$discount_amount."+".$flat_fee." > ".$min_price_rand." and from_bg.product_price*".$discount_amount."+".$flat_fee." < ".$max_price_rand.") and from_bg.qty > 0 and from_bg.deleted=0 and from_bg_videos.disable = 0 and from_bg_videos.mp4_url <> '' order by customer_reviews_total.`review_total` desc LIMIT ". 1*$num_results. "";
// // ORDER BY RAND()
// //items with video only - RANDOM ITEMS - SLOW THEN QUESRY ABOVE !!!
// $sql_text = "SELECT from_bg.department, from_bg.product_name, from_bg.product_sku, from_bg.sub_category, from_bg.brand, from_bg.last_node, from_bg.cat_text, from_bg.image_url0,
// from_bg.local_image_url0, from_bg.qty, from_bg.product_price*".$discount_amount."+".$flat_fee." as 1cd_price, from_bg_videos.mp4_url
// FROM from_bg inner join from_bg_videos on from_bg.product_sku = from_bg_videos.product_sku
// where " . $prime_sql_text . $warehouse_sql_text . $store_id_sql_text . $sales_rank_sql_text . $binding_sql_text . $forbidden_items_sql_text . " (from_bg.product_price*".$discount_amount."+".$flat_fee." > ".$min_price." and from_bg.product_price*".$discount_amount."+".$flat_fee." < ".$max_price.") and from_bg.qty > 0 and from_bg.deleted=0 and from_bg_videos.disable = 0 and from_bg_videos.mp4_url <> '' ORDER BY RAND() LIMIT ". 1*$num_results. "";
$item_with_video = true;
}
else if ($binding_sql_text <> '') { // in this case we will not join it with deals ...
// if (strpos($domain_1 , 'pumpsnheels.com') !== false) {$num_results = 16*$num_results;}
//$sql_text = "SELECT from_bg.department, from_bg.product_name, from_bg.product_sku, from_bg.sub_category, from_bg.brand, from_bg.last_node, from_bg.cat_text, from_bg.image_url0, from_bg.local_image_url0, from_bg.qty, from_bg.product_price*".$discount_amount."+".$flat_fee." as 1cd_price FROM from_bg ms_sql_text . " (from_bg.product_price*".$discount_amount."+".$flat_fee." > ".$min_price_rand." and from_bg.product_price*".$discount_amount."+".$flat_fee." < ".$max_price_rand.") and from_bg.qty > 0 and from_bg.deleted=0 LIMIT ". 0.25*$num_results. "";
// ORDER BY RAND()
$sql_text = "SELECT from_bg.department, from_bg.product_name, from_bg.product_sku, from_bg.sub_category, from_bg.brand, from_bg.last_node, from_bg.cat_text, from_bg.image_url0,
from_bg.local_image_url0, from_bg.qty, from_bg.product_price*".$discount_amount."+".$flat_fee." as 1cd_price
FROM from_bg
where " . $prime_sql_text . $warehouse_sql_text . $store_id_sql_text . $sales_rank_sql_text . $binding_sql_text . $forbidden_items_sql_text . " (from_bg.product_price*".$discount_amount."+".$flat_fee." > ".$min_price." and from_bg.product_price*".$discount_amount."+".$flat_fee." < ".$max_price.") and from_bg.qty > 0 and from_bg.deleted=0 ORDER BY RAND() LIMIT ". 1*$num_results. "";
$sql_text = "SELECT from_bg.department, from_bg.product_name, from_bg.product_sku, from_bg.sub_category, from_bg.brand, from_bg.last_node, from_bg.cat_text, from_bg.image_url0,
from_bg.local_image_url0, from_bg.qty, from_bg.product_price*".$discount_amount."+".$flat_fee." as 1cd_price
FROM from_bg
where " . $prime_sql_text . $warehouse_sql_text . $store_id_sql_text . $sales_rank_sql_text . $binding_sql_text . $forbidden_items_sql_text . " (from_bg.product_price*".$discount_amount."+".$flat_fee." > ".$min_price_rand." and from_bg.product_price*".$discount_amount."+".$flat_fee." < ".$max_price_rand.") and from_bg.qty > 0 and from_bg.deleted=0 ORDER BY ".$sort." LIMIT ". 1*$num_results. "";
$sql_text = "SELECT from_bg.department, from_bg.product_name, from_bg.product_sku, from_bg.sub_category, from_bg.brand, from_bg.last_node, from_bg.cat_text, from_bg.image_url0,
from_bg.local_image_url0, from_bg.qty, from_bg.product_price*".$discount_amount."+".$flat_fee." as 1cd_price
FROM from_bg
where " . $prime_sql_text . $warehouse_sql_text . $store_id_sql_text . $sales_rank_sql_text . $binding_sql_text . $forbidden_items_sql_text . " (from_bg.product_price*".$discount_amount."+".$flat_fee." > ".$min_price_rand." and from_bg.product_price*".$discount_amount."+".$flat_fee." < ".$max_price_rand.") and from_bg.qty > 0 and from_bg.deleted=0 LIMIT ". 1*$num_results. "";
}
$reload_more = ' ' . 'Load More... ' . '';
//$text_text = date("F j") . ' - ' .$daily_deals_menu . ' - Upto 70% Off ' . $reload_more;
//$text_text = $daily_deals_menu . ' ' . $reload_more;
$text_text = ' ☆ Daily Deals ☆ ' . $reload_more;
//echo $sql_text;
if ($_GET['test1']) { echo "sql_text show 1" . $sql_text.'
'; }
}
else if ($_GET['search_param'] == "My History Items" && isset($_COOKIE["email_cookie"])) // we will show history items for that customer
{
// just do a random search on all daily deals ...
$sql_text = "SELECT from_bg.department, from_bg.product_name, from_bg.product_sku, from_bg.sub_category, from_bg.brand, from_bg.last_node, from_bg.cat_text, from_bg.image_url0,
from_bg.local_image_url0, from_bg.qty, from_bg.product_price*".$discount_amount."+".$flat_fee." as 1cd_price
FROM from_bg inner join viewed_items_customer on from_bg.product_sku = viewed_items_customer.item_sku
where " . $prime_sql_text . $warehouse_sql_text . $store_id_sql_text . $sales_rank_sql_text . $binding_sql_text . $forbidden_items_sql_text . " (from_bg.product_price*".$discount_amount."+".$flat_fee." > ".$min_price." and from_bg.product_price*".$discount_amount."+".$flat_fee." < ".$max_price.") and from_bg.qty > 0 and from_bg.deleted=0 and viewed_items_customer.email = '".$_COOKIE["email_cookie"]."' ORDER BY viewed_items_customer.create_date DESC LIMIT ". 1*$num_results. "";
$text_text = 'My History Items';
//echo $sql_text;
if ($_GET['test1']) { echo "sql_text show 2" . $sql_text.'
'; }
}
else if ($_GET['search_param'] == "Watched Items" && isset($_COOKIE["shopper_cookie"])) // we will show Viewed items for that visitor
{
// just do a random search on all daily deals ...
$sql_text = "SELECT from_bg.department, from_bg.product_name, from_bg.product_sku, from_bg.sub_category, from_bg.brand, from_bg.last_node, from_bg.cat_text, from_bg.image_url0,
from_bg.local_image_url0, from_bg.qty, from_bg.product_price*".$discount_amount."+".$flat_fee." as 1cd_price
FROM from_bg inner join visitors on from_bg.product_sku = visitors.sku
where " . $prime_sql_text . $warehouse_sql_text . $store_id_sql_text . $sales_rank_sql_text . $binding_sql_text . $forbidden_items_sql_text . " (from_bg.product_price*".$discount_amount."+".$flat_fee." > ".$min_price." and from_bg.product_price*".$discount_amount."+".$flat_fee." < ".$max_price.") and from_bg.qty > 0 and from_bg.deleted=0 and visitors.cookie_id = '".$_COOKIE["shopper_cookie"]."' ORDER BY visitors.date_time DESC LIMIT ". 1*$num_results. "";
$text_text = 'Watched Items';
//echo $sql_text; exit;
if ($_GET['test1']) { echo "sql_text show 3" . $sql_text.'
'; }
}
if ($sql_text == '' )
{
//$limit_products = ".$num_results.";
/*
$search_param = mysqli_real_escape_string($con,$search_param);
$sql_text = "SELECT ".$sql_select_string.", product_price*".$discount_amount."+".$flat_fee." as 1cd_price
FROM from_bg
where " . $prime_sql_text . $warehouse_sql_text . $store_id_sql_text . $sales_rank_sql_text . " (product_price*".$discount_amount."+".$flat_fee." > 0 and product_price*".$discount_amount."+".$flat_fee." < ".$max_price.") and MATCH(product_name) AGAINST ('" . $search_param . "') and qty > 0 " .$show_in_store . " LIMIT ".$num_results."";
*/
/*
$sql_text = "SELECT from_bg.product_name, from_bg.product_sku, from_bg.sub_category, from_bg.brand, from_bg.last_node, from_bg.cat_text, from_bg.image_url0,
from_bg.local_image_url0, from_bg.qty, from_bg.product_price*".$discount_amount."+".$flat_fee." as 1cd_price , daily_deals.deal_discount_off
FROM from_bg inner join daily_deals on from_bg.product_sku = daily_deals.product_sku
where " . $prime_sql_text . $warehouse_sql_text . $store_id_sql_text . $sales_rank_sql_text . " (from_bg.product_price*".$discount_amount."+".$flat_fee." > 0 and from_bg.product_price*".$discount_amount."+".$flat_fee." < ".$max_price.") and from_bg.qty > 0 and from_bg.deleted=0 ORDER BY RAND() LIMIT ". 1*$num_results. "";
*/
$sql_text = "";
$text_text = $search_param ;
}
}
else { $search_param = 'SORRY ... NOTHING TO SHOW HERE';}
if ($_GET['test1']) { echo $sql_text ; }
if ($sql_text <> '' && $run_sql == true) {
$result = mysqli_query($con, $sql_text);
//echo $sql_text ;
}
$counter = 0;
?>
'') {
$array_image_url0[] = $row['image_url0'];
$array_items[] = $row; }
}
//save unique brands for this search
if (!in_array($row['brand'], $array_brand) && $row['brand'] <>'') {
$array_brand[] = $row['brand']; }
//save unique last node category for this search
if (!in_array($row['last_node'], $array_last_node) && $row['last_node'] <>'') {
$array_last_node[] = $row['last_node']; }
//save unique last node category for this search
if (!in_array($row['cat_text'], $array_cat_text) && $row['cat_text'] <>'' && str_replace(">","",str_replace(" ","",$row['cat_text'])) <>'') {
$array_cat_text[] = $row['cat_text']; }
//save unique department ( gender ) for this search
if (!in_array( strtolower($row['department']), $array_department) && $row['department'] <>'') {
$array_department[] = strtolower($row['department']); }
if (isset($row['color'])) {
//save unique department ( gender ) for this search
if (!in_array($row['color'], $array_color) && $row['color'] <>'') {
$array_color[] = $row['color']; }
}
if (isset($row['clothing_size'])) {
//save unique department ( gender ) for this search
if (!in_array($row['clothing_size'], $array_clothing_size) && $row['clothing_size'] <>'') {
$array_clothing_size[] = $row['clothing_size']; }
}
}
}
sort($array_last_node);
sort($array_cat_text);
sort($array_brand);
?>
1 && 1==0) {
include "simple_html_dom.php";
$search_query = $search_param;
$search_query = urlencode( $search_query );
//echo $html ;
if (file_get_html("https://www.google.com/search?q=$search_query&tbm=isch" )) {
$html = file_get_html("https://www.google.com/search?q=$search_query&tbm=isch" );
$image_container = $html->find('div#ires', 0);
$images = $image_container->find('img');
//echo $images[0] ;
$image_count = 4; //Enter the amount of images to be shown on mobile
if ( !$detect->isMobile()) {
//Enter the amount of images to be shown on non mobile
$image_count = 14; }
$i = 0; ?>