-
Notifications
You must be signed in to change notification settings - Fork 8
/
goods.php
54 lines (43 loc) · 1.46 KB
/
goods.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
define('PERMISSION',true);
//定义一个变量为true,然后在“禁止用户直接地址栏访问的文件”里检测该变量,
//如果检测不到该变量则判断为非法访问该文件。
//conntroller都define(定义常量)
//非conntroller都defined(检验常量)
require('./include/init.php');
$goods_id = isset($_GET['goods_id'])?$_GET['goods_id']+0:0;
//查询商品信息
$goods = new GoodsModel();
$good = $goods->find($goods_id);
if(empty($good)){
header('location: index.php');
exit;
}
$cat = new CatModel();
//取出树状导航
$cats = $cat->select();//获取所有栏目
$sort = $cat->getCatTree($cats,0,1);//排序
//取出面包屑导航
$cat_id = $good['cat_id'];
$addr = $cat->getTree($cat_id);
//商品浏览历史
if(!isset($_SESSION['history_goods'][0])){
array_unshift($_SESSION['history_goods'],array(
'goods_id'=>$goods_id,
'goods_name'=>$good['goods_name'],
'shop_price'=>$good['shop_price'],
'thumb_img'=>$good['thumb_img'],''));
}else{
if($_SESSION['history_goods'][0]['goods_id']!=$goods_id){
if(count($_SESSION['history_goods'])==5){
array_pop($_SESSION['history_goods']);
}
array_unshift($_SESSION['history_goods'],array(
'goods_id'=>$goods_id,
'goods_name'=>$good['goods_name'],
'shop_price'=>$good['shop_price'],
'thumb_img'=>$good['thumb_img'],''));
}
}
include(ROOT.'./view/front/shangpin.html');
?>