<?php 

//返回频道管理地址，名称
function definition_type($type)
	{
			if  ($type=="0"){
				$category="文章频道";
				$admin_url="../article/";
			}
			if  ($type=="1"){
				$category="产品频道";
				$admin_url="../product/";
			}
			if  ($type=="2"){
				$category="下载频道";
				$admin_url="../download/";
			}
			if  ($type=="3"){
				$category="图片频道";
				$admin_url="../picture/";
			}
			if  ($type=="4"){
				$category="FLASH视频";
				$admin_url="../flash/";
			}
			if  ($type=="5"){
				$category="在线商城";
				$admin_url="../mall/";
			}
			if  ($type=="6"){
				$category="影视频道";
				$admin_url="../vod/";
			}
			if  ($type=="7"){
				$category="在线问答";
				$admin_url="../question/";
			}
			$definition_type_record = array("category"=>$category, 
									   		 "url"=>$admin_url); 
			return($definition_type_record);
	}
//单一频道查询
function channel_query($id,$db)
	{
				$channel_query=new mysql_db();
				$channel_query->table=$db."channel"; 
				$channel_query->table_mod="5"; 
				$channel_query->table_where="id=$id";
				$channel_query->limit="0";       
				$channel_query->page_size="1";
				$channel_query->query_object="*"; 
				$channel_query->order_by="id asc";
				$channel_query->query();
				$rows=$channel_query->rows;
				$channel_query->query_result();
				$definition_type_record=definition_type($channel_query->record['channel']);
				$channel_record = array("id"=>$channel_query->record['Id'], 
									  	  "name"=>$channel_query->record['name'],
										  "channel_name"=>$definition_type_record['category'],
										  "channel"=>$channel_query->record['channel'],
										 ); 
				return($channel_record);
				$channel_query=NULL;
	}
//所有频道查询,带分页
function channel_query_page($db,$page)
	{
			global $prepage,$nextpage,$pages,$rows_count;
			$channel_query=new mysql_db();
			$channel_query->table=$db."channel";  
			$channel_query->table_where="1"; 
			$channel_query->page_size="10";  
			$channel_query->table_mod="6";   
			$channel_query->page=$page;
			$channel_query->query();
			
			$prepage=$channel_query->prepage;
			$nextpage=$channel_query->nextpage;
			$pages=$channel_query->pages;
			$rows_count=$channel_query->rows_count;

			$channel_query->table_mod="5"; 
			$channel_query->table_where="1";     
			$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();
				$definition_type_record=definition_type($channel_query->record['channel']);
				$channel_record_page[] = array("Id"=>$channel_query->record['Id'], 
								  				"name"=>$channel_query->record['name'],
								  				"type"=>$channel_query->record['type'],
								  				"url"=>$channel_query->record['url'],
												"channel_name"=>$definition_type_record['category'],
												"admin_url"=>$definition_type_record['url'],
								  				"channel"=>$channel_query->record['channel']
								   				); 
			} 
			return($channel_record_page);
			$channel_query=NULL;
	}
	
//查询所有类，不带分页
function channel_query_all($db)
	{
				$channel_query=new mysql_db();
				$channel_query->table=$db."channel"; 
				$channel_query->table_mod="5"; 
				$channel_query->table_where="1";
				$channel_query->limit="0";       
				$channel_query->page_size="50";
				$channel_query->query_object="*"; 
				$channel_query->order_by="channel asc";
				$channel_query->query();
				$rows=$channel_query->rows;
				for($i=0;$i<$rows;$i++){
					$channel_query->query_result();
					$definition_type_record=definition_type($channel_query->record['channel']);
					$channel_all_record[] = array("id"=>$channel_query->record['Id'], 
									  			  "name"=>$channel_query->record['name'],
												  "channel_name"=>$definition_type_record['category'],
												  "admin_url"=>$definition_type_record['url'],
												  "channel"=>$channel_query->record['channel'],
												  "is_zt"=>$channel_query->record['is_zt'],  
												  ); 
					}
				return($channel_all_record);
				$channel_query=NULL;
	}

