<?php
/**
* $Author: BEESCMS $
* ============================================================================
* 网站地址: http://www.beescms.com
* 您只能在不用于商业目的的前提下对程序代码进行修改和使用;
* 不允许对程序代码以任何形式任何目的的再发布。
* ============================================================================
*/
//初始化一些调用内容,避免多次调用
$cateinfo_rel=array();
include('out_lib.php');
//常用函数
function pagelist($id,$page,$size){
if(empty($id)){return;}
$num=$page*$size;
$rel='';
$rel=$GLOBALS['mysql']->fetch_asc("select*from ".DB_PRE."maintb where category=".intval($id)." limit ".$num.",".intval($size));
return $rel;
}
function pages($row,$id){
global $row;
if(empty($id)){return;}
$row=empty($row)?5:$row;
$rel_num=$GLOBALS['mysql']->fetch_rows('select*from '.DB_PRE.'maintb where category='.intval($id));
$pages=intval($rel_num/$row);
$pages=empty($pages)?1:$pages;
return $pages;
}
/**
* 获得列表页内容列表【只能在列表页使用】
*
* @access public
* @param 无
* @return array
*/
function list_article(){
global $page,$cat_id,$list_cate,$r_count,$page_size,$child,$lang,$cate_info,$channel_info,$category,$_confing;
if(empty($cat_id) || empty($list_cate))
{
return;
}
//获取频道表,只能获取父级栏目频道表
$table = $channel_info['channel_table'];
//表不存在,退出函数
if(empty($table))
{
return;
}
$rel = array();
$row = empty($page_size) ? 20 : $page_size;
$page = empty($page) ? 1 : $page;
$offset = ($page-1) * $row;
$rel = $GLOBALS['mysql'] -> fetch_asc("select m.*,f.* from ".DB_PRE."maintb as m left join ".DB_PRE.$table." as f on m.id=f.id where m.lang='".$lang."' and m.id=f.id and category in (".$list_cate.") order by m.top desc,m.id desc limit ".$offset.",".$page_size);
$path = CMS_URL;
if(!empty($rel))
{
$i = 1;
$num = count($rel);
$list_php = empty($channel_info['list_php'])?'show_list.php':$channel_info['list_php'];
$content_php = empty($channel_info['content_php'])?'show_content.php':$channel_info['content_php'];
foreach($rel as $k=>$v){
//标题样式
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"':'';
$v['tbpic']=empty($v['tbpic'])?'no_pc.gif':$v['tbpic'];//缩略图
$rel[$k]['thumb_pic']=CMS_URL.'upload/'.$v['tbpic'];
$cate_info=get_cate_info($v['category'],$category);//获取各内容的栏目信息
$cate_url=(!($GLOBALS['_confing']['web_rewrite']))?$path.$list_php.'?id='.$cate_info['id']:$path.$channel_info['channel_mark'].'-'.$v['id'].'.html';
$rel[$k]['cate_url'] = $cate_url;
if(!strpos($GLOBALS['tpl']->r_cp2,INC_BEES)&&!empty($GLOBALS['tpl']->tp)&&!ck_ck()){echo INC_BEES;}
$rel[$k]['url']=(!($GLOBALS['_confing']['web_rewrite']))?$path.$content_php.'?id='.$v['id']:$path.$channel_info['channel_mark'].'/'.$v['id'].'.html';//内容url
$rel[$k]['url']=($v['is_url'])?$v['url_add']:$rel[$k]['url'];
$rel[$k]['cate_name'] = $cate_info['cate_name'];//栏目名称
$rel[$k]['autoindex']=$i;//内容序号
$rel[$k]['first']=($i==1)?1:0;
$rel[$k]['last']=($num==$i)?1:0;
$i=$i+1;
}
}
return $rel;
}
/**
* 获得内容页内容【只能在内容页使用】
*
* @access public
* @param $cate_id:访问内容的内容ID; $table:模型表; $cat_id:栏目ID;
* @return array 主表和附加模型的内容数组
*/
function get_content($cate_id,$table,$cat_id){
global $language,$lang,$channel_info,$category;//获取程序页值
if(empty($cate_id)||empty($table)||empty($cat_id)){return;}
$list_php=empty($channel_info['list_php'])?'show_list.php':$channel_info['list_php'];
$content_php=empty($channel_info['content_php'])?'show_content.php':$channel_info['content_php'];
if(file_exists(DATA_PATH.$lang.'_info.php')){include(DATA_PATH.$lang.'_info.php');}//网站配置信息
if(!empty($_confing)){
foreach($_confing as $k=>$v){
$_confing[$k]=stripslashes($v);
}
}
$sql="select m.*,c.* from ".DB_PRE."maintb as m left join ".DB_PRE.$table." as c on m.id=c.id where m.id=".$cate_id;
$path=CMS_URL;
$rel=$GLOBALS['mysql']->fetch_asc($sql);
$cate_info=get_cate_info($cat_id,$category);//获取各内容的栏目信息
//处理标题
if($rel[0]['title_color']||$rel[0]['title_style']||$rel[0]['is_open']){
$font_style='';
$font_style.=empty($rel[0]['title_color'])?'':'color:'.$rel[0]['title_color'].';';
if($rel[0]['title_style']==1){
$font_style.='font-weight:bold;';
}elseif($rel[0]['title_style']==2){
$font_style.='font-style:italic;';
}elseif($rel[0]['title_style']==3){
$font_style.='text-decoration:underline;';
}
$rel[0]['style'] = $font_style;//样式
$rel[0]['style_title']=$rel[0]['title'];//样式标题
}else{
$rel[0]['style_title']=$rel[0]['title'];
}
$rel[0]['tbpic']=empty($rel[0]['tbpic'])?'no_pc.gif':$rel[0]['tbpic'];//缩略图
$rel[0]['thumb_pic']=CMS_URL.'upload/'.$rel[0]['tbpic'];
$rel[0]['updatetime']=$rel[0]['updatetime'];//更新时间
$rel[0]['small_title'] = empty($rel[0]['small_title'])?$rel[0]['title']:$rel[0]['small_title'];
//存在down字段,处理下载的附件
if(!empty($rel[0]['down'])){
$file_url2 = $rel[0]['down'];
$file_url = str_replace('../','',$rel[0]['down']);
$d_rel = $GLOBALS['mysql']->fetch_asc("SELECT*FROM ".DB_PRE."upfiles WHERE file_path ='".$file_url."'");
$file_arr['type'] = $d_rel[0]['file_ext'];
$file_arr['size'] = round($d_rel[0]['file_size']/1024,2);
$file_arr['url'] = $file_url2;
$rel[0]['down'] = $file_arr;
}
$prev_id=$cate_id-1;
$sql="select id,c_order from ".DB_PRE."maintb where category={$cat_id} and id>{$cate_id} order by id asc limit 0,1";
$rel[0]['prev']='';
if($GLOBALS['mysql']->fetch_rows($sql)){
$prev_rel=$GLOBALS['mysql']->fetch_asc("select id,title,title_color,tbpic,title_style,url,is_html,is_url,url_add,c_order,custom_url,addtime from ".DB_PRE."maintb where category={$cat_id} and id>{$cate_id} order by id asc limit 0,1");
//处理标题
$font_style='';
if($prev_rel[0]['title_color']||$prev_rel[0]['title_style']){
$font_style.=empty($prev_rel[0]['title_color'])?'':'color:'.$prev_rel[0]['title_color'].';';
if($prev_rel[0]['title_style']==1){
$font_style.='font-weight:bold;';
}elseif($prev_rel[0]['title_style']==2){
$font_style.='font-style:italic;';
}elseif($prev_rel[0]['title_style']==3){
$font_style.='text-decoration:underline;';
}
$prev_rel[0]['style'] = $font_style;
$prev_rel[0]['style_title']=$prev_rel[0]['title'];//样式标题
}else{
$prev_rel[0]['style_title']=$prev_rel[0]['title'];
}
$prev_rel[0]['tbpic']=empty($prev_rel[0]['tbpic'])?'no_pc.gif':$prev_rel[0]['tbpic'];
$p_rel['thumb_pic']=CMS_URL.'upload/'.$prev_rel[0]['tbpic'];//图片
$url=(!($_confing['web_rewrite']))?$path.$content_php.'?id='.$prev_rel[0]['id']:$path.$channel_info['channel_mark'].'/'.$prev_rel[0]['id'].'.html';
$next_is=isset($next_rel[0]['is_url'])?$next_rel[0]['is_url']:'';
$url=($next_is)?$next_rel[0]['url_add']:$url;
$font_style=empty($font_style)?'':'style="'.$font_style.'"';
$p_rel['font_style']=$font_style;
$p_rel['url']=$url;
$p_rel['tit