<?php

/*《-----------------------------------------大类操作类-----------------------------------------------》*/
//所有大类查询,带分页
function category_query_page($db,$page)
	{
			global $prepage,$nextpage,$pages,$rows_count;
			$category_query=new mysql_db();
			$category_query->table=$db."article_category";  
			$category_query->table_where="1"; 
			$category_query->page_size="10";  
			$category_query->table_mod="6";   
			$category_query->page=$page;
			$category_query->query();
			
			$prepage=$category_query->prepage;
			$nextpage=$category_query->nextpage;
			$pages=$category_query->pages;
			$rows_count=$category_query->rows_count;

			$category_query->table_mod="5"; 
			$category_query->table_where="1";     
			$category_query->query_object="*"; 
			$category_query->order_by="Id asc";
			$category_query->query();
			$rows=$category_query->rows;
			for($i=0;$i<$rows;$i++)
			{ 
				$category_query->query_result();
				$channel_record=channel_query($category_query->record['channel'],$db);
				$category_record_page[] = array("Id"=>$category_query->record['Id'], 
								  				"name"=>$category_query->record['name'],
												"channel_name"=>$channel_record['name'],
								  				"Is_sub"=>$category_query->record['Is_sub'],
								  				"channel"=>$category_query->record['channel']
								   				); 
			} 
			return($category_record_page);
			$category_query=NULL;
	}
//所有大类查询,不带分页
function category_query_all($db)
	{
				$category_query=new mysql_db();
				$category_query->table=$db."article_category"; 
				$category_query->table_mod="5"; 
				$category_query->table_where="1";
				$category_query->limit="0";       
				$category_query->page_size="50";
				$category_query->query_object="*"; 
				$category_query->order_by="Id asc";
				$category_query->query();
				$rows=$category_query->rows;
				for($i=0;$i<$rows;$i++){
					$category_query->query_result();
					$channel_record=channel_query($category_query->record['channel'],$db);
								$category_all_record[] = array("Id"=>$category_query->record['Id'], 
									  					      "name"=>$category_query->record['name'],
															  "channel_name"=>$channel_record['name'],
															  "channel"=>$category_query->record['channel'],
															  "Is_sub"=>$category_query->record['Is_sub']
															  ); 
					}
				return($category_all_record);
				$category_query=NULL;
	}
//返回同一频道的大类
function category_query_channel($db,$channel)
	{
				$category_query=new mysql_db();
				$category_query->table=$db."article_category"; 
				$category_query->table_mod="5"; 
				$category_query->table_where="channel=$channel";
				$category_query->limit="0";       
				$category_query->page_size="50";
				$category_query->query_object="*"; 
				$category_query->order_by="Id asc";
				$category_query->query();
				$rows=$category_query->rows;
				for($i=0;$i<$rows;$i++){
					$category_query->query_result();
					$channel_record=channel_query($category_query->record['channel'],$db);
								$category_all_record[] = array("Id"=>$category_query->record['Id'], 
									  					      "name"=>$category_query->record['name'],
															  "channel_name"=>$channel_record['name'],
															  "channel"=>$category_query->record['channel'],
															  "Is_sub"=>$category_query->record['Is_sub']
															  ); 
					}
				return($category_all_record);
				$category_query=NULL;
	}
//返回同一频道的大类,只允许有下级分类
function category_query_channel_yes($db,$channel)
	{
				$category_query=new mysql_db();
				$category_query->table=$db."article_category"; 
				$category_query->table_mod="5"; 
				$category_query->table_where="channel=$channel and Is_sub=1";
				$category_query->limit="0";       
				$category_query->page_size="50";
				$category_query->query_object="*"; 
				$category_query->order_by="Id asc";
				$category_query->query();
				$rows=$category_query->rows;
				for($i=0;$i<$rows;$i++){
					$category_query->query_result();
					$channel_record=channel_query($category_query->record['channel'],$db);
								$category_all_record[] = array("Id"=>$category_query->record['Id'], 
									  					      "name"=>$category_query->record['name'],
															  "channel_name"=>$channel_record['name'],
															  "channel"=>$category_query->record['channel'],
															  "Is_sub"=>$category_query->record['Is_sub']
															  ); 
					}
				return($category_all_record);
				$category_query=NULL;
	}
//所有大类查询，返回一条记录
function category_query_one($id,$db)
	{
				$category_query=new mysql_db();
				$category_query->table=$db."article_category"; 
				$category_query->table_mod="5"; 
				$category_query->table_where="Id=$id";
				$category_query->limit="0";       
				$category_query->page_size="1";
				$category_query->query_object="*"; 
				$category_query->order_by="Id asc";
				$category_query->query();
				$rows=$category_query->rows;
				$category_query->query_result();
				$channel_record=channel_query($category_query->record['channel'],$db);
				$category_record = array("Id"=>$category_query->record['Id'], 
									  	 "name"=>$category_query->record['name'],
										 "channel_name"=>$channel_record['name'],
										 "channel"=>$category_query->record['channel'],
										 "Is_sub"=>$category_query->record['Is_sub']
										 ); 
				return($category_record);
				$category_query=NULL;
	}
	
	
