Exemplo n.º 1
0
function get_cat_articles($cat_id, $page = 1, $size = 20, $requirement = '')
{
    //取出所有非0的文章
    if ($cat_id == '-1') {
        $cat_str = 'cat_id > 0';
    } else {
        $cat_str = get_article_children($cat_id);
    }
    //增加搜索条件,如果有搜索内容就进行搜索
    if ($requirement != '') {
        $sql = 'SELECT article_id, title, author,click, add_time, file_url, open_type, keywords, description' . ' FROM ' . $GLOBALS['ecs']->table('article') . ' WHERE is_open = 1 AND title like \'%' . $requirement . '%\' ' . ' ORDER BY article_type DESC, article_id DESC';
    } else {
        $sql = 'SELECT article_id, title, author,click, add_time, file_url, open_type, keywords, description' . ' FROM ' . $GLOBALS['ecs']->table('article') . ' WHERE is_open = 1 AND ' . $cat_str . ' ORDER BY article_type DESC, article_id DESC';
    }
    $res = $GLOBALS['db']->selectLimit($sql, $size, ($page - 1) * $size);
    $arr = array();
    if ($res) {
        while ($row = $GLOBALS['db']->fetchRow($res)) {
            $article_id = $row['article_id'];
            $arr[$article_id]['id'] = $article_id;
            $arr[$article_id]['title'] = $row['title'];
            $arr[$article_id]['keywords'] = $row['keywords'];
            $arr[$article_id]['description'] = $row['description'];
            $arr[$article_id]['short_title'] = $GLOBALS['_CFG']['article_title_length'] > 0 ? sub_str($row['title'], $GLOBALS['_CFG']['article_title_length']) : $row['title'];
            $arr[$article_id]['author'] = empty($row['author']) || $row['author'] == '_SHOPHELP' ? $GLOBALS['_CFG']['shop_name'] : $row['author'];
            $arr[$article_id]['url'] = build_uri('article', array('aid' => $article_id), $row['title']);
            $arr[$article_id]['file_url'] = trim($row['file_url']);
            $arr[$article_id]['add_time'] = date($GLOBALS['_CFG']['date_format'], $row['add_time']);
            $arr[$article_id]['click'] = $row['click'];
            $cmt = assign_comment($article_id, 1);
            $arr[$article_id]['comments'] = $cmt['comments'];
            $arr[$article_id]['pager'] = $cmt['pager'];
        }
    }
    return $arr;
}
Exemplo n.º 2
0
            }
        }
    }
} else {
    /*
     * act 参数不为空
     * 默认为评论内容列表
     * 根据 _GET 创建一个静态对象
     */
    $cmt = new stdClass();
    $cmt->id = !empty($_GET['id']) ? intval($_GET['id']) : 0;
    $cmt->type = !empty($_GET['type']) ? intval($_GET['type']) : 0;
    $cmt->page = isset($_GET['page']) && intval($_GET['page']) > 0 ? intval($_GET['page']) : 1;
}
if ($result['error'] == 0) {
    $comments = assign_comment($cmt->id, $cmt->type, $cmt->page);
    $smarty->assign('comment_type', $cmt->type);
    $smarty->assign('id', $cmt->id);
    $smarty->assign('username', $_SESSION['user_name']);
    $smarty->assign('email', $_SESSION['email']);
    $smarty->assign('comments', $comments['comments']);
    $smarty->assign('comment_percent', $comments['comment_percent']);
    $smarty->assign('pager', $comments['pager']);
    /* 验证码相关设置 */
    if (intval($_CFG['captcha']) & CAPTCHA_COMMENT && gd_version() > 0) {
        $smarty->assign('enabled_captcha', 1);
        $smarty->assign('rand', mt_rand());
    }
    $result['message'] = $_CFG['comment_check'] ? $_LANG['cmt_submit_wait'] : $_LANG['cmt_submit_done'];
    $result['content'] = $smarty->fetch("library/comments_list.lbi");
}
Exemplo n.º 3
0
/**
 * 调用评论信息
 *
 * @access  public
 * @return  string
 */
