<?php
require_once $_SERVER['DOCUMENT_ROOT']."/data/config.php";
require_once $_SERVER['DOCUMENT_ROOT']."/comn/ImageTool.class.php";
set_time_limit(0);
/**
* 取得当前位置和页面标题
*
* @access public
* @param integer $cat 分类编号(只有商品及分类、文章及分类用到)
* @param string $str 商品名、文章标题或其他附加的内容(无链接)
* @return array
*/
function assign_ur_here($cat = 0, $str = '')
{
/* 判断是否重写,取得文件名 */
$cur_url = basename(PHP_SELF);
if (intval(0))
{
$filename = strpos($cur_url,'-') ? substr($cur_url, 0, strpos($cur_url,'-')) : substr($cur_url, 0, -4);
}
else
{
$filename = substr($cur_url, 0, -4);
}
/* 初始化“页面标题”和“当前位置” */
$page_title = '硬汉联盟';
$ur_here = '<a href="http://www.manlm.com">' . '首页' . '</a>';
/* 根据文件名分别处理中间的部分 */
if ($filename != 'index')
{
/* 处理有分类的 */
if (in_array($filename, array('category', 'goods', 'article_cat', 'article', 'brand')))
{
/* 商品分类或商品 */
if ('category' == $filename || 'goods' == $filename || 'brand' == $filename)
{
if ($cat > 0)
{
$cat_arr = get_parent_cats($cat);
$key = 'cid';
$type = 'category';
}
else
{
$cat_arr = array();
}
}
/* 文章分类或文章 */
elseif ('article_cat' == $filename || 'article' == $filename)
{
if ($cat > 0)
{
$cat_arr = get_article_parent_cats($cat);
$key = 'acid';
$type = 'article_cat';
}
else
{
$cat_arr = array();
}
}
/* 循环分类 */
if (!empty($cat_arr))
{
krsort($cat_arr);
foreach ($cat_arr as $val)
{
$page_title = htmlspecialchars($val['Name']) . '_' . $page_title;
$args = array($key => $val['ID']);
$ur_here .= ' <code>></code> <a href="' . build_uri($type, $args, $val['Name']) . '">' .
htmlspecialchars($val['Name']) . '</a>';
}
}
}
/* 处理无分类的 */
else
{
/* 团购 */
if ('group_buy' == $filename)
{
$page_title = $GLOBALS['_LANG']['group_buy_goods'] . '_' . $page_title;
$args = array('gbid' => '0');
$ur_here .= ' <code>></code> <a href="group_buy.php">' .
$GLOBALS['_LANG']['group_buy_goods'] . '</a>';
}
/* 拍卖 */
elseif ('auction' == $filename)
{
$page_title = $GLOBALS['_LANG']['auction'] . '_' . $page_title;
$args = array('auid' => '0');
$ur_here .= ' <code>></code> <a href="auction.php">' .
$GLOBALS['_LANG']['auction'] . '</a>';
}
/* 夺宝 */
elseif ('snatch' == $filename)
{
$page_title = $GLOBALS['_LANG']['snatch'] . '_' . $page_title;
$args = array('id' => '0');
$ur_here .= ' <code> > </code><a href="snatch.php">' . $GLOBALS['_LANG']['snatch_list'] . '</a>';
}
/* 批发 */
elseif ('wholesale' == $filename)
{
$page_title = $GLOBALS['_LANG']['wholesale'] . '_' . $page_title;
$args = array('wsid' => '0');
$ur_here .= ' <code>></code> <a href="wholesale.php">' .
$GLOBALS['_LANG']['wholesale'] . '</a>';
}
/* 积分兑换 */
elseif ('exchange' == $filename)
{
$page_title = $GLOBALS['_LANG']['exchange'] . '_' . $page_title;
$args = array('wsid' => '0');
$ur_here .= ' <code>></code> <a href="exchange.php">' .
$GLOBALS['_LANG']['exchange'] . '</a>';
}
/* 其他的在这里补充 */
}
}
/* 处理最后一部分 */
if (!empty($str))
{
$page_title = $str . '_' . $page_title;
$ur_here .= ' <code>></code> ' . $str;
}
/* 返回值 */
return array('title' => $page_title, 'ur_here' => $ur_here);
}
/**
* 重写 URL 地址
*
* @access public
* @param string $app 执行程序
* @param array $params 参数数组
* @param string $append 附加字串
* @param integer $page 页数
* @param string $keywords 搜索关键词字符串
* @return void
*/
function build_uri($app, $params, $append = '', $page = 0, $keywords = '', $size = 0)
{
static $rewrite = NULL;
if ($rewrite === NULL)
{
$rewrite = intval(0);
}
$args = array('cid' => 0,
'gid' => 0,
'bid' => 0,
'acid' => 0,
'aid' => 0,
'sid' => 0,
'gbid' => 0,
'auid' => 0,
'alid' => array(),
'sort' => '',
'order' => '',
);
extract(array_merge($args, $params));
$uri = '';
switch ($app)
{
case 'category':
if (empty($cid))
{
return false;
}
else
{
if ($rewrite)
{
$uri = 'category-' . $cid;
if (isset($bid))
{
$uri .= '-b' . $bid;
}
if (isset($price_min))
{
$uri .= '-min'.$price_min;
}
if (isset($price_max))
{
$uri .= '-max'.$price_max;
}
if (isset($filter_attr))
{
$uri .= '-attr' . $filter_attr;
}
if (!empty($page))
{
$uri .= '-' . $page;
}
if (!empty($sort))
{
$uri .= '-' . $sort;
}
if (!empty($order))
{
$uri .= '-' . $order;
}
}
else
{
$uri = 'category.php?id=' . $cid;
if (!empty($bid))
{
$uri .= '&brand=' . $bid;
}
if (isset($price_min))
{
$uri .= '&price_min=' . $price_min;
}
if (isset($price_max))
{
$uri .= '&price_max=' . $price_max;
}
if (!empty($filter_attr))
{
$uri .='&filter_attr=' . $filter_attr;
}
if (!empty($page))