//所有大类查询,不允许有下级分类
function category_query_all_no($db)
	{
				$category_query=new mysql_db();
				$category_query->table=$db."article_category"; 
				$category_query->table_mod="5"; 
				$category_query->table_where="Is_sub=0";
				$category_query->limit="0";       
				$category_query->page_size="50";
				$category_query->query_object="*"; 
				$category_query->order_by="Id asc";
				$category_query->query();
				$rows=$category_query->rows;
				for($i=0;$i<$rows;$i++){
					$category_query->query_result();
					$channel_record=channel_query($category_query->record['channel'],$db);
								$category_all_record[] = array("Id"=>$category_query->record['Id'], 
									  					      "name"=>$category_query->record['name'],
															  "channel_name"=>$channel_record['name'],
															  "channel"=>$category_query->record['channel'],
															  "Is_sub"=>$category_query->record['Is_sub']
															  ); 
					}
				return($category_all_record);
				$category_query=NULL;
	}	
	
//所有大类查询,只允许有下级分类
function category_query_all_yes($db)
	{
				$category_query=new mysql_db();
				$category_query->table=$db."article_category"; 
				$category_query->table_mod="5"; 
				$category_query->table_where="Is_sub=1";
				$category_query->limit="0";       
				$category_query->page_size="50";
				$category_query->query_object="*"; 
				$category_query->order_by="Id asc";
				$category_query->query();
				$rows=$category_query->rows;
				for($i=0;$i<$rows;$i++){
					$category_query->query_result();
					$channel_record=channel_query($category_query->record['channel'],$db);
								$category_all_record[] = array("Id"=>$category_query->record['Id'], 
									  					      "name"=>$category_query->record['name'],
															  "channel_name"=>$channel_record['name'],
															  "channel"=>$category_query->record['channel'],
															  "Is_sub"=>$category_query->record['Is_sub']
															  ); 
					}
				return($category_all_record);
				$category_query=NULL;
	}	
	
/*《-----------------------------------------小类操作类-----------------------------------------------》*/


//所有小类查询,带分页
function sub_category_query_page($db,$page)
	{
			global $prepage,$nextpage,$pages,$rows_count;
			$sub_category_query=new mysql_db();
			$sub_category_query->table=$db."article_sub_category";  
			$sub_category_query->table_where="1"; 
			$sub_category_query->page_size="10";  
			$sub_category_query->table_mod="6";   
			$sub_category_query->page=$page;
			$sub_category_query->query();
			
			$prepage=$sub_category_query->prepage;
			$nextpage=$sub_category_query->nextpage;
			$pages=$sub_category_query->pages;
			$rows_count=$sub_category_query->rows_count;

			$sub_category_query->table_mod="5"; 
			$sub_category_query->table_where="1";     
			$sub_category_query->query_object="*"; 
			$sub_category_query->order_by="Id asc";
			$sub_category_query->query();
			$rows=$sub_category_query->rows;
			for($i=0;$i<$rows;$i++)
			{ 
				$sub_category_query->query_result();
				$category_record=category_query_one($sub_category_query->record['category'],$db);
				$sub_category_record_page[] = array("Id"=>$sub_category_query->record['Id'], 
								  				"name"=>$sub_category_query->record['name'],
												"category"=>$sub_category_query->record['category'],
								  				"category_name"=>$category_record['name'],
								  				"channel"=>$sub_category_query->record['channel']
								   				); 
			} 
			return($sub_category_record_page);
			$sub_category_query=NULL;
	}
//所有小类查询,不带分页
function sub_category_query_all($db)
	{
				$sub_category_query=new mysql_db();
				$sub_category_query->table=$db."article_sub_category"; 
				$sub_category_query->table_mod="5"; 
				$sub_category_query->table_where="1";
				$sub_category_query->limit="0";       
				$sub_category_query->page_size="50";
				$sub_category_query->query_object="*"; 
				$sub_category_query->order_by="category asc";
				$sub_category_query->query();
				$rows=$sub_category_query->rows;
				for($i=0;$i<$rows;$i++){
					$sub_category_query->query_result();
				    $category_record=category_query_one($sub_category_query->record['category'],$db);
								$sub_category_record[] = array("Id"=>$sub_category_query->record['Id'], 
								  								"name"=>$sub_category_query->record['name'],
																"category"=>$sub_category_query->record['category'],
								  								"category_name"=>$category_record['name'],
								  								"channel"=>$sub_category_query->record['channel']
								   								);
				
					}
				return($sub_category_record);
				$sub_category_query=NULL;
	}
//所有小类查询，返回一条记录
function sub_category_query_one($id,$db)
	{
				$sub_category_query=new mysql_db();
				$sub_category_query->table=$db."article_sub_category"; 
				$sub_category_query->table_mod="5"; 
				$sub_category_query->table_where="Id=$id";
				$sub_category_query->limit="0";       
				$sub_category_query->page_size="1";
				$sub_category_query->query_object="*"; 
				$sub_category_query->order_by="Id asc";
				$sub_category_query->query();
				$rows=$sub_category_query->rows;
				$sub_category_query->query_result();
				$category_record=category_query_one($sub_category_query->record['category'],$db);
				$sub_category_record = array("Id"=>$sub_category_query->record['Id'], 
								  		 "name"=>$sub_category_query->record['name'],
										 "category"=>$sub_category_query->record['category'],
								  		 "category_name"=>$category_record['name'],
								  		 "channel"=>$sub_category_query->record['channel']
								   		 );
				return($sub_category_record);
				$sub_category_query=NULL;
	}