function insert_comments($arr)
{
    $need_cache = $GLOBALS['smarty']->caching;
    $need_compile = $GLOBALS['smarty']->force_compile;
    $GLOBALS['smarty']->caching = false;
    $GLOBALS['smarty']->force_compile = true;
    /* 验证码相关设置 */
    if (intval($GLOBALS['_CFG']['captcha']) & CAPTCHA_COMMENT && gd_version() > 0) {
        $GLOBALS['smarty']->assign('enabled_captcha', 1);
        $GLOBALS['smarty']->assign('rand', mt_rand());
    }
    $GLOBALS['smarty']->assign('username', stripslashes($_SESSION['user_name']));
    $GLOBALS['smarty']->assign('email', $_SESSION['email']);
    $GLOBALS['smarty']->assign('comment_type', $arr['type']);
    $GLOBALS['smarty']->assign('id', $arr['id']);
    $cmt = assign_comment($arr['id'], $arr['type']);
    $GLOBALS['smarty']->assign('comments', $cmt['comments']);
    $GLOBALS['smarty']->assign('pager', $cmt['pager']);
    $val = $GLOBALS['smarty']->fetch('library/comments_list.lbi');
    $GLOBALS['smarty']->caching = $need_cache;
    $GLOBALS['smarty']->force_compile = $need_compile;
    return $val;
}
Exemplo n.º 4
0
if ($goods_id <= 0)
{
    exit();
}
/* 读取商品信息 */
$_LANG['kilogram'] = '千克';
$_LANG['gram'] = '克';
$_LANG['home'] = '首页';
$smarty->assign('goods_id', $goods_id);
$goods_info = get_goods_info($goods_id);
$goods_info['goods_name'] = encode_output($goods_info['goods_name']);
$goods_info['goods_brief'] = encode_output($goods_info['goods_brief']);
$smarty->assign('goods_info', $goods_info);

/* 读评论信息 */
$comment = assign_comment($goods_id, 'comments');

$num = $comment['pager']['record_count'];
if ($num > 0)
{
    $page_num = '10';
    $page = !empty($_GET['page']) ? intval($_GET['page']) : 1;
    $pages = ceil($num / $page_num);
    if ($page <= 0)
    {
        $page = 1;
    }
    if ($pages == 0)
    {
        $pages = 1;
    }
Exemplo n.º 5
0
    $smarty->assign('brand_name', encode_output($brand_name));
}
/* 显示分类名称 */
$cat_array = get_parent_cats($goods_info['cat_id']);
krsort($cat_array);
$cat_str = '';
foreach ($cat_array as $key => $cat_data) {
    $cat_array[$key]['cat_name'] = encode_output($cat_data['cat_name']);
    $cat_str .= "<a href='category.php?c_id={$cat_data['cat_id']}'>" . encode_output($cat_data['cat_name']) . "</a>-&gt;";
}
$smarty->assign('cat_array', $cat_array);
$properties = get_goods_properties($goods_id);
// 获得商品的规格和属性
$smarty->assign('specification', $properties['spe']);
// 商品规格
$comment = assign_comment($goods_id, 0);
$smarty->assign('comment', $comment);
$smarty->display('goods.html');
/**
 * 获得指定商品的各会员等级对应的价格
 *
 * @access  public
 * @param   integer     $goods_id
 * @return  array
 */
