func_code = "product"; $func_title = array ( 'tw' => '產品專區', 'cn' => '产品专区', 'en' => 'Products', ); $CFG->func_title = $func_title[$CFG->lang]; //定義資料表 $CFG->table_name = $CFG->table_prefix."product"; $CFG->table_type = $CFG->table_prefix."product_type"; $CFG->table_image = $CFG->table_prefix."product_image"; $CFG->table_spec = $CFG->table_prefix."product_spec"; $CFG->table_size = $CFG->table_prefix."product_size"; //預設分頁 $CFG->page_limit = 12; // ---------------------------------------------------------------------------- // 主判斷式 // ---------------------------------------------------------------------------- if ($_REQUEST["mode"]) { $_REQUEST["mode"]($_REQUEST); } else { $_SESSION['web']['back_url'] = $CFG->this_url; show($_REQUEST); } // 主判斷式結束 // ---------------------------------------------------------------------------- // 函式集 // ---------------------------------------------------------------------------- function show($frm) { global $CFG,$WFunc,$UFunc; $new_query_string = "SELECT * FROM $CFG->table_name WHERE status = '1' ORDER BY id DESC LIMIT 4"; $new_db_result = mysql_query($new_query_string); $hot_query_string = "SELECT * FROM $CFG->table_name WHERE status = '1' ORDER BY counts DESC LIMIT 8"; $hot_db_result = mysql_query($hot_query_string); #################################################################### # 載入樣板 #################################################################### // 頁首 !$_REQUEST['pjax'] ? include ($CFG->themes."header.php") : false; include ($CFG->lib."funcs/header_func.php"); // 畫面 include ("themes/$CFG->lang/type_list.php"); // 頁尾 !$_REQUEST['pjax'] ? include ($CFG->themes."footer.php") : false; } function list_show($frm) { global $CFG,$WFunc,$UFunc; $first_query_string = "SELECT * FROM $CFG->table_type WHERE status = '1' AND parent_id = '0' AND lang = '$CFG->lang' ORDER BY sequence ASC"; $first_db_result = mysql_query($first_query_string); $first_result = mysql_fetch_assoc($first_db_result); $limit_end = $CFG->page_limit; //每頁顯示數量 if (!$frm['page']) { $frm['page'] = 1; } //處理分頁 if ($frm['page'] == 1) { $limit_start = $frm['page'] - 1; } else { $limit_start = ($frm['page'] - 1) * $limit_end; } if ($frm['keyword']) { $keyword_string = "AND name LIKE '%$frm[keyword]%'"; } if (!$frm['main_id']) { $frm['main_id'] = 0; } if (!$frm['type_id']) { $frm['type_id'] = 0; } if ($frm['main_id'] && !$frm['type_id']) { $keyword_string .= "AND main_id = '$frm[main_id]'"; } if ($frm['main_id'] && $frm['type_id']) { $keyword_string .= "AND type_id = '$frm[type_id]'"; } $query_string = "SELECT * FROM $CFG->table_name WHERE status = '1' AND lang = '$CFG->lang' $keyword_string ORDER BY id ASC"; $limir_string = " LIMIT $limit_start,$limit_end"; $db_result = mysql_query($query_string.$limir_string); /* 資料分頁 */ $total_result = mysql_query($query_string); $total = mysql_num_rows($total_result); if ($total % $CFG->page_limit != 0) { $total_page = intval($total / $CFG->page_limit + 1); } else { $total_page = intval($total / $CFG->page_limit); } $page_start = 1; //第一頁 if ($total % $limit_end == 0) { $page_last = $total / $limit_end; } else { $page_last = intval($total / $limit_end) + 1; } $page_back = $frm['page'] - 1; $page_next = $frm['page'] + 1; if ($page_next > $page_last) { $page_next = 0; } #################################################################### # 載入樣板 #################################################################### // 頁首 !$_REQUEST['pjax'] ? include ($CFG->themes."header.php") : false; include ($CFG->lib."funcs/header_func.php"); // 畫面 include ("themes/$CFG->lang/list.php"); // 頁尾 !$_REQUEST['pjax'] ? include ($CFG->themes."footer.php") : false; } function detail($frm) { global $CFG,$WFunc,$UFunc; $query_string = "SELECT * FROM $CFG->table_name WHERE id = '$frm[id]'"; $db_result = mysql_query($query_string); $result = mysql_fetch_assoc($db_result); //取得圖片 $image_query_string = "SELECT * FROM $CFG->table_image WHERE product_id = '$frm[id]' ORDER BY id ASC"; $image_db_result = mysql_query($image_query_string); while ($image_result = mysql_fetch_assoc($image_db_result)) { $image_array[] = $image_result; } $WFunc->unset_cookie('lang'); $WFunc->set_cookie("lang", $result['lang'], time()+3600*24*365); // 上一則 $last_query_string = "SELECT * FROM $CFG->table_name WHERE id < '$result[id]' AND type_id = '$result[type_id]' AND status = '1' AND lang = '$CFG->lang' ORDER BY id DESC"; $last_db_result = mysql_query($last_query_string); $last_result = mysql_fetch_assoc($last_db_result); // 下一則 $next_query_string = "SELECT * FROM $CFG->table_name WHERE id > '$result[id]' AND type_id = '$result[type_id]' AND status = '1' AND lang = '$CFG->lang' ORDER BY id ASC"; $next_db_result = mysql_query($next_query_string); $next_result = mysql_fetch_assoc($next_db_result); $field = array ( 'counts' => $result['counts'] + 1, ); $update_string = $WFunc->sql_update_string($CFG->table_name,$field,"id = '$frm[id]'"); mysql_query($update_string); $CFG->func_title = $result['name'].' - '.$CFG->func_title; #################################################################### # 載入樣板 #################################################################### // 頁首 !$_REQUEST['pjax'] ? include ($CFG->themes."header.php") : false; include ($CFG->lib."funcs/header_func.php"); // 畫面 include ("themes/$CFG->lang/detail.php"); // 頁尾 !$_REQUEST['pjax'] ? include ($CFG->themes."footer.php") : false; } function ajx_order($frm) { global $CFG,$WFunc,$UFunc; $query_string = "SELECT * FROM $CFG->table_name WHERE id = '$frm[product_id]'"; $db_result = mysql_query($query_string); $result = mysql_fetch_assoc($db_result); $spec_query_string = "SELECT * FROM $CFG->table_spec WHERE product_id = '$frm[product_id]' AND status = '1'"; $spec_db_result = mysql_query($spec_query_string); #################################################################### # 載入樣板 #################################################################### // 畫面 include ("themes/$CFG->lang/ajx_order.php"); } function ajax_change_size($frm) { global $CFG,$WFunc,$UFunc; $product_id = $frm['product_id']; $spec_id = $frm['spec_id']; $query_string = "SELECT * FROM $CFG->table_size WHERE spec_id = '$spec_id' AND product_id = '$product_id' AND status = '1'"; $db_result = mysql_query($query_string); include ("themes/$CFG->lang/ajax_size.php"); } function ajax_size_stock($frm) { global $CFG,$WFunc,$UFunc; $product_id = $frm['product_id']; $spec_id = $frm['spec_id']; $size_id = $frm['size_id']; $query_string = "SELECT * FROM $CFG->table_size WHERE id = '$size_id' AND status = '1'"; $db_result = mysql_query($query_string); $result = mysql_fetch_assoc($db_result); echo $result['stock']; } function get_type_name($type_id) { global $CFG,$WFunc,$UFunc; $query_string = "SELECT * FROM $CFG->table_type WHERE id = '$type_id'"; $db_result = mysql_query($query_string); $result = mysql_fetch_assoc($db_result); return $result['name']; } function get_deputy_image($product_id) { global $CFG,$WFunc,$UFunc; $query_string = "SELECT * FROM $CFG->table_image WHERE product_id = '$product_id' ORDER BY id ASC LIMIT 1"; $db_result = mysql_query($query_string); $result = mysql_fetch_assoc($db_result); if ($result) { $image = "/archive/product/normal/".$result['image']; } else { $image = '/images/pro_pic06.jpg'; } return $image; } function get_product_value($product_id) { global $CFG,$WFunc,$UFunc; $query_string = "SELECT * FROM $CFG->table_name WHERE id = '$product_id' ORDER BY id ASC"; $db_result = mysql_query($query_string); $result = mysql_fetch_assoc($db_result); return $result; } function get_type_image($type_id) { global $CFG,$WFunc,$UFunc; $query_string = "SELECT * FROM $CFG->table_type WHERE id = '$type_id'"; $db_result = mysql_query($query_string); $result = mysql_fetch_assoc($db_result); $product_query_string = "SELECT * FROM $CFG->table_name WHERE main_id = '$result[id]'"; $product_db_result = mysql_query($product_query_string); $product_result = mysql_fetch_assoc($product_db_result); $image_query_string = "SELECT * FROM $CFG->table_image WHERE product_id = '$product_result[id]'"; $image_db_result = mysql_query($image_query_string); return $image_db_result; } function get_product_name($product_id) { global $CFG,$WFunc,$UFunc; $query_string = "SELECT * FROM $CFG->table_name WHERE id = '$product_id'"; $db_result = mysql_query($query_string); $result = mysql_fetch_assoc($db_result); return $result['name']; } function get_spec_name($spec_id) { global $CFG,$WFunc,$UFunc; $query_string = "SELECT * FROM $CFG->table_spec WHERE id = '$spec_id'"; $db_result = mysql_query($query_string); $result = mysql_fetch_assoc($db_result); return $result['name']; } function get_size_name($size_id) { global $CFG,$WFunc,$UFunc; $query_string = "SELECT * FROM $CFG->table_size WHERE id = '$size_id'"; $db_result = mysql_query($query_string); $result = mysql_fetch_assoc($db_result); return $result['name']; } ?>