//返回同一频道的小类,不带分页
function sub_category_query_channel($db,$channel)
	{
				$sub_category_query=new mysql_db();
				$sub_category_query->table=$db."article_sub_category"; 
				$sub_category_query->table_mod="5"; 
				$sub_category_query->table_where="channel=$channel";
				$sub_category_query->limit="0";       
				$sub_category_query->page_size="50";
				$sub_category_query->query_object="*"; 
				$sub_category_query->order_by="Id asc";
				$sub_category_query->query();
				$rows=$sub_category_query->rows;
				for($i=0;$i<$rows;$i++){
					$sub_category_query->query_result();
				    $category_record=category_query_one($sub_category_query->record['category'],$db);
								$sub_category_record[] = array("Id"=>$sub_category_query->record['Id'], 
								  								"name"=>$sub_category_query->record['name'],
																"category"=>$sub_category_query->record['category'],
								  								"category_name"=>$category_record['name'],
								  								"channel"=>$sub_category_query->record['channel']
								   								);
				
					}
				return($sub_category_record);
				$sub_category_query=NULL;
	}
//返回同一大类的小类,单个大类时有效
function sub_category_query_category($db,$category)
	{
				$sub_category_query=new mysql_db();
				$sub_category_query->table=$db."article_sub_category"; 
				$sub_category_query->table_mod="5"; 
				$sub_category_query->table_where="category=$category";
				$sub_category_query->limit="0";       
				$sub_category_query->page_size="20";
				$sub_category_query->query_object="*"; 
				$sub_category_query->order_by="Id asc";
				$sub_category_query->query();
				$rows=$sub_category_query->rows;
				for($i=0;$i<$rows;$i++){
					$sub_category_query->query_result();
				    $category_record=category_query_one($sub_category_query->record['category'],$db);
								$sub_category_record[] = array("Id"=>$sub_category_query->record['Id'], 
								  								"name"=>$sub_category_query->record['name'],
																"category"=>$sub_category_query->record['category'],
								  								"category_name"=>$category_record['name'],
								  								"channel"=>$sub_category_query->record['channel']
								   								);
				
					}
				return($sub_category_record);
				$sub_category_query=NULL;
	}













/*《-----------------------------------------频道操作类-----------------------------------------------》*/

//新闻频道查询不带分页,非专题
function channel_query_category($db)
	{
				$channel_query=new mysql_db();
				$channel_query->table=$db."channel"; 
				$channel_query->table_mod="5"; 
				$channel_query->table_where="channel=0 and is_zt=0";
				$channel_query->limit="0";       
				$channel_query->page_size="50";
				$channel_query->query_object="*"; 
				$channel_query->order_by="id asc";
				$channel_query->query();
				$rows=$channel_query->rows;
				for($i=0;$i<$rows;$i++){
					$channel_query->query_result();
								$channel_all_record[] = array("id"=>$channel_query->record['Id'], 
									  					      "name"=>$channel_query->record['name'],
															  "channel"=>$channel_query->record['channel'],
															  ); 
					}
				return($channel_all_record);
				$channel_query=NULL;
	}
//专题查询
function channel_query_category_zt($db)
	{
				$channel_query=new mysql_db();
				$channel_query->table=$db."channel"; 
				$channel_query->table_mod="5"; 
				$channel_query->table_where="channel=0 and is_zt=1";
				$channel_query->limit="0";       
				$channel_query->page_size="50";
				$channel_query->query_object="*"; 
				$channel_query->order_by="id asc";
				$channel_query->query();
				$rows=$channel_query->rows;
				for($i=0;$i<$rows;$i++){
					$channel_query->query_result();
								$channel_all_record[] = array("id"=>$channel_query->record['Id'], 
									  					      "name"=>$channel_query->record['name'],
															  "channel"=>$channel_query->record['channel'],
															  ); 
					}
				return($channel_all_record);
				$channel_query=NULL;
	}
/*《-----------------------------------------文章操作类-----------------------------------------------》*/

//所有文章查询,带分页
function info_query_page($db,$page)
	{
			global $prepage,$nextpage,$pages,$rows_count;
			$info_query=new mysql_db();
			$info_query->table=$db."article_info";  
			$info_query->table_where="1"; 
			$info_query->page_size="10";  
			$info_query->table_mod="6";   
			$info_query->page=$page;
			$info_query->query();
			
			$prepage=$info_query->prepage;
			$nextpage=$info_query->nextpage;
			$pages=$info_query->pages;
			$rows_count=$info_query->rows_count;

			$info_query->table_mod="5"; 
			$info_query->table_where="1";     
			$info_query->query_object="*"; 
			$info_query->order_by="Id asc";
			$info_query->query();
			$rows=$info_query->rows;
			for($i=0;$i<$rows;$i++)
			{ 
				$info_query->query_result();
				$text=str_transforms($info_query->record['Text']);
				if (!empty($info_query->record['Cate_id'])){
					$category_record=sub_category_query_one($info_query->record['Cate_id'],$db);
					$big_cate_id=$info_query->record['big_cate_id'];
					$channel=$info_query->record['channel'];
					$Cate_id=$info_query->record['Cate_id'];
				}else{
					if($info_query->record['typefile']==1){
						$channel_name=channel_query($info_query->record['channel'],$db);
						$category_record['name']="[专题]".$channel_name['name'];
						$Cate_id="zt";
						$big_cate_id="zt";
						$channel=$info_query->record['channel'];
					}else if($info_query->record['typefile']==2){
						$category_big_name_record=category_query_one($info_query->record['big_cate_id'],$db);
						$category_record['name']="[独立大类]".$category_big_name_record['name'];
						$Cate_id="dl";
						$big_cate_id=$info_query->record['big_cate_id'];
						$channel=$info_query->record['channel'];
					}
				}
				$info_record[]= array("Id"=>$info_query->record['Id'], 
									  "Title"=>$info_query->record['Title'],
									  "Description"=>$info_query->record['Description'],
									  "Text"=>$text, 
									  "Add_date"=>$info_query->record['Add_date'],
									  "Picture"=>$info_query->record['Picture'],
									  "Up_File"=>$info_query->record['Up_File'],
									  "Review"=>$info_query->record['Review'],
									  "author"=>$info_query->record['author'],
									  "source"=>$info_query->record['source'],
									  "Hit"=>$info_query->record['Hit'],
									  "Hot"=>$info_query->record['Hot'],
									  "TOP"=>$info_query->record['TOP'],
									  "Recommend"=>$info_query->record['Recommend'],
								      "Cate_id"=>$Cate_id,
									  "Flash_file"=>$info_query->record['Flash_file'],
									  "channel"=>$channel,
									  "big_cate_id"=>$big_cate_id,
									  "typefile"=>$info_query->record['typefile'],     //类型：0:默认1:专题;2:大类独
									  "category_name"=>$category_record['name']        //小类名称									 
										 ); 
			} 
			return($info_record);
			$info_query=NULL;
	}
