代码拉取完成,页面将自动刷新
<?php
/**
* ECSHOP 商品详情
* ============================================================================
* * 版权所有 2005-2012 上海商派网络科技有限公司,并保留所有权利。
* 网站地址: http://www.ecshop.com;
* ----------------------------------------------------------------------------
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
* 使用;不允许对程序代码以任何形式任何目的的再发布。
* ============================================================================
* $Author: liubo $
* $Id: goods.php 17217 2011-01-19 06:29:08Z liubo $
*/
define('IN_ECS', true);
require(dirname(__FILE__) . '/includes/init.php');
if ((DEBUG_MODE & 2) != 2)
{
$smarty->caching = true;
}
$affiliate = unserialize($GLOBALS['_CFG']['affiliate']);
$smarty->assign('affiliate', $affiliate);
/*------------------------------------------------------ */
//-- INPUT
/*------------------------------------------------------ */
$goods_id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
/*------------------------------------------------------ */
//-- PROCESSOR
/*------------------------------------------------------ */
$cache_id = $goods_id . '-' . $_SESSION['user_rank'].'-'.$_CFG['lang'];
$cache_id = sprintf('%X', crc32($cache_id));
if (!$smarty->is_cached('goods.dwt', $cache_id))
{
$smarty->assign('image_width', $_CFG['image_width']);
$smarty->assign('image_height', $_CFG['image_height']);
$smarty->assign('id', $goods_id);
$smarty->assign('type', 0);
$smarty->assign('cfg', $_CFG);
$smarty->assign('promotion', get_promotion_info($goods_id));//促销信息
$smarty->assign('promotion_info', get_promotion_info());
/* 获得商品的信息 */
$goods = get_goods_info($goods_id);
if ($goods === false)
{
/* 如果没有找到任何记录则跳回到首页 */
ecs_header("Location: ./\n");
exit;
}
else
{
assign_template('c', $catlist);
if ($goods['brand_id'] > 0)
{
$goods['goods_brand_url'] = build_uri('brand', array('bid'=>$goods['brand_id']), $goods['goods_brand']);
}
$shop_price = $goods['shop_price'];
$linked_goods = get_linked_goods($goods_id); //关联商品
$goods['goods_style_name'] = add_style($goods['goods_name'], $goods['goods_name_style']);
/* 购买该商品可以得到多少钱的红包 */
if ($goods['bonus_type_id'] > 0)
{
$time = gmtime();
$sql = "SELECT type_money FROM " . $ecs->table('bonus_type') .
" WHERE type_id = '$goods[bonus_type_id]' " .
" AND send_type = '" . SEND_BY_GOODS . "' " .
" AND send_start_date <= '$time'" .
" AND send_end_date >= '$time'";
$goods['bonus_money'] = floatval($db->getOne($sql));
if ($goods['bonus_money'] > 0)
{
$goods['bonus_money'] = price_format($goods['bonus_money']);
}
}
$smarty->assign('goods', $goods);
$smarty->assign('goods_id', $goods['goods_id']);
$smarty->assign('promote_end_time', $goods['gmt_end_time']);
$smarty->assign('categories', get_categories_tree($goods['cat_id'])); // 分类树
/* meta */
$smarty->assign('keywords', htmlspecialchars($goods['keywords']));
$smarty->assign('description', htmlspecialchars($goods['goods_brief']));
$position = assign_ur_here($goods['cat_id'], $goods['goods_name']);
/* current position */
$smarty->assign('page_title', $position['title']); // 页面标题
$smarty->assign('ur_here', $position['ur_here']); // 当前位置
$properties = get_goods_properties($goods_id); // 获得商品的规格和属性
$smarty->assign('properties', $properties['pro']); // 商品属性
$smarty->assign('specification', $properties['spe']); // 商品规格
$smarty->assign('pictures', get_goods_gallery($goods_id)); // 商品相册
$smarty->assign('related_goods', $linked_goods); // 关联商品
//获取tag
$tag_array = get_tags($goods_id);
$smarty->assign('tags', $tag_array); // 商品的标记
assign_dynamic('goods');
}
}
$smarty->display('goods.dwt', $cache_id);
/**
* 获得指定商品的关联商品
*
* @access public
* @param integer $goods_id
* @return array
*/
function get_linked_goods($goods_id)
{
$sql = 'SELECT g.goods_id, g.goods_name, g.goods_thumb, g.goods_img, g.shop_price AS org_price, ' .
"IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, ".
'g.market_price, g.promote_price, g.promote_start_date, g.promote_end_date ' .
'FROM ' . $GLOBALS['ecs']->table('link_goods') . ' lg ' .
'LEFT JOIN ' . $GLOBALS['ecs']->table('goods') . ' AS g ON g.goods_id = lg.link_goods_id ' .
"LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp ".
"ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' ".
"WHERE lg.goods_id = '$goods_id' AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 ".
"LIMIT " . $GLOBALS['_CFG']['related_goods_number'];
$res = $GLOBALS['db']->query($sql);
$arr = array();
while ($row = $GLOBALS['db']->fetchRow($res))
{
$arr[$row['goods_id']]['goods_id'] = $row['goods_id'];
$arr[$row['goods_id']]['goods_name'] = $row['goods_name'];
$arr[$row['goods_id']]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ?
sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
$arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
$arr[$row['goods_id']]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
$arr[$row['goods_id']]['market_price'] = price_format($row['market_price']);
$arr[$row['goods_id']]['shop_price'] = price_format($row['shop_price']);
$arr[$row['goods_id']]['url'] = build_uri('goods', array('gid'=>$row['goods_id']), $row['goods_name']);
if ($row['promote_price'] > 0)
{
$arr[$row['goods_id']]['promote_price'] = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
$arr[$row['goods_id']]['formated_promote_price'] = price_format($arr[$row['goods_id']]['promote_price']);
}
else
{
$arr[$row['goods_id']]['promote_price'] = 0;
}
}
return $arr;
}
?>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。