function get_user_rank_prices($goods_id, $shop_price)
{
    $sql = "SELECT rank_id, IFNULL(mp.user_price, r.discount * {$shop_price} / 100) AS price, r.rank_name, r.discount " . 'FROM ' . $GLOBALS['ecs']->table('user_rank') . ' AS r ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('member_price') . " AS mp " . "ON mp.goods_id = '{$goods_id}' AND mp.user_rank = r.rank_id " . "WHERE r.show_price = 1 OR r.rank_id = '{$_SESSION['user_rank']}'";
    $res = $GLOBALS['db']->query($sql);
    $arr = array();
    while ($row = $GLOBALS['db']->fetchRow($res)) {
Exemplo n.º 6
0
    }
} else {
    /*
     * act 参数不为空
     * 默认为评论内容列表
     * 根据 _GET 创建一个静态对象
     */
    $cmt = new stdClass();
    $cmt->id = !empty($_GET['id']) ? intval($_GET['id']) : 0;
    $cmt->type = !empty($_GET['type']) ? intval($_GET['type']) : 0;
    $cmt->page = isset($_GET['page']) && intval($_GET['page']) > 0 ? intval($_GET['page']) : 1;
    $cmt->comment_level = !empty($_GET['comment_level']) ? intval($_GET['comment_level']) : 0;
    //代码增加  By www.ecshophome.com
}
if ($result['error'] == 0) {
    $comments = assign_comment($cmt->id, $cmt->type, $cmt->page, $cmt->comment_level);
    //代码修改 增加一个 $cmt->comment_level   By www.ecshophome.com
    $smarty->assign('comment_type', $cmt->type);
    $smarty->assign('comment_level', $cmt->comment_level);
    //代码增加  By www.ecshophome.com
    $smarty->assign('id', $cmt->id);
    $smarty->assign('username', $_SESSION['user_name']);
    $smarty->assign('email', $_SESSION['email']);
    $smarty->assign('comments', $comments['comments']);
    $smarty->assign('pager', $comments['pager']);
    /* 验证码相关设置 */
    if (intval($_CFG['captcha']) & CAPTCHA_COMMENT && gd_version() > 0) {
        $smarty->assign('enabled_captcha', 1);
        $smarty->assign('rand', mt_rand());
    }
    $result['message'] = $_CFG['comment_check'] ? $_LANG['cmt_submit_wait'] : $_LANG['cmt_submit_done'];
Exemplo n.º 7
0
/**
 * 获得购买过该商品的人还买过的商品
 *
 * @access  public
 * @param   integer     $goods_id
 * @return  array
 */
function get_also_bought($goods_id)
{
    $sql = 'SELECT COUNT(b.goods_id ) AS num, g.goods_id, g.goods_name, g.goods_thumb, g.goods_img, g.shop_price, g.promote_price, g.promote_start_date, g.promote_end_date ' . 'FROM ' . $GLOBALS['ecs']->table('order_goods') . ' AS a ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('order_goods') . ' AS b ON b.order_id = a.order_id ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('goods') . ' AS g ON g.goods_id = b.goods_id ' . "WHERE a.goods_id = '{$goods_id}' AND b.goods_id <> '{$goods_id}' AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 " . 'GROUP BY b.goods_id ' . 'ORDER BY num DESC ' . 'LIMIT ' . $GLOBALS['_CFG']['bought_goods'];
    $res = $GLOBALS['db']->query($sql);
    $key = 0;
    $arr = array();
    while ($row = $GLOBALS['db']->fetchRow($res)) {
        $arr[$key]['goods_id'] = $row['goods_id'];
        $arr[$key]['goods_name'] = $row['goods_name'];
        $arr[$key]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
        $arr[$key]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
        $arr[$key]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
        $arr[$key]['shop_price'] = price_format($row['shop_price']);
        $arr[$key]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
        $comment = assign_comment($row['goods_id'], 0);
        // by Leah
        $arr[$key]['goods_comment'] = $comment['comments'];
        // by Leah  购买改商品的会员还买了的商品评论
        if ($row['promote_price'] > 0) {
            $arr[$key]['promote_price'] = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
            $arr[$key]['formated_promote_price'] = price_format($arr[$key]['promote_price']);
        } else {
            $arr[$key]['promote_price'] = 0;
        }
        $key++;
    }
    return $arr;
}
Exemplo n.º 8
0
/**
 * 获得指定分类下的商品
 *
 * @access  public
 * @param   integer     $cat_id     分类ID
 * @param   integer     $num        数量
 * @param   string      $from       来自web/wap的调用
 * @param   string      $order_rule 指定商品排序规则
 * @return  array
 */
function assign_cat_goods($cat_id, $num = 0, $from = 'web', $order_rule = '')
{
    $sql = 'SELECT sort_order FROM ' . $GLOBALS['ecs']->table('template') . " WHERE filename = 'index' AND type = 1 AND remarks ='' AND id = {$cat_id} ";
    $sort_order = $GLOBALS['db']->getOne($sql);
    $cat['sort_order'] = $sort_order;
    $children = get_children($cat_id);
    $sql = 'SELECT g.goods_id, g.goods_name, g.market_price, g.shop_price AS org_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, " . 'g.promote_price, promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, g.goods_img ' . "FROM " . $GLOBALS['ecs']->table('goods') . ' AS g ' . "LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp " . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . 'WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND ' . 'g.is_delete = 0 AND (' . $children . 'OR ' . get_extension_goods($children) . ') ';
    $order_rule = empty($order_rule) ? 'ORDER BY g.sort_order, g.goods_id DESC' : $order_rule;
    $sql .= $order_rule;
    if ($num > 0) {
        $sql .= ' LIMIT ' . $num;
    }
    $res = $GLOBALS['db']->getAll($sql);
    $goods = array();
    foreach ($res as $idx => $row) {
        if ($row['promote_price'] > 0) {
            $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
            $goods[$idx]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : '';
        } else {
            $goods[$idx]['promote_price'] = '';
        }
        $goods[$idx]['id'] = $row['goods_id'];
        $goods[$idx]['name'] = $row['goods_name'];
        $goods[$idx]['brief'] = $row['goods_brief'];
        $goods[$idx]['market_price'] = price_format($row['market_price']);
        $goods[$idx]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
        $goods[$idx]['shop_price'] = price_format($row['shop_price']);
        $goods[$idx]['thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
        $goods[$idx]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
        $goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
    }
    if ($from == 'web') {
        $GLOBALS['smarty']->assign('cat_goods_' . $cat_id, $goods);
    } elseif ($from == 'wap') {
        $cat['goods'] = $goods;
    }
    /* 分类信息 */
    $sql = 'SELECT cat_name FROM ' . $GLOBALS['ecs']->table('category') . " WHERE cat_id = {$cat_id}";
    $cat['name'] = $GLOBALS['db']->getOne($sql);
    $cat['url'] = build_uri('category', array('cid' => $cat_id), $cat['name']);
    $cat['id'] = $cat_id;
    $cat['cat_clild'] = get_clild_list($cat_id);
    $cat['cat_best'] = get_recommend_goods_index('best', $cat_id);
    $cat['cat_new'] = get_recommend_goods_index('new', $cat_id);
    $cat['cat_hot'] = get_recommend_goods_index('hot', $cat_id);
    //获取二级分类下的商品
    $cat_list_arr = cat_list($cat_id, 0, false);
    foreach ($cat_list_arr as $key => $value) {
        if ($value['level'] == 1) {
            $sql = 'SELECT g.goods_id,g.cat_id, g.goods_name, g.market_price, g.shop_price AS org_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, " . 'g.promote_price, promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, g.goods_img ' . 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('member_price') . ' AS mp ' . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . 'WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND is_delete = 0 AND ' . get_children($value['cat_id']) . ' ORDER BY g.sort_order, g.goods_id DESC';
            if ($num > 0) {
                $sql .= ' LIMIT ' . $num;
            }
            $goods_res = $GLOBALS['db']->getAll($sql);
            foreach ($goods_res as $idx => $row) {
                if ($row['promote_price'] > 0) {
                    $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
                    $goods_res[$idx]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : '';
                } else {
                    $goods_res[$idx]['promote_price'] = '';
                }
                $goods_res[$idx]['market_price'] = price_format($row['market_price']);
                $goods_res[$idx]['shop_price'] = price_format($row['shop_price']);
                $goods_res[$idx]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : '';
                $goods_res[$idx]['shop_price'] = price_format($row['shop_price']);
                $goods_res[$idx]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
                $goods_res[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
                /*修改:获得商品评论*/
                $goods_res[$idx]['comments'] = assign_comment($row['goods_id']);
            }
            $cat_list_arr[$key]['goods'] = $goods_res;
        } else {
            unset($cat_list_arr[$key]);
        }
    }
    $cat['goods_level2'] = $cat_list_arr;
    // 获取分类下品牌
    $sql = "SELECT b.brand_id, b.brand_name, brand_logo , COUNT(*) AS goods_num " . "FROM " . $GLOBALS['ecs']->table('brand') . "AS b, " . $GLOBALS['ecs']->table('goods') . " AS g LEFT JOIN " . $GLOBALS['ecs']->table('goods_cat') . " AS gc ON g.goods_id = gc.goods_id " . "WHERE g.brand_id = b.brand_id AND ({$children} OR " . 'gc.cat_id ' . db_create_in(array_unique(array_merge(array($cat_id), array_keys(cat_list($cat_id, 0, false))))) . ") AND b.is_show = 1 " . " AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 " . "GROUP BY b.brand_id HAVING goods_num > 0 ORDER BY b.sort_order, b.brand_id ASC LIMIT 3";
    $brands = $GLOBALS['db']->getAll($sql);
    foreach ($brands as $key => $val) {
        $brands[$key]['brand_name'] = $val['brand_name'];
        $brands[$key]['url'] = build_uri('brand', array('bid' => $val['brand_id']), $val['brand_name']);
        $brands[$key]['logo'] = 'data/brandlogo/' . $val['brand_logo'];
    }
    $cat['brands'] = $brands;
    return $cat;
}
Exemplo n.º 9
0
require dirname(__FILE__) . '/includes/init.php';
$goods_id = !empty($_GET['g_id']) ? intval($_GET['g_id']) : exit;
if ($goods_id <= 0) {
    exit;
}
/* 读取商品信息 */
$_LANG['kilogram'] = '千克';
$_LANG['gram'] = '克';
$_LANG['home'] = '首页';
$smarty->assign('goods_id', $goods_id);
$goods_info = get_goods_info($goods_id);
$goods_info['goods_name'] = encode_output($goods_info['goods_name']);
$goods_info['goods_brief'] = encode_output($goods_info['goods_brief']);
$smarty->assign('goods_info', $goods_info);
/* 读评论信息 */
$comment = assign_comment($goods_id, 'comments', 1, 1000);
$num = $comment['pager']['record_count'];
if ($num > 0) {
    $page_num = '10';
    $page = !empty($_GET['page']) ? intval($_GET['page']) : 1;
    $pages = ceil($num / $page_num);
    if ($page <= 0) {
        $page = 1;
    }
    if ($pages == 0) {
        $pages = 1;
    }
    if ($page > $pages) {
        $page = $pages;
    }
    $i = 1;