//友情连接，不带分页
function Links_query_all($db)
{
	$channel_query=new mysql_db();
	$channel_query->table=$db."Links"; 
	$channel_query->table_mod="5"; 
	$channel_query->table_where="1";
	$channel_query->limit="0";       
	$channel_query->page_size="100";
	$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'], 
									  "Linkname"=>$channel_query->record['Linkname'],
									  "LinkUrl"=>$channel_query->record['LinkUrl'],
									  ); 
		}
	return($channel_all_record);
	$channel_query=NULL;
}	
	
//友情连接,带分页
function Links_query_page($db,$page)
{
			global $prepage,$nextpage,$pages,$rows_count;
			$channel_query=new mysql_db();
			$channel_query->table=$db."Links";  
			$channel_query->table_where="1"; 
			$channel_query->page_size="10";  
			$channel_query->table_mod="6";   
			$channel_query->page=$page;
			$channel_query->query();
			
			$prepage=$channel_query->prepage;
			$nextpage=$channel_query->nextpage;
			$pages=$channel_query->pages;
			$rows_count=$channel_query->rows_count;

			$channel_query->table_mod="5"; 
			$channel_query->table_where="1";     
			$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_record_page[] = array("id"=>$channel_query->record['Id'], 
									  		   "Linkname"=>$channel_query->record['Linkname'],
									  		   "LinkUrl"=>$channel_query->record['LinkUrl']
								   				); 
			} 
			return($channel_record_page);
			$channel_query=NULL;
}	
function Links_query_One($id,$db)
	{
				$channel_query=new mysql_db();
				$channel_query->table=$db."Links"; 
				$channel_query->table_mod="5"; 
				$channel_query->table_where="id=$id";
				$channel_query->limit="0";       
				$channel_query->page_size="1";
				$channel_query->query_object="*"; 
				$channel_query->order_by="id asc";
				$channel_query->query();
				$rows=$channel_query->rows;
				$channel_query->query_result();
				$channel_record  = array("id"=>$channel_query->record['Id'], 
									  "Linkname"=>$channel_query->record['Linkname'],
									  "LinkUrl"=>$channel_query->record['LinkUrl'],
									  ); 
				return($channel_record);
				$channel_query=NULL;
	}
		
function article_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 article_info_query($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="200";
				$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']);
				

				
				$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 download_info_query_all($db)
	{
				$info_query=new mysql_db();
				$info_query->table=$db."download_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']);
				$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'],
									  "down_server1"=>$info_query->record['down_server1'],
									  "down_server2"=>$info_query->record['down_server2'],
									  "down_server3"=>$info_query->record['down_server3'],
									  "down_server4"=>$info_query->record['down_server4'],
									  "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 url_jump($url_location,$url_link,$str_location,$str_link)
{
		echo " <table width='100%' border='0' cellpadding='0' cellspacing='0'>";
		echo "  <tr>";
		echo " <td height='350'><table width='100%' height='35' border='0' cellpadding='0' cellspacing='1' bgcolor='#E8E8E8'>";
		echo " <tr>";
		echo "   <td align='center'  bgcolor='#F6F6F6' style='line-height:250%'>操作成功! 3秒后将自动跳转到默认页面，如果页面没有跳转,请点击这里!<BR>";
		echo "     <a href='".$url_location."'>".$str_location."</a>&nbsp;&nbsp;&nbsp;<a href='".$url_link."'>".$str_link."</a></td>";
		echo " </tr>";
		echo " </table></td>";
		echo " </tr>";
		echo " </table>";
		header("refresh:3;url='".$url_location."'");

}
//错误处理
	function url_error($url_location,$url_link,$str_location,$str_link,$info)
{
		echo " <table width='100%' border='0' cellpadding='0' cellspacing='0'>";
		echo "  <tr>";
		echo " <td height='350'><table width='100%' height='35' border='0' cellpadding='0' cellspacing='1' bgcolor='#E8E8E8'>";
		echo " <tr>";
		echo "   <td align='center'  bgcolor='#F6F6F6' style='line-height:250%'>".$info." 3秒后将自动跳转到默认页面，如果页面没有跳转,请点击这里!<BR>";
		echo "     <a href='".$url_location."'>".$str_location."</a>&nbsp;&nbsp;&nbsp;<a href='".$url_link."'>".$str_link."</a></td>";
		echo " </tr>";
		echo " </table></td>";
		echo " </tr>";
		echo " </table>";
		header("refresh:3;url='".$url_location."'");

}	


?>﻿