function cate($cid) { $this->catep = get_catep_arr($cid); //导航 //获取下级分类 $dao = D("Cate"); $this->assign('pagekeywords', $dao->getKeywords($cid)); //关键字 $this->assign('pagedesc', $dao->getDescription($cid)); //描述 $this->assign('pagetitle', $dao->getPageTitle($cid)); //标题 $strFid_class = 'Fid_class' . $cid; if (S($strFid_class) == '') { $classChildren = $dao->getChildren($cid); $classChildren[count($classChildren)] = $cid; S($strFid_class, implode(",", $classChildren)); //取得所有子类 } $map['isdown'] = array('neq', 1); $map['cateid'] = array('in', S($strFid_class)); switch (true) { case isset($_REQUEST['new']): $map['isnew'] = 1; break; case isset($_REQUEST['hot']): $map['ishot'] = 1; break; case isset($_REQUEST['rec']): $map['isrec'] = 1; break; case isset($_REQUEST['price']): $map['isprice'] = 1; break; } //属性筛选 if (isset($_GET['attr_id']) && isset($_GET['attr_value'])) { $Pro_attrView = D('Pro_attrView'); $map['attr_id'] = intval($_GET['attr_id']); $map['attr_value'] = base64_decode($_GET['attr_value']); $Pro_attrView->_list($this->view, $map, 'sort', false); } else { D("Products")->_list($this->view, $map, 'sort', false); } //属性筛选 $typeid = $dao->getTypeId($cid); if ($typeid) { self::$Model = D("Type_attr"); $attr = self::$Model->getAttrs($typeid); $this->attr = $attr; } $cateinfo = get_cate_info($cid); $catec = $dao->where("pid=" . $cid)->order("sort desc")->select(); //下级分类 //如果没有下级仍显示同类 if (!$catec) { $pid = $cateinfo['pid']; $catec = $dao->where("pid=" . $pid)->order("sort desc")->select(); } $this->catec = $catec; $this->cateinfo = $cateinfo; $this->pagetitle = $cateinfo['pagetitle']; $this->pagekeywords = $cateinfo['pagekey']; $this->pagedesc = $cateinfo['pagedec']; $this->cateid = $cid; $this->display("Empty:cate"); }
* 您只能在不用于商业目的的前提下对程序代码进行修改和使用; * 不允许对程序代码以任何形式任何目的的再发布。 * ============================================================================ */ if (!file_exists("../data/install.lock") || !file_exists("../data/confing.php")) { header("location:../install/index.php"); exit; } define('CMS', true); require_once '../includes/init.php'; require_once '../includes/fun.php'; require_once '../includes/lib.php'; //载入模板调用函数,不载入该文件不能使用函数 $id = intval($_GET['id']); $cate_info = get_cate_info($id, $category); $channel_info = get_cate_info($cate_info['cate_channel'], $channel); //获得内容模型信息 if (empty($cate_info)) { header('location:../index.php'); } $lang = $cate_info['lang']; if (file_exists(LANG_PATH . 'lang_' . $lang . '.php')) { include LANG_PATH . 'lang_' . $lang . '.php'; } //语言包缓存,数组$language if (file_exists(DATA_PATH . 'cache_cate/cate_list_' . $lang . '.php')) { include DATA_PATH . 'cache_cate/cate_list_' . $lang . '.php'; } //当前语言下的栏目 $_confing = get_confing($lang); //配置信息
function get_catep_arr($cid) { $cate = get_cate_info($cid); $arr = explode("__", $cate['key']); //dump($arr); for ($row = 0; $row < count($arr); $row++) { $subarr = explode("_", $arr[$row]); //dump($subarr); $r[] = get_cate_info($subarr[2]); } return $r; }
/** * 根据内容或列表页第一个关键词获取内容,不存在关键词随机获取 * * @access public * @param $is_rand:1为随机;$filter:过滤标示(如推荐等);$order_type:排序类型;$pic:是否有图片;$limit:数量 * @return array */ function get_rand_content($key = '', $limit = '0,5', $order_type = 'id', $filter = '', $pic = 'no', $order = 'desc', $lang = '') { $sql_key = ''; $sql_rand = ''; if ($key) { $key_arr = explode(',', $key); $sql_key = " and ("; $key_num = count($key_arr); $sql_or = ''; foreach ($key_arr as $k => $v) { if ($k != $key_num - 1) { $sql_key .= " m.keywords like '%" . $v . "%' or"; } else { $sql_key .= " m.keywords like '%" . $v . "%'"; } if ($k == 2) { break; } } $sql_key .= ")"; } else { $sql_rand = ' rand(),'; } $cate_id = $GLOBALS['cateid']; //获得栏目ID,不存在获取内容页的栏目ID if (empty($cate_id)) { return; } global $category, $channel; $cate_info = get_cate_info($cate_id, $category); //获得栏目信息 $channel_id = $cate_info['cate_channel']; //获得栏目模型ID unset($cate_info); //释放栏目信息,下面将会用到 $channel_info = get_cate_info($channel_id, $channel); //获得栏目模型信息 $content_php = empty($channel_info['content_php']) ? 'show_content.php' : $channel_info['content_php']; $list_php = empty($channel_info['list_php']) ? 'show_list.php' : $channel_info['list_php']; $table = $channel_info['channel_table']; //获得栏目模型表 if (empty($table)) { return; } $child = get_child_id($cate_id); //获得栏目的下级栏目 $cate_id_all = empty($child) ? $cate_id : $cate_id . $child; //组合栏目ID $sql = "select m.*,f.* from " . DB_PRE . "maintb as m left join " . DB_PRE . $table . " as f on f.id = m.id where m.id=f.id and m.verify=0 and m.category in (" . $cate_id_all . ")"; $sql .= empty($filter) ? ' ' : " and m.filter like '%" . $filter . "%'"; $sql .= $sql_key; if ($pic == 'no') { $sql .= ''; } elseif ($pic == 'yes') { $sql .= " and m.tbpic <> ''"; } $sql .= empty($lang) ? " and m.lang='" . $GLOBALS['lang'] . "'" : " and m.lang='" . $lang . "'"; $sql .= in_array($order_type, array('id', 'hits', 'addtime', 'updatetime')) ? " GROUP BY m.id order by" . $sql_rand . " m.top desc, m." . $order_type : " GROUP BY m.id order by" . $sql_rand . " m.top desc, m.id "; $sql .= in_array($order, array('asc', 'desc')) ? ' ' . $order : ' desc'; $sql .= empty($limit) ? ' limit 0,5' : " limit " . $limit; $rel = $GLOBALS['mysql']->fetch_asc($sql); if (!empty($rel)) { $path = CMS_SELF; $i = 1; foreach ($rel as $k => $v) { $rel[$k]['title'] = $v['title']; //标题 if ($rel[$k]['title_color'] || $rel[$k]['title_style'] || $rel[$k]['is_open']) { $font_style = ''; $font_style .= empty($rel[$k]['title_color']) ? '' : 'color:' . $rel[$k]['title_color'] . ';'; if ($rel[$k]['title_style'] == 1) { $font_style .= 'font-weight:bold;'; } elseif ($rel[$k]['title_style'] == 2) { $font_style .= 'font-style:italic;'; } elseif ($rel[$k]['title_style'] == 3) { $font_style .= 'text-decoration:underline;'; } $rel[$k]['style'] = $font_style; $rel[$k]['style_title'] = $rel[$k]['title']; //样式标题 } else { $rel[$k]['style_title'] = $rel[$k]['title']; } $rel[$k]['target'] = $v['is_open'] ? 'target="_blank"' : ''; //新窗口 if ($v['purview']) { $url = $path . 'show_content.php?id=' . $v['id']; } else { $url = !$v['is_html'] && !$GLOBALS['_confing']['web_html'][0] ? $path . $content_php . '?id=' . $v['id'] : $path . $v['url']; } $rel[$k]['url'] = $v['is_url'] ? $v['url_add'] : $url; //链接 $v['tbpic'] = empty($v['tbpic']) ? 'no_pc.gif' : $v['tbpic']; $rel[$k]['thumb_pic'] = CMS_SELF . 'upload/' . $v['tbpic']; //图片 $cate_info = get_cate_info($v['category'], $category); //获取栏目信息 $cate_url = !$v['is_html'] && !$GLOBALS['_confing']['web_html'][0] ? $path . $list_php . '?id=' . $cate_info['id'] : $path . $cate_info['cate_fold_name']; $rel[$k]['cate_url'] = $cate_url; //栏目url $rel[$k]['cate_name'] = $cate_info['cate_name']; //栏目名称 $rel[$k]['cate_pic1'] = CMS_SELF . 'upload/' . $cate_info['cate_pic1']; $rel[$k]['cate_pic2'] = CMS_SELF . 'upload/' . $cate_info['cate_pic2']; $rel[$k]['cate_pic3'] = CMS_SELF . 'upload/' . $cate_info['cate_pic3']; $rel[$k]['cate_content'] = CMS_SELF . 'upload/' . $cate_info['cate_content']; $rel[$k]['autoindex'] = $i; $rel[$k]['first'] = $i == 1 ? 1 : 0; $rel[$k]['last'] = $num == $i ? 1 : 0; $i = $i + 1; } } return $rel; }
* 网站地址: http://www.beescms.com * 您只能在不用于商业目的的前提下对程序代码进行修改和使用; * 不允许对程序代码以任何形式任何目的的再发布。 * ============================================================================ */ if (!file_exists("../data/install.lock") || !file_exists("../data/confing.php")) { header("location:../install/index.php"); exit; } define('CMS', true); require_once '../includes/init.php'; require_once '../includes/fun.php'; require_once '../includes/lib.php'; $id = intval($_GET['id']); $pr_id = intval($_GET['pr_id']); $cate_info = get_cate_info($id, $category); if (empty($cate_info) || $cate_info['cate_channel'] != -9) { header('location:../index.php'); } //非表单跳转首页 $lang = $cate_info['lang']; if (file_exists(LANG_PATH . 'lang_' . $lang . '.php')) { include LANG_PATH . 'lang_' . $lang . '.php'; } //语言包缓存,数组$language if (file_exists(DATA_PATH . 'cache_cate/cate_list_' . $lang . '.php')) { include DATA_PATH . 'cache_cate/cate_list_' . $lang . '.php'; } //当前语言下的栏目 $_confing = get_confing($lang); //配置信息
function get_child_cate($parent_id, $lang, $cateid = '') { if (empty($parent_id)) { return; } $child = array(); $_confing = get_confing($lang); if (file_exists(DATA_PATH . 'cache_channel/cache_channel_all.php')) { include DATA_PATH . 'cache_channel/cache_channel_all.php'; } $sql = "select*from " . DB_PRE . "category where cate_parent=" . $parent_id . " order by cate_order asc"; $rel = $GLOBALS['mysql']->fetch_asc($sql); foreach ($rel as $row) { if (!$row['cate_hide']) { $channel_info = get_cate_info($row['cate_channel'], $GLOBALS['channel']); //获得内容模型信息 $list_php = empty($channel_info['list_php']) ? 'show_list.php' : $channel_info['list_php']; if ($row['cate_tpl'] == 2) { $url = $row['cate_url']; } else { $url = $row['cate_html'] && $_confing['web_html'][0] ? CMS_SELF . 'htm/' . $row['cate_fold_name'] : CMS_SELF . $list_php . '?id=' . $row['id']; if ($row['cate_tpl'] == 3) { $url = $row['cate_html'] && $_confing['web_html'][0] ? CMS_SELF . 'htm/' . $row['cate_fold_name'] . '/index_' . $lang . '.html' : CMS_SELF . $list_php . '?id=' . $row['id']; } } if ($row['cate_channel'] == '-9') { $url = $row['cate_html'] && $_confing['web_html'][0] ? CMS_SELF . 'htm/' . $row['cate_fold_name'] : CMS_SELF . 'order/order.php?id=' . $row['id']; } if ($row['id'] == $GLOBALS['cat_id']) { $child[$row['id']]['class'] = "focus"; } $child[$row['id']]['url'] = $url; $child[$row['id']]['cate_name'] = $row['cate_name']; $child[$row['id']]['cate_pic1'] = CMS_SELF . 'upload/' . $row['cate_pic1']; $child[$row['id']]['cate_pic2'] = CMS_SELF . 'upload/' . $row['cate_pic2']; $child[$row['id']]['cate_pic3'] = CMS_SELF . 'upload/' . $row['cate_pic3']; $child[$row['id']]['cate_content'] = $row['cate_content']; $child[$row['id']]['cate_tpl'] = $row['cate_tpl']; if ($row['cate_parent'] != 0) { $child[$row['id']]['child'] = get_child_cate($row['id'], $lang); } } } return $child; }