/*************************************\
BIDBUY SCRIPT - by RWEBWORKS
Copyright(c) Rwebworks.com (2008)
http://www.rwebworks.com
\*************************************/
session_start();
define ('IN_SITE', 1);
include_once ('includes/global.php');
include_once ('global_header.php');
(array) $query = null;
$parent_id = intval($_REQUEST['parent_id']);
$advanced_search = ($_REQUEST['advanced_search'] == '') ? 1 : intval($_REQUEST['advanced_search']);
$template->set('parent_id', $parent_id);
define('IS_CATEGORIES', 1);
//$template->set('db', $db);
(string) $subcategories_content = null;
$main_category_id = $db->main_category($parent_id);
$category_details = $db->get_sql_row("SELECT image_path, minimum_age FROM " . DB_PREFIX . "categories WHERE category_id='" . $main_category_id . "' order by name");
$category_logo = $category_details['image_path'];
$category_logo = (!empty($category_logo)) ? '
' : '';
$template->set('category_logo', $category_logo);
$categories_header_menu = all_category_navigator($parent_id, true, true, 'view_all_categories.php');
$template->set('categories_header_menu', $categories_header_menu);
if ($_REQUEST['option'] == 'agree_adult')
{
$session->set('adult_category', 1);
}
if ($category_details['minimum_age'] > 0 && !$session->value('adult_category'))
{
$template->set('minimum_age', $category_details['minimum_age']);
$template_output .= $template->process('adult_category_warning.tpl.php');
}
else
{
$mod_count = 0;
$is_subcategories = $db->count_rows('categories', "WHERE parent_id='" . $parent_id . "'");
$template->set('is_subcategories', $is_subcategories);
$sql_select_categories = $db->query("SELECT category_id, items_counter FROM " . DB_PREFIX . "categories WHERE
parent_id='" . $parent_id . "' AND user_id=0 ORDER BY name ASC");
$outer_cnt = 0;
while ($cat_details = $db->fetch_array($sql_select_categories))
{
$background = ($counter++%4) ? 'c1' : 'c2';
if( ($outer_cnt % 2) == 0)
{
$subcategories_content .= '
';
$subcategories_content .= ' » ' . $category_lang[$cat_details['category_id']] . ' '.
(($setts['enable_cat_counters']) ? (($cat_details['items_counter']) ? '(' . $cat_details['items_counter'] . ')' : '') : '') . ' | ';
$subcategories_content .= ' ';
// for subcategory - 1
$cat_id = $cat_details['category_id'];
$q = "select * from " . DB_PREFIX . "categories where parent_id = $cat_id order by order_id asc";
$res = mysql_query($q);
$num1 = mysql_num_rows($res);
$subcategories_content .= ' ' ;
$subcategories_content .= ' ';
$sub_cnt = 0;
while($row = mysql_fetch_array($res))
{
$sub_cnt ++;
if($sub_cnt > 2)
break;
$cat_id = $row["category_id"];
$val = $row["name"];
$len = count($val);
$subcategories_content .= ' ' . $val . ' ';
}
if($num1 >= 1)
{
$subcategories_content .= 'mai multe...';
}
$subcategories_content .= ' | '; // inner table
$subcategories_content .= ' | | '; // outer table
}
else
{
$subcategories_content .= ' ';
$subcategories_content .= ' » ' . $category_lang[$cat_details['category_id']] . ' '.
(($setts['enable_cat_counters']) ? (($cat_details['items_counter']) ? '(' . $cat_details['items_counter'] . ')' : '') : '') . ' | ';
$subcategories_content .= ' ';
// for subcategory - 1
$cat_id = $cat_details['category_id'];
$q = "select * from " . DB_PREFIX . "categories where parent_id = $cat_id order by order_id asc";
$res = mysql_query($q);
$num1 = mysql_num_rows($res);
$subcategories_content .= ' ' ;
$subcategories_content .= ' ';
$sub_cnt = 0;
while($row = mysql_fetch_array($res))
{
$sub_cnt ++;
if($sub_cnt > 2)
break;
$cat_id = $row["category_id"];
$val = $row["name"];
$len = count($val);
$subcategories_content .= ' ' . $val . ' ';
}
if($num1 >= 1)
{
$subcategories_content .= 'mai multe...';
}
$subcategories_content .= ' | '; // inner table
$subcategories_content .= ' | | '; // outer table
$subcategories_content .= '
';
}
$outer_cnt++;
/* $subcategories_content .= ' ';
$subcategories_content .= ' » ' . $category_lang[$cat_details['category_id']] . ' '.
(($setts['enable_cat_counters']) ? (($cat_details['items_counter']) ? '(' . $cat_details['items_counter'] . ')' : '') : '') . ' | ';
$subcategories_content .= ' ';
// for subcategory -1
$cat_id = $cat_details['category_id'];
$q = "select * from " . DB_PREFIX . "categories where parent_id = $cat_id order by order_id asc";
$res = mysql_query($q);
$subcategories_content .= ' ' ;
$sub_cnt = 0;
while($row = mysql_fetch_array($res))
{
$sub_cnt ++;
if($sub_cnt > 3)
break;
$cat_id = $row["category_id"];
$val = $row["name"];
$len = count($val);
$subcategories_content .= ' ' . $val . ' ';
}
$subcategories_content .= '....';
$subcategories_content .= ' | ';
$subcategories_content .= ' |
'; // inner table
$subcategories_content .= '';
$subcategories_content .= '';
$outer_cnt++; */
}//outer whiie
$template->set('subcategories_content', $subcategories_content);
if ($parent_id)
{
(array) $src_cats = null;
(string) $category_name = null;
reset($categories_array);
foreach ($categories_array as $key => $value)
{
if ($parent_id == $key)
{
list($category_name, $tmp_user_id) = $value;
}
}
reset($categories_array);
while (list($cat_array_id, $cat_array_details) = each($categories_array))
{
list($cat_array_name, $cat_user_id) = $cat_array_details;
$categories_match = strpos($cat_array_name, $category_name);
if (trim($categories_match) == "0")
{
$src_cats[] = $cat_array_id;
}
$all_subcategories = $db->implode_array($src_cats, ', ');
}
$query[] = "(a.category_id IN (" . $all_subcategories . ") OR a.addl_category_id IN (" . $all_subcategories . "))";
}
$item_details = $db->rem_special_chars_array($_REQUEST);
if ($_REQUEST['buyout_price'] == 1)
{
$query[] = "a.buyout_price>0";
}
if ($_REQUEST['reserve_price'] == 1)
{
$query[] = "a.reserve_price>0";
}
if ($_REQUEST['quantity_standard'] == 1)
{
$query[] = "a.quantity=1";
}
if ($_REQUEST['quantity'] == 1)
{
$query[] = "a.quantity>1";
}
if ($_REQUEST['enable_swap'] == 1)
{
$query[] = "a.enable_swap=1";
}
if ($_REQUEST['direct_payment_only'] == 1)
{
$query[] = "a.direct_payment!=''";
}
if ($_REQUEST['regular_payment_only'] == 1)
{
$query[] = "a.payment_methods!=''";
}
$addl_where_query = $db->implode_array($query, ' AND ');
$addl_where_query = (!empty($addl_where_query)) ? ' AND ' . $addl_where_query : '';## PHP Pro Bid v6.00 search in category procedure
$option = 'category_search';
$template->set('option', $option);
$template->set('advanced_search', $advanced_search);
if (!empty($_REQUEST['keywords_cat_search']))
{
$addl_where_query .= " AND MATCH (a.name, a.description) AGAINST ('" . $item_details['keywords_cat_search'] . "*' IN BOOLEAN MODE)";
/**
* or the old and SLOW search using LIKE - disabled by default, just added the line in case
* anyone might want to use this instead
*/## PHP Pro Bid v6.00 $addl_store_query = " AND (a.name LIKE '%" . $item_details['keywords_cat_search'] . "%' OR a.description LIKE '%" . $item_details['keywords_cat_search'] . "%')";
}
$template->set('item_details', $item_details);
$cats_src_drop_down = '';
$cats_src_adv_search_link = ($advanced_search) ? '' . MSG_BASIC_SEARCH . '' :
'' . MSG_ADVANCED_SEARCH . '';
$template->set('cats_src_adv_search_link', '[ ' . $cats_src_adv_search_link . ' ]');
$template->set('cats_src_drop_down', $cats_src_drop_down);
$template->set('search_options_title', MSG_SEARCH_IN_THIS_CATEGORY);
$categories_search_box = $template->process('search.tpl.php');
$template->set('categories_search_box', $categories_search_box);
/**
* featured items, recently listed and ending soon code
*/
if ($layout['catfeat_nb'])
{
(array) $item_details = null;
$select_condition = "WHERE a.active=1 AND a.approved=1 AND a.closed=0 AND a.deleted=0
AND a.list_in!='store' AND a.catfeat='1'" . $addl_where_query;
$template->set('featured_columns', min((floor($db->count_rows('auctions a', $select_condition)/$layout['catfeat_nb']) + 1), ceil($layout['catfeat_max']/$layout['catfeat_nb'])));
$item_details = $db->random_rows('auctions a', 'a.auction_id, a.name, a.start_price, a.max_bid, a.currency, a.end_time', $select_condition, $layout['catfeat_max']);
$template->set('item_details', $item_details);
}
/**
* shop in stores code snippet
*/
if ($parent_id)
{
$sql_select_stores = $db->query("SELECT u.user_id, u.shop_name FROM
" . DB_PREFIX . "users u, " . DB_PREFIX . "auctions a WHERE a.active=1 AND a.approved=1
AND a.closed=0 AND a.deleted=0 AND a.list_in!='auction'" . $addl_where_query . " AND
a.owner_id=u.user_id AND u.active='1' AND u.shop_active='1' GROUP BY u.user_id");
$is_shop_stores = $db->num_rows($sql_select_stores);
$template->set('is_shop_stores', $is_shop_stores);
if ($is_shop_stores)
{
(string) $shop_stores_content = null;
while ($store_details = $db->fetch_array($sql_select_stores))
{
$background = ($counter++%2) ? 'c1' : 'c2';
$shop_stores_content .= ' '.
' » ' . $store_details['shop_name'] . ' | '.
'
';
}
$template->set('shop_stores_content', $shop_stores_content);
}
}
$categories_header .= $template->process('all_categories_header.tpl.php');
$categories_footer = $template->process('categories_footer.tpl.php');
/**
* below we have the variables that need to be declared in each separate browse page
*/
$page_url = 'view_all_categories';
$form_search_proceed = $_REQUEST["form_search_proceed"];
if(!empty($form_search_proceed))
{
(array) $query = null;
$keywords_search = trim($_REQUEST["keywords_search"]);
if(!empty($keywords_search))
{
//$query[] = "MATCH (a.name, a.description) AGAINST ('*" . $keywords_search . "*' IN BOOLEAN MODE)";
$query[] = "(a.name LIKE '%" . $keywords_search . "%' OR a.description LIKE '%" . $keywords_search . "%')";
}
$min_price = $_REQUEST["min_price"];
$max_price = $_REQUEST["max_price"];
if(!empty($min_price) && !empty($max_price))
{
$query[] = "a.start_price BETWEEN '$min_price' AND '$max_price'";
}
$buyout_price = $_REQUEST["buyout_price"];
if($buyout_price == 1)
{
$query[] = "a.buyout_price>0";
}
$fpay = $_REQUEST["fpay"];
if ($fpay == 1)
{
$fpaym = $_REQUEST["fpaym"];
$query[] = "a.direct_payment = $fpaym";
}//payment
$free_shipping = $_REQUEST["free_shipping"];
if ($free_shipping == 1)
{
$query[] = "a.shipping_method = 2";
}
$item_condition = $_REQUEST["item_condition"];
if ($item_condition == 1)
{
$item_condition_values = $_REQUEST['item_condition_values'];
if($item_condition_values == "Nou")
$query[] = "a.it_condition = 'Nou'";
else
$query[] = "a.it_condition = 'Folosit'";
}
$zip_code = $_REQUEST["zip_code"];
if(!empty($zip_code))
$query[] = "a.zip_code = '$zip_code'";
$city = $_REQUEST["city"];
if(!empty($city))
{
$query[] = "a.state=$city";
}
////// for category //////////////////////////////////////////////////////////
$cat_mode = $_REQUEST["cat_mode"];
if(!empty($cat_mode))
{
(array) $src_cats = null;
(string) $category_name = null;
reset($categories_array);
foreach ($categories_array as $key => $value)
{
if ($cat_mode == $key)
list($category_name, $tmp_user_id) = $value;
}
reset($categories_array);
while (list($cat_array_id, $cat_array_details) = each($categories_array))
{
list($cat_array_name, $cat_user_id) = $cat_array_details;
$categories_match = strpos($cat_array_name, $category_name);
if (trim($categories_match) == "0")
$src_cats[] = $cat_array_id;
$all_subcategories = $db->implode_array($src_cats, ', ');
}
$query[] = "(a.category_id IN (" . $all_subcategories . ") OR a.addl_category_id IN (" . $all_subcategories . "))";
}
//////////////////////////////////////////////////////////////////////////////
if (count($query))
$addl_query = " AND " . $db->implode_array($query, ' AND ');
$where_query = "WHERE a.active=1 AND a.approved=1 AND a.closed=0 AND a.deleted=0 AND
a.list_in!='store' AND a.creation_in_progress=0" . $addl_query . $addl_where_query;
$order_field = ($_REQUEST['order_field']) ? $_REQUEST['order_field'] : 'a.end_time';
$order_type = ($_REQUEST['order_type']) ? $_REQUEST['order_type'] : 'ASC';
$additional_vars = '&parent_id=' . $parent_id . '&keywords_cat_search=' . $_REQUEST['keywords_cat_search'] .
'&buyout_price=' . $_REQUEST['buyout_price'] . '&reserve_price=' . $_REQUEST['reserve_price'] .
'&quantity=' . $_REQUEST['quantity'] . '&enable_swap=' . $_REQUEST['enable_swap'];
}///left side search button click
else
{
$where_query = "WHERE a.active=1 AND a.approved=1 AND a.closed=0 AND a.deleted=0 AND
a.list_in!='store' AND a.creation_in_progress=0" . $addl_where_query;
$order_field = ($_REQUEST['order_field']) ? $_REQUEST['order_field'] : 'a.end_time';
$order_type = ($_REQUEST['order_type']) ? $_REQUEST['order_type'] : 'ASC';
$additional_vars = '&parent_id=' . $parent_id . '&keywords_cat_search=' . $_REQUEST['keywords_cat_search'] .
'&buyout_price=' . $_REQUEST['buyout_price'] . '&reserve_price=' . $_REQUEST['reserve_price'] .
'&quantity=' . $_REQUEST['quantity'] . '&enable_swap=' . $_REQUEST['enable_swap'];
}
$template->set('categories_header', $categories_header);
$template->set('categories_footer', $categories_footer);
include_once('includes/page_browse_auctions.php');
}
include_once ('global_footer.php');
echo $template_output;
?>