//所有文章查询,不带分页
function info_query_all($db)
	{
				$info_query=new mysql_db();
				$info_query->table=$db."article_info"; 
				$info_query->table_mod="5"; 
				$info_query->table_where="1";
				$info_query->limit="0";       
				$info_query->page_size="50";
				$info_query->query_object="*"; 
				$info_query->order_by="Id asc";
				$info_query->query();
				$rows=$info_query->rows;
				for($i=0;$i<$rows;$i++){
					$info_query->query_result();
				$text=str_transforms($info_query->record['Text']);
				if (!empty($info_query->record['Cate_id'])){
					$category_record=sub_category_query_one($info_query->record['Cate_id'],$db);
					$big_cate_id=$info_query->record['big_cate_id'];
					$channel=$info_query->record['channel'];
					$Cate_id=$info_query->record['Cate_id'];
				}else{
					if($info_query->record['typefile']==1){
						$channel_name=channel_query($info_query->record['channel'],$db);
						$category_record['name']="[专题]".$channel_name['name'];
						$Cate_id="zt";
						$big_cate_id="zt";
						$channel=$info_query->record['channel'];
					}else if($info_query->record['typefile']==2){
						$category_big_name_record=category_query_one($info_query->record['big_cate_id'],$db);
						$category_record['name']="[独立大类]".$category_big_name_record['name'];
						$Cate_id="dl";
						$big_cate_id=$info_query->record['big_cate_id'];
						$channel=$info_query->record['channel'];
					}
				}
				$info_record[] = array("Id"=>$info_query->record['Id'], 
									  "Title"=>$info_query->record['Title'],
									  "Description"=>$info_query->record['Description'],
									  "Text"=>$text, 
									  "Add_date"=>$info_query->record['Add_date'],
									  "Picture"=>$info_query->record['Picture'],
									  "Up_File"=>$info_query->record['Up_File'],
									  "Review"=>$info_query->record['Review'],
									  "author"=>$info_query->record['author'],
									  "source"=>$info_query->record['source'],
									  "Hit"=>$info_query->record['Hit'],
									  "Hot"=>$info_query->record['Hot'],
									  "TOP"=>$info_query->record['TOP'],
									  "Recommend"=>$info_query->record['Recommend'],
								      "Cate_id"=>$Cate_id,
									  "Flash_file"=>$info_query->record['Flash_file'],
									  "channel"=>$channel,
									  "big_cate_id"=>$big_cate_id,
									  "typefile"=>$info_query->record['typefile'],     //类型：0:默认1:专题;2:大类独
									  "category_name"=>$category_record['name']        //小类名称									 
										 ); 
					}
				return($info_record);
				$info_query=NULL;
	}
//所有文章查询，返回一条记录
function info_query_one($id,$db)
	{
				$info_query=new mysql_db();
				$info_query->table=$db."article_info"; 
				$info_query->table_mod="5"; 
				$info_query->table_where="Id=$id";
				$info_query->limit="0";       
				$info_query->page_size="1";
				$info_query->query_object="*"; 
				$info_query->order_by="Id asc";
				$info_query->query();
				$rows=$info_query->rows;
				$info_query->query_result();
				$text=str_transforms($info_query->record['Text']);
				if (!empty($info_query->record['Cate_id'])){
					$category_record=sub_category_query_one($info_query->record['Cate_id'],$db);
					$big_cate_id=$info_query->record['big_cate_id'];
					$channel=$info_query->record['channel'];
					$Cate_id=$info_query->record['Cate_id'];
				}else{
					if($info_query->record['typefile']==1){
						$channel_name=channel_query($info_query->record['channel'],$db);
						$category_record['name']="[专题]".$channel_name['name'];
						$Cate_id="zt";
						$big_cate_id="zt";
						$channel=$info_query->record['channel'];
					}else if($info_query->record['typefile']==2){
						$category_big_name_record=category_query_one($info_query->record['big_cate_id'],$db);
						$category_record['name']="[独立大类]".$category_big_name_record['name'];
						$Cate_id="dl";
						$big_cate_id=$info_query->record['big_cate_id'];
						$channel=$info_query->record['channel'];
					}
				}
				$info_record = array("Id"=>$info_query->record['Id'], 
									  "Title"=>$info_query->record['Title'],
									  "Description"=>$info_query->record['Description'],
									  "Text"=>$text, 
									  "Add_date"=>$info_query->record['Add_date'],
									  "Picture"=>$info_query->record['Picture'],
									  "Up_File"=>$info_query->record['Up_File'],
									  "Review"=>$info_query->record['Review'],
									  "author"=>$info_query->record['author'],
									  "source"=>$info_query->record['source'],
									  "Hit"=>$info_query->record['Hit'],
									  "Hot"=>$info_query->record['Hot'],
									  "TOP"=>$info_query->record['TOP'],
									  "Recommend"=>$info_query->record['Recommend'],
								      "Cate_id"=>$Cate_id,
									  "Flash_file"=>$info_query->record['Flash_file'],
									  "channel"=>$channel,
									  "big_cate_id"=>$big_cate_id,
									  "typefile"=>$info_query->record['typefile'],     //类型：0:默认1:专题;2:大类独
									  "category_name"=>$category_record['name']        //小类名称									 
										 ); 
				return($info_record);
				$category_query=NULL;
	}
