<?php 


/** 
***************************************************
*欢迎使用免费版SiteTeam企业建站软件！
*这是一个专业为搜索引擎营销而设计的，极稳定、极易维护的建站软件！
*官方客服：help@php.net.cn
*官方下载网址：http://www.SiteTeam.cn 
***************************************************
**/




if(!defined('IN_SITETEAM')) { exit('Access Denied'); } define("CURSCRIPT", "product_list"); if (SITE_REWRITE) { if (preg_match("/^\/\?/i", $_SERVER['REQUEST_URI'])) { $page_url = "http://{$site_url}{$_SERVER['REQUEST_URI']}"; $page_url = url_rewrite($page_url, 'url'); header("HTTP/1.1 301 Moved Permanently"); header("Location:{$page_url}"); exit(); } } $category = empty($GET['category']) ? empty($_POST['category']) ? '' : $_POST['category'] : $GET['category']; $page = empty($GET['page']) ? empty($_POST['page']) ? 1 : $_POST['page'] : $GET['page']; $limit = 30; $offset = ($page - 1) * $limit; $cache_product_list_dir = SITE_ROOT . "/data/tpl/{$site_url}"; $cache_product_list_html = "{$cache_product_list_dir}/product/" . md5($category . $page) . ".html"; if (file_exists($cache_product_list_html) && time() - filemtime($cache_product_list_html) < CACHE_TIME && IN_CACHE) { include $cache_product_list_html; exit(); } extract($product_setting); if (!empty($category) && !array_key_exists($category, $product_category)) { header("HTTP/1.1 301 Moved Permanently"); $page_url = "http://{$site_url}/?{$site_product_list_url}.html"; $page_url = url_rewrite($page_url, 'url'); header("Location:{$page_url}"); } foreach ($product_category as $k=>$v) { $sortid[$k] = array_key_exists("sortid", $v) ? $v['sortid'] : 0; } array_multisort($sortid, SORT_NUMERIC, SORT_DESC, $product_category); if (!empty($category) && time() < 1292206261 && file_exists(SITE_ROOT . "/data/setting/{$site_url}/product/{$category}.index.txt")) { require_once "./admin/admin.inc.php"; if (check_db_structure($site_id)) { $user_product_dir = SITE_ROOT . "/data/setting/{$site_url}/product"; update_product_index($category); @unlink("{$user_product_dir}/{$category}.index.txt"); } } $banner_flv = $first_bgsound = ""; $db = new txtSQL('./data/siteteam'); $db->connect("root", "siteteam"); if (empty($category)) { $total_row = $db->execute("select", array('db' => dbname($site_id), 'select' => array('key'), 'where' => array('pass = 1'), 'table' => 'sm_product')); $total_row = count($total_row); $multipage = multipage($total_row, $page, $limit); $product_list = $db->execute("select", array('db' => dbname($site_id), 'select' => array('*'), 'table' => 'sm_product', 'where' => array('pass = 1'), 'limit' => array($multipage['start_row'], $multipage['end_row']), 'orderby' => array('key', true ? 'desc' : 'asc'))); } else { $total_row = $db->execute("select", array('db' => dbname($site_id), 'select' => array('key'), 'where' => array("category={$category}", 'and', 'pass = 1'), 'table' => 'sm_product')); $total_row = count($total_row); $multipage = multipage($total_row, $page, $limit); $product_list = $db->execute("select", array('db' => dbname($site_id), 'select' => array('*'), 'where' => array("category={$category}", 'and', 'pass = 1'), 'table' => 'sm_product', 'limit' => array($multipage['start_row'], $multipage['end_row']), 'orderby' => array('key', PRODUCT_LIST_DESC ? 'desc' : 'asc'))); } if (!empty($category)) { if (empty($product_category[$category]['seo_title'])) { $product_category[$category]['seo_title'] = "{$product_category[$category]['name']}，" . (empty($product_setting['seo_title']) ? '' : $product_setting['seo_title'] . "，") . "{$site_title}"; } foreach ($product_category[$category] as $k => $v) { if ($k == 'seo_keywords') continue; if ($k == 'seo_description') continue; if (empty($v) && array_key_exists($k, $product_setting)) $product_category[$category][$k] = $product_setting[$k]; } extract($product_category[$category]); } if ($banner_off == "1") { $banner_ad = ''; } if (empty($seo_description)) { if (is_array($product_list) && count($product_list)) { foreach ($product_list as $k => $v) { $seo_description .= "{$v['pname']}，"; } if (strlen($seo_description) < 180) { $seo_description .= (empty($product_setting['seo_description']) ? "{$site_description} - " : "{$product_setting['seo_description']} - "); } if (strlen($seo_description) < 180) { $seo_description .= (empty($product_setting['seo_keywords']) ? implode("，", explode(',', $site_keywords)) . " - " : "{$product_setting['seo_keywords']} - "); } if (!empty($category)) { $seo_description = $product_category[$category]['name'] . " - " . $seo_description; } if (strlen($seo_description) > 400) { $seo_description = str_sub($seo_description, 400, ""); } $seo_description .= "{$site_title}"; } else { $seo_noindex = 1; } } $db->disconnect(); ob_start(); @eval(tpl_render($skinid, "product_list")); $html = ob_get_clean(); $html = url_rewrite($html); if (CACHE_TIME > 0 && IN_CACHE) { if (!file_exists("{$cache_product_list_dir}/product")) { if (!file_exists($cache_product_list_dir)) { mkdir($cache_product_list_dir); } mkdir("{$cache_product_list_dir}/product"); } if ($fp = @fopen($cache_product_list_html, "w")) { if (@fwrite($fp, $html)) { @fclose($fp); echo $html; } else { exit(siteteam_sys_msg(3)); } } else { exit(siteteam_sys_msg(3)); } } else { echo $html; } ?>