<?php

/**
 * ECSHOP 轮播图片程序
 * ============================================================================
 * 版权所有 (C) 2005-2007 北京亿商互动科技发展有限公司，并保留所有权利。
 * 网站地址: http://www.ecshop.com
 * ----------------------------------------------------------------------------
 * 这是一个免费开源的软件；这意味着您可以在不用于商业目的的前提下对程序代码
 * 进行修改、使用和再发布。
 * ============================================================================
 * @author:     Weber Liu <weberliu@hotmail.com>
 * @version:    v2.1
 * ---------------------------------------------
 * $Author: paulgao $
 * $Date: 2007-05-09 13:57:22 +0800 (星期三, 09 五月 2007) $
 * $Id: cycle_image.php 8536 2007-05-09 05:57:22Z paulgao $
*/

define('IN_ECS', true);
define('INIT_NO_USERS', true);
define('INIT_NO_SMARTY', true);

require('./includes/init.php');

header('Content-Type: application/xml; charset=utf-8');
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Fri, 14 Mar 1980 20:53:00 GMT');
header('Last-Modified: ' . date('r'));
header('Pragma: no-cache');

echo '<?xml version="1.0" encoding="utf-8"?>';
echo '<bcaster>';

if (!empty($_CFG['shop_slagon']) && file_exists(str_replace('../', '', $_CFG['shop_slagon'])))
{
    echo '<item item_url="'. str_replace('../', '', $_CFG['shop_slagon']). '" link="" />';
}

$sql = 'SELECT goods_id, goods_name, cycle_img, RAND() AS rand ' .
       'FROM ' . $ecs->table('goods') . " WHERE cycle_img > '' AND is_delete = '0' ORDER BY rand LIMIT 8";
$res = $db->getAllCached($sql);

foreach ($res AS $row)
{
    echo '<item item_url="' .$row['cycle_img']. '" link="'. build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']). '" />';
}

echo '</bcaster>';

?>