//所有当前频道文章查询,带分页
function info_query_page_channel($db,$page,$channel)
	{
			global $prepage,$nextpage,$pages,$rows_count;
			$info_query=new mysql_db();
			$info_query->table=$db."article_info";  
			$info_query->table_where="channel=$channel"; 
			$info_query->page_size="10";  
			$info_query->table_mod="6";   
			$info_query->page=$page;
			$info_query->query();
			
			$prepage=$info_query->prepage;
			$nextpage=$info_query->nextpage;
			$pages=$info_query->pages;
			$rows_count=$info_query->rows_count;

			$info_query->table_mod="5"; 
			$info_query->table_where="1";     
			$info_query->query_object="*"; 
			$info_query->order_by="Id asc";
			$info_query->query();
			$rows=$info_query->rows;
			for($i=0;$i<$rows;$i++)
			{ 
				$info_query->query_result();
				$text=str_transforms($info_query->record['Text']);
				if (!empty($info_query->record['Cate_id'])){
					$category_record=sub_category_query_one($info_query->record['Cate_id'],$db);
					$big_cate_id=$info_query->record['big_cate_id'];
					$channel=$info_query->record['channel'];
					$Cate_id=$info_query->record['Cate_id'];
				}else{
					if($info_query->record['typefile']==1){
						$channel_name=channel_query($info_query->record['channel'],$db);
						$category_record['name']="[专题]".$channel_name['name'];
						$Cate_id="zt";
						$big_cate_id="zt";
						$channel=$info_query->record['channel'];
					}else if($info_query->record['typefile']==2){
						$category_big_name_record=category_query_one($info_query->record['big_cate_id'],$db);
						$category_record['name']="[独立大类]".$category_big_name_record['name'];
						$Cate_id="dl";
						$big_cate_id=$info_query->record['big_cate_id'];
						$channel=$info_query->record['channel'];
					}
				}
				$info_record[]= array("Id"=>$info_query->record['Id'], 
									  "Title"=>$info_query->record['Title'],
									  "Description"=>$info_query->record['Description'],
									  "Text"=>$text, 
									  "Add_date"=>$info_query->record['Add_date'],
									  "Picture"=>$info_query->record['Picture'],
									  "Up_File"=>$info_query->record['Up_File'],
									  "Review"=>$info_query->record['Review'],
									  "author"=>$info_query->record['author'],
									  "source"=>$info_query->record['source'],
									  "Hit"=>$info_query->record['Hit'],
									  "Hot"=>$info_query->record['Hot'],
									  "TOP"=>$info_query->record['TOP'],
									  "Recommend"=>$info_query->record['Recommend'],
								      "Cate_id"=>$Cate_id,
									  "Flash_file"=>$info_query->record['Flash_file'],
									  "channel"=>$channel,
									  "big_cate_id"=>$big_cate_id,
									  "typefile"=>$info_query->record['typefile'],     //类型：0:默认1:专题;2:大类独
									  "category_name"=>$category_record['name']        //小类名称									 
										 ); 
			} 
			return($info_record);
			$info_query=NULL;
	}
//所有文章查询,最新记录20个
function info_query_new_channel($db,$channel)
	{
				$info_query=new mysql_db();
				$info_query->table=$db."article_info"; 
				$info_query->table_mod="5"; 
				$info_query->table_where="channel=$channel";
				$info_query->limit="0";       
				$info_query->page_size="20";
				$info_query->query_object="*"; 
				$info_query->order_by="Id asc";
				$info_query->query();
				$rows=$info_query->rows;
				for($i=0;$i<$rows;$i++){
					$info_query->query_result();
				$text=str_transforms($info_query->record['Text']);
				if (!empty($info_query->record['Cate_id'])){
					$category_record=sub_category_query_one($info_query->record['Cate_id'],$db);
					$big_cate_id=$info_query->record['big_cate_id'];
					$channel=$info_query->record['channel'];
					$Cate_id=$info_query->record['Cate_id'];
				}else{
					if($info_query->record['typefile']==1){
						$channel_name=channel_query($info_query->record['channel'],$db);
						$category_record['name']="[专题]".$channel_name['name'];
						$Cate_id="zt";
						$big_cate_id="zt";
						$channel=$info_query->record['channel'];
					}else if($info_query->record['typefile']==2){
						$category_big_name_record=category_query_one($info_query->record['big_cate_id'],$db);
						$category_record['name']="[独立大类]".$category_big_name_record['name'];
						$Cate_id="dl";
						$big_cate_id=$info_query->record['big_cate_id'];
						$channel=$info_query->record['channel'];
					}
				}
				$info_record[] = array("Id"=>$info_query->record['Id'], 
									  "Title"=>$info_query->record['Title'],
									  "Description"=>$info_query->record['Description'],
									  "Text"=>$text, 
									  "Add_date"=>$info_query->record['Add_date'],
									  "Picture"=>$info_query->record['Picture'],
									  "Up_File"=>$info_query->record['Up_File'],
									  "Review"=>$info_query->record['Review'],
									  "author"=>$info_query->record['author'],
									  "source"=>$info_query->record['source'],
									  "Hit"=>$info_query->record['Hit'],
									  "Hot"=>$info_query->record['Hot'],
									  "TOP"=>$info_query->record['TOP'],
									  "Recommend"=>$info_query->record['Recommend'],
								      "Cate_id"=>$Cate_id,
									  "Flash_file"=>$info_query->record['Flash_file'],
									  "channel"=>$channel,
									  "big_cate_id"=>$big_cate_id,
									  "typefile"=>$info_query->record['typefile'],     //类型：0:默认1:专题;2:大类独
									  "category_name"=>$category_record['name']        //小类名称									 
										 ); 
					}
				return($info_record);
				$info_query=NULL;
	}
