<?php 
class newsstr
{
  var $dbz;
  var $str="";
  //获取数据库表前缀
  function newsstr($str){
    $this->dbz=$str;
	return $this->dbz;
  }
  
  //news 作者为0 来源为1
  function newssource($i,$n){
    $str_01="";
    $sql=query("select * from ".$this->dbz."news_source where types='$i' order by id desc");
	while($row=fetch($sql)){
	  if ($n=='0'){
	    $str_01.="<option value=".$row["mg"].">".$row["mg"]."</option>";
	  }
	  elseif(($n=='1')){
	    $str_01.="<a href=\"query.php?rel=news_source_del&id=".$row["id"]."\">删除</a>&nbsp;&nbsp;&nbsp;&nbsp;字段:".$row["mg"]."<br />";
	  }
	}
	return $str_01;
  }
  //获取信息总数
  function newsnum($sqls=''){
    $i=0;
	$sql=query("select id from ".$this->dbz."news ".$sqls." order by id asc");
	$i=rows($sql);
	return $i;
  }
  //评论总数
  function commentsnum($sqls=''){
    $i=0;
	$sql=query("select id from ".$this->dbz."comments ".$sqls." order by id asc");
	$i=rows($sql);
	return $i;
  }
  //获取分类名
  function classnewscid($id,$i_01=0){
    $sql=query("select * from ".$this->dbz."class where id='$id' limit 0,1");
	if ($row=fetch($sql)){
	  if($i_01==0){
	    return "<a href=\"news.php?rel=news&cid=$id\">".$row["names"]."</a>";
	  }
	  elseif($i_01==1){
	    return "<option value=\"".$row["id"].",".$row["trees"]."\" selected=\"selected\" style=\"background-color:#FF9900\">".$row["names"]."</option>";
	  }
	}
  }
  
  
  //信息列表
  function newslist($start,$num,$page,$sqls=''){
    $list='';
	$i=1;
	
    $sql=query("select * from ".$this->dbz."news ".$sqls." order by id desc limit ".$start.",".$num."");
	
	
	while($row=fetch($sql)){
	  if($row["audits"]==0){$audits="[<a href=\"query.php?rel=news_audits&id=".$row["id"]."&num=1&page=$page\">审</a>]";}elseif($row["audits"]==1){$audits="[<a href=\"query.php?rel=news_audits&id=".$row["id"]."&num=0&page=$page\"><font color=red>审</font></a>]";}
	  if($row["vips"]==0){$vips="[<a href=\"query.php?rel=news_vips&id=".$row["id"]."&num=1&page=$page\">荐</a>]";}elseif($row["vips"]==1){$vips="[<a href=\"query.php?rel=news_vips&id=".$row["id"]."&num=0&page=$page\"><font color=red>荐</font></a>]";}
	  if($row["headlines"]==0){$headlines="[<a href=\"query.php?rel=news_headlines&id=".$row["id"]."&num=1&page=$page\">头</a>]";}elseif($row["headlines"]==1){$headlines="[<a href=\"query.php?rel=news_headlines&id=".$row["id"]."&num=0&page=$page\"><font color=red>头</font></a>]";}
	  if($row["slides"]==0){$slides="[<a href=\"query.php?rel=news_slides&id=".$row["id"]."&num=1&page=$page\">幻</a>]";}elseif($row["slides"]==1){$slides="[<a href=\"query.php?rel=news_slides&id=".$row["id"]."&num=0&page=$page\"><font color=red>幻</font></a>]";}
	  if($row["tops"]==0){$tops="[<a href=\"query.php?rel=news_tops&id=".$row["id"]."&num=1&page=$page\">置</a>]";}elseif($row["tops"]==1){$tops="[<a href=\"query.php?rel=news_tops&id=".$row["id"]."&num=0&page=$page\"><font color=red>置</font></a>]";}
	  
	  $list=$list."<tr align=\"center\">
	  <td  height=\"25\" bgcolor=\"#FFFFFF\"><input type=\"checkbox\" name=\"checkbox".$i."\" id=\"checkbox".$i."\" value=\"".$row["id"]."\" />".$row["id"]."</td>
	  <td bgcolor=\"#FFFFFF\" align=\"left\"><a href=\"../news.php?id=".$row["id"]."\" target=\"_blank\">".utf_substr($row["titles"],20)."</a></td>
	  <td bgcolor=\"#FFFFFF\" align=\"left\">".$audits.$vips.$headlines.$slides.$tops."</td>
	  <td bgcolor=\"#FFFFFF\" align=\"left\">".$this->classnewscid($row["cid"])."</td>
	  <td bgcolor=\"#FFFFFF\" align=\"left\"><a href=\"news.php?rel=comments&nid=".$row["id"]."\">查看</a></td>
	  <td bgcolor=\"#FFFFFF\" align=\"left\">".$row["counts"]."</td>
	  <td bgcolor=\"#FFFFFF\" align=\"left\">".$row["top2"]."/".$row["steps"]."</td>
	  <td bgcolor=\"#FFFFFF\" align=\"left\">".$row["times"]."</td>
	  <td bgcolor=\"#FFFFFF\" align=\"left\"><a href=\"html.php?rel=news_html&id=".$row["id"]."&page=$page\">静态</a> <a href=\"news.php?rel=news_info&id=".$row["id"]."&page=$page\">修改</a> <a href=\"query.php?rel=news_del&id=".$row["id"]."&page=$page\">删除</a></td>
	  ";
	  $i=$i+1;
	}
	return $list;
  }
  //信息列表
  function commentslist($start,$num,$page,$sqls=''){
    $list='';
	$i=1;
	
    $sql=query("select * from ".$this->dbz."comments ".$sqls." order by id desc limit ".$start.",".$num."");
	
	
	while($row=fetch($sql)){
	  if($row["audits"]==0){$audits="[<a href=\"query.php?rel=comments_audits&id=".$row["id"]."&num=1&page=$page\">审</a>]";}elseif($row["audits"]==1){$audits="[<a href=\"query.php?rel=comments_audits&id=".$row["id"]."&num=0&page=$page\"><font color=red>审</font></a>]";}
	  
	  
	  $list=$list."<tr align=\"center\">
	  <td  height=\"25\" bgcolor=\"#FFFFFF\"><input type=\"checkbox\" name=\"checkbox".$i."\" id=\"checkbox".$i."\" value=\"".$row["id"]."\" />".$row["id"]."</td>
	  <td bgcolor=\"#FFFFFF\" align=\"left\"><a href=\"../news.php?id=".$row["nid"]."\" target=\"_blank\">".$row["nid"]."</a></td>
	  <td bgcolor=\"#FFFFFF\" align=\"left\"><a href=\"mailto:".$row["mails"]."\">发送</a></td>
	  <td bgcolor=\"#FFFFFF\" align=\"left\"><a href=\"http://wpa.qq.com/msgrd?V=1&Uin=".$row["qqs"]."&Site=http://www.csc9.cn&Menu=yes\">会话</a></td>
	  <td bgcolor=\"#FFFFFF\" align=\"left\">".$audits."</td>
	  <td bgcolor=\"#FFFFFF\" align=\"left\">".$row["ips"]."</td>
	  <td bgcolor=\"#FFFFFF\" align=\"left\">".$row["mg"]."</td>
	  <td bgcolor=\"#FFFFFF\" align=\"left\">".$row["replys"]."</td>
	  <td bgcolor=\"#FFFFFF\" align=\"left\">".$row["times"]."</td>
	  <td bgcolor=\"#FFFFFF\" align=\"left\"><a href=\"news.php?rel=comments_replys&id=".$row["id"]."&page=$page\">回复</a> <a href=\"query.php?rel=comments_del&id=".$row["id"]."&page=$page\">删除</a></td>
	  ";
	  $i=$i+1;
	}
	return $list;
  }
}
?>