//所有文章最新10个图片查询
function info_query_pic_channel($db,$channel)
	{
				$info_query=new mysql_db();
				$info_query->table=$db."article_info"; 
				$info_query->table_mod="5"; 
				$info_query->table_where="channel=$channel and Picture<>''";
				$info_query->limit="0";       
				$info_query->page_size="10";
				$info_query->query_object="*"; 
				$info_query->order_by="Id asc";
				$info_query->query();
				$rows=$info_query->rows;
				for($i=0;$i<$rows;$i++){
					$info_query->query_result();
				$text=str_transforms($info_query->record['Text']);
				if (!empty($info_query->record['Cate_id'])){
					$category_record=sub_category_query_one($info_query->record['Cate_id'],$db);
					$big_cate_id=$info_query->record['big_cate_id'];
					$channel=$info_query->record['channel'];
					$Cate_id=$info_query->record['Cate_id'];
				}else{
					if($info_query->record['typefile']==1){
						$channel_name=channel_query($info_query->record['channel'],$db);
						$category_record['name']="[专题]".$channel_name['name'];
						$Cate_id="zt";
						$big_cate_id="zt";
						$channel=$info_query->record['channel'];
					}else if($info_query->record['typefile']==2){
						$category_big_name_record=category_query_one($info_query->record['big_cate_id'],$db);
						$category_record['name']="[独立大类]".$category_big_name_record['name'];
						$Cate_id="dl";
						$big_cate_id=$info_query->record['big_cate_id'];
						$channel=$info_query->record['channel'];
					}
				}
				$info_record[] = array("Id"=>$info_query->record['Id'], 
									  "Title"=>$info_query->record['Title'],
									  "Description"=>$info_query->record['Description'],
									  "Text"=>$text, 
									  "Add_date"=>$info_query->record['Add_date'],
									  "Picture"=>$info_query->record['Picture'],
									  "Up_File"=>$info_query->record['Up_File'],
									  "Review"=>$info_query->record['Review'],
									  "author"=>$info_query->record['author'],
									  "source"=>$info_query->record['source'],
									  "Hit"=>$info_query->record['Hit'],
									  "Hot"=>$info_query->record['Hot'],
									  "TOP"=>$info_query->record['TOP'],
									  "Recommend"=>$info_query->record['Recommend'],
								      "Cate_id"=>$Cate_id,
									  "Flash_file"=>$info_query->record['Flash_file'],
									  "channel"=>$channel,
									  "big_cate_id"=>$big_cate_id,
									  "typefile"=>$info_query->record['typefile'],     //类型：0:默认1:专题;2:大类独
									  "category_name"=>$category_record['name']        //小类名称									 
										 ); 
					}
				return($info_record);
				$info_query=NULL;
	}
//所有当前大类文章查询,带分页
function info_query_page_big_category($db,$page,$channel,$id)
	{
			global $prepage,$nextpage,$pages,$rows_count;
			$info_query=new mysql_db();
			$info_query->table=$db."article_info";  
			$info_query->table_where="channel=$channel and big_cate_id=$id"; 
			$info_query->page_size="10";  
			$info_query->table_mod="6";   
			$info_query->page=$page;
			$info_query->query();
			
			$prepage=$info_query->prepage;
			$nextpage=$info_query->nextpage;
			$pages=$info_query->pages;
			$rows_count=$info_query->rows_count;

			$info_query->table_mod="5"; 
			$info_query->table_where="channel=$channel and big_cate_id=$id";     
			$info_query->query_object="*"; 
			$info_query->order_by="Id asc";
			$info_query->query();
			$rows=$info_query->rows;
			for($i=0;$i<$rows;$i++)
			{ 
				$info_query->query_result();
				$text=str_transforms($info_query->record['Text']);
				if (!empty($info_query->record['Cate_id'])){
					$category_record=sub_category_query_one($info_query->record['Cate_id'],$db);
					$big_cate_id=$info_query->record['big_cate_id'];
					$channel=$info_query->record['channel'];
					$Cate_id=$info_query->record['Cate_id'];
				}else{
					if($info_query->record['typefile']==1){
						$channel_name=channel_query($info_query->record['channel'],$db);
						$category_record['name']="[专题]".$channel_name['name'];
						$Cate_id="zt";
						$big_cate_id="zt";
						$channel=$info_query->record['channel'];
					}else if($info_query->record['typefile']==2){
						$category_big_name_record=category_query_one($info_query->record['big_cate_id'],$db);
						$category_record['name']="[独立大类]".$category_big_name_record['name'];
						$Cate_id="dl";
						$big_cate_id=$info_query->record['big_cate_id'];
						$channel=$info_query->record['channel'];
					}
				}
				$info_record[]= array("Id"=>$info_query->record['Id'], 
									  "Title"=>$info_query->record['Title'],
									  "Description"=>$info_query->record['Description'],
									  "Text"=>$text, 
									  "Add_date"=>$info_query->record['Add_date'],
									  "Picture"=>$info_query->record['Picture'],
									  "Up_File"=>$info_query->record['Up_File'],
									  "Review"=>$info_query->record['Review'],
									  "author"=>$info_query->record['author'],
									  "source"=>$info_query->record['source'],
									  "Hit"=>$info_query->record['Hit'],
									  "Hot"=>$info_query->record['Hot'],
									  "TOP"=>$info_query->record['TOP'],
									  "Recommend"=>$info_query->record['Recommend'],
									  "Cate_id"=>$Cate_id,
									  "Flash_file"=>$info_query->record['Flash_file'],
									  "channel"=>$channel,
									  "big_cate_id"=>$big_cate_id,
									  "typefile"=>$info_query->record['typefile'],     //类型：0:默认1:专题;2:大类独立
									  "category_name"=>$category_record['name']        //小类名称									 
										 ); 
			} 
			return($info_record);
			$info_query=NULL;
	}
	
//所有文章查询,不带分页的专题,25个专题
function info_query_zt_all($db,$channel)
	{
				$info_query=new mysql_db();
				$info_query->table=$db."article_info"; 
				$info_query->table_mod="5"; 
				$info_query->table_where="channel=$channel and typefile=1";
				$info_query->limit="0";       
				$info_query->page_size="25";
				$info_query->query_object="*"; 
				$info_query->order_by="Id asc";
				$info_query->query();
				$rows=$info_query->rows;
				for($i=0;$i<$rows;$i++){
					$info_query->query_result();
				$text=str_transforms($info_query->record['Text']);
				if (!empty($info_query->record['Cate_id'])){
					$category_record=sub_category_query_one($info_query->record['Cate_id'],$db);
					$big_cate_id=$info_query->record['big_cate_id'];
					$channel=$info_query->record['channel'];
					$Cate_id=$info_query->record['Cate_id'];
				}else{
					if($info_query->record['typefile']==1){
						$channel_name=channel_query($info_query->record['channel'],$db);
						$category_record['name']="[专题]".$channel_name['name'];
						$Cate_id="zt";
						$big_cate_id="zt";
						$channel=$info_query->record['channel'];
					}else if($info_query->record['typefile']==2){
						$category_big_name_record=category_query_one($info_query->record['big_cate_id'],$db);
						$category_record['name']="[独立大类]".$category_big_name_record['name'];
						$Cate_id="dl";
						$big_cate_id=$info_query->record['big_cate_id'];
						$channel=$info_query->record['channel'];
					}
				}
				$info_record[] = array("Id"=>$info_query->record['Id'], 
									  "Title"=>$info_query->record['Title'],
									  "Description"=>$info_query->record['Description'],
									  "Text"=>$text, 
									  "Add_date"=>$info_query->record['Add_date'],
									  "Picture"=>$info_query->record['Picture'],
									  "Up_File"=>$info_query->record['Up_File'],
									  "Review"=>$info_query->record['Review'],
									  "author"=>$info_query->record['author'],
									  "source"=>$info_query->record['source'],
									  "Hit"=>$info_query->record['Hit'],
									  "Hot"=>$info_query->record['Hot'],
									  "TOP"=>$info_query->record['TOP'],
									  "Recommend"=>$info_query->record['Recommend'],
								      "Cate_id"=>$Cate_id,
									  "Flash_file"=>$info_query->record['Flash_file'],
									  "channel"=>$channel,
									  "big_cate_id"=>$big_cate_id,
									  "typefile"=>$info_query->record['typefile'],     //类型：0:默认1:专题;2:大类独
									  "category_name"=>$category_record['name']        //小类名称									 
										 ); 
					}
				return($info_record);
				$info_query=NULL;
	}
	
//专题查询,返回一条记录，随机型
function info_query_one_zt($db,$channel)
	{
				$info_query=new mysql_db();
				$info_query->table=$db."article_info"; 
				$info_query->table_mod="5"; 
				$info_query->table_where="channel=$channel and typefile=1";
				$info_query->limit="0";       
				$info_query->page_size="1";
				$info_query->query_object="*"; 
				$info_query->order_by="Id asc";
				$info_query->query();
				$rows=$info_query->rows;
				$info_query->query_result();
				$text=str_transforms($info_query->record['Text']);
				if (!empty($info_query->record['Cate_id'])){
					$category_record=sub_category_query_one($info_query->record['Cate_id'],$db);
					$big_cate_id=$info_query->record['big_cate_id'];
					$channel=$info_query->record['channel'];
					$Cate_id=$info_query->record['Cate_id'];
				}else{
					if($info_query->record['typefile']==1){
						$channel_name=channel_query($info_query->record['channel'],$db);
						$category_record['name']="[专题]".$channel_name['name'];
						$Cate_id="zt";
						$big_cate_id="zt";
						$channel=$info_query->record['channel'];
					}else if($info_query->record['typefile']==2){
						$category_big_name_record=category_query_one($info_query->record['big_cate_id'],$db);
						$category_record['name']="[独立大类]".$category_big_name_record['name'];
						$Cate_id="dl";
						$big_cate_id=$info_query->record['big_cate_id'];
						$channel=$info_query->record['channel'];
					}
				}
				$info_record = array("Id"=>$info_query->record['Id'], 
									  "Title"=>$info_query->record['Title'],
									  "Description"=>$info_query->record['Description'],
									  "Text"=>$text, 
									  "Add_date"=>$info_query->record['Add_date'],
									  "Picture"=>$info_query->record['Picture'],
									  "Up_File"=>$info_query->record['Up_File'],
									  "Review"=>$info_query->record['Review'],
									  "author"=>$info_query->record['author'],
									  "source"=>$info_query->record['source'],
									  "Hit"=>$info_query->record['Hit'],
									  "Hot"=>$info_query->record['Hot'],
									  "TOP"=>$info_query->record['TOP'],
									  "Recommend"=>$info_query->record['Recommend'],
								      "Cate_id"=>$Cate_id,
									  "Flash_file"=>$info_query->record['Flash_file'],
									  "channel"=>$channel,
									  "big_cate_id"=>$big_cate_id,
									  "typefile"=>$info_query->record['typefile'],     //类型：0:默认1:专题;2:大类独
									  "category_name"=>$category_record['name']        //小类名称									 
										 ); 
				return($info_record);
				$category_query=NULL;
	}
//所有当前小类文章查询,带分页
function info_query_page_sub_category($db,$page,$channel,$id)
	{
			global $prepage,$nextpage,$pages,$rows_count;
			$info_query=new mysql_db();
			$info_query->table=$db."article_info";  
			$info_query->table_where="channel=$channel and Cate_id=$id"; 
			$info_query->page_size="10";  
			$info_query->table_mod="6";   
			$info_query->page=$page;
			$info_query->query();
			
			$prepage=$info_query->prepage;
			$nextpage=$info_query->nextpage;
			$pages=$info_query->pages;
			$rows_count=$info_query->rows_count;

			$info_query->table_mod="5"; 
			$info_query->table_where="channel=$channel and Cate_id=$id";     
			$info_query->query_object="*"; 
			$info_query->order_by="Id asc";
			$info_query->query();
			$rows=$info_query->rows;
			for($i=0;$i<$rows;$i++)
			{ 
				$info_query->query_result();
				$text=str_transforms($info_query->record['Text']);
				if (!empty($info_query->record['Cate_id'])){
					$category_record=sub_category_query_one($info_query->record['Cate_id'],$db);
					$big_cate_id=$info_query->record['big_cate_id'];
					$channel=$info_query->record['channel'];
					$Cate_id=$info_query->record['Cate_id'];
				}else{
					if($info_query->record['typefile']==1){
						$channel_name=channel_query($info_query->record['channel'],$db);
						$category_record['name']="[专题]".$channel_name['name'];
						$Cate_id="zt";
						$big_cate_id="zt";
						$channel=$info_query->record['channel'];
					}else if($info_query->record['typefile']==2){
						$category_big_name_record=category_query_one($info_query->record['big_cate_id'],$db);
						$category_record['name']="[独立大类]".$category_big_name_record['name'];
						$Cate_id="dl";
						$big_cate_id=$info_query->record['big_cate_id'];
						$channel=$info_query->record['channel'];
					}
				}
				$info_record[]= array("Id"=>$info_query->record['Id'], 
									  "Title"=>$info_query->record['Title'],
									  "Description"=>$info_query->record['Description'],
									  "Text"=>$text, 
									  "Add_date"=>$info_query->record['Add_date'],
									  "Picture"=>$info_query->record['Picture'],
									  "Up_File"=>$info_query->record['Up_File'],
									  "Review"=>$info_query->record['Review'],
									  "author"=>$info_query->record['author'],
									  "source"=>$info_query->record['source'],
									  "Hit"=>$info_query->record['Hit'],
									  "Hot"=>$info_query->record['Hot'],
									  "TOP"=>$info_query->record['TOP'],
									  "Recommend"=>$info_query->record['Recommend'],
									  "Cate_id"=>$Cate_id,
									  "Flash_file"=>$info_query->record['Flash_file'],
									  "channel"=>$channel,
									  "big_cate_id"=>$big_cate_id,
									  "typefile"=>$info_query->record['typefile'],     //类型：0:默认1:专题;2:大类独立
									  "category_name"=>$category_record['name']        //小类名称									 
										 ); 
			} 
			return($info_record);
			$info_query=NULL;
	}
/*《-----------------------------------------系统调用函数-----------------------------------------------》*/	
//文本转换
function str_transforms($edit_info)
	{
 		$str='"';
 		$new_edit="'";
 		$new_edit_info=str_replace($str, $new_edit, $edit_info);
		//$new_edit_info = html_entity_decode($new_edit_info,ENT_QUOTES,"UTF-8");
		return($new_edit_info);
 	}

//显示信息转换
function info_transforms($edit_info)
	{
		$edit_info = html_entity_decode($edit_info,ENT_QUOTES,"UTF-8");
		return($edit_info);
 	}
//转换选项
function option_convert($str)
	{
		if(1==$str){
			$str_true="checked";
			$str_false="";
		}else
		{
			$str_true="";
			$str_false="checked";
		}
		$convert_str = array("str_false"=>$str_false, 
							 "str_true"=>$str_true
							); 
		return($convert_str